@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
package/src/button/test/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { render, screen } from '@testing-library/react';
|
|
4
|
+
import { act, render, screen } from '@testing-library/react';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
@@ -76,20 +76,20 @@ describe( 'Button', () => {
|
|
|
76
76
|
expect( screen.getByRole( 'button' ) ).toHaveClass( 'is-pressed' );
|
|
77
77
|
} );
|
|
78
78
|
|
|
79
|
-
it( 'should render a button element with has-text when children are passed',
|
|
79
|
+
it( 'should render a button element with has-text when children are passed', () => {
|
|
80
80
|
render( <Button icon={ plusCircle }>Children</Button> );
|
|
81
|
-
|
|
81
|
+
act( () => screen.getByRole( 'button' ).focus() );
|
|
82
82
|
expect( screen.getByRole( 'button' ) ).toHaveClass( 'has-text' );
|
|
83
83
|
} );
|
|
84
84
|
|
|
85
|
-
it( 'should render a button element without has-text when children are not passed',
|
|
85
|
+
it( 'should render a button element without has-text when children are not passed', () => {
|
|
86
86
|
render( <Button icon={ plusCircle }></Button> );
|
|
87
87
|
expect( screen.getByRole( 'button' ) ).not.toHaveClass(
|
|
88
88
|
'has-text'
|
|
89
89
|
);
|
|
90
90
|
} );
|
|
91
91
|
|
|
92
|
-
it( 'should render a button element without has-text when children are empty fragment',
|
|
92
|
+
it( 'should render a button element without has-text when children are empty fragment', () => {
|
|
93
93
|
render(
|
|
94
94
|
<Button icon={ plusCircle }>
|
|
95
95
|
<></>
|
|
@@ -100,7 +100,7 @@ describe( 'Button', () => {
|
|
|
100
100
|
);
|
|
101
101
|
} );
|
|
102
102
|
|
|
103
|
-
it( 'should render a button element without has-text when a button wrapped in Tooltip',
|
|
103
|
+
it( 'should render a button element without has-text when a button wrapped in Tooltip', () => {
|
|
104
104
|
render(
|
|
105
105
|
<Tooltip text="Help text">
|
|
106
106
|
<Button icon={ plusCircle } />
|
|
@@ -184,10 +184,15 @@ describe( 'Button', () => {
|
|
|
184
184
|
|
|
185
185
|
it( 'should add an aria-label when the label property is used, with Tooltip wrapper', async () => {
|
|
186
186
|
render( <Button icon={ plusCircle } label="WordPress" /> );
|
|
187
|
+
// Wait for the `floating-ui` effects in `Tooltip`/`Popover` to finish running
|
|
188
|
+
// See also: https://floating-ui.com/docs/react-dom#testing
|
|
189
|
+
await act( () => Promise.resolve() );
|
|
187
190
|
|
|
188
191
|
expect( screen.queryByText( 'WordPress' ) ).not.toBeInTheDocument();
|
|
189
192
|
|
|
190
|
-
await
|
|
193
|
+
await act( () => {
|
|
194
|
+
screen.getByRole( 'button', { name: 'WordPress' } ).focus();
|
|
195
|
+
} );
|
|
191
196
|
|
|
192
197
|
expect( screen.getByText( 'WordPress' ) ).toBeVisible();
|
|
193
198
|
} );
|
|
@@ -218,15 +223,18 @@ describe( 'Button', () => {
|
|
|
218
223
|
icon={ plusCircle }
|
|
219
224
|
/>
|
|
220
225
|
);
|
|
226
|
+
await act( () => Promise.resolve() );
|
|
221
227
|
|
|
222
228
|
expect( screen.queryByText( 'Label' ) ).not.toBeInTheDocument();
|
|
223
229
|
|
|
224
|
-
await
|
|
230
|
+
await act( async () => {
|
|
231
|
+
screen.getByRole( 'button', { name: 'Label' } ).focus();
|
|
232
|
+
} );
|
|
225
233
|
|
|
226
234
|
expect( screen.getByText( 'Label' ) ).toBeVisible();
|
|
227
235
|
} );
|
|
228
236
|
|
|
229
|
-
it( 'should populate tooltip with description content for buttons with visible labels (buttons with children)', () => {
|
|
237
|
+
it( 'should populate tooltip with description content for buttons with visible labels (buttons with children)', async () => {
|
|
230
238
|
render(
|
|
231
239
|
<Button
|
|
232
240
|
label="Label"
|
|
@@ -237,6 +245,7 @@ describe( 'Button', () => {
|
|
|
237
245
|
Children
|
|
238
246
|
</Button>
|
|
239
247
|
);
|
|
248
|
+
await act( () => Promise.resolve() );
|
|
240
249
|
|
|
241
250
|
expect(
|
|
242
251
|
screen.getByRole( 'button', {
|
|
@@ -245,7 +254,7 @@ describe( 'Button', () => {
|
|
|
245
254
|
).toBeVisible();
|
|
246
255
|
} );
|
|
247
256
|
|
|
248
|
-
it( 'should allow tooltip disable',
|
|
257
|
+
it( 'should allow tooltip disable', () => {
|
|
249
258
|
render(
|
|
250
259
|
<Button
|
|
251
260
|
icon={ plusCircle }
|
|
@@ -259,7 +268,7 @@ describe( 'Button', () => {
|
|
|
259
268
|
|
|
260
269
|
expect( screen.queryByText( 'WordPress' ) ).not.toBeInTheDocument();
|
|
261
270
|
|
|
262
|
-
|
|
271
|
+
act( () => button.focus() );
|
|
263
272
|
|
|
264
273
|
expect( screen.queryByText( 'WordPress' ) ).not.toBeInTheDocument();
|
|
265
274
|
} );
|
|
@@ -268,15 +277,18 @@ describe( 'Button', () => {
|
|
|
268
277
|
render(
|
|
269
278
|
<Button icon={ plusCircle } label="WordPress" children={ [] } />
|
|
270
279
|
);
|
|
280
|
+
await act( () => Promise.resolve() );
|
|
271
281
|
|
|
272
282
|
expect( screen.queryByText( 'WordPress' ) ).not.toBeInTheDocument();
|
|
273
283
|
|
|
274
|
-
await
|
|
284
|
+
await act( async () => {
|
|
285
|
+
screen.getByRole( 'button', { name: 'WordPress' } ).focus();
|
|
286
|
+
} );
|
|
275
287
|
|
|
276
288
|
expect( screen.getByText( 'WordPress' ) ).toBeVisible();
|
|
277
289
|
} );
|
|
278
290
|
|
|
279
|
-
it( 'should not show the tooltip when icon and children defined',
|
|
291
|
+
it( 'should not show the tooltip when icon and children defined', () => {
|
|
280
292
|
render(
|
|
281
293
|
<Button icon={ plusCircle } label="WordPress">
|
|
282
294
|
Children
|
|
@@ -285,7 +297,9 @@ describe( 'Button', () => {
|
|
|
285
297
|
|
|
286
298
|
expect( screen.queryByText( 'WordPress' ) ).not.toBeInTheDocument();
|
|
287
299
|
|
|
288
|
-
|
|
300
|
+
act( () => {
|
|
301
|
+
screen.getByRole( 'button', { name: 'WordPress' } ).focus();
|
|
302
|
+
} );
|
|
289
303
|
|
|
290
304
|
expect( screen.queryByText( 'WordPress' ) ).not.toBeInTheDocument();
|
|
291
305
|
} );
|
|
@@ -296,10 +310,13 @@ describe( 'Button', () => {
|
|
|
296
310
|
Children
|
|
297
311
|
</Button>
|
|
298
312
|
);
|
|
313
|
+
await act( () => Promise.resolve() );
|
|
299
314
|
|
|
300
315
|
expect( screen.queryByText( 'WordPress' ) ).not.toBeInTheDocument();
|
|
301
316
|
|
|
302
|
-
await
|
|
317
|
+
await act( async () => {
|
|
318
|
+
screen.getByRole( 'button', { name: 'WordPress' } ).focus();
|
|
319
|
+
} );
|
|
303
320
|
|
|
304
321
|
expect( screen.getByText( 'WordPress' ) ).toBeVisible();
|
|
305
322
|
} );
|
package/src/card/test/index.tsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { render } from '@testing-library/react';
|
|
4
|
+
import { render, screen } from '@testing-library/react';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Internal dependencies
|
|
@@ -38,27 +38,39 @@ describe( 'Card', () => {
|
|
|
38
38
|
} );
|
|
39
39
|
|
|
40
40
|
it( 'should remove borders when the isBorderless prop is true', () => {
|
|
41
|
-
const { rerender
|
|
42
|
-
<Card>Code is Poetry</Card>
|
|
41
|
+
const { rerender } = render(
|
|
42
|
+
<Card data-testid="card-wrapper">Code is Poetry</Card>
|
|
43
43
|
);
|
|
44
|
-
|
|
44
|
+
|
|
45
|
+
expect( screen.getByTestId( 'card-wrapper' ) ).not.toHaveStyle(
|
|
45
46
|
'box-shadow: none'
|
|
46
47
|
);
|
|
47
48
|
|
|
48
|
-
rerender(
|
|
49
|
-
|
|
49
|
+
rerender(
|
|
50
|
+
<Card data-testid="card-wrapper" isBorderless>
|
|
51
|
+
Code is Poetry
|
|
52
|
+
</Card>
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
expect( screen.getByTestId( 'card-wrapper' ) ).toHaveStyle(
|
|
56
|
+
'box-shadow: none'
|
|
57
|
+
);
|
|
50
58
|
} );
|
|
51
59
|
|
|
52
60
|
it( 'should add rounded border when the isRounded prop is true', () => {
|
|
53
|
-
|
|
54
|
-
<Card
|
|
61
|
+
render(
|
|
62
|
+
<Card data-testid="card-rounded" isRounded>
|
|
63
|
+
Code is Poetry
|
|
64
|
+
</Card>
|
|
55
65
|
);
|
|
56
|
-
|
|
57
|
-
<Card isRounded={ false }>
|
|
66
|
+
render(
|
|
67
|
+
<Card data-testid="card-squared" isRounded={ false }>
|
|
68
|
+
Code is Poetry
|
|
69
|
+
</Card>
|
|
58
70
|
);
|
|
59
71
|
expect(
|
|
60
|
-
|
|
61
|
-
).toMatchStyleDiffSnapshot(
|
|
72
|
+
screen.getByTestId( 'card-rounded' )
|
|
73
|
+
).toMatchStyleDiffSnapshot( screen.getByTestId( 'card-squared' ) );
|
|
62
74
|
} );
|
|
63
75
|
|
|
64
76
|
it( 'should show a box shadow when the elevation prop is greater than 0', () => {
|
|
@@ -94,7 +106,7 @@ describe( 'Card', () => {
|
|
|
94
106
|
it( 'should warn when the isElevated prop is passed', () => {
|
|
95
107
|
// `isElevated` is automatically converted to `elevation="2"`
|
|
96
108
|
const { container } = render(
|
|
97
|
-
<Card isElevated
|
|
109
|
+
<Card isElevated>Code is Poetry</Card>
|
|
98
110
|
);
|
|
99
111
|
expect( container ).toMatchSnapshot();
|
|
100
112
|
|
|
@@ -103,7 +115,7 @@ describe( 'Card', () => {
|
|
|
103
115
|
|
|
104
116
|
it( 'should pass the isBorderless and isSize props from its context to its sub-components', () => {
|
|
105
117
|
const { container: withoutBorderLarge } = render(
|
|
106
|
-
<Card isBorderless
|
|
118
|
+
<Card isBorderless size="large">
|
|
107
119
|
<CardHeader>Header</CardHeader>
|
|
108
120
|
<CardBody>Body</CardBody>
|
|
109
121
|
<CardFooter>Footer</CardFooter>
|
|
@@ -121,14 +133,14 @@ describe( 'Card', () => {
|
|
|
121
133
|
|
|
122
134
|
it( 'should get the isBorderless and isSize props (passed from its context) overriddenwhen the same props is specified directly on the component', () => {
|
|
123
135
|
const { container: withoutBorder } = render(
|
|
124
|
-
<Card isBorderless
|
|
136
|
+
<Card isBorderless size="large">
|
|
125
137
|
<CardHeader>Header</CardHeader>
|
|
126
138
|
<CardBody>Body</CardBody>
|
|
127
139
|
<CardFooter>Footer</CardFooter>
|
|
128
140
|
</Card>
|
|
129
141
|
);
|
|
130
142
|
const { container: withBorder } = render(
|
|
131
|
-
<Card isBorderless
|
|
143
|
+
<Card isBorderless size="large">
|
|
132
144
|
<CardHeader isBorderless={ false } size="small">
|
|
133
145
|
Header
|
|
134
146
|
</CardHeader>
|
|
@@ -165,7 +177,7 @@ describe( 'Card', () => {
|
|
|
165
177
|
it( 'should render with a darker background color when isShady is true', () => {
|
|
166
178
|
const { container } = render( <CardHeader>Header</CardHeader> );
|
|
167
179
|
const { container: containerShady } = render(
|
|
168
|
-
<CardHeader isShady
|
|
180
|
+
<CardHeader isShady>Header</CardHeader>
|
|
169
181
|
);
|
|
170
182
|
expect( container ).toMatchDiffSnapshot( containerShady );
|
|
171
183
|
} );
|
|
@@ -175,7 +187,7 @@ describe( 'Card', () => {
|
|
|
175
187
|
it( 'should render with a darker background color when isShady is true', () => {
|
|
176
188
|
const { container } = render( <CardFooter>Footer</CardFooter> );
|
|
177
189
|
const { container: containerShady } = render(
|
|
178
|
-
<CardFooter isShady
|
|
190
|
+
<CardFooter isShady>Footer</CardFooter>
|
|
179
191
|
);
|
|
180
192
|
expect( container ).toMatchDiffSnapshot( containerShady );
|
|
181
193
|
} );
|
|
@@ -193,14 +205,14 @@ describe( 'Card', () => {
|
|
|
193
205
|
it( 'should render with a darker background color when isShady is true', () => {
|
|
194
206
|
const { container } = render( <CardBody>Body</CardBody> );
|
|
195
207
|
const { container: containerShady } = render(
|
|
196
|
-
<CardBody isShady
|
|
208
|
+
<CardBody isShady>Body</CardBody>
|
|
197
209
|
);
|
|
198
210
|
expect( container ).toMatchDiffSnapshot( containerShady );
|
|
199
211
|
} );
|
|
200
212
|
|
|
201
213
|
it( 'should allow scrolling content with the scrollable prop is true', () => {
|
|
202
214
|
const { container: containerScrollable } = render(
|
|
203
|
-
<CardBody isScrollable
|
|
215
|
+
<CardBody isScrollable>Body</CardBody>
|
|
204
216
|
);
|
|
205
217
|
const { container } = render( <CardBody>Body</CardBody> );
|
|
206
218
|
expect( container ).toMatchDiffSnapshot( containerScrollable );
|
|
@@ -70,7 +70,7 @@ function SinglePalette( {
|
|
|
70
70
|
}
|
|
71
71
|
style={ { backgroundColor: color, color } }
|
|
72
72
|
onClick={
|
|
73
|
-
isSelected ? clearColor : () => onChange( color )
|
|
73
|
+
isSelected ? clearColor : () => onChange( color, index )
|
|
74
74
|
}
|
|
75
75
|
aria-label={
|
|
76
76
|
name
|
|
@@ -84,10 +84,6 @@ function SinglePalette( {
|
|
|
84
84
|
} );
|
|
85
85
|
}, [ colors, value, onChange, clearColor ] );
|
|
86
86
|
|
|
87
|
-
if ( colors.length === 0 ) {
|
|
88
|
-
return null;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
87
|
return (
|
|
92
88
|
<CircularOptionPicker
|
|
93
89
|
className={ className }
|
|
@@ -118,7 +114,9 @@ function MultiplePalettes( {
|
|
|
118
114
|
<SinglePalette
|
|
119
115
|
clearColor={ clearColor }
|
|
120
116
|
colors={ colorPalette }
|
|
121
|
-
onChange={
|
|
117
|
+
onChange={ ( newColor ) =>
|
|
118
|
+
onChange( newColor, index )
|
|
119
|
+
}
|
|
122
120
|
value={ value }
|
|
123
121
|
actions={
|
|
124
122
|
colors.length === index + 1 ? actions : null
|
|
@@ -15,7 +15,6 @@ import { useState } from '@wordpress/element';
|
|
|
15
15
|
import ColorPalette from '..';
|
|
16
16
|
import Popover from '../../popover';
|
|
17
17
|
import { Provider as SlotFillProvider } from '../../slot-fill';
|
|
18
|
-
import type { ColorObject, PaletteObject } from '../types';
|
|
19
18
|
|
|
20
19
|
const meta: ComponentMeta< typeof ColorPalette > = {
|
|
21
20
|
title: 'Components/ColorPalette',
|
|
@@ -43,10 +42,7 @@ const Template: ComponentStory< typeof ColorPalette > = ( {
|
|
|
43
42
|
onChange,
|
|
44
43
|
...args
|
|
45
44
|
} ) => {
|
|
46
|
-
const
|
|
47
|
-
( args.colors as ColorObject[] )[ 0 ].color ||
|
|
48
|
-
( args.colors as PaletteObject[] )[ 0 ].colors[ 0 ].color;
|
|
49
|
-
const [ color, setColor ] = useState< string | undefined >( firstColor );
|
|
45
|
+
const [ color, setColor ] = useState< string | undefined >();
|
|
50
46
|
|
|
51
47
|
return (
|
|
52
48
|
<SlotFillProvider>
|
|
@@ -63,10 +63,10 @@ exports[`ColorPalette should allow disabling custom color picker 1`] = `
|
|
|
63
63
|
class="components-circular-option-picker__option-wrapper"
|
|
64
64
|
>
|
|
65
65
|
<button
|
|
66
|
-
aria-label="Color:
|
|
66
|
+
aria-label="Color: green"
|
|
67
67
|
aria-pressed="false"
|
|
68
68
|
class="components-button components-circular-option-picker__option"
|
|
69
|
-
style="background-color: rgb(
|
|
69
|
+
style="background-color: rgb(0, 255, 0); color: rgb(0, 255, 0);"
|
|
70
70
|
type="button"
|
|
71
71
|
/>
|
|
72
72
|
</div>
|
|
@@ -235,10 +235,10 @@ exports[`ColorPalette should render a dynamic toolbar of colors 1`] = `
|
|
|
235
235
|
class="components-circular-option-picker__option-wrapper"
|
|
236
236
|
>
|
|
237
237
|
<button
|
|
238
|
-
aria-label="Color:
|
|
238
|
+
aria-label="Color: green"
|
|
239
239
|
aria-pressed="false"
|
|
240
240
|
class="components-button components-circular-option-picker__option"
|
|
241
|
-
style="background-color: rgb(
|
|
241
|
+
style="background-color: rgb(0, 255, 0); color: rgb(0, 255, 0);"
|
|
242
242
|
type="button"
|
|
243
243
|
/>
|
|
244
244
|
</div>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { render, screen, within } from '@testing-library/react';
|
|
4
|
+
import { render, screen, within, waitFor } from '@testing-library/react';
|
|
5
5
|
import userEvent from '@testing-library/user-event';
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -9,24 +9,25 @@ import userEvent from '@testing-library/user-event';
|
|
|
9
9
|
*/
|
|
10
10
|
import ColorPalette from '..';
|
|
11
11
|
|
|
12
|
+
const EXAMPLE_COLORS = [
|
|
13
|
+
{ name: 'red', color: '#f00' },
|
|
14
|
+
{ name: 'green', color: '#0f0' },
|
|
15
|
+
{ name: 'blue', color: '#00f' },
|
|
16
|
+
];
|
|
17
|
+
const INITIAL_COLOR = EXAMPLE_COLORS[ 0 ].color;
|
|
18
|
+
|
|
19
|
+
function getWrappingPopoverElement( element: HTMLElement ) {
|
|
20
|
+
return element.closest( '.components-popover' );
|
|
21
|
+
}
|
|
22
|
+
|
|
12
23
|
describe( 'ColorPalette', () => {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
{ name: 'white', color: '#fff' },
|
|
16
|
-
{ name: 'blue', color: '#00f' },
|
|
17
|
-
];
|
|
18
|
-
const currentColor = '#f00';
|
|
19
|
-
const onChange = jest.fn();
|
|
20
|
-
|
|
21
|
-
beforeEach( () => {
|
|
22
|
-
onChange.mockClear();
|
|
23
|
-
} );
|
|
24
|
+
it( 'should render a dynamic toolbar of colors', () => {
|
|
25
|
+
const onChange = jest.fn();
|
|
24
26
|
|
|
25
|
-
test( 'should render a dynamic toolbar of colors', () => {
|
|
26
27
|
const { container } = render(
|
|
27
28
|
<ColorPalette
|
|
28
|
-
colors={
|
|
29
|
-
value={
|
|
29
|
+
colors={ EXAMPLE_COLORS }
|
|
30
|
+
value={ INITIAL_COLOR }
|
|
30
31
|
onChange={ onChange }
|
|
31
32
|
/>
|
|
32
33
|
);
|
|
@@ -34,11 +35,13 @@ describe( 'ColorPalette', () => {
|
|
|
34
35
|
expect( container ).toMatchSnapshot();
|
|
35
36
|
} );
|
|
36
37
|
|
|
37
|
-
|
|
38
|
+
it( 'should render three color button options', () => {
|
|
39
|
+
const onChange = jest.fn();
|
|
40
|
+
|
|
38
41
|
render(
|
|
39
42
|
<ColorPalette
|
|
40
|
-
colors={
|
|
41
|
-
value={
|
|
43
|
+
colors={ EXAMPLE_COLORS }
|
|
44
|
+
value={ INITIAL_COLOR }
|
|
42
45
|
onChange={ onChange }
|
|
43
46
|
/>
|
|
44
47
|
);
|
|
@@ -48,15 +51,16 @@ describe( 'ColorPalette', () => {
|
|
|
48
51
|
).toHaveLength( 3 );
|
|
49
52
|
} );
|
|
50
53
|
|
|
51
|
-
|
|
54
|
+
it( 'should call onClick on an active button with undefined', async () => {
|
|
52
55
|
const user = userEvent.setup( {
|
|
53
56
|
advanceTimers: jest.advanceTimersByTime,
|
|
54
57
|
} );
|
|
58
|
+
const onChange = jest.fn();
|
|
55
59
|
|
|
56
60
|
render(
|
|
57
61
|
<ColorPalette
|
|
58
|
-
colors={
|
|
59
|
-
value={
|
|
62
|
+
colors={ EXAMPLE_COLORS }
|
|
63
|
+
value={ INITIAL_COLOR }
|
|
60
64
|
onChange={ onChange }
|
|
61
65
|
/>
|
|
62
66
|
);
|
|
@@ -69,19 +73,22 @@ describe( 'ColorPalette', () => {
|
|
|
69
73
|
expect( onChange ).toHaveBeenCalledWith( undefined );
|
|
70
74
|
} );
|
|
71
75
|
|
|
72
|
-
|
|
76
|
+
it( 'should call onClick on an inactive button', async () => {
|
|
73
77
|
const user = userEvent.setup( {
|
|
74
78
|
advanceTimers: jest.advanceTimersByTime,
|
|
75
79
|
} );
|
|
80
|
+
const onChange = jest.fn();
|
|
76
81
|
|
|
77
82
|
render(
|
|
78
83
|
<ColorPalette
|
|
79
|
-
colors={
|
|
80
|
-
value={
|
|
84
|
+
colors={ EXAMPLE_COLORS }
|
|
85
|
+
value={ INITIAL_COLOR }
|
|
81
86
|
onChange={ onChange }
|
|
82
87
|
/>
|
|
83
88
|
);
|
|
84
89
|
|
|
90
|
+
// Click the first unpressed button
|
|
91
|
+
// (i.e. a button representing a color that is not the current color)
|
|
85
92
|
await user.click(
|
|
86
93
|
screen.getAllByRole( 'button', {
|
|
87
94
|
name: /^Color:/,
|
|
@@ -89,19 +96,21 @@ describe( 'ColorPalette', () => {
|
|
|
89
96
|
} )[ 0 ]
|
|
90
97
|
);
|
|
91
98
|
|
|
99
|
+
// Expect the green color to have been selected
|
|
92
100
|
expect( onChange ).toHaveBeenCalledTimes( 1 );
|
|
93
|
-
expect( onChange ).toHaveBeenCalledWith(
|
|
101
|
+
expect( onChange ).toHaveBeenCalledWith( EXAMPLE_COLORS[ 1 ].color, 1 );
|
|
94
102
|
} );
|
|
95
103
|
|
|
96
|
-
|
|
104
|
+
it( 'should call onClick with undefined, when the clearButton onClick is triggered', async () => {
|
|
97
105
|
const user = userEvent.setup( {
|
|
98
106
|
advanceTimers: jest.advanceTimersByTime,
|
|
99
107
|
} );
|
|
108
|
+
const onChange = jest.fn();
|
|
100
109
|
|
|
101
110
|
render(
|
|
102
111
|
<ColorPalette
|
|
103
|
-
colors={
|
|
104
|
-
value={
|
|
112
|
+
colors={ EXAMPLE_COLORS }
|
|
113
|
+
value={ INITIAL_COLOR }
|
|
105
114
|
onChange={ onChange }
|
|
106
115
|
/>
|
|
107
116
|
);
|
|
@@ -112,12 +121,14 @@ describe( 'ColorPalette', () => {
|
|
|
112
121
|
expect( onChange ).toHaveBeenCalledWith( undefined );
|
|
113
122
|
} );
|
|
114
123
|
|
|
115
|
-
|
|
124
|
+
it( 'should allow disabling custom color picker', () => {
|
|
125
|
+
const onChange = jest.fn();
|
|
126
|
+
|
|
116
127
|
const { container } = render(
|
|
117
128
|
<ColorPalette
|
|
118
|
-
colors={
|
|
129
|
+
colors={ EXAMPLE_COLORS }
|
|
119
130
|
disableCustomColors
|
|
120
|
-
value={
|
|
131
|
+
value={ INITIAL_COLOR }
|
|
121
132
|
onChange={ onChange }
|
|
122
133
|
/>
|
|
123
134
|
);
|
|
@@ -125,15 +136,16 @@ describe( 'ColorPalette', () => {
|
|
|
125
136
|
expect( container ).toMatchSnapshot();
|
|
126
137
|
} );
|
|
127
138
|
|
|
128
|
-
|
|
139
|
+
it( 'should render dropdown and its content', async () => {
|
|
129
140
|
const user = userEvent.setup( {
|
|
130
141
|
advanceTimers: jest.advanceTimersByTime,
|
|
131
142
|
} );
|
|
143
|
+
const onChange = jest.fn();
|
|
132
144
|
|
|
133
145
|
render(
|
|
134
146
|
<ColorPalette
|
|
135
|
-
colors={
|
|
136
|
-
value={
|
|
147
|
+
colors={ EXAMPLE_COLORS }
|
|
148
|
+
value={ INITIAL_COLOR }
|
|
137
149
|
onChange={ onChange }
|
|
138
150
|
/>
|
|
139
151
|
);
|
|
@@ -153,12 +165,48 @@ describe( 'ColorPalette', () => {
|
|
|
153
165
|
expect( dropdownButton ).toBeVisible();
|
|
154
166
|
|
|
155
167
|
expect(
|
|
156
|
-
within( dropdownButton ).getByText(
|
|
168
|
+
within( dropdownButton ).getByText( EXAMPLE_COLORS[ 0 ].name )
|
|
157
169
|
).toBeVisible();
|
|
170
|
+
|
|
158
171
|
expect(
|
|
159
172
|
within( dropdownButton ).getByText(
|
|
160
|
-
|
|
173
|
+
EXAMPLE_COLORS[ 0 ].color.replace( '#', '' )
|
|
161
174
|
)
|
|
162
175
|
).toBeVisible();
|
|
176
|
+
|
|
177
|
+
// Check that the popover with custom color input has appeared.
|
|
178
|
+
const dropdownColorInput = screen.getByLabelText( 'Hex color' );
|
|
179
|
+
|
|
180
|
+
await waitFor( () =>
|
|
181
|
+
expect(
|
|
182
|
+
getWrappingPopoverElement( dropdownColorInput )
|
|
183
|
+
).toBePositionedPopover()
|
|
184
|
+
);
|
|
185
|
+
} );
|
|
186
|
+
|
|
187
|
+
it( 'should show the clear button by default', () => {
|
|
188
|
+
const onChange = jest.fn();
|
|
189
|
+
|
|
190
|
+
render(
|
|
191
|
+
<ColorPalette
|
|
192
|
+
colors={ EXAMPLE_COLORS }
|
|
193
|
+
value={ INITIAL_COLOR }
|
|
194
|
+
onChange={ onChange }
|
|
195
|
+
/>
|
|
196
|
+
);
|
|
197
|
+
|
|
198
|
+
expect(
|
|
199
|
+
screen.getByRole( 'button', { name: 'Clear' } )
|
|
200
|
+
).toBeInTheDocument();
|
|
201
|
+
} );
|
|
202
|
+
|
|
203
|
+
it( 'should show the clear button even when `colors` is an empty array', () => {
|
|
204
|
+
const onChange = jest.fn();
|
|
205
|
+
|
|
206
|
+
render( <ColorPalette colors={ [] } onChange={ onChange } /> );
|
|
207
|
+
|
|
208
|
+
expect(
|
|
209
|
+
screen.getByRole( 'button', { name: 'Clear' } )
|
|
210
|
+
).toBeInTheDocument();
|
|
163
211
|
} );
|
|
164
212
|
} );
|
|
@@ -38,10 +38,6 @@ export const SelectControl = styled( InnerSelectControl )`
|
|
|
38
38
|
export const RangeControl = styled( InnerRangeControl )`
|
|
39
39
|
flex: 1;
|
|
40
40
|
margin-right: ${ space( 2 ) };
|
|
41
|
-
|
|
42
|
-
${ StyledField } {
|
|
43
|
-
margin-bottom: 0;
|
|
44
|
-
}
|
|
45
41
|
`;
|
|
46
42
|
|
|
47
43
|
// Make the Hue circle picker not go out of the bar.
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
This feature is still experimental. "Experimental" means this is an early implementation subject to drastic and breaking changes.
|
|
5
5
|
</div>
|
|
6
6
|
|
|
7
|
-
`ConfirmDialog` is built of top of [`Modal`](/packages/components/src/modal/README.md
|
|
7
|
+
`ConfirmDialog` is built of top of [`Modal`](/packages/components/src/modal/README.md) and displays a confirmation dialog, with _confirm_ and _cancel_ buttons.
|
|
8
8
|
|
|
9
9
|
The dialog is confirmed by clicking the _confirm_ button or by pressing the `Enter` key. It is cancelled (closed) by clicking the _cancel_ button, by pressing the `ESC` key, or by clicking outside the dialog focus (i.e, the overlay).
|
|
10
10
|
|
|
@@ -44,6 +44,7 @@ Let the parent component control when the dialog is open/closed. It's activated
|
|
|
44
44
|
|
|
45
45
|
```jsx
|
|
46
46
|
import { __experimentalConfirmDialog as ConfirmDialog } from '@wordpress/components';
|
|
47
|
+
import { useState } from '@wordpress/element';
|
|
47
48
|
|
|
48
49
|
function Example() {
|
|
49
50
|
const [ isOpen, setIsOpen ] = useState( true );
|
|
@@ -72,7 +73,7 @@ function Example() {
|
|
|
72
73
|
|
|
73
74
|
### Unsupported: Multiple instances
|
|
74
75
|
|
|
75
|
-
Multiple `ConfirmDialog
|
|
76
|
+
Multiple `ConfirmDialog`s is an edge case that's currently not officially supported by this component. At the moment, new instances will end up closing the last instance due to the way the `Modal` is implemented.
|
|
76
77
|
|
|
77
78
|
## Custom Types
|
|
78
79
|
|
|
@@ -145,6 +145,20 @@ A handler for onMouseOut events.
|
|
|
145
145
|
- Type: `Function`
|
|
146
146
|
- Required: No
|
|
147
147
|
|
|
148
|
+
#### onFocus
|
|
149
|
+
|
|
150
|
+
A handler for onFocus events.
|
|
151
|
+
|
|
152
|
+
- Type: `Function`
|
|
153
|
+
- Required: No
|
|
154
|
+
|
|
155
|
+
#### onBlur
|
|
156
|
+
|
|
157
|
+
A handler for onBlur events.
|
|
158
|
+
|
|
159
|
+
- Type: `Function`
|
|
160
|
+
- Required: No
|
|
161
|
+
|
|
148
162
|
## Related components
|
|
149
163
|
|
|
150
164
|
- Like this component, but implemented using a native `<select>` for when custom styling is not necessary, the `SelectControl` component.
|