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