@wordpress/components 22.1.0 → 23.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +67 -0
- package/CONTRIBUTING.md +0 -21
- 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 +39 -12
- 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-box-control/border-box-control/component.js +0 -3
- package/build/border-box-control/border-box-control/component.js.map +1 -1
- package/build/border-box-control/border-box-control/hook.js +0 -2
- package/build/border-box-control/border-box-control/hook.js.map +1 -1
- package/build/border-box-control/border-box-control-split-controls/component.js +0 -2
- package/build/border-box-control/border-box-control-split-controls/component.js.map +1 -1
- package/build/border-box-control/border-box-control-split-controls/hook.js +0 -2
- package/build/border-box-control/border-box-control-split-controls/hook.js.map +1 -1
- package/build/border-control/border-control/component.js +1 -2
- package/build/border-control/border-control/component.js.map +1 -1
- package/build/border-control/border-control/hook.js +0 -2
- package/build/border-control/border-control/hook.js.map +1 -1
- package/build/border-control/border-control-dropdown/component.js +6 -11
- package/build/border-control/border-control-dropdown/component.js.map +1 -1
- package/build/border-control/border-control-dropdown/hook.js +0 -2
- package/build/border-control/border-control-dropdown/hook.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 +7 -15
- 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/dimension-control/index.js.map +1 -1
- package/build/dropdown/index.js +45 -10
- package/build/dropdown/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 +4 -11
- package/build/gradient-picker/index.js.map +1 -1
- package/build/higher-order/navigate-regions/index.js +4 -3
- package/build/higher-order/navigate-regions/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 -9
- 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/picker-cell.native.js +1 -9
- package/build/mobile/bottom-sheet/picker-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/global-styles-context/utils.native.js +30 -12
- package/build/mobile/global-styles-context/utils.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 +15 -9
- 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 +39 -11
- 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-box-control/border-box-control/component.js +0 -3
- package/build-module/border-box-control/border-box-control/component.js.map +1 -1
- package/build-module/border-box-control/border-box-control/hook.js +0 -2
- package/build-module/border-box-control/border-box-control/hook.js.map +1 -1
- package/build-module/border-box-control/border-box-control-split-controls/component.js +0 -2
- package/build-module/border-box-control/border-box-control-split-controls/component.js.map +1 -1
- package/build-module/border-box-control/border-box-control-split-controls/hook.js +0 -2
- package/build-module/border-box-control/border-box-control-split-controls/hook.js.map +1 -1
- package/build-module/border-control/border-control/component.js +1 -2
- package/build-module/border-control/border-control/component.js.map +1 -1
- package/build-module/border-control/border-control/hook.js +0 -2
- package/build-module/border-control/border-control/hook.js.map +1 -1
- package/build-module/border-control/border-control-dropdown/component.js +6 -11
- package/build-module/border-control/border-control-dropdown/component.js.map +1 -1
- package/build-module/border-control/border-control-dropdown/hook.js +0 -2
- package/build-module/border-control/border-control-dropdown/hook.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 +7 -15
- 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/dimension-control/index.js +1 -2
- package/build-module/dimension-control/index.js.map +1 -1
- package/build-module/dropdown/index.js +44 -10
- package/build-module/dropdown/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 +4 -10
- package/build-module/gradient-picker/index.js.map +1 -1
- package/build-module/higher-order/navigate-regions/index.js +4 -3
- package/build-module/higher-order/navigate-regions/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 -3
- 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/picker-cell.native.js +1 -8
- package/build-module/mobile/bottom-sheet/picker-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/global-styles-context/utils.native.js +31 -13
- package/build-module/mobile/global-styles-context/utils.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 +15 -8
- 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 +108 -104
- package/build-style/style.css +108 -104
- 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/component.d.ts +1 -1
- package/build-types/border-box-control/border-box-control/component.d.ts.map +1 -1
- package/build-types/border-box-control/border-box-control/hook.d.ts +2 -3
- package/build-types/border-box-control/border-box-control/hook.d.ts.map +1 -1
- 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/component.d.ts +1 -1
- package/build-types/border-box-control/border-box-control-split-controls/component.d.ts.map +1 -1
- package/build-types/border-box-control/border-box-control-split-controls/hook.d.ts +2 -3
- package/build-types/border-box-control/border-box-control-split-controls/hook.d.ts.map +1 -1
- package/build-types/border-box-control/border-box-control-visualizer/hook.d.ts +2 -2
- package/build-types/border-box-control/stories/index.d.ts +1 -1
- package/build-types/border-control/border-control/component.d.ts +1 -1
- package/build-types/border-control/border-control/component.d.ts.map +1 -1
- package/build-types/border-control/border-control/hook.d.ts +2 -3
- package/build-types/border-control/border-control/hook.d.ts.map +1 -1
- package/build-types/border-control/border-control-dropdown/component.d.ts +1 -1
- package/build-types/border-control/border-control-dropdown/component.d.ts.map +1 -1
- package/build-types/border-control/border-control-dropdown/hook.d.ts +2 -3
- package/build-types/border-control/border-control-dropdown/hook.d.ts.map +1 -1
- package/build-types/border-control/border-control-style-picker/hook.d.ts +2 -2
- package/build-types/border-control/stories/index.d.ts +6 -6
- package/build-types/border-control/stories/index.d.ts.map +1 -1
- package/build-types/border-control/styles.d.ts.map +1 -1
- package/build-types/border-control/types.d.ts +1 -1
- package/build-types/border-control/types.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 +3 -4
- package/build-types/color-palette/index.d.ts.map +1 -1
- package/build-types/color-palette/stories/index.d.ts +6 -14
- 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 +4 -17
- 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/disabled/stories/index.d.ts.map +1 -1
- package/build-types/dropdown/index.d.ts +29 -1
- package/build-types/dropdown/index.d.ts.map +1 -1
- package/build-types/dropdown/stories/index.d.ts +23 -0
- package/build-types/dropdown/stories/index.d.ts.map +1 -0
- package/build-types/dropdown/test/index.d.ts +2 -0
- package/build-types/dropdown/test/index.d.ts.map +1 -0
- package/build-types/dropdown/types.d.ts +101 -0
- package/build-types/dropdown/types.d.ts.map +1 -1
- 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/icon/stories/index.d.ts +22 -0
- package/build-types/icon/stories/index.d.ts.map +1 -0
- package/build-types/input-control/index.d.ts +1 -1
- package/build-types/input-control/index.d.ts.map +1 -1
- package/build-types/input-control/input-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 +44 -15
- package/src/autocomplete/test/index.js +2 -0
- 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 +53 -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/border-box-control/component.tsx +0 -7
- package/src/border-box-control/border-box-control/hook.ts +0 -2
- package/src/border-box-control/border-box-control-split-controls/component.tsx +0 -2
- package/src/border-box-control/border-box-control-split-controls/hook.ts +0 -2
- package/src/border-box-control/test/index.js +5 -1
- package/src/border-control/border-control/component.tsx +1 -4
- package/src/border-control/border-control/hook.ts +0 -2
- package/src/border-control/border-control-dropdown/component.tsx +11 -17
- package/src/border-control/border-control-dropdown/hook.ts +0 -2
- package/src/border-control/stories/index.tsx +0 -1
- package/src/border-control/styles.ts +1 -10
- package/src/border-control/test/index.js +70 -67
- package/src/border-control/types.ts +1 -4
- package/src/box-control/linked-button.js +8 -11
- package/src/box-control/test/index.js +207 -134
- 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/checkbox-control/test/index.tsx +2 -0
- package/src/circular-option-picker/style.scss +1 -0
- package/src/color-palette/index.tsx +16 -18
- package/src/color-palette/stories/index.tsx +1 -18
- package/src/color-palette/test/__snapshots__/index.tsx.snap +4 -4
- package/src/color-palette/test/index.tsx +86 -36
- package/src/color-palette/types.ts +4 -18
- 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/color-picker/test/index.js +2 -0
- package/src/combobox-control/test/index.js +2 -0
- package/src/confirm-dialog/README.md +3 -2
- package/src/confirm-dialog/test/index.js +2 -0
- 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/test/index.tsx +2 -0
- package/src/date-time/date-time/index.tsx +2 -2
- package/src/date-time/time/test/index.tsx +2 -0
- package/src/dimension-control/index.js +2 -3
- package/src/dimension-control/test/__snapshots__/index.test.js.snap +4 -8
- package/src/dimension-control/test/index.test.js +2 -0
- package/src/disabled/stories/index.tsx +6 -2
- package/src/disabled/test/index.tsx +23 -11
- package/src/dropdown/README.md +41 -46
- package/src/dropdown/{index.js → index.tsx} +57 -13
- package/src/dropdown/stories/{index.js → index.tsx} +21 -8
- package/src/dropdown/test/index.tsx +88 -0
- package/src/dropdown/types.ts +107 -0
- package/src/dropdown-menu/README.md +2 -3
- package/src/dropdown-menu/test/index.js +20 -12
- package/src/duotone-picker/duotone-picker.js +2 -2
- package/src/external-link/test/index.tsx +2 -0
- package/src/focal-point-picker/test/index.js +2 -0
- package/src/focal-point-picker/test/media.js +26 -21
- package/src/font-size-picker/test/index.tsx +2 -0
- package/src/form-file-upload/test/index.tsx +2 -0
- package/src/form-toggle/test/index.tsx +2 -0
- package/src/form-token-field/style.scss +1 -1
- package/src/form-token-field/test/index.tsx +3 -0
- package/src/gradient-picker/index.js +6 -10
- package/src/gradient-picker/stories/index.js +0 -1
- package/src/grid/test/grid.tsx +31 -31
- package/src/guide/test/index.js +2 -0
- package/src/higher-order/navigate-regions/index.js +5 -2
- package/src/higher-order/navigate-regions/style.scss +13 -59
- package/src/higher-order/with-fallback-styles/index.js +4 -2
- package/src/higher-order/with-filters/test/index.js +32 -43
- package/src/higher-order/with-focus-outside/test/index.js +2 -0
- package/src/higher-order/with-focus-return/test/index.js +3 -4
- package/src/higher-order/with-notices/test/index.js +1 -0
- package/src/icon/stories/index.tsx +103 -0
- package/src/index.js +2 -3
- 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 +21 -0
- package/src/input-control/types.ts +2 -0
- package/src/isolated-event-container/test/index.js +2 -0
- package/src/mobile/bottom-sheet/cell.native.js +1 -1
- package/src/mobile/bottom-sheet/picker-cell.native.js +1 -6
- 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/global-styles-context/utils.native.js +17 -16
- 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 +13 -0
- package/src/navigable-container/test/navigable-menu.js +2 -0
- package/src/navigable-container/test/tababble-container.js +2 -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/navigation/test/index.js +2 -0
- package/src/navigator/navigator-provider/component.tsx +13 -10
- package/src/navigator/test/index.tsx +2 -0
- package/src/notice/test/index.js +8 -3
- 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 +602 -0
- package/src/palette-edit/index.js +88 -39
- package/src/palette-edit/test/index.js +25 -1
- package/src/panel/test/__snapshots__/body.js.snap +9 -0
- package/src/panel/test/body.js +71 -62
- package/src/placeholder/test/index.tsx +3 -0
- 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/select-control/test/select-control.tsx +2 -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 +15 -5
- package/src/tab-panel/style.scss +46 -34
- package/src/tab-panel/test/index.tsx +113 -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/text-highlight/test/index.tsx +1 -0
- 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 +15 -2
- package/src/toolbar/style.scss +1 -1
- package/src/toolbar-group/test/index.js +10 -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/stories/index.js +68 -78
- package/src/tooltip/style.scss +2 -2
- package/src/tooltip/test/index.js +111 -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 +4 -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/test/use-latest-ref.js +2 -0
- 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/dropdown/test/index.js +0 -98
- package/src/icon/stories/index.js +0 -128
- package/src/number-control/test/index.js +0 -478
- package/src/snackbar/stories/index.js +0 -89
package/build/snackbar/index.js
CHANGED
|
@@ -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.default = void 0;
|
|
8
|
+
exports.default = exports.Snackbar = void 0;
|
|
9
9
|
|
|
10
10
|
var _element = require("@wordpress/element");
|
|
11
11
|
|
|
@@ -17,7 +17,7 @@ var _i18n = require("@wordpress/i18n");
|
|
|
17
17
|
|
|
18
18
|
var _warning = _interopRequireDefault(require("@wordpress/warning"));
|
|
19
19
|
|
|
20
|
-
var
|
|
20
|
+
var _button = _interopRequireDefault(require("../button"));
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
23
|
* External dependencies
|
|
@@ -30,17 +30,13 @@ var _ = require("../");
|
|
|
30
30
|
/**
|
|
31
31
|
* Internal dependencies
|
|
32
32
|
*/
|
|
33
|
-
const noop = () => {};
|
|
34
|
-
|
|
35
33
|
const NOTICE_TIMEOUT = 10000;
|
|
36
|
-
/** @typedef {import('@wordpress/element').WPElement} WPElement */
|
|
37
|
-
|
|
38
34
|
/**
|
|
39
35
|
* Custom hook which announces the message with the given politeness, if a
|
|
40
36
|
* valid message is provided.
|
|
41
37
|
*
|
|
42
|
-
* @param
|
|
43
|
-
* @param
|
|
38
|
+
* @param message Message to announce.
|
|
39
|
+
* @param politeness Politeness to announce.
|
|
44
40
|
*/
|
|
45
41
|
|
|
46
42
|
function useSpokenMessage(message, politeness) {
|
|
@@ -52,38 +48,39 @@ function useSpokenMessage(message, politeness) {
|
|
|
52
48
|
}, [spokenMessage, politeness]);
|
|
53
49
|
}
|
|
54
50
|
|
|
55
|
-
function
|
|
51
|
+
function UnforwardedSnackbar(_ref, ref) {
|
|
56
52
|
let {
|
|
57
53
|
className,
|
|
58
54
|
children,
|
|
59
55
|
spokenMessage = children,
|
|
60
56
|
politeness = 'polite',
|
|
61
57
|
actions = [],
|
|
62
|
-
onRemove
|
|
58
|
+
onRemove,
|
|
63
59
|
icon = null,
|
|
64
60
|
explicitDismiss = false,
|
|
65
61
|
// onDismiss is a callback executed when the snackbar is dismissed.
|
|
66
62
|
// It is distinct from onRemove, which _looks_ like a callback but is
|
|
67
63
|
// actually the function to call to remove the snackbar from the UI.
|
|
68
|
-
onDismiss
|
|
64
|
+
onDismiss,
|
|
69
65
|
listRef
|
|
70
66
|
} = _ref;
|
|
71
|
-
onDismiss = onDismiss || noop;
|
|
72
67
|
|
|
73
68
|
function dismissMe(event) {
|
|
69
|
+
var _listRef$current;
|
|
70
|
+
|
|
74
71
|
if (event && event.preventDefault) {
|
|
75
72
|
event.preventDefault();
|
|
76
73
|
} // Prevent focus loss by moving it to the list element.
|
|
77
74
|
|
|
78
75
|
|
|
79
|
-
listRef.current.focus();
|
|
80
|
-
onDismiss();
|
|
81
|
-
onRemove();
|
|
76
|
+
listRef === null || listRef === void 0 ? void 0 : (_listRef$current = listRef.current) === null || _listRef$current === void 0 ? void 0 : _listRef$current.focus();
|
|
77
|
+
onDismiss === null || onDismiss === void 0 ? void 0 : onDismiss();
|
|
78
|
+
onRemove === null || onRemove === void 0 ? void 0 : onRemove();
|
|
82
79
|
}
|
|
83
80
|
|
|
84
81
|
function onActionClick(event, onClick) {
|
|
85
82
|
event.stopPropagation();
|
|
86
|
-
onRemove();
|
|
83
|
+
onRemove === null || onRemove === void 0 ? void 0 : onRemove();
|
|
87
84
|
|
|
88
85
|
if (onClick) {
|
|
89
86
|
onClick(event);
|
|
@@ -95,8 +92,8 @@ function Snackbar(_ref, ref) {
|
|
|
95
92
|
(0, _element.useEffect)(() => {
|
|
96
93
|
const timeoutHandle = setTimeout(() => {
|
|
97
94
|
if (!explicitDismiss) {
|
|
98
|
-
onDismiss();
|
|
99
|
-
onRemove();
|
|
95
|
+
onDismiss === null || onDismiss === void 0 ? void 0 : onDismiss();
|
|
96
|
+
onRemove === null || onRemove === void 0 ? void 0 : onRemove();
|
|
100
97
|
}
|
|
101
98
|
}, NOTICE_TIMEOUT);
|
|
102
99
|
return () => clearTimeout(timeoutHandle);
|
|
@@ -118,10 +115,10 @@ function Snackbar(_ref, ref) {
|
|
|
118
115
|
return (0, _element.createElement)("div", {
|
|
119
116
|
ref: ref,
|
|
120
117
|
className: classes,
|
|
121
|
-
onClick: !explicitDismiss ? dismissMe :
|
|
122
|
-
tabIndex:
|
|
118
|
+
onClick: !explicitDismiss ? dismissMe : undefined,
|
|
119
|
+
tabIndex: 0,
|
|
123
120
|
role: !explicitDismiss ? 'button' : '',
|
|
124
|
-
onKeyPress: !explicitDismiss ? dismissMe :
|
|
121
|
+
onKeyPress: !explicitDismiss ? dismissMe : undefined,
|
|
125
122
|
"aria-label": !explicitDismiss ? (0, _i18n.__)('Dismiss this notice') : ''
|
|
126
123
|
}, (0, _element.createElement)("div", {
|
|
127
124
|
className: snackbarContentClassnames
|
|
@@ -133,7 +130,7 @@ function Snackbar(_ref, ref) {
|
|
|
133
130
|
onClick,
|
|
134
131
|
url
|
|
135
132
|
} = _ref2;
|
|
136
|
-
return (0, _element.createElement)(
|
|
133
|
+
return (0, _element.createElement)(_button.default, {
|
|
137
134
|
key: index,
|
|
138
135
|
href: url,
|
|
139
136
|
variant: "tertiary",
|
|
@@ -143,14 +140,28 @@ function Snackbar(_ref, ref) {
|
|
|
143
140
|
}), explicitDismiss && (0, _element.createElement)("span", {
|
|
144
141
|
role: "button",
|
|
145
142
|
"aria-label": "Dismiss this notice",
|
|
146
|
-
tabIndex:
|
|
143
|
+
tabIndex: 0,
|
|
147
144
|
className: "components-snackbar__dismiss-button",
|
|
148
145
|
onClick: dismissMe,
|
|
149
146
|
onKeyPress: dismissMe
|
|
150
147
|
}, "\u2715")));
|
|
151
148
|
}
|
|
149
|
+
/**
|
|
150
|
+
* A Snackbar displays a succinct message that is cleared out after a small delay.
|
|
151
|
+
*
|
|
152
|
+
* It can also offer the user options, like viewing a published post.
|
|
153
|
+
* But these options should also be available elsewhere in the UI.
|
|
154
|
+
*
|
|
155
|
+
* ```jsx
|
|
156
|
+
* const MySnackbarNotice = () => (
|
|
157
|
+
* <Snackbar>Post published successfully.</Snackbar>
|
|
158
|
+
* );
|
|
159
|
+
* ```
|
|
160
|
+
*/
|
|
152
161
|
|
|
153
|
-
var _default = (0, _element.forwardRef)(Snackbar);
|
|
154
162
|
|
|
163
|
+
const Snackbar = (0, _element.forwardRef)(UnforwardedSnackbar);
|
|
164
|
+
exports.Snackbar = Snackbar;
|
|
165
|
+
var _default = Snackbar;
|
|
155
166
|
exports.default = _default;
|
|
156
167
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/components/src/snackbar/index.
|
|
1
|
+
{"version":3,"sources":["@wordpress/components/src/snackbar/index.tsx"],"names":["NOTICE_TIMEOUT","useSpokenMessage","message","politeness","spokenMessage","UnforwardedSnackbar","ref","className","children","actions","onRemove","icon","explicitDismiss","onDismiss","listRef","dismissMe","event","preventDefault","current","focus","onActionClick","onClick","stopPropagation","timeoutHandle","setTimeout","clearTimeout","classes","length","snackbarContentClassnames","undefined","map","index","label","url","Snackbar"],"mappings":";;;;;;;;;AAUA;;AANA;;AAKA;;AAEA;;AACA;;AAKA;;AAjBA;AACA;AACA;;AAIA;AACA;AACA;;AAMA;AACA;AACA;AAKA,MAAMA,cAAc,GAAG,KAAvB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASC,gBAAT,CACCC,OADD,EAECC,UAFD,EAGE;AACD,QAAMC,aAAa,GAClB,OAAOF,OAAP,KAAmB,QAAnB,GAA8BA,OAA9B,GAAwC,6BAAgBA,OAAhB,CADzC;AAGA,0BAAW,MAAM;AAChB,QAAKE,aAAL,EAAqB;AACpB,uBAAOA,aAAP,EAAsBD,UAAtB;AACA;AACD,GAJD,EAIG,CAAEC,aAAF,EAAiBD,UAAjB,CAJH;AAKA;;AAED,SAASE,mBAAT,OAgBCC,GAhBD,EAiBE;AAAA,MAhBD;AACCC,IAAAA,SADD;AAECC,IAAAA,QAFD;AAGCJ,IAAAA,aAAa,GAAGI,QAHjB;AAICL,IAAAA,UAAU,GAAG,QAJd;AAKCM,IAAAA,OAAO,GAAG,EALX;AAMCC,IAAAA,QAND;AAOCC,IAAAA,IAAI,GAAG,IAPR;AAQCC,IAAAA,eAAe,GAAG,KARnB;AASC;AACA;AACA;AACAC,IAAAA,SAZD;AAaCC,IAAAA;AAbD,GAgBC;;AACD,WAASC,SAAT,CAAoBC,KAApB,EAAwD;AAAA;;A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A6CA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,MAAMmB,QAAQ,GAAG,yBAAY7B,mBAAZ,CAAjB;;eAEQ6B,Q","sourcesContent":["/**\n * External dependencies\n */\nimport type { ForwardedRef, KeyboardEvent, MouseEvent } from 'react';\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { speak } from '@wordpress/a11y';\nimport { useEffect, forwardRef, renderToString } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport warning from '@wordpress/warning';\n\n/**\n * Internal dependencies\n */\nimport Button from '../button';\nimport type { NoticeAction, SnackbarProps } from './types';\nimport type { WordPressComponentProps } from '../ui/context';\n\nconst NOTICE_TIMEOUT = 10000;\n\n/**\n * Custom hook which announces the message with the given politeness, if a\n * valid message is provided.\n *\n * @param message Message to announce.\n * @param politeness Politeness to announce.\n */\nfunction useSpokenMessage(\n\tmessage: SnackbarProps[ 'spokenMessage' ],\n\tpoliteness: NonNullable< SnackbarProps[ 'politeness' ] >\n) {\n\tconst spokenMessage =\n\t\ttypeof message === 'string' ? message : renderToString( message );\n\n\tuseEffect( () => {\n\t\tif ( spokenMessage ) {\n\t\t\tspeak( spokenMessage, politeness );\n\t\t}\n\t}, [ spokenMessage, politeness ] );\n}\n\nfunction UnforwardedSnackbar(\n\t{\n\t\tclassName,\n\t\tchildren,\n\t\tspokenMessage = children,\n\t\tpoliteness = 'polite',\n\t\tactions = [],\n\t\tonRemove,\n\t\ticon = null,\n\t\texplicitDismiss = false,\n\t\t// onDismiss is a callback executed when the snackbar is dismissed.\n\t\t// It is distinct from onRemove, which _looks_ like a callback but is\n\t\t// actually the function to call to remove the snackbar from the UI.\n\t\tonDismiss,\n\t\tlistRef,\n\t}: WordPressComponentProps< SnackbarProps, 'div' >,\n\tref: ForwardedRef< any >\n) {\n\tfunction dismissMe( event: KeyboardEvent | MouseEvent ) {\n\t\tif ( event && event.preventDefault ) {\n\t\t\tevent.preventDefault();\n\t\t}\n\n\t\t// Prevent focus loss by moving it to the list element.\n\t\tlistRef?.current?.focus();\n\n\t\tonDismiss?.();\n\t\tonRemove?.();\n\t}\n\n\tfunction onActionClick(\n\t\tevent: MouseEvent,\n\t\tonClick: NoticeAction[ 'onClick' ]\n\t) {\n\t\tevent.stopPropagation();\n\n\t\tonRemove?.();\n\n\t\tif ( onClick ) {\n\t\t\tonClick( event );\n\t\t}\n\t}\n\n\tuseSpokenMessage( spokenMessage, politeness );\n\n\t// Only set up the timeout dismiss if we're not explicitly dismissing.\n\tuseEffect( () => {\n\t\tconst timeoutHandle = setTimeout( () => {\n\t\t\tif ( ! explicitDismiss ) {\n\t\t\t\tonDismiss?.();\n\t\t\t\tonRemove?.();\n\t\t\t}\n\t\t}, NOTICE_TIMEOUT );\n\n\t\treturn () => clearTimeout( timeoutHandle );\n\t}, [ onDismiss, onRemove, explicitDismiss ] );\n\n\tconst classes = classnames( className, 'components-snackbar', {\n\t\t'components-snackbar-explicit-dismiss': !! explicitDismiss,\n\t} );\n\tif ( actions && actions.length > 1 ) {\n\t\t// We need to inform developers that snackbar only accepts 1 action.\n\t\twarning(\n\t\t\t'Snackbar can only have 1 action, use Notice if your message require many messages'\n\t\t);\n\t\t// return first element only while keeping it inside an array\n\t\tactions = [ actions[ 0 ] ];\n\t}\n\n\tconst snackbarContentClassnames = classnames(\n\t\t'components-snackbar__content',\n\t\t{\n\t\t\t'components-snackbar__content-with-icon': !! icon,\n\t\t}\n\t);\n\n\treturn (\n\t\t<div\n\t\t\tref={ ref }\n\t\t\tclassName={ classes }\n\t\t\tonClick={ ! explicitDismiss ? dismissMe : undefined }\n\t\t\ttabIndex={ 0 }\n\t\t\trole={ ! explicitDismiss ? 'button' : '' }\n\t\t\tonKeyPress={ ! explicitDismiss ? dismissMe : undefined }\n\t\t\taria-label={ ! explicitDismiss ? __( 'Dismiss this notice' ) : '' }\n\t\t>\n\t\t\t<div className={ snackbarContentClassnames }>\n\t\t\t\t{ icon && (\n\t\t\t\t\t<div className=\"components-snackbar__icon\">{ icon }</div>\n\t\t\t\t) }\n\t\t\t\t{ children }\n\t\t\t\t{ actions.map( ( { label, onClick, url }, index ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tkey={ index }\n\t\t\t\t\t\t\thref={ url }\n\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\tonClick={ ( event: MouseEvent ) =>\n\t\t\t\t\t\t\t\tonActionClick( event, onClick )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tclassName=\"components-snackbar__action\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ label }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t);\n\t\t\t\t} ) }\n\t\t\t\t{ explicitDismiss && (\n\t\t\t\t\t<span\n\t\t\t\t\t\trole=\"button\"\n\t\t\t\t\t\taria-label=\"Dismiss this notice\"\n\t\t\t\t\t\ttabIndex={ 0 }\n\t\t\t\t\t\tclassName=\"components-snackbar__dismiss-button\"\n\t\t\t\t\t\tonClick={ dismissMe }\n\t\t\t\t\t\tonKeyPress={ dismissMe }\n\t\t\t\t\t>\n\t\t\t\t\t\t✕\n\t\t\t\t\t</span>\n\t\t\t\t) }\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n\n/**\n * A Snackbar displays a succinct message that is cleared out after a small delay.\n *\n * It can also offer the user options, like viewing a published post.\n * But these options should also be available elsewhere in the UI.\n *\n * ```jsx\n * const MySnackbarNotice = () => (\n * <Snackbar>Post published successfully.</Snackbar>\n * );\n * ```\n */\nexport const Snackbar = forwardRef( UnforwardedSnackbar );\n\nexport default Snackbar;\n"]}
|
package/build/snackbar/list.js
CHANGED
|
@@ -5,6 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
+
exports.SnackbarList = SnackbarList;
|
|
8
9
|
exports.default = void 0;
|
|
9
10
|
|
|
10
11
|
var _element = require("@wordpress/element");
|
|
@@ -15,7 +16,7 @@ var _classnames = _interopRequireDefault(require("classnames"));
|
|
|
15
16
|
|
|
16
17
|
var _compose = require("@wordpress/compose");
|
|
17
18
|
|
|
18
|
-
var _ = _interopRequireDefault(require("
|
|
19
|
+
var _ = _interopRequireDefault(require("."));
|
|
19
20
|
|
|
20
21
|
var _animation = require("../animation");
|
|
21
22
|
|
|
@@ -30,8 +31,6 @@ var _animation = require("../animation");
|
|
|
30
31
|
/**
|
|
31
32
|
* Internal dependencies
|
|
32
33
|
*/
|
|
33
|
-
const noop = () => {};
|
|
34
|
-
|
|
35
34
|
const SNACKBAR_VARIANTS = {
|
|
36
35
|
init: {
|
|
37
36
|
height: 0,
|
|
@@ -54,21 +53,17 @@ const SNACKBAR_VARIANTS = {
|
|
|
54
53
|
}
|
|
55
54
|
}
|
|
56
55
|
};
|
|
57
|
-
const SNACKBAR_REDUCE_MOTION_VARIANTS = {
|
|
58
|
-
init: false,
|
|
59
|
-
open: false,
|
|
60
|
-
exit: false
|
|
61
|
-
};
|
|
62
56
|
/**
|
|
63
57
|
* Renders a list of notices.
|
|
64
58
|
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
59
|
+
* ```jsx
|
|
60
|
+
* const MySnackbarListNotice = () => (
|
|
61
|
+
* <SnackbarList
|
|
62
|
+
* notices={ notices }
|
|
63
|
+
* onRemove={ removeNotice }
|
|
64
|
+
* />
|
|
65
|
+
* );
|
|
66
|
+
* ```
|
|
72
67
|
*/
|
|
73
68
|
|
|
74
69
|
function SnackbarList(_ref) {
|
|
@@ -76,13 +71,13 @@ function SnackbarList(_ref) {
|
|
|
76
71
|
notices,
|
|
77
72
|
className,
|
|
78
73
|
children,
|
|
79
|
-
onRemove
|
|
74
|
+
onRemove
|
|
80
75
|
} = _ref;
|
|
81
|
-
const listRef = (0, _element.useRef)();
|
|
76
|
+
const listRef = (0, _element.useRef)(null);
|
|
82
77
|
const isReducedMotion = (0, _compose.useReducedMotion)();
|
|
83
78
|
className = (0, _classnames.default)('components-snackbar-list', className);
|
|
84
79
|
|
|
85
|
-
const removeNotice = notice => () => onRemove(notice.id);
|
|
80
|
+
const removeNotice = notice => () => onRemove === null || onRemove === void 0 ? void 0 : onRemove(notice.id);
|
|
86
81
|
|
|
87
82
|
return (0, _element.createElement)("div", {
|
|
88
83
|
className: className,
|
|
@@ -100,7 +95,7 @@ function SnackbarList(_ref) {
|
|
|
100
95
|
animate: 'open',
|
|
101
96
|
exit: 'exit',
|
|
102
97
|
key: notice.id,
|
|
103
|
-
variants: isReducedMotion ?
|
|
98
|
+
variants: isReducedMotion ? undefined : SNACKBAR_VARIANTS
|
|
104
99
|
}, (0, _element.createElement)("div", {
|
|
105
100
|
className: "components-snackbar-list__notice-container"
|
|
106
101
|
}, (0, _element.createElement)(_.default, (0, _extends2.default)({}, restNotice, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/components/src/snackbar/list.
|
|
1
|
+
{"version":3,"sources":["@wordpress/components/src/snackbar/list.tsx"],"names":["SNACKBAR_VARIANTS","init","height","opacity","open","transition","stiffness","velocity","exit","duration","SnackbarList","notices","className","children","onRemove","listRef","isReducedMotion","removeNotice","notice","id","map","content","restNotice","undefined"],"mappings":";;;;;;;;;;AASA;;;;AANA;;AAKA;;AAMA;;AACA;;AAfA;AACA;AACA;;AAGA;AACA;AACA;;AAIA;AACA;AACA;AASA,MAAMA,iBAAiB,GAAG;AACzBC,EAAAA,IAAI,EAAE;AACLC,IAAAA,MAAM,EAAE,CADH;AAELC,IAAAA,OAAO,EAAE;AAFJ,GADmB;AAKzBC,EAAAA,IAAI,EAAE;AACLF,IAAAA,MAAM,EAAE,MADH;AAELC,IAAAA,OAAO,EAAE,CAFJ;AAGLE,IAAAA,UAAU,EAAE;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SAAH,GAAevB;AAPhC,OAUC;AAAK,MAAA,SAAS,EAAC;AAAf,OACC,4BAAC,SAAD,6BACMsB,UADN;AAEC,MAAA,QAAQ,EAAGL,YAAY,CAAEC,MAAF,CAFxB;AAGC,MAAA,OAAO,EAAGH;AAHX,QAKGG,MAAM,CAACG,OALV,CADD,CAVD,CADD;AAsBA,GAzBC,CADH,CAFD,CADD;AAiCA;;eAEcX,Y","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useReducedMotion } from '@wordpress/compose';\nimport { useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport Snackbar from '.';\nimport {\n\t__unstableMotion as motion,\n\t__unstableAnimatePresence as AnimatePresence,\n} from '../animation';\nimport type { Notice, SnackbarListProps } from './types';\nimport type { WordPressComponentProps } from '../ui/context';\n\nconst SNACKBAR_VARIANTS = {\n\tinit: {\n\t\theight: 0,\n\t\topacity: 0,\n\t},\n\topen: {\n\t\theight: 'auto',\n\t\topacity: 1,\n\t\ttransition: {\n\t\t\theight: { stiffness: 1000, velocity: -100 },\n\t\t},\n\t},\n\texit: {\n\t\topacity: 0,\n\t\ttransition: {\n\t\t\tduration: 0.5,\n\t\t},\n\t},\n};\n\n/**\n * Renders a list of notices.\n *\n * ```jsx\n * const MySnackbarListNotice = () => (\n * <SnackbarList\n * notices={ notices }\n * onRemove={ removeNotice }\n * />\n * );\n * ```\n */\nexport function SnackbarList( {\n\tnotices,\n\tclassName,\n\tchildren,\n\tonRemove,\n}: WordPressComponentProps< SnackbarListProps, 'div' > ) {\n\tconst listRef = useRef< HTMLDivElement | null >( null );\n\tconst isReducedMotion = useReducedMotion();\n\tclassName = classnames( 'components-snackbar-list', className );\n\tconst removeNotice = ( notice: Notice ) => () => onRemove?.( notice.id );\n\treturn (\n\t\t<div className={ className } tabIndex={ -1 } ref={ listRef }>\n\t\t\t{ children }\n\t\t\t<AnimatePresence>\n\t\t\t\t{ notices.map( ( notice ) => {\n\t\t\t\t\tconst { content, ...restNotice } = notice;\n\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<motion.div\n\t\t\t\t\t\t\tlayout={ ! isReducedMotion } // See https://www.framer.com/docs/animation/#layout-animations\n\t\t\t\t\t\t\tinitial={ 'init' }\n\t\t\t\t\t\t\tanimate={ 'open' }\n\t\t\t\t\t\t\texit={ 'exit' }\n\t\t\t\t\t\t\tkey={ notice.id }\n\t\t\t\t\t\t\tvariants={\n\t\t\t\t\t\t\t\tisReducedMotion ? undefined : SNACKBAR_VARIANTS\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<div className=\"components-snackbar-list__notice-container\">\n\t\t\t\t\t\t\t\t<Snackbar\n\t\t\t\t\t\t\t\t\t{ ...restNotice }\n\t\t\t\t\t\t\t\t\tonRemove={ removeNotice( notice ) }\n\t\t\t\t\t\t\t\t\tlistRef={ listRef }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ notice.content }\n\t\t\t\t\t\t\t\t</Snackbar>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</motion.div>\n\t\t\t\t\t);\n\t\t\t\t} ) }\n\t\t\t</AnimatePresence>\n\t\t</div>\n\t);\n}\n\nexport default SnackbarList;\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
|
package/build/tab-panel/index.js
CHANGED
|
@@ -14,8 +14,6 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
|
|
|
14
14
|
|
|
15
15
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
16
16
|
|
|
17
|
-
var _lodash = require("lodash");
|
|
18
|
-
|
|
19
17
|
var _compose = require("@wordpress/compose");
|
|
20
18
|
|
|
21
19
|
var _navigableContainer = require("../navigable-container");
|
|
@@ -94,6 +92,7 @@ function TabPanel(_ref2) {
|
|
|
94
92
|
className,
|
|
95
93
|
children,
|
|
96
94
|
tabs,
|
|
95
|
+
selectOnMove = true,
|
|
97
96
|
initialTabName,
|
|
98
97
|
orientation = 'horizontal',
|
|
99
98
|
activeClass = 'is-active',
|
|
@@ -104,14 +103,18 @@ function TabPanel(_ref2) {
|
|
|
104
103
|
const handleTabSelection = (0, _element.useCallback)(tabKey => {
|
|
105
104
|
setSelected(tabKey);
|
|
106
105
|
onSelect === null || onSelect === void 0 ? void 0 : onSelect(tabKey);
|
|
107
|
-
}, [onSelect]);
|
|
106
|
+
}, [onSelect]); // Simulate a click on the newly focused tab, which causes the component
|
|
107
|
+
// to show the `tab-panel` associated with the clicked tab.
|
|
108
108
|
|
|
109
|
-
const
|
|
109
|
+
const activateTabAutomatically = (_childIndex, child) => {
|
|
110
110
|
child.click();
|
|
111
111
|
};
|
|
112
112
|
|
|
113
|
-
const selectedTab =
|
|
114
|
-
|
|
113
|
+
const selectedTab = tabs.find(_ref3 => {
|
|
114
|
+
let {
|
|
115
|
+
name
|
|
116
|
+
} = _ref3;
|
|
117
|
+
return name === selected;
|
|
115
118
|
});
|
|
116
119
|
const selectedId = `${instanceId}-${(_selectedTab$name = selectedTab === null || selectedTab === void 0 ? void 0 : selectedTab.name) !== null && _selectedTab$name !== void 0 ? _selectedTab$name : 'none'}`;
|
|
117
120
|
(0, _element.useEffect)(() => {
|
|
@@ -124,7 +127,7 @@ function TabPanel(_ref2) {
|
|
|
124
127
|
}, (0, _element.createElement)(_navigableContainer.NavigableMenu, {
|
|
125
128
|
role: "tablist",
|
|
126
129
|
orientation: orientation,
|
|
127
|
-
onNavigate:
|
|
130
|
+
onNavigate: selectOnMove ? activateTabAutomatically : undefined,
|
|
128
131
|
className: "components-tab-panel__tabs"
|
|
129
132
|
}, tabs.map(tab => (0, _element.createElement)(TabButton, {
|
|
130
133
|
className: (0, _classnames.default)('components-tab-panel__tabs-item', tab.className, {
|
|
@@ -134,8 +137,11 @@ function TabPanel(_ref2) {
|
|
|
134
137
|
"aria-controls": `${instanceId}-${tab.name}-view`,
|
|
135
138
|
selected: tab.name === selected,
|
|
136
139
|
key: tab.name,
|
|
137
|
-
onClick: () => handleTabSelection(tab.name)
|
|
138
|
-
|
|
140
|
+
onClick: () => handleTabSelection(tab.name),
|
|
141
|
+
label: tab.icon && tab.title,
|
|
142
|
+
icon: tab.icon,
|
|
143
|
+
showTooltip: !!tab.icon
|
|
144
|
+
}, !tab.icon && tab.title))), selectedTab && (0, _element.createElement)("div", {
|
|
139
145
|
key: selectedId,
|
|
140
146
|
"aria-labelledby": selectedId,
|
|
141
147
|
role: "tabpanel",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/components/src/tab-panel/index.tsx"],"names":["TabButton","tabId","onClick","children","selected","rest","TabPanel","className","tabs","initialTabName","orientation","activeClass","onSelect","instanceId","setSelected","handleTabSelection","tabKey","
|
|
1
|
+
{"version":3,"sources":["@wordpress/components/src/tab-panel/index.tsx"],"names":["TabButton","tabId","onClick","children","selected","rest","TabPanel","className","tabs","selectOnMove","initialTabName","orientation","activeClass","onSelect","instanceId","setSelected","handleTabSelection","tabKey","activateTabAutomatically","_childIndex","child","click","selectedTab","find","name","selectedId","length","undefined","map","tab","icon","title"],"mappings":";;;;;;;;;;AAQA;;;;AALA;;AAMA;;AAKA;;AACA;;AAfA;AACA;AACA;;AAGA;AACA;AACA;;AAIA;AACA;AACA;AAMA,MAAMA,SAAS,GAAG;AAAA,MAAE;AACnBC,IAAAA,KADmB;AAEnBC,IAAAA,OAFmB;AAGnBC,IAAAA,QAHmB;AAInBC,IAAAA,QAJmB;AAKnB,OAAGC;AALgB,GAAF;AAAA,SAOjB,4BAAC,eAAD;AACC,IAAA,IAAI,EAAC,KADN;AAEC,IAAA,QAAQ,EAAGD,QAAQ,GAAG,IAAH,GAAU,CAAC,CAF/B;AAGC,qBAAgBA,QAHjB;AAIC,IAAA,EAAE,EAAGH,KAJN;AAKC,IAAA,OAAO,EAAGC;AALX,KAMMG,IANN,GAQGF,Q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N,IAAcD,GAAG,CAACE,KAjBrB,CADC,CARH,CADD,EA+BGT,WAAW,IACZ;AACC,IAAA,GAAG,EAAGG,UADP;AAEC,uBAAkBA,UAFnB;AAGC,IAAA,IAAI,EAAC,UAHN;AAIC,IAAA,EAAE,EAAI,GAAGA,UAAY,OAJtB;AAKC,IAAA,SAAS,EAAC;AALX,KAOGtB,QAAQ,CAAEmB,WAAF,CAPX,CAhCF,CADD;AA6CA;;eAEchB,Q","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useState, useEffect, useCallback } from '@wordpress/element';\nimport { useInstanceId } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { NavigableMenu } from '../navigable-container';\nimport Button from '../button';\nimport type { TabButtonProps, TabPanelProps } from './types';\nimport type { WordPressComponentProps } from '../ui/context';\n\nconst TabButton = ( {\n\ttabId,\n\tonClick,\n\tchildren,\n\tselected,\n\t...rest\n}: TabButtonProps ) => (\n\t<Button\n\t\trole=\"tab\"\n\t\ttabIndex={ selected ? null : -1 }\n\t\taria-selected={ selected }\n\t\tid={ tabId }\n\t\tonClick={ onClick }\n\t\t{ ...rest }\n\t>\n\t\t{ children }\n\t</Button>\n);\n\n/**\n * TabPanel is an ARIA-compliant tabpanel.\n *\n * TabPanels organize content across different screens, data sets, and interactions.\n * It has two sections: a list of tabs, and the view to show when tabs are chosen.\n *\n * ```jsx\n * import { TabPanel } from '@wordpress/components';\n *\n * const onSelect = ( tabName ) => {\n * console.log( 'Selecting tab', tabName );\n * };\n *\n * const MyTabPanel = () => (\n * <TabPanel\n * className=\"my-tab-panel\"\n * activeClass=\"active-tab\"\n * onSelect={ onSelect }\n * tabs={ [\n * {\n * name: 'tab1',\n * title: 'Tab 1',\n * className: 'tab-one',\n * },\n * {\n * name: 'tab2',\n * title: 'Tab 2',\n * className: 'tab-two',\n * },\n * ] }\n * >\n * { ( tab ) => <p>{ tab.title }</p> }\n * </TabPanel>\n * );\n * ```\n */\nexport function TabPanel( {\n\tclassName,\n\tchildren,\n\ttabs,\n\tselectOnMove = true,\n\tinitialTabName,\n\torientation = 'horizontal',\n\tactiveClass = 'is-active',\n\tonSelect,\n}: WordPressComponentProps< TabPanelProps, 'div', false > ) {\n\tconst instanceId = useInstanceId( TabPanel, 'tab-panel' );\n\tconst [ selected, setSelected ] = useState< string >();\n\n\tconst handleTabSelection = useCallback(\n\t\t( tabKey: string ) => {\n\t\t\tsetSelected( tabKey );\n\t\t\tonSelect?.( tabKey );\n\t\t},\n\t\t[ onSelect ]\n\t);\n\n\t// Simulate a click on the newly focused tab, which causes the component\n\t// to show the `tab-panel` associated with the clicked tab.\n\tconst activateTabAutomatically = (\n\t\t_childIndex: number,\n\t\tchild: HTMLButtonElement\n\t) => {\n\t\tchild.click();\n\t};\n\tconst selectedTab = tabs.find( ( { name } ) => name === selected );\n\tconst selectedId = `${ instanceId }-${ selectedTab?.name ?? 'none' }`;\n\n\tuseEffect( () => {\n\t\tif ( ! selectedTab?.name && tabs.length > 0 ) {\n\t\t\thandleTabSelection( initialTabName || tabs[ 0 ].name );\n\t\t}\n\t}, [ tabs, selectedTab?.name, initialTabName, handleTabSelection ] );\n\n\treturn (\n\t\t<div className={ className }>\n\t\t\t<NavigableMenu\n\t\t\t\trole=\"tablist\"\n\t\t\t\torientation={ orientation }\n\t\t\t\tonNavigate={\n\t\t\t\t\tselectOnMove ? activateTabAutomatically : undefined\n\t\t\t\t}\n\t\t\t\tclassName=\"components-tab-panel__tabs\"\n\t\t\t>\n\t\t\t\t{ tabs.map( ( tab ) => (\n\t\t\t\t\t<TabButton\n\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t'components-tab-panel__tabs-item',\n\t\t\t\t\t\t\ttab.className,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t[ activeClass ]: tab.name === selected,\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t) }\n\t\t\t\t\t\ttabId={ `${ instanceId }-${ tab.name }` }\n\t\t\t\t\t\taria-controls={ `${ instanceId }-${ tab.name }-view` }\n\t\t\t\t\t\tselected={ tab.name === selected }\n\t\t\t\t\t\tkey={ tab.name }\n\t\t\t\t\t\tonClick={ () => handleTabSelection( tab.name ) }\n\t\t\t\t\t\tlabel={ tab.icon && tab.title }\n\t\t\t\t\t\ticon={ tab.icon }\n\t\t\t\t\t\tshowTooltip={ !! tab.icon }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ ! tab.icon && tab.title }\n\t\t\t\t\t</TabButton>\n\t\t\t\t) ) }\n\t\t\t</NavigableMenu>\n\t\t\t{ selectedTab && (\n\t\t\t\t<div\n\t\t\t\t\tkey={ selectedId }\n\t\t\t\t\taria-labelledby={ selectedId }\n\t\t\t\t\trole=\"tabpanel\"\n\t\t\t\t\tid={ `${ selectedId }-view` }\n\t\t\t\t\tclassName=\"components-tab-panel__tab-content\"\n\t\t\t\t>\n\t\t\t\t\t{ children( selectedTab ) }\n\t\t\t\t</div>\n\t\t\t) }\n\t\t</div>\n\t);\n}\n\nexport default TabPanel;\n"]}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.checkContrasts = checkContrasts;
|
|
9
|
+
exports.generateShades = generateShades;
|
|
10
|
+
exports.generateThemeVariables = generateThemeVariables;
|
|
11
|
+
|
|
12
|
+
var _colord = require("colord");
|
|
13
|
+
|
|
14
|
+
var _a11y = _interopRequireDefault(require("colord/plugins/a11y"));
|
|
15
|
+
|
|
16
|
+
var _names = _interopRequireDefault(require("colord/plugins/names"));
|
|
17
|
+
|
|
18
|
+
var _warning = _interopRequireDefault(require("@wordpress/warning"));
|
|
19
|
+
|
|
20
|
+
var _utils = require("../utils");
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* External dependencies
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* WordPress dependencies
|
|
28
|
+
*/
|
|
29
|
+
(0, _colord.extend)([_names.default, _a11y.default]);
|
|
30
|
+
|
|
31
|
+
function generateThemeVariables(inputs) {
|
|
32
|
+
validateInputs(inputs);
|
|
33
|
+
const generatedColors = { ...generateAccentDependentColors(inputs.accent),
|
|
34
|
+
...generateBackgroundDependentColors(inputs.background)
|
|
35
|
+
};
|
|
36
|
+
warnContrastIssues(checkContrasts(inputs, generatedColors));
|
|
37
|
+
return {
|
|
38
|
+
colors: generatedColors
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function validateInputs(inputs) {
|
|
43
|
+
for (const [key, value] of Object.entries(inputs)) {
|
|
44
|
+
if (typeof value !== 'undefined' && !(0, _colord.colord)(value).isValid()) {
|
|
45
|
+
typeof process !== "undefined" && process.env && process.env.NODE_ENV !== "production" ? (0, _warning.default)(`wp.components.Theme: "${value}" is not a valid color value for the '${key}' prop.`) : void 0;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function checkContrasts(inputs, outputs) {
|
|
51
|
+
const background = inputs.background || _utils.COLORS.white;
|
|
52
|
+
const accent = inputs.accent || '#007cba';
|
|
53
|
+
const foreground = outputs.foreground || _utils.COLORS.gray[900];
|
|
54
|
+
const gray = outputs.gray || _utils.COLORS.gray;
|
|
55
|
+
return {
|
|
56
|
+
accent: (0, _colord.colord)(background).isReadable(accent) ? undefined : `The background color ("${background}") does not have sufficient contrast against the accent color ("${accent}").`,
|
|
57
|
+
foreground: (0, _colord.colord)(background).isReadable(foreground) ? undefined : `The background color provided ("${background}") does not have sufficient contrast against the standard foreground colors.`,
|
|
58
|
+
grays: (0, _colord.colord)(background).contrast(gray[600]) >= 3 && (0, _colord.colord)(background).contrast(gray[700]) >= 4.5 ? undefined : `The background color provided ("${background}") cannot generate a set of grayscale foreground colors with sufficient contrast. Try adjusting the color to be lighter or darker.`
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function warnContrastIssues(issues) {
|
|
63
|
+
for (const error of Object.values(issues)) {
|
|
64
|
+
if (error) {
|
|
65
|
+
typeof process !== "undefined" && process.env && process.env.NODE_ENV !== "production" ? (0, _warning.default)('wp.components.Theme: ' + error) : void 0;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function generateAccentDependentColors(accent) {
|
|
71
|
+
if (!accent) return {};
|
|
72
|
+
return {
|
|
73
|
+
accent,
|
|
74
|
+
accentDarker10: (0, _colord.colord)(accent).darken(0.1).toHex(),
|
|
75
|
+
accentDarker20: (0, _colord.colord)(accent).darken(0.2).toHex(),
|
|
76
|
+
accentInverted: getForegroundForColor(accent)
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function generateBackgroundDependentColors(background) {
|
|
81
|
+
if (!background) return {};
|
|
82
|
+
const foreground = getForegroundForColor(background);
|
|
83
|
+
return {
|
|
84
|
+
background,
|
|
85
|
+
foreground,
|
|
86
|
+
foregroundInverted: getForegroundForColor(foreground),
|
|
87
|
+
gray: generateShades(background, foreground)
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function getForegroundForColor(color) {
|
|
92
|
+
return (0, _colord.colord)(color).isDark() ? _utils.COLORS.white : _utils.COLORS.gray[900];
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function generateShades(background, foreground) {
|
|
96
|
+
// How much darkness you need to add to #fff to get the COLORS.gray[n] color
|
|
97
|
+
const SHADES = {
|
|
98
|
+
100: 0.06,
|
|
99
|
+
200: 0.121,
|
|
100
|
+
300: 0.132,
|
|
101
|
+
400: 0.2,
|
|
102
|
+
600: 0.42,
|
|
103
|
+
700: 0.543,
|
|
104
|
+
800: 0.821
|
|
105
|
+
}; // Darkness of COLORS.gray[ 900 ], relative to #fff
|
|
106
|
+
|
|
107
|
+
const limit = 0.884;
|
|
108
|
+
const direction = (0, _colord.colord)(background).isDark() ? 'lighten' : 'darken'; // Lightness delta between the background and foreground colors
|
|
109
|
+
|
|
110
|
+
const range = Math.abs((0, _colord.colord)(background).toHsl().l - (0, _colord.colord)(foreground).toHsl().l) / 100;
|
|
111
|
+
const result = {};
|
|
112
|
+
Object.entries(SHADES).forEach(_ref => {
|
|
113
|
+
let [key, value] = _ref;
|
|
114
|
+
result[parseInt(key)] = (0, _colord.colord)(background)[direction](value / limit * range).toHex();
|
|
115
|
+
});
|
|
116
|
+
return result;
|
|
117
|
+
}
|
|
118
|
+
//# sourceMappingURL=color-algorithms.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/components/src/theme/color-algorithms.ts"],"names":["namesPlugin","a11yPlugin","generateThemeVariables","inputs","validateInputs","generatedColors","generateAccentDependentColors","accent","generateBackgroundDependentColors","background","warnContrastIssues","checkContrasts","colors","key","value","Object","entries","isValid","outputs","COLORS","white","foreground","gray","isReadable","undefined","grays","contrast","issues","error","values","accentDarker10","darken","toHex","accentDarker20","accentInverted","getForegroundForColor","foregroundInverted","generateShades","color","isDark","SHADES","limit","direction","range","Math","abs","toHsl","l","result","forEach","parseInt"],"mappings":";;;;;;;;;;;AAGA;;AACA;;AACA;;AAKA;;AAMA;;AAhBA;AACA;AACA;;AAKA;AACA;AACA;AASA,oBAAQ,CAAEA,cAAF,EAAeC,aAAf,CAAR;;AAEO,SAASC,sBAAT,CACNC,MADM,EAEc;AACpBC,EAAAA,cAAc,CAAED,MAAF,CAAd;AAEA,QAAME,eAAe,GAAG,EACvB,GAAGC,6BAA6B,CAAEH,MAAM,CAACI,MAAT,CADT;AAEvB,OAAGC,iCAAiC,CAAEL,MAAM,CAACM,UAAT;AAFb,GAAxB;AAKAC,EAAAA,kBAAkB,CAAEC,cAAc,CAAER,MAAF,EAAUE,eAAV,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AK;AAPS,GAAf,CAFwE,CAYxE;;AACA,QAAMC,KAAK,GAAG,KAAd;AAEA,QAAMC,SAAS,GAAG,oBAAQjC,UAAR,EAAqB8B,MAArB,KAAgC,SAAhC,GAA4C,QAA9D,CAfwE,CAiBxE;;AACA,QAAMI,KAAK,GACVC,IAAI,CAACC,GAAL,CACC,oBAAQpC,UAAR,EAAqBqC,KAArB,GAA6BC,CAA7B,GAAiC,oBAAQ1B,UAAR,EAAqByB,KAArB,GAA6BC,CAD/D,IAEI,GAHL;AAKA,QAAMC,MAAgC,GAAG,EAAzC;AAEAjC,EAAAA,MAAM,CAACC,OAAP,CAAgBwB,MAAhB,EAAyBS,OAAzB,CAAkC,QAAsB;AAAA,QAApB,CAAEpC,GAAF,EAAOC,KAAP,CAAoB;AACvDkC,IAAAA,MAAM,CAAEE,QAAQ,CAAErC,GAAF,CAAV,CAAN,GAA4B,oBAAQJ,UAAR,EACzBiC,SADyB,EACV5B,KAAK,GAAG2B,KAAV,GAAoBE,KADR,EAE1BX,KAF0B,EAA5B;AAGA,GAJD;AAMA,SAAOgB,MAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { colord, extend } from 'colord';\nimport a11yPlugin from 'colord/plugins/a11y';\nimport namesPlugin from 'colord/plugins/names';\n\n/**\n * WordPress dependencies\n */\nimport warning from '@wordpress/warning';\n\n/**\n * Internal dependencies\n */\nimport type { ThemeInputValues, ThemeOutputValues } from './types';\nimport { COLORS } from '../utils';\n\nextend( [ namesPlugin, a11yPlugin ] );\n\nexport function generateThemeVariables(\n\tinputs: ThemeInputValues\n): ThemeOutputValues {\n\tvalidateInputs( inputs );\n\n\tconst generatedColors = {\n\t\t...generateAccentDependentColors( inputs.accent ),\n\t\t...generateBackgroundDependentColors( inputs.background ),\n\t};\n\n\twarnContrastIssues( checkContrasts( inputs, generatedColors ) );\n\n\treturn { colors: generatedColors };\n}\n\nfunction validateInputs( inputs: ThemeInputValues ) {\n\tfor ( const [ key, value ] of Object.entries( inputs ) ) {\n\t\tif ( typeof value !== 'undefined' && ! colord( value ).isValid() ) {\n\t\t\twarning(\n\t\t\t\t`wp.components.Theme: \"${ value }\" is not a valid color value for the '${ key }' prop.`\n\t\t\t);\n\t\t}\n\t}\n}\n\nexport function checkContrasts(\n\tinputs: ThemeInputValues,\n\toutputs: ThemeOutputValues[ 'colors' ]\n) {\n\tconst background = inputs.background || COLORS.white;\n\tconst accent = inputs.accent || '#007cba';\n\tconst foreground = outputs.foreground || COLORS.gray[ 900 ];\n\tconst gray = outputs.gray || COLORS.gray;\n\n\treturn {\n\t\taccent: colord( background ).isReadable( accent )\n\t\t\t? undefined\n\t\t\t: `The background color (\"${ background }\") does not have sufficient contrast against the accent color (\"${ accent }\").`,\n\t\tforeground: colord( background ).isReadable( foreground )\n\t\t\t? undefined\n\t\t\t: `The background color provided (\"${ background }\") does not have sufficient contrast against the standard foreground colors.`,\n\t\tgrays:\n\t\t\tcolord( background ).contrast( gray[ 600 ] ) >= 3 &&\n\t\t\tcolord( background ).contrast( gray[ 700 ] ) >= 4.5\n\t\t\t\t? undefined\n\t\t\t\t: `The background color provided (\"${ background }\") cannot generate a set of grayscale foreground colors with sufficient contrast. Try adjusting the color to be lighter or darker.`,\n\t};\n}\n\nfunction warnContrastIssues( issues: ReturnType< typeof checkContrasts > ) {\n\tfor ( const error of Object.values( issues ) ) {\n\t\tif ( error ) {\n\t\t\twarning( 'wp.components.Theme: ' + error );\n\t\t}\n\t}\n}\n\nfunction generateAccentDependentColors( accent?: string ) {\n\tif ( ! accent ) return {};\n\n\treturn {\n\t\taccent,\n\t\taccentDarker10: colord( accent ).darken( 0.1 ).toHex(),\n\t\taccentDarker20: colord( accent ).darken( 0.2 ).toHex(),\n\t\taccentInverted: getForegroundForColor( accent ),\n\t};\n}\n\nfunction generateBackgroundDependentColors( background?: string ) {\n\tif ( ! background ) return {};\n\n\tconst foreground = getForegroundForColor( background );\n\n\treturn {\n\t\tbackground,\n\t\tforeground,\n\t\tforegroundInverted: getForegroundForColor( foreground ),\n\t\tgray: generateShades( background, foreground ),\n\t};\n}\n\nfunction getForegroundForColor( color: string ) {\n\treturn colord( color ).isDark() ? COLORS.white : COLORS.gray[ 900 ];\n}\n\nexport function generateShades( background: string, foreground: string ) {\n\t// How much darkness you need to add to #fff to get the COLORS.gray[n] color\n\tconst SHADES = {\n\t\t100: 0.06,\n\t\t200: 0.121,\n\t\t300: 0.132,\n\t\t400: 0.2,\n\t\t600: 0.42,\n\t\t700: 0.543,\n\t\t800: 0.821,\n\t};\n\n\t// Darkness of COLORS.gray[ 900 ], relative to #fff\n\tconst limit = 0.884;\n\n\tconst direction = colord( background ).isDark() ? 'lighten' : 'darken';\n\n\t// Lightness delta between the background and foreground colors\n\tconst range =\n\t\tMath.abs(\n\t\t\tcolord( background ).toHsl().l - colord( foreground ).toHsl().l\n\t\t) / 100;\n\n\tconst result: Record< number, string > = {};\n\n\tObject.entries( SHADES ).forEach( ( [ key, value ] ) => {\n\t\tresult[ parseInt( key ) ] = colord( background )\n\t\t\t[ direction ]( ( value / limit ) * range )\n\t\t\t.toHex();\n\t} );\n\n\treturn result as NonNullable< ThemeOutputValues[ 'colors' ][ 'gray' ] >;\n}\n"]}
|
package/build/theme/index.js
CHANGED
|
@@ -9,18 +9,18 @@ exports.default = void 0;
|
|
|
9
9
|
|
|
10
10
|
var _element = require("@wordpress/element");
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
13
13
|
|
|
14
|
-
var
|
|
14
|
+
var _styles = require("./styles");
|
|
15
15
|
|
|
16
|
-
var
|
|
16
|
+
var _colorAlgorithms = require("./color-algorithms");
|
|
17
17
|
|
|
18
|
-
var
|
|
18
|
+
var _utils = require("../utils");
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
|
-
*
|
|
21
|
+
* WordPress dependencies
|
|
22
22
|
*/
|
|
23
|
-
|
|
23
|
+
|
|
24
24
|
/**
|
|
25
25
|
* `Theme` allows defining theme variables for components in the `@wordpress/components` package.
|
|
26
26
|
*
|
|
@@ -43,18 +43,21 @@ var _styles = require("./styles");
|
|
|
43
43
|
* };
|
|
44
44
|
* ```
|
|
45
45
|
*/
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
46
|
+
function Theme(_ref) {
|
|
47
|
+
let {
|
|
48
|
+
accent,
|
|
49
|
+
background,
|
|
50
|
+
className,
|
|
51
|
+
...props
|
|
52
|
+
} = _ref;
|
|
53
|
+
const cx = (0, _utils.useCx)();
|
|
54
|
+
const classes = (0, _element.useMemo)(() => cx(...(0, _styles.colorVariables)((0, _colorAlgorithms.generateThemeVariables)({
|
|
55
|
+
accent,
|
|
56
|
+
background
|
|
57
|
+
})), className), [accent, background, className, cx]);
|
|
58
|
+
return (0, _element.createElement)(_styles.Wrapper, (0, _extends2.default)({
|
|
59
|
+
className: classes
|
|
60
|
+
}, props));
|
|
58
61
|
}
|
|
59
62
|
|
|
60
63
|
var _default = Theme;
|
package/build/theme/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/components/src/theme/index.tsx"],"names":["
|
|
1
|
+
{"version":3,"sources":["@wordpress/components/src/theme/index.tsx"],"names":["Theme","accent","background","className","props","cx","classes"],"mappings":";;;;;;;;;AAGA;;;;AAOA;;AACA;;AACA;;AAZA;AACA;AACA;;AAYA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,KAAT,OAKwD;AAAA,MALxC;AACfC,IAAAA,MADe;AAEfC,IAAAA,UAFe;AAGfC,IAAAA,SAHe;AAIf,OAAGC;AAJY,GAKwC;AACvD,QAAMC,EAAE,GAAG,mBAAX;AACA,QAAMC,OAAO,GAAG,sBACf,MACCD,EAAE,CACD,GAAG,4BACF,6CAAwB;AAAEJ,IAAAA,MAAF;AAAUC,IAAAA;AAAV,GAAxB,CADE,CADF,EAIDC,SAJC,CAFY,EAQf,CAAEF,MAAF,EAAUC,UAAV,EAAsBC,SAAtB,EAAiCE,EAAjC,CARe,CAAhB;AAWA,SAAO,4BAAC,eAAD;AAAS,IAAA,SAAS,EAAGC;AAArB,KAAoCF,KAApC,EAAP;AACA;;eAEcJ,K","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport type { ThemeProps } from './types';\nimport type { WordPressComponentProps } from '../ui/context';\nimport { colorVariables, Wrapper } from './styles';\nimport { generateThemeVariables } from './color-algorithms';\nimport { useCx } from '../utils';\n\n/**\n * `Theme` allows defining theme variables for components in the `@wordpress/components` package.\n *\n * Multiple `Theme` components can be nested in order to override specific theme variables.\n *\n *\n * @example\n * ```jsx\n * import { __experimentalTheme as Theme } from '@wordpress/components';\n *\n * const Example = () => {\n * return (\n * <Theme accent=\"red\">\n * <Button variant=\"primary\">I'm red</Button>\n * <Theme accent=\"blue\">\n * <Button variant=\"primary\">I'm blue</Button>\n * </Theme>\n * </Theme>\n * );\n * };\n * ```\n */\nfunction Theme( {\n\taccent,\n\tbackground,\n\tclassName,\n\t...props\n}: WordPressComponentProps< ThemeProps, 'div', true > ) {\n\tconst cx = useCx();\n\tconst classes = useMemo(\n\t\t() =>\n\t\t\tcx(\n\t\t\t\t...colorVariables(\n\t\t\t\t\tgenerateThemeVariables( { accent, background } )\n\t\t\t\t),\n\t\t\t\tclassName\n\t\t\t),\n\t\t[ accent, background, className, cx ]\n\t);\n\n\treturn <Wrapper className={ classes } { ...props } />;\n}\n\nexport default Theme;\n"]}
|