@wordpress/block-editor 15.9.1-next.738bb1424.0 → 15.9.1-next.8fd3f8831.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.
Files changed (63) hide show
  1. package/build/components/block-card/index.cjs +56 -49
  2. package/build/components/block-card/index.cjs.map +3 -3
  3. package/build/components/block-settings-menu/block-settings-dropdown.cjs +0 -17
  4. package/build/components/block-settings-menu/block-settings-dropdown.cjs.map +2 -2
  5. package/build/components/inspector-controls-tabs/index.cjs +15 -16
  6. package/build/components/inspector-controls-tabs/index.cjs.map +3 -3
  7. package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.cjs +1 -3
  8. package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.cjs.map +3 -3
  9. package/build/components/list-view/block.cjs +4 -4
  10. package/build/components/list-view/block.cjs.map +2 -2
  11. package/build/hooks/index.cjs +3 -1
  12. package/build/hooks/index.cjs.map +3 -3
  13. package/build/hooks/list-view.cjs +89 -0
  14. package/build/hooks/list-view.cjs.map +7 -0
  15. package/build/store/private-actions.cjs +0 -8
  16. package/build/store/private-actions.cjs.map +2 -2
  17. package/build/store/private-selectors.cjs +0 -5
  18. package/build/store/private-selectors.cjs.map +2 -2
  19. package/build/store/reducer.cjs +0 -9
  20. package/build/store/reducer.cjs.map +2 -2
  21. package/build-module/components/block-card/index.js +58 -50
  22. package/build-module/components/block-card/index.js.map +2 -2
  23. package/build-module/components/block-settings-menu/block-settings-dropdown.js +0 -17
  24. package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +2 -2
  25. package/build-module/components/inspector-controls-tabs/index.js +16 -17
  26. package/build-module/components/inspector-controls-tabs/index.js.map +2 -2
  27. package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js +1 -3
  28. package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +2 -2
  29. package/build-module/components/list-view/block.js +4 -4
  30. package/build-module/components/list-view/block.js.map +2 -2
  31. package/build-module/hooks/index.js +3 -1
  32. package/build-module/hooks/index.js.map +2 -2
  33. package/build-module/hooks/list-view.js +52 -0
  34. package/build-module/hooks/list-view.js.map +7 -0
  35. package/build-module/store/private-actions.js +0 -7
  36. package/build-module/store/private-actions.js.map +2 -2
  37. package/build-module/store/private-selectors.js +0 -4
  38. package/build-module/store/private-selectors.js.map +2 -2
  39. package/build-module/store/reducer.js +0 -8
  40. package/build-module/store/reducer.js.map +2 -2
  41. package/build-style/content-rtl.css +4 -0
  42. package/build-style/content.css +4 -0
  43. package/build-style/style-rtl.css +4 -2
  44. package/build-style/style.css +4 -2
  45. package/package.json +39 -39
  46. package/src/components/block-card/index.js +83 -57
  47. package/src/components/block-card/style.scss +0 -2
  48. package/src/components/block-settings-menu/block-settings-dropdown.js +0 -33
  49. package/src/components/inspector-controls-tabs/index.js +19 -31
  50. package/src/components/inspector-controls-tabs/use-inspector-controls-tabs.js +1 -3
  51. package/src/components/list-view/block.js +5 -4
  52. package/src/hooks/index.js +2 -0
  53. package/src/hooks/list-view.js +80 -0
  54. package/src/store/private-actions.js +0 -13
  55. package/src/store/private-selectors.js +0 -10
  56. package/src/store/reducer.js +0 -16
  57. package/src/store/test/private-actions.js +0 -17
  58. package/src/store/test/reducer.js +0 -25
  59. package/build/components/inspector-controls-tabs/use-is-list-view-tab-disabled.cjs +0 -36
  60. package/build/components/inspector-controls-tabs/use-is-list-view-tab-disabled.cjs.map +0 -7
  61. package/build-module/components/inspector-controls-tabs/use-is-list-view-tab-disabled.js +0 -11
  62. package/build-module/components/inspector-controls-tabs/use-is-list-view-tab-disabled.js.map +0 -7
  63. package/src/components/inspector-controls-tabs/use-is-list-view-tab-disabled.js +0 -9
