@wordpress/components 19.3.0 → 19.4.1
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 +27 -0
- package/CONTRIBUTING.md +1 -1
- package/README.md +8 -4
- package/build/base-field/hook.js +1 -1
- package/build/base-field/hook.js.map +1 -1
- package/build/button/deprecated.js +2 -1
- package/build/button/deprecated.js.map +1 -1
- package/build/button/index.js +2 -1
- package/build/button/index.js.map +1 -1
- package/build/card/card/component.js +1 -1
- package/build/card/card/component.js.map +1 -1
- package/build/card/card/hook.js +1 -1
- package/build/card/card/hook.js.map +1 -1
- package/build/card/card-body/hook.js +1 -1
- package/build/card/card-body/hook.js.map +1 -1
- package/build/card/card-divider/hook.js +1 -1
- package/build/card/card-divider/hook.js.map +1 -1
- package/build/card/card-footer/hook.js +1 -1
- package/build/card/card-footer/hook.js.map +1 -1
- package/build/card/card-header/hook.js +1 -1
- package/build/card/card-header/hook.js.map +1 -1
- package/build/card/card-media/hook.js +1 -1
- package/build/card/card-media/hook.js.map +1 -1
- package/build/circular-option-picker/index.js +2 -0
- package/build/circular-option-picker/index.js.map +1 -1
- package/build/color-indicator/index.js +2 -0
- package/build/color-indicator/index.js.map +1 -1
- package/build/color-palette/index.js +2 -0
- package/build/color-palette/index.js.map +1 -1
- package/build/color-picker/color-display.js.map +1 -1
- package/build/color-picker/color-input.js.map +1 -1
- package/build/color-picker/component.js +1 -1
- package/build/color-picker/component.js.map +1 -1
- package/build/color-picker/use-deprecated-props.js +2 -0
- package/build/color-picker/use-deprecated-props.js.map +1 -1
- package/build/date-time/time.js +1 -1
- package/build/date-time/time.js.map +1 -1
- package/build/dropdown/index.js +3 -3
- package/build/dropdown/index.js.map +1 -1
- package/build/elevation/hook.js +5 -5
- package/build/elevation/hook.js.map +1 -1
- package/build/flex/flex/hook.js +4 -4
- package/build/flex/flex/hook.js.map +1 -1
- package/build/grid/hook.js +2 -2
- package/build/grid/hook.js.map +1 -1
- package/build/item-group/item/hook.js +1 -1
- package/build/item-group/item/hook.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/modal/index.js +1 -12
- package/build/modal/index.js.map +1 -1
- package/build/navigator/context.js +2 -2
- package/build/navigator/context.js.map +1 -1
- package/build/navigator/navigator-provider/component.js +18 -25
- package/build/navigator/navigator-provider/component.js.map +1 -1
- package/build/navigator/navigator-screen/component.js +39 -13
- package/build/navigator/navigator-screen/component.js.map +1 -1
- package/build/navigator/use-navigator.js +4 -4
- package/build/navigator/use-navigator.js.map +1 -1
- package/build/placeholder/index.js +4 -4
- package/build/placeholder/index.js.map +1 -1
- package/build/scrollable/hook.js +1 -1
- package/build/scrollable/hook.js.map +1 -1
- package/build/slot-fill/bubbles-virtually/fill.js +11 -2
- package/build/slot-fill/bubbles-virtually/fill.js.map +1 -1
- package/build/spinner/index.js +44 -5
- package/build/spinner/index.js.map +1 -1
- package/build/spinner/styles.js +56 -0
- package/build/spinner/styles.js.map +1 -0
- package/build/surface/hook.js +1 -1
- package/build/surface/hook.js.map +1 -1
- package/build/text/hook.js +5 -5
- package/build/text/hook.js.map +1 -1
- package/build/tip/index.js +4 -8
- package/build/tip/index.js.map +1 -1
- package/build/toggle-group-control/toggle-group-control/component.js +1 -1
- package/build/toggle-group-control/toggle-group-control/component.js.map +1 -1
- package/build/tools-panel/tools-panel/hook.js +7 -7
- package/build/tools-panel/tools-panel/hook.js.map +1 -1
- package/build/tools-panel/tools-panel-header/hook.js +3 -3
- package/build/tools-panel/tools-panel-header/hook.js.map +1 -1
- package/build/tools-panel/tools-panel-item/hook.js +1 -1
- package/build/tools-panel/tools-panel-item/hook.js.map +1 -1
- package/build/tree-grid/index.js +13 -6
- package/build/tree-grid/index.js.map +1 -1
- package/build/truncate/hook.js +2 -2
- package/build/truncate/hook.js.map +1 -1
- package/build/utils/config-values.js +1 -1
- package/build/utils/config-values.js.map +1 -1
- package/build-module/base-field/hook.js +1 -1
- package/build-module/base-field/hook.js.map +1 -1
- package/build-module/button/deprecated.js +2 -1
- package/build-module/button/deprecated.js.map +1 -1
- package/build-module/button/index.js +2 -1
- package/build-module/button/index.js.map +1 -1
- package/build-module/card/card/component.js +1 -1
- package/build-module/card/card/component.js.map +1 -1
- package/build-module/card/card/hook.js +1 -1
- package/build-module/card/card/hook.js.map +1 -1
- package/build-module/card/card-body/hook.js +1 -1
- package/build-module/card/card-body/hook.js.map +1 -1
- package/build-module/card/card-divider/hook.js +1 -1
- package/build-module/card/card-divider/hook.js.map +1 -1
- package/build-module/card/card-footer/hook.js +1 -1
- package/build-module/card/card-footer/hook.js.map +1 -1
- package/build-module/card/card-header/hook.js +1 -1
- package/build-module/card/card-header/hook.js.map +1 -1
- package/build-module/card/card-media/hook.js +1 -1
- package/build-module/card/card-media/hook.js.map +1 -1
- package/build-module/circular-option-picker/index.js +1 -0
- package/build-module/circular-option-picker/index.js.map +1 -1
- package/build-module/color-indicator/index.js +1 -0
- package/build-module/color-indicator/index.js.map +1 -1
- package/build-module/color-palette/index.js +1 -0
- package/build-module/color-palette/index.js.map +1 -1
- package/build-module/color-picker/color-display.js.map +1 -1
- package/build-module/color-picker/color-input.js.map +1 -1
- package/build-module/color-picker/component.js +1 -1
- package/build-module/color-picker/component.js.map +1 -1
- package/build-module/color-picker/use-deprecated-props.js +2 -0
- package/build-module/color-picker/use-deprecated-props.js.map +1 -1
- package/build-module/date-time/time.js +1 -1
- package/build-module/date-time/time.js.map +1 -1
- package/build-module/dropdown/index.js +3 -3
- package/build-module/dropdown/index.js.map +1 -1
- package/build-module/elevation/hook.js +5 -5
- package/build-module/elevation/hook.js.map +1 -1
- package/build-module/flex/flex/hook.js +4 -4
- package/build-module/flex/flex/hook.js.map +1 -1
- package/build-module/grid/hook.js +2 -2
- package/build-module/grid/hook.js.map +1 -1
- package/build-module/item-group/item/hook.js +1 -1
- package/build-module/item-group/item/hook.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/modal/index.js +1 -11
- package/build-module/modal/index.js.map +1 -1
- package/build-module/navigator/context.js +2 -2
- package/build-module/navigator/context.js.map +1 -1
- package/build-module/navigator/navigator-provider/component.js +18 -25
- package/build-module/navigator/navigator-provider/component.js.map +1 -1
- package/build-module/navigator/navigator-screen/component.js +39 -15
- package/build-module/navigator/navigator-screen/component.js.map +1 -1
- package/build-module/navigator/use-navigator.js +4 -4
- package/build-module/navigator/use-navigator.js.map +1 -1
- package/build-module/placeholder/index.js +4 -4
- package/build-module/placeholder/index.js.map +1 -1
- package/build-module/scrollable/hook.js +1 -1
- package/build-module/scrollable/hook.js.map +1 -1
- package/build-module/slot-fill/bubbles-virtually/fill.js +11 -2
- package/build-module/slot-fill/bubbles-virtually/fill.js.map +1 -1
- package/build-module/spinner/index.js +40 -5
- package/build-module/spinner/index.js.map +1 -1
- package/build-module/spinner/styles.js +49 -0
- package/build-module/spinner/styles.js.map +1 -0
- package/build-module/surface/hook.js +1 -1
- package/build-module/surface/hook.js.map +1 -1
- package/build-module/text/hook.js +5 -5
- package/build-module/text/hook.js.map +1 -1
- package/build-module/tip/index.js +4 -8
- package/build-module/tip/index.js.map +1 -1
- package/build-module/toggle-group-control/toggle-group-control/component.js +1 -1
- package/build-module/toggle-group-control/toggle-group-control/component.js.map +1 -1
- package/build-module/tools-panel/tools-panel/hook.js +7 -7
- package/build-module/tools-panel/tools-panel/hook.js.map +1 -1
- package/build-module/tools-panel/tools-panel-header/hook.js +3 -3
- package/build-module/tools-panel/tools-panel-header/hook.js.map +1 -1
- package/build-module/tools-panel/tools-panel-item/hook.js +1 -1
- package/build-module/tools-panel/tools-panel-item/hook.js.map +1 -1
- package/build-module/tree-grid/index.js +12 -6
- package/build-module/tree-grid/index.js.map +1 -1
- package/build-module/truncate/hook.js +2 -2
- package/build-module/truncate/hook.js.map +1 -1
- package/build-module/utils/config-values.js +1 -1
- package/build-module/utils/config-values.js.map +1 -1
- package/build-style/style-rtl.css +12 -2
- package/build-style/style.css +12 -2
- package/build-types/button/index.d.ts.map +1 -1
- package/build-types/circular-option-picker/index.d.ts +31 -0
- package/build-types/circular-option-picker/index.d.ts.map +1 -0
- package/build-types/color-palette/index.d.ts +16 -0
- package/build-types/color-palette/index.d.ts.map +1 -0
- package/build-types/color-palette/styles.d.ts +8 -0
- package/build-types/color-palette/styles.d.ts.map +1 -0
- package/build-types/color-picker/color-display.d.ts +14 -0
- package/build-types/color-picker/color-display.d.ts.map +1 -0
- package/build-types/color-picker/color-input.d.ts +14 -0
- package/build-types/color-picker/color-input.d.ts.map +1 -0
- package/build-types/color-picker/component.d.ts +11 -0
- package/build-types/color-picker/component.d.ts.map +1 -0
- package/build-types/color-picker/hex-input.d.ts +13 -0
- package/build-types/color-picker/hex-input.d.ts.map +1 -0
- package/build-types/color-picker/hsl-input.d.ts +13 -0
- package/build-types/color-picker/hsl-input.d.ts.map +1 -0
- package/build-types/color-picker/index.d.ts +5 -0
- package/build-types/color-picker/index.d.ts.map +1 -0
- package/build-types/color-picker/input-with-slider.d.ts +12 -0
- package/build-types/color-picker/input-with-slider.d.ts.map +1 -0
- package/build-types/color-picker/legacy-adapter.d.ts +6 -0
- package/build-types/color-picker/legacy-adapter.d.ts.map +1 -0
- package/build-types/color-picker/picker.d.ts +10 -0
- package/build-types/color-picker/picker.d.ts.map +1 -0
- package/build-types/color-picker/rgb-input.d.ts +13 -0
- package/build-types/color-picker/rgb-input.d.ts.map +1 -0
- package/build-types/color-picker/styles.d.ts +76 -0
- package/build-types/color-picker/styles.d.ts.map +1 -0
- package/build-types/color-picker/types.d.ts +2 -0
- package/build-types/color-picker/types.d.ts.map +1 -0
- package/build-types/color-picker/use-deprecated-props.d.ts +49 -0
- package/build-types/color-picker/use-deprecated-props.d.ts.map +1 -0
- package/build-types/dropdown/index.d.ts +1 -13
- package/build-types/dropdown/index.d.ts.map +1 -1
- package/build-types/elevation/hook.d.ts.map +1 -1
- package/build-types/flex/flex/hook.d.ts.map +1 -1
- package/build-types/grid/hook.d.ts.map +1 -1
- package/build-types/navigator/navigator-provider/component.d.ts +4 -4
- package/build-types/navigator/navigator-provider/component.d.ts.map +1 -1
- package/build-types/navigator/navigator-screen/component.d.ts +4 -4
- package/build-types/navigator/navigator-screen/component.d.ts.map +1 -1
- package/build-types/navigator/types.d.ts +5 -3
- package/build-types/navigator/types.d.ts.map +1 -1
- package/build-types/resizable-box/index.d.ts +1 -1
- package/build-types/resizable-box/resize-tooltip/index.d.ts +1 -1
- package/build-types/slot-fill/bubbles-virtually/fill.d.ts.map +1 -1
- package/build-types/spinner/index.d.ts +18 -1
- package/build-types/spinner/index.d.ts.map +1 -1
- package/build-types/spinner/styles.d.ts +13 -0
- package/build-types/spinner/styles.d.ts.map +1 -0
- package/build-types/surface/hook.d.ts.map +1 -1
- package/build-types/text/hook.d.ts.map +1 -1
- package/build-types/tip/index.d.ts.map +1 -1
- package/build-types/tools-panel/tools-panel/hook.d.ts.map +1 -1
- package/build-types/tools-panel/tools-panel-item/hook.d.ts.map +1 -1
- package/build-types/unit-control/index.d.ts +3 -2
- package/build-types/unit-control/index.d.ts.map +1 -1
- package/build-types/unit-control/types.d.ts +2 -1
- package/build-types/unit-control/types.d.ts.map +1 -1
- package/build-types/utils/config-values.d.ts +1 -1
- package/package.json +16 -17
- package/src/base-field/hook.js +1 -1
- package/src/button/deprecated.js +1 -0
- package/src/button/index.js +1 -0
- package/src/card/card/component.js +1 -1
- package/src/card/card/hook.js +1 -1
- package/src/card/card-body/hook.js +1 -1
- package/src/card/card-divider/hook.js +1 -1
- package/src/card/card-footer/hook.js +1 -1
- package/src/card/card-header/hook.js +1 -1
- package/src/card/card-media/hook.js +1 -1
- package/src/circular-option-picker/index.js +1 -0
- package/src/color-indicator/index.js +2 -0
- package/src/color-palette/index.js +1 -0
- package/src/color-palette/test/__snapshots__/index.js.snap +0 -1
- package/src/color-picker/color-display.tsx +1 -1
- package/src/color-picker/color-input.tsx +1 -1
- package/src/color-picker/component.tsx +1 -1
- package/src/color-picker/use-deprecated-props.ts +2 -0
- package/src/combobox-control/stories/index.js +6 -2
- package/src/combobox-control/style.scss +2 -2
- package/src/date-time/README.md +4 -4
- package/src/date-time/test/time.js +2 -2
- package/src/date-time/time.js +2 -2
- package/src/dropdown/index.js +14 -13
- package/src/elevation/hook.js +1 -0
- package/src/flex/flex/hook.js +1 -0
- package/src/grid/hook.js +1 -0
- package/src/item-group/item/hook.ts +1 -1
- package/src/item-group/stories/index.js +2 -2
- package/src/mobile/inserter-button/index.native.js +1 -2
- package/src/mobile/inserter-button/sparkles.js +15 -0
- package/src/mobile/link-settings/test/edit.native.js +5 -5
- package/src/modal/index.js +1 -10
- package/src/navigator/context.ts +2 -2
- package/src/navigator/navigator-provider/README.md +11 -9
- package/src/navigator/navigator-provider/component.tsx +16 -25
- package/src/navigator/navigator-screen/component.tsx +55 -15
- package/src/navigator/stories/index.js +19 -5
- package/src/navigator/test/index.js +77 -25
- package/src/navigator/types.ts +5 -3
- package/src/navigator/use-navigator.ts +3 -3
- package/src/placeholder/index.js +8 -6
- package/src/placeholder/style.scss +12 -0
- package/src/placeholder/test/index.js +18 -1
- package/src/scrollable/hook.js +1 -1
- package/src/slot-fill/bubbles-virtually/fill.js +12 -1
- package/src/spinner/README.md +10 -10
- package/src/spinner/index.js +42 -3
- package/src/spinner/stories/index.js +36 -3
- package/src/spinner/styles.js +47 -0
- package/src/surface/hook.js +1 -0
- package/src/text/hook.js +1 -0
- package/src/tip/index.js +2 -4
- package/src/toggle-group-control/toggle-group-control/component.tsx +1 -1
- package/src/tools-panel/stories/index.js +20 -1
- package/src/tools-panel/test/__snapshots__/index.js.snap +0 -1
- package/src/tools-panel/test/index.js +31 -1
- package/src/tools-panel/tools-panel/hook.ts +14 -9
- package/src/tools-panel/tools-panel-header/hook.ts +3 -3
- package/src/tools-panel/tools-panel-item/hook.ts +1 -0
- package/src/tree-grid/index.js +19 -5
- package/src/truncate/hook.js +1 -1
- package/src/unit-control/types.ts +2 -1
- package/src/utils/config-values.js +1 -1
- package/src/utils/hooks/stories/use-cx.js +121 -44
- package/tsconfig.json +3 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/build/spinner/styles/spinner-styles.js +0 -40
- package/build/spinner/styles/spinner-styles.js.map +0 -1
- package/build-module/spinner/styles/spinner-styles.js +0 -28
- package/build-module/spinner/styles/spinner-styles.js.map +0 -1
- package/build-types/spinner/styles/spinner-styles.d.ts +0 -5
- package/build-types/spinner/styles/spinner-styles.d.ts.map +0 -1
- package/src/spinner/styles/spinner-styles.js +0 -47
- package/src/ui/visually-hidden/README.md +0 -21
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { createElement } from "@wordpress/element";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* WordPress dependencies
|
|
5
|
+
*/
|
|
6
|
+
import { SVG, Path } from '@wordpress/primitives';
|
|
7
|
+
const sparkles = createElement(SVG, {
|
|
8
|
+
viewBox: "0 0 24 24",
|
|
9
|
+
fill: "none",
|
|
10
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
11
|
+
}, createElement(Path, {
|
|
12
|
+
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",
|
|
13
|
+
fill: "#F0C930"
|
|
14
|
+
}));
|
|
15
|
+
export default sparkles;
|
|
16
|
+
//# sourceMappingURL=sparkles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/components/src/mobile/inserter-button/sparkles.js"],"names":["SVG","Path","sparkles"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,GAAT,EAAcC,IAAd,QAA0B,uBAA1B;AAEA,MAAMC,QAAQ,GACb,cAAC,GAAD;AAAK,EAAA,OAAO,EAAC,WAAb;AAAyB,EAAA,IAAI,EAAC,MAA9B;AAAqC,EAAA,KAAK,EAAC;AAA3C,GACC,cAAC,IAAD;AACC,EAAA,CAAC,EAAC,k8BADH;AAEC,EAAA,IAAI,EAAC;AAFN,EADD,CADD;AASA,eAAeA,QAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { SVG, Path } from '@wordpress/primitives';\n\nconst sparkles = (\n\t<SVG viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n\t\t<Path\n\t\t\td=\"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\"\n\t\t\tfill=\"#F0C930\"\n\t\t/>\n\t</SVG>\n);\n\nexport default sparkles;\n"]}
|
|
@@ -12,7 +12,6 @@ import classnames from 'classnames';
|
|
|
12
12
|
|
|
13
13
|
import { createPortal, useEffect, useRef, forwardRef } from '@wordpress/element';
|
|
14
14
|
import { useInstanceId, useFocusReturn, useFocusOnMount, __experimentalUseFocusOutside as useFocusOutside, useConstrainedTabbing, useMergeRefs } from '@wordpress/compose';
|
|
15
|
-
import deprecated from '@wordpress/deprecated';
|
|
16
15
|
import { ESCAPE } from '@wordpress/keycodes';
|
|
17
16
|
import { __ } from '@wordpress/i18n';
|
|
18
17
|
import { closeSmall } from '@wordpress/icons';
|
|
@@ -34,9 +33,7 @@ function Modal(props, forwardedRef) {
|
|
|
34
33
|
focusOnMount = true,
|
|
35
34
|
shouldCloseOnEsc = true,
|
|
36
35
|
shouldCloseOnClickOutside = true,
|
|
37
|
-
|
|
38
|
-
// Deprecated
|
|
39
|
-
isDismissible = isDismissable || true,
|
|
36
|
+
isDismissible = true,
|
|
40
37
|
|
|
41
38
|
/* accessibility */
|
|
42
39
|
aria = {
|
|
@@ -80,13 +77,6 @@ function Modal(props, forwardedRef) {
|
|
|
80
77
|
};
|
|
81
78
|
}, []);
|
|
82
79
|
|
|
83
|
-
if (isDismissable) {
|
|
84
|
-
deprecated('isDismissable prop of the Modal component', {
|
|
85
|
-
since: '5.4',
|
|
86
|
-
alternative: 'isDismissible prop (renamed) of the Modal component'
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
|
|
90
80
|
function handleEscapeKeyDown(event) {
|
|
91
81
|
if (shouldCloseOnEsc && event.keyCode === ESCAPE && !event.defaultPrevented) {
|
|
92
82
|
event.preventDefault();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/components/src/modal/index.js"],"names":["classnames","createPortal","useEffect","useRef","forwardRef","useInstanceId","useFocusReturn","useFocusOnMount","__experimentalUseFocusOutside","useFocusOutside","useConstrainedTabbing","useMergeRefs","
|
|
1
|
+
{"version":3,"sources":["@wordpress/components/src/modal/index.js"],"names":["classnames","createPortal","useEffect","useRef","forwardRef","useInstanceId","useFocusReturn","useFocusOnMount","__experimentalUseFocusOutside","useFocusOutside","useConstrainedTabbing","useMergeRefs","ESCAPE","__","closeSmall","ariaHelper","Button","StyleProvider","openModalCount","Modal","props","forwardedRef","bodyOpenClassName","role","title","focusOnMount","shouldCloseOnEsc","shouldCloseOnClickOutside","isDismissible","aria","labelledby","describedby","onRequestClose","icon","closeButtonLabel","children","style","overlayClassName","className","contentLabel","onKeyDown","isFullScreen","__experimentalHideHeader","ref","instanceId","headingId","focusOnMountRef","constrainedTabbingRef","focusReturnRef","focusOutsideProps","hideApp","current","document","body","classList","add","remove","showApp","handleEscapeKeyDown","event","keyCode","defaultPrevented","preventDefault"],"mappings":";;AAAA;;AAEA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AA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,CAAEe,KAAF,CAAzB","sourcesContent":["//@ts-nocheck\n\n/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tcreatePortal,\n\tuseEffect,\n\tuseRef,\n\tforwardRef,\n} from '@wordpress/element';\nimport {\n\tuseInstanceId,\n\tuseFocusReturn,\n\tuseFocusOnMount,\n\t__experimentalUseFocusOutside as useFocusOutside,\n\tuseConstrainedTabbing,\n\tuseMergeRefs,\n} from '@wordpress/compose';\nimport { ESCAPE } from '@wordpress/keycodes';\nimport { __ } from '@wordpress/i18n';\nimport { closeSmall } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport * as ariaHelper from './aria-helper';\nimport Button from '../button';\nimport StyleProvider from '../style-provider';\n\n// Used to count the number of open modals.\nlet openModalCount = 0;\n\nfunction Modal( props, forwardedRef ) {\n\tconst {\n\t\tbodyOpenClassName = 'modal-open',\n\t\trole = 'dialog',\n\t\ttitle = null,\n\t\tfocusOnMount = true,\n\t\tshouldCloseOnEsc = true,\n\t\tshouldCloseOnClickOutside = true,\n\t\tisDismissible = true,\n\t\t/* accessibility */\n\t\taria = {\n\t\t\tlabelledby: null,\n\t\t\tdescribedby: null,\n\t\t},\n\t\tonRequestClose,\n\t\ticon,\n\t\tcloseButtonLabel,\n\t\tchildren,\n\t\tstyle,\n\t\toverlayClassName,\n\t\tclassName,\n\t\tcontentLabel,\n\t\tonKeyDown,\n\t\tisFullScreen = false,\n\t\t__experimentalHideHeader = false,\n\t} = props;\n\n\tconst ref = useRef();\n\tconst instanceId = useInstanceId( Modal );\n\tconst headingId = title\n\t\t? `components-modal-header-${ instanceId }`\n\t\t: aria.labelledby;\n\tconst focusOnMountRef = useFocusOnMount( focusOnMount );\n\tconst constrainedTabbingRef = useConstrainedTabbing();\n\tconst focusReturnRef = useFocusReturn();\n\tconst focusOutsideProps = useFocusOutside( onRequestClose );\n\n\tuseEffect( () => {\n\t\topenModalCount++;\n\n\t\tif ( openModalCount === 1 ) {\n\t\t\tariaHelper.hideApp( ref.current );\n\t\t\tdocument.body.classList.add( bodyOpenClassName );\n\t\t}\n\n\t\treturn () => {\n\t\t\topenModalCount--;\n\n\t\t\tif ( openModalCount === 0 ) {\n\t\t\t\tdocument.body.classList.remove( bodyOpenClassName );\n\t\t\t\tariaHelper.showApp();\n\t\t\t}\n\t\t};\n\t}, [] );\n\n\tfunction handleEscapeKeyDown( event ) {\n\t\tif (\n\t\t\tshouldCloseOnEsc &&\n\t\t\tevent.keyCode === ESCAPE &&\n\t\t\t! event.defaultPrevented\n\t\t) {\n\t\t\tevent.preventDefault();\n\t\t\tif ( onRequestClose ) {\n\t\t\t\tonRequestClose( event );\n\t\t\t}\n\t\t}\n\t}\n\n\treturn createPortal(\n\t\t// eslint-disable-next-line jsx-a11y/no-static-element-interactions\n\t\t<div\n\t\t\tref={ useMergeRefs( [ ref, forwardedRef ] ) }\n\t\t\tclassName={ classnames(\n\t\t\t\t'components-modal__screen-overlay',\n\t\t\t\toverlayClassName\n\t\t\t) }\n\t\t\tonKeyDown={ handleEscapeKeyDown }\n\t\t>\n\t\t\t<StyleProvider document={ document }>\n\t\t\t\t<div\n\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t'components-modal__frame',\n\t\t\t\t\t\tclassName,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t'is-full-screen': isFullScreen,\n\t\t\t\t\t\t}\n\t\t\t\t\t) }\n\t\t\t\t\tstyle={ style }\n\t\t\t\t\tref={ useMergeRefs( [\n\t\t\t\t\t\tconstrainedTabbingRef,\n\t\t\t\t\t\tfocusReturnRef,\n\t\t\t\t\t\tfocusOnMountRef,\n\t\t\t\t\t] ) }\n\t\t\t\t\trole={ role }\n\t\t\t\t\taria-label={ contentLabel }\n\t\t\t\t\taria-labelledby={ contentLabel ? null : headingId }\n\t\t\t\t\taria-describedby={ aria.describedby }\n\t\t\t\t\ttabIndex=\"-1\"\n\t\t\t\t\t{ ...( shouldCloseOnClickOutside\n\t\t\t\t\t\t? focusOutsideProps\n\t\t\t\t\t\t: {} ) }\n\t\t\t\t\tonKeyDown={ onKeyDown }\n\t\t\t\t>\n\t\t\t\t\t<div\n\t\t\t\t\t\tclassName={ classnames( 'components-modal__content', {\n\t\t\t\t\t\t\t'hide-header': __experimentalHideHeader,\n\t\t\t\t\t\t} ) }\n\t\t\t\t\t\trole=\"document\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ ! __experimentalHideHeader && (\n\t\t\t\t\t\t\t<div className=\"components-modal__header\">\n\t\t\t\t\t\t\t\t<div className=\"components-modal__header-heading-container\">\n\t\t\t\t\t\t\t\t\t{ icon && (\n\t\t\t\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"components-modal__icon-container\"\n\t\t\t\t\t\t\t\t\t\t\taria-hidden\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t{ icon }\n\t\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t{ title && (\n\t\t\t\t\t\t\t\t\t\t<h1\n\t\t\t\t\t\t\t\t\t\t\tid={ headingId }\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"components-modal__header-heading\"\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t{ title }\n\t\t\t\t\t\t\t\t\t\t</h1>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t{ isDismissible && (\n\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\tonClick={ onRequestClose }\n\t\t\t\t\t\t\t\t\t\ticon={ closeSmall }\n\t\t\t\t\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\t\t\t\t\tcloseButtonLabel ||\n\t\t\t\t\t\t\t\t\t\t\t__( 'Close dialog' )\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ children }\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t</StyleProvider>\n\t\t</div>,\n\t\tdocument.body\n\t);\n}\n\nexport default forwardRef( Modal );\n"]}
|
|
@@ -8,8 +8,8 @@ import { createContext } from '@wordpress/element';
|
|
|
8
8
|
|
|
9
9
|
const initialContextValue = {
|
|
10
10
|
location: {},
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
goTo: () => {},
|
|
12
|
+
goBack: () => {}
|
|
13
13
|
};
|
|
14
14
|
export const NavigatorContext = createContext(initialContextValue);
|
|
15
15
|
//# sourceMappingURL=context.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/components/src/navigator/context.ts"],"names":["createContext","initialContextValue","location","
|
|
1
|
+
{"version":3,"sources":["@wordpress/components/src/navigator/context.ts"],"names":["createContext","initialContextValue","location","goTo","goBack","NavigatorContext"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,aAAT,QAA8B,oBAA9B;AAEA;AACA;AACA;;AAGA,MAAMC,mBAAyC,GAAG;AACjDC,EAAAA,QAAQ,EAAE,EADuC;AAEjDC,EAAAA,IAAI,EAAE,MAAM,CAAE,CAFmC;AAGjDC,EAAAA,MAAM,EAAE,MAAM,CAAE;AAHiC,CAAlD;AAKA,OAAO,MAAMC,gBAAgB,GAAGL,aAAa,CAAEC,mBAAF,CAAtC","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createContext } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport type { NavigatorContext as NavigatorContextType } from './types';\n\nconst initialContextValue: NavigatorContextType = {\n\tlocation: {},\n\tgoTo: () => {},\n\tgoBack: () => {},\n};\nexport const NavigatorContext = createContext( initialContextValue );\n"]}
|
|
@@ -27,7 +27,7 @@ var _ref = process.env.NODE_ENV === "production" ? {
|
|
|
27
27
|
} : {
|
|
28
28
|
name: "192ebb7-classes",
|
|
29
29
|
styles: "overflow-x:hidden;label:classes;",
|
|
30
|
-
map: "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,
|
|
30
|
+
map: "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIkB3b3JkcHJlc3MvY29tcG9uZW50cy9zcmMvbmF2aWdhdG9yL25hdmlnYXRvci1wcm92aWRlci9jb21wb25lbnQudHN4Il0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQXdGWSIsImZpbGUiOiJAd29yZHByZXNzL2NvbXBvbmVudHMvc3JjL25hdmlnYXRvci9uYXZpZ2F0b3ItcHJvdmlkZXIvY29tcG9uZW50LnRzeCIsInNvdXJjZXNDb250ZW50IjpbIi8qKlxuICogRXh0ZXJuYWwgZGVwZW5kZW5jaWVzXG4gKi9cbmltcG9ydCB0eXBlIHsgUmVmIH0gZnJvbSAncmVhY3QnO1xuaW1wb3J0IHsgY3NzIH0gZnJvbSAnQGVtb3Rpb24vcmVhY3QnO1xuXG4vKipcbiAqIFdvcmRQcmVzcyBkZXBlbmRlbmNpZXNcbiAqL1xuaW1wb3J0IHsgdXNlTWVtbywgdXNlU3RhdGUsIHVzZUNhbGxiYWNrIH0gZnJvbSAnQHdvcmRwcmVzcy9lbGVtZW50JztcblxuLyoqXG4gKiBJbnRlcm5hbCBkZXBlbmRlbmNpZXNcbiAqL1xuaW1wb3J0IHtcblx0Y29udGV4dENvbm5lY3QsXG5cdHVzZUNvbnRleHRTeXN0ZW0sXG5cdFdvcmRQcmVzc0NvbXBvbmVudFByb3BzLFxufSBmcm9tICcuLi8uLi91aS9jb250ZXh0JztcbmltcG9ydCB7IHVzZUN4IH0gZnJvbSAnLi4vLi4vdXRpbHMvaG9va3MvdXNlLWN4JztcbmltcG9ydCB7IFZpZXcgfSBmcm9tICcuLi8uLi92aWV3JztcbmltcG9ydCB7IE5hdmlnYXRvckNvbnRleHQg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dG9yQmFja0J1dHRvbj5HbyBiYWNrPC9OYXZpZ2F0b3JCYWNrQnV0dG9uPlxuICogICAgIDwvTmF2aWdhdG9yU2NyZWVuPlxuICogICA8L05hdmlnYXRvclByb3ZpZGVyPlxuICogKTtcbiAqIGBgYFxuICovXG5jb25zdCBDb25uZWN0ZWROYXZpZ2F0b3JQcm92aWRlciA9IGNvbnRleHRDb25uZWN0KFxuXHROYXZpZ2F0b3JQcm92aWRlcixcblx0J05hdmlnYXRvclByb3ZpZGVyJ1xuKTtcblxuZXhwb3J0IGRlZmF1bHQgQ29ubmVjdGVkTmF2aWdhdG9yUHJvdmlkZXI7XG4iXX0= */",
|
|
31
31
|
toString: _EMOTION_STRINGIFIED_CSS_ERROR__
|
|
32
32
|
};
|
|
33
33
|
|
|
@@ -39,39 +39,32 @@ function NavigatorProvider(props, forwardedRef) {
|
|
|
39
39
|
...otherProps
|
|
40
40
|
} = useContextSystem(props, 'NavigatorProvider');
|
|
41
41
|
const [locationHistory, setLocationHistory] = useState([{
|
|
42
|
-
path: initialPath
|
|
43
|
-
isBack: false,
|
|
44
|
-
isInitial: true
|
|
42
|
+
path: initialPath
|
|
45
43
|
}]);
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
// Also force the `isInitial` flag to `false` for the new location, to make
|
|
50
|
-
// sure it doesn't get overridden by mistake.
|
|
51
|
-
setLocationHistory([...locationHistory.slice(0, -1), { ...locationHistory[locationHistory.length - 1],
|
|
52
|
-
isBack: false
|
|
53
|
-
}, { ...options,
|
|
44
|
+
const goTo = useCallback(function (path) {
|
|
45
|
+
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
46
|
+
setLocationHistory([...locationHistory, { ...options,
|
|
54
47
|
path,
|
|
55
|
-
isBack: false
|
|
56
|
-
isInitial: false
|
|
48
|
+
isBack: false
|
|
57
49
|
}]);
|
|
58
50
|
}, [locationHistory]);
|
|
59
|
-
const
|
|
51
|
+
const goBack = useCallback(() => {
|
|
60
52
|
if (locationHistory.length > 1) {
|
|
61
|
-
// Force the `isBack` flag to `true` when navigating back.
|
|
62
53
|
setLocationHistory([...locationHistory.slice(0, -2), { ...locationHistory[locationHistory.length - 2],
|
|
63
54
|
isBack: true
|
|
64
55
|
}]);
|
|
65
56
|
}
|
|
66
57
|
}, [locationHistory]);
|
|
67
58
|
const navigatorContextValue = useMemo(() => ({
|
|
68
|
-
location: locationHistory[locationHistory.length - 1],
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
59
|
+
location: { ...locationHistory[locationHistory.length - 1],
|
|
60
|
+
isInitial: locationHistory.length === 1
|
|
61
|
+
},
|
|
62
|
+
goTo,
|
|
63
|
+
goBack
|
|
64
|
+
}), [locationHistory, goTo, goBack]);
|
|
72
65
|
const cx = useCx();
|
|
73
66
|
const classes = useMemo( // Prevents horizontal overflow while animating screen transitions
|
|
74
|
-
() => cx(_ref, className), [className]);
|
|
67
|
+
() => cx(_ref, className), [className, cx]);
|
|
75
68
|
return createElement(View, _extends({
|
|
76
69
|
ref: forwardedRef,
|
|
77
70
|
className: classes
|
|
@@ -91,19 +84,19 @@ function NavigatorProvider(props, forwardedRef) {
|
|
|
91
84
|
* } from '@wordpress/components';
|
|
92
85
|
*
|
|
93
86
|
* function NavigatorButton( { path, ...props } ) {
|
|
94
|
-
* const {
|
|
87
|
+
* const { goTo } = useNavigator();
|
|
95
88
|
* return (
|
|
96
89
|
* <Button
|
|
97
90
|
* variant="primary"
|
|
98
|
-
* onClick={ () =>
|
|
91
|
+
* onClick={ () => goTo( path ) }
|
|
99
92
|
* { ...props }
|
|
100
93
|
* />
|
|
101
94
|
* );
|
|
102
95
|
* }
|
|
103
96
|
*
|
|
104
97
|
* function NavigatorBackButton( props ) {
|
|
105
|
-
* const {
|
|
106
|
-
* return <Button variant="secondary" onClick={ () =>
|
|
98
|
+
* const { goBack } = useNavigator();
|
|
99
|
+
* return <Button variant="secondary" onClick={ () => goBack() } { ...props } />;
|
|
107
100
|
* }
|
|
108
101
|
*
|
|
109
102
|
* const MyNavigation = () => (
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/components/src/navigator/navigator-provider/component.tsx"],"names":["css","useMemo","useState","useCallback","contextConnect","useContextSystem","useCx","View","NavigatorContext","NavigatorProvider","props","forwardedRef","initialPath","children","className","otherProps","locationHistory","setLocationHistory","path","
|
|
1
|
+
{"version":3,"sources":["@wordpress/components/src/navigator/navigator-provider/component.tsx"],"names":["css","useMemo","useState","useCallback","contextConnect","useContextSystem","useCx","View","NavigatorContext","NavigatorProvider","props","forwardedRef","initialPath","children","className","otherProps","locationHistory","setLocationHistory","path","goTo","options","isBack","goBack","length","slice","navigatorContextValue","location","isInitial","cx","classes","ConnectedNavigatorProvider"],"mappings":";;;;;AAAA;AACA;AACA;AAEA,SAASA,GAAT,QAAoB,gBAApB;AAEA;AACA;AACA;;AACA,SAASC,OAAT,EAAkBC,QAAlB,EAA4BC,WAA5B,QAA+C,oBAA/C;AAEA;AACA;AACA;;AACA,SACCC,cADD,EAECC,gBAFD,QAIO,kBAJP;AAKA,SAASC,KAAT,QAAsB,0BAAtB;AACA,SAASC,IAAT,QAAqB,YAArB;AACA,SAASC,gBAAT,QAAiC,YAAjC;;;;;;;;;;;;AAOA,SAASC,iBAAT,CACCC,KADD,EAECC,YAFD,EAGE;AACD,QAAM;AACLC,IAAAA,WADK;AAELC,IAAAA,QAFK;AAGLC,IAAAA,SAHK;AAIL,OAAGC;AAJE,MAKFV,gBAAgB,CAAEK,KAAF,EAAS,mBAAT,CALpB;AAOA,QAAM,CAAEM,eAAF,EAAmBC,kBAAnB,IAA0Cf,QAAQ,CAErD,CACF;AACCgB,IAAAA,IAAI,EAAEN;AADP,GADE,CAFqD,CAAxD;AAQA,QAAMO,IAAoC,GAAGhB,WAAW,CACvD,UAAEe,IAAF,EAA0B;AAAA,QAAlBE,OAAkB,uEAAR,EAAQ;AACzBH,IAAAA,kBAAkB,CAAE,CACnB,G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A;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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,MAAMiB,0BAA0B,GAAG1B,cAAc,CAChDK,iBADgD,EAEhD,mBAFgD,CAAjD;AAKA,eAAeqB,0BAAf","sourcesContent":["/**\n * External dependencies\n */\nimport type { Ref } from 'react';\nimport { css } from '@emotion/react';\n\n/**\n * WordPress dependencies\n */\nimport { useMemo, useState, useCallback } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport {\n\tcontextConnect,\n\tuseContextSystem,\n\tWordPressComponentProps,\n} from '../../ui/context';\nimport { useCx } from '../../utils/hooks/use-cx';\nimport { View } from '../../view';\nimport { NavigatorContext } from '../context';\nimport type {\n\tNavigatorProviderProps,\n\tNavigatorLocation,\n\tNavigatorContext as NavigatorContextType,\n} from '../types';\n\nfunction NavigatorProvider(\n\tprops: WordPressComponentProps< NavigatorProviderProps, 'div' >,\n\tforwardedRef: Ref< any >\n) {\n\tconst {\n\t\tinitialPath,\n\t\tchildren,\n\t\tclassName,\n\t\t...otherProps\n\t} = useContextSystem( props, 'NavigatorProvider' );\n\n\tconst [ locationHistory, setLocationHistory ] = useState<\n\t\tNavigatorLocation[]\n\t>( [\n\t\t{\n\t\t\tpath: initialPath,\n\t\t},\n\t] );\n\n\tconst goTo: NavigatorContextType[ 'goTo' ] = useCallback(\n\t\t( path, options = {} ) => {\n\t\t\tsetLocationHistory( [\n\t\t\t\t...locationHistory,\n\t\t\t\t{\n\t\t\t\t\t...options,\n\t\t\t\t\tpath,\n\t\t\t\t\tisBack: false,\n\t\t\t\t},\n\t\t\t] );\n\t\t},\n\t\t[ locationHistory ]\n\t);\n\n\tconst goBack: NavigatorContextType[ 'goBack' ] = useCallback( () => {\n\t\tif ( locationHistory.length > 1 ) {\n\t\t\tsetLocationHistory( [\n\t\t\t\t...locationHistory.slice( 0, -2 ),\n\t\t\t\t{\n\t\t\t\t\t...locationHistory[ locationHistory.length - 2 ],\n\t\t\t\t\tisBack: true,\n\t\t\t\t},\n\t\t\t] );\n\t\t}\n\t}, [ locationHistory ] );\n\n\tconst navigatorContextValue: NavigatorContextType = useMemo(\n\t\t() => ( {\n\t\t\tlocation: {\n\t\t\t\t...locationHistory[ locationHistory.length - 1 ],\n\t\t\t\tisInitial: locationHistory.length === 1,\n\t\t\t},\n\t\t\tgoTo,\n\t\t\tgoBack,\n\t\t} ),\n\t\t[ locationHistory, goTo, goBack ]\n\t);\n\n\tconst cx = useCx();\n\tconst classes = useMemo(\n\t\t// Prevents horizontal overflow while animating screen transitions\n\t\t() => cx( css( { overflowX: 'hidden' } ), className ),\n\t\t[ className, cx ]\n\t);\n\n\treturn (\n\t\t<View ref={ forwardedRef } className={ classes } { ...otherProps }>\n\t\t\t<NavigatorContext.Provider value={ navigatorContextValue }>\n\t\t\t\t{ children }\n\t\t\t</NavigatorContext.Provider>\n\t\t</View>\n\t);\n}\n\n/**\n * The `NavigatorProvider` component allows rendering nested panels or menus (via the `NavigatorScreen` component) and navigate between these different states (via the `useNavigator` hook).\n *\n * @example\n * ```jsx\n * import {\n * __experimentalNavigatorProvider as NavigatorProvider,\n * __experimentalNavigatorScreen as NavigatorScreen,\n * __experimentalUseNavigator as useNavigator,\n * } from '@wordpress/components';\n *\n * function NavigatorButton( { path, ...props } ) {\n * const { goTo } = useNavigator();\n * return (\n * <Button\n * variant=\"primary\"\n * onClick={ () => goTo( path ) }\n * { ...props }\n * />\n * );\n * }\n *\n * function NavigatorBackButton( props ) {\n * const { goBack } = useNavigator();\n * return <Button variant=\"secondary\" onClick={ () => goBack() } { ...props } />;\n * }\n *\n * const MyNavigation = () => (\n * <NavigatorProvider initialPath=\"/\">\n * <NavigatorScreen path=\"/\">\n * <p>This is the home screen.</p>\n * \t <NavigatorButton path=\"/child\">\n * Navigate to child screen.\n * </NavigatorButton>\n * </NavigatorScreen>\n *\n * <NavigatorScreen path=\"/child\">\n * <p>This is the child screen.</p>\n * <NavigatorBackButton>Go back</NavigatorBackButton>\n * </NavigatorScreen>\n * </NavigatorProvider>\n * );\n * ```\n */\nconst ConnectedNavigatorProvider = contextConnect(\n\tNavigatorProvider,\n\t'NavigatorProvider'\n);\n\nexport default ConnectedNavigatorProvider;\n"]}
|
|
@@ -13,8 +13,9 @@ import { css } from '@emotion/react';
|
|
|
13
13
|
* WordPress dependencies
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
16
|
+
import { focus } from '@wordpress/dom';
|
|
17
|
+
import { useContext, useEffect, useMemo, useRef } from '@wordpress/element';
|
|
18
|
+
import { useReducedMotion, useMergeRefs, usePrevious } from '@wordpress/compose';
|
|
18
19
|
import { isRTL } from '@wordpress/i18n';
|
|
19
20
|
/**
|
|
20
21
|
* Internal dependencies
|
|
@@ -36,7 +37,7 @@ var _ref = process.env.NODE_ENV === "production" ? {
|
|
|
36
37
|
} : {
|
|
37
38
|
name: "1ulogbc-classes",
|
|
38
39
|
styles: "overflow-x:auto;max-height:100%;label:classes;",
|
|
39
|
-
map: "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,
|
|
40
|
+
map: "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIkB3b3JkcHJlc3MvY29tcG9uZW50cy9zcmMvbmF2aWdhdG9yL25hdmlnYXRvci1zY3JlZW4vY29tcG9uZW50LnRzeCJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUE4REkiLCJmaWxlIjoiQHdvcmRwcmVzcy9jb21wb25lbnRzL3NyYy9uYXZpZ2F0b3IvbmF2aWdhdG9yLXNjcmVlbi9jb21wb25lbnQudHN4Iiwic291cmNlc0NvbnRlbnQiOlsiLyoqXG4gKiBFeHRlcm5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ogICAgICAgICAgTmF2aWdhdGUgdG8gY2hpbGQgc2NyZWVuLlxuICogICAgICAgPC9OYXZpZ2F0b3JCdXR0b24+XG4gKiAgICAgPC9OYXZpZ2F0b3JTY3JlZW4+XG4gKlxuICogICAgIDxOYXZpZ2F0b3JTY3JlZW4gcGF0aD1cIi9jaGlsZFwiPlxuICogICAgICAgPHA+VGhpcyBpcyB0aGUgY2hpbGQgc2NyZWVuLjwvcD5cbiAqICAgICAgIDxOYXZpZ2F0b3JCYWNrQnV0dG9uPkdvIGJhY2s8L05hdmlnYXRvckJhY2tCdXR0b24+XG4gKiAgICAgPC9OYXZpZ2F0b3JTY3JlZW4+XG4gKiAgIDwvTmF2aWdhdG9yUHJvdmlkZXI+XG4gKiApO1xuICogYGBgXG4gKi9cbmNvbnN0IENvbm5lY3RlZE5hdmlnYXRvclNjcmVlbiA9IGNvbnRleHRDb25uZWN0KFxuXHROYXZpZ2F0b3JTY3JlZW4sXG5cdCdOYXZpZ2F0b3JTY3JlZW4nXG4pO1xuXG5leHBvcnQgZGVmYXVsdCBDb25uZWN0ZWROYXZpZ2F0b3JTY3JlZW47XG4iXX0= */",
|
|
40
41
|
toString: _EMOTION_STRINGIFIED_CSS_ERROR__
|
|
41
42
|
};
|
|
42
43
|
|
|
@@ -52,15 +53,38 @@ function NavigatorScreen(props, forwardedRef) {
|
|
|
52
53
|
location
|
|
53
54
|
} = useContext(NavigatorContext);
|
|
54
55
|
const isMatch = location.path === path;
|
|
55
|
-
const
|
|
56
|
+
const wrapperRef = useRef(null);
|
|
57
|
+
const previousLocation = usePrevious(location);
|
|
56
58
|
const cx = useCx();
|
|
57
|
-
const classes = useMemo(() => cx(_ref, className), [className]); //
|
|
58
|
-
// It avoids the focus to happen on the first render.
|
|
59
|
+
const classes = useMemo(() => cx(_ref, className), [className, cx]); // Focus restoration
|
|
59
60
|
|
|
60
|
-
const
|
|
61
|
+
const isInitialLocation = location.isInitial && !location.isBack;
|
|
61
62
|
useEffect(() => {
|
|
62
|
-
|
|
63
|
-
|
|
63
|
+
// Only attempt to restore focus:
|
|
64
|
+
// - if the current location is not the initial one (to avoid moving focus on page load)
|
|
65
|
+
// - when the screen becomes visible
|
|
66
|
+
// - if the wrapper ref has been assigned
|
|
67
|
+
if (isInitialLocation || !isMatch || !wrapperRef.current) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
let elementToFocus = null; // When navigating back, if a selector is provided, use it to look for the
|
|
72
|
+
// target element (assumed to be a node inside the current NavigatorScreen)
|
|
73
|
+
|
|
74
|
+
if (location.isBack && previousLocation !== null && previousLocation !== void 0 && previousLocation.focusTargetSelector) {
|
|
75
|
+
elementToFocus = wrapperRef.current.querySelector(previousLocation.focusTargetSelector);
|
|
76
|
+
} // If the previous query didn't run or find any element to focus, fallback
|
|
77
|
+
// to the first tabbable element in the screen (or the screen itself).
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
if (!elementToFocus) {
|
|
81
|
+
const firstTabbable = focus.tabbable.find(wrapperRef.current)[0];
|
|
82
|
+
elementToFocus = firstTabbable !== null && firstTabbable !== void 0 ? firstTabbable : wrapperRef.current;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
elementToFocus.focus();
|
|
86
|
+
}, [isInitialLocation, isMatch]);
|
|
87
|
+
const mergedWrapperRef = useMergeRefs([forwardedRef, wrapperRef]);
|
|
64
88
|
|
|
65
89
|
if (!isMatch) {
|
|
66
90
|
return null;
|
|
@@ -68,7 +92,7 @@ function NavigatorScreen(props, forwardedRef) {
|
|
|
68
92
|
|
|
69
93
|
if (prefersReducedMotion) {
|
|
70
94
|
return createElement(View, _extends({
|
|
71
|
-
ref:
|
|
95
|
+
ref: mergedWrapperRef,
|
|
72
96
|
className: classes
|
|
73
97
|
}, otherProps), children);
|
|
74
98
|
}
|
|
@@ -101,7 +125,7 @@ function NavigatorScreen(props, forwardedRef) {
|
|
|
101
125
|
initial
|
|
102
126
|
};
|
|
103
127
|
return createElement(motion.div, _extends({
|
|
104
|
-
ref:
|
|
128
|
+
ref: mergedWrapperRef,
|
|
105
129
|
className: classes
|
|
106
130
|
}, otherProps, animatedProps), children);
|
|
107
131
|
}
|
|
@@ -117,19 +141,19 @@ function NavigatorScreen(props, forwardedRef) {
|
|
|
117
141
|
* } from '@wordpress/components';
|
|
118
142
|
*
|
|
119
143
|
* function NavigatorButton( { path, ...props } ) {
|
|
120
|
-
* const {
|
|
144
|
+
* const { goTo } = useNavigator();
|
|
121
145
|
* return (
|
|
122
146
|
* <Button
|
|
123
147
|
* variant="primary"
|
|
124
|
-
* onClick={ () =>
|
|
148
|
+
* onClick={ () => goTo( path ) }
|
|
125
149
|
* { ...props }
|
|
126
150
|
* />
|
|
127
151
|
* );
|
|
128
152
|
* }
|
|
129
153
|
*
|
|
130
154
|
* function NavigatorBackButton( props ) {
|
|
131
|
-
* const {
|
|
132
|
-
* return <Button variant="secondary" onClick={ () =>
|
|
155
|
+
* const { goBack } = useNavigator();
|
|
156
|
+
* return <Button variant="secondary" onClick={ () => goBack() } { ...props } />;
|
|
133
157
|
* }
|
|
134
158
|
*
|
|
135
159
|
* const MyNavigation = () => (
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/components/src/navigator/navigator-screen/component.tsx"],"names":["motion","css","useContext","useEffect","useState","useMemo","useReducedMotion","useFocusOnMount","isRTL","contextConnect","useContextSystem","useCx","View","NavigatorContext","animationEnterDelay","animationEnterDuration","animationExitDuration","animationExitDelay","NavigatorScreen","props","forwardedRef","children","className","path","otherProps","prefersReducedMotion","location","isMatch","ref","cx","classes","hasPathChanged","setHasPathChanged","animate","opacity","transition","delay","duration","ease","x","initial","isBack","exit","animatedProps","undefined","ConnectedNavigatorScreen"],"mappings":";;;;;AAAA;AACA;AACA;AAEA;AACA,SAASA,MAAT,QAAoC,eAApC;AACA,SAASC,GAAT,QAAoB,gBAApB;AAEA;AACA;AACA;;AACA,SAASC,UAAT,EAAqBC,SAArB,EAAgCC,Q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AIMmB,aAJN,GAMGtB,QANH,CADD;AAUA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,MAAMwB,wBAAwB,GAAGpC,cAAc,CAC9CS,eAD8C,EAE9C,iBAF8C,CAA/C;AAKA,eAAe2B,wBAAf","sourcesContent":["/**\n * External dependencies\n */\nimport type { Ref } from 'react';\n// eslint-disable-next-line no-restricted-imports\nimport { motion, MotionProps } from 'framer-motion';\nimport { css } from '@emotion/react';\n\n/**\n * WordPress dependencies\n */\nimport { useContext, useEffect, useState, useMemo } from '@wordpress/element';\nimport { useReducedMotion, useFocusOnMount } from '@wordpress/compose';\nimport { isRTL } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport {\n\tcontextConnect,\n\tuseContextSystem,\n\tWordPressComponentProps,\n} from '../../ui/context';\nimport { useCx } from '../../utils/hooks/use-cx';\nimport { View } from '../../view';\nimport { NavigatorContext } from '../context';\nimport type { NavigatorScreenProps } from '../types';\n\nconst animationEnterDelay = 0;\nconst animationEnterDuration = 0.14;\nconst animationExitDuration = 0.14;\nconst animationExitDelay = 0;\n\n// Props specific to `framer-motion` can't be currently passed to `NavigatorScreen`,\n// as some of them would overlap with HTML props (e.g. `onAnimationStart`, ...)\ntype Props = Omit<\n\tWordPressComponentProps< NavigatorScreenProps, 'div', false >,\n\tkeyof MotionProps\n>;\n\nfunction NavigatorScreen( props: Props, forwardedRef: Ref< any > ) {\n\tconst { children, className, path, ...otherProps } = useContextSystem(\n\t\tprops,\n\t\t'NavigatorScreen'\n\t);\n\n\tconst prefersReducedMotion = useReducedMotion();\n\tconst { location } = useContext( NavigatorContext );\n\tconst isMatch = location.path === path;\n\tconst ref = useFocusOnMount();\n\n\tconst cx = useCx();\n\tconst classes = useMemo(\n\t\t() =>\n\t\t\tcx(\n\t\t\t\tcss( {\n\t\t\t\t\t// Ensures horizontal overflow is visually accessible\n\t\t\t\t\toverflowX: 'auto',\n\t\t\t\t\t// In case the root has a height, it should not be exceeded\n\t\t\t\t\tmaxHeight: '100%',\n\t\t\t\t} ),\n\t\t\t\tclassName\n\t\t\t),\n\t\t[ className ]\n\t);\n\n\t// This flag is used to only apply the focus on mount when the actual path changes.\n\t// It avoids the focus to happen on the first render.\n\tconst [ hasPathChanged, setHasPathChanged ] = useState( false );\n\tuseEffect( () => {\n\t\tsetHasPathChanged( true );\n\t}, [ path ] );\n\n\tif ( ! isMatch ) {\n\t\treturn null;\n\t}\n\n\tif ( prefersReducedMotion ) {\n\t\treturn (\n\t\t\t<View ref={ forwardedRef } className={ classes } { ...otherProps }>\n\t\t\t\t{ children }\n\t\t\t</View>\n\t\t);\n\t}\n\n\tconst animate = {\n\t\topacity: 1,\n\t\ttransition: {\n\t\t\tdelay: animationEnterDelay,\n\t\t\tduration: animationEnterDuration,\n\t\t\tease: 'easeInOut',\n\t\t},\n\t\tx: 0,\n\t};\n\tconst initial = {\n\t\topacity: 0,\n\t\tx:\n\t\t\t( isRTL() && location.isBack ) || ( ! isRTL() && ! location.isBack )\n\t\t\t\t? 50\n\t\t\t\t: -50,\n\t};\n\tconst exit = {\n\t\tdelay: animationExitDelay,\n\t\topacity: 0,\n\t\tx:\n\t\t\t( ! isRTL() && location.isBack ) || ( isRTL() && ! location.isBack )\n\t\t\t\t? 50\n\t\t\t\t: -50,\n\t\ttransition: {\n\t\t\tduration: animationExitDuration,\n\t\t\tease: 'easeInOut',\n\t\t},\n\t};\n\n\tconst animatedProps = {\n\t\tanimate,\n\t\texit,\n\t\tinitial,\n\t};\n\n\treturn (\n\t\t<motion.div\n\t\t\tref={ hasPathChanged ? ref : undefined }\n\t\t\tclassName={ classes }\n\t\t\t{ ...otherProps }\n\t\t\t{ ...animatedProps }\n\t\t>\n\t\t\t{ children }\n\t\t</motion.div>\n\t);\n}\n\n/**\n * The `NavigatorScreen` component represents a single view/screen/panel/menu and is supposed to be used in combination with the `NavigatorProvider` component.\n *\n * @example\n * ```jsx\n * import {\n * __experimentalNavigatorProvider as NavigatorProvider,\n * __experimentalNavigatorScreen as NavigatorScreen,\n * __experimentalUseNavigator as useNavigator,\n * } from '@wordpress/components';\n *\n * function NavigatorButton( { path, ...props } ) {\n * const { push } = useNavigator();\n * return (\n * <Button\n * variant=\"primary\"\n * onClick={ () => push( path ) }\n * { ...props }\n * />\n * );\n * }\n *\n * function NavigatorBackButton( props ) {\n * const { pop } = useNavigator();\n * return <Button variant=\"secondary\" onClick={ () => pop() } { ...props } />;\n * }\n *\n * const MyNavigation = () => (\n * <NavigatorProvider initialPath=\"/\">\n * <NavigatorScreen path=\"/\">\n * <p>This is the home screen.</p>\n * \t <NavigatorButton path=\"/child\">\n * Navigate to child screen.\n * </NavigatorButton>\n * </NavigatorScreen>\n *\n * <NavigatorScreen path=\"/child\">\n * <p>This is the child screen.</p>\n * <NavigatorBackButton>Go back</NavigatorBackButton>\n * </NavigatorScreen>\n * </NavigatorProvider>\n * );\n * ```\n */\nconst ConnectedNavigatorScreen = contextConnect(\n\tNavigatorScreen,\n\t'NavigatorScreen'\n);\n\nexport default ConnectedNavigatorScreen;\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/components/src/navigator/navigator-screen/component.tsx"],"names":["motion","css","focus","useContext","useEffect","useMemo","useRef","useReducedMotion","useMergeRefs","usePrevious","isRTL","contextConnect","useContextSystem","useCx","View","NavigatorContext","animationEnterDelay","animationEnterDuration","animationExitDuration","animationExitDelay","NavigatorScreen","props","forwardedRef","children","className","path","otherProps","prefersReducedMotion","location","isMatch","wrapperRef","previousLocation","cx","classes","isInitialLocation","isInitial","isBack","current","elementToFocus","focusTargetSelector","querySelector","firstTabbable","tabbable","find","mergedWrapperRef","animate","opacity","transition","delay","duration","ease","x","initial","exit","animatedProps","Connected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A;AACA;AACA;AACA;;;AACA,MAAMgC,wBAAwB,GAAG5C,cAAc,CAC9CS,eAD8C,EAE9C,iBAF8C,CAA/C;AAKA,eAAemC,wBAAf","sourcesContent":["/**\n * External dependencies\n */\nimport type { Ref } from 'react';\n// eslint-disable-next-line no-restricted-imports\nimport { motion, MotionProps } from 'framer-motion';\nimport { css } from '@emotion/react';\n\n/**\n * WordPress dependencies\n */\nimport { focus } from '@wordpress/dom';\nimport { useContext, useEffect, useMemo, useRef } from '@wordpress/element';\nimport {\n\tuseReducedMotion,\n\tuseMergeRefs,\n\tusePrevious,\n} from '@wordpress/compose';\nimport { isRTL } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport {\n\tcontextConnect,\n\tuseContextSystem,\n\tWordPressComponentProps,\n} from '../../ui/context';\nimport { useCx } from '../../utils/hooks/use-cx';\nimport { View } from '../../view';\nimport { NavigatorContext } from '../context';\nimport type { NavigatorScreenProps } from '../types';\n\nconst animationEnterDelay = 0;\nconst animationEnterDuration = 0.14;\nconst animationExitDuration = 0.14;\nconst animationExitDelay = 0;\n\n// Props specific to `framer-motion` can't be currently passed to `NavigatorScreen`,\n// as some of them would overlap with HTML props (e.g. `onAnimationStart`, ...)\ntype Props = Omit<\n\tWordPressComponentProps< NavigatorScreenProps, 'div', false >,\n\tkeyof MotionProps\n>;\n\nfunction NavigatorScreen( props: Props, forwardedRef: Ref< any > ) {\n\tconst { children, className, path, ...otherProps } = useContextSystem(\n\t\tprops,\n\t\t'NavigatorScreen'\n\t);\n\n\tconst prefersReducedMotion = useReducedMotion();\n\tconst { location } = useContext( NavigatorContext );\n\tconst isMatch = location.path === path;\n\tconst wrapperRef = useRef< HTMLDivElement >( null );\n\n\tconst previousLocation = usePrevious( location );\n\n\tconst cx = useCx();\n\tconst classes = useMemo(\n\t\t() =>\n\t\t\tcx(\n\t\t\t\tcss( {\n\t\t\t\t\t// Ensures horizontal overflow is visually accessible\n\t\t\t\t\toverflowX: 'auto',\n\t\t\t\t\t// In case the root has a height, it should not be exceeded\n\t\t\t\t\tmaxHeight: '100%',\n\t\t\t\t} ),\n\t\t\t\tclassName\n\t\t\t),\n\t\t[ className, cx ]\n\t);\n\n\t// Focus restoration\n\tconst isInitialLocation = location.isInitial && ! location.isBack;\n\tuseEffect( () => {\n\t\t// Only attempt to restore focus:\n\t\t// - if the current location is not the initial one (to avoid moving focus on page load)\n\t\t// - when the screen becomes visible\n\t\t// - if the wrapper ref has been assigned\n\t\tif ( isInitialLocation || ! isMatch || ! wrapperRef.current ) {\n\t\t\treturn;\n\t\t}\n\n\t\tlet elementToFocus: HTMLElement | null = null;\n\n\t\t// When navigating back, if a selector is provided, use it to look for the\n\t\t// target element (assumed to be a node inside the current NavigatorScreen)\n\t\tif ( location.isBack && previousLocation?.focusTargetSelector ) {\n\t\t\telementToFocus = wrapperRef.current.querySelector(\n\t\t\t\tpreviousLocation.focusTargetSelector\n\t\t\t);\n\t\t}\n\n\t\t// If the previous query didn't run or find any element to focus, fallback\n\t\t// to the first tabbable element in the screen (or the screen itself).\n\t\tif ( ! elementToFocus ) {\n\t\t\tconst firstTabbable = ( focus.tabbable.find(\n\t\t\t\twrapperRef.current\n\t\t\t) as HTMLElement[] )[ 0 ];\n\n\t\t\telementToFocus = firstTabbable ?? wrapperRef.current;\n\t\t}\n\n\t\telementToFocus.focus();\n\t}, [ isInitialLocation, isMatch ] );\n\n\tconst mergedWrapperRef = useMergeRefs( [ forwardedRef, wrapperRef ] );\n\n\tif ( ! isMatch ) {\n\t\treturn null;\n\t}\n\n\tif ( prefersReducedMotion ) {\n\t\treturn (\n\t\t\t<View\n\t\t\t\tref={ mergedWrapperRef }\n\t\t\t\tclassName={ classes }\n\t\t\t\t{ ...otherProps }\n\t\t\t>\n\t\t\t\t{ children }\n\t\t\t</View>\n\t\t);\n\t}\n\n\tconst animate = {\n\t\topacity: 1,\n\t\ttransition: {\n\t\t\tdelay: animationEnterDelay,\n\t\t\tduration: animationEnterDuration,\n\t\t\tease: 'easeInOut',\n\t\t},\n\t\tx: 0,\n\t};\n\tconst initial = {\n\t\topacity: 0,\n\t\tx:\n\t\t\t( isRTL() && location.isBack ) || ( ! isRTL() && ! location.isBack )\n\t\t\t\t? 50\n\t\t\t\t: -50,\n\t};\n\tconst exit = {\n\t\tdelay: animationExitDelay,\n\t\topacity: 0,\n\t\tx:\n\t\t\t( ! isRTL() && location.isBack ) || ( isRTL() && ! location.isBack )\n\t\t\t\t? 50\n\t\t\t\t: -50,\n\t\ttransition: {\n\t\t\tduration: animationExitDuration,\n\t\t\tease: 'easeInOut',\n\t\t},\n\t};\n\n\tconst animatedProps = {\n\t\tanimate,\n\t\texit,\n\t\tinitial,\n\t};\n\n\treturn (\n\t\t<motion.div\n\t\t\tref={ mergedWrapperRef }\n\t\t\tclassName={ classes }\n\t\t\t{ ...otherProps }\n\t\t\t{ ...animatedProps }\n\t\t>\n\t\t\t{ children }\n\t\t</motion.div>\n\t);\n}\n\n/**\n * The `NavigatorScreen` component represents a single view/screen/panel/menu and is supposed to be used in combination with the `NavigatorProvider` component.\n *\n * @example\n * ```jsx\n * import {\n * __experimentalNavigatorProvider as NavigatorProvider,\n * __experimentalNavigatorScreen as NavigatorScreen,\n * __experimentalUseNavigator as useNavigator,\n * } from '@wordpress/components';\n *\n * function NavigatorButton( { path, ...props } ) {\n * const { goTo } = useNavigator();\n * return (\n * <Button\n * variant=\"primary\"\n * onClick={ () => goTo( path ) }\n * { ...props }\n * />\n * );\n * }\n *\n * function NavigatorBackButton( props ) {\n * const { goBack } = useNavigator();\n * return <Button variant=\"secondary\" onClick={ () => goBack() } { ...props } />;\n * }\n *\n * const MyNavigation = () => (\n * <NavigatorProvider initialPath=\"/\">\n * <NavigatorScreen path=\"/\">\n * <p>This is the home screen.</p>\n * \t <NavigatorButton path=\"/child\">\n * Navigate to child screen.\n * </NavigatorButton>\n * </NavigatorScreen>\n *\n * <NavigatorScreen path=\"/child\">\n * <p>This is the child screen.</p>\n * <NavigatorBackButton>Go back</NavigatorBackButton>\n * </NavigatorScreen>\n * </NavigatorProvider>\n * );\n * ```\n */\nconst ConnectedNavigatorScreen = contextConnect(\n\tNavigatorScreen,\n\t'NavigatorScreen'\n);\n\nexport default ConnectedNavigatorScreen;\n"]}
|
|
@@ -14,13 +14,13 @@ import { NavigatorContext } from './context';
|
|
|
14
14
|
function useNavigator() {
|
|
15
15
|
const {
|
|
16
16
|
location,
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
goTo,
|
|
18
|
+
goBack
|
|
19
19
|
} = useContext(NavigatorContext);
|
|
20
20
|
return {
|
|
21
21
|
location,
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
goTo,
|
|
23
|
+
goBack
|
|
24
24
|
};
|
|
25
25
|
}
|
|
26
26
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/components/src/navigator/use-navigator.ts"],"names":["useContext","NavigatorContext","useNavigator","location","
|
|
1
|
+
{"version":3,"sources":["@wordpress/components/src/navigator/use-navigator.ts"],"names":["useContext","NavigatorContext","useNavigator","location","goTo","goBack"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,UAAT,QAA2B,oBAA3B;AAEA;AACA;AACA;;AACA,SAASC,gBAAT,QAAiC,WAAjC;;AAGA;AACA;AACA;AACA,SAASC,YAAT,GAAmC;AAClC,QAAM;AAAEC,IAAAA,QAAF;AAAYC,IAAAA,IAAZ;AAAkBC,IAAAA;AAAlB,MAA6BL,UAAU,CAAEC,gBAAF,CAA7C;AAEA,SAAO;AACNE,IAAAA,QADM;AAENC,IAAAA,IAFM;AAGNC,IAAAA;AAHM,GAAP;AAKA;;AAED,eAAeH,YAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useContext } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { NavigatorContext } from './context';\nimport type { Navigator } from './types';\n\n/**\n * Retrieves a `navigator` instance.\n */\nfunction useNavigator(): Navigator {\n\tconst { location, goTo, goBack } = useContext( NavigatorContext );\n\n\treturn {\n\t\tlocation,\n\t\tgoTo,\n\t\tgoBack,\n\t};\n}\n\nexport default useNavigator;\n"]}
|
|
@@ -70,11 +70,11 @@ function Placeholder(_ref) {
|
|
|
70
70
|
className: "components-placeholder__label"
|
|
71
71
|
}, createElement(Icon, {
|
|
72
72
|
icon: icon
|
|
73
|
-
}), label),
|
|
74
|
-
className: "components-placeholder__instructions"
|
|
75
|
-
}, instructions), createElement("div", {
|
|
73
|
+
}), label), createElement("fieldset", {
|
|
76
74
|
className: fieldsetClasses
|
|
77
|
-
},
|
|
75
|
+
}, !!instructions && createElement("legend", {
|
|
76
|
+
className: "components-placeholder__instructions"
|
|
77
|
+
}, instructions), children));
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
export default Placeholder;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/components/src/placeholder/index.js"],"names":["classnames","useResizeObserver","Icon","Placeholder","icon","children","label","instructions","className","notices","preview","isColumnLayout","additionalProps","resizeListener","width","modifierClassNames","classes","fieldsetClasses"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,iBAAT,QAAkC,oBAAlC;AAEA;AACA;AACA;;AACA,OAAOC,IAAP,MAAiB,SAAjB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASC,WAAT,OAUI;AAAA,MAVkB;AACrBC,IAAAA,IADqB;AAErBC,IAAAA,QAFqB;AAGrBC,IAAAA,KAHqB;AAIrBC,IAAAA,YAJqB;AAKrBC,IAAAA,SALqB;AAMrBC,IAAAA,OANqB;AAOrBC,IAAAA,OAPqB;AAQrBC,IAAAA,cARqB;AASrB,OAAGC;AATkB,GAUlB;AACH,QAAM,CAAEC,cAAF,EAAkB;AAAEC,IAAAA;AAAF,GAAlB,IAAgCb,iBAAiB,EAAvD,CADG,CAGH;AACA;;AACA,MAAIc,kBAAJ;;AACA,MAAK,OAAOD,KAAP,KAAiB,QAAtB,EAAiC;AAChCC,IAAAA,kBAAkB,GAAG;AACpB,kBAAYD,KAAK,IAAI,GADD;AAEpB,mBAAaA,KAAK,IAAI,GAAT,IAAgBA,KAAK,GAAG,GAFjB;AAGpB,kBAAYA,KAAK,GAAG;AAHA,KAArB;AAKA;;AAED,QAAME,OAAO,GAAGhB,UAAU,CACzB,wBADyB,EAEzBQ,SAFyB,EAGzBO,kBAHyB,CAA1B;AAKA,QAAME,eAAe,GAAGjB,UAAU,CAAE,kCAAF,EAAsC;AACvE,wBAAoBW;AADmD,GAAtC,CAAlC;AAGA,SACC,kCAAUC,eAAV;AAA4B,IAAA,SAAS,EAAGI;AAAxC,MACGH,cADH,EAEGJ,OAFH,EAGGC,OAAO,IACR;AAAK,IAAA,SAAS,EAAC;AAAf,KACGA,OADH,CAJF,EAQC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,cAAC,IAAD;AAAM,IAAA,IAAI,EAAGN;AAAb,IADD,EAEGE,KAFH,CARD,
|
|
1
|
+
{"version":3,"sources":["@wordpress/components/src/placeholder/index.js"],"names":["classnames","useResizeObserver","Icon","Placeholder","icon","children","label","instructions","className","notices","preview","isColumnLayout","additionalProps","resizeListener","width","modifierClassNames","classes","fieldsetClasses"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,iBAAT,QAAkC,oBAAlC;AAEA;AACA;AACA;;AACA,OAAOC,IAAP,MAAiB,SAAjB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASC,WAAT,OAUI;AAAA,MAVkB;AACrBC,IAAAA,IADqB;AAErBC,IAAAA,QAFqB;AAGrBC,IAAAA,KAHqB;AAIrBC,IAAAA,YAJqB;AAKrBC,IAAAA,SALqB;AAMrBC,IAAAA,OANqB;AAOrBC,IAAAA,OAPqB;AAQrBC,IAAAA,cARqB;AASrB,OAAGC;AATkB,GAUlB;AACH,QAAM,CAAEC,cAAF,EAAkB;AAAEC,IAAAA;AAAF,GAAlB,IAAgCb,iBAAiB,EAAvD,CADG,CAGH;AACA;;AACA,MAAIc,kBAAJ;;AACA,MAAK,OAAOD,KAAP,KAAiB,QAAtB,EAAiC;AAChCC,IAAAA,kBAAkB,GAAG;AACpB,kBAAYD,KAAK,IAAI,GADD;AAEpB,mBAAaA,KAAK,IAAI,GAAT,IAAgBA,KAAK,GAAG,GAFjB;AAGpB,kBAAYA,KAAK,GAAG;AAHA,KAArB;AAKA;;AAED,QAAME,OAAO,GAAGhB,UAAU,CACzB,wBADyB,EAEzBQ,SAFyB,EAGzBO,kBAHyB,CAA1B;AAKA,QAAME,eAAe,GAAGjB,UAAU,CAAE,kCAAF,EAAsC;AACvE,wBAAoBW;AADmD,GAAtC,CAAlC;AAGA,SACC,kCAAUC,eAAV;AAA4B,IAAA,SAAS,EAAGI;AAAxC,MACGH,cADH,EAEGJ,OAFH,EAGGC,OAAO,IACR;AAAK,IAAA,SAAS,EAAC;AAAf,KACGA,OADH,CAJF,EAQC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,cAAC,IAAD;AAAM,IAAA,IAAI,EAAGN;AAAb,IADD,EAEGE,KAFH,CARD,EAYC;AAAU,IAAA,SAAS,EAAGW;AAAtB,KACG,CAAC,CAAEV,YAAH,IACD;AAAQ,IAAA,SAAS,EAAC;AAAlB,KACGA,YADH,CAFF,EAMGF,QANH,CAZD,CADD;AAuBA;;AAED,eAAeF,WAAf","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useResizeObserver } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport Icon from '../icon';\n\n/**\n * Renders a placeholder. Normally used by blocks to render their empty state.\n *\n * @param {Object} props The component props.\n * @param {WPIcon} props.icon An icon rendered before the label.\n * @param {WPElement} props.children Children to be rendered.\n * @param {string} props.label Title of the placeholder.\n * @param {string} props.instructions Instructions of the placeholder.\n * @param {string} props.className Class to set on the container div.\n * @param {Object} props.notices A rendered notices list.\n * @param {Object} props.preview Preview to be rendered in the placeholder.\n * @param {boolean} props.isColumnLayout Whether a column layout should be used.\n *\n * @return {Object} The rendered placeholder.\n */\nfunction Placeholder( {\n\ticon,\n\tchildren,\n\tlabel,\n\tinstructions,\n\tclassName,\n\tnotices,\n\tpreview,\n\tisColumnLayout,\n\t...additionalProps\n} ) {\n\tconst [ resizeListener, { width } ] = useResizeObserver();\n\n\t// Since `useResizeObserver` will report a width of `null` until after the\n\t// first render, avoid applying any modifier classes until width is known.\n\tlet modifierClassNames;\n\tif ( typeof width === 'number' ) {\n\t\tmodifierClassNames = {\n\t\t\t'is-large': width >= 480,\n\t\t\t'is-medium': width >= 160 && width < 480,\n\t\t\t'is-small': width < 160,\n\t\t};\n\t}\n\n\tconst classes = classnames(\n\t\t'components-placeholder',\n\t\tclassName,\n\t\tmodifierClassNames\n\t);\n\tconst fieldsetClasses = classnames( 'components-placeholder__fieldset', {\n\t\t'is-column-layout': isColumnLayout,\n\t} );\n\treturn (\n\t\t<div { ...additionalProps } className={ classes }>\n\t\t\t{ resizeListener }\n\t\t\t{ notices }\n\t\t\t{ preview && (\n\t\t\t\t<div className=\"components-placeholder__preview\">\n\t\t\t\t\t{ preview }\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t<div className=\"components-placeholder__label\">\n\t\t\t\t<Icon icon={ icon } />\n\t\t\t\t{ label }\n\t\t\t</div>\n\t\t\t<fieldset className={ fieldsetClasses }>\n\t\t\t\t{ !! instructions && (\n\t\t\t\t\t<legend className=\"components-placeholder__instructions\">\n\t\t\t\t\t\t{ instructions }\n\t\t\t\t\t</legend>\n\t\t\t\t) }\n\t\t\t\t{ children }\n\t\t\t</fieldset>\n\t\t</div>\n\t);\n}\n\nexport default Placeholder;\n"]}
|
|
@@ -25,7 +25,7 @@ export function useScrollable(props) {
|
|
|
25
25
|
...otherProps
|
|
26
26
|
} = useContextSystem(props, 'Scrollable');
|
|
27
27
|
const cx = useCx();
|
|
28
|
-
const classes = useMemo(() => cx(styles.Scrollable, styles.scrollableScrollbar, smoothScroll && styles.smoothScroll, scrollDirection === 'x' && styles.scrollX, scrollDirection === 'y' && styles.scrollY, scrollDirection === 'auto' && styles.scrollAuto, className), [className, scrollDirection, smoothScroll]);
|
|
28
|
+
const classes = useMemo(() => cx(styles.Scrollable, styles.scrollableScrollbar, smoothScroll && styles.smoothScroll, scrollDirection === 'x' && styles.scrollX, scrollDirection === 'y' && styles.scrollY, scrollDirection === 'auto' && styles.scrollAuto, className), [className, cx, scrollDirection, smoothScroll]);
|
|
29
29
|
return { ...otherProps,
|
|
30
30
|
className: classes
|
|
31
31
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/components/src/scrollable/hook.js"],"names":["useMemo","useContextSystem","styles","useCx","useScrollable","props","className","scrollDirection","smoothScroll","otherProps","cx","classes","Scrollable","scrollableScrollbar","scrollX","scrollY","scrollAuto"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,OAAT,QAAwB,oBAAxB;AAEA;AACA;AACA;;AACA,SAASC,gBAAT,QAAiC,eAAjC;AACA,OAAO,KAAKC,MAAZ,MAAwB,UAAxB;AACA,SAASC,KAAT,QAAsB,uBAAtB;AAEA;;AACA;AACA;AACA;;AACA;;AACA,OAAO,SAASC,aAAT,CAAwBC,KAAxB,EAAgC;AACtC,QAAM;AACLC,IAAAA,SADK;AAELC,IAAAA,eAAe,GAAG,GAFb;AAGLC,IAAAA,YAAY,GAAG,KAHV;AAIL,OAAGC;AAJE,MAKFR,gBAAgB,CAAEI,KAAF,EAAS,YAAT,CALpB;AAOA,QAAMK,EAAE,GAAGP,KAAK,EAAhB;AAEA,QAAMQ,OAAO,GAAGX,OAAO,CACtB,MACCU,EAAE,CACDR,MAAM,CAACU,UADN,EAEDV,MAAM,CAACW,mBAFN,EAGDL,YAAY,IAAIN,MAAM,CAACM,YAHtB,EAIDD,eAAe,KAAK,GAApB,IAA2BL,MAAM,CAACY,OAJjC,EAKDP,eAAe,KAAK,GAApB,IAA2BL,MAAM,CAACa,OALjC,EAMDR,eAAe,KAAK,MAApB,IAA8BL,MAAM,CAACc,UANpC,EAODV,SAPC,CAFmB,EAWtB,CAAEA,SAAF,
|
|
1
|
+
{"version":3,"sources":["@wordpress/components/src/scrollable/hook.js"],"names":["useMemo","useContextSystem","styles","useCx","useScrollable","props","className","scrollDirection","smoothScroll","otherProps","cx","classes","Scrollable","scrollableScrollbar","scrollX","scrollY","scrollAuto"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,OAAT,QAAwB,oBAAxB;AAEA;AACA;AACA;;AACA,SAASC,gBAAT,QAAiC,eAAjC;AACA,OAAO,KAAKC,MAAZ,MAAwB,UAAxB;AACA,SAASC,KAAT,QAAsB,uBAAtB;AAEA;;AACA;AACA;AACA;;AACA;;AACA,OAAO,SAASC,aAAT,CAAwBC,KAAxB,EAAgC;AACtC,QAAM;AACLC,IAAAA,SADK;AAELC,IAAAA,eAAe,GAAG,GAFb;AAGLC,IAAAA,YAAY,GAAG,KAHV;AAIL,OAAGC;AAJE,MAKFR,gBAAgB,CAAEI,KAAF,EAAS,YAAT,CALpB;AAOA,QAAMK,EAAE,GAAGP,KAAK,EAAhB;AAEA,QAAMQ,OAAO,GAAGX,OAAO,CACtB,MACCU,EAAE,CACDR,MAAM,CAACU,UADN,EAEDV,MAAM,CAACW,mBAFN,EAGDL,YAAY,IAAIN,MAAM,CAACM,YAHtB,EAIDD,eAAe,KAAK,GAApB,IAA2BL,MAAM,CAACY,OAJjC,EAKDP,eAAe,KAAK,GAApB,IAA2BL,MAAM,CAACa,OALjC,EAMDR,eAAe,KAAK,MAApB,IAA8BL,MAAM,CAACc,UANpC,EAODV,SAPC,CAFmB,EAWtB,CAAEA,SAAF,EAAaI,EAAb,EAAiBH,eAAjB,EAAkCC,YAAlC,CAXsB,CAAvB;AAcA,SAAO,EAAE,GAAGC,UAAL;AAAiBH,IAAAA,SAAS,EAAEK;AAA5B,GAAP;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { useContextSystem } from '../ui/context';\nimport * as styles from './styles';\nimport { useCx } from '../utils/hooks/use-cx';\n\n/* eslint-disable jsdoc/valid-types */\n/**\n * @param {import('../ui/context').WordPressComponentProps<import('./types').Props, 'div'>} props\n */\n/* eslint-enable jsdoc/valid-types */\nexport function useScrollable( props ) {\n\tconst {\n\t\tclassName,\n\t\tscrollDirection = 'y',\n\t\tsmoothScroll = false,\n\t\t...otherProps\n\t} = useContextSystem( props, 'Scrollable' );\n\n\tconst cx = useCx();\n\n\tconst classes = useMemo(\n\t\t() =>\n\t\t\tcx(\n\t\t\t\tstyles.Scrollable,\n\t\t\t\tstyles.scrollableScrollbar,\n\t\t\t\tsmoothScroll && styles.smoothScroll,\n\t\t\t\tscrollDirection === 'x' && styles.scrollX,\n\t\t\t\tscrollDirection === 'y' && styles.scrollY,\n\t\t\t\tscrollDirection === 'auto' && styles.scrollAuto,\n\t\t\t\tclassName\n\t\t\t),\n\t\t[ className, cx, scrollDirection, smoothScroll ]\n\t);\n\n\treturn { ...otherProps, className: classes };\n}\n"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createElement } from "@wordpress/element";
|
|
1
2
|
// @ts-nocheck
|
|
2
3
|
|
|
3
4
|
/**
|
|
@@ -9,6 +10,7 @@ import { useRef, useState, useEffect, createPortal } from '@wordpress/element';
|
|
|
9
10
|
*/
|
|
10
11
|
|
|
11
12
|
import useSlot from './use-slot';
|
|
13
|
+
import StyleProvider from '../../style-provider';
|
|
12
14
|
|
|
13
15
|
function useForceUpdate() {
|
|
14
16
|
const [, setState] = useState({});
|
|
@@ -50,8 +52,15 @@ export default function Fill(_ref) {
|
|
|
50
52
|
|
|
51
53
|
if (typeof children === 'function') {
|
|
52
54
|
children = children(slot.fillProps);
|
|
53
|
-
}
|
|
55
|
+
} // When using a `Fill`, the `children` will be rendered in the document of the
|
|
56
|
+
// `Slot`. This means that we need to wrap the `children` in a `StyleProvider`
|
|
57
|
+
// to make sure we're referencing the right document/iframe (instead of the
|
|
58
|
+
// context of the `Fill`'s parent).
|
|
59
|
+
|
|
54
60
|
|
|
55
|
-
|
|
61
|
+
const wrappedChildren = createElement(StyleProvider, {
|
|
62
|
+
document: slot.ref.current.ownerDocument
|
|
63
|
+
}, children);
|
|
64
|
+
return createPortal(wrappedChildren, slot.ref.current);
|
|
56
65
|
}
|
|
57
66
|
//# sourceMappingURL=fill.js.map
|