@wordpress/patterns 1.9.1-next.79a6196f.0 → 1.10.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.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 1.10.0 (2024-01-10)
6
+
5
7
  ## 1.9.0 (2023-12-13)
6
8
 
7
9
  ## 1.8.0 (2023-11-29)
@@ -28,58 +28,56 @@ 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);
31
+ const attributeSources = Object.keys(syncedAttributes).map(attributeName => attributes.connections?.attributes?.[attributeName]?.source);
32
32
  const isConnectedToOtherSources = attributeSources.every(source => source && source !== 'pattern_attributes');
33
33
 
34
34
  // Render nothing if all supported attributes are connected to other sources.
35
35
  if (isConnectedToOtherSources) {
36
36
  return null;
37
37
  }
38
- function updateBindings(isChecked) {
39
- let updatedBindings = {
40
- ...attributes?.metadata?.bindings
38
+ function updateConnections(isChecked) {
39
+ let updatedConnections = {
40
+ ...attributes.connections,
41
+ attributes: {
42
+ ...attributes.connections?.attributes
43
+ }
41
44
  };
42
45
  if (!isChecked) {
43
46
  for (const attributeName of Object.keys(syncedAttributes)) {
44
- if (updatedBindings[attributeName]?.source?.name === 'pattern_attributes') {
45
- delete updatedBindings[attributeName];
47
+ if (updatedConnections.attributes[attributeName]?.source === 'pattern_attributes') {
48
+ delete updatedConnections.attributes[attributeName];
46
49
  }
47
50
  }
48
- if (!Object.keys(updatedBindings).length) {
49
- updatedBindings = undefined;
51
+ if (!Object.keys(updatedConnections.attributes).length) {
52
+ delete updatedConnections.attributes;
53
+ }
54
+ if (!Object.keys(updatedConnections).length) {
55
+ updatedConnections = undefined;
50
56
  }
51
57
  setAttributes({
52
- metadata: {
53
- ...attributes.metadata,
54
- bindings: updatedBindings
55
- }
58
+ connections: updatedConnections
56
59
  });
57
60
  return;
58
61
  }
59
62
  for (const attributeName of Object.keys(syncedAttributes)) {
60
- if (!updatedBindings[attributeName]) {
61
- updatedBindings[attributeName] = {
62
- source: {
63
- name: 'pattern_attributes'
64
- }
63
+ if (!updatedConnections.attributes[attributeName]) {
64
+ updatedConnections.attributes[attributeName] = {
65
+ source: 'pattern_attributes'
65
66
  };
66
67
  }
67
68
  }
68
69
  if (typeof attributes.metadata?.id === 'string') {
69
70
  setAttributes({
70
- metadata: {
71
- ...attributes.metadata,
72
- bindings: updatedBindings
73
- }
71
+ connections: updatedConnections
74
72
  });
75
73
  return;
76
74
  }
77
75
  const id = (0, _nanoid.nanoid)(6);
78
76
  setAttributes({
77
+ connections: updatedConnections,
79
78
  metadata: {
80
79
  ...attributes.metadata,
81
- id,
82
- bindings: updatedBindings
80
+ id
83
81
  }
84
82
  });
85
83
  }
@@ -92,7 +90,7 @@ function PartialSyncingControls({
92
90
  label: (0, _i18n.__)('Allow instance overrides'),
93
91
  checked: attributeSources.some(source => source === 'pattern_attributes'),
94
92
  onChange: isChecked => {
95
- updateBindings(isChecked);
93
+ updateConnections(isChecked);
96
94
  }
97
95
  })));
98
96
  }
@@ -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\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,g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AE;UACT,GAAGT,UAAU,CAACS,QAAQ;UACtBC,QAAQ,EAAEM;QACX;MACD,CAAE,CAAC;MACH;IACD;IAEA,MAAMG,EAAE,GAAG,IAAAC,cAAM,EAAE,CAAE,CAAC;IACtBnB,aAAa,CAAE;MACdQ,QAAQ,EAAE;QACT,GAAGT,UAAU,CAACS,QAAQ;QACtBU,EAAE;QACFT,QAAQ,EAAEM;MACX;IACD,CAAE,CAAC;EACJ;EAEA,OACC,IAAAK,MAAA,CAAAC,aAAA,EAAC5B,YAAA,CAAA6B,iBAAiB;IAACC,KAAK,EAAC;EAAU,GAClC,IAAAH,MAAA,CAAAC,aAAA,EAAC3B,WAAA,CAAA8B,WAAW;IAACC,uBAAuB;EAAA,GACnC,IAAAL,MAAA,CAAAC,aAAA,EAAC3B,WAAA,CAAA8B,WAAW,CAACE,WAAW,QACrB,IAAAC,QAAE,EAAE,mBAAoB,CACF,CAAC,EAC1B,IAAAP,MAAA,CAAAC,aAAA,EAAC3B,WAAA,CAAAkC,eAAe;IACfH,uBAAuB;IACvBI,KAAK,EAAG,IAAAF,QAAE,EAAE,0BAA2B,CAAG;IAC1CG,OAAO,EAAG3B,gBAAgB,CAAC4B,IAAI,CAC5BrB,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","connections","source","isConnectedToOtherSources","every","updateConnections","isChecked","updatedConnections","length","undefined","metadata","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.connections?.attributes?.[ attributeName ]?.source\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 updateConnections( isChecked ) {\n\t\tlet updatedConnections = {\n\t\t\t...attributes.connections,\n\t\t\tattributes: { ...attributes.connections?.attributes },\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\tupdatedConnections.attributes[ attributeName ]?.source ===\n\t\t\t\t\t'pattern_attributes'\n\t\t\t\t) {\n\t\t\t\t\tdelete updatedConnections.attributes[ attributeName ];\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( ! Object.keys( updatedConnections.attributes ).length ) {\n\t\t\t\tdelete updatedConnections.attributes;\n\t\t\t}\n\t\t\tif ( ! Object.keys( updatedConnections ).length ) {\n\t\t\t\tupdatedConnections = undefined;\n\t\t\t}\n\t\t\tsetAttributes( {\n\t\t\t\tconnections: updatedConnections,\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 ( ! updatedConnections.attributes[ attributeName ] ) {\n\t\t\t\tupdatedConnections.attributes[ attributeName ] = {\n\t\t\t\t\tsource: 'pattern_attributes',\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( { connections: updatedConnections } );\n\t\t\treturn;\n\t\t}\n\n\t\tconst id = nanoid( 6 );\n\t\tsetAttributes( {\n\t\t\tconnections: updatedConnections,\n\t\t\tmetadata: {\n\t\t\t\t...attributes.metadata,\n\t\t\t\tid,\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\tupdateConnections( 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,MA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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);
24
+ const attributeSources = Object.keys(syncedAttributes).map(attributeName => attributes.connections?.attributes?.[attributeName]?.source);
25
25
  const isConnectedToOtherSources = attributeSources.every(source => source && source !== 'pattern_attributes');
26
26
 
27
27
  // Render nothing if all supported attributes are connected to other sources.
28
28
  if (isConnectedToOtherSources) {
29
29
  return null;
30
30
  }
31
- function updateBindings(isChecked) {
32
- let updatedBindings = {
33
- ...attributes?.metadata?.bindings
31
+ function updateConnections(isChecked) {
32
+ let updatedConnections = {
33
+ ...attributes.connections,
34
+ attributes: {
35
+ ...attributes.connections?.attributes
36
+ }
34
37
  };
35
38
  if (!isChecked) {
36
39
  for (const attributeName of Object.keys(syncedAttributes)) {
37
- if (updatedBindings[attributeName]?.source?.name === 'pattern_attributes') {
38
- delete updatedBindings[attributeName];
40
+ if (updatedConnections.attributes[attributeName]?.source === 'pattern_attributes') {
41
+ delete updatedConnections.attributes[attributeName];
39
42
  }
40
43
  }
41
- if (!Object.keys(updatedBindings).length) {
42
- updatedBindings = undefined;
44
+ if (!Object.keys(updatedConnections.attributes).length) {
45
+ delete updatedConnections.attributes;
46
+ }
47
+ if (!Object.keys(updatedConnections).length) {
48
+ updatedConnections = undefined;
43
49
  }
44
50
  setAttributes({
45
- metadata: {
46
- ...attributes.metadata,
47
- bindings: updatedBindings
48
- }
51
+ connections: updatedConnections
49
52
  });
50
53
  return;
51
54
  }
52
55
  for (const attributeName of Object.keys(syncedAttributes)) {
53
- if (!updatedBindings[attributeName]) {
54
- updatedBindings[attributeName] = {
55
- source: {
56
- name: 'pattern_attributes'
57
- }
56
+ if (!updatedConnections.attributes[attributeName]) {
57
+ updatedConnections.attributes[attributeName] = {
58
+ source: 'pattern_attributes'
58
59
  };
59
60
  }
60
61
  }
61
62
  if (typeof attributes.metadata?.id === 'string') {
62
63
  setAttributes({
63
- metadata: {
64
- ...attributes.metadata,
65
- bindings: updatedBindings
66
- }
64
+ connections: updatedConnections
67
65
  });
68
66
  return;
69
67
  }
70
68
  const id = nanoid(6);
71
69
  setAttributes({
70
+ connections: updatedConnections,
72
71
  metadata: {
73
72
  ...attributes.metadata,
74
- id,
75
- bindings: updatedBindings
73
+ id
76
74
  }
77
75
  });
78
76
  }
@@ -85,7 +83,7 @@ function PartialSyncingControls({
85
83
  label: __('Allow instance overrides'),
86
84
  checked: attributeSources.some(source => source === 'pattern_attributes'),
87
85
  onChange: isChecked => {
88
- updateBindings(isChecked);
86
+ updateConnections(isChecked);
89
87
  }
90
88
  })));
91
89
  }
@@ -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,E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ACzB,WAAW,CAAC4B,WAAW,QACrB1B,EAAE,CAAE,mBAAoB,CACF,CAAC,EAC1BuB,aAAA,CAACxB,eAAe;IACf0B,uBAAuB;IACvBE,KAAK,EAAG3B,EAAE,CAAE,0BAA2B,CAAG;IAC1C4B,OAAO,EAAGrB,gBAAgB,CAACsB,IAAI,CAC5Bf,MAAM,IAAMA,MAAM,KAAK,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","connections","source","isConnectedToOtherSources","every","updateConnections","isChecked","updatedConnections","length","undefined","metadata","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.connections?.attributes?.[ attributeName ]?.source\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 updateConnections( isChecked ) {\n\t\tlet updatedConnections = {\n\t\t\t...attributes.connections,\n\t\t\tattributes: { ...attributes.connections?.attributes },\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\tupdatedConnections.attributes[ attributeName ]?.source ===\n\t\t\t\t\t'pattern_attributes'\n\t\t\t\t) {\n\t\t\t\t\tdelete updatedConnections.attributes[ attributeName ];\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( ! Object.keys( updatedConnections.attributes ).length ) {\n\t\t\t\tdelete updatedConnections.attributes;\n\t\t\t}\n\t\t\tif ( ! Object.keys( updatedConnections ).length ) {\n\t\t\t\tupdatedConnections = undefined;\n\t\t\t}\n\t\t\tsetAttributes( {\n\t\t\t\tconnections: updatedConnections,\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 ( ! updatedConnections.attributes[ attributeName ] ) {\n\t\t\t\tupdatedConnections.attributes[ attributeName ] = {\n\t\t\t\t\tsource: 'pattern_attributes',\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( { connections: updatedConnections } );\n\t\t\treturn;\n\t\t}\n\n\t\tconst id = nanoid( 6 );\n\t\tsetAttributes( {\n\t\t\tconnections: updatedConnections,\n\t\t\tmetadata: {\n\t\t\t\t...attributes.metadata,\n\t\t\t\tid,\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\tupdateConnections( 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,WAAW,EAAER,UAAU,GAAIO,aAAa,CAAE,EAAEE,MACzD,CAAC;EACD,MAAMC,yBAAyB,GAAGP,gBAAgB,CAACQ,KAAK,CACrDF,MAAM,IAAMA,MAAM,IAAIA,MAAM,KAAK,oBACpC,CAAC;;EAED;EACA,IAAKC,yBAAyB,EAAG;IAChC,OAAO,IAAI;EACZ;EAEA,SAASE,iBAAiBA,CAAEC,SAAS,EAAG;IACvC,IAAIC,kBAAkB,GAAG;MACxB,GAAGd,UAAU,CAACQ,WAAW;MACzBR,UAAU,EAAE;QAAE,GAAGA,UAAU,CAACQ,WAAW,EAAER;MAAW;IACrD,CAAC;IAED,IAAK,CAAEa,SAAS,EAAG;MAClB,KAAM,MAAMN,aAAa,IAAIH,MAAM,CA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AAoB,CACF,CAAC,EAC1BuB,aAAA,CAACxB,eAAe;IACf0B,uBAAuB;IACvBE,KAAK,EAAG3B,EAAE,CAAE,0BAA2B,CAAG;IAC1C4B,OAAO,EAAGrB,gBAAgB,CAACsB,IAAI,CAC5BhB,MAAM,IAAMA,MAAM,KAAK,oBAC1B,CAAG;IACHiB,QAAQ,EAAKb,SAAS,IAAM;MAC3BD,iBAAiB,CAAEC,SAAU,CAAC;IAC/B;EAAG,CACH,CACW,CACK,CAAC;AAEtB;AAEA,eAAef,sBAAsB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/patterns",
3
- "version": "1.9.1-next.79a6196f.0",
3
+ "version": "1.10.0",
4
4
  "description": "Management of user pattern editing.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -31,20 +31,20 @@
31
31
  ],
32
32
  "dependencies": {
33
33
  "@babel/runtime": "^7.16.0",
34
- "@wordpress/a11y": "^3.48.1-next.79a6196f.0",
35
- "@wordpress/block-editor": "^12.16.1-next.79a6196f.0",
36
- "@wordpress/blocks": "^12.25.1-next.79a6196f.0",
37
- "@wordpress/components": "^25.15.1-next.79a6196f.0",
38
- "@wordpress/compose": "^6.25.1-next.79a6196f.0",
39
- "@wordpress/core-data": "^6.25.1-next.79a6196f.0",
40
- "@wordpress/data": "^9.18.1-next.79a6196f.0",
41
- "@wordpress/element": "^5.25.1-next.79a6196f.0",
42
- "@wordpress/html-entities": "^3.48.1-next.79a6196f.0",
43
- "@wordpress/i18n": "^4.48.1-next.79a6196f.0",
44
- "@wordpress/icons": "^9.39.1-next.79a6196f.0",
45
- "@wordpress/notices": "^4.16.1-next.79a6196f.0",
46
- "@wordpress/private-apis": "^0.30.1-next.79a6196f.0",
47
- "@wordpress/url": "^3.49.1-next.79a6196f.0",
34
+ "@wordpress/a11y": "^3.49.0",
35
+ "@wordpress/block-editor": "^12.17.0",
36
+ "@wordpress/blocks": "^12.26.0",
37
+ "@wordpress/components": "^25.15.0",
38
+ "@wordpress/compose": "^6.26.0",
39
+ "@wordpress/core-data": "^6.26.0",
40
+ "@wordpress/data": "^9.19.0",
41
+ "@wordpress/element": "^5.26.0",
42
+ "@wordpress/html-entities": "^3.49.0",
43
+ "@wordpress/i18n": "^4.49.0",
44
+ "@wordpress/icons": "^9.40.0",
45
+ "@wordpress/notices": "^4.17.0",
46
+ "@wordpress/private-apis": "^0.31.0",
47
+ "@wordpress/url": "^3.50.0",
48
48
  "nanoid": "^3.3.4"
49
49
  },
50
50
  "peerDependencies": {
@@ -54,5 +54,5 @@
54
54
  "publishConfig": {
55
55
  "access": "public"
56
56
  },
57
- "gitHead": "1e74b942ac0119a22ceaaf5c9594263f3ec516ab"
57
+ "gitHead": "5e6f9caa205d3bfdbac131952b7bf9c6ec60569b"
58
58
  }
@@ -19,7 +19,7 @@ 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.connections?.attributes?.[ attributeName ]?.source
23
23
  );
24
24
  const isConnectedToOtherSources = attributeSources.every(
25
25
  ( source ) => source && source !== 'pattern_attributes'
@@ -30,58 +30,52 @@ function PartialSyncingControls( { name, attributes, setAttributes } ) {
30
30
  return null;
31
31
  }
32
32
 
33
- function updateBindings( isChecked ) {
34
- let updatedBindings = {
35
- ...attributes?.metadata?.bindings,
33
+ function updateConnections( isChecked ) {
34
+ let updatedConnections = {
35
+ ...attributes.connections,
36
+ attributes: { ...attributes.connections?.attributes },
36
37
  };
37
38
 
38
39
  if ( ! isChecked ) {
39
40
  for ( const attributeName of Object.keys( syncedAttributes ) ) {
40
41
  if (
41
- updatedBindings[ attributeName ]?.source?.name ===
42
+ updatedConnections.attributes[ attributeName ]?.source ===
42
43
  'pattern_attributes'
43
44
  ) {
44
- delete updatedBindings[ attributeName ];
45
+ delete updatedConnections.attributes[ attributeName ];
45
46
  }
46
47
  }
47
- if ( ! Object.keys( updatedBindings ).length ) {
48
- updatedBindings = undefined;
48
+ if ( ! Object.keys( updatedConnections.attributes ).length ) {
49
+ delete updatedConnections.attributes;
50
+ }
51
+ if ( ! Object.keys( updatedConnections ).length ) {
52
+ updatedConnections = undefined;
49
53
  }
50
54
  setAttributes( {
51
- metadata: {
52
- ...attributes.metadata,
53
- bindings: updatedBindings,
54
- },
55
+ connections: updatedConnections,
55
56
  } );
56
57
  return;
57
58
  }
58
59
 
59
60
  for ( const attributeName of Object.keys( syncedAttributes ) ) {
60
- if ( ! updatedBindings[ attributeName ] ) {
61
- updatedBindings[ attributeName ] = {
62
- source: {
63
- name: 'pattern_attributes',
64
- },
61
+ if ( ! updatedConnections.attributes[ attributeName ] ) {
62
+ updatedConnections.attributes[ attributeName ] = {
63
+ source: 'pattern_attributes',
65
64
  };
66
65
  }
67
66
  }
68
67
 
69
68
  if ( typeof attributes.metadata?.id === 'string' ) {
70
- setAttributes( {
71
- metadata: {
72
- ...attributes.metadata,
73
- bindings: updatedBindings,
74
- },
75
- } );
69
+ setAttributes( { connections: updatedConnections } );
76
70
  return;
77
71
  }
78
72
 
79
73
  const id = nanoid( 6 );
80
74
  setAttributes( {
75
+ connections: updatedConnections,
81
76
  metadata: {
82
77
  ...attributes.metadata,
83
78
  id,
84
- bindings: updatedBindings,
85
79
  },
86
80
  } );
87
81
  }
@@ -99,7 +93,7 @@ function PartialSyncingControls( { name, attributes, setAttributes } ) {
99
93
  ( source ) => source === 'pattern_attributes'
100
94
  ) }
101
95
  onChange={ ( isChecked ) => {
102
- updateBindings( isChecked );
96
+ updateConnections( isChecked );
103
97
  } }
104
98
  />
105
99
  </BaseControl>