@wordpress/editor 12.21.0 → 13.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/build/components/document-outline/check.js +1 -7
  3. package/build/components/document-outline/check.js.map +1 -1
  4. package/build/components/editor-notices/index.js +12 -12
  5. package/build/components/editor-notices/index.js.map +1 -1
  6. package/build/components/editor-snackbars/index.js +5 -8
  7. package/build/components/editor-snackbars/index.js.map +1 -1
  8. package/build/components/page-attributes/parent.js +2 -1
  9. package/build/components/page-attributes/parent.js.map +1 -1
  10. package/build/components/post-author/combobox.js +1 -0
  11. package/build/components/post-author/combobox.js.map +1 -1
  12. package/build/components/post-format/index.js +1 -7
  13. package/build/components/post-format/index.js.map +1 -1
  14. package/build/components/post-publish-panel/maybe-category-panel.js +10 -5
  15. package/build/components/post-publish-panel/maybe-category-panel.js.map +1 -1
  16. package/build/components/post-publish-panel/maybe-post-format-panel.js +1 -1
  17. package/build/components/post-publish-panel/maybe-post-format-panel.js.map +1 -1
  18. package/build/components/post-taxonomies/flat-term-selector.js +2 -2
  19. package/build/components/post-taxonomies/flat-term-selector.js.map +1 -1
  20. package/build/components/post-taxonomies/hierarchical-term-selector.js +1 -1
  21. package/build/components/post-taxonomies/hierarchical-term-selector.js.map +1 -1
  22. package/build/components/post-taxonomies/index.js +2 -8
  23. package/build/components/post-taxonomies/index.js.map +1 -1
  24. package/build/components/post-title/index.native.js +2 -4
  25. package/build/components/post-title/index.native.js.map +1 -1
  26. package/build/components/post-url/index.js +6 -2
  27. package/build/components/post-url/index.js.map +1 -1
  28. package/build/components/provider/index.native.js.map +1 -1
  29. package/build/components/provider/use-block-editor-settings.js +10 -9
  30. package/build/components/provider/use-block-editor-settings.js.map +1 -1
  31. package/build/components/provider/use-block-editor-settings.native.js +3 -1
  32. package/build/components/provider/use-block-editor-settings.native.js.map +1 -1
  33. package/build-module/components/document-outline/check.js +1 -6
  34. package/build-module/components/document-outline/check.js.map +1 -1
  35. package/build-module/components/editor-notices/index.js +12 -11
  36. package/build-module/components/editor-notices/index.js.map +1 -1
  37. package/build-module/components/editor-snackbars/index.js +5 -7
  38. package/build-module/components/editor-snackbars/index.js.map +1 -1
  39. package/build-module/components/page-attributes/parent.js +3 -2
  40. package/build-module/components/page-attributes/parent.js.map +1 -1
  41. package/build-module/components/post-author/combobox.js +1 -0
  42. package/build-module/components/post-author/combobox.js.map +1 -1
  43. package/build-module/components/post-format/index.js +1 -6
  44. package/build-module/components/post-format/index.js.map +1 -1
  45. package/build-module/components/post-publish-panel/maybe-category-panel.js +10 -5
  46. package/build-module/components/post-publish-panel/maybe-category-panel.js.map +1 -1
  47. package/build-module/components/post-publish-panel/maybe-post-format-panel.js +2 -2
  48. package/build-module/components/post-publish-panel/maybe-post-format-panel.js.map +1 -1
  49. package/build-module/components/post-taxonomies/flat-term-selector.js +3 -3
  50. package/build-module/components/post-taxonomies/flat-term-selector.js.map +1 -1
  51. package/build-module/components/post-taxonomies/hierarchical-term-selector.js +2 -2
  52. package/build-module/components/post-taxonomies/hierarchical-term-selector.js.map +1 -1
  53. package/build-module/components/post-taxonomies/index.js +2 -7
  54. package/build-module/components/post-taxonomies/index.js.map +1 -1
  55. package/build-module/components/post-title/index.native.js +2 -3
  56. package/build-module/components/post-title/index.native.js.map +1 -1
  57. package/build-module/components/post-url/index.js +6 -2
  58. package/build-module/components/post-url/index.js.map +1 -1
  59. package/build-module/components/provider/index.native.js +2 -1
  60. package/build-module/components/provider/index.native.js.map +1 -1
  61. package/build-module/components/provider/use-block-editor-settings.js +10 -8
  62. package/build-module/components/provider/use-block-editor-settings.js.map +1 -1
  63. package/build-module/components/provider/use-block-editor-settings.native.js +2 -1
  64. package/build-module/components/provider/use-block-editor-settings.native.js.map +1 -1
  65. package/build-style/style-rtl.css +17 -3
  66. package/build-style/style.css +17 -3
  67. package/package.json +31 -31
  68. package/src/components/document-outline/check.js +1 -7
  69. package/src/components/editor-notices/index.js +6 -13
  70. package/src/components/editor-snackbars/index.js +3 -8
  71. package/src/components/page-attributes/parent.js +3 -3
  72. package/src/components/post-author/combobox.js +1 -0
  73. package/src/components/post-format/index.js +1 -7
  74. package/src/components/post-publish-panel/maybe-category-panel.js +9 -12
  75. package/src/components/post-publish-panel/maybe-post-format-panel.js +2 -2
  76. package/src/components/post-taxonomies/flat-term-selector.js +3 -3
  77. package/src/components/post-taxonomies/hierarchical-term-selector.js +2 -2
  78. package/src/components/post-taxonomies/index.js +2 -8
  79. package/src/components/post-taxonomies/test/index.js +1 -1
  80. package/src/components/post-title/index.native.js +2 -3
  81. package/src/components/post-url/index.js +6 -2
  82. package/src/components/provider/index.native.js +1 -0
  83. package/src/components/provider/use-block-editor-settings.js +56 -50
  84. package/src/components/provider/use-block-editor-settings.native.js +3 -1
