@helpwave/hightide 0.0.15 → 0.0.16

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 (111) hide show
  1. package/dist/index.d.mts +86 -2
  2. package/dist/index.d.ts +86 -2
  3. package/dist/index.js +5714 -0
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.mjs +5541 -0
  6. package/dist/index.mjs.map +1 -1
  7. package/dist/util/news.d.mts +9 -9
  8. package/dist/util/news.d.ts +9 -9
  9. package/package.json +11 -7
  10. package/dist/components/Span.d.mts +0 -2
  11. package/dist/components/Span.d.ts +0 -2
  12. package/dist/components/Span.js +0 -2
  13. package/dist/components/Span.js.map +0 -1
  14. package/dist/components/Span.mjs +0 -1
  15. package/dist/components/Span.mjs.map +0 -1
  16. package/dist/components/examples/InputGroupExample.d.mts +0 -11
  17. package/dist/components/examples/InputGroupExample.d.ts +0 -11
  18. package/dist/components/examples/InputGroupExample.js +0 -466
  19. package/dist/components/examples/InputGroupExample.js.map +0 -1
  20. package/dist/components/examples/InputGroupExample.mjs +0 -436
  21. package/dist/components/examples/InputGroupExample.mjs.map +0 -1
  22. package/dist/components/examples/MultiSelectExample.d.mts +0 -14
  23. package/dist/components/examples/MultiSelectExample.d.ts +0 -14
  24. package/dist/components/examples/MultiSelectExample.js +0 -661
  25. package/dist/components/examples/MultiSelectExample.js.map +0 -1
  26. package/dist/components/examples/MultiSelectExample.mjs +0 -631
  27. package/dist/components/examples/MultiSelectExample.mjs.map +0 -1
  28. package/dist/components/examples/SearchableSelectExample.d.mts +0 -13
  29. package/dist/components/examples/SearchableSelectExample.d.ts +0 -13
  30. package/dist/components/examples/SearchableSelectExample.js +0 -365
  31. package/dist/components/examples/SearchableSelectExample.js.map +0 -1
  32. package/dist/components/examples/SearchableSelectExample.mjs +0 -335
  33. package/dist/components/examples/SearchableSelectExample.mjs.map +0 -1
  34. package/dist/components/examples/SelectExample.d.mts +0 -9
  35. package/dist/components/examples/SelectExample.d.ts +0 -9
  36. package/dist/components/examples/SelectExample.js +0 -180
  37. package/dist/components/examples/SelectExample.js.map +0 -1
  38. package/dist/components/examples/SelectExample.mjs +0 -145
  39. package/dist/components/examples/SelectExample.mjs.map +0 -1
  40. package/dist/components/examples/StackingModals.d.mts +0 -8
  41. package/dist/components/examples/StackingModals.d.ts +0 -8
  42. package/dist/components/examples/StackingModals.js +0 -498
  43. package/dist/components/examples/StackingModals.js.map +0 -1
  44. package/dist/components/examples/StackingModals.mjs +0 -463
  45. package/dist/components/examples/StackingModals.mjs.map +0 -1
  46. package/dist/components/examples/TableExample.d.mts +0 -13
  47. package/dist/components/examples/TableExample.d.ts +0 -13
  48. package/dist/components/examples/TableExample.js +0 -853
  49. package/dist/components/examples/TableExample.js.map +0 -1
  50. package/dist/components/examples/TableExample.mjs +0 -823
  51. package/dist/components/examples/TableExample.mjs.map +0 -1
  52. package/dist/components/examples/TextareaExample.d.mts +0 -12
  53. package/dist/components/examples/TextareaExample.d.ts +0 -12
  54. package/dist/components/examples/TextareaExample.js +0 -176
  55. package/dist/components/examples/TextareaExample.js.map +0 -1
  56. package/dist/components/examples/TextareaExample.mjs +0 -141
  57. package/dist/components/examples/TextareaExample.mjs.map +0 -1
  58. package/dist/components/examples/TileExample.d.mts +0 -14
  59. package/dist/components/examples/TileExample.d.ts +0 -14
  60. package/dist/components/examples/TileExample.js +0 -79
  61. package/dist/components/examples/TileExample.js.map +0 -1
  62. package/dist/components/examples/TileExample.mjs +0 -44
  63. package/dist/components/examples/TileExample.mjs.map +0 -1
  64. package/dist/components/examples/Title.d.mts +0 -2
  65. package/dist/components/examples/Title.d.ts +0 -2
  66. package/dist/components/examples/Title.js +0 -2
  67. package/dist/components/examples/Title.js.map +0 -1
  68. package/dist/components/examples/Title.mjs +0 -1
  69. package/dist/components/examples/Title.mjs.map +0 -1
  70. package/dist/components/examples/date/DateTimePickerExample.d.mts +0 -18
  71. package/dist/components/examples/date/DateTimePickerExample.d.ts +0 -18
  72. package/dist/components/examples/date/DateTimePickerExample.js +0 -879
  73. package/dist/components/examples/date/DateTimePickerExample.js.map +0 -1
  74. package/dist/components/examples/date/DateTimePickerExample.mjs +0 -844
  75. package/dist/components/examples/date/DateTimePickerExample.mjs.map +0 -1
  76. package/dist/components/examples/properties/CheckboxPropertyExample.d.mts +0 -16
  77. package/dist/components/examples/properties/CheckboxPropertyExample.d.ts +0 -16
  78. package/dist/components/examples/properties/CheckboxPropertyExample.js +0 -349
  79. package/dist/components/examples/properties/CheckboxPropertyExample.js.map +0 -1
  80. package/dist/components/examples/properties/CheckboxPropertyExample.mjs +0 -314
  81. package/dist/components/examples/properties/CheckboxPropertyExample.mjs.map +0 -1
  82. package/dist/components/examples/properties/DatePropertyExample.d.mts +0 -16
  83. package/dist/components/examples/properties/DatePropertyExample.d.ts +0 -16
  84. package/dist/components/examples/properties/DatePropertyExample.js +0 -460
  85. package/dist/components/examples/properties/DatePropertyExample.js.map +0 -1
  86. package/dist/components/examples/properties/DatePropertyExample.mjs +0 -430
  87. package/dist/components/examples/properties/DatePropertyExample.mjs.map +0 -1
  88. package/dist/components/examples/properties/MultiSelectPropertyExample.d.mts +0 -18
  89. package/dist/components/examples/properties/MultiSelectPropertyExample.d.ts +0 -18
  90. package/dist/components/examples/properties/MultiSelectPropertyExample.js +0 -848
  91. package/dist/components/examples/properties/MultiSelectPropertyExample.js.map +0 -1
  92. package/dist/components/examples/properties/MultiSelectPropertyExample.mjs +0 -818
  93. package/dist/components/examples/properties/MultiSelectPropertyExample.mjs.map +0 -1
  94. package/dist/components/examples/properties/NumberPropertyExample.d.mts +0 -14
  95. package/dist/components/examples/properties/NumberPropertyExample.d.ts +0 -14
  96. package/dist/components/examples/properties/NumberPropertyExample.js +0 -456
  97. package/dist/components/examples/properties/NumberPropertyExample.js.map +0 -1
  98. package/dist/components/examples/properties/NumberPropertyExample.mjs +0 -426
  99. package/dist/components/examples/properties/NumberPropertyExample.mjs.map +0 -1
  100. package/dist/components/examples/properties/SelectPropertyExample.d.mts +0 -17
  101. package/dist/components/examples/properties/SelectPropertyExample.d.ts +0 -17
  102. package/dist/components/examples/properties/SelectPropertyExample.js +0 -584
  103. package/dist/components/examples/properties/SelectPropertyExample.js.map +0 -1
  104. package/dist/components/examples/properties/SelectPropertyExample.mjs +0 -554
  105. package/dist/components/examples/properties/SelectPropertyExample.mjs.map +0 -1
  106. package/dist/components/examples/properties/TextPropertyExample.d.mts +0 -16
  107. package/dist/components/examples/properties/TextPropertyExample.d.ts +0 -16
  108. package/dist/components/examples/properties/TextPropertyExample.js +0 -405
  109. package/dist/components/examples/properties/TextPropertyExample.js.map +0 -1
  110. package/dist/components/examples/properties/TextPropertyExample.mjs +0 -370
  111. package/dist/components/examples/properties/TextPropertyExample.mjs.map +0 -1
