PluginProbe
Scrollsequence – Cinematic Scroll Image Animation Plugin / 1.5.5
Scrollsequence – Cinematic Scroll Image Animation Plugin v1.5.5
1.4.3 1.4.4 1.4.5 1.4.6 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.5.9 1.6.0 1.6.1 1.6.2 1.6.3 trunk 0.9.92 0.9.93 0.9.94 0.9.96 1.0.072 1.0.073 All 61 releases
scrollsequence / includes / carbonfields / htmlburger / carbon-fields / packages / blocks / fields / datetime / index.js

index.js in Scrollsequence – Cinematic Scroll Image Animation Plugin 1.5.5, at includes/carbonfields/htmlburger/carbon-fields/packages/blocks/fields/datetime/index.js

97 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /**
2 * External dependencies.
3 */
4 import { format } from '@wordpress/date';
5 import { Component } from '@wordpress/element';
6 import { addFilter } from '@wordpress/hooks';
7 import { __ } from '@wordpress/i18n';
8
9 /**
10 * Internal dependencies.
11 */
12 import './style.scss';
13
14 class DateTimeField extends Component {
15 /**
16 * Handles the change.
17 *
18 * @param {Date[]} selectedDates
19 * @param {string} selectedDateStr
20 * @return {void}
21 */
22 handleChange = ( selectedDates, selectedDateStr ) => {
23 const {
24 id,
25 onChange,
26 value,
27 field
28 } = this.props;
29
30 const formattedDate = format( field.storage_format, selectedDateStr );
31
32 if ( formattedDate !== value ) {
33 onChange( id, formattedDate );
34 }
35 }
36
37 /**
38 * Renders the component.
39 *
40 * @return {Object}
41 */
42 render() {
43 const { handleChange } = this;
44 const { children } = this.props;
45
46 return children( {
47 handleChange
48 } );
49 }
50 }
51
52 addFilter( 'carbon-fields.date_time.block', 'carbon-fields/blocks', ( OriginalDateTimeField ) => ( props ) => {
53 return (
54 <DateTimeField { ...props }>
55 { ( {
56 handleChange
57 } ) => (
58 <OriginalDateTimeField
59 buttonText={ __( 'Select Date', 'carbon-fields-ui' ) }
60 { ...props }
61 onChange={ handleChange }
62 />
63 ) }
64 </DateTimeField>
65 );
66 } );
67
68 addFilter( 'carbon-fields.date.block', 'carbon-fields/blocks', ( OriginalDateField ) => ( props ) => {
69 return (
70 <DateTimeField { ...props }>
71 { ( {
72 handleChange
73 } ) => (
74 <OriginalDateField
75 { ...props }
76 onChange={ handleChange }
77 />
78 ) }
79 </DateTimeField>
80 );
81 } );
82
83 addFilter( 'carbon-fields.time.block', 'carbon-fields/blocks', ( OriginalTimeField ) => ( props ) => {
84 return (
85 <DateTimeField { ...props }>
86 { ( {
87 handleChange
88 } ) => (
89 <OriginalTimeField
90 { ...props }
91 onChange={ handleChange }
92 />
93 ) }
94 </DateTimeField>
95 );
96 } );
97