@wordpress/components 32.5.2-next.v.202604091042.0 → 33.0.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 +46 -1
- package/build/alignment-matrix-control/cell.cjs +3 -3
- package/build/alignment-matrix-control/cell.cjs.map +2 -2
- package/build/alignment-matrix-control/index.cjs +3 -3
- package/build/alignment-matrix-control/index.cjs.map +2 -2
- package/build/autocomplete/get-autocomplete-match.cjs +11 -2
- package/build/autocomplete/get-autocomplete-match.cjs.map +2 -2
- package/build/autocomplete/index.cjs +42 -11
- package/build/autocomplete/index.cjs.map +2 -2
- package/build/custom-gradient-picker/index.cjs.map +2 -2
- package/build/date-time/{date → date-picker}/index.cjs +6 -6
- package/build/date-time/{date → date-picker}/index.cjs.map +2 -2
- package/build/date-time/{date → date-picker}/styles.cjs +17 -17
- package/build/date-time/{date → date-picker}/styles.cjs.map +2 -2
- package/build/date-time/{date → date-picker}/use-lilius/index.cjs +1 -1
- package/build/date-time/{date → date-picker}/use-lilius/index.cjs.map +1 -1
- package/build/date-time/date-time/index.cjs +6 -6
- package/build/date-time/date-time/index.cjs.map +2 -2
- package/build/date-time/index.cjs +4 -4
- package/build/date-time/index.cjs.map +2 -2
- package/build/date-time/{time → time-picker}/index.cjs +6 -6
- package/build/date-time/time-picker/index.cjs.map +7 -0
- package/build/date-time/{time → time-picker}/styles.cjs +21 -21
- package/build/date-time/{time → time-picker}/styles.cjs.map +2 -2
- package/build/date-time/{time → time-picker}/time-input/index.cjs +1 -1
- package/build/date-time/{time → time-picker}/time-input/index.cjs.map +1 -1
- package/build/date-time/{time → time-picker}/timezone.cjs +1 -1
- package/build/date-time/{time → time-picker}/timezone.cjs.map +1 -1
- package/build/external-link/index.cjs +1 -1
- package/build/external-link/index.cjs.map +2 -2
- package/build/form-token-field/index.cjs +22 -6
- package/build/form-token-field/index.cjs.map +3 -3
- package/build/form-token-field/token-input.cjs +1 -1
- package/build/form-token-field/token-input.cjs.map +2 -2
- package/build/menu/popover.cjs +7 -3
- package/build/menu/popover.cjs.map +2 -2
- package/build/menu/styles.cjs +39 -16
- package/build/menu/styles.cjs.map +2 -2
- package/build/modal/index.cjs.map +2 -2
- package/build/navigable-container/container.cjs +72 -110
- package/build/navigable-container/container.cjs.map +2 -2
- package/build/palette-edit/index.cjs.map +2 -2
- package/build/radio-control/index.cjs +2 -0
- package/build/radio-control/index.cjs.map +2 -2
- package/build/sandbox/index.cjs +125 -1
- package/build/sandbox/index.cjs.map +2 -2
- package/build/textarea-control/styles/textarea-control-styles.cjs +3 -3
- package/build/textarea-control/styles/textarea-control-styles.cjs.map +2 -2
- package/build/utils/breakpoint.cjs.map +1 -1
- package/build/utils/font.cjs.map +1 -1
- package/build/visually-hidden/component.cjs +1 -0
- package/build/visually-hidden/component.cjs.map +2 -2
- package/build-module/alignment-matrix-control/cell.mjs +3 -3
- package/build-module/alignment-matrix-control/cell.mjs.map +2 -2
- package/build-module/alignment-matrix-control/index.mjs +3 -3
- package/build-module/alignment-matrix-control/index.mjs.map +2 -2
- package/build-module/autocomplete/get-autocomplete-match.mjs +11 -2
- package/build-module/autocomplete/get-autocomplete-match.mjs.map +2 -2
- package/build-module/autocomplete/index.mjs +42 -11
- package/build-module/autocomplete/index.mjs.map +2 -2
- package/build-module/custom-gradient-picker/index.mjs.map +2 -2
- package/build-module/date-time/{date → date-picker}/index.mjs +3 -3
- package/build-module/date-time/{date → date-picker}/index.mjs.map +2 -2
- package/build-module/date-time/{date → date-picker}/styles.mjs +17 -17
- package/build-module/date-time/{date → date-picker}/styles.mjs.map +2 -2
- package/build-module/date-time/{date → date-picker}/use-lilius/index.mjs +1 -1
- package/build-module/date-time/{date → date-picker}/use-lilius/index.mjs.map +1 -1
- package/build-module/date-time/date-time/index.mjs +2 -2
- package/build-module/date-time/date-time/index.mjs.map +1 -1
- package/build-module/date-time/index.mjs +2 -2
- package/build-module/date-time/index.mjs.map +1 -1
- package/build-module/date-time/{time → time-picker}/index.mjs +3 -3
- package/build-module/date-time/time-picker/index.mjs.map +7 -0
- package/build-module/date-time/{time → time-picker}/styles.mjs +21 -21
- package/build-module/date-time/{time → time-picker}/styles.mjs.map +2 -2
- package/build-module/date-time/{time → time-picker}/time-input/index.mjs +1 -1
- package/build-module/date-time/{time → time-picker}/time-input/index.mjs.map +1 -1
- package/build-module/date-time/{time → time-picker}/timezone.mjs +1 -1
- package/build-module/date-time/{time → time-picker}/timezone.mjs.map +1 -1
- package/build-module/external-link/index.mjs +1 -1
- package/build-module/external-link/index.mjs.map +2 -2
- package/build-module/form-token-field/index.mjs +22 -6
- package/build-module/form-token-field/index.mjs.map +2 -2
- package/build-module/form-token-field/token-input.mjs +1 -1
- package/build-module/form-token-field/token-input.mjs.map +2 -2
- package/build-module/menu/popover.mjs +7 -3
- package/build-module/menu/popover.mjs.map +2 -2
- package/build-module/menu/styles.mjs +37 -16
- package/build-module/menu/styles.mjs.map +2 -2
- package/build-module/modal/index.mjs.map +2 -2
- package/build-module/navigable-container/container.mjs +73 -111
- package/build-module/navigable-container/container.mjs.map +2 -2
- package/build-module/palette-edit/index.mjs.map +2 -2
- package/build-module/radio-control/index.mjs +2 -0
- package/build-module/radio-control/index.mjs.map +2 -2
- package/build-module/sandbox/index.mjs +126 -2
- package/build-module/sandbox/index.mjs.map +2 -2
- package/build-module/textarea-control/styles/textarea-control-styles.mjs +3 -3
- package/build-module/textarea-control/styles/textarea-control-styles.mjs.map +2 -2
- package/build-module/utils/breakpoint.mjs.map +1 -1
- package/build-module/utils/font.mjs.map +1 -1
- package/build-module/visually-hidden/component.mjs +1 -0
- package/build-module/visually-hidden/component.mjs.map +2 -2
- package/build-style/style-rtl.css +109 -25
- package/build-style/style.css +109 -25
- package/build-types/autocomplete/get-autocomplete-match.d.ts +10 -1
- package/build-types/autocomplete/get-autocomplete-match.d.ts.map +1 -1
- package/build-types/autocomplete/index.d.ts.map +1 -1
- package/build-types/base-control/stories/index.story.d.ts.map +1 -1
- package/build-types/button/stories/index.story.d.ts.map +1 -1
- package/build-types/card/stories/index.story.d.ts +0 -6
- package/build-types/card/stories/index.story.d.ts.map +1 -1
- package/build-types/checkbox-control/stories/index.story.d.ts.map +1 -1
- package/build-types/checkbox-control/types.d.ts +4 -0
- package/build-types/checkbox-control/types.d.ts.map +1 -1
- package/build-types/color-indicator/stories/index.story.d.ts.map +1 -1
- package/build-types/color-palette/stories/index.story.d.ts.map +1 -1
- package/build-types/color-picker/stories/index.story.d.ts.map +1 -1
- package/build-types/combobox-control/stories/index.story.d.ts.map +1 -1
- package/build-types/composite/stories/index.story.d.ts.map +1 -1
- package/build-types/custom-gradient-picker/index.d.ts.map +1 -1
- package/build-types/custom-select-control/stories/index.story.d.ts.map +1 -1
- package/build-types/date-time/date-picker/index.d.ts.map +1 -0
- package/build-types/date-time/date-picker/styles.d.ts.map +1 -0
- package/build-types/date-time/date-picker/test/index.d.ts.map +1 -0
- package/build-types/date-time/date-picker/test/use-lilius.d.ts.map +1 -0
- package/build-types/date-time/date-picker/use-lilius/index.d.ts.map +1 -0
- package/build-types/date-time/date-time/index.d.ts +2 -2
- package/build-types/date-time/date-time/index.d.ts.map +1 -1
- package/build-types/date-time/index.d.ts +2 -2
- package/build-types/date-time/index.d.ts.map +1 -1
- package/build-types/date-time/stories/date.story.d.ts +1 -1
- package/build-types/date-time/stories/date.story.d.ts.map +1 -1
- package/build-types/date-time/stories/time.story.d.ts +1 -1
- package/build-types/date-time/stories/time.story.d.ts.map +1 -1
- package/build-types/date-time/{time → time-picker}/index.d.ts +1 -1
- package/build-types/date-time/time-picker/index.d.ts.map +1 -0
- package/build-types/date-time/time-picker/styles.d.ts.map +1 -0
- package/build-types/date-time/time-picker/test/index.d.ts.map +1 -0
- package/build-types/date-time/time-picker/time-input/index.d.ts.map +1 -0
- package/build-types/date-time/time-picker/time-input/test/index.d.ts.map +1 -0
- package/build-types/date-time/time-picker/timezone.d.ts.map +1 -0
- package/build-types/date-time/types.d.ts +1 -1
- package/build-types/date-time/types.d.ts.map +1 -1
- package/build-types/disabled/stories/index.story.d.ts.map +1 -1
- package/build-types/drop-zone/stories/index.story.d.ts.map +1 -1
- package/build-types/dropdown/stories/index.story.d.ts.map +1 -1
- package/build-types/external-link/index.d.ts.map +1 -1
- package/build-types/external-link/stories/index.story.d.ts.map +1 -1
- package/build-types/form-file-upload/stories/index.story.d.ts.map +1 -1
- package/build-types/form-toggle/stories/index.story.d.ts.map +1 -1
- package/build-types/form-token-field/index.d.ts.map +1 -1
- package/build-types/form-token-field/stories/index.story.d.ts.map +1 -1
- package/build-types/form-token-field/token-input.d.ts.map +1 -1
- package/build-types/form-token-field/types.d.ts +16 -2
- package/build-types/form-token-field/types.d.ts.map +1 -1
- package/build-types/gradient-picker/stories/index.story.d.ts.map +1 -1
- package/build-types/icon/stories/index.story.d.ts.map +1 -1
- package/build-types/keyboard-shortcuts/stories/index.story.d.ts.map +1 -1
- package/build-types/menu/popover.d.ts.map +1 -1
- package/build-types/menu/styles.d.ts +16 -1
- package/build-types/menu/styles.d.ts.map +1 -1
- package/build-types/menu-group/stories/index.story.d.ts.map +1 -1
- package/build-types/menu-item/stories/index.story.d.ts.map +1 -1
- package/build-types/menu-items-choice/stories/index.story.d.ts.map +1 -1
- package/build-types/modal/index.d.ts.map +1 -1
- package/build-types/modal/stories/index.story.d.ts.map +1 -1
- package/build-types/navigable-container/container.d.ts +3 -8
- package/build-types/navigable-container/container.d.ts.map +1 -1
- package/build-types/navigable-container/types.d.ts +1 -5
- package/build-types/navigable-container/types.d.ts.map +1 -1
- package/build-types/navigation/stories/utils/more-examples.d.ts.map +1 -1
- package/build-types/navigator/stories/index.story.d.ts.map +1 -1
- package/build-types/notice/stories/index.story.d.ts.map +1 -1
- package/build-types/palette-edit/index.d.ts.map +1 -1
- package/build-types/panel/stories/index.story.d.ts.map +1 -1
- package/build-types/popover/stories/index.story.d.ts.map +1 -1
- package/build-types/progress-bar/stories/index.story.d.ts.map +1 -1
- package/build-types/radio-control/index.d.ts.map +1 -1
- package/build-types/radio-control/stories/index.story.d.ts.map +1 -1
- package/build-types/radio-control/types.d.ts +6 -0
- package/build-types/radio-control/types.d.ts.map +1 -1
- package/build-types/range-control/stories/index.story.d.ts.map +1 -1
- package/build-types/resizable-box/stories/index.story.d.ts.map +1 -1
- package/build-types/sandbox/index.d.ts +1 -1
- package/build-types/sandbox/index.d.ts.map +1 -1
- package/build-types/sandbox/stories/index.story.d.ts.map +1 -1
- package/build-types/sandbox/types.d.ts +11 -0
- package/build-types/sandbox/types.d.ts.map +1 -1
- package/build-types/scroll-lock/stories/index.story.d.ts.map +1 -1
- package/build-types/search-control/stories/index.story.d.ts.map +1 -1
- package/build-types/select-control/stories/index.story.d.ts.map +1 -1
- package/build-types/shortcut/stories/index.story.d.ts.map +1 -1
- package/build-types/slot-fill/stories/index.story.d.ts.map +1 -1
- package/build-types/snackbar/stories/index.story.d.ts.map +1 -1
- package/build-types/spinner/stories/index.story.d.ts.map +1 -1
- package/build-types/text-control/stories/index.story.d.ts.map +1 -1
- package/build-types/text-highlight/stories/index.story.d.ts.map +1 -1
- package/build-types/textarea-control/stories/index.story.d.ts.map +1 -1
- package/build-types/textarea-control/styles/textarea-control-styles.d.ts.map +1 -1
- package/build-types/toggle-control/stories/index.story.d.ts.map +1 -1
- package/build-types/tooltip/stories/index.story.d.ts.map +1 -1
- package/build-types/tree-select/stories/index.story.d.ts.map +1 -1
- package/build-types/utils/breakpoint.d.ts +2 -1
- package/build-types/utils/breakpoint.d.ts.map +1 -1
- package/build-types/utils/font.d.ts +3 -2
- package/build-types/utils/font.d.ts.map +1 -1
- package/build-types/validated-form-controls/components/checkbox-control.d.ts +2 -1
- package/build-types/validated-form-controls/components/checkbox-control.d.ts.map +1 -1
- package/build-types/validated-form-controls/components/radio-control.d.ts +2 -1
- package/build-types/validated-form-controls/components/radio-control.d.ts.map +1 -1
- package/build-types/visually-hidden/component.d.ts.map +1 -1
- package/build-types/visually-hidden/stories/index.story.d.ts +0 -6
- package/build-types/visually-hidden/stories/index.story.d.ts.map +1 -1
- package/package.json +21 -21
- package/src/alignment-matrix-control/style.module.scss +1 -1
- package/src/autocomplete/get-autocomplete-match.ts +25 -4
- package/src/autocomplete/index.tsx +69 -21
- package/src/autocomplete/test/get-autocomplete-match.ts +97 -75
- package/src/base-control/stories/index.story.tsx +1 -0
- package/src/button/stories/index.story.tsx +1 -0
- package/src/button/style.scss +1 -1
- package/src/button-group/style.scss +1 -2
- package/src/calendar/style.scss +3 -3
- package/src/card/stories/index.story.tsx +2 -9
- package/src/checkbox-control/stories/index.story.tsx +1 -0
- package/src/checkbox-control/style.scss +17 -5
- package/src/checkbox-control/types.ts +4 -0
- package/src/circular-option-picker/style.scss +9 -7
- package/src/color-indicator/stories/index.story.tsx +1 -0
- package/src/color-palette/stories/index.story.tsx +1 -0
- package/src/color-palette/style.scss +1 -1
- package/src/color-picker/stories/index.story.tsx +1 -0
- package/src/combobox-control/stories/index.story.tsx +1 -0
- package/src/composite/stories/index.story.tsx +1 -0
- package/src/confirm-dialog/stories/index.story.tsx +1 -1
- package/src/css.d.ts +1 -0
- package/src/custom-gradient-picker/index.tsx +1 -0
- package/src/custom-select-control/stories/index.story.tsx +1 -0
- package/src/date-time/README.md +3 -3
- package/src/date-time/date-picker/README.md +65 -0
- package/src/date-time/date-time/index.tsx +2 -2
- package/src/date-time/index.ts +2 -2
- package/src/date-time/stories/date.story.tsx +1 -1
- package/src/date-time/stories/time.story.tsx +1 -1
- package/src/date-time/time-picker/README.md +119 -0
- package/src/date-time/{time → time-picker}/index.tsx +1 -1
- package/src/date-time/types.ts +1 -1
- package/src/disabled/stories/index.story.tsx +1 -0
- package/src/drop-zone/stories/index.story.tsx +1 -0
- package/src/dropdown/stories/index.story.tsx +1 -0
- package/src/dropdown-menu/style.scss +1 -1
- package/src/external-link/index.tsx +1 -6
- package/src/external-link/stories/index.story.tsx +2 -1
- package/src/external-link/style.scss +30 -2
- package/src/form-file-upload/stories/index.story.tsx +1 -0
- package/src/form-toggle/stories/index.story.tsx +1 -0
- package/src/form-toggle/style.scss +38 -4
- package/src/form-token-field/README.md +2 -1
- package/src/form-token-field/index.tsx +39 -9
- package/src/form-token-field/stories/index.story.tsx +2 -0
- package/src/form-token-field/style.scss +12 -3
- package/src/form-token-field/test/index.tsx +70 -10
- package/src/form-token-field/token-input.tsx +1 -6
- package/src/form-token-field/types.ts +16 -2
- package/src/gradient-picker/stories/index.story.tsx +1 -0
- package/src/icon/stories/index.story.tsx +1 -0
- package/src/input-control/stories/index.story.tsx +1 -1
- package/src/item-group/stories/index.story.tsx +1 -1
- package/src/keyboard-shortcuts/stories/index.story.tsx +1 -0
- package/src/menu/popover.tsx +15 -8
- package/src/menu/styles.ts +26 -16
- package/src/menu/test/index.tsx +24 -34
- package/src/menu-group/stories/index.story.tsx +1 -0
- package/src/menu-item/stories/index.story.tsx +1 -0
- package/src/menu-items-choice/stories/index.story.tsx +1 -0
- package/src/mobile/link-settings/index.native.js +1 -1
- package/src/modal/index.tsx +1 -0
- package/src/modal/stories/index.story.tsx +1 -0
- package/src/navigable-container/container.tsx +120 -141
- package/src/navigable-container/test/navigable-menu.tsx +24 -0
- package/src/navigable-container/types.ts +1 -5
- package/src/navigation/stories/utils/more-examples.tsx +2 -1
- package/src/navigator/stories/index.story.tsx +1 -0
- package/src/notice/stories/index.story.tsx +1 -0
- package/src/notice/test/__snapshots__/index.tsx.snap +1 -0
- package/src/number-control/stories/index.story.tsx +1 -1
- package/src/palette-edit/index.tsx +1 -0
- package/src/panel/stories/index.story.tsx +1 -0
- package/src/popover/stories/index.story.tsx +1 -0
- package/src/progress-bar/stories/index.story.tsx +1 -0
- package/src/radio-control/index.tsx +2 -0
- package/src/radio-control/stories/index.story.tsx +1 -0
- package/src/radio-control/style.scss +21 -2
- package/src/radio-control/test/index.tsx +10 -0
- package/src/radio-control/types.ts +6 -0
- package/src/range-control/stories/index.story.tsx +1 -0
- package/src/resizable-box/stories/index.story.tsx +1 -0
- package/src/resizable-box/style.scss +4 -5
- package/src/sandbox/index.tsx +189 -9
- package/src/sandbox/stories/index.story.tsx +1 -0
- package/src/sandbox/test/index.tsx +65 -24
- package/src/sandbox/types.ts +11 -0
- package/src/scroll-lock/stories/index.story.tsx +1 -0
- package/src/search-control/stories/index.story.tsx +1 -0
- package/src/select-control/stories/index.story.tsx +1 -0
- package/src/shortcut/stories/index.story.tsx +1 -0
- package/src/slot-fill/stories/index.story.tsx +1 -0
- package/src/snackbar/stories/index.story.tsx +1 -0
- package/src/snackbar/style.scss +2 -2
- package/src/spinner/stories/index.story.tsx +1 -0
- package/src/tab-panel/style.scss +1 -1
- package/src/text-control/stories/index.story.tsx +1 -0
- package/src/text-highlight/stories/index.story.tsx +1 -0
- package/src/textarea-control/stories/index.story.tsx +4 -0
- package/src/textarea-control/styles/textarea-control-styles.ts +6 -0
- package/src/toggle-control/stories/index.story.tsx +1 -0
- package/src/toggle-control/style.scss +1 -1
- package/src/toggle-control/test/index.tsx +8 -2
- package/src/toggle-group-control/stories/index.story.tsx +1 -1
- package/src/toolbar/toolbar-group/index.tsx +2 -2
- package/src/tooltip/stories/index.story.tsx +1 -0
- package/src/tooltip/test/index.tsx +3 -2
- package/src/tree-grid/stories/index.story.tsx +1 -1
- package/src/tree-select/stories/index.story.tsx +1 -0
- package/src/truncate/stories/index.story.tsx +1 -1
- package/src/unit-control/stories/index.story.tsx +1 -1
- package/src/utils/breakpoint.js +1 -1
- package/src/utils/font.js +1 -1
- package/src/visually-hidden/component.tsx +1 -0
- package/src/visually-hidden/stories/index.story.tsx +2 -8
- package/build/card/context.cjs +0 -36
- package/build/card/context.cjs.map +0 -7
- package/build/date-time/time/index.cjs.map +0 -7
- package/build-module/card/context.mjs +0 -10
- package/build-module/card/context.mjs.map +0 -7
- package/build-module/date-time/time/index.mjs.map +0 -7
- package/build-types/card/context.d.ts +0 -3
- package/build-types/card/context.d.ts.map +0 -1
- package/build-types/date-time/date/index.d.ts.map +0 -1
- package/build-types/date-time/date/styles.d.ts.map +0 -1
- package/build-types/date-time/date/test/index.d.ts.map +0 -1
- package/build-types/date-time/date/test/use-lilius.d.ts.map +0 -1
- package/build-types/date-time/date/use-lilius/index.d.ts.map +0 -1
- package/build-types/date-time/time/index.d.ts.map +0 -1
- package/build-types/date-time/time/styles.d.ts.map +0 -1
- package/build-types/date-time/time/test/index.d.ts.map +0 -1
- package/build-types/date-time/time/time-input/index.d.ts.map +0 -1
- package/build-types/date-time/time/time-input/test/index.d.ts.map +0 -1
- package/build-types/date-time/time/timezone.d.ts.map +0 -1
- package/build-types/visually-hidden/test/index.d.ts +0 -2
- package/build-types/visually-hidden/test/index.d.ts.map +0 -1
- package/src/card/context.ts +0 -9
- package/src/visually-hidden/test/__snapshots__/index.tsx.snap +0 -12
- package/src/visually-hidden/test/index.tsx +0 -17
- /package/build-types/date-time/{date → date-picker}/index.d.ts +0 -0
- /package/build-types/date-time/{date → date-picker}/styles.d.ts +0 -0
- /package/build-types/date-time/{date → date-picker}/test/index.d.ts +0 -0
- /package/build-types/date-time/{date → date-picker}/test/use-lilius.d.ts +0 -0
- /package/build-types/date-time/{date → date-picker}/use-lilius/index.d.ts +0 -0
- /package/build-types/date-time/{time → time-picker}/styles.d.ts +0 -0
- /package/build-types/date-time/{time → time-picker}/test/index.d.ts +0 -0
- /package/build-types/date-time/{time → time-picker}/time-input/index.d.ts +0 -0
- /package/build-types/date-time/{time → time-picker}/time-input/test/index.d.ts +0 -0
- /package/build-types/date-time/{time → time-picker}/timezone.d.ts +0 -0
- /package/src/date-time/{date → date-picker}/index.tsx +0 -0
- /package/src/date-time/{date → date-picker}/styles.ts +0 -0
- /package/src/date-time/{date → date-picker}/test/index.tsx +0 -0
- /package/src/date-time/{date → date-picker}/test/use-lilius.ts +0 -0
- /package/src/date-time/{date → date-picker}/use-lilius/index.ts +0 -0
- /package/src/date-time/{time → time-picker}/styles.ts +0 -0
- /package/src/date-time/{time → time-picker}/test/index.tsx +0 -0
- /package/src/date-time/{time → time-picker}/time-input/index.tsx +0 -0
- /package/src/date-time/{time → time-picker}/time-input/test/index.tsx +0 -0
- /package/src/date-time/{time → time-picker}/timezone.tsx +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/modal/index.tsx"],
|
|
4
|
-
"sourcesContent": ["import clsx from 'clsx';\nimport { createPortal, useCallback, useEffect, useRef, useState, forwardRef, useLayoutEffect, useContext } from '@wordpress/element';\nimport { useInstanceId, useFocusReturn, useFocusOnMount, useConstrainedTabbing, useMergeRefs } from '@wordpress/compose';\nimport { __ } from '@wordpress/i18n';\nimport { close } from '@wordpress/icons';\nimport { getScrollContainer } from '@wordpress/dom';\nimport * as ariaHelper from './aria-helper';\nimport Button from '../button';\nimport StyleProvider from '../style-provider';\nimport { withIgnoreIMEEvents } from '../utils/with-ignore-ime-events';\nimport { Spacer } from '../spacer';\nimport { useModalExitAnimation } from './use-modal-exit-animation';\nimport { ModalContext } from './context';\n\n// Used to track body class names applied while modals are open.\nimport { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from \"react/jsx-runtime\";\nconst bodyOpenClasses = new Map();\nfunction UnforwardedModal(props, forwardedRef) {\n const {\n bodyOpenClassName = 'modal-open',\n role = 'dialog',\n title = null,\n focusOnMount = true,\n shouldCloseOnEsc = true,\n shouldCloseOnClickOutside = true,\n isDismissible = true,\n /* Accessibility. */\n aria = {\n labelledby: undefined,\n describedby: undefined\n },\n onRequestClose,\n icon,\n closeButtonLabel,\n children,\n style,\n overlayClassName: overlayClassnameProp,\n className,\n contentLabel,\n onKeyDown,\n isFullScreen = false,\n size,\n headerActions = null,\n __experimentalHideHeader = false\n } = props;\n const ref = useRef(null);\n const instanceId = useInstanceId(Modal);\n const headingId = title ? `components-modal-header-${instanceId}` : aria.labelledby;\n\n // The focus hook does not support 'firstContentElement' but this is a valid\n // value for the Modal's focusOnMount prop. The following code ensures the focus\n // hook will focus the first focusable node within the element to which it is applied.\n // When `firstContentElement` is passed as the value of the focusOnMount prop,\n // the focus hook is applied to the Modal's content element.\n // Otherwise, the focus hook is applied to the Modal's ref. This ensures that the\n // focus hook will focus the first element in the Modal's **content** when\n // `firstContentElement` is passed.\n const focusOnMountRef = useFocusOnMount(focusOnMount === 'firstContentElement' ? 'firstElement' : focusOnMount);\n const constrainedTabbingRef = useConstrainedTabbing();\n const focusReturnRef = useFocusReturn();\n const contentRef = useRef(null);\n const childrenContainerRef = useRef(null);\n const [hasScrolledContent, setHasScrolledContent] = useState(false);\n const [hasScrollableContent, setHasScrollableContent] = useState(false);\n let sizeClass;\n if (isFullScreen || size === 'fill') {\n sizeClass = 'is-full-screen';\n } else if (size) {\n sizeClass = `has-size-${size}`;\n }\n\n // Determines whether the Modal content is scrollable and updates the state.\n const isContentScrollable = useCallback(() => {\n if (!contentRef.current) {\n return;\n }\n const closestScrollContainer = getScrollContainer(contentRef.current);\n if (contentRef.current === closestScrollContainer) {\n setHasScrollableContent(true);\n } else {\n setHasScrollableContent(false);\n }\n }, [contentRef]);\n\n // Accessibly isolates/unisolates the modal.\n useEffect(() => {\n ariaHelper.modalize(ref.current);\n return () => ariaHelper.unmodalize();\n }, []);\n\n // Keeps a fresh ref for the subsequent effect.\n const onRequestCloseRef = useRef(undefined);\n useEffect(() => {\n onRequestCloseRef.current = onRequestClose;\n }, [onRequestClose]);\n\n // The list of `onRequestClose` callbacks of open (non-nested) Modals. Only\n // one should remain open at a time and the list enables closing prior ones.\n const dismissers = useContext(ModalContext);\n // Used for the tracking and dismissing any nested modals.\n const [nestedDismissers] = useState(() => new Set());\n\n // Updates the stack tracking open modals at this level and calls\n // onRequestClose for any prior and/or nested modals as applicable.\n useEffect(() => {\n // add this modal instance to the dismissers set\n dismissers.add(onRequestCloseRef);\n // request that all the other modals close themselves\n for (const dismisser of dismissers) {\n if (dismisser !== onRequestCloseRef) {\n dismisser.current?.();\n }\n }\n return () => {\n // request that all the nested modals close themselves\n for (const dismisser of nestedDismissers) {\n dismisser.current?.();\n }\n // remove this modal instance from the dismissers set\n dismissers.delete(onRequestCloseRef);\n };\n }, [dismissers, nestedDismissers]);\n\n // Adds/removes the value of bodyOpenClassName to body element.\n useEffect(() => {\n const theClass = bodyOpenClassName;\n const oneMore = 1 + (bodyOpenClasses.get(theClass) ?? 0);\n bodyOpenClasses.set(theClass, oneMore);\n document.body.classList.add(bodyOpenClassName);\n return () => {\n const oneLess = bodyOpenClasses.get(theClass) - 1;\n if (oneLess === 0) {\n document.body.classList.remove(theClass);\n bodyOpenClasses.delete(theClass);\n } else {\n bodyOpenClasses.set(theClass, oneLess);\n }\n };\n }, [bodyOpenClassName]);\n const {\n closeModal,\n frameRef,\n frameStyle,\n overlayClassname\n } = useModalExitAnimation();\n\n // Calls the isContentScrollable callback when the Modal children container resizes.\n useLayoutEffect(() => {\n if (!window.ResizeObserver || !childrenContainerRef.current) {\n return;\n }\n const resizeObserver = new ResizeObserver(isContentScrollable);\n resizeObserver.observe(childrenContainerRef.current);\n isContentScrollable();\n return () => {\n resizeObserver.disconnect();\n };\n }, [isContentScrollable, childrenContainerRef]);\n function handleEscapeKeyDown(event) {\n if (shouldCloseOnEsc && (event.code === 'Escape' || event.key === 'Escape') && !event.defaultPrevented) {\n event.preventDefault();\n closeModal().then(() => onRequestClose(event));\n }\n }\n const onContentContainerScroll = useCallback(e => {\n const scrollY = e?.currentTarget?.scrollTop ?? -1;\n if (!hasScrolledContent && scrollY > 0) {\n setHasScrolledContent(true);\n } else if (hasScrolledContent && scrollY <= 0) {\n setHasScrolledContent(false);\n }\n }, [hasScrolledContent]);\n let pressTarget = null;\n const overlayPressHandlers = {\n onPointerDown: event => {\n if (event.target === event.currentTarget) {\n pressTarget = event.target;\n // Avoids focus changing so that focus return works as expected.\n event.preventDefault();\n }\n },\n // Closes the modal with two exceptions. 1. Opening the context menu on\n // the overlay. 2. Pressing on the overlay then dragging the pointer\n // over the modal and releasing. Due to the modal being a child of the\n // overlay, such a gesture is a `click` on the overlay and cannot be\n // excepted by a `click` handler. Thus the tactic of handling\n // `pointerup` and comparing its target to that of the `pointerdown`.\n onPointerUp: ({\n target,\n button\n }) => {\n const isSameTarget = target === pressTarget;\n pressTarget = null;\n if (button === 0 && isSameTarget) {\n closeModal().then(() => onRequestClose());\n }\n }\n };\n const modal =\n /*#__PURE__*/\n // eslint-disable-next-line jsx-a11y/no-static-element-interactions\n _jsx(\"div\", {\n ref: useMergeRefs([ref, forwardedRef]),\n className: clsx('components-modal__screen-overlay', overlayClassname, overlayClassnameProp),\n onKeyDown: withIgnoreIMEEvents(handleEscapeKeyDown),\n ...(shouldCloseOnClickOutside ? overlayPressHandlers : {}),\n children: /*#__PURE__*/_jsx(StyleProvider, {\n document: document,\n children: /*#__PURE__*/_jsx(\"div\", {\n className: clsx('components-modal__frame', sizeClass, className),\n style: {\n ...frameStyle,\n ...style\n },\n ref: useMergeRefs([frameRef, constrainedTabbingRef, focusReturnRef, focusOnMount !== 'firstContentElement' ? focusOnMountRef : null]),\n role: role,\n \"aria-label\": contentLabel,\n \"aria-labelledby\": contentLabel ? undefined : headingId,\n \"aria-describedby\": aria.describedby,\n tabIndex: -1,\n onKeyDown: onKeyDown,\n children: /*#__PURE__*/_jsxs(\"div\", {\n className: clsx('components-modal__content', {\n 'hide-header': __experimentalHideHeader,\n 'is-scrollable': hasScrollableContent,\n 'has-scrolled-content': hasScrolledContent\n }),\n role: \"document\",\n onScroll: onContentContainerScroll,\n ref: contentRef,\n \"aria-label\": hasScrollableContent ? __('Scrollable section') : undefined,\n tabIndex: hasScrollableContent ? 0 : undefined,\n children: [!__experimentalHideHeader && /*#__PURE__*/_jsxs(\"div\", {\n className: \"components-modal__header\",\n children: [/*#__PURE__*/_jsxs(\"div\", {\n className: \"components-modal__header-heading-container\",\n children: [icon && /*#__PURE__*/_jsx(\"span\", {\n className: \"components-modal__icon-container\",\n \"aria-hidden\": true,\n children: icon\n }), title && /*#__PURE__*/_jsx(\"h1\", {\n id: headingId,\n className: \"components-modal__header-heading\",\n children: title\n })]\n }), headerActions, isDismissible && /*#__PURE__*/_jsxs(_Fragment, {\n children: [/*#__PURE__*/_jsx(Spacer, {\n marginBottom: 0,\n marginLeft: 2\n }), /*#__PURE__*/_jsx(Button, {\n size: \"compact\",\n onClick: event => closeModal().then(() => onRequestClose(event)),\n icon: close,\n label: closeButtonLabel || __('Close')\n })]\n })]\n }), /*#__PURE__*/_jsx(\"div\", {\n ref: useMergeRefs([childrenContainerRef, focusOnMount === 'firstContentElement' ? focusOnMountRef : null]),\n className: \"components-modal__children-container\",\n children: children\n })]\n })\n })\n })\n });\n return createPortal(/*#__PURE__*/_jsx(ModalContext.Provider, {\n value: nestedDismissers,\n children: modal\n }), document.body);\n}\n\n/**\n * Modals give users information and choices related to a task they\u2019re trying to\n * accomplish. They can contain critical information, require decisions, or\n * involve multiple tasks.\n *\n * ```jsx\n * import { Button, Modal } from '@wordpress/components';\n * import { useState } from '@wordpress/element';\n *\n * const MyModal = () => {\n * const [ isOpen, setOpen ] = useState( false );\n * const openModal = () => setOpen( true );\n * const closeModal = () => setOpen( false );\n *\n * return (\n * <>\n * <Button variant=\"secondary\" onClick={ openModal }>\n * Open Modal\n * </Button>\n * { isOpen && (\n * <Modal title=\"This is my modal\" onRequestClose={ closeModal }>\n * <Button variant=\"secondary\" onClick={ closeModal }>\n * My custom close button\n * </Button>\n * </Modal>\n * ) }\n * </>\n * );\n * };\n * ```\n */\nexport const Modal = forwardRef(UnforwardedModal);\nModal.displayName = 'Modal';\nexport default Modal;"],
|
|
5
|
-
"mappings": ";AAAA,OAAO,UAAU;AACjB,SAAS,cAAc,aAAa,WAAW,QAAQ,UAAU,YAAY,iBAAiB,kBAAkB;AAChH,SAAS,eAAe,gBAAgB,iBAAiB,uBAAuB,oBAAoB;AACpG,SAAS,UAAU;AACnB,SAAS,aAAa;AACtB,SAAS,0BAA0B;AACnC,YAAY,gBAAgB;AAC5B,OAAO,YAAY;AACnB,OAAO,mBAAmB;AAC1B,SAAS,2BAA2B;AACp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QAAI,WAAW,YAAY,wBAAwB;AACjD,8BAAwB,IAAI;AAAA,IAC9B,OAAO;AACL,8BAAwB,KAAK;AAAA,IAC/B;AAAA,EACF,GAAG,CAAC,UAAU,CAAC;AAGf,YAAU,MAAM;AACd,IAAW,oBAAS,IAAI,OAAO;AAC/B,WAAO,MAAiB,sBAAW;AAAA,EACrC,GAAG,CAAC,CAAC;AAGL,QAAM,oBAAoB,OAAO,MAAS;AAC1C,YAAU,MAAM;
|
|
4
|
+
"sourcesContent": ["import clsx from 'clsx';\nimport { createPortal, useCallback, useEffect, useRef, useState, forwardRef, useLayoutEffect, useContext } from '@wordpress/element';\nimport { useInstanceId, useFocusReturn, useFocusOnMount, useConstrainedTabbing, useMergeRefs } from '@wordpress/compose';\nimport { __ } from '@wordpress/i18n';\nimport { close } from '@wordpress/icons';\nimport { getScrollContainer } from '@wordpress/dom';\nimport * as ariaHelper from './aria-helper';\nimport Button from '../button';\nimport StyleProvider from '../style-provider';\nimport { withIgnoreIMEEvents } from '../utils/with-ignore-ime-events';\nimport { Spacer } from '../spacer';\nimport { useModalExitAnimation } from './use-modal-exit-animation';\nimport { ModalContext } from './context';\n\n// Used to track body class names applied while modals are open.\nimport { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from \"react/jsx-runtime\";\nconst bodyOpenClasses = new Map();\nfunction UnforwardedModal(props, forwardedRef) {\n const {\n bodyOpenClassName = 'modal-open',\n role = 'dialog',\n title = null,\n focusOnMount = true,\n shouldCloseOnEsc = true,\n shouldCloseOnClickOutside = true,\n isDismissible = true,\n /* Accessibility. */\n aria = {\n labelledby: undefined,\n describedby: undefined\n },\n onRequestClose,\n icon,\n closeButtonLabel,\n children,\n style,\n overlayClassName: overlayClassnameProp,\n className,\n contentLabel,\n onKeyDown,\n isFullScreen = false,\n size,\n headerActions = null,\n __experimentalHideHeader = false\n } = props;\n const ref = useRef(null);\n const instanceId = useInstanceId(Modal);\n const headingId = title ? `components-modal-header-${instanceId}` : aria.labelledby;\n\n // The focus hook does not support 'firstContentElement' but this is a valid\n // value for the Modal's focusOnMount prop. The following code ensures the focus\n // hook will focus the first focusable node within the element to which it is applied.\n // When `firstContentElement` is passed as the value of the focusOnMount prop,\n // the focus hook is applied to the Modal's content element.\n // Otherwise, the focus hook is applied to the Modal's ref. This ensures that the\n // focus hook will focus the first element in the Modal's **content** when\n // `firstContentElement` is passed.\n const focusOnMountRef = useFocusOnMount(focusOnMount === 'firstContentElement' ? 'firstElement' : focusOnMount);\n const constrainedTabbingRef = useConstrainedTabbing();\n const focusReturnRef = useFocusReturn();\n const contentRef = useRef(null);\n const childrenContainerRef = useRef(null);\n const [hasScrolledContent, setHasScrolledContent] = useState(false);\n const [hasScrollableContent, setHasScrollableContent] = useState(false);\n let sizeClass;\n if (isFullScreen || size === 'fill') {\n sizeClass = 'is-full-screen';\n } else if (size) {\n sizeClass = `has-size-${size}`;\n }\n\n // Determines whether the Modal content is scrollable and updates the state.\n const isContentScrollable = useCallback(() => {\n if (!contentRef.current) {\n return;\n }\n const closestScrollContainer = getScrollContainer(contentRef.current);\n if (contentRef.current === closestScrollContainer) {\n setHasScrollableContent(true);\n } else {\n setHasScrollableContent(false);\n }\n }, [contentRef]);\n\n // Accessibly isolates/unisolates the modal.\n useEffect(() => {\n ariaHelper.modalize(ref.current);\n return () => ariaHelper.unmodalize();\n }, []);\n\n // Keeps a fresh ref for the subsequent effect.\n const onRequestCloseRef = useRef(undefined);\n useEffect(() => {\n // eslint-disable-next-line react-compiler/react-compiler -- false positive, see https://github.com/facebook/react/issues/29196\n onRequestCloseRef.current = onRequestClose;\n }, [onRequestClose]);\n\n // The list of `onRequestClose` callbacks of open (non-nested) Modals. Only\n // one should remain open at a time and the list enables closing prior ones.\n const dismissers = useContext(ModalContext);\n // Used for the tracking and dismissing any nested modals.\n const [nestedDismissers] = useState(() => new Set());\n\n // Updates the stack tracking open modals at this level and calls\n // onRequestClose for any prior and/or nested modals as applicable.\n useEffect(() => {\n // add this modal instance to the dismissers set\n dismissers.add(onRequestCloseRef);\n // request that all the other modals close themselves\n for (const dismisser of dismissers) {\n if (dismisser !== onRequestCloseRef) {\n dismisser.current?.();\n }\n }\n return () => {\n // request that all the nested modals close themselves\n for (const dismisser of nestedDismissers) {\n dismisser.current?.();\n }\n // remove this modal instance from the dismissers set\n dismissers.delete(onRequestCloseRef);\n };\n }, [dismissers, nestedDismissers]);\n\n // Adds/removes the value of bodyOpenClassName to body element.\n useEffect(() => {\n const theClass = bodyOpenClassName;\n const oneMore = 1 + (bodyOpenClasses.get(theClass) ?? 0);\n bodyOpenClasses.set(theClass, oneMore);\n document.body.classList.add(bodyOpenClassName);\n return () => {\n const oneLess = bodyOpenClasses.get(theClass) - 1;\n if (oneLess === 0) {\n document.body.classList.remove(theClass);\n bodyOpenClasses.delete(theClass);\n } else {\n bodyOpenClasses.set(theClass, oneLess);\n }\n };\n }, [bodyOpenClassName]);\n const {\n closeModal,\n frameRef,\n frameStyle,\n overlayClassname\n } = useModalExitAnimation();\n\n // Calls the isContentScrollable callback when the Modal children container resizes.\n useLayoutEffect(() => {\n if (!window.ResizeObserver || !childrenContainerRef.current) {\n return;\n }\n const resizeObserver = new ResizeObserver(isContentScrollable);\n resizeObserver.observe(childrenContainerRef.current);\n isContentScrollable();\n return () => {\n resizeObserver.disconnect();\n };\n }, [isContentScrollable, childrenContainerRef]);\n function handleEscapeKeyDown(event) {\n if (shouldCloseOnEsc && (event.code === 'Escape' || event.key === 'Escape') && !event.defaultPrevented) {\n event.preventDefault();\n closeModal().then(() => onRequestClose(event));\n }\n }\n const onContentContainerScroll = useCallback(e => {\n const scrollY = e?.currentTarget?.scrollTop ?? -1;\n if (!hasScrolledContent && scrollY > 0) {\n setHasScrolledContent(true);\n } else if (hasScrolledContent && scrollY <= 0) {\n setHasScrolledContent(false);\n }\n }, [hasScrolledContent]);\n let pressTarget = null;\n const overlayPressHandlers = {\n onPointerDown: event => {\n if (event.target === event.currentTarget) {\n pressTarget = event.target;\n // Avoids focus changing so that focus return works as expected.\n event.preventDefault();\n }\n },\n // Closes the modal with two exceptions. 1. Opening the context menu on\n // the overlay. 2. Pressing on the overlay then dragging the pointer\n // over the modal and releasing. Due to the modal being a child of the\n // overlay, such a gesture is a `click` on the overlay and cannot be\n // excepted by a `click` handler. Thus the tactic of handling\n // `pointerup` and comparing its target to that of the `pointerdown`.\n onPointerUp: ({\n target,\n button\n }) => {\n const isSameTarget = target === pressTarget;\n pressTarget = null;\n if (button === 0 && isSameTarget) {\n closeModal().then(() => onRequestClose());\n }\n }\n };\n const modal =\n /*#__PURE__*/\n // eslint-disable-next-line jsx-a11y/no-static-element-interactions\n _jsx(\"div\", {\n ref: useMergeRefs([ref, forwardedRef]),\n className: clsx('components-modal__screen-overlay', overlayClassname, overlayClassnameProp),\n onKeyDown: withIgnoreIMEEvents(handleEscapeKeyDown),\n ...(shouldCloseOnClickOutside ? overlayPressHandlers : {}),\n children: /*#__PURE__*/_jsx(StyleProvider, {\n document: document,\n children: /*#__PURE__*/_jsx(\"div\", {\n className: clsx('components-modal__frame', sizeClass, className),\n style: {\n ...frameStyle,\n ...style\n },\n ref: useMergeRefs([frameRef, constrainedTabbingRef, focusReturnRef, focusOnMount !== 'firstContentElement' ? focusOnMountRef : null]),\n role: role,\n \"aria-label\": contentLabel,\n \"aria-labelledby\": contentLabel ? undefined : headingId,\n \"aria-describedby\": aria.describedby,\n tabIndex: -1,\n onKeyDown: onKeyDown,\n children: /*#__PURE__*/_jsxs(\"div\", {\n className: clsx('components-modal__content', {\n 'hide-header': __experimentalHideHeader,\n 'is-scrollable': hasScrollableContent,\n 'has-scrolled-content': hasScrolledContent\n }),\n role: \"document\",\n onScroll: onContentContainerScroll,\n ref: contentRef,\n \"aria-label\": hasScrollableContent ? __('Scrollable section') : undefined,\n tabIndex: hasScrollableContent ? 0 : undefined,\n children: [!__experimentalHideHeader && /*#__PURE__*/_jsxs(\"div\", {\n className: \"components-modal__header\",\n children: [/*#__PURE__*/_jsxs(\"div\", {\n className: \"components-modal__header-heading-container\",\n children: [icon && /*#__PURE__*/_jsx(\"span\", {\n className: \"components-modal__icon-container\",\n \"aria-hidden\": true,\n children: icon\n }), title && /*#__PURE__*/_jsx(\"h1\", {\n id: headingId,\n className: \"components-modal__header-heading\",\n children: title\n })]\n }), headerActions, isDismissible && /*#__PURE__*/_jsxs(_Fragment, {\n children: [/*#__PURE__*/_jsx(Spacer, {\n marginBottom: 0,\n marginLeft: 2\n }), /*#__PURE__*/_jsx(Button, {\n size: \"compact\",\n onClick: event => closeModal().then(() => onRequestClose(event)),\n icon: close,\n label: closeButtonLabel || __('Close')\n })]\n })]\n }), /*#__PURE__*/_jsx(\"div\", {\n ref: useMergeRefs([childrenContainerRef, focusOnMount === 'firstContentElement' ? focusOnMountRef : null]),\n className: \"components-modal__children-container\",\n children: children\n })]\n })\n })\n })\n });\n return createPortal(/*#__PURE__*/_jsx(ModalContext.Provider, {\n value: nestedDismissers,\n children: modal\n }), document.body);\n}\n\n/**\n * Modals give users information and choices related to a task they\u2019re trying to\n * accomplish. They can contain critical information, require decisions, or\n * involve multiple tasks.\n *\n * ```jsx\n * import { Button, Modal } from '@wordpress/components';\n * import { useState } from '@wordpress/element';\n *\n * const MyModal = () => {\n * const [ isOpen, setOpen ] = useState( false );\n * const openModal = () => setOpen( true );\n * const closeModal = () => setOpen( false );\n *\n * return (\n * <>\n * <Button variant=\"secondary\" onClick={ openModal }>\n * Open Modal\n * </Button>\n * { isOpen && (\n * <Modal title=\"This is my modal\" onRequestClose={ closeModal }>\n * <Button variant=\"secondary\" onClick={ closeModal }>\n * My custom close button\n * </Button>\n * </Modal>\n * ) }\n * </>\n * );\n * };\n * ```\n */\nexport const Modal = forwardRef(UnforwardedModal);\nModal.displayName = 'Modal';\nexport default Modal;"],
|
|
5
|
+
"mappings": ";AAAA,OAAO,UAAU;AACjB,SAAS,cAAc,aAAa,WAAW,QAAQ,UAAU,YAAY,iBAAiB,kBAAkB;AAChH,SAAS,eAAe,gBAAgB,iBAAi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AAA,kBACJ,WAAW;AAAA,kBACX,UAAU;AAAA,gBACZ,CAAC,CAAC;AAAA,cACJ,CAAC,GAAG,eAAe,iBAA8B,sBAAM,WAAW;AAAA,gBAChE,UAAU,CAAc,qBAAK,QAAQ;AAAA,kBACnC,cAAc;AAAA,kBACd,YAAY;AAAA,gBACd,CAAC,GAAgB,qBAAK,QAAQ;AAAA,kBAC5B,MAAM;AAAA,kBACN,SAAS,WAAS,WAAW,EAAE,KAAK,MAAM,eAAe,KAAK,CAAC;AAAA,kBAC/D,MAAM;AAAA,kBACN,OAAO,oBAAoB,GAAG,OAAO;AAAA,gBACvC,CAAC,CAAC;AAAA,cACJ,CAAC,CAAC;AAAA,YACJ,CAAC,GAAgB,qBAAK,OAAO;AAAA,cAC3B,KAAK,aAAa,CAAC,sBAAsB,iBAAiB,wBAAwB,kBAAkB,IAAI,CAAC;AAAA,cACzG,WAAW;AAAA,cACX;AAAA,YACF,CAAC,CAAC;AAAA,UACJ,CAAC;AAAA,QACH,CAAC;AAAA,MACH,CAAC;AAAA,IACH,CAAC;AAAA;AACD,SAAO,aAA0B,qBAAK,aAAa,UAAU;AAAA,IAC3D,OAAO;AAAA,IACP,UAAU;AAAA,EACZ,CAAC,GAAG,SAAS,IAAI;AACnB;AAiCO,IAAM,QAAQ,WAAW,gBAAgB;AAChD,MAAM,cAAc;AACpB,IAAO,gBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// packages/components/src/navigable-container/container.tsx
|
|
2
|
-
import {
|
|
2
|
+
import { forwardRef, useRef, useEffect, useCallback } from "@wordpress/element";
|
|
3
|
+
import { useMergeRefs } from "@wordpress/compose";
|
|
3
4
|
import { focus } from "@wordpress/dom";
|
|
4
5
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
6
|
var noop = () => {
|
|
@@ -14,47 +15,27 @@ function cycleValue(value, total, offset) {
|
|
|
14
15
|
}
|
|
15
16
|
return nextValue;
|
|
16
17
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
if (!
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
this.container.removeEventListener("keydown", this.onKeyDown);
|
|
36
|
-
}
|
|
37
|
-
bindContainer(ref) {
|
|
38
|
-
const {
|
|
39
|
-
forwardedRef
|
|
40
|
-
} = this.props;
|
|
41
|
-
this.container = ref;
|
|
42
|
-
if (typeof forwardedRef === "function") {
|
|
43
|
-
forwardedRef(ref);
|
|
44
|
-
} else if (forwardedRef && "current" in forwardedRef) {
|
|
45
|
-
forwardedRef.current = ref;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
getFocusableContext(target) {
|
|
49
|
-
if (!this.container) {
|
|
18
|
+
function UnforwardedNavigableContainer({
|
|
19
|
+
children,
|
|
20
|
+
stopNavigationEvents,
|
|
21
|
+
eventToOffset,
|
|
22
|
+
onNavigate = noop,
|
|
23
|
+
onKeyDown,
|
|
24
|
+
cycle = true,
|
|
25
|
+
onlyBrowserTabstops,
|
|
26
|
+
...restProps
|
|
27
|
+
}, ref) {
|
|
28
|
+
const containerRef = useRef(null);
|
|
29
|
+
const getFocusableIndex = useCallback((focusables, target) => {
|
|
30
|
+
return focusables.indexOf(target);
|
|
31
|
+
}, []);
|
|
32
|
+
const getFocusableContext = useCallback((target) => {
|
|
33
|
+
if (!containerRef.current) {
|
|
50
34
|
return null;
|
|
51
35
|
}
|
|
52
|
-
const {
|
|
53
|
-
onlyBrowserTabstops
|
|
54
|
-
} = this.props;
|
|
55
36
|
const finder = onlyBrowserTabstops ? focus.tabbable : focus.focusable;
|
|
56
|
-
const focusables = finder.find(
|
|
57
|
-
const index =
|
|
37
|
+
const focusables = finder.find(containerRef.current);
|
|
38
|
+
const index = getFocusableIndex(focusables, target);
|
|
58
39
|
if (index > -1 && target) {
|
|
59
40
|
return {
|
|
60
41
|
index,
|
|
@@ -63,83 +44,64 @@ var NavigableContainer = class extends Component {
|
|
|
63
44
|
};
|
|
64
45
|
}
|
|
65
46
|
return null;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
onKeyDown(event) {
|
|
71
|
-
if (this.props.onKeyDown) {
|
|
72
|
-
this.props.onKeyDown(event);
|
|
73
|
-
}
|
|
74
|
-
const {
|
|
75
|
-
getFocusableContext
|
|
76
|
-
} = this;
|
|
77
|
-
const {
|
|
78
|
-
cycle = true,
|
|
79
|
-
eventToOffset,
|
|
80
|
-
onNavigate = noop,
|
|
81
|
-
stopNavigationEvents
|
|
82
|
-
} = this.props;
|
|
83
|
-
const offset = eventToOffset(event);
|
|
84
|
-
if (offset !== void 0 && stopNavigationEvents) {
|
|
85
|
-
event.stopImmediatePropagation();
|
|
86
|
-
const targetRole = event.target?.getAttribute("role");
|
|
87
|
-
const targetHasMenuItemRole = !!targetRole && MENU_ITEM_ROLES.includes(targetRole);
|
|
88
|
-
if (targetHasMenuItemRole) {
|
|
89
|
-
event.preventDefault();
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
if (!offset) {
|
|
47
|
+
}, [onlyBrowserTabstops, getFocusableIndex]);
|
|
48
|
+
useEffect(() => {
|
|
49
|
+
const container = containerRef.current;
|
|
50
|
+
if (!container) {
|
|
93
51
|
return;
|
|
94
52
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
53
|
+
function handleKeyDown(event) {
|
|
54
|
+
if (onKeyDown) {
|
|
55
|
+
onKeyDown(event);
|
|
56
|
+
}
|
|
57
|
+
const offset = eventToOffset(event);
|
|
58
|
+
if (offset !== void 0 && stopNavigationEvents) {
|
|
59
|
+
event.stopImmediatePropagation();
|
|
60
|
+
const targetRole = event.target?.getAttribute("role");
|
|
61
|
+
const targetHasMenuItemRole = !!targetRole && MENU_ITEM_ROLES.includes(targetRole);
|
|
62
|
+
if (targetHasMenuItemRole) {
|
|
63
|
+
event.preventDefault();
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
if (!offset) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
const activeElement = event.target?.ownerDocument?.activeElement;
|
|
70
|
+
if (!activeElement) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
const context = getFocusableContext(activeElement);
|
|
74
|
+
if (!context) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
const {
|
|
78
|
+
index,
|
|
79
|
+
focusables
|
|
80
|
+
} = context;
|
|
81
|
+
const nextIndex = cycle ? cycleValue(index, focusables.length, offset) : index + offset;
|
|
82
|
+
if (nextIndex >= 0 && nextIndex < focusables.length) {
|
|
83
|
+
focusables[nextIndex].focus();
|
|
84
|
+
onNavigate(nextIndex, focusables[nextIndex]);
|
|
85
|
+
if (event.code === "Tab") {
|
|
86
|
+
event.preventDefault();
|
|
87
|
+
}
|
|
113
88
|
}
|
|
114
89
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
forwardedRef,
|
|
126
|
-
...restProps
|
|
127
|
-
} = this.props;
|
|
128
|
-
return /* @__PURE__ */ _jsx("div", {
|
|
129
|
-
ref: this.bindContainer,
|
|
130
|
-
...restProps,
|
|
131
|
-
children
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
};
|
|
135
|
-
var forwardedNavigableContainer = (props, ref) => {
|
|
136
|
-
return /* @__PURE__ */ _jsx(NavigableContainer, {
|
|
137
|
-
...props,
|
|
138
|
-
forwardedRef: ref
|
|
90
|
+
container.addEventListener("keydown", handleKeyDown);
|
|
91
|
+
return () => {
|
|
92
|
+
container.removeEventListener("keydown", handleKeyDown);
|
|
93
|
+
};
|
|
94
|
+
}, [onKeyDown, eventToOffset, stopNavigationEvents, cycle, onNavigate, getFocusableContext]);
|
|
95
|
+
const mergedRef = useMergeRefs([containerRef, ref]);
|
|
96
|
+
return /* @__PURE__ */ _jsx("div", {
|
|
97
|
+
ref: mergedRef,
|
|
98
|
+
...restProps,
|
|
99
|
+
children
|
|
139
100
|
});
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
|
|
101
|
+
}
|
|
102
|
+
var NavigableContainer = forwardRef(UnforwardedNavigableContainer);
|
|
103
|
+
NavigableContainer.displayName = "NavigableContainer";
|
|
104
|
+
var container_default = NavigableContainer;
|
|
143
105
|
export {
|
|
144
106
|
container_default as default
|
|
145
107
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/navigable-container/container.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\n\n/**\n * WordPress dependencies\n */\nimport {
|
|
5
|
-
"mappings": ";AAOA,SAAS,WAAW,
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\n\n/**\n * WordPress dependencies\n */\nimport { forwardRef, useRef, useEffect, useCallback } from '@wordpress/element';\nimport { useMergeRefs } from '@wordpress/compose';\nimport { focus } from '@wordpress/dom';\n\n/**\n * Internal dependencies\n */\nimport { jsx as _jsx } from \"react/jsx-runtime\";\nconst noop = () => {};\nconst MENU_ITEM_ROLES = ['menuitem', 'menuitemradio', 'menuitemcheckbox'];\nfunction cycleValue(value, total, offset) {\n const nextValue = value + offset;\n if (nextValue < 0) {\n return total + nextValue;\n } else if (nextValue >= total) {\n return nextValue - total;\n }\n return nextValue;\n}\nfunction UnforwardedNavigableContainer({\n children,\n stopNavigationEvents,\n eventToOffset,\n onNavigate = noop,\n onKeyDown,\n cycle = true,\n onlyBrowserTabstops,\n ...restProps\n}, ref) {\n const containerRef = useRef(null);\n const getFocusableIndex = useCallback((focusables, target) => {\n return focusables.indexOf(target);\n }, []);\n const getFocusableContext = useCallback(target => {\n if (!containerRef.current) {\n return null;\n }\n const finder = onlyBrowserTabstops ? focus.tabbable : focus.focusable;\n const focusables = finder.find(containerRef.current);\n const index = getFocusableIndex(focusables, target);\n if (index > -1 && target) {\n return {\n index,\n target,\n focusables\n };\n }\n return null;\n }, [onlyBrowserTabstops, getFocusableIndex]);\n useEffect(() => {\n const container = containerRef.current;\n if (!container) {\n return;\n }\n function handleKeyDown(event) {\n if (onKeyDown) {\n onKeyDown(event);\n }\n const offset = eventToOffset(event);\n\n // eventToOffset returns undefined if the event is not handled by the component.\n if (offset !== undefined && stopNavigationEvents) {\n // Prevents arrow key handlers bound to the document directly interfering.\n event.stopImmediatePropagation();\n\n // When navigating a collection of items, prevent scroll containers\n // from scrolling. The preventDefault also prevents Voiceover from\n // 'handling' the event, as voiceover will try to use arrow keys\n // for highlighting text.\n const targetRole = event.target?.getAttribute('role');\n const targetHasMenuItemRole = !!targetRole && MENU_ITEM_ROLES.includes(targetRole);\n if (targetHasMenuItemRole) {\n event.preventDefault();\n }\n }\n if (!offset) {\n return;\n }\n const activeElement = event.target?.ownerDocument?.activeElement;\n if (!activeElement) {\n return;\n }\n const context = getFocusableContext(activeElement);\n if (!context) {\n return;\n }\n const {\n index,\n focusables\n } = context;\n const nextIndex = cycle ? cycleValue(index, focusables.length, offset) : index + offset;\n if (nextIndex >= 0 && nextIndex < focusables.length) {\n focusables[nextIndex].focus();\n onNavigate(nextIndex, focusables[nextIndex]);\n\n // `preventDefault()` on tab to avoid having the browser move the focus\n // after this component has already moved it.\n if (event.code === 'Tab') {\n event.preventDefault();\n }\n }\n }\n\n // We use DOM event listeners instead of React event listeners\n // because we want to catch events from the underlying DOM tree.\n // The React Tree can be different from the DOM tree when using\n // portals. Block Toolbars for instance are rendered in a separate\n // React Trees.\n container.addEventListener('keydown', handleKeyDown);\n return () => {\n container.removeEventListener('keydown', handleKeyDown);\n };\n }, [onKeyDown, eventToOffset, stopNavigationEvents, cycle, onNavigate, getFocusableContext]);\n const mergedRef = useMergeRefs([containerRef, ref]);\n return /*#__PURE__*/_jsx(\"div\", {\n ref: mergedRef,\n ...restProps,\n children: children\n });\n}\nconst NavigableContainer = forwardRef(UnforwardedNavigableContainer);\nNavigableContainer.displayName = 'NavigableContainer';\nexport default NavigableContainer;"],
|
|
5
|
+
"mappings": ";AAOA,SAAS,YAAY,QAAQ,WAAW,mBAAmB;AAC3D,SAAS,oBAAoB;AAC7B,SAAS,aAAa;AAKtB,SAAS,OAAO,YAAY;AAC5B,IAAM,OAAO,MAAM;AAAC;AACpB,IAAM,kBAAkB,CAAC,YAAY,iBAAiB,kBAAkB;AACxE,SAAS,WAAW,OAAO,OAAO,QAAQ;AACxC,QAAM,YAAY,QAAQ;AAC1B,MAAI,YAAY,GAAG;AACjB,WAAO,QAAQ;AAAA,EACjB,WAAW,aAAa,OAAO;AAC7B,WAAO,YAAY;AAAA,EACrB;AACA,SAAO;AACT;AACA,SAAS,8BAA8B;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AAAA,EACA,aAAa;AAAA,EACb;AAAA,EACA,QAAQ;AAAA,EACR;AAAA,EACA,GAAG;AACL,GAAG,KAAK;AACN,QAAM,eAAe,OAAO,IAAI;AAChC,QAAM,oBAAoB,YAAY,CAAC,YAAY,WAAW;AAC5D,WAAO,WAAW,QAAQ,MAAM;AAAA,EAClC,GAAG,CAAC,CAAC;AACL,QAAM,sBAAsB,YAAY,YAAU;AAChD,QAAI,CAAC,aAAa,SAAS;AACzB,aAAO;AAAA,IACT;AACA,UAAM,SAAS,sBAAsB,MAAM,WAAW,MAAM;AAC5D,UAAM,aAAa,OAAO,KAAK,aA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AAC,WAAW,eAAe,sBAAsB,OAAO,YAAY,mBAAmB,CAAC;AAC3F,QAAM,YAAY,aAAa,CAAC,cAAc,GAAG,CAAC;AAClD,SAAoB,qBAAK,OAAO;AAAA,IAC9B,KAAK;AAAA,IACL,GAAG;AAAA,IACH;AAAA,EACF,CAAC;AACH;AACA,IAAM,qBAAqB,WAAW,6BAA6B;AACnE,mBAAmB,cAAc;AACjC,IAAO,oBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/palette-edit/index.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useState, useRef, useEffect, useCallback, useMemo } from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { lineSolid, moreVertical, plus } from '@wordpress/icons';\nimport { useDebounce } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport Button from '../button';\nimport { ColorPicker } from '../color-picker';\nimport { FlexBlock, FlexItem } from '../flex';\nimport { HStack } from '../h-stack';\nimport { Item, ItemGroup } from '../item-group';\nimport { VStack } from '../v-stack';\nimport GradientPicker from '../gradient-picker';\nimport ColorPalette from '../color-palette';\nimport DropdownMenu from '../dropdown-menu';\nimport Popover from '../popover';\nimport { PaletteActionsContainer, PaletteEditStyles, PaletteHeading, IndicatorStyled, NameContainer, NameInputControl, DoneButton, RemoveButton, PaletteEditContents } from './styles';\nimport { NavigableMenu } from '../navigable-container';\nimport { DEFAULT_GRADIENT } from '../custom-gradient-picker/constants';\nimport CustomGradientPicker from '../custom-gradient-picker';\nimport { kebabCase } from '../utils/strings';\nimport { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from \"react/jsx-runtime\";\nconst DEFAULT_COLOR = '#000';\nfunction NameInput({\n value,\n onChange,\n label\n}) {\n return /*#__PURE__*/_jsx(NameInputControl, {\n size: \"compact\",\n label: label,\n hideLabelFromVision: true,\n value: value,\n onChange: onChange\n });\n}\n\n/*\n * Deduplicates the slugs of the provided elements.\n */\nexport function deduplicateElementSlugs(elements) {\n const slugCounts = {};\n return elements.map(element => {\n let newSlug;\n const {\n slug\n } = element;\n slugCounts[slug] = (slugCounts[slug] || 0) + 1;\n if (slugCounts[slug] > 1) {\n newSlug = `${slug}-${slugCounts[slug] - 1}`;\n }\n return {\n ...element,\n slug: newSlug ?? slug\n };\n });\n}\n\n/**\n * Returns a name and slug for a palette item. The name takes the format \"Color + id\".\n * To ensure there are no duplicate ids, this function checks all slugs.\n * It expects slugs to be in the format: slugPrefix + color- + number.\n * It then sets the id component of the new name based on the incremented id of the highest existing slug id.\n *\n * @param elements An array of color palette items.\n * @param slugPrefix The slug prefix used to match the element slug.\n *\n * @return A name and slug for the new palette item.\n */\nexport function getNameAndSlugForPosition(elements, slugPrefix) {\n const nameRegex = new RegExp(`^${slugPrefix}color-([\\\\d]+)$`);\n const position = elements.reduce((previousValue, currentValue) => {\n if (typeof currentValue?.slug === 'string') {\n const matches = currentValue?.slug.match(nameRegex);\n if (matches) {\n const id = parseInt(matches[1], 10);\n if (id >= previousValue) {\n return id + 1;\n }\n }\n }\n return previousValue;\n }, 1);\n return {\n name: sprintf(/* translators: %d: is an id for a custom color */\n __('Color %d'), position),\n slug: `${slugPrefix}color-${position}`\n };\n}\nfunction ColorPickerPopover({\n isGradient,\n element,\n onChange,\n popoverProps: receivedPopoverProps,\n onClose = () => {}\n}) {\n const popoverProps = useMemo(() => ({\n shift: true,\n offset: 20,\n // Disabling resize as it would otherwise cause the popover to show\n // scrollbars while dragging the color picker's handle close to the\n // popover edge.\n resize: false,\n placement: 'left-start',\n ...receivedPopoverProps,\n className: clsx('components-palette-edit__popover', receivedPopoverProps?.className)\n }), [receivedPopoverProps]);\n return /*#__PURE__*/_jsxs(Popover, {\n ...popoverProps,\n onClose: onClose,\n children: [!isGradient && /*#__PURE__*/_jsx(ColorPicker, {\n color: element.color,\n enableAlpha: true,\n onChange: newColor => {\n onChange({\n ...element,\n color: newColor\n });\n }\n }), isGradient && /*#__PURE__*/_jsx(\"div\", {\n className: \"components-palette-edit__popover-gradient-picker\",\n children: /*#__PURE__*/_jsx(CustomGradientPicker, {\n __experimentalIsRenderedInSidebar: true,\n value: element.gradient,\n onChange: newGradient => {\n onChange({\n ...element,\n gradient: newGradient\n });\n }\n })\n })]\n });\n}\nfunction Option({\n canOnlyChangeValues,\n element,\n onChange,\n onRemove,\n popoverProps: receivedPopoverProps,\n slugPrefix,\n isGradient\n}) {\n const value = isGradient ? element.gradient : element.color;\n const [isEditingColor, setIsEditingColor] = useState(false);\n\n // Use internal state instead of a ref to make sure that the component\n // re-renders when the popover's anchor updates.\n const [popoverAnchor, setPopoverAnchor] = useState(null);\n const popoverProps = useMemo(() => ({\n ...receivedPopoverProps,\n // Use the custom palette color item as the popover anchor.\n anchor: popoverAnchor\n }), [popoverAnchor, receivedPopoverProps]);\n return /*#__PURE__*/_jsxs(Item, {\n ref: setPopoverAnchor,\n size: \"small\",\n children: [/*#__PURE__*/_jsxs(HStack, {\n justify: \"flex-start\",\n children: [/*#__PURE__*/_jsx(Button, {\n size: \"small\",\n onClick: () => {\n setIsEditingColor(true);\n },\n \"aria-label\": sprintf(\n // translators: %s is a color or gradient name, e.g. \"Red\".\n __('Edit: %s'), element.name.trim().length ? element.name : value || ''),\n style: {\n padding: 0\n },\n children: /*#__PURE__*/_jsx(IndicatorStyled, {\n colorValue: value\n })\n }), /*#__PURE__*/_jsx(FlexBlock, {\n children: !canOnlyChangeValues ? /*#__PURE__*/_jsx(NameInput, {\n label: isGradient ? __('Gradient name') : __('Color name'),\n value: element.name,\n onChange: nextName => onChange({\n ...element,\n name: nextName,\n slug: slugPrefix + kebabCase(nextName ?? '')\n })\n }) : /*#__PURE__*/_jsx(NameContainer, {\n children: element.name.trim().length ? element.name : /* Fall back to non-breaking space to maintain height */\n '\\u00A0'\n })\n }), !canOnlyChangeValues && /*#__PURE__*/_jsx(FlexItem, {\n children: /*#__PURE__*/_jsx(RemoveButton, {\n size: \"small\",\n icon: lineSolid,\n label: sprintf(\n // translators: %s is a color or gradient name, e.g. \"Red\".\n __('Remove color: %s'), element.name.trim().length ? element.name : value || ''),\n onClick: onRemove\n })\n })]\n }), isEditingColor && /*#__PURE__*/_jsx(ColorPickerPopover, {\n isGradient: isGradient,\n onChange: onChange,\n element: element,\n popoverProps: popoverProps,\n onClose: () => setIsEditingColor(false)\n })]\n });\n}\nfunction PaletteEditListView({\n elements,\n onChange,\n canOnlyChangeValues,\n slugPrefix,\n isGradient,\n popoverProps,\n addColorRef\n}) {\n // When unmounting the component if there are empty elements (the user did not complete the insertion) clean them.\n const elementsReferenceRef = useRef(undefined);\n useEffect(() => {\n elementsReferenceRef.current = elements;\n }, [elements]);\n const debounceOnChange = useDebounce(updatedElements => onChange(deduplicateElementSlugs(updatedElements)), 100);\n return /*#__PURE__*/_jsx(VStack, {\n spacing: 3,\n children: /*#__PURE__*/_jsx(ItemGroup, {\n isRounded: true,\n isBordered: true,\n isSeparated: true,\n children: elements.map((element, index) => /*#__PURE__*/_jsx(Option, {\n isGradient: isGradient,\n canOnlyChangeValues: canOnlyChangeValues,\n element: element,\n onChange: newElement => {\n debounceOnChange(elements.map((currentElement, currentIndex) => {\n if (currentIndex === index) {\n return newElement;\n }\n return currentElement;\n }));\n },\n onRemove: () => {\n const newElements = elements.filter((_currentElement, currentIndex) => {\n if (currentIndex === index) {\n return false;\n }\n return true;\n });\n onChange(newElements.length ? newElements : undefined);\n addColorRef.current?.focus();\n },\n slugPrefix: slugPrefix,\n popoverProps: popoverProps\n }, index))\n })\n });\n}\nconst EMPTY_ARRAY = [];\n\n/**\n * Allows editing a palette of colors or gradients.\n *\n * ```jsx\n * import { PaletteEdit } from '@wordpress/components';\n * const MyPaletteEdit = () => {\n * const [ controlledColors, setControlledColors ] = useState( colors );\n *\n * return (\n * <PaletteEdit\n * colors={ controlledColors }\n * onChange={ ( newColors?: Color[] ) => {\n * setControlledColors( newColors );\n * } }\n * paletteLabel=\"Here is a label\"\n * />\n * );\n * };\n * ```\n */\nexport function PaletteEdit({\n gradients,\n colors = EMPTY_ARRAY,\n onChange,\n paletteLabel,\n paletteLabelHeadingLevel = 2,\n emptyMessage,\n canOnlyChangeValues,\n canReset,\n slugPrefix = '',\n popoverProps\n}) {\n const isGradient = !!gradients;\n const elements = isGradient ? gradients : colors;\n const [isEditing, setIsEditing] = useState(false);\n const [editingElement, setEditingElement] = useState(null);\n const isAdding = isEditing && !!editingElement && elements[editingElement] && !elements[editingElement].slug;\n const elementsLength = elements.length;\n const hasElements = elementsLength > 0;\n const debounceOnChange = useDebounce(onChange, 100);\n const onSelectPaletteItem = useCallback((value, newEditingElementIndex) => {\n const selectedElement = newEditingElementIndex === undefined ? undefined : elements[newEditingElementIndex];\n const key = isGradient ? 'gradient' : 'color';\n // Ensures that the index returned matches a known element value.\n if (!!selectedElement && selectedElement[key] === value) {\n setEditingElement(newEditingElementIndex);\n } else {\n setIsEditing(true);\n }\n }, [isGradient, elements]);\n const addColorRef = useRef(null);\n return /*#__PURE__*/_jsxs(PaletteEditStyles, {\n children: [/*#__PURE__*/_jsxs(HStack, {\n children: [/*#__PURE__*/_jsx(PaletteHeading, {\n level: paletteLabelHeadingLevel,\n children: paletteLabel\n }), /*#__PURE__*/_jsxs(PaletteActionsContainer, {\n children: [hasElements && isEditing && /*#__PURE__*/_jsx(DoneButton, {\n size: \"small\",\n onClick: () => {\n setIsEditing(false);\n setEditingElement(null);\n },\n children: __('Done')\n }), !canOnlyChangeValues && /*#__PURE__*/_jsx(Button, {\n ref: addColorRef,\n size: \"small\",\n isPressed: isAdding,\n icon: plus,\n label: isGradient ? __('Add gradient') : __('Add color'),\n onClick: () => {\n const {\n name,\n slug\n } = getNameAndSlugForPosition(elements, slugPrefix);\n if (!!gradients) {\n onChange([...gradients, {\n gradient: DEFAULT_GRADIENT,\n name,\n slug\n }]);\n } else {\n onChange([...colors, {\n color: DEFAULT_COLOR,\n name,\n slug\n }]);\n }\n setIsEditing(true);\n setEditingElement(elements.length);\n }\n }), hasElements && (!isEditing || !canOnlyChangeValues || canReset) && /*#__PURE__*/_jsx(DropdownMenu, {\n icon: moreVertical,\n label: isGradient ? __('Gradient options') : __('Color options'),\n toggleProps: {\n size: 'small'\n },\n children: ({\n onClose\n }) => /*#__PURE__*/_jsx(_Fragment, {\n children: /*#__PURE__*/_jsxs(NavigableMenu, {\n role: \"menu\",\n children: [!isEditing && /*#__PURE__*/_jsx(Button, {\n __next40pxDefaultSize: true,\n variant: \"tertiary\",\n onClick: () => {\n setIsEditing(true);\n onClose();\n },\n className: \"components-palette-edit__menu-button\",\n children: __('Show details')\n }), !canOnlyChangeValues && /*#__PURE__*/_jsx(Button, {\n __next40pxDefaultSize: true,\n variant: \"tertiary\",\n onClick: () => {\n setEditingElement(null);\n setIsEditing(false);\n onChange();\n onClose();\n },\n className: \"components-palette-edit__menu-button\",\n children: isGradient ? __('Remove all gradients') : __('Remove all colors')\n }), canReset && /*#__PURE__*/_jsx(Button, {\n __next40pxDefaultSize: true,\n className: \"components-palette-edit__menu-button\",\n variant: \"tertiary\",\n onClick: () => {\n setEditingElement(null);\n onChange();\n onClose();\n },\n children: isGradient ? __('Reset gradient') : __('Reset colors')\n })]\n })\n })\n })]\n })]\n }), hasElements && /*#__PURE__*/_jsxs(PaletteEditContents, {\n children: [isEditing && /*#__PURE__*/_jsx(PaletteEditListView, {\n canOnlyChangeValues: canOnlyChangeValues,\n elements: elements\n // @ts-expect-error TODO: Don't know how to resolve\n ,\n onChange: onChange,\n slugPrefix: slugPrefix,\n isGradient: isGradient,\n popoverProps: popoverProps,\n addColorRef: addColorRef\n }), !isEditing && editingElement !== null && /*#__PURE__*/_jsx(ColorPickerPopover, {\n isGradient: isGradient,\n onClose: () => setEditingElement(null),\n onChange: newElement => {\n debounceOnChange(\n // @ts-expect-error TODO: Don't know how to resolve\n elements.map((currentElement, currentIndex) => {\n if (currentIndex === editingElement) {\n return newElement;\n }\n return currentElement;\n }));\n },\n element: elements[editingElement ?? -1],\n popoverProps: popoverProps\n }), !isEditing && (isGradient ? /*#__PURE__*/_jsx(GradientPicker, {\n gradients: gradients,\n onChange: onSelectPaletteItem,\n clearable: false,\n disableCustomGradients: true\n }) : /*#__PURE__*/_jsx(ColorPalette, {\n colors: colors,\n onChange: onSelectPaletteItem,\n clearable: false,\n disableCustomColors: true\n }))]\n }), !hasElements && emptyMessage && /*#__PURE__*/_jsx(PaletteEditContents, {\n children: emptyMessage\n })]\n });\n}\nexport default PaletteEdit;"],
|
|
5
|
-
"mappings": ";AAGA,OAAO,UAAU;AAKjB,SAAS,UAAU,QAAQ,WAAW,aAAa,eAAe;AAClE,SAAS,IAAI,eAAe;AAC5B,SAAS,WAAW,cAAc,YAAY;AAC9C,SAAS,mBAAmB;AAK5B,OAAO,YAAY;AACnB,SAAS,mBAAmB;AAC5B,SAAS,WAAW,gBAAgB;AACpC,SAAS,cAAc;AACvB,SAAS,MAAM,iBAAiB;AAChC,SAAS,cAAc;AACvB,OAAO,oBAAoB;AAC3B,OAAO,kBAAkB;AACzB,OAAO,kBAAkB;AACzB,OAAO,aAAa;AACpB,SAAS,yBAAyB,mBAAmB,gBAAgB,iBAAiB,eAAe,kBAAkB,YAAY,cAAc,2BAA2B;AAC5K,SAAS,qBAAqB;AAC9B,SAAS,wBAAwB;AACjC,OAAO,0BAA0B;AACjC,SAAS,iBAAiB;AAC1B,SAAS,OAAO,MAAM,QAAQ,OAAO,YAAY,iBAAiB;AAClE,IAAM,gBAAgB;AACtB,SAAS,UAAU;AAAA,EACjB;AAAA,EACA;AAAA,EACA;AACF,GAAG;AACD,SAAoB,qBAAK,kBAAkB;AAAA,IACzC,MAAM;AAAA,IACN;AAAA,IACA,qBAAqB;AAAA,IACrB;AAAA,IACA;AAAA,EACF,CAAC;AACH;AAKO,SAAS,wBAAwB,UAAU;AAChD,QAAM,aAAa,CAA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port clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useState, useRef, useEffect, useCallback, useMemo } from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { lineSolid, moreVertical, plus } from '@wordpress/icons';\nimport { useDebounce } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport Button from '../button';\nimport { ColorPicker } from '../color-picker';\nimport { FlexBlock, FlexItem } from '../flex';\nimport { HStack } from '../h-stack';\nimport { Item, ItemGroup } from '../item-group';\nimport { VStack } from '../v-stack';\nimport GradientPicker from '../gradient-picker';\nimport ColorPalette from '../color-palette';\nimport DropdownMenu from '../dropdown-menu';\nimport Popover from '../popover';\nimport { PaletteActionsContainer, PaletteEditStyles, PaletteHeading, IndicatorStyled, NameContainer, NameInputControl, DoneButton, RemoveButton, PaletteEditContents } from './styles';\nimport { NavigableMenu } from '../navigable-container';\nimport { DEFAULT_GRADIENT } from '../custom-gradient-picker/constants';\nimport CustomGradientPicker from '../custom-gradient-picker';\nimport { kebabCase } from '../utils/strings';\nimport { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from \"react/jsx-runtime\";\nconst DEFAULT_COLOR = '#000';\nfunction NameInput({\n value,\n onChange,\n label\n}) {\n return /*#__PURE__*/_jsx(NameInputControl, {\n size: \"compact\",\n label: label,\n hideLabelFromVision: true,\n value: value,\n onChange: onChange\n });\n}\n\n/*\n * Deduplicates the slugs of the provided elements.\n */\nexport function deduplicateElementSlugs(elements) {\n const slugCounts = {};\n return elements.map(element => {\n let newSlug;\n const {\n slug\n } = element;\n slugCounts[slug] = (slugCounts[slug] || 0) + 1;\n if (slugCounts[slug] > 1) {\n newSlug = `${slug}-${slugCounts[slug] - 1}`;\n }\n return {\n ...element,\n slug: newSlug ?? slug\n };\n });\n}\n\n/**\n * Returns a name and slug for a palette item. The name takes the format \"Color + id\".\n * To ensure there are no duplicate ids, this function checks all slugs.\n * It expects slugs to be in the format: slugPrefix + color- + number.\n * It then sets the id component of the new name based on the incremented id of the highest existing slug id.\n *\n * @param elements An array of color palette items.\n * @param slugPrefix The slug prefix used to match the element slug.\n *\n * @return A name and slug for the new palette item.\n */\nexport function getNameAndSlugForPosition(elements, slugPrefix) {\n const nameRegex = new RegExp(`^${slugPrefix}color-([\\\\d]+)$`);\n const position = elements.reduce((previousValue, currentValue) => {\n if (typeof currentValue?.slug === 'string') {\n const matches = currentValue?.slug.match(nameRegex);\n if (matches) {\n const id = parseInt(matches[1], 10);\n if (id >= previousValue) {\n return id + 1;\n }\n }\n }\n return previousValue;\n }, 1);\n return {\n name: sprintf(/* translators: %d: is an id for a custom color */\n __('Color %d'), position),\n slug: `${slugPrefix}color-${position}`\n };\n}\nfunction ColorPickerPopover({\n isGradient,\n element,\n onChange,\n popoverProps: receivedPopoverProps,\n onClose = () => {}\n}) {\n const popoverProps = useMemo(() => ({\n shift: true,\n offset: 20,\n // Disabling resize as it would otherwise cause the popover to show\n // scrollbars while dragging the color picker's handle close to the\n // popover edge.\n resize: false,\n placement: 'left-start',\n ...receivedPopoverProps,\n className: clsx('components-palette-edit__popover', receivedPopoverProps?.className)\n }), [receivedPopoverProps]);\n return /*#__PURE__*/_jsxs(Popover, {\n ...popoverProps,\n onClose: onClose,\n children: [!isGradient && /*#__PURE__*/_jsx(ColorPicker, {\n color: element.color,\n enableAlpha: true,\n onChange: newColor => {\n onChange({\n ...element,\n color: newColor\n });\n }\n }), isGradient && /*#__PURE__*/_jsx(\"div\", {\n className: \"components-palette-edit__popover-gradient-picker\",\n children: /*#__PURE__*/_jsx(CustomGradientPicker, {\n __experimentalIsRenderedInSidebar: true,\n value: element.gradient,\n onChange: newGradient => {\n onChange({\n ...element,\n gradient: newGradient\n });\n }\n })\n })]\n });\n}\nfunction Option({\n canOnlyChangeValues,\n element,\n onChange,\n onRemove,\n popoverProps: receivedPopoverProps,\n slugPrefix,\n isGradient\n}) {\n const value = isGradient ? element.gradient : element.color;\n const [isEditingColor, setIsEditingColor] = useState(false);\n\n // Use internal state instead of a ref to make sure that the component\n // re-renders when the popover's anchor updates.\n const [popoverAnchor, setPopoverAnchor] = useState(null);\n const popoverProps = useMemo(() => ({\n ...receivedPopoverProps,\n // Use the custom palette color item as the popover anchor.\n anchor: popoverAnchor\n }), [popoverAnchor, receivedPopoverProps]);\n return /*#__PURE__*/_jsxs(Item, {\n ref: setPopoverAnchor,\n size: \"small\",\n children: [/*#__PURE__*/_jsxs(HStack, {\n justify: \"flex-start\",\n children: [/*#__PURE__*/_jsx(Button, {\n size: \"small\",\n onClick: () => {\n setIsEditingColor(true);\n },\n \"aria-label\": sprintf(\n // translators: %s is a color or gradient name, e.g. \"Red\".\n __('Edit: %s'), element.name.trim().length ? element.name : value || ''),\n style: {\n padding: 0\n },\n children: /*#__PURE__*/_jsx(IndicatorStyled, {\n colorValue: value\n })\n }), /*#__PURE__*/_jsx(FlexBlock, {\n children: !canOnlyChangeValues ? /*#__PURE__*/_jsx(NameInput, {\n label: isGradient ? __('Gradient name') : __('Color name'),\n value: element.name,\n onChange: nextName => onChange({\n ...element,\n name: nextName,\n slug: slugPrefix + kebabCase(nextName ?? '')\n })\n }) : /*#__PURE__*/_jsx(NameContainer, {\n children: element.name.trim().length ? element.name : /* Fall back to non-breaking space to maintain height */\n '\\u00A0'\n })\n }), !canOnlyChangeValues && /*#__PURE__*/_jsx(FlexItem, {\n children: /*#__PURE__*/_jsx(RemoveButton, {\n size: \"small\",\n icon: lineSolid,\n label: sprintf(\n // translators: %s is a color or gradient name, e.g. \"Red\".\n __('Remove color: %s'), element.name.trim().length ? element.name : value || ''),\n onClick: onRemove\n })\n })]\n }), isEditingColor && /*#__PURE__*/_jsx(ColorPickerPopover, {\n isGradient: isGradient,\n onChange: onChange,\n element: element,\n popoverProps: popoverProps,\n onClose: () => setIsEditingColor(false)\n })]\n });\n}\nfunction PaletteEditListView({\n elements,\n onChange,\n canOnlyChangeValues,\n slugPrefix,\n isGradient,\n popoverProps,\n addColorRef\n}) {\n // When unmounting the component if there are empty elements (the user did not complete the insertion) clean them.\n const elementsReferenceRef = useRef(undefined);\n useEffect(() => {\n // eslint-disable-next-line react-compiler/react-compiler -- false positive, see https://github.com/facebook/react/issues/29196\n elementsReferenceRef.current = elements;\n }, [elements]);\n const debounceOnChange = useDebounce(updatedElements => onChange(deduplicateElementSlugs(updatedElements)), 100);\n return /*#__PURE__*/_jsx(VStack, {\n spacing: 3,\n children: /*#__PURE__*/_jsx(ItemGroup, {\n isRounded: true,\n isBordered: true,\n isSeparated: true,\n children: elements.map((element, index) => /*#__PURE__*/_jsx(Option, {\n isGradient: isGradient,\n canOnlyChangeValues: canOnlyChangeValues,\n element: element,\n onChange: newElement => {\n debounceOnChange(elements.map((currentElement, currentIndex) => {\n if (currentIndex === index) {\n return newElement;\n }\n return currentElement;\n }));\n },\n onRemove: () => {\n const newElements = elements.filter((_currentElement, currentIndex) => {\n if (currentIndex === index) {\n return false;\n }\n return true;\n });\n onChange(newElements.length ? newElements : undefined);\n addColorRef.current?.focus();\n },\n slugPrefix: slugPrefix,\n popoverProps: popoverProps\n }, index))\n })\n });\n}\nconst EMPTY_ARRAY = [];\n\n/**\n * Allows editing a palette of colors or gradients.\n *\n * ```jsx\n * import { PaletteEdit } from '@wordpress/components';\n * const MyPaletteEdit = () => {\n * const [ controlledColors, setControlledColors ] = useState( colors );\n *\n * return (\n * <PaletteEdit\n * colors={ controlledColors }\n * onChange={ ( newColors?: Color[] ) => {\n * setControlledColors( newColors );\n * } }\n * paletteLabel=\"Here is a label\"\n * />\n * );\n * };\n * ```\n */\nexport function PaletteEdit({\n gradients,\n colors = EMPTY_ARRAY,\n onChange,\n paletteLabel,\n paletteLabelHeadingLevel = 2,\n emptyMessage,\n canOnlyChangeValues,\n canReset,\n slugPrefix = '',\n popoverProps\n}) {\n const isGradient = !!gradients;\n const elements = isGradient ? gradients : colors;\n const [isEditing, setIsEditing] = useState(false);\n const [editingElement, setEditingElement] = useState(null);\n const isAdding = isEditing && !!editingElement && elements[editingElement] && !elements[editingElement].slug;\n const elementsLength = elements.length;\n const hasElements = elementsLength > 0;\n const debounceOnChange = useDebounce(onChange, 100);\n const onSelectPaletteItem = useCallback((value, newEditingElementIndex) => {\n const selectedElement = newEditingElementIndex === undefined ? undefined : elements[newEditingElementIndex];\n const key = isGradient ? 'gradient' : 'color';\n // Ensures that the index returned matches a known element value.\n if (!!selectedElement && selectedElement[key] === value) {\n setEditingElement(newEditingElementIndex);\n } else {\n setIsEditing(true);\n }\n }, [isGradient, elements]);\n const addColorRef = useRef(null);\n return /*#__PURE__*/_jsxs(PaletteEditStyles, {\n children: [/*#__PURE__*/_jsxs(HStack, {\n children: [/*#__PURE__*/_jsx(PaletteHeading, {\n level: paletteLabelHeadingLevel,\n children: paletteLabel\n }), /*#__PURE__*/_jsxs(PaletteActionsContainer, {\n children: [hasElements && isEditing && /*#__PURE__*/_jsx(DoneButton, {\n size: \"small\",\n onClick: () => {\n setIsEditing(false);\n setEditingElement(null);\n },\n children: __('Done')\n }), !canOnlyChangeValues && /*#__PURE__*/_jsx(Button, {\n ref: addColorRef,\n size: \"small\",\n isPressed: isAdding,\n icon: plus,\n label: isGradient ? __('Add gradient') : __('Add color'),\n onClick: () => {\n const {\n name,\n slug\n } = getNameAndSlugForPosition(elements, slugPrefix);\n if (!!gradients) {\n onChange([...gradients, {\n gradient: DEFAULT_GRADIENT,\n name,\n slug\n }]);\n } else {\n onChange([...colors, {\n color: DEFAULT_COLOR,\n name,\n slug\n }]);\n }\n setIsEditing(true);\n setEditingElement(elements.length);\n }\n }), hasElements && (!isEditing || !canOnlyChangeValues || canReset) && /*#__PURE__*/_jsx(DropdownMenu, {\n icon: moreVertical,\n label: isGradient ? __('Gradient options') : __('Color options'),\n toggleProps: {\n size: 'small'\n },\n children: ({\n onClose\n }) => /*#__PURE__*/_jsx(_Fragment, {\n children: /*#__PURE__*/_jsxs(NavigableMenu, {\n role: \"menu\",\n children: [!isEditing && /*#__PURE__*/_jsx(Button, {\n __next40pxDefaultSize: true,\n variant: \"tertiary\",\n onClick: () => {\n setIsEditing(true);\n onClose();\n },\n className: \"components-palette-edit__menu-button\",\n children: __('Show details')\n }), !canOnlyChangeValues && /*#__PURE__*/_jsx(Button, {\n __next40pxDefaultSize: true,\n variant: \"tertiary\",\n onClick: () => {\n setEditingElement(null);\n setIsEditing(false);\n onChange();\n onClose();\n },\n className: \"components-palette-edit__menu-button\",\n children: isGradient ? __('Remove all gradients') : __('Remove all colors')\n }), canReset && /*#__PURE__*/_jsx(Button, {\n __next40pxDefaultSize: true,\n className: \"components-palette-edit__menu-button\",\n variant: \"tertiary\",\n onClick: () => {\n setEditingElement(null);\n onChange();\n onClose();\n },\n children: isGradient ? __('Reset gradient') : __('Reset colors')\n })]\n })\n })\n })]\n })]\n }), hasElements && /*#__PURE__*/_jsxs(PaletteEditContents, {\n children: [isEditing && /*#__PURE__*/_jsx(PaletteEditListView, {\n canOnlyChangeValues: canOnlyChangeValues,\n elements: elements\n // @ts-expect-error TODO: Don't know how to resolve\n ,\n onChange: onChange,\n slugPrefix: slugPrefix,\n isGradient: isGradient,\n popoverProps: popoverProps,\n addColorRef: addColorRef\n }), !isEditing && editingElement !== null && /*#__PURE__*/_jsx(ColorPickerPopover, {\n isGradient: isGradient,\n onClose: () => setEditingElement(null),\n onChange: newElement => {\n debounceOnChange(\n // @ts-expect-error TODO: Don't know how to resolve\n elements.map((currentElement, currentIndex) => {\n if (currentIndex === editingElement) {\n return newElement;\n }\n return currentElement;\n }));\n },\n element: elements[editingElement ?? -1],\n popoverProps: popoverProps\n }), !isEditing && (isGradient ? /*#__PURE__*/_jsx(GradientPicker, {\n gradients: gradients,\n onChange: onSelectPaletteItem,\n clearable: false,\n disableCustomGradients: true\n }) : /*#__PURE__*/_jsx(ColorPalette, {\n colors: colors,\n onChange: onSelectPaletteItem,\n clearable: false,\n disableCustomColors: true\n }))]\n }), !hasElements && emptyMessage && /*#__PURE__*/_jsx(PaletteEditContents, {\n children: emptyMessage\n })]\n });\n}\nexport default PaletteEdit;"],
|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AA,YAEA,SAAS,IAAI,CAAC,gBAAgB,iBAAiB;AAC7C,kBAAI,iBAAiB,gBAAgB;AACnC,uBAAO;AAAA,cACT;AACA,qBAAO;AAAA,YACT,CAAC;AAAA,UAAC;AAAA,QACJ;AAAA,QACA,SAAS,SAAS,kBAAkB,EAAE;AAAA,QACtC;AAAA,MACF,CAAC,GAAG,CAAC,cAAc,aAA0B,qBAAK,gBAAgB;AAAA,QAChE;AAAA,QACA,UAAU;AAAA,QACV,WAAW;AAAA,QACX,wBAAwB;AAAA,MAC1B,CAAC,IAAiB,qBAAK,cAAc;AAAA,QACnC;AAAA,QACA,UAAU;AAAA,QACV,WAAW;AAAA,QACX,qBAAqB;AAAA,MACvB,CAAC,EAAE;AAAA,IACL,CAAC,GAAG,CAAC,eAAe,gBAA6B,qBAAK,qBAAqB;AAAA,MACzE,UAAU;AAAA,IACZ,CAAC,CAAC;AAAA,EACJ,CAAC;AACH;AACA,IAAO,uBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -24,6 +24,7 @@ function RadioControl(props) {
|
|
|
24
24
|
onChange,
|
|
25
25
|
onClick,
|
|
26
26
|
hideLabelFromVision,
|
|
27
|
+
disabled,
|
|
27
28
|
options = [],
|
|
28
29
|
id: preferredId,
|
|
29
30
|
...additionalProps
|
|
@@ -37,6 +38,7 @@ function RadioControl(props) {
|
|
|
37
38
|
id,
|
|
38
39
|
role: "radiogroup",
|
|
39
40
|
className: clsx(className, "components-radio-control"),
|
|
41
|
+
disabled,
|
|
40
42
|
"aria-describedby": !!help ? generateHelpId(id) : void 0,
|
|
41
43
|
children: [hideLabelFromVision ? /* @__PURE__ */ _jsx(VisuallyHidden, {
|
|
42
44
|
as: "legend",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/radio-control/index.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n/**\n * WordPress dependencies\n */\nimport { useInstanceId } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport BaseControl from '../base-control';\nimport { VStack } from '../v-stack';\nimport { StyledHelp } from '../base-control/styles/base-control-styles';\nimport { VisuallyHidden } from '../visually-hidden';\nimport { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nfunction generateOptionDescriptionId(radioGroupId, index) {\n return `${radioGroupId}-${index}-option-description`;\n}\nfunction generateOptionId(radioGroupId, index) {\n return `${radioGroupId}-${index}`;\n}\nfunction generateHelpId(radioGroupId) {\n return `${radioGroupId}__help`;\n}\n\n/**\n * Render a user interface to select the user type using radio inputs.\n *\n * ```jsx\n * import { RadioControl } from '@wordpress/components';\n * import { useState } from '@wordpress/element';\n *\n * const MyRadioControl = () => {\n * const [ option, setOption ] = useState( 'a' );\n *\n * return (\n * <RadioControl\n * label=\"User type\"\n * help=\"The type of the current user\"\n * selected={ option }\n * options={ [\n * { label: 'Author', value: 'a' },\n * { label: 'Editor', value: 'e' },\n * ] }\n * onChange={ ( value ) => setOption( value ) }\n * />\n * );\n * };\n * ```\n */\nexport function RadioControl(props) {\n const {\n label,\n className,\n selected,\n help,\n onChange,\n onClick,\n hideLabelFromVision,\n options = [],\n id: preferredId,\n ...additionalProps\n } = props;\n const id = useInstanceId(RadioControl, 'inspector-radio-control', preferredId);\n const onChangeValue = event => onChange(event.target.value);\n if (!options?.length) {\n return null;\n }\n return /*#__PURE__*/_jsxs(\"fieldset\", {\n id: id,\n role: \"radiogroup\",\n className: clsx(className, 'components-radio-control'),\n \"aria-describedby\": !!help ? generateHelpId(id) : undefined,\n children: [hideLabelFromVision ? /*#__PURE__*/_jsx(VisuallyHidden, {\n as: \"legend\",\n children: label\n }) : /*#__PURE__*/_jsx(BaseControl.VisualLabel, {\n as: \"legend\",\n children: label\n }), /*#__PURE__*/_jsx(VStack, {\n spacing: 3,\n className: clsx('components-radio-control__group-wrapper', {\n 'has-help': !!help\n }),\n children: options.map((option, index) => /*#__PURE__*/_jsxs(\"div\", {\n className: \"components-radio-control__option\",\n children: [/*#__PURE__*/_jsx(\"input\", {\n id: generateOptionId(id, index),\n className: \"components-radio-control__input\",\n type: \"radio\",\n name: id,\n value: option.value,\n onChange: onChangeValue,\n checked: option.value === selected,\n \"aria-describedby\": !!option.description ? generateOptionDescriptionId(id, index) : undefined,\n onClick: event => {\n // Compat code for Safari to ensure that the radio is focused when clicked.\n event.currentTarget.focus();\n onClick?.(event);\n },\n ...additionalProps\n }), /*#__PURE__*/_jsx(\"label\", {\n className: \"components-radio-control__label\",\n htmlFor: generateOptionId(id, index),\n children: option.label\n }), !!option.description ? /*#__PURE__*/_jsx(StyledHelp, {\n id: generateOptionDescriptionId(id, index),\n className: \"components-radio-control__option-description\",\n children: option.description\n }) : null]\n }, generateOptionId(id, index)))\n }), !!help && /*#__PURE__*/_jsx(StyledHelp, {\n id: generateHelpId(id),\n className: \"components-base-control__help\",\n children: help\n })]\n });\n}\nexport default RadioControl;"],
|
|
5
|
-
"mappings": ";AAGA,OAAO,UAAU;AAIjB,SAAS,qBAAqB;AAK9B,OAAO,iBAAiB;AACxB,SAAS,cAAc;AACvB,SAAS,kBAAkB;AAC3B,SAAS,sBAAsB;AAC/B,SAAS,OAAO,MAAM,QAAQ,aAAa;AAC3C,SAAS,4BAA4B,cAAc,OAAO;AACxD,SAAO,GAAG,YAAY,IAAI,KAAK;AACjC;AACA,SAAS,iBAAiB,cAAc,OAAO;AAC7C,SAAO,GAAG,YAAY,IAAI,KAAK;AACjC;AACA,SAAS,eAAe,cAAc;AACpC,SAAO,GAAG,YAAY;AACxB;AA2BO,SAAS,aAAa,OAAO;AAClC,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,UAAU,CAAC;AAAA,IACX,IAAI;AAAA,IACJ,GAAG;AAAA,EACL,IAAI;AACJ,QAAM,KAAK,cAAc,cAAc,2BAA2B,W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;AAAA,UACzC,WAAW;AAAA,UACX,UAAU,OAAO;AAAA,QACnB,CAAC,IAAI,IAAI;AAAA,MACX,GAAG,iBAAiB,IAAI,KAAK,CAAC,CAAC;AAAA,IACjC,CAAC,GAAG,CAAC,CAAC,QAAqB,qBAAK,YAAY;AAAA,MAC1C,IAAI,eAAe,EAAE;AAAA,MACrB,WAAW;AAAA,MACX,UAAU;AAAA,IACZ,CAAC,CAAC;AAAA,EACJ,CAAC;AACH;AACA,IAAO,wBAAQ;",
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n/**\n * WordPress dependencies\n */\nimport { useInstanceId } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport BaseControl from '../base-control';\nimport { VStack } from '../v-stack';\nimport { StyledHelp } from '../base-control/styles/base-control-styles';\nimport { VisuallyHidden } from '../visually-hidden';\nimport { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nfunction generateOptionDescriptionId(radioGroupId, index) {\n return `${radioGroupId}-${index}-option-description`;\n}\nfunction generateOptionId(radioGroupId, index) {\n return `${radioGroupId}-${index}`;\n}\nfunction generateHelpId(radioGroupId) {\n return `${radioGroupId}__help`;\n}\n\n/**\n * Render a user interface to select the user type using radio inputs.\n *\n * ```jsx\n * import { RadioControl } from '@wordpress/components';\n * import { useState } from '@wordpress/element';\n *\n * const MyRadioControl = () => {\n * const [ option, setOption ] = useState( 'a' );\n *\n * return (\n * <RadioControl\n * label=\"User type\"\n * help=\"The type of the current user\"\n * selected={ option }\n * options={ [\n * { label: 'Author', value: 'a' },\n * { label: 'Editor', value: 'e' },\n * ] }\n * onChange={ ( value ) => setOption( value ) }\n * />\n * );\n * };\n * ```\n */\nexport function RadioControl(props) {\n const {\n label,\n className,\n selected,\n help,\n onChange,\n onClick,\n hideLabelFromVision,\n disabled,\n options = [],\n id: preferredId,\n ...additionalProps\n } = props;\n const id = useInstanceId(RadioControl, 'inspector-radio-control', preferredId);\n const onChangeValue = event => onChange(event.target.value);\n if (!options?.length) {\n return null;\n }\n return /*#__PURE__*/_jsxs(\"fieldset\", {\n id: id,\n role: \"radiogroup\",\n className: clsx(className, 'components-radio-control'),\n disabled: disabled,\n \"aria-describedby\": !!help ? generateHelpId(id) : undefined,\n children: [hideLabelFromVision ? /*#__PURE__*/_jsx(VisuallyHidden, {\n as: \"legend\",\n children: label\n }) : /*#__PURE__*/_jsx(BaseControl.VisualLabel, {\n as: \"legend\",\n children: label\n }), /*#__PURE__*/_jsx(VStack, {\n spacing: 3,\n className: clsx('components-radio-control__group-wrapper', {\n 'has-help': !!help\n }),\n children: options.map((option, index) => /*#__PURE__*/_jsxs(\"div\", {\n className: \"components-radio-control__option\",\n children: [/*#__PURE__*/_jsx(\"input\", {\n id: generateOptionId(id, index),\n className: \"components-radio-control__input\",\n type: \"radio\",\n name: id,\n value: option.value,\n onChange: onChangeValue,\n checked: option.value === selected,\n \"aria-describedby\": !!option.description ? generateOptionDescriptionId(id, index) : undefined,\n onClick: event => {\n // Compat code for Safari to ensure that the radio is focused when clicked.\n event.currentTarget.focus();\n onClick?.(event);\n },\n ...additionalProps\n }), /*#__PURE__*/_jsx(\"label\", {\n className: \"components-radio-control__label\",\n htmlFor: generateOptionId(id, index),\n children: option.label\n }), !!option.description ? /*#__PURE__*/_jsx(StyledHelp, {\n id: generateOptionDescriptionId(id, index),\n className: \"components-radio-control__option-description\",\n children: option.description\n }) : null]\n }, generateOptionId(id, index)))\n }), !!help && /*#__PURE__*/_jsx(StyledHelp, {\n id: generateHelpId(id),\n className: \"components-base-control__help\",\n children: help\n })]\n });\n}\nexport default RadioControl;"],
|
|
5
|
+
"mappings": ";AAGA,OAAO,UAAU;AAIjB,SAAS,qBAAqB;AAK9B,OAAO,iBAAiB;AACxB,SAAS,cAAc;AACvB,SAAS,kBAAkB;AAC3B,SAAS,sBAAsB;AAC/B,SAAS,OAAO,MAAM,QAAQ,aAAa;AAC3C,SAAS,4BAA4B,cAAc,OAAO;AACxD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