@wordpress/patterns 1.19.0 → 2.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 (67) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/build/api/index.js +17 -0
  3. package/build/api/index.js.map +1 -1
  4. package/build/components/allow-overrides-modal.js +72 -58
  5. package/build/components/allow-overrides-modal.js.map +1 -1
  6. package/build/components/category-selector.js +2 -2
  7. package/build/components/category-selector.js.map +1 -1
  8. package/build/components/create-pattern-modal.js +56 -48
  9. package/build/components/create-pattern-modal.js.map +1 -1
  10. package/build/components/duplicate-pattern-modal.js +2 -2
  11. package/build/components/duplicate-pattern-modal.js.map +1 -1
  12. package/build/components/index.js +15 -11
  13. package/build/components/index.js.map +1 -1
  14. package/build/components/overrides-panel.js +7 -6
  15. package/build/components/overrides-panel.js.map +1 -1
  16. package/build/components/pattern-convert-button.js +22 -20
  17. package/build/components/pattern-convert-button.js.map +1 -1
  18. package/build/components/pattern-overrides-controls.js +49 -54
  19. package/build/components/pattern-overrides-controls.js.map +1 -1
  20. package/build/components/patterns-manage-button.js +10 -6
  21. package/build/components/patterns-manage-button.js.map +1 -1
  22. package/build/components/rename-pattern-category-modal.js +42 -34
  23. package/build/components/rename-pattern-category-modal.js.map +1 -1
  24. package/build/components/rename-pattern-modal.js +31 -25
  25. package/build/components/rename-pattern-modal.js.map +1 -1
  26. package/build/components/reset-overrides-control.js +12 -8
  27. package/build/components/reset-overrides-control.js.map +1 -1
  28. package/build/private-apis.js +1 -0
  29. package/build/private-apis.js.map +1 -1
  30. package/build/store/actions.js +2 -2
  31. package/build/store/actions.js.map +1 -1
  32. package/build-module/api/index.js +16 -0
  33. package/build-module/api/index.js.map +1 -1
  34. package/build-module/components/allow-overrides-modal.js +73 -58
  35. package/build-module/components/allow-overrides-modal.js.map +1 -1
  36. package/build-module/components/category-selector.js +2 -2
  37. package/build-module/components/category-selector.js.map +1 -1
  38. package/build-module/components/create-pattern-modal.js +59 -50
  39. package/build-module/components/create-pattern-modal.js.map +1 -1
  40. package/build-module/components/duplicate-pattern-modal.js +2 -2
  41. package/build-module/components/duplicate-pattern-modal.js.map +1 -1
  42. package/build-module/components/index.js +17 -11
  43. package/build-module/components/index.js.map +1 -1
  44. package/build-module/components/overrides-panel.js +7 -6
  45. package/build-module/components/overrides-panel.js.map +1 -1
  46. package/build-module/components/pattern-convert-button.js +23 -18
  47. package/build-module/components/pattern-convert-button.js.map +1 -1
  48. package/build-module/components/pattern-overrides-controls.js +52 -55
  49. package/build-module/components/pattern-overrides-controls.js.map +1 -1
  50. package/build-module/components/patterns-manage-button.js +12 -6
  51. package/build-module/components/patterns-manage-button.js.map +1 -1
  52. package/build-module/components/rename-pattern-category-modal.js +43 -34
  53. package/build-module/components/rename-pattern-category-modal.js.map +1 -1
  54. package/build-module/components/rename-pattern-modal.js +32 -25
  55. package/build-module/components/rename-pattern-modal.js.map +1 -1
  56. package/build-module/components/reset-overrides-control.js +12 -8
  57. package/build-module/components/reset-overrides-control.js.map +1 -1
  58. package/build-module/private-apis.js +2 -1
  59. package/build-module/private-apis.js.map +1 -1
  60. package/build-module/store/actions.js +2 -2
  61. package/build-module/store/actions.js.map +1 -1
  62. package/package.json +18 -17
  63. package/src/api/index.js +16 -0
  64. package/src/components/create-pattern-modal.js +16 -5
  65. package/src/components/pattern-overrides-controls.js +19 -44
  66. package/src/private-apis.js +2 -1
  67. package/src/store/actions.js +2 -2
@@ -1 +1 @@
1
- {"version":3,"names":["_blockEditor","require","_patternConvertButton","_interopRequireDefault","_patternsManageButton","PatternsMenuItems","rootClientId","_react","createElement","BlockSettingsMenuControls","selectedClientIds","onClose","Fragment","default","clientIds","closeBlockSettingsMenu","length","clientId"],"sources":["@wordpress/patterns/src/components/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { BlockSettingsMenuControls } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport PatternConvertButton from './pattern-convert-button';\nimport PatternsManageButton from './patterns-manage-button';\n\nexport default function PatternsMenuItems( { rootClientId } ) {\n\treturn (\n\t\t<BlockSettingsMenuControls>\n\t\t\t{ ( { selectedClientIds, onClose } ) => (\n\t\t\t\t<>\n\t\t\t\t\t<PatternConvertButton\n\t\t\t\t\t\tclientIds={ selectedClientIds }\n\t\t\t\t\t\trootClientId={ rootClientId }\n\t\t\t\t\t\tcloseBlockSettingsMenu={ onClose }\n\t\t\t\t\t/>\n\t\t\t\t\t{ selectedClientIds.length === 1 && (\n\t\t\t\t\t\t<PatternsManageButton\n\t\t\t\t\t\t\tclientId={ selectedClientIds[ 0 ] }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</>\n\t\t\t) }\n\t\t</BlockSettingsMenuControls>\n\t);\n}\n"],"mappings":";;;;;;;;AAGA,IAAAA,YAAA,GAAAC,OAAA;AAKA,IAAAC,qBAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,qBAAA,GAAAD,sBAAA,CAAAF,OAAA;AATA;AACA;AACA;;AAGA;AACA;AACA;;AAIe,SAASI,iBAAiBA,CAAE;EAAEC;AAAa,CAAC,EAAG;EAC7D,OACC,IAAAC,MAAA,CAAAC,aAAA,EAACR,YAAA,CAAAS,yBAAyB,QACvB,CAAE;IAAEC,iBAAiB;IAAEC;EAAQ,CAAC,KACjC,IAAAJ,MAAA,CAAAC,aAAA,EAAAD,MAAA,CAAAK,QAAA,QACC,IAAAL,MAAA,CAAAC,aAAA,EAACN,qBAAA,CAAAW,OAAoB;IACpBC,SAAS,EAAGJ,iBAAmB;IAC/BJ,YAAY,EAAGA,YAAc;IAC7BS,sBAAsB,EAAGJ;EAAS,CAClC,CAAC,EACAD,iBAAiB,CAACM,MAAM,KAAK,CAAC,IAC/B,IAAAT,MAAA,CAAAC,aAAA,EAACJ,qBAAA,CAAAS,OAAoB;IACpBI,QAAQ,EAAGP,iBAAiB,CAAE,CAAC;EAAI,CACnC,CAED,CAEuB,CAAC;AAE9B","ignoreList":[]}
1
+ {"version":3,"names":["_blockEditor","require","_patternConvertButton","_interopRequireDefault","_patternsManageButton","_jsxRuntime","PatternsMenuItems","rootClientId","jsx","BlockSettingsMenuControls","children","selectedClientIds","onClose","jsxs","Fragment","default","clientIds","closeBlockSettingsMenu","length","clientId"],"sources":["@wordpress/patterns/src/components/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { BlockSettingsMenuControls } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport PatternConvertButton from './pattern-convert-button';\nimport PatternsManageButton from './patterns-manage-button';\n\nexport default function PatternsMenuItems( { rootClientId } ) {\n\treturn (\n\t\t<BlockSettingsMenuControls>\n\t\t\t{ ( { selectedClientIds, onClose } ) => (\n\t\t\t\t<>\n\t\t\t\t\t<PatternConvertButton\n\t\t\t\t\t\tclientIds={ selectedClientIds }\n\t\t\t\t\t\trootClientId={ rootClientId }\n\t\t\t\t\t\tcloseBlockSettingsMenu={ onClose }\n\t\t\t\t\t/>\n\t\t\t\t\t{ selectedClientIds.length === 1 && (\n\t\t\t\t\t\t<PatternsManageButton\n\t\t\t\t\t\t\tclientId={ selectedClientIds[ 0 ] }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</>\n\t\t\t) }\n\t\t</BlockSettingsMenuControls>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,YAAA,GAAAC,OAAA;AAKA,IAAAC,qBAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,qBAAA,GAAAD,sBAAA,CAAAF,OAAA;AAA4D,IAAAI,WAAA,GAAAJ,OAAA;AAT5D;AACA;AACA;;AAGA;AACA;AACA;;AAIe,SAASK,iBAAiBA,CAAE;EAAEC;AAAa,CAAC,EAAG;EAC7D,oBACC,IAAAF,WAAA,CAAAG,GAAA,EAACR,YAAA,CAAAS,yBAAyB;IAAAC,QAAA,EACvBA,CAAE;MAAEC,iBAAiB;MAAEC;IAAQ,CAAC,kBACjC,IAAAP,WAAA,CAAAQ,IAAA,EAAAR,WAAA,CAAAS,QAAA;MAAAJ,QAAA,gBACC,IAAAL,WAAA,CAAAG,GAAA,EAACN,qBAAA,CAAAa,OAAoB;QACpBC,SAAS,EAAGL,iBAAmB;QAC/BJ,YAAY,EAAGA,YAAc;QAC7BU,sBAAsB,EAAGL;MAAS,CAClC,CAAC,EACAD,iBAAiB,CAACO,MAAM,KAAK,CAAC,iBAC/B,IAAAb,WAAA,CAAAG,GAAA,EAACJ,qBAAA,CAAAW,OAAoB;QACpBI,QAAQ,EAAGR,iBAAiB,CAAE,CAAC;MAAI,CACnC,CACD;IAAA,CACA;EACF,CACyB,CAAC;AAE9B","ignoreList":[]}
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = OverridesPanel;
7
- var _react = require("react");
8
7
  var _blockEditor = require("@wordpress/block-editor");
9
8
  var _components = require("@wordpress/components");
10
9
  var _data = require("@wordpress/data");
@@ -12,6 +11,7 @@ var _element = require("@wordpress/element");
12
11
  var _i18n = require("@wordpress/i18n");
13
12
  var _api = require("../api");
14
13
  var _lockUnlock = require("../lock-unlock");
14
+ var _jsxRuntime = require("react/jsx-runtime");
15
15
  /**
16
16
  * WordPress dependencies
17
17
  */
@@ -35,10 +35,11 @@ function OverridesPanel() {
35
35
  if (!clientIdsWithOverrides?.length) {
36
36
  return null;
37
37
  }
38
- return (0, _react.createElement)(_components.PanelBody, {
39
- title: (0, _i18n.__)('Overrides')
40
- }, (0, _react.createElement)(BlockQuickNavigation, {
41
- clientIds: clientIdsWithOverrides
42
- }));
38
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.PanelBody, {
39
+ title: (0, _i18n.__)('Overrides'),
40
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(BlockQuickNavigation, {
41
+ clientIds: clientIdsWithOverrides
42
+ })
43
+ });
43
44
  }
