@wordpress/components 25.9.1 → 25.11.1-next.f8d8eceb.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 +48 -0
- package/build/alignment-matrix-control/cell.js +8 -5
- package/build/alignment-matrix-control/cell.js.map +1 -1
- package/build/alignment-matrix-control/index.js +27 -43
- package/build/alignment-matrix-control/index.js.map +1 -1
- package/build/alignment-matrix-control/utils.js +29 -9
- package/build/alignment-matrix-control/utils.js.map +1 -1
- package/build/autocomplete/index.js +104 -52
- package/build/autocomplete/index.js.map +1 -1
- package/build/circular-option-picker/circular-option-picker-option.js +20 -39
- package/build/circular-option-picker/circular-option-picker-option.js.map +1 -1
- package/build/circular-option-picker/circular-option-picker.js +11 -32
- package/build/circular-option-picker/circular-option-picker.js.map +1 -1
- package/build/circular-option-picker/types.js.map +1 -1
- package/build/color-palette/index.js +7 -2
- package/build/color-palette/index.js.map +1 -1
- package/build/color-picker/component.js +12 -2
- package/build/color-picker/component.js.map +1 -1
- package/build/color-picker/picker.js +77 -1
- package/build/color-picker/picker.js.map +1 -1
- package/build/color-picker/styles.js +8 -8
- package/build/color-picker/styles.js.map +1 -1
- package/build/color-picker/types.js.map +1 -1
- package/build/composite/v2.js +43 -0
- package/build/composite/v2.js.map +1 -0
- package/build/confirm-dialog/component.js +74 -8
- package/build/confirm-dialog/component.js.map +1 -1
- package/build/confirm-dialog/types.js.map +1 -1
- package/build/custom-gradient-picker/gradient-bar/control-points.js +13 -4
- package/build/custom-gradient-picker/gradient-bar/control-points.js.map +1 -1
- package/build/dropdown-menu-v2-ariakit/index.js +217 -0
- package/build/dropdown-menu-v2-ariakit/index.js.map +1 -0
- package/build/dropdown-menu-v2-ariakit/styles.js +157 -0
- package/build/dropdown-menu-v2-ariakit/styles.js.map +1 -0
- package/build/dropdown-menu-v2-ariakit/types.js +6 -0
- package/build/dropdown-menu-v2-ariakit/types.js.map +1 -0
- package/build/font-size-picker/utils.js +1 -1
- package/build/font-size-picker/utils.js.map +1 -1
- package/build/input-control/styles/input-control-styles.js +23 -23
- package/build/input-control/styles/input-control-styles.js.map +1 -1
- package/build/mobile/global-styles-context/utils.native.js +1 -1
- package/build/mobile/global-styles-context/utils.native.js.map +1 -1
- package/build/modal/index.js +45 -16
- package/build/modal/index.js.map +1 -1
- package/build/palette-edit/index.js +4 -0
- package/build/palette-edit/index.js.map +1 -1
- package/build/popover/index.js +34 -6
- package/build/popover/index.js.map +1 -1
- package/build/private-apis.js +18 -2
- package/build/private-apis.js.map +1 -1
- package/build/progress-bar/styles.js +5 -5
- package/build/progress-bar/styles.js.map +1 -1
- package/build/sandbox/index.js +1 -1
- 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/styles/select-control-styles.js +8 -8
- package/build/select-control/styles/select-control-styles.js.map +1 -1
- package/build/tabs/context.js +16 -0
- package/build/tabs/context.js.map +1 -0
- package/build/tabs/index.js +147 -0
- package/build/tabs/index.js.map +1 -0
- package/build/tabs/styles.js +38 -0
- package/build/tabs/styles.js.map +1 -0
- package/build/tabs/tab.js +46 -0
- package/build/tabs/tab.js.map +1 -0
- package/build/tabs/tablist.js +47 -0
- package/build/tabs/tablist.js.map +1 -0
- package/build/tabs/tabpanel.js +48 -0
- package/build/tabs/tabpanel.js.map +1 -0
- package/build/tabs/types.js +6 -0
- package/build/tabs/types.js.map +1 -0
- package/build/text/component.js +7 -6
- package/build/text/component.js.map +1 -1
- package/build/text/hook.js +6 -15
- package/build/text/hook.js.map +1 -1
- package/build/text/index.js.map +1 -1
- package/build/text/styles.js +7 -7
- package/build/text/styles.js.map +1 -1
- package/build/text/types.js.map +1 -1
- package/build/text/utils.js +17 -33
- package/build/text/utils.js.map +1 -1
- package/build/toggle-group-control/toggle-group-control-option-base/component.js +1 -0
- package/build/toggle-group-control/toggle-group-control-option-base/component.js.map +1 -1
- package/build/toolbar/toolbar/index.js +17 -10
- package/build/toolbar/toolbar/index.js.map +1 -1
- package/build/toolbar/toolbar/types.js.map +1 -1
- package/build/tools-panel/tools-panel-item/hook.js +2 -2
- package/build/tools-panel/tools-panel-item/hook.js.map +1 -1
- package/build/tools-panel/types.js.map +1 -1
- package/build/tooltip/index.js +2 -2
- package/build/tooltip/index.js.map +1 -1
- package/build/unit-control/utils.js +108 -0
- package/build/unit-control/utils.js.map +1 -1
- package/build/utils/unit-values.js +1 -1
- package/build/utils/unit-values.js.map +1 -1
- package/build-module/alignment-matrix-control/cell.js +7 -4
- package/build-module/alignment-matrix-control/cell.js.map +1 -1
- package/build-module/alignment-matrix-control/index.js +27 -43
- package/build-module/alignment-matrix-control/index.js.map +1 -1
- package/build-module/alignment-matrix-control/utils.js +29 -8
- package/build-module/alignment-matrix-control/utils.js.map +1 -1
- package/build-module/autocomplete/index.js +104 -52
- package/build-module/autocomplete/index.js.map +1 -1
- package/build-module/circular-option-picker/circular-option-picker-option.js +20 -39
- package/build-module/circular-option-picker/circular-option-picker-option.js.map +1 -1
- package/build-module/circular-option-picker/circular-option-picker.js +10 -31
- package/build-module/circular-option-picker/circular-option-picker.js.map +1 -1
- package/build-module/circular-option-picker/types.js.map +1 -1
- package/build-module/color-palette/index.js +7 -2
- package/build-module/color-palette/index.js.map +1 -1
- package/build-module/color-picker/component.js +13 -3
- package/build-module/color-picker/component.js.map +1 -1
- package/build-module/color-picker/picker.js +78 -2
- package/build-module/color-picker/picker.js.map +1 -1
- package/build-module/color-picker/styles.js +8 -8
- package/build-module/color-picker/styles.js.map +1 -1
- package/build-module/color-picker/types.js.map +1 -1
- package/build-module/composite/v2.js +15 -0
- package/build-module/composite/v2.js.map +1 -0
- package/build-module/confirm-dialog/component.js +72 -7
- package/build-module/confirm-dialog/component.js.map +1 -1
- package/build-module/confirm-dialog/types.js.map +1 -1
- package/build-module/custom-gradient-picker/gradient-bar/control-points.js +13 -4
- package/build-module/custom-gradient-picker/gradient-bar/control-points.js.map +1 -1
- package/build-module/dropdown-menu-v2-ariakit/index.js +199 -0
- package/build-module/dropdown-menu-v2-ariakit/index.js.map +1 -0
- package/build-module/dropdown-menu-v2-ariakit/styles.js +136 -0
- package/build-module/dropdown-menu-v2-ariakit/styles.js.map +1 -0
- package/build-module/dropdown-menu-v2-ariakit/types.js +2 -0
- package/build-module/dropdown-menu-v2-ariakit/types.js.map +1 -0
- package/build-module/font-size-picker/utils.js +1 -1
- package/build-module/font-size-picker/utils.js.map +1 -1
- package/build-module/input-control/styles/input-control-styles.js +23 -23
- package/build-module/input-control/styles/input-control-styles.js.map +1 -1
- package/build-module/mobile/global-styles-context/utils.native.js +2 -2
- package/build-module/mobile/global-styles-context/utils.native.js.map +1 -1
- package/build-module/modal/index.js +47 -18
- package/build-module/modal/index.js.map +1 -1
- package/build-module/palette-edit/index.js +4 -0
- package/build-module/palette-edit/index.js.map +1 -1
- package/build-module/popover/index.js +34 -6
- package/build-module/popover/index.js.map +1 -1
- package/build-module/private-apis.js +18 -2
- package/build-module/private-apis.js.map +1 -1
- package/build-module/progress-bar/styles.js +5 -5
- package/build-module/progress-bar/styles.js.map +1 -1
- package/build-module/sandbox/index.js +1 -1
- 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/styles/select-control-styles.js +8 -8
- package/build-module/select-control/styles/select-control-styles.js.map +1 -1
- package/build-module/tabs/context.js +12 -0
- package/build-module/tabs/context.js.map +1 -0
- package/build-module/tabs/index.js +142 -0
- package/build-module/tabs/index.js.map +1 -0
- package/build-module/tabs/styles.js +36 -0
- package/build-module/tabs/styles.js.map +1 -0
- package/build-module/tabs/tab.js +43 -0
- package/build-module/tabs/tab.js.map +1 -0
- package/build-module/tabs/tablist.js +41 -0
- package/build-module/tabs/tablist.js.map +1 -0
- package/build-module/tabs/tabpanel.js +43 -0
- package/build-module/tabs/tabpanel.js.map +1 -0
- package/build-module/tabs/types.js +2 -0
- package/build-module/tabs/types.js.map +1 -0
- package/build-module/text/component.js +6 -6
- package/build-module/text/component.js.map +1 -1
- package/build-module/text/hook.js +11 -19
- package/build-module/text/hook.js.map +1 -1
- package/build-module/text/index.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/types.js.map +1 -1
- package/build-module/text/utils.js +17 -10
- package/build-module/text/utils.js.map +1 -1
- package/build-module/toggle-group-control/toggle-group-control-option-base/component.js +1 -0
- package/build-module/toggle-group-control/toggle-group-control-option-base/component.js.map +1 -1
- package/build-module/toolbar/toolbar/index.js +18 -11
- package/build-module/toolbar/toolbar/index.js.map +1 -1
- package/build-module/toolbar/toolbar/types.js.map +1 -1
- package/build-module/tools-panel/tools-panel-item/hook.js +2 -2
- package/build-module/tools-panel/tools-panel-item/hook.js.map +1 -1
- package/build-module/tools-panel/types.js.map +1 -1
- package/build-module/tooltip/index.js +2 -2
- package/build-module/tooltip/index.js.map +1 -1
- package/build-module/unit-control/utils.js +108 -0
- package/build-module/unit-control/utils.js.map +1 -1
- package/build-module/utils/unit-values.js +1 -1
- package/build-module/utils/unit-values.js.map +1 -1
- package/build-style/style-rtl.css +17 -5
- package/build-style/style.css +17 -5
- package/build-types/alignment-matrix-control/cell.d.ts +1 -1
- package/build-types/alignment-matrix-control/cell.d.ts.map +1 -1
- package/build-types/alignment-matrix-control/index.d.ts.map +1 -1
- package/build-types/alignment-matrix-control/stories/index.story.d.ts.map +1 -1
- package/build-types/alignment-matrix-control/utils.d.ts +9 -9
- package/build-types/alignment-matrix-control/utils.d.ts.map +1 -1
- package/build-types/autocomplete/index.d.ts.map +1 -1
- package/build-types/circular-option-picker/circular-option-picker-option.d.ts.map +1 -1
- package/build-types/circular-option-picker/circular-option-picker.d.ts.map +1 -1
- package/build-types/circular-option-picker/types.d.ts +4 -6
- package/build-types/circular-option-picker/types.d.ts.map +1 -1
- package/build-types/color-palette/index.d.ts.map +1 -1
- package/build-types/color-picker/component.d.ts.map +1 -1
- package/build-types/color-picker/picker.d.ts +1 -1
- package/build-types/color-picker/picker.d.ts.map +1 -1
- package/build-types/color-picker/styles.d.ts.map +1 -1
- package/build-types/color-picker/types.d.ts +3 -0
- package/build-types/color-picker/types.d.ts.map +1 -1
- package/build-types/composite/v2.d.ts +12 -0
- package/build-types/composite/v2.d.ts.map +1 -0
- package/build-types/confirm-dialog/component.d.ts +70 -29
- package/build-types/confirm-dialog/component.d.ts.map +1 -1
- package/build-types/confirm-dialog/stories/index.story.d.ts +11 -0
- package/build-types/confirm-dialog/stories/index.story.d.ts.map +1 -0
- package/build-types/confirm-dialog/test/index.d.ts +2 -0
- package/build-types/confirm-dialog/test/index.d.ts.map +1 -0
- package/build-types/confirm-dialog/types.d.ts +32 -10
- package/build-types/confirm-dialog/types.d.ts.map +1 -1
- package/build-types/custom-gradient-picker/gradient-bar/control-points.d.ts.map +1 -1
- package/build-types/dropdown-menu-v2-ariakit/index.d.ts +11 -0
- package/build-types/dropdown-menu-v2-ariakit/index.d.ts.map +1 -0
- package/build-types/dropdown-menu-v2-ariakit/stories/index.story.d.ts +16 -0
- package/build-types/dropdown-menu-v2-ariakit/stories/index.story.d.ts.map +1 -0
- package/build-types/dropdown-menu-v2-ariakit/styles.d.ts +88 -0
- package/build-types/dropdown-menu-v2-ariakit/styles.d.ts.map +1 -0
- package/build-types/dropdown-menu-v2-ariakit/test/index.d.ts +2 -0
- package/build-types/dropdown-menu-v2-ariakit/test/index.d.ts.map +1 -0
- package/build-types/dropdown-menu-v2-ariakit/types.d.ts +174 -0
- package/build-types/dropdown-menu-v2-ariakit/types.d.ts.map +1 -0
- package/build-types/font-size-picker/utils.d.ts.map +1 -1
- package/build-types/heading/stories/index.story.d.ts.map +1 -1
- package/build-types/modal/index.d.ts.map +1 -1
- package/build-types/palette-edit/index.d.ts.map +1 -1
- package/build-types/popover/index.d.ts +1 -1
- package/build-types/popover/index.d.ts.map +1 -1
- package/build-types/popover/stories/e2e/index.story.d.ts +1 -1
- package/build-types/private-apis.d.ts.map +1 -1
- package/build-types/progress-bar/styles.d.ts.map +1 -1
- package/build-types/sandbox/index.d.ts.map +1 -1
- package/build-types/tabs/context.d.ts +8 -0
- package/build-types/tabs/context.d.ts.map +1 -0
- package/build-types/tabs/index.d.ts +13 -0
- package/build-types/tabs/index.d.ts.map +1 -0
- package/build-types/tabs/stories/index.story.d.ts +20 -0
- package/build-types/tabs/stories/index.story.d.ts.map +1 -0
- package/build-types/tabs/styles.d.ts +17 -0
- package/build-types/tabs/styles.d.ts.map +1 -0
- package/build-types/tabs/tab.d.ts +10 -0
- package/build-types/tabs/tab.d.ts.map +1 -0
- package/build-types/tabs/tablist.d.ts +7 -0
- package/build-types/tabs/tablist.d.ts.map +1 -0
- package/build-types/tabs/tabpanel.d.ts +7 -0
- package/build-types/tabs/tabpanel.d.ts.map +1 -0
- package/build-types/tabs/test/index.d.ts +2 -0
- package/build-types/tabs/test/index.d.ts.map +1 -0
- package/build-types/tabs/types.d.ts +134 -0
- package/build-types/tabs/types.d.ts.map +1 -0
- package/build-types/text/component.d.ts +4 -2
- package/build-types/text/component.d.ts.map +1 -1
- package/build-types/text/hook.d.ts +171 -165
- package/build-types/text/hook.d.ts.map +1 -1
- package/build-types/text/index.d.ts +2 -2
- package/build-types/text/index.d.ts.map +1 -1
- package/build-types/text/stories/index.story.d.ts +21 -0
- package/build-types/text/stories/index.story.d.ts.map +1 -0
- package/build-types/text/styles.d.ts +7 -7
- package/build-types/text/styles.d.ts.map +1 -1
- package/build-types/text/types.d.ts +1 -1
- package/build-types/text/types.d.ts.map +1 -1
- package/build-types/text/utils.d.ts +56 -61
- package/build-types/text/utils.d.ts.map +1 -1
- package/build-types/toggle-group-control/toggle-group-control-option-base/component.d.ts.map +1 -1
- package/build-types/toolbar/stories/index.story.d.ts +5 -0
- package/build-types/toolbar/stories/index.story.d.ts.map +1 -1
- package/build-types/toolbar/toolbar/index.d.ts.map +1 -1
- package/build-types/toolbar/toolbar/types.d.ts +10 -0
- package/build-types/toolbar/toolbar/types.d.ts.map +1 -1
- package/build-types/tools-panel/tools-panel-item/hook.d.ts.map +1 -1
- package/build-types/tools-panel/types.d.ts +2 -0
- 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/utils.d.ts.map +1 -1
- package/package.json +21 -20
- package/src/alignment-matrix-control/cell.tsx +6 -2
- package/src/alignment-matrix-control/index.tsx +31 -54
- package/src/alignment-matrix-control/stories/index.story.tsx +3 -7
- package/src/alignment-matrix-control/test/index.tsx +117 -18
- package/src/alignment-matrix-control/utils.tsx +33 -9
- package/src/autocomplete/index.tsx +136 -77
- package/src/button/style.scss +1 -2
- package/src/circular-option-picker/circular-option-picker-option.tsx +24 -38
- package/src/circular-option-picker/circular-option-picker.tsx +11 -28
- package/src/circular-option-picker/types.ts +6 -5
- package/src/color-palette/index.tsx +6 -1
- package/src/color-picker/component.tsx +25 -3
- package/src/color-picker/picker.tsx +96 -2
- package/src/color-picker/styles.ts +0 -1
- package/src/color-picker/types.ts +3 -0
- package/src/composite/v2.ts +22 -0
- package/src/confirm-dialog/README.md +1 -1
- package/src/confirm-dialog/component.tsx +79 -13
- package/src/confirm-dialog/stories/{index.story.js → index.story.tsx} +26 -24
- package/src/confirm-dialog/test/{index.js → index.tsx} +3 -3
- package/src/confirm-dialog/types.ts +32 -12
- package/src/custom-gradient-picker/gradient-bar/control-points.tsx +32 -25
- package/src/dimension-control/test/__snapshots__/index.test.js.snap +8 -8
- package/src/dropdown-menu-v2-ariakit/README.md +324 -0
- package/src/dropdown-menu-v2-ariakit/index.tsx +318 -0
- package/src/dropdown-menu-v2-ariakit/stories/index.story.tsx +506 -0
- package/src/dropdown-menu-v2-ariakit/styles.ts +297 -0
- package/src/dropdown-menu-v2-ariakit/test/index.tsx +1139 -0
- package/src/dropdown-menu-v2-ariakit/types.ts +186 -0
- package/src/font-size-picker/utils.ts +2 -1
- package/src/heading/stories/index.story.tsx +2 -4
- package/src/input-control/styles/input-control-styles.tsx +2 -2
- package/src/mobile/global-styles-context/utils.native.js +2 -2
- package/src/modal/index.tsx +58 -22
- package/src/modal/test/index.tsx +29 -0
- package/src/notice/style.scss +0 -1
- package/src/palette-edit/index.tsx +4 -0
- package/src/popover/index.tsx +99 -57
- package/src/popover/style.scss +9 -0
- package/src/private-apis.ts +31 -1
- package/src/progress-bar/styles.ts +19 -4
- package/src/sandbox/index.native.js +1 -1
- package/src/sandbox/index.tsx +3 -1
- package/src/select-control/styles/select-control-styles.ts +2 -2
- package/src/tabs/README.md +242 -0
- package/src/tabs/context.ts +13 -0
- package/src/tabs/index.tsx +167 -0
- package/src/tabs/stories/index.story.tsx +352 -0
- package/src/tabs/styles.ts +103 -0
- package/src/tabs/tab.tsx +39 -0
- package/src/tabs/tablist.tsx +40 -0
- package/src/tabs/tabpanel.tsx +42 -0
- package/src/tabs/test/index.tsx +1133 -0
- package/src/tabs/types.ts +142 -0
- package/src/text/README.md +2 -2
- package/src/text/{component.js → component.tsx} +10 -6
- package/src/text/{hook.js → hook.ts} +12 -15
- package/src/text/stories/index.story.tsx +80 -0
- package/src/text/types.ts +1 -6
- package/src/text/{utils.js → utils.ts} +40 -14
- package/src/toggle-group-control/test/__snapshots__/index.tsx.snap +16 -0
- package/src/toggle-group-control/toggle-group-control-option-base/component.tsx +1 -0
- package/src/toolbar/stories/index.story.tsx +15 -0
- package/src/toolbar/test/index.tsx +8 -0
- package/src/toolbar/toolbar/README.md +9 -0
- package/src/toolbar/toolbar/index.tsx +21 -12
- package/src/toolbar/toolbar/style.scss +9 -0
- package/src/toolbar/toolbar/types.ts +10 -0
- package/src/tools-panel/tools-panel/README.md +3 -0
- package/src/tools-panel/tools-panel-item/hook.ts +4 -6
- package/src/tools-panel/types.ts +2 -0
- package/src/tooltip/index.tsx +2 -3
- package/src/unit-control/utils.ts +124 -0
- package/src/utils/unit-values.ts +1 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/src/text/stories/index.story.js +0 -53
- /package/src/text/{index.js → index.ts} +0 -0
- /package/src/text/{styles.js → styles.ts} +0 -0
|
@@ -59,6 +59,9 @@ export interface PickerProps {
|
|
|
59
59
|
color: Colord;
|
|
60
60
|
enableAlpha: boolean;
|
|
61
61
|
onChange: ( nextColor: Colord ) => void;
|
|
62
|
+
containerEl: HTMLElement | null;
|
|
63
|
+
onDragStart?: ( event: MouseEvent ) => void;
|
|
64
|
+
onDragEnd?: ( event: MouseEvent ) => void;
|
|
62
65
|
}
|
|
63
66
|
|
|
64
67
|
export interface ColorInputProps {
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Composite is a component that may contain navigable items represented by
|
|
3
|
+
* CompositeItem. It's inspired by the WAI-ARIA Composite Role and implements
|
|
4
|
+
* all the keyboard navigation mechanisms to ensure that there's only one
|
|
5
|
+
* tab stop for the whole Composite element. This means that it can behave as
|
|
6
|
+
* a roving tabindex or aria-activedescendant container.
|
|
7
|
+
*
|
|
8
|
+
* @see https://ariakit.org/components/composite
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/* eslint-disable-next-line no-restricted-imports */
|
|
12
|
+
export {
|
|
13
|
+
Composite,
|
|
14
|
+
CompositeGroup,
|
|
15
|
+
CompositeGroupLabel,
|
|
16
|
+
CompositeItem,
|
|
17
|
+
CompositeRow,
|
|
18
|
+
useCompositeStore,
|
|
19
|
+
} from '@ariakit/react';
|
|
20
|
+
|
|
21
|
+
/* eslint-disable-next-line no-restricted-imports */
|
|
22
|
+
export type { CompositeStore } from '@ariakit/react';
|
|
@@ -137,4 +137,4 @@ The optional custom text to display as the confirmation button's label
|
|
|
137
137
|
- Required: No
|
|
138
138
|
- Default: "Cancel"
|
|
139
139
|
|
|
140
|
-
The optional custom text to display as the
|
|
140
|
+
The optional custom text to display as the cancellation button's label
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import type { ForwardedRef, KeyboardEvent } from 'react';
|
|
5
|
-
|
|
6
1
|
/**
|
|
7
2
|
* WordPress dependencies
|
|
8
3
|
*/
|
|
@@ -13,7 +8,7 @@ import { useCallback, useEffect, useRef, useState } from '@wordpress/element';
|
|
|
13
8
|
* Internal dependencies
|
|
14
9
|
*/
|
|
15
10
|
import Modal from '../modal';
|
|
16
|
-
import type {
|
|
11
|
+
import type { ConfirmDialogProps, DialogInputEvent } from './types';
|
|
17
12
|
import type { WordPressComponentProps } from '../context';
|
|
18
13
|
import { useContextSystem, contextConnect } from '../context';
|
|
19
14
|
import { Flex } from '../flex';
|
|
@@ -23,10 +18,10 @@ import { VStack } from '../v-stack';
|
|
|
23
18
|
import * as styles from './styles';
|
|
24
19
|
import { useCx } from '../utils/hooks/use-cx';
|
|
25
20
|
|
|
26
|
-
|
|
27
|
-
props: WordPressComponentProps<
|
|
28
|
-
forwardedRef: ForwardedRef< any >
|
|
29
|
-
) {
|
|
21
|
+
const UnconnectedConfirmDialog = (
|
|
22
|
+
props: WordPressComponentProps< ConfirmDialogProps, 'div', false >,
|
|
23
|
+
forwardedRef: React.ForwardedRef< any >
|
|
24
|
+
) => {
|
|
30
25
|
const {
|
|
31
26
|
isOpen: isOpenProp,
|
|
32
27
|
onConfirm,
|
|
@@ -67,7 +62,7 @@ function ConfirmDialog(
|
|
|
67
62
|
);
|
|
68
63
|
|
|
69
64
|
const handleEnter = useCallback(
|
|
70
|
-
( event: KeyboardEvent< HTMLDivElement > ) => {
|
|
65
|
+
( event: React.KeyboardEvent< HTMLDivElement > ) => {
|
|
71
66
|
// Avoid triggering the 'confirm' action when a button is focused,
|
|
72
67
|
// as this can cause a double submission.
|
|
73
68
|
const isConfirmOrCancelButton =
|
|
@@ -120,6 +115,77 @@ function ConfirmDialog(
|
|
|
120
115
|
) }
|
|
121
116
|
</>
|
|
122
117
|
);
|
|
123
|
-
}
|
|
118
|
+
};
|
|
124
119
|
|
|
125
|
-
|
|
120
|
+
/**
|
|
121
|
+
* `ConfirmDialog` is built of top of [`Modal`](/packages/components/src/modal/README.md)
|
|
122
|
+
* and displays a confirmation dialog, with _confirm_ and _cancel_ buttons.
|
|
123
|
+
* The dialog is confirmed by clicking the _confirm_ button or by pressing the `Enter` key.
|
|
124
|
+
* It is cancelled (closed) by clicking the _cancel_ button, by pressing the `ESC` key, or by
|
|
125
|
+
* clicking outside the dialog focus (i.e, the overlay).
|
|
126
|
+
*
|
|
127
|
+
* `ConfirmDialog` has two main implicit modes: controlled and uncontrolled.
|
|
128
|
+
*
|
|
129
|
+
* UnControlled:
|
|
130
|
+
*
|
|
131
|
+
* Allows the component to be used standalone, just by declaring it as part of another React's component render method:
|
|
132
|
+
* - It will be automatically open (displayed) upon mounting;
|
|
133
|
+
* - It will be automatically closed when clicking the _cancel_ button, by pressing the `ESC` key, or by clicking outside the dialog focus (i.e, the overlay);
|
|
134
|
+
* - `onCancel` is not mandatory but can be passed. Even if passed, the dialog will still be able to close itself.
|
|
135
|
+
*
|
|
136
|
+
* Activating this mode is as simple as omitting the `isOpen` prop. The only mandatory prop, in this case, is the `onConfirm` callback. The message is passed as the `children`. You can pass any JSX you'd like, which allows to further format the message or include sub-component if you'd like:
|
|
137
|
+
*
|
|
138
|
+
* ```jsx
|
|
139
|
+
* import { __experimentalConfirmDialog as ConfirmDialog } from '@wordpress/components';
|
|
140
|
+
*
|
|
141
|
+
* function Example() {
|
|
142
|
+
* return (
|
|
143
|
+
* <ConfirmDialog onConfirm={ () => console.debug( ' Confirmed! ' ) }>
|
|
144
|
+
* Are you sure? <strong>This action cannot be undone!</strong>
|
|
145
|
+
* </ConfirmDialog>
|
|
146
|
+
* );
|
|
147
|
+
* }
|
|
148
|
+
* ```
|
|
149
|
+
*
|
|
150
|
+
*
|
|
151
|
+
* Controlled mode:
|
|
152
|
+
* Let the parent component control when the dialog is open/closed. It's activated when a
|
|
153
|
+
* boolean value is passed to `isOpen`:
|
|
154
|
+
* - It will not be automatically closed. You need to let it know when to open/close by updating the value of the `isOpen` prop;
|
|
155
|
+
* - Both `onConfirm` and the `onCancel` callbacks are mandatory props in this mode;
|
|
156
|
+
* - You'll want to update the state that controls `isOpen` by updating it from the `onCancel` and `onConfirm` callbacks.
|
|
157
|
+
*
|
|
158
|
+
*```jsx
|
|
159
|
+
* import { __experimentalConfirmDialog as ConfirmDialog } from '@wordpress/components';
|
|
160
|
+
* import { useState } from '@wordpress/element';
|
|
161
|
+
*
|
|
162
|
+
* function Example() {
|
|
163
|
+
* const [ isOpen, setIsOpen ] = useState( true );
|
|
164
|
+
*
|
|
165
|
+
* const handleConfirm = () => {
|
|
166
|
+
* console.debug( 'Confirmed!' );
|
|
167
|
+
* setIsOpen( false );
|
|
168
|
+
* };
|
|
169
|
+
*
|
|
170
|
+
* const handleCancel = () => {
|
|
171
|
+
* console.debug( 'Cancelled!' );
|
|
172
|
+
* setIsOpen( false );
|
|
173
|
+
* };
|
|
174
|
+
*
|
|
175
|
+
* return (
|
|
176
|
+
* <ConfirmDialog
|
|
177
|
+
* isOpen={ isOpen }
|
|
178
|
+
* onConfirm={ handleConfirm }
|
|
179
|
+
* onCancel={ handleCancel }
|
|
180
|
+
* >
|
|
181
|
+
* Are you sure? <strong>This action cannot be undone!</strong>
|
|
182
|
+
* </ConfirmDialog>
|
|
183
|
+
* );
|
|
184
|
+
* }
|
|
185
|
+
* ```
|
|
186
|
+
*/
|
|
187
|
+
export const ConfirmDialog = contextConnect(
|
|
188
|
+
UnconnectedConfirmDialog,
|
|
189
|
+
'ConfirmDialog'
|
|
190
|
+
);
|
|
191
|
+
export default ConfirmDialog;
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import type { Meta, StoryFn } from '@storybook/react';
|
|
5
|
+
|
|
1
6
|
/**
|
|
2
7
|
* WordPress dependencies
|
|
3
8
|
*/
|
|
@@ -7,47 +12,41 @@ import { useState } from '@wordpress/element';
|
|
|
7
12
|
* Internal dependencies
|
|
8
13
|
*/
|
|
9
14
|
import Button from '../../button';
|
|
10
|
-
import { ConfirmDialog } from '
|
|
15
|
+
import { ConfirmDialog } from '../component';
|
|
11
16
|
|
|
12
|
-
const meta = {
|
|
17
|
+
const meta: Meta< typeof ConfirmDialog > = {
|
|
13
18
|
component: ConfirmDialog,
|
|
14
19
|
title: 'Components (Experimental)/ConfirmDialog',
|
|
15
20
|
argTypes: {
|
|
16
|
-
children: {
|
|
17
|
-
control: { type: 'text' },
|
|
18
|
-
},
|
|
19
|
-
confirmButtonText: {
|
|
20
|
-
control: { type: 'text' },
|
|
21
|
-
},
|
|
22
|
-
cancelButtonText: {
|
|
23
|
-
control: { type: 'text' },
|
|
24
|
-
},
|
|
25
21
|
isOpen: {
|
|
26
22
|
control: { type: null },
|
|
27
23
|
},
|
|
28
|
-
onConfirm: { action: 'onConfirm' },
|
|
29
|
-
onCancel: { action: 'onCancel' },
|
|
30
|
-
},
|
|
31
|
-
args: {
|
|
32
|
-
children: 'Would you like to privately publish the post now?',
|
|
33
24
|
},
|
|
34
25
|
parameters: {
|
|
26
|
+
actions: { argTypesRegex: '^on.*' },
|
|
27
|
+
controls: {
|
|
28
|
+
expanded: true,
|
|
29
|
+
},
|
|
35
30
|
docs: { canvas: { sourceState: 'shown' } },
|
|
36
31
|
},
|
|
37
32
|
};
|
|
38
33
|
|
|
39
34
|
export default meta;
|
|
40
35
|
|
|
41
|
-
const Template
|
|
36
|
+
const Template: StoryFn< typeof ConfirmDialog > = ( {
|
|
37
|
+
onConfirm,
|
|
38
|
+
onCancel,
|
|
39
|
+
...args
|
|
40
|
+
} ) => {
|
|
42
41
|
const [ isOpen, setIsOpen ] = useState( false );
|
|
43
42
|
|
|
44
|
-
const handleConfirm = (
|
|
45
|
-
onConfirm(
|
|
43
|
+
const handleConfirm: typeof onConfirm = ( confirmArgs ) => {
|
|
44
|
+
onConfirm( confirmArgs );
|
|
46
45
|
setIsOpen( false );
|
|
47
46
|
};
|
|
48
47
|
|
|
49
|
-
const handleCancel = (
|
|
50
|
-
onCancel(
|
|
48
|
+
const handleCancel: typeof onCancel = ( cancelArgs ) => {
|
|
49
|
+
onCancel?.( cancelArgs );
|
|
51
50
|
setIsOpen( false );
|
|
52
51
|
};
|
|
53
52
|
|
|
@@ -70,7 +69,7 @@ const Template = ( { onConfirm, onCancel, ...args } ) => {
|
|
|
70
69
|
};
|
|
71
70
|
|
|
72
71
|
// Simplest usage: just declare the component with the required `onConfirm` prop. Note: the `onCancel` prop is optional here, unless you'd like to render the component in Controlled mode (see below)
|
|
73
|
-
export const
|
|
72
|
+
export const Default = Template.bind( {} );
|
|
74
73
|
const _defaultSnippet = `() => {
|
|
75
74
|
const [ isOpen, setIsOpen ] = useState( false );
|
|
76
75
|
const [ confirmVal, setConfirmVal ] = useState('');
|
|
@@ -103,8 +102,10 @@ const _defaultSnippet = `() => {
|
|
|
103
102
|
</>
|
|
104
103
|
);
|
|
105
104
|
};`;
|
|
106
|
-
|
|
107
|
-
|
|
105
|
+
Default.args = {
|
|
106
|
+
children: 'Would you like to privately publish the post now?',
|
|
107
|
+
};
|
|
108
|
+
Default.parameters = {
|
|
108
109
|
docs: {
|
|
109
110
|
source: {
|
|
110
111
|
code: _defaultSnippet,
|
|
@@ -117,6 +118,7 @@ _default.parameters = {
|
|
|
117
118
|
// To customize button text, pass the `cancelButtonText` and/or `confirmButtonText` props.
|
|
118
119
|
export const WithCustomButtonLabels = Template.bind( {} );
|
|
119
120
|
WithCustomButtonLabels.args = {
|
|
121
|
+
...Default.args,
|
|
120
122
|
cancelButtonText: 'No thanks',
|
|
121
123
|
confirmButtonText: 'Yes please!',
|
|
122
124
|
};
|
|
@@ -113,7 +113,7 @@ describe( 'Confirm', () => {
|
|
|
113
113
|
expect( onCancel ).toHaveBeenCalled();
|
|
114
114
|
} );
|
|
115
115
|
|
|
116
|
-
it( 'should be
|
|
116
|
+
it( 'should be dismissible even if an `onCancel` callback is not provided', async () => {
|
|
117
117
|
const user = userEvent.setup();
|
|
118
118
|
|
|
119
119
|
render(
|
|
@@ -144,7 +144,7 @@ describe( 'Confirm', () => {
|
|
|
144
144
|
|
|
145
145
|
// Disable reason: Semantic queries can’t reach the overlay.
|
|
146
146
|
// eslint-disable-next-line testing-library/no-node-access
|
|
147
|
-
await user.click( confirmDialog.parentElement );
|
|
147
|
+
await user.click( confirmDialog.parentElement! );
|
|
148
148
|
|
|
149
149
|
expect( confirmDialog ).not.toBeInTheDocument();
|
|
150
150
|
expect( onCancel ).toHaveBeenCalled();
|
|
@@ -325,7 +325,7 @@ describe( 'Confirm', () => {
|
|
|
325
325
|
|
|
326
326
|
// Disable reason: Semantic queries can’t reach the overlay.
|
|
327
327
|
// eslint-disable-next-line testing-library/no-node-access
|
|
328
|
-
await user.click( confirmDialog.parentElement );
|
|
328
|
+
await user.click( confirmDialog.parentElement! );
|
|
329
329
|
|
|
330
330
|
expect( onCancel ).toHaveBeenCalled();
|
|
331
331
|
} );
|
|
@@ -13,21 +13,41 @@ export type DialogInputEvent =
|
|
|
13
13
|
| KeyboardEvent< HTMLDivElement >
|
|
14
14
|
| MouseEvent< HTMLButtonElement >;
|
|
15
15
|
|
|
16
|
-
type
|
|
16
|
+
export type ConfirmDialogProps = {
|
|
17
|
+
/**
|
|
18
|
+
* The actual message for the dialog. It's passed as children and any valid `ReactNode` is accepted.
|
|
19
|
+
*/
|
|
17
20
|
children: ReactNode;
|
|
21
|
+
/**
|
|
22
|
+
* The callback that's called when the user confirms.
|
|
23
|
+
* A confirmation can happen when the `OK` button is clicked or when `Enter` is pressed.
|
|
24
|
+
*/
|
|
18
25
|
onConfirm: ( event: DialogInputEvent ) => void;
|
|
26
|
+
/**
|
|
27
|
+
* The optional custom text to display as the confirmation button's label.
|
|
28
|
+
*/
|
|
19
29
|
confirmButtonText?: string;
|
|
30
|
+
/**
|
|
31
|
+
* The optional custom text to display as the cancellation button's label.
|
|
32
|
+
*/
|
|
20
33
|
cancelButtonText?: string;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
34
|
+
/**
|
|
35
|
+
* The callback that's called when the user cancels. A cancellation can happen
|
|
36
|
+
* when the `Cancel` button is clicked, when the `ESC` key is pressed, or when
|
|
37
|
+
* a click outside of the dialog focus is detected (i.e. in the overlay).
|
|
38
|
+
*
|
|
39
|
+
* It's not required if `isOpen` is not set (uncontrolled mode), as the component
|
|
40
|
+
* will take care of closing itself, but you can still pass a callback if something
|
|
41
|
+
* must be done upon cancelling (the component will still close itself in this case).
|
|
42
|
+
*
|
|
43
|
+
* If `isOpen` is set (controlled mode), then it's required, and you need to set
|
|
44
|
+
* the state that defines `isOpen` to `false` as part of this callback if you want the
|
|
45
|
+
* dialog to close when the user cancels.
|
|
46
|
+
*/
|
|
29
47
|
onCancel?: ( event: DialogInputEvent ) => void;
|
|
30
|
-
|
|
48
|
+
/**
|
|
49
|
+
* Defines if the dialog is open (displayed) or closed (not rendered/displayed).
|
|
50
|
+
* It also implicitly toggles the controlled mode if set or the uncontrolled mode if it's not set.
|
|
51
|
+
*/
|
|
52
|
+
isOpen?: boolean;
|
|
31
53
|
};
|
|
32
|
-
|
|
33
|
-
export type OwnProps = ControlledProps | UncontrolledProps;
|
|
@@ -42,6 +42,7 @@ import type {
|
|
|
42
42
|
InsertPointProps,
|
|
43
43
|
} from '../types';
|
|
44
44
|
import type { CustomColorPickerDropdownProps } from '../../color-palette/types';
|
|
45
|
+
import DropdownContentWrapper from '../../dropdown/dropdown-content-wrapper';
|
|
45
46
|
|
|
46
47
|
function ControlPointButton( {
|
|
47
48
|
isOpen,
|
|
@@ -93,6 +94,10 @@ function GradientColorPickerDropdown( {
|
|
|
93
94
|
( {
|
|
94
95
|
placement: 'bottom',
|
|
95
96
|
offset: 8,
|
|
97
|
+
// Disabling resize as it would otherwise cause the popover to show
|
|
98
|
+
// scrollbars while dragging the color picker's handle close to the
|
|
99
|
+
// popover edge.
|
|
100
|
+
resize: false,
|
|
96
101
|
} ) as const,
|
|
97
102
|
[]
|
|
98
103
|
);
|
|
@@ -271,7 +276,7 @@ function ControlPoints( {
|
|
|
271
276
|
/>
|
|
272
277
|
) }
|
|
273
278
|
renderContent={ ( { onClose } ) => (
|
|
274
|
-
|
|
279
|
+
<DropdownContentWrapper paddingSize="none">
|
|
275
280
|
<ColorPicker
|
|
276
281
|
enableAlpha={ ! disableAlpha }
|
|
277
282
|
color={ point.color }
|
|
@@ -311,7 +316,7 @@ function ControlPoints( {
|
|
|
311
316
|
</Button>
|
|
312
317
|
</HStack>
|
|
313
318
|
) }
|
|
314
|
-
|
|
319
|
+
</DropdownContentWrapper>
|
|
315
320
|
) }
|
|
316
321
|
style={ {
|
|
317
322
|
left: `${ point.position }%`,
|
|
@@ -360,29 +365,31 @@ function InsertPoint( {
|
|
|
360
365
|
/>
|
|
361
366
|
) }
|
|
362
367
|
renderContent={ () => (
|
|
363
|
-
<
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
368
|
+
<DropdownContentWrapper paddingSize="none">
|
|
369
|
+
<ColorPicker
|
|
370
|
+
enableAlpha={ ! disableAlpha }
|
|
371
|
+
onChange={ ( color ) => {
|
|
372
|
+
if ( ! alreadyInsertedPoint ) {
|
|
373
|
+
onChange(
|
|
374
|
+
addControlPoint(
|
|
375
|
+
controlPoints,
|
|
376
|
+
insertPosition,
|
|
377
|
+
colord( color ).toRgbString()
|
|
378
|
+
)
|
|
379
|
+
);
|
|
380
|
+
setAlreadyInsertedPoint( true );
|
|
381
|
+
} else {
|
|
382
|
+
onChange(
|
|
383
|
+
updateControlPointColorByPosition(
|
|
384
|
+
controlPoints,
|
|
385
|
+
insertPosition,
|
|
386
|
+
colord( color ).toRgbString()
|
|
387
|
+
)
|
|
388
|
+
);
|
|
389
|
+
}
|
|
390
|
+
} }
|
|
391
|
+
/>
|
|
392
|
+
</DropdownContentWrapper>
|
|
386
393
|
) }
|
|
387
394
|
style={
|
|
388
395
|
insertPosition !== null
|
|
@@ -119,8 +119,8 @@ exports[`DimensionControl rendering renders with custom sizes 1`] = `
|
|
|
119
119
|
white-space: nowrap;
|
|
120
120
|
text-overflow: ellipsis;
|
|
121
121
|
font-size: 16px;
|
|
122
|
-
height:
|
|
123
|
-
min-height:
|
|
122
|
+
height: 32px;
|
|
123
|
+
min-height: 32px;
|
|
124
124
|
padding-top: 0;
|
|
125
125
|
padding-bottom: 0;
|
|
126
126
|
padding-left: 8px;
|
|
@@ -390,8 +390,8 @@ exports[`DimensionControl rendering renders with defaults 1`] = `
|
|
|
390
390
|
white-space: nowrap;
|
|
391
391
|
text-overflow: ellipsis;
|
|
392
392
|
font-size: 16px;
|
|
393
|
-
height:
|
|
394
|
-
min-height:
|
|
393
|
+
height: 32px;
|
|
394
|
+
min-height: 32px;
|
|
395
395
|
padding-top: 0;
|
|
396
396
|
padding-bottom: 0;
|
|
397
397
|
padding-left: 8px;
|
|
@@ -671,8 +671,8 @@ exports[`DimensionControl rendering renders with icon and custom icon label 1`]
|
|
|
671
671
|
white-space: nowrap;
|
|
672
672
|
text-overflow: ellipsis;
|
|
673
673
|
font-size: 16px;
|
|
674
|
-
height:
|
|
675
|
-
min-height:
|
|
674
|
+
height: 32px;
|
|
675
|
+
min-height: 32px;
|
|
676
676
|
padding-top: 0;
|
|
677
677
|
padding-bottom: 0;
|
|
678
678
|
padding-left: 8px;
|
|
@@ -964,8 +964,8 @@ exports[`DimensionControl rendering renders with icon and default icon label 1`]
|
|
|
964
964
|
white-space: nowrap;
|
|
965
965
|
text-overflow: ellipsis;
|
|
966
966
|
font-size: 16px;
|
|
967
|
-
height:
|
|
968
|
-
min-height:
|
|
967
|
+
height: 32px;
|
|
968
|
+
min-height: 32px;
|
|
969
969
|
padding-top: 0;
|
|
970
970
|
padding-bottom: 0;
|
|
971
971
|
padding-left: 8px;
|