@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/components/src/navigator/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA","sourcesContent":["export {
|
|
1
|
+
{"version":3,"sources":["@wordpress/components/src/navigator/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA","sourcesContent":["export { NavigatorProvider } from './navigator-provider';\nexport { NavigatorScreen } from './navigator-screen';\nexport { NavigatorButton } from './navigator-button';\nexport { NavigatorBackButton } from './navigator-back-button';\nexport { default as useNavigator } from './use-navigator';\n"]}
|
|
@@ -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.NavigatorBackButton = void 0;
|
|
9
9
|
|
|
10
10
|
var _element = require("@wordpress/element");
|
|
11
11
|
|
|
@@ -24,7 +24,7 @@ var _hook = require("./hook");
|
|
|
24
24
|
/**
|
|
25
25
|
* Internal dependencies
|
|
26
26
|
*/
|
|
27
|
-
function
|
|
27
|
+
function UnconnectedNavigatorBackButton(props, forwardedRef) {
|
|
28
28
|
const navigatorBackButtonProps = (0, _hook.useNavigatorBackButton)(props);
|
|
29
29
|
return (0, _element.createElement)(_view.View, (0, _extends2.default)({
|
|
30
30
|
ref: forwardedRef
|
|
@@ -66,7 +66,8 @@ function NavigatorBackButton(props, forwardedRef) {
|
|
|
66
66
|
*/
|
|
67
67
|
|
|
68
68
|
|
|
69
|
-
const
|
|
70
|
-
|
|
69
|
+
const NavigatorBackButton = (0, _context.contextConnect)(UnconnectedNavigatorBackButton, 'NavigatorBackButton');
|
|
70
|
+
exports.NavigatorBackButton = NavigatorBackButton;
|
|
71
|
+
var _default = NavigatorBackButton;
|
|
71
72
|
exports.default = _default;
|
|
72
73
|
//# sourceMappingURL=component.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/components/src/navigator/navigator-back-button/component.tsx"],"names":["
|
|
1
|
+
{"version":3,"sources":["@wordpress/components/src/navigator/navigator-back-button/component.tsx"],"names":["UnconnectedNavigatorBackButton","props","forwardedRef","navigatorBackButtonProps","NavigatorBackButton"],"mappings":";;;;;;;;;;;;;AAQA;;AACA;;AACA;;AAVA;AACA;AACA;;AAGA;AACA;AACA;AAMA,SAASA,8BAAT,CACCC,KADD,EAECC,YAFD,EAGE;AACD,QAAMC,wBAAwB,GAAG,kCAAwBF,KAAxB,CAAjC;AAEA,SAAO,4BAAC,UAAD;AAAM,IAAA,GAAG,EAAGC;AAAZ,KAAgCC,wBAAhC,EAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,MAAMC,mBAAmB,GAAG,6BAClCJ,8BADkC,EAElC,qBAFkC,CAA5B;;eAKQI,mB","sourcesContent":["/**\n * External dependencies\n */\nimport type { ForwardedRef } from 'react';\n\n/**\n * Internal dependencies\n */\nimport { contextConnect, WordPressComponentProps } from '../../ui/context';\nimport { View } from '../../view';\nimport { useNavigatorBackButton } from './hook';\nimport type { NavigatorBackButtonProps } from '../types';\n\nfunction UnconnectedNavigatorBackButton(\n\tprops: WordPressComponentProps< NavigatorBackButtonProps, 'button' >,\n\tforwardedRef: ForwardedRef< any >\n) {\n\tconst navigatorBackButtonProps = useNavigatorBackButton( props );\n\n\treturn <View ref={ forwardedRef } { ...navigatorBackButtonProps } />;\n}\n\n/**\n * The `NavigatorBackButton` component can be used to navigate to a screen and\n * should be used in combination with the `NavigatorProvider`, the\n * `NavigatorScreen` and the `NavigatorButton` components (or the `useNavigator`\n * hook).\n *\n * @example\n * ```jsx\n * import {\n * __experimentalNavigatorProvider as NavigatorProvider,\n * __experimentalNavigatorScreen as NavigatorScreen,\n * __experimentalNavigatorButton as NavigatorButton,\n * __experimentalNavigatorBackButton as NavigatorBackButton,\n * } from '@wordpress/components';\n *\n * const MyNavigation = () => (\n * <NavigatorProvider initialPath=\"/\">\n * <NavigatorScreen path=\"/\">\n * <p>This is the home screen.</p>\n * <NavigatorButton path=\"/child\">\n * Navigate to child screen.\n * </NavigatorButton>\n * </NavigatorScreen>\n *\n * <NavigatorScreen path=\"/child\">\n * <p>This is the child screen.</p>\n * <NavigatorBackButton>\n * Go back\n * </NavigatorBackButton>\n * </NavigatorScreen>\n * </NavigatorProvider>\n * );\n * ```\n */\nexport const NavigatorBackButton = contextConnect(\n\tUnconnectedNavigatorBackButton,\n\t'NavigatorBackButton'\n);\n\nexport default NavigatorBackButton;\n"]}
|
|
@@ -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
Object.defineProperty(exports, "
|
|
8
|
+
Object.defineProperty(exports, "NavigatorBackButton", {
|
|
9
9
|
enumerable: true,
|
|
10
10
|
get: function () {
|
|
11
11
|
return _component.default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/components/src/navigator/navigator-back-button/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA","sourcesContent":["export { default } from './component';\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/components/src/navigator/navigator-back-button/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA","sourcesContent":["export { default as NavigatorBackButton } from './component';\n"]}
|
|
@@ -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.NavigatorButton = void 0;
|
|
9
9
|
|
|
10
10
|
var _element = require("@wordpress/element");
|
|
11
11
|
|
|
@@ -24,7 +24,7 @@ var _hook = require("./hook");
|
|
|
24
24
|
/**
|
|
25
25
|
* Internal dependencies
|
|
26
26
|
*/
|
|
27
|
-
function
|
|
27
|
+
function UnconnectedNavigatorButton(props, forwardedRef) {
|
|
28
28
|
const navigatorButtonProps = (0, _hook.useNavigatorButton)(props);
|
|
29
29
|
return (0, _element.createElement)(_view.View, (0, _extends2.default)({
|
|
30
30
|
ref: forwardedRef
|
|
@@ -65,7 +65,8 @@ function NavigatorButton(props, forwardedRef) {
|
|
|
65
65
|
*/
|
|
66
66
|
|
|
67
67
|
|
|
68
|
-
const
|
|
69
|
-
|
|
68
|
+
const NavigatorButton = (0, _context.contextConnect)(UnconnectedNavigatorButton, 'NavigatorButton');
|
|
69
|
+
exports.NavigatorButton = NavigatorButton;
|
|
70
|
+
var _default = NavigatorButton;
|
|
70
71
|
exports.default = _default;
|
|
71
72
|
//# sourceMappingURL=component.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/components/src/navigator/navigator-button/component.tsx"],"names":["
|
|
1
|
+
{"version":3,"sources":["@wordpress/components/src/navigator/navigator-button/component.tsx"],"names":["UnconnectedNavigatorButton","props","forwardedRef","navigatorButtonProps","NavigatorButton"],"mappings":";;;;;;;;;;;;;AAQA;;AACA;;AACA;;AAVA;AACA;AACA;;AAGA;AACA;AACA;AAMA,SAASA,0BAAT,CACCC,KADD,EAECC,YAFD,EAGE;AACD,QAAMC,oBAAoB,GAAG,8BAAoBF,KAApB,CAA7B;AAEA,SAAO,4BAAC,UAAD;AAAM,IAAA,GAAG,EAAGC;AAAZ,KAAgCC,oBAAhC,EAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,MAAMC,eAAe,GAAG,6BAC9BJ,0BAD8B,EAE9B,iBAF8B,CAAxB;;eAKQI,e","sourcesContent":["/**\n * External dependencies\n */\nimport type { ForwardedRef } from 'react';\n\n/**\n * Internal dependencies\n */\nimport { contextConnect, WordPressComponentProps } from '../../ui/context';\nimport { View } from '../../view';\nimport { useNavigatorButton } from './hook';\nimport type { NavigatorButtonProps } from '../types';\n\nfunction UnconnectedNavigatorButton(\n\tprops: WordPressComponentProps< NavigatorButtonProps, 'button' >,\n\tforwardedRef: ForwardedRef< any >\n) {\n\tconst navigatorButtonProps = useNavigatorButton( props );\n\n\treturn <View ref={ forwardedRef } { ...navigatorButtonProps } />;\n}\n\n/**\n * The `NavigatorButton` component can be used to navigate to a screen and should\n * be used in combination with the `NavigatorProvider`, the `NavigatorScreen`\n * and the `NavigatorBackButton` components (or the `useNavigator` hook).\n *\n * @example\n * ```jsx\n * import {\n * __experimentalNavigatorProvider as NavigatorProvider,\n * __experimentalNavigatorScreen as NavigatorScreen,\n * __experimentalNavigatorButton as NavigatorButton,\n * __experimentalNavigatorBackButton as NavigatorBackButton,\n * } from '@wordpress/components';\n *\n * const MyNavigation = () => (\n * <NavigatorProvider initialPath=\"/\">\n * <NavigatorScreen path=\"/\">\n * <p>This is the home screen.</p>\n * <NavigatorButton path=\"/child\">\n * Navigate to child screen.\n * </NavigatorButton>\n * </NavigatorScreen>\n *\n * <NavigatorScreen path=\"/child\">\n * <p>This is the child screen.</p>\n * <NavigatorBackButton>\n * Go back\n * </NavigatorBackButton>\n * </NavigatorScreen>\n * </NavigatorProvider>\n * );\n * ```\n */\nexport const NavigatorButton = contextConnect(\n\tUnconnectedNavigatorButton,\n\t'NavigatorButton'\n);\n\nexport default NavigatorButton;\n"]}
|
|
@@ -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
Object.defineProperty(exports, "
|
|
8
|
+
Object.defineProperty(exports, "NavigatorButton", {
|
|
9
9
|
enumerable: true,
|
|
10
10
|
get: function () {
|
|
11
11
|
return _component.default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/components/src/navigator/navigator-button/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA","sourcesContent":["export { default } from './component';\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/components/src/navigator/navigator-button/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA","sourcesContent":["export { default as NavigatorButton } from './component';\n"]}
|
|
@@ -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.NavigatorProvider = void 0;
|
|
9
9
|
|
|
10
10
|
var _element = require("@wordpress/element");
|
|
11
11
|
|
|
@@ -29,11 +29,11 @@ var _ref = process.env.NODE_ENV === "production" ? {
|
|
|
29
29
|
} : {
|
|
30
30
|
name: "192ebb7-classes",
|
|
31
31
|
styles: "overflow-x:hidden;label:classes;",
|
|
32
|
-
map: "/*# sourceMappingURL=data:application/json;charset=utf-8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nQgZGVmYXVsdCBOYXZpZ2F0b3JQcm92aWRlcjtcbiJdfQ== */",
|
|
33
33
|
toString: _EMOTION_STRINGIFIED_CSS_ERROR__
|
|
34
34
|
};
|
|
35
35
|
|
|
36
|
-
function
|
|
36
|
+
function UnconnectedNavigatorProvider(props, forwardedRef) {
|
|
37
37
|
const {
|
|
38
38
|
initialPath,
|
|
39
39
|
children,
|
|
@@ -47,13 +47,15 @@ function NavigatorProvider(props, forwardedRef) {
|
|
|
47
47
|
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
48
48
|
setLocationHistory([...locationHistory, { ...options,
|
|
49
49
|
path,
|
|
50
|
-
isBack: false
|
|
50
|
+
isBack: false,
|
|
51
|
+
hasRestoredFocus: false
|
|
51
52
|
}]);
|
|
52
53
|
}, [locationHistory]);
|
|
53
54
|
const goBack = (0, _element.useCallback)(() => {
|
|
54
55
|
if (locationHistory.length > 1) {
|
|
55
56
|
setLocationHistory([...locationHistory.slice(0, -2), { ...locationHistory[locationHistory.length - 2],
|
|
56
|
-
isBack: true
|
|
57
|
+
isBack: true,
|
|
58
|
+
hasRestoredFocus: false
|
|
57
59
|
}]);
|
|
58
60
|
}
|
|
59
61
|
}, [locationHistory]);
|
|
@@ -110,7 +112,8 @@ function NavigatorProvider(props, forwardedRef) {
|
|
|
110
112
|
*/
|
|
111
113
|
|
|
112
114
|
|
|
113
|
-
const
|
|
114
|
-
|
|
115
|
+
const NavigatorProvider = (0, _context.contextConnect)(UnconnectedNavigatorProvider, 'NavigatorProvider');
|
|
116
|
+
exports.NavigatorProvider = NavigatorProvider;
|
|
117
|
+
var _default = NavigatorProvider;
|
|
115
118
|
exports.default = _default;
|
|
116
119
|
//# sourceMappingURL=component.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/components/src/navigator/navigator-provider/component.tsx"],"names":["
|
|
1
|
+
{"version":3,"sources":["@wordpress/components/src/navigator/navigator-provider/component.tsx"],"names":["UnconnectedNavigatorProvider","props","forwardedRef","initialPath","children","className","otherProps","locationHistory","setLocationHistory","path","goTo","options","isBack","hasRestoredFocus","goBack","length","slice","navigatorContextValue","location","isInitial","cx","classes","NavigatorProvider"],"mappings":";;;;;;;;;AASA;;;;AALA;;AAUA;;AAKA;;AACA;;AACA;;;;;;;;;;;;;;AAOA,SAASA,4BAAT,CACCC,KADD,EAECC,YAFD,EAGE;AACD,QAAM;AAAEC,IAAAA,WAAF;AAAeC,IAAAA,QAAf;AAAyBC,IAAAA,SAAzB;AAAoC,OAAGC;AAAvC,MACL,+BAAkBL,KAAlB,EAAyB,mBAAzB,CADD;AAGA,QAAM,CAAEM,eAAF,EAAmBC,kBAAnB,IAA0C,uBAE7C,CACF;AACCC,IAAAA,IAAI,EAAEN;AADP,GADE,CAF6C,CAAhD;AAQA,QAAMO,IAAoC,GAAG,0BAC5C,UAAED,IAAF,EAA0B;AAAA,QAAlBE,OAAkB,uEAAR,EAAQ;AACzBH,IAAAA,kBAAkB,CAAE,CACnB,GAAGD,eADgB,EAEnB,EACC,GAAGI,OADJ;AAECF,MAAAA,IAFD;AAGCG,MAAAA,MAAM,EAAE,KAHT;AAICC,MAAAA,gBAAgB,EAAE;AAJnB,KAFmB,CAAF,CAAlB;AASA,GAX2C,EAY5C,CAAEN,eAAF,CAZ4C,CAA7C;AAeA,QAAMO,MAAwC,GAAG,0BAAa,MAAM;AACnE,QAAKP,eAAe,CAACQ,MAAhB,GAAyB,CAA9B,EAAkC;AACjCP,MAAAA,kBAAkB,CAAE,CACnB,GAAGD,eAAe,CAACS,KAAhB,CAAuB,CAAvB,EAA0B,CAAC,CAA3B,CADgB,EAEnB,EACC,GAAGT,eAAe,CAAEA,eAAe,CAACQ,MAAhB,GAAyB,CAA3B,CADnB;AAECH,QAAAA,MAAM,EAAE,IAFT;AAGCC,QAAAA,gBAAgB,EAAE;AAHnB,OAFmB,CAAF,CAAlB;AAQA;AACD,GAXgD,EAW9C,CAAEN,eAAF,CAX8C,CAAjD;AAaA,QAAMU,qBAA2C,GAAG,sBACnD,OAAQ;AACPC,IAAAA,QAAQ,EAAE,EACT,GAAGX,eAAe,CAAEA,eAAe,CAACQ,MAAhB,GAAyB,CAA3B,CADT;AAETI,MAAAA,SAAS,EAAEZ,eAAe,CAACQ,MAAhB,KAA2B;AAF7B,KADH;AAKPL,IAAAA,IALO;AAMPI,IAAAA;AANO,GAAR,CADmD,EASnD,CAAEP,eAAF,EAAmBG,IAAnB,EAAyBI,MAAzB,CATmD,CAApD;AAYA,QAAMM,EAAE,GAAG,mBAAX;AACA,QAAMC,OAAO,GAAG,uBACf;AACA,QAAMD,EAAE,OAAkCf,SAAlC,CAFO,EAGf,CAAEA,SAAF,EAAae,EAAb,CAHe,CAAhB;AAMA,SACC,4BAAC,UAAD;AAAM,IAAA,GAAG,EAAGlB,YAAZ;AAA2B,IAAA,SAAS,EAAGmB;AAAvC,KAAsDf,UAAtD,GACC,4BAAC,0BAAD,CAAkB,QAAlB;AAA2B,IAAA,KAAK,EAAGW;AAAnC,KACGb,QADH,CADD,CADD;AAOA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,MAAMkB,iBAAiB,GAAG,6BAChCtB,4BADgC,EAEhC,mBAFgC,CAA1B;;eAKQsB,iB","sourcesContent":["/**\n * External dependencies\n */\nimport type { ForwardedRef } from 'react';\nimport { css } from '@emotion/react';\n\n/**\n * WordPress dependencies\n */\nimport { useMemo, useState, useCallback } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport {\n\tcontextConnect,\n\tuseContextSystem,\n\tWordPressComponentProps,\n} from '../../ui/context';\nimport { useCx } from '../../utils/hooks/use-cx';\nimport { View } from '../../view';\nimport { NavigatorContext } from '../context';\nimport type {\n\tNavigatorProviderProps,\n\tNavigatorLocation,\n\tNavigatorContext as NavigatorContextType,\n} from '../types';\n\nfunction UnconnectedNavigatorProvider(\n\tprops: WordPressComponentProps< NavigatorProviderProps, 'div' >,\n\tforwardedRef: ForwardedRef< any >\n) {\n\tconst { initialPath, children, className, ...otherProps } =\n\t\tuseContextSystem( props, 'NavigatorProvider' );\n\n\tconst [ locationHistory, setLocationHistory ] = useState<\n\t\tNavigatorLocation[]\n\t>( [\n\t\t{\n\t\t\tpath: initialPath,\n\t\t},\n\t] );\n\n\tconst goTo: NavigatorContextType[ 'goTo' ] = useCallback(\n\t\t( path, options = {} ) => {\n\t\t\tsetLocationHistory( [\n\t\t\t\t...locationHistory,\n\t\t\t\t{\n\t\t\t\t\t...options,\n\t\t\t\t\tpath,\n\t\t\t\t\tisBack: false,\n\t\t\t\t\thasRestoredFocus: false,\n\t\t\t\t},\n\t\t\t] );\n\t\t},\n\t\t[ locationHistory ]\n\t);\n\n\tconst goBack: NavigatorContextType[ 'goBack' ] = useCallback( () => {\n\t\tif ( locationHistory.length > 1 ) {\n\t\t\tsetLocationHistory( [\n\t\t\t\t...locationHistory.slice( 0, -2 ),\n\t\t\t\t{\n\t\t\t\t\t...locationHistory[ locationHistory.length - 2 ],\n\t\t\t\t\tisBack: true,\n\t\t\t\t\thasRestoredFocus: false,\n\t\t\t\t},\n\t\t\t] );\n\t\t}\n\t}, [ locationHistory ] );\n\n\tconst navigatorContextValue: NavigatorContextType = useMemo(\n\t\t() => ( {\n\t\t\tlocation: {\n\t\t\t\t...locationHistory[ locationHistory.length - 1 ],\n\t\t\t\tisInitial: locationHistory.length === 1,\n\t\t\t},\n\t\t\tgoTo,\n\t\t\tgoBack,\n\t\t} ),\n\t\t[ locationHistory, goTo, goBack ]\n\t);\n\n\tconst cx = useCx();\n\tconst classes = useMemo(\n\t\t// Prevents horizontal overflow while animating screen transitions.\n\t\t() => cx( css( { overflowX: 'hidden' } ), className ),\n\t\t[ className, cx ]\n\t);\n\n\treturn (\n\t\t<View ref={ forwardedRef } className={ classes } { ...otherProps }>\n\t\t\t<NavigatorContext.Provider value={ navigatorContextValue }>\n\t\t\t\t{ children }\n\t\t\t</NavigatorContext.Provider>\n\t\t</View>\n\t);\n}\n\n/**\n * The `NavigatorProvider` component allows rendering nested views/panels/menus\n * (via the `NavigatorScreen` component and navigate between these different\n * view (via the `NavigatorButton` and `NavigatorBackButton` components or the\n * `useNavigator` hook).\n *\n * @example\n * ```jsx\n * import {\n * __experimentalNavigatorProvider as NavigatorProvider,\n * __experimentalNavigatorScreen as NavigatorScreen,\n * __experimentalNavigatorButton as NavigatorButton,\n * __experimentalNavigatorBackButton as NavigatorBackButton,\n * } from '@wordpress/components';\n *\n * const MyNavigation = () => (\n * <NavigatorProvider initialPath=\"/\">\n * <NavigatorScreen path=\"/\">\n * <p>This is the home screen.</p>\n * <NavigatorButton path=\"/child\">\n * Navigate to child screen.\n * </NavigatorButton>\n * </NavigatorScreen>\n *\n * <NavigatorScreen path=\"/child\">\n * <p>This is the child screen.</p>\n * <NavigatorBackButton>\n * Go back\n * </NavigatorBackButton>\n * </NavigatorScreen>\n * </NavigatorProvider>\n * );\n * ```\n */\nexport const NavigatorProvider = contextConnect(\n\tUnconnectedNavigatorProvider,\n\t'NavigatorProvider'\n);\n\nexport default NavigatorProvider;\n"]}
|
|
@@ -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
Object.defineProperty(exports, "
|
|
8
|
+
Object.defineProperty(exports, "NavigatorProvider", {
|
|
9
9
|
enumerable: true,
|
|
10
10
|
get: function () {
|
|
11
11
|
return _component.default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/components/src/navigator/navigator-provider/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA","sourcesContent":["export { default } from './component';\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/components/src/navigator/navigator-provider/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA","sourcesContent":["export { default as NavigatorProvider } from './component';\n"]}
|
|
@@ -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.NavigatorScreen = void 0;
|
|
9
9
|
|
|
10
10
|
var _element = require("@wordpress/element");
|
|
11
11
|
|
|
@@ -13,8 +13,6 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
|
|
|
13
13
|
|
|
14
14
|
var _framerMotion = require("framer-motion");
|
|
15
15
|
|
|
16
|
-
var _react = require("@emotion/react");
|
|
17
|
-
|
|
18
16
|
var _dom = require("@wordpress/dom");
|
|
19
17
|
|
|
20
18
|
var _compose = require("@wordpress/compose");
|
|
@@ -25,31 +23,29 @@ var _escapeHtml = require("@wordpress/escape-html");
|
|
|
25
23
|
|
|
26
24
|
var _context = require("../../ui/context");
|
|
27
25
|
|
|
28
|
-
var _useCx = require("../../utils/hooks/use-cx");
|
|
29
|
-
|
|
30
26
|
var _view = require("../../view");
|
|
31
27
|
|
|
32
28
|
var _context2 = require("../context");
|
|
33
29
|
|
|
34
|
-
|
|
30
|
+
/**
|
|
31
|
+
* External dependencies
|
|
32
|
+
*/
|
|
33
|
+
// eslint-disable-next-line no-restricted-imports
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* WordPress dependencies
|
|
37
|
+
*/
|
|
35
38
|
|
|
39
|
+
/**
|
|
40
|
+
* Internal dependencies
|
|
41
|
+
*/
|
|
36
42
|
const animationEnterDelay = 0;
|
|
37
43
|
const animationEnterDuration = 0.14;
|
|
38
44
|
const animationExitDuration = 0.14;
|
|
39
45
|
const animationExitDelay = 0; // Props specific to `framer-motion` can't be currently passed to `NavigatorScreen`,
|
|
40
46
|
// as some of them would overlap with HTML props (e.g. `onAnimationStart`, ...)
|
|
41
47
|
|
|
42
|
-
|
|
43
|
-
name: "14x3t6z",
|
|
44
|
-
styles: "overflow-x:auto;max-height:100%"
|
|
45
|
-
} : {
|
|
46
|
-
name: "1ulogbc-classes",
|
|
47
|
-
styles: "overflow-x:auto;max-height:100%;label:classes;",
|
|
48
|
-
map: "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIkB3b3JkcHJlc3MvY29tcG9uZW50cy9zcmMvbmF2aWdhdG9yL25hdmlnYXRvci1zY3JlZW4vY29tcG9uZW50LnRzeCJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUErREkiLCJmaWxlIjoiQHdvcmRwcmVzcy9jb21wb25lbnRzL3NyYy9uYXZpZ2F0b3IvbmF2aWdhdG9yLXNjcmVlbi9jb21wb25lbnQudHN4Iiwic291cmNlc0NvbnRlbnQiOlsiLyoqXG4gKiBFeHRlcm5hbCBkZXBlbmRlbmNpZXNcbiAqL1xuaW1wb3J0IHR5cGUgeyBGb3J3YXJkZWRSZWYgfSBmcm9tICdyZWFjdCc7XG4vLyBlc2xpbnQtZGlzYWJsZS1uZXh0LWxpbmUgbm8tcmVzdHJpY3RlZC1pbXBvcnRzXG5pbXBvcnQgeyBtb3Rpb24sIE1vdGlvblByb3BzIH0gZnJvbSAnZnJhbWVyLW1vdGlvbic7XG5pbXBvcnQgeyBjc3MgfSBmcm9tICdAZW1vdGlvbi9yZWFjdCc7XG5cbi8qKlxuICogV29yZFByZXNzIGRlcGVuZGVuY2llc1xuICovXG5pbXBvcnQgeyBmb2N1cyB9IGZyb20gJ0B3b3JkcHJlc3MvZG9tJztcbmltcG9ydCB7IHVzZUNvbnRleHQsIHVzZUVmZmVjdCwgdXNlTWVtbywgdXNlUmVmIH0gZnJvbSAnQHdvcmRwcmVzcy9lbGVtZW50JztcbmltcG9ydCB7XG5cdHVzZVJlZHVjZWRNb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-
toString: _EMOTION_STRINGIFIED_CSS_ERROR__
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
function NavigatorScreen(props, forwardedRef) {
|
|
48
|
+
function UnconnectedNavigatorScreen(props, forwardedRef) {
|
|
53
49
|
const {
|
|
54
50
|
children,
|
|
55
51
|
className,
|
|
@@ -62,9 +58,7 @@ function NavigatorScreen(props, forwardedRef) {
|
|
|
62
58
|
} = (0, _element.useContext)(_context2.NavigatorContext);
|
|
63
59
|
const isMatch = location.path === (0, _escapeHtml.escapeAttribute)(path);
|
|
64
60
|
const wrapperRef = (0, _element.useRef)(null);
|
|
65
|
-
const previousLocation = (0, _compose.usePrevious)(location);
|
|
66
|
-
const cx = (0, _useCx.useCx)();
|
|
67
|
-
const classes = (0, _element.useMemo)(() => cx(_ref, className), [className, cx]); // Focus restoration
|
|
61
|
+
const previousLocation = (0, _compose.usePrevious)(location); // Focus restoration
|
|
68
62
|
|
|
69
63
|
const isInitialLocation = location.isInitial && !location.isBack;
|
|
70
64
|
(0, _element.useEffect)(() => {
|
|
@@ -72,7 +66,15 @@ function NavigatorScreen(props, forwardedRef) {
|
|
|
72
66
|
// - if the current location is not the initial one (to avoid moving focus on page load)
|
|
73
67
|
// - when the screen becomes visible
|
|
74
68
|
// - if the wrapper ref has been assigned
|
|
75
|
-
if
|
|
69
|
+
// - if focus hasn't already been restored for the current location
|
|
70
|
+
if (isInitialLocation || !isMatch || !wrapperRef.current || location.hasRestoredFocus) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const activeElement = wrapperRef.current.ownerDocument.activeElement; // If an element is already focused within the wrapper do not focus the
|
|
75
|
+
// element. This prevents inputs or buttons from losing focus unnecessarily.
|
|
76
|
+
|
|
77
|
+
if (wrapperRef.current.contains(activeElement)) {
|
|
76
78
|
return;
|
|
77
79
|
}
|
|
78
80
|
|
|
@@ -91,8 +93,9 @@ function NavigatorScreen(props, forwardedRef) {
|
|
|
91
93
|
elementToFocus = firstTabbable !== null && firstTabbable !== void 0 ? firstTabbable : wrapperRef.current;
|
|
92
94
|
}
|
|
93
95
|
|
|
96
|
+
location.hasRestoredFocus = true;
|
|
94
97
|
elementToFocus.focus();
|
|
95
|
-
}, [isInitialLocation, isMatch, location.isBack, previousLocation === null || previousLocation === void 0 ? void 0 : previousLocation.focusTargetSelector]);
|
|
98
|
+
}, [isInitialLocation, isMatch, location.hasRestoredFocus, location.isBack, previousLocation === null || previousLocation === void 0 ? void 0 : previousLocation.focusTargetSelector]);
|
|
96
99
|
const mergedWrapperRef = (0, _compose.useMergeRefs)([forwardedRef, wrapperRef]);
|
|
97
100
|
|
|
98
101
|
if (!isMatch) {
|
|
@@ -102,7 +105,7 @@ function NavigatorScreen(props, forwardedRef) {
|
|
|
102
105
|
if (prefersReducedMotion) {
|
|
103
106
|
return (0, _element.createElement)(_view.View, (0, _extends2.default)({
|
|
104
107
|
ref: mergedWrapperRef,
|
|
105
|
-
className:
|
|
108
|
+
className: className
|
|
106
109
|
}, otherProps), children);
|
|
107
110
|
}
|
|
108
111
|
|
|
@@ -135,7 +138,7 @@ function NavigatorScreen(props, forwardedRef) {
|
|
|
135
138
|
};
|
|
136
139
|
return (0, _element.createElement)(_framerMotion.motion.div, (0, _extends2.default)({
|
|
137
140
|
ref: mergedWrapperRef,
|
|
138
|
-
className:
|
|
141
|
+
className: className
|
|
139
142
|
}, otherProps, animatedProps), children);
|
|
140
143
|
}
|
|
141
144
|
/**
|
|
@@ -174,7 +177,8 @@ function NavigatorScreen(props, forwardedRef) {
|
|
|
174
177
|
*/
|
|
175
178
|
|
|
176
179
|
|
|
177
|
-
const
|
|
178
|
-
|
|
180
|
+
const NavigatorScreen = (0, _context.contextConnect)(UnconnectedNavigatorScreen, 'NavigatorScreen');
|
|
181
|
+
exports.NavigatorScreen = NavigatorScreen;
|
|
182
|
+
var _default = NavigatorScreen;
|
|
179
183
|
exports.default = _default;
|
|
180
184
|
//# sourceMappingURL=component.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/components/src/navigator/navigator-screen/component.tsx"],"names":["animationEnterDelay","animationEnterDuration","animationExitDuration","animationExitDelay","
|
|
1
|
+
{"version":3,"sources":["@wordpress/components/src/navigator/navigator-screen/component.tsx"],"names":["animationEnterDelay","animationEnterDuration","animationExitDuration","animationExitDelay","UnconnectedNavigatorScreen","props","forwardedRef","children","className","path","otherProps","prefersReducedMotion","location","NavigatorContext","isMatch","wrapperRef","previousLocation","isInitialLocation","isInitial","isBack","current","hasRestoredFocus","activeElement","ownerDocument","contains","elementToFocus","focusTargetSelector","querySelector","firstTabbable","focus","tabbable","find","mergedWrapperRef","animate","opacity","transition","delay","duration","ease","x","initial","exit","animatedProps","NavigatorScreen"],"mappings":";;;;;;;;;AAWA;;;;AANA;;AAKA;;AAEA;;AAKA;;AACA;;AAKA;;AAKA;;AACA;;AA7BA;AACA;AACA;AAEA;;AAGA;AACA;AACA;;AAWA;AACA;AACA;AAUA,MAAMA,mBAAmB,GAAG,CAA5B;AACA,MAAMC,sBAAsB,GAAG,IAA/B;AACA,MAAMC,qBAAqB,GAAG,IAA9B;AACA,MAAMC,kBAAkB,GAAG,CAA3B,C,CAEA;AACA;;AAMA,SAASC,0BAAT,CACCC,KADD,EAECC,YAFD,EAGE;AACD,QAAM;AAAEC,IAAAA,QAAF;AAAYC,IAAAA,SAAZ;AAAuBC,IAAAA,IAAvB;AAA6B,OAAGC;AAAhC,MAA+C,+BACpDL,KADoD,EAEpD,iBAFoD,CAArD;AAKA,QAAMM,oBAAoB,GAAG,gCAA7B;AACA,QAAM;AAAEC,IAAAA;AAAF,MAAe,yBAAYC,0BAAZ,CAArB;AACA,QAAMC,OAAO,GAAGF,QAAQ,CAACH,IAAT,KAAkB,iCAAiBA,IAAjB,CAAlC;AACA,QAAMM,UAAU,GAAG,qBAA0B,IAA1B,CAAnB;AAEA,QAAMC,gBAAgB,GAAG,0BAAaJ,QAAb,CAAzB,CAXC,CAaD;;AACA,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AMGnC,QANH,CADD;AAUA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,MAAMoC,eAAe,GAAG,6BAC9BvC,0BAD8B,EAE9B,iBAF8B,CAAxB;;eAKQuC,e","sourcesContent":["/**\n * External dependencies\n */\nimport type { ForwardedRef } from 'react';\n// eslint-disable-next-line no-restricted-imports\nimport { motion, MotionProps } from 'framer-motion';\n\n/**\n * WordPress dependencies\n */\nimport { focus } from '@wordpress/dom';\nimport { useContext, useEffect, useRef } from '@wordpress/element';\nimport {\n\tuseReducedMotion,\n\tuseMergeRefs,\n\tusePrevious,\n} from '@wordpress/compose';\nimport { isRTL } from '@wordpress/i18n';\nimport { escapeAttribute } from '@wordpress/escape-html';\n\n/**\n * Internal dependencies\n */\nimport {\n\tcontextConnect,\n\tuseContextSystem,\n\tWordPressComponentProps,\n} from '../../ui/context';\nimport { View } from '../../view';\nimport { NavigatorContext } from '../context';\nimport type { NavigatorScreenProps } from '../types';\n\nconst animationEnterDelay = 0;\nconst animationEnterDuration = 0.14;\nconst animationExitDuration = 0.14;\nconst animationExitDelay = 0;\n\n// Props specific to `framer-motion` can't be currently passed to `NavigatorScreen`,\n// as some of them would overlap with HTML props (e.g. `onAnimationStart`, ...)\ntype Props = Omit<\n\tWordPressComponentProps< NavigatorScreenProps, 'div', false >,\n\tkeyof MotionProps\n>;\n\nfunction UnconnectedNavigatorScreen(\n\tprops: Props,\n\tforwardedRef: ForwardedRef< any >\n) {\n\tconst { children, className, path, ...otherProps } = useContextSystem(\n\t\tprops,\n\t\t'NavigatorScreen'\n\t);\n\n\tconst prefersReducedMotion = useReducedMotion();\n\tconst { location } = useContext( NavigatorContext );\n\tconst isMatch = location.path === escapeAttribute( path );\n\tconst wrapperRef = useRef< HTMLDivElement >( null );\n\n\tconst previousLocation = usePrevious( location );\n\n\t// Focus restoration\n\tconst isInitialLocation = location.isInitial && ! location.isBack;\n\tuseEffect( () => {\n\t\t// Only attempt to restore focus:\n\t\t// - if the current location is not the initial one (to avoid moving focus on page load)\n\t\t// - when the screen becomes visible\n\t\t// - if the wrapper ref has been assigned\n\t\t// - if focus hasn't already been restored for the current location\n\t\tif (\n\t\t\tisInitialLocation ||\n\t\t\t! isMatch ||\n\t\t\t! wrapperRef.current ||\n\t\t\tlocation.hasRestoredFocus\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst activeElement = wrapperRef.current.ownerDocument.activeElement;\n\n\t\t// If an element is already focused within the wrapper do not focus the\n\t\t// element. This prevents inputs or buttons from losing focus unnecessarily.\n\t\tif ( wrapperRef.current.contains( activeElement ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tlet elementToFocus: HTMLElement | null = null;\n\n\t\t// When navigating back, if a selector is provided, use it to look for the\n\t\t// target element (assumed to be a node inside the current NavigatorScreen)\n\t\tif ( location.isBack && previousLocation?.focusTargetSelector ) {\n\t\t\telementToFocus = wrapperRef.current.querySelector(\n\t\t\t\tpreviousLocation.focusTargetSelector\n\t\t\t);\n\t\t}\n\n\t\t// If the previous query didn't run or find any element to focus, fallback\n\t\t// to the first tabbable element in the screen (or the screen itself).\n\t\tif ( ! elementToFocus ) {\n\t\t\tconst firstTabbable = (\n\t\t\t\tfocus.tabbable.find( wrapperRef.current ) as HTMLElement[]\n\t\t\t )[ 0 ];\n\t\t\telementToFocus = firstTabbable ?? wrapperRef.current;\n\t\t}\n\n\t\tlocation.hasRestoredFocus = true;\n\t\telementToFocus.focus();\n\t}, [\n\t\tisInitialLocation,\n\t\tisMatch,\n\t\tlocation.hasRestoredFocus,\n\t\tlocation.isBack,\n\t\tpreviousLocation?.focusTargetSelector,\n\t] );\n\n\tconst mergedWrapperRef = useMergeRefs( [ forwardedRef, wrapperRef ] );\n\n\tif ( ! isMatch ) {\n\t\treturn null;\n\t}\n\n\tif ( prefersReducedMotion ) {\n\t\treturn (\n\t\t\t<View\n\t\t\t\tref={ mergedWrapperRef }\n\t\t\t\tclassName={ className }\n\t\t\t\t{ ...otherProps }\n\t\t\t>\n\t\t\t\t{ children }\n\t\t\t</View>\n\t\t);\n\t}\n\n\tconst animate = {\n\t\topacity: 1,\n\t\ttransition: {\n\t\t\tdelay: animationEnterDelay,\n\t\t\tduration: animationEnterDuration,\n\t\t\tease: 'easeInOut',\n\t\t},\n\t\tx: 0,\n\t};\n\tconst initial = {\n\t\topacity: 0,\n\t\tx:\n\t\t\t( isRTL() && location.isBack ) || ( ! isRTL() && ! location.isBack )\n\t\t\t\t? 50\n\t\t\t\t: -50,\n\t};\n\tconst exit = {\n\t\tdelay: animationExitDelay,\n\t\topacity: 0,\n\t\tx:\n\t\t\t( ! isRTL() && location.isBack ) || ( isRTL() && ! location.isBack )\n\t\t\t\t? 50\n\t\t\t\t: -50,\n\t\ttransition: {\n\t\t\tduration: animationExitDuration,\n\t\t\tease: 'easeInOut',\n\t\t},\n\t};\n\n\tconst animatedProps = {\n\t\tanimate,\n\t\texit,\n\t\tinitial,\n\t};\n\n\treturn (\n\t\t<motion.div\n\t\t\tref={ mergedWrapperRef }\n\t\t\tclassName={ className }\n\t\t\t{ ...otherProps }\n\t\t\t{ ...animatedProps }\n\t\t>\n\t\t\t{ children }\n\t\t</motion.div>\n\t);\n}\n\n/**\n * The `NavigatorScreen` component represents a single view/screen/panel and\n * should be used in combination with the `NavigatorProvider`, the\n * `NavigatorButton` and the `NavigatorBackButton` components (or the `useNavigator`\n * hook).\n *\n * @example\n * ```jsx\n * import {\n * __experimentalNavigatorProvider as NavigatorProvider,\n * __experimentalNavigatorScreen as NavigatorScreen,\n * __experimentalNavigatorButton as NavigatorButton,\n * __experimentalNavigatorBackButton as NavigatorBackButton,\n * } from '@wordpress/components';\n *\n * const MyNavigation = () => (\n * <NavigatorProvider initialPath=\"/\">\n * <NavigatorScreen path=\"/\">\n * <p>This is the home screen.</p>\n * <NavigatorButton path=\"/child\">\n * Navigate to child screen.\n * </NavigatorButton>\n * </NavigatorScreen>\n *\n * <NavigatorScreen path=\"/child\">\n * <p>This is the child screen.</p>\n * <NavigatorBackButton>\n * Go back\n * </NavigatorBackButton>\n * </NavigatorScreen>\n * </NavigatorProvider>\n * );\n * ```\n */\nexport const NavigatorScreen = contextConnect(\n\tUnconnectedNavigatorScreen,\n\t'NavigatorScreen'\n);\n\nexport default NavigatorScreen;\n"]}
|
|
@@ -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
Object.defineProperty(exports, "
|
|
8
|
+
Object.defineProperty(exports, "NavigatorScreen", {
|
|
9
9
|
enumerable: true,
|
|
10
10
|
get: function () {
|
|
11
11
|
return _component.default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/components/src/navigator/navigator-screen/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA","sourcesContent":["export { default } from './component';\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/components/src/navigator/navigator-screen/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA","sourcesContent":["export { default as NavigatorScreen } from './component';\n"]}
|
|
@@ -79,25 +79,23 @@ function useResizeLabel(_ref) {
|
|
|
79
79
|
*/
|
|
80
80
|
|
|
81
81
|
const moveTimeoutRef = (0, _element.useRef)();
|
|
82
|
+
const debounceUnsetMoveXY = (0, _element.useCallback)(() => {
|
|
83
|
+
const unsetMoveXY = () => {
|
|
84
|
+
/*
|
|
85
|
+
* If axis is controlled, we will avoid resetting the moveX and moveY values.
|
|
86
|
+
* This will allow for the preferred axis values to persist in the label.
|
|
87
|
+
*/
|
|
88
|
+
if (isAxisControlled) return;
|
|
89
|
+
setMoveX(false);
|
|
90
|
+
setMoveY(false);
|
|
91
|
+
};
|
|
82
92
|
|
|
83
|
-
const unsetMoveXY = () => {
|
|
84
|
-
/*
|
|
85
|
-
* If axis is controlled, we will avoid resetting the moveX and moveY values.
|
|
86
|
-
* This will allow for the preferred axis values to persist in the label.
|
|
87
|
-
*/
|
|
88
|
-
if (isAxisControlled) return;
|
|
89
|
-
setMoveX(false);
|
|
90
|
-
setMoveY(false);
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
const debounceUnsetMoveXY = () => {
|
|
94
93
|
if (moveTimeoutRef.current) {
|
|
95
94
|
window.clearTimeout(moveTimeoutRef.current);
|
|
96
95
|
}
|
|
97
96
|
|
|
98
97
|
moveTimeoutRef.current = window.setTimeout(unsetMoveXY, fadeTimeout);
|
|
99
|
-
};
|
|
100
|
-
|
|
98
|
+
}, [fadeTimeout, isAxisControlled]);
|
|
101
99
|
(0, _element.useEffect)(() => {
|
|
102
100
|
/*
|
|
103
101
|
* On the initial render of useResizeAware, the height and width values are
|
|
@@ -140,7 +138,7 @@ function useResizeLabel(_ref) {
|
|
|
140
138
|
height
|
|
141
139
|
});
|
|
142
140
|
debounceUnsetMoveXY();
|
|
143
|
-
}, [width, height]);
|
|
141
|
+
}, [width, height, onResize, debounceUnsetMoveXY]);
|
|
144
142
|
const label = getSizeLabel({
|
|
145
143
|
axis,
|
|
146
144
|
height,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/components/src/resizable-box/resize-tooltip/utils.ts"],"names":["noop","POSITIONS","bottom","corner","useResizeLabel","axis","fadeTimeout","onResize","position","showPx","resizeListener","sizes","isAxisControlled","moveX","setMoveX","moveY","setMoveY","width","height","heightRef","widthRef","moveTimeoutRef","unsetMoveXY","debounceUnsetMoveXY","current","window","clearTimeout","setTimeout","isRendered","didWidthChange","didHeightChange","label","getSizeLabel","undefined","labelUnit"],"mappings":";;;;;;;;AAGA;;AACA;;AAJA;AACA;AACA;AAIA,MAAMA,IAAI,GAAG,MAAM,CAAE,CAArB;;AAIO,MAAMC,SAA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;AACA;;AAED,SAAOD,SAAP;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect, useRef, useState } from '@wordpress/element';\nimport { useResizeObserver } from '@wordpress/compose';\n\nconst noop = () => {};\n\nexport type Axis = 'x' | 'y';\n\nexport const POSITIONS = {\n\tbottom: 'bottom',\n\tcorner: 'corner',\n} as const;\n\nexport type Position = typeof POSITIONS[ keyof typeof POSITIONS ];\n\ninterface UseResizeLabelProps {\n\t/** The label value. */\n\tlabel?: string;\n\t/** Element to be rendered for resize listening events. */\n\tresizeListener: JSX.Element;\n}\n\ninterface UseResizeLabelArgs {\n\taxis?: Axis;\n\tfadeTimeout: number;\n\tonResize( data: { width: number | null; height: number | null } ): void;\n\tposition: Position;\n\tshowPx: boolean;\n}\n\n/**\n * Custom hook that manages resize listener events. It also provides a label\n * based on current resize width x height values.\n *\n * @param props\n * @param props.axis Only shows the label corresponding to the axis.\n * @param props.fadeTimeout Duration (ms) before deactivating the resize label.\n * @param props.onResize Callback when a resize occurs. Provides { width, height } callback.\n * @param props.position Adjusts label value.\n * @param props.showPx Whether to add `PX` to the label.\n *\n * @return Properties for hook.\n */\nexport function useResizeLabel( {\n\taxis,\n\tfadeTimeout = 180,\n\tonResize = noop,\n\tposition = POSITIONS.bottom,\n\tshowPx = false,\n}: UseResizeLabelArgs ): UseResizeLabelProps {\n\t/*\n\t * The width/height values derive from this special useResizeObserver hook.\n\t * This custom hook uses the ResizeObserver API to listen for resize events.\n\t */\n\tconst [ resizeListener, sizes ] = useResizeObserver();\n\n\t/*\n\t * Indicates if the x/y axis is preferred.\n\t * If set, we will avoid resetting the moveX and moveY values.\n\t * This will allow for the preferred axis values to persist in the label.\n\t */\n\tconst isAxisControlled = !! axis;\n\n\t/*\n\t * The moveX and moveY values are used to track whether the label should\n\t * display width, height, or width x height.\n\t */\n\tconst [ moveX, setMoveX ] = useState( false );\n\tconst [ moveY, setMoveY ] = useState( false );\n\n\t/*\n\t * Cached dimension values to check for width/height updates from the\n\t * sizes property from useResizeAware()\n\t */\n\tconst { width, height } = sizes;\n\tconst heightRef = useRef( height );\n\tconst widthRef = useRef( width );\n\n\t/*\n\t * This timeout is used with setMoveX and setMoveY to determine of\n\t * both width and height values have changed at (roughly) the same time.\n\t */\n\tconst moveTimeoutRef = useRef< number >();\n\n\tconst unsetMoveXY = () => {\n\t\t/*\n\t\t * If axis is controlled, we will avoid resetting the moveX and moveY values.\n\t\t * This will allow for the preferred axis values to persist in the label.\n\t\t */\n\t\tif ( isAxisControlled ) return;\n\t\tsetMoveX( false );\n\t\tsetMoveY( false );\n\t};\n\n\tconst debounceUnsetMoveXY = () => {\n\t\tif ( moveTimeoutRef.current ) {\n\t\t\twindow.clearTimeout( moveTimeoutRef.current );\n\t\t}\n\n\t\tmoveTimeoutRef.current = window.setTimeout( unsetMoveXY, fadeTimeout );\n\t};\n\n\tuseEffect( () => {\n\t\t/*\n\t\t * On the initial render of useResizeAware, the height and width values are\n\t\t * null. They are calculated then set using via an internal useEffect hook.\n\t\t */\n\t\tconst isRendered = width !== null || height !== null;\n\n\t\tif ( ! isRendered ) return;\n\n\t\tconst didWidthChange = width !== widthRef.current;\n\t\tconst didHeightChange = height !== heightRef.current;\n\n\t\tif ( ! didWidthChange && ! didHeightChange ) return;\n\n\t\t/*\n\t\t * After the initial render, the useResizeAware will set the first\n\t\t * width and height values. We'll sync those values with our\n\t\t * width and height refs. However, we shouldn't render our Tooltip\n\t\t * label on this first cycle.\n\t\t */\n\t\tif ( width && ! widthRef.current && height && ! heightRef.current ) {\n\t\t\twidthRef.current = width;\n\t\t\theightRef.current = height;\n\t\t\treturn;\n\t\t}\n\n\t\t/*\n\t\t * After the first cycle, we can track width and height changes.\n\t\t */\n\t\tif ( didWidthChange ) {\n\t\t\tsetMoveX( true );\n\t\t\twidthRef.current = width;\n\t\t}\n\n\t\tif ( didHeightChange ) {\n\t\t\tsetMoveY( true );\n\t\t\theightRef.current = height;\n\t\t}\n\n\t\tonResize( { width, height } );\n\t\tdebounceUnsetMoveXY();\n\t}, [ width, height ] );\n\n\tconst label = getSizeLabel( {\n\t\taxis,\n\t\theight,\n\t\tmoveX,\n\t\tmoveY,\n\t\tposition,\n\t\tshowPx,\n\t\twidth,\n\t} );\n\n\treturn {\n\t\tlabel,\n\t\tresizeListener,\n\t};\n}\n\ninterface GetSizeLabelArgs {\n\taxis?: Axis;\n\theight: number | null;\n\tmoveX: boolean;\n\tmoveY: boolean;\n\tposition: Position;\n\tshowPx: boolean;\n\twidth: number | null;\n}\n\n/**\n * Gets the resize label based on width and height values (as well as recent changes).\n *\n * @param props\n * @param props.axis Only shows the label corresponding to the axis.\n * @param props.height Height value.\n * @param props.moveX Recent width (x axis) changes.\n * @param props.moveY Recent width (y axis) changes.\n * @param props.position Adjusts label value.\n * @param props.showPx Whether to add `PX` to the label.\n * @param props.width Width value.\n *\n * @return The rendered label.\n */\nfunction getSizeLabel( {\n\taxis,\n\theight,\n\tmoveX = false,\n\tmoveY = false,\n\tposition = POSITIONS.bottom,\n\tshowPx = false,\n\twidth,\n}: GetSizeLabelArgs ): string | undefined {\n\tif ( ! moveX && ! moveY ) return undefined;\n\n\t/*\n\t * Corner position...\n\t * We want the label to appear like width x height.\n\t */\n\tif ( position === POSITIONS.corner ) {\n\t\treturn `${ width } x ${ height }`;\n\t}\n\n\t/*\n\t * Other POSITIONS...\n\t * The label will combine both width x height values if both\n\t * values have recently been changed.\n\t *\n\t * Otherwise, only width or height will be displayed.\n\t * The `PX` unit will be added, if specified by the `showPx` prop.\n\t */\n\tconst labelUnit = showPx ? ' px' : '';\n\n\tif ( axis ) {\n\t\tif ( axis === 'x' && moveX ) {\n\t\t\treturn `${ width }${ labelUnit }`;\n\t\t}\n\t\tif ( axis === 'y' && moveY ) {\n\t\t\treturn `${ height }${ labelUnit }`;\n\t\t}\n\t}\n\n\tif ( moveX && moveY ) {\n\t\treturn `${ width } x ${ height }`;\n\t}\n\tif ( moveX ) {\n\t\treturn `${ width }${ labelUnit }`;\n\t}\n\tif ( moveY ) {\n\t\treturn `${ height }${ labelUnit }`;\n\t}\n\n\treturn undefined;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/components/src/resizable-box/resize-tooltip/utils.ts"],"names":["noop","POSITIONS","bottom","corner","useResizeLabel","axis","fadeTimeout","onResize","position","showPx","resizeListener","sizes","isAxisControlled","moveX","setMoveX","moveY","setMoveY","width","height","heightRef","widthRef","moveTimeoutRef","debounceUnsetMoveXY","unsetMoveXY","current","window","clearTimeout","setTimeout","isRendered","didWidthChange","didHeightChange","label","getSizeLabel","undefined","labelUnit"],"mappings":";;;;;;;;AAGA;;AACA;;AAJA;AACA;AACA;AAIA,MAAMA,IAAI,GAAG,MAAM,CAAE,CAArB;;AAIO,MAAMC,SAAS,GAAG;AACxBC,EAAAA,MAAM,EAAE,QADgB;AAExBC,EAAAA,MAAM,EAAE;AAFgB,CAAlB;;;AAsBP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,cAAT,OAMsC;AAAA,MANb;AAC/BC,IAAAA,IAD+B;AAE/BC,IAAAA,WAAW,GAAG,GAFiB;AAG/BC,IAAAA,QAAQ,GAAGP,IAHoB;AAI/BQ,IAAAA,QAAQ,GAAGP,SAAS,CAACC,MAJU;AAK/BO,IAAAA,MAAM,GAAG;AALsB,GAMa;;AAC5C;AACD;AACA;AACA;AACC,QAAM,CAAEC,cAAF,EAAkBC,KAAlB,IAA4B,iCAAlC;AAEA;AACD;AACA;AACA;AACA;;AACC,QAAMC,gBAAgB,GAAG,CAAC,CAAEP,IAA5B;AAEA;AACD;AACA;AACA;;AACC,QAAM,CAAEQ,KAAF,EAASC,QAAT,IAAsB,uBAAU,KAAV,CAA5B;AACA,QAAM,CAAEC,KAAF,EAASC,QAAT,IAAsB,uBAAU,KAAV,CAA5B;AAEA;AACD;AACA;AACA;;AACC,QAAM;AAAEC,IAAAA,KAAF;AAASC,IAAAA;AAAT,MAAoBP,KAA1B;AACA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AACA;AACA;;;AACC,QAAMgB,SAAS,GAAGzB,MAAM,GAAG,KAAH,GAAW,EAAnC;;AAEA,MAAKJ,IAAL,EAAY;AACX,QAAKA,IAAI,KAAK,GAAT,IAAgBQ,KAArB,EAA6B;AAC5B,aAAQ,GAAGI,KAAO,GAAGiB,SAAW,EAAhC;AACA;;AACD,QAAK7B,IAAI,KAAK,GAAT,IAAgBU,KAArB,EAA6B;AAC5B,aAAQ,GAAGG,MAAQ,GAAGgB,SAAW,EAAjC;AACA;AACD;;AAED,MAAKrB,KAAK,IAAIE,KAAd,EAAsB;AACrB,WAAQ,GAAGE,KAAO,MAAMC,MAAQ,EAAhC;AACA;;AACD,MAAKL,KAAL,EAAa;AACZ,WAAQ,GAAGI,KAAO,GAAGiB,SAAW,EAAhC;AACA;;AACD,MAAKnB,KAAL,EAAa;AACZ,WAAQ,GAAGG,MAAQ,GAAGgB,SAAW,EAAjC;AACA;;AAED,SAAOD,SAAP;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useCallback, useEffect, useRef, useState } from '@wordpress/element';\nimport { useResizeObserver } from '@wordpress/compose';\n\nconst noop = () => {};\n\nexport type Axis = 'x' | 'y';\n\nexport const POSITIONS = {\n\tbottom: 'bottom',\n\tcorner: 'corner',\n} as const;\n\nexport type Position = typeof POSITIONS[ keyof typeof POSITIONS ];\n\ninterface UseResizeLabelProps {\n\t/** The label value. */\n\tlabel?: string;\n\t/** Element to be rendered for resize listening events. */\n\tresizeListener: JSX.Element;\n}\n\ninterface UseResizeLabelArgs {\n\taxis?: Axis;\n\tfadeTimeout: number;\n\tonResize( data: { width: number | null; height: number | null } ): void;\n\tposition: Position;\n\tshowPx: boolean;\n}\n\n/**\n * Custom hook that manages resize listener events. It also provides a label\n * based on current resize width x height values.\n *\n * @param props\n * @param props.axis Only shows the label corresponding to the axis.\n * @param props.fadeTimeout Duration (ms) before deactivating the resize label.\n * @param props.onResize Callback when a resize occurs. Provides { width, height } callback.\n * @param props.position Adjusts label value.\n * @param props.showPx Whether to add `PX` to the label.\n *\n * @return Properties for hook.\n */\nexport function useResizeLabel( {\n\taxis,\n\tfadeTimeout = 180,\n\tonResize = noop,\n\tposition = POSITIONS.bottom,\n\tshowPx = false,\n}: UseResizeLabelArgs ): UseResizeLabelProps {\n\t/*\n\t * The width/height values derive from this special useResizeObserver hook.\n\t * This custom hook uses the ResizeObserver API to listen for resize events.\n\t */\n\tconst [ resizeListener, sizes ] = useResizeObserver();\n\n\t/*\n\t * Indicates if the x/y axis is preferred.\n\t * If set, we will avoid resetting the moveX and moveY values.\n\t * This will allow for the preferred axis values to persist in the label.\n\t */\n\tconst isAxisControlled = !! axis;\n\n\t/*\n\t * The moveX and moveY values are used to track whether the label should\n\t * display width, height, or width x height.\n\t */\n\tconst [ moveX, setMoveX ] = useState( false );\n\tconst [ moveY, setMoveY ] = useState( false );\n\n\t/*\n\t * Cached dimension values to check for width/height updates from the\n\t * sizes property from useResizeAware()\n\t */\n\tconst { width, height } = sizes;\n\tconst heightRef = useRef( height );\n\tconst widthRef = useRef( width );\n\n\t/*\n\t * This timeout is used with setMoveX and setMoveY to determine of\n\t * both width and height values have changed at (roughly) the same time.\n\t */\n\tconst moveTimeoutRef = useRef< number >();\n\n\tconst debounceUnsetMoveXY = useCallback( () => {\n\t\tconst unsetMoveXY = () => {\n\t\t\t/*\n\t\t\t * If axis is controlled, we will avoid resetting the moveX and moveY values.\n\t\t\t * This will allow for the preferred axis values to persist in the label.\n\t\t\t */\n\t\t\tif ( isAxisControlled ) return;\n\t\t\tsetMoveX( false );\n\t\t\tsetMoveY( false );\n\t\t};\n\n\t\tif ( moveTimeoutRef.current ) {\n\t\t\twindow.clearTimeout( moveTimeoutRef.current );\n\t\t}\n\n\t\tmoveTimeoutRef.current = window.setTimeout( unsetMoveXY, fadeTimeout );\n\t}, [ fadeTimeout, isAxisControlled ] );\n\n\tuseEffect( () => {\n\t\t/*\n\t\t * On the initial render of useResizeAware, the height and width values are\n\t\t * null. They are calculated then set using via an internal useEffect hook.\n\t\t */\n\t\tconst isRendered = width !== null || height !== null;\n\n\t\tif ( ! isRendered ) return;\n\n\t\tconst didWidthChange = width !== widthRef.current;\n\t\tconst didHeightChange = height !== heightRef.current;\n\n\t\tif ( ! didWidthChange && ! didHeightChange ) return;\n\n\t\t/*\n\t\t * After the initial render, the useResizeAware will set the first\n\t\t * width and height values. We'll sync those values with our\n\t\t * width and height refs. However, we shouldn't render our Tooltip\n\t\t * label on this first cycle.\n\t\t */\n\t\tif ( width && ! widthRef.current && height && ! heightRef.current ) {\n\t\t\twidthRef.current = width;\n\t\t\theightRef.current = height;\n\t\t\treturn;\n\t\t}\n\n\t\t/*\n\t\t * After the first cycle, we can track width and height changes.\n\t\t */\n\t\tif ( didWidthChange ) {\n\t\t\tsetMoveX( true );\n\t\t\twidthRef.current = width;\n\t\t}\n\n\t\tif ( didHeightChange ) {\n\t\t\tsetMoveY( true );\n\t\t\theightRef.current = height;\n\t\t}\n\n\t\tonResize( { width, height } );\n\t\tdebounceUnsetMoveXY();\n\t}, [ width, height, onResize, debounceUnsetMoveXY ] );\n\n\tconst label = getSizeLabel( {\n\t\taxis,\n\t\theight,\n\t\tmoveX,\n\t\tmoveY,\n\t\tposition,\n\t\tshowPx,\n\t\twidth,\n\t} );\n\n\treturn {\n\t\tlabel,\n\t\tresizeListener,\n\t};\n}\n\ninterface GetSizeLabelArgs {\n\taxis?: Axis;\n\theight: number | null;\n\tmoveX: boolean;\n\tmoveY: boolean;\n\tposition: Position;\n\tshowPx: boolean;\n\twidth: number | null;\n}\n\n/**\n * Gets the resize label based on width and height values (as well as recent changes).\n *\n * @param props\n * @param props.axis Only shows the label corresponding to the axis.\n * @param props.height Height value.\n * @param props.moveX Recent width (x axis) changes.\n * @param props.moveY Recent width (y axis) changes.\n * @param props.position Adjusts label value.\n * @param props.showPx Whether to add `PX` to the label.\n * @param props.width Width value.\n *\n * @return The rendered label.\n */\nfunction getSizeLabel( {\n\taxis,\n\theight,\n\tmoveX = false,\n\tmoveY = false,\n\tposition = POSITIONS.bottom,\n\tshowPx = false,\n\twidth,\n}: GetSizeLabelArgs ): string | undefined {\n\tif ( ! moveX && ! moveY ) return undefined;\n\n\t/*\n\t * Corner position...\n\t * We want the label to appear like width x height.\n\t */\n\tif ( position === POSITIONS.corner ) {\n\t\treturn `${ width } x ${ height }`;\n\t}\n\n\t/*\n\t * Other POSITIONS...\n\t * The label will combine both width x height values if both\n\t * values have recently been changed.\n\t *\n\t * Otherwise, only width or height will be displayed.\n\t * The `PX` unit will be added, if specified by the `showPx` prop.\n\t */\n\tconst labelUnit = showPx ? ' px' : '';\n\n\tif ( axis ) {\n\t\tif ( axis === 'x' && moveX ) {\n\t\t\treturn `${ width }${ labelUnit }`;\n\t\t}\n\t\tif ( axis === 'y' && moveY ) {\n\t\t\treturn `${ height }${ labelUnit }`;\n\t\t}\n\t}\n\n\tif ( moveX && moveY ) {\n\t\treturn `${ width } x ${ height }`;\n\t}\n\tif ( moveX ) {\n\t\treturn `${ width }${ labelUnit }`;\n\t}\n\tif ( moveY ) {\n\t\treturn `${ height }${ labelUnit }`;\n\t}\n\n\treturn undefined;\n}\n"]}
|