@@ -0,0 +1,80 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { __ } from '@wordpress/i18n';
5
+ import { PanelBody } from '@wordpress/components';
6
+ import { useSelect } from '@wordpress/data';
7
+ import { store as blocksStore, hasBlockSupport } from '@wordpress/blocks';
8
+
9
+ /**
10
+ * Internal dependencies
11
+ */
12
+ import InspectorControls from '../components/inspector-controls';
13
+ import { store as blockEditorStore } from '../store';
14
+ import { privateApis } from '../private-apis';
15
+ import { unlock } from '../lock-unlock';
16
+
17
+ const { PrivateListView } = unlock( privateApis );
18
+
19
+ export const LIST_VIEW_SUPPORT_KEY = 'listView';
20
+
21
+ /**
22
+ * Check if the block has list view support.
23
+ *
24
+ * @param {string|Object} nameOrType Block name or block type object.
25
+ * @return {boolean} Whether the block has list view support.
26
+ */
27
+ export function hasListViewSupport( nameOrType ) {
28
+ return hasBlockSupport( nameOrType, LIST_VIEW_SUPPORT_KEY );
29
+ }
30
+
31
+ /**
32
+ * Inspector controls panel for list view.
33
+ *
34
+ * @param {Object} props Component props.
35
+ * @param {string} props.clientId Block client ID.
36
+ * @param {string} props.name Block name.
37
+ * @return {Element|null} List view inspector controls or null.
38
+ */
39
+ export function ListViewPanel( { clientId, name } ) {
40
+ const isEnabled = hasListViewSupport( name );
41
+ const { hasChildren, blockTitle } = useSelect(
42
+ ( select ) => ( {
43
+ hasChildren:
44
+ !! select( blockEditorStore ).getBlockCount( clientId ),
45
+ blockTitle: select( blocksStore ).getBlockType( name )?.title,
46
+ } ),
47
+ [ clientId, name ]
48
+ );
49
+
50
+ if ( ! isEnabled ) {
51
+ return null;
52
+ }
53
+
54
+ return (
55
+ <InspectorControls group="list">
56
+ <PanelBody title={ null }>
57
+ { ! hasChildren && (
58
+ <p className="block-editor-block-inspector__no-blocks">
59
+ { __( 'No items yet.' ) }
60
+ </p>
61
+ ) }
62
+ <PrivateListView
63
+ rootClientId={ clientId }
64
+ isExpanded
65
+ description={ blockTitle }
66
+ showAppender
67
+ />
68
+ </PanelBody>
69
+ </InspectorControls>
70
+ );
71
+ }
72
+
73
+ /**
74
+ * Export block support definition.
75
+ */
76
+ export default {
77
+ edit: ListViewPanel,
78
+ hasSupport: hasListViewSupport,
79
+ attributeKeys: [],
80
+ };
@@ -275,19 +275,6 @@ export function setBlockRemovalRules( rules = false ) {
275
275
  };
276
276
  }
277
277
 
