@wordpress/patterns 1.8.0 → 1.9.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.9.0 (2023-12-13)
6
+
5
7
  ## 1.8.0 (2023-11-29)
6
8
 
7
9
  ## 1.7.0 (2023-11-16)
@@ -0,0 +1,91 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _react = require("react");
8
+ var _nanoid = require("nanoid");
9
+ var _blockEditor = require("@wordpress/block-editor");
10
+ var _components = require("@wordpress/components");
11
+ var _i18n = require("@wordpress/i18n");
12
+ var _constants = require("../constants");
13
+ /**
14
+ * External dependencies
15
+ */
16
+
17
+ /**
18
+ * WordPress dependencies
19
+ */
20
+
21
+ /**
22
+ * Internal dependencies
23
+ */
24
+
25
+ function PartialSyncingControls({
26
+ name,
27
+ attributes,
28
+ setAttributes
29
+ }) {
30
+ const syncedAttributes = _constants.PARTIAL_SYNCING_SUPPORTED_BLOCKS[name];
31
+ function updateConnections(attributeName, isChecked) {
32
+ if (!isChecked) {
33
+ let updatedConnections = {
34
+ ...attributes.connections,
35
+ attributes: {
36
+ ...attributes.connections?.attributes,
37
+ [attributeName]: undefined
38
+ }
39
+ };
40
+ if (Object.keys(updatedConnections.attributes).length === 1) {
41
+ updatedConnections.attributes = undefined;
42
+ }
43
+ if (Object.keys(updatedConnections).length === 1 && updateConnections.attributes === undefined) {
44
+ updatedConnections = undefined;
45
+ }
46
+ setAttributes({
47
+ connections: updatedConnections
48
+ });
49
+ return;
50
+ }
51
+ const updatedConnections = {
52
+ ...attributes.connections,
53
+ attributes: {
54
+ ...attributes.connections?.attributes,
55
+ [attributeName]: {
56
+ source: 'pattern_attributes'
57
+ }
58
+ }
59
+ };
60
+ if (typeof attributes.metadata?.id === 'string') {
61
+ setAttributes({
62
+ connections: updatedConnections
63
+ });
64
+ return;
65
+ }
66
+ const id = (0, _nanoid.nanoid)(6);
67
+ setAttributes({
68
+ connections: updatedConnections,
69
+ metadata: {
70
+ ...attributes.metadata,
71
+ id
72
+ }
73
+ });
74
+ }
75
+ return (0, _react.createElement)(_blockEditor.InspectorControls, {
76
+ group: "advanced"
77
+ }, (0, _react.createElement)(_components.BaseControl, {
78
+ __nextHasNoMarginBottom: true
79
+ }, (0, _react.createElement)(_components.BaseControl.VisualLabel, null, (0, _i18n.__)('Synced attributes')), Object.entries(syncedAttributes).map(([attributeName, label]) => (0, _react.createElement)(_components.CheckboxControl, {
80
+ key: attributeName,
81
+ __nextHasNoMarginBottom: true,
82
+ label: label,
83
+ checked: attributes.connections?.attributes?.[attributeName]?.source === 'pattern_attributes',
84
+ onChange: isChecked => {
85
+ updateConnections(attributeName, isChecked);
86
+ }
87
+ }))));
88
+ }
89
+ var _default = PartialSyncingControls;
90
+ exports.default = _default;
91
+ //# sourceMappingURL=partial-syncing-controls.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_nanoid","require","_blockEditor","_components","_i18n","_constants","PartialSyncingControls","name","attributes","setAttributes","syncedAttributes","PARTIAL_SYNCING_SUPPORTED_BLOCKS","updateConnections","attributeName","isChecked","updatedConnections","connections","undefined","Object","keys","length","source","metadata","id","nanoid","_react","createElement","InspectorControls","group","BaseControl","__nextHasNoMarginBottom","VisualLabel","__","entries","map","label","CheckboxControl","key","checked","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\n\tfunction updateConnections( attributeName, isChecked ) {\n\t\tif ( ! isChecked ) {\n\t\t\tlet updatedConnections = {\n\t\t\t\t...attributes.connections,\n\t\t\t\tattributes: {\n\t\t\t\t\t...attributes.connections?.attributes,\n\t\t\t\t\t[ attributeName ]: undefined,\n\t\t\t\t},\n\t\t\t};\n\t\t\tif ( Object.keys( updatedConnections.attributes ).length === 1 ) {\n\t\t\t\tupdatedConnections.attributes = undefined;\n\t\t\t}\n\t\t\tif (\n\t\t\t\tObject.keys( updatedConnections ).length === 1 &&\n\t\t\t\tupdateConnections.attributes === undefined\n\t\t\t) {\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\tconst updatedConnections = {\n\t\t\t...attributes.connections,\n\t\t\tattributes: {\n\t\t\t\t...attributes.connections?.attributes,\n\t\t\t\t[ 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{ __( 'Synced attributes' ) }\n\t\t\t\t</BaseControl.VisualLabel>\n\t\t\t\t{ Object.entries( syncedAttributes ).map(\n\t\t\t\t\t( [ attributeName, label ] ) => (\n\t\t\t\t\t\t<CheckboxControl\n\t\t\t\t\t\t\tkey={ attributeName }\n\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\tlabel={ label }\n\t\t\t\t\t\t\tchecked={\n\t\t\t\t\t\t\t\tattributes.connections?.attributes?.[\n\t\t\t\t\t\t\t\t\tattributeName\n\t\t\t\t\t\t\t\t]?.source === 'pattern_attributes'\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tonChange={ ( isChecked ) => {\n\t\t\t\t\t\t\t\tupdateConnections( attributeName, isChecked );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t)\n\t\t\t\t) }\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;EAEjE,SAASK,iBAAiBA,CAAEC,aAAa,EAAEC,SAAS,EAAG;IACtD,IAAK,CAAEA,SAAS,EAAG;MAClB,IAAIC,kBAAkB,GAAG;QACxB,GAAGP,UAAU,CAACQ,WAAW;QACzBR,UAAU,EAAE;UACX,GAAGA,UAAU,CAACQ,WAAW,EAAER,UAAU;UACrC,CAAEK,aAAa,GAAII;QACpB;MACD,CAAC;MACD,IAAKC,MAAM,CAACC,IAAI,CAAEJ,kBAAkB,CAACP,UAAW,CAAC,CAACY,MAAM,KAAK,CAAC,EAAG;QAChEL,kBAAkB,CAACP,UAAU,GAAGS,SAAS;MAC1C;MACA,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AuB;IACvBK,KAAK,EAAGA,KAAO;IACfG,OAAO,EACN9B,UAAU,CAACQ,WAAW,EAAER,UAAU,GACjCK,aAAa,CACb,EAAEQ,MAAM,KAAK,oBACd;IACDkB,QAAQ,EAAKzB,SAAS,IAAM;MAC3BF,iBAAiB,CAAEC,aAAa,EAAEC,SAAU,CAAC;IAC9C;EAAG,CACH,CAEH,CACY,CACK,CAAC;AAEtB;AAAC,IAAA0B,QAAA,GAEclC,sBAAsB;AAAAmC,OAAA,CAAAC,OAAA,GAAAF,QAAA"}
@@ -122,6 +122,7 @@ function RenamePatternCategoryModal({
122
122
  }, (0, _react.createElement)(_components.TextControl, {
123
123
  ref: textControlRef,
124
124
  __nextHasNoMarginBottom: true,
125
+ __next40pxDefaultSize: true,
125
126
  label: (0, _i18n.__)('Name'),
126
127
  value: name,
127
128
  onChange: onChange,
@@ -133,9 +134,11 @@ function RenamePatternCategoryModal({
133
134
  }, validationMessage)), (0, _react.createElement)(_components.__experimentalHStack, {
134
135
  justify: "right"
135
136
  }, (0, _react.createElement)(_components.Button, {
137
+ __next40pxDefaultSize: true,
136
138
  variant: "tertiary",
137
139
  onClick: onRequestClose
138
140
  }, (0, _i18n.__)('Cancel')), (0, _react.createElement)(_components.Button, {
141
+ __next40pxDefaultSize: true,
139
142
  variant: "primary",
140
143
  type: "submit",
141
144
  "aria-disabled": !name || name === category.name || isSaving,
@@ -1 +1 @@
1
- {"version":3,"names":["_components","require","_coreData","_data","_element","_htmlEntities","_i18n","_notices","_a11y","_categorySelector","RenamePatternCategoryModal","category","existingCategories","onClose","onError","onSuccess","props","id","useId","textControlRef","useRef","name","setName","useState","decodeEntities","isSaving","setIsSaving","validationMessage","setValidationMessage","validationMessageId","undefined","saveEntityRecord","invalidateResolution","useDispatch","coreStore","createErrorNotice","createSuccessNotice","noticesStore","onChange","newName","onSave","event","preventDefault","message","__","speak","current","focus","patternCategories","find","existingCategory","label","toLowerCase","savedRecord","CATEGORY_SLUG","slug","type","error","onRequestClose","_react","createElement","Modal","title","onSubmit","__experimentalVStack","spacing","TextControl","ref","__nextHasNoMarginBottom","value","required","className","__experimentalHStack","justify","Button","variant","onClick","isBusy"],"sources":["@wordpress/patterns/src/components/rename-pattern-category-modal.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tModal,\n\tButton,\n\tTextControl,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useDispatch } from '@wordpress/data';\nimport { useId, useRef, useState } from '@wordpress/element';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { __ } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { speak } from '@wordpress/a11y';\n\n/**\n * Internal dependencies\n */\nimport { CATEGORY_SLUG } from './category-selector';\n\nexport default function RenamePatternCategoryModal( {\n\tcategory,\n\texistingCategories,\n\tonClose,\n\tonError,\n\tonSuccess,\n\t...props\n} ) {\n\tconst id = useId();\n\tconst textControlRef = useRef();\n\tconst [ name, setName ] = useState( decodeEntities( category.name ) );\n\tconst [ isSaving, setIsSaving ] = useState( false );\n\tconst [ validationMessage, setValidationMessage ] = useState( false );\n\tconst validationMessageId = validationMessage\n\t\t? `patterns-rename-pattern-category-modal__validation-message-${ id }`\n\t\t: undefined;\n\n\tconst { saveEntityRecord, invalidateResolution } = useDispatch( coreStore );\n\tconst { createErrorNotice, createSuccessNotice } =\n\t\tuseDispatch( noticesStore );\n\n\tconst onChange = ( newName ) => {\n\t\tif ( validationMessage ) {\n\t\t\tsetValidationMessage( undefined );\n\t\t}\n\t\tsetName( newName );\n\t};\n\n\tconst onSave = async ( event ) => {\n\t\tevent.preventDefault();\n\n\t\tif ( isSaving ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( ! name || name === category.name ) {\n\t\t\tconst message = __( 'Please enter a new name for this category.' );\n\t\t\tspeak( message, 'assertive' );\n\t\t\tsetValidationMessage( message );\n\t\t\ttextControlRef.current?.focus();\n\t\t\treturn;\n\t\t}\n\n\t\t// Check existing categories to avoid creating duplicates.\n\t\tif (\n\t\t\texistingCategories.patternCategories.find( ( existingCategory ) => {\n\t\t\t\t// Compare the id so that the we don't disallow the user changing the case of their current category\n\t\t\t\t// (i.e. renaming 'test' to 'Test').\n\t\t\t\treturn (\n\t\t\t\t\texistingCategory.id !== category.id &&\n\t\t\t\t\texistingCategory.label.toLowerCase() === name.toLowerCase()\n\t\t\t\t);\n\t\t\t} )\n\t\t) {\n\t\t\tconst message = __(\n\t\t\t\t'This category already exists. Please use a different name.'\n\t\t\t);\n\t\t\tspeak( message, 'assertive' );\n\t\t\tsetValidationMessage( message );\n\t\t\ttextControlRef.current?.focus();\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tsetIsSaving( true );\n\n\t\t\t// User pattern category properties may differ as they can be\n\t\t\t// normalized for use alongside template part areas, core pattern\n\t\t\t// categories etc. As a result we won't just destructure the passed\n\t\t\t// category object.\n\t\t\tconst savedRecord = await saveEntityRecord(\n\t\t\t\t'taxonomy',\n\t\t\t\tCATEGORY_SLUG,\n\t\t\t\t{\n\t\t\t\t\tid: category.id,\n\t\t\t\t\tslug: category.slug,\n\t\t\t\t\tname,\n\t\t\t\t}\n\t\t\t);\n\n\t\t\tinvalidateResolution( 'getUserPatternCategories' );\n\t\t\tonSuccess?.( savedRecord );\n\t\t\tonClose();\n\n\t\t\tcreateSuccessNotice( __( 'Pattern category renamed.' ), {\n\t\t\t\ttype: 'snackbar',\n\t\t\t\tid: 'pattern-category-update',\n\t\t\t} );\n\t\t} catch ( error ) {\n\t\t\tonError?.();\n\t\t\tcreateErrorNotice( error.message, {\n\t\t\t\ttype: 'snackbar',\n\t\t\t\tid: 'pattern-category-update',\n\t\t\t} );\n\t\t} finally {\n\t\t\tsetIsSaving( false );\n\t\t\tsetName( '' );\n\t\t}\n\t};\n\n\tconst onRequestClose = () => {\n\t\tonClose();\n\t\tsetName( '' );\n\t};\n\n\treturn (\n\t\t<Modal\n\t\t\ttitle={ __( 'Rename' ) }\n\t\t\tonRequestClose={ onRequestClose }\n\t\t\t{ ...props }\n\t\t>\n\t\t\t<form onSubmit={ onSave }>\n\t\t\t\t<VStack spacing=\"5\">\n\t\t\t\t\t<VStack spacing=\"2\">\n\t\t\t\t\t\t<TextControl\n\t\t\t\t\t\t\tref={ textControlRef }\n\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\tlabel={ __( 'Name' ) }\n\t\t\t\t\t\t\tvalue={ name }\n\t\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\t\taria-describedby={ validationMessageId }\n\t\t\t\t\t\t\trequired\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t{ validationMessage && (\n\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\tclassName=\"patterns-rename-pattern-category-modal__validation-message\"\n\t\t\t\t\t\t\t\tid={ validationMessageId }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ validationMessage }\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</VStack>\n\t\t\t\t\t<HStack justify=\"right\">\n\t\t\t\t\t\t<Button variant=\"tertiary\" onClick={ onRequestClose }>\n\t\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\ttype=\"submit\"\n\t\t\t\t\t\t\taria-disabled={\n\t\t\t\t\t\t\t\t! name || name === category.name || isSaving\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tisBusy={ isSaving }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Save' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</HStack>\n\t\t\t\t</VStack>\n\t\t\t</form>\n\t\t</Modal>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AAOA,IAAA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AA4D;IACtEtD,EAAE,EAAGY;EAAqB,GAExBF,iBACG,CAEA,CAAC,EACT,IAAAgC,MAAA,CAAAC,aAAA,EAAC5D,WAAA,CAAAwE,oBAAM;IAACC,OAAO,EAAC;EAAO,GACtB,IAAAd,MAAA,CAAAC,aAAA,EAAC5D,WAAA,CAAA0E,MAAM;IAACC,OAAO,EAAC,UAAU;IAACC,OAAO,EAAGlB;EAAgB,GAClD,IAAAd,QAAE,EAAE,QAAS,CACR,CAAC,EACT,IAAAe,MAAA,CAAAC,aAAA,EAAC5D,WAAA,CAAA0E,MAAM;IACNC,OAAO,EAAC,SAAS;IACjBnB,IAAI,EAAC,QAAQ;IACb,iBACC,CAAEnC,IAAI,IAAIA,IAAI,KAAKV,QAAQ,CAACU,IAAI,IAAII,QACpC;IACDoD,MAAM,EAAGpD;EAAU,GAEjB,IAAAmB,QAAE,EAAE,MAAO,CACN,CACD,CACD,CACH,CACA,CAAC;AAEV"}
1
+ {"version":3,"names":["_components","require","_coreData","_data","_element","_htmlEntities","_i18n","_notices","_a11y","_categorySelector","RenamePatternCategoryModal","category","existingCategories","onClose","onError","onSuccess","props","id","useId","textControlRef","useRef","name","setName","useState","decodeEntities","isSaving","setIsSaving","validationMessage","setValidationMessage","validationMessageId","undefined","saveEntityRecord","invalidateResolution","useDispatch","coreStore","createErrorNotice","createSuccessNotice","noticesStore","onChange","newName","onSave","event","preventDefault","message","__","speak","current","focus","patternCategories","find","existingCategory","label","toLowerCase","savedRecord","CATEGORY_SLUG","slug","type","error","onRequestClose","_react","createElement","Modal","title","onSubmit","__experimentalVStack","spacing","TextControl","ref","__nextHasNoMarginBottom","__next40pxDefaultSize","value","required","className","__experimentalHStack","justify","Button","variant","onClick","isBusy"],"sources":["@wordpress/patterns/src/components/rename-pattern-category-modal.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tModal,\n\tButton,\n\tTextControl,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useDispatch } from '@wordpress/data';\nimport { useId, useRef, useState } from '@wordpress/element';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { __ } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { speak } from '@wordpress/a11y';\n\n/**\n * Internal dependencies\n */\nimport { CATEGORY_SLUG } from './category-selector';\n\nexport default function RenamePatternCategoryModal( {\n\tcategory,\n\texistingCategories,\n\tonClose,\n\tonError,\n\tonSuccess,\n\t...props\n} ) {\n\tconst id = useId();\n\tconst textControlRef = useRef();\n\tconst [ name, setName ] = useState( decodeEntities( category.name ) );\n\tconst [ isSaving, setIsSaving ] = useState( false );\n\tconst [ validationMessage, setValidationMessage ] = useState( false );\n\tconst validationMessageId = validationMessage\n\t\t? `patterns-rename-pattern-category-modal__validation-message-${ id }`\n\t\t: undefined;\n\n\tconst { saveEntityRecord, invalidateResolution } = useDispatch( coreStore );\n\tconst { createErrorNotice, createSuccessNotice } =\n\t\tuseDispatch( noticesStore );\n\n\tconst onChange = ( newName ) => {\n\t\tif ( validationMessage ) {\n\t\t\tsetValidationMessage( undefined );\n\t\t}\n\t\tsetName( newName );\n\t};\n\n\tconst onSave = async ( event ) => {\n\t\tevent.preventDefault();\n\n\t\tif ( isSaving ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( ! name || name === category.name ) {\n\t\t\tconst message = __( 'Please enter a new name for this category.' );\n\t\t\tspeak( message, 'assertive' );\n\t\t\tsetValidationMessage( message );\n\t\t\ttextControlRef.current?.focus();\n\t\t\treturn;\n\t\t}\n\n\t\t// Check existing categories to avoid creating duplicates.\n\t\tif (\n\t\t\texistingCategories.patternCategories.find( ( existingCategory ) => {\n\t\t\t\t// Compare the id so that the we don't disallow the user changing the case of their current category\n\t\t\t\t// (i.e. renaming 'test' to 'Test').\n\t\t\t\treturn (\n\t\t\t\t\texistingCategory.id !== category.id &&\n\t\t\t\t\texistingCategory.label.toLowerCase() === name.toLowerCase()\n\t\t\t\t);\n\t\t\t} )\n\t\t) {\n\t\t\tconst message = __(\n\t\t\t\t'This category already exists. Please use a different name.'\n\t\t\t);\n\t\t\tspeak( message, 'assertive' );\n\t\t\tsetValidationMessage( message );\n\t\t\ttextControlRef.current?.focus();\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tsetIsSaving( true );\n\n\t\t\t// User pattern category properties may differ as they can be\n\t\t\t// normalized for use alongside template part areas, core pattern\n\t\t\t// categories etc. As a result we won't just destructure the passed\n\t\t\t// category object.\n\t\t\tconst savedRecord = await saveEntityRecord(\n\t\t\t\t'taxonomy',\n\t\t\t\tCATEGORY_SLUG,\n\t\t\t\t{\n\t\t\t\t\tid: category.id,\n\t\t\t\t\tslug: category.slug,\n\t\t\t\t\tname,\n\t\t\t\t}\n\t\t\t);\n\n\t\t\tinvalidateResolution( 'getUserPatternCategories' );\n\t\t\tonSuccess?.( savedRecord );\n\t\t\tonClose();\n\n\t\t\tcreateSuccessNotice( __( 'Pattern category renamed.' ), {\n\t\t\t\ttype: 'snackbar',\n\t\t\t\tid: 'pattern-category-update',\n\t\t\t} );\n\t\t} catch ( error ) {\n\t\t\tonError?.();\n\t\t\tcreateErrorNotice( error.message, {\n\t\t\t\ttype: 'snackbar',\n\t\t\t\tid: 'pattern-category-update',\n\t\t\t} );\n\t\t} finally {\n\t\t\tsetIsSaving( false );\n\t\t\tsetName( '' );\n\t\t}\n\t};\n\n\tconst onRequestClose = () => {\n\t\tonClose();\n\t\tsetName( '' );\n\t};\n\n\treturn (\n\t\t<Modal\n\t\t\ttitle={ __( 'Rename' ) }\n\t\t\tonRequestClose={ onRequestClose }\n\t\t\t{ ...props }\n\t\t>\n\t\t\t<form onSubmit={ onSave }>\n\t\t\t\t<VStack spacing=\"5\">\n\t\t\t\t\t<VStack spacing=\"2\">\n\t\t\t\t\t\t<TextControl\n\t\t\t\t\t\t\tref={ textControlRef }\n\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tlabel={ __( 'Name' ) }\n\t\t\t\t\t\t\tvalue={ name }\n\t\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\t\taria-describedby={ validationMessageId }\n\t\t\t\t\t\t\trequired\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t{ validationMessage && (\n\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\tclassName=\"patterns-rename-pattern-category-modal__validation-message\"\n\t\t\t\t\t\t\t\tid={ validationMessageId }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ validationMessage }\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</VStack>\n\t\t\t\t\t<HStack justify=\"right\">\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\tonClick={ onRequestClose }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\ttype=\"submit\"\n\t\t\t\t\t\t\taria-disabled={\n\t\t\t\t\t\t\t\t! name || name === category.name || isSaving\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tisBusy={ isSaving }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Save' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</HStack>\n\t\t\t\t</VStack>\n\t\t\t</form>\n\t\t</Modal>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AAOA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,aAAA,GAAAJ,OAA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5D,WAAA,CAAAyE,oBAAM;IAACC,OAAO,EAAC;EAAO,GACtB,IAAAf,MAAA,CAAAC,aAAA,EAAC5D,WAAA,CAAA2E,MAAM;IACNN,qBAAqB;IACrBO,OAAO,EAAC,UAAU;IAClBC,OAAO,EAAGnB;EAAgB,GAExB,IAAAd,QAAE,EAAE,QAAS,CACR,CAAC,EACT,IAAAe,MAAA,CAAAC,aAAA,EAAC5D,WAAA,CAAA2E,MAAM;IACNN,qBAAqB;IACrBO,OAAO,EAAC,SAAS;IACjBpB,IAAI,EAAC,QAAQ;IACb,iBACC,CAAEnC,IAAI,IAAIA,IAAI,KAAKV,QAAQ,CAACU,IAAI,IAAII,QACpC;IACDqD,MAAM,EAAGrD;EAAU,GAEjB,IAAAmB,QAAE,EAAE,MAAO,CACN,CACD,CACD,CACH,CACA,CAAC;AAEV"}
@@ -80,6 +80,7 @@ function RenamePatternModal({
80
80
  spacing: "5"
81
81
  }, (0, _react.createElement)(_components.TextControl, {
82
82
  __nextHasNoMarginBottom: true,
83
+ __next40pxDefaultSize: true,
83
84
  label: (0, _i18n.__)('Name'),
84
85
  value: name,
85
86
  onChange: setName,
@@ -87,9 +88,11 @@ function RenamePatternModal({
87
88
  }), (0, _react.createElement)(_components.__experimentalHStack, {
88
89
  justify: "right"
89
90
  }, (0, _react.createElement)(_components.Button, {
91
+ __next40pxDefaultSize: true,
90
92
  variant: "tertiary",
91
93
  onClick: onRequestClose
92
94
  }, (0, _i18n.__)('Cancel')), (0, _react.createElement)(_components.Button, {
95
+ __next40pxDefaultSize: true,
93
96
  variant: "primary",
94
97
  type: "submit"
95
98
  }, (0, _i18n.__)('Save'))))));
@@ -1 +1 @@
1
- {"version":3,"names":["_components","require","_coreData","_data","_element","_htmlEntities","_i18n","_notices","RenamePatternModal","onClose","onError","onSuccess","pattern","props","originalName","decodeEntities","title","name","setName","useState","isSaving","setIsSaving","editEntityRecord","__experimentalSaveSpecifiedEntityEdits","saveSpecifiedEntityEdits","useDispatch","coreStore","createSuccessNotice","createErrorNotice","noticesStore","onRename","event","preventDefault","type","id","savedRecord","throwOnError","__","error","errorMessage","message","code","onRequestClose","_react","createElement","Modal","onSubmit","__experimentalVStack","spacing","TextControl","__nextHasNoMarginBottom","label","value","onChange","required","__experimentalHStack","justify","Button","variant","onClick"],"sources":["@wordpress/patterns/src/components/rename-pattern-modal.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\tModal,\n\tTextControl,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useDispatch } from '@wordpress/data';\nimport { useState } from '@wordpress/element';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { __ } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\n\nexport default function RenamePatternModal( {\n\tonClose,\n\tonError,\n\tonSuccess,\n\tpattern,\n\t...props\n} ) {\n\tconst originalName = decodeEntities( pattern.title );\n\tconst [ name, setName ] = useState( originalName );\n\tconst [ isSaving, setIsSaving ] = useState( false );\n\n\tconst {\n\t\teditEntityRecord,\n\t\t__experimentalSaveSpecifiedEntityEdits: saveSpecifiedEntityEdits,\n\t} = useDispatch( coreStore );\n\n\tconst { createSuccessNotice, createErrorNotice } =\n\t\tuseDispatch( noticesStore );\n\n\tconst onRename = async ( event ) => {\n\t\tevent.preventDefault();\n\n\t\tif ( ! name || name === pattern.title || isSaving ) {\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tawait editEntityRecord( 'postType', pattern.type, pattern.id, {\n\t\t\t\ttitle: name,\n\t\t\t} );\n\n\t\t\tsetIsSaving( true );\n\t\t\tsetName( '' );\n\t\t\tonClose?.();\n\n\t\t\tconst savedRecord = await saveSpecifiedEntityEdits(\n\t\t\t\t'postType',\n\t\t\t\tpattern.type,\n\t\t\t\tpattern.id,\n\t\t\t\t[ 'title' ],\n\t\t\t\t{ throwOnError: true }\n\t\t\t);\n\n\t\t\tonSuccess?.( savedRecord );\n\n\t\t\tcreateSuccessNotice( __( 'Pattern renamed' ), {\n\t\t\t\ttype: 'snackbar',\n\t\t\t\tid: 'pattern-update',\n\t\t\t} );\n\t\t} catch ( error ) {\n\t\t\tonError?.();\n\n\t\t\tconst errorMessage =\n\t\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t\t? error.message\n\t\t\t\t\t: __( 'An error occurred while renaming the pattern.' );\n\n\t\t\tcreateErrorNotice( errorMessage, {\n\t\t\t\ttype: 'snackbar',\n\t\t\t\tid: 'pattern-update',\n\t\t\t} );\n\t\t} finally {\n\t\t\tsetIsSaving( false );\n\t\t\tsetName( '' );\n\t\t}\n\t};\n\n\tconst onRequestClose = () => {\n\t\tonClose?.();\n\t\tsetName( '' );\n\t};\n\n\treturn (\n\t\t<Modal title={ __( 'Rename' ) } { ...props } onRequestClose={ onClose }>\n\t\t\t<form onSubmit={ onRename }>\n\t\t\t\t<VStack spacing=\"5\">\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\tlabel={ __( 'Name' ) }\n\t\t\t\t\t\tvalue={ name }\n\t\t\t\t\t\tonChange={ setName }\n\t\t\t\t\t\trequired\n\t\t\t\t\t/>\n\n\t\t\t\t\t<HStack justify=\"right\">\n\t\t\t\t\t\t<Button variant=\"tertiary\" onClick={ onRequestClose }>\n\t\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t\t</Button>\n\n\t\t\t\t\t\t<Button variant=\"primary\" type=\"submit\">\n\t\t\t\t\t\t\t{ __( 'Save' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</HStack>\n\t\t\t\t</VStack>\n\t\t\t</form>\n\t\t</Modal>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AAOA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA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,aAAA,EAAC5C,WAAA,CAAAuD,oBAAM;IAACC,OAAO,EAAC;EAAO,GACtB,IAAAb,MAAA,CAAAC,aAAA,EAAC5C,WAAA,CAAAyD,MAAM;IAACC,OAAO,EAAC,UAAU;IAACC,OAAO,EAAGjB;EAAgB,GAClD,IAAAL,QAAE,EAAE,QAAS,CACR,CAAC,EAET,IAAAM,MAAA,CAAAC,aAAA,EAAC5C,WAAA,CAAAyD,MAAM;IAACC,OAAO,EAAC,SAAS;IAACzB,IAAI,EAAC;EAAQ,GACpC,IAAAI,QAAE,EAAE,MAAO,CACN,CACD,CACD,CACH,CACA,CAAC;AAEV"}
1
+ {"version":3,"names":["_components","require","_coreData","_data","_element","_htmlEntities","_i18n","_notices","RenamePatternModal","onClose","onError","onSuccess","pattern","props","originalName","decodeEntities","title","name","setName","useState","isSaving","setIsSaving","editEntityRecord","__experimentalSaveSpecifiedEntityEdits","saveSpecifiedEntityEdits","useDispatch","coreStore","createSuccessNotice","createErrorNotice","noticesStore","onRename","event","preventDefault","type","id","savedRecord","throwOnError","__","error","errorMessage","message","code","onRequestClose","_react","createElement","Modal","onSubmit","__experimentalVStack","spacing","TextControl","__nextHasNoMarginBottom","__next40pxDefaultSize","label","value","onChange","required","__experimentalHStack","justify","Button","variant","onClick"],"sources":["@wordpress/patterns/src/components/rename-pattern-modal.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\tModal,\n\tTextControl,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useDispatch } from '@wordpress/data';\nimport { useState } from '@wordpress/element';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { __ } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\n\nexport default function RenamePatternModal( {\n\tonClose,\n\tonError,\n\tonSuccess,\n\tpattern,\n\t...props\n} ) {\n\tconst originalName = decodeEntities( pattern.title );\n\tconst [ name, setName ] = useState( originalName );\n\tconst [ isSaving, setIsSaving ] = useState( false );\n\n\tconst {\n\t\teditEntityRecord,\n\t\t__experimentalSaveSpecifiedEntityEdits: saveSpecifiedEntityEdits,\n\t} = useDispatch( coreStore );\n\n\tconst { createSuccessNotice, createErrorNotice } =\n\t\tuseDispatch( noticesStore );\n\n\tconst onRename = async ( event ) => {\n\t\tevent.preventDefault();\n\n\t\tif ( ! name || name === pattern.title || isSaving ) {\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tawait editEntityRecord( 'postType', pattern.type, pattern.id, {\n\t\t\t\ttitle: name,\n\t\t\t} );\n\n\t\t\tsetIsSaving( true );\n\t\t\tsetName( '' );\n\t\t\tonClose?.();\n\n\t\t\tconst savedRecord = await saveSpecifiedEntityEdits(\n\t\t\t\t'postType',\n\t\t\t\tpattern.type,\n\t\t\t\tpattern.id,\n\t\t\t\t[ 'title' ],\n\t\t\t\t{ throwOnError: true }\n\t\t\t);\n\n\t\t\tonSuccess?.( savedRecord );\n\n\t\t\tcreateSuccessNotice( __( 'Pattern renamed' ), {\n\t\t\t\ttype: 'snackbar',\n\t\t\t\tid: 'pattern-update',\n\t\t\t} );\n\t\t} catch ( error ) {\n\t\t\tonError?.();\n\n\t\t\tconst errorMessage =\n\t\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t\t? error.message\n\t\t\t\t\t: __( 'An error occurred while renaming the pattern.' );\n\n\t\t\tcreateErrorNotice( errorMessage, {\n\t\t\t\ttype: 'snackbar',\n\t\t\t\tid: 'pattern-update',\n\t\t\t} );\n\t\t} finally {\n\t\t\tsetIsSaving( false );\n\t\t\tsetName( '' );\n\t\t}\n\t};\n\n\tconst onRequestClose = () => {\n\t\tonClose?.();\n\t\tsetName( '' );\n\t};\n\n\treturn (\n\t\t<Modal title={ __( 'Rename' ) } { ...props } onRequestClose={ onClose }>\n\t\t\t<form onSubmit={ onRename }>\n\t\t\t\t<VStack spacing=\"5\">\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tlabel={ __( 'Name' ) }\n\t\t\t\t\t\tvalue={ name }\n\t\t\t\t\t\tonChange={ setName }\n\t\t\t\t\t\trequired\n\t\t\t\t\t/>\n\n\t\t\t\t\t<HStack justify=\"right\">\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\tonClick={ onRequestClose }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t\t</Button>\n\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\ttype=\"submit\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Save' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</HStack>\n\t\t\t\t</VStack>\n\t\t\t</form>\n\t\t</Modal>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AAOA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,aAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AACA,IAAAM,QAAA,GAAAN,OAAA;AAfA;AACA;AACA;;AAee,SAASO,kBAAkBA,CAAE;EAC3CC,OAAO;EACPC,OAAO;EACPC,SAAS;EACTC,OAAO;EACP,GAAGC;AACJ,CAAC,EAAG;EACH,MAAMC,YAAY,GAAG,IAAAC,4BAAc,EAAEH,OAAO,CAACI,KAAM,CAAC;EACpD,MAAM,CAAEC,IAAI,EAAEC,OAAO,CAAE,GAAG,IAAAC,iBAAQ,EAAEL,YAAa,CAAC;EAClD,MAAM,CAAEM,QAAQ,EAAEC,WAAW,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N,CACD,CACD,CACH,CACA,CAAC;AAEV"}
@@ -3,7 +3,12 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.PATTERN_USER_CATEGORY = exports.PATTERN_TYPES = exports.PATTERN_SYNC_TYPES = exports.PATTERN_DEFAULT_CATEGORY = exports.EXCLUDED_PATTERN_SOURCES = void 0;
6
+ exports.PATTERN_USER_CATEGORY = exports.PATTERN_TYPES = exports.PATTERN_SYNC_TYPES = exports.PATTERN_DEFAULT_CATEGORY = exports.PARTIAL_SYNCING_SUPPORTED_BLOCKS = exports.EXCLUDED_PATTERN_SOURCES = void 0;
7
+ var _i18n = require("@wordpress/i18n");
8
+ /**
9
+ * WordPress dependencies
10
+ */
11
+
7
12
  const PATTERN_TYPES = {
8
13
  theme: 'pattern',
9
14
  user: 'wp_block'
@@ -19,5 +24,13 @@ const PATTERN_SYNC_TYPES = {
19
24
  full: 'fully',
20
25
  unsynced: 'unsynced'
21
26
  };
27
+
28
+ // TODO: This should not be hardcoded. Maybe there should be a config and/or an UI.
22
29
  exports.PATTERN_SYNC_TYPES = PATTERN_SYNC_TYPES;
30
+ const PARTIAL_SYNCING_SUPPORTED_BLOCKS = {
31
+ 'core/paragraph': {
32
+ content: (0, _i18n.__)('Content')
33
+ }
34
+ };
35
+ exports.PARTIAL_SYNCING_SUPPORTED_BLOCKS = PARTIAL_SYNCING_SUPPORTED_BLOCKS;
23
36
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["PATTERN_TYPES","theme","user","exports","PATTERN_DEFAULT_CATEGORY","PATTERN_USER_CATEGORY","EXCLUDED_PATTERN_SOURCES","PATTERN_SYNC_TYPES","full","unsynced"],"sources":["@wordpress/patterns/src/constants.js"],"sourcesContent":["export const PATTERN_TYPES = {\n\ttheme: 'pattern',\n\tuser: 'wp_block',\n};\n\nexport const PATTERN_DEFAULT_CATEGORY = 'all-patterns';\nexport const PATTERN_USER_CATEGORY = 'my-patterns';\nexport const EXCLUDED_PATTERN_SOURCES = [\n\t'core',\n\t'pattern-directory/core',\n\t'pattern-directory/featured',\n];\nexport const PATTERN_SYNC_TYPES = {\n\tfull: 'fully',\n\tunsynced: 'unsynced',\n};\n"],"mappings":";;;;;;AAAO,MAAMA,aAAa,GAAG;EAC5BC,KAAK,EAAE,SAAS;EAChBC,IAAI,EAAE;AACP,CAAC;AAACC,OAAA,CAAAH,aAAA,GAAAA,aAAA;AAEK,MAAMI,wBAAwB,GAAG,cAAc;AAACD,OAAA,CAAAC,wBAAA,GAAAA,wBAAA;AAChD,MAAMC,qBAAqB,GAAG,aAAa;AAACF,OAAA,CAAAE,qBAAA,GAAAA,qBAAA;AAC5C,MAAMC,wBAAwB,GAAG,CACvC,MAAM,EACN,wBAAwB,EACxB,4BAA4B,CAC5B;AAACH,OAAA,CAAAG,wBAAA,GAAAA,wBAAA;AACK,MAAMC,kBAAkB,GAAG;EACjCC,IAAI,EAAE,OAAO;EACbC,QAAQ,EAAE;AACX,CAAC;AAACN,OAAA,CAAAI,kBAAA,GAAAA,kBAAA"}
1
+ {"version":3,"names":["_i18n","require","PATTERN_TYPES","theme","user","exports","PATTERN_DEFAULT_CATEGORY","PATTERN_USER_CATEGORY","EXCLUDED_PATTERN_SOURCES","PATTERN_SYNC_TYPES","full","unsynced","PARTIAL_SYNCING_SUPPORTED_BLOCKS","content","__"],"sources":["@wordpress/patterns/src/constants.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\n\nexport const PATTERN_TYPES = {\n\ttheme: 'pattern',\n\tuser: 'wp_block',\n};\n\nexport const PATTERN_DEFAULT_CATEGORY = 'all-patterns';\nexport const PATTERN_USER_CATEGORY = 'my-patterns';\nexport const EXCLUDED_PATTERN_SOURCES = [\n\t'core',\n\t'pattern-directory/core',\n\t'pattern-directory/featured',\n];\nexport const PATTERN_SYNC_TYPES = {\n\tfull: 'fully',\n\tunsynced: 'unsynced',\n};\n\n// TODO: This should not be hardcoded. Maybe there should be a config and/or an UI.\nexport const PARTIAL_SYNCING_SUPPORTED_BLOCKS = {\n\t'core/paragraph': { content: __( 'Content' ) },\n};\n"],"mappings":";;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AAHA;AACA;AACA;;AAGO,MAAMC,aAAa,GAAG;EAC5BC,KAAK,EAAE,SAAS;EAChBC,IAAI,EAAE;AACP,CAAC;AAACC,OAAA,CAAAH,aAAA,GAAAA,aAAA;AAEK,MAAMI,wBAAwB,GAAG,cAAc;AAACD,OAAA,CAAAC,wBAAA,GAAAA,wBAAA;AAChD,MAAMC,qBAAqB,GAAG,aAAa;AAACF,OAAA,CAAAE,qBAAA,GAAAA,qBAAA;AAC5C,MAAMC,wBAAwB,GAAG,CACvC,MAAM,EACN,wBAAwB,EACxB,4BAA4B,CAC5B;AAACH,OAAA,CAAAG,wBAAA,GAAAA,wBAAA;AACK,MAAMC,kBAAkB,GAAG;EACjCC,IAAI,EAAE,OAAO;EACbC,QAAQ,EAAE;AACX,CAAC;;AAED;AAAAN,OAAA,CAAAI,kBAAA,GAAAA,kBAAA;AACO,MAAMG,gCAAgC,GAAG;EAC/C,gBAAgB,EAAE;IAAEC,OAAO,EAAE,IAAAC,QAAE,EAAE,SAAU;EAAE;AAC9C,CAAC;AAACT,OAAA,CAAAO,gCAAA,GAAAA,gCAAA"}
@@ -11,6 +11,7 @@ var _duplicatePatternModal = _interopRequireDefault(require("./components/duplic
11
11
  var _renamePatternModal = _interopRequireDefault(require("./components/rename-pattern-modal"));
12
12
  var _components = _interopRequireDefault(require("./components"));
13
13
  var _renamePatternCategoryModal = _interopRequireDefault(require("./components/rename-pattern-category-modal"));
14
+ var _partialSyncingControls = _interopRequireDefault(require("./components/partial-syncing-controls"));
14
15
  var _constants = require("./constants");
15
16
  /**
16
17
  * Internal dependencies
@@ -24,10 +25,12 @@ exports.privateApis = privateApis;
24
25
  RenamePatternModal: _renamePatternModal.default,
25
26
  PatternsMenuItems: _components.default,
26
27
  RenamePatternCategoryModal: _renamePatternCategoryModal.default,
28
+ PartialSyncingControls: _partialSyncingControls.default,
27
29
  PATTERN_TYPES: _constants.PATTERN_TYPES,
28
30
  PATTERN_DEFAULT_CATEGORY: _constants.PATTERN_DEFAULT_CATEGORY,
29
31
  PATTERN_USER_CATEGORY: _constants.PATTERN_USER_CATEGORY,
30
32
  EXCLUDED_PATTERN_SOURCES: _constants.EXCLUDED_PATTERN_SOURCES,
31
- PATTERN_SYNC_TYPES: _constants.PATTERN_SYNC_TYPES
33
+ PATTERN_SYNC_TYPES: _constants.PATTERN_SYNC_TYPES,
34
+ PARTIAL_SYNCING_SUPPORTED_BLOCKS: _constants.PARTIAL_SYNCING_SUPPORTED_BLOCKS
32
35
  });
33
36
  //# sourceMappingURL=private-apis.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_lockUnlock","require","_createPatternModal","_interopRequireDefault","_duplicatePatternModal","_renamePatternModal","_components","_renamePatternCategoryModal","_constants","privateApis","exports","lock","CreatePatternModal","DuplicatePatternModal","RenamePatternModal","PatternsMenuItems","RenamePatternCategoryModal","PATTERN_TYPES","PATTERN_DEFAULT_CATEGORY","PATTERN_USER_CATEGORY","EXCLUDED_PATTERN_SOURCES","PATTERN_SYNC_TYPES"],"sources":["@wordpress/patterns/src/private-apis.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport { lock } from './lock-unlock';\nimport CreatePatternModal from './components/create-pattern-modal';\nimport DuplicatePatternModal from './components/duplicate-pattern-modal';\nimport RenamePatternModal from './components/rename-pattern-modal';\nimport PatternsMenuItems from './components';\nimport RenamePatternCategoryModal from './components/rename-pattern-category-modal';\nimport {\n\tPATTERN_TYPES,\n\tPATTERN_DEFAULT_CATEGORY,\n\tPATTERN_USER_CATEGORY,\n\tEXCLUDED_PATTERN_SOURCES,\n\tPATTERN_SYNC_TYPES,\n} from './constants';\n\nexport const privateApis = {};\nlock( privateApis, {\n\tCreatePatternModal,\n\tDuplicatePatternModal,\n\tRenamePatternModal,\n\tPatternsMenuItems,\n\tRenamePatternCategoryModal,\n\tPATTERN_TYPES,\n\tPATTERN_DEFAULT_CATEGORY,\n\tPATTERN_USER_CATEGORY,\n\tEXCLUDED_PATTERN_SOURCES,\n\tPATTERN_SYNC_TYPES,\n} );\n"],"mappings":";;;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,mBAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,sBAAA,GAAAD,sBAAA,CAAAF,OAAA;AACA,IAAAI,mBAAA,GAAAF,sBAAA,CAAAF,OAAA;AACA,IAAAK,WAAA,GAAAH,sBAAA,CAAAF,OAAA;AACA,IAAAM,2BAAA,GAAAJ,sBAAA,CAAAF,OAAA;AACA,IAAAO,UAAA,GAAAP,OAAA;AATA;AACA;AACA;;AAeO,MAAMQ,WAAW,GAAG,CAAC,CAAC;AAACC,OAAA,CAAAD,WAAA,GAAAA,WAAA;AAC9B,IAAAE,gBAAI,EAAEF,WAAW,EAAE;EAClBG,kBAAkB,EAAlBA,2BAAkB;EAClBC,qBAAqB,EAArBA,8BAAqB;EACrBC,kBAAkB,EAAlBA,2BAAkB;EAClBC,iBAAiB,EAAjBA,mBAAiB;EACjBC,0BAA0B,EAA1BA,mCAA0B;EAC1BC,aAAa,EAAbA,wBAAa;EACbC,wBAAwB,EAAxBA,mCAAwB;EACxBC,qBAAqB,EAArBA,gCAAqB;EACrBC,wBAAwB,EAAxBA,mCAAwB;EACxBC,kBAAkB,EAAlBA;AACD,CAAE,CAAC"}
1
+ {"version":3,"names":["_lockUnlock","require","_createPatternModal","_interopRequireDefault","_duplicatePatternModal","_renamePatternModal","_components","_renamePatternCategoryModal","_partialSyncingControls","_constants","privateApis","exports","lock","CreatePatternModal","DuplicatePatternModal","RenamePatternModal","PatternsMenuItems","RenamePatternCategoryModal","PartialSyncingControls","PATTERN_TYPES","PATTERN_DEFAULT_CATEGORY","PATTERN_USER_CATEGORY","EXCLUDED_PATTERN_SOURCES","PATTERN_SYNC_TYPES","PARTIAL_SYNCING_SUPPORTED_BLOCKS"],"sources":["@wordpress/patterns/src/private-apis.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport { lock } from './lock-unlock';\nimport CreatePatternModal from './components/create-pattern-modal';\nimport DuplicatePatternModal from './components/duplicate-pattern-modal';\nimport RenamePatternModal from './components/rename-pattern-modal';\nimport PatternsMenuItems from './components';\nimport RenamePatternCategoryModal from './components/rename-pattern-category-modal';\nimport PartialSyncingControls from './components/partial-syncing-controls';\nimport {\n\tPATTERN_TYPES,\n\tPATTERN_DEFAULT_CATEGORY,\n\tPATTERN_USER_CATEGORY,\n\tEXCLUDED_PATTERN_SOURCES,\n\tPATTERN_SYNC_TYPES,\n\tPARTIAL_SYNCING_SUPPORTED_BLOCKS,\n} from './constants';\n\nexport const privateApis = {};\nlock( privateApis, {\n\tCreatePatternModal,\n\tDuplicatePatternModal,\n\tRenamePatternModal,\n\tPatternsMenuItems,\n\tRenamePatternCategoryModal,\n\tPartialSyncingControls,\n\tPATTERN_TYPES,\n\tPATTERN_DEFAULT_CATEGORY,\n\tPATTERN_USER_CATEGORY,\n\tEXCLUDED_PATTERN_SOURCES,\n\tPATTERN_SYNC_TYPES,\n\tPARTIAL_SYNCING_SUPPORTED_BLOCKS,\n} );\n"],"mappings":";;;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,mBAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,sBAAA,GAAAD,sBAAA,CAAAF,OAAA;AACA,IAAAI,mBAAA,GAAAF,sBAAA,CAAAF,OAAA;AACA,IAAAK,WAAA,GAAAH,sBAAA,CAAAF,OAAA;AACA,IAAAM,2BAAA,GAAAJ,sBAAA,CAAAF,OAAA;AACA,IAAAO,uBAAA,GAAAL,sBAAA,CAAAF,OAAA;AACA,IAAAQ,UAAA,GAAAR,OAAA;AAVA;AACA;AACA;;AAiBO,MAAMS,WAAW,GAAG,CAAC,CAAC;AAACC,OAAA,CAAAD,WAAA,GAAAA,WAAA;AAC9B,IAAAE,gBAAI,EAAEF,WAAW,EAAE;EAClBG,kBAAkB,EAAlBA,2BAAkB;EAClBC,qBAAqB,EAArBA,8BAAqB;EACrBC,kBAAkB,EAAlBA,2BAAkB;EAClBC,iBAAiB,EAAjBA,mBAAiB;EACjBC,0BAA0B,EAA1BA,mCAA0B;EAC1BC,sBAAsB,EAAtBA,+BAAsB;EACtBC,aAAa,EAAbA,wBAAa;EACbC,wBAAwB,EAAxBA,mCAAwB;EACxBC,qBAAqB,EAArBA,gCAAqB;EACrBC,wBAAwB,EAAxBA,mCAAwB;EACxBC,kBAAkB,EAAlBA,6BAAkB;EAClBC,gCAAgC,EAAhCA;AACD,CAAE,CAAC"}
@@ -0,0 +1,83 @@
1
+ import { createElement } from "react";
2
+ /**
3
+ * External dependencies
4
+ */
5
+ import { nanoid } from 'nanoid';
6
+
7
+ /**
8
+ * WordPress dependencies
9
+ */
10
+ import { InspectorControls } from '@wordpress/block-editor';
11
+ import { BaseControl, CheckboxControl } from '@wordpress/components';
12
+ import { __ } from '@wordpress/i18n';
13
+
14
+ /**
15
+ * Internal dependencies
16
+ */
17
+ import { PARTIAL_SYNCING_SUPPORTED_BLOCKS } from '../constants';
18
+ function PartialSyncingControls({
19
+ name,
20
+ attributes,
21
+ setAttributes
22
+ }) {
23
+ const syncedAttributes = PARTIAL_SYNCING_SUPPORTED_BLOCKS[name];
24
+ function updateConnections(attributeName, isChecked) {
25
+ if (!isChecked) {
26
+ let updatedConnections = {
27
+ ...attributes.connections,
28
+ attributes: {
29
+ ...attributes.connections?.attributes,
30
+ [attributeName]: undefined
31
+ }
32
+ };
33
+ if (Object.keys(updatedConnections.attributes).length === 1) {
34
+ updatedConnections.attributes = undefined;
35
+ }
36
+ if (Object.keys(updatedConnections).length === 1 && updateConnections.attributes === undefined) {
37
+ updatedConnections = undefined;
38
+ }
39
+ setAttributes({
40
+ connections: updatedConnections
41
+ });
42
+ return;
43
+ }
44
+ const updatedConnections = {
45
+ ...attributes.connections,
46
+ attributes: {
47
+ ...attributes.connections?.attributes,
48
+ [attributeName]: {
49
+ source: 'pattern_attributes'
50
+ }
51
+ }
52
+ };
53
+ if (typeof attributes.metadata?.id === 'string') {
54
+ setAttributes({
55
+ connections: updatedConnections
56
+ });
57
+ return;
58
+ }
59
+ const id = nanoid(6);
60
+ setAttributes({
61
+ connections: updatedConnections,
62
+ metadata: {
63
+ ...attributes.metadata,
64
+ id
65
+ }
66
+ });
67
+ }
68
+ return createElement(InspectorControls, {
69
+ group: "advanced"
70
+ }, createElement(BaseControl, {
71
+ __nextHasNoMarginBottom: true
72
+ }, createElement(BaseControl.VisualLabel, null, __('Synced attributes')), Object.entries(syncedAttributes).map(([attributeName, label]) => createElement(CheckboxControl, {
73
+ key: attributeName,
74
+ __nextHasNoMarginBottom: true,
75
+ label: label,
76
+ checked: attributes.connections?.attributes?.[attributeName]?.source === 'pattern_attributes',
77
+ onChange: isChecked => {
78
+ updateConnections(attributeName, isChecked);
79
+ }
80
+ }))));
81
+ }
82
+ export default PartialSyncingControls;
83
+ //# sourceMappingURL=partial-syncing-controls.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["nanoid","InspectorControls","BaseControl","CheckboxControl","__","PARTIAL_SYNCING_SUPPORTED_BLOCKS","PartialSyncingControls","name","attributes","setAttributes","syncedAttributes","updateConnections","attributeName","isChecked","updatedConnections","connections","undefined","Object","keys","length","source","metadata","id","createElement","group","__nextHasNoMarginBottom","VisualLabel","entries","map","label","key","checked","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\n\tfunction updateConnections( attributeName, isChecked ) {\n\t\tif ( ! isChecked ) {\n\t\t\tlet updatedConnections = {\n\t\t\t\t...attributes.connections,\n\t\t\t\tattributes: {\n\t\t\t\t\t...attributes.connections?.attributes,\n\t\t\t\t\t[ attributeName ]: undefined,\n\t\t\t\t},\n\t\t\t};\n\t\t\tif ( Object.keys( updatedConnections.attributes ).length === 1 ) {\n\t\t\t\tupdatedConnections.attributes = undefined;\n\t\t\t}\n\t\t\tif (\n\t\t\t\tObject.keys( updatedConnections ).length === 1 &&\n\t\t\t\tupdateConnections.attributes === undefined\n\t\t\t) {\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\tconst updatedConnections = {\n\t\t\t...attributes.connections,\n\t\t\tattributes: {\n\t\t\t\t...attributes.connections?.attributes,\n\t\t\t\t[ 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{ __( 'Synced attributes' ) }\n\t\t\t\t</BaseControl.VisualLabel>\n\t\t\t\t{ Object.entries( syncedAttributes ).map(\n\t\t\t\t\t( [ attributeName, label ] ) => (\n\t\t\t\t\t\t<CheckboxControl\n\t\t\t\t\t\t\tkey={ attributeName }\n\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\tlabel={ label }\n\t\t\t\t\t\t\tchecked={\n\t\t\t\t\t\t\t\tattributes.connections?.attributes?.[\n\t\t\t\t\t\t\t\t\tattributeName\n\t\t\t\t\t\t\t\t]?.source === 'pattern_attributes'\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tonChange={ ( isChecked ) => {\n\t\t\t\t\t\t\t\tupdateConnections( attributeName, isChecked );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t)\n\t\t\t\t) }\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;EAEjE,SAASI,iBAAiBA,CAAEC,aAAa,EAAEC,SAAS,EAAG;IACtD,IAAK,CAAEA,SAAS,EAAG;MAClB,IAAIC,kBAAkB,GAAG;QACxB,GAAGN,UAAU,CAACO,WAAW;QACzBP,UAAU,EAAE;UACX,GAAGA,UAAU,CAACO,WAAW,EAAEP,UAAU;UACrC,CAAEI,aAAa,GAAII;QACpB;MACD,CAAC;MACD,IAAKC,MAAM,CAACC,IAAI,CAAEJ,kBAAkB,CAACN,UAAW,CAAC,CAACW,MAAM,KAAK,CAAC,EAAG;QAChEL,kBAAkB,CAACN,UAAU,GAAGQ,SAAS;M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DY,QAAQ,EAAKnB,SAAS,IAAM;MAC3BF,iBAAiB,CAAEC,aAAa,EAAEC,SAAU,CAAC;IAC9C;EAAG,CACH,CAEH,CACY,CACK,CAAC;AAEtB;AAEA,eAAeP,sBAAsB"}
@@ -115,6 +115,7 @@ export default function RenamePatternCategoryModal({
115
115
  }, createElement(TextControl, {
116
116
  ref: textControlRef,
117
117
  __nextHasNoMarginBottom: true,
118
+ __next40pxDefaultSize: true,
118
119
  label: __('Name'),
119
120
  value: name,
120
121
  onChange: onChange,
@@ -126,9 +127,11 @@ export default function RenamePatternCategoryModal({
126
127
  }, validationMessage)), createElement(HStack, {
127
128
  justify: "right"
128
129
  }, createElement(Button, {
130
+ __next40pxDefaultSize: true,
129
131
  variant: "tertiary",
130
132
  onClick: onRequestClose
131
133
  }, __('Cancel')), createElement(Button, {
134
+ __next40pxDefaultSize: true,
132
135
  variant: "primary",
133
136
  type: "submit",
134
137
  "aria-disabled": !name || name === category.name || isSaving,
@@ -1 +1 @@
1
- {"version":3,"names":["Modal","Button","TextControl","__experimentalHStack","HStack","__experimentalVStack","VStack","store","coreStore","useDispatch","useId","useRef","useState","decodeEntities","__","noticesStore","speak","CATEGORY_SLUG","RenamePatternCategoryModal","category","existingCategories","onClose","onError","onSuccess","props","id","textControlRef","name","setName","isSaving","setIsSaving","validationMessage","setValidationMessage","validationMessageId","undefined","saveEntityRecord","invalidateResolution","createErrorNotice","createSuccessNotice","onChange","newName","onSave","event","preventDefault","message","current","focus","patternCategories","find","existingCategory","label","toLowerCase","savedRecord","slug","type","error","onRequestClose","createElement","title","onSubmit","spacing","ref","__nextHasNoMarginBottom","value","required","className","justify","variant","onClick","isBusy"],"sources":["@wordpress/patterns/src/components/rename-pattern-category-modal.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tModal,\n\tButton,\n\tTextControl,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useDispatch } from '@wordpress/data';\nimport { useId, useRef, useState } from '@wordpress/element';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { __ } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { speak } from '@wordpress/a11y';\n\n/**\n * Internal dependencies\n */\nimport { CATEGORY_SLUG } from './category-selector';\n\nexport default function RenamePatternCategoryModal( {\n\tcategory,\n\texistingCategories,\n\tonClose,\n\tonError,\n\tonSuccess,\n\t...props\n} ) {\n\tconst id = useId();\n\tconst textControlRef = useRef();\n\tconst [ name, setName ] = useState( decodeEntities( category.name ) );\n\tconst [ isSaving, setIsSaving ] = useState( false );\n\tconst [ validationMessage, setValidationMessage ] = useState( false );\n\tconst validationMessageId = validationMessage\n\t\t? `patterns-rename-pattern-category-modal__validation-message-${ id }`\n\t\t: undefined;\n\n\tconst { saveEntityRecord, invalidateResolution } = useDispatch( coreStore );\n\tconst { createErrorNotice, createSuccessNotice } =\n\t\tuseDispatch( noticesStore );\n\n\tconst onChange = ( newName ) => {\n\t\tif ( validationMessage ) {\n\t\t\tsetValidationMessage( undefined );\n\t\t}\n\t\tsetName( newName );\n\t};\n\n\tconst onSave = async ( event ) => {\n\t\tevent.preventDefault();\n\n\t\tif ( isSaving ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( ! name || name === category.name ) {\n\t\t\tconst message = __( 'Please enter a new name for this category.' );\n\t\t\tspeak( message, 'assertive' );\n\t\t\tsetValidationMessage( message );\n\t\t\ttextControlRef.current?.focus();\n\t\t\treturn;\n\t\t}\n\n\t\t// Check existing categories to avoid creating duplicates.\n\t\tif (\n\t\t\texistingCategories.patternCategories.find( ( existingCategory ) => {\n\t\t\t\t// Compare the id so that the we don't disallow the user changing the case of their current category\n\t\t\t\t// (i.e. renaming 'test' to 'Test').\n\t\t\t\treturn (\n\t\t\t\t\texistingCategory.id !== category.id &&\n\t\t\t\t\texistingCategory.label.toLowerCase() === name.toLowerCase()\n\t\t\t\t);\n\t\t\t} )\n\t\t) {\n\t\t\tconst message = __(\n\t\t\t\t'This category already exists. Please use a different name.'\n\t\t\t);\n\t\t\tspeak( message, 'assertive' );\n\t\t\tsetValidationMessage( message );\n\t\t\ttextControlRef.current?.focus();\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tsetIsSaving( true );\n\n\t\t\t// User pattern category properties may differ as they can be\n\t\t\t// normalized for use alongside template part areas, core pattern\n\t\t\t// categories etc. As a result we won't just destructure the passed\n\t\t\t// category object.\n\t\t\tconst savedRecord = await saveEntityRecord(\n\t\t\t\t'taxonomy',\n\t\t\t\tCATEGORY_SLUG,\n\t\t\t\t{\n\t\t\t\t\tid: category.id,\n\t\t\t\t\tslug: category.slug,\n\t\t\t\t\tname,\n\t\t\t\t}\n\t\t\t);\n\n\t\t\tinvalidateResolution( 'getUserPatternCategories' );\n\t\t\tonSuccess?.( savedRecord );\n\t\t\tonClose();\n\n\t\t\tcreateSuccessNotice( __( 'Pattern category renamed.' ), {\n\t\t\t\ttype: 'snackbar',\n\t\t\t\tid: 'pattern-category-update',\n\t\t\t} );\n\t\t} catch ( error ) {\n\t\t\tonError?.();\n\t\t\tcreateErrorNotice( error.message, {\n\t\t\t\ttype: 'snackbar',\n\t\t\t\tid: 'pattern-category-update',\n\t\t\t} );\n\t\t} finally {\n\t\t\tsetIsSaving( false );\n\t\t\tsetName( '' );\n\t\t}\n\t};\n\n\tconst onRequestClose = () => {\n\t\tonClose();\n\t\tsetName( '' );\n\t};\n\n\treturn (\n\t\t<Modal\n\t\t\ttitle={ __( 'Rename' ) }\n\t\t\tonRequestClose={ onRequestClose }\n\t\t\t{ ...props }\n\t\t>\n\t\t\t<form onSubmit={ onSave }>\n\t\t\t\t<VStack spacing=\"5\">\n\t\t\t\t\t<VStack spacing=\"2\">\n\t\t\t\t\t\t<TextControl\n\t\t\t\t\t\t\tref={ textControlRef }\n\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\tlabel={ __( 'Name' ) }\n\t\t\t\t\t\t\tvalue={ name }\n\t\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\t\taria-describedby={ validationMessageId }\n\t\t\t\t\t\t\trequired\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t{ validationMessage && (\n\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\tclassName=\"patterns-rename-pattern-category-modal__validation-message\"\n\t\t\t\t\t\t\t\tid={ validationMessageId }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ validationMessage }\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</VStack>\n\t\t\t\t\t<HStack justify=\"right\">\n\t\t\t\t\t\t<Button variant=\"tertiary\" onClick={ onRequestClose }>\n\t\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\ttype=\"submit\"\n\t\t\t\t\t\t\taria-disabled={\n\t\t\t\t\t\t\t\t! name || name === category.name || isSaving\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tisBusy={ isSaving }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Save' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</HStack>\n\t\t\t\t</VStack>\n\t\t\t</form>\n\t\t</Modal>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SACCA,KAAK,EACLC,MAAM,EACNC,WAAW,EACXC,oBAAoB,IAAIC,MAAM,EAC9BC,oBAAoB,IAAIC,MAAM,QACxB,uBAAuB;AAC9B,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;AACzD,SAASC,WAAW,QAAQ,iBAAiB;AAC7C,SAASC,KAAK,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,oBAAoB;AAC5D,SAASC,cAAc,QAAQ,0BAA0B;AACzD,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASP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EjBf,EAAE,CAAE,MAAO,CACN,CACD,CACD,CACH,CACA,CAAC;AAEV"}
1
+ {"version":3,"names":["Modal","Button","TextControl","__experimentalHStack","HStack","__experimentalVStack","VStack","store","coreStore","useDispatch","useId","useRef","useState","decodeEntities","__","noticesStore","speak","CATEGORY_SLUG","RenamePatternCategoryModal","category","existingCategories","onClose","onError","onSuccess","props","id","textControlRef","name","setName","isSaving","setIsSaving","validationMessage","setValidationMessage","validationMessageId","undefined","saveEntityRecord","invalidateResolution","createErrorNotice","createSuccessNotice","onChange","newName","onSave","event","preventDefault","message","current","focus","patternCategories","find","existingCategory","label","toLowerCase","savedRecord","slug","type","error","onRequestClose","createElement","title","onSubmit","spacing","ref","__nextHasNoMarginBottom","__next40pxDefaultSize","value","required","className","justify","variant","onClick","isBusy"],"sources":["@wordpress/patterns/src/components/rename-pattern-category-modal.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tModal,\n\tButton,\n\tTextControl,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useDispatch } from '@wordpress/data';\nimport { useId, useRef, useState } from '@wordpress/element';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { __ } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { speak } from '@wordpress/a11y';\n\n/**\n * Internal dependencies\n */\nimport { CATEGORY_SLUG } from './category-selector';\n\nexport default function RenamePatternCategoryModal( {\n\tcategory,\n\texistingCategories,\n\tonClose,\n\tonError,\n\tonSuccess,\n\t...props\n} ) {\n\tconst id = useId();\n\tconst textControlRef = useRef();\n\tconst [ name, setName ] = useState( decodeEntities( category.name ) );\n\tconst [ isSaving, setIsSaving ] = useState( false );\n\tconst [ validationMessage, setValidationMessage ] = useState( false );\n\tconst validationMessageId = validationMessage\n\t\t? `patterns-rename-pattern-category-modal__validation-message-${ id }`\n\t\t: undefined;\n\n\tconst { saveEntityRecord, invalidateResolution } = useDispatch( coreStore );\n\tconst { createErrorNotice, createSuccessNotice } =\n\t\tuseDispatch( noticesStore );\n\n\tconst onChange = ( newName ) => {\n\t\tif ( validationMessage ) {\n\t\t\tsetValidationMessage( undefined );\n\t\t}\n\t\tsetName( newName );\n\t};\n\n\tconst onSave = async ( event ) => {\n\t\tevent.preventDefault();\n\n\t\tif ( isSaving ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( ! name || name === category.name ) {\n\t\t\tconst message = __( 'Please enter a new name for this category.' );\n\t\t\tspeak( message, 'assertive' );\n\t\t\tsetValidationMessage( message );\n\t\t\ttextControlRef.current?.focus();\n\t\t\treturn;\n\t\t}\n\n\t\t// Check existing categories to avoid creating duplicates.\n\t\tif (\n\t\t\texistingCategories.patternCategories.find( ( existingCategory ) => {\n\t\t\t\t// Compare the id so that the we don't disallow the user changing the case of their current category\n\t\t\t\t// (i.e. renaming 'test' to 'Test').\n\t\t\t\treturn (\n\t\t\t\t\texistingCategory.id !== category.id &&\n\t\t\t\t\texistingCategory.label.toLowerCase() === name.toLowerCase()\n\t\t\t\t);\n\t\t\t} )\n\t\t) {\n\t\t\tconst message = __(\n\t\t\t\t'This category already exists. Please use a different name.'\n\t\t\t);\n\t\t\tspeak( message, 'assertive' );\n\t\t\tsetValidationMessage( message );\n\t\t\ttextControlRef.current?.focus();\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tsetIsSaving( true );\n\n\t\t\t// User pattern category properties may differ as they can be\n\t\t\t// normalized for use alongside template part areas, core pattern\n\t\t\t// categories etc. As a result we won't just destructure the passed\n\t\t\t// category object.\n\t\t\tconst savedRecord = await saveEntityRecord(\n\t\t\t\t'taxonomy',\n\t\t\t\tCATEGORY_SLUG,\n\t\t\t\t{\n\t\t\t\t\tid: category.id,\n\t\t\t\t\tslug: category.slug,\n\t\t\t\t\tname,\n\t\t\t\t}\n\t\t\t);\n\n\t\t\tinvalidateResolution( 'getUserPatternCategories' );\n\t\t\tonSuccess?.( savedRecord );\n\t\t\tonClose();\n\n\t\t\tcreateSuccessNotice( __( 'Pattern category renamed.' ), {\n\t\t\t\ttype: 'snackbar',\n\t\t\t\tid: 'pattern-category-update',\n\t\t\t} );\n\t\t} catch ( error ) {\n\t\t\tonError?.();\n\t\t\tcreateErrorNotice( error.message, {\n\t\t\t\ttype: 'snackbar',\n\t\t\t\tid: 'pattern-category-update',\n\t\t\t} );\n\t\t} finally {\n\t\t\tsetIsSaving( false );\n\t\t\tsetName( '' );\n\t\t}\n\t};\n\n\tconst onRequestClose = () => {\n\t\tonClose();\n\t\tsetName( '' );\n\t};\n\n\treturn (\n\t\t<Modal\n\t\t\ttitle={ __( 'Rename' ) }\n\t\t\tonRequestClose={ onRequestClose }\n\t\t\t{ ...props }\n\t\t>\n\t\t\t<form onSubmit={ onSave }>\n\t\t\t\t<VStack spacing=\"5\">\n\t\t\t\t\t<VStack spacing=\"2\">\n\t\t\t\t\t\t<TextControl\n\t\t\t\t\t\t\tref={ textControlRef }\n\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tlabel={ __( 'Name' ) }\n\t\t\t\t\t\t\tvalue={ name }\n\t\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\t\taria-describedby={ validationMessageId }\n\t\t\t\t\t\t\trequired\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t{ validationMessage && (\n\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\tclassName=\"patterns-rename-pattern-category-modal__validation-message\"\n\t\t\t\t\t\t\t\tid={ validationMessageId }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ validationMessage }\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</VStack>\n\t\t\t\t\t<HStack justify=\"right\">\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\tonClick={ onRequestClose }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\ttype=\"submit\"\n\t\t\t\t\t\t\taria-disabled={\n\t\t\t\t\t\t\t\t! name || name === category.name || isSaving\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tisBusy={ isSaving }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Save' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</HStack>\n\t\t\t\t</VStack>\n\t\t\t</form>\n\t\t</Modal>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SACCA,KAAK,EACLC,MAAM,EACNC,WAAW,EACXC,oBAAoB,IAAIC,MAAM,EAC9BC,oBAAoB,IAAIC,MAAM,QACxB,uBAAuB;AAC9B,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;AACzD,SAASC,WAAW,QAAQ,iBAAiB;AAC7C,SAASC,KAAK,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,oBAAoB;AAC5D,SAASC,cAAc,QAAQ,0BAA0B;AACzD,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASP,KAAK,IAAIQ,YAAY,QAAQ,oBAAoB;AAC1D,SAASC,KAAK,QAAQ,iBAAiB;;AAEvC;AACA;AACA;AACA,SAASC,aAAa,QAAQ,qBAAqB;AAEnD,eAAe,SAASC,0BAA0BA,CAAE;EACnDC,QAAQ;EACRC,kBAAkB;EAClBC,OAAO;EACPC,OAAO;EACPC,SAAS;EACT,GAAGC;AACJ,CAAC,EAAG;EACH,MAAMC,EAAE,GAAGf,KAAK,CAAC,CAAC;EAClB,MAAMgB,cAAc,GAAGf,MAAM,CAAC,CAAC;EAC/B,MAAM,CAAEgB,IAAI,EAAEC,OAAO,CA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AEViC,aAAA;IAAME,QAAQ,EAAGlB;EAAQ,GACxBgB,aAAA,CAACnD,MAAM;IAACsD,OAAO,EAAC;EAAG,GAClBH,aAAA,CAACnD,MAAM;IAACsD,OAAO,EAAC;EAAG,GAClBH,aAAA,CAACvD,WAAW;IACX2D,GAAG,EAAGnC,cAAgB;IACtBoC,uBAAuB;IACvBC,qBAAqB;IACrBb,KAAK,EAAGpC,EAAE,CAAE,MAAO,CAAG;IACtBkD,KAAK,EAAGrC,IAAM;IACdY,QAAQ,EAAGA,QAAU;IACrB,oBAAmBN,mBAAqB;IACxCgC,QAAQ;EAAA,CACR,CAAC,EACAlC,iBAAiB,IAClB0B,aAAA;IACCS,SAAS,EAAC,4DAA4D;IACtEzC,EAAE,EAAGQ;EAAqB,GAExBF,iBACG,CAEA,CAAC,EACT0B,aAAA,CAACrD,MAAM;IAAC+D,OAAO,EAAC;EAAO,GACtBV,aAAA,CAACxD,MAAM;IACN8D,qBAAqB;IACrBK,OAAO,EAAC,UAAU;IAClBC,OAAO,EAAGb;EAAgB,GAExB1C,EAAE,CAAE,QAAS,CACR,CAAC,EACT2C,aAAA,CAACxD,MAAM;IACN8D,qBAAqB;IACrBK,OAAO,EAAC,SAAS;IACjBd,IAAI,EAAC,QAAQ;IACb,iBACC,CAAE3B,IAAI,IAAIA,IAAI,KAAKR,QAAQ,CAACQ,IAAI,IAAIE,QACpC;IACDyC,MAAM,EAAGzC;EAAU,GAEjBf,EAAE,CAAE,MAAO,CACN,CACD,CACD,CACH,CACA,CAAC;AAEV"}
@@ -73,6 +73,7 @@ export default function RenamePatternModal({
73
73
  spacing: "5"
74
74
  }, createElement(TextControl, {
75
75
  __nextHasNoMarginBottom: true,
76
+ __next40pxDefaultSize: true,
76
77
  label: __('Name'),
77
78
  value: name,
78
79
  onChange: setName,
@@ -80,9 +81,11 @@ export default function RenamePatternModal({
80
81
  }), createElement(HStack, {
81
82
  justify: "right"
82
83
  }, createElement(Button, {
84
+ __next40pxDefaultSize: true,
83
85
  variant: "tertiary",
84
86
  onClick: onRequestClose
85
87
  }, __('Cancel')), createElement(Button, {
88
+ __next40pxDefaultSize: true,
86
89
  variant: "primary",
87
90
  type: "submit"
88
91
  }, __('Save'))))));
@@ -1 +1 @@
1
- {"version":3,"names":["Button","Modal","TextControl","__experimentalHStack","HStack","__experimentalVStack","VStack","store","coreStore","useDispatch","useState","decodeEntities","__","noticesStore","RenamePatternModal","onClose","onError","onSuccess","pattern","props","originalName","title","name","setName","isSaving","setIsSaving","editEntityRecord","__experimentalSaveSpecifiedEntityEdits","saveSpecifiedEntityEdits","createSuccessNotice","createErrorNotice","onRename","event","preventDefault","type","id","savedRecord","throwOnError","error","errorMessage","message","code","onRequestClose","createElement","onSubmit","spacing","__nextHasNoMarginBottom","label","value","onChange","required","justify","variant","onClick"],"sources":["@wordpress/patterns/src/components/rename-pattern-modal.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\tModal,\n\tTextControl,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useDispatch } from '@wordpress/data';\nimport { useState } from '@wordpress/element';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { __ } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\n\nexport default function RenamePatternModal( {\n\tonClose,\n\tonError,\n\tonSuccess,\n\tpattern,\n\t...props\n} ) {\n\tconst originalName = decodeEntities( pattern.title );\n\tconst [ name, setName ] = useState( originalName );\n\tconst [ isSaving, setIsSaving ] = useState( false );\n\n\tconst {\n\t\teditEntityRecord,\n\t\t__experimentalSaveSpecifiedEntityEdits: saveSpecifiedEntityEdits,\n\t} = useDispatch( coreStore );\n\n\tconst { createSuccessNotice, createErrorNotice } =\n\t\tuseDispatch( noticesStore );\n\n\tconst onRename = async ( event ) => {\n\t\tevent.preventDefault();\n\n\t\tif ( ! name || name === pattern.title || isSaving ) {\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tawait editEntityRecord( 'postType', pattern.type, pattern.id, {\n\t\t\t\ttitle: name,\n\t\t\t} );\n\n\t\t\tsetIsSaving( true );\n\t\t\tsetName( '' );\n\t\t\tonClose?.();\n\n\t\t\tconst savedRecord = await saveSpecifiedEntityEdits(\n\t\t\t\t'postType',\n\t\t\t\tpattern.type,\n\t\t\t\tpattern.id,\n\t\t\t\t[ 'title' ],\n\t\t\t\t{ throwOnError: true }\n\t\t\t);\n\n\t\t\tonSuccess?.( savedRecord );\n\n\t\t\tcreateSuccessNotice( __( 'Pattern renamed' ), {\n\t\t\t\ttype: 'snackbar',\n\t\t\t\tid: 'pattern-update',\n\t\t\t} );\n\t\t} catch ( error ) {\n\t\t\tonError?.();\n\n\t\t\tconst errorMessage =\n\t\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t\t? error.message\n\t\t\t\t\t: __( 'An error occurred while renaming the pattern.' );\n\n\t\t\tcreateErrorNotice( errorMessage, {\n\t\t\t\ttype: 'snackbar',\n\t\t\t\tid: 'pattern-update',\n\t\t\t} );\n\t\t} finally {\n\t\t\tsetIsSaving( false );\n\t\t\tsetName( '' );\n\t\t}\n\t};\n\n\tconst onRequestClose = () => {\n\t\tonClose?.();\n\t\tsetName( '' );\n\t};\n\n\treturn (\n\t\t<Modal title={ __( 'Rename' ) } { ...props } onRequestClose={ onClose }>\n\t\t\t<form onSubmit={ onRename }>\n\t\t\t\t<VStack spacing=\"5\">\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\tlabel={ __( 'Name' ) }\n\t\t\t\t\t\tvalue={ name }\n\t\t\t\t\t\tonChange={ setName }\n\t\t\t\t\t\trequired\n\t\t\t\t\t/>\n\n\t\t\t\t\t<HStack justify=\"right\">\n\t\t\t\t\t\t<Button variant=\"tertiary\" onClick={ onRequestClose }>\n\t\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t\t</Button>\n\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b;EAAU,GAC1BY,aAAA,CAACrC,MAAM;IAACuC,OAAO,EAAC;EAAG,GAClBF,aAAA,CAACzC,WAAW;IACX4C,uBAAuB;IACvBC,KAAK,EAAGnC,EAAE,CAAE,MAAO,CAAG;IACtBoC,KAAK,EAAG1B,IAAM;IACd2B,QAAQ,EAAG1B,OAAS;IACpB2B,QAAQ;EAAA,CACR,CAAC,EAEFP,aAAA,CAACvC,MAAM;IAAC+C,OAAO,EAAC;EAAO,GACtBR,aAAA,CAAC3C,MAAM;IAACoD,OAAO,EAAC,UAAU;IAACC,OAAO,EAAGX;EAAgB,GAClD9B,EAAE,CAAE,QAAS,CACR,CAAC,EAET+B,aAAA,CAAC3C,MAAM;IAACoD,OAAO,EAAC,SAAS;IAAClB,IAAI,EAAC;EAAQ,GACpCtB,EAAE,CAAE,MAAO,CACN,CACD,CACD,CACH,CACA,CAAC;AAEV"}
1
+ {"version":3,"names":["Button","Modal","TextControl","__experimentalHStack","HStack","__experimentalVStack","VStack","store","coreStore","useDispatch","useState","decodeEntities","__","noticesStore","RenamePatternModal","onClose","onError","onSuccess","pattern","props","originalName","title","name","setName","isSaving","setIsSaving","editEntityRecord","__experimentalSaveSpecifiedEntityEdits","saveSpecifiedEntityEdits","createSuccessNotice","createErrorNotice","onRename","event","preventDefault","type","id","savedRecord","throwOnError","error","errorMessage","message","code","onRequestClose","createElement","onSubmit","spacing","__nextHasNoMarginBottom","__next40pxDefaultSize","label","value","onChange","required","justify","variant","onClick"],"sources":["@wordpress/patterns/src/components/rename-pattern-modal.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\tModal,\n\tTextControl,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useDispatch } from '@wordpress/data';\nimport { useState } from '@wordpress/element';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { __ } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\n\nexport default function RenamePatternModal( {\n\tonClose,\n\tonError,\n\tonSuccess,\n\tpattern,\n\t...props\n} ) {\n\tconst originalName = decodeEntities( pattern.title );\n\tconst [ name, setName ] = useState( originalName );\n\tconst [ isSaving, setIsSaving ] = useState( false );\n\n\tconst {\n\t\teditEntityRecord,\n\t\t__experimentalSaveSpecifiedEntityEdits: saveSpecifiedEntityEdits,\n\t} = useDispatch( coreStore );\n\n\tconst { createSuccessNotice, createErrorNotice } =\n\t\tuseDispatch( noticesStore );\n\n\tconst onRename = async ( event ) => {\n\t\tevent.preventDefault();\n\n\t\tif ( ! name || name === pattern.title || isSaving ) {\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tawait editEntityRecord( 'postType', pattern.type, pattern.id, {\n\t\t\t\ttitle: name,\n\t\t\t} );\n\n\t\t\tsetIsSaving( true );\n\t\t\tsetName( '' );\n\t\t\tonClose?.();\n\n\t\t\tconst savedRecord = await saveSpecifiedEntityEdits(\n\t\t\t\t'postType',\n\t\t\t\tpattern.type,\n\t\t\t\tpattern.id,\n\t\t\t\t[ 'title' ],\n\t\t\t\t{ throwOnError: true }\n\t\t\t);\n\n\t\t\tonSuccess?.( savedRecord );\n\n\t\t\tcreateSuccessNotice( __( 'Pattern renamed' ), {\n\t\t\t\ttype: 'snackbar',\n\t\t\t\tid: 'pattern-update',\n\t\t\t} );\n\t\t} catch ( error ) {\n\t\t\tonError?.();\n\n\t\t\tconst errorMessage =\n\t\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t\t? error.message\n\t\t\t\t\t: __( 'An error occurred while renaming the pattern.' );\n\n\t\t\tcreateErrorNotice( errorMessage, {\n\t\t\t\ttype: 'snackbar',\n\t\t\t\tid: 'pattern-update',\n\t\t\t} );\n\t\t} finally {\n\t\t\tsetIsSaving( false );\n\t\t\tsetName( '' );\n\t\t}\n\t};\n\n\tconst onRequestClose = () => {\n\t\tonClose?.();\n\t\tsetName( '' );\n\t};\n\n\treturn (\n\t\t<Modal title={ __( 'Rename' ) } { ...props } onRequestClose={ onClose }>\n\t\t\t<form onSubmit={ onRename }>\n\t\t\t\t<VStack spacing=\"5\">\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tlabel={ __( 'Name' ) }\n\t\t\t\t\t\tvalue={ name }\n\t\t\t\t\t\tonChange={ setName }\n\t\t\t\t\t\trequired\n\t\t\t\t\t/>\n\n\t\t\t\t\t<HStack justify=\"right\">\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\tonClick={ onRequestClose }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t\t</Button>\n\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\ttype=\"submit\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Save' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</HStack>\n\t\t\t\t</VStack>\n\t\t\t</form>\n\t\t</Modal>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SACCA,MAAM,EACNC,KAAK,EACLC,WAAW,EACXC,oBAAoB,IAAIC,MAAM,EAC9BC,oBAAoB,IAAIC,MAAM,QACxB,uBAAuB;AAC9B,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;AACzD,SAASC,WAAW,QAAQ,iBAAiB;AAC7C,SAASC,QAAQ,QAAQ,oBAAoB;AAC7C,SAASC,cAAc,QAAQ,0BAA0B;AACzD,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASL,KAAK,IAAIM,YAAY,QAAQ,oBAAoB;AAE1D,eAAe,SAASC,kBAAkBA,CAAE;EAC3CC,OAAO;EACPC,OAAO;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 -1,3 +1,7 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { __ } from '@wordpress/i18n';
1
5
  export const PATTERN_TYPES = {
2
6
  theme: 'pattern',
3
7
  user: 'wp_block'
@@ -9,4 +13,11 @@ export const PATTERN_SYNC_TYPES = {
9
13
  full: 'fully',
10
14
  unsynced: 'unsynced'
11
15
  };
16
+
17
+ // TODO: This should not be hardcoded. Maybe there should be a config and/or an UI.
18
+ export const PARTIAL_SYNCING_SUPPORTED_BLOCKS = {
19
+ 'core/paragraph': {
20
+ content: __('Content')
21
+ }
22
+ };
12
23
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["PATTERN_TYPES","theme","user","PATTERN_DEFAULT_CATEGORY","PATTERN_USER_CATEGORY","EXCLUDED_PATTERN_SOURCES","PATTERN_SYNC_TYPES","full","unsynced"],"sources":["@wordpress/patterns/src/constants.js"],"sourcesContent":["export const PATTERN_TYPES = {\n\ttheme: 'pattern',\n\tuser: 'wp_block',\n};\n\nexport const PATTERN_DEFAULT_CATEGORY = 'all-patterns';\nexport const PATTERN_USER_CATEGORY = 'my-patterns';\nexport const EXCLUDED_PATTERN_SOURCES = [\n\t'core',\n\t'pattern-directory/core',\n\t'pattern-directory/featured',\n];\nexport const PATTERN_SYNC_TYPES = {\n\tfull: 'fully',\n\tunsynced: 'unsynced',\n};\n"],"mappings":"AAAA,OAAO,MAAMA,aAAa,GAAG;EAC5BC,KAAK,EAAE,SAAS;EAChBC,IAAI,EAAE;AACP,CAAC;AAED,OAAO,MAAMC,wBAAwB,GAAG,cAAc;AACtD,OAAO,MAAMC,qBAAqB,GAAG,aAAa;AAClD,OAAO,MAAMC,wBAAwB,GAAG,CACvC,MAAM,EACN,wBAAwB,EACxB,4BAA4B,CAC5B;AACD,OAAO,MAAMC,kBAAkB,GAAG;EACjCC,IAAI,EAAE,OAAO;EACbC,QAAQ,EAAE;AACX,CAAC"}
1
+ {"version":3,"names":["__","PATTERN_TYPES","theme","user","PATTERN_DEFAULT_CATEGORY","PATTERN_USER_CATEGORY","EXCLUDED_PATTERN_SOURCES","PATTERN_SYNC_TYPES","full","unsynced","PARTIAL_SYNCING_SUPPORTED_BLOCKS","content"],"sources":["@wordpress/patterns/src/constants.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\n\nexport const PATTERN_TYPES = {\n\ttheme: 'pattern',\n\tuser: 'wp_block',\n};\n\nexport const PATTERN_DEFAULT_CATEGORY = 'all-patterns';\nexport const PATTERN_USER_CATEGORY = 'my-patterns';\nexport const EXCLUDED_PATTERN_SOURCES = [\n\t'core',\n\t'pattern-directory/core',\n\t'pattern-directory/featured',\n];\nexport const PATTERN_SYNC_TYPES = {\n\tfull: 'fully',\n\tunsynced: 'unsynced',\n};\n\n// TODO: This should not be hardcoded. Maybe there should be a config and/or an UI.\nexport const PARTIAL_SYNCING_SUPPORTED_BLOCKS = {\n\t'core/paragraph': { content: __( 'Content' ) },\n};\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;AAEpC,OAAO,MAAMC,aAAa,GAAG;EAC5BC,KAAK,EAAE,SAAS;EAChBC,IAAI,EAAE;AACP,CAAC;AAED,OAAO,MAAMC,wBAAwB,GAAG,cAAc;AACtD,OAAO,MAAMC,qBAAqB,GAAG,aAAa;AAClD,OAAO,MAAMC,wBAAwB,GAAG,CACvC,MAAM,EACN,wBAAwB,EACxB,4BAA4B,CAC5B;AACD,OAAO,MAAMC,kBAAkB,GAAG;EACjCC,IAAI,EAAE,OAAO;EACbC,QAAQ,EAAE;AACX,CAAC;;AAED;AACA,OAAO,MAAMC,gCAAgC,GAAG;EAC/C,gBAAgB,EAAE;IAAEC,OAAO,EAAEX,EAAE,CAAE,SAAU;EAAE;AAC9C,CAAC"}
@@ -7,7 +7,8 @@ import DuplicatePatternModal from './components/duplicate-pattern-modal';
7
7
  import RenamePatternModal from './components/rename-pattern-modal';
8
8
  import PatternsMenuItems from './components';
9
9
  import RenamePatternCategoryModal from './components/rename-pattern-category-modal';
10
- import { PATTERN_TYPES, PATTERN_DEFAULT_CATEGORY, PATTERN_USER_CATEGORY, EXCLUDED_PATTERN_SOURCES, PATTERN_SYNC_TYPES } from './constants';
10
+ import PartialSyncingControls from './components/partial-syncing-controls';
11
+ import { PATTERN_TYPES, PATTERN_DEFAULT_CATEGORY, PATTERN_USER_CATEGORY, EXCLUDED_PATTERN_SOURCES, PATTERN_SYNC_TYPES, PARTIAL_SYNCING_SUPPORTED_BLOCKS } from './constants';
11
12
  export const privateApis = {};
12
13
  lock(privateApis, {
13
14
  CreatePatternModal,
@@ -15,10 +16,12 @@ lock(privateApis, {
15
16
  RenamePatternModal,
16
17
  PatternsMenuItems,
17
18
  RenamePatternCategoryModal,
19
+ PartialSyncingControls,
18
20
  PATTERN_TYPES,
19
21
  PATTERN_DEFAULT_CATEGORY,
20
22
  PATTERN_USER_CATEGORY,
21
23
  EXCLUDED_PATTERN_SOURCES,
22
- PATTERN_SYNC_TYPES
24
+ PATTERN_SYNC_TYPES,
25
+ PARTIAL_SYNCING_SUPPORTED_BLOCKS
23
26
  });
24
27
  //# sourceMappingURL=private-apis.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["lock","CreatePatternModal","DuplicatePatternModal","RenamePatternModal","PatternsMenuItems","RenamePatternCategoryModal","PATTERN_TYPES","PATTERN_DEFAULT_CATEGORY","PATTERN_USER_CATEGORY","EXCLUDED_PATTERN_SOURCES","PATTERN_SYNC_TYPES","privateApis"],"sources":["@wordpress/patterns/src/private-apis.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport { lock } from './lock-unlock';\nimport CreatePatternModal from './components/create-pattern-modal';\nimport DuplicatePatternModal from './components/duplicate-pattern-modal';\nimport RenamePatternModal from './components/rename-pattern-modal';\nimport PatternsMenuItems from './components';\nimport RenamePatternCategoryModal from './components/rename-pattern-category-modal';\nimport {\n\tPATTERN_TYPES,\n\tPATTERN_DEFAULT_CATEGORY,\n\tPATTERN_USER_CATEGORY,\n\tEXCLUDED_PATTERN_SOURCES,\n\tPATTERN_SYNC_TYPES,\n} from './constants';\n\nexport const privateApis = {};\nlock( privateApis, {\n\tCreatePatternModal,\n\tDuplicatePatternModal,\n\tRenamePatternModal,\n\tPatternsMenuItems,\n\tRenamePatternCategoryModal,\n\tPATTERN_TYPES,\n\tPATTERN_DEFAULT_CATEGORY,\n\tPATTERN_USER_CATEGORY,\n\tEXCLUDED_PATTERN_SOURCES,\n\tPATTERN_SYNC_TYPES,\n} );\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,IAAI,QAAQ,eAAe;AACpC,OAAOC,kBAAkB,MAAM,mCAAmC;AAClE,OAAOC,qBAAqB,MAAM,sCAAsC;AACxE,OAAOC,kBAAkB,MAAM,mCAAmC;AAClE,OAAOC,iBAAiB,MAAM,cAAc;AAC5C,OAAOC,0BAA0B,MAAM,4CAA4C;AACnF,SACCC,aAAa,EACbC,wBAAwB,EACxBC,qBAAqB,EACrBC,wBAAwB,EACxBC,kBAAkB,QACZ,aAAa;AAEpB,OAAO,MAAMC,WAAW,GAAG,CAAC,CAAC;AAC7BX,IAAI,CAAEW,WAAW,EAAE;EAClBV,kBAAkB;EAClBC,qBAAqB;EACrBC,kBAAkB;EAClBC,iBAAiB;EACjBC,0BAA0B;EAC1BC,aAAa;EACbC,wBAAwB;EACxBC,qBAAqB;EACrBC,wBAAwB;EACxBC;AACD,CAAE,CAAC"}
1
+ {"version":3,"names":["lock","CreatePatternModal","DuplicatePatternModal","RenamePatternModal","PatternsMenuItems","RenamePatternCategoryModal","PartialSyncingControls","PATTERN_TYPES","PATTERN_DEFAULT_CATEGORY","PATTERN_USER_CATEGORY","EXCLUDED_PATTERN_SOURCES","PATTERN_SYNC_TYPES","PARTIAL_SYNCING_SUPPORTED_BLOCKS","privateApis"],"sources":["@wordpress/patterns/src/private-apis.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport { lock } from './lock-unlock';\nimport CreatePatternModal from './components/create-pattern-modal';\nimport DuplicatePatternModal from './components/duplicate-pattern-modal';\nimport RenamePatternModal from './components/rename-pattern-modal';\nimport PatternsMenuItems from './components';\nimport RenamePatternCategoryModal from './components/rename-pattern-category-modal';\nimport PartialSyncingControls from './components/partial-syncing-controls';\nimport {\n\tPATTERN_TYPES,\n\tPATTERN_DEFAULT_CATEGORY,\n\tPATTERN_USER_CATEGORY,\n\tEXCLUDED_PATTERN_SOURCES,\n\tPATTERN_SYNC_TYPES,\n\tPARTIAL_SYNCING_SUPPORTED_BLOCKS,\n} from './constants';\n\nexport const privateApis = {};\nlock( privateApis, {\n\tCreatePatternModal,\n\tDuplicatePatternModal,\n\tRenamePatternModal,\n\tPatternsMenuItems,\n\tRenamePatternCategoryModal,\n\tPartialSyncingControls,\n\tPATTERN_TYPES,\n\tPATTERN_DEFAULT_CATEGORY,\n\tPATTERN_USER_CATEGORY,\n\tEXCLUDED_PATTERN_SOURCES,\n\tPATTERN_SYNC_TYPES,\n\tPARTIAL_SYNCING_SUPPORTED_BLOCKS,\n} );\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,IAAI,QAAQ,eAAe;AACpC,OAAOC,kBAAkB,MAAM,mCAAmC;AAClE,OAAOC,qBAAqB,MAAM,sCAAsC;AACxE,OAAOC,kBAAkB,MAAM,mCAAmC;AAClE,OAAOC,iBAAiB,MAAM,cAAc;AAC5C,OAAOC,0BAA0B,MAAM,4CAA4C;AACnF,OAAOC,sBAAsB,MAAM,uCAAuC;AAC1E,SACCC,aAAa,EACbC,wBAAwB,EACxBC,qBAAqB,EACrBC,wBAAwB,EACxBC,kBAAkB,EAClBC,gCAAgC,QAC1B,aAAa;AAEpB,OAAO,MAAMC,WAAW,GAAG,CAAC,CAAC;AAC7Bb,IAAI,CAAEa,WAAW,EAAE;EAClBZ,kBAAkB;EAClBC,qBAAqB;EACrBC,kBAAkB;EAClBC,iBAAiB;EACjBC,0BAA0B;EAC1BC,sBAAsB;EACtBC,aAAa;EACbC,wBAAwB;EACxBC,qBAAqB;EACrBC,wBAAwB;EACxBC,kBAAkB;EAClBC;AACD,CAAE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/patterns",
3
- "version": "1.8.0",
3
+ "version": "1.9.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,21 @@
31
31
  ],
32
32
  "dependencies": {
33
33
  "@babel/runtime": "^7.16.0",
34
- "@wordpress/a11y": "^3.47.0",
35
- "@wordpress/block-editor": "^12.15.0",
36
- "@wordpress/blocks": "^12.24.0",
37
- "@wordpress/components": "^25.13.0",
38
- "@wordpress/compose": "^6.24.0",
39
- "@wordpress/core-data": "^6.24.0",
40
- "@wordpress/data": "^9.17.0",
41
- "@wordpress/element": "^5.24.0",
42
- "@wordpress/html-entities": "^3.47.0",
43
- "@wordpress/i18n": "^4.47.0",
44
- "@wordpress/icons": "^9.38.0",
45
- "@wordpress/notices": "^4.15.0",
46
- "@wordpress/private-apis": "^0.29.0",
47
- "@wordpress/url": "^3.48.0"
34
+ "@wordpress/a11y": "^3.48.0",
35
+ "@wordpress/block-editor": "^12.16.0",
36
+ "@wordpress/blocks": "^12.25.0",
37
+ "@wordpress/components": "^25.14.0",
38
+ "@wordpress/compose": "^6.25.0",
39
+ "@wordpress/core-data": "^6.25.0",
40
+ "@wordpress/data": "^9.18.0",
41
+ "@wordpress/element": "^5.25.0",
42
+ "@wordpress/html-entities": "^3.48.0",
43
+ "@wordpress/i18n": "^4.48.0",
44
+ "@wordpress/icons": "^9.39.0",
45
+ "@wordpress/notices": "^4.16.0",
46
+ "@wordpress/private-apis": "^0.30.0",
47
+ "@wordpress/url": "^3.49.0",
48
+ "nanoid": "^3.3.4"
48
49
  },
49
50
  "peerDependencies": {
50
51
  "react": "^18.0.0",
@@ -53,5 +54,5 @@
53
54
  "publishConfig": {
54
55
  "access": "public"
55
56
  },
56
- "gitHead": "d98dff8ea96f29cfea045bf964269f46f040d539"
57
+ "gitHead": "fcf61b4beff747222c2c81d09d757ca1a0abd925"
57
58
  }
@@ -0,0 +1,98 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import { nanoid } from 'nanoid';
5
+
6
+ /**
7
+ * WordPress dependencies
8
+ */
9
+ import { InspectorControls } from '@wordpress/block-editor';
10
+ import { BaseControl, CheckboxControl } from '@wordpress/components';
11
+ import { __ } from '@wordpress/i18n';
12
+
13
+ /**
14
+ * Internal dependencies
15
+ */
16
+ import { PARTIAL_SYNCING_SUPPORTED_BLOCKS } from '../constants';
17
+
18
+ function PartialSyncingControls( { name, attributes, setAttributes } ) {
19
+ const syncedAttributes = PARTIAL_SYNCING_SUPPORTED_BLOCKS[ name ];
20
+
21
+ function updateConnections( attributeName, isChecked ) {
22
+ if ( ! isChecked ) {
23
+ let updatedConnections = {
24
+ ...attributes.connections,
25
+ attributes: {
26
+ ...attributes.connections?.attributes,
27
+ [ attributeName ]: undefined,
28
+ },
29
+ };
30
+ if ( Object.keys( updatedConnections.attributes ).length === 1 ) {
31
+ updatedConnections.attributes = undefined;
32
+ }
33
+ if (
34
+ Object.keys( updatedConnections ).length === 1 &&
35
+ updateConnections.attributes === undefined
36
+ ) {
37
+ updatedConnections = undefined;
38
+ }
39
+ setAttributes( {
40
+ connections: updatedConnections,
41
+ } );
42
+ return;
43
+ }
44
+
45
+ const updatedConnections = {
46
+ ...attributes.connections,
47
+ attributes: {
48
+ ...attributes.connections?.attributes,
49
+ [ attributeName ]: {
50
+ source: 'pattern_attributes',
51
+ },
52
+ },
53
+ };
54
+
55
+ if ( typeof attributes.metadata?.id === 'string' ) {
56
+ setAttributes( { connections: updatedConnections } );
57
+ return;
58
+ }
59
+
60
+ const id = nanoid( 6 );
61
+ setAttributes( {
62
+ connections: updatedConnections,
63
+ metadata: {
64
+ ...attributes.metadata,
65
+ id,
66
+ },
67
+ } );
68
+ }
69
+
70
+ return (
71
+ <InspectorControls group="advanced">
72
+ <BaseControl __nextHasNoMarginBottom>
73
+ <BaseControl.VisualLabel>
74
+ { __( 'Synced attributes' ) }
75
+ </BaseControl.VisualLabel>
76
+ { Object.entries( syncedAttributes ).map(
77
+ ( [ attributeName, label ] ) => (
78
+ <CheckboxControl
79
+ key={ attributeName }
80
+ __nextHasNoMarginBottom
81
+ label={ label }
82
+ checked={
83
+ attributes.connections?.attributes?.[
84
+ attributeName
85
+ ]?.source === 'pattern_attributes'
86
+ }
87
+ onChange={ ( isChecked ) => {
88
+ updateConnections( attributeName, isChecked );
89
+ } }
90
+ />
91
+ )
92
+ ) }
93
+ </BaseControl>
94
+ </InspectorControls>
95
+ );
96
+ }
97
+
98
+ export default PartialSyncingControls;
@@ -138,6 +138,7 @@ export default function RenamePatternCategoryModal( {
138
138
  <TextControl
139
139
  ref={ textControlRef }
140
140
  __nextHasNoMarginBottom
141
+ __next40pxDefaultSize
141
142
  label={ __( 'Name' ) }
142
143
  value={ name }
143
144
  onChange={ onChange }
@@ -154,10 +155,15 @@ export default function RenamePatternCategoryModal( {
154
155
  ) }
155
156
  </VStack>
156
157
  <HStack justify="right">
157
- <Button variant="tertiary" onClick={ onRequestClose }>
158
+ <Button
159
+ __next40pxDefaultSize
160
+ variant="tertiary"
161
+ onClick={ onRequestClose }
162
+ >
158
163
  { __( 'Cancel' ) }
159
164
  </Button>
160
165
  <Button
166
+ __next40pxDefaultSize
161
167
  variant="primary"
162
168
  type="submit"
163
169
  aria-disabled={
@@ -93,6 +93,7 @@ export default function RenamePatternModal( {
93
93
  <VStack spacing="5">
94
94
  <TextControl
95
95
  __nextHasNoMarginBottom
96
+ __next40pxDefaultSize
96
97
  label={ __( 'Name' ) }
97
98
  value={ name }
98
99
  onChange={ setName }
@@ -100,11 +101,19 @@ export default function RenamePatternModal( {
100
101
  />
101
102
 
102
103
  <HStack justify="right">
103
- <Button variant="tertiary" onClick={ onRequestClose }>
104
+ <Button
105
+ __next40pxDefaultSize
106
+ variant="tertiary"
107
+ onClick={ onRequestClose }
108
+ >
104
109
  { __( 'Cancel' ) }
105
110
  </Button>
106
111
 
107
- <Button variant="primary" type="submit">
112
+ <Button
113
+ __next40pxDefaultSize
114
+ variant="primary"
115
+ type="submit"
116
+ >
108
117
  { __( 'Save' ) }
109
118
  </Button>
110
119
  </HStack>
package/src/constants.js CHANGED
@@ -1,3 +1,8 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { __ } from '@wordpress/i18n';
5
+
1
6
  export const PATTERN_TYPES = {
2
7
  theme: 'pattern',
3
8
  user: 'wp_block',
@@ -14,3 +19,8 @@ export const PATTERN_SYNC_TYPES = {
14
19
  full: 'fully',
15
20
  unsynced: 'unsynced',
16
21
  };
22
+
23
+ // TODO: This should not be hardcoded. Maybe there should be a config and/or an UI.
24
+ export const PARTIAL_SYNCING_SUPPORTED_BLOCKS = {
25
+ 'core/paragraph': { content: __( 'Content' ) },
26
+ };
@@ -7,12 +7,14 @@ import DuplicatePatternModal from './components/duplicate-pattern-modal';
7
7
  import RenamePatternModal from './components/rename-pattern-modal';
8
8
  import PatternsMenuItems from './components';
9
9
  import RenamePatternCategoryModal from './components/rename-pattern-category-modal';
10
+ import PartialSyncingControls from './components/partial-syncing-controls';
10
11
  import {
11
12
  PATTERN_TYPES,
12
13
  PATTERN_DEFAULT_CATEGORY,
13
14
  PATTERN_USER_CATEGORY,
14
15
  EXCLUDED_PATTERN_SOURCES,
15
16
  PATTERN_SYNC_TYPES,
17
+ PARTIAL_SYNCING_SUPPORTED_BLOCKS,
16
18
  } from './constants';
17
19
 
18
20
  export const privateApis = {};
@@ -22,9 +24,11 @@ lock( privateApis, {
22
24
  RenamePatternModal,
23
25
  PatternsMenuItems,
24
26
  RenamePatternCategoryModal,
27
+ PartialSyncingControls,
25
28
  PATTERN_TYPES,
26
29
  PATTERN_DEFAULT_CATEGORY,
27
30
  PATTERN_USER_CATEGORY,
28
31
  EXCLUDED_PATTERN_SOURCES,
29
32
  PATTERN_SYNC_TYPES,
33
+ PARTIAL_SYNCING_SUPPORTED_BLOCKS,
30
34
  } );