44
45
  //# sourceMappingURL=overrides-panel.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_blockEditor","require","_components","_data","_element","_i18n","_api","_lockUnlock","BlockQuickNavigation","unlock","blockEditorPrivateApis","OverridesPanel","allClientIds","useSelect","select","blockEditorStore","getClientIdsWithDescendants","getBlock","clientIdsWithOverrides","useMemo","filter","clientId","block","isOverridableBlock","length","_react","createElement","PanelBody","title","__","clientIds"],"sources":["@wordpress/patterns/src/components/overrides-panel.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tprivateApis as blockEditorPrivateApis,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { PanelBody } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { useMemo } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { isOverridableBlock } from '../api';\nimport { unlock } from '../lock-unlock';\n\nconst { BlockQuickNavigation } = unlock( blockEditorPrivateApis );\n\nexport default function OverridesPanel() {\n\tconst allClientIds = useSelect(\n\t\t( select ) => select( blockEditorStore ).getClientIdsWithDescendants(),\n\t\t[]\n\t);\n\tconst { getBlock } = useSelect( blockEditorStore );\n\tconst clientIdsWithOverrides = useMemo(\n\t\t() =>\n\t\t\tallClientIds.filter( ( clientId ) => {\n\t\t\t\tconst block = getBlock( clientId );\n\t\t\t\treturn isOverridableBlock( block );\n\t\t\t} ),\n\t\t[ allClientIds, getBlock ]\n\t);\n\n\tif ( ! clientIdsWithOverrides?.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<PanelBody title={ __( 'Overrides' ) }>\n\t\t\t<BlockQuickNavigation clientIds={ clientIdsWithOverrides } />\n\t\t</PanelBody>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,YAAA,GAAAC,OAAA;AAIA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AAKA,IAAAK,IAAA,GAAAL,OAAA;AACA,IAAAM,WAAA,GAAAN,OAAA;AAhBA;AACA;AACA;;AAUA;AACA;AACA;;AAIA,MAAM;EAAEO;AAAqB,CAAC,GAAG,IAAAC,kBAAM,EAAEC,wBAAuB,CAAC;AAElD,SAASC,cAAcA,CAAA,EAAG;EACxC,MAAMC,YAAY,GAAG,IAAAC,eAAS,EAC3BC,MAAM,IAAMA,MAAM,CAAEC,kBAAiB,CAAC,CAACC,2BAA2B,CAAC,CAAC,EACtE,EACD,CAAC;EACD,MAAM;IAAEC;EAAS,CAAC,GAAG,IAAAJ,eAAS,EAAEE,kBAAiB,CAAC;EAClD,MAAMG,sBAAsB,GAAG,IAAAC,gBAAO,EACrC,MACCP,YAAY,CAACQ,MAAM,CAAIC,QAAQ,IAAM;IACpC,MAAMC,KAAK,GAAGL,QAAQ,CAAEI,QAAS,CAAC;IAClC,OAAO,IAAAE,uBAAkB,EAAED,KAAM,CAAC;EACnC,CAAE,CAAC,EACJ,CAAEV,YAAY,EAAEK,QAAQ,CACzB,CAAC;EAED,IAAK,CAAEC,sBAAsB,EAAEM,MAAM,EAAG;IACvC,OAAO,IAAI;EACZ;EAEA,OACC,IAAAC,MAAA,CAAAC,aAAA,EAACxB,WAAA,CAAAyB,SAAS;IAACC,KAAK,EAAG,IAAAC,QAAE,EAAE,WAAY;EAAG,GACrC,IAAAJ,MAAA,CAAAC,aAAA,EAAClB,oBAAoB;IAACsB,SAAS,EAAGZ;EAAwB,CAAE,CAClD,CAAC;AAEd","ignoreList":[]}
1
+ {"version":3,"names":["_blockEditor","require","_components","_data","_element","_i18n","_api","_lockUnlock","_jsxRuntime","BlockQuickNavigation","unlock","blockEditorPrivateApis","OverridesPanel","allClientIds","useSelect","select","blockEditorStore","getClientIdsWithDescendants","getBlock","clientIdsWithOverrides","useMemo","filter","clientId","block","isOverridableBlock","length","jsx","PanelBody","title","__","children","clientIds"],"sources":["@wordpress/patterns/src/components/overrides-panel.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tprivateApis as blockEditorPrivateApis,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { PanelBody } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { useMemo } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { isOverridableBlock } from '../api';\nimport { unlock } from '../lock-unlock';\n\nconst { BlockQuickNavigation } = unlock( blockEditorPrivateApis );\n\nexport default function OverridesPanel() {\n\tconst allClientIds = useSelect(\n\t\t( select ) => select( blockEditorStore ).getClientIdsWithDescendants(),\n\t\t[]\n\t);\n\tconst { getBlock } = useSelect( blockEditorStore );\n\tconst clientIdsWithOverrides = useMemo(\n\t\t() =>\n\t\t\tallClientIds.filter( ( clientId ) => {\n\t\t\t\tconst block = getBlock( clientId );\n\t\t\t\treturn isOverridableBlock( block );\n\t\t\t} ),\n\t\t[ allClientIds, getBlock ]\n\t);\n\n\tif ( ! clientIdsWithOverrides?.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<PanelBody title={ __( 'Overrides' ) }>\n\t\t\t<BlockQuickNavigation clientIds={ clientIdsWithOverrides } />\n\t\t</PanelBody>\n\t);\n}\n"],"mappings":";;;;;;AAGA,IAAAA,YAAA,GAAAC,OAAA;AAIA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AAKA,IAAAK,IAAA,GAAAL,OAAA;AACA,IAAAM,WAAA,GAAAN,OAAA;AAAwC,IAAAO,WAAA,GAAAP,OAAA;AAhBxC;AACA;AACA;;AAUA;AACA;AACA;;AAIA,MAAM;EAAEQ;AAAqB,CAAC,GAAG,IAAAC,kBAAM,EAAEC,wBAAuB,CAAC;AAElD,SAASC,cAAcA,CAAA,EAAG;EACxC,MAAMC,YAAY,GAAG,IAAAC,eAAS,EAC3BC,MAAM,IAAMA,MAAM,CAAEC,kBAAiB,CAAC,CAACC,2BAA2B,CAAC,CAAC,EACtE,EACD,CAAC;EACD,MAAM;IAAEC;EAAS,CAAC,GAAG,IAAAJ,eAAS,EAAEE,kBAAiB,CAAC;EAClD,MAAMG,sBAAsB,GAAG,IAAAC,gBAAO,EACrC,MACCP,YAAY,CAACQ,MAAM,CAAIC,QAAQ,IAAM;IACpC,MAAMC,KAAK,GAAGL,QAAQ,CAAEI,QAAS,CAAC;IAClC,OAAO,IAAAE,uBAAkB,EAAED,KAAM,CAAC;EACnC,CAAE,CAAC,EACJ,CAAEV,YAAY,EAAEK,QAAQ,CACzB,CAAC;EAED,IAAK,CAAEC,sBAAsB,EAAEM,MAAM,EAAG;IACvC,OAAO,IAAI;EACZ;EAEA,oBACC,IAAAjB,WAAA,CAAAkB,GAAA,EAACxB,WAAA,CAAAyB,SAAS;IAACC,KAAK,EAAG,IAAAC,QAAE,EAAE,WAAY,CAAG;IAAAC,QAAA,eACrC,IAAAtB,WAAA,CAAAkB,GAAA,EAACjB,oBAAoB;MAACsB,SAAS,EAAGZ;IAAwB,CAAE;EAAC,CACnD,CAAC;AAEd","ignoreList":[]}
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.default = PatternConvertButton;
8
- var _react = require("react");
9
8
  var _blocks = require("@wordpress/blocks");
10
9
  var _blockEditor = require("@wordpress/block-editor");
11
10
  var _element = require("@wordpress/element");
@@ -19,6 +18,7 @@ var _store = require("../store");
19
18
  var _createPatternModal = _interopRequireDefault(require("./create-pattern-modal"));
20
19
  var _lockUnlock = require("../lock-unlock");
21
20
  var _constants = require("../constants");
21
+ var _jsxRuntime = require("react/jsx-runtime");
22
22
  /**
23
23
  * WordPress dependencies
24
24
  */
@@ -35,8 +35,7 @@ var _constants = require("../constants");
35
35
  * @param {string} props.rootClientId ID of the currently selected top-level block.
36
36
  * @param {()=>void} props.closeBlockSettingsMenu Callback to close the block settings menu dropdown.
37
37
  * @return {import('react').ComponentType} The menu control or null.
