@wordpress/edit-site 3.0.19 → 3.0.20

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.
Files changed (110) hide show
  1. package/build/components/block-editor/index.js +1 -1
  2. package/build/components/block-editor/index.js.map +1 -1
  3. package/build/components/block-editor/resizable-editor.js +37 -7
  4. package/build/components/block-editor/resizable-editor.js.map +1 -1
  5. package/build/components/navigation-sidebar/navigation-panel/constants.js +1 -11
  6. package/build/components/navigation-sidebar/navigation-panel/constants.js.map +1 -1
  7. package/build/plugins/site-export.js +1 -1
  8. package/build/plugins/site-export.js.map +1 -1
  9. package/build-module/components/block-editor/index.js +2 -2
  10. package/build-module/components/block-editor/index.js.map +1 -1
  11. package/build-module/components/block-editor/resizable-editor.js +37 -7
  12. package/build-module/components/block-editor/resizable-editor.js.map +1 -1
  13. package/build-module/components/navigation-sidebar/navigation-panel/constants.js +0 -5
  14. package/build-module/components/navigation-sidebar/navigation-panel/constants.js.map +1 -1
  15. package/build-module/plugins/site-export.js +2 -2
  16. package/build-module/plugins/site-export.js.map +1 -1
  17. package/build-style/style-rtl.css +7 -3
  18. package/build-style/style.css +7 -3
  19. package/package.json +8 -8
  20. package/src/components/block-editor/index.js +2 -2
  21. package/src/components/block-editor/resizable-editor.js +52 -12
  22. package/src/components/global-styles/style.scss +2 -1
  23. package/src/components/navigation-sidebar/navigation-panel/constants.js +0 -15
  24. package/src/components/navigation-sidebar/navigation-toggle/style.scss +8 -4
  25. package/src/plugins/site-export.js +2 -2
  26. package/build/components/navigation-sidebar/navigation-panel/content-navigation-item.js +0 -101
  27. package/build/components/navigation-sidebar/navigation-panel/content-navigation-item.js.map +0 -1
  28. package/build/components/navigation-sidebar/navigation-panel/menus/content-categories.js +0 -82
  29. package/build/components/navigation-sidebar/navigation-panel/menus/content-categories.js.map +0 -1
  30. package/build/components/navigation-sidebar/navigation-panel/menus/content-pages.js +0 -82
  31. package/build/components/navigation-sidebar/navigation-panel/menus/content-pages.js.map +0 -1
  32. package/build/components/navigation-sidebar/navigation-panel/menus/content-posts.js +0 -107
  33. package/build/components/navigation-sidebar/navigation-panel/menus/content-posts.js.map +0 -1
  34. package/build/components/navigation-sidebar/navigation-panel/menus/index.js +0 -57
  35. package/build/components/navigation-sidebar/navigation-panel/menus/index.js.map +0 -1
  36. package/build/components/navigation-sidebar/navigation-panel/menus/template-parts-sub.js +0 -48
  37. package/build/components/navigation-sidebar/navigation-panel/menus/template-parts-sub.js.map +0 -1
  38. package/build/components/navigation-sidebar/navigation-panel/menus/template-parts.js +0 -100
  39. package/build/components/navigation-sidebar/navigation-panel/menus/template-parts.js.map +0 -1
  40. package/build/components/navigation-sidebar/navigation-panel/menus/templates-sub.js +0 -62
  41. package/build/components/navigation-sidebar/navigation-panel/menus/templates-sub.js.map +0 -1
  42. package/build/components/navigation-sidebar/navigation-panel/menus/templates.js +0 -143
  43. package/build/components/navigation-sidebar/navigation-panel/menus/templates.js.map +0 -1
  44. package/build/components/navigation-sidebar/navigation-panel/navigation-entity-items.js +0 -76
  45. package/build/components/navigation-sidebar/navigation-panel/navigation-entity-items.js.map +0 -1
  46. package/build/components/navigation-sidebar/navigation-panel/new-template-dropdown.js +0 -125
  47. package/build/components/navigation-sidebar/navigation-panel/new-template-dropdown.js.map +0 -1
  48. package/build/components/navigation-sidebar/navigation-panel/search-results.js +0 -132
  49. package/build/components/navigation-sidebar/navigation-panel/search-results.js.map +0 -1
  50. package/build/components/navigation-sidebar/navigation-panel/template-navigation-item.js +0 -86
  51. package/build/components/navigation-sidebar/navigation-panel/template-navigation-item.js.map +0 -1
  52. package/build/components/navigation-sidebar/navigation-panel/template-preview.js +0 -46
  53. package/build/components/navigation-sidebar/navigation-panel/template-preview.js.map +0 -1
  54. package/build/components/navigation-sidebar/navigation-panel/use-debounced-search.js +0 -47
  55. package/build/components/navigation-sidebar/navigation-panel/use-debounced-search.js.map +0 -1
  56. package/build/components/navigation-sidebar/navigation-panel/utils.js +0 -21
  57. package/build/components/navigation-sidebar/navigation-panel/utils.js.map +0 -1
  58. package/build/utils/get-closest-available-template.js +0 -48
  59. package/build/utils/get-closest-available-template.js.map +0 -1
  60. package/build-module/components/navigation-sidebar/navigation-panel/content-navigation-item.js +0 -86
  61. package/build-module/components/navigation-sidebar/navigation-panel/content-navigation-item.js.map +0 -1
  62. package/build-module/components/navigation-sidebar/navigation-panel/menus/content-categories.js +0 -65
  63. package/build-module/components/navigation-sidebar/navigation-panel/menus/content-categories.js.map +0 -1
  64. package/build-module/components/navigation-sidebar/navigation-panel/menus/content-pages.js +0 -65
  65. package/build-module/components/navigation-sidebar/navigation-panel/menus/content-pages.js.map +0 -1
  66. package/build-module/components/navigation-sidebar/navigation-panel/menus/content-posts.js +0 -90
  67. package/build-module/components/navigation-sidebar/navigation-panel/menus/content-posts.js.map +0 -1
  68. package/build-module/components/navigation-sidebar/navigation-panel/menus/index.js +0 -40
  69. package/build-module/components/navigation-sidebar/navigation-panel/menus/index.js.map +0 -1
  70. package/build-module/components/navigation-sidebar/navigation-panel/menus/template-parts-sub.js +0 -35
  71. package/build-module/components/navigation-sidebar/navigation-panel/menus/template-parts-sub.js.map +0 -1
  72. package/build-module/components/navigation-sidebar/navigation-panel/menus/template-parts.js +0 -84
  73. package/build-module/components/navigation-sidebar/navigation-panel/menus/template-parts.js.map +0 -1
  74. package/build-module/components/navigation-sidebar/navigation-panel/menus/templates-sub.js +0 -50
  75. package/build-module/components/navigation-sidebar/navigation-panel/menus/templates-sub.js.map +0 -1
  76. package/build-module/components/navigation-sidebar/navigation-panel/menus/templates.js +0 -124
  77. package/build-module/components/navigation-sidebar/navigation-panel/menus/templates.js.map +0 -1
  78. package/build-module/components/navigation-sidebar/navigation-panel/navigation-entity-items.js +0 -65
  79. package/build-module/components/navigation-sidebar/navigation-panel/navigation-entity-items.js.map +0 -1
  80. package/build-module/components/navigation-sidebar/navigation-panel/new-template-dropdown.js +0 -106
  81. package/build-module/components/navigation-sidebar/navigation-panel/new-template-dropdown.js.map +0 -1
  82. package/build-module/components/navigation-sidebar/navigation-panel/search-results.js +0 -116
  83. package/build-module/components/navigation-sidebar/navigation-panel/search-results.js.map +0 -1
  84. package/build-module/components/navigation-sidebar/navigation-panel/template-navigation-item.js +0 -71
  85. package/build-module/components/navigation-sidebar/navigation-panel/template-navigation-item.js.map +0 -1
  86. package/build-module/components/navigation-sidebar/navigation-panel/template-preview.js +0 -38
  87. package/build-module/components/navigation-sidebar/navigation-panel/template-preview.js.map +0 -1
  88. package/build-module/components/navigation-sidebar/navigation-panel/use-debounced-search.js +0 -37
  89. package/build-module/components/navigation-sidebar/navigation-panel/use-debounced-search.js.map +0 -1
  90. package/build-module/components/navigation-sidebar/navigation-panel/utils.js +0 -8
  91. package/build-module/components/navigation-sidebar/navigation-panel/utils.js.map +0 -1
  92. package/build-module/utils/get-closest-available-template.js +0 -40
  93. package/build-module/utils/get-closest-available-template.js.map +0 -1
  94. package/src/components/navigation-sidebar/navigation-panel/content-navigation-item.js +0 -89
  95. package/src/components/navigation-sidebar/navigation-panel/menus/content-categories.js +0 -85
  96. package/src/components/navigation-sidebar/navigation-panel/menus/content-pages.js +0 -85
  97. package/src/components/navigation-sidebar/navigation-panel/menus/content-posts.js +0 -117
  98. package/src/components/navigation-sidebar/navigation-panel/menus/index.js +0 -61
  99. package/src/components/navigation-sidebar/navigation-panel/menus/template-parts-sub.js +0 -34
  100. package/src/components/navigation-sidebar/navigation-panel/menus/template-parts.js +0 -94
  101. package/src/components/navigation-sidebar/navigation-panel/menus/templates-sub.js +0 -42
  102. package/src/components/navigation-sidebar/navigation-panel/menus/templates.js +0 -147
  103. package/src/components/navigation-sidebar/navigation-panel/navigation-entity-items.js +0 -53
  104. package/src/components/navigation-sidebar/navigation-panel/new-template-dropdown.js +0 -110
  105. package/src/components/navigation-sidebar/navigation-panel/search-results.js +0 -117
  106. package/src/components/navigation-sidebar/navigation-panel/template-navigation-item.js +0 -83
  107. package/src/components/navigation-sidebar/navigation-panel/template-preview.js +0 -32
  108. package/src/components/navigation-sidebar/navigation-panel/use-debounced-search.js +0 -47
  109. package/src/components/navigation-sidebar/navigation-panel/utils.js +0 -11
  110. package/src/utils/get-closest-available-template.js +0 -31
