@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,818 +0,0 @@
1
- // src/components/examples/properties/MultiSelectPropertyExample.tsx
2
- import { useEffect as useEffect7, useState as useState8 } from "react";
3
-
4
- // src/components/properties/MultiSelectProperty.tsx
5
- import { List } from "lucide-react";
6
- import clsx8 from "clsx";
7
-
8
- // src/hooks/useLanguage.tsx
9
- import { createContext, useContext, useEffect as useEffect2, useState as useState2 } from "react";
10
-
11
- // src/hooks/useLocalStorage.tsx
12
- import { useCallback, useEffect, useState } from "react";
13
-
14
- // src/hooks/useLanguage.tsx
15
- import { jsx } from "react/jsx-runtime";
16
- var DEFAULT_LANGUAGE = "en";
17
- var LanguageContext = createContext({ language: DEFAULT_LANGUAGE, setLanguage: (v) => v });
18
- var useLanguage = () => useContext(LanguageContext);
19
-
20
- // src/hooks/useTranslation.ts
21
- var useTranslation = (defaults, translationOverwrite = {}) => {
22
- const { language: languageProp, translation: overwrite } = translationOverwrite;
23
- const { language: inferredLanguage } = useLanguage();
24
- const usedLanguage = languageProp ?? inferredLanguage;
25
- let defaultValues = defaults[usedLanguage];
26
- if (overwrite && overwrite[usedLanguage]) {
27
- defaultValues = { ...defaultValues, ...overwrite[usedLanguage] };
28
- }
29
- return defaultValues;
30
- };
31
-
32
- // src/components/user-input/MultiSelect.tsx
33
- import { useState as useState7 } from "react";
34
- import { Search } from "lucide-react";
35
-
36
- // src/util/simpleSearch.ts
37
- var MultiSearchWithMapping = (search, objects, mapping) => {
38
- return objects.filter((object) => {
39
- const mappedSearchKeywords = mapping(object).map((value) => value.toLowerCase().trim());
40
- return !!mappedSearchKeywords.find((value) => value.includes(search.toLowerCase().trim()));
41
- });
42
- };
43
-
44
- // src/components/user-input/MultiSelect.tsx
45
- import clsx4 from "clsx";
46
-
47
- // src/components/user-input/Menu.tsx
48
- import { useRef } from "react";
49
- import clsx from "clsx";
50
-
51
- // src/hooks/useOutsideClick.ts
52
- import { useEffect as useEffect3 } from "react";
53
- var useOutsideClick = (refs, handler) => {
54
- useEffect3(() => {
55
- const listener = (event) => {
56
- if (event.target === null) return;
57
- if (refs.some((ref) => !ref.current || ref.current.contains(event.target))) {
58
- return;
59
- }
60
- handler();
61
- };
62
- document.addEventListener("mousedown", listener);
63
- document.addEventListener("touchstart", listener);
64
- return () => {
65
- document.removeEventListener("mousedown", listener);
66
- document.removeEventListener("touchstart", listener);
67
- };
68
- }, [refs, handler]);
69
- };
70
-
71
- // src/hooks/useHoverState.ts
72
- import { useEffect as useEffect4, useState as useState3 } from "react";
73
- var defaultUseHoverStateProps = {
74
- closingDelay: 200,
75
- isDisabled: false
76
- };
77
- var useHoverState = (props = void 0) => {
78
- const { closingDelay, isDisabled } = { ...defaultUseHoverStateProps, ...props };
79
- const [isHovered, setIsHovered] = useState3(false);
80
- const [timer, setTimer] = useState3();
81
- const onMouseEnter = () => {
82
- if (isDisabled) {
83
- return;
84
- }
85
- clearTimeout(timer);
86
- setIsHovered(true);
87
- };
88
- const onMouseLeave = () => {
89
- if (isDisabled) {
90
- return;
91
- }
92
- setTimer(setTimeout(() => {
93
- setIsHovered(false);
94
- }, closingDelay));
95
- };
96
- useEffect4(() => {
97
- if (timer) {
98
- return () => {
99
- clearTimeout(timer);
100
- };
101
- }
102
- });
103
- useEffect4(() => {
104
- if (timer) {
105
- clearTimeout(timer);
106
- }
107
- }, [isDisabled]);
108
- return {
109
- isHovered,
110
- setIsHovered,
111
- handlers: { onMouseEnter, onMouseLeave }
112
- };
113
- };
114
-
115
- // src/components/user-input/Menu.tsx
116
- import { jsx as jsx2, jsxs } from "react/jsx-runtime";
117
- var MenuItem = ({
118
- children,
119
- onClick,
120
- alignment = "left",
121
- className
122
- }) => /* @__PURE__ */ jsx2(
123
- "div",
124
- {
125
- className: clsx("block px-3 py-1 bg-menu-background text-menu-text hover:brightness-90", {
126
- "text-right": alignment === "right",
127
- "text-left": alignment === "left"
128
- }, className),
129
- onClick,
130
- children
131
- }
132
- );
133
- var Menu = ({
134
- trigger,
135
- children,
136
- alignment = "tl",
137
- showOnHover = false,
138
- menuClassName = ""
139
- }) => {
140
- const { isHovered: isOpen, setIsHovered: setIsOpen, handlers } = useHoverState({ isDisabled: !showOnHover });
141
- const triggerRef = useRef(null);
142
- const menuRef = useRef(null);
143
- useOutsideClick([triggerRef, menuRef], () => setIsOpen(false));
144
- return /* @__PURE__ */ jsxs(
145
- "div",
146
- {
147
- className: "relative",
148
- ...handlers,
149
- children: [
150
- trigger(() => setIsOpen(!isOpen), triggerRef),
151
- isOpen ? /* @__PURE__ */ jsx2(
152
- "div",
153
- {
154
- ref: menuRef,
155
- onClick: (e) => e.stopPropagation(),
156
- className: clsx("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]", {
157
- " top-[8px]": alignment[0] === "t",
158
- " bottom-[8px]": alignment[0] === "b",
159
- " left-[-8px]": alignment[1] === "l",
160
- " right-[-8px]": alignment[1] === "r"
161
- }, menuClassName),
162
- children
163
- }
164
- ) : null
165
- ]
166
- }
167
- );
168
- };
169
-
170
- // src/components/user-input/Input.tsx
171
- import {
172
- useEffect as useEffect6,
173
- useRef as useRef2,
174
- useState as useState5,
175
- forwardRef
176
- } from "react";
177
- import clsx2 from "clsx";
178
-
179
- // src/hooks/useSaveDelay.ts
180
- import { useEffect as useEffect5, useState as useState4 } from "react";
181
- function useSaveDelay(setNotificationStatus, delay) {
182
- const [updateTimer, setUpdateTimer] = useState4(void 0);
183
- const [notificationTimer, setNotificationTimer] = useState4(void 0);
184
- const restartTimer = (onSave) => {
185
- clearTimeout(updateTimer);
186
- setUpdateTimer(setTimeout(() => {
187
- onSave();
188
- setNotificationStatus(true);
189
- clearTimeout(notificationTimer);
190
- setNotificationTimer(setTimeout(() => {
191
- setNotificationStatus(false);
192
- clearTimeout(notificationTimer);
193
- }, delay));
194
- clearTimeout(updateTimer);
195
- }, delay));
196
- };
197
- const clearUpdateTimer = (hasSaved = true) => {
198
- clearTimeout(updateTimer);
199
- if (hasSaved) {
200
- setNotificationStatus(true);
201
- clearTimeout(notificationTimer);
202
- setNotificationTimer(setTimeout(() => {
203
- setNotificationStatus(false);
204
- clearTimeout(notificationTimer);
205
- }, delay));
206
- } else {
207
- setNotificationStatus(false);
208
- }
209
- };
210
- useEffect5(() => {
211
- return () => {
212
- clearTimeout(updateTimer);
213
- clearTimeout(notificationTimer);
214
- };
215
- }, []);
216
- return { restartTimer, clearUpdateTimer };
217
- }
218
- var useSaveDelay_default = useSaveDelay;
219
-
220
- // src/util/noop.ts
221
- var noop = () => void 0;
222
-
223
- // src/components/user-input/Label.tsx
224
- import { jsx as jsx3 } from "react/jsx-runtime";
225
- var styleMapping = {
226
- labelSmall: "textstyle-label-sm",
227
- labelMedium: "textstyle-label-md",
228
- labelBig: "textstyle-label-lg"
229
- };
230
- var Label = ({
231
- children,
232
- name,
233
- labelType = "labelSmall",
234
- ...props
235
- }) => {
236
- return /* @__PURE__ */ jsx3("label", { ...props, children: children ? children : /* @__PURE__ */ jsx3("span", { className: styleMapping[labelType], children: name }) });
237
- };
238
-
239
- // src/components/user-input/Input.tsx
240
- import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
241
- var ControlledInput = ({
242
- id,
243
- type = "text",
244
- value,
245
- label,
246
- onChange = noop,
247
- onChangeEvent = noop,
248
- className = "",
249
- onEditCompleted,
250
- expanded = true,
251
- onBlur,
252
- containerClassName,
253
- ...restProps
254
- }) => {
255
- const {
256
- restartTimer,
257
- clearUpdateTimer
258
- } = useSaveDelay_default(() => void 0, 3e3);
259
- const ref = useRef2(null);
260
- useEffect6(() => {
261
- if (restProps.autoFocus) {
262
- ref.current?.focus();
263
- }
264
- }, [restProps.autoFocus]);
265
- return /* @__PURE__ */ jsxs2("div", { className: clsx2({ "w-full": expanded }, containerClassName), children: [
266
- label && /* @__PURE__ */ jsx4(Label, { ...label, htmlFor: id, className: clsx2("mb-1", label.className) }),
267
- /* @__PURE__ */ jsx4(
268
- "input",
269
- {
270
- ref,
271
- value,
272
- id,
273
- type,
274
- className: clsx2("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),
275
- onBlur: (event) => {
276
- if (onBlur) {
277
- onBlur(event);
278
- }
279
- if (onEditCompleted) {
280
- onEditCompleted(event.target.value, event);
281
- clearUpdateTimer();
282
- }
283
- },
284
- onChange: (e) => {
285
- const value2 = e.target.value;
286
- if (onEditCompleted) {
287
- restartTimer(() => {
288
- onEditCompleted(value2, e);
289
- clearUpdateTimer();
290
- });
291
- }
292
- onChange(value2, e);
293
- onChangeEvent(e);
294
- },
295
- ...restProps
296
- }
297
- )
298
- ] });
299
- };
300
- var FormInput = forwardRef(function FormInput2({
301
- id,
302
- labelText,
303
- errorText,
304
- className,
305
- labelClassName,
306
- errorClassName,
307
- containerClassName,
308
- required,
309
- ...restProps
310
- }, ref) {
311
- const input = /* @__PURE__ */ jsx4(
312
- "input",
313
- {
314
- ref,
315
- id,
316
- ...restProps,
317
- className: clsx2(
318
- "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",
319
- {
320
- "focus:border-primary focus:ring-primary": !errorText,
321
- "focus:border-negative focus:ring-negative text-negative": !!errorText
322
- },
323
- className
324
- )
325
- }
326
- );
327
- return /* @__PURE__ */ jsxs2("div", { className: clsx2("flex flex-col gap-y-1", containerClassName), children: [
328
- labelText && /* @__PURE__ */ jsxs2("label", { htmlFor: id, className: clsx2("textstyle-label-md", labelClassName), children: [
329
- labelText,
330
- required && /* @__PURE__ */ jsx4("span", { className: "text-primary font-bold", children: "*" })
331
- ] }),
332
- input,
333
- errorText && /* @__PURE__ */ jsx4("label", { htmlFor: id, className: clsx2("text-negative", errorClassName), children: errorText })
334
- ] });
335
- });
336
-
337
- // src/components/user-input/Checkbox.tsx
338
- import { useState as useState6 } from "react";
339
- import * as CheckboxPrimitive from "@radix-ui/react-checkbox";
340
- import { Check, Minus } from "lucide-react";
341
- import clsx3 from "clsx";
342
- import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
343
- var checkboxSizeMapping = {
344
- small: "size-4",
345
- medium: "size-6",
346
- large: "size-8"
347
- };
348
- var checkboxIconSizeMapping = {
349
- small: "size-3",
350
- medium: "size-5",
351
- large: "size-7"
352
- };
353
- var ControlledCheckbox = ({
354
- id,
355
- label,
356
- checked,
357
- disabled,
358
- onChange,
359
- onChangeTristate,
360
- size = "medium",
361
- className = "",
362
- containerClassName
363
- }) => {
364
- const usedSizeClass = checkboxSizeMapping[size];
365
- const innerIconSize = checkboxIconSizeMapping[size];
366
- const propagateChange = (checked2) => {
367
- if (onChangeTristate) {
368
- onChangeTristate(checked2);
369
- }
370
- if (onChange) {
371
- onChange(checked2 === "indeterminate" ? false : checked2);
372
- }
373
- };
374
- const changeValue = () => {
375
- const newValue = checked === "indeterminate" ? false : !checked;
376
- propagateChange(newValue);
377
- };
378
- return /* @__PURE__ */ jsxs3("div", { className: clsx3("row justify-center items-center", containerClassName), children: [
379
- /* @__PURE__ */ jsx5(
380
- CheckboxPrimitive.Root,
381
- {
382
- onCheckedChange: propagateChange,
383
- checked,
384
- disabled,
385
- id,
386
- className: clsx3(usedSizeClass, `items-center border-2 rounded outline-none focus:border-primary`, {
387
- "text-disabled-text border-disabled-text": disabled,
388
- "border-on-background": !disabled,
389
- "bg-primary/30 border-primary text-primary": checked === true || checked === "indeterminate",
390
- "hover:border-gray-400 focus:hover:border-primary": !checked
391
- }, className),
392
- children: /* @__PURE__ */ jsxs3(CheckboxPrimitive.Indicator, { children: [
393
- checked === true && /* @__PURE__ */ jsx5(Check, { className: innerIconSize }),
394
- checked === "indeterminate" && /* @__PURE__ */ jsx5(Minus, { className: innerIconSize })
395
- ] })
396
- }
397
- ),
398
- label && /* @__PURE__ */ jsx5(Label, { ...label, className: clsx3("cursor-pointer", label.className), htmlFor: id, onClick: changeValue })
399
- ] });
400
- };
401
-
402
- // src/components/user-input/MultiSelect.tsx
403
- import { jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
404
- var defaultMultiSelectTranslation = {
405
- en: {
406
- select: "Select",
407
- search: "Search",
408
- selected: "selected"
409
- },
410
- de: {
411
- select: "Ausw\xE4hlen",
412
- search: "Suche",
413
- selected: "ausgew\xE4hlt"
414
- }
415
- };
416
- var MultiSelect = ({
417
- overwriteTranslation,
418
- options,
419
- onChange,
420
- search,
421
- disabled = false,
422
- selectedDisplay,
423
- label,
424
- hintText,
425
- showDisabledOptions = true,
426
- className = "",
427
- triggerClassName = ""
428
- }) => {
429
- const translation = useTranslation(defaultMultiSelectTranslation, overwriteTranslation);
430
- const [searchText, setSearchText] = useState7(search?.initialSearch ?? "");
431
- let filteredOptions = options;
432
- const enableSearch = !!search;
433
- if (enableSearch && !!searchText) {
434
- filteredOptions = MultiSearchWithMapping(
435
- searchText,
436
- filteredOptions,
437
- (value) => search.searchMapping(value)
438
- );
439
- }
440
- if (!showDisabledOptions) {
441
- filteredOptions = filteredOptions.filter((value) => !value.disabled);
442
- }
443
- const selectedItems = options.filter((value) => value.selected);
444
- const menuButtonText = selectedItems.length === 0 ? hintText ?? translation.select : /* @__PURE__ */ jsx6("span", { children: `${selectedItems.length} ${translation.selected}` });
445
- const borderColor = "border-menu-border";
446
- return /* @__PURE__ */ jsxs4("div", { className: clsx4(className), children: [
447
- label && /* @__PURE__ */ jsx6(
448
- Label,
449
- {
450
- ...label,
451
- htmlFor: label.name,
452
- className: clsx4(" mb-1", label.className),
453
- labelType: label.labelType ?? "labelBig"
454
- }
455
- ),
456
- /* @__PURE__ */ jsxs4(
457
- Menu,
458
- {
459
- alignment: "t_",
460
- trigger: (onClick, ref) => /* @__PURE__ */ jsx6(
461
- "div",
462
- {
463
- ref,
464
- onClick: disabled ? void 0 : onClick,
465
- className: clsx4(
466
- borderColor,
467
- "bg-menu-background text-menu-text inline-w-full justify-between items-center rounded-lg border-2 px-4 py-2 font-medium",
468
- {
469
- "hover:brightness-90 hover:border-primary cursor-pointer": !disabled,
470
- "bg-disabled-background text-disabled cursor-not-allowed": disabled
471
- },
472
- triggerClassName
473
- ),
474
- children: selectedDisplay ? selectedDisplay({ items: options, disabled }) : menuButtonText
475
- }
476
- ),
477
- menuClassName: clsx4(
478
- "!rounded-lg !shadow-lg !max-h-[500px] !min-w-[400px] !max-w-[70vh] !overflow-y-auto !border !border-2",
479
- borderColor,
480
- { "!py-0": !enableSearch, "!pb-0": enableSearch }
481
- ),
482
- children: [
483
- enableSearch && /* @__PURE__ */ jsxs4("div", { className: "row gap-x-2 items-center px-2 py-2", children: [
484
- /* @__PURE__ */ jsx6(ControlledInput, { autoFocus: true, value: searchText, onChange: setSearchText }),
485
- /* @__PURE__ */ jsx6(Search, {})
486
- ] }, "selectSearch"),
487
- filteredOptions.map((option, index) => /* @__PURE__ */ jsx6(
488
- MenuItem,
489
- {
490
- className: clsx4({
491
- "cursor-not-allowed !bg-disabled-background !text-disabled-text hover:brightness-100": !!option.disabled,
492
- "cursor-pointer": !option.disabled
493
- }),
494
- children: /* @__PURE__ */ jsxs4(
495
- "div",
496
- {
497
- className: clsx4("overflow-hidden whitespace-nowrap text-ellipsis row items-center gap-x-2", option.className),
498
- onClick: () => {
499
- if (!option.disabled) {
500
- onChange(options.map((value) => value.value === option.value ? {
501
- ...option,
502
- selected: !value.selected
503
- } : value));
504
- }
505
- },
506
- children: [
507
- /* @__PURE__ */ jsx6(ControlledCheckbox, { checked: option.selected, disabled: option.disabled, size: "small" }),
508
- option.label
509
- ]
510
- }
511
- )
512
- },
513
- `item${index}`
514
- ))
515
- ]
516
- }
517
- )
518
- ] });
519
- };
520
-
521
- // src/components/ChipList.tsx
522
- import clsx5 from "clsx";
523
- import { jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
524
- var Chip = ({
525
- children,
526
- trailingIcon,
527
- color = "default",
528
- variant = "normal",
529
- className = "",
530
- ...restProps
531
- }) => {
532
- const colorMapping = {
533
- default: "text-tag-default-text bg-tag-default-background",
534
- dark: "text-tag-dark-text bg-tag-dark-background",
535
- red: "text-tag-red-text bg-tag-red-background",
536
- yellow: "text-tag-yellow-text bg-tag-yellow-background",
537
- green: "text-tag-green-text bg-tag-green-background",
538
- blue: "text-tag-blue-text bg-tag-blue-background",
539
- pink: "text-tag-pink-text bg-tag-pink-background"
540
- }[color];
541
- const colorMappingIcon = {
542
- default: "text-tag-default-icon",
543
- dark: "text-tag-dark-icon",
544
- red: "text-tag-red-icon",
545
- yellow: "text-tag-yellow-icon",
546
- green: "text-tag-green-icon",
547
- blue: "text-tag-blue-icon",
548
- pink: "text-tag-pink-icon"
549
- }[color];
550
- return /* @__PURE__ */ jsxs5(
551
- "div",
552
- {
553
- ...restProps,
554
- className: clsx5(
555
- `row w-fit px-2 py-1`,
556
- colorMapping,
557
- {
558
- "rounded-md": variant === "normal",
559
- "rounded-full": variant === "fullyRounded"
560
- },
561
- className
562
- ),
563
- children: [
564
- children,
565
- trailingIcon && /* @__PURE__ */ jsx7("span", { className: colorMappingIcon, children: trailingIcon })
566
- ]
567
- }
568
- );
569
- };
570
- var ChipList = ({
571
- list,
572
- className = ""
573
- }) => {
574
- return /* @__PURE__ */ jsx7("div", { className: clsx5("flex flex-wrap gap-x-4 gap-y-2", className), children: list.map((value, index) => /* @__PURE__ */ jsx7(
575
- Chip,
576
- {
577
- ...value,
578
- color: value.color ?? "dark",
579
- variant: value.variant ?? "normal",
580
- children: value.children
581
- },
582
- index
583
- )) });
584
- };
585
-
586
- // src/components/properties/PropertyBase.tsx
587
- import { AlertTriangle } from "lucide-react";
588
- import clsx7 from "clsx";
589
-
590
- // src/components/Button.tsx
591
- import clsx6 from "clsx";
592
- import { jsx as jsx8, jsxs as jsxs6 } from "react/jsx-runtime";
593
- var ButtonSizePaddings = {
594
- small: "btn-sm",
595
- medium: "btn-md",
596
- large: "btn-lg"
597
- };
598
- var TextButton = ({
599
- children,
600
- disabled = false,
601
- color = "neutral",
602
- size = "medium",
603
- startIcon,
604
- endIcon,
605
- onClick,
606
- className,
607
- ...restProps
608
- }) => {
609
- const colorClasses = {
610
- negative: "bg-transparent text-button-text-negative-text",
611
- neutral: "bg-transparent text-button-text-neutral-text"
612
- }[color];
613
- const iconColorClasses = {
614
- negative: "text-button-text-negative-icon",
615
- neutral: "text-button-text-neutral-icon"
616
- }[color];
617
- return /* @__PURE__ */ jsxs6(
618
- "button",
619
- {
620
- onClick: disabled ? void 0 : onClick,
621
- disabled: disabled || onClick === void 0,
622
- className: clsx6(
623
- className,
624
- {
625
- "text-disabled-text": disabled,
626
- [clsx6(colorClasses, "hover:bg-button-text-hover-background rounded-full")]: !disabled
627
- },
628
- ButtonSizePaddings[size]
629
- ),
630
- ...restProps,
631
- children: [
632
- startIcon && /* @__PURE__ */ jsx8(
633
- "span",
634
- {
635
- className: clsx6({
636
- [iconColorClasses]: !disabled,
637
- [`text-disabled-icon`]: disabled
638
- }),
639
- children: startIcon
640
- }
641
- ),
642
- children,
643
- endIcon && /* @__PURE__ */ jsx8(
644
- "span",
645
- {
646
- className: clsx6({
647
- [iconColorClasses]: !disabled,
648
- [`text-disabled-icon`]: disabled
649
- }),
650
- children: endIcon
651
- }
652
- )
653
- ]
654
- }
655
- );
656
- };
657
-
658
- // src/components/properties/PropertyBase.tsx
659
- import { jsx as jsx9, jsxs as jsxs7 } from "react/jsx-runtime";
660
- var defaultPropertyBaseTranslation = {
661
- en: {
662
- remove: "Remove"
663
- },
664
- de: {
665
- remove: "Entfernen"
666
- }
667
- };
668
- var PropertyBase = ({
669
- overwriteTranslation,
670
- name,
671
- input,
672
- softRequired = false,
673
- hasValue,
674
- icon,
675
- readOnly,
676
- onRemove,
677
- className = ""
678
- }) => {
679
- const translation = useTranslation(defaultPropertyBaseTranslation, overwriteTranslation);
680
- const requiredAndNoValue = softRequired && !hasValue;
681
- return /* @__PURE__ */ jsxs7("div", { className: clsx7("row gap-x-0 group", className), children: [
682
- /* @__PURE__ */ jsxs7(
683
- "div",
684
- {
685
- className: clsx7("row gap-x-2 !w-[200px] px-4 py-2 items-center rounded-l-xl border-2 border-r-0", {
686
- "bg-gray-100 text-black group-hover:border-primary border-gray-400": !requiredAndNoValue,
687
- "bg-warning text-surface-warning group-hover:border-warning border-warning/90": requiredAndNoValue
688
- }, className),
689
- children: [
690
- icon,
691
- name
692
- ]
693
- }
694
- ),
695
- /* @__PURE__ */ jsxs7(
696
- "div",
697
- {
698
- className: clsx7("row grow justify-between items-center rounded-r-xl border-2 border-l-0", {
699
- "bg-white group-hover:border-primary border-gray-400": !requiredAndNoValue,
700
- "bg-surface-warning group-hover:border-warning border-warning/90": requiredAndNoValue
701
- }, className),
702
- children: [
703
- input({ softRequired, hasValue }),
704
- requiredAndNoValue && /* @__PURE__ */ jsx9("div", { className: "text-warning pr-4", children: /* @__PURE__ */ jsx9(AlertTriangle, { size: 24 }) }),
705
- onRemove && /* @__PURE__ */ jsx9(
706
- TextButton,
707
- {
708
- onClick: onRemove,
709
- color: "negative",
710
- className: clsx7("pr-4 items-center", { "!text-transparent": !hasValue || readOnly }),
711
- disabled: !hasValue || readOnly,
712
- children: translation.remove
713
- }
714
- )
715
- ]
716
- }
717
- )
718
- ] });
719
- };
720
-
721
- // src/components/properties/MultiSelectProperty.tsx
722
- import { jsx as jsx10 } from "react/jsx-runtime";
723
- var defaultMultiSelectPropertyTranslation = {
724
- en: {
725
- select: "Select"
726
- },
727
- de: {
728
- select: "Ausw\xE4hlen"
729
- }
730
- };
731
- var MultiSelectProperty = ({
732
- overwriteTranslation,
733
- options,
734
- name,
735
- readOnly = false,
736
- softRequired,
737
- onRemove,
738
- ...multiSelectProps
739
- }) => {
740
- const translation = useTranslation(defaultMultiSelectPropertyTranslation, overwriteTranslation);
741
- const hasValue = options.some((value) => value.selected);
742
- let triggerClassName;
743
- if (softRequired && !hasValue) {
744
- triggerClassName = "border-warning hover:brightness-90";
745
- }
746
- return /* @__PURE__ */ jsx10(
747
- PropertyBase,
748
- {
749
- name,
750
- onRemove,
751
- readOnly,
752
- softRequired,
753
- hasValue,
754
- icon: /* @__PURE__ */ jsx10(List, { size: 16 }),
755
- input: ({ softRequired: softRequired2 }) => /* @__PURE__ */ jsx10(
756
- "div",
757
- {
758
- className: clsx8("row grow py-2 px-4 cursor-pointer", { "text-warning": softRequired2 && !hasValue }),
759
- children: /* @__PURE__ */ jsx10(
760
- MultiSelect,
761
- {
762
- ...multiSelectProps,
763
- className: clsx8("w-full", { "bg-surface-warning": softRequired2 && !hasValue }),
764
- triggerClassName,
765
- selectedDisplay: ({ items }) => {
766
- const selected = items.filter((value) => value.selected);
767
- if (selected.length === 0) {
768
- return /* @__PURE__ */ jsx10("span", { children: "Select" });
769
- }
770
- return /* @__PURE__ */ jsx10(
771
- ChipList,
772
- {
773
- list: selected.map((value) => ({ children: value.label }))
774
- }
775
- );
776
- },
777
- options,
778
- disabled: readOnly,
779
- hintText: `${translation.select}...`
780
- }
781
- )
782
- }
783
- )
784
- }
785
- );
786
- };
787
-
788
- // src/components/examples/properties/MultiSelectPropertyExample.tsx
789
- import { jsx as jsx11 } from "react/jsx-runtime";
790
- var MultiSelectPropertyExample = ({
791
- options,
792
- hintText,
793
- enableSearch,
794
- ...restProps
795
- }) => {
796
- const [usedOptions, setUsedOptions] = useState8(options);
797
- useEffect7(() => {
798
- setUsedOptions(options);
799
- }, [options]);
800
- useEffect7(() => {
801
- setUsedOptions(options.map((value) => ({ ...value, selected: false })));
802
- }, [hintText, options]);
803
- return /* @__PURE__ */ jsx11(
804
- MultiSelectProperty,
805
- {
806
- ...restProps,
807
- options: usedOptions,
808
- search: enableSearch ? { initialSearch: "", searchMapping: (value) => [value.label] } : void 0,
809
- onChange: setUsedOptions,
810
- onRemove: () => setUsedOptions(usedOptions.map((value) => ({ ...value, selected: false }))),
811
- hintText
812
- }
813
- );
814
- };
815
- export {
816
- MultiSelectPropertyExample
817
- };
818
- //# sourceMappingURL=MultiSelectPropertyExample.mjs.map