package/CHANGELOG.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 13.0.0 (2022-12-14)
6
+
7
+ ### Breaking Changes
8
+
9
+ - Updated dependencies to require React 18 ([45235](https://github.com/WordPress/gutenberg/pull/45235))
10
+
5
11
  ## 12.21.0 (2022-11-16)
6
12
 
7
13
  ## 12.20.0 (2022-11-02)
@@ -5,16 +5,10 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
 
8
- var _lodash = require("lodash");
9
-
10
8
  var _data = require("@wordpress/data");
11
9
 
12
10
  var _blockEditor = require("@wordpress/block-editor");
13
11
 
14
- /**
15
- * External dependencies
16
- */
17
-
18
12
  /**
19
13
  * WordPress dependencies
20
14
  */
@@ -23,7 +17,7 @@ function DocumentOutlineCheck(_ref) {
23
17
  blocks,
24
18
  children
25
19
  } = _ref;
26
- const headings = (0, _lodash.filter)(blocks, block => block.name === 'core/heading');
20
+ const headings = blocks.filter(block => block.name === 'core/heading');
27
21
 
28
22
  if (headings.length < 1) {
29
23
  return null;
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/editor/src/components/document-outline/check.js"],"names":["DocumentOutlineCheck","blocks","children","headings","block","name","length","select","blockEditorStore","getBlocks"],"mappings":";;;;;;;AAGA;;AAKA;;AACA;;AATA;AACA;AACA;;AAGA;AACA;AACA;AAIA,SAASA,oBAAT,OAAsD;AAAA,MAAvB;AAAEC,IAAAA,MAAF;AAAUC,IAAAA;AAAV,GAAuB;AACrD,QAAMC,QAAQ,GAAG,oBAChBF,MADgB,EAEdG,KAAF,IAAaA,KAAK,CAACC,IAAN,KAAe,cAFZ,CAAjB;;AAKA,MAAKF,QAAQ,CAACG,MAAT,GAAkB,CAAvB,EAA2B;AAC1B,WAAO,IAAP;AACA;;AAED,SAAOJ,QAAP;AACA;;eAEc,sBAAcK,MAAF,KAAgB;AAC1CN,EAAAA,MAAM,EAAEM,MAAM,CAAEC,kBAAF,CAAN,CAA2BC,SAA3B;AADkC,CAAhB,CAAZ,EAERT,oBAFQ,C","sourcesContent":["/**\n * External dependencies\n */\nimport { filter } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { withSelect } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\nfunction DocumentOutlineCheck( { blocks, children } ) {\n\tconst headings = filter(\n\t\tblocks,\n\t\t( block ) => block.name === 'core/heading'\n\t);\n\n\tif ( headings.length < 1 ) {\n\t\treturn null;\n\t}\n\n\treturn children;\n}\n\nexport default withSelect( ( select ) => ( {\n\tblocks: select( blockEditorStore ).getBlocks(),\n} ) )( DocumentOutlineCheck );\n"]}
1
+ {"version":3,"sources":["@wordpress/editor/src/components/document-outline/check.js"],"names":["DocumentOutlineCheck","blocks","children","headings","filter","block","name","length","select","blockEditorStore","getBlocks"],"mappings":";;;;;;;AAGA;;AACA;;AAJA;AACA;AACA;AAIA,SAASA,oBAAT,OAAsD;AAAA,MAAvB;AAAEC,IAAAA,MAAF;AAAUC,IAAAA;AAAV,GAAuB;AACrD,QAAMC,QAAQ,GAAGF,MAAM,CAACG,MAAP,CACdC,KAAF,IAAaA,KAAK,CAACC,IAAN,KAAe,cADZ,CAAjB;;AAIA,MAAKH,QAAQ,CAACI,MAAT,GAAkB,CAAvB,EAA2B;AAC1B,WAAO,IAAP;AACA;;AAED,SAAOL,QAAP;AACA;;eAEc,sBAAcM,MAAF,KAAgB;AAC1CP,EAAAA,MAAM,EAAEO,MAAM,CAAEC,kBAAF,CAAN,CAA2BC,SAA3B;AADkC,CAAhB,CAAZ,EAERV,oBAFQ,C","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { withSelect } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\nfunction DocumentOutlineCheck( { blocks, children } ) {\n\tconst headings = blocks.filter(\n\t\t( block ) => block.name === 'core/heading'\n\t);\n\n\tif ( headings.length < 1 ) {\n\t\treturn null;\n\t}\n\n\treturn children;\n}\n\nexport default withSelect( ( select ) => ( {\n\tblocks: select( blockEditorStore ).getBlocks(),\n} ) )( DocumentOutlineCheck );\n"]}
@@ -10,8 +10,6 @@ exports.default = void 0;
10
10
 
11
11
  var _element = require("@wordpress/element");
12
12
 
13
- var _lodash = require("lodash");
14
-
15
13
  var _components = require("@wordpress/components");
16
14
 
17
15
  var _data = require("@wordpress/data");
@@ -22,10 +20,6 @@ var _notices = require("@wordpress/notices");
22
20
 
23
21
  var _templateValidationNotice = _interopRequireDefault(require("../template-validation-notice"));
24
22
 
25
- /**
26
- * External dependencies
27
- */
28
-
29
23
  /**
30
24
  * WordPress dependencies
31
25
  */
@@ -38,13 +32,19 @@ function EditorNotices(_ref) {
38
32
  notices,
39
33
  onRemove
40
34
  } = _ref;
41
- const dismissibleNotices = (0, _lodash.filter)(notices, {
42
- isDismissible: true,
43
- type: 'default'
35
+ const dismissibleNotices = notices.filter(_ref2 => {
36
+ let {
37
+ isDismissible,
38
+ type
39
+ } = _ref2;
40
+ return isDismissible && type === 'default';
44
41
  });
45
- const nonDismissibleNotices = (0, _lodash.filter)(notices, {
46
- isDismissible: false,
47
- type: 'default'
42
+ const nonDismissibleNotices = notices.filter(_ref3 => {
43
+ let {
44
+ isDismissible,
45
+ type
46
+ } = _ref3;
47
+ return !isDismissible && type === 'default';
48
48
  });
49
49
  return (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)(_components.NoticeList, {
50
50
  notices: nonDismissibleNotices,
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/editor/src/components/editor-notices/index.js"],"names":["EditorNotices","notices","onRemove","dismissibleNotices","isDismissible","type","nonDismissibleNotices","select","noticesStore","getNotices","dispatch","removeNotice"],"mappings":";;;;;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AACA;;AAKA;;AAhBA;AACA;AACA;;AAGA;AACA;AACA;;AAMA;AACA;AACA;AAGO,SAASA,aAAT,OAAgD;AAAA,MAAxB;AAAEC,IAAAA,OAAF;AAAWC,IAAAA;AAAX,GAAwB;AACtD,QAAMC,kBAAkB,GAAG,oBAAQF,OAAR,EAAiB;AAC3CG,IAAAA,aAAa,EAAE,IAD4B;AAE3CC,IAAAA,IAAI,EAAE;AAFqC,GAAjB,CAA3B;AAIA,QAAMC,qBAAqB,GAAG,oBAAQL,OAAR,EAAiB;AAC9CG,IAAAA,aAAa,EAAE,KAD+B;AAE9CC,IAAAA,IAAI,EAAE;AAFwC,GAAjB,CAA9B;AAKA,SACC,qDACC,4BAAC,sBAAD;AACC,IAAA,OAAO,EAAGC,qBADX;AAEC,IAAA,SAAS,EAAC;AAFX,IADD,EAKC,4BAAC,sBAAD;AACC,IAAA,OAAO,EAAGH,kBADX;AAEC,IAAA,SAAS,EAAC,wCAFX;AAGC,IAAA,QAAQ,EAAGD;AAHZ,KAKC,4BAAC,iCAAD,OALD,CALD,CADD;AAeA;;eAEc,sBAAS,CACvB,sBAAcK,MAAF,KAAgB;AAC3BN,EAAAA,OAAO,EAAEM,MAAM,CAAEC,cAAF,CAAN,CAAuBC,UAAvB;AADkB,CAAhB,CAAZ,CADuB,EAIvB,wBAAgBC,QAAF,KAAkB;AAC/BR,EAAAA,QAAQ,EAAEQ,QAAQ,CAAEF,cAAF,CAAR,CAAyBG;AADJ,CAAlB,CAAd,CAJuB,CAAT,EAOVX,aAPU,C","sourcesContent":["/**\n * External dependencies\n */\nimport { filter } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { NoticeList } from '@wordpress/components';\nimport { withSelect, withDispatch } from '@wordpress/data';\nimport { compose } from '@wordpress/compose';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport TemplateValidationNotice from '../template-validation-notice';\n\nexport function EditorNotices( { notices, onRemove } ) {\n\tconst dismissibleNotices = filter( notices, {\n\t\tisDismissible: true,\n\t\ttype: 'default',\n\t} );\n\tconst nonDismissibleNotices = filter( notices, {\n\t\tisDismissible: false,\n\t\ttype: 'default',\n\t} );\n\n\treturn (\n\t\t<>\n\t\t\t<NoticeList\n\t\t\t\tnotices={ nonDismissibleNotices }\n\t\t\t\tclassName=\"components-editor-notices__pinned\"\n\t\t\t/>\n\t\t\t<NoticeList\n\t\t\t\tnotices={ dismissibleNotices }\n\t\t\t\tclassName=\"components-editor-notices__dismissible\"\n\t\t\t\tonRemove={ onRemove }\n\t\t\t>\n\t\t\t\t<TemplateValidationNotice />\n\t\t\t</NoticeList>\n\t\t</>\n\t);\n}\n\nexport default compose( [\n\twithSelect( ( select ) => ( {\n\t\tnotices: select( noticesStore ).getNotices(),\n\t} ) ),\n\twithDispatch( ( dispatch ) => ( {\n\t\tonRemove: dispatch( noticesStore ).removeNotice,\n\t} ) ),\n] )( EditorNotices );\n"]}
1
+ {"version":3,"sources":["@wordpress/editor/src/components/editor-notices/index.js"],"names":["EditorNotices","notices","onRemove","dismissibleNotices","filter","isDismissible","type","nonDismissibleNotices","select","noticesStore","getNotices","dispatch","removeNotice"],"mappings":";;;;;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AAKA;;AAXA;AACA;AACA;;AAMA;AACA;AACA;AAGO,SAASA,aAAT,OAAgD;AAAA,MAAxB;AAAEC,IAAAA,OAAF;AAAWC,IAAAA;AAAX,GAAwB;AACtD,QAAMC,kBAAkB,GAAGF,OAAO,CAACG,MAAR,CAC1B;AAAA,QAAE;AAAEC,MAAAA,aAAF;AAAiBC,MAAAA;AAAjB,KAAF;AAAA,WAA+BD,aAAa,IAAIC,IAAI,KAAK,SAAzD;AAAA,GAD0B,CAA3B;AAGA,QAAMC,qBAAqB,GAAGN,OAAO,CAACG,MAAR,CAC7B;AAAA,QAAE;AAAEC,MAAAA,aAAF;AAAiBC,MAAAA;AAAjB,KAAF;AAAA,WAA+B,CAAED,aAAF,IAAmBC,IAAI,KAAK,SAA3D;AAAA,GAD6B,CAA9B;AAIA,SACC,qDACC,4BAAC,sBAAD;AACC,IAAA,OAAO,EAAGC,qBADX;AAEC,IAAA,SAAS,EAAC;AAFX,IADD,EAKC,4BAAC,sBAAD;AACC,IAAA,OAAO,EAAGJ,kBADX;AAEC,IAAA,SAAS,EAAC,wCAFX;AAGC,IAAA,QAAQ,EAAGD;AAHZ,KAKC,4BAAC,iCAAD,OALD,CALD,CADD;AAeA;;eAEc,sBAAS,CACvB,sBAAcM,MAAF,KAAgB;AAC3BP,EAAAA,OAAO,EAAEO,MAAM,CAAEC,cAAF,CAAN,CAAuBC,UAAvB;AADkB,CAAhB,CAAZ,CADuB,EAIvB,wBAAgBC,QAAF,KAAkB;AAC/BT,EAAAA,QAAQ,EAAES,QAAQ,CAAEF,cAAF,CAAR,CAAyBG;AADJ,CAAlB,CAAd,CAJuB,CAAT,EAOVZ,aAPU,C","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { NoticeList } from '@wordpress/components';\nimport { withSelect, withDispatch } from '@wordpress/data';\nimport { compose } from '@wordpress/compose';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport TemplateValidationNotice from '../template-validation-notice';\n\nexport function EditorNotices( { notices, onRemove } ) {\n\tconst dismissibleNotices = notices.filter(\n\t\t( { isDismissible, type } ) => isDismissible && type === 'default'\n\t);\n\tconst nonDismissibleNotices = notices.filter(\n\t\t( { isDismissible, type } ) => ! isDismissible && type === 'default'\n\t);\n\n\treturn (\n\t\t<>\n\t\t\t<NoticeList\n\t\t\t\tnotices={ nonDismissibleNotices }\n\t\t\t\tclassName=\"components-editor-notices__pinned\"\n\t\t\t/>\n\t\t\t<NoticeList\n\t\t\t\tnotices={ dismissibleNotices }\n\t\t\t\tclassName=\"components-editor-notices__dismissible\"\n\t\t\t\tonRemove={ onRemove }\n\t\t\t>\n\t\t\t\t<TemplateValidationNotice />\n\t\t\t</NoticeList>\n\t\t</>\n\t);\n}\n\nexport default compose( [\n\twithSelect( ( select ) => ( {\n\t\tnotices: select( noticesStore ).getNotices(),\n\t} ) ),\n\twithDispatch( ( dispatch ) => ( {\n\t\tonRemove: dispatch( noticesStore ).removeNotice,\n\t} ) ),\n] )( EditorNotices );\n"]}
@@ -7,18 +7,12 @@ exports.default = EditorSnackbars;
7
7
 
8
8
  var _element = require("@wordpress/element");
9
9
 
10
- var _lodash = require("lodash");
11
-
12
10
  var _components = require("@wordpress/components");
13
11
 
14
12
  var _data = require("@wordpress/data");
15
13
 
16
14
  var _notices = require("@wordpress/notices");
17
15
 
18
- /**
19
- * External dependencies
20
- */
21
-
22
16
  /**
23
17
  * WordPress dependencies
24
18
  */
@@ -27,8 +21,11 @@ function EditorSnackbars() {
27
21
  const {
28
22
  removeNotice
29
23
  } = (0, _data.useDispatch)(_notices.store);
30
- const snackbarNotices = (0, _lodash.filter)(notices, {
31
- type: 'snackbar'
24
+ const snackbarNotices = notices.filter(_ref => {
25
+ let {
26
+ type
27
+ } = _ref;
28
+ return type === 'snackbar';
32
29
  });
33
30
  return (0, _element.createElement)(_components.SnackbarList, {
34
31
  notices: snackbarNotices,
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/editor/src/components/editor-snackbars/index.js"],"names":["EditorSnackbars","notices","select","noticesStore","getNotices","removeNotice","snackbarNotices","type"],"mappings":";;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AAVA;AACA;AACA;;AAGA;AACA;AACA;AAKe,SAASA,eAAT,GAA2B;AACzC,QAAMC,OAAO,GAAG,qBACbC,MAAF,IAAcA,MAAM,CAAEC,cAAF,CAAN,CAAuBC,UAAvB,EADC,EAEf,EAFe,CAAhB;AAIA,QAAM;AAAEC,IAAAA;AAAF,MAAmB,uBAAaF,cAAb,CAAzB;AACA,QAAMG,eAAe,GAAG,oBAAQL,OAAR,EAAiB;AACxCM,IAAAA,IAAI,EAAE;AADkC,GAAjB,CAAxB;AAIA,SACC,4BAAC,wBAAD;AACC,IAAA,OAAO,EAAGD,eADX;AAEC,IAAA,SAAS,EAAC,qCAFX;AAGC,IAAA,QAAQ,EAAGD;AAHZ,IADD;AAOA","sourcesContent":["/**\n * External dependencies\n */\nimport { filter } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { SnackbarList } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as noticesStore } from '@wordpress/notices';\n\nexport default function EditorSnackbars() {\n\tconst notices = useSelect(\n\t\t( select ) => select( noticesStore ).getNotices(),\n\t\t[]\n\t);\n\tconst { removeNotice } = useDispatch( noticesStore );\n\tconst snackbarNotices = filter( notices, {\n\t\ttype: 'snackbar',\n\t} );\n\n\treturn (\n\t\t<SnackbarList\n\t\t\tnotices={ snackbarNotices }\n\t\t\tclassName=\"components-editor-notices__snackbar\"\n\t\t\tonRemove={ removeNotice }\n\t\t/>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/editor/src/components/editor-snackbars/index.js"],"names":["EditorSnackbars","notices","select","noticesStore","getNotices","removeNotice","snackbarNotices","filter","type"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AALA;AACA;AACA;AAKe,SAASA,eAAT,GAA2B;AACzC,QAAMC,OAAO,GAAG,qBACbC,MAAF,IAAcA,MAAM,CAAEC,cAAF,CAAN,CAAuBC,UAAvB,EADC,EAEf,EAFe,CAAhB;AAIA,QAAM;AAAEC,IAAAA;AAAF,MAAmB,uBAAaF,cAAb,CAAzB;AACA,QAAMG,eAAe,GAAGL,OAAO,CAACM,MAAR,CACvB;AAAA,QAAE;AAAEC,MAAAA;AAAF,KAAF;AAAA,WAAgBA,IAAI,KAAK,UAAzB;AAAA,GADuB,CAAxB;AAIA,SACC,4BAAC,wBAAD;AACC,IAAA,OAAO,EAAGF,eADX;AAEC,IAAA,SAAS,EAAC,qCAFX;AAGC,IAAA,QAAQ,EAAGD;AAHZ,IADD;AAOA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { SnackbarList } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as noticesStore } from '@wordpress/notices';\n\nexport default function EditorSnackbars() {\n\tconst notices = useSelect(\n\t\t( select ) => select( noticesStore ).getNotices(),\n\t\t[]\n\t);\n\tconst { removeNotice } = useDispatch( noticesStore );\n\tconst snackbarNotices = notices.filter(\n\t\t( { type } ) => type === 'snackbar'\n\t);\n\n\treturn (\n\t\t<SnackbarList\n\t\t\tnotices={ snackbarNotices }\n\t\t\tclassName=\"components-editor-notices__snackbar\"\n\t\t\tonRemove={ removeNotice }\n\t\t/>\n\t);\n}\n"]}
@@ -142,7 +142,7 @@ function PageAttributesParent() {
142
142
 
143
143
  const opts = getOptionsFromTree(tree); // Ensure the current parent is in the options list.
144
144
 
145
- const optsHasParent = (0, _lodash.find)(opts, item => item.value === parentPostId);
145
+ const optsHasParent = opts.find(item => item.value === parentPostId);
146
146
 
147
147
  if (parentPost && !optsHasParent) {
148
148
  opts.unshift({
@@ -181,6 +181,7 @@ function PageAttributesParent() {
181
181
  };
182
182
 
183
183
  return (0, _element.createElement)(_components.ComboboxControl, {
184
+ __nextHasNoMarginBottom: true,
184
185
  className: "editor-page-attributes__parent",
185
186
  label: parentPageLabel,
186
187
  value: parentPostId,
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/editor/src/components/page-attributes/parent.js"],"names":["getTitle","post","title","rendered","id","getItemPriority","name","searchValue","normalizedName","toLowerCase","normalizedSearch","startsWith","length","Infinity","PageAttributesParent","editPost","editorStore","fieldValue","setFieldValue","parentPost","parentPostId","items","postType","select","getPostType","getEntityRecords","getEntityRecord","coreStore","getCurrentPostId","getEditedPostAttribute","postTypeSlug","pageId","pType","postId","isHierarchical","query","per_page","exclude","parent_exclude","orderby","order","_fields","search","parentPageLabel","pageItems","parentOptions","getOptionsFromTree","tree","level","mappedNodes","map","treeNode","value","label","repeat","rawName","children","sortedNodes","sort","a","b","priorityA","priorityB","flat","item","parent","opts","optsHasParent","unshift","handleKeydown","inputValue","handleChange","selectedPostId"],"mappings":";;;;;;;;;;AAYA;;AATA;;AACA;;AAKA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AAKA;;AACA;;AArBA;AACA;AACA;;AAIA;AACA;AACA;;AASA;AACA;AACA;AAIA,SAASA,QAAT,CAAmBC,IAAnB,EAA0B;AAAA;;AACzB,SAAOA,IAAI,SAAJ,IAAAA,IAAI,WAAJ,mBAAAA,IAAI,CAAEC,KAAN,oDAAaC,QAAb,GACJ,kCAAgBF,IAAI,CAACC,KAAL,CAAWC,QAA3B,CADI,GAEH,IAAIF,IAAI,CAACG,EAAI,KAAK,cAAI,UAAJ,CAAkB,GAFxC;AAGA;;AAEM,MAAMC,eAAe,GAAG,CAAEC,IAAF,EAAQC,WAAR,KAAyB;AACvD,QAAMC,cAAc,GAAG,4BAAeF,IAAI,IAAI,EAAvB,EAA4BG,WAA5B,EAAvB;AACA,QAAMC,gBAAgB,GAAG,4BAAeH,WAAW,IAAI,EAA9B,EAAmCE,WAAnC,EAAzB;;AACA,MAAKD,cAAc,KAAKE,gBAAxB,EAA2C;AAC1C,WAAO,CAAP;AACA;;AAED,MAAKF,cAAc,CAACG,UAAf,CAA2BD,gBAA3B,CAAL,EAAqD;AACpD,WAAOF,cAAc,CAACI,MAAtB;AACA;;AAED,SAAOC,QAAP;AACA,CAZM;;;;AAcA,SAASC,oBAAT,G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KAAF,CAAR;AACA,GAFD;;AAIA,SACC,4BAAC,2BAAD;AACC,IAAA,SAAS,EAAC,gCADX;AAEC,IAAA,KAAK,EAAG7B,eAFT;AAGC,IAAA,KAAK,EAAGvB,YAHT;AAIC,IAAA,OAAO,EAAGyB,aAJX;AAKC,IAAA,mBAAmB,EAAG,uBAAUwB,aAAV,EAAyB,GAAzB,CALvB;AAMC,IAAA,QAAQ,EAAGE;AANZ,IADD;AAUA;;eAEczD,oB","sourcesContent":["/**\n * External dependencies\n */\nimport { get, unescape as unescapeString, find } from 'lodash';\nimport removeAccents from 'remove-accents';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { ComboboxControl } from '@wordpress/components';\nimport { debounce } from '@wordpress/compose';\nimport { useState, useMemo } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { buildTermsTree } from '../../utils/terms';\nimport { store as editorStore } from '../../store';\n\nfunction getTitle( post ) {\n\treturn post?.title?.rendered\n\t\t? decodeEntities( post.title.rendered )\n\t\t: `#${ post.id } (${ __( 'no title' ) })`;\n}\n\nexport const getItemPriority = ( name, searchValue ) => {\n\tconst normalizedName = removeAccents( name || '' ).toLowerCase();\n\tconst normalizedSearch = removeAccents( searchValue || '' ).toLowerCase();\n\tif ( normalizedName === normalizedSearch ) {\n\t\treturn 0;\n\t}\n\n\tif ( normalizedName.startsWith( normalizedSearch ) ) {\n\t\treturn normalizedName.length;\n\t}\n\n\treturn Infinity;\n};\n\nexport function PageAttributesParent() {\n\tconst { editPost } = useDispatch( editorStore );\n\tconst [ fieldValue, setFieldValue ] = useState( false );\n\tconst { parentPost, parentPostId, items, postType } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getPostType, getEntityRecords, getEntityRecord } =\n\t\t\t\tselect( coreStore );\n\t\t\tconst { getCurrentPostId, getEditedPostAttribute } =\n\t\t\t\tselect( editorStore );\n\t\t\tconst postTypeSlug = getEditedPostAttribute( 'type' );\n\t\t\tconst pageId = getEditedPostAttribute( 'parent' );\n\t\t\tconst pType = getPostType( postTypeSlug );\n\t\t\tconst postId = getCurrentPostId();\n\t\t\tconst isHierarchical = get( pType, [ 'hierarchical' ], false );\n\t\t\tconst query = {\n\t\t\t\tper_page: 100,\n\t\t\t\texclude: postId,\n\t\t\t\tparent_exclude: postId,\n\t\t\t\torderby: 'menu_order',\n\t\t\t\torder: 'asc',\n\t\t\t\t_fields: 'id,title,parent',\n\t\t\t};\n\n\t\t\t// Perform a search when the field is changed.\n\t\t\tif ( !! fieldValue ) {\n\t\t\t\tquery.search = fieldValue;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tparentPostId: pageId,\n\t\t\t\tparentPost: pageId\n\t\t\t\t\t? getEntityRecord( 'postType', postTypeSlug, pageId )\n\t\t\t\t\t: null,\n\t\t\t\titems: isHierarchical\n\t\t\t\t\t? getEntityRecords( 'postType', postTypeSlug, query )\n\t\t\t\t\t: [],\n\t\t\t\tpostType: pType,\n\t\t\t};\n\t\t},\n\t\t[ fieldValue ]\n\t);\n\n\tconst isHierarchical = get( postType, [ 'hierarchical' ], false );\n\tconst parentPageLabel = get( postType, [ 'labels', 'parent_item_colon' ] );\n\tconst pageItems = items || [];\n\n\tconst parentOptions = useMemo( () => {\n\t\tconst getOptionsFromTree = ( tree, level = 0 ) => {\n\t\t\tconst mappedNodes = tree.map( ( treeNode ) => [\n\t\t\t\t{\n\t\t\t\t\tvalue: treeNode.id,\n\t\t\t\t\tlabel:\n\t\t\t\t\t\t'— '.repeat( level ) + unescapeString( treeNode.name ),\n\t\t\t\t\trawName: treeNode.name,\n\t\t\t\t},\n\t\t\t\t...getOptionsFromTree( treeNode.children || [], level + 1 ),\n\t\t\t] );\n\n\t\t\tconst sortedNodes = mappedNodes.sort( ( [ a ], [ b ] ) => {\n\t\t\t\tconst priorityA = getItemPriority( a.rawName, fieldValue );\n\t\t\t\tconst priorityB = getItemPriority( b.rawName, fieldValue );\n\t\t\t\treturn priorityA >= priorityB ? 1 : -1;\n\t\t\t} );\n\n\t\t\treturn sortedNodes.flat();\n\t\t};\n\n\t\tlet tree = pageItems.map( ( item ) => ( {\n\t\t\tid: item.id,\n\t\t\tparent: item.parent,\n\t\t\tname: getTitle( item ),\n\t\t} ) );\n\n\t\t// Only build a hierarchical tree when not searching.\n\t\tif ( ! fieldValue ) {\n\t\t\ttree = buildTermsTree( tree );\n\t\t}\n\n\t\tconst opts = getOptionsFromTree( tree );\n\n\t\t// Ensure the current parent is in the options list.\n\t\tconst optsHasParent = find(\n\t\t\topts,\n\t\t\t( item ) => item.value === parentPostId\n\t\t);\n\t\tif ( parentPost && ! optsHasParent ) {\n\t\t\topts.unshift( {\n\t\t\t\tvalue: parentPostId,\n\t\t\t\tlabel: getTitle( parentPost ),\n\t\t\t} );\n\t\t}\n\t\treturn opts;\n\t}, [ pageItems, fieldValue ] );\n\n\tif ( ! isHierarchical || ! parentPageLabel ) {\n\t\treturn null;\n\t}\n\t/**\n\t * Handle user input.\n\t *\n\t * @param {string} inputValue The current value of the input field.\n\t */\n\tconst handleKeydown = ( inputValue ) => {\n\t\tsetFieldValue( inputValue );\n\t};\n\n\t/**\n\t * Handle author selection.\n\t *\n\t * @param {Object} selectedPostId The selected Author.\n\t */\n\tconst handleChange = ( selectedPostId ) => {\n\t\teditPost( { parent: selectedPostId } );\n\t};\n\n\treturn (\n\t\t<ComboboxControl\n\t\t\tclassName=\"editor-page-attributes__parent\"\n\t\t\tlabel={ parentPageLabel }\n\t\t\tvalue={ parentPostId }\n\t\t\toptions={ parentOptions }\n\t\t\tonFilterValueChange={ debounce( handleKeydown, 300 ) }\n\t\t\tonChange={ handleChange }\n\t\t/>\n\t);\n}\n\nexport default PageAttributesParent;\n"]}
1
+ {"version":3,"sources":["@wordpress/editor/src/components/page-attributes/parent.js"],"names":["getTitle","post","title","rendered","id","getItemPriority","name","searchValue","normalizedName","toLowerCase","normalizedSearch","startsWith","length","Infinity","PageAttributesParent","editPost","editorStore","fieldValue","setFieldValue","parentPost","parentPostId","items","postType","select","getPostType","getEntityRecords","getEntityRecord","coreStore","getCurrentPostId","getEditedPostAttribute","postTypeSlug","pageId","pType","postId","isHierarchical","query","per_page","exclude","parent_exclude","orderby","order","_fields","search","parentPageLabel","pageItems","parentOptions","getOptionsFromTree","tree","level","mappedNodes","map","treeNode","value","label","repeat","rawName","children","sortedNodes","sort","a","b","priorityA","priorityB","flat","item","parent","opts","optsHasParent","find","unshift","handleKeydown","inputValue","handleChange","selectedPostId"],"mappings":";;;;;;;;;;AAYA;;AATA;;AACA;;AAKA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AAKA;;AACA;;AArBA;AACA;AACA;;AAIA;AACA;AACA;;AASA;AACA;AACA;AAIA,SAASA,QAAT,CAAmBC,IAAnB,EAA0B;AAAA;;AACzB,SAAOA,IAAI,SAAJ,IAAAA,IAAI,WAAJ,mBAAAA,IAAI,CAAEC,KAAN,oDAAaC,QAAb,GACJ,kCAAgBF,IAAI,CAACC,KAAL,CAAWC,QAA3B,CADI,GAEH,IAAIF,IAAI,CAACG,EAAI,KAAK,cAAI,UAAJ,CAAkB,GAFxC;AAGA;;AAEM,MAAMC,eAAe,GAAG,CAAEC,IAAF,EAAQC,WAAR,KAAyB;AACvD,QAAMC,cAAc,GAAG,4BAAeF,IAAI,IAAI,EAAvB,EAA4BG,WAA5B,EAAvB;AACA,QAAMC,gBAAgB,GAAG,4BAAeH,WAAW,IAAI,EAA9B,EAAmCE,WAAnC,EAAzB;;AACA,MAAKD,cAAc,KAAKE,gBAAxB,EAA2C;AAC1C,WAAO,CAAP;AACA;;AAED,MAAKF,cAAc,CAACG,UAAf,CAA2BD,gBAA3B,CAAL,EAAqD;AACpD,WAAOF,cAAc,CAACI,MAAtB;AACA;;AAED,SAAOC,QAAP;AACA,CAZM;;;;AAcA,SAASC,oBAAT,GAAgC;AACtC,QA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R;AACA,GAFD;;AAIA,SACC,4BAAC,2BAAD;AACC,IAAA,uBAAuB,MADxB;AAEC,IAAA,SAAS,EAAC,gCAFX;AAGC,IAAA,KAAK,EAAG9B,eAHT;AAIC,IAAA,KAAK,EAAGvB,YAJT;AAKC,IAAA,OAAO,EAAGyB,aALX;AAMC,IAAA,mBAAmB,EAAG,uBAAUyB,aAAV,EAAyB,GAAzB,CANvB;AAOC,IAAA,QAAQ,EAAGE;AAPZ,IADD;AAWA;;eAEc1D,oB","sourcesContent":["/**\n * External dependencies\n */\nimport { get, unescape as unescapeString } from 'lodash';\nimport removeAccents from 'remove-accents';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { ComboboxControl } from '@wordpress/components';\nimport { debounce } from '@wordpress/compose';\nimport { useState, useMemo } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { buildTermsTree } from '../../utils/terms';\nimport { store as editorStore } from '../../store';\n\nfunction getTitle( post ) {\n\treturn post?.title?.rendered\n\t\t? decodeEntities( post.title.rendered )\n\t\t: `#${ post.id } (${ __( 'no title' ) })`;\n}\n\nexport const getItemPriority = ( name, searchValue ) => {\n\tconst normalizedName = removeAccents( name || '' ).toLowerCase();\n\tconst normalizedSearch = removeAccents( searchValue || '' ).toLowerCase();\n\tif ( normalizedName === normalizedSearch ) {\n\t\treturn 0;\n\t}\n\n\tif ( normalizedName.startsWith( normalizedSearch ) ) {\n\t\treturn normalizedName.length;\n\t}\n\n\treturn Infinity;\n};\n\nexport function PageAttributesParent() {\n\tconst { editPost } = useDispatch( editorStore );\n\tconst [ fieldValue, setFieldValue ] = useState( false );\n\tconst { parentPost, parentPostId, items, postType } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getPostType, getEntityRecords, getEntityRecord } =\n\t\t\t\tselect( coreStore );\n\t\t\tconst { getCurrentPostId, getEditedPostAttribute } =\n\t\t\t\tselect( editorStore );\n\t\t\tconst postTypeSlug = getEditedPostAttribute( 'type' );\n\t\t\tconst pageId = getEditedPostAttribute( 'parent' );\n\t\t\tconst pType = getPostType( postTypeSlug );\n\t\t\tconst postId = getCurrentPostId();\n\t\t\tconst isHierarchical = get( pType, [ 'hierarchical' ], false );\n\t\t\tconst query = {\n\t\t\t\tper_page: 100,\n\t\t\t\texclude: postId,\n\t\t\t\tparent_exclude: postId,\n\t\t\t\torderby: 'menu_order',\n\t\t\t\torder: 'asc',\n\t\t\t\t_fields: 'id,title,parent',\n\t\t\t};\n\n\t\t\t// Perform a search when the field is changed.\n\t\t\tif ( !! fieldValue ) {\n\t\t\t\tquery.search = fieldValue;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tparentPostId: pageId,\n\t\t\t\tparentPost: pageId\n\t\t\t\t\t? getEntityRecord( 'postType', postTypeSlug, pageId )\n\t\t\t\t\t: null,\n\t\t\t\titems: isHierarchical\n\t\t\t\t\t? getEntityRecords( 'postType', postTypeSlug, query )\n\t\t\t\t\t: [],\n\t\t\t\tpostType: pType,\n\t\t\t};\n\t\t},\n\t\t[ fieldValue ]\n\t);\n\n\tconst isHierarchical = get( postType, [ 'hierarchical' ], false );\n\tconst parentPageLabel = get( postType, [ 'labels', 'parent_item_colon' ] );\n\tconst pageItems = items || [];\n\n\tconst parentOptions = useMemo( () => {\n\t\tconst getOptionsFromTree = ( tree, level = 0 ) => {\n\t\t\tconst mappedNodes = tree.map( ( treeNode ) => [\n\t\t\t\t{\n\t\t\t\t\tvalue: treeNode.id,\n\t\t\t\t\tlabel:\n\t\t\t\t\t\t'— '.repeat( level ) + unescapeString( treeNode.name ),\n\t\t\t\t\trawName: treeNode.name,\n\t\t\t\t},\n\t\t\t\t...getOptionsFromTree( treeNode.children || [], level + 1 ),\n\t\t\t] );\n\n\t\t\tconst sortedNodes = mappedNodes.sort( ( [ a ], [ b ] ) => {\n\t\t\t\tconst priorityA = getItemPriority( a.rawName, fieldValue );\n\t\t\t\tconst priorityB = getItemPriority( b.rawName, fieldValue );\n\t\t\t\treturn priorityA >= priorityB ? 1 : -1;\n\t\t\t} );\n\n\t\t\treturn sortedNodes.flat();\n\t\t};\n\n\t\tlet tree = pageItems.map( ( item ) => ( {\n\t\t\tid: item.id,\n\t\t\tparent: item.parent,\n\t\t\tname: getTitle( item ),\n\t\t} ) );\n\n\t\t// Only build a hierarchical tree when not searching.\n\t\tif ( ! fieldValue ) {\n\t\t\ttree = buildTermsTree( tree );\n\t\t}\n\n\t\tconst opts = getOptionsFromTree( tree );\n\n\t\t// Ensure the current parent is in the options list.\n\t\tconst optsHasParent = opts.find(\n\t\t\t( item ) => item.value === parentPostId\n\t\t);\n\t\tif ( parentPost && ! optsHasParent ) {\n\t\t\topts.unshift( {\n\t\t\t\tvalue: parentPostId,\n\t\t\t\tlabel: getTitle( parentPost ),\n\t\t\t} );\n\t\t}\n\t\treturn opts;\n\t}, [ pageItems, fieldValue ] );\n\n\tif ( ! isHierarchical || ! parentPageLabel ) {\n\t\treturn null;\n\t}\n\t/**\n\t * Handle user input.\n\t *\n\t * @param {string} inputValue The current value of the input field.\n\t */\n\tconst handleKeydown = ( inputValue ) => {\n\t\tsetFieldValue( inputValue );\n\t};\n\n\t/**\n\t * Handle author selection.\n\t *\n\t * @param {Object} selectedPostId The selected Author.\n\t */\n\tconst handleChange = ( selectedPostId ) => {\n\t\teditPost( { parent: selectedPostId } );\n\t};\n\n\treturn (\n\t\t<ComboboxControl\n\t\t\t__nextHasNoMarginBottom\n\t\t\tclassName=\"editor-page-attributes__parent\"\n\t\t\tlabel={ parentPageLabel }\n\t\t\tvalue={ parentPostId }\n\t\t\toptions={ parentOptions }\n\t\t\tonFilterValueChange={ debounce( handleKeydown, 300 ) }\n\t\t\tonChange={ handleChange }\n\t\t/>\n\t);\n}\n\nexport default PageAttributesParent;\n"]}
@@ -121,6 +121,7 @@ function PostAuthorCombobox() {
121
121
  }
122
122
 
123
123
  return (0, _element.createElement)(_components.ComboboxControl, {
124
+ __nextHasNoMarginBottom: true,
124
125
  label: (0, _i18n.__)('Author'),
125
126
  options: authorOptions,
126
127
  value: authorId,
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/editor/src/components/post-author/combobox.js"],"names":["PostAuthorCombobox","fieldValue","setFieldValue","authorId","isLoading","authors","postAuthor","select","getUser","getUsers","isResolving","coreStore","getEditedPostAttribute","editorStore","author","context","query","AUTHORS_QUERY","search","editPost","authorOptions","fetchedAuthors","map","value","id","label","name","foundAuthor","findIndex","handleSelect","postAuthorId","handleKeydown","inputValue"],"mappings":";;;;;;;AAIA;;AADA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AAfA;AACA;AACA;;AASA;AACA;AACA;AAIA,SAASA,kBAAT,GAA8B;AAC7B,QAAM,CAAEC,UAAF,EAAcC,aAAd,IAAgC,wBAAtC;AAEA,QAAM;AAAEC,IAAAA,QAAF;AAAYC,IAAAA,SAAZ;AAAuBC,IAAAA,OAAvB;AAAgCC,IAAAA;AAAhC,MAA+C,qBAClDC,MAAF,IAAc;AACb,UAAM;AAAEC,MAAAA,OAAF;AAAWC,MAAAA,QAAX;AAAqBC,MAAAA;AAArB,QAAqCH,MAAM,CAAEI,eAAF,CAAjD;AACA,UAAM;AAAEC,MAAAA;AAAF,QAA6BL,MAAM,CAAEM,YAAF,CAAzC;AACA,UAAMC,MAAM,GAAGN,OAAO,CAAEI,sBAAsB,CAAE,QAAF,CAAxB,EAAsC;AAC3DG,MAAAA,OAAO,EAAE;AADkD,KAAtC,CAAtB;AAGA,UAAMC,KAAK,GAAG,EAAE,GAAGC;AAAL,KAAd;;AAEA,QAAKhB,UAAL,EAAkB;AACjBe,MAAAA,KAAK,CAACE,MAAN,GAAejB,UAAf;AACA;;AAED,WAAO;AACNE,MAAAA,QAAQ,EAAES,sBAAsB,CAAE,QAAF,CAD1B;AAENN,MAAAA,UAAU,EAAEQ,MAFN;AAGN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EAAEgB;AAAV,KAAF,CAAR;AACA,GALD;AAOA;AACD;AACA;AACA;AACA;;;AACC,QAAMC,aAAa,GAAKC,UAAF,IAAkB;AACvC9B,IAAAA,aAAa,CAAE8B,UAAF,CAAb;AACA,GAFD;;AAIA,MAAK,CAAE1B,UAAP,EAAoB;AACnB,WAAO,IAAP;AACA;;AAED,SACC,4BAAC,2BAAD;AACC,IAAA,KAAK,EAAG,cAAI,QAAJ,CADT;AAEC,IAAA,OAAO,EAAGc,aAFX;AAGC,IAAA,KAAK,EAAGjB,QAHT;AAIC,IAAA,mBAAmB,EAAG,uBAAU4B,aAAV,EAAyB,GAAzB,CAJvB;AAKC,IAAA,QAAQ,EAAGF,YALZ;AAMC,IAAA,SAAS,EAAGzB,SANb;AAOC,IAAA,UAAU,EAAG;AAPd,IADD;AAWA;;eAEcJ,kB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { debounce } from '@wordpress/compose';\nimport { useState, useMemo } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { ComboboxControl } from '@wordpress/components';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport { AUTHORS_QUERY } from './constants';\n\nfunction PostAuthorCombobox() {\n\tconst [ fieldValue, setFieldValue ] = useState();\n\n\tconst { authorId, isLoading, authors, postAuthor } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getUser, getUsers, isResolving } = select( coreStore );\n\t\t\tconst { getEditedPostAttribute } = select( editorStore );\n\t\t\tconst author = getUser( getEditedPostAttribute( 'author' ), {\n\t\t\t\tcontext: 'view',\n\t\t\t} );\n\t\t\tconst query = { ...AUTHORS_QUERY };\n\n\t\t\tif ( fieldValue ) {\n\t\t\t\tquery.search = fieldValue;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tauthorId: getEditedPostAttribute( 'author' ),\n\t\t\t\tpostAuthor: author,\n\t\t\t\tauthors: getUsers( query ),\n\t\t\t\tisLoading: isResolving( 'core', 'getUsers', [ query ] ),\n\t\t\t};\n\t\t},\n\t\t[ fieldValue ]\n\t);\n\tconst { editPost } = useDispatch( editorStore );\n\n\tconst authorOptions = useMemo( () => {\n\t\tconst fetchedAuthors = ( authors ?? [] ).map( ( author ) => {\n\t\t\treturn {\n\t\t\t\tvalue: author.id,\n\t\t\t\tlabel: decodeEntities( author.name ),\n\t\t\t};\n\t\t} );\n\n\t\t// Ensure the current author is included in the dropdown list.\n\t\tconst foundAuthor = fetchedAuthors.findIndex(\n\t\t\t( { value } ) => postAuthor?.id === value\n\t\t);\n\n\t\tif ( foundAuthor < 0 && postAuthor ) {\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tvalue: postAuthor.id,\n\t\t\t\t\tlabel: decodeEntities( postAuthor.name ),\n\t\t\t\t},\n\t\t\t\t...fetchedAuthors,\n\t\t\t];\n\t\t}\n\n\t\treturn fetchedAuthors;\n\t}, [ authors, postAuthor ] );\n\n\t/**\n\t * Handle author selection.\n\t *\n\t * @param {number} postAuthorId The selected Author.\n\t */\n\tconst handleSelect = ( postAuthorId ) => {\n\t\tif ( ! postAuthorId ) {\n\t\t\treturn;\n\t\t}\n\t\teditPost( { author: postAuthorId } );\n\t};\n\n\t/**\n\t * Handle user input.\n\t *\n\t * @param {string} inputValue The current value of the input field.\n\t */\n\tconst handleKeydown = ( inputValue ) => {\n\t\tsetFieldValue( inputValue );\n\t};\n\n\tif ( ! postAuthor ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<ComboboxControl\n\t\t\tlabel={ __( 'Author' ) }\n\t\t\toptions={ authorOptions }\n\t\t\tvalue={ authorId }\n\t\t\tonFilterValueChange={ debounce( handleKeydown, 300 ) }\n\t\t\tonChange={ handleSelect }\n\t\t\tisLoading={ isLoading }\n\t\t\tallowReset={ false }\n\t\t/>\n\t);\n}\n\nexport default PostAuthorCombobox;\n"]}
1
+ {"version":3,"sources":["@wordpress/editor/src/components/post-author/combobox.js"],"names":["PostAuthorCombobox","fieldValue","setFieldValue","authorId","isLoading","authors","postAuthor","select","getUser","getUsers","isResolving","coreStore","getEditedPostAttribute","editorStore","author","context","query","AUTHORS_QUERY","search","editPost","authorOptions","fetchedAuthors","map","value","id","label","name","foundAuthor","findIndex","handleSelect","postAuthorId","handleKeydown","inputValue"],"mappings":";;;;;;;AAIA;;AADA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AAfA;AACA;AACA;;AASA;AACA;AACA;AAIA,SAASA,kBAAT,GAA8B;AAC7B,QAAM,CAAEC,UAAF,EAAcC,aAAd,IAAgC,wBAAtC;AAEA,QAAM;AAAEC,IAAAA,QAAF;AAAYC,IAAAA,SAAZ;AAAuBC,IAAAA,OAAvB;AAAgCC,IAAAA;AAAhC,MAA+C,qBAClDC,MAAF,IAAc;AACb,UAAM;AAAEC,MAAAA,OAAF;AAAWC,MAAAA,QAAX;AAAqBC,MAAAA;AAArB,QAAqCH,MAAM,CAAEI,eAAF,CAAjD;AACA,UAAM;AAAEC,MAAAA;AAAF,QAA6BL,MAAM,CAAEM,YAAF,CAAzC;AACA,UAAMC,MAAM,GAAGN,OAAO,CAAEI,sBAAsB,CAAE,QAAF,CAAxB,EAAsC;AAC3DG,MAAAA,OAAO,EAAE;AADkD,KAAtC,CAAtB;AAGA,UAAMC,KAAK,GAAG,EAAE,GAAGC;AAAL,KAAd;;AAEA,QAAKhB,UAAL,EAAkB;AACjBe,MAAAA,KAAK,CAACE,MAAN,GAAejB,UAAf;AACA;;AAED,WAAO;AACNE,MAAAA,QAAQ,EAAES,sBAAsB,CAAE,QAAF,CAD1B;AAENN,MAAAA,UAAU,EAAEQ,MAFN;AAGNT,MAAAA,OAAO,EAAEI,QAAQ,CAAEO,KAAF,CAHX;AAINZ,MAAAA,SAAS,EAAEM,WAAW,CAAE,MAAF,EAAU,UAAV,EAAsB,CAAEM,KAAF,CAAtB;A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F,CAAb;AACA,GAFD;;AAIA,MAAK,CAAE1B,UAAP,EAAoB;AACnB,WAAO,IAAP;AACA;;AAED,SACC,4BAAC,2BAAD;AACC,IAAA,uBAAuB,MADxB;AAEC,IAAA,KAAK,EAAG,cAAI,QAAJ,CAFT;AAGC,IAAA,OAAO,EAAGc,aAHX;AAIC,IAAA,KAAK,EAAGjB,QAJT;AAKC,IAAA,mBAAmB,EAAG,uBAAU4B,aAAV,EAAyB,GAAzB,CALvB;AAMC,IAAA,QAAQ,EAAGF,YANZ;AAOC,IAAA,SAAS,EAAGzB,SAPb;AAQC,IAAA,UAAU,EAAG;AARd,IADD;AAYA;;eAEcJ,kB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { debounce } from '@wordpress/compose';\nimport { useState, useMemo } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { ComboboxControl } from '@wordpress/components';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport { AUTHORS_QUERY } from './constants';\n\nfunction PostAuthorCombobox() {\n\tconst [ fieldValue, setFieldValue ] = useState();\n\n\tconst { authorId, isLoading, authors, postAuthor } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getUser, getUsers, isResolving } = select( coreStore );\n\t\t\tconst { getEditedPostAttribute } = select( editorStore );\n\t\t\tconst author = getUser( getEditedPostAttribute( 'author' ), {\n\t\t\t\tcontext: 'view',\n\t\t\t} );\n\t\t\tconst query = { ...AUTHORS_QUERY };\n\n\t\t\tif ( fieldValue ) {\n\t\t\t\tquery.search = fieldValue;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tauthorId: getEditedPostAttribute( 'author' ),\n\t\t\t\tpostAuthor: author,\n\t\t\t\tauthors: getUsers( query ),\n\t\t\t\tisLoading: isResolving( 'core', 'getUsers', [ query ] ),\n\t\t\t};\n\t\t},\n\t\t[ fieldValue ]\n\t);\n\tconst { editPost } = useDispatch( editorStore );\n\n\tconst authorOptions = useMemo( () => {\n\t\tconst fetchedAuthors = ( authors ?? [] ).map( ( author ) => {\n\t\t\treturn {\n\t\t\t\tvalue: author.id,\n\t\t\t\tlabel: decodeEntities( author.name ),\n\t\t\t};\n\t\t} );\n\n\t\t// Ensure the current author is included in the dropdown list.\n\t\tconst foundAuthor = fetchedAuthors.findIndex(\n\t\t\t( { value } ) => postAuthor?.id === value\n\t\t);\n\n\t\tif ( foundAuthor < 0 && postAuthor ) {\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tvalue: postAuthor.id,\n\t\t\t\t\tlabel: decodeEntities( postAuthor.name ),\n\t\t\t\t},\n\t\t\t\t...fetchedAuthors,\n\t\t\t];\n\t\t}\n\n\t\treturn fetchedAuthors;\n\t}, [ authors, postAuthor ] );\n\n\t/**\n\t * Handle author selection.\n\t *\n\t * @param {number} postAuthorId The selected Author.\n\t */\n\tconst handleSelect = ( postAuthorId ) => {\n\t\tif ( ! postAuthorId ) {\n\t\t\treturn;\n\t\t}\n\t\teditPost( { author: postAuthorId } );\n\t};\n\n\t/**\n\t * Handle user input.\n\t *\n\t * @param {string} inputValue The current value of the input field.\n\t */\n\tconst handleKeydown = ( inputValue ) => {\n\t\tsetFieldValue( inputValue );\n\t};\n\n\tif ( ! postAuthor ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<ComboboxControl\n\t\t\t__nextHasNoMarginBottom\n\t\t\tlabel={ __( 'Author' ) }\n\t\t\toptions={ authorOptions }\n\t\t\tvalue={ authorId }\n\t\t\tonFilterValueChange={ debounce( handleKeydown, 300 ) }\n\t\t\tonChange={ handleSelect }\n\t\t\tisLoading={ isLoading }\n\t\t\tallowReset={ false }\n\t\t/>\n\t);\n}\n\nexport default PostAuthorCombobox;\n"]}
@@ -10,8 +10,6 @@ exports.default = PostFormat;
10
10
 
11
11
  var _element = require("@wordpress/element");
12
12
 
13
- var _lodash = require("lodash");
14
-
15
13
  var _i18n = require("@wordpress/i18n");
16
14
 
17
15
  var _components = require("@wordpress/components");
@@ -26,10 +24,6 @@ var _check = _interopRequireDefault(require("./check"));
26
24
 
27
25
  var _store = require("../../store");
28
26
 
29
- /**
30
- * External dependencies
31
- */
32
-
33
27
  /**
34
28
  * WordPress dependencies
35
29
  */
@@ -111,7 +105,7 @@ function PostFormat() {
111
105
  // The current format may not be a format supported by the theme.
112
106
  return (supportedFormats === null || supportedFormats === void 0 ? void 0 : supportedFormats.includes(format.id)) || postFormat === format.id;
113
107
  });
114
- const suggestion = (0, _lodash.find)(formats, format => format.id === suggestedFormat);
108
+ const suggestion = formats.find(format => format.id === suggestedFormat);
115
109
  const {
116
110
  editPost
117
111
  } = (0, _data.useDispatch)(_store.store);
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/editor/src/components/post-format/index.js"],"names":["POST_FORMATS","id","caption","sort","a","b","normalizedA","toUpperCase","normalizedB","PostFormat","instanceId","postFormatSelectorId","postFormat","suggestedFormat","supportedFormats","select","getEditedPostAttribute","getSuggestedPostFormat","editorStore","_postFormat","themeSupports","coreStore","getThemeSupports","formats","filter","format","includes","suggestion","editPost","onUpdatePostFormat","map","label","value"],"mappings":";;;;;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AAlBA;AACA;AACA;;AAGA;AACA;AACA;;AAOA;AACA;AACA;AAIA;AACO,MAAMA,YAAY,GAAG,CAC3B;AAAEC,EAAAA,EAAE,EAAE,OAAN;AAAeC,EAAAA,OAAO,EAAE,cAAI,OAAJ;AAAxB,CAD2B,EAE3B;AAAED,EAAAA,EAAE,EAAE,OAAN;AAAeC,EAAAA,OAAO,EAAE,cAAI,OAAJ;AAAxB,CAF2B,EAG3B;AAAED,EAAAA,EAAE,EAAE,MAAN;AAAcC,EAAAA,OAAO,EAAE,cAAI,MAAJ;AAAvB,CAH2B,EAI3B;AAAED,EAAAA,EAAE,EAAE,SAAN;A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,KAAK,EAAEN,MAAM,CAACvB,OADwB;AAEtC8B,MAAAA,KAAK,EAAEP,MAAM,CAACxB;AAFwB,KAAhB,CAAb;AALX,IADD,EAWG0B,UAAU,IAAIA,UAAU,CAAC1B,EAAX,KAAkBW,UAAhC,IACD;AAAG,IAAA,SAAS,EAAC;AAAb,KACC,4BAAC,kBAAD;AACC,IAAA,OAAO,EAAC,MADT;AAEC,IAAA,OAAO,EAAG,MACTiB,kBAAkB,CAAEF,UAAU,CAAC1B,EAAb;AAHpB,KAMG;AACD;AACA,gBAAI,4BAAJ,CAFC,EAGD0B,UAAU,CAACzB,OAHV,CANH,CADD,CAZF,CADD,CADD;AAgCA","sourcesContent":["/**\n * External dependencies\n */\nimport { find } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { Button, SelectControl } from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useInstanceId } from '@wordpress/compose';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport PostFormatCheck from './check';\nimport { store as editorStore } from '../../store';\n\n// All WP post formats, sorted alphabetically by translated name.\nexport const POST_FORMATS = [\n\t{ id: 'aside', caption: __( 'Aside' ) },\n\t{ id: 'audio', caption: __( 'Audio' ) },\n\t{ id: 'chat', caption: __( 'Chat' ) },\n\t{ id: 'gallery', caption: __( 'Gallery' ) },\n\t{ id: 'image', caption: __( 'Image' ) },\n\t{ id: 'link', caption: __( 'Link' ) },\n\t{ id: 'quote', caption: __( 'Quote' ) },\n\t{ id: 'standard', caption: __( 'Standard' ) },\n\t{ id: 'status', caption: __( 'Status' ) },\n\t{ id: 'video', caption: __( 'Video' ) },\n].sort( ( a, b ) => {\n\tconst normalizedA = a.caption.toUpperCase();\n\tconst normalizedB = b.caption.toUpperCase();\n\n\tif ( normalizedA < normalizedB ) {\n\t\treturn -1;\n\t}\n\tif ( normalizedA > normalizedB ) {\n\t\treturn 1;\n\t}\n\treturn 0;\n} );\n\nexport default function PostFormat() {\n\tconst instanceId = useInstanceId( PostFormat );\n\tconst postFormatSelectorId = `post-format-selector-${ instanceId }`;\n\n\tconst { postFormat, suggestedFormat, supportedFormats } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEditedPostAttribute, getSuggestedPostFormat } =\n\t\t\t\tselect( editorStore );\n\t\t\tconst _postFormat = getEditedPostAttribute( 'format' );\n\t\t\tconst themeSupports = select( coreStore ).getThemeSupports();\n\t\t\treturn {\n\t\t\t\tpostFormat: _postFormat ?? 'standard',\n\t\t\t\tsuggestedFormat: getSuggestedPostFormat(),\n\t\t\t\tsupportedFormats: themeSupports.formats,\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\n\tconst formats = POST_FORMATS.filter( ( format ) => {\n\t\t// Ensure current format is always in the set.\n\t\t// The current format may not be a format supported by the theme.\n\t\treturn (\n\t\t\tsupportedFormats?.includes( format.id ) || postFormat === format.id\n\t\t);\n\t} );\n\tconst suggestion = find(\n\t\tformats,\n\t\t( format ) => format.id === suggestedFormat\n\t);\n\n\tconst { editPost } = useDispatch( editorStore );\n\n\tconst onUpdatePostFormat = ( format ) => editPost( { format } );\n\n\treturn (\n\t\t<PostFormatCheck>\n\t\t\t<div className=\"editor-post-format\">\n\t\t\t\t<SelectControl\n\t\t\t\t\tlabel={ __( 'Post Format' ) }\n\t\t\t\t\tvalue={ postFormat }\n\t\t\t\t\tonChange={ ( format ) => onUpdatePostFormat( format ) }\n\t\t\t\t\tid={ postFormatSelectorId }\n\t\t\t\t\toptions={ formats.map( ( format ) => ( {\n\t\t\t\t\t\tlabel: format.caption,\n\t\t\t\t\t\tvalue: format.id,\n\t\t\t\t\t} ) ) }\n\t\t\t\t/>\n\t\t\t\t{ suggestion && suggestion.id !== postFormat && (\n\t\t\t\t\t<p className=\"editor-post-format__suggestion\">\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tvariant=\"link\"\n\t\t\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\t\t\tonUpdatePostFormat( suggestion.id )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t\t\t/* translators: %s: post format */\n\t\t\t\t\t\t\t\t__( 'Apply suggested format: %s' ),\n\t\t\t\t\t\t\t\tsuggestion.caption\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</p>\n\t\t\t\t) }\n\t\t\t</div>\n\t\t</PostFormatCheck>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/editor/src/components/post-format/index.js"],"names":["POST_FORMATS","id","caption","sort","a","b","normalizedA","toUpperCase","normalizedB","PostFormat","instanceId","postFormatSelectorId","postFormat","suggestedFormat","supportedFormats","select","getEditedPostAttribute","getSuggestedPostFormat","editorStore","_postFormat","themeSupports","coreStore","getThemeSupports","formats","filter","format","includes","suggestion","find","editPost","onUpdatePostFormat","map","label","value"],"mappings":";;;;;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AAbA;AACA;AACA;;AAOA;AACA;AACA;AAIA;AACO,MAAMA,YAAY,GAAG,CAC3B;AAAEC,EAAAA,EAAE,EAAE,OAAN;AAAeC,EAAAA,OAAO,EAAE,cAAI,OAAJ;AAAxB,CAD2B,EAE3B;AAAED,EAAAA,EAAE,EAAE,OAAN;AAAeC,EAAAA,OAAO,EAAE,cAAI,OAAJ;AAAxB,CAF2B,EAG3B;AAAED,EAAAA,EAAE,EAAE,MAAN;AAAcC,EAAAA,OAAO,EAAE,cAAI,MAAJ;AAAvB,CAH2B,EAI3B;AAAED,EAAAA,EAAE,EAAE,SAAN;AAAiBC,EAAAA,OAAO,EAAE,cAAI,SAAJ;AAA1B,CAJ2B,EAK3B;AAAED,EAAAA,EAAE,EAAE,OAAN;AAAeC,EAAAA,OAAO,EAAE,cAAI,OAAJ;AAAxB,CAL2B,EAM3B;AAAED,EAAAA,EAAE,EAAE,MAAN;AAA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EAAC;AAAb,KACC,4BAAC,kBAAD;AACC,IAAA,OAAO,EAAC,MADT;AAEC,IAAA,OAAO,EAAG,MACTkB,kBAAkB,CAAEH,UAAU,CAAC1B,EAAb;AAHpB,KAMG;AACD;AACA,gBAAI,4BAAJ,CAFC,EAGD0B,UAAU,CAACzB,OAHV,CANH,CADD,CAZF,CADD,CADD;AAgCA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { Button, SelectControl } from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useInstanceId } from '@wordpress/compose';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport PostFormatCheck from './check';\nimport { store as editorStore } from '../../store';\n\n// All WP post formats, sorted alphabetically by translated name.\nexport const POST_FORMATS = [\n\t{ id: 'aside', caption: __( 'Aside' ) },\n\t{ id: 'audio', caption: __( 'Audio' ) },\n\t{ id: 'chat', caption: __( 'Chat' ) },\n\t{ id: 'gallery', caption: __( 'Gallery' ) },\n\t{ id: 'image', caption: __( 'Image' ) },\n\t{ id: 'link', caption: __( 'Link' ) },\n\t{ id: 'quote', caption: __( 'Quote' ) },\n\t{ id: 'standard', caption: __( 'Standard' ) },\n\t{ id: 'status', caption: __( 'Status' ) },\n\t{ id: 'video', caption: __( 'Video' ) },\n].sort( ( a, b ) => {\n\tconst normalizedA = a.caption.toUpperCase();\n\tconst normalizedB = b.caption.toUpperCase();\n\n\tif ( normalizedA < normalizedB ) {\n\t\treturn -1;\n\t}\n\tif ( normalizedA > normalizedB ) {\n\t\treturn 1;\n\t}\n\treturn 0;\n} );\n\nexport default function PostFormat() {\n\tconst instanceId = useInstanceId( PostFormat );\n\tconst postFormatSelectorId = `post-format-selector-${ instanceId }`;\n\n\tconst { postFormat, suggestedFormat, supportedFormats } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEditedPostAttribute, getSuggestedPostFormat } =\n\t\t\t\tselect( editorStore );\n\t\t\tconst _postFormat = getEditedPostAttribute( 'format' );\n\t\t\tconst themeSupports = select( coreStore ).getThemeSupports();\n\t\t\treturn {\n\t\t\t\tpostFormat: _postFormat ?? 'standard',\n\t\t\t\tsuggestedFormat: getSuggestedPostFormat(),\n\t\t\t\tsupportedFormats: themeSupports.formats,\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\n\tconst formats = POST_FORMATS.filter( ( format ) => {\n\t\t// Ensure current format is always in the set.\n\t\t// The current format may not be a format supported by the theme.\n\t\treturn (\n\t\t\tsupportedFormats?.includes( format.id ) || postFormat === format.id\n\t\t);\n\t} );\n\tconst suggestion = formats.find(\n\t\t( format ) => format.id === suggestedFormat\n\t);\n\n\tconst { editPost } = useDispatch( editorStore );\n\n\tconst onUpdatePostFormat = ( format ) => editPost( { format } );\n\n\treturn (\n\t\t<PostFormatCheck>\n\t\t\t<div className=\"editor-post-format\">\n\t\t\t\t<SelectControl\n\t\t\t\t\tlabel={ __( 'Post Format' ) }\n\t\t\t\t\tvalue={ postFormat }\n\t\t\t\t\tonChange={ ( format ) => onUpdatePostFormat( format ) }\n\t\t\t\t\tid={ postFormatSelectorId }\n\t\t\t\t\toptions={ formats.map( ( format ) => ( {\n\t\t\t\t\t\tlabel: format.caption,\n\t\t\t\t\t\tvalue: format.id,\n\t\t\t\t\t} ) ) }\n\t\t\t\t/>\n\t\t\t\t{ suggestion && suggestion.id !== postFormat && (\n\t\t\t\t\t<p className=\"editor-post-format__suggestion\">\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tvariant=\"link\"\n\t\t\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\t\t\tonUpdatePostFormat( suggestion.id )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t\t\t/* translators: %s: post format */\n\t\t\t\t\t\t\t\t__( 'Apply suggested format: %s' ),\n\t\t\t\t\t\t\t\tsuggestion.caption\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</p>\n\t\t\t\t) }\n\t\t\t</div>\n\t\t</PostFormatCheck>\n\t);\n}\n"]}
@@ -30,18 +30,23 @@ var _store = require("../../store");
30
30
  */
31
31
  function MaybeCategoryPanel() {
32
32
  const hasNoCategory = (0, _data.useSelect)(select => {
33
- var _select$getEntityReco;
33
+ var _getEntityRecord;
34
34
 
35
35
  const postType = select(_store.store).getCurrentPostType();
36
- const categoriesTaxonomy = select(_coreData.store).getTaxonomy('category');
37
- const defaultCategoryId = (_select$getEntityReco = select(_coreData.store).getEntityRecord('root', 'site')) === null || _select$getEntityReco === void 0 ? void 0 : _select$getEntityReco.default_category;
38
- const defaultCategory = select(_coreData.store).getEntityRecord('taxonomy', 'category', defaultCategoryId);
36
+ const {
37
+ canUser,
38
+ getEntityRecord,
39
+ getTaxonomy
40
+ } = select(_coreData.store);
41
+ const categoriesTaxonomy = getTaxonomy('category');
42
+ const defaultCategoryId = canUser('read', 'settings') ? (_getEntityRecord = getEntityRecord('root', 'site')) === null || _getEntityRecord === void 0 ? void 0 : _getEntityRecord.default_category : undefined;
43
+ const defaultCategory = defaultCategoryId ? getEntityRecord('taxonomy', 'category', defaultCategoryId) : undefined;
39
44
  const postTypeSupportsCategories = categoriesTaxonomy && categoriesTaxonomy.types.some(type => type === postType);
40
45
  const categories = categoriesTaxonomy && select(_store.store).getEditedPostAttribute(categoriesTaxonomy.rest_base); // This boolean should return true if everything is loaded
41
46
  // ( categoriesTaxonomy, defaultCategory )
42
47
  // and the post has not been assigned a category different than "uncategorized".
43
48
 
44
- return !!categoriesTaxonomy && !!defaultCategory && postTypeSupportsCategories && ((categories === null || categories === void 0 ? void 0 : categories.length) === 0 || (categories === null || categories === void 0 ? void 0 : categories.length) === 1 && defaultCategory.id === categories[0]);
49
+ return !!categoriesTaxonomy && !!defaultCategory && postTypeSupportsCategories && ((categories === null || categories === void 0 ? void 0 : categories.length) === 0 || (categories === null || categories === void 0 ? void 0 : categories.length) === 1 && (defaultCategory === null || defaultCategory === void 0 ? void 0 : defaultCategory.id) === categories[0]);
45
50
  }, []);
46
51
  const [shouldShowPanel, setShouldShowPanel] = (0, _element.useState)(false);
47
52
  (0, _element.useEffect)(() => {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/editor/src/components/post-publish-panel/maybe-category-panel.js"],"names":["MaybeCategoryPanel","hasNoCategory","select","postType","editorStore","getCurrentPostType","categoriesTaxonomy","coreStore","getTaxonomy","defaultCategoryId","getEntityRecord","default_category","defaultCategory","postTypeSupportsCategories","types","some","type","categories","getEditedPostAttribute","rest_base","length","id","shouldShowPanel","setShouldShowPanel","panelBodyTitle"],"mappings":";;;;;;;;;AAOA;;AAJA;;AACA;;AACA;;AACA;;AAMA;;AACA;;AAbA;AACA;AACA;;AAOA;AACA;AACA;AAIA,SAASA,kBAAT,GAA8B;AAC7B,QAAMC,aAAa,GAAG,qBAAaC,MAAF,IAAc;AAAA;;AAC9C,UAAMC,QAAQ,GAAGD,MAAM,CAAEE,YAAF,CAAN,CAAsBC,kBAAtB,EAAjB;AACA,UAAMC,kBAAkB,GACvBJ,MAAM,CAAEK,eAAF,CAAN,CAAoBC,WAApB,CAAiC,UAAjC,CADD;AAEA,UAAMC,iBAAiB,4BAAGP,MAAM,CAAEK,eAAF,CAAN,CAAoBG,eAApB,CACzB,MADyB,EAEzB,MAFyB,CAAH,0DAAG,sBAGvBC,gBAHH;AAIA,UAAMC,eAAe,GAAGV,MAAM,CAAEK,eAAF,CAAN,CAAoBG,eAApB,CACvB,UADuB,EAEvB,UAFuB,EAGvBD,iBAHuB,CAAxB;AAKA,UAAMI,0BAA0B,GAC/BP,kBAAkB,IAClBA,kBAAkB,CAACQ,KAAnB,CAAyBC,IAAzB,CAAiCC,IAAF,IAAYA,IAAI,KAAKb,QAApD,CAFD;AAGA,UAAMc,UAAU,GACfX,kBAAkB,IAClBJ,MAAM,CAAEE,YAAF,CAAN,CAAsBc,sBAAtB,CACCZ,kBAAkB,CAACa,SADpB,CAFD,CAhB8C,CAsB9C;AACA;AACA;;AACA,WACC,CAAC,CAAEb,kBAAH,IACA,CAAC,CAAEM,eADH,IAEAC,0BAFA,KAGE,CAAAI,UAAU,SAAV,IAAAA,UAAU,WAAV,YAAAA,UAAU,CAAEG,MAAZ,MAAuB,CAAvB,IACC,CAAAH,UAAU,SAAV,IAAAA,UAAU,WAAV,YAAAA,UAAU,CAAEG,MAAZ,MAAuB,CAAvB,IACDR,eAAe,CAACS,EAAhB,KAAuBJ,UAAU,CAAE,CAAF,CALnC,CADD;AAQA,GAjCqB,EAiCnB,EAjCmB,CAAtB;AAkCA,QAAM,CAAEK,eAAF,EAAmBC,kBAAnB,IAA0C,uBAAU,KAAV,CAAhD;AACA,0BAAW,MAAM;AAChB;AACA;AACA,QAAKtB,aAAL,EAAqB;AACpBsB,MAAAA,kBAAkB,CAAE,IAAF,CAAlB;AACA;AACD,GAND,EAMG,CAAEtB,aAAF,CANH;;AAQA,MAAK,CAAEqB,eAAP,EAAyB;AACxB,WAAO,IAAP;AACA;;AAED,QAAME,cAAc,GAAG,CACtB,cAAI,aAAJ,CADsB,EAEtB;AAAM,IAAA,SAAS,EAAC,iCAAhB;AAAkD,IAAA,GAAG,EAAC;AAAtD,KACG,cAAI,mBAAJ,CADH,CAFsB,CAAvB;AAOA,SACC,4BAAC,qBAAD;AAAW,IAAA,WAAW,EAAG,KAAzB;AAAiC,IAAA,KAAK,EAAGA;AAAzC,KACC,uCACG,cACD,oHADC,CADH,CADD,EAMC,4BAAC,iCAAD;AAA0B,IAAA,IAAI,EAAC;AAA/B,IAND,CADD;AAUA;;eAEcxB,kB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport { PanelBody } from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useState, useEffect } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport HierarchicalTermSelector from '../post-taxonomies/hierarchical-term-selector';\nimport { store as editorStore } from '../../store';\n\nfunction MaybeCategoryPanel() {\n\tconst hasNoCategory = useSelect( ( select ) => {\n\t\tconst postType = select( editorStore ).getCurrentPostType();\n\t\tconst categoriesTaxonomy =\n\t\t\tselect( coreStore ).getTaxonomy( 'category' );\n\t\tconst defaultCategoryId = select( coreStore ).getEntityRecord(\n\t\t\t'root',\n\t\t\t'site'\n\t\t)?.default_category;\n\t\tconst defaultCategory = select( coreStore ).getEntityRecord(\n\t\t\t'taxonomy',\n\t\t\t'category',\n\t\t\tdefaultCategoryId\n\t\t);\n\t\tconst postTypeSupportsCategories =\n\t\t\tcategoriesTaxonomy &&\n\t\t\tcategoriesTaxonomy.types.some( ( type ) => type === postType );\n\t\tconst categories =\n\t\t\tcategoriesTaxonomy &&\n\t\t\tselect( editorStore ).getEditedPostAttribute(\n\t\t\t\tcategoriesTaxonomy.rest_base\n\t\t\t);\n\n\t\t// This boolean should return true if everything is loaded\n\t\t// ( categoriesTaxonomy, defaultCategory )\n\t\t// and the post has not been assigned a category different than \"uncategorized\".\n\t\treturn (\n\t\t\t!! categoriesTaxonomy &&\n\t\t\t!! defaultCategory &&\n\t\t\tpostTypeSupportsCategories &&\n\t\t\t( categories?.length === 0 ||\n\t\t\t\t( categories?.length === 1 &&\n\t\t\t\t\tdefaultCategory.id === categories[ 0 ] ) )\n\t\t);\n\t}, [] );\n\tconst [ shouldShowPanel, setShouldShowPanel ] = useState( false );\n\tuseEffect( () => {\n\t\t// We use state to avoid hiding the panel if the user edits the categories\n\t\t// and adds one within the panel itself (while visible).\n\t\tif ( hasNoCategory ) {\n\t\t\tsetShouldShowPanel( true );\n\t\t}\n\t}, [ hasNoCategory ] );\n\n\tif ( ! shouldShowPanel ) {\n\t\treturn null;\n\t}\n\n\tconst panelBodyTitle = [\n\t\t__( 'Suggestion:' ),\n\t\t<span className=\"editor-post-publish-panel__link\" key=\"label\">\n\t\t\t{ __( 'Assign a category' ) }\n\t\t</span>,\n\t];\n\n\treturn (\n\t\t<PanelBody initialOpen={ false } title={ panelBodyTitle }>\n\t\t\t<p>\n\t\t\t\t{ __(\n\t\t\t\t\t'Categories provide a helpful way to group related posts together and to quickly tell readers what a post is about.'\n\t\t\t\t) }\n\t\t\t</p>\n\t\t\t<HierarchicalTermSelector slug=\"category\" />\n\t\t</PanelBody>\n\t);\n}\n\nexport default MaybeCategoryPanel;\n"]}
1
+ {"version":3,"sources":["@wordpress/editor/src/components/post-publish-panel/maybe-category-panel.js"],"names":["MaybeCategoryPanel","hasNoCategory","select","postType","editorStore","getCurrentPostType","canUser","getEntityRecord","getTaxonomy","coreStore","categoriesTaxonomy","defaultCategoryId","default_category","undefined","defaultCategory","postTypeSupportsCategories","types","some","type","categories","getEditedPostAttribute","rest_base","length","id","shouldShowPanel","setShouldShowPanel","panelBodyTitle"],"mappings":";;;;;;;;;AAOA;;AAJA;;AACA;;AACA;;AACA;;AAMA;;AACA;;AAbA;AACA;AACA;;AAOA;AACA;AACA;AAIA,SAASA,kBAAT,GAA8B;AAC7B,QAAMC,aAAa,GAAG,qBAAaC,MAAF,IAAc;AAAA;;AAC9C,UAAMC,QAAQ,GAAGD,MAAM,CAAEE,YAAF,CAAN,CAAsBC,kBAAtB,EAAjB;AACA,UAAM;AAAEC,MAAAA,OAAF;AAAWC,MAAAA,eAAX;AAA4BC,MAAAA;AAA5B,QAA4CN,MAAM,CAAEO,eAAF,CAAxD;AACA,UAAMC,kBAAkB,GAAGF,WAAW,CAAE,UAAF,CAAtC;AACA,UAAMG,iBAAiB,GAAGL,OAAO,CAAE,MAAF,EAAU,UAAV,CAAP,uBACvBC,eAAe,CAAE,MAAF,EAAU,MAAV,CADQ,qDACvB,iBAAmCK,gBADZ,GAEvBC,SAFH;AAGA,UAAMC,eAAe,GAAGH,iBAAiB,GACtCJ,eAAe,CAAE,UAAF,EAAc,UAAd,EAA0BI,iBAA1B,CADuB,GAEtCE,SAFH;AAGA,UAAME,0BAA0B,GAC/BL,kBAAkB,IAClBA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;eAEc1B,kB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport { PanelBody } from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useState, useEffect } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport HierarchicalTermSelector from '../post-taxonomies/hierarchical-term-selector';\nimport { store as editorStore } from '../../store';\n\nfunction MaybeCategoryPanel() {\n\tconst hasNoCategory = useSelect( ( select ) => {\n\t\tconst postType = select( editorStore ).getCurrentPostType();\n\t\tconst { canUser, getEntityRecord, getTaxonomy } = select( coreStore );\n\t\tconst categoriesTaxonomy = getTaxonomy( 'category' );\n\t\tconst defaultCategoryId = canUser( 'read', 'settings' )\n\t\t\t? getEntityRecord( 'root', 'site' )?.default_category\n\t\t\t: undefined;\n\t\tconst defaultCategory = defaultCategoryId\n\t\t\t? getEntityRecord( 'taxonomy', 'category', defaultCategoryId )\n\t\t\t: undefined;\n\t\tconst postTypeSupportsCategories =\n\t\t\tcategoriesTaxonomy &&\n\t\t\tcategoriesTaxonomy.types.some( ( type ) => type === postType );\n\t\tconst categories =\n\t\t\tcategoriesTaxonomy &&\n\t\t\tselect( editorStore ).getEditedPostAttribute(\n\t\t\t\tcategoriesTaxonomy.rest_base\n\t\t\t);\n\n\t\t// This boolean should return true if everything is loaded\n\t\t// ( categoriesTaxonomy, defaultCategory )\n\t\t// and the post has not been assigned a category different than \"uncategorized\".\n\t\treturn (\n\t\t\t!! categoriesTaxonomy &&\n\t\t\t!! defaultCategory &&\n\t\t\tpostTypeSupportsCategories &&\n\t\t\t( categories?.length === 0 ||\n\t\t\t\t( categories?.length === 1 &&\n\t\t\t\t\tdefaultCategory?.id === categories[ 0 ] ) )\n\t\t);\n\t}, [] );\n\tconst [ shouldShowPanel, setShouldShowPanel ] = useState( false );\n\tuseEffect( () => {\n\t\t// We use state to avoid hiding the panel if the user edits the categories\n\t\t// and adds one within the panel itself (while visible).\n\t\tif ( hasNoCategory ) {\n\t\t\tsetShouldShowPanel( true );\n\t\t}\n\t}, [ hasNoCategory ] );\n\n\tif ( ! shouldShowPanel ) {\n\t\treturn null;\n\t}\n\n\tconst panelBodyTitle = [\n\t\t__( 'Suggestion:' ),\n\t\t<span className=\"editor-post-publish-panel__link\" key=\"label\">\n\t\t\t{ __( 'Assign a category' ) }\n\t\t</span>,\n\t];\n\n\treturn (\n\t\t<PanelBody initialOpen={ false } title={ panelBodyTitle }>\n\t\t\t<p>\n\t\t\t\t{ __(\n\t\t\t\t\t'Categories provide a helpful way to group related posts together and to quickly tell readers what a post is about.'\n\t\t\t\t) }\n\t\t\t</p>\n\t\t\t<HierarchicalTermSelector slug=\"category\" />\n\t\t</PanelBody>\n\t);\n}\n\nexport default MaybeCategoryPanel;\n"]}
@@ -35,7 +35,7 @@ var _store = require("../../store");
35
35
  const getSuggestion = (supportedFormats, suggestedPostFormat) => {
36
36
  const formats = _postFormat.POST_FORMATS.filter(format => supportedFormats === null || supportedFormats === void 0 ? void 0 : supportedFormats.includes(format.id));
37
37
 
38
- return (0, _lodash.find)(formats, format => format.id === suggestedPostFormat);
38
+ return formats.find(format => format.id === suggestedPostFormat);
39
39
  };
40
40
 
41
41
  const PostFormatSuggestion = _ref => {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/editor/src/components/post-publish-panel/maybe-post-format-panel.js"],"names":["getSuggestion","supportedFormats","suggestedPostFormat","formats","POST_FORMATS","filter","format","includes","id","PostFormatSuggestion","suggestionText","onUpdatePostFormat","PostFormatPanel","currentPostFormat","suggestion","select","getEditedPostAttribute","getSuggestedPostFormat","editorStore","coreStore","getThemeSupports","editPost","panelBodyTitle","caption"],"mappings":";;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AAjBA;AACA;AACA;;AAGA;AACA;AACA;;AAMA;AACA;AACA;AAIA,MAAMA,aAAa,GAAG,CAAEC,gBAAF,EAAoBC,mBAApB,KAA6C;AAClE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tB;AAAM,IAAA,SAAS,EAAC,iCAAhB;AAAkD,IAAA,GAAG,EAAC;AAAtD,KACG,cAAI,mBAAJ,CADH,CAFsB,CAAvB;;AAOA,MAAK,CAAER,UAAF,IAAgBA,UAAU,CAACN,EAAX,KAAkBK,iBAAvC,EAA2D;AAC1D,WAAO,IAAP;AACA;;AAED,SACC,4BAAC,qBAAD;AAAW,IAAA,WAAW,EAAG,KAAzB;AAAiC,IAAA,KAAK,EAAGS;AAAzC,KACC,uCACG,cACD,+IADC,CADH,CADD,EAMC,uCACC,4BAAC,oBAAD;AACC,IAAA,kBAAkB,EAAGX,kBADtB;AAEC,IAAA,mBAAmB,EAAGG,UAAU,CAACN,EAFlC;AAGC,IAAA,cAAc,EAAG;AAChB;AACA,kBAAI,0BAAJ,CAFgB,EAGhBM,UAAU,CAACS,OAHK;AAHlB,IADD,CAND,CADD;AAoBA","sourcesContent":["/**\n * External dependencies\n */\nimport { find, get } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { Button, PanelBody } from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { POST_FORMATS } from '../post-format';\nimport { store as editorStore } from '../../store';\n\nconst getSuggestion = ( supportedFormats, suggestedPostFormat ) => {\n\tconst formats = POST_FORMATS.filter( ( format ) =>\n\t\tsupportedFormats?.includes( format.id )\n\t);\n\treturn find( formats, ( format ) => format.id === suggestedPostFormat );\n};\n\nconst PostFormatSuggestion = ( {\n\tsuggestedPostFormat,\n\tsuggestionText,\n\tonUpdatePostFormat,\n} ) => (\n\t<Button\n\t\tvariant=\"link\"\n\t\tonClick={ () => onUpdatePostFormat( suggestedPostFormat ) }\n\t>\n\t\t{ suggestionText }\n\t</Button>\n);\n\nexport default function PostFormatPanel() {\n\tconst { currentPostFormat, suggestion } = useSelect( ( select ) => {\n\t\tconst { getEditedPostAttribute, getSuggestedPostFormat } =\n\t\t\tselect( editorStore );\n\t\tconst supportedFormats = get(\n\t\t\tselect( coreStore ).getThemeSupports(),\n\t\t\t[ 'formats' ],\n\t\t\t[]\n\t\t);\n\t\treturn {\n\t\t\tcurrentPostFormat: getEditedPostAttribute( 'format' ),\n\t\t\tsuggestion: getSuggestion(\n\t\t\t\tsupportedFormats,\n\t\t\t\tgetSuggestedPostFormat()\n\t\t\t),\n\t\t};\n\t}, [] );\n\n\tconst { editPost } = useDispatch( editorStore );\n\n\tconst onUpdatePostFormat = ( format ) => editPost( { format } );\n\n\tconst panelBodyTitle = [\n\t\t__( 'Suggestion:' ),\n\t\t<span className=\"editor-post-publish-panel__link\" key=\"label\">\n\t\t\t{ __( 'Use a post format' ) }\n\t\t</span>,\n\t];\n\n\tif ( ! suggestion || suggestion.id === currentPostFormat ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<PanelBody initialOpen={ false } title={ panelBodyTitle }>\n\t\t\t<p>\n\t\t\t\t{ __(\n\t\t\t\t\t'Your theme uses post formats to highlight different kinds of content, like images or videos. Apply a post format to see this special styling.'\n\t\t\t\t) }\n\t\t\t</p>\n\t\t\t<p>\n\t\t\t\t<PostFormatSuggestion\n\t\t\t\t\tonUpdatePostFormat={ onUpdatePostFormat }\n\t\t\t\t\tsuggestedPostFormat={ suggestion.id }\n\t\t\t\t\tsuggestionText={ sprintf(\n\t\t\t\t\t\t/* translators: %s: post format */\n\t\t\t\t\t\t__( 'Apply the \"%1$s\" format.' ),\n\t\t\t\t\t\tsuggestion.caption\n\t\t\t\t\t) }\n\t\t\t\t/>\n\t\t\t</p>\n\t\t</PanelBody>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/editor/src/components/post-publish-panel/maybe-post-format-panel.js"],"names":["getSuggestion","supportedFormats","suggestedPostFormat","formats","POST_FORMATS","filter","format","includes","id","find","PostFormatSuggestion","suggestionText","onUpdatePostFormat","PostFormatPanel","currentPostFormat","suggestion","select","getEditedPostAttribute","getSuggestedPostFormat","editorStore","coreStore","getThemeSupports","editPost","panelBodyTitle","caption"],"mappings":";;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AAjBA;AACA;AACA;;AAGA;AACA;AACA;;AAMA;AACA;AACA;AAIA,MAAMA,aAAa,GAAG,CAAEC,gBAAF,EAAoBC,mBAApB,KAA6C;AAClE,QAAMC,OAAO,GAAGC,yBAAaC,MAAb,CAAuBC,MAAF,IACpCL,gBADoC,aACpCA,gBADoC,uBACpCA,gBAAgB,CAAEM,QAAlB,CAA4BD,MAAM,CAACE,EAAnC,CADe,CAAhB;;AAGA,SAAOL,OAAO,CAACM,IAAR,CAAgBH,MAAF,IAAcA,MAAM,CAACE,EAAP,KAAcN,mBAA1C,CAAP;AACA,CALD;;AAOA,MAAMQ,oBAAoB,GAAG;AAAA,MAAE;AAC9BR,IAAAA,mBAD8B;AAE9BS,IAAAA,cAF8B;AAG9BC,IAAAA;AAH8B,GAAF;AAAA,SAK5B,4BAAC,kBAAD;AACC,IAAA,OAAO,EAAC,MADT;AAEC,IAAA,OAAO,EAAG,MAAMA,kBAAkB,CAAEV,mBAAF;AAFnC,KAIGS,cAJH,CAL4B;AAAA,CAA7B;;AAae,SAASE,eAAT,GAA2B;AACzC,QAAM;AAAEC,IAAAA,iBAAF;AAAqBC,IAAAA;AAArB,MAAoC,qBAAaC,MAAF,IAAc;AAClE,UAAM;AAAEC,MAAAA,sBAAF;AAA0BC,MAAAA;AAA1B,QACLF,MAAM,CAAEG,YAAF,CADP;AAEA,UAAMlB,gBAAgB,GAAG,iBACxBe,MAAM,CAAEI,eAAF,CAAN,CAAoBC,gBAApB,EADwB,EAExB,CAAE,SAAF,CAFwB,EAGxB,EAHwB,CAAzB;AAKA,WAAO;AACNP,MAAAA,iBAAiB,EAAEG,sBAAsB,CAAE,QAAF,CADnC;AAENF,MAAAA,UAAU,EAAEf,aAAa,CACxBC,gBADwB,EAExBiB,sBAAsB,EAFE;AAFnB,KAAP;AAOA,GAfyC,EAevC,EAfuC,CAA1C;AAiBA,QAAM;AAAEI,IAAAA;AAAF,MAAe,uBAAaH,YAAb,CAArB;;AAEA,QAAMP,kBAAkB,GAAKN,MAAF,IAAcgB,QAAQ,CAAE;AAAEhB,IAAAA;AAAF,GAAF,CAAjD;;AAEA,QAAMiB,cAAc,GAAG,CACtB,cAAI,aAAJ,CADsB,EAEtB;AAAM,IAAA,SAAS,EAAC,iCAAhB;AAAkD,IAAA,GAAG,EAAC;AAAtD,KACG,cAAI,mBAAJ,CADH,CAFsB,CAAvB;;AAOA,MAAK,CAAER,UAAF,IAAgBA,UAAU,CAACP,EAAX,KAAkBM,iBAAvC,EAA2D;AAC1D,WAAO,IAAP;AACA;;AAED,SACC,4BAAC,qBAAD;AAAW,IAAA,WAAW,EAAG,KAAzB;AAAiC,IAAA,KAAK,EAAGS;AAAzC,KACC,uCACG,cACD,+IADC,CADH,CADD,EAMC,uCACC,4BAAC,oBAAD;AACC,IAAA,kBAAkB,EAAGX,kBADtB;AAEC,IAAA,mBAAmB,EAAGG,UAAU,CAACP,EAFlC;AAGC,IAAA,cAAc,EAAG;AAChB;AACA,kBAAI,0BAAJ,CAFgB,EAGhBO,UAAU,CAACS,OAHK;AAHlB,IADD,CAND,CADD;AAoBA","sourcesContent":["/**\n * External dependencies\n */\nimport { get } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { Button, PanelBody } from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { POST_FORMATS } from '../post-format';\nimport { store as editorStore } from '../../store';\n\nconst getSuggestion = ( supportedFormats, suggestedPostFormat ) => {\n\tconst formats = POST_FORMATS.filter( ( format ) =>\n\t\tsupportedFormats?.includes( format.id )\n\t);\n\treturn formats.find( ( format ) => format.id === suggestedPostFormat );\n};\n\nconst PostFormatSuggestion = ( {\n\tsuggestedPostFormat,\n\tsuggestionText,\n\tonUpdatePostFormat,\n} ) => (\n\t<Button\n\t\tvariant=\"link\"\n\t\tonClick={ () => onUpdatePostFormat( suggestedPostFormat ) }\n\t>\n\t\t{ suggestionText }\n\t</Button>\n);\n\nexport default function PostFormatPanel() {\n\tconst { currentPostFormat, suggestion } = useSelect( ( select ) => {\n\t\tconst { getEditedPostAttribute, getSuggestedPostFormat } =\n\t\t\tselect( editorStore );\n\t\tconst supportedFormats = get(\n\t\t\tselect( coreStore ).getThemeSupports(),\n\t\t\t[ 'formats' ],\n\t\t\t[]\n\t\t);\n\t\treturn {\n\t\t\tcurrentPostFormat: getEditedPostAttribute( 'format' ),\n\t\t\tsuggestion: getSuggestion(\n\t\t\t\tsupportedFormats,\n\t\t\t\tgetSuggestedPostFormat()\n\t\t\t),\n\t\t};\n\t}, [] );\n\n\tconst { editPost } = useDispatch( editorStore );\n\n\tconst onUpdatePostFormat = ( format ) => editPost( { format } );\n\n\tconst panelBodyTitle = [\n\t\t__( 'Suggestion:' ),\n\t\t<span className=\"editor-post-publish-panel__link\" key=\"label\">\n\t\t\t{ __( 'Use a post format' ) }\n\t\t</span>,\n\t];\n\n\tif ( ! suggestion || suggestion.id === currentPostFormat ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<PanelBody initialOpen={ false } title={ panelBodyTitle }>\n\t\t\t<p>\n\t\t\t\t{ __(\n\t\t\t\t\t'Your theme uses post formats to highlight different kinds of content, like images or videos. Apply a post format to see this special styling.'\n\t\t\t\t) }\n\t\t\t</p>\n\t\t\t<p>\n\t\t\t\t<PostFormatSuggestion\n\t\t\t\t\tonUpdatePostFormat={ onUpdatePostFormat }\n\t\t\t\t\tsuggestedPostFormat={ suggestion.id }\n\t\t\t\t\tsuggestionText={ sprintf(\n\t\t\t\t\t\t/* translators: %s: post format */\n\t\t\t\t\t\t__( 'Apply the \"%1$s\" format.' ),\n\t\t\t\t\t\tsuggestion.caption\n\t\t\t\t\t) }\n\t\t\t\t/>\n\t\t\t</p>\n\t\t</PanelBody>\n\t);\n}\n"]}
@@ -69,7 +69,7 @@ const DEFAULT_QUERY = {
69
69
  const isSameTermName = (termA, termB) => (0, _terms.unescapeString)(termA).toLowerCase() === (0, _terms.unescapeString)(termB).toLowerCase();
70
70
 
71
71
  const termNamesToIds = (names, terms) => {
72
- return names.map(termName => (0, _lodash.find)(terms, term => isSameTermName(term.name, termName)).id);
72
+ return names.map(termName => terms.find(term => isSameTermName(term.name, termName)).id);
73
73
  }; // Tries to create a term or fetch it if it already exists.
74
74
 
75
75
 
@@ -185,7 +185,7 @@ function FlatTermSelector(_ref) {
185
185
 
186
186
  return acc;
187
187
  }, []);
188
- const newTermNames = uniqueTerms.filter(termName => !(0, _lodash.find)(availableTerms, term => isSameTermName(term.name, termName))); // Optimistically update term values.
188
+ const newTermNames = uniqueTerms.filter(termName => !availableTerms.find(term => isSameTermName(term.name, termName))); // Optimistically update term values.
189
189
  // The selector will always re-fetch terms later.
190
190
 
191
191
  setValues(uniqueTerms);
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/editor/src/components/post-taxonomies/flat-term-selector.js"],"names":["EMPTY_ARRAY","MAX_TERMS_SUGGESTIONS","DEFAULT_QUERY","per_page","orderby","order","_fields","context","isSameTermName","termA","termB","toLowerCase","termNamesToIds","names","terms","map","termName","term","name","id","findOrCreateTerm","restBase","namespace","escapedTermName","path","method","data","catch","error","code","Promise","reject","resolve","term_id","then","unescapeTerm","FlatTermSelector","slug","values","setValues","search","setSearch","debouncedSearch","termIds","taxonomy","hasAssignAction","hasCreateAction","hasResolvedTerms","select","getCurrentPost","getEditedPostAttribute","editorStore","getEntityRecords","getTaxonomy","hasFinishedResolution","coreStore","post","_taxonomy","_termIds","rest_base","query","include","join","length","searchResults","newValues","suggestions","editPost","onUpdateTerms","newTermIds","onChange","termNames","availableTerms","uniqueTerms","reduce","acc","some","n","push","newTermNames","filter","rest_namespace","all","newTerms","newAvailableTerms","concat","appendTerm","newTerm","includes","termAddedMessage","newTermLabel","singularName","termAddedLabel","termRemovedLabel","removeTermLabel","added","removed","remove"],"mappings":";;;;;;;;;;AAUA;;AAPA;;AACA;;AAKA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AAvBA;AACA;AACA;;AAIA;AACA;AACA;;AAUA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,WAAW,GAAG,EAApB;AAEA;AACA;AACA;;AACA,MAAMC,qBAAqB,GAAG,EAA9B;AACA,MAAMC,aAAa,GAAG;AACrBC,EAAAA,QAAQ,EAAEF,qBADW;AAErBG,EAAAA,OAAO,EAAE,OAFY;AAGrBC,EAAAA,KAAK,EAAE,MAHc;AAIrBC,EAAAA,OAAO,EAAE,SAJY;AAKrBC,EAAAA,OAAO,EAAE;AALY,CAAtB;;AAQA,MAAMC,cAAc,GAAG,CAAEC,KAAF,EAASC,KAAT,KACtB,2BAAgBD,KAAhB,EAAwBE,WAAxB,OACA,2BAAgBD,KAAhB,EAAwBC,WAAxB,EAFD;;AAIA,MAAMC,cAAc,GAAG,CAAEC,KAAF,EAASC,KAAT,KAAoB;AAC1C,SAAOD,KAAK,CAACE,GAAN,CACJC,QAAF,IACC,kBAAMF,KAAN,EAAeG,IAAF,IAAYT,cAAc,CAAES,IAAI,CAACC,IAAP,EAAaF,QAAb,CAAvC,EAAiEG,EAF5D,CAAP;AAIA,CALD,C,CAOA;;;AACA,SAASC,gBAAT,CAA2BJ,QAA3B,EAAqCK,QAArC,EAA+CC,SAA/C,EAA2D;AAC1D,QAAMC,eAAe,GAAG,yBAAYP,QAAZ,CAAxB;AAEA,SAAO,uBAAU;AAChBQ,IAAAA,IAAI,EAAG,IAAIF,SAAW,IAAID,QAAU,EADpB;AAEhBI,IAAAA,MAAM,EAAE,MAFQ;AAGhBC,IAAAA,IAAI,EAAE;AAAER,MAAAA,IAAI,EAAEK;AAAR;AAHU,GAAV,EAKLI,KALK,CAKIC,KAAF,I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sourcesContent":["/**\n * External dependencies\n */\nimport { find, get } from 'lodash';\nimport escapeHtml from 'escape-html';\n\n/**\n * WordPress dependencies\n */\nimport { __, _x, sprintf } from '@wordpress/i18n';\nimport { useEffect, useMemo, useState } from '@wordpress/element';\nimport { FormTokenField, withFilters } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useDebounce } from '@wordpress/compose';\nimport apiFetch from '@wordpress/api-fetch';\nimport { speak } from '@wordpress/a11y';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport { unescapeString, unescapeTerm } from '../../utils/terms';\nimport MostUsedTerms from './most-used-terms';\n\n/**\n * Shared reference to an empty array for cases where it is important to avoid\n * returning a new array reference on every invocation.\n *\n * @type {Array<any>}\n */\nconst EMPTY_ARRAY = [];\n\n/**\n * Module constants\n */\nconst MAX_TERMS_SUGGESTIONS = 20;\nconst DEFAULT_QUERY = {\n\tper_page: MAX_TERMS_SUGGESTIONS,\n\torderby: 'count',\n\torder: 'desc',\n\t_fields: 'id,name',\n\tcontext: 'view',\n};\n\nconst isSameTermName = ( termA, termB ) =>\n\tunescapeString( termA ).toLowerCase() ===\n\tunescapeString( termB ).toLowerCase();\n\nconst termNamesToIds = ( names, terms ) => {\n\treturn names.map(\n\t\t( termName ) =>\n\t\t\tfind( terms, ( term ) => isSameTermName( term.name, termName ) ).id\n\t);\n};\n\n// Tries to create a term or fetch it if it already exists.\nfunction findOrCreateTerm( termName, restBase, namespace ) {\n\tconst escapedTermName = escapeHtml( termName );\n\n\treturn apiFetch( {\n\t\tpath: `/${ namespace }/${ restBase }`,\n\t\tmethod: 'POST',\n\t\tdata: { name: escapedTermName },\n\t} )\n\t\t.catch( ( error ) => {\n\t\t\tif ( error.code !== 'term_exists' ) {\n\t\t\t\treturn Promise.reject( error );\n\t\t\t}\n\n\t\t\treturn Promise.resolve( {\n\t\t\t\tid: error.data.term_id,\n\t\t\t\tname: termName,\n\t\t\t} );\n\t\t} )\n\t\t.then( unescapeTerm );\n}\n\nexport function FlatTermSelector( { slug } ) {\n\tconst [ values, setValues ] = useState( [] );\n\tconst [ search, setSearch ] = useState( '' );\n\tconst debouncedSearch = useDebounce( setSearch, 500 );\n\n\tconst {\n\t\tterms,\n\t\ttermIds,\n\t\ttaxonomy,\n\t\thasAssignAction,\n\t\thasCreateAction,\n\t\thasResolvedTerms,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getCurrentPost, getEditedPostAttribute } =\n\t\t\t\tselect( editorStore );\n\t\t\tconst { getEntityRecords, getTaxonomy, hasFinishedResolution } =\n\t\t\t\tselect( coreStore );\n\t\t\tconst post = getCurrentPost();\n\t\t\tconst _taxonomy = getTaxonomy( slug );\n\t\t\tconst _termIds = _taxonomy\n\t\t\t\t? getEditedPostAttribute( _taxonomy.rest_base )\n\t\t\t\t: EMPTY_ARRAY;\n\n\t\t\tconst query = {\n\t\t\t\t...DEFAULT_QUERY,\n\t\t\t\tinclude: _termIds.join( ',' ),\n\t\t\t\tper_page: -1,\n\t\t\t};\n\n\t\t\treturn {\n\t\t\t\thasCreateAction: _taxonomy\n\t\t\t\t\t? get(\n\t\t\t\t\t\t\tpost,\n\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t'_links',\n\t\t\t\t\t\t\t\t'wp:action-create-' + _taxonomy.rest_base,\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\tfalse\n\t\t\t\t\t )\n\t\t\t\t\t: false,\n\t\t\t\thasAssignAction: _taxonomy\n\t\t\t\t\t? get(\n\t\t\t\t\t\t\tpost,\n\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t'_links',\n\t\t\t\t\t\t\t\t'wp:action-assign-' + _taxonomy.rest_base,\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\tfalse\n\t\t\t\t\t )\n\t\t\t\t\t: false,\n\t\t\t\ttaxonomy: _taxonomy,\n\t\t\t\ttermIds: _termIds,\n\t\t\t\tterms: _termIds.length\n\t\t\t\t\t? getEntityRecords( 'taxonomy', slug, query )\n\t\t\t\t\t: EMPTY_ARRAY,\n\t\t\t\thasResolvedTerms: hasFinishedResolution( 'getEntityRecords', [\n\t\t\t\t\t'taxonomy',\n\t\t\t\t\tslug,\n\t\t\t\t\tquery,\n\t\t\t\t] ),\n\t\t\t};\n\t\t},\n\t\t[ slug ]\n\t);\n\n\tconst { searchResults } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecords } = select( coreStore );\n\n\t\t\treturn {\n\t\t\t\tsearchResults: !! search\n\t\t\t\t\t? getEntityRecords( 'taxonomy', slug, {\n\t\t\t\t\t\t\t...DEFAULT_QUERY,\n\t\t\t\t\t\t\tsearch,\n\t\t\t\t\t } )\n\t\t\t\t\t: EMPTY_ARRAY,\n\t\t\t};\n\t\t},\n\t\t[ search ]\n\t);\n\n\t// Update terms state only after the selectors are resolved.\n\t// We're using this to avoid terms temporarily disappearing on slow networks\n\t// while core data makes REST API requests.\n\tuseEffect( () => {\n\t\tif ( hasResolvedTerms ) {\n\t\t\tconst newValues = ( terms ?? [] ).map( ( term ) =>\n\t\t\t\tunescapeString( term.name )\n\t\t\t);\n\n\t\t\tsetValues( newValues );\n\t\t}\n\t}, [ terms, hasResolvedTerms ] );\n\n\tconst suggestions = useMemo( () => {\n\t\treturn ( searchResults ?? [] ).map( ( term ) =>\n\t\t\tunescapeString( term.name )\n\t\t);\n\t}, [ searchResults ] );\n\n\tconst { editPost } = useDispatch( editorStore );\n\n\tif ( ! hasAssignAction ) {\n\t\treturn null;\n\t}\n\n\tfunction onUpdateTerms( newTermIds ) {\n\t\teditPost( { [ taxonomy.rest_base ]: newTermIds } );\n\t}\n\n\tfunction onChange( termNames ) {\n\t\tconst availableTerms = [\n\t\t\t...( terms ?? [] ),\n\t\t\t...( searchResults ?? [] ),\n\t\t];\n\t\tconst uniqueTerms = termNames.reduce( ( acc, name ) => {\n\t\t\tif (\n\t\t\t\t! acc.some( ( n ) => n.toLowerCase() === name.toLowerCase() )\n\t\t\t) {\n\t\t\t\tacc.push( name );\n\t\t\t}\n\t\t\treturn acc;\n\t\t}, [] );\n\n\t\tconst newTermNames = uniqueTerms.filter(\n\t\t\t( termName ) =>\n\t\t\t\t! find( availableTerms, ( term ) =>\n\t\t\t\t\tisSameTermName( term.name, termName )\n\t\t\t\t)\n\t\t);\n\n\t\t// Optimistically update term values.\n\t\t// The selector will always re-fetch terms later.\n\t\tsetValues( uniqueTerms );\n\n\t\tif ( newTermNames.length === 0 ) {\n\t\t\treturn onUpdateTerms(\n\t\t\t\ttermNamesToIds( uniqueTerms, availableTerms )\n\t\t\t);\n\t\t}\n\n\t\tif ( ! hasCreateAction ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst namespace = taxonomy?.rest_namespace ?? 'wp/v2';\n\t\tPromise.all(\n\t\t\tnewTermNames.map( ( termName ) =>\n\t\t\t\tfindOrCreateTerm( termName, taxonomy.rest_base, namespace )\n\t\t\t)\n\t\t).then( ( newTerms ) => {\n\t\t\tconst newAvailableTerms = availableTerms.concat( newTerms );\n\t\t\treturn onUpdateTerms(\n\t\t\t\ttermNamesToIds( uniqueTerms, newAvailableTerms )\n\t\t\t);\n\t\t} );\n\t}\n\n\tfunction appendTerm( newTerm ) {\n\t\tif ( termIds.includes( newTerm.id ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst newTermIds = [ ...termIds, newTerm.id ];\n\t\tconst termAddedMessage = sprintf(\n\t\t\t/* translators: %s: term name. */\n\t\t\t_x( '%s added', 'term' ),\n\t\t\tget(\n\t\t\t\ttaxonomy,\n\t\t\t\t[ 'labels', 'singular_name' ],\n\t\t\t\tslug === 'post_tag' ? __( 'Tag' ) : __( 'Term' )\n\t\t\t)\n\t\t);\n\n\t\tspeak( termAddedMessage, 'assertive' );\n\t\tonUpdateTerms( newTermIds );\n\t}\n\n\tconst newTermLabel = get(\n\t\ttaxonomy,\n\t\t[ 'labels', 'add_new_item' ],\n\t\tslug === 'post_tag' ? __( 'Add new tag' ) : __( 'Add new Term' )\n\t);\n\tconst singularName = get(\n\t\ttaxonomy,\n\t\t[ 'labels', 'singular_name' ],\n\t\tslug === 'post_tag' ? __( 'Tag' ) : __( 'Term' )\n\t);\n\tconst termAddedLabel = sprintf(\n\t\t/* translators: %s: term name. */\n\t\t_x( '%s added', 'term' ),\n\t\tsingularName\n\t);\n\tconst termRemovedLabel = sprintf(\n\t\t/* translators: %s: term name. */\n\t\t_x( '%s removed', 'term' ),\n\t\tsingularName\n\t);\n\tconst removeTermLabel = sprintf(\n\t\t/* translators: %s: term name. */\n\t\t_x( 'Remove %s', 'term' ),\n\t\tsingularName\n\t);\n\n\treturn (\n\t\t<>\n\t\t\t<FormTokenField\n\t\t\t\tvalue={ values }\n\t\t\t\tsuggestions={ suggestions }\n\t\t\t\tonChange={ onChange }\n\t\t\t\tonInputChange={ debouncedSearch }\n\t\t\t\tmaxSuggestions={ MAX_TERMS_SUGGESTIONS }\n\t\t\t\tlabel={ newTermLabel }\n\t\t\t\tmessages={ {\n\t\t\t\t\tadded: termAddedLabel,\n\t\t\t\t\tremoved: termRemovedLabel,\n\t\t\t\t\tremove: removeTermLabel,\n\t\t\t\t} }\n\t\t\t/>\n\t\t\t<MostUsedTerms taxonomy={ taxonomy } onSelect={ appendTerm } />\n\t\t</>\n\t);\n}\n\nexport default withFilters( 'editor.PostTaxonomyType' )( FlatTermSelector );\n"]}
1
+ {"version":3,"sources":["@wordpress/editor/src/components/post-taxonomies/flat-term-selector.js"],"names":["EMPTY_ARRAY","MAX_TERMS_SUGGESTIONS","DEFAULT_QUERY","per_page","orderby","order","_fields","context","isSameTermName","termA","termB","toLowerCase","termNamesToIds","names","terms","map","termName","find","term","name","id","findOrCreateTerm","restBase","namespace","escapedTermName","path","method","data","catch","error","code","Promise","reject","resolve","term_id","then","unescapeTerm","FlatTermSelector","slug","values","setValues","search","setSearch","debouncedSearch","termIds","taxonomy","hasAssignAction","hasCreateAction","hasResolvedTerms","select","getCurrentPost","getEditedPostAttribute","editorStore","getEntityRecords","getTaxonomy","hasFinishedResolution","coreStore","post","_taxonomy","_termIds","rest_base","query","include","join","length","searchResults","newValues","suggestions","editPost","onUpdateTerms","newTermIds","onChange","termNames","availableTerms","uniqueTerms","reduce","acc","some","n","push","newTermNames","filter","rest_namespace","all","newTerms","newAvailableTerms","concat","appendTerm","newTerm","includes","termAddedMessage","newTermLabel","singularName","termAddedLabel","termRemovedLabel","removeTermLabel","added","removed","remove"],"mappings":";;;;;;;;;;AAUA;;AAPA;;AACA;;AAKA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AAvBA;AACA;AACA;;AAIA;AACA;AACA;;AAUA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,WAAW,GAAG,EAApB;AAEA;AACA;AACA;;AACA,MAAMC,qBAAqB,GAAG,EAA9B;AACA,MAAMC,aAAa,GAAG;AACrBC,EAAAA,QAAQ,EAAEF,qBADW;AAErBG,EAAAA,OAAO,EAAE,OAFY;AAGrBC,EAAAA,KAAK,EAAE,MAHc;AAIrBC,EAAAA,OAAO,EAAE,SAJY;AAKrBC,EAAAA,OAAO,EAAE;AALY,CAAtB;;AAQA,MAAMC,cAAc,GAAG,CAAEC,KAAF,EAASC,KAAT,KACtB,2BAAgBD,KAAhB,EAAwBE,WAAxB,OACA,2BAAgBD,KAAhB,EAAwBC,WAAxB,EAFD;;AAIA,MAAMC,cAAc,GAAG,CAAEC,KAAF,EAASC,KAAT,KAAoB;AAC1C,SAAOD,KAAK,CAACE,GAAN,CACJC,QAAF,IACCF,KAAK,CAACG,IAAN,CAAcC,IAAF,IAAYV,cAAc,CAAEU,IAAI,CAACC,IAAP,EAAaH,QAAb,CAAtC,EAAgEI,EAF3D,CAAP;AAIA,CALD,C,CAOA;;;AACA,SAASC,gBAAT,CAA2BL,QAA3B,EAAqCM,QAArC,EAA+CC,SAA/C,EAA2D;AAC1D,QAAM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AA,KAAK,EAAEH,cADG;AAEVI,MAAAA,OAAO,EAAEH,gBAFC;AAGVI,MAAAA,MAAM,EAAEH;AAHE;AAPZ,IADD,EAcC,4BAAC,sBAAD;AAAe,IAAA,QAAQ,EAAGlD,QAA1B;AAAqC,IAAA,QAAQ,EAAG0C;AAAhD,IAdD,CADD;AAkBA;;eAEc,6BAAa,yBAAb,EAA0ClD,gBAA1C,C","sourcesContent":["/**\n * External dependencies\n */\nimport { get } from 'lodash';\nimport escapeHtml from 'escape-html';\n\n/**\n * WordPress dependencies\n */\nimport { __, _x, sprintf } from '@wordpress/i18n';\nimport { useEffect, useMemo, useState } from '@wordpress/element';\nimport { FormTokenField, withFilters } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useDebounce } from '@wordpress/compose';\nimport apiFetch from '@wordpress/api-fetch';\nimport { speak } from '@wordpress/a11y';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport { unescapeString, unescapeTerm } from '../../utils/terms';\nimport MostUsedTerms from './most-used-terms';\n\n/**\n * Shared reference to an empty array for cases where it is important to avoid\n * returning a new array reference on every invocation.\n *\n * @type {Array<any>}\n */\nconst EMPTY_ARRAY = [];\n\n/**\n * Module constants\n */\nconst MAX_TERMS_SUGGESTIONS = 20;\nconst DEFAULT_QUERY = {\n\tper_page: MAX_TERMS_SUGGESTIONS,\n\torderby: 'count',\n\torder: 'desc',\n\t_fields: 'id,name',\n\tcontext: 'view',\n};\n\nconst isSameTermName = ( termA, termB ) =>\n\tunescapeString( termA ).toLowerCase() ===\n\tunescapeString( termB ).toLowerCase();\n\nconst termNamesToIds = ( names, terms ) => {\n\treturn names.map(\n\t\t( termName ) =>\n\t\t\tterms.find( ( term ) => isSameTermName( term.name, termName ) ).id\n\t);\n};\n\n// Tries to create a term or fetch it if it already exists.\nfunction findOrCreateTerm( termName, restBase, namespace ) {\n\tconst escapedTermName = escapeHtml( termName );\n\n\treturn apiFetch( {\n\t\tpath: `/${ namespace }/${ restBase }`,\n\t\tmethod: 'POST',\n\t\tdata: { name: escapedTermName },\n\t} )\n\t\t.catch( ( error ) => {\n\t\t\tif ( error.code !== 'term_exists' ) {\n\t\t\t\treturn Promise.reject( error );\n\t\t\t}\n\n\t\t\treturn Promise.resolve( {\n\t\t\t\tid: error.data.term_id,\n\t\t\t\tname: termName,\n\t\t\t} );\n\t\t} )\n\t\t.then( unescapeTerm );\n}\n\nexport function FlatTermSelector( { slug } ) {\n\tconst [ values, setValues ] = useState( [] );\n\tconst [ search, setSearch ] = useState( '' );\n\tconst debouncedSearch = useDebounce( setSearch, 500 );\n\n\tconst {\n\t\tterms,\n\t\ttermIds,\n\t\ttaxonomy,\n\t\thasAssignAction,\n\t\thasCreateAction,\n\t\thasResolvedTerms,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getCurrentPost, getEditedPostAttribute } =\n\t\t\t\tselect( editorStore );\n\t\t\tconst { getEntityRecords, getTaxonomy, hasFinishedResolution } =\n\t\t\t\tselect( coreStore );\n\t\t\tconst post = getCurrentPost();\n\t\t\tconst _taxonomy = getTaxonomy( slug );\n\t\t\tconst _termIds = _taxonomy\n\t\t\t\t? getEditedPostAttribute( _taxonomy.rest_base )\n\t\t\t\t: EMPTY_ARRAY;\n\n\t\t\tconst query = {\n\t\t\t\t...DEFAULT_QUERY,\n\t\t\t\tinclude: _termIds.join( ',' ),\n\t\t\t\tper_page: -1,\n\t\t\t};\n\n\t\t\treturn {\n\t\t\t\thasCreateAction: _taxonomy\n\t\t\t\t\t? get(\n\t\t\t\t\t\t\tpost,\n\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t'_links',\n\t\t\t\t\t\t\t\t'wp:action-create-' + _taxonomy.rest_base,\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\tfalse\n\t\t\t\t\t )\n\t\t\t\t\t: false,\n\t\t\t\thasAssignAction: _taxonomy\n\t\t\t\t\t? get(\n\t\t\t\t\t\t\tpost,\n\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t'_links',\n\t\t\t\t\t\t\t\t'wp:action-assign-' + _taxonomy.rest_base,\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\tfalse\n\t\t\t\t\t )\n\t\t\t\t\t: false,\n\t\t\t\ttaxonomy: _taxonomy,\n\t\t\t\ttermIds: _termIds,\n\t\t\t\tterms: _termIds.length\n\t\t\t\t\t? getEntityRecords( 'taxonomy', slug, query )\n\t\t\t\t\t: EMPTY_ARRAY,\n\t\t\t\thasResolvedTerms: hasFinishedResolution( 'getEntityRecords', [\n\t\t\t\t\t'taxonomy',\n\t\t\t\t\tslug,\n\t\t\t\t\tquery,\n\t\t\t\t] ),\n\t\t\t};\n\t\t},\n\t\t[ slug ]\n\t);\n\n\tconst { searchResults } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecords } = select( coreStore );\n\n\t\t\treturn {\n\t\t\t\tsearchResults: !! search\n\t\t\t\t\t? getEntityRecords( 'taxonomy', slug, {\n\t\t\t\t\t\t\t...DEFAULT_QUERY,\n\t\t\t\t\t\t\tsearch,\n\t\t\t\t\t } )\n\t\t\t\t\t: EMPTY_ARRAY,\n\t\t\t};\n\t\t},\n\t\t[ search ]\n\t);\n\n\t// Update terms state only after the selectors are resolved.\n\t// We're using this to avoid terms temporarily disappearing on slow networks\n\t// while core data makes REST API requests.\n\tuseEffect( () => {\n\t\tif ( hasResolvedTerms ) {\n\t\t\tconst newValues = ( terms ?? [] ).map( ( term ) =>\n\t\t\t\tunescapeString( term.name )\n\t\t\t);\n\n\t\t\tsetValues( newValues );\n\t\t}\n\t}, [ terms, hasResolvedTerms ] );\n\n\tconst suggestions = useMemo( () => {\n\t\treturn ( searchResults ?? [] ).map( ( term ) =>\n\t\t\tunescapeString( term.name )\n\t\t);\n\t}, [ searchResults ] );\n\n\tconst { editPost } = useDispatch( editorStore );\n\n\tif ( ! hasAssignAction ) {\n\t\treturn null;\n\t}\n\n\tfunction onUpdateTerms( newTermIds ) {\n\t\teditPost( { [ taxonomy.rest_base ]: newTermIds } );\n\t}\n\n\tfunction onChange( termNames ) {\n\t\tconst availableTerms = [\n\t\t\t...( terms ?? [] ),\n\t\t\t...( searchResults ?? [] ),\n\t\t];\n\t\tconst uniqueTerms = termNames.reduce( ( acc, name ) => {\n\t\t\tif (\n\t\t\t\t! acc.some( ( n ) => n.toLowerCase() === name.toLowerCase() )\n\t\t\t) {\n\t\t\t\tacc.push( name );\n\t\t\t}\n\t\t\treturn acc;\n\t\t}, [] );\n\n\t\tconst newTermNames = uniqueTerms.filter(\n\t\t\t( termName ) =>\n\t\t\t\t! availableTerms.find( ( term ) =>\n\t\t\t\t\tisSameTermName( term.name, termName )\n\t\t\t\t)\n\t\t);\n\n\t\t// Optimistically update term values.\n\t\t// The selector will always re-fetch terms later.\n\t\tsetValues( uniqueTerms );\n\n\t\tif ( newTermNames.length === 0 ) {\n\t\t\treturn onUpdateTerms(\n\t\t\t\ttermNamesToIds( uniqueTerms, availableTerms )\n\t\t\t);\n\t\t}\n\n\t\tif ( ! hasCreateAction ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst namespace = taxonomy?.rest_namespace ?? 'wp/v2';\n\t\tPromise.all(\n\t\t\tnewTermNames.map( ( termName ) =>\n\t\t\t\tfindOrCreateTerm( termName, taxonomy.rest_base, namespace )\n\t\t\t)\n\t\t).then( ( newTerms ) => {\n\t\t\tconst newAvailableTerms = availableTerms.concat( newTerms );\n\t\t\treturn onUpdateTerms(\n\t\t\t\ttermNamesToIds( uniqueTerms, newAvailableTerms )\n\t\t\t);\n\t\t} );\n\t}\n\n\tfunction appendTerm( newTerm ) {\n\t\tif ( termIds.includes( newTerm.id ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst newTermIds = [ ...termIds, newTerm.id ];\n\t\tconst termAddedMessage = sprintf(\n\t\t\t/* translators: %s: term name. */\n\t\t\t_x( '%s added', 'term' ),\n\t\t\tget(\n\t\t\t\ttaxonomy,\n\t\t\t\t[ 'labels', 'singular_name' ],\n\t\t\t\tslug === 'post_tag' ? __( 'Tag' ) : __( 'Term' )\n\t\t\t)\n\t\t);\n\n\t\tspeak( termAddedMessage, 'assertive' );\n\t\tonUpdateTerms( newTermIds );\n\t}\n\n\tconst newTermLabel = get(\n\t\ttaxonomy,\n\t\t[ 'labels', 'add_new_item' ],\n\t\tslug === 'post_tag' ? __( 'Add new tag' ) : __( 'Add new Term' )\n\t);\n\tconst singularName = get(\n\t\ttaxonomy,\n\t\t[ 'labels', 'singular_name' ],\n\t\tslug === 'post_tag' ? __( 'Tag' ) : __( 'Term' )\n\t);\n\tconst termAddedLabel = sprintf(\n\t\t/* translators: %s: term name. */\n\t\t_x( '%s added', 'term' ),\n\t\tsingularName\n\t);\n\tconst termRemovedLabel = sprintf(\n\t\t/* translators: %s: term name. */\n\t\t_x( '%s removed', 'term' ),\n\t\tsingularName\n\t);\n\tconst removeTermLabel = sprintf(\n\t\t/* translators: %s: term name. */\n\t\t_x( 'Remove %s', 'term' ),\n\t\tsingularName\n\t);\n\n\treturn (\n\t\t<>\n\t\t\t<FormTokenField\n\t\t\t\tvalue={ values }\n\t\t\t\tsuggestions={ suggestions }\n\t\t\t\tonChange={ onChange }\n\t\t\t\tonInputChange={ debouncedSearch }\n\t\t\t\tmaxSuggestions={ MAX_TERMS_SUGGESTIONS }\n\t\t\t\tlabel={ newTermLabel }\n\t\t\t\tmessages={ {\n\t\t\t\t\tadded: termAddedLabel,\n\t\t\t\t\tremoved: termRemovedLabel,\n\t\t\t\t\tremove: removeTermLabel,\n\t\t\t\t} }\n\t\t\t/>\n\t\t\t<MostUsedTerms taxonomy={ taxonomy } onSelect={ appendTerm } />\n\t\t</>\n\t);\n}\n\nexport default withFilters( 'editor.PostTaxonomyType' )( FlatTermSelector );\n"]}
@@ -109,7 +109,7 @@ function sortBySelected(termsTree, terms) {
109
109
 
110
110
 
111
111
  function findTerm(terms, parent, name) {
112
- return (0, _lodash.find)(terms, term => {
112
+ return terms.find(term => {
113
113
  return (!term.parent && !parent || parseInt(term.parent) === parseInt(parent)) && term.name.toLowerCase() === name.toLowerCase();
114
114
  });
115
115
  }