@wordpress/components 19.4.0 → 19.5.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 +16 -1
- package/CONTRIBUTING.md +69 -2
- package/build/box-control/unit-control.js +2 -2
- package/build/box-control/unit-control.js.map +1 -1
- package/build/card/card/component.js +2 -2
- package/build/card/card/component.js.map +1 -1
- package/build/card/card-body/component.js +1 -1
- package/build/card/card-body/component.js.map +1 -1
- package/build/card/card-divider/component.js +1 -1
- package/build/card/card-divider/component.js.map +1 -1
- package/build/card/card-footer/component.js +1 -1
- package/build/card/card-footer/component.js.map +1 -1
- package/build/card/card-header/component.js +1 -1
- package/build/card/card-header/component.js.map +1 -1
- package/build/card/card-media/component.js +1 -1
- package/build/card/card-media/component.js.map +1 -1
- package/build/color-palette/index.native.js +35 -30
- package/build/color-palette/index.native.js.map +1 -1
- package/build/color-picker/component.js.map +1 -1
- package/build/color-picker/hex-input.js +6 -9
- package/build/color-picker/hex-input.js.map +1 -1
- package/build/confirm-dialog/component.js.map +1 -1
- package/build/divider/component.js.map +1 -1
- package/build/elevation/component.js +1 -1
- package/build/elevation/component.js.map +1 -1
- package/build/flex/flex/component.js +1 -1
- package/build/flex/flex/component.js.map +1 -1
- package/build/flex/flex-block/component.js +1 -1
- package/build/flex/flex-block/component.js.map +1 -1
- package/build/flex/flex-item/component.js +1 -1
- package/build/flex/flex-item/component.js.map +1 -1
- package/build/flyout/flyout/component.js +1 -1
- package/build/flyout/flyout/component.js.map +1 -1
- package/build/flyout/flyout-content/component.js +1 -1
- package/build/flyout/flyout-content/component.js.map +1 -1
- package/build/focal-point-picker/index.js +18 -12
- package/build/focal-point-picker/index.js.map +1 -1
- package/build/font-size-picker/index.js +0 -1
- package/build/font-size-picker/index.js.map +1 -1
- package/build/grid/component.js +1 -1
- package/build/grid/component.js.map +1 -1
- package/build/h-stack/component.js +1 -1
- package/build/h-stack/component.js.map +1 -1
- package/build/heading/component.js.map +1 -1
- package/build/index.js +12 -0
- package/build/index.js.map +1 -1
- package/build/index.native.js +15 -1
- package/build/index.native.js.map +1 -1
- package/build/input-control/index.js.map +1 -1
- package/build/input-control/input-base.js.map +1 -1
- package/build/input-control/input-field.js +7 -7
- package/build/input-control/input-field.js.map +1 -1
- package/build/input-control/reducer/reducer.js +3 -0
- package/build/input-control/reducer/reducer.js.map +1 -1
- package/build/item-group/item/component.js.map +1 -1
- package/build/item-group/item-group/component.js.map +1 -1
- package/build/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js +1 -1
- package/build/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js.map +1 -1
- package/build/mobile/color-settings/palette.screen.native.js +26 -9
- package/build/mobile/color-settings/palette.screen.native.js.map +1 -1
- package/build/mobile/global-styles-context/utils.native.js +63 -9
- package/build/mobile/global-styles-context/utils.native.js.map +1 -1
- package/build/mobile/inserter-button/index.native.js +3 -3
- package/build/mobile/inserter-button/index.native.js.map +1 -1
- package/build/mobile/inserter-button/sparkles.js +25 -0
- package/build/mobile/inserter-button/sparkles.js.map +1 -0
- package/build/navigator/index.js +16 -0
- package/build/navigator/index.js.map +1 -1
- package/build/navigator/navigator-back-button/component.js +72 -0
- package/build/navigator/navigator-back-button/component.js.map +1 -0
- package/build/navigator/navigator-back-button/hook.js +49 -0
- package/build/navigator/navigator-back-button/hook.js.map +1 -0
- package/build/navigator/navigator-back-button/index.js +16 -0
- package/build/navigator/navigator-back-button/index.js.map +1 -0
- package/build/navigator/navigator-button/component.js +71 -0
- package/build/navigator/navigator-button/component.js.map +1 -0
- package/build/navigator/navigator-button/hook.js +59 -0
- package/build/navigator/navigator-button/hook.js.map +1 -0
- package/build/navigator/navigator-button/index.js +16 -0
- package/build/navigator/navigator-button/index.js.map +1 -0
- package/build/navigator/navigator-provider/component.js +11 -21
- package/build/navigator/navigator-provider/component.js.map +1 -1
- package/build/navigator/navigator-screen/component.js +14 -22
- package/build/navigator/navigator-screen/component.js.map +1 -1
- package/build/resizable-box/index.js.map +1 -1
- package/build/resizable-box/resize-tooltip/index.js.map +1 -1
- package/build/resizable-box/resize-tooltip/label.js.map +1 -1
- package/build/scrollable/component.js +1 -1
- package/build/scrollable/component.js.map +1 -1
- package/build/select-control/index.js.map +1 -1
- package/build/spacer/component.js.map +1 -1
- package/build/surface/component.js +1 -1
- package/build/surface/component.js.map +1 -1
- package/build/text/component.js +1 -1
- package/build/text/component.js.map +1 -1
- package/build/text-control/index.js +2 -2
- package/build/text-control/index.js.map +1 -1
- package/build/toggle-group-control/toggle-group-control/component.js.map +1 -1
- package/build/toggle-group-control/toggle-group-control-option/component.js.map +1 -1
- package/build/tools-panel/tools-panel/component.js.map +1 -1
- package/build/tools-panel/tools-panel-header/component.js.map +1 -1
- package/build/tools-panel/tools-panel-item/component.js.map +1 -1
- package/build/tree-grid/index.js +50 -6
- package/build/tree-grid/index.js.map +1 -1
- package/build/truncate/component.js +1 -1
- package/build/truncate/component.js.map +1 -1
- package/build/ui/control-group/component.js +1 -1
- package/build/ui/control-group/component.js.map +1 -1
- package/build/ui/control-label/component.js +1 -1
- package/build/ui/control-label/component.js.map +1 -1
- package/build/ui/form-group/form-group.js +1 -1
- package/build/ui/form-group/form-group.js.map +1 -1
- package/build/ui/shortcut/component.js.map +1 -1
- package/build/ui/spinner/component.js +1 -1
- package/build/ui/spinner/component.js.map +1 -1
- package/build/ui/tooltip/component.js +1 -1
- package/build/ui/tooltip/component.js.map +1 -1
- package/build/ui/tooltip/content.js +1 -1
- package/build/ui/tooltip/content.js.map +1 -1
- package/build/unit-control/index.js.map +1 -1
- package/build/v-stack/component.js +1 -1
- package/build/v-stack/component.js.map +1 -1
- package/build/visually-hidden/component.js +1 -1
- package/build/visually-hidden/component.js.map +1 -1
- package/build/z-stack/component.js.map +1 -1
- package/build-module/box-control/unit-control.js +1 -1
- package/build-module/box-control/unit-control.js.map +1 -1
- package/build-module/card/card/component.js +2 -2
- package/build-module/card/card/component.js.map +1 -1
- package/build-module/card/card-body/component.js +1 -1
- package/build-module/card/card-body/component.js.map +1 -1
- package/build-module/card/card-divider/component.js +1 -1
- package/build-module/card/card-divider/component.js.map +1 -1
- package/build-module/card/card-footer/component.js +1 -1
- package/build-module/card/card-footer/component.js.map +1 -1
- package/build-module/card/card-header/component.js +1 -1
- package/build-module/card/card-header/component.js.map +1 -1
- package/build-module/card/card-media/component.js +1 -1
- package/build-module/card/card-media/component.js.map +1 -1
- package/build-module/color-palette/index.native.js +36 -31
- package/build-module/color-palette/index.native.js.map +1 -1
- package/build-module/color-picker/component.js.map +1 -1
- package/build-module/color-picker/hex-input.js +6 -9
- package/build-module/color-picker/hex-input.js.map +1 -1
- package/build-module/confirm-dialog/component.js.map +1 -1
- package/build-module/divider/component.js.map +1 -1
- package/build-module/elevation/component.js +1 -1
- package/build-module/elevation/component.js.map +1 -1
- package/build-module/flex/flex/component.js +1 -1
- package/build-module/flex/flex/component.js.map +1 -1
- package/build-module/flex/flex-block/component.js +1 -1
- package/build-module/flex/flex-block/component.js.map +1 -1
- package/build-module/flex/flex-item/component.js +1 -1
- package/build-module/flex/flex-item/component.js.map +1 -1
- package/build-module/flyout/flyout/component.js +1 -1
- package/build-module/flyout/flyout/component.js.map +1 -1
- package/build-module/flyout/flyout-content/component.js +1 -1
- package/build-module/flyout/flyout-content/component.js.map +1 -1
- package/build-module/focal-point-picker/index.js +18 -12
- package/build-module/focal-point-picker/index.js.map +1 -1
- package/build-module/font-size-picker/index.js +0 -1
- package/build-module/font-size-picker/index.js.map +1 -1
- package/build-module/grid/component.js +1 -1
- package/build-module/grid/component.js.map +1 -1
- package/build-module/h-stack/component.js +1 -1
- package/build-module/h-stack/component.js.map +1 -1
- package/build-module/heading/component.js.map +1 -1
- package/build-module/index.js +1 -1
- package/build-module/index.js.map +1 -1
- package/build-module/index.native.js +1 -1
- package/build-module/index.native.js.map +1 -1
- package/build-module/input-control/index.js.map +1 -1
- package/build-module/input-control/input-base.js.map +1 -1
- package/build-module/input-control/input-field.js +6 -6
- package/build-module/input-control/input-field.js.map +1 -1
- package/build-module/input-control/reducer/reducer.js +3 -0
- package/build-module/input-control/reducer/reducer.js.map +1 -1
- package/build-module/item-group/item/component.js.map +1 -1
- package/build-module/item-group/item-group/component.js.map +1 -1
- package/build-module/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js +1 -1
- package/build-module/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js.map +1 -1
- package/build-module/mobile/color-settings/palette.screen.native.js +27 -10
- package/build-module/mobile/color-settings/palette.screen.native.js.map +1 -1
- package/build-module/mobile/global-styles-context/utils.native.js +60 -10
- package/build-module/mobile/global-styles-context/utils.native.js.map +1 -1
- package/build-module/mobile/inserter-button/index.native.js +1 -1
- package/build-module/mobile/inserter-button/index.native.js.map +1 -1
- package/build-module/mobile/inserter-button/sparkles.js +16 -0
- package/build-module/mobile/inserter-button/sparkles.js.map +1 -0
- package/build-module/navigator/index.js +2 -0
- package/build-module/navigator/index.js.map +1 -1
- package/build-module/navigator/navigator-back-button/component.js +59 -0
- package/build-module/navigator/navigator-back-button/component.js.map +1 -0
- package/build-module/navigator/navigator-back-button/hook.js +36 -0
- package/build-module/navigator/navigator-back-button/hook.js.map +1 -0
- package/build-module/navigator/navigator-back-button/index.js +2 -0
- package/build-module/navigator/navigator-back-button/index.js.map +1 -0
- package/build-module/navigator/navigator-button/component.js +58 -0
- package/build-module/navigator/navigator-button/component.js.map +1 -0
- package/build-module/navigator/navigator-button/hook.js +46 -0
- package/build-module/navigator/navigator-button/hook.js.map +1 -0
- package/build-module/navigator/navigator-button/index.js +2 -0
- package/build-module/navigator/navigator-button/index.js.map +1 -0
- package/build-module/navigator/navigator-provider/component.js +11 -21
- package/build-module/navigator/navigator-provider/component.js.map +1 -1
- package/build-module/navigator/navigator-screen/component.js +13 -22
- package/build-module/navigator/navigator-screen/component.js.map +1 -1
- package/build-module/resizable-box/index.js.map +1 -1
- package/build-module/resizable-box/resize-tooltip/index.js.map +1 -1
- package/build-module/resizable-box/resize-tooltip/label.js.map +1 -1
- package/build-module/scrollable/component.js +1 -1
- package/build-module/scrollable/component.js.map +1 -1
- package/build-module/select-control/index.js +1 -1
- package/build-module/select-control/index.js.map +1 -1
- package/build-module/spacer/component.js.map +1 -1
- package/build-module/surface/component.js +1 -1
- package/build-module/surface/component.js.map +1 -1
- package/build-module/text/component.js +1 -1
- package/build-module/text/component.js.map +1 -1
- package/build-module/text-control/index.js +2 -2
- package/build-module/text-control/index.js.map +1 -1
- package/build-module/toggle-group-control/toggle-group-control/component.js.map +1 -1
- package/build-module/toggle-group-control/toggle-group-control-option/component.js.map +1 -1
- package/build-module/tools-panel/tools-panel/component.js.map +1 -1
- package/build-module/tools-panel/tools-panel-header/component.js.map +1 -1
- package/build-module/tools-panel/tools-panel-item/component.js.map +1 -1
- package/build-module/tree-grid/index.js +51 -7
- package/build-module/tree-grid/index.js.map +1 -1
- package/build-module/truncate/component.js +1 -1
- package/build-module/truncate/component.js.map +1 -1
- package/build-module/ui/control-group/component.js +1 -1
- package/build-module/ui/control-group/component.js.map +1 -1
- package/build-module/ui/control-label/component.js +1 -1
- package/build-module/ui/control-label/component.js.map +1 -1
- package/build-module/ui/form-group/form-group.js +1 -1
- package/build-module/ui/form-group/form-group.js.map +1 -1
- package/build-module/ui/shortcut/component.js.map +1 -1
- package/build-module/ui/spinner/component.js +1 -1
- package/build-module/ui/spinner/component.js.map +1 -1
- package/build-module/ui/tooltip/component.js +1 -1
- package/build-module/ui/tooltip/component.js.map +1 -1
- package/build-module/ui/tooltip/content.js +1 -1
- package/build-module/ui/tooltip/content.js.map +1 -1
- package/build-module/unit-control/index.js.map +1 -1
- package/build-module/v-stack/component.js +1 -1
- package/build-module/v-stack/component.js.map +1 -1
- package/build-module/visually-hidden/component.js +1 -1
- package/build-module/visually-hidden/component.js.map +1 -1
- package/build-module/z-stack/component.js.map +1 -1
- package/build-types/card/card-divider/hook.d.ts +0 -1
- package/build-types/card/card-divider/hook.d.ts.map +1 -1
- package/build-types/color-picker/styles.d.ts +2 -4
- package/build-types/color-picker/styles.d.ts.map +1 -1
- package/build-types/confirm-dialog/component.d.ts +2 -6
- package/build-types/confirm-dialog/component.d.ts.map +1 -1
- package/build-types/flyout/flyout/hook.d.ts +0 -1
- package/build-types/flyout/flyout/hook.d.ts.map +1 -1
- package/build-types/input-control/index.d.ts +3 -3
- package/build-types/input-control/index.d.ts.map +1 -1
- package/build-types/input-control/input-base.d.ts +2 -2
- package/build-types/input-control/input-base.d.ts.map +1 -1
- package/build-types/input-control/input-field.d.ts +1 -3
- package/build-types/input-control/input-field.d.ts.map +1 -1
- package/build-types/input-control/reducer/reducer.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/navigator/index.d.ts +2 -0
- package/build-types/navigator/index.d.ts.map +1 -1
- package/build-types/navigator/navigator-back-button/component.d.ts +38 -0
- package/build-types/navigator/navigator-back-button/component.d.ts.map +1 -0
- package/build-types/navigator/navigator-back-button/hook.d.ts +282 -0
- package/build-types/navigator/navigator-back-button/hook.d.ts.map +1 -0
- package/build-types/navigator/navigator-back-button/index.d.ts +2 -0
- package/build-types/navigator/navigator-back-button/index.d.ts.map +1 -0
- package/build-types/navigator/navigator-button/component.d.ts +37 -0
- package/build-types/navigator/navigator-button/component.d.ts.map +1 -0
- package/build-types/navigator/navigator-button/hook.d.ts +282 -0
- package/build-types/navigator/navigator-button/hook.d.ts.map +1 -0
- package/build-types/navigator/navigator-button/index.d.ts +2 -0
- package/build-types/navigator/navigator-button/index.d.ts.map +1 -0
- package/build-types/navigator/navigator-provider/component.d.ts +10 -20
- package/build-types/navigator/navigator-provider/component.d.ts.map +1 -1
- package/build-types/navigator/navigator-screen/component.d.ts +10 -20
- package/build-types/navigator/navigator-screen/component.d.ts.map +1 -1
- package/build-types/navigator/types.d.ts +21 -0
- package/build-types/navigator/types.d.ts.map +1 -1
- package/build-types/number-control/styles/number-control-styles.d.ts +1 -1
- package/build-types/resizable-box/index.d.ts +2 -2
- package/build-types/resizable-box/index.d.ts.map +1 -1
- package/build-types/resizable-box/resize-tooltip/index.d.ts.map +1 -1
- package/build-types/select-control/index.d.ts +1 -3
- package/build-types/select-control/index.d.ts.map +1 -1
- package/build-types/ui/context/wordpress-component.d.ts +2 -6
- package/build-types/ui/context/wordpress-component.d.ts.map +1 -1
- package/build-types/unit-control/index.d.ts +1 -3
- package/build-types/unit-control/index.d.ts.map +1 -1
- package/build-types/z-stack/component.d.ts.map +1 -1
- package/package.json +8 -7
- package/src/alignment-matrix-control/README.md +4 -0
- package/src/alignment-matrix-control/stories/index.js +1 -1
- package/src/base-control/stories/index.js +65 -22
- package/src/box-control/stories/index.js +4 -1
- package/src/box-control/unit-control.js +1 -1
- package/src/card/card/component.js +1 -1
- package/src/card/card-body/component.js +1 -1
- package/src/card/card-divider/component.js +1 -1
- package/src/card/card-footer/component.js +1 -1
- package/src/card/card-header/component.js +1 -1
- package/src/card/card-media/component.js +1 -1
- package/src/color-palette/index.native.js +92 -75
- package/src/color-palette/style.native.scss +10 -5
- package/src/color-picker/component.tsx +2 -2
- package/src/color-picker/hex-input.tsx +9 -9
- package/src/confirm-dialog/component.tsx +2 -2
- package/src/divider/component.tsx +2 -2
- package/src/elevation/component.js +1 -1
- package/src/flex/flex/component.js +1 -1
- package/src/flex/flex-block/component.js +1 -1
- package/src/flex/flex-item/component.js +1 -1
- package/src/flyout/flyout/component.js +1 -1
- package/src/flyout/flyout-content/component.js +1 -1
- package/src/focal-point-picker/README.md +7 -0
- package/src/focal-point-picker/index.js +12 -7
- package/src/focal-point-picker/stories/index.js +30 -0
- package/src/focal-point-picker/test/index.js +44 -0
- package/src/font-size-picker/index.js +0 -1
- package/src/form-file-upload/README.md +1 -1
- package/src/form-file-upload/stories/index.js +51 -0
- package/src/grid/component.js +1 -1
- package/src/h-stack/component.js +1 -1
- package/src/heading/component.tsx +2 -2
- package/src/index.js +2 -0
- package/src/index.native.js +5 -1
- package/src/input-control/index.tsx +2 -2
- package/src/input-control/input-base.tsx +2 -2
- package/src/input-control/input-field.tsx +4 -6
- package/src/input-control/reducer/reducer.ts +3 -0
- package/src/input-control/stories/index.js +1 -1
- package/src/input-control/types.ts +1 -1
- package/src/item-group/item/component.tsx +2 -2
- package/src/item-group/item-group/component.tsx +2 -2
- package/src/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js +10 -1
- package/src/mobile/color-settings/palette.screen.native.js +39 -9
- package/src/mobile/color-settings/style.native.scss +4 -0
- package/src/mobile/global-styles-context/test/fixtures/theme.native.js +27 -0
- package/src/mobile/global-styles-context/test/utils.native.js +2 -2
- package/src/mobile/global-styles-context/utils.native.js +75 -6
- package/src/mobile/inserter-button/index.native.js +1 -2
- package/src/mobile/inserter-button/sparkles.js +15 -0
- package/src/navigation/stories/index.js +1 -1
- package/src/navigator/index.ts +2 -0
- package/src/navigator/navigator-back-button/README.md +31 -0
- package/src/navigator/navigator-back-button/component.tsx +62 -0
- package/src/navigator/navigator-back-button/hook.ts +40 -0
- package/src/navigator/navigator-back-button/index.ts +1 -0
- package/src/navigator/navigator-button/README.md +38 -0
- package/src/navigator/navigator-button/component.tsx +61 -0
- package/src/navigator/navigator-button/hook.ts +55 -0
- package/src/navigator/navigator-button/index.ts +1 -0
- package/src/navigator/navigator-provider/README.md +20 -33
- package/src/navigator/navigator-provider/component.tsx +12 -22
- package/src/navigator/navigator-screen/README.md +1 -1
- package/src/navigator/navigator-screen/component.tsx +14 -23
- package/src/navigator/stories/index.js +24 -37
- package/src/navigator/test/index.js +89 -34
- package/src/navigator/types.ts +26 -0
- package/src/number-control/stories/index.js +1 -1
- package/src/radio/stories/index.js +1 -1
- package/src/radio-group/stories/index.js +4 -1
- package/src/resizable-box/index.tsx +2 -2
- package/src/resizable-box/resize-tooltip/index.tsx +2 -2
- package/src/resizable-box/resize-tooltip/label.tsx +2 -2
- package/src/scrollable/component.js +1 -1
- package/src/select-control/index.tsx +2 -3
- package/src/spacer/component.tsx +2 -2
- package/src/surface/component.js +1 -1
- package/src/text/component.js +1 -1
- package/src/text-control/index.js +2 -2
- package/src/toggle-group-control/stories/index.js +1 -1
- package/src/toggle-group-control/toggle-group-control/component.tsx +2 -2
- package/src/toggle-group-control/toggle-group-control-option/component.tsx +2 -2
- package/src/tools-panel/stories/index.js +0 -1
- package/src/tools-panel/tools-panel/component.tsx +2 -2
- package/src/tools-panel/tools-panel-header/component.tsx +2 -2
- package/src/tools-panel/tools-panel-item/component.tsx +2 -2
- package/src/tree-grid/README.md +24 -1
- package/src/tree-grid/index.js +66 -7
- package/src/tree-grid/stories/index.js +4 -1
- package/src/tree-grid/test/__snapshots__/index.js.snap +1 -14
- package/src/tree-grid/test/index.js +226 -7
- package/src/truncate/component.js +1 -1
- package/src/ui/context/wordpress-component.ts +2 -2
- package/src/ui/control-group/component.js +1 -1
- package/src/ui/control-label/component.js +1 -1
- package/src/ui/form-group/form-group.js +1 -1
- package/src/ui/shortcut/component.tsx +2 -2
- package/src/ui/spinner/component.js +1 -1
- package/src/ui/tooltip/component.js +1 -1
- package/src/ui/tooltip/content.js +1 -1
- package/src/unit-control/index.tsx +2 -2
- package/src/unit-control/stories/index.js +1 -1
- package/src/v-stack/component.js +1 -1
- package/src/visually-hidden/component.js +1 -1
- package/src/z-stack/component.tsx +2 -2
- package/tsconfig.tsbuildinfo +1 -1
- package/src/tools-panel/stories/typography-panel.js +0 -215
|
@@ -7,7 +7,11 @@ import { Dimensions } from 'react-native';
|
|
|
7
7
|
/**
|
|
8
8
|
* WordPress dependencies
|
|
9
9
|
*/
|
|
10
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
getPxFromCssUnit,
|
|
12
|
+
useSetting,
|
|
13
|
+
useMultipleOriginColorsAndGradients,
|
|
14
|
+
} from '@wordpress/block-editor';
|
|
11
15
|
|
|
12
16
|
export const BLOCK_STYLE_ATTRIBUTES = [
|
|
13
17
|
'textColor',
|
|
@@ -186,7 +190,7 @@ export function getBlockTypography(
|
|
|
186
190
|
|
|
187
191
|
export function parseStylesVariables( styles, mappedValues, customValues ) {
|
|
188
192
|
let stylesBase = styles;
|
|
189
|
-
const variables = [ 'preset', 'custom' ];
|
|
193
|
+
const variables = [ 'preset', 'custom', 'var' ];
|
|
190
194
|
|
|
191
195
|
if ( ! stylesBase ) {
|
|
192
196
|
return styles;
|
|
@@ -196,7 +200,9 @@ export function parseStylesVariables( styles, mappedValues, customValues ) {
|
|
|
196
200
|
// Examples
|
|
197
201
|
// var(--wp--preset--color--gray)
|
|
198
202
|
// var(--wp--custom--body--typography--font-family)
|
|
203
|
+
// var:preset|color|custom-color-2
|
|
199
204
|
const regex = new RegExp( `var\\(--wp--${ variable }--(.*?)\\)`, 'g' );
|
|
205
|
+
const varRegex = /\"var:preset\|color\|(.*?)\"/gm;
|
|
200
206
|
|
|
201
207
|
if ( variable === 'preset' ) {
|
|
202
208
|
stylesBase = stylesBase.replace( regex, ( _$1, $2 ) => {
|
|
@@ -226,6 +232,18 @@ export function parseStylesVariables( styles, mappedValues, customValues ) {
|
|
|
226
232
|
] );
|
|
227
233
|
} );
|
|
228
234
|
}
|
|
235
|
+
|
|
236
|
+
if ( variable === 'var' ) {
|
|
237
|
+
stylesBase = stylesBase.replace( varRegex, ( _$1, $2 ) => {
|
|
238
|
+
if ( mappedValues?.color ) {
|
|
239
|
+
const matchedValue = find( mappedValues.color?.values, {
|
|
240
|
+
slug: $2,
|
|
241
|
+
} );
|
|
242
|
+
return `"${ matchedValue?.color }"`;
|
|
243
|
+
}
|
|
244
|
+
return UNKNOWN_VALUE;
|
|
245
|
+
} );
|
|
246
|
+
}
|
|
229
247
|
} );
|
|
230
248
|
|
|
231
249
|
return JSON.parse( stylesBase );
|
|
@@ -233,7 +251,12 @@ export function parseStylesVariables( styles, mappedValues, customValues ) {
|
|
|
233
251
|
|
|
234
252
|
export function getMappedValues( features, palette ) {
|
|
235
253
|
const typography = features?.typography;
|
|
236
|
-
const colors =
|
|
254
|
+
const colors = [
|
|
255
|
+
...( palette?.theme || [] ),
|
|
256
|
+
...( palette?.custom || [] ),
|
|
257
|
+
...( palette?.default || [] ),
|
|
258
|
+
];
|
|
259
|
+
|
|
237
260
|
const fontSizes = {
|
|
238
261
|
...typography?.fontSizes?.theme,
|
|
239
262
|
...typography?.fontSizes?.custom,
|
|
@@ -265,7 +288,7 @@ function normalizeFontSizes( fontSizes ) {
|
|
|
265
288
|
const normalizedFontSizes = {};
|
|
266
289
|
const dimensions = Dimensions.get( 'window' );
|
|
267
290
|
|
|
268
|
-
[ 'default', 'theme', '
|
|
291
|
+
[ 'default', 'theme', 'custom' ].forEach( ( key ) => {
|
|
269
292
|
if ( fontSizes[ key ] ) {
|
|
270
293
|
normalizedFontSizes[ key ] = fontSizes[ key ]?.map(
|
|
271
294
|
( fontSizeObject ) => {
|
|
@@ -286,6 +309,52 @@ function normalizeFontSizes( fontSizes ) {
|
|
|
286
309
|
return normalizedFontSizes;
|
|
287
310
|
}
|
|
288
311
|
|
|
312
|
+
export function useMobileGlobalStylesColors( type = 'colors' ) {
|
|
313
|
+
const colorGradientSettings = useMultipleOriginColorsAndGradients();
|
|
314
|
+
const availableThemeColors = colorGradientSettings?.[ type ]?.reduce(
|
|
315
|
+
( colors, origin ) => colors.concat( origin?.[ type ] ),
|
|
316
|
+
[]
|
|
317
|
+
);
|
|
318
|
+
// Default editor colors/gradients if it's not a block-based theme.
|
|
319
|
+
const colorPalette =
|
|
320
|
+
type === 'colors' ? 'color.palette' : 'color.gradients';
|
|
321
|
+
const editorDefaultPalette = useSetting( colorPalette );
|
|
322
|
+
|
|
323
|
+
return availableThemeColors.length >= 1
|
|
324
|
+
? availableThemeColors
|
|
325
|
+
: editorDefaultPalette;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
export function getColorsAndGradients(
|
|
329
|
+
defaultEditorColors = [],
|
|
330
|
+
defaultEditorGradients = [],
|
|
331
|
+
rawFeatures
|
|
332
|
+
) {
|
|
333
|
+
const features = rawFeatures ? JSON.parse( rawFeatures ) : {};
|
|
334
|
+
|
|
335
|
+
return {
|
|
336
|
+
__experimentalGlobalStylesBaseStyles: null,
|
|
337
|
+
__experimentalFeatures: {
|
|
338
|
+
color: {
|
|
339
|
+
...( ! features?.color
|
|
340
|
+
? {
|
|
341
|
+
text: true,
|
|
342
|
+
background: true,
|
|
343
|
+
palette: {
|
|
344
|
+
default: defaultEditorColors,
|
|
345
|
+
},
|
|
346
|
+
gradients: {
|
|
347
|
+
default: defaultEditorGradients,
|
|
348
|
+
},
|
|
349
|
+
}
|
|
350
|
+
: features?.color ),
|
|
351
|
+
defaultPalette: defaultEditorColors?.length > 0,
|
|
352
|
+
defaultGradients: defaultEditorGradients?.length > 0,
|
|
353
|
+
},
|
|
354
|
+
},
|
|
355
|
+
};
|
|
356
|
+
}
|
|
357
|
+
|
|
289
358
|
export function getGlobalStyles( rawStyles, rawFeatures ) {
|
|
290
359
|
const features = rawFeatures ? JSON.parse( rawFeatures ) : {};
|
|
291
360
|
const mappedValues = getMappedValues( features, features?.color?.palette );
|
|
@@ -310,14 +379,14 @@ export function getGlobalStyles( rawStyles, rawFeatures ) {
|
|
|
310
379
|
const fontSizes = normalizeFontSizes( features?.typography?.fontSizes );
|
|
311
380
|
|
|
312
381
|
return {
|
|
313
|
-
colors,
|
|
314
|
-
gradients,
|
|
315
382
|
__experimentalFeatures: {
|
|
316
383
|
color: {
|
|
317
384
|
palette: colors?.palette,
|
|
318
385
|
gradients,
|
|
319
386
|
text: features?.color?.text ?? true,
|
|
320
387
|
background: features?.color?.background ?? true,
|
|
388
|
+
defaultPalette: features?.color?.defaultPalette ?? true,
|
|
389
|
+
defaultGradients: features?.color?.defaultGradients ?? true,
|
|
321
390
|
},
|
|
322
391
|
typography: {
|
|
323
392
|
fontSizes,
|
|
@@ -10,14 +10,13 @@ import { Component } from '@wordpress/element';
|
|
|
10
10
|
import { Icon } from '@wordpress/components';
|
|
11
11
|
import { withPreferredColorScheme } from '@wordpress/compose';
|
|
12
12
|
import { __, sprintf } from '@wordpress/i18n';
|
|
13
|
-
import { sparkles } from '@wordpress/icons';
|
|
14
13
|
import { BlockIcon } from '@wordpress/block-editor';
|
|
15
14
|
|
|
16
15
|
/**
|
|
17
16
|
* Internal dependencies
|
|
18
17
|
*/
|
|
19
18
|
import styles from './style.scss';
|
|
20
|
-
|
|
19
|
+
import sparkles from './sparkles';
|
|
21
20
|
class MenuItem extends Component {
|
|
22
21
|
constructor() {
|
|
23
22
|
super( ...arguments );
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { SVG, Path } from '@wordpress/primitives';
|
|
5
|
+
|
|
6
|
+
const sparkles = (
|
|
7
|
+
<SVG viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
8
|
+
<Path
|
|
9
|
+
d="M10 11c-1.588-.479-4-.91-4-.91s2-.241 4-.454c1.8-.191 3.365-.502 4-3.181C14.635 3.775 15 1 15 1s.365 2.775 1 5.455c.635 2.679 2 2.969 4 3.181 2 .213 4 .455 4 .455s-2.412.43-4 .909c-1.588.479-3 1-4 4.546-.746 2.643-.893 4.948-1 5.454-.107-.506-.167-2.5-1-5.454C13 12 11.588 11.479 10 11zM7.333 3.5C6.803 3.333 6 3.182 6 3.182s.667-.085 1.333-.16c.6-.066 1.122-.175 1.334-1.113C8.878.971 9 0 9 0s.122.971.333 1.91c.212.937.667 1.038 1.334 1.113.666.074 1.333.159 1.333.159s-.804.15-1.333.318c-.53.167-1 .35-1.334 1.59C9.085 6.017 9.036 6.824 9 7c-.036-.177-.056-.875-.333-1.91-.334-1.24-.804-1.423-1.334-1.59zM2.444 18C1.474 17.713 0 17.454 0 17.454s1.222-.145 2.444-.272c1.1-.115 2.057-.302 2.445-1.91C5.277 13.666 5.5 12 5.5 12s.223 1.665.611 3.273c.388 1.607 1.222 1.781 2.445 1.909 1.222.127 2.444.273 2.444.273s-1.474.258-2.444.545c-.971.287-1.834.6-2.445 2.727-.456 1.586-.546 2.97-.611 3.273-.065-.304-.102-1.5-.611-3.273C4.278 18.6 3.415 18.287 2.444 18z"
|
|
10
|
+
fill="#F0C930"
|
|
11
|
+
/>
|
|
12
|
+
</SVG>
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
export default sparkles;
|
package/src/navigator/index.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
export { default as NavigatorProvider } from './navigator-provider';
|
|
2
2
|
export { default as NavigatorScreen } from './navigator-screen';
|
|
3
|
+
export { default as NavigatorButton } from './navigator-button';
|
|
4
|
+
export { default as NavigatorBackButton } from './navigator-back-button';
|
|
3
5
|
export { default as useNavigator } from './use-navigator';
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# `NavigatorBackButton`
|
|
2
|
+
|
|
3
|
+
<div class="callout callout-alert">
|
|
4
|
+
This feature is still experimental. “Experimental” means this is an early implementation subject to drastic and breaking changes.
|
|
5
|
+
</div>
|
|
6
|
+
|
|
7
|
+
The `NavigatorBackButton` component can be used to navigate to a screen and should be used in combination with the [`NavigatorProvider`](/packages/components/src/navigator/navigator-provider/README.md), the [`NavigatorScreen`](/packages/components/src/navigator/navigator-screen/README.md) and the [`NavigatorButton`](/packages/components/src/navigator/navigator-button/README.md) components (or the `useNavigator` hook).
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
Refer to [the `NavigatorProvider` component](/packages/components/src/navigator/navigator-provider/README.md#usage) for a usage example.
|
|
12
|
+
|
|
13
|
+
## Props
|
|
14
|
+
|
|
15
|
+
The component accepts the following props:
|
|
16
|
+
|
|
17
|
+
### `onClick`: `React.MouseEventHandler< HTMLElement >`
|
|
18
|
+
|
|
19
|
+
The callback called in response to a `click` event.
|
|
20
|
+
|
|
21
|
+
- Required: No
|
|
22
|
+
|
|
23
|
+
### `path`: `string`
|
|
24
|
+
|
|
25
|
+
The path of the screen to navigate to.
|
|
26
|
+
|
|
27
|
+
- Required: Yes
|
|
28
|
+
|
|
29
|
+
### Inherited props
|
|
30
|
+
|
|
31
|
+
`NavigatorBackButton` also inherits all of the [`Button` props](/packages/components/src/button/README.md#props), except for `href`.
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import type { ForwardedRef } from 'react';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
import { contextConnect, WordPressComponentProps } from '../../ui/context';
|
|
10
|
+
import { View } from '../../view';
|
|
11
|
+
import { useNavigatorBackButton } from './hook';
|
|
12
|
+
import type { NavigatorBackButtonProps } from '../types';
|
|
13
|
+
|
|
14
|
+
function NavigatorBackButton(
|
|
15
|
+
props: WordPressComponentProps< NavigatorBackButtonProps, 'button' >,
|
|
16
|
+
forwardedRef: ForwardedRef< any >
|
|
17
|
+
) {
|
|
18
|
+
const navigatorBackButtonProps = useNavigatorBackButton( props );
|
|
19
|
+
|
|
20
|
+
return <View ref={ forwardedRef } { ...navigatorBackButtonProps } />;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* The `NavigatorBackButton` component can be used to navigate to a screen and
|
|
25
|
+
* should be used in combination with the `NavigatorProvider`, the
|
|
26
|
+
* `NavigatorScreen` and the `NavigatorButton` components (or the `useNavigator`
|
|
27
|
+
* hook).
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```jsx
|
|
31
|
+
* import {
|
|
32
|
+
* __experimentalNavigatorProvider as NavigatorProvider,
|
|
33
|
+
* __experimentalNavigatorScreen as NavigatorScreen,
|
|
34
|
+
* __experimentalNavigatorButton as NavigatorButton,
|
|
35
|
+
* __experimentalNavigatorBackButton as NavigatorBackButton,
|
|
36
|
+
* } from '@wordpress/components';
|
|
37
|
+
*
|
|
38
|
+
* const MyNavigation = () => (
|
|
39
|
+
* <NavigatorProvider initialPath="/">
|
|
40
|
+
* <NavigatorScreen path="/">
|
|
41
|
+
* <p>This is the home screen.</p>
|
|
42
|
+
* <NavigatorButton path="/child">
|
|
43
|
+
* Navigate to child screen.
|
|
44
|
+
* </NavigatorButton>
|
|
45
|
+
* </NavigatorScreen>
|
|
46
|
+
*
|
|
47
|
+
* <NavigatorScreen path="/child">
|
|
48
|
+
* <p>This is the child screen.</p>
|
|
49
|
+
* <NavigatorBackButton>
|
|
50
|
+
* Go back
|
|
51
|
+
* </NavigatorBackButton>
|
|
52
|
+
* </NavigatorScreen>
|
|
53
|
+
* </NavigatorProvider>
|
|
54
|
+
* );
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
const ConnectedNavigatorBackButton = contextConnect(
|
|
58
|
+
NavigatorBackButton,
|
|
59
|
+
'NavigatorBackButton'
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
export default ConnectedNavigatorBackButton;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useCallback } from '@wordpress/element';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Internal dependencies
|
|
11
|
+
*/
|
|
12
|
+
import { useContextSystem, WordPressComponentProps } from '../../ui/context';
|
|
13
|
+
import Button from '../../button';
|
|
14
|
+
import useNavigator from '../use-navigator';
|
|
15
|
+
import type { NavigatorBackButtonProps } from '../types';
|
|
16
|
+
|
|
17
|
+
export function useNavigatorBackButton(
|
|
18
|
+
props: WordPressComponentProps< NavigatorBackButtonProps, 'button' >
|
|
19
|
+
) {
|
|
20
|
+
const { onClick, as = Button, ...otherProps } = useContextSystem(
|
|
21
|
+
props,
|
|
22
|
+
'NavigatorBackButton'
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
const { goBack } = useNavigator();
|
|
26
|
+
const handleClick: React.MouseEventHandler< HTMLButtonElement > = useCallback(
|
|
27
|
+
( e ) => {
|
|
28
|
+
e.preventDefault();
|
|
29
|
+
goBack();
|
|
30
|
+
onClick?.( e );
|
|
31
|
+
},
|
|
32
|
+
[ goBack, onClick ]
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
return {
|
|
36
|
+
as,
|
|
37
|
+
onClick: handleClick,
|
|
38
|
+
...otherProps,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './component';
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# `NavigatorButton`
|
|
2
|
+
|
|
3
|
+
<div class="callout callout-alert">
|
|
4
|
+
This feature is still experimental. “Experimental” means this is an early implementation subject to drastic and breaking changes.
|
|
5
|
+
</div>
|
|
6
|
+
|
|
7
|
+
The `NavigatorButton` component can be used to navigate to a screen and should be used in combination with the [`NavigatorProvider`](/packages/components/src/navigator/navigator-provider/README.md), the [`NavigatorScreen`](/packages/components/src/navigator/navigator-screen/README.md) and the [`NavigatorBackButton`](/packages/components/src/navigator/navigator-back-button/README.md) components (or the `useNavigator` hook).
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
Refer to [the `NavigatorProvider` component](/packages/components/src/navigator/navigator-provider/README.md#usage) for a usage example.
|
|
12
|
+
|
|
13
|
+
## Props
|
|
14
|
+
|
|
15
|
+
The component accepts the following props:
|
|
16
|
+
|
|
17
|
+
### `attributeName`: `string`
|
|
18
|
+
|
|
19
|
+
The HTML attribute used to identify the `NavigatorButton`, which is used by `Navigator` to restore focus.
|
|
20
|
+
|
|
21
|
+
- Required: No
|
|
22
|
+
- Default: `id`
|
|
23
|
+
|
|
24
|
+
### `onClick`: `React.MouseEventHandler< HTMLElement >`
|
|
25
|
+
|
|
26
|
+
The callback called in response to a `click` event.
|
|
27
|
+
|
|
28
|
+
- Required: No
|
|
29
|
+
|
|
30
|
+
### `path`: `string`
|
|
31
|
+
|
|
32
|
+
The path of the screen to navigate to. The value of this prop needs to be [a valid value for an HTML attribute](https://html.spec.whatwg.org/multipage/syntax.html#attributes-2).
|
|
33
|
+
|
|
34
|
+
- Required: Yes
|
|
35
|
+
|
|
36
|
+
### Inherited props
|
|
37
|
+
|
|
38
|
+
`NavigatorButton` also inherits all of the [`Button` props](/packages/components/src/button/README.md#props), except for `href`.
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import type { ForwardedRef } from 'react';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
import { contextConnect, WordPressComponentProps } from '../../ui/context';
|
|
10
|
+
import { View } from '../../view';
|
|
11
|
+
import { useNavigatorButton } from './hook';
|
|
12
|
+
import type { NavigatorButtonProps } from '../types';
|
|
13
|
+
|
|
14
|
+
function NavigatorButton(
|
|
15
|
+
props: WordPressComponentProps< NavigatorButtonProps, 'button' >,
|
|
16
|
+
forwardedRef: ForwardedRef< any >
|
|
17
|
+
) {
|
|
18
|
+
const navigatorButtonProps = useNavigatorButton( props );
|
|
19
|
+
|
|
20
|
+
return <View ref={ forwardedRef } { ...navigatorButtonProps } />;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* The `NavigatorButton` component can be used to navigate to a screen and should
|
|
25
|
+
* be used in combination with the `NavigatorProvider`, the `NavigatorScreen`
|
|
26
|
+
* and the `NavigatorBackButton` components (or the `useNavigator` hook).
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```jsx
|
|
30
|
+
* import {
|
|
31
|
+
* __experimentalNavigatorProvider as NavigatorProvider,
|
|
32
|
+
* __experimentalNavigatorScreen as NavigatorScreen,
|
|
33
|
+
* __experimentalNavigatorButton as NavigatorButton,
|
|
34
|
+
* __experimentalNavigatorBackButton as NavigatorBackButton,
|
|
35
|
+
* } from '@wordpress/components';
|
|
36
|
+
*
|
|
37
|
+
* const MyNavigation = () => (
|
|
38
|
+
* <NavigatorProvider initialPath="/">
|
|
39
|
+
* <NavigatorScreen path="/">
|
|
40
|
+
* <p>This is the home screen.</p>
|
|
41
|
+
* <NavigatorButton path="/child">
|
|
42
|
+
* Navigate to child screen.
|
|
43
|
+
* </NavigatorButton>
|
|
44
|
+
* </NavigatorScreen>
|
|
45
|
+
*
|
|
46
|
+
* <NavigatorScreen path="/child">
|
|
47
|
+
* <p>This is the child screen.</p>
|
|
48
|
+
* <NavigatorBackButton>
|
|
49
|
+
* Go back
|
|
50
|
+
* </NavigatorBackButton>
|
|
51
|
+
* </NavigatorScreen>
|
|
52
|
+
* </NavigatorProvider>
|
|
53
|
+
* );
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
const ConnectedNavigatorButton = contextConnect(
|
|
57
|
+
NavigatorButton,
|
|
58
|
+
'NavigatorButton'
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
export default ConnectedNavigatorButton;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useCallback } from '@wordpress/element';
|
|
5
|
+
import { escapeAttribute } from '@wordpress/escape-html';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Internal dependencies
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Internal dependencies
|
|
12
|
+
*/
|
|
13
|
+
import { useContextSystem, WordPressComponentProps } from '../../ui/context';
|
|
14
|
+
import Button from '../../button';
|
|
15
|
+
import useNavigator from '../use-navigator';
|
|
16
|
+
import type { NavigatorButtonProps } from '../types';
|
|
17
|
+
|
|
18
|
+
const cssSelectorForAttribute = ( attrName: string, attrValue: string ) =>
|
|
19
|
+
`[${ attrName }="${ attrValue }"]`;
|
|
20
|
+
|
|
21
|
+
export function useNavigatorButton(
|
|
22
|
+
props: WordPressComponentProps< NavigatorButtonProps, 'button' >
|
|
23
|
+
) {
|
|
24
|
+
const {
|
|
25
|
+
path,
|
|
26
|
+
onClick,
|
|
27
|
+
as = Button,
|
|
28
|
+
attributeName = 'id',
|
|
29
|
+
...otherProps
|
|
30
|
+
} = useContextSystem( props, 'NavigatorButton' );
|
|
31
|
+
|
|
32
|
+
const escapedPath = escapeAttribute( path );
|
|
33
|
+
|
|
34
|
+
const { goTo } = useNavigator();
|
|
35
|
+
const handleClick: React.MouseEventHandler< HTMLButtonElement > = useCallback(
|
|
36
|
+
( e ) => {
|
|
37
|
+
e.preventDefault();
|
|
38
|
+
goTo( escapedPath, {
|
|
39
|
+
focusTargetSelector: cssSelectorForAttribute(
|
|
40
|
+
attributeName,
|
|
41
|
+
escapedPath
|
|
42
|
+
),
|
|
43
|
+
} );
|
|
44
|
+
onClick?.( e );
|
|
45
|
+
},
|
|
46
|
+
[ goTo, onClick ]
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
return {
|
|
50
|
+
as,
|
|
51
|
+
onClick: handleClick,
|
|
52
|
+
...otherProps,
|
|
53
|
+
[ attributeName ]: escapedPath,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './component';
|
|
@@ -4,47 +4,34 @@
|
|
|
4
4
|
This feature is still experimental. “Experimental” means this is an early implementation subject to drastic and breaking changes.
|
|
5
5
|
</div>
|
|
6
6
|
|
|
7
|
-
The `NavigatorProvider` component allows rendering nested panels
|
|
7
|
+
The `NavigatorProvider` component allows rendering nested views/panels/menus (via the [`NavigatorScreen` component](/packages/components/src/navigator/navigator-screen/README.md)) and navigate between these different states (via the [`NavigatorButton`](/packages/components/src/navigator/navigator-button/README.md) and [`NavigatorBackButton`](/packages/components/src/navigator/navigator-back-button/README.md) components or the `useNavigator` hook). The Global Styles sidebar is an example of this.
|
|
8
8
|
|
|
9
9
|
## Usage
|
|
10
10
|
|
|
11
11
|
```jsx
|
|
12
12
|
import {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
__experimentalNavigatorProvider as NavigatorProvider,
|
|
14
|
+
__experimentalNavigatorScreen as NavigatorScreen,
|
|
15
|
+
__experimentalNavigatorButton as NavigatorButton,
|
|
16
|
+
__experimentalNavigatorBackButton as NavigatorBackButton,
|
|
16
17
|
} from '@wordpress/components';
|
|
17
18
|
|
|
18
|
-
function NavigatorButton( { path, ...props } ) {
|
|
19
|
-
const { goTo } = useNavigator();
|
|
20
|
-
return (
|
|
21
|
-
<Button
|
|
22
|
-
variant="primary"
|
|
23
|
-
onClick={ () => goTo( path ) }
|
|
24
|
-
{ ...props }
|
|
25
|
-
/>
|
|
26
|
-
);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
function NavigatorBackButton( props ) {
|
|
30
|
-
const { goBack } = useNavigator();
|
|
31
|
-
return <Button variant="secondary" onClick={ () => goBack() } { ...props } />;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
19
|
const MyNavigation = () => (
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
20
|
+
<NavigatorProvider initialPath="/">
|
|
21
|
+
<NavigatorScreen path="/">
|
|
22
|
+
<p>This is the home screen.</p>
|
|
23
|
+
<NavigatorButton path="/child">
|
|
24
|
+
Navigate to child screen.
|
|
25
|
+
</NavigatorButton>
|
|
26
|
+
</NavigatorScreen>
|
|
27
|
+
|
|
28
|
+
<NavigatorScreen path="/child">
|
|
29
|
+
<p>This is the child screen.</p>
|
|
30
|
+
<NavigatorBackButton>
|
|
31
|
+
Go back
|
|
32
|
+
</NavigatorBackButton>
|
|
33
|
+
</NavigatorScreen>
|
|
34
|
+
</NavigatorProvider>
|
|
48
35
|
);
|
|
49
36
|
```
|
|
50
37
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import type {
|
|
4
|
+
import type { ForwardedRef } from 'react';
|
|
5
5
|
import { css } from '@emotion/react';
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -28,7 +28,7 @@ import type {
|
|
|
28
28
|
|
|
29
29
|
function NavigatorProvider(
|
|
30
30
|
props: WordPressComponentProps< NavigatorProviderProps, 'div' >,
|
|
31
|
-
forwardedRef:
|
|
31
|
+
forwardedRef: ForwardedRef< any >
|
|
32
32
|
) {
|
|
33
33
|
const {
|
|
34
34
|
initialPath,
|
|
@@ -100,44 +100,34 @@ function NavigatorProvider(
|
|
|
100
100
|
}
|
|
101
101
|
|
|
102
102
|
/**
|
|
103
|
-
* The `NavigatorProvider` component allows rendering nested panels
|
|
103
|
+
* The `NavigatorProvider` component allows rendering nested views/panels/menus
|
|
104
|
+
* (via the `NavigatorScreen` component and navigate between these different
|
|
105
|
+
* view (via the `NavigatorButton` and `NavigatorBackButton` components or the
|
|
106
|
+
* `useNavigator` hook).
|
|
104
107
|
*
|
|
105
108
|
* @example
|
|
106
109
|
* ```jsx
|
|
107
110
|
* import {
|
|
108
111
|
* __experimentalNavigatorProvider as NavigatorProvider,
|
|
109
112
|
* __experimentalNavigatorScreen as NavigatorScreen,
|
|
110
|
-
*
|
|
113
|
+
* __experimentalNavigatorButton as NavigatorButton,
|
|
114
|
+
* __experimentalNavigatorBackButton as NavigatorBackButton,
|
|
111
115
|
* } from '@wordpress/components';
|
|
112
116
|
*
|
|
113
|
-
* function NavigatorButton( { path, ...props } ) {
|
|
114
|
-
* const { goTo } = useNavigator();
|
|
115
|
-
* return (
|
|
116
|
-
* <Button
|
|
117
|
-
* variant="primary"
|
|
118
|
-
* onClick={ () => goTo( path ) }
|
|
119
|
-
* { ...props }
|
|
120
|
-
* />
|
|
121
|
-
* );
|
|
122
|
-
* }
|
|
123
|
-
*
|
|
124
|
-
* function NavigatorBackButton( props ) {
|
|
125
|
-
* const { goBack } = useNavigator();
|
|
126
|
-
* return <Button variant="secondary" onClick={ () => goBack() } { ...props } />;
|
|
127
|
-
* }
|
|
128
|
-
*
|
|
129
117
|
* const MyNavigation = () => (
|
|
130
118
|
* <NavigatorProvider initialPath="/">
|
|
131
119
|
* <NavigatorScreen path="/">
|
|
132
120
|
* <p>This is the home screen.</p>
|
|
133
|
-
*
|
|
121
|
+
* <NavigatorButton path="/child">
|
|
134
122
|
* Navigate to child screen.
|
|
135
123
|
* </NavigatorButton>
|
|
136
124
|
* </NavigatorScreen>
|
|
137
125
|
*
|
|
138
126
|
* <NavigatorScreen path="/child">
|
|
139
127
|
* <p>This is the child screen.</p>
|
|
140
|
-
* <NavigatorBackButton>
|
|
128
|
+
* <NavigatorBackButton>
|
|
129
|
+
* Go back
|
|
130
|
+
* </NavigatorBackButton>
|
|
141
131
|
* </NavigatorScreen>
|
|
142
132
|
* </NavigatorProvider>
|
|
143
133
|
* );
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
This feature is still experimental. “Experimental” means this is an early implementation subject to drastic and breaking changes.
|
|
5
5
|
</div>
|
|
6
6
|
|
|
7
|
-
The `NavigatorScreen` component represents a single view/screen/panel
|
|
7
|
+
The `NavigatorScreen` component represents a single view/screen/panel and should be used in combination with the [`NavigatorProvider`](/packages/components/src/navigator/navigator-provider/README.md), the [`NavigatorButton`](/packages/components/src/navigator/navigator-button/README.md) and the [`NavigatorBackButton`](/packages/components/src/navigator/navigator-back-button/README.md) components (or the `useNavigator` hook).
|
|
8
8
|
|
|
9
9
|
## Usage
|
|
10
10
|
|