38
- */
39
- function PatternConvertButton({
38
+ */function PatternConvertButton({
40
39
  clientIds,
41
40
  rootClientId,
42
41
  closeBlockSettingsMenu
@@ -109,22 +108,25 @@ function PatternConvertButton({
109
108
  });
110
109
  setIsModalOpen(false);
111
110
  };
112
- return (0, _react.createElement)(_react.Fragment, null, (0, _react.createElement)(_components.MenuItem, {
113
- icon: _icons.symbol,
114
- onClick: () => setIsModalOpen(true),
115
- "aria-expanded": isModalOpen,
116
- "aria-haspopup": "dialog"
117
- }, (0, _i18n.__)('Create pattern')), isModalOpen && (0, _react.createElement)(_createPatternModal.default, {
118
- content: getContent,
119
- onSuccess: pattern => {
120
- handleSuccess(pattern);
121
- },
122
- onError: () => {
123
- setIsModalOpen(false);
124
- },
125
- onClose: () => {
126
- setIsModalOpen(false);
127
- }
128
- }));
111
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
112
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.MenuItem, {
113
+ icon: _icons.symbol,
114
+ onClick: () => setIsModalOpen(true),
115
+ "aria-expanded": isModalOpen,
116
+ "aria-haspopup": "dialog",
117
+ children: (0, _i18n.__)('Create pattern')
118
+ }), isModalOpen && /*#__PURE__*/(0, _jsxRuntime.jsx)(_createPatternModal.default, {
119
+ content: getContent,
120
+ onSuccess: pattern => {
121
+ handleSuccess(pattern);
122
+ },
123
+ onError: () => {
124
+ setIsModalOpen(false);
125
+ },
126
+ onClose: () => {
127
+ setIsModalOpen(false);
128
+ }
129
+ })]
130
+ });
129
131
  }
130
132
  //# sourceMappingURL=pattern-convert-button.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_blocks","require","_blockEditor","_element","_components","_icons","_data","_coreData","_i18n","_notices","_store","_createPatternModal","_interopRequireDefault","_lockUnlock","_constants","PatternConvertButton","clientIds","rootClientId","closeBlockSettingsMenu","createSuccessNotice","useDispatch","noticesStore","replaceBlocks","blockEditorStore","setEditingPattern","unlock","patternsStore","isModalOpen","setIsModalOpen","useState","canConvert","useSelect","select","_getBlocksByClientId","canUser","coreStore","getBlocksByClientId","canInsertBlockType","getBlockRootClientId","rootId","length","undefined","blocks","isReusable","isReusableBlock","getEntityRecord","attributes","ref","_canConvert","every","block","isValid","hasBlockSupport","name","getContent","useCallback","serialize","handleSuccess","pattern","wp_pattern_sync_status","PATTERN_SYNC_TYPES","unsynced","newBlock","createBlock","id","clientId","sprintf","__","title","raw","type","_react","createElement","Fragment","MenuItem","icon","symbol","onClick","default","content","onSuccess","onError","onClose"],"sources":["@wordpress/patterns/src/components/pattern-convert-button.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\thasBlockSupport,\n\tisReusableBlock,\n\tcreateBlock,\n\tserialize,\n} from '@wordpress/blocks';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { useState, useCallback } from '@wordpress/element';\nimport { MenuItem } from '@wordpress/components';\nimport { symbol } from '@wordpress/icons';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\n/**\n * Internal dependencies\n */\nimport { store as patternsStore } from '../store';\nimport CreatePatternModal from './create-pattern-modal';\nimport { unlock } from '../lock-unlock';\nimport { PATTERN_SYNC_TYPES } from '../constants';\n\n/**\n * Menu control to convert block(s) to a pattern block.\n *\n * @param {Object} props Component props.\n * @param {string[]} props.clientIds Client ids of selected blocks.\n * @param {string} props.rootClientId ID of the currently selected top-level block.\n * @param {()=>void} props.closeBlockSettingsMenu Callback to close the block settings menu dropdown.\n * @return {import('react').ComponentType} The menu control or null.\n */\nexport default function PatternConvertButton( {\n\tclientIds,\n\trootClientId,\n\tcloseBlockSettingsMenu,\n} ) {\n\tconst { createSuccessNotice } = useDispatch( noticesStore );\n\tconst { replaceBlocks } = useDispatch( blockEditorStore );\n\t// Ignore reason: false positive of the lint rule.\n\t// eslint-disable-next-line @wordpress/no-unused-vars-before-return\n\tconst { setEditingPattern } = unlock( useDispatch( patternsStore ) );\n\tconst [ isModalOpen, setIsModalOpen ] = useState( false );\n\tconst canConvert = useSelect(\n\t\t( select ) => {\n\t\t\tconst { canUser } = select( coreStore );\n\t\t\tconst {\n\t\t\t\tgetBlocksByClientId,\n\t\t\t\tcanInsertBlockType,\n\t\t\t\tgetBlockRootClientId,\n\t\t\t} = select( blockEditorStore );\n\n\t\t\tconst rootId =\n\t\t\t\trootClientId ||\n\t\t\t\t( clientIds.length > 0\n\t\t\t\t\t? getBlockRootClientId( clientIds[ 0 ] )\n\t\t\t\t\t: undefined );\n\n\t\t\tconst blocks = getBlocksByClientId( clientIds ) ?? [];\n\n\t\t\tconst isReusable =\n\t\t\t\tblocks.length === 1 &&\n\t\t\t\tblocks[ 0 ] &&\n\t\t\t\tisReusableBlock( blocks[ 0 ] ) &&\n\t\t\t\t!! select( coreStore ).getEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\t'wp_block',\n\t\t\t\t\tblocks[ 0 ].attributes.ref\n\t\t\t\t);\n\n\t\t\tconst _canConvert =\n\t\t\t\t// Hide when this is already a synced pattern.\n\t\t\t\t! isReusable &&\n\t\t\t\t// Hide when patterns are disabled.\n\t\t\t\tcanInsertBlockType( 'core/block', rootId ) &&\n\t\t\t\tblocks.every(\n\t\t\t\t\t( block ) =>\n\t\t\t\t\t\t// Guard against the case where a regular block has *just* been converted.\n\t\t\t\t\t\t!! block &&\n\t\t\t\t\t\t// Hide on invalid blocks.\n\t\t\t\t\t\tblock.isValid &&\n\t\t\t\t\t\t// Hide when block doesn't support being made into a pattern.\n\t\t\t\t\t\thasBlockSupport( block.name, 'reusable', true )\n\t\t\t\t) &&\n\t\t\t\t// Hide when current doesn't have permission to do that.\n\t\t\t\t!! canUser( 'create', 'blocks' );\n\n\t\t\treturn _canConvert;\n\t\t},\n\t\t[ clientIds, rootClientId ]\n\t);\n\tconst { getBlocksByClientId } = useSelect( blockEditorStore );\n\tconst getContent = useCallback(\n\t\t() => serialize( getBlocksByClientId( clientIds ) ),\n\t\t[ getBlocksByClientId, clientIds ]\n\t);\n\n\tif ( ! canConvert ) {\n\t\treturn null;\n\t}\n\n\tconst handleSuccess = ( { pattern } ) => {\n\t\tif ( pattern.wp_pattern_sync_status !== PATTERN_SYNC_TYPES.unsynced ) {\n\t\t\tconst newBlock = createBlock( 'core/block', {\n\t\t\t\tref: pattern.id,\n\t\t\t} );\n\n\t\t\treplaceBlocks( clientIds, newBlock );\n\t\t\tsetEditingPattern( newBlock.clientId, true );\n\t\t\tcloseBlockSettingsMenu();\n\t\t}\n\n\t\tcreateSuccessNotice(\n\t\t\tpattern.wp_pattern_sync_status === PATTERN_SYNC_TYPES.unsynced\n\t\t\t\t? sprintf(\n\t\t\t\t\t\t// translators: %s: the name the user has given to the pattern.\n\t\t\t\t\t\t__( 'Unsynced pattern created: %s' ),\n\t\t\t\t\t\tpattern.title.raw\n\t\t\t\t )\n\t\t\t\t: sprintf(\n\t\t\t\t\t\t// translators: %s: the name the user has given to the pattern.\n\t\t\t\t\t\t__( 'Synced pattern created: %s' ),\n\t\t\t\t\t\tpattern.title.raw\n\t\t\t\t ),\n\t\t\t{\n\t\t\t\ttype: 'snackbar',\n\t\t\t\tid: 'convert-to-pattern-success',\n\t\t\t}\n\t\t);\n\t\tsetIsModalOpen( false );\n\t};\n\treturn (\n\t\t<>\n\t\t\t<MenuItem\n\t\t\t\ticon={ symbol }\n\t\t\t\tonClick={ () => setIsModalOpen( true ) }\n\t\t\t\taria-expanded={ isModalOpen }\n\t\t\t\taria-haspopup=\"dialog\"\n\t\t\t>\n\t\t\t\t{ __( 'Create pattern' ) }\n\t\t\t</MenuItem>\n\t\t\t{ isModalOpen && (\n\t\t\t\t<CreatePatternModal\n\t\t\t\t\tcontent={ getContent }\n\t\t\t\t\tonSuccess={ ( pattern ) => {\n\t\t\t\t\t\thandleSuccess( pattern );\n\t\t\t\t\t} }\n\t\t\t\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ACZ,IAAA4C,MAAA,CAAAC,aAAA,EAAC7D,mBAAA,CAAAmE,OAAkB;IAClBC,OAAO,EAAGzB,UAAY;IACtB0B,SAAS,EAAKtB,OAAO,IAAM;MAC1BD,aAAa,CAAEC,OAAQ,CAAC;IACzB,CAAG;IACHuB,OAAO,EAAGA,CAAA,KAAM;MACfrD,cAAc,CAAE,KAAM,CAAC;IACxB,CAAG;IACHsD,OAAO,EAAGA,CAAA,KAAM;MACftD,cAAc,CAAE,KAAM,CAAC;IACxB;EAAG,CACH,CAED,CAAC;AAEL","ignoreList":[]}
