@wordpress/components 25.14.0 → 25.15.1-next.79a6196f.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 +51 -0
- package/CONTRIBUTING.md +57 -115
- package/LICENSE.md +1 -1
- package/build/base-control/index.js +17 -13
- package/build/base-control/index.js.map +1 -1
- package/build/border-box-control/border-box-control-linked-button/component.js +1 -1
- package/build/border-box-control/border-box-control-linked-button/component.js.map +1 -1
- package/build/border-control/border-control-style-picker/component.js +1 -1
- package/build/border-control/border-control-style-picker/component.js.map +1 -1
- package/build/box-control/index.js +1 -1
- package/build/box-control/index.js.map +1 -1
- package/build/box-control/linked-button.js +1 -1
- package/build/box-control/linked-button.js.map +1 -1
- package/build/button/index.js +1 -1
- package/build/button/index.js.map +1 -1
- package/build/color-palette/index.native.js +11 -7
- package/build/color-palette/index.native.js.map +1 -1
- package/build/color-picker/color-copy-button.js +1 -1
- package/build/color-picker/color-copy-button.js.map +1 -1
- package/build/context/wordpress-component.js.map +1 -1
- package/build/custom-select-control-v2/index.js +11 -10
- package/build/custom-select-control-v2/index.js.map +1 -1
- package/build/date-time/date/styles.js +8 -8
- package/build/date-time/date/styles.js.map +1 -1
- package/build/dropdown-menu-v2/index.js +205 -159
- package/build/dropdown-menu-v2/index.js.map +1 -1
- package/build/dropdown-menu-v2/styles.js +86 -77
- package/build/dropdown-menu-v2/styles.js.map +1 -1
- package/build/dropdown-menu-v2/types.js.map +1 -1
- package/build/duotone-picker/duotone-picker.js +4 -3
- package/build/duotone-picker/duotone-picker.js.map +1 -1
- package/build/font-size-picker/index.js +4 -2
- package/build/font-size-picker/index.js.map +1 -1
- package/build/font-size-picker/index.native.js +6 -3
- package/build/font-size-picker/index.native.js.map +1 -1
- package/build/form-token-field/index.js +10 -5
- package/build/form-token-field/index.js.map +1 -1
- package/build/form-token-field/token.js +1 -0
- package/build/form-token-field/token.js.map +1 -1
- package/build/gradient-picker/index.js +3 -2
- package/build/gradient-picker/index.js.map +1 -1
- package/build/index.native.js +20 -3
- package/build/index.native.js.map +1 -1
- package/build/input-control/styles/input-control-styles.js +32 -29
- package/build/input-control/styles/input-control-styles.js.map +1 -1
- package/build/input-control/types.js.map +1 -1
- package/build/lock-unlock.js +18 -0
- package/build/lock-unlock.js.map +1 -0
- package/build/mobile/bottom-sheet/index.native.js +8 -0
- package/build/mobile/bottom-sheet/index.native.js.map +1 -1
- package/build/mobile/color-settings/palette.screen.native.js +8 -4
- package/build/mobile/color-settings/palette.screen.native.js.map +1 -1
- package/build/mobile/global-styles-context/utils.native.js +26 -13
- package/build/mobile/global-styles-context/utils.native.js.map +1 -1
- package/build/mobile/image/constants.js +12 -0
- package/build/mobile/image/constants.js.map +1 -0
- package/build/mobile/image/index.native.js +26 -18
- package/build/mobile/image/index.native.js.map +1 -1
- package/build/mobile/keyboard-aware-flat-list/index.android.js +40 -8
- package/build/mobile/keyboard-aware-flat-list/index.android.js.map +1 -1
- package/build/mobile/keyboard-aware-flat-list/index.ios.js +44 -68
- package/build/mobile/keyboard-aware-flat-list/index.ios.js.map +1 -1
- package/build/mobile/keyboard-aware-flat-list/use-scroll-to-element.native.js +39 -0
- package/build/mobile/keyboard-aware-flat-list/use-scroll-to-element.native.js.map +1 -0
- package/build/mobile/keyboard-aware-flat-list/{use-scroll-to-text-input.native.js → use-scroll-to-section.native.js} +22 -29
- package/build/mobile/keyboard-aware-flat-list/use-scroll-to-section.native.js.map +1 -0
- package/build/mobile/keyboard-aware-flat-list/use-scroll.native.js +93 -0
- package/build/mobile/keyboard-aware-flat-list/use-scroll.native.js.map +1 -0
- package/build/mobile/utils/get-px-from-css-unit.native.js +302 -0
- package/build/mobile/utils/get-px-from-css-unit.native.js.map +1 -0
- package/build/modal/index.js +18 -13
- package/build/modal/index.js.map +1 -1
- package/build/navigation/menu/menu-title.js +1 -1
- package/build/navigation/menu/menu-title.js.map +1 -1
- package/build/navigator/navigator-provider/component.js +13 -15
- package/build/navigator/navigator-provider/component.js.map +1 -1
- package/build/navigator/navigator-screen/component.js +23 -63
- package/build/navigator/navigator-screen/component.js.map +1 -1
- package/build/navigator/styles.js +52 -0
- package/build/navigator/styles.js.map +1 -0
- package/build/number-control/index.js +4 -8
- package/build/number-control/index.js.map +1 -1
- package/build/number-control/types.js.map +1 -1
- package/build/palette-edit/index.js +15 -54
- package/build/palette-edit/index.js.map +1 -1
- package/build/private-apis.js +11 -26
- package/build/private-apis.js.map +1 -1
- package/build/private-apis.native.js +21 -0
- package/build/private-apis.native.js.map +1 -0
- package/build/radio-control/index.js +1 -0
- package/build/radio-control/index.js.map +1 -1
- package/build/range-control/index.js +1 -1
- package/build/range-control/index.js.map +1 -1
- package/build/select-control/styles/select-control-styles.js +15 -25
- package/build/select-control/styles/select-control-styles.js.map +1 -1
- package/build/slot-fill/index.js +3 -2
- package/build/slot-fill/index.js.map +1 -1
- package/build/slot-fill/types.js.map +1 -1
- package/build/snackbar/types.js.map +1 -1
- package/build/tabs/styles.js +3 -3
- package/build/tabs/styles.js.map +1 -1
- package/build/tabs/tabpanel.js +9 -7
- package/build/tabs/tabpanel.js.map +1 -1
- package/build/toggle-group-control/toggle-group-control/component.js +4 -4
- package/build/toggle-group-control/toggle-group-control/component.js.map +1 -1
- package/build/toggle-group-control/toggle-group-control/styles.js +29 -15
- package/build/toggle-group-control/toggle-group-control/styles.js.map +1 -1
- package/build/toggle-group-control/toggle-group-control-option-base/styles.js +9 -9
- package/build/toggle-group-control/toggle-group-control-option-base/styles.js.map +1 -1
- package/build/tools-panel/tools-panel/component.js +3 -1
- package/build/tools-panel/tools-panel/component.js.map +1 -1
- package/build/tools-panel/tools-panel-header/component.js +9 -8
- package/build/tools-panel/tools-panel-header/component.js.map +1 -1
- package/build/tools-panel/types.js.map +1 -1
- package/build/tooltip/index.js +34 -10
- package/build/tooltip/index.js.map +1 -1
- package/build/tooltip/types.js.map +1 -1
- package/build/truncate/hook.js +10 -4
- package/build/truncate/hook.js.map +1 -1
- package/build/truncate/types.js.map +1 -1
- package/build/unit-control/index.js +1 -1
- package/build/unit-control/index.js.map +1 -1
- package/build/utils/strings.js +34 -3
- package/build/utils/strings.js.map +1 -1
- package/build-module/base-control/index.js +16 -12
- package/build-module/base-control/index.js.map +1 -1
- package/build-module/border-box-control/border-box-control-linked-button/component.js +1 -1
- package/build-module/border-box-control/border-box-control-linked-button/component.js.map +1 -1
- package/build-module/border-control/border-control-style-picker/component.js +1 -1
- package/build-module/border-control/border-control-style-picker/component.js.map +1 -1
- package/build-module/box-control/index.js +1 -1
- package/build-module/box-control/index.js.map +1 -1
- package/build-module/box-control/linked-button.js +1 -1
- package/build-module/box-control/linked-button.js.map +1 -1
- package/build-module/button/index.js +1 -1
- package/build-module/button/index.js.map +1 -1
- package/build-module/color-palette/index.native.js +11 -7
- package/build-module/color-palette/index.native.js.map +1 -1
- package/build-module/color-picker/color-copy-button.js +1 -1
- package/build-module/color-picker/color-copy-button.js.map +1 -1
- package/build-module/context/wordpress-component.js.map +1 -1
- package/build-module/custom-select-control-v2/index.js +11 -10
- package/build-module/custom-select-control-v2/index.js.map +1 -1
- package/build-module/date-time/date/styles.js +8 -8
- package/build-module/date-time/date/styles.js.map +1 -1
- package/build-module/dropdown-menu-v2/index.js +201 -154
- package/build-module/dropdown-menu-v2/index.js.map +1 -1
- package/build-module/dropdown-menu-v2/styles.js +68 -61
- package/build-module/dropdown-menu-v2/styles.js.map +1 -1
- package/build-module/dropdown-menu-v2/types.js.map +1 -1
- package/build-module/duotone-picker/duotone-picker.js +4 -3
- package/build-module/duotone-picker/duotone-picker.js.map +1 -1
- package/build-module/font-size-picker/index.js +4 -2
- package/build-module/font-size-picker/index.js.map +1 -1
- package/build-module/font-size-picker/index.native.js +5 -2
- package/build-module/font-size-picker/index.native.js.map +1 -1
- package/build-module/form-token-field/index.js +10 -5
- package/build-module/form-token-field/index.js.map +1 -1
- package/build-module/form-token-field/token.js +1 -0
- package/build-module/form-token-field/token.js.map +1 -1
- package/build-module/gradient-picker/index.js +3 -2
- package/build-module/gradient-picker/index.js.map +1 -1
- package/build-module/index.native.js +6 -1
- package/build-module/index.native.js.map +1 -1
- package/build-module/input-control/styles/input-control-styles.js +31 -29
- package/build-module/input-control/styles/input-control-styles.js.map +1 -1
- package/build-module/input-control/types.js.map +1 -1
- package/build-module/lock-unlock.js +9 -0
- package/build-module/lock-unlock.js.map +1 -0
- package/build-module/mobile/bottom-sheet/index.native.js +9 -1
- package/build-module/mobile/bottom-sheet/index.native.js.map +1 -1
- package/build-module/mobile/color-settings/palette.screen.native.js +8 -4
- package/build-module/mobile/color-settings/palette.screen.native.js.map +1 -1
- package/build-module/mobile/global-styles-context/utils.native.js +25 -13
- package/build-module/mobile/global-styles-context/utils.native.js.map +1 -1
- package/build-module/mobile/image/constants.js +5 -0
- package/build-module/mobile/image/constants.js.map +1 -0
- package/build-module/mobile/image/index.native.js +25 -16
- package/build-module/mobile/image/index.native.js.map +1 -1
- package/build-module/mobile/keyboard-aware-flat-list/index.android.js +40 -6
- package/build-module/mobile/keyboard-aware-flat-list/index.android.js.map +1 -1
- package/build-module/mobile/keyboard-aware-flat-list/index.ios.js +46 -68
- package/build-module/mobile/keyboard-aware-flat-list/index.ios.js.map +1 -1
- package/build-module/mobile/keyboard-aware-flat-list/use-scroll-to-element.native.js +33 -0
- package/build-module/mobile/keyboard-aware-flat-list/use-scroll-to-element.native.js.map +1 -0
- package/build-module/mobile/keyboard-aware-flat-list/{use-scroll-to-text-input.native.js → use-scroll-to-section.native.js} +21 -27
- package/build-module/mobile/keyboard-aware-flat-list/use-scroll-to-section.native.js.map +1 -0
- package/build-module/mobile/keyboard-aware-flat-list/use-scroll.native.js +86 -0
- package/build-module/mobile/keyboard-aware-flat-list/use-scroll.native.js.map +1 -0
- package/build-module/mobile/utils/get-px-from-css-unit.native.js +294 -0
- package/build-module/mobile/utils/get-px-from-css-unit.native.js.map +1 -0
- package/build-module/modal/index.js +18 -13
- package/build-module/modal/index.js.map +1 -1
- package/build-module/navigation/menu/menu-title.js +1 -1
- package/build-module/navigation/menu/menu-title.js.map +1 -1
- package/build-module/navigator/navigator-provider/component.js +3 -16
- package/build-module/navigator/navigator-provider/component.js.map +1 -1
- package/build-module/navigator/navigator-screen/component.js +16 -70
- package/build-module/navigator/navigator-screen/component.js.map +1 -1
- package/build-module/navigator/styles.js +47 -0
- package/build-module/navigator/styles.js.map +1 -0
- package/build-module/number-control/index.js +4 -8
- package/build-module/number-control/index.js.map +1 -1
- package/build-module/number-control/types.js.map +1 -1
- package/build-module/palette-edit/index.js +15 -51
- package/build-module/palette-edit/index.js.map +1 -1
- package/build-module/private-apis.js +10 -23
- package/build-module/private-apis.js.map +1 -1
- package/build-module/private-apis.native.js +14 -0
- package/build-module/private-apis.native.js.map +1 -0
- package/build-module/radio-control/index.js +1 -0
- package/build-module/radio-control/index.js.map +1 -1
- package/build-module/range-control/index.js +1 -1
- package/build-module/range-control/index.js.map +1 -1
- package/build-module/select-control/styles/select-control-styles.js +15 -25
- package/build-module/select-control/styles/select-control-styles.js.map +1 -1
- package/build-module/slot-fill/index.js +3 -2
- package/build-module/slot-fill/index.js.map +1 -1
- package/build-module/slot-fill/types.js.map +1 -1
- package/build-module/snackbar/types.js.map +1 -1
- package/build-module/tabs/styles.js +3 -3
- package/build-module/tabs/styles.js.map +1 -1
- package/build-module/tabs/tabpanel.js +9 -7
- package/build-module/tabs/tabpanel.js.map +1 -1
- package/build-module/toggle-group-control/toggle-group-control/component.js +4 -4
- package/build-module/toggle-group-control/toggle-group-control/component.js.map +1 -1
- package/build-module/toggle-group-control/toggle-group-control/styles.js +29 -15
- package/build-module/toggle-group-control/toggle-group-control/styles.js.map +1 -1
- package/build-module/toggle-group-control/toggle-group-control-option-base/styles.js +9 -9
- package/build-module/toggle-group-control/toggle-group-control-option-base/styles.js.map +1 -1
- package/build-module/tools-panel/tools-panel/component.js +3 -1
- package/build-module/tools-panel/tools-panel/component.js.map +1 -1
- package/build-module/tools-panel/tools-panel-header/component.js +9 -8
- package/build-module/tools-panel/tools-panel-header/component.js.map +1 -1
- package/build-module/tools-panel/types.js.map +1 -1
- package/build-module/tooltip/index.js +34 -12
- package/build-module/tooltip/index.js.map +1 -1
- package/build-module/tooltip/types.js.map +1 -1
- package/build-module/truncate/hook.js +10 -4
- package/build-module/truncate/hook.js.map +1 -1
- package/build-module/truncate/types.js.map +1 -1
- package/build-module/unit-control/index.js +1 -1
- package/build-module/unit-control/index.js.map +1 -1
- package/build-module/utils/strings.js +32 -2
- package/build-module/utils/strings.js.map +1 -1
- package/build-style/style-rtl.css +29 -5
- package/build-style/style.css +29 -5
- package/build-types/base-control/index.d.ts +3 -27
- package/build-types/base-control/index.d.ts.map +1 -1
- package/build-types/base-control/stories/index.story.d.ts +4 -1
- package/build-types/base-control/stories/index.story.d.ts.map +1 -1
- package/build-types/border-box-control/border-box-control/hook.d.ts +4 -4
- package/build-types/border-box-control/border-box-control-linked-button/hook.d.ts +6 -6
- package/build-types/border-box-control/border-box-control-split-controls/hook.d.ts +4 -4
- package/build-types/border-box-control/border-box-control-visualizer/hook.d.ts +4 -4
- package/build-types/border-box-control/stories/index.story.d.ts +1 -1
- package/build-types/border-control/border-control/hook.d.ts +4 -4
- package/build-types/border-control/border-control-dropdown/hook.d.ts +4 -4
- package/build-types/border-control/border-control-style-picker/hook.d.ts +4 -4
- package/build-types/border-control/stories/index.story.d.ts +6 -6
- package/build-types/box-control/stories/index.story.d.ts +42 -42
- package/build-types/box-control/styles/box-control-styles.d.ts +1 -1
- package/build-types/button/deprecated.d.ts +3 -3
- package/build-types/card/card/hook.d.ts +4 -4
- package/build-types/card/card-body/hook.d.ts +4 -4
- package/build-types/card/card-divider/hook.d.ts +4 -4
- package/build-types/card/card-footer/hook.d.ts +4 -4
- package/build-types/card/card-header/hook.d.ts +4 -4
- package/build-types/card/card-media/hook.d.ts +4 -4
- package/build-types/color-palette/styles.d.ts +2 -2
- package/build-types/color-picker/component.d.ts +2 -2
- package/build-types/color-picker/stories/index.story.d.ts +1 -1
- package/build-types/color-picker/stories/index.story.d.ts.map +1 -1
- package/build-types/color-picker/styles.d.ts +3 -3
- package/build-types/composite/test/index.d.ts.map +1 -0
- package/build-types/context/wordpress-component.d.ts +3 -3
- package/build-types/context/wordpress-component.d.ts.map +1 -1
- package/build-types/custom-select-control-v2/index.d.ts +3 -2
- package/build-types/custom-select-control-v2/index.d.ts.map +1 -1
- package/build-types/custom-select-control-v2/stories/index.story.d.ts +4 -3
- package/build-types/custom-select-control-v2/stories/index.story.d.ts.map +1 -1
- package/build-types/date-time/date/styles.d.ts +3 -3
- package/build-types/date-time/date-time/styles.d.ts +1 -1
- package/build-types/date-time/time/styles.d.ts +4 -4
- package/build-types/dropdown/index.d.ts +1 -1
- package/build-types/dropdown/index.d.ts.map +1 -1
- package/build-types/dropdown/stories/index.story.d.ts +3 -3
- package/build-types/dropdown/stories/index.story.d.ts.map +1 -1
- package/build-types/dropdown-menu/index.d.ts +1 -1
- package/build-types/dropdown-menu/index.d.ts.map +1 -1
- package/build-types/dropdown-menu/stories/index.story.d.ts +2 -2
- package/build-types/dropdown-menu/stories/index.story.d.ts.map +1 -1
- package/build-types/dropdown-menu-v2/index.d.ts +18 -15
- package/build-types/dropdown-menu-v2/index.d.ts.map +1 -1
- package/build-types/dropdown-menu-v2/stories/index.story.d.ts +7 -2
- package/build-types/dropdown-menu-v2/stories/index.story.d.ts.map +1 -1
- package/build-types/dropdown-menu-v2/styles.d.ts +77 -23
- package/build-types/dropdown-menu-v2/styles.d.ts.map +1 -1
- package/build-types/dropdown-menu-v2/types.d.ts +89 -173
- package/build-types/dropdown-menu-v2/types.d.ts.map +1 -1
- package/build-types/duotone-picker/duotone-picker.d.ts.map +1 -1
- package/build-types/elevation/hook.d.ts +4 -4
- package/build-types/flex/flex/hook.d.ts +4 -4
- package/build-types/flex/flex-block/hook.d.ts +4 -4
- package/build-types/flex/flex-item/hook.d.ts +4 -4
- package/build-types/focal-point-picker/stories/index.story.d.ts +4 -4
- package/build-types/focal-point-picker/styles/focal-point-picker-style.d.ts +1 -1
- package/build-types/font-size-picker/index.d.ts.map +1 -1
- package/build-types/font-size-picker/styles.d.ts +1 -1
- package/build-types/form-token-field/index.d.ts.map +1 -1
- package/build-types/form-token-field/token.d.ts.map +1 -1
- package/build-types/grid/hook.d.ts +4 -4
- package/build-types/h-stack/hook.d.ts +4 -4
- package/build-types/heading/component.d.ts +1 -1
- package/build-types/heading/hook.d.ts +4 -4
- package/build-types/input-control/styles/input-control-styles.d.ts +11 -0
- package/build-types/input-control/styles/input-control-styles.d.ts.map +1 -1
- package/build-types/input-control/types.d.ts +1 -1
- package/build-types/input-control/types.d.ts.map +1 -1
- package/build-types/item-group/item/hook.d.ts +4 -4
- package/build-types/item-group/item-group/hook.d.ts +4 -4
- package/build-types/lock-unlock.d.ts +3 -0
- package/build-types/lock-unlock.d.ts.map +1 -0
- package/build-types/menu-item/index.d.ts +1 -1
- package/build-types/menu-item/stories/index.story.d.ts +4 -4
- package/build-types/mobile/image/constants.d.ts +5 -0
- package/build-types/mobile/image/constants.d.ts.map +1 -0
- package/build-types/modal/index.d.ts.map +1 -1
- package/build-types/navigation/styles/navigation-styles.d.ts +3 -3
- package/build-types/navigator/navigator-back-button/hook.d.ts +6 -6
- package/build-types/navigator/navigator-button/hook.d.ts +6 -6
- package/build-types/navigator/navigator-provider/component.d.ts.map +1 -1
- package/build-types/navigator/navigator-screen/component.d.ts +1 -7
- package/build-types/navigator/navigator-screen/component.d.ts.map +1 -1
- package/build-types/navigator/styles.d.ts +9 -0
- package/build-types/navigator/styles.d.ts.map +1 -0
- package/build-types/number-control/index.d.ts +1 -1
- package/build-types/number-control/index.d.ts.map +1 -1
- package/build-types/number-control/stories/index.story.d.ts +1 -1
- package/build-types/number-control/types.d.ts +1 -1
- package/build-types/palette-edit/index.d.ts +3 -8
- package/build-types/palette-edit/index.d.ts.map +1 -1
- package/build-types/palette-edit/styles.d.ts +3 -3
- package/build-types/popover/index.d.ts +1 -1
- package/build-types/popover/index.d.ts.map +1 -1
- package/build-types/popover/stories/e2e/index.story.d.ts +1 -1
- package/build-types/private-apis.d.ts +0 -1
- package/build-types/private-apis.d.ts.map +1 -1
- package/build-types/radio-control/index.d.ts.map +1 -1
- package/build-types/range-control/index.d.ts +1 -1
- package/build-types/range-control/styles/range-control-styles.d.ts +1 -1
- package/build-types/resizable-box/index.d.ts +1 -1
- package/build-types/resizable-box/resize-tooltip/index.d.ts +1 -1
- package/build-types/resizable-box/stories/index.story.d.ts +2 -2
- package/build-types/scrollable/hook.d.ts +4 -4
- package/build-types/search-control/index.d.ts +1 -1
- package/build-types/search-control/stories/index.story.d.ts +2 -2
- package/build-types/select-control/styles/select-control-styles.d.ts.map +1 -1
- package/build-types/slot-fill/index.d.ts +1 -1
- package/build-types/slot-fill/index.d.ts.map +1 -1
- package/build-types/slot-fill/types.d.ts +4 -0
- package/build-types/slot-fill/types.d.ts.map +1 -1
- package/build-types/snackbar/index.d.ts +2 -2
- package/build-types/snackbar/stories/index.story.d.ts +0 -3
- package/build-types/snackbar/stories/index.story.d.ts.map +1 -1
- package/build-types/snackbar/types.d.ts +1 -1
- package/build-types/snackbar/types.d.ts.map +1 -1
- package/build-types/spacer/hook.d.ts +4 -4
- package/build-types/surface/hook.d.ts +4 -4
- package/build-types/tabs/styles.d.ts.map +1 -1
- package/build-types/tabs/tabpanel.d.ts +1 -1
- package/build-types/tabs/tabpanel.d.ts.map +1 -1
- package/build-types/text/hook.d.ts +4 -4
- package/build-types/text-control/index.d.ts +1 -1
- package/build-types/textarea-control/index.d.ts +1 -1
- package/build-types/toggle-control/stories/index.story.d.ts +2 -2
- package/build-types/toggle-group-control/toggle-group-control/as-button-group.d.ts +1 -1
- package/build-types/toggle-group-control/toggle-group-control/as-radio-group.d.ts +1 -1
- package/build-types/toggle-group-control/toggle-group-control/component.d.ts.map +1 -1
- package/build-types/toggle-group-control/toggle-group-control/styles.d.ts +2 -2
- package/build-types/toggle-group-control/toggle-group-control/styles.d.ts.map +1 -1
- package/build-types/toggle-group-control/toggle-group-control-option/component.d.ts +1 -1
- package/build-types/toggle-group-control/toggle-group-control-option-base/component.d.ts +1 -1
- package/build-types/toggle-group-control/toggle-group-control-option-base/component.d.ts.map +1 -1
- package/build-types/toggle-group-control/toggle-group-control-option-base/styles.d.ts.map +1 -1
- package/build-types/toggle-group-control/toggle-group-control-option-icon/component.d.ts +1 -1
- package/build-types/toolbar/toolbar-button/index.d.ts +3 -3
- package/build-types/tools-panel/tools-panel/component.d.ts.map +1 -1
- package/build-types/tools-panel/tools-panel/hook.d.ts +5 -4
- package/build-types/tools-panel/tools-panel/hook.d.ts.map +1 -1
- package/build-types/tools-panel/tools-panel-header/component.d.ts.map +1 -1
- package/build-types/tools-panel/tools-panel-header/hook.d.ts +5 -4
- package/build-types/tools-panel/tools-panel-header/hook.d.ts.map +1 -1
- package/build-types/tools-panel/tools-panel-item/hook.d.ts +4 -4
- package/build-types/tools-panel/types.d.ts +9 -0
- package/build-types/tools-panel/types.d.ts.map +1 -1
- package/build-types/tooltip/index.d.ts +1 -1
- package/build-types/tooltip/index.d.ts.map +1 -1
- package/build-types/tooltip/stories/index.story.d.ts +10 -1
- package/build-types/tooltip/stories/index.story.d.ts.map +1 -1
- package/build-types/tooltip/types.d.ts +3 -0
- package/build-types/tooltip/types.d.ts.map +1 -1
- package/build-types/truncate/hook.d.ts +5 -5
- package/build-types/truncate/hook.d.ts.map +1 -1
- package/build-types/truncate/types.d.ts +4 -0
- package/build-types/truncate/types.d.ts.map +1 -1
- package/build-types/unit-control/index.d.ts +1 -1
- package/build-types/unit-control/styles/unit-control-styles.d.ts +1 -1
- package/build-types/utils/strings.d.ts +14 -2
- package/build-types/utils/strings.d.ts.map +1 -1
- package/build-types/v-stack/hook.d.ts +4 -4
- package/build-types/v-stack/stories/index.story.d.ts +1 -1
- package/package.json +20 -21
- package/src/alignment-matrix-control/test/index.tsx +10 -16
- package/src/base-control/index.tsx +21 -16
- package/src/border-box-control/border-box-control-linked-button/component.tsx +1 -1
- package/src/border-control/border-control-style-picker/component.tsx +1 -1
- package/src/box-control/index.tsx +1 -1
- package/src/box-control/linked-button.tsx +1 -1
- package/src/button/README.md +32 -6
- package/src/button/index.tsx +1 -1
- package/src/button-group/README.md +0 -6
- package/src/card/card/README.md +1 -1
- package/src/checkbox-control/README.md +1 -9
- package/src/color-palette/index.native.js +18 -7
- package/src/color-picker/color-copy-button.tsx +1 -1
- package/src/combobox-control/README.md +0 -6
- package/src/composite/test/index.tsx +576 -0
- package/src/context/wordpress-component.ts +11 -6
- package/src/custom-select-control/README.md +0 -6
- package/src/custom-select-control-v2/index.tsx +13 -12
- package/src/date-time/date/styles.ts +3 -3
- package/src/dropdown-menu/README.md +0 -5
- package/src/dropdown-menu-v2/README.md +75 -136
- package/src/dropdown-menu-v2/index.tsx +321 -231
- package/src/dropdown-menu-v2/stories/index.story.tsx +522 -126
- package/src/dropdown-menu-v2/styles.ts +226 -151
- package/src/dropdown-menu-v2/test/index.tsx +480 -188
- package/src/dropdown-menu-v2/types.ts +98 -184
- package/src/duotone-picker/duotone-picker.tsx +7 -3
- package/src/font-size-picker/index.native.js +8 -2
- package/src/font-size-picker/index.tsx +4 -2
- package/src/form-toggle/README.md +0 -6
- package/src/form-token-field/index.tsx +11 -7
- package/src/form-token-field/test/index.tsx +97 -0
- package/src/form-token-field/token.tsx +1 -0
- package/src/gradient-picker/index.tsx +2 -2
- package/src/index.native.js +6 -1
- package/src/input-control/styles/input-control-styles.tsx +10 -8
- package/src/input-control/types.ts +1 -1
- package/src/lock-unlock.js +10 -0
- package/src/menu-group/README.md +0 -8
- package/src/menu-items-choice/README.md +0 -7
- package/src/mobile/bottom-sheet/index.native.js +15 -1
- package/src/mobile/color-settings/palette.screen.native.js +7 -5
- package/src/mobile/global-styles-context/test/fixtures/theme.native.js +0 -20
- package/src/mobile/global-styles-context/utils.native.js +28 -19
- package/src/mobile/image/constants.js +1 -0
- package/src/mobile/image/index.native.js +55 -18
- package/src/mobile/image/style.native.scss +35 -9
- package/src/mobile/keyboard-aware-flat-list/index.android.js +50 -5
- package/src/mobile/keyboard-aware-flat-list/index.ios.js +65 -91
- package/src/mobile/keyboard-aware-flat-list/test/{use-scroll-to-text-input.native.js → use-scroll-to-section.native.js} +27 -25
- package/src/mobile/keyboard-aware-flat-list/test/use-scroll.native.js +71 -0
- package/src/mobile/keyboard-aware-flat-list/use-scroll-to-element.native.js +41 -0
- package/src/mobile/keyboard-aware-flat-list/{use-scroll-to-text-input.native.js → use-scroll-to-section.native.js} +22 -27
- package/src/mobile/keyboard-aware-flat-list/use-scroll.native.js +100 -0
- package/src/mobile/utils/get-px-from-css-unit.native.js +329 -0
- package/src/mobile/utils/test/get-px-from-css-unit.native.js +172 -0
- package/src/modal/README.md +0 -6
- package/src/modal/index.tsx +18 -16
- package/src/modal/test/index.tsx +90 -1
- package/src/navigation/menu/menu-title.tsx +1 -1
- package/src/navigator/navigator-provider/component.tsx +3 -4
- package/src/navigator/navigator-screen/component.tsx +15 -93
- package/src/navigator/styles.ts +71 -0
- package/src/navigator/test/index.tsx +0 -64
- package/src/notice/README.md +0 -6
- package/src/number-control/README.md +2 -2
- package/src/number-control/index.tsx +4 -8
- package/src/number-control/types.ts +1 -1
- package/src/palette-edit/index.tsx +15 -58
- package/src/palette-edit/test/index.tsx +1 -75
- package/src/panel/README.md +0 -6
- package/src/private-apis.native.js +13 -0
- package/src/private-apis.ts +12 -37
- package/src/radio-control/README.md +0 -6
- package/src/radio-control/index.tsx +4 -1
- package/src/radio-control/style.scss +29 -2
- package/src/radio-group/README.md +0 -6
- package/src/range-control/README.md +1 -9
- package/src/range-control/index.tsx +1 -1
- package/src/search-control/README.md +0 -6
- package/src/select-control/README.md +0 -6
- package/src/select-control/styles/select-control-styles.ts +10 -28
- package/src/slot-fill/index.tsx +5 -2
- package/src/slot-fill/types.ts +5 -0
- package/src/snackbar/README.md +0 -6
- package/src/snackbar/stories/index.story.tsx +7 -5
- package/src/snackbar/style.scss +4 -3
- package/src/snackbar/types.ts +2 -1
- package/src/spacer/README.md +0 -2
- package/src/tab-panel/README.md +0 -5
- package/src/tab-panel/test/index.tsx +39 -56
- package/src/tabs/styles.ts +7 -1
- package/src/tabs/tabpanel.tsx +7 -6
- package/src/tabs/test/index.tsx +56 -0
- package/src/text-control/README.md +0 -6
- package/src/textarea-control/README.md +0 -6
- package/src/toggle-group-control/test/__snapshots__/index.tsx.snap +12 -16
- package/src/toggle-group-control/test/index.tsx +58 -45
- package/src/toggle-group-control/toggle-group-control/component.tsx +5 -4
- package/src/toggle-group-control/toggle-group-control/styles.ts +13 -19
- package/src/toggle-group-control/toggle-group-control-option/README.md +1 -1
- package/src/toggle-group-control/toggle-group-control-option-base/README.md +1 -1
- package/src/toggle-group-control/toggle-group-control-option-base/styles.ts +3 -2
- package/src/toggle-group-control/toggle-group-control-option-icon/README.md +1 -1
- package/src/toolbar/toolbar/README.md +0 -6
- package/src/tools-panel/test/index.tsx +12 -20
- package/src/tools-panel/tools-panel/README.md +7 -0
- package/src/tools-panel/tools-panel/component.tsx +2 -0
- package/src/tools-panel/tools-panel-header/README.md +7 -0
- package/src/tools-panel/tools-panel-header/component.tsx +20 -13
- package/src/tools-panel/types.ts +9 -0
- package/src/tooltip/README.md +4 -0
- package/src/tooltip/index.tsx +48 -10
- package/src/tooltip/stories/index.story.tsx +18 -1
- package/src/tooltip/test/index.tsx +404 -254
- package/src/tooltip/types.ts +4 -0
- package/src/tree-grid/README.md +0 -4
- package/src/truncate/README.md +8 -0
- package/src/truncate/hook.ts +17 -10
- package/src/truncate/test/index.tsx +54 -27
- package/src/truncate/types.ts +4 -0
- package/src/unit-control/index.tsx +1 -1
- package/src/utils/strings.ts +30 -2
- package/src/utils/test/strings.js +96 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/build/dropdown-menu-v2-ariakit/index.js +0 -256
- package/build/dropdown-menu-v2-ariakit/index.js.map +0 -1
- package/build/dropdown-menu-v2-ariakit/styles.js +0 -180
- package/build/dropdown-menu-v2-ariakit/styles.js.map +0 -1
- package/build/dropdown-menu-v2-ariakit/types.js +0 -6
- package/build/dropdown-menu-v2-ariakit/types.js.map +0 -1
- package/build/mobile/keyboard-aware-flat-list/use-scroll-to-text-input.native.js.map +0 -1
- package/build-module/dropdown-menu-v2-ariakit/index.js +0 -237
- package/build-module/dropdown-menu-v2-ariakit/index.js.map +0 -1
- package/build-module/dropdown-menu-v2-ariakit/styles.js +0 -165
- package/build-module/dropdown-menu-v2-ariakit/styles.js.map +0 -1
- package/build-module/dropdown-menu-v2-ariakit/types.js +0 -2
- package/build-module/dropdown-menu-v2-ariakit/types.js.map +0 -1
- package/build-module/mobile/keyboard-aware-flat-list/use-scroll-to-text-input.native.js.map +0 -1
- package/build-types/dropdown-menu-v2-ariakit/index.d.ts +0 -20
- package/build-types/dropdown-menu-v2-ariakit/index.d.ts.map +0 -1
- package/build-types/dropdown-menu-v2-ariakit/stories/index.story.d.ts +0 -16
- package/build-types/dropdown-menu-v2-ariakit/stories/index.story.d.ts.map +0 -1
- package/build-types/dropdown-menu-v2-ariakit/styles.d.ts +0 -96
- package/build-types/dropdown-menu-v2-ariakit/styles.d.ts.map +0 -1
- package/build-types/dropdown-menu-v2-ariakit/test/index.d.ts.map +0 -1
- package/build-types/dropdown-menu-v2-ariakit/types.d.ts +0 -168
- package/build-types/dropdown-menu-v2-ariakit/types.d.ts.map +0 -1
- package/src/dropdown-menu-v2-ariakit/README.md +0 -331
- package/src/dropdown-menu-v2-ariakit/index.tsx +0 -383
- package/src/dropdown-menu-v2-ariakit/stories/index.story.tsx +0 -617
- package/src/dropdown-menu-v2-ariakit/styles.ts +0 -345
- package/src/dropdown-menu-v2-ariakit/test/index.tsx +0 -1108
- package/src/dropdown-menu-v2-ariakit/types.ts +0 -179
- /package/build-types/{dropdown-menu-v2-ariakit → composite}/test/index.d.ts +0 -0
|
@@ -19,9 +19,10 @@ import * as ariaHelper from './aria-helper';
|
|
|
19
19
|
import Button from '../button';
|
|
20
20
|
import StyleProvider from '../style-provider';
|
|
21
21
|
// Used to track and dismiss the prior modal when another opens unless nested.
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
const ModalContext = createContext([]);
|
|
23
|
+
|
|
24
|
+
// Used to track body class names applied while modals are open.
|
|
25
|
+
const bodyOpenClasses = new Map();
|
|
25
26
|
function UnforwardedModal(props, forwardedRef) {
|
|
26
27
|
const {
|
|
27
28
|
bodyOpenClassName = 'modal-open',
|
|
@@ -119,20 +120,24 @@ function UnforwardedModal(props, forwardedRef) {
|
|
|
119
120
|
dismissers.shift();
|
|
120
121
|
};
|
|
121
122
|
}, [dismissers]);
|
|
122
|
-
|
|
123
|
+
|
|
123
124
|
// Adds/removes the value of bodyOpenClassName to body element.
|
|
124
125
|
useEffect(() => {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
126
|
+
var _bodyOpenClasses$get;
|
|
127
|
+
const theClass = bodyOpenClassName;
|
|
128
|
+
const oneMore = 1 + ((_bodyOpenClasses$get = bodyOpenClasses.get(theClass)) !== null && _bodyOpenClasses$get !== void 0 ? _bodyOpenClasses$get : 0);
|
|
129
|
+
bodyOpenClasses.set(theClass, oneMore);
|
|
130
|
+
document.body.classList.add(bodyOpenClassName);
|
|
129
131
|
return () => {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
132
|
+
const oneLess = bodyOpenClasses.get(theClass) - 1;
|
|
133
|
+
if (oneLess === 0) {
|
|
134
|
+
document.body.classList.remove(theClass);
|
|
135
|
+
bodyOpenClasses.delete(theClass);
|
|
136
|
+
} else {
|
|
137
|
+
bodyOpenClasses.set(theClass, oneLess);
|
|
133
138
|
}
|
|
134
139
|
};
|
|
135
|
-
}, [bodyOpenClassName
|
|
140
|
+
}, [bodyOpenClassName]);
|
|
136
141
|
|
|
137
142
|
// Calls the isContentScrollable callback when the Modal children container resizes.
|
|
138
143
|
useLayoutEffect(() => {
|
|
@@ -156,7 +161,7 @@ function UnforwardedModal(props, forwardedRef) {
|
|
|
156
161
|
event.keyCode === 229) {
|
|
157
162
|
return;
|
|
158
163
|
}
|
|
159
|
-
if (shouldCloseOnEsc && event.code === 'Escape' && !event.defaultPrevented) {
|
|
164
|
+
if (shouldCloseOnEsc && (event.code === 'Escape' || event.key === 'Escape') && !event.defaultPrevented) {
|
|
160
165
|
event.preventDefault();
|
|
161
166
|
if (onRequestClose) {
|
|
162
167
|
onRequestClose(event);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["classnames","createPortal","useCallback","useEffect","useRef","useState","forwardRef","useLayoutEffect","createContext","useContext","useInstanceId","useFocusReturn","useFocusOnMount","useConstrainedTabbing","useMergeRefs","__","close","getScrollContainer","ariaHelper","Button","StyleProvider","level0Dismissers","ModalContext","isBodyOpenClassActive","UnforwardedModal","props","forwardedRef","bodyOpenClassName","role","title","focusOnMount","shouldCloseOnEsc","shouldCloseOnClickOutside","isDismissible","aria","labelledby","undefined","describedby","onRequestClose","icon","closeButtonLabel","children","style","overlayClassName","className","contentLabel","onKeyDown","isFullScreen","size","headerActions","__experimentalHideHeader","ref","instanceId","Modal","headingId","focusOnMountRef","constrainedTabbingRef","focusReturnRef","contentRef","childrenContainerRef","hasScrolledContent","setHasScrolledContent","hasScrollableContent","setHasScrollableContent","sizeClass","isContentScrollable","current","closestScrollContainer","modalize","unmodalize","refOnRequestClose","dismissers","nestedDismissers","push","first","second","nested","shift","isLevel0","document","body","classList","add","length","remove","window","ResizeObserver","resizeObserver","observe","disconnect","handleEscapeKeyDown","event","nativeEvent","isComposing","keyCode","code","defaultPrevented","preventDefault","onContentContainerScroll","e","_e$currentTarget$scro","scrollY","currentTarget","scrollTop","pressTarget","overlayPressHandlers","onPointerDown","target","onPointerUp","button","isSameTarget","modal","createElement","tabIndex","onScroll","id","onClick","label","Provider","value"],"sources":["@wordpress/components/src/modal/index.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\nimport type {\n\tForwardedRef,\n\tKeyboardEvent,\n\tMutableRefObject,\n\tUIEvent,\n} from 'react';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tcreatePortal,\n\tuseCallback,\n\tuseEffect,\n\tuseRef,\n\tuseState,\n\tforwardRef,\n\tuseLayoutEffect,\n\tcreateContext,\n\tuseContext,\n} from '@wordpress/element';\nimport {\n\tuseInstanceId,\n\tuseFocusReturn,\n\tuseFocusOnMount,\n\tuseConstrainedTabbing,\n\tuseMergeRefs,\n} from '@wordpress/compose';\nimport { __ } from '@wordpress/i18n';\nimport { close } from '@wordpress/icons';\nimport { getScrollContainer } from '@wordpress/dom';\n\n/**\n * Internal dependencies\n */\nimport * as ariaHelper from './aria-helper';\nimport Button from '../button';\nimport StyleProvider from '../style-provider';\nimport type { ModalProps } from './types';\n\n// Used to track and dismiss the prior modal when another opens unless nested.\nconst level0Dismissers: MutableRefObject<\n\tModalProps[ 'onRequestClose' ] | undefined\n>[] = [];\nconst ModalContext = createContext( level0Dismissers );\n\nlet isBodyOpenClassActive = false;\n\nfunction UnforwardedModal(\n\tprops: ModalProps,\n\tforwardedRef: ForwardedRef< HTMLDivElement >\n) {\n\tconst {\n\t\tbodyOpenClassName = 'modal-open',\n\t\trole = 'dialog',\n\t\ttitle = null,\n\t\tfocusOnMount = true,\n\t\tshouldCloseOnEsc = true,\n\t\tshouldCloseOnClickOutside = true,\n\t\tisDismissible = true,\n\t\t/* Accessibility. */\n\t\taria = {\n\t\t\tlabelledby: undefined,\n\t\t\tdescribedby: undefined,\n\t\t},\n\t\tonRequestClose,\n\t\ticon,\n\t\tcloseButtonLabel,\n\t\tchildren,\n\t\tstyle,\n\t\toverlayClassName,\n\t\tclassName,\n\t\tcontentLabel,\n\t\tonKeyDown,\n\t\tisFullScreen = false,\n\t\tsize,\n\t\theaderActions = null,\n\t\t__experimentalHideHeader = false,\n\t} = props;\n\n\tconst ref = useRef< HTMLDivElement >();\n\n\tconst instanceId = useInstanceId( Modal );\n\tconst headingId = title\n\t\t? `components-modal-header-${ instanceId }`\n\t\t: aria.labelledby;\n\n\t// The focus hook does not support 'firstContentElement' but this is a valid\n\t// value for the Modal's focusOnMount prop. The following code ensures the focus\n\t// hook will focus the first focusable node within the element to which it is applied.\n\t// When `firstContentElement` is passed as the value of the focusOnMount prop,\n\t// the focus hook is applied to the Modal's content element.\n\t// Otherwise, the focus hook is applied to the Modal's ref. This ensures that the\n\t// focus hook will focus the first element in the Modal's **content** when\n\t// `firstContentElement` is passed.\n\tconst focusOnMountRef = useFocusOnMount(\n\t\tfocusOnMount === 'firstContentElement' ? 'firstElement' : focusOnMount\n\t);\n\tconst constrainedTabbingRef = useConstrainedTabbing();\n\tconst focusReturnRef = useFocusReturn();\n\tconst contentRef = useRef< HTMLDivElement >( null );\n\tconst childrenContainerRef = useRef< HTMLDivElement >( null );\n\n\tconst [ hasScrolledContent, setHasScrolledContent ] = useState( false );\n\tconst [ hasScrollableContent, setHasScrollableContent ] = useState( false );\n\n\tlet sizeClass;\n\tif ( isFullScreen || size === 'fill' ) {\n\t\tsizeClass = 'is-full-screen';\n\t} else if ( size ) {\n\t\tsizeClass = `has-size-${ size }`;\n\t}\n\n\t// Determines whether the Modal content is scrollable and updates the state.\n\tconst isContentScrollable = useCallback( () => {\n\t\tif ( ! contentRef.current ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst closestScrollContainer = getScrollContainer( contentRef.current );\n\n\t\tif ( contentRef.current === closestScrollContainer ) {\n\t\t\tsetHasScrollableContent( true );\n\t\t} else {\n\t\t\tsetHasScrollableContent( false );\n\t\t}\n\t}, [ contentRef ] );\n\n\t// Accessibly isolates/unisolates the modal.\n\tuseEffect( () => {\n\t\tariaHelper.modalize( ref.current );\n\t\treturn () => ariaHelper.unmodalize();\n\t}, [] );\n\n\t// Keeps a fresh ref for the subsequent effect.\n\tconst refOnRequestClose = useRef< ModalProps[ 'onRequestClose' ] >();\n\tuseEffect( () => {\n\t\trefOnRequestClose.current = onRequestClose;\n\t}, [ onRequestClose ] );\n\n\t// The list of `onRequestClose` callbacks of open (non-nested) Modals. Only\n\t// one should remain open at a time and the list enables closing prior ones.\n\tconst dismissers = useContext( ModalContext );\n\t// Used for the tracking and dismissing any nested modals.\n\tconst nestedDismissers = useRef< typeof level0Dismissers >( [] );\n\n\t// Updates the stack tracking open modals at this level and calls\n\t// onRequestClose for any prior and/or nested modals as applicable.\n\tuseEffect( () => {\n\t\tdismissers.push( refOnRequestClose );\n\t\tconst [ first, second ] = dismissers;\n\t\tif ( second ) first?.current?.();\n\n\t\tconst nested = nestedDismissers.current;\n\t\treturn () => {\n\t\t\tnested[ 0 ]?.current?.();\n\t\t\tdismissers.shift();\n\t\t};\n\t}, [ dismissers ] );\n\n\tconst isLevel0 = dismissers === level0Dismissers;\n\t// Adds/removes the value of bodyOpenClassName to body element.\n\tuseEffect( () => {\n\t\tif ( ! isBodyOpenClassActive ) {\n\t\t\tisBodyOpenClassActive = true;\n\t\t\tdocument.body.classList.add( bodyOpenClassName );\n\t\t}\n\t\treturn () => {\n\t\t\tif ( isLevel0 && dismissers.length === 0 ) {\n\t\t\t\tdocument.body.classList.remove( bodyOpenClassName );\n\t\t\t\tisBodyOpenClassActive = false;\n\t\t\t}\n\t\t};\n\t}, [ bodyOpenClassName, dismissers, isLevel0 ] );\n\n\t// Calls the isContentScrollable callback when the Modal children container resizes.\n\tuseLayoutEffect( () => {\n\t\tif ( ! window.ResizeObserver || ! childrenContainerRef.current ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst resizeObserver = new ResizeObserver( isContentScrollable );\n\t\tresizeObserver.observe( childrenContainerRef.current );\n\n\t\tisContentScrollable();\n\n\t\treturn () => {\n\t\t\tresizeObserver.disconnect();\n\t\t};\n\t}, [ isContentScrollable, childrenContainerRef ] );\n\n\tfunction handleEscapeKeyDown( event: KeyboardEvent< HTMLDivElement > ) {\n\t\tif (\n\t\t\t// Ignore keydowns from IMEs\n\t\t\tevent.nativeEvent.isComposing ||\n\t\t\t// Workaround for Mac Safari where the final Enter/Backspace of an IME composition\n\t\t\t// is `isComposing=false`, even though it's technically still part of the composition.\n\t\t\t// These can only be detected by keyCode.\n\t\t\tevent.keyCode === 229\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (\n\t\t\tshouldCloseOnEsc &&\n\t\t\tevent.code === 'Escape' &&\n\t\t\t! event.defaultPrevented\n\t\t) {\n\t\t\tevent.preventDefault();\n\t\t\tif ( onRequestClose ) {\n\t\t\t\tonRequestClose( event );\n\t\t\t}\n\t\t}\n\t}\n\n\tconst onContentContainerScroll = useCallback(\n\t\t( e: UIEvent< HTMLDivElement > ) => {\n\t\t\tconst scrollY = e?.currentTarget?.scrollTop ?? -1;\n\n\t\t\tif ( ! hasScrolledContent && scrollY > 0 ) {\n\t\t\t\tsetHasScrolledContent( true );\n\t\t\t} else if ( hasScrolledContent && scrollY <= 0 ) {\n\t\t\t\tsetHasScrolledContent( false );\n\t\t\t}\n\t\t},\n\t\t[ hasScrolledContent ]\n\t);\n\n\tlet pressTarget: EventTarget | null = null;\n\tconst overlayPressHandlers: {\n\t\tonPointerDown: React.PointerEventHandler< HTMLDivElement >;\n\t\tonPointerUp: React.PointerEventHandler< HTMLDivElement >;\n\t} = {\n\t\tonPointerDown: ( event ) => {\n\t\t\tif ( event.target === event.currentTarget ) {\n\t\t\t\tpressTarget = event.target;\n\t\t\t\t// Avoids focus changing so that focus return works as expected.\n\t\t\t\tevent.preventDefault();\n\t\t\t}\n\t\t},\n\t\t// Closes the modal with two exceptions. 1. Opening the context menu on\n\t\t// the overlay. 2. Pressing on the overlay then dragging the pointer\n\t\t// over the modal and releasing. Due to the modal being a child of the\n\t\t// overlay, such a gesture is a `click` on the overlay and cannot be\n\t\t// excepted by a `click` handler. Thus the tactic of handling\n\t\t// `pointerup` and comparing its target to that of the `pointerdown`.\n\t\tonPointerUp: ( { target, button } ) => {\n\t\t\tconst isSameTarget = target === pressTarget;\n\t\t\tpressTarget = null;\n\t\t\tif ( button === 0 && isSameTarget ) onRequestClose();\n\t\t},\n\t};\n\n\tconst modal = (\n\t\t// eslint-disable-next-line jsx-a11y/no-static-element-interactions\n\t\t<div\n\t\t\tref={ useMergeRefs( [ ref, forwardedRef ] ) }\n\t\t\tclassName={ classnames(\n\t\t\t\t'components-modal__screen-overlay',\n\t\t\t\toverlayClassName\n\t\t\t) }\n\t\t\tonKeyDown={ handleEscapeKeyDown }\n\t\t\t{ ...( shouldCloseOnClickOutside ? overlayPressHandlers : {} ) }\n\t\t>\n\t\t\t<StyleProvider document={ document }>\n\t\t\t\t<div\n\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t'components-modal__frame',\n\t\t\t\t\t\tsizeClass,\n\t\t\t\t\t\tclassName\n\t\t\t\t\t) }\n\t\t\t\t\tstyle={ style }\n\t\t\t\t\tref={ useMergeRefs( [\n\t\t\t\t\t\tconstrainedTabbingRef,\n\t\t\t\t\t\tfocusReturnRef,\n\t\t\t\t\t\tfocusOnMount !== 'firstContentElement'\n\t\t\t\t\t\t\t? focusOnMountRef\n\t\t\t\t\t\t\t: null,\n\t\t\t\t\t] ) }\n\t\t\t\t\trole={ role }\n\t\t\t\t\taria-label={ contentLabel }\n\t\t\t\t\taria-labelledby={ contentLabel ? undefined : headingId }\n\t\t\t\t\taria-describedby={ aria.describedby }\n\t\t\t\t\ttabIndex={ -1 }\n\t\t\t\t\tonKeyDown={ onKeyDown }\n\t\t\t\t>\n\t\t\t\t\t<div\n\t\t\t\t\t\tclassName={ classnames( 'components-modal__content', {\n\t\t\t\t\t\t\t'hide-header': __experimentalHideHeader,\n\t\t\t\t\t\t\t'is-scrollable': hasScrollableContent,\n\t\t\t\t\t\t\t'has-scrolled-content': hasScrolledContent,\n\t\t\t\t\t\t} ) }\n\t\t\t\t\t\trole=\"document\"\n\t\t\t\t\t\tonScroll={ onContentContainerScroll }\n\t\t\t\t\t\tref={ contentRef }\n\t\t\t\t\t\taria-label={\n\t\t\t\t\t\t\thasScrollableContent\n\t\t\t\t\t\t\t\t? __( 'Scrollable section' )\n\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t}\n\t\t\t\t\t\ttabIndex={ hasScrollableContent ? 0 : undefined }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ ! __experimentalHideHeader && (\n\t\t\t\t\t\t\t<div className=\"components-modal__header\">\n\t\t\t\t\t\t\t\t<div className=\"components-modal__header-heading-container\">\n\t\t\t\t\t\t\t\t\t{ icon && (\n\t\t\t\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"components-modal__icon-container\"\n\t\t\t\t\t\t\t\t\t\t\taria-hidden\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t{ icon }\n\t\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t{ title && (\n\t\t\t\t\t\t\t\t\t\t<h1\n\t\t\t\t\t\t\t\t\t\t\tid={ headingId }\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"components-modal__header-heading\"\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t{ title }\n\t\t\t\t\t\t\t\t\t\t</h1>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t{ headerActions }\n\t\t\t\t\t\t\t\t{ isDismissible && (\n\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\tonClick={ onRequestClose }\n\t\t\t\t\t\t\t\t\t\ticon={ close }\n\t\t\t\t\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\t\t\t\t\tcloseButtonLabel || __( 'Close' )\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t) }\n\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tref={ useMergeRefs( [\n\t\t\t\t\t\t\t\tchildrenContainerRef,\n\t\t\t\t\t\t\t\tfocusOnMount === 'firstContentElement'\n\t\t\t\t\t\t\t\t\t? focusOnMountRef\n\t\t\t\t\t\t\t\t\t: null,\n\t\t\t\t\t\t\t] ) }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ children }\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t</StyleProvider>\n\t\t</div>\n\t);\n\n\treturn createPortal(\n\t\t<ModalContext.Provider value={ nestedDismissers.current }>\n\t\t\t{ modal }\n\t\t</ModalContext.Provider>,\n\t\tdocument.body\n\t);\n}\n\n/**\n * Modals give users information and choices related to a task they’re trying to\n * accomplish. They can contain critical information, require decisions, or\n * involve multiple tasks.\n *\n * ```jsx\n * import { Button, Modal } from '@wordpress/components';\n * import { useState } from '@wordpress/element';\n *\n * const MyModal = () => {\n * const [ isOpen, setOpen ] = useState( false );\n * const openModal = () => setOpen( true );\n * const closeModal = () => setOpen( false );\n *\n * return (\n * <>\n * <Button variant=\"secondary\" onClick={ openModal }>\n * Open Modal\n * </Button>\n * { isOpen && (\n * <Modal title=\"This is my modal\" onRequestClose={ closeModal }>\n * <Button variant=\"secondary\" onClick={ closeModal }>\n * My custom close button\n * </Button>\n * </Modal>\n * ) }\n * </>\n * );\n * };\n * ```\n */\nexport const Modal = forwardRef( UnforwardedModal );\n\nexport default Modal;\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;AAQnC;AACA;AACA;AACA,SACCC,YAAY,EACZC,WAAW,EACXC,SAAS,EACTC,MAAM,EACNC,QAAQ,EACRC,UAAU,EACVC,eAAe,EACfC,aAAa,EACbC,UAAU,QACJ,oBAAoB;AAC3B,SACCC,aAAa,EACbC,cAAc,EACdC,eAAe,EACfC,qBAAqB,EACrBC,YAAY,QACN,oBAAoB;AAC3B,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,KAAK,QAAQ,kBAAkB;AACxC,SAASC,kBAAkB,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Ae6B,KAAK"}
|
|
1
|
+
{"version":3,"names":["classnames","createPortal","useCallback","useEffect","useRef","useState","forwardRef","useLayoutEffect","createContext","useContext","useInstanceId","useFocusReturn","useFocusOnMount","useConstrainedTabbing","useMergeRefs","__","close","getScrollContainer","ariaHelper","Button","StyleProvider","ModalContext","bodyOpenClasses","Map","UnforwardedModal","props","forwardedRef","bodyOpenClassName","role","title","focusOnMount","shouldCloseOnEsc","shouldCloseOnClickOutside","isDismissible","aria","labelledby","undefined","describedby","onRequestClose","icon","closeButtonLabel","children","style","overlayClassName","className","contentLabel","onKeyDown","isFullScreen","size","headerActions","__experimentalHideHeader","ref","instanceId","Modal","headingId","focusOnMountRef","constrainedTabbingRef","focusReturnRef","contentRef","childrenContainerRef","hasScrolledContent","setHasScrolledContent","hasScrollableContent","setHasScrollableContent","sizeClass","isContentScrollable","current","closestScrollContainer","modalize","unmodalize","refOnRequestClose","dismissers","nestedDismissers","push","first","second","nested","shift","_bodyOpenClasses$get","theClass","oneMore","get","set","document","body","classList","add","oneLess","remove","delete","window","ResizeObserver","resizeObserver","observe","disconnect","handleEscapeKeyDown","event","nativeEvent","isComposing","keyCode","code","key","defaultPrevented","preventDefault","onContentContainerScroll","e","_e$currentTarget$scro","scrollY","currentTarget","scrollTop","pressTarget","overlayPressHandlers","onPointerDown","target","onPointerUp","button","isSameTarget","modal","createElement","tabIndex","onScroll","id","onClick","label","Provider","value"],"sources":["@wordpress/components/src/modal/index.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\nimport type {\n\tForwardedRef,\n\tKeyboardEvent,\n\tMutableRefObject,\n\tUIEvent,\n} from 'react';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tcreatePortal,\n\tuseCallback,\n\tuseEffect,\n\tuseRef,\n\tuseState,\n\tforwardRef,\n\tuseLayoutEffect,\n\tcreateContext,\n\tuseContext,\n} from '@wordpress/element';\nimport {\n\tuseInstanceId,\n\tuseFocusReturn,\n\tuseFocusOnMount,\n\tuseConstrainedTabbing,\n\tuseMergeRefs,\n} from '@wordpress/compose';\nimport { __ } from '@wordpress/i18n';\nimport { close } from '@wordpress/icons';\nimport { getScrollContainer } from '@wordpress/dom';\n\n/**\n * Internal dependencies\n */\nimport * as ariaHelper from './aria-helper';\nimport Button from '../button';\nimport StyleProvider from '../style-provider';\nimport type { ModalProps } from './types';\n\n// Used to track and dismiss the prior modal when another opens unless nested.\nconst ModalContext = createContext<\n\tMutableRefObject< ModalProps[ 'onRequestClose' ] | undefined >[]\n>( [] );\n\n// Used to track body class names applied while modals are open.\nconst bodyOpenClasses = new Map< string, number >();\n\nfunction UnforwardedModal(\n\tprops: ModalProps,\n\tforwardedRef: ForwardedRef< HTMLDivElement >\n) {\n\tconst {\n\t\tbodyOpenClassName = 'modal-open',\n\t\trole = 'dialog',\n\t\ttitle = null,\n\t\tfocusOnMount = true,\n\t\tshouldCloseOnEsc = true,\n\t\tshouldCloseOnClickOutside = true,\n\t\tisDismissible = true,\n\t\t/* Accessibility. */\n\t\taria = {\n\t\t\tlabelledby: undefined,\n\t\t\tdescribedby: undefined,\n\t\t},\n\t\tonRequestClose,\n\t\ticon,\n\t\tcloseButtonLabel,\n\t\tchildren,\n\t\tstyle,\n\t\toverlayClassName,\n\t\tclassName,\n\t\tcontentLabel,\n\t\tonKeyDown,\n\t\tisFullScreen = false,\n\t\tsize,\n\t\theaderActions = null,\n\t\t__experimentalHideHeader = false,\n\t} = props;\n\n\tconst ref = useRef< HTMLDivElement >();\n\n\tconst instanceId = useInstanceId( Modal );\n\tconst headingId = title\n\t\t? `components-modal-header-${ instanceId }`\n\t\t: aria.labelledby;\n\n\t// The focus hook does not support 'firstContentElement' but this is a valid\n\t// value for the Modal's focusOnMount prop. The following code ensures the focus\n\t// hook will focus the first focusable node within the element to which it is applied.\n\t// When `firstContentElement` is passed as the value of the focusOnMount prop,\n\t// the focus hook is applied to the Modal's content element.\n\t// Otherwise, the focus hook is applied to the Modal's ref. This ensures that the\n\t// focus hook will focus the first element in the Modal's **content** when\n\t// `firstContentElement` is passed.\n\tconst focusOnMountRef = useFocusOnMount(\n\t\tfocusOnMount === 'firstContentElement' ? 'firstElement' : focusOnMount\n\t);\n\tconst constrainedTabbingRef = useConstrainedTabbing();\n\tconst focusReturnRef = useFocusReturn();\n\tconst contentRef = useRef< HTMLDivElement >( null );\n\tconst childrenContainerRef = useRef< HTMLDivElement >( null );\n\n\tconst [ hasScrolledContent, setHasScrolledContent ] = useState( false );\n\tconst [ hasScrollableContent, setHasScrollableContent ] = useState( false );\n\n\tlet sizeClass;\n\tif ( isFullScreen || size === 'fill' ) {\n\t\tsizeClass = 'is-full-screen';\n\t} else if ( size ) {\n\t\tsizeClass = `has-size-${ size }`;\n\t}\n\n\t// Determines whether the Modal content is scrollable and updates the state.\n\tconst isContentScrollable = useCallback( () => {\n\t\tif ( ! contentRef.current ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst closestScrollContainer = getScrollContainer( contentRef.current );\n\n\t\tif ( contentRef.current === closestScrollContainer ) {\n\t\t\tsetHasScrollableContent( true );\n\t\t} else {\n\t\t\tsetHasScrollableContent( false );\n\t\t}\n\t}, [ contentRef ] );\n\n\t// Accessibly isolates/unisolates the modal.\n\tuseEffect( () => {\n\t\tariaHelper.modalize( ref.current );\n\t\treturn () => ariaHelper.unmodalize();\n\t}, [] );\n\n\t// Keeps a fresh ref for the subsequent effect.\n\tconst refOnRequestClose = useRef< ModalProps[ 'onRequestClose' ] >();\n\tuseEffect( () => {\n\t\trefOnRequestClose.current = onRequestClose;\n\t}, [ onRequestClose ] );\n\n\t// The list of `onRequestClose` callbacks of open (non-nested) Modals. Only\n\t// one should remain open at a time and the list enables closing prior ones.\n\tconst dismissers = useContext( ModalContext );\n\t// Used for the tracking and dismissing any nested modals.\n\tconst nestedDismissers = useRef< typeof dismissers >( [] );\n\n\t// Updates the stack tracking open modals at this level and calls\n\t// onRequestClose for any prior and/or nested modals as applicable.\n\tuseEffect( () => {\n\t\tdismissers.push( refOnRequestClose );\n\t\tconst [ first, second ] = dismissers;\n\t\tif ( second ) first?.current?.();\n\n\t\tconst nested = nestedDismissers.current;\n\t\treturn () => {\n\t\t\tnested[ 0 ]?.current?.();\n\t\t\tdismissers.shift();\n\t\t};\n\t}, [ dismissers ] );\n\n\t// Adds/removes the value of bodyOpenClassName to body element.\n\tuseEffect( () => {\n\t\tconst theClass = bodyOpenClassName;\n\t\tconst oneMore = 1 + ( bodyOpenClasses.get( theClass ) ?? 0 );\n\t\tbodyOpenClasses.set( theClass, oneMore );\n\t\tdocument.body.classList.add( bodyOpenClassName );\n\t\treturn () => {\n\t\t\tconst oneLess = bodyOpenClasses.get( theClass )! - 1;\n\t\t\tif ( oneLess === 0 ) {\n\t\t\t\tdocument.body.classList.remove( theClass );\n\t\t\t\tbodyOpenClasses.delete( theClass );\n\t\t\t} else {\n\t\t\t\tbodyOpenClasses.set( theClass, oneLess );\n\t\t\t}\n\t\t};\n\t}, [ bodyOpenClassName ] );\n\n\t// Calls the isContentScrollable callback when the Modal children container resizes.\n\tuseLayoutEffect( () => {\n\t\tif ( ! window.ResizeObserver || ! childrenContainerRef.current ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst resizeObserver = new ResizeObserver( isContentScrollable );\n\t\tresizeObserver.observe( childrenContainerRef.current );\n\n\t\tisContentScrollable();\n\n\t\treturn () => {\n\t\t\tresizeObserver.disconnect();\n\t\t};\n\t}, [ isContentScrollable, childrenContainerRef ] );\n\n\tfunction handleEscapeKeyDown( event: KeyboardEvent< HTMLDivElement > ) {\n\t\tif (\n\t\t\t// Ignore keydowns from IMEs\n\t\t\tevent.nativeEvent.isComposing ||\n\t\t\t// Workaround for Mac Safari where the final Enter/Backspace of an IME composition\n\t\t\t// is `isComposing=false`, even though it's technically still part of the composition.\n\t\t\t// These can only be detected by keyCode.\n\t\t\tevent.keyCode === 229\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (\n\t\t\tshouldCloseOnEsc &&\n\t\t\t( event.code === 'Escape' || event.key === 'Escape' ) &&\n\t\t\t! event.defaultPrevented\n\t\t) {\n\t\t\tevent.preventDefault();\n\t\t\tif ( onRequestClose ) {\n\t\t\t\tonRequestClose( event );\n\t\t\t}\n\t\t}\n\t}\n\n\tconst onContentContainerScroll = useCallback(\n\t\t( e: UIEvent< HTMLDivElement > ) => {\n\t\t\tconst scrollY = e?.currentTarget?.scrollTop ?? -1;\n\n\t\t\tif ( ! hasScrolledContent && scrollY > 0 ) {\n\t\t\t\tsetHasScrolledContent( true );\n\t\t\t} else if ( hasScrolledContent && scrollY <= 0 ) {\n\t\t\t\tsetHasScrolledContent( false );\n\t\t\t}\n\t\t},\n\t\t[ hasScrolledContent ]\n\t);\n\n\tlet pressTarget: EventTarget | null = null;\n\tconst overlayPressHandlers: {\n\t\tonPointerDown: React.PointerEventHandler< HTMLDivElement >;\n\t\tonPointerUp: React.PointerEventHandler< HTMLDivElement >;\n\t} = {\n\t\tonPointerDown: ( event ) => {\n\t\t\tif ( event.target === event.currentTarget ) {\n\t\t\t\tpressTarget = event.target;\n\t\t\t\t// Avoids focus changing so that focus return works as expected.\n\t\t\t\tevent.preventDefault();\n\t\t\t}\n\t\t},\n\t\t// Closes the modal with two exceptions. 1. Opening the context menu on\n\t\t// the overlay. 2. Pressing on the overlay then dragging the pointer\n\t\t// over the modal and releasing. Due to the modal being a child of the\n\t\t// overlay, such a gesture is a `click` on the overlay and cannot be\n\t\t// excepted by a `click` handler. Thus the tactic of handling\n\t\t// `pointerup` and comparing its target to that of the `pointerdown`.\n\t\tonPointerUp: ( { target, button } ) => {\n\t\t\tconst isSameTarget = target === pressTarget;\n\t\t\tpressTarget = null;\n\t\t\tif ( button === 0 && isSameTarget ) onRequestClose();\n\t\t},\n\t};\n\n\tconst modal = (\n\t\t// eslint-disable-next-line jsx-a11y/no-static-element-interactions\n\t\t<div\n\t\t\tref={ useMergeRefs( [ ref, forwardedRef ] ) }\n\t\t\tclassName={ classnames(\n\t\t\t\t'components-modal__screen-overlay',\n\t\t\t\toverlayClassName\n\t\t\t) }\n\t\t\tonKeyDown={ handleEscapeKeyDown }\n\t\t\t{ ...( shouldCloseOnClickOutside ? overlayPressHandlers : {} ) }\n\t\t>\n\t\t\t<StyleProvider document={ document }>\n\t\t\t\t<div\n\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t'components-modal__frame',\n\t\t\t\t\t\tsizeClass,\n\t\t\t\t\t\tclassName\n\t\t\t\t\t) }\n\t\t\t\t\tstyle={ style }\n\t\t\t\t\tref={ useMergeRefs( [\n\t\t\t\t\t\tconstrainedTabbingRef,\n\t\t\t\t\t\tfocusReturnRef,\n\t\t\t\t\t\tfocusOnMount !== 'firstContentElement'\n\t\t\t\t\t\t\t? focusOnMountRef\n\t\t\t\t\t\t\t: null,\n\t\t\t\t\t] ) }\n\t\t\t\t\trole={ role }\n\t\t\t\t\taria-label={ contentLabel }\n\t\t\t\t\taria-labelledby={ contentLabel ? undefined : headingId }\n\t\t\t\t\taria-describedby={ aria.describedby }\n\t\t\t\t\ttabIndex={ -1 }\n\t\t\t\t\tonKeyDown={ onKeyDown }\n\t\t\t\t>\n\t\t\t\t\t<div\n\t\t\t\t\t\tclassName={ classnames( 'components-modal__content', {\n\t\t\t\t\t\t\t'hide-header': __experimentalHideHeader,\n\t\t\t\t\t\t\t'is-scrollable': hasScrollableContent,\n\t\t\t\t\t\t\t'has-scrolled-content': hasScrolledContent,\n\t\t\t\t\t\t} ) }\n\t\t\t\t\t\trole=\"document\"\n\t\t\t\t\t\tonScroll={ onContentContainerScroll }\n\t\t\t\t\t\tref={ contentRef }\n\t\t\t\t\t\taria-label={\n\t\t\t\t\t\t\thasScrollableContent\n\t\t\t\t\t\t\t\t? __( 'Scrollable section' )\n\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t}\n\t\t\t\t\t\ttabIndex={ hasScrollableContent ? 0 : undefined }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ ! __experimentalHideHeader && (\n\t\t\t\t\t\t\t<div className=\"components-modal__header\">\n\t\t\t\t\t\t\t\t<div className=\"components-modal__header-heading-container\">\n\t\t\t\t\t\t\t\t\t{ icon && (\n\t\t\t\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"components-modal__icon-container\"\n\t\t\t\t\t\t\t\t\t\t\taria-hidden\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t{ icon }\n\t\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t{ title && (\n\t\t\t\t\t\t\t\t\t\t<h1\n\t\t\t\t\t\t\t\t\t\t\tid={ headingId }\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"components-modal__header-heading\"\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t{ title }\n\t\t\t\t\t\t\t\t\t\t</h1>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t{ headerActions }\n\t\t\t\t\t\t\t\t{ isDismissible && (\n\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\tonClick={ onRequestClose }\n\t\t\t\t\t\t\t\t\t\ticon={ close }\n\t\t\t\t\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\t\t\t\t\tcloseButtonLabel || __( 'Close' )\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t) }\n\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tref={ useMergeRefs( [\n\t\t\t\t\t\t\t\tchildrenContainerRef,\n\t\t\t\t\t\t\t\tfocusOnMount === 'firstContentElement'\n\t\t\t\t\t\t\t\t\t? focusOnMountRef\n\t\t\t\t\t\t\t\t\t: null,\n\t\t\t\t\t\t\t] ) }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ children }\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t</StyleProvider>\n\t\t</div>\n\t);\n\n\treturn createPortal(\n\t\t<ModalContext.Provider value={ nestedDismissers.current }>\n\t\t\t{ modal }\n\t\t</ModalContext.Provider>,\n\t\tdocument.body\n\t);\n}\n\n/**\n * Modals give users information and choices related to a task they’re trying to\n * accomplish. They can contain critical information, require decisions, or\n * involve multiple tasks.\n *\n * ```jsx\n * import { Button, Modal } from '@wordpress/components';\n * import { useState } from '@wordpress/element';\n *\n * const MyModal = () => {\n * const [ isOpen, setOpen ] = useState( false );\n * const openModal = () => setOpen( true );\n * const closeModal = () => setOpen( false );\n *\n * return (\n * <>\n * <Button variant=\"secondary\" onClick={ openModal }>\n * Open Modal\n * </Button>\n * { isOpen && (\n * <Modal title=\"This is my modal\" onRequestClose={ closeModal }>\n * <Button variant=\"secondary\" onClick={ closeModal }>\n * My custom close button\n * </Button>\n * </Modal>\n * ) }\n * </>\n * );\n * };\n * ```\n */\nexport const Modal = forwardRef( UnforwardedModal );\n\nexport default Modal;\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;AAQnC;AACA;AACA;AACA,SACCC,YAAY,EACZC,WAAW,EACXC,SAAS,EACTC,MAAM,EACNC,QAAQ,EACRC,UAAU,EACVC,eAAe,EACfC,aAAa,EACbC,UAAU,QACJ,oBAAoB;AAC3B,SACCC,aAAa,EACbC,cAAc,EACdC,eAAe,EACfC,qBAAqB,EACrBC,YAAY,QACN,oBAAoB;AAC3B,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,KAAK,QAAQ,kBAAkB;AACxC,SAASC,kBAAkB,QAAQ,gBAAgB;;AAEnD;AACA;AACA;AACA,OAAO,KAAKC,UAAU,MAAM,eAAe;AAC3C,OAAOC,MAAM,MAAM,WAAW;AAC9B,OAAOC,aAAa,MAAM,mBAAmB;AAG7C;AACA,MAAMC,YA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A;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAM/B,KAAK,GAAG/C,UAAU,CAAEkB,gBAAiB,CAAC;AAEnD,eAAe6B,KAAK"}
|
|
@@ -51,7 +51,7 @@ export default function NavigationMenuTitle({
|
|
|
51
51
|
}, createElement("span", {
|
|
52
52
|
id: menuTitleId
|
|
53
53
|
}, title), (hasSearch || titleAction) && createElement(MenuTitleActionsUI, null, titleAction, hasSearch && createElement(Button, {
|
|
54
|
-
|
|
54
|
+
size: "small",
|
|
55
55
|
variant: "tertiary",
|
|
56
56
|
label: searchButtonLabel,
|
|
57
57
|
onClick: () => setIsSearching(true),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useRef","useState","__","sprintf","Icon","search","searchIcon","getAnimateClassName","Button","MenuTitleSearch","GroupTitleUI","MenuTitleActionsUI","MenuTitleUI","useNavigationMenuContext","SEARCH_FOCUS_DELAY","NavigationMenuTitle","hasSearch","onSearch","title","titleAction","isSearching","setIsSearching","menu","searchButtonRef","onCloseSearch","setTimeout","current","focus","menuTitleId","searchButtonLabel","createElement","className","as","level","id","
|
|
1
|
+
{"version":3,"names":["useRef","useState","__","sprintf","Icon","search","searchIcon","getAnimateClassName","Button","MenuTitleSearch","GroupTitleUI","MenuTitleActionsUI","MenuTitleUI","useNavigationMenuContext","SEARCH_FOCUS_DELAY","NavigationMenuTitle","hasSearch","onSearch","title","titleAction","isSearching","setIsSearching","menu","searchButtonRef","onCloseSearch","setTimeout","current","focus","menuTitleId","searchButtonLabel","createElement","className","as","level","id","size","variant","label","onClick","ref","icon","type","origin"],"sources":["@wordpress/components/src/navigation/menu/menu-title.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRef, useState } from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { Icon, search as searchIcon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { getAnimateClassName } from '../../animate';\nimport Button from '../../button';\nimport MenuTitleSearch from './menu-title-search';\nimport {\n\tGroupTitleUI,\n\tMenuTitleActionsUI,\n\tMenuTitleUI,\n} from '../styles/navigation-styles';\nimport { useNavigationMenuContext } from './context';\nimport { SEARCH_FOCUS_DELAY } from '../constants';\n\nimport type { NavigationMenuTitleProps } from '../types';\n\nexport default function NavigationMenuTitle( {\n\thasSearch,\n\tonSearch,\n\tsearch,\n\ttitle,\n\ttitleAction,\n}: NavigationMenuTitleProps ) {\n\tconst [ isSearching, setIsSearching ] = useState( false );\n\tconst { menu } = useNavigationMenuContext();\n\tconst searchButtonRef = useRef< HTMLElement >( null );\n\n\tif ( ! title ) {\n\t\treturn null;\n\t}\n\n\tconst onCloseSearch = () => {\n\t\tsetIsSearching( false );\n\n\t\t// Wait for the slide-in animation to complete before focusing the search button.\n\t\t// eslint-disable-next-line @wordpress/react-no-unsafe-timeout\n\t\tsetTimeout( () => {\n\t\t\tsearchButtonRef.current?.focus();\n\t\t}, SEARCH_FOCUS_DELAY );\n\t};\n\n\tconst menuTitleId = `components-navigation__menu-title-${ menu }`;\n\t/* translators: search button label for menu search box. %s: menu title */\n\tconst searchButtonLabel = sprintf( __( 'Search in %s' ), title );\n\n\treturn (\n\t\t<MenuTitleUI className=\"components-navigation__menu-title\">\n\t\t\t{ ! isSearching && (\n\t\t\t\t<GroupTitleUI\n\t\t\t\t\tas=\"h2\"\n\t\t\t\t\tclassName=\"components-navigation__menu-title-heading\"\n\t\t\t\t\tlevel={ 3 }\n\t\t\t\t>\n\t\t\t\t\t<span id={ menuTitleId }>{ title }</span>\n\n\t\t\t\t\t{ ( hasSearch || titleAction ) && (\n\t\t\t\t\t\t<MenuTitleActionsUI>\n\t\t\t\t\t\t\t{ titleAction }\n\n\t\t\t\t\t\t\t{ hasSearch && (\n\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\t\t\tlabel={ searchButtonLabel }\n\t\t\t\t\t\t\t\t\tonClick={ () => setIsSearching( true ) }\n\t\t\t\t\t\t\t\t\tref={ searchButtonRef }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<Icon icon={ searchIcon } />\n\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</MenuTitleActionsUI>\n\t\t\t\t\t) }\n\t\t\t\t</GroupTitleUI>\n\t\t\t) }\n\n\t\t\t{ isSearching && (\n\t\t\t\t<div\n\t\t\t\t\tclassName={ getAnimateClassName( {\n\t\t\t\t\t\ttype: 'slide-in',\n\t\t\t\t\t\torigin: 'left',\n\t\t\t\t\t} ) }\n\t\t\t\t>\n\t\t\t\t\t<MenuTitleSearch\n\t\t\t\t\t\tonCloseSearch={ onCloseSearch }\n\t\t\t\t\t\tonSearch={ onSearch }\n\t\t\t\t\t\tsearch={ search }\n\t\t\t\t\t\ttitle={ title }\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t</MenuTitleUI>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,MAAM,EAAEC,QAAQ,QAAQ,oBAAoB;AACrD,SAASC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AAC7C,SAASC,IAAI,EAAEC,MAAM,IAAIC,UAAU,QAAQ,kBAAkB;;AAE7D;AACA;AACA;AACA,SAASC,mBAAmB,QAAQ,eAAe;AACnD,OAAOC,MAAM,MAAM,cAAc;AACjC,OAAOC,eAAe,MAAM,qBAAqB;AACjD,SACCC,YAAY,EACZC,kBAAkB,EAClBC,WAAW,QACL,6BAA6B;AACpC,SAASC,wBAAwB,QAAQ,WAAW;AACpD,SAASC,kBAAkB,QAAQ,cAAc;AAIjD,eAAe,SAASC,mBAAmBA,CAAE;EAC5CC,SAAS;EACTC,QAAQ;EACRZ,MAAM;EACNa,KAAK;EACLC;AACyB,CAAC,EAAG;EAC7B,MAAM,CAAEC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,CAAE;MAChCkC,IAAI,EAAE,UAAU;MAChBC,MAAM,EAAE;IACT,CAAE;EAAG,GAELZ,aAAA,CAACrB,eAAe;IACfe,aAAa,EAAGA,aAAe;IAC/BP,QAAQ,EAAGA,QAAU;IACrBZ,MAAM,EAAGA,MAAQ;IACjBa,KAAK,EAAGA;EAAO,CACf,CACG,CAEM,CAAC;AAEhB"}
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import { createElement } from "react";
|
|
2
|
-
function _EMOTION_STRINGIFIED_CSS_ERROR__() { return "You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."; }
|
|
3
2
|
/**
|
|
4
3
|
* External dependencies
|
|
5
4
|
*/
|
|
6
5
|
|
|
7
|
-
import { css } from '@emotion/react';
|
|
8
|
-
|
|
9
6
|
/**
|
|
10
7
|
* WordPress dependencies
|
|
11
8
|
*/
|
|
@@ -18,9 +15,10 @@ import isShallowEqual from '@wordpress/is-shallow-equal';
|
|
|
18
15
|
|
|
19
16
|
import { contextConnect, useContextSystem } from '../../context';
|
|
20
17
|
import { useCx } from '../../utils/hooks/use-cx';
|
|
18
|
+
import { patternMatch, findParent } from '../utils/router';
|
|
21
19
|
import { View } from '../../view';
|
|
22
20
|
import { NavigatorContext } from '../context';
|
|
23
|
-
import
|
|
21
|
+
import * as styles from '../styles';
|
|
24
22
|
const MAX_HISTORY_LENGTH = 50;
|
|
25
23
|
function screensReducer(state = [], action) {
|
|
26
24
|
switch (action.type) {
|
|
@@ -31,15 +29,6 @@ function screensReducer(state = [], action) {
|
|
|
31
29
|
}
|
|
32
30
|
return state;
|
|
33
31
|
}
|
|
34
|
-
var _ref = process.env.NODE_ENV === "production" ? {
|
|
35
|
-
name: "15bx5k",
|
|
36
|
-
styles: "overflow-x:hidden"
|
|
37
|
-
} : {
|
|
38
|
-
name: "192ebb7-classes",
|
|
39
|
-
styles: "overflow-x:hidden;label:classes;",
|
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zIGlzIHRoZSBob21lIHNjcmVlbi48L3A+XG4gKiAgICAgICAgPE5hdmlnYXRvckJ1dHRvbiBwYXRoPVwiL2NoaWxkXCI+XG4gKiAgICAgICAgICBOYXZpZ2F0ZSB0byBjaGlsZCBzY3JlZW4uXG4gKiAgICAgICA8L05hdmlnYXRvckJ1dHRvbj5cbiAqICAgICA8L05hdmlnYXRvclNjcmVlbj5cbiAqXG4gKiAgICAgPE5hdmlnYXRvclNjcmVlbiBwYXRoPVwiL2NoaWxkXCI+XG4gKiAgICAgICA8cD5UaGlzIGlzIHRoZSBjaGlsZCBzY3JlZW4uPC9wPlxuICogICAgICAgPE5hdmlnYXRvckJhY2tCdXR0b24+XG4gKiAgICAgICAgIEdvIGJhY2tcbiAqICAgICAgIDwvTmF2aWdhdG9yQmFja0J1dHRvbj5cbiAqICAgICA8L05hdmlnYXRvclNjcmVlbj5cbiAqICAgPC9OYXZpZ2F0b3JQcm92aWRlcj5cbiAqICk7XG4gKiBgYGBcbiAqL1xuZXhwb3J0IGNvbnN0IE5hdmlnYXRvclByb3ZpZGVyID0gY29udGV4dENvbm5lY3QoXG5cdFVuY29ubmVjdGVkTmF2aWdhdG9yUHJvdmlkZXIsXG5cdCdOYXZpZ2F0b3JQcm92aWRlcidcbik7XG5cbmV4cG9ydCBkZWZhdWx0IE5hdmlnYXRvclByb3ZpZGVyO1xuIl19 */",
|
|
41
|
-
toString: _EMOTION_STRINGIFIED_CSS_ERROR__
|
|
42
|
-
};
|
|
43
32
|
function UnconnectedNavigatorProvider(props, forwardedRef) {
|
|
44
33
|
const {
|
|
45
34
|
initialPath,
|
|
@@ -166,9 +155,7 @@ function UnconnectedNavigatorProvider(props, forwardedRef) {
|
|
|
166
155
|
removeScreen
|
|
167
156
|
}), [locationHistory, matchedPath, goTo, goBack, goToParent, addScreen, removeScreen]);
|
|
168
157
|
const cx = useCx();
|
|
169
|
-
const classes = useMemo(
|
|
170
|
-
// Prevents horizontal overflow while animating screen transitions.
|
|
171
|
-
() => cx(_ref, className), [className, cx]);
|
|
158
|
+
const classes = useMemo(() => cx(styles.navigatorProviderWrapper, className), [className, cx]);
|
|
172
159
|
return createElement(View, {
|
|
173
160
|
ref: forwardedRef,
|
|
174
161
|
className: classes,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["css","useMemo","useState","useCallback","useReducer","useRef","useEffect","isShallowEqual","contextConnect","useContextSystem","useCx","View","NavigatorContext","patternMatch","findParent","MAX_HISTORY_LENGTH","screensReducer","state","action","type","screen","filter","s","id","_ref","process","env","NODE_ENV","name","styles","map","toString","_EMOTION_STRINGIFIED_CSS_ERROR__","UnconnectedNavigatorProvider","props","forwardedRef","initialPath","children","className","otherProps","locationHistory","setLocationHistory","path","currentLocationHistory","screens","dispatch","currentScreens","current","currentMatch","matchedPath","currentPath","length","undefined","resolvePath","newMatch","params","addScreen","removeScreen","goBack","prevLocationHistory","slice","isBack","hasRestoredFocus","goTo","options","focusTargetSelector","skipFocus","replace","restOptions","isNavigatingToPreviousPath","newLocation","newLocationHistory","push","goToParent","parentPath","navigatorContextValue","location","isInitial","match","cx","classes","createElement","ref","Provider","value","NavigatorProvider"],"sources":["@wordpress/components/src/navigator/navigator-provider/component.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { ForwardedRef } from 'react';\nimport { css } from '@emotion/react';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tuseMemo,\n\tuseState,\n\tuseCallback,\n\tuseReducer,\n\tuseRef,\n\tuseEffect,\n} from '@wordpress/element';\nimport isShallowEqual from '@wordpress/is-shallow-equal';\n\n/**\n * Internal dependencies\n */\nimport type { WordPressComponentProps } from '../../context';\nimport { contextConnect, useContextSystem } from '../../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\tScreen,\n} from '../types';\nimport { patternMatch, findParent } from '../utils/router';\n\ntype MatchedPath = ReturnType< typeof patternMatch >;\ntype ScreenAction = { type: string; screen: Screen };\n\nconst MAX_HISTORY_LENGTH = 50;\n\nfunction screensReducer(\n\tstate: Screen[] = [],\n\taction: ScreenAction\n): Screen[] {\n\tswitch ( action.type ) {\n\t\tcase 'add':\n\t\t\treturn [ ...state, action.screen ];\n\t\tcase 'remove':\n\t\t\treturn state.filter( ( s: Screen ) => s.id !== action.screen.id );\n\t}\n\n\treturn state;\n}\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\tconst currentLocationHistory = useRef< NavigatorLocation[] >( [] );\n\tconst [ screens, dispatch ] = useReducer( screensReducer, [] );\n\tconst currentScreens = useRef< Screen[] >( [] );\n\tuseEffect( () => {\n\t\tcurrentScreens.current = screens;\n\t}, [ screens ] );\n\tuseEffect( () => {\n\t\tcurrentLocationHistory.current = locationHistory;\n\t}, [ locationHistory ] );\n\tconst currentMatch = useRef< MatchedPath >();\n\tconst matchedPath = useMemo( () => {\n\t\tlet currentPath: string | undefined;\n\t\tif (\n\t\t\tlocationHistory.length === 0 ||\n\t\t\t( currentPath =\n\t\t\t\tlocationHistory[ locationHistory.length - 1 ].path ) ===\n\t\t\t\tundefined\n\t\t) {\n\t\t\tcurrentMatch.current = undefined;\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst resolvePath = ( path: string ) => {\n\t\t\tconst newMatch = patternMatch( path, screens );\n\n\t\t\t// If the new match is the same as the current match,\n\t\t\t// return the previous one for performance reasons.\n\t\t\tif (\n\t\t\t\tcurrentMatch.current &&\n\t\t\t\tnewMatch &&\n\t\t\t\tisShallowEqual(\n\t\t\t\t\tnewMatch.params,\n\t\t\t\t\tcurrentMatch.current.params\n\t\t\t\t) &&\n\t\t\t\tnewMatch.id === currentMatch.current.id\n\t\t\t) {\n\t\t\t\treturn currentMatch.current;\n\t\t\t}\n\n\t\t\treturn newMatch;\n\t\t};\n\n\t\tconst newMatch = resolvePath( currentPath );\n\t\tcurrentMatch.current = newMatch;\n\t\treturn newMatch;\n\t}, [ screens, locationHistory ] );\n\n\tconst addScreen = useCallback(\n\t\t( screen: Screen ) => dispatch( { type: 'add', screen } ),\n\t\t[]\n\t);\n\n\tconst removeScreen = useCallback(\n\t\t( screen: Screen ) => dispatch( { type: 'remove', screen } ),\n\t\t[]\n\t);\n\n\tconst goBack: NavigatorContextType[ 'goBack' ] = useCallback( () => {\n\t\tsetLocationHistory( ( prevLocationHistory ) => {\n\t\t\tif ( prevLocationHistory.length <= 1 ) {\n\t\t\t\treturn prevLocationHistory;\n\t\t\t}\n\t\t\treturn [\n\t\t\t\t...prevLocationHistory.slice( 0, -2 ),\n\t\t\t\t{\n\t\t\t\t\t...prevLocationHistory[ prevLocationHistory.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}, [] );\n\n\tconst goTo: NavigatorContextType[ 'goTo' ] = useCallback(\n\t\t( path, options = {} ) => {\n\t\t\tconst {\n\t\t\t\tfocusTargetSelector,\n\t\t\t\tisBack = false,\n\t\t\t\tskipFocus = false,\n\t\t\t\treplace = false,\n\t\t\t\t...restOptions\n\t\t\t} = options;\n\n\t\t\tconst isNavigatingToPreviousPath =\n\t\t\t\tisBack &&\n\t\t\t\tcurrentLocationHistory.current.length > 1 &&\n\t\t\t\tcurrentLocationHistory.current[\n\t\t\t\t\tcurrentLocationHistory.current.length - 2\n\t\t\t\t].path === path;\n\n\t\t\tif ( isNavigatingToPreviousPath ) {\n\t\t\t\tgoBack();\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tsetLocationHistory( ( prevLocationHistory ) => {\n\t\t\t\tconst newLocation = {\n\t\t\t\t\t...restOptions,\n\t\t\t\t\tpath,\n\t\t\t\t\tisBack,\n\t\t\t\t\thasRestoredFocus: false,\n\t\t\t\t\tskipFocus,\n\t\t\t\t};\n\n\t\t\t\tif ( prevLocationHistory.length === 0 ) {\n\t\t\t\t\treturn replace ? [] : [ newLocation ];\n\t\t\t\t}\n\n\t\t\t\tconst newLocationHistory = prevLocationHistory.slice(\n\t\t\t\t\tprevLocationHistory.length > MAX_HISTORY_LENGTH - 1 ? 1 : 0,\n\t\t\t\t\t-1\n\t\t\t\t);\n\n\t\t\t\tif ( ! replace ) {\n\t\t\t\t\tnewLocationHistory.push(\n\t\t\t\t\t\t// Assign `focusTargetSelector` to the previous location in history\n\t\t\t\t\t\t// (the one we just navigated from).\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t...prevLocationHistory[\n\t\t\t\t\t\t\t\tprevLocationHistory.length - 1\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\tfocusTargetSelector,\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tnewLocationHistory.push( newLocation );\n\n\t\t\t\treturn newLocationHistory;\n\t\t\t} );\n\t\t},\n\t\t[ goBack ]\n\t);\n\n\tconst goToParent: NavigatorContextType[ 'goToParent' ] = useCallback(\n\t\t( options = {} ) => {\n\t\t\tconst currentPath =\n\t\t\t\tcurrentLocationHistory.current[\n\t\t\t\t\tcurrentLocationHistory.current.length - 1\n\t\t\t\t].path;\n\t\t\tif ( currentPath === undefined ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst parentPath = findParent(\n\t\t\t\tcurrentPath,\n\t\t\t\tcurrentScreens.current\n\t\t\t);\n\t\t\tif ( parentPath === undefined ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tgoTo( parentPath, { ...options, isBack: true } );\n\t\t},\n\t\t[ goTo ]\n\t);\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\tparams: matchedPath ? matchedPath.params : {},\n\t\t\tmatch: matchedPath ? matchedPath.id : undefined,\n\t\t\tgoTo,\n\t\t\tgoBack,\n\t\t\tgoToParent,\n\t\t\taddScreen,\n\t\t\tremoveScreen,\n\t\t} ),\n\t\t[\n\t\t\tlocationHistory,\n\t\t\tmatchedPath,\n\t\t\tgoTo,\n\t\t\tgoBack,\n\t\t\tgoToParent,\n\t\t\taddScreen,\n\t\t\tremoveScreen,\n\t\t]\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 * ```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"],"mappings":";;AAAA;AACA;AACA;;AAEA,SAASA,GAAG,QAAQ,gBAAgB;;AAEpC;AACA;AACA;AACA,SACCC,OAAO,EACPC,QAAQ,EACRC,WAAW,EACXC,UAAU,EACVC,MAAM,EACNC,SAAS,QACH,oBAAoB;AAC3B,OAAOC,cAAc,MAAM,6BAA6B;;AAExD;AACA;AACA;;AAEA,SAASC,cAAc,EAAEC,gBAAgB,QAAQ,eAAe;AAChE,SAASC,KAAK,QAAQ,0BAA0B;AAChD,SAASC,IAAI,QAAQ,YAAY;AACjC,SAASC,gBAAgB,QAAQ,YAAY;AAO7C,SAASC,YAAY,EAAEC,UAAU,QAAQ,iBAAiB;AAK1D,MAAMC,kBAAkB,GAAG,EAAE;AAE7B,SAASC,cAAcA,CACtBC,KAAe,GAAG,EAAE,EACpBC,MAAoB,EACT;EACX,QAASA,MAAM,CAACC,IAAI;IACnB,KAAK,KAAK;MACT,OAAO,CAAE,GAAGF,KAAK,EAAEC,MAAM,CAACE,MAAM,CAAE;IACnC,KAAK,QAAQ;MACZ,OAAOH,KAAK,CAACI,MAAM,CAAIC,CAAS,IAAMA,CAAC,CAACC,EAAE,KAAKL,MAAM,CAACE,MAAM,CAACG,EAAG,CAAC;EACnE;EAEA,OAAON,KAAK;AACb;AAAC,IAAAO,IAAA,GAAAC,OAAA,CAAAC,GAAA,CAAAC,QAAA;EAAAC,IAAA;EAAAC,MAAA;AAAA;EAAAD,IAAA;EAAAC,MAAA;EAAAC,GAAA;EAAAC,QAAA,EAAAC;AAAA;AAED,SAASC,4BAA4BA,CACpCC,KAA+D,EAC/DC,YAAiC,EAChC;EACD,MAAM;IAAEC,WAAW;IAAEC,QAAQ;IAAEC,SAAS;IAAE,GAAGC;EAAW,CAAC,GACxD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AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMgD,iBAAiB,GAAG7E,cAAc,CAC9CyB,4BAA4B,EAC5B,mBACD,CAAC;AAED,eAAeoD,iBAAiB"}
|
|
1
|
+
{"version":3,"names":["useMemo","useState","useCallback","useReducer","useRef","useEffect","isShallowEqual","contextConnect","useContextSystem","useCx","patternMatch","findParent","View","NavigatorContext","styles","MAX_HISTORY_LENGTH","screensReducer","state","action","type","screen","filter","s","id","UnconnectedNavigatorProvider","props","forwardedRef","initialPath","children","className","otherProps","locationHistory","setLocationHistory","path","currentLocationHistory","screens","dispatch","currentScreens","current","currentMatch","matchedPath","currentPath","length","undefined","resolvePath","newMatch","params","addScreen","removeScreen","goBack","prevLocationHistory","slice","isBack","hasRestoredFocus","goTo","options","focusTargetSelector","skipFocus","replace","restOptions","isNavigatingToPreviousPath","newLocation","newLocationHistory","push","goToParent","parentPath","navigatorContextValue","location","isInitial","match","cx","classes","navigatorProviderWrapper","createElement","ref","Provider","value","NavigatorProvider"],"sources":["@wordpress/components/src/navigator/navigator-provider/component.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { ForwardedRef } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tuseMemo,\n\tuseState,\n\tuseCallback,\n\tuseReducer,\n\tuseRef,\n\tuseEffect,\n} from '@wordpress/element';\nimport isShallowEqual from '@wordpress/is-shallow-equal';\n\n/**\n * Internal dependencies\n */\nimport type { WordPressComponentProps } from '../../context';\nimport { contextConnect, useContextSystem } from '../../context';\nimport { useCx } from '../../utils/hooks/use-cx';\nimport { patternMatch, findParent } from '../utils/router';\nimport { View } from '../../view';\nimport { NavigatorContext } from '../context';\nimport * as styles from '../styles';\nimport type {\n\tNavigatorProviderProps,\n\tNavigatorLocation,\n\tNavigatorContext as NavigatorContextType,\n\tScreen,\n} from '../types';\n\ntype MatchedPath = ReturnType< typeof patternMatch >;\ntype ScreenAction = { type: string; screen: Screen };\n\nconst MAX_HISTORY_LENGTH = 50;\n\nfunction screensReducer(\n\tstate: Screen[] = [],\n\taction: ScreenAction\n): Screen[] {\n\tswitch ( action.type ) {\n\t\tcase 'add':\n\t\t\treturn [ ...state, action.screen ];\n\t\tcase 'remove':\n\t\t\treturn state.filter( ( s: Screen ) => s.id !== action.screen.id );\n\t}\n\n\treturn state;\n}\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\tconst currentLocationHistory = useRef< NavigatorLocation[] >( [] );\n\tconst [ screens, dispatch ] = useReducer( screensReducer, [] );\n\tconst currentScreens = useRef< Screen[] >( [] );\n\tuseEffect( () => {\n\t\tcurrentScreens.current = screens;\n\t}, [ screens ] );\n\tuseEffect( () => {\n\t\tcurrentLocationHistory.current = locationHistory;\n\t}, [ locationHistory ] );\n\tconst currentMatch = useRef< MatchedPath >();\n\tconst matchedPath = useMemo( () => {\n\t\tlet currentPath: string | undefined;\n\t\tif (\n\t\t\tlocationHistory.length === 0 ||\n\t\t\t( currentPath =\n\t\t\t\tlocationHistory[ locationHistory.length - 1 ].path ) ===\n\t\t\t\tundefined\n\t\t) {\n\t\t\tcurrentMatch.current = undefined;\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst resolvePath = ( path: string ) => {\n\t\t\tconst newMatch = patternMatch( path, screens );\n\n\t\t\t// If the new match is the same as the current match,\n\t\t\t// return the previous one for performance reasons.\n\t\t\tif (\n\t\t\t\tcurrentMatch.current &&\n\t\t\t\tnewMatch &&\n\t\t\t\tisShallowEqual(\n\t\t\t\t\tnewMatch.params,\n\t\t\t\t\tcurrentMatch.current.params\n\t\t\t\t) &&\n\t\t\t\tnewMatch.id === currentMatch.current.id\n\t\t\t) {\n\t\t\t\treturn currentMatch.current;\n\t\t\t}\n\n\t\t\treturn newMatch;\n\t\t};\n\n\t\tconst newMatch = resolvePath( currentPath );\n\t\tcurrentMatch.current = newMatch;\n\t\treturn newMatch;\n\t}, [ screens, locationHistory ] );\n\n\tconst addScreen = useCallback(\n\t\t( screen: Screen ) => dispatch( { type: 'add', screen } ),\n\t\t[]\n\t);\n\n\tconst removeScreen = useCallback(\n\t\t( screen: Screen ) => dispatch( { type: 'remove', screen } ),\n\t\t[]\n\t);\n\n\tconst goBack: NavigatorContextType[ 'goBack' ] = useCallback( () => {\n\t\tsetLocationHistory( ( prevLocationHistory ) => {\n\t\t\tif ( prevLocationHistory.length <= 1 ) {\n\t\t\t\treturn prevLocationHistory;\n\t\t\t}\n\t\t\treturn [\n\t\t\t\t...prevLocationHistory.slice( 0, -2 ),\n\t\t\t\t{\n\t\t\t\t\t...prevLocationHistory[ prevLocationHistory.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}, [] );\n\n\tconst goTo: NavigatorContextType[ 'goTo' ] = useCallback(\n\t\t( path, options = {} ) => {\n\t\t\tconst {\n\t\t\t\tfocusTargetSelector,\n\t\t\t\tisBack = false,\n\t\t\t\tskipFocus = false,\n\t\t\t\treplace = false,\n\t\t\t\t...restOptions\n\t\t\t} = options;\n\n\t\t\tconst isNavigatingToPreviousPath =\n\t\t\t\tisBack &&\n\t\t\t\tcurrentLocationHistory.current.length > 1 &&\n\t\t\t\tcurrentLocationHistory.current[\n\t\t\t\t\tcurrentLocationHistory.current.length - 2\n\t\t\t\t].path === path;\n\n\t\t\tif ( isNavigatingToPreviousPath ) {\n\t\t\t\tgoBack();\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tsetLocationHistory( ( prevLocationHistory ) => {\n\t\t\t\tconst newLocation = {\n\t\t\t\t\t...restOptions,\n\t\t\t\t\tpath,\n\t\t\t\t\tisBack,\n\t\t\t\t\thasRestoredFocus: false,\n\t\t\t\t\tskipFocus,\n\t\t\t\t};\n\n\t\t\t\tif ( prevLocationHistory.length === 0 ) {\n\t\t\t\t\treturn replace ? [] : [ newLocation ];\n\t\t\t\t}\n\n\t\t\t\tconst newLocationHistory = prevLocationHistory.slice(\n\t\t\t\t\tprevLocationHistory.length > MAX_HISTORY_LENGTH - 1 ? 1 : 0,\n\t\t\t\t\t-1\n\t\t\t\t);\n\n\t\t\t\tif ( ! replace ) {\n\t\t\t\t\tnewLocationHistory.push(\n\t\t\t\t\t\t// Assign `focusTargetSelector` to the previous location in history\n\t\t\t\t\t\t// (the one we just navigated from).\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t...prevLocationHistory[\n\t\t\t\t\t\t\t\tprevLocationHistory.length - 1\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\tfocusTargetSelector,\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tnewLocationHistory.push( newLocation );\n\n\t\t\t\treturn newLocationHistory;\n\t\t\t} );\n\t\t},\n\t\t[ goBack ]\n\t);\n\n\tconst goToParent: NavigatorContextType[ 'goToParent' ] = useCallback(\n\t\t( options = {} ) => {\n\t\t\tconst currentPath =\n\t\t\t\tcurrentLocationHistory.current[\n\t\t\t\t\tcurrentLocationHistory.current.length - 1\n\t\t\t\t].path;\n\t\t\tif ( currentPath === undefined ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst parentPath = findParent(\n\t\t\t\tcurrentPath,\n\t\t\t\tcurrentScreens.current\n\t\t\t);\n\t\t\tif ( parentPath === undefined ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tgoTo( parentPath, { ...options, isBack: true } );\n\t\t},\n\t\t[ goTo ]\n\t);\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\tparams: matchedPath ? matchedPath.params : {},\n\t\t\tmatch: matchedPath ? matchedPath.id : undefined,\n\t\t\tgoTo,\n\t\t\tgoBack,\n\t\t\tgoToParent,\n\t\t\taddScreen,\n\t\t\tremoveScreen,\n\t\t} ),\n\t\t[\n\t\t\tlocationHistory,\n\t\t\tmatchedPath,\n\t\t\tgoTo,\n\t\t\tgoBack,\n\t\t\tgoToParent,\n\t\t\taddScreen,\n\t\t\tremoveScreen,\n\t\t]\n\t);\n\n\tconst cx = useCx();\n\tconst classes = useMemo(\n\t\t() => cx( styles.navigatorProviderWrapper, 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 * ```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\tUn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,GAAGlE,OAAO,CAC1D,OAAQ;IACPmE,QAAQ,EAAE;MACT,GAAGpC,eAAe,CAAEA,eAAe,CAACW,MAAM,GAAG,CAAC,CAAE;MAChD0B,SAAS,EAAErC,eAAe,CAACW,MAAM,KAAK;IACvC,CAAC;IACDI,MAAM,EAAEN,WAAW,GAAGA,WAAW,CAACM,MAAM,GAAG,CAAC,CAAC;IAC7CuB,KAAK,EAAE7B,WAAW,GAAGA,WAAW,CAACjB,EAAE,GAAGoB,SAAS;IAC/CW,IAAI;IACJL,MAAM;IACNe,UAAU;IACVjB,SAAS;IACTC;EACD,CAAC,CAAE,EACH,CACCjB,eAAe,EACfS,WAAW,EACXc,IAAI,EACJL,MAAM,EACNe,UAAU,EACVjB,SAAS,EACTC,YAAY,CAEd,CAAC;EAED,MAAMsB,EAAE,GAAG7D,KAAK,CAAC,CAAC;EAClB,MAAM8D,OAAO,GAAGvE,OAAO,CACtB,MAAMsE,EAAE,CAAExD,MAAM,CAAC0D,wBAAwB,EAAE3C,SAAU,CAAC,EACtD,CAAEA,SAAS,EAAEyC,EAAE,CAChB,CAAC;EAED,OACCG,aAAA,CAAC7D,IAAI;IAAC8D,GAAG,EAAGhD,YAAc;IAACG,SAAS,EAAG0C,OAAS;IAAA,GAAMzC;EAAU,GAC/D2C,aAAA,CAAC5D,gBAAgB,CAAC8D,QAAQ;IAACC,KAAK,EAAGV;EAAuB,GACvDtC,QACwB,CACtB,CAAC;AAET;;AAEA;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,OAAO,MAAMiD,iBAAiB,GAAGtE,cAAc,CAC9CiB,4BAA4B,EAC5B,mBACD,CAAC;AAED,eAAeqD,iBAAiB"}
|
|
@@ -1,22 +1,15 @@
|
|
|
1
1
|
import { createElement } from "react";
|
|
2
|
-
function _EMOTION_STRINGIFIED_CSS_ERROR__() { return "You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."; }
|
|
3
2
|
/**
|
|
4
3
|
* External dependencies
|
|
5
4
|
*/
|
|
6
5
|
|
|
7
|
-
// eslint-disable-next-line no-restricted-imports
|
|
8
|
-
|
|
9
|
-
// eslint-disable-next-line no-restricted-imports
|
|
10
|
-
import { motion } from 'framer-motion';
|
|
11
|
-
import { css } from '@emotion/react';
|
|
12
|
-
|
|
13
6
|
/**
|
|
14
7
|
* WordPress dependencies
|
|
15
8
|
*/
|
|
16
9
|
import { focus } from '@wordpress/dom';
|
|
17
10
|
import { useContext, useEffect, useMemo, useRef, useId } from '@wordpress/element';
|
|
18
|
-
import {
|
|
19
|
-
import { isRTL } from '@wordpress/i18n';
|
|
11
|
+
import { useMergeRefs } from '@wordpress/compose';
|
|
12
|
+
import { isRTL as isRTLFn } from '@wordpress/i18n';
|
|
20
13
|
import { escapeAttribute } from '@wordpress/escape-html';
|
|
21
14
|
|
|
22
15
|
/**
|
|
@@ -27,22 +20,7 @@ import { contextConnect, useContextSystem } from '../../context';
|
|
|
27
20
|
import { useCx } from '../../utils/hooks/use-cx';
|
|
28
21
|
import { View } from '../../view';
|
|
29
22
|
import { NavigatorContext } from '../context';
|
|
30
|
-
|
|
31
|
-
const animationEnterDuration = 0.14;
|
|
32
|
-
const animationExitDuration = 0.14;
|
|
33
|
-
const animationExitDelay = 0;
|
|
34
|
-
|
|
35
|
-
// Props specific to `framer-motion` can't be currently passed to `NavigatorScreen`,
|
|
36
|
-
// as some of them would overlap with HTML props (e.g. `onAnimationStart`, ...)
|
|
37
|
-
var _ref = process.env.NODE_ENV === "production" ? {
|
|
38
|
-
name: "14x3t6z",
|
|
39
|
-
styles: "overflow-x:auto;max-height:100%"
|
|
40
|
-
} : {
|
|
41
|
-
name: "1ulogbc-classes",
|
|
42
|
-
styles: "overflow-x:auto;max-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lIHNjcmVlbi48L3A+XG4gKiAgICAgICAgPE5hdmlnYXRvckJ1dHRvbiBwYXRoPVwiL2NoaWxkXCI+XG4gKiAgICAgICAgICBOYXZpZ2F0ZSB0byBjaGlsZCBzY3JlZW4uXG4gKiAgICAgICA8L05hdmlnYXRvckJ1dHRvbj5cbiAqICAgICA8L05hdmlnYXRvclNjcmVlbj5cbiAqXG4gKiAgICAgPE5hdmlnYXRvclNjcmVlbiBwYXRoPVwiL2NoaWxkXCI+XG4gKiAgICAgICA8cD5UaGlzIGlzIHRoZSBjaGlsZCBzY3JlZW4uPC9wPlxuICogICAgICAgPE5hdmlnYXRvckJhY2tCdXR0b24+XG4gKiAgICAgICAgIEdvIGJhY2tcbiAqICAgICAgIDwvTmF2aWdhdG9yQmFja0J1dHRvbj5cbiAqICAgICA8L05hdmlnYXRvclNjcmVlbj5cbiAqICAgPC9OYXZpZ2F0b3JQcm92aWRlcj5cbiAqICk7XG4gKiBgYGBcbiAqL1xuZXhwb3J0IGNvbnN0IE5hdmlnYXRvclNjcmVlbiA9IGNvbnRleHRDb25uZWN0KFxuXHRVbmNvbm5lY3RlZE5hdmlnYXRvclNjcmVlbixcblx0J05hdmlnYXRvclNjcmVlbidcbik7XG5cbmV4cG9ydCBkZWZhdWx0IE5hdmlnYXRvclNjcmVlbjtcbiJdfQ== */",
|
|
44
|
-
toString: _EMOTION_STRINGIFIED_CSS_ERROR__
|
|
45
|
-
};
|
|
23
|
+
import * as styles from '../styles';
|
|
46
24
|
function UnconnectedNavigatorScreen(props, forwardedRef) {
|
|
47
25
|
const screenId = useId();
|
|
48
26
|
const {
|
|
@@ -51,7 +29,6 @@ function UnconnectedNavigatorScreen(props, forwardedRef) {
|
|
|
51
29
|
path,
|
|
52
30
|
...otherProps
|
|
53
31
|
} = useContextSystem(props, 'NavigatorScreen');
|
|
54
|
-
const prefersReducedMotion = useReducedMotion();
|
|
55
32
|
const {
|
|
56
33
|
location,
|
|
57
34
|
match,
|
|
@@ -68,8 +45,17 @@ function UnconnectedNavigatorScreen(props, forwardedRef) {
|
|
|
68
45
|
addScreen(screen);
|
|
69
46
|
return () => removeScreen(screen);
|
|
70
47
|
}, [screenId, path, addScreen, removeScreen]);
|
|
48
|
+
const isRTL = isRTLFn();
|
|
49
|
+
const {
|
|
50
|
+
isInitial,
|
|
51
|
+
isBack
|
|
52
|
+
} = location;
|
|
71
53
|
const cx = useCx();
|
|
72
|
-
const classes = useMemo(() => cx(
|
|
54
|
+
const classes = useMemo(() => cx(styles.navigatorScreen({
|
|
55
|
+
isInitial,
|
|
56
|
+
isBack,
|
|
57
|
+
isRTL
|
|
58
|
+
}), className), [className, cx, isInitial, isBack, isRTL]);
|
|
73
59
|
const locationRef = useRef(location);
|
|
74
60
|
useEffect(() => {
|
|
75
61
|
locationRef.current = location;
|
|
@@ -112,51 +98,11 @@ function UnconnectedNavigatorScreen(props, forwardedRef) {
|
|
|
112
98
|
elementToFocus.focus();
|
|
113
99
|
}, [isInitialLocation, isMatch, location.isBack, location.focusTargetSelector, location.skipFocus]);
|
|
114
100
|
const mergedWrapperRef = useMergeRefs([forwardedRef, wrapperRef]);
|
|
115
|
-
|
|
116
|
-
return null;
|
|
117
|
-
}
|
|
118
|
-
if (prefersReducedMotion) {
|
|
119
|
-
return createElement(View, {
|
|
120
|
-
ref: mergedWrapperRef,
|
|
121
|
-
className: classes,
|
|
122
|
-
...otherProps
|
|
123
|
-
}, children);
|
|
124
|
-
}
|
|
125
|
-
const animate = {
|
|
126
|
-
opacity: 1,
|
|
127
|
-
transition: {
|
|
128
|
-
delay: animationEnterDelay,
|
|
129
|
-
duration: animationEnterDuration,
|
|
130
|
-
ease: 'easeInOut'
|
|
131
|
-
},
|
|
132
|
-
x: 0
|
|
133
|
-
};
|
|
134
|
-
// Disable the initial animation if the screen is the very first screen to be
|
|
135
|
-
// rendered within the current `NavigatorProvider`.
|
|
136
|
-
const initial = location.isInitial && !location.isBack ? false : {
|
|
137
|
-
opacity: 0,
|
|
138
|
-
x: isRTL() && location.isBack || !isRTL() && !location.isBack ? 50 : -50
|
|
139
|
-
};
|
|
140
|
-
const exit = {
|
|
141
|
-
delay: animationExitDelay,
|
|
142
|
-
opacity: 0,
|
|
143
|
-
x: !isRTL() && location.isBack || isRTL() && !location.isBack ? 50 : -50,
|
|
144
|
-
transition: {
|
|
145
|
-
duration: animationExitDuration,
|
|
146
|
-
ease: 'easeInOut'
|
|
147
|
-
}
|
|
148
|
-
};
|
|
149
|
-
const animatedProps = {
|
|
150
|
-
animate,
|
|
151
|
-
exit,
|
|
152
|
-
initial
|
|
153
|
-
};
|
|
154
|
-
return createElement(motion.div, {
|
|
101
|
+
return isMatch ? createElement(View, {
|
|
155
102
|
ref: mergedWrapperRef,
|
|
156
103
|
className: classes,
|
|
157
|
-
...otherProps
|
|
158
|
-
|
|
159
|
-
}, children);
|
|
104
|
+
...otherProps
|
|
105
|
+
}, children) : null;
|
|
160
106
|
}
|
|
161
107
|
|
|
162
108
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["motion","css","focus","useContext","useEffect","useMemo","useRef","useId","useReducedMotion","useMergeRefs","isRTL","escapeAttribute","contextConnect","useContextSystem","useCx","View","NavigatorContext","animationEnterDelay","animationEnterDuration","animationExitDuration","animationExitDelay","_ref","process","env","NODE_ENV","name","styles","map","toString","_EMOTION_STRINGIFIED_CSS_ERROR__","UnconnectedNavigatorScreen","props","forwardedRef","screenId","children","className","path","otherProps","prefersReducedMotion","location","match","addScreen","removeScreen","isMatch","wrapperRef","screen","id","cx","classes","locationRef","current","isInitialLocation","isInitial","isBack","hasRestoredFocus","skipFocus","activeElement","ownerDocument","contains","elementToFocus","focusTargetSelector","querySelector","firstTabbable","tabbable","find","mergedWrapperRef","createElement","ref","animate","opacity","transition","delay","duration","ease","x","initial","exit","animatedProps","div","NavigatorScreen"],"sources":["@wordpress/components/src/navigator/navigator-screen/component.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { ForwardedRef } from 'react';\n// eslint-disable-next-line no-restricted-imports\nimport type { MotionProps } from 'framer-motion';\n// eslint-disable-next-line no-restricted-imports\nimport { motion } from 'framer-motion';\nimport { css } from '@emotion/react';\n\n/**\n * WordPress dependencies\n */\nimport { focus } from '@wordpress/dom';\nimport {\n\tuseContext,\n\tuseEffect,\n\tuseMemo,\n\tuseRef,\n\tuseId,\n} from '@wordpress/element';\nimport { useReducedMotion, useMergeRefs } from '@wordpress/compose';\nimport { isRTL } from '@wordpress/i18n';\nimport { escapeAttribute } from '@wordpress/escape-html';\n\n/**\n * Internal dependencies\n */\nimport type { WordPressComponentProps } from '../../context';\nimport { contextConnect, useContextSystem } from '../../context';\nimport { useCx } from '../../utils/hooks/use-cx';\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\tExclude< keyof MotionProps, 'style' | 'children' >\n>;\n\nfunction UnconnectedNavigatorScreen(\n\tprops: Props,\n\tforwardedRef: ForwardedRef< any >\n) {\n\tconst screenId = useId();\n\tconst { children, className, path, ...otherProps } = useContextSystem(\n\t\tprops,\n\t\t'NavigatorScreen'\n\t);\n\n\tconst prefersReducedMotion = useReducedMotion();\n\tconst { location, match, addScreen, removeScreen } =\n\t\tuseContext( NavigatorContext );\n\tconst isMatch = match === screenId;\n\tconst wrapperRef = useRef< HTMLDivElement >( null );\n\n\tuseEffect( () => {\n\t\tconst screen = {\n\t\t\tid: screenId,\n\t\t\tpath: escapeAttribute( path ),\n\t\t};\n\t\taddScreen( screen );\n\t\treturn () => removeScreen( screen );\n\t}, [ screenId, path, addScreen, removeScreen ] );\n\n\tconst cx = useCx();\n\tconst classes = useMemo(\n\t\t() =>\n\t\t\tcx(\n\t\t\t\tcss( {\n\t\t\t\t\t// Ensures horizontal overflow is visually accessible.\n\t\t\t\t\toverflowX: 'auto',\n\t\t\t\t\t// In case the root has a height, it should not be exceeded.\n\t\t\t\t\tmaxHeight: '100%',\n\t\t\t\t} ),\n\t\t\t\tclassName\n\t\t\t),\n\t\t[ className, cx ]\n\t);\n\n\tconst locationRef = useRef( location );\n\n\tuseEffect( () => {\n\t\tlocationRef.current = location;\n\t}, [ 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\t// - if the `skipFocus` option is not set to `true`. This is useful when we trigger the navigation outside of NavigatorScreen.\n\t\tif (\n\t\t\tisInitialLocation ||\n\t\t\t! isMatch ||\n\t\t\t! wrapperRef.current ||\n\t\t\tlocationRef.current.hasRestoredFocus ||\n\t\t\tlocation.skipFocus\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 && location?.focusTargetSelector ) {\n\t\t\telementToFocus = wrapperRef.current.querySelector(\n\t\t\t\tlocation.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\tlocationRef.current.hasRestoredFocus = true;\n\t\telementToFocus.focus();\n\t}, [\n\t\tisInitialLocation,\n\t\tisMatch,\n\t\tlocation.isBack,\n\t\tlocation.focusTargetSelector,\n\t\tlocation.skipFocus,\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={ classes }\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\t// Disable the initial animation if the screen is the very first screen to be\n\t// rendered within the current `NavigatorProvider`.\n\tconst initial =\n\t\tlocation.isInitial && ! location.isBack\n\t\t\t? false\n\t\t\t: {\n\t\t\t\t\topacity: 0,\n\t\t\t\t\tx:\n\t\t\t\t\t\t( isRTL() && location.isBack ) ||\n\t\t\t\t\t\t( ! isRTL() && ! location.isBack )\n\t\t\t\t\t\t\t? 50\n\t\t\t\t\t\t\t: -50,\n\t\t\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={ classes }\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"],"mappings":";;AAAA;AACA;AACA;;AAEA;;AAEA;AACA,SAASA,MAAM,QAAQ,eAAe;AACtC,SAASC,GAAG,QAAQ,gBAAgB;;AAEpC;AACA;AACA;AACA,SAASC,KAAK,QAAQ,gBAAgB;AACtC,SACCC,UAAU,EACVC,SAAS,EACTC,OAAO,EACPC,MAAM,EACNC,KAAK,QACC,oBAAoB;AAC3B,SAASC,gBAAgB,EAAEC,YAAY,QAAQ,oBAAoB;AACnE,SAASC,KAAK,QAAQ,iBAAiB;AACvC,SAASC,eAAe,QAAQ,wBAAwB;;AAExD;AACA;AACA;;AAEA,SAASC,cAAc,EAAEC,g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jE,EAAE,GACF,CAAC,EAAE;IACPiB,UAAU,EAAE;MACXE,QAAQ,EAAErD,qBAAqB;MAC/BsD,IAAI,EAAE;IACP;EACD,CAAC;EAED,MAAMI,aAAa,GAAG;IACrBT,OAAO;IACPQ,IAAI;IACJD;EACD,CAAC;EAED,OACCT,aAAA,CAAClE,MAAM,CAAC8E,GAAG;IACVX,GAAG,EAAGF,gBAAkB;IACxB9B,SAAS,EAAGa,OAAS;IAAA,GAChBX,UAAU;IAAA,GACVwC;EAAa,GAEhB3C,QACS,CAAC;AAEf;;AAEA;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;AACA,OAAO,MAAM6C,eAAe,GAAGnE,cAAc,CAC5CkB,0BAA0B,EAC1B,iBACD,CAAC;AAED,eAAeiD,eAAe"}
|
|
1
|
+
{"version":3,"names":["focus","useContext","useEffect","useMemo","useRef","useId","useMergeRefs","isRTL","isRTLFn","escapeAttribute","contextConnect","useContextSystem","useCx","View","NavigatorContext","styles","UnconnectedNavigatorScreen","props","forwardedRef","screenId","children","className","path","otherProps","location","match","addScreen","removeScreen","isMatch","wrapperRef","screen","id","isInitial","isBack","cx","classes","navigatorScreen","locationRef","current","isInitialLocation","hasRestoredFocus","skipFocus","activeElement","ownerDocument","contains","elementToFocus","focusTargetSelector","querySelector","firstTabbable","tabbable","find","mergedWrapperRef","createElement","ref","NavigatorScreen"],"sources":["@wordpress/components/src/navigator/navigator-screen/component.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { ForwardedRef } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { focus } from '@wordpress/dom';\nimport {\n\tuseContext,\n\tuseEffect,\n\tuseMemo,\n\tuseRef,\n\tuseId,\n} from '@wordpress/element';\nimport { useMergeRefs } from '@wordpress/compose';\nimport { isRTL as isRTLFn } from '@wordpress/i18n';\nimport { escapeAttribute } from '@wordpress/escape-html';\n\n/**\n * Internal dependencies\n */\nimport type { WordPressComponentProps } from '../../context';\nimport { contextConnect, useContextSystem } from '../../context';\nimport { useCx } from '../../utils/hooks/use-cx';\nimport { View } from '../../view';\nimport { NavigatorContext } from '../context';\nimport * as styles from '../styles';\nimport type { NavigatorScreenProps } from '../types';\n\nfunction UnconnectedNavigatorScreen(\n\tprops: WordPressComponentProps< NavigatorScreenProps, 'div', false >,\n\tforwardedRef: ForwardedRef< any >\n) {\n\tconst screenId = useId();\n\tconst { children, className, path, ...otherProps } = useContextSystem(\n\t\tprops,\n\t\t'NavigatorScreen'\n\t);\n\n\tconst { location, match, addScreen, removeScreen } =\n\t\tuseContext( NavigatorContext );\n\tconst isMatch = match === screenId;\n\tconst wrapperRef = useRef< HTMLDivElement >( null );\n\n\tuseEffect( () => {\n\t\tconst screen = {\n\t\t\tid: screenId,\n\t\t\tpath: escapeAttribute( path ),\n\t\t};\n\t\taddScreen( screen );\n\t\treturn () => removeScreen( screen );\n\t}, [ screenId, path, addScreen, removeScreen ] );\n\n\tconst isRTL = isRTLFn();\n\tconst { isInitial, isBack } = location;\n\tconst cx = useCx();\n\tconst classes = useMemo(\n\t\t() =>\n\t\t\tcx(\n\t\t\t\tstyles.navigatorScreen( {\n\t\t\t\t\tisInitial,\n\t\t\t\t\tisBack,\n\t\t\t\t\tisRTL,\n\t\t\t\t} ),\n\t\t\t\tclassName\n\t\t\t),\n\t\t[ className, cx, isInitial, isBack, isRTL ]\n\t);\n\n\tconst locationRef = useRef( location );\n\n\tuseEffect( () => {\n\t\tlocationRef.current = location;\n\t}, [ 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\t// - if the `skipFocus` option is not set to `true`. This is useful when we trigger the navigation outside of NavigatorScreen.\n\t\tif (\n\t\t\tisInitialLocation ||\n\t\t\t! isMatch ||\n\t\t\t! wrapperRef.current ||\n\t\t\tlocationRef.current.hasRestoredFocus ||\n\t\t\tlocation.skipFocus\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 && location?.focusTargetSelector ) {\n\t\t\telementToFocus = wrapperRef.current.querySelector(\n\t\t\t\tlocation.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\tlocationRef.current.hasRestoredFocus = true;\n\t\telementToFocus.focus();\n\t}, [\n\t\tisInitialLocation,\n\t\tisMatch,\n\t\tlocation.isBack,\n\t\tlocation.focusTargetSelector,\n\t\tlocation.skipFocus,\n\t] );\n\n\tconst mergedWrapperRef = useMergeRefs( [ forwardedRef, wrapperRef ] );\n\n\treturn isMatch ? (\n\t\t<View ref={ mergedWrapperRef } className={ classes } { ...otherProps }>\n\t\t\t{ children }\n\t\t</View>\n\t) : null;\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"],"mappings":";AAAA;AACA;AACA;;AAGA;AACA;AACA;AACA,SAASA,KAAK,QAAQ,gBAAgB;AACtC,SACCC,UAAU,EACVC,SAAS,EACTC,OAAO,EACPC,MAAM,EACNC,KAAK,QACC,oBAAoB;AAC3B,SAASC,YAAY,QAAQ,oBAAoB;AACjD,SAASC,KAAK,IAAIC,OAAO,QAAQ,iBAAiB;AAClD,SAASC,eAAe,QAAQ,wBAAwB;;AAExD;AACA;AACA;;AAEA,SAASC,cAAc,EAAEC,gBAAgB,QAAQ,eAAe;AAChE,SAASC,KAAK,QAAQ,0BAA0B;AAChD,SAASC,IAAI,QAAQ,YAAY;AACjC,SAASC,gBAAgB,QAAQ,YAAY;AAC7C,OAAO,KAAKC,MAAM,MAAM,WAAW;AAGnC,SAASC,0BAA0BA,CAClCC,KAAoE,EACpEC,YAAiC,EAChC;EACD,MAAMC,QAAQ,GAAGd,KAAK,CAAC,CAAC;EACxB,MAAM;IAAEe,QAAQ;IAAEC,SAAS;IAAEC,IAAI;IAAE,GAAGC;EAAW,CAAC,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