@wordpress/components 19.5.0 → 19.6.1-next.a55ed9455a.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 +21 -5
- package/build/alignment-matrix-control/utils.js +1 -1
- package/build/alignment-matrix-control/utils.js.map +1 -1
- package/build/angle-picker-control/angle-circle.js +1 -1
- package/build/angle-picker-control/angle-circle.js.map +1 -1
- package/build/animation/index.js +0 -6
- package/build/animation/index.js.map +1 -1
- package/build/autocomplete/get-default-use-items.js +3 -3
- package/build/autocomplete/get-default-use-items.js.map +1 -1
- package/build/base-field/hook.js +1 -1
- package/build/base-field/hook.js.map +1 -1
- package/build/box-control/icon.js +1 -1
- package/build/box-control/icon.js.map +1 -1
- package/build/box-control/index.js +4 -4
- package/build/box-control/index.js.map +1 -1
- package/build/box-control/utils.js +12 -8
- package/build/box-control/utils.js.map +1 -1
- package/build/button/index.js +5 -5
- package/build/button/index.js.map +1 -1
- package/build/button/index.native.js +7 -7
- package/build/button/index.native.js.map +1 -1
- package/build/color-picker/color-display.js +1 -1
- package/build/color-picker/color-display.js.map +1 -1
- package/build/color-picker/styles.js +8 -8
- package/build/color-picker/styles.js.map +1 -1
- package/build/combobox-control/index.js +1 -1
- package/build/combobox-control/index.js.map +1 -1
- package/build/confirm-dialog/component.js +4 -2
- package/build/confirm-dialog/component.js.map +1 -1
- package/build/date-time/time.js +7 -4
- package/build/date-time/time.js.map +1 -1
- package/build/divider/component.js +5 -4
- package/build/divider/component.js.map +1 -1
- package/build/draggable/index.js +3 -3
- package/build/draggable/index.js.map +1 -1
- package/build/focal-point-picker/index.native.js +7 -7
- package/build/focal-point-picker/index.native.js.map +1 -1
- package/build/focal-point-picker/tooltip/index.native.js +1 -1
- package/build/focal-point-picker/tooltip/index.native.js.map +1 -1
- package/build/font-size-picker/index.js +1 -1
- package/build/font-size-picker/index.js.map +1 -1
- package/build/form-token-field/index.js +6 -6
- package/build/form-token-field/index.js.map +1 -1
- package/build/form-token-field/suggestions-list.js +2 -2
- package/build/form-token-field/suggestions-list.js.map +1 -1
- package/build/heading/component.js +6 -5
- package/build/heading/component.js.map +1 -1
- package/build/heading/hook.js +1 -1
- package/build/heading/hook.js.map +1 -1
- package/build/higher-order/with-notices/index.js +1 -1
- package/build/higher-order/with-notices/index.js.map +1 -1
- package/build/index.js +2 -2
- package/build/index.js.map +1 -1
- package/build/index.native.js.map +1 -1
- package/build/input-control/input-base.js +1 -1
- package/build/input-control/input-base.js.map +1 -1
- package/build/input-control/input-field.js +12 -10
- package/build/input-control/input-field.js.map +1 -1
- package/build/input-control/styles/input-control-styles.js +25 -25
- package/build/input-control/styles/input-control-styles.js.map +1 -1
- package/build/isolated-event-container/index.js +1 -1
- package/build/isolated-event-container/index.js.map +1 -1
- package/build/mobile/bottom-sheet/bottom-sheet-context.native.js +4 -4
- package/build/mobile/bottom-sheet/bottom-sheet-context.native.js.map +1 -1
- package/build/mobile/bottom-sheet/bottom-sheet-navigation/navigation-container.native.js +1 -1
- package/build/mobile/bottom-sheet/bottom-sheet-navigation/navigation-container.native.js.map +1 -1
- package/build/mobile/bottom-sheet/cell.native.js +1 -1
- package/build/mobile/bottom-sheet/cell.native.js.map +1 -1
- package/build/mobile/bottom-sheet/index.native.js +11 -11
- package/build/mobile/bottom-sheet/index.native.js.map +1 -1
- package/build/mobile/bottom-sheet/link-cell.native.js +1 -1
- package/build/mobile/bottom-sheet/link-cell.native.js.map +1 -1
- package/build/mobile/bottom-sheet/link-suggestion-item-cell.native.js +1 -1
- package/build/mobile/bottom-sheet/link-suggestion-item-cell.native.js.map +1 -1
- package/build/mobile/bottom-sheet/nav-bar/back-button.native.js +1 -1
- package/build/mobile/bottom-sheet/nav-bar/back-button.native.js.map +1 -1
- package/build/mobile/global-styles-context/utils.native.js +10 -10
- package/build/mobile/global-styles-context/utils.native.js.map +1 -1
- package/build/mobile/gradient/index.native.js +2 -2
- package/build/mobile/gradient/index.native.js.map +1 -1
- package/build/mobile/html-text-input/container.ios.js +3 -3
- package/build/mobile/html-text-input/container.ios.js.map +1 -1
- package/build/mobile/html-text-input/index.native.js +1 -1
- package/build/mobile/html-text-input/index.native.js.map +1 -1
- package/build/mobile/image/index.native.js +1 -1
- package/build/mobile/image/index.native.js.map +1 -1
- package/build/mobile/keyboard-aware-flat-list/index.android.js +1 -1
- package/build/mobile/keyboard-aware-flat-list/index.android.js.map +1 -1
- package/build/mobile/keyboard-aware-flat-list/index.ios.js +2 -2
- package/build/mobile/keyboard-aware-flat-list/index.ios.js.map +1 -1
- package/build/mobile/link-picker/index.native.js +3 -3
- package/build/mobile/link-picker/index.native.js.map +1 -1
- package/build/mobile/link-picker/link-picker-results.native.js +8 -8
- package/build/mobile/link-picker/link-picker-results.native.js.map +1 -1
- package/build/mobile/link-settings/image-link-destinations-screen.native.js +2 -2
- package/build/mobile/link-settings/image-link-destinations-screen.native.js.map +1 -1
- package/build/mobile/link-settings/index.native.js +1 -1
- package/build/mobile/link-settings/index.native.js.map +1 -1
- package/build/modal/aria-helper.js +1 -1
- package/build/modal/aria-helper.js.map +1 -1
- package/build/modal/index.js +2 -2
- package/build/modal/index.js.map +1 -1
- package/build/navigable-container/container.js +2 -2
- package/build/navigable-container/container.js.map +1 -1
- package/build/navigable-container/tabbable.js +1 -1
- package/build/navigable-container/tabbable.js.map +1 -1
- package/build/navigation/item/index.js +1 -1
- package/build/navigation/item/index.js.map +1 -1
- package/build/navigation/menu/index.js +1 -1
- package/build/navigation/menu/index.js.map +1 -1
- package/build/navigator/navigator-provider/component.js +2 -2
- package/build/navigator/navigator-provider/component.js.map +1 -1
- package/build/navigator/navigator-screen/component.js +1 -1
- package/build/navigator/navigator-screen/component.js.map +1 -1
- package/build/number-control/index.js +1 -1
- package/build/number-control/index.js.map +1 -1
- package/build/panel/body.js +2 -2
- package/build/panel/body.js.map +1 -1
- package/build/popover/index.js +3 -3
- package/build/popover/index.js.map +1 -1
- package/build/popover/utils.js +6 -6
- package/build/popover/utils.js.map +1 -1
- package/build/radio-group/index.js +1 -1
- package/build/radio-group/index.js.map +1 -1
- package/build/range-control/styles/range-control-styles.js +29 -29
- package/build/range-control/styles/range-control-styles.js.map +1 -1
- package/build/sandbox/index.js +5 -5
- package/build/sandbox/index.js.map +1 -1
- package/build/sandbox/index.native.js +1 -1
- package/build/sandbox/index.native.js.map +1 -1
- package/build/select-control/index.js +1 -1
- package/build/select-control/index.js.map +1 -1
- package/build/select-control/styles/select-control-styles.js +5 -5
- package/build/select-control/styles/select-control-styles.js.map +1 -1
- package/build/slot-fill/bubbles-virtually/slot-fill-provider.js +1 -1
- package/build/slot-fill/bubbles-virtually/slot-fill-provider.js.map +1 -1
- package/build/slot-fill/bubbles-virtually/slot.js +1 -1
- package/build/slot-fill/bubbles-virtually/slot.js.map +1 -1
- package/build/slot-fill/fill.js +1 -1
- package/build/slot-fill/fill.js.map +1 -1
- package/build/slot-fill/provider.js +1 -1
- package/build/slot-fill/provider.js.map +1 -1
- package/build/snackbar/index.js +1 -1
- package/build/snackbar/index.js.map +1 -1
- package/build/snackbar/list.js +1 -1
- package/build/snackbar/list.js.map +1 -1
- package/build/style-provider/index.js +2 -2
- package/build/style-provider/index.js.map +1 -1
- package/build/toggle-group-control/toggle-group-control/component.js +2 -2
- package/build/toggle-group-control/toggle-group-control/component.js.map +1 -1
- package/build/toggle-group-control/toggle-group-control-option/styles.js +8 -8
- package/build/toggle-group-control/toggle-group-control-option/styles.js.map +1 -1
- package/build/toolbar/index.js +1 -1
- package/build/toolbar/index.js.map +1 -1
- package/build/tooltip/index.js +3 -3
- package/build/tooltip/index.js.map +1 -1
- package/build/tooltip/index.native.js +7 -7
- package/build/tooltip/index.native.js.map +1 -1
- package/build/truncate/utils.js +1 -1
- package/build/truncate/utils.js.map +1 -1
- package/build/ui/context/context-connect.js +8 -15
- package/build/ui/context/context-connect.js.map +1 -1
- package/build/ui/context/context-system-provider.js +2 -2
- package/build/ui/context/context-system-provider.js.map +1 -1
- package/build/ui/context/index.js.map +1 -1
- package/build/ui/utils/colors.js +2 -2
- package/build/ui/utils/colors.js.map +1 -1
- package/build/ui/utils/space.js +2 -2
- package/build/ui/utils/space.js.map +1 -1
- package/build/unit-control/index.js +38 -29
- package/build/unit-control/index.js.map +1 -1
- package/build/unit-control/index.native.js +4 -2
- package/build/unit-control/index.native.js.map +1 -1
- package/build/unit-control/unit-select-control.js +1 -1
- package/build/unit-control/unit-select-control.js.map +1 -1
- package/build/unit-control/utils.js +96 -104
- package/build/unit-control/utils.js.map +1 -1
- package/build/utils/breakpoint-values.js +1 -1
- package/build/utils/breakpoint-values.js.map +1 -1
- package/build/utils/colors-values.js +1 -1
- package/build/utils/colors-values.js.map +1 -1
- package/build-module/alignment-matrix-control/utils.js +1 -1
- package/build-module/alignment-matrix-control/utils.js.map +1 -1
- package/build-module/angle-picker-control/angle-circle.js +1 -1
- package/build-module/angle-picker-control/angle-circle.js.map +1 -1
- package/build-module/animation/index.js +1 -1
- package/build-module/animation/index.js.map +1 -1
- package/build-module/autocomplete/get-default-use-items.js +3 -3
- package/build-module/autocomplete/get-default-use-items.js.map +1 -1
- package/build-module/base-field/hook.js +1 -1
- package/build-module/base-field/hook.js.map +1 -1
- package/build-module/box-control/icon.js +1 -1
- package/build-module/box-control/icon.js.map +1 -1
- package/build-module/box-control/index.js +5 -5
- package/build-module/box-control/index.js.map +1 -1
- package/build-module/box-control/utils.js +13 -9
- package/build-module/box-control/utils.js.map +1 -1
- package/build-module/button/index.js +5 -5
- package/build-module/button/index.js.map +1 -1
- package/build-module/button/index.native.js +7 -7
- package/build-module/button/index.native.js.map +1 -1
- package/build-module/color-picker/color-display.js +1 -1
- package/build-module/color-picker/color-display.js.map +1 -1
- package/build-module/color-picker/styles.js +8 -8
- package/build-module/color-picker/styles.js.map +1 -1
- package/build-module/combobox-control/index.js +1 -1
- package/build-module/combobox-control/index.js.map +1 -1
- package/build-module/confirm-dialog/component.js +4 -5
- package/build-module/confirm-dialog/component.js.map +1 -1
- package/build-module/date-time/time.js +7 -4
- package/build-module/date-time/time.js.map +1 -1
- package/build-module/divider/component.js +3 -3
- package/build-module/divider/component.js.map +1 -1
- package/build-module/draggable/index.js +3 -3
- package/build-module/draggable/index.js.map +1 -1
- package/build-module/focal-point-picker/index.native.js +7 -7
- package/build-module/focal-point-picker/index.native.js.map +1 -1
- package/build-module/focal-point-picker/tooltip/index.native.js +1 -1
- package/build-module/focal-point-picker/tooltip/index.native.js.map +1 -1
- package/build-module/font-size-picker/index.js +1 -1
- package/build-module/font-size-picker/index.js.map +1 -1
- package/build-module/form-token-field/index.js +6 -6
- package/build-module/form-token-field/index.js.map +1 -1
- package/build-module/form-token-field/suggestions-list.js +2 -2
- package/build-module/form-token-field/suggestions-list.js.map +1 -1
- package/build-module/heading/component.js +4 -4
- package/build-module/heading/component.js.map +1 -1
- package/build-module/heading/hook.js +1 -1
- package/build-module/heading/hook.js.map +1 -1
- package/build-module/higher-order/with-notices/index.js +1 -1
- package/build-module/higher-order/with-notices/index.js.map +1 -1
- package/build-module/index.js +4 -4
- package/build-module/index.js.map +1 -1
- package/build-module/index.native.js +4 -4
- package/build-module/index.native.js.map +1 -1
- package/build-module/input-control/input-base.js +1 -1
- package/build-module/input-control/input-base.js.map +1 -1
- package/build-module/input-control/input-field.js +13 -10
- package/build-module/input-control/input-field.js.map +1 -1
- package/build-module/input-control/styles/input-control-styles.js +25 -25
- package/build-module/input-control/styles/input-control-styles.js.map +1 -1
- package/build-module/isolated-event-container/index.js +1 -1
- package/build-module/isolated-event-container/index.js.map +1 -1
- package/build-module/mobile/bottom-sheet/bottom-sheet-context.native.js +4 -4
- package/build-module/mobile/bottom-sheet/bottom-sheet-context.native.js.map +1 -1
- package/build-module/mobile/bottom-sheet/bottom-sheet-navigation/navigation-container.native.js +1 -1
- package/build-module/mobile/bottom-sheet/bottom-sheet-navigation/navigation-container.native.js.map +1 -1
- package/build-module/mobile/bottom-sheet/cell.native.js +1 -1
- package/build-module/mobile/bottom-sheet/cell.native.js.map +1 -1
- package/build-module/mobile/bottom-sheet/index.native.js +11 -11
- package/build-module/mobile/bottom-sheet/index.native.js.map +1 -1
- package/build-module/mobile/bottom-sheet/link-cell.native.js +1 -1
- package/build-module/mobile/bottom-sheet/link-cell.native.js.map +1 -1
- package/build-module/mobile/bottom-sheet/link-suggestion-item-cell.native.js +1 -1
- package/build-module/mobile/bottom-sheet/link-suggestion-item-cell.native.js.map +1 -1
- package/build-module/mobile/bottom-sheet/nav-bar/back-button.native.js +1 -1
- package/build-module/mobile/bottom-sheet/nav-bar/back-button.native.js.map +1 -1
- package/build-module/mobile/global-styles-context/utils.native.js +10 -10
- package/build-module/mobile/global-styles-context/utils.native.js.map +1 -1
- package/build-module/mobile/gradient/index.native.js +2 -2
- package/build-module/mobile/gradient/index.native.js.map +1 -1
- package/build-module/mobile/html-text-input/container.ios.js +3 -3
- package/build-module/mobile/html-text-input/container.ios.js.map +1 -1
- package/build-module/mobile/html-text-input/index.native.js +1 -1
- package/build-module/mobile/html-text-input/index.native.js.map +1 -1
- package/build-module/mobile/image/index.native.js +1 -1
- package/build-module/mobile/image/index.native.js.map +1 -1
- package/build-module/mobile/keyboard-aware-flat-list/index.android.js +1 -1
- package/build-module/mobile/keyboard-aware-flat-list/index.android.js.map +1 -1
- package/build-module/mobile/keyboard-aware-flat-list/index.ios.js +2 -2
- package/build-module/mobile/keyboard-aware-flat-list/index.ios.js.map +1 -1
- package/build-module/mobile/link-picker/index.native.js +3 -3
- package/build-module/mobile/link-picker/index.native.js.map +1 -1
- package/build-module/mobile/link-picker/link-picker-results.native.js +8 -8
- package/build-module/mobile/link-picker/link-picker-results.native.js.map +1 -1
- package/build-module/mobile/link-settings/image-link-destinations-screen.native.js +2 -2
- package/build-module/mobile/link-settings/image-link-destinations-screen.native.js.map +1 -1
- package/build-module/mobile/link-settings/index.native.js +1 -1
- package/build-module/mobile/link-settings/index.native.js.map +1 -1
- package/build-module/modal/aria-helper.js +1 -1
- package/build-module/modal/aria-helper.js.map +1 -1
- package/build-module/modal/index.js +2 -2
- package/build-module/modal/index.js.map +1 -1
- package/build-module/navigable-container/container.js +2 -2
- package/build-module/navigable-container/container.js.map +1 -1
- package/build-module/navigable-container/tabbable.js +1 -1
- package/build-module/navigable-container/tabbable.js.map +1 -1
- package/build-module/navigation/item/index.js +1 -1
- package/build-module/navigation/item/index.js.map +1 -1
- package/build-module/navigation/menu/index.js +1 -1
- package/build-module/navigation/menu/index.js.map +1 -1
- package/build-module/navigator/navigator-provider/component.js +2 -2
- package/build-module/navigator/navigator-provider/component.js.map +1 -1
- package/build-module/navigator/navigator-screen/component.js +1 -1
- package/build-module/navigator/navigator-screen/component.js.map +1 -1
- package/build-module/number-control/index.js +1 -1
- package/build-module/number-control/index.js.map +1 -1
- package/build-module/panel/body.js +2 -2
- package/build-module/panel/body.js.map +1 -1
- package/build-module/popover/index.js +3 -3
- package/build-module/popover/index.js.map +1 -1
- package/build-module/popover/utils.js +6 -6
- package/build-module/popover/utils.js.map +1 -1
- package/build-module/radio-group/index.js +1 -1
- package/build-module/radio-group/index.js.map +1 -1
- package/build-module/range-control/styles/range-control-styles.js +29 -29
- package/build-module/range-control/styles/range-control-styles.js.map +1 -1
- package/build-module/sandbox/index.js +5 -5
- package/build-module/sandbox/index.js.map +1 -1
- package/build-module/sandbox/index.native.js +1 -1
- package/build-module/sandbox/index.native.js.map +1 -1
- package/build-module/select-control/index.js +1 -1
- package/build-module/select-control/index.js.map +1 -1
- package/build-module/select-control/styles/select-control-styles.js +5 -5
- package/build-module/select-control/styles/select-control-styles.js.map +1 -1
- package/build-module/slot-fill/bubbles-virtually/slot-fill-provider.js +1 -1
- package/build-module/slot-fill/bubbles-virtually/slot-fill-provider.js.map +1 -1
- package/build-module/slot-fill/bubbles-virtually/slot.js +1 -1
- package/build-module/slot-fill/bubbles-virtually/slot.js.map +1 -1
- package/build-module/slot-fill/fill.js +1 -1
- package/build-module/slot-fill/fill.js.map +1 -1
- package/build-module/slot-fill/provider.js +1 -1
- package/build-module/slot-fill/provider.js.map +1 -1
- package/build-module/snackbar/index.js +1 -1
- package/build-module/snackbar/index.js.map +1 -1
- package/build-module/snackbar/list.js +1 -1
- package/build-module/snackbar/list.js.map +1 -1
- package/build-module/style-provider/index.js +2 -2
- package/build-module/style-provider/index.js.map +1 -1
- package/build-module/toggle-group-control/toggle-group-control/component.js +2 -2
- package/build-module/toggle-group-control/toggle-group-control/component.js.map +1 -1
- package/build-module/toggle-group-control/toggle-group-control-option/styles.js +8 -8
- package/build-module/toggle-group-control/toggle-group-control-option/styles.js.map +1 -1
- package/build-module/toolbar/index.js +1 -1
- package/build-module/toolbar/index.js.map +1 -1
- package/build-module/tooltip/index.js +3 -3
- package/build-module/tooltip/index.js.map +1 -1
- package/build-module/tooltip/index.native.js +7 -7
- package/build-module/tooltip/index.native.js.map +1 -1
- package/build-module/truncate/utils.js +1 -1
- package/build-module/truncate/utils.js.map +1 -1
- package/build-module/ui/context/context-connect.js +9 -16
- package/build-module/ui/context/context-connect.js.map +1 -1
- package/build-module/ui/context/context-system-provider.js +2 -2
- package/build-module/ui/context/context-system-provider.js.map +1 -1
- package/build-module/ui/context/index.js.map +1 -1
- package/build-module/ui/utils/colors.js +2 -2
- package/build-module/ui/utils/colors.js.map +1 -1
- package/build-module/ui/utils/space.js +2 -2
- package/build-module/ui/utils/space.js.map +1 -1
- package/build-module/unit-control/index.js +39 -30
- package/build-module/unit-control/index.js.map +1 -1
- package/build-module/unit-control/index.native.js +5 -3
- package/build-module/unit-control/index.native.js.map +1 -1
- package/build-module/unit-control/unit-select-control.js +1 -1
- package/build-module/unit-control/unit-select-control.js.map +1 -1
- package/build-module/unit-control/utils.js +92 -100
- package/build-module/unit-control/utils.js.map +1 -1
- package/build-module/utils/breakpoint-values.js +1 -1
- package/build-module/utils/breakpoint-values.js.map +1 -1
- package/build-module/utils/colors-values.js +1 -1
- package/build-module/utils/colors-values.js.map +1 -1
- package/build-style/style-rtl.css +8 -0
- package/build-style/style.css +8 -0
- package/build-types/base-field/hook.d.ts +2 -1
- package/build-types/base-field/hook.d.ts.map +1 -1
- package/build-types/card/card/hook.d.ts +2 -1
- package/build-types/card/card/hook.d.ts.map +1 -1
- package/build-types/card/card-body/hook.d.ts +2 -1
- package/build-types/card/card-body/hook.d.ts.map +1 -1
- package/build-types/card/card-divider/hook.d.ts +2 -2
- package/build-types/card/card-footer/hook.d.ts +2 -1
- package/build-types/card/card-footer/hook.d.ts.map +1 -1
- package/build-types/card/card-header/hook.d.ts +2 -1
- package/build-types/card/card-header/hook.d.ts.map +1 -1
- package/build-types/card/card-media/hook.d.ts +2 -1
- package/build-types/card/card-media/hook.d.ts.map +1 -1
- package/build-types/color-picker/styles.d.ts +2 -2
- package/build-types/confirm-dialog/component.d.ts +8 -0
- package/build-types/confirm-dialog/component.d.ts.map +1 -1
- package/build-types/confirm-dialog/types.d.ts +2 -0
- package/build-types/confirm-dialog/types.d.ts.map +1 -1
- package/build-types/divider/component.d.ts +2 -2
- package/build-types/divider/component.d.ts.map +1 -1
- package/build-types/divider/stories/index.d.ts +10 -0
- package/build-types/divider/stories/index.d.ts.map +1 -0
- package/build-types/divider/types.d.ts +1 -1
- package/build-types/divider/types.d.ts.map +1 -1
- package/build-types/elevation/hook.d.ts +2 -1
- package/build-types/elevation/hook.d.ts.map +1 -1
- package/build-types/flex/flex/hook.d.ts +2 -1
- package/build-types/flex/flex/hook.d.ts.map +1 -1
- package/build-types/flex/flex-block/hook.d.ts +2 -1
- package/build-types/flex/flex-block/hook.d.ts.map +1 -1
- package/build-types/flex/flex-item/hook.d.ts +2 -1
- package/build-types/flex/flex-item/hook.d.ts.map +1 -1
- package/build-types/flyout/flyout/hook.d.ts +2 -1
- package/build-types/flyout/flyout/hook.d.ts.map +1 -1
- package/build-types/grid/hook.d.ts +2 -1
- package/build-types/grid/hook.d.ts.map +1 -1
- package/build-types/h-stack/hook.d.ts +3 -2
- package/build-types/h-stack/hook.d.ts.map +1 -1
- package/build-types/heading/component.d.ts +3 -3
- package/build-types/heading/component.d.ts.map +1 -1
- package/build-types/heading/hook.d.ts +2 -1
- package/build-types/heading/hook.d.ts.map +1 -1
- package/build-types/heading/stories/index.d.ts +12 -0
- package/build-types/heading/stories/index.d.ts.map +1 -0
- package/build-types/input-control/index.d.ts +1 -1
- package/build-types/input-control/index.d.ts.map +1 -1
- package/build-types/input-control/input-field.d.ts +1 -1
- package/build-types/input-control/input-field.d.ts.map +1 -1
- package/build-types/input-control/styles/input-control-styles.d.ts.map +1 -1
- package/build-types/item-group/item/hook.d.ts +2 -1
- package/build-types/item-group/item/hook.d.ts.map +1 -1
- package/build-types/item-group/item-group/hook.d.ts +2 -1
- package/build-types/item-group/item-group/hook.d.ts.map +1 -1
- package/build-types/navigator/navigator-back-button/hook.d.ts +2 -1
- package/build-types/navigator/navigator-back-button/hook.d.ts.map +1 -1
- package/build-types/navigator/navigator-button/hook.d.ts +2 -1
- package/build-types/navigator/navigator-button/hook.d.ts.map +1 -1
- package/build-types/number-control/styles/number-control-styles.d.ts +1 -1
- package/build-types/scrollable/hook.d.ts +2 -1
- package/build-types/scrollable/hook.d.ts.map +1 -1
- package/build-types/select-control/index.d.ts +1 -1
- package/build-types/select-control/index.d.ts.map +1 -1
- package/build-types/select-control/styles/select-control-styles.d.ts.map +1 -1
- package/build-types/spacer/hook.d.ts +2 -1
- package/build-types/spacer/hook.d.ts.map +1 -1
- package/build-types/surface/hook.d.ts +2 -1
- package/build-types/surface/hook.d.ts.map +1 -1
- package/build-types/text/hook.d.ts +2 -1
- package/build-types/text/hook.d.ts.map +1 -1
- package/build-types/text/types.d.ts +1 -2
- package/build-types/text/types.d.ts.map +1 -1
- package/build-types/toggle-group-control/toggle-group-control-option/styles.d.ts.map +1 -1
- package/build-types/tools-panel/tools-panel/hook.d.ts +2 -1
- package/build-types/tools-panel/tools-panel/hook.d.ts.map +1 -1
- package/build-types/tools-panel/tools-panel-header/hook.d.ts +2 -1
- package/build-types/tools-panel/tools-panel-header/hook.d.ts.map +1 -1
- package/build-types/tools-panel/tools-panel-item/hook.d.ts +2 -1
- package/build-types/tools-panel/tools-panel-item/hook.d.ts.map +1 -1
- package/build-types/truncate/hook.d.ts +2 -1
- package/build-types/truncate/hook.d.ts.map +1 -1
- package/build-types/ui/context/context-connect.d.ts +18 -16
- package/build-types/ui/context/context-connect.d.ts.map +1 -1
- package/build-types/ui/context/index.d.ts +4 -4
- package/build-types/ui/context/index.d.ts.map +1 -1
- package/build-types/ui/context/wordpress-component.d.ts +1 -0
- package/build-types/ui/context/wordpress-component.d.ts.map +1 -1
- package/build-types/ui/control-group/hook.d.ts +2 -1
- package/build-types/ui/control-group/hook.d.ts.map +1 -1
- package/build-types/ui/control-label/hook.d.ts +2 -1
- package/build-types/ui/control-label/hook.d.ts.map +1 -1
- package/build-types/ui/form-group/use-form-group.d.ts +6 -4
- package/build-types/ui/form-group/use-form-group.d.ts.map +1 -1
- package/build-types/unit-control/index.d.ts +3 -3
- package/build-types/unit-control/index.d.ts.map +1 -1
- package/build-types/unit-control/types.d.ts +4 -6
- package/build-types/unit-control/types.d.ts.map +1 -1
- package/build-types/unit-control/utils.d.ts +47 -38
- package/build-types/unit-control/utils.d.ts.map +1 -1
- package/build-types/v-stack/hook.d.ts +2 -1
- package/build-types/v-stack/hook.d.ts.map +1 -1
- package/package.json +18 -18
- package/src/alignment-matrix-control/utils.js +1 -1
- package/src/angle-picker-control/angle-circle.js +1 -1
- package/src/animation/index.js +0 -1
- package/src/autocomplete/get-default-use-items.js +3 -3
- package/src/base-field/hook.js +1 -1
- package/src/box-control/icon.js +1 -1
- package/src/box-control/index.js +5 -5
- package/src/box-control/test/index.js +27 -7
- package/src/box-control/utils.js +13 -9
- package/src/button/index.js +5 -5
- package/src/button/index.native.js +7 -7
- package/src/button/style.scss +1 -0
- package/src/color-palette/style.scss +1 -0
- package/src/color-picker/color-display.tsx +1 -1
- package/src/color-picker/styles.ts +1 -1
- package/src/color-picker/test/index.js +1 -1
- package/src/combobox-control/index.js +1 -1
- package/src/combobox-control/style.scss +1 -0
- package/src/confirm-dialog/README.md +56 -45
- package/src/confirm-dialog/component.tsx +4 -2
- package/src/confirm-dialog/stories/index.js +19 -0
- package/src/confirm-dialog/test/index.js +28 -0
- package/src/confirm-dialog/types.ts +2 -0
- package/src/date-time/style.scss +4 -0
- package/src/date-time/time.js +16 -5
- package/src/dimension-control/test/index.test.js +1 -1
- package/src/disabled/test/index.js +1 -1
- package/src/divider/component.tsx +3 -3
- package/src/divider/stories/index.tsx +70 -0
- package/src/divider/types.ts +3 -1
- package/src/draggable/index.js +3 -3
- package/src/draggable/stories/index.js +1 -1
- package/src/flyout/flyout/README.md +1 -1
- package/src/flyout/test/index.js +1 -1
- package/src/focal-point-picker/index.native.js +7 -7
- package/src/focal-point-picker/tooltip/index.native.js +1 -1
- package/src/font-size-picker/README.md +1 -2
- package/src/font-size-picker/index.js +1 -1
- package/src/font-size-picker/stories/index.js +87 -108
- package/src/form-token-field/index.js +6 -6
- package/src/form-token-field/style.scss +1 -0
- package/src/form-token-field/suggestions-list.js +2 -2
- package/src/form-token-field/test/index.js +6 -6
- package/src/heading/component.tsx +4 -4
- package/src/heading/hook.ts +1 -1
- package/src/heading/stories/index.tsx +37 -0
- package/src/higher-order/with-filters/test/index.js +1 -1
- package/src/higher-order/with-focus-outside/test/index.js +1 -1
- package/src/higher-order/with-notices/index.js +1 -1
- package/src/higher-order/with-notices/test/index.js +3 -3
- package/src/index.js +4 -4
- package/src/index.native.js +4 -4
- package/src/input-control/input-base.tsx +1 -1
- package/src/input-control/input-field.tsx +12 -9
- package/src/input-control/styles/input-control-styles.tsx +1 -0
- package/src/input-control/test/index.js +4 -4
- package/src/isolated-event-container/index.js +1 -1
- package/src/item-group/test/index.js +0 -1
- package/src/mobile/bottom-sheet/bottom-sheet-context.native.js +4 -4
- package/src/mobile/bottom-sheet/bottom-sheet-navigation/navigation-container.native.js +1 -1
- package/src/mobile/bottom-sheet/cell.native.js +1 -1
- package/src/mobile/bottom-sheet/index.native.js +11 -11
- package/src/mobile/bottom-sheet/link-cell.native.js +1 -1
- package/src/mobile/bottom-sheet/link-suggestion-item-cell.native.js +1 -1
- package/src/mobile/bottom-sheet/nav-bar/back-button.native.js +1 -1
- package/src/mobile/global-styles-context/utils.native.js +10 -10
- package/src/mobile/gradient/index.native.js +2 -2
- package/src/mobile/html-text-input/container.ios.js +3 -3
- package/src/mobile/html-text-input/index.native.js +1 -1
- package/src/mobile/html-text-input/test/index.native.js +14 -14
- package/src/mobile/image/index.native.js +1 -1
- package/src/mobile/keyboard-aware-flat-list/index.android.js +1 -1
- package/src/mobile/keyboard-aware-flat-list/index.ios.js +2 -2
- package/src/mobile/link-picker/index.native.js +3 -3
- package/src/mobile/link-picker/link-picker-results.native.js +8 -8
- package/src/mobile/link-settings/image-link-destinations-screen.native.js +2 -2
- package/src/mobile/link-settings/index.native.js +1 -2
- package/src/mobile/link-settings/test/edit.native.js +15 -15
- package/src/modal/aria-helper.js +1 -1
- package/src/modal/index.js +2 -2
- package/src/navigable-container/container.js +2 -2
- package/src/navigable-container/tabbable.js +1 -1
- package/src/navigable-container/test/menu.js +5 -5
- package/src/navigable-container/test/tabbable.js +2 -2
- package/src/navigation/item/index.js +1 -1
- package/src/navigation/menu/index.js +1 -1
- package/src/navigation/stories/controlled-state.js +2 -2
- package/src/navigator/navigator-provider/component.tsx +1 -1
- package/src/navigator/navigator-screen/component.tsx +2 -2
- package/src/navigator/test/index.js +18 -19
- package/src/navigator/types.ts +1 -1
- package/src/number-control/index.js +1 -1
- package/src/panel/body.js +2 -2
- package/src/popover/index.js +3 -3
- package/src/popover/utils.js +6 -6
- package/src/radio-group/index.js +1 -1
- package/src/range-control/stories/index.js +1 -1
- package/src/range-control/styles/range-control-styles.js +1 -1
- package/src/range-control/test/index.js +2 -2
- package/src/sandbox/index.js +5 -5
- package/src/sandbox/index.native.js +1 -1
- package/src/select-control/index.tsx +1 -1
- package/src/select-control/styles/select-control-styles.ts +1 -0
- package/src/slot-fill/bubbles-virtually/slot-fill-provider.js +1 -1
- package/src/slot-fill/bubbles-virtually/slot.js +1 -2
- package/src/slot-fill/fill.js +1 -1
- package/src/slot-fill/provider.js +1 -1
- package/src/snackbar/index.js +1 -1
- package/src/snackbar/list.js +1 -1
- package/src/style-provider/index.js +2 -2
- package/src/tab-panel/test/index.js +1 -1
- package/src/text/test/index.js +2 -2
- package/src/text/types.ts +6 -8
- package/src/text-highlight/test/index.js +4 -4
- package/src/toggle-control/test/index.js +3 -3
- package/src/toggle-group-control/test/__snapshots__/index.js.snap +1 -0
- package/src/toggle-group-control/toggle-group-control/component.tsx +2 -2
- package/src/toggle-group-control/toggle-group-control-option/styles.ts +1 -0
- package/src/toolbar/index.js +1 -1
- package/src/toolbar-group/test/index.js +2 -2
- package/src/tooltip/index.js +3 -3
- package/src/tooltip/index.native.js +7 -7
- package/src/tooltip/test/index.js +2 -2
- package/src/tooltip/test/index.native.js +2 -2
- package/src/tree-grid/test/__snapshots__/index.js.snap +1 -1
- package/src/tree-grid/test/index.js +71 -39
- package/src/truncate/utils.js +1 -1
- package/src/ui/context/{context-connect.js → context-connect.ts} +27 -16
- package/src/ui/context/context-system-provider.js +2 -2
- package/src/ui/context/{index.js → index.ts} +0 -0
- package/src/ui/context/wordpress-component.ts +1 -0
- package/src/ui/tooltip/test/index.js +4 -4
- package/src/ui/utils/colors.js +2 -2
- package/src/ui/utils/space.ts +2 -2
- package/src/unit-control/README.md +1 -1
- package/src/unit-control/index.native.js +5 -3
- package/src/unit-control/index.tsx +64 -35
- package/src/unit-control/test/index.js +102 -3
- package/src/unit-control/test/utils.js +56 -15
- package/src/unit-control/types.ts +5 -8
- package/src/unit-control/unit-select-control.tsx +1 -1
- package/src/unit-control/utils.ts +128 -125
- package/src/utils/breakpoint-values.js +1 -1
- package/src/utils/colors-values.js +1 -1
- package/src/utils/hooks/test/use-controlled-state.js +1 -1
- package/src/utils/hooks/test/use-controlled-value.js +3 -3
- package/src/utils/hooks/test/use-latest-ref.js +1 -1
- package/src/utils/test/math.js +2 -2
- package/src/utils/test/rtl.js +12 -12
- package/tsconfig.json +1 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/src/divider/stories/index.js +0 -64
- package/src/heading/stories/index.js +0 -24
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { render, fireEvent } from '@testing-library/react';
|
|
4
|
+
import { render, fireEvent, screen } from '@testing-library/react';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
|
-
import { UP, DOWN, ENTER } from '@wordpress/keycodes';
|
|
9
|
+
import { UP, DOWN, ENTER, ESCAPE } from '@wordpress/keycodes';
|
|
10
|
+
import { useState } from '@wordpress/element';
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* Internal dependencies
|
|
13
14
|
*/
|
|
14
15
|
import UnitControl from '../';
|
|
16
|
+
import { parseQuantityAndUnitFromRawValue } from '../utils';
|
|
15
17
|
|
|
16
18
|
const getComponent = () =>
|
|
17
19
|
document.body.querySelector( '.components-unit-control' );
|
|
@@ -25,6 +27,52 @@ const getUnitLabel = () =>
|
|
|
25
27
|
const fireKeyDown = ( data ) =>
|
|
26
28
|
fireEvent.keyDown( document.activeElement || document.body, data );
|
|
27
29
|
|
|
30
|
+
const ControlledSyncUnits = () => {
|
|
31
|
+
const [ state, setState ] = useState( { valueA: '', valueB: '' } );
|
|
32
|
+
|
|
33
|
+
// Keep the unit sync'd between the two `UnitControl` instances.
|
|
34
|
+
const onUnitControlChange = ( fieldName, newValue ) => {
|
|
35
|
+
// eslint-disable-next-line @wordpress/no-unused-vars-before-return
|
|
36
|
+
const [ quantity, newUnit ] = parseQuantityAndUnitFromRawValue(
|
|
37
|
+
newValue
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
if ( ! Number.isFinite( quantity ) ) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const nextState = { ...state, [ fieldName ]: newValue };
|
|
45
|
+
|
|
46
|
+
Object.entries( state ).forEach( ( [ stateProp, stateValue ] ) => {
|
|
47
|
+
const [
|
|
48
|
+
stateQuantity,
|
|
49
|
+
stateUnit,
|
|
50
|
+
] = parseQuantityAndUnitFromRawValue( stateValue );
|
|
51
|
+
|
|
52
|
+
if ( stateProp !== fieldName && stateUnit !== newUnit ) {
|
|
53
|
+
nextState[ stateProp ] = `${ stateQuantity }${ newUnit }`;
|
|
54
|
+
}
|
|
55
|
+
} );
|
|
56
|
+
|
|
57
|
+
setState( nextState );
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
return (
|
|
61
|
+
<>
|
|
62
|
+
<UnitControl
|
|
63
|
+
label="Field A"
|
|
64
|
+
value={ state.valueA }
|
|
65
|
+
onChange={ ( v ) => onUnitControlChange( 'valueA', v ) }
|
|
66
|
+
/>
|
|
67
|
+
<UnitControl
|
|
68
|
+
label="Field B"
|
|
69
|
+
value={ state.valueB }
|
|
70
|
+
onChange={ ( v ) => onUnitControlChange( 'valueB', v ) }
|
|
71
|
+
/>
|
|
72
|
+
</>
|
|
73
|
+
);
|
|
74
|
+
};
|
|
75
|
+
|
|
28
76
|
describe( 'UnitControl', () => {
|
|
29
77
|
describe( 'Basic rendering', () => {
|
|
30
78
|
it( 'should render', () => {
|
|
@@ -45,7 +93,7 @@ describe( 'UnitControl', () => {
|
|
|
45
93
|
} );
|
|
46
94
|
|
|
47
95
|
it( 'should not render select, if units are disabled', () => {
|
|
48
|
-
render( <UnitControl unit="em" units={
|
|
96
|
+
render( <UnitControl unit="em" units={ [] } /> );
|
|
49
97
|
const input = getInput();
|
|
50
98
|
const select = getSelect();
|
|
51
99
|
|
|
@@ -126,6 +174,32 @@ describe( 'UnitControl', () => {
|
|
|
126
174
|
|
|
127
175
|
expect( state ).toBe( '40px' );
|
|
128
176
|
} );
|
|
177
|
+
|
|
178
|
+
it( 'should cancel change when ESCAPE key is pressed', () => {
|
|
179
|
+
let state = 50;
|
|
180
|
+
const setState = ( nextState ) => ( state = nextState );
|
|
181
|
+
|
|
182
|
+
render(
|
|
183
|
+
<UnitControl
|
|
184
|
+
value={ state }
|
|
185
|
+
onChange={ setState }
|
|
186
|
+
isPressEnterToChange
|
|
187
|
+
/>
|
|
188
|
+
);
|
|
189
|
+
|
|
190
|
+
const input = getInput();
|
|
191
|
+
input.focus();
|
|
192
|
+
|
|
193
|
+
fireEvent.change( input, { target: { value: '300px' } } );
|
|
194
|
+
|
|
195
|
+
expect( input.value ).toBe( '300px' );
|
|
196
|
+
expect( state ).toBe( 50 );
|
|
197
|
+
|
|
198
|
+
fireKeyDown( { keyCode: ESCAPE } );
|
|
199
|
+
|
|
200
|
+
expect( input.value ).toBe( '50' );
|
|
201
|
+
expect( state ).toBe( 50 );
|
|
202
|
+
} );
|
|
129
203
|
} );
|
|
130
204
|
|
|
131
205
|
describe( 'Unit', () => {
|
|
@@ -240,6 +314,31 @@ describe( 'UnitControl', () => {
|
|
|
240
314
|
|
|
241
315
|
expect( state ).toBe( '62%' );
|
|
242
316
|
} );
|
|
317
|
+
|
|
318
|
+
it( 'should update unit value when a new raw value is passed', () => {
|
|
319
|
+
render( <ControlledSyncUnits /> );
|
|
320
|
+
|
|
321
|
+
const [ inputA, inputB ] = screen.getAllByRole( 'spinbutton' );
|
|
322
|
+
const [ selectA, selectB ] = screen.getAllByRole( 'combobox' );
|
|
323
|
+
|
|
324
|
+
inputA.focus();
|
|
325
|
+
fireEvent.change( inputA, { target: { value: '55' } } );
|
|
326
|
+
|
|
327
|
+
inputB.focus();
|
|
328
|
+
fireEvent.change( inputB, { target: { value: '14' } } );
|
|
329
|
+
|
|
330
|
+
selectA.focus();
|
|
331
|
+
fireEvent.change( selectA, { target: { value: 'rem' } } );
|
|
332
|
+
|
|
333
|
+
expect( selectA ).toHaveValue( 'rem' );
|
|
334
|
+
expect( selectB ).toHaveValue( 'rem' );
|
|
335
|
+
|
|
336
|
+
selectB.focus();
|
|
337
|
+
fireEvent.change( selectB, { target: { value: 'vw' } } );
|
|
338
|
+
|
|
339
|
+
expect( selectA ).toHaveValue( 'vw' );
|
|
340
|
+
expect( selectB ).toHaveValue( 'vw' );
|
|
341
|
+
} );
|
|
243
342
|
} );
|
|
244
343
|
|
|
245
344
|
describe( 'Unit Parser', () => {
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import {
|
|
5
5
|
filterUnitsWithSettings,
|
|
6
6
|
useCustomUnits,
|
|
7
|
-
|
|
7
|
+
getValidParsedQuantityAndUnit,
|
|
8
8
|
getUnitsWithCurrentUnit,
|
|
9
9
|
} from '../utils';
|
|
10
10
|
|
|
@@ -34,7 +34,27 @@ describe( 'UnitControl utils', () => {
|
|
|
34
34
|
] );
|
|
35
35
|
} );
|
|
36
36
|
|
|
37
|
-
it( 'should
|
|
37
|
+
it( 'should add default values to available units even if the default values are strings', () => {
|
|
38
|
+
// Although the public APIs of the component expect a `number` as the type of the
|
|
39
|
+
// default values, it's still good to test for strings (as it can happen in un-typed
|
|
40
|
+
// environments)
|
|
41
|
+
const cssUnits = [ { value: 'px' }, { value: '%' } ];
|
|
42
|
+
const units = useCustomUnits( {
|
|
43
|
+
availableUnits: [ '%', 'px' ],
|
|
44
|
+
defaultValues: {
|
|
45
|
+
'%': '14',
|
|
46
|
+
px: 'not a valid numeric quantity',
|
|
47
|
+
},
|
|
48
|
+
units: cssUnits,
|
|
49
|
+
} );
|
|
50
|
+
|
|
51
|
+
expect( units ).toEqual( [
|
|
52
|
+
{ value: 'px', default: undefined },
|
|
53
|
+
{ value: '%', default: 14 },
|
|
54
|
+
] );
|
|
55
|
+
} );
|
|
56
|
+
|
|
57
|
+
it( 'should return an empty array where availableUnits match no preferred css units', () => {
|
|
38
58
|
const cssUnits = [ { value: 'em' }, { value: 'vh' } ];
|
|
39
59
|
const units = useCustomUnits( {
|
|
40
60
|
availableUnits: [ '%', 'px' ],
|
|
@@ -42,7 +62,7 @@ describe( 'UnitControl utils', () => {
|
|
|
42
62
|
units: cssUnits,
|
|
43
63
|
} );
|
|
44
64
|
|
|
45
|
-
expect( units ).
|
|
65
|
+
expect( units ).toHaveLength( 0 );
|
|
46
66
|
} );
|
|
47
67
|
} );
|
|
48
68
|
|
|
@@ -65,6 +85,8 @@ describe( 'UnitControl utils', () => {
|
|
|
65
85
|
).toEqual( [] );
|
|
66
86
|
} );
|
|
67
87
|
|
|
88
|
+
// Although the component's APIs and types don't allow for `false` as a value
|
|
89
|
+
// unit lists, it's good to keep this test around for backwards compat.
|
|
68
90
|
it( 'should return empty array where available units is set to false', () => {
|
|
69
91
|
const preferredUnits = [ '%', 'px' ];
|
|
70
92
|
const availableUnits = false;
|
|
@@ -73,19 +95,31 @@ describe( 'UnitControl utils', () => {
|
|
|
73
95
|
filterUnitsWithSettings( preferredUnits, availableUnits )
|
|
74
96
|
).toEqual( [] );
|
|
75
97
|
} );
|
|
98
|
+
|
|
99
|
+
it( 'should return empty array where available units is set to an empty array', () => {
|
|
100
|
+
const preferredUnits = [ '%', 'px' ];
|
|
101
|
+
const availableUnits = [];
|
|
102
|
+
|
|
103
|
+
expect(
|
|
104
|
+
filterUnitsWithSettings( preferredUnits, availableUnits )
|
|
105
|
+
).toEqual( [] );
|
|
106
|
+
} );
|
|
76
107
|
} );
|
|
77
108
|
|
|
78
|
-
describe( '
|
|
109
|
+
describe( 'getValidParsedQuantityAndUnit', () => {
|
|
79
110
|
it( 'should parse valid number and unit', () => {
|
|
80
111
|
const nextValue = '42px';
|
|
81
112
|
|
|
82
|
-
expect(
|
|
113
|
+
expect( getValidParsedQuantityAndUnit( nextValue ) ).toEqual( [
|
|
114
|
+
42,
|
|
115
|
+
'px',
|
|
116
|
+
] );
|
|
83
117
|
} );
|
|
84
118
|
|
|
85
119
|
it( 'should return next value only where no known unit parsed', () => {
|
|
86
120
|
const nextValue = '365zz';
|
|
87
121
|
|
|
88
|
-
expect(
|
|
122
|
+
expect( getValidParsedQuantityAndUnit( nextValue ) ).toEqual( [
|
|
89
123
|
365,
|
|
90
124
|
undefined,
|
|
91
125
|
] );
|
|
@@ -97,7 +131,11 @@ describe( 'UnitControl utils', () => {
|
|
|
97
131
|
const fallbackValue = 13;
|
|
98
132
|
|
|
99
133
|
expect(
|
|
100
|
-
|
|
134
|
+
getValidParsedQuantityAndUnit(
|
|
135
|
+
nextValue,
|
|
136
|
+
preferredUnits,
|
|
137
|
+
fallbackValue
|
|
138
|
+
)
|
|
101
139
|
).toEqual( [ 13, 'em' ] );
|
|
102
140
|
} );
|
|
103
141
|
|
|
@@ -106,7 +144,7 @@ describe( 'UnitControl utils', () => {
|
|
|
106
144
|
const fallbackUnit = '%';
|
|
107
145
|
|
|
108
146
|
expect(
|
|
109
|
-
|
|
147
|
+
getValidParsedQuantityAndUnit(
|
|
110
148
|
nextValue,
|
|
111
149
|
undefined,
|
|
112
150
|
undefined,
|
|
@@ -119,10 +157,9 @@ describe( 'UnitControl utils', () => {
|
|
|
119
157
|
const nextValue = 101;
|
|
120
158
|
const preferredUnits = [ { value: 'px' } ];
|
|
121
159
|
|
|
122
|
-
expect(
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
] );
|
|
160
|
+
expect(
|
|
161
|
+
getValidParsedQuantityAndUnit( nextValue, preferredUnits )
|
|
162
|
+
).toEqual( [ 101, 'px' ] );
|
|
126
163
|
} );
|
|
127
164
|
} );
|
|
128
165
|
|
|
@@ -139,7 +176,11 @@ describe( 'UnitControl utils', () => {
|
|
|
139
176
|
];
|
|
140
177
|
|
|
141
178
|
it( 'should return units list with valid current unit prepended', () => {
|
|
142
|
-
const result = getUnitsWithCurrentUnit(
|
|
179
|
+
const result = getUnitsWithCurrentUnit(
|
|
180
|
+
'20%',
|
|
181
|
+
undefined,
|
|
182
|
+
limitedUnits
|
|
183
|
+
);
|
|
143
184
|
|
|
144
185
|
expect( result ).toHaveLength( 3 );
|
|
145
186
|
|
|
@@ -163,7 +204,7 @@ describe( 'UnitControl utils', () => {
|
|
|
163
204
|
it( 'should return units list without invalid current unit prepended', () => {
|
|
164
205
|
const result = getUnitsWithCurrentUnit(
|
|
165
206
|
'20null',
|
|
166
|
-
|
|
207
|
+
undefined,
|
|
167
208
|
limitedUnits
|
|
168
209
|
);
|
|
169
210
|
|
|
@@ -174,7 +215,7 @@ describe( 'UnitControl utils', () => {
|
|
|
174
215
|
it( 'should return units list without an existing current unit prepended', () => {
|
|
175
216
|
const result = getUnitsWithCurrentUnit(
|
|
176
217
|
'20em',
|
|
177
|
-
|
|
218
|
+
undefined,
|
|
178
219
|
limitedUnits
|
|
179
220
|
);
|
|
180
221
|
|
|
@@ -12,8 +12,6 @@ import type {
|
|
|
12
12
|
Size as InputSize,
|
|
13
13
|
} from '../input-control/types';
|
|
14
14
|
|
|
15
|
-
export type Value = number | string;
|
|
16
|
-
|
|
17
15
|
export type SelectSize = InputSize;
|
|
18
16
|
|
|
19
17
|
export type WPUnitControlUnit = {
|
|
@@ -26,9 +24,9 @@ export type WPUnitControlUnit = {
|
|
|
26
24
|
*/
|
|
27
25
|
label: string;
|
|
28
26
|
/**
|
|
29
|
-
* Default value for the unit, used when switching units.
|
|
27
|
+
* Default value (quantity) for the unit, used when switching units.
|
|
30
28
|
*/
|
|
31
|
-
default?:
|
|
29
|
+
default?: number;
|
|
32
30
|
/**
|
|
33
31
|
* An accessible label used by screen readers.
|
|
34
32
|
*/
|
|
@@ -39,8 +37,6 @@ export type WPUnitControlUnit = {
|
|
|
39
37
|
step?: number;
|
|
40
38
|
};
|
|
41
39
|
|
|
42
|
-
export type WPUnitControlUnitList = Array< WPUnitControlUnit > | false;
|
|
43
|
-
|
|
44
40
|
export type UnitControlOnChangeCallback = InputChangeCallback<
|
|
45
41
|
SyntheticEvent< HTMLSelectElement | HTMLInputElement >,
|
|
46
42
|
{ data?: WPUnitControlUnit }
|
|
@@ -74,9 +70,10 @@ export type UnitSelectControlProps = {
|
|
|
74
70
|
*
|
|
75
71
|
* @default CSS_UNITS
|
|
76
72
|
*/
|
|
77
|
-
units?:
|
|
73
|
+
units?: WPUnitControlUnit[];
|
|
78
74
|
};
|
|
79
75
|
|
|
76
|
+
// TODO: when available, should (partially) extend `NumberControl` props.
|
|
80
77
|
export type UnitControlProps = UnitSelectControlProps & {
|
|
81
78
|
__unstableStateReducer?: StateReducer;
|
|
82
79
|
__unstableInputWidth?: CSSProperties[ 'width' ];
|
|
@@ -114,5 +111,5 @@ export type UnitControlProps = UnitSelectControlProps & {
|
|
|
114
111
|
* Current value. If passed as a string, the current unit will be inferred from this value.
|
|
115
112
|
* For example, a `value` of "50%" will set the current unit to `%`.
|
|
116
113
|
*/
|
|
117
|
-
value
|
|
114
|
+
value?: string | number;
|
|
118
115
|
};
|
|
@@ -22,7 +22,7 @@ export default function UnitSelectControl( {
|
|
|
22
22
|
units = CSS_UNITS,
|
|
23
23
|
...props
|
|
24
24
|
}: WordPressComponentProps< UnitSelectControlProps, 'select', false > ) {
|
|
25
|
-
if ( !
|
|
25
|
+
if ( ! hasUnits( units ) || units?.length === 1 ) {
|
|
26
26
|
return (
|
|
27
27
|
<UnitLabel
|
|
28
28
|
className="components-unit-control__unit-label"
|