@wordpress/components 19.10.0 → 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 +24 -6
- 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/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/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 +1 -1
- 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/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/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 +3 -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/palette-edit/index.js +38 -7
- package/build/palette-edit/index.js.map +1 -1
- package/build/popover/index.js +223 -277
- 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.native.js +1 -1
- package/build/sandbox/index.native.js.map +1 -1
- package/build/select-control/styles/select-control-styles.js +14 -11
- package/build/select-control/styles/select-control-styles.js.map +1 -1
- 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/tooltip/index.js +2 -2
- package/build/tooltip/index.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/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/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 +1 -1
- 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/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/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 +3 -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/palette-edit/index.js +37 -7
- package/build-module/palette-edit/index.js.map +1 -1
- package/build-module/popover/index.js +225 -279
- 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.native.js +1 -1
- package/build-module/sandbox/index.native.js.map +1 -1
- package/build-module/select-control/styles/select-control-styles.js +14 -11
- package/build-module/select-control/styles/select-control-styles.js.map +1 -1
- 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/tooltip/index.js +2 -2
- package/build-module/tooltip/index.js.map +1 -1
- package/build-style/style-rtl.css +31 -170
- package/build-style/style.css +27 -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-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/color-palette/index.d.ts.map +1 -1
- package/build-types/color-picker/styles.d.ts +1 -1
- 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/dropdown/index.d.ts.map +1 -1
- package/build-types/input-control/index.d.ts +1 -1
- package/build-types/input-control/stories/index.d.ts +5 -5
- package/build-types/number-control/styles/number-control-styles.d.ts +1 -1
- package/build-types/popover/index.d.ts +5 -7
- 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/styles/select-control-styles.d.ts.map +1 -1
- package/build-types/toggle-group-control/toggle-group-control/component.d.ts.map +1 -1
- package/build-types/tooltip/index.d.ts.map +1 -1
- package/package.json +19 -19
- 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/button/index.native.js +33 -18
- 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/style.scss +1 -0
- package/src/color-palette/index.js +6 -13
- package/src/color-palette/style.scss +3 -18
- 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.js → date.tsx} +3 -2
- 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/disabled/index.js +1 -1
- 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 +8 -4
- package/src/index.js +0 -1
- package/src/index.native.js +1 -0
- package/src/item-group/stories/index.js +22 -18
- 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 +1 -1
- package/src/mobile/bottom-sheet/index.native.js +1 -1
- package/src/mobile/bottom-sheet-select-control/index.native.js +7 -2
- package/src/mobile/html-text-input/index.native.js +45 -29
- package/src/mobile/html-text-input/style.android.scss +1 -15
- package/src/mobile/html-text-input/style.ios.scss +1 -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/navigator/stories/index.js +16 -10
- 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 -371
- package/src/popover/style.scss +20 -190
- package/src/popover/test/__snapshots__/index.js.snap +6 -18
- package/src/resizable-box/resize-tooltip/utils.ts +4 -5
- package/src/sandbox/index.native.js +1 -1
- package/src/select-control/styles/select-control-styles.ts +6 -3
- package/src/tab-panel/style.scss +1 -1
- 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/tooltip/index.js +8 -2
- package/src/tooltip/style.scss +2 -4
- package/src/tooltip/test/index.native.js +1 -1
- package/src/unit-control/test/index.tsx +84 -4
- package/tsconfig.json +6 -2
- package/tsconfig.tsbuildinfo +1 -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/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/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 -91
- package/src/date-time/stories/time.js +0 -32
- 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/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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/components/src/border-control/styles.ts"],"names":["labelStyles","
|
|
1
|
+
{"version":3,"sources":["@wordpress/components/src/border-control/styles.ts"],"names":["labelStyles","focusBoxShadow","css","CONFIG","borderWidth","COLORS","ui","borderFocus","borderControl","innerWrapper","UnitControlWrapper","marginLeft","UnitSelect","borderRadius","marginRight","wrapperWidth","width","wrapperHeight","__next36pxDefaultSize","borderControlDropdown","border","colorIndicatorBorder","color","style","fallbackColor","gray","undefined","colorIndicatorWrapper","borderControlPopover","borderControlPopoverControls","StyledLabel","borderControlPopoverContent","borderColorIndicator","resetButton","borderWidthControl","BackdropUI","borderTopLeftRadius","borderBottomLeftRadius","paddingRight","borderControlStylePicker","borderStyleButton","borderSlider","StyledField"],"mappings":";;;;;;;AAGA;;AAMA;;AACA;;AACA;;AAIA;;AACA;;;;AAOA,MAAMA,WAAW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAjB;AAIA,MAAMC,cAAc,oBAAGC,UAAH,6BACQC,cAAOC,WADf,OACgCC,cAAOC,EAAP,CAAU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BADiC,OAEhC9B,WAFgC,mwQAA9B;;AAMA,MAAMwC,iBAAiB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAvB;;;AASA,MAAMC,YAAY,GAAG,uBAAMvC,UAAN,mBAExB,gBAAK;AAAEY,EAAAA,WAAW,EAAE,kBAAO,CAAP;AAAf,CAAL,GAFwB,OAIxB4B,8BAJwB,gyQAArB","sourcesContent":["/**\n * External dependencies\n */\nimport { css } from '@emotion/react';\nimport type { CSSProperties } from 'react';\n\n/**\n * Internal dependencies\n */\nimport { COLORS, CONFIG, rtl } from '../utils';\nimport { space } from '../ui/utils/space';\nimport {\n\tStyledField,\n\tStyledLabel,\n} from '../base-control/styles/base-control-styles';\nimport { BackdropUI } from '../input-control/styles/input-control-styles';\nimport {\n\tRoot as UnitControlWrapper,\n\tUnitSelect,\n} from '../unit-control/styles/unit-control-styles';\n\nimport type { Border } from './types';\n\nconst labelStyles = css`\n\tfont-weight: 500;\n`;\n\nconst focusBoxShadow = css`\n\tbox-shadow: inset 0 0 0 ${ CONFIG.borderWidth } ${ COLORS.ui.borderFocus };\n`;\n\nexport const borderControl = css`\n\tposition: relative;\n`;\n\nexport const innerWrapper = () => css`\n\tflex: 1 0 40%;\n\n\t/*\n\t * Needs more thought. Aim is to prevent the border for BorderBoxControl\n\t * showing through the control. Likely needs to take into account\n\t * light/dark themes etc.\n\t */\n\tbackground: #fff;\n\n\t/*\n\t * Forces the width control to fill available space given UnitControl\n\t * passes its className directly through to the input.\n\t */\n\t${ UnitControlWrapper } {\n\t\tflex: 1;\n\t\t${ rtl( { marginLeft: -1 } )() }\n\t}\n\n\t&& ${ UnitSelect } {\n\t\t/* Prevent default styles forcing heights larger than BorderControl */\n\t\tmin-height: 0;\n\t\t${ rtl(\n\t\t\t{\n\t\t\t\tborderRadius: '0 1px 1px 0',\n\t\t\t\tmarginRight: 0,\n\t\t\t},\n\t\t\t{\n\t\t\t\tborderRadius: '1px 0 0 1px',\n\t\t\t\tmarginLeft: 0,\n\t\t\t}\n\t\t)() }\n\t\ttransition: box-shadow 0.1s linear, border 0.1s linear;\n\n\t\t&:focus {\n\t\t\tz-index: 1;\n\t\t\t${ focusBoxShadow }\n\t\t\tborder: 1px solid ${ COLORS.ui.borderFocus };\n\t\t}\n\t}\n`;\n\nexport const wrapperWidth = ( width: CSSProperties[ 'width' ] ) => {\n\treturn css`\n\t\twidth: ${ width };\n\t\tflex: 0 0 auto;\n\t`;\n};\n\n/*\n * When default control height is 36px the following should be removed.\n * See: InputControl and __next36pxDefaultSize.\n */\nexport const wrapperHeight = ( __next36pxDefaultSize?: boolean ) => {\n\treturn css`\n\t\theight: ${ __next36pxDefaultSize ? '36px' : '30px' };\n\t`;\n};\n\nexport const borderControlDropdown = () => css`\n\tbackground: #fff;\n\n\t&& > button {\n\t\t/*\n\t\t * Override button component height and padding to fit within\n\t\t * BorderControl\n\t\t */\n\t\theight: 100%;\n\t\tpadding: ${ space( 0.75 ) };\n\t\t${ rtl(\n\t\t\t{ borderRadius: `2px 0 0 2px` },\n\t\t\t{ borderRadius: `0 2px 2px 0` }\n\t\t)() }\n\t\tborder: ${ CONFIG.borderWidth } solid ${ COLORS.ui.border };\n\t\tposition: relative;\n\n\t\t&:focus,\n\t\t&:hover:not( :disabled ) {\n\t\t\t${ focusBoxShadow }\n\t\t\tborder-color: ${ COLORS.ui.borderFocus };\n\t\t\tz-index: 1;\n\t\t\tposition: relative;\n\t\t}\n\t}\n`;\n\nexport const colorIndicatorBorder = ( border?: Border ) => {\n\tconst { color, style } = border || {};\n\n\tconst fallbackColor =\n\t\t!! style && style !== 'none' ? COLORS.gray[ 300 ] : undefined;\n\n\treturn css`\n\t\tborder-style: ${ style === 'none' ? 'solid' : style };\n\t\tborder-color: ${ color || fallbackColor };\n\t`;\n};\n\nexport const colorIndicatorWrapper = (\n\tborder?: Border,\n\t__next36pxDefaultSize?: boolean\n) => {\n\tconst { style } = border || {};\n\n\treturn css`\n\t\tborder-radius: 9999px;\n\t\tborder: 2px solid transparent;\n\t\t${ style ? colorIndicatorBorder( border ) : undefined }\n\t\twidth: ${ __next36pxDefaultSize ? '28px' : '22px' };\n\t\theight: ${ __next36pxDefaultSize ? '28px' : '22px' };\n\t\tpadding: ${ __next36pxDefaultSize ? '2px' : '1px' };\n\n\t\t/*\n\t\t * ColorIndicator\n\t\t *\n\t\t * The transparent colors used here ensure visibility of the indicator\n\t\t * over the active state of the border control dropdown's toggle button.\n\t\t */\n\t\t& > span {\n\t\t\t${ ! __next36pxDefaultSize\n\t\t\t\t? css`\n\t\t\t\t\t\t/* Dimensions fit in 30px overall control height. */\n\t\t\t\t\t\theight: 16px;\n\t\t\t\t\t\twidth: 16px;\n\t\t\t\t `\n\t\t\t\t: '' }\n\t\t\tbackground: linear-gradient(\n\t\t\t\t-45deg,\n\t\t\t\ttransparent 48%,\n\t\t\t\trgb( 0 0 0 / 20% ) 48%,\n\t\t\t\trgb( 0 0 0 / 20% ) 52%,\n\t\t\t\ttransparent 52%\n\t\t\t);\n\t\t}\n\t`;\n};\n\nexport const borderControlPopover = css`\n\t/* Remove padding from content, this will be re-added via inner elements*/\n\t&& .components-popover__content {\n\t\tpadding: 0;\n\t\twidth: 264px;\n\t}\n`;\n\nexport const borderControlPopoverControls = css`\n\tpadding: ${ space( 2 ) };\n\n\t> div:first-of-type > ${ StyledLabel } {\n\t\tmargin-bottom: 0;\n\t\t${ labelStyles }\n\t}\n\n\t&& ${ StyledLabel } + button:not( .has-text ) {\n\t\tmin-width: 24px;\n\t\tpadding: 0;\n\t}\n`;\n\nexport const borderControlPopoverContent = css``;\nexport const borderColorIndicator = css``;\n\nexport const resetButton = css`\n\tjustify-content: center;\n\twidth: 100%;\n\n\t/* Override button component styling */\n\t&& {\n\t\tborder-top: ${ CONFIG.borderWidth } solid ${ COLORS.gray[ 200 ] };\n\t\theight: 46px;\n\t}\n`;\n\nexport const borderWidthControl = () => css`\n\t/* Target the InputControl's backdrop */\n\t&&& ${ BackdropUI } {\n\t\t${ rtl( {\n\t\t\tborderTopLeftRadius: 0,\n\t\t\tborderBottomLeftRadius: 0,\n\t\t} )() }\n\t\ttransition: box-shadow 0.1s linear;\n\t}\n\n\t/* Specificity required to overcome UnitControl padding */\n\t/* See packages/components/src/unit-control/styles/unit-control-styles.ts */\n\t&&& input {\n\t\t${ rtl( { paddingRight: 0 } )() }\n\t}\n`;\n\nexport const borderControlStylePicker = css`\n\t${ StyledLabel } {\n\t\t${ labelStyles }\n\t}\n`;\n\nexport const borderStyleButton = css`\n\t&&&&& {\n\t\tmin-width: 30px;\n\t\twidth: 30px;\n\t\theight: 30px;\n\t\tpadding: 3px;\n\t}\n`;\n\nexport const borderSlider = () => css`\n\tflex: 1 1 60%;\n\t${ rtl( { marginRight: space( 3 ) } )() }\n\n\t${ StyledField } {\n\t\tmargin-bottom: 0;\n\t\tfont-size: 0;\n\t\tdisplay: flex;\n\t}\n`;\n"]}
|
|
@@ -14,6 +14,8 @@ var _reactNative = require("react-native");
|
|
|
14
14
|
|
|
15
15
|
var _lodash = require("lodash");
|
|
16
16
|
|
|
17
|
+
var _reactNativeGestureHandler = require("react-native-gesture-handler");
|
|
18
|
+
|
|
17
19
|
var _compose = require("@wordpress/compose");
|
|
18
20
|
|
|
19
21
|
var _tooltip = _interopRequireDefault(require("../tooltip"));
|
|
@@ -152,6 +154,15 @@ function Button(props) {
|
|
|
152
154
|
colorScheme: preferredColorScheme,
|
|
153
155
|
isPressed
|
|
154
156
|
}) : null;
|
|
157
|
+
const longPressHandler = (0, _element.useCallback)(_ref => {
|
|
158
|
+
let {
|
|
159
|
+
nativeEvent
|
|
160
|
+
} = _ref;
|
|
161
|
+
|
|
162
|
+
if (nativeEvent.state === _reactNativeGestureHandler.State.ACTIVE && onLongPress) {
|
|
163
|
+
onLongPress();
|
|
164
|
+
}
|
|
165
|
+
}, [onLongPress]);
|
|
155
166
|
const element = (0, _element.createElement)(_reactNative.TouchableOpacity, {
|
|
156
167
|
activeOpacity: 0.7,
|
|
157
168
|
accessible: true,
|
|
@@ -160,10 +171,13 @@ function Button(props) {
|
|
|
160
171
|
accessibilityRole: 'button',
|
|
161
172
|
accessibilityHint: hint,
|
|
162
173
|
onPress: onClick,
|
|
163
|
-
onLongPress: onLongPress,
|
|
164
174
|
style: containerStyle,
|
|
165
175
|
disabled: isDisabled,
|
|
166
176
|
testID: testID
|
|
177
|
+
}, (0, _element.createElement)(_reactNativeGestureHandler.LongPressGestureHandler, {
|
|
178
|
+
minDurationMs: 500,
|
|
179
|
+
maxDist: 150,
|
|
180
|
+
onHandlerStateChange: longPressHandler
|
|
167
181
|
}, (0, _element.createElement)(_reactNative.View, {
|
|
168
182
|
style: buttonViewStyle
|
|
169
183
|
}, (0, _element.createElement)(_reactNative.View, {
|
|
@@ -172,7 +186,7 @@ function Button(props) {
|
|
|
172
186
|
}
|
|
173
187
|
}, newIcon, newChildren, subscript && (0, _element.createElement)(_reactNative.Text, {
|
|
174
188
|
style: isPressed ? styles.subscriptActive : subscriptInactive
|
|
175
|
-
}, subscript))));
|
|
189
|
+
}, subscript)))));
|
|
176
190
|
|
|
177
191
|
if (!shouldShowTooltip) {
|
|
178
192
|
return element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/components/src/button/index.native.js"],"names":["isAndroid","Platform","OS","marginBottom","marginLeft","styles","StyleSheet","create","container","flex","padding","justifyContent","alignItems","buttonInactive","flexDirection","fixedRatio","aspectRatio","buttonActive","borderRadius","borderColor","backgroundColor","subscriptInactive","color","fontWeight","fontSize","alignSelf","subscriptInactiveDark","subscriptActive","Button","props","children","onClick","onLongPress","disabled","hint","isPressed","ariaDisabled","subscript","testID","icon","iconSize","showTooltip","label","shortcut","tooltipPosition","isActiveStyle","customContainerStyles","preferredColorScheme","isDisabled","containerStyle","buttonViewStyle","opacity","states","push","newChildren","Children","map","child","colorScheme","shouldShowTooltip","length","newIcon","element"],"mappings":";;;;;;;;;;AAeA;;AAZA;;AAOA;;AAMA;;AAQA;;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EAAG,IAFd;AAGC,IAAA,kBAAkB,EAAGpB,KAHtB;AAIC,IAAA,mBAAmB,EAAGU,MAJvB;AAKC,IAAA,iBAAiB,EAAG,QALrB;AAMC,IAAA,iBAAiB,EAAGlB,IANrB;AAOC,IAAA,OAAO,EAAGH,OAPX;AAQC,IAAA,WAAW,EAAGC,WARf;AASC,IAAA,KAAK,EAAGiB,cATT;AAUC,IAAA,QAAQ,EAAGD,UAVZ;AAWC,IAAA,MAAM,EAAGV;AAXV,KAaC,4BAAC,iBAAD;AAAM,IAAA,KAAK,EAAGY;AAAd,KACC,4BAAC,iBAAD;AAAM,IAAA,KAAK,EAAG;AAAEpC,MAAAA,aAAa,EAAE;AAAjB;AAAd,KACG+C,OADH,EAEGP,WAFH,EAGGjB,SAAS,IACV,4BAAC,iBAAD;AACC,IAAA,KAAK,EACJF,SAAS,GACN9B,MAAM,CAACsB,eADD,GAENN;AAJL,KAOGgB,SAPH,CAJF,CADD,CAbD,CADD;;AAkCA,MAAK,CAAEsB,iBAAP,EAA2B;AAC1B,WAAOG,OAAP;AACA;;AAED,SACC,4BAAC,gBAAD;AACC,IAAA,IAAI,EAAGpB,KADR;AAEC,IAAA,QAAQ,EAAGC,QAFZ;AAGC,IAAA,QAAQ,EAAGC,eAHZ;AAIC,IAAA,OAAO,EAAGH,WAAW,KAAK;AAJ3B,KAMGqB,OANH,CADD;AAUA;;eAEclC,M","sourcesContent":["/**\n * External dependencies\n */\nimport {\n\tStyleSheet,\n\tTouchableOpacity,\n\tText,\n\tView,\n\tPlatform,\n} from 'react-native';\nimport { isArray } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { Children, cloneElement } from '@wordpress/element';\nimport {\n\tusePreferredColorScheme,\n\tusePreferredColorSchemeStyle,\n} from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport Tooltip from '../tooltip';\nimport Icon from '../icon';\n\nconst isAndroid = Platform.OS === 'android';\nconst marginBottom = isAndroid ? -0.5 : 0;\nconst marginLeft = -3;\n\nconst styles = StyleSheet.create( {\n\tcontainer: {\n\t\tflex: 1,\n\t\tpadding: 3,\n\t\tjustifyContent: 'center',\n\t\talignItems: 'center',\n\t},\n\tbuttonInactive: {\n\t\tflex: 1,\n\t\tflexDirection: 'row',\n\t\tjustifyContent: 'center',\n\t\talignItems: 'center',\n\t},\n\tfixedRatio: {\n\t\taspectRatio: 1,\n\t},\n\tbuttonActive: {\n\t\tflex: 1,\n\t\tflexDirection: 'row',\n\t\tjustifyContent: 'center',\n\t\talignItems: 'center',\n\t\tborderRadius: 6,\n\t\tborderColor: '#2e4453',\n\t\tbackgroundColor: '#2e4453',\n\t},\n\tsubscriptInactive: {\n\t\tcolor: '#7b9ab1', // $toolbar-button.\n\t\tfontWeight: 'bold',\n\t\tfontSize: 13,\n\t\talignSelf: 'flex-end',\n\t\tmarginLeft,\n\t\tmarginBottom,\n\t},\n\tsubscriptInactiveDark: {\n\t\tcolor: '#a7aaad', // $gray_20.\n\t},\n\tsubscriptActive: {\n\t\tcolor: 'white',\n\t\tfontWeight: 'bold',\n\t\tfontSize: 13,\n\t\talignSelf: 'flex-end',\n\t\tmarginLeft,\n\t\tmarginBottom,\n\t},\n} );\n\nexport function Button( props ) {\n\tconst {\n\t\tchildren,\n\t\tonClick,\n\t\tonLongPress,\n\t\tdisabled,\n\t\thint,\n\t\tfixedRatio = true,\n\t\tisPressed,\n\t\t'aria-disabled': ariaDisabled,\n\t\t'data-subscript': subscript,\n\t\ttestID,\n\t\ticon,\n\t\ticonSize,\n\t\tshowTooltip,\n\t\tlabel,\n\t\tshortcut,\n\t\ttooltipPosition,\n\t\tisActiveStyle,\n\t\tcustomContainerStyles,\n\t} = props;\n\tconst preferredColorScheme = usePreferredColorScheme();\n\n\tconst isDisabled = ariaDisabled || disabled;\n\n\tconst containerStyle = [\n\t\tstyles.container,\n\t\tcustomContainerStyles && { ...customContainerStyles },\n\t];\n\n\tconst buttonViewStyle = {\n\t\topacity: isDisabled ? 0.3 : 1,\n\t\t...( fixedRatio && styles.fixedRatio ),\n\t\t...( isPressed ? styles.buttonActive : styles.buttonInactive ),\n\t\t...( isPressed &&\n\t\t\tisActiveStyle?.borderRadius && {\n\t\t\t\tborderRadius: isActiveStyle.borderRadius,\n\t\t\t} ),\n\t\t...( isActiveStyle?.backgroundColor && {\n\t\t\tbackgroundColor: isActiveStyle.backgroundColor,\n\t\t} ),\n\t};\n\n\tconst states = [];\n\tif ( isPressed ) {\n\t\tstates.push( 'selected' );\n\t}\n\n\tif ( isDisabled ) {\n\t\tstates.push( 'disabled' );\n\t}\n\n\tconst subscriptInactive = usePreferredColorSchemeStyle(\n\t\tstyles.subscriptInactive,\n\t\tstyles.subscriptInactiveDark\n\t);\n\n\tconst newChildren = Children.map( children, ( child ) => {\n\t\treturn child\n\t\t\t? cloneElement( child, {\n\t\t\t\t\tcolorScheme: preferredColorScheme,\n\t\t\t\t\tisPressed,\n\t\t\t } )\n\t\t\t: child;\n\t} );\n\n\t// Should show the tooltip if...\n\tconst shouldShowTooltip =\n\t\t! isDisabled &&\n\t\t// An explicit tooltip is passed or...\n\t\t( ( showTooltip && label ) ||\n\t\t\t// There's a shortcut or...\n\t\t\tshortcut ||\n\t\t\t// There's a label and...\n\t\t\t( !! label &&\n\t\t\t\t// The children are empty and...\n\t\t\t\t( ! children ||\n\t\t\t\t\t( isArray( children ) && ! children.length ) ) &&\n\t\t\t\t// The tooltip is not explicitly disabled.\n\t\t\t\tfalse !== showTooltip ) );\n\n\tconst newIcon = icon\n\t\t? cloneElement( <Icon icon={ icon } size={ iconSize } />, {\n\t\t\t\tcolorScheme: preferredColorScheme,\n\t\t\t\tisPressed,\n\t\t } )\n\t\t: null;\n\n\tconst element = (\n\t\t<TouchableOpacity\n\t\t\tactiveOpacity={ 0.7 }\n\t\t\taccessible={ true }\n\t\t\taccessibilityLabel={ label }\n\t\t\taccessibilityStates={ states }\n\t\t\taccessibilityRole={ 'button' }\n\t\t\taccessibilityHint={ hint }\n\t\t\tonPress={ onClick }\n\t\t\tonLongPress={ onLongPress }\n\t\t\tstyle={ containerStyle }\n\t\t\tdisabled={ isDisabled }\n\t\t\ttestID={ testID }\n\t\t>\n\t\t\t<View style={ buttonViewStyle }>\n\t\t\t\t<View style={ { flexDirection: 'row' } }>\n\t\t\t\t\t{ newIcon }\n\t\t\t\t\t{ newChildren }\n\t\t\t\t\t{ subscript && (\n\t\t\t\t\t\t<Text\n\t\t\t\t\t\t\tstyle={\n\t\t\t\t\t\t\t\tisPressed\n\t\t\t\t\t\t\t\t\t? styles.subscriptActive\n\t\t\t\t\t\t\t\t\t: subscriptInactive\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ subscript }\n\t\t\t\t\t\t</Text>\n\t\t\t\t\t) }\n\t\t\t\t</View>\n\t\t\t</View>\n\t\t</TouchableOpacity>\n\t);\n\n\tif ( ! shouldShowTooltip ) {\n\t\treturn element;\n\t}\n\n\treturn (\n\t\t<Tooltip\n\t\t\ttext={ label }\n\t\t\tshortcut={ shortcut }\n\t\t\tposition={ tooltipPosition }\n\t\t\tvisible={ showTooltip === true }\n\t\t>\n\t\t\t{ element }\n\t\t</Tooltip>\n\t);\n}\n\nexport default Button;\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/components/src/button/index.native.js"],"names":["isAndroid","Platform","OS","marginBottom","marginLeft","styles","StyleSheet","create","container","flex","padding","justifyContent","alignItems","buttonInactive","flexDirection","fixedRatio","aspectRatio","buttonActive","borderRadius","borderColor","backgroundColor","subscriptInactive","color","fontWeight","fontSize","alignSelf","subscriptInactiveDark","subscriptActive","Button","props","children","onClick","onLongPress","disabled","hint","isPressed","ariaDisabled","subscript","testID","icon","iconSize","showTooltip","label","shortcut","tooltipPosition","isActiveStyle","customContainerStyles","preferredColorScheme","isDisabled","containerStyle","buttonViewStyle","opacity","states","push","newChildren","Children","map","child","colorScheme","shouldShowTooltip","length","newIcon","longPressHandler","nativeEvent","state","State","ACTIVE","element"],"mappings":";;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A;;eAEcvC,M","sourcesContent":["/**\n * External dependencies\n */\nimport {\n\tStyleSheet,\n\tTouchableOpacity,\n\tText,\n\tView,\n\tPlatform,\n} from 'react-native';\nimport { isArray } from 'lodash';\nimport { LongPressGestureHandler, State } from 'react-native-gesture-handler';\n\n/**\n * WordPress dependencies\n */\nimport { Children, cloneElement, useCallback } from '@wordpress/element';\nimport {\n\tusePreferredColorScheme,\n\tusePreferredColorSchemeStyle,\n} from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport Tooltip from '../tooltip';\nimport Icon from '../icon';\n\nconst isAndroid = Platform.OS === 'android';\nconst marginBottom = isAndroid ? -0.5 : 0;\nconst marginLeft = -3;\n\nconst styles = StyleSheet.create( {\n\tcontainer: {\n\t\tflex: 1,\n\t\tpadding: 3,\n\t\tjustifyContent: 'center',\n\t\talignItems: 'center',\n\t},\n\tbuttonInactive: {\n\t\tflex: 1,\n\t\tflexDirection: 'row',\n\t\tjustifyContent: 'center',\n\t\talignItems: 'center',\n\t},\n\tfixedRatio: {\n\t\taspectRatio: 1,\n\t},\n\tbuttonActive: {\n\t\tflex: 1,\n\t\tflexDirection: 'row',\n\t\tjustifyContent: 'center',\n\t\talignItems: 'center',\n\t\tborderRadius: 6,\n\t\tborderColor: '#2e4453',\n\t\tbackgroundColor: '#2e4453',\n\t},\n\tsubscriptInactive: {\n\t\tcolor: '#7b9ab1', // $toolbar-button.\n\t\tfontWeight: 'bold',\n\t\tfontSize: 13,\n\t\talignSelf: 'flex-end',\n\t\tmarginLeft,\n\t\tmarginBottom,\n\t},\n\tsubscriptInactiveDark: {\n\t\tcolor: '#a7aaad', // $gray_20.\n\t},\n\tsubscriptActive: {\n\t\tcolor: 'white',\n\t\tfontWeight: 'bold',\n\t\tfontSize: 13,\n\t\talignSelf: 'flex-end',\n\t\tmarginLeft,\n\t\tmarginBottom,\n\t},\n} );\n\nexport function Button( props ) {\n\tconst {\n\t\tchildren,\n\t\tonClick,\n\t\tonLongPress,\n\t\tdisabled,\n\t\thint,\n\t\tfixedRatio = true,\n\t\tisPressed,\n\t\t'aria-disabled': ariaDisabled,\n\t\t'data-subscript': subscript,\n\t\ttestID,\n\t\ticon,\n\t\ticonSize,\n\t\tshowTooltip,\n\t\tlabel,\n\t\tshortcut,\n\t\ttooltipPosition,\n\t\tisActiveStyle,\n\t\tcustomContainerStyles,\n\t} = props;\n\tconst preferredColorScheme = usePreferredColorScheme();\n\n\tconst isDisabled = ariaDisabled || disabled;\n\n\tconst containerStyle = [\n\t\tstyles.container,\n\t\tcustomContainerStyles && { ...customContainerStyles },\n\t];\n\n\tconst buttonViewStyle = {\n\t\topacity: isDisabled ? 0.3 : 1,\n\t\t...( fixedRatio && styles.fixedRatio ),\n\t\t...( isPressed ? styles.buttonActive : styles.buttonInactive ),\n\t\t...( isPressed &&\n\t\t\tisActiveStyle?.borderRadius && {\n\t\t\t\tborderRadius: isActiveStyle.borderRadius,\n\t\t\t} ),\n\t\t...( isActiveStyle?.backgroundColor && {\n\t\t\tbackgroundColor: isActiveStyle.backgroundColor,\n\t\t} ),\n\t};\n\n\tconst states = [];\n\tif ( isPressed ) {\n\t\tstates.push( 'selected' );\n\t}\n\n\tif ( isDisabled ) {\n\t\tstates.push( 'disabled' );\n\t}\n\n\tconst subscriptInactive = usePreferredColorSchemeStyle(\n\t\tstyles.subscriptInactive,\n\t\tstyles.subscriptInactiveDark\n\t);\n\n\tconst newChildren = Children.map( children, ( child ) => {\n\t\treturn child\n\t\t\t? cloneElement( child, {\n\t\t\t\t\tcolorScheme: preferredColorScheme,\n\t\t\t\t\tisPressed,\n\t\t\t } )\n\t\t\t: child;\n\t} );\n\n\t// Should show the tooltip if...\n\tconst shouldShowTooltip =\n\t\t! isDisabled &&\n\t\t// An explicit tooltip is passed or...\n\t\t( ( showTooltip && label ) ||\n\t\t\t// There's a shortcut or...\n\t\t\tshortcut ||\n\t\t\t// There's a label and...\n\t\t\t( !! label &&\n\t\t\t\t// The children are empty and...\n\t\t\t\t( ! children ||\n\t\t\t\t\t( isArray( children ) && ! children.length ) ) &&\n\t\t\t\t// The tooltip is not explicitly disabled.\n\t\t\t\tfalse !== showTooltip ) );\n\n\tconst newIcon = icon\n\t\t? cloneElement( <Icon icon={ icon } size={ iconSize } />, {\n\t\t\t\tcolorScheme: preferredColorScheme,\n\t\t\t\tisPressed,\n\t\t } )\n\t\t: null;\n\n\tconst longPressHandler = useCallback(\n\t\t( { nativeEvent } ) => {\n\t\t\tif ( nativeEvent.state === State.ACTIVE && onLongPress ) {\n\t\t\t\tonLongPress();\n\t\t\t}\n\t\t},\n\t\t[ onLongPress ]\n\t);\n\n\tconst element = (\n\t\t<TouchableOpacity\n\t\t\tactiveOpacity={ 0.7 }\n\t\t\taccessible={ true }\n\t\t\taccessibilityLabel={ label }\n\t\t\taccessibilityStates={ states }\n\t\t\taccessibilityRole={ 'button' }\n\t\t\taccessibilityHint={ hint }\n\t\t\tonPress={ onClick }\n\t\t\tstyle={ containerStyle }\n\t\t\tdisabled={ isDisabled }\n\t\t\ttestID={ testID }\n\t\t>\n\t\t\t<LongPressGestureHandler\n\t\t\t\tminDurationMs={ 500 }\n\t\t\t\tmaxDist={ 150 }\n\t\t\t\tonHandlerStateChange={ longPressHandler }\n\t\t\t>\n\t\t\t\t<View style={ buttonViewStyle }>\n\t\t\t\t\t<View style={ { flexDirection: 'row' } }>\n\t\t\t\t\t\t{ newIcon }\n\t\t\t\t\t\t{ newChildren }\n\t\t\t\t\t\t{ subscript && (\n\t\t\t\t\t\t\t<Text\n\t\t\t\t\t\t\t\tstyle={\n\t\t\t\t\t\t\t\t\tisPressed\n\t\t\t\t\t\t\t\t\t\t? styles.subscriptActive\n\t\t\t\t\t\t\t\t\t\t: subscriptInactive\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ subscript }\n\t\t\t\t\t\t\t</Text>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</View>\n\t\t\t\t</View>\n\t\t\t</LongPressGestureHandler>\n\t\t</TouchableOpacity>\n\t);\n\n\tif ( ! shouldShowTooltip ) {\n\t\treturn element;\n\t}\n\n\treturn (\n\t\t<Tooltip\n\t\t\ttext={ label }\n\t\t\tshortcut={ shortcut }\n\t\t\tposition={ tooltipPosition }\n\t\t\tvisible={ showTooltip === true }\n\t\t>\n\t\t\t{ element }\n\t\t</Tooltip>\n\t);\n}\n\nexport default Button;\n"]}
|
|
@@ -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.default = void 0;
|
|
8
|
+
exports.default = exports.ButtonGroup = void 0;
|
|
9
9
|
|
|
10
10
|
var _element = require("@wordpress/element");
|
|
11
11
|
|
|
@@ -20,20 +20,37 @@ var _classnames = _interopRequireDefault(require("classnames"));
|
|
|
20
20
|
/**
|
|
21
21
|
* WordPress dependencies
|
|
22
22
|
*/
|
|
23
|
-
function
|
|
24
|
-
|
|
23
|
+
function UnforwardedButtonGroup(props, ref) {
|
|
24
|
+
const {
|
|
25
25
|
className,
|
|
26
|
-
...
|
|
27
|
-
} =
|
|
26
|
+
...restProps
|
|
27
|
+
} = props;
|
|
28
28
|
const classes = (0, _classnames.default)('components-button-group', className);
|
|
29
29
|
return (0, _element.createElement)("div", (0, _extends2.default)({
|
|
30
30
|
ref: ref,
|
|
31
31
|
role: "group",
|
|
32
32
|
className: classes
|
|
33
|
-
},
|
|
33
|
+
}, restProps));
|
|
34
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* ButtonGroup can be used to group any related buttons together. To emphasize
|
|
37
|
+
* related buttons, a group should share a common container.
|
|
38
|
+
*
|
|
39
|
+
* ```jsx
|
|
40
|
+
* import { Button, ButtonGroup } from '@wordpress/components';
|
|
41
|
+
*
|
|
42
|
+
* const MyButtonGroup = () => (
|
|
43
|
+
* <ButtonGroup>
|
|
44
|
+
* <Button variant="primary">Button 1</Button>
|
|
45
|
+
* <Button variant="primary">Button 2</Button>
|
|
46
|
+
* </ButtonGroup>
|
|
47
|
+
* );
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
35
50
|
|
|
36
|
-
var _default = (0, _element.forwardRef)(ButtonGroup);
|
|
37
51
|
|
|
52
|
+
const ButtonGroup = (0, _element.forwardRef)(UnforwardedButtonGroup);
|
|
53
|
+
exports.ButtonGroup = ButtonGroup;
|
|
54
|
+
var _default = ButtonGroup;
|
|
38
55
|
exports.default = _default;
|
|
39
56
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/components/src/button-group/index.
|
|
1
|
+
{"version":3,"sources":["@wordpress/components/src/button-group/index.tsx"],"names":["UnforwardedButtonGroup","props","ref","className","restProps","classes","ButtonGroup"],"mappings":";;;;;;;;;AASA;;;;AANA;;AAHA;AACA;AACA;;AAIA;AACA;AACA;AASA,SAASA,sBAAT,CACCC,KADD,EAECC,GAFD,EAGE;AACD,QAAM;AAAEC,IAAAA,SAAF;AAAa,OAAGC;AAAhB,MAA8BH,KAApC;AACA,QAAMI,OAAO,GAAG,yBAAY,yBAAZ,EAAuCF,SAAvC,CAAhB;AAEA,SACC;AAAK,IAAA,GAAG,EAAGD,GAAX;AAAiB,IAAA,IAAI,EAAC,OAAtB;AAA8B,IAAA,SAAS,EAAGG;AAA1C,KAAyDD,SAAzD,EADD;AAGA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,MAAME,WAAW,GAAG,yBAAYN,sBAAZ,CAApB;;eAEQM,W","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\nimport type { ForwardedRef } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { forwardRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport type { ButtonGroupProps } from './types';\nimport type { WordPressComponentProps } from '../ui/context';\n\nfunction UnforwardedButtonGroup(\n\tprops: WordPressComponentProps< ButtonGroupProps, 'div', false >,\n\tref: ForwardedRef< HTMLDivElement >\n) {\n\tconst { className, ...restProps } = props;\n\tconst classes = classnames( 'components-button-group', className );\n\n\treturn (\n\t\t<div ref={ ref } role=\"group\" className={ classes } { ...restProps } />\n\t);\n}\n\n/**\n * ButtonGroup can be used to group any related buttons together. To emphasize\n * related buttons, a group should share a common container.\n *\n * ```jsx\n * import { Button, ButtonGroup } from '@wordpress/components';\n *\n * const MyButtonGroup = () => (\n * <ButtonGroup>\n * <Button variant=\"primary\">Button 1</Button>\n * <Button variant=\"primary\">Button 2</Button>\n * </ButtonGroup>\n * );\n * ```\n */\nexport const ButtonGroup = forwardRef( UnforwardedButtonGroup );\n\nexport default ButtonGroup;\n"]}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
|
|
@@ -5,7 +5,8 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.
|
|
8
|
+
exports.CheckboxControl = CheckboxControl;
|
|
9
|
+
exports.default = void 0;
|
|
9
10
|
|
|
10
11
|
var _element = require("@wordpress/element");
|
|
11
12
|
|
|
@@ -32,8 +33,31 @@ var _baseControl = _interopRequireDefault(require("../base-control"));
|
|
|
32
33
|
/**
|
|
33
34
|
* Internal dependencies
|
|
34
35
|
*/
|
|
35
|
-
|
|
36
|
-
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Checkboxes allow the user to select one or more items from a set.
|
|
39
|
+
*
|
|
40
|
+
* ```jsx
|
|
41
|
+
* import { CheckboxControl } from '@wordpress/components';
|
|
42
|
+
* import { useState } from '@wordpress/element';
|
|
43
|
+
*
|
|
44
|
+
* const MyCheckboxControl = () => {
|
|
45
|
+
* const [ isChecked, setChecked ] = useState( true );
|
|
46
|
+
* return (
|
|
47
|
+
* <CheckboxControl
|
|
48
|
+
* label="Is author"
|
|
49
|
+
* help="Is the user a author or not?"
|
|
50
|
+
* checked={ isChecked }
|
|
51
|
+
* onChange={ setChecked }
|
|
52
|
+
* />
|
|
53
|
+
* );
|
|
54
|
+
* };
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
function CheckboxControl( // ref is omitted until we have `WordPressComponentPropsWithoutRef` or add
|
|
58
|
+
// ref forwarding to CheckboxControl.
|
|
59
|
+
props) {
|
|
60
|
+
const {
|
|
37
61
|
label,
|
|
38
62
|
className,
|
|
39
63
|
heading,
|
|
@@ -41,8 +65,8 @@ function CheckboxControl(_ref) {
|
|
|
41
65
|
indeterminate,
|
|
42
66
|
help,
|
|
43
67
|
onChange,
|
|
44
|
-
...
|
|
45
|
-
} =
|
|
68
|
+
...additionalProps
|
|
69
|
+
} = props;
|
|
46
70
|
|
|
47
71
|
if (heading) {
|
|
48
72
|
(0, _deprecated.default)('`heading` prop in `CheckboxControl`', {
|
|
@@ -52,7 +76,7 @@ function CheckboxControl(_ref) {
|
|
|
52
76
|
}
|
|
53
77
|
|
|
54
78
|
const [showCheckedIcon, setShowCheckedIcon] = (0, _element.useState)(false);
|
|
55
|
-
const [showIndeterminateIcon, setShowIndeterminateIcon] = (0, _element.useState)(false); // Run the following callback
|
|
79
|
+
const [showIndeterminateIcon, setShowIndeterminateIcon] = (0, _element.useState)(false); // Run the following callback every time the `ref` (and the additional
|
|
56
80
|
// dependencies) change.
|
|
57
81
|
|
|
58
82
|
const ref = (0, _compose.useRefEffect)(node => {
|
|
@@ -86,7 +110,7 @@ function CheckboxControl(_ref) {
|
|
|
86
110
|
onChange: onChangeValue,
|
|
87
111
|
checked: checked,
|
|
88
112
|
"aria-describedby": !!help ? id + '__help' : undefined
|
|
89
|
-
},
|
|
113
|
+
}, additionalProps)), showIndeterminateIcon ? (0, _element.createElement)(_icons.Icon, {
|
|
90
114
|
icon: _icons.reset,
|
|
91
115
|
className: "components-checkbox-control__indeterminate",
|
|
92
116
|
role: "presentation"
|
|
@@ -99,4 +123,7 @@ function CheckboxControl(_ref) {
|
|
|
99
123
|
htmlFor: id
|
|
100
124
|
}, label));
|
|
101
125
|
}
|
|
126
|
+
|
|
127
|
+
var _default = CheckboxControl;
|
|
128
|
+
exports.default = _default;
|
|
102
129
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/components/src/checkbox-control/index.
|
|
1
|
+
{"version":3,"sources":["@wordpress/components/src/checkbox-control/index.tsx"],"names":["CheckboxControl","props","label","className","heading","checked","indeterminate","help","onChange","additionalProps","alternative","since","showCheckedIcon","setShowCheckedIcon","showIndeterminateIcon","setShowIndeterminateIcon","ref","node","matches","instanceId","id","onChangeValue","event","target","undefined","reset","check"],"mappings":";;;;;;;;;;AASA;;;;AANA;;AAOA;;AACA;;AACA;;AAKA;;AAjBA;AACA;AACA;;AAIA;AACA;AACA;;AAMA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,eAAT,EACN;AACA;AACAC,KAHM,EAOL;AACD,QAAM;AACLC,IAAAA,KADK;AAELC,IAAAA,SAFK;AAGLC,IAAAA,OAHK;AAILC,IAAAA,OAJK;AAKLC,IAAAA,aALK;AAMLC,IAAAA,IANK;AAOLC,IAAAA,QAPK;AAQL,OAAGC;AARE,MASFR,KATJ;;AAWA,MAAKG,OAAL,EAAe;AACd,6BAAY,qCAAZ,EAAmD;AAClDM,MAAAA,WAAW,EAAE,2CADqC;AAElDC,MAAAA,KAAK,EAAE;AAF2C,KAAnD;AAIA;;AAED,QAAM,CAAEC,eAAF,EAAmBC,kBAAnB,IAA0C,uBAAU,KAAV,CAAhD;AACA,QAAM,CAAEC,qBAAF,EAAyBC,wBAAzB,IAAsD,uBAC3D,KAD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B,GAMnB,IAlBL,EAmBGb,eAAe,GAChB,4BAAC,WAAD;AACC,IAAA,IAAI,EAAGc,YADR;AAEC,IAAA,SAAS,EAAC,sCAFX;AAGC,IAAA,IAAI,EAAC;AAHN,IADgB,GAMb,IAzBL,CAND,EAiCC;AACC,IAAA,SAAS,EAAC,oCADX;AAEC,IAAA,OAAO,EAAGN;AAFX,KAIGlB,KAJH,CAjCD,CADD;AA0CA;;eAEcF,e","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\nimport type { ChangeEvent } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { useState } from '@wordpress/element';\nimport { useInstanceId, useRefEffect } from '@wordpress/compose';\nimport deprecated from '@wordpress/deprecated';\nimport { Icon, check, reset } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport BaseControl from '../base-control';\nimport type { CheckboxControlProps } from './types';\nimport type { WordPressComponentProps } from '../ui/context';\n\n/**\n * Checkboxes allow the user to select one or more items from a set.\n *\n * ```jsx\n * import { CheckboxControl } from '@wordpress/components';\n * import { useState } from '@wordpress/element';\n *\n * const MyCheckboxControl = () => {\n * const [ isChecked, setChecked ] = useState( true );\n * return (\n * <CheckboxControl\n * label=\"Is author\"\n * help=\"Is the user a author or not?\"\n * checked={ isChecked }\n * onChange={ setChecked }\n * />\n * );\n * };\n * ```\n */\nexport function CheckboxControl(\n\t// ref is omitted until we have `WordPressComponentPropsWithoutRef` or add\n\t// ref forwarding to CheckboxControl.\n\tprops: Omit<\n\t\tWordPressComponentProps< CheckboxControlProps, 'input', false >,\n\t\t'ref'\n\t>\n) {\n\tconst {\n\t\tlabel,\n\t\tclassName,\n\t\theading,\n\t\tchecked,\n\t\tindeterminate,\n\t\thelp,\n\t\tonChange,\n\t\t...additionalProps\n\t} = props;\n\n\tif ( heading ) {\n\t\tdeprecated( '`heading` prop in `CheckboxControl`', {\n\t\t\talternative: 'a separate element to implement a heading',\n\t\t\tsince: '5.8',\n\t\t} );\n\t}\n\n\tconst [ showCheckedIcon, setShowCheckedIcon ] = useState( false );\n\tconst [ showIndeterminateIcon, setShowIndeterminateIcon ] = useState(\n\t\tfalse\n\t);\n\n\t// Run the following callback every time the `ref` (and the additional\n\t// dependencies) change.\n\tconst ref = useRefEffect< HTMLInputElement >(\n\t\t( node ) => {\n\t\t\tif ( ! node ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// It cannot be set using an HTML attribute.\n\t\t\tnode.indeterminate = !! indeterminate;\n\n\t\t\tsetShowCheckedIcon( node.matches( ':checked' ) );\n\t\t\tsetShowIndeterminateIcon( node.matches( ':indeterminate' ) );\n\t\t},\n\t\t[ checked, indeterminate ]\n\t);\n\tconst instanceId = useInstanceId( CheckboxControl );\n\tconst id = `inspector-checkbox-control-${ instanceId }`;\n\tconst onChangeValue = ( event: ChangeEvent< HTMLInputElement > ) =>\n\t\tonChange( event.target.checked );\n\n\treturn (\n\t\t<BaseControl\n\t\t\tlabel={ heading }\n\t\t\tid={ id }\n\t\t\thelp={ help }\n\t\t\tclassName={ classnames( 'components-checkbox-control', className ) }\n\t\t>\n\t\t\t<span className=\"components-checkbox-control__input-container\">\n\t\t\t\t<input\n\t\t\t\t\tref={ ref }\n\t\t\t\t\tid={ id }\n\t\t\t\t\tclassName=\"components-checkbox-control__input\"\n\t\t\t\t\ttype=\"checkbox\"\n\t\t\t\t\tvalue=\"1\"\n\t\t\t\t\tonChange={ onChangeValue }\n\t\t\t\t\tchecked={ checked }\n\t\t\t\t\taria-describedby={ !! help ? id + '__help' : undefined }\n\t\t\t\t\t{ ...additionalProps }\n\t\t\t\t/>\n\t\t\t\t{ showIndeterminateIcon ? (\n\t\t\t\t\t<Icon\n\t\t\t\t\t\ticon={ reset }\n\t\t\t\t\t\tclassName=\"components-checkbox-control__indeterminate\"\n\t\t\t\t\t\trole=\"presentation\"\n\t\t\t\t\t/>\n\t\t\t\t) : null }\n\t\t\t\t{ showCheckedIcon ? (\n\t\t\t\t\t<Icon\n\t\t\t\t\t\ticon={ check }\n\t\t\t\t\t\tclassName=\"components-checkbox-control__checked\"\n\t\t\t\t\t\trole=\"presentation\"\n\t\t\t\t\t/>\n\t\t\t\t) : null }\n\t\t\t</span>\n\t\t\t<label\n\t\t\t\tclassName=\"components-checkbox-control__label\"\n\t\t\t\thtmlFor={ id }\n\t\t\t>\n\t\t\t\t{ label }\n\t\t\t</label>\n\t\t</BaseControl>\n\t);\n}\n\nexport default CheckboxControl;\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
|
|
@@ -20,8 +20,6 @@ var _names = _interopRequireDefault(require("colord/plugins/names"));
|
|
|
20
20
|
|
|
21
21
|
var _a11y = _interopRequireDefault(require("colord/plugins/a11y"));
|
|
22
22
|
|
|
23
|
-
var _classnames = _interopRequireDefault(require("classnames"));
|
|
24
|
-
|
|
25
23
|
var _i18n = require("@wordpress/i18n");
|
|
26
24
|
|
|
27
25
|
var _dropdown = _interopRequireDefault(require("../dropdown"));
|
|
@@ -131,9 +129,11 @@ function CustomColorPickerDropdown(_ref5) {
|
|
|
131
129
|
...props
|
|
132
130
|
} = _ref5;
|
|
133
131
|
return (0, _element.createElement)(_dropdown.default, (0, _extends2.default)({
|
|
134
|
-
contentClassName:
|
|
135
|
-
|
|
136
|
-
|
|
132
|
+
contentClassName: "components-color-palette__custom-color-dropdown-content",
|
|
133
|
+
popoverProps: isRenderedInSidebar ? {
|
|
134
|
+
placement: 'left-start',
|
|
135
|
+
offset: 20
|
|
136
|
+
} : undefined
|
|
137
137
|
}, props));
|
|
138
138
|
}
|
|
139
139
|
|
|
@@ -189,12 +189,6 @@ function ColorPalette(_ref6) {
|
|
|
189
189
|
enableAlpha: enableAlpha
|
|
190
190
|
});
|
|
191
191
|
|
|
192
|
-
let dropdownPosition;
|
|
193
|
-
|
|
194
|
-
if (__experimentalIsRenderedInSidebar) {
|
|
195
|
-
dropdownPosition = 'bottom left';
|
|
196
|
-
}
|
|
197
|
-
|
|
198
192
|
const colordColor = (0, _colord.colord)(value);
|
|
199
193
|
const valueWithoutLeadingHash = value !== null && value !== void 0 && value.startsWith('#') ? value.substring(1) : value !== null && value !== void 0 ? value : '';
|
|
200
194
|
const buttonLabelName = (0, _element.useMemo)(() => extractColorNameFromCurrentValue(value, colors, showMultiplePalettes), [value, colors, showMultiplePalettes]);
|
|
@@ -204,7 +198,6 @@ function ColorPalette(_ref6) {
|
|
|
204
198
|
spacing: 3,
|
|
205
199
|
className: className
|
|
206
200
|
}, !disableCustomColors && (0, _element.createElement)(CustomColorPickerDropdown, {
|
|
207
|
-
position: dropdownPosition,
|
|
208
201
|
isRenderedInSidebar: __experimentalIsRenderedInSidebar,
|
|
209
202
|
renderContent: renderCustomColorPicker,
|
|
210
203
|
renderToggle: _ref7 => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/components/src/color-palette/index.js"],"names":["namesPlugin","a11yPlugin","SinglePalette","className","clearColor","colors","onChange","value","actions","colorOptions","color","name","colordColor","fill","contrast","backgroundColor","MultiplePalettes","map","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","Truncate"],"mappings":";;;;;;;;;;AAcA;;;;AAVA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AAMA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAzBA;;AACA;AACA;AACA;;AAOA;AACA;AACA;;AAIA;AACA;AACA;AASA,oBAAQ,CAAEA,cAAF,EAAeC,aAAf,CAAR;;AAEA,SAASC,aAAT,OAOI;AAAA,MAPoB;AACvBC,IAAAA,SADuB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GC,QAPX;AAQC,sBAAaF,0BARd;AASC,QAAA,KAAK,EAAG;AACPG,UAAAA,UAAU,EAAE1C,KADL;AAEPG,UAAAA,KAAK,EACJE,WAAW,CAACE,QAAZ,KACAF,WAAW,CAACE,QAAZ,CAAsB,MAAtB,CADA,GAEG,MAFH,GAGG;AANG;AATT,SAkBC,4BAAC,cAAD;AACC,QAAA,OAAO,MADR;AAEC,QAAA,EAAE,EAAGoC,kBAFN;AAGC,QAAA,SAAS,EAAC;AAHX,SAKGL,eALH,CAlBD,EAyBC,4BAAC,cAAD;AACC,QAAA,EAAE,EAAC,MADJ;AAEC,QAAA,SAAS,EAAC;AAFX,SAIGH,uBAJH,CAzBD,CADc;AAAA;AAJhB,IAFF,EA0CC,4BAAC,SAAD;AACC,IAAA,SAAS,EAAGT,SADb;AAEC,IAAA,UAAU,EAAG7B,UAFd;AAGC,IAAA,MAAM,EAAGC,MAHV;AAIC,IAAA,QAAQ,EAAGC,QAJZ;AAKC,IAAA,KAAK,EAAGC,KALT;AAMC,IAAA,OAAO,EACN,CAAC,CAAE0B,SAAH,IACC,4BAAC,6BAAD,CAAsB,YAAtB;AACC,MAAA,OAAO,EAAG7B;AADX,OAGG,cAAI,OAAJ,CAHH;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":["namesPlugin","a11yPlugin","SinglePalette","className","clearColor","colors","onChange","value","actions","colorOptions","color","name","colordColor","fill","contrast","backgroundColor","MultiplePalettes","map","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","Truncate"],"mappings":";;;;;;;;;;AAaA;;;;AATA;;AACA;;AACA;;AACA;;AAKA;;AAMA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAxBA;;AACA;AACA;AACA;;AAMA;AACA;AACA;;AAIA;AACA;AACA;AASA,oBAAQ,CAAEA,cAAF,EAAeC,aAAf,CAAR;;AAEA,SAASC,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,GAAG,sBAAS,MAAM;AACnC,WAAO,iBAAKJ,MAAL,EAAa,SAAuB;AAAA,UAArB;AAAEK,Q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C,kBAFN;AAGC,QAAA,SAAS,EAAC;AAHX,SAKGL,eALH,CAlBD,EAyBC,4BAAC,cAAD;AACC,QAAA,EAAE,EAAC,MADJ;AAEC,QAAA,SAAS,EAAC;AAFX,SAIGH,uBAJH,CAzBD,CADc;AAAA;AAHhB,IAFF,EAyCC,4BAAC,SAAD;AACC,IAAA,SAAS,EAAGP,SADb;AAEC,IAAA,UAAU,EAAGhC,UAFd;AAGC,IAAA,MAAM,EAAGC,MAHV;AAIC,IAAA,QAAQ,EAAGC,QAJZ;AAKC,IAAA,KAAK,EAAGC,KALT;AAMC,IAAA,OAAO,EACN,CAAC,CAAE6B,SAAH,IACC,4BAAC,6BAAD,CAAsB,YAAtB;AACC,MAAA,OAAO,EAAGhC;AADX,OAGG,cAAI,OAAJ,CAHH;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"]}
|
package/build/date-time/date.js
CHANGED
|
@@ -5,6 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
+
exports.DatePicker = DatePicker;
|
|
8
9
|
exports.default = void 0;
|
|
9
10
|
|
|
10
11
|
var _element = require("@wordpress/element");
|
|
@@ -13,6 +14,8 @@ var _moment = _interopRequireDefault(require("moment"));
|
|
|
13
14
|
|
|
14
15
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
15
16
|
|
|
17
|
+
var _lodash = require("lodash");
|
|
18
|
+
|
|
16
19
|
var _DayPickerSingleDateController = _interopRequireDefault(require("react-dates/lib/components/DayPickerSingleDateController"));
|
|
17
20
|
|
|
18
21
|
var _i18n = require("@wordpress/i18n");
|
|
@@ -22,20 +25,16 @@ var _utils = require("./utils");
|
|
|
22
25
|
/**
|
|
23
26
|
* External dependencies
|
|
24
27
|
*/
|
|
25
|
-
// react-dates doesn't tree-shake correctly, so we import from the individual
|
|
26
|
-
// component here
|
|
27
|
-
|
|
28
|
+
// `react-dates` doesn't tree-shake correctly, so we import from the individual
|
|
29
|
+
// component here.
|
|
30
|
+
// @ts-expect-error TypeScript won't find any type declarations at
|
|
31
|
+
// `react-dates/lib/components/DayPickerSingleDateController` as they're located
|
|
32
|
+
// at `react-dates`.
|
|
33
|
+
const TypedDayPickerSingleDateController = _DayPickerSingleDateController.default;
|
|
28
34
|
/**
|
|
29
35
|
* WordPress dependencies
|
|
30
36
|
*/
|
|
31
37
|
|
|
32
|
-
/**
|
|
33
|
-
* Internal dependencies
|
|
34
|
-
*/
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Module Constants
|
|
38
|
-
*/
|
|
39
38
|
const TIMEZONELESS_FORMAT = 'YYYY-MM-DDTHH:mm:ss';
|
|
40
39
|
const ARIAL_LABEL_TIME_FORMAT = 'dddd, LL';
|
|
41
40
|
|
|
@@ -44,7 +43,7 @@ function DatePickerDay(_ref) {
|
|
|
44
43
|
day,
|
|
45
44
|
events = []
|
|
46
45
|
} = _ref;
|
|
47
|
-
const ref = (0, _element.useRef)();
|
|
46
|
+
const ref = (0, _element.useRef)(null);
|
|
48
47
|
/*
|
|
49
48
|
* a11y hack to make the `There is/are n events` string
|
|
50
49
|
* available speaking for readers,
|
|
@@ -56,7 +55,7 @@ function DatePickerDay(_ref) {
|
|
|
56
55
|
var _ref$current;
|
|
57
56
|
|
|
58
57
|
// Bail when no parent node.
|
|
59
|
-
if (!(ref
|
|
58
|
+
if (!((ref === null || ref === void 0 ? void 0 : (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.parentNode) instanceof Element)) {
|
|
60
59
|
return;
|
|
61
60
|
}
|
|
62
61
|
|
|
@@ -82,6 +81,26 @@ function DatePickerDay(_ref) {
|
|
|
82
81
|
})
|
|
83
82
|
}, day.format('D'));
|
|
84
83
|
}
|
|
84
|
+
/**
|
|
85
|
+
* DatePicker is a React component that renders a calendar for date selection.
|
|
86
|
+
*
|
|
87
|
+
* ```jsx
|
|
88
|
+
* import { DatePicker } from '@wordpress/components';
|
|
89
|
+
* import { useState } from '@wordpress/element';
|
|
90
|
+
*
|
|
91
|
+
* const MyDatePicker = () => {
|
|
92
|
+
* const [ date, setDate ] = useState( new Date() );
|
|
93
|
+
*
|
|
94
|
+
* return (
|
|
95
|
+
* <DatePicker
|
|
96
|
+
* currentDate={ date }
|
|
97
|
+
* onChange={ ( newDate ) => setDate( newDate ) }
|
|
98
|
+
* />
|
|
99
|
+
* );
|
|
100
|
+
* };
|
|
101
|
+
* ```
|
|
102
|
+
*/
|
|
103
|
+
|
|
85
104
|
|
|
86
105
|
function DatePicker(_ref2) {
|
|
87
106
|
let {
|
|
@@ -91,7 +110,7 @@ function DatePicker(_ref2) {
|
|
|
91
110
|
isInvalidDate,
|
|
92
111
|
onMonthPreviewed
|
|
93
112
|
} = _ref2;
|
|
94
|
-
const nodeRef = (0, _element.useRef)();
|
|
113
|
+
const nodeRef = (0, _element.useRef)(null);
|
|
95
114
|
|
|
96
115
|
const onMonthPreviewedHandler = newMonthDate => {
|
|
97
116
|
onMonthPreviewed === null || onMonthPreviewed === void 0 ? void 0 : onMonthPreviewed(newMonthDate.toISOString());
|
|
@@ -121,7 +140,7 @@ function DatePicker(_ref2) {
|
|
|
121
140
|
// Retrieve the focus region div.
|
|
122
141
|
const focusRegion = nodeRef.current.querySelector('.DayPicker_focusRegion');
|
|
123
142
|
|
|
124
|
-
if (!focusRegion) {
|
|
143
|
+
if (!(focusRegion instanceof HTMLElement)) {
|
|
125
144
|
return;
|
|
126
145
|
} // Keep the focus on focus region.
|
|
127
146
|
|
|
@@ -131,14 +150,18 @@ function DatePicker(_ref2) {
|
|
|
131
150
|
};
|
|
132
151
|
|
|
133
152
|
const onChangeMoment = newDate => {
|
|
134
|
-
|
|
153
|
+
if (!newDate) {
|
|
154
|
+
return;
|
|
155
|
+
} // If currentDate is null, use now as momentTime to designate hours, minutes, seconds.
|
|
156
|
+
|
|
157
|
+
|
|
135
158
|
const momentDate = currentDate ? (0, _moment.default)(currentDate) : (0, _moment.default)();
|
|
136
159
|
const momentTime = {
|
|
137
160
|
hours: momentDate.hours(),
|
|
138
161
|
minutes: momentDate.minutes(),
|
|
139
162
|
seconds: 0
|
|
140
163
|
};
|
|
141
|
-
onChange(newDate.set(momentTime).format(TIMEZONELESS_FORMAT)); // Keep focus on the date picker.
|
|
164
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(newDate.set(momentTime).format(TIMEZONELESS_FORMAT)); // Keep focus on the date picker.
|
|
142
165
|
|
|
143
166
|
keepFocusInside();
|
|
144
167
|
};
|
|
@@ -155,7 +178,7 @@ function DatePicker(_ref2) {
|
|
|
155
178
|
return (0, _element.createElement)("div", {
|
|
156
179
|
className: "components-datetime__date",
|
|
157
180
|
ref: nodeRef
|
|
158
|
-
}, (0, _element.createElement)(
|
|
181
|
+
}, (0, _element.createElement)(TypedDayPickerSingleDateController, {
|
|
159
182
|
date: momentDate,
|
|
160
183
|
daySize: 30,
|
|
161
184
|
focused: true,
|
|
@@ -171,14 +194,15 @@ function DatePicker(_ref2) {
|
|
|
171
194
|
dayAriaLabelFormat: ARIAL_LABEL_TIME_FORMAT,
|
|
172
195
|
isRTL: (0, _i18n.isRTL)(),
|
|
173
196
|
isOutsideRange: date => {
|
|
174
|
-
return isInvalidDate && isInvalidDate(date.toDate());
|
|
197
|
+
return !!isInvalidDate && isInvalidDate(date.toDate());
|
|
175
198
|
},
|
|
176
199
|
onPrevMonthClick: onMonthPreviewedHandler,
|
|
177
200
|
onNextMonthClick: onMonthPreviewedHandler,
|
|
178
201
|
renderDayContents: day => (0, _element.createElement)(DatePickerDay, {
|
|
179
202
|
day: day,
|
|
180
203
|
events: getEventsPerDay(day)
|
|
181
|
-
})
|
|
204
|
+
}),
|
|
205
|
+
onFocusChange: _lodash.noop
|
|
182
206
|
}));
|
|
183
207
|
}
|
|
184
208
|
|