@wordpress/customize-widgets 4.13.0 → 4.15.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,10 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 4.15.0 (2023-07-20)
6
+
7
+ ## 4.14.0 (2023-07-05)
8
+
5
9
  ## 4.13.0 (2023-06-23)
6
10
 
7
11
  ## 4.12.0 (2023-06-07)
package/build/index.js CHANGED
@@ -6,6 +6,12 @@ Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
8
  exports.initialize = initialize;
9
+ Object.defineProperty(exports, "store", {
10
+ enumerable: true,
11
+ get: function () {
12
+ return _store.store;
13
+ }
14
+ });
9
15
 
10
16
  var _element = require("@wordpress/element");
11
17
 
@@ -27,6 +33,8 @@ var _sidebarControl = _interopRequireDefault(require("./controls/sidebar-control
27
33
 
28
34
  require("./filters");
29
35
 
36
+ var _store = require("./store");
37
+
30
38
  /**
31
39
  * WordPress dependencies
32
40
  */
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/customize-widgets/src/index.js"],"names":["wp","window","DISABLED_BLOCKS","ENABLE_EXPERIMENTAL_FSE_BLOCKS","initialize","editorName","blockEditorSettings","preferencesStore","setDefaults","fixedToolbar","welcomeGuide","blocksStore","__experimentalReapplyBlockTypeFilters","coreBlocks","filter","block","includes","name","startsWith","process","env","IS_GUTENBERG_PLUGIN","enableFSEBlocks","SidebarControl","customize","sectionConstructor","sidebar","controlConstructor","sidebar_block_editor","container","document","createElement","body","appendChild","bind","sidebarControls","control","each","push","render"],"mappings":";;;;;;;;;AAGA;;AACA;;AAKA;;AAKA;;AAIA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AA3BA;AACA;AACA;;AAmBA;AACA;AACA;AAMA,MAAM;AAAEA,EAAAA;AAAF,IAASC,MAAf;AAEA,MAAMC,eAAe,GAAG,CACvB,WADuB,EAEvB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B;AACAD,EAAAA,QAAQ,CAACE,IAAT,CAAcC,WAAd,CAA2BJ,SAA3B;AAEA7B,EAAAA,EAAE,CAACwB,SAAH,CAAaU,IAAb,CAAmB,OAAnB,EAA4B,MAAM;AACjC,UAAMC,eAAe,GAAG,EAAxB;AACAnC,IAAAA,EAAE,CAACwB,SAAH,CAAaY,OAAb,CAAqBC,IAArB,CAA6BD,OAAF,IAAe;AACzC,UAAKA,OAAO,YAAYb,cAAxB,EAAyC;AACxCY,QAAAA,eAAe,CAACG,IAAhB,CAAsBF,OAAtB;AACA;AACD,KAJD;AAMA,6BAAYP,SAAZ,EAAwBU,MAAxB,CACC,4BAAC,yBAAD;AACC,MAAA,GAAG,EAAGvC,EAAE,CAACwB,SADV;AAEC,MAAA,eAAe,EAAGW,eAFnB;AAGC,MAAA,mBAAmB,EAAG7B;AAHvB,MADD;AAOA,GAfD;AAgBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createRoot } from '@wordpress/element';\nimport {\n\tregisterCoreBlocks,\n\t__experimentalGetCoreBlocks,\n\t__experimentalRegisterExperimentalCoreBlocks,\n} from '@wordpress/block-library';\nimport {\n\tregisterLegacyWidgetBlock,\n\tregisterLegacyWidgetVariations,\n\tregisterWidgetGroupBlock,\n} from '@wordpress/widgets';\nimport {\n\tsetFreeformContentHandlerName,\n\tstore as blocksStore,\n} from '@wordpress/blocks';\nimport { dispatch } from '@wordpress/data';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\n/**\n * Internal dependencies\n */\nimport CustomizeWidgets from './components/customize-widgets';\nimport getSidebarSection from './controls/sidebar-section';\nimport getSidebarControl from './controls/sidebar-control';\nimport './filters';\n\nconst { wp } = window;\n\nconst DISABLED_BLOCKS = [\n\t'core/more',\n\t'core/block',\n\t'core/freeform',\n\t'core/template-part',\n];\nconst ENABLE_EXPERIMENTAL_FSE_BLOCKS = false;\n\n/**\n * Initializes the widgets block editor in the customizer.\n *\n * @param {string} editorName The editor name.\n * @param {Object} blockEditorSettings Block editor settings.\n */\nexport function initialize( editorName, blockEditorSettings ) {\n\tdispatch( preferencesStore ).setDefaults( 'core/customize-widgets', {\n\t\tfixedToolbar: false,\n\t\twelcomeGuide: true,\n\t} );\n\n\tdispatch( blocksStore ).__experimentalReapplyBlockTypeFilters();\n\tconst coreBlocks = __experimentalGetCoreBlocks().filter( ( block ) => {\n\t\treturn ! (\n\t\t\tDISABLED_BLOCKS.includes( block.name ) ||\n\t\t\tblock.name.startsWith( 'core/post' ) ||\n\t\t\tblock.name.startsWith( 'core/query' ) ||\n\t\t\tblock.name.startsWith( 'core/site' ) ||\n\t\t\tblock.name.startsWith( 'core/navigation' )\n\t\t);\n\t} );\n\tregisterCoreBlocks( coreBlocks );\n\tregisterLegacyWidgetBlock();\n\tif ( process.env.IS_GUTENBERG_PLUGIN ) {\n\t\t__experimentalRegisterExperimentalCoreBlocks( {\n\t\t\tenableFSEBlocks: ENABLE_EXPERIMENTAL_FSE_BLOCKS,\n\t\t} );\n\t}\n\tregisterLegacyWidgetVariations( blockEditorSettings );\n\tregisterWidgetGroupBlock();\n\n\t// As we are unregistering `core/freeform` to avoid the Classic block, we must\n\t// replace it with something as the default freeform content handler. Failure to\n\t// do this will result in errors in the default block parser.\n\t// see: https://github.com/WordPress/gutenberg/issues/33097\n\tsetFreeformContentHandlerName( 'core/html' );\n\n\tconst SidebarControl = getSidebarControl( blockEditorSettings );\n\n\twp.customize.sectionConstructor.sidebar = getSidebarSection();\n\twp.customize.controlConstructor.sidebar_block_editor = SidebarControl;\n\n\tconst container = document.createElement( 'div' );\n\tdocument.body.appendChild( container );\n\n\twp.customize.bind( 'ready', () => {\n\t\tconst sidebarControls = [];\n\t\twp.customize.control.each( ( control ) => {\n\t\t\tif ( control instanceof SidebarControl ) {\n\t\t\t\tsidebarControls.push( control );\n\t\t\t}\n\t\t} );\n\n\t\tcreateRoot( container ).render(\n\t\t\t<CustomizeWidgets\n\t\t\t\tapi={ wp.customize }\n\t\t\t\tsidebarControls={ sidebarControls }\n\t\t\t\tblockEditorSettings={ blockEditorSettings }\n\t\t\t/>\n\t\t);\n\t} );\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/customize-widgets/src/index.js"],"names":["wp","window","DISABLED_BLOCKS","ENABLE_EXPERIMENTAL_FSE_BLOCKS","initialize","editorName","blockEditorSettings","preferencesStore","setDefaults","fixedToolbar","welcomeGuide","blocksStore","__experimentalReapplyBlockTypeFilters","coreBlocks","filter","block","includes","name","startsWith","process","env","IS_GUTENBERG_PLUGIN","enableFSEBlocks","SidebarControl","customize","sectionConstructor","sidebar","controlConstructor","sidebar_block_editor","container","document","createElement","body","appendChild","bind","sidebarControls","control","each","push","render"],"mappings":";;;;;;;;;;;;;;;AAGA;;AACA;;AAKA;;AAKA;;AAIA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AA2EA;;AAtGA;AACA;AACA;;AAmBA;AACA;AACA;AAMA,MAAM;AAAEA,EAAAA;AAAF,IAASC,MAAf;AAEA,MAAMC,eAAe,GAAG,CACvB,WADuB,EAEvB,YAFuB,EAGvB,eAHuB,EAIvB,oBAJuB,CAAxB;AAMA,MAAMC,8BAA8B,GAAG,KAAvC;AAEA;AACA;AACA;AACA;AACA;AACA;;AACO,SAASC,UAAT,CAAqBC,UAArB,EAAiCC,mBAAjC,EAAuD;AAC7D,sBAAUC,kBAAV,EAA6BC,WAA7B,CAA0C,wBAA1C,EAAoE;AACnEC,IAAAA,YAAY,EAAE,KADqD;AAEnEC,IAAAA,YAAY,EAAE;AAFqD,GAApE;;AAKA,sBAAUC,aAAV,EAAwBC,qCAAxB;;AACA,QAAMC,UAAU,GAAG,iDAA8BC,MAA9B,CAAwCC,KAAF,IAAa;AACrE,WAAO,EACNb,eAAe,CAACc,QAAhB,CAA0BD,KAAK,CAACE,IAAhC,KACAF,KAAK,CAACE,IAAN,CAAWC,UAAX,CAAuB,WAAvB,CADA,IAEAH,KAAK,CAACE,IAAN,CAAWC,UAAX,CAAuB,YAAvB,CAFA,IAGAH,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oot } from '@wordpress/element';\nimport {\n\tregisterCoreBlocks,\n\t__experimentalGetCoreBlocks,\n\t__experimentalRegisterExperimentalCoreBlocks,\n} from '@wordpress/block-library';\nimport {\n\tregisterLegacyWidgetBlock,\n\tregisterLegacyWidgetVariations,\n\tregisterWidgetGroupBlock,\n} from '@wordpress/widgets';\nimport {\n\tsetFreeformContentHandlerName,\n\tstore as blocksStore,\n} from '@wordpress/blocks';\nimport { dispatch } from '@wordpress/data';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\n/**\n * Internal dependencies\n */\nimport CustomizeWidgets from './components/customize-widgets';\nimport getSidebarSection from './controls/sidebar-section';\nimport getSidebarControl from './controls/sidebar-control';\nimport './filters';\n\nconst { wp } = window;\n\nconst DISABLED_BLOCKS = [\n\t'core/more',\n\t'core/block',\n\t'core/freeform',\n\t'core/template-part',\n];\nconst ENABLE_EXPERIMENTAL_FSE_BLOCKS = false;\n\n/**\n * Initializes the widgets block editor in the customizer.\n *\n * @param {string} editorName The editor name.\n * @param {Object} blockEditorSettings Block editor settings.\n */\nexport function initialize( editorName, blockEditorSettings ) {\n\tdispatch( preferencesStore ).setDefaults( 'core/customize-widgets', {\n\t\tfixedToolbar: false,\n\t\twelcomeGuide: true,\n\t} );\n\n\tdispatch( blocksStore ).__experimentalReapplyBlockTypeFilters();\n\tconst coreBlocks = __experimentalGetCoreBlocks().filter( ( block ) => {\n\t\treturn ! (\n\t\t\tDISABLED_BLOCKS.includes( block.name ) ||\n\t\t\tblock.name.startsWith( 'core/post' ) ||\n\t\t\tblock.name.startsWith( 'core/query' ) ||\n\t\t\tblock.name.startsWith( 'core/site' ) ||\n\t\t\tblock.name.startsWith( 'core/navigation' )\n\t\t);\n\t} );\n\tregisterCoreBlocks( coreBlocks );\n\tregisterLegacyWidgetBlock();\n\tif ( process.env.IS_GUTENBERG_PLUGIN ) {\n\t\t__experimentalRegisterExperimentalCoreBlocks( {\n\t\t\tenableFSEBlocks: ENABLE_EXPERIMENTAL_FSE_BLOCKS,\n\t\t} );\n\t}\n\tregisterLegacyWidgetVariations( blockEditorSettings );\n\tregisterWidgetGroupBlock();\n\n\t// As we are unregistering `core/freeform` to avoid the Classic block, we must\n\t// replace it with something as the default freeform content handler. Failure to\n\t// do this will result in errors in the default block parser.\n\t// see: https://github.com/WordPress/gutenberg/issues/33097\n\tsetFreeformContentHandlerName( 'core/html' );\n\n\tconst SidebarControl = getSidebarControl( blockEditorSettings );\n\n\twp.customize.sectionConstructor.sidebar = getSidebarSection();\n\twp.customize.controlConstructor.sidebar_block_editor = SidebarControl;\n\n\tconst container = document.createElement( 'div' );\n\tdocument.body.appendChild( container );\n\n\twp.customize.bind( 'ready', () => {\n\t\tconst sidebarControls = [];\n\t\twp.customize.control.each( ( control ) => {\n\t\t\tif ( control instanceof SidebarControl ) {\n\t\t\t\tsidebarControls.push( control );\n\t\t\t}\n\t\t} );\n\n\t\tcreateRoot( container ).render(\n\t\t\t<CustomizeWidgets\n\t\t\t\tapi={ wp.customize }\n\t\t\t\tsidebarControls={ sidebarControls }\n\t\t\t\tblockEditorSettings={ blockEditorSettings }\n\t\t\t/>\n\t\t);\n\t} );\n}\nexport { store } from './store';\n"]}
@@ -15,6 +15,31 @@ exports.setIsInserterOpened = setIsInserterOpened;
15
15
  * @param {string} value.rootClientId The root client ID to insert at.
16
16
  * @param {number} value.insertionIndex The index to insert at.
17
17
  *
18
+ * @example
19
+ * ```js
20
+ * import { store as customizeWidgetsStore } from '@wordpress/customize-widgets';
21
+ * import { __ } from '@wordpress/i18n';
22
+ * import { useDispatch } from '@wordpress/data';
23
+ * import { Button } from '@wordpress/components';
24
+ * import { useState } from '@wordpress/element';
25
+ *
26
+ * const ExampleComponent = () => {
27
+ * const { setIsInserterOpened } = useDispatch( customizeWidgetsStore );
28
+ * const [ isOpen, setIsOpen ] = useState( false );
29
+ *
30
+ * return (
31
+ * <Button
32
+ * onClick={ () => {
33
+ * setIsInserterOpened( ! isOpen );
34
+ * setIsOpen( ! isOpen );
35
+ * } }
36
+ * >
37
+ * { __( 'Open/close inserter' ) }
38
+ * </Button>
39
+ * );
40
+ * };
41
+ * ```
42
+ *
18
43
  * @return {Object} Action object.
19
44
  */
20
45
  function setIsInserterOpened(value) {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/customize-widgets/src/store/actions.js"],"names":["setIsInserterOpened","value","type"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,mBAAT,CAA8BC,KAA9B,EAAsC;AAC5C,SAAO;AACNC,IAAAA,IAAI,EAAE,wBADA;AAEND,IAAAA;AAFM,GAAP;AAIA","sourcesContent":["/**\n * Returns an action object used to open/close the inserter.\n *\n * @param {boolean|Object} value Whether the inserter should be\n * opened (true) or closed (false).\n * To specify an insertion point,\n * use an object.\n * @param {string} value.rootClientId The root client ID to insert at.\n * @param {number} value.insertionIndex The index to insert at.\n *\n * @return {Object} Action object.\n */\nexport function setIsInserterOpened( value ) {\n\treturn {\n\t\ttype: 'SET_IS_INSERTER_OPENED',\n\t\tvalue,\n\t};\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/customize-widgets/src/store/actions.js"],"names":["setIsInserterOpened","value","type"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,mBAAT,CAA8BC,KAA9B,EAAsC;AAC5C,SAAO;AACNC,IAAAA,IAAI,EAAE,wBADA;AAEND,IAAAA;AAFM,GAAP;AAIA","sourcesContent":["/**\n * Returns an action object used to open/close the inserter.\n *\n * @param {boolean|Object} value Whether the inserter should be\n * opened (true) or closed (false).\n * To specify an insertion point,\n * use an object.\n * @param {string} value.rootClientId The root client ID to insert at.\n * @param {number} value.insertionIndex The index to insert at.\n *\n * @example\n * ```js\n * import { store as customizeWidgetsStore } from '@wordpress/customize-widgets';\n * import { __ } from '@wordpress/i18n';\n * import { useDispatch } from '@wordpress/data';\n * import { Button } from '@wordpress/components';\n * import { useState } from '@wordpress/element';\n *\n * const ExampleComponent = () => {\n * const { setIsInserterOpened } = useDispatch( customizeWidgetsStore );\n * const [ isOpen, setIsOpen ] = useState( false );\n *\n * return (\n * <Button\n * onClick={ () => {\n * setIsInserterOpened( ! isOpen );\n * setIsOpen( ! isOpen );\n * } }\n * >\n * { __( 'Open/close inserter' ) }\n * </Button>\n * );\n * };\n * ```\n *\n * @return {Object} Action object.\n */\nexport function setIsInserterOpened( value ) {\n\treturn {\n\t\ttype: 'SET_IS_INSERTER_OPENED',\n\t\tvalue,\n\t};\n}\n"]}
@@ -11,6 +11,24 @@ exports.isInserterOpened = isInserterOpened;
11
11
  *
12
12
  * @param {Object} state Global application state.
13
13
  *
14
+ * @example
15
+ * ```js
16
+ * import { store as customizeWidgetsStore } from '@wordpress/customize-widgets';
17
+ * import { __ } from '@wordpress/i18n';
18
+ * import { useSelect } from '@wordpress/data';
19
+ *
20
+ * const ExampleComponent = () => {
21
+ * const { isInserterOpened } = useSelect(
22
+ * ( select ) => select( customizeWidgetsStore ),
23
+ * []
24
+ * );
25
+ *
26
+ * return isInserterOpened()
27
+ * ? __( 'Inserter is open' )
28
+ * : __( 'Inserter is closed.' );
29
+ * };
30
+ * ```
31
+ *
14
32
  * @return {boolean} Whether the inserter is opened.
15
33
  */
16
34
  function isInserterOpened(state) {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/customize-widgets/src/store/selectors.js"],"names":["isInserterOpened","state","blockInserterPanel","__experimentalGetInsertionPoint","rootClientId","insertionIndex"],"mappings":";;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,gBAAT,CAA2BC,KAA3B,EAAmC;AACzC,SAAO,CAAC,CAAEA,KAAK,CAACC,kBAAhB;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASC,+BAAT,CAA0CF,KAA1C,EAAkD;AACxD,QAAM;AAAEG,IAAAA,YAAF;AAAgBC,IAAAA;AAAhB,MAAmCJ,KAAK,CAACC,kBAA/C;AACA,SAAO;AAAEE,IAAAA,YAAF;AAAgBC,IAAAA;AAAhB,GAAP;AACA","sourcesContent":["/**\n * Returns true if the inserter is opened.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} Whether the inserter is opened.\n */\nexport function isInserterOpened( state ) {\n\treturn !! state.blockInserterPanel;\n}\n\n/**\n * Get the insertion point for the inserter.\n *\n * @param {Object} state Global application state.\n *\n * @return {Object} The root client ID and index to insert at.\n */\nexport function __experimentalGetInsertionPoint( state ) {\n\tconst { rootClientId, insertionIndex } = state.blockInserterPanel;\n\treturn { rootClientId, insertionIndex };\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/customize-widgets/src/store/selectors.js"],"names":["isInserterOpened","state","blockInserterPanel","__experimentalGetInsertionPoint","rootClientId","insertionIndex"],"mappings":";;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,gBAAT,CAA2BC,KAA3B,EAAmC;AACzC,SAAO,CAAC,CAAEA,KAAK,CAACC,kBAAhB;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASC,+BAAT,CAA0CF,KAA1C,EAAkD;AACxD,QAAM;AAAEG,IAAAA,YAAF;AAAgBC,IAAAA;AAAhB,MAAmCJ,KAAK,CAACC,kBAA/C;AACA,SAAO;AAAEE,IAAAA,YAAF;AAAgBC,IAAAA;AAAhB,GAAP;AACA","sourcesContent":["/**\n * Returns true if the inserter is opened.\n *\n * @param {Object} state Global application state.\n *\n * @example\n * ```js\n * import { store as customizeWidgetsStore } from '@wordpress/customize-widgets';\n * import { __ } from '@wordpress/i18n';\n * import { useSelect } from '@wordpress/data';\n *\n * const ExampleComponent = () => {\n * const { isInserterOpened } = useSelect(\n * ( select ) => select( customizeWidgetsStore ),\n * []\n * );\n *\n * return isInserterOpened()\n * ? __( 'Inserter is open' )\n * : __( 'Inserter is closed.' );\n * };\n * ```\n *\n * @return {boolean} Whether the inserter is opened.\n */\nexport function isInserterOpened( state ) {\n\treturn !! state.blockInserterPanel;\n}\n\n/**\n * Get the insertion point for the inserter.\n *\n * @param {Object} state Global application state.\n *\n * @return {Object} The root client ID and index to insert at.\n */\nexport function __experimentalGetInsertionPoint( state ) {\n\tconst { rootClientId, insertionIndex } = state.blockInserterPanel;\n\treturn { rootClientId, insertionIndex };\n}\n"]}
@@ -76,4 +76,5 @@ export function initialize(editorName, blockEditorSettings) {
76
76
  }));
77
77
  });
78
78
  }
79
+ export { store } from './store';
79
80
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/customize-widgets/src/index.js"],"names":["createRoot","registerCoreBlocks","__experimentalGetCoreBlocks","__experimentalRegisterExperimentalCoreBlocks","registerLegacyWidgetBlock","registerLegacyWidgetVariations","registerWidgetGroupBlock","setFreeformContentHandlerName","store","blocksStore","dispatch","preferencesStore","CustomizeWidgets","getSidebarSection","getSidebarControl","wp","window","DISABLED_BLOCKS","ENABLE_EXPERIMENTAL_FSE_BLOCKS","initialize","editorName","blockEditorSettings","setDefaults","fixedToolbar","welcomeGuide","__experimentalReapplyBlockTypeFilters","coreBlocks","filter","block","includes","name","startsWith","process","env","IS_GUTENBERG_PLUGIN","enableFSEBlocks","SidebarControl","customize","sectionConstructor","sidebar","controlConstructor","sidebar_block_editor","container","document","createElement","body","appendChild","bind","sidebarControls","control","each","push","render"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,UAAT,QAA2B,oBAA3B;AACA,SACCC,kBADD,EAECC,2BAFD,EAGCC,4CAHD,QAIO,0BAJP;AAKA,SACCC,yBADD,EAECC,8BAFD,EAGCC,wBA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t__experimentalGetCoreBlocks,\n\t__experimentalRegisterExperimentalCoreBlocks,\n} from '@wordpress/block-library';\nimport {\n\tregisterLegacyWidgetBlock,\n\tregisterLegacyWidgetVariations,\n\tregisterWidgetGroupBlock,\n} from '@wordpress/widgets';\nimport {\n\tsetFreeformContentHandlerName,\n\tstore as blocksStore,\n} from '@wordpress/blocks';\nimport { dispatch } from '@wordpress/data';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\n/**\n * Internal dependencies\n */\nimport CustomizeWidgets from './components/customize-widgets';\nimport getSidebarSection from './controls/sidebar-section';\nimport getSidebarControl from './controls/sidebar-control';\nimport './filters';\n\nconst { wp } = window;\n\nconst DISABLED_BLOCKS = [\n\t'core/more',\n\t'core/block',\n\t'core/freeform',\n\t'core/template-part',\n];\nconst ENABLE_EXPERIMENTAL_FSE_BLOCKS = false;\n\n/**\n * Initializes the widgets block editor in the customizer.\n *\n * @param {string} editorName The editor name.\n * @param {Object} blockEditorSettings Block editor settings.\n */\nexport function initialize( editorName, blockEditorSettings ) {\n\tdispatch( preferencesStore ).setDefaults( 'core/customize-widgets', {\n\t\tfixedToolbar: false,\n\t\twelcomeGuide: true,\n\t} );\n\n\tdispatch( blocksStore ).__experimentalReapplyBlockTypeFilters();\n\tconst coreBlocks = __experimentalGetCoreBlocks().filter( ( block ) => {\n\t\treturn ! (\n\t\t\tDISABLED_BLOCKS.includes( block.name ) ||\n\t\t\tblock.name.startsWith( 'core/post' ) ||\n\t\t\tblock.name.startsWith( 'core/query' ) ||\n\t\t\tblock.name.startsWith( 'core/site' ) ||\n\t\t\tblock.name.startsWith( 'core/navigation' )\n\t\t);\n\t} );\n\tregisterCoreBlocks( coreBlocks );\n\tregisterLegacyWidgetBlock();\n\tif ( process.env.IS_GUTENBERG_PLUGIN ) {\n\t\t__experimentalRegisterExperimentalCoreBlocks( {\n\t\t\tenableFSEBlocks: ENABLE_EXPERIMENTAL_FSE_BLOCKS,\n\t\t} );\n\t}\n\tregisterLegacyWidgetVariations( blockEditorSettings );\n\tregisterWidgetGroupBlock();\n\n\t// As we are unregistering `core/freeform` to avoid the Classic block, we must\n\t// replace it with something as the default freeform content handler. Failure to\n\t// do this will result in errors in the default block parser.\n\t// see: https://github.com/WordPress/gutenberg/issues/33097\n\tsetFreeformContentHandlerName( 'core/html' );\n\n\tconst SidebarControl = getSidebarControl( blockEditorSettings );\n\n\twp.customize.sectionConstructor.sidebar = getSidebarSection();\n\twp.customize.controlConstructor.sidebar_block_editor = SidebarControl;\n\n\tconst container = document.createElement( 'div' );\n\tdocument.body.appendChild( container );\n\n\twp.customize.bind( 'ready', () => {\n\t\tconst sidebarControls = [];\n\t\twp.customize.control.each( ( control ) => {\n\t\t\tif ( control instanceof SidebarControl ) {\n\t\t\t\tsidebarControls.push( control );\n\t\t\t}\n\t\t} );\n\n\t\tcreateRoot( container ).render(\n\t\t\t<CustomizeWidgets\n\t\t\t\tapi={ wp.customize }\n\t\t\t\tsidebarControls={ sidebarControls }\n\t\t\t\tblockEditorSettings={ blockEditorSettings }\n\t\t\t/>\n\t\t);\n\t} );\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/customize-widgets/src/index.js"],"names":["createRoot","registerCoreBlocks","__experimentalGetCoreBlocks","__experimentalRegisterExperimentalCoreBlocks","registerLegacyWidgetBlock","registerLegacyWidgetVariations","registerWidgetGroupBlock","setFreeformContentHandlerName","store","blocksStore","dispatch","preferencesStore","CustomizeWidgets","getSidebarSection","getSidebarControl","wp","window","DISABLED_BLOCKS","ENABLE_EXPERIMENTAL_FSE_BLOCKS","initialize","editorName","blockEditorSettings","setDefaults","fixedToolbar","welcomeGuide","__experimentalReapplyBlockTypeFilters","coreBlocks","filter","block","includes","name","startsWith","process","env","IS_GUTENBERG_PLUGIN","enableFSEBlocks","SidebarControl","customize","sectionConstructor","sidebar","controlConstructor","sidebar_block_editor","container","document","createElement","body","appendChild","bind","sidebarControls","control","each","push","render"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,UAAT,QAA2B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HvB,MADD;AAOA,GAfD;AAgBA;AACD,SAASb,KAAT,QAAsB,SAAtB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createRoot } from '@wordpress/element';\nimport {\n\tregisterCoreBlocks,\n\t__experimentalGetCoreBlocks,\n\t__experimentalRegisterExperimentalCoreBlocks,\n} from '@wordpress/block-library';\nimport {\n\tregisterLegacyWidgetBlock,\n\tregisterLegacyWidgetVariations,\n\tregisterWidgetGroupBlock,\n} from '@wordpress/widgets';\nimport {\n\tsetFreeformContentHandlerName,\n\tstore as blocksStore,\n} from '@wordpress/blocks';\nimport { dispatch } from '@wordpress/data';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\n/**\n * Internal dependencies\n */\nimport CustomizeWidgets from './components/customize-widgets';\nimport getSidebarSection from './controls/sidebar-section';\nimport getSidebarControl from './controls/sidebar-control';\nimport './filters';\n\nconst { wp } = window;\n\nconst DISABLED_BLOCKS = [\n\t'core/more',\n\t'core/block',\n\t'core/freeform',\n\t'core/template-part',\n];\nconst ENABLE_EXPERIMENTAL_FSE_BLOCKS = false;\n\n/**\n * Initializes the widgets block editor in the customizer.\n *\n * @param {string} editorName The editor name.\n * @param {Object} blockEditorSettings Block editor settings.\n */\nexport function initialize( editorName, blockEditorSettings ) {\n\tdispatch( preferencesStore ).setDefaults( 'core/customize-widgets', {\n\t\tfixedToolbar: false,\n\t\twelcomeGuide: true,\n\t} );\n\n\tdispatch( blocksStore ).__experimentalReapplyBlockTypeFilters();\n\tconst coreBlocks = __experimentalGetCoreBlocks().filter( ( block ) => {\n\t\treturn ! (\n\t\t\tDISABLED_BLOCKS.includes( block.name ) ||\n\t\t\tblock.name.startsWith( 'core/post' ) ||\n\t\t\tblock.name.startsWith( 'core/query' ) ||\n\t\t\tblock.name.startsWith( 'core/site' ) ||\n\t\t\tblock.name.startsWith( 'core/navigation' )\n\t\t);\n\t} );\n\tregisterCoreBlocks( coreBlocks );\n\tregisterLegacyWidgetBlock();\n\tif ( process.env.IS_GUTENBERG_PLUGIN ) {\n\t\t__experimentalRegisterExperimentalCoreBlocks( {\n\t\t\tenableFSEBlocks: ENABLE_EXPERIMENTAL_FSE_BLOCKS,\n\t\t} );\n\t}\n\tregisterLegacyWidgetVariations( blockEditorSettings );\n\tregisterWidgetGroupBlock();\n\n\t// As we are unregistering `core/freeform` to avoid the Classic block, we must\n\t// replace it with something as the default freeform content handler. Failure to\n\t// do this will result in errors in the default block parser.\n\t// see: https://github.com/WordPress/gutenberg/issues/33097\n\tsetFreeformContentHandlerName( 'core/html' );\n\n\tconst SidebarControl = getSidebarControl( blockEditorSettings );\n\n\twp.customize.sectionConstructor.sidebar = getSidebarSection();\n\twp.customize.controlConstructor.sidebar_block_editor = SidebarControl;\n\n\tconst container = document.createElement( 'div' );\n\tdocument.body.appendChild( container );\n\n\twp.customize.bind( 'ready', () => {\n\t\tconst sidebarControls = [];\n\t\twp.customize.control.each( ( control ) => {\n\t\t\tif ( control instanceof SidebarControl ) {\n\t\t\t\tsidebarControls.push( control );\n\t\t\t}\n\t\t} );\n\n\t\tcreateRoot( container ).render(\n\t\t\t<CustomizeWidgets\n\t\t\t\tapi={ wp.customize }\n\t\t\t\tsidebarControls={ sidebarControls }\n\t\t\t\tblockEditorSettings={ blockEditorSettings }\n\t\t\t/>\n\t\t);\n\t} );\n}\nexport { store } from './store';\n"]}
@@ -8,6 +8,31 @@
8
8
  * @param {string} value.rootClientId The root client ID to insert at.
9
9
  * @param {number} value.insertionIndex The index to insert at.
10
10
  *
11
+ * @example
12
+ * ```js
13
+ * import { store as customizeWidgetsStore } from '@wordpress/customize-widgets';
14
+ * import { __ } from '@wordpress/i18n';
15
+ * import { useDispatch } from '@wordpress/data';
16
+ * import { Button } from '@wordpress/components';
17
+ * import { useState } from '@wordpress/element';
18
+ *
19
+ * const ExampleComponent = () => {
20
+ * const { setIsInserterOpened } = useDispatch( customizeWidgetsStore );
21
+ * const [ isOpen, setIsOpen ] = useState( false );
22
+ *
23
+ * return (
24
+ * <Button
25
+ * onClick={ () => {
26
+ * setIsInserterOpened( ! isOpen );
27
+ * setIsOpen( ! isOpen );
28
+ * } }
29
+ * >
30
+ * { __( 'Open/close inserter' ) }
31
+ * </Button>
32
+ * );
33
+ * };
34
+ * ```
35
+ *
11
36
  * @return {Object} Action object.
12
37
  */
13
38
  export function setIsInserterOpened(value) {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/customize-widgets/src/store/actions.js"],"names":["setIsInserterOpened","value","type"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,mBAAT,CAA8BC,KAA9B,EAAsC;AAC5C,SAAO;AACNC,IAAAA,IAAI,EAAE,wBADA;AAEND,IAAAA;AAFM,GAAP;AAIA","sourcesContent":["/**\n * Returns an action object used to open/close the inserter.\n *\n * @param {boolean|Object} value Whether the inserter should be\n * opened (true) or closed (false).\n * To specify an insertion point,\n * use an object.\n * @param {string} value.rootClientId The root client ID to insert at.\n * @param {number} value.insertionIndex The index to insert at.\n *\n * @return {Object} Action object.\n */\nexport function setIsInserterOpened( value ) {\n\treturn {\n\t\ttype: 'SET_IS_INSERTER_OPENED',\n\t\tvalue,\n\t};\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/customize-widgets/src/store/actions.js"],"names":["setIsInserterOpened","value","type"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,mBAAT,CAA8BC,KAA9B,EAAsC;AAC5C,SAAO;AACNC,IAAAA,IAAI,EAAE,wBADA;AAEND,IAAAA;AAFM,GAAP;AAIA","sourcesContent":["/**\n * Returns an action object used to open/close the inserter.\n *\n * @param {boolean|Object} value Whether the inserter should be\n * opened (true) or closed (false).\n * To specify an insertion point,\n * use an object.\n * @param {string} value.rootClientId The root client ID to insert at.\n * @param {number} value.insertionIndex The index to insert at.\n *\n * @example\n * ```js\n * import { store as customizeWidgetsStore } from '@wordpress/customize-widgets';\n * import { __ } from '@wordpress/i18n';\n * import { useDispatch } from '@wordpress/data';\n * import { Button } from '@wordpress/components';\n * import { useState } from '@wordpress/element';\n *\n * const ExampleComponent = () => {\n * const { setIsInserterOpened } = useDispatch( customizeWidgetsStore );\n * const [ isOpen, setIsOpen ] = useState( false );\n *\n * return (\n * <Button\n * onClick={ () => {\n * setIsInserterOpened( ! isOpen );\n * setIsOpen( ! isOpen );\n * } }\n * >\n * { __( 'Open/close inserter' ) }\n * </Button>\n * );\n * };\n * ```\n *\n * @return {Object} Action object.\n */\nexport function setIsInserterOpened( value ) {\n\treturn {\n\t\ttype: 'SET_IS_INSERTER_OPENED',\n\t\tvalue,\n\t};\n}\n"]}
@@ -3,6 +3,24 @@
3
3
  *
4
4
  * @param {Object} state Global application state.
5
5
  *
6
+ * @example
7
+ * ```js
8
+ * import { store as customizeWidgetsStore } from '@wordpress/customize-widgets';
9
+ * import { __ } from '@wordpress/i18n';
10
+ * import { useSelect } from '@wordpress/data';
11
+ *
12
+ * const ExampleComponent = () => {
13
+ * const { isInserterOpened } = useSelect(
14
+ * ( select ) => select( customizeWidgetsStore ),
15
+ * []
16
+ * );
17
+ *
18
+ * return isInserterOpened()
19
+ * ? __( 'Inserter is open' )
20
+ * : __( 'Inserter is closed.' );
21
+ * };
22
+ * ```
23
+ *
6
24
  * @return {boolean} Whether the inserter is opened.
7
25
  */
8
26
  export function isInserterOpened(state) {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/customize-widgets/src/store/selectors.js"],"names":["isInserterOpened","state","blockInserterPanel","__experimentalGetInsertionPoint","rootClientId","insertionIndex"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,gBAAT,CAA2BC,KAA3B,EAAmC;AACzC,SAAO,CAAC,CAAEA,KAAK,CAACC,kBAAhB;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,+BAAT,CAA0CF,KAA1C,EAAkD;AACxD,QAAM;AAAEG,IAAAA,YAAF;AAAgBC,IAAAA;AAAhB,MAAmCJ,KAAK,CAACC,kBAA/C;AACA,SAAO;AAAEE,IAAAA,YAAF;AAAgBC,IAAAA;AAAhB,GAAP;AACA","sourcesContent":["/**\n * Returns true if the inserter is opened.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} Whether the inserter is opened.\n */\nexport function isInserterOpened( state ) {\n\treturn !! state.blockInserterPanel;\n}\n\n/**\n * Get the insertion point for the inserter.\n *\n * @param {Object} state Global application state.\n *\n * @return {Object} The root client ID and index to insert at.\n */\nexport function __experimentalGetInsertionPoint( state ) {\n\tconst { rootClientId, insertionIndex } = state.blockInserterPanel;\n\treturn { rootClientId, insertionIndex };\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/customize-widgets/src/store/selectors.js"],"names":["isInserterOpened","state","blockInserterPanel","__experimentalGetInsertionPoint","rootClientId","insertionIndex"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,gBAAT,CAA2BC,KAA3B,EAAmC;AACzC,SAAO,CAAC,CAAEA,KAAK,CAACC,kBAAhB;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,+BAAT,CAA0CF,KAA1C,EAAkD;AACxD,QAAM;AAAEG,IAAAA,YAAF;AAAgBC,IAAAA;AAAhB,MAAmCJ,KAAK,CAACC,kBAA/C;AACA,SAAO;AAAEE,IAAAA,YAAF;AAAgBC,IAAAA;AAAhB,GAAP;AACA","sourcesContent":["/**\n * Returns true if the inserter is opened.\n *\n * @param {Object} state Global application state.\n *\n * @example\n * ```js\n * import { store as customizeWidgetsStore } from '@wordpress/customize-widgets';\n * import { __ } from '@wordpress/i18n';\n * import { useSelect } from '@wordpress/data';\n *\n * const ExampleComponent = () => {\n * const { isInserterOpened } = useSelect(\n * ( select ) => select( customizeWidgetsStore ),\n * []\n * );\n *\n * return isInserterOpened()\n * ? __( 'Inserter is open' )\n * : __( 'Inserter is closed.' );\n * };\n * ```\n *\n * @return {boolean} Whether the inserter is opened.\n */\nexport function isInserterOpened( state ) {\n\treturn !! state.blockInserterPanel;\n}\n\n/**\n * Get the insertion point for the inserter.\n *\n * @param {Object} state Global application state.\n *\n * @return {Object} The root client ID and index to insert at.\n */\nexport function __experimentalGetInsertionPoint( state ) {\n\tconst { rootClientId, insertionIndex } = state.blockInserterPanel;\n\treturn { rootClientId, insertionIndex };\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/customize-widgets",
3
- "version": "4.13.0",
3
+ "version": "4.15.0",
4
4
  "description": "Widgets blocks in Customizer Module for WordPress.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -24,26 +24,26 @@
24
24
  "react-native": "src/index",
25
25
  "dependencies": {
26
26
  "@babel/runtime": "^7.16.0",
27
- "@wordpress/block-editor": "^12.4.0",
28
- "@wordpress/block-library": "^8.13.0",
29
- "@wordpress/blocks": "^12.13.0",
30
- "@wordpress/components": "^25.2.0",
31
- "@wordpress/compose": "^6.13.0",
32
- "@wordpress/core-data": "^6.13.0",
33
- "@wordpress/data": "^9.6.0",
34
- "@wordpress/dom": "^3.36.0",
35
- "@wordpress/element": "^5.13.0",
36
- "@wordpress/hooks": "^3.36.0",
37
- "@wordpress/i18n": "^4.36.0",
38
- "@wordpress/icons": "^9.27.0",
39
- "@wordpress/interface": "^5.13.0",
40
- "@wordpress/is-shallow-equal": "^4.36.0",
41
- "@wordpress/keyboard-shortcuts": "^4.13.0",
42
- "@wordpress/keycodes": "^3.36.0",
43
- "@wordpress/media-utils": "^4.27.0",
44
- "@wordpress/preferences": "^3.13.0",
45
- "@wordpress/private-apis": "^0.18.0",
46
- "@wordpress/widgets": "^3.13.0",
27
+ "@wordpress/block-editor": "^12.6.0",
28
+ "@wordpress/block-library": "^8.15.0",
29
+ "@wordpress/blocks": "^12.15.0",
30
+ "@wordpress/components": "^25.4.0",
31
+ "@wordpress/compose": "^6.15.0",
32
+ "@wordpress/core-data": "^6.15.0",
33
+ "@wordpress/data": "^9.8.0",
34
+ "@wordpress/dom": "^3.38.0",
35
+ "@wordpress/element": "^5.15.0",
36
+ "@wordpress/hooks": "^3.38.0",
37
+ "@wordpress/i18n": "^4.38.0",
38
+ "@wordpress/icons": "^9.29.0",
39
+ "@wordpress/interface": "^5.15.0",
40
+ "@wordpress/is-shallow-equal": "^4.38.0",
41
+ "@wordpress/keyboard-shortcuts": "^4.15.0",
42
+ "@wordpress/keycodes": "^3.38.0",
43
+ "@wordpress/media-utils": "^4.29.0",
44
+ "@wordpress/preferences": "^3.15.0",
45
+ "@wordpress/private-apis": "^0.20.0",
46
+ "@wordpress/widgets": "^3.15.0",
47
47
  "classnames": "^2.3.1",
48
48
  "fast-deep-equal": "^3.1.3"
49
49
  },
@@ -54,5 +54,5 @@
54
54
  "publishConfig": {
55
55
  "access": "public"
56
56
  },
57
- "gitHead": "d47d8069e1aae05d4a16dc287902eb90edcbff50"
57
+ "gitHead": "6f14d11ed4cb59df110a28ebaa23ecba95eb673a"
58
58
  }
package/src/index.js CHANGED
@@ -100,3 +100,4 @@ export function initialize( editorName, blockEditorSettings ) {
100
100
  );
101
101
  } );
102
102
  }
103
+ export { store } from './store';
@@ -8,6 +8,31 @@
8
8
  * @param {string} value.rootClientId The root client ID to insert at.
9
9
  * @param {number} value.insertionIndex The index to insert at.
10
10
  *
11
+ * @example
12
+ * ```js
13
+ * import { store as customizeWidgetsStore } from '@wordpress/customize-widgets';
14
+ * import { __ } from '@wordpress/i18n';
15
+ * import { useDispatch } from '@wordpress/data';
16
+ * import { Button } from '@wordpress/components';
17
+ * import { useState } from '@wordpress/element';
18
+ *
19
+ * const ExampleComponent = () => {
20
+ * const { setIsInserterOpened } = useDispatch( customizeWidgetsStore );
21
+ * const [ isOpen, setIsOpen ] = useState( false );
22
+ *
23
+ * return (
24
+ * <Button
25
+ * onClick={ () => {
26
+ * setIsInserterOpened( ! isOpen );
27
+ * setIsOpen( ! isOpen );
28
+ * } }
29
+ * >
30
+ * { __( 'Open/close inserter' ) }
31
+ * </Button>
32
+ * );
33
+ * };
34
+ * ```
35
+ *
11
36
  * @return {Object} Action object.
12
37
  */
13
38
  export function setIsInserterOpened( value ) {
@@ -3,6 +3,24 @@
3
3
  *
4
4
  * @param {Object} state Global application state.
5
5
  *
6
+ * @example
7
+ * ```js
8
+ * import { store as customizeWidgetsStore } from '@wordpress/customize-widgets';
9
+ * import { __ } from '@wordpress/i18n';
10
+ * import { useSelect } from '@wordpress/data';
11
+ *
12
+ * const ExampleComponent = () => {
13
+ * const { isInserterOpened } = useSelect(
14
+ * ( select ) => select( customizeWidgetsStore ),
15
+ * []
16
+ * );
17
+ *
18
+ * return isInserterOpened()
19
+ * ? __( 'Inserter is open' )
20
+ * : __( 'Inserter is closed.' );
21
+ * };
22
+ * ```
23
+ *
6
24
  * @return {boolean} Whether the inserter is opened.
7
25
  */
8
26
  export function isInserterOpened( state ) {