@dbcdk/react-components 0.0.191 → 0.0.193

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 (44) hide show
  1. package/dist/client.cjs +7 -0
  2. package/dist/client.d.ts +1 -0
  3. package/dist/client.js +1 -0
  4. package/dist/components/forms/input/Input.module.css +93 -0
  5. package/dist/components/json-viewer/JsonViewer.cjs +4 -2
  6. package/dist/components/json-viewer/JsonViewer.d.ts +2 -2
  7. package/dist/components/json-viewer/JsonViewer.js +5 -3
  8. package/dist/components/json-viewer/types.d.ts +2 -0
  9. package/dist/components/line-viewer/LineViewer.cjs +11 -3
  10. package/dist/components/line-viewer/LineViewer.d.ts +6 -1
  11. package/dist/components/line-viewer/LineViewer.js +12 -4
  12. package/dist/components/line-viewer/LineViewer.module.css +15 -2
  13. package/dist/components/popover/Popover.cjs +2 -1
  14. package/dist/components/popover/Popover.d.ts +8 -1
  15. package/dist/components/popover/Popover.js +2 -1
  16. package/dist/components/search-box/SearchBox.cjs +10 -7
  17. package/dist/components/search-box/SearchBox.d.ts +7 -0
  18. package/dist/components/search-box/SearchBox.js +10 -7
  19. package/dist/components/sidebar/components/sidenav-filteirng/SidenavFiltering.cjs +2 -1
  20. package/dist/components/sidebar/components/sidenav-filteirng/SidenavFiltering.js +2 -1
  21. package/dist/components/tabs/Tabs.cjs +58 -56
  22. package/dist/components/tabs/Tabs.js +58 -56
  23. package/dist/components/tabs/Tabs.module.css +32 -16
  24. package/dist/components/timeline/Timeline.d.ts +1 -0
  25. package/dist/components/timeline/components/TimelineRow.cjs +1 -1
  26. package/dist/components/timeline/components/TimelineRow.js +1 -1
  27. package/dist/components/timeline/components/TimelineRow.module.css +4 -0
  28. package/dist/components/tree-view/TreeNodeRow.cjs +9 -1
  29. package/dist/components/tree-view/TreeNodeRow.d.ts +2 -1
  30. package/dist/components/tree-view/TreeNodeRow.js +9 -1
  31. package/dist/components/tree-view/TreeView.cjs +2 -0
  32. package/dist/components/tree-view/TreeView.d.ts +1 -1
  33. package/dist/components/tree-view/TreeView.js +2 -0
  34. package/dist/components/tree-view/TreeView.module.css +8 -0
  35. package/dist/components/tree-view/types.d.ts +2 -0
  36. package/dist/components/tree-view/useTreeExpansion.cjs +12 -2
  37. package/dist/components/tree-view/useTreeExpansion.d.ts +1 -0
  38. package/dist/components/tree-view/useTreeExpansion.js +12 -2
  39. package/dist/components/xml-viewer/XmlViewer.cjs +2 -1
  40. package/dist/components/xml-viewer/XmlViewer.js +3 -2
  41. package/dist/hooks/useTreeViewSettings.cjs +87 -0
  42. package/dist/hooks/useTreeViewSettings.d.ts +35 -0
  43. package/dist/hooks/useTreeViewSettings.js +84 -0
  44. package/package.json +1 -1
