@wordpress/components 29.0.0 → 29.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +39 -1
- package/LICENSE.md +1 -1
- package/build/badge/index.js +64 -0
- package/build/badge/index.js.map +1 -0
- package/build/badge/types.js +6 -0
- package/build/badge/types.js.map +1 -0
- package/build/box-control/index.js +5 -1
- package/build/box-control/index.js.map +1 -1
- package/build/box-control/input-control.js +90 -29
- package/build/box-control/input-control.js.map +1 -1
- package/build/box-control/types.js.map +1 -1
- package/build/box-control/utils.js +50 -0
- package/build/box-control/utils.js.map +1 -1
- package/build/button-group/index.js +10 -0
- package/build/button-group/index.js.map +1 -1
- package/build/button-group/types.js.map +1 -1
- package/build/custom-select-control/index.js +3 -5
- package/build/custom-select-control/index.js.map +1 -1
- package/build/custom-select-control-v2/custom-select.js +2 -3
- package/build/custom-select-control-v2/custom-select.js.map +1 -1
- package/build/date-time/date/index.js +1 -0
- package/build/date-time/date/index.js.map +1 -1
- package/build/dimension-control/index.js +1 -0
- package/build/dimension-control/index.js.map +1 -1
- package/build/font-size-picker/styles.js +9 -9
- package/build/font-size-picker/styles.js.map +1 -1
- package/build/heading/hook.js +1 -1
- package/build/heading/hook.js.map +1 -1
- package/build/input-control/index.js +9 -0
- package/build/input-control/index.js.map +1 -1
- package/build/input-control/types.js.map +1 -1
- package/build/menu/checkbox-item.js +2 -0
- package/build/menu/checkbox-item.js.map +1 -1
- package/build/menu/index.js +25 -94
- package/build/menu/index.js.map +1 -1
- package/build/menu/item.js +10 -1
- package/build/menu/item.js.map +1 -1
- package/build/menu/popover.js +89 -0
- package/build/menu/popover.js.map +1 -0
- package/build/menu/radio-item.js +2 -0
- package/build/menu/radio-item.js.map +1 -1
- package/build/menu/submenu-trigger-item.js +58 -0
- package/build/menu/submenu-trigger-item.js.map +1 -0
- package/build/menu/trigger-button.js +45 -0
- package/build/menu/trigger-button.js.map +1 -0
- package/build/menu/types.js.map +1 -1
- package/build/navigation/back-button/index.js +1 -0
- package/build/navigation/back-button/index.js.map +1 -1
- package/build/navigation/index.js +6 -0
- package/build/navigation/index.js.map +1 -1
- package/build/navigation/item/index.js +1 -0
- package/build/navigation/item/index.js.map +1 -1
- package/build/number-control/index.js +1 -0
- package/build/number-control/index.js.map +1 -1
- package/build/palette-edit/index.js +1 -0
- package/build/palette-edit/index.js.map +1 -1
- package/build/private-apis.js +3 -1
- package/build/private-apis.js.map +1 -1
- package/build/radio-group/index.js +6 -0
- package/build/radio-group/index.js.map +1 -1
- package/build/radio-group/radio.js +2 -3
- package/build/radio-group/radio.js.map +1 -1
- package/build/range-control/styles/range-control-styles.js +28 -28
- package/build/range-control/styles/range-control-styles.js.map +1 -1
- package/build/select-control/index.js +9 -0
- package/build/select-control/index.js.map +1 -1
- package/build/select-control/types.js.map +1 -1
- package/build/slot-fill/context.js +4 -3
- package/build/slot-fill/context.js.map +1 -1
- package/build/slot-fill/fill.js +10 -15
- package/build/slot-fill/fill.js.map +1 -1
- package/build/slot-fill/provider.js +41 -55
- package/build/slot-fill/provider.js.map +1 -1
- package/build/slot-fill/slot.js +31 -23
- package/build/slot-fill/slot.js.map +1 -1
- package/build/slot-fill/types.js.map +1 -1
- package/build/tab-panel/index.js +2 -3
- package/build/tab-panel/index.js.map +1 -1
- package/build/tabs/index.js +21 -4
- package/build/tabs/index.js.map +1 -1
- package/build/tabs/types.js.map +1 -1
- package/build/text/hook.js +6 -6
- package/build/text/hook.js.map +1 -1
- package/build/text/styles.js +7 -7
- package/build/text/styles.js.map +1 -1
- package/build/toggle-group-control/toggle-group-control/as-radio-group.js +2 -3
- package/build/toggle-group-control/toggle-group-control/as-radio-group.js.map +1 -1
- package/build/tooltip/index.js +2 -3
- package/build/tooltip/index.js.map +1 -1
- package/build/tree-select/index.js +10 -2
- package/build/tree-select/index.js.map +1 -1
- package/build/tree-select/types.js.map +1 -1
- package/build-module/badge/index.js +57 -0
- package/build-module/badge/index.js.map +1 -0
- package/build-module/badge/types.js +2 -0
- package/build-module/badge/types.js.map +1 -0
- package/build-module/box-control/index.js +5 -1
- package/build-module/box-control/index.js.map +1 -1
- package/build-module/box-control/input-control.js +92 -31
- package/build-module/box-control/input-control.js.map +1 -1
- package/build-module/box-control/types.js.map +1 -1
- package/build-module/box-control/utils.js +47 -0
- package/build-module/box-control/utils.js.map +1 -1
- package/build-module/button-group/index.js +10 -0
- package/build-module/button-group/index.js.map +1 -1
- package/build-module/button-group/types.js.map +1 -1
- package/build-module/custom-select-control/index.js +3 -5
- package/build-module/custom-select-control/index.js.map +1 -1
- package/build-module/custom-select-control-v2/custom-select.js +1 -2
- package/build-module/custom-select-control-v2/custom-select.js.map +1 -1
- package/build-module/date-time/date/index.js +1 -0
- package/build-module/date-time/date/index.js.map +1 -1
- package/build-module/dimension-control/index.js +1 -0
- package/build-module/dimension-control/index.js.map +1 -1
- package/build-module/font-size-picker/styles.js +9 -9
- package/build-module/font-size-picker/styles.js.map +1 -1
- package/build-module/heading/hook.js +1 -1
- package/build-module/heading/hook.js.map +1 -1
- package/build-module/input-control/index.js +9 -0
- package/build-module/input-control/index.js.map +1 -1
- package/build-module/input-control/types.js.map +1 -1
- package/build-module/menu/checkbox-item.js +2 -0
- package/build-module/menu/checkbox-item.js.map +1 -1
- package/build-module/menu/index.js +28 -97
- package/build-module/menu/index.js.map +1 -1
- package/build-module/menu/item.js +10 -1
- package/build-module/menu/item.js.map +1 -1
- package/build-module/menu/popover.js +81 -0
- package/build-module/menu/popover.js.map +1 -0
- package/build-module/menu/radio-item.js +2 -0
- package/build-module/menu/radio-item.js.map +1 -1
- package/build-module/menu/submenu-trigger-item.js +50 -0
- package/build-module/menu/submenu-trigger-item.js.map +1 -0
- package/build-module/menu/trigger-button.js +37 -0
- package/build-module/menu/trigger-button.js.map +1 -0
- package/build-module/menu/types.js.map +1 -1
- package/build-module/navigation/back-button/index.js +1 -0
- package/build-module/navigation/back-button/index.js.map +1 -1
- package/build-module/navigation/index.js +6 -0
- package/build-module/navigation/index.js.map +1 -1
- package/build-module/navigation/item/index.js +1 -0
- package/build-module/navigation/item/index.js.map +1 -1
- package/build-module/number-control/index.js +1 -0
- package/build-module/number-control/index.js.map +1 -1
- package/build-module/palette-edit/index.js +1 -0
- package/build-module/palette-edit/index.js.map +1 -1
- package/build-module/private-apis.js +3 -1
- package/build-module/private-apis.js.map +1 -1
- package/build-module/radio-group/index.js +6 -0
- package/build-module/radio-group/index.js.map +1 -1
- package/build-module/radio-group/radio.js +1 -2
- package/build-module/radio-group/radio.js.map +1 -1
- package/build-module/range-control/styles/range-control-styles.js +28 -28
- package/build-module/range-control/styles/range-control-styles.js.map +1 -1
- package/build-module/select-control/index.js +9 -0
- package/build-module/select-control/index.js.map +1 -1
- package/build-module/select-control/types.js.map +1 -1
- package/build-module/slot-fill/context.js +5 -3
- package/build-module/slot-fill/context.js.map +1 -1
- package/build-module/slot-fill/fill.js +10 -15
- package/build-module/slot-fill/fill.js.map +1 -1
- package/build-module/slot-fill/provider.js +41 -55
- package/build-module/slot-fill/provider.js.map +1 -1
- package/build-module/slot-fill/slot.js +32 -24
- package/build-module/slot-fill/slot.js.map +1 -1
- package/build-module/slot-fill/types.js.map +1 -1
- package/build-module/tab-panel/index.js +1 -2
- package/build-module/tab-panel/index.js.map +1 -1
- package/build-module/tabs/index.js +21 -4
- package/build-module/tabs/index.js.map +1 -1
- package/build-module/tabs/types.js.map +1 -1
- package/build-module/text/hook.js +6 -6
- package/build-module/text/hook.js.map +1 -1
- package/build-module/text/styles.js +7 -7
- package/build-module/text/styles.js.map +1 -1
- package/build-module/toggle-group-control/toggle-group-control/as-radio-group.js +1 -2
- package/build-module/toggle-group-control/toggle-group-control/as-radio-group.js.map +1 -1
- package/build-module/tooltip/index.js +1 -2
- package/build-module/tooltip/index.js.map +1 -1
- package/build-module/tree-select/index.js +10 -2
- package/build-module/tree-select/index.js.map +1 -1
- package/build-module/tree-select/types.js.map +1 -1
- package/build-style/style-rtl.css +60 -13
- package/build-style/style.css +60 -13
- package/build-types/alignment-matrix-control/stories/index.story.d.ts +1 -1
- package/build-types/alignment-matrix-control/stories/index.story.d.ts.map +1 -1
- package/build-types/angle-picker-control/stories/index.story.d.ts +1 -1
- package/build-types/animate/stories/index.story.d.ts +7 -7
- package/build-types/animate/stories/index.story.d.ts.map +1 -1
- package/build-types/badge/index.d.ts +8 -0
- package/build-types/badge/index.d.ts.map +1 -0
- package/build-types/badge/stories/index.story.d.ts +17 -0
- package/build-types/badge/stories/index.story.d.ts.map +1 -0
- package/build-types/badge/test/index.d.ts +2 -0
- package/build-types/badge/test/index.d.ts.map +1 -0
- package/build-types/badge/types.d.ts +13 -0
- package/build-types/badge/types.d.ts.map +1 -0
- package/build-types/base-control/stories/index.story.d.ts +1 -1
- package/build-types/border-box-control/stories/index.story.d.ts +1 -1
- package/build-types/border-control/stories/index.story.d.ts +5 -5
- package/build-types/box-control/index.d.ts +1 -1
- package/build-types/box-control/index.d.ts.map +1 -1
- package/build-types/box-control/input-control.d.ts +1 -1
- package/build-types/box-control/input-control.d.ts.map +1 -1
- package/build-types/box-control/stories/index.story.d.ts +356 -11
- package/build-types/box-control/stories/index.story.d.ts.map +1 -1
- package/build-types/box-control/styles/box-control-styles.d.ts +2 -2
- package/build-types/box-control/types.d.ts +17 -0
- package/build-types/box-control/types.d.ts.map +1 -1
- package/build-types/box-control/utils.d.ts +27 -1
- package/build-types/box-control/utils.d.ts.map +1 -1
- package/build-types/button/stories/e2e/index.story.d.ts +1 -1
- package/build-types/button/stories/e2e/index.story.d.ts.map +1 -1
- package/build-types/button/stories/index.story.d.ts +7 -7
- package/build-types/button/stories/index.story.d.ts.map +1 -1
- package/build-types/button-group/index.d.ts +3 -1
- package/build-types/button-group/index.d.ts.map +1 -1
- package/build-types/button-group/stories/index.story.d.ts +6 -0
- package/build-types/button-group/stories/index.story.d.ts.map +1 -1
- package/build-types/button-group/types.d.ts +7 -0
- package/build-types/button-group/types.d.ts.map +1 -1
- package/build-types/circular-option-picker/stories/index.story.d.ts +5 -5
- package/build-types/circular-option-picker/stories/index.story.d.ts.map +1 -1
- package/build-types/color-palette/stories/index.story.d.ts +3 -3
- package/build-types/color-palette/stories/index.story.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/stories/index.story.d.ts +4 -4
- package/build-types/confirm-dialog/stories/index.story.d.ts +2 -2
- package/build-types/confirm-dialog/stories/index.story.d.ts.map +1 -1
- package/build-types/custom-gradient-picker/stories/index.story.d.ts +1 -1
- package/build-types/custom-gradient-picker/stories/index.story.d.ts.map +1 -1
- package/build-types/custom-select-control/stories/index.story.d.ts +3 -3
- package/build-types/custom-select-control/stories/index.story.d.ts.map +1 -1
- package/build-types/custom-select-control-v2/custom-select.d.ts.map +1 -1
- package/build-types/custom-select-control-v2/stories/index.story.d.ts +3 -3
- package/build-types/custom-select-control-v2/stories/index.story.d.ts.map +1 -1
- package/build-types/date-time/date/index.d.ts.map +1 -1
- package/build-types/date-time/stories/time.story.d.ts +1 -1
- package/build-types/date-time/stories/time.story.d.ts.map +1 -1
- package/build-types/date-time/time/styles.d.ts +4 -4
- package/build-types/dimension-control/index.d.ts.map +1 -1
- package/build-types/dimension-control/stories/index.story.d.ts +1 -1
- package/build-types/disabled/stories/index.story.d.ts.map +1 -1
- package/build-types/drop-zone/stories/index.story.d.ts +1 -1
- package/build-types/drop-zone/stories/index.story.d.ts.map +1 -1
- package/build-types/duotone-picker/stories/duotone-picker.story.d.ts +1 -1
- package/build-types/duotone-picker/stories/duotone-picker.story.d.ts.map +1 -1
- package/build-types/duotone-picker/stories/duotone-swatch.story.d.ts +3 -3
- package/build-types/duotone-picker/stories/duotone-swatch.story.d.ts.map +1 -1
- package/build-types/focal-point-picker/stories/index.story.d.ts +4 -4
- package/build-types/focal-point-picker/styles/focal-point-picker-style.d.ts +1 -1
- package/build-types/font-size-picker/styles.d.ts.map +1 -1
- package/build-types/form-file-upload/stories/index.story.d.ts +5 -5
- package/build-types/form-file-upload/stories/index.story.d.ts.map +1 -1
- package/build-types/gradient-picker/stories/index.story.d.ts +3 -3
- package/build-types/gradient-picker/stories/index.story.d.ts.map +1 -1
- package/build-types/guide/stories/index.story.d.ts +1 -1
- package/build-types/guide/stories/index.story.d.ts.map +1 -1
- package/build-types/icon/stories/index.story.d.ts +4 -4
- package/build-types/icon/stories/index.story.d.ts.map +1 -1
- package/build-types/input-control/index.d.ts +1 -0
- package/build-types/input-control/index.d.ts.map +1 -1
- package/build-types/input-control/stories/index.story.d.ts +7 -7
- package/build-types/input-control/stories/index.story.d.ts.map +1 -1
- package/build-types/input-control/types.d.ts +11 -2
- package/build-types/input-control/types.d.ts.map +1 -1
- package/build-types/keyboard-shortcuts/stories/index.story.d.ts +1 -1
- package/build-types/keyboard-shortcuts/stories/index.story.d.ts.map +1 -1
- package/build-types/menu/checkbox-item.d.ts.map +1 -1
- package/build-types/menu/index.d.ts +10 -1
- package/build-types/menu/index.d.ts.map +1 -1
- package/build-types/menu/item.d.ts.map +1 -1
- package/build-types/menu/popover.d.ts +3 -0
- package/build-types/menu/popover.d.ts.map +1 -0
- package/build-types/menu/radio-item.d.ts.map +1 -1
- package/build-types/menu/stories/index.story.d.ts +9 -9
- package/build-types/menu/stories/index.story.d.ts.map +1 -1
- package/build-types/menu/submenu-trigger-item.d.ts +3 -0
- package/build-types/menu/submenu-trigger-item.d.ts.map +1 -0
- package/build-types/menu/trigger-button.d.ts +3 -0
- package/build-types/menu/trigger-button.d.ts.map +1 -0
- package/build-types/menu/types.d.ts +208 -57
- package/build-types/menu/types.d.ts.map +1 -1
- package/build-types/menu-group/stories/index.story.d.ts +1 -1
- package/build-types/menu-group/stories/index.story.d.ts.map +1 -1
- package/build-types/menu-item/stories/index.story.d.ts +4 -4
- package/build-types/modal/stories/index.story.d.ts.map +1 -1
- package/build-types/navigation/back-button/index.d.ts.map +1 -1
- package/build-types/navigation/index.d.ts.map +1 -1
- package/build-types/navigation/item/index.d.ts.map +1 -1
- package/build-types/navigation/stories/index.story.d.ts +6 -6
- package/build-types/navigation/stories/index.story.d.ts.map +1 -1
- package/build-types/notice/stories/index.story.d.ts +4 -4
- package/build-types/notice/stories/index.story.d.ts.map +1 -1
- package/build-types/number-control/index.d.ts +1 -1
- package/build-types/number-control/index.d.ts.map +1 -1
- package/build-types/number-control/stories/index.story.d.ts +2 -2
- package/build-types/palette-edit/index.d.ts.map +1 -1
- package/build-types/palette-edit/stories/index.story.d.ts +2 -2
- package/build-types/palette-edit/stories/index.story.d.ts.map +1 -1
- package/build-types/private-apis.d.ts.map +1 -1
- package/build-types/progress-bar/stories/index.story.d.ts +1 -1
- package/build-types/progress-bar/stories/index.story.d.ts.map +1 -1
- package/build-types/query-controls/stories/index.story.d.ts +1 -1
- package/build-types/query-controls/stories/index.story.d.ts.map +1 -1
- package/build-types/radio-group/index.d.ts.map +1 -1
- package/build-types/radio-group/radio.d.ts.map +1 -1
- package/build-types/range-control/index.d.ts +1 -1
- package/build-types/range-control/styles/range-control-styles.d.ts +1 -1
- package/build-types/range-control/styles/range-control-styles.d.ts.map +1 -1
- package/build-types/resizable-box/stories/index.story.d.ts +2 -2
- package/build-types/responsive-wrapper/stories/index.story.d.ts +1 -1
- package/build-types/responsive-wrapper/stories/index.story.d.ts.map +1 -1
- package/build-types/sandbox/stories/index.story.d.ts +1 -1
- package/build-types/sandbox/stories/index.story.d.ts.map +1 -1
- package/build-types/search-control/stories/index.story.d.ts +1 -1
- package/build-types/search-control/stories/index.story.d.ts.map +1 -1
- package/build-types/select-control/index.d.ts +1 -0
- package/build-types/select-control/index.d.ts.map +1 -1
- package/build-types/select-control/stories/index.story.d.ts +5 -5
- package/build-types/select-control/stories/index.story.d.ts.map +1 -1
- package/build-types/select-control/types.d.ts +1 -1
- package/build-types/select-control/types.d.ts.map +1 -1
- package/build-types/shortcut/stories/index.story.d.ts +1 -1
- package/build-types/shortcut/stories/index.story.d.ts.map +1 -1
- package/build-types/slot-fill/context.d.ts.map +1 -1
- package/build-types/slot-fill/fill.d.ts.map +1 -1
- package/build-types/slot-fill/provider.d.ts.map +1 -1
- package/build-types/slot-fill/slot.d.ts.map +1 -1
- package/build-types/slot-fill/types.d.ts +13 -11
- package/build-types/slot-fill/types.d.ts.map +1 -1
- package/build-types/tab-panel/index.d.ts.map +1 -1
- package/build-types/tab-panel/stories/index.story.d.ts +4 -4
- package/build-types/tab-panel/stories/index.story.d.ts.map +1 -1
- package/build-types/tabs/index.d.ts +21 -4
- package/build-types/tabs/index.d.ts.map +1 -1
- package/build-types/tabs/stories/index.story.d.ts +10 -10
- package/build-types/tabs/stories/index.story.d.ts.map +1 -1
- package/build-types/tabs/types.d.ts +13 -13
- package/build-types/tabs/types.d.ts.map +1 -1
- package/build-types/text/stories/index.story.d.ts +3 -3
- package/build-types/theme/stories/index.story.d.ts +1 -1
- package/build-types/toggle-control/stories/index.story.d.ts +2 -2
- package/build-types/toggle-group-control/toggle-group-control/as-radio-group.d.ts.map +1 -1
- package/build-types/toolbar/stories/index.story.d.ts +3 -3
- package/build-types/toolbar/stories/index.story.d.ts.map +1 -1
- package/build-types/tooltip/index.d.ts.map +1 -1
- package/build-types/tooltip/stories/index.story.d.ts +1 -1
- package/build-types/tooltip/stories/index.story.d.ts.map +1 -1
- package/build-types/tree-grid/stories/index.story.d.ts +1 -1
- package/build-types/tree-grid/stories/index.story.d.ts.map +1 -1
- package/build-types/tree-select/index.d.ts +3 -2
- package/build-types/tree-select/index.d.ts.map +1 -1
- package/build-types/tree-select/stories/index.story.d.ts +1 -1
- package/build-types/tree-select/stories/index.story.d.ts.map +1 -1
- package/build-types/tree-select/types.d.ts +5 -1
- package/build-types/tree-select/types.d.ts.map +1 -1
- package/build-types/unit-control/index.d.ts +1 -1
- package/build-types/unit-control/styles/unit-control-styles.d.ts +1 -1
- package/build-types/v-stack/stories/index.story.d.ts +1 -1
- package/package.json +19 -19
- package/src/alignment-matrix-control/README.md +16 -15
- package/src/angle-picker-control/README.md +10 -9
- package/src/badge/README.md +24 -0
- package/src/badge/docs-manifest.json +5 -0
- package/src/badge/index.tsx +67 -0
- package/src/badge/stories/index.story.tsx +54 -0
- package/src/badge/styles.scss +49 -0
- package/src/badge/test/index.tsx +45 -0
- package/src/badge/types.ts +12 -0
- package/src/base-control/README.md +22 -21
- package/src/box-control/README.md +41 -24
- package/src/box-control/index.tsx +4 -0
- package/src/box-control/input-control.tsx +142 -40
- package/src/box-control/stories/index.story.tsx +12 -0
- package/src/box-control/types.ts +18 -0
- package/src/box-control/utils.ts +60 -0
- package/src/button/README.md +51 -50
- package/src/button/style.scss +9 -10
- package/src/button/test/index.tsx +9 -2
- package/src/button-group/README.md +4 -0
- package/src/button-group/index.tsx +11 -1
- package/src/button-group/stories/index.story.tsx +8 -1
- package/src/button-group/types.ts +7 -0
- package/src/custom-select-control/index.tsx +3 -3
- package/src/custom-select-control-v2/custom-select.tsx +1 -2
- package/src/custom-select-control-v2/stories/index.story.tsx +4 -0
- package/src/date-time/date/index.tsx +1 -0
- package/src/dimension-control/index.tsx +1 -0
- package/src/dimension-control/test/__snapshots__/index.test.js.snap +4 -4
- package/src/disabled/stories/index.story.tsx +1 -0
- package/src/drop-zone/stories/index.story.tsx +7 -1
- package/src/font-size-picker/styles.ts +1 -0
- package/src/form-file-upload/README.md +22 -21
- package/src/gradient-picker/README.md +36 -35
- package/src/heading/hook.ts +1 -1
- package/src/heading/test/__snapshots__/index.tsx.snap +4 -4
- package/src/icon/README.md +9 -8
- package/src/input-control/README.md +1 -0
- package/src/input-control/index.tsx +10 -0
- package/src/input-control/stories/index.story.tsx +6 -1
- package/src/input-control/test/index.js +9 -3
- package/src/input-control/types.ts +11 -2
- package/src/menu/checkbox-item.tsx +2 -1
- package/src/menu/index.tsx +61 -165
- package/src/menu/item.tsx +17 -2
- package/src/menu/popover.tsx +103 -0
- package/src/menu/radio-item.tsx +2 -1
- package/src/menu/stories/index.story.tsx +533 -381
- package/src/menu/submenu-trigger-item.tsx +61 -0
- package/src/menu/test/index.tsx +266 -182
- package/src/menu/trigger-button.tsx +46 -0
- package/src/menu/types.ts +210 -63
- package/src/modal/stories/index.story.tsx +4 -1
- package/src/navigation/back-button/index.tsx +1 -0
- package/src/navigation/index.tsx +7 -0
- package/src/navigation/item/index.tsx +2 -0
- package/src/navigation/test/index.tsx +4 -0
- package/src/navigator/test/index.tsx +4 -0
- package/src/number-control/index.tsx +1 -0
- package/src/palette-edit/index.tsx +1 -0
- package/src/panel/stories/index.story.tsx +3 -3
- package/src/private-apis.ts +2 -0
- package/src/radio-group/index.tsx +12 -1
- package/src/radio-group/radio.tsx +1 -2
- package/src/range-control/styles/range-control-styles.ts +8 -4
- package/src/select-control/README.md +3 -0
- package/src/select-control/index.tsx +10 -0
- package/src/select-control/stories/index.story.tsx +2 -0
- package/src/select-control/test/select-control.tsx +7 -1
- package/src/select-control/types.ts +1 -0
- package/src/slot-fill/context.ts +5 -3
- package/src/slot-fill/fill.ts +10 -15
- package/src/slot-fill/provider.tsx +63 -64
- package/src/slot-fill/slot.tsx +40 -27
- package/src/slot-fill/types.ts +23 -11
- package/src/style.scss +1 -0
- package/src/tab-panel/index.tsx +1 -2
- package/src/tab-panel/stories/index.story.tsx +4 -0
- package/src/tabs/README.md +151 -187
- package/src/tabs/docs-manifest.json +22 -0
- package/src/tabs/index.tsx +21 -4
- package/src/tabs/stories/best-practices.mdx +99 -0
- package/src/tabs/stories/index.story.tsx +5 -0
- package/src/tabs/types.ts +13 -14
- package/src/text/hook.ts +2 -2
- package/src/text/styles.ts +1 -1
- package/src/text/test/__snapshots__/index.tsx.snap +3 -3
- package/src/text/test/index.tsx +1 -1
- package/src/toggle-group-control/test/__snapshots__/index.tsx.snap +2 -2
- package/src/toggle-group-control/test/index.tsx +7 -1
- package/src/toggle-group-control/toggle-group-control/as-radio-group.tsx +1 -2
- package/src/tooltip/index.tsx +1 -2
- package/src/tree-grid/stories/index.story.tsx +2 -0
- package/src/tree-select/README.md +144 -28
- package/src/tree-select/docs-manifest.json +5 -0
- package/src/tree-select/index.tsx +11 -2
- package/src/tree-select/stories/index.story.tsx +1 -0
- package/src/tree-select/types.ts +8 -1
- package/tsconfig.json +0 -3
- package/tsconfig.tsbuildinfo +1 -1
- package/build/slot-fill/use-slot.js +0 -32
- package/build/slot-fill/use-slot.js.map +0 -1
- package/build-module/slot-fill/use-slot.js +0 -24
- package/build-module/slot-fill/use-slot.js.map +0 -1
- package/build-types/slot-fill/use-slot.d.ts +0 -10
- package/build-types/slot-fill/use-slot.d.ts.map +0 -1
- package/src/slot-fill/use-slot.ts +0 -27
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,42 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
## 29.1.0 (2025-01-02)
|
|
6
|
+
|
|
7
|
+
### Enhancements
|
|
8
|
+
|
|
9
|
+
- `BoxControl`: Add presets support ([#67688](https://github.com/WordPress/gutenberg/pull/67688)).
|
|
10
|
+
- `Navigation`: Upsize back buttons ([#68157](https://github.com/WordPress/gutenberg/pull/68157)).
|
|
11
|
+
- `Heading`: Fix text contrast for dark mode ([#68349](https://github.com/WordPress/gutenberg/pull/68349)).
|
|
12
|
+
- `Text`: Fix text contrast for dark mode ([#68349](https://github.com/WordPress/gutenberg/pull/68349)).
|
|
13
|
+
|
|
14
|
+
### Deprecations
|
|
15
|
+
|
|
16
|
+
- `TreeSelect`: Deprecate 36px default size ([#67855](https://github.com/WordPress/gutenberg/pull/67855)).
|
|
17
|
+
- `SelectControl`: Deprecate 36px default size ([#66898](https://github.com/WordPress/gutenberg/pull/66898)).
|
|
18
|
+
- `InputControl`: Deprecate 36px default size ([#66897](https://github.com/WordPress/gutenberg/pull/66897)).
|
|
19
|
+
- `RadioGroup`: Log deprecation warning ([#68067](https://github.com/WordPress/gutenberg/pull/68067)).
|
|
20
|
+
- Soft deprecate `ButtonGroup` component. Use `ToggleGroupControl` instead ([#65429](https://github.com/WordPress/gutenberg/pull/65429)).
|
|
21
|
+
- `Navigation`: Log deprecation warning for removal in WP 7.1. Use `Navigator` instead ([#68158](https://github.com/WordPress/gutenberg/pull/68158)).
|
|
22
|
+
|
|
23
|
+
### Bug Fixes
|
|
24
|
+
|
|
25
|
+
- `BoxControl`: Better respect for the `min` prop in the Range Slider ([#67819](https://github.com/WordPress/gutenberg/pull/67819)).
|
|
26
|
+
- `FontSizePicker`: Add `display:contents` rule to fix overflowing text in the custom size select. ([#68280](https://github.com/WordPress/gutenberg/pull/68280)).
|
|
27
|
+
- `BoxControl`: Fix aria-valuetext value ([#68362](https://github.com/WordPress/gutenberg/pull/68362)).
|
|
28
|
+
|
|
29
|
+
### Experimental
|
|
30
|
+
|
|
31
|
+
- Add new `Badge` component ([#66555](https://github.com/WordPress/gutenberg/pull/66555)).
|
|
32
|
+
- `Menu`: refactor to more granular sub-components ([#67422](https://github.com/WordPress/gutenberg/pull/67422)).
|
|
33
|
+
- `Badge`: Support text truncation ([#68107](https://github.com/WordPress/gutenberg/pull/68107)).
|
|
34
|
+
|
|
35
|
+
### Internal
|
|
36
|
+
|
|
37
|
+
- `SlotFill`: rewrite the non-portal version to use `observableMap` ([#67400](https://github.com/WordPress/gutenberg/pull/67400)).
|
|
38
|
+
- `DatePicker`: Prepare day buttons for 40px default size ([#68156](https://github.com/WordPress/gutenberg/pull/68156)).
|
|
39
|
+
- `SlotFill`: register slots in a layout effect ([#68176](https://github.com/WordPress/gutenberg/pull/68176)).
|
|
40
|
+
|
|
5
41
|
## 29.0.0 (2024-12-11)
|
|
6
42
|
|
|
7
43
|
### Breaking Changes
|
|
@@ -15,12 +51,13 @@
|
|
|
15
51
|
- `Menu`: Replace hardcoded white color with theme-ready variable ([#67649](https://github.com/WordPress/gutenberg/pull/67649)).
|
|
16
52
|
- `Navigation` (deprecated): Replace hardcoded white color with theme-ready variable ([#67649](https://github.com/WordPress/gutenberg/pull/67649)).
|
|
17
53
|
- `ToggleGroupControl`: Replace hardcoded white color with theme-ready variable ([#67649](https://github.com/WordPress/gutenberg/pull/67649)).
|
|
18
|
-
- `RangeControl`: Update the design of the range control marks ([#67611](https://github.com/WordPress/gutenberg/pull/67611))
|
|
54
|
+
- `RangeControl`: Update the design of the range control marks ([#67611](https://github.com/WordPress/gutenberg/pull/67611)).
|
|
19
55
|
- `BorderBoxControl`: Reduce gap value when unlinked ([#67049](https://github.com/WordPress/gutenberg/pull/67049)).
|
|
20
56
|
- `DropdownMenu`: Increase option height to 40px ([#67435](https://github.com/WordPress/gutenberg/pull/67435)).
|
|
21
57
|
- `MenuItem`: Increase height to 40px ([#67435](https://github.com/WordPress/gutenberg/pull/67435)).
|
|
22
58
|
- `MenuItemsChoice`: Increase option height to 40px ([#67435](https://github.com/WordPress/gutenberg/pull/67435)).
|
|
23
59
|
- `Navigation`: Fix active item hover color ([#67732](https://github.com/WordPress/gutenberg/pull/67732)).
|
|
60
|
+
- `Button`: Adjust `secondary` variant hover style. ([#67325](https://github.com/WordPress/gutenberg/pull/67325)).
|
|
24
61
|
|
|
25
62
|
### Deprecations
|
|
26
63
|
|
|
@@ -48,6 +85,7 @@
|
|
|
48
85
|
|
|
49
86
|
- `ResizableBox`: Make drag handles focusable ([#67305](https://github.com/WordPress/gutenberg/pull/67305)).
|
|
50
87
|
- `CustomSelectControl`: Update correctly when `showSelectedHint` is enabled ([#67733](https://github.com/WordPress/gutenberg/pull/67733)).
|
|
88
|
+
- `CustomSelectControl`: Use `useStoreState` to get `currentValue` and avoid stale values ([#67815](https://github.com/WordPress/gutenberg/pull/67815)).
|
|
51
89
|
|
|
52
90
|
## 28.13.0 (2024-11-27)
|
|
53
91
|
|
package/LICENSE.md
CHANGED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _clsx = _interopRequireDefault(require("clsx"));
|
|
9
|
+
var _icons = require("@wordpress/icons");
|
|
10
|
+
var _icon = _interopRequireDefault(require("../icon"));
|
|
11
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
12
|
+
/**
|
|
13
|
+
* External dependencies
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* WordPress dependencies
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Internal dependencies
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
function Badge({
|
|
25
|
+
className,
|
|
26
|
+
intent = 'default',
|
|
27
|
+
children,
|
|
28
|
+
...props
|
|
29
|
+
}) {
|
|
30
|
+
/**
|
|
31
|
+
* Returns an icon based on the badge context.
|
|
32
|
+
*
|
|
33
|
+
* @return The corresponding icon for the provided context.
|
|
34
|
+
*/
|
|
35
|
+
function contextBasedIcon() {
|
|
36
|
+
switch (intent) {
|
|
37
|
+
case 'info':
|
|
38
|
+
return _icons.info;
|
|
39
|
+
case 'success':
|
|
40
|
+
return _icons.published;
|
|
41
|
+
case 'warning':
|
|
42
|
+
return _icons.caution;
|
|
43
|
+
case 'error':
|
|
44
|
+
return _icons.error;
|
|
45
|
+
default:
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("span", {
|
|
50
|
+
className: (0, _clsx.default)('components-badge', `is-${intent}`, intent !== 'default' && 'has-icon', className),
|
|
51
|
+
...props,
|
|
52
|
+
children: [intent !== 'default' && /*#__PURE__*/(0, _jsxRuntime.jsx)(_icon.default, {
|
|
53
|
+
icon: contextBasedIcon(),
|
|
54
|
+
size: 16,
|
|
55
|
+
fill: "currentColor",
|
|
56
|
+
className: "components-badge__icon"
|
|
57
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
58
|
+
className: "components-badge__content",
|
|
59
|
+
children: children
|
|
60
|
+
})]
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
var _default = exports.default = Badge;
|
|
64
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_clsx","_interopRequireDefault","require","_icons","_icon","_jsxRuntime","Badge","className","intent","children","props","contextBasedIcon","info","published","caution","error","jsxs","clsx","jsx","default","icon","size","fill","_default","exports"],"sources":["@wordpress/components/src/badge/index.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { info, caution, error, published } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport type { BadgeProps } from './types';\nimport type { WordPressComponentProps } from '../context';\nimport Icon from '../icon';\n\nfunction Badge( {\n\tclassName,\n\tintent = 'default',\n\tchildren,\n\t...props\n}: WordPressComponentProps< BadgeProps, 'span', false > ) {\n\t/**\n\t * Returns an icon based on the badge context.\n\t *\n\t * @return The corresponding icon for the provided context.\n\t */\n\tfunction contextBasedIcon() {\n\t\tswitch ( intent ) {\n\t\t\tcase 'info':\n\t\t\t\treturn info;\n\t\t\tcase 'success':\n\t\t\t\treturn published;\n\t\t\tcase 'warning':\n\t\t\t\treturn caution;\n\t\t\tcase 'error':\n\t\t\t\treturn error;\n\t\t\tdefault:\n\t\t\t\treturn null;\n\t\t}\n\t}\n\n\treturn (\n\t\t<span\n\t\t\tclassName={ clsx(\n\t\t\t\t'components-badge',\n\t\t\t\t`is-${ intent }`,\n\t\t\t\tintent !== 'default' && 'has-icon',\n\t\t\t\tclassName\n\t\t\t) }\n\t\t\t{ ...props }\n\t\t>\n\t\t\t{ intent !== 'default' && (\n\t\t\t\t<Icon\n\t\t\t\t\ticon={ contextBasedIcon() }\n\t\t\t\t\tsize={ 16 }\n\t\t\t\t\tfill=\"currentColor\"\n\t\t\t\t\tclassName=\"components-badge__icon\"\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t<span className=\"components-bad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[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["@wordpress/components/src/badge/types.ts"],"sourcesContent":["export type BadgeProps = {\n\t/**\n\t * Badge variant.\n\t *\n\t * @default 'default'\n\t */\n\tintent?: 'default' | 'info' | 'success' | 'warning' | 'error';\n\t/**\n\t * Text to display inside the badge.\n\t */\n\tchildren: string;\n};\n"],"mappings":"","ignoreList":[]}
|
|
@@ -80,6 +80,8 @@ function BoxControl({
|
|
|
80
80
|
splitOnAxis = false,
|
|
81
81
|
allowReset = true,
|
|
82
82
|
resetValues = _utils2.DEFAULT_VALUES,
|
|
83
|
+
presets,
|
|
84
|
+
presetKey,
|
|
83
85
|
onMouseOver,
|
|
84
86
|
onMouseOut
|
|
85
87
|
}) {
|
|
@@ -136,7 +138,9 @@ function BoxControl({
|
|
|
136
138
|
setSelectedUnits,
|
|
137
139
|
sides,
|
|
138
140
|
values: inputValues,
|
|
139
|
-
__next40pxDefaultSize
|
|
141
|
+
__next40pxDefaultSize,
|
|
142
|
+
presets,
|
|
143
|
+
presetKey
|
|
140
144
|
};
|
|
141
145
|
(0, _deprecated36pxSize.maybeWarnDeprecated36pxSize)({
|
|
142
146
|
componentName: 'BoxControl',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_compose","require","_element","_i18n","_baseControl","_inputControl","_interopRequireDefault","_linkedButton","_grid","_boxControlStyles","_utils","_utils2","_hooks","_deprecated36pxSize","_jsxRuntime","defaultInputProps","min","noop","useUniqueId","idProp","instanceId","useInstanceId","BoxControl","__next40pxDefaultSize","id","inputProps","onChange","label","__","values","valuesProp","units","sides","splitOnAxis","allowReset","resetValues","DEFAULT_VALUES","onMouseOver","onMouseOut","setValues","useControlledState","fallback","inputValues","hasInitialValue","isValuesDefined","hasOneSide","length","isDirty","setIsDirty","useState","isLinked","setIsLinked","isValueMixed","side","setSide","getInitialSide","selectedUnits","setSelectedUnits","top","parseQuantityAndUnitFromRawValue","right","bottom","left","headingId","toggleLinked","handleOnFocus","_event","nextSide","handleOnChange","nextValues","handleOnReset","inputControlProps","onFocus","maybeWarnDeprecated36pxSize","componentName","size","undefined","sidesToRender","getAllowedSides","jsxs","Grid","columns","templateColumns","role","children","jsx","BaseControl","VisualLabel","InputWrapper","default","LinkedButtonWrapper","onClick","map","axis","Array","from","ResetButton","className","variant","disabled","_default","exports"],"sources":["@wordpress/components/src/box-control/index.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useInstanceId } from '@wordpress/compose';\nimport { useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { BaseControl } from '../base-control';\nimport InputControl from './input-control';\nimport LinkedButton from './linked-button';\nimport { Grid } from '../grid';\nimport {\n\tInputWrapper,\n\tResetButton,\n\tLinkedButtonWrapper,\n} from './styles/box-control-styles';\nimport { parseQuantityAndUnitFromRawValue } from '../unit-control/utils';\nimport {\n\tDEFAULT_VALUES,\n\tgetInitialSide,\n\tisValueMixed,\n\tisValuesDefined,\n\tgetAllowedSides,\n} from './utils';\nimport { useControlledState } from '../utils/hooks';\nimport type {\n\tBoxControlIconProps,\n\tBoxControlProps,\n\tBoxControlValue,\n} from './types';\nimport { maybeWarnDeprecated36pxSize } from '../utils/deprecated-36px-size';\n\nconst defaultInputProps = {\n\tmin: 0,\n};\n\nconst noop = () => {};\n\nfunction useUniqueId( idProp?: string ) {\n\tconst instanceId = useInstanceId( BoxControl, 'inspector-box-control' );\n\n\treturn idProp || instanceId;\n}\n\n/**\n * A control that lets users set values for top, right, bottom, and left. Can be\n * used as an input control for values like `padding` or `margin`.\n *\n * ```jsx\n * import { useState } from 'react';\n * import { BoxControl } from '@wordpress/components';\n *\n * function Example() {\n * const [ values, setValues ] = useState( {\n * top: '50px',\n * left: '10%',\n * right: '10%',\n * bottom: '50px',\n * } );\n *\n * return (\n * <BoxControl\n * __next40pxDefaultSize\n * values={ values }\n * onChange={ setValues }\n * />\n * );\n * };\n * ```\n */\nfunction BoxControl( {\n\t__next40pxDefaultSize = false,\n\tid: idProp,\n\tinputProps = defaultInputProps,\n\tonChange = noop,\n\tlabel = __( 'Box Control' ),\n\tvalues: valuesProp,\n\tunits,\n\tsides,\n\tsplitOnAxis = false,\n\tallowReset = true,\n\tresetValues = DEFAULT_VALUES,\n\tonMouseOver,\n\tonMouseOut,\n}: BoxControlProps ) {\n\tconst [ values, setValues ] = useControlledState( valuesProp, {\n\t\tfallback: DEFAULT_VALUES,\n\t} );\n\tconst inputValues = values || DEFAULT_VALUES;\n\tconst hasInitialValue = isValuesDefined( valuesProp );\n\tconst hasOneSide = sides?.length === 1;\n\n\tconst [ isDirty, setIsDirty ] = useState( hasInitialValue );\n\tconst [ isLinked, setIsLinked ] = useState(\n\t\t! hasInitialValue || ! isValueMixed( inputValues ) || hasOneSide\n\t);\n\n\tconst [ side, setSide ] = useState< BoxControlIconProps[ 'side' ] >(\n\t\tgetInitialSide( isLinked, splitOnAxis )\n\t);\n\n\t// Tracking selected units via internal state allows filtering of CSS unit\n\t// only values from being saved while maintaining preexisting unit selection\n\t// behaviour. Filtering CSS only values prevents invalid style values.\n\tconst [ selectedUnits, setSelectedUnits ] = useState< BoxControlValue >( {\n\t\ttop: parseQuantityAndUnitFromRawValue( valuesProp?.top )[ 1 ],\n\t\tright: parseQuantityAndUnitFromRawValue( valuesProp?.right )[ 1 ],\n\t\tbottom: parseQuantityAndUnitFromRawValue( valuesProp?.bottom )[ 1 ],\n\t\tleft: parseQuantityAndUnitFromRawValue( valuesProp?.left )[ 1 ],\n\t} );\n\n\tconst id = useUniqueId( idProp );\n\tconst headingId = `${ id }-heading`;\n\n\tconst toggleLinked = () => {\n\t\tsetIsLinked( ! isLinked );\n\t\tsetSide( getInitialSide( ! isLinked, splitOnAxis ) );\n\t};\n\n\tconst handleOnFocus = (\n\t\t_event: React.FocusEvent< HTMLInputElement >,\n\t\t{ side: nextSide }: { side: typeof side }\n\t) => {\n\t\tsetSide( nextSide );\n\t};\n\n\tconst handleOnChange = ( nextValues: BoxControlValue ) => {\n\t\tonChange( nextValues );\n\t\tsetValues( nextValues );\n\t\tsetIsDirty( true );\n\t};\n\n\tconst handleOnReset = () => {\n\t\tonChange( resetValues );\n\t\tsetValues( resetValues );\n\t\tsetSelectedUnits( resetValues );\n\t\tsetIsDirty( false );\n\t};\n\n\tconst inputControlProps = {\n\t\tonMouseOver,\n\t\tonMouseOut,\n\t\t...inputProps,\n\t\tonChange: handleOnChange,\n\t\tonFocus: handleOnFocus,\n\t\tisLinked,\n\t\tunits,\n\t\tselectedUnits,\n\t\tsetSelectedUnits,\n\t\tsides,\n\t\tvalues: inputValues,\n\t\t__next40pxDefaultSize,\n\t};\n\n\tmaybeWarnDeprecated36pxSize( {\n\t\tcomponentName: 'BoxControl',\n\t\t__next40pxDefaultSize,\n\t\tsize: undefined,\n\t} );\n\tconst sidesToRender = getAllowedSides( sides );\n\n\treturn (\n\t\t<Grid\n\t\t\tid={ id }\n\t\t\tcolumns={ 3 }\n\t\t\ttemplateColumns=\"1fr min-content min-content\"\n\t\t\trole=\"group\"\n\t\t\taria-labelledby={ headingId }\n\t\t>\n\t\t\t<BaseControl.VisualLabel id={ headingId }>\n\t\t\t\t{ label }\n\t\t\t</BaseControl.VisualLabel>\n\t\t\t{ isLinked && (\n\t\t\t\t<InputWrapper>\n\t\t\t\t\t<InputControl side=\"all\" { ...inputControlProps } />\n\t\t\t\t</InputWrapper>\n\t\t\t) }\n\t\t\t{ ! hasOneSide && (\n\t\t\t\t<LinkedButtonWrapper>\n\t\t\t\t\t<LinkedButton\n\t\t\t\t\t\tonClick={ toggleLinked }\n\t\t\t\t\t\tisLinked={ isLinked }\n\t\t\t\t\t/>\n\t\t\t\t</LinkedButtonWrapper>\n\t\t\t) }\n\n\t\t\t{ ! isLinked &&\n\t\t\t\tsplitOnAxis &&\n\t\t\t\t[ 'vertical', 'horizontal' ].map( ( axis ) => (\n\t\t\t\t\t<InputControl\n\t\t\t\t\t\tkey={ axis }\n\t\t\t\t\t\tside={ axis as 'horizontal' | 'vertical' }\n\t\t\t\t\t\t{ ...inputControlProps }\n\t\t\t\t\t/>\n\t\t\t\t) ) }\n\t\t\t{ ! isLinked &&\n\t\t\t\t! splitOnAxis &&\n\t\t\t\tArray.from( sidesToRender ).map( ( axis ) => (\n\t\t\t\t\t<InputControl\n\t\t\t\t\t\tkey={ axis }\n\t\t\t\t\t\tside={ axis }\n\t\t\t\t\t\t{ ...inputControlProps }\n\t\t\t\t\t/>\n\t\t\t\t) ) }\n\t\t\t{ allowReset && (\n\t\t\t\t<ResetButton\n\t\t\t\t\tclassName=\"component-box-control__reset-button\"\n\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\tsize=\"small\"\n\t\t\t\t\tonClick={ handleOnReset }\n\t\t\t\t\tdisabled={ ! isDirty }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Reset' ) }\n\t\t\t\t</ResetButton>\n\t\t\t) }\n\t\t</Grid>\n\t);\n}\n\nexport { applyValueToSides } from './utils';\nexport default BoxControl;\n"],"mappings":";;;;;;;;;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AAKA,IAAAG,YAAA,GAAAH,OAAA;AACA,IAAAI,aAAA,GAAAC,sBAAA,CAAAL,OAAA;AACA,IAAAM,aAAA,GAAAD,sBAAA,CAAAL,OAAA;AACA,IAAAO,KAAA,GAAAP,OAAA;AACA,IAAAQ,iBAAA,GAAAR,OAAA;AAKA,IAAAS,MAAA,GAAAT,OAAA;AACA,IAAAU,OAAA,GAAAV,OAAA;AAOA,IAAAW,MAAA,GAAAX,OAAA;AAMA,IAAAY,mBAAA,GAAAZ,OAAA;AAA4E,IAAAa,WAAA,GAAAb,OAAA;AAjC5E;AACA;AACA;;AAKA;AACA;AACA;;AA0BA,MAAMc,iBAAiB,GAAG;EACzBC,GAAG,EAAE;AACN,CAAC;AAED,MAAMC,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OAAO,EAAG3B,YAAc;QACxBd,QAAQ,EAAGA;MAAU,CACrB;IAAC,CACkB,CACrB,EAEC,CAAEA,QAAQ,IACXjB,WAAW,IACX,CAAE,UAAU,EAAE,YAAY,CAAE,CAAC2D,GAAG,CAAIC,IAAI,iBACvC,IAAA/E,WAAA,CAAAuE,GAAA,EAAChF,aAAA,CAAAoF,OAAY;MAEZpC,IAAI,EAAGwC,IAAmC;MAAA,GACrCtB;IAAiB,GAFhBsB,IAGN,CACA,CAAC,EACF,CAAE3C,QAAQ,IACX,CAAEjB,WAAW,IACb6D,KAAK,CAACC,IAAI,CAAElB,aAAc,CAAC,CAACe,GAAG,CAAIC,IAAI,iBACtC,IAAA/E,WAAA,CAAAuE,GAAA,EAAChF,aAAA,CAAAoF,OAAY;MAEZpC,IAAI,EAAGwC,IAAM;MAAA,GACRtB;IAAiB,GAFhBsB,IAGN,CACA,CAAC,EACF3D,UAAU,iBACX,IAAApB,WAAA,CAAAuE,GAAA,EAAC5E,iBAAA,CAAAuF,WAAW;MACXC,SAAS,EAAC,qCAAqC;MAC/CC,OAAO,EAAC,WAAW;MACnBvB,IAAI,EAAC,OAAO;MACZgB,OAAO,EAAGrB,aAAe;MACzB6B,QAAQ,EAAG,CAAEpD,OAAS;MAAAqC,QAAA,EAEpB,IAAAxD,QAAE,EAAE,OAAQ;IAAC,CACH,CACb;EAAA,CACI,CAAC;AAET;AAAC,IAAAwE,QAAA,GAAAC,OAAA,CAAAZ,OAAA,GAGcnE,UAAU","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_compose","require","_element","_i18n","_baseControl","_inputControl","_interopRequireDefault","_linkedButton","_grid","_boxControlStyles","_utils","_utils2","_hooks","_deprecated36pxSize","_jsxRuntime","defaultInputProps","min","noop","useUniqueId","idProp","instanceId","useInstanceId","BoxControl","__next40pxDefaultSize","id","inputProps","onChange","label","__","values","valuesProp","units","sides","splitOnAxis","allowReset","resetValues","DEFAULT_VALUES","presets","presetKey","onMouseOver","onMouseOut","setValues","useControlledState","fallback","inputValues","hasInitialValue","isValuesDefined","hasOneSide","length","isDirty","setIsDirty","useState","isLinked","setIsLinked","isValueMixed","side","setSide","getInitialSide","selectedUnits","setSelectedUnits","top","parseQuantityAndUnitFromRawValue","right","bottom","left","headingId","toggleLinked","handleOnFocus","_event","nextSide","handleOnChange","nextValues","handleOnReset","inputControlProps","onFocus","maybeWarnDeprecated36pxSize","componentName","size","undefined","sidesToRender","getAllowedSides","jsxs","Grid","columns","templateColumns","role","children","jsx","BaseControl","VisualLabel","InputWrapper","default","LinkedButtonWrapper","onClick","map","axis","Array","from","ResetButton","className","variant","disabled","_default","exports"],"sources":["@wordpress/components/src/box-control/index.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useInstanceId } from '@wordpress/compose';\nimport { useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { BaseControl } from '../base-control';\nimport InputControl from './input-control';\nimport LinkedButton from './linked-button';\nimport { Grid } from '../grid';\nimport {\n\tInputWrapper,\n\tResetButton,\n\tLinkedButtonWrapper,\n} from './styles/box-control-styles';\nimport { parseQuantityAndUnitFromRawValue } from '../unit-control/utils';\nimport {\n\tDEFAULT_VALUES,\n\tgetInitialSide,\n\tisValueMixed,\n\tisValuesDefined,\n\tgetAllowedSides,\n} from './utils';\nimport { useControlledState } from '../utils/hooks';\nimport type {\n\tBoxControlIconProps,\n\tBoxControlProps,\n\tBoxControlValue,\n} from './types';\nimport { maybeWarnDeprecated36pxSize } from '../utils/deprecated-36px-size';\n\nconst defaultInputProps = {\n\tmin: 0,\n};\n\nconst noop = () => {};\n\nfunction useUniqueId( idProp?: string ) {\n\tconst instanceId = useInstanceId( BoxControl, 'inspector-box-control' );\n\n\treturn idProp || instanceId;\n}\n\n/**\n * A control that lets users set values for top, right, bottom, and left. Can be\n * used as an input control for values like `padding` or `margin`.\n *\n * ```jsx\n * import { useState } from 'react';\n * import { BoxControl } from '@wordpress/components';\n *\n * function Example() {\n * const [ values, setValues ] = useState( {\n * top: '50px',\n * left: '10%',\n * right: '10%',\n * bottom: '50px',\n * } );\n *\n * return (\n * <BoxControl\n * __next40pxDefaultSize\n * values={ values }\n * onChange={ setValues }\n * />\n * );\n * };\n * ```\n */\nfunction BoxControl( {\n\t__next40pxDefaultSize = false,\n\tid: idProp,\n\tinputProps = defaultInputProps,\n\tonChange = noop,\n\tlabel = __( 'Box Control' ),\n\tvalues: valuesProp,\n\tunits,\n\tsides,\n\tsplitOnAxis = false,\n\tallowReset = true,\n\tresetValues = DEFAULT_VALUES,\n\tpresets,\n\tpresetKey,\n\tonMouseOver,\n\tonMouseOut,\n}: BoxControlProps ) {\n\tconst [ values, setValues ] = useControlledState( valuesProp, {\n\t\tfallback: DEFAULT_VALUES,\n\t} );\n\tconst inputValues = values || DEFAULT_VALUES;\n\tconst hasInitialValue = isValuesDefined( valuesProp );\n\tconst hasOneSide = sides?.length === 1;\n\n\tconst [ isDirty, setIsDirty ] = useState( hasInitialValue );\n\tconst [ isLinked, setIsLinked ] = useState(\n\t\t! hasInitialValue || ! isValueMixed( inputValues ) || hasOneSide\n\t);\n\n\tconst [ side, setSide ] = useState< BoxControlIconProps[ 'side' ] >(\n\t\tgetInitialSide( isLinked, splitOnAxis )\n\t);\n\n\t// Tracking selected units via internal state allows filtering of CSS unit\n\t// only values from being saved while maintaining preexisting unit selection\n\t// behaviour. Filtering CSS only values prevents invalid style values.\n\tconst [ selectedUnits, setSelectedUnits ] = useState< BoxControlValue >( {\n\t\ttop: parseQuantityAndUnitFromRawValue( valuesProp?.top )[ 1 ],\n\t\tright: parseQuantityAndUnitFromRawValue( valuesProp?.right )[ 1 ],\n\t\tbottom: parseQuantityAndUnitFromRawValue( valuesProp?.bottom )[ 1 ],\n\t\tleft: parseQuantityAndUnitFromRawValue( valuesProp?.left )[ 1 ],\n\t} );\n\n\tconst id = useUniqueId( idProp );\n\tconst headingId = `${ id }-heading`;\n\n\tconst toggleLinked = () => {\n\t\tsetIsLinked( ! isLinked );\n\t\tsetSide( getInitialSide( ! isLinked, splitOnAxis ) );\n\t};\n\n\tconst handleOnFocus = (\n\t\t_event: React.FocusEvent< HTMLInputElement >,\n\t\t{ side: nextSide }: { side: typeof side }\n\t) => {\n\t\tsetSide( nextSide );\n\t};\n\n\tconst handleOnChange = ( nextValues: BoxControlValue ) => {\n\t\tonChange( nextValues );\n\t\tsetValues( nextValues );\n\t\tsetIsDirty( true );\n\t};\n\n\tconst handleOnReset = () => {\n\t\tonChange( resetValues );\n\t\tsetValues( resetValues );\n\t\tsetSelectedUnits( resetValues );\n\t\tsetIsDirty( false );\n\t};\n\n\tconst inputControlProps = {\n\t\tonMouseOver,\n\t\tonMouseOut,\n\t\t...inputProps,\n\t\tonChange: handleOnChange,\n\t\tonFocus: handleOnFocus,\n\t\tisLinked,\n\t\tunits,\n\t\tselectedUnits,\n\t\tsetSelectedUnits,\n\t\tsides,\n\t\tvalues: inputValues,\n\t\t__next40pxDefaultSize,\n\t\tpresets,\n\t\tpresetKey,\n\t};\n\n\tmaybeWarnDeprecated36pxSize( {\n\t\tcomponentName: 'BoxControl',\n\t\t__next40pxDefaultSize,\n\t\tsize: undefined,\n\t} );\n\tconst sidesToRender = getAllowedSides( sides );\n\n\treturn (\n\t\t<Grid\n\t\t\tid={ id }\n\t\t\tcolumns={ 3 }\n\t\t\ttemplateColumns=\"1fr min-content min-content\"\n\t\t\trole=\"group\"\n\t\t\taria-labelledby={ headingId }\n\t\t>\n\t\t\t<BaseControl.VisualLabel id={ headingId }>\n\t\t\t\t{ label }\n\t\t\t</BaseControl.VisualLabel>\n\t\t\t{ isLinked && (\n\t\t\t\t<InputWrapper>\n\t\t\t\t\t<InputControl side=\"all\" { ...inputControlProps } />\n\t\t\t\t</InputWrapper>\n\t\t\t) }\n\t\t\t{ ! hasOneSide && (\n\t\t\t\t<LinkedButtonWrapper>\n\t\t\t\t\t<LinkedButton\n\t\t\t\t\t\tonClick={ toggleLinked }\n\t\t\t\t\t\tisLinked={ isLinked }\n\t\t\t\t\t/>\n\t\t\t\t</LinkedButtonWrapper>\n\t\t\t) }\n\n\t\t\t{ ! isLinked &&\n\t\t\t\tsplitOnAxis &&\n\t\t\t\t[ 'vertical', 'horizontal' ].map( ( axis ) => (\n\t\t\t\t\t<InputControl\n\t\t\t\t\t\tkey={ axis }\n\t\t\t\t\t\tside={ axis as 'horizontal' | 'vertical' }\n\t\t\t\t\t\t{ ...inputControlProps }\n\t\t\t\t\t/>\n\t\t\t\t) ) }\n\t\t\t{ ! isLinked &&\n\t\t\t\t! splitOnAxis &&\n\t\t\t\tArray.from( sidesToRender ).map( ( axis ) => (\n\t\t\t\t\t<InputControl\n\t\t\t\t\t\tkey={ axis }\n\t\t\t\t\t\tside={ axis }\n\t\t\t\t\t\t{ ...inputControlProps }\n\t\t\t\t\t/>\n\t\t\t\t) ) }\n\t\t\t{ allowReset && (\n\t\t\t\t<ResetButton\n\t\t\t\t\tclassName=\"component-box-control__reset-button\"\n\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\tsize=\"small\"\n\t\t\t\t\tonClick={ handleOnReset }\n\t\t\t\t\tdisabled={ ! isDirty }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Reset' ) }\n\t\t\t\t</ResetButton>\n\t\t\t) }\n\t\t</Grid>\n\t);\n}\n\nexport { applyValueToSides } from './utils';\nexport default BoxControl;\n"],"mappings":";;;;;;;;;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AAKA,IAAAG,YAAA,GAAAH,OAAA;AACA,IAAAI,aAAA,GAAAC,sBAAA,CAAAL,OAAA;AACA,IAAAM,aAAA,GAAAD,sBAAA,CAAAL,OAAA;AACA,IAAAO,KAAA,GAAAP,OAAA;AACA,IAAAQ,iBAAA,GAAAR,OAAA;AAKA,IAAAS,MAAA,GAAAT,OAAA;AACA,IAAAU,OAAA,GAAAV,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 Object.defineProperty(exports, "__esModule", {
|
|
|
8
8
|
exports.default = BoxInputControl;
|
|
9
9
|
var _compose = require("@wordpress/compose");
|
|
10
10
|
var _i18n = require("@wordpress/i18n");
|
|
11
|
+
var _element = require("@wordpress/element");
|
|
12
|
+
var _icons = require("@wordpress/icons");
|
|
11
13
|
var _tooltip = _interopRequireDefault(require("../tooltip"));
|
|
12
14
|
var _utils = require("../unit-control/utils");
|
|
13
15
|
var _utils2 = require("./utils");
|
|
14
16
|
var _boxControlStyles = require("./styles/box-control-styles");
|
|
17
|
+
var _button = _interopRequireDefault(require("../button"));
|
|
15
18
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
16
19
|
/**
|
|
17
20
|
* WordPress dependencies
|
|
@@ -65,6 +68,9 @@ function BoxInputControl({
|
|
|
65
68
|
setSelectedUnits,
|
|
66
69
|
sides,
|
|
67
70
|
side,
|
|
71
|
+
min = 0,
|
|
72
|
+
presets,
|
|
73
|
+
presetKey,
|
|
68
74
|
...props
|
|
69
75
|
}) {
|
|
70
76
|
var _CUSTOM_VALUE_SETTING, _CUSTOM_VALUE_SETTING2;
|
|
@@ -77,6 +83,15 @@ function BoxInputControl({
|
|
|
77
83
|
const handleOnChange = nextValues => {
|
|
78
84
|
onChange(nextValues);
|
|
79
85
|
};
|
|
86
|
+
const handleRawOnValueChange = next => {
|
|
87
|
+
const nextValues = {
|
|
88
|
+
...values
|
|
89
|
+
};
|
|
90
|
+
defaultValuesToModify.forEach(modifiedSide => {
|
|
91
|
+
nextValues[modifiedSide] = next;
|
|
92
|
+
});
|
|
93
|
+
handleOnChange(nextValues);
|
|
94
|
+
};
|
|
80
95
|
const handleOnValueChange = (next, extra) => {
|
|
81
96
|
const nextValues = {
|
|
82
97
|
...values
|
|
@@ -116,45 +131,91 @@ function BoxInputControl({
|
|
|
116
131
|
const isMixedUnit = defaultValuesToModify.length > 1 && mergedValue === undefined && defaultValuesToModify.some(s => selectedUnits[s] !== computedUnit);
|
|
117
132
|
const usedValue = mergedValue === undefined && computedUnit ? computedUnit : mergedValue;
|
|
118
133
|
const mixedPlaceholder = isMixed || isMixedUnit ? (0, _i18n.__)('Mixed') : undefined;
|
|
134
|
+
const hasPresets = presets && presets.length > 0 && presetKey;
|
|
135
|
+
const hasPresetValue = hasPresets && mergedValue !== undefined && !isMixed && (0, _utils2.isValuePreset)(mergedValue, presetKey);
|
|
136
|
+
const [showCustomValueControl, setShowCustomValueControl] = (0, _element.useState)(!hasPresets || !hasPresetValue && !isMixed && mergedValue !== undefined);
|
|
137
|
+
const presetIndex = hasPresetValue ? (0, _utils2.getPresetIndexFromValue)(mergedValue, presetKey, presets) : undefined;
|
|
138
|
+
const marks = hasPresets ? [{
|
|
139
|
+
value: 0,
|
|
140
|
+
label: '',
|
|
141
|
+
tooltip: (0, _i18n.__)('None')
|
|
142
|
+
}].concat(presets.map((preset, index) => {
|
|
143
|
+
var _preset$name;
|
|
144
|
+
return {
|
|
145
|
+
value: index + 1,
|
|
146
|
+
label: '',
|
|
147
|
+
tooltip: (_preset$name = preset.name) !== null && _preset$name !== void 0 ? _preset$name : preset.slug
|
|
148
|
+
};
|
|
149
|
+
})) : [];
|
|
119
150
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_boxControlStyles.InputWrapper, {
|
|
120
151
|
expanded: true,
|
|
121
152
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_boxControlStyles.FlexedBoxControlIcon, {
|
|
122
153
|
side: side,
|
|
123
154
|
sides: sides
|
|
124
|
-
}), /*#__PURE__*/(0, _jsxRuntime.
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
155
|
+
}), showCustomValueControl && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
156
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_tooltip.default, {
|
|
157
|
+
placement: "top-end",
|
|
158
|
+
text: _utils2.LABELS[side],
|
|
159
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_boxControlStyles.StyledUnitControl, {
|
|
160
|
+
...props,
|
|
161
|
+
min: min,
|
|
162
|
+
__shouldNotWarnDeprecated36pxSize: true,
|
|
163
|
+
__next40pxDefaultSize: __next40pxDefaultSize,
|
|
164
|
+
className: "component-box-control__unit-control",
|
|
165
|
+
id: inputId,
|
|
166
|
+
isPressEnterToChange: true,
|
|
167
|
+
disableUnits: isMixed || isMixedUnit,
|
|
168
|
+
value: usedValue,
|
|
169
|
+
onChange: handleOnValueChange,
|
|
170
|
+
onUnitChange: handleOnUnitChange,
|
|
171
|
+
onFocus: handleOnFocus,
|
|
172
|
+
label: _utils2.LABELS[side],
|
|
173
|
+
placeholder: mixedPlaceholder,
|
|
174
|
+
hideLabelFromVision: true
|
|
175
|
+
})
|
|
176
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_boxControlStyles.FlexedRangeControl, {
|
|
177
|
+
__nextHasNoMarginBottom: true,
|
|
130
178
|
__next40pxDefaultSize: __next40pxDefaultSize,
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
isPressEnterToChange: true,
|
|
134
|
-
disableUnits: isMixed || isMixedUnit,
|
|
135
|
-
value: usedValue,
|
|
136
|
-
onChange: handleOnValueChange,
|
|
137
|
-
onUnitChange: handleOnUnitChange,
|
|
138
|
-
onFocus: handleOnFocus,
|
|
179
|
+
__shouldNotWarnDeprecated36pxSize: true,
|
|
180
|
+
"aria-controls": inputId,
|
|
139
181
|
label: _utils2.LABELS[side],
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
182
|
+
hideLabelFromVision: true,
|
|
183
|
+
onChange: newValue => {
|
|
184
|
+
handleOnValueChange(newValue !== undefined ? [newValue, computedUnit].join('') : undefined);
|
|
185
|
+
},
|
|
186
|
+
min: isFinite(min) ? min : 0,
|
|
187
|
+
max: (_CUSTOM_VALUE_SETTING = _utils2.CUSTOM_VALUE_SETTINGS[computedUnit !== null && computedUnit !== void 0 ? computedUnit : 'px']?.max) !== null && _CUSTOM_VALUE_SETTING !== void 0 ? _CUSTOM_VALUE_SETTING : 10,
|
|
188
|
+
step: (_CUSTOM_VALUE_SETTING2 = _utils2.CUSTOM_VALUE_SETTINGS[computedUnit !== null && computedUnit !== void 0 ? computedUnit : 'px']?.step) !== null && _CUSTOM_VALUE_SETTING2 !== void 0 ? _CUSTOM_VALUE_SETTING2 : 0.1,
|
|
189
|
+
value: parsedQuantity !== null && parsedQuantity !== void 0 ? parsedQuantity : 0,
|
|
190
|
+
withInputField: false
|
|
191
|
+
})]
|
|
192
|
+
}), hasPresets && !showCustomValueControl && /*#__PURE__*/(0, _jsxRuntime.jsx)(_boxControlStyles.FlexedRangeControl, {
|
|
193
|
+
__next40pxDefaultSize: true,
|
|
194
|
+
className: "spacing-sizes-control__range-control",
|
|
195
|
+
value: presetIndex !== undefined ? presetIndex + 1 : 0,
|
|
196
|
+
onChange: newIndex => {
|
|
197
|
+
const newValue = newIndex === 0 || newIndex === undefined ? undefined : (0, _utils2.getPresetValueFromIndex)(newIndex - 1, presetKey, presets);
|
|
198
|
+
handleRawOnValueChange(newValue);
|
|
199
|
+
},
|
|
200
|
+
withInputField: false,
|
|
201
|
+
"aria-valuenow": presetIndex !== undefined ? presetIndex + 1 : 0,
|
|
202
|
+
"aria-valuetext": marks[presetIndex !== undefined ? presetIndex + 1 : 0].tooltip,
|
|
203
|
+
renderTooltipContent: index => marks[!index ? 0 : index].tooltip,
|
|
204
|
+
min: 0,
|
|
205
|
+
max: marks.length - 1,
|
|
206
|
+
marks: marks,
|
|
148
207
|
label: _utils2.LABELS[side],
|
|
149
208
|
hideLabelFromVision: true,
|
|
150
|
-
|
|
151
|
-
|
|
209
|
+
__nextHasNoMarginBottom: true
|
|
210
|
+
}), hasPresets && /*#__PURE__*/(0, _jsxRuntime.jsx)(_button.default, {
|
|
211
|
+
label: showCustomValueControl ? (0, _i18n.__)('Use size preset') : (0, _i18n.__)('Set custom size'),
|
|
212
|
+
icon: _icons.settings,
|
|
213
|
+
onClick: () => {
|
|
214
|
+
setShowCustomValueControl(!showCustomValueControl);
|
|
152
215
|
},
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
value: parsedQuantity !== null && parsedQuantity !== void 0 ? parsedQuantity : 0,
|
|
157
|
-
withInputField: false
|
|
216
|
+
isPressed: showCustomValueControl,
|
|
217
|
+
size: "small",
|
|
218
|
+
iconSize: 24
|
|
158
219
|
})]
|
|
159
220
|
}, `box-control-${side}`);
|
|
160
221
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_compose","require","_i18n","_tooltip","_interopRequireDefault","_utils","_utils2","_boxControlStyles","_jsxRuntime","noop","getSidesToModify","side","sides","isAlt","allowedSides","getAllowedSides","modifiedSides","push","filter","s","has","BoxInputControl","__next40pxDefaultSize","onChange","onFocus","values","selectedUnits","setSelectedUnits","props","_CUSTOM_VALUE_SETTING","_CUSTOM_VALUE_SETTING2","defaultValuesToModify","handleOnFocus","event","handleOnChange","nextValues","handleOnValueChange","next","extra","isNumeric","undefined","isNaN","parseFloat","nextValue","altKey","forEach","modifiedSide","handleOnUnitChange","newUnits","mergedValue","getMergedValue","hasValues","isValuesDefined","isMixed","length","isValueMixed","parsedQuantity","parsedUnit","parseQuantityAndUnitFromRawValue","computedUnit","generatedId","useInstanceId","inputId","join","isMixedUnit","some","usedValue","mixedPlaceholder","__","jsxs","InputWrapper","expanded","children","jsx","FlexedBoxControlIcon","default","placement","text","LABELS","StyledUnitControl","__shouldNotWarnDeprecated36pxSize","className","id","isPressEnterToChange","disableUnits","value","onUnitChange","label","placeholder","hideLabelFromVision","FlexedRangeControl","__nextHasNoMarginBottom","newValue","min","max","CUSTOM_VALUE_SETTINGS","step","withInputField"],"sources":["@wordpress/components/src/box-control/input-control.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useInstanceId } from '@wordpress/compose';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport Tooltip from '../tooltip';\nimport { parseQuantityAndUnitFromRawValue } from '../unit-control/utils';\nimport {\n\tCUSTOM_VALUE_SETTINGS,\n\tgetAllowedSides,\n\tgetMergedValue,\n\tisValueMixed,\n\tisValuesDefined,\n\tLABELS,\n} from './utils';\nimport {\n\tFlexedBoxControlIcon,\n\tFlexedRangeControl,\n\tInputWrapper,\n\tStyledUnitControl,\n} from './styles/box-control-styles';\nimport type { BoxControlInputControlProps, BoxControlValue } from './types';\n\nconst noop = () => {};\n\nfunction getSidesToModify(\n\tside: BoxControlInputControlProps[ 'side' ],\n\tsides: BoxControlInputControlProps[ 'sides' ],\n\tisAlt?: boolean\n) {\n\tconst allowedSides = getAllowedSides( sides );\n\n\tlet modifiedSides: ( keyof BoxControlValue )[] = [];\n\tswitch ( side ) {\n\t\tcase 'all':\n\t\t\tmodifiedSides = [ 'top', 'bottom', 'left', 'right' ];\n\t\t\tbreak;\n\t\tcase 'horizontal':\n\t\t\tmodifiedSides = [ 'left', 'right' ];\n\t\t\tbreak;\n\t\tcase 'vertical':\n\t\t\tmodifiedSides = [ 'top', 'bottom' ];\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tmodifiedSides = [ side ];\n\t}\n\n\tif ( isAlt ) {\n\t\tswitch ( side ) {\n\t\t\tcase 'top':\n\t\t\t\tmodifiedSides.push( 'bottom' );\n\t\t\t\tbreak;\n\t\t\tcase 'bottom':\n\t\t\t\tmodifiedSides.push( 'top' );\n\t\t\t\tbreak;\n\t\t\tcase 'left':\n\t\t\t\tmodifiedSides.push( 'left' );\n\t\t\t\tbreak;\n\t\t\tcase 'right':\n\t\t\t\tmodifiedSides.push( 'right' );\n\t\t\t\tbreak;\n\t\t}\n\t}\n\n\treturn modifiedSides.filter( ( s ) => allowedSides.has( s ) );\n}\n\nexport default function BoxInputControl( {\n\t__next40pxDefaultSize,\n\tonChange = noop,\n\tonFocus = noop,\n\tvalues,\n\tselectedUnits,\n\tsetSelectedUnits,\n\tsides,\n\tside,\n\t...props\n}: BoxControlInputControlProps ) {\n\tconst defaultValuesToModify = getSidesToModify( side, sides );\n\n\tconst handleOnFocus = ( event: React.FocusEvent< HTMLInputElement > ) => {\n\t\tonFocus( event, { side } );\n\t};\n\n\tconst handleOnChange = ( nextValues: BoxControlValue ) => {\n\t\tonChange( nextValues );\n\t};\n\n\tconst handleOnValueChange = (\n\t\tnext?: string,\n\t\textra?: { event: React.SyntheticEvent< Element, Event > }\n\t) => {\n\t\tconst nextValues = { ...values };\n\t\tconst isNumeric = next !== undefined && ! isNaN( parseFloat( next ) );\n\t\tconst nextValue = isNumeric ? next : undefined;\n\t\tconst modifiedSides = getSidesToModify(\n\t\t\tside,\n\t\t\tsides,\n\t\t\t/**\n\t\t\t * Supports changing pair sides. For example, holding the ALT key\n\t\t\t * when changing the TOP will also update BOTTOM.\n\t\t\t */\n\t\t\t// @ts-expect-error - TODO: event.altKey is only present when the change event was\n\t\t\t// triggered by a keyboard event. Should this feature be implemented differently so\n\t\t\t// it also works with drag events?\n\t\t\t!! extra?.event.altKey\n\t\t);\n\n\t\tmodifiedSides.forEach( ( modifiedSide ) => {\n\t\t\tnextValues[ modifiedSide ] = nextValue;\n\t\t} );\n\n\t\thandleOnChange( nextValues );\n\t};\n\n\tconst handleOnUnitChange = ( next?: string ) => {\n\t\tconst newUnits = { ...selectedUnits };\n\t\tdefaultValuesToModify.forEach( ( modifiedSide ) => {\n\t\t\tnewUnits[ modifiedSide ] = next;\n\t\t} );\n\t\tsetSelectedUnits( newUnits );\n\t};\n\n\tconst mergedValue = getMergedValue( values, defaultValuesToModify );\n\tconst hasValues = isValuesDefined( values );\n\tconst isMixed =\n\t\thasValues &&\n\t\tdefaultValuesToModify.length > 1 &&\n\t\tisValueMixed( values, defaultValuesToModify );\n\tconst [ parsedQuantity, parsedUnit ] =\n\t\tparseQuantityAndUnitFromRawValue( mergedValue );\n\tconst computedUnit = hasValues\n\t\t? parsedUnit\n\t\t: selectedUnits[ defaultValuesToModify[ 0 ] ];\n\tconst generatedId = useInstanceId( BoxInputControl, 'box-control-input' );\n\tconst inputId = [ generatedId, side ].join( '-' );\n\tconst isMixedUnit =\n\t\tdefaultValuesToModify.length > 1 &&\n\t\tmergedValue === undefined &&\n\t\tdefaultValuesToModify.some(\n\t\t\t( s ) => selectedUnits[ s ] !== computedUnit\n\t\t);\n\tconst usedValue =\n\t\tmergedValue === undefined && computedUnit ? computedUnit : mergedValue;\n\tconst mixedPlaceholder = isMixed || isMixedUnit ? __( 'Mixed' ) : undefined;\n\n\treturn (\n\t\t<InputWrapper key={ `box-control-${ side }` } expanded>\n\t\t\t<FlexedBoxControlIcon side={ side } sides={ sides } />\n\t\t\t<Tooltip placement=\"top-end\" text={ LABELS[ side ] }>\n\t\t\t\t<StyledUnitControl\n\t\t\t\t\t{ ...props }\n\t\t\t\t\t__shouldNotWarnDeprecated36pxSize\n\t\t\t\t\t__next40pxDefaultSize={ __next40pxDefaultSize }\n\t\t\t\t\tclassName=\"component-box-control__unit-control\"\n\t\t\t\t\tid={ inputId }\n\t\t\t\t\tisPressEnterToChange\n\t\t\t\t\tdisableUnits={ isMixed || isMixedUnit }\n\t\t\t\t\tvalue={ usedValue }\n\t\t\t\t\tonChange={ handleOnValueChange }\n\t\t\t\t\tonUnitChange={ handleOnUnitChange }\n\t\t\t\t\tonFocus={ handleOnFocus }\n\t\t\t\t\tlabel={ LABELS[ side ] }\n\t\t\t\t\tplaceholder={ mixedPlaceholder }\n\t\t\t\t\thideLabelFromVision\n\t\t\t\t/>\n\t\t\t</Tooltip>\n\n\t\t\t<FlexedRangeControl\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t__next40pxDefaultSize={ __next40pxDefaultSize }\n\t\t\t\t__shouldNotWarnDeprecated36pxSize\n\t\t\t\taria-controls={ inputId }\n\t\t\t\tlabel={ LABELS[ side ] }\n\t\t\t\thideLabelFromVision\n\t\t\t\tonChange={ ( newValue ) => {\n\t\t\t\t\thandleOnValueChange(\n\t\t\t\t\t\tnewValue !== undefined\n\t\t\t\t\t\t\t? [ newValue, computedUnit ].join( '' )\n\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t);\n\t\t\t\t} }\n\t\t\t\tmin={ 0 }\n\t\t\t\tmax={ CUSTOM_VALUE_SETTINGS[ computedUnit ?? 'px' ]?.max ?? 10 }\n\t\t\t\tstep={\n\t\t\t\t\tCUSTOM_VALUE_SETTINGS[ computedUnit ?? 'px' ]?.step ?? 0.1\n\t\t\t\t}\n\t\t\t\tvalue={ parsedQuantity ?? 0 }\n\t\t\t\twithInputField={ false }\n\t\t\t/>\n\t\t</InputWrapper>\n\t);\n}\n"],"mappings":";;;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AAKA,IAAAE,QAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AACA,IAAAK,OAAA,GAAAL,OAAA;AAQA,IAAAM,iBAAA,GAAAN,OAAA;AAKqC,IAAAO,WAAA,GAAAP,OAAA;AAxBrC;AACA;AACA;;AAIA;AACA;AACA;;AAmBA,MAAMQ,IAAI,GAAGA,CAAA,KAAM,CAAC,CAAC;AAErB,SAASC,gBAAgBA,CACxBC,IAA2C,EAC3CC,KAA6C,EAC7CC,KAAe,EACd;EACD,MAAMC,YAAY,GAAG,IAAAC,uBAAe,EAAEH,KAAM,CAAC;EAE7C,IAAII,aAA0C,GAAG,EAAE;EACnD,QAASL,IAAI;IACZ,KAAK,KAAK;MACTK,aAAa,GAAG,CAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAE;MACpD;IACD,KAAK,YAAY;MAChBA,aAAa,GAAG,CAAE,MAAM,EAAE,OAAO,CAAE;MACnC;IACD,KAAK,UAAU;MACdA,aAAa,GAAG,CAAE,KAAK,EAAE,QAAQ,CAAE;MACnC;IACD;MACCA,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EAAClE,iBAAA,CAAAmF,kBAAkB;MAClBC,uBAAuB;MACvBrE,qBAAqB,EAAGA,qBAAuB;MAC/C0D,iCAAiC;MACjC,iBAAgBlB,OAAS;MACzByB,KAAK,EAAGT,cAAM,CAAEnE,IAAI,CAAI;MACxB8E,mBAAmB;MACnBlE,QAAQ,EAAKqE,QAAQ,IAAM;QAC1BxD,mBAAmB,CAClBwD,QAAQ,KAAKpD,SAAS,GACnB,CAAEoD,QAAQ,EAAEjC,YAAY,CAAE,CAACI,IAAI,CAAE,EAAG,CAAC,GACrCvB,SACJ,CAAC;MACF,CAAG;MACHqD,GAAG,EAAG,CAAG;MACTC,GAAG,GAAAjE,qBAAA,GAAGkE,6BAAqB,CAAEpC,YAAY,aAAZA,YAAY,cAAZA,YAAY,GAAI,IAAI,CAAE,EAAEmC,GAAG,cAAAjE,qBAAA,cAAAA,qBAAA,GAAI,EAAI;MAChEmE,IAAI,GAAAlE,sBAAA,GACHiE,6BAAqB,CAAEpC,YAAY,aAAZA,YAAY,cAAZA,YAAY,GAAI,IAAI,CAAE,EAAEqC,IAAI,cAAAlE,sBAAA,cAAAA,sBAAA,GAAI,GACvD;MACDuD,KAAK,EAAG7B,cAAc,aAAdA,cAAc,cAAdA,cAAc,GAAI,CAAG;MAC7ByC,cAAc,EAAG;IAAO,CACxB,CAAC;EAAA,GA1CiB,eAAgBtF,IAAI,EA2C1B,CAAC;AAEjB","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_compose","require","_i18n","_element","_icons","_tooltip","_interopRequireDefault","_utils","_utils2","_boxControlStyles","_button","_jsxRuntime","noop","getSidesToModify","side","sides","isAlt","allowedSides","getAllowedSides","modifiedSides","push","filter","s","has","BoxInputControl","__next40pxDefaultSize","onChange","onFocus","values","selectedUnits","setSelectedUnits","min","presets","presetKey","props","_CUSTOM_VALUE_SETTING","_CUSTOM_VALUE_SETTING2","defaultValuesToModify","handleOnFocus","event","handleOnChange","nextValues","handleRawOnValueChange","next","forEach","modifiedSide","handleOnValueChange","extra","isNumeric","undefined","isNaN","parseFloat","nextValue","altKey","handleOnUnitChange","newUnits","mergedValue","getMergedValue","hasValues","isValuesDefined","isMixed","length","isValueMixed","parsedQuantity","parsedUnit","parseQuantityAndUnitFromRawValue","computedUnit","generatedId","useInstanceId","inputId","join","isMixedUnit","some","usedValue","mixedPlaceholder","__","hasPresets","hasPresetValue","isValuePreset","showCustomValueControl","setShowCustomValueControl","useState","presetIndex","getPresetIndexFromValue","marks","value","label","tooltip","concat","map","preset","index","_preset$name","name","slug","jsxs","InputWrapper","expanded","children","jsx","FlexedBoxControlIcon","Fragment","default","placement","text","LABELS","StyledUnitControl","__shouldNotWarnDeprecated36pxSize","className","id","isPressEnterToChange","disableUnits","onUnitChange","placeholder","hideLabelFromVision","FlexedRangeControl","__nextHasNoMarginBottom","newValue","isFinite","max","CUSTOM_VALUE_SETTINGS","step","withInputField","newIndex","getPresetValueFromIndex","renderTooltipContent","icon","settings","onClick","isPressed","size","iconSize"],"sources":["@wordpress/components/src/box-control/input-control.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useInstanceId } from '@wordpress/compose';\nimport { __ } from '@wordpress/i18n';\nimport { useState } from '@wordpress/element';\nimport { settings } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport Tooltip from '../tooltip';\nimport { parseQuantityAndUnitFromRawValue } from '../unit-control/utils';\nimport {\n\tCUSTOM_VALUE_SETTINGS,\n\tgetMergedValue,\n\tgetAllowedSides,\n\tgetPresetIndexFromValue,\n\tgetPresetValueFromIndex,\n\tisValuePreset,\n\tisValuesDefined,\n\tisValueMixed,\n\tLABELS,\n} from './utils';\nimport {\n\tFlexedBoxControlIcon,\n\tFlexedRangeControl,\n\tInputWrapper,\n\tStyledUnitControl,\n} from './styles/box-control-styles';\nimport type { BoxControlInputControlProps, BoxControlValue } from './types';\nimport Button from '../button';\n\nconst noop = () => {};\n\nfunction getSidesToModify(\n\tside: BoxControlInputControlProps[ 'side' ],\n\tsides: BoxControlInputControlProps[ 'sides' ],\n\tisAlt?: boolean\n) {\n\tconst allowedSides = getAllowedSides( sides );\n\n\tlet modifiedSides: ( keyof BoxControlValue )[] = [];\n\tswitch ( side ) {\n\t\tcase 'all':\n\t\t\tmodifiedSides = [ 'top', 'bottom', 'left', 'right' ];\n\t\t\tbreak;\n\t\tcase 'horizontal':\n\t\t\tmodifiedSides = [ 'left', 'right' ];\n\t\t\tbreak;\n\t\tcase 'vertical':\n\t\t\tmodifiedSides = [ 'top', 'bottom' ];\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tmodifiedSides = [ side ];\n\t}\n\n\tif ( isAlt ) {\n\t\tswitch ( side ) {\n\t\t\tcase 'top':\n\t\t\t\tmodifiedSides.push( 'bottom' );\n\t\t\t\tbreak;\n\t\t\tcase 'bottom':\n\t\t\t\tmodifiedSides.push( 'top' );\n\t\t\t\tbreak;\n\t\t\tcase 'left':\n\t\t\t\tmodifiedSides.push( 'left' );\n\t\t\t\tbreak;\n\t\t\tcase 'right':\n\t\t\t\tmodifiedSides.push( 'right' );\n\t\t\t\tbreak;\n\t\t}\n\t}\n\n\treturn modifiedSides.filter( ( s ) => allowedSides.has( s ) );\n}\n\nexport default function BoxInputControl( {\n\t__next40pxDefaultSize,\n\tonChange = noop,\n\tonFocus = noop,\n\tvalues,\n\tselectedUnits,\n\tsetSelectedUnits,\n\tsides,\n\tside,\n\tmin = 0,\n\tpresets,\n\tpresetKey,\n\t...props\n}: BoxControlInputControlProps ) {\n\tconst defaultValuesToModify = getSidesToModify( side, sides );\n\n\tconst handleOnFocus = ( event: React.FocusEvent< HTMLInputElement > ) => {\n\t\tonFocus( event, { side } );\n\t};\n\n\tconst handleOnChange = ( nextValues: BoxControlValue ) => {\n\t\tonChange( nextValues );\n\t};\n\n\tconst handleRawOnValueChange = ( next?: string ) => {\n\t\tconst nextValues = { ...values };\n\t\tdefaultValuesToModify.forEach( ( modifiedSide ) => {\n\t\t\tnextValues[ modifiedSide ] = next;\n\t\t} );\n\n\t\thandleOnChange( nextValues );\n\t};\n\n\tconst handleOnValueChange = (\n\t\tnext?: string,\n\t\textra?: { event: React.SyntheticEvent< Element, Event > }\n\t) => {\n\t\tconst nextValues = { ...values };\n\t\tconst isNumeric = next !== undefined && ! isNaN( parseFloat( next ) );\n\t\tconst nextValue = isNumeric ? next : undefined;\n\t\tconst modifiedSides = getSidesToModify(\n\t\t\tside,\n\t\t\tsides,\n\t\t\t/**\n\t\t\t * Supports changing pair sides. For example, holding the ALT key\n\t\t\t * when changing the TOP will also update BOTTOM.\n\t\t\t */\n\t\t\t// @ts-expect-error - TODO: event.altKey is only present when the change event was\n\t\t\t// triggered by a keyboard event. Should this feature be implemented differently so\n\t\t\t// it also works with drag events?\n\t\t\t!! extra?.event.altKey\n\t\t);\n\n\t\tmodifiedSides.forEach( ( modifiedSide ) => {\n\t\t\tnextValues[ modifiedSide ] = nextValue;\n\t\t} );\n\n\t\thandleOnChange( nextValues );\n\t};\n\n\tconst handleOnUnitChange = ( next?: string ) => {\n\t\tconst newUnits = { ...selectedUnits };\n\t\tdefaultValuesToModify.forEach( ( modifiedSide ) => {\n\t\t\tnewUnits[ modifiedSide ] = next;\n\t\t} );\n\t\tsetSelectedUnits( newUnits );\n\t};\n\n\tconst mergedValue = getMergedValue( values, defaultValuesToModify );\n\tconst hasValues = isValuesDefined( values );\n\tconst isMixed =\n\t\thasValues &&\n\t\tdefaultValuesToModify.length > 1 &&\n\t\tisValueMixed( values, defaultValuesToModify );\n\tconst [ parsedQuantity, parsedUnit ] =\n\t\tparseQuantityAndUnitFromRawValue( mergedValue );\n\tconst computedUnit = hasValues\n\t\t? parsedUnit\n\t\t: selectedUnits[ defaultValuesToModify[ 0 ] ];\n\tconst generatedId = useInstanceId( BoxInputControl, 'box-control-input' );\n\tconst inputId = [ generatedId, side ].join( '-' );\n\tconst isMixedUnit =\n\t\tdefaultValuesToModify.length > 1 &&\n\t\tmergedValue === undefined &&\n\t\tdefaultValuesToModify.some(\n\t\t\t( s ) => selectedUnits[ s ] !== computedUnit\n\t\t);\n\tconst usedValue =\n\t\tmergedValue === undefined && computedUnit ? computedUnit : mergedValue;\n\tconst mixedPlaceholder = isMixed || isMixedUnit ? __( 'Mixed' ) : undefined;\n\tconst hasPresets = presets && presets.length > 0 && presetKey;\n\tconst hasPresetValue =\n\t\thasPresets &&\n\t\tmergedValue !== undefined &&\n\t\t! isMixed &&\n\t\tisValuePreset( mergedValue, presetKey );\n\tconst [ showCustomValueControl, setShowCustomValueControl ] = useState(\n\t\t! hasPresets ||\n\t\t\t( ! hasPresetValue && ! isMixed && mergedValue !== undefined )\n\t);\n\tconst presetIndex = hasPresetValue\n\t\t? getPresetIndexFromValue( mergedValue, presetKey, presets )\n\t\t: undefined;\n\tconst marks = hasPresets\n\t\t? [ { value: 0, label: '', tooltip: __( 'None' ) } ].concat(\n\t\t\t\tpresets.map( ( preset, index ) => ( {\n\t\t\t\t\tvalue: index + 1,\n\t\t\t\t\tlabel: '',\n\t\t\t\t\ttooltip: preset.name ?? preset.slug,\n\t\t\t\t} ) )\n\t\t )\n\t\t: [];\n\n\treturn (\n\t\t<InputWrapper key={ `box-control-${ side }` } expanded>\n\t\t\t<FlexedBoxControlIcon side={ side } sides={ sides } />\n\t\t\t{ showCustomValueControl && (\n\t\t\t\t<>\n\t\t\t\t\t<Tooltip placement=\"top-end\" text={ LABELS[ side ] }>\n\t\t\t\t\t\t<StyledUnitControl\n\t\t\t\t\t\t\t{ ...props }\n\t\t\t\t\t\t\tmin={ min }\n\t\t\t\t\t\t\t__shouldNotWarnDeprecated36pxSize\n\t\t\t\t\t\t\t__next40pxDefaultSize={ __next40pxDefaultSize }\n\t\t\t\t\t\t\tclassName=\"component-box-control__unit-control\"\n\t\t\t\t\t\t\tid={ inputId }\n\t\t\t\t\t\t\tisPressEnterToChange\n\t\t\t\t\t\t\tdisableUnits={ isMixed || isMixedUnit }\n\t\t\t\t\t\t\tvalue={ usedValue }\n\t\t\t\t\t\t\tonChange={ handleOnValueChange }\n\t\t\t\t\t\t\tonUnitChange={ handleOnUnitChange }\n\t\t\t\t\t\t\tonFocus={ handleOnFocus }\n\t\t\t\t\t\t\tlabel={ LABELS[ side ] }\n\t\t\t\t\t\t\tplaceholder={ mixedPlaceholder }\n\t\t\t\t\t\t\thideLabelFromVision\n\t\t\t\t\t\t/>\n\t\t\t\t\t</Tooltip>\n\n\t\t\t\t\t<FlexedRangeControl\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t__next40pxDefaultSize={ __next40pxDefaultSize }\n\t\t\t\t\t\t__shouldNotWarnDeprecated36pxSize\n\t\t\t\t\t\taria-controls={ inputId }\n\t\t\t\t\t\tlabel={ LABELS[ side ] }\n\t\t\t\t\t\thideLabelFromVision\n\t\t\t\t\t\tonChange={ ( newValue ) => {\n\t\t\t\t\t\t\thandleOnValueChange(\n\t\t\t\t\t\t\t\tnewValue !== undefined\n\t\t\t\t\t\t\t\t\t? [ newValue, computedUnit ].join( '' )\n\t\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tmin={ isFinite( min ) ? min : 0 }\n\t\t\t\t\t\tmax={\n\t\t\t\t\t\t\tCUSTOM_VALUE_SETTINGS[ computedUnit ?? 'px' ]\n\t\t\t\t\t\t\t\t?.max ?? 10\n\t\t\t\t\t\t}\n\t\t\t\t\t\tstep={\n\t\t\t\t\t\t\tCUSTOM_VALUE_SETTINGS[ computedUnit ?? 'px' ]\n\t\t\t\t\t\t\t\t?.step ?? 0.1\n\t\t\t\t\t\t}\n\t\t\t\t\t\tvalue={ parsedQuantity ?? 0 }\n\t\t\t\t\t\twithInputField={ false }\n\t\t\t\t\t/>\n\t\t\t\t</>\n\t\t\t) }\n\n\t\t\t{ hasPresets && ! showCustomValueControl && (\n\t\t\t\t<FlexedRangeControl\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\tclassName=\"spacing-sizes-control__range-control\"\n\t\t\t\t\tvalue={ presetIndex !== undefined ? presetIndex + 1 : 0 }\n\t\t\t\t\tonChange={ ( newIndex ) => {\n\t\t\t\t\t\tconst newValue =\n\t\t\t\t\t\t\tnewIndex === 0 || newIndex === undefined\n\t\t\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t\t\t: getPresetValueFromIndex(\n\t\t\t\t\t\t\t\t\t\tnewIndex - 1,\n\t\t\t\t\t\t\t\t\t\tpresetKey,\n\t\t\t\t\t\t\t\t\t\tpresets\n\t\t\t\t\t\t\t\t );\n\t\t\t\t\t\thandleRawOnValueChange( newValue );\n\t\t\t\t\t} }\n\t\t\t\t\twithInputField={ false }\n\t\t\t\t\taria-valuenow={\n\t\t\t\t\t\tpresetIndex !== undefined ? presetIndex + 1 : 0\n\t\t\t\t\t}\n\t\t\t\t\taria-valuetext={\n\t\t\t\t\t\tmarks[ presetIndex !== undefined ? presetIndex + 1 : 0 ]\n\t\t\t\t\t\t\t.tooltip\n\t\t\t\t\t}\n\t\t\t\t\trenderTooltipContent={ ( index ) =>\n\t\t\t\t\t\tmarks[ ! index ? 0 : index ].tooltip\n\t\t\t\t\t}\n\t\t\t\t\tmin={ 0 }\n\t\t\t\t\tmax={ marks.length - 1 }\n\t\t\t\t\tmarks={ marks }\n\t\t\t\t\tlabel={ LABELS[ side ] }\n\t\t\t\t\thideLabelFromVision\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t/>\n\t\t\t) }\n\n\t\t\t{ hasPresets && (\n\t\t\t\t<Button\n\t\t\t\t\tlabel={\n\t\t\t\t\t\tshowCustomValueControl\n\t\t\t\t\t\t\t? __( 'Use size preset' )\n\t\t\t\t\t\t\t: __( 'Set custom size' )\n\t\t\t\t\t}\n\t\t\t\t\ticon={ settings }\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\tsetShowCustomValueControl( ! showCustomValueControl );\n\t\t\t\t\t} }\n\t\t\t\t\tisPressed={ showCustomValueControl }\n\t\t\t\t\tsize=\"small\"\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,sBAAsB,CAAE2E,QAAS,CAAC;MACnC,CAAG;MACHK,cAAc,EAAG,KAAO;MACxB,iBACCxC,WAAW,KAAKjC,SAAS,GAAGiC,WAAW,GAAG,CAAC,GAAG,CAC9C;MACD,kBACCE,KAAK,CAAEF,WAAW,KAAKjC,SAAS,GAAGiC,WAAW,GAAG,CAAC,GAAG,CAAC,CAAE,CACtDK,OACF;MACDsC,oBAAoB,EAAKlC,KAAK,IAC7BP,KAAK,CAAE,CAAEO,KAAK,GAAG,CAAC,GAAGA,KAAK,CAAE,CAACJ,OAC7B;MACDxD,GAAG,EAAG,CAAG;MACTwF,GAAG,EAAGnC,KAAK,CAACvB,MAAM,GAAG,CAAG;MACxBuB,KAAK,EAAGA,KAAO;MACfE,KAAK,EAAGmB,cAAM,CAAE3F,IAAI,CAAI;MACxBoG,mBAAmB;MACnBE,uBAAuB;IAAA,CACvB,CACD,EAECxC,UAAU,iBACX,IAAAjE,WAAA,CAAAwF,GAAA,EAACzF,OAAA,CAAA4F,OAAM;MACNhB,KAAK,EACJP,sBAAsB,GACnB,IAAAJ,QAAE,EAAE,iBAAkB,CAAC,GACvB,IAAAA,QAAE,EAAE,iBAAkB,CACzB;MACDmD,IAAI,EAAGC,eAAU;MACjBC,OAAO,EAAGA,CAAA,KAAM;QACfhD,yBAAyB,CAAE,CAAED,sBAAuB,CAAC;MACtD,CAAG;MACHkD,SAAS,EAAGlD,sBAAwB;MACpCmD,IAAI,EAAC,OAAO;MACZC,QAAQ,EAAG;IAAI,CACf,CACD;EAAA,GAxGkB,eAAgBrH,IAAI,EAyG1B,CAAC;AAEjB","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["@wordpress/components/src/box-control/types.ts"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport type { UnitControlProps } from '../unit-control/types';\nimport type { LABELS } from './utils';\n\nexport type BoxControlValue = {\n\ttop?: string;\n\tright?: string;\n\tbottom?: string;\n\tleft?: string;\n};\n\nexport type CustomValueUnits = {\n\t[ key: string ]: { max: number; step: number };\n};\n\ntype UnitControlPassthroughProps = Omit<\n\tUnitControlProps,\n\t'label' | 'onChange' | 'onFocus' | 'units'\n>;\n\ntype DeprecatedBoxControlProps = {\n\t/**\n\t * @deprecated Pass to the `inputProps` prop instead.\n\t * @ignore\n\t */\n\tonMouseOver?: UnitControlProps[ 'onMouseOver' ];\n\t/**\n\t * @deprecated Pass to the `inputProps` prop instead.\n\t * @ignore\n\t */\n\tonMouseOut?: UnitControlProps[ 'onMouseOut' ];\n};\n\nexport type BoxControlProps = Pick< UnitControlProps, 'units' > &\n\tDeprecatedBoxControlProps & {\n\t\t/**\n\t\t * If this property is true, a button to reset the box control is rendered.\n\t\t *\n\t\t * @default true\n\t\t */\n\t\tallowReset?: boolean;\n\t\t/**\n\t\t * The id to use as a base for the unique HTML id attribute of the control.\n\t\t */\n\t\tid?: string;\n\t\t/**\n\t\t * Props for the internal `UnitControl` components.\n\t\t *\n\t\t * @default { min: 0 }\n\t\t */\n\t\tinputProps?: UnitControlPassthroughProps;\n\t\t/**\n\t\t * Heading label for the control.\n\t\t *\n\t\t * @default __( 'Box Control' )\n\t\t */\n\t\tlabel?: string;\n\t\t/**\n\t\t * A callback function when an input value changes.\n\t\t */\n\t\tonChange: ( next: BoxControlValue ) => void;\n\t\t/**\n\t\t * The `top`, `right`, `bottom`, and `left` box dimension values to use when the control is reset.\n\t\t *\n\t\t * @default { top: undefined, right: undefined, bottom: undefined, left: undefined }\n\t\t */\n\t\tresetValues?: BoxControlValue;\n\t\t/**\n\t\t * Collection of sides to allow control of. If omitted or empty, all sides will be available.\n\t\t *\n\t\t * Allowed values are \"top\", \"right\", \"bottom\", \"left\", \"vertical\", and \"horizontal\".\n\t\t */\n\t\tsides?: readonly (\n\t\t\t| keyof BoxControlValue\n\t\t\t| 'horizontal'\n\t\t\t| 'vertical'\n\t\t)[];\n\t\t/**\n\t\t * If this property is true, when the box control is unlinked, vertical and horizontal controls\n\t\t * can be used instead of updating individual sides.\n\t\t *\n\t\t * @default false\n\t\t */\n\t\tsplitOnAxis?: boolean;\n\t\t/**\n\t\t * The current values of the control, expressed as an object of `top`, `right`, `bottom`, and `left` values.\n\t\t */\n\t\tvalues?: BoxControlValue;\n\t\t/**\n\t\t * Start opting into the larger default height that will become the default size in a future version.\n\t\t *\n\t\t * @default false\n\t\t */\n\t\t__next40pxDefaultSize?: boolean;\n\t};\n\nexport type BoxControlInputControlProps = UnitControlPassthroughProps & {\n\tonChange?: ( nextValues: BoxControlValue ) => void;\n\tonFocus?: (\n\t\t_event: React.FocusEvent< HTMLInputElement >,\n\t\t{ side }: { side: keyof typeof LABELS }\n\t) => void;\n\tonHoverOff?: (\n\t\tsides: Partial< Record< keyof BoxControlValue, boolean > >\n\t) => void;\n\tonHoverOn?: (\n\t\tsides: Partial< Record< keyof BoxControlValue, boolean > >\n\t) => void;\n\tselectedUnits: BoxControlValue;\n\tsetSelectedUnits: React.Dispatch< React.SetStateAction< BoxControlValue > >;\n\tvalues: BoxControlValue;\n\t/**\n\t * Collection of sides to allow control of. If omitted or empty, all sides will be available.\n\t */\n\tsides: BoxControlProps[ 'sides' ];\n\t/**\n\t * Side represents the current side being rendered by the input.\n\t * It can be a concrete side like: left, right, top, bottom or a combined one like: horizontal, vertical.\n\t */\n\tside: keyof typeof LABELS;\n};\n\nexport type BoxControlIconProps = {\n\t/**\n\t * @default 24\n\t */\n\tsize?: number;\n\t/**\n\t * @default 'all'\n\t */\n\tside?: keyof typeof LABELS;\n\tsides?: BoxControlProps[ 'sides' ];\n};\n"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":[],"sources":["@wordpress/components/src/box-control/types.ts"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport type { UnitControlProps } from '../unit-control/types';\nimport type { LABELS } from './utils';\n\nexport type BoxControlValue = {\n\ttop?: string;\n\tright?: string;\n\tbottom?: string;\n\tleft?: string;\n};\n\nexport type CustomValueUnits = {\n\t[ key: string ]: { max: number; step: number };\n};\n\nexport interface Preset {\n\tname: string;\n\tslug: string;\n\tvalue?: string;\n}\n\ntype UnitControlPassthroughProps = Omit<\n\tUnitControlProps,\n\t'label' | 'onChange' | 'onFocus' | 'units'\n>;\n\ntype DeprecatedBoxControlProps = {\n\t/**\n\t * @deprecated Pass to the `inputProps` prop instead.\n\t * @ignore\n\t */\n\tonMouseOver?: UnitControlProps[ 'onMouseOver' ];\n\t/**\n\t * @deprecated Pass to the `inputProps` prop instead.\n\t * @ignore\n\t */\n\tonMouseOut?: UnitControlProps[ 'onMouseOut' ];\n};\n\nexport type BoxControlProps = Pick< UnitControlProps, 'units' > &\n\tDeprecatedBoxControlProps & {\n\t\t/**\n\t\t * If this property is true, a button to reset the box control is rendered.\n\t\t *\n\t\t * @default true\n\t\t */\n\t\tallowReset?: boolean;\n\t\t/**\n\t\t * The id to use as a base for the unique HTML id attribute of the control.\n\t\t */\n\t\tid?: string;\n\t\t/**\n\t\t * Props for the internal `UnitControl` components.\n\t\t *\n\t\t * @default { min: 0 }\n\t\t */\n\t\tinputProps?: UnitControlPassthroughProps;\n\t\t/**\n\t\t * Heading label for the control.\n\t\t *\n\t\t * @default __( 'Box Control' )\n\t\t */\n\t\tlabel?: string;\n\t\t/**\n\t\t * A callback function when an input value changes.\n\t\t */\n\t\tonChange: ( next: BoxControlValue ) => void;\n\t\t/**\n\t\t * The `top`, `right`, `bottom`, and `left` box dimension values to use when the control is reset.\n\t\t *\n\t\t * @default { top: undefined, right: undefined, bottom: undefined, left: undefined }\n\t\t */\n\t\tresetValues?: BoxControlValue;\n\t\t/**\n\t\t * Collection of sides to allow control of. If omitted or empty, all sides will be available.\n\t\t *\n\t\t * Allowed values are \"top\", \"right\", \"bottom\", \"left\", \"vertical\", and \"horizontal\".\n\t\t */\n\t\tsides?: readonly (\n\t\t\t| keyof BoxControlValue\n\t\t\t| 'horizontal'\n\t\t\t| 'vertical'\n\t\t)[];\n\t\t/**\n\t\t * If this property is true, when the box control is unlinked, vertical and horizontal controls\n\t\t * can be used instead of updating individual sides.\n\t\t *\n\t\t * @default false\n\t\t */\n\t\tsplitOnAxis?: boolean;\n\t\t/**\n\t\t * The current values of the control, expressed as an object of `top`, `right`, `bottom`, and `left` values.\n\t\t */\n\t\tvalues?: BoxControlValue;\n\t\t/**\n\t\t * Start opting into the larger default height that will become the default size in a future version.\n\t\t *\n\t\t * @default false\n\t\t */\n\t\t__next40pxDefaultSize?: boolean;\n\t\t/**\n\t\t * Available presets to pick from.\n\t\t */\n\t\tpresets?: Preset[];\n\t\t/**\n\t\t * The key of the preset to apply.\n\t\t * If you provide a list of presets, you must provide a preset key to use.\n\t\t * The format of preset selected values is going to be `var:preset|${ presetKey }|${ presetSlug }`\n\t\t */\n\t\tpresetKey?: string;\n\t};\n\nexport type BoxControlInputControlProps = UnitControlPassthroughProps & {\n\tonChange?: ( nextValues: BoxControlValue ) => void;\n\tonFocus?: (\n\t\t_event: React.FocusEvent< HTMLInputElement >,\n\t\t{ side }: { side: keyof typeof LABELS }\n\t) => void;\n\tonHoverOff?: (\n\t\tsides: Partial< Record< keyof BoxControlValue, boolean > >\n\t) => void;\n\tonHoverOn?: (\n\t\tsides: Partial< Record< keyof BoxControlValue, boolean > >\n\t) => void;\n\tselectedUnits: BoxControlValue;\n\tsetSelectedUnits: React.Dispatch< React.SetStateAction< BoxControlValue > >;\n\tvalues: BoxControlValue;\n\t/**\n\t * Collection of sides to allow control of. If omitted or empty, all sides will be available.\n\t */\n\tsides: BoxControlProps[ 'sides' ];\n\t/**\n\t * Side represents the current side being rendered by the input.\n\t * It can be a concrete side like: left, right, top, bottom or a combined one like: horizontal, vertical.\n\t */\n\tside: keyof typeof LABELS;\n\tpresets?: Preset[];\n\tpresetKey?: string;\n};\n\nexport type BoxControlIconProps = {\n\t/**\n\t * @default 24\n\t */\n\tsize?: number;\n\t/**\n\t * @default 'all'\n\t */\n\tside?: keyof typeof LABELS;\n\tsides?: BoxControlProps[ 'sides' ];\n};\n"],"mappings":"","ignoreList":[]}
|
|
@@ -11,7 +11,10 @@ exports.getAllUnitFallback = getAllUnitFallback;
|
|
|
11
11
|
exports.getAllowedSides = getAllowedSides;
|
|
12
12
|
exports.getInitialSide = getInitialSide;
|
|
13
13
|
exports.getMergedValue = getMergedValue;
|
|
14
|
+
exports.getPresetIndexFromValue = getPresetIndexFromValue;
|
|
15
|
+
exports.getPresetValueFromIndex = getPresetValueFromIndex;
|
|
14
16
|
exports.isValueMixed = isValueMixed;
|
|
17
|
+
exports.isValuePreset = isValuePreset;
|
|
15
18
|
exports.isValuesDefined = isValuesDefined;
|
|
16
19
|
exports.normalizeSides = normalizeSides;
|
|
17
20
|
var _i18n = require("@wordpress/i18n");
|
|
@@ -323,4 +326,51 @@ function getAllowedSides(sides) {
|
|
|
323
326
|
});
|
|
324
327
|
return allowedSides;
|
|
325
328
|
}
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* Checks if a value is a preset value.
|
|
332
|
+
*
|
|
333
|
+
* @param value The value to check.
|
|
334
|
+
* @param presetKey The preset key to check against.
|
|
335
|
+
* @return Whether the value is a preset value.
|
|
336
|
+
*/
|
|
337
|
+
function isValuePreset(value, presetKey) {
|
|
338
|
+
return value.startsWith(`var:preset|${presetKey}|`);
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
/**
|
|
342
|
+
* Returns the index of the preset value in the presets array.
|
|
343
|
+
*
|
|
344
|
+
* @param value The value to check.
|
|
345
|
+
* @param presetKey The preset key to check against.
|
|
346
|
+
* @param presets The array of presets to search.
|
|
347
|
+
* @return The index of the preset value in the presets array.
|
|
348
|
+
*/
|
|
349
|
+
function getPresetIndexFromValue(value, presetKey, presets) {
|
|
350
|
+
if (!isValuePreset(value, presetKey)) {
|
|
351
|
+
return undefined;
|
|
352
|
+
}
|
|
353
|
+
const match = value.match(new RegExp(`^var:preset\\|${presetKey}\\|(.+)$`));
|
|
354
|
+
if (!match) {
|
|
355
|
+
return undefined;
|
|
356
|
+
}
|
|
357
|
+
const slug = match[1];
|
|
358
|
+
const index = presets.findIndex(preset => {
|
|
359
|
+
return preset.slug === slug;
|
|
360
|
+
});
|
|
361
|
+
return index !== -1 ? index : undefined;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
/**
|
|
365
|
+
* Returns the preset value from the index.
|
|
366
|
+
*
|
|
367
|
+
* @param index The index of the preset value in the presets array.
|
|
368
|
+
* @param presetKey The preset key to check against.
|
|
369
|
+
* @param presets The array of presets to search.
|
|
370
|
+
* @return The preset value from the index.
|
|
371
|
+
*/
|
|
372
|
+
function getPresetValueFromIndex(index, presetKey, presets) {
|
|
373
|
+
const preset = presets[index];
|
|
374
|
+
return `var:preset|${presetKey}|${preset.slug}`;
|
|
375
|
+
}
|
|
326
376
|
//# sourceMappingURL=utils.js.map
|