278
- /**
279
- * Sets the client ID of the block settings menu that is currently open.
280
- *
281
- * @param {?string} clientId The block client ID.
282
- * @return {Object} Action object.
283
- */
284
- export function setOpenedBlockSettingsMenu( clientId ) {
285
- return {
286
- type: 'SET_OPENED_BLOCK_SETTINGS_MENU',
287
- clientId,
288
- };
289
- }
290
-
291
278
  export function setStyleOverride( id, style ) {
292
279
  return {
293
280
  type: 'SET_STYLE_OVERRIDE',
@@ -198,16 +198,6 @@ export function getBlockRemovalRules( state ) {
198
198
  return state.blockRemovalRules;
199
199
  }
200
200
 
201
- /**
202
- * Returns the client ID of the block settings menu that is currently open.
203
- *
204
- * @param {Object} state Global application state.
205
- * @return {string|null} The client ID of the block menu that is currently open.
206
- */
207
- export function getOpenedBlockSettingsMenu( state ) {
208
- return state.openedBlockSettingsMenu;
209
- }
210
-
211
201
  /**
212
202
  * Returns all style overrides, intended to be merged with global editor styles.
213
203
  *
@@ -2009,21 +2009,6 @@ export function blockEditingModes( state = new Map(), action ) {
2009
2009
  return state;
2010
2010
  }
2011
2011
 
2012
- /**
2013
- * Reducer returning the clientId of the block settings menu that is currently open.
2014
- *
2015
- * @param {string|null} state Current state.
2016
- * @param {Object} action Dispatched action.
2017
- *
2018
- * @return {string|null} Updated state.
2019
- */
2020
- export function openedBlockSettingsMenu( state = null, action ) {
2021
- if ( 'SET_OPENED_BLOCK_SETTINGS_MENU' === action.type ) {
2022
- return action?.clientId ?? null;
2023
- }
2024
- return state;
2025
- }
2026
-
2027
2012
  /**
2028
2013
  * Reducer returning a map of style IDs to style overrides.
2029
2014
  *
@@ -2145,7 +2130,6 @@ const combinedReducers = combineReducers( {
2145
2130
  styleOverrides,
2146
2131
  removalPromptData,
2147
2132
  blockRemovalRules,
2148
- openedBlockSettingsMenu,
2149
2133
  registeredInserterMediaCategories,
2150
2134
  zoomLevel,
2151
2135
  hasBlockSpotlight,
@@ -7,7 +7,6 @@ import {
7
7
  expandBlock,
8
8
  __experimentalUpdateSettings,
9
9
  setInsertionPoint,
10
- setOpenedBlockSettingsMenu,
11
10
  startDragging,
12
11
  stopDragging,
13
12
  } from '../private-actions';
@@ -84,22 +83,6 @@ describe( 'private actions', () => {
84
83
  } );
85
84
  } );
86
85
 
87
- describe( 'setOpenedBlockSettingsMenu', () => {
88
- it( 'should return the SET_OPENED_BLOCK_SETTINGS_MENU action', () => {
89
- expect( setOpenedBlockSettingsMenu() ).toEqual( {
90
- clientId: undefined,
91
- type: 'SET_OPENED_BLOCK_SETTINGS_MENU',
92
- } );
93
- } );
94
-
95
- it( 'should return the SET_OPENED_BLOCK_SETTINGS_MENU action with client id if provided', () => {
96
- expect( setOpenedBlockSettingsMenu( 'abcd' ) ).toEqual( {
97
- clientId: 'abcd',
98
- type: 'SET_OPENED_BLOCK_SETTINGS_MENU',
99
- } );
100
- } );
101
- } );
102
-
103
86
  describe( 'startDragging', () => {
104
87
  it( 'should return the START_DRAGGING action', () => {
105
88
  expect( startDragging() ).toEqual( {
@@ -38,7 +38,6 @@ import {
38
38
  lastBlockAttributesChange,
39
39
  lastBlockInserted,
40
40
  blockEditingModes,
41
- openedBlockSettingsMenu,
42
41
  expandedBlock,
43
42
  zoomLevel,
44
43
  editedContentOnlySection,
@@ -3486,30 +3485,6 @@ describe( 'state', () => {
3486
3485
  } );
3487
3486
  } );
3488
3487
 
3489
- describe( 'openedBlockSettingsMenu', () => {
3490
- it( 'should return null by default', () => {
3491
- expect( openedBlockSettingsMenu( undefined, {} ) ).toBe( null );
3492
- } );
3493
-
3494
- it( 'should set client id for opened block settings menu', () => {
3495
- const state = openedBlockSettingsMenu( null, {
3496
- type: 'SET_OPENED_BLOCK_SETTINGS_MENU',
3497
- clientId: '14501cc2-90a6-4f52-aa36-ab6e896135d1',
3498
- } );
3499
- expect( state ).toBe( '14501cc2-90a6-4f52-aa36-ab6e896135d1' );
3500
- } );
3501
-
3502
- it( 'should clear the state when no client id is passed', () => {
3503
- const state = openedBlockSettingsMenu(
3504
- '14501cc2-90a6-4f52-aa36-ab6e896135d1',
3505
- {
3506
- type: 'SET_OPENED_BLOCK_SETTINGS_MENU',
3507
- }
3508
- );
3509
- expect( state ).toBe( null );
3510
- } );
3511
- } );
3512
-
3513
3488
  describe( 'expandedBlock', () => {
3514
3489
  it( 'should return null by default', () => {
3515
3490
  expect( expandedBlock( undefined, {} ) ).toBe( null );
@@ -1,36 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // packages/block-editor/src/components/inspector-controls-tabs/use-is-list-view-tab-disabled.js
21
- var use_is_list_view_tab_disabled_exports = {};
22
- __export(use_is_list_view_tab_disabled_exports, {
23
- default: () => use_is_list_view_tab_disabled_default,
24
- useIsListViewTabDisabled: () => useIsListViewTabDisabled
25
- });
26
- module.exports = __toCommonJS(use_is_list_view_tab_disabled_exports);
27
- var allowlist = ["core/navigation"];
28
- var useIsListViewTabDisabled = (blockName) => {
29
- return !allowlist.includes(blockName);
30
- };
31
- var use_is_list_view_tab_disabled_default = useIsListViewTabDisabled;
32
- // Annotate the CommonJS export names for ESM import in node:
33
- 0 && (module.exports = {
34
- useIsListViewTabDisabled
35
- });
36
- //# sourceMappingURL=use-is-list-view-tab-disabled.cjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/components/inspector-controls-tabs/use-is-list-view-tab-disabled.js"],
4
- "sourcesContent": ["// List view tab restricts the blocks that may render to it via the\n// allowlist below.\nconst allowlist = [ 'core/navigation' ];\n\nexport const useIsListViewTabDisabled = ( blockName ) => {\n\treturn ! allowlist.includes( blockName );\n};\n\nexport default useIsListViewTabDisabled;\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,IAAM,YAAY,CAAE,iBAAkB;AAE/B,IAAM,2BAA2B,CAAE,cAAe;AACxD,SAAO,CAAE,UAAU,SAAU,SAAU;AACxC;AAEA,IAAO,wCAAQ;",
6
- "names": []
7
- }
@@ -1,11 +0,0 @@
1
- // packages/block-editor/src/components/inspector-controls-tabs/use-is-list-view-tab-disabled.js
2
- var allowlist = ["core/navigation"];
3
- var useIsListViewTabDisabled = (blockName) => {
4
- return !allowlist.includes(blockName);
5
- };
6
- var use_is_list_view_tab_disabled_default = useIsListViewTabDisabled;
7
- export {
8
- use_is_list_view_tab_disabled_default as default,
9
- useIsListViewTabDisabled
10
- };
11
- //# sourceMappingURL=use-is-list-view-tab-disabled.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/components/inspector-controls-tabs/use-is-list-view-tab-disabled.js"],
4
- "sourcesContent": ["// List view tab restricts the blocks that may render to it via the\n// allowlist below.\nconst allowlist = [ 'core/navigation' ];\n\nexport const useIsListViewTabDisabled = ( blockName ) => {\n\treturn ! allowlist.includes( blockName );\n};\n\nexport default useIsListViewTabDisabled;\n"],
5
- "mappings": ";AAEA,IAAM,YAAY,CAAE,iBAAkB;AAE/B,IAAM,2BAA2B,CAAE,cAAe;AACxD,SAAO,CAAE,UAAU,SAAU,SAAU;AACxC;AAEA,IAAO,wCAAQ;",
6
- "names": []
7
- }
@@ -1,9 +0,0 @@
1
- // List view tab restricts the blocks that may render to it via the
2
- // allowlist below.
3
- const allowlist = [ 'core/navigation' ];
4
-
5
- export const useIsListViewTabDisabled = ( blockName ) => {
6
- return ! allowlist.includes( blockName );
7
- };
8
-
9
- export default useIsListViewTabDisabled;