@@ -150,62 +150,64 @@ function Tabs({
150
150
  ) : null,
151
151
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `${styles__default.default.tabs} ${styles__default.default[variant]} ${panelStyle ? styles__default.default.panelStyle : ""}`, children: [
152
152
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: styles__default.default.tabList, children: [
153
- /* @__PURE__ */ jsxRuntime.jsx(
154
- "div",
155
- {
156
- className: onAddTab ? styles__default.default.tabButtons : `${styles__default.default.tabButtons} ${styles__default.default.tabButtonsEnd}`,
157
- role: "tablist",
158
- "aria-label": header != null ? header : "Tabs",
159
- children: visibleTabs.map((tab, index) => {
160
- const selected = index === activeIndex;
161
- const tabDomId = `${uid}-tab-${String(tab.id)}`;
162
- const panelDomId = `${uid}-panel-${String(tab.id)}`;
163
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `${styles__default.default.tab} ${selected ? styles__default.default.active : ""}`, children: [
164
- /* @__PURE__ */ jsxRuntime.jsxs(
165
- "button",
166
- {
167
- id: tabDomId,
168
- type: "button",
169
- className: styles__default.default.tabButton,
170
- role: "tab",
171
- "aria-selected": selected,
172
- "aria-controls": panelDomId,
173
- tabIndex: selected ? 0 : -1,
174
- disabled: tab.disabled,
175
- onClick: () => setValue(tab.id),
176
- onKeyDown: (e) => onKeyDownTab(e, index),
177
- children: [
178
- tab.headerIcon ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: styles__default.default.icon, children: tab.headerIcon }) : null,
179
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: styles__default.default.label, children: tab.header }),
180
- tab.badge ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: styles__default.default.badge, children: /* @__PURE__ */ jsxRuntime.jsx(Chip.Chip, { size: "sm", children: tab.badge.toLocaleString("da-DK") }) }) : null
181
- ]
182
- }
183
- ),
184
- tab.removable && onRemoveTab ? /* @__PURE__ */ jsxRuntime.jsx(
185
- "button",
186
- {
187
- type: "button",
188
- className: styles__default.default.removeTabButton,
189
- "aria-label": `Fjern fane ${tab.header}`,
190
- disabled: tab.disabled,
191
- onClick: () => onRemoveTab(tab.id, tab, index),
192
- children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { "aria-hidden": "true" })
193
- }
194
- ) : null
195
- ] }, tab.id);
196
- })
197
- }
198
- ),
199
- onAddTab ? /* @__PURE__ */ jsxRuntime.jsx(
200
- "button",
201
- {
202
- type: "button",
203
- className: styles__default.default.addTabButton,
204
- onClick: onAddTab,
205
- "aria-label": "Tilf\xF8j fane",
206
- children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Plus, { "aria-hidden": "true" })
207
- }
208
- ) : null,
153
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: styles__default.default.tabStrip, children: [
154
+ /* @__PURE__ */ jsxRuntime.jsx(
155
+ "div",
156
+ {
157
+ className: onAddTab ? styles__default.default.tabButtons : `${styles__default.default.tabButtons} ${styles__default.default.tabButtonsEnd}`,
158
+ role: "tablist",
159
+ "aria-label": header != null ? header : "Tabs",
160
+ children: visibleTabs.map((tab, index) => {
161
+ const selected = index === activeIndex;
162
+ const tabDomId = `${uid}-tab-${String(tab.id)}`;
163
+ const panelDomId = `${uid}-panel-${String(tab.id)}`;
164
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `${styles__default.default.tab} ${selected ? styles__default.default.active : ""}`, children: [
165
+ /* @__PURE__ */ jsxRuntime.jsxs(
166
+ "button",
167
+ {
168
+ id: tabDomId,
169
+ type: "button",
170
+ className: styles__default.default.tabButton,
171
+ role: "tab",
172
+ "aria-selected": selected,
173
+ "aria-controls": panelDomId,
174
+ tabIndex: selected ? 0 : -1,
175
+ disabled: tab.disabled,
176
+ onClick: () => setValue(tab.id),
177
+ onKeyDown: (e) => onKeyDownTab(e, index),
178
+ children: [
179
+ tab.headerIcon ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: styles__default.default.icon, children: tab.headerIcon }) : null,
180
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: styles__default.default.label, children: tab.header }),
181
+ tab.badge ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: styles__default.default.badge, children: /* @__PURE__ */ jsxRuntime.jsx(Chip.Chip, { size: "sm", children: tab.badge.toLocaleString("da-DK") }) }) : null
182
+ ]
183
+ }
184
+ ),
185
+ tab.removable && onRemoveTab ? /* @__PURE__ */ jsxRuntime.jsx(
186
+ "button",
187
+ {
188
+ type: "button",
189
+ className: styles__default.default.removeTabButton,
190
+ "aria-label": `Fjern fane ${tab.header}`,
191
+ disabled: tab.disabled,
192
+ onClick: () => onRemoveTab(tab.id, tab, index),
193
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { "aria-hidden": "true" })
194
+ }
195
+ ) : null
196
+ ] }, tab.id);
197
+ })
198
+ }
199
+ ),
200
+ onAddTab ? /* @__PURE__ */ jsxRuntime.jsx(
201
+ "button",
202
+ {
203
+ type: "button",
204
+ className: styles__default.default.addTabButton,
205
+ onClick: onAddTab,
206
+ "aria-label": "Tilf\xF8j fane",
207
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Plus, { "aria-hidden": "true" })
208
+ }
209
+ ) : null
210
+ ] }),
209
211
  tabListAddition ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: styles__default.default.tabListAddition, children: tabListAddition }) : null
