@wordpress/components 32.2.1-next.v.202602111440.0 → 32.2.1
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/CLAUDE.md +1 -0
- package/build/alignment-matrix-control/cell.cjs +2 -2
- package/build/alignment-matrix-control/cell.cjs.map +1 -1
- package/build/alignment-matrix-control/index.cjs +2 -2
- package/build/alignment-matrix-control/index.cjs.map +1 -1
- package/build/angle-picker-control/angle-circle.cjs +4 -4
- package/build/angle-picker-control/angle-circle.cjs.map +2 -2
- package/build/autocomplete/index.cjs +16 -8
- package/build/autocomplete/index.cjs.map +2 -2
- package/build/clipboard-button/index.cjs +1 -1
- package/build/clipboard-button/index.cjs.map +2 -2
- package/build/color-picker/color-copy-button.cjs +1 -1
- package/build/color-picker/color-copy-button.cjs.map +2 -2
- package/build/confirm-dialog/component.cjs +2 -2
- package/build/confirm-dialog/component.cjs.map +2 -2
- package/build/context/context-system-provider.cjs.map +1 -1
- package/build/custom-gradient-picker/gradient-bar/control-points.cjs +2 -2
- package/build/custom-gradient-picker/gradient-bar/control-points.cjs.map +2 -2
- package/build/date-time/date/index.cjs +1 -1
- package/build/date-time/date/index.cjs.map +2 -2
- package/build/date-time/time/index.cjs +1 -1
- package/build/date-time/time/index.cjs.map +2 -2
- package/build/date-time/utils.cjs +9 -0
- package/build/date-time/utils.cjs.map +2 -2
- package/build/dropdown/index.cjs +1 -1
- package/build/dropdown/index.cjs.map +2 -2
- package/build/external-link/index.cjs +5 -1
- package/build/external-link/index.cjs.map +2 -2
- package/build/higher-order/with-spoken-messages/index.cjs.map +2 -2
- package/build/modal/index.cjs +2 -2
- package/build/modal/index.cjs.map +2 -2
- package/build/modal/use-modal-exit-animation.cjs +2 -2
- package/build/modal/use-modal-exit-animation.cjs.map +2 -2
- package/build/number-control/index.cjs +1 -1
- package/build/number-control/index.cjs.map +2 -2
- package/build/palette-edit/index.cjs +1 -1
- package/build/palette-edit/index.cjs.map +2 -2
- package/build/panel/body.cjs +1 -1
- package/build/panel/body.cjs.map +2 -2
- package/build/private-apis.cjs +0 -2
- package/build/private-apis.cjs.map +2 -2
- package/build/range-control/index.cjs +1 -1
- package/build/range-control/index.cjs.map +2 -2
- package/build/resizable-box/resize-tooltip/utils.cjs +1 -1
- package/build/resizable-box/resize-tooltip/utils.cjs.map +2 -2
- package/build/sandbox/index.cjs +126 -2
- package/build/sandbox/index.cjs.map +2 -2
- package/build/select-control/styles/select-control-styles.cjs +8 -8
- package/build/select-control/styles/select-control-styles.cjs.map +2 -2
- package/build/snackbar/list.cjs +4 -1
- package/build/snackbar/list.cjs.map +2 -2
- package/build/tabs/styles.cjs +5 -5
- package/build/tabs/styles.cjs.map +2 -2
- package/build/text/utils.cjs.map +1 -1
- package/build/toggle-group-control/toggle-group-control-option-base/styles.cjs +8 -8
- package/build/toggle-group-control/toggle-group-control-option-base/styles.cjs.map +2 -2
- package/build/tree-grid/roving-tab-index-item.cjs +1 -1
- package/build/tree-grid/roving-tab-index-item.cjs.map +2 -2
- package/build/utils/element-rect.cjs +1 -1
- package/build/utils/element-rect.cjs.map +2 -2
- package/build/utils/hooks/use-update-effect.cjs.map +1 -1
- package/build/utils/rtl.cjs +2 -2
- package/build/utils/rtl.cjs.map +2 -2
- package/build/utils/use-responsive-value.cjs +1 -7
- package/build/utils/use-responsive-value.cjs.map +2 -2
- package/build/validated-form-controls/control-with-error.cjs +26 -3
- package/build/validated-form-controls/control-with-error.cjs.map +2 -2
- package/build/validated-form-controls/validity-indicator.cjs +2 -0
- package/build/validated-form-controls/validity-indicator.cjs.map +2 -2
- package/build-module/alignment-matrix-control/cell.mjs +2 -2
- package/build-module/alignment-matrix-control/cell.mjs.map +1 -1
- package/build-module/alignment-matrix-control/index.mjs +2 -2
- package/build-module/alignment-matrix-control/index.mjs.map +1 -1
- package/build-module/angle-picker-control/angle-circle.mjs +4 -4
- package/build-module/angle-picker-control/angle-circle.mjs.map +2 -2
- package/build-module/autocomplete/index.mjs +14 -7
- package/build-module/autocomplete/index.mjs.map +2 -2
- package/build-module/clipboard-button/index.mjs +1 -1
- package/build-module/clipboard-button/index.mjs.map +2 -2
- package/build-module/color-picker/color-copy-button.mjs +1 -1
- package/build-module/color-picker/color-copy-button.mjs.map +2 -2
- package/build-module/confirm-dialog/component.mjs +2 -2
- package/build-module/confirm-dialog/component.mjs.map +2 -2
- package/build-module/context/context-system-provider.mjs.map +1 -1
- package/build-module/custom-gradient-picker/gradient-bar/control-points.mjs +2 -2
- package/build-module/custom-gradient-picker/gradient-bar/control-points.mjs.map +2 -2
- package/build-module/date-time/date/index.mjs +1 -1
- package/build-module/date-time/date/index.mjs.map +2 -2
- package/build-module/date-time/time/index.mjs +2 -2
- package/build-module/date-time/time/index.mjs.map +2 -2
- package/build-module/date-time/utils.mjs +8 -0
- package/build-module/date-time/utils.mjs.map +2 -2
- package/build-module/dropdown/index.mjs +1 -1
- package/build-module/dropdown/index.mjs.map +2 -2
- package/build-module/external-link/index.mjs +5 -1
- package/build-module/external-link/index.mjs.map +2 -2
- package/build-module/higher-order/with-spoken-messages/index.mjs.map +2 -2
- package/build-module/modal/index.mjs +2 -2
- package/build-module/modal/index.mjs.map +2 -2
- package/build-module/modal/use-modal-exit-animation.mjs +2 -2
- package/build-module/modal/use-modal-exit-animation.mjs.map +2 -2
- package/build-module/number-control/index.mjs +1 -1
- package/build-module/number-control/index.mjs.map +2 -2
- package/build-module/palette-edit/index.mjs +1 -1
- package/build-module/palette-edit/index.mjs.map +2 -2
- package/build-module/panel/body.mjs +1 -1
- package/build-module/panel/body.mjs.map +2 -2
- package/build-module/private-apis.mjs +0 -2
- package/build-module/private-apis.mjs.map +2 -2
- package/build-module/range-control/index.mjs +1 -1
- package/build-module/range-control/index.mjs.map +2 -2
- package/build-module/resizable-box/resize-tooltip/utils.mjs +1 -1
- package/build-module/resizable-box/resize-tooltip/utils.mjs.map +2 -2
- package/build-module/sandbox/index.mjs +127 -3
- package/build-module/sandbox/index.mjs.map +2 -2
- package/build-module/select-control/styles/select-control-styles.mjs +8 -8
- package/build-module/select-control/styles/select-control-styles.mjs.map +2 -2
- package/build-module/snackbar/list.mjs +4 -1
- package/build-module/snackbar/list.mjs.map +2 -2
- package/build-module/tabs/styles.mjs +5 -5
- package/build-module/tabs/styles.mjs.map +2 -2
- package/build-module/text/utils.mjs.map +1 -1
- package/build-module/toggle-group-control/toggle-group-control-option-base/styles.mjs +8 -8
- package/build-module/toggle-group-control/toggle-group-control-option-base/styles.mjs.map +2 -2
- package/build-module/tree-grid/roving-tab-index-item.mjs +1 -1
- package/build-module/tree-grid/roving-tab-index-item.mjs.map +2 -2
- package/build-module/utils/element-rect.mjs +1 -1
- package/build-module/utils/element-rect.mjs.map +2 -2
- package/build-module/utils/hooks/use-update-effect.mjs.map +1 -1
- package/build-module/utils/rtl.mjs +2 -2
- package/build-module/utils/rtl.mjs.map +2 -2
- package/build-module/utils/use-responsive-value.mjs +1 -7
- package/build-module/utils/use-responsive-value.mjs.map +2 -2
- package/build-module/validated-form-controls/control-with-error.mjs +27 -4
- package/build-module/validated-form-controls/control-with-error.mjs.map +2 -2
- package/build-module/validated-form-controls/validity-indicator.mjs +2 -0
- package/build-module/validated-form-controls/validity-indicator.mjs.map +2 -2
- package/build-style/style-rtl.css +8 -4
- package/build-style/style.css +8 -4
- package/build-types/alignment-matrix-control/styles/alignment-matrix-control-icon-styles.d.ts +19 -0
- package/build-types/alignment-matrix-control/styles/alignment-matrix-control-icon-styles.d.ts.map +1 -0
- package/build-types/alignment-matrix-control/styles/alignment-matrix-control-styles.d.ts +23 -0
- package/build-types/alignment-matrix-control/styles/alignment-matrix-control-styles.d.ts.map +1 -0
- package/build-types/angle-picker-control/angle-circle.d.ts.map +1 -1
- package/build-types/angle-picker-control/index.d.ts +1 -1
- package/build-types/angle-picker-control/stories/index.story.d.ts +1 -1
- package/build-types/angle-picker-control/styles/angle-picker-control-styles.d.ts +25 -0
- package/build-types/angle-picker-control/styles/angle-picker-control-styles.d.ts.map +1 -0
- package/build-types/animate/index.d.ts +1 -1
- package/build-types/animate/index.d.ts.map +1 -1
- package/build-types/animate/types.d.ts +1 -1
- package/build-types/animate/types.d.ts.map +1 -1
- package/build-types/autocomplete/get-autocomplete-match.d.ts +20 -0
- package/build-types/autocomplete/get-autocomplete-match.d.ts.map +1 -0
- package/build-types/autocomplete/index.d.ts +10 -2
- package/build-types/autocomplete/index.d.ts.map +1 -1
- package/build-types/autocomplete/test/get-autocomplete-match.d.ts +2 -0
- package/build-types/autocomplete/test/get-autocomplete-match.d.ts.map +1 -0
- package/build-types/autocomplete/types.d.ts +1 -1
- package/build-types/autocomplete/types.d.ts.map +1 -1
- package/build-types/badge/stories/e2e/index.story.d.ts +7 -0
- package/build-types/badge/stories/e2e/index.story.d.ts.map +1 -0
- package/build-types/base-control/index.d.ts +2 -2
- package/build-types/base-control/stories/index.story.d.ts +1 -1
- package/build-types/border-box-control/border-box-control/hook.d.ts +1 -1
- package/build-types/border-box-control/border-box-control-linked-button/hook.d.ts +1 -1
- package/build-types/border-box-control/border-box-control-split-controls/hook.d.ts +1 -1
- package/build-types/border-box-control/border-box-control-visualizer/hook.d.ts +1 -1
- package/build-types/border-control/border-control/hook.d.ts +1 -1
- package/build-types/border-control/border-control-dropdown/hook.d.ts +1 -1
- package/build-types/border-control/border-control-style-picker/hook.d.ts +267 -0
- package/build-types/border-control/border-control-style-picker/hook.d.ts.map +1 -0
- package/build-types/box-control/all-input-control.d.ts +4 -0
- package/build-types/box-control/all-input-control.d.ts.map +1 -0
- package/build-types/box-control/axial-input-controls.d.ts +4 -0
- package/build-types/box-control/axial-input-controls.d.ts.map +1 -0
- package/build-types/box-control/input-controls.d.ts +4 -0
- package/build-types/box-control/input-controls.d.ts.map +1 -0
- package/build-types/box-control/styles/box-control-styles.d.ts +2 -2
- package/build-types/box-control/styles/box-control-styles.d.ts.map +1 -1
- package/build-types/box-control/styles/box-control-visualizer-styles.d.ts +46 -0
- package/build-types/box-control/styles/box-control-visualizer-styles.d.ts.map +1 -0
- package/build-types/box-control/unit-control.d.ts +4 -0
- package/build-types/box-control/unit-control.d.ts.map +1 -0
- package/build-types/card/card/hook.d.ts +1 -1
- package/build-types/card/card-body/hook.d.ts +1 -1
- package/build-types/card/card-footer/hook.d.ts +1 -1
- package/build-types/card/card-header/hook.d.ts +1 -1
- package/build-types/card/card-media/hook.d.ts +1 -1
- package/build-types/color-palette/stories/index.story.d.ts +6 -5
- package/build-types/color-palette/stories/index.story.d.ts.map +1 -1
- package/build-types/color-palette/styles.d.ts +1 -1
- package/build-types/color-picker/color-copy-button.d.ts.map +1 -1
- package/build-types/color-picker/styles.d.ts +2 -2
- package/build-types/color-picker/styles.d.ts.map +1 -1
- package/build-types/combobox-control/styles.d.ts +1 -1
- package/build-types/context/context-connect.d.ts +2 -2
- package/build-types/context/context-connect.d.ts.map +1 -1
- package/build-types/context/context-system-provider.d.ts +2 -2
- package/build-types/context/context-system-provider.d.ts.map +1 -1
- package/build-types/context/wordpress-component.d.ts +3 -3
- package/build-types/context/wordpress-component.d.ts.map +1 -1
- package/build-types/custom-gradient-picker/gradient-bar/control-points.d.ts.map +1 -1
- package/build-types/custom-gradient-picker/styles/custom-gradient-picker-styles.d.ts +2 -2
- package/build-types/custom-gradient-picker/test/index.d.ts +2 -0
- package/build-types/custom-gradient-picker/test/index.d.ts.map +1 -0
- package/build-types/custom-gradient-picker/types.d.ts +1 -1
- package/build-types/custom-gradient-picker/types.d.ts.map +1 -1
- package/build-types/custom-select-control/styles.d.ts +11 -0
- package/build-types/custom-select-control/styles.d.ts.map +1 -0
- package/build-types/custom-select-control-v2/types.d.ts +4 -4
- package/build-types/custom-select-control-v2/types.d.ts.map +1 -1
- package/build-types/date-time/date/styles.d.ts +2 -2
- package/build-types/date-time/date-picker/index.d.ts +23 -0
- package/build-types/date-time/date-picker/index.d.ts.map +1 -0
- package/build-types/date-time/date-picker/styles.d.ts +45 -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 +2 -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 +2 -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 +169 -0
- package/build-types/date-time/date-picker/use-lilius/index.d.ts.map +1 -0
- package/build-types/date-time/date-time/styles.d.ts +1 -1
- package/build-types/date-time/time/index.d.ts.map +1 -1
- package/build-types/date-time/time-picker/index.d.ts +27 -0
- package/build-types/date-time/time-picker/index.d.ts.map +1 -0
- package/build-types/date-time/time-picker/styles.d.ts +93 -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 +2 -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 +4 -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 +2 -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 +7 -0
- package/build-types/date-time/time-picker/timezone.d.ts.map +1 -0
- package/build-types/date-time/utils.d.ts +9 -0
- package/build-types/date-time/utils.d.ts.map +1 -1
- package/build-types/dimension-control/index.d.ts +28 -0
- package/build-types/dimension-control/index.d.ts.map +1 -0
- package/build-types/dimension-control/sizes.d.ts +26 -0
- package/build-types/dimension-control/sizes.d.ts.map +1 -0
- package/build-types/dimension-control/stories/index.story.d.ts +4 -0
- package/build-types/dimension-control/stories/index.story.d.ts.map +1 -0
- package/build-types/dimension-control/types.d.ts +47 -0
- package/build-types/dimension-control/types.d.ts.map +1 -0
- package/build-types/draggable/types.d.ts +1 -1
- package/build-types/draggable/types.d.ts.map +1 -1
- package/build-types/drop-zone/types.d.ts +1 -1
- package/build-types/drop-zone/types.d.ts.map +1 -1
- package/build-types/dropdown-menu/types.d.ts +1 -1
- package/build-types/dropdown-menu/types.d.ts.map +1 -1
- package/build-types/dropdown-menu-v2/index.d.ts +17 -0
- package/build-types/dropdown-menu-v2/index.d.ts.map +1 -0
- package/build-types/dropdown-menu-v2/stories/index.story.d.ts +11 -0
- package/build-types/dropdown-menu-v2/stories/index.story.d.ts.map +1 -0
- package/build-types/dropdown-menu-v2/styles.d.ts +42 -0
- package/build-types/dropdown-menu-v2/styles.d.ts.map +1 -0
- package/build-types/dropdown-menu-v2/test/index.d.ts +2 -0
- package/build-types/dropdown-menu-v2/test/index.d.ts.map +1 -0
- package/build-types/dropdown-menu-v2/types.d.ts +252 -0
- package/build-types/dropdown-menu-v2/types.d.ts.map +1 -0
- package/build-types/elevation/hook.d.ts +1 -1
- package/build-types/external-link/index.d.ts.map +1 -1
- package/build-types/external-link/styles/external-link-styles.d.ts +10 -0
- package/build-types/external-link/styles/external-link-styles.d.ts.map +1 -0
- package/build-types/flex/flex/hook.d.ts +1 -1
- package/build-types/flex/flex-block/hook.d.ts +1 -1
- package/build-types/flex/flex-item/hook.d.ts +1 -1
- package/build-types/focal-point-picker/styles/focal-point-picker-style.d.ts +1 -1
- package/build-types/font-size-picker/stories/index.story.d.ts +8 -7
- package/build-types/font-size-picker/stories/index.story.d.ts.map +1 -1
- package/build-types/font-size-picker/styles.d.ts +2 -2
- package/build-types/form-token-field/styles.d.ts +1 -1
- package/build-types/gradient-picker/stories/index.story.d.ts +6 -5
- package/build-types/gradient-picker/stories/index.story.d.ts.map +1 -1
- package/build-types/grid/hook.d.ts +1 -1
- package/build-types/h-stack/hook.d.ts +1 -1
- package/build-types/heading/hook.d.ts +1 -1
- package/build-types/higher-order/navigate-regions/index.d.ts +1 -1
- package/build-types/higher-order/with-notices/types.d.ts +1 -1
- package/build-types/higher-order/with-notices/types.d.ts.map +1 -1
- package/build-types/higher-order/with-spoken-messages/index.d.ts +2 -3
- package/build-types/higher-order/with-spoken-messages/index.d.ts.map +1 -1
- package/build-types/icon/index.d.ts +2 -2
- package/build-types/icon/index.d.ts.map +1 -1
- package/build-types/input-control/styles/input-control-styles.d.ts +2 -2
- package/build-types/item-group/item/hook.d.ts +1 -1
- package/build-types/item-group/item-group/hook.d.ts +1 -1
- package/build-types/menu/index.d.ts +2 -2
- package/build-types/menu/item-help-text.d.ts +1 -1
- package/build-types/menu/item-label.d.ts +1 -1
- package/build-types/menu/styles.d.ts +2 -2
- package/build-types/menu-item/index.d.ts +1 -1
- package/build-types/menu-item/stories/index.story.d.ts +4 -4
- package/build-types/menu-item/types.d.ts +1 -1
- package/build-types/menu-item/types.d.ts.map +1 -1
- package/build-types/mobile/inserter-button/sparkles.d.ts +3 -0
- package/build-types/mobile/inserter-button/sparkles.d.ts.map +1 -0
- package/build-types/modal/index.d.ts.map +1 -1
- package/build-types/modal/types.d.ts +1 -1
- package/build-types/modal/types.d.ts.map +1 -1
- package/build-types/modal/use-modal-exit-animation.d.ts +1 -1
- package/build-types/navigation/styles/navigation-styles.d.ts +2 -2
- package/build-types/navigation/types.d.ts +1 -1
- package/build-types/navigation/types.d.ts.map +1 -1
- package/build-types/navigator/navigator-back-button/hook.d.ts +1 -1
- package/build-types/navigator/navigator-back-button/index.d.ts +2 -0
- package/build-types/navigator/navigator-back-button/index.d.ts.map +1 -0
- package/build-types/navigator/navigator-button/hook.d.ts +1 -1
- package/build-types/navigator/navigator-button/index.d.ts +2 -0
- package/build-types/navigator/navigator-button/index.d.ts.map +1 -0
- package/build-types/navigator/navigator-provider/component.d.ts +38 -0
- package/build-types/navigator/navigator-provider/component.d.ts.map +1 -0
- package/build-types/navigator/navigator-provider/index.d.ts +2 -0
- package/build-types/navigator/navigator-provider/index.d.ts.map +1 -0
- package/build-types/navigator/navigator-screen/index.d.ts +2 -0
- package/build-types/navigator/navigator-screen/index.d.ts.map +1 -0
- package/build-types/navigator/navigator-to-parent-button/index.d.ts +2 -0
- package/build-types/navigator/navigator-to-parent-button/index.d.ts.map +1 -0
- package/build-types/palette-edit/styles.d.ts +1 -1
- package/build-types/palette-edit/types.d.ts +1 -1
- package/build-types/palette-edit/types.d.ts.map +1 -1
- package/build-types/panel/types.d.ts +2 -2
- package/build-types/panel/types.d.ts.map +1 -1
- package/build-types/private-apis.d.ts.map +1 -1
- package/build-types/radio-group/radio/index.d.ts +7 -0
- package/build-types/radio-group/radio/index.d.ts.map +1 -0
- package/build-types/radio-group/radio-context/index.d.ts +6 -0
- package/build-types/radio-group/radio-context/index.d.ts.map +1 -0
- package/build-types/range-control/index.d.ts.map +1 -1
- package/build-types/range-control/input-range.d.ts +1 -1
- package/build-types/range-control/styles/range-control-styles.d.ts.map +1 -1
- package/build-types/range-control/types.d.ts +2 -2
- package/build-types/range-control/types.d.ts.map +1 -1
- package/build-types/resizable-box/resize-tooltip/styles/resize-tooltip.styles.d.ts +1 -1
- package/build-types/resizable-box/resize-tooltip/utils.d.ts +1 -1
- package/build-types/resizable-box/resize-tooltip/utils.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/types.d.ts +11 -0
- package/build-types/sandbox/types.d.ts.map +1 -1
- package/build-types/scrollable/hook.d.ts +1 -1
- package/build-types/search-control/types.d.ts +1 -1
- package/build-types/search-control/types.d.ts.map +1 -1
- package/build-types/select-control/styles/select-control-styles.d.ts +2 -2
- package/build-types/select-control/styles/select-control-styles.d.ts.map +1 -1
- package/build-types/slot-fill/bubbles-virtually/fill.d.ts +5 -0
- package/build-types/slot-fill/bubbles-virtually/fill.d.ts.map +1 -0
- package/build-types/slot-fill/bubbles-virtually/slot-fill-context.d.ts +12 -0
- package/build-types/slot-fill/bubbles-virtually/slot-fill-context.d.ts.map +1 -0
- package/build-types/slot-fill/bubbles-virtually/slot-fill-provider.d.ts +4 -0
- package/build-types/slot-fill/bubbles-virtually/slot-fill-provider.d.ts.map +1 -0
- package/build-types/slot-fill/bubbles-virtually/slot.d.ts +1 -1
- package/build-types/slot-fill/types.d.ts +1 -1
- package/build-types/slot-fill/types.d.ts.map +1 -1
- package/build-types/slot-fill/use-slot.d.ts +9 -0
- package/build-types/slot-fill/use-slot.d.ts.map +1 -0
- package/build-types/snackbar/index.d.ts +1 -1
- package/build-types/snackbar/list.d.ts.map +1 -1
- package/build-types/spacer/hook.d.ts +1 -1
- package/build-types/style-provider/test/index.d.ts +2 -0
- package/build-types/style-provider/test/index.d.ts.map +1 -0
- package/build-types/surface/hook.d.ts +1 -1
- package/build-types/tabs/styles.d.ts.map +1 -1
- package/build-types/text/hook.d.ts +1 -1
- package/build-types/text/stories/index.story.d.ts +3 -3
- package/build-types/text/utils.d.ts +18 -18
- package/build-types/text/utils.d.ts.map +1 -1
- package/build-types/theme/stories/index.story.d.ts +1 -1
- package/build-types/toggle-group-control/toggle-group-control-option-base/styles.d.ts.map +1 -1
- package/build-types/toggle-group-control/toggle-group-control-option-icon/component.d.ts +1 -1
- package/build-types/toggle-group-control/types.d.ts +1 -1
- package/build-types/toggle-group-control/types.d.ts.map +1 -1
- package/build-types/tools-panel/tools-panel/hook.d.ts +1 -1
- package/build-types/tools-panel/tools-panel-header/hook.d.ts +1 -1
- package/build-types/tools-panel/tools-panel-item/hook.d.ts +1 -1
- package/build-types/tree-grid/types.d.ts +1 -1
- package/build-types/tree-grid/types.d.ts.map +1 -1
- package/build-types/truncate/hook.d.ts +1 -1
- package/build-types/ui/context/constants.d.ts +8 -0
- package/build-types/ui/context/constants.d.ts.map +1 -0
- package/build-types/ui/context/context-connect.d.ts +40 -0
- package/build-types/ui/context/context-connect.d.ts.map +1 -0
- package/build-types/ui/context/context-system-provider.d.ts +7 -0
- package/build-types/ui/context/context-system-provider.d.ts.map +1 -0
- package/build-types/ui/context/get-styled-class-name-from-key.d.ts +2 -0
- package/build-types/ui/context/get-styled-class-name-from-key.d.ts.map +1 -0
- package/build-types/ui/context/index.d.ts +5 -0
- package/build-types/ui/context/index.d.ts.map +1 -0
- package/build-types/ui/context/test/context-connect.d.ts +2 -0
- package/build-types/ui/context/test/context-connect.d.ts.map +1 -0
- package/build-types/ui/context/test/wordpress-component.d.ts +2 -0
- package/build-types/ui/context/test/wordpress-component.d.ts.map +1 -0
- package/build-types/ui/context/use-context-system.d.ts +20 -0
- package/build-types/ui/context/use-context-system.d.ts.map +1 -0
- package/build-types/ui/context/utils.d.ts +26 -0
- package/build-types/ui/context/utils.d.ts.map +1 -0
- package/build-types/ui/context/wordpress-component.d.ts +32 -0
- package/build-types/ui/context/wordpress-component.d.ts.map +1 -0
- package/build-types/ui/shortcut/component.d.ts +12 -0
- package/build-types/ui/shortcut/component.d.ts.map +1 -0
- package/build-types/ui/shortcut/index.d.ts +3 -0
- package/build-types/ui/shortcut/index.d.ts.map +1 -0
- package/build-types/ui/tooltip/component.d.ts +29 -0
- package/build-types/ui/tooltip/component.d.ts.map +1 -0
- package/build-types/ui/tooltip/content.d.ts +9 -0
- package/build-types/ui/tooltip/content.d.ts.map +1 -0
- package/build-types/ui/tooltip/context.d.ts +10 -0
- package/build-types/ui/tooltip/context.d.ts.map +1 -0
- package/build-types/ui/tooltip/index.d.ts +3 -0
- package/build-types/ui/tooltip/index.d.ts.map +1 -0
- package/build-types/ui/tooltip/styles.d.ts +12 -0
- package/build-types/ui/tooltip/styles.d.ts.map +1 -0
- package/build-types/ui/tooltip/types.d.ts +62 -0
- package/build-types/ui/tooltip/types.d.ts.map +1 -0
- package/build-types/ui/utils/colors.d.ts +17 -0
- package/build-types/ui/utils/colors.d.ts.map +1 -0
- package/build-types/ui/utils/font-size.d.ts +18 -0
- package/build-types/ui/utils/font-size.d.ts.map +1 -0
- package/build-types/ui/utils/get-valid-children.d.ts +13 -0
- package/build-types/ui/utils/get-valid-children.d.ts.map +1 -0
- package/build-types/ui/utils/index.d.ts +2 -0
- package/build-types/ui/utils/index.d.ts.map +1 -0
- package/build-types/ui/utils/space.d.ts +23 -0
- package/build-types/ui/utils/space.d.ts.map +1 -0
- package/build-types/ui/utils/types.d.ts +14 -0
- package/build-types/ui/utils/types.d.ts.map +1 -0
- package/build-types/ui/utils/use-responsive-value.d.ts +5 -0
- package/build-types/ui/utils/use-responsive-value.d.ts.map +1 -0
- package/build-types/utils/hooks/use-latest-ref.d.ts +15 -0
- package/build-types/utils/hooks/use-latest-ref.d.ts.map +1 -0
- package/build-types/utils/hooks/use-update-effect.d.ts +3 -3
- package/build-types/utils/hooks/use-update-effect.d.ts.map +1 -1
- package/build-types/utils/input/base.d.ts +3 -0
- package/build-types/utils/input/base.d.ts.map +1 -0
- package/build-types/utils/input/index.d.ts +2 -0
- package/build-types/utils/input/index.d.ts.map +1 -0
- package/build-types/utils/input/input-control.d.ts +2 -0
- package/build-types/utils/input/input-control.d.ts.map +1 -0
- package/build-types/utils/reduce-motion.d.ts +8 -0
- package/build-types/utils/reduce-motion.d.ts.map +1 -0
- package/build-types/utils/rtl.d.ts +4 -4
- package/build-types/utils/rtl.d.ts.map +1 -1
- package/build-types/utils/use-responsive-value.d.ts.map +1 -1
- package/build-types/utils/z-index.d.ts +3 -0
- package/build-types/utils/z-index.d.ts.map +1 -0
- package/build-types/v-stack/hook.d.ts +1 -1
- package/build-types/v-stack/stories/index.story.d.ts +1 -1
- package/build-types/validated-form-controls/components/range-control.d.ts.map +1 -1
- package/build-types/validated-form-controls/components/stories/overview.story.d.ts.map +1 -1
- package/build-types/validated-form-controls/control-with-error.d.ts.map +1 -1
- package/build-types/validated-form-controls/test/checkbox-control.d.ts +2 -0
- package/build-types/validated-form-controls/test/checkbox-control.d.ts.map +1 -0
- package/build-types/validated-form-controls/test/combobox-control.d.ts +2 -0
- package/build-types/validated-form-controls/test/combobox-control.d.ts.map +1 -0
- package/build-types/validated-form-controls/test/custom-select-control.d.ts +2 -0
- package/build-types/validated-form-controls/test/custom-select-control.d.ts.map +1 -0
- package/build-types/validated-form-controls/test/form-token-field.d.ts +2 -0
- package/build-types/validated-form-controls/test/form-token-field.d.ts.map +1 -0
- package/build-types/validated-form-controls/test/input-control.d.ts +2 -0
- package/build-types/validated-form-controls/test/input-control.d.ts.map +1 -0
- package/build-types/validated-form-controls/test/number-control.d.ts +2 -0
- package/build-types/validated-form-controls/test/number-control.d.ts.map +1 -0
- package/build-types/validated-form-controls/test/radio-control.d.ts +2 -0
- package/build-types/validated-form-controls/test/radio-control.d.ts.map +1 -0
- package/build-types/validated-form-controls/test/range-control.d.ts +2 -0
- package/build-types/validated-form-controls/test/range-control.d.ts.map +1 -0
- package/build-types/validated-form-controls/test/select-control.d.ts +2 -0
- package/build-types/validated-form-controls/test/select-control.d.ts.map +1 -0
- package/build-types/validated-form-controls/test/text-control.d.ts +2 -0
- package/build-types/validated-form-controls/test/text-control.d.ts.map +1 -0
- package/build-types/validated-form-controls/test/textarea-control.d.ts +2 -0
- package/build-types/validated-form-controls/test/textarea-control.d.ts.map +1 -0
- package/build-types/validated-form-controls/test/toggle-control.d.ts +2 -0
- package/build-types/validated-form-controls/test/toggle-control.d.ts.map +1 -0
- package/build-types/validated-form-controls/test/toggle-group-control.d.ts +2 -0
- package/build-types/validated-form-controls/test/toggle-group-control.d.ts.map +1 -0
- package/build-types/validated-form-controls/validity-indicator.d.ts +2 -1
- package/build-types/validated-form-controls/validity-indicator.d.ts.map +1 -1
- package/build-types/view/types.d.ts +8 -0
- package/build-types/view/types.d.ts.map +1 -0
- package/package.json +24 -24
- package/src/alignment-matrix-control/test/index.tsx +1 -1
- package/src/angle-picker-control/angle-circle.tsx +6 -5
- package/src/animate/types.ts +1 -1
- package/src/autocomplete/autocompleter-ui.tsx +1 -1
- package/src/autocomplete/index.tsx +33 -8
- package/src/autocomplete/test/index.tsx +110 -1
- package/src/autocomplete/types.ts +1 -1
- package/src/button/style.scss +8 -5
- package/src/calendar/style.scss +4 -2
- package/src/clipboard-button/index.tsx +1 -1
- package/src/color-palette/stories/index.story.tsx +56 -48
- package/src/color-picker/color-copy-button.tsx +1 -3
- package/src/composite/stories/index.story.tsx +1 -1
- package/src/confirm-dialog/component.tsx +2 -2
- package/src/context/context-connect.ts +3 -3
- package/src/context/context-system-provider.js +4 -4
- package/src/context/wordpress-component.ts +3 -5
- package/src/custom-gradient-picker/gradient-bar/control-points.tsx +3 -2
- package/src/custom-gradient-picker/types.ts +1 -1
- package/src/custom-select-control-v2/custom-select.tsx +1 -1
- package/src/custom-select-control-v2/stories/index.story.tsx +3 -3
- package/src/custom-select-control-v2/test/index.tsx +3 -3
- package/src/custom-select-control-v2/types.ts +4 -4
- package/src/date-time/date/index.tsx +1 -1
- package/src/date-time/test/utils.test.ts +8 -11
- package/src/date-time/time/index.tsx +2 -12
- package/src/date-time/time/test/index.tsx +69 -0
- package/src/date-time/utils.ts +18 -0
- package/src/draggable/index.native.js +17 -17
- package/src/draggable/types.ts +1 -1
- package/src/drop-zone/types.ts +1 -1
- package/src/dropdown/index.tsx +1 -1
- package/src/dropdown-menu/types.ts +1 -1
- package/src/external-link/index.tsx +5 -1
- package/src/font-size-picker/stories/index.story.tsx +133 -125
- package/src/form-token-field/style.scss +1 -0
- package/src/gradient-picker/stories/index.story.tsx +48 -42
- package/src/h-stack/test/index.tsx +1 -1
- package/src/heading/hook.ts +2 -2
- package/src/higher-order/with-notices/test/index.tsx +2 -2
- package/src/higher-order/with-notices/types.ts +1 -1
- package/src/higher-order/with-spoken-messages/index.tsx +2 -4
- package/src/icon/index.tsx +2 -2
- package/src/keyboard-shortcuts/index.tsx +1 -1
- package/src/menu/stories/index.story.tsx +1 -1
- package/src/menu-item/types.ts +1 -1
- package/src/modal/index.tsx +4 -3
- package/src/modal/types.ts +1 -1
- package/src/modal/use-modal-exit-animation.ts +2 -2
- package/src/navigation/README.md +1 -1
- package/src/navigation/types.ts +1 -1
- package/src/number-control/index.tsx +1 -1
- package/src/palette-edit/index.tsx +2 -2
- package/src/palette-edit/types.ts +1 -1
- package/src/panel/README.md +1 -1
- package/src/panel/body.tsx +1 -1
- package/src/panel/types.ts +2 -2
- package/src/popover/stories/index.story.tsx +1 -1
- package/src/private-apis.ts +0 -2
- package/src/radio-control/test/index.tsx +5 -4
- package/src/range-control/index.tsx +1 -1
- package/src/range-control/types.ts +2 -2
- package/src/resizable-box/index.tsx +1 -1
- package/src/resizable-box/resize-tooltip/index.tsx +1 -1
- package/src/resizable-box/resize-tooltip/label.tsx +1 -1
- package/src/resizable-box/resize-tooltip/utils.ts +2 -2
- package/src/sandbox/index.tsx +190 -10
- package/src/sandbox/test/index.tsx +65 -24
- package/src/sandbox/types.ts +11 -0
- package/src/search-control/types.ts +1 -1
- package/src/select-control/styles/select-control-styles.ts +1 -0
- package/src/slot-fill/types.ts +1 -1
- package/src/snackbar/list.tsx +7 -2
- package/src/tabs/styles.ts +1 -0
- package/src/text/utils.ts +18 -18
- package/src/toggle-group-control/test/__snapshots__/index.tsx.snap +18 -16
- package/src/toggle-group-control/toggle-group-control-option-base/component.tsx +1 -1
- package/src/toggle-group-control/toggle-group-control-option-base/styles.ts +4 -6
- package/src/toggle-group-control/types.ts +1 -1
- package/src/tree-grid/roving-tab-index-item.tsx +1 -1
- package/src/tree-grid/types.ts +1 -1
- package/src/utils/element-rect.ts +1 -1
- package/src/utils/hooks/use-update-effect.js +2 -2
- package/src/utils/rtl.js +4 -4
- package/src/utils/use-responsive-value.ts +1 -5
- package/src/v-stack/test/index.tsx +1 -1
- package/src/validated-form-controls/components/stories/overview.story.tsx +2 -1
- package/src/validated-form-controls/control-with-error.tsx +44 -4
- package/src/validated-form-controls/test/checkbox-control.tsx +49 -0
- package/src/validated-form-controls/test/combobox-control.tsx +61 -0
- package/src/validated-form-controls/test/control-with-error.tsx +182 -1
- package/src/validated-form-controls/test/custom-select-control.tsx +60 -0
- package/src/validated-form-controls/test/form-token-field.tsx +52 -0
- package/src/validated-form-controls/test/input-control.tsx +42 -0
- package/src/validated-form-controls/test/number-control.tsx +44 -0
- package/src/validated-form-controls/test/radio-control.tsx +61 -0
- package/src/validated-form-controls/test/range-control.tsx +73 -0
- package/src/validated-form-controls/test/select-control.tsx +57 -0
- package/src/validated-form-controls/test/text-control.tsx +49 -0
- package/src/validated-form-controls/test/textarea-control.tsx +51 -0
- package/src/validated-form-controls/test/toggle-control.tsx +49 -0
- package/src/validated-form-controls/test/toggle-group-control.tsx +28 -0
- package/src/validated-form-controls/validity-indicator.tsx +3 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/modal/use-modal-exit-animation.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useReducedMotion } from '@wordpress/compose';\nimport { useCallback, useRef, useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { CONFIG } from '../utils';\
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAAiC;AACjC,qBAA8C;
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useReducedMotion } from '@wordpress/compose';\nimport { useCallback, useRef, useState } from '@wordpress/element';\nimport warning from '@wordpress/warning';\n\n/**\n * Internal dependencies\n */\nimport { CONFIG } from '../utils';\n\n// Animation duration (ms) extracted to JS in order to be used on a setTimeout.\nconst FRAME_ANIMATION_DURATION = CONFIG.transitionDuration;\nconst FRAME_ANIMATION_DURATION_NUMBER = Number.parseInt(CONFIG.transitionDuration);\nconst EXIT_ANIMATION_NAME = 'components-modal__disappear-animation';\nexport function useModalExitAnimation() {\n const frameRef = useRef(null);\n const [isAnimatingOut, setIsAnimatingOut] = useState(false);\n const isReducedMotion = useReducedMotion();\n const closeModal = useCallback(() => new Promise(closeModalResolve => {\n // Grab a \"stable\" reference of the frame element, since\n // the value held by the react ref might change at runtime.\n const frameEl = frameRef.current;\n if (isReducedMotion) {\n closeModalResolve();\n return;\n }\n if (!frameEl) {\n globalThis.SCRIPT_DEBUG === true ? warning(\"wp.components.Modal: the Modal component can't be closed with an exit animation because of a missing reference to the modal frame element.\") : void 0;\n closeModalResolve();\n return;\n }\n let handleAnimationEnd;\n const startAnimation = () => new Promise(animationResolve => {\n handleAnimationEnd = e => {\n if (e.animationName === EXIT_ANIMATION_NAME) {\n animationResolve();\n }\n };\n frameEl.addEventListener('animationend', handleAnimationEnd);\n setIsAnimatingOut(true);\n });\n const animationTimeout = () => new Promise(timeoutResolve => {\n setTimeout(() => timeoutResolve(),\n // Allow an extra 20% of the animation duration for the\n // animationend event to fire, in case the animation frame is\n // slightly delayes by some other events in the event loop.\n FRAME_ANIMATION_DURATION_NUMBER * 1.2);\n });\n Promise.race([startAnimation(), animationTimeout()]).then(() => {\n if (handleAnimationEnd) {\n frameEl.removeEventListener('animationend', handleAnimationEnd);\n }\n setIsAnimatingOut(false);\n closeModalResolve();\n });\n }), [isReducedMotion]);\n return {\n overlayClassname: isAnimatingOut ? 'is-animating-out' : undefined,\n frameRef,\n frameStyle: {\n '--modal-frame-animation-duration': `${FRAME_ANIMATION_DURATION}`\n },\n closeModal\n };\n}"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAAiC;AACjC,qBAA8C;AAC9C,qBAAoB;AAKpB,mBAAuB;AAGvB,IAAM,2BAA2B,oBAAO;AACxC,IAAM,kCAAkC,OAAO,SAAS,oBAAO,kBAAkB;AACjF,IAAM,sBAAsB;AACrB,SAAS,wBAAwB;AACtC,QAAM,eAAW,uBAAO,IAAI;AAC5B,QAAM,CAAC,gBAAgB,iBAAiB,QAAI,yBAAS,KAAK;AAC1D,QAAM,sBAAkB,iCAAiB;AACzC,QAAM,iBAAa,4BAAY,MAAM,IAAI,QAAQ,uBAAqB;AAGpE,UAAM,UAAU,SAAS;AACzB,QAAI,iBAAiB;AACnB,wBAAkB;AAClB;AAAA,IACF;AACA,QAAI,CAAC,SAAS;AACZ,iBAAW,iBAAiB,WAAO,eAAAA,SAAQ,4IAA4I,IAAI;AAC3L,wBAAkB;AAClB;AAAA,IACF;AACA,QAAI;AACJ,UAAM,iBAAiB,MAAM,IAAI,QAAQ,sBAAoB;AAC3D,2BAAqB,OAAK;AACxB,YAAI,EAAE,kBAAkB,qBAAqB;AAC3C,2BAAiB;AAAA,QACnB;AAAA,MACF;AACA,cAAQ,iBAAiB,gBAAgB,kBAAkB;AAC3D,wBAAkB,IAAI;AAAA,IACxB,CAAC;AACD,UAAM,mBAAmB,MAAM,IAAI,QAAQ,oBAAkB;AAC3D;AAAA,QAAW,MAAM,eAAe;AAAA;AAAA;AAAA;AAAA,QAIhC,kCAAkC;AAAA,MAAG;AAAA,IACvC,CAAC;AACD,YAAQ,KAAK,CAAC,eAAe,GAAG,iBAAiB,CAAC,CAAC,EAAE,KAAK,MAAM;AAC9D,UAAI,oBAAoB;AACtB,gBAAQ,oBAAoB,gBAAgB,kBAAkB;AAAA,MAChE;AACA,wBAAkB,KAAK;AACvB,wBAAkB;AAAA,IACpB,CAAC;AAAA,EACH,CAAC,GAAG,CAAC,eAAe,CAAC;AACrB,SAAO;AAAA,IACL,kBAAkB,iBAAiB,qBAAqB;AAAA,IACxD;AAAA,IACA,YAAY;AAAA,MACV,oCAAoC,GAAG,wBAAwB;AAAA,IACjE;AAAA,IACA;AAAA,EACF;AACF;",
|
|
6
6
|
"names": ["warning"]
|
|
7
7
|
}
|
|
@@ -89,7 +89,7 @@ function UnforwardedNumberControl(props, forwardedRef) {
|
|
|
89
89
|
version: "6.3"
|
|
90
90
|
});
|
|
91
91
|
}
|
|
92
|
-
const inputRef = (0, import_element.useRef)();
|
|
92
|
+
const inputRef = (0, import_element.useRef)(null);
|
|
93
93
|
const mergedRef = (0, import_compose.useMergeRefs)([inputRef, forwardedRef]);
|
|
94
94
|
const isStepAny = step === "any";
|
|
95
95
|
const baseStep = isStepAny ? 1 : (0, import_values.ensureNumber)(step);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/number-control/index.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n/**\n * WordPress dependencies\n */\nimport { useRef, forwardRef } from '@wordpress/element';\nimport { isRTL, __ } from '@wordpress/i18n';\nimport { plus as plusIcon, reset as resetIcon } from '@wordpress/icons';\nimport { useMergeRefs } from '@wordpress/compose';\nimport deprecated from '@wordpress/deprecated';\n\n/**\n * Internal dependencies\n */\nimport { Input, SpinButton, styles } from './styles/number-control-styles';\nimport * as inputControlActionTypes from '../input-control/reducer/actions';\nimport { add, subtract, clamp, ensureValidStep } from '../utils/math';\nimport { ensureNumber, isValueEmpty } from '../utils/values';\nimport { HStack } from '../h-stack';\nimport { Spacer } from '../spacer';\nimport { useCx } from '../utils';\nimport { useDeprecated36pxDefaultSizeProp } from '../utils/use-deprecated-props';\nimport { maybeWarnDeprecated36pxSize } from '../utils/deprecated-36px-size';\nimport { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from \"react/jsx-runtime\";\nconst noop = () => {};\nfunction UnforwardedNumberControl(props, forwardedRef) {\n const {\n __unstableStateReducer: stateReducerProp,\n className,\n dragDirection = 'n',\n hideHTMLArrows = false,\n spinControls = hideHTMLArrows ? 'none' : 'native',\n isDragEnabled = true,\n isShiftStepEnabled = true,\n label,\n max = Infinity,\n min = -Infinity,\n required = false,\n shiftStep = 10,\n step = 1,\n spinFactor = 1,\n type: typeProp = 'number',\n value: valueProp,\n size = 'default',\n suffix,\n onChange = noop,\n __shouldNotWarnDeprecated36pxSize,\n ...restProps\n } = useDeprecated36pxDefaultSizeProp(props);\n maybeWarnDeprecated36pxSize({\n componentName: 'NumberControl',\n size,\n __next40pxDefaultSize: restProps.__next40pxDefaultSize,\n __shouldNotWarnDeprecated36pxSize\n });\n if (hideHTMLArrows) {\n deprecated('wp.components.NumberControl hideHTMLArrows prop ', {\n alternative: 'spinControls=\"none\"',\n since: '6.2',\n version: '6.3'\n });\n }\n const inputRef = useRef();\n const mergedRef = useMergeRefs([inputRef, forwardedRef]);\n const isStepAny = step === 'any';\n const baseStep = isStepAny ? 1 : ensureNumber(step);\n const baseSpin = ensureNumber(spinFactor) * baseStep;\n const constrainValue = (value, stepOverride) => {\n // When step is not \"any\" the value must be a valid step.\n if (!isStepAny) {\n value = ensureValidStep(value, min, stepOverride ?? baseStep);\n }\n return `${clamp(value, min, max)}`;\n };\n const baseValue = constrainValue(0);\n const autoComplete = typeProp === 'number' ? 'off' : undefined;\n const classes = clsx('components-number-control', className);\n const cx = useCx();\n const spinButtonClasses = cx(size === 'small' && styles.smallSpinButtons);\n const spinValue = (value, direction, event) => {\n event?.preventDefault();\n const shift = event?.shiftKey && isShiftStepEnabled;\n const delta = shift ? ensureNumber(shiftStep) * baseSpin : baseSpin;\n let nextValue = isValueEmpty(value) ? baseValue : value;\n if (direction === 'up') {\n nextValue = add(nextValue, delta);\n } else if (direction === 'down') {\n nextValue = subtract(nextValue, delta);\n }\n return constrainValue(nextValue, shift ? delta : undefined);\n };\n\n /**\n * \"Middleware\" function that intercepts updates from InputControl.\n * This allows us to tap into actions to transform the (next) state for\n * InputControl.\n *\n * @return The updated state to apply to InputControl\n */\n const numberControlStateReducer = (state, action) => {\n const nextState = {\n ...state\n };\n const {\n type,\n payload\n } = action;\n const event = payload.event;\n const currentValue = nextState.value;\n\n /**\n * Handles custom UP and DOWN Keyboard events\n */\n if (type === inputControlActionTypes.PRESS_UP || type === inputControlActionTypes.PRESS_DOWN) {\n nextState.value = spinValue(currentValue, type === inputControlActionTypes.PRESS_UP ? 'up' : 'down', event);\n }\n\n /**\n * Handles drag to update events\n */\n if (type === inputControlActionTypes.DRAG && isDragEnabled) {\n const [x, y] = payload.delta;\n const enableShift = payload.shiftKey && isShiftStepEnabled;\n const modifier = enableShift ? ensureNumber(shiftStep) * baseSpin : baseSpin;\n let directionModifier;\n let delta;\n switch (dragDirection) {\n case 'n':\n delta = y;\n directionModifier = -1;\n break;\n case 'e':\n delta = x;\n directionModifier = isRTL() ? -1 : 1;\n break;\n case 's':\n delta = y;\n directionModifier = 1;\n break;\n case 'w':\n delta = x;\n directionModifier = isRTL() ? 1 : -1;\n break;\n }\n if (delta !== 0) {\n delta = Math.ceil(Math.abs(delta)) * Math.sign(delta);\n const distance = delta * modifier * directionModifier;\n nextState.value = constrainValue(\n // @ts-expect-error TODO: Investigate if it's ok for currentValue to be undefined\n add(currentValue, distance), enableShift ? modifier : undefined);\n }\n }\n\n /**\n * Handles commit (ENTER key press or blur)\n */\n if (type === inputControlActionTypes.PRESS_ENTER || type === inputControlActionTypes.COMMIT) {\n const applyEmptyValue = required === false && currentValue === '';\n nextState.value = applyEmptyValue ? currentValue :\n // @ts-expect-error TODO: Investigate if it's ok for currentValue to be undefined\n constrainValue(currentValue);\n }\n return nextState;\n };\n const buildSpinButtonClickHandler = direction => event => onChange(String(spinValue(valueProp, direction, event)), {\n // Set event.target to the <input> so that consumers can use\n // e.g. event.target.validity.\n event: {\n ...event,\n target: inputRef.current\n }\n });\n return /*#__PURE__*/_jsx(Input, {\n autoComplete: autoComplete,\n inputMode: \"numeric\",\n ...restProps,\n className: classes,\n dragDirection: dragDirection,\n hideHTMLArrows: spinControls !== 'native',\n isDragEnabled: isDragEnabled,\n label: label,\n max: max === Infinity ? undefined : max,\n min: min === -Infinity ? undefined : min,\n ref: mergedRef,\n required: required,\n step: step,\n type: typeProp\n // @ts-expect-error TODO: Resolve discrepancy between `value` types in InputControl based components\n ,\n value: valueProp,\n __unstableStateReducer: (state, action) => {\n const baseState = numberControlStateReducer(state, action);\n return stateReducerProp?.(baseState, action) ?? baseState;\n },\n size: size,\n __shouldNotWarnDeprecated36pxSize: true,\n suffix: spinControls === 'custom' ? /*#__PURE__*/_jsxs(_Fragment, {\n children: [suffix, /*#__PURE__*/_jsx(Spacer, {\n marginBottom: 0,\n marginRight: 2,\n children: /*#__PURE__*/_jsxs(HStack, {\n spacing: 1,\n children: [/*#__PURE__*/_jsx(SpinButton, {\n className: spinButtonClasses,\n icon: plusIcon,\n size: \"small\",\n label: __('Increment'),\n onClick: buildSpinButtonClickHandler('up')\n }), /*#__PURE__*/_jsx(SpinButton, {\n className: spinButtonClasses,\n icon: resetIcon,\n size: \"small\",\n label: __('Decrement'),\n onClick: buildSpinButtonClickHandler('down')\n })]\n })\n })]\n }) : suffix,\n onChange: onChange\n });\n}\nexport const NumberControl = forwardRef(UnforwardedNumberControl);\nNumberControl.displayName = 'NumberControl';\nexport default NumberControl;"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAiB;AAIjB,qBAAmC;AACnC,kBAA0B;AAC1B,mBAAqD;AACrD,qBAA6B;AAC7B,wBAAuB;AAKvB,mCAA0C;AAC1C,8BAAyC;AACzC,kBAAsD;AACtD,oBAA2C;AAC3C,qBAAuB;AACvB,oBAAuB;AACvB,mBAAsB;AACtB,kCAAiD;AACjD,kCAA4C;AAC5C,yBAAkE;AAClE,IAAM,OAAO,MAAM;AAAC;AACpB,SAAS,yBAAyB,OAAO,cAAc;AACrD,QAAM;AAAA,IACJ,wBAAwB;AAAA,IACxB;AAAA,IACA,gBAAgB;AAAA,IAChB,iBAAiB;AAAA,IACjB,eAAe,iBAAiB,SAAS;AAAA,IACzC,gBAAgB;AAAA,IAChB,qBAAqB;AAAA,IACrB;AAAA,IACA,MAAM;AAAA,IACN,MAAM;AAAA,IACN,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,OAAO;AAAA,IACP,aAAa;AAAA,IACb,MAAM,WAAW;AAAA,IACjB,OAAO;AAAA,IACP,OAAO;AAAA,IACP;AAAA,IACA,WAAW;AAAA,IACX;AAAA,IACA,GAAG;AAAA,EACL,QAAI,8DAAiC,KAAK;AAC1C,+DAA4B;AAAA,IAC1B,eAAe;AAAA,IACf;AAAA,IACA,uBAAuB,UAAU;AAAA,IACjC;AAAA,EACF,CAAC;AACD,MAAI,gBAAgB;AAClB,0BAAAA,SAAW,oDAAoD;AAAA,MAC7D,aAAa;AAAA,MACb,OAAO;AAAA,MACP,SAAS;AAAA,IACX,CAAC;AAAA,EACH;AACA,QAAM,eAAW,uBAAO;
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n/**\n * WordPress dependencies\n */\nimport { useRef, forwardRef } from '@wordpress/element';\nimport { isRTL, __ } from '@wordpress/i18n';\nimport { plus as plusIcon, reset as resetIcon } from '@wordpress/icons';\nimport { useMergeRefs } from '@wordpress/compose';\nimport deprecated from '@wordpress/deprecated';\n\n/**\n * Internal dependencies\n */\nimport { Input, SpinButton, styles } from './styles/number-control-styles';\nimport * as inputControlActionTypes from '../input-control/reducer/actions';\nimport { add, subtract, clamp, ensureValidStep } from '../utils/math';\nimport { ensureNumber, isValueEmpty } from '../utils/values';\nimport { HStack } from '../h-stack';\nimport { Spacer } from '../spacer';\nimport { useCx } from '../utils';\nimport { useDeprecated36pxDefaultSizeProp } from '../utils/use-deprecated-props';\nimport { maybeWarnDeprecated36pxSize } from '../utils/deprecated-36px-size';\nimport { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from \"react/jsx-runtime\";\nconst noop = () => {};\nfunction UnforwardedNumberControl(props, forwardedRef) {\n const {\n __unstableStateReducer: stateReducerProp,\n className,\n dragDirection = 'n',\n hideHTMLArrows = false,\n spinControls = hideHTMLArrows ? 'none' : 'native',\n isDragEnabled = true,\n isShiftStepEnabled = true,\n label,\n max = Infinity,\n min = -Infinity,\n required = false,\n shiftStep = 10,\n step = 1,\n spinFactor = 1,\n type: typeProp = 'number',\n value: valueProp,\n size = 'default',\n suffix,\n onChange = noop,\n __shouldNotWarnDeprecated36pxSize,\n ...restProps\n } = useDeprecated36pxDefaultSizeProp(props);\n maybeWarnDeprecated36pxSize({\n componentName: 'NumberControl',\n size,\n __next40pxDefaultSize: restProps.__next40pxDefaultSize,\n __shouldNotWarnDeprecated36pxSize\n });\n if (hideHTMLArrows) {\n deprecated('wp.components.NumberControl hideHTMLArrows prop ', {\n alternative: 'spinControls=\"none\"',\n since: '6.2',\n version: '6.3'\n });\n }\n const inputRef = useRef(null);\n const mergedRef = useMergeRefs([inputRef, forwardedRef]);\n const isStepAny = step === 'any';\n const baseStep = isStepAny ? 1 : ensureNumber(step);\n const baseSpin = ensureNumber(spinFactor) * baseStep;\n const constrainValue = (value, stepOverride) => {\n // When step is not \"any\" the value must be a valid step.\n if (!isStepAny) {\n value = ensureValidStep(value, min, stepOverride ?? baseStep);\n }\n return `${clamp(value, min, max)}`;\n };\n const baseValue = constrainValue(0);\n const autoComplete = typeProp === 'number' ? 'off' : undefined;\n const classes = clsx('components-number-control', className);\n const cx = useCx();\n const spinButtonClasses = cx(size === 'small' && styles.smallSpinButtons);\n const spinValue = (value, direction, event) => {\n event?.preventDefault();\n const shift = event?.shiftKey && isShiftStepEnabled;\n const delta = shift ? ensureNumber(shiftStep) * baseSpin : baseSpin;\n let nextValue = isValueEmpty(value) ? baseValue : value;\n if (direction === 'up') {\n nextValue = add(nextValue, delta);\n } else if (direction === 'down') {\n nextValue = subtract(nextValue, delta);\n }\n return constrainValue(nextValue, shift ? delta : undefined);\n };\n\n /**\n * \"Middleware\" function that intercepts updates from InputControl.\n * This allows us to tap into actions to transform the (next) state for\n * InputControl.\n *\n * @return The updated state to apply to InputControl\n */\n const numberControlStateReducer = (state, action) => {\n const nextState = {\n ...state\n };\n const {\n type,\n payload\n } = action;\n const event = payload.event;\n const currentValue = nextState.value;\n\n /**\n * Handles custom UP and DOWN Keyboard events\n */\n if (type === inputControlActionTypes.PRESS_UP || type === inputControlActionTypes.PRESS_DOWN) {\n nextState.value = spinValue(currentValue, type === inputControlActionTypes.PRESS_UP ? 'up' : 'down', event);\n }\n\n /**\n * Handles drag to update events\n */\n if (type === inputControlActionTypes.DRAG && isDragEnabled) {\n const [x, y] = payload.delta;\n const enableShift = payload.shiftKey && isShiftStepEnabled;\n const modifier = enableShift ? ensureNumber(shiftStep) * baseSpin : baseSpin;\n let directionModifier;\n let delta;\n switch (dragDirection) {\n case 'n':\n delta = y;\n directionModifier = -1;\n break;\n case 'e':\n delta = x;\n directionModifier = isRTL() ? -1 : 1;\n break;\n case 's':\n delta = y;\n directionModifier = 1;\n break;\n case 'w':\n delta = x;\n directionModifier = isRTL() ? 1 : -1;\n break;\n }\n if (delta !== 0) {\n delta = Math.ceil(Math.abs(delta)) * Math.sign(delta);\n const distance = delta * modifier * directionModifier;\n nextState.value = constrainValue(\n // @ts-expect-error TODO: Investigate if it's ok for currentValue to be undefined\n add(currentValue, distance), enableShift ? modifier : undefined);\n }\n }\n\n /**\n * Handles commit (ENTER key press or blur)\n */\n if (type === inputControlActionTypes.PRESS_ENTER || type === inputControlActionTypes.COMMIT) {\n const applyEmptyValue = required === false && currentValue === '';\n nextState.value = applyEmptyValue ? currentValue :\n // @ts-expect-error TODO: Investigate if it's ok for currentValue to be undefined\n constrainValue(currentValue);\n }\n return nextState;\n };\n const buildSpinButtonClickHandler = direction => event => onChange(String(spinValue(valueProp, direction, event)), {\n // Set event.target to the <input> so that consumers can use\n // e.g. event.target.validity.\n event: {\n ...event,\n target: inputRef.current\n }\n });\n return /*#__PURE__*/_jsx(Input, {\n autoComplete: autoComplete,\n inputMode: \"numeric\",\n ...restProps,\n className: classes,\n dragDirection: dragDirection,\n hideHTMLArrows: spinControls !== 'native',\n isDragEnabled: isDragEnabled,\n label: label,\n max: max === Infinity ? undefined : max,\n min: min === -Infinity ? undefined : min,\n ref: mergedRef,\n required: required,\n step: step,\n type: typeProp\n // @ts-expect-error TODO: Resolve discrepancy between `value` types in InputControl based components\n ,\n value: valueProp,\n __unstableStateReducer: (state, action) => {\n const baseState = numberControlStateReducer(state, action);\n return stateReducerProp?.(baseState, action) ?? baseState;\n },\n size: size,\n __shouldNotWarnDeprecated36pxSize: true,\n suffix: spinControls === 'custom' ? /*#__PURE__*/_jsxs(_Fragment, {\n children: [suffix, /*#__PURE__*/_jsx(Spacer, {\n marginBottom: 0,\n marginRight: 2,\n children: /*#__PURE__*/_jsxs(HStack, {\n spacing: 1,\n children: [/*#__PURE__*/_jsx(SpinButton, {\n className: spinButtonClasses,\n icon: plusIcon,\n size: \"small\",\n label: __('Increment'),\n onClick: buildSpinButtonClickHandler('up')\n }), /*#__PURE__*/_jsx(SpinButton, {\n className: spinButtonClasses,\n icon: resetIcon,\n size: \"small\",\n label: __('Decrement'),\n onClick: buildSpinButtonClickHandler('down')\n })]\n })\n })]\n }) : suffix,\n onChange: onChange\n });\n}\nexport const NumberControl = forwardRef(UnforwardedNumberControl);\nNumberControl.displayName = 'NumberControl';\nexport default NumberControl;"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAiB;AAIjB,qBAAmC;AACnC,kBAA0B;AAC1B,mBAAqD;AACrD,qBAA6B;AAC7B,wBAAuB;AAKvB,mCAA0C;AAC1C,8BAAyC;AACzC,kBAAsD;AACtD,oBAA2C;AAC3C,qBAAuB;AACvB,oBAAuB;AACvB,mBAAsB;AACtB,kCAAiD;AACjD,kCAA4C;AAC5C,yBAAkE;AAClE,IAAM,OAAO,MAAM;AAAC;AACpB,SAAS,yBAAyB,OAAO,cAAc;AACrD,QAAM;AAAA,IACJ,wBAAwB;AAAA,IACxB;AAAA,IACA,gBAAgB;AAAA,IAChB,iBAAiB;AAAA,IACjB,eAAe,iBAAiB,SAAS;AAAA,IACzC,gBAAgB;AAAA,IAChB,qBAAqB;AAAA,IACrB;AAAA,IACA,MAAM;AAAA,IACN,MAAM;AAAA,IACN,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,OAAO;AAAA,IACP,aAAa;AAAA,IACb,MAAM,WAAW;AAAA,IACjB,OAAO;AAAA,IACP,OAAO;AAAA,IACP;AAAA,IACA,WAAW;AAAA,IACX;AAAA,IACA,GAAG;AAAA,EACL,QAAI,8DAAiC,KAAK;AAC1C,+DAA4B;AAAA,IAC1B,eAAe;AAAA,IACf;AAAA,IACA,uBAAuB,UAAU;AAAA,I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
"names": ["deprecated", "clsx", "_jsx", "_jsxs", "_Fragment", "plusIcon", "resetIcon"]
|
|
7
7
|
}
|
|
@@ -240,7 +240,7 @@ function PaletteEditListView({
|
|
|
240
240
|
popoverProps,
|
|
241
241
|
addColorRef
|
|
242
242
|
}) {
|
|
243
|
-
const elementsReferenceRef = (0, import_element.useRef)();
|
|
243
|
+
const elementsReferenceRef = (0, import_element.useRef)(void 0);
|
|
244
244
|
(0, import_element.useEffect)(() => {
|
|
245
245
|
elementsReferenceRef.current = elements;
|
|
246
246
|
}, [elements]);
|
|
@@ -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();\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": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAiB;AAKjB,qBAAkE;AAClE,kBAA4B;AAC5B,mBAA8C;AAC9C,qBAA4B;AAK5B,oBAAmB;AACnB,0BAA4B;AAC5B,kBAAoC;AACpC,qBAAuB;AACvB,wBAAgC;AAChC,qBAAuB;AACvB,6BAA2B;AAC3B,2BAAyB;AACzB,2BAAyB;AACzB,qBAAoB;AACpB,oBAA4K;AAC5K,iCAA8B;AAC9B,uBAAiC;AACjC,oCAAiC;AACjC,qBAA0B;AAC1B,yBAAkE;AAClE,IAAM,gBAAgB;AACtB,SAAS,UAAU;AAAA,EACjB;AAAA,EACA;AAAA,EACA;AACF,GAAG;AACD,SAAoB,uCAAAA,KAAK,gCAAkB;AAAA,IACzC,MAAM;AAAA,IACN;AAAA,IACA,qBAAqB;AAAA,IACrB;AAAA,IACA;AAAA,EACF,CAAC;AACH;AAKO,SAAS,wBAAwB,UAAU;AAChD,QAAM,aAAa,CAAC;AACpB,SAAO,SAAS,IAAI,aAAW;AAC7B,QAAI;AACJ,UAAM;AAAA,MACJ;AAAA,IACF,IAAI;AACJ,eAAW,IAAI,KAAK,WAAW,IAAI,KAAK,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*/\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": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AC,GAAG,CAAC,aAAa,mBAAmB,QAAqB,uCAAAA,KAAK,oBAAoB;AAAA,QACjF;AAAA,QACA,SAAS,MAAM,kBAAkB,IAAI;AAAA,QACrC,UAAU,gBAAc;AACtB;AAAA;AAAA,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,uCAAAA,KAAK,uBAAAQ,SAAgB;AAAA,QAChE;AAAA,QACA,UAAU;AAAA,QACV,WAAW;AAAA,QACX,wBAAwB;AAAA,MAC1B,CAAC,IAAiB,uCAAAR,KAAK,qBAAAS,SAAc;AAAA,QACnC;AAAA,QACA,UAAU;AAAA,QACV,WAAW;AAAA,QACX,qBAAqB;AAAA,MACvB,CAAC,EAAE;AAAA,IACL,CAAC,GAAG,CAAC,eAAe,gBAA6B,uCAAAT,KAAK,mCAAqB;AAAA,MACzE,UAAU;AAAA,IACZ,CAAC,CAAC;AAAA,EACJ,CAAC;AACH;AACA,IAAO,uBAAQ;",
|
|
6
6
|
"names": ["_jsx", "clsx", "_jsxs", "Popover", "CustomGradientPicker", "Button", "DropdownMenu", "_Fragment", "GradientPicker", "ColorPalette"]
|
|
7
7
|
}
|
package/build/panel/body.cjs
CHANGED
|
@@ -69,7 +69,7 @@ function UnforwardedPanelBody(props, ref) {
|
|
|
69
69
|
setIsOpened(next);
|
|
70
70
|
onToggle(next);
|
|
71
71
|
};
|
|
72
|
-
const scrollAfterOpenRef = (0, import_element.useRef)();
|
|
72
|
+
const scrollAfterOpenRef = (0, import_element.useRef)(void 0);
|
|
73
73
|
scrollAfterOpenRef.current = scrollAfterOpen;
|
|
74
74
|
(0, import_utils.useUpdateEffect)(() => {
|
|
75
75
|
if (isOpened && scrollAfterOpenRef.current && nodeRef.current?.scrollIntoView) {
|
package/build/panel/body.cjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/panel/body.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useReducedMotion, useMergeRefs } from '@wordpress/compose';\nimport { forwardRef, useRef } from '@wordpress/element';\nimport { chevronUp, chevronDown } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\n\nimport Button from '../button';\nimport Icon from '../icon';\nimport { useControlledState, useUpdateEffect } from '../utils';\nimport { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nconst noop = () => {};\nexport function UnforwardedPanelBody(props, ref) {\n const {\n buttonProps = {},\n children,\n className,\n icon,\n initialOpen,\n onToggle = noop,\n opened,\n title,\n scrollAfterOpen = true\n } = props;\n const [isOpened, setIsOpened] = useControlledState(opened, {\n initial: initialOpen === undefined ? true : initialOpen,\n fallback: false\n });\n const nodeRef = useRef(null);\n\n // Defaults to 'smooth' scrolling\n // https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView\n const scrollBehavior = useReducedMotion() ? 'auto' : 'smooth';\n const handleOnToggle = event => {\n event.preventDefault();\n const next = !isOpened;\n setIsOpened(next);\n onToggle(next);\n };\n\n // Ref is used so that the effect does not re-run upon scrollAfterOpen changing value.\n const scrollAfterOpenRef = useRef();\n scrollAfterOpenRef.current = scrollAfterOpen;\n // Runs after initial render.\n useUpdateEffect(() => {\n if (isOpened && scrollAfterOpenRef.current && nodeRef.current?.scrollIntoView) {\n /*\n * Scrolls the content into view when visible.\n * This improves the UX when there are multiple stacking <PanelBody />\n * components in a scrollable container.\n */\n nodeRef.current.scrollIntoView({\n inline: 'nearest',\n block: 'nearest',\n behavior: scrollBehavior\n });\n }\n }, [isOpened, scrollBehavior]);\n const classes = clsx('components-panel__body', className, {\n 'is-opened': isOpened\n });\n return /*#__PURE__*/_jsxs(\"div\", {\n className: classes,\n ref: useMergeRefs([nodeRef, ref]),\n children: [/*#__PURE__*/_jsx(PanelBodyTitle, {\n icon: icon,\n isOpened: Boolean(isOpened),\n onClick: handleOnToggle,\n title: title,\n ...buttonProps\n }), typeof children === 'function' ? children({\n opened: Boolean(isOpened)\n }) : isOpened && children]\n });\n}\nconst PanelBodyTitle = forwardRef(({\n isOpened,\n icon,\n title,\n ...props\n}, ref) => {\n if (!title) {\n return null;\n }\n return /*#__PURE__*/_jsx(\"h2\", {\n className: \"components-panel__body-title\",\n children: /*#__PURE__*/_jsxs(Button, {\n __next40pxDefaultSize: true,\n className: \"components-panel__body-toggle\",\n \"aria-expanded\": isOpened,\n ref: ref,\n ...props,\n children: [/*#__PURE__*/_jsx(\"span\", {\n \"aria-hidden\": \"true\",\n children: /*#__PURE__*/_jsx(Icon, {\n className: \"components-panel__arrow\",\n icon: isOpened ? chevronUp : chevronDown\n })\n }), title, icon && /*#__PURE__*/_jsx(Icon, {\n icon: icon,\n className: \"components-panel__icon\",\n size: 20\n })]\n })\n });\n});\nexport const PanelBody = forwardRef(UnforwardedPanelBody);\nPanelBody.displayName = 'PanelBody';\nexport default PanelBody;"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAiB;AAKjB,qBAA+C;AAC/C,qBAAmC;AACnC,mBAAuC;AAMvC,oBAAmB;AACnB,kBAAiB;AACjB,mBAAoD;AACpD,yBAA2C;AAC3C,IAAM,OAAO,MAAM;AAAC;AACb,SAAS,qBAAqB,OAAO,KAAK;AAC/C,QAAM;AAAA,IACJ,cAAc,CAAC;AAAA,IACf;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,WAAW;AAAA,IACX;AAAA,IACA;AAAA,IACA,kBAAkB;AAAA,EACpB,IAAI;AACJ,QAAM,CAAC,UAAU,WAAW,QAAI,iCAAmB,QAAQ;AAAA,IACzD,SAAS,gBAAgB,SAAY,OAAO;AAAA,IAC5C,UAAU;AAAA,EACZ,CAAC;AACD,QAAM,cAAU,uBAAO,IAAI;AAI3B,QAAM,qBAAiB,iCAAiB,IAAI,SAAS;AACrD,QAAM,iBAAiB,WAAS;AAC9B,UAAM,eAAe;AACrB,UAAM,OAAO,CAAC;AACd,gBAAY,IAAI;AAChB,aAAS,IAAI;AAAA,EACf;AAGA,QAAM,yBAAqB,uBAAO;
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useReducedMotion, useMergeRefs } from '@wordpress/compose';\nimport { forwardRef, useRef } from '@wordpress/element';\nimport { chevronUp, chevronDown } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\n\nimport Button from '../button';\nimport Icon from '../icon';\nimport { useControlledState, useUpdateEffect } from '../utils';\nimport { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nconst noop = () => {};\nexport function UnforwardedPanelBody(props, ref) {\n const {\n buttonProps = {},\n children,\n className,\n icon,\n initialOpen,\n onToggle = noop,\n opened,\n title,\n scrollAfterOpen = true\n } = props;\n const [isOpened, setIsOpened] = useControlledState(opened, {\n initial: initialOpen === undefined ? true : initialOpen,\n fallback: false\n });\n const nodeRef = useRef(null);\n\n // Defaults to 'smooth' scrolling\n // https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView\n const scrollBehavior = useReducedMotion() ? 'auto' : 'smooth';\n const handleOnToggle = event => {\n event.preventDefault();\n const next = !isOpened;\n setIsOpened(next);\n onToggle(next);\n };\n\n // Ref is used so that the effect does not re-run upon scrollAfterOpen changing value.\n const scrollAfterOpenRef = useRef(undefined);\n scrollAfterOpenRef.current = scrollAfterOpen;\n // Runs after initial render.\n useUpdateEffect(() => {\n if (isOpened && scrollAfterOpenRef.current && nodeRef.current?.scrollIntoView) {\n /*\n * Scrolls the content into view when visible.\n * This improves the UX when there are multiple stacking <PanelBody />\n * components in a scrollable container.\n */\n nodeRef.current.scrollIntoView({\n inline: 'nearest',\n block: 'nearest',\n behavior: scrollBehavior\n });\n }\n }, [isOpened, scrollBehavior]);\n const classes = clsx('components-panel__body', className, {\n 'is-opened': isOpened\n });\n return /*#__PURE__*/_jsxs(\"div\", {\n className: classes,\n ref: useMergeRefs([nodeRef, ref]),\n children: [/*#__PURE__*/_jsx(PanelBodyTitle, {\n icon: icon,\n isOpened: Boolean(isOpened),\n onClick: handleOnToggle,\n title: title,\n ...buttonProps\n }), typeof children === 'function' ? children({\n opened: Boolean(isOpened)\n }) : isOpened && children]\n });\n}\nconst PanelBodyTitle = forwardRef(({\n isOpened,\n icon,\n title,\n ...props\n}, ref) => {\n if (!title) {\n return null;\n }\n return /*#__PURE__*/_jsx(\"h2\", {\n className: \"components-panel__body-title\",\n children: /*#__PURE__*/_jsxs(Button, {\n __next40pxDefaultSize: true,\n className: \"components-panel__body-toggle\",\n \"aria-expanded\": isOpened,\n ref: ref,\n ...props,\n children: [/*#__PURE__*/_jsx(\"span\", {\n \"aria-hidden\": \"true\",\n children: /*#__PURE__*/_jsx(Icon, {\n className: \"components-panel__arrow\",\n icon: isOpened ? chevronUp : chevronDown\n })\n }), title, icon && /*#__PURE__*/_jsx(Icon, {\n icon: icon,\n className: \"components-panel__icon\",\n size: 20\n })]\n })\n });\n});\nexport const PanelBody = forwardRef(UnforwardedPanelBody);\nPanelBody.displayName = 'PanelBody';\nexport default PanelBody;"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAiB;AAKjB,qBAA+C;AAC/C,qBAAmC;AACnC,mBAAuC;AAMvC,oBAAmB;AACnB,kBAAiB;AACjB,mBAAoD;AACpD,yBAA2C;AAC3C,IAAM,OAAO,MAAM;AAAC;AACb,SAAS,qBAAqB,OAAO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IAAM,qBAAiB,2BAAW,CAAC;AAAA,EACjC;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAG,QAAQ;AACT,MAAI,CAAC,OAAO;AACV,WAAO;AAAA,EACT;AACA,SAAoB,uCAAAA,KAAK,MAAM;AAAA,IAC7B,WAAW;AAAA,IACX,UAAuB,uCAAAD,MAAM,cAAAE,SAAQ;AAAA,MACnC,uBAAuB;AAAA,MACvB,WAAW;AAAA,MACX,iBAAiB;AAAA,MACjB;AAAA,MACA,GAAG;AAAA,MACH,UAAU,CAAc,uCAAAD,KAAK,QAAQ;AAAA,QACnC,eAAe;AAAA,QACf,UAAuB,uCAAAA,KAAK,YAAAE,SAAM;AAAA,UAChC,WAAW;AAAA,UACX,MAAM,WAAW,yBAAY;AAAA,QAC/B,CAAC;AAAA,MACH,CAAC,GAAG,OAAO,QAAqB,uCAAAF,KAAK,YAAAE,SAAM;AAAA,QACzC;AAAA,QACA,WAAW;AAAA,QACX,MAAM;AAAA,MACR,CAAC,CAAC;AAAA,IACJ,CAAC;AAAA,EACH,CAAC;AACH,CAAC;AACM,IAAM,gBAAY,2BAAW,oBAAoB;AACxD,UAAU,cAAc;AACxB,IAAO,eAAQ;",
|
|
6
6
|
"names": ["clsx", "_jsxs", "_jsx", "Button", "Icon"]
|
|
7
7
|
}
|
package/build/private-apis.cjs
CHANGED
|
@@ -46,7 +46,6 @@ var import_badge = __toESM(require("./badge/index.cjs"));
|
|
|
46
46
|
var import_calendar = require("./calendar/index.cjs");
|
|
47
47
|
var import_validated_form_controls = require("./validated-form-controls/index.cjs");
|
|
48
48
|
var import_form_token_field = require("./validated-form-controls/components/form-token-field.cjs");
|
|
49
|
-
var import_picker = require("./color-picker/picker.cjs");
|
|
50
49
|
var privateApis = {};
|
|
51
50
|
(0, import_lock_unlock.lock)(privateApis, {
|
|
52
51
|
__experimentalPopoverLegacyPositionToPlacement: import_utils.positionToPlacement,
|
|
@@ -61,7 +60,6 @@ var privateApis = {};
|
|
|
61
60
|
DateCalendar: import_calendar.DateCalendar,
|
|
62
61
|
DateRangeCalendar: import_calendar.DateRangeCalendar,
|
|
63
62
|
TZDate: import_calendar.TZDate,
|
|
64
|
-
Picker: import_picker.Picker,
|
|
65
63
|
useDrag: import_react.useDrag,
|
|
66
64
|
ValidatedInputControl: import_validated_form_controls.ValidatedInputControl,
|
|
67
65
|
ValidatedCheckboxControl: import_validated_form_controls.ValidatedCheckboxControl,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/private-apis.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport { useDrag } from '@use-gesture/react';\n\n/**\n * Internal dependencies\n */\nimport { positionToPlacement as __experimentalPopoverLegacyPositionToPlacement } from './popover/utils';\nimport { Menu } from './menu';\nimport { ComponentsContext } from './context/context-system-provider';\nimport Theme from './theme';\nimport { Tabs } from './tabs';\nimport { kebabCase, normalizeTextString } from './utils/strings';\nimport { withIgnoreIMEEvents } from './utils/with-ignore-ime-events';\nimport { lock } from './lock-unlock';\nimport Badge from './badge';\nimport { DateCalendar, DateRangeCalendar, TZDate } from './calendar';\nimport { ValidatedCheckboxControl, ValidatedComboboxControl, ValidatedInputControl, ValidatedNumberControl, ValidatedSelectControl, ValidatedRadioControl, ValidatedTextControl, ValidatedTextareaControl, ValidatedToggleControl, ValidatedToggleGroupControl } from './validated-form-controls';\nimport { ValidatedFormTokenField } from './validated-form-controls/components/form-token-field';\
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,mBAAwB;AAKxB,mBAAsF;AACtF,kBAAqB;AACrB,qCAAkC;AAClC,mBAAkB;AAClB,kBAAqB;AACrB,qBAA+C;AAC/C,oCAAoC;AACpC,yBAAqB;AACrB,mBAAkB;AAClB,sBAAwD;AACxD,qCAAsQ;AACtQ,8BAAwC;
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport { useDrag } from '@use-gesture/react';\n\n/**\n * Internal dependencies\n */\nimport { positionToPlacement as __experimentalPopoverLegacyPositionToPlacement } from './popover/utils';\nimport { Menu } from './menu';\nimport { ComponentsContext } from './context/context-system-provider';\nimport Theme from './theme';\nimport { Tabs } from './tabs';\nimport { kebabCase, normalizeTextString } from './utils/strings';\nimport { withIgnoreIMEEvents } from './utils/with-ignore-ime-events';\nimport { lock } from './lock-unlock';\nimport Badge from './badge';\nimport { DateCalendar, DateRangeCalendar, TZDate } from './calendar';\nimport { ValidatedCheckboxControl, ValidatedComboboxControl, ValidatedInputControl, ValidatedNumberControl, ValidatedSelectControl, ValidatedRadioControl, ValidatedTextControl, ValidatedTextareaControl, ValidatedToggleControl, ValidatedToggleGroupControl } from './validated-form-controls';\nimport { ValidatedFormTokenField } from './validated-form-controls/components/form-token-field';\nexport const privateApis = {};\nlock(privateApis, {\n __experimentalPopoverLegacyPositionToPlacement,\n ComponentsContext,\n Tabs,\n Theme,\n Menu,\n kebabCase,\n withIgnoreIMEEvents,\n Badge,\n normalizeTextString,\n DateCalendar,\n DateRangeCalendar,\n TZDate,\n useDrag,\n ValidatedInputControl,\n ValidatedCheckboxControl,\n ValidatedComboboxControl,\n ValidatedNumberControl,\n ValidatedSelectControl,\n ValidatedRadioControl,\n ValidatedTextControl,\n ValidatedTextareaControl,\n ValidatedToggleControl,\n ValidatedToggleGroupControl,\n ValidatedFormTokenField\n});"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,mBAAwB;AAKxB,mBAAsF;AACtF,kBAAqB;AACrB,qCAAkC;AAClC,mBAAkB;AAClB,kBAAqB;AACrB,qBAA+C;AAC/C,oCAAoC;AACpC,yBAAqB;AACrB,mBAAkB;AAClB,sBAAwD;AACxD,qCAAsQ;AACtQ,8BAAwC;AACjC,IAAM,cAAc,CAAC;AAAA,IAC5B,yBAAK,aAAa;AAAA,EAChB,6DAAAA;AAAA,EACA;AAAA,EACA;AAAA,EACA,oBAAAC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,oBAAAC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;",
|
|
6
6
|
"names": ["__experimentalPopoverLegacyPositionToPlacement", "Theme", "Badge"]
|
|
7
7
|
}
|
|
@@ -117,7 +117,7 @@ function UnforwardedRangeControl(props, forwardedRef) {
|
|
|
117
117
|
}
|
|
118
118
|
const [showTooltip, setShowTooltip] = (0, import_element.useState)(hasTooltip);
|
|
119
119
|
const [isFocused, setIsFocused] = (0, import_element.useState)(false);
|
|
120
|
-
const inputRef = (0, import_element.useRef)();
|
|
120
|
+
const inputRef = (0, import_element.useRef)(null);
|
|
121
121
|
const isCurrentlyFocused = inputRef.current?.matches(":focus");
|
|
122
122
|
const isThumbFocused = !disabled && isFocused;
|
|
123
123
|
const isValueReset = value === null;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/range-control/index.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n/**\n * WordPress dependencies\n */\nimport { __, isRTL } from '@wordpress/i18n';\nimport { useRef, useState, forwardRef } from '@wordpress/element';\nimport { useInstanceId, useMergeRefs } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport BaseControl from '../base-control';\nimport Button from '../button';\nimport Icon from '../icon';\nimport { COLORS } from '../utils';\nimport { floatClamp, useControlledRangeValue } from './utils';\nimport { clamp } from '../utils/math';\nimport InputRange from './input-range';\nimport RangeRail from './rail';\nimport SimpleTooltip from './tooltip';\nimport { ActionRightWrapper, AfterIconWrapper, BeforeIconWrapper, InputNumber, Root, Track, ThumbWrapper, Thumb, Wrapper } from './styles/range-control-styles';\nimport { space } from '../utils/space';\nimport { maybeWarnDeprecated36pxSize } from '../utils/deprecated-36px-size';\nimport { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nconst noop = () => {};\n\n/**\n * Computes the value that `RangeControl` should reset to when pressing\n * the reset button.\n */\nfunction computeResetValue({\n resetFallbackValue,\n initialPosition\n}) {\n if (resetFallbackValue !== undefined) {\n return !Number.isNaN(resetFallbackValue) ? resetFallbackValue : null;\n }\n if (initialPosition !== undefined) {\n return !Number.isNaN(initialPosition) ? initialPosition : null;\n }\n return null;\n}\nfunction UnforwardedRangeControl(props, forwardedRef) {\n const {\n __nextHasNoMarginBottom: _,\n // Prevent passing to internal component\n afterIcon,\n allowReset = false,\n beforeIcon,\n className,\n color: colorProp = COLORS.theme.accent,\n currentInput,\n disabled = false,\n help,\n hideLabelFromVision = false,\n initialPosition,\n isShiftStepEnabled = true,\n label,\n marks = false,\n max = 100,\n min = 0,\n onBlur = noop,\n onChange = noop,\n onFocus = noop,\n onMouseLeave = noop,\n onMouseMove = noop,\n railColor,\n renderTooltipContent = v => v,\n resetFallbackValue,\n __next40pxDefaultSize = false,\n shiftStep = 10,\n showTooltip: showTooltipProp,\n step = 1,\n trackColor,\n value: valueProp,\n withInputField = true,\n __shouldNotWarnDeprecated36pxSize,\n ...otherProps\n } = props;\n const [value, setValue] = useControlledRangeValue({\n min,\n max,\n value: valueProp ?? null,\n initial: initialPosition\n });\n const isResetPendent = useRef(false);\n let hasTooltip = showTooltipProp;\n let hasInputField = withInputField;\n if (step === 'any') {\n // The tooltip and number input field are hidden when the step is \"any\"\n // because the decimals get too lengthy to fit well.\n hasTooltip = false;\n hasInputField = false;\n }\n const [showTooltip, setShowTooltip] = useState(hasTooltip);\n const [isFocused, setIsFocused] = useState(false);\n const inputRef = useRef();\n const isCurrentlyFocused = inputRef.current?.matches(':focus');\n const isThumbFocused = !disabled && isFocused;\n const isValueReset = value === null;\n const currentValue = value !== undefined ? value : currentInput;\n const inputSliderValue = isValueReset ? '' : currentValue;\n const rangeFillValue = isValueReset ? (max - min) / 2 + min : value;\n const fillValue = isValueReset ? 50 : (value - min) / (max - min) * 100;\n const fillValueOffset = `${clamp(fillValue, 0, 100)}%`;\n const classes = clsx('components-range-control', className);\n const wrapperClasses = clsx('components-range-control__wrapper', !!marks && 'is-marked');\n const id = useInstanceId(UnforwardedRangeControl, 'inspector-range-control');\n const describedBy = !!help ? `${id}__help` : undefined;\n const enableTooltip = hasTooltip !== false && Number.isFinite(value);\n const handleOnRangeChange = event => {\n const nextValue = parseFloat(event.target.value);\n setValue(nextValue);\n onChange(nextValue);\n };\n const handleOnChange = next => {\n // @ts-expect-error TODO: Investigate if it's problematic for setValue() to\n // potentially receive a NaN when next is undefined.\n let nextValue = parseFloat(next);\n setValue(nextValue);\n\n /*\n * Calls onChange only when nextValue is numeric\n * otherwise may queue a reset for the blur event.\n */\n if (!isNaN(nextValue)) {\n if (nextValue < min || nextValue > max) {\n nextValue = floatClamp(nextValue, min, max);\n }\n onChange(nextValue);\n isResetPendent.current = false;\n } else if (allowReset) {\n isResetPendent.current = true;\n }\n };\n const handleOnInputNumberBlur = () => {\n if (isResetPendent.current) {\n handleOnReset();\n isResetPendent.current = false;\n }\n };\n const handleOnReset = () => {\n // Reset to `resetFallbackValue` if defined, otherwise set internal value\n // to `null` \u2014 which, if propagated to the `value` prop, will cause\n // the value to be reset to the `initialPosition` prop if defined.\n const resetValue = Number.isNaN(resetFallbackValue) ? null : resetFallbackValue ?? null;\n setValue(resetValue);\n\n /**\n * Previously, this callback would always receive undefined as\n * an argument. This behavior is unexpected, specifically\n * when resetFallbackValue is defined.\n *\n * The value of undefined is not ideal. Passing it through\n * to internal <input /> elements would change it from a\n * controlled component to an uncontrolled component.\n *\n * For now, to minimize unexpected regressions, we're going to\n * preserve the undefined callback argument, except when a\n * resetFallbackValue is defined.\n */\n onChange(resetValue ?? undefined);\n };\n const handleShowTooltip = () => setShowTooltip(true);\n const handleHideTooltip = () => setShowTooltip(false);\n const handleOnBlur = event => {\n onBlur(event);\n setIsFocused(false);\n handleHideTooltip();\n };\n const handleOnFocus = event => {\n onFocus(event);\n setIsFocused(true);\n handleShowTooltip();\n };\n const offsetStyle = {\n [isRTL() ? 'right' : 'left']: fillValueOffset\n };\n\n // Add default size deprecation warning.\n maybeWarnDeprecated36pxSize({\n componentName: 'RangeControl',\n __next40pxDefaultSize,\n size: undefined,\n __shouldNotWarnDeprecated36pxSize\n });\n return /*#__PURE__*/_jsx(BaseControl, {\n className: classes,\n label: label,\n hideLabelFromVision: hideLabelFromVision,\n id: `${id}`,\n help: help,\n children: /*#__PURE__*/_jsxs(Root, {\n className: \"components-range-control__root\",\n __next40pxDefaultSize: __next40pxDefaultSize,\n children: [beforeIcon && /*#__PURE__*/_jsx(BeforeIconWrapper, {\n children: /*#__PURE__*/_jsx(Icon, {\n icon: beforeIcon\n })\n }), /*#__PURE__*/_jsxs(Wrapper, {\n className: wrapperClasses,\n color: colorProp,\n marks: !!marks,\n children: [/*#__PURE__*/_jsx(InputRange, {\n ...otherProps,\n className: \"components-range-control__slider\",\n describedBy: describedBy,\n disabled: disabled,\n id: `${id}`,\n label: label,\n max: max,\n min: min,\n onBlur: handleOnBlur,\n onChange: handleOnRangeChange,\n onFocus: handleOnFocus,\n onMouseMove: onMouseMove,\n onMouseLeave: onMouseLeave,\n ref: useMergeRefs([inputRef, forwardedRef]),\n step: step,\n value: inputSliderValue ?? undefined\n }), /*#__PURE__*/_jsx(RangeRail, {\n \"aria-hidden\": true,\n disabled: disabled,\n marks: marks,\n max: max,\n min: min,\n railColor: railColor,\n step: step,\n value: rangeFillValue\n }), /*#__PURE__*/_jsx(Track, {\n \"aria-hidden\": true,\n className: \"components-range-control__track\",\n disabled: disabled,\n style: {\n width: fillValueOffset\n },\n trackColor: trackColor\n }), /*#__PURE__*/_jsx(ThumbWrapper, {\n className: \"components-range-control__thumb-wrapper\",\n style: offsetStyle,\n disabled: disabled,\n children: /*#__PURE__*/_jsx(Thumb, {\n \"aria-hidden\": true,\n isFocused: isThumbFocused,\n disabled: disabled\n })\n }), enableTooltip && /*#__PURE__*/_jsx(SimpleTooltip, {\n className: \"components-range-control__tooltip\",\n inputRef: inputRef,\n tooltipPlacement: \"bottom\",\n renderTooltipContent: renderTooltipContent,\n show: isCurrentlyFocused || showTooltip,\n style: offsetStyle,\n value: value\n })]\n }), afterIcon && /*#__PURE__*/_jsx(AfterIconWrapper, {\n children: /*#__PURE__*/_jsx(Icon, {\n icon: afterIcon\n })\n }), hasInputField && /*#__PURE__*/_jsx(InputNumber, {\n \"aria-label\": label,\n className: \"components-range-control__number\",\n disabled: disabled,\n inputMode: \"decimal\",\n isShiftStepEnabled: isShiftStepEnabled,\n max: max,\n min: min,\n onBlur: handleOnInputNumberBlur,\n onChange: handleOnChange,\n shiftStep: shiftStep,\n size: __next40pxDefaultSize ? '__unstable-large' : 'default',\n __unstableInputWidth: __next40pxDefaultSize ? space(20) : space(16),\n step: step\n // @ts-expect-error TODO: Investigate if the `null` value is necessary\n ,\n value: inputSliderValue,\n __shouldNotWarnDeprecated36pxSize: true\n }), allowReset && /*#__PURE__*/_jsx(ActionRightWrapper, {\n children: /*#__PURE__*/_jsx(Button, {\n className: \"components-range-control__reset\"\n // If the RangeControl itself is disabled, the reset button shouldn't be in the tab sequence.\n ,\n accessibleWhenDisabled: !disabled\n // The reset button should be disabled if RangeControl itself is disabled,\n // or if the current `value` is equal to the value that would be currently\n // assigned when clicking the button.\n ,\n disabled: disabled || value === computeResetValue({\n resetFallbackValue,\n initialPosition\n }),\n variant: \"secondary\",\n size: \"small\",\n onClick: handleOnReset,\n children: __('Reset')\n })\n })]\n })\n });\n}\n\n/**\n * RangeControls are used to make selections from a range of incremental values.\n *\n * ```jsx\n * import { RangeControl } from '@wordpress/components';\n * import { useState } from '@wordpress/element';\n *\n * const MyRangeControl = () => {\n * const [ value, setValue ] = useState();\n * return (\n * <RangeControl\n * __next40pxDefaultSize\n * help=\"Please select how transparent you would like this.\"\n * initialPosition={ 50 }\n * label=\"Opacity\"\n * max={ 100 }\n * min={ 0 }\n * value={ value }\n * onChange={ setValue }\n * />\n * );\n * };\n * ```\n */\nexport const RangeControl = forwardRef(UnforwardedRangeControl);\nRangeControl.displayName = 'RangeControl';\nexport default RangeControl;"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAiB;AAIjB,kBAA0B;AAC1B,qBAA6C;AAC7C,qBAA4C;AAK5C,0BAAwB;AACxB,oBAAmB;AACnB,kBAAiB;AACjB,mBAAuB;AACvB,IAAAA,gBAAoD;AACpD,kBAAsB;AACtB,yBAAuB;AACvB,kBAAsB;AACtB,qBAA0B;AAC1B,kCAAgI;AAChI,mBAAsB;AACtB,kCAA4C;AAC5C,yBAA2C;AAC3C,IAAM,OAAO,MAAM;AAAC;AAMpB,SAAS,kBAAkB;AAAA,EACzB;AAAA,EACA;AACF,GAAG;AACD,MAAI,uBAAuB,QAAW;AACpC,WAAO,CAAC,OAAO,MAAM,kBAAkB,IAAI,qBAAqB;AAAA,EAClE;AACA,MAAI,oBAAoB,QAAW;AACjC,WAAO,CAAC,OAAO,MAAM,eAAe,IAAI,kBAAkB;AAAA,EAC5D;AACA,SAAO;AACT;AACA,SAAS,wBAAwB,OAAO,cAAc;AACpD,QAAM;AAAA,IACJ,yBAAyB;AAAA;AAAA,IAEzB;AAAA,IACA,aAAa;AAAA,IACb;AAAA,IACA;AAAA,IACA,OAAO,YAAY,oBAAO,MAAM;AAAA,IAChC;AAAA,IACA,WAAW;AAAA,IACX;AAAA,IACA,sBAAsB;AAAA,IACtB;AAAA,IACA,qBAAqB;AAAA,IACrB;AAAA,IACA,QAAQ;AAAA,IACR,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SAAS;AAAA,IACT,WAAW;AAAA,IACX,UAAU;AAAA,IACV,eAAe;AAAA,IACf,cAAc;AAAA,IACd;AAAA,IACA,uBAAuB,OAAK;AAAA,IAC5B;AAAA,IACA,wBAAwB;AAAA,IACxB,YAAY;AAAA,IACZ,aAAa;AAAA,IACb,OAAO;AAAA,IACP;AAAA,IACA,OAAO;AAAA,IACP,iBAAiB;AAAA,IACjB;AAAA,IACA,GAAG;AAAA,EACL,IAAI;AACJ,QAAM,CAAC,OAAO,QAAQ,QAAI,uCAAwB;AAAA,IAChD;AAAA,IACA;AAAA,IACA,OAAO,aAAa;AAAA,IACpB,SAAS;AAAA,EACX,CAAC;AACD,QAAM,qBAAiB,uBAAO,KAAK;AACnC,MAAI,aAAa;AACjB,MAAI,gBAAgB;AACpB,MAAI,SAAS,OAAO;AAGlB,iBAAa;AACb,oBAAgB;AAAA,EAClB;AACA,QAAM,CAAC,aAAa,cAAc,QAAI,yBAAS,UAAU;AACzD,QAAM,CAAC,WAAW,YAAY,QAAI,yBAAS,KAAK;AAChD,QAAM,eAAW,uBAAO;
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n/**\n * WordPress dependencies\n */\nimport { __, isRTL } from '@wordpress/i18n';\nimport { useRef, useState, forwardRef } from '@wordpress/element';\nimport { useInstanceId, useMergeRefs } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport BaseControl from '../base-control';\nimport Button from '../button';\nimport Icon from '../icon';\nimport { COLORS } from '../utils';\nimport { floatClamp, useControlledRangeValue } from './utils';\nimport { clamp } from '../utils/math';\nimport InputRange from './input-range';\nimport RangeRail from './rail';\nimport SimpleTooltip from './tooltip';\nimport { ActionRightWrapper, AfterIconWrapper, BeforeIconWrapper, InputNumber, Root, Track, ThumbWrapper, Thumb, Wrapper } from './styles/range-control-styles';\nimport { space } from '../utils/space';\nimport { maybeWarnDeprecated36pxSize } from '../utils/deprecated-36px-size';\nimport { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nconst noop = () => {};\n\n/**\n * Computes the value that `RangeControl` should reset to when pressing\n * the reset button.\n */\nfunction computeResetValue({\n resetFallbackValue,\n initialPosition\n}) {\n if (resetFallbackValue !== undefined) {\n return !Number.isNaN(resetFallbackValue) ? resetFallbackValue : null;\n }\n if (initialPosition !== undefined) {\n return !Number.isNaN(initialPosition) ? initialPosition : null;\n }\n return null;\n}\nfunction UnforwardedRangeControl(props, forwardedRef) {\n const {\n __nextHasNoMarginBottom: _,\n // Prevent passing to internal component\n afterIcon,\n allowReset = false,\n beforeIcon,\n className,\n color: colorProp = COLORS.theme.accent,\n currentInput,\n disabled = false,\n help,\n hideLabelFromVision = false,\n initialPosition,\n isShiftStepEnabled = true,\n label,\n marks = false,\n max = 100,\n min = 0,\n onBlur = noop,\n onChange = noop,\n onFocus = noop,\n onMouseLeave = noop,\n onMouseMove = noop,\n railColor,\n renderTooltipContent = v => v,\n resetFallbackValue,\n __next40pxDefaultSize = false,\n shiftStep = 10,\n showTooltip: showTooltipProp,\n step = 1,\n trackColor,\n value: valueProp,\n withInputField = true,\n __shouldNotWarnDeprecated36pxSize,\n ...otherProps\n } = props;\n const [value, setValue] = useControlledRangeValue({\n min,\n max,\n value: valueProp ?? null,\n initial: initialPosition\n });\n const isResetPendent = useRef(false);\n let hasTooltip = showTooltipProp;\n let hasInputField = withInputField;\n if (step === 'any') {\n // The tooltip and number input field are hidden when the step is \"any\"\n // because the decimals get too lengthy to fit well.\n hasTooltip = false;\n hasInputField = false;\n }\n const [showTooltip, setShowTooltip] = useState(hasTooltip);\n const [isFocused, setIsFocused] = useState(false);\n const inputRef = useRef(null);\n const isCurrentlyFocused = inputRef.current?.matches(':focus');\n const isThumbFocused = !disabled && isFocused;\n const isValueReset = value === null;\n const currentValue = value !== undefined ? value : currentInput;\n const inputSliderValue = isValueReset ? '' : currentValue;\n const rangeFillValue = isValueReset ? (max - min) / 2 + min : value;\n const fillValue = isValueReset ? 50 : (value - min) / (max - min) * 100;\n const fillValueOffset = `${clamp(fillValue, 0, 100)}%`;\n const classes = clsx('components-range-control', className);\n const wrapperClasses = clsx('components-range-control__wrapper', !!marks && 'is-marked');\n const id = useInstanceId(UnforwardedRangeControl, 'inspector-range-control');\n const describedBy = !!help ? `${id}__help` : undefined;\n const enableTooltip = hasTooltip !== false && Number.isFinite(value);\n const handleOnRangeChange = event => {\n const nextValue = parseFloat(event.target.value);\n setValue(nextValue);\n onChange(nextValue);\n };\n const handleOnChange = next => {\n // @ts-expect-error TODO: Investigate if it's problematic for setValue() to\n // potentially receive a NaN when next is undefined.\n let nextValue = parseFloat(next);\n setValue(nextValue);\n\n /*\n * Calls onChange only when nextValue is numeric\n * otherwise may queue a reset for the blur event.\n */\n if (!isNaN(nextValue)) {\n if (nextValue < min || nextValue > max) {\n nextValue = floatClamp(nextValue, min, max);\n }\n onChange(nextValue);\n isResetPendent.current = false;\n } else if (allowReset) {\n isResetPendent.current = true;\n }\n };\n const handleOnInputNumberBlur = () => {\n if (isResetPendent.current) {\n handleOnReset();\n isResetPendent.current = false;\n }\n };\n const handleOnReset = () => {\n // Reset to `resetFallbackValue` if defined, otherwise set internal value\n // to `null` \u2014 which, if propagated to the `value` prop, will cause\n // the value to be reset to the `initialPosition` prop if defined.\n const resetValue = Number.isNaN(resetFallbackValue) ? null : resetFallbackValue ?? null;\n setValue(resetValue);\n\n /**\n * Previously, this callback would always receive undefined as\n * an argument. This behavior is unexpected, specifically\n * when resetFallbackValue is defined.\n *\n * The value of undefined is not ideal. Passing it through\n * to internal <input /> elements would change it from a\n * controlled component to an uncontrolled component.\n *\n * For now, to minimize unexpected regressions, we're going to\n * preserve the undefined callback argument, except when a\n * resetFallbackValue is defined.\n */\n onChange(resetValue ?? undefined);\n };\n const handleShowTooltip = () => setShowTooltip(true);\n const handleHideTooltip = () => setShowTooltip(false);\n const handleOnBlur = event => {\n onBlur(event);\n setIsFocused(false);\n handleHideTooltip();\n };\n const handleOnFocus = event => {\n onFocus(event);\n setIsFocused(true);\n handleShowTooltip();\n };\n const offsetStyle = {\n [isRTL() ? 'right' : 'left']: fillValueOffset\n };\n\n // Add default size deprecation warning.\n maybeWarnDeprecated36pxSize({\n componentName: 'RangeControl',\n __next40pxDefaultSize,\n size: undefined,\n __shouldNotWarnDeprecated36pxSize\n });\n return /*#__PURE__*/_jsx(BaseControl, {\n className: classes,\n label: label,\n hideLabelFromVision: hideLabelFromVision,\n id: `${id}`,\n help: help,\n children: /*#__PURE__*/_jsxs(Root, {\n className: \"components-range-control__root\",\n __next40pxDefaultSize: __next40pxDefaultSize,\n children: [beforeIcon && /*#__PURE__*/_jsx(BeforeIconWrapper, {\n children: /*#__PURE__*/_jsx(Icon, {\n icon: beforeIcon\n })\n }), /*#__PURE__*/_jsxs(Wrapper, {\n className: wrapperClasses,\n color: colorProp,\n marks: !!marks,\n children: [/*#__PURE__*/_jsx(InputRange, {\n ...otherProps,\n className: \"components-range-control__slider\",\n describedBy: describedBy,\n disabled: disabled,\n id: `${id}`,\n label: label,\n max: max,\n min: min,\n onBlur: handleOnBlur,\n onChange: handleOnRangeChange,\n onFocus: handleOnFocus,\n onMouseMove: onMouseMove,\n onMouseLeave: onMouseLeave,\n ref: useMergeRefs([inputRef, forwardedRef]),\n step: step,\n value: inputSliderValue ?? undefined\n }), /*#__PURE__*/_jsx(RangeRail, {\n \"aria-hidden\": true,\n disabled: disabled,\n marks: marks,\n max: max,\n min: min,\n railColor: railColor,\n step: step,\n value: rangeFillValue\n }), /*#__PURE__*/_jsx(Track, {\n \"aria-hidden\": true,\n className: \"components-range-control__track\",\n disabled: disabled,\n style: {\n width: fillValueOffset\n },\n trackColor: trackColor\n }), /*#__PURE__*/_jsx(ThumbWrapper, {\n className: \"components-range-control__thumb-wrapper\",\n style: offsetStyle,\n disabled: disabled,\n children: /*#__PURE__*/_jsx(Thumb, {\n \"aria-hidden\": true,\n isFocused: isThumbFocused,\n disabled: disabled\n })\n }), enableTooltip && /*#__PURE__*/_jsx(SimpleTooltip, {\n className: \"components-range-control__tooltip\",\n inputRef: inputRef,\n tooltipPlacement: \"bottom\",\n renderTooltipContent: renderTooltipContent,\n show: isCurrentlyFocused || showTooltip,\n style: offsetStyle,\n value: value\n })]\n }), afterIcon && /*#__PURE__*/_jsx(AfterIconWrapper, {\n children: /*#__PURE__*/_jsx(Icon, {\n icon: afterIcon\n })\n }), hasInputField && /*#__PURE__*/_jsx(InputNumber, {\n \"aria-label\": label,\n className: \"components-range-control__number\",\n disabled: disabled,\n inputMode: \"decimal\",\n isShiftStepEnabled: isShiftStepEnabled,\n max: max,\n min: min,\n onBlur: handleOnInputNumberBlur,\n onChange: handleOnChange,\n shiftStep: shiftStep,\n size: __next40pxDefaultSize ? '__unstable-large' : 'default',\n __unstableInputWidth: __next40pxDefaultSize ? space(20) : space(16),\n step: step\n // @ts-expect-error TODO: Investigate if the `null` value is necessary\n ,\n value: inputSliderValue,\n __shouldNotWarnDeprecated36pxSize: true\n }), allowReset && /*#__PURE__*/_jsx(ActionRightWrapper, {\n children: /*#__PURE__*/_jsx(Button, {\n className: \"components-range-control__reset\"\n // If the RangeControl itself is disabled, the reset button shouldn't be in the tab sequence.\n ,\n accessibleWhenDisabled: !disabled\n // The reset button should be disabled if RangeControl itself is disabled,\n // or if the current `value` is equal to the value that would be currently\n // assigned when clicking the button.\n ,\n disabled: disabled || value === computeResetValue({\n resetFallbackValue,\n initialPosition\n }),\n variant: \"secondary\",\n size: \"small\",\n onClick: handleOnReset,\n children: __('Reset')\n })\n })]\n })\n });\n}\n\n/**\n * RangeControls are used to make selections from a range of incremental values.\n *\n * ```jsx\n * import { RangeControl } from '@wordpress/components';\n * import { useState } from '@wordpress/element';\n *\n * const MyRangeControl = () => {\n * const [ value, setValue ] = useState();\n * return (\n * <RangeControl\n * __next40pxDefaultSize\n * help=\"Please select how transparent you would like this.\"\n * initialPosition={ 50 }\n * label=\"Opacity\"\n * max={ 100 }\n * min={ 0 }\n * value={ value }\n * onChange={ setValue }\n * />\n * );\n * };\n * ```\n */\nexport const RangeControl = forwardRef(UnforwardedRangeControl);\nRangeControl.displayName = 'RangeControl';\nexport default RangeControl;"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAiB;AAIjB,kBAA0B;AAC1B,qBAA6C;AAC7C,qBAA4C;AAK5C,0BAAwB;AACxB,oBAAmB;AACnB,kBAAiB;AACjB,mBAAuB;AACvB,IAAAA,gBAAoD;AACpD,kBAAsB;AACtB,yBAAuB;AACvB,kBAAsB;AACtB,qBAA0B;AAC1B,kCAAgI;AAChI,mBAAsB;AACtB,kCAA4C;AAC5C,yBAA2C;AAC3C,IAAM,OAAO,MAAM;AAAC;AAMpB,SAAS,kBAAkB;AAAA,EACzB;AAAA,EACA;AACF,GAAG;AACD,MAAI,uBAAuB,QAAW;AACpC,WAAO,CAAC,OAAO,MAAM,kBAAkB,IAAI,qBAAqB;AAAA,EAClE;AACA,MAAI,oBAAoB,QAAW;AACjC,WAAO,CAAC,OAAO,MAAM,eAAe,IAAI,kBAAkB;AAAA,EAC5D;AACA,SAAO;AACT;AACA,SAAS,wBAAwB,OAAO,cAAc;AACpD,QAAM;AAAA,IACJ,yBAAyB;AAAA;AAAA,IAEzB;AAAA,IACA,aAAa;AAAA,IACb;AAAA,IACA;AAAA,IACA,OAAO,YAAY,oBAAO,MAAM;AAAA,IAChC;AAAA,IACA,WAAW;AAAA,IACX;AAAA,IACA,sBAAsB;AAAA,IACtB;AAAA,IACA,qBAAqB;AAAA,IACrB;AAAA,IACA,QAAQ;AAAA,IACR,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SAAS;AAAA,IACT,WAAW;AAAA,IACX,UAAU;AAAA,IACV,eAAe;AAAA,IACf,cAAc;AAAA,IACd;AAAA,IACA,uBAAuB,OAAK;AAAA,IAC5B;AAAA,IACA,wBAAwB;AAAA,IACxB,YAAY;AAAA,IACZ,aAAa;AAAA,IACb,OAAO;AAAA,IAC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QACnD,UAAuB,uCAAAA,KAAK,YAAAG,SAAM;AAAA,UAChC,MAAM;AAAA,QACR,CAAC;AAAA,MACH,CAAC,GAAG,iBAA8B,uCAAAH,KAAK,yCAAa;AAAA,QAClD,cAAc;AAAA,QACd,WAAW;AAAA,QACX;AAAA,QACA,WAAW;AAAA,QACX;AAAA,QACA;AAAA,QACA;AAAA,QACA,QAAQ;AAAA,QACR,UAAU;AAAA,QACV;AAAA,QACA,MAAM,wBAAwB,qBAAqB;AAAA,QACnD,sBAAsB,4BAAwB,oBAAM,EAAE,QAAI,oBAAM,EAAE;AAAA,QAClE;AAAA,QAGA,OAAO;AAAA,QACP,mCAAmC;AAAA,MACrC,CAAC,GAAG,cAA2B,uCAAAA,KAAK,gDAAoB;AAAA,QACtD,UAAuB,uCAAAA,KAAK,cAAAO,SAAQ;AAAA,UAClC,WAAW;AAAA,UAGX,wBAAwB,CAAC;AAAA,UAKzB,UAAU,YAAY,UAAU,kBAAkB;AAAA,YAChD;AAAA,YACA;AAAA,UACF,CAAC;AAAA,UACD,SAAS;AAAA,UACT,MAAM;AAAA,UACN,SAAS;AAAA,UACT,cAAU,gBAAG,OAAO;AAAA,QACtB,CAAC;AAAA,MACH,CAAC,CAAC;AAAA,IACJ,CAAC;AAAA,EACH,CAAC;AACH;AA0BO,IAAM,mBAAe,2BAAW,uBAAuB;AAC9D,aAAa,cAAc;AAC3B,IAAO,wBAAQ;",
|
|
6
6
|
"names": ["import_utils", "clsx", "_jsx", "BaseControl", "_jsxs", "Icon", "InputRange", "RangeRail", "SimpleTooltip", "Button"]
|
|
7
7
|
}
|
|
@@ -49,7 +49,7 @@ function useResizeLabel({
|
|
|
49
49
|
} = sizes;
|
|
50
50
|
const heightRef = (0, import_element.useRef)(height);
|
|
51
51
|
const widthRef = (0, import_element.useRef)(width);
|
|
52
|
-
const moveTimeoutRef = (0, import_element.useRef)();
|
|
52
|
+
const moveTimeoutRef = (0, import_element.useRef)(void 0);
|
|
53
53
|
const debounceUnsetMoveXY = (0, import_element.useCallback)(() => {
|
|
54
54
|
const unsetMoveXY = () => {
|
|
55
55
|
if (isAxisControlled) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/resizable-box/resize-tooltip/utils.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useCallback, useEffect, useRef, useState } from '@wordpress/element';\nimport { useResizeObserver } from '@wordpress/compose';\nconst noop = () => {};\nexport const POSITIONS = {\n bottom: 'bottom',\n corner: 'corner'\n};\n/**\n * Custom hook that manages resize listener events. It also provides a label\n * based on current resize width x height values.\n *\n * @param props\n * @param props.axis Only shows the label corresponding to the axis.\n * @param props.fadeTimeout Duration (ms) before deactivating the resize label.\n * @param props.onResize Callback when a resize occurs. Provides { width, height } callback.\n * @param props.position Adjusts label value.\n * @param props.showPx Whether to add `PX` to the label.\n *\n * @return Properties for hook.\n */\nexport function useResizeLabel({\n axis,\n fadeTimeout = 180,\n onResize = noop,\n position = POSITIONS.bottom,\n showPx = false\n}) {\n /*\n * The width/height values derive from this special useResizeObserver hook.\n * This custom hook uses the ResizeObserver API to listen for resize events.\n */\n const [resizeListener, sizes] = useResizeObserver();\n\n /*\n * Indicates if the x/y axis is preferred.\n * If set, we will avoid resetting the moveX and moveY values.\n * This will allow for the preferred axis values to persist in the label.\n */\n const isAxisControlled = !!axis;\n\n /*\n * The moveX and moveY values are used to track whether the label should\n * display width, height, or width x height.\n */\n const [moveX, setMoveX] = useState(false);\n const [moveY, setMoveY] = useState(false);\n\n /*\n * Cached dimension values to check for width/height updates from the\n * sizes property from useResizeAware()\n */\n const {\n width,\n height\n } = sizes;\n const heightRef = useRef(height);\n const widthRef = useRef(width);\n\n /*\n * This timeout is used with setMoveX and setMoveY to determine of\n * both width and height values have changed at (roughly) the same time.\n */\n const moveTimeoutRef = useRef();\n const debounceUnsetMoveXY = useCallback(() => {\n const unsetMoveXY = () => {\n /*\n * If axis is controlled, we will avoid resetting the moveX and moveY values.\n * This will allow for the preferred axis values to persist in the label.\n */\n if (isAxisControlled) {\n return;\n }\n setMoveX(false);\n setMoveY(false);\n };\n if (moveTimeoutRef.current) {\n window.clearTimeout(moveTimeoutRef.current);\n }\n moveTimeoutRef.current = window.setTimeout(unsetMoveXY, fadeTimeout);\n }, [fadeTimeout, isAxisControlled]);\n useEffect(() => {\n /*\n * On the initial render of useResizeAware, the height and width values are\n * null. They are calculated then set using via an internal useEffect hook.\n */\n const isRendered = width !== null || height !== null;\n if (!isRendered) {\n return;\n }\n const didWidthChange = width !== widthRef.current;\n const didHeightChange = height !== heightRef.current;\n if (!didWidthChange && !didHeightChange) {\n return;\n }\n\n /*\n * After the initial render, the useResizeAware will set the first\n * width and height values. We'll sync those values with our\n * width and height refs. However, we shouldn't render our Tooltip\n * label on this first cycle.\n */\n if (width && !widthRef.current && height && !heightRef.current) {\n widthRef.current = width;\n heightRef.current = height;\n return;\n }\n\n /*\n * After the first cycle, we can track width and height changes.\n */\n if (didWidthChange) {\n setMoveX(true);\n widthRef.current = width;\n }\n if (didHeightChange) {\n setMoveY(true);\n heightRef.current = height;\n }\n onResize({\n width,\n height\n });\n debounceUnsetMoveXY();\n }, [width, height, onResize, debounceUnsetMoveXY]);\n const label = getSizeLabel({\n axis,\n height,\n moveX,\n moveY,\n position,\n showPx,\n width\n });\n return {\n label,\n resizeListener\n };\n}\n/**\n * Gets the resize label based on width and height values (as well as recent changes).\n *\n * @param props\n * @param props.axis Only shows the label corresponding to the axis.\n * @param props.height Height value.\n * @param props.moveX Recent width (x axis) changes.\n * @param props.moveY Recent width (y axis) changes.\n * @param props.position Adjusts label value.\n * @param props.showPx Whether to add `PX` to the label.\n * @param props.width Width value.\n *\n * @return The rendered label.\n */\nfunction getSizeLabel({\n axis,\n height,\n moveX = false,\n moveY = false,\n position = POSITIONS.bottom,\n showPx = false,\n width\n}) {\n if (!moveX && !moveY) {\n return undefined;\n }\n\n /*\n * Corner position...\n * We want the label to appear like width x height.\n */\n if (position === POSITIONS.corner) {\n return `${width} x ${height}`;\n }\n\n /*\n * Other POSITIONS...\n * The label will combine both width x height values if both\n * values have recently been changed.\n *\n * Otherwise, only width or height will be displayed.\n * The `PX` unit will be added, if specified by the `showPx` prop.\n */\n const labelUnit = showPx ? ' px' : '';\n if (axis) {\n if (axis === 'x' && moveX) {\n return `${width}${labelUnit}`;\n }\n if (axis === 'y' && moveY) {\n return `${height}${labelUnit}`;\n }\n }\n if (moveX && moveY) {\n return `${width} x ${height}`;\n }\n if (moveX) {\n return `${width}${labelUnit}`;\n }\n if (moveY) {\n return `${height}${labelUnit}`;\n }\n return undefined;\n}"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAAyD;AACzD,qBAAkC;AAClC,IAAM,OAAO,MAAM;AAAC;AACb,IAAM,YAAY;AAAA,EACvB,QAAQ;AAAA,EACR,QAAQ;AACV;AAcO,SAAS,eAAe;AAAA,EAC7B;AAAA,EACA,cAAc;AAAA,EACd,WAAW;AAAA,EACX,WAAW,UAAU;AAAA,EACrB,SAAS;AACX,GAAG;AAKD,QAAM,CAAC,gBAAgB,KAAK,QAAI,kCAAkB;AAOlD,QAAM,mBAAmB,CAAC,CAAC;AAM3B,QAAM,CAAC,OAAO,QAAQ,QAAI,yBAAS,KAAK;AACxC,QAAM,CAAC,OAAO,QAAQ,QAAI,yBAAS,KAAK;AAMxC,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,EACF,IAAI;AACJ,QAAM,gBAAY,uBAAO,MAAM;AAC/B,QAAM,eAAW,uBAAO,KAAK;AAM7B,QAAM,qBAAiB,uBAAO;
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useCallback, useEffect, useRef, useState } from '@wordpress/element';\nimport { useResizeObserver } from '@wordpress/compose';\nconst noop = () => {};\nexport const POSITIONS = {\n bottom: 'bottom',\n corner: 'corner'\n};\n/**\n * Custom hook that manages resize listener events. It also provides a label\n * based on current resize width x height values.\n *\n * @param props\n * @param props.axis Only shows the label corresponding to the axis.\n * @param props.fadeTimeout Duration (ms) before deactivating the resize label.\n * @param props.onResize Callback when a resize occurs. Provides { width, height } callback.\n * @param props.position Adjusts label value.\n * @param props.showPx Whether to add `PX` to the label.\n *\n * @return Properties for hook.\n */\nexport function useResizeLabel({\n axis,\n fadeTimeout = 180,\n onResize = noop,\n position = POSITIONS.bottom,\n showPx = false\n}) {\n /*\n * The width/height values derive from this special useResizeObserver hook.\n * This custom hook uses the ResizeObserver API to listen for resize events.\n */\n const [resizeListener, sizes] = useResizeObserver();\n\n /*\n * Indicates if the x/y axis is preferred.\n * If set, we will avoid resetting the moveX and moveY values.\n * This will allow for the preferred axis values to persist in the label.\n */\n const isAxisControlled = !!axis;\n\n /*\n * The moveX and moveY values are used to track whether the label should\n * display width, height, or width x height.\n */\n const [moveX, setMoveX] = useState(false);\n const [moveY, setMoveY] = useState(false);\n\n /*\n * Cached dimension values to check for width/height updates from the\n * sizes property from useResizeAware()\n */\n const {\n width,\n height\n } = sizes;\n const heightRef = useRef(height);\n const widthRef = useRef(width);\n\n /*\n * This timeout is used with setMoveX and setMoveY to determine of\n * both width and height values have changed at (roughly) the same time.\n */\n const moveTimeoutRef = useRef(undefined);\n const debounceUnsetMoveXY = useCallback(() => {\n const unsetMoveXY = () => {\n /*\n * If axis is controlled, we will avoid resetting the moveX and moveY values.\n * This will allow for the preferred axis values to persist in the label.\n */\n if (isAxisControlled) {\n return;\n }\n setMoveX(false);\n setMoveY(false);\n };\n if (moveTimeoutRef.current) {\n window.clearTimeout(moveTimeoutRef.current);\n }\n moveTimeoutRef.current = window.setTimeout(unsetMoveXY, fadeTimeout);\n }, [fadeTimeout, isAxisControlled]);\n useEffect(() => {\n /*\n * On the initial render of useResizeAware, the height and width values are\n * null. They are calculated then set using via an internal useEffect hook.\n */\n const isRendered = width !== null || height !== null;\n if (!isRendered) {\n return;\n }\n const didWidthChange = width !== widthRef.current;\n const didHeightChange = height !== heightRef.current;\n if (!didWidthChange && !didHeightChange) {\n return;\n }\n\n /*\n * After the initial render, the useResizeAware will set the first\n * width and height values. We'll sync those values with our\n * width and height refs. However, we shouldn't render our Tooltip\n * label on this first cycle.\n */\n if (width && !widthRef.current && height && !heightRef.current) {\n widthRef.current = width;\n heightRef.current = height;\n return;\n }\n\n /*\n * After the first cycle, we can track width and height changes.\n */\n if (didWidthChange) {\n setMoveX(true);\n widthRef.current = width;\n }\n if (didHeightChange) {\n setMoveY(true);\n heightRef.current = height;\n }\n onResize({\n width,\n height\n });\n debounceUnsetMoveXY();\n }, [width, height, onResize, debounceUnsetMoveXY]);\n const label = getSizeLabel({\n axis,\n height,\n moveX,\n moveY,\n position,\n showPx,\n width\n });\n return {\n label,\n resizeListener\n };\n}\n/**\n * Gets the resize label based on width and height values (as well as recent changes).\n *\n * @param props\n * @param props.axis Only shows the label corresponding to the axis.\n * @param props.height Height value.\n * @param props.moveX Recent width (x axis) changes.\n * @param props.moveY Recent width (y axis) changes.\n * @param props.position Adjusts label value.\n * @param props.showPx Whether to add `PX` to the label.\n * @param props.width Width value.\n *\n * @return The rendered label.\n */\nfunction getSizeLabel({\n axis,\n height,\n moveX = false,\n moveY = false,\n position = POSITIONS.bottom,\n showPx = false,\n width\n}) {\n if (!moveX && !moveY) {\n return undefined;\n }\n\n /*\n * Corner position...\n * We want the label to appear like width x height.\n */\n if (position === POSITIONS.corner) {\n return `${width} x ${height}`;\n }\n\n /*\n * Other POSITIONS...\n * The label will combine both width x height values if both\n * values have recently been changed.\n *\n * Otherwise, only width or height will be displayed.\n * The `PX` unit will be added, if specified by the `showPx` prop.\n */\n const labelUnit = showPx ? ' px' : '';\n if (axis) {\n if (axis === 'x' && moveX) {\n return `${width}${labelUnit}`;\n }\n if (axis === 'y' && moveY) {\n return `${height}${labelUnit}`;\n }\n }\n if (moveX && moveY) {\n return `${width} x ${height}`;\n }\n if (moveX) {\n return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