@helpwave/hightide 0.1.27 → 0.1.28

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 (134) hide show
  1. package/dist/coloring/index.d.mts +2 -0
  2. package/dist/coloring/index.d.ts +2 -0
  3. package/dist/coloring/index.js +85 -0
  4. package/dist/coloring/index.js.map +1 -0
  5. package/dist/coloring/index.mjs +48 -0
  6. package/dist/coloring/index.mjs.map +1 -0
  7. package/dist/components/branding/index.d.mts +3 -0
  8. package/dist/components/branding/index.d.ts +3 -0
  9. package/dist/components/branding/index.js +140 -0
  10. package/dist/components/branding/index.js.map +1 -0
  11. package/dist/components/branding/index.mjs +104 -0
  12. package/dist/components/branding/index.mjs.map +1 -0
  13. package/dist/components/date/index.d.mts +10 -0
  14. package/dist/components/date/index.d.ts +10 -0
  15. package/dist/components/date/index.js +1168 -0
  16. package/dist/components/date/index.js.map +1 -0
  17. package/dist/components/date/index.mjs +1124 -0
  18. package/dist/components/date/index.mjs.map +1 -0
  19. package/dist/components/dialog/index.js.map +1 -1
  20. package/dist/components/form/index.d.mts +5 -0
  21. package/dist/components/form/index.d.ts +5 -0
  22. package/dist/components/form/index.js +100 -0
  23. package/dist/components/form/index.js.map +1 -0
  24. package/dist/components/form/index.mjs +64 -0
  25. package/dist/components/form/index.mjs.map +1 -0
  26. package/dist/components/icons-and-geometry/index.d.mts +7 -0
  27. package/dist/components/icons-and-geometry/index.d.ts +7 -0
  28. package/dist/components/icons-and-geometry/index.js +3955 -0
  29. package/dist/components/icons-and-geometry/index.js.map +1 -0
  30. package/dist/components/icons-and-geometry/index.mjs +3939 -0
  31. package/dist/components/icons-and-geometry/index.mjs.map +1 -0
  32. package/dist/components/index.d.mts +83 -0
  33. package/dist/components/index.d.ts +83 -0
  34. package/dist/components/index.js +15471 -0
  35. package/dist/components/index.js.map +1 -0
  36. package/dist/components/index.mjs +15377 -0
  37. package/dist/components/index.mjs.map +1 -0
  38. package/dist/components/layout/index.d.mts +18 -0
  39. package/dist/components/layout/index.d.ts +18 -0
  40. package/dist/components/layout/index.js +3111 -0
  41. package/dist/components/layout/index.js.map +1 -0
  42. package/dist/components/layout/index.mjs +3064 -0
  43. package/dist/components/layout/index.mjs.map +1 -0
  44. package/dist/components/loading-states/index.d.mts +12 -0
  45. package/dist/components/loading-states/index.d.ts +12 -0
  46. package/dist/components/loading-states/index.js +614 -0
  47. package/dist/components/loading-states/index.js.map +1 -0
  48. package/dist/components/loading-states/index.mjs +573 -0
  49. package/dist/components/loading-states/index.mjs.map +1 -0
  50. package/dist/components/navigation/index.d.mts +9 -0
  51. package/dist/components/navigation/index.d.ts +9 -0
  52. package/dist/components/navigation/index.js +4660 -0
  53. package/dist/components/navigation/index.js.map +1 -0
  54. package/dist/components/navigation/index.mjs +4648 -0
  55. package/dist/components/navigation/index.mjs.map +1 -0
  56. package/dist/components/properties/index.d.mts +12 -0
  57. package/dist/components/properties/index.d.ts +12 -0
  58. package/dist/components/properties/index.js +2983 -0
  59. package/dist/components/properties/index.js.map +1 -0
  60. package/dist/components/properties/index.mjs +2951 -0
  61. package/dist/components/properties/index.mjs.map +1 -0
  62. package/dist/components/table/index.d.mts +10 -0
  63. package/dist/components/table/index.d.ts +10 -0
  64. package/dist/components/table/index.js +2329 -0
  65. package/dist/components/table/index.js.map +1 -0
  66. package/dist/components/table/index.mjs +2293 -0
  67. package/dist/components/table/index.mjs.map +1 -0
  68. package/dist/components/user-action/index.d.mts +30 -0
  69. package/dist/components/user-action/index.d.ts +30 -0
  70. package/dist/components/user-action/index.js +4257 -0
  71. package/dist/components/user-action/index.js.map +1 -0
  72. package/dist/components/user-action/index.mjs +4195 -0
  73. package/dist/components/user-action/index.mjs.map +1 -0
  74. package/dist/components/user-action/input/index.d.mts +6 -0
  75. package/dist/components/user-action/input/index.d.ts +6 -0
  76. package/dist/components/user-action/input/index.js +398 -0
  77. package/dist/components/user-action/input/index.js.map +1 -0
  78. package/dist/components/user-action/input/index.mjs +357 -0
  79. package/dist/components/user-action/input/index.mjs.map +1 -0
  80. package/dist/components/user-action/select/index.d.mts +4 -0
  81. package/dist/components/user-action/select/index.d.ts +4 -0
  82. package/dist/components/user-action/select/index.js +1369 -0
  83. package/dist/components/user-action/select/index.js.map +1 -0
  84. package/dist/components/user-action/select/index.mjs +1333 -0
  85. package/dist/components/user-action/select/index.mjs.map +1 -0
  86. package/dist/components/utils/index.d.mts +4 -0
  87. package/dist/components/utils/index.d.ts +4 -0
  88. package/dist/components/utils/index.js +302 -0
  89. package/dist/components/utils/index.js.map +1 -0
  90. package/dist/components/utils/index.mjs +275 -0
  91. package/dist/components/utils/index.mjs.map +1 -0
  92. package/dist/hooks/focus/index.d.mts +6 -0
  93. package/dist/hooks/focus/index.d.ts +6 -0
  94. package/dist/hooks/focus/index.js +379 -0
  95. package/dist/hooks/focus/index.js.map +1 -0
  96. package/dist/hooks/focus/index.mjs +339 -0
  97. package/dist/hooks/focus/index.mjs.map +1 -0
  98. package/dist/hooks/index.d.mts +16 -0
  99. package/dist/hooks/index.d.ts +16 -0
  100. package/dist/hooks/index.js +844 -0
  101. package/dist/hooks/index.js.map +1 -0
  102. package/dist/hooks/index.mjs +794 -0
  103. package/dist/hooks/index.mjs.map +1 -0
  104. package/dist/index.d.mts +110 -0
  105. package/dist/index.d.ts +110 -0
  106. package/dist/index.js +16101 -0
  107. package/dist/index.js.map +1 -0
  108. package/dist/index.mjs +15941 -0
  109. package/dist/index.mjs.map +1 -0
  110. package/dist/localization/defaults/index.d.mts +4 -0
  111. package/dist/localization/defaults/index.d.ts +4 -0
  112. package/dist/localization/defaults/index.js +223 -0
  113. package/dist/localization/defaults/index.js.map +1 -0
  114. package/dist/localization/defaults/index.mjs +195 -0
  115. package/dist/localization/defaults/index.mjs.map +1 -0
  116. package/dist/localization/index.d.mts +7 -0
  117. package/dist/localization/index.d.ts +7 -0
  118. package/dist/localization/index.js +415 -0
  119. package/dist/localization/index.js.map +1 -0
  120. package/dist/localization/index.mjs +380 -0
  121. package/dist/localization/index.mjs.map +1 -0
  122. package/dist/theming/index.d.mts +5 -0
  123. package/dist/theming/index.d.ts +5 -0
  124. package/dist/theming/index.js +174 -0
  125. package/dist/theming/index.js.map +1 -0
  126. package/dist/theming/index.mjs +145 -0
  127. package/dist/theming/index.mjs.map +1 -0
  128. package/dist/utils/index.d.mts +15 -0
  129. package/dist/utils/index.d.ts +15 -0
  130. package/dist/utils/index.js +553 -0
  131. package/dist/utils/index.js.map +1 -0
  132. package/dist/utils/index.mjs +493 -0
  133. package/dist/utils/index.mjs.map +1 -0
  134. package/package.json +25 -24
