@wordpress/components 23.9.0 → 25.0.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 +62 -0
- package/CONTRIBUTING.md +75 -1
- package/README.md +1 -3
- package/build/autocomplete/autocompleter-ui.js +0 -2
- package/build/autocomplete/autocompleter-ui.js.map +1 -1
- package/build/autocomplete/index.js +2 -0
- package/build/autocomplete/index.js.map +1 -1
- package/build/button/index.js +2 -0
- package/build/button/index.js.map +1 -1
- package/build/card/card-media/component.js +2 -1
- package/build/card/card-media/component.js.map +1 -1
- package/build/color-picker/styles.js +8 -8
- package/build/color-picker/styles.js.map +1 -1
- package/build/combobox-control/index.js +7 -5
- package/build/combobox-control/index.js.map +1 -1
- package/build/combobox-control/styles.js +3 -3
- package/build/combobox-control/styles.js.map +1 -1
- package/build/date-time/date-time/index.js +3 -84
- package/build/date-time/date-time/index.js.map +1 -1
- package/build/date-time/date-time/styles.js +4 -19
- package/build/date-time/date-time/styles.js.map +1 -1
- package/build/dimension-control/index.js +1 -1
- package/build/dimension-control/index.js.map +1 -1
- package/build/draggable/index.js +2 -7
- package/build/draggable/index.js.map +1 -1
- package/build/dropdown-menu/index.js +87 -11
- package/build/dropdown-menu/index.js.map +1 -1
- package/build/dropdown-menu/types.js +6 -0
- package/build/dropdown-menu/types.js.map +1 -0
- package/build/dropdown-menu-v2/index.js +195 -0
- package/build/dropdown-menu-v2/index.js.map +1 -0
- package/build/dropdown-menu-v2/styles.js +176 -0
- package/build/dropdown-menu-v2/styles.js.map +1 -0
- package/build/dropdown-menu-v2/types.js +6 -0
- package/build/dropdown-menu-v2/types.js.map +1 -0
- package/build/form-token-field/index.js +5 -3
- package/build/form-token-field/index.js.map +1 -1
- package/build/form-token-field/styles.js +3 -3
- package/build/form-token-field/styles.js.map +1 -1
- package/build/index.native.js +0 -9
- package/build/index.native.js.map +1 -1
- package/build/input-control/styles/input-control-styles.js +30 -23
- package/build/input-control/styles/input-control-styles.js.map +1 -1
- package/build/mobile/bottom-sheet/cell.native.js +16 -8
- package/build/mobile/bottom-sheet/cell.native.js.map +1 -1
- package/build/mobile/bottom-sheet/range-cell.native.js +3 -2
- package/build/mobile/bottom-sheet/range-cell.native.js.map +1 -1
- package/build/mobile/bottom-sheet/stepper-cell/index.native.js +4 -2
- package/build/mobile/bottom-sheet/stepper-cell/index.native.js.map +1 -1
- package/build/mobile/bottom-sheet/switch-cell.native.js +8 -2
- package/build/mobile/bottom-sheet/switch-cell.native.js.map +1 -1
- package/build/mobile/bottom-sheet-select-control/index.native.js +4 -2
- package/build/mobile/bottom-sheet-select-control/index.native.js.map +1 -1
- package/build/mobile/bottom-sheet-text-control/index.native.js +4 -2
- package/build/mobile/bottom-sheet-text-control/index.native.js.map +1 -1
- package/build/mobile/global-styles-context/index.native.js +13 -1
- package/build/mobile/global-styles-context/index.native.js.map +1 -1
- package/build/mobile/link-picker/link-picker-results.native.js +3 -1
- package/build/mobile/link-picker/link-picker-results.native.js.map +1 -1
- package/build/navigable-container/container.js +39 -19
- package/build/navigable-container/container.js.map +1 -1
- package/build/navigable-container/index.js.map +1 -1
- package/build/navigable-container/menu.js +37 -5
- package/build/navigable-container/menu.js.map +1 -1
- package/build/navigable-container/tabbable.js +45 -4
- package/build/navigable-container/tabbable.js.map +1 -1
- package/build/navigable-container/types.js +6 -0
- package/build/navigable-container/types.js.map +1 -0
- package/build/palette-edit/index.js +34 -12
- package/build/palette-edit/index.js.map +1 -1
- package/build/private-apis.js +13 -1
- package/build/private-apis.js.map +1 -1
- package/build/range-control/index.native.js +5 -2
- package/build/range-control/index.native.js.map +1 -1
- package/build/sandbox/index.native.js +6 -2
- package/build/sandbox/index.native.js.map +1 -1
- package/build/slot-fill/bubbles-virtually/fill.js +2 -1
- package/build/slot-fill/bubbles-virtually/fill.js.map +1 -1
- package/build/slot-fill/bubbles-virtually/slot-fill-provider.js +45 -35
- package/build/slot-fill/bubbles-virtually/slot-fill-provider.js.map +1 -1
- package/build/slot-fill/bubbles-virtually/use-slot.js +11 -26
- package/build/slot-fill/bubbles-virtually/use-slot.js.map +1 -1
- package/build/slot-fill/fill.js +7 -31
- package/build/slot-fill/fill.js.map +1 -1
- package/build/slot-fill/index.js.map +1 -1
- package/build/slot-fill/provider.js +0 -6
- package/build/slot-fill/provider.js.map +1 -1
- package/build/slot-fill/slot.js +0 -5
- package/build/slot-fill/slot.js.map +1 -1
- package/build/snackbar/list.js +0 -2
- package/build/snackbar/list.js.map +1 -1
- package/build/tab-panel/index.js.map +1 -1
- package/build/theme/color-algorithms.js +1 -1
- package/build/theme/color-algorithms.js.map +1 -1
- package/build/toggle-group-control/toggle-group-control/styles.js +7 -7
- package/build/toggle-group-control/toggle-group-control/styles.js.map +1 -1
- package/build/toolbar/toolbar-button/index.js +1 -2
- package/build/toolbar/toolbar-button/index.js.map +1 -1
- package/build/toolbar/toolbar-item/index.js +4 -2
- package/build/toolbar/toolbar-item/index.js.map +1 -1
- package/build/utils/colors-values.js +3 -3
- package/build/utils/colors-values.js.map +1 -1
- package/build/utils/use-deprecated-props.js +35 -0
- package/build/utils/use-deprecated-props.js.map +1 -0
- package/build-module/autocomplete/autocompleter-ui.js +1 -3
- package/build-module/autocomplete/autocompleter-ui.js.map +1 -1
- package/build-module/autocomplete/index.js +3 -3
- package/build-module/autocomplete/index.js.map +1 -1
- package/build-module/button/index.js +2 -0
- package/build-module/button/index.js.map +1 -1
- package/build-module/card/card-media/component.js +2 -1
- package/build-module/card/card-media/component.js.map +1 -1
- package/build-module/color-picker/styles.js +8 -8
- package/build-module/color-picker/styles.js.map +1 -1
- package/build-module/combobox-control/index.js +6 -5
- package/build-module/combobox-control/index.js.map +1 -1
- package/build-module/combobox-control/styles.js +3 -3
- package/build-module/combobox-control/styles.js.map +1 -1
- package/build-module/date-time/date-time/index.js +6 -81
- package/build-module/date-time/date-time/index.js.map +1 -1
- package/build-module/date-time/date-time/styles.js +3 -17
- package/build-module/date-time/date-time/styles.js.map +1 -1
- package/build-module/dimension-control/index.js +1 -1
- package/build-module/dimension-control/index.js.map +1 -1
- package/build-module/draggable/index.js +2 -7
- package/build-module/draggable/index.js.map +1 -1
- package/build-module/dropdown-menu/index.js +87 -10
- package/build-module/dropdown-menu/index.js.map +1 -1
- package/build-module/dropdown-menu/types.js +2 -0
- package/build-module/dropdown-menu/types.js.map +1 -0
- package/build-module/dropdown-menu-v2/index.js +149 -0
- package/build-module/dropdown-menu-v2/index.js.map +1 -0
- package/build-module/dropdown-menu-v2/styles.js +153 -0
- package/build-module/dropdown-menu-v2/styles.js.map +1 -0
- package/build-module/dropdown-menu-v2/types.js +2 -0
- package/build-module/dropdown-menu-v2/types.js.map +1 -0
- package/build-module/form-token-field/index.js +4 -3
- package/build-module/form-token-field/index.js.map +1 -1
- package/build-module/form-token-field/styles.js +3 -3
- package/build-module/form-token-field/styles.js.map +1 -1
- package/build-module/index.native.js +0 -1
- package/build-module/index.native.js.map +1 -1
- package/build-module/input-control/styles/input-control-styles.js +30 -23
- package/build-module/input-control/styles/input-control-styles.js.map +1 -1
- package/build-module/mobile/bottom-sheet/cell.native.js +16 -8
- package/build-module/mobile/bottom-sheet/cell.native.js.map +1 -1
- package/build-module/mobile/bottom-sheet/range-cell.native.js +3 -2
- package/build-module/mobile/bottom-sheet/range-cell.native.js.map +1 -1
- package/build-module/mobile/bottom-sheet/stepper-cell/index.native.js +4 -2
- package/build-module/mobile/bottom-sheet/stepper-cell/index.native.js.map +1 -1
- package/build-module/mobile/bottom-sheet/switch-cell.native.js +7 -2
- package/build-module/mobile/bottom-sheet/switch-cell.native.js.map +1 -1
- package/build-module/mobile/bottom-sheet-select-control/index.native.js +4 -2
- package/build-module/mobile/bottom-sheet-select-control/index.native.js.map +1 -1
- package/build-module/mobile/bottom-sheet-text-control/index.native.js +4 -2
- package/build-module/mobile/bottom-sheet-text-control/index.native.js.map +1 -1
- package/build-module/mobile/global-styles-context/index.native.js +13 -1
- package/build-module/mobile/global-styles-context/index.native.js.map +1 -1
- package/build-module/mobile/link-picker/link-picker-results.native.js +3 -1
- package/build-module/mobile/link-picker/link-picker-results.native.js.map +1 -1
- package/build-module/navigable-container/container.js +43 -19
- package/build-module/navigable-container/container.js.map +1 -1
- package/build-module/navigable-container/index.js +0 -2
- package/build-module/navigable-container/index.js.map +1 -1
- package/build-module/navigable-container/menu.js +36 -4
- package/build-module/navigable-container/menu.js.map +1 -1
- package/build-module/navigable-container/tabbable.js +44 -3
- package/build-module/navigable-container/tabbable.js.map +1 -1
- package/build-module/navigable-container/types.js +2 -0
- package/build-module/navigable-container/types.js.map +1 -0
- package/build-module/palette-edit/index.js +34 -13
- package/build-module/palette-edit/index.js.map +1 -1
- package/build-module/private-apis.js +12 -1
- package/build-module/private-apis.js.map +1 -1
- package/build-module/range-control/index.native.js +5 -2
- package/build-module/range-control/index.native.js.map +1 -1
- package/build-module/sandbox/index.native.js +6 -2
- package/build-module/sandbox/index.native.js.map +1 -1
- package/build-module/slot-fill/bubbles-virtually/fill.js +2 -1
- package/build-module/slot-fill/bubbles-virtually/fill.js.map +1 -1
- package/build-module/slot-fill/bubbles-virtually/slot-fill-provider.js +46 -36
- package/build-module/slot-fill/bubbles-virtually/slot-fill-provider.js.map +1 -1
- package/build-module/slot-fill/bubbles-virtually/use-slot.js +12 -27
- package/build-module/slot-fill/bubbles-virtually/use-slot.js.map +1 -1
- package/build-module/slot-fill/fill.js +7 -31
- package/build-module/slot-fill/fill.js.map +1 -1
- package/build-module/slot-fill/index.js +1 -2
- package/build-module/slot-fill/index.js.map +1 -1
- package/build-module/slot-fill/provider.js +0 -6
- package/build-module/slot-fill/provider.js.map +1 -1
- package/build-module/slot-fill/slot.js +0 -5
- package/build-module/slot-fill/slot.js.map +1 -1
- package/build-module/snackbar/list.js +0 -2
- package/build-module/snackbar/list.js.map +1 -1
- package/build-module/tab-panel/index.js.map +1 -1
- package/build-module/theme/color-algorithms.js +1 -1
- package/build-module/theme/color-algorithms.js.map +1 -1
- package/build-module/toggle-group-control/toggle-group-control/styles.js +7 -7
- package/build-module/toggle-group-control/toggle-group-control/styles.js.map +1 -1
- package/build-module/toolbar/toolbar-button/index.js +1 -2
- package/build-module/toolbar/toolbar-button/index.js.map +1 -1
- package/build-module/toolbar/toolbar-item/index.js +5 -2
- package/build-module/toolbar/toolbar-item/index.js.map +1 -1
- package/build-module/utils/colors-values.js +3 -3
- package/build-module/utils/colors-values.js.map +1 -1
- package/build-module/utils/use-deprecated-props.js +25 -0
- package/build-module/utils/use-deprecated-props.js.map +1 -0
- package/build-style/style-rtl.css +67 -67
- package/build-style/style.css +67 -67
- package/build-types/autocomplete/autocompleter-ui.d.ts.map +1 -1
- package/build-types/autocomplete/index.d.ts.map +1 -1
- package/build-types/autocomplete/types.d.ts +2 -18
- package/build-types/autocomplete/types.d.ts.map +1 -1
- package/build-types/button/deprecated.d.ts +6 -0
- package/build-types/button/deprecated.d.ts.map +1 -1
- package/build-types/button/index.d.ts.map +1 -1
- package/build-types/button/types.d.ts +7 -0
- package/build-types/button/types.d.ts.map +1 -1
- package/build-types/card/card-media/component.d.ts +2 -1
- package/build-types/card/card-media/component.d.ts.map +1 -1
- package/build-types/card/stories/index.d.ts +21 -1
- package/build-types/card/stories/index.d.ts.map +1 -1
- package/build-types/color-picker/styles.d.ts.map +1 -1
- package/build-types/combobox-control/index.d.ts +1 -1
- package/build-types/combobox-control/index.d.ts.map +1 -1
- package/build-types/combobox-control/stories/index.d.ts.map +1 -1
- package/build-types/combobox-control/styles.d.ts +1 -1
- package/build-types/combobox-control/types.d.ts +8 -1
- package/build-types/combobox-control/types.d.ts.map +1 -1
- package/build-types/date-time/date-time/index.d.ts +3 -4
- package/build-types/date-time/date-time/index.d.ts.map +1 -1
- package/build-types/date-time/date-time/styles.d.ts +0 -4
- package/build-types/date-time/date-time/styles.d.ts.map +1 -1
- package/build-types/date-time/stories/date-time.d.ts.map +1 -1
- package/build-types/date-time/types.d.ts +0 -14
- package/build-types/date-time/types.d.ts.map +1 -1
- package/build-types/dimension-control/index.d.ts +1 -1
- package/build-types/draggable/index.d.ts.map +1 -1
- package/build-types/dropdown-menu/index.d.ts +83 -1
- package/build-types/dropdown-menu/index.d.ts.map +1 -1
- package/build-types/dropdown-menu/stories/index.d.ts +13 -0
- package/build-types/dropdown-menu/stories/index.d.ts.map +1 -0
- package/build-types/dropdown-menu/test/index.d.ts +2 -0
- package/build-types/dropdown-menu/test/index.d.ts.map +1 -0
- package/build-types/dropdown-menu/types.d.ts +134 -0
- package/build-types/dropdown-menu/types.d.ts.map +1 -0
- package/build-types/dropdown-menu-v2/index.d.ts +17 -0
- package/build-types/dropdown-menu-v2/index.d.ts.map +1 -0
- package/build-types/dropdown-menu-v2/stories/index.d.ts +13 -0
- package/build-types/dropdown-menu-v2/stories/index.d.ts.map +1 -0
- package/build-types/dropdown-menu-v2/styles.d.ts +41 -0
- package/build-types/dropdown-menu-v2/styles.d.ts.map +1 -0
- package/build-types/dropdown-menu-v2/test/index.d.ts +2 -0
- package/build-types/dropdown-menu-v2/test/index.d.ts.map +1 -0
- package/build-types/dropdown-menu-v2/types.d.ts +242 -0
- package/build-types/dropdown-menu-v2/types.d.ts.map +1 -0
- package/build-types/form-token-field/index.d.ts.map +1 -1
- package/build-types/form-token-field/styles.d.ts +1 -1
- package/build-types/form-token-field/types.d.ts +8 -1
- package/build-types/form-token-field/types.d.ts.map +1 -1
- package/build-types/input-control/styles/input-control-styles.d.ts.map +1 -1
- package/build-types/navigable-container/container.d.ts +20 -1
- package/build-types/navigable-container/container.d.ts.map +1 -1
- package/build-types/navigable-container/index.d.ts +5 -2
- package/build-types/navigable-container/index.d.ts.map +1 -1
- package/build-types/navigable-container/menu.d.ts +45 -11
- package/build-types/navigable-container/menu.d.ts.map +1 -1
- package/build-types/navigable-container/stories/navigable-menu.d.ts +12 -0
- package/build-types/navigable-container/stories/navigable-menu.d.ts.map +1 -0
- package/build-types/navigable-container/stories/tabbable-container.d.ts +12 -0
- package/build-types/navigable-container/stories/tabbable-container.d.ts.map +1 -0
- package/build-types/navigable-container/tabbable.d.ts +52 -9
- package/build-types/navigable-container/tabbable.d.ts.map +1 -1
- package/build-types/navigable-container/test/navigable-menu.d.ts +2 -0
- package/build-types/navigable-container/test/navigable-menu.d.ts.map +1 -0
- package/build-types/navigable-container/test/tababble-container.d.ts +2 -0
- package/build-types/navigable-container/test/tababble-container.d.ts.map +1 -0
- package/build-types/navigable-container/types.d.ts +61 -0
- package/build-types/navigable-container/types.d.ts.map +1 -0
- package/build-types/navigator/navigator-back-button/component.d.ts +1 -0
- package/build-types/navigator/navigator-back-button/component.d.ts.map +1 -1
- package/build-types/navigator/navigator-back-button/hook.d.ts +1 -0
- package/build-types/navigator/navigator-back-button/hook.d.ts.map +1 -1
- package/build-types/navigator/navigator-button/component.d.ts +1 -0
- package/build-types/navigator/navigator-button/component.d.ts.map +1 -1
- package/build-types/navigator/navigator-button/hook.d.ts +1 -0
- package/build-types/navigator/navigator-button/hook.d.ts.map +1 -1
- package/build-types/navigator/navigator-to-parent-button/component.d.ts +1 -0
- package/build-types/navigator/navigator-to-parent-button/component.d.ts.map +1 -1
- package/build-types/palette-edit/index.d.ts +1 -1
- package/build-types/palette-edit/index.d.ts.map +1 -1
- package/build-types/palette-edit/stories/index.d.ts.map +1 -1
- package/build-types/palette-edit/types.d.ts +8 -0
- package/build-types/palette-edit/types.d.ts.map +1 -1
- package/build-types/private-apis.d.ts.map +1 -1
- package/build-types/slot-fill/bubbles-virtually/fill.d.ts.map +1 -1
- package/build-types/slot-fill/bubbles-virtually/slot-fill-provider.d.ts.map +1 -1
- package/build-types/slot-fill/bubbles-virtually/use-slot.d.ts.map +1 -1
- package/build-types/slot-fill/fill.d.ts +4 -2
- package/build-types/slot-fill/fill.d.ts.map +1 -1
- package/build-types/slot-fill/index.d.ts +1 -2
- package/build-types/slot-fill/index.d.ts.map +1 -1
- package/build-types/slot-fill/provider.d.ts +0 -2
- package/build-types/slot-fill/provider.d.ts.map +1 -1
- package/build-types/slot-fill/slot.d.ts.map +1 -1
- package/build-types/snackbar/list.d.ts.map +1 -1
- package/build-types/toggle-group-control/toggle-group-control/styles.d.ts.map +1 -1
- package/build-types/toolbar/stories/index.d.ts.map +1 -1
- package/build-types/toolbar/toolbar-button/index.d.ts +6 -0
- package/build-types/toolbar/toolbar-button/index.d.ts.map +1 -1
- package/build-types/toolbar/toolbar-item/index.d.ts +6 -4
- package/build-types/toolbar/toolbar-item/index.d.ts.map +1 -1
- package/build-types/tree-grid/types.d.ts +7 -0
- package/build-types/tree-grid/types.d.ts.map +1 -1
- package/build-types/ui/context/get-styled-class-name-from-key.d.ts +1 -10
- package/build-types/ui/context/get-styled-class-name-from-key.d.ts.map +1 -1
- package/build-types/utils/use-deprecated-props.d.ts +9 -0
- package/build-types/utils/use-deprecated-props.d.ts.map +1 -0
- package/package.json +21 -20
- package/src/autocomplete/README.md +78 -52
- package/src/autocomplete/autocompleter-ui.tsx +0 -2
- package/src/autocomplete/index.tsx +1 -2
- package/src/autocomplete/types.ts +3 -19
- package/src/button/index.tsx +2 -0
- package/src/button/style.scss +18 -18
- package/src/button/types.ts +7 -0
- package/src/card/card-media/README.md +1 -1
- package/src/card/card-media/component.tsx +2 -1
- package/src/card/stories/index.tsx +47 -26
- package/src/checkbox-control/style.scss +1 -4
- package/src/color-picker/styles.ts +7 -2
- package/src/combobox-control/index.tsx +24 -18
- package/src/combobox-control/stories/index.tsx +0 -1
- package/src/combobox-control/styles.ts +4 -4
- package/src/combobox-control/types.ts +8 -1
- package/src/custom-gradient-picker/style.scss +2 -2
- package/src/date-time/README.md +0 -16
- package/src/date-time/date-time/index.tsx +17 -155
- package/src/date-time/date-time/styles.ts +0 -4
- package/src/date-time/stories/date-time.tsx +0 -4
- package/src/date-time/types.ts +0 -16
- package/src/dimension-control/index.tsx +1 -1
- package/src/draggable/index.tsx +1 -9
- package/src/dropdown-menu/README.md +12 -22
- package/src/dropdown-menu/{index.js → index.tsx} +111 -25
- package/src/dropdown-menu/stories/{index.js → index.tsx} +14 -22
- package/src/dropdown-menu/test/{index.js → index.tsx} +6 -5
- package/src/dropdown-menu/types.ts +143 -0
- package/src/dropdown-menu-v2/README.md +392 -0
- package/src/dropdown-menu-v2/index.tsx +241 -0
- package/src/dropdown-menu-v2/stories/index.tsx +193 -0
- package/src/dropdown-menu-v2/styles.ts +263 -0
- package/src/dropdown-menu-v2/test/index.tsx +816 -0
- package/src/dropdown-menu-v2/types.ts +250 -0
- package/src/form-toggle/style.scss +1 -5
- package/src/form-token-field/index.tsx +7 -3
- package/src/form-token-field/styles.ts +4 -4
- package/src/form-token-field/types.ts +8 -1
- package/src/index.native.js +0 -1
- package/src/input-control/styles/input-control-styles.tsx +7 -0
- package/src/mobile/bottom-sheet/cell.native.js +26 -5
- package/src/mobile/bottom-sheet/range-cell.native.js +2 -1
- package/src/mobile/bottom-sheet/stepper-cell/index.native.js +2 -0
- package/src/mobile/bottom-sheet/styles.native.scss +13 -1
- package/src/mobile/bottom-sheet/switch-cell.native.js +10 -2
- package/src/mobile/bottom-sheet-select-control/index.native.js +2 -0
- package/src/mobile/bottom-sheet-text-control/index.native.js +2 -0
- package/src/mobile/global-styles-context/index.native.js +12 -1
- package/src/mobile/link-picker/link-picker-results.native.js +3 -0
- package/src/modal/style.scss +1 -1
- package/src/navigable-container/README.md +24 -13
- package/src/navigable-container/{container.js → container.tsx} +57 -27
- package/src/navigable-container/{index.js → index.tsx} +0 -1
- package/src/navigable-container/menu.tsx +100 -0
- package/src/navigable-container/stories/{navigable-menu.js → navigable-menu.tsx} +15 -10
- package/src/navigable-container/stories/{tabbable-container.js → tabbable-container.tsx} +15 -6
- package/src/navigable-container/tabbable.tsx +92 -0
- package/src/navigable-container/test/{navigable-menu.js → navigable-menu.tsx} +3 -1
- package/src/navigable-container/test/{tababble-container.js → tababble-container.tsx} +53 -24
- package/src/navigable-container/types.ts +76 -0
- package/src/palette-edit/index.tsx +45 -7
- package/src/palette-edit/stories/index.tsx +4 -0
- package/src/palette-edit/types.ts +11 -0
- package/src/private-apis.ts +22 -0
- package/src/range-control/index.native.js +3 -0
- package/src/sandbox/index.native.js +4 -0
- package/src/search-control/style.scss +2 -0
- package/src/slot-fill/bubbles-virtually/fill.js +2 -1
- package/src/slot-fill/bubbles-virtually/slot-fill-provider.js +46 -60
- package/src/slot-fill/bubbles-virtually/use-slot.js +14 -41
- package/src/slot-fill/fill.js +4 -26
- package/src/slot-fill/index.js +1 -3
- package/src/slot-fill/provider.js +0 -6
- package/src/slot-fill/slot.js +0 -5
- package/src/snackbar/list.tsx +0 -1
- package/src/style.scss +6 -0
- package/src/tab-panel/index.tsx +1 -1
- package/src/theme/color-algorithms.ts +1 -1
- package/src/theme/stories/index.tsx +1 -1
- package/src/theme/test/color-algorithms.ts +2 -2
- package/src/toggle-group-control/test/__snapshots__/index.tsx.snap +10 -6
- package/src/toggle-group-control/toggle-group-control/styles.ts +6 -1
- package/src/toolbar/stories/index.tsx +25 -26
- package/src/toolbar/toolbar-button/index.tsx +10 -13
- package/src/toolbar/toolbar-item/{index.js → index.tsx} +12 -3
- package/src/tooltip/style.scss +2 -2
- package/src/tree-grid/README.md +18 -0
- package/src/tree-grid/types.ts +7 -0
- package/src/utils/colors-values.js +3 -3
- package/src/utils/theme-variables.scss +4 -4
- package/src/utils/use-deprecated-props.ts +29 -0
- package/tsconfig.json +1 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/build/mobile/readable-content-view/index.native.js +0 -97
- package/build/mobile/readable-content-view/index.native.js.map +0 -1
- package/build-module/mobile/readable-content-view/index.native.js +0 -81
- package/build-module/mobile/readable-content-view/index.native.js.map +0 -1
- package/src/CONTRIBUTING.md +0 -78
- package/src/README.md +0 -20
- package/src/mobile/readable-content-view/index.native.js +0 -85
- package/src/mobile/readable-content-view/style.native.scss +0 -30
- package/src/navigable-container/menu.js +0 -62
- package/src/navigable-container/tabbable.js +0 -46
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/components/src/mobile/bottom-sheet-text-control/index.native.js"],"names":["BottomSheetTextControl","initialValue","onChange","placeholder","label","icon","footerNote","cellPlaceholder","showSubSheet","setShowSubSheet","navigation","goBack","openSubSheet","navigate","BottomSheet","SubSheet","screenName","horizontalBorderStyle","styles","horizontalBorder","horizontalBorderDark","textEditorStyle","textEditor","textEditorDark","chevronRight","text","textFooternote"],"mappings":";;;;;;;;;AASA;;AANA;;AACA;;AAMA;;AACA;;AACA;;AASA;;AArBA;AACA;AACA;;AAIA;AACA;AACA;;AAUA;AACA;AACA;AAGA,MAAMA,sBAAsB,GAAG,
|
|
1
|
+
{"version":3,"sources":["@wordpress/components/src/mobile/bottom-sheet-text-control/index.native.js"],"names":["BottomSheetTextControl","initialValue","onChange","placeholder","label","icon","footerNote","cellPlaceholder","disabled","showSubSheet","setShowSubSheet","navigation","goBack","openSubSheet","navigate","BottomSheet","SubSheet","screenName","horizontalBorderStyle","styles","horizontalBorder","horizontalBorderDark","textEditorStyle","textEditor","textEditorDark","chevronRight","text","textFooternote"],"mappings":";;;;;;;;;AASA;;AANA;;AACA;;AAMA;;AACA;;AACA;;AASA;;AArBA;AACA;AACA;;AAIA;AACA;AACA;;AAUA;AACA;AACA;AAGA,MAAMA,sBAAsB,GAAG,QASxB;AAAA,MAT0B;AAChCC,IAAAA,YADgC;AAEhCC,IAAAA,QAFgC;AAGhCC,IAAAA,WAHgC;AAIhCC,IAAAA,KAJgC;AAKhCC,IAAAA,IALgC;AAMhCC,IAAAA,UANgC;AAOhCC,IAAAA,eAPgC;AAQhCC,IAAAA;AARgC,GAS1B;AACN,QAAM,CAAEC,YAAF,EAAgBC,eAAhB,IAAoC,uBAAU,KAAV,CAA1C;AACA,QAAMC,UAAU,GAAG,4BAAnB;;AAEA,QAAMC,MAAM,GAAG,MAAM;AACpBF,IAAAA,eAAe,CAAE,KAAF,CAAf;AACAC,IAAAA,UAAU,CAACC,MAAX;AACA,GAHD;;AAKA,QAAMC,YAAY,GAAG,MAAM;AAC1BF,IAAAA,UAAU,CAACG,QA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PD,CAfD,EAoCGhB,UAAU,IACX,4BAAC,qBAAD;AAAW,IAAA,KAAK,EAAGa,gBAAOQ;AAA1B,KACC,4BAAC,gCAAD;AACC,IAAA,KAAK,EAAGrB,UADT;AAEC,IAAA,SAAS,EAAC;AAFX,IADD,CArCF,CADD;AA+CA,CAhFD;;eAkFeN,sB","sourcesContent":["/**\n * External dependencies\n */\nimport { TextInput } from 'react-native';\nimport { useNavigation } from '@react-navigation/native';\n\n/**\n * WordPress dependencies\n */\nimport { useState } from '@wordpress/element';\nimport { Icon, chevronRight } from '@wordpress/icons';\nimport { usePreferredColorSchemeStyle } from '@wordpress/compose';\nimport {\n\tBottomSheet,\n\tPanelBody,\n\tFooterMessageControl,\n} from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport styles from './styles.scss';\n\nconst BottomSheetTextControl = ( {\n\tinitialValue,\n\tonChange,\n\tplaceholder,\n\tlabel,\n\ticon,\n\tfooterNote,\n\tcellPlaceholder,\n\tdisabled,\n} ) => {\n\tconst [ showSubSheet, setShowSubSheet ] = useState( false );\n\tconst navigation = useNavigation();\n\n\tconst goBack = () => {\n\t\tsetShowSubSheet( false );\n\t\tnavigation.goBack();\n\t};\n\n\tconst openSubSheet = () => {\n\t\tnavigation.navigate( BottomSheet.SubSheet.screenName );\n\t\tsetShowSubSheet( true );\n\t};\n\n\tconst horizontalBorderStyle = usePreferredColorSchemeStyle(\n\t\tstyles.horizontalBorder,\n\t\tstyles.horizontalBorderDark\n\t);\n\n\tconst textEditorStyle = usePreferredColorSchemeStyle(\n\t\tstyles.textEditor,\n\t\tstyles.textEditorDark\n\t);\n\n\treturn (\n\t\t<BottomSheet.SubSheet\n\t\t\tnavigationButton={\n\t\t\t\t<BottomSheet.Cell\n\t\t\t\t\ticon={ icon }\n\t\t\t\t\tlabel={ label }\n\t\t\t\t\tonPress={ openSubSheet }\n\t\t\t\t\tvalue={ initialValue || '' }\n\t\t\t\t\tplaceholder={ cellPlaceholder || placeholder || '' }\n\t\t\t\t\tdisabled={ disabled }\n\t\t\t\t>\n\t\t\t\t\t<Icon icon={ chevronRight }></Icon>\n\t\t\t\t</BottomSheet.Cell>\n\t\t\t}\n\t\t\tshowSheet={ showSubSheet }\n\t\t>\n\t\t\t<>\n\t\t\t\t<BottomSheet.NavBar>\n\t\t\t\t\t<BottomSheet.NavBar.BackButton onPress={ goBack } />\n\t\t\t\t\t<BottomSheet.NavBar.Heading>\n\t\t\t\t\t\t{ label }\n\t\t\t\t\t</BottomSheet.NavBar.Heading>\n\t\t\t\t</BottomSheet.NavBar>\n\t\t\t\t<PanelBody style={ horizontalBorderStyle }>\n\t\t\t\t\t<TextInput\n\t\t\t\t\t\tlabel={ label }\n\t\t\t\t\t\tonChangeText={ ( text ) => onChange( text ) }\n\t\t\t\t\t\tdefaultValue={ initialValue }\n\t\t\t\t\t\tmultiline={ true }\n\t\t\t\t\t\tplaceholder={ placeholder }\n\t\t\t\t\t\tplaceholderTextColor={ '#87a6bc' }\n\t\t\t\t\t\tstyle={ textEditorStyle }\n\t\t\t\t\t\ttextAlignVertical={ 'top' }\n\t\t\t\t\t/>\n\t\t\t\t</PanelBody>\n\t\t\t</>\n\n\t\t\t{ footerNote && (\n\t\t\t\t<PanelBody style={ styles.textFooternote }>\n\t\t\t\t\t<FooterMessageControl\n\t\t\t\t\t\tlabel={ footerNote }\n\t\t\t\t\t\ttextAlign=\"left\"\n\t\t\t\t\t/>\n\t\t\t\t</PanelBody>\n\t\t\t) }\n\t\t</BottomSheet.SubSheet>\n\t);\n};\n\nexport default BottomSheetTextControl;\n"]}
|
|
@@ -26,8 +26,20 @@ const GlobalStylesContext = (0, _element.createContext)({
|
|
|
26
26
|
GlobalStylesContext.BLOCK_STYLE_ATTRIBUTES = _utils.BLOCK_STYLE_ATTRIBUTES;
|
|
27
27
|
|
|
28
28
|
const getMergedGlobalStyles = (baseGlobalStyles, globalStyle, wrapperPropsStyle, blockAttributes, defaultColors, blockName, fontSizes) => {
|
|
29
|
+
var _baseGlobalStyles$ele, _baseGlobalStyles$blo;
|
|
30
|
+
|
|
31
|
+
// Current support for general styles and blocks.
|
|
29
32
|
const baseGlobalColors = {
|
|
30
|
-
baseColors:
|
|
33
|
+
baseColors: {
|
|
34
|
+
color: baseGlobalStyles === null || baseGlobalStyles === void 0 ? void 0 : baseGlobalStyles.color,
|
|
35
|
+
typography: baseGlobalStyles === null || baseGlobalStyles === void 0 ? void 0 : baseGlobalStyles.typography,
|
|
36
|
+
elements: {
|
|
37
|
+
link: baseGlobalStyles === null || baseGlobalStyles === void 0 ? void 0 : (_baseGlobalStyles$ele = baseGlobalStyles.elements) === null || _baseGlobalStyles$ele === void 0 ? void 0 : _baseGlobalStyles$ele.link
|
|
38
|
+
},
|
|
39
|
+
blocks: {
|
|
40
|
+
'core/button': baseGlobalStyles === null || baseGlobalStyles === void 0 ? void 0 : (_baseGlobalStyles$blo = baseGlobalStyles.blocks) === null || _baseGlobalStyles$blo === void 0 ? void 0 : _baseGlobalStyles$blo['core/button']
|
|
41
|
+
}
|
|
42
|
+
}
|
|
31
43
|
};
|
|
32
44
|
const blockStyleAttributes = Object.fromEntries(Object.entries(blockAttributes !== null && blockAttributes !== void 0 ? blockAttributes : {}).filter(_ref => {
|
|
33
45
|
let [key] = _ref;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/components/src/mobile/global-styles-context/index.native.js"],"names":["GlobalStylesContext","style","BLOCK_STYLE_ATTRIBUTES","getMergedGlobalStyles","baseGlobalStyles","globalStyle","wrapperPropsStyle","blockAttributes","defaultColors","blockName","fontSizes","baseGlobalColors","baseColors","blockStyleAttributes","Object","fromEntries","entries","filter","key","includes","wrapperPropsStyleFiltered","mergedStyle","blockColors","blockPaddings","blockTypography","useGlobalStyles","globalStyles","withGlobalStyles","WrappedComponent","props"],"mappings":";;;;;;;;;AAGA;;;;AAKA;;AARA;AACA;AACA;;AAGA;AACA;AACA;AAQA,MAAMA,mBAAmB,GAAG,4BAAe;AAAEC,EAAAA,KAAK,EAAE;AAAT,CAAf,CAA5B;AAEAD,mBAAmB,CAACE,sBAApB,GAA6CA,6BAA7C;;AAEO,MAAMC,qBAAqB,GAAG,CACpCC,gBADoC,EAEpCC,WAFoC,EAGpCC,iBAHoC,EAIpCC,eAJoC,EAKpCC,aALoC,EAMpCC,SANoC,EAOpCC,SAPoC,KAQhC;AACJ,QAAMC,gBAAgB,GAAG;AACxBC,IAAAA,UAAU,
|
|
1
|
+
{"version":3,"sources":["@wordpress/components/src/mobile/global-styles-context/index.native.js"],"names":["GlobalStylesContext","style","BLOCK_STYLE_ATTRIBUTES","getMergedGlobalStyles","baseGlobalStyles","globalStyle","wrapperPropsStyle","blockAttributes","defaultColors","blockName","fontSizes","baseGlobalColors","baseColors","color","typography","elements","link","blocks","blockStyleAttributes","Object","fromEntries","entries","filter","key","includes","wrapperPropsStyleFiltered","mergedStyle","blockColors","blockPaddings","blockTypography","useGlobalStyles","globalStyles","withGlobalStyles","WrappedComponent","props"],"mappings":";;;;;;;;;AAGA;;;;AAKA;;AARA;AACA;AACA;;AAGA;AACA;AACA;AAQA,MAAMA,mBAAmB,GAAG,4BAAe;AAAEC,EAAAA,KAAK,EAAE;AAAT,CAAf,CAA5B;AAEAD,mBAAmB,CAACE,sBAApB,GAA6CA,6BAA7C;;AAEO,MAAMC,qBAAqB,GAAG,CACpCC,gBADoC,EAEpCC,WAFoC,EAGpCC,iBAHoC,EAIpCC,eAJoC,EAKpCC,aALoC,EAMpCC,SANoC,EAOpCC,SAPoC,KAQhC;AAAA;;AACJ;AACA,QAAMC,gBAAgB,GAAG;AACxBC,IAAAA,UAAU,EAAE;AACXC,MAAAA,KAAK,EAAET,gBAAF,aAAEA,gBAAF,uBAAEA,gBAAgB,CAAES,KADd;AAEXC,MAAAA,UAAU,EAAEV,gBAAF,aAAEA,gBAAF,uBAAEA,gBAAgB,CAAEU,UAFnB;AAGXC,MAAAA,QAAQ,EAAE;AACTC,QAAAA,IAAI,EAAEZ,gBAA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OAAGE;AAJG,GAAP;AAMA,CAnEM;;;;AAqEA,MAAMC,eAAe,GAAG,MAAM;AACpC,QAAMC,YAAY,GAAG,yBAAY/B,mBAAZ,CAArB;AAEA,SAAO+B,YAAP;AACA,CAJM;;;;AAMA,MAAMC,gBAAgB,GAAKC,gBAAF,IAA0BC,KAAF,IAEtD,4BAAC,mBAAD,CAAqB,QAArB,QACKH,YAAF,IACD,4BAAC,gBAAD,6BAAuBG,KAAvB;AAA+B,EAAA,YAAY,EAAGH;AAA9C,GAFF,CAFK;;;eASQ/B,mB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createContext, useContext } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport {\n\tBLOCK_STYLE_ATTRIBUTES,\n\tgetBlockPaddings,\n\tgetBlockColors,\n\tgetBlockTypography,\n} from './utils';\n\nconst GlobalStylesContext = createContext( { style: {} } );\n\nGlobalStylesContext.BLOCK_STYLE_ATTRIBUTES = BLOCK_STYLE_ATTRIBUTES;\n\nexport const getMergedGlobalStyles = (\n\tbaseGlobalStyles,\n\tglobalStyle,\n\twrapperPropsStyle,\n\tblockAttributes,\n\tdefaultColors,\n\tblockName,\n\tfontSizes\n) => {\n\t// Current support for general styles and blocks.\n\tconst baseGlobalColors = {\n\t\tbaseColors: {\n\t\t\tcolor: baseGlobalStyles?.color,\n\t\t\ttypography: baseGlobalStyles?.typography,\n\t\t\telements: {\n\t\t\t\tlink: baseGlobalStyles?.elements?.link,\n\t\t\t},\n\t\t\tblocks: {\n\t\t\t\t'core/button': baseGlobalStyles?.blocks?.[ 'core/button' ],\n\t\t\t},\n\t\t},\n\t};\n\n\tconst blockStyleAttributes = Object.fromEntries(\n\t\tObject.entries( blockAttributes ?? {} ).filter( ( [ key ] ) =>\n\t\t\tBLOCK_STYLE_ATTRIBUTES.includes( key )\n\t\t)\n\t);\n\n\t// This prevents certain wrapper styles from being applied to blocks that\n\t// don't support them yet.\n\tconst wrapperPropsStyleFiltered = Object.fromEntries(\n\t\tObject.entries( wrapperPropsStyle ?? {} ).filter( ( [ key ] ) =>\n\t\t\tBLOCK_STYLE_ATTRIBUTES.includes( key )\n\t\t)\n\t);\n\n\tconst mergedStyle = {\n\t\t...baseGlobalColors,\n\t\t...globalStyle,\n\t\t...wrapperPropsStyleFiltered,\n\t};\n\tconst blockColors = getBlockColors(\n\t\tblockStyleAttributes,\n\t\tdefaultColors,\n\t\tblockName,\n\t\tbaseGlobalStyles\n\t);\n\tconst blockPaddings = getBlockPaddings(\n\t\tmergedStyle,\n\t\twrapperPropsStyle,\n\t\tblockStyleAttributes,\n\t\tblockColors\n\t);\n\tconst blockTypography = getBlockTypography(\n\t\tblockStyleAttributes,\n\t\tfontSizes,\n\t\tblockName,\n\t\tbaseGlobalStyles\n\t);\n\n\treturn {\n\t\t...mergedStyle,\n\t\t...blockPaddings,\n\t\t...blockColors,\n\t\t...blockTypography,\n\t};\n};\n\nexport const useGlobalStyles = () => {\n\tconst globalStyles = useContext( GlobalStylesContext );\n\n\treturn globalStyles;\n};\n\nexport const withGlobalStyles = ( WrappedComponent ) => ( props ) =>\n\t(\n\t\t<GlobalStylesContext.Consumer>\n\t\t\t{ ( globalStyles ) => (\n\t\t\t\t<WrappedComponent { ...props } globalStyles={ globalStyles } />\n\t\t\t) }\n\t\t</GlobalStylesContext.Consumer>\n\t);\n\nexport default GlobalStylesContext;\n"]}
|
|
@@ -109,7 +109,9 @@ function LinkPickerResults(_ref) {
|
|
|
109
109
|
|
|
110
110
|
return {
|
|
111
111
|
fetchMoreSuggestions: (0, _compose.debounce)(fetchMore, REQUEST_DEBOUNCE_DELAY)
|
|
112
|
-
};
|
|
112
|
+
}; // Disable eslint rule for now, to avoid introducing a regression
|
|
113
|
+
// (see https://github.com/WordPress/gutenberg/pull/23922#discussion_r1170634879).
|
|
114
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
113
115
|
}, []); // Prevent setting state when unmounted.
|
|
114
116
|
|
|
115
117
|
(0, _element.useEffect)(() => clearRequest, []); // Any time the query changes, we reset pagination.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/components/src/mobile/link-picker/link-picker-results.native.js"],"names":["PER_PAGE","REQUEST_DEBOUNCE_DELAY","MINIMUM_QUERY_SIZE","meetsThreshold","query","length","LinkPickerResults","onLinkPicked","directEntry","links","setLinks","hasAllSuggestions","setHasAllSuggestions","nextPage","pendingRequest","clearRequest","current","fetchMoreSuggestions","select","getSettings","fetchLinkSuggestions","search","__experimentalFetchLinkSuggestions","page","type","perPage","fetchMore","currentSuggestions","request","suggestions","onEndReached","spinner","styles","listProps","item","url","contentContainerStyle","list"],"mappings":";;;;;;;;;AAUA;;;;AAPA;;AAKA;;AACA;;AAEA;;AAKA;;AAhBA;AACA;AACA;;AAGA;AACA;AACA;;AAMA;AACA;AACA;AAGA,MAAMA,QAAQ,GAAG,EAAjB;AACA,MAAMC,sBAAsB,GAAG,GAA/B;AACA,MAAMC,kBAAkB,GAAG,CAA3B;;AACA,MAAMC,cAAc,GAAKC,KAAF,IAAaF,kBAAkB,IAAIE,KAAK,CAACC,MAAhE;;AAEe,SAASC,iBAAT,OAIX;AAAA,MAJuC;AAC1CF,IAAAA,KAD0C;AAE1CG,IAAAA,YAF0C;AAG1CC,IAAAA;AAH0C,GAIvC;AACH,QAAM,CAAEC,KAAF,EAASC,QAAT,IAAsB,uBAAU,CAAEF,WAAF,CAAV,CAA5B;AACA,QAAM,CAAEG,iBAAF,EAAqBC,oBAArB,IAA8C,uBAAU,KAAV,CAApD;AACA,QAAMC,QAAQ,GAAG,qBAAQ,CAAR,CAAjB;AACA,QAAMC,cAAc,GAAG,sBAAvB;;AACA,QAAMC,YAAY,GAAG,MAAM;AAC1BD,IAAAA,cAAc,CAACE,OAAf,GAAyB,IAAzB;AACA,GAFD,CALG,CASH;;;AACA,QAAM;AAAEC,IAAAA;AAAF,MAA2B,qBAAaC,MAAF,IAAc;AACzD,UAAM;AAAEC,MAAAA;AAAF,QAA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PAGE","REQUEST_DEBOUNCE_DELAY","MINIMUM_QUERY_SIZE","meetsThreshold","query","length","LinkPickerResults","onLinkPicked","directEntry","links","setLinks","hasAllSuggestions","setHasAllSuggestions","nextPage","pendingRequest","clearRequest","current","fetchMoreSuggestions","select","getSettings","fetchLinkSuggestions","search","__experimentalFetchLinkSuggestions","page","type","perPage","fetchMore","currentSuggestions","request","suggestions","onEndReached","spinner","styles","listProps","item","url","contentContainerStyle","list"],"mappings":";;;;;;;;;AAUA;;;;AAPA;;AAKA;;AACA;;AAEA;;AAKA;;AAhBA;AACA;AACA;;AAGA;AACA;AACA;;AAMA;AACA;AACA;AAGA,MAAMA,QAAQ,GAAG,EAAjB;AACA,MAAMC,sBAAsB,GAAG,GAA/B;AACA,MAAMC,kBAAkB,GAAG,CAA3B;;AACA,MAAMC,cAAc,GAAKC,KAAF,IAAaF,kBAAkB,IAAIE,KAAK,CAACC,MAAhE;;AAEe,SAASC,iBAAT,OAIX;AAAA,MAJuC;AAC1CF,IAAAA,KAD0C;AAE1CG,IAAAA,YAF0C;AAG1CC,IAAAA;AAH0C,GAIvC;AACH,QAAM,CAAEC,KAAF,EAASC,QAAT,IAAsB,uBAAU,CAAEF,WAAF,CAAV,CAA5B;AACA,QAAM,CAAEG,iBAAF,EAAqBC,oBAArB,IAA8C,uBAAU,KAAV,CAApD;AACA,QAAMC,QAAQ,GAAG,qBAAQ,CAAR,CAAjB;AACA,QAAMC,cAAc,GAAG,sBAAvB;;AACA,QAAMC,YAAY,GAAG,MAAM;AAC1BD,IAAAA,cAAc,CAACE,OAAf,GAAyB,IAAzB;AACA,GAFD,CALG,CASH;;;AACA,QAAM;AAAEC,IAAAA;AAAF,MAA2B,qBAAaC,MAAF,IAAc;AACzD,UAAM;AAAEC,MAAAA;AAAF,QAAkBD,MAAM,CAAE,mBAAF,CAA9B;;AACA,UAAME,oBAAoB,GAAG,eAAwB;AAAA,UAAhB;AAAEC,QAAAA;AAAF,OAAgB;;AACpD,UAAKlB,cA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ACvB,GAAGA,SAAS,CAACG,qBADU,EAEvBJ,gBAAOK,IAFgB;AAfzB,OADC;AAAA,GADH,CADD;AA0BA","sourcesContent":["/**\n * External dependencies\n */\nimport { ActivityIndicator, FlatList, View } from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport { BottomSheet, BottomSheetConsumer } from '@wordpress/components';\nimport { debounce } from '@wordpress/compose';\nimport { useState, useEffect, useRef } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport styles from './styles.scss';\n\nconst PER_PAGE = 20;\nconst REQUEST_DEBOUNCE_DELAY = 400;\nconst MINIMUM_QUERY_SIZE = 2;\nconst meetsThreshold = ( query ) => MINIMUM_QUERY_SIZE <= query.length;\n\nexport default function LinkPickerResults( {\n\tquery,\n\tonLinkPicked,\n\tdirectEntry,\n} ) {\n\tconst [ links, setLinks ] = useState( [ directEntry ] );\n\tconst [ hasAllSuggestions, setHasAllSuggestions ] = useState( false );\n\tconst nextPage = useRef( 1 );\n\tconst pendingRequest = useRef();\n\tconst clearRequest = () => {\n\t\tpendingRequest.current = null;\n\t};\n\n\t// A stable debounced function to fetch suggestions and append.\n\tconst { fetchMoreSuggestions } = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( 'core/block-editor' );\n\t\tconst fetchLinkSuggestions = async ( { search } ) => {\n\t\t\tif ( meetsThreshold( search ) ) {\n\t\t\t\treturn await getSettings().__experimentalFetchLinkSuggestions(\n\t\t\t\t\tsearch,\n\t\t\t\t\t{ page: nextPage.current, type: 'post', perPage: PER_PAGE }\n\t\t\t\t);\n\t\t\t}\n\t\t};\n\t\tconst fetchMore = async ( {\n\t\t\tquery: search,\n\t\t\tlinks: currentSuggestions,\n\t\t} ) => {\n\t\t\t// Return early if we've already detected the end of data or we are\n\t\t\t// already awaiting a response.\n\t\t\tif ( hasAllSuggestions || pendingRequest.current ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst request = fetchLinkSuggestions( { search } );\n\t\t\tpendingRequest.current = request;\n\t\t\tconst suggestions = await request;\n\n\t\t\t// Only update links for the most recent request.\n\t\t\tif ( suggestions && request === pendingRequest.current ) {\n\t\t\t\t// Since we don't have the response header, we check if the results\n\t\t\t\t// are truncated to determine we've reached the end.\n\t\t\t\tif ( suggestions.length < PER_PAGE ) {\n\t\t\t\t\tsetHasAllSuggestions( true );\n\t\t\t\t}\n\t\t\t\tsetLinks( [ ...currentSuggestions, ...suggestions ] );\n\t\t\t\tnextPage.current++;\n\t\t\t}\n\n\t\t\tclearRequest();\n\t\t};\n\t\treturn {\n\t\t\tfetchMoreSuggestions: debounce( fetchMore, REQUEST_DEBOUNCE_DELAY ),\n\t\t};\n\t\t// Disable eslint rule for now, to avoid introducing a regression\n\t\t// (see https://github.com/WordPress/gutenberg/pull/23922#discussion_r1170634879).\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [] );\n\n\t// Prevent setting state when unmounted.\n\tuseEffect( () => clearRequest, [] );\n\n\t// Any time the query changes, we reset pagination.\n\tuseEffect( () => {\n\t\tclearRequest();\n\t\tnextPage.current = 1;\n\t\tsetHasAllSuggestions( false );\n\t\tsetLinks( [ directEntry ] );\n\t\tfetchMoreSuggestions( { query, links: [ directEntry ] } );\n\t\t// Disable reason: deferring this refactor to the native team.\n\t\t// see https://github.com/WordPress/gutenberg/pull/41166\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [ query ] );\n\n\tconst onEndReached = () => fetchMoreSuggestions( { query, links } );\n\n\tconst spinner = ! hasAllSuggestions && meetsThreshold( query ) && (\n\t\t<View style={ styles.spinner }>\n\t\t\t<ActivityIndicator animating />\n\t\t</View>\n\t);\n\n\treturn (\n\t\t<BottomSheetConsumer>\n\t\t\t{ ( { listProps } ) => (\n\t\t\t\t<FlatList\n\t\t\t\t\tdata={ links }\n\t\t\t\t\tkeyboardShouldPersistTaps=\"always\"\n\t\t\t\t\trenderItem={ ( { item } ) => (\n\t\t\t\t\t\t<BottomSheet.LinkSuggestionItemCell\n\t\t\t\t\t\t\tsuggestion={ item }\n\t\t\t\t\t\t\tonLinkPicked={ onLinkPicked }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t\tkeyExtractor={ ( { url, type } ) => `${ url }-${ type }` }\n\t\t\t\t\tonEndReached={ onEndReached }\n\t\t\t\t\tonEndReachedThreshold={ 0.1 }\n\t\t\t\t\tinitialNumToRender={ PER_PAGE }\n\t\t\t\t\tListFooterComponent={ spinner }\n\t\t\t\t\t{ ...listProps }\n\t\t\t\t\tcontentContainerStyle={ [\n\t\t\t\t\t\t...listProps.contentContainerStyle,\n\t\t\t\t\t\tstyles.list,\n\t\t\t\t\t] }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</BottomSheetConsumer>\n\t);\n}\n"]}
|
|
@@ -13,7 +13,9 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
|
|
|
13
13
|
|
|
14
14
|
var _dom = require("@wordpress/dom");
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
/**
|
|
17
|
+
* External dependencies
|
|
18
|
+
*/
|
|
17
19
|
|
|
18
20
|
/**
|
|
19
21
|
* WordPress dependencies
|
|
@@ -35,8 +37,8 @@ function cycleValue(value, total, offset) {
|
|
|
35
37
|
}
|
|
36
38
|
|
|
37
39
|
class NavigableContainer extends _element.Component {
|
|
38
|
-
constructor() {
|
|
39
|
-
super(
|
|
40
|
+
constructor(args) {
|
|
41
|
+
super(args);
|
|
40
42
|
this.onKeyDown = this.onKeyDown.bind(this);
|
|
41
43
|
this.bindContainer = this.bindContainer.bind(this);
|
|
42
44
|
this.getFocusableContext = this.getFocusableContext.bind(this);
|
|
@@ -44,18 +46,24 @@ class NavigableContainer extends _element.Component {
|
|
|
44
46
|
}
|
|
45
47
|
|
|
46
48
|
componentDidMount() {
|
|
47
|
-
|
|
49
|
+
if (!this.container) {
|
|
50
|
+
return;
|
|
51
|
+
} // We use DOM event listeners instead of React event listeners
|
|
48
52
|
// because we want to catch events from the underlying DOM tree
|
|
49
53
|
// The React Tree can be different from the DOM tree when using
|
|
50
54
|
// portals. Block Toolbars for instance are rendered in a separate
|
|
51
55
|
// React Trees.
|
|
56
|
+
|
|
57
|
+
|
|
52
58
|
this.container.addEventListener('keydown', this.onKeyDown);
|
|
53
|
-
this.container.addEventListener('focus', this.onFocus);
|
|
54
59
|
}
|
|
55
60
|
|
|
56
61
|
componentWillUnmount() {
|
|
62
|
+
if (!this.container) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
|
|
57
66
|
this.container.removeEventListener('keydown', this.onKeyDown);
|
|
58
|
-
this.container.removeEventListener('focus', this.onFocus);
|
|
59
67
|
}
|
|
60
68
|
|
|
61
69
|
bindContainer(ref) {
|
|
@@ -72,6 +80,10 @@ class NavigableContainer extends _element.Component {
|
|
|
72
80
|
}
|
|
73
81
|
|
|
74
82
|
getFocusableContext(target) {
|
|
83
|
+
if (!this.container) {
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
|
|
75
87
|
const {
|
|
76
88
|
onlyBrowserTabstops
|
|
77
89
|
} = this.props;
|
|
@@ -91,14 +103,12 @@ class NavigableContainer extends _element.Component {
|
|
|
91
103
|
}
|
|
92
104
|
|
|
93
105
|
getFocusableIndex(focusables, target) {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
if (directIndex !== -1) {
|
|
97
|
-
return directIndex;
|
|
98
|
-
}
|
|
106
|
+
return focusables.indexOf(target);
|
|
99
107
|
}
|
|
100
108
|
|
|
101
109
|
onKeyDown(event) {
|
|
110
|
+
var _event$target2, _event$target2$ownerD;
|
|
111
|
+
|
|
102
112
|
if (this.props.onKeyDown) {
|
|
103
113
|
this.props.onKeyDown(event);
|
|
104
114
|
}
|
|
@@ -115,19 +125,18 @@ class NavigableContainer extends _element.Component {
|
|
|
115
125
|
const offset = eventToOffset(event); // eventToOffset returns undefined if the event is not handled by the component.
|
|
116
126
|
|
|
117
127
|
if (offset !== undefined && stopNavigationEvents) {
|
|
128
|
+
var _event$target;
|
|
129
|
+
|
|
118
130
|
// Prevents arrow key handlers bound to the document directly interfering.
|
|
119
131
|
event.stopImmediatePropagation(); // When navigating a collection of items, prevent scroll containers
|
|
120
132
|
// from scrolling. The preventDefault also prevents Voiceover from
|
|
121
133
|
// 'handling' the event, as voiceover will try to use arrow keys
|
|
122
134
|
// for highlighting text.
|
|
123
135
|
|
|
124
|
-
const targetRole = event.target.getAttribute('role');
|
|
125
|
-
const targetHasMenuItemRole = MENU_ITEM_ROLES.includes(targetRole);
|
|
126
|
-
// after this component has already moved it.
|
|
127
|
-
|
|
128
|
-
const isTab = event.code === 'Tab';
|
|
136
|
+
const targetRole = (_event$target = event.target) === null || _event$target === void 0 ? void 0 : _event$target.getAttribute('role');
|
|
137
|
+
const targetHasMenuItemRole = !!targetRole && MENU_ITEM_ROLES.includes(targetRole);
|
|
129
138
|
|
|
130
|
-
if (targetHasMenuItemRole
|
|
139
|
+
if (targetHasMenuItemRole) {
|
|
131
140
|
event.preventDefault();
|
|
132
141
|
}
|
|
133
142
|
}
|
|
@@ -136,7 +145,13 @@ class NavigableContainer extends _element.Component {
|
|
|
136
145
|
return;
|
|
137
146
|
}
|
|
138
147
|
|
|
139
|
-
const
|
|
148
|
+
const activeElement = (_event$target2 = event.target) === null || _event$target2 === void 0 ? void 0 : (_event$target2$ownerD = _event$target2.ownerDocument) === null || _event$target2$ownerD === void 0 ? void 0 : _event$target2$ownerD.activeElement;
|
|
149
|
+
|
|
150
|
+
if (!activeElement) {
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
const context = getFocusableContext(activeElement);
|
|
140
155
|
|
|
141
156
|
if (!context) {
|
|
142
157
|
return;
|
|
@@ -150,7 +165,12 @@ class NavigableContainer extends _element.Component {
|
|
|
150
165
|
|
|
151
166
|
if (nextIndex >= 0 && nextIndex < focusables.length) {
|
|
152
167
|
focusables[nextIndex].focus();
|
|
153
|
-
onNavigate(nextIndex, focusables[nextIndex]);
|
|
168
|
+
onNavigate(nextIndex, focusables[nextIndex]); // `preventDefault()` on tab to avoid having the browser move the focus
|
|
169
|
+
// after this component has already moved it.
|
|
170
|
+
|
|
171
|
+
if (event.code === 'Tab') {
|
|
172
|
+
event.preventDefault();
|
|
173
|
+
}
|
|
154
174
|
}
|
|
155
175
|
}
|
|
156
176
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/components/src/navigable-container/container.js"],"names":["noop","MENU_ITEM_ROLES","cycleValue","value","total","offset","nextValue","NavigableContainer","Component","constructor","arguments","onKeyDown","bind","bindContainer","getFocusableContext","getFocusableIndex","componentDidMount","container","addEventListener","onFocus","componentWillUnmount","removeEventListener","ref","forwardedRef","props","current","target","onlyBrowserTabstops","finder","focus","tabbable","focusable","focusables","find","index","directIndex","indexOf","event","cycle","eventToOffset","onNavigate","stopNavigationEvents","undefined","stopImmediatePropagation","targetRole","getAttribute","targetHasMenuItemRole","includes","isTab","code","preventDefault","context","ownerDocument","activeElement","nextIndex","length","render","children","restProps","forwardedNavigableContainer","displayName"],"mappings":";;;;;;;;;AAIA;;;;AACA;;AALA;;AACA;AACA;AACA;AAIA,MAAMA,IAAI,GAAG,MAAM,CAAE,CAArB;;AACA,MAAMC,eAAe,GAAG,CAAE,UAAF,EAAc,eAAd,EAA+B,kBAA/B,CAAxB;;AAEA,SAASC,UAAT,CAAqBC,KAArB,EAA4BC,KAA5B,EAAmCC,MAAnC,EAA4C;AAC3C,QAAMC,SAAS,GAAGH,KAAK,GAAGE,MAA1B;;AACA,MAAKC,SAAS,GAAG,CAAjB,EAAqB;AACpB,WAAOF,KAAK,GAAGE,SAAf;AACA,GAFD,MAEO,IAAKA,SAAS,IAAIF,KAAlB,EAA0B;AAChC,WAAOE,SAAS,GAAGF,KAAnB;AACA;;AAED,SAAOE,SAAP;AACA;;AAED,MAAMC,kBAAN,SAAiCC,kBAAjC,CAA2C;AAC1CC,EAAAA,WAAW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,2BAA2B,CAACC,WAA5B,GAA0C,oBAA1C;;eAEe,yBAAYD,2BAAZ,C","sourcesContent":["// @ts-nocheck\n/**\n * WordPress dependencies\n */\nimport { Component, forwardRef } from '@wordpress/element';\nimport { focus } from '@wordpress/dom';\n\nconst noop = () => {};\nconst MENU_ITEM_ROLES = [ 'menuitem', 'menuitemradio', 'menuitemcheckbox' ];\n\nfunction cycleValue( value, total, offset ) {\n\tconst nextValue = value + offset;\n\tif ( nextValue < 0 ) {\n\t\treturn total + nextValue;\n\t} else if ( nextValue >= total ) {\n\t\treturn nextValue - total;\n\t}\n\n\treturn nextValue;\n}\n\nclass NavigableContainer extends Component {\n\tconstructor() {\n\t\tsuper( ...arguments );\n\t\tthis.onKeyDown = this.onKeyDown.bind( this );\n\t\tthis.bindContainer = this.bindContainer.bind( this );\n\n\t\tthis.getFocusableContext = this.getFocusableContext.bind( this );\n\t\tthis.getFocusableIndex = this.getFocusableIndex.bind( this );\n\t}\n\n\tcomponentDidMount() {\n\t\t// We use DOM event listeners instead of React event listeners\n\t\t// because we want to catch events from the underlying DOM tree\n\t\t// The React Tree can be different from the DOM tree when using\n\t\t// portals. Block Toolbars for instance are rendered in a separate\n\t\t// React Trees.\n\t\tthis.container.addEventListener( 'keydown', this.onKeyDown );\n\t\tthis.container.addEventListener( 'focus', this.onFocus );\n\t}\n\n\tcomponentWillUnmount() {\n\t\tthis.container.removeEventListener( 'keydown', this.onKeyDown );\n\t\tthis.container.removeEventListener( 'focus', this.onFocus );\n\t}\n\n\tbindContainer( ref ) {\n\t\tconst { forwardedRef } = this.props;\n\t\tthis.container = ref;\n\n\t\tif ( typeof forwardedRef === 'function' ) {\n\t\t\tforwardedRef( ref );\n\t\t} else if ( forwardedRef && 'current' in forwardedRef ) {\n\t\t\tforwardedRef.current = ref;\n\t\t}\n\t}\n\n\tgetFocusableContext( target ) {\n\t\tconst { onlyBrowserTabstops } = this.props;\n\t\tconst finder = onlyBrowserTabstops ? focus.tabbable : focus.focusable;\n\t\tconst focusables = finder.find( this.container );\n\n\t\tconst index = this.getFocusableIndex( focusables, target );\n\t\tif ( index > -1 && target ) {\n\t\t\treturn { index, target, focusables };\n\t\t}\n\t\treturn null;\n\t}\n\n\tgetFocusableIndex( focusables, target ) {\n\t\tconst directIndex = focusables.indexOf( target );\n\t\tif ( directIndex !== -1 ) {\n\t\t\treturn directIndex;\n\t\t}\n\t}\n\n\tonKeyDown( event ) {\n\t\tif ( this.props.onKeyDown ) {\n\t\t\tthis.props.onKeyDown( event );\n\t\t}\n\n\t\tconst { getFocusableContext } = this;\n\t\tconst {\n\t\t\tcycle = true,\n\t\t\teventToOffset,\n\t\t\tonNavigate = noop,\n\t\t\tstopNavigationEvents,\n\t\t} = this.props;\n\n\t\tconst offset = eventToOffset( event );\n\n\t\t// eventToOffset returns undefined if the event is not handled by the component.\n\t\tif ( offset !== undefined && stopNavigationEvents ) {\n\t\t\t// Prevents arrow key handlers bound to the document directly interfering.\n\t\t\tevent.stopImmediatePropagation();\n\n\t\t\t// When navigating a collection of items, prevent scroll containers\n\t\t\t// from scrolling. The preventDefault also prevents Voiceover from\n\t\t\t// 'handling' the event, as voiceover will try to use arrow keys\n\t\t\t// for highlighting text.\n\t\t\tconst targetRole = event.target.getAttribute( 'role' );\n\t\t\tconst targetHasMenuItemRole =\n\t\t\t\tMENU_ITEM_ROLES.includes( targetRole );\n\n\t\t\t// `preventDefault()` on tab to avoid having the browser move the focus\n\t\t\t// after this component has already moved it.\n\t\t\tconst isTab = event.code === 'Tab';\n\n\t\t\tif ( targetHasMenuItemRole || isTab ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t}\n\t\t}\n\n\t\tif ( ! offset ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst context = getFocusableContext(\n\t\t\tevent.target.ownerDocument.activeElement\n\t\t);\n\t\tif ( ! context ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { index, focusables } = context;\n\t\tconst nextIndex = cycle\n\t\t\t? cycleValue( index, focusables.length, offset )\n\t\t\t: index + offset;\n\t\tif ( nextIndex >= 0 && nextIndex < focusables.length ) {\n\t\t\tfocusables[ nextIndex ].focus();\n\t\t\tonNavigate( nextIndex, focusables[ nextIndex ] );\n\t\t}\n\t}\n\n\trender() {\n\t\tconst {\n\t\t\tchildren,\n\t\t\tstopNavigationEvents,\n\t\t\teventToOffset,\n\t\t\tonNavigate,\n\t\t\tonKeyDown,\n\t\t\tcycle,\n\t\t\tonlyBrowserTabstops,\n\t\t\tforwardedRef,\n\t\t\t...restProps\n\t\t} = this.props;\n\t\treturn (\n\t\t\t<div ref={ this.bindContainer } { ...restProps }>\n\t\t\t\t{ children }\n\t\t\t</div>\n\t\t);\n\t}\n}\n\nconst forwardedNavigableContainer = ( props, ref ) => {\n\treturn <NavigableContainer { ...props } forwardedRef={ ref } />;\n};\nforwardedNavigableContainer.displayName = 'NavigableContainer';\n\nexport default forwardRef( forwardedNavigableContainer );\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/components/src/navigable-container/container.tsx"],"names":["noop","MENU_ITEM_ROLES","cycleValue","value","total","offset","nextValue","NavigableContainer","Component","constructor","args","onKeyDown","bind","bindContainer","getFocusableContext","getFocusableIndex","componentDidMount","container","addEventListener","componentWillUnmount","removeEventListener","ref","forwardedRef","props","current","target","onlyBrowserTabstops","finder","focus","tabbable","focusable","focusables","find","index","indexOf","event","cycle","eventToOffset","onNavigate","stopNavigationEvents","undefined","stopImmediatePropagation","targetRole","getAttribute","targetHasMenuItemRole","includes","preventDefault","activeElement","ownerDocument","context","nextIndex","length","code","render","children","restProps","forwardedNavigableContainer","displayName"],"mappings":";;;;;;;;;AAQA;;;;AACA;;AATA;AACA;AACA;;AAGA;AACA;AACA;AASA,MAAMA,IAAI,GAAG,MAAM,CAAE,CAArB;;AACA,MAAMC,eAAe,GAAG,CAAE,UAAF,EAAc,eAAd,EAA+B,kBAA/B,CAAxB;;AAEA,SAASC,UAAT,CAAqBC,KAArB,EAAoCC,KAApC,EAAmDC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AAELf,MAAAA,oBAFK;AAGLF,MAAAA,aAHK;AAILC,MAAAA,UAJK;AAKL3B,MAAAA,SALK;AAMLyB,MAAAA,KANK;AAOLV,MAAAA,mBAPK;AAQLJ,MAAAA,YARK;AASL,SAAGiC;AATE,QAUF,KAAKhC,KAVT;AAWA,WACC;AAAK,MAAA,GAAG,EAAG,KAAKV;AAAhB,OAAqC0C,SAArC,GACGD,QADH,CADD;AAKA;;AApJoE;;AAuJtE,MAAME,2BAA2B,GAAG,CACnCjC,KADmC,EAEnCF,GAFmC,KAG/B;AACJ,SAAO,4BAAC,kBAAD,6BAAyBE,KAAzB;AAAiC,IAAA,YAAY,EAAGF;AAAhD,KAAP;AACA,CALD;;AAMAmC,2BAA2B,CAACC,WAA5B,GAA0C,oBAA1C;;eAEe,yBAAYD,2BAAZ,C","sourcesContent":["/**\n * External dependencies\n */\nimport type { ForwardedRef } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { Component, forwardRef } from '@wordpress/element';\nimport { focus } from '@wordpress/dom';\n\n/**\n * Internal dependencies\n */\nimport type { NavigableContainerProps } from './types';\n\nconst noop = () => {};\nconst MENU_ITEM_ROLES = [ 'menuitem', 'menuitemradio', 'menuitemcheckbox' ];\n\nfunction cycleValue( value: number, total: number, offset: number ) {\n\tconst nextValue = value + offset;\n\tif ( nextValue < 0 ) {\n\t\treturn total + nextValue;\n\t} else if ( nextValue >= total ) {\n\t\treturn nextValue - total;\n\t}\n\n\treturn nextValue;\n}\n\nclass NavigableContainer extends Component< NavigableContainerProps > {\n\tcontainer?: HTMLDivElement;\n\n\tconstructor( args: NavigableContainerProps ) {\n\t\tsuper( args );\n\t\tthis.onKeyDown = this.onKeyDown.bind( this );\n\t\tthis.bindContainer = this.bindContainer.bind( this );\n\n\t\tthis.getFocusableContext = this.getFocusableContext.bind( this );\n\t\tthis.getFocusableIndex = this.getFocusableIndex.bind( this );\n\t}\n\n\tcomponentDidMount() {\n\t\tif ( ! this.container ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// We use DOM event listeners instead of React event listeners\n\t\t// because we want to catch events from the underlying DOM tree\n\t\t// The React Tree can be different from the DOM tree when using\n\t\t// portals. Block Toolbars for instance are rendered in a separate\n\t\t// React Trees.\n\t\tthis.container.addEventListener( 'keydown', this.onKeyDown );\n\t}\n\n\tcomponentWillUnmount() {\n\t\tif ( ! this.container ) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.container.removeEventListener( 'keydown', this.onKeyDown );\n\t}\n\n\tbindContainer( ref: HTMLDivElement ) {\n\t\tconst { forwardedRef } = this.props;\n\t\tthis.container = ref;\n\n\t\tif ( typeof forwardedRef === 'function' ) {\n\t\t\tforwardedRef( ref );\n\t\t} else if ( forwardedRef && 'current' in forwardedRef ) {\n\t\t\tforwardedRef.current = ref;\n\t\t}\n\t}\n\n\tgetFocusableContext( target: Element ) {\n\t\tif ( ! this.container ) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst { onlyBrowserTabstops } = this.props;\n\t\tconst finder = onlyBrowserTabstops ? focus.tabbable : focus.focusable;\n\t\tconst focusables = finder.find( this.container ) as HTMLElement[];\n\n\t\tconst index = this.getFocusableIndex( focusables, target );\n\t\tif ( index > -1 && target ) {\n\t\t\treturn { index, target, focusables };\n\t\t}\n\t\treturn null;\n\t}\n\n\tgetFocusableIndex( focusables: Element[], target: Element ) {\n\t\treturn focusables.indexOf( target );\n\t}\n\n\tonKeyDown( event: KeyboardEvent ) {\n\t\tif ( this.props.onKeyDown ) {\n\t\t\tthis.props.onKeyDown( event );\n\t\t}\n\n\t\tconst { getFocusableContext } = this;\n\t\tconst {\n\t\t\tcycle = true,\n\t\t\teventToOffset,\n\t\t\tonNavigate = noop,\n\t\t\tstopNavigationEvents,\n\t\t} = this.props;\n\n\t\tconst offset = eventToOffset( event );\n\n\t\t// eventToOffset returns undefined if the event is not handled by the component.\n\t\tif ( offset !== undefined && stopNavigationEvents ) {\n\t\t\t// Prevents arrow key handlers bound to the document directly interfering.\n\t\t\tevent.stopImmediatePropagation();\n\n\t\t\t// When navigating a collection of items, prevent scroll containers\n\t\t\t// from scrolling. The preventDefault also prevents Voiceover from\n\t\t\t// 'handling' the event, as voiceover will try to use arrow keys\n\t\t\t// for highlighting text.\n\t\t\tconst targetRole = (\n\t\t\t\tevent.target as HTMLDivElement | null\n\t\t\t )?.getAttribute( 'role' );\n\t\t\tconst targetHasMenuItemRole =\n\t\t\t\t!! targetRole && MENU_ITEM_ROLES.includes( targetRole );\n\n\t\t\tif ( targetHasMenuItemRole ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t}\n\t\t}\n\n\t\tif ( ! offset ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst activeElement = ( event.target as HTMLElement | null )\n\t\t\t?.ownerDocument?.activeElement;\n\t\tif ( ! activeElement ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst context = getFocusableContext( activeElement );\n\t\tif ( ! context ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { index, focusables } = context;\n\t\tconst nextIndex = cycle\n\t\t\t? cycleValue( index, focusables.length, offset )\n\t\t\t: index + offset;\n\n\t\tif ( nextIndex >= 0 && nextIndex < focusables.length ) {\n\t\t\tfocusables[ nextIndex ].focus();\n\t\t\tonNavigate( nextIndex, focusables[ nextIndex ] );\n\n\t\t\t// `preventDefault()` on tab to avoid having the browser move the focus\n\t\t\t// after this component has already moved it.\n\t\t\tif ( event.code === 'Tab' ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t}\n\t\t}\n\t}\n\n\trender() {\n\t\tconst {\n\t\t\tchildren,\n\t\t\tstopNavigationEvents,\n\t\t\teventToOffset,\n\t\t\tonNavigate,\n\t\t\tonKeyDown,\n\t\t\tcycle,\n\t\t\tonlyBrowserTabstops,\n\t\t\tforwardedRef,\n\t\t\t...restProps\n\t\t} = this.props;\n\t\treturn (\n\t\t\t<div ref={ this.bindContainer } { ...restProps }>\n\t\t\t\t{ children }\n\t\t\t</div>\n\t\t);\n\t}\n}\n\nconst forwardedNavigableContainer = (\n\tprops: NavigableContainerProps,\n\tref: ForwardedRef< HTMLDivElement >\n) => {\n\treturn <NavigableContainer { ...props } forwardedRef={ ref } />;\n};\nforwardedNavigableContainer.displayName = 'NavigableContainer';\n\nexport default forwardRef( forwardedNavigableContainer );\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/components/src/navigable-container/index.
|
|
1
|
+
{"version":3,"sources":["@wordpress/components/src/navigable-container/index.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAGA;;AACA","sourcesContent":["/**\n * Internal Dependencies\n */\nexport { default as NavigableMenu } from './menu';\nexport { default as TabbableContainer } from './tabbable';\n"]}
|
|
@@ -5,7 +5,8 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.NavigableMenu =
|
|
8
|
+
exports.NavigableMenu = void 0;
|
|
9
|
+
exports.UnforwardedNavigableMenu = UnforwardedNavigableMenu;
|
|
9
10
|
exports.default = void 0;
|
|
10
11
|
|
|
11
12
|
var _element = require("@wordpress/element");
|
|
@@ -14,7 +15,9 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
|
|
|
14
15
|
|
|
15
16
|
var _container = _interopRequireDefault(require("./container"));
|
|
16
17
|
|
|
17
|
-
|
|
18
|
+
/**
|
|
19
|
+
* External dependencies
|
|
20
|
+
*/
|
|
18
21
|
|
|
19
22
|
/**
|
|
20
23
|
* WordPress dependencies
|
|
@@ -23,7 +26,7 @@ var _container = _interopRequireDefault(require("./container"));
|
|
|
23
26
|
/**
|
|
24
27
|
* Internal dependencies
|
|
25
28
|
*/
|
|
26
|
-
function
|
|
29
|
+
function UnforwardedNavigableMenu(_ref, ref) {
|
|
27
30
|
let {
|
|
28
31
|
role = 'menu',
|
|
29
32
|
orientation = 'vertical',
|
|
@@ -57,6 +60,8 @@ function NavigableMenu(_ref, ref) {
|
|
|
57
60
|
// in an offset.
|
|
58
61
|
return 0;
|
|
59
62
|
}
|
|
63
|
+
|
|
64
|
+
return undefined;
|
|
60
65
|
};
|
|
61
66
|
|
|
62
67
|
return (0, _element.createElement)(_container.default, (0, _extends2.default)({
|
|
@@ -64,12 +69,39 @@ function NavigableMenu(_ref, ref) {
|
|
|
64
69
|
stopNavigationEvents: true,
|
|
65
70
|
onlyBrowserTabstops: false,
|
|
66
71
|
role: role,
|
|
67
|
-
"aria-orientation": role
|
|
72
|
+
"aria-orientation": role !== 'presentation' && (orientation === 'vertical' || orientation === 'horizontal') ? orientation : undefined,
|
|
68
73
|
eventToOffset: eventToOffset
|
|
69
74
|
}, rest));
|
|
70
75
|
}
|
|
76
|
+
/**
|
|
77
|
+
* A container for a navigable menu.
|
|
78
|
+
*
|
|
79
|
+
* ```jsx
|
|
80
|
+
* import {
|
|
81
|
+
* NavigableMenu,
|
|
82
|
+
* Button,
|
|
83
|
+
* } from '@wordpress/components';
|
|
84
|
+
*
|
|
85
|
+
* function onNavigate( index, target ) {
|
|
86
|
+
* console.log( `Navigates to ${ index }`, target );
|
|
87
|
+
* }
|
|
88
|
+
*
|
|
89
|
+
* const MyNavigableContainer = () => (
|
|
90
|
+
* <div>
|
|
91
|
+
* <span>Navigable Menu:</span>
|
|
92
|
+
* <NavigableMenu onNavigate={ onNavigate } orientation="horizontal">
|
|
93
|
+
* <Button variant="secondary">Item 1</Button>
|
|
94
|
+
* <Button variant="secondary">Item 2</Button>
|
|
95
|
+
* <Button variant="secondary">Item 3</Button>
|
|
96
|
+
* </NavigableMenu>
|
|
97
|
+
* </div>
|
|
98
|
+
* );
|
|
99
|
+
* ```
|
|
100
|
+
*/
|
|
71
101
|
|
|
72
|
-
var _default = (0, _element.forwardRef)(NavigableMenu);
|
|
73
102
|
|
|
103
|
+
const NavigableMenu = (0, _element.forwardRef)(UnforwardedNavigableMenu);
|
|
104
|
+
exports.NavigableMenu = NavigableMenu;
|
|
105
|
+
var _default = NavigableMenu;
|
|
74
106
|
exports.default = _default;
|
|
75
107
|
//# sourceMappingURL=menu.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/components/src/navigable-container/menu.
|
|
1
|
+
{"version":3,"sources":["@wordpress/components/src/navigable-container/menu.tsx"],"names":["UnforwardedNavigableMenu","ref","role","orientation","rest","eventToOffset","evt","code","next","previous","includes","undefined","NavigableMenu"],"mappings":";;;;;;;;;;;AAQA;;;;AAKA;;AAbA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;AAIO,SAASA,wBAAT,OAENC,GAFM,EAGL;AAAA,MAFD;AAAEC,IAAAA,IAAI,GAAG,MAAT;AAAiBC,IAAAA,WAAW,GAAG,UAA/B;AAA2C,OAAGC;AAA9C,GAEC;;AACD,QAAMC,aAAa,GAAKC,GAAF,IAA0B;AAC/C,UAAM;AAAEC,MAAAA;AAAF,QAAWD,GAAjB;AAEA,QAAIE,IAAI,GAAG,CAAE,WAAF,CAAX;AACA,QAAIC,QAAQ,GAAG,CAAE,SAAF,CAAf;;AAEA,QAAKN,WAAW,KAAK,YAArB,EAAoC;AACnCK,MAAAA,IAAI,GAAG,CAAE,YAAF,CAAP;AACAC,MAAAA,QAAQ,GAAG,CAAE,WAAF,CAAX;AACA;;AAED,QAAKN,WAAW,KAAK,MAArB,EAA8B;AAC7BK,MAAAA,IAAI,GAAG,CAAE,YAAF,EAAgB,WAAhB,CAAP;AACAC,MAAAA,QAAQ,GAAG,CAAE,WAAF,EAAe,SAAf,CAAX;AACA;;AAED,QAAKD,IAAI,CAACE,QAAL,CAAeH,IAAf,CAAL,EAA6B;AAC5B,aAAO,CAAP;AACA,KAFD,MAEO,IAAKE,QAAQ,CAACC,QAAT,CAAmBH,IAAnB,CAAL,EAAiC;AACvC,aAAO,CAAC,CAAR;AACA,KAFM,MAEA,IACN,CAAE,WAAF,EAAe,SAAf,EAA0B,WAA1B,EAAuC,YAAvC,EAAsDG,QAAtD,CACCH,IADD,CADM,EAIL;AACD;AACA;AACA;AACA,aAAO,CAAP;AACA;;AAED,WAAOI,SAAP;AACA,GAhCD;;AAkCA,SACC,4BAAC,kBAAD;AACC,IAAA,GAAG,EAAGV,GADP;AAEC,IAAA,oBAAoB,MAFrB;AAGC,IAAA,mBAAmB,EAAG,KAHvB;AAIC,IAAA,IAAI,EAAGC,IAJR;AAKC,wBACCA,IAAI,KAAK,cAAT,KACEC,WAAW,KAAK,UAAhB,IAA8BA,WAAW,KAAK,YADhD,IAEGA,WAFH,GAGGQ,SATL;AAWC,IAAA,aAAa,EAAGN;AAXjB,KAYMD,IAZN,EADD;AAgBA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,MAAMQ,aAAa,GAAG,yBAAYZ,wBAAZ,CAAtB;;eAEQY,a","sourcesContent":["/**\n * External dependencies\n */\nimport type { ForwardedRef } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { forwardRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport NavigableContainer from './container';\nimport type { NavigableMenuProps } from './types';\n\nexport function UnforwardedNavigableMenu(\n\t{ role = 'menu', orientation = 'vertical', ...rest }: NavigableMenuProps,\n\tref: ForwardedRef< any >\n) {\n\tconst eventToOffset = ( evt: KeyboardEvent ) => {\n\t\tconst { code } = evt;\n\n\t\tlet next = [ 'ArrowDown' ];\n\t\tlet previous = [ 'ArrowUp' ];\n\n\t\tif ( orientation === 'horizontal' ) {\n\t\t\tnext = [ 'ArrowRight' ];\n\t\t\tprevious = [ 'ArrowLeft' ];\n\t\t}\n\n\t\tif ( orientation === 'both' ) {\n\t\t\tnext = [ 'ArrowRight', 'ArrowDown' ];\n\t\t\tprevious = [ 'ArrowLeft', 'ArrowUp' ];\n\t\t}\n\n\t\tif ( next.includes( code ) ) {\n\t\t\treturn 1;\n\t\t} else if ( previous.includes( code ) ) {\n\t\t\treturn -1;\n\t\t} else if (\n\t\t\t[ 'ArrowDown', 'ArrowUp', 'ArrowLeft', 'ArrowRight' ].includes(\n\t\t\t\tcode\n\t\t\t)\n\t\t) {\n\t\t\t// Key press should be handled, e.g. have event propagation and\n\t\t\t// default behavior handled by NavigableContainer but not result\n\t\t\t// in an offset.\n\t\t\treturn 0;\n\t\t}\n\n\t\treturn undefined;\n\t};\n\n\treturn (\n\t\t<NavigableContainer\n\t\t\tref={ ref }\n\t\t\tstopNavigationEvents\n\t\t\tonlyBrowserTabstops={ false }\n\t\t\trole={ role }\n\t\t\taria-orientation={\n\t\t\t\trole !== 'presentation' &&\n\t\t\t\t( orientation === 'vertical' || orientation === 'horizontal' )\n\t\t\t\t\t? orientation\n\t\t\t\t\t: undefined\n\t\t\t}\n\t\t\teventToOffset={ eventToOffset }\n\t\t\t{ ...rest }\n\t\t/>\n\t);\n}\n\n/**\n * A container for a navigable menu.\n *\n * ```jsx\n * import {\n * NavigableMenu,\n * Button,\n * } from '@wordpress/components';\n *\n * function onNavigate( index, target ) {\n * console.log( `Navigates to ${ index }`, target );\n * }\n *\n * const MyNavigableContainer = () => (\n * <div>\n * <span>Navigable Menu:</span>\n * <NavigableMenu onNavigate={ onNavigate } orientation=\"horizontal\">\n * <Button variant=\"secondary\">Item 1</Button>\n * <Button variant=\"secondary\">Item 2</Button>\n * <Button variant=\"secondary\">Item 3</Button>\n * </NavigableMenu>\n * </div>\n * );\n * ```\n */\nexport const NavigableMenu = forwardRef( UnforwardedNavigableMenu );\n\nexport default NavigableMenu;\n"]}
|
|
@@ -5,7 +5,8 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.TabbableContainer =
|
|
8
|
+
exports.TabbableContainer = void 0;
|
|
9
|
+
exports.UnforwardedTabbableContainer = UnforwardedTabbableContainer;
|
|
9
10
|
exports.default = void 0;
|
|
10
11
|
|
|
11
12
|
var _element = require("@wordpress/element");
|
|
@@ -14,7 +15,9 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
|
|
|
14
15
|
|
|
15
16
|
var _container = _interopRequireDefault(require("./container"));
|
|
16
17
|
|
|
17
|
-
|
|
18
|
+
/**
|
|
19
|
+
* External dependencies
|
|
20
|
+
*/
|
|
18
21
|
|
|
19
22
|
/**
|
|
20
23
|
* WordPress dependencies
|
|
@@ -23,7 +26,7 @@ var _container = _interopRequireDefault(require("./container"));
|
|
|
23
26
|
/**
|
|
24
27
|
* Internal dependencies
|
|
25
28
|
*/
|
|
26
|
-
function
|
|
29
|
+
function UnforwardedTabbableContainer(_ref, ref) {
|
|
27
30
|
let {
|
|
28
31
|
eventToOffset,
|
|
29
32
|
...props
|
|
@@ -53,6 +56,8 @@ function TabbableContainer(_ref, ref) {
|
|
|
53
56
|
if (eventToOffset) {
|
|
54
57
|
return eventToOffset(evt);
|
|
55
58
|
}
|
|
59
|
+
|
|
60
|
+
return undefined;
|
|
56
61
|
};
|
|
57
62
|
|
|
58
63
|
return (0, _element.createElement)(_container.default, (0, _extends2.default)({
|
|
@@ -62,8 +67,44 @@ function TabbableContainer(_ref, ref) {
|
|
|
62
67
|
eventToOffset: innerEventToOffset
|
|
63
68
|
}, props));
|
|
64
69
|
}
|
|
70
|
+
/**
|
|
71
|
+
* A container for tabbable elements.
|
|
72
|
+
*
|
|
73
|
+
* ```jsx
|
|
74
|
+
* import {
|
|
75
|
+
* TabbableContainer,
|
|
76
|
+
* Button,
|
|
77
|
+
* } from '@wordpress/components';
|
|
78
|
+
*
|
|
79
|
+
* function onNavigate( index, target ) {
|
|
80
|
+
* console.log( `Navigates to ${ index }`, target );
|
|
81
|
+
* }
|
|
82
|
+
*
|
|
83
|
+
* const MyTabbableContainer = () => (
|
|
84
|
+
* <div>
|
|
85
|
+
* <span>Tabbable Container:</span>
|
|
86
|
+
* <TabbableContainer onNavigate={ onNavigate }>
|
|
87
|
+
* <Button variant="secondary" tabIndex="0">
|
|
88
|
+
* Section 1
|
|
89
|
+
* </Button>
|
|
90
|
+
* <Button variant="secondary" tabIndex="0">
|
|
91
|
+
* Section 2
|
|
92
|
+
* </Button>
|
|
93
|
+
* <Button variant="secondary" tabIndex="0">
|
|
94
|
+
* Section 3
|
|
95
|
+
* </Button>
|
|
96
|
+
* <Button variant="secondary" tabIndex="0">
|
|
97
|
+
* Section 4
|
|
98
|
+
* </Button>
|
|
99
|
+
* </TabbableContainer>
|
|
100
|
+
* </div>
|
|
101
|
+
* );
|
|
102
|
+
* ```
|
|
103
|
+
*/
|
|
65
104
|
|
|
66
|
-
var _default = (0, _element.forwardRef)(TabbableContainer);
|
|
67
105
|
|
|
106
|
+
const TabbableContainer = (0, _element.forwardRef)(UnforwardedTabbableContainer);
|
|
107
|
+
exports.TabbableContainer = TabbableContainer;
|
|
108
|
+
var _default = TabbableContainer;
|
|
68
109
|
exports.default = _default;
|
|
69
110
|
//# sourceMappingURL=tabbable.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/components/src/navigable-container/tabbable.
|
|
1
|
+
{"version":3,"sources":["@wordpress/components/src/navigable-container/tabbable.tsx"],"names":["UnforwardedTabbableContainer","ref","eventToOffset","props","innerEventToOffset","evt","code","shiftKey","undefined","TabbableContainer"],"mappings":";;;;;;;;;;;AAQA;;;;AAKA;;AAbA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;AAIO,SAASA,4BAAT,OAENC,GAFM,EAGL;AAAA,MAFD;AAAEC,IAAAA,aAAF;AAAiB,OAAGC;AAApB,GAEC;;AACD,QAAMC,kBAAkB,GAAKC,GAAF,IAA0B;AACpD,UAAM;AAAEC,MAAAA,IAAF;AAAQC,MAAAA;AAAR,QAAqBF,GAA3B;;AACA,QAAK,UAAUC,IAAf,EAAsB;AACrB,aAAOC,QAAQ,GAAG,CAAC,CAAJ,GAAQ,CAAvB;AACA,KAJmD,CAMpD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,QAAKL,aAAL,EAAqB;AACpB,aAAOA,aAAa,CAAEG,GAAF,CAApB;AACA;;AAED,WAAOG,SAAP;AACA,GAtBD;;AAwBA,SACC,4BAAC,kBAAD;AACC,IAAA,GAAG,EAAGP,GADP;AAEC,IAAA,oBAAoB,MAFrB;AAGC,IAAA,mBAAmB,MAHpB;AAIC,IAAA,aAAa,EAAGG;AAJjB,KAKMD,KALN,EADD;AASA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,MAAMM,iBAAiB,GAAG,yBAAYT,4BAAZ,CAA1B;;eAEQS,iB","sourcesContent":["/**\n * External dependencies\n */\nimport type { ForwardedRef } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { forwardRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport NavigableContainer from './container';\nimport type { TabbableContainerProps } from './types';\n\nexport function UnforwardedTabbableContainer(\n\t{ eventToOffset, ...props }: TabbableContainerProps,\n\tref: ForwardedRef< any >\n) {\n\tconst innerEventToOffset = ( evt: KeyboardEvent ) => {\n\t\tconst { code, shiftKey } = evt;\n\t\tif ( 'Tab' === code ) {\n\t\t\treturn shiftKey ? -1 : 1;\n\t\t}\n\n\t\t// Allow custom handling of keys besides Tab.\n\t\t//\n\t\t// By default, TabbableContainer will move focus forward on Tab and\n\t\t// backward on Shift+Tab. The handler below will be used for all other\n\t\t// events. The semantics for `eventToOffset`'s return\n\t\t// values are the following:\n\t\t//\n\t\t// - +1: move focus forward\n\t\t// - -1: move focus backward\n\t\t// - 0: don't move focus, but acknowledge event and thus stop it\n\t\t// - undefined: do nothing, let the event propagate.\n\t\tif ( eventToOffset ) {\n\t\t\treturn eventToOffset( evt );\n\t\t}\n\n\t\treturn undefined;\n\t};\n\n\treturn (\n\t\t<NavigableContainer\n\t\t\tref={ ref }\n\t\t\tstopNavigationEvents\n\t\t\tonlyBrowserTabstops\n\t\t\teventToOffset={ innerEventToOffset }\n\t\t\t{ ...props }\n\t\t/>\n\t);\n}\n\n/**\n * A container for tabbable elements.\n *\n * ```jsx\n * import {\n * TabbableContainer,\n * Button,\n * } from '@wordpress/components';\n *\n * function onNavigate( index, target ) {\n * console.log( `Navigates to ${ index }`, target );\n * }\n *\n * const MyTabbableContainer = () => (\n * <div>\n * <span>Tabbable Container:</span>\n * <TabbableContainer onNavigate={ onNavigate }>\n * <Button variant=\"secondary\" tabIndex=\"0\">\n * Section 1\n * </Button>\n * <Button variant=\"secondary\" tabIndex=\"0\">\n * Section 2\n * </Button>\n * <Button variant=\"secondary\" tabIndex=\"0\">\n * Section 3\n * </Button>\n * <Button variant=\"secondary\" tabIndex=\"0\">\n * Section 4\n * </Button>\n * </TabbableContainer>\n * </div>\n * );\n * ```\n */\nexport const TabbableContainer = forwardRef( UnforwardedTabbableContainer );\n\nexport default TabbableContainer;\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
|