@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,111 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
|
|
10
|
+
var _element = require("@wordpress/element");
|
|
11
|
+
|
|
12
|
+
var _i18n = require("@wordpress/i18n");
|
|
13
|
+
|
|
14
|
+
var _compose = require("@wordpress/compose");
|
|
15
|
+
|
|
16
|
+
var _components = require("@wordpress/components");
|
|
17
|
+
|
|
18
|
+
var _a11y = require("@wordpress/a11y");
|
|
19
|
+
|
|
20
|
+
var _blockPatternsList = _interopRequireDefault(require("../../block-patterns-list"));
|
|
21
|
+
|
|
22
|
+
var _noResults = _interopRequireDefault(require("../no-results"));
|
|
23
|
+
|
|
24
|
+
var _useInsertionPoint = _interopRequireDefault(require("../hooks/use-insertion-point"));
|
|
25
|
+
|
|
26
|
+
var _usePatternsState = _interopRequireDefault(require("../hooks/use-patterns-state"));
|
|
27
|
+
|
|
28
|
+
var _inserterListbox = _interopRequireDefault(require("../../inserter-listbox"));
|
|
29
|
+
|
|
30
|
+
var _searchItems = require("../search-items");
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* WordPress dependencies
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Internal dependencies
|
|
38
|
+
*/
|
|
39
|
+
const INITIAL_INSERTER_RESULTS = 2;
|
|
40
|
+
|
|
41
|
+
function PatternsListHeader({
|
|
42
|
+
filterValue,
|
|
43
|
+
filteredBlockPatternsLength
|
|
44
|
+
}) {
|
|
45
|
+
if (!filterValue) {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return (0, _element.createElement)(_components.__experimentalHeading, {
|
|
50
|
+
level: 2,
|
|
51
|
+
lineHeight: '48px',
|
|
52
|
+
className: "block-editor-block-patterns-explorer__search-results-count"
|
|
53
|
+
}, (0, _i18n.sprintf)(
|
|
54
|
+
/* translators: %d: number of patterns. %s: block pattern search query */
|
|
55
|
+
(0, _i18n._n)('%1$d pattern found for "%2$s"', '%1$d patterns found for "%2$s"', filteredBlockPatternsLength), filteredBlockPatternsLength, filterValue));
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function PatternList({
|
|
59
|
+
filterValue,
|
|
60
|
+
selectedCategory,
|
|
61
|
+
patternCategories
|
|
62
|
+
}) {
|
|
63
|
+
const debouncedSpeak = (0, _compose.useDebounce)(_a11y.speak, 500);
|
|
64
|
+
const [destinationRootClientId, onInsertBlocks] = (0, _useInsertionPoint.default)({
|
|
65
|
+
shouldFocusBlock: true
|
|
66
|
+
});
|
|
67
|
+
const [allPatterns,, onSelectBlockPattern] = (0, _usePatternsState.default)(onInsertBlocks, destinationRootClientId);
|
|
68
|
+
const registeredPatternCategories = (0, _element.useMemo)(() => patternCategories.map(patternCategory => patternCategory.name), [patternCategories]);
|
|
69
|
+
const filteredBlockPatterns = (0, _element.useMemo)(() => {
|
|
70
|
+
if (!filterValue) {
|
|
71
|
+
return allPatterns.filter(pattern => {
|
|
72
|
+
var _pattern$categories, _pattern$categories2;
|
|
73
|
+
|
|
74
|
+
return selectedCategory === 'uncategorized' ? !((_pattern$categories = pattern.categories) !== null && _pattern$categories !== void 0 && _pattern$categories.length) || pattern.categories.every(category => !registeredPatternCategories.includes(category)) : (_pattern$categories2 = pattern.categories) === null || _pattern$categories2 === void 0 ? void 0 : _pattern$categories2.includes(selectedCategory);
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return (0, _searchItems.searchItems)(allPatterns, filterValue);
|
|
79
|
+
}, [filterValue, selectedCategory, allPatterns]); // Announce search results on change.
|
|
80
|
+
|
|
81
|
+
(0, _element.useEffect)(() => {
|
|
82
|
+
if (!filterValue) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const count = filteredBlockPatterns.length;
|
|
87
|
+
const resultsFoundMessage = (0, _i18n.sprintf)(
|
|
88
|
+
/* translators: %d: number of results. */
|
|
89
|
+
(0, _i18n._n)('%d result found.', '%d results found.', count), count);
|
|
90
|
+
debouncedSpeak(resultsFoundMessage);
|
|
91
|
+
}, [filterValue, debouncedSpeak]);
|
|
92
|
+
const currentShownPatterns = (0, _compose.useAsyncList)(filteredBlockPatterns, {
|
|
93
|
+
step: INITIAL_INSERTER_RESULTS
|
|
94
|
+
});
|
|
95
|
+
const hasItems = !!(filteredBlockPatterns !== null && filteredBlockPatterns !== void 0 && filteredBlockPatterns.length);
|
|
96
|
+
return (0, _element.createElement)("div", {
|
|
97
|
+
className: "block-editor-block-patterns-explorer__list"
|
|
98
|
+
}, hasItems && (0, _element.createElement)(PatternsListHeader, {
|
|
99
|
+
filterValue: filterValue,
|
|
100
|
+
filteredBlockPatternsLength: filteredBlockPatterns.length
|
|
101
|
+
}), (0, _element.createElement)(_inserterListbox.default, null, !hasItems && (0, _element.createElement)(_noResults.default, null), hasItems && (0, _element.createElement)(_blockPatternsList.default, {
|
|
102
|
+
shownPatterns: currentShownPatterns,
|
|
103
|
+
blockPatterns: filteredBlockPatterns,
|
|
104
|
+
onClickPattern: onSelectBlockPattern,
|
|
105
|
+
isDraggable: false
|
|
106
|
+
})));
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
var _default = PatternList;
|
|
110
|
+
exports.default = _default;
|
|
111
|
+
//# sourceMappingURL=patterns-list.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/inserter/block-patterns-explorer/patterns-list.js"],"names":["INITIAL_INSERTER_RESULTS","PatternsListHeader","filterValue","filteredBlockPatternsLength","PatternList","selectedCategory","patternCategories","debouncedSpeak","speak","destinationRootClientId","onInsertBlocks","shouldFocusBlock","allPatterns","onSelectBlockPattern","registeredPatternCategories","map","patternCategory","name","filteredBlockPatterns","filter","pattern","categories","length","every","category","includes","count","resultsFoundMessage","currentShownPatterns","step","hasItems"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAjBA;AACA;AACA;;AAOA;AACA;AACA;AAQA,MAAMA,wBAAwB,GAAG,CAAjC;;AAEA,SAASC,kBAAT,CAA6B;AAAEC,EAAAA,WAAF;AAAeC,EAAAA;AAAf,CAA7B,EAA4E;AAC3E,MAAK,CAAED,WAAP,EAAqB;AACpB,WAAO,IAAP;AACA;;AACD,SACC,4BAAC,iCAAD;AACC,IAAA,KAAK,EAAG,CADT;AAEC,IAAA,UAAU,EAAG,MAFd;AAGC,IAAA,SAAS,EAAC;AAHX,KAKG;AACD;AACA,gBACC,+BADD,EAEC,gCAFD,EAGCC,2BAHD,CAFC,EAODA,2BAPC,EAQDD,WARC,CALH,CADD;AAkBA;;AAED,SAASE,WAAT,CAAsB;AAAEF,EAAAA,WAAF;AAAeG,EAAAA,gBAAf;AAAiCC,EAAAA;AAAjC,CAAtB,EAA6E;AAC5E,QAAMC,cAAc,GAAG,0BAAaC,WAAb,EAAoB,GAApB,CAAvB;AACA,QAAM,CAAEC,uBAAF,EAA2BC,cAA3B,IAA8C,gCAAmB;AACtEC,IAAAA,gBAAgB,EAAE;AADoD,GAAnB,CA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QAAM8B,QAAQ,GAAG,CAAC,EAAEZ,qBAAF,aAAEA,qBAAF,eAAEA,qBAAqB,CAAEI,MAAzB,CAAlB;AACA,SACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACGQ,QAAQ,IACT,4BAAC,kBAAD;AACC,IAAA,WAAW,EAAG5B,WADf;AAEC,IAAA,2BAA2B,EAAGgB,qBAAqB,CAACI;AAFrD,IAFF,EAOC,4BAAC,wBAAD,QACG,CAAEQ,QAAF,IAAc,4BAAC,kBAAD,OADjB,EAEGA,QAAQ,IACT,4BAAC,0BAAD;AACC,IAAA,aAAa,EAAGF,oBADjB;AAEC,IAAA,aAAa,EAAGV,qBAFjB;AAGC,IAAA,cAAc,EAAGL,oBAHlB;AAIC,IAAA,WAAW,EAAG;AAJf,IAHF,CAPD,CADD;AAqBA;;eAEcT,W","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,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _element = require("@wordpress/element");
|
|
9
|
+
|
|
10
|
+
var _components = require("@wordpress/components");
|
|
11
|
+
|
|
12
|
+
var _i18n = require("@wordpress/i18n");
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* WordPress dependencies
|
|
16
|
+
*/
|
|
17
|
+
function PatternCategoriesList({
|
|
18
|
+
selectedCategory,
|
|
19
|
+
patternCategories,
|
|
20
|
+
onClickCategory
|
|
21
|
+
}) {
|
|
22
|
+
const baseClassName = 'block-editor-block-patterns-explorer__sidebar';
|
|
23
|
+
return (0, _element.createElement)("div", {
|
|
24
|
+
className: `${baseClassName}__categories-list`
|
|
25
|
+
}, patternCategories.map(({
|
|
26
|
+
name,
|
|
27
|
+
label
|
|
28
|
+
}) => {
|
|
29
|
+
return (0, _element.createElement)(_components.Button, {
|
|
30
|
+
key: name,
|
|
31
|
+
label: label,
|
|
32
|
+
className: `${baseClassName}__categories-list__item`,
|
|
33
|
+
isPressed: selectedCategory === name,
|
|
34
|
+
onClick: () => {
|
|
35
|
+
onClickCategory(name);
|
|
36
|
+
}
|
|
37
|
+
}, label);
|
|
38
|
+
}));
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function PatternsExplorerSearch({
|
|
42
|
+
filterValue,
|
|
43
|
+
setFilterValue
|
|
44
|
+
}) {
|
|
45
|
+
const baseClassName = 'block-editor-block-patterns-explorer__search';
|
|
46
|
+
return (0, _element.createElement)("div", {
|
|
47
|
+
className: baseClassName
|
|
48
|
+
}, (0, _element.createElement)(_components.SearchControl, {
|
|
49
|
+
onChange: setFilterValue,
|
|
50
|
+
value: filterValue,
|
|
51
|
+
label: (0, _i18n.__)('Search for patterns'),
|
|
52
|
+
placeholder: (0, _i18n.__)('Search')
|
|
53
|
+
}));
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function PatternExplorerSidebar({
|
|
57
|
+
selectedCategory,
|
|
58
|
+
patternCategories,
|
|
59
|
+
onClickCategory,
|
|
60
|
+
filterValue,
|
|
61
|
+
setFilterValue
|
|
62
|
+
}) {
|
|
63
|
+
const baseClassName = 'block-editor-block-patterns-explorer__sidebar';
|
|
64
|
+
return (0, _element.createElement)("div", {
|
|
65
|
+
className: baseClassName
|
|
66
|
+
}, (0, _element.createElement)(PatternsExplorerSearch, {
|
|
67
|
+
filterValue: filterValue,
|
|
68
|
+
setFilterValue: setFilterValue
|
|
69
|
+
}), !filterValue && (0, _element.createElement)(PatternCategoriesList, {
|
|
70
|
+
selectedCategory: selectedCategory,
|
|
71
|
+
patternCategories: patternCategories,
|
|
72
|
+
onClickCategory: onClickCategory
|
|
73
|
+
}));
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
var _default = PatternExplorerSidebar;
|
|
77
|
+
exports.default = _default;
|
|
78
|
+
//# sourceMappingURL=sidebar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/inserter/block-patterns-explorer/sidebar.js"],"names":["PatternCategoriesList","selectedCategory","patternCategories","onClickCategory","baseClassName","map","name","label","PatternsExplorerSearch","filterValue","setFilterValue","PatternExplorerSidebar"],"mappings":";;;;;;;;;AAGA;;AACA;;AAJA;AACA;AACA;AAIA,SAASA,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,4BAAC,kBAAD;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,4BAAC,yBAAD;AACC,IAAA,QAAQ,EAAGM,cADZ;AAEC,IAAA,KAAK,EAAGD,WAFT;AAGC,IAAA,KAAK,EAAG,cAAI,qBAAJ,CAHT;AAIC,IAAA,WAAW,EAAG,cAAI,QAAJ;AAJf,IADD,CADD;AAUA;;AAED,SAASE,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,4BAAC,sBAAD;AACC,IAAA,WAAW,EAAGK,WADf;AAEC,IAAA,cAAc,EAAGC;AAFlB,IADD,EAKG,CAAED,WAAF,IACD,4BAAC,qBAAD;AACC,IAAA,gBAAgB,EAAGR,gBADpB;AAEC,IAAA,iBAAiB,EAAGC,iBAFrB;AAGC,IAAA,eAAe,EAAGC;AAHnB,IANF,CADD;AAeA;;eAEcQ,sB","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"]}
|
|
@@ -9,8 +9,6 @@ exports.default = void 0;
|
|
|
9
9
|
|
|
10
10
|
var _element = require("@wordpress/element");
|
|
11
11
|
|
|
12
|
-
var _lodash = require("lodash");
|
|
13
|
-
|
|
14
12
|
var _i18n = require("@wordpress/i18n");
|
|
15
13
|
|
|
16
14
|
var _compose = require("@wordpress/compose");
|
|
@@ -21,9 +19,7 @@ var _usePatternsState = _interopRequireDefault(require("./hooks/use-patterns-sta
|
|
|
21
19
|
|
|
22
20
|
var _blockPatternsList = _interopRequireDefault(require("../block-patterns-list"));
|
|
23
21
|
|
|
24
|
-
|
|
25
|
-
* External dependencies
|
|
26
|
-
*/
|
|
22
|
+
var _explorer = _interopRequireDefault(require("./block-patterns-explorer/explorer"));
|
|
27
23
|
|
|
28
24
|
/**
|
|
29
25
|
* WordPress dependencies
|
|
@@ -36,45 +32,29 @@ function BlockPatternsCategory({
|
|
|
36
32
|
rootClientId,
|
|
37
33
|
onInsert,
|
|
38
34
|
selectedCategory,
|
|
39
|
-
|
|
35
|
+
populatedCategories
|
|
40
36
|
}) {
|
|
41
|
-
const [allPatterns
|
|
42
|
-
|
|
43
|
-
const populatedCategories = (0, _element.useMemo)(() => allCategories.filter(category => allPatterns.some(pattern => {
|
|
37
|
+
const [allPatterns,, onClick] = (0, _usePatternsState.default)(onInsert, rootClientId);
|
|
38
|
+
const getPatternIndex = (0, _element.useCallback)(pattern => {
|
|
44
39
|
var _pattern$categories;
|
|
45
40
|
|
|
46
|
-
|
|
47
|
-
})).sort(({
|
|
48
|
-
name: currentName
|
|
49
|
-
}, {
|
|
50
|
-
name: nextName
|
|
51
|
-
}) => {
|
|
52
|
-
if (![currentName, nextName].includes('featured')) {
|
|
53
|
-
return 0;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
return currentName === 'featured' ? -1 : 1;
|
|
57
|
-
}), [allPatterns, allCategories]);
|
|
58
|
-
const patternCategory = selectedCategory ? selectedCategory : populatedCategories[0];
|
|
59
|
-
(0, _element.useEffect)(() => {
|
|
60
|
-
if (allPatterns.some(pattern => getPatternIndex(pattern) === Infinity) && !populatedCategories.find(category => category.name === 'uncategorized')) {
|
|
61
|
-
populatedCategories.push({
|
|
62
|
-
name: 'uncategorized',
|
|
63
|
-
label: (0, _i18n._x)('Uncategorized')
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
}, [populatedCategories, allPatterns]);
|
|
67
|
-
const getPatternIndex = (0, _element.useCallback)(pattern => {
|
|
68
|
-
if (!pattern.categories || !pattern.categories.length) {
|
|
41
|
+
if (!((_pattern$categories = pattern.categories) !== null && _pattern$categories !== void 0 && _pattern$categories.length)) {
|
|
69
42
|
return Infinity;
|
|
70
43
|
}
|
|
71
44
|
|
|
72
|
-
const indexedCategories =
|
|
45
|
+
const indexedCategories = populatedCategories.reduce((accumulator, {
|
|
73
46
|
name
|
|
74
|
-
}, index) =>
|
|
47
|
+
}, index) => {
|
|
48
|
+
accumulator[name] = index;
|
|
49
|
+
return accumulator;
|
|
50
|
+
}, {});
|
|
75
51
|
return Math.min(...pattern.categories.map(cat => indexedCategories[cat] !== undefined ? indexedCategories[cat] : Infinity));
|
|
76
52
|
}, [populatedCategories]);
|
|
77
|
-
const currentCategoryPatterns = (0, _element.useMemo)(() => allPatterns.filter(pattern =>
|
|
53
|
+
const currentCategoryPatterns = (0, _element.useMemo)(() => allPatterns.filter(pattern => {
|
|
54
|
+
var _pattern$categories2;
|
|
55
|
+
|
|
56
|
+
return selectedCategory.name === 'uncategorized' ? getPatternIndex(pattern) === Infinity : (_pattern$categories2 = pattern.categories) === null || _pattern$categories2 === void 0 ? void 0 : _pattern$categories2.includes(selectedCategory.name);
|
|
57
|
+
}), [allPatterns, selectedCategory]); // Ordering the patterns is important for the async rendering.
|
|
78
58
|
|
|
79
59
|
const orderedPatterns = (0, _element.useMemo)(() => {
|
|
80
60
|
return currentCategoryPatterns.sort((a, b) => {
|
|
@@ -82,18 +62,21 @@ function BlockPatternsCategory({
|
|
|
82
62
|
});
|
|
83
63
|
}, [currentCategoryPatterns, getPatternIndex]);
|
|
84
64
|
const currentShownPatterns = (0, _compose.useAsyncList)(orderedPatterns);
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
65
|
+
|
|
66
|
+
if (!currentCategoryPatterns.length) {
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return (0, _element.createElement)("div", {
|
|
71
|
+
className: "block-editor-inserter__panel-content"
|
|
89
72
|
}, (0, _element.createElement)(_blockPatternsList.default, {
|
|
90
73
|
shownPatterns: currentShownPatterns,
|
|
91
74
|
blockPatterns: currentCategoryPatterns,
|
|
92
75
|
onClickPattern: onClick,
|
|
93
|
-
label:
|
|
76
|
+
label: selectedCategory.label,
|
|
94
77
|
orientation: "vertical",
|
|
95
78
|
isDraggable: true
|
|
96
|
-
}))
|
|
79
|
+
}));
|
|
97
80
|
}
|
|
98
81
|
|
|
99
82
|
function BlockPatternsTabs({
|
|
@@ -102,12 +85,58 @@ function BlockPatternsTabs({
|
|
|
102
85
|
onClickCategory,
|
|
103
86
|
selectedCategory
|
|
104
87
|
}) {
|
|
105
|
-
|
|
88
|
+
const [showPatternsExplorer, setShowPatternsExplorer] = (0, _element.useState)(false);
|
|
89
|
+
const [allPatterns, allCategories] = (0, _usePatternsState.default)();
|
|
90
|
+
const hasRegisteredCategory = (0, _element.useCallback)(pattern => {
|
|
91
|
+
if (!pattern.categories || !pattern.categories.length) {
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return pattern.categories.some(cat => allCategories.some(category => category.name === cat));
|
|
96
|
+
}, [allCategories]); // Remove any empty categories
|
|
97
|
+
|
|
98
|
+
const populatedCategories = (0, _element.useMemo)(() => {
|
|
99
|
+
const categories = allCategories.filter(category => allPatterns.some(pattern => {
|
|
100
|
+
var _pattern$categories3;
|
|
101
|
+
|
|
102
|
+
return (_pattern$categories3 = pattern.categories) === null || _pattern$categories3 === void 0 ? void 0 : _pattern$categories3.includes(category.name);
|
|
103
|
+
})).sort(({
|
|
104
|
+
name: currentName
|
|
105
|
+
}, {
|
|
106
|
+
name: nextName
|
|
107
|
+
}) => {
|
|
108
|
+
if (![currentName, nextName].includes('featured')) {
|
|
109
|
+
return 0;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return currentName === 'featured' ? -1 : 1;
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
if (allPatterns.some(pattern => !hasRegisteredCategory(pattern)) && !categories.find(category => category.name === 'uncategorized')) {
|
|
116
|
+
categories.push({
|
|
117
|
+
name: 'uncategorized',
|
|
118
|
+
label: (0, _i18n._x)('Uncategorized')
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
return categories;
|
|
123
|
+
}, [allPatterns, allCategories]);
|
|
124
|
+
const patternCategory = selectedCategory ? selectedCategory : populatedCategories[0];
|
|
125
|
+
return (0, _element.createElement)(_element.Fragment, null, !showPatternsExplorer && (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)(_patternPanel.default, {
|
|
126
|
+
selectedCategory: patternCategory,
|
|
127
|
+
patternCategories: populatedCategories,
|
|
128
|
+
onClickCategory: onClickCategory,
|
|
129
|
+
openPatternExplorer: () => setShowPatternsExplorer(true)
|
|
130
|
+
}), (0, _element.createElement)(BlockPatternsCategory, {
|
|
106
131
|
rootClientId: rootClientId,
|
|
107
|
-
selectedCategory: selectedCategory,
|
|
108
132
|
onInsert: onInsert,
|
|
109
|
-
|
|
110
|
-
|
|
133
|
+
selectedCategory: patternCategory,
|
|
134
|
+
populatedCategories: populatedCategories
|
|
135
|
+
})), showPatternsExplorer && (0, _element.createElement)(_explorer.default, {
|
|
136
|
+
initialCategory: patternCategory,
|
|
137
|
+
patternCategories: populatedCategories,
|
|
138
|
+
onModalClose: () => setShowPatternsExplorer(false)
|
|
139
|
+
}));
|
|
111
140
|
}
|
|
112
141
|
|
|
113
142
|
var _default = BlockPatternsTabs;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/inserter/block-patterns-tab.js"],"names":["BlockPatternsCategory","rootClientId","onInsert","selectedCategory","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/inserter/block-patterns-tab.js"],"names":["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":";;;;;;;;;AAGA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AAbA;AACA;AACA;;AAKA;AACA;AACA;AAMA,SAASA,qBAAT,CAAgC;AAC/BC,EAAAA,YAD+B;AAE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AGC,IAAA,eAAe,EAAG4B,eAHnB;AAIC,IAAA,mBAAmB,EAAG,MACrBE,uBAAuB,CAAE,IAAF;AALzB,IADD,EASC,4BAAC,qBAAD;AACC,IAAA,YAAY,EAAGjC,YADhB;AAEC,IAAA,QAAQ,EAAGC,QAFZ;AAGC,IAAA,gBAAgB,EAAGyC,eAHpB;AAIC,IAAA,mBAAmB,EAAGvC;AAJvB,IATD,CAFF,EAmBG6B,oBAAoB,IACrB,4BAAC,iBAAD;AACC,IAAA,eAAe,EAAGU,eADnB;AAEC,IAAA,iBAAiB,EAAGvC,mBAFrB;AAGC,IAAA,YAAY,EAAG,MAAM8B,uBAAuB,CAAE,KAAF;AAH7C,IApBF,CADD;AA6BA;;eAEcH,iB","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"]}
|
|
@@ -20,27 +20,24 @@ var _store = require("../../../store");
|
|
|
20
20
|
*/
|
|
21
21
|
function useBlockTypeImpressions(blockTypes) {
|
|
22
22
|
const {
|
|
23
|
-
blockTypeImpressions
|
|
24
|
-
enableEditorOnboarding
|
|
23
|
+
blockTypeImpressions
|
|
25
24
|
} = (0, _data.useSelect)(select => {
|
|
26
25
|
const {
|
|
27
26
|
getSettings: getBlockEditorSettings
|
|
28
27
|
} = select(_store.store);
|
|
29
28
|
const {
|
|
30
|
-
editorOnboarding,
|
|
31
29
|
impressions
|
|
32
30
|
} = getBlockEditorSettings();
|
|
33
31
|
return {
|
|
34
|
-
blockTypeImpressions: impressions
|
|
35
|
-
enableEditorOnboarding: editorOnboarding
|
|
32
|
+
blockTypeImpressions: impressions
|
|
36
33
|
};
|
|
37
34
|
}, []);
|
|
38
35
|
const {
|
|
39
36
|
updateSettings
|
|
40
37
|
} = (0, _data.useDispatch)(_store.store);
|
|
41
|
-
const items =
|
|
38
|
+
const items = blockTypes.map(blockType => ({ ...blockType,
|
|
42
39
|
isNew: blockTypeImpressions[blockType.name] > 0
|
|
43
|
-
}))
|
|
40
|
+
}));
|
|
44
41
|
|
|
45
42
|
const trackBlockTypeSelected = ({
|
|
46
43
|
name
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/inserter/hooks/use-block-type-impressions.native.js"],"names":["useBlockTypeImpressions","blockTypes","blockTypeImpressions","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/inserter/hooks/use-block-type-impressions.native.js"],"names":["useBlockTypeImpressions","blockTypes","blockTypeImpressions","select","getSettings","getBlockEditorSettings","blockEditorStore","impressions","updateSettings","items","map","blockType","isNew","name","trackBlockTypeSelected","updatedBlockTypeImpressions"],"mappings":";;;;;;;AAGA;;AACA;;AAKA;;AATA;AACA;AACA;;AAIA;AACA;AACA;AAGA,SAASA,uBAAT,CAAkCC,UAAlC,EAA+C;AAC9C,QAAM;AAAEC,IAAAA;AAAF,MAA2B,qBAAaC,MAAF,IAAc;AACzD,UAAM;AAAEC,MAAAA,WAAW,EAAEC;AAAf,QAA0CF,MAAM,CACrDG,YADqD,CAAtD;AAGA,UAAM;AAAEC,MAAAA;AAAF,QAAkBF,sBAAsB,EAA9C;AAEA,WAAO;AACNH,MAAAA,oBAAoB,EAAEK;AADhB,KAAP;AAGA,GATgC,EAS9B,EAT8B,CAAjC;AAUA,QAAM;AAAEC,IAAAA;AAAF,MAAqB,uBAAaF,YAAb,CAA3B;AAEA,QAAMG,KAAK,GAAGR,UAAU,CAACS,GAAX,CAAkBC,SAAF,KAAmB,EAChD,GAAGA,SAD6C;AAEhDC,IAAAA,KAAK,EAAEV,oBAAoB,CAAES,SAAS,CAACE,IAAZ,CAApB,GAAyC;AAFA,GAAnB,CAAhB,CAAd;;AAIA,QAAMC,sBAAsB,GAAG,CAAE;AAAED,IAAAA;AAAF,GAAF,KAAgB;AAC9C,QAAKX,oBAAoB,CAAEW,IAAF,CAApB,GAA+B,CAApC,EAAwC;AACvC,YAAME,2BAA2B,GAAG,EACnC,GAAGb,oBADgC;AAEnC,SAAEW,IAAF,GAAU;AAFyB,OAApC,CADuC,CAKvC;;AACAL,MAAAA,cAAc,CAAE;AACfD,QAAAA,WAAW,EAAEQ;AADE,OAAF,CAAd,CANuC,CAUvC;;AACA,sDAAyBA,2BAAzB;AACA;AACD,GAdD;;AAgBA,SAAO;AAAEN,IAAAA,KAAF;AAASK,IAAAA;AAAT,GAAP;AACA;;eAEcd,uB","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"]}
|
|
@@ -15,6 +15,8 @@ var _components = require("@wordpress/components");
|
|
|
15
15
|
|
|
16
16
|
var _i18n = require("@wordpress/i18n");
|
|
17
17
|
|
|
18
|
+
var _compose = require("@wordpress/compose");
|
|
19
|
+
|
|
18
20
|
/**
|
|
19
21
|
* External dependencies
|
|
20
22
|
*/
|
|
@@ -26,8 +28,10 @@ function PatternInserterPanel({
|
|
|
26
28
|
selectedCategory,
|
|
27
29
|
patternCategories,
|
|
28
30
|
onClickCategory,
|
|
29
|
-
|
|
31
|
+
openPatternExplorer
|
|
30
32
|
}) {
|
|
33
|
+
const isMobile = (0, _compose.useViewportMatch)('medium', '<');
|
|
34
|
+
|
|
31
35
|
const categoryOptions = () => {
|
|
32
36
|
const options = [];
|
|
33
37
|
patternCategories.map(patternCategory => {
|
|
@@ -43,22 +47,24 @@ function PatternInserterPanel({
|
|
|
43
47
|
onClickCategory(patternCategories.find(patternCategory => selected === patternCategory.name));
|
|
44
48
|
};
|
|
45
49
|
|
|
46
|
-
const
|
|
47
|
-
return (0, _classnames.default)('block-editor-inserter__panel-header', 'block-editor-inserter__panel-header-patterns');
|
|
48
|
-
}; // In iOS-based mobile devices, the onBlur will fire when selecting an option
|
|
50
|
+
const className = (0, _classnames.default)('block-editor-inserter__panel-header', 'block-editor-inserter__panel-header-patterns'); // In iOS-based mobile devices, the onBlur will fire when selecting an option
|
|
49
51
|
// from a Select element. To prevent closing the useDialog on iOS devices, we
|
|
50
52
|
// stop propagating the onBlur event if there is no relatedTarget, which means
|
|
51
53
|
// that the user most likely did not click on an element within the editor canvas.
|
|
52
54
|
|
|
53
|
-
|
|
54
55
|
const onBlur = event => {
|
|
55
56
|
if (!(event !== null && event !== void 0 && event.relatedTarget)) {
|
|
56
57
|
event.stopPropagation();
|
|
57
58
|
}
|
|
58
59
|
};
|
|
59
60
|
|
|
60
|
-
return (0, _element.createElement)(
|
|
61
|
-
|
|
61
|
+
return (0, _element.createElement)(_components.Flex, {
|
|
62
|
+
justify: "space-between",
|
|
63
|
+
align: "start",
|
|
64
|
+
gap: "4",
|
|
65
|
+
className: className
|
|
66
|
+
}, (0, _element.createElement)(_components.FlexItem, {
|
|
67
|
+
isBlock: true
|
|
62
68
|
}, (0, _element.createElement)(_components.SelectControl, {
|
|
63
69
|
className: "block-editor-inserter__panel-dropdown",
|
|
64
70
|
label: (0, _i18n.__)('Filter patterns'),
|
|
@@ -67,9 +73,12 @@ function PatternInserterPanel({
|
|
|
67
73
|
onChange: onChangeSelect,
|
|
68
74
|
onBlur: onBlur,
|
|
69
75
|
options: categoryOptions()
|
|
70
|
-
})), (0, _element.createElement)(
|
|
71
|
-
|
|
72
|
-
|
|
76
|
+
})), !isMobile && (0, _element.createElement)(_components.FlexItem, null, (0, _element.createElement)(_components.Button, {
|
|
77
|
+
variant: "secondary",
|
|
78
|
+
className: "block-editor-inserter__patterns-explorer-expand",
|
|
79
|
+
label: (0, _i18n.__)('Explore all patterns'),
|
|
80
|
+
onClick: () => openPatternExplorer()
|
|
81
|
+
}, (0, _i18n._x)('Explore', 'Label for showing all block patterns'))));
|
|
73
82
|
}
|
|
74
83
|
|
|
75
84
|
var _default = PatternInserterPanel;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/inserter/pattern-panel.js"],"names":["PatternInserterPanel","selectedCategory","patternCategories","onClickCategory","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/inserter/pattern-panel.js"],"names":["PatternInserterPanel","selectedCategory","patternCategories","onClickCategory","openPatternExplorer","isMobile","categoryOptions","options","map","patternCategory","push","value","name","label","onChangeSelect","selected","find","className","onBlur","event","relatedTarget","stopPropagation"],"mappings":";;;;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AAVA;AACA;AACA;;AAGA;AACA;AACA;AAKA,SAASA,oBAAT,CAA+B;AAC9BC,EAAAA,gBAD8B;AAE9BC,EAAAA,iBAF8B;AAG9BC,EAAAA,eAH8B;AAI9BC,EAAAA;AAJ8B,CAA/B,EAKI;AACH,QAAMC,QAAQ,GAAG,+BAAkB,QAAlB,EAA4B,GAA5B,CAAjB;;AACA,QAAMC,eAAe,GAAG,MAAM;AAC7B,UAAMC,OAAO,GAAG,EAAhB;AAEAL,IAAAA,iBAAiB,CAACM,GAAlB,CAAyBC,eAAF,IAAuB;AAC7C,aAAOF,OAAO,CAACG,IAAR,CAAc;AACpBC,QAAAA,KAAK,EAAEF,eAAe,CAACG,IADH;AAEpBC,QAAAA,KAAK,EAAEJ,eAAe,CAACI;AAFH,OAAd,CAAP;AAIA,KALD;AAOA,WAAON,OAAP;AACA,GAXD;;AAaA,QAAMO,cAAc,GAAKC,QAAF,IAAgB;AACtCZ,IAAAA,eAAe,CACdD,iBAAiB,CAACc,IAAlB,CACGP,eAAF,IAAuBM,QAAQ,KAAKN,eAAe,CAACG,IADrD,CADc,CAAf;AAKA,GAND;;AAQA,QAAMK,SAAS,GAAG,yBACjB,qCADiB,EAEjB,8CAFiB,CAAlB,CAvBG,CA4BH;AACA;AACA;AACA;;AACA,QAAMC,MAAM,GAAKC,KAAF,IAAa;AAC3B,QAAK,EAAEA,KAAF,aAAEA,KAAF,eAAEA,KAAK,CAAEC,aAAT,CAAL,EAA8B;AAC7BD,MAAAA,KAAK,CAACE,eAAN;AACA;AACD,GAJD;;AAMA,SACC,4BAAC,gBAAD;AACC,IAAA,OAAO,EAAC,eADT;AAEC,IAAA,KAAK,EAAC,OAFP;AAGC,IAAA,GAAG,EAAC,GAHL;AAIC,IAAA,SAAS,EAAGJ;AAJb,KAMC,4BAAC,oBAAD;AAAU,IAAA,OAAO;AAAjB,KACC,4BAAC,yBAAD;AACC,IAAA,SAAS,EAAC,uCADX;AAEC,IAAA,KAAK,EAAG,cAAI,iBAAJ,CAFT;AAGC,IAAA,mBAAmB,MAHpB;AAIC,IAAA,KAAK,EAAGhB,gBAAgB,CAACW,IAJ1B;AAKC,IAAA,QAAQ,EAAGE,cALZ;AAMC,IAAA,MAAM,EAAGI,MANV;AAOC,IAAA,OAAO,EAAGZ,eAAe;AAP1B,IADD,CAND,EAiBG,CAAED,QAAF,IACD,4BAAC,oBAAD,QACC,4BAAC,kBAAD;AACC,IAAA,OAAO,EAAC,WADT;AAEC,IAAA,SAAS,EAAC,iDAFX;AAGC,IAAA,KAAK,EAAG,cAAI,sBAAJ,CAHT;AAIC,IAAA,OAAO,EAAG,MAAMD,mBAAmB;AAJpC,KAMG,cACD,SADC,EAED,sCAFC,CANH,CADD,CAlBF,CADD;AAmCA;;eAEcJ,oB","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"]}
|
|
@@ -13,10 +13,12 @@ var _components = require("@wordpress/components");
|
|
|
13
13
|
const InspectorControlsDefault = (0, _components.createSlotFill)('InspectorControls');
|
|
14
14
|
const InspectorControlsAdvanced = (0, _components.createSlotFill)('InspectorAdvancedControls');
|
|
15
15
|
const InspectorControlsDimensions = (0, _components.createSlotFill)('InspectorControlsDimensions');
|
|
16
|
+
const InspectorControlsTypography = (0, _components.createSlotFill)('InspectorControlsTypography');
|
|
16
17
|
const groups = {
|
|
17
18
|
default: InspectorControlsDefault,
|
|
18
19
|
advanced: InspectorControlsAdvanced,
|
|
19
|
-
dimensions: InspectorControlsDimensions
|
|
20
|
+
dimensions: InspectorControlsDimensions,
|
|
21
|
+
typography: InspectorControlsTypography
|
|
20
22
|
};
|
|
21
23
|
var _default = groups;
|
|
22
24
|
exports.default = _default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/inspector-controls/groups.js"],"names":["InspectorControlsDefault","InspectorControlsAdvanced","InspectorControlsDimensions","groups","default","advanced","dimensions"],"mappings":";;;;;;;AAGA;;AAHA;AACA;AACA;AAGA,MAAMA,wBAAwB,GAAG,gCAAgB,mBAAhB,CAAjC;AACA,MAAMC,yBAAyB,GAAG,gCAAgB,2BAAhB,CAAlC;AACA,MAAMC,2BAA2B,GAAG,gCACnC,6BADmC,CAApC;AAIA,MAAMC,MAAM,GAAG;AACdC,EAAAA,OAAO,
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/inspector-controls/groups.js"],"names":["InspectorControlsDefault","InspectorControlsAdvanced","InspectorControlsDimensions","InspectorControlsTypography","groups","default","advanced","dimensions","typography"],"mappings":";;;;;;;AAGA;;AAHA;AACA;AACA;AAGA,MAAMA,wBAAwB,GAAG,gCAAgB,mBAAhB,CAAjC;AACA,MAAMC,yBAAyB,GAAG,gCAAgB,2BAAhB,CAAlC;AACA,MAAMC,2BAA2B,GAAG,gCACnC,6BADmC,CAApC;AAGA,MAAMC,2BAA2B,GAAG,gCACnC,6BADmC,CAApC;AAIA,MAAMC,MAAM,GAAG;AACdC,EAAAA,OAAO,EAAEL,wBADK;AAEdM,EAAAA,QAAQ,EAAEL,yBAFI;AAGdM,EAAAA,UAAU,EAAEL,2BAHE;AAIdM,EAAAA,UAAU,EAAEL;AAJE,CAAf;eAOeC,M","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"]}
|