@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,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useCopyToClipboard } from '@wordpress/compose';
|
|
5
|
+
import { useState, useEffect, useRef } from '@wordpress/element';
|
|
6
|
+
import { copy } from '@wordpress/icons';
|
|
7
|
+
import { __ } from '@wordpress/i18n';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Internal dependencies
|
|
11
|
+
*/
|
|
12
|
+
import { CopyButton } from './styles';
|
|
13
|
+
import { Text } from '../text';
|
|
14
|
+
import { Tooltip } from '../ui/tooltip';
|
|
15
|
+
|
|
16
|
+
import type { ColorCopyButtonProps } from './types';
|
|
17
|
+
|
|
18
|
+
export const ColorCopyButton = ( props: ColorCopyButtonProps ) => {
|
|
19
|
+
const { color, colorType } = props;
|
|
20
|
+
const [ copiedColor, setCopiedColor ] = useState< string | null >( null );
|
|
21
|
+
const copyTimer = useRef< ReturnType< typeof setTimeout > | undefined >();
|
|
22
|
+
const copyRef = useCopyToClipboard< HTMLDivElement >(
|
|
23
|
+
() => {
|
|
24
|
+
switch ( colorType ) {
|
|
25
|
+
case 'hsl': {
|
|
26
|
+
return color.toHslString();
|
|
27
|
+
}
|
|
28
|
+
case 'rgb': {
|
|
29
|
+
return color.toRgbString();
|
|
30
|
+
}
|
|
31
|
+
default:
|
|
32
|
+
case 'hex': {
|
|
33
|
+
return color.toHex();
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
() => {
|
|
38
|
+
if ( copyTimer.current ) {
|
|
39
|
+
clearTimeout( copyTimer.current );
|
|
40
|
+
}
|
|
41
|
+
setCopiedColor( color.toHex() );
|
|
42
|
+
copyTimer.current = setTimeout( () => {
|
|
43
|
+
setCopiedColor( null );
|
|
44
|
+
copyTimer.current = undefined;
|
|
45
|
+
}, 3000 );
|
|
46
|
+
}
|
|
47
|
+
);
|
|
48
|
+
useEffect( () => {
|
|
49
|
+
// Clear copyTimer on component unmount.
|
|
50
|
+
return () => {
|
|
51
|
+
if ( copyTimer.current ) {
|
|
52
|
+
clearTimeout( copyTimer.current );
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
}, [] );
|
|
56
|
+
|
|
57
|
+
return (
|
|
58
|
+
<Tooltip
|
|
59
|
+
content={
|
|
60
|
+
<Text color="white">
|
|
61
|
+
{ copiedColor === color.toHex()
|
|
62
|
+
? __( 'Copied!' )
|
|
63
|
+
: __( 'Copy' ) }
|
|
64
|
+
</Text>
|
|
65
|
+
}
|
|
66
|
+
placement="bottom"
|
|
67
|
+
>
|
|
68
|
+
<CopyButton
|
|
69
|
+
isSmall
|
|
70
|
+
ref={ copyRef }
|
|
71
|
+
icon={ copy }
|
|
72
|
+
showTooltip={ false }
|
|
73
|
+
/>
|
|
74
|
+
</Tooltip>
|
|
75
|
+
);
|
|
76
|
+
};
|
|
@@ -9,7 +9,6 @@ import namesPlugin from 'colord/plugins/names';
|
|
|
9
9
|
* WordPress dependencies
|
|
10
10
|
*/
|
|
11
11
|
import { useCallback, useState, useMemo } from '@wordpress/element';
|
|
12
|
-
import { settings } from '@wordpress/icons';
|
|
13
12
|
import { useDebounce } from '@wordpress/compose';
|
|
14
13
|
import { __ } from '@wordpress/i18n';
|
|
15
14
|
|
|
@@ -27,9 +26,8 @@ import {
|
|
|
27
26
|
ColorfulWrapper,
|
|
28
27
|
SelectControl,
|
|
29
28
|
AuxiliaryColorArtefactWrapper,
|
|
30
|
-
DetailsControlButton,
|
|
31
29
|
} from './styles';
|
|
32
|
-
import {
|
|
30
|
+
import { ColorCopyButton } from './color-copy-button';
|
|
33
31
|
import { ColorInput } from './color-input';
|
|
34
32
|
import { Picker } from './picker';
|
|
35
33
|
import { useControlledValue } from '../utils/hooks';
|
|
@@ -85,7 +83,6 @@ const ColorPicker = (
|
|
|
85
83
|
[ debouncedSetColor ]
|
|
86
84
|
);
|
|
87
85
|
|
|
88
|
-
const [ showInputs, setShowInputs ] = useState< boolean >( false );
|
|
89
86
|
const [ colorType, setColorType ] = useState< ColorType >(
|
|
90
87
|
copyFormat || 'hex'
|
|
91
88
|
);
|
|
@@ -99,44 +96,27 @@ const ColorPicker = (
|
|
|
99
96
|
/>
|
|
100
97
|
<AuxiliaryColorArtefactWrapper>
|
|
101
98
|
<HStack justify="space-between">
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
setColorType( nextColorType as ColorType )
|
|
108
|
-
}
|
|
109
|
-
label={ __( 'Color format' ) }
|
|
110
|
-
hideLabelFromVision
|
|
111
|
-
/>
|
|
112
|
-
) : (
|
|
113
|
-
<ColorDisplay
|
|
114
|
-
color={ safeColordColor }
|
|
115
|
-
colorType={ copyFormat || colorType }
|
|
116
|
-
enableAlpha={ enableAlpha }
|
|
117
|
-
/>
|
|
118
|
-
) }
|
|
119
|
-
<DetailsControlButton
|
|
120
|
-
isSmall
|
|
121
|
-
onClick={ () => setShowInputs( ! showInputs ) }
|
|
122
|
-
icon={ settings }
|
|
123
|
-
isPressed={ showInputs }
|
|
124
|
-
label={
|
|
125
|
-
showInputs
|
|
126
|
-
? __( 'Hide detailed inputs' )
|
|
127
|
-
: __( 'Show detailed inputs' )
|
|
99
|
+
<SelectControl
|
|
100
|
+
options={ options }
|
|
101
|
+
value={ colorType }
|
|
102
|
+
onChange={ ( nextColorType ) =>
|
|
103
|
+
setColorType( nextColorType as ColorType )
|
|
128
104
|
}
|
|
105
|
+
label={ __( 'Color format' ) }
|
|
106
|
+
hideLabelFromVision
|
|
129
107
|
/>
|
|
130
|
-
|
|
131
|
-
<Spacer margin={ 4 } />
|
|
132
|
-
{ showInputs && (
|
|
133
|
-
<ColorInput
|
|
134
|
-
colorType={ colorType }
|
|
108
|
+
<ColorCopyButton
|
|
135
109
|
color={ safeColordColor }
|
|
136
|
-
|
|
137
|
-
enableAlpha={ enableAlpha }
|
|
110
|
+
colorType={ copyFormat || colorType }
|
|
138
111
|
/>
|
|
139
|
-
|
|
112
|
+
</HStack>
|
|
113
|
+
<Spacer margin={ 4 } />
|
|
114
|
+
<ColorInput
|
|
115
|
+
colorType={ colorType }
|
|
116
|
+
color={ safeColordColor }
|
|
117
|
+
onChange={ handleChange }
|
|
118
|
+
enableAlpha={ enableAlpha }
|
|
119
|
+
/>
|
|
140
120
|
</AuxiliaryColorArtefactWrapper>
|
|
141
121
|
</ColorfulWrapper>
|
|
142
122
|
);
|
|
@@ -16,6 +16,7 @@ import { Spacer } from '../spacer';
|
|
|
16
16
|
import { space } from '../ui/utils/space';
|
|
17
17
|
import { ColorHexInputControl } from './styles';
|
|
18
18
|
import { COLORS } from '../utils/colors-values';
|
|
19
|
+
import type { StateReducer } from '../input-control/reducer/state';
|
|
19
20
|
|
|
20
21
|
interface HexInputProps {
|
|
21
22
|
color: Colord;
|
|
@@ -33,6 +34,20 @@ export const HexInput = ( { color, onChange, enableAlpha }: HexInputProps ) => {
|
|
|
33
34
|
onChange( colord( hexValue ) );
|
|
34
35
|
};
|
|
35
36
|
|
|
37
|
+
const stateReducer: StateReducer = ( state, action ) => {
|
|
38
|
+
const nativeEvent = action.payload?.event?.nativeEvent as InputEvent;
|
|
39
|
+
|
|
40
|
+
if ( 'insertFromPaste' !== nativeEvent?.inputType ) {
|
|
41
|
+
return { ...state };
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const value = state.value?.startsWith( '#' )
|
|
45
|
+
? state.value.slice( 1 ).toUpperCase()
|
|
46
|
+
: state.value?.toUpperCase();
|
|
47
|
+
|
|
48
|
+
return { ...state, value };
|
|
49
|
+
};
|
|
50
|
+
|
|
36
51
|
return (
|
|
37
52
|
<ColorHexInputControl
|
|
38
53
|
prefix={
|
|
@@ -50,6 +65,7 @@ export const HexInput = ( { color, onChange, enableAlpha }: HexInputProps ) => {
|
|
|
50
65
|
maxLength={ enableAlpha ? 9 : 7 }
|
|
51
66
|
label={ __( 'Hex color' ) }
|
|
52
67
|
hideLabelFromVision
|
|
68
|
+
__unstableStateReducer={ stateReducer }
|
|
53
69
|
/>
|
|
54
70
|
);
|
|
55
71
|
};
|
|
@@ -111,10 +111,14 @@ export const ColorfulWrapper = styled.div`
|
|
|
111
111
|
${ inputHeightStyle }
|
|
112
112
|
`;
|
|
113
113
|
|
|
114
|
-
export const
|
|
114
|
+
export const CopyButton = styled( Button )`
|
|
115
115
|
&&&&& {
|
|
116
116
|
min-width: ${ space( 6 ) };
|
|
117
117
|
padding: 0;
|
|
118
|
+
|
|
119
|
+
> svg {
|
|
120
|
+
margin-right: 0;
|
|
121
|
+
}
|
|
118
122
|
}
|
|
119
123
|
`;
|
|
120
124
|
|
package/src/date-time/README.md
CHANGED
|
@@ -26,6 +26,8 @@ const MyDateTimePicker = () => {
|
|
|
26
26
|
currentDate={ date }
|
|
27
27
|
onChange={ ( newDate ) => setDate( newDate ) }
|
|
28
28
|
is12Hour={ true }
|
|
29
|
+
__nextRemoveHelpButton
|
|
30
|
+
__nextRemoveResetButton
|
|
29
31
|
/>
|
|
30
32
|
);
|
|
31
33
|
};
|
|
@@ -74,3 +76,17 @@ List of events to show in the date picker. Each event will appear as a dot on th
|
|
|
74
76
|
|
|
75
77
|
- Type: `Array`
|
|
76
78
|
- Required: No
|
|
79
|
+
|
|
80
|
+
### `__nextRemoveHelpButton`: `boolean`
|
|
81
|
+
|
|
82
|
+
Start opting in to not displaying a Help button which will become the default in a future version.
|
|
83
|
+
|
|
84
|
+
- Required: No
|
|
85
|
+
- Default: `false`
|
|
86
|
+
|
|
87
|
+
### `__nextRemoveResetButton`: `boolean`
|
|
88
|
+
|
|
89
|
+
Start opting in to not displaying a Reset button which will become the default in a future version.
|
|
90
|
+
|
|
91
|
+
- Required: No
|
|
92
|
+
- Default: `false`
|
|
File without changes
|
|
@@ -2,30 +2,28 @@
|
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
4
|
import moment from 'moment';
|
|
5
|
-
import classnames from 'classnames';
|
|
6
5
|
import type { Moment } from 'moment';
|
|
7
6
|
import { noop } from 'lodash';
|
|
8
|
-
|
|
7
|
+
// Needed to initialise the default datepicker styles.
|
|
8
|
+
// See: https://github.com/airbnb/react-dates#initialize
|
|
9
|
+
import 'react-dates/initialize';
|
|
9
10
|
// `react-dates` doesn't tree-shake correctly, so we import from the individual
|
|
10
11
|
// component here.
|
|
11
|
-
|
|
12
|
-
// `react-dates/lib/components/DayPickerSingleDateController` as they're located
|
|
13
|
-
// at `react-dates`.
|
|
14
|
-
import UntypedDayPickerSingleDateController from 'react-dates/lib/components/DayPickerSingleDateController';
|
|
15
|
-
import type { DayPickerSingleDateController } from 'react-dates';
|
|
16
|
-
const TypedDayPickerSingleDateController = UntypedDayPickerSingleDateController as DayPickerSingleDateController;
|
|
12
|
+
import DayPickerSingleDateController from 'react-dates/lib/components/DayPickerSingleDateController';
|
|
17
13
|
|
|
18
14
|
/**
|
|
19
15
|
* WordPress dependencies
|
|
20
16
|
*/
|
|
21
17
|
import { useEffect, useRef } from '@wordpress/element';
|
|
22
18
|
import { isRTL, _n, sprintf } from '@wordpress/i18n';
|
|
19
|
+
import { arrowLeft, arrowRight } from '@wordpress/icons';
|
|
23
20
|
|
|
24
21
|
/**
|
|
25
22
|
* Internal dependencies
|
|
26
23
|
*/
|
|
27
24
|
import { getMomentDate } from './utils';
|
|
28
|
-
import type { DatePickerDayProps, DatePickerProps } from '
|
|
25
|
+
import type { DatePickerDayProps, DatePickerProps } from '../types';
|
|
26
|
+
import { Day, NavPrevButton, NavNextButton } from './styles';
|
|
29
27
|
|
|
30
28
|
const TIMEZONELESS_FORMAT = 'YYYY-MM-DDTHH:mm:ss';
|
|
31
29
|
const ARIAL_LABEL_TIME_FORMAT = 'dddd, LL';
|
|
@@ -69,14 +67,14 @@ function DatePickerDay( { day, events = [] }: DatePickerDayProps ) {
|
|
|
69
67
|
}, [ events.length ] );
|
|
70
68
|
|
|
71
69
|
return (
|
|
72
|
-
<
|
|
70
|
+
<Day
|
|
73
71
|
ref={ ref }
|
|
74
|
-
className=
|
|
75
|
-
|
|
76
|
-
|
|
72
|
+
className="components-datetime__date__day" // Unused, for backwards compatibility.
|
|
73
|
+
hasEvents={ !! events?.length }
|
|
74
|
+
alignment="center"
|
|
77
75
|
>
|
|
78
76
|
{ day.format( 'D' ) }
|
|
79
|
-
</
|
|
77
|
+
</Day>
|
|
80
78
|
);
|
|
81
79
|
}
|
|
82
80
|
|
|
@@ -107,6 +105,7 @@ export function DatePicker( {
|
|
|
107
105
|
onMonthPreviewed,
|
|
108
106
|
}: DatePickerProps ) {
|
|
109
107
|
const nodeRef = useRef< HTMLDivElement >( null );
|
|
108
|
+
|
|
110
109
|
const onMonthPreviewedHandler = ( newMonthDate: Moment ) => {
|
|
111
110
|
onMonthPreviewed?.( newMonthDate.toISOString() );
|
|
112
111
|
keepFocusInside();
|
|
@@ -176,9 +175,11 @@ export function DatePicker( {
|
|
|
176
175
|
|
|
177
176
|
return (
|
|
178
177
|
<div className="components-datetime__date" ref={ nodeRef }>
|
|
179
|
-
<
|
|
178
|
+
<DayPickerSingleDateController
|
|
180
179
|
date={ momentDate }
|
|
180
|
+
initialVisibleMonth={ null }
|
|
181
181
|
daySize={ 30 }
|
|
182
|
+
horizontalMonthPadding={ 0 }
|
|
182
183
|
focused
|
|
183
184
|
hideKeyboardShortcutsPanel
|
|
184
185
|
// This is a hack to force the calendar to update on month or year change
|
|
@@ -204,6 +205,28 @@ export function DatePicker( {
|
|
|
204
205
|
events={ getEventsPerDay( day ) }
|
|
205
206
|
/>
|
|
206
207
|
) }
|
|
208
|
+
renderMonthElement={ ( { month } ) => (
|
|
209
|
+
<>
|
|
210
|
+
<strong>{ month.format( 'MMMM' ) }</strong>{ ' ' }
|
|
211
|
+
{ month.format( 'YYYY' ) }
|
|
212
|
+
</>
|
|
213
|
+
) }
|
|
214
|
+
renderNavPrevButton={ ( { ariaLabel, ...props } ) => (
|
|
215
|
+
<NavPrevButton
|
|
216
|
+
icon={ arrowLeft }
|
|
217
|
+
variant="tertiary"
|
|
218
|
+
aria-label={ ariaLabel }
|
|
219
|
+
{ ...props }
|
|
220
|
+
/>
|
|
221
|
+
) }
|
|
222
|
+
renderNavNextButton={ ( { ariaLabel, ...props } ) => (
|
|
223
|
+
<NavNextButton
|
|
224
|
+
icon={ arrowRight }
|
|
225
|
+
variant="tertiary"
|
|
226
|
+
aria-label={ ariaLabel }
|
|
227
|
+
{ ...props }
|
|
228
|
+
/>
|
|
229
|
+
) }
|
|
207
230
|
onFocusChange={ noop }
|
|
208
231
|
/>
|
|
209
232
|
</div>
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
@import "./datepicker.scss";
|
|
2
|
+
|
|
3
|
+
// Styles that overrides the calendar styling provided by react-dates go here.
|
|
4
|
+
// Everything else goes in styles.ts.
|
|
5
|
+
|
|
6
|
+
.components-datetime__date {
|
|
7
|
+
//
|
|
8
|
+
// Margin overrides
|
|
9
|
+
//
|
|
10
|
+
|
|
11
|
+
// Remove the left and right margin from the calendar by setting all the
|
|
12
|
+
// containers' widths to 100%. This means that the slide left / slide right
|
|
13
|
+
// animation won't work but we don't want that, anyway.
|
|
14
|
+
|
|
15
|
+
.CalendarMonthGrid__horizontal,
|
|
16
|
+
.DayPicker_weekHeader_li {
|
|
17
|
+
transform: none !important; // Override inline style.
|
|
18
|
+
width: 100% !important; // Override inline style.
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.CalendarMonthGrid_month__horizontal,
|
|
22
|
+
.CalendarMonth_table,
|
|
23
|
+
.DayPicker_weekHeader {
|
|
24
|
+
width: 100%;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.DayPicker_weekHeaders__horizontal {
|
|
28
|
+
margin: 0;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.DayPicker_weekHeader_ul {
|
|
32
|
+
display: flex;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
//
|
|
36
|
+
// Theming
|
|
37
|
+
//
|
|
38
|
+
|
|
39
|
+
.DayPicker_weekHeader {
|
|
40
|
+
top: 50px;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.CalendarMonth_caption {
|
|
44
|
+
font-size: $default-font-size;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.CalendarMonth_table {
|
|
48
|
+
border-collapse: separate;
|
|
49
|
+
border-spacing: 2px;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.CalendarDay {
|
|
53
|
+
border: none;
|
|
54
|
+
font-size: $default-font-size;
|
|
55
|
+
border-radius: $radius-round;
|
|
56
|
+
|
|
57
|
+
&:focus {
|
|
58
|
+
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;
|
|
59
|
+
outline: 2px solid transparent; // Shown in Windows 10 high contrast mode.
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.CalendarDay__selected {
|
|
64
|
+
background: var(--wp-admin-theme-color);
|
|
65
|
+
border: 2px solid transparent; // This indicates selection in Windows 10 high contrast mode.
|
|
66
|
+
|
|
67
|
+
&:hover {
|
|
68
|
+
background: var(--wp-admin-theme-color-darker-20);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
&:focus {
|
|
72
|
+
box-shadow: inset 0 0 0 $border-width $white;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import styled from '@emotion/styled';
|
|
5
|
+
import { css } from '@emotion/react';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Internal dependencies
|
|
9
|
+
*/
|
|
10
|
+
import Button from '../../button';
|
|
11
|
+
import { COLORS } from '../../utils';
|
|
12
|
+
import { VStack } from '../../v-stack';
|
|
13
|
+
|
|
14
|
+
// Styles that overrides the calendar styling provided by react-dates go in
|
|
15
|
+
// style.scss. Everything else goes here.
|
|
16
|
+
|
|
17
|
+
export const Day = styled( VStack )< { hasEvents: boolean } >`
|
|
18
|
+
height: 100%;
|
|
19
|
+
position: relative;
|
|
20
|
+
|
|
21
|
+
${ ( props ) =>
|
|
22
|
+
props.hasEvents &&
|
|
23
|
+
`
|
|
24
|
+
::before {
|
|
25
|
+
background: var(--wp-admin-theme-color);
|
|
26
|
+
border-radius: 2px;
|
|
27
|
+
bottom: 0;
|
|
28
|
+
content: " ";
|
|
29
|
+
height: 4px;
|
|
30
|
+
left: 50%;
|
|
31
|
+
margin-left: -2px;
|
|
32
|
+
position: absolute;
|
|
33
|
+
width: 4px;
|
|
34
|
+
|
|
35
|
+
.CalendarDay__selected & {
|
|
36
|
+
background: ${ COLORS.white };
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
` }
|
|
40
|
+
`;
|
|
41
|
+
|
|
42
|
+
const baseNavButton = css`
|
|
43
|
+
position: absolute;
|
|
44
|
+
top: 15px;
|
|
45
|
+
`;
|
|
46
|
+
|
|
47
|
+
export const NavPrevButton = styled( Button )`
|
|
48
|
+
${ baseNavButton }
|
|
49
|
+
left: 0;
|
|
50
|
+
`;
|
|
51
|
+
|
|
52
|
+
export const NavNextButton = styled( Button )`
|
|
53
|
+
${ baseNavButton }
|
|
54
|
+
right: 0;
|
|
55
|
+
`;
|
|
File without changes
|
|
File without changes
|