@@ -0,0 +1,1333 @@
1
+ // src/components/user-action/select/Select.tsx
2
+ import {
3
+ createContext as createContext2,
4
+ forwardRef as forwardRef3,
5
+ useCallback as useCallback5,
6
+ useContext as useContext2,
7
+ useEffect as useEffect6,
8
+ useId as useId3,
9
+ useImperativeHandle,
10
+ useRef as useRef2,
11
+ useState as useState7
12
+ } from "react";
13
+ import clsx4 from "clsx";
14
+
15
+ // src/localization/LanguageProvider.tsx
16
+ import { createContext, useContext, useEffect, useState as useState2 } from "react";
17
+
18
+ // src/hooks/useLocalStorage.ts
19
+ import { useCallback, useState } from "react";
20
+
21
+ // src/localization/util.ts
22
+ var languages = ["en", "de"];
23
+ var languagesLocalNames = {
24
+ en: "English",
25
+ de: "Deutsch"
26
+ };
27
+ var DEFAULT_LANGUAGE = "en";
28
+ var LanguageUtil = {
29
+ languages,
30
+ DEFAULT_LANGUAGE,
31
+ languagesLocalNames
32
+ };
33
+
34
+ // src/localization/LanguageProvider.tsx
35
+ import { jsx } from "react/jsx-runtime";
36
+ var LanguageContext = createContext({
37
+ language: LanguageUtil.DEFAULT_LANGUAGE,
38
+ setLanguage: (v) => v
39
+ });
40
+ var useLanguage = () => useContext(LanguageContext);
41
+
42
+ // src/localization/useTranslation.ts
43
+ var TranslationPluralCount = {
44
+ zero: 0,
45
+ one: 1,
46
+ two: 2,
47
+ few: 3,
48
+ many: 11,
49
+ other: -1
50
+ };
51
+ var useTranslation = (translations, overwriteTranslation = {}) => {
52
+ const { language: languageProp, translation: overwrite } = overwriteTranslation;
53
+ const { language: inferredLanguage } = useLanguage();
54
+ const usedLanguage = languageProp ?? inferredLanguage;
55
+ const usedTranslations = [...translations];
56
+ if (overwrite) {
57
+ usedTranslations.push(overwrite);
58
+ }
59
+ return (key, options) => {
60
+ const { count, replacements } = { ...{ count: 0, replacements: {} }, ...options };
61
+ try {
62
+ for (let i = translations.length - 1; i >= 0; i--) {
63
+ const translation = translations[i];
64
+ const localizedTranslation = translation[usedLanguage];
65
+ if (!localizedTranslation) {
66
+ continue;
67
+ }
68
+ const value = localizedTranslation[key];
69
+ if (!value) {
70
+ continue;
71
+ }
72
+ let forProcessing;
73
+ if (typeof value !== "string") {
74
+ if (count === TranslationPluralCount.zero && value?.zero) {
75
+ forProcessing = value.zero;
76
+ } else if (count === TranslationPluralCount.one && value?.one) {
77
+ forProcessing = value.one;
78
+ } else if (count === TranslationPluralCount.two && value?.two) {
79
+ forProcessing = value.two;
80
+ } else if (TranslationPluralCount.few <= count && count < TranslationPluralCount.many && value?.few) {
81
+ forProcessing = value.few;
82
+ } else if (count > TranslationPluralCount.many && value?.many) {
83
+ forProcessing = value.many;
84
+ } else {
85
+ forProcessing = value.other;
86
+ }
87
+ } else {
88
+ forProcessing = value;
89
+ }
90
+ forProcessing = forProcessing.replace(/\{\{(\w+)}}/g, (_, placeholder) => {
91
+ return replacements[placeholder] ?? `{{key:${placeholder}}}`;
92
+ });
93
+ return forProcessing;
94
+ }
95
+ } catch (e) {
96
+ console.error(e);
97
+ }
98
+ return `{{${usedLanguage}:${key}}}`;
99
+ };
100
+ };
101
+
102
+ // src/components/layout/Expandable.tsx
103
+ import { forwardRef, useCallback as useCallback2, useEffect as useEffect2, useId, useState as useState3 } from "react";
104
+ import { ChevronDown } from "lucide-react";
105
+ import clsx from "clsx";
106
+
107
+ // src/utils/noop.ts
108
+ var noop = () => void 0;
109
+
110
+ // src/components/layout/Expandable.tsx
111
+ import { jsx as jsx2, jsxs } from "react/jsx-runtime";
112
+ var ExpansionIcon = ({ isExpanded, className }) => {
113
+ return /* @__PURE__ */ jsx2(
114
+ ChevronDown,
115
+ {
116
+ "aria-hidden": true,
117
+ className: clsx(
118
+ "min-w-6 w-6 min-h-6 h-6 transition-transform motion-safe:duration-200 motion-reduce:duration-0 ease-in-out",
119
+ { "rotate-180": isExpanded },
120
+ className
121
+ )
122
+ }
123
+ );
124
+ };
125
+ var Expandable = forwardRef(function Expandable2({
126
+ children,
127
+ id: providedId,
128
+ label,
129
+ icon,
130
+ isExpanded = false,
131
+ onChange = noop,
132
+ clickOnlyOnHeader = true,
133
+ disabled = false,
134
+ className,
135
+ headerClassName,
136
+ contentClassName,
137
+ contentExpandedClassName
138
+ }, ref) {
139
+ const defaultIcon = useCallback2((expanded) => /* @__PURE__ */ jsx2(ExpansionIcon, { isExpanded: expanded }), []);
140
+ icon ??= defaultIcon;
141
+ const generatedId = useId();
142
+ const id = providedId ?? generatedId;
143
+ return /* @__PURE__ */ jsxs(
144
+ "div",
145
+ {
146
+ ref,
147
+ onClick: () => !clickOnlyOnHeader && !disabled && onChange(!isExpanded),
148
+ className: clsx(
149
+ "flex-col-0 bg-surface text-on-surface group rounded-lg shadow-sm",
150
+ { "cursor-pointer": !clickOnlyOnHeader && !disabled },
151
+ className
152
+ ),
153
+ children: [
154
+ /* @__PURE__ */ jsxs(
155
+ "button",
156
+ {
157
+ onClick: () => clickOnlyOnHeader && !disabled && onChange(!isExpanded),
158
+ className: clsx(
159
+ "flex-row-2 py-2 px-4 rounded-lg justify-between items-center bg-surface text-on-surface select-none",
160
+ {
161
+ "group-hover:brightness-97": !isExpanded,
162
+ "hover:brightness-97": isExpanded && !disabled,
163
+ "cursor-pointer": clickOnlyOnHeader && !disabled
164
+ },
165
+ headerClassName
166
+ ),
167
+ "aria-expanded": isExpanded,
168
+ "aria-controls": `${id}-content`,
169
+ "aria-disabled": disabled ?? void 0,
170
+ children: [
171
+ label,
172
+ icon(isExpanded)
173
+ ]
174
+ }
175
+ ),
176
+ /* @__PURE__ */ jsx2(
177
+ "div",
178
+ {
179
+ id: `${id}-content`,
180
+ className: clsx(
181
+ "flex-col-2 px-4 transition-all duration-300 ease-in-out",
182
+ {
183
+ [clsx("max-h-96 opacity-100 pb-2 overflow-y-auto", contentExpandedClassName)]: isExpanded,
184
+ "max-h-0 opacity-0 overflow-hidden": !isExpanded
185
+ },
186
+ contentClassName
187
+ ),
188
+ role: "region",
189
+ children
190
+ }
191
+ )
192
+ ]
193
+ }
194
+ );
195
+ });
196
+ var ExpandableUncontrolled = forwardRef(function ExpandableUncontrolled2({
197
+ isExpanded,
198
+ onChange = noop,
199
+ ...props
200
+ }, ref) {
201
+ const [usedIsExpanded, setUsedIsExpanded] = useState3(isExpanded);
202
+ useEffect2(() => {
203
+ setUsedIsExpanded(isExpanded);
204
+ }, [isExpanded]);
205
+ return /* @__PURE__ */ jsx2(
206
+ Expandable,
207
+ {
208
+ ...props,
209
+ ref,
210
+ isExpanded: usedIsExpanded,
211
+ onChange: (value) => {
212
+ onChange(value);
213
+ setUsedIsExpanded(value);
214
+ }
215
+ }
216
+ );
217
+ });
218
+
219
+ // src/hooks/focus/useFocusTrap.ts
220
+ import { useCallback as useCallback3, useEffect as useEffect4, useId as useId2, useRef, useState as useState5 } from "react";
221
+
222
+ // src/hooks/focus/useIsMounted.ts
223
+ import { useEffect as useEffect3, useLayoutEffect, useState as useState4 } from "react";
224
+ var isClient = typeof window !== "undefined" && typeof document !== "undefined";
225
+ var useIsomorphicEffect = isClient ? useLayoutEffect : useEffect3;
226
+ var useIsMounted = () => {
227
+ const [isMounted, setIsMounted] = useState4(false);
228
+ useIsomorphicEffect(() => {
229
+ setIsMounted(true);
230
+ return () => {
231
+ setIsMounted(false);
232
+ };
233
+ }, []);
234
+ return isMounted;
235
+ };
236
+
237
+ // src/hooks/focus/useFocusTrap.ts
238
+ var createFocusGuard = () => {
239
+ const div = document.createElement("div");
240
+ Object.assign(div.style, {
241
+ opacity: "0",
242
+ outline: "none",
243
+ boxShadow: "none",
244
+ position: "fixed",
245
+ pointerEvents: "none",
246
+ touchAction: "none"
247
+ });
248
+ div.tabIndex = 0;
249
+ div.setAttribute("data-hw-focus-guard", "");
250
+ document.body.appendChild(div);
251
+ return div;
252
+ };
253
+ function getContainedFocusableElements(element) {
254
+ return element?.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');
255
+ }
256
+ var FocusTrapService = class {
257
+ constructor() {
258
+ // The last entry is always the active one
259
+ this.listeners = [];
260
+ this.onFocusIn = (event) => {
261
+ const active = this.getActive();
262
+ if (!active || !active.container.current) return;
263
+ const { container } = active;
264
+ if (!container.current.contains(event.target)) {
265
+ this.focusElement();
266
+ }
267
+ };
268
+ }
269
+ getActive() {
270
+ if (this.listeners.length === 0) return void 0;
271
+ return this.listeners[this.listeners.length - 1];
272
+ }
273
+ focusElement() {
274
+ const active = this.getActive();
275
+ if (!active) return;
276
+ const { container, initialFocusElement } = active;
277
+ const containerElement = container.current;
278
+ if (initialFocusElement?.current) {
279
+ initialFocusElement.current.focus();
280
+ } else {
281
+ const elements = getContainedFocusableElements(containerElement);
282
+ if (elements && elements.length > 0) {
283
+ const first = elements.item(0);
284
+ first.focus();
285
+ } else {
286
+ containerElement.focus();
287
+ }
288
+ }
289
+ }
290
+ removeGuards() {
291
+ document.querySelectorAll("[data-hw-focus-guard]").forEach((node) => node.remove());
292
+ }
293
+ addGuards() {
294
+ document.body.insertAdjacentElement("afterbegin", createFocusGuard());
295
+ document.body.insertAdjacentElement("beforeend", createFocusGuard());
296
+ }
297
+ activate() {
298
+ document.addEventListener("focusin", this.onFocusIn);
299
+ this.addGuards();
300
+ }
301
+ deactivate() {
302
+ document.removeEventListener("focusin", this.onFocusIn);
303
+ this.removeGuards();
304
+ }
305
+ register(listener) {
306
+ this.listeners.push(listener);
307
+ if (this.listeners.length === 1) {
308
+ this.activate();
309
+ }
310
+ const active = listener;
311
+ this.listeners.forEach((listener2) => {
312
+ const { focus, pause } = listener2;
313
+ if (listener2 === active) {
314
+ focus();
315
+ } else {
316
+ pause();
317
+ }
318
+ });
319
+ }
320
+ unregister(id) {
321
+ const index = this.listeners.findIndex((trap) => trap.id === id);
322
+ if (index !== -1) {
323
+ const isActive = index === this.listeners.length - 1;
324
+ const listener = this.listeners[index];
325
+ this.listeners = this.listeners.filter((listener2) => listener2.id !== id);
326
+ if (isActive) {
327
+ this.deactivate();
328
+ listener.focusLast();
329
+ const active = this.getActive();
330
+ this.listeners.forEach((listener2) => {
331
+ const { pause, unpause } = listener2;
332
+ if (listener2 === active) {
333
+ unpause();
334
+ } else {
335
+ pause();
336
+ }
337
+ });
338
+ if (this.listeners.length > 0) {
339
+ this.activate();
340
+ }
341
+ }
342
+ } else {
343
+ console.warn(`Unable to unregister id ${id}: not found`);
344
+ }
345
+ }
346
+ };
347
+ var service = new FocusTrapService();
348
+ var useFocusTrap = ({
349
+ container,
350
+ active = true,
351
+ initialFocus,
352
+ focusFirst = true
353
+ }) => {
354
+ const lastFocusRef = useRef(null);
355
+ const [paused, setPaused] = useState5(false);
356
+ const isMounted = useIsMounted();
357
+ const id = useId2();
358
+ const focusElement = useCallback3(() => {
359
+ const containerElement = container.current;
360
+ if (initialFocus?.current) {
361
+ initialFocus.current.focus();
362
+ } else {
363
+ const elements = getContainedFocusableElements(containerElement);
364
+ if (elements && elements.length > 0) {
365
+ const first = elements.item(0);
366
+ first.focus();
367
+ } else {
368
+ containerElement.focus();
369
+ }
370
+ }
371
+ }, [container, initialFocus]);
372
+ useEffect4(() => {
373
+ if (active && isMounted) {
374
+ let pause = function() {
375
+ setPaused(true);
376
+ }, unpause = function() {
377
+ setPaused(false);
378
+ if (!container.current.contains(document.activeElement)) {
379
+ focusElement();
380
+ }
381
+ }, focus = function() {
382
+ focusElement();
383
+ setPaused(false);
384
+ }, focusLast = function() {
385
+ lastFocusRef.current?.focus();
386
+ };
387
+ if (!lastFocusRef.current) {
388
+ lastFocusRef.current = document.activeElement;
389
+ }
390
+ service.register({ id, pause, focus, focusLast, unpause, container, initialFocusElement: initialFocus });
391
+ return () => {
392
+ service.unregister(id);
393
+ lastFocusRef.current = void 0;
394
+ };
395
+ }
396
+ }, [active, container, focusElement, id, initialFocus, isMounted]);
397
+ useEffect4(() => {
398
+ if (active && !paused && isMounted) {
399
+ let onKeyDown = function(event) {
400
+ const key = event.key;
401
+ const elements = getContainedFocusableElements(containerElement);
402
+ const active2 = document.activeElement;
403
+ const index = [...elements].findIndex((value) => value === active2);
404
+ if (index === -1 || event.altKey || event.ctrlKey || event.metaKey) {
405
+ return;
406
+ }
407
+ if (key === "Tab") {
408
+ const next = event.shiftKey ? -1 : 1;
409
+ const nextIndex = (index + next + elements.length) % elements.length;
410
+ const nextElement = elements[nextIndex];
411
+ nextElement.focus();
412
+ event.preventDefault();
413
+ }
414
+ };
415
+ const containerElement = container.current;
416
+ containerElement.addEventListener("keydown", onKeyDown);
417
+ return () => {
418
+ containerElement.removeEventListener("keydown", onKeyDown);
419
+ };
420
+ }
421
+ }, [active, paused, isMounted, container, initialFocus, focusFirst, focusElement]);
422
+ };
423
+
424
+ // src/utils/match.ts
425
+ var match = (key, values) => {
426
+ return values[key];
427
+ };
428
+
429
+ // src/components/user-action/select/Select.tsx
430
+ import { CheckIcon, Plus, XIcon } from "lucide-react";
431
+
432
+ // src/components/layout/Chip.tsx
433
+ import clsx2 from "clsx";
434
+ import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
435
+ var Chip = ({
436
+ children,
437
+ trailingIcon,
438
+ color = "default",
439
+ size = "md",
440
+ icon = false,
441
+ variant = "normal",
442
+ className = "",
443
+ ...restProps
444
+ }) => {
445
+ const colorMapping = {
446
+ default: "text-tag-default-text bg-tag-default-background",
447
+ dark: "text-tag-dark-text bg-tag-dark-background",
448
+ red: "text-tag-red-text bg-tag-red-background",
449
+ yellow: "text-tag-yellow-text bg-tag-yellow-background",
450
+ green: "text-tag-green-text bg-tag-green-background",
451
+ blue: "text-tag-blue-text bg-tag-blue-background",
452
+ pink: "text-tag-pink-text bg-tag-pink-background",
453
+ orange: "text-tag-orange-text bg-tag-orange-background"
454
+ }[color];
455
+ const colorMappingIcon = {
456
+ default: "text-tag-default-icon",
457
+ dark: "text-tag-dark-icon",
458
+ red: "text-tag-red-icon",
459
+ yellow: "text-tag-yellow-icon",
460
+ green: "text-tag-green-icon",
461
+ blue: "text-tag-blue-icon",
462
+ pink: "text-tag-pink-icon",
463
+ orange: "text-tag-orange-icon"
464
+ }[color];
465
+ return /* @__PURE__ */ jsxs2(
466
+ "div",
467
+ {
468
+ ...restProps,
469
+ className: clsx2(
470
+ `flex-row-0 w-fit font-semibold`,
471
+ colorMapping,
472
+ !icon ? {
473
+ "px-1 py-0.5": size === "sm",
474
+ "px-2 py-1": size === "md",
475
+ "px-4 py-2": size === "lg"
476
+ } : {
477
+ "p-0.5": size === "sm",
478
+ "p-1": size === "md",
479
+ "p-2": size === "lg"
480
+ },
481
+ {
482
+ "rounded-md": variant === "normal",
483
+ "rounded-full": variant === "fullyRounded"
484
+ },
485
+ className
486
+ ),
487
+ children: [
488
+ children,
489
+ trailingIcon && /* @__PURE__ */ jsx3("span", { className: colorMappingIcon, children: trailingIcon })
490
+ ]
491
+ }
492
+ );
493
+ };
494
+
495
+ // src/components/user-action/Button.tsx
496
+ import { forwardRef as forwardRef2 } from "react";
497
+ import clsx3 from "clsx";
498
+ import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
499
+ var ButtonColorUtil = {
500
+ solid: ["primary", "secondary", "tertiary", "positive", "warning", "negative", "neutral"],
501
+ text: ["primary", "negative", "neutral"],
502
+ outline: ["primary"]
503
+ };
504
+ var IconButtonUtil = {
505
+ icon: [...ButtonColorUtil.solid, "transparent"]
506
+ };
507
+ var paddingMapping = {
508
+ small: "btn-sm",
509
+ medium: "btn-md",
510
+ large: "btn-lg"
511
+ };
512
+ var iconPaddingMapping = {
513
+ tiny: "icon-btn-xs",
514
+ small: "icon-btn-sm",
515
+ medium: "icon-btn-md",
516
+ large: "icon-btn-lg"
517
+ };
518
+ var ButtonUtil = {
519
+ paddingMapping,
520
+ iconPaddingMapping
521
+ };
522
+ var SolidButton = forwardRef2(function SolidButton2({
523
+ children,
524
+ color = "primary",
525
+ size = "medium",
526
+ startIcon,
527
+ endIcon,
528
+ onClick,
529
+ className,
530
+ ...restProps
531
+ }, ref) {
532
+ const colorClasses = {
533
+ primary: "not-disabled:bg-button-solid-primary-background not-disabled:text-button-solid-primary-text",
534
+ secondary: "not-disabled:bg-button-solid-secondary-background not-disabled:text-button-solid-secondary-text",
535
+ tertiary: "not-disabled:bg-button-solid-tertiary-background not-disabled:text-button-solid-tertiary-text",
536
+ positive: "not-disabled:bg-button-solid-positive-background not-disabled:text-button-solid-positive-text",
537
+ warning: "not-disabled:bg-button-solid-warning-background not-disabled:text-button-solid-warning-text",
538
+ negative: "not-disabled:bg-button-solid-negative-background not-disabled:text-button-solid-negative-text",
539
+ neutral: "not-disabled:bg-button-solid-neutral-background not-disabled:text-button-solid-neutral-text"
540
+ }[color];
541
+ const iconColorClasses = {
542
+ primary: "not-group-disabled:text-button-solid-primary-icon",
543
+ secondary: "not-group-disabled:text-button-solid-secondary-icon",
544
+ tertiary: "not-group-disabled:text-button-solid-tertiary-icon",
545
+ positive: "not-group-disabled:text-button-solid-positive-icon",
546
+ warning: "not-group-disabled:text-button-solid-warning-icon",
547
+ negative: "not-group-disabled:text-button-solid-negative-icon",
548
+ neutral: "not-group-disabled:text-button-solid-neutral-icon"
549
+ }[color];
550
+ return /* @__PURE__ */ jsxs3(
551
+ "button",
552
+ {
553
+ ref,
554
+ onClick,
555
+ className: clsx3(
556
+ "group font-semibold",
557
+ colorClasses,
558
+ "not-disabled:hover:brightness-90",
559
+ "disabled:text-disabled-text disabled:bg-disabled-background",
560
+ ButtonUtil.paddingMapping[size],
561
+ className
562
+ ),
563
+ ...restProps,
564
+ children: [
565
+ startIcon && /* @__PURE__ */ jsx4(
566
+ "span",
567
+ {
568
+ className: clsx3(
569
+ iconColorClasses,
570
+ "group-disabled:text-disabled-icon"
571
+ ),
572
+ children: startIcon
573
+ }
574
+ ),
575
+ children,
576
+ endIcon && /* @__PURE__ */ jsx4(
577
+ "span",
578
+ {
579
+ className: clsx3(
580
+ iconColorClasses,
581
+ "group-disabled:text-disabled-icon"
582
+ ),
583
+ children: endIcon
584
+ }
585
+ )
586
+ ]
587
+ }
588
+ );
589
+ });
590
+ var IconButton = forwardRef2(function IconButton2({
591
+ children,
592
+ color = "primary",
593
+ size = "medium",
594
+ className,
595
+ ...restProps
596
+ }, ref) {
597
+ const colorClasses = {
598
+ primary: "not-disabled:bg-button-solid-primary-background not-disabled:text-button-solid-primary-text",
599
+ secondary: "not-disabled:bg-button-solid-secondary-background not-disabled:text-button-solid-secondary-text",
600
+ tertiary: "not-disabled:bg-button-solid-tertiary-background not-disabled:text-button-solid-tertiary-text",
601
+ positive: "not-disabled:bg-button-solid-positive-background not-disabled:text-button-solid-positive-text",
602
+ warning: "not-disabled:bg-button-solid-warning-background not-disabled:text-button-solid-warning-text",
603
+ negative: "not-disabled:bg-button-solid-negative-background not-disabled:text-button-solid-negative-text",
604
+ neutral: "not-disabled:bg-button-solid-neutral-background not-disabled:text-button-solid-neutral-text",
605
+ transparent: "not-disabled:bg-transparent"
606
+ }[color];
607
+ return /* @__PURE__ */ jsx4(
608
+ "button",
609
+ {
610
+ ref,
611
+ className: clsx3(
612
+ colorClasses,
613
+ "not-disabled:hover:brightness-90",
614
+ "disabled:text-disabled-text",
615
+ {
616
+ "disabled:bg-disabled-background": color !== "transparent",
617
+ "disabled:opacity-70": color === "transparent",
618
+ "not-disabled:hover:bg-button-text-hover-background": color === "transparent"
619
+ },
620
+ ButtonUtil.iconPaddingMapping[size],
621
+ className
622
+ ),
623
+ ...restProps,
624
+ children
625
+ }
626
+ );
627
+ });
628
+
629
+ // src/hooks/useFloatingElement.ts
630
+ import { useCallback as useCallback4, useEffect as useEffect5, useState as useState6 } from "react";
631
+
632
+ // src/utils/math.ts
633
+ var clamp = (value, range = [0, 1]) => {
634
+ const [min, max] = range;
635
+ return Math.min(Math.max(value, min), max);
636
+ };
637
+
638
+ // src/hooks/useFloatingElement.ts
639
+ function calculatePosition({
640
+ windowRect,
641
+ containerRect,
642
+ anchorRect,
643
+ options
644
+ }) {
645
+ const { verticalAlignment, horizontalAlignment, gap, screenPadding } = options;
646
+ const windowWidth = windowRect.width;
647
+ const windowHeight = windowRect.height;
648
+ const maxWidth = windowWidth - 2 * screenPadding;
649
+ const maxHeight = windowHeight - 2 * screenPadding;
650
+ const width = Math.min(containerRect.width, maxWidth);
651
+ const height = Math.min(containerRect.height, maxHeight);
652
+ const leftSuggestion = {
653
+ beforeStart: anchorRect.left - width - gap,
654
+ afterStart: anchorRect.left,
655
+ center: anchorRect.left + anchorRect.width / 2 - width / 2,
656
+ beforeEnd: anchorRect.right - width,
657
+ afterEnd: anchorRect.right + gap
658
+ }[horizontalAlignment];
659
+ const topSuggestion = {
660
+ beforeStart: anchorRect.top - height - gap,
661
+ afterStart: anchorRect.top,
662
+ center: anchorRect.top + anchorRect.height / 2 - height / 2,
663
+ beforeEnd: anchorRect.bottom - height,
664
+ afterEnd: anchorRect.bottom + gap
665
+ }[verticalAlignment];
666
+ const left = clamp(leftSuggestion, [
667
+ screenPadding,
668
+ windowWidth - screenPadding - width
669
+ ]);
670
+ const top = clamp(topSuggestion, [
671
+ screenPadding,
672
+ windowHeight - screenPadding - height
673
+ ]);
674
+ return {
675
+ left,
676
+ top,
677
+ maxWidth,
678
+ maxHeight
679
+ };
680
+ }
681
+ function useFloatingElement({
682
+ active = true,
683
+ windowRef,
684
+ anchorRef,
685
+ containerRef,
686
+ isPolling = false,
687
+ pollingInterval = 100,
688
+ verticalAlignment = "afterEnd",
689
+ horizontalAlignment = "afterStart",
690
+ screenPadding = 16,
691
+ gap = 4
692
+ }) {
693
+ const [style, setStyle] = useState6();
694
+ const isMounted = useIsMounted();
695
+ const calculate = useCallback4(() => {
696
+ const containerRect = containerRef.current.getBoundingClientRect();
697
+ const windowRect = windowRef?.current.getBoundingClientRect() ?? {
698
+ top: 0,
699
+ bottom: window.innerHeight,
700
+ left: 0,
701
+ right: window.innerWidth,
702
+ width: window.innerWidth,
703
+ height: window.innerHeight
704
+ };
705
+ const anchorElement = anchorRef?.current;
706
+ if (anchorRef && !anchorElement) {
707
+ console.warn("FloatingContainer anchor provided, but its value is undefined");
708
+ }
709
+ const anchorRect = anchorElement?.getBoundingClientRect() ?? windowRect;
710
+ const calculateProps = {
711
+ windowRect,
712
+ anchorRect,
713
+ containerRect,
714
+ options: {
715
+ horizontalAlignment,
716
+ verticalAlignment,
717
+ screenPadding,
718
+ gap
719
+ }
720
+ };
721
+ setStyle(calculatePosition(calculateProps));
722
+ }, [anchorRef, containerRef, gap, horizontalAlignment, screenPadding, verticalAlignment, windowRef]);
723
+ const height = containerRef.current?.getBoundingClientRect().height;
724
+ const width = containerRef.current?.getBoundingClientRect().width;
725
+ useEffect5(() => {
726
+ if (active && isMounted) {
727
+ calculate();
728
+ } else {
729
+ setStyle(void 0);
730
+ }
731
+ }, [calculate, active, isMounted, height, width]);
732
+ useEffect5(() => {
733
+ window.addEventListener("resize", calculate);
734
+ let timeout;
735
+ if (isPolling) {
736
+ timeout = setInterval(calculate, pollingInterval);
737
+ }
738
+ return () => {
739
+ window.removeEventListener("resize", calculate);
740
+ if (timeout) {
741
+ clearInterval(timeout);
742
+ }
743
+ };
744
+ }, [calculate, isPolling, pollingInterval]);
745
+ return style;
746
+ }
747
+
748
+ // src/components/user-action/select/Select.tsx
749
+ import { createPortal } from "react-dom";
750
+ import { Fragment, jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
751
+ var defaultToggleOpenOptions = {
752
+ highlightStartPosition: "first"
753
+ };
754
+ var SelectContext = createContext2(null);
755
+ function useSelectContext() {
756
+ const ctx = useContext2(SelectContext);
757
+ if (!ctx) {
758
+ throw new Error("SelectContext must be used within a ListBoxPrimitive");
759
+ }
760
+ return ctx;
761
+ }
762
+ var SelectRoot = ({
763
+ children,
764
+ id,
765
+ value,
766
+ onValueChanged,
767
+ values,
768
+ onValuesChanged,
769
+ isOpen = false,
770
+ disabled = false,
771
+ invalid = false,
772
+ isMultiSelect = false,
773
+ iconAppearance = "left"
774
+ }) => {
775
+ const optionsRef = useRef2([]);
776
+ const triggerRef = useRef2(null);
777
+ const generatedId = useId3();
778
+ const usedId = id ?? generatedId;
779
+ const [internalState, setInternalState] = useState7({
780
+ isOpen
781
+ });
782
+ const state = {
783
+ ...internalState,
784
+ id: usedId,
785
+ disabled,
786
+ invalid,
787
+ value: isMultiSelect ? values ?? [] : [value].filter(Boolean)
788
+ };
789
+ const config = {
790
+ isMultiSelect,
791
+ iconAppearance
792
+ };
793
+ const registerItem = useCallback5((item) => {
794
+ optionsRef.current.push(item);
795
+ optionsRef.current.sort((a, b) => {
796
+ const aEl = a.ref.current;
797
+ const bEl = b.ref.current;
798
+ if (!aEl || !bEl) return 0;
799
+ return aEl.compareDocumentPosition(bEl) & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : 1;
800
+ });
801
+ }, []);
802
+ const unregisterItem = useCallback5((value2) => {
803
+ optionsRef.current = optionsRef.current.filter((i) => i.value !== value2);
804
+ }, []);
805
+ const toggleSelection = (value2, isSelected) => {
806
+ if (disabled) {
807
+ return;
808
+ }
809
+ const option = optionsRef.current.find((i) => i.value === value2);
810
+ if (!option) {
811
+ console.error(`SelectOption with value: ${value2} not found`);
812
+ return;
813
+ }
814
+ let newValue;
815
+ if (isMultiSelect) {
816
+ const isSelectedBefore = state.value.includes(value2);
817
+ const isSelectedAfter = isSelected ?? !isSelectedBefore;
818
+ if (!isSelectedAfter) {
819
+ newValue = state.value.filter((v) => v !== value2);
820
+ } else {
821
+ newValue = [...state.value, value2];
822
+ }
823
+ } else {
824
+ newValue = [value2];
825
+ }
826
+ if (!isMultiSelect) {
827
+ onValueChanged?.(newValue[0]);
828
+ } else {
829
+ onValuesChanged?.(newValue);
830
+ }
831
+ setInternalState((prevState) => ({
832
+ ...prevState,
833
+ highlightedValue: value2
834
+ }));
835
+ };
836
+ const highlightItem = (value2) => {
837
+ if (disabled) {
838
+ return;
839
+ }
840
+ setInternalState((prevState) => ({
841
+ ...prevState,
842
+ highlightedValue: value2
843
+ }));
844
+ };
845
+ const registerTrigger = useCallback5((ref) => {
846
+ triggerRef.current = ref.current;
847
+ }, []);
848
+ const unregisterTrigger = useCallback5(() => {
849
+ triggerRef.current = null;
850
+ }, []);
851
+ const toggleOpen = (isOpen2, options) => {
852
+ const { highlightStartPosition } = { ...defaultToggleOpenOptions, ...options };
853
+ let highlightedIndex;
854
+ if (highlightStartPosition === "first") {
855
+ highlightedIndex = optionsRef.current.findIndex((option) => !option.disabled);
856
+ } else {
857
+ highlightedIndex = optionsRef.current.length - 1 - [...optionsRef.current].reverse().findIndex((option) => !option.disabled);
858
+ }
859
+ if (highlightedIndex === -1 || highlightedIndex === optionsRef.current.length) {
860
+ highlightedIndex = 0;
861
+ }
862
+ setInternalState((prevState) => ({
863
+ ...prevState,
864
+ isOpen: isOpen2 ?? !prevState.isOpen,
865
+ highlightedValue: optionsRef.current[highlightedIndex].value
866
+ }));
867
+ };
868
+ const moveHighlightedIndex = (delta) => {
869
+ let highlightedIndex = optionsRef.current.findIndex((value2) => value2.value === internalState.highlightedValue);
870
+ if (highlightedIndex === -1) {
871
+ highlightedIndex = 0;
872
+ }
873
+ const optionLength = optionsRef.current.length;
874
+ const startIndex = (highlightedIndex + delta % optionLength + optionLength) % optionLength;
875
+ const isForward = delta >= 0;
876
+ let highlightedValue = optionsRef.current[startIndex].value;
877
+ for (let i = 0; i < optionsRef.current.length; i++) {
878
+ const index = (startIndex + (isForward ? i : -i) + optionLength) % optionLength;
879
+ if (!optionsRef.current[index].disabled) {
880
+ highlightedValue = optionsRef.current[index].value;
881
+ break;
882
+ }
883
+ }
884
+ setInternalState((prevState) => ({
885
+ ...prevState,
886
+ highlightedValue
887
+ }));
888
+ };
889
+ useEffect6(() => {
890
+ if (!internalState.highlightedValue) return;
891
+ const highlighted = optionsRef.current.find((value2) => value2.value === internalState.highlightedValue);
892
+ if (highlighted) {
893
+ highlighted.ref.current.scrollIntoView({ behavior: "instant", block: "nearest" });
894
+ } else {
895
+ console.error(`SelectRoot: Could not find highlighted value (${internalState.highlightedValue})`);
896
+ }
897
+ }, [internalState.highlightedValue]);
898
+ const contextValue = {
899
+ state,
900
+ config,
901
+ item: {
902
+ register: registerItem,
903
+ unregister: unregisterItem,
904
+ toggleSelection,
905
+ highlightItem,
906
+ moveHighlightedIndex
907
+ },
908
+ trigger: {
909
+ ref: triggerRef,
910
+ register: registerTrigger,
911
+ unregister: unregisterTrigger,
912
+ toggleOpen
913
+ }
914
+ };
915
+ return /* @__PURE__ */ jsx5(SelectContext.Provider, { value: contextValue, children });
916
+ };
917
+ var SelectOption = forwardRef3(
918
+ function SelectOption2({ children, value, disabled = false, iconAppearance, className, ...restProps }, ref) {
919
+ const { state, config, item, trigger } = useSelectContext();
920
+ const { register, unregister, toggleSelection, highlightItem } = item;
921
+ const itemRef = useRef2(null);
922
+ iconAppearance ??= config.iconAppearance;
923
+ useEffect6(() => {
924
+ register({
925
+ value,
926
+ disabled,
927
+ ref: itemRef
928
+ });
929
+ return () => unregister(value);
930
+ }, [value, disabled, register, unregister, children]);
931
+ const isHighlighted = state.highlightedValue === value;
932
+ const isSelected = state.value.includes(value);
933
+ return /* @__PURE__ */ jsxs4(
934
+ "li",
935
+ {
936
+ ...restProps,
937
+ ref: (node) => {
938
+ itemRef.current = node;
939
+ if (typeof ref === "function") ref(node);
940
+ else if (ref) ref.current = node;
941
+ },
942
+ id: value,
943
+ role: "option",
944
+ "aria-disabled": disabled,
945
+ "aria-selected": isSelected,
946
+ "data-highlighted": isHighlighted ? "" : void 0,
947
+ "data-selected": isSelected ? "" : void 0,
948
+ "data-disabled": disabled ? "" : void 0,
949
+ className: clsx4(
950
+ "flex-row-1 items-center px-2 py-1 rounded-md",
951
+ "data-highlighted:bg-primary/20",
952
+ "data-disabled:text-disabled data-disabled:cursor-not-allowed",
953
+ "not-data-disabled:cursor-pointer",
954
+ className
955
+ ),
956
+ onClick: (event) => {
957
+ if (!disabled) {
958
+ toggleSelection(value);
959
+ if (!config.isMultiSelect) {
960
+ trigger.toggleOpen(false);
961
+ }
962
+ restProps.onClick?.(event);
963
+ }
964
+ },
965
+ onMouseEnter: (event) => {
966
+ if (!disabled) {
967
+ highlightItem(value);
968
+ restProps.onMouseEnter?.(event);
969
+ }
970
+ },
971
+ children: [
972
+ iconAppearance === "left" && /* @__PURE__ */ jsx5(
973
+ CheckIcon,
974
+ {
975
+ className: clsx4("w-4 h-4", { "opacity-0": !isSelected || disabled }),
976
+ "aria-hidden": true
977
+ }
978
+ ),
979
+ children ?? value,
980
+ iconAppearance === "right" && /* @__PURE__ */ jsx5(
981
+ CheckIcon,
982
+ {
983
+ className: clsx4("w-4 h-4", { "opacity-0": !isSelected || disabled }),
984
+ "aria-hidden": true
985
+ }
986
+ )
987
+ ]
988
+ }
989
+ );
990
+ }
991
+ );
992
+ var defaultSelectButtonTranslation = {
993
+ en: {
994
+ clickToSelect: "Click to select"
995
+ },
996
+ de: {
997
+ clickToSelect: "Zum ausw\xE4hlen dr\xFCcken"
998
+ }
999
+ };
1000
+ var SelectButton = forwardRef3(function SelectButton2({ placeholder, selectedDisplay, ...props }, ref) {
1001
+ const translation = useTranslation([defaultSelectButtonTranslation]);
1002
+ const { state, trigger } = useSelectContext();
1003
+ const { register, unregister, toggleOpen } = trigger;
1004
+ const innerRef = useRef2(null);
1005
+ useImperativeHandle(ref, () => innerRef.current);
1006
+ useEffect6(() => {
1007
+ register(innerRef);
1008
+ return () => unregister();
1009
+ }, [register, unregister]);
1010
+ const disabled = !!props?.disabled || !!state.disabled;
1011
+ const invalid = state.invalid;
1012
+ const hasValue = state.value.length > 0;
1013
+ return /* @__PURE__ */ jsxs4(
1014
+ "button",
1015
+ {
1016
+ ...props,
1017
+ ref: innerRef,
1018
+ id: state.id,
1019
+ className: clsx4(
1020
+ "flex-row-2 items-center justify-between bg-input-background text-input-text rounded-md px-2.5 py-2.5",
1021
+ "data-placeholder:text-description",
1022
+ props.className
1023
+ ),
1024
+ onClick: () => toggleOpen(!state.isOpen),
1025
+ onKeyDown: (event) => {
1026
+ switch (event.key) {
1027
+ case "ArrowDown":
1028
+ toggleOpen(true, { highlightStartPosition: "first" });
1029
+ break;
1030
+ case "ArrowUp":
1031
+ toggleOpen(true, { highlightStartPosition: "last" });
1032
+ break;
1033
+ }
1034
+ },
1035
+ "data-placeholder": !hasValue ? "" : void 0,
1036
+ "data-disabled": disabled ? "" : void 0,
1037
+ "data-invalid": invalid ? "" : void 0,
1038
+ "aria-invalid": invalid,
1039
+ "aria-disabled": disabled,
1040
+ "aria-haspopup": "listbox",
1041
+ "aria-expanded": state.isOpen,
1042
+ "aria-controls": state.isOpen ? `${state.id}-listbox` : void 0,
1043
+ children: [
1044
+ hasValue ? selectedDisplay?.(state.value) ?? state.value.join(", ") : placeholder ?? translation("clickToSelect"),
1045
+ /* @__PURE__ */ jsx5(ExpansionIcon, { isExpanded: state.isOpen })
1046
+ ]
1047
+ }
1048
+ );
1049
+ });
1050
+ var SelectChipDisplay = forwardRef3(function SelectChipDisplay2({ ...props }, ref) {
1051
+ const { state, trigger, item } = useSelectContext();
1052
+ const { register, unregister, toggleOpen } = trigger;
1053
+ const innerRef = useRef2(null);
1054
+ useImperativeHandle(ref, () => innerRef.current);
1055
+ useEffect6(() => {
1056
+ register(innerRef);
1057
+ return () => unregister();
1058
+ }, [register, unregister]);
1059
+ const disabled = !!props?.disabled || !!state.disabled;
1060
+ const invalid = state.invalid;
1061
+ return /* @__PURE__ */ jsxs4(
1062
+ "div",
1063
+ {
1064
+ ...props,
1065
+ ref: innerRef,
1066
+ className: clsx4(
1067
+ "flex flex-wrap flex-row gap-2 items-center bg-input-background text-input-text rounded-md px-2.5 py-2.5",
1068
+ props.className
1069
+ ),
1070
+ "data-disabled": disabled ? "" : void 0,
1071
+ "data-invalid": invalid ? "" : void 0,
1072
+ "aria-invalid": invalid,
1073
+ "aria-disabled": disabled,
1074
+ children: [
1075
+ state.value.map((value) => /* @__PURE__ */ jsxs4(Chip, { className: "gap-x-2", children: [
1076
+ value,
1077
+ /* @__PURE__ */ jsx5(
1078
+ "button",
1079
+ {
1080
+ onClick: () => {
1081
+ item.toggleSelection(value, false);
1082
+ },
1083
+ className: "focus-within:text-negative hover:bg-negative/20 hover:text-negative rounded-md focus-style-none focus-visible:ring-2 focus-visible:ring-negative focus-visible:bg-negative/20",
1084
+ children: /* @__PURE__ */ jsx5(XIcon, {})
1085
+ }
1086
+ )
1087
+ ] }, value)),
1088
+ /* @__PURE__ */ jsx5(
1089
+ IconButton,
1090
+ {
1091
+ id: state.id,
1092
+ onClick: () => toggleOpen(),
1093
+ onKeyDown: (event) => {
1094
+ switch (event.key) {
1095
+ case "ArrowDown":
1096
+ toggleOpen(true, { highlightStartPosition: "first" });
1097
+ break;
1098
+ case "ArrowUp":
1099
+ toggleOpen(true, { highlightStartPosition: "last" });
1100
+ }
1101
+ },
1102
+ size: "small",
1103
+ color: "neutral",
1104
+ "aria-invalid": invalid,
1105
+ "aria-disabled": disabled,
1106
+ "aria-haspopup": "listbox",
1107
+ "aria-expanded": state.isOpen,
1108
+ "aria-controls": state.isOpen ? `${state.id}-listbox` : void 0,
1109
+ children: /* @__PURE__ */ jsx5(Plus, {})
1110
+ }
1111
+ )
1112
+ ]
1113
+ }
1114
+ );
1115
+ });
1116
+ var SelectContent = forwardRef3(
1117
+ function SelectContent2({
1118
+ alignment,
1119
+ orientation = "vertical",
1120
+ ...props
1121
+ }, ref) {
1122
+ const innerRef = useRef2(null);
1123
+ useImperativeHandle(ref, () => innerRef.current);
1124
+ const { trigger, state, config, item } = useSelectContext();
1125
+ const position = useFloatingElement({
1126
+ active: state.isOpen,
1127
+ anchorRef: trigger.ref,
1128
+ containerRef: innerRef,
1129
+ ...alignment
1130
+ });
1131
+ useFocusTrap({
1132
+ container: innerRef,
1133
+ active: state.isOpen && !!position
1134
+ });
1135
+ return createPortal(
1136
+ /* @__PURE__ */ jsxs4(Fragment, { children: [
1137
+ /* @__PURE__ */ jsx5(
1138
+ "div",
1139
+ {
1140
+ hidden: !state.isOpen,
1141
+ onClick: () => trigger.toggleOpen(false),
1142
+ className: clsx4("fixed w-screen h-screen inset-0")
1143
+ }
1144
+ ),
1145
+ /* @__PURE__ */ jsx5(
1146
+ "ul",
1147
+ {
1148
+ ...props,
1149
+ id: `${state.id}-listbox`,
1150
+ ref: innerRef,
1151
+ hidden: !state.isOpen,
1152
+ onKeyDown: (event) => {
1153
+ switch (event.key) {
1154
+ case "Escape":
1155
+ trigger.toggleOpen(false);
1156
+ event.preventDefault();
1157
+ event.stopPropagation();
1158
+ break;
1159
+ case match(orientation, {
1160
+ vertical: "ArrowDown",
1161
+ horizontal: "ArrowUp"
1162
+ }):
1163
+ item.moveHighlightedIndex(1);
1164
+ event.preventDefault();
1165
+ break;
1166
+ case match(orientation, {
1167
+ vertical: "ArrowUp",
1168
+ horizontal: "ArrowDown"
1169
+ }):
1170
+ item.moveHighlightedIndex(-1);
1171
+ event.preventDefault();
1172
+ break;
1173
+ case "Home":
1174
+ event.preventDefault();
1175
+ break;
1176
+ case "End":
1177
+ event.preventDefault();
1178
+ break;
1179
+ case "Enter":
1180
+ // Fall through
1181
+ case " ":
1182
+ if (state.highlightedValue) {
1183
+ item.toggleSelection(state.highlightedValue);
1184
+ if (!config.isMultiSelect) {
1185
+ trigger.toggleOpen(false);
1186
+ }
1187
+ event.preventDefault();
1188
+ }
1189
+ break;
1190
+ }
1191
+ },
1192
+ className: clsx4("flex-col-0 p-2 bg-menu-background text-menu-text rounded-md shadow-hw-bottom focus-style-within overflow-auto", props.className),
1193
+ style: {
1194
+ opacity: position ? void 0 : 0,
1195
+ position: "fixed",
1196
+ ...position
1197
+ },
1198
+ role: "listbox",
1199
+ "aria-multiselectable": config.isMultiSelect,
1200
+ "aria-orientation": orientation,
1201
+ tabIndex: position ? 0 : void 0,
1202
+ children: props.children
1203
+ }
1204
+ )
1205
+ ] }),
1206
+ document.body
1207
+ );
1208
+ }
1209
+ );
1210
+ var Select = forwardRef3(function Select2({
1211
+ children,
1212
+ contentPanelProps,
1213
+ buttonProps,
1214
+ ...props
1215
+ }, ref) {
1216
+ return /* @__PURE__ */ jsxs4(SelectRoot, { ...props, isMultiSelect: false, children: [
1217
+ /* @__PURE__ */ jsx5(
1218
+ SelectButton,
1219
+ {
1220
+ ref,
1221
+ ...buttonProps,
1222
+ selectedDisplay: (values) => {
1223
+ const value = values[0];
1224
+ if (!buttonProps?.selectedDisplay) return void 0;
1225
+ return buttonProps.selectedDisplay(value);
1226
+ }
1227
+ }
1228
+ ),
1229
+ /* @__PURE__ */ jsx5(SelectContent, { ...contentPanelProps, children })
1230
+ ] });
1231
+ });
1232
+ var SelectUncontrolled = forwardRef3(function SelectUncontrolled2({
1233
+ value: initialValue,
1234
+ onValueChanged,
1235
+ ...props
1236
+ }, ref) {
1237
+ const [value, setValue] = useState7(initialValue);
1238
+ useEffect6(() => {
1239
+ setValue(initialValue);
1240
+ }, [initialValue]);
1241
+ return /* @__PURE__ */ jsx5(
1242
+ Select,
1243
+ {
1244
+ ...props,
1245
+ ref,
1246
+ value,
1247
+ onValueChanged: (value2) => {
1248
+ setValue(value2);
1249
+ onValueChanged?.(value2);
1250
+ }
1251
+ }
1252
+ );
1253
+ });
1254
+ var MultiSelect = forwardRef3(function MultiSelect2({
1255
+ children,
1256
+ contentPanelProps,
1257
+ buttonProps,
1258
+ ...props
1259
+ }, ref) {
1260
+ return /* @__PURE__ */ jsxs4(SelectRoot, { ...props, isMultiSelect: true, children: [
1261
+ /* @__PURE__ */ jsx5(SelectButton, { ref, ...buttonProps }),
1262
+ /* @__PURE__ */ jsx5(SelectContent, { ...contentPanelProps, children })
1263
+ ] });
1264
+ });
1265
+ var MultiSelectUncontrolled = forwardRef3(function MultiSelectUncontrolled2({
1266
+ values: initialValues,
1267
+ onValuesChanged,
1268
+ ...props
1269
+ }, ref) {
1270
+ const [values, setValues] = useState7(initialValues);
1271
+ useEffect6(() => {
1272
+ setValues(initialValues);
1273
+ }, [initialValues]);
1274
+ return /* @__PURE__ */ jsx5(
1275
+ MultiSelect,
1276
+ {
1277
+ ...props,
1278
+ ref,
1279
+ values,
1280
+ onValuesChanged: (value) => {
1281
+ setValues(value);
1282
+ onValuesChanged?.(value);
1283
+ }
1284
+ }
1285
+ );
1286
+ });
1287
+ var MultiSelectChipDisplay = forwardRef3(function MultiSelectChipDisplay2({
1288
+ children,
1289
+ contentPanelProps,
1290
+ chipDisplayProps,
1291
+ ...props
1292
+ }, ref) {
1293
+ return /* @__PURE__ */ jsxs4(SelectRoot, { ...props, isMultiSelect: true, children: [
1294
+ /* @__PURE__ */ jsx5(SelectChipDisplay, { ref, ...chipDisplayProps }),
1295
+ /* @__PURE__ */ jsx5(SelectContent, { ...contentPanelProps, children })
1296
+ ] });
1297
+ });
1298
+ var MultiSelectChipDisplayUncontrolled = forwardRef3(function MultiSelectChipDisplayUncontrolled2({
1299
+ values: initialValues,
1300
+ onValuesChanged,
1301
+ ...props
1302
+ }, ref) {
1303
+ const [values, setValues] = useState7(initialValues);
1304
+ useEffect6(() => {
1305
+ setValues(initialValues);
1306
+ }, [initialValues]);
1307
+ return /* @__PURE__ */ jsx5(
1308
+ MultiSelectChipDisplay,
1309
+ {
1310
+ ...props,
1311
+ ref,
1312
+ values,
1313
+ onValuesChanged: (value) => {
1314
+ setValues(value);
1315
+ onValuesChanged?.(value);
1316
+ }
1317
+ }
1318
+ );
1319
+ });
1320
+ export {
1321
+ MultiSelect,
1322
+ MultiSelectChipDisplay,
1323
+ MultiSelectChipDisplayUncontrolled,
1324
+ MultiSelectUncontrolled,
1325
+ Select,
1326
+ SelectButton,
1327
+ SelectChipDisplay,
1328
+ SelectContent,
1329
+ SelectOption,
1330
+ SelectRoot,
1331
+ SelectUncontrolled
1332
+ };
1333
+ //# sourceMappingURL=index.mjs.map