210
212
  ] }),
211
213
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -144,62 +144,64 @@ function Tabs({
144
144
  ) : null,
145
145
  /* @__PURE__ */ jsxs("div", { className: `${styles.tabs} ${styles[variant]} ${panelStyle ? styles.panelStyle : ""}`, children: [
146
146
  /* @__PURE__ */ jsxs("div", { className: styles.tabList, children: [
147
- /* @__PURE__ */ jsx(
148
- "div",
149
- {
150
- className: onAddTab ? styles.tabButtons : `${styles.tabButtons} ${styles.tabButtonsEnd}`,
151
- role: "tablist",
152
- "aria-label": header != null ? header : "Tabs",
153
- children: visibleTabs.map((tab, index) => {
154
- const selected = index === activeIndex;
155
- const tabDomId = `${uid}-tab-${String(tab.id)}`;
156
- const panelDomId = `${uid}-panel-${String(tab.id)}`;
157
- return /* @__PURE__ */ jsxs("div", { className: `${styles.tab} ${selected ? styles.active : ""}`, children: [
158
- /* @__PURE__ */ jsxs(
159
- "button",
160
- {
161
- id: tabDomId,
162
- type: "button",
163
- className: styles.tabButton,
164
- role: "tab",
165
- "aria-selected": selected,
166
- "aria-controls": panelDomId,
167
- tabIndex: selected ? 0 : -1,
168
- disabled: tab.disabled,
169
- onClick: () => setValue(tab.id),
170
- onKeyDown: (e) => onKeyDownTab(e, index),
171
- children: [
172
- tab.headerIcon ? /* @__PURE__ */ jsx("span", { className: styles.icon, children: tab.headerIcon }) : null,
173
- /* @__PURE__ */ jsx("span", { className: styles.label, children: tab.header }),
174
- tab.badge ? /* @__PURE__ */ jsx("span", { className: styles.badge, children: /* @__PURE__ */ jsx(Chip, { size: "sm", children: tab.badge.toLocaleString("da-DK") }) }) : null
175
- ]
176
- }
177
- ),
178
- tab.removable && onRemoveTab ? /* @__PURE__ */ jsx(
179
- "button",
180
- {
181
- type: "button",
182
- className: styles.removeTabButton,
183
- "aria-label": `Fjern fane ${tab.header}`,
184
- disabled: tab.disabled,
185
- onClick: () => onRemoveTab(tab.id, tab, index),
186
- children: /* @__PURE__ */ jsx(X, { "aria-hidden": "true" })
187
- }
188
- ) : null
189
- ] }, tab.id);
190
- })
191
- }
192
- ),
193
- onAddTab ? /* @__PURE__ */ jsx(
194
- "button",
195
- {
196
- type: "button",
197
- className: styles.addTabButton,
198
- onClick: onAddTab,
199
- "aria-label": "Tilf\xF8j fane",
200
- children: /* @__PURE__ */ jsx(Plus, { "aria-hidden": "true" })
201
- }
202
- ) : null,
147
+ /* @__PURE__ */ jsxs("div", { className: styles.tabStrip, children: [
148
+ /* @__PURE__ */ jsx(
149
+ "div",
150
+ {
151
+ className: onAddTab ? styles.tabButtons : `${styles.tabButtons} ${styles.tabButtonsEnd}`,
152
+ role: "tablist",
153
+ "aria-label": header != null ? header : "Tabs",
154
+ children: visibleTabs.map((tab, index) => {
155
+ const selected = index === activeIndex;
156
+ const tabDomId = `${uid}-tab-${String(tab.id)}`;
157
+ const panelDomId = `${uid}-panel-${String(tab.id)}`;
158
+ return /* @__PURE__ */ jsxs("div", { className: `${styles.tab} ${selected ? styles.active : ""}`, children: [
159
+ /* @__PURE__ */ jsxs(
160
+ "button",
161
+ {
162
+ id: tabDomId,
163
+ type: "button",
164
+ className: styles.tabButton,
165
+ role: "tab",
166
+ "aria-selected": selected,
167
+ "aria-controls": panelDomId,
168
+ tabIndex: selected ? 0 : -1,
169
+ disabled: tab.disabled,
170
+ onClick: () => setValue(tab.id),
171
+ onKeyDown: (e) => onKeyDownTab(e, index),
172
+ children: [
173
+ tab.headerIcon ? /* @__PURE__ */ jsx("span", { className: styles.icon, children: tab.headerIcon }) : null,
174
+ /* @__PURE__ */ jsx("span", { className: styles.label, children: tab.header }),
175
+ tab.badge ? /* @__PURE__ */ jsx("span", { className: styles.badge, children: /* @__PURE__ */ jsx(Chip, { size: "sm", children: tab.badge.toLocaleString("da-DK") }) }) : null
176
+ ]
177
+ }
178
+ ),
179
+ tab.removable && onRemoveTab ? /* @__PURE__ */ jsx(
180
+ "button",
181
+ {
182
+ type: "button",
183
+ className: styles.removeTabButton,
184
+ "aria-label": `Fjern fane ${tab.header}`,
185
+ disabled: tab.disabled,
186
+ onClick: () => onRemoveTab(tab.id, tab, index),
187
+ children: /* @__PURE__ */ jsx(X, { "aria-hidden": "true" })
188
+ }
189
+ ) : null
190
+ ] }, tab.id);
191
+ })
192
+ }
193
+ ),
194
+ onAddTab ? /* @__PURE__ */ jsx(
195
+ "button",
196
+ {
197
+ type: "button",
198
+ className: styles.addTabButton,
199
+ onClick: onAddTab,
200
+ "aria-label": "Tilf\xF8j fane",
201
+ children: /* @__PURE__ */ jsx(Plus, { "aria-hidden": "true" })
202
+ }
203
+ ) : null
204
+ ] }),
203
205
  tabListAddition ? /* @__PURE__ */ jsx("div", { className: styles.tabListAddition, children: tabListAddition }) : null
204
206
  ] }),
205
207
  /* @__PURE__ */ jsx(
@@ -26,8 +26,18 @@
26
26
 
27
27
  /* Tablist */
28
28
  .tabList {
29
+ display: grid;
30
+ grid-template-columns: minmax(0, 1fr) auto;
31
+ grid-template-rows: auto var(--spacing-sm);
32
+ min-width: 0;
33
+ }
34
+
35
+ .tabStrip {
29
36
  display: flex;
37
+ grid-column: 1;
38
+ grid-row: 1 / span 2;
30
39
  min-width: 0;
40
+ align-self: end;
31
41
  }
32
42
 
33
43
  .tabButtons {
@@ -40,6 +50,12 @@
40
50
  here. */
41
51
  overflow-y: hidden;
42
52
  min-width: 0;
53
+ scrollbar-width: none;
54
+ -ms-overflow-style: none;
55
+ }
56
+
57
+ .tabButtons::-webkit-scrollbar {
58
+ display: none;
43
59
  }
44
60
 
45
61
  /* Extra content next to the tab buttons, pushed into the free space on the
@@ -48,6 +64,8 @@
48
64
  .tabListAddition {
49
65
  display: flex;
50
66
  align-items: start;
67
+ grid-column: 2;
68
+ grid-row: 1;
51
69
  flex-shrink: 0;
52
70
  gap: var(--spacing-sm);
53
71
  margin-inline-start: auto;
@@ -94,8 +112,6 @@
94
112
  border-color var(--transition-fast) var(--ease-standard);
95
113
  }
96
114
 
97
- .active .tabButton {
98
- }
99
115
  .tabButton:focus-visible {
100
116
  outline: none;
101
117
  box-shadow: var(--focus-ring);
@@ -236,37 +252,37 @@
236
252
  /* One continuous backdrop behind the whole button row, so the curved gap
237
253
  next to the active tab's rounded corners shows toolbar gray, not the
238
254
  surface color behind the row. */
239
- .filled > .tabList > .tabButtons {
255
+ .filled > .tabList > .tabStrip > .tabButtons {
240
256
  display: flex;
241
257
  background: var(--color-bg-toolbar);
242
258
  border-start-start-radius: var(--border-radius-md);
243
259
  }
244
260
 
245
- .filled > .tabList > .tabButtons > .tab > .tabButton {
261
+ .filled > .tabList > .tabStrip > .tabButtons > .tab > .tabButton {
246
262
  padding-block: var(--spacing-xs);
247
263
  }
248
264
 
249
- .filled > .tabList > .tabButtons > .tab > .tabButton .icon svg {
265
+ .filled > .tabList > .tabStrip > .tabButtons > .tab > .tabButton .icon svg {
250
266
  inline-size: var(--icon-size-sm);
251
267
  block-size: var(--icon-size-sm);
252
268
  }
253
269
 
254
- .filled > .tabList > .tabButtons.tabButtonsEnd {
270
+ .filled > .tabList > .tabStrip > .tabButtons.tabButtonsEnd {
255
271
  border-start-end-radius: var(--border-radius-md);
256
272
  }
257
273
 
258
- .filled > .tabList > .addTabButton {
274
+ .filled > .tabList > .tabStrip > .addTabButton {
259
275
  background: var(--color-bg-toolbar);
260
276
  border: 1px solid transparent;
261
277
  border-block-end: 0;
262
278
  border-start-end-radius: var(--border-radius-md);
263
279
  }
264
280
 
265
- .filled > .tabList > .addTabButton:hover {
281
+ .filled > .tabList > .tabStrip > .addTabButton:hover {
266
282
  background: var(--color-bg-toolbar-hover);
267
283
  }
268
284
 
269
- .filled > .tabList > .tabButtons > .tab {
285
+ .filled > .tabList > .tabStrip > .tabButtons > .tab {
270
286
  border: 1px solid transparent;
271
287
  border-block-end-width: 1px;
272
288
  margin-block-end: -1px;
@@ -278,14 +294,14 @@
278
294
  border-color var(--transition-fast) var(--ease-standard);
279
295
  }
280
296
 
281
- .filled > .tabList > .tabButtons > .tab:not(.active):hover {
297
+ .filled > .tabList > .tabStrip > .tabButtons > .tab:not(.active):hover {
282
298
  background: var(--color-bg-toolbar-hover);
283
299
  color: var(--color-fg-default);
284
300
  }
285
301
 
286
302
  /* Active tab physically overlaps the tabList separator by 1px so its
287
303
  erased bottom border seamlessly merges with the panel below. */
288
- .filled > .tabList > .tabButtons > .tab.active {
304
+ .filled > .tabList > .tabStrip > .tabButtons > .tab.active {
289
305
  background: var(--color-bg-surface);
290
306
  border-color: var(--color-border-subtle);
291
307
  border-block-end-color: var(--color-bg-surface);
@@ -295,7 +311,7 @@
295
311
  color: var(--color-fg-default);
296
312
  }
297
313
 
298
- .filled > .tabList > .tabButtons > .tab.active::after {
314
+ .filled > .tabList > .tabStrip > .tabButtons > .tab.active::after {
299
315
  content: '';
300
316
  position: absolute;
301
317
  inset-inline: -1px;
@@ -325,17 +341,17 @@
325
341
  padding-block-end: var(--spacing-xs);
326
342
  }
327
343
 
328
- .outlined > .tabList > .tabButtons > .tab {
344
+ .outlined > .tabList > .tabStrip > .tabButtons > .tab {
329
345
  color: var(--color-fg-muted);
330
346
  border-block-end: 2px solid var(--color-border-default);
331
347
  transition: color var(--transition-fast) var(--ease-standard);
332
348
  }
333
349
 
334
- .outlined > .tabList > .tabButtons > .tab:not(.active):hover {
350
+ .outlined > .tabList > .tabStrip > .tabButtons > .tab:not(.active):hover {
335
351
  color: var(--color-brand);
336
352
  }
337
353
 
338
- .outlined > .tabList > .tabButtons > .tab.active {
354
+ .outlined > .tabList > .tabStrip > .tabButtons > .tab.active {
339
355
  color: var(--color-brand);
340
356
  border-block-end-color: var(--color-brand);
341
357
  }
@@ -355,7 +371,7 @@
355
371
  }
356
372
 
357
373
  /* When panelStyle is on, tabs look “embedded” (no bottom border indicators) */
358
- .panelStyle > .tabList > .tabButtons > .tab {
374
+ .panelStyle > .tabList > .tabStrip > .tabButtons > .tab {
359
375
  border-block-end: 0;
360
376
  }
361
377
 
@@ -20,6 +20,7 @@ export interface TimelineItem {
20
20
  id?: string;
21
21
  label: ReactNode;
22
22
  content: ReactNode;
23
+ active?: boolean;
23
24
  collapsible?: boolean;
24
25
  severity?: Severity;
25
26
  icon?: ReactNode;
@@ -58,7 +58,7 @@ function TimelineRow({
58
58
  ] }),
59
59
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: styles__default.default.body, children: [
60
60
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `${styles__default.default.headerRow} ${hasContextMenu ? styles__default.default.headerRowWithActions : ""}`, children: [
61
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: styles__default.default.label, children: item.label }),
61
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: `${styles__default.default.label} ${item.active ? styles__default.default.labelActive : ""}`.trim(), children: item.label }),
62
62
  item.date !== void 0 ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: styles__default.default.date, children: formatDate.formatDate(item.date, { userFriendlyLabel: true, ...item.dateOptions }) }) : null,
63
63
  isCollapsible ? /* @__PURE__ */ jsxRuntime.jsx(
64
64
  "button",
@@ -52,7 +52,7 @@ function TimelineRow({
52
52
  ] }),
53
53
  /* @__PURE__ */ jsxs("div", { className: styles.body, children: [
54
54
  /* @__PURE__ */ jsxs("div", { className: `${styles.headerRow} ${hasContextMenu ? styles.headerRowWithActions : ""}`, children: [
55
- /* @__PURE__ */ jsx("div", { className: styles.label, children: item.label }),
55
+ /* @__PURE__ */ jsx("div", { className: `${styles.label} ${item.active ? styles.labelActive : ""}`.trim(), children: item.label }),
56
56
  item.date !== void 0 ? /* @__PURE__ */ jsx("span", { className: styles.date, children: formatDate(item.date, { userFriendlyLabel: true, ...item.dateOptions }) }) : null,
57
57
  isCollapsible ? /* @__PURE__ */ jsx(
58
58
  "button",
@@ -73,6 +73,10 @@
73
73
  min-width: 0;
74
74
  }
75
75
 
76
+ .labelActive {
77
+ color: var(--color-fg-default);
78
+ }
79
+
76
80
  .date {
77
81
  font-size: var(--font-size-xs);
78
82
  font-weight: 400;
@@ -13,6 +13,7 @@ var styles__default = /*#__PURE__*/_interopDefault(styles);
13
13
  function TreeNodeRow({
14
14
  node,
15
15
  depth,
16
+ wrapLabels,
16
17
  isExpanded,
17
18
  toggle,
18
19
  resolvedChildren,
@@ -66,7 +67,13 @@ function TreeNodeRow({
66
67
  ),
67
68
  /* @__PURE__ */ jsxRuntime.jsxs("button", { type: "button", className: styles__default.default.labelButton, onClick: () => onSelectNode == null ? void 0 : onSelectNode(node), children: [
68
69
  node.icon ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: styles__default.default.icon, "aria-hidden": "true", children: node.icon }) : null,
69
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: styles__default.default.label, children: renderLabel ? renderLabel(node) : node.label })
70
+ /* @__PURE__ */ jsxRuntime.jsx(
71
+ "span",
72
+ {
73
+ className: [styles__default.default.label, wrapLabels ? styles__default.default.labelWrap : styles__default.default.labelTruncate].filter(Boolean).join(" "),
74
+ children: renderLabel ? renderLabel(node) : node.label
75
+ }
76
+ )
70
77
  ] })
71
78
  ] }),
72
79
  error ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: styles__default.default.errorRow, children: [
@@ -78,6 +85,7 @@ function TreeNodeRow({
78
85
  {
79
86
  node: child,
80
87
  depth: depth + 1,
88
+ wrapLabels,
81
89
  isExpanded,
82
90
  toggle,
83
91
  resolvedChildren,
@@ -3,6 +3,7 @@ import type { LoadTreeChildren, TreeNode } from './types';
3
3
  type TreeNodeRowProps<T> = {
4
4
  node: TreeNode<T>;
5
5
  depth: number;
6
+ wrapLabels: boolean;
6
7
  isExpanded: (id: string) => boolean;
7
8
  toggle: (id: string) => void;
8
9
  resolvedChildren: Record<string, TreeNode<T>[]>;
@@ -14,5 +15,5 @@ type TreeNodeRowProps<T> = {
14
15
  onSelectNode?: (node: TreeNode<T>) => void;
15
16
  renderLabel?: (node: TreeNode<T>) => ReactNode;
16
17
  };
17
- export declare function TreeNodeRow<T>({ node, depth, isExpanded, toggle, resolvedChildren, loadingIds, errorIds, requestLoad, loadChildren, selectedId, onSelectNode, renderLabel, }: TreeNodeRowProps<T>): JSX.Element;
18
+ export declare function TreeNodeRow<T>({ node, depth, wrapLabels, isExpanded, toggle, resolvedChildren, loadingIds, errorIds, requestLoad, loadChildren, selectedId, onSelectNode, renderLabel, }: TreeNodeRowProps<T>): JSX.Element;
18
19
  export {};
@@ -7,6 +7,7 @@ import styles from './TreeView.module.css';
7
7
  function TreeNodeRow({
8
8
  node,
9
9
  depth,
10
+ wrapLabels,
10
11
  isExpanded,
11
12
  toggle,
12
13
  resolvedChildren,
@@ -60,7 +61,13 @@ function TreeNodeRow({
60
61
  ),
61
62
  /* @__PURE__ */ jsxs("button", { type: "button", className: styles.labelButton, onClick: () => onSelectNode == null ? void 0 : onSelectNode(node), children: [
62
63
  node.icon ? /* @__PURE__ */ jsx("span", { className: styles.icon, "aria-hidden": "true", children: node.icon }) : null,
63
- /* @__PURE__ */ jsx("span", { className: styles.label, children: renderLabel ? renderLabel(node) : node.label })
64
+ /* @__PURE__ */ jsx(
65
+ "span",
66
+ {
67
+ className: [styles.label, wrapLabels ? styles.labelWrap : styles.labelTruncate].filter(Boolean).join(" "),
68
+ children: renderLabel ? renderLabel(node) : node.label
69
+ }
70
+ )
64
71
  ] })
65
72
  ] }),
66
73
  error ? /* @__PURE__ */ jsxs("div", { className: styles.errorRow, children: [
@@ -72,6 +79,7 @@ function TreeNodeRow({
72
79
  {
73
80
  node: child,
74
81
  depth: depth + 1,
82
+ wrapLabels,
75
83
  isExpanded,
76
84
  toggle,
77
85
  resolvedChildren,
@@ -21,6 +21,7 @@ function TreeView({
21
21
  selectedId,
22
22
  onSelectNode,
23
23
  renderLabel,
24
+ wrapLabels = true,
24
25
  emptyMessage = "Intet at vise.",
25
26
  loadErrorMessage = () => "Der skete en fejl under indl\xE6sning.",
26
27
  className,
@@ -67,6 +68,7 @@ function TreeView({
67
68
  {
68
69
  node,
69
70
  depth: 0,
71
+ wrapLabels,
70
72
  isExpanded,
71
73
  toggle,
72
74
  resolvedChildren,
@@ -17,4 +17,4 @@ export { collectExpandableIds, findAncestorIds } from './utils';
17
17
  * useTreeExpansion), and it can be left uncontrolled or owned by the
18
18
  * caller via `expandedIds`/`onExpandedIdsChange`.
19
19
  */
20
- export declare function TreeView<T = unknown>({ data, loadChildren, defaultExpandedIds, expandedIds, onExpandedIdsChange, selectedId, onSelectNode, renderLabel, emptyMessage, loadErrorMessage, className, ...rest }: TreeViewProps<T>): JSX.Element;
20
+ export declare function TreeView<T = unknown>({ data, loadChildren, defaultExpandedIds, expandedIds, onExpandedIdsChange, selectedId, onSelectNode, renderLabel, wrapLabels, emptyMessage, loadErrorMessage, className, ...rest }: TreeViewProps<T>): JSX.Element;
@@ -15,6 +15,7 @@ function TreeView({
15
15
  selectedId,
16
16
  onSelectNode,
17
17
  renderLabel,
18
+ wrapLabels = true,
18
19
  emptyMessage = "Intet at vise.",
19
20
  loadErrorMessage = () => "Der skete en fejl under indl\xE6sning.",
20
21
  className,
@@ -61,6 +62,7 @@ function TreeView({
61
62
  {
62
63
  node,
63
64
  depth: 0,
65
+ wrapLabels,
64
66
  isExpanded,
65
67
  toggle,
66
68
  resolvedChildren,
@@ -108,6 +108,14 @@
108
108
 
109
109
  .label {
110
110
  min-inline-size: 0;
111
+ }
112
+
113
+ .labelWrap {
114
+ overflow-wrap: anywhere;
115
+ white-space: normal;
116
+ }
117
+
118
+ .labelTruncate {
111
119
  overflow: hidden;
112
120
  text-overflow: ellipsis;
113
121
  white-space: nowrap;
@@ -36,6 +36,8 @@ export type TreeViewProps<T = unknown> = {
36
36
  onSelectNode?: (node: TreeNode<T>) => void;
37
37
  /** Customize how a node's row content renders; defaults to `node.icon` + `node.label`. */
38
38
  renderLabel?: (node: TreeNode<T>) => ReactNode;
39
+ /** Allows node labels to wrap onto multiple lines. Set to false to truncate them to one line. */
40
+ wrapLabels?: boolean;
39
41
  emptyMessage?: ReactNode;
40
42
  /** Formats the error shown under a node whose `loadChildren` call rejected. */
41
43
  loadErrorMessage?: (error: unknown, node: TreeNode<T>) => ReactNode;
@@ -38,10 +38,20 @@ function useTreeExpansion(defaultExpandedIds = [], controlledIds, onChange) {
38
38
  (id) => expandedIds.has(id) ? collapse(id) : expand(id),
39
39
  [expandedIds, expand, collapse]
40
40
  );
41
- const expandAll = react.useCallback((ids) => commit(new Set(ids)), [commit]);
41
+ const setExpandedIds = react.useCallback((ids) => commit(new Set(ids)), [commit]);
42
+ const expandAll = react.useCallback((ids) => setExpandedIds(ids), [setExpandedIds]);
42
43
  const collapseAll = react.useCallback(() => commit(/* @__PURE__ */ new Set()), [commit]);
43
44
  const isExpanded = react.useCallback((id) => expandedIds.has(id), [expandedIds]);
44
- return { expandedIds, expand, collapse, toggle, expandAll, collapseAll, isExpanded };
45
+ return {
46
+ expandedIds,
47
+ setExpandedIds,
48
+ expand,
49
+ collapse,
50
+ toggle,
51
+ expandAll,
52
+ collapseAll,
53
+ isExpanded
54
+ };
45
55
  }
46
56
 
47
57
  exports.useTreeExpansion = useTreeExpansion;
@@ -8,6 +8,7 @@
8
8
  */
9
9
  export declare function useTreeExpansion(defaultExpandedIds?: string[], controlledIds?: string[], onChange?: (ids: string[]) => void): {
10
10
  expandedIds: Set<string>;
11
+ setExpandedIds: (ids: string[]) => void;
11
12
  expand: (id: string) => void;
12
13
  collapse: (id: string) => void;
13
14
  toggle: (id: string) => void;
@@ -36,10 +36,20 @@ function useTreeExpansion(defaultExpandedIds = [], controlledIds, onChange) {
36
36
  (id) => expandedIds.has(id) ? collapse(id) : expand(id),
37
37
  [expandedIds, expand, collapse]
38
38
  );
39
- const expandAll = useCallback((ids) => commit(new Set(ids)), [commit]);
39
+ const setExpandedIds = useCallback((ids) => commit(new Set(ids)), [commit]);
40
+ const expandAll = useCallback((ids) => setExpandedIds(ids), [setExpandedIds]);
40
41
  const collapseAll = useCallback(() => commit(/* @__PURE__ */ new Set()), [commit]);
41
42
  const isExpanded = useCallback((id) => expandedIds.has(id), [expandedIds]);
42
- return { expandedIds, expand, collapse, toggle, expandAll, collapseAll, isExpanded };
43
+ return {
44
+ expandedIds,
45
+ setExpandedIds,
46
+ expand,
47
+ collapse,
48
+ toggle,
49
+ expandAll,
50
+ collapseAll,
51
+ isExpanded
52
+ };
43
53
  }
44
54
 
45
55
  export { useTreeExpansion };