@seedgrid/fe-components 2026.3.20 → 2026.3.27

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 (174) hide show
  1. package/dist/buttons/SgFloatActionButton.d.ts.map +1 -1
  2. package/dist/buttons/SgFloatActionButton.js +5 -26
  3. package/dist/buttons/SgSplitButton.d.ts.map +1 -1
  4. package/dist/buttons/SgSplitButton.js +3 -1
  5. package/dist/buttons/fab-helpers.d.ts +6 -0
  6. package/dist/buttons/fab-helpers.d.ts.map +1 -0
  7. package/dist/buttons/fab-helpers.js +29 -0
  8. package/dist/commons/SgAvatar.d.ts.map +1 -1
  9. package/dist/commons/SgAvatar.js +6 -3
  10. package/dist/commons/SgBadge.d.ts.map +1 -1
  11. package/dist/commons/SgBadge.js +5 -2
  12. package/dist/commons/SgToast.d.ts.map +1 -1
  13. package/dist/commons/SgToast.js +3 -1
  14. package/dist/commons/SgToaster.d.ts.map +1 -1
  15. package/dist/commons/SgToaster.js +3 -1
  16. package/dist/environment/SgEnvironmentProvider.d.ts.map +1 -1
  17. package/dist/environment/SgEnvironmentProvider.js +10 -15
  18. package/dist/environment/persistent-state.d.ts +22 -0
  19. package/dist/environment/persistent-state.d.ts.map +1 -0
  20. package/dist/environment/persistent-state.js +33 -0
  21. package/dist/gadgets/calendar/SgCalendar.d.ts.map +1 -1
  22. package/dist/gadgets/calendar/SgCalendar.js +5 -23
  23. package/dist/gadgets/clock/SgClock.d.ts.map +1 -1
  24. package/dist/gadgets/clock/SgClock.js +12 -10
  25. package/dist/gadgets/clock/themes/SgClockThemePicker.d.ts +2 -1
  26. package/dist/gadgets/clock/themes/SgClockThemePicker.d.ts.map +1 -1
  27. package/dist/gadgets/clock/themes/SgClockThemePicker.js +23 -28
  28. package/dist/gadgets/clock/themes/search.d.ts +9 -0
  29. package/dist/gadgets/clock/themes/search.d.ts.map +1 -0
  30. package/dist/gadgets/clock/themes/search.js +15 -0
  31. package/dist/gadgets/gauge/SgLinearGauge.d.ts.map +1 -1
  32. package/dist/gadgets/gauge/SgLinearGauge.js +39 -28
  33. package/dist/gadgets/gauge/SgRadialGauge.d.ts.map +1 -1
  34. package/dist/gadgets/gauge/SgRadialGauge.js +44 -37
  35. package/dist/gadgets/gauge/math.d.ts +90 -0
  36. package/dist/gadgets/gauge/math.d.ts.map +1 -0
  37. package/dist/gadgets/gauge/math.js +81 -0
  38. package/dist/gadgets/qr-code/SgQRCode.d.ts.map +1 -1
  39. package/dist/gadgets/qr-code/SgQRCode.js +3 -1
  40. package/dist/i18n/en-US.d.ts.map +1 -1
  41. package/dist/i18n/en-US.js +99 -1
  42. package/dist/i18n/es.d.ts.map +1 -1
  43. package/dist/i18n/es.js +155 -57
  44. package/dist/i18n/fr.d.ts +3 -0
  45. package/dist/i18n/fr.d.ts.map +1 -0
  46. package/dist/i18n/fr.js +208 -0
  47. package/dist/i18n/index.d.ts +5 -1
  48. package/dist/i18n/index.d.ts.map +1 -1
  49. package/dist/i18n/index.js +50 -14
  50. package/dist/i18n/pt-BR.d.ts.map +1 -1
  51. package/dist/i18n/pt-BR.js +99 -1
  52. package/dist/i18n/pt-PT.d.ts.map +1 -1
  53. package/dist/i18n/pt-PT.js +99 -1
  54. package/dist/index.d.ts +12 -2
  55. package/dist/index.d.ts.map +1 -1
  56. package/dist/index.js +10 -2
  57. package/dist/inputs/SgAutocomplete.d.ts +1 -1
  58. package/dist/inputs/SgAutocomplete.d.ts.map +1 -1
  59. package/dist/inputs/SgAutocomplete.js +7 -4
  60. package/dist/inputs/SgCheckboxGroup.d.ts +2 -6
  61. package/dist/inputs/SgCheckboxGroup.d.ts.map +1 -1
  62. package/dist/inputs/SgCheckboxGroup.js +6 -6
  63. package/dist/inputs/SgCombobox.d.ts.map +1 -1
  64. package/dist/inputs/SgCombobox.js +11 -2
  65. package/dist/inputs/SgDatatable.d.ts.map +1 -1
  66. package/dist/inputs/SgDatatable.js +10 -10
  67. package/dist/inputs/SgInputBirthDate.d.ts.map +1 -1
  68. package/dist/inputs/SgInputBirthDate.js +6 -1
  69. package/dist/inputs/SgInputCNPJ.d.ts +3 -1
  70. package/dist/inputs/SgInputCNPJ.d.ts.map +1 -1
  71. package/dist/inputs/SgInputCNPJ.js +4 -3
  72. package/dist/inputs/SgInputCPF.d.ts +3 -1
  73. package/dist/inputs/SgInputCPF.d.ts.map +1 -1
  74. package/dist/inputs/SgInputCPF.js +8 -3
  75. package/dist/inputs/SgInputCPFCNPJ.d.ts +3 -1
  76. package/dist/inputs/SgInputCPFCNPJ.d.ts.map +1 -1
  77. package/dist/inputs/SgInputCPFCNPJ.js +8 -3
  78. package/dist/inputs/SgInputCurrency.d.ts +3 -7
  79. package/dist/inputs/SgInputCurrency.d.ts.map +1 -1
  80. package/dist/inputs/SgInputCurrency.js +5 -2
  81. package/dist/inputs/SgInputDate.d.ts.map +1 -1
  82. package/dist/inputs/SgInputDate.js +6 -1
  83. package/dist/inputs/SgInputEmail.d.ts.map +1 -1
  84. package/dist/inputs/SgInputEmail.js +1 -1
  85. package/dist/inputs/SgInputNumber.d.ts +3 -7
  86. package/dist/inputs/SgInputNumber.d.ts.map +1 -1
  87. package/dist/inputs/SgInputNumber.js +5 -2
  88. package/dist/inputs/SgInputOTP.d.ts +5 -12
  89. package/dist/inputs/SgInputOTP.d.ts.map +1 -1
  90. package/dist/inputs/SgInputOTP.js +7 -4
  91. package/dist/inputs/SgInputPassword.d.ts.map +1 -1
  92. package/dist/inputs/SgInputPassword.js +1 -1
  93. package/dist/inputs/SgInputPhone.d.ts +3 -1
  94. package/dist/inputs/SgInputPhone.d.ts.map +1 -1
  95. package/dist/inputs/SgInputPhone.js +2 -1
  96. package/dist/inputs/SgInputPostalCode.d.ts.map +1 -1
  97. package/dist/inputs/SgInputPostalCode.js +2 -1
  98. package/dist/inputs/SgInputSelect.d.ts +4 -2
  99. package/dist/inputs/SgInputSelect.d.ts.map +1 -1
  100. package/dist/inputs/SgInputSelect.js +38 -3
  101. package/dist/inputs/SgInputText.d.ts +3 -7
  102. package/dist/inputs/SgInputText.d.ts.map +1 -1
  103. package/dist/inputs/SgInputText.js +5 -2
  104. package/dist/inputs/SgInputTextArea.d.ts +4 -2
  105. package/dist/inputs/SgInputTextArea.d.ts.map +1 -1
  106. package/dist/inputs/SgInputTextArea.js +37 -2
  107. package/dist/inputs/SgOrderList.d.ts +3 -1
  108. package/dist/inputs/SgOrderList.d.ts.map +1 -1
  109. package/dist/inputs/SgOrderList.js +24 -8
  110. package/dist/inputs/SgPickList.d.ts +3 -1
  111. package/dist/inputs/SgPickList.d.ts.map +1 -1
  112. package/dist/inputs/SgPickList.js +33 -17
  113. package/dist/inputs/SgRadioGroup.d.ts +2 -6
  114. package/dist/inputs/SgRadioGroup.d.ts.map +1 -1
  115. package/dist/inputs/SgRadioGroup.js +6 -6
  116. package/dist/inputs/SgRating.d.ts +2 -10
  117. package/dist/inputs/SgRating.d.ts.map +1 -1
  118. package/dist/inputs/SgRating.js +6 -3
  119. package/dist/inputs/SgSlider.d.ts +8 -2
  120. package/dist/inputs/SgSlider.d.ts.map +1 -1
  121. package/dist/inputs/SgSlider.js +62 -10
  122. package/dist/inputs/SgStepperInput.d.ts +8 -2
  123. package/dist/inputs/SgStepperInput.d.ts.map +1 -1
  124. package/dist/inputs/SgStepperInput.js +62 -8
  125. package/dist/inputs/SgTextEditor.d.ts +3 -1
  126. package/dist/inputs/SgTextEditor.d.ts.map +1 -1
  127. package/dist/inputs/SgTextEditor.js +30 -16
  128. package/dist/inputs/SgToggleSwitch.d.ts +3 -7
  129. package/dist/inputs/SgToggleSwitch.d.ts.map +1 -1
  130. package/dist/inputs/SgToggleSwitch.js +6 -3
  131. package/dist/layout/SgBreadcrumb.d.ts.map +1 -1
  132. package/dist/layout/SgBreadcrumb.js +7 -3
  133. package/dist/layout/SgCard.d.ts.map +1 -1
  134. package/dist/layout/SgCard.js +3 -1
  135. package/dist/layout/SgCarousel.d.ts.map +1 -1
  136. package/dist/layout/SgCarousel.js +3 -1
  137. package/dist/layout/SgExpandablePanel.d.ts.map +1 -1
  138. package/dist/layout/SgExpandablePanel.js +3 -1
  139. package/dist/layout/SgMenu.d.ts.map +1 -1
  140. package/dist/layout/SgMenu.js +174 -298
  141. package/dist/layout/SgPageControl.d.ts.map +1 -1
  142. package/dist/layout/SgPageControl.js +7 -3
  143. package/dist/layout/SgToolBar.d.ts.map +1 -1
  144. package/dist/layout/SgToolBar.js +19 -55
  145. package/dist/layout/SgTreeView.d.ts.map +1 -1
  146. package/dist/layout/SgTreeView.js +7 -3
  147. package/dist/layout/drag-position.d.ts +7 -0
  148. package/dist/layout/drag-position.d.ts.map +1 -0
  149. package/dist/layout/drag-position.js +30 -0
  150. package/dist/layout/menu-logic.d.ts +187 -0
  151. package/dist/layout/menu-logic.d.ts.map +1 -0
  152. package/dist/layout/menu-logic.js +349 -0
  153. package/dist/layout/toolbar-logic.d.ts +26 -0
  154. package/dist/layout/toolbar-logic.d.ts.map +1 -0
  155. package/dist/layout/toolbar-logic.js +38 -0
  156. package/dist/menus/SgDockMenu.d.ts.map +1 -1
  157. package/dist/menus/SgDockMenu.js +44 -120
  158. package/dist/menus/dock-menu-logic.d.ts +50 -0
  159. package/dist/menus/dock-menu-logic.d.ts.map +1 -0
  160. package/dist/menus/dock-menu-logic.js +113 -0
  161. package/dist/overlay/SgDialog.d.ts.map +1 -1
  162. package/dist/overlay/SgDialog.js +4 -2
  163. package/dist/overlay/SgPopup.d.ts.map +1 -1
  164. package/dist/overlay/SgPopup.js +4 -1
  165. package/dist/rhf.d.ts +8 -3
  166. package/dist/rhf.d.ts.map +1 -1
  167. package/dist/rhf.js +18 -1
  168. package/dist/sandbox.cjs +64 -64
  169. package/dist/wizard/SgWizard.d.ts.map +1 -1
  170. package/dist/wizard/SgWizard.js +20 -32
  171. package/dist/wizard/logic.d.ts +9 -0
  172. package/dist/wizard/logic.d.ts.map +1 -0
  173. package/dist/wizard/logic.js +20 -0
  174. package/package.json +8 -6
