@wordpress/block-editor 7.0.4 → 8.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/README.md +31 -0
- package/build/components/alignment-control/ui.js +1 -2
- package/build/components/alignment-control/ui.js.map +1 -1
- package/build/components/block-icon/index.js +5 -1
- package/build/components/block-icon/index.js.map +1 -1
- package/build/components/block-inspector/index.js +4 -0
- package/build/components/block-inspector/index.js.map +1 -1
- package/build/components/block-list/index.native.js +1 -1
- package/build/components/block-list/index.native.js.map +1 -1
- package/build/components/block-list/use-block-props/use-multi-selection.js +21 -8
- package/build/components/block-list/use-block-props/use-multi-selection.js.map +1 -1
- package/build/components/block-navigation/dropdown.js +0 -1
- package/build/components/block-navigation/dropdown.js.map +1 -1
- package/build/components/block-patterns-list/index.js +1 -8
- package/build/components/block-patterns-list/index.js.map +1 -1
- package/build/components/block-settings/container.native.js +5 -2
- package/build/components/block-settings/container.native.js.map +1 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js +22 -2
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/block-styles/preview.native.js +2 -2
- package/build/components/block-styles/preview.native.js.map +1 -1
- package/build/components/colors-gradients/control.js +8 -47
- package/build/components/colors-gradients/control.js.map +1 -1
- package/build/components/colors-gradients/panel-color-gradient-settings.js +81 -6
- package/build/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
- package/build/components/duotone-control/index.js +5 -2
- package/build/components/duotone-control/index.js.map +1 -1
- package/build/components/font-appearance-control/index.js +27 -15
- package/build/components/font-appearance-control/index.js.map +1 -1
- package/build/components/iframe/index.js +1 -1
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/index.js +20 -2
- package/build/components/index.js.map +1 -1
- package/build/components/index.native.js +2 -2
- package/build/components/index.native.js.map +1 -1
- package/build/components/inner-blocks/index.js +5 -4
- package/build/components/inner-blocks/index.js.map +1 -1
- package/build/components/inner-blocks/index.native.js +4 -3
- package/build/components/inner-blocks/index.native.js.map +1 -1
- package/build/components/inserter/block-patterns-explorer/explorer.js +62 -0
- package/build/components/inserter/block-patterns-explorer/explorer.js.map +1 -0
- package/build/components/inserter/block-patterns-explorer/patterns-list.js +111 -0
- package/build/components/inserter/block-patterns-explorer/patterns-list.js.map +1 -0
- package/build/components/inserter/block-patterns-explorer/sidebar.js +78 -0
- package/build/components/inserter/block-patterns-explorer/sidebar.js.map +1 -0
- package/build/components/inserter/block-patterns-tab.js +74 -45
- package/build/components/inserter/block-patterns-tab.js.map +1 -1
- package/build/components/inserter/hooks/use-block-type-impressions.native.js +4 -7
- package/build/components/inserter/hooks/use-block-type-impressions.native.js.map +1 -1
- package/build/components/inserter/pattern-panel.js +19 -10
- package/build/components/inserter/pattern-panel.js.map +1 -1
- package/build/components/inspector-controls/groups.js +3 -1
- package/build/components/inspector-controls/groups.js.map +1 -1
- package/build/components/letter-spacing-control/index.js +9 -6
- package/build/components/letter-spacing-control/index.js.map +1 -1
- package/build/components/link-control/index.js +88 -35
- package/build/components/link-control/index.js.map +1 -1
- package/build/components/link-control/link-preview.js +19 -6
- package/build/components/link-control/link-preview.js.map +1 -1
- package/build/components/link-control/search-input.js +12 -3
- package/build/components/link-control/search-input.js.map +1 -1
- package/build/components/list-view/block.js +49 -23
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/list-view/branch.js +92 -73
- package/build/components/list-view/branch.js.map +1 -1
- package/build/components/list-view/index.js +39 -16
- package/build/components/list-view/index.js.map +1 -1
- package/build/components/list-view/leaf.js +1 -1
- package/build/components/list-view/leaf.js.map +1 -1
- package/build/components/list-view/use-list-view-client-ids.js +8 -58
- package/build/components/list-view/use-list-view-client-ids.js.map +1 -1
- package/build/components/rich-text/embed-handler-picker.native.js +1 -0
- package/build/components/rich-text/embed-handler-picker.native.js.map +1 -1
- package/build/components/rich-text/format-edit.js +28 -2
- package/build/components/rich-text/format-edit.js.map +1 -1
- package/build/components/rich-text/format-toolbar/index.js +2 -1
- package/build/components/rich-text/format-toolbar/index.js.map +1 -1
- package/build/components/url-input/index.js +11 -4
- package/build/components/url-input/index.js.map +1 -1
- package/build/components/use-setting/index.js +48 -9
- package/build/components/use-setting/index.js.map +1 -1
- package/build/hooks/border.js +5 -5
- package/build/hooks/border.js.map +1 -1
- package/build/hooks/color-panel.js +2 -1
- package/build/hooks/color-panel.js.map +1 -1
- package/build/hooks/duotone.js +16 -5
- package/build/hooks/duotone.js.map +1 -1
- package/build/hooks/font-appearance.js +49 -6
- package/build/hooks/font-appearance.js.map +1 -1
- package/build/hooks/font-family.js +37 -16
- package/build/hooks/font-family.js.map +1 -1
- package/build/hooks/font-size.js +51 -9
- package/build/hooks/font-size.js.map +1 -1
- package/build/hooks/index.js +8 -0
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/index.native.js +8 -0
- package/build/hooks/index.native.js.map +1 -1
- package/build/hooks/letter-spacing.js +44 -7
- package/build/hooks/letter-spacing.js.map +1 -1
- package/build/hooks/line-height.js +45 -8
- package/build/hooks/line-height.js.map +1 -1
- package/build/hooks/margin.js +1 -1
- package/build/hooks/margin.js.map +1 -1
- package/build/hooks/padding.js +1 -1
- package/build/hooks/padding.js.map +1 -1
- package/build/hooks/text-decoration.js +42 -6
- package/build/hooks/text-decoration.js.map +1 -1
- package/build/hooks/text-transform.js +42 -6
- package/build/hooks/text-transform.js.map +1 -1
- package/build/hooks/typography.js +108 -8
- package/build/hooks/typography.js.map +1 -1
- package/build/hooks/use-cached-truthy.js +29 -0
- package/build/hooks/use-cached-truthy.js.map +1 -0
- package/build/index.js +7 -0
- package/build/index.js.map +1 -1
- package/build/layouts/flex.js +120 -28
- package/build/layouts/flex.js.map +1 -1
- package/build/store/actions.js +303 -265
- package/build/store/actions.js.map +1 -1
- package/build/store/index.js +1 -3
- package/build/store/index.js.map +1 -1
- package/build/store/reducer.js +23 -22
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +44 -35
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/alignment-control/ui.js +1 -2
- package/build-module/components/alignment-control/ui.js.map +1 -1
- package/build-module/components/block-icon/index.js +5 -1
- package/build-module/components/block-icon/index.js.map +1 -1
- package/build-module/components/block-inspector/index.js +4 -0
- package/build-module/components/block-inspector/index.js.map +1 -1
- package/build-module/components/block-list/index.native.js +1 -1
- package/build-module/components/block-list/index.native.js.map +1 -1
- package/build-module/components/block-list/use-block-props/use-multi-selection.js +21 -8
- package/build-module/components/block-list/use-block-props/use-multi-selection.js.map +1 -1
- package/build-module/components/block-navigation/dropdown.js +0 -1
- package/build-module/components/block-navigation/dropdown.js.map +1 -1
- package/build-module/components/block-patterns-list/index.js +1 -6
- package/build-module/components/block-patterns-list/index.js.map +1 -1
- package/build-module/components/block-settings/container.native.js +6 -3
- package/build-module/components/block-settings/container.native.js.map +1 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +24 -4
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/block-styles/preview.native.js +2 -2
- package/build-module/components/block-styles/preview.native.js.map +1 -1
- package/build-module/components/colors-gradients/control.js +12 -53
- package/build-module/components/colors-gradients/control.js.map +1 -1
- package/build-module/components/colors-gradients/panel-color-gradient-settings.js +82 -6
- package/build-module/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
- package/build-module/components/duotone-control/index.js +5 -2
- package/build-module/components/duotone-control/index.js.map +1 -1
- package/build-module/components/font-appearance-control/index.js +23 -15
- package/build-module/components/font-appearance-control/index.js.map +1 -1
- package/build-module/components/iframe/index.js +1 -1
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/index.js +3 -1
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/index.native.js +1 -1
- package/build-module/components/index.native.js.map +1 -1
- package/build-module/components/inner-blocks/index.js +6 -5
- package/build-module/components/inner-blocks/index.js.map +1 -1
- package/build-module/components/inner-blocks/index.native.js +5 -4
- package/build-module/components/inner-blocks/index.native.js.map +1 -1
- package/build-module/components/inserter/block-patterns-explorer/explorer.js +50 -0
- package/build-module/components/inserter/block-patterns-explorer/explorer.js.map +1 -0
- package/build-module/components/inserter/block-patterns-explorer/patterns-list.js +92 -0
- package/build-module/components/inserter/block-patterns-explorer/patterns-list.js.map +1 -0
- package/build-module/components/inserter/block-patterns-explorer/sidebar.js +69 -0
- package/build-module/components/inserter/block-patterns-explorer/sidebar.js.map +1 -0
- package/build-module/components/inserter/block-patterns-tab.js +75 -46
- package/build-module/components/inserter/block-patterns-tab.js.map +1 -1
- package/build-module/components/inserter/hooks/use-block-type-impressions.native.js +4 -7
- package/build-module/components/inserter/hooks/use-block-type-impressions.native.js.map +1 -1
- package/build-module/components/inserter/pattern-panel.js +21 -13
- package/build-module/components/inserter/pattern-panel.js.map +1 -1
- package/build-module/components/inspector-controls/groups.js +3 -1
- package/build-module/components/inspector-controls/groups.js.map +1 -1
- package/build-module/components/letter-spacing-control/index.js +9 -6
- package/build-module/components/letter-spacing-control/index.js.map +1 -1
- package/build-module/components/link-control/index.js +88 -36
- package/build-module/components/link-control/index.js.map +1 -1
- package/build-module/components/link-control/link-preview.js +19 -7
- package/build-module/components/link-control/link-preview.js.map +1 -1
- package/build-module/components/link-control/search-input.js +11 -3
- package/build-module/components/link-control/search-input.js.map +1 -1
- package/build-module/components/list-view/block.js +49 -24
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/list-view/branch.js +92 -73
- package/build-module/components/list-view/branch.js.map +1 -1
- package/build-module/components/list-view/index.js +41 -18
- package/build-module/components/list-view/index.js.map +1 -1
- package/build-module/components/list-view/leaf.js +1 -1
- package/build-module/components/list-view/leaf.js.map +1 -1
- package/build-module/components/list-view/use-list-view-client-ids.js +8 -58
- package/build-module/components/list-view/use-list-view-client-ids.js.map +1 -1
- package/build-module/components/rich-text/embed-handler-picker.native.js +1 -0
- package/build-module/components/rich-text/embed-handler-picker.native.js.map +1 -1
- package/build-module/components/rich-text/format-edit.js +28 -3
- package/build-module/components/rich-text/format-edit.js.map +1 -1
- package/build-module/components/rich-text/format-toolbar/index.js +2 -1
- package/build-module/components/rich-text/format-toolbar/index.js.map +1 -1
- package/build-module/components/url-input/index.js +11 -4
- package/build-module/components/url-input/index.js.map +1 -1
- package/build-module/components/use-setting/index.js +48 -9
- package/build-module/components/use-setting/index.js.map +1 -1
- package/build-module/hooks/border.js +5 -5
- package/build-module/hooks/border.js.map +1 -1
- package/build-module/hooks/color-panel.js +2 -1
- package/build-module/hooks/color-panel.js.map +1 -1
- package/build-module/hooks/duotone.js +16 -5
- package/build-module/hooks/duotone.js.map +1 -1
- package/build-module/hooks/font-appearance.js +45 -6
- package/build-module/hooks/font-appearance.js.map +1 -1
- package/build-module/hooks/font-family.js +33 -16
- package/build-module/hooks/font-family.js.map +1 -1
- package/build-module/hooks/font-size.js +47 -9
- package/build-module/hooks/font-size.js.map +1 -1
- package/build-module/hooks/index.js +1 -0
- package/build-module/hooks/index.js.map +1 -1
- package/build-module/hooks/index.native.js +1 -0
- package/build-module/hooks/index.native.js.map +1 -1
- package/build-module/hooks/letter-spacing.js +40 -7
- package/build-module/hooks/letter-spacing.js.map +1 -1
- package/build-module/hooks/line-height.js +41 -8
- package/build-module/hooks/line-height.js.map +1 -1
- package/build-module/hooks/margin.js +1 -1
- package/build-module/hooks/margin.js.map +1 -1
- package/build-module/hooks/padding.js +1 -1
- package/build-module/hooks/padding.js.map +1 -1
- package/build-module/hooks/text-decoration.js +38 -6
- package/build-module/hooks/text-decoration.js.map +1 -1
- package/build-module/hooks/text-transform.js +38 -6
- package/build-module/hooks/text-transform.js.map +1 -1
- package/build-module/hooks/typography.js +117 -17
- package/build-module/hooks/typography.js.map +1 -1
- package/build-module/hooks/use-cached-truthy.js +21 -0
- package/build-module/hooks/use-cached-truthy.js.map +1 -0
- package/build-module/index.js +1 -1
- package/build-module/index.js.map +1 -1
- package/build-module/layouts/flex.js +124 -32
- package/build-module/layouts/flex.js.map +1 -1
- package/build-module/store/actions.js +266 -241
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/index.js +1 -2
- package/build-module/store/index.js.map +1 -1
- package/build-module/store/reducer.js +23 -22
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +42 -30
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +160 -57
- package/build-style/style.css +160 -57
- package/package.json +13 -14
- package/src/components/alignment-control/test/__snapshots__/index.js.snap +0 -2
- package/src/components/alignment-control/ui.js +1 -4
- package/src/components/block-draggable/style.scss +19 -4
- package/src/components/block-icon/index.js +4 -1
- package/src/components/block-inspector/index.js +5 -0
- package/src/components/block-list/index.native.js +1 -1
- package/src/components/block-list/use-block-props/use-multi-selection.js +27 -7
- package/src/components/block-navigation/dropdown.js +0 -1
- package/src/components/block-patterns-list/index.js +1 -8
- package/src/components/block-patterns-list/style.scss +22 -12
- package/src/components/block-settings/container.native.js +7 -0
- package/src/components/block-settings-menu/block-settings-dropdown.js +19 -7
- package/src/components/block-styles/preview.native.js +2 -2
- package/src/components/block-switcher/test/__snapshots__/index.js.snap +1 -1
- package/src/components/color-palette/test/__snapshots__/control.js.snap +88 -63
- package/src/components/colors-gradients/control.js +19 -62
- package/src/components/colors-gradients/panel-color-gradient-settings.js +76 -6
- package/src/components/colors-gradients/style.scss +3 -14
- package/src/components/colors-gradients/test/control.js +0 -16
- package/src/components/duotone-control/index.js +6 -0
- package/src/components/duotone-control/style.scss +27 -12
- package/src/components/font-appearance-control/index.js +22 -14
- package/src/components/iframe/index.js +1 -1
- package/src/components/index.js +3 -4
- package/src/components/index.native.js +1 -4
- package/src/components/inner-blocks/index.js +4 -4
- package/src/components/inner-blocks/index.native.js +7 -4
- package/src/components/inserter/block-patterns-explorer/explorer.js +50 -0
- package/src/components/inserter/block-patterns-explorer/patterns-list.js +122 -0
- package/src/components/inserter/block-patterns-explorer/sidebar.js +73 -0
- package/src/components/inserter/block-patterns-tab.js +107 -80
- package/src/components/inserter/hooks/use-block-type-impressions.native.js +14 -21
- package/src/components/inserter/pattern-panel.js +33 -16
- package/src/components/inserter/style.scss +64 -1
- package/src/components/inserter/test/block-types-tab.native.js +1 -1
- package/src/components/inserter/test/fixtures/index.native.js +12 -0
- package/src/components/inspector-controls/groups.js +4 -0
- package/src/components/letter-spacing-control/index.js +12 -6
- package/src/components/link-control/README.md +7 -0
- package/src/components/link-control/index.js +99 -34
- package/src/components/link-control/link-preview.js +21 -9
- package/src/components/link-control/search-input.js +9 -3
- package/src/components/link-control/style.scss +32 -16
- package/src/components/link-control/test/index.js +179 -4
- package/src/components/list-view/block.js +67 -23
- package/src/components/list-view/branch.js +113 -91
- package/src/components/list-view/index.js +58 -19
- package/src/components/list-view/leaf.js +1 -1
- package/src/components/list-view/style.scss +14 -3
- package/src/components/list-view/use-list-view-client-ids.js +7 -66
- package/src/components/rich-text/embed-handler-picker.native.js +1 -0
- package/src/components/rich-text/format-edit.js +36 -2
- package/src/components/rich-text/format-toolbar/index.js +3 -0
- package/src/components/url-input/index.js +14 -4
- package/src/components/use-setting/index.js +49 -11
- package/src/hooks/border.js +8 -11
- package/src/hooks/color-panel.js +1 -0
- package/src/hooks/duotone.js +21 -7
- package/src/hooks/font-appearance.js +38 -7
- package/src/hooks/font-family.js +29 -13
- package/src/hooks/font-size.js +42 -6
- package/src/hooks/index.js +1 -0
- package/src/hooks/index.native.js +1 -0
- package/src/hooks/layout.scss +3 -1
- package/src/hooks/letter-spacing.js +35 -7
- package/src/hooks/line-height.js +37 -9
- package/src/hooks/margin.js +1 -1
- package/src/hooks/padding.js +1 -1
- package/src/hooks/text-decoration.js +34 -6
- package/src/hooks/text-transform.js +34 -6
- package/src/hooks/typography.js +165 -15
- package/src/hooks/typography.scss +16 -0
- package/src/hooks/use-cached-truthy.js +20 -0
- package/src/index.js +1 -0
- package/src/layouts/flex.js +137 -41
- package/src/store/actions.js +223 -391
- package/src/store/index.js +1 -2
- package/src/store/reducer.js +36 -18
- package/src/store/selectors.js +52 -47
- package/src/store/test/actions.js +395 -694
- package/src/store/test/selectors.js +79 -21
- package/src/style.scss +1 -1
- package/src/utils/test/parse-css-unit-to-px.js +127 -167
- package/build/components/text-decoration-and-transform/index.js +0 -39
- package/build/components/text-decoration-and-transform/index.js.map +0 -1
- package/build/store/controls.js +0 -44
- package/build/store/controls.js.map +0 -1
- package/build-module/components/text-decoration-and-transform/index.js +0 -30
- package/build-module/components/text-decoration-and-transform/index.js.map +0 -1
- package/build-module/store/controls.js +0 -32
- package/build-module/store/controls.js.map +0 -1
- package/src/components/text-decoration-and-transform/index.js +0 -36
- package/src/components/text-decoration-and-transform/style.scss +0 -3
- package/src/store/controls.js +0 -39
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/inserter/block-patterns-explorer/patterns-list.js"],"names":["useMemo","useEffect","_n","sprintf","useDebounce","useAsyncList","__experimentalHeading","Heading","speak","BlockPatternsList","InserterNoResults","useInsertionPoint","usePatternsState","InserterListbox","searchItems","INITIAL_INSERTER_RESULTS","PatternsListHeader","filterValue","filteredBlockPatternsLength","PatternList","selectedCategory","patternCategories","debouncedSpeak","destinationRootClientId","onInsertBlocks","shouldFocusBlock","allPatterns","onSelectBlockPattern","registeredPatternCategories","map","patternCategory","name","filteredBlockPatterns","filter","pattern","categories","length","every","category","includes","count","resultsFoundMessage","currentShownPatterns","step","hasItems"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,OAAT,EAAkBC,SAAlB,QAAmC,oBAAnC;AACA,SAASC,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SAASC,WAAT,EAAsBC,YAAtB,QAA0C,oBAA1C;AACA,SAASC,qBAAqB,IAAIC,OAAlC,QAAiD,uBAAjD;AACA,SAASC,KAAT,QAAsB,iBAAtB;AAEA;AACA;AACA;;AACA,OAAOC,iBAAP,MAA8B,2BAA9B;AACA,OAAOC,iBAAP,MAA8B,eAA9B;AACA,OAAOC,iBAAP,MAA8B,8BAA9B;AACA,OAAOC,gBAAP,MAA6B,6BAA7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,aAAa,EAAGV,qBAFjB;AAGC,IAAA,cAAc,EAAGL,oBAHlB;AAIC,IAAA,WAAW,EAAG;AAJf,IAHF,CAPD,CADD;AAqBA;;AAED,eAAeR,WAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo, useEffect } from '@wordpress/element';\nimport { _n, sprintf } from '@wordpress/i18n';\nimport { useDebounce, useAsyncList } from '@wordpress/compose';\nimport { __experimentalHeading as Heading } from '@wordpress/components';\nimport { speak } from '@wordpress/a11y';\n\n/**\n * Internal dependencies\n */\nimport BlockPatternsList from '../../block-patterns-list';\nimport InserterNoResults from '../no-results';\nimport useInsertionPoint from '../hooks/use-insertion-point';\nimport usePatternsState from '../hooks/use-patterns-state';\nimport InserterListbox from '../../inserter-listbox';\nimport { searchItems } from '../search-items';\n\nconst INITIAL_INSERTER_RESULTS = 2;\n\nfunction PatternsListHeader( { filterValue, filteredBlockPatternsLength } ) {\n\tif ( ! filterValue ) {\n\t\treturn null;\n\t}\n\treturn (\n\t\t<Heading\n\t\t\tlevel={ 2 }\n\t\t\tlineHeight={ '48px' }\n\t\t\tclassName=\"block-editor-block-patterns-explorer__search-results-count\"\n\t\t>\n\t\t\t{ sprintf(\n\t\t\t\t/* translators: %d: number of patterns. %s: block pattern search query */\n\t\t\t\t_n(\n\t\t\t\t\t'%1$d pattern found for \"%2$s\"',\n\t\t\t\t\t'%1$d patterns found for \"%2$s\"',\n\t\t\t\t\tfilteredBlockPatternsLength\n\t\t\t\t),\n\t\t\t\tfilteredBlockPatternsLength,\n\t\t\t\tfilterValue\n\t\t\t) }\n\t\t</Heading>\n\t);\n}\n\nfunction PatternList( { filterValue, selectedCategory, patternCategories } ) {\n\tconst debouncedSpeak = useDebounce( speak, 500 );\n\tconst [ destinationRootClientId, onInsertBlocks ] = useInsertionPoint( {\n\t\tshouldFocusBlock: true,\n\t} );\n\tconst [ allPatterns, , onSelectBlockPattern ] = usePatternsState(\n\t\tonInsertBlocks,\n\t\tdestinationRootClientId\n\t);\n\tconst registeredPatternCategories = useMemo(\n\t\t() =>\n\t\t\tpatternCategories.map(\n\t\t\t\t( patternCategory ) => patternCategory.name\n\t\t\t),\n\t\t[ patternCategories ]\n\t);\n\n\tconst filteredBlockPatterns = useMemo( () => {\n\t\tif ( ! filterValue ) {\n\t\t\treturn allPatterns.filter( ( pattern ) =>\n\t\t\t\tselectedCategory === 'uncategorized'\n\t\t\t\t\t? ! pattern.categories?.length ||\n\t\t\t\t\t pattern.categories.every(\n\t\t\t\t\t\t\t( category ) =>\n\t\t\t\t\t\t\t\t! registeredPatternCategories.includes(\n\t\t\t\t\t\t\t\t\tcategory\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t )\n\t\t\t\t\t: pattern.categories?.includes( selectedCategory )\n\t\t\t);\n\t\t}\n\t\treturn searchItems( allPatterns, filterValue );\n\t}, [ filterValue, selectedCategory, allPatterns ] );\n\n\t// Announce search results on change.\n\tuseEffect( () => {\n\t\tif ( ! filterValue ) {\n\t\t\treturn;\n\t\t}\n\t\tconst count = filteredBlockPatterns.length;\n\t\tconst resultsFoundMessage = sprintf(\n\t\t\t/* translators: %d: number of results. */\n\t\t\t_n( '%d result found.', '%d results found.', count ),\n\t\t\tcount\n\t\t);\n\t\tdebouncedSpeak( resultsFoundMessage );\n\t}, [ filterValue, debouncedSpeak ] );\n\n\tconst currentShownPatterns = useAsyncList( filteredBlockPatterns, {\n\t\tstep: INITIAL_INSERTER_RESULTS,\n\t} );\n\n\tconst hasItems = !! filteredBlockPatterns?.length;\n\treturn (\n\t\t<div className=\"block-editor-block-patterns-explorer__list\">\n\t\t\t{ hasItems && (\n\t\t\t\t<PatternsListHeader\n\t\t\t\t\tfilterValue={ filterValue }\n\t\t\t\t\tfilteredBlockPatternsLength={ filteredBlockPatterns.length }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t<InserterListbox>\n\t\t\t\t{ ! hasItems && <InserterNoResults /> }\n\t\t\t\t{ hasItems && (\n\t\t\t\t\t<BlockPatternsList\n\t\t\t\t\t\tshownPatterns={ currentShownPatterns }\n\t\t\t\t\t\tblockPatterns={ filteredBlockPatterns }\n\t\t\t\t\t\tonClickPattern={ onSelectBlockPattern }\n\t\t\t\t\t\tisDraggable={ false }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</InserterListbox>\n\t\t</div>\n\t);\n}\n\nexport default PatternList;\n"]}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { createElement } from "@wordpress/element";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* WordPress dependencies
|
|
5
|
+
*/
|
|
6
|
+
import { Button, SearchControl } from '@wordpress/components';
|
|
7
|
+
import { __ } from '@wordpress/i18n';
|
|
8
|
+
|
|
9
|
+
function PatternCategoriesList({
|
|
10
|
+
selectedCategory,
|
|
11
|
+
patternCategories,
|
|
12
|
+
onClickCategory
|
|
13
|
+
}) {
|
|
14
|
+
const baseClassName = 'block-editor-block-patterns-explorer__sidebar';
|
|
15
|
+
return createElement("div", {
|
|
16
|
+
className: `${baseClassName}__categories-list`
|
|
17
|
+
}, patternCategories.map(({
|
|
18
|
+
name,
|
|
19
|
+
label
|
|
20
|
+
}) => {
|
|
21
|
+
return createElement(Button, {
|
|
22
|
+
key: name,
|
|
23
|
+
label: label,
|
|
24
|
+
className: `${baseClassName}__categories-list__item`,
|
|
25
|
+
isPressed: selectedCategory === name,
|
|
26
|
+
onClick: () => {
|
|
27
|
+
onClickCategory(name);
|
|
28
|
+
}
|
|
29
|
+
}, label);
|
|
30
|
+
}));
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function PatternsExplorerSearch({
|
|
34
|
+
filterValue,
|
|
35
|
+
setFilterValue
|
|
36
|
+
}) {
|
|
37
|
+
const baseClassName = 'block-editor-block-patterns-explorer__search';
|
|
38
|
+
return createElement("div", {
|
|
39
|
+
className: baseClassName
|
|
40
|
+
}, createElement(SearchControl, {
|
|
41
|
+
onChange: setFilterValue,
|
|
42
|
+
value: filterValue,
|
|
43
|
+
label: __('Search for patterns'),
|
|
44
|
+
placeholder: __('Search')
|
|
45
|
+
}));
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function PatternExplorerSidebar({
|
|
49
|
+
selectedCategory,
|
|
50
|
+
patternCategories,
|
|
51
|
+
onClickCategory,
|
|
52
|
+
filterValue,
|
|
53
|
+
setFilterValue
|
|
54
|
+
}) {
|
|
55
|
+
const baseClassName = 'block-editor-block-patterns-explorer__sidebar';
|
|
56
|
+
return createElement("div", {
|
|
57
|
+
className: baseClassName
|
|
58
|
+
}, createElement(PatternsExplorerSearch, {
|
|
59
|
+
filterValue: filterValue,
|
|
60
|
+
setFilterValue: setFilterValue
|
|
61
|
+
}), !filterValue && createElement(PatternCategoriesList, {
|
|
62
|
+
selectedCategory: selectedCategory,
|
|
63
|
+
patternCategories: patternCategories,
|
|
64
|
+
onClickCategory: onClickCategory
|
|
65
|
+
}));
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export default PatternExplorerSidebar;
|
|
69
|
+
//# sourceMappingURL=sidebar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/inserter/block-patterns-explorer/sidebar.js"],"names":["Button","SearchControl","__","PatternCategoriesList","selectedCategory","patternCategories","onClickCategory","baseClassName","map","name","label","PatternsExplorerSearch","filterValue","setFilterValue","PatternExplorerSidebar"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,MAAT,EAAiBC,aAAjB,QAAsC,uBAAtC;AACA,SAASC,EAAT,QAAmB,iBAAnB;;AAEA,SAASC,qBAAT,CAAgC;AAC/BC,EAAAA,gBAD+B;AAE/BC,EAAAA,iBAF+B;AAG/BC,EAAAA;AAH+B,CAAhC,EAII;AACH,QAAMC,aAAa,GAAG,+CAAtB;AACA,SACC;AAAK,IAAA,SAAS,EAAI,GAAGA,aAAe;AAApC,KACGF,iBAAiB,CAACG,GAAlB,CAAuB,CAAE;AAAEC,IAAAA,IAAF;AAAQC,IAAAA;AAAR,GAAF,KAAuB;AAC/C,WACC,cAAC,MAAD;AACC,MAAA,GAAG,EAAGD,IADP;AAEC,MAAA,KAAK,EAAGC,KAFT;AAGC,MAAA,SAAS,EAAI,GAAGH,aAAe,yBAHhC;AAIC,MAAA,SAAS,EAAGH,gBAAgB,KAAKK,IAJlC;AAKC,MAAA,OAAO,EAAG,MAAM;AACfH,QAAAA,eAAe,CAAEG,IAAF,CAAf;AACA;AAPF,OASGC,KATH,CADD;AAaA,GAdC,CADH,CADD;AAmBA;;AAED,SAASC,sBAAT,CAAiC;AAAEC,EAAAA,WAAF;AAAeC,EAAAA;AAAf,CAAjC,EAAmE;AAClE,QAAMN,aAAa,GAAG,8CAAtB;AACA,SACC;AAAK,IAAA,SAAS,EAAGA;AAAjB,KACC,cAAC,aAAD;AACC,IAAA,QAAQ,EAAGM,cADZ;AAEC,IAAA,KAAK,EAAGD,WAFT;AAGC,IAAA,KAAK,EAAGV,EAAE,CAAE,qBAAF,CAHX;AAIC,IAAA,WAAW,EAAGA,EAAE,CAAE,QAAF;AAJjB,IADD,CADD;AAUA;;AAED,SAASY,sBAAT,CAAiC;AAChCV,EAAAA,gBADgC;AAEhCC,EAAAA,iBAFgC;AAGhCC,EAAAA,eAHgC;AAIhCM,EAAAA,WAJgC;AAKhCC,EAAAA;AALgC,CAAjC,EAMI;AACH,QAAMN,aAAa,GAAG,+CAAtB;AACA,SACC;AAAK,IAAA,SAAS,EAAGA;AAAjB,KACC,cAAC,sBAAD;AACC,IAAA,WAAW,EAAGK,WADf;AAEC,IAAA,cAAc,EAAGC;AAFlB,IADD,EAKG,CAAED,WAAF,IACD,cAAC,qBAAD;AACC,IAAA,gBAAgB,EAAGR,gBADpB;AAEC,IAAA,iBAAiB,EAAGC,iBAFrB;AAGC,IAAA,eAAe,EAAGC;AAHnB,IANF,CADD;AAeA;;AAED,eAAeQ,sBAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Button, SearchControl } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\nfunction PatternCategoriesList( {\n\tselectedCategory,\n\tpatternCategories,\n\tonClickCategory,\n} ) {\n\tconst baseClassName = 'block-editor-block-patterns-explorer__sidebar';\n\treturn (\n\t\t<div className={ `${ baseClassName }__categories-list` }>\n\t\t\t{ patternCategories.map( ( { name, label } ) => {\n\t\t\t\treturn (\n\t\t\t\t\t<Button\n\t\t\t\t\t\tkey={ name }\n\t\t\t\t\t\tlabel={ label }\n\t\t\t\t\t\tclassName={ `${ baseClassName }__categories-list__item` }\n\t\t\t\t\t\tisPressed={ selectedCategory === name }\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tonClickCategory( name );\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ label }\n\t\t\t\t\t</Button>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</div>\n\t);\n}\n\nfunction PatternsExplorerSearch( { filterValue, setFilterValue } ) {\n\tconst baseClassName = 'block-editor-block-patterns-explorer__search';\n\treturn (\n\t\t<div className={ baseClassName }>\n\t\t\t<SearchControl\n\t\t\t\tonChange={ setFilterValue }\n\t\t\t\tvalue={ filterValue }\n\t\t\t\tlabel={ __( 'Search for patterns' ) }\n\t\t\t\tplaceholder={ __( 'Search' ) }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n\nfunction PatternExplorerSidebar( {\n\tselectedCategory,\n\tpatternCategories,\n\tonClickCategory,\n\tfilterValue,\n\tsetFilterValue,\n} ) {\n\tconst baseClassName = 'block-editor-block-patterns-explorer__sidebar';\n\treturn (\n\t\t<div className={ baseClassName }>\n\t\t\t<PatternsExplorerSearch\n\t\t\t\tfilterValue={ filterValue }\n\t\t\t\tsetFilterValue={ setFilterValue }\n\t\t\t/>\n\t\t\t{ ! filterValue && (\n\t\t\t\t<PatternCategoriesList\n\t\t\t\t\tselectedCategory={ selectedCategory }\n\t\t\t\t\tpatternCategories={ patternCategories }\n\t\t\t\t\tonClickCategory={ onClickCategory }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</div>\n\t);\n}\n\nexport default PatternExplorerSidebar;\n"]}
|
|
@@ -1,14 +1,9 @@
|
|
|
1
1
|
import { createElement, Fragment } from "@wordpress/element";
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
* External dependencies
|
|
5
|
-
*/
|
|
6
|
-
import { fromPairs } from 'lodash';
|
|
7
3
|
/**
|
|
8
4
|
* WordPress dependencies
|
|
9
5
|
*/
|
|
10
|
-
|
|
11
|
-
import { useMemo, useCallback, useEffect } from '@wordpress/element';
|
|
6
|
+
import { useMemo, useState, useCallback } from '@wordpress/element';
|
|
12
7
|
import { _x } from '@wordpress/i18n';
|
|
13
8
|
import { useAsyncList } from '@wordpress/compose';
|
|
14
9
|
/**
|
|
@@ -18,50 +13,35 @@ import { useAsyncList } from '@wordpress/compose';
|
|
|
18
13
|
import PatternInserterPanel from './pattern-panel';
|
|
19
14
|
import usePatternsState from './hooks/use-patterns-state';
|
|
20
15
|
import BlockPatternList from '../block-patterns-list';
|
|
16
|
+
import PatternsExplorerModal from './block-patterns-explorer/explorer';
|
|
21
17
|
|
|
22
18
|
function BlockPatternsCategory({
|
|
23
19
|
rootClientId,
|
|
24
20
|
onInsert,
|
|
25
21
|
selectedCategory,
|
|
26
|
-
|
|
22
|
+
populatedCategories
|
|
27
23
|
}) {
|
|
28
|
-
const [allPatterns
|
|
29
|
-
|
|
30
|
-
const populatedCategories = useMemo(() => allCategories.filter(category => allPatterns.some(pattern => {
|
|
24
|
+
const [allPatterns,, onClick] = usePatternsState(onInsert, rootClientId);
|
|
25
|
+
const getPatternIndex = useCallback(pattern => {
|
|
31
26
|
var _pattern$categories;
|
|
32
27
|
|
|
33
|
-
|
|
34
|
-
})).sort(({
|
|
35
|
-
name: currentName
|
|
36
|
-
}, {
|
|
37
|
-
name: nextName
|
|
38
|
-
}) => {
|
|
39
|
-
if (![currentName, nextName].includes('featured')) {
|
|
40
|
-
return 0;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return currentName === 'featured' ? -1 : 1;
|
|
44
|
-
}), [allPatterns, allCategories]);
|
|
45
|
-
const patternCategory = selectedCategory ? selectedCategory : populatedCategories[0];
|
|
46
|
-
useEffect(() => {
|
|
47
|
-
if (allPatterns.some(pattern => getPatternIndex(pattern) === Infinity) && !populatedCategories.find(category => category.name === 'uncategorized')) {
|
|
48
|
-
populatedCategories.push({
|
|
49
|
-
name: 'uncategorized',
|
|
50
|
-
label: _x('Uncategorized')
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
}, [populatedCategories, allPatterns]);
|
|
54
|
-
const getPatternIndex = useCallback(pattern => {
|
|
55
|
-
if (!pattern.categories || !pattern.categories.length) {
|
|
28
|
+
if (!((_pattern$categories = pattern.categories) !== null && _pattern$categories !== void 0 && _pattern$categories.length)) {
|
|
56
29
|
return Infinity;
|
|
57
30
|
}
|
|
58
31
|
|
|
59
|
-
const indexedCategories =
|
|
32
|
+
const indexedCategories = populatedCategories.reduce((accumulator, {
|
|
60
33
|
name
|
|
61
|
-
}, index) =>
|
|
34
|
+
}, index) => {
|
|
35
|
+
accumulator[name] = index;
|
|
36
|
+
return accumulator;
|
|
37
|
+
}, {});
|
|
62
38
|
return Math.min(...pattern.categories.map(cat => indexedCategories[cat] !== undefined ? indexedCategories[cat] : Infinity));
|
|
63
39
|
}, [populatedCategories]);
|
|
64
|
-
const currentCategoryPatterns = useMemo(() => allPatterns.filter(pattern =>
|
|
40
|
+
const currentCategoryPatterns = useMemo(() => allPatterns.filter(pattern => {
|
|
41
|
+
var _pattern$categories2;
|
|
42
|
+
|
|
43
|
+
return selectedCategory.name === 'uncategorized' ? getPatternIndex(pattern) === Infinity : (_pattern$categories2 = pattern.categories) === null || _pattern$categories2 === void 0 ? void 0 : _pattern$categories2.includes(selectedCategory.name);
|
|
44
|
+
}), [allPatterns, selectedCategory]); // Ordering the patterns is important for the async rendering.
|
|
65
45
|
|
|
66
46
|
const orderedPatterns = useMemo(() => {
|
|
67
47
|
return currentCategoryPatterns.sort((a, b) => {
|
|
@@ -69,18 +49,21 @@ function BlockPatternsCategory({
|
|
|
69
49
|
});
|
|
70
50
|
}, [currentCategoryPatterns, getPatternIndex]);
|
|
71
51
|
const currentShownPatterns = useAsyncList(orderedPatterns);
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
52
|
+
|
|
53
|
+
if (!currentCategoryPatterns.length) {
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return createElement("div", {
|
|
58
|
+
className: "block-editor-inserter__panel-content"
|
|
76
59
|
}, createElement(BlockPatternList, {
|
|
77
60
|
shownPatterns: currentShownPatterns,
|
|
78
61
|
blockPatterns: currentCategoryPatterns,
|
|
79
62
|
onClickPattern: onClick,
|
|
80
|
-
label:
|
|
63
|
+
label: selectedCategory.label,
|
|
81
64
|
orientation: "vertical",
|
|
82
65
|
isDraggable: true
|
|
83
|
-
}))
|
|
66
|
+
}));
|
|
84
67
|
}
|
|
85
68
|
|
|
86
69
|
function BlockPatternsTabs({
|
|
@@ -89,12 +72,58 @@ function BlockPatternsTabs({
|
|
|
89
72
|
onClickCategory,
|
|
90
73
|
selectedCategory
|
|
91
74
|
}) {
|
|
92
|
-
|
|
75
|
+
const [showPatternsExplorer, setShowPatternsExplorer] = useState(false);
|
|
76
|
+
const [allPatterns, allCategories] = usePatternsState();
|
|
77
|
+
const hasRegisteredCategory = useCallback(pattern => {
|
|
78
|
+
if (!pattern.categories || !pattern.categories.length) {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return pattern.categories.some(cat => allCategories.some(category => category.name === cat));
|
|
83
|
+
}, [allCategories]); // Remove any empty categories
|
|
84
|
+
|
|
85
|
+
const populatedCategories = useMemo(() => {
|
|
86
|
+
const categories = allCategories.filter(category => allPatterns.some(pattern => {
|
|
87
|
+
var _pattern$categories3;
|
|
88
|
+
|
|
89
|
+
return (_pattern$categories3 = pattern.categories) === null || _pattern$categories3 === void 0 ? void 0 : _pattern$categories3.includes(category.name);
|
|
90
|
+
})).sort(({
|
|
91
|
+
name: currentName
|
|
92
|
+
}, {
|
|
93
|
+
name: nextName
|
|
94
|
+
}) => {
|
|
95
|
+
if (![currentName, nextName].includes('featured')) {
|
|
96
|
+
return 0;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return currentName === 'featured' ? -1 : 1;
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
if (allPatterns.some(pattern => !hasRegisteredCategory(pattern)) && !categories.find(category => category.name === 'uncategorized')) {
|
|
103
|
+
categories.push({
|
|
104
|
+
name: 'uncategorized',
|
|
105
|
+
label: _x('Uncategorized')
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
return categories;
|
|
110
|
+
}, [allPatterns, allCategories]);
|
|
111
|
+
const patternCategory = selectedCategory ? selectedCategory : populatedCategories[0];
|
|
112
|
+
return createElement(Fragment, null, !showPatternsExplorer && createElement(Fragment, null, createElement(PatternInserterPanel, {
|
|
113
|
+
selectedCategory: patternCategory,
|
|
114
|
+
patternCategories: populatedCategories,
|
|
115
|
+
onClickCategory: onClickCategory,
|
|
116
|
+
openPatternExplorer: () => setShowPatternsExplorer(true)
|
|
117
|
+
}), createElement(BlockPatternsCategory, {
|
|
93
118
|
rootClientId: rootClientId,
|
|
94
|
-
selectedCategory: selectedCategory,
|
|
95
119
|
onInsert: onInsert,
|
|
96
|
-
|
|
97
|
-
|
|
120
|
+
selectedCategory: patternCategory,
|
|
121
|
+
populatedCategories: populatedCategories
|
|
122
|
+
})), showPatternsExplorer && createElement(PatternsExplorerModal, {
|
|
123
|
+
initialCategory: patternCategory,
|
|
124
|
+
patternCategories: populatedCategories,
|
|
125
|
+
onModalClose: () => setShowPatternsExplorer(false)
|
|
126
|
+
}));
|
|
98
127
|
}
|
|
99
128
|
|
|
100
129
|
export default BlockPatternsTabs;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/inserter/block-patterns-tab.js"],"names":["
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/inserter/block-patterns-tab.js"],"names":["useMemo","useState","useCallback","_x","useAsyncList","PatternInserterPanel","usePatternsState","BlockPatternList","PatternsExplorerModal","BlockPatternsCategory","rootClientId","onInsert","selectedCategory","populatedCategories","allPatterns","onClick","getPatternIndex","pattern","categories","length","Infinity","indexedCategories","reduce","accumulator","name","index","Math","min","map","cat","undefined","currentCategoryPatterns","filter","includes","orderedPatterns","sort","a","b","currentShownPatterns","label","BlockPatternsTabs","onClickCategory","showPatternsExplorer","setShowPatternsExplorer","allCategories","hasRegisteredCategory","some","category","currentName","nextName","find","push","patternCategory"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,OAAT,EAAkBC,QAAlB,EAA4BC,WAA5B,QAA+C,oBAA/C;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,YAAT,QAA6B,oBAA7B;AAEA;AACA;AACA;;AACA,OAAOC,oBAAP,MAAiC,iBAAjC;AACA,OAAOC,gBAAP,MAA6B,4BAA7B;AACA,OAAOC,gBAAP,MAA6B,wBAA7B;AACA,OAAOC,qBAAP,MAAkC,oCAAlC;;AAEA,SAASC,qBAAT,CAAgC;AAC/BC,EAAAA,YAD+B;AAE/BC,EAAAA,QAF+B;AAG/BC,EAAAA,gBAH+B;AAI/BC,EAAAA;AAJ+B,CAAhC,EAKI;AACH,QAAM,CAAEC,WAAF,GAAiBC,OAAjB,IAA6BT,gBAAgB,CAClDK,QADkD,EAElDD,YAFkD,CAAnD;AAKA,QAAMM,eAAe,GAAGd,WAAW,CAChCe,OAAF,IAAe;AAAA;;AACd,QAAK,yBAAEA,OAAO,CAACC,UAAV,gDAAE,oBAAoBC,MAAtB,CAAL,EAAoC;AACnC,aAAOC,QAAP;AACA;;AACD,UAAMC,iBAAiB,GAAGR,mBAAmB,CAACS,MAApB,CACzB,CAAEC,WAA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nB;AAEC,IAAA,iBAAiB,EAAGvC,mBAFrB;AAGC,IAAA,YAAY,EAAG,MAAM8B,uBAAuB,CAAE,KAAF;AAH7C,IApBF,CADD;AA6BA;;AAED,eAAeH,iBAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo, useState, useCallback } from '@wordpress/element';\nimport { _x } from '@wordpress/i18n';\nimport { useAsyncList } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport PatternInserterPanel from './pattern-panel';\nimport usePatternsState from './hooks/use-patterns-state';\nimport BlockPatternList from '../block-patterns-list';\nimport PatternsExplorerModal from './block-patterns-explorer/explorer';\n\nfunction BlockPatternsCategory( {\n\trootClientId,\n\tonInsert,\n\tselectedCategory,\n\tpopulatedCategories,\n} ) {\n\tconst [ allPatterns, , onClick ] = usePatternsState(\n\t\tonInsert,\n\t\trootClientId\n\t);\n\n\tconst getPatternIndex = useCallback(\n\t\t( pattern ) => {\n\t\t\tif ( ! pattern.categories?.length ) {\n\t\t\t\treturn Infinity;\n\t\t\t}\n\t\t\tconst indexedCategories = populatedCategories.reduce(\n\t\t\t\t( accumulator, { name }, index ) => {\n\t\t\t\t\taccumulator[ name ] = index;\n\t\t\t\t\treturn accumulator;\n\t\t\t\t},\n\t\t\t\t{}\n\t\t\t);\n\t\t\treturn Math.min(\n\t\t\t\t...pattern.categories.map( ( cat ) =>\n\t\t\t\t\tindexedCategories[ cat ] !== undefined\n\t\t\t\t\t\t? indexedCategories[ cat ]\n\t\t\t\t\t\t: Infinity\n\t\t\t\t)\n\t\t\t);\n\t\t},\n\t\t[ populatedCategories ]\n\t);\n\n\tconst currentCategoryPatterns = useMemo(\n\t\t() =>\n\t\t\tallPatterns.filter( ( pattern ) =>\n\t\t\t\tselectedCategory.name === 'uncategorized'\n\t\t\t\t\t? getPatternIndex( pattern ) === Infinity\n\t\t\t\t\t: pattern.categories?.includes( selectedCategory.name )\n\t\t\t),\n\t\t[ allPatterns, selectedCategory ]\n\t);\n\n\t// Ordering the patterns is important for the async rendering.\n\tconst orderedPatterns = useMemo( () => {\n\t\treturn currentCategoryPatterns.sort( ( a, b ) => {\n\t\t\treturn getPatternIndex( a ) - getPatternIndex( b );\n\t\t} );\n\t}, [ currentCategoryPatterns, getPatternIndex ] );\n\n\tconst currentShownPatterns = useAsyncList( orderedPatterns );\n\n\tif ( ! currentCategoryPatterns.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<div className=\"block-editor-inserter__panel-content\">\n\t\t\t<BlockPatternList\n\t\t\t\tshownPatterns={ currentShownPatterns }\n\t\t\t\tblockPatterns={ currentCategoryPatterns }\n\t\t\t\tonClickPattern={ onClick }\n\t\t\t\tlabel={ selectedCategory.label }\n\t\t\t\torientation=\"vertical\"\n\t\t\t\tisDraggable\n\t\t\t/>\n\t\t</div>\n\t);\n}\n\nfunction BlockPatternsTabs( {\n\trootClientId,\n\tonInsert,\n\tonClickCategory,\n\tselectedCategory,\n} ) {\n\tconst [ showPatternsExplorer, setShowPatternsExplorer ] = useState( false );\n\tconst [ allPatterns, allCategories ] = usePatternsState();\n\n\tconst hasRegisteredCategory = useCallback(\n\t\t( pattern ) => {\n\t\t\tif ( ! pattern.categories || ! pattern.categories.length ) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\treturn pattern.categories.some( ( cat ) =>\n\t\t\t\tallCategories.some( ( category ) => category.name === cat )\n\t\t\t);\n\t\t},\n\t\t[ allCategories ]\n\t);\n\n\t// Remove any empty categories\n\tconst populatedCategories = useMemo( () => {\n\t\tconst categories = allCategories\n\t\t\t.filter( ( category ) =>\n\t\t\t\tallPatterns.some( ( pattern ) =>\n\t\t\t\t\tpattern.categories?.includes( category.name )\n\t\t\t\t)\n\t\t\t)\n\t\t\t.sort( ( { name: currentName }, { name: nextName } ) => {\n\t\t\t\tif ( ! [ currentName, nextName ].includes( 'featured' ) ) {\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t\treturn currentName === 'featured' ? -1 : 1;\n\t\t\t} );\n\n\t\tif (\n\t\t\tallPatterns.some(\n\t\t\t\t( pattern ) => ! hasRegisteredCategory( pattern )\n\t\t\t) &&\n\t\t\t! categories.find(\n\t\t\t\t( category ) => category.name === 'uncategorized'\n\t\t\t)\n\t\t) {\n\t\t\tcategories.push( {\n\t\t\t\tname: 'uncategorized',\n\t\t\t\tlabel: _x( 'Uncategorized' ),\n\t\t\t} );\n\t\t}\n\n\t\treturn categories;\n\t}, [ allPatterns, allCategories ] );\n\n\tconst patternCategory = selectedCategory\n\t\t? selectedCategory\n\t\t: populatedCategories[ 0 ];\n\n\treturn (\n\t\t<>\n\t\t\t{ ! showPatternsExplorer && (\n\t\t\t\t<>\n\t\t\t\t\t<PatternInserterPanel\n\t\t\t\t\t\tselectedCategory={ patternCategory }\n\t\t\t\t\t\tpatternCategories={ populatedCategories }\n\t\t\t\t\t\tonClickCategory={ onClickCategory }\n\t\t\t\t\t\topenPatternExplorer={ () =>\n\t\t\t\t\t\t\tsetShowPatternsExplorer( true )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t\t<BlockPatternsCategory\n\t\t\t\t\t\trootClientId={ rootClientId }\n\t\t\t\t\t\tonInsert={ onInsert }\n\t\t\t\t\t\tselectedCategory={ patternCategory }\n\t\t\t\t\t\tpopulatedCategories={ populatedCategories }\n\t\t\t\t\t/>\n\t\t\t\t</>\n\t\t\t) }\n\t\t\t{ showPatternsExplorer && (\n\t\t\t\t<PatternsExplorerModal\n\t\t\t\t\tinitialCategory={ patternCategory }\n\t\t\t\t\tpatternCategories={ populatedCategories }\n\t\t\t\t\tonModalClose={ () => setShowPatternsExplorer( false ) }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport default BlockPatternsTabs;\n"]}
|
|
@@ -11,27 +11,24 @@ import { store as blockEditorStore } from '../../../store';
|
|
|
11
11
|
|
|
12
12
|
function useBlockTypeImpressions(blockTypes) {
|
|
13
13
|
const {
|
|
14
|
-
blockTypeImpressions
|
|
15
|
-
enableEditorOnboarding
|
|
14
|
+
blockTypeImpressions
|
|
16
15
|
} = useSelect(select => {
|
|
17
16
|
const {
|
|
18
17
|
getSettings: getBlockEditorSettings
|
|
19
18
|
} = select(blockEditorStore);
|
|
20
19
|
const {
|
|
21
|
-
editorOnboarding,
|
|
22
20
|
impressions
|
|
23
21
|
} = getBlockEditorSettings();
|
|
24
22
|
return {
|
|
25
|
-
blockTypeImpressions: impressions
|
|
26
|
-
enableEditorOnboarding: editorOnboarding
|
|
23
|
+
blockTypeImpressions: impressions
|
|
27
24
|
};
|
|
28
25
|
}, []);
|
|
29
26
|
const {
|
|
30
27
|
updateSettings
|
|
31
28
|
} = useDispatch(blockEditorStore);
|
|
32
|
-
const items =
|
|
29
|
+
const items = blockTypes.map(blockType => ({ ...blockType,
|
|
33
30
|
isNew: blockTypeImpressions[blockType.name] > 0
|
|
34
|
-
}))
|
|
31
|
+
}));
|
|
35
32
|
|
|
36
33
|
const trackBlockTypeSelected = ({
|
|
37
34
|
name
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/inserter/hooks/use-block-type-impressions.native.js"],"names":["useSelect","useDispatch","setBlockTypeImpressions","store","blockEditorStore","useBlockTypeImpressions","blockTypes","blockTypeImpressions","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/inserter/hooks/use-block-type-impressions.native.js"],"names":["useSelect","useDispatch","setBlockTypeImpressions","store","blockEditorStore","useBlockTypeImpressions","blockTypes","blockTypeImpressions","select","getSettings","getBlockEditorSettings","impressions","updateSettings","items","map","blockType","isNew","name","trackBlockTypeSelected","updatedBlockTypeImpressions"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SAASC,uBAAT,QAAwC,gCAAxC;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,gBAA1C;;AAEA,SAASC,uBAAT,CAAkCC,UAAlC,EAA+C;AAC9C,QAAM;AAAEC,IAAAA;AAAF,MAA2BP,SAAS,CAAIQ,MAAF,IAAc;AACzD,UAAM;AAAEC,MAAAA,WAAW,EAAEC;AAAf,QAA0CF,MAAM,CACrDJ,gBADqD,CAAtD;AAGA,UAAM;AAAEO,MAAAA;AAAF,QAAkBD,sBAAsB,EAA9C;AAEA,WAAO;AACNH,MAAAA,oBAAoB,EAAEI;AADhB,KAAP;AAGA,GATyC,EASvC,EATuC,CAA1C;AAUA,QAAM;AAAEC,IAAAA;AAAF,MAAqBX,WAAW,CAAEG,gBAAF,CAAtC;AAEA,QAAMS,KAAK,GAAGP,UAAU,CAACQ,GAAX,CAAkBC,SAAF,KAAmB,EAChD,GAAGA,SAD6C;AAEhDC,IAAAA,KAAK,EAAET,oBAAoB,CAAEQ,SAAS,CAACE,IAAZ,CAApB,GAAyC;AAFA,GAAnB,CAAhB,CAAd;;AAIA,QAAMC,sBAAsB,GAAG,CAAE;AAAED,IAAAA;AAAF,GAAF,KAAgB;AAC9C,QAAKV,oBAAoB,CAAEU,IAAF,CAApB,GAA+B,CAApC,EAAwC;AACvC,YAAME,2BAA2B,GAAG,EACnC,GAAGZ,oBADgC;AAEnC,SAAEU,IAAF,GAAU;AAFyB,OAApC,CADuC,CAKvC;;AACAL,MAAAA,cAAc,CAAE;AACfD,QAAAA,WAAW,EAAEQ;AADE,OAAF,CAAd,CANuC,CAUvC;;AACAjB,MAAAA,uBAAuB,CAAEiB,2BAAF,CAAvB;AACA;AACD,GAdD;;AAgBA,SAAO;AAAEN,IAAAA,KAAF;AAASK,IAAAA;AAAT,GAAP;AACA;;AAED,eAAeb,uBAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { setBlockTypeImpressions } from '@wordpress/react-native-bridge';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../../store';\n\nfunction useBlockTypeImpressions( blockTypes ) {\n\tconst { blockTypeImpressions } = useSelect( ( select ) => {\n\t\tconst { getSettings: getBlockEditorSettings } = select(\n\t\t\tblockEditorStore\n\t\t);\n\t\tconst { impressions } = getBlockEditorSettings();\n\n\t\treturn {\n\t\t\tblockTypeImpressions: impressions,\n\t\t};\n\t}, [] );\n\tconst { updateSettings } = useDispatch( blockEditorStore );\n\n\tconst items = blockTypes.map( ( blockType ) => ( {\n\t\t...blockType,\n\t\tisNew: blockTypeImpressions[ blockType.name ] > 0,\n\t} ) );\n\tconst trackBlockTypeSelected = ( { name } ) => {\n\t\tif ( blockTypeImpressions[ name ] > 0 ) {\n\t\t\tconst updatedBlockTypeImpressions = {\n\t\t\t\t...blockTypeImpressions,\n\t\t\t\t[ name ]: 0,\n\t\t\t};\n\t\t\t// Persist block type impression to JavaScript store\n\t\t\tupdateSettings( {\n\t\t\t\timpressions: updatedBlockTypeImpressions,\n\t\t\t} );\n\n\t\t\t// Persist block type impression count to native app store\n\t\t\tsetBlockTypeImpressions( updatedBlockTypeImpressions );\n\t\t}\n\t};\n\n\treturn { items, trackBlockTypeSelected };\n}\n\nexport default useBlockTypeImpressions;\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createElement
|
|
1
|
+
import { createElement } from "@wordpress/element";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* External dependencies
|
|
@@ -8,15 +8,18 @@ import classnames from 'classnames';
|
|
|
8
8
|
* WordPress dependencies
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import { SelectControl } from '@wordpress/components';
|
|
12
|
-
import { __ } from '@wordpress/i18n';
|
|
11
|
+
import { Flex, FlexItem, SelectControl, Button } from '@wordpress/components';
|
|
12
|
+
import { __, _x } from '@wordpress/i18n';
|
|
13
|
+
import { useViewportMatch } from '@wordpress/compose';
|
|
13
14
|
|
|
14
15
|
function PatternInserterPanel({
|
|
15
16
|
selectedCategory,
|
|
16
17
|
patternCategories,
|
|
17
18
|
onClickCategory,
|
|
18
|
-
|
|
19
|
+
openPatternExplorer
|
|
19
20
|
}) {
|
|
21
|
+
const isMobile = useViewportMatch('medium', '<');
|
|
22
|
+
|
|
20
23
|
const categoryOptions = () => {
|
|
21
24
|
const options = [];
|
|
22
25
|
patternCategories.map(patternCategory => {
|
|
@@ -32,22 +35,24 @@ function PatternInserterPanel({
|
|
|
32
35
|
onClickCategory(patternCategories.find(patternCategory => selected === patternCategory.name));
|
|
33
36
|
};
|
|
34
37
|
|
|
35
|
-
const
|
|
36
|
-
return classnames('block-editor-inserter__panel-header', 'block-editor-inserter__panel-header-patterns');
|
|
37
|
-
}; // In iOS-based mobile devices, the onBlur will fire when selecting an option
|
|
38
|
+
const className = classnames('block-editor-inserter__panel-header', 'block-editor-inserter__panel-header-patterns'); // In iOS-based mobile devices, the onBlur will fire when selecting an option
|
|
38
39
|
// from a Select element. To prevent closing the useDialog on iOS devices, we
|
|
39
40
|
// stop propagating the onBlur event if there is no relatedTarget, which means
|
|
40
41
|
// that the user most likely did not click on an element within the editor canvas.
|
|
41
42
|
|
|
42
|
-
|
|
43
43
|
const onBlur = event => {
|
|
44
44
|
if (!(event !== null && event !== void 0 && event.relatedTarget)) {
|
|
45
45
|
event.stopPropagation();
|
|
46
46
|
}
|
|
47
47
|
};
|
|
48
48
|
|
|
49
|
-
return createElement(
|
|
50
|
-
|
|
49
|
+
return createElement(Flex, {
|
|
50
|
+
justify: "space-between",
|
|
51
|
+
align: "start",
|
|
52
|
+
gap: "4",
|
|
53
|
+
className: className
|
|
54
|
+
}, createElement(FlexItem, {
|
|
55
|
+
isBlock: true
|
|
51
56
|
}, createElement(SelectControl, {
|
|
52
57
|
className: "block-editor-inserter__panel-dropdown",
|
|
53
58
|
label: __('Filter patterns'),
|
|
@@ -56,9 +61,12 @@ function PatternInserterPanel({
|
|
|
56
61
|
onChange: onChangeSelect,
|
|
57
62
|
onBlur: onBlur,
|
|
58
63
|
options: categoryOptions()
|
|
59
|
-
})), createElement(
|
|
60
|
-
|
|
61
|
-
|
|
64
|
+
})), !isMobile && createElement(FlexItem, null, createElement(Button, {
|
|
65
|
+
variant: "secondary",
|
|
66
|
+
className: "block-editor-inserter__patterns-explorer-expand",
|
|
67
|
+
label: __('Explore all patterns'),
|
|
68
|
+
onClick: () => openPatternExplorer()
|
|
69
|
+
}, _x('Explore', 'Label for showing all block patterns'))));
|
|
62
70
|
}
|
|
63
71
|
|
|
64
72
|
export default PatternInserterPanel;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/inserter/pattern-panel.js"],"names":["classnames","SelectControl","__","PatternInserterPanel","selectedCategory","patternCategories","onClickCategory","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/inserter/pattern-panel.js"],"names":["classnames","Flex","FlexItem","SelectControl","Button","__","_x","useViewportMatch","PatternInserterPanel","selectedCategory","patternCategories","onClickCategory","openPatternExplorer","isMobile","categoryOptions","options","map","patternCategory","push","value","name","label","onChangeSelect","selected","find","className","onBlur","event","relatedTarget","stopPropagation"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,IAAT,EAAeC,QAAf,EAAyBC,aAAzB,EAAwCC,MAAxC,QAAsD,uBAAtD;AACA,SAASC,EAAT,EAAaC,EAAb,QAAuB,iBAAvB;AACA,SAASC,gBAAT,QAAiC,oBAAjC;;AAEA,SAASC,oBAAT,CAA+B;AAC9BC,EAAAA,gBAD8B;AAE9BC,EAAAA,iBAF8B;AAG9BC,EAAAA,eAH8B;AAI9BC,EAAAA;AAJ8B,CAA/B,EAKI;AACH,QAAMC,QAAQ,GAAGN,gBAAgB,CAAE,QAAF,EAAY,GAAZ,CAAjC;;AACA,QAAMO,eAAe,GAAG,MAAM;AAC7B,UAAMC,OAAO,GAAG,EAAhB;AAEAL,IAAAA,iBAAiB,CAACM,GAAlB,CAAyBC,eAAF,IAAuB;AAC7C,aAAOF,OAAO,CAACG,IAAR,CAAc;AACpBC,Q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AAMO,mBAAmB;AAJpC,KAMGN,EAAE,CACH,SADG,EAEH,sCAFG,CANL,CADD,CAlBF,CADD;AAmCA;;AAED,eAAeE,oBAAf","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { Flex, FlexItem, SelectControl, Button } from '@wordpress/components';\nimport { __, _x } from '@wordpress/i18n';\nimport { useViewportMatch } from '@wordpress/compose';\n\nfunction PatternInserterPanel( {\n\tselectedCategory,\n\tpatternCategories,\n\tonClickCategory,\n\topenPatternExplorer,\n} ) {\n\tconst isMobile = useViewportMatch( 'medium', '<' );\n\tconst categoryOptions = () => {\n\t\tconst options = [];\n\n\t\tpatternCategories.map( ( patternCategory ) => {\n\t\t\treturn options.push( {\n\t\t\t\tvalue: patternCategory.name,\n\t\t\t\tlabel: patternCategory.label,\n\t\t\t} );\n\t\t} );\n\n\t\treturn options;\n\t};\n\n\tconst onChangeSelect = ( selected ) => {\n\t\tonClickCategory(\n\t\t\tpatternCategories.find(\n\t\t\t\t( patternCategory ) => selected === patternCategory.name\n\t\t\t)\n\t\t);\n\t};\n\n\tconst className = classnames(\n\t\t'block-editor-inserter__panel-header',\n\t\t'block-editor-inserter__panel-header-patterns'\n\t);\n\n\t// In iOS-based mobile devices, the onBlur will fire when selecting an option\n\t// from a Select element. To prevent closing the useDialog on iOS devices, we\n\t// stop propagating the onBlur event if there is no relatedTarget, which means\n\t// that the user most likely did not click on an element within the editor canvas.\n\tconst onBlur = ( event ) => {\n\t\tif ( ! event?.relatedTarget ) {\n\t\t\tevent.stopPropagation();\n\t\t}\n\t};\n\n\treturn (\n\t\t<Flex\n\t\t\tjustify=\"space-between\"\n\t\t\talign=\"start\"\n\t\t\tgap=\"4\"\n\t\t\tclassName={ className }\n\t\t>\n\t\t\t<FlexItem isBlock>\n\t\t\t\t<SelectControl\n\t\t\t\t\tclassName=\"block-editor-inserter__panel-dropdown\"\n\t\t\t\t\tlabel={ __( 'Filter patterns' ) }\n\t\t\t\t\thideLabelFromVision\n\t\t\t\t\tvalue={ selectedCategory.name }\n\t\t\t\t\tonChange={ onChangeSelect }\n\t\t\t\t\tonBlur={ onBlur }\n\t\t\t\t\toptions={ categoryOptions() }\n\t\t\t\t/>\n\t\t\t</FlexItem>\n\t\t\t{ ! isMobile && (\n\t\t\t\t<FlexItem>\n\t\t\t\t\t<Button\n\t\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\t\tclassName=\"block-editor-inserter__patterns-explorer-expand\"\n\t\t\t\t\t\tlabel={ __( 'Explore all patterns' ) }\n\t\t\t\t\t\tonClick={ () => openPatternExplorer() }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ _x(\n\t\t\t\t\t\t\t'Explore',\n\t\t\t\t\t\t\t'Label for showing all block patterns'\n\t\t\t\t\t\t) }\n\t\t\t\t\t</Button>\n\t\t\t\t</FlexItem>\n\t\t\t) }\n\t\t</Flex>\n\t);\n}\n\nexport default PatternInserterPanel;\n"]}
|
|
@@ -5,10 +5,12 @@ import { createSlotFill } from '@wordpress/components';
|
|
|
5
5
|
const InspectorControlsDefault = createSlotFill('InspectorControls');
|
|
6
6
|
const InspectorControlsAdvanced = createSlotFill('InspectorAdvancedControls');
|
|
7
7
|
const InspectorControlsDimensions = createSlotFill('InspectorControlsDimensions');
|
|
8
|
+
const InspectorControlsTypography = createSlotFill('InspectorControlsTypography');
|
|
8
9
|
const groups = {
|
|
9
10
|
default: InspectorControlsDefault,
|
|
10
11
|
advanced: InspectorControlsAdvanced,
|
|
11
|
-
dimensions: InspectorControlsDimensions
|
|
12
|
+
dimensions: InspectorControlsDimensions,
|
|
13
|
+
typography: InspectorControlsTypography
|
|
12
14
|
};
|
|
13
15
|
export default groups;
|
|
14
16
|
//# sourceMappingURL=groups.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/inspector-controls/groups.js"],"names":["createSlotFill","InspectorControlsDefault","InspectorControlsAdvanced","InspectorControlsDimensions","groups","default","advanced","dimensions"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,cAAT,QAA+B,uBAA/B;AAEA,MAAMC,wBAAwB,GAAGD,cAAc,CAAE,mBAAF,CAA/C;AACA,MAAME,yBAAyB,GAAGF,cAAc,CAAE,2BAAF,CAAhD;AACA,MAAMG,2BAA2B,GAAGH,cAAc,CACjD,6BADiD,CAAlD;
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/inspector-controls/groups.js"],"names":["createSlotFill","InspectorControlsDefault","InspectorControlsAdvanced","InspectorControlsDimensions","InspectorControlsTypography","groups","default","advanced","dimensions","typography"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,cAAT,QAA+B,uBAA/B;AAEA,MAAMC,wBAAwB,GAAGD,cAAc,CAAE,mBAAF,CAA/C;AACA,MAAME,yBAAyB,GAAGF,cAAc,CAAE,2BAAF,CAAhD;AACA,MAAMG,2BAA2B,GAAGH,cAAc,CACjD,6BADiD,CAAlD;AAGA,MAAMI,2BAA2B,GAAGJ,cAAc,CACjD,6BADiD,CAAlD;AAIA,MAAMK,MAAM,GAAG;AACdC,EAAAA,OAAO,EAAEL,wBADK;AAEdM,EAAAA,QAAQ,EAAEL,yBAFI;AAGdM,EAAAA,UAAU,EAAEL,2BAHE;AAIdM,EAAAA,UAAU,EAAEL;AAJE,CAAf;AAOA,eAAeC,MAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createSlotFill } from '@wordpress/components';\n\nconst InspectorControlsDefault = createSlotFill( 'InspectorControls' );\nconst InspectorControlsAdvanced = createSlotFill( 'InspectorAdvancedControls' );\nconst InspectorControlsDimensions = createSlotFill(\n\t'InspectorControlsDimensions'\n);\nconst InspectorControlsTypography = createSlotFill(\n\t'InspectorControlsTypography'\n);\n\nconst groups = {\n\tdefault: InspectorControlsDefault,\n\tadvanced: InspectorControlsAdvanced,\n\tdimensions: InspectorControlsDimensions,\n\ttypography: InspectorControlsTypography,\n};\n\nexport default groups;\n"]}
|
|
@@ -13,15 +13,18 @@ import useSetting from '../../components/use-setting';
|
|
|
13
13
|
/**
|
|
14
14
|
* Control for letter-spacing.
|
|
15
15
|
*
|
|
16
|
-
* @param {Object} props
|
|
17
|
-
* @param {string} props.value
|
|
18
|
-
* @param {Function} props.onChange
|
|
19
|
-
* @
|
|
16
|
+
* @param {Object} props Component props.
|
|
17
|
+
* @param {string} props.value Currently selected letter-spacing.
|
|
18
|
+
* @param {Function} props.onChange Handles change in letter-spacing selection.
|
|
19
|
+
* @param {boolean} props.__unstableInputWidth Input width to pass through to inner UnitControl.
|
|
20
|
+
*
|
|
21
|
+
* @return {WPElement} Letter-spacing control.
|
|
20
22
|
*/
|
|
21
23
|
|
|
22
24
|
export default function LetterSpacingControl({
|
|
23
25
|
value,
|
|
24
|
-
onChange
|
|
26
|
+
onChange,
|
|
27
|
+
__unstableInputWidth = '60px'
|
|
25
28
|
}) {
|
|
26
29
|
const units = useCustomUnits({
|
|
27
30
|
availableUnits: useSetting('spacing.units') || ['px', 'em', 'rem'],
|
|
@@ -34,7 +37,7 @@ export default function LetterSpacingControl({
|
|
|
34
37
|
return createElement(UnitControl, {
|
|
35
38
|
label: __('Letter-spacing'),
|
|
36
39
|
value: value,
|
|
37
|
-
__unstableInputWidth:
|
|
40
|
+
__unstableInputWidth: __unstableInputWidth,
|
|
38
41
|
units: units,
|
|
39
42
|
onChange: onChange
|
|
40
43
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/letter-spacing-control/index.js"],"names":["__experimentalUnitControl","UnitControl","__experimentalUseCustomUnits","useCustomUnits","__","useSetting","LetterSpacingControl","value","onChange","units","availableUnits","defaultValues","px","em","rem"],"mappings":";;AAAA;AACA;AACA;AACA,SACCA,yBAAyB,IAAIC,WAD9B,EAECC,4BAA4B,IAAIC,cAFjC,QAGO,uBAHP;AAIA,SAASC,EAAT,QAAmB,iBAAnB;AAEA;AACA;AACA;;AACA,OAAOC,UAAP,MAAuB,8BAAvB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,eAAe,SAASC,oBAAT,CAA+B;
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/letter-spacing-control/index.js"],"names":["__experimentalUnitControl","UnitControl","__experimentalUseCustomUnits","useCustomUnits","__","useSetting","LetterSpacingControl","value","onChange","__unstableInputWidth","units","availableUnits","defaultValues","px","em","rem"],"mappings":";;AAAA;AACA;AACA;AACA,SACCA,yBAAyB,IAAIC,WAD9B,EAECC,4BAA4B,IAAIC,cAFjC,QAGO,uBAHP;AAIA,SAASC,EAAT,QAAmB,iBAAnB;AAEA;AACA;AACA;;AACA,OAAOC,UAAP,MAAuB,8BAAvB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,eAAe,SAASC,oBAAT,CAA+B;AAC7CC,EAAAA,KAD6C;AAE7CC,EAAAA,QAF6C;AAG7CC,EAAAA,oBAAoB,GAAG;AAHsB,CAA/B,EAIX;AACH,QAAMC,KAAK,GAAGP,cAAc,CAAE;AAC7BQ,IAAAA,cAAc,EAAEN,UAAU,CAAE,eAAF,CAAV,IAAiC,CAAE,IAAF,EAAQ,IAAR,EAAc,KAAd,CADpB;AAE7BO,IAAAA,aAAa,EAAE;AAAEC,MAAAA,EAAE,EAAE,GAAN;AAAWC,MAAAA,EAAE,EAAE,IAAf;AAAqBC,MAAAA,GAAG,EAAE;AAA1B;AAFc,GAAF,CAA5B;AAIA,SACC,cAAC,WAAD;AACC,IAAA,KAAK,EAAGX,EAAE,CAAE,gBAAF,CADX;AAEC,IAAA,KAAK,EAAGG,KAFT;AAGC,IAAA,oBAAoB,EAAGE,oBAHxB;AAIC,IAAA,KAAK,EAAGC,KAJT;AAKC,IAAA,QAAQ,EAAGF;AALZ,IADD;AASA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalUnitControl as UnitControl,\n\t__experimentalUseCustomUnits as useCustomUnits,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport useSetting from '../../components/use-setting';\n\n/**\n * Control for letter-spacing.\n *\n * @param {Object} props Component props.\n * @param {string} props.value Currently selected letter-spacing.\n * @param {Function} props.onChange Handles change in letter-spacing selection.\n * @param {boolean} props.__unstableInputWidth Input width to pass through to inner UnitControl.\n *\n * @return {WPElement} Letter-spacing control.\n */\nexport default function LetterSpacingControl( {\n\tvalue,\n\tonChange,\n\t__unstableInputWidth = '60px',\n} ) {\n\tconst units = useCustomUnits( {\n\t\tavailableUnits: useSetting( 'spacing.units' ) || [ 'px', 'em', 'rem' ],\n\t\tdefaultValues: { px: '2', em: '.2', rem: '.2' },\n\t} );\n\treturn (\n\t\t<UnitControl\n\t\t\tlabel={ __( 'Letter-spacing' ) }\n\t\t\tvalue={ value }\n\t\t\t__unstableInputWidth={ __unstableInputWidth }\n\t\t\tunits={ units }\n\t\t\tonChange={ onChange }\n\t\t/>\n\t);\n}\n"]}
|