@wordpress/components 21.1.2-next.4d3b314fd5.0 → 21.3.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 +48 -3
- package/CONTRIBUTING.md +20 -0
- package/build/border-box-control/border-box-control/component.js +2 -0
- package/build/border-box-control/border-box-control/component.js.map +1 -1
- package/build/border-box-control/border-box-control/hook.js +4 -1
- package/build/border-box-control/border-box-control/hook.js.map +1 -1
- package/build/border-box-control/utils.js +42 -2
- package/build/border-box-control/utils.js.map +1 -1
- package/build/border-control/border-control/component.js +2 -0
- package/build/border-control/border-control/component.js.map +1 -1
- package/build/combobox-control/index.js +0 -1
- package/build/combobox-control/index.js.map +1 -1
- package/build/custom-select-control/index.js +4 -2
- package/build/custom-select-control/index.js.map +1 -1
- package/build/disabled/index.js +6 -26
- package/build/disabled/index.js.map +1 -1
- package/build/font-size-picker/index.js +47 -56
- package/build/font-size-picker/index.js.map +1 -1
- package/build/font-size-picker/styles.js +65 -0
- package/build/font-size-picker/styles.js.map +1 -0
- package/build/font-size-picker/types.js +6 -0
- package/build/font-size-picker/types.js.map +1 -0
- package/build/font-size-picker/utils.js +18 -16
- package/build/font-size-picker/utils.js.map +1 -1
- package/build/form-token-field/suggestions-list.js +5 -5
- package/build/form-token-field/suggestions-list.js.map +1 -1
- package/build/form-token-field/token-input.js +20 -1
- package/build/form-token-field/token-input.js.map +1 -1
- package/build/higher-order/with-fallback-styles/index.js +1 -1
- package/build/higher-order/with-fallback-styles/index.js.map +1 -1
- package/build/index.js +14 -6
- package/build/index.js.map +1 -1
- package/build/modal/aria-helper.js +2 -3
- package/build/modal/aria-helper.js.map +1 -1
- package/build/modal/index.js +42 -11
- package/build/modal/index.js.map +1 -1
- package/build/modal/types.js +6 -0
- package/build/modal/types.js.map +1 -0
- package/build/navigator/index.js +8 -8
- package/build/navigator/index.js.map +1 -1
- package/build/navigator/navigator-back-button/component.js +5 -4
- package/build/navigator/navigator-back-button/component.js.map +1 -1
- package/build/navigator/navigator-back-button/index.js +1 -1
- package/build/navigator/navigator-back-button/index.js.map +1 -1
- package/build/navigator/navigator-button/component.js +5 -4
- package/build/navigator/navigator-button/component.js.map +1 -1
- package/build/navigator/navigator-button/index.js +1 -1
- package/build/navigator/navigator-button/index.js.map +1 -1
- package/build/navigator/navigator-provider/component.js +10 -7
- package/build/navigator/navigator-provider/component.js.map +1 -1
- package/build/navigator/navigator-provider/index.js +1 -1
- package/build/navigator/navigator-provider/index.js.map +1 -1
- package/build/navigator/navigator-screen/component.js +30 -26
- package/build/navigator/navigator-screen/component.js.map +1 -1
- package/build/navigator/navigator-screen/index.js +1 -1
- package/build/navigator/navigator-screen/index.js.map +1 -1
- package/build/resizable-box/resize-tooltip/utils.js +12 -14
- package/build/resizable-box/resize-tooltip/utils.js.map +1 -1
- package/build/sandbox/index.js +68 -67
- package/build/sandbox/index.js.map +1 -1
- package/build/sandbox/index.native.js +66 -63
- package/build/sandbox/index.native.js.map +1 -1
- package/build/search-control/index.native.js +6 -2
- package/build/search-control/index.native.js.map +1 -1
- package/build/slot-fill/bubbles-virtually/slot-fill-context.js +8 -2
- package/build/slot-fill/bubbles-virtually/slot-fill-context.js.map +1 -1
- package/build/slot-fill/bubbles-virtually/slot-fill-provider.js +31 -41
- package/build/slot-fill/bubbles-virtually/slot-fill-provider.js.map +1 -1
- package/build/slot-fill/bubbles-virtually/use-slot-fills.js +39 -0
- package/build/slot-fill/bubbles-virtually/use-slot-fills.js.map +1 -0
- package/build/slot-fill/bubbles-virtually/use-slot.js +13 -4
- package/build/slot-fill/bubbles-virtually/use-slot.js.map +1 -1
- package/build/slot-fill/index.js +8 -0
- package/build/slot-fill/index.js.map +1 -1
- package/build/tab-panel/index.js +4 -4
- package/build/tab-panel/index.js.map +1 -1
- package/build/theme/index.js +62 -0
- package/build/theme/index.js.map +1 -0
- package/build/theme/styles.js +33 -0
- package/build/theme/styles.js.map +1 -0
- package/build/theme/types.js +6 -0
- package/build/theme/types.js.map +1 -0
- package/build/toggle-group-control/toggle-group-control-option-base/styles.js +8 -8
- package/build/toggle-group-control/toggle-group-control-option-base/styles.js.map +1 -1
- package/build/tools-panel/tools-panel/hook.js +3 -3
- package/build/tools-panel/tools-panel/hook.js.map +1 -1
- package/build/tools-panel/tools-panel-item/hook.js +6 -6
- package/build/tools-panel/tools-panel-item/hook.js.map +1 -1
- package/build/tooltip/index.js +4 -1
- package/build/tooltip/index.js.map +1 -1
- package/build/tooltip/index.native.js +17 -4
- package/build/tooltip/index.native.js.map +1 -1
- package/build-module/border-box-control/border-box-control/component.js +2 -0
- 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 +4 -1
- package/build-module/border-box-control/border-box-control/hook.js.map +1 -1
- package/build-module/border-box-control/utils.js +36 -1
- package/build-module/border-box-control/utils.js.map +1 -1
- package/build-module/border-control/border-control/component.js +2 -0
- package/build-module/border-control/border-control/component.js.map +1 -1
- package/build-module/combobox-control/index.js +0 -1
- package/build-module/combobox-control/index.js.map +1 -1
- package/build-module/custom-select-control/index.js +2 -1
- package/build-module/custom-select-control/index.js.map +1 -1
- package/build-module/disabled/index.js +7 -26
- package/build-module/disabled/index.js.map +1 -1
- package/build-module/font-size-picker/index.js +46 -54
- package/build-module/font-size-picker/index.js.map +1 -1
- package/build-module/font-size-picker/styles.js +54 -0
- package/build-module/font-size-picker/styles.js.map +1 -0
- package/build-module/font-size-picker/types.js +2 -0
- package/build-module/font-size-picker/types.js.map +1 -0
- package/build-module/font-size-picker/utils.js +22 -16
- package/build-module/font-size-picker/utils.js.map +1 -1
- package/build-module/form-token-field/suggestions-list.js +5 -5
- package/build-module/form-token-field/suggestions-list.js.map +1 -1
- package/build-module/form-token-field/token-input.js +21 -2
- package/build-module/form-token-field/token-input.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 +3 -2
- package/build-module/index.js.map +1 -1
- package/build-module/modal/aria-helper.js +2 -3
- package/build-module/modal/aria-helper.js.map +1 -1
- package/build-module/modal/index.js +44 -12
- package/build-module/modal/index.js.map +1 -1
- package/build-module/modal/types.js +2 -0
- package/build-module/modal/types.js.map +1 -0
- package/build-module/navigator/index.js +4 -4
- package/build-module/navigator/index.js.map +1 -1
- package/build-module/navigator/navigator-back-button/component.js +3 -3
- package/build-module/navigator/navigator-back-button/component.js.map +1 -1
- package/build-module/navigator/navigator-back-button/index.js +1 -1
- package/build-module/navigator/navigator-back-button/index.js.map +1 -1
- package/build-module/navigator/navigator-button/component.js +3 -3
- package/build-module/navigator/navigator-button/component.js.map +1 -1
- package/build-module/navigator/navigator-button/index.js +1 -1
- package/build-module/navigator/navigator-button/index.js.map +1 -1
- package/build-module/navigator/navigator-provider/component.js +8 -6
- package/build-module/navigator/navigator-provider/component.js.map +1 -1
- package/build-module/navigator/navigator-provider/index.js +1 -1
- package/build-module/navigator/navigator-provider/index.js.map +1 -1
- package/build-module/navigator/navigator-screen/component.js +18 -25
- package/build-module/navigator/navigator-screen/component.js.map +1 -1
- package/build-module/navigator/navigator-screen/index.js +1 -1
- package/build-module/navigator/navigator-screen/index.js.map +1 -1
- package/build-module/resizable-box/resize-tooltip/utils.js +13 -15
- package/build-module/resizable-box/resize-tooltip/utils.js.map +1 -1
- package/build-module/sandbox/index.js +69 -67
- package/build-module/sandbox/index.js.map +1 -1
- package/build-module/sandbox/index.native.js +57 -53
- package/build-module/sandbox/index.native.js.map +1 -1
- package/build-module/search-control/index.native.js +6 -2
- package/build-module/search-control/index.native.js.map +1 -1
- package/build-module/slot-fill/bubbles-virtually/slot-fill-context.js +7 -2
- package/build-module/slot-fill/bubbles-virtually/slot-fill-context.js.map +1 -1
- package/build-module/slot-fill/bubbles-virtually/slot-fill-provider.js +30 -42
- package/build-module/slot-fill/bubbles-virtually/slot-fill-provider.js.map +1 -1
- package/build-module/slot-fill/bubbles-virtually/use-slot-fills.js +27 -0
- package/build-module/slot-fill/bubbles-virtually/use-slot-fills.js.map +1 -0
- package/build-module/slot-fill/bubbles-virtually/use-slot.js +13 -5
- package/build-module/slot-fill/bubbles-virtually/use-slot.js.map +1 -1
- package/build-module/slot-fill/index.js +1 -0
- package/build-module/slot-fill/index.js.map +1 -1
- package/build-module/tab-panel/index.js +4 -4
- package/build-module/tab-panel/index.js.map +1 -1
- package/build-module/theme/index.js +52 -0
- package/build-module/theme/index.js.map +1 -0
- package/build-module/theme/styles.js +25 -0
- package/build-module/theme/styles.js.map +1 -0
- package/build-module/theme/types.js +2 -0
- package/build-module/theme/types.js.map +1 -0
- package/build-module/toggle-group-control/toggle-group-control-option-base/styles.js +7 -7
- package/build-module/toggle-group-control/toggle-group-control-option-base/styles.js.map +1 -1
- package/build-module/tools-panel/tools-panel/hook.js +3 -3
- package/build-module/tools-panel/tools-panel/hook.js.map +1 -1
- package/build-module/tools-panel/tools-panel-item/hook.js +6 -6
- package/build-module/tools-panel/tools-panel-item/hook.js.map +1 -1
- package/build-module/tooltip/index.js +4 -1
- package/build-module/tooltip/index.js.map +1 -1
- package/build-module/tooltip/index.native.js +17 -4
- package/build-module/tooltip/index.native.js.map +1 -1
- package/build-style/style-rtl.css +27 -120
- package/build-style/style.css +27 -120
- 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 +1 -0
- package/build-types/border-box-control/border-box-control/hook.d.ts.map +1 -1
- package/build-types/border-box-control/utils.d.ts +1 -3
- package/build-types/border-box-control/utils.d.ts.map +1 -1
- package/build-types/border-control/border-control/component.d.ts +1 -0
- package/build-types/border-control/border-control/component.d.ts.map +1 -1
- package/build-types/border-control/border-control/hook.d.ts +1 -0
- package/build-types/border-control/border-control/hook.d.ts.map +1 -1
- package/build-types/border-control/stories/index.d.ts +6 -0
- package/build-types/border-control/stories/index.d.ts.map +1 -1
- package/build-types/border-control/types.d.ts +4 -0
- package/build-types/border-control/types.d.ts.map +1 -1
- package/build-types/confirm-dialog/types.d.ts +5 -1
- package/build-types/confirm-dialog/types.d.ts.map +1 -1
- package/build-types/custom-select-control/index.d.ts +13 -0
- package/build-types/custom-select-control/index.d.ts.map +1 -0
- package/build-types/custom-select-control/styles.d.ts +9 -0
- package/build-types/custom-select-control/styles.d.ts.map +1 -0
- package/build-types/disabled/index.d.ts.map +1 -1
- package/build-types/font-size-picker/index.d.ts +5 -0
- package/build-types/font-size-picker/index.d.ts.map +1 -0
- package/build-types/font-size-picker/stories/e2e/index.d.ts +16 -0
- package/build-types/font-size-picker/stories/e2e/index.d.ts.map +1 -0
- package/build-types/font-size-picker/stories/index.d.ts +31 -0
- package/build-types/font-size-picker/stories/index.d.ts.map +1 -0
- package/build-types/font-size-picker/styles.d.ts +27 -0
- package/build-types/font-size-picker/styles.d.ts.map +1 -0
- package/build-types/font-size-picker/test/index.d.ts +2 -0
- package/build-types/font-size-picker/test/index.d.ts.map +1 -0
- package/build-types/font-size-picker/test/utils.d.ts +2 -0
- package/build-types/font-size-picker/test/utils.d.ts.map +1 -0
- package/build-types/font-size-picker/types.d.ts +93 -0
- package/build-types/font-size-picker/types.d.ts.map +1 -0
- package/build-types/font-size-picker/utils.d.ts +41 -0
- package/build-types/font-size-picker/utils.d.ts.map +1 -0
- package/build-types/form-token-field/token-input.d.ts.map +1 -1
- package/build-types/modal/aria-helper.d.ts +4 -4
- package/build-types/modal/aria-helper.d.ts.map +1 -1
- package/build-types/modal/index.d.ts +35 -2
- package/build-types/modal/index.d.ts.map +1 -1
- package/build-types/modal/stories/index.d.ts +9 -0
- package/build-types/modal/stories/index.d.ts.map +1 -0
- package/build-types/modal/test/aria-helper.d.ts +2 -0
- package/build-types/modal/test/aria-helper.d.ts.map +1 -0
- package/build-types/modal/test/index.d.ts +2 -0
- package/build-types/modal/test/index.d.ts.map +1 -0
- package/build-types/modal/types.d.ts +134 -0
- package/build-types/modal/types.d.ts.map +1 -0
- package/build-types/navigator/index.d.ts +4 -4
- package/build-types/navigator/index.d.ts.map +1 -1
- package/build-types/navigator/navigator-back-button/component.d.ts +4 -2
- package/build-types/navigator/navigator-back-button/component.d.ts.map +1 -1
- package/build-types/navigator/navigator-back-button/hook.d.ts +1 -0
- package/build-types/navigator/navigator-back-button/hook.d.ts.map +1 -1
- package/build-types/navigator/navigator-back-button/index.d.ts +1 -1
- package/build-types/navigator/navigator-back-button/index.d.ts.map +1 -1
- package/build-types/navigator/navigator-button/component.d.ts +4 -2
- package/build-types/navigator/navigator-button/component.d.ts.map +1 -1
- package/build-types/navigator/navigator-button/hook.d.ts +1 -0
- package/build-types/navigator/navigator-button/hook.d.ts.map +1 -1
- package/build-types/navigator/navigator-button/index.d.ts +1 -1
- package/build-types/navigator/navigator-button/index.d.ts.map +1 -1
- package/build-types/navigator/navigator-provider/component.d.ts +2 -2
- package/build-types/navigator/navigator-provider/component.d.ts.map +1 -1
- package/build-types/navigator/navigator-provider/index.d.ts +1 -1
- package/build-types/navigator/navigator-provider/index.d.ts.map +1 -1
- package/build-types/navigator/navigator-screen/component.d.ts +2 -2
- package/build-types/navigator/navigator-screen/component.d.ts.map +1 -1
- package/build-types/navigator/navigator-screen/index.d.ts +1 -1
- package/build-types/navigator/navigator-screen/index.d.ts.map +1 -1
- package/build-types/navigator/stories/index.d.ts +9 -0
- package/build-types/navigator/stories/index.d.ts.map +1 -0
- package/build-types/navigator/test/index.d.ts +2 -0
- package/build-types/navigator/test/index.d.ts.map +1 -0
- package/build-types/navigator/types.d.ts +4 -1
- package/build-types/navigator/types.d.ts.map +1 -1
- package/build-types/slot-fill/bubbles-virtually/slot-fill-context.d.ts +2 -2
- package/build-types/slot-fill/bubbles-virtually/slot-fill-context.d.ts.map +1 -1
- package/build-types/slot-fill/bubbles-virtually/slot-fill-provider.d.ts.map +1 -1
- package/build-types/slot-fill/bubbles-virtually/use-slot-fills.d.ts +2 -0
- package/build-types/slot-fill/bubbles-virtually/use-slot-fills.d.ts.map +1 -0
- package/build-types/slot-fill/bubbles-virtually/use-slot.d.ts.map +1 -1
- package/build-types/slot-fill/index.d.ts +1 -0
- package/build-types/slot-fill/index.d.ts.map +1 -1
- package/build-types/tab-panel/index.d.ts.map +1 -1
- package/build-types/theme/index.d.ts +31 -0
- package/build-types/theme/index.d.ts.map +1 -0
- package/build-types/theme/stories/index.d.ts +13 -0
- package/build-types/theme/stories/index.d.ts.map +1 -0
- package/build-types/theme/styles.d.ts +10 -0
- package/build-types/theme/styles.d.ts.map +1 -0
- package/build-types/theme/test/index.d.ts +2 -0
- package/build-types/theme/test/index.d.ts.map +1 -0
- package/build-types/theme/types.d.ts +21 -0
- package/build-types/theme/types.d.ts.map +1 -0
- package/build-types/toggle-group-control/toggle-group-control-option-base/styles.d.ts +1 -1
- package/build-types/toggle-group-control/toggle-group-control-option-base/styles.d.ts.map +1 -1
- package/build-types/tools-panel/tools-panel/hook.d.ts.map +1 -1
- package/build-types/tools-panel/tools-panel-item/hook.d.ts.map +1 -1
- package/build-types/tooltip/index.d.ts.map +1 -1
- package/package.json +19 -18
- package/src/alignment-matrix-control/test/index.js +17 -62
- package/src/base-field/test/index.js +4 -6
- package/src/border-box-control/border-box-control/component.tsx +2 -0
- package/src/border-box-control/border-box-control/hook.ts +4 -0
- package/src/border-box-control/test/index.js +7 -2
- package/src/border-box-control/test/utils.js +48 -0
- package/src/border-box-control/utils.ts +44 -1
- package/src/border-control/border-control/README.md +6 -0
- package/src/border-control/border-control/component.tsx +2 -0
- package/src/border-control/types.ts +4 -0
- package/src/button/style.scss +25 -25
- package/src/button/test/index.js +3 -5
- package/src/combobox-control/index.js +0 -5
- package/src/combobox-control/test/index.js +1 -1
- package/src/confirm-dialog/types.ts +6 -0
- package/src/custom-select-control/index.js +2 -1
- package/src/date-time/time/test/index.tsx +2 -6
- package/src/disabled/index.tsx +11 -33
- package/src/disabled/test/index.tsx +14 -82
- package/src/dropdown/test/index.js +4 -3
- package/src/font-size-picker/{index.js → index.tsx} +114 -80
- package/src/font-size-picker/stories/e2e/{index.js → index.tsx} +13 -4
- package/src/font-size-picker/stories/{index.js → index.tsx} +42 -36
- package/src/font-size-picker/styles.ts +46 -0
- package/src/font-size-picker/test/{index.js → index.tsx} +3 -3
- package/src/font-size-picker/test/{utils.js → utils.ts} +11 -7
- package/src/font-size-picker/types.ts +98 -0
- package/src/font-size-picker/{utils.js → utils.ts} +52 -28
- package/src/form-file-upload/test/index.tsx +1 -1
- package/src/form-token-field/suggestions-list.tsx +5 -5
- package/src/form-token-field/test/index.tsx +22 -1
- package/src/form-token-field/token-input.tsx +25 -3
- package/src/higher-order/with-fallback-styles/index.js +6 -2
- package/src/higher-order/with-focus-outside/test/index.js +44 -45
- package/src/higher-order/with-focus-return/test/index.js +34 -30
- package/src/higher-order/with-notices/test/index.js +1 -1
- package/src/index.js +3 -1
- package/src/input-control/test/index.js +2 -2
- package/src/item-group/test/index.js +2 -2
- package/src/menu-item/test/index.js +0 -3
- package/src/mobile/bottom-sheet/test/range-cell.native.js +16 -14
- package/src/modal/README.md +53 -54
- package/src/modal/{aria-helper.js → aria-helper.ts} +5 -7
- package/src/modal/{index.js → index.tsx} +48 -12
- package/src/modal/stories/{index.js → index.tsx} +47 -42
- package/src/modal/test/{aria-helper.js → aria-helper.ts} +0 -0
- package/src/modal/test/{index.js → index.tsx} +13 -3
- package/src/modal/types.ts +144 -0
- package/src/navigation/test/index.js +1 -1
- package/src/navigator/index.ts +4 -4
- package/src/navigator/navigator-back-button/component.tsx +4 -4
- package/src/navigator/navigator-back-button/index.ts +1 -1
- package/src/navigator/navigator-button/component.tsx +4 -4
- package/src/navigator/navigator-button/index.ts +1 -1
- package/src/navigator/navigator-provider/component.tsx +6 -4
- package/src/navigator/navigator-provider/index.ts +1 -1
- package/src/navigator/navigator-screen/component.tsx +27 -26
- package/src/navigator/navigator-screen/index.ts +1 -1
- package/src/navigator/stories/index.tsx +210 -0
- package/src/navigator/test/index.tsx +509 -0
- package/src/navigator/types.ts +2 -0
- package/src/notice/test/__snapshots__/index.js.snap +39 -38
- package/src/notice/test/index.js +15 -36
- package/src/notice/test/list.js +6 -14
- package/src/number-control/test/index.js +3 -2
- package/src/panel/test/body.js +2 -2
- package/src/placeholder/style.scss +7 -2
- package/src/resizable-box/resize-tooltip/utils.ts +13 -13
- package/src/sandbox/index.js +75 -54
- package/src/sandbox/index.native.js +75 -52
- package/src/sandbox/test/index.js +7 -10
- package/src/search-control/index.native.js +6 -0
- package/src/shortcut/test/index.tsx +1 -1
- package/src/slot-fill/bubbles-virtually/slot-fill-context.js +6 -2
- package/src/slot-fill/bubbles-virtually/slot-fill-provider.js +53 -58
- package/src/slot-fill/bubbles-virtually/use-slot-fills.js +24 -0
- package/src/slot-fill/bubbles-virtually/use-slot.js +11 -6
- package/src/slot-fill/index.js +1 -0
- package/src/style.scss +4 -1
- package/src/tab-panel/index.tsx +4 -7
- package/src/text-highlight/test/index.tsx +1 -3
- package/src/theme/README.md +34 -0
- package/src/theme/index.tsx +51 -0
- package/src/theme/stories/index.tsx +47 -0
- package/src/theme/styles.ts +28 -0
- package/src/theme/test/index.tsx +101 -0
- package/src/theme/types.ts +21 -0
- package/src/toggle-group-control/test/__snapshots__/index.tsx.snap +1 -0
- package/src/toggle-group-control/toggle-group-control-option-base/styles.ts +9 -7
- package/src/toolbar/test/index.js +2 -2
- package/src/toolbar-group/test/index.js +6 -10
- package/src/tools-panel/test/index.js +4 -6
- package/src/tools-panel/tools-panel/hook.ts +2 -9
- package/src/tools-panel/tools-panel-item/hook.ts +17 -3
- package/src/tooltip/index.js +3 -0
- package/src/tooltip/index.native.js +15 -0
- package/src/tooltip/test/index.native.js +1 -2
- package/src/tree-grid/test/__snapshots__/cell.js.snap +1 -3
- package/src/tree-grid/test/__snapshots__/roving-tab-index-item.js.snap +17 -15
- package/src/tree-grid/test/__snapshots__/row.js.snap +25 -21
- package/src/tree-grid/test/cell.js +4 -4
- package/src/tree-grid/test/roving-tab-index-item.js +8 -8
- package/src/tree-grid/test/roving-tab-index.js +3 -3
- package/src/tree-grid/test/row.js +20 -16
- package/src/truncate/test/index.tsx +4 -4
- package/src/ui/shortcut/test/index.js +2 -1
- package/src/ui/spinner/test/index.js +14 -13
- package/src/ui/tooltip/test/index.js +16 -14
- package/src/utils/theme-variables.scss +8 -0
- package/src/visually-hidden/README.md +4 -0
- package/tsconfig.json +0 -2
- package/tsconfig.tsbuildinfo +1 -1
- package/src/font-size-picker/style.scss +0 -78
- package/src/navigator/stories/index.js +0 -194
- package/src/navigator/test/index.js +0 -407
|
@@ -115,6 +115,9 @@ function SearchControl( {
|
|
|
115
115
|
mergeFutureStyles( activeDarkStyles, [ isActive, isDark ] );
|
|
116
116
|
|
|
117
117
|
setCurrentStyles( futureStyles );
|
|
118
|
+
// Disable reason: deferring this refactor to the native team.
|
|
119
|
+
// see https://github.com/WordPress/gutenberg/pull/41166
|
|
120
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
118
121
|
}, [ isActive, isDark ] );
|
|
119
122
|
|
|
120
123
|
useEffect( () => {
|
|
@@ -130,6 +133,9 @@ function SearchControl( {
|
|
|
130
133
|
clearTimeout( onCancelTimer.current );
|
|
131
134
|
keyboardHideSubscription.remove();
|
|
132
135
|
};
|
|
136
|
+
// Disable reason: deferring this refactor to the native team.
|
|
137
|
+
// see https://github.com/WordPress/gutenberg/pull/41166
|
|
138
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
133
139
|
}, [] );
|
|
134
140
|
|
|
135
141
|
const {
|
|
@@ -11,7 +11,7 @@ import Shortcut from '..';
|
|
|
11
11
|
describe( 'Shortcut', () => {
|
|
12
12
|
it( 'does not render anything if no shortcut prop is provided', () => {
|
|
13
13
|
const { container } = render( <Shortcut /> );
|
|
14
|
-
expect( container
|
|
14
|
+
expect( container ).toBeEmptyDOMElement();
|
|
15
15
|
} );
|
|
16
16
|
|
|
17
17
|
it( 'renders the shortcut display text when a string is passed as the shortcut', () => {
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
|
+
/**
|
|
3
|
+
* External dependencies
|
|
4
|
+
*/
|
|
5
|
+
import { proxyMap } from 'valtio/utils';
|
|
2
6
|
/**
|
|
3
7
|
* WordPress dependencies
|
|
4
8
|
*/
|
|
@@ -6,8 +10,8 @@ import { createContext } from '@wordpress/element';
|
|
|
6
10
|
import warning from '@wordpress/warning';
|
|
7
11
|
|
|
8
12
|
const SlotFillContext = createContext( {
|
|
9
|
-
slots:
|
|
10
|
-
fills:
|
|
13
|
+
slots: proxyMap(),
|
|
14
|
+
fills: proxyMap(),
|
|
11
15
|
registerSlot: () => {
|
|
12
16
|
warning(
|
|
13
17
|
'Components must be wrapped within `SlotFillProvider`. ' +
|
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
|
+
/**
|
|
3
|
+
* External dependencies
|
|
4
|
+
*/
|
|
5
|
+
import { ref as valRef } from 'valtio';
|
|
6
|
+
import { proxyMap } from 'valtio/utils';
|
|
7
|
+
|
|
2
8
|
/**
|
|
3
9
|
* WordPress dependencies
|
|
4
10
|
*/
|
|
5
|
-
import { useMemo, useCallback,
|
|
11
|
+
import { useMemo, useCallback, useRef } from '@wordpress/element';
|
|
6
12
|
import isShallowEqual from '@wordpress/is-shallow-equal';
|
|
7
13
|
|
|
8
14
|
/**
|
|
@@ -11,79 +17,70 @@ import isShallowEqual from '@wordpress/is-shallow-equal';
|
|
|
11
17
|
import SlotFillContext from './slot-fill-context';
|
|
12
18
|
|
|
13
19
|
function useSlotRegistry() {
|
|
14
|
-
const
|
|
15
|
-
const
|
|
20
|
+
const slots = useRef( proxyMap() );
|
|
21
|
+
const fills = useRef( proxyMap() );
|
|
16
22
|
|
|
17
23
|
const registerSlot = useCallback( ( name, ref, fillProps ) => {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
};
|
|
28
|
-
} );
|
|
24
|
+
const slot = slots.current.get( name ) || {};
|
|
25
|
+
slots.current.set(
|
|
26
|
+
name,
|
|
27
|
+
valRef( {
|
|
28
|
+
...slot,
|
|
29
|
+
ref: ref || slot.ref,
|
|
30
|
+
fillProps: fillProps || slot.fillProps || {},
|
|
31
|
+
} )
|
|
32
|
+
);
|
|
29
33
|
}, [] );
|
|
30
34
|
|
|
31
35
|
const unregisterSlot = useCallback( ( name, ref ) => {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
return nextSlots;
|
|
38
|
-
}
|
|
39
|
-
return prevSlots;
|
|
40
|
-
} );
|
|
36
|
+
// Make sure we're not unregistering a slot registered by another element
|
|
37
|
+
// See https://github.com/WordPress/gutenberg/pull/19242#issuecomment-590295412
|
|
38
|
+
if ( slots.current.get( name )?.ref === ref ) {
|
|
39
|
+
slots.current.delete( name );
|
|
40
|
+
}
|
|
41
41
|
}, [] );
|
|
42
42
|
|
|
43
|
-
const updateSlot = useCallback(
|
|
44
|
-
( name
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
43
|
+
const updateSlot = useCallback( ( name, fillProps ) => {
|
|
44
|
+
const slot = slots.current.get( name );
|
|
45
|
+
if ( ! slot ) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if ( ! isShallowEqual( slot.fillProps, fillProps ) ) {
|
|
50
|
+
slot.fillProps = fillProps;
|
|
51
|
+
const slotFills = fills.current.get( name );
|
|
52
|
+
if ( slotFills ) {
|
|
53
|
+
// Force update fills.
|
|
54
|
+
slotFills.map( ( fill ) => fill.current.rerender() );
|
|
56
55
|
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
);
|
|
56
|
+
}
|
|
57
|
+
}, [] );
|
|
60
58
|
|
|
61
59
|
const registerFill = useCallback( ( name, ref ) => {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
60
|
+
fills.current.set(
|
|
61
|
+
name,
|
|
62
|
+
valRef( [ ...( fills.current.get( name ) || [] ), ref ] )
|
|
63
|
+
);
|
|
66
64
|
}, [] );
|
|
67
65
|
|
|
68
66
|
const unregisterFill = useCallback( ( name, ref ) => {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
(
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
} );
|
|
67
|
+
if ( fills.current.get( name ) ) {
|
|
68
|
+
fills.current.set(
|
|
69
|
+
name,
|
|
70
|
+
valRef(
|
|
71
|
+
fills.current
|
|
72
|
+
.get( name )
|
|
73
|
+
.filter( ( fillRef ) => fillRef !== ref )
|
|
74
|
+
)
|
|
75
|
+
);
|
|
76
|
+
}
|
|
80
77
|
}, [] );
|
|
81
78
|
|
|
82
79
|
// Memoizing the return value so it can be directly passed to Provider value
|
|
83
80
|
const registry = useMemo(
|
|
84
81
|
() => ( {
|
|
85
|
-
slots,
|
|
86
|
-
fills,
|
|
82
|
+
slots: slots.current,
|
|
83
|
+
fills: fills.current,
|
|
87
84
|
registerSlot,
|
|
88
85
|
updateSlot,
|
|
89
86
|
unregisterSlot,
|
|
@@ -91,8 +88,6 @@ function useSlotRegistry() {
|
|
|
91
88
|
unregisterFill,
|
|
92
89
|
} ),
|
|
93
90
|
[
|
|
94
|
-
slots,
|
|
95
|
-
fills,
|
|
96
91
|
registerSlot,
|
|
97
92
|
updateSlot,
|
|
98
93
|
unregisterSlot,
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
/**
|
|
3
|
+
* External dependencies
|
|
4
|
+
*/
|
|
5
|
+
import { useSnapshot } from 'valtio';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* WordPress dependencies
|
|
9
|
+
*/
|
|
10
|
+
import { useContext } from '@wordpress/element';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Internal dependencies
|
|
14
|
+
*/
|
|
15
|
+
import SlotFillContext from './slot-fill-context';
|
|
16
|
+
|
|
17
|
+
export default function useSlotFills( name ) {
|
|
18
|
+
const registry = useContext( SlotFillContext );
|
|
19
|
+
const fills = useSnapshot( registry.fills, { sync: true } );
|
|
20
|
+
// The important bit here is that this call ensures that the hook
|
|
21
|
+
// only causes a re-render if the "fills" of a given slot name
|
|
22
|
+
// change change, not any fills.
|
|
23
|
+
return fills.get( name );
|
|
24
|
+
}
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
|
+
/**
|
|
3
|
+
* External dependencies
|
|
4
|
+
*/
|
|
5
|
+
import { useSnapshot } from 'valtio';
|
|
6
|
+
|
|
2
7
|
/**
|
|
3
8
|
* WordPress dependencies
|
|
4
9
|
*/
|
|
5
|
-
import { useCallback, useContext
|
|
10
|
+
import { useCallback, useContext } from '@wordpress/element';
|
|
6
11
|
|
|
7
12
|
/**
|
|
8
13
|
* Internal dependencies
|
|
@@ -11,10 +16,11 @@ import SlotFillContext from './slot-fill-context';
|
|
|
11
16
|
|
|
12
17
|
export default function useSlot( name ) {
|
|
13
18
|
const registry = useContext( SlotFillContext );
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
19
|
+
const slots = useSnapshot( registry.slots, { sync: true } );
|
|
20
|
+
// The important bit here is that this call ensures
|
|
21
|
+
// the hook only causes a re-render if the slot
|
|
22
|
+
// with the given name change, not any other slot.
|
|
23
|
+
const slot = slots.get( name );
|
|
18
24
|
|
|
19
25
|
const updateSlot = useCallback(
|
|
20
26
|
( fillProps ) => {
|
|
@@ -48,7 +54,6 @@ export default function useSlot( name ) {
|
|
|
48
54
|
...slot,
|
|
49
55
|
updateSlot,
|
|
50
56
|
unregisterSlot,
|
|
51
|
-
fills,
|
|
52
57
|
registerFill,
|
|
53
58
|
unregisterFill,
|
|
54
59
|
};
|
package/src/slot-fill/index.js
CHANGED
|
@@ -14,6 +14,7 @@ import BubblesVirtuallySlot from './bubbles-virtually/slot';
|
|
|
14
14
|
import BubblesVirtuallySlotFillProvider from './bubbles-virtually/slot-fill-provider';
|
|
15
15
|
import SlotFillProvider from './provider';
|
|
16
16
|
import useSlot from './bubbles-virtually/use-slot';
|
|
17
|
+
export { default as useSlotFills } from './bubbles-virtually/use-slot-fills';
|
|
17
18
|
|
|
18
19
|
export function Fill( props ) {
|
|
19
20
|
// We're adding both Fills here so they can register themselves before
|
package/src/style.scss
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
// Variables
|
|
2
|
+
@import "./utils/theme-variables.scss";
|
|
3
|
+
|
|
4
|
+
// Components
|
|
1
5
|
@import "./animate/style.scss";
|
|
2
6
|
@import "./autocomplete/style.scss";
|
|
3
7
|
@import "./button-group/style.scss";
|
|
@@ -17,7 +21,6 @@
|
|
|
17
21
|
@import "./dropdown/style.scss";
|
|
18
22
|
@import "./dropdown-menu/style.scss";
|
|
19
23
|
@import "./duotone-picker/style.scss";
|
|
20
|
-
@import "./font-size-picker/style.scss";
|
|
21
24
|
@import "./form-toggle/style.scss";
|
|
22
25
|
@import "./form-token-field/style.scss";
|
|
23
26
|
@import "./guide/style.scss";
|
package/src/tab-panel/index.tsx
CHANGED
|
@@ -85,7 +85,7 @@ export function TabPanel( {
|
|
|
85
85
|
const instanceId = useInstanceId( TabPanel, 'tab-panel' );
|
|
86
86
|
const [ selected, setSelected ] = useState< string >();
|
|
87
87
|
|
|
88
|
-
const
|
|
88
|
+
const handleTabSelection = ( tabKey: string ) => {
|
|
89
89
|
setSelected( tabKey );
|
|
90
90
|
onSelect?.( tabKey );
|
|
91
91
|
};
|
|
@@ -98,11 +98,8 @@ export function TabPanel( {
|
|
|
98
98
|
|
|
99
99
|
useEffect( () => {
|
|
100
100
|
const newSelectedTab = find( tabs, { name: selected } );
|
|
101
|
-
if ( ! newSelectedTab ) {
|
|
102
|
-
|
|
103
|
-
initialTabName ||
|
|
104
|
-
( tabs.length > 0 ? tabs[ 0 ].name : undefined )
|
|
105
|
-
);
|
|
101
|
+
if ( ! newSelectedTab && tabs.length > 0 ) {
|
|
102
|
+
handleTabSelection( initialTabName || tabs[ 0 ].name );
|
|
106
103
|
}
|
|
107
104
|
}, [ tabs ] );
|
|
108
105
|
|
|
@@ -127,7 +124,7 @@ export function TabPanel( {
|
|
|
127
124
|
aria-controls={ `${ instanceId }-${ tab.name }-view` }
|
|
128
125
|
selected={ tab.name === selected }
|
|
129
126
|
key={ tab.name }
|
|
130
|
-
onClick={ () =>
|
|
127
|
+
onClick={ () => handleTabSelection( tab.name ) }
|
|
131
128
|
>
|
|
132
129
|
{ tab.title }
|
|
133
130
|
</TabButton>
|
|
@@ -50,9 +50,7 @@ describe( 'TextHighlight', () => {
|
|
|
50
50
|
expect( highlightedEls ).toHaveLength( 2 );
|
|
51
51
|
|
|
52
52
|
highlightedEls.forEach( ( el ) => {
|
|
53
|
-
expect( el
|
|
54
|
-
expect.stringContaining( highlight )
|
|
55
|
-
);
|
|
53
|
+
expect( el ).toHaveTextContent( highlight );
|
|
56
54
|
} );
|
|
57
55
|
} );
|
|
58
56
|
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Theme
|
|
2
|
+
|
|
3
|
+
<div class="callout callout-alert">
|
|
4
|
+
This feature is still experimental. “Experimental” means this is an early implementation subject to drastic and breaking changes.
|
|
5
|
+
</div>
|
|
6
|
+
|
|
7
|
+
`Theme` allows defining theme variables for components in the `@wordpress/components` package.
|
|
8
|
+
|
|
9
|
+
Multiple `Theme` components can be nested in order to override specific theme variables.
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```jsx
|
|
14
|
+
import { __experimentalTheme as Theme } from '@wordpress/components';
|
|
15
|
+
|
|
16
|
+
const Example = () => {
|
|
17
|
+
return (
|
|
18
|
+
<Theme accent="red">
|
|
19
|
+
<Button variant="primary">I'm red</Button>
|
|
20
|
+
<Theme accent="blue">
|
|
21
|
+
<Button variant="primary">I'm blue</Button>
|
|
22
|
+
</Theme>
|
|
23
|
+
</Theme>
|
|
24
|
+
);
|
|
25
|
+
};
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Props
|
|
29
|
+
|
|
30
|
+
### `accent`: `string`
|
|
31
|
+
|
|
32
|
+
Used to set the accent color (used by components as the primary color). If an accent color is not defined, the default fallback value is the original WP Admin main theme color. No all valid CSS color syntaxes are supported — in particular, keywords (like `'currentcolor'`, `'inherit'`, `'initial'`, `'revert'`, `'unset'`...) and CSS custom properties (e.g. `var(--my-custom-property)`) are _not_ supported values for this property.
|
|
33
|
+
|
|
34
|
+
- Required: No
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { colord, extend } from 'colord';
|
|
5
|
+
import a11yPlugin from 'colord/plugins/a11y';
|
|
6
|
+
import namesPlugin from 'colord/plugins/names';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Internal dependencies
|
|
10
|
+
*/
|
|
11
|
+
import type { ThemeProps } from './types';
|
|
12
|
+
import type { WordPressComponentProps } from '../ui/context';
|
|
13
|
+
import { Wrapper } from './styles';
|
|
14
|
+
|
|
15
|
+
extend( [ namesPlugin, a11yPlugin ] );
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* `Theme` allows defining theme variables for components in the `@wordpress/components` package.
|
|
19
|
+
*
|
|
20
|
+
* Multiple `Theme` components can be nested in order to override specific theme variables.
|
|
21
|
+
*
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```jsx
|
|
25
|
+
* import { __experimentalTheme as Theme } from '@wordpress/components';
|
|
26
|
+
*
|
|
27
|
+
* const Example = () => {
|
|
28
|
+
* return (
|
|
29
|
+
* <Theme accent="red">
|
|
30
|
+
* <Button variant="primary">I'm red</Button>
|
|
31
|
+
* <Theme accent="blue">
|
|
32
|
+
* <Button variant="primary">I'm blue</Button>
|
|
33
|
+
* </Theme>
|
|
34
|
+
* </Theme>
|
|
35
|
+
* );
|
|
36
|
+
* };
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
function Theme( props: WordPressComponentProps< ThemeProps, 'div', true > ) {
|
|
40
|
+
const { accent } = props;
|
|
41
|
+
if ( accent && ! colord( accent ).isValid() ) {
|
|
42
|
+
// eslint-disable-next-line no-console
|
|
43
|
+
console.warn(
|
|
44
|
+
`wp.components.Theme: "${ accent }" is not a valid color value for the 'accent' prop.`
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return <Wrapper { ...props } />;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export default Theme;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import type { ComponentMeta, ComponentStory } from '@storybook/react';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
import Theme from '../index';
|
|
10
|
+
import Button from '../../button';
|
|
11
|
+
|
|
12
|
+
const meta: ComponentMeta< typeof Theme > = {
|
|
13
|
+
component: Theme,
|
|
14
|
+
title: 'Components (Experimental)/Theme',
|
|
15
|
+
argTypes: {
|
|
16
|
+
accent: { control: { type: 'color' } },
|
|
17
|
+
},
|
|
18
|
+
parameters: {
|
|
19
|
+
controls: { expanded: true },
|
|
20
|
+
docs: { source: { state: 'open' } },
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
export default meta;
|
|
24
|
+
|
|
25
|
+
const Template: ComponentStory< typeof Theme > = ( args ) => (
|
|
26
|
+
<Theme { ...args }>
|
|
27
|
+
<Button variant="primary">Hello</Button>
|
|
28
|
+
</Theme>
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
export const Default = Template.bind( {} );
|
|
32
|
+
Default.args = {};
|
|
33
|
+
|
|
34
|
+
export const Nested: ComponentStory< typeof Theme > = ( args ) => (
|
|
35
|
+
<Theme accent="tomato">
|
|
36
|
+
<Button variant="primary">Outer theme (hardcoded)</Button>
|
|
37
|
+
|
|
38
|
+
<Theme { ...args }>
|
|
39
|
+
<Button variant="primary">
|
|
40
|
+
Inner theme (set via Storybook controls)
|
|
41
|
+
</Button>
|
|
42
|
+
</Theme>
|
|
43
|
+
</Theme>
|
|
44
|
+
);
|
|
45
|
+
Nested.args = {
|
|
46
|
+
accent: 'blue',
|
|
47
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { colord } from 'colord';
|
|
5
|
+
import styled from '@emotion/styled';
|
|
6
|
+
import { css } from '@emotion/react';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Internal dependencies
|
|
10
|
+
*/
|
|
11
|
+
import type { ThemeProps } from './types';
|
|
12
|
+
|
|
13
|
+
const accentColor = ( { accent }: ThemeProps ) =>
|
|
14
|
+
accent
|
|
15
|
+
? css`
|
|
16
|
+
--wp-components-color-accent: ${ accent };
|
|
17
|
+
--wp-components-color-accent-darker-10: ${ colord( accent )
|
|
18
|
+
.darken( 0.1 )
|
|
19
|
+
.toHex() };
|
|
20
|
+
--wp-components-color-accent-darker-20: ${ colord( accent )
|
|
21
|
+
.darken( 0.2 )
|
|
22
|
+
.toHex() };
|
|
23
|
+
`
|
|
24
|
+
: undefined;
|
|
25
|
+
|
|
26
|
+
export const Wrapper = styled.div< ThemeProps >`
|
|
27
|
+
${ accentColor }
|
|
28
|
+
`;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { render, screen } from '@testing-library/react';
|
|
5
|
+
import type { ReactNode } from 'react';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Internal dependencies
|
|
9
|
+
*/
|
|
10
|
+
import Theme from '../';
|
|
11
|
+
|
|
12
|
+
type MyThemableComponentProps = {
|
|
13
|
+
children: ReactNode;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const MyThemableComponent = ( props: MyThemableComponentProps ) => {
|
|
17
|
+
return (
|
|
18
|
+
<div
|
|
19
|
+
{ ...props }
|
|
20
|
+
style={ {
|
|
21
|
+
color: 'var(--wp-components-color-accent)',
|
|
22
|
+
} }
|
|
23
|
+
/>
|
|
24
|
+
);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
describe( 'Theme', () => {
|
|
28
|
+
describe( 'accent color', () => {
|
|
29
|
+
it( 'it does not define the accent color (and its variations) as a CSS variable when the `accent` prop is undefined', () => {
|
|
30
|
+
render(
|
|
31
|
+
<Theme>
|
|
32
|
+
<MyThemableComponent>Inner</MyThemableComponent>
|
|
33
|
+
</Theme>
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
const inner = screen.getByText( 'Inner' );
|
|
37
|
+
|
|
38
|
+
if ( inner?.parentElement === null ) {
|
|
39
|
+
throw new Error(
|
|
40
|
+
'Somehow the `Theme` component does not render a DOM element?'
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const innerElementStyles = window.getComputedStyle(
|
|
45
|
+
inner?.parentElement
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
expect(
|
|
49
|
+
innerElementStyles.getPropertyValue(
|
|
50
|
+
'--wp-components-color-accent'
|
|
51
|
+
)
|
|
52
|
+
).toBe( '' );
|
|
53
|
+
|
|
54
|
+
expect(
|
|
55
|
+
innerElementStyles.getPropertyValue(
|
|
56
|
+
'--wp-components-color-accent-darker-10'
|
|
57
|
+
)
|
|
58
|
+
).toBe( '' );
|
|
59
|
+
|
|
60
|
+
expect(
|
|
61
|
+
innerElementStyles.getPropertyValue(
|
|
62
|
+
'--wp-components-color-accent-darker-20'
|
|
63
|
+
)
|
|
64
|
+
).toBe( '' );
|
|
65
|
+
} );
|
|
66
|
+
|
|
67
|
+
it( 'it defines the accent color (and its variations) as a CSS variable', () => {
|
|
68
|
+
render(
|
|
69
|
+
<Theme accent="#123abc">
|
|
70
|
+
<MyThemableComponent>Inner</MyThemableComponent>
|
|
71
|
+
</Theme>
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
const inner = screen.getByText( 'Inner' );
|
|
75
|
+
|
|
76
|
+
expect( inner?.parentElement ).toHaveStyle( {
|
|
77
|
+
'--wp-components-color-accent': '#123abc',
|
|
78
|
+
'--wp-components-color-accent-darker-10': '#0e2c8d',
|
|
79
|
+
'--wp-components-color-accent-darker-20': '#091d5f',
|
|
80
|
+
} );
|
|
81
|
+
} );
|
|
82
|
+
|
|
83
|
+
describe( 'unsupported values', () => {
|
|
84
|
+
it.each( [
|
|
85
|
+
// Keywords
|
|
86
|
+
'currentcolor',
|
|
87
|
+
'initial',
|
|
88
|
+
'reset',
|
|
89
|
+
'inherit',
|
|
90
|
+
'revert',
|
|
91
|
+
'unset',
|
|
92
|
+
// CSS Custom properties
|
|
93
|
+
'var( --my-variable )',
|
|
94
|
+
] )( 'should warn when the value is "%s"', ( accentValue ) => {
|
|
95
|
+
render( <Theme accent={ accentValue } /> );
|
|
96
|
+
|
|
97
|
+
expect( console ).toHaveWarned();
|
|
98
|
+
} );
|
|
99
|
+
} );
|
|
100
|
+
} );
|
|
101
|
+
} );
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import type { ReactNode } from 'react';
|
|
5
|
+
|
|
6
|
+
export type ThemeProps = {
|
|
7
|
+
/**
|
|
8
|
+
* Used to set the accent color (used by components as the primary color).
|
|
9
|
+
*
|
|
10
|
+
* If an accent color is not defined, the default fallback value is the original
|
|
11
|
+
* WP Admin main theme color. No all valid CSS color syntaxes are supported —
|
|
12
|
+
* in particular, keywords (like `'currentcolor'`, `'inherit'`, `'initial'`,
|
|
13
|
+
* `'revert'`, `'unset'`...) and CSS custom properties (e.g.
|
|
14
|
+
* `var(--my-custom-property)`) are _not_ supported values for this property.
|
|
15
|
+
*/
|
|
16
|
+
accent?: string;
|
|
17
|
+
/**
|
|
18
|
+
* The children elements.
|
|
19
|
+
*/
|
|
20
|
+
children?: ReactNode;
|
|
21
|
+
};
|
|
@@ -55,13 +55,6 @@ export const buttonView = css`
|
|
|
55
55
|
}
|
|
56
56
|
`;
|
|
57
57
|
|
|
58
|
-
export const buttonActive = css`
|
|
59
|
-
color: ${ COLORS.white };
|
|
60
|
-
&:active {
|
|
61
|
-
background: transparent;
|
|
62
|
-
}
|
|
63
|
-
`;
|
|
64
|
-
|
|
65
58
|
export const ButtonContentView = styled.div`
|
|
66
59
|
font-size: ${ CONFIG.fontSize };
|
|
67
60
|
line-height: 1;
|
|
@@ -82,8 +75,17 @@ export const isIcon = ( {
|
|
|
82
75
|
};
|
|
83
76
|
|
|
84
77
|
return css`
|
|
78
|
+
color: ${ COLORS.gray[ 900 ] };
|
|
85
79
|
width: ${ iconButtonSizes[ size ] };
|
|
86
80
|
padding-left: 0;
|
|
87
81
|
padding-right: 0;
|
|
88
82
|
`;
|
|
89
83
|
};
|
|
84
|
+
|
|
85
|
+
export const buttonActive = css`
|
|
86
|
+
color: ${ COLORS.white };
|
|
87
|
+
|
|
88
|
+
&:active {
|
|
89
|
+
background: transparent;
|
|
90
|
+
}
|
|
91
|
+
`;
|
|
@@ -21,10 +21,10 @@ describe( 'Toolbar', () => {
|
|
|
21
21
|
|
|
22
22
|
expect(
|
|
23
23
|
screen.getByLabelText( 'control1', { selector: 'button' } )
|
|
24
|
-
).
|
|
24
|
+
).toBeInTheDocument();
|
|
25
25
|
expect(
|
|
26
26
|
screen.getByLabelText( 'control2', { selector: 'button' } )
|
|
27
|
-
).
|
|
27
|
+
).toBeInTheDocument();
|
|
28
28
|
} );
|
|
29
29
|
} );
|
|
30
30
|
} );
|