@@ -0,0 +1,349 @@
1
+ export function buildMenuMaps(menu, rootParentId = "__sg_menu_root__") {
2
+ const parentById = new Map();
3
+ const nodeById = new Map();
4
+ const childrenByParent = new Map();
5
+ const firstByUrl = new Map();
6
+ const walk = (nodes, parentId) => {
7
+ childrenByParent.set(parentId, nodes.map((node) => node.id));
8
+ for (const node of nodes) {
9
+ parentById.set(node.id, parentId);
10
+ nodeById.set(node.id, node);
11
+ if (node.url && !firstByUrl.has(node.url))
12
+ firstByUrl.set(node.url, node.id);
13
+ if (Array.isArray(node.children) && node.children.length > 0) {
14
+ walk(node.children, node.id);
15
+ }
16
+ }
17
+ };
18
+ walk(menu, rootParentId);
19
+ return { parentById, nodeById, childrenByParent, firstByUrl };
20
+ }
21
+ export function collectParentChain(parentById, id, rootParentId = "__sg_menu_root__") {
22
+ const out = [];
23
+ let current = parentById.get(id);
24
+ while (current && current !== rootParentId) {
25
+ out.push(current);
26
+ current = parentById.get(current);
27
+ }
28
+ return out;
29
+ }
30
+ export function computeActiveSets(nodes, activeId, activeUrl) {
31
+ const exact = new Set();
32
+ const branch = new Set();
33
+ const walk = (list) => {
34
+ let found = false;
35
+ for (const node of list) {
36
+ const childFound = Array.isArray(node.children) && node.children.length > 0 ? walk(node.children) : false;
37
+ const selfActive = (activeId ? node.id === activeId : false) || (activeUrl ? node.url === activeUrl : false);
38
+ if (selfActive)
39
+ exact.add(node.id);
40
+ if (childFound)
41
+ branch.add(node.id);
42
+ if (selfActive || childFound)
43
+ found = true;
44
+ }
45
+ return found;
46
+ };
47
+ walk(nodes);
48
+ return { exact, branch };
49
+ }
50
+ export function resolveEffectiveActiveId(args) {
51
+ return args.activeId ?? (args.activeUrl ? args.firstByUrl.get(args.activeUrl) : undefined) ?? args.localActiveId;
52
+ }
53
+ export function mergeExpandedIdsForActivePath(currentIds, parentChain) {
54
+ if (parentChain.length === 0)
55
+ return currentIds;
56
+ return Array.from(new Set([...currentIds, ...parentChain]));
57
+ }
58
+ export function resolveTieredActiveState(args) {
59
+ const { effectiveActiveId, maps, menu, rootParentId = "__sg_menu_root__" } = args;
60
+ if (!effectiveActiveId) {
61
+ return { tieredPath: [], megaActiveId: menu[0]?.id };
62
+ }
63
+ const parentChain = collectParentChain(maps.parentById, effectiveActiveId, rootParentId).reverse();
64
+ const activeNode = maps.nodeById.get(effectiveActiveId);
65
+ const tieredPath = [...parentChain];
66
+ if (activeNode?.children?.length)
67
+ tieredPath.push(activeNode.id);
68
+ return {
69
+ tieredPath,
70
+ megaActiveId: parentChain[0] ?? activeNode?.id ?? menu[0]?.id
71
+ };
72
+ }
73
+ export function resolveMenuLayoutState(args) {
74
+ const { dockMode, effectiveDockZone, orientationDirection, position, horizontalDockAlign, isCollapsed, menuStyle, effectiveMenuStyle, pinnedState, expandedWidthCss, collapsedWidthCss } = args;
75
+ const resolvedPosition = dockMode && effectiveDockZone
76
+ ? effectiveDockZone === "right"
77
+ ? "right"
78
+ : effectiveDockZone === "left"
79
+ ? "left"
80
+ : orientationDirection === "horizontal-right"
81
+ ? "right"
82
+ : "left"
83
+ : position;
84
+ const isHorizontalDockZone = effectiveDockZone === "top" || effectiveDockZone === "bottom";
85
+ const isVerticalDockZone = effectiveDockZone === "left" || effectiveDockZone === "right";
86
+ const tieredOpenToLeft = resolvedPosition === "right" ||
87
+ (isHorizontalDockZone && horizontalDockAlign === "right");
88
+ const isMegaMenuStyle = effectiveMenuStyle === "mega-horizontal" || effectiveMenuStyle === "mega-vertical";
89
+ const dockAlign = dockMode && effectiveDockZone === "right" && !isCollapsed
90
+ ? "end"
91
+ : dockMode && effectiveDockZone === "left"
92
+ ? "start"
93
+ : null;
94
+ const sidebarWidthCss = dockMode && isHorizontalDockZone && menuStyle !== "sidebar"
95
+ ? "100%"
96
+ : menuStyle === "inline" && isMegaMenuStyle
97
+ ? "100%"
98
+ : menuStyle === "hybrid"
99
+ ? pinnedState
100
+ ? expandedWidthCss
101
+ : collapsedWidthCss
102
+ : isCollapsed
103
+ ? collapsedWidthCss
104
+ : expandedWidthCss;
105
+ return {
106
+ resolvedPosition,
107
+ isHorizontalDockZone,
108
+ isVerticalDockZone,
109
+ tieredOpenToLeft,
110
+ isMegaMenuStyle,
111
+ dockAlign,
112
+ sidebarWidthCss
113
+ };
114
+ }
115
+ export function resolveMenuNodeActionIntent(args) {
116
+ const { variant, hasChildren, hasActionTarget, isCollapsed = false } = args;
117
+ if (variant === "panel") {
118
+ if (hasChildren && !hasActionTarget && !isCollapsed)
119
+ return "toggle";
120
+ return "activate";
121
+ }
122
+ if (hasChildren && !hasActionTarget)
123
+ return "noop";
124
+ return "activate";
125
+ }
126
+ export function resolveExpandedIdsToggle(args) {
127
+ const { currentIds, nodeId, mode, parentById, childrenByParent, rootParentId = "__sg_menu_root__" } = args;
128
+ const next = new Set(currentIds);
129
+ const isOpen = next.has(nodeId);
130
+ if (isOpen) {
131
+ next.delete(nodeId);
132
+ return Array.from(next);
133
+ }
134
+ if (mode === "accordion") {
135
+ const parentId = parentById.get(nodeId) ?? rootParentId;
136
+ const siblings = childrenByParent.get(parentId) ?? [];
137
+ for (const siblingId of siblings) {
138
+ if (siblingId !== nodeId)
139
+ next.delete(siblingId);
140
+ }
141
+ }
142
+ next.add(nodeId);
143
+ return Array.from(next);
144
+ }
145
+ export function resolveMenuHintPosition(args) {
146
+ const { isConnected, rect, placement } = args;
147
+ if (!isConnected)
148
+ return null;
149
+ if (placement === "right") {
150
+ return {
151
+ x: rect.right + 8,
152
+ y: rect.top + rect.height / 2
153
+ };
154
+ }
155
+ return {
156
+ x: rect.left + rect.width / 2,
157
+ y: rect.top - 8
158
+ };
159
+ }
160
+ export function resolveHorizontalDockAlign(clientX, zoneRect) {
161
+ return clientX < zoneRect.left + zoneRect.width / 2 ? "left" : "right";
162
+ }
163
+ export function resolveTieredHoverPath(currentPath, depth, nodeId, hasChildren) {
164
+ if (!hasChildren)
165
+ return currentPath.slice(0, depth);
166
+ return [...currentPath.slice(0, depth), nodeId];
167
+ }
168
+ export function resolveTieredHoverIntent(args) {
169
+ if (!args.openSubmenuOnHover)
170
+ return undefined;
171
+ return resolveTieredHoverPath(args.currentPath, args.depth, args.nodeId, args.hasChildren);
172
+ }
173
+ export function resolveTieredClickState(currentPath, depth, nodeId) {
174
+ const base = currentPath.slice(0, depth);
175
+ const isOpenAtDepth = currentPath[depth] === nodeId;
176
+ return {
177
+ nextPath: isOpenAtDepth ? base : [...base, nodeId],
178
+ isOpenAtDepth
179
+ };
180
+ }
181
+ export function resolveMenuSearchSelectionState(args) {
182
+ const { currentExpandedIds, parentChain, rootToParent, nodeId, hasChildren, hasActionTarget } = args;
183
+ const expandedIds = mergeExpandedIdsForActivePath(currentExpandedIds, parentChain);
184
+ const tieredPath = [...rootToParent, ...(hasChildren ? [nodeId] : [])];
185
+ const megaActiveId = rootToParent[0] ?? nodeId;
186
+ if (hasChildren && !hasActionTarget) {
187
+ return {
188
+ expandedIds: mergeExpandedIdsForActivePath(expandedIds, [nodeId]),
189
+ tieredPath,
190
+ megaActiveId,
191
+ localActiveId: nodeId,
192
+ shouldActivateNode: false
193
+ };
194
+ }
195
+ return {
196
+ expandedIds,
197
+ tieredPath,
198
+ megaActiveId,
199
+ shouldActivateNode: true
200
+ };
201
+ }
202
+ export function resolveTieredNodeClickIntent(args) {
203
+ const { currentPath, depth, nodeId, hasChildren, hasActionTarget } = args;
204
+ if (!hasChildren) {
205
+ return {
206
+ nextPath: currentPath,
207
+ shouldActivateNode: true,
208
+ isOpenAtDepth: false
209
+ };
210
+ }
211
+ const nextState = resolveTieredClickState(currentPath, depth, nodeId);
212
+ if (nextState.isOpenAtDepth) {
213
+ return {
214
+ nextPath: nextState.nextPath,
215
+ shouldActivateNode: false,
216
+ isOpenAtDepth: true
217
+ };
218
+ }
219
+ return {
220
+ nextPath: nextState.nextPath,
221
+ shouldActivateNode: hasActionTarget,
222
+ isOpenAtDepth: false
223
+ };
224
+ }
225
+ export function resolveMegaMenuActiveNode(items, megaActiveId) {
226
+ return items.find((node) => node.id === megaActiveId) ?? items[0];
227
+ }
228
+ export function resolveMegaMenuInteraction(args) {
229
+ if (args.hasChildren) {
230
+ return { nextMegaActiveId: args.nodeId, shouldActivateNode: false };
231
+ }
232
+ return { shouldActivateNode: true };
233
+ }
234
+ export function resolveMegaMenuHoverActiveId(args) {
235
+ return args.hasChildren ? args.nodeId : undefined;
236
+ }
237
+ export function resolveMenuAutocompleteItems(searchEntries, query, limit = 120) {
238
+ const q = query.trim().toLowerCase();
239
+ const matches = !q
240
+ ? searchEntries
241
+ : searchEntries.filter((entry) => entry.label.toLowerCase().includes(q) ||
242
+ entry.path.toLowerCase().includes(q));
243
+ return matches.slice(0, limit).map((entry) => ({
244
+ id: entry.id,
245
+ label: entry.label,
246
+ value: entry.path,
247
+ group: entry.group,
248
+ data: { nodeId: entry.id, path: entry.path }
249
+ }));
250
+ }
251
+ export function filterMenuNodes(nodes, query) {
252
+ const q = query.trim().toLowerCase();
253
+ if (!q)
254
+ return nodes;
255
+ const walk = (list) => {
256
+ const out = [];
257
+ for (const node of list) {
258
+ const selfMatch = (node.label ?? "").toLowerCase().includes(q);
259
+ const children = Array.isArray(node.children) && node.children.length > 0 ? walk(node.children) : [];
260
+ if (selfMatch || children.length > 0) {
261
+ out.push({
262
+ ...node,
263
+ children: children.length > 0 ? children : undefined
264
+ });
265
+ }
266
+ }
267
+ return out;
268
+ };
269
+ return walk(nodes);
270
+ }
271
+ export function collectMenuSearchEntries(nodes, trail = [], out = []) {
272
+ for (const node of nodes) {
273
+ const label = node.label ?? node.id;
274
+ const nextTrail = [...trail, label];
275
+ out.push({
276
+ id: node.id,
277
+ label,
278
+ path: nextTrail.join(" > "),
279
+ group: trail[0] ?? label
280
+ });
281
+ if (Array.isArray(node.children) && node.children.length > 0) {
282
+ collectMenuSearchEntries(node.children, nextTrail, out);
283
+ }
284
+ }
285
+ return out;
286
+ }
287
+ export function flattenVisibleNodes(nodes, expandedSet, collapsed, forceExpand, depth = 0, parentId = "__sg_menu_root__", out = []) {
288
+ for (const node of nodes) {
289
+ out.push({ node, depth, parentId });
290
+ if (collapsed)
291
+ continue;
292
+ const hasChildren = Boolean(node.children?.length);
293
+ const isOpen = forceExpand || expandedSet.has(node.id);
294
+ if (hasChildren && isOpen) {
295
+ flattenVisibleNodes(node.children, expandedSet, collapsed, forceExpand, depth + 1, node.id, out);
296
+ }
297
+ }
298
+ return out;
299
+ }
300
+ export function resolveMenuKeyboardAction(args) {
301
+ const { key, visibleNodes, focusedId, expandedIds, hasSearch, isCollapsed, parentById, rootParentId } = args;
302
+ if (visibleNodes.length === 0)
303
+ return { type: "noop" };
304
+ const currentIndex = visibleNodes.findIndex((item) => item.node.id === focusedId);
305
+ const activeIndex = currentIndex >= 0 ? currentIndex : 0;
306
+ const current = visibleNodes[activeIndex];
307
+ if (!current)
308
+ return { type: "noop" };
309
+ const node = current.node;
310
+ const hasChildren = Boolean(node.children?.length);
311
+ const isOpen = hasSearch || expandedIds.has(node.id);
312
+ if (key === "ArrowDown") {
313
+ const next = visibleNodes[Math.min(activeIndex + 1, visibleNodes.length - 1)];
314
+ return next ? { type: "focus", id: next.node.id } : { type: "noop" };
315
+ }
316
+ if (key === "ArrowUp") {
317
+ const next = visibleNodes[Math.max(activeIndex - 1, 0)];
318
+ return next ? { type: "focus", id: next.node.id } : { type: "noop" };
319
+ }
320
+ if (key === "ArrowRight") {
321
+ if (hasChildren && !isCollapsed && !isOpen && !hasSearch) {
322
+ return { type: "toggle", id: node.id };
323
+ }
324
+ if (hasChildren && !isCollapsed) {
325
+ const next = visibleNodes[activeIndex + 1];
326
+ if (next && next.depth > current.depth) {
327
+ return { type: "focus", id: next.node.id };
328
+ }
329
+ }
330
+ return { type: "noop" };
331
+ }
332
+ if (key === "ArrowLeft") {
333
+ if (hasChildren && !isCollapsed && isOpen && !hasSearch) {
334
+ return { type: "toggle", id: node.id };
335
+ }
336
+ const parentId = parentById.get(node.id);
337
+ if (parentId && parentId !== rootParentId) {
338
+ return { type: "focus", id: parentId };
339
+ }
340
+ return { type: "noop" };
341
+ }
342
+ if (key === "Enter" || key === " ") {
343
+ if (hasChildren && !node.url && !node.onClick && !isCollapsed) {
344
+ return { type: "toggle", id: node.id };
345
+ }
346
+ return { type: "activate", id: node.id };
347
+ }
348
+ return { type: "noop" };
349
+ }
@@ -0,0 +1,26 @@
1
+ import type { SgDockZoneId } from "./SgDockLayout";
2
+ import type { SgToolBarOrientation, SgToolBarOrientationDirection } from "./SgToolBar";
3
+ export declare function resolveToolbarOrientationDirection(orientationDirection: SgToolBarOrientationDirection): {
4
+ orientation: SgToolBarOrientation;
5
+ direction: "left" | "right" | "up" | "down";
6
+ };
7
+ export declare function resolveToolbarDockOrientationDirection(orientationDirection: SgToolBarOrientationDirection, inDock: boolean, zone: "top" | "bottom" | "left" | "right" | "free"): SgToolBarOrientationDirection;
8
+ export declare function buildToolbarLayoutState(args: {
9
+ orientationDirection: SgToolBarOrientationDirection;
10
+ inDock: boolean;
11
+ zone: "top" | "bottom" | "left" | "right" | "free";
12
+ freeDrag: boolean;
13
+ dragHoverZone: SgDockZoneId | null;
14
+ effectiveZone: "top" | "bottom" | "left" | "right" | "free";
15
+ showContent: boolean;
16
+ }): {
17
+ zoneForOrientation: "top" | "bottom" | "left" | "right" | "free";
18
+ resolvedOrientationDirection: SgToolBarOrientationDirection;
19
+ orientation: SgToolBarOrientation;
20
+ direction: "left" | "right" | "up" | "down";
21
+ openUp: boolean;
22
+ openLeft: boolean;
23
+ showLeadingCollapseButton: boolean;
24
+ collapseIconDirection: "left" | "right" | "up" | "down";
25
+ };
26
+ //# sourceMappingURL=toolbar-logic.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toolbar-logic.d.ts","sourceRoot":"","sources":["../../src/layout/toolbar-logic.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,KAAK,EAAE,oBAAoB,EAAE,6BAA6B,EAAE,MAAM,aAAa,CAAC;AAEvF,wBAAgB,kCAAkC,CAChD,oBAAoB,EAAE,6BAA6B,GAClD;IAAE,WAAW,EAAE,oBAAoB,CAAC;IAAC,SAAS,EAAE,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,MAAM,CAAA;CAAE,CAYpF;AAED,wBAAgB,sCAAsC,CACpD,oBAAoB,EAAE,6BAA6B,EACnD,MAAM,EAAE,OAAO,EACf,IAAI,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,GACjD,6BAA6B,CAQ/B;AAED,wBAAgB,uBAAuB,CAAC,IAAI,EAAE;IAC5C,oBAAoB,EAAE,6BAA6B,CAAC;IACpD,MAAM,EAAE,OAAO,CAAC;IAChB,IAAI,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC;IACnD,QAAQ,EAAE,OAAO,CAAC;IAClB,aAAa,EAAE,YAAY,GAAG,IAAI,CAAC;IACnC,aAAa,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC;IAC5D,WAAW,EAAE,OAAO,CAAC;CACtB,GAAG;IACF,kBAAkB,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC;IACjE,4BAA4B,EAAE,6BAA6B,CAAC;IAC5D,WAAW,EAAE,oBAAoB,CAAC;IAClC,SAAS,EAAE,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,MAAM,CAAC;IAC5C,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,OAAO,CAAC;IAClB,yBAAyB,EAAE,OAAO,CAAC;IACnC,qBAAqB,EAAE,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,MAAM,CAAC;CACzD,CAoBA"}
@@ -0,0 +1,38 @@
1
+ export function resolveToolbarOrientationDirection(orientationDirection) {
2
+ switch (orientationDirection) {
3
+ case "horizontal-right":
4
+ return { orientation: "horizontal", direction: "left" };
5
+ case "horizontal-left":
6
+ return { orientation: "horizontal", direction: "right" };
7
+ case "vertical-up":
8
+ return { orientation: "vertical", direction: "up" };
9
+ case "vertical-down":
10
+ default:
11
+ return { orientation: "vertical", direction: "down" };
12
+ }
13
+ }
14
+ export function resolveToolbarDockOrientationDirection(orientationDirection, inDock, zone) {
15
+ if (!inDock || zone == "free")
16
+ return orientationDirection;
17
+ if (zone === "top" || zone === "bottom") {
18
+ return orientationDirection.startsWith("horizontal") ? orientationDirection : "horizontal-left";
19
+ }
20
+ return orientationDirection.startsWith("vertical") ? orientationDirection : "vertical-down";
21
+ }
22
+ export function buildToolbarLayoutState(args) {
23
+ const zoneForOrientation = args.inDock && !args.freeDrag && args.dragHoverZone ? args.dragHoverZone : args.effectiveZone;
24
+ const resolvedOrientationDirection = resolveToolbarDockOrientationDirection(args.orientationDirection, args.inDock, zoneForOrientation);
25
+ const { orientation, direction } = resolveToolbarOrientationDirection(resolvedOrientationDirection);
26
+ const openUp = orientation === "vertical" && direction === "up";
27
+ const openLeft = orientation === "horizontal" && direction === "left";
28
+ return {
29
+ zoneForOrientation,
30
+ resolvedOrientationDirection,
31
+ orientation,
32
+ direction,
33
+ openUp,
34
+ openLeft,
35
+ showLeadingCollapseButton: orientation === "horizontal" && openLeft && args.showContent,
36
+ collapseIconDirection: resolvedOrientationDirection === "horizontal-right" ? "right" : direction
37
+ };
38
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"SgDockMenu.d.ts","sourceRoot":"","sources":["../../src/menus/SgDockMenu.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAM/B,MAAM,MAAM,kBAAkB,GAC1B,UAAU,GAAG,aAAa,GAAG,aAAa,GAC1C,YAAY,GAAG,eAAe,GAC9B,WAAW,GAAG,cAAc,GAAG,cAAc,CAAC;AAElD,MAAM,MAAM,qBAAqB,GAAG,YAAY,GAAG,UAAU,CAAC;AAE9D,MAAM,MAAM,cAAc,GAAG;IAC3B,wBAAwB;IACxB,EAAE,EAAE,M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