@wordpress/components 19.11.0 → 19.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +36 -0
- package/README.md +1 -1
- package/build/alignment-matrix-control/index.js +5 -2
- package/build/alignment-matrix-control/index.js.map +1 -1
- package/build/autocomplete/autocompleter-ui.js +1 -1
- package/build/autocomplete/autocompleter-ui.js.map +1 -1
- package/build/autocomplete/autocompleter-ui.native.js +2 -2
- package/build/autocomplete/autocompleter-ui.native.js.map +1 -1
- package/build/autocomplete/index.js +12 -10
- package/build/autocomplete/index.js.map +1 -1
- package/build/border-box-control/border-box-control/hook.js +2 -2
- package/build/border-box-control/border-box-control/hook.js.map +1 -1
- package/build/border-box-control/border-box-control-split-controls/component.js +2 -0
- package/build/border-box-control/border-box-control-split-controls/component.js.map +1 -1
- package/build/border-box-control/border-box-control-split-controls/hook.js +13 -4
- package/build/border-box-control/border-box-control-split-controls/hook.js.map +1 -1
- package/build/border-box-control/border-box-control-visualizer/hook.js +6 -2
- package/build/border-box-control/border-box-control-visualizer/hook.js.map +1 -1
- package/build/border-box-control/styles.js +21 -11
- package/build/border-box-control/styles.js.map +1 -1
- package/build/border-control/border-control/hook.js +2 -2
- package/build/border-control/border-control/hook.js.map +1 -1
- package/build/color-palette/index.js +9 -2
- package/build/color-palette/index.js.map +1 -1
- package/build/color-palette/index.native.js +4 -1
- package/build/color-palette/index.native.js.map +1 -1
- package/build/color-picker/color-copy-button.js +87 -0
- package/build/color-picker/color-copy-button.js.map +1 -0
- package/build/color-picker/component.js +5 -15
- package/build/color-picker/component.js.map +1 -1
- package/build/color-picker/hex-input.js +18 -1
- package/build/color-picker/hex-input.js.map +1 -1
- package/build/color-picker/styles.js +11 -11
- package/build/color-picker/styles.js.map +1 -1
- package/build/custom-gradient-picker/utils.js +1 -1
- package/build/custom-gradient-picker/utils.js.map +1 -1
- package/build/date-time/{date.js → date/index.js} +51 -12
- package/build/date-time/date/index.js.map +1 -0
- package/build/date-time/date/styles.js +70 -0
- package/build/date-time/date/styles.js.map +1 -0
- package/build/date-time/{utils.js → date/utils.js} +0 -0
- package/build/date-time/date/utils.js.map +1 -0
- package/build/date-time/date-time/index.js +175 -0
- package/build/date-time/date-time/index.js.map +1 -0
- package/build/date-time/date-time/styles.js +32 -0
- package/build/date-time/date-time/styles.js.map +1 -0
- package/build/date-time/index.js +2 -109
- package/build/date-time/index.js.map +1 -1
- package/build/date-time/time/index.js +322 -0
- package/build/date-time/time/index.js.map +1 -0
- package/build/date-time/time/styles.js +139 -0
- package/build/date-time/time/styles.js.map +1 -0
- package/build/date-time/{timezone.js → time/timezone.js} +4 -2
- package/build/date-time/time/timezone.js.map +1 -0
- package/build/draggable/index.native.js +10 -5
- package/build/draggable/index.native.js.map +1 -1
- package/build/dropdown/index.js +4 -1
- package/build/dropdown/index.js.map +1 -1
- package/build/input-control/index.js +9 -4
- package/build/input-control/index.js.map +1 -1
- package/build/input-control/input-field.js +1 -26
- package/build/input-control/input-field.js.map +1 -1
- package/build/input-control/reducer/reducer.js +36 -24
- package/build/input-control/reducer/reducer.js.map +1 -1
- package/build/input-control/reducer/state.js +0 -1
- package/build/input-control/reducer/state.js.map +1 -1
- package/build/input-control/utils.js +45 -0
- package/build/input-control/utils.js.map +1 -1
- package/build/popover/index.js +40 -33
- package/build/popover/index.js.map +1 -1
- package/build/search-control/index.js +4 -6
- package/build/search-control/index.js.map +1 -1
- package/build/select-control/index.js +3 -1
- package/build/select-control/index.js.map +1 -1
- package/build/spacer/hook.js +11 -3
- package/build/spacer/hook.js.map +1 -1
- package/build/surface/component.js +7 -7
- package/build/surface/component.js.map +1 -1
- package/build/surface/hook.js +8 -11
- package/build/surface/hook.js.map +1 -1
- package/build/surface/index.js.map +1 -1
- package/build/surface/styles.js +8 -48
- package/build/surface/styles.js.map +1 -1
- package/build/textarea-control/index.js +40 -6
- package/build/textarea-control/index.js.map +1 -1
- package/build/textarea-control/styles/textarea-control-styles.js +3 -3
- package/build/textarea-control/styles/textarea-control-styles.js.map +1 -1
- package/build/textarea-control/types.js +6 -0
- package/build/textarea-control/types.js.map +1 -0
- package/build/utils/hooks/index.js +0 -8
- package/build/utils/hooks/index.js.map +1 -1
- package/build-module/alignment-matrix-control/index.js +5 -2
- package/build-module/alignment-matrix-control/index.js.map +1 -1
- package/build-module/autocomplete/autocompleter-ui.js +1 -1
- package/build-module/autocomplete/autocompleter-ui.js.map +1 -1
- package/build-module/autocomplete/autocompleter-ui.native.js +2 -2
- package/build-module/autocomplete/autocompleter-ui.native.js.map +1 -1
- package/build-module/autocomplete/index.js +13 -11
- package/build-module/autocomplete/index.js.map +1 -1
- package/build-module/border-box-control/border-box-control/hook.js +2 -2
- package/build-module/border-box-control/border-box-control/hook.js.map +1 -1
- package/build-module/border-box-control/border-box-control-split-controls/component.js +2 -0
- package/build-module/border-box-control/border-box-control-split-controls/component.js.map +1 -1
- package/build-module/border-box-control/border-box-control-split-controls/hook.js +11 -4
- package/build-module/border-box-control/border-box-control-split-controls/hook.js.map +1 -1
- package/build-module/border-box-control/border-box-control-visualizer/hook.js +4 -2
- package/build-module/border-box-control/border-box-control-visualizer/hook.js.map +1 -1
- package/build-module/border-box-control/styles.js +13 -8
- package/build-module/border-box-control/styles.js.map +1 -1
- package/build-module/border-control/border-control/hook.js +2 -2
- package/build-module/border-control/border-control/hook.js.map +1 -1
- package/build-module/color-palette/index.js +7 -5
- package/build-module/color-palette/index.js.map +1 -1
- package/build-module/color-palette/index.native.js +4 -1
- package/build-module/color-palette/index.native.js.map +1 -1
- package/build-module/color-picker/color-copy-button.js +73 -0
- package/build-module/color-picker/color-copy-button.js.map +1 -0
- package/build-module/color-picker/component.js +6 -15
- package/build-module/color-picker/component.js.map +1 -1
- package/build-module/color-picker/hex-input.js +18 -1
- package/build-module/color-picker/hex-input.js.map +1 -1
- package/build-module/color-picker/styles.js +9 -9
- package/build-module/color-picker/styles.js.map +1 -1
- package/build-module/custom-gradient-picker/utils.js +1 -1
- package/build-module/custom-gradient-picker/utils.js.map +1 -1
- package/build-module/date-time/{date.js → date/index.js} +46 -14
- package/build-module/date-time/date/index.js.map +1 -0
- package/build-module/date-time/date/styles.js +61 -0
- package/build-module/date-time/date/styles.js.map +1 -0
- package/build-module/date-time/{utils.js → date/utils.js} +0 -0
- package/build-module/date-time/date/utils.js.map +1 -0
- package/build-module/date-time/date-time/index.js +144 -0
- package/build-module/date-time/date-time/index.js.map +1 -0
- package/build-module/date-time/date-time/styles.js +22 -0
- package/build-module/date-time/date-time/styles.js.map +1 -0
- package/build-module/date-time/index.js +1 -105
- package/build-module/date-time/index.js.map +1 -1
- package/build-module/date-time/time/index.js +302 -0
- package/build-module/date-time/time/index.js.map +1 -0
- package/build-module/date-time/time/styles.js +118 -0
- package/build-module/date-time/time/styles.js.map +1 -0
- package/build-module/date-time/{timezone.js → time/timezone.js} +3 -2
- package/build-module/date-time/time/timezone.js.map +1 -0
- package/build-module/draggable/index.native.js +10 -5
- package/build-module/draggable/index.native.js.map +1 -1
- package/build-module/dropdown/index.js +4 -1
- package/build-module/dropdown/index.js.map +1 -1
- package/build-module/input-control/index.js +8 -4
- package/build-module/input-control/index.js.map +1 -1
- package/build-module/input-control/input-field.js +1 -25
- package/build-module/input-control/input-field.js.map +1 -1
- package/build-module/input-control/reducer/reducer.js +38 -26
- package/build-module/input-control/reducer/reducer.js.map +1 -1
- package/build-module/input-control/reducer/state.js +0 -1
- package/build-module/input-control/reducer/state.js.map +1 -1
- package/build-module/input-control/utils.js +48 -2
- package/build-module/input-control/utils.js.map +1 -1
- package/build-module/popover/index.js +40 -33
- package/build-module/popover/index.js.map +1 -1
- package/build-module/search-control/index.js +6 -7
- package/build-module/search-control/index.js.map +1 -1
- package/build-module/select-control/index.js +3 -1
- package/build-module/select-control/index.js.map +1 -1
- package/build-module/spacer/hook.js +10 -2
- package/build-module/spacer/hook.js.map +1 -1
- package/build-module/surface/component.js +7 -7
- package/build-module/surface/component.js.map +1 -1
- package/build-module/surface/hook.js +8 -11
- package/build-module/surface/hook.js.map +1 -1
- package/build-module/surface/index.js.map +1 -1
- package/build-module/surface/styles.js +8 -48
- package/build-module/surface/styles.js.map +1 -1
- package/build-module/textarea-control/index.js +36 -5
- package/build-module/textarea-control/index.js.map +1 -1
- package/build-module/textarea-control/styles/textarea-control-styles.js +3 -3
- package/build-module/textarea-control/styles/textarea-control-styles.js.map +1 -1
- package/build-module/textarea-control/types.js +2 -0
- package/build-module/textarea-control/types.js.map +1 -0
- package/build-module/utils/hooks/index.js +0 -1
- package/build-module/utils/hooks/index.js.map +1 -1
- package/build-style/style-rtl.css +13 -188
- package/build-style/style.css +13 -191
- package/build-types/border-box-control/border-box-control-split-controls/component.d.ts.map +1 -1
- package/build-types/border-box-control/border-box-control-split-controls/hook.d.ts +1 -0
- package/build-types/border-box-control/border-box-control-split-controls/hook.d.ts.map +1 -1
- package/build-types/border-box-control/border-box-control-visualizer/hook.d.ts.map +1 -1
- package/build-types/border-box-control/styles.d.ts +3 -2
- package/build-types/border-box-control/styles.d.ts.map +1 -1
- package/build-types/border-control/border-control/hook.d.ts.map +1 -1
- package/build-types/card/types.d.ts +1 -1
- package/build-types/card/types.d.ts.map +1 -1
- package/build-types/checkbox-control/test/index.d.ts +2 -0
- package/build-types/checkbox-control/test/index.d.ts.map +1 -0
- package/build-types/color-palette/index.d.ts +1 -0
- package/build-types/color-palette/index.d.ts.map +1 -1
- package/build-types/{date-time → color-palette}/test/utils.d.ts +0 -0
- package/build-types/color-palette/test/utils.d.ts.map +1 -0
- package/build-types/color-picker/color-copy-button.d.ts +4 -0
- package/build-types/color-picker/color-copy-button.d.ts.map +1 -0
- package/build-types/color-picker/component.d.ts.map +1 -1
- package/build-types/color-picker/hex-input.d.ts.map +1 -1
- package/build-types/color-picker/styles.d.ts +1 -1
- package/build-types/color-picker/styles.d.ts.map +1 -1
- package/build-types/color-picker/types.d.ts +8 -0
- package/build-types/color-picker/types.d.ts.map +1 -1
- package/build-types/date-time/{date.d.ts → date/index.d.ts} +3 -2
- package/build-types/date-time/date/index.d.ts.map +1 -0
- package/build-types/date-time/date/styles.d.ts +23 -0
- package/build-types/date-time/date/styles.d.ts.map +1 -0
- package/build-types/date-time/date/test/index.d.ts +2 -0
- package/build-types/date-time/date/test/index.d.ts.map +1 -0
- package/build-types/date-time/date/test/utils.d.ts +2 -0
- package/build-types/date-time/date/test/utils.d.ts.map +1 -0
- package/build-types/date-time/{utils.d.ts → date/utils.d.ts} +0 -0
- package/build-types/date-time/date/utils.d.ts.map +1 -0
- package/build-types/date-time/date-time/index.d.ts +33 -0
- package/build-types/date-time/date-time/index.d.ts.map +1 -0
- package/build-types/date-time/date-time/styles.d.ts +6 -0
- package/build-types/date-time/date-time/styles.d.ts.map +1 -0
- package/build-types/date-time/index.d.ts +2 -28
- package/build-types/date-time/index.d.ts.map +1 -1
- package/build-types/date-time/stories/{index.d.ts → date-time.d.ts} +2 -2
- package/build-types/date-time/stories/date-time.d.ts.map +1 -0
- package/build-types/date-time/{time.d.ts → time/index.d.ts} +2 -2
- package/build-types/date-time/time/index.d.ts.map +1 -0
- package/build-types/date-time/time/styles.d.ts +111 -0
- package/build-types/date-time/time/styles.d.ts.map +1 -0
- package/build-types/date-time/time/test/index.d.ts +2 -0
- package/build-types/date-time/time/test/index.d.ts.map +1 -0
- package/build-types/date-time/{timezone.d.ts → time/timezone.d.ts} +0 -0
- package/build-types/date-time/time/timezone.d.ts.map +1 -0
- package/build-types/date-time/types.d.ts +14 -15
- package/build-types/date-time/types.d.ts.map +1 -1
- package/build-types/dropdown/index.d.ts.map +1 -1
- package/build-types/input-control/index.d.ts.map +1 -1
- package/build-types/input-control/input-field.d.ts.map +1 -1
- package/build-types/input-control/reducer/reducer.d.ts +5 -3
- package/build-types/input-control/reducer/reducer.d.ts.map +1 -1
- package/build-types/input-control/reducer/state.d.ts +2 -2
- package/build-types/input-control/reducer/state.d.ts.map +1 -1
- package/build-types/input-control/utils.d.ts +17 -0
- package/build-types/input-control/utils.d.ts.map +1 -1
- package/build-types/popover/index.d.ts +1 -0
- package/build-types/popover/index.d.ts.map +1 -1
- package/build-types/select-control/index.d.ts.map +1 -1
- package/build-types/select-control/types.d.ts +1 -1
- package/build-types/select-control/types.d.ts.map +1 -1
- package/build-types/surface/component.d.ts +3 -2
- package/build-types/surface/component.d.ts.map +1 -1
- package/build-types/surface/hook.d.ts +4 -4
- package/build-types/surface/hook.d.ts.map +1 -1
- package/build-types/surface/index.d.ts +2 -2
- package/build-types/surface/index.d.ts.map +1 -1
- package/build-types/surface/stories/index.d.ts +12 -0
- package/build-types/surface/stories/index.d.ts.map +1 -0
- package/build-types/surface/styles.d.ts +10 -21
- package/build-types/surface/styles.d.ts.map +1 -1
- package/build-types/surface/test/index.d.ts +2 -0
- package/build-types/surface/test/index.d.ts.map +1 -0
- package/build-types/surface/types.d.ts +1 -1
- package/build-types/surface/types.d.ts.map +1 -1
- package/build-types/textarea-control/index.d.ts +29 -0
- package/build-types/textarea-control/index.d.ts.map +1 -0
- package/build-types/textarea-control/stories/index.d.ts +12 -0
- package/build-types/textarea-control/stories/index.d.ts.map +1 -0
- package/build-types/textarea-control/styles/textarea-control-styles.d.ts +6 -0
- package/build-types/textarea-control/styles/textarea-control-styles.d.ts.map +1 -0
- package/build-types/textarea-control/types.d.ts +26 -0
- package/build-types/textarea-control/types.d.ts.map +1 -0
- package/build-types/utils/hooks/index.d.ts +0 -1
- package/package.json +18 -18
- package/src/alignment-matrix-control/index.js +4 -2
- package/src/autocomplete/autocompleter-ui.js +1 -1
- package/src/autocomplete/autocompleter-ui.native.js +2 -2
- package/src/autocomplete/index.js +21 -9
- package/src/border-box-control/border-box-control/hook.ts +2 -2
- package/src/border-box-control/border-box-control-split-controls/component.tsx +2 -0
- package/src/border-box-control/border-box-control-split-controls/hook.ts +18 -4
- package/src/border-box-control/border-box-control-visualizer/hook.ts +5 -2
- package/src/border-box-control/styles.ts +6 -2
- package/src/border-control/border-control/hook.ts +8 -2
- package/src/box-control/test/index.js +120 -109
- package/src/card/types.ts +1 -1
- package/src/checkbox-control/test/__snapshots__/index.tsx.snap +42 -0
- package/src/checkbox-control/test/index.tsx +109 -0
- package/src/color-palette/index.js +11 -4
- package/src/color-palette/index.native.js +3 -0
- package/src/color-palette/stories/index.js +25 -1
- package/src/color-palette/test/utils.ts +24 -0
- package/src/color-picker/color-copy-button.tsx +76 -0
- package/src/color-picker/component.tsx +18 -38
- package/src/color-picker/hex-input.tsx +16 -0
- package/src/color-picker/styles.ts +5 -1
- package/src/color-picker/types.ts +9 -0
- package/src/custom-gradient-picker/utils.js +1 -1
- package/src/date-time/README.md +16 -0
- package/src/date-time/{datepicker.scss → date/datepicker.scss} +0 -0
- package/src/date-time/{date.tsx → date/index.tsx} +38 -15
- package/src/date-time/date/style.scss +75 -0
- package/src/date-time/date/styles.ts +55 -0
- package/src/date-time/{test/date.tsx → date/test/index.tsx} +1 -1
- package/src/date-time/{test → date/test}/utils.ts +0 -0
- package/src/date-time/{utils.ts → date/utils.ts} +0 -0
- package/src/date-time/date-time/index.tsx +217 -0
- package/src/date-time/date-time/styles.ts +8 -0
- package/src/date-time/index.ts +9 -0
- package/src/date-time/stories/{index.tsx → date-time.tsx} +1 -1
- package/src/date-time/style.scss +1 -262
- package/src/date-time/time/index.tsx +356 -0
- package/src/date-time/time/styles.ts +119 -0
- package/src/date-time/{test/time.tsx → time/test/index.tsx} +85 -38
- package/src/date-time/{timezone.tsx → time/timezone.tsx} +5 -2
- package/src/date-time/types.ts +16 -18
- package/src/draggable/index.native.js +14 -3
- package/src/draggable/test/index.native.js +130 -0
- package/src/dropdown/index.js +5 -1
- package/src/input-control/index.tsx +8 -2
- package/src/input-control/input-field.tsx +10 -30
- package/src/input-control/reducer/reducer.ts +40 -26
- package/src/input-control/reducer/state.ts +2 -3
- package/src/input-control/utils.ts +55 -1
- package/src/popover/index.js +42 -27
- package/src/query-controls/README.md +1 -1
- package/src/search-control/index.js +6 -7
- package/src/select-control/README.md +11 -0
- package/src/select-control/index.tsx +6 -1
- package/src/select-control/types.ts +1 -1
- package/src/slot-fill/README.md +1 -1
- package/src/spacer/hook.ts +13 -13
- package/src/surface/README.md +15 -15
- package/src/surface/{component.js → component.tsx} +13 -7
- package/src/surface/{hook.js → hook.ts} +13 -12
- package/src/surface/{index.js → index.ts} +0 -0
- package/src/surface/stories/index.tsx +40 -0
- package/src/surface/{styles.js → styles.ts} +15 -44
- package/src/surface/test/__snapshots__/{index.js.snap → index.tsx.snap} +0 -0
- package/src/surface/test/{index.js → index.tsx} +2 -1
- package/src/surface/types.ts +1 -1
- package/src/textarea-control/README.md +14 -20
- package/src/textarea-control/index.tsx +86 -0
- package/src/textarea-control/stories/index.tsx +58 -0
- package/src/textarea-control/styles/{textarea-control-styles.js → textarea-control-styles.ts} +0 -0
- package/src/textarea-control/types.ts +30 -0
- package/src/utils/hooks/index.js +0 -1
- package/tsconfig.json +1 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/build/color-picker/color-display.js +0 -184
- package/build/color-picker/color-display.js.map +0 -1
- package/build/date-time/date.js.map +0 -1
- package/build/date-time/time.js +0 -289
- package/build/date-time/time.js.map +0 -1
- package/build/date-time/timezone.js.map +0 -1
- package/build/date-time/utils.js.map +0 -1
- package/build/utils/hooks/use-combined-ref.js +0 -32
- package/build/utils/hooks/use-combined-ref.js.map +0 -1
- package/build-module/color-picker/color-display.js +0 -170
- package/build-module/color-picker/color-display.js.map +0 -1
- package/build-module/date-time/date.js.map +0 -1
- package/build-module/date-time/time.js +0 -271
- package/build-module/date-time/time.js.map +0 -1
- package/build-module/date-time/timezone.js.map +0 -1
- package/build-module/date-time/utils.js.map +0 -1
- package/build-module/utils/hooks/use-combined-ref.js +0 -28
- package/build-module/utils/hooks/use-combined-ref.js.map +0 -1
- package/build-types/color-picker/color-display.d.ts +0 -14
- package/build-types/color-picker/color-display.d.ts.map +0 -1
- package/build-types/date-time/date.d.ts.map +0 -1
- package/build-types/date-time/stories/index.d.ts.map +0 -1
- package/build-types/date-time/test/date.d.ts +0 -2
- package/build-types/date-time/test/date.d.ts.map +0 -1
- package/build-types/date-time/test/time.d.ts +0 -2
- package/build-types/date-time/test/time.d.ts.map +0 -1
- package/build-types/date-time/test/utils.d.ts.map +0 -1
- package/build-types/date-time/time.d.ts.map +0 -1
- package/build-types/date-time/timezone.d.ts.map +0 -1
- package/build-types/date-time/utils.d.ts.map +0 -1
- package/build-types/utils/hooks/use-combined-ref.d.ts +0 -8
- package/build-types/utils/hooks/use-combined-ref.d.ts.map +0 -1
- package/src/color-picker/color-display.tsx +0 -169
- package/src/date-time/index.tsx +0 -196
- package/src/date-time/time.tsx +0 -321
- package/src/surface/stories/index.js +0 -46
- package/src/textarea-control/index.js +0 -45
- package/src/textarea-control/stories/index.js +0 -48
- package/src/utils/hooks/use-combined-ref.ts +0 -28
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { noop } from 'lodash';
|
|
5
|
+
import type { ForwardedRef } from 'react';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* WordPress dependencies
|
|
9
|
+
*/
|
|
10
|
+
import { useState, forwardRef } from '@wordpress/element';
|
|
11
|
+
import { __, _x } from '@wordpress/i18n';
|
|
12
|
+
import deprecated from '@wordpress/deprecated';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Internal dependencies
|
|
16
|
+
*/
|
|
17
|
+
import Button from '../../button';
|
|
18
|
+
import { default as DatePicker } from '../date';
|
|
19
|
+
import { default as TimePicker } from '../time';
|
|
20
|
+
import type { DateTimePickerProps } from '../types';
|
|
21
|
+
import { CalendarHelp } from './styles';
|
|
22
|
+
import { HStack } from '../../h-stack';
|
|
23
|
+
import { Heading } from '../../heading';
|
|
24
|
+
import { Spacer } from '../../spacer';
|
|
25
|
+
|
|
26
|
+
export { DatePicker, TimePicker };
|
|
27
|
+
|
|
28
|
+
function UnforwardedDateTimePicker(
|
|
29
|
+
{
|
|
30
|
+
currentDate,
|
|
31
|
+
is12Hour,
|
|
32
|
+
isInvalidDate,
|
|
33
|
+
onMonthPreviewed = noop,
|
|
34
|
+
onChange,
|
|
35
|
+
events,
|
|
36
|
+
__nextRemoveHelpButton = false,
|
|
37
|
+
__nextRemoveResetButton = false,
|
|
38
|
+
}: DateTimePickerProps,
|
|
39
|
+
ref: ForwardedRef< any >
|
|
40
|
+
) {
|
|
41
|
+
if ( ! __nextRemoveHelpButton ) {
|
|
42
|
+
deprecated( 'Help button in wp.components.DateTimePicker', {
|
|
43
|
+
since: '13.4',
|
|
44
|
+
version: '14.6', // Six months of plugin releases.
|
|
45
|
+
hint:
|
|
46
|
+
'Set the `__nextRemoveHelpButton` prop to `true` to remove this warning and opt in to the new behaviour, which will become the default in a future version.',
|
|
47
|
+
} );
|
|
48
|
+
}
|
|
49
|
+
if ( ! __nextRemoveResetButton ) {
|
|
50
|
+
deprecated( 'Reset button in wp.components.DateTimePicker', {
|
|
51
|
+
since: '13.4',
|
|
52
|
+
version: '14.6', // Six months of plugin releases.
|
|
53
|
+
hint:
|
|
54
|
+
'Set the `__nextRemoveResetButton` prop to `true` to remove this warning and opt in to the new behaviour, which will become the default in a future version.',
|
|
55
|
+
} );
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const [ calendarHelpIsVisible, setCalendarHelpIsVisible ] = useState(
|
|
59
|
+
false
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
function onClickDescriptionToggle() {
|
|
63
|
+
setCalendarHelpIsVisible( ! calendarHelpIsVisible );
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return (
|
|
67
|
+
<div ref={ ref } className="components-datetime">
|
|
68
|
+
{ ! calendarHelpIsVisible && (
|
|
69
|
+
<>
|
|
70
|
+
<TimePicker
|
|
71
|
+
currentTime={ currentDate }
|
|
72
|
+
onChange={ onChange }
|
|
73
|
+
is12Hour={ is12Hour }
|
|
74
|
+
/>
|
|
75
|
+
<DatePicker
|
|
76
|
+
currentDate={ currentDate }
|
|
77
|
+
onChange={ onChange }
|
|
78
|
+
isInvalidDate={ isInvalidDate }
|
|
79
|
+
events={ events }
|
|
80
|
+
onMonthPreviewed={ onMonthPreviewed }
|
|
81
|
+
/>
|
|
82
|
+
</>
|
|
83
|
+
) }
|
|
84
|
+
{ calendarHelpIsVisible && (
|
|
85
|
+
<CalendarHelp
|
|
86
|
+
className="components-datetime__calendar-help" // Unused, for backwards compatibility.
|
|
87
|
+
>
|
|
88
|
+
<Heading level={ 4 }>{ __( 'Click to Select' ) }</Heading>
|
|
89
|
+
<ul>
|
|
90
|
+
<li>
|
|
91
|
+
{ __(
|
|
92
|
+
'Click the right or left arrows to select other months in the past or the future.'
|
|
93
|
+
) }
|
|
94
|
+
</li>
|
|
95
|
+
<li>{ __( 'Click the desired day to select it.' ) }</li>
|
|
96
|
+
</ul>
|
|
97
|
+
<Heading level={ 4 }>
|
|
98
|
+
{ __( 'Navigating with a keyboard' ) }
|
|
99
|
+
</Heading>
|
|
100
|
+
<ul>
|
|
101
|
+
<li>
|
|
102
|
+
<abbr
|
|
103
|
+
aria-label={ _x( 'Enter', 'keyboard button' ) }
|
|
104
|
+
>
|
|
105
|
+
↵
|
|
106
|
+
</abbr>
|
|
107
|
+
{
|
|
108
|
+
' ' /* JSX removes whitespace, but a space is required for screen readers. */
|
|
109
|
+
}
|
|
110
|
+
<span>{ __( 'Select the date in focus.' ) }</span>
|
|
111
|
+
</li>
|
|
112
|
+
<li>
|
|
113
|
+
<abbr aria-label={ __( 'Left and Right Arrows' ) }>
|
|
114
|
+
←/→
|
|
115
|
+
</abbr>
|
|
116
|
+
{
|
|
117
|
+
' ' /* JSX removes whitespace, but a space is required for screen readers. */
|
|
118
|
+
}
|
|
119
|
+
{ __(
|
|
120
|
+
'Move backward (left) or forward (right) by one day.'
|
|
121
|
+
) }
|
|
122
|
+
</li>
|
|
123
|
+
<li>
|
|
124
|
+
<abbr aria-label={ __( 'Up and Down Arrows' ) }>
|
|
125
|
+
↑/↓
|
|
126
|
+
</abbr>
|
|
127
|
+
{
|
|
128
|
+
' ' /* JSX removes whitespace, but a space is required for screen readers. */
|
|
129
|
+
}
|
|
130
|
+
{ __(
|
|
131
|
+
'Move backward (up) or forward (down) by one week.'
|
|
132
|
+
) }
|
|
133
|
+
</li>
|
|
134
|
+
<li>
|
|
135
|
+
<abbr aria-label={ __( 'Page Up and Page Down' ) }>
|
|
136
|
+
{ __( 'PgUp/PgDn' ) }
|
|
137
|
+
</abbr>
|
|
138
|
+
{
|
|
139
|
+
' ' /* JSX removes whitespace, but a space is required for screen readers. */
|
|
140
|
+
}
|
|
141
|
+
{ __(
|
|
142
|
+
'Move backward (PgUp) or forward (PgDn) by one month.'
|
|
143
|
+
) }
|
|
144
|
+
</li>
|
|
145
|
+
<li>
|
|
146
|
+
<abbr aria-label={ __( 'Home and End' ) }>
|
|
147
|
+
{ /* Translators: Home/End reffer to the 'Home' and 'End' buttons on the keyboard.*/ }
|
|
148
|
+
{ __( 'Home/End' ) }
|
|
149
|
+
</abbr>
|
|
150
|
+
{
|
|
151
|
+
' ' /* JSX removes whitespace, but a space is required for screen readers. */
|
|
152
|
+
}
|
|
153
|
+
{ __(
|
|
154
|
+
'Go to the first (Home) or last (End) day of a week.'
|
|
155
|
+
) }
|
|
156
|
+
</li>
|
|
157
|
+
</ul>
|
|
158
|
+
</CalendarHelp>
|
|
159
|
+
) }
|
|
160
|
+
{ ( ! __nextRemoveResetButton || ! __nextRemoveHelpButton ) && (
|
|
161
|
+
<HStack
|
|
162
|
+
className="components-datetime__buttons" // Unused, for backwards compatibility.
|
|
163
|
+
>
|
|
164
|
+
{ ! __nextRemoveResetButton &&
|
|
165
|
+
! calendarHelpIsVisible &&
|
|
166
|
+
currentDate && (
|
|
167
|
+
<Button
|
|
168
|
+
className="components-datetime__date-reset-button" // Unused, for backwards compatibility.
|
|
169
|
+
variant="link"
|
|
170
|
+
onClick={ () => onChange?.( null ) }
|
|
171
|
+
>
|
|
172
|
+
{ __( 'Reset' ) }
|
|
173
|
+
</Button>
|
|
174
|
+
) }
|
|
175
|
+
<Spacer />
|
|
176
|
+
{ ! __nextRemoveHelpButton && (
|
|
177
|
+
<Button
|
|
178
|
+
className="components-datetime__date-help-toggle" // Unused, for backwards compatibility.
|
|
179
|
+
variant="link"
|
|
180
|
+
onClick={ onClickDescriptionToggle }
|
|
181
|
+
>
|
|
182
|
+
{ calendarHelpIsVisible
|
|
183
|
+
? __( 'Close' )
|
|
184
|
+
: __( 'Calendar Help' ) }
|
|
185
|
+
</Button>
|
|
186
|
+
) }
|
|
187
|
+
</HStack>
|
|
188
|
+
) }
|
|
189
|
+
</div>
|
|
190
|
+
);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* DateTimePicker is a React component that renders a calendar and clock for
|
|
195
|
+
* date and time selection. The calendar and clock components can be accessed
|
|
196
|
+
* individually using the `DatePicker` and `TimePicker` components respectively.
|
|
197
|
+
*
|
|
198
|
+
* ```jsx
|
|
199
|
+
* import { DateTimePicker } from '@wordpress/components';
|
|
200
|
+
* import { useState } from '@wordpress/element';
|
|
201
|
+
*
|
|
202
|
+
* const MyDateTimePicker = () => {
|
|
203
|
+
* const [ date, setDate ] = useState( new Date() );
|
|
204
|
+
*
|
|
205
|
+
* return (
|
|
206
|
+
* <DateTimePicker
|
|
207
|
+
* currentDate={ date }
|
|
208
|
+
* onChange={ ( newDate ) => setDate( newDate ) }
|
|
209
|
+
* is12Hour
|
|
210
|
+
* />
|
|
211
|
+
* );
|
|
212
|
+
* };
|
|
213
|
+
* ```
|
|
214
|
+
*/
|
|
215
|
+
export const DateTimePicker = forwardRef( UnforwardedDateTimePicker );
|
|
216
|
+
|
|
217
|
+
export default DateTimePicker;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { default as DatePicker } from './date';
|
|
5
|
+
import { default as TimePicker } from './time';
|
|
6
|
+
import { default as DateTimePicker } from './date-time';
|
|
7
|
+
|
|
8
|
+
export { DatePicker, TimePicker };
|
|
9
|
+
export default DateTimePicker;
|
|
@@ -11,7 +11,7 @@ import { useState, useEffect } from '@wordpress/element';
|
|
|
11
11
|
/**
|
|
12
12
|
* Internal dependencies
|
|
13
13
|
*/
|
|
14
|
-
import DateTimePicker from '
|
|
14
|
+
import DateTimePicker from '../date-time';
|
|
15
15
|
import { daysFromNow, isWeekend } from './utils';
|
|
16
16
|
|
|
17
17
|
const meta: ComponentMeta< typeof DateTimePicker > = {
|
package/src/date-time/style.scss
CHANGED
|
@@ -1,262 +1 @@
|
|
|
1
|
-
@import "./
|
|
2
|
-
|
|
3
|
-
.components-datetime {
|
|
4
|
-
// This padding is leveraged when the component is used alone,
|
|
5
|
-
// usually inside popovers.
|
|
6
|
-
padding: $grid-unit-20;
|
|
7
|
-
|
|
8
|
-
// This rule removes the padding when used inside a panel.
|
|
9
|
-
.components-panel__body & {
|
|
10
|
-
padding: 0;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
.components-datetime__calendar-help {
|
|
14
|
-
padding: $grid-unit-20;
|
|
15
|
-
min-width: 260px;
|
|
16
|
-
|
|
17
|
-
h4 {
|
|
18
|
-
margin: 0;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
.components-datetime__buttons {
|
|
23
|
-
display: flex;
|
|
24
|
-
justify-content: space-between;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
.components-datetime__date-help-toggle {
|
|
28
|
-
display: block;
|
|
29
|
-
margin-left: auto;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
fieldset {
|
|
33
|
-
border: 0;
|
|
34
|
-
padding: 0;
|
|
35
|
-
margin: 0;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
select,
|
|
39
|
-
input {
|
|
40
|
-
@include input-style__neutral();
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
// Override inherited conflicting styles to be consistent.
|
|
44
|
-
select,
|
|
45
|
-
input[type="number"],
|
|
46
|
-
.components-button {
|
|
47
|
-
height: 30px;
|
|
48
|
-
margin-top: 0;
|
|
49
|
-
margin-bottom: 0;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
.components-button:focus {
|
|
53
|
-
z-index: z-index(".components-button {:focus or .is-primary}");
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
.components-datetime__date {
|
|
58
|
-
min-height: 236px;
|
|
59
|
-
border-top: 1px solid $gray-300;
|
|
60
|
-
|
|
61
|
-
// Override external DatePicker styles.
|
|
62
|
-
.DayPickerNavigation_leftButton__horizontalDefault {
|
|
63
|
-
/*!rtl:begin:ignore*/
|
|
64
|
-
left: 13px;
|
|
65
|
-
/*!rtl:end:ignore*/
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
.CalendarMonth_caption {
|
|
69
|
-
font-size: $default-font-size;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// Seperate borders so that border respect border radius
|
|
73
|
-
.CalendarMonth_table {
|
|
74
|
-
border-collapse: separate;
|
|
75
|
-
border-spacing: 2px;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
.CalendarDay {
|
|
79
|
-
font-size: $default-font-size;
|
|
80
|
-
border: none;
|
|
81
|
-
border-radius: $radius-round;
|
|
82
|
-
text-align: center;
|
|
83
|
-
|
|
84
|
-
&:focus {
|
|
85
|
-
box-shadow: inset 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color), inset 0 0 0 #{ $border-width-focus + $border-width } $white;
|
|
86
|
-
outline: 2px solid transparent; // Shown in Windows 10 high contrast mode.
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
.CalendarDay__selected {
|
|
91
|
-
background: var(--wp-admin-theme-color);
|
|
92
|
-
border: 2px solid transparent; // This indicates selection in Windows 10 high contrast mode.
|
|
93
|
-
|
|
94
|
-
&:hover {
|
|
95
|
-
background: var(--wp-admin-theme-color-darker-20);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
&:focus {
|
|
99
|
-
box-shadow: inset 0 0 0 $border-width $white;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
.DayPickerNavigation_button__horizontalDefault {
|
|
104
|
-
padding: 2px 8px;
|
|
105
|
-
top: 20px;
|
|
106
|
-
|
|
107
|
-
&:focus {
|
|
108
|
-
@include input-style__focus();
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
.DayPicker_weekHeader {
|
|
113
|
-
top: 50px;
|
|
114
|
-
.DayPicker_weekHeader_ul {
|
|
115
|
-
margin: 1px;
|
|
116
|
-
padding-left: 0;
|
|
117
|
-
padding-right: 0;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
&.is-description-visible .DayPicker {
|
|
122
|
-
visibility: hidden;
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
.components-datetime__date .CalendarDay .components-datetime__date__day {
|
|
127
|
-
height: 100%;
|
|
128
|
-
display: flex;
|
|
129
|
-
justify-content: center;
|
|
130
|
-
align-content: center;
|
|
131
|
-
flex-direction: column;
|
|
132
|
-
position: relative;
|
|
133
|
-
|
|
134
|
-
&.has-events::before {
|
|
135
|
-
content: " ";
|
|
136
|
-
width: 4px;
|
|
137
|
-
height: 4px;
|
|
138
|
-
border-radius: 2px;
|
|
139
|
-
position: absolute;
|
|
140
|
-
left: 50%;
|
|
141
|
-
margin-left: -2px;
|
|
142
|
-
bottom: 0;
|
|
143
|
-
background-color: $white;
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
.components-datetime__date .CalendarDay:not(.CalendarDay__selected) .components-datetime__date__day.has-events::before {
|
|
148
|
-
background: var(--wp-admin-theme-color);
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
.components-datetime__time {
|
|
152
|
-
padding-bottom: $grid-unit-20;
|
|
153
|
-
|
|
154
|
-
fieldset {
|
|
155
|
-
position: relative;
|
|
156
|
-
margin-bottom: 0.5em;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
fieldset + fieldset {
|
|
160
|
-
margin-bottom: 0;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
.components-datetime__time-field-am-pm fieldset {
|
|
164
|
-
margin-top: 0;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
.components-datetime__time-wrapper {
|
|
168
|
-
display: flex;
|
|
169
|
-
|
|
170
|
-
.components-datetime__time-separator {
|
|
171
|
-
display: inline-block;
|
|
172
|
-
padding: 0 3px 0 0;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
.components-datetime__time-field {
|
|
176
|
-
|
|
177
|
-
&-time {
|
|
178
|
-
/*rtl:ignore*/
|
|
179
|
-
direction: ltr;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
select {
|
|
183
|
-
margin-right: $grid-unit-05;
|
|
184
|
-
|
|
185
|
-
&:focus {
|
|
186
|
-
position: relative;
|
|
187
|
-
z-index: 1;
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
input[type="number"] {
|
|
192
|
-
padding: 2px;
|
|
193
|
-
margin-right: $grid-unit-05;
|
|
194
|
-
text-align: center;
|
|
195
|
-
-moz-appearance: textfield;
|
|
196
|
-
|
|
197
|
-
&:focus {
|
|
198
|
-
position: relative;
|
|
199
|
-
z-index: 1;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
&::-webkit-inner-spin-button {
|
|
203
|
-
-webkit-appearance: none;
|
|
204
|
-
margin: 0;
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
// Makes the month appear before the day if time format uses AM/PM
|
|
211
|
-
// We are assuming MM-DD-YYY correlates with AM/PM
|
|
212
|
-
&.is-12-hour {
|
|
213
|
-
.components-datetime__time-field-day input {
|
|
214
|
-
margin: 0 -$grid-unit-05 0 0 !important;
|
|
215
|
-
border-radius: $radius-block-ui 0 0 $radius-block-ui !important;
|
|
216
|
-
}
|
|
217
|
-
.components-datetime__time-field-year input {
|
|
218
|
-
border-radius: 0 $radius-block-ui $radius-block-ui 0 !important;
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
.components-datetime__timezone {
|
|
224
|
-
line-height: 30px;
|
|
225
|
-
margin-left: $grid-unit-05;
|
|
226
|
-
text-decoration: underline dotted;
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
.components-datetime__time-legend {
|
|
230
|
-
font-weight: 600;
|
|
231
|
-
margin-top: 0.5em;
|
|
232
|
-
|
|
233
|
-
&.invisible {
|
|
234
|
-
position: absolute;
|
|
235
|
-
top: -999em;
|
|
236
|
-
left: -999em;
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
.components-datetime__time-field-integer-field {
|
|
241
|
-
font-family: inherit;
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
.components-datetime__time-field-hours-input,
|
|
245
|
-
.components-datetime__time-field-minutes-input,
|
|
246
|
-
.components-datetime__time-field-day-input {
|
|
247
|
-
width: 35px;
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
.components-datetime__time-field-year-input {
|
|
251
|
-
width: 55px;
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
.components-datetime__time-field-month-select {
|
|
255
|
-
max-width: 145px;
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
// Hack to center the datepicker component within the popover.
|
|
259
|
-
// It sets its own styles so centering is tricky.
|
|
260
|
-
.components-popover .components-datetime__date {
|
|
261
|
-
padding-left: $grid-unit-05;
|
|
262
|
-
}
|
|
1
|
+
@import "./date/style.scss";
|