@wordpress/components 22.1.0 → 23.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +57 -0
- package/build/alignment-matrix-control/cell.js.map +1 -1
- package/build/alignment-matrix-control/icon.js +4 -2
- package/build/alignment-matrix-control/icon.js.map +1 -1
- package/build/alignment-matrix-control/index.js +25 -1
- package/build/alignment-matrix-control/index.js.map +1 -1
- package/build/alignment-matrix-control/styles/alignment-matrix-control-icon-styles.js +13 -13
- package/build/alignment-matrix-control/styles/alignment-matrix-control-icon-styles.js.map +1 -1
- package/build/alignment-matrix-control/styles/alignment-matrix-control-styles.js +16 -16
- package/build/alignment-matrix-control/styles/alignment-matrix-control-styles.js.map +1 -1
- package/build/alignment-matrix-control/types.js +6 -0
- package/build/alignment-matrix-control/types.js.map +1 -0
- package/build/alignment-matrix-control/utils.js +9 -8
- package/build/alignment-matrix-control/utils.js.map +1 -1
- package/build/angle-picker-control/styles/angle-picker-control-styles.js +9 -9
- package/build/angle-picker-control/styles/angle-picker-control-styles.js.map +1 -1
- package/build/autocomplete/index.js +38 -9
- package/build/autocomplete/index.js.map +1 -1
- package/build/base-control/hooks.js +52 -0
- package/build/base-control/hooks.js.map +1 -0
- package/build/base-control/index.js +24 -7
- package/build/base-control/index.js.map +1 -1
- package/build/base-field/hook.js +0 -14
- package/build/base-field/hook.js.map +1 -1
- package/build/base-field/index.js.map +1 -1
- package/build/base-field/styles.js +5 -5
- package/build/base-field/styles.js.map +1 -1
- package/build/base-field/types.js +6 -0
- package/build/base-field/types.js.map +1 -0
- package/build/border-control/border-control/component.js +1 -0
- package/build/border-control/border-control/component.js.map +1 -1
- package/build/border-control/styles.js +16 -16
- package/build/border-control/styles.js.map +1 -1
- package/build/box-control/linked-button.js +3 -4
- package/build/box-control/linked-button.js.map +1 -1
- package/build/color-palette/index.js +2 -7
- package/build/color-palette/index.js.map +1 -1
- package/build/color-picker/input-with-slider.js +1 -0
- package/build/color-picker/input-with-slider.js.map +1 -1
- package/build/color-picker/styles.js +8 -8
- package/build/color-picker/styles.js.map +1 -1
- package/build/custom-select-control/index.js +14 -2
- package/build/custom-select-control/index.js.map +1 -1
- package/build/dashicon/index.js +1 -4
- package/build/dashicon/index.js.map +1 -1
- package/build/date-time/date-time/index.js +4 -4
- package/build/date-time/date-time/index.js.map +1 -1
- package/build/duotone-picker/duotone-picker.js +2 -2
- package/build/duotone-picker/duotone-picker.js.map +1 -1
- package/build/gradient-picker/index.js +3 -9
- package/build/gradient-picker/index.js.map +1 -1
- package/build/higher-order/with-fallback-styles/index.js +2 -2
- package/build/higher-order/with-fallback-styles/index.js.map +1 -1
- package/build/index.js +13 -1
- package/build/index.js.map +1 -1
- package/build/input-control/index.js +17 -5
- package/build/input-control/index.js.map +1 -1
- package/build/input-control/input-base.js +2 -0
- package/build/input-control/input-base.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/switch-cell.native.js +1 -3
- package/build/mobile/bottom-sheet/switch-cell.native.js.map +1 -1
- package/build/mobile/global-styles-context/index.native.js +8 -8
- package/build/mobile/global-styles-context/index.native.js.map +1 -1
- package/build/mobile/keyboard-aware-flat-list/index.ios.js +4 -2
- package/build/mobile/keyboard-aware-flat-list/index.ios.js.map +1 -1
- package/build/modal/index.js +8 -0
- package/build/modal/index.js.map +1 -1
- package/build/navigator/navigator-provider/component.js +12 -8
- package/build/navigator/navigator-provider/component.js.map +1 -1
- package/build/number-control/styles/number-control-styles.js +8 -8
- package/build/number-control/styles/number-control-styles.js.map +1 -1
- package/build/palette-edit/index.js +72 -33
- package/build/palette-edit/index.js.map +1 -1
- package/build/popover/index.js +10 -2
- package/build/popover/index.js.map +1 -1
- package/build/query-controls/index.js +1 -0
- package/build/query-controls/index.js.map +1 -1
- package/build/snackbar/index.js +35 -24
- package/build/snackbar/index.js.map +1 -1
- package/build/snackbar/list.js +14 -19
- package/build/snackbar/list.js.map +1 -1
- package/build/snackbar/types.js +6 -0
- package/build/snackbar/types.js.map +1 -0
- package/build/tab-panel/index.js +10 -5
- package/build/tab-panel/index.js.map +1 -1
- package/build/theme/color-algorithms.js +118 -0
- package/build/theme/color-algorithms.js.map +1 -0
- package/build/theme/index.js +21 -18
- package/build/theme/index.js.map +1 -1
- package/build/theme/styles.js +10 -7
- package/build/theme/styles.js.map +1 -1
- package/build/toggle-control/index.js +5 -2
- package/build/toggle-control/index.js.map +1 -1
- package/build/ui/context/context-system-provider.js +3 -1
- package/build/ui/context/context-system-provider.js.map +1 -1
- package/build/unit-control/index.js +5 -2
- package/build/unit-control/index.js.map +1 -1
- package/build/utils/colors-values.js +1 -1
- package/build/utils/colors-values.js.map +1 -1
- package/build/utils/config-values.js +0 -2
- package/build/utils/config-values.js.map +1 -1
- package/build/utils/hooks/use-controlled-value.js.map +1 -1
- package/build-module/alignment-matrix-control/cell.js.map +1 -1
- package/build-module/alignment-matrix-control/icon.js +4 -2
- package/build-module/alignment-matrix-control/icon.js.map +1 -1
- package/build-module/alignment-matrix-control/index.js +23 -1
- package/build-module/alignment-matrix-control/index.js.map +1 -1
- package/build-module/alignment-matrix-control/styles/alignment-matrix-control-icon-styles.js +13 -13
- package/build-module/alignment-matrix-control/styles/alignment-matrix-control-icon-styles.js.map +1 -1
- package/build-module/alignment-matrix-control/styles/alignment-matrix-control-styles.js +16 -16
- package/build-module/alignment-matrix-control/styles/alignment-matrix-control-styles.js.map +1 -1
- package/build-module/alignment-matrix-control/types.js +2 -0
- package/build-module/alignment-matrix-control/types.js.map +1 -0
- package/build-module/alignment-matrix-control/utils.js +13 -8
- package/build-module/alignment-matrix-control/utils.js.map +1 -1
- package/build-module/angle-picker-control/styles/angle-picker-control-styles.js +9 -9
- package/build-module/angle-picker-control/styles/angle-picker-control-styles.js.map +1 -1
- package/build-module/autocomplete/index.js +38 -9
- package/build-module/autocomplete/index.js.map +1 -1
- package/build-module/base-control/hooks.js +41 -0
- package/build-module/base-control/hooks.js.map +1 -0
- package/build-module/base-control/index.js +18 -8
- package/build-module/base-control/index.js.map +1 -1
- package/build-module/base-field/hook.js +0 -14
- package/build-module/base-field/hook.js.map +1 -1
- package/build-module/base-field/index.js.map +1 -1
- package/build-module/base-field/styles.js +5 -5
- package/build-module/base-field/styles.js.map +1 -1
- package/build-module/base-field/types.js +2 -0
- package/build-module/base-field/types.js.map +1 -0
- package/build-module/border-control/border-control/component.js +1 -0
- package/build-module/border-control/border-control/component.js.map +1 -1
- package/build-module/border-control/styles.js +17 -17
- package/build-module/border-control/styles.js.map +1 -1
- package/build-module/box-control/linked-button.js +3 -4
- package/build-module/box-control/linked-button.js.map +1 -1
- package/build-module/color-palette/index.js +2 -7
- package/build-module/color-palette/index.js.map +1 -1
- package/build-module/color-picker/input-with-slider.js +1 -0
- package/build-module/color-picker/input-with-slider.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/custom-select-control/index.js +14 -2
- package/build-module/custom-select-control/index.js.map +1 -1
- package/build-module/dashicon/index.js +1 -4
- package/build-module/dashicon/index.js.map +1 -1
- package/build-module/date-time/date-time/index.js +4 -4
- package/build-module/date-time/date-time/index.js.map +1 -1
- package/build-module/duotone-picker/duotone-picker.js +2 -2
- package/build-module/duotone-picker/duotone-picker.js.map +1 -1
- package/build-module/gradient-picker/index.js +3 -8
- package/build-module/gradient-picker/index.js.map +1 -1
- package/build-module/higher-order/with-fallback-styles/index.js +2 -2
- package/build-module/higher-order/with-fallback-styles/index.js.map +1 -1
- package/build-module/index.js +2 -2
- package/build-module/index.js.map +1 -1
- package/build-module/input-control/index.js +16 -5
- package/build-module/input-control/index.js.map +1 -1
- package/build-module/input-control/input-base.js +2 -0
- package/build-module/input-control/input-base.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/switch-cell.native.js +1 -2
- package/build-module/mobile/bottom-sheet/switch-cell.native.js.map +1 -1
- package/build-module/mobile/global-styles-context/index.native.js +8 -7
- package/build-module/mobile/global-styles-context/index.native.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/modal/index.js +8 -0
- package/build-module/modal/index.js.map +1 -1
- package/build-module/navigator/navigator-provider/component.js +12 -8
- package/build-module/navigator/navigator-provider/component.js.map +1 -1
- package/build-module/number-control/styles/number-control-styles.js +8 -10
- package/build-module/number-control/styles/number-control-styles.js.map +1 -1
- package/build-module/palette-edit/index.js +73 -34
- package/build-module/palette-edit/index.js.map +1 -1
- package/build-module/popover/index.js +10 -2
- package/build-module/popover/index.js.map +1 -1
- package/build-module/query-controls/index.js +1 -0
- package/build-module/query-controls/index.js.map +1 -1
- package/build-module/snackbar/index.js +33 -23
- package/build-module/snackbar/index.js.map +1 -1
- package/build-module/snackbar/list.js +14 -22
- package/build-module/snackbar/list.js.map +1 -1
- package/build-module/snackbar/types.js +2 -0
- package/build-module/snackbar/types.js.map +1 -0
- package/build-module/tab-panel/index.js +10 -5
- package/build-module/tab-panel/index.js.map +1 -1
- package/build-module/theme/color-algorithms.js +105 -0
- package/build-module/theme/color-algorithms.js.map +1 -0
- package/build-module/theme/index.js +21 -17
- package/build-module/theme/index.js.map +1 -1
- package/build-module/theme/styles.js +8 -6
- package/build-module/theme/styles.js.map +1 -1
- package/build-module/toggle-control/index.js +4 -2
- package/build-module/toggle-control/index.js.map +1 -1
- package/build-module/ui/context/context-system-provider.js +3 -2
- package/build-module/ui/context/context-system-provider.js.map +1 -1
- package/build-module/unit-control/index.js +5 -2
- package/build-module/unit-control/index.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-module/utils/config-values.js +0 -2
- package/build-module/utils/config-values.js.map +1 -1
- package/build-module/utils/hooks/use-controlled-value.js.map +1 -1
- package/build-style/style-rtl.css +92 -75
- package/build-style/style.css +92 -75
- package/build-types/alignment-matrix-control/cell.d.ts +5 -0
- package/build-types/alignment-matrix-control/cell.d.ts.map +1 -0
- package/build-types/alignment-matrix-control/icon.d.ts +6 -0
- package/build-types/alignment-matrix-control/icon.d.ts.map +1 -0
- package/build-types/alignment-matrix-control/index.d.ts +30 -0
- package/build-types/alignment-matrix-control/index.d.ts.map +1 -0
- package/build-types/alignment-matrix-control/stories/index.d.ts +14 -0
- package/build-types/alignment-matrix-control/stories/index.d.ts.map +1 -0
- package/build-types/alignment-matrix-control/styles/alignment-matrix-control-icon-styles.d.ts +19 -0
- package/build-types/alignment-matrix-control/styles/alignment-matrix-control-icon-styles.d.ts.map +1 -0
- package/build-types/alignment-matrix-control/styles/alignment-matrix-control-styles.d.ts +23 -0
- package/build-types/alignment-matrix-control/styles/alignment-matrix-control-styles.d.ts.map +1 -0
- package/build-types/alignment-matrix-control/test/index.d.ts +2 -0
- package/build-types/alignment-matrix-control/test/index.d.ts.map +1 -0
- package/build-types/alignment-matrix-control/types.d.ts +39 -0
- package/build-types/alignment-matrix-control/types.d.ts.map +1 -0
- package/build-types/alignment-matrix-control/utils.d.ts +33 -0
- package/build-types/alignment-matrix-control/utils.d.ts.map +1 -0
- package/build-types/base-control/hooks.d.ts +23 -0
- package/build-types/base-control/hooks.d.ts.map +1 -0
- package/build-types/base-control/index.d.ts +17 -7
- package/build-types/base-control/index.d.ts.map +1 -1
- package/build-types/base-control/stories/index.d.ts.map +1 -1
- package/build-types/base-control/test/index.d.ts +2 -0
- package/build-types/base-control/test/index.d.ts.map +1 -0
- package/build-types/base-control/types.d.ts +8 -2
- package/build-types/base-control/types.d.ts.map +1 -1
- package/build-types/base-field/hook.d.ts +7 -31
- package/build-types/base-field/hook.d.ts.map +1 -1
- package/build-types/base-field/index.d.ts +1 -1
- package/build-types/base-field/index.d.ts.map +1 -1
- package/build-types/base-field/styles.d.ts +5 -5
- package/build-types/base-field/styles.d.ts.map +1 -1
- package/build-types/base-field/test/index.d.ts +2 -0
- package/build-types/base-field/test/index.d.ts.map +1 -0
- package/build-types/base-field/types.d.ts +29 -0
- package/build-types/base-field/types.d.ts.map +1 -0
- package/build-types/border-box-control/border-box-control/hook.d.ts +2 -2
- package/build-types/border-box-control/border-box-control-linked-button/hook.d.ts +2 -2
- package/build-types/border-box-control/border-box-control-split-controls/hook.d.ts +2 -2
- package/build-types/border-box-control/border-box-control-visualizer/hook.d.ts +2 -2
- package/build-types/border-control/border-control/component.d.ts.map +1 -1
- package/build-types/border-control/border-control/hook.d.ts +2 -2
- package/build-types/border-control/border-control-dropdown/hook.d.ts +2 -2
- package/build-types/border-control/border-control-style-picker/hook.d.ts +2 -2
- package/build-types/border-control/styles.d.ts.map +1 -1
- package/build-types/card/card/hook.d.ts +2 -2
- package/build-types/card/card-body/hook.d.ts +2 -2
- package/build-types/card/card-divider/hook.d.ts +2 -2
- package/build-types/card/card-footer/hook.d.ts +2 -2
- package/build-types/card/card-header/hook.d.ts +2 -2
- package/build-types/card/card-media/hook.d.ts +2 -2
- package/build-types/color-palette/index.d.ts +2 -2
- package/build-types/color-palette/index.d.ts.map +1 -1
- package/build-types/color-palette/stories/index.d.ts +6 -7
- package/build-types/color-palette/stories/index.d.ts.map +1 -1
- package/build-types/color-palette/styles.d.ts +1 -1
- package/build-types/color-palette/types.d.ts +1 -1
- package/build-types/color-palette/types.d.ts.map +1 -1
- package/build-types/color-picker/input-with-slider.d.ts.map +1 -1
- package/build-types/color-picker/styles.d.ts +5 -5
- package/build-types/color-picker/styles.d.ts.map +1 -1
- package/build-types/custom-select-control/index.d.ts.map +1 -1
- package/build-types/dashicon/index.d.ts +6 -20
- package/build-types/dashicon/index.d.ts.map +1 -1
- package/build-types/dashicon/types.d.ts +14 -0
- package/build-types/dashicon/types.d.ts.map +1 -1
- package/build-types/date-time/date/styles.d.ts +3 -3
- package/build-types/date-time/date-time/styles.d.ts +3 -3
- package/build-types/date-time/time/styles.d.ts +8 -8
- package/build-types/elevation/hook.d.ts +2 -2
- package/build-types/external-link/styles/external-link-styles.d.ts +1 -1
- package/build-types/flex/flex/hook.d.ts +2 -2
- package/build-types/flex/flex-block/hook.d.ts +2 -2
- package/build-types/flex/flex-item/hook.d.ts +2 -2
- package/build-types/focal-point-picker/styles/focal-point-picker-style.d.ts +2 -5
- package/build-types/focal-point-picker/styles/focal-point-picker-style.d.ts.map +1 -1
- package/build-types/grid/hook.d.ts +2 -2
- package/build-types/h-stack/component.d.ts +1 -1
- package/build-types/h-stack/hook.d.ts +2 -2
- package/build-types/heading/hook.d.ts +2 -2
- 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-base.d.ts.map +1 -1
- package/build-types/input-control/stories/index.d.ts +1 -0
- package/build-types/input-control/stories/index.d.ts.map +1 -1
- package/build-types/input-control/types.d.ts +2 -1
- package/build-types/input-control/types.d.ts.map +1 -1
- package/build-types/item-group/item/hook.d.ts +2 -2
- package/build-types/item-group/item-group/hook.d.ts +2 -2
- package/build-types/modal/index.d.ts.map +1 -1
- package/build-types/modal/stories/index.d.ts.map +1 -1
- package/build-types/navigator/navigator-back-button/hook.d.ts +3 -3
- package/build-types/navigator/navigator-button/hook.d.ts +3 -3
- package/build-types/navigator/navigator-provider/component.d.ts.map +1 -1
- package/build-types/number-control/index.d.ts +2 -2
- package/build-types/number-control/index.d.ts.map +1 -1
- package/build-types/number-control/stories/index.d.ts +25 -0
- package/build-types/number-control/stories/index.d.ts.map +1 -0
- package/build-types/number-control/styles/number-control-styles.d.ts +6 -6
- package/build-types/number-control/styles/number-control-styles.d.ts.map +1 -1
- package/build-types/number-control/test/index.d.ts +2 -0
- package/build-types/number-control/test/index.d.ts.map +1 -0
- package/build-types/popover/index.d.ts +1 -1
- package/build-types/popover/index.d.ts.map +1 -1
- package/build-types/popover/stories/e2e/index.d.ts +1 -1
- package/build-types/range-control/index.d.ts +1 -1
- package/build-types/range-control/styles/range-control-styles.d.ts +2 -2
- package/build-types/resizable-box/resize-tooltip/index.d.ts +15 -19
- package/build-types/resizable-box/resize-tooltip/index.d.ts.map +1 -1
- package/build-types/resizable-box/resize-tooltip/label.d.ts +4 -3
- package/build-types/resizable-box/resize-tooltip/label.d.ts.map +1 -1
- package/build-types/scrollable/hook.d.ts +2 -2
- package/build-types/search-control/index.d.ts +1 -1
- package/build-types/search-control/stories/index.d.ts +2 -2
- package/build-types/snackbar/index.d.ts +19 -0
- package/build-types/snackbar/index.d.ts.map +1 -0
- package/build-types/snackbar/list.d.ts +18 -0
- package/build-types/snackbar/list.d.ts.map +1 -0
- package/build-types/snackbar/stories/index.d.ts +16 -0
- package/build-types/snackbar/stories/index.d.ts.map +1 -0
- package/build-types/snackbar/stories/list.d.ts +12 -0
- package/build-types/snackbar/stories/list.d.ts.map +1 -0
- package/build-types/snackbar/types.d.ts +111 -0
- package/build-types/snackbar/types.d.ts.map +1 -0
- package/build-types/spacer/hook.d.ts +2 -2
- package/build-types/spinner/index.d.ts +1 -1
- package/build-types/surface/hook.d.ts +2 -2
- package/build-types/tab-panel/index.d.ts +1 -1
- package/build-types/tab-panel/index.d.ts.map +1 -1
- package/build-types/tab-panel/types.d.ts +19 -1
- package/build-types/tab-panel/types.d.ts.map +1 -1
- package/build-types/text/hook.d.ts +2 -2
- package/build-types/text-control/index.d.ts +2 -2
- package/build-types/text-control/stories/index.d.ts.map +1 -1
- package/build-types/text-control/types.d.ts +1 -5
- package/build-types/text-control/types.d.ts.map +1 -1
- package/build-types/theme/color-algorithms.d.ts +20 -0
- package/build-types/theme/color-algorithms.d.ts.map +1 -0
- package/build-types/theme/index.d.ts +1 -1
- package/build-types/theme/index.d.ts.map +1 -1
- package/build-types/theme/stories/index.d.ts +4 -0
- package/build-types/theme/stories/index.d.ts.map +1 -1
- package/build-types/theme/styles.d.ts +3 -2
- package/build-types/theme/styles.d.ts.map +1 -1
- package/build-types/theme/test/color-algorithms.d.ts +2 -0
- package/build-types/theme/test/color-algorithms.d.ts.map +1 -0
- package/build-types/theme/types.d.ts +41 -3
- package/build-types/theme/types.d.ts.map +1 -1
- package/build-types/toggle-control/index.d.ts.map +1 -1
- package/build-types/toggle-group-control/toggle-group-control/as-button-group.d.ts +2 -2
- package/build-types/toggle-group-control/toggle-group-control/as-radio-group.d.ts +2 -2
- package/build-types/toggle-group-control/toggle-group-control-option/component.d.ts +1 -1
- package/build-types/toggle-group-control/toggle-group-control-option-icon/component.d.ts +1 -1
- package/build-types/tools-panel/tools-panel/hook.d.ts +2 -2
- package/build-types/tools-panel/tools-panel-header/hook.d.ts +2 -2
- package/build-types/tools-panel/tools-panel-item/hook.d.ts +2 -2
- package/build-types/truncate/hook.d.ts +2 -2
- package/build-types/ui/context/context-system-provider.d.ts.map +1 -1
- package/build-types/ui/control-group/hook.d.ts +2 -2
- package/build-types/ui/control-label/hook.d.ts +2 -2
- package/build-types/ui/form-group/form-group.d.ts +2 -2
- package/build-types/ui/form-group/use-form-group.d.ts +5 -5
- package/build-types/unit-control/index.d.ts +2 -1
- package/build-types/unit-control/index.d.ts.map +1 -1
- package/build-types/unit-control/styles/unit-control-styles.d.ts +2 -2
- package/build-types/unit-control/types.d.ts +4 -0
- package/build-types/unit-control/types.d.ts.map +1 -1
- package/build-types/utils/config-values.d.ts +0 -2
- package/build-types/utils/hooks/use-controlled-value.d.ts +2 -1
- package/build-types/utils/hooks/use-controlled-value.d.ts.map +1 -1
- package/build-types/v-stack/component.d.ts +2 -2
- package/build-types/v-stack/hook.d.ts +2 -2
- package/build-types/v-stack/stories/index.d.ts +2 -2
- package/package.json +21 -20
- package/src/alignment-matrix-control/README.md +7 -7
- package/src/alignment-matrix-control/{cell.js → cell.tsx} +7 -1
- package/src/alignment-matrix-control/{icon.js → icon.tsx} +6 -3
- package/src/alignment-matrix-control/{index.js → index.tsx} +31 -4
- package/src/alignment-matrix-control/stories/{index.js → index.tsx} +17 -9
- package/src/alignment-matrix-control/styles/{alignment-matrix-control-icon-styles.js → alignment-matrix-control-icon-styles.ts} +11 -3
- package/src/alignment-matrix-control/styles/{alignment-matrix-control-styles.js → alignment-matrix-control-styles.ts} +13 -3
- package/src/alignment-matrix-control/test/{index.js → index.tsx} +5 -5
- package/src/alignment-matrix-control/types.ts +54 -0
- package/src/alignment-matrix-control/{utils.js → utils.tsx} +24 -14
- package/src/angle-picker-control/styles/angle-picker-control-styles.js +4 -0
- package/src/autocomplete/index.js +43 -12
- package/src/base-control/README.md +21 -12
- package/src/base-control/hooks.ts +45 -0
- package/src/base-control/index.tsx +18 -7
- package/src/base-control/stories/index.tsx +8 -10
- package/src/base-control/test/index.tsx +52 -0
- package/src/base-control/types.ts +8 -2
- package/src/base-field/README.md +21 -22
- package/src/base-field/{hook.js → hook.ts} +5 -15
- package/src/base-field/{index.js → index.ts} +0 -0
- package/src/base-field/{styles.js → styles.ts} +2 -2
- package/src/base-field/test/__snapshots__/{index.js.snap → index.tsx.snap} +4 -4
- package/src/base-field/test/{index.js → index.tsx} +10 -5
- package/src/base-field/types.ts +29 -0
- package/src/border-box-control/border-box-control/README.md +1 -0
- package/src/border-box-control/test/index.js +3 -1
- package/src/border-control/border-control/component.tsx +1 -0
- package/src/border-control/styles.ts +1 -10
- package/src/box-control/linked-button.js +8 -11
- package/src/box-control/test/index.js +206 -135
- package/src/button/stories/index.js +30 -0
- package/src/button/style.scss +17 -14
- package/src/button/test/index.js +32 -15
- package/src/card/test/index.tsx +32 -20
- package/src/circular-option-picker/style.scss +1 -0
- package/src/color-palette/index.tsx +4 -6
- package/src/color-palette/stories/index.tsx +1 -5
- package/src/color-palette/test/__snapshots__/index.tsx.snap +4 -4
- package/src/color-palette/test/index.tsx +84 -36
- package/src/color-palette/types.ts +1 -1
- package/src/color-picker/README.md +1 -0
- package/src/color-picker/input-with-slider.tsx +1 -0
- package/src/color-picker/styles.ts +0 -4
- package/src/confirm-dialog/README.md +3 -2
- package/src/custom-select-control/README.md +14 -0
- package/src/custom-select-control/index.js +14 -2
- package/src/dashicon/{index.js → index.tsx} +10 -4
- package/src/dashicon/types.ts +17 -0
- package/src/date-time/date-time/index.tsx +2 -2
- package/src/dimension-control/test/__snapshots__/index.test.js.snap +4 -8
- package/src/disabled/test/index.tsx +21 -11
- package/src/dropdown/test/index.js +39 -49
- package/src/dropdown-menu/test/index.js +18 -12
- package/src/duotone-picker/duotone-picker.js +2 -2
- package/src/focal-point-picker/test/media.js +26 -21
- package/src/form-token-field/style.scss +1 -1
- package/src/gradient-picker/index.js +5 -8
- package/src/grid/test/grid.tsx +31 -31
- package/src/higher-order/navigate-regions/style.scss +2 -22
- package/src/higher-order/with-fallback-styles/index.js +4 -2
- package/src/higher-order/with-filters/test/index.js +94 -101
- package/src/higher-order/with-focus-return/test/index.js +1 -4
- package/src/index.js +2 -2
- package/src/input-control/index.tsx +42 -28
- package/src/input-control/input-base.tsx +8 -1
- package/src/input-control/stories/index.tsx +6 -0
- package/src/input-control/test/index.js +18 -0
- package/src/input-control/types.ts +2 -0
- package/src/mobile/bottom-sheet/cell.native.js +1 -1
- package/src/mobile/bottom-sheet/switch-cell.native.js +2 -2
- package/src/mobile/global-styles-context/index.native.js +9 -11
- package/src/mobile/keyboard-aware-flat-list/index.ios.js +2 -2
- package/src/mobile/link-settings/test/edit.native.js +68 -124
- package/src/modal/index.tsx +11 -0
- package/src/modal/stories/index.tsx +3 -0
- package/src/modal/test/index.tsx +15 -0
- package/src/navigation/stories/index.js +6 -6
- package/src/navigation/stories/{controlled-state.js → utils/controlled-state.js} +3 -3
- package/src/navigation/stories/{default.js → utils/default.js} +3 -3
- package/src/navigation/stories/{group.js → utils/group.js} +4 -4
- package/src/navigation/stories/{hide-if-empty.js → utils/hide-if-empty.js} +3 -3
- package/src/navigation/stories/{more-examples.js → utils/more-examples.js} +4 -4
- package/src/navigation/stories/{search.js → utils/search.js} +5 -5
- package/src/navigator/navigator-provider/component.tsx +13 -10
- package/src/notice/test/list.js +8 -5
- package/src/number-control/stories/{index.js → index.tsx} +24 -7
- package/src/number-control/styles/{number-control-styles.js → number-control-styles.ts} +5 -3
- package/src/number-control/test/index.tsx +600 -0
- package/src/palette-edit/index.js +88 -39
- package/src/palette-edit/test/index.js +25 -1
- package/src/popover/index.tsx +10 -2
- package/src/popover/style.scss +12 -11
- package/src/popover/test/index.tsx +25 -15
- package/src/query-controls/index.js +1 -0
- package/src/range-control/test/index.tsx +57 -60
- package/src/resizable-box/style.scss +1 -0
- package/src/sandbox/test/index.js +13 -11
- package/src/search-control/style.scss +4 -0
- package/src/snackbar/README.md +63 -8
- package/src/snackbar/{index.js → index.tsx} +46 -28
- package/src/snackbar/{list.js → list.tsx} +20 -21
- package/src/snackbar/stories/index.tsx +96 -0
- package/src/snackbar/stories/list.tsx +98 -0
- package/src/snackbar/types.ts +116 -0
- package/src/tab-panel/README.md +9 -0
- package/src/tab-panel/index.tsx +14 -3
- package/src/tab-panel/style.scss +46 -34
- package/src/tab-panel/test/index.tsx +111 -0
- package/src/tab-panel/types.ts +20 -1
- package/src/text/test/__snapshots__/index.tsx.snap +1 -0
- package/src/text/test/index.tsx +98 -46
- package/src/text-control/stories/index.tsx +0 -1
- package/src/text-control/types.ts +1 -6
- package/src/theme/README.md +32 -2
- package/src/theme/color-algorithms.ts +138 -0
- package/src/theme/index.tsx +23 -16
- package/src/theme/stories/index.tsx +67 -0
- package/src/theme/styles.ts +22 -17
- package/src/theme/test/color-algorithms.ts +100 -0
- package/src/theme/test/index.tsx +68 -35
- package/src/theme/types.ts +43 -3
- package/src/toggle-control/index.tsx +4 -2
- package/src/toggle-group-control/test/index.tsx +13 -2
- package/src/toolbar-group/test/index.js +8 -6
- package/src/tools-panel/stories/index.js +1 -1
- package/src/tools-panel/stories/{tools-panel-with-item-group-slot.js → utils/tools-panel-with-item-group-slot.js} +14 -11
- package/src/tools-panel/test/index.js +20 -14
- package/src/tooltip/README.md +7 -0
- package/src/tooltip/style.scss +2 -2
- package/src/tooltip/test/index.js +109 -18
- package/src/ui/context/context-system-provider.js +3 -2
- package/src/ui/context/test/context-system-provider.js +5 -4
- package/src/ui/control-label/test/index.js +3 -5
- package/src/unit-control/README.md +9 -1
- package/src/unit-control/index.tsx +3 -0
- package/src/unit-control/test/index.tsx +1 -0
- package/src/unit-control/types.ts +4 -0
- package/src/utils/colors-values.js +1 -1
- package/src/utils/config-values.js +0 -2
- package/src/utils/hooks/use-controlled-value.ts +2 -2
- package/src/utils/theme-variables.scss +20 -0
- package/tsconfig.json +2 -4
- package/tsconfig.tsbuildinfo +1 -1
- package/src/number-control/test/index.js +0 -478
- package/src/snackbar/stories/index.js +0 -89
|
@@ -12,6 +12,10 @@ import {
|
|
|
12
12
|
pointBase,
|
|
13
13
|
Cell as CellBase,
|
|
14
14
|
} from './alignment-matrix-control-styles';
|
|
15
|
+
import type {
|
|
16
|
+
AlignmentMatrixControlIconProps,
|
|
17
|
+
AlignmentMatrixControlCellProps,
|
|
18
|
+
} from '../types';
|
|
15
19
|
|
|
16
20
|
const rootSize = () => {
|
|
17
21
|
const padding = 1.5;
|
|
@@ -25,9 +29,11 @@ const rootSize = () => {
|
|
|
25
29
|
} );
|
|
26
30
|
};
|
|
27
31
|
|
|
28
|
-
const rootPointerEvents = ( {
|
|
32
|
+
const rootPointerEvents = ( {
|
|
33
|
+
disablePointerEvents,
|
|
34
|
+
}: Pick< AlignmentMatrixControlIconProps, 'disablePointerEvents' > ) => {
|
|
29
35
|
return css( {
|
|
30
|
-
pointerEvents: disablePointerEvents ? 'none' :
|
|
36
|
+
pointerEvents: disablePointerEvents ? 'none' : undefined,
|
|
31
37
|
} );
|
|
32
38
|
};
|
|
33
39
|
|
|
@@ -46,7 +52,9 @@ export const Root = styled.div`
|
|
|
46
52
|
${ rootPointerEvents };
|
|
47
53
|
`;
|
|
48
54
|
|
|
49
|
-
const pointActive = ( {
|
|
55
|
+
const pointActive = ( {
|
|
56
|
+
isActive,
|
|
57
|
+
}: Pick< AlignmentMatrixControlCellProps, 'isActive' > ) => {
|
|
50
58
|
const boxShadow = isActive ? `0 0 0 1px currentColor` : null;
|
|
51
59
|
|
|
52
60
|
return css`
|
|
@@ -8,6 +8,10 @@ import { css } from '@emotion/react';
|
|
|
8
8
|
* Internal dependencies
|
|
9
9
|
*/
|
|
10
10
|
import { COLORS, reduceMotion } from '../../utils';
|
|
11
|
+
import type {
|
|
12
|
+
AlignmentMatrixControlProps,
|
|
13
|
+
AlignmentMatrixControlCellProps,
|
|
14
|
+
} from '../types';
|
|
11
15
|
|
|
12
16
|
export const rootBase = () => {
|
|
13
17
|
return css`
|
|
@@ -27,7 +31,9 @@ const rootSize = ( { size = 92 } ) => {
|
|
|
27
31
|
`;
|
|
28
32
|
};
|
|
29
33
|
|
|
30
|
-
export const Root = styled.div
|
|
34
|
+
export const Root = styled.div< {
|
|
35
|
+
size: AlignmentMatrixControlProps[ 'width' ];
|
|
36
|
+
} >`
|
|
31
37
|
${ rootBase };
|
|
32
38
|
|
|
33
39
|
border: 1px solid transparent;
|
|
@@ -43,7 +49,9 @@ export const Row = styled.div`
|
|
|
43
49
|
grid-template-columns: repeat( 3, 1fr );
|
|
44
50
|
`;
|
|
45
51
|
|
|
46
|
-
const pointActive = ( {
|
|
52
|
+
const pointActive = ( {
|
|
53
|
+
isActive,
|
|
54
|
+
}: Pick< AlignmentMatrixControlCellProps, 'isActive' > ) => {
|
|
47
55
|
const boxShadow = isActive ? `0 0 0 2px ${ COLORS.gray[ 900 ] }` : null;
|
|
48
56
|
const pointColor = isActive ? COLORS.gray[ 900 ] : COLORS.gray[ 400 ];
|
|
49
57
|
const pointColorHover = isActive ? COLORS.gray[ 900 ] : COLORS.ui.theme;
|
|
@@ -58,7 +66,9 @@ const pointActive = ( { isActive } ) => {
|
|
|
58
66
|
`;
|
|
59
67
|
};
|
|
60
68
|
|
|
61
|
-
export const pointBase = (
|
|
69
|
+
export const pointBase = (
|
|
70
|
+
props: Pick< AlignmentMatrixControlCellProps, 'isActive' >
|
|
71
|
+
) => {
|
|
62
72
|
return css`
|
|
63
73
|
background: currentColor;
|
|
64
74
|
box-sizing: border-box;
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { render, screen, within } from '@testing-library/react';
|
|
4
|
+
import { act, render, screen, within } from '@testing-library/react';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Internal dependencies
|
|
8
8
|
*/
|
|
9
|
-
import AlignmentMatrixControl from '
|
|
9
|
+
import AlignmentMatrixControl from '..';
|
|
10
10
|
|
|
11
11
|
const getControl = () => {
|
|
12
12
|
return screen.getByRole( 'grid' );
|
|
13
13
|
};
|
|
14
14
|
|
|
15
|
-
const getCell = ( name ) => {
|
|
15
|
+
const getCell = ( name: string ) => {
|
|
16
16
|
return within( getControl() ).getByRole( 'gridcell', { name } );
|
|
17
17
|
};
|
|
18
18
|
|
|
@@ -30,14 +30,14 @@ describe( 'AlignmentMatrixControl', () => {
|
|
|
30
30
|
|
|
31
31
|
it.each( alignments )(
|
|
32
32
|
'should change value on %s cell click',
|
|
33
|
-
( alignment ) => {
|
|
33
|
+
async ( alignment ) => {
|
|
34
34
|
const spy = jest.fn();
|
|
35
35
|
|
|
36
36
|
render(
|
|
37
37
|
<AlignmentMatrixControl value="center" onChange={ spy } />
|
|
38
38
|
);
|
|
39
39
|
|
|
40
|
-
getCell( alignment ).focus();
|
|
40
|
+
await act( () => getCell( alignment ).focus() );
|
|
41
41
|
|
|
42
42
|
expect( spy ).toHaveBeenCalledWith( alignment );
|
|
43
43
|
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
export type AlignmentMatrixControlValue =
|
|
2
|
+
| 'top left'
|
|
3
|
+
| 'top center'
|
|
4
|
+
| 'top right'
|
|
5
|
+
| 'center left'
|
|
6
|
+
| 'center'
|
|
7
|
+
| 'center center'
|
|
8
|
+
| 'center right'
|
|
9
|
+
| 'bottom left'
|
|
10
|
+
| 'bottom center'
|
|
11
|
+
| 'bottom right';
|
|
12
|
+
|
|
13
|
+
export type AlignmentMatrixControlProps = {
|
|
14
|
+
/**
|
|
15
|
+
* Accessible label. If provided, sets the `aria-label` attribute of the
|
|
16
|
+
* underlying `grid` widget.
|
|
17
|
+
*
|
|
18
|
+
* @default 'Alignment Matrix Control'
|
|
19
|
+
*/
|
|
20
|
+
label?: string;
|
|
21
|
+
/**
|
|
22
|
+
* If provided, sets the default alignment value.
|
|
23
|
+
*
|
|
24
|
+
* @default 'center center'
|
|
25
|
+
*/
|
|
26
|
+
defaultValue?: AlignmentMatrixControlValue;
|
|
27
|
+
/**
|
|
28
|
+
* The current alignment value.
|
|
29
|
+
*/
|
|
30
|
+
value?: AlignmentMatrixControlValue;
|
|
31
|
+
/**
|
|
32
|
+
* A function that receives the updated alignment value.
|
|
33
|
+
*/
|
|
34
|
+
onChange?: ( newValue: AlignmentMatrixControlValue ) => void;
|
|
35
|
+
/**
|
|
36
|
+
* If provided, sets the width of the control.
|
|
37
|
+
*
|
|
38
|
+
* @default 92
|
|
39
|
+
*/
|
|
40
|
+
width?: number;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export type AlignmentMatrixControlIconProps = Pick<
|
|
44
|
+
AlignmentMatrixControlProps,
|
|
45
|
+
'value'
|
|
46
|
+
> & {
|
|
47
|
+
disablePointerEvents?: boolean;
|
|
48
|
+
size?: number;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export type AlignmentMatrixControlCellProps = {
|
|
52
|
+
isActive?: boolean;
|
|
53
|
+
value: NonNullable< AlignmentMatrixControlProps[ 'value' ] >;
|
|
54
|
+
};
|
|
@@ -2,20 +2,25 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { __ } from '@wordpress/i18n';
|
|
5
|
+
/**
|
|
6
|
+
* Internal dependencies
|
|
7
|
+
*/
|
|
8
|
+
import type { AlignmentMatrixControlValue } from './types';
|
|
5
9
|
|
|
6
|
-
export const GRID = [
|
|
10
|
+
export const GRID: AlignmentMatrixControlValue[][] = [
|
|
7
11
|
[ 'top left', 'top center', 'top right' ],
|
|
8
12
|
[ 'center left', 'center center', 'center right' ],
|
|
9
13
|
[ 'bottom left', 'bottom center', 'bottom right' ],
|
|
10
14
|
];
|
|
11
15
|
|
|
12
16
|
// Stored as map as i18n __() only accepts strings (not variables)
|
|
13
|
-
export const ALIGNMENT_LABEL = {
|
|
17
|
+
export const ALIGNMENT_LABEL: Record< AlignmentMatrixControlValue, string > = {
|
|
14
18
|
'top left': __( 'Top Left' ),
|
|
15
19
|
'top center': __( 'Top Center' ),
|
|
16
20
|
'top right': __( 'Top Right' ),
|
|
17
21
|
'center left': __( 'Center Left' ),
|
|
18
22
|
'center center': __( 'Center Center' ),
|
|
23
|
+
center: __( 'Center Center' ),
|
|
19
24
|
'center right': __( 'Center Right' ),
|
|
20
25
|
'bottom left': __( 'Bottom Left' ),
|
|
21
26
|
'bottom center': __( 'Bottom Center' ),
|
|
@@ -28,25 +33,28 @@ export const ALIGNMENTS = GRID.flat();
|
|
|
28
33
|
/**
|
|
29
34
|
* Parses and transforms an incoming value to better match the alignment values
|
|
30
35
|
*
|
|
31
|
-
* @param
|
|
36
|
+
* @param value An alignment value to parse.
|
|
32
37
|
*
|
|
33
|
-
* @return
|
|
38
|
+
* @return The parsed value.
|
|
34
39
|
*/
|
|
35
|
-
export function transformValue( value ) {
|
|
40
|
+
export function transformValue( value: AlignmentMatrixControlValue ) {
|
|
36
41
|
const nextValue = value === 'center' ? 'center center' : value;
|
|
37
42
|
|
|
38
|
-
return nextValue.replace( '-', ' ' );
|
|
43
|
+
return nextValue.replace( '-', ' ' ) as AlignmentMatrixControlValue;
|
|
39
44
|
}
|
|
40
45
|
|
|
41
46
|
/**
|
|
42
47
|
* Creates an item ID based on a prefix ID and an alignment value.
|
|
43
48
|
*
|
|
44
|
-
* @param
|
|
45
|
-
* @param
|
|
49
|
+
* @param prefixId An ID to prefix.
|
|
50
|
+
* @param value An alignment value.
|
|
46
51
|
*
|
|
47
|
-
* @return
|
|
52
|
+
* @return The item id.
|
|
48
53
|
*/
|
|
49
|
-
export function getItemId(
|
|
54
|
+
export function getItemId(
|
|
55
|
+
prefixId: string,
|
|
56
|
+
value: AlignmentMatrixControlValue
|
|
57
|
+
) {
|
|
50
58
|
const valueId = transformValue( value ).replace( ' ', '-' );
|
|
51
59
|
|
|
52
60
|
return `${ prefixId }-${ valueId }`;
|
|
@@ -55,12 +63,14 @@ export function getItemId( prefixId, value ) {
|
|
|
55
63
|
/**
|
|
56
64
|
* Retrieves the alignment index from a value.
|
|
57
65
|
*
|
|
58
|
-
* @param
|
|
66
|
+
* @param alignment Value to check.
|
|
59
67
|
*
|
|
60
|
-
* @return
|
|
68
|
+
* @return The index of a matching alignment.
|
|
61
69
|
*/
|
|
62
|
-
export function getAlignmentIndex(
|
|
63
|
-
|
|
70
|
+
export function getAlignmentIndex(
|
|
71
|
+
alignment: AlignmentMatrixControlValue = 'center'
|
|
72
|
+
) {
|
|
73
|
+
const item = transformValue( alignment );
|
|
64
74
|
const index = ALIGNMENTS.indexOf( item );
|
|
65
75
|
|
|
66
76
|
return index > -1 ? index : undefined;
|
|
@@ -415,26 +415,57 @@ function useAutocomplete( {
|
|
|
415
415
|
}
|
|
416
416
|
|
|
417
417
|
export function useAutocompleteProps( options ) {
|
|
418
|
+
const [ isVisible, setIsVisible ] = useState( false );
|
|
418
419
|
const ref = useRef();
|
|
420
|
+
const recordAfterInput = useRef();
|
|
419
421
|
const onKeyDownRef = useRef();
|
|
420
422
|
const { popover, listBoxId, activeId, onKeyDown } = useAutocomplete( {
|
|
421
423
|
...options,
|
|
422
424
|
contentRef: ref,
|
|
423
425
|
} );
|
|
424
426
|
onKeyDownRef.current = onKeyDown;
|
|
427
|
+
|
|
428
|
+
useEffect( () => {
|
|
429
|
+
if ( isVisible ) {
|
|
430
|
+
if ( ! recordAfterInput.current ) {
|
|
431
|
+
recordAfterInput.current = options.record;
|
|
432
|
+
} else if (
|
|
433
|
+
recordAfterInput.current.start !== options.record.start ||
|
|
434
|
+
recordAfterInput.current.end !== options.record.end
|
|
435
|
+
) {
|
|
436
|
+
setIsVisible( false );
|
|
437
|
+
recordAfterInput.current = null;
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
441
|
+
}, [ options.record ] );
|
|
442
|
+
|
|
443
|
+
const mergedRefs = useMergeRefs( [
|
|
444
|
+
ref,
|
|
445
|
+
useRefEffect( ( element ) => {
|
|
446
|
+
function _onKeyDown( event ) {
|
|
447
|
+
onKeyDownRef.current( event );
|
|
448
|
+
}
|
|
449
|
+
function _onInput() {
|
|
450
|
+
// Only show auto complete UI if the user is inputting text.
|
|
451
|
+
setIsVisible( true );
|
|
452
|
+
recordAfterInput.current = null;
|
|
453
|
+
}
|
|
454
|
+
element.addEventListener( 'keydown', _onKeyDown );
|
|
455
|
+
element.addEventListener( 'input', _onInput );
|
|
456
|
+
return () => {
|
|
457
|
+
element.removeEventListener( 'keydown', _onKeyDown );
|
|
458
|
+
element.removeEventListener( 'input', _onInput );
|
|
459
|
+
};
|
|
460
|
+
}, [] ),
|
|
461
|
+
] );
|
|
462
|
+
|
|
463
|
+
if ( ! isVisible ) {
|
|
464
|
+
return { ref: mergedRefs };
|
|
465
|
+
}
|
|
466
|
+
|
|
425
467
|
return {
|
|
426
|
-
ref:
|
|
427
|
-
ref,
|
|
428
|
-
useRefEffect( ( element ) => {
|
|
429
|
-
function _onKeyDown( event ) {
|
|
430
|
-
onKeyDownRef.current( event );
|
|
431
|
-
}
|
|
432
|
-
element.addEventListener( 'keydown', _onKeyDown );
|
|
433
|
-
return () => {
|
|
434
|
-
element.removeEventListener( 'keydown', _onKeyDown );
|
|
435
|
-
};
|
|
436
|
-
}, [] ),
|
|
437
|
-
] ),
|
|
468
|
+
ref: mergedRefs,
|
|
438
469
|
children: popover,
|
|
439
470
|
'aria-autocomplete': listBoxId ? 'list' : undefined,
|
|
440
471
|
'aria-owns': listBoxId,
|
|
@@ -4,16 +4,23 @@
|
|
|
4
4
|
|
|
5
5
|
## Usage
|
|
6
6
|
|
|
7
|
-
Render a `BaseControl` for a textarea input:
|
|
8
|
-
|
|
9
7
|
```jsx
|
|
10
|
-
import { BaseControl } from '@wordpress/components';
|
|
11
|
-
|
|
12
|
-
//
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
8
|
+
import { BaseControl, useBaseControlProps } from '@wordpress/components';
|
|
9
|
+
|
|
10
|
+
// Render a `BaseControl` for a textarea input
|
|
11
|
+
const MyCustomTextareaControl = ({ children, ...baseProps }) => (
|
|
12
|
+
// `useBaseControlProps` is a convenience hook to get the props for the `BaseControl`
|
|
13
|
+
// and the inner control itself. Namely, it takes care of generating a unique `id`,
|
|
14
|
+
// properly associating it with the `label` and `help` elements.
|
|
15
|
+
const { baseControlProps, controlProps } = useBaseControlProps( baseProps );
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<BaseControl { ...baseControlProps } __nextHasNoMarginBottom={ true }>
|
|
19
|
+
<textarea { ...controlProps }>
|
|
20
|
+
{ children }
|
|
21
|
+
</textarea>
|
|
22
|
+
</BaseControl>
|
|
23
|
+
);
|
|
17
24
|
);
|
|
18
25
|
```
|
|
19
26
|
|
|
@@ -23,7 +30,9 @@ The component accepts the following props:
|
|
|
23
30
|
|
|
24
31
|
### id
|
|
25
32
|
|
|
26
|
-
The HTML `id` of the element (passed in as a child to `BaseControl`) to which labels and help text are being generated. This is necessary to accessibly associate the label with that element.
|
|
33
|
+
The HTML `id` of the control element (passed in as a child to `BaseControl`) to which labels and help text are being generated. This is necessary to accessibly associate the label with that element.
|
|
34
|
+
|
|
35
|
+
The recommended way is to use the `useBaseControlProps` hook, which takes care of generating a unique `id` for you. Otherwise, if you choose to pass an explicit `id` to this prop, you are responsible for ensuring the uniqueness of the `id`.
|
|
27
36
|
|
|
28
37
|
- Type: `String`
|
|
29
38
|
- Required: No
|
|
@@ -44,9 +53,9 @@ If true, the label will only be visible to screen readers.
|
|
|
44
53
|
|
|
45
54
|
### help
|
|
46
55
|
|
|
47
|
-
|
|
56
|
+
Additional description for the control. It is preferable to use plain text for `help`, as it can be accessibly associated with the control using `aria-describedby`. When the `help` contains links, or otherwise non-plain text content, it will be associated with the control using `aria-details`.
|
|
48
57
|
|
|
49
|
-
- Type: `
|
|
58
|
+
- Type: `ReactNode`
|
|
50
59
|
- Required: No
|
|
51
60
|
|
|
52
61
|
### className
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useInstanceId } from '@wordpress/compose';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
import BaseControl from '.';
|
|
10
|
+
import type { BaseControlProps } from './types';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Generate props for the `BaseControl` and the inner control itself.
|
|
14
|
+
*
|
|
15
|
+
* Namely, it takes care of generating a unique `id`, properly associating it with the `label` and `help` elements.
|
|
16
|
+
*
|
|
17
|
+
* @param props
|
|
18
|
+
*/
|
|
19
|
+
export function useBaseControlProps(
|
|
20
|
+
props: Omit< BaseControlProps, 'children' >
|
|
21
|
+
) {
|
|
22
|
+
const { help, id: preferredId, ...restProps } = props;
|
|
23
|
+
|
|
24
|
+
const uniqueId = useInstanceId(
|
|
25
|
+
BaseControl,
|
|
26
|
+
'wp-components-base-control',
|
|
27
|
+
preferredId
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
// ARIA descriptions can only contain plain text, so fall back to aria-details if not.
|
|
31
|
+
const helpPropName =
|
|
32
|
+
typeof help === 'string' ? 'aria-describedby' : 'aria-details';
|
|
33
|
+
|
|
34
|
+
return {
|
|
35
|
+
baseControlProps: {
|
|
36
|
+
id: uniqueId,
|
|
37
|
+
help,
|
|
38
|
+
...restProps,
|
|
39
|
+
},
|
|
40
|
+
controlProps: {
|
|
41
|
+
id: uniqueId,
|
|
42
|
+
...( !! help ? { [ helpPropName ]: `${ uniqueId }__help` } : {} ),
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
}
|
|
@@ -17,19 +17,30 @@ import {
|
|
|
17
17
|
} from './styles/base-control-styles';
|
|
18
18
|
import type { WordPressComponentProps } from '../ui/context';
|
|
19
19
|
|
|
20
|
+
export { useBaseControlProps } from './hooks';
|
|
21
|
+
|
|
20
22
|
/**
|
|
21
23
|
* `BaseControl` is a component used to generate labels and help text for components handling user inputs.
|
|
22
24
|
*
|
|
23
|
-
*
|
|
25
|
+
* ```jsx
|
|
26
|
+
* import { BaseControl, useBaseControlProps } from '@wordpress/components';
|
|
27
|
+
*
|
|
24
28
|
* // Render a `BaseControl` for a textarea input
|
|
25
|
-
*
|
|
29
|
+
* const MyCustomTextareaControl = ({ children, ...baseProps }) => (
|
|
30
|
+
* // `useBaseControlProps` is a convenience hook to get the props for the `BaseControl`
|
|
31
|
+
* // and the inner control itself. Namely, it takes care of generating a unique `id`,
|
|
32
|
+
* // properly associating it with the `label` and `help` elements.
|
|
33
|
+
* const { baseControlProps, controlProps } = useBaseControlProps( baseProps );
|
|
26
34
|
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
35
|
+
* return (
|
|
36
|
+
* <BaseControl { ...baseControlProps } __nextHasNoMarginBottom={ true }>
|
|
37
|
+
* <textarea { ...controlProps }>
|
|
38
|
+
* { children }
|
|
39
|
+
* </textarea>
|
|
40
|
+
* </BaseControl>
|
|
41
|
+
* );
|
|
32
42
|
* );
|
|
43
|
+
* ```
|
|
33
44
|
*/
|
|
34
45
|
export const BaseControl = ( {
|
|
35
46
|
__nextHasNoMarginBottom = false,
|
|
@@ -6,7 +6,7 @@ import type { ComponentMeta, ComponentStory } from '@storybook/react';
|
|
|
6
6
|
/**
|
|
7
7
|
* Internal dependencies
|
|
8
8
|
*/
|
|
9
|
-
import BaseControl from '..';
|
|
9
|
+
import BaseControl, { useBaseControlProps } from '..';
|
|
10
10
|
import Button from '../../button';
|
|
11
11
|
|
|
12
12
|
const meta: ComponentMeta< typeof BaseControl > = {
|
|
@@ -24,13 +24,14 @@ const meta: ComponentMeta< typeof BaseControl > = {
|
|
|
24
24
|
};
|
|
25
25
|
export default meta;
|
|
26
26
|
|
|
27
|
-
const BaseControlWithTextarea: ComponentStory< typeof BaseControl > = (
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
27
|
+
const BaseControlWithTextarea: ComponentStory< typeof BaseControl > = (
|
|
28
|
+
props
|
|
29
|
+
) => {
|
|
30
|
+
const { baseControlProps, controlProps } = useBaseControlProps( props );
|
|
31
|
+
|
|
31
32
|
return (
|
|
32
|
-
<BaseControl
|
|
33
|
-
<textarea style={ { display: 'block' } }
|
|
33
|
+
<BaseControl { ...baseControlProps }>
|
|
34
|
+
<textarea style={ { display: 'block' } } { ...controlProps } />
|
|
34
35
|
</BaseControl>
|
|
35
36
|
);
|
|
36
37
|
};
|
|
@@ -39,14 +40,12 @@ export const Default: ComponentStory< typeof BaseControl > =
|
|
|
39
40
|
BaseControlWithTextarea.bind( {} );
|
|
40
41
|
Default.args = {
|
|
41
42
|
__nextHasNoMarginBottom: true,
|
|
42
|
-
id: 'textarea-default-1',
|
|
43
43
|
label: 'Label text',
|
|
44
44
|
};
|
|
45
45
|
|
|
46
46
|
export const WithHelpText = BaseControlWithTextarea.bind( {} );
|
|
47
47
|
WithHelpText.args = {
|
|
48
48
|
...Default.args,
|
|
49
|
-
id: 'textarea-with-help-text-1',
|
|
50
49
|
help: 'Help text adds more explanation.',
|
|
51
50
|
};
|
|
52
51
|
|
|
@@ -75,6 +74,5 @@ export const WithVisualLabel: ComponentStory< typeof BaseControl > = (
|
|
|
75
74
|
WithVisualLabel.args = {
|
|
76
75
|
...Default.args,
|
|
77
76
|
help: 'This button is already accessibly labeled.',
|
|
78
|
-
id: undefined,
|
|
79
77
|
label: undefined,
|
|
80
78
|
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { render, screen } from '@testing-library/react';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
import BaseControl from '..';
|
|
10
|
+
import { useBaseControlProps } from '../hooks';
|
|
11
|
+
import type { BaseControlProps } from '../types';
|
|
12
|
+
|
|
13
|
+
const MyBaseControl = ( props: Omit< BaseControlProps, 'children' > ) => {
|
|
14
|
+
const { baseControlProps, controlProps } = useBaseControlProps( props );
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<BaseControl { ...baseControlProps } __nextHasNoMarginBottom={ true }>
|
|
18
|
+
<textarea { ...controlProps } />
|
|
19
|
+
</BaseControl>
|
|
20
|
+
);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
describe( 'BaseControl', () => {
|
|
24
|
+
it( 'should render help text as description', () => {
|
|
25
|
+
render( <MyBaseControl label="Text" help="My help text" /> );
|
|
26
|
+
|
|
27
|
+
expect(
|
|
28
|
+
screen.getByRole( 'textbox', {
|
|
29
|
+
description: 'My help text',
|
|
30
|
+
} )
|
|
31
|
+
).toBeInTheDocument();
|
|
32
|
+
} );
|
|
33
|
+
|
|
34
|
+
it( 'should render help as aria-details when not plain text', () => {
|
|
35
|
+
render(
|
|
36
|
+
<MyBaseControl
|
|
37
|
+
label="Text"
|
|
38
|
+
help={ <a href="/foo">My help text</a> }
|
|
39
|
+
/>
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
const textarea = screen.getByRole( 'textbox' );
|
|
43
|
+
const help = screen.getByRole( 'link', {
|
|
44
|
+
name: 'My help text',
|
|
45
|
+
} );
|
|
46
|
+
|
|
47
|
+
expect( textarea ).toHaveAttribute( 'aria-details' );
|
|
48
|
+
expect(
|
|
49
|
+
help.closest( `#${ textarea.getAttribute( 'aria-details' ) }` )
|
|
50
|
+
).toBeVisible();
|
|
51
|
+
} );
|
|
52
|
+
} );
|
|
@@ -11,12 +11,18 @@ export type BaseControlProps = {
|
|
|
11
11
|
*/
|
|
12
12
|
__nextHasNoMarginBottom?: boolean;
|
|
13
13
|
/**
|
|
14
|
-
* The HTML `id` of the element (passed in as a child to `BaseControl`) to which labels and help text are being generated.
|
|
14
|
+
* The HTML `id` of the control element (passed in as a child to `BaseControl`) to which labels and help text are being generated.
|
|
15
15
|
* This is necessary to accessibly associate the label with that element.
|
|
16
|
+
*
|
|
17
|
+
* The recommended way is to use the `useBaseControlProps` hook, which takes care of generating a unique `id` for you.
|
|
18
|
+
* Otherwise, if you choose to pass an explicit `id` to this prop, you are responsible for ensuring the uniqueness of the `id`.
|
|
16
19
|
*/
|
|
17
20
|
id?: string;
|
|
18
21
|
/**
|
|
19
|
-
*
|
|
22
|
+
* Additional description for the control.
|
|
23
|
+
*
|
|
24
|
+
* It is preferable to use plain text for `help`, as it can be accessibly associated with the control using `aria-describedby`.
|
|
25
|
+
* When the `help` contains links, or otherwise non-plain text content, it will be associated with the control using `aria-details`.
|
|
20
26
|
*/
|
|
21
27
|
help?: ReactNode;
|
|
22
28
|
/**
|
package/src/base-field/README.md
CHANGED
|
@@ -12,37 +12,25 @@ This feature is still experimental. “Experimental” means this is an early im
|
|
|
12
12
|
|
|
13
13
|
```js
|
|
14
14
|
function useExampleField( props ) {
|
|
15
|
-
const {
|
|
16
|
-
as = 'input',
|
|
17
|
-
...baseProps,
|
|
18
|
-
} = useBaseField( props );
|
|
15
|
+
const { as = 'input', ...baseProps } = useBaseField( props );
|
|
19
16
|
|
|
20
17
|
const inputProps = {
|
|
21
18
|
as,
|
|
22
19
|
// more cool stuff here
|
|
23
|
-
}
|
|
20
|
+
};
|
|
24
21
|
|
|
25
22
|
return { inputProps, ...baseProps };
|
|
26
23
|
}
|
|
27
24
|
|
|
28
25
|
function ExampleField( props, forwardRef ) {
|
|
29
|
-
const {
|
|
30
|
-
|
|
31
|
-
affix,
|
|
32
|
-
disabled,
|
|
33
|
-
inputProps,
|
|
34
|
-
...baseProps
|
|
35
|
-
} = useExampleField( props );
|
|
26
|
+
const { preFix, affix, disabled, inputProps, ...baseProps } =
|
|
27
|
+
useExampleField( props );
|
|
36
28
|
|
|
37
29
|
return (
|
|
38
30
|
<View { ...baseProps } disabled={ disabled }>
|
|
39
|
-
{preFix}
|
|
40
|
-
<View
|
|
41
|
-
|
|
42
|
-
{ ...inputProps }
|
|
43
|
-
disabled={ disabled }
|
|
44
|
-
/>
|
|
45
|
-
{affix}
|
|
31
|
+
{ preFix }
|
|
32
|
+
<View autocomplete="off" { ...inputProps } disabled={ disabled } />
|
|
33
|
+
{ affix }
|
|
46
34
|
</View>
|
|
47
35
|
);
|
|
48
36
|
}
|
|
@@ -50,18 +38,29 @@ function ExampleField( props, forwardRef ) {
|
|
|
50
38
|
|
|
51
39
|
## Props
|
|
52
40
|
|
|
41
|
+
### `disabled`: `boolean`
|
|
42
|
+
|
|
43
|
+
Whether the field is disabled.
|
|
44
|
+
|
|
45
|
+
- Required: No
|
|
46
|
+
|
|
53
47
|
### `hasError`: `boolean`
|
|
54
48
|
|
|
55
49
|
Renders an error style around the component.
|
|
56
50
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
Whether the field is disabled.
|
|
51
|
+
- Required: No
|
|
52
|
+
- Default: `false`
|
|
60
53
|
|
|
61
54
|
### `isInline`: `boolean`
|
|
62
55
|
|
|
63
56
|
Renders a component that can be inlined in some text.
|
|
64
57
|
|
|
58
|
+
- Required: No
|
|
59
|
+
- Default: `false`
|
|
60
|
+
|
|
65
61
|
### `isSubtle`: `boolean`
|
|
66
62
|
|
|
67
63
|
Renders a subtle variant of the component.
|
|
64
|
+
|
|
65
|
+
- Required: No
|
|
66
|
+
- Default: `false`
|