@wordpress/patterns 2.2.0 → 2.3.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
+ ## 2.3.0 (2024-07-10)
6
+
5
7
  ## 2.2.0 (2024-06-26)
6
8
 
7
9
  ## 2.1.0 (2024-06-15)
@@ -47,7 +47,7 @@ function PatternOverridesControls({
47
47
  const [showDisallowOverridesModal, setShowDisallowOverridesModal] = (0, _element.useState)(false);
48
48
  const hasName = !!attributes.metadata?.name;
49
49
  const defaultBindings = attributes.metadata?.bindings?.__default;
50
- const allowOverrides = hasName && defaultBindings?.source === _constants.PATTERN_OVERRIDES_BINDING_SOURCE;
50
+ const hasOverrides = hasName && defaultBindings?.source === _constants.PATTERN_OVERRIDES_BINDING_SOURCE;
51
51
  const isConnectedToOtherSources = defaultBindings?.source && defaultBindings.source !== _constants.PATTERN_OVERRIDES_BINDING_SOURCE;
52
52
  function updateBindings(isChecked, customName) {
53
53
  const prevBindings = attributes?.metadata?.bindings;
@@ -69,7 +69,7 @@ function PatternOverridesControls({
69
69
  return null;
70
70
  }
71
71
  const hasUnsupportedImageAttributes = blockName === 'core/image' && (!!attributes.caption?.length || !!attributes.href?.length);
72
- const helpText = hasUnsupportedImageAttributes ? (0, _i18n.__)(`Overrides currently don't support image captions or links. Remove the caption or link first before enabling overrides.`) : (0, _i18n.__)('Allow changes to this block throughout instances of this pattern.');
72
+ const helpText = !hasOverrides && hasUnsupportedImageAttributes ? (0, _i18n.__)(`Overrides currently don't support image captions or links. Remove the caption or link first before enabling overrides.`) : (0, _i18n.__)('Allow changes to this block throughout instances of this pattern.');
73
73
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
74
74
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_blockEditor.InspectorControls, {
75
75
  group: "advanced",
@@ -83,15 +83,15 @@ function PatternOverridesControls({
83
83
  variant: "secondary",
84
84
  "aria-haspopup": "dialog",
85
85
  onClick: () => {
86
- if (allowOverrides) {
86
+ if (hasOverrides) {
87
87
  setShowDisallowOverridesModal(true);
88
88
  } else {
89
89
  setShowAllowOverridesModal(true);
90
90
  }
91
91
  },
92
- disabled: hasUnsupportedImageAttributes,
93
- __experimentalIsFocusable: true,
94
- children: allowOverrides ? (0, _i18n.__)('Disable overrides') : (0, _i18n.__)('Enable overrides')
92
+ disabled: !hasOverrides && hasUnsupportedImageAttributes,
93
+ accessibleWhenDisabled: true,
94
+ children: hasOverrides ? (0, _i18n.__)('Disable overrides') : (0, _i18n.__)('Enable overrides')
95
95
  })
96
96
  })
97
97
  }), showAllowOverridesModal && /*#__PURE__*/(0, _jsxRuntime.jsx)(_allowOverridesModal.AllowOverridesModal, {
@@ -1 +1 @@
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","name","blockName","controlId","useId","showAllowOverridesModal","setShowAllowOverridesModal","useState","showDisallowOverridesModal","setShowDisallowOverridesModal","hasName","metadata","defaultBindings","allowOverrides","isConnectedToOtherSources","updateBindings","isChecked","customName","prevBindings","updatedMetadata","hasUnsupportedImageAttributes","caption","href","helpText","__","jsxs","Fragment","children","jsx","InspectorControls","group","BaseControl","id","label","help","Button","__next40pxDefaultSize","className","variant","onClick","disabled","__experimentalIsFocusable","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( {\n\tattributes,\n\tsetAttributes,\n\tname: blockName,\n} ) {\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\tconst hasUnsupportedImageAttributes =\n\t\tblockName === 'core/image' &&\n\t\t( !! attributes.caption?.length || !! attributes.href?.length );\n\n\tconst helpText = hasUnsupportedImageAttributes\n\t\t? __(\n\t\t\t\t`Overrides currently don't support image captions or links. Remove the caption or link first before enabling overrides.`\n\t\t )\n\t\t: __(\n\t\t\t\t'Allow changes to this block throughout instances of this pattern.'\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={ helpText }\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\tdisabled={ hasUnsupportedImageAttributes }\n\t\t\t\t\t\t__experimentalIsFocusable\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;EAClCC,UAAU;EACVC,aAAa;EACbC,IAAI,EAAEC;AACP,CAAC,EAAG;EACH,MAAMC,SAAS,GAAG,IAAAC,cAAK,EAAC,CAAC;EACzB,MAAM,CAAEC,uBAAuB,EAAEC,0BAA0B,CAAE,GAC5D,IAAAC,iBAAQ,EAAE,KAAM,CAAC;EAClB,MAAM,CAAEC,0BAA0B,EAAEC,6BAA6B,CAAE,GAClE,IAAAF,iBAAQ,EAAE,KAAM,CAAC;EAElB,MAAMG,OAAO,GAAG,CAAC,CAAEX,UAAU,CAACY,QAAQ,EAAEV,IAAI;E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AAA,GAAAC,OAAA,CAAAC,OAAA,GAEcpD,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","name","blockName","controlId","useId","showAllowOverridesModal","setShowAllowOverridesModal","useState","showDisallowOverridesModal","setShowDisallowOverridesModal","hasName","metadata","defaultBindings","hasOverrides","isConnectedToOtherSources","updateBindings","isChecked","customName","prevBindings","updatedMetadata","hasUnsupportedImageAttributes","caption","href","helpText","__","jsxs","Fragment","children","jsx","InspectorControls","group","BaseControl","id","label","help","Button","__next40pxDefaultSize","className","variant","onClick","disabled","accessibleWhenDisabled","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( {\n\tattributes,\n\tsetAttributes,\n\tname: blockName,\n} ) {\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 hasOverrides =\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\tconst hasUnsupportedImageAttributes =\n\t\tblockName === 'core/image' &&\n\t\t( !! attributes.caption?.length || !! attributes.href?.length );\n\n\tconst helpText =\n\t\t! hasOverrides && hasUnsupportedImageAttributes\n\t\t\t? __(\n\t\t\t\t\t`Overrides currently don't support image captions or links. Remove the caption or link first before enabling overrides.`\n\t\t\t )\n\t\t\t: __(\n\t\t\t\t\t'Allow changes to this block throughout instances of this pattern.'\n\t\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={ helpText }\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 ( hasOverrides ) {\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\tdisabled={\n\t\t\t\t\t\t\t! hasOverrides && hasUnsupportedImageAttributes\n\t\t\t\t\t\t}\n\t\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\t>\n\t\t\t\t\t\t{ hasOverrides\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,GA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BAA6B,CAAE,IAAK,CAAC;YACtC,CAAC,MAAM;cACNH,0BAA0B,CAAE,IAAK,CAAC;YACnC;UACD,CAAG;UACHkC,QAAQ,EACP,CAAE3B,YAAY,IAAIO,6BAClB;UACDqB,sBAAsB;UAAAd,QAAA,EAEpBd,YAAY,GACX,IAAAW,QAAE,EAAE,mBAAoB,CAAC,GACzB,IAAAA,QAAE,EAAE,kBAAmB;QAAC,CACpB;MAAC,CACG;IAAC,CACI,CAAC,EAElBnB,uBAAuB,iBACxB,IAAAnB,WAAA,CAAA0C,GAAA,EAAC3C,oBAAA,CAAAyD,mBAAmB;MACnBC,WAAW,EAAG5C,UAAU,CAACY,QAAQ,EAAEV,IAAM;MACzC2C,OAAO,EAAGA,CAAA,KAAMtC,0BAA0B,CAAE,KAAM,CAAG;MACrDuC,MAAM,EAAKC,OAAO,IAAM;QACvB/B,cAAc,CAAE,IAAI,EAAE+B,OAAQ,CAAC;MAChC;IAAG,CACH,CACD,EACCtC,0BAA0B,iBAC3B,IAAAtB,WAAA,CAAA0C,GAAA,EAAC3C,oBAAA,CAAA8D,sBAAsB;MACtBH,OAAO,EAAGA,CAAA,KAAMnC,6BAA6B,CAAE,KAAM,CAAG;MACxDoC,MAAM,EAAGA,CAAA,KAAM9B,cAAc,CAAE,KAAM;IAAG,CACxC,CACD;EAAA,CACA,CAAC;AAEL;AAAC,IAAAiC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEcpD,wBAAwB","ignoreList":[]}
@@ -70,7 +70,6 @@ function ResetOverridesControl(props) {
70
70
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.ToolbarButton, {
71
71
  onClick: onClick,
72
72
  disabled: !isOverriden,
73
- __experimentalIsFocusable: true,
74
73
  children: (0, _i18n.__)('Reset')
75
74
  })
76
75
  })
@@ -1 +1 @@
1
- {"version":3,"names":["_blockEditor","require","_components","_data","_i18n","_jsxRuntime","CONTENT","ResetOverridesControl","props","name","attributes","metadata","registry","useRegistry","isOverriden","useSelect","select","getBlockAttributes","getBlockParentsByBlockName","blockEditorStore","patternClientId","clientId","overrides","hasOwnProperty","onClick","updateBlockAttributes","__unstableMarkLastChangeAsPersistent","dispatch","newOverrides","Object","keys","length","undefined","jsx","BlockControls","group","children","ToolbarGroup","ToolbarButton","disabled","__experimentalIsFocusable","__"],"sources":["@wordpress/patterns/src/components/reset-overrides-control.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tstore as blockEditorStore,\n\tBlockControls,\n} from '@wordpress/block-editor';\nimport { ToolbarButton, ToolbarGroup } from '@wordpress/components';\nimport { useRegistry, useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\n\nconst CONTENT = 'content';\n\nexport default function ResetOverridesControl( props ) {\n\tconst name = props.attributes.metadata?.name;\n\tconst registry = useRegistry();\n\tconst isOverriden = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! name ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst { getBlockAttributes, getBlockParentsByBlockName } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst [ patternClientId ] = getBlockParentsByBlockName(\n\t\t\t\tprops.clientId,\n\t\t\t\t'core/block',\n\t\t\t\ttrue\n\t\t\t);\n\n\t\t\tif ( ! patternClientId ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst overrides = getBlockAttributes( patternClientId )[ CONTENT ];\n\n\t\t\tif ( ! overrides ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\treturn overrides.hasOwnProperty( name );\n\t\t},\n\t\t[ props.clientId, name ]\n\t);\n\n\tfunction onClick() {\n\t\tconst { getBlockAttributes, getBlockParentsByBlockName } =\n\t\t\tregistry.select( blockEditorStore );\n\t\tconst [ patternClientId ] = getBlockParentsByBlockName(\n\t\t\tprops.clientId,\n\t\t\t'core/block',\n\t\t\ttrue\n\t\t);\n\n\t\tif ( ! patternClientId ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst overrides = getBlockAttributes( patternClientId )[ CONTENT ];\n\n\t\tif ( ! overrides.hasOwnProperty( name ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { updateBlockAttributes, __unstableMarkLastChangeAsPersistent } =\n\t\t\tregistry.dispatch( blockEditorStore );\n\t\t__unstableMarkLastChangeAsPersistent();\n\n\t\tlet newOverrides = { ...overrides };\n\t\tdelete newOverrides[ name ];\n\n\t\tif ( ! Object.keys( newOverrides ).length ) {\n\t\t\tnewOverrides = undefined;\n\t\t}\n\n\t\tupdateBlockAttributes( patternClientId, {\n\t\t\t[ CONTENT ]: newOverrides,\n\t\t} );\n\t}\n\n\treturn (\n\t\t<BlockControls group=\"other\">\n\t\t\t<ToolbarGroup>\n\t\t\t\t<ToolbarButton\n\t\t\t\t\tonClick={ onClick }\n\t\t\t\t\tdisabled={ ! isOverriden }\n\t\t\t\t\t__experimentalIsFocusable\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Reset' ) }\n\t\t\t\t</ToolbarButton>\n\t\t\t</ToolbarGroup>\n\t\t</BlockControls>\n\t);\n}\n"],"mappings":";;;;;;AAGA,IAAAA,YAAA,GAAAC,OAAA;AAIA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AAAqC,IAAAI,WAAA,GAAAJ,OAAA;AATrC;AACA;AACA;;AASA,MAAMK,OAAO,GAAG,SAAS;AAEV,SAASC,qBAAqBA,CAAEC,KAAK,EAAG;EACtD,MAAMC,IAAI,GAAGD,KAAK,CAACE,UAAU,CAACC,QAAQ,EAAEF,IAAI;EAC5C,MAAMG,QAAQ,GAAG,IAAAC,iBAAW,EAAC,CAAC;EAC9B,MAAMC,WAAW,GAAG,IAAAC,eAAS,EAC1BC,MAAM,IAAM;IACb,IAAK,CAAEP,IAAI,EAAG;MACb;IACD;IAEA,MAAM;MAAEQ,kBAAkB;MAAEC;IAA2B,CAAC,GACvDF,MAAM,CAAEG,kBAAiB,CAAC;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CAAA4B,GAAA,EAACjC,YAAA,CAAAkC,aAAa;IAACC,KAAK,EAAC,OAAO;IAAAC,QAAA,eAC3B,IAAA/B,WAAA,CAAA4B,GAAA,EAAC/B,WAAA,CAAAmC,YAAY;MAAAD,QAAA,eACZ,IAAA/B,WAAA,CAAA4B,GAAA,EAAC/B,WAAA,CAAAoC,aAAa;QACbd,OAAO,EAAGA,OAAS;QACnBe,QAAQ,EAAG,CAAEzB,WAAa;QAC1B0B,yBAAyB;QAAAJ,QAAA,EAEvB,IAAAK,QAAE,EAAE,OAAQ;MAAC,CACD;IAAC,CACH;EAAC,CACD,CAAC;AAElB","ignoreList":[]}
1
+ {"version":3,"names":["_blockEditor","require","_components","_data","_i18n","_jsxRuntime","CONTENT","ResetOverridesControl","props","name","attributes","metadata","registry","useRegistry","isOverriden","useSelect","select","getBlockAttributes","getBlockParentsByBlockName","blockEditorStore","patternClientId","clientId","overrides","hasOwnProperty","onClick","updateBlockAttributes","__unstableMarkLastChangeAsPersistent","dispatch","newOverrides","Object","keys","length","undefined","jsx","BlockControls","group","children","ToolbarGroup","ToolbarButton","disabled","__"],"sources":["@wordpress/patterns/src/components/reset-overrides-control.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tstore as blockEditorStore,\n\tBlockControls,\n} from '@wordpress/block-editor';\nimport { ToolbarButton, ToolbarGroup } from '@wordpress/components';\nimport { useRegistry, useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\n\nconst CONTENT = 'content';\n\nexport default function ResetOverridesControl( props ) {\n\tconst name = props.attributes.metadata?.name;\n\tconst registry = useRegistry();\n\tconst isOverriden = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! name ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst { getBlockAttributes, getBlockParentsByBlockName } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst [ patternClientId ] = getBlockParentsByBlockName(\n\t\t\t\tprops.clientId,\n\t\t\t\t'core/block',\n\t\t\t\ttrue\n\t\t\t);\n\n\t\t\tif ( ! patternClientId ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst overrides = getBlockAttributes( patternClientId )[ CONTENT ];\n\n\t\t\tif ( ! overrides ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\treturn overrides.hasOwnProperty( name );\n\t\t},\n\t\t[ props.clientId, name ]\n\t);\n\n\tfunction onClick() {\n\t\tconst { getBlockAttributes, getBlockParentsByBlockName } =\n\t\t\tregistry.select( blockEditorStore );\n\t\tconst [ patternClientId ] = getBlockParentsByBlockName(\n\t\t\tprops.clientId,\n\t\t\t'core/block',\n\t\t\ttrue\n\t\t);\n\n\t\tif ( ! patternClientId ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst overrides = getBlockAttributes( patternClientId )[ CONTENT ];\n\n\t\tif ( ! overrides.hasOwnProperty( name ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { updateBlockAttributes, __unstableMarkLastChangeAsPersistent } =\n\t\t\tregistry.dispatch( blockEditorStore );\n\t\t__unstableMarkLastChangeAsPersistent();\n\n\t\tlet newOverrides = { ...overrides };\n\t\tdelete newOverrides[ name ];\n\n\t\tif ( ! Object.keys( newOverrides ).length ) {\n\t\t\tnewOverrides = undefined;\n\t\t}\n\n\t\tupdateBlockAttributes( patternClientId, {\n\t\t\t[ CONTENT ]: newOverrides,\n\t\t} );\n\t}\n\n\treturn (\n\t\t<BlockControls group=\"other\">\n\t\t\t<ToolbarGroup>\n\t\t\t\t<ToolbarButton onClick={ onClick } disabled={ ! isOverriden }>\n\t\t\t\t\t{ __( 'Reset' ) }\n\t\t\t\t</ToolbarButton>\n\t\t\t</ToolbarGroup>\n\t\t</BlockControls>\n\t);\n}\n"],"mappings":";;;;;;AAGA,IAAAA,YAAA,GAAAC,OAAA;AAIA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AAAqC,I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EgB,qBAAqB;MAAEC;IAAqC,CAAC,GACpEd,QAAQ,CAACe,QAAQ,CAAER,kBAAiB,CAAC;IACtCO,oCAAoC,CAAC,CAAC;IAEtC,IAAIE,YAAY,GAAG;MAAE,GAAGN;IAAU,CAAC;IACnC,OAAOM,YAAY,CAAEnB,IAAI,CAAE;IAE3B,IAAK,CAAEoB,MAAM,CAACC,IAAI,CAAEF,YAAa,CAAC,CAACG,MAAM,EAAG;MAC3CH,YAAY,GAAGI,SAAS;IACzB;IAEAP,qBAAqB,CAAEL,eAAe,EAAE;MACvC,CAAEd,OAAO,GAAIsB;IACd,CAAE,CAAC;EACJ;EAEA,oBACC,IAAAvB,WAAA,CAAA4B,GAAA,EAACjC,YAAA,CAAAkC,aAAa;IAACC,KAAK,EAAC,OAAO;IAAAC,QAAA,eAC3B,IAAA/B,WAAA,CAAA4B,GAAA,EAAC/B,WAAA,CAAAmC,YAAY;MAAAD,QAAA,eACZ,IAAA/B,WAAA,CAAA4B,GAAA,EAAC/B,WAAA,CAAAoC,aAAa;QAACd,OAAO,EAAGA,OAAS;QAACe,QAAQ,EAAG,CAAEzB,WAAa;QAAAsB,QAAA,EAC1D,IAAAI,QAAE,EAAE,OAAQ;MAAC,CACD;IAAC,CACH;EAAC,CACD,CAAC;AAElB","ignoreList":[]}
@@ -42,7 +42,7 @@ function PatternOverridesControls({
42
42
  const [showDisallowOverridesModal, setShowDisallowOverridesModal] = useState(false);
43
43
  const hasName = !!attributes.metadata?.name;
44
44
  const defaultBindings = attributes.metadata?.bindings?.__default;
45
- const allowOverrides = hasName && defaultBindings?.source === PATTERN_OVERRIDES_BINDING_SOURCE;
45
+ const hasOverrides = hasName && defaultBindings?.source === PATTERN_OVERRIDES_BINDING_SOURCE;
46
46
  const isConnectedToOtherSources = defaultBindings?.source && defaultBindings.source !== PATTERN_OVERRIDES_BINDING_SOURCE;
47
47
  function updateBindings(isChecked, customName) {
48
48
  const prevBindings = attributes?.metadata?.bindings;
@@ -64,7 +64,7 @@ function PatternOverridesControls({
64
64
  return null;
65
65
  }
66
66
  const hasUnsupportedImageAttributes = blockName === 'core/image' && (!!attributes.caption?.length || !!attributes.href?.length);
67
- const helpText = hasUnsupportedImageAttributes ? __(`Overrides currently don't support image captions or links. Remove the caption or link first before enabling overrides.`) : __('Allow changes to this block throughout instances of this pattern.');
67
+ const helpText = !hasOverrides && hasUnsupportedImageAttributes ? __(`Overrides currently don't support image captions or links. Remove the caption or link first before enabling overrides.`) : __('Allow changes to this block throughout instances of this pattern.');
68
68
  return /*#__PURE__*/_jsxs(_Fragment, {
69
69
  children: [/*#__PURE__*/_jsx(InspectorControls, {
70
70
  group: "advanced",
@@ -78,15 +78,15 @@ function PatternOverridesControls({
78
78
  variant: "secondary",
79
79
  "aria-haspopup": "dialog",
80
80
  onClick: () => {
81
- if (allowOverrides) {
81
+ if (hasOverrides) {
82
82
  setShowDisallowOverridesModal(true);
83
83
  } else {
84
84
  setShowAllowOverridesModal(true);
85
85
  }
86
86
  },
87
- disabled: hasUnsupportedImageAttributes,
88
- __experimentalIsFocusable: true,
89
- children: allowOverrides ? __('Disable overrides') : __('Enable overrides')
87
+ disabled: !hasOverrides && hasUnsupportedImageAttributes,
88
+ accessibleWhenDisabled: true,
89
+ children: hasOverrides ? __('Disable overrides') : __('Enable overrides')
90
90
  })
91
91
  })
92
92
  }), showAllowOverridesModal && /*#__PURE__*/_jsx(AllowOverridesModal, {
@@ -1 +1 @@
1
- {"version":3,"names":["useState","useId","InspectorControls","BaseControl","Button","__","PATTERN_OVERRIDES_BINDING_SOURCE","AllowOverridesModal","DisallowOverridesModal","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","removeBindings","bindings","updatedBindings","__default","Object","keys","length","undefined","addBindings","source","PatternOverridesControls","attributes","setAttributes","name","blockName","controlId","showAllowOverridesModal","setShowAllowOverridesModal","showDisallowOverridesModal","setShowDisallowOverridesModal","hasName","metadata","defaultBindings","allowOverrides","isConnectedToOtherSources","updateBindings","isChecked","customName","prevBindings","updatedMetadata","hasUnsupportedImageAttributes","caption","href","helpText","children","group","id","label","help","__next40pxDefaultSize","className","variant","onClick","disabled","__experimentalIsFocusable","initialName","onClose","onSave","newName"],"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( {\n\tattributes,\n\tsetAttributes,\n\tname: blockName,\n} ) {\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\tconst hasUnsupportedImageAttributes =\n\t\tblockName === 'core/image' &&\n\t\t( !! attributes.caption?.length || !! attributes.href?.length );\n\n\tconst helpText = hasUnsupportedImageAttributes\n\t\t? __(\n\t\t\t\t`Overrides currently don't support image captions or links. Remove the caption or link first before enabling overrides.`\n\t\t )\n\t\t: __(\n\t\t\t\t'Allow changes to this block throughout instances of this pattern.'\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={ helpText }\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\tdisabled={ hasUnsupportedImageAttributes }\n\t\t\t\t\t\t__experimentalIsFocusable\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":"AAAA;AACA;AACA;AACA,SAASA,QAAQ,EAAEC,KAAK,QAAQ,oBAAoB;AACpD,SAASC,iBAAiB,QAAQ,yBAAyB;AAC3D,SAASC,WAAW,EAAEC,MAAM,QAAQ,uBAAuB;AAC3D,SAASC,EAAE,QAAQ,iBAAiB;;AAEpC;AACA;AACA;AACA,SAASC,gCAAgC,QAAQ,cAAc;AAC/D,SACCC,mBAAmB,EACnBC,sBAAsB,QAChB,yBAAyB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC,QAAA,IAAAC,SAAA;AAAA,SAAAC,IAAA,IAAAC,KAAA;AAEjC,SAASC,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,MA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EAAGA,CAAA,KAAM3B,6BAA6B,CAAE,KAAM,CAAG;MACxD4B,MAAM,EAAGA,CAAA,KAAMtB,cAAc,CAAE,KAAM;IAAG,CACxC,CACD;EAAA,CACA,CAAC;AAEL;AAEA,eAAef,wBAAwB","ignoreList":[]}
1
+ {"version":3,"names":["useState","useId","InspectorControls","BaseControl","Button","__","PATTERN_OVERRIDES_BINDING_SOURCE","AllowOverridesModal","DisallowOverridesModal","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","removeBindings","bindings","updatedBindings","__default","Object","keys","length","undefined","addBindings","source","PatternOverridesControls","attributes","setAttributes","name","blockName","controlId","showAllowOverridesModal","setShowAllowOverridesModal","showDisallowOverridesModal","setShowDisallowOverridesModal","hasName","metadata","defaultBindings","hasOverrides","isConnectedToOtherSources","updateBindings","isChecked","customName","prevBindings","updatedMetadata","hasUnsupportedImageAttributes","caption","href","helpText","children","group","id","label","help","__next40pxDefaultSize","className","variant","onClick","disabled","accessibleWhenDisabled","initialName","onClose","onSave","newName"],"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( {\n\tattributes,\n\tsetAttributes,\n\tname: blockName,\n} ) {\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 hasOverrides =\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\tconst hasUnsupportedImageAttributes =\n\t\tblockName === 'core/image' &&\n\t\t( !! attributes.caption?.length || !! attributes.href?.length );\n\n\tconst helpText =\n\t\t! hasOverrides && hasUnsupportedImageAttributes\n\t\t\t? __(\n\t\t\t\t\t`Overrides currently don't support image captions or links. Remove the caption or link first before enabling overrides.`\n\t\t\t )\n\t\t\t: __(\n\t\t\t\t\t'Allow changes to this block throughout instances of this pattern.'\n\t\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={ helpText }\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 ( hasOverrides ) {\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\tdisabled={\n\t\t\t\t\t\t\t! hasOverrides && hasUnsupportedImageAttributes\n\t\t\t\t\t\t}\n\t\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\t>\n\t\t\t\t\t\t{ hasOverrides\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":"AAAA;AACA;AACA;AACA,SAASA,QAAQ,EAAEC,KAAK,QAAQ,oBAAoB;AACpD,SAASC,iBAAiB,QAAQ,yBAAyB;AAC3D,SAASC,WAAW,EAAEC,MAAM,QAAQ,uBAAuB;A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cACnBJ,6BAA6B,CAAE,IAAK,CAAC;YACtC,CAAC,MAAM;cACNF,0BAA0B,CAAE,IAAK,CAAC;YACnC;UACD,CAAG;UACH0B,QAAQ,EACP,CAAEpB,YAAY,IAAIO,6BAClB;UACDc,sBAAsB;UAAAV,QAAA,EAEpBX,YAAY,GACXjC,EAAE,CAAE,mBAAoB,CAAC,GACzBA,EAAE,CAAE,kBAAmB;QAAC,CACpB;MAAC,CACG;IAAC,CACI,CAAC,EAElB0B,uBAAuB,iBACxBrB,IAAA,CAACH,mBAAmB;MACnBqD,WAAW,EAAGlC,UAAU,CAACU,QAAQ,EAAER,IAAM;MACzCiC,OAAO,EAAGA,CAAA,KAAM7B,0BAA0B,CAAE,KAAM,CAAG;MACrD8B,MAAM,EAAKC,OAAO,IAAM;QACvBvB,cAAc,CAAE,IAAI,EAAEuB,OAAQ,CAAC;MAChC;IAAG,CACH,CACD,EACC9B,0BAA0B,iBAC3BvB,IAAA,CAACF,sBAAsB;MACtBqD,OAAO,EAAGA,CAAA,KAAM3B,6BAA6B,CAAE,KAAM,CAAG;MACxD4B,MAAM,EAAGA,CAAA,KAAMtB,cAAc,CAAE,KAAM;IAAG,CACxC,CACD;EAAA,CACA,CAAC;AAEL;AAEA,eAAef,wBAAwB","ignoreList":[]}
@@ -63,7 +63,6 @@ export default function ResetOverridesControl(props) {
63
63
  children: /*#__PURE__*/_jsx(ToolbarButton, {
64
64
  onClick: onClick,
65
65
  disabled: !isOverriden,
66
- __experimentalIsFocusable: true,
67
66
  children: __('Reset')
68
67
  })
69
68
  })
@@ -1 +1 @@
1
- {"version":3,"names":["store","blockEditorStore","BlockControls","ToolbarButton","ToolbarGroup","useRegistry","useSelect","__","jsx","_jsx","CONTENT","ResetOverridesControl","props","name","attributes","metadata","registry","isOverriden","select","getBlockAttributes","getBlockParentsByBlockName","patternClientId","clientId","overrides","hasOwnProperty","onClick","updateBlockAttributes","__unstableMarkLastChangeAsPersistent","dispatch","newOverrides","Object","keys","length","undefined","group","children","disabled","__experimentalIsFocusable"],"sources":["@wordpress/patterns/src/components/reset-overrides-control.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tstore as blockEditorStore,\n\tBlockControls,\n} from '@wordpress/block-editor';\nimport { ToolbarButton, ToolbarGroup } from '@wordpress/components';\nimport { useRegistry, useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\n\nconst CONTENT = 'content';\n\nexport default function ResetOverridesControl( props ) {\n\tconst name = props.attributes.metadata?.name;\n\tconst registry = useRegistry();\n\tconst isOverriden = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! name ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst { getBlockAttributes, getBlockParentsByBlockName } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst [ patternClientId ] = getBlockParentsByBlockName(\n\t\t\t\tprops.clientId,\n\t\t\t\t'core/block',\n\t\t\t\ttrue\n\t\t\t);\n\n\t\t\tif ( ! patternClientId ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst overrides = getBlockAttributes( patternClientId )[ CONTENT ];\n\n\t\t\tif ( ! overrides ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\treturn overrides.hasOwnProperty( name );\n\t\t},\n\t\t[ props.clientId, name ]\n\t);\n\n\tfunction onClick() {\n\t\tconst { getBlockAttributes, getBlockParentsByBlockName } =\n\t\t\tregistry.select( blockEditorStore );\n\t\tconst [ patternClientId ] = getBlockParentsByBlockName(\n\t\t\tprops.clientId,\n\t\t\t'core/block',\n\t\t\ttrue\n\t\t);\n\n\t\tif ( ! patternClientId ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst overrides = getBlockAttributes( patternClientId )[ CONTENT ];\n\n\t\tif ( ! overrides.hasOwnProperty( name ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { updateBlockAttributes, __unstableMarkLastChangeAsPersistent } =\n\t\t\tregistry.dispatch( blockEditorStore );\n\t\t__unstableMarkLastChangeAsPersistent();\n\n\t\tlet newOverrides = { ...overrides };\n\t\tdelete newOverrides[ name ];\n\n\t\tif ( ! Object.keys( newOverrides ).length ) {\n\t\t\tnewOverrides = undefined;\n\t\t}\n\n\t\tupdateBlockAttributes( patternClientId, {\n\t\t\t[ CONTENT ]: newOverrides,\n\t\t} );\n\t}\n\n\treturn (\n\t\t<BlockControls group=\"other\">\n\t\t\t<ToolbarGroup>\n\t\t\t\t<ToolbarButton\n\t\t\t\t\tonClick={ onClick }\n\t\t\t\t\tdisabled={ ! isOverriden }\n\t\t\t\t\t__experimentalIsFocusable\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Reset' ) }\n\t\t\t\t</ToolbarButton>\n\t\t\t</ToolbarGroup>\n\t\t</BlockControls>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SACCA,KAAK,IAAIC,gBAAgB,EACzBC,aAAa,QACP,yBAAyB;AAChC,SAASC,aAAa,EAAEC,YAAY,QAAQ,uBAAuB;AACnE,SAASC,WAAW,EAAEC,SAAS,QAAQ,iBAAiB;AACxD,SAASC,EAAE,QAAQ,iBAAiB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAErC,MAAMC,OAAO,GAAG,SAAS;AAEzB,eAAe,SAASC,qBAAqBA,CAAEC,KAAK,EAAG;EACtD,MAAMC,IAAI,GAAGD,KAAK,CAACE,UAAU,CAACC,QAAQ,EAAEF,IAAI;EAC5C,MAAMG,QAAQ,GAAGX,WAAW,CAAC,CAAC;EAC9B,MAAMY,WAAW,GAAGX,SAAS,CAC1BY,MAAM,IAAM;IACb,IAAK,CAAEL,IAAI,EAAG;MACb;IACD;IAEA,MAAM;MAAEM,kBAAkB;MAAEC;IAA2B,CAAC,GACvDF,MAAM,CAAEjB,gBAAiB,CAAC;IAC3B,MAAM,CAAEoB,eAAe,CAAE,GAAGD,0BAA0B,CACrDR,KAAK,CAACU,QAAQ,EACd,YAAY,EACZ,IACD,CAAC;IAED,IAAK,CAAED,eAAe,EAA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EAAGA,OAAS;QACnBW,QAAQ,EAAG,CAAEnB,WAAa;QAC1BoB,yBAAyB;QAAAF,QAAA,EAEvB5B,EAAE,CAAE,OAAQ;MAAC,CACD;IAAC,CACH;EAAC,CACD,CAAC;AAElB","ignoreList":[]}
1
+ {"version":3,"names":["store","blockEditorStore","BlockControls","ToolbarButton","ToolbarGroup","useRegistry","useSelect","__","jsx","_jsx","CONTENT","ResetOverridesControl","props","name","attributes","metadata","registry","isOverriden","select","getBlockAttributes","getBlockParentsByBlockName","patternClientId","clientId","overrides","hasOwnProperty","onClick","updateBlockAttributes","__unstableMarkLastChangeAsPersistent","dispatch","newOverrides","Object","keys","length","undefined","group","children","disabled"],"sources":["@wordpress/patterns/src/components/reset-overrides-control.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tstore as blockEditorStore,\n\tBlockControls,\n} from '@wordpress/block-editor';\nimport { ToolbarButton, ToolbarGroup } from '@wordpress/components';\nimport { useRegistry, useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\n\nconst CONTENT = 'content';\n\nexport default function ResetOverridesControl( props ) {\n\tconst name = props.attributes.metadata?.name;\n\tconst registry = useRegistry();\n\tconst isOverriden = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! name ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst { getBlockAttributes, getBlockParentsByBlockName } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst [ patternClientId ] = getBlockParentsByBlockName(\n\t\t\t\tprops.clientId,\n\t\t\t\t'core/block',\n\t\t\t\ttrue\n\t\t\t);\n\n\t\t\tif ( ! patternClientId ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst overrides = getBlockAttributes( patternClientId )[ CONTENT ];\n\n\t\t\tif ( ! overrides ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\treturn overrides.hasOwnProperty( name );\n\t\t},\n\t\t[ props.clientId, name ]\n\t);\n\n\tfunction onClick() {\n\t\tconst { getBlockAttributes, getBlockParentsByBlockName } =\n\t\t\tregistry.select( blockEditorStore );\n\t\tconst [ patternClientId ] = getBlockParentsByBlockName(\n\t\t\tprops.clientId,\n\t\t\t'core/block',\n\t\t\ttrue\n\t\t);\n\n\t\tif ( ! patternClientId ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst overrides = getBlockAttributes( patternClientId )[ CONTENT ];\n\n\t\tif ( ! overrides.hasOwnProperty( name ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { updateBlockAttributes, __unstableMarkLastChangeAsPersistent } =\n\t\t\tregistry.dispatch( blockEditorStore );\n\t\t__unstableMarkLastChangeAsPersistent();\n\n\t\tlet newOverrides = { ...overrides };\n\t\tdelete newOverrides[ name ];\n\n\t\tif ( ! Object.keys( newOverrides ).length ) {\n\t\t\tnewOverrides = undefined;\n\t\t}\n\n\t\tupdateBlockAttributes( patternClientId, {\n\t\t\t[ CONTENT ]: newOverrides,\n\t\t} );\n\t}\n\n\treturn (\n\t\t<BlockControls group=\"other\">\n\t\t\t<ToolbarGroup>\n\t\t\t\t<ToolbarButton onClick={ onClick } disabled={ ! isOverriden }>\n\t\t\t\t\t{ __( 'Reset' ) }\n\t\t\t\t</ToolbarButton>\n\t\t\t</ToolbarGroup>\n\t\t</BlockControls>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SACCA,KAAK,IAAIC,gBAAgB,EACzBC,aAAa,QACP,yBAAyB;AAChC,SAASC,aAAa,EAAEC,YAAY,QAAQ,uBAAuB;AACnE,SAASC,WAAW,EAAEC,SAAS,QAAQ,iBAAiB;AACxD,SAASC,EAAE,QAAQ,iBAAiB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAErC,MAAMC,OAAO,GAAG,SAAS;AAEzB,eAAe,SAASC,qBAAqBA,CAAEC,KAAK,EAAG;EACtD,MAAMC,IAAI,GAAGD,KAAK,CAACE,UAAU,CAACC,QAAQ,EAAEF,IAAI;EAC5C,MAAMG,QAAQ,G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AEiB,MAAM,CAACC,IAAI,CAAEF,YAAa,CAAC,CAACG,MAAM,EAAG;MAC3CH,YAAY,GAAGI,SAAS;IACzB;IAEAP,qBAAqB,CAAEL,eAAe,EAAE;MACvC,CAAEX,OAAO,GAAImB;IACd,CAAE,CAAC;EACJ;EAEA,oBACCpB,IAAA,CAACP,aAAa;IAACgC,KAAK,EAAC,OAAO;IAAAC,QAAA,eAC3B1B,IAAA,CAACL,YAAY;MAAA+B,QAAA,eACZ1B,IAAA,CAACN,aAAa;QAACsB,OAAO,EAAGA,OAAS;QAACW,QAAQ,EAAG,CAAEnB,WAAa;QAAAkB,QAAA,EAC1D5B,EAAE,CAAE,OAAQ;MAAC,CACD;IAAC,CACH;EAAC,CACD,CAAC;AAElB","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/patterns",
3
- "version": "2.2.0",
3
+ "version": "2.3.0",
4
4
  "description": "Management of user pattern editing.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -32,20 +32,20 @@
32
32
  ],
33
33
  "dependencies": {
34
34
  "@babel/runtime": "^7.16.0",
35
- "@wordpress/a11y": "^4.2.0",
36
- "@wordpress/block-editor": "^13.2.0",
37
- "@wordpress/blocks": "^13.2.0",
38
- "@wordpress/components": "^28.2.0",
39
- "@wordpress/compose": "^7.2.0",
40
- "@wordpress/core-data": "^7.2.0",
41
- "@wordpress/data": "^10.2.0",
42
- "@wordpress/element": "^6.2.0",
43
- "@wordpress/html-entities": "^4.2.0",
44
- "@wordpress/i18n": "^5.2.0",
45
- "@wordpress/icons": "^10.2.0",
46
- "@wordpress/notices": "^5.2.0",
47
- "@wordpress/private-apis": "^1.2.0",
48
- "@wordpress/url": "^4.2.0"
35
+ "@wordpress/a11y": "^4.3.0",
36
+ "@wordpress/block-editor": "^13.3.0",
37
+ "@wordpress/blocks": "^13.3.0",
38
+ "@wordpress/components": "^28.3.0",
39
+ "@wordpress/compose": "^7.3.0",
40
+ "@wordpress/core-data": "^7.3.0",
41
+ "@wordpress/data": "^10.3.0",
42
+ "@wordpress/element": "^6.3.0",
43
+ "@wordpress/html-entities": "^4.3.0",
44
+ "@wordpress/i18n": "^5.3.0",
45
+ "@wordpress/icons": "^10.3.0",
46
+ "@wordpress/notices": "^5.3.0",
47
+ "@wordpress/private-apis": "^1.3.0",
48
+ "@wordpress/url": "^4.3.0"
49
49
  },
50
50
  "peerDependencies": {
51
51
  "react": "^18.0.0",
@@ -54,5 +54,5 @@
54
54
  "publishConfig": {
55
55
  "access": "public"
56
56
  },
57
- "gitHead": "aa5b14bb5bdbb8d8a02914e154c3bc1c2f18ace6"
57
+ "gitHead": "122867d355ca4edc63d3a3bbd9411d3a2e1458df"
58
58
  }
@@ -44,7 +44,7 @@ function PatternOverridesControls( {
44
44
 
45
45
  const hasName = !! attributes.metadata?.name;
46
46
  const defaultBindings = attributes.metadata?.bindings?.__default;
47
- const allowOverrides =
47
+ const hasOverrides =
48
48
  hasName && defaultBindings?.source === PATTERN_OVERRIDES_BINDING_SOURCE;
49
49
  const isConnectedToOtherSources =
50
50
  defaultBindings?.source &&
@@ -79,13 +79,14 @@ function PatternOverridesControls( {
79
79
  blockName === 'core/image' &&
80
80
  ( !! attributes.caption?.length || !! attributes.href?.length );
81
81
 
82
- const helpText = hasUnsupportedImageAttributes
83
- ? __(
84
- `Overrides currently don't support image captions or links. Remove the caption or link first before enabling overrides.`
85
- )
86
- : __(
87
- 'Allow changes to this block throughout instances of this pattern.'
88
- );
82
+ const helpText =
83
+ ! hasOverrides && hasUnsupportedImageAttributes
84
+ ? __(
85
+ `Overrides currently don't support image captions or links. Remove the caption or link first before enabling overrides.`
86
+ )
87
+ : __(
88
+ 'Allow changes to this block throughout instances of this pattern.'
89
+ );
89
90
 
90
91
  return (
91
92
  <>
@@ -101,16 +102,18 @@ function PatternOverridesControls( {
101
102
  variant="secondary"
102
103
  aria-haspopup="dialog"
103
104
  onClick={ () => {
104
- if ( allowOverrides ) {
105
+ if ( hasOverrides ) {
105
106
  setShowDisallowOverridesModal( true );
106
107
  } else {
107
108
  setShowAllowOverridesModal( true );
108
109
  }
109
110
  } }
110
- disabled={ hasUnsupportedImageAttributes }
111
- __experimentalIsFocusable
111
+ disabled={
112
+ ! hasOverrides && hasUnsupportedImageAttributes
113
+ }
114
+ accessibleWhenDisabled
112
115
  >
113
- { allowOverrides
116
+ { hasOverrides
114
117
  ? __( 'Disable overrides' )
115
118
  : __( 'Enable overrides' ) }
116
119
  </Button>
@@ -81,11 +81,7 @@ export default function ResetOverridesControl( props ) {
81
81
  return (
82
82
  <BlockControls group="other">
83
83
  <ToolbarGroup>
84
- <ToolbarButton
85
- onClick={ onClick }
86
- disabled={ ! isOverriden }
87
- __experimentalIsFocusable
88
- >
84
+ <ToolbarButton onClick={ onClick } disabled={ ! isOverriden }>
89
85
  { __( 'Reset' ) }
90
86
  </ToolbarButton>
91
87
  </ToolbarGroup>