@wordpress/block-library 8.3.0 → 8.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -25,6 +25,8 @@ var _experiments = require("../../experiments");
25
25
 
26
26
  var _deletedNavigationWarning = _interopRequireDefault(require("./deleted-navigation-warning"));
27
27
 
28
+ var _useNavigationMenu = _interopRequireDefault(require("../use-navigation-menu"));
29
+
28
30
  /**
29
31
  * WordPress dependencies
30
32
  */
@@ -55,12 +57,15 @@ const MainContent = _ref => {
55
57
  } = select(_blockEditor.store);
56
58
  return __unstableGetClientIdsTree(clientId);
57
59
  }, [clientId]);
60
+ const {
61
+ navigationMenu
62
+ } = (0, _useNavigationMenu.default)(currentMenuId);
58
63
 
59
64
  if (currentMenuId && isNavigationMenuMissing) {
60
65
  return (0, _element.createElement)("p", null, (0, _i18n.__)('Select or create a menu'));
61
66
  }
62
67
 
63
- if (isNavigationMenuMissing) {
68
+ if (currentMenuId && isNavigationMenuMissing) {
64
69
  return (0, _element.createElement)(_deletedNavigationWarning.default, {
65
70
  onCreateNew: onCreateNew
66
71
  });
@@ -70,10 +75,14 @@ const MainContent = _ref => {
70
75
  return (0, _element.createElement)(_components.Spinner, null);
71
76
  }
72
77
 
78
+ const description = navigationMenu ? (0, _i18n.sprintf)(
79
+ /* translators: %s: The name of a menu. */
80
+ (0, _i18n.__)('Structure for navigation menu: %s'), (navigationMenu === null || navigationMenu === void 0 ? void 0 : navigationMenu.title) || (0, _i18n.__)('Untitled menu')) : (0, _i18n.__)('You have not yet created any menus. Displaying a list of your Pages');
73
81
  return (0, _element.createElement)(OffCanvasEditor, {
74
82
  blocks: clientIdsTree,
75
83
  isExpanded: true,
76
- LeafMoreMenu: _leafMoreMenu.LeafMoreMenu
84
+ LeafMoreMenu: _leafMoreMenu.LeafMoreMenu,
85
+ description: description
77
86
  });
78
87
  };
79
88
 
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/navigation/edit/menu-inspector-controls.js"],"names":["actionLabel","MainContent","clientId","currentMenuId","isLoading","isNavigationMenuMissing","onCreateNew","OffCanvasEditor","blockEditorExperiments","clientIdsTree","select","__unstableGetClientIdsTree","blockEditorStore","LeafMoreMenu","MenuInspectorControls","props","createNavigationMenuIsSuccess","createNavigationMenuIsError","onSelectClassicMenu","onSelectNavigationMenu","isManageMenusButtonDisabled","process","env","IS_GUTENBERG_PLUGIN"],"mappings":";;;;;;;;;;;AAGA;;AAKA;;AAMA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AAvBA;AACA;AACA;;AAeA;AACA;AACA;;AAMA;AACA,MAAMA,WAAW,GAAG,cAAI,gBAAJ,CAApB;;AAEA,MAAMC,WAAW,GAAG,QAMb;AAAA,MANe;AACrBC,IAAAA,QADqB;AAErBC,IAAAA,aAFqB;AAGrBC,IAAAA,SAHqB;AAIrBC,IAAAA,uBAJqB;AAKrBC,IAAAA;AALqB,GAMf;AACN,QAAM;AAAEC,IAAAA;AAAF,MAAsB,yBAAQC,wBAAR,CAA5B,CADM,CAEN;AACA;;AACA,QAAMC,aAAa,GAAG,qBACnBC,MAAF,IAAc;AACb,UAAM;AAAEC,MAAAA;AAAF,QAAiCD,MAAM,CAAEE,kBAAF,CAA7C;AACA,WAAOD,0BAA0B,CAAET,QAAF,CAAjC;AACA,GAJoB,EAKrB,CAAEA,QAAF,CALqB,CAAtB;;AAQA,MAAKC,aAAa,IAAIE,uBAAtB,EAAgD;AAC/C,WAAO,uCAAK,cAAI,yBAAJ,CAAL,CAAP;AACA;;AAED,MAAKA,uBAAL,EAA+B;AAC9B,WAAO,4BAAC,iCAAD;AAA0B,MAAA,WAAW,EAAGC;AAAxC,MAAP;AACA;;AAED,MAAKF,SAAL,EAAiB;AAChB,WAAO,4BAAC,mBAAD,OAAP;AACA;;AAED,SACC,4BAAC,eAAD;AACC,IAAA,MAAM,EAAGK,aADV;AAEC,IAAA,UAAU,EAAG,IAFd;AAGC,IAAA,YAAY,EAAGI;AAHhB,IADD;AAOA,CArCD;;AAuCA,MAAMC,qBAAqB,GAAKC,KAAF,IAAa;AAC1C,QAAM;AACLC,IAAAA,6BADK;AAELC,IAAAA,2BAFK;AAGLd,IAAAA,aAAa,GAAG,IAHX;AAILG,IAAAA,WAJK;AAKLY,IAAAA,mBALK;AAMLC,IAAAA,sBANK;AAOLC,IAAAA;AAPK,MAQFL,KARJ;AAUA,SACC,4BAAC,8BAAD;AAAmB,IAAA,KAAK,EAAC;AAAzB,KACC,4BAAC,qBAAD;AACC,IAAA,KAAK,EAAGM,OAAO,CAACC,GAAR,CAAYC,mBAAZ,GAAkC,IAAlC,GAAyC,cAAI,MAAJ;AADlD,KAGC,4BAAC,gCAAD;AAAQ,IAAA,SAAS,EAAC;AAAlB,KACC,4BAAC,iCAAD;AACC,IAAA,SAAS,EAAC,8CADX;AAEC,IAAA,KAAK,EAAG;AAFT,KAIG,cAAI,MAAJ,CAJH,CADD,EAOC,4BAAC,+BAAD;AACC,IAAA,aAAa,EAAGpB,aADjB;AAEC,IAAA,mBAAmB,EAAGe,mBAFvB;AAGC,IAAA,sBAAsB,EAAGC,sBAH1B;AAIC,IAAA,WAAW,EAAGb,WAJf;AAKC,IAAA,6BAA6B,EAC5BU,6BANF;AAQC,IAAA,2BAA2B,EAC1BC,2BATF;AAWC,IAAA,WAAW,EAAGjB,WAXf;AAYC,IAAA,2BAA2B,EAC1BoB;AAbF,IAPD,CAHD,EA2BC,4BAAC,WAAD,EAAkBL,KAAlB,CA3BD,CADD,CADD;AAiCA,CA5CD;;eA8CeD,qB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\texperiments as blockEditorExperiments,\n\tInspectorControls,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport {\n\tPanelBody,\n\t__experimentalHStack as HStack,\n\t__experimentalHeading as Heading,\n\tSpinner,\n} from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport NavigationMenuSelector from './navigation-menu-selector';\nimport { LeafMoreMenu } from '../leaf-more-menu';\nimport { unlock } from '../../experiments';\nimport DeletedNavigationWarning from './deleted-navigation-warning';\n\n/* translators: %s: The name of a menu. */\nconst actionLabel = __( \"Switch to '%s'\" );\n\nconst MainContent = ( {\n\tclientId,\n\tcurrentMenuId,\n\tisLoading,\n\tisNavigationMenuMissing,\n\tonCreateNew,\n} ) => {\n\tconst { OffCanvasEditor } = unlock( blockEditorExperiments );\n\t// Provide a hierarchy of clientIds for the given Navigation block (clientId).\n\t// This is required else the list view will display the entire block tree.\n\tconst clientIdsTree = useSelect(\n\t\t( select ) => {\n\t\t\tconst { __unstableGetClientIdsTree } = select( blockEditorStore );\n\t\t\treturn __unstableGetClientIdsTree( clientId );\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tif ( currentMenuId && isNavigationMenuMissing ) {\n\t\treturn <p>{ __( 'Select or create a menu' ) }</p>;\n\t}\n\n\tif ( isNavigationMenuMissing ) {\n\t\treturn <DeletedNavigationWarning onCreateNew={ onCreateNew } />;\n\t}\n\n\tif ( isLoading ) {\n\t\treturn <Spinner />;\n\t}\n\n\treturn (\n\t\t<OffCanvasEditor\n\t\t\tblocks={ clientIdsTree }\n\t\t\tisExpanded={ true }\n\t\t\tLeafMoreMenu={ LeafMoreMenu }\n\t\t/>\n\t);\n};\n\nconst MenuInspectorControls = ( props ) => {\n\tconst {\n\t\tcreateNavigationMenuIsSuccess,\n\t\tcreateNavigationMenuIsError,\n\t\tcurrentMenuId = null,\n\t\tonCreateNew,\n\t\tonSelectClassicMenu,\n\t\tonSelectNavigationMenu,\n\t\tisManageMenusButtonDisabled,\n\t} = props;\n\n\treturn (\n\t\t<InspectorControls group=\"list\">\n\t\t\t<PanelBody\n\t\t\t\ttitle={ process.env.IS_GUTENBERG_PLUGIN ? null : __( 'Menu' ) }\n\t\t\t>\n\t\t\t\t<HStack className=\"wp-block-navigation-off-canvas-editor__header\">\n\t\t\t\t\t<Heading\n\t\t\t\t\t\tclassName=\"wp-block-navigation-off-canvas-editor__title\"\n\t\t\t\t\t\tlevel={ 2 }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Menu' ) }\n\t\t\t\t\t</Heading>\n\t\t\t\t\t<NavigationMenuSelector\n\t\t\t\t\t\tcurrentMenuId={ currentMenuId }\n\t\t\t\t\t\tonSelectClassicMenu={ onSelectClassicMenu }\n\t\t\t\t\t\tonSelectNavigationMenu={ onSelectNavigationMenu }\n\t\t\t\t\t\tonCreateNew={ onCreateNew }\n\t\t\t\t\t\tcreateNavigationMenuIsSuccess={\n\t\t\t\t\t\t\tcreateNavigationMenuIsSuccess\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcreateNavigationMenuIsError={\n\t\t\t\t\t\t\tcreateNavigationMenuIsError\n\t\t\t\t\t\t}\n\t\t\t\t\t\tactionLabel={ actionLabel }\n\t\t\t\t\t\tisManageMenusButtonDisabled={\n\t\t\t\t\t\t\tisManageMenusButtonDisabled\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t</HStack>\n\t\t\t\t<MainContent { ...props } />\n\t\t\t</PanelBody>\n\t\t</InspectorControls>\n\t);\n};\n\nexport default MenuInspectorControls;\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/navigation/edit/menu-inspector-controls.js"],"names":["actionLabel","MainContent","clientId","currentMenuId","isLoading","isNavigationMenuMissing","onCreateNew","OffCanvasEditor","blockEditorExperiments","clientIdsTree","select","__unstableGetClientIdsTree","blockEditorStore","navigationMenu","description","title","LeafMoreMenu","MenuInspectorControls","props","createNavigationMenuIsSuccess","createNavigationMenuIsError","onSelectClassicMenu","onSelectNavigationMenu","isManageMenusButtonDisabled","process","env","IS_GUTENBERG_PLUGIN"],"mappings":";;;;;;;;;;;AAGA;;AAKA;;AAMA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AAxBA;AACA;AACA;;AAeA;AACA;AACA;;AAOA;AACA,MAAMA,WAAW,G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,6BADK;AAELC,IAAAA,2BAFK;AAGLjB,IAAAA,aAAa,GAAG,IAHX;AAILG,IAAAA,WAJK;AAKLe,IAAAA,mBALK;AAMLC,IAAAA,sBANK;AAOLC,IAAAA;AAPK,MAQFL,KARJ;AAUA,SACC,4BAAC,8BAAD;AAAmB,IAAA,KAAK,EAAC;AAAzB,KACC,4BAAC,qBAAD;AACC,IAAA,KAAK,EAAGM,OAAO,CAACC,GAAR,CAAYC,mBAAZ,GAAkC,IAAlC,GAAyC,cAAI,MAAJ;AADlD,KAGC,4BAAC,gCAAD;AAAQ,IAAA,SAAS,EAAC;AAAlB,KACC,4BAAC,iCAAD;AACC,IAAA,SAAS,EAAC,8CADX;AAEC,IAAA,KAAK,EAAG;AAFT,KAIG,cAAI,MAAJ,CAJH,CADD,EAOC,4BAAC,+BAAD;AACC,IAAA,aAAa,EAAGvB,aADjB;AAEC,IAAA,mBAAmB,EAAGkB,mBAFvB;AAGC,IAAA,sBAAsB,EAAGC,sBAH1B;AAIC,IAAA,WAAW,EAAGhB,WAJf;AAKC,IAAA,6BAA6B,EAC5Ba,6BANF;AAQC,IAAA,2BAA2B,EAC1BC,2BATF;AAWC,IAAA,WAAW,EAAGpB,WAXf;AAYC,IAAA,2BAA2B,EAC1BuB;AAbF,IAPD,CAHD,EA2BC,4BAAC,WAAD,EAAkBL,KAAlB,CA3BD,CADD,CADD;AAiCA,CA5CD;;eA8CeD,qB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\texperiments as blockEditorExperiments,\n\tInspectorControls,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport {\n\tPanelBody,\n\t__experimentalHStack as HStack,\n\t__experimentalHeading as Heading,\n\tSpinner,\n} from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { __, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport NavigationMenuSelector from './navigation-menu-selector';\nimport { LeafMoreMenu } from '../leaf-more-menu';\nimport { unlock } from '../../experiments';\nimport DeletedNavigationWarning from './deleted-navigation-warning';\nimport useNavigationMenu from '../use-navigation-menu';\n\n/* translators: %s: The name of a menu. */\nconst actionLabel = __( \"Switch to '%s'\" );\n\nconst MainContent = ( {\n\tclientId,\n\tcurrentMenuId,\n\tisLoading,\n\tisNavigationMenuMissing,\n\tonCreateNew,\n} ) => {\n\tconst { OffCanvasEditor } = unlock( blockEditorExperiments );\n\t// Provide a hierarchy of clientIds for the given Navigation block (clientId).\n\t// This is required else the list view will display the entire block tree.\n\tconst clientIdsTree = useSelect(\n\t\t( select ) => {\n\t\t\tconst { __unstableGetClientIdsTree } = select( blockEditorStore );\n\t\t\treturn __unstableGetClientIdsTree( clientId );\n\t\t},\n\t\t[ clientId ]\n\t);\n\tconst { navigationMenu } = useNavigationMenu( currentMenuId );\n\n\tif ( currentMenuId && isNavigationMenuMissing ) {\n\t\treturn <p>{ __( 'Select or create a menu' ) }</p>;\n\t}\n\n\tif ( currentMenuId && isNavigationMenuMissing ) {\n\t\treturn <DeletedNavigationWarning onCreateNew={ onCreateNew } />;\n\t}\n\n\tif ( isLoading ) {\n\t\treturn <Spinner />;\n\t}\n\n\tconst description = navigationMenu\n\t\t? sprintf(\n\t\t\t\t/* translators: %s: The name of a menu. */\n\t\t\t\t__( 'Structure for navigation menu: %s' ),\n\t\t\t\tnavigationMenu?.title || __( 'Untitled menu' )\n\t\t )\n\t\t: __(\n\t\t\t\t'You have not yet created any menus. Displaying a list of your Pages'\n\t\t );\n\treturn (\n\t\t<OffCanvasEditor\n\t\t\tblocks={ clientIdsTree }\n\t\t\tisExpanded={ true }\n\t\t\tLeafMoreMenu={ LeafMoreMenu }\n\t\t\tdescription={ description }\n\t\t/>\n\t);\n};\n\nconst MenuInspectorControls = ( props ) => {\n\tconst {\n\t\tcreateNavigationMenuIsSuccess,\n\t\tcreateNavigationMenuIsError,\n\t\tcurrentMenuId = null,\n\t\tonCreateNew,\n\t\tonSelectClassicMenu,\n\t\tonSelectNavigationMenu,\n\t\tisManageMenusButtonDisabled,\n\t} = props;\n\n\treturn (\n\t\t<InspectorControls group=\"list\">\n\t\t\t<PanelBody\n\t\t\t\ttitle={ process.env.IS_GUTENBERG_PLUGIN ? null : __( 'Menu' ) }\n\t\t\t>\n\t\t\t\t<HStack className=\"wp-block-navigation-off-canvas-editor__header\">\n\t\t\t\t\t<Heading\n\t\t\t\t\t\tclassName=\"wp-block-navigation-off-canvas-editor__title\"\n\t\t\t\t\t\tlevel={ 2 }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Menu' ) }\n\t\t\t\t\t</Heading>\n\t\t\t\t\t<NavigationMenuSelector\n\t\t\t\t\t\tcurrentMenuId={ currentMenuId }\n\t\t\t\t\t\tonSelectClassicMenu={ onSelectClassicMenu }\n\t\t\t\t\t\tonSelectNavigationMenu={ onSelectNavigationMenu }\n\t\t\t\t\t\tonCreateNew={ onCreateNew }\n\t\t\t\t\t\tcreateNavigationMenuIsSuccess={\n\t\t\t\t\t\t\tcreateNavigationMenuIsSuccess\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcreateNavigationMenuIsError={\n\t\t\t\t\t\t\tcreateNavigationMenuIsError\n\t\t\t\t\t\t}\n\t\t\t\t\t\tactionLabel={ actionLabel }\n\t\t\t\t\t\tisManageMenusButtonDisabled={\n\t\t\t\t\t\t\tisManageMenusButtonDisabled\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t</HStack>\n\t\t\t\t<MainContent { ...props } />\n\t\t\t</PanelBody>\n\t\t</InspectorControls>\n\t);\n};\n\nexport default MenuInspectorControls;\n"]}
@@ -35,7 +35,7 @@ const getTermIdByTermValue = (terms, termValue) => {
35
35
  var _terms$find, _terms$find2;
36
36
 
37
37
  // First we check for exact match by `term.id` or case sensitive `term.name` match.
38
- const termId = (termValue === null || termValue === void 0 ? void 0 : termValue.id) || ((_terms$find = terms.find(term => term.name === termValue)) === null || _terms$find === void 0 ? void 0 : _terms$find.id);
38
+ const termId = (termValue === null || termValue === void 0 ? void 0 : termValue.id) || (terms === null || terms === void 0 ? void 0 : (_terms$find = terms.find(term => term.name === termValue)) === null || _terms$find === void 0 ? void 0 : _terms$find.id);
39
39
 
40
40
  if (termId) {
41
41
  return termId;
@@ -52,7 +52,7 @@ const getTermIdByTermValue = (terms, termValue) => {
52
52
 
53
53
 
54
54
  const termValueLower = termValue.toLocaleLowerCase();
55
- return (_terms$find2 = terms.find(term => term.name.toLocaleLowerCase() === termValueLower)) === null || _terms$find2 === void 0 ? void 0 : _terms$find2.id;
55
+ return terms === null || terms === void 0 ? void 0 : (_terms$find2 = terms.find(term => term.name.toLocaleLowerCase() === termValueLower)) === null || _terms$find2 === void 0 ? void 0 : _terms$find2.id;
56
56
  };
57
57
 
58
58
  function TaxonomyControls(_ref) {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/query/edit/inspector-controls/taxonomy-controls.js"],"names":["EMPTY_ARRAY","BASE_QUERY","order","_fields","context","getTermIdByTermValue","terms","termValue","termId","id","find","term","name","termValueLower","toLocaleLowerCase","TaxonomyControls","onChange","query","postType","taxQuery","taxonomies","length","map","taxonomy","termIds","slug","handleChange","newTermIds","TaxonomyItem","search","setSearch","value","setValue","suggestions","setSuggestions","debouncedSearch","searchResults","searchHasResolved","select","getEntityRecords","hasFinishedResolution","coreStore","selectorArgs","orderby","exclude","per_page","existingTerms","include","sanitizedValue","reduce","accumulator","entity","push","result","onTermsChange","newTermValues","Set","add","Array","from"],"mappings":";;;;;;;AAMA;;AAHA;;AACA;;AACA;;AAEA;;AAKA;;AAZA;AACA;AACA;;AAOA;AACA;AACA;AAGA,MAAMA,WAAW,GAAG,EAApB;AACA,MAAMC,UAAU,GAAG;AAClBC,EAAAA,KAAK,EAAE,KADW;AAElBC,EAAAA,OAAO,EAAE,SAFS;AAGlBC,EAAAA,OAAO,EAAE;AAHS,CAAnB,C,CAMA;;AACA,MAAMC,oBAAoB,GAAG,CAAEC,KAAF,EAASC,SAAT,KAAwB;AAAA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,CAAExB,OAAF,EAAWsB,aAAX,CAlBH,EAlDwD,CAqExD;;AACA,0BAAW,MAAM;AAChB,QAAK,CAAET,iBAAP,EAA2B;AAC3BH,IAAAA,cAAc,CAAEE,aAAa,CAACd,GAAd,CAAqB+B,MAAF,IAAcA,MAAM,CAACzC,IAAxC,CAAF,CAAd;AACA,GAHD,EAGG,CAAEwB,aAAF,EAAiBC,iBAAjB,CAHH;;AAIA,QAAMiB,aAAa,GAAKC,aAAF,IAAqB;AAC1C,UAAM5B,UAAU,GAAG,IAAI6B,GAAJ,EAAnB;;AACA,SAAM,MAAMjD,SAAZ,IAAyBgD,aAAzB,EAAyC;AACxC,YAAM/C,MAAM,GAAGH,oBAAoB,CAAE+B,aAAF,EAAiB7B,SAAjB,CAAnC;;AACA,UAAKC,MAAL,EAAc;AACbmB,QAAAA,UAAU,CAAC8B,GAAX,CAAgBjD,MAAhB;AACA;AACD;;AACD0B,IAAAA,cAAc,CAAElC,WAAF,CAAd;AACAgB,IAAAA,QAAQ,CAAE0C,KAAK,CAACC,IAAN,CAAYhC,UAAZ,CAAF,CAAR;AACA,GAVD;;AAWA,SACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,4BAAC,0BAAD;AACC,IAAA,KAAK,EAAGJ,QAAQ,CAACX,IADlB;AAEC,IAAA,KAAK,EAAGmB,KAFT;AAGC,IAAA,aAAa,EAAGI,eAHjB;AAIC,IAAA,WAAW,EAAGF,WAJf;AAKC,IAAA,QAAQ,EAAGqB,aALZ;AAMC,IAAA,uBAAuB,EAAG;AAN3B,IADD,CADD;AAYA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { FormTokenField } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useState, useEffect } from '@wordpress/element';\nimport { useDebounce } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { useTaxonomies } from '../../utils';\n\nconst EMPTY_ARRAY = [];\nconst BASE_QUERY = {\n\torder: 'asc',\n\t_fields: 'id,name',\n\tcontext: 'view',\n};\n\n// Helper function to get the term id based on user input in terms `FormTokenField`.\nconst getTermIdByTermValue = ( terms, termValue ) => {\n\t// First we check for exact match by `term.id` or case sensitive `term.name` match.\n\tconst termId =\n\t\ttermValue?.id || terms.find( ( term ) => term.name === termValue )?.id;\n\tif ( termId ) {\n\t\treturn termId;\n\t}\n\n\t/**\n\t * Here we make an extra check for entered terms in a non case sensitive way,\n\t * to match user expectations, due to `FormTokenField` behaviour that shows\n\t * suggestions which are case insensitive.\n\t *\n\t * Although WP tries to discourage users to add terms with the same name (case insensitive),\n\t * it's still possible if you manually change the name, as long as the terms have different slugs.\n\t * In this edge case we always apply the first match from the terms list.\n\t */\n\tconst termValueLower = termValue.toLocaleLowerCase();\n\treturn terms.find(\n\t\t( term ) => term.name.toLocaleLowerCase() === termValueLower\n\t)?.id;\n};\n\nexport function TaxonomyControls( { onChange, query } ) {\n\tconst { postType, taxQuery } = query;\n\n\tconst taxonomies = useTaxonomies( postType );\n\tif ( ! taxonomies || taxonomies.length === 0 ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t{ taxonomies.map( ( taxonomy ) => {\n\t\t\t\tconst termIds = taxQuery?.[ taxonomy.slug ] || [];\n\t\t\t\tconst handleChange = ( newTermIds ) =>\n\t\t\t\t\tonChange( {\n\t\t\t\t\t\ttaxQuery: {\n\t\t\t\t\t\t\t...taxQuery,\n\t\t\t\t\t\t\t[ taxonomy.slug ]: newTermIds,\n\t\t\t\t\t\t},\n\t\t\t\t\t} );\n\n\t\t\t\treturn (\n\t\t\t\t\t<TaxonomyItem\n\t\t\t\t\t\tkey={ taxonomy.slug }\n\t\t\t\t\t\ttaxonomy={ taxonomy }\n\t\t\t\t\t\ttermIds={ termIds }\n\t\t\t\t\t\tonChange={ handleChange }\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</>\n\t);\n}\n\n/**\n * Renders a `FormTokenField` for a given taxonomy.\n *\n * @param {Object} props The props for the component.\n * @param {Object} props.taxonomy The taxonomy object.\n * @param {number[]} props.termIds An array with the block's term ids for the given taxonomy.\n * @param {Function} props.onChange Callback `onChange` function.\n * @return {JSX.Element} The rendered component.\n */\nfunction TaxonomyItem( { taxonomy, termIds, onChange } ) {\n\tconst [ search, setSearch ] = useState( '' );\n\tconst [ value, setValue ] = useState( EMPTY_ARRAY );\n\tconst [ suggestions, setSuggestions ] = useState( EMPTY_ARRAY );\n\tconst debouncedSearch = useDebounce( setSearch, 250 );\n\tconst { searchResults, searchHasResolved } = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! search ) {\n\t\t\t\treturn { searchResults: EMPTY_ARRAY, searchHasResolved: true };\n\t\t\t}\n\t\t\tconst { getEntityRecords, hasFinishedResolution } =\n\t\t\t\tselect( coreStore );\n\t\t\tconst selectorArgs = [\n\t\t\t\t'taxonomy',\n\t\t\t\ttaxonomy.slug,\n\t\t\t\t{\n\t\t\t\t\t...BASE_QUERY,\n\t\t\t\t\tsearch,\n\t\t\t\t\torderby: 'name',\n\t\t\t\t\texclude: termIds,\n\t\t\t\t\tper_page: 20,\n\t\t\t\t},\n\t\t\t];\n\t\t\treturn {\n\t\t\t\tsearchResults: getEntityRecords( ...selectorArgs ),\n\t\t\t\tsearchHasResolved: hasFinishedResolution(\n\t\t\t\t\t'getEntityRecords',\n\t\t\t\t\tselectorArgs\n\t\t\t\t),\n\t\t\t};\n\t\t},\n\t\t[ search, termIds ]\n\t);\n\t// `existingTerms` are the ones fetched from the API and their type is `{ id: number; name: string }`.\n\t// They are used to extract the terms' names to populate the `FormTokenField` properly\n\t// and to sanitize the provided `termIds`, by setting only the ones that exist.\n\tconst existingTerms = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! termIds?.length ) return EMPTY_ARRAY;\n\t\t\tconst { getEntityRecords } = select( coreStore );\n\t\t\treturn getEntityRecords( 'taxonomy', taxonomy.slug, {\n\t\t\t\t...BASE_QUERY,\n\t\t\t\tinclude: termIds,\n\t\t\t\tper_page: termIds.length,\n\t\t\t} );\n\t\t},\n\t\t[ termIds ]\n\t);\n\t// Update the `value` state only after the selectors are resolved\n\t// to avoid emptying the input when we're changing terms.\n\tuseEffect( () => {\n\t\tif ( ! termIds?.length ) {\n\t\t\tsetValue( EMPTY_ARRAY );\n\t\t}\n\t\tif ( ! existingTerms?.length ) return;\n\t\t// Returns only the existing entity ids. This prevents the component\n\t\t// from crashing in the editor, when non existing ids are provided.\n\t\tconst sanitizedValue = termIds.reduce( ( accumulator, id ) => {\n\t\t\tconst entity = existingTerms.find( ( term ) => term.id === id );\n\t\t\tif ( entity ) {\n\t\t\t\taccumulator.push( {\n\t\t\t\t\tid,\n\t\t\t\t\tvalue: entity.name,\n\t\t\t\t} );\n\t\t\t}\n\t\t\treturn accumulator;\n\t\t}, [] );\n\t\tsetValue( sanitizedValue );\n\t}, [ termIds, existingTerms ] );\n\t// Update suggestions only when the query has resolved.\n\tuseEffect( () => {\n\t\tif ( ! searchHasResolved ) return;\n\t\tsetSuggestions( searchResults.map( ( result ) => result.name ) );\n\t}, [ searchResults, searchHasResolved ] );\n\tconst onTermsChange = ( newTermValues ) => {\n\t\tconst newTermIds = new Set();\n\t\tfor ( const termValue of newTermValues ) {\n\t\t\tconst termId = getTermIdByTermValue( searchResults, termValue );\n\t\t\tif ( termId ) {\n\t\t\t\tnewTermIds.add( termId );\n\t\t\t}\n\t\t}\n\t\tsetSuggestions( EMPTY_ARRAY );\n\t\tonChange( Array.from( newTermIds ) );\n\t};\n\treturn (\n\t\t<div className=\"block-library-query-inspector__taxonomy-control\">\n\t\t\t<FormTokenField\n\t\t\t\tlabel={ taxonomy.name }\n\t\t\t\tvalue={ value }\n\t\t\t\tonInputChange={ debouncedSearch }\n\t\t\t\tsuggestions={ suggestions }\n\t\t\t\tonChange={ onTermsChange }\n\t\t\t\t__experimentalShowHowTo={ false }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/query/edit/inspector-controls/taxonomy-controls.js"],"names":["EMPTY_ARRAY","BASE_QUERY","order","_fields","context","getTermIdByTermValue","terms","termValue","termId","id","find","term","name","termValueLower","toLocaleLowerCase","TaxonomyControls","onChange","query","postType","taxQuery","taxonomies","length","map","taxonomy","termIds","slug","handleChange","newTermIds","TaxonomyItem","search","setSearch","value","setValue","suggestions","setSuggestions","debouncedSearch","searchResults","searchHasResolved","select","getEntityRecords","hasFinishedResolution","coreStore","selectorArgs","orderby","exclude","per_page","existingTerms","include","sanitizedValue","reduce","accumulator","entity","push","result","onTermsChange","newTermValues","Set","add","Array","from"],"mappings":";;;;;;;AAMA;;AAHA;;AACA;;AACA;;AAEA;;AAKA;;AAZA;AACA;AACA;;AAOA;AACA;AACA;AAGA,MAAMA,WAAW,GAAG,EAApB;AACA,MAAMC,UAAU,GAAG;AAClBC,EAAAA,KAAK,EAAE,KADW;AAElBC,EAAAA,OAAO,EAAE,SAFS;AAGlBC,EAAAA,OAAO,EAAE;AAHS,CAAnB,C,CAMA;;AACA,MAAMC,oBAAoB,GAAG,CAAEC,KAAF,EAASC,SAAT,KAAwB;AAAA;;AACpD;AACA,QAAMC,MAAM,GACX,CAAAD,SAAS,SAAT,IAAAA,SAAS,WAAT,YAAAA,SAAS,CAAEE,EAAX,MAAiBH,KAAjB,aAAiBA,KAAjB,sCAAiBA,KAAK,CAAEI,IAAP,CAAeC,IAAF,IAAYA,IAAI,CAACC,IAAL,KAAcL,SAAvC,CAAjB,gDAAiB,YAAoDE,EAArE,CADD;;AAEA,MAAKD,MAAL,EAAc;AACb,WAAOA,MAAP;AACA;AAED;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACC,QAAMK,cAAc,GAAGN,SAAS,CAACO,iBAAV,EAAvB;AACA,SAAOR,KAAP,aAAOA,KAAP,uCAAOA,KAAK,CAAEI,IAAP,CACJC,IAAF,IAAYA,IAAI,CAACC,IAAL,CAAUE,iBAAV,OAAkCD,c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AF,EAAiB7B,SAAjB,CAAnC;;AACA,UAAKC,MAAL,EAAc;AACbmB,QAAAA,UAAU,CAAC8B,GAAX,CAAgBjD,MAAhB;AACA;AACD;;AACD0B,IAAAA,cAAc,CAAElC,WAAF,CAAd;AACAgB,IAAAA,QAAQ,CAAE0C,KAAK,CAACC,IAAN,CAAYhC,UAAZ,CAAF,CAAR;AACA,GAVD;;AAWA,SACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,4BAAC,0BAAD;AACC,IAAA,KAAK,EAAGJ,QAAQ,CAACX,IADlB;AAEC,IAAA,KAAK,EAAGmB,KAFT;AAGC,IAAA,aAAa,EAAGI,eAHjB;AAIC,IAAA,WAAW,EAAGF,WAJf;AAKC,IAAA,QAAQ,EAAGqB,aALZ;AAMC,IAAA,uBAAuB,EAAG;AAN3B,IADD,CADD;AAYA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { FormTokenField } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useState, useEffect } from '@wordpress/element';\nimport { useDebounce } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { useTaxonomies } from '../../utils';\n\nconst EMPTY_ARRAY = [];\nconst BASE_QUERY = {\n\torder: 'asc',\n\t_fields: 'id,name',\n\tcontext: 'view',\n};\n\n// Helper function to get the term id based on user input in terms `FormTokenField`.\nconst getTermIdByTermValue = ( terms, termValue ) => {\n\t// First we check for exact match by `term.id` or case sensitive `term.name` match.\n\tconst termId =\n\t\ttermValue?.id || terms?.find( ( term ) => term.name === termValue )?.id;\n\tif ( termId ) {\n\t\treturn termId;\n\t}\n\n\t/**\n\t * Here we make an extra check for entered terms in a non case sensitive way,\n\t * to match user expectations, due to `FormTokenField` behaviour that shows\n\t * suggestions which are case insensitive.\n\t *\n\t * Although WP tries to discourage users to add terms with the same name (case insensitive),\n\t * it's still possible if you manually change the name, as long as the terms have different slugs.\n\t * In this edge case we always apply the first match from the terms list.\n\t */\n\tconst termValueLower = termValue.toLocaleLowerCase();\n\treturn terms?.find(\n\t\t( term ) => term.name.toLocaleLowerCase() === termValueLower\n\t)?.id;\n};\n\nexport function TaxonomyControls( { onChange, query } ) {\n\tconst { postType, taxQuery } = query;\n\n\tconst taxonomies = useTaxonomies( postType );\n\tif ( ! taxonomies || taxonomies.length === 0 ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t{ taxonomies.map( ( taxonomy ) => {\n\t\t\t\tconst termIds = taxQuery?.[ taxonomy.slug ] || [];\n\t\t\t\tconst handleChange = ( newTermIds ) =>\n\t\t\t\t\tonChange( {\n\t\t\t\t\t\ttaxQuery: {\n\t\t\t\t\t\t\t...taxQuery,\n\t\t\t\t\t\t\t[ taxonomy.slug ]: newTermIds,\n\t\t\t\t\t\t},\n\t\t\t\t\t} );\n\n\t\t\t\treturn (\n\t\t\t\t\t<TaxonomyItem\n\t\t\t\t\t\tkey={ taxonomy.slug }\n\t\t\t\t\t\ttaxonomy={ taxonomy }\n\t\t\t\t\t\ttermIds={ termIds }\n\t\t\t\t\t\tonChange={ handleChange }\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</>\n\t);\n}\n\n/**\n * Renders a `FormTokenField` for a given taxonomy.\n *\n * @param {Object} props The props for the component.\n * @param {Object} props.taxonomy The taxonomy object.\n * @param {number[]} props.termIds An array with the block's term ids for the given taxonomy.\n * @param {Function} props.onChange Callback `onChange` function.\n * @return {JSX.Element} The rendered component.\n */\nfunction TaxonomyItem( { taxonomy, termIds, onChange } ) {\n\tconst [ search, setSearch ] = useState( '' );\n\tconst [ value, setValue ] = useState( EMPTY_ARRAY );\n\tconst [ suggestions, setSuggestions ] = useState( EMPTY_ARRAY );\n\tconst debouncedSearch = useDebounce( setSearch, 250 );\n\tconst { searchResults, searchHasResolved } = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! search ) {\n\t\t\t\treturn { searchResults: EMPTY_ARRAY, searchHasResolved: true };\n\t\t\t}\n\t\t\tconst { getEntityRecords, hasFinishedResolution } =\n\t\t\t\tselect( coreStore );\n\t\t\tconst selectorArgs = [\n\t\t\t\t'taxonomy',\n\t\t\t\ttaxonomy.slug,\n\t\t\t\t{\n\t\t\t\t\t...BASE_QUERY,\n\t\t\t\t\tsearch,\n\t\t\t\t\torderby: 'name',\n\t\t\t\t\texclude: termIds,\n\t\t\t\t\tper_page: 20,\n\t\t\t\t},\n\t\t\t];\n\t\t\treturn {\n\t\t\t\tsearchResults: getEntityRecords( ...selectorArgs ),\n\t\t\t\tsearchHasResolved: hasFinishedResolution(\n\t\t\t\t\t'getEntityRecords',\n\t\t\t\t\tselectorArgs\n\t\t\t\t),\n\t\t\t};\n\t\t},\n\t\t[ search, termIds ]\n\t);\n\t// `existingTerms` are the ones fetched from the API and their type is `{ id: number; name: string }`.\n\t// They are used to extract the terms' names to populate the `FormTokenField` properly\n\t// and to sanitize the provided `termIds`, by setting only the ones that exist.\n\tconst existingTerms = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! termIds?.length ) return EMPTY_ARRAY;\n\t\t\tconst { getEntityRecords } = select( coreStore );\n\t\t\treturn getEntityRecords( 'taxonomy', taxonomy.slug, {\n\t\t\t\t...BASE_QUERY,\n\t\t\t\tinclude: termIds,\n\t\t\t\tper_page: termIds.length,\n\t\t\t} );\n\t\t},\n\t\t[ termIds ]\n\t);\n\t// Update the `value` state only after the selectors are resolved\n\t// to avoid emptying the input when we're changing terms.\n\tuseEffect( () => {\n\t\tif ( ! termIds?.length ) {\n\t\t\tsetValue( EMPTY_ARRAY );\n\t\t}\n\t\tif ( ! existingTerms?.length ) return;\n\t\t// Returns only the existing entity ids. This prevents the component\n\t\t// from crashing in the editor, when non existing ids are provided.\n\t\tconst sanitizedValue = termIds.reduce( ( accumulator, id ) => {\n\t\t\tconst entity = existingTerms.find( ( term ) => term.id === id );\n\t\t\tif ( entity ) {\n\t\t\t\taccumulator.push( {\n\t\t\t\t\tid,\n\t\t\t\t\tvalue: entity.name,\n\t\t\t\t} );\n\t\t\t}\n\t\t\treturn accumulator;\n\t\t}, [] );\n\t\tsetValue( sanitizedValue );\n\t}, [ termIds, existingTerms ] );\n\t// Update suggestions only when the query has resolved.\n\tuseEffect( () => {\n\t\tif ( ! searchHasResolved ) return;\n\t\tsetSuggestions( searchResults.map( ( result ) => result.name ) );\n\t}, [ searchResults, searchHasResolved ] );\n\tconst onTermsChange = ( newTermValues ) => {\n\t\tconst newTermIds = new Set();\n\t\tfor ( const termValue of newTermValues ) {\n\t\t\tconst termId = getTermIdByTermValue( searchResults, termValue );\n\t\t\tif ( termId ) {\n\t\t\t\tnewTermIds.add( termId );\n\t\t\t}\n\t\t}\n\t\tsetSuggestions( EMPTY_ARRAY );\n\t\tonChange( Array.from( newTermIds ) );\n\t};\n\treturn (\n\t\t<div className=\"block-library-query-inspector__taxonomy-control\">\n\t\t\t<FormTokenField\n\t\t\t\tlabel={ taxonomy.name }\n\t\t\t\tvalue={ value }\n\t\t\t\tonInputChange={ debouncedSearch }\n\t\t\t\tsuggestions={ suggestions }\n\t\t\t\tonChange={ onTermsChange }\n\t\t\t\t__experimentalShowHowTo={ false }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n"]}
@@ -6,7 +6,7 @@ import { createElement } from "@wordpress/element";
6
6
  import { experiments as blockEditorExperiments, InspectorControls, store as blockEditorStore } from '@wordpress/block-editor';
7
7
  import { PanelBody, __experimentalHStack as HStack, __experimentalHeading as Heading, Spinner } from '@wordpress/components';
8
8
  import { useSelect } from '@wordpress/data';
9
- import { __ } from '@wordpress/i18n';
9
+ import { __, sprintf } from '@wordpress/i18n';
10
10
  /**
11
11
  * Internal dependencies
12
12
  */
@@ -15,6 +15,7 @@ import NavigationMenuSelector from './navigation-menu-selector';
15
15
  import { LeafMoreMenu } from '../leaf-more-menu';
16
16
  import { unlock } from '../../experiments';
17
17
  import DeletedNavigationWarning from './deleted-navigation-warning';
18
+ import useNavigationMenu from '../use-navigation-menu';
18
19
  /* translators: %s: The name of a menu. */
19
20
 
20
21
  const actionLabel = __("Switch to '%s'");
@@ -38,12 +39,15 @@ const MainContent = _ref => {
38
39
  } = select(blockEditorStore);
39
40
  return __unstableGetClientIdsTree(clientId);
40
41
  }, [clientId]);