@@ -1,125 +0,0 @@
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 = NewTemplateDropdown;
9
-
10
- var _element = require("@wordpress/element");
11
-
12
- var _lodash = require("lodash");
13
-
14
- var _components = require("@wordpress/components");
15
-
16
- var _data = require("@wordpress/data");
17
-
18
- var _i18n = require("@wordpress/i18n");
19
-
20
- var _icons = require("@wordpress/icons");
21
-
22
- var _editor = require("@wordpress/editor");
23
-
24
- var _coreData = require("@wordpress/core-data");
25
-
26
- var _getClosestAvailableTemplate = _interopRequireDefault(require("../../../utils/get-closest-available-template"));
27
-
28
- var _constants = require("./constants");
29
-
30
- var _store = require("../../../store");
31
-
32
- /**
33
- * External dependencies
34
- */
35
-
36
- /**
37
- * WordPress dependencies
38
- */
39
-
40
- /**
41
- * Internal dependencies
42
- */
43
- function NewTemplateDropdown() {
44
- const {
45
- defaultTemplateTypes,
46
- templates
47
- } = (0, _data.useSelect)(select => {
48
- const {
49
- __experimentalGetDefaultTemplateTypes: getDefaultTemplateTypes
50
- } = select(_editor.store);
51
- const templateEntities = select(_coreData.store).getEntityRecords('postType', 'wp_template');
52
- return {
53
- defaultTemplateTypes: getDefaultTemplateTypes(),
54
- templates: templateEntities
55
- };
56
- }, []);
57
- const {
58
- addTemplate
59
- } = (0, _data.useDispatch)(_store.store);
60
-
61
- const createTemplate = slug => {
62
- const closestAvailableTemplate = (0, _getClosestAvailableTemplate.default)(slug, templates);
63
- const {
64
- title,
65
- description
66
- } = (0, _lodash.find)(defaultTemplateTypes, {
67
- slug
68
- });
69
- addTemplate({
70
- content: closestAvailableTemplate.content.raw,
71
- excerpt: description,
72
- // Slugs need to be strings, so this is for template `404`
73
- slug: slug.toString(),
74
- status: 'publish',
75
- title
76
- });
77
- };
78
-
79
- const existingTemplateSlugs = (0, _lodash.map)(templates, 'slug');
80
- const missingTemplates = (0, _lodash.filter)(defaultTemplateTypes, template => (0, _lodash.includes)(_constants.TEMPLATES_NEW_OPTIONS, template.slug) && !(0, _lodash.includes)(existingTemplateSlugs, template.slug));
81
-
82
- if (!missingTemplates.length) {
83
- return null;
84
- }
85
-
86
- return (0, _element.createElement)(_components.DropdownMenu, {
87
- className: "edit-site-navigation-panel__new-template-dropdown",
88
- icon: null,
89
- label: (0, _i18n.__)('Add Template'),
90
- popoverProps: {
91
- noArrow: false
92
- },
93
- toggleProps: {
94
- children: (0, _element.createElement)(_icons.Icon, {
95
- icon: _icons.plus
96
- }),
97
- isSmall: true,
98
- variant: 'tertiary'
99
- }
100
- }, _ref => {
101
- let {
102
- onClose
103
- } = _ref;
104
- return (0, _element.createElement)(_components.NavigableMenu, {
105
- className: "edit-site-navigation-panel__new-template-popover"
106
- }, (0, _element.createElement)(_components.MenuGroup, {
107
- label: (0, _i18n.__)('Add Template')
108
- }, (0, _lodash.map)(missingTemplates, _ref2 => {
109
- let {
110
- title,
111
- description,
112
- slug
113
- } = _ref2;
114
- return (0, _element.createElement)(_components.MenuItem, {
115
- info: description,
116
- key: slug,
117
- onClick: () => {
118
- createTemplate(slug);
119
- onClose();
120
- }
121
- }, title);
122
- })));
123
- });
124
- }
125
- //# sourceMappingURL=new-template-dropdown.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/components/navigation-sidebar/navigation-panel/new-template-dropdown.js"],"names":["NewTemplateDropdown","defaultTemplateTypes","templates","select","__experimentalGetDefaultTemplateTypes","getDefaultTemplateTypes","editorStore","templateEntities","coreStore","getEntityRecords","addTemplate","editSiteStore","createTemplate","slug","closestAvailableTemplate","title","description","content","raw","excerpt","toString","status","existingTemplateSlugs","missingTemplates","template","TEMPLATES_NEW_OPTIONS","length","noArrow","children","plus","is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B,QAAF,IACC,sBAAUC,gCAAV,EAAiCD,QAAQ,CAACX,IAA1C,KACA,CAAE,sBAAUS,qBAAV,EAAiCE,QAAQ,CAACX,IAA1C,CAJqB,CAAzB;;AAOA,MAAK,CAAEU,gBAAgB,CAACG,MAAxB,EAAiC;AAChC,WAAO,IAAP;AACA;;AAED,SACC,4BAAC,wBAAD;AACC,IAAA,SAAS,EAAC,mDADX;AAEC,IAAA,IAAI,EAAG,IAFR;AAGC,IAAA,KAAK,EAAG,cAAI,cAAJ,CAHT;AAIC,IAAA,YAAY,EAAG;AACdC,MAAAA,OAAO,EAAE;AADK,KAJhB;AAOC,IAAA,WAAW,EAAG;AACbC,MAAAA,QAAQ,EAAE,4BAAC,WAAD;AAAM,QAAA,IAAI,EAAGC;AAAb,QADG;AAEbC,MAAAA,OAAO,EAAE,IAFI;AAGbC,MAAAA,OAAO,EAAE;AAHI;AAPf,KAaG;AAAA,QAAE;AAAEC,MAAAA;AAAF,KAAF;AAAA,WACD,4BAAC,yBAAD;AAAe,MAAA,SAAS,EAAC;AAAzB,OACC,4BAAC,qBAAD;AAAW,MAAA,KAAK,EAAG,cAAI,cAAJ;AAAnB,OACG,iBACDT,gBADC,EAED;AAAA,UAAE;AAAER,QAAAA,KAAF;AAASC,QAAAA,WAAT;AAAsBH,QAAAA;AAAtB,OAAF;AAAA,aACC,4BAAC,oBAAD;AACC,QAAA,IAAI,EAAGG,WADR;AAEC,QAAA,GAAG,EAAGH,IAFP;AAGC,QAAA,OAAO,EAAG,MAAM;AACfD,UAAAA,cAAc,CAAEC,IAAF,CAAd;AACAmB,UAAAA,OAAO;AACP;AANF,SAQGjB,KARH,CADD;AAAA,KAFC,CADH,CADD,CADC;AAAA,GAbH,CADD;AAqCA","sourcesContent":["/**\n * External dependencies\n */\nimport { filter, find, includes, map } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tDropdownMenu,\n\tMenuGroup,\n\tMenuItem,\n\tNavigableMenu,\n} from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { Icon, plus } from '@wordpress/icons';\nimport { store as editorStore } from '@wordpress/editor';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport getClosestAvailableTemplate from '../../../utils/get-closest-available-template';\nimport { TEMPLATES_NEW_OPTIONS } from './constants';\nimport { store as editSiteStore } from '../../../store';\n\nexport default function NewTemplateDropdown() {\n\tconst { defaultTemplateTypes, templates } = useSelect( ( select ) => {\n\t\tconst {\n\t\t\t__experimentalGetDefaultTemplateTypes: getDefaultTemplateTypes,\n\t\t} = select( editorStore );\n\t\tconst templateEntities = select( coreStore ).getEntityRecords(\n\t\t\t'postType',\n\t\t\t'wp_template'\n\t\t);\n\t\treturn {\n\t\t\tdefaultTemplateTypes: getDefaultTemplateTypes(),\n\t\t\ttemplates: templateEntities,\n\t\t};\n\t}, [] );\n\tconst { addTemplate } = useDispatch( editSiteStore );\n\n\tconst createTemplate = ( slug ) => {\n\t\tconst closestAvailableTemplate = getClosestAvailableTemplate(\n\t\t\tslug,\n\t\t\ttemplates\n\t\t);\n\t\tconst { title, description } = find( defaultTemplateTypes, { slug } );\n\t\taddTemplate( {\n\t\t\tcontent: closestAvailableTemplate.content.raw,\n\t\t\texcerpt: description,\n\t\t\t// Slugs need to be strings, so this is for template `404`\n\t\t\tslug: slug.toString(),\n\t\t\tstatus: 'publish',\n\t\t\ttitle,\n\t\t} );\n\t};\n\n\tconst existingTemplateSlugs = map( templates, 'slug' );\n\n\tconst missingTemplates = filter(\n\t\tdefaultTemplateTypes,\n\t\t( template ) =>\n\t\t\tincludes( TEMPLATES_NEW_OPTIONS, template.slug ) &&\n\t\t\t! includes( existingTemplateSlugs, template.slug )\n\t);\n\n\tif ( ! missingTemplates.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<DropdownMenu\n\t\t\tclassName=\"edit-site-navigation-panel__new-template-dropdown\"\n\t\t\ticon={ null }\n\t\t\tlabel={ __( 'Add Template' ) }\n\t\t\tpopoverProps={ {\n\t\t\t\tnoArrow: false,\n\t\t\t} }\n\t\t\ttoggleProps={ {\n\t\t\t\tchildren: <Icon icon={ plus } />,\n\t\t\t\tisSmall: true,\n\t\t\t\tvariant: 'tertiary',\n\t\t\t} }\n\t\t>\n\t\t\t{ ( { onClose } ) => (\n\t\t\t\t<NavigableMenu className=\"edit-site-navigation-panel__new-template-popover\">\n\t\t\t\t\t<MenuGroup label={ __( 'Add Template' ) }>\n\t\t\t\t\t\t{ map(\n\t\t\t\t\t\t\tmissingTemplates,\n\t\t\t\t\t\t\t( { title, description, slug } ) => (\n\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\tinfo={ description }\n\t\t\t\t\t\t\t\t\tkey={ slug }\n\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\tcreateTemplate( slug );\n\t\t\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ title }\n\t\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t) }\n\t\t\t\t\t</MenuGroup>\n\t\t\t\t</NavigableMenu>\n\t\t\t) }\n\t\t</DropdownMenu>\n\t);\n}\n"]}
@@ -1,132 +0,0 @@
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 = SearchResults;
9
-
10
- var _element = require("@wordpress/element");
11
-
12
- var _lodash = require("lodash");
13
-
14
- var _components = require("@wordpress/components");
15
-
16
- var _i18n = require("@wordpress/i18n");
17
-
18
- var _utils = require("./utils");
19
-
20
- var _data = require("@wordpress/data");
21
-
22
- var _editor = require("@wordpress/editor");
23
-
24
- var _templateNavigationItem = _interopRequireDefault(require("./template-navigation-item"));
25
-
26
- var _contentNavigationItem = _interopRequireDefault(require("./content-navigation-item"));
27
-
28
- /**
29
- * External dependencies
30
- */
31
-
32
- /**
33
- * WordPress dependencies
34
- */
35
-
36
- /**
37
- * Internal dependencies
38
- */
39
- function SearchResults(_ref) {
40
- let {
41
- items,
42
- search,
43
- disableFilter
44
- } = _ref;
45
- let itemType = null;
46
-
47
- if ((items === null || items === void 0 ? void 0 : items.length) > 0) {
48
- if (items[0].taxonomy) {
49
- itemType = 'taxonomy';
50
- } else {
51
- itemType = items[0].type;
52
- }
53
- }
54
-
55
- const itemInfos = (0, _data.useSelect)(select => {
56
- if (itemType === null || items === null) {
57
- return [];
58
- }
59
-
60
- if (itemType === 'wp_template') {
61
- const {
62
- __experimentalGetTemplateInfo: getTemplateInfo
63
- } = select(_editor.store);
64
- return items.map(item => ({
65
- slug: item.slug,
66
- ...getTemplateInfo(item)
67
- }));
68
- }
69
-
70
- if (itemType === 'taxonomy') {
71
- return items.map(item => ({
72
- slug: item.slug,
73
- title: item.name,
74
- description: item.description
75
- }));
76
- }
77
-
78
- return items.map(item => {
79
- var _item$title, _item$excerpt;
80
-
81
- return {
82
- slug: item.slug,
83
- title: (_item$title = item.title) === null || _item$title === void 0 ? void 0 : _item$title.rendered,
84
- description: (_item$excerpt = item.excerpt) === null || _item$excerpt === void 0 ? void 0 : _item$excerpt.rendered
85
- };
86
- });
87
- }, [items, itemType]);
88
- const itemInfosMap = (0, _element.useMemo)(() => (0, _lodash.keyBy)(itemInfos, 'slug'), [itemInfos]);
89
- const itemsFiltered = (0, _element.useMemo)(() => {
90
- if (items === null || search.length === 0) {
91
- return [];
92
- }
93
-
94
- if (disableFilter) {
95
- return items;
96
- }
97
-
98
- return items.filter(_ref2 => {
99
- let {
100
- slug
101
- } = _ref2;
102
- const {
103
- title,
104
- description
105
- } = itemInfosMap[slug];
106
- return (0, _utils.normalizedSearch)(slug, search) || (0, _utils.normalizedSearch)(title, search) || (0, _utils.normalizedSearch)(description, search);
107
- });
108
- }, [items, itemInfos, search]);
109
- const itemsSorted = (0, _element.useMemo)(() => {
110
- if (!itemsFiltered) {
111
- return [];
112
- }
113
-
114
- return (0, _lodash.sortBy)(itemsFiltered, [_ref3 => {
115
- let {
116
- slug
117
- } = _ref3;
118
- const {
119
- title
120
- } = itemInfosMap[slug];
121
- return !(0, _utils.normalizedSearch)(title, search);
122
- }]);
123
- }, [itemsFiltered, search]);
124
- const ItemComponent = itemType === 'wp_template' || itemType === 'wp_template_part' ? _templateNavigationItem.default : _contentNavigationItem.default;
125
- return (0, _element.createElement)(_components.__experimentalNavigationGroup, {
126
- title: (0, _i18n.__)('Search results')
127
- }, (0, _lodash.map)(itemsSorted, item => (0, _element.createElement)(ItemComponent, {
128
- item: item,
129
- key: `${item.taxonomy || item.type}-${item.id}`
130
- })));
131
- }
132
- //# sourceMappingURL=search-results.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/components/navigation-sidebar/navigation-panel/search-results.js"],"names":["SearchResults","items","search","disableFilter","itemType","length","taxonomy","type","itemInfos","select","__experimentalGetTemplateInfo","getTemplateInfo","editorStore","map","item","slug","title","name","description","rendered","excerpt","itemInfosMap","itemsFiltered","filter","itemsSorted","ItemComponent","TemplateNavigationItem","ContentNavigationItem","id"],"mappings":";;;;;;;;;AAQA;;AALA;;AAMA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AAnBA;AACA;AACA;;AAGA;AACA;AACA;;AAKA;AACA;AACA;AAOe,SAASA,aAAT,OAA2D;AAAA,MAAnC;AAAEC,IAAAA,KAAF;AAASC,IAAAA,MAAT;AAAiBC,IAAAA;AAAjB,GAAmC;AACzE,MAAIC,QAAQ,GAAG,IAAf;;AACA,MAAK,CAAAH,KAAK,SAAL,IAAAA,KAAK,WAAL,YAAAA,KAAK,CAAEI,MAAP,IAAgB,CAArB,EAAyB;AACxB,QAAKJ,KAAK,CAAE,CAAF,CAAL,CAAWK,QAAhB,EAA2B;AAC1BF,MAAAA,QAAQ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AGA,IADR;AAEC,IAAA,GAAG,EAAI,GAAGA,IAAI,CAACR,QAAL,IAAiBQ,IAAI,CAACP,IAAM,IAAIO,IAAI,CAACc,EAAI;AAFpD,IADC,CADH,CADD;AAUA","sourcesContent":["/**\n * External dependencies\n */\nimport { map, sortBy, keyBy } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\nimport { __experimentalNavigationGroup as NavigationGroup } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { normalizedSearch } from './utils';\nimport { useSelect } from '@wordpress/data';\nimport { store as editorStore } from '@wordpress/editor';\nimport TemplateNavigationItem from './template-navigation-item';\nimport ContentNavigationItem from './content-navigation-item';\n\nexport default function SearchResults( { items, search, disableFilter } ) {\n\tlet itemType = null;\n\tif ( items?.length > 0 ) {\n\t\tif ( items[ 0 ].taxonomy ) {\n\t\t\titemType = 'taxonomy';\n\t\t} else {\n\t\t\titemType = items[ 0 ].type;\n\t\t}\n\t}\n\n\tconst itemInfos = useSelect(\n\t\t( select ) => {\n\t\t\tif ( itemType === null || items === null ) {\n\t\t\t\treturn [];\n\t\t\t}\n\n\t\t\tif ( itemType === 'wp_template' ) {\n\t\t\t\tconst {\n\t\t\t\t\t__experimentalGetTemplateInfo: getTemplateInfo,\n\t\t\t\t} = select( editorStore );\n\n\t\t\t\treturn items.map( ( item ) => ( {\n\t\t\t\t\tslug: item.slug,\n\t\t\t\t\t...getTemplateInfo( item ),\n\t\t\t\t} ) );\n\t\t\t}\n\n\t\t\tif ( itemType === 'taxonomy' ) {\n\t\t\t\treturn items.map( ( item ) => ( {\n\t\t\t\t\tslug: item.slug,\n\t\t\t\t\ttitle: item.name,\n\t\t\t\t\tdescription: item.description,\n\t\t\t\t} ) );\n\t\t\t}\n\n\t\t\treturn items.map( ( item ) => ( {\n\t\t\t\tslug: item.slug,\n\t\t\t\ttitle: item.title?.rendered,\n\t\t\t\tdescription: item.excerpt?.rendered,\n\t\t\t} ) );\n\t\t},\n\t\t[ items, itemType ]\n\t);\n\tconst itemInfosMap = useMemo( () => keyBy( itemInfos, 'slug' ), [\n\t\titemInfos,\n\t] );\n\n\tconst itemsFiltered = useMemo( () => {\n\t\tif ( items === null || search.length === 0 ) {\n\t\t\treturn [];\n\t\t}\n\n\t\tif ( disableFilter ) {\n\t\t\treturn items;\n\t\t}\n\n\t\treturn items.filter( ( { slug } ) => {\n\t\t\tconst { title, description } = itemInfosMap[ slug ];\n\n\t\t\treturn (\n\t\t\t\tnormalizedSearch( slug, search ) ||\n\t\t\t\tnormalizedSearch( title, search ) ||\n\t\t\t\tnormalizedSearch( description, search )\n\t\t\t);\n\t\t} );\n\t}, [ items, itemInfos, search ] );\n\n\tconst itemsSorted = useMemo( () => {\n\t\tif ( ! itemsFiltered ) {\n\t\t\treturn [];\n\t\t}\n\n\t\treturn sortBy( itemsFiltered, [\n\t\t\t( { slug } ) => {\n\t\t\t\tconst { title } = itemInfosMap[ slug ];\n\t\t\t\treturn ! normalizedSearch( title, search );\n\t\t\t},\n\t\t] );\n\t}, [ itemsFiltered, search ] );\n\n\tconst ItemComponent =\n\t\titemType === 'wp_template' || itemType === 'wp_template_part'\n\t\t\t? TemplateNavigationItem\n\t\t\t: ContentNavigationItem;\n\n\treturn (\n\t\t<NavigationGroup title={ __( 'Search results' ) }>\n\t\t\t{ map( itemsSorted, ( item ) => (\n\t\t\t\t<ItemComponent\n\t\t\t\t\titem={ item }\n\t\t\t\t\tkey={ `${ item.taxonomy || item.type }-${ item.id }` }\n\t\t\t\t/>\n\t\t\t) ) }\n\t\t</NavigationGroup>\n\t);\n}\n"]}
@@ -1,86 +0,0 @@
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 = TemplateNavigationItem;
9
-
10
- var _element = require("@wordpress/element");
11
-
12
- var _components = require("@wordpress/components");
13
-
14
- var _data = require("@wordpress/data");
15
-
16
- var _i18n = require("@wordpress/i18n");
17
-
18
- var _editor = require("@wordpress/editor");
19
-
20
- var _templatePreview = _interopRequireDefault(require("./template-preview"));
21
-
22
- var _index = require("../index");
23
-
24
- var _store = require("../../../store");
25
-
26
- /**
27
- * WordPress dependencies
28
- */
29
-
30
- /**
31
- * Internal dependencies
32
- */
33
- function TemplateNavigationItem(_ref) {
34
- let {
35
- item
36
- } = _ref;
37
- const {
38
- title,
39
- description
40
- } = (0, _data.useSelect)(select => {
41
- var _item$title;
42
-
43
- return 'wp_template' === item.type ? select(_editor.store).__experimentalGetTemplateInfo(item) : {
44
- title: (item === null || item === void 0 ? void 0 : (_item$title = item.title) === null || _item$title === void 0 ? void 0 : _item$title.rendered) || (item === null || item === void 0 ? void 0 : item.slug),
45
- description: ''
46
- };
47
- }, []);
48
- const {
49
- setTemplate,
50
- setTemplatePart,
51
- setIsNavigationPanelOpened
52
- } = (0, _data.useDispatch)(_store.store);
53
- const [isPreviewVisible, setIsPreviewVisible] = (0, _element.useState)(false);
54
-
55
- if (!item) {
56
- return null;
57
- }
58
-
59
- const onActivateItem = () => {
60
- if ('wp_template' === item.type) {
61
- setTemplate(item.id, item.slug);
62
- } else {
63
- setTemplatePart(item.id);
64
- }
65
-
66
- setIsNavigationPanelOpened(false);
67
- };
68
-
69
- return (0, _element.createElement)(_components.__experimentalNavigationItem, {
70
- className: "edit-site-navigation-panel__template-item",
71
- item: `${item.type}-${item.id}`
72
- }, (0, _element.createElement)(_components.Button, {
73
- onClick: onActivateItem,
74
- onMouseEnter: () => setIsPreviewVisible(true),
75
- onMouseLeave: () => setIsPreviewVisible(false)
76
- }, (0, _element.createElement)("span", {
77
- className: "edit-site-navigation-panel__info-wrapper"
78
- }, (0, _element.createElement)("div", {
79
- className: "edit-site-navigation-panel__template-item-title"
80
- }, 'draft' === item.status && (0, _element.createElement)("em", null, (0, _i18n.__)('[Draft]')), title), description && (0, _element.createElement)("div", {
81
- className: "edit-site-navigation-panel__template-item-description"
82
- }, description))), isPreviewVisible && (0, _element.createElement)(_index.NavigationPanelPreviewFill, null, (0, _element.createElement)(_templatePreview.default, {
83
- rawContent: item.content.raw
84
- })));
85
- }
86
- //# sourceMappingURL=template-navigation-item.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/components/navigation-sidebar/navigation-panel/template-navigation-item.js"],"names":["TemplateNavigationItem","item","title","description","select","type","editorStore","__experimentalGetTemplateInfo","rendered","slug","setTemplate","setTemplatePart","setIsNavigationPanelOpened","editSiteStore","isPreviewVisible","setIsPreviewVisible","onActivateItem","id","status","content","raw"],"mappings":";;;;;;;;;AAQA;;AALA;;AAIA;;AAEA;;AACA;;AAKA;;AACA;;AACA;;AAjBA;AACA;AACA;;AAUA;AACA;AACA;AAKe,SAASA,sBAAT,OAA4C;AAAA,MAAX;AAAEC,IAAAA;AAAF,GAAW;AAC1D,QAAM;AAAEC,IAAAA,KAAF;AAASC,IAAAA;AAAT,MAAyB,qBAC5BC,MAAF;AAAA;;AAAA,WACC,kBAAkBH,IAAI,CAACI,IAAvB,GACGD,MAAM,CAAEE,aAAF,CAAN,CAAsBC,6BAAtB,CAAqDN,IAArD,CADH,GAEG;AACAC,MAAAA,KAAK,EAAE,CAAAD,IAAI,SAAJ,IAAAA,IAAI,WAAJ,2BAAAA,IAAI,CAAEC,KAAN,4DAAaM,QAAb,MAAyBP,IAAzB,aAAyBA,IAAzB,uBAAyBA,IAAI,CAAEQ,IAA/B,CADP;AAEAN,MAAAA,WAAW,EAAE;AAFb,KAHJ;AAAA,GAD8B,EAQ9B,EAR8B,CAA/B;AAUA,QAAM;AACLO,IAAAA,WADK;AAELC,IAAAA,eAFK;AAGLC,IAAAA;AAHK,MAIF,uBAAaC,YAAb,CAJJ;AAKA,QAAM,CAAEC,gBAAF,EAAoBC,mBAApB,IAA4C,uBAAU,KAAV,CAAlD;;AAEA,MAAK,CAAEd,IAAP,EAAc;AACb,WAAO,IAAP;AACA;;AAED,QAAMe,cAAc,GAAG,MAAM;AAC5B,QAAK,kBAAkBf,IAAI,CAACI,IAA5B,EAAmC;AAClCK,MAAAA,WAAW,CAAET,IAAI,CAACgB,EAAP,EAAWhB,IAAI,CAACQ,IAAhB,CAAX;AACA,KAFD,MAEO;AACNE,MAAAA,eAAe,CAAEV,IAAI,CAACgB,EAAP,CAAf;AACA;;AACDL,IAAAA,0BAA0B,CAAE,KAAF,CAA1B;AACA,GAPD;;AASA,SACC,4BAAC,wCAAD;AACC,IAAA,SAAS,EAAC,2CADX;AAEC,IAAA,IAAI,EAAI,GAAGX,IAAI,CAACI,IAAM,IAAIJ,IAAI,CAACgB,EAAI;AAFpC,KAIC,4BAAC,kBAAD;AACC,IAAA,OAAO,EAAGD,cADX;AAEC,IAAA,YAAY,EAAG,MAAMD,mBAAmB,CAAE,IAAF,CAFzC;AAGC,IAAA,YAAY,EAAG,MAAMA,mBAAmB,CAAE,KAAF;AAHzC,KAKC;AAAM,IAAA,SAAS,EAAC;AAAhB,KACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACG,YAAYd,IAAI,CAACiB,MAAjB,IACD,wCAAM,cAAI,SAAJ,CAAN,CAFF,EAIGhB,KAJH,CADD,EAOGC,WAAW,IACZ;AAAK,IAAA,SAAS,EAAC;AAAf,KACGA,WADH,CARF,CALD,CAJD,EAwBGW,gBAAgB,IACjB,4BAAC,iCAAD,QACC,4BAAC,wBAAD;AAAiB,IAAA,UAAU,EAAGb,IAAI,CAACkB,OAAL,CAAaC;AAA3C,IADD,CAzBF,CADD;AAgCA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\t__experimentalNavigationItem as NavigationItem,\n} from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { store as editorStore } from '@wordpress/editor';\n\n/**\n * Internal dependencies\n */\nimport TemplatePreview from './template-preview';\nimport { NavigationPanelPreviewFill } from '../index';\nimport { store as editSiteStore } from '../../../store';\n\nexport default function TemplateNavigationItem( { item } ) {\n\tconst { title, description } = useSelect(\n\t\t( select ) =>\n\t\t\t'wp_template' === item.type\n\t\t\t\t? select( editorStore ).__experimentalGetTemplateInfo( item )\n\t\t\t\t: {\n\t\t\t\t\t\ttitle: item?.title?.rendered || item?.slug,\n\t\t\t\t\t\tdescription: '',\n\t\t\t\t },\n\t\t[]\n\t);\n\tconst {\n\t\tsetTemplate,\n\t\tsetTemplatePart,\n\t\tsetIsNavigationPanelOpened,\n\t} = useDispatch( editSiteStore );\n\tconst [ isPreviewVisible, setIsPreviewVisible ] = useState( false );\n\n\tif ( ! item ) {\n\t\treturn null;\n\t}\n\n\tconst onActivateItem = () => {\n\t\tif ( 'wp_template' === item.type ) {\n\t\t\tsetTemplate( item.id, item.slug );\n\t\t} else {\n\t\t\tsetTemplatePart( item.id );\n\t\t}\n\t\tsetIsNavigationPanelOpened( false );\n\t};\n\n\treturn (\n\t\t<NavigationItem\n\t\t\tclassName=\"edit-site-navigation-panel__template-item\"\n\t\t\titem={ `${ item.type }-${ item.id }` }\n\t\t>\n\t\t\t<Button\n\t\t\t\tonClick={ onActivateItem }\n\t\t\t\tonMouseEnter={ () => setIsPreviewVisible( true ) }\n\t\t\t\tonMouseLeave={ () => setIsPreviewVisible( false ) }\n\t\t\t>\n\t\t\t\t<span className=\"edit-site-navigation-panel__info-wrapper\">\n\t\t\t\t\t<div className=\"edit-site-navigation-panel__template-item-title\">\n\t\t\t\t\t\t{ 'draft' === item.status && (\n\t\t\t\t\t\t\t<em>{ __( '[Draft]' ) }</em>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ title }\n\t\t\t\t\t</div>\n\t\t\t\t\t{ description && (\n\t\t\t\t\t\t<div className=\"edit-site-navigation-panel__template-item-description\">\n\t\t\t\t\t\t\t{ description }\n\t\t\t\t\t\t</div>\n\t\t\t\t\t) }\n\t\t\t\t</span>\n\t\t\t</Button>\n\n\t\t\t{ isPreviewVisible && (\n\t\t\t\t<NavigationPanelPreviewFill>\n\t\t\t\t\t<TemplatePreview rawContent={ item.content.raw } />\n\t\t\t\t</NavigationPanelPreviewFill>\n\t\t\t) }\n\t\t</NavigationItem>\n\t);\n}\n"]}
@@ -1,46 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = TemplatePreview;
7
-
8
- var _element = require("@wordpress/element");
9
-
10
- var _blocks = require("@wordpress/blocks");
11
-
12
- var _blockEditor = require("@wordpress/block-editor");
13
-
14
- /**
15
- * WordPress dependencies
16
- */
17
- function TemplatePreview(_ref) {
18
- let {
19
- rawContent,
20
- blockContext
21
- } = _ref;
22
- const blocks = (0, _element.useMemo)(() => rawContent ? (0, _blocks.parse)(rawContent) : [], [rawContent]);
23
-
24
- if (!blocks || blocks.length === 0) {
25
- return null;
26
- }
27
-
28
- if (blockContext) {
29
- return (0, _element.createElement)("div", {
30
- className: "edit-site-navigation-panel__preview"
31
- }, (0, _element.createElement)(_blockEditor.BlockContextProvider, {
32
- value: blockContext
33
- }, (0, _element.createElement)(_blockEditor.BlockPreview, {
34
- blocks: blocks,
35
- viewportWidth: 1200
36
- })));
37
- }
38
-
39
- return (0, _element.createElement)("div", {
40
- className: "edit-site-navigation-panel__preview"
41
- }, (0, _element.createElement)(_blockEditor.BlockPreview, {
42
- blocks: blocks,
43
- viewportWidth: 1200
44
- }));
45
- }
46
- //# sourceMappingURL=template-preview.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/components/navigation-sidebar/navigation-panel/template-preview.js"],"names":["TemplatePreview","rawContent","blockContext","blocks","length"],"mappings":";;;;;;;AAKA;;AAFA;;AACA;;AAJA;AACA;AACA;AAKe,SAASA,eAAT,OAAyD;AAAA,MAA/B;AAAEC,IAAAA,UAAF;AAAcC,IAAAA;AAAd,GAA+B;AACvE,QAAMC,MAAM,GAAG,sBAAS,MAAQF,UAAU,GAAG,mBAAOA,UAAP,CAAH,GAAyB,EAApD,EAA0D,CACxEA,UADwE,CAA1D,CAAf;;AAIA,MAAK,CAAEE,MAAF,IAAYA,MAAM,CAACC,MAAP,KAAkB,CAAnC,EAAuC;AACtC,WAAO,IAAP;AACA;;AAED,MAAKF,YAAL,EAAoB;AACnB,WACC;AAAK,MAAA,SAAS,EAAC;AAAf,OACC,4BAAC,iCAAD;AAAsB,MAAA,KAAK,EAAGA;AAA9B,OACC,4BAAC,yBAAD;AAAc,MAAA,MAAM,EAAGC,MAAvB;AAAgC,MAAA,aAAa,EAAG;AAAhD,MADD,CADD,CADD;AAOA;;AAED,SACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,4BAAC,yBAAD;AAAc,IAAA,MAAM,EAAGA,MAAvB;AAAgC,IAAA,aAAa,EAAG;AAAhD,IADD,CADD;AAKA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { parse } from '@wordpress/blocks';\nimport { BlockPreview, BlockContextProvider } from '@wordpress/block-editor';\nimport { useMemo } from '@wordpress/element';\n\nexport default function TemplatePreview( { rawContent, blockContext } ) {\n\tconst blocks = useMemo( () => ( rawContent ? parse( rawContent ) : [] ), [\n\t\trawContent,\n\t] );\n\n\tif ( ! blocks || blocks.length === 0 ) {\n\t\treturn null;\n\t}\n\n\tif ( blockContext ) {\n\t\treturn (\n\t\t\t<div className=\"edit-site-navigation-panel__preview\">\n\t\t\t\t<BlockContextProvider value={ blockContext }>\n\t\t\t\t\t<BlockPreview blocks={ blocks } viewportWidth={ 1200 } />\n\t\t\t\t</BlockContextProvider>\n\t\t\t</div>\n\t\t);\n\t}\n\n\treturn (\n\t\t<div className=\"edit-site-navigation-panel__preview\">\n\t\t\t<BlockPreview blocks={ blocks } viewportWidth={ 1200 } />\n\t\t</div>\n\t);\n}\n"]}
@@ -1,47 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = useDebouncedSearch;
7
-
8
- var _lodash = require("lodash");
9
-
10
- var _element = require("@wordpress/element");
11
-
12
- var _constants = require("./constants");
13
-
14
- /**
15
- * External dependencies
16
- */
17
-
18
- /**
19
- * WordPress dependencies
20
- */
21
-
22
- /**
23
- * Internal dependencies
24
- */
25
- function useDebouncedSearch() {
26
- // The value used by the NavigationMenu to control the input field.
27
- const [search, setSearch] = (0, _element.useState)(''); // The value used to actually perform the search query.
28
-
29
- const [searchQuery, setSearchQuery] = (0, _element.useState)('');
30
- const [isDebouncing, setIsDebouncing] = (0, _element.useState)(false);
31
- (0, _element.useEffect)(() => {
32
- setIsDebouncing(false);
33
- }, [searchQuery]);
34
- const debouncedSetSearchQuery = (0, _element.useCallback)((0, _lodash.debounce)(setSearchQuery, _constants.SEARCH_DEBOUNCE_IN_MS), [setSearchQuery]);
35
- const onSearch = (0, _element.useCallback)(value => {
36
- setSearch(value);
37
- debouncedSetSearchQuery(value);
38
- setIsDebouncing(true);
39
- }, [setSearch, setIsDebouncing, debouncedSetSearchQuery]);
40
- return {
41
- search,
42
- searchQuery,
43
- isDebouncing,
44
- onSearch
45
- };
46
- }
47
- //# sourceMappingURL=use-debounced-search.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/components/navigation-sidebar/navigation-panel/use-debounced-search.js"],"names":["useDebouncedSearch","search","setSearch","searchQuery","setSearchQuery","isDebouncing","setIsDebouncing","debouncedSetSearchQuery","SEARCH_DEBOUNCE_IN_MS","onSearch","value"],"mappings":";;;;;;;AAGA;;AAKA;;AAKA;;AAbA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;AAGe,SAASA,kBAAT,GAA8B;AAC5C;AACA,QAAM,CAAEC,MAAF,EAAUC,SAAV,IAAwB,uBAAU,EAAV,CAA9B,CAF4C,CAG5C;;AACA,QAAM,CAAEC,WAAF,EAAeC,cAAf,IAAkC,uBAAU,EAAV,CAAxC;AACA,QAAM,CAAEC,YAAF,EAAgBC,eAAhB,IAAoC,uBAAU,KAAV,CAA1C;AAEA,0BAAW,MAAM;AAChBA,IAAAA,eAAe,CAAE,KAAF,CAAf;AACA,GAFD,EAEG,CAAEH,WAAF,CAFH;AAIA,QAAMI,uBAAuB,GAAG,0BAC/B,sBAAUH,cAAV,EAA0BI,gCAA1B,CAD+B,EAE/B,CAAEJ,cAAF,CAF+B,CAAhC;AAKA,QAAMK,QAAQ,GAAG,0BACdC,KAAF,IAAa;AACZR,IAAAA,SAAS,CAAEQ,KAAF,CAAT;AACAH,IAAAA,uBAAuB,CAAEG,KAAF,CAAvB;AACAJ,IAAAA,eAAe,CAAE,IAAF,CAAf;AACA,GALe,EAMhB,CAAEJ,SAAF,EAAaI,eAAb,EAA8BC,uBAA9B,CANgB,CAAjB;AASA,SAAO;AACNN,IAAAA,MADM;AAENE,IAAAA,WAFM;AAGNE,IAAAA,YAHM;AAINI,IAAAA;AAJM,GAAP;AAMA","sourcesContent":["/**\n * External dependencies\n */\nimport { debounce } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useState, useCallback, useEffect } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { SEARCH_DEBOUNCE_IN_MS } from './constants';\n\nexport default function useDebouncedSearch() {\n\t// The value used by the NavigationMenu to control the input field.\n\tconst [ search, setSearch ] = useState( '' );\n\t// The value used to actually perform the search query.\n\tconst [ searchQuery, setSearchQuery ] = useState( '' );\n\tconst [ isDebouncing, setIsDebouncing ] = useState( false );\n\n\tuseEffect( () => {\n\t\tsetIsDebouncing( false );\n\t}, [ searchQuery ] );\n\n\tconst debouncedSetSearchQuery = useCallback(\n\t\tdebounce( setSearchQuery, SEARCH_DEBOUNCE_IN_MS ),\n\t\t[ setSearchQuery ]\n\t);\n\n\tconst onSearch = useCallback(\n\t\t( value ) => {\n\t\t\tsetSearch( value );\n\t\t\tdebouncedSetSearchQuery( value );\n\t\t\tsetIsDebouncing( true );\n\t\t},\n\t\t[ setSearch, setIsDebouncing, debouncedSetSearchQuery ]\n\t);\n\n\treturn {\n\t\tsearch,\n\t\tsearchQuery,\n\t\tisDebouncing,\n\t\tonSearch,\n\t};\n}\n"]}
@@ -1,21 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.normalizedSearch = exports.normalizeInput = void 0;
7
-
8
- var _lodash = require("lodash");
9
-
10
- /**
11
- * External dependencies
12
- */
13
- // @see packages/block-editor/src/components/inserter/search-items.js
14
- const normalizeInput = input => (0, _lodash.deburr)(input).replace(/^\//, '').toLowerCase();
15
-
16
- exports.normalizeInput = normalizeInput;
17
-
18
- const normalizedSearch = (title, search) => -1 !== normalizeInput(title).indexOf(normalizeInput(search));
19
-
20
- exports.normalizedSearch = normalizedSearch;
21
- //# sourceMappingURL=utils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/components/navigation-sidebar/navigation-panel/utils.js"],"names":["normalizeInput","input","replace","toLowerCase","normalizedSearch","title","search","indexOf"],"mappings":";;;;;;;AAGA;;AAHA;AACA;AACA;AAGA;AACO,MAAMA,cAAc,GAAKC,KAAF,IAC7B,oBAAQA,KAAR,EAAgBC,OAAhB,CAAyB,KAAzB,EAAgC,EAAhC,EAAqCC,WAArC,EADM;;;;AAGA,MAAMC,gBAAgB,GAAG,CAAEC,KAAF,EAASC,MAAT,KAC/B,CAAC,CAAD,KAAON,cAAc,CAAEK,KAAF,CAAd,CAAwBE,OAAxB,CAAiCP,cAAc,CAAEM,MAAF,CAA/C,CADD","sourcesContent":["/**\n * External dependencies\n */\nimport { deburr } from 'lodash';\n\n// @see packages/block-editor/src/components/inserter/search-items.js\nexport const normalizeInput = ( input ) =>\n\tdeburr( input ).replace( /^\\//, '' ).toLowerCase();\n\nexport const normalizedSearch = ( title, search ) =>\n\t-1 !== normalizeInput( title ).indexOf( normalizeInput( search ) );\n"]}
@@ -1,48 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = getClosestAvailableTemplate;
7
-
8
- var _lodash = require("lodash");
9
-
10
- /**
11
- * External dependencies
12
- */
13
- function getClosestAvailableTemplate(slug, templates) {
14
- const template = (0, _lodash.find)(templates, {
15
- slug
16
- });
17
-
18
- if (template) {
19
- return template;
20
- }
21
-
22
- switch (slug) {
23
- case 'single':
24
- case 'page':
25
- return getClosestAvailableTemplate('singular', templates);
26
-
27
- case 'author':
28
- case 'category':
29
- case 'taxonomy':
30
- case 'date':
31
- case 'tag':
32
- return getClosestAvailableTemplate('archive', templates);
33
-
34
- case 'front-page':
35
- return getClosestAvailableTemplate('home', templates);
36
-
37
- case 'attachment':
38
- return getClosestAvailableTemplate('single', templates);
39
-
40
- case 'privacy-policy':
41
- return getClosestAvailableTemplate('page', templates);
42
- }
43
-
44
- return (0, _lodash.find)(templates, {
45
- slug: 'index'
46
- });
47
- }
48
- //# sourceMappingURL=get-closest-available-template.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/utils/get-closest-available-template.js"],"names":["getClosestAvailableTemplate","slug","templates","template"],"mappings":";;;;;;;AAGA;;AAHA;AACA;AACA;AAGe,SAASA,2BAAT,CAAsCC,IAAtC,EAA4CC,SAA5C,EAAwD;AACtE,QAAMC,QAAQ,GAAG,kBAAMD,SAAN,EAAiB;AAAED,IAAAA;AAAF,GAAjB,CAAjB;;AACA,MAAKE,QAAL,EAAgB;AACf,WAAOA,QAAP;AACA;;AAED,UAASF,IAAT;AACC,SAAK,QAAL;AACA,SAAK,MAAL;AACC,aAAOD,2BAA2B,CAAE,UAAF,EAAcE,SAAd,CAAlC;;AACD,SAAK,QAAL;AACA,SAAK,UAAL;AACA,SAAK,UAAL;AACA,SAAK,MAAL;AACA,SAAK,KAAL;AACC,aAAOF,2BAA2B,CAAE,SAAF,EAAaE,SAAb,CAAlC;;AACD,SAAK,YAAL;AACC,aAAOF,2BAA2B,CAAE,MAAF,EAAUE,SAAV,CAAlC;;AACD,SAAK,YAAL;AACC,aAAOF,2BAA2B,CAAE,QAAF,EAAYE,SAAZ,CAAlC;;AACD,SAAK,gBAAL;AACC,aAAOF,2BAA2B,CAAE,MAAF,EAAUE,SAAV,CAAlC;AAfF;;AAkBA,SAAO,kBAAMA,SAAN,EAAiB;AAAED,IAAAA,IAAI,EAAE;AAAR,GAAjB,CAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { find } from 'lodash';\n\nexport default function getClosestAvailableTemplate( slug, templates ) {\n\tconst template = find( templates, { slug } );\n\tif ( template ) {\n\t\treturn template;\n\t}\n\n\tswitch ( slug ) {\n\t\tcase 'single':\n\t\tcase 'page':\n\t\t\treturn getClosestAvailableTemplate( 'singular', templates );\n\t\tcase 'author':\n\t\tcase 'category':\n\t\tcase 'taxonomy':\n\t\tcase 'date':\n\t\tcase 'tag':\n\t\t\treturn getClosestAvailableTemplate( 'archive', templates );\n\t\tcase 'front-page':\n\t\t\treturn getClosestAvailableTemplate( 'home', templates );\n\t\tcase 'attachment':\n\t\t\treturn getClosestAvailableTemplate( 'single', templates );\n\t\tcase 'privacy-policy':\n\t\t\treturn getClosestAvailableTemplate( 'page', templates );\n\t}\n\n\treturn find( templates, { slug: 'index' } );\n}\n"]}
@@ -1,86 +0,0 @@
1
- import { createElement, Fragment } from "@wordpress/element";
2
-
3
- /**
4
- * WordPress dependencies
5
- */
6
- import { __experimentalNavigationItem as NavigationItem } from '@wordpress/components';
7
- import { useDispatch, useSelect } from '@wordpress/data';
8
- import { useCallback, useState } from '@wordpress/element';
9
- import { __ } from '@wordpress/i18n';
10
- import { getPathAndQueryString } from '@wordpress/url';
11
- import { store as coreStore } from '@wordpress/core-data';
12
- /**
13
- * Internal dependencies
14
- */
15
-
16
- import { NavigationPanelPreviewFill } from '..';
17
- import TemplatePreview from './template-preview';
18
- import { store as editSiteStore } from '../../../store';
19
-
20
- const getTitle = entity => {
21
- var _entity$title;
22
-
23
- const title = entity.taxonomy ? entity.name : entity === null || entity === void 0 ? void 0 : (_entity$title = entity.title) === null || _entity$title === void 0 ? void 0 : _entity$title.rendered; // Make sure encoded characters are displayed as the characters they represent.
24
-
25
- const titleElement = document.createElement('div');
26
- titleElement.innerHTML = title;
27
- return titleElement.textContent || titleElement.innerText || '';
28
- };
29
-
30
- export default function ContentNavigationItem(_ref) {
31
- let {
32
- item
33
- } = _ref;
34
- const [isPreviewVisible, setIsPreviewVisible] = useState(false);
35
- const previewContent = useSelect(select => {
36
- if (!isPreviewVisible) {
37
- return null;
38
- }
39
-
40
- const template = select(coreStore).__experimentalGetTemplateForLink(item.link);
41
-
42
- return template === null || template === void 0 ? void 0 : template.content;
43
- }, [isPreviewVisible]);
44
- const {
45
- setPage,
46
- setIsNavigationPanelOpened
47
- } = useDispatch(editSiteStore);
48
- const onActivateItem = useCallback(() => {
49
- const {
50
- type,
51
- slug,
52
- link,
53
- id
54
- } = item;
55
- setPage({
56
- type,
57
- slug,
58
- path: getPathAndQueryString(link),
59
- context: {
60
- postType: type,
61
- postId: id
62
- }
63
- });
64
- setIsNavigationPanelOpened(false);
65
- }, [setPage, item]);
66
-
67
- if (!item) {
68
- return null;
69
- }
70
-
71
- return createElement(Fragment, null, createElement(NavigationItem, {
72
- className: "edit-site-navigation-panel__content-item",
73
- item: `${item.taxonomy || item.type}-${item.id}`,
74
- title: getTitle(item) || __('(no title)'),
75
- onClick: onActivateItem,
76
- onMouseEnter: () => setIsPreviewVisible(true),
77
- onMouseLeave: () => setIsPreviewVisible(false)
78
- }), isPreviewVisible && previewContent && createElement(NavigationPanelPreviewFill, null, createElement(TemplatePreview, {
79
- rawContent: previewContent,
80
- blockContext: {
81
- postType: item.type,
82
- postId: item.id
83
- }
84
- })));
85
- }
86
- //# sourceMappingURL=content-navigation-item.js.map