@wordpress/patterns 1.7.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 +4 -0
- package/build/components/category-selector.js +2 -1
- package/build/components/category-selector.js.map +1 -1
- package/build/components/create-pattern-modal.js +6 -3
- package/build/components/create-pattern-modal.js.map +1 -1
- package/build/components/duplicate-pattern-modal.js +3 -3
- package/build/components/duplicate-pattern-modal.js.map +1 -1
- package/build/components/index.js +4 -2
- package/build/components/index.js.map +1 -1
- package/build/components/partial-syncing-controls.js +91 -0
- package/build/components/partial-syncing-controls.js.map +1 -0
- package/build/components/pattern-convert-button.js +7 -4
- package/build/components/pattern-convert-button.js.map +1 -1
- package/build/components/patterns-manage-button.js +1 -2
- package/build/components/patterns-manage-button.js.map +1 -1
- package/build/components/rename-pattern-category-modal.js +3 -0
- package/build/components/rename-pattern-category-modal.js.map +1 -1
- package/build/components/rename-pattern-modal.js +3 -0
- package/build/components/rename-pattern-modal.js.map +1 -1
- package/build/constants.js +14 -1
- package/build/constants.js.map +1 -1
- package/build/private-apis.js +4 -1
- package/build/private-apis.js.map +1 -1
- package/build-module/components/category-selector.js +2 -1
- package/build-module/components/category-selector.js.map +1 -1
- package/build-module/components/create-pattern-modal.js +6 -3
- package/build-module/components/create-pattern-modal.js.map +1 -1
- package/build-module/components/duplicate-pattern-modal.js +4 -4
- package/build-module/components/duplicate-pattern-modal.js.map +1 -1
- package/build-module/components/index.js +4 -2
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/partial-syncing-controls.js +83 -0
- package/build-module/components/partial-syncing-controls.js.map +1 -0
- package/build-module/components/pattern-convert-button.js +7 -4
- package/build-module/components/pattern-convert-button.js.map +1 -1
- package/build-module/components/patterns-manage-button.js +1 -2
- package/build-module/components/patterns-manage-button.js.map +1 -1
- package/build-module/components/rename-pattern-category-modal.js +3 -0
- package/build-module/components/rename-pattern-category-modal.js.map +1 -1
- package/build-module/components/rename-pattern-modal.js +3 -0
- package/build-module/components/rename-pattern-modal.js.map +1 -1
- package/build-module/constants.js +11 -0
- package/build-module/constants.js.map +1 -1
- package/build-module/private-apis.js +5 -2
- package/build-module/private-apis.js.map +1 -1
- package/build-style/style-rtl.css +6 -9
- package/build-style/style.css +6 -9
- package/package.json +17 -16
- package/src/components/category-selector.js +1 -0
- package/src/components/create-pattern-modal.js +5 -2
- package/src/components/duplicate-pattern-modal.js +7 -6
- package/src/components/index.js +2 -1
- package/src/components/partial-syncing-controls.js +98 -0
- package/src/components/pattern-convert-button.js +10 -4
- package/src/components/patterns-manage-button.js +34 -37
- package/src/components/rename-pattern-category-modal.js +7 -1
- package/src/components/rename-pattern-modal.js +11 -2
- package/src/components/style.scss +9 -14
- package/src/constants.js +10 -0
- package/src/private-apis.js +4 -0
|
@@ -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
|
|
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;A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A,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
|
|
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;EACPC,SAAS;EACTC,OAAO;EACP,GAAGC;AACJ,CAAC,EAAG;EACH,MAAMC,YAAY,GAAGT,cAAc,CAAEO,OAAO,CAACG,KAAM,CAAC;EACpD,MAAM,CAAEC,IAAI,EAAEC,OAAO,CAAE,GAAGb,QAAQ,CAAEU,YAAa,CAAC;EACl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AAE;QAChCL,IAAI,EAAE,UAAU;QAChBC,EAAE,EAAE;MACL,CAAE,CAAC;IACJ,CAAC,SAAS;MACTV,WAAW,CAAE,KAAM,CAAC;MACpBF,OAAO,CAAE,EAAG,CAAC;IACd;EACD,CAAC;EAED,MAAMmB,cAAc,GAAGA,CAAA,KAAM;IAC5B3B,OAAO,GAAG,CAAC;IACXQ,OAAO,CAAE,EAAG,CAAC;EACd,CAAC;EAED,OACCoB,aAAA,CAAC1C,KAAK;IAACoB,KAAK,EAAGT,EAAE,CAAE,QAAS,CAAG;IAAA,GAAMO,KAAK;IAAGuB,cAAc,EAAG3B;EAAS,GACtE4B,aAAA;IAAMC,QAAQ,EAAGb;EAAU,GAC1BY,aAAA,CAACrC,MAAM;IAACuC,OAAO,EAAC;EAAG,GAClBF,aAAA,CAACzC,WAAW;IACX4C,uBAAuB;IACvBC,qBAAqB;IACrBC,KAAK,EAAGpC,EAAE,CAAE,MAAO,CAAG;IACtBqC,KAAK,EAAG3B,IAAM;IACd4B,QAAQ,EAAG3B,OAAS;IACpB4B,QAAQ;EAAA,CACR,CAAC,EAEFR,aAAA,CAACvC,MAAM;IAACgD,OAAO,EAAC;EAAO,GACtBT,aAAA,CAAC3C,MAAM;IACN+C,qBAAqB;IACrBM,OAAO,EAAC,UAAU;IAClBC,OAAO,EAAGZ;EAAgB,GAExB9B,EAAE,CAAE,QAAS,CACR,CAAC,EAET+B,aAAA,CAAC3C,MAAM;IACN+C,qBAAqB;IACrBM,OAAO,EAAC,SAAS;IACjBnB,IAAI,EAAC;EAAQ,GAEXtB,EAAE,CAAE,MAAO,CACN,CACD,CACD,CACH,CACA,CAAC;AAEV"}
|
|
@@ -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":["
|
|
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
|
|
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,
|
|
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"}
|
|
@@ -110,27 +110,24 @@
|
|
|
110
110
|
width: 350px;
|
|
111
111
|
}
|
|
112
112
|
.patterns-menu-items__convert-modal .patterns-menu-items__convert-modal-categories {
|
|
113
|
-
width: 100%;
|
|
114
113
|
position: relative;
|
|
115
|
-
min-height: 40px;
|
|
116
114
|
}
|
|
117
|
-
.patterns-menu-items__convert-modal .components-form-token-field__suggestions-list {
|
|
115
|
+
.patterns-menu-items__convert-modal .components-form-token-field__suggestions-list:not(:empty) {
|
|
118
116
|
position: absolute;
|
|
117
|
+
border: 1px solid var(--wp-admin-theme-color);
|
|
118
|
+
border-bottom-right-radius: 2px;
|
|
119
|
+
border-bottom-left-radius: 2px;
|
|
120
|
+
box-shadow: 0 0 0.5px 0.5px var(--wp-admin-theme-color);
|
|
119
121
|
box-sizing: border-box;
|
|
120
122
|
z-index: 1;
|
|
121
123
|
background-color: #fff;
|
|
122
124
|
width: calc(100% + 2px);
|
|
123
125
|
right: -1px;
|
|
124
126
|
min-width: initial;
|
|
125
|
-
|
|
126
|
-
border-top: none;
|
|
127
|
-
box-shadow: 0 0 0 0.5px var(--wp-admin-theme-color);
|
|
128
|
-
border-bottom-right-radius: 2px;
|
|
129
|
-
border-bottom-left-radius: 2px;
|
|
127
|
+
max-height: 96px;
|
|
130
128
|
}
|
|
131
129
|
|
|
132
130
|
.patterns-create-modal__name-input input[type=text] {
|
|
133
|
-
min-height: 40px;
|
|
134
131
|
margin: 0;
|
|
135
132
|
}
|
|
136
133
|
|
package/build-style/style.css
CHANGED
|
@@ -110,27 +110,24 @@
|
|
|
110
110
|
width: 350px;
|
|
111
111
|
}
|
|
112
112
|
.patterns-menu-items__convert-modal .patterns-menu-items__convert-modal-categories {
|
|
113
|
-
width: 100%;
|
|
114
113
|
position: relative;
|
|
115
|
-
min-height: 40px;
|
|
116
114
|
}
|
|
117
|
-
.patterns-menu-items__convert-modal .components-form-token-field__suggestions-list {
|
|
115
|
+
.patterns-menu-items__convert-modal .components-form-token-field__suggestions-list:not(:empty) {
|
|
118
116
|
position: absolute;
|
|
117
|
+
border: 1px solid var(--wp-admin-theme-color);
|
|
118
|
+
border-bottom-left-radius: 2px;
|
|
119
|
+
border-bottom-right-radius: 2px;
|
|
120
|
+
box-shadow: 0 0 0.5px 0.5px var(--wp-admin-theme-color);
|
|
119
121
|
box-sizing: border-box;
|
|
120
122
|
z-index: 1;
|
|
121
123
|
background-color: #fff;
|
|
122
124
|
width: calc(100% + 2px);
|
|
123
125
|
left: -1px;
|
|
124
126
|
min-width: initial;
|
|
125
|
-
|
|
126
|
-
border-top: none;
|
|
127
|
-
box-shadow: 0 0 0 0.5px var(--wp-admin-theme-color);
|
|
128
|
-
border-bottom-left-radius: 2px;
|
|
129
|
-
border-bottom-right-radius: 2px;
|
|
127
|
+
max-height: 96px;
|
|
130
128
|
}
|
|
131
129
|
|
|
132
130
|
.patterns-create-modal__name-input input[type=text] {
|
|
133
|
-
min-height: 40px;
|
|
134
131
|
margin: 0;
|
|
135
132
|
}
|
|
136
133
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/patterns",
|
|
3
|
-
"version": "1.
|
|
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.
|
|
35
|
-
"@wordpress/block-editor": "^12.
|
|
36
|
-
"@wordpress/blocks": "^12.
|
|
37
|
-
"@wordpress/components": "^25.
|
|
38
|
-
"@wordpress/compose": "^6.
|
|
39
|
-
"@wordpress/core-data": "^6.
|
|
40
|
-
"@wordpress/data": "^9.
|
|
41
|
-
"@wordpress/element": "^5.
|
|
42
|
-
"@wordpress/html-entities": "^3.
|
|
43
|
-
"@wordpress/i18n": "^4.
|
|
44
|
-
"@wordpress/icons": "^9.
|
|
45
|
-
"@wordpress/notices": "^4.
|
|
46
|
-
"@wordpress/private-apis": "^0.
|
|
47
|
-
"@wordpress/url": "^3.
|
|
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": "
|
|
57
|
+
"gitHead": "fcf61b4beff747222c2c81d09d757ca1a0abd925"
|
|
57
58
|
}
|
|
@@ -166,12 +166,13 @@ export default function CreatePatternModal( {
|
|
|
166
166
|
>
|
|
167
167
|
<VStack spacing="5">
|
|
168
168
|
<TextControl
|
|
169
|
-
__nextHasNoMarginBottom
|
|
170
169
|
label={ __( 'Name' ) }
|
|
171
170
|
value={ title }
|
|
172
171
|
onChange={ setTitle }
|
|
173
172
|
placeholder={ __( 'My pattern' ) }
|
|
174
173
|
className="patterns-create-modal__name-input"
|
|
174
|
+
__nextHasNoMarginBottom
|
|
175
|
+
__next40pxDefaultSize
|
|
175
176
|
/>
|
|
176
177
|
<CategorySelector
|
|
177
178
|
categoryTerms={ categoryTerms }
|
|
@@ -184,7 +185,7 @@ export default function CreatePatternModal( {
|
|
|
184
185
|
'Option that makes an individual pattern synchronized'
|
|
185
186
|
) }
|
|
186
187
|
help={ __(
|
|
187
|
-
'
|
|
188
|
+
'Sync this pattern across multiple locations.'
|
|
188
189
|
) }
|
|
189
190
|
checked={ syncType === PATTERN_SYNC_TYPES.full }
|
|
190
191
|
onChange={ () => {
|
|
@@ -197,6 +198,7 @@ export default function CreatePatternModal( {
|
|
|
197
198
|
/>
|
|
198
199
|
<HStack justify="right">
|
|
199
200
|
<Button
|
|
201
|
+
__next40pxDefaultSize
|
|
200
202
|
variant="tertiary"
|
|
201
203
|
onClick={ () => {
|
|
202
204
|
onClose();
|
|
@@ -207,6 +209,7 @@ export default function CreatePatternModal( {
|
|
|
207
209
|
</Button>
|
|
208
210
|
|
|
209
211
|
<Button
|
|
212
|
+
__next40pxDefaultSize
|
|
210
213
|
variant="primary"
|
|
211
214
|
type="submit"
|
|
212
215
|
aria-disabled={ ! title || isSaving }
|
|
@@ -10,11 +10,11 @@ import { store as noticesStore } from '@wordpress/notices';
|
|
|
10
10
|
* Internal dependencies
|
|
11
11
|
*/
|
|
12
12
|
import CreatePatternModal from './create-pattern-modal';
|
|
13
|
-
import { PATTERN_SYNC_TYPES } from '../constants';
|
|
13
|
+
import { PATTERN_SYNC_TYPES, PATTERN_TYPES } from '../constants';
|
|
14
14
|
|
|
15
15
|
function getTermLabels( pattern, categories ) {
|
|
16
|
-
// Theme patterns
|
|
17
|
-
if (
|
|
16
|
+
// Theme patterns rely on core pattern categories.
|
|
17
|
+
if ( pattern.type !== PATTERN_TYPES.user ) {
|
|
18
18
|
return categories.core
|
|
19
19
|
?.filter( ( category ) =>
|
|
20
20
|
pattern.categories.includes( category.name )
|
|
@@ -52,9 +52,10 @@ export default function DuplicatePatternModal( {
|
|
|
52
52
|
const duplicatedProps = {
|
|
53
53
|
content: pattern.content,
|
|
54
54
|
defaultCategories: getTermLabels( pattern, categories ),
|
|
55
|
-
defaultSyncType:
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
defaultSyncType:
|
|
56
|
+
pattern.type !== PATTERN_TYPES.user // Theme patterns are unsynced by default.
|
|
57
|
+
? PATTERN_SYNC_TYPES.unsynced
|
|
58
|
+
: pattern.wp_pattern_sync_status || PATTERN_SYNC_TYPES.full,
|
|
58
59
|
defaultTitle: sprintf(
|
|
59
60
|
/* translators: %s: Existing pattern title */
|
|
60
61
|
__( '%s (Copy)' ),
|
package/src/components/index.js
CHANGED
|
@@ -12,11 +12,12 @@ import PatternsManageButton from './patterns-manage-button';
|
|
|
12
12
|
export default function PatternsMenuItems( { rootClientId } ) {
|
|
13
13
|
return (
|
|
14
14
|
<BlockSettingsMenuControls>
|
|
15
|
-
{ ( { selectedClientIds } ) => (
|
|
15
|
+
{ ( { selectedClientIds, onClose } ) => (
|
|
16
16
|
<>
|
|
17
17
|
<PatternConvertButton
|
|
18
18
|
clientIds={ selectedClientIds }
|
|
19
19
|
rootClientId={ rootClientId }
|
|
20
|
+
closeBlockSettingsMenu={ onClose }
|
|
20
21
|
/>
|
|
21
22
|
{ selectedClientIds.length === 1 && (
|
|
22
23
|
<PatternsManageButton
|
|
@@ -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;
|
|
@@ -26,12 +26,17 @@ import { PATTERN_SYNC_TYPES } from '../constants';
|
|
|
26
26
|
/**
|
|
27
27
|
* Menu control to convert block(s) to a pattern block.
|
|
28
28
|
*
|
|
29
|
-
* @param {Object} props
|
|
30
|
-
* @param {string[]} props.clientIds
|
|
31
|
-
* @param {string} props.rootClientId
|
|
29
|
+
* @param {Object} props Component props.
|
|
30
|
+
* @param {string[]} props.clientIds Client ids of selected blocks.
|
|
31
|
+
* @param {string} props.rootClientId ID of the currently selected top-level block.
|
|
32
|
+
* @param {()=>void} props.closeBlockSettingsMenu Callback to close the block settings menu dropdown.
|
|
32
33
|
* @return {import('react').ComponentType} The menu control or null.
|
|
33
34
|
*/
|
|
34
|
-
export default function PatternConvertButton( {
|
|
35
|
+
export default function PatternConvertButton( {
|
|
36
|
+
clientIds,
|
|
37
|
+
rootClientId,
|
|
38
|
+
closeBlockSettingsMenu,
|
|
39
|
+
} ) {
|
|
35
40
|
const { createSuccessNotice } = useDispatch( noticesStore );
|
|
36
41
|
const { replaceBlocks } = useDispatch( blockEditorStore );
|
|
37
42
|
// Ignore reason: false positive of the lint rule.
|
|
@@ -104,6 +109,7 @@ export default function PatternConvertButton( { clientIds, rootClientId } ) {
|
|
|
104
109
|
|
|
105
110
|
replaceBlocks( clientIds, newBlock );
|
|
106
111
|
setEditingPattern( newBlock.clientId, true );
|
|
112
|
+
closeBlockSettingsMenu();
|
|
107
113
|
}
|
|
108
114
|
|
|
109
115
|
createSuccessNotice(
|
|
@@ -16,41 +16,40 @@ import { store as patternsStore } from '../store';
|
|
|
16
16
|
import { unlock } from '../lock-unlock';
|
|
17
17
|
|
|
18
18
|
function PatternsManageButton( { clientId } ) {
|
|
19
|
-
const { canRemove, isVisible,
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const isBlockTheme = getSettings().__unstableIsBlockBasedTheme;
|
|
19
|
+
const { canRemove, isVisible, managePatternsUrl } = useSelect(
|
|
20
|
+
( select ) => {
|
|
21
|
+
const { getBlock, canRemoveBlock, getBlockCount, getSettings } =
|
|
22
|
+
select( blockEditorStore );
|
|
23
|
+
const { canUser } = select( coreStore );
|
|
24
|
+
const reusableBlock = getBlock( clientId );
|
|
25
|
+
const isBlockTheme = getSettings().__unstableIsBlockBasedTheme;
|
|
27
26
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
27
|
+
return {
|
|
28
|
+
canRemove: canRemoveBlock( clientId ),
|
|
29
|
+
isVisible:
|
|
30
|
+
!! reusableBlock &&
|
|
31
|
+
isReusableBlock( reusableBlock ) &&
|
|
32
|
+
!! canUser(
|
|
33
|
+
'update',
|
|
34
|
+
'blocks',
|
|
35
|
+
reusableBlock.attributes.ref
|
|
36
|
+
),
|
|
37
|
+
innerBlockCount: getBlockCount( clientId ),
|
|
38
|
+
// The site editor and templates both check whether the user
|
|
39
|
+
// has edit_theme_options capabilities. We can leverage that here
|
|
40
|
+
// and omit the manage patterns link if the user can't access it.
|
|
41
|
+
managePatternsUrl:
|
|
42
|
+
isBlockTheme && canUser( 'read', 'templates' )
|
|
43
|
+
? addQueryArgs( 'site-editor.php', {
|
|
44
|
+
path: '/patterns',
|
|
45
|
+
} )
|
|
46
|
+
: addQueryArgs( 'edit.php', {
|
|
47
|
+
post_type: 'wp_block',
|
|
48
|
+
} ),
|
|
49
|
+
};
|
|
50
|
+
},
|
|
51
|
+
[ clientId ]
|
|
52
|
+
);
|
|
54
53
|
|
|
55
54
|
// Ignore reason: false positive of the lint rule.
|
|
56
55
|
// eslint-disable-next-line @wordpress/no-unused-vars-before-return
|
|
@@ -68,9 +67,7 @@ function PatternsManageButton( { clientId } ) {
|
|
|
68
67
|
<MenuItem
|
|
69
68
|
onClick={ () => convertSyncedPatternToStatic( clientId ) }
|
|
70
69
|
>
|
|
71
|
-
{
|
|
72
|
-
? __( 'Detach patterns' )
|
|
73
|
-
: __( 'Detach pattern' ) }
|
|
70
|
+
{ __( 'Detach' ) }
|
|
74
71
|
</MenuItem>
|
|
75
72
|
) }
|
|
76
73
|
<MenuItem href={ managePatternsUrl }>
|
|
@@ -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
|
|
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={
|