42
+ const {
43
+ navigationMenu
44
+ } = useNavigationMenu(currentMenuId);
41
45
 
42
46
  if (currentMenuId && isNavigationMenuMissing) {
43
47
  return createElement("p", null, __('Select or create a menu'));
44
48
  }
45
49
 
46
- if (isNavigationMenuMissing) {
50
+ if (currentMenuId && isNavigationMenuMissing) {
47
51
  return createElement(DeletedNavigationWarning, {
48
52
  onCreateNew: onCreateNew
49
53
  });
@@ -53,10 +57,14 @@ const MainContent = _ref => {
53
57
  return createElement(Spinner, null);
54
58
  }
55
59
 
60
+ const description = navigationMenu ? sprintf(
61
+ /* translators: %s: The name of a menu. */
62
+ __('Structure for navigation menu: %s'), (navigationMenu === null || navigationMenu === void 0 ? void 0 : navigationMenu.title) || __('Untitled menu')) : __('You have not yet created any menus. Displaying a list of your Pages');
56
63
  return createElement(OffCanvasEditor, {
57
64
  blocks: clientIdsTree,
58
65
  isExpanded: true,
59
- LeafMoreMenu: LeafMoreMenu
66
+ LeafMoreMenu: LeafMoreMenu,
67
+ description: description
60
68
  });
61
69
  };
62
70
 
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/navigation/edit/menu-inspector-controls.js"],"names":["experiments","blockEditorExperiments","InspectorControls","store","blockEditorStore","PanelBody","__experimentalHStack","HStack","__experimentalHeading","Heading","Spinner","useSelect","__","NavigationMenuSelector","LeafMoreMenu","unlock","DeletedNavigationWarning","actionLabel","MainContent","clientId","currentMenuId","isLoading","isNavigationMenuMissing","onCreateNew","OffCanvasEditor","clientIdsTree","select","__unstableGetClientIdsTree","MenuInspectorControls","props","createNavigationMenuIsSuccess","createNavigationMenuIsError","onSelectClassicMenu","onSelectNavigationMenu","isManageMenusButtonDisabled","process","env","IS_GUTENBERG_PLUGI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IAAA,MAAM,EAAGI,aADV;AAEC,IAAA,UAAU,EAAG,IAFd;AAGC,IAAA,YAAY,EAAGX;AAHhB,IADD;AAOA,CArCD;;AAuCA,MAAMc,qBAAqB,GAAKC,KAAF,IAAa;AAC1C,QAAM;AACLC,IAAAA,6BADK;AAELC,IAAAA,2BAFK;AAGLX,IAAAA,aAAa,GAAG,IAHX;AAILG,IAAAA,WAJK;AAKLS,IAAAA,mBALK;AAMLC,IAAAA,sBANK;AAOLC,IAAAA;AAPK,MAQFL,KARJ;AAUA,SACC,cAAC,iBAAD;AAAmB,IAAA,KAAK,EAAC;AAAzB,KACC,cAAC,SAAD;AACC,IAAA,KAAK,EAAGM,OAAO,CAACC,GAAR,CAAYC,mBAAZ,GAAkC,IAAlC,GAAyCzB,EAAE,CAAE,MAAF;AADpD,KAGC,cAAC,MAAD;AAAQ,IAAA,SAAS,EAAC;AAAlB,KACC,cAAC,OAAD;AACC,IAAA,SAAS,EAAC,8CADX;AAEC,IAAA,KAAK,EAAG;AAFT,KAIGA,EAAE,CAAE,MAAF,CAJL,CADD,EAOC,cAAC,sBAAD;AACC,IAAA,aAAa,EAAGQ,aADjB;AAEC,IAAA,mBAAmB,EAAGY,mBAFvB;AAGC,IAAA,sBAAsB,EAAGC,sBAH1B;AAIC,IAAA,WAAW,EAAGV,WAJf;AAKC,IAAA,6BAA6B,EAC5BO,6BANF;AAQC,IAAA,2BAA2B,EAC1BC,2BATF;AAWC,IAAA,WAAW,EAAGd,WAXf;AAYC,IAAA,2BAA2B,EAC1BiB;AAbF,IAPD,CAHD,EA2BC,cAAC,WAAD,EAAkBL,KAAlB,CA3BD,CADD,CADD;AAiCA,CA5CD;;AA8CA,eAAeD,qBAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\texperiments as blockEditorExperiments,\n\tInspectorControls,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport {\n\tPanelBody,\n\t__experimentalHStack as HStack,\n\t__experimentalHeading as Heading,\n\tSpinner,\n} from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport NavigationMenuSelector from './navigation-menu-selector';\nimport { LeafMoreMenu } from '../leaf-more-menu';\nimport { unlock } from '../../experiments';\nimport DeletedNavigationWarning from './deleted-navigation-warning';\n\n/* translators: %s: The name of a menu. */\nconst actionLabel = __( \"Switch to '%s'\" );\n\nconst MainContent = ( {\n\tclientId,\n\tcurrentMenuId,\n\tisLoading,\n\tisNavigationMenuMissing,\n\tonCreateNew,\n} ) => {\n\tconst { OffCanvasEditor } = unlock( blockEditorExperiments );\n\t// Provide a hierarchy of clientIds for the given Navigation block (clientId).\n\t// This is required else the list view will display the entire block tree.\n\tconst clientIdsTree = useSelect(\n\t\t( select ) => {\n\t\t\tconst { __unstableGetClientIdsTree } = select( blockEditorStore );\n\t\t\treturn __unstableGetClientIdsTree( clientId );\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tif ( currentMenuId && isNavigationMenuMissing ) {\n\t\treturn <p>{ __( 'Select or create a menu' ) }</p>;\n\t}\n\n\tif ( isNavigationMenuMissing ) {\n\t\treturn <DeletedNavigationWarning onCreateNew={ onCreateNew } />;\n\t}\n\n\tif ( isLoading ) {\n\t\treturn <Spinner />;\n\t}\n\n\treturn (\n\t\t<OffCanvasEditor\n\t\t\tblocks={ clientIdsTree }\n\t\t\tisExpanded={ true }\n\t\t\tLeafMoreMenu={ LeafMoreMenu }\n\t\t/>\n\t);\n};\n\nconst MenuInspectorControls = ( props ) => {\n\tconst {\n\t\tcreateNavigationMenuIsSuccess,\n\t\tcreateNavigationMenuIsError,\n\t\tcurrentMenuId = null,\n\t\tonCreateNew,\n\t\tonSelectClassicMenu,\n\t\tonSelectNavigationMenu,\n\t\tisManageMenusButtonDisabled,\n\t} = props;\n\n\treturn (\n\t\t<InspectorControls group=\"list\">\n\t\t\t<PanelBody\n\t\t\t\ttitle={ process.env.IS_GUTENBERG_PLUGIN ? null : __( 'Menu' ) }\n\t\t\t>\n\t\t\t\t<HStack className=\"wp-block-navigation-off-canvas-editor__header\">\n\t\t\t\t\t<Heading\n\t\t\t\t\t\tclassName=\"wp-block-navigation-off-canvas-editor__title\"\n\t\t\t\t\t\tlevel={ 2 }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Menu' ) }\n\t\t\t\t\t</Heading>\n\t\t\t\t\t<NavigationMenuSelector\n\t\t\t\t\t\tcurrentMenuId={ currentMenuId }\n\t\t\t\t\t\tonSelectClassicMenu={ onSelectClassicMenu }\n\t\t\t\t\t\tonSelectNavigationMenu={ onSelectNavigationMenu }\n\t\t\t\t\t\tonCreateNew={ onCreateNew }\n\t\t\t\t\t\tcreateNavigationMenuIsSuccess={\n\t\t\t\t\t\t\tcreateNavigationMenuIsSuccess\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcreateNavigationMenuIsError={\n\t\t\t\t\t\t\tcreateNavigationMenuIsError\n\t\t\t\t\t\t}\n\t\t\t\t\t\tactionLabel={ actionLabel }\n\t\t\t\t\t\tisManageMenusButtonDisabled={\n\t\t\t\t\t\t\tisManageMenusButtonDisabled\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t</HStack>\n\t\t\t\t<MainContent { ...props } />\n\t\t\t</PanelBody>\n\t\t</InspectorControls>\n\t);\n};\n\nexport default MenuInspectorControls;\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/navigation/edit/menu-inspector-controls.js"],"names":["experiments","blockEditorExperiments","InspectorControls","store","blockEditorStore","PanelBody","__experimentalHStack","HStack","__experimentalHeading","Heading","Spinner","useSelect","__","sprintf","NavigationMenuSelector","LeafMoreMenu","unlock","DeletedNavigationWarning","useNavigationMenu","actionLabel","MainContent","clientId","currentMenuId","isLoading","isNavigationMenuMissing","onCreateNew","OffCanvasEditor","clientIdsTree","select","__unstableGetClientIdsTree","navigationMenu","description","title","MenuInspectorControls","props","createNavigationMenuIsSuccess","createNavigationMenuIsError","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,IAAA,sBAAsB,EAAGC,sBAH1B;AAIC,IAAA,WAAW,EAAGb,WAJf;AAKC,IAAA,6BAA6B,EAC5BU,6BANF;AAQC,IAAA,2BAA2B,EAC1BC,2BATF;AAWC,IAAA,WAAW,EAAGjB,WAXf;AAYC,IAAA,2BAA2B,EAC1BoB;AAbF,IAPD,CAHD,EA2BC,cAAC,WAAD,EAAkBL,KAAlB,CA3BD,CADD,CADD;AAiCA,CA5CD;;AA8CA,eAAeD,qBAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\texperiments as blockEditorExperiments,\n\tInspectorControls,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport {\n\tPanelBody,\n\t__experimentalHStack as HStack,\n\t__experimentalHeading as Heading,\n\tSpinner,\n} from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { __, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport NavigationMenuSelector from './navigation-menu-selector';\nimport { LeafMoreMenu } from '../leaf-more-menu';\nimport { unlock } from '../../experiments';\nimport DeletedNavigationWarning from './deleted-navigation-warning';\nimport useNavigationMenu from '../use-navigation-menu';\n\n/* translators: %s: The name of a menu. */\nconst actionLabel = __( \"Switch to '%s'\" );\n\nconst MainContent = ( {\n\tclientId,\n\tcurrentMenuId,\n\tisLoading,\n\tisNavigationMenuMissing,\n\tonCreateNew,\n} ) => {\n\tconst { OffCanvasEditor } = unlock( blockEditorExperiments );\n\t// Provide a hierarchy of clientIds for the given Navigation block (clientId).\n\t// This is required else the list view will display the entire block tree.\n\tconst clientIdsTree = useSelect(\n\t\t( select ) => {\n\t\t\tconst { __unstableGetClientIdsTree } = select( blockEditorStore );\n\t\t\treturn __unstableGetClientIdsTree( clientId );\n\t\t},\n\t\t[ clientId ]\n\t);\n\tconst { navigationMenu } = useNavigationMenu( currentMenuId );\n\n\tif ( currentMenuId && isNavigationMenuMissing ) {\n\t\treturn <p>{ __( 'Select or create a menu' ) }</p>;\n\t}\n\n\tif ( currentMenuId && isNavigationMenuMissing ) {\n\t\treturn <DeletedNavigationWarning onCreateNew={ onCreateNew } />;\n\t}\n\n\tif ( isLoading ) {\n\t\treturn <Spinner />;\n\t}\n\n\tconst description = navigationMenu\n\t\t? sprintf(\n\t\t\t\t/* translators: %s: The name of a menu. */\n\t\t\t\t__( 'Structure for navigation menu: %s' ),\n\t\t\t\tnavigationMenu?.title || __( 'Untitled menu' )\n\t\t )\n\t\t: __(\n\t\t\t\t'You have not yet created any menus. Displaying a list of your Pages'\n\t\t );\n\treturn (\n\t\t<OffCanvasEditor\n\t\t\tblocks={ clientIdsTree }\n\t\t\tisExpanded={ true }\n\t\t\tLeafMoreMenu={ LeafMoreMenu }\n\t\t\tdescription={ description }\n\t\t/>\n\t);\n};\n\nconst MenuInspectorControls = ( props ) => {\n\tconst {\n\t\tcreateNavigationMenuIsSuccess,\n\t\tcreateNavigationMenuIsError,\n\t\tcurrentMenuId = null,\n\t\tonCreateNew,\n\t\tonSelectClassicMenu,\n\t\tonSelectNavigationMenu,\n\t\tisManageMenusButtonDisabled,\n\t} = props;\n\n\treturn (\n\t\t<InspectorControls group=\"list\">\n\t\t\t<PanelBody\n\t\t\t\ttitle={ process.env.IS_GUTENBERG_PLUGIN ? null : __( 'Menu' ) }\n\t\t\t>\n\t\t\t\t<HStack className=\"wp-block-navigation-off-canvas-editor__header\">\n\t\t\t\t\t<Heading\n\t\t\t\t\t\tclassName=\"wp-block-navigation-off-canvas-editor__title\"\n\t\t\t\t\t\tlevel={ 2 }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Menu' ) }\n\t\t\t\t\t</Heading>\n\t\t\t\t\t<NavigationMenuSelector\n\t\t\t\t\t\tcurrentMenuId={ currentMenuId }\n\t\t\t\t\t\tonSelectClassicMenu={ onSelectClassicMenu }\n\t\t\t\t\t\tonSelectNavigationMenu={ onSelectNavigationMenu }\n\t\t\t\t\t\tonCreateNew={ onCreateNew }\n\t\t\t\t\t\tcreateNavigationMenuIsSuccess={\n\t\t\t\t\t\t\tcreateNavigationMenuIsSuccess\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcreateNavigationMenuIsError={\n\t\t\t\t\t\t\tcreateNavigationMenuIsError\n\t\t\t\t\t\t}\n\t\t\t\t\t\tactionLabel={ actionLabel }\n\t\t\t\t\t\tisManageMenusButtonDisabled={\n\t\t\t\t\t\t\tisManageMenusButtonDisabled\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t</HStack>\n\t\t\t\t<MainContent { ...props } />\n\t\t\t</PanelBody>\n\t\t</InspectorControls>\n\t);\n};\n\nexport default MenuInspectorControls;\n"]}
@@ -24,7 +24,7 @@ const getTermIdByTermValue = (terms, termValue) => {
24
24
  var _terms$find, _terms$find2;
25
25
 
26
26
  // First we check for exact match by `term.id` or case sensitive `term.name` match.
27
- const termId = (termValue === null || termValue === void 0 ? void 0 : termValue.id) || ((_terms$find = terms.find(term => term.name === termValue)) === null || _terms$find === void 0 ? void 0 : _terms$find.id);
27
+ const termId = (termValue === null || termValue === void 0 ? void 0 : termValue.id) || (terms === null || terms === void 0 ? void 0 : (_terms$find = terms.find(term => term.name === termValue)) === null || _terms$find === void 0 ? void 0 : _terms$find.id);
28
28
 
29
29
  if (termId) {
30
30
  return termId;
@@ -41,7 +41,7 @@ const getTermIdByTermValue = (terms, termValue) => {
41
41
 
42
42
 
43
43
  const termValueLower = termValue.toLocaleLowerCase();
44
- return (_terms$find2 = terms.find(term => term.name.toLocaleLowerCase() === termValueLower)) === null || _terms$find2 === void 0 ? void 0 : _terms$find2.id;
44
+ return terms === null || terms === void 0 ? void 0 : (_terms$find2 = terms.find(term => term.name.toLocaleLowerCase() === termValueLower)) === null || _terms$find2 === void 0 ? void 0 : _terms$find2.id;
45
45
  };
46
46
 
47
47
  export function TaxonomyControls(_ref) {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/query/edit/inspector-controls/taxonomy-controls.js"],"names":["FormTokenField","useSelect","store","coreStore","useState","useEffect","useDebounce","useTaxonomies","EMPTY_ARRAY","BASE_QUERY","order","_fields","context","getTermIdByTermValue","terms","termValue","termId","id","find","term","name","termValueLower","toLocaleLowerCase","TaxonomyControls","onChange","query","postType","taxQuery","taxonomies","length","map","taxonomy","termIds","slug","handleChange","newTermIds","TaxonomyItem","search","setSearch","value","setValue","suggestions","setSuggestions","debouncedSearch","searchResults","searchHasResolved","select","getEntityRecords","hasFinishedResolution","selectorArgs","orderby","exclude","per_page","existingTerms","include","sanitizedValue","reduce","accumulator","entity","push","result","onTermsChange","newTermValues","Set","add","Array","from"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,cAAT,QAA+B,uBAA/B;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SAASC,KAAK,IAAIC,SAAlB,QAAmC,sBAAnC;AACA,SAASC,QAAT,EAAmBC,SAAnB,QAAoC,oBAApC;AACA,SAASC,WAAT,QAA4B,oBAA5B;AAEA;AACA;AACA;;AACA,SAASC,aAAT,QAA8B,aAA9B;AAEA,MAAMC,WAAW,GAAG,EAApB;AACA,MAAMC,UAAU,GAAG;AAClBC,EAAAA,KAAK,EAAE,KADW;AAElBC,EAAAA,OAAO,EAAE,SAFS;AAGlBC,EAAAA,OAAO,EAAE;AAHS,CAAnB,C,CAMA;;AACA,MAAMC,oBAAoB,GAAG,CAAEC,KAAF,EAASC,SAAT,KAAwB;AAAA;;AACpD;AACA,QAAMC,MAAM,GACX,CAAAD,SAAS,SAAT,IAAAA,SAAS,WAAT,YAAAA,SAAS,CAAEE,EAAX,qBAAiBH,KAAK,CAACI,IAAN,CAAcC,IAAF,IAAYA,IAAI,CAACC,IAAL,KAAcL,SAAtC,CAAjB,gDAAiB,YAAmDE,EAApE,CADD;;AAEA,MAAKD,MAAL,EAAc;AACb,WAAOA,MAAP;AACA;AAED;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACC,QAAMK,cAAc,GAAGN,SAAS,CAACO,iBAAV,EAAvB;A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,CAHM,CAAT;;AAIA,QAAMgB,aAAa,GAAKC,aAAF,IAAqB;AAC1C,UAAM3B,UAAU,GAAG,IAAI4B,GAAJ,EAAnB;;AACA,SAAM,MAAMhD,SAAZ,IAAyB+C,aAAzB,EAAyC;AACxC,YAAM9C,MAAM,GAAGH,oBAAoB,CAAE+B,aAAF,EAAiB7B,SAAjB,CAAnC;;AACA,UAAKC,MAAL,EAAc;AACbmB,QAAAA,UAAU,CAAC6B,GAAX,CAAgBhD,MAAhB;AACA;AACD;;AACD0B,IAAAA,cAAc,CAAElC,WAAF,CAAd;AACAgB,IAAAA,QAAQ,CAAEyC,KAAK,CAACC,IAAN,CAAY/B,UAAZ,CAAF,CAAR;AACA,GAVD;;AAWA,SACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,cAAC,cAAD;AACC,IAAA,KAAK,EAAGJ,QAAQ,CAACX,IADlB;AAEC,IAAA,KAAK,EAAGmB,KAFT;AAGC,IAAA,aAAa,EAAGI,eAHjB;AAIC,IAAA,WAAW,EAAGF,WAJf;AAKC,IAAA,QAAQ,EAAGoB,aALZ;AAMC,IAAA,uBAAuB,EAAG;AAN3B,IADD,CADD;AAYA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { FormTokenField } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useState, useEffect } from '@wordpress/element';\nimport { useDebounce } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { useTaxonomies } from '../../utils';\n\nconst EMPTY_ARRAY = [];\nconst BASE_QUERY = {\n\torder: 'asc',\n\t_fields: 'id,name',\n\tcontext: 'view',\n};\n\n// Helper function to get the term id based on user input in terms `FormTokenField`.\nconst getTermIdByTermValue = ( terms, termValue ) => {\n\t// First we check for exact match by `term.id` or case sensitive `term.name` match.\n\tconst termId =\n\t\ttermValue?.id || terms.find( ( term ) => term.name === termValue )?.id;\n\tif ( termId ) {\n\t\treturn termId;\n\t}\n\n\t/**\n\t * Here we make an extra check for entered terms in a non case sensitive way,\n\t * to match user expectations, due to `FormTokenField` behaviour that shows\n\t * suggestions which are case insensitive.\n\t *\n\t * Although WP tries to discourage users to add terms with the same name (case insensitive),\n\t * it's still possible if you manually change the name, as long as the terms have different slugs.\n\t * In this edge case we always apply the first match from the terms list.\n\t */\n\tconst termValueLower = termValue.toLocaleLowerCase();\n\treturn terms.find(\n\t\t( term ) => term.name.toLocaleLowerCase() === termValueLower\n\t)?.id;\n};\n\nexport function TaxonomyControls( { onChange, query } ) {\n\tconst { postType, taxQuery } = query;\n\n\tconst taxonomies = useTaxonomies( postType );\n\tif ( ! taxonomies || taxonomies.length === 0 ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t{ taxonomies.map( ( taxonomy ) => {\n\t\t\t\tconst termIds = taxQuery?.[ taxonomy.slug ] || [];\n\t\t\t\tconst handleChange = ( newTermIds ) =>\n\t\t\t\t\tonChange( {\n\t\t\t\t\t\ttaxQuery: {\n\t\t\t\t\t\t\t...taxQuery,\n\t\t\t\t\t\t\t[ taxonomy.slug ]: newTermIds,\n\t\t\t\t\t\t},\n\t\t\t\t\t} );\n\n\t\t\t\treturn (\n\t\t\t\t\t<TaxonomyItem\n\t\t\t\t\t\tkey={ taxonomy.slug }\n\t\t\t\t\t\ttaxonomy={ taxonomy }\n\t\t\t\t\t\ttermIds={ termIds }\n\t\t\t\t\t\tonChange={ handleChange }\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</>\n\t);\n}\n\n/**\n * Renders a `FormTokenField` for a given taxonomy.\n *\n * @param {Object} props The props for the component.\n * @param {Object} props.taxonomy The taxonomy object.\n * @param {number[]} props.termIds An array with the block's term ids for the given taxonomy.\n * @param {Function} props.onChange Callback `onChange` function.\n * @return {JSX.Element} The rendered component.\n */\nfunction TaxonomyItem( { taxonomy, termIds, onChange } ) {\n\tconst [ search, setSearch ] = useState( '' );\n\tconst [ value, setValue ] = useState( EMPTY_ARRAY );\n\tconst [ suggestions, setSuggestions ] = useState( EMPTY_ARRAY );\n\tconst debouncedSearch = useDebounce( setSearch, 250 );\n\tconst { searchResults, searchHasResolved } = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! search ) {\n\t\t\t\treturn { searchResults: EMPTY_ARRAY, searchHasResolved: true };\n\t\t\t}\n\t\t\tconst { getEntityRecords, hasFinishedResolution } =\n\t\t\t\tselect( coreStore );\n\t\t\tconst selectorArgs = [\n\t\t\t\t'taxonomy',\n\t\t\t\ttaxonomy.slug,\n\t\t\t\t{\n\t\t\t\t\t...BASE_QUERY,\n\t\t\t\t\tsearch,\n\t\t\t\t\torderby: 'name',\n\t\t\t\t\texclude: termIds,\n\t\t\t\t\tper_page: 20,\n\t\t\t\t},\n\t\t\t];\n\t\t\treturn {\n\t\t\t\tsearchResults: getEntityRecords( ...selectorArgs ),\n\t\t\t\tsearchHasResolved: hasFinishedResolution(\n\t\t\t\t\t'getEntityRecords',\n\t\t\t\t\tselectorArgs\n\t\t\t\t),\n\t\t\t};\n\t\t},\n\t\t[ search, termIds ]\n\t);\n\t// `existingTerms` are the ones fetched from the API and their type is `{ id: number; name: string }`.\n\t// They are used to extract the terms' names to populate the `FormTokenField` properly\n\t// and to sanitize the provided `termIds`, by setting only the ones that exist.\n\tconst existingTerms = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! termIds?.length ) return EMPTY_ARRAY;\n\t\t\tconst { getEntityRecords } = select( coreStore );\n\t\t\treturn getEntityRecords( 'taxonomy', taxonomy.slug, {\n\t\t\t\t...BASE_QUERY,\n\t\t\t\tinclude: termIds,\n\t\t\t\tper_page: termIds.length,\n\t\t\t} );\n\t\t},\n\t\t[ termIds ]\n\t);\n\t// Update the `value` state only after the selectors are resolved\n\t// to avoid emptying the input when we're changing terms.\n\tuseEffect( () => {\n\t\tif ( ! termIds?.length ) {\n\t\t\tsetValue( EMPTY_ARRAY );\n\t\t}\n\t\tif ( ! existingTerms?.length ) return;\n\t\t// Returns only the existing entity ids. This prevents the component\n\t\t// from crashing in the editor, when non existing ids are provided.\n\t\tconst sanitizedValue = termIds.reduce( ( accumulator, id ) => {\n\t\t\tconst entity = existingTerms.find( ( term ) => term.id === id );\n\t\t\tif ( entity ) {\n\t\t\t\taccumulator.push( {\n\t\t\t\t\tid,\n\t\t\t\t\tvalue: entity.name,\n\t\t\t\t} );\n\t\t\t}\n\t\t\treturn accumulator;\n\t\t}, [] );\n\t\tsetValue( sanitizedValue );\n\t}, [ termIds, existingTerms ] );\n\t// Update suggestions only when the query has resolved.\n\tuseEffect( () => {\n\t\tif ( ! searchHasResolved ) return;\n\t\tsetSuggestions( searchResults.map( ( result ) => result.name ) );\n\t}, [ searchResults, searchHasResolved ] );\n\tconst onTermsChange = ( newTermValues ) => {\n\t\tconst newTermIds = new Set();\n\t\tfor ( const termValue of newTermValues ) {\n\t\t\tconst termId = getTermIdByTermValue( searchResults, termValue );\n\t\t\tif ( termId ) {\n\t\t\t\tnewTermIds.add( termId );\n\t\t\t}\n\t\t}\n\t\tsetSuggestions( EMPTY_ARRAY );\n\t\tonChange( Array.from( newTermIds ) );\n\t};\n\treturn (\n\t\t<div className=\"block-library-query-inspector__taxonomy-control\">\n\t\t\t<FormTokenField\n\t\t\t\tlabel={ taxonomy.name }\n\t\t\t\tvalue={ value }\n\t\t\t\tonInputChange={ debouncedSearch }\n\t\t\t\tsuggestions={ suggestions }\n\t\t\t\tonChange={ onTermsChange }\n\t\t\t\t__experimentalShowHowTo={ false }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/query/edit/inspector-controls/taxonomy-controls.js"],"names":["FormTokenField","useSelect","store","coreStore","useState","useEffect","useDebounce","useTaxonomies","EMPTY_ARRAY","BASE_QUERY","order","_fields","context","getTermIdByTermValue","terms","termValue","termId","id","find","term","name","termValueLower","toLocaleLowerCase","TaxonomyControls","onChange","query","postType","taxQuery","taxonomies","length","map","taxonomy","termIds","slug","handleChange","newTermIds","TaxonomyItem","search","setSearch","value","setValue","suggestions","setSuggestions","debouncedSearch","searchResults","searchHasResolved","select","getEntityRecords","hasFinishedResolution","selectorArgs","orderby","exclude","per_page","existingTerms","include","sanitizedValue","reduce","accumulator","entity","push","result","onTermsChange","newTermValues","Set","add","Array","from"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,cAAT,QAA+B,uBAA/B;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SAASC,KAAK,IAAIC,SAAlB,QAAmC,sBAAnC;AACA,SAASC,QAAT,EAAmBC,SAAnB,QAAoC,oBAApC;AACA,SAASC,WAAT,QAA4B,oBAA5B;AAEA;AACA;AACA;;AACA,SAASC,aAAT,QAA8B,aAA9B;AAEA,MAAMC,WAAW,GAAG,EAApB;AACA,MAAMC,UAAU,GAAG;AAClBC,EAAAA,KAAK,EAAE,KADW;AAElBC,EAAAA,OAAO,EAAE,SAFS;AAGlBC,EAAAA,OAAO,EAAE;AAHS,CAAnB,C,CAMA;;AACA,MAAMC,oBAAoB,GAAG,CAAEC,KAAF,EAASC,SAAT,KAAwB;AAAA;;AACpD;AACA,QAAMC,MAAM,GACX,CAAAD,SAAS,SAAT,IAAAA,SAAS,WAAT,YAAAA,SAAS,CAAEE,EAAX,MAAiBH,KAAjB,aAAiBA,KAAjB,sCAAiBA,KAAK,CAAEI,IAAP,CAAeC,IAAF,IAAYA,IAAI,CAACC,IAAL,KAAcL,SAAvC,CAAjB,gDAAiB,YAAoDE,EAArE,CADD;;AAEA,MAAKD,MAAL,EAAc;AACb,WAAOA,MAAP;AACA;AAED;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACC,QAAMK,cAAc,GAAGN,SAAS,CAACO,iBAAV,EAAvB;AACA,SAAOR,KAAP,aAAOA,KAAP,uCAAOA,KAAK,CAAEI,IAAP,CACJC,IAAF,IAAYA,IAAI,CAACC,IAAL,CAAUE,iBAAV,OAAkCD,cADxC,CAAP,iDAAO,aAEJJ,EAF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MhD,SAAZ,IAAyB+C,aAAzB,EAAyC;AACxC,YAAM9C,MAAM,GAAGH,oBAAoB,CAAE+B,aAAF,EAAiB7B,SAAjB,CAAnC;;AACA,UAAKC,MAAL,EAAc;AACbmB,QAAAA,UAAU,CAAC6B,GAAX,CAAgBhD,MAAhB;AACA;AACD;;AACD0B,IAAAA,cAAc,CAAElC,WAAF,CAAd;AACAgB,IAAAA,QAAQ,CAAEyC,KAAK,CAACC,IAAN,CAAY/B,UAAZ,CAAF,CAAR;AACA,GAVD;;AAWA,SACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,cAAC,cAAD;AACC,IAAA,KAAK,EAAGJ,QAAQ,CAACX,IADlB;AAEC,IAAA,KAAK,EAAGmB,KAFT;AAGC,IAAA,aAAa,EAAGI,eAHjB;AAIC,IAAA,WAAW,EAAGF,WAJf;AAKC,IAAA,QAAQ,EAAGoB,aALZ;AAMC,IAAA,uBAAuB,EAAG;AAN3B,IADD,CADD;AAYA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { FormTokenField } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useState, useEffect } from '@wordpress/element';\nimport { useDebounce } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { useTaxonomies } from '../../utils';\n\nconst EMPTY_ARRAY = [];\nconst BASE_QUERY = {\n\torder: 'asc',\n\t_fields: 'id,name',\n\tcontext: 'view',\n};\n\n// Helper function to get the term id based on user input in terms `FormTokenField`.\nconst getTermIdByTermValue = ( terms, termValue ) => {\n\t// First we check for exact match by `term.id` or case sensitive `term.name` match.\n\tconst termId =\n\t\ttermValue?.id || terms?.find( ( term ) => term.name === termValue )?.id;\n\tif ( termId ) {\n\t\treturn termId;\n\t}\n\n\t/**\n\t * Here we make an extra check for entered terms in a non case sensitive way,\n\t * to match user expectations, due to `FormTokenField` behaviour that shows\n\t * suggestions which are case insensitive.\n\t *\n\t * Although WP tries to discourage users to add terms with the same name (case insensitive),\n\t * it's still possible if you manually change the name, as long as the terms have different slugs.\n\t * In this edge case we always apply the first match from the terms list.\n\t */\n\tconst termValueLower = termValue.toLocaleLowerCase();\n\treturn terms?.find(\n\t\t( term ) => term.name.toLocaleLowerCase() === termValueLower\n\t)?.id;\n};\n\nexport function TaxonomyControls( { onChange, query } ) {\n\tconst { postType, taxQuery } = query;\n\n\tconst taxonomies = useTaxonomies( postType );\n\tif ( ! taxonomies || taxonomies.length === 0 ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t{ taxonomies.map( ( taxonomy ) => {\n\t\t\t\tconst termIds = taxQuery?.[ taxonomy.slug ] || [];\n\t\t\t\tconst handleChange = ( newTermIds ) =>\n\t\t\t\t\tonChange( {\n\t\t\t\t\t\ttaxQuery: {\n\t\t\t\t\t\t\t...taxQuery,\n\t\t\t\t\t\t\t[ taxonomy.slug ]: newTermIds,\n\t\t\t\t\t\t},\n\t\t\t\t\t} );\n\n\t\t\t\treturn (\n\t\t\t\t\t<TaxonomyItem\n\t\t\t\t\t\tkey={ taxonomy.slug }\n\t\t\t\t\t\ttaxonomy={ taxonomy }\n\t\t\t\t\t\ttermIds={ termIds }\n\t\t\t\t\t\tonChange={ handleChange }\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</>\n\t);\n}\n\n/**\n * Renders a `FormTokenField` for a given taxonomy.\n *\n * @param {Object} props The props for the component.\n * @param {Object} props.taxonomy The taxonomy object.\n * @param {number[]} props.termIds An array with the block's term ids for the given taxonomy.\n * @param {Function} props.onChange Callback `onChange` function.\n * @return {JSX.Element} The rendered component.\n */\nfunction TaxonomyItem( { taxonomy, termIds, onChange } ) {\n\tconst [ search, setSearch ] = useState( '' );\n\tconst [ value, setValue ] = useState( EMPTY_ARRAY );\n\tconst [ suggestions, setSuggestions ] = useState( EMPTY_ARRAY );\n\tconst debouncedSearch = useDebounce( setSearch, 250 );\n\tconst { searchResults, searchHasResolved } = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! search ) {\n\t\t\t\treturn { searchResults: EMPTY_ARRAY, searchHasResolved: true };\n\t\t\t}\n\t\t\tconst { getEntityRecords, hasFinishedResolution } =\n\t\t\t\tselect( coreStore );\n\t\t\tconst selectorArgs = [\n\t\t\t\t'taxonomy',\n\t\t\t\ttaxonomy.slug,\n\t\t\t\t{\n\t\t\t\t\t...BASE_QUERY,\n\t\t\t\t\tsearch,\n\t\t\t\t\torderby: 'name',\n\t\t\t\t\texclude: termIds,\n\t\t\t\t\tper_page: 20,\n\t\t\t\t},\n\t\t\t];\n\t\t\treturn {\n\t\t\t\tsearchResults: getEntityRecords( ...selectorArgs ),\n\t\t\t\tsearchHasResolved: hasFinishedResolution(\n\t\t\t\t\t'getEntityRecords',\n\t\t\t\t\tselectorArgs\n\t\t\t\t),\n\t\t\t};\n\t\t},\n\t\t[ search, termIds ]\n\t);\n\t// `existingTerms` are the ones fetched from the API and their type is `{ id: number; name: string }`.\n\t// They are used to extract the terms' names to populate the `FormTokenField` properly\n\t// and to sanitize the provided `termIds`, by setting only the ones that exist.\n\tconst existingTerms = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! termIds?.length ) return EMPTY_ARRAY;\n\t\t\tconst { getEntityRecords } = select( coreStore );\n\t\t\treturn getEntityRecords( 'taxonomy', taxonomy.slug, {\n\t\t\t\t...BASE_QUERY,\n\t\t\t\tinclude: termIds,\n\t\t\t\tper_page: termIds.length,\n\t\t\t} );\n\t\t},\n\t\t[ termIds ]\n\t);\n\t// Update the `value` state only after the selectors are resolved\n\t// to avoid emptying the input when we're changing terms.\n\tuseEffect( () => {\n\t\tif ( ! termIds?.length ) {\n\t\t\tsetValue( EMPTY_ARRAY );\n\t\t}\n\t\tif ( ! existingTerms?.length ) return;\n\t\t// Returns only the existing entity ids. This prevents the component\n\t\t// from crashing in the editor, when non existing ids are provided.\n\t\tconst sanitizedValue = termIds.reduce( ( accumulator, id ) => {\n\t\t\tconst entity = existingTerms.find( ( term ) => term.id === id );\n\t\t\tif ( entity ) {\n\t\t\t\taccumulator.push( {\n\t\t\t\t\tid,\n\t\t\t\t\tvalue: entity.name,\n\t\t\t\t} );\n\t\t\t}\n\t\t\treturn accumulator;\n\t\t}, [] );\n\t\tsetValue( sanitizedValue );\n\t}, [ termIds, existingTerms ] );\n\t// Update suggestions only when the query has resolved.\n\tuseEffect( () => {\n\t\tif ( ! searchHasResolved ) return;\n\t\tsetSuggestions( searchResults.map( ( result ) => result.name ) );\n\t}, [ searchResults, searchHasResolved ] );\n\tconst onTermsChange = ( newTermValues ) => {\n\t\tconst newTermIds = new Set();\n\t\tfor ( const termValue of newTermValues ) {\n\t\t\tconst termId = getTermIdByTermValue( searchResults, termValue );\n\t\t\tif ( termId ) {\n\t\t\t\tnewTermIds.add( termId );\n\t\t\t}\n\t\t}\n\t\tsetSuggestions( EMPTY_ARRAY );\n\t\tonChange( Array.from( newTermIds ) );\n\t};\n\treturn (\n\t\t<div className=\"block-library-query-inspector__taxonomy-control\">\n\t\t\t<FormTokenField\n\t\t\t\tlabel={ taxonomy.name }\n\t\t\t\tvalue={ value }\n\t\t\t\tonInputChange={ debouncedSearch }\n\t\t\t\tsuggestions={ suggestions }\n\t\t\t\tonChange={ onTermsChange }\n\t\t\t\t__experimentalShowHowTo={ false }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n"]}
@@ -302,4 +302,18 @@ html :where(img[class*="wp-image-"]) {
302
302
  */
303
303
  figure {
304
304
  margin: 0 0 1em 0;
305
+ }
306
+
307
+ html :where(.is-position-sticky) {
308
+ /* stylelint-disable length-zero-no-unit */
309
+ --wp-admin--admin-bar--position-offset: var(--wp-admin--admin-bar--height, 0px);
310
+ /* stylelint-enable length-zero-no-unit */
311
+ }
312
+
313
+ @media screen and (max-width: 600px) {
314
+ html :where(.is-position-sticky) {
315
+ /* stylelint-disable length-zero-no-unit */
316
+ --wp-admin--admin-bar--position-offset: 0px;
317
+ /* stylelint-enable length-zero-no-unit */
318
+ }
305
319
  }
@@ -304,4 +304,18 @@ html :where(img[class*="wp-image-"]) {
304
304
  */
305
305
  figure {
306
306
  margin: 0 0 1em 0;
307
+ }
308
+
309
+ html :where(.is-position-sticky) {
310
+ /* stylelint-disable length-zero-no-unit */
311
+ --wp-admin--admin-bar--position-offset: var(--wp-admin--admin-bar--height, 0px);
312
+ /* stylelint-enable length-zero-no-unit */
313
+ }
314
+
315
+ @media screen and (max-width: 600px) {
316
+ html :where(.is-position-sticky) {
317
+ /* stylelint-disable length-zero-no-unit */
318
+ --wp-admin--admin-bar--position-offset: 0px;
319
+ /* stylelint-enable length-zero-no-unit */
320
+ }
307
321
  }
@@ -86,6 +86,21 @@
86
86
  /**
87
87
  * Reset the WP Admin page styles for Gutenberg-like pages.
88
88
  */
89
+ .wp-block-post-excerpt {
90
+ margin-top: var(--wp--style--block-gap);
91
+ margin-bottom: var(--wp--style--block-gap);
92
+ }
93
+
94
+ .wp-block-post-excerpt__excerpt {
95
+ margin-top: 0;
96
+ margin-bottom: 0;
97
+ }
98
+
99
+ .wp-block-post-excerpt__more-text {
100
+ margin-top: var(--wp--style--block-gap);
101
+ margin-bottom: 0;
102
+ }
103
+
89
104
  .wp-block-post-excerpt__more-link {
90
105
  display: inline-block;
91
106
  }
@@ -86,6 +86,21 @@
86
86
  /**
87
87
  * Reset the WP Admin page styles for Gutenberg-like pages.
88
88
  */
89
+ .wp-block-post-excerpt {
90
+ margin-top: var(--wp--style--block-gap);
91
+ margin-bottom: var(--wp--style--block-gap);
92
+ }
93
+
94
+ .wp-block-post-excerpt__excerpt {
95
+ margin-top: 0;
96
+ margin-bottom: 0;
97
+ }
98
+
99
+ .wp-block-post-excerpt__more-text {
100
+ margin-top: var(--wp--style--block-gap);
101
+ margin-bottom: 0;
102
+ }
103
+
89
104
  .wp-block-post-excerpt__more-link {
90
105
  display: inline-block;
91
106
  }
@@ -2431,6 +2431,21 @@ p.has-background {
2431
2431
  box-sizing: border-box;
2432
2432
  }
2433
2433
 
2434
+ .wp-block-post-excerpt {
2435
+ margin-top: var(--wp--style--block-gap);
2436
+ margin-bottom: var(--wp--style--block-gap);
2437
+ }
2438
+
2439
+ .wp-block-post-excerpt__excerpt {
2440
+ margin-top: 0;
2441
+ margin-bottom: 0;
2442
+ }
2443
+
2444
+ .wp-block-post-excerpt__more-text {
2445
+ margin-top: var(--wp--style--block-gap);
2446
+ margin-bottom: 0;
2447
+ }
2448
+
2434
2449
  .wp-block-post-excerpt__more-link {
2435
2450
  display: inline-block;
2436
2451
  }
@@ -3665,4 +3680,18 @@ html :where(img[class*="wp-image-"]) {
3665
3680
  */
3666
3681
  figure {
3667
3682
  margin: 0 0 1em 0;
3683
+ }
3684
+
3685
+ html :where(.is-position-sticky) {
3686
+ /* stylelint-disable length-zero-no-unit */
3687
+ --wp-admin--admin-bar--position-offset: var(--wp-admin--admin-bar--height, 0px);
3688
+ /* stylelint-enable length-zero-no-unit */
3689
+ }
3690
+
3691
+ @media screen and (max-width: 600px) {
3692
+ html :where(.is-position-sticky) {
3693
+ /* stylelint-disable length-zero-no-unit */
3694
+ --wp-admin--admin-bar--position-offset: 0px;
3695
+ /* stylelint-enable length-zero-no-unit */
3696
+ }
3668
3697
  }
@@ -2459,6 +2459,21 @@ p.has-background {
2459
2459
  box-sizing: border-box;
2460
2460
  }
2461
2461
 
2462
+ .wp-block-post-excerpt {
2463
+ margin-top: var(--wp--style--block-gap);
2464
+ margin-bottom: var(--wp--style--block-gap);
2465
+ }
2466
+
2467
+ .wp-block-post-excerpt__excerpt {
2468
+ margin-top: 0;
2469
+ margin-bottom: 0;
2470
+ }
2471
+
2472
+ .wp-block-post-excerpt__more-text {
2473
+ margin-top: var(--wp--style--block-gap);
2474
+ margin-bottom: 0;
2475
+ }
2476
+
2462
2477
  .wp-block-post-excerpt__more-link {
2463
2478
  display: inline-block;
2464
2479
  }
@@ -3700,4 +3715,18 @@ html :where(img[class*="wp-image-"]) {
3700
3715
  */
3701
3716
  figure {
3702
3717
  margin: 0 0 1em 0;
3718
+ }
3719
+
3720
+ html :where(.is-position-sticky) {
3721
+ /* stylelint-disable length-zero-no-unit */
3722
+ --wp-admin--admin-bar--position-offset: var(--wp-admin--admin-bar--height, 0px);
3723
+ /* stylelint-enable length-zero-no-unit */
3724
+ }
3725
+
3726
+ @media screen and (max-width: 600px) {
3727
+ html :where(.is-position-sticky) {
3728
+ /* stylelint-disable length-zero-no-unit */
3729
+ --wp-admin--admin-bar--position-offset: 0px;
3730
+ /* stylelint-enable length-zero-no-unit */
3731
+ }
3703
3732
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/block-library",
3
- "version": "8.3.0",
3
+ "version": "8.3.1",
4
4
  "description": "Block library for the WordPress editor.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -31,34 +31,34 @@
31
31
  ],
32
32
  "dependencies": {
33
33
  "@babel/runtime": "^7.16.0",
34
- "@wordpress/a11y": "^3.26.0",
35
- "@wordpress/api-fetch": "^6.23.0",
36
- "@wordpress/autop": "^3.26.0",
37
- "@wordpress/blob": "^3.26.0",
38
- "@wordpress/block-editor": "^11.3.0",
39
- "@wordpress/blocks": "^12.3.0",
40
- "@wordpress/components": "^23.3.0",
41
- "@wordpress/compose": "^6.3.0",
42
- "@wordpress/core-data": "^6.3.0",
43
- "@wordpress/data": "^8.3.0",
44
- "@wordpress/date": "^4.26.0",
45
- "@wordpress/deprecated": "^3.26.0",
46
- "@wordpress/dom": "^3.26.0",
47
- "@wordpress/element": "^5.3.0",
48
- "@wordpress/escape-html": "^2.26.0",
49
- "@wordpress/experiments": "^0.8.0",
50
- "@wordpress/hooks": "^3.26.0",
51
- "@wordpress/html-entities": "^3.26.0",
52
- "@wordpress/i18n": "^4.26.0",
53
- "@wordpress/icons": "^9.17.0",
54
- "@wordpress/keycodes": "^3.26.0",
55
- "@wordpress/notices": "^3.26.0",
56
- "@wordpress/primitives": "^3.24.0",
57
- "@wordpress/reusable-blocks": "^4.3.0",
58
- "@wordpress/rich-text": "^6.3.0",
59
- "@wordpress/server-side-render": "^4.3.0",
60
- "@wordpress/url": "^3.27.0",
61
- "@wordpress/viewport": "^5.3.0",
34
+ "@wordpress/a11y": "^3.26.1",
35
+ "@wordpress/api-fetch": "^6.23.1",
36
+ "@wordpress/autop": "^3.26.1",
37
+ "@wordpress/blob": "^3.26.1",
38
+ "@wordpress/block-editor": "^11.3.1",
39
+ "@wordpress/blocks": "^12.3.1",
40
+ "@wordpress/components": "^23.3.1",
41
+ "@wordpress/compose": "^6.3.1",
42
+ "@wordpress/core-data": "^6.3.1",
43
+ "@wordpress/data": "^8.3.1",
44
+ "@wordpress/date": "^4.26.1",
45
+ "@wordpress/deprecated": "^3.26.1",
46
+ "@wordpress/dom": "^3.26.1",
47
+ "@wordpress/element": "^5.3.1",
48
+ "@wordpress/escape-html": "^2.26.1",
49
+ "@wordpress/experiments": "^0.8.1",
50
+ "@wordpress/hooks": "^3.26.1",
51
+ "@wordpress/html-entities": "^3.26.1",
52
+ "@wordpress/i18n": "^4.26.1",
53
+ "@wordpress/icons": "^9.17.1",
54
+ "@wordpress/keycodes": "^3.26.1",
55
+ "@wordpress/notices": "^3.26.1",
56
+ "@wordpress/primitives": "^3.24.1",
57
+ "@wordpress/reusable-blocks": "^4.3.1",
58
+ "@wordpress/rich-text": "^6.3.1",
59
+ "@wordpress/server-side-render": "^4.3.1",
60
+ "@wordpress/url": "^3.27.1",
61
+ "@wordpress/viewport": "^5.3.1",
62
62
  "change-case": "^4.1.2",
63
63
  "classnames": "^2.3.1",
64
64
  "colord": "^2.7.0",
@@ -77,5 +77,5 @@
77
77
  "publishConfig": {
78
78
  "access": "public"
79
79
  },
80
- "gitHead": "cab6ebe2b4c5dbacfd753dcae4a2406559c4813c"
80
+ "gitHead": "e9ff92d836928aba65dde94d9d193bc401a934d7"
81
81
  }
@@ -53,7 +53,7 @@ function render_block_core_calendar( $attributes ) {
53
53
  $color_block_styles['background'] = $preset_background_color ? $preset_background_color : $custom_background_color;
54
54
 
55
55
  // Generate color styles and classes.
56
- $styles = gutenberg_style_engine_get_styles( array( 'color' => $color_block_styles ), array( 'convert_vars_to_classnames' => true ) );
56
+ $styles = wp_style_engine_get_styles( array( 'color' => $color_block_styles ), array( 'convert_vars_to_classnames' => true ) );
57
57
  $inline_styles = empty( $styles['css'] ) ? '' : sprintf( ' style="%s"', esc_attr( $styles['css'] ) );
58
58
  $classnames = empty( $styles['classnames'] ) ? '' : ' ' . esc_attr( $styles['classnames'] );
59
59
  if ( isset( $attributes['style']['elements']['link']['color']['text'] ) ) {
package/src/common.scss CHANGED
@@ -161,3 +161,22 @@ html :where(img[class*="wp-image-"]) {
161
161
  figure {
162
162
  margin: 0 0 1em 0;
163
163
  }
164
+
165
+ // Set the admin bar offset for sticky positioned blocks to the height of the admin bar.
166
+ // This allows sticky positioned blocks to be positioned correctly when the admin bar is visible.
167
+ html :where(.is-position-sticky) {
168
+ /* stylelint-disable length-zero-no-unit */
169
+ --wp-admin--admin-bar--position-offset: var(--wp-admin--admin-bar--height, 0px); // 0px is set explicitly so that it can be used in a calc value.
170
+ /* stylelint-enable length-zero-no-unit */
171
+ }
172
+
173
+ // To support sticky positioning, reset the admin bar offset to 0px on mobile devices,
174
+ // within the scope of the position classname. This is required because the admin bar
175
+ // is not fixed to the top on mobile devices, but is fixed on viewports larger than 600px.
176
+ @media screen and (max-width: 600px) {
177
+ html :where(.is-position-sticky) {
178
+ /* stylelint-disable length-zero-no-unit */
179
+ --wp-admin--admin-bar--position-offset: 0px; // 0px is set explicitly so that it can be used in a calc value.
180
+ /* stylelint-enable length-zero-no-unit */
181
+ }
182
+ }
@@ -108,7 +108,7 @@ function block_core_gallery_render( $attributes, $content ) {
108
108
  ),
109
109
  );
110
110
 
111
- gutenberg_style_engine_get_stylesheet_from_css_rules(
111
+ wp_style_engine_get_stylesheet_from_css_rules(
112
112
  $gallery_styles,
113
113
  array(
114
114
  'context' => 'block-supports',
@@ -13,7 +13,7 @@ import {
13
13
  Spinner,
14
14
  } from '@wordpress/components';
15
15
  import { useSelect } from '@wordpress/data';
16
- import { __ } from '@wordpress/i18n';
16
+ import { __, sprintf } from '@wordpress/i18n';
17
17
 
18
18
  /**
19
19
  * Internal dependencies
@@ -22,6 +22,7 @@ import NavigationMenuSelector from './navigation-menu-selector';
22
22
  import { LeafMoreMenu } from '../leaf-more-menu';
23
23
  import { unlock } from '../../experiments';
24
24
  import DeletedNavigationWarning from './deleted-navigation-warning';
25
+ import useNavigationMenu from '../use-navigation-menu';
25
26
 
26
27
  /* translators: %s: The name of a menu. */
27
28
  const actionLabel = __( "Switch to '%s'" );
@@ -43,12 +44,13 @@ const MainContent = ( {
43
44
  },
44
45
  [ clientId ]
45
46
  );
47
+ const { navigationMenu } = useNavigationMenu( currentMenuId );
46
48
 
47
49
  if ( currentMenuId && isNavigationMenuMissing ) {
48
50
  return <p>{ __( 'Select or create a menu' ) }</p>;
49
51
  }
50
52
 
51
- if ( isNavigationMenuMissing ) {
53
+ if ( currentMenuId && isNavigationMenuMissing ) {
52
54
  return <DeletedNavigationWarning onCreateNew={ onCreateNew } />;
53
55
  }
54
56
 
@@ -56,11 +58,21 @@ const MainContent = ( {
56
58
  return <Spinner />;
57
59
  }
58
60
 
61
+ const description = navigationMenu
62
+ ? sprintf(
63
+ /* translators: %s: The name of a menu. */
64
+ __( 'Structure for navigation menu: %s' ),
65
+ navigationMenu?.title || __( 'Untitled menu' )
66
+ )
67
+ : __(
68
+ 'You have not yet created any menus. Displaying a list of your Pages'
69
+ );
59
70
  return (
60
71
  <OffCanvasEditor
61
72
  blocks={ clientIdsTree }
62
73
  isExpanded={ true }
63
74
  LeafMoreMenu={ LeafMoreMenu }
75
+ description={ description }
64
76
  />
65
77
  );
66
78
  };
@@ -885,7 +885,7 @@ add_filter( 'render_block_data', 'block_core_navigation_typographic_presets_back
885
885
  * @param array $settings Default editor settings.
886
886
  * @return array Filtered editor settings.
887
887
  */
888
- function gutenberg_enable_animation_for_navigation_inspector( $settings ) {
888
+ function block_core_navigation_enable_inspector_animation( $settings ) {
889
889
  $current_animation_settings = _wp_array_get(
890
890
  $settings,
891
891
  array( '__experimentalBlockInspectorAnimation' ),
@@ -905,4 +905,4 @@ function gutenberg_enable_animation_for_navigation_inspector( $settings ) {
905
905
  return $settings;
906
906
  }
907
907
 
908
- add_filter( 'block_editor_settings_all', 'gutenberg_enable_animation_for_navigation_inspector' );
908
+ add_filter( 'block_editor_settings_all', 'block_core_navigation_enable_inspector_animation' );
@@ -382,7 +382,7 @@ add_action( 'init', 'register_block_core_navigation_link' );
382
382
  * @param array $settings Default editor settings.
383
383
  * @return array Filtered editor settings.
384
384
  */
385
- function gutenberg_enable_animation_for_navigation_link_inspector( $settings ) {
385
+ function block_core_navigation_link_enable_inspector_animation( $settings ) {
386
386
  $current_animation_settings = _wp_array_get(
387
387
  $settings,
388
388
  array( '__experimentalBlockInspectorAnimation' ),
@@ -402,4 +402,4 @@ function gutenberg_enable_animation_for_navigation_link_inspector( $settings ) {
402
402
  return $settings;
403
403
  }
404
404
 
405
- add_filter( 'block_editor_settings_all', 'gutenberg_enable_animation_for_navigation_link_inspector' );
405
+ add_filter( 'block_editor_settings_all', 'block_core_navigation_link_enable_inspector_animation' );
@@ -300,7 +300,7 @@ add_action( 'init', 'register_block_core_navigation_submenu' );
300
300
  * @param array $settings Default editor settings.
301
301
  * @return array Filtered editor settings.
302
302
  */
303
- function gutenberg_enable_animation_for_navigation_submenu_inspector( $settings ) {
303
+ function block_core_navigation_submenu_enable_inspector_animation( $settings ) {
304
304
  $current_animation_settings = _wp_array_get(
305
305
  $settings,
306
306
  array( '__experimentalBlockInspectorAnimation' ),
@@ -320,4 +320,4 @@ function gutenberg_enable_animation_for_navigation_submenu_inspector( $settings
320
320
  return $settings;
321
321
  }
322
322
 
323
- add_filter( 'block_editor_settings_all', 'gutenberg_enable_animation_for_navigation_submenu_inspector' );
323
+ add_filter( 'block_editor_settings_all', 'block_core_navigation_submenu_enable_inspector_animation' );
@@ -1,3 +1,21 @@
1
+ .wp-block-post-excerpt {
2
+ margin-top: var(--wp--style--block-gap);
3
+ margin-bottom: var(--wp--style--block-gap);
4
+ }
5
+
6
+ // Zero out the margin on the excerpt paragraph, to match the body paragraphs.
7
+ .wp-block-post-excerpt__excerpt {
8
+ margin-top: 0;
9
+ margin-bottom: 0;
10
+ }
11
+
12
+ // Matches block gap.
13
+ .wp-block-post-excerpt__more-text {
14
+ margin-top: var(--wp--style--block-gap);
15
+ margin-bottom: 0;
16
+ }
17
+
1
18
  .wp-block-post-excerpt__more-link {
2
19
  display: inline-block;
3
20
  }
21
+
@@ -23,7 +23,7 @@ const BASE_QUERY = {
23
23
  const getTermIdByTermValue = ( terms, termValue ) => {
24
24
  // First we check for exact match by `term.id` or case sensitive `term.name` match.
25
25
  const termId =
26
- termValue?.id || terms.find( ( term ) => term.name === termValue )?.id;
26
+ termValue?.id || terms?.find( ( term ) => term.name === termValue )?.id;
27
27
  if ( termId ) {
28
28
  return termId;
29
29
  }
@@ -38,7 +38,7 @@ const getTermIdByTermValue = ( terms, termValue ) => {
38
38
  * In this edge case we always apply the first match from the terms list.
39
39
  */
40
40
  const termValueLower = termValue.toLocaleLowerCase();
41
- return terms.find(
41
+ return terms?.find(
42
42
  ( term ) => term.name.toLocaleLowerCase() === termValueLower
43
43
  )?.id;
44
44
  };