@wordpress/patterns 1.11.1 → 1.11.2

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.
@@ -28,8 +28,8 @@ function PartialSyncingControls({
28
28
  setAttributes
29
29
  }) {
30
30
  const syncedAttributes = _constants.PARTIAL_SYNCING_SUPPORTED_BLOCKS[name];
31
- const attributeSources = Object.keys(syncedAttributes).map(attributeName => attributes.metadata?.bindings?.[attributeName]?.source?.name);
32
- const isConnectedToOtherSources = attributeSources.every(source => source && source !== 'pattern_attributes');
31
+ const attributeSources = Object.keys(syncedAttributes).map(attributeName => attributes.metadata?.bindings?.[attributeName]?.source);
32
+ const isConnectedToOtherSources = attributeSources.every(source => source && source !== 'core/pattern-overrides');
33
33
 
34
34
  // Render nothing if all supported attributes are connected to other sources.
35
35
  if (isConnectedToOtherSources) {
@@ -41,7 +41,7 @@ function PartialSyncingControls({
41
41
  };
42
42
  if (!isChecked) {
43
43
  for (const attributeName of Object.keys(syncedAttributes)) {
44
- if (updatedBindings[attributeName]?.source?.name === 'pattern_attributes') {
44
+ if (updatedBindings[attributeName]?.source === 'core/pattern-overrides') {
45
45
  delete updatedBindings[attributeName];
46
46
  }
47
47
  }
@@ -59,9 +59,7 @@ function PartialSyncingControls({
59
59
  for (const attributeName of Object.keys(syncedAttributes)) {
60
60
  if (!updatedBindings[attributeName]) {
61
61
  updatedBindings[attributeName] = {
62
- source: {
63
- name: 'pattern_attributes'
64
- }
62
+ source: 'core/pattern-overrides'
65
63
  };
66
64
  }
67
65
  }
@@ -90,7 +88,7 @@ function PartialSyncingControls({
90
88
  }, (0, _react.createElement)(_components.BaseControl.VisualLabel, null, (0, _i18n.__)('Pattern overrides')), (0, _react.createElement)(_components.CheckboxControl, {
91
89
  __nextHasNoMarginBottom: true,
92
90
  label: (0, _i18n.__)('Allow instance overrides'),
93
- checked: attributeSources.some(source => source === 'pattern_attributes'),
91
+ checked: attributeSources.some(source => source === 'core/pattern-overrides'),
94
92
  onChange: isChecked => {
95
93
  updateBindings(isChecked);
96
94
  }
@@ -1 +1 @@
1
- {"version":3,"names":["_nanoid","require","_blockEditor","_components","_i18n","_constants","PartialSyncingControls","name","attributes","setAttributes","syncedAttributes","PARTIAL_SYNCING_SUPPORTED_BLOCKS","attributeSources","Object","keys","map","attributeName","metadata","bindings","source","isConnectedToOtherSources","every","updateBindings","isChecked","updatedBindings","length","undefined","id","nanoid","_react","createElement","InspectorControls","group","BaseControl","__nextHasNoMarginBottom","VisualLabel","__","CheckboxControl","label","checked","some","onChange","_default","exports","default"],"sources":["@wordpress/patterns/src/components/partial-syncing-controls.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { nanoid } from 'nanoid';\n\n/**\n * WordPress dependencies\n */\nimport { InspectorControls } from '@wordpress/block-editor';\nimport { BaseControl, CheckboxControl } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { PARTIAL_SYNCING_SUPPORTED_BLOCKS } from '../constants';\n\nfunction PartialSyncingControls( { name, attributes, setAttributes } ) {\n\tconst syncedAttributes = PARTIAL_SYNCING_SUPPORTED_BLOCKS[ name ];\n\tconst attributeSources = Object.keys( syncedAttributes ).map(\n\t\t( attributeName ) =>\n\t\t\tattributes.metadata?.bindings?.[ attributeName ]?.source?.name\n\t);\n\tconst isConnectedToOtherSources = attributeSources.every(\n\t\t( source ) => source && source !== 'pattern_attributes'\n\t);\n\n\t// Render nothing if all supported attributes are connected to other sources.\n\tif ( isConnectedToOtherSources ) {\n\t\treturn null;\n\t}\n\n\tfunction updateBindings( isChecked ) {\n\t\tlet updatedBindings = {\n\t\t\t...attributes?.metadata?.bindings,\n\t\t};\n\n\t\tif ( ! isChecked ) {\n\t\t\tfor ( const attributeName of Object.keys( syncedAttributes ) ) {\n\t\t\t\tif (\n\t\t\t\t\tupdatedBindings[ attributeName ]?.source?.name ===\n\t\t\t\t\t'pattern_attributes'\n\t\t\t\t) {\n\t\t\t\t\tdelete updatedBindings[ attributeName ];\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( ! Object.keys( updatedBindings ).length ) {\n\t\t\t\tupdatedBindings = undefined;\n\t\t\t}\n\t\t\tsetAttributes( {\n\t\t\t\tmetadata: {\n\t\t\t\t\t...attributes.metadata,\n\t\t\t\t\tbindings: updatedBindings,\n\t\t\t\t},\n\t\t\t} );\n\t\t\treturn;\n\t\t}\n\n\t\tfor ( const attributeName of Object.keys( syncedAttributes ) ) {\n\t\t\tif ( ! updatedBindings[ attributeName ] ) {\n\t\t\t\tupdatedBindings[ attributeName ] = {\n\t\t\t\t\tsource: {\n\t\t\t\t\t\tname: 'pattern_attributes',\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\tif ( typeof attributes.metadata?.id === 'string' ) {\n\t\t\tsetAttributes( {\n\t\t\t\tmetadata: {\n\t\t\t\t\t...attributes.metadata,\n\t\t\t\t\tbindings: updatedBindings,\n\t\t\t\t},\n\t\t\t} );\n\t\t\treturn;\n\t\t}\n\n\t\tconst id = nanoid( 6 );\n\t\tsetAttributes( {\n\t\t\tmetadata: {\n\t\t\t\t...attributes.metadata,\n\t\t\t\tid,\n\t\t\t\tbindings: updatedBindings,\n\t\t\t},\n\t\t} );\n\t}\n\n\treturn (\n\t\t<InspectorControls group=\"advanced\">\n\t\t\t<BaseControl __nextHasNoMarginBottom>\n\t\t\t\t<BaseControl.VisualLabel>\n\t\t\t\t\t{ __( 'Pattern overrides' ) }\n\t\t\t\t</BaseControl.VisualLabel>\n\t\t\t\t<CheckboxControl\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\tlabel={ __( 'Allow instance overrides' ) }\n\t\t\t\t\tchecked={ attributeSources.some(\n\t\t\t\t\t\t( source ) => source === 'pattern_attributes'\n\t\t\t\t\t) }\n\t\t\t\t\tonChange={ ( isChecked ) => {\n\t\t\t\t\t\tupdateBindings( isChecked );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\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BrB,MAAM,IAAMA,MAAM,KAAK,oBAC1B,CAAG;IACHsB,QAAQ,EAAKlB,SAAS,IAAM;MAC3BD,cAAc,CAAEC,SAAU,CAAC;IAC5B;EAAG,CACH,CACW,CACK,CAAC;AAEtB;AAAC,IAAAmB,QAAA,GAEcpC,sBAAsB;AAAAqC,OAAA,CAAAC,OAAA,GAAAF,QAAA"}
1
+ {"version":3,"names":["_nanoid","require","_blockEditor","_components","_i18n","_constants","PartialSyncingControls","name","attributes","setAttributes","syncedAttributes","PARTIAL_SYNCING_SUPPORTED_BLOCKS","attributeSources","Object","keys","map","attributeName","metadata","bindings","source","isConnectedToOtherSources","every","updateBindings","isChecked","updatedBindings","length","undefined","id","nanoid","_react","createElement","InspectorControls","group","BaseControl","__nextHasNoMarginBottom","VisualLabel","__","CheckboxControl","label","checked","some","onChange","_default","exports","default"],"sources":["@wordpress/patterns/src/components/partial-syncing-controls.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { nanoid } from 'nanoid';\n\n/**\n * WordPress dependencies\n */\nimport { InspectorControls } from '@wordpress/block-editor';\nimport { BaseControl, CheckboxControl } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { PARTIAL_SYNCING_SUPPORTED_BLOCKS } from '../constants';\n\nfunction PartialSyncingControls( { name, attributes, setAttributes } ) {\n\tconst syncedAttributes = PARTIAL_SYNCING_SUPPORTED_BLOCKS[ name ];\n\tconst attributeSources = Object.keys( 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\t// Render nothing if all supported attributes are connected to other sources.\n\tif ( isConnectedToOtherSources ) {\n\t\treturn null;\n\t}\n\n\tfunction updateBindings( isChecked ) {\n\t\tlet updatedBindings = {\n\t\t\t...attributes?.metadata?.bindings,\n\t\t};\n\n\t\tif ( ! isChecked ) {\n\t\t\tfor ( const attributeName of Object.keys( syncedAttributes ) ) {\n\t\t\t\tif (\n\t\t\t\t\tupdatedBindings[ attributeName ]?.source ===\n\t\t\t\t\t'core/pattern-overrides'\n\t\t\t\t) {\n\t\t\t\t\tdelete updatedBindings[ attributeName ];\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( ! Object.keys( updatedBindings ).length ) {\n\t\t\t\tupdatedBindings = undefined;\n\t\t\t}\n\t\t\tsetAttributes( {\n\t\t\t\tmetadata: {\n\t\t\t\t\t...attributes.metadata,\n\t\t\t\t\tbindings: updatedBindings,\n\t\t\t\t},\n\t\t\t} );\n\t\t\treturn;\n\t\t}\n\n\t\tfor ( const attributeName of Object.keys( syncedAttributes ) ) {\n\t\t\tif ( ! updatedBindings[ attributeName ] ) {\n\t\t\t\tupdatedBindings[ attributeName ] = {\n\t\t\t\t\tsource: 'core/pattern-overrides',\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\tif ( typeof attributes.metadata?.id === 'string' ) {\n\t\t\tsetAttributes( {\n\t\t\t\tmetadata: {\n\t\t\t\t\t...attributes.metadata,\n\t\t\t\t\tbindings: updatedBindings,\n\t\t\t\t},\n\t\t\t} );\n\t\t\treturn;\n\t\t}\n\n\t\tconst id = nanoid( 6 );\n\t\tsetAttributes( {\n\t\t\tmetadata: {\n\t\t\t\t...attributes.metadata,\n\t\t\t\tid,\n\t\t\t\tbindings: updatedBindings,\n\t\t\t},\n\t\t} );\n\t}\n\n\treturn (\n\t\t<InspectorControls group=\"advanced\">\n\t\t\t<BaseControl __nextHasNoMarginBottom>\n\t\t\t\t<BaseControl.VisualLabel>\n\t\t\t\t\t{ __( 'Pattern overrides' ) }\n\t\t\t\t</BaseControl.VisualLabel>\n\t\t\t\t<CheckboxControl\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\tlabel={ __( 'Allow instance overrides' ) }\n\t\t\t\t\tchecked={ attributeSources.some(\n\t\t\t\t\t\t( source ) => source === 'core/pattern-overrides'\n\t\t\t\t\t) }\n\t\t\t\t\tonChange={ ( isChecked ) => {\n\t\t\t\t\t\tupdateBindings( isChecked );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t</BaseControl>\n\t\t</InspectorControls>\n\t);\n}\n\nexport default PartialSyncingControls;\n"],"mappings":";;;;;;;AAGA,IAAAA,OAAA,GAAAC,OAAA;AAKA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AAKA,IAAAI,UAAA,GAAAJ,OAAA;AAfA;AACA;AACA;;AAGA;AACA;AACA;;AAKA;AACA;AACA;;AAGA,SAASK,sBAAsBA,CAAE;EAAEC,IAAI;EAAEC,UAAU;EAAEC;AAAc,CAAC,EAAG;EACtE,MAAMC,gBAAgB,GAAGC,2CAAgC,CAAEJ,IAAI,CAAE;EACjE,MAAMK,gBAAgB,GAAGC,MAAM,CAACC,IAAI,CAAEJ,gBAAiB,CAAC,CAACK,GAAG,CACzDC,aAAa,IACdR,UAAU,CAACS,QAAQ,EAAEC,QAAQ,GAAIF,aAAa,CAAE,EAAEG,MACpD,CAAC;EACD,MAAMC,yBAAyB,GAAGR,gBAAgB,CAACS,KAAK,CACrDF,MAAM,IAAMA,MAAM,IAAIA,MAAM,KAAK,wBACpC,CAAC;;EAED;EACA,IAAKC,yBAAyB,EAAG;IAChC,OAAO,IAAI;EACZ;EAEA,SAASE,cAAcA,CAAEC,SAAS,EAAG;IACpC,IAAIC,eAAe,GAAG;MACrB,GAAGhB,UAAU,EAAES,QAAQ,EAAEC;IAC1B,CAAC;IAED,IAAK,CAAEK,SAAS,EAAG;MAClB,KAAM,MAAMP,aAAa,IAAIH,MAAM,CAACC,IAAI,CAAEJ,gBAAiB,CAAC,EAAG;QAC9D,IACCc,eAAe,CAAER,aAAa,CAAE,EAAEG,MAAM,KACxC,wBAAwB,EACvB;UACD,OAAOK,eAAe,CAAER,aAAa,CA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AAAF,QAAE,EAAE,0BAA2B,CAAG;IAC1CG,OAAO,EAAG3B,gBAAgB,CAAC4B,IAAI,CAC5BrB,MAAM,IAAMA,MAAM,KAAK,wBAC1B,CAAG;IACHsB,QAAQ,EAAKlB,SAAS,IAAM;MAC3BD,cAAc,CAAEC,SAAU,CAAC;IAC5B;EAAG,CACH,CACW,CACK,CAAC;AAEtB;AAAC,IAAAmB,QAAA,GAEcpC,sBAAsB;AAAAqC,OAAA,CAAAC,OAAA,GAAAF,QAAA"}
@@ -21,8 +21,8 @@ function PartialSyncingControls({
21
21
  setAttributes
22
22
  }) {
23
23
  const syncedAttributes = PARTIAL_SYNCING_SUPPORTED_BLOCKS[name];
24
- const attributeSources = Object.keys(syncedAttributes).map(attributeName => attributes.metadata?.bindings?.[attributeName]?.source?.name);
25
- const isConnectedToOtherSources = attributeSources.every(source => source && source !== 'pattern_attributes');
24
+ const attributeSources = Object.keys(syncedAttributes).map(attributeName => attributes.metadata?.bindings?.[attributeName]?.source);
25
+ const isConnectedToOtherSources = attributeSources.every(source => source && source !== 'core/pattern-overrides');
26
26
 
27
27
  // Render nothing if all supported attributes are connected to other sources.
28
28
  if (isConnectedToOtherSources) {
@@ -34,7 +34,7 @@ function PartialSyncingControls({
34
34
  };
35
35
  if (!isChecked) {
36
36
  for (const attributeName of Object.keys(syncedAttributes)) {
37
- if (updatedBindings[attributeName]?.source?.name === 'pattern_attributes') {
37
+ if (updatedBindings[attributeName]?.source === 'core/pattern-overrides') {
38
38
  delete updatedBindings[attributeName];
39
39
  }
40
40
  }
@@ -52,9 +52,7 @@ function PartialSyncingControls({
52
52
  for (const attributeName of Object.keys(syncedAttributes)) {
53
53
  if (!updatedBindings[attributeName]) {
54
54
  updatedBindings[attributeName] = {
55
- source: {
56
- name: 'pattern_attributes'
57
- }
55
+ source: 'core/pattern-overrides'
58
56
  };
59
57
  }
60
58
  }
@@ -83,7 +81,7 @@ function PartialSyncingControls({
83
81
  }, createElement(BaseControl.VisualLabel, null, __('Pattern overrides')), createElement(CheckboxControl, {
84
82
  __nextHasNoMarginBottom: true,
85
83
  label: __('Allow instance overrides'),
86
- checked: attributeSources.some(source => source === 'pattern_attributes'),
84
+ checked: attributeSources.some(source => source === 'core/pattern-overrides'),
87
85
  onChange: isChecked => {
88
86
  updateBindings(isChecked);
89
87
  }
@@ -1 +1 @@
1
- {"version":3,"names":["nanoid","InspectorControls","BaseControl","CheckboxControl","__","PARTIAL_SYNCING_SUPPORTED_BLOCKS","PartialSyncingControls","name","attributes","setAttributes","syncedAttributes","attributeSources","Object","keys","map","attributeName","metadata","bindings","source","isConnectedToOtherSources","every","updateBindings","isChecked","updatedBindings","length","undefined","id","createElement","group","__nextHasNoMarginBottom","VisualLabel","label","checked","some","onChange"],"sources":["@wordpress/patterns/src/components/partial-syncing-controls.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { nanoid } from 'nanoid';\n\n/**\n * WordPress dependencies\n */\nimport { InspectorControls } from '@wordpress/block-editor';\nimport { BaseControl, CheckboxControl } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { PARTIAL_SYNCING_SUPPORTED_BLOCKS } from '../constants';\n\nfunction PartialSyncingControls( { name, attributes, setAttributes } ) {\n\tconst syncedAttributes = PARTIAL_SYNCING_SUPPORTED_BLOCKS[ name ];\n\tconst attributeSources = Object.keys( syncedAttributes ).map(\n\t\t( attributeName ) =>\n\t\t\tattributes.metadata?.bindings?.[ attributeName ]?.source?.name\n\t);\n\tconst isConnectedToOtherSources = attributeSources.every(\n\t\t( source ) => source && source !== 'pattern_attributes'\n\t);\n\n\t// Render nothing if all supported attributes are connected to other sources.\n\tif ( isConnectedToOtherSources ) {\n\t\treturn null;\n\t}\n\n\tfunction updateBindings( isChecked ) {\n\t\tlet updatedBindings = {\n\t\t\t...attributes?.metadata?.bindings,\n\t\t};\n\n\t\tif ( ! isChecked ) {\n\t\t\tfor ( const attributeName of Object.keys( syncedAttributes ) ) {\n\t\t\t\tif (\n\t\t\t\t\tupdatedBindings[ attributeName ]?.source?.name ===\n\t\t\t\t\t'pattern_attributes'\n\t\t\t\t) {\n\t\t\t\t\tdelete updatedBindings[ attributeName ];\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( ! Object.keys( updatedBindings ).length ) {\n\t\t\t\tupdatedBindings = undefined;\n\t\t\t}\n\t\t\tsetAttributes( {\n\t\t\t\tmetadata: {\n\t\t\t\t\t...attributes.metadata,\n\t\t\t\t\tbindings: updatedBindings,\n\t\t\t\t},\n\t\t\t} );\n\t\t\treturn;\n\t\t}\n\n\t\tfor ( const attributeName of Object.keys( syncedAttributes ) ) {\n\t\t\tif ( ! updatedBindings[ attributeName ] ) {\n\t\t\t\tupdatedBindings[ attributeName ] = {\n\t\t\t\t\tsource: {\n\t\t\t\t\t\tname: 'pattern_attributes',\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\tif ( typeof attributes.metadata?.id === 'string' ) {\n\t\t\tsetAttributes( {\n\t\t\t\tmetadata: {\n\t\t\t\t\t...attributes.metadata,\n\t\t\t\t\tbindings: updatedBindings,\n\t\t\t\t},\n\t\t\t} );\n\t\t\treturn;\n\t\t}\n\n\t\tconst id = nanoid( 6 );\n\t\tsetAttributes( {\n\t\t\tmetadata: {\n\t\t\t\t...attributes.metadata,\n\t\t\t\tid,\n\t\t\t\tbindings: updatedBindings,\n\t\t\t},\n\t\t} );\n\t}\n\n\treturn (\n\t\t<InspectorControls group=\"advanced\">\n\t\t\t<BaseControl __nextHasNoMarginBottom>\n\t\t\t\t<BaseControl.VisualLabel>\n\t\t\t\t\t{ __( 'Pattern overrides' ) }\n\t\t\t\t</BaseControl.VisualLabel>\n\t\t\t\t<CheckboxControl\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\tlabel={ __( 'Allow instance overrides' ) }\n\t\t\t\t\tchecked={ attributeSources.some(\n\t\t\t\t\t\t( source ) => source === 'pattern_attributes'\n\t\t\t\t\t) }\n\t\t\t\t\tonChange={ ( isChecked ) => {\n\t\t\t\t\t\tupdateBindings( isChecked );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t</BaseControl>\n\t\t</InspectorControls>\n\t);\n}\n\nexport default PartialSyncingControls;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,MAAM,QAAQ,QAAQ;;AAE/B;AACA;AACA;AACA,SAASC,iBAAiB,QAAQ,yBAAyB;AAC3D,SAASC,WAAW,EAAEC,eAAe,QAAQ,uBAAuB;AACpE,SAASC,EAAE,QAAQ,iBAAiB;;AAEpC;AACA;AACA;AACA,SAASC,gCAAgC,QAAQ,cAAc;AAE/D,SAASC,sBAAsBA,CAAE;EAAEC,IAAI;EAAEC,UAAU;EAAEC;AAAc,CAAC,EAAG;EACtE,MAAMC,gBAAgB,GAAGL,gCAAgC,CAAEE,IAAI,CAAE;EACjE,MAAMI,gBAAgB,GAAGC,MAAM,CAACC,IAAI,CAAEH,gBAAiB,CAAC,CAACI,GAAG,CACzDC,aAAa,IACdP,UAAU,CAACQ,QAAQ,EAAEC,QAAQ,GAAIF,aAAa,CAAE,EAAEG,MAAM,EAAEX,IAC5D,CAAC;EACD,MAAMY,yBAAyB,GAAGR,gBAAgB,CAACS,KAAK,CACrDF,MAAM,IAAMA,MAAM,IAAIA,MAAM,KAAK,oBACpC,CAAC;;EAED;EACA,IAAKC,yBAAyB,EAAG;IAChC,OAAO,IAAI;EACZ;EAEA,SAASE,cAAcA,CAAEC,SAAS,EAAG;IACpC,IAAIC,eAAe,GAAG;MACrB,GAAGf,UAAU,EAAEQ,QAAQ,EAAEC;IAC1B,CAAC;IAED,IAAK,CAAEK,SAAS,EAAG;MAClB,KAAM,MAAMP,aAAa,IAAIH,MAAM,CAACC,IAAI,CAAEH,gBAAiB,CAAC,EAAG;QAC9D,IACCa,eAAe,CAAER,aAAa,CAAE,EAAEG,MAAM,EAAEX,IAAI,KAC9C,oBAAoB,EACnB;UACD,OAAOgB,eAAe,C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AAK,oBAC1B,CAAG;IACHgB,QAAQ,EAAKZ,SAAS,IAAM;MAC3BD,cAAc,CAAEC,SAAU,CAAC;IAC5B;EAAG,CACH,CACW,CACK,CAAC;AAEtB;AAEA,eAAehB,sBAAsB"}
1
+ {"version":3,"names":["nanoid","InspectorControls","BaseControl","CheckboxControl","__","PARTIAL_SYNCING_SUPPORTED_BLOCKS","PartialSyncingControls","name","attributes","setAttributes","syncedAttributes","attributeSources","Object","keys","map","attributeName","metadata","bindings","source","isConnectedToOtherSources","every","updateBindings","isChecked","updatedBindings","length","undefined","id","createElement","group","__nextHasNoMarginBottom","VisualLabel","label","checked","some","onChange"],"sources":["@wordpress/patterns/src/components/partial-syncing-controls.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { nanoid } from 'nanoid';\n\n/**\n * WordPress dependencies\n */\nimport { InspectorControls } from '@wordpress/block-editor';\nimport { BaseControl, CheckboxControl } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { PARTIAL_SYNCING_SUPPORTED_BLOCKS } from '../constants';\n\nfunction PartialSyncingControls( { name, attributes, setAttributes } ) {\n\tconst syncedAttributes = PARTIAL_SYNCING_SUPPORTED_BLOCKS[ name ];\n\tconst attributeSources = Object.keys( 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\t// Render nothing if all supported attributes are connected to other sources.\n\tif ( isConnectedToOtherSources ) {\n\t\treturn null;\n\t}\n\n\tfunction updateBindings( isChecked ) {\n\t\tlet updatedBindings = {\n\t\t\t...attributes?.metadata?.bindings,\n\t\t};\n\n\t\tif ( ! isChecked ) {\n\t\t\tfor ( const attributeName of Object.keys( syncedAttributes ) ) {\n\t\t\t\tif (\n\t\t\t\t\tupdatedBindings[ attributeName ]?.source ===\n\t\t\t\t\t'core/pattern-overrides'\n\t\t\t\t) {\n\t\t\t\t\tdelete updatedBindings[ attributeName ];\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( ! Object.keys( updatedBindings ).length ) {\n\t\t\t\tupdatedBindings = undefined;\n\t\t\t}\n\t\t\tsetAttributes( {\n\t\t\t\tmetadata: {\n\t\t\t\t\t...attributes.metadata,\n\t\t\t\t\tbindings: updatedBindings,\n\t\t\t\t},\n\t\t\t} );\n\t\t\treturn;\n\t\t}\n\n\t\tfor ( const attributeName of Object.keys( syncedAttributes ) ) {\n\t\t\tif ( ! updatedBindings[ attributeName ] ) {\n\t\t\t\tupdatedBindings[ attributeName ] = {\n\t\t\t\t\tsource: 'core/pattern-overrides',\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\tif ( typeof attributes.metadata?.id === 'string' ) {\n\t\t\tsetAttributes( {\n\t\t\t\tmetadata: {\n\t\t\t\t\t...attributes.metadata,\n\t\t\t\t\tbindings: updatedBindings,\n\t\t\t\t},\n\t\t\t} );\n\t\t\treturn;\n\t\t}\n\n\t\tconst id = nanoid( 6 );\n\t\tsetAttributes( {\n\t\t\tmetadata: {\n\t\t\t\t...attributes.metadata,\n\t\t\t\tid,\n\t\t\t\tbindings: updatedBindings,\n\t\t\t},\n\t\t} );\n\t}\n\n\treturn (\n\t\t<InspectorControls group=\"advanced\">\n\t\t\t<BaseControl __nextHasNoMarginBottom>\n\t\t\t\t<BaseControl.VisualLabel>\n\t\t\t\t\t{ __( 'Pattern overrides' ) }\n\t\t\t\t</BaseControl.VisualLabel>\n\t\t\t\t<CheckboxControl\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\tlabel={ __( 'Allow instance overrides' ) }\n\t\t\t\t\tchecked={ attributeSources.some(\n\t\t\t\t\t\t( source ) => source === 'core/pattern-overrides'\n\t\t\t\t\t) }\n\t\t\t\t\tonChange={ ( isChecked ) => {\n\t\t\t\t\t\tupdateBindings( isChecked );\n\t\t\t\t\t} }\n\t\t\t\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}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/patterns",
3
- "version": "1.11.1",
3
+ "version": "1.11.2",
4
4
  "description": "Management of user pattern editing.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -32,11 +32,11 @@
32
32
  "dependencies": {
33
33
  "@babel/runtime": "^7.16.0",
34
34
  "@wordpress/a11y": "^3.50.0",
35
- "@wordpress/block-editor": "^12.18.1",
35
+ "@wordpress/block-editor": "^12.18.2",
36
36
  "@wordpress/blocks": "^12.27.1",
37
37
  "@wordpress/components": "^25.16.0",
38
38
  "@wordpress/compose": "^6.27.0",
39
- "@wordpress/core-data": "^6.27.1",
39
+ "@wordpress/core-data": "^6.27.2",
40
40
  "@wordpress/data": "^9.20.0",
41
41
  "@wordpress/element": "^5.27.0",
42
42
  "@wordpress/html-entities": "^3.50.0",
@@ -54,5 +54,5 @@
54
54
  "publishConfig": {
55
55
  "access": "public"
56
56
  },
57
- "gitHead": "c2f6d07ffab7d68b9ac3c423ce7e11af91f6e45e"
57
+ "gitHead": "fefb6f718fbfd5df9390f366d5733369f613084a"
58
58
  }
@@ -19,10 +19,10 @@ function PartialSyncingControls( { name, attributes, setAttributes } ) {
19
19
  const syncedAttributes = PARTIAL_SYNCING_SUPPORTED_BLOCKS[ name ];
20
20
  const attributeSources = Object.keys( syncedAttributes ).map(
21
21
  ( attributeName ) =>
22
- attributes.metadata?.bindings?.[ attributeName ]?.source?.name
22
+ attributes.metadata?.bindings?.[ attributeName ]?.source
23
23
  );
24
24
  const isConnectedToOtherSources = attributeSources.every(
25
- ( source ) => source && source !== 'pattern_attributes'
25
+ ( source ) => source && source !== 'core/pattern-overrides'
26
26
  );
27
27
 
28
28
  // Render nothing if all supported attributes are connected to other sources.
@@ -38,8 +38,8 @@ function PartialSyncingControls( { name, attributes, setAttributes } ) {
38
38
  if ( ! isChecked ) {
39
39
  for ( const attributeName of Object.keys( syncedAttributes ) ) {
40
40
  if (
41
- updatedBindings[ attributeName ]?.source?.name ===
42
- 'pattern_attributes'
41
+ updatedBindings[ attributeName ]?.source ===
42
+ 'core/pattern-overrides'
43
43
  ) {
44
44
  delete updatedBindings[ attributeName ];
45
45
  }
@@ -59,9 +59,7 @@ function PartialSyncingControls( { name, attributes, setAttributes } ) {
59
59
  for ( const attributeName of Object.keys( syncedAttributes ) ) {
60
60
  if ( ! updatedBindings[ attributeName ] ) {
61
61
  updatedBindings[ attributeName ] = {
62
- source: {
63
- name: 'pattern_attributes',
64
- },
62
+ source: 'core/pattern-overrides',
65
63
  };
66
64
  }
67
65
  }
@@ -96,7 +94,7 @@ function PartialSyncingControls( { name, attributes, setAttributes } ) {
96
94
  __nextHasNoMarginBottom
97
95
  label={ __( 'Allow instance overrides' ) }
98
96
  checked={ attributeSources.some(
99
- ( source ) => source === 'pattern_attributes'
97
+ ( source ) => source === 'core/pattern-overrides'
100
98
  ) }
101
99
  onChange={ ( isChecked ) => {
102
100
  updateBindings( isChecked );