@wordpress/block-library 9.40.2-next.v.202602241322.0 → 9.41.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 (153) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/accordion/view.cjs +0 -34
  3. package/build/accordion/view.cjs.map +2 -2
  4. package/build/button/block.json +11 -3
  5. package/build/button/deprecated.cjs +246 -13
  6. package/build/button/deprecated.cjs.map +2 -2
  7. package/build/button/edit.cjs +45 -58
  8. package/build/button/edit.cjs.map +3 -3
  9. package/build/button/save.cjs +3 -7
  10. package/build/button/save.cjs.map +2 -2
  11. package/build/button/utils.cjs +59 -0
  12. package/build/button/utils.cjs.map +7 -0
  13. package/build/image/image.cjs +1 -1
  14. package/build/image/image.cjs.map +2 -2
  15. package/build/navigation/edit/index.cjs +4 -2
  16. package/build/navigation/edit/index.cjs.map +3 -3
  17. package/build/navigation/edit/leaf-more-menu.cjs +68 -6
  18. package/build/navigation/edit/leaf-more-menu.cjs.map +3 -3
  19. package/build/navigation/edit/menu-inspector-controls.cjs +20 -91
  20. package/build/navigation/edit/menu-inspector-controls.cjs.map +3 -3
  21. package/build/navigation/edit/navigation-link-ui.cjs +97 -0
  22. package/build/navigation/edit/navigation-link-ui.cjs.map +7 -0
  23. package/build/navigation/edit/navigation-list-view-header.cjs +86 -0
  24. package/build/navigation/edit/navigation-list-view-header.cjs.map +7 -0
  25. package/build/navigation/edit/navigation-menu-selector.cjs +4 -2
  26. package/build/navigation/edit/navigation-menu-selector.cjs.map +3 -3
  27. package/build/navigation/edit/placeholder/index.cjs +2 -2
  28. package/build/navigation/edit/placeholder/index.cjs.map +3 -3
  29. package/build/navigation-link/shared/controls.cjs +29 -52
  30. package/build/navigation-link/shared/controls.cjs.map +3 -3
  31. package/build/navigation-link/shared/use-link-preview.cjs +8 -9
  32. package/build/navigation-link/shared/use-link-preview.cjs.map +2 -2
  33. package/build/page-list-item/edit.cjs +6 -3
  34. package/build/page-list-item/edit.cjs.map +2 -2
  35. package/build/playlist/edit.cjs +43 -136
  36. package/build/playlist/edit.cjs.map +3 -3
  37. package/build/playlist/view.cjs +56 -38
  38. package/build/playlist/view.cjs.map +2 -2
  39. package/build/playlist-track/edit.cjs +0 -1
  40. package/build/playlist-track/edit.cjs.map +2 -2
  41. package/build/post-title/block.json +3 -0
  42. package/build/post-title/edit.cjs +2 -2
  43. package/build/post-title/edit.cjs.map +2 -2
  44. package/build/utils/waveform-player.cjs +68 -0
  45. package/build/utils/waveform-player.cjs.map +7 -0
  46. package/build/utils/waveform-utils.cjs +171 -0
  47. package/build/utils/waveform-utils.cjs.map +7 -0
  48. package/build-module/accordion/view.mjs +1 -35
  49. package/build-module/accordion/view.mjs.map +2 -2
  50. package/build-module/button/block.json +11 -3
  51. package/build-module/button/deprecated.mjs +246 -13
  52. package/build-module/button/deprecated.mjs.map +2 -2
  53. package/build-module/button/edit.mjs +47 -63
  54. package/build-module/button/edit.mjs.map +2 -2
  55. package/build-module/button/save.mjs +3 -7
  56. package/build-module/button/save.mjs.map +2 -2
  57. package/build-module/button/utils.mjs +33 -0
  58. package/build-module/button/utils.mjs.map +7 -0
  59. package/build-module/image/image.mjs +1 -1
  60. package/build-module/image/image.mjs.map +2 -2
  61. package/build-module/navigation/edit/index.mjs +4 -2
  62. package/build-module/navigation/edit/index.mjs.map +2 -2
  63. package/build-module/navigation/edit/leaf-more-menu.mjs +73 -7
  64. package/build-module/navigation/edit/leaf-more-menu.mjs.map +2 -2
  65. package/build-module/navigation/edit/menu-inspector-controls.mjs +21 -101
  66. package/build-module/navigation/edit/menu-inspector-controls.mjs.map +2 -2
  67. package/build-module/navigation/edit/navigation-link-ui.mjs +76 -0
  68. package/build-module/navigation/edit/navigation-link-ui.mjs.map +7 -0
  69. package/build-module/navigation/edit/navigation-list-view-header.mjs +58 -0
  70. package/build-module/navigation/edit/navigation-list-view-header.mjs.map +7 -0
  71. package/build-module/navigation/edit/navigation-menu-selector.mjs +5 -3
  72. package/build-module/navigation/edit/navigation-menu-selector.mjs.map +2 -2
  73. package/build-module/navigation/edit/placeholder/index.mjs +2 -2
  74. package/build-module/navigation/edit/placeholder/index.mjs.map +2 -2
  75. package/build-module/navigation-link/shared/controls.mjs +29 -53
  76. package/build-module/navigation-link/shared/controls.mjs.map +2 -2
  77. package/build-module/navigation-link/shared/use-link-preview.mjs +8 -9
  78. package/build-module/navigation-link/shared/use-link-preview.mjs.map +2 -2
  79. package/build-module/page-list-item/edit.mjs +6 -3
  80. package/build-module/page-list-item/edit.mjs.map +2 -2
  81. package/build-module/playlist/edit.mjs +41 -139
  82. package/build-module/playlist/edit.mjs.map +2 -2
  83. package/build-module/playlist/view.mjs +56 -38
  84. package/build-module/playlist/view.mjs.map +2 -2
  85. package/build-module/playlist-track/edit.mjs +0 -1
  86. package/build-module/playlist-track/edit.mjs.map +2 -2
  87. package/build-module/post-title/block.json +3 -0
  88. package/build-module/post-title/edit.mjs +2 -2
  89. package/build-module/post-title/edit.mjs.map +2 -2
  90. package/build-module/utils/waveform-player.mjs +43 -0
  91. package/build-module/utils/waveform-player.mjs.map +7 -0
  92. package/build-module/utils/waveform-utils.mjs +131 -0
  93. package/build-module/utils/waveform-utils.mjs.map +7 -0
  94. package/build-style/button/style-rtl.css +6 -0
  95. package/build-style/button/style.css +6 -0
  96. package/build-style/editor-rtl.css +13 -3
  97. package/build-style/editor.css +13 -3
  98. package/build-style/navigation-link/editor-rtl.css +10 -0
  99. package/build-style/navigation-link/editor.css +10 -0
  100. package/build-style/playlist/editor-rtl.css +3 -3
  101. package/build-style/playlist/editor.css +3 -3
  102. package/build-style/playlist/style-rtl.css +351 -17
  103. package/build-style/playlist/style.css +351 -17
  104. package/build-style/style-rtl.css +357 -17
  105. package/build-style/style.css +357 -17
  106. package/package.json +39 -38
  107. package/src/accordion/view.js +1 -44
  108. package/src/accordion-item/index.php +0 -1
  109. package/src/button/block.json +11 -3
  110. package/src/button/deprecated.js +254 -16
  111. package/src/button/edit.js +50 -61
  112. package/src/button/index.php +68 -0
  113. package/src/button/save.js +2 -8
  114. package/src/button/style.scss +49 -7
  115. package/src/button/test/utils.js +84 -0
  116. package/src/button/utils.js +42 -0
  117. package/src/cover/index.php +4 -4
  118. package/src/image/image.js +14 -15
  119. package/src/image/index.php +3 -1
  120. package/src/navigation/edit/index.js +4 -2
  121. package/src/navigation/edit/leaf-more-menu.js +86 -11
  122. package/src/navigation/edit/menu-inspector-controls.js +23 -142
  123. package/src/navigation/edit/navigation-link-ui.js +115 -0
  124. package/src/navigation/edit/navigation-list-view-header.js +62 -0
  125. package/src/navigation/edit/navigation-menu-selector.js +5 -3
  126. package/src/navigation/edit/placeholder/index.js +3 -2
  127. package/src/navigation/edit/test/navigation-menu-selector.js +23 -20
  128. package/src/navigation-link/editor.scss +18 -0
  129. package/src/navigation-link/shared/controls.js +35 -62
  130. package/src/navigation-link/shared/test/controls.js +5 -5
  131. package/src/navigation-link/shared/test/use-link-preview.test.js +19 -1
  132. package/src/navigation-link/shared/use-link-preview.js +14 -15
  133. package/src/page-list/index.php +1 -1
  134. package/src/page-list-item/edit.js +8 -7
  135. package/src/playlist/edit.js +60 -154
  136. package/src/playlist/editor.scss +3 -3
  137. package/src/playlist/index.php +15 -40
  138. package/src/playlist/style.scss +34 -27
  139. package/src/playlist/test/edit.js +137 -0
  140. package/src/playlist/view.js +97 -40
  141. package/src/playlist-track/edit.js +0 -1
  142. package/src/post-title/block.json +3 -0
  143. package/src/post-title/edit.js +4 -2
  144. package/src/query-title/index.php +1 -1
  145. package/src/search/index.php +1 -1
  146. package/src/utils/test/waveform-utils.js +328 -0
  147. package/src/utils/waveform-player.js +77 -0
  148. package/src/utils/waveform-utils.js +232 -0
  149. package/build/navigation/use-navigation-entities.cjs +0 -67
  150. package/build/navigation/use-navigation-entities.cjs.map +0 -7
  151. package/build-module/navigation/use-navigation-entities.mjs +0 -46
  152. package/build-module/navigation/use-navigation-entities.mjs.map +0 -7
  153. package/src/navigation/use-navigation-entities.js +0 -72