1
+ {"version":3,"names":["_blocks","require","_blockEditor","_element","_components","_icons","_data","_coreData","_i18n","_notices","_store","_createPatternModal","_interopRequireDefault","_lockUnlock","_constants","_jsxRuntime","PatternConvertButton","clientIds","rootClientId","closeBlockSettingsMenu","createSuccessNotice","useDispatch","noticesStore","replaceBlocks","blockEditorStore","setEditingPattern","unlock","patternsStore","isModalOpen","setIsModalOpen","useState","canConvert","useSelect","select","_getBlocksByClientId","canUser","coreStore","getBlocksByClientId","canInsertBlockType","getBlockRootClientId","rootId","length","undefined","blocks","isReusable","isReusableBlock","getEntityRecord","attributes","ref","_canConvert","every","block","isValid","hasBlockSupport","name","getContent","useCallback","serialize","handleSuccess","pattern","wp_pattern_sync_status","PATTERN_SYNC_TYPES","unsynced","newBlock","createBlock","id","clientId","sprintf","__","title","raw","type","jsxs","Fragment","children","jsx","MenuItem","icon","symbol","onClick","default","content","onSuccess","onError","onClose"],"sources":["@wordpress/patterns/src/components/pattern-convert-button.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\thasBlockSupport,\n\tisReusableBlock,\n\tcreateBlock,\n\tserialize,\n} from '@wordpress/blocks';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { useState, useCallback } from '@wordpress/element';\nimport { MenuItem } from '@wordpress/components';\nimport { symbol } from '@wordpress/icons';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\n/**\n * Internal dependencies\n */\nimport { store as patternsStore } from '../store';\nimport CreatePatternModal from './create-pattern-modal';\nimport { unlock } from '../lock-unlock';\nimport { PATTERN_SYNC_TYPES } from '../constants';\n\n/**\n * Menu control to convert block(s) to a pattern block.\n *\n * @param {Object} props Component props.\n * @param {string[]} props.clientIds Client ids of selected blocks.\n * @param {string} props.rootClientId ID of the currently selected top-level block.\n * @param {()=>void} props.closeBlockSettingsMenu Callback to close the block settings menu dropdown.\n * @return {import('react').ComponentType} The menu control or null.\n */\nexport default function PatternConvertButton( {\n\tclientIds,\n\trootClientId,\n\tcloseBlockSettingsMenu,\n} ) {\n\tconst { createSuccessNotice } = useDispatch( noticesStore );\n\tconst { replaceBlocks } = useDispatch( blockEditorStore );\n\t// Ignore reason: false positive of the lint rule.\n\t// eslint-disable-next-line @wordpress/no-unused-vars-before-return\n\tconst { setEditingPattern } = unlock( useDispatch( patternsStore ) );\n\tconst [ isModalOpen, setIsModalOpen ] = useState( false );\n\tconst canConvert = useSelect(\n\t\t( select ) => {\n\t\t\tconst { canUser } = select( coreStore );\n\t\t\tconst {\n\t\t\t\tgetBlocksByClientId,\n\t\t\t\tcanInsertBlockType,\n\t\t\t\tgetBlockRootClientId,\n\t\t\t} = select( blockEditorStore );\n\n\t\t\tconst rootId =\n\t\t\t\trootClientId ||\n\t\t\t\t( clientIds.length > 0\n\t\t\t\t\t? getBlockRootClientId( clientIds[ 0 ] )\n\t\t\t\t\t: undefined );\n\n\t\t\tconst blocks = getBlocksByClientId( clientIds ) ?? [];\n\n\t\t\tconst isReusable =\n\t\t\t\tblocks.length === 1 &&\n\t\t\t\tblocks[ 0 ] &&\n\t\t\t\tisReusableBlock( blocks[ 0 ] ) &&\n\t\t\t\t!! select( coreStore ).getEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\t'wp_block',\n\t\t\t\t\tblocks[ 0 ].attributes.ref\n\t\t\t\t);\n\n\t\t\tconst _canConvert =\n\t\t\t\t// Hide when this is already a synced pattern.\n\t\t\t\t! isReusable &&\n\t\t\t\t// Hide when patterns are disabled.\n\t\t\t\tcanInsertBlockType( 'core/block', rootId ) &&\n\t\t\t\tblocks.every(\n\t\t\t\t\t( block ) =>\n\t\t\t\t\t\t// Guard against the case where a regular block has *just* been converted.\n\t\t\t\t\t\t!! block &&\n\t\t\t\t\t\t// Hide on invalid blocks.\n\t\t\t\t\t\tblock.isValid &&\n\t\t\t\t\t\t// Hide when block doesn't support being made into a pattern.\n\t\t\t\t\t\thasBlockSupport( block.name, 'reusable', true )\n\t\t\t\t) &&\n\t\t\t\t// Hide when current doesn't have permission to do that.\n\t\t\t\t!! canUser( 'create', 'blocks' );\n\n\t\t\treturn _canConvert;\n\t\t},\n\t\t[ clientIds, rootClientId ]\n\t);\n\tconst { getBlocksByClientId } = useSelect( blockEditorStore );\n\tconst getContent = useCallback(\n\t\t() => serialize( getBlocksByClientId( clientIds ) ),\n\t\t[ getBlocksByClientId, clientIds ]\n\t);\n\n\tif ( ! canConvert ) {\n\t\treturn null;\n\t}\n\n\tconst handleSuccess = ( { pattern } ) => {\n\t\tif ( pattern.wp_pattern_sync_status !== PATTERN_SYNC_TYPES.unsynced ) {\n\t\t\tconst newBlock = createBlock( 'core/block', {\n\t\t\t\tref: pattern.id,\n\t\t\t} );\n\n\t\t\treplaceBlocks( clientIds, newBlock );\n\t\t\tsetEditingPattern( newBlock.clientId, true );\n\t\t\tcloseBlockSettingsMenu();\n\t\t}\n\n\t\tcreateSuccessNotice(\n\t\t\tpattern.wp_pattern_sync_status === PATTERN_SYNC_TYPES.unsynced\n\t\t\t\t? sprintf(\n\t\t\t\t\t\t// translators: %s: the name the user has given to the pattern.\n\t\t\t\t\t\t__( 'Unsynced pattern created: %s' ),\n\t\t\t\t\t\tpattern.title.raw\n\t\t\t\t )\n\t\t\t\t: sprintf(\n\t\t\t\t\t\t// translators: %s: the name the user has given to the pattern.\n\t\t\t\t\t\t__( 'Synced pattern created: %s' ),\n\t\t\t\t\t\tpattern.title.raw\n\t\t\t\t ),\n\t\t\t{\n\t\t\t\ttype: 'snackbar',\n\t\t\t\tid: 'convert-to-pattern-success',\n\t\t\t}\n\t\t);\n\t\tsetIsModalOpen( false );\n\t};\n\treturn (\n\t\t<>\n\t\t\t<MenuItem\n\t\t\t\ticon={ symbol }\n\t\t\t\tonClick={ () => setIsModalOpen( true ) }\n\t\t\t\taria-expanded={ isModalOpen }\n\t\t\t\taria-haspopup=\"dialog\"\n\t\t\t>\n\t\t\t\t{ __( 'Create pattern' ) }\n\t\t\t</MenuItem>\n\t\t\t{ isModalOpen && (\n\t\t\t\t<CreatePatternModal\n\t\t\t\t\tcontent={ getContent }\n\t\t\t\t\tonSuccess={ ( pattern ) => {\n\t\t\t\t\t\thandleSuccess( pattern );\n\t\t\t\t\t} }\n\t\t\t\t\tonError={ () => {\n\t\t\t\t\t\tsetIsModalOpen( false );\n\t\t\t\t\t} }\n\t\t\t\t\tonClose={ () => {\n\t\t\t\t\t\tsetIsModalOpen( false );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,OAAA,GAAAC,OAAA;AAMA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AACA,IAAAM,SAAA,GAAAN,OAAA;AACA,IAAAO,KAAA,GAAAP,OAAA;AACA,IAAAQ,QAAA,GAAAR,OAAA;AAIA,IAAAS,MAAA,GAAAT,OAAA;AACA,IAAAU,mBAAA,GAAAC,sBAAA,CAAAX,OAAA;AACA,IAAAY,WAAA,GAAAZ,OAAA;AACA,IAAAa,UAAA,GAAAb,OAAA;AAAkD,IAAAc,WAAA,GAAAd,OAAA;AAvBlD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AAC,QAAE,EAAE,8BAA+B,CAAC,EACpCT,OAAO,CAACU,KAAK,CAACC,GACd,CAAC,GACD,IAAAH,aAAO;IACP;IACA,IAAAC,QAAE,EAAE,4BAA6B,CAAC,EAClCT,OAAO,CAACU,KAAK,CAACC,GACd,CAAC,EACJ;MACCC,IAAI,EAAE,UAAU;MAChBN,EAAE,EAAE;IACL,CACD,CAAC;IACDpC,cAAc,CAAE,KAAM,CAAC;EACxB,CAAC;EACD,oBACC,IAAAd,WAAA,CAAAyD,IAAA,EAAAzD,WAAA,CAAA0D,QAAA;IAAAC,QAAA,gBACC,IAAA3D,WAAA,CAAA4D,GAAA,EAACvE,WAAA,CAAAwE,QAAQ;MACRC,IAAI,EAAGC,aAAQ;MACfC,OAAO,EAAGA,CAAA,KAAMlD,cAAc,CAAE,IAAK,CAAG;MACxC,iBAAgBD,WAAa;MAC7B,iBAAc,QAAQ;MAAA8C,QAAA,EAEpB,IAAAN,QAAE,EAAE,gBAAiB;IAAC,CACf,CAAC,EACTxC,WAAW,iBACZ,IAAAb,WAAA,CAAA4D,GAAA,EAAChE,mBAAA,CAAAqE,OAAkB;MAClBC,OAAO,EAAG1B,UAAY;MACtB2B,SAAS,EAAKvB,OAAO,IAAM;QAC1BD,aAAa,CAAEC,OAAQ,CAAC;MACzB,CAAG;MACHwB,OAAO,EAAGA,CAAA,KAAM;QACftD,cAAc,CAAE,KAAM,CAAC;MACxB,CAAG;MACHuD,OAAO,EAAGA,CAAA,KAAM;QACfvD,cAAc,CAAE,KAAM,CAAC;MACxB;IAAG,CACH,CACD;EAAA,CACA,CAAC;AAEL","ignoreList":[]}
@@ -4,13 +4,13 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
- var _react = require("react");
8
7
  var _element = require("@wordpress/element");
9
8
  var _blockEditor = require("@wordpress/block-editor");
10
9
  var _components = require("@wordpress/components");
11
10
  var _i18n = require("@wordpress/i18n");
12
11
  var _constants = require("../constants");
13
12
  var _allowOverridesModal = require("./allow-overrides-modal");
13
+ var _jsxRuntime = require("react/jsx-runtime");
14
14
  /**
15
15
  * WordPress dependencies
16
16
  */
@@ -19,46 +19,38 @@ var _allowOverridesModal = require("./allow-overrides-modal");
19
19
  * Internal dependencies
20
20
  */
21
21
 
22
- function removeBindings(bindings, syncedAttributes) {
23
- let updatedBindings = {};
24
- for (const attributeName of syncedAttributes) {
25
- // Omit any bindings that's not the same source from the `updatedBindings` object.
26
- if (bindings?.[attributeName]?.source !== _constants.PATTERN_OVERRIDES_BINDING_SOURCE && bindings?.[attributeName]?.source !== undefined) {
27
- updatedBindings[attributeName] = bindings[attributeName];
28
- }
29
- }
22
+ function removeBindings(bindings) {
23
+ let updatedBindings = {
24
+ ...bindings
25
+ };
26
+ delete updatedBindings.__default;
30
27
  if (!Object.keys(updatedBindings).length) {
31
28
  updatedBindings = undefined;
32
29
  }
33
30
  return updatedBindings;
34
31
  }
35
- function addBindings(bindings, syncedAttributes) {
36
- const updatedBindings = {
37
- ...bindings
38
- };
39
- for (const attributeName of syncedAttributes) {
40
- if (!bindings?.[attributeName]) {
41
- updatedBindings[attributeName] = {
42
- source: _constants.PATTERN_OVERRIDES_BINDING_SOURCE
43
- };
32
+ function addBindings(bindings) {
33
+ return {
34
+ ...bindings,
35
+ __default: {
36
+ source: _constants.PATTERN_OVERRIDES_BINDING_SOURCE
44
37
  }
45
- }
46
- return updatedBindings;
38
+ };
47
39
  }
48
40
  function PatternOverridesControls({
49
41
  attributes,
50
- name,
51
42
  setAttributes
52
43
  }) {
53
44
  const controlId = (0, _element.useId)();
54
45
  const [showAllowOverridesModal, setShowAllowOverridesModal] = (0, _element.useState)(false);
55
46
  const [showDisallowOverridesModal, setShowDisallowOverridesModal] = (0, _element.useState)(false);
56
- const syncedAttributes = _constants.PARTIAL_SYNCING_SUPPORTED_BLOCKS[name];
57
- const attributeSources = syncedAttributes.map(attributeName => attributes.metadata?.bindings?.[attributeName]?.source);
58
- const isConnectedToOtherSources = attributeSources.every(source => source && source !== 'core/pattern-overrides');
47
+ const hasName = !!attributes.metadata?.name;
48
+ const defaultBindings = attributes.metadata?.bindings?.__default;
49
+ const allowOverrides = hasName && defaultBindings?.source === _constants.PATTERN_OVERRIDES_BINDING_SOURCE;
50
+ const isConnectedToOtherSources = defaultBindings?.source && defaultBindings.source !== _constants.PATTERN_OVERRIDES_BINDING_SOURCE;
59
51
  function updateBindings(isChecked, customName) {
60
52
  const prevBindings = attributes?.metadata?.bindings;
61
- const updatedBindings = isChecked ? addBindings(prevBindings, syncedAttributes) : removeBindings(prevBindings, syncedAttributes);
53
+ const updatedBindings = isChecked ? addBindings(prevBindings) : removeBindings(prevBindings);
62
54
  const updatedMetadata = {
63
55
  ...attributes.metadata,
64
56
  bindings: updatedBindings
@@ -75,36 +67,39 @@ function PatternOverridesControls({
75
67
  if (isConnectedToOtherSources) {
76
68
  return null;
77
69
  }
78
- const hasName = !!attributes.metadata?.name;
79
- const allowOverrides = hasName && attributeSources.some(source => source === _constants.PATTERN_OVERRIDES_BINDING_SOURCE);
80
- return (0, _react.createElement)(_react.Fragment, null, (0, _react.createElement)(_blockEditor.InspectorControls, {
81
- group: "advanced"
82
- }, (0, _react.createElement)(_components.BaseControl, {
83
- id: controlId,
84
- label: (0, _i18n.__)('Overrides'),
85
- help: (0, _i18n.__)('Allow changes to this block throughout instances of this pattern.')
86
- }, (0, _react.createElement)(_components.Button, {
87
- __next40pxDefaultSize: true,
88
- className: "pattern-overrides-control__allow-overrides-button",
89
- variant: "secondary",
90
- "aria-haspopup": "dialog",
91
- onClick: () => {
92
- if (allowOverrides) {
93
- setShowDisallowOverridesModal(true);
94
- } else {
95
- setShowAllowOverridesModal(true);
70
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
71
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_blockEditor.InspectorControls, {
72
+ group: "advanced",
73
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.BaseControl, {
74
+ id: controlId,
75
+ label: (0, _i18n.__)('Overrides'),
76
+ help: (0, _i18n.__)('Allow changes to this block throughout instances of this pattern.'),
77
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button, {
78
+ __next40pxDefaultSize: true,
79
+ className: "pattern-overrides-control__allow-overrides-button",
80
+ variant: "secondary",
81
+ "aria-haspopup": "dialog",
82
+ onClick: () => {
83
+ if (allowOverrides) {
84
+ setShowDisallowOverridesModal(true);
85
+ } else {
86
+ setShowAllowOverridesModal(true);
87
+ }
88
+ },
89
+ children: allowOverrides ? (0, _i18n.__)('Disable overrides') : (0, _i18n.__)('Enable overrides')
90
+ })
91
+ })
92
+ }), showAllowOverridesModal && /*#__PURE__*/(0, _jsxRuntime.jsx)(_allowOverridesModal.AllowOverridesModal, {
93
+ initialName: attributes.metadata?.name,
94
+ onClose: () => setShowAllowOverridesModal(false),
95
+ onSave: newName => {
96
+ updateBindings(true, newName);
96
97
  }
97
- }
98
- }, allowOverrides ? (0, _i18n.__)('Disable overrides') : (0, _i18n.__)('Enable overrides')))), showAllowOverridesModal && (0, _react.createElement)(_allowOverridesModal.AllowOverridesModal, {
99
- initialName: attributes.metadata?.name,
100
- onClose: () => setShowAllowOverridesModal(false),
101
- onSave: newName => {
102
- updateBindings(true, newName);
103
- }
104
- }), showDisallowOverridesModal && (0, _react.createElement)(_allowOverridesModal.DisallowOverridesModal, {
105
- onClose: () => setShowDisallowOverridesModal(false),
106
- onSave: () => updateBindings(false)
107
- }));
98
+ }), showDisallowOverridesModal && /*#__PURE__*/(0, _jsxRuntime.jsx)(_allowOverridesModal.DisallowOverridesModal, {
99
+ onClose: () => setShowDisallowOverridesModal(false),
100
+ onSave: () => updateBindings(false)
101
+ })]
102
+ });
108
103
  }
109
104
  var _default = exports.default = PatternOverridesControls;
110
105
  //# sourceMappingURL=pattern-overrides-controls.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_element","require","_blockEditor","_components","_i18n","_constants","_allowOverridesModal","removeBindings","bindings","syncedAttributes","updatedBindings","attributeName","source","PATTERN_OVERRIDES_BINDING_SOURCE","undefined","Object","keys","length","addBindings","PatternOverridesControls","attributes","name","setAttributes","controlId","useId","showAllowOverridesModal","setShowAllowOverridesModal","useState","showDisallowOverridesModal","setShowDisallowOverridesModal","PARTIAL_SYNCING_SUPPORTED_BLOCKS","attributeSources","map","metadata","isConnectedToOtherSources","every","updateBindings","isChecked","customName","prevBindings","updatedMetadata","hasName","allowOverrides","some","_react","createElement","Fragment","InspectorControls","group","BaseControl","id","label","__","help","Button","__next40pxDefaultSize","className","variant","onClick","AllowOverridesModal","initialName","onClose","onSave","newName","DisallowOverridesModal","_default","exports","default"],"sources":["@wordpress/patterns/src/components/pattern-overrides-controls.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useState, useId } from '@wordpress/element';\nimport { InspectorControls } from '@wordpress/block-editor';\nimport { BaseControl, Button } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport {\n\tPARTIAL_SYNCING_SUPPORTED_BLOCKS,\n\tPATTERN_OVERRIDES_BINDING_SOURCE,\n} from '../constants';\nimport {\n\tAllowOverridesModal,\n\tDisallowOverridesModal,\n} from './allow-overrides-modal';\n\nfunction removeBindings( bindings, syncedAttributes ) {\n\tlet updatedBindings = {};\n\tfor ( const attributeName of syncedAttributes ) {\n\t\t// Omit any bindings that's not the same source from the `updatedBindings` object.\n\t\tif (\n\t\t\tbindings?.[ attributeName ]?.source !==\n\t\t\t\tPATTERN_OVERRIDES_BINDING_SOURCE &&\n\t\t\tbindings?.[ attributeName ]?.source !== undefined\n\t\t) {\n\t\t\tupdatedBindings[ attributeName ] = bindings[ attributeName ];\n\t\t}\n\t}\n\tif ( ! Object.keys( updatedBindings ).length ) {\n\t\tupdatedBindings = undefined;\n\t}\n\treturn updatedBindings;\n}\n\nfunction addBindings( bindings, syncedAttributes ) {\n\tconst updatedBindings = { ...bindings };\n\tfor ( const attributeName of syncedAttributes ) {\n\t\tif ( ! bindings?.[ attributeName ] ) {\n\t\t\tupdatedBindings[ attributeName ] = {\n\t\t\t\tsource: PATTERN_OVERRIDES_BINDING_SOURCE,\n\t\t\t};\n\t\t}\n\t}\n\treturn updatedBindings;\n}\n\nfunction PatternOverridesControls( { attributes, name, setAttributes } ) {\n\tconst controlId = useId();\n\tconst [ showAllowOverridesModal, setShowAllowOverridesModal ] =\n\t\tuseState( false );\n\tconst [ showDisallowOverridesModal, setShowDisallowOverridesModal ] =\n\t\tuseState( false );\n\n\tconst syncedAttributes = PARTIAL_SYNCING_SUPPORTED_BLOCKS[ name ];\n\tconst attributeSources = syncedAttributes.map(\n\t\t( attributeName ) =>\n\t\t\tattributes.metadata?.bindings?.[ attributeName ]?.source\n\t);\n\tconst isConnectedToOtherSources = attributeSources.every(\n\t\t( source ) => source && source !== 'core/pattern-overrides'\n\t);\n\n\tfunction updateBindings( isChecked, customName ) {\n\t\tconst prevBindings = attributes?.metadata?.bindings;\n\t\tconst updatedBindings = isChecked\n\t\t\t? addBindings( prevBindings, syncedAttributes )\n\t\t\t: removeBindings( prevBindings, syncedAttributes );\n\n\t\tconst updatedMetadata = {\n\t\t\t...attributes.metadata,\n\t\t\tbindings: updatedBindings,\n\t\t};\n\n\t\tif ( customName ) {\n\t\t\tupdatedMetadata.name = customName;\n\t\t}\n\n\t\tsetAttributes( {\n\t\t\tmetadata: updatedMetadata,\n\t\t} );\n\t}\n\n\t// Avoid overwriting other (e.g. meta) bindings.\n\tif ( isConnectedToOtherSources ) {\n\t\treturn null;\n\t}\n\n\tconst hasName = !! attributes.metadata?.name;\n\tconst allowOverrides =\n\t\thasName &&\n\t\tattributeSources.some(\n\t\t\t( source ) => source === PATTERN_OVERRIDES_BINDING_SOURCE\n\t\t);\n\n\treturn (\n\t\t<>\n\t\t\t<InspectorControls group=\"advanced\">\n\t\t\t\t<BaseControl\n\t\t\t\t\tid={ controlId }\n\t\t\t\t\tlabel={ __( 'Overrides' ) }\n\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t'Allow changes to this block throughout instances of this pattern.'\n\t\t\t\t\t) }\n\t\t\t\t>\n\t\t\t\t\t<Button\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tclassName=\"pattern-overrides-control__allow-overrides-button\"\n\t\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\t\taria-haspopup=\"dialog\"\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tif ( allowOverrides ) {\n\t\t\t\t\t\t\t\tsetShowDisallowOverridesModal( true );\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tsetShowAllowOverridesModal( true );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ allowOverrides\n\t\t\t\t\t\t\t? __( 'Disable overrides' )\n\t\t\t\t\t\t\t: __( 'Enable overrides' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t</BaseControl>\n\t\t\t</InspectorControls>\n\n\t\t\t{ showAllowOverridesModal && (\n\t\t\t\t<AllowOverridesModal\n\t\t\t\t\tinitialName={ attributes.metadata?.name }\n\t\t\t\t\tonClose={ () => setShowAllowOverridesModal( false ) }\n\t\t\t\t\tonSave={ ( newName ) => {\n\t\t\t\t\t\tupdateBindings( true, newName );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ showDisallowOverridesModal && (\n\t\t\t\t<DisallowOverridesModal\n\t\t\t\t\tonClose={ () => setShowDisallowOverridesModal( false ) }\n\t\t\t\t\tonSave={ () => updateBindings( false ) }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport default PatternOverridesControls;\n"],"mappings":";;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AAKA,IAAAI,UA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G3B,SAAW;IAChB4B,KAAK,EAAG,IAAAC,QAAE,EAAE,WAAY,CAAG;IAC3BC,IAAI,EAAG,IAAAD,QAAE,EACR,mEACD;EAAG,GAEH,IAAAR,MAAA,CAAAC,aAAA,EAAC1C,WAAA,CAAAmD,MAAM;IACNC,qBAAqB;IACrBC,SAAS,EAAC,mDAAmD;IAC7DC,OAAO,EAAC,WAAW;IACnB,iBAAc,QAAQ;IACtBC,OAAO,EAAGA,CAAA,KAAM;MACf,IAAKhB,cAAc,EAAG;QACrBb,6BAA6B,CAAE,IAAK,CAAC;MACtC,CAAC,MAAM;QACNH,0BAA0B,CAAE,IAAK,CAAC;MACnC;IACD;EAAG,GAEDgB,cAAc,GACb,IAAAU,QAAE,EAAE,mBAAoB,CAAC,GACzB,IAAAA,QAAE,EAAE,kBAAmB,CACnB,CACI,CACK,CAAC,EAElB3B,uBAAuB,IACxB,IAAAmB,MAAA,CAAAC,aAAA,EAACvC,oBAAA,CAAAqD,mBAAmB;IACnBC,WAAW,EAAGxC,UAAU,CAACa,QAAQ,EAAEZ,IAAM;IACzCwC,OAAO,EAAGA,CAAA,KAAMnC,0BAA0B,CAAE,KAAM,CAAG;IACrDoC,MAAM,EAAKC,OAAO,IAAM;MACvB3B,cAAc,CAAE,IAAI,EAAE2B,OAAQ,CAAC;IAChC;EAAG,CACH,CACD,EACCnC,0BAA0B,IAC3B,IAAAgB,MAAA,CAAAC,aAAA,EAACvC,oBAAA,CAAA0D,sBAAsB;IACtBH,OAAO,EAAGA,CAAA,KAAMhC,6BAA6B,CAAE,KAAM,CAAG;IACxDiC,MAAM,EAAGA,CAAA,KAAM1B,cAAc,CAAE,KAAM;EAAG,CACxC,CAED,CAAC;AAEL;AAAC,IAAA6B,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEchD,wBAAwB","ignoreList":[]}
1
+ {"version":3,"names":["_element","require","_blockEditor","_components","_i18n","_constants","_allowOverridesModal","_jsxRuntime","removeBindings","bindings","updatedBindings","__default","Object","keys","length","undefined","addBindings","source","PATTERN_OVERRIDES_BINDING_SOURCE","PatternOverridesControls","attributes","setAttributes","controlId","useId","showAllowOverridesModal","setShowAllowOverridesModal","useState","showDisallowOverridesModal","setShowDisallowOverridesModal","hasName","metadata","name","defaultBindings","allowOverrides","isConnectedToOtherSources","updateBindings","isChecked","customName","prevBindings","updatedMetadata","jsxs","Fragment","children","jsx","InspectorControls","group","BaseControl","id","label","__","help","Button","__next40pxDefaultSize","className","variant","onClick","AllowOverridesModal","initialName","onClose","onSave","newName","DisallowOverridesModal","_default","exports","default"],"sources":["@wordpress/patterns/src/components/pattern-overrides-controls.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useState, useId } from '@wordpress/element';\nimport { InspectorControls } from '@wordpress/block-editor';\nimport { BaseControl, Button } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { PATTERN_OVERRIDES_BINDING_SOURCE } from '../constants';\nimport {\n\tAllowOverridesModal,\n\tDisallowOverridesModal,\n} from './allow-overrides-modal';\n\nfunction removeBindings( bindings ) {\n\tlet updatedBindings = { ...bindings };\n\tdelete updatedBindings.__default;\n\tif ( ! Object.keys( updatedBindings ).length ) {\n\t\tupdatedBindings = undefined;\n\t}\n\treturn updatedBindings;\n}\n\nfunction addBindings( bindings ) {\n\treturn {\n\t\t...bindings,\n\t\t__default: { source: PATTERN_OVERRIDES_BINDING_SOURCE },\n\t};\n}\n\nfunction PatternOverridesControls( { attributes, setAttributes } ) {\n\tconst controlId = useId();\n\tconst [ showAllowOverridesModal, setShowAllowOverridesModal ] =\n\t\tuseState( false );\n\tconst [ showDisallowOverridesModal, setShowDisallowOverridesModal ] =\n\t\tuseState( false );\n\n\tconst hasName = !! attributes.metadata?.name;\n\tconst defaultBindings = attributes.metadata?.bindings?.__default;\n\tconst allowOverrides =\n\t\thasName && defaultBindings?.source === PATTERN_OVERRIDES_BINDING_SOURCE;\n\tconst isConnectedToOtherSources =\n\t\tdefaultBindings?.source &&\n\t\tdefaultBindings.source !== PATTERN_OVERRIDES_BINDING_SOURCE;\n\n\tfunction updateBindings( isChecked, customName ) {\n\t\tconst prevBindings = attributes?.metadata?.bindings;\n\t\tconst updatedBindings = isChecked\n\t\t\t? addBindings( prevBindings )\n\t\t\t: removeBindings( prevBindings );\n\n\t\tconst updatedMetadata = {\n\t\t\t...attributes.metadata,\n\t\t\tbindings: updatedBindings,\n\t\t};\n\n\t\tif ( customName ) {\n\t\t\tupdatedMetadata.name = customName;\n\t\t}\n\n\t\tsetAttributes( {\n\t\t\tmetadata: updatedMetadata,\n\t\t} );\n\t}\n\n\t// Avoid overwriting other (e.g. meta) bindings.\n\tif ( isConnectedToOtherSources ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<InspectorControls group=\"advanced\">\n\t\t\t\t<BaseControl\n\t\t\t\t\tid={ controlId }\n\t\t\t\t\tlabel={ __( 'Overrides' ) }\n\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t'Allow changes to this block throughout instances of this pattern.'\n\t\t\t\t\t) }\n\t\t\t\t>\n\t\t\t\t\t<Button\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tclassName=\"pattern-overrides-control__allow-overrides-button\"\n\t\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\t\taria-haspopup=\"dialog\"\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tif ( allowOverrides ) {\n\t\t\t\t\t\t\t\tsetShowDisallowOverridesModal( true );\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tsetShowAllowOverridesModal( true );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ allowOverrides\n\t\t\t\t\t\t\t? __( 'Disable overrides' )\n\t\t\t\t\t\t\t: __( 'Enable overrides' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t</BaseControl>\n\t\t\t</InspectorControls>\n\n\t\t\t{ showAllowOverridesModal && (\n\t\t\t\t<AllowOverridesModal\n\t\t\t\t\tinitialName={ attributes.metadata?.name }\n\t\t\t\t\tonClose={ () => setShowAllowOverridesModal( false ) }\n\t\t\t\t\tonSave={ ( newName ) => {\n\t\t\t\t\t\tupdateBindings( true, newName );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ showDisallowOverridesModal && (\n\t\t\t\t<DisallowOverridesModal\n\t\t\t\t\tonClose={ () => setShowDisallowOverridesModal( false ) }\n\t\t\t\t\tonSave={ () => updateBindings( false ) }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport default PatternOverridesControls;\n"],"mappings":";;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AAKA,IAAAI,UAAA,GAAAJ,OAAA;AACA,IAAAK,oBAAA,GAAAL,OAAA;AAGiC,IAAAM,WAAA,GAAAN,OAAA;AAfjC;AACA;AACA;;AAMA;AACA;AACA;;AAOA,SAASO,cAAcA,CAAEC,QAAQ,EAAG;EACnC,IAAIC,eAAe,GAAG;IAAE,GAAGD;EAAS,CAAC;EACrC,OAAOC,eAAe,CAACC,SAAS;EAChC,IAAK,CAAEC,MAAM,CAACC,IAAI,CAAEH,eAAgB,CAAC,CAACI,MAAM,EAAG;IAC9CJ,eAAe,GAAGK,SAAS;EAC5B;EACA,OAAOL,eAAe;AACvB;AAEA,SAASM,WAAWA,CAAEP,QAAQ,EAAG;EAChC,OAAO;IACN,GAAGA,QAAQ;IACXE,SAAS,EAAE;MAAEM,MAAM,EAAEC;IAAiC;EACvD,CAAC;AACF;AAEA,SAASC,wBAAwBA,CAAE;EAAEC,UAAU;EAAEC;AAAc,CAAC,EAAG;EAClE,MAAMC,SAAS,GAAG,IAAAC,cAAK,EAAC,CAAC;EACzB,MAAM,CAAEC,u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Property(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
- var _react = require("react");
8
7
  var _components = require("@wordpress/components");
9
8
  var _i18n = require("@wordpress/i18n");
10
9
  var _blocks = require("@wordpress/blocks");
@@ -14,6 +13,7 @@ var _url = require("@wordpress/url");
14
13
  var _coreData = require("@wordpress/core-data");
15
14
  var _store = require("../store");
16
15
  var _lockUnlock = require("../lock-unlock");
16
+ var _jsxRuntime = require("react/jsx-runtime");
17
17
  /**
18
18
  * WordPress dependencies
19
19
  */
@@ -62,11 +62,15 @@ function PatternsManageButton({
62
62
  if (!isVisible) {
63
63
  return null;
64
64
  }
65
- return (0, _react.createElement)(_react.Fragment, null, canRemove && (0, _react.createElement)(_components.MenuItem, {
66
- onClick: () => convertSyncedPatternToStatic(clientId)
67
- }, (0, _i18n.__)('Detach')), (0, _react.createElement)(_components.MenuItem, {
68
- href: managePatternsUrl
69
- }, (0, _i18n.__)('Manage patterns')));
65
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
66
+ children: [canRemove && /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.MenuItem, {
67
+ onClick: () => convertSyncedPatternToStatic(clientId),
68
+ children: (0, _i18n.__)('Detach')
69
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.MenuItem, {
70
+ href: managePatternsUrl,
71
+ children: (0, _i18n.__)('Manage patterns')
72
+ })]
73
+ });
70
74
  }
71
75
  var _default = exports.default = PatternsManageButton;
72
76
  //# sourceMappingURL=patterns-manage-button.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_components","require","_i18n","_blocks","_data","_blockEditor","_url","_coreData","_store","_lockUnlock","PatternsManageButton","clientId","canRemove","isVisible","managePatternsUrl","useSelect","select","getBlock","canRemoveBlock","getBlockCount","blockEditorStore","canUser","coreStore","reusableBlock","isReusableBlock","attributes","ref","innerBlockCount","addQueryArgs","path","post_type","convertSyncedPatternToStatic","unlock","useDispatch","patternsStore","_react","createElement","Fragment","MenuItem","onClick","__","href","_default","exports","default"],"sources":["@wordpress/patterns/src/components/patterns-manage-button.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { MenuItem } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { isReusableBlock } from '@wordpress/blocks';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { addQueryArgs } from '@wordpress/url';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as patternsStore } from '../store';\nimport { unlock } from '../lock-unlock';\n\nfunction PatternsManageButton( { clientId } ) {\n\tconst { canRemove, isVisible, managePatternsUrl } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlock, canRemoveBlock, getBlockCount } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst { canUser } = select( coreStore );\n\t\t\tconst reusableBlock = getBlock( clientId );\n\n\t\t\treturn {\n\t\t\t\tcanRemove: canRemoveBlock( clientId ),\n\t\t\t\tisVisible:\n\t\t\t\t\t!! reusableBlock &&\n\t\t\t\t\tisReusableBlock( reusableBlock ) &&\n\t\t\t\t\t!! canUser(\n\t\t\t\t\t\t'update',\n\t\t\t\t\t\t'blocks',\n\t\t\t\t\t\treusableBlock.attributes.ref\n\t\t\t\t\t),\n\t\t\t\tinnerBlockCount: getBlockCount( clientId ),\n\t\t\t\t// The site editor and templates both check whether the user\n\t\t\t\t// has edit_theme_options capabilities. We can leverage that here\n\t\t\t\t// and omit the manage patterns link if the user can't access it.\n\t\t\t\tmanagePatternsUrl: canUser( 'create', 'templates' )\n\t\t\t\t\t? addQueryArgs( 'site-editor.php', {\n\t\t\t\t\t\t\tpath: '/patterns',\n\t\t\t\t\t } )\n\t\t\t\t\t: addQueryArgs( 'edit.php', {\n\t\t\t\t\t\t\tpost_type: 'wp_block',\n\t\t\t\t\t } ),\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\t// Ignore reason: false positive of the lint rule.\n\t// eslint-disable-next-line @wordpress/no-unused-vars-before-return\n\tconst { convertSyncedPatternToStatic } = unlock(\n\t\tuseDispatch( patternsStore )\n\t);\n\n\tif ( ! isVisible ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t{ canRemove && (\n\t\t\t\t<MenuItem\n\t\t\t\t\tonClick={ () => convertSyncedPatternToStatic( clientId ) }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Detach' ) }\n\t\t\t\t</MenuItem>\n\t\t\t) }\n\t\t\t<MenuItem href={ managePatternsUrl }>\n\t\t\t\t{ __( 'Manage patterns' ) }\n\t\t\t</MenuItem>\n\t\t</>\n\t);\n}\n\nexport default PatternsManageButton;\n"],"mappings":";;;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,YAAA,GAAAJ,OAAA;AACA,IAAAK,IAAA,GAAAL,OAAA;AACA,IAAAM,SAAA,GAAAN,OAAA;AAKA,IAAAO,MAAA,GAAAP,OAAA;AACA,IAAAQ,WAAA,GAAAR,OAAA;AAfA;AACA;AACA;;AASA;AACA;AACA;;AAIA,SAASS,oBAAoBA,CAAE;EAAEC;AAAS,CAAC,EAAG;EAC7C,MAAM;IAAEC,SAAS;IAAEC,SAAS;IAAEC;EAAkB,CAAC,GAAG,IAAAC,eAAS,EAC1DC,MAAM,IAAM;IACb,MAAM;MAAEC,QAAQ;MAAEC,cAAc;MAAEC;IAAc,CAAC,GAChDH,MAAM,CAAEI,kBAAiB,CAAC;IAC3B,MAAM;MAAEC;IAAQ,CAAC,GAAGL,MAAM,CAAEM,eAAU,CAAC;IACvC,MAAMC,aAAa,GAAGN,QAAQ,CAAEN,QAAS,CAAC;IAE1C,OAAO;MACNC,SAAS,EAAEM,cAAc,CAAEP,QAAS,CAAC;MACrCE,SAAS,EACR,CAAC,CAAEU,aAAa,IAChB,IAAAC,uBAAe,EAAED,aAAc,CAAC,IAChC,CAAC,CAAEF,OAAO,CACT,QAAQ,EACR,QAAQ,EACRE,aAAa,CAACE,UAAU,CAACC,GAC1B,CAAC;MACFC,eAAe,EAAER,aAAa,CAAER,QAAS,CAAC;MAC1C;MACA;MACA;MACAG,iBAAiB,EAAEO,OAAO,CAAE,QAAQ,EAAE,WAAY,CAAC,GAChD,IAAAO,iBAAY,EAAE,iBAAiB,EAAE;QACjCC,IAAI,EAAE;MACN,CAAE,CAAC,GACH,IAAAD,iBAAY,EAAE,UAAU,EAAE;QAC1BE,SAAS,EAAE;MACX,CAAE;IACN,CAAC;EACF,CAAC,EACD,CAAEnB,QAAQ,CACX,CAAC;;EAED;EACA;EACA,MAAM;IAAEoB;EAA6B,CAAC,GAAG,IAAAC,kBAAM,EAC9C,IAAAC,iBAAW,EAAEC,YAAc,CAC5B,CAAC;EAED,IAAK,CAAErB,SAAS,EAAG;IAClB,OAAO,IAAI;EACZ;EAEA,OACC,IAAAsB,MAAA,CAAAC,aAAA,EAAAD,MAAA,CAAAE,QAAA,QACGzB,SAAS,IACV,IAAAuB,MAAA,CAAAC,aAAA,EAACpC,WAAA,CAAAsC,QAAQ;IACRC,OAAO,EAAGA,CAAA,KAAMR,4BAA4B,CAAEpB,QAAS;EAAG,GAExD,IAAA6B,QAAE,EAAE,QAAS,CACN,CACV,EACD,IAAAL,MAAA,CAAAC,aAAA,EAACpC,WAAA,CAAAsC,QAAQ;IAACG,IAAI,EAAG3B;EAAmB,GACjC,IAAA0B,QAAE,EAAE,iBAAkB,CACf,CACT,CAAC;AAEL;AAAC,IAAAE,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEclC,oBAAoB","ignoreList":[]}
1
+ {"version":3,"names":["_components","require","_i18n","_blocks","_data","_blockEditor","_url","_coreData","_store","_lockUnlock","_jsxRuntime","PatternsManageButton","clientId","canRemove","isVisible","managePatternsUrl","useSelect","select","getBlock","canRemoveBlock","getBlockCount","blockEditorStore","canUser","coreStore","reusableBlock","isReusableBlock","attributes","ref","innerBlockCount","addQueryArgs","path","post_type","convertSyncedPatternToStatic","unlock","useDispatch","patternsStore","jsxs","Fragment","children","jsx","MenuItem","onClick","__","href","_default","exports","default"],"sources":["@wordpress/patterns/src/components/patterns-manage-button.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { MenuItem } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { isReusableBlock } from '@wordpress/blocks';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { addQueryArgs } from '@wordpress/url';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as patternsStore } from '../store';\nimport { unlock } from '../lock-unlock';\n\nfunction PatternsManageButton( { clientId } ) {\n\tconst { canRemove, isVisible, managePatternsUrl } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlock, canRemoveBlock, getBlockCount } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst { canUser } = select( coreStore );\n\t\t\tconst reusableBlock = getBlock( clientId );\n\n\t\t\treturn {\n\t\t\t\tcanRemove: canRemoveBlock( clientId ),\n\t\t\t\tisVisible:\n\t\t\t\t\t!! reusableBlock &&\n\t\t\t\t\tisReusableBlock( reusableBlock ) &&\n\t\t\t\t\t!! canUser(\n\t\t\t\t\t\t'update',\n\t\t\t\t\t\t'blocks',\n\t\t\t\t\t\treusableBlock.attributes.ref\n\t\t\t\t\t),\n\t\t\t\tinnerBlockCount: getBlockCount( clientId ),\n\t\t\t\t// The site editor and templates both check whether the user\n\t\t\t\t// has edit_theme_options capabilities. We can leverage that here\n\t\t\t\t// and omit the manage patterns link if the user can't access it.\n\t\t\t\tmanagePatternsUrl: canUser( 'create', 'templates' )\n\t\t\t\t\t? addQueryArgs( 'site-editor.php', {\n\t\t\t\t\t\t\tpath: '/patterns',\n\t\t\t\t\t } )\n\t\t\t\t\t: addQueryArgs( 'edit.php', {\n\t\t\t\t\t\t\tpost_type: 'wp_block',\n\t\t\t\t\t } ),\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\t// Ignore reason: false positive of the lint rule.\n\t// eslint-disable-next-line @wordpress/no-unused-vars-before-return\n\tconst { convertSyncedPatternToStatic } = unlock(\n\t\tuseDispatch( patternsStore )\n\t);\n\n\tif ( ! isVisible ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t{ canRemove && (\n\t\t\t\t<MenuItem\n\t\t\t\t\tonClick={ () => convertSyncedPatternToStatic( clientId ) }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Detach' ) }\n\t\t\t\t</MenuItem>\n\t\t\t) }\n\t\t\t<MenuItem href={ managePatternsUrl }>\n\t\t\t\t{ __( 'Manage patterns' ) }\n\t\t\t</MenuItem>\n\t\t</>\n\t);\n}\n\nexport default PatternsManageButton;\n"],"mappings":";;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,YAAA,GAAAJ,OAAA;AACA,IAAAK,IAAA,GAAAL,OAAA;AACA,IAAAM,SAAA,GAAAN,OAAA;AAKA,IAAAO,MAAA,GAAAP,OAAA;AACA,IAAAQ,WAAA,GAAAR,OAAA;AAAwC,IAAAS,WAAA,GAAAT,OAAA;AAfxC;AACA;AACA;;AASA;AACA;AACA;;AAIA,SAASU,oBAAoBA,CAAE;EAAEC;AAAS,CAAC,EAAG;EAC7C,MAAM;IAAEC,SAAS;IAAEC,SAAS;IAAEC;EAAkB,CAAC,GAAG,IAAAC,eAAS,EAC1DC,MAAM,IAAM;IACb,MAAM;MAAEC,QAAQ;MAAEC,cAAc;MAAEC;IAAc,CAAC,GAChDH,MAAM,CAAEI,kBAAiB,CAAC;IAC3B,MAAM;MAAEC;IA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CAChB,CAAC;EAAA,CACV,CAAC;AAEL;AAAC,IAAAE,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEcnC,oBAAoB","ignoreList":[]}
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = RenamePatternCategoryModal;
7
- var _react = require("react");
8
7
  var _components = require("@wordpress/components");
9
8
  var _coreData = require("@wordpress/core-data");
10
9
  var _data = require("@wordpress/data");
@@ -14,6 +13,7 @@ var _i18n = require("@wordpress/i18n");
14
13
  var _notices = require("@wordpress/notices");
15
14
  var _a11y = require("@wordpress/a11y");
16
15
  var _categorySelector = require("./category-selector");
16
+ var _jsxRuntime = require("react/jsx-runtime");
17
17
  /**
18
18
  * WordPress dependencies
19
19
  */
@@ -109,40 +109,48 @@ function RenamePatternCategoryModal({
109
109
  onClose();
110
110
  setName('');
111
111
  };
112
- return (0, _react.createElement)(_components.Modal, {
112
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Modal, {
113
113
  title: (0, _i18n.__)('Rename'),
114
114
  onRequestClose: onRequestClose,
115
- ...props
116
- }, (0, _react.createElement)("form", {
117
- onSubmit: onSave
118
- }, (0, _react.createElement)(_components.__experimentalVStack, {
119
- spacing: "5"
120
- }, (0, _react.createElement)(_components.__experimentalVStack, {
121
- spacing: "2"
122
- }, (0, _react.createElement)(_components.TextControl, {
123
- ref: textControlRef,
124
- __nextHasNoMarginBottom: true,
125
- __next40pxDefaultSize: true,
126
- label: (0, _i18n.__)('Name'),
127
- value: name,
128
- onChange: onChange,
129
- "aria-describedby": validationMessageId,
130
- required: true
131
- }), validationMessage && (0, _react.createElement)("span", {
132
- className: "patterns-rename-pattern-category-modal__validation-message",
133
- id: validationMessageId
134
- }, validationMessage)), (0, _react.createElement)(_components.__experimentalHStack, {
135
- justify: "right"
136
- }, (0, _react.createElement)(_components.Button, {
137
- __next40pxDefaultSize: true,
138
- variant: "tertiary",
139
- onClick: onRequestClose
140
- }, (0, _i18n.__)('Cancel')), (0, _react.createElement)(_components.Button, {
141
- __next40pxDefaultSize: true,
142
- variant: "primary",
143
- type: "submit",
144
- "aria-disabled": !name || name === category.name || isSaving,
145
- isBusy: isSaving
146
- }, (0, _i18n.__)('Save'))))));
115
+ ...props,
116
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)("form", {
117
+ onSubmit: onSave,
118
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.__experimentalVStack, {
119
+ spacing: "5",
120
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.__experimentalVStack, {
121
+ spacing: "2",
122
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.TextControl, {
123
+ ref: textControlRef,
124
+ __nextHasNoMarginBottom: true,
125
+ __next40pxDefaultSize: true,
126
+ label: (0, _i18n.__)('Name'),
127
+ value: name,
128
+ onChange: onChange,
129
+ "aria-describedby": validationMessageId,
130
+ required: true
131
+ }), validationMessage && /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
132
+ className: "patterns-rename-pattern-category-modal__validation-message",
133
+ id: validationMessageId,
134
+ children: validationMessage
135
+ })]
136
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.__experimentalHStack, {
137
+ justify: "right",
138
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button, {
139
+ __next40pxDefaultSize: true,
140
+ variant: "tertiary",
141
+ onClick: onRequestClose,
142
+ children: (0, _i18n.__)('Cancel')
143
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button, {
144
+ __next40pxDefaultSize: true,
145
+ variant: "primary",
146
+ type: "submit",
147
+ "aria-disabled": !name || name === category.name || isSaving,
148
+ isBusy: isSaving,
149
+ children: (0, _i18n.__)('Save')
150
+ })]
151
+ })]
152
+ })
153
+ })
154
+ });
147
155
  }
148
156
  //# sourceMappingURL=rename-pattern-category-modal.js.map