@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
|
@@ -41,6 +41,9 @@ export function useBorderBoxControl(
|
|
|
41
41
|
? ( value as Borders )
|
|
42
42
|
: getSplitBorders( value as Border | undefined );
|
|
43
43
|
|
|
44
|
+
// If no numeric width value is set, the unit select will be disabled.
|
|
45
|
+
const hasWidthValue = ! isNaN( parseFloat( `${ linkedValue?.width }` ) );
|
|
46
|
+
|
|
44
47
|
const [ isLinked, setIsLinked ] = useState( ! mixedBorders );
|
|
45
48
|
const toggleLinked = () => setIsLinked( ! isLinked );
|
|
46
49
|
|
|
@@ -107,6 +110,7 @@ export function useBorderBoxControl(
|
|
|
107
110
|
return {
|
|
108
111
|
...otherProps,
|
|
109
112
|
className: classes,
|
|
113
|
+
disableUnits: mixedBorders && ! hasWidthValue,
|
|
110
114
|
hasMixedBorders: mixedBorders,
|
|
111
115
|
isLinked,
|
|
112
116
|
linkedControlClassName,
|
|
@@ -120,17 +120,20 @@ describe( 'BorderBoxControl', () => {
|
|
|
120
120
|
expect( widthInput.value ).toBe( '1' );
|
|
121
121
|
} );
|
|
122
122
|
|
|
123
|
-
it( 'should render placeholder when border values are mixed', () => {
|
|
123
|
+
it( 'should render placeholder and omit unit select when border values are mixed', () => {
|
|
124
124
|
renderBorderBoxControl( { value: mixedBorders } );
|
|
125
125
|
|
|
126
126
|
// First render of control with mixed values should show split view.
|
|
127
127
|
clickButton( 'Link sides' );
|
|
128
128
|
|
|
129
129
|
const widthInput = screen.getByRole( 'spinbutton' );
|
|
130
|
+
const unitSelect = screen.queryByRole( 'combobox' );
|
|
131
|
+
|
|
130
132
|
expect( widthInput ).toHaveAttribute( 'placeholder', 'Mixed' );
|
|
133
|
+
expect( unitSelect ).not.toBeInTheDocument();
|
|
131
134
|
} );
|
|
132
135
|
|
|
133
|
-
it( 'should render shared border width when switching to linked view', async () => {
|
|
136
|
+
it( 'should render shared border width and unit select when switching to linked view', async () => {
|
|
134
137
|
// Render control with mixed border values but consistent widths.
|
|
135
138
|
renderBorderBoxControl( {
|
|
136
139
|
value: {
|
|
@@ -144,8 +147,10 @@ describe( 'BorderBoxControl', () => {
|
|
|
144
147
|
// First render of control with mixed values should show split view.
|
|
145
148
|
clickButton( 'Link sides' );
|
|
146
149
|
const linkedInput = screen.getByRole( 'spinbutton' );
|
|
150
|
+
const unitSelect = screen.getByRole( 'combobox' );
|
|
147
151
|
|
|
148
152
|
expect( linkedInput.value ).toBe( '5' );
|
|
153
|
+
expect( unitSelect ).toBeInTheDocument();
|
|
149
154
|
} );
|
|
150
155
|
|
|
151
156
|
it( 'should omit style options when requested', () => {
|
|
@@ -244,6 +244,54 @@ describe( 'BorderBoxControl Utils', () => {
|
|
|
244
244
|
|
|
245
245
|
expect( getCommonBorder( sideBorders ) ).toEqual( commonBorder );
|
|
246
246
|
} );
|
|
247
|
+
|
|
248
|
+
it( 'should return most common unit selection if border widths are mixed', () => {
|
|
249
|
+
const sideBorders = {
|
|
250
|
+
top: { color: '#fff', style: 'solid', width: '10px' },
|
|
251
|
+
right: { color: '#000', style: 'solid', width: '1rem' },
|
|
252
|
+
bottom: { color: '#000', style: 'solid', width: '2em' },
|
|
253
|
+
left: { color: '#000', style: undefined, width: '2em' },
|
|
254
|
+
};
|
|
255
|
+
const commonBorder = {
|
|
256
|
+
color: undefined,
|
|
257
|
+
style: undefined,
|
|
258
|
+
width: 'em',
|
|
259
|
+
};
|
|
260
|
+
|
|
261
|
+
expect( getCommonBorder( sideBorders ) ).toEqual( commonBorder );
|
|
262
|
+
} );
|
|
263
|
+
|
|
264
|
+
it( 'should return first unit when multiple units are equal most common', () => {
|
|
265
|
+
const sideBorders = {
|
|
266
|
+
top: { color: '#fff', style: 'solid', width: '1rem' },
|
|
267
|
+
right: { color: '#000', style: 'solid', width: '0.75em' },
|
|
268
|
+
bottom: { color: '#000', style: 'solid', width: '1vw' },
|
|
269
|
+
left: { color: '#000', style: undefined, width: '2vh' },
|
|
270
|
+
};
|
|
271
|
+
const commonBorder = {
|
|
272
|
+
color: undefined,
|
|
273
|
+
style: undefined,
|
|
274
|
+
width: 'rem',
|
|
275
|
+
};
|
|
276
|
+
|
|
277
|
+
expect( getCommonBorder( sideBorders ) ).toEqual( commonBorder );
|
|
278
|
+
} );
|
|
279
|
+
|
|
280
|
+
it( 'should ignore undefined values in determining most common unit', () => {
|
|
281
|
+
const sideBorders = {
|
|
282
|
+
top: { color: '#fff', style: 'solid', width: undefined },
|
|
283
|
+
right: { color: '#000', style: 'solid', width: '5vw' },
|
|
284
|
+
bottom: { color: '#000', style: 'solid', width: undefined },
|
|
285
|
+
left: { color: '#000', style: undefined, width: '2vh' },
|
|
286
|
+
};
|
|
287
|
+
const commonBorder = {
|
|
288
|
+
color: undefined,
|
|
289
|
+
style: undefined,
|
|
290
|
+
width: 'vw',
|
|
291
|
+
};
|
|
292
|
+
|
|
293
|
+
expect( getCommonBorder( sideBorders ) ).toEqual( commonBorder );
|
|
294
|
+
} );
|
|
247
295
|
} );
|
|
248
296
|
|
|
249
297
|
describe( 'getShorthandBorderStyle', () => {
|
|
@@ -6,6 +6,7 @@ import type { CSSProperties } from 'react';
|
|
|
6
6
|
/**
|
|
7
7
|
* Internal dependencies
|
|
8
8
|
*/
|
|
9
|
+
import { parseCSSUnitValue } from '../utils/unit-values';
|
|
9
10
|
import type { Border } from '../border-control/types';
|
|
10
11
|
import type { AnyBorder, Borders, BorderProp, BorderSide } from './types';
|
|
11
12
|
|
|
@@ -123,7 +124,7 @@ export const getCommonBorder = ( borders?: Borders ) => {
|
|
|
123
124
|
return {
|
|
124
125
|
color: allColorsMatch ? colors[ 0 ] : undefined,
|
|
125
126
|
style: allStylesMatch ? styles[ 0 ] : undefined,
|
|
126
|
-
width: allWidthsMatch ? widths[ 0 ] :
|
|
127
|
+
width: allWidthsMatch ? widths[ 0 ] : getMostCommonUnit( widths ),
|
|
127
128
|
};
|
|
128
129
|
};
|
|
129
130
|
|
|
@@ -152,3 +153,45 @@ export const getShorthandBorderStyle = (
|
|
|
152
153
|
|
|
153
154
|
return [ width, borderStyle, color ].filter( Boolean ).join( ' ' );
|
|
154
155
|
};
|
|
156
|
+
|
|
157
|
+
export const getMostCommonUnit = (
|
|
158
|
+
values: Array< string | number | undefined >
|
|
159
|
+
): string | undefined => {
|
|
160
|
+
// Collect all the CSS units.
|
|
161
|
+
const units = values.map( ( value ) =>
|
|
162
|
+
value === undefined ? undefined : parseCSSUnitValue( `${ value }` )[ 1 ]
|
|
163
|
+
);
|
|
164
|
+
|
|
165
|
+
// Return the most common unit out of only the defined CSS units.
|
|
166
|
+
const filteredUnits = units.filter( ( value ) => value !== undefined );
|
|
167
|
+
return mode( filteredUnits as string[] );
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Finds the mode value out of the array passed favouring the first value
|
|
172
|
+
* as a tiebreaker.
|
|
173
|
+
*
|
|
174
|
+
* @param values Values to determine the mode from.
|
|
175
|
+
*
|
|
176
|
+
* @return The mode value.
|
|
177
|
+
*/
|
|
178
|
+
function mode( values: Array< string > ): string | undefined {
|
|
179
|
+
if ( values.length === 0 ) {
|
|
180
|
+
return undefined;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
const map: { [ index: string ]: number } = {};
|
|
184
|
+
let maxCount = 0;
|
|
185
|
+
let currentMode;
|
|
186
|
+
|
|
187
|
+
values.forEach( ( value ) => {
|
|
188
|
+
map[ value ] = map[ value ] === undefined ? 1 : map[ value ] + 1;
|
|
189
|
+
|
|
190
|
+
if ( map[ value ] > maxCount ) {
|
|
191
|
+
currentMode = value;
|
|
192
|
+
maxCount = map[ value ];
|
|
193
|
+
}
|
|
194
|
+
} );
|
|
195
|
+
|
|
196
|
+
return currentMode;
|
|
197
|
+
}
|
|
@@ -66,6 +66,12 @@ This toggles the ability to choose custom colors.
|
|
|
66
66
|
|
|
67
67
|
- Required: No
|
|
68
68
|
|
|
69
|
+
### `disableUnits`: `boolean`
|
|
70
|
+
|
|
71
|
+
This controls whether unit selection should be disabled.
|
|
72
|
+
|
|
73
|
+
- Required: No
|
|
74
|
+
|
|
69
75
|
### `enableAlpha`: `boolean`
|
|
70
76
|
|
|
71
77
|
This controls whether the alpha channel will be offered when selecting
|
|
@@ -39,6 +39,7 @@ const UnconnectedBorderControl = (
|
|
|
39
39
|
const {
|
|
40
40
|
colors,
|
|
41
41
|
disableCustomColors,
|
|
42
|
+
disableUnits,
|
|
42
43
|
enableAlpha,
|
|
43
44
|
enableStyle = true,
|
|
44
45
|
hideLabelFromVision,
|
|
@@ -97,6 +98,7 @@ const UnconnectedBorderControl = (
|
|
|
97
98
|
onChange={ onWidthChange }
|
|
98
99
|
value={ border?.width || '' }
|
|
99
100
|
placeholder={ placeholder }
|
|
101
|
+
disableUnits={ disableUnits }
|
|
100
102
|
__unstableInputWidth={ inputWidth }
|
|
101
103
|
/>
|
|
102
104
|
{ withSlider && (
|
|
@@ -67,6 +67,10 @@ export type LabelProps = {
|
|
|
67
67
|
|
|
68
68
|
export type BorderControlProps = ColorProps &
|
|
69
69
|
LabelProps & {
|
|
70
|
+
/**
|
|
71
|
+
* This controls whether unit selection should be disabled.
|
|
72
|
+
*/
|
|
73
|
+
disableUnits?: boolean;
|
|
70
74
|
/**
|
|
71
75
|
* This controls whether to include border style options within the
|
|
72
76
|
* `BorderDropdown` sub-component.
|
package/src/button/style.scss
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
|
|
21
21
|
&[aria-expanded="true"],
|
|
22
22
|
&:hover {
|
|
23
|
-
color:
|
|
23
|
+
color: $components-color-accent;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
// Unset some hovers, instead of adding :not specificity.
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
// Focus.
|
|
32
32
|
// See https://github.com/WordPress/gutenberg/issues/13267 for more context on these selectors.
|
|
33
33
|
&:focus:not(:disabled) {
|
|
34
|
-
box-shadow: 0 0 0 var(--wp-admin-border-width-focus)
|
|
34
|
+
box-shadow: 0 0 0 var(--wp-admin-border-width-focus) $components-color-accent;
|
|
35
35
|
|
|
36
36
|
// Windows High Contrast mode will show this outline, but not the box-shadow.
|
|
37
37
|
outline: 3px solid transparent;
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
|
|
44
44
|
&.is-primary {
|
|
45
45
|
white-space: nowrap;
|
|
46
|
-
background:
|
|
46
|
+
background: $components-color-accent;
|
|
47
47
|
color: $white;
|
|
48
48
|
text-decoration: none;
|
|
49
49
|
text-shadow: none;
|
|
@@ -52,18 +52,18 @@
|
|
|
52
52
|
outline: 1px solid transparent;
|
|
53
53
|
|
|
54
54
|
&:hover:not(:disabled) {
|
|
55
|
-
background:
|
|
55
|
+
background: $components-color-accent-darker-10;
|
|
56
56
|
color: $white;
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
&:active:not(:disabled) {
|
|
60
|
-
background:
|
|
61
|
-
border-color:
|
|
60
|
+
background: $components-color-accent-darker-20;
|
|
61
|
+
border-color: $components-color-accent-darker-20;
|
|
62
62
|
color: $white;
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
&:focus:not(:disabled) {
|
|
66
|
-
box-shadow: inset 0 0 0 1px $white, 0 0 0 var(--wp-admin-border-width-focus)
|
|
66
|
+
box-shadow: inset 0 0 0 1px $white, 0 0 0 var(--wp-admin-border-width-focus) $components-color-accent;
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
&:disabled,
|
|
@@ -72,15 +72,15 @@
|
|
|
72
72
|
&[aria-disabled="true"]:enabled, // This catches a situation where a Button is aria-disabled, but not disabled.
|
|
73
73
|
&[aria-disabled="true"]:active:enabled {
|
|
74
74
|
color: rgba($white, 0.4);
|
|
75
|
-
background:
|
|
76
|
-
border-color:
|
|
75
|
+
background: $components-color-accent;
|
|
76
|
+
border-color: $components-color-accent;
|
|
77
77
|
opacity: 1;
|
|
78
78
|
outline: none;
|
|
79
79
|
|
|
80
80
|
&:focus:enabled {
|
|
81
81
|
box-shadow:
|
|
82
82
|
0 0 0 $border-width $white,
|
|
83
|
-
0 0 0 3px
|
|
83
|
+
0 0 0 3px $components-color-accent;
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
86
|
|
|
@@ -93,13 +93,13 @@
|
|
|
93
93
|
/* stylelint-disable */
|
|
94
94
|
background-image: linear-gradient(
|
|
95
95
|
-45deg,
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
96
|
+
$components-color-accent 33%,
|
|
97
|
+
$components-color-accent-darker-20 33%,
|
|
98
|
+
$components-color-accent-darker-20 70%,
|
|
99
|
+
$components-color-accent 70%
|
|
100
100
|
);
|
|
101
101
|
/* stylelint-enable */
|
|
102
|
-
border-color:
|
|
102
|
+
border-color: $components-color-accent;
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
105
|
|
|
@@ -114,13 +114,13 @@
|
|
|
114
114
|
|
|
115
115
|
&:active:not(:disabled) {
|
|
116
116
|
background: $gray-300;
|
|
117
|
-
color:
|
|
117
|
+
color: $components-color-accent-darker-10;
|
|
118
118
|
box-shadow: none;
|
|
119
119
|
}
|
|
120
120
|
|
|
121
121
|
&:hover:not(:disabled) {
|
|
122
|
-
color:
|
|
123
|
-
box-shadow: inset 0 0 0 $border-width
|
|
122
|
+
color: $components-color-accent-darker-10;
|
|
123
|
+
box-shadow: inset 0 0 0 $border-width $components-color-accent-darker-10;
|
|
124
124
|
}
|
|
125
125
|
|
|
126
126
|
&:disabled,
|
|
@@ -140,10 +140,10 @@
|
|
|
140
140
|
*/
|
|
141
141
|
|
|
142
142
|
&.is-secondary {
|
|
143
|
-
box-shadow: inset 0 0 0 $border-width
|
|
143
|
+
box-shadow: inset 0 0 0 $border-width $components-color-accent;
|
|
144
144
|
outline: 1px solid transparent; // Shown in high contrast mode.
|
|
145
145
|
white-space: nowrap;
|
|
146
|
-
color:
|
|
146
|
+
color: $components-color-accent;
|
|
147
147
|
background: transparent;
|
|
148
148
|
}
|
|
149
149
|
|
|
@@ -153,7 +153,7 @@
|
|
|
153
153
|
|
|
154
154
|
&.is-tertiary {
|
|
155
155
|
white-space: nowrap;
|
|
156
|
-
color:
|
|
156
|
+
color: $components-color-accent;
|
|
157
157
|
background: transparent;
|
|
158
158
|
padding: $grid-unit-15 * 0.5; // This reduces the horizontal padding on tertiary/text buttons, so as to space them optically.
|
|
159
159
|
|
|
@@ -182,7 +182,7 @@
|
|
|
182
182
|
}
|
|
183
183
|
|
|
184
184
|
&:focus:not(:disabled) {
|
|
185
|
-
color:
|
|
185
|
+
color: $components-color-accent;
|
|
186
186
|
}
|
|
187
187
|
|
|
188
188
|
&:active:not(:disabled) {
|
|
@@ -230,7 +230,7 @@
|
|
|
230
230
|
background: none;
|
|
231
231
|
outline: none;
|
|
232
232
|
text-align: left;
|
|
233
|
-
color:
|
|
233
|
+
color: $components-color-accent;
|
|
234
234
|
text-decoration: underline;
|
|
235
235
|
transition-property: border, background, color;
|
|
236
236
|
transition-duration: 0.05s;
|
|
@@ -253,7 +253,7 @@
|
|
|
253
253
|
}
|
|
254
254
|
|
|
255
255
|
&:focus:not(:disabled) {
|
|
256
|
-
color:
|
|
256
|
+
color: $components-color-accent;
|
|
257
257
|
}
|
|
258
258
|
}
|
|
259
259
|
}
|
|
@@ -333,7 +333,7 @@
|
|
|
333
333
|
background: $gray-900;
|
|
334
334
|
|
|
335
335
|
&:focus:not(:disabled) {
|
|
336
|
-
box-shadow: inset 0 0 0 1px $white, 0 0 0 var(--wp-admin-border-width-focus)
|
|
336
|
+
box-shadow: inset 0 0 0 1px $white, 0 0 0 var(--wp-admin-border-width-focus) $components-color-accent;
|
|
337
337
|
|
|
338
338
|
// Windows High Contrast mode will show this outline, but not the box-shadow.
|
|
339
339
|
outline: 2px solid transparent;
|
package/src/button/test/index.js
CHANGED
|
@@ -27,7 +27,7 @@ describe( 'Button', () => {
|
|
|
27
27
|
expect( button ).not.toHaveClass( 'is-large' );
|
|
28
28
|
expect( button ).not.toHaveClass( 'is-primary' );
|
|
29
29
|
expect( button ).not.toHaveClass( 'is-pressed' );
|
|
30
|
-
expect( button ).
|
|
30
|
+
expect( button ).toBeEnabled();
|
|
31
31
|
expect( button ).not.toHaveAttribute( 'aria-disabled' );
|
|
32
32
|
expect( button ).toHaveAttribute( 'type', 'button' );
|
|
33
33
|
} );
|
|
@@ -114,16 +114,14 @@ describe( 'Button', () => {
|
|
|
114
114
|
it( 'should add a disabled prop to the button', () => {
|
|
115
115
|
render( <Button disabled /> );
|
|
116
116
|
|
|
117
|
-
expect( screen.getByRole( 'button' ) ).
|
|
118
|
-
'disabled'
|
|
119
|
-
);
|
|
117
|
+
expect( screen.getByRole( 'button' ) ).toBeDisabled();
|
|
120
118
|
} );
|
|
121
119
|
|
|
122
120
|
it( 'should add only aria-disabled attribute when disabled and isFocusable are true', () => {
|
|
123
121
|
render( <Button disabled __experimentalIsFocusable /> );
|
|
124
122
|
const button = screen.getByRole( 'button' );
|
|
125
123
|
|
|
126
|
-
expect( button ).
|
|
124
|
+
expect( button ).toBeEnabled();
|
|
127
125
|
expect( button ).toHaveAttribute( 'aria-disabled' );
|
|
128
126
|
} );
|
|
129
127
|
|
|
@@ -247,11 +247,6 @@ function ComboboxControl( {
|
|
|
247
247
|
instanceId={ instanceId }
|
|
248
248
|
ref={ inputContainer }
|
|
249
249
|
value={ isExpanded ? inputValue : currentLabel }
|
|
250
|
-
aria-label={
|
|
251
|
-
currentLabel
|
|
252
|
-
? `${ currentLabel }, ${ label }`
|
|
253
|
-
: null
|
|
254
|
-
}
|
|
255
250
|
onFocus={ onFocus }
|
|
256
251
|
onBlur={ onBlur }
|
|
257
252
|
isExpanded={ isExpanded }
|
|
@@ -271,7 +271,7 @@ describe.each( [
|
|
|
271
271
|
|
|
272
272
|
// No options are rendered if no match is found
|
|
273
273
|
await user.keyboard( unmatchedString );
|
|
274
|
-
expect( screen.queryByRole( 'option' ) ).
|
|
274
|
+
expect( screen.queryByRole( 'option' ) ).not.toBeInTheDocument();
|
|
275
275
|
|
|
276
276
|
// Clearing the input renders all options again
|
|
277
277
|
await user.clear( input );
|
|
@@ -3,7 +3,13 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import type { MouseEvent, KeyboardEvent, ReactNode } from 'react';
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
import type { ModalProps } from '../modal/types';
|
|
10
|
+
|
|
6
11
|
export type DialogInputEvent =
|
|
12
|
+
| Parameters< ModalProps[ 'onRequestClose' ] >[ 0 ]
|
|
7
13
|
| KeyboardEvent< HTMLDivElement >
|
|
8
14
|
| MouseEvent< HTMLButtonElement >;
|
|
9
15
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
1
2
|
/**
|
|
2
3
|
* External dependencies
|
|
3
4
|
*/
|
|
@@ -15,7 +16,7 @@ import deprecated from '@wordpress/deprecated';
|
|
|
15
16
|
/**
|
|
16
17
|
* Internal dependencies
|
|
17
18
|
*/
|
|
18
|
-
import { VisuallyHidden } from '../';
|
|
19
|
+
import { VisuallyHidden } from '../visually-hidden';
|
|
19
20
|
import { Select as SelectControlSelect } from '../select-control/styles/select-control-styles';
|
|
20
21
|
import SelectControlChevronDown from '../select-control/chevron-down';
|
|
21
22
|
import { InputBaseWithBackCompatMinWidth } from './styles';
|
|
@@ -303,12 +303,8 @@ describe( 'TimePicker', () => {
|
|
|
303
303
|
* This is not ideal, but best of we can do for now until we refactor
|
|
304
304
|
* AM/PM into accessible elements, like radio buttons.
|
|
305
305
|
*/
|
|
306
|
-
expect(
|
|
307
|
-
|
|
308
|
-
).toBe( false );
|
|
309
|
-
expect(
|
|
310
|
-
screen.getByText( 'PM' ).classList.contains( 'is-primary' )
|
|
311
|
-
).toBe( true );
|
|
306
|
+
expect( screen.getByText( 'AM' ) ).not.toHaveClass( 'is-primary' );
|
|
307
|
+
expect( screen.getByText( 'PM' ) ).toHaveClass( 'is-primary' );
|
|
312
308
|
} );
|
|
313
309
|
|
|
314
310
|
it( 'should have different layouts/orders for 12/24 hour formats', () => {
|
package/src/disabled/index.tsx
CHANGED
|
@@ -1,13 +1,7 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import type { HTMLProps } from 'react';
|
|
5
|
-
|
|
6
1
|
/**
|
|
7
2
|
* WordPress dependencies
|
|
8
3
|
*/
|
|
9
|
-
import {
|
|
10
|
-
import { createContext, forwardRef } from '@wordpress/element';
|
|
4
|
+
import { createContext } from '@wordpress/element';
|
|
11
5
|
|
|
12
6
|
/**
|
|
13
7
|
* Internal dependencies
|
|
@@ -20,15 +14,6 @@ import { useCx } from '../utils';
|
|
|
20
14
|
const Context = createContext< boolean >( false );
|
|
21
15
|
const { Consumer, Provider } = Context;
|
|
22
16
|
|
|
23
|
-
// Extracting this ContentWrapper component in order to make it more explicit
|
|
24
|
-
// the same 'ContentWrapper' component is needed so that React can reconcile
|
|
25
|
-
// the dom correctly when switching between disabled/non-disabled (instead
|
|
26
|
-
// of thrashing the previous DOM and therefore losing the form fields values).
|
|
27
|
-
const ContentWrapper = forwardRef<
|
|
28
|
-
HTMLDivElement,
|
|
29
|
-
HTMLProps< HTMLDivElement >
|
|
30
|
-
>( ( props, ref ) => <div { ...props } ref={ ref } /> );
|
|
31
|
-
|
|
32
17
|
/**
|
|
33
18
|
* `Disabled` is a component which disables descendant tabbable elements and prevents pointer interaction.
|
|
34
19
|
*
|
|
@@ -65,29 +50,22 @@ function Disabled( {
|
|
|
65
50
|
isDisabled = true,
|
|
66
51
|
...props
|
|
67
52
|
}: WordPressComponentProps< DisabledProps, 'div' > ) {
|
|
68
|
-
const ref = useDisabled();
|
|
69
53
|
const cx = useCx();
|
|
70
|
-
if ( ! isDisabled ) {
|
|
71
|
-
return (
|
|
72
|
-
<Provider value={ false }>
|
|
73
|
-
<ContentWrapper>{ children }</ContentWrapper>
|
|
74
|
-
</Provider>
|
|
75
|
-
);
|
|
76
|
-
}
|
|
77
54
|
|
|
78
55
|
return (
|
|
79
|
-
<Provider value={
|
|
80
|
-
<
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
56
|
+
<Provider value={ isDisabled }>
|
|
57
|
+
<div
|
|
58
|
+
// @ts-ignore Reason: inert is a recent HTML attribute
|
|
59
|
+
inert={ isDisabled ? 'true' : undefined }
|
|
60
|
+
className={
|
|
61
|
+
isDisabled
|
|
62
|
+
? cx( disabledStyles, className, 'components-disabled' )
|
|
63
|
+
: undefined
|
|
64
|
+
}
|
|
87
65
|
{ ...props }
|
|
88
66
|
>
|
|
89
67
|
{ children }
|
|
90
|
-
</
|
|
68
|
+
</div>
|
|
91
69
|
</Provider>
|
|
92
70
|
);
|
|
93
71
|
}
|