@@ -0,0 +1,232 @@
1
+ /**
2
+ * Shared utilities for waveform audio player functionality.
3
+ * Used by both the WaveformPlayer component (editor) and view.js (frontend).
4
+ */
5
+
6
+ /**
7
+ * External dependencies
8
+ */
9
+ import { colord } from 'colord';
10
+ import WaveformPlayerLib from '@arraypress/waveform-player';
11
+
12
+ /**
13
+ * Configuration constants.
14
+ * Note: DEFAULT_WAVEFORM_HEIGHT should match $waveform-player-height in style.scss.
15
+ */
16
+ const DEFAULT_WAVEFORM_HEIGHT = 100;
17
+
18
+ /**
19
+ * Get computed style for an element, using ownerDocument for iframe compatibility.
20
+ *
21
+ * @param {Element} element - The element to get styles from.
22
+ * @return {CSSStyleDeclaration} The computed style.
23
+ */
24
+ function getComputedStyle( element ) {
25
+ return element.ownerDocument.defaultView.getComputedStyle( element );
26
+ }
27
+
28
+ /**
29
+ * Get all colors needed for the waveform player based on the element's styles.
30
+ *
31
+ * @param {Element} element - The element to derive colors from.
32
+ * @return {Object} Object containing textColor, waveformColor, progressColor.
33
+ */
34
+ export function getWaveformColors( element ) {
35
+ const textColor = getComputedStyle( element ).color;
36
+ const waveformColor = colord( textColor ).alpha( 0.3 ).toRgbString();
37
+ const progressColor = colord( textColor ).alpha( 0.6 ).toRgbString();
38
+
39
+ return { textColor, waveformColor, progressColor };
40
+ }
41
+
42
+ /**
43
+ * Create a waveform container element with the specified attributes.
44
+ *
45
+ * @param {Object} options - The options for the container.
46
+ * @param {string} options.url - The audio URL.
47
+ * @param {string} options.title - The track title.
48
+ * @param {string} options.artist - The track artist.
49
+ * @param {string} options.artwork - The album artwork URL.
50
+ * @param {string} options.waveformColor - The waveform bar color.
51
+ * @param {string} options.progressColor - The progress indicator color.
52
+ * @param {string} options.buttonColor - The play button color.
53
+ * @param {number} options.height - The waveform height in pixels.
54
+ * @return {Element} The configured container element.
55
+ */
56
+ export function createWaveformContainer( {
57
+ url,
58
+ title,
59
+ artist,
60
+ artwork,
61
+ waveformColor,
62
+ progressColor,
63
+ buttonColor,
64
+ height = DEFAULT_WAVEFORM_HEIGHT,
65
+ } ) {
66
+ const container = document.createElement( 'div' );
67
+ container.setAttribute( 'data-waveform-player', '' );
68
+ container.setAttribute( 'data-url', url );
69
+ container.setAttribute( 'data-height', String( height ) );
70
+ container.setAttribute( 'data-waveform-style', 'bars' );
71
+ container.setAttribute( 'data-waveform-color', waveformColor );
72
+ container.setAttribute( 'data-progress-color', progressColor );
73
+ container.setAttribute( 'data-button-color', buttonColor );
74
+ container.setAttribute( 'data-text-color', buttonColor );
75
+ container.setAttribute( 'data-text-secondary-color', buttonColor );
76
+ if ( title ) {
77
+ container.setAttribute( 'data-title', title );
78
+ }
79
+ if ( artist ) {
80
+ container.setAttribute( 'data-subtitle', artist );
81
+ }
82
+ if ( artwork ) {
83
+ container.setAttribute( 'data-artwork', artwork );
84
+ }
85
+ return container;
86
+ }
87
+
88
+ /**
89
+ * Apply contrasting color to SVG icon paths for visibility.
90
+ * The icons should contrast with the button background (which uses textColor).
91
+ *
92
+ * @param {Element} container - The waveform container element.
93
+ * @param {string} buttonColor - The button background color (textColor).
94
+ */
95
+ export function styleSvgIcons( container, buttonColor ) {
96
+ // Compute a contrasting color for the icons based on button brightness.
97
+ const isButtonDark = colord( buttonColor ).isDark();
98
+ const iconColor = isButtonDark ? '#ffffff' : '#000000';
99
+
100
+ const svgPaths = container.querySelectorAll( 'svg path' );
101
+ svgPaths.forEach( ( path ) => {
102
+ path.style.fill = iconColor;
103
+ } );
104
+ }
105
+
106
+ /**
107
+ * Set up play button accessibility: aria-label that toggles on play/pause.
108
+ *
109
+ * @param {Element} container - The waveform container element.
110
+ * @param {Object} labels - Button labels.
111
+ * @param {string} labels.play - Label for the play state.
112
+ * @param {string} labels.pause - Label for the pause state.
113
+ */
114
+ export function setupPlayButtonAccessibility(
115
+ container,
116
+ { play: playLabel = 'Play', pause: pauseLabel = 'Pause' } = {}
117
+ ) {
118
+ const playBtn = container.querySelector( '.waveform-btn' );
119
+ if ( ! playBtn ) {
120
+ return;
121
+ }
122
+
123
+ playBtn.setAttribute( 'aria-label', playLabel );
124
+
125
+ const onPlay = () => playBtn.setAttribute( 'aria-label', pauseLabel );
126
+ const onPause = () => playBtn.setAttribute( 'aria-label', playLabel );
127
+
128
+ container.addEventListener( 'waveformplayer:play', onPlay );
129
+ container.addEventListener( 'waveformplayer:pause', onPause );
130
+ container.addEventListener( 'waveformplayer:ended', onPause );
131
+
132
+ return () => {
133
+ container.removeEventListener( 'waveformplayer:play', onPlay );
134
+ container.removeEventListener( 'waveformplayer:pause', onPause );
135
+ container.removeEventListener( 'waveformplayer:ended', onPause );
136
+ };
137
+ }
138
+
139
+ /**
140
+ * Log play errors, filtering out expected AbortError.
141
+ *
142
+ * @param {Error} error - The error from play().
143
+ */
144
+ export function logPlayError( error ) {
145
+ // The browser throws AbortError when a play() promise is interrupted
146
+ // by a subsequent pause() or a new audio source load (track change).
147
+ // This is normal during rapid user interaction and safe to ignore.
148
+ if ( error.name === 'AbortError' ) {
149
+ return;
150
+ }
151
+ // eslint-disable-next-line no-console
152
+ console.error( 'Playlist play error:', error );
153
+ }
154
+
155
+ /**
156
+ * Initialize a WaveformPlayer instance on an element.
157
+ *
158
+ * This is the shared core logic used by both the React component (editor)
159
+ * and the Interactivity API (frontend).
160
+ *
161
+ * @param {Element} element - The container element (must be in DOM).
162
+ * @param {Object} options - Configuration options.
163
+ * @param {string} options.src - The audio file URL.
164
+ * @param {string} options.title - The track title.
165
+ * @param {string} options.artist - The artist name.
166
+ * @param {string} options.image - The artwork image URL.
167
+ * @param {boolean} options.autoPlay - Whether to auto-play when ready.
168
+ * @param {Function} options.onEnded - Callback when track ends.
169
+ * @param {Object} options.labels - Translated button labels.
170
+ * @return {Object} Object with instance, container, and destroy function.
171
+ */
172
+ export function initWaveformPlayer(
173
+ element,
174
+ { src, title, artist, image, autoPlay, onEnded, labels }
175
+ ) {
176
+ // Get colors from computed styles.
177
+ const { textColor, waveformColor, progressColor } =
178
+ getWaveformColors( element );
179
+
180
+ // Create the waveform container.
181
+ const container = createWaveformContainer( {
182
+ url: src,
183
+ title,
184
+ artist,
185
+ artwork: image,
186
+ waveformColor,
187
+ progressColor,
188
+ buttonColor: textColor,
189
+ } );
190
+ element.appendChild( container );
191
+
192
+ // Initialize the WaveformPlayer library.
193
+ const instance = new WaveformPlayerLib( container );
194
+
195
+ // Set up event handlers.
196
+ let cleanupAccessibility;
197
+ const handlers = {
198
+ ready: () => {
199
+ styleSvgIcons( container, textColor );
200
+ cleanupAccessibility = setupPlayButtonAccessibility(
201
+ container,
202
+ labels
203
+ );
204
+ if ( autoPlay ) {
205
+ instance.play()?.catch( logPlayError );
206
+ }
207
+ },
208
+ ended: () => onEnded?.(),
209
+ };
210
+
211
+ container.addEventListener( 'waveformplayer:ready', handlers.ready );
212
+ container.addEventListener( 'waveformplayer:ended', handlers.ended );
213
+
214
+ // Return instance, container, and cleanup function.
215
+ return {
216
+ instance,
217
+ container,
218
+ destroy: () => {
219
+ cleanupAccessibility?.();
220
+ container.removeEventListener(
221
+ 'waveformplayer:ready',
222
+ handlers.ready
223
+ );
224
+ container.removeEventListener(
225
+ 'waveformplayer:ended',
226
+ handlers.ended
227
+ );
228
+ instance.destroy();
229
+ container.remove();
230
+ },
231
+ };
232
+ }
@@ -1,67 +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-library/src/navigation/use-navigation-entities.js
21
- var use_navigation_entities_exports = {};
22
- __export(use_navigation_entities_exports, {
23
- default: () => useNavigationEntities
24
- });
25
- module.exports = __toCommonJS(use_navigation_entities_exports);
26
- var import_core_data = require("@wordpress/core-data");
27
- function useNavigationEntities(menuId) {
28
- const {
29
- records: menus,
30
- isResolving: isResolvingMenus,
31
- hasResolved: hasResolvedMenus
32
- } = (0, import_core_data.useEntityRecords)("root", "menu", { per_page: -1, context: "view" });
33
- const {
34
- records: pages,
35
- isResolving: isResolvingPages,
36
- hasResolved: hasResolvedPages
37
- } = (0, import_core_data.useEntityRecords)("postType", "page", {
38
- parent: 0,
39
- order: "asc",
40
- orderby: "id",
41
- per_page: -1,
42
- context: "view"
43
- });
44
- const { records: menuItems, hasResolved: hasResolvedMenuItems } = (0, import_core_data.useEntityRecords)(
45
- "root",
46
- "menuItem",
47
- {
48
- menus: menuId,
49
- per_page: -1,
50
- context: "view"
51
- },
52
- { enabled: !!menuId }
53
- );
54
- return {
55
- pages,
56
- isResolvingPages,
57
- hasResolvedPages,
58
- hasPages: !!(hasResolvedPages && pages?.length),
59
- menus,
60
- isResolvingMenus,
61
- hasResolvedMenus,
62
- hasMenus: !!(hasResolvedMenus && menus?.length),
63
- menuItems,
64
- hasResolvedMenuItems
65
- };
66
- }
67
- //# sourceMappingURL=use-navigation-entities.cjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/navigation/use-navigation-entities.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useEntityRecords } from '@wordpress/core-data';\n\n/**\n * @typedef {Object} NavigationEntitiesData\n * @property {Array|undefined} pages - a collection of WP Post entity objects of post type \"Page\".\n * @property {boolean} isResolvingPages - indicates whether the request to fetch pages is currently resolving.\n * @property {boolean} hasResolvedPages - indicates whether the request to fetch pages has finished resolving.\n * @property {Array|undefined} menus - a collection of Menu entity objects.\n * @property {boolean} isResolvingMenus - indicates whether the request to fetch menus is currently resolving.\n * @property {boolean} hasResolvedMenus - indicates whether the request to fetch menus has finished resolving.\n * @property {Array|undefined} menusItems - a collection of Menu Item entity objects for the current menuId.\n * @property {boolean} hasResolvedMenuItems - indicates whether the request to fetch menuItems has finished resolving.\n * @property {boolean} hasPages - indicates whether there is currently any data for pages.\n * @property {boolean} hasMenus - indicates whether there is currently any data for menus.\n */\n\n/**\n * Manages fetching and resolution state for all entities required\n * for the Navigation block.\n *\n * @param {number} menuId the menu for which to retrieve menuItem data.\n * @return { NavigationEntitiesData } the entity data.\n */\nexport default function useNavigationEntities( menuId ) {\n\tconst {\n\t\trecords: menus,\n\t\tisResolving: isResolvingMenus,\n\t\thasResolved: hasResolvedMenus,\n\t} = useEntityRecords( 'root', 'menu', { per_page: -1, context: 'view' } );\n\n\tconst {\n\t\trecords: pages,\n\t\tisResolving: isResolvingPages,\n\t\thasResolved: hasResolvedPages,\n\t} = useEntityRecords( 'postType', 'page', {\n\t\tparent: 0,\n\t\torder: 'asc',\n\t\torderby: 'id',\n\t\tper_page: -1,\n\t\tcontext: 'view',\n\t} );\n\n\tconst { records: menuItems, hasResolved: hasResolvedMenuItems } =\n\t\tuseEntityRecords(\n\t\t\t'root',\n\t\t\t'menuItem',\n\t\t\t{\n\t\t\t\tmenus: menuId,\n\t\t\t\tper_page: -1,\n\t\t\t\tcontext: 'view',\n\t\t\t},\n\t\t\t{ enabled: !! menuId }\n\t\t);\n\n\treturn {\n\t\tpages,\n\t\tisResolvingPages,\n\t\thasResolvedPages,\n\t\thasPages: !! ( hasResolvedPages && pages?.length ),\n\n\t\tmenus,\n\t\tisResolvingMenus,\n\t\thasResolvedMenus,\n\t\thasMenus: !! ( hasResolvedMenus && menus?.length ),\n\n\t\tmenuItems,\n\t\thasResolvedMenuItems,\n\t};\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,uBAAiC;AAuBlB,SAAR,sBAAwC,QAAS;AACvD,QAAM;AAAA,IACL,SAAS;AAAA,IACT,aAAa;AAAA,IACb,aAAa;AAAA,EACd,QAAI,mCAAkB,QAAQ,QAAQ,EAAE,UAAU,IAAI,SAAS,OAAO,CAAE;AAExE,QAAM;AAAA,IACL,SAAS;AAAA,IACT,aAAa;AAAA,IACb,aAAa;AAAA,EACd,QAAI,mCAAkB,YAAY,QAAQ;AAAA,IACzC,QAAQ;AAAA,IACR,OAAO;AAAA,IACP,SAAS;AAAA,IACT,UAAU;AAAA,IACV,SAAS;AAAA,EACV,CAAE;AAEF,QAAM,EAAE,SAAS,WAAW,aAAa,qBAAqB,QAC7D;AAAA,IACC;AAAA,IACA;AAAA,IACA;AAAA,MACC,OAAO;AAAA,MACP,UAAU;AAAA,MACV,SAAS;AAAA,IACV;AAAA,IACA,EAAE,SAAS,CAAC,CAAE,OAAO;AAAA,EACtB;AAED,SAAO;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,IACA,UAAU,CAAC,EAAI,oBAAoB,OAAO;AAAA,IAE1C;AAAA,IACA;AAAA,IACA;AAAA,IACA,UAAU,CAAC,EAAI,oBAAoB,OAAO;AAAA,IAE1C;AAAA,IACA;AAAA,EACD;AACD;",
6
- "names": []
7
- }
@@ -1,46 +0,0 @@
1
- // packages/block-library/src/navigation/use-navigation-entities.js
2
- import { useEntityRecords } from "@wordpress/core-data";
3
- function useNavigationEntities(menuId) {
4
- const {
5
- records: menus,
6
- isResolving: isResolvingMenus,
7
- hasResolved: hasResolvedMenus
8
- } = useEntityRecords("root", "menu", { per_page: -1, context: "view" });
9
- const {
10
- records: pages,
11
- isResolving: isResolvingPages,
12
- hasResolved: hasResolvedPages
13
- } = useEntityRecords("postType", "page", {
14
- parent: 0,
15
- order: "asc",
16
- orderby: "id",
17
- per_page: -1,
18
- context: "view"
19
- });
20
- const { records: menuItems, hasResolved: hasResolvedMenuItems } = useEntityRecords(
21
- "root",
22
- "menuItem",
23
- {
24
- menus: menuId,
25
- per_page: -1,
26
- context: "view"
27
- },
28
- { enabled: !!menuId }
29
- );
30
- return {
31
- pages,
32
- isResolvingPages,
33
- hasResolvedPages,
34
- hasPages: !!(hasResolvedPages && pages?.length),
35
- menus,
36
- isResolvingMenus,
37
- hasResolvedMenus,
38
- hasMenus: !!(hasResolvedMenus && menus?.length),
39
- menuItems,
40
- hasResolvedMenuItems
41
- };
42
- }
43
- export {
44
- useNavigationEntities as default
45
- };
46
- //# sourceMappingURL=use-navigation-entities.mjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/navigation/use-navigation-entities.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useEntityRecords } from '@wordpress/core-data';\n\n/**\n * @typedef {Object} NavigationEntitiesData\n * @property {Array|undefined} pages - a collection of WP Post entity objects of post type \"Page\".\n * @property {boolean} isResolvingPages - indicates whether the request to fetch pages is currently resolving.\n * @property {boolean} hasResolvedPages - indicates whether the request to fetch pages has finished resolving.\n * @property {Array|undefined} menus - a collection of Menu entity objects.\n * @property {boolean} isResolvingMenus - indicates whether the request to fetch menus is currently resolving.\n * @property {boolean} hasResolvedMenus - indicates whether the request to fetch menus has finished resolving.\n * @property {Array|undefined} menusItems - a collection of Menu Item entity objects for the current menuId.\n * @property {boolean} hasResolvedMenuItems - indicates whether the request to fetch menuItems has finished resolving.\n * @property {boolean} hasPages - indicates whether there is currently any data for pages.\n * @property {boolean} hasMenus - indicates whether there is currently any data for menus.\n */\n\n/**\n * Manages fetching and resolution state for all entities required\n * for the Navigation block.\n *\n * @param {number} menuId the menu for which to retrieve menuItem data.\n * @return { NavigationEntitiesData } the entity data.\n */\nexport default function useNavigationEntities( menuId ) {\n\tconst {\n\t\trecords: menus,\n\t\tisResolving: isResolvingMenus,\n\t\thasResolved: hasResolvedMenus,\n\t} = useEntityRecords( 'root', 'menu', { per_page: -1, context: 'view' } );\n\n\tconst {\n\t\trecords: pages,\n\t\tisResolving: isResolvingPages,\n\t\thasResolved: hasResolvedPages,\n\t} = useEntityRecords( 'postType', 'page', {\n\t\tparent: 0,\n\t\torder: 'asc',\n\t\torderby: 'id',\n\t\tper_page: -1,\n\t\tcontext: 'view',\n\t} );\n\n\tconst { records: menuItems, hasResolved: hasResolvedMenuItems } =\n\t\tuseEntityRecords(\n\t\t\t'root',\n\t\t\t'menuItem',\n\t\t\t{\n\t\t\t\tmenus: menuId,\n\t\t\t\tper_page: -1,\n\t\t\t\tcontext: 'view',\n\t\t\t},\n\t\t\t{ enabled: !! menuId }\n\t\t);\n\n\treturn {\n\t\tpages,\n\t\tisResolvingPages,\n\t\thasResolvedPages,\n\t\thasPages: !! ( hasResolvedPages && pages?.length ),\n\n\t\tmenus,\n\t\tisResolvingMenus,\n\t\thasResolvedMenus,\n\t\thasMenus: !! ( hasResolvedMenus && menus?.length ),\n\n\t\tmenuItems,\n\t\thasResolvedMenuItems,\n\t};\n}\n"],
5
- "mappings": ";AAGA,SAAS,wBAAwB;AAuBlB,SAAR,sBAAwC,QAAS;AACvD,QAAM;AAAA,IACL,SAAS;AAAA,IACT,aAAa;AAAA,IACb,aAAa;AAAA,EACd,IAAI,iBAAkB,QAAQ,QAAQ,EAAE,UAAU,IAAI,SAAS,OAAO,CAAE;AAExE,QAAM;AAAA,IACL,SAAS;AAAA,IACT,aAAa;AAAA,IACb,aAAa;AAAA,EACd,IAAI,iBAAkB,YAAY,QAAQ;AAAA,IACzC,QAAQ;AAAA,IACR,OAAO;AAAA,IACP,SAAS;AAAA,IACT,UAAU;AAAA,IACV,SAAS;AAAA,EACV,CAAE;AAEF,QAAM,EAAE,SAAS,WAAW,aAAa,qBAAqB,IAC7D;AAAA,IACC;AAAA,IACA;AAAA,IACA;AAAA,MACC,OAAO;AAAA,MACP,UAAU;AAAA,MACV,SAAS;AAAA,IACV;AAAA,IACA,EAAE,SAAS,CAAC,CAAE,OAAO;AAAA,EACtB;AAED,SAAO;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,IACA,UAAU,CAAC,EAAI,oBAAoB,OAAO;AAAA,IAE1C;AAAA,IACA;AAAA,IACA;AAAA,IACA,UAAU,CAAC,EAAI,oBAAoB,OAAO;AAAA,IAE1C;AAAA,IACA;AAAA,EACD;AACD;",
6
- "names": []
7
- }
@@ -1,72 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { useEntityRecords } from '@wordpress/core-data';
5
-
6
- /**
7
- * @typedef {Object} NavigationEntitiesData
8
- * @property {Array|undefined} pages - a collection of WP Post entity objects of post type "Page".
9
- * @property {boolean} isResolvingPages - indicates whether the request to fetch pages is currently resolving.
10
- * @property {boolean} hasResolvedPages - indicates whether the request to fetch pages has finished resolving.
11
- * @property {Array|undefined} menus - a collection of Menu entity objects.
12
- * @property {boolean} isResolvingMenus - indicates whether the request to fetch menus is currently resolving.
13
- * @property {boolean} hasResolvedMenus - indicates whether the request to fetch menus has finished resolving.
14
- * @property {Array|undefined} menusItems - a collection of Menu Item entity objects for the current menuId.
15
- * @property {boolean} hasResolvedMenuItems - indicates whether the request to fetch menuItems has finished resolving.
16
- * @property {boolean} hasPages - indicates whether there is currently any data for pages.
17
- * @property {boolean} hasMenus - indicates whether there is currently any data for menus.
18
- */
19
-
20
- /**
21
- * Manages fetching and resolution state for all entities required
22
- * for the Navigation block.
23
- *
24
- * @param {number} menuId the menu for which to retrieve menuItem data.
25
- * @return { NavigationEntitiesData } the entity data.
26
- */
27
- export default function useNavigationEntities( menuId ) {
28
- const {
29
- records: menus,
30
- isResolving: isResolvingMenus,
31
- hasResolved: hasResolvedMenus,
32
- } = useEntityRecords( 'root', 'menu', { per_page: -1, context: 'view' } );
33
-
34
- const {
35
- records: pages,
36
- isResolving: isResolvingPages,
37
- hasResolved: hasResolvedPages,
38
- } = useEntityRecords( 'postType', 'page', {
39
- parent: 0,
40
- order: 'asc',
41
- orderby: 'id',
42
- per_page: -1,
43
- context: 'view',
44
- } );
45
-
46
- const { records: menuItems, hasResolved: hasResolvedMenuItems } =
47
- useEntityRecords(
48
- 'root',
49
- 'menuItem',
50
- {
51
- menus: menuId,
52
- per_page: -1,
53
- context: 'view',
54
- },
55
- { enabled: !! menuId }
56
- );
57
-
58
- return {
59
- pages,
60
- isResolvingPages,
61
- hasResolvedPages,
62
- hasPages: !! ( hasResolvedPages && pages?.length ),
63
-
64
- menus,
65
- isResolvingMenus,
66
- hasResolvedMenus,
67
- hasMenus: !! ( hasResolvedMenus && menus?.length ),
68
-
69
- menuItems,
70
- hasResolvedMenuItems,
71
- };
72
- }