@wordpress/components 19.8.4 → 19.11.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 +60 -0
- package/CONTRIBUTING.md +80 -7
- package/build/alignment-matrix-control/styles/alignment-matrix-control-styles.js +11 -11
- package/build/alignment-matrix-control/styles/alignment-matrix-control-styles.js.map +1 -1
- package/build/border-box-control/border-box-control/component.js +22 -7
- package/build/border-box-control/border-box-control/component.js.map +1 -1
- package/build/border-box-control/border-box-control-linked-button/hook.js +3 -2
- package/build/border-box-control/border-box-control-linked-button/hook.js.map +1 -1
- package/build/border-box-control/border-box-control-split-controls/component.js +21 -8
- package/build/border-box-control/border-box-control-split-controls/component.js.map +1 -1
- package/build/border-box-control/border-box-control-visualizer/hook.js +3 -2
- package/build/border-box-control/border-box-control-visualizer/hook.js.map +1 -1
- package/build/border-box-control/styles.js +11 -15
- package/build/border-box-control/styles.js.map +1 -1
- package/build/border-control/border-control/component.js +5 -3
- package/build/border-control/border-control/component.js.map +1 -1
- package/build/border-control/border-control/hook.js +6 -3
- package/build/border-control/border-control/hook.js.map +1 -1
- package/build/border-control/border-control-dropdown/component.js +6 -2
- package/build/border-control/border-control-dropdown/component.js.map +1 -1
- package/build/border-control/border-control-dropdown/hook.js +5 -5
- package/build/border-control/border-control-dropdown/hook.js.map +1 -1
- package/build/border-control/styles.js +58 -29
- package/build/border-control/styles.js.map +1 -1
- package/build/box-control/index.js +0 -21
- package/build/box-control/index.js.map +1 -1
- package/build/box-control/utils.js +1 -8
- package/build/box-control/utils.js.map +1 -1
- package/build/button/index.js +3 -5
- package/build/button/index.js.map +1 -1
- package/build/button/index.native.js +16 -2
- package/build/button/index.native.js.map +1 -1
- package/build/button-group/index.js +24 -7
- package/build/button-group/index.js.map +1 -1
- package/build/{flyout → button-group}/types.js +0 -0
- package/build/button-group/types.js.map +1 -0
- package/build/checkbox-control/index.js +34 -7
- package/build/checkbox-control/index.js.map +1 -1
- package/build/checkbox-control/types.js +6 -0
- package/build/checkbox-control/types.js.map +1 -0
- package/build/circular-option-picker/index.js +1 -2
- package/build/circular-option-picker/index.js.map +1 -1
- package/build/color-palette/index.js +5 -12
- package/build/color-palette/index.js.map +1 -1
- package/build/date-time/date.js +43 -19
- package/build/date-time/date.js.map +1 -1
- package/build/date-time/index.js +28 -3
- package/build/date-time/index.js.map +1 -1
- package/build/date-time/time.js +42 -40
- package/build/date-time/time.js.map +1 -1
- package/build/date-time/timezone.js +4 -3
- package/build/date-time/timezone.js.map +1 -1
- package/build/date-time/types.js +6 -0
- package/build/date-time/types.js.map +1 -0
- package/build/date-time/utils.js +6 -4
- package/build/date-time/utils.js.map +1 -1
- package/build/disabled/index.js +4 -76
- package/build/disabled/index.js.map +1 -1
- package/build/draggable/index.native.js +223 -0
- package/build/draggable/index.native.js.map +1 -0
- package/build/dropdown/index.js +7 -5
- package/build/dropdown/index.js.map +1 -1
- package/build/focal-point-picker/index.native.js +3 -3
- package/build/focal-point-picker/index.native.js.map +1 -1
- package/build/heading/hook.js +1 -1
- package/build/heading/hook.js.map +1 -1
- package/build/index.js +0 -8
- package/build/index.js.map +1 -1
- package/build/index.native.js +16 -0
- package/build/index.native.js.map +1 -1
- package/build/input-control/index.js +27 -4
- package/build/input-control/index.js.map +1 -1
- package/build/input-control/styles/input-control-styles.js +42 -30
- package/build/input-control/styles/input-control-styles.js.map +1 -1
- package/build/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js +1 -1
- package/build/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js.map +1 -1
- package/build/mobile/bottom-sheet/index.native.js +1 -1
- package/build/mobile/bottom-sheet/index.native.js.map +1 -1
- package/build/mobile/bottom-sheet-select-control/index.native.js +4 -2
- package/build/mobile/bottom-sheet-select-control/index.native.js.map +1 -1
- package/build/mobile/html-text-input/index.native.js +19 -8
- package/build/mobile/html-text-input/index.native.js.map +1 -1
- package/build/mobile/keyboard-aware-flat-list/index.android.js +28 -5
- package/build/mobile/keyboard-aware-flat-list/index.android.js.map +1 -1
- package/build/mobile/keyboard-aware-flat-list/index.ios.js +47 -24
- package/build/mobile/keyboard-aware-flat-list/index.ios.js.map +1 -1
- package/build/navigation/styles/navigation-styles.js +12 -12
- package/build/navigation/styles/navigation-styles.js.map +1 -1
- package/build/notice/index.native.js +44 -40
- package/build/notice/index.native.js.map +1 -1
- package/build/notice/list.native.js +27 -45
- package/build/notice/list.native.js.map +1 -1
- package/build/palette-edit/index.js +38 -7
- package/build/palette-edit/index.js.map +1 -1
- package/build/popover/index.js +223 -323
- package/build/popover/index.js.map +1 -1
- package/build/resizable-box/resize-tooltip/utils.js +5 -8
- package/build/resizable-box/resize-tooltip/utils.js.map +1 -1
- package/build/sandbox/index.js +2 -2
- package/build/sandbox/index.js.map +1 -1
- package/build/sandbox/index.native.js +1 -1
- package/build/sandbox/index.native.js.map +1 -1
- package/build/select-control/index.js +31 -4
- package/build/select-control/index.js.map +1 -1
- package/build/select-control/styles/select-control-styles.js +17 -14
- package/build/select-control/styles/select-control-styles.js.map +1 -1
- package/build/surface/styles.js +8 -8
- package/build/surface/styles.js.map +1 -1
- package/build/text/hook.js +5 -5
- package/build/text/hook.js.map +1 -1
- package/build/text/styles/text-mixins.native.js +1 -1
- package/build/text/styles/text-mixins.native.js.map +1 -1
- package/build/text/styles.js +7 -7
- package/build/text/styles.js.map +1 -1
- package/build/text-control/index.js +35 -28
- package/build/text-control/index.js.map +1 -1
- package/build/text-control/types.js +6 -0
- package/build/text-control/types.js.map +1 -0
- package/build/toggle-group-control/toggle-group-control/component.js +1 -3
- package/build/toggle-group-control/toggle-group-control/component.js.map +1 -1
- package/build/toggle-group-control/toggle-group-control-option-icon/component.js +6 -4
- package/build/toggle-group-control/toggle-group-control-option-icon/component.js.map +1 -1
- package/build/tools-panel/tools-panel-header/component.js +52 -36
- package/build/tools-panel/tools-panel-header/component.js.map +1 -1
- package/build/tooltip/index.js +2 -2
- package/build/tooltip/index.js.map +1 -1
- package/build/ui/spinner/component.js +1 -1
- package/build/ui/spinner/component.js.map +1 -1
- package/build/unit-control/index.js +3 -3
- package/build/unit-control/index.js.map +1 -1
- package/build/unit-control/styles/unit-control-styles.js +11 -20
- package/build/unit-control/styles/unit-control-styles.js.map +1 -1
- package/build/unit-control/utils.js.map +1 -1
- package/build/utils/colors-values.js +9 -24
- package/build/utils/colors-values.js.map +1 -1
- package/build-module/alignment-matrix-control/styles/alignment-matrix-control-styles.js +11 -11
- package/build-module/alignment-matrix-control/styles/alignment-matrix-control-styles.js.map +1 -1
- package/build-module/border-box-control/border-box-control/component.js +22 -7
- package/build-module/border-box-control/border-box-control/component.js.map +1 -1
- package/build-module/border-box-control/border-box-control-linked-button/hook.js +3 -2
- package/build-module/border-box-control/border-box-control-linked-button/hook.js.map +1 -1
- package/build-module/border-box-control/border-box-control-split-controls/component.js +21 -8
- 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-visualizer/hook.js +3 -2
- package/build-module/border-box-control/border-box-control-visualizer/hook.js.map +1 -1
- package/build-module/border-box-control/styles.js +9 -15
- package/build-module/border-box-control/styles.js.map +1 -1
- package/build-module/border-control/border-control/component.js +5 -3
- package/build-module/border-control/border-control/component.js.map +1 -1
- package/build-module/border-control/border-control/hook.js +6 -3
- package/build-module/border-control/border-control/hook.js.map +1 -1
- package/build-module/border-control/border-control-dropdown/component.js +6 -2
- package/build-module/border-control/border-control-dropdown/component.js.map +1 -1
- package/build-module/border-control/border-control-dropdown/hook.js +5 -5
- package/build-module/border-control/border-control-dropdown/hook.js.map +1 -1
- package/build-module/border-control/styles.js +56 -29
- package/build-module/border-control/styles.js.map +1 -1
- package/build-module/box-control/index.js +1 -20
- package/build-module/box-control/index.js.map +1 -1
- package/build-module/box-control/utils.js +0 -6
- package/build-module/box-control/utils.js.map +1 -1
- package/build-module/button/index.js +3 -4
- package/build-module/button/index.js.map +1 -1
- package/build-module/button/index.native.js +16 -3
- package/build-module/button/index.native.js.map +1 -1
- package/build-module/button-group/index.js +27 -7
- package/build-module/button-group/index.js.map +1 -1
- package/build-module/{flyout → button-group}/types.js +0 -0
- package/build-module/{flyout → button-group}/types.js.map +0 -0
- package/build-module/checkbox-control/index.js +31 -7
- package/build-module/checkbox-control/index.js.map +1 -1
- package/build-module/checkbox-control/types.js +2 -0
- package/{build/flyout → build-module/checkbox-control}/types.js.map +0 -0
- package/build-module/circular-option-picker/index.js +1 -2
- package/build-module/circular-option-picker/index.js.map +1 -1
- package/build-module/color-palette/index.js +5 -11
- package/build-module/color-palette/index.js.map +1 -1
- package/build-module/date-time/date.js +44 -19
- package/build-module/date-time/date.js.map +1 -1
- package/build-module/date-time/index.js +28 -4
- package/build-module/date-time/index.js.map +1 -1
- package/build-module/date-time/time.js +43 -41
- package/build-module/date-time/time.js.map +1 -1
- package/build-module/date-time/timezone.js +4 -3
- package/build-module/date-time/timezone.js.map +1 -1
- package/build-module/date-time/types.js +2 -0
- package/build-module/date-time/types.js.map +1 -0
- package/build-module/date-time/utils.js +6 -4
- package/build-module/date-time/utils.js.map +1 -1
- package/build-module/disabled/index.js +5 -76
- package/build-module/disabled/index.js.map +1 -1
- package/build-module/draggable/index.native.js +206 -0
- package/build-module/draggable/index.native.js.map +1 -0
- package/build-module/dropdown/index.js +7 -5
- package/build-module/dropdown/index.js.map +1 -1
- package/build-module/focal-point-picker/index.native.js +3 -3
- package/build-module/focal-point-picker/index.native.js.map +1 -1
- package/build-module/heading/hook.js +1 -1
- package/build-module/heading/hook.js.map +1 -1
- package/build-module/index.js +0 -1
- package/build-module/index.js.map +1 -1
- package/build-module/index.native.js +2 -1
- package/build-module/index.native.js.map +1 -1
- package/build-module/input-control/index.js +24 -3
- package/build-module/input-control/index.js.map +1 -1
- package/build-module/input-control/styles/input-control-styles.js +42 -30
- package/build-module/input-control/styles/input-control-styles.js.map +1 -1
- package/build-module/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js +1 -1
- package/build-module/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js.map +1 -1
- package/build-module/mobile/bottom-sheet/index.native.js +1 -1
- package/build-module/mobile/bottom-sheet/index.native.js.map +1 -1
- package/build-module/mobile/bottom-sheet-select-control/index.native.js +4 -2
- package/build-module/mobile/bottom-sheet-select-control/index.native.js.map +1 -1
- package/build-module/mobile/html-text-input/index.native.js +20 -9
- package/build-module/mobile/html-text-input/index.native.js.map +1 -1
- package/build-module/mobile/keyboard-aware-flat-list/index.android.js +21 -5
- package/build-module/mobile/keyboard-aware-flat-list/index.android.js.map +1 -1
- package/build-module/mobile/keyboard-aware-flat-list/index.ios.js +42 -25
- package/build-module/mobile/keyboard-aware-flat-list/index.ios.js.map +1 -1
- package/build-module/navigation/styles/navigation-styles.js +13 -13
- package/build-module/navigation/styles/navigation-styles.js.map +1 -1
- package/build-module/notice/index.native.js +45 -41
- package/build-module/notice/index.native.js.map +1 -1
- package/build-module/notice/list.native.js +28 -46
- package/build-module/notice/list.native.js.map +1 -1
- package/build-module/palette-edit/index.js +37 -7
- package/build-module/palette-edit/index.js.map +1 -1
- package/build-module/popover/index.js +225 -325
- package/build-module/popover/index.js.map +1 -1
- package/build-module/resizable-box/resize-tooltip/utils.js +4 -5
- package/build-module/resizable-box/resize-tooltip/utils.js.map +1 -1
- package/build-module/sandbox/index.js +2 -2
- package/build-module/sandbox/index.js.map +1 -1
- package/build-module/sandbox/index.native.js +1 -1
- package/build-module/sandbox/index.native.js.map +1 -1
- package/build-module/select-control/index.js +29 -3
- package/build-module/select-control/index.js.map +1 -1
- package/build-module/select-control/styles/select-control-styles.js +17 -14
- package/build-module/select-control/styles/select-control-styles.js.map +1 -1
- package/build-module/surface/styles.js +8 -8
- package/build-module/surface/styles.js.map +1 -1
- package/build-module/text/hook.js +5 -5
- package/build-module/text/hook.js.map +1 -1
- package/build-module/text/styles/text-mixins.native.js +2 -2
- package/build-module/text/styles/text-mixins.native.js.map +1 -1
- package/build-module/text/styles.js +7 -7
- package/build-module/text/styles.js.map +1 -1
- package/build-module/text-control/index.js +35 -27
- package/build-module/text-control/index.js.map +1 -1
- package/build-module/text-control/types.js +2 -0
- package/build-module/text-control/types.js.map +1 -0
- package/build-module/toggle-group-control/toggle-group-control/component.js +2 -3
- package/build-module/toggle-group-control/toggle-group-control/component.js.map +1 -1
- package/build-module/toggle-group-control/toggle-group-control-option-icon/component.js +1 -5
- package/build-module/toggle-group-control/toggle-group-control-option-icon/component.js.map +1 -1
- package/build-module/tools-panel/tools-panel-header/component.js +51 -36
- package/build-module/tools-panel/tools-panel-header/component.js.map +1 -1
- package/build-module/tooltip/index.js +2 -2
- package/build-module/tooltip/index.js.map +1 -1
- package/build-module/ui/spinner/component.js +1 -1
- package/build-module/ui/spinner/component.js.map +1 -1
- package/build-module/unit-control/index.js +3 -3
- package/build-module/unit-control/index.js.map +1 -1
- package/build-module/unit-control/styles/unit-control-styles.js +11 -20
- package/build-module/unit-control/styles/unit-control-styles.js.map +1 -1
- package/build-module/unit-control/utils.js.map +1 -1
- package/build-module/utils/colors-values.js +19 -23
- package/build-module/utils/colors-values.js.map +1 -1
- package/build-style/style-rtl.css +55 -170
- package/build-style/style.css +51 -170
- package/build-types/border-box-control/border-box-control/component.d.ts.map +1 -1
- package/build-types/border-box-control/border-box-control/hook.d.ts +3 -1
- package/build-types/border-box-control/border-box-control/hook.d.ts.map +1 -1
- package/build-types/border-box-control/border-box-control-linked-button/hook.d.ts.map +1 -1
- 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 +3 -1
- 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 +2 -2
- package/build-types/border-box-control/styles.d.ts.map +1 -1
- package/build-types/border-box-control/types.d.ts +40 -13
- package/build-types/border-box-control/types.d.ts.map +1 -1
- package/build-types/border-control/border-control/component.d.ts.map +1 -1
- package/build-types/border-control/border-control/hook.d.ts +2 -1
- package/build-types/border-control/border-control/hook.d.ts.map +1 -1
- package/build-types/border-control/border-control-dropdown/component.d.ts.map +1 -1
- package/build-types/border-control/border-control-dropdown/hook.d.ts +1 -0
- package/build-types/border-control/border-control-dropdown/hook.d.ts.map +1 -1
- package/build-types/border-control/styles.d.ts +2 -1
- package/build-types/border-control/styles.d.ts.map +1 -1
- package/build-types/border-control/types.d.ts +18 -6
- package/build-types/border-control/types.d.ts.map +1 -1
- package/build-types/button/index.d.ts.map +1 -1
- package/build-types/button-group/index.d.ts +25 -0
- package/build-types/button-group/index.d.ts.map +1 -0
- package/build-types/button-group/stories/index.d.ts +12 -0
- package/build-types/button-group/stories/index.d.ts.map +1 -0
- package/build-types/button-group/types.d.ts +11 -0
- package/build-types/button-group/types.d.ts.map +1 -0
- package/build-types/checkbox-control/index.d.ts +26 -0
- package/build-types/checkbox-control/index.d.ts.map +1 -0
- package/build-types/checkbox-control/stories/index.d.ts +13 -0
- package/build-types/checkbox-control/stories/index.d.ts.map +1 -0
- package/build-types/checkbox-control/types.d.ts +35 -0
- package/build-types/checkbox-control/types.d.ts.map +1 -0
- package/build-types/circular-option-picker/index.d.ts.map +1 -1
- package/build-types/color-palette/index.d.ts.map +1 -1
- package/build-types/color-picker/styles.d.ts +3 -3
- package/build-types/date-time/date.d.ts +24 -0
- package/build-types/date-time/date.d.ts.map +1 -0
- package/build-types/date-time/index.d.ts +35 -0
- package/build-types/date-time/index.d.ts.map +1 -0
- package/build-types/date-time/stories/date.d.ts +14 -0
- package/build-types/date-time/stories/date.d.ts.map +1 -0
- package/build-types/date-time/stories/index.d.ts +14 -0
- package/build-types/date-time/stories/index.d.ts.map +1 -0
- package/build-types/date-time/stories/time.d.ts +12 -0
- package/build-types/date-time/stories/time.d.ts.map +1 -0
- package/build-types/date-time/stories/utils.d.ts +3 -0
- package/build-types/date-time/stories/utils.d.ts.map +1 -0
- package/build-types/date-time/test/date.d.ts +2 -0
- package/build-types/date-time/test/date.d.ts.map +1 -0
- package/build-types/date-time/test/time.d.ts +2 -0
- package/build-types/date-time/test/time.d.ts.map +1 -0
- package/build-types/date-time/test/utils.d.ts +2 -0
- package/build-types/date-time/test/utils.d.ts.map +1 -0
- package/build-types/date-time/time.d.ts +25 -0
- package/build-types/date-time/time.d.ts.map +1 -0
- package/build-types/date-time/timezone.d.ts +8 -0
- package/build-types/date-time/timezone.d.ts.map +1 -0
- package/build-types/date-time/types.d.ts +91 -0
- package/build-types/date-time/types.d.ts.map +1 -0
- package/build-types/date-time/utils.d.ts +15 -0
- package/build-types/date-time/utils.d.ts.map +1 -0
- package/build-types/disabled/index.d.ts.map +1 -1
- package/build-types/dropdown/index.d.ts.map +1 -1
- package/build-types/input-control/index.d.ts +23 -3
- package/build-types/input-control/index.d.ts.map +1 -1
- package/build-types/input-control/input-field.d.ts +1 -1
- package/build-types/input-control/input-field.d.ts.map +1 -1
- package/build-types/input-control/stories/index.d.ts +5 -5
- package/build-types/input-control/stories/index.d.ts.map +1 -1
- package/build-types/input-control/styles/input-control-styles.d.ts +1 -0
- package/build-types/input-control/styles/input-control-styles.d.ts.map +1 -1
- package/build-types/input-control/types.d.ts +79 -3
- package/build-types/input-control/types.d.ts.map +1 -1
- package/build-types/number-control/styles/number-control-styles.d.ts +1 -1
- package/build-types/popover/index.d.ts +5 -8
- package/build-types/popover/index.d.ts.map +1 -1
- package/build-types/resizable-box/index.d.ts +1 -1
- package/build-types/resizable-box/resize-tooltip/index.d.ts +1 -1
- package/build-types/resizable-box/resize-tooltip/utils.d.ts.map +1 -1
- package/build-types/select-control/index.d.ts +30 -26
- package/build-types/select-control/index.d.ts.map +1 -1
- package/build-types/select-control/stories/index.d.ts +23 -0
- package/build-types/select-control/stories/index.d.ts.map +1 -0
- package/build-types/select-control/styles/select-control-styles.d.ts +3 -4
- package/build-types/select-control/styles/select-control-styles.d.ts.map +1 -1
- package/build-types/select-control/test/select-control.d.ts +2 -0
- package/build-types/select-control/test/select-control.d.ts.map +1 -0
- package/build-types/select-control/types.d.ts +52 -1
- package/build-types/select-control/types.d.ts.map +1 -1
- package/build-types/text-control/index.d.ts +2 -2
- package/build-types/toggle-group-control/toggle-group-control/component.d.ts.map +1 -1
- package/build-types/toggle-group-control/toggle-group-control-option-icon/component.d.ts.map +1 -1
- package/build-types/tools-panel/tools-panel-header/component.d.ts.map +1 -1
- package/build-types/tools-panel/types.d.ts +0 -1
- package/build-types/tools-panel/types.d.ts.map +1 -1
- package/build-types/tooltip/index.d.ts.map +1 -1
- package/build-types/unit-control/index.d.ts +2 -2
- package/build-types/unit-control/index.d.ts.map +1 -1
- package/build-types/unit-control/styles/unit-control-styles.d.ts.map +1 -1
- package/build-types/unit-control/test/index.d.ts +2 -0
- package/build-types/unit-control/test/index.d.ts.map +1 -0
- package/build-types/unit-control/test/utils.d.ts +2 -0
- package/build-types/unit-control/test/utils.d.ts.map +1 -0
- package/build-types/unit-control/types.d.ts +1 -1
- package/build-types/unit-control/types.d.ts.map +1 -1
- package/build-types/unit-control/utils.d.ts +3 -3
- package/build-types/unit-control/utils.d.ts.map +1 -1
- package/build-types/utils/colors-values.d.ts +6 -146
- package/build-types/utils/colors-values.d.ts.map +1 -1
- package/package.json +19 -19
- package/src/alignment-matrix-control/styles/alignment-matrix-control-styles.js +5 -3
- package/src/autocomplete/style.scss +1 -1
- package/src/border-box-control/border-box-control/README.md +10 -14
- package/src/border-box-control/border-box-control/component.tsx +21 -4
- package/src/border-box-control/border-box-control-linked-button/hook.ts +10 -6
- package/src/border-box-control/border-box-control-split-controls/component.tsx +24 -7
- package/src/border-box-control/border-box-control-visualizer/hook.ts +11 -6
- package/src/border-box-control/stories/index.js +1 -0
- package/src/border-box-control/styles.ts +15 -8
- package/src/border-box-control/types.ts +40 -14
- package/src/border-control/border-control/README.md +0 -7
- package/src/border-control/border-control/component.tsx +4 -2
- package/src/border-control/border-control/hook.ts +5 -2
- package/src/border-control/border-control-dropdown/component.tsx +18 -11
- package/src/border-control/border-control-dropdown/hook.ts +7 -5
- package/src/border-control/stories/index.js +1 -0
- package/src/border-control/styles.ts +82 -22
- package/src/border-control/types.ts +18 -6
- package/src/box-control/README.md +0 -74
- package/src/box-control/index.js +0 -15
- package/src/box-control/stories/index.js +0 -29
- package/src/box-control/utils.js +0 -7
- package/src/button/index.js +2 -4
- package/src/button/index.native.js +33 -18
- package/src/button/test/index.js +16 -1
- package/src/button-group/index.tsx +47 -0
- package/src/button-group/stories/index.tsx +41 -0
- package/src/button-group/types.ts +11 -0
- package/src/checkbox-control/README.md +10 -8
- package/src/checkbox-control/{index.js → index.tsx} +49 -14
- package/src/checkbox-control/stories/{index.js → index.tsx} +49 -27
- package/src/checkbox-control/types.ts +36 -0
- package/src/circular-option-picker/index.js +1 -2
- package/src/circular-option-picker/style.scss +1 -0
- package/src/color-palette/README.md +0 -1
- package/src/color-palette/index.js +6 -13
- package/src/color-palette/style.scss +3 -18
- package/src/color-palette/test/__snapshots__/index.js.snap +2 -3
- package/src/confirm-dialog/stories/index.js +87 -99
- package/src/date-time/README.md +13 -10
- package/src/date-time/{date.js → date.tsx} +49 -20
- package/src/date-time/{index.js → index.tsx} +31 -5
- package/src/date-time/stories/date.tsx +73 -0
- package/src/date-time/stories/index.tsx +75 -0
- package/src/date-time/stories/time.tsx +51 -0
- package/src/date-time/stories/utils.ts +9 -0
- package/src/date-time/test/date.tsx +127 -0
- package/src/date-time/test/{time.js → time.tsx} +34 -19
- package/src/date-time/test/{utils.js → utils.ts} +1 -1
- package/src/date-time/{time.js → time.tsx} +57 -46
- package/src/date-time/{timezone.js → timezone.tsx} +4 -3
- package/src/date-time/types.ts +106 -0
- package/src/date-time/utils.ts +20 -0
- package/src/dimension-control/test/__snapshots__/index.test.js.snap +4 -4
- package/src/disabled/index.js +5 -90
- package/src/draggable/index.native.js +215 -0
- package/src/draggable/style.native.scss +3 -0
- package/src/dropdown/index.js +9 -4
- package/src/dropdown/style.scss +1 -1
- package/src/focal-point-picker/index.native.js +3 -3
- package/src/form-file-upload/test/index.js +20 -13
- package/src/heading/hook.ts +1 -1
- package/src/heading/test/__snapshots__/index.js.snap +3 -3
- package/src/index.js +0 -1
- package/src/index.native.js +1 -0
- package/src/input-control/README.md +3 -3
- package/src/input-control/index.tsx +23 -3
- package/src/input-control/stories/index.tsx +63 -0
- package/src/input-control/styles/input-control-styles.tsx +20 -7
- package/src/input-control/types.ts +79 -2
- package/src/item-group/stories/index.js +22 -18
- package/src/menu-item/style.scss +10 -0
- package/src/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js +1 -1
- package/src/mobile/bottom-sheet/bottom-sheet-navigation/test/navigation-container.native.js +9 -2
- package/src/mobile/bottom-sheet/index.native.js +1 -1
- package/src/mobile/bottom-sheet-select-control/index.native.js +8 -2
- package/src/mobile/html-text-input/index.native.js +45 -29
- package/src/mobile/html-text-input/style.android.scss +2 -15
- package/src/mobile/html-text-input/style.ios.scss +2 -15
- package/src/mobile/html-text-input/{style-common.native.scss → style.scss} +16 -0
- package/src/mobile/keyboard-aware-flat-list/index.android.js +15 -5
- package/src/mobile/keyboard-aware-flat-list/index.ios.js +75 -46
- package/src/mobile/link-settings/test/link-settings-navigation.native.js +9 -1
- package/src/navigation/styles/navigation-styles.js +5 -5
- package/src/navigator/stories/index.js +16 -10
- package/src/notice/index.native.js +44 -54
- package/src/notice/list.native.js +27 -51
- package/src/notice/style.native.scss +1 -0
- package/src/palette-edit/index.js +37 -9
- package/src/palette-edit/style.scss +0 -7
- package/src/palette-edit/test/index.js +63 -0
- package/src/panel/README.md +1 -1
- package/src/placeholder/test/index.js +7 -0
- package/src/popover/README.md +7 -9
- package/src/popover/index.js +242 -417
- package/src/popover/style.scss +20 -190
- package/src/popover/test/__snapshots__/index.js.snap +6 -18
- package/src/query-controls/README.md +2 -2
- package/src/resizable-box/resize-tooltip/utils.ts +4 -5
- package/src/sandbox/index.js +2 -2
- package/src/sandbox/index.native.js +1 -1
- package/src/select-control/README.md +2 -2
- package/src/select-control/index.tsx +30 -29
- package/src/select-control/stories/index.tsx +90 -0
- package/src/select-control/styles/select-control-styles.ts +16 -12
- package/src/select-control/test/{select-control.js → select-control.tsx} +2 -2
- package/src/select-control/types.ts +66 -1
- package/src/surface/styles.js +1 -1
- package/src/tab-panel/style.scss +1 -1
- package/src/text/hook.js +1 -1
- package/src/text/styles/text-mixins.native.js +2 -2
- package/src/text/styles.js +1 -1
- package/src/text/test/__snapshots__/{index.js.snap → index.tsx.snap} +16 -0
- package/src/text/test/{index.js → index.tsx} +12 -6
- package/src/text-control/index.tsx +84 -0
- package/src/text-control/stories/index.tsx +66 -0
- package/src/text-control/types.ts +29 -0
- package/src/toggle-group-control/test/__snapshots__/index.js.snap +4 -10
- package/src/toggle-group-control/toggle-group-control/component.tsx +7 -3
- package/src/toggle-group-control/toggle-group-control-option-icon/component.tsx +1 -5
- package/src/toolbar-group/style.scss +20 -0
- package/src/tools-panel/test/__snapshots__/index.js.snap +2 -2
- package/src/tools-panel/test/index.js +71 -18
- package/src/tools-panel/tools-panel-header/component.tsx +75 -33
- package/src/tools-panel/types.ts +0 -1
- package/src/tooltip/index.js +8 -2
- package/src/tooltip/style.scss +2 -4
- package/src/tooltip/test/index.js +6 -0
- package/src/tooltip/test/index.native.js +1 -1
- package/src/ui/spinner/component.js +1 -1
- package/src/ui/spinner/test/__snapshots__/index.js.snap +3 -3
- package/src/unit-control/index.tsx +2 -5
- package/src/unit-control/styles/unit-control-styles.ts +3 -13
- package/src/unit-control/test/__snapshots__/index.tsx.snap +33 -0
- package/src/unit-control/test/{index.js → index.tsx} +295 -166
- package/src/unit-control/test/{utils.js → utils.ts} +38 -19
- package/src/unit-control/types.ts +4 -1
- package/src/unit-control/utils.ts +5 -3
- package/src/utils/colors-values.js +18 -22
- package/tsconfig.json +14 -3
- package/tsconfig.tsbuildinfo +1 -1
- package/build/box-control/visualizer.js +0 -165
- package/build/box-control/visualizer.js.map +0 -1
- package/build/flyout/context.js +0 -23
- package/build/flyout/context.js.map +0 -1
- package/build/flyout/flyout/component.js +0 -106
- package/build/flyout/flyout/component.js.map +0 -1
- package/build/flyout/flyout/hook.js +0 -53
- package/build/flyout/flyout/hook.js.map +0 -1
- package/build/flyout/flyout/index.js +0 -24
- package/build/flyout/flyout/index.js.map +0 -1
- package/build/flyout/flyout-content/component.js +0 -65
- package/build/flyout/flyout-content/component.js.map +0 -1
- package/build/flyout/flyout-content/index.js +0 -16
- package/build/flyout/flyout-content/index.js.map +0 -1
- package/build/flyout/index.js +0 -16
- package/build/flyout/index.js.map +0 -1
- package/build/flyout/styles.js +0 -46
- package/build/flyout/styles.js.map +0 -1
- package/build/flyout/utils.js +0 -36
- package/build/flyout/utils.js.map +0 -1
- package/build/mobile/html-text-input/container.android.js +0 -41
- package/build/mobile/html-text-input/container.android.js.map +0 -1
- package/build/mobile/html-text-input/container.ios.js +0 -60
- package/build/mobile/html-text-input/container.ios.js.map +0 -1
- package/build/popover/utils.js +0 -322
- package/build/popover/utils.js.map +0 -1
- package/build-module/box-control/visualizer.js +0 -154
- package/build-module/box-control/visualizer.js.map +0 -1
- package/build-module/flyout/context.js +0 -11
- package/build-module/flyout/context.js.map +0 -1
- package/build-module/flyout/flyout/component.js +0 -89
- package/build-module/flyout/flyout/component.js.map +0 -1
- package/build-module/flyout/flyout/hook.js +0 -44
- package/build-module/flyout/flyout/hook.js.map +0 -1
- package/build-module/flyout/flyout/index.js +0 -3
- package/build-module/flyout/flyout/index.js.map +0 -1
- package/build-module/flyout/flyout-content/component.js +0 -51
- package/build-module/flyout/flyout-content/component.js.map +0 -1
- package/build-module/flyout/flyout-content/index.js +0 -2
- package/build-module/flyout/flyout-content/index.js.map +0 -1
- package/build-module/flyout/index.js +0 -2
- package/build-module/flyout/index.js.map +0 -1
- package/build-module/flyout/styles.js +0 -27
- package/build-module/flyout/styles.js.map +0 -1
- package/build-module/flyout/utils.js +0 -25
- package/build-module/flyout/utils.js.map +0 -1
- package/build-module/mobile/html-text-input/container.android.js +0 -29
- package/build-module/mobile/html-text-input/container.android.js.map +0 -1
- package/build-module/mobile/html-text-input/container.ios.js +0 -48
- package/build-module/mobile/html-text-input/container.ios.js.map +0 -1
- package/build-module/popover/utils.js +0 -308
- package/build-module/popover/utils.js.map +0 -1
- package/build-types/flyout/context.d.ts +0 -6
- package/build-types/flyout/context.d.ts.map +0 -1
- package/build-types/flyout/flyout/component.d.ts +0 -21
- package/build-types/flyout/flyout/component.d.ts.map +0 -1
- package/build-types/flyout/flyout/hook.d.ts +0 -270
- package/build-types/flyout/flyout/hook.d.ts.map +0 -1
- package/build-types/flyout/flyout/index.d.ts +0 -3
- package/build-types/flyout/flyout/index.d.ts.map +0 -1
- package/build-types/flyout/flyout-content/component.d.ts +0 -3
- package/build-types/flyout/flyout-content/component.d.ts.map +0 -1
- package/build-types/flyout/flyout-content/index.d.ts +0 -2
- package/build-types/flyout/flyout-content/index.d.ts.map +0 -1
- package/build-types/flyout/index.d.ts +0 -2
- package/build-types/flyout/index.d.ts.map +0 -1
- package/build-types/flyout/styles.d.ts +0 -22
- package/build-types/flyout/styles.d.ts.map +0 -1
- package/build-types/flyout/types.d.ts +0 -80
- package/build-types/flyout/types.d.ts.map +0 -1
- package/build-types/flyout/utils.d.ts +0 -8
- package/build-types/flyout/utils.d.ts.map +0 -1
- package/build-types/popover/utils.d.ts +0 -70
- package/build-types/popover/utils.d.ts.map +0 -1
- package/build-types/toggle-group-control/toggle-group-control-option/styles.d.ts +0 -19
- package/build-types/toggle-group-control/toggle-group-control-option/styles.d.ts.map +0 -1
- package/src/box-control/visualizer.js +0 -116
- package/src/button-group/index.js +0 -17
- package/src/button-group/stories/index.js +0 -21
- package/src/date-time/stories/date.js +0 -17
- package/src/date-time/stories/index.js +0 -72
- package/src/date-time/stories/time.js +0 -32
- package/src/date-time/test/date.js +0 -97
- package/src/date-time/utils.js +0 -18
- package/src/flyout/context.js +0 -10
- package/src/flyout/flyout/README.md +0 -98
- package/src/flyout/flyout/component.js +0 -111
- package/src/flyout/flyout/hook.js +0 -45
- package/src/flyout/flyout/index.js +0 -2
- package/src/flyout/flyout-content/component.js +0 -53
- package/src/flyout/flyout-content/index.js +0 -1
- package/src/flyout/index.js +0 -1
- package/src/flyout/stories/index.js +0 -24
- package/src/flyout/styles.ts +0 -41
- package/src/flyout/test/__snapshots__/index.js.snap +0 -186
- package/src/flyout/test/index.js +0 -103
- package/src/flyout/types.ts +0 -84
- package/src/flyout/utils.js +0 -23
- package/src/input-control/stories/index.js +0 -71
- package/src/mobile/html-text-input/container.android.js +0 -23
- package/src/mobile/html-text-input/container.ios.js +0 -50
- package/src/popover/test/utils.js +0 -304
- package/src/popover/utils.js +0 -396
- package/src/select-control/stories/index.js +0 -104
- package/src/text-control/index.js +0 -72
- package/src/text-control/stories/index.js +0 -46
|
File without changes
|
|
@@ -72,8 +72,7 @@ function ButtonAction(_ref4) {
|
|
|
72
72
|
} = _ref4;
|
|
73
73
|
return createElement(Button, _extends({
|
|
74
74
|
className: classnames('components-circular-option-picker__clear', className),
|
|
75
|
-
|
|
76
|
-
variant: "secondary"
|
|
75
|
+
variant: "tertiary"
|
|
77
76
|
}, additionalProps), children);
|
|
78
77
|
}
|
|
79
78
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/components/src/circular-option-picker/index.js"],"names":["classnames","Icon","check","Button","Dropdown","Tooltip","Option","className","isSelected","selectedIconProps","tooltipText","additionalProps","optionButton","DropdownLinkAction","buttonProps","dropdownProps","linkText","isOpen","onToggle","ButtonAction","children","CircularOptionPicker","actions","options"],"mappings":";;AAAA;;AACA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,IAAT,EAAeC,KAAf,QAA4B,kBAA5B;AAEA;AACA;AACA;;AACA,OAAOC,MAAP,MAAmB,WAAnB;AACA,OAAOC,QAAP,MAAqB,aAArB;AACA,OAAOC,OAAP,MAAoB,YAApB;;AAEA,SAASC,MAAT,OAMI;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;AAKC,IAAA,OAAO,
|
|
1
|
+
{"version":3,"sources":["@wordpress/components/src/circular-option-picker/index.js"],"names":["classnames","Icon","check","Button","Dropdown","Tooltip","Option","className","isSelected","selectedIconProps","tooltipText","additionalProps","optionButton","DropdownLinkAction","buttonProps","dropdownProps","linkText","isOpen","onToggle","ButtonAction","children","CircularOptionPicker","actions","options"],"mappings":";;AAAA;;AACA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,IAAT,EAAeC,KAAf,QAA4B,kBAA5B;AAEA;AACA;AACA;;AACA,OAAOC,MAAP,MAAmB,WAAnB;AACA,OAAOC,QAAP,MAAqB,aAArB;AACA,OAAOC,OAAP,MAAoB,YAApB;;AAEA,SAASC,MAAT,OAMI;AAAA,MANa;AAChBC,IAAAA,SADgB;AAEhBC,IAAAA,UAFgB;AAGhBC,IAAAA,iBAHgB;AAIhBC,IAAAA,WAJgB;AAKhB,OAAGC;AALa,GAMb;AACH,QAAMC,YAAY,GACjB,cAAC,MAAD;AACC,IAAA,SAAS,EAAGJ,UADb;AAEC,IAAA,SAAS,EAAC;AAFX,KAGMG,eAHN,EADD;AAOA,SACC;AACC,IAAA,SAAS,EAAGX,UAAU,CACrBO,SADqB,EAErB,mDAFqB;AADvB,KAMGG,WAAW,GACZ,cAAC,OAAD;AAAS,IAAA,IAAI,EAAGA;AAAhB,KAAgCE,YAAhC,CADY,GAGZA,YATF,EAWGJ,UAAU,IACX,cAAC,IAAD;AACC,IAAA,IAAI,EAAGN;AADR,KAEQO,iBAAiB,GAAGA,iBAAH,GAAuB,EAFhD,EAZF,CADD;AAoBA;;AAED,SAASI,kBAAT,QAKI;AAAA,MALyB;AAC5BC,IAAAA,WAD4B;AAE5BP,IAAAA,SAF4B;AAG5BQ,IAAAA,aAH4B;AAI5BC,IAAAA;AAJ4B,GAKzB;AACH,SACC,cAAC,QAAD;AACC,IAAA,SAAS,EAAGhB,UAAU,CACrB,yDADqB,EAErBO,SAFqB,CADvB;AAKC,IAAA,YAAY,EAAG;AAAA,UAAE;AAAEU,QAAAA,MAAF;AAAUC,QAAAA;AAAV,OAAF;AAAA,aACd,cAAC,MAAD;AACC,yBAAgBD,MADjB;AAEC,yBAAc,MAFf;AAGC,QAAA,OAAO,EAAGC,QAHX;AAIC,QAAA,OAAO,EAAC;AAJT,SAKMJ,WALN,GAOGE,QAPH,CADc;AAAA;AALhB,KAgBMD,aAhBN,EADD;AAoBA;;AAED,SAASI,YAAT,QAAqE;AAAA,MAA9C;AAAEZ,IAAAA,SAAF;AAAaa,IAAAA,QAAb;AAAuB,OAAGT;AAA1B,GAA8C;AACpE,SACC,cAAC,MAAD;AACC,IAAA,SAAS,EAAGX,UAAU,CACrB,0CADqB,EAErBO,SAFqB,CADvB;AAKC,IAAA,OAAO,EAAC;AALT,KAMMI,eANN,GAQGS,QARH,CADD;AAYA;;AAED,eAAe,SAASC,oBAAT,QAKX;AAAA,MAL0C;AAC7CC,IAAAA,OAD6C;AAE7Cf,IAAAA,SAF6C;AAG7CgB,IAAAA,OAH6C;AAI7CH,IAAAA;AAJ6C,GAK1C;AACH,SACC;AACC,IAAA,SAAS,EAAGpB,UAAU,CACrB,mCADqB,EAErBO,SAFqB;AADvB,KAMC;AAAK,IAAA,SAAS,EAAC;AAAf,KACGgB,OADH,CAND,EASGH,QATH,EAUGE,OAAO,IACR;AAAK,IAAA,SAAS,EAAC;AAAf,KACGA,OADH,CAXF,CADD;AAkBA;AAEDD,oBAAoB,CAACf,MAArB,GAA8BA,MAA9B;AACAe,oBAAoB,CAACF,YAArB,GAAoCA,YAApC;AACAE,oBAAoB,CAACR,kBAArB,GAA0CA,kBAA1C","sourcesContent":["// @ts-nocheck\n/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { Icon, check } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport Button from '../button';\nimport Dropdown from '../dropdown';\nimport Tooltip from '../tooltip';\n\nfunction Option( {\n\tclassName,\n\tisSelected,\n\tselectedIconProps,\n\ttooltipText,\n\t...additionalProps\n} ) {\n\tconst optionButton = (\n\t\t<Button\n\t\t\tisPressed={ isSelected }\n\t\t\tclassName=\"components-circular-option-picker__option\"\n\t\t\t{ ...additionalProps }\n\t\t/>\n\t);\n\treturn (\n\t\t<div\n\t\t\tclassName={ classnames(\n\t\t\t\tclassName,\n\t\t\t\t'components-circular-option-picker__option-wrapper'\n\t\t\t) }\n\t\t>\n\t\t\t{ tooltipText ? (\n\t\t\t\t<Tooltip text={ tooltipText }>{ optionButton }</Tooltip>\n\t\t\t) : (\n\t\t\t\toptionButton\n\t\t\t) }\n\t\t\t{ isSelected && (\n\t\t\t\t<Icon\n\t\t\t\t\ticon={ check }\n\t\t\t\t\t{ ...( selectedIconProps ? selectedIconProps : {} ) }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</div>\n\t);\n}\n\nfunction DropdownLinkAction( {\n\tbuttonProps,\n\tclassName,\n\tdropdownProps,\n\tlinkText,\n} ) {\n\treturn (\n\t\t<Dropdown\n\t\t\tclassName={ classnames(\n\t\t\t\t'components-circular-option-picker__dropdown-link-action',\n\t\t\t\tclassName\n\t\t\t) }\n\t\t\trenderToggle={ ( { isOpen, onToggle } ) => (\n\t\t\t\t<Button\n\t\t\t\t\taria-expanded={ isOpen }\n\t\t\t\t\taria-haspopup=\"true\"\n\t\t\t\t\tonClick={ onToggle }\n\t\t\t\t\tvariant=\"link\"\n\t\t\t\t\t{ ...buttonProps }\n\t\t\t\t>\n\t\t\t\t\t{ linkText }\n\t\t\t\t</Button>\n\t\t\t) }\n\t\t\t{ ...dropdownProps }\n\t\t/>\n\t);\n}\n\nfunction ButtonAction( { className, children, ...additionalProps } ) {\n\treturn (\n\t\t<Button\n\t\t\tclassName={ classnames(\n\t\t\t\t'components-circular-option-picker__clear',\n\t\t\t\tclassName\n\t\t\t) }\n\t\t\tvariant=\"tertiary\"\n\t\t\t{ ...additionalProps }\n\t\t>\n\t\t\t{ children }\n\t\t</Button>\n\t);\n}\n\nexport default function CircularOptionPicker( {\n\tactions,\n\tclassName,\n\toptions,\n\tchildren,\n} ) {\n\treturn (\n\t\t<div\n\t\t\tclassName={ classnames(\n\t\t\t\t'components-circular-option-picker',\n\t\t\t\tclassName\n\t\t\t) }\n\t\t>\n\t\t\t<div className=\"components-circular-option-picker__swatches\">\n\t\t\t\t{ options }\n\t\t\t</div>\n\t\t\t{ children }\n\t\t\t{ actions && (\n\t\t\t\t<div className=\"components-circular-option-picker__custom-clear-wrapper\">\n\t\t\t\t\t{ actions }\n\t\t\t\t</div>\n\t\t\t) }\n\t\t</div>\n\t);\n}\n\nCircularOptionPicker.Option = Option;\nCircularOptionPicker.ButtonAction = ButtonAction;\nCircularOptionPicker.DropdownLinkAction = DropdownLinkAction;\n"]}
|
|
@@ -9,7 +9,6 @@ import { map } from 'lodash';
|
|
|
9
9
|
import { colord, extend } from 'colord';
|
|
10
10
|
import namesPlugin from 'colord/plugins/names';
|
|
11
11
|
import a11yPlugin from 'colord/plugins/a11y';
|
|
12
|
-
import classnames from 'classnames';
|
|
13
12
|
/**
|
|
14
13
|
* WordPress dependencies
|
|
15
14
|
*/
|
|
@@ -107,9 +106,11 @@ export function CustomColorPickerDropdown(_ref5) {
|
|
|
107
106
|
...props
|
|
108
107
|
} = _ref5;
|
|
109
108
|
return createElement(Dropdown, _extends({
|
|
110
|
-
contentClassName:
|
|
111
|
-
|
|
112
|
-
|
|
109
|
+
contentClassName: "components-color-palette__custom-color-dropdown-content",
|
|
110
|
+
popoverProps: isRenderedInSidebar ? {
|
|
111
|
+
placement: 'left-start',
|
|
112
|
+
offset: 20
|
|
113
|
+
} : undefined
|
|
113
114
|
}, props));
|
|
114
115
|
}
|
|
115
116
|
|
|
@@ -165,12 +166,6 @@ export default function ColorPalette(_ref6) {
|
|
|
165
166
|
enableAlpha: enableAlpha
|
|
166
167
|
});
|
|
167
168
|
|
|
168
|
-
let dropdownPosition;
|
|
169
|
-
|
|
170
|
-
if (__experimentalIsRenderedInSidebar) {
|
|
171
|
-
dropdownPosition = 'bottom left';
|
|
172
|
-
}
|
|
173
|
-
|
|
174
169
|
const colordColor = colord(value);
|
|
175
170
|
const valueWithoutLeadingHash = value !== null && value !== void 0 && value.startsWith('#') ? value.substring(1) : value !== null && value !== void 0 ? value : '';
|
|
176
171
|
const buttonLabelName = useMemo(() => extractColorNameFromCurrentValue(value, colors, showMultiplePalettes), [value, colors, showMultiplePalettes]);
|
|
@@ -180,7 +175,6 @@ export default function ColorPalette(_ref6) {
|
|
|
180
175
|
spacing: 3,
|
|
181
176
|
className: className
|
|
182
177
|
}, !disableCustomColors && createElement(CustomColorPickerDropdown, {
|
|
183
|
-
position: dropdownPosition,
|
|
184
178
|
isRenderedInSidebar: __experimentalIsRenderedInSidebar,
|
|
185
179
|
renderContent: renderCustomColorPicker,
|
|
186
180
|
renderToggle: _ref7 => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/components/src/color-palette/index.js"],"names":["map","colord","extend","namesPlugin","a11yPlugin","classnames","__","sprintf","useCallback","useMemo","Dropdown","ColorPicker","CircularOptionPicker","VStack","Flex","FlexItem","Truncate","ColorHeading","SinglePalette","className","clearColor","colors","onChange","value","actions","colorOptions","color","name","colordColor","fill","contrast","backgroundColor","MultiplePalettes","index","colorPalette","length","CustomColorPickerDropdown","isRenderedInSidebar","props","extractColorNameFromCurrentValue","currentValue","showMultiplePalettes","colorPalettes","paletteColors","colorName","colorValue","toHex","ColorPalette","clearable","disableCustomColors","enableAlpha","__experimentalHasMultipleOrigins","__experimentalIsRenderedInSidebar","undefined","Component","renderCustomColorPicker","dropdownPosition","valueWithoutLeadingHash","startsWith","substring","buttonLabelName","customColorAccessibleLabel","isOpen","onToggle","background"],"mappings":";;AAAA;;AACA;AACA;AACA;AACA,SAASA,GAAT,QAAoB,QAApB;AACA,SAASC,MAAT,EAAiBC,MAAjB,QAA+B,QAA/B;AACA,OAAOC,WA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AS,EAAGT,SADb;AAEC,IAAA,UAAU,EAAG5B,UAFd;AAGC,IAAA,MAAM,EAAGC,MAHV;AAIC,IAAA,QAAQ,EAAGC,QAJZ;AAKC,IAAA,KAAK,EAAGC,KALT;AAMC,IAAA,OAAO,EACN,CAAC,CAAEyB,SAAH,IACC,cAAC,oBAAD,CAAsB,YAAtB;AACC,MAAA,OAAO,EAAG5B;AADX,OAGGd,EAAE,CAAE,OAAF,CAHL;AARH,IA1CD,CADD;AA6DA","sourcesContent":["// @ts-nocheck\n/**\n * External dependencies\n */\nimport { map } from 'lodash';\nimport { colord, extend } from 'colord';\nimport namesPlugin from 'colord/plugins/names';\nimport a11yPlugin from 'colord/plugins/a11y';\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useCallback, useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport Dropdown from '../dropdown';\nimport { ColorPicker } from '../color-picker';\nimport CircularOptionPicker from '../circular-option-picker';\nimport { VStack } from '../v-stack';\nimport { Flex, FlexItem } from '../flex';\nimport { Truncate } from '../truncate';\nimport { ColorHeading } from './styles';\n\nextend( [ namesPlugin, a11yPlugin ] );\n\nfunction SinglePalette( {\n\tclassName,\n\tclearColor,\n\tcolors,\n\tonChange,\n\tvalue,\n\tactions,\n} ) {\n\tconst colorOptions = useMemo( () => {\n\t\treturn map( colors, ( { color, name } ) => {\n\t\t\tconst colordColor = colord( color );\n\n\t\t\treturn (\n\t\t\t\t<CircularOptionPicker.Option\n\t\t\t\t\tkey={ color }\n\t\t\t\t\tisSelected={ value === color }\n\t\t\t\t\tselectedIconProps={\n\t\t\t\t\t\tvalue === color\n\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\tfill:\n\t\t\t\t\t\t\t\t\t\tcolordColor.contrast() >\n\t\t\t\t\t\t\t\t\t\tcolordColor.contrast( '#000' )\n\t\t\t\t\t\t\t\t\t\t\t? '#fff'\n\t\t\t\t\t\t\t\t\t\t\t: '#000',\n\t\t\t\t\t\t\t }\n\t\t\t\t\t\t\t: {}\n\t\t\t\t\t}\n\t\t\t\t\ttooltipText={\n\t\t\t\t\t\tname ||\n\t\t\t\t\t\t// translators: %s: color hex code e.g: \"#f00\".\n\t\t\t\t\t\tsprintf( __( 'Color code: %s' ), color )\n\t\t\t\t\t}\n\t\t\t\t\tstyle={ { backgroundColor: color, color } }\n\t\t\t\t\tonClick={\n\t\t\t\t\t\tvalue === color ? clearColor : () => onChange( color )\n\t\t\t\t\t}\n\t\t\t\t\taria-label={\n\t\t\t\t\t\tname\n\t\t\t\t\t\t\t? // translators: %s: The name of the color e.g: \"vivid red\".\n\t\t\t\t\t\t\t sprintf( __( 'Color: %s' ), name )\n\t\t\t\t\t\t\t: // translators: %s: color hex code e.g: \"#f00\".\n\t\t\t\t\t\t\t sprintf( __( 'Color code: %s' ), color )\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t);\n\t\t} );\n\t}, [ colors, value, onChange, clearColor ] );\n\treturn (\n\t\t<CircularOptionPicker\n\t\t\tclassName={ className }\n\t\t\toptions={ colorOptions }\n\t\t\tactions={ actions }\n\t\t/>\n\t);\n}\n\nfunction MultiplePalettes( {\n\tclassName,\n\tclearColor,\n\tcolors,\n\tonChange,\n\tvalue,\n\tactions,\n} ) {\n\treturn (\n\t\t<VStack spacing={ 3 } className={ className }>\n\t\t\t{ colors.map( ( { name, colors: colorPalette }, index ) => {\n\t\t\t\treturn (\n\t\t\t\t\t<VStack spacing={ 2 } key={ index }>\n\t\t\t\t\t\t<ColorHeading>{ name }</ColorHeading>\n\t\t\t\t\t\t<SinglePalette\n\t\t\t\t\t\t\tclearColor={ clearColor }\n\t\t\t\t\t\t\tcolors={ colorPalette }\n\t\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t\t\tactions={\n\t\t\t\t\t\t\t\tcolors.length === index + 1 ? actions : null\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</VStack>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</VStack>\n\t);\n}\n\nexport function CustomColorPickerDropdown( { isRenderedInSidebar, ...props } ) {\n\treturn (\n\t\t<Dropdown\n\t\t\tcontentClassName={ classnames(\n\t\t\t\t'components-color-palette__custom-color-dropdown-content',\n\t\t\t\t{\n\t\t\t\t\t'is-rendered-in-sidebar': isRenderedInSidebar,\n\t\t\t\t}\n\t\t\t) }\n\t\t\t{ ...props }\n\t\t/>\n\t);\n}\n\nconst extractColorNameFromCurrentValue = (\n\tcurrentValue,\n\tcolors = [],\n\tshowMultiplePalettes = false\n) => {\n\tif ( ! currentValue ) {\n\t\treturn '';\n\t}\n\n\t// Normalize format of `colors` to simplify the following loop\n\tconst colorPalettes = showMultiplePalettes ? colors : [ { colors } ];\n\tfor ( const { colors: paletteColors } of colorPalettes ) {\n\t\tfor ( const { name: colorName, color: colorValue } of paletteColors ) {\n\t\t\tif (\n\t\t\t\tcolord( currentValue ).toHex() === colord( colorValue ).toHex()\n\t\t\t) {\n\t\t\t\treturn colorName;\n\t\t\t}\n\t\t}\n\t}\n\n\t// translators: shown when the user has picked a custom color (i.e not in the palette of colors).\n\treturn __( 'Custom' );\n};\n\nexport default function ColorPalette( {\n\tclearable = true,\n\tclassName,\n\tcolors,\n\tdisableCustomColors = false,\n\tenableAlpha,\n\tonChange,\n\tvalue,\n\t__experimentalHasMultipleOrigins = false,\n\t__experimentalIsRenderedInSidebar = false,\n} ) {\n\tconst clearColor = useCallback( () => onChange( undefined ), [ onChange ] );\n\tconst showMultiplePalettes =\n\t\t__experimentalHasMultipleOrigins && colors?.length;\n\tconst Component = showMultiplePalettes ? MultiplePalettes : SinglePalette;\n\n\tconst renderCustomColorPicker = () => (\n\t\t<ColorPicker\n\t\t\tcolor={ value }\n\t\t\tonChange={ ( color ) => onChange( color ) }\n\t\t\tenableAlpha={ enableAlpha }\n\t\t/>\n\t);\n\n\tlet dropdownPosition;\n\tif ( __experimentalIsRenderedInSidebar ) {\n\t\tdropdownPosition = 'bottom left';\n\t}\n\n\tconst colordColor = colord( value );\n\n\tconst valueWithoutLeadingHash = value?.startsWith( '#' )\n\t\t? value.substring( 1 )\n\t\t: value ?? '';\n\tconst buttonLabelName = useMemo(\n\t\t() =>\n\t\t\textractColorNameFromCurrentValue(\n\t\t\t\tvalue,\n\t\t\t\tcolors,\n\t\t\t\tshowMultiplePalettes\n\t\t\t),\n\t\t[ value, colors, showMultiplePalettes ]\n\t);\n\n\tconst customColorAccessibleLabel = !! valueWithoutLeadingHash\n\t\t? sprintf(\n\t\t\t\t// translators: %1$s: The name of the color e.g: \"vivid red\". %2$s: The color's hex code e.g: \"#f00\".\n\t\t\t\t__(\n\t\t\t\t\t'Custom color picker. The currently selected color is called \"%1$s\" and has a value of \"%2$s\".'\n\t\t\t\t),\n\t\t\t\tbuttonLabelName,\n\t\t\t\tvalueWithoutLeadingHash\n\t\t )\n\t\t: __( 'Custom color picker.' );\n\n\treturn (\n\t\t<VStack spacing={ 3 } className={ className }>\n\t\t\t{ ! disableCustomColors && (\n\t\t\t\t<CustomColorPickerDropdown\n\t\t\t\t\tposition={ dropdownPosition }\n\t\t\t\t\tisRenderedInSidebar={ __experimentalIsRenderedInSidebar }\n\t\t\t\t\trenderContent={ renderCustomColorPicker }\n\t\t\t\t\trenderToggle={ ( { isOpen, onToggle } ) => (\n\t\t\t\t\t\t<Flex\n\t\t\t\t\t\t\tas={ 'button' }\n\t\t\t\t\t\t\tjustify=\"space-between\"\n\t\t\t\t\t\t\talign=\"flex-start\"\n\t\t\t\t\t\t\tclassName=\"components-color-palette__custom-color\"\n\t\t\t\t\t\t\taria-expanded={ isOpen }\n\t\t\t\t\t\t\taria-haspopup=\"true\"\n\t\t\t\t\t\t\tonClick={ onToggle }\n\t\t\t\t\t\t\taria-label={ customColorAccessibleLabel }\n\t\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\t\tbackground: value,\n\t\t\t\t\t\t\t\tcolor:\n\t\t\t\t\t\t\t\t\tcolordColor.contrast() >\n\t\t\t\t\t\t\t\t\tcolordColor.contrast( '#000' )\n\t\t\t\t\t\t\t\t\t\t? '#fff'\n\t\t\t\t\t\t\t\t\t\t: '#000',\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<FlexItem\n\t\t\t\t\t\t\t\tisBlock\n\t\t\t\t\t\t\t\tas={ Truncate }\n\t\t\t\t\t\t\t\tclassName=\"components-color-palette__custom-color-name\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ buttonLabelName }\n\t\t\t\t\t\t\t</FlexItem>\n\t\t\t\t\t\t\t<FlexItem\n\t\t\t\t\t\t\t\tas=\"span\"\n\t\t\t\t\t\t\t\tclassName=\"components-color-palette__custom-color-value\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ valueWithoutLeadingHash }\n\t\t\t\t\t\t\t</FlexItem>\n\t\t\t\t\t\t</Flex>\n\t\t\t\t\t) }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t<Component\n\t\t\t\tclearable={ clearable }\n\t\t\t\tclearColor={ clearColor }\n\t\t\t\tcolors={ colors }\n\t\t\t\tonChange={ onChange }\n\t\t\t\tvalue={ value }\n\t\t\t\tactions={\n\t\t\t\t\t!! clearable && (\n\t\t\t\t\t\t<CircularOptionPicker.ButtonAction\n\t\t\t\t\t\t\tonClick={ clearColor }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Clear' ) }\n\t\t\t\t\t\t</CircularOptionPicker.ButtonAction>\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t/>\n\t\t</VStack>\n\t);\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/components/src/color-palette/index.js"],"names":["map","colord","extend","namesPlugin","a11yPlugin","__","sprintf","useCallback","useMemo","Dropdown","ColorPicker","CircularOptionPicker","VStack","Flex","FlexItem","Truncate","ColorHeading","SinglePalette","className","clearColor","colors","onChange","value","actions","colorOptions","color","name","colordColor","fill","contrast","backgroundColor","MultiplePalettes","index","colorPalette","length","CustomColorPickerDropdown","isRenderedInSidebar","props","placement","offset","undefined","extractColorNameFromCurrentValue","currentValue","showMultiplePalettes","colorPalettes","paletteColors","colorName","colorValue","toHex","ColorPalette","clearable","disableCustomColors","enableAlpha","__experimentalHasMultipleOrigins","__experimentalIsRenderedInSidebar","Component","renderCustomColorPicker","valueWithoutLeadingHash","startsWith","substring","buttonLabelName","customColorAccessibleLabel","isOpen","onToggle","background"],"mappings":";;AAAA;;AACA;AACA;AACA;AACA,SAASA,GAAT,QAAoB,QAApB;AACA,SAASC,MAAT,EAAiBC,MAAjB,QAA+B,QAA/B;AACA,OAAOC,WAAP,MAAwB,sBAAxB;AACA,OAAOC,UAAP,MAAuB,qBAAvB;AAEA;AACA;AACA;;AACA,SAASC,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SAASC,WAAT,EAAsBC,OAAtB,QAAqC,oBAArC;AAEA;AACA;AACA;;AACA,OAAOC,QAAP,MAAqB,aAArB;AACA,SAASC,WAAT,QAA4B,iBAA5B;AACA,OAAOC,oBAAP,MAAiC,2BAAjC;AACA,SAASC,MAAT,QAAuB,YAAvB;AACA,SAASC,IAAT,EAAeC,QAAf,QAA+B,SAA/B;AACA,SAASC,QAAT,QAAyB,aAAzB;AACA,SAASC,YAAT,QAA6B,UAA7B;AAEAd,MAAM,CAAE,CAAEC,WAAF,EAAeC,UAAf,CAAF,CAAN;;AAEA,SAASa,aAAT,OAOI;AAAA,MAPoB;AACvBC,IAAAA,SADuB;AAEvBC,IAAAA,UAFuB;AAGvBC,IAAAA,MAHuB;AAIvBC,IAAAA,QAJuB;AAKvBC,IAAAA,KALuB;AAMvBC,IAAAA;AANuB,GAOpB;AACH,QAAMC,YAAY,GAAGhB,OAAO,CAAE,MAAM;AACnC,WAAOR,GAAG,CAAEoB,MAAF,EAAU,SAAuB;AAAA,UAArB;AAAEK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,EACJE,WAAW,CAACE,QAAZ,KACAF,WAAW,CAACE,QAAZ,CAAsB,MAAtB,CADA,GAEG,MAFH,GAGG;AANG;AATT,SAkBC,cAAC,QAAD;AACC,QAAA,OAAO,MADR;AAEC,QAAA,EAAE,EAAGd,QAFN;AAGC,QAAA,SAAS,EAAC;AAHX,SAKG6C,eALH,CAlBD,EAyBC,cAAC,QAAD;AACC,QAAA,EAAE,EAAC,MADJ;AAEC,QAAA,SAAS,EAAC;AAFX,SAIGH,uBAJH,CAzBD,CADc;AAAA;AAHhB,IAFF,EAyCC,cAAC,SAAD;AACC,IAAA,SAAS,EAAGP,SADb;AAEC,IAAA,UAAU,EAAG/B,UAFd;AAGC,IAAA,MAAM,EAAGC,MAHV;AAIC,IAAA,QAAQ,EAAGC,QAJZ;AAKC,IAAA,KAAK,EAAGC,KALT;AAMC,IAAA,OAAO,EACN,CAAC,CAAE4B,SAAH,IACC,cAAC,oBAAD,CAAsB,YAAtB;AACC,MAAA,OAAO,EAAG/B;AADX,OAGGd,EAAE,CAAE,OAAF,CAHL;AARH,IAzCD,CADD;AA4DA","sourcesContent":["// @ts-nocheck\n/**\n * External dependencies\n */\nimport { map } from 'lodash';\nimport { colord, extend } from 'colord';\nimport namesPlugin from 'colord/plugins/names';\nimport a11yPlugin from 'colord/plugins/a11y';\n\n/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useCallback, useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport Dropdown from '../dropdown';\nimport { ColorPicker } from '../color-picker';\nimport CircularOptionPicker from '../circular-option-picker';\nimport { VStack } from '../v-stack';\nimport { Flex, FlexItem } from '../flex';\nimport { Truncate } from '../truncate';\nimport { ColorHeading } from './styles';\n\nextend( [ namesPlugin, a11yPlugin ] );\n\nfunction SinglePalette( {\n\tclassName,\n\tclearColor,\n\tcolors,\n\tonChange,\n\tvalue,\n\tactions,\n} ) {\n\tconst colorOptions = useMemo( () => {\n\t\treturn map( colors, ( { color, name } ) => {\n\t\t\tconst colordColor = colord( color );\n\n\t\t\treturn (\n\t\t\t\t<CircularOptionPicker.Option\n\t\t\t\t\tkey={ color }\n\t\t\t\t\tisSelected={ value === color }\n\t\t\t\t\tselectedIconProps={\n\t\t\t\t\t\tvalue === color\n\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\tfill:\n\t\t\t\t\t\t\t\t\t\tcolordColor.contrast() >\n\t\t\t\t\t\t\t\t\t\tcolordColor.contrast( '#000' )\n\t\t\t\t\t\t\t\t\t\t\t? '#fff'\n\t\t\t\t\t\t\t\t\t\t\t: '#000',\n\t\t\t\t\t\t\t }\n\t\t\t\t\t\t\t: {}\n\t\t\t\t\t}\n\t\t\t\t\ttooltipText={\n\t\t\t\t\t\tname ||\n\t\t\t\t\t\t// translators: %s: color hex code e.g: \"#f00\".\n\t\t\t\t\t\tsprintf( __( 'Color code: %s' ), color )\n\t\t\t\t\t}\n\t\t\t\t\tstyle={ { backgroundColor: color, color } }\n\t\t\t\t\tonClick={\n\t\t\t\t\t\tvalue === color ? clearColor : () => onChange( color )\n\t\t\t\t\t}\n\t\t\t\t\taria-label={\n\t\t\t\t\t\tname\n\t\t\t\t\t\t\t? // translators: %s: The name of the color e.g: \"vivid red\".\n\t\t\t\t\t\t\t sprintf( __( 'Color: %s' ), name )\n\t\t\t\t\t\t\t: // translators: %s: color hex code e.g: \"#f00\".\n\t\t\t\t\t\t\t sprintf( __( 'Color code: %s' ), color )\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t);\n\t\t} );\n\t}, [ colors, value, onChange, clearColor ] );\n\treturn (\n\t\t<CircularOptionPicker\n\t\t\tclassName={ className }\n\t\t\toptions={ colorOptions }\n\t\t\tactions={ actions }\n\t\t/>\n\t);\n}\n\nfunction MultiplePalettes( {\n\tclassName,\n\tclearColor,\n\tcolors,\n\tonChange,\n\tvalue,\n\tactions,\n} ) {\n\treturn (\n\t\t<VStack spacing={ 3 } className={ className }>\n\t\t\t{ colors.map( ( { name, colors: colorPalette }, index ) => {\n\t\t\t\treturn (\n\t\t\t\t\t<VStack spacing={ 2 } key={ index }>\n\t\t\t\t\t\t<ColorHeading>{ name }</ColorHeading>\n\t\t\t\t\t\t<SinglePalette\n\t\t\t\t\t\t\tclearColor={ clearColor }\n\t\t\t\t\t\t\tcolors={ colorPalette }\n\t\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t\t\tactions={\n\t\t\t\t\t\t\t\tcolors.length === index + 1 ? actions : null\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</VStack>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</VStack>\n\t);\n}\n\nexport function CustomColorPickerDropdown( { isRenderedInSidebar, ...props } ) {\n\treturn (\n\t\t<Dropdown\n\t\t\tcontentClassName=\"components-color-palette__custom-color-dropdown-content\"\n\t\t\tpopoverProps={\n\t\t\t\tisRenderedInSidebar\n\t\t\t\t\t? { placement: 'left-start', offset: 20 }\n\t\t\t\t\t: undefined\n\t\t\t}\n\t\t\t{ ...props }\n\t\t/>\n\t);\n}\n\nconst extractColorNameFromCurrentValue = (\n\tcurrentValue,\n\tcolors = [],\n\tshowMultiplePalettes = false\n) => {\n\tif ( ! currentValue ) {\n\t\treturn '';\n\t}\n\n\t// Normalize format of `colors` to simplify the following loop\n\tconst colorPalettes = showMultiplePalettes ? colors : [ { colors } ];\n\tfor ( const { colors: paletteColors } of colorPalettes ) {\n\t\tfor ( const { name: colorName, color: colorValue } of paletteColors ) {\n\t\t\tif (\n\t\t\t\tcolord( currentValue ).toHex() === colord( colorValue ).toHex()\n\t\t\t) {\n\t\t\t\treturn colorName;\n\t\t\t}\n\t\t}\n\t}\n\n\t// translators: shown when the user has picked a custom color (i.e not in the palette of colors).\n\treturn __( 'Custom' );\n};\n\nexport default function ColorPalette( {\n\tclearable = true,\n\tclassName,\n\tcolors,\n\tdisableCustomColors = false,\n\tenableAlpha,\n\tonChange,\n\tvalue,\n\t__experimentalHasMultipleOrigins = false,\n\t__experimentalIsRenderedInSidebar = false,\n} ) {\n\tconst clearColor = useCallback( () => onChange( undefined ), [ onChange ] );\n\tconst showMultiplePalettes =\n\t\t__experimentalHasMultipleOrigins && colors?.length;\n\tconst Component = showMultiplePalettes ? MultiplePalettes : SinglePalette;\n\n\tconst renderCustomColorPicker = () => (\n\t\t<ColorPicker\n\t\t\tcolor={ value }\n\t\t\tonChange={ ( color ) => onChange( color ) }\n\t\t\tenableAlpha={ enableAlpha }\n\t\t/>\n\t);\n\n\tconst colordColor = colord( value );\n\n\tconst valueWithoutLeadingHash = value?.startsWith( '#' )\n\t\t? value.substring( 1 )\n\t\t: value ?? '';\n\tconst buttonLabelName = useMemo(\n\t\t() =>\n\t\t\textractColorNameFromCurrentValue(\n\t\t\t\tvalue,\n\t\t\t\tcolors,\n\t\t\t\tshowMultiplePalettes\n\t\t\t),\n\t\t[ value, colors, showMultiplePalettes ]\n\t);\n\n\tconst customColorAccessibleLabel = !! valueWithoutLeadingHash\n\t\t? sprintf(\n\t\t\t\t// translators: %1$s: The name of the color e.g: \"vivid red\". %2$s: The color's hex code e.g: \"#f00\".\n\t\t\t\t__(\n\t\t\t\t\t'Custom color picker. The currently selected color is called \"%1$s\" and has a value of \"%2$s\".'\n\t\t\t\t),\n\t\t\t\tbuttonLabelName,\n\t\t\t\tvalueWithoutLeadingHash\n\t\t )\n\t\t: __( 'Custom color picker.' );\n\n\treturn (\n\t\t<VStack spacing={ 3 } className={ className }>\n\t\t\t{ ! disableCustomColors && (\n\t\t\t\t<CustomColorPickerDropdown\n\t\t\t\t\tisRenderedInSidebar={ __experimentalIsRenderedInSidebar }\n\t\t\t\t\trenderContent={ renderCustomColorPicker }\n\t\t\t\t\trenderToggle={ ( { isOpen, onToggle } ) => (\n\t\t\t\t\t\t<Flex\n\t\t\t\t\t\t\tas={ 'button' }\n\t\t\t\t\t\t\tjustify=\"space-between\"\n\t\t\t\t\t\t\talign=\"flex-start\"\n\t\t\t\t\t\t\tclassName=\"components-color-palette__custom-color\"\n\t\t\t\t\t\t\taria-expanded={ isOpen }\n\t\t\t\t\t\t\taria-haspopup=\"true\"\n\t\t\t\t\t\t\tonClick={ onToggle }\n\t\t\t\t\t\t\taria-label={ customColorAccessibleLabel }\n\t\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\t\tbackground: value,\n\t\t\t\t\t\t\t\tcolor:\n\t\t\t\t\t\t\t\t\tcolordColor.contrast() >\n\t\t\t\t\t\t\t\t\tcolordColor.contrast( '#000' )\n\t\t\t\t\t\t\t\t\t\t? '#fff'\n\t\t\t\t\t\t\t\t\t\t: '#000',\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<FlexItem\n\t\t\t\t\t\t\t\tisBlock\n\t\t\t\t\t\t\t\tas={ Truncate }\n\t\t\t\t\t\t\t\tclassName=\"components-color-palette__custom-color-name\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ buttonLabelName }\n\t\t\t\t\t\t\t</FlexItem>\n\t\t\t\t\t\t\t<FlexItem\n\t\t\t\t\t\t\t\tas=\"span\"\n\t\t\t\t\t\t\t\tclassName=\"components-color-palette__custom-color-value\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ valueWithoutLeadingHash }\n\t\t\t\t\t\t\t</FlexItem>\n\t\t\t\t\t\t</Flex>\n\t\t\t\t\t) }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t<Component\n\t\t\t\tclearable={ clearable }\n\t\t\t\tclearColor={ clearColor }\n\t\t\t\tcolors={ colors }\n\t\t\t\tonChange={ onChange }\n\t\t\t\tvalue={ value }\n\t\t\t\tactions={\n\t\t\t\t\t!! clearable && (\n\t\t\t\t\t\t<CircularOptionPicker.ButtonAction\n\t\t\t\t\t\t\tonClick={ clearColor }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Clear' ) }\n\t\t\t\t\t\t</CircularOptionPicker.ButtonAction>\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t/>\n\t\t</VStack>\n\t);\n}\n"]}
|
|
@@ -4,10 +4,15 @@ import { createElement } from "@wordpress/element";
|
|
|
4
4
|
* External dependencies
|
|
5
5
|
*/
|
|
6
6
|
import moment from 'moment';
|
|
7
|
-
import classnames from 'classnames';
|
|
8
|
-
//
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
import classnames from 'classnames';
|
|
8
|
+
import { noop } from 'lodash'; // `react-dates` doesn't tree-shake correctly, so we import from the individual
|
|
9
|
+
// component here.
|
|
10
|
+
// @ts-expect-error TypeScript won't find any type declarations at
|
|
11
|
+
// `react-dates/lib/components/DayPickerSingleDateController` as they're located
|
|
12
|
+
// at `react-dates`.
|
|
13
|
+
|
|
14
|
+
import UntypedDayPickerSingleDateController from 'react-dates/lib/components/DayPickerSingleDateController';
|
|
15
|
+
const TypedDayPickerSingleDateController = UntypedDayPickerSingleDateController;
|
|
11
16
|
/**
|
|
12
17
|
* WordPress dependencies
|
|
13
18
|
*/
|
|
@@ -19,10 +24,6 @@ import { isRTL, _n, sprintf } from '@wordpress/i18n';
|
|
|
19
24
|
*/
|
|
20
25
|
|
|
21
26
|
import { getMomentDate } from './utils';
|
|
22
|
-
/**
|
|
23
|
-
* Module Constants
|
|
24
|
-
*/
|
|
25
|
-
|
|
26
27
|
const TIMEZONELESS_FORMAT = 'YYYY-MM-DDTHH:mm:ss';
|
|
27
28
|
const ARIAL_LABEL_TIME_FORMAT = 'dddd, LL';
|
|
28
29
|
|
|
@@ -31,7 +32,7 @@ function DatePickerDay(_ref) {
|
|
|
31
32
|
day,
|
|
32
33
|
events = []
|
|
33
34
|
} = _ref;
|
|
34
|
-
const ref = useRef();
|
|
35
|
+
const ref = useRef(null);
|
|
35
36
|
/*
|
|
36
37
|
* a11y hack to make the `There is/are n events` string
|
|
37
38
|
* available speaking for readers,
|
|
@@ -43,7 +44,7 @@ function DatePickerDay(_ref) {
|
|
|
43
44
|
var _ref$current;
|
|
44
45
|
|
|
45
46
|
// Bail when no parent node.
|
|
46
|
-
if (!(ref
|
|
47
|
+
if (!((ref === null || ref === void 0 ? void 0 : (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.parentNode) instanceof Element)) {
|
|
47
48
|
return;
|
|
48
49
|
}
|
|
49
50
|
|
|
@@ -69,8 +70,28 @@ function DatePickerDay(_ref) {
|
|
|
69
70
|
})
|
|
70
71
|
}, day.format('D'));
|
|
71
72
|
}
|
|
73
|
+
/**
|
|
74
|
+
* DatePicker is a React component that renders a calendar for date selection.
|
|
75
|
+
*
|
|
76
|
+
* ```jsx
|
|
77
|
+
* import { DatePicker } from '@wordpress/components';
|
|
78
|
+
* import { useState } from '@wordpress/element';
|
|
79
|
+
*
|
|
80
|
+
* const MyDatePicker = () => {
|
|
81
|
+
* const [ date, setDate ] = useState( new Date() );
|
|
82
|
+
*
|
|
83
|
+
* return (
|
|
84
|
+
* <DatePicker
|
|
85
|
+
* currentDate={ date }
|
|
86
|
+
* onChange={ ( newDate ) => setDate( newDate ) }
|
|
87
|
+
* />
|
|
88
|
+
* );
|
|
89
|
+
* };
|
|
90
|
+
* ```
|
|
91
|
+
*/
|
|
72
92
|
|
|
73
|
-
|
|
93
|
+
|
|
94
|
+
export function DatePicker(_ref2) {
|
|
74
95
|
let {
|
|
75
96
|
currentDate,
|
|
76
97
|
onChange,
|
|
@@ -78,7 +99,7 @@ function DatePicker(_ref2) {
|
|
|
78
99
|
isInvalidDate,
|
|
79
100
|
onMonthPreviewed
|
|
80
101
|
} = _ref2;
|
|
81
|
-
const nodeRef = useRef();
|
|
102
|
+
const nodeRef = useRef(null);
|
|
82
103
|
|
|
83
104
|
const onMonthPreviewedHandler = newMonthDate => {
|
|
84
105
|
onMonthPreviewed === null || onMonthPreviewed === void 0 ? void 0 : onMonthPreviewed(newMonthDate.toISOString());
|
|
@@ -108,7 +129,7 @@ function DatePicker(_ref2) {
|
|
|
108
129
|
// Retrieve the focus region div.
|
|
109
130
|
const focusRegion = nodeRef.current.querySelector('.DayPicker_focusRegion');
|
|
110
131
|
|
|
111
|
-
if (!focusRegion) {
|
|
132
|
+
if (!(focusRegion instanceof HTMLElement)) {
|
|
112
133
|
return;
|
|
113
134
|
} // Keep the focus on focus region.
|
|
114
135
|
|
|
@@ -118,14 +139,18 @@ function DatePicker(_ref2) {
|
|
|
118
139
|
};
|
|
119
140
|
|
|
120
141
|
const onChangeMoment = newDate => {
|
|
121
|
-
|
|
142
|
+
if (!newDate) {
|
|
143
|
+
return;
|
|
144
|
+
} // If currentDate is null, use now as momentTime to designate hours, minutes, seconds.
|
|
145
|
+
|
|
146
|
+
|
|
122
147
|
const momentDate = currentDate ? moment(currentDate) : moment();
|
|
123
148
|
const momentTime = {
|
|
124
149
|
hours: momentDate.hours(),
|
|
125
150
|
minutes: momentDate.minutes(),
|
|
126
151
|
seconds: 0
|
|
127
152
|
};
|
|
128
|
-
onChange(newDate.set(momentTime).format(TIMEZONELESS_FORMAT)); // Keep focus on the date picker.
|
|
153
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(newDate.set(momentTime).format(TIMEZONELESS_FORMAT)); // Keep focus on the date picker.
|
|
129
154
|
|
|
130
155
|
keepFocusInside();
|
|
131
156
|
};
|
|
@@ -142,7 +167,7 @@ function DatePicker(_ref2) {
|
|
|
142
167
|
return createElement("div", {
|
|
143
168
|
className: "components-datetime__date",
|
|
144
169
|
ref: nodeRef
|
|
145
|
-
}, createElement(
|
|
170
|
+
}, createElement(TypedDayPickerSingleDateController, {
|
|
146
171
|
date: momentDate,
|
|
147
172
|
daySize: 30,
|
|
148
173
|
focused: true,
|
|
@@ -158,16 +183,16 @@ function DatePicker(_ref2) {
|
|
|
158
183
|
dayAriaLabelFormat: ARIAL_LABEL_TIME_FORMAT,
|
|
159
184
|
isRTL: isRTL(),
|
|
160
185
|
isOutsideRange: date => {
|
|
161
|
-
return isInvalidDate && isInvalidDate(date.toDate());
|
|
186
|
+
return !!isInvalidDate && isInvalidDate(date.toDate());
|
|
162
187
|
},
|
|
163
188
|
onPrevMonthClick: onMonthPreviewedHandler,
|
|
164
189
|
onNextMonthClick: onMonthPreviewedHandler,
|
|
165
190
|
renderDayContents: day => createElement(DatePickerDay, {
|
|
166
191
|
day: day,
|
|
167
192
|
events: getEventsPerDay(day)
|
|
168
|
-
})
|
|
193
|
+
}),
|
|
194
|
+
onFocusChange: noop
|
|
169
195
|
}));
|
|
170
196
|
}
|
|
171
|
-
|
|
172
197
|
export default DatePicker;
|
|
173
198
|
//# sourceMappingURL=date.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/components/src/date-time/date.js"],"names":["moment","classnames","DayPickerSingleDateController","useEffect","useRef","isRTL","_n","sprintf","getMomentDate","TIMEZONELESS_FORMAT","ARIAL_LABEL_TIME_FORMAT","DatePickerDay","day","events","ref","current","parentNode","dayAriaLabel","format","length","setAttribute","dayWithEventsDescription","DatePicker","currentDate","onChange","isInvalidDate","onMonthPreviewed","nodeRef","onMonthPreviewedHandler","newMonthDate","toISOString","keepFocusInside","ownerDocument","activeElement","contains","focusRegion","querySelector","focus","onChangeMoment","newDate","momentDate","momentTime","hours","minutes","seconds","set","getEventsPerDay","filter","eventDay","isSame","date","toDate"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,MAAP,MAAmB,QAAnB;AACA,OAAOC,UAAP,MAAuB,YAAvB,C,CAEA;AACA;;AACA,OAAOC,6BAAP,MAA0C,0DAA1C;AAEA;AACA;AACA;;AACA,SAASC,SAAT,EAAoBC,MAApB,QAAkC,oBAAlC;AACA,SAASC,KAAT,EAAgBC,EAAhB,EAAoBC,OAApB,QAAmC,iBAAnC;AAEA;AACA;AACA;;AACA,SAASC,aAAT,QAA8B,SAA9B;AAEA;AACA;AACA;;AACA,MAAMC,mBAAmB,GAAG,qBAA5B;AACA,MAAMC,uBAAuB,GAAG,UAAhC;;AAEA,SAASC,aAAT,OAA+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AvBF,IADD,CADD;AAiCA;;AAED,eAAeU,UAAf","sourcesContent":["/**\n * External dependencies\n */\nimport moment from 'moment';\nimport classnames from 'classnames';\n\n// react-dates doesn't tree-shake correctly, so we import from the individual\n// component here, to avoid including too much of the library\nimport DayPickerSingleDateController from 'react-dates/lib/components/DayPickerSingleDateController';\n\n/**\n * WordPress dependencies\n */\nimport { useEffect, useRef } from '@wordpress/element';\nimport { isRTL, _n, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { getMomentDate } from './utils';\n\n/**\n * Module Constants\n */\nconst TIMEZONELESS_FORMAT = 'YYYY-MM-DDTHH:mm:ss';\nconst ARIAL_LABEL_TIME_FORMAT = 'dddd, LL';\n\nfunction DatePickerDay( { day, events = [] } ) {\n\tconst ref = useRef();\n\n\t/*\n\t * a11y hack to make the `There is/are n events` string\n\t * available speaking for readers,\n\t * re-defining the aria-label attribute.\n\t * This attribute is handled by the react-dates component.\n\t */\n\tuseEffect( () => {\n\t\t// Bail when no parent node.\n\t\tif ( ! ref?.current?.parentNode ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { parentNode } = ref.current;\n\t\tconst dayAriaLabel = moment( day ).format( ARIAL_LABEL_TIME_FORMAT );\n\n\t\tif ( ! events.length ) {\n\t\t\t// Set aria-label without event description.\n\t\t\tparentNode.setAttribute( 'aria-label', dayAriaLabel );\n\t\t\treturn;\n\t\t}\n\n\t\tconst dayWithEventsDescription = sprintf(\n\t\t\t// translators: 1: Calendar day format, 2: Calendar event number.\n\t\t\t_n(\n\t\t\t\t'%1$s. There is %2$d event.',\n\t\t\t\t'%1$s. There are %2$d events.',\n\t\t\t\tevents.length\n\t\t\t),\n\t\t\tdayAriaLabel,\n\t\t\tevents.length\n\t\t);\n\n\t\tparentNode.setAttribute( 'aria-label', dayWithEventsDescription );\n\t}, [ events.length ] );\n\n\treturn (\n\t\t<div\n\t\t\tref={ ref }\n\t\t\tclassName={ classnames( 'components-datetime__date__day', {\n\t\t\t\t'has-events': events?.length,\n\t\t\t} ) }\n\t\t>\n\t\t\t{ day.format( 'D' ) }\n\t\t</div>\n\t);\n}\n\nfunction DatePicker( {\n\tcurrentDate,\n\tonChange,\n\tevents,\n\tisInvalidDate,\n\tonMonthPreviewed,\n} ) {\n\tconst nodeRef = useRef();\n\tconst onMonthPreviewedHandler = ( newMonthDate ) => {\n\t\tonMonthPreviewed?.( newMonthDate.toISOString() );\n\t\tkeepFocusInside();\n\t};\n\n\t/*\n\t * Todo: We should remove this function ASAP.\n\t * It is kept because focus is lost when we click on the previous and next month buttons.\n\t * This focus loss closes the date picker popover.\n\t * Ideally we should add an upstream commit on react-dates to fix this issue.\n\t */\n\tconst keepFocusInside = () => {\n\t\tif ( ! nodeRef.current ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { ownerDocument } = nodeRef.current;\n\t\tconst { activeElement } = ownerDocument;\n\n\t\t// If focus was lost.\n\t\tif (\n\t\t\t! activeElement ||\n\t\t\t! nodeRef.current.contains( ownerDocument.activeElement )\n\t\t) {\n\t\t\t// Retrieve the focus region div.\n\t\t\tconst focusRegion = nodeRef.current.querySelector(\n\t\t\t\t'.DayPicker_focusRegion'\n\t\t\t);\n\t\t\tif ( ! focusRegion ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Keep the focus on focus region.\n\t\t\tfocusRegion.focus();\n\t\t}\n\t};\n\n\tconst onChangeMoment = ( newDate ) => {\n\t\t// If currentDate is null, use now as momentTime to designate hours, minutes, seconds.\n\t\tconst momentDate = currentDate ? moment( currentDate ) : moment();\n\t\tconst momentTime = {\n\t\t\thours: momentDate.hours(),\n\t\t\tminutes: momentDate.minutes(),\n\t\t\tseconds: 0,\n\t\t};\n\n\t\tonChange( newDate.set( momentTime ).format( TIMEZONELESS_FORMAT ) );\n\n\t\t// Keep focus on the date picker.\n\t\tkeepFocusInside();\n\t};\n\n\tconst getEventsPerDay = ( day ) => {\n\t\tif ( ! events?.length ) {\n\t\t\treturn [];\n\t\t}\n\n\t\treturn events.filter( ( eventDay ) =>\n\t\t\tday.isSame( eventDay.date, 'day' )\n\t\t);\n\t};\n\n\tconst momentDate = getMomentDate( currentDate );\n\n\treturn (\n\t\t<div className=\"components-datetime__date\" ref={ nodeRef }>\n\t\t\t<DayPickerSingleDateController\n\t\t\t\tdate={ momentDate }\n\t\t\t\tdaySize={ 30 }\n\t\t\t\tfocused\n\t\t\t\thideKeyboardShortcutsPanel\n\t\t\t\t// This is a hack to force the calendar to update on month or year change\n\t\t\t\t// https://github.com/airbnb/react-dates/issues/240#issuecomment-361776665\n\t\t\t\tkey={ `datepicker-controller-${\n\t\t\t\t\tmomentDate ? momentDate.format( 'MM-YYYY' ) : 'null'\n\t\t\t\t}` }\n\t\t\t\tnoBorder\n\t\t\t\tnumberOfMonths={ 1 }\n\t\t\t\tonDateChange={ onChangeMoment }\n\t\t\t\ttransitionDuration={ 0 }\n\t\t\t\tweekDayFormat=\"ddd\"\n\t\t\t\tdayAriaLabelFormat={ ARIAL_LABEL_TIME_FORMAT }\n\t\t\t\tisRTL={ isRTL() }\n\t\t\t\tisOutsideRange={ ( date ) => {\n\t\t\t\t\treturn isInvalidDate && isInvalidDate( date.toDate() );\n\t\t\t\t} }\n\t\t\t\tonPrevMonthClick={ onMonthPreviewedHandler }\n\t\t\t\tonNextMonthClick={ onMonthPreviewedHandler }\n\t\t\t\trenderDayContents={ ( day ) => (\n\t\t\t\t\t<DatePickerDay\n\t\t\t\t\t\tday={ day }\n\t\t\t\t\t\tevents={ getEventsPerDay( day ) }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n\nexport default DatePicker;\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/components/src/date-time/date.tsx"],"names":["moment","classnames","noop","UntypedDayPickerSingleDateController","TypedDayPickerSingleDateController","useEffect","useRef","isRTL","_n","sprintf","getMomentDate","TIMEZONELESS_FORMAT","ARIAL_LABEL_TIME_FORMAT","DatePickerDay","day","events","ref","current","parentNode","Element","dayAriaLabel","format","length","setAttribute","dayWithEventsDescription","DatePicker","currentDate","onChange","isInvalidDate","onMonthPreviewed","nodeRef","onMonthPreviewedHandler","newMonthDate","toISOString","keepFocusInside","ownerDocument","activeElement","contains","focusRegion","querySelector","HTMLElement","focus","onChangeMoment","newDate","momentDate","momentTime","hours","minutes","seconds","set","getEventsPerDay","filter","eventDay","isSame","date","toDate"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,MAAP,MAAmB,QAAnB;AACA,OAAOC,UAAP,MAAuB,YAAvB;AAEA,SAASC,IAAT,QAAqB,QAArB,C,CAEA;AACA;AACA;AACA;AACA;;AACA,OAAOC,oCAAP,MAAiD,0DAAjD;AAEA,MAAMC,kCAAkC,GAAGD,oCAA3C;AAEA;AACA;AACA;;AACA,SAASE,SAAT,EAAoBC,MAApB,QAAkC,oBAAlC;AACA,SAASC,KAAT,EAAgBC,EAAhB,EAAoBC,OAApB,QAAmC,iBAAnC;AAEA;AACA;AACA;;AACA,SAASC,aAAT,QAA8B,SAA9B;AAGA,MAAMC,mBAAmB,GAAG,qBAA5B;AACA,MAAMC,uBAAuB,GAAG,UAAhC;;AAEA,SAASC,aAAT,OAAmE;AAAA,MAA3C;AAAEC,IAAAA,GAAF;AAAOC,IAAAA,MAAM,GAAG;AAAhB,GAA2C;AAClE,QAAMC,GAAG,GAAGV,MAAM,CAAoB,IAApB,CAAlB;AAEA;AACD;AACA;AACA;AACA;AACA;;AACCD,EAAAA,SAAS,CAAE,MAAM;AAAA;;AAChB;AACA,QAAK,EAAI,CAAAW,GAAG,SAAH,IAAAA,GAAG,WAAH,4BAAAA,GAAG,CAAEC,OAAL,8DAAcC,UAAd,aAAoCC,OAAxC,CAAL,EAAyD;AACxD;AACA;;AAED,UAAM;AAAED,MAAAA;AAAF,QAAiBF,GAAG,CAACC,OAA3B;AACA,UAAMG,YAAY,GAAGpB,MAAM,CAAEc,GAAF,CAAN,CAAcO,MAAd,CAAsBT,uBAAt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GAAG,CAACuC,MAAJ,CAAYD,QAAQ,CAACE,IAArB,EAA2B,KAA3B,CADM,CAAP;AAGA,GARD;;AAUA,QAAMV,UAAU,GAAGlC,aAAa,CAAEgB,WAAF,CAAhC;AAEA,SACC;AAAK,IAAA,SAAS,EAAC,2BAAf;AAA2C,IAAA,GAAG,EAAGI;AAAjD,KACC,cAAC,kCAAD;AACC,IAAA,IAAI,EAAGc,UADR;AAEC,IAAA,OAAO,EAAG,EAFX;AAGC,IAAA,OAAO,MAHR;AAIC,IAAA,0BAA0B,MAJ3B,CAKC;AACA;AAND;AAOC,IAAA,GAAG,EAAI,yBACNA,UAAU,GAAGA,UAAU,CAACvB,MAAX,CAAmB,SAAnB,CAAH,GAAoC,MAC9C,EATF;AAUC,IAAA,QAAQ,MAVT;AAWC,IAAA,cAAc,EAAG,CAXlB;AAYC,IAAA,YAAY,EAAGqB,cAZhB;AAaC,IAAA,kBAAkB,EAAG,CAbtB;AAcC,IAAA,aAAa,EAAC,KAdf;AAeC,IAAA,kBAAkB,EAAG9B,uBAftB;AAgBC,IAAA,KAAK,EAAGL,KAAK,EAhBd;AAiBC,IAAA,cAAc,EAAK+C,IAAF,IAAY;AAC5B,aAAO,CAAC,CAAE1B,aAAH,IAAoBA,aAAa,CAAE0B,IAAI,CAACC,MAAL,EAAF,CAAxC;AACA,KAnBF;AAoBC,IAAA,gBAAgB,EAAGxB,uBApBpB;AAqBC,IAAA,gBAAgB,EAAGA,uBArBpB;AAsBC,IAAA,iBAAiB,EAAKjB,GAAF,IACnB,cAAC,aAAD;AACC,MAAA,GAAG,EAAGA,GADP;AAEC,MAAA,MAAM,EAAGoC,eAAe,CAAEpC,GAAF;AAFzB,MAvBF;AA4BC,IAAA,aAAa,EAAGZ;AA5BjB,IADD,CADD;AAkCA;AAED,eAAeuB,UAAf","sourcesContent":["/**\n * External dependencies\n */\nimport moment from 'moment';\nimport classnames from 'classnames';\nimport type { Moment } from 'moment';\nimport { noop } from 'lodash';\n\n// `react-dates` doesn't tree-shake correctly, so we import from the individual\n// component here.\n// @ts-expect-error TypeScript won't find any type declarations at\n// `react-dates/lib/components/DayPickerSingleDateController` as they're located\n// at `react-dates`.\nimport UntypedDayPickerSingleDateController from 'react-dates/lib/components/DayPickerSingleDateController';\nimport type { DayPickerSingleDateController } from 'react-dates';\nconst TypedDayPickerSingleDateController = UntypedDayPickerSingleDateController as DayPickerSingleDateController;\n\n/**\n * WordPress dependencies\n */\nimport { useEffect, useRef } from '@wordpress/element';\nimport { isRTL, _n, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { getMomentDate } from './utils';\nimport type { DatePickerDayProps, DatePickerProps } from './types';\n\nconst TIMEZONELESS_FORMAT = 'YYYY-MM-DDTHH:mm:ss';\nconst ARIAL_LABEL_TIME_FORMAT = 'dddd, LL';\n\nfunction DatePickerDay( { day, events = [] }: DatePickerDayProps ) {\n\tconst ref = useRef< HTMLDivElement >( null );\n\n\t/*\n\t * a11y hack to make the `There is/are n events` string\n\t * available speaking for readers,\n\t * re-defining the aria-label attribute.\n\t * This attribute is handled by the react-dates component.\n\t */\n\tuseEffect( () => {\n\t\t// Bail when no parent node.\n\t\tif ( ! ( ref?.current?.parentNode instanceof Element ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { parentNode } = ref.current;\n\t\tconst dayAriaLabel = moment( day ).format( ARIAL_LABEL_TIME_FORMAT );\n\n\t\tif ( ! events.length ) {\n\t\t\t// Set aria-label without event description.\n\t\t\tparentNode.setAttribute( 'aria-label', dayAriaLabel );\n\t\t\treturn;\n\t\t}\n\n\t\tconst dayWithEventsDescription = sprintf(\n\t\t\t// translators: 1: Calendar day format, 2: Calendar event number.\n\t\t\t_n(\n\t\t\t\t'%1$s. There is %2$d event.',\n\t\t\t\t'%1$s. There are %2$d events.',\n\t\t\t\tevents.length\n\t\t\t),\n\t\t\tdayAriaLabel,\n\t\t\tevents.length\n\t\t);\n\n\t\tparentNode.setAttribute( 'aria-label', dayWithEventsDescription );\n\t}, [ events.length ] );\n\n\treturn (\n\t\t<div\n\t\t\tref={ ref }\n\t\t\tclassName={ classnames( 'components-datetime__date__day', {\n\t\t\t\t'has-events': events?.length,\n\t\t\t} ) }\n\t\t>\n\t\t\t{ day.format( 'D' ) }\n\t\t</div>\n\t);\n}\n\n/**\n * DatePicker is a React component that renders a calendar for date selection.\n *\n * ```jsx\n * import { DatePicker } from '@wordpress/components';\n * import { useState } from '@wordpress/element';\n *\n * const MyDatePicker = () => {\n * const [ date, setDate ] = useState( new Date() );\n *\n * return (\n * <DatePicker\n * currentDate={ date }\n * onChange={ ( newDate ) => setDate( newDate ) }\n * />\n * );\n * };\n * ```\n */\nexport function DatePicker( {\n\tcurrentDate,\n\tonChange,\n\tevents,\n\tisInvalidDate,\n\tonMonthPreviewed,\n}: DatePickerProps ) {\n\tconst nodeRef = useRef< HTMLDivElement >( null );\n\tconst onMonthPreviewedHandler = ( newMonthDate: Moment ) => {\n\t\tonMonthPreviewed?.( newMonthDate.toISOString() );\n\t\tkeepFocusInside();\n\t};\n\n\t/*\n\t * Todo: We should remove this function ASAP.\n\t * It is kept because focus is lost when we click on the previous and next month buttons.\n\t * This focus loss closes the date picker popover.\n\t * Ideally we should add an upstream commit on react-dates to fix this issue.\n\t */\n\tconst keepFocusInside = () => {\n\t\tif ( ! nodeRef.current ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { ownerDocument } = nodeRef.current;\n\t\tconst { activeElement } = ownerDocument;\n\n\t\t// If focus was lost.\n\t\tif (\n\t\t\t! activeElement ||\n\t\t\t! nodeRef.current.contains( ownerDocument.activeElement )\n\t\t) {\n\t\t\t// Retrieve the focus region div.\n\t\t\tconst focusRegion = nodeRef.current.querySelector(\n\t\t\t\t'.DayPicker_focusRegion'\n\t\t\t);\n\t\t\tif ( ! ( focusRegion instanceof HTMLElement ) ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Keep the focus on focus region.\n\t\t\tfocusRegion.focus();\n\t\t}\n\t};\n\n\tconst onChangeMoment = ( newDate: Moment | null ) => {\n\t\tif ( ! newDate ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// If currentDate is null, use now as momentTime to designate hours, minutes, seconds.\n\t\tconst momentDate = currentDate ? moment( currentDate ) : moment();\n\t\tconst momentTime = {\n\t\t\thours: momentDate.hours(),\n\t\t\tminutes: momentDate.minutes(),\n\t\t\tseconds: 0,\n\t\t};\n\n\t\tonChange?.( newDate.set( momentTime ).format( TIMEZONELESS_FORMAT ) );\n\n\t\t// Keep focus on the date picker.\n\t\tkeepFocusInside();\n\t};\n\n\tconst getEventsPerDay = ( day: Moment ) => {\n\t\tif ( ! events?.length ) {\n\t\t\treturn [];\n\t\t}\n\n\t\treturn events.filter( ( eventDay ) =>\n\t\t\tday.isSame( eventDay.date, 'day' )\n\t\t);\n\t};\n\n\tconst momentDate = getMomentDate( currentDate );\n\n\treturn (\n\t\t<div className=\"components-datetime__date\" ref={ nodeRef }>\n\t\t\t<TypedDayPickerSingleDateController\n\t\t\t\tdate={ momentDate }\n\t\t\t\tdaySize={ 30 }\n\t\t\t\tfocused\n\t\t\t\thideKeyboardShortcutsPanel\n\t\t\t\t// This is a hack to force the calendar to update on month or year change\n\t\t\t\t// https://github.com/airbnb/react-dates/issues/240#issuecomment-361776665\n\t\t\t\tkey={ `datepicker-controller-${\n\t\t\t\t\tmomentDate ? momentDate.format( 'MM-YYYY' ) : 'null'\n\t\t\t\t}` }\n\t\t\t\tnoBorder\n\t\t\t\tnumberOfMonths={ 1 }\n\t\t\t\tonDateChange={ onChangeMoment }\n\t\t\t\ttransitionDuration={ 0 }\n\t\t\t\tweekDayFormat=\"ddd\"\n\t\t\t\tdayAriaLabelFormat={ ARIAL_LABEL_TIME_FORMAT }\n\t\t\t\tisRTL={ isRTL() }\n\t\t\t\tisOutsideRange={ ( date ) => {\n\t\t\t\t\treturn !! isInvalidDate && isInvalidDate( date.toDate() );\n\t\t\t\t} }\n\t\t\t\tonPrevMonthClick={ onMonthPreviewedHandler }\n\t\t\t\tonNextMonthClick={ onMonthPreviewedHandler }\n\t\t\t\trenderDayContents={ ( day ) => (\n\t\t\t\t\t<DatePickerDay\n\t\t\t\t\t\tday={ day }\n\t\t\t\t\t\tevents={ getEventsPerDay( day ) }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\tonFocusChange={ noop }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n\nexport default DatePicker;\n"]}
|
|
@@ -7,10 +7,10 @@ import { createElement, Fragment } from "@wordpress/element";
|
|
|
7
7
|
// See: https://github.com/airbnb/react-dates#initialize
|
|
8
8
|
import 'react-dates/initialize';
|
|
9
9
|
import { noop } from 'lodash';
|
|
10
|
+
|
|
10
11
|
/**
|
|
11
12
|
* WordPress dependencies
|
|
12
13
|
*/
|
|
13
|
-
|
|
14
14
|
import { useState, forwardRef } from '@wordpress/element';
|
|
15
15
|
import { __, _x } from '@wordpress/i18n';
|
|
16
16
|
/**
|
|
@@ -22,7 +22,7 @@ import { default as DatePicker } from './date';
|
|
|
22
22
|
import { default as TimePicker } from './time';
|
|
23
23
|
export { DatePicker, TimePicker };
|
|
24
24
|
|
|
25
|
-
function
|
|
25
|
+
function UnforwardedDateTimePicker(_ref, ref) {
|
|
26
26
|
let {
|
|
27
27
|
currentDate,
|
|
28
28
|
is12Hour,
|
|
@@ -77,13 +77,37 @@ function DateTimePicker(_ref, ref) {
|
|
|
77
77
|
}, !calendarHelpIsVisible && currentDate && createElement(Button, {
|
|
78
78
|
className: "components-datetime__date-reset-button",
|
|
79
79
|
variant: "link",
|
|
80
|
-
onClick: () => onChange(null)
|
|
80
|
+
onClick: () => onChange === null || onChange === void 0 ? void 0 : onChange(null)
|
|
81
81
|
}, __('Reset')), createElement(Button, {
|
|
82
82
|
className: "components-datetime__date-help-toggle",
|
|
83
83
|
variant: "link",
|
|
84
84
|
onClick: onClickDescriptionToggle
|
|
85
85
|
}, calendarHelpIsVisible ? __('Close') : __('Calendar Help'))));
|
|
86
86
|
}
|
|
87
|
+
/**
|
|
88
|
+
* DateTimePicker is a React component that renders a calendar and clock for
|
|
89
|
+
* date and time selection. The calendar and clock components can be accessed
|
|
90
|
+
* individually using the `DatePicker` and `TimePicker` components respectively.
|
|
91
|
+
*
|
|
92
|
+
* ```jsx
|
|
93
|
+
* import { DateTimePicker } from '@wordpress/components';
|
|
94
|
+
* import { useState } from '@wordpress/element';
|
|
95
|
+
*
|
|
96
|
+
* const MyDateTimePicker = () => {
|
|
97
|
+
* const [ date, setDate ] = useState( new Date() );
|
|
98
|
+
*
|
|
99
|
+
* return (
|
|
100
|
+
* <DateTimePicker
|
|
101
|
+
* currentDate={ date }
|
|
102
|
+
* onChange={ ( newDate ) => setDate( newDate ) }
|
|
103
|
+
* is12Hour
|
|
104
|
+
* />
|
|
105
|
+
* );
|
|
106
|
+
* };
|
|
107
|
+
* ```
|
|
108
|
+
*/
|
|
109
|
+
|
|
87
110
|
|
|
88
|
-
export
|
|
111
|
+
export const DateTimePicker = forwardRef(UnforwardedDateTimePicker);
|
|
112
|
+
export default DateTimePicker;
|
|
89
113
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/components/src/date-time/index.
|
|
1
|
+
{"version":3,"sources":["@wordpress/components/src/date-time/index.tsx"],"names":["noop","useState","forwardRef","__","_x","Button","default","DatePicker","TimePicker","UnforwardedDateTimePicker","ref","currentDate","is12Hour","isInvalidDate","onMonthPreviewed","onChange","events","calendarHelpIsVisible","setCalendarHelpIsVisible","onClickDescriptionToggle","DateTimePicker"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA,OAAO,wBAAP;AACA,SAASA,IAAT,QAAqB,QAArB;;AAGA;AACA;AACA;AACA,SAASC,QAAT,EAAmBC,UAAnB,QAAqC,oBAArC;AACA,SAASC,EAAT,EAAaC,EAAb,QAAuB,iBAAvB;AAEA;AACA;AACA;;AACA,OAAOC,MAAP,MAAmB,WAAnB;AACA,SAASC,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*/\n// Needed to initialise the default datepicker styles.\n// See: https://github.com/airbnb/react-dates#initialize\nimport 'react-dates/initialize';\nimport { noop } from 'lodash';\nimport type { ForwardedRef } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { useState, forwardRef } from '@wordpress/element';\nimport { __, _x } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport Button from '../button';\nimport { default as DatePicker } from './date';\nimport { default as TimePicker } from './time';\nimport type { DateTimePickerProps } from './types';\n\nexport { DatePicker, TimePicker };\n\nfunction UnforwardedDateTimePicker(\n\t{\n\t\tcurrentDate,\n\t\tis12Hour,\n\t\tisInvalidDate,\n\t\tonMonthPreviewed = noop,\n\t\tonChange,\n\t\tevents,\n\t}: DateTimePickerProps,\n\tref: ForwardedRef< any >\n) {\n\tconst [ calendarHelpIsVisible, setCalendarHelpIsVisible ] = useState(\n\t\tfalse\n\t);\n\n\tfunction onClickDescriptionToggle() {\n\t\tsetCalendarHelpIsVisible( ! calendarHelpIsVisible );\n\t}\n\n\treturn (\n\t\t<div ref={ ref } className=\"components-datetime\">\n\t\t\t{ ! calendarHelpIsVisible && (\n\t\t\t\t<>\n\t\t\t\t\t<TimePicker\n\t\t\t\t\t\tcurrentTime={ currentDate }\n\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\tis12Hour={ is12Hour }\n\t\t\t\t\t/>\n\t\t\t\t\t<DatePicker\n\t\t\t\t\t\tcurrentDate={ currentDate }\n\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\tisInvalidDate={ isInvalidDate }\n\t\t\t\t\t\tevents={ events }\n\t\t\t\t\t\tonMonthPreviewed={ onMonthPreviewed }\n\t\t\t\t\t/>\n\t\t\t\t</>\n\t\t\t) }\n\t\t\t{ calendarHelpIsVisible && (\n\t\t\t\t<>\n\t\t\t\t\t<div className=\"components-datetime__calendar-help\">\n\t\t\t\t\t\t<h4>{ __( 'Click to Select' ) }</h4>\n\t\t\t\t\t\t<ul>\n\t\t\t\t\t\t\t<li>\n\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t'Click the right or left arrows to select other months in the past or the future.'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</li>\n\t\t\t\t\t\t\t<li>\n\t\t\t\t\t\t\t\t{ __( 'Click the desired day to select it.' ) }\n\t\t\t\t\t\t\t</li>\n\t\t\t\t\t\t</ul>\n\t\t\t\t\t\t<h4>{ __( 'Navigating with a keyboard' ) }</h4>\n\t\t\t\t\t\t<ul>\n\t\t\t\t\t\t\t<li>\n\t\t\t\t\t\t\t\t<abbr\n\t\t\t\t\t\t\t\t\taria-label={ _x(\n\t\t\t\t\t\t\t\t\t\t'Enter',\n\t\t\t\t\t\t\t\t\t\t'keyboard button'\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t↵\n\t\t\t\t\t\t\t\t</abbr>\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t' ' /* JSX removes whitespace, but a space is required for screen readers. */\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t<span>\n\t\t\t\t\t\t\t\t\t{ __( 'Select the date in focus.' ) }\n\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t</li>\n\t\t\t\t\t\t\t<li>\n\t\t\t\t\t\t\t\t<abbr\n\t\t\t\t\t\t\t\t\taria-label={ __( 'Left and Right Arrows' ) }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t←/→\n\t\t\t\t\t\t\t\t</abbr>\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t' ' /* JSX removes whitespace, but a space is required for screen readers. */\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t'Move backward (left) or forward (right) by one day.'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</li>\n\t\t\t\t\t\t\t<li>\n\t\t\t\t\t\t\t\t<abbr aria-label={ __( 'Up and Down Arrows' ) }>\n\t\t\t\t\t\t\t\t\t↑/↓\n\t\t\t\t\t\t\t\t</abbr>\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t' ' /* JSX removes whitespace, but a space is required for screen readers. */\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t'Move backward (up) or forward (down) by one week.'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</li>\n\t\t\t\t\t\t\t<li>\n\t\t\t\t\t\t\t\t<abbr\n\t\t\t\t\t\t\t\t\taria-label={ __( 'Page Up and Page Down' ) }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ __( 'PgUp/PgDn' ) }\n\t\t\t\t\t\t\t\t</abbr>\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t' ' /* JSX removes whitespace, but a space is required for screen readers. */\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t'Move backward (PgUp) or forward (PgDn) by one month.'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</li>\n\t\t\t\t\t\t\t<li>\n\t\t\t\t\t\t\t\t<abbr aria-label={ __( 'Home and End' ) }>\n\t\t\t\t\t\t\t\t\t{ /* Translators: Home/End reffer to the 'Home' and 'End' buttons on the keyboard.*/ }\n\t\t\t\t\t\t\t\t\t{ __( 'Home/End' ) }\n\t\t\t\t\t\t\t\t</abbr>\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t' ' /* JSX removes whitespace, but a space is required for screen readers. */\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t'Go to the first (Home) or last (End) day of a week.'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</li>\n\t\t\t\t\t\t</ul>\n\t\t\t\t\t</div>\n\t\t\t\t</>\n\t\t\t) }\n\t\t\t<div className=\"components-datetime__buttons\">\n\t\t\t\t{ ! calendarHelpIsVisible && currentDate && (\n\t\t\t\t\t<Button\n\t\t\t\t\t\tclassName=\"components-datetime__date-reset-button\"\n\t\t\t\t\t\tvariant=\"link\"\n\t\t\t\t\t\tonClick={ () => onChange?.( null ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Reset' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t) }\n\t\t\t\t<Button\n\t\t\t\t\tclassName=\"components-datetime__date-help-toggle\"\n\t\t\t\t\tvariant=\"link\"\n\t\t\t\t\tonClick={ onClickDescriptionToggle }\n\t\t\t\t>\n\t\t\t\t\t{ calendarHelpIsVisible\n\t\t\t\t\t\t? __( 'Close' )\n\t\t\t\t\t\t: __( 'Calendar Help' ) }\n\t\t\t\t</Button>\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n\n/**\n * DateTimePicker is a React component that renders a calendar and clock for\n * date and time selection. The calendar and clock components can be accessed\n * individually using the `DatePicker` and `TimePicker` components respectively.\n *\n * ```jsx\n * import { DateTimePicker } from '@wordpress/components';\n * import { useState } from '@wordpress/element';\n *\n * const MyDateTimePicker = () => {\n * const [ date, setDate ] = useState( new Date() );\n *\n * return (\n * <DateTimePicker\n * currentDate={ date }\n * onChange={ ( newDate ) => setDate( newDate ) }\n * is12Hour\n * />\n * );\n * };\n * ```\n */\nexport const DateTimePicker = forwardRef( UnforwardedDateTimePicker );\n\nexport default DateTimePicker;\n"]}
|