@@ -1,661 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
-
30
- // src/components/examples/MultiSelectExample.tsx
31
- var MultiSelectExample_exports = {};
32
- __export(MultiSelectExample_exports, {
33
- MultiSelectExample: () => MultiSelectExample
34
- });
35
- module.exports = __toCommonJS(MultiSelectExample_exports);
36
- var import_react10 = require("react");
37
-
38
- // src/components/user-input/MultiSelect.tsx
39
- var import_react9 = require("react");
40
- var import_lucide_react2 = require("lucide-react");
41
-
42
- // src/hooks/useLanguage.tsx
43
- var import_react2 = require("react");
44
-
45
- // src/hooks/useLocalStorage.tsx
46
- var import_react = require("react");
47
-
48
- // src/hooks/useLanguage.tsx
49
- var import_jsx_runtime = require("react/jsx-runtime");
50
- var DEFAULT_LANGUAGE = "en";
51
- var LanguageContext = (0, import_react2.createContext)({ language: DEFAULT_LANGUAGE, setLanguage: (v) => v });
52
- var useLanguage = () => (0, import_react2.useContext)(LanguageContext);
53
-
54
- // src/hooks/useTranslation.ts
55
- var useTranslation = (defaults, translationOverwrite = {}) => {
56
- const { language: languageProp, translation: overwrite } = translationOverwrite;
57
- const { language: inferredLanguage } = useLanguage();
58
- const usedLanguage = languageProp ?? inferredLanguage;
59
- let defaultValues = defaults[usedLanguage];
60
- if (overwrite && overwrite[usedLanguage]) {
61
- defaultValues = { ...defaultValues, ...overwrite[usedLanguage] };
62
- }
63
- return defaultValues;
64
- };
65
-
66
- // src/util/simpleSearch.ts
67
- var MultiSearchWithMapping = (search, objects, mapping) => {
68
- return objects.filter((object) => {
69
- const mappedSearchKeywords = mapping(object).map((value) => value.toLowerCase().trim());
70
- return !!mappedSearchKeywords.find((value) => value.includes(search.toLowerCase().trim()));
71
- });
72
- };
73
-
74
- // src/components/user-input/MultiSelect.tsx
75
- var import_clsx4 = __toESM(require("clsx"));
76
-
77
- // src/components/user-input/Menu.tsx
78
- var import_react5 = require("react");
79
- var import_clsx = __toESM(require("clsx"));
80
-
81
- // src/hooks/useOutsideClick.ts
82
- var import_react3 = require("react");
83
- var useOutsideClick = (refs, handler) => {
84
- (0, import_react3.useEffect)(() => {
85
- const listener = (event) => {
86
- if (event.target === null) return;
87
- if (refs.some((ref) => !ref.current || ref.current.contains(event.target))) {
88
- return;
89
- }
90
- handler();
91
- };
92
- document.addEventListener("mousedown", listener);
93
- document.addEventListener("touchstart", listener);
94
- return () => {
95
- document.removeEventListener("mousedown", listener);
96
- document.removeEventListener("touchstart", listener);
97
- };
98
- }, [refs, handler]);
99
- };
100
-
101
- // src/hooks/useHoverState.ts
102
- var import_react4 = require("react");
103
- var defaultUseHoverStateProps = {
104
- closingDelay: 200,
105
- isDisabled: false
106
- };
107
- var useHoverState = (props = void 0) => {
108
- const { closingDelay, isDisabled } = { ...defaultUseHoverStateProps, ...props };
109
- const [isHovered, setIsHovered] = (0, import_react4.useState)(false);
110
- const [timer, setTimer] = (0, import_react4.useState)();
111
- const onMouseEnter = () => {
112
- if (isDisabled) {
113
- return;
114
- }
115
- clearTimeout(timer);
116
- setIsHovered(true);
117
- };
118
- const onMouseLeave = () => {
119
- if (isDisabled) {
120
- return;
121
- }
122
- setTimer(setTimeout(() => {
123
- setIsHovered(false);
124
- }, closingDelay));
125
- };
126
- (0, import_react4.useEffect)(() => {
127
- if (timer) {
128
- return () => {
129
- clearTimeout(timer);
130
- };
131
- }
132
- });
133
- (0, import_react4.useEffect)(() => {
134
- if (timer) {
135
- clearTimeout(timer);
136
- }
137
- }, [isDisabled]);
138
- return {
139
- isHovered,
140
- setIsHovered,
141
- handlers: { onMouseEnter, onMouseLeave }
142
- };
143
- };
144
-
145
- // src/components/user-input/Menu.tsx
146
- var import_jsx_runtime2 = require("react/jsx-runtime");
147
- var MenuItem = ({
148
- children,
149
- onClick,
150
- alignment = "left",
151
- className
152
- }) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
153
- "div",
154
- {
155
- className: (0, import_clsx.default)("block px-3 py-1 bg-menu-background text-menu-text hover:brightness-90", {
156
- "text-right": alignment === "right",
157
- "text-left": alignment === "left"
158
- }, className),
159
- onClick,
160
- children
161
- }
162
- );
163
- var Menu = ({
164
- trigger,
165
- children,
166
- alignment = "tl",
167
- showOnHover = false,
168
- menuClassName = ""
169
- }) => {
170
- const { isHovered: isOpen, setIsHovered: setIsOpen, handlers } = useHoverState({ isDisabled: !showOnHover });
171
- const triggerRef = (0, import_react5.useRef)(null);
172
- const menuRef = (0, import_react5.useRef)(null);
173
- useOutsideClick([triggerRef, menuRef], () => setIsOpen(false));
174
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
175
- "div",
176
- {
177
- className: "relative",
178
- ...handlers,
179
- children: [
180
- trigger(() => setIsOpen(!isOpen), triggerRef),
181
- isOpen ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
182
- "div",
183
- {
184
- ref: menuRef,
185
- onClick: (e) => e.stopPropagation(),
186
- className: (0, import_clsx.default)("absolute top-full mt-1 py-2 w-60 rounded-lg bg-menu-background text-menu-text ring-1 ring-slate-900/5 text-sm leading-6 font-semibold shadow-md z-[1]", {
187
- " top-[8px]": alignment[0] === "t",
188
- " bottom-[8px]": alignment[0] === "b",
189
- " left-[-8px]": alignment[1] === "l",
190
- " right-[-8px]": alignment[1] === "r"
191
- }, menuClassName),
192
- children
193
- }
194
- ) : null
195
- ]
196
- }
197
- );
198
- };
199
-
200
- // src/components/user-input/Input.tsx
201
- var import_react7 = require("react");
202
- var import_clsx2 = __toESM(require("clsx"));
203
-
204
- // src/hooks/useSaveDelay.ts
205
- var import_react6 = require("react");
206
- function useSaveDelay(setNotificationStatus, delay) {
207
- const [updateTimer, setUpdateTimer] = (0, import_react6.useState)(void 0);
208
- const [notificationTimer, setNotificationTimer] = (0, import_react6.useState)(void 0);
209
- const restartTimer = (onSave) => {
210
- clearTimeout(updateTimer);
211
- setUpdateTimer(setTimeout(() => {
212
- onSave();
213
- setNotificationStatus(true);
214
- clearTimeout(notificationTimer);
215
- setNotificationTimer(setTimeout(() => {
216
- setNotificationStatus(false);
217
- clearTimeout(notificationTimer);
218
- }, delay));
219
- clearTimeout(updateTimer);
220
- }, delay));
221
- };
222
- const clearUpdateTimer = (hasSaved = true) => {
223
- clearTimeout(updateTimer);
224
- if (hasSaved) {
225
- setNotificationStatus(true);
226
- clearTimeout(notificationTimer);
227
- setNotificationTimer(setTimeout(() => {
228
- setNotificationStatus(false);
229
- clearTimeout(notificationTimer);
230
- }, delay));
231
- } else {
232
- setNotificationStatus(false);
233
- }
234
- };
235
- (0, import_react6.useEffect)(() => {
236
- return () => {
237
- clearTimeout(updateTimer);
238
- clearTimeout(notificationTimer);
239
- };
240
- }, []);
241
- return { restartTimer, clearUpdateTimer };
242
- }
243
- var useSaveDelay_default = useSaveDelay;
244
-
245
- // src/util/noop.ts
246
- var noop = () => void 0;
247
-
248
- // src/components/user-input/Label.tsx
249
- var import_jsx_runtime3 = require("react/jsx-runtime");
250
- var styleMapping = {
251
- labelSmall: "textstyle-label-sm",
252
- labelMedium: "textstyle-label-md",
253
- labelBig: "textstyle-label-lg"
254
- };
255
- var Label = ({
256
- children,
257
- name,
258
- labelType = "labelSmall",
259
- ...props
260
- }) => {
261
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("label", { ...props, children: children ? children : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: styleMapping[labelType], children: name }) });
262
- };
263
-
264
- // src/components/user-input/Input.tsx
265
- var import_jsx_runtime4 = require("react/jsx-runtime");
266
- var ControlledInput = ({
267
- id,
268
- type = "text",
269
- value,
270
- label,
271
- onChange = noop,
272
- onChangeEvent = noop,
273
- className = "",
274
- onEditCompleted,
275
- expanded = true,
276
- onBlur,
277
- containerClassName,
278
- ...restProps
279
- }) => {
280
- const {
281
- restartTimer,
282
- clearUpdateTimer
283
- } = useSaveDelay_default(() => void 0, 3e3);
284
- const ref = (0, import_react7.useRef)(null);
285
- (0, import_react7.useEffect)(() => {
286
- if (restProps.autoFocus) {
287
- ref.current?.focus();
288
- }
289
- }, [restProps.autoFocus]);
290
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: (0, import_clsx2.default)({ "w-full": expanded }, containerClassName), children: [
291
- label && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Label, { ...label, htmlFor: id, className: (0, import_clsx2.default)("mb-1", label.className) }),
292
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
293
- "input",
294
- {
295
- ref,
296
- value,
297
- id,
298
- type,
299
- className: (0, import_clsx2.default)("block bg-surface text-on-surface px-3 py-2 rounded-md w-full border-2 border-gray-200 hover:border-primary focus:outline-none focus:border-primary focus:ring-primary", className),
300
- onBlur: (event) => {
301
- if (onBlur) {
302
- onBlur(event);
303
- }
304
- if (onEditCompleted) {
305
- onEditCompleted(event.target.value, event);
306
- clearUpdateTimer();
307
- }
308
- },
309
- onChange: (e) => {
310
- const value2 = e.target.value;
311
- if (onEditCompleted) {
312
- restartTimer(() => {
313
- onEditCompleted(value2, e);
314
- clearUpdateTimer();
315
- });
316
- }
317
- onChange(value2, e);
318
- onChangeEvent(e);
319
- },
320
- ...restProps
321
- }
322
- )
323
- ] });
324
- };
325
- var FormInput = (0, import_react7.forwardRef)(function FormInput2({
326
- id,
327
- labelText,
328
- errorText,
329
- className,
330
- labelClassName,
331
- errorClassName,
332
- containerClassName,
333
- required,
334
- ...restProps
335
- }, ref) {
336
- const input = /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
337
- "input",
338
- {
339
- ref,
340
- id,
341
- ...restProps,
342
- className: (0, import_clsx2.default)(
343
- "block bg-surface text-on-surface px-3 py-2 rounded-md w-full border-2 border-gray-200 hover:border-primary focus:outline-none focus:border-primary focus:ring-primary",
344
- {
345
- "focus:border-primary focus:ring-primary": !errorText,
346
- "focus:border-negative focus:ring-negative text-negative": !!errorText
347
- },
348
- className
349
- )
350
- }
351
- );
352
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: (0, import_clsx2.default)("flex flex-col gap-y-1", containerClassName), children: [
353
- labelText && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("label", { htmlFor: id, className: (0, import_clsx2.default)("textstyle-label-md", labelClassName), children: [
354
- labelText,
355
- required && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "text-primary font-bold", children: "*" })
356
- ] }),
357
- input,
358
- errorText && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("label", { htmlFor: id, className: (0, import_clsx2.default)("text-negative", errorClassName), children: errorText })
359
- ] });
360
- });
361
-
362
- // src/components/user-input/Checkbox.tsx
363
- var import_react8 = require("react");
364
- var CheckboxPrimitive = __toESM(require("@radix-ui/react-checkbox"));
365
- var import_lucide_react = require("lucide-react");
366
- var import_clsx3 = __toESM(require("clsx"));
367
- var import_jsx_runtime5 = require("react/jsx-runtime");
368
- var checkboxSizeMapping = {
369
- small: "size-4",
370
- medium: "size-6",
371
- large: "size-8"
372
- };
373
- var checkboxIconSizeMapping = {
374
- small: "size-3",
375
- medium: "size-5",
376
- large: "size-7"
377
- };
378
- var ControlledCheckbox = ({
379
- id,
380
- label,
381
- checked,
382
- disabled,
383
- onChange,
384
- onChangeTristate,
385
- size = "medium",
386
- className = "",
387
- containerClassName
388
- }) => {
389
- const usedSizeClass = checkboxSizeMapping[size];
390
- const innerIconSize = checkboxIconSizeMapping[size];
391
- const propagateChange = (checked2) => {
392
- if (onChangeTristate) {
393
- onChangeTristate(checked2);
394
- }
395
- if (onChange) {
396
- onChange(checked2 === "indeterminate" ? false : checked2);
397
- }
398
- };
399
- const changeValue = () => {
400
- const newValue = checked === "indeterminate" ? false : !checked;
401
- propagateChange(newValue);
402
- };
403
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: (0, import_clsx3.default)("row justify-center items-center", containerClassName), children: [
404
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
405
- CheckboxPrimitive.Root,
406
- {
407
- onCheckedChange: propagateChange,
408
- checked,
409
- disabled,
410
- id,
411
- className: (0, import_clsx3.default)(usedSizeClass, `items-center border-2 rounded outline-none focus:border-primary`, {
412
- "text-disabled-text border-disabled-text": disabled,
413
- "border-on-background": !disabled,
414
- "bg-primary/30 border-primary text-primary": checked === true || checked === "indeterminate",
415
- "hover:border-gray-400 focus:hover:border-primary": !checked
416
- }, className),
417
- children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(CheckboxPrimitive.Indicator, { children: [
418
- checked === true && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react.Check, { className: innerIconSize }),
419
- checked === "indeterminate" && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react.Minus, { className: innerIconSize })
420
- ] })
421
- }
422
- ),
423
- label && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Label, { ...label, className: (0, import_clsx3.default)("cursor-pointer", label.className), htmlFor: id, onClick: changeValue })
424
- ] });
425
- };
426
-
427
- // src/components/user-input/MultiSelect.tsx
428
- var import_jsx_runtime6 = require("react/jsx-runtime");
429
- var defaultMultiSelectTranslation = {
430
- en: {
431
- select: "Select",
432
- search: "Search",
433
- selected: "selected"
434
- },
435
- de: {
436
- select: "Ausw\xE4hlen",
437
- search: "Suche",
438
- selected: "ausgew\xE4hlt"
439
- }
440
- };
441
- var MultiSelect = ({
442
- overwriteTranslation,
443
- options,
444
- onChange,
445
- search,
446
- disabled = false,
447
- selectedDisplay,
448
- label,
449
- hintText,
450
- showDisabledOptions = true,
451
- className = "",
452
- triggerClassName = ""
453
- }) => {
454
- const translation = useTranslation(defaultMultiSelectTranslation, overwriteTranslation);
455
- const [searchText, setSearchText] = (0, import_react9.useState)(search?.initialSearch ?? "");
456
- let filteredOptions = options;
457
- const enableSearch = !!search;
458
- if (enableSearch && !!searchText) {
459
- filteredOptions = MultiSearchWithMapping(
460
- searchText,
461
- filteredOptions,
462
- (value) => search.searchMapping(value)
463
- );
464
- }
465
- if (!showDisabledOptions) {
466
- filteredOptions = filteredOptions.filter((value) => !value.disabled);
467
- }
468
- const selectedItems = options.filter((value) => value.selected);
469
- const menuButtonText = selectedItems.length === 0 ? hintText ?? translation.select : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: `${selectedItems.length} ${translation.selected}` });
470
- const borderColor = "border-menu-border";
471
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: (0, import_clsx4.default)(className), children: [
472
- label && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
473
- Label,
474
- {
475
- ...label,
476
- htmlFor: label.name,
477
- className: (0, import_clsx4.default)(" mb-1", label.className),
478
- labelType: label.labelType ?? "labelBig"
479
- }
480
- ),
481
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
482
- Menu,
483
- {
484
- alignment: "t_",
485
- trigger: (onClick, ref) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
486
- "div",
487
- {
488
- ref,
489
- onClick: disabled ? void 0 : onClick,
490
- className: (0, import_clsx4.default)(
491
- borderColor,
492
- "bg-menu-background text-menu-text inline-w-full justify-between items-center rounded-lg border-2 px-4 py-2 font-medium",
493
- {
494
- "hover:brightness-90 hover:border-primary cursor-pointer": !disabled,
495
- "bg-disabled-background text-disabled cursor-not-allowed": disabled
496
- },
497
- triggerClassName
498
- ),
499
- children: selectedDisplay ? selectedDisplay({ items: options, disabled }) : menuButtonText
500
- }
501
- ),
502
- menuClassName: (0, import_clsx4.default)(
503
- "!rounded-lg !shadow-lg !max-h-[500px] !min-w-[400px] !max-w-[70vh] !overflow-y-auto !border !border-2",
504
- borderColor,
505
- { "!py-0": !enableSearch, "!pb-0": enableSearch }
506
- ),
507
- children: [
508
- enableSearch && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "row gap-x-2 items-center px-2 py-2", children: [
509
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ControlledInput, { autoFocus: true, value: searchText, onChange: setSearchText }),
510
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react2.Search, {})
511
- ] }, "selectSearch"),
512
- filteredOptions.map((option, index) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
513
- MenuItem,
514
- {
515
- className: (0, import_clsx4.default)({
516
- "cursor-not-allowed !bg-disabled-background !text-disabled-text hover:brightness-100": !!option.disabled,
517
- "cursor-pointer": !option.disabled
518
- }),
519
- children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
520
- "div",
521
- {
522
- className: (0, import_clsx4.default)("overflow-hidden whitespace-nowrap text-ellipsis row items-center gap-x-2", option.className),
523
- onClick: () => {
524
- if (!option.disabled) {
525
- onChange(options.map((value) => value.value === option.value ? {
526
- ...option,
527
- selected: !value.selected
528
- } : value));
529
- }
530
- },
531
- children: [
532
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ControlledCheckbox, { checked: option.selected, disabled: option.disabled, size: "small" }),
533
- option.label
534
- ]
535
- }
536
- )
537
- },
538
- `item${index}`
539
- ))
540
- ]
541
- }
542
- )
543
- ] });
544
- };
545
-
546
- // src/components/ChipList.tsx
547
- var import_clsx5 = __toESM(require("clsx"));
548
- var import_jsx_runtime7 = require("react/jsx-runtime");
549
- var Chip = ({
550
- children,
551
- trailingIcon,
552
- color = "default",
553
- variant = "normal",
554
- className = "",
555
- ...restProps
556
- }) => {
557
- const colorMapping = {
558
- default: "text-tag-default-text bg-tag-default-background",
559
- dark: "text-tag-dark-text bg-tag-dark-background",
560
- red: "text-tag-red-text bg-tag-red-background",
561
- yellow: "text-tag-yellow-text bg-tag-yellow-background",
562
- green: "text-tag-green-text bg-tag-green-background",
563
- blue: "text-tag-blue-text bg-tag-blue-background",
564
- pink: "text-tag-pink-text bg-tag-pink-background"
565
- }[color];
566
- const colorMappingIcon = {
567
- default: "text-tag-default-icon",
568
- dark: "text-tag-dark-icon",
569
- red: "text-tag-red-icon",
570
- yellow: "text-tag-yellow-icon",
571
- green: "text-tag-green-icon",
572
- blue: "text-tag-blue-icon",
573
- pink: "text-tag-pink-icon"
574
- }[color];
575
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
576
- "div",
577
- {
578
- ...restProps,
579
- className: (0, import_clsx5.default)(
580
- `row w-fit px-2 py-1`,
581
- colorMapping,
582
- {
583
- "rounded-md": variant === "normal",
584
- "rounded-full": variant === "fullyRounded"
585
- },
586
- className
587
- ),
588
- children: [
589
- children,
590
- trailingIcon && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: colorMappingIcon, children: trailingIcon })
591
- ]
592
- }
593
- );
594
- };
595
- var ChipList = ({
596
- list,
597
- className = ""
598
- }) => {
599
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: (0, import_clsx5.default)("flex flex-wrap gap-x-4 gap-y-2", className), children: list.map((value, index) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
600
- Chip,
601
- {
602
- ...value,
603
- color: value.color ?? "dark",
604
- variant: value.variant ?? "normal",
605
- children: value.children
606
- },
607
- index
608
- )) });
609
- };
610
-
611
- // src/components/examples/MultiSelectExample.tsx
612
- var import_jsx_runtime8 = require("react/jsx-runtime");
613
- var MultiSelectExample = ({
614
- options,
615
- hintText,
616
- enableSearch,
617
- onChange,
618
- useChipDisplay = false,
619
- ...props
620
- }) => {
621
- const [usedOptions, setUsedOptions] = (0, import_react10.useState)(options);
622
- (0, import_react10.useEffect)(() => {
623
- setUsedOptions(options);
624
- }, [options]);
625
- (0, import_react10.useEffect)(() => {
626
- setUsedOptions(options);
627
- }, [options]);
628
- (0, import_react10.useEffect)(() => {
629
- setUsedOptions(options.map((value) => ({ ...value, selected: false })));
630
- }, [hintText, options]);
631
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
632
- MultiSelect,
633
- {
634
- options: usedOptions,
635
- onChange: (value) => {
636
- onChange(value);
637
- setUsedOptions(value);
638
- },
639
- hintText,
640
- search: enableSearch ? { initialSearch: "", searchMapping: (value) => [value.label] } : void 0,
641
- selectedDisplay: useChipDisplay ? ({ items }) => {
642
- const selected = items.filter((value) => value.selected);
643
- if (selected.length === 0) {
644
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { children: "Select" });
645
- }
646
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
647
- ChipList,
648
- {
649
- list: selected.map((value) => ({ children: value.label }))
650
- }
651
- );
652
- } : void 0,
653
- ...props
654
- }
655
- );
656
- };
657
- // Annotate the CommonJS export names for ESM import in node:
658
- 0 && (module.exports = {
659
- MultiSelectExample
660
- });
661
- //# sourceMappingURL=MultiSelectExample.js.map