@helpwave/hightide 0.1.7 → 0.1.9

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 (263) hide show
  1. package/dist/components/branding/HelpwaveBadge.js +30 -8
  2. package/dist/components/branding/HelpwaveBadge.js.map +1 -1
  3. package/dist/components/branding/HelpwaveBadge.mjs +30 -8
  4. package/dist/components/branding/HelpwaveBadge.mjs.map +1 -1
  5. package/dist/components/date/DatePicker.d.mts +3 -4
  6. package/dist/components/date/DatePicker.d.ts +3 -4
  7. package/dist/components/date/DatePicker.js +135 -33
  8. package/dist/components/date/DatePicker.js.map +1 -1
  9. package/dist/components/date/DatePicker.mjs +135 -33
  10. package/dist/components/date/DatePicker.mjs.map +1 -1
  11. package/dist/components/date/DayPicker.d.mts +1 -1
  12. package/dist/components/date/DayPicker.d.ts +1 -1
  13. package/dist/components/date/DayPicker.js +23 -11
  14. package/dist/components/date/DayPicker.js.map +1 -1
  15. package/dist/components/date/DayPicker.mjs +23 -11
  16. package/dist/components/date/DayPicker.mjs.map +1 -1
  17. package/dist/components/date/TimeDisplay.d.mts +5 -19
  18. package/dist/components/date/TimeDisplay.d.ts +5 -19
  19. package/dist/components/date/TimeDisplay.js +121 -37
  20. package/dist/components/date/TimeDisplay.js.map +1 -1
  21. package/dist/components/date/TimeDisplay.mjs +121 -37
  22. package/dist/components/date/TimeDisplay.mjs.map +1 -1
  23. package/dist/components/date/YearMonthPicker.js +106 -22
  24. package/dist/components/date/YearMonthPicker.js.map +1 -1
  25. package/dist/components/date/YearMonthPicker.mjs +106 -22
  26. package/dist/components/date/YearMonthPicker.mjs.map +1 -1
  27. package/dist/components/dialogs/ConfirmDialog.d.mts +2 -5
  28. package/dist/components/dialogs/ConfirmDialog.d.ts +2 -5
  29. package/dist/components/dialogs/ConfirmDialog.js +157 -25
  30. package/dist/components/dialogs/ConfirmDialog.js.map +1 -1
  31. package/dist/components/dialogs/ConfirmDialog.mjs +157 -25
  32. package/dist/components/dialogs/ConfirmDialog.mjs.map +1 -1
  33. package/dist/components/icons-and-geometry/Avatar.js +2 -2
  34. package/dist/components/icons-and-geometry/Avatar.js.map +1 -1
  35. package/dist/components/icons-and-geometry/Avatar.mjs +2 -2
  36. package/dist/components/icons-and-geometry/Avatar.mjs.map +1 -1
  37. package/dist/components/layout-and-navigation/Carousel.d.mts +1 -1
  38. package/dist/components/layout-and-navigation/Carousel.d.ts +1 -1
  39. package/dist/components/layout-and-navigation/Carousel.js +86 -28
  40. package/dist/components/layout-and-navigation/Carousel.js.map +1 -1
  41. package/dist/components/layout-and-navigation/Carousel.mjs +86 -28
  42. package/dist/components/layout-and-navigation/Carousel.mjs.map +1 -1
  43. package/dist/components/layout-and-navigation/Expandable.d.mts +3 -0
  44. package/dist/components/layout-and-navigation/Expandable.d.ts +3 -0
  45. package/dist/components/layout-and-navigation/Expandable.js +4 -3
  46. package/dist/components/layout-and-navigation/Expandable.js.map +1 -1
  47. package/dist/components/layout-and-navigation/Expandable.mjs +4 -3
  48. package/dist/components/layout-and-navigation/Expandable.mjs.map +1 -1
  49. package/dist/components/layout-and-navigation/FAQSection.js +4 -3
  50. package/dist/components/layout-and-navigation/FAQSection.js.map +1 -1
  51. package/dist/components/layout-and-navigation/FAQSection.mjs +4 -3
  52. package/dist/components/layout-and-navigation/FAQSection.mjs.map +1 -1
  53. package/dist/components/layout-and-navigation/Overlay.d.mts +2 -3
  54. package/dist/components/layout-and-navigation/Overlay.d.ts +2 -3
  55. package/dist/components/layout-and-navigation/Overlay.js +152 -12
  56. package/dist/components/layout-and-navigation/Overlay.js.map +1 -1
  57. package/dist/components/layout-and-navigation/Overlay.mjs +152 -12
  58. package/dist/components/layout-and-navigation/Overlay.mjs.map +1 -1
  59. package/dist/components/layout-and-navigation/Pagination.d.mts +2 -3
  60. package/dist/components/layout-and-navigation/Pagination.d.ts +2 -3
  61. package/dist/components/layout-and-navigation/Pagination.js +145 -13
  62. package/dist/components/layout-and-navigation/Pagination.js.map +1 -1
  63. package/dist/components/layout-and-navigation/Pagination.mjs +145 -13
  64. package/dist/components/layout-and-navigation/Pagination.mjs.map +1 -1
  65. package/dist/components/layout-and-navigation/SearchableList.d.mts +10 -8
  66. package/dist/components/layout-and-navigation/SearchableList.d.ts +10 -8
  67. package/dist/components/layout-and-navigation/SearchableList.js +261 -30
  68. package/dist/components/layout-and-navigation/SearchableList.js.map +1 -1
  69. package/dist/components/layout-and-navigation/SearchableList.mjs +261 -30
  70. package/dist/components/layout-and-navigation/SearchableList.mjs.map +1 -1
  71. package/dist/components/layout-and-navigation/StepperBar.d.mts +2 -5
  72. package/dist/components/layout-and-navigation/StepperBar.d.ts +2 -5
  73. package/dist/components/layout-and-navigation/StepperBar.js +149 -19
  74. package/dist/components/layout-and-navigation/StepperBar.js.map +1 -1
  75. package/dist/components/layout-and-navigation/StepperBar.mjs +149 -19
  76. package/dist/components/layout-and-navigation/StepperBar.mjs.map +1 -1
  77. package/dist/components/layout-and-navigation/Table.js +146 -14
  78. package/dist/components/layout-and-navigation/Table.js.map +1 -1
  79. package/dist/components/layout-and-navigation/Table.mjs +146 -14
  80. package/dist/components/layout-and-navigation/Table.mjs.map +1 -1
  81. package/dist/components/layout-and-navigation/TextImage.d.mts +3 -4
  82. package/dist/components/layout-and-navigation/TextImage.d.ts +3 -4
  83. package/dist/components/layout-and-navigation/TextImage.js +153 -19
  84. package/dist/components/layout-and-navigation/TextImage.js.map +1 -1
  85. package/dist/components/layout-and-navigation/TextImage.mjs +153 -19
  86. package/dist/components/layout-and-navigation/TextImage.mjs.map +1 -1
  87. package/dist/components/layout-and-navigation/Tile.d.mts +10 -15
  88. package/dist/components/layout-and-navigation/Tile.d.ts +10 -15
  89. package/dist/components/layout-and-navigation/Tile.js +30 -8
  90. package/dist/components/layout-and-navigation/Tile.js.map +1 -1
  91. package/dist/components/layout-and-navigation/Tile.mjs +30 -8
  92. package/dist/components/layout-and-navigation/Tile.mjs.map +1 -1
  93. package/dist/components/loading-states/ErrorComponent.js +48 -8
  94. package/dist/components/loading-states/ErrorComponent.js.map +1 -1
  95. package/dist/components/loading-states/ErrorComponent.mjs +48 -8
  96. package/dist/components/loading-states/ErrorComponent.mjs.map +1 -1
  97. package/dist/components/loading-states/LoadingAndErrorComponent.d.mts +1 -0
  98. package/dist/components/loading-states/LoadingAndErrorComponent.d.ts +1 -0
  99. package/dist/components/loading-states/LoadingAndErrorComponent.js +147 -15
  100. package/dist/components/loading-states/LoadingAndErrorComponent.js.map +1 -1
  101. package/dist/components/loading-states/LoadingAndErrorComponent.mjs +147 -15
  102. package/dist/components/loading-states/LoadingAndErrorComponent.mjs.map +1 -1
  103. package/dist/components/loading-states/LoadingAnimation.d.mts +2 -3
  104. package/dist/components/loading-states/LoadingAnimation.d.ts +2 -3
  105. package/dist/components/loading-states/LoadingAnimation.js +145 -13
  106. package/dist/components/loading-states/LoadingAnimation.js.map +1 -1
  107. package/dist/components/loading-states/LoadingAnimation.mjs +145 -13
  108. package/dist/components/loading-states/LoadingAnimation.mjs.map +1 -1
  109. package/dist/components/loading-states/ProgressIndicator.js +2 -2
  110. package/dist/components/loading-states/ProgressIndicator.js.map +1 -1
  111. package/dist/components/loading-states/ProgressIndicator.mjs +2 -2
  112. package/dist/components/loading-states/ProgressIndicator.mjs.map +1 -1
  113. package/dist/components/modals/ConfirmModal.d.mts +2 -5
  114. package/dist/components/modals/ConfirmModal.d.ts +2 -5
  115. package/dist/components/modals/ConfirmModal.js +158 -28
  116. package/dist/components/modals/ConfirmModal.js.map +1 -1
  117. package/dist/components/modals/ConfirmModal.mjs +158 -28
  118. package/dist/components/modals/ConfirmModal.mjs.map +1 -1
  119. package/dist/components/modals/DiscardChangesModal.d.mts +2 -7
  120. package/dist/components/modals/DiscardChangesModal.d.ts +2 -7
  121. package/dist/components/modals/DiscardChangesModal.js +162 -48
  122. package/dist/components/modals/DiscardChangesModal.js.map +1 -1
  123. package/dist/components/modals/DiscardChangesModal.mjs +162 -48
  124. package/dist/components/modals/DiscardChangesModal.mjs.map +1 -1
  125. package/dist/components/modals/InputModal.d.mts +1 -0
  126. package/dist/components/modals/InputModal.d.ts +1 -0
  127. package/dist/components/modals/InputModal.js +158 -28
  128. package/dist/components/modals/InputModal.js.map +1 -1
  129. package/dist/components/modals/InputModal.mjs +158 -28
  130. package/dist/components/modals/InputModal.mjs.map +1 -1
  131. package/dist/components/modals/LanguageModal.d.mts +3 -2
  132. package/dist/components/modals/LanguageModal.d.ts +3 -2
  133. package/dist/components/modals/LanguageModal.js +538 -166
  134. package/dist/components/modals/LanguageModal.js.map +1 -1
  135. package/dist/components/modals/LanguageModal.mjs +537 -165
  136. package/dist/components/modals/LanguageModal.mjs.map +1 -1
  137. package/dist/components/modals/ThemeModal.d.mts +5 -5
  138. package/dist/components/modals/ThemeModal.d.ts +5 -5
  139. package/dist/components/modals/ThemeModal.js +547 -176
  140. package/dist/components/modals/ThemeModal.js.map +1 -1
  141. package/dist/components/modals/ThemeModal.mjs +544 -173
  142. package/dist/components/modals/ThemeModal.mjs.map +1 -1
  143. package/dist/components/properties/CheckboxProperty.d.mts +3 -5
  144. package/dist/components/properties/CheckboxProperty.d.ts +3 -5
  145. package/dist/components/properties/CheckboxProperty.js +148 -26
  146. package/dist/components/properties/CheckboxProperty.js.map +1 -1
  147. package/dist/components/properties/CheckboxProperty.mjs +148 -26
  148. package/dist/components/properties/CheckboxProperty.mjs.map +1 -1
  149. package/dist/components/properties/DateProperty.d.mts +1 -0
  150. package/dist/components/properties/DateProperty.d.ts +1 -0
  151. package/dist/components/properties/DateProperty.js +146 -14
  152. package/dist/components/properties/DateProperty.js.map +1 -1
  153. package/dist/components/properties/DateProperty.mjs +146 -14
  154. package/dist/components/properties/DateProperty.mjs.map +1 -1
  155. package/dist/components/properties/MultiSelectProperty.d.mts +5 -5
  156. package/dist/components/properties/MultiSelectProperty.d.ts +5 -5
  157. package/dist/components/properties/MultiSelectProperty.js +626 -456
  158. package/dist/components/properties/MultiSelectProperty.js.map +1 -1
  159. package/dist/components/properties/MultiSelectProperty.mjs +622 -452
  160. package/dist/components/properties/MultiSelectProperty.mjs.map +1 -1
  161. package/dist/components/properties/NumberProperty.d.mts +1 -0
  162. package/dist/components/properties/NumberProperty.d.ts +1 -0
  163. package/dist/components/properties/NumberProperty.js +148 -16
  164. package/dist/components/properties/NumberProperty.js.map +1 -1
  165. package/dist/components/properties/NumberProperty.mjs +148 -16
  166. package/dist/components/properties/NumberProperty.mjs.map +1 -1
  167. package/dist/components/properties/PropertyBase.d.mts +2 -3
  168. package/dist/components/properties/PropertyBase.d.ts +2 -3
  169. package/dist/components/properties/PropertyBase.js +146 -14
  170. package/dist/components/properties/PropertyBase.js.map +1 -1
  171. package/dist/components/properties/PropertyBase.mjs +146 -14
  172. package/dist/components/properties/PropertyBase.mjs.map +1 -1
  173. package/dist/components/properties/SelectProperty.d.mts +5 -6
  174. package/dist/components/properties/SelectProperty.d.ts +5 -6
  175. package/dist/components/properties/SelectProperty.js +542 -279
  176. package/dist/components/properties/SelectProperty.js.map +1 -1
  177. package/dist/components/properties/SelectProperty.mjs +542 -279
  178. package/dist/components/properties/SelectProperty.mjs.map +1 -1
  179. package/dist/components/properties/TextProperty.d.mts +2 -1
  180. package/dist/components/properties/TextProperty.d.ts +2 -1
  181. package/dist/components/properties/TextProperty.js +150 -18
  182. package/dist/components/properties/TextProperty.js.map +1 -1
  183. package/dist/components/properties/TextProperty.mjs +150 -18
  184. package/dist/components/properties/TextProperty.mjs.map +1 -1
  185. package/dist/components/user-action/DateAndTimePicker.d.mts +4 -20
  186. package/dist/components/user-action/DateAndTimePicker.d.ts +4 -20
  187. package/dist/components/user-action/DateAndTimePicker.js +233 -71
  188. package/dist/components/user-action/DateAndTimePicker.js.map +1 -1
  189. package/dist/components/user-action/DateAndTimePicker.mjs +233 -71
  190. package/dist/components/user-action/DateAndTimePicker.mjs.map +1 -1
  191. package/dist/components/user-action/Menu.d.mts +14 -8
  192. package/dist/components/user-action/Menu.d.ts +14 -8
  193. package/dist/components/user-action/Menu.js +32 -11
  194. package/dist/components/user-action/Menu.js.map +1 -1
  195. package/dist/components/user-action/Menu.mjs +32 -11
  196. package/dist/components/user-action/Menu.mjs.map +1 -1
  197. package/dist/components/user-action/MultiSelect.d.mts +13 -23
  198. package/dist/components/user-action/MultiSelect.d.ts +13 -23
  199. package/dist/components/user-action/MultiSelect.js +632 -325
  200. package/dist/components/user-action/MultiSelect.js.map +1 -1
  201. package/dist/components/user-action/MultiSelect.mjs +629 -323
  202. package/dist/components/user-action/MultiSelect.mjs.map +1 -1
  203. package/dist/components/user-action/Select.d.mts +5 -18
  204. package/dist/components/user-action/Select.d.ts +5 -18
  205. package/dist/components/user-action/Select.js +447 -113
  206. package/dist/components/user-action/Select.js.map +1 -1
  207. package/dist/components/user-action/Select.mjs +442 -107
  208. package/dist/components/user-action/Select.mjs.map +1 -1
  209. package/dist/components/user-action/Tooltip.js +2 -2
  210. package/dist/components/user-action/Tooltip.js.map +1 -1
  211. package/dist/components/user-action/Tooltip.mjs +2 -2
  212. package/dist/components/user-action/Tooltip.mjs.map +1 -1
  213. package/dist/css/globals.css +224 -207
  214. package/dist/css/uncompiled/globals.css +138 -74
  215. package/dist/hooks/useSearch.d.mts +17 -0
  216. package/dist/hooks/useSearch.d.ts +17 -0
  217. package/dist/hooks/useSearch.js +66 -0
  218. package/dist/hooks/useSearch.js.map +1 -0
  219. package/dist/hooks/useSearch.mjs +42 -0
  220. package/dist/hooks/useSearch.mjs.map +1 -0
  221. package/dist/index.d.mts +10 -6
  222. package/dist/index.d.ts +10 -6
  223. package/dist/index.js +882 -758
  224. package/dist/index.js.map +1 -1
  225. package/dist/index.mjs +836 -717
  226. package/dist/index.mjs.map +1 -1
  227. package/dist/localization/defaults/form.d.mts +54 -0
  228. package/dist/localization/defaults/form.d.ts +54 -0
  229. package/dist/localization/defaults/form.js +127 -0
  230. package/dist/localization/defaults/form.js.map +1 -0
  231. package/dist/localization/defaults/form.mjs +103 -0
  232. package/dist/localization/defaults/form.mjs.map +1 -0
  233. package/dist/localization/defaults/time.d.mts +39 -0
  234. package/dist/localization/defaults/time.d.ts +39 -0
  235. package/dist/localization/defaults/time.js +101 -0
  236. package/dist/localization/defaults/time.js.map +1 -0
  237. package/dist/localization/defaults/time.mjs +76 -0
  238. package/dist/localization/defaults/time.mjs.map +1 -0
  239. package/dist/localization/useTranslation.d.mts +30 -6
  240. package/dist/localization/useTranslation.d.ts +30 -6
  241. package/dist/localization/useTranslation.js +46 -6
  242. package/dist/localization/useTranslation.js.map +1 -1
  243. package/dist/localization/useTranslation.mjs +46 -6
  244. package/dist/localization/useTranslation.mjs.map +1 -1
  245. package/dist/theming/useTheme.d.mts +4 -2
  246. package/dist/theming/useTheme.d.ts +4 -2
  247. package/dist/theming/useTheme.js +10 -2
  248. package/dist/theming/useTheme.js.map +1 -1
  249. package/dist/theming/useTheme.mjs +10 -2
  250. package/dist/theming/useTheme.mjs.map +1 -1
  251. package/dist/util/PropsWithFunctionChildren.d.mts +14 -0
  252. package/dist/util/PropsWithFunctionChildren.d.ts +14 -0
  253. package/dist/util/PropsWithFunctionChildren.js +38 -0
  254. package/dist/util/PropsWithFunctionChildren.js.map +1 -0
  255. package/dist/util/PropsWithFunctionChildren.mjs +14 -0
  256. package/dist/util/PropsWithFunctionChildren.mjs.map +1 -0
  257. package/dist/util/simpleSearch.d.mts +2 -2
  258. package/dist/util/simpleSearch.d.ts +2 -2
  259. package/dist/util/simpleSearch.js +4 -1
  260. package/dist/util/simpleSearch.js.map +1 -1
  261. package/dist/util/simpleSearch.mjs +4 -1
  262. package/dist/util/simpleSearch.mjs.map +1 -1
  263. package/package.json +1 -2
@@ -1,6 +1,6 @@
1
1
  // src/components/user-action/MultiSelect.tsx
2
- import { useState as useState7 } from "react";
3
- import { Search } from "lucide-react";
2
+ import { useEffect as useEffect7, useRef as useRef2, useState as useState6 } from "react";
3
+ import { ChevronDown, ChevronUp } from "lucide-react";
4
4
 
5
5
  // src/localization/LanguageProvider.tsx
6
6
  import { createContext, useContext, useEffect as useEffect2, useState as useState2 } from "react";
@@ -30,160 +30,91 @@ var LanguageContext = createContext({
30
30
  var useLanguage = () => useContext(LanguageContext);
31
31
 
32
32
  // src/localization/useTranslation.ts
33
- var useTranslation = (defaults, translationOverwrite = {}) => {
34
- const { language: languageProp, translation: overwrite } = translationOverwrite;
33
+ var useTranslation = (translations, overwriteTranslation = {}) => {
34
+ const { language: languageProp, translation: overwrite } = overwriteTranslation;
35
35
  const { language: inferredLanguage } = useLanguage();
36
36
  const usedLanguage = languageProp ?? inferredLanguage;
37
- let defaultValues = defaults[usedLanguage];
38
- if (overwrite && overwrite[usedLanguage]) {
39
- defaultValues = { ...defaultValues, ...overwrite[usedLanguage] };
37
+ const usedTranslations = [...translations];
38
+ if (overwrite) {
39
+ usedTranslations.push(overwrite);
40
40
  }
41
- return defaultValues;
42
- };
43
-
44
- // src/util/simpleSearch.ts
45
- var MultiSearchWithMapping = (search, objects, mapping) => {
46
- return objects.filter((object) => {
47
- const mappedSearchKeywords = mapping(object).map((value) => value.toLowerCase().trim());
48
- return !!mappedSearchKeywords.find((value) => value.includes(search.toLowerCase().trim()));
49
- });
41
+ return (key, options) => {
42
+ const { count, replacements } = { ...{ count: 0, replacements: {} }, ...options };
43
+ try {
44
+ for (let i = translations.length - 1; i >= 0; i--) {
45
+ const translation = translations[i];
46
+ const localizedTranslation = translation[usedLanguage];
47
+ if (!localizedTranslation) {
48
+ continue;
49
+ }
50
+ const value = localizedTranslation[key];
51
+ if (!value) {
52
+ continue;
53
+ }
54
+ let forProcessing;
55
+ if (typeof value !== "string") {
56
+ if (count <= 0 && value?.zero) {
57
+ forProcessing = value.zero;
58
+ } else if (count === 1 && value?.one) {
59
+ forProcessing = value.one;
60
+ } else if (count === 2 && value?.two) {
61
+ forProcessing = value.two;
62
+ } else if (count <= 10 && value?.few) {
63
+ forProcessing = value.few;
64
+ } else if (count > 10 && value?.many) {
65
+ forProcessing = value.many;
66
+ } else {
67
+ forProcessing = value.other;
68
+ }
69
+ } else {
70
+ forProcessing = value;
71
+ }
72
+ forProcessing = forProcessing.replace(/\{\{(\w+)}}/g, (_, placeholder) => {
73
+ return replacements[placeholder] ?? `{{${placeholder}}}`;
74
+ });
75
+ return forProcessing;
76
+ }
77
+ } catch (e) {
78
+ console.error(e);
79
+ }
80
+ return `{{${usedLanguage}:${key}}}`;
81
+ };
50
82
  };
51
83
 
52
84
  // src/components/user-action/MultiSelect.tsx
53
- import clsx5 from "clsx";
85
+ import clsx7 from "clsx";
54
86
 
55
- // src/components/user-action/Menu.tsx
56
- import { useRef } from "react";
87
+ // src/components/user-action/Label.tsx
57
88
  import clsx from "clsx";
58
-
59
- // src/hooks/useOutsideClick.ts
60
- import { useEffect as useEffect3 } from "react";
61
- var useOutsideClick = (refs, handler) => {
62
- useEffect3(() => {
63
- const listener = (event) => {
64
- if (event.target === null) return;
65
- if (refs.some((ref) => !ref.current || ref.current.contains(event.target))) {
66
- return;
67
- }
68
- handler();
69
- };
70
- document.addEventListener("mousedown", listener);
71
- document.addEventListener("touchstart", listener);
72
- return () => {
73
- document.removeEventListener("mousedown", listener);
74
- document.removeEventListener("touchstart", listener);
75
- };
76
- }, [refs, handler]);
77
- };
78
-
79
- // src/hooks/useHoverState.ts
80
- import { useEffect as useEffect4, useState as useState3 } from "react";
81
- var defaultUseHoverStateProps = {
82
- closingDelay: 200,
83
- isDisabled: false
84
- };
85
- var useHoverState = (props = void 0) => {
86
- const { closingDelay, isDisabled } = { ...defaultUseHoverStateProps, ...props };
87
- const [isHovered, setIsHovered] = useState3(false);
88
- const [timer, setTimer] = useState3();
89
- const onMouseEnter = () => {
90
- if (isDisabled) {
91
- return;
92
- }
93
- clearTimeout(timer);
94
- setIsHovered(true);
95
- };
96
- const onMouseLeave = () => {
97
- if (isDisabled) {
98
- return;
99
- }
100
- setTimer(setTimeout(() => {
101
- setIsHovered(false);
102
- }, closingDelay));
103
- };
104
- useEffect4(() => {
105
- if (timer) {
106
- return () => {
107
- clearTimeout(timer);
108
- };
109
- }
110
- });
111
- useEffect4(() => {
112
- if (timer) {
113
- clearTimeout(timer);
114
- }
115
- }, [isDisabled]);
116
- return {
117
- isHovered,
118
- setIsHovered,
119
- handlers: { onMouseEnter, onMouseLeave }
120
- };
89
+ import { jsx as jsx2 } from "react/jsx-runtime";
90
+ var styleMapping = {
91
+ labelSmall: "textstyle-label-sm",
92
+ labelMedium: "textstyle-label-md",
93
+ labelBig: "textstyle-label-lg"
121
94
  };
122
-
123
- // src/components/user-action/Menu.tsx
124
- import { jsx as jsx2, jsxs } from "react/jsx-runtime";
125
- var MenuItem = ({
126
- children,
127
- onClick,
128
- alignment = "left",
129
- className
130
- }) => /* @__PURE__ */ jsx2(
131
- "div",
132
- {
133
- className: clsx("block px-3 py-1 bg-menu-background text-menu-text hover:brightness-90", {
134
- "text-right": alignment === "right",
135
- "text-left": alignment === "left"
136
- }, className),
137
- onClick,
138
- children
139
- }
140
- );
141
- var Menu = ({
142
- trigger,
95
+ var Label = ({
143
96
  children,
144
- alignment = "tl",
145
- showOnHover = false,
146
- menuClassName = ""
97
+ name,
98
+ labelType = "labelSmall",
99
+ className,
100
+ ...props
147
101
  }) => {
148
- const { isHovered: isOpen, setIsHovered: setIsOpen, handlers } = useHoverState({ isDisabled: !showOnHover });
149
- const triggerRef = useRef(null);
150
- const menuRef = useRef(null);
151
- useOutsideClick([triggerRef, menuRef], () => setIsOpen(false));
152
- return /* @__PURE__ */ jsxs(
153
- "div",
154
- {
155
- className: "relative",
156
- ...handlers,
157
- children: [
158
- trigger(() => setIsOpen(!isOpen), triggerRef),
159
- isOpen ? /* @__PURE__ */ jsx2(
160
- "div",
161
- {
162
- ref: menuRef,
163
- onClick: (e) => e.stopPropagation(),
164
- 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]", {
165
- " top-[8px]": alignment[0] === "t",
166
- " bottom-[8px]": alignment[0] === "b",
167
- " left-[-8px]": alignment[1] === "l",
168
- " right-[-8px]": alignment[1] === "r"
169
- }, menuClassName),
170
- children
171
- }
172
- ) : null
173
- ]
174
- }
175
- );
102
+ return /* @__PURE__ */ jsx2("label", { ...props, className: clsx(styleMapping[labelType], className), children: children ? children : name });
176
103
  };
177
104
 
105
+ // src/components/layout-and-navigation/SearchableList.tsx
106
+ import { Search } from "lucide-react";
107
+ import clsx4 from "clsx";
108
+
178
109
  // src/components/user-action/Input.tsx
179
- import { forwardRef, useEffect as useEffect6, useRef as useRef2, useState as useState5 } from "react";
180
- import clsx3 from "clsx";
110
+ import { forwardRef, useEffect as useEffect4, useRef, useState as useState4 } from "react";
111
+ import clsx2 from "clsx";
181
112
 
182
113
  // src/hooks/useSaveDelay.ts
183
- import { useEffect as useEffect5, useState as useState4 } from "react";
114
+ import { useEffect as useEffect3, useState as useState3 } from "react";
184
115
  function useSaveDelay(setNotificationStatus, delay) {
185
- const [updateTimer, setUpdateTimer] = useState4(void 0);
186
- const [notificationTimer, setNotificationTimer] = useState4(void 0);
116
+ const [updateTimer, setUpdateTimer] = useState3(void 0);
117
+ const [notificationTimer, setNotificationTimer] = useState3(void 0);
187
118
  const restartTimer = (onSave) => {
188
119
  clearTimeout(updateTimer);
189
120
  setUpdateTimer(setTimeout(() => {
@@ -210,7 +141,7 @@ function useSaveDelay(setNotificationStatus, delay) {
210
141
  setNotificationStatus(false);
211
142
  }
212
143
  };
213
- useEffect5(() => {
144
+ useEffect3(() => {
214
145
  return () => {
215
146
  clearTimeout(updateTimer);
216
147
  clearTimeout(notificationTimer);
@@ -222,26 +153,8 @@ function useSaveDelay(setNotificationStatus, delay) {
222
153
  // src/util/noop.ts
223
154
  var noop = () => void 0;
224
155
 
225
- // src/components/user-action/Label.tsx
226
- import clsx2 from "clsx";
227
- import { jsx as jsx3 } from "react/jsx-runtime";
228
- var styleMapping = {
229
- labelSmall: "textstyle-label-sm",
230
- labelMedium: "textstyle-label-md",
231
- labelBig: "textstyle-label-lg"
232
- };
233
- var Label = ({
234
- children,
235
- name,
236
- labelType = "labelSmall",
237
- className,
238
- ...props
239
- }) => {
240
- return /* @__PURE__ */ jsx3("label", { ...props, className: clsx2(styleMapping[labelType], className), children: children ? children : name });
241
- };
242
-
243
156
  // src/components/user-action/Input.tsx
244
- import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
157
+ import { jsx as jsx3, jsxs } from "react/jsx-runtime";
245
158
  var Input = ({
246
159
  id,
247
160
  type = "text",
@@ -261,15 +174,15 @@ var Input = ({
261
174
  restartTimer,
262
175
  clearUpdateTimer
263
176
  } = useSaveDelay(() => void 0, 3e3);
264
- const ref = useRef2(null);
265
- useEffect6(() => {
177
+ const ref = useRef(null);
178
+ useEffect4(() => {
266
179
  if (autoFocus) {
267
180
  ref.current?.focus();
268
181
  }
269
182
  }, [autoFocus]);
270
- return /* @__PURE__ */ jsxs2("div", { className: clsx3({ "w-full": expanded }, containerClassName), children: [
271
- label && /* @__PURE__ */ jsx4(Label, { ...label, htmlFor: id, className: clsx3("mb-1", label.className) }),
272
- /* @__PURE__ */ jsx4(
183
+ return /* @__PURE__ */ jsxs("div", { className: clsx2({ "w-full": expanded }, containerClassName), children: [
184
+ label && /* @__PURE__ */ jsx3(Label, { ...label, htmlFor: id, className: clsx2("mb-1", label.className) }),
185
+ /* @__PURE__ */ jsx3(
273
186
  "input",
274
187
  {
275
188
  ref,
@@ -313,13 +226,13 @@ var FormInput = forwardRef(function FormInput2({
313
226
  required,
314
227
  ...restProps
315
228
  }, ref) {
316
- const input = /* @__PURE__ */ jsx4(
229
+ const input = /* @__PURE__ */ jsx3(
317
230
  "input",
318
231
  {
319
232
  ref,
320
233
  id,
321
234
  ...restProps,
322
- className: clsx3(
235
+ className: clsx2(
323
236
  {
324
237
  "focus:border-primary focus:ring-primary": !errorText,
325
238
  "focus:border-negative focus:ring-negative text-negative": !!errorText
@@ -328,208 +241,601 @@ var FormInput = forwardRef(function FormInput2({
328
241
  )
329
242
  }
330
243
  );
331
- return /* @__PURE__ */ jsxs2("div", { className: clsx3("flex flex-col gap-y-1", containerClassName), children: [
332
- labelText && /* @__PURE__ */ jsxs2("label", { htmlFor: id, className: clsx3("textstyle-label-md", labelClassName), children: [
244
+ return /* @__PURE__ */ jsxs("div", { className: clsx2("flex flex-col gap-y-1", containerClassName), children: [
245
+ labelText && /* @__PURE__ */ jsxs("label", { htmlFor: id, className: clsx2("textstyle-label-md", labelClassName), children: [
333
246
  labelText,
334
- required && /* @__PURE__ */ jsx4("span", { className: "text-primary font-bold", children: "*" })
247
+ required && /* @__PURE__ */ jsx3("span", { className: "text-primary font-bold", children: "*" })
335
248
  ] }),
336
249
  input,
337
- errorText && /* @__PURE__ */ jsx4("label", { htmlFor: id, className: clsx3("text-negative", errorClassName), children: errorText })
250
+ errorText && /* @__PURE__ */ jsx3("label", { htmlFor: id, className: clsx2("text-negative", errorClassName), children: errorText })
338
251
  ] });
339
252
  });
340
253
 
341
- // src/components/user-action/Checkbox.tsx
342
- import { useState as useState6 } from "react";
343
- import * as CheckboxPrimitive from "@radix-ui/react-checkbox";
344
- import { Check, Minus } from "lucide-react";
345
- import clsx4 from "clsx";
346
- import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
347
- var checkboxSizeMapping = {
348
- small: "size-4",
349
- medium: "size-6",
350
- large: "size-8"
254
+ // src/components/user-action/Button.tsx
255
+ import clsx3 from "clsx";
256
+ import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
257
+ var paddingMapping = {
258
+ small: "btn-sm",
259
+ medium: "btn-md",
260
+ large: "btn-lg"
351
261
  };
352
- var checkboxIconSizeMapping = {
353
- small: "size-3",
354
- medium: "size-5",
355
- large: "size-7"
262
+ var iconPaddingMapping = {
263
+ small: "icon-btn-sm",
264
+ medium: "icon-btn-md",
265
+ large: "icon-btn-lg"
356
266
  };
357
- var Checkbox = ({
358
- id,
359
- label,
360
- checked,
361
- disabled,
362
- onChange,
363
- onChangeTristate,
267
+ var ButtonUtil = {
268
+ paddingMapping,
269
+ iconPaddingMapping
270
+ };
271
+ var SolidButton = ({
272
+ children,
273
+ disabled = false,
274
+ color = "primary",
364
275
  size = "medium",
365
- className = "",
366
- containerClassName
276
+ startIcon,
277
+ endIcon,
278
+ onClick,
279
+ className,
280
+ ...restProps
367
281
  }) => {
368
- const usedSizeClass = checkboxSizeMapping[size];
369
- const innerIconSize = checkboxIconSizeMapping[size];
370
- const propagateChange = (checked2) => {
371
- if (onChangeTristate) {
372
- onChangeTristate(checked2);
282
+ const colorClasses = {
283
+ primary: "bg-button-solid-primary-background text-button-solid-primary-text",
284
+ secondary: "bg-button-solid-secondary-background text-button-solid-secondary-text",
285
+ tertiary: "bg-button-solid-tertiary-background text-button-solid-tertiary-text",
286
+ positive: "bg-button-solid-positive-background text-button-solid-positive-text",
287
+ warning: "bg-button-solid-warning-background text-button-solid-warning-text",
288
+ negative: "bg-button-solid-negative-background text-button-solid-negative-text",
289
+ neutral: "bg-button-solid-neutral-background text-button-solid-neutral-text"
290
+ }[color];
291
+ const iconColorClasses = {
292
+ primary: "text-button-solid-primary-icon",
293
+ secondary: "text-button-solid-secondary-icon",
294
+ tertiary: "text-button-solid-tertiary-icon",
295
+ positive: "text-button-solid-positive-icon",
296
+ warning: "text-button-solid-warning-icon",
297
+ negative: "text-button-solid-negative-icon",
298
+ neutral: "text-button-solid-neutral-icon"
299
+ }[color];
300
+ return /* @__PURE__ */ jsxs2(
301
+ "button",
302
+ {
303
+ onClick: disabled ? void 0 : onClick,
304
+ disabled: disabled || onClick === void 0,
305
+ className: clsx3(
306
+ {
307
+ "text-disabled-text bg-disabled-background cursor-not-allowed": disabled,
308
+ [clsx3(colorClasses, "hover:brightness-90")]: !disabled
309
+ },
310
+ ButtonUtil.paddingMapping[size],
311
+ className
312
+ ),
313
+ ...restProps,
314
+ children: [
315
+ startIcon && /* @__PURE__ */ jsx4(
316
+ "span",
317
+ {
318
+ className: clsx3({
319
+ [iconColorClasses]: !disabled,
320
+ [`text-disabled-icon`]: disabled
321
+ }),
322
+ children: startIcon
323
+ }
324
+ ),
325
+ children,
326
+ endIcon && /* @__PURE__ */ jsx4(
327
+ "span",
328
+ {
329
+ className: clsx3({
330
+ [iconColorClasses]: !disabled,
331
+ [`text-disabled-icon`]: disabled
332
+ }),
333
+ children: endIcon
334
+ }
335
+ )
336
+ ]
373
337
  }
374
- if (onChange) {
375
- onChange(checked2 === "indeterminate" ? false : checked2);
338
+ );
339
+ };
340
+ var IconButton = ({
341
+ children,
342
+ disabled = false,
343
+ color = "primary",
344
+ size = "medium",
345
+ onClick,
346
+ className,
347
+ ...restProps
348
+ }) => {
349
+ const colorClasses = {
350
+ primary: "bg-button-solid-primary-background text-button-solid-primary-text",
351
+ secondary: "bg-button-solid-secondary-background text-button-solid-secondary-text",
352
+ tertiary: "bg-button-solid-tertiary-background text-button-solid-tertiary-text",
353
+ positive: "bg-button-solid-positive-background text-button-solid-positive-text",
354
+ warning: "bg-button-solid-warning-background text-button-solid-warning-text",
355
+ negative: "bg-button-solid-negative-background text-button-solid-negative-text",
356
+ neutral: "bg-button-solid-neutral-background text-button-solid-neutral-text"
357
+ }[color];
358
+ return /* @__PURE__ */ jsx4(
359
+ "button",
360
+ {
361
+ onClick: disabled ? void 0 : onClick,
362
+ disabled: disabled || onClick === void 0,
363
+ className: clsx3(
364
+ {
365
+ "text-disabled-text bg-disabled-background cursor-not-allowed": disabled,
366
+ [clsx3(colorClasses, "hover:brightness-90")]: !disabled
367
+ },
368
+ ButtonUtil.iconPaddingMapping[size],
369
+ className
370
+ ),
371
+ ...restProps,
372
+ children
376
373
  }
374
+ );
375
+ };
376
+
377
+ // src/hooks/useSearch.ts
378
+ import { useEffect as useEffect5, useMemo, useState as useState5 } from "react";
379
+
380
+ // src/util/simpleSearch.ts
381
+ var MultiSearchWithMapping = (search, objects, mapping) => {
382
+ return objects.filter((object) => {
383
+ const mappedSearchKeywords = mapping(object)?.map((value) => value.toLowerCase().trim());
384
+ if (!mappedSearchKeywords) {
385
+ return true;
386
+ }
387
+ return !!mappedSearchKeywords.find((value) => value.includes(search.toLowerCase().trim()));
388
+ });
389
+ };
390
+
391
+ // src/hooks/useSearch.ts
392
+ var useSearch = ({
393
+ list,
394
+ initialSearch,
395
+ searchMapping
396
+ }) => {
397
+ const [items, setItems] = useState5(list);
398
+ const [search, setSearch] = useState5(initialSearch);
399
+ useEffect5(() => {
400
+ setItems(list);
401
+ }, [list]);
402
+ const result = useMemo(
403
+ () => MultiSearchWithMapping(search, items, searchMapping),
404
+ [search, items, searchMapping]
405
+ );
406
+ return {
407
+ result,
408
+ hasResult: result.length > 0,
409
+ allItems: items,
410
+ setItems,
411
+ search,
412
+ setSearch
377
413
  };
378
- const changeValue = () => {
379
- const newValue = checked === "indeterminate" ? false : !checked;
380
- propagateChange(newValue);
381
- };
382
- return /* @__PURE__ */ jsxs3("div", { className: clsx4("row justify-center items-center", containerClassName), children: [
383
- /* @__PURE__ */ jsx5(
384
- CheckboxPrimitive.Root,
385
- {
386
- onCheckedChange: propagateChange,
387
- checked,
388
- disabled,
389
- id,
390
- className: clsx4(usedSizeClass, `items-center border-2 rounded outline-none focus:border-primary`, {
391
- "text-disabled-text border-disabled-text bg-disabled-background": disabled,
392
- "bg-surface": !disabled && !checked,
393
- "bg-primary/30 border-primary text-primary": checked === true || checked === "indeterminate",
394
- "hover:border-primary focus:hover:border-primary": !checked
395
- }, className),
396
- children: /* @__PURE__ */ jsxs3(CheckboxPrimitive.Indicator, { children: [
397
- checked === true && /* @__PURE__ */ jsx5(Check, { className: innerIconSize }),
398
- checked === "indeterminate" && /* @__PURE__ */ jsx5(Minus, { className: innerIconSize })
399
- ] })
400
- }
401
- ),
402
- label && /* @__PURE__ */ jsx5(
403
- Label,
404
- {
405
- ...label,
406
- className: clsx4("cursor-pointer", label.className),
407
- htmlFor: id,
408
- onClick: changeValue
409
- }
410
- )
414
+ };
415
+
416
+ // src/localization/defaults/form.ts
417
+ var formTranslation = {
418
+ en: {
419
+ all: "All",
420
+ back: "Back",
421
+ cancel: "Cancel",
422
+ change: "Change",
423
+ clear: "Clear",
424
+ close: "Close",
425
+ confirm: "Confirm",
426
+ decline: "Decline",
427
+ delete: "Delete",
428
+ discard: "Discard",
429
+ discardChanges: "Discard Changes",
430
+ done: "Done",
431
+ edit: "Edit",
432
+ enterText: "Enter text here",
433
+ error: "Error",
434
+ exit: "Exit",
435
+ fieldRequiredError: "This field is required.",
436
+ invalidEmailError: "Please enter a valid email address.",
437
+ less: "Less",
438
+ loading: "Loading",
439
+ maxLengthError: "Maximum length exceeded.",
440
+ minLengthError: "Minimum length not met.",
441
+ more: "More",
442
+ next: "Next",
443
+ no: "No",
444
+ none: "None",
445
+ of: "of",
446
+ optional: "Optional",
447
+ pleaseWait: "Please wait...",
448
+ previous: "Previous",
449
+ remove: "Remove",
450
+ required: "Required",
451
+ reset: "Reset",
452
+ save: "Save",
453
+ search: "Search",
454
+ select: "Select",
455
+ selectOption: "Select an option",
456
+ show: "Show",
457
+ showMore: "Show more",
458
+ showLess: "Show less",
459
+ submit: "Submit",
460
+ success: "Success",
461
+ update: "Update",
462
+ unsavedChanges: "Unsaved Changes",
463
+ unsavedChangesSaveQuestion: "Do you want to save your changes?",
464
+ yes: "Yes"
465
+ },
466
+ de: {
467
+ all: "Alle",
468
+ back: "Zur\xFCck",
469
+ cancel: "Abbrechen",
470
+ change: "\xC4ndern",
471
+ clear: "L\xF6schen",
472
+ close: "Schlie\xDFen",
473
+ confirm: "Best\xE4tigen",
474
+ decline: "Ablehnen",
475
+ delete: "L\xF6schen",
476
+ discard: "Verwerfen",
477
+ discardChanges: "\xC4nderungen Verwerfen",
478
+ done: "Fertig",
479
+ edit: "Bearbeiten",
480
+ enterText: "Text hier eingeben",
481
+ error: "Fehler",
482
+ exit: "Beenden",
483
+ fieldRequiredError: "Dieses Feld ist erforderlich.",
484
+ invalidEmailError: "Bitte geben Sie eine g\xFCltige E-Mail-Adresse ein.",
485
+ less: "Weniger",
486
+ loading: "L\xE4dt",
487
+ maxLengthError: "Maximale L\xE4nge \xFCberschritten.",
488
+ minLengthError: "Mindestl\xE4nge nicht erreicht.",
489
+ more: "Mehr",
490
+ next: "Weiter",
491
+ no: "Nein",
492
+ none: "Nichts",
493
+ of: "von",
494
+ optional: "Optional",
495
+ pleaseWait: "Bitte warten...",
496
+ previous: "Vorherige",
497
+ remove: "Entfernen",
498
+ required: "Erforderlich",
499
+ reset: "Zur\xFCcksetzen",
500
+ save: "Speichern",
501
+ search: "Suche",
502
+ select: "Select",
503
+ selectOption: "Option ausw\xE4hlen",
504
+ show: "Anzeigen",
505
+ showMore: "Mehr anzeigen",
506
+ showLess: "Weniger anzeigen",
507
+ submit: "Abschicken",
508
+ success: "Erfolg",
509
+ update: "Update",
510
+ unsavedChanges: "Ungespeicherte \xC4nderungen",
511
+ unsavedChangesSaveQuestion: "M\xF6chtest du die \xC4nderungen speichern?",
512
+ yes: "Ja"
513
+ }
514
+ };
515
+
516
+ // src/components/layout-and-navigation/SearchableList.tsx
517
+ import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
518
+ var defaultSearchableListTranslation = {
519
+ en: {
520
+ nothingFound: "Nothing found"
521
+ },
522
+ de: {
523
+ nothingFound: "Nichts gefunden"
524
+ }
525
+ };
526
+ var SearchableList = ({
527
+ overwriteTranslation,
528
+ list,
529
+ initialSearch = "",
530
+ searchMapping,
531
+ autoFocus,
532
+ minimumItemsForSearch = 6,
533
+ itemMapper,
534
+ className,
535
+ resultListClassName
536
+ }) => {
537
+ const translation = useTranslation([defaultSearchableListTranslation, formTranslation], overwriteTranslation);
538
+ const { result, hasResult, search, setSearch } = useSearch({ list, initialSearch, searchMapping });
539
+ return /* @__PURE__ */ jsxs3("div", { className: clsx4("col gap-y-2", className), children: [
540
+ list.length > minimumItemsForSearch && /* @__PURE__ */ jsxs3("div", { className: "row justify-between gap-x-4 items-center", children: [
541
+ /* @__PURE__ */ jsx5(
542
+ Input,
543
+ {
544
+ value: search,
545
+ onChangeText: setSearch,
546
+ placeholder: translation("search"),
547
+ autoFocus,
548
+ className: "w-full"
549
+ }
550
+ ),
551
+ /* @__PURE__ */ jsx5(IconButton, { color: "neutral", disabled: search.length === 0, children: /* @__PURE__ */ jsx5(Search, { className: "w-full h-full" }) })
552
+ ] }),
553
+ hasResult ? /* @__PURE__ */ jsx5("div", { className: clsx4("col gap-y-1", resultListClassName), children: result.map(itemMapper) }) : /* @__PURE__ */ jsx5("div", { className: "row text-description py-2 px-2", children: translation("nothingFound") })
411
554
  ] });
412
555
  };
413
556
 
414
- // src/components/user-action/MultiSelect.tsx
557
+ // src/components/layout-and-navigation/Tile.tsx
558
+ import clsx5 from "clsx";
559
+ import { Check } from "lucide-react";
415
560
  import { jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
561
+ var Tile = ({
562
+ title,
563
+ description,
564
+ onClick,
565
+ isSelected = false,
566
+ isDisabled = false,
567
+ prefix,
568
+ suffix,
569
+ normalClassName = "hover:bg-primary/40 cursor-pointer",
570
+ selectedClassName = " bg-primary/20",
571
+ disabledClassName = "text-disabled-text bg-disabled-background cursor-not-allowed",
572
+ className
573
+ }) => {
574
+ return /* @__PURE__ */ jsxs4(
575
+ "div",
576
+ {
577
+ className: clsx5(
578
+ "row gap-x-2 w-full items-center",
579
+ {
580
+ [normalClassName]: !!onClick && !isDisabled,
581
+ [selectedClassName]: isSelected && !isDisabled,
582
+ [disabledClassName]: isDisabled
583
+ },
584
+ className
585
+ ),
586
+ onClick: isDisabled ? void 0 : onClick,
587
+ children: [
588
+ prefix ?? (isSelected ? /* @__PURE__ */ jsx6(Check, { size: 24 }) : void 0),
589
+ /* @__PURE__ */ jsxs4("div", { className: "col gap-y-0 w-full", children: [
590
+ /* @__PURE__ */ jsx6("h4", { className: clsx5(title.className ?? "textstyle-title-normal"), children: title.value }),
591
+ !!description && /* @__PURE__ */ jsx6("span", { className: clsx5(description.className ?? "textstyle-description"), children: description.value })
592
+ ] }),
593
+ suffix
594
+ ]
595
+ }
596
+ );
597
+ };
598
+
599
+ // src/components/layout-and-navigation/Chip.tsx
600
+ import clsx6 from "clsx";
601
+ import { jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
602
+ var Chip = ({
603
+ children,
604
+ trailingIcon,
605
+ color = "default",
606
+ variant = "normal",
607
+ className = "",
608
+ ...restProps
609
+ }) => {
610
+ const colorMapping = {
611
+ default: "text-tag-default-text bg-tag-default-background",
612
+ dark: "text-tag-dark-text bg-tag-dark-background",
613
+ red: "text-tag-red-text bg-tag-red-background",
614
+ yellow: "text-tag-yellow-text bg-tag-yellow-background",
615
+ green: "text-tag-green-text bg-tag-green-background",
616
+ blue: "text-tag-blue-text bg-tag-blue-background",
617
+ pink: "text-tag-pink-text bg-tag-pink-background"
618
+ }[color];
619
+ const colorMappingIcon = {
620
+ default: "text-tag-default-icon",
621
+ dark: "text-tag-dark-icon",
622
+ red: "text-tag-red-icon",
623
+ yellow: "text-tag-yellow-icon",
624
+ green: "text-tag-green-icon",
625
+ blue: "text-tag-blue-icon",
626
+ pink: "text-tag-pink-icon"
627
+ }[color];
628
+ return /* @__PURE__ */ jsxs5(
629
+ "div",
630
+ {
631
+ ...restProps,
632
+ className: clsx6(
633
+ `row w-fit px-2 py-1`,
634
+ colorMapping,
635
+ {
636
+ "rounded-md": variant === "normal",
637
+ "rounded-full": variant === "fullyRounded"
638
+ },
639
+ className
640
+ ),
641
+ children: [
642
+ children,
643
+ trailingIcon && /* @__PURE__ */ jsx7("span", { className: colorMappingIcon, children: trailingIcon })
644
+ ]
645
+ }
646
+ );
647
+ };
648
+ var ChipList = ({
649
+ list,
650
+ className = ""
651
+ }) => {
652
+ return /* @__PURE__ */ jsx7("div", { className: clsx6("flex flex-wrap gap-x-4 gap-y-2", className), children: list.map((value, index) => /* @__PURE__ */ jsx7(
653
+ Chip,
654
+ {
655
+ ...value,
656
+ color: value.color ?? "dark",
657
+ variant: value.variant ?? "normal",
658
+ children: value.children
659
+ },
660
+ index
661
+ )) });
662
+ };
663
+
664
+ // src/hooks/useOutsideClick.ts
665
+ import { useEffect as useEffect6 } from "react";
666
+ var useOutsideClick = (refs, handler) => {
667
+ useEffect6(() => {
668
+ const listener = (event) => {
669
+ if (event.target === null) return;
670
+ if (refs.some((ref) => !ref.current || ref.current.contains(event.target))) {
671
+ return;
672
+ }
673
+ handler();
674
+ };
675
+ document.addEventListener("mousedown", listener);
676
+ document.addEventListener("touchstart", listener);
677
+ return () => {
678
+ document.removeEventListener("mousedown", listener);
679
+ document.removeEventListener("touchstart", listener);
680
+ };
681
+ }, [refs, handler]);
682
+ };
683
+
684
+ // src/components/user-action/MultiSelect.tsx
685
+ import { jsx as jsx8, jsxs as jsxs6 } from "react/jsx-runtime";
416
686
  var defaultMultiSelectTranslation = {
417
687
  en: {
418
- select: "Select",
419
- search: "Search",
420
- selected: "selected"
688
+ selected: `{{amount}} selected`
421
689
  },
422
690
  de: {
423
- select: "Ausw\xE4hlen",
424
- search: "Suche",
425
- selected: "ausgew\xE4hlt"
691
+ selected: `{{amount}} ausgew\xE4hlt`
426
692
  }
427
693
  };
428
694
  var MultiSelect = ({
429
695
  overwriteTranslation,
430
696
  options,
431
- onChange,
432
- search,
433
- disabled = false,
434
- selectedDisplay,
435
697
  label,
698
+ onChange,
436
699
  hintText,
437
- showDisabledOptions = true,
438
- className = "",
439
- triggerClassName = ""
700
+ isDisabled = false,
701
+ isSearchEnabled = false,
702
+ selectedDisplayOverwrite,
703
+ useChipDisplay = false,
704
+ className = ""
440
705
  }) => {
441
- const translation = useTranslation(defaultMultiSelectTranslation, overwriteTranslation);
442
- const [searchText, setSearchText] = useState7(search?.initialSearch ?? "");
443
- let filteredOptions = options;
444
- const enableSearch = !!search;
445
- if (enableSearch && !!searchText) {
446
- filteredOptions = MultiSearchWithMapping(
447
- searchText,
448
- filteredOptions,
449
- (value) => search.searchMapping(value)
450
- );
451
- }
452
- if (!showDisabledOptions) {
453
- filteredOptions = filteredOptions.filter((value) => !value.disabled);
454
- }
706
+ const translation = useTranslation([formTranslation, defaultMultiSelectTranslation], overwriteTranslation);
707
+ const triggerRef = useRef2(null);
708
+ const menuRef = useRef2(null);
709
+ const [isOpen, setIsOpen] = useState6(false);
710
+ useOutsideClick([triggerRef, menuRef], () => setIsOpen(false));
455
711
  const selectedItems = options.filter((value) => value.selected);
456
- const menuButtonText = selectedItems.length === 0 ? hintText ?? translation.select : /* @__PURE__ */ jsx6("span", { children: `${selectedItems.length} ${translation.selected}` });
457
- const borderColor = "border-menu-border";
458
- return /* @__PURE__ */ jsxs4("div", { className: clsx5(className), children: [
459
- label && /* @__PURE__ */ jsx6(
712
+ const isShowingHint = !selectedDisplayOverwrite && selectedItems.length === 0;
713
+ return /* @__PURE__ */ jsxs6("div", { className: clsx7(className), children: [
714
+ label && /* @__PURE__ */ jsx8(
460
715
  Label,
461
716
  {
462
717
  ...label,
463
718
  htmlFor: label.name,
464
- className: clsx5(" mb-1", label.className),
719
+ className: clsx7(" mb-1", label.className),
465
720
  labelType: label.labelType ?? "labelBig"
466
721
  }
467
722
  ),
468
- /* @__PURE__ */ jsxs4(
469
- Menu,
470
- {
471
- alignment: "t_",
472
- trigger: (onClick, ref) => /* @__PURE__ */ jsx6(
473
- "div",
474
- {
475
- ref,
476
- onClick: disabled ? void 0 : onClick,
477
- className: clsx5(
478
- borderColor,
479
- "bg-menu-background text-menu-text inline-w-full justify-between items-center rounded-lg border-2 px-4 py-2 font-medium",
480
- {
481
- "hover:border-primary cursor-pointer": !disabled,
482
- "bg-disabled-background text-disabled cursor-not-allowed": disabled
483
- },
484
- triggerClassName
485
- ),
486
- children: selectedDisplay ? selectedDisplay({ items: options, disabled }) : menuButtonText
487
- }
488
- ),
489
- menuClassName: clsx5(
490
- "!rounded-lg !shadow-lg !max-h-[500px] !min-w-[400px] !max-w-[70vh] !overflow-y-auto !border !border-2",
491
- borderColor,
492
- { "!py-0": !enableSearch, "!pb-0": enableSearch }
493
- ),
494
- children: [
495
- enableSearch && /* @__PURE__ */ jsxs4("div", { className: "row gap-x-2 items-center px-2 py-2", children: [
496
- /* @__PURE__ */ jsx6(Input, { autoFocus: true, className: "w-full", value: searchText, onChangeText: setSearchText }),
497
- /* @__PURE__ */ jsx6(Search, {})
498
- ] }, "selectSearch"),
499
- filteredOptions.map((option, index) => /* @__PURE__ */ jsx6(
500
- MenuItem,
723
+ /* @__PURE__ */ jsxs6("div", { className: "relative", children: [
724
+ /* @__PURE__ */ jsxs6(
725
+ "button",
726
+ {
727
+ ref: triggerRef,
728
+ className: clsx7(
729
+ "btn-md justify-between w-full border-2 h-auto",
501
730
  {
502
- className: clsx5({
503
- "cursor-not-allowed !bg-disabled-background !text-disabled-text hover:brightness-100": !!option.disabled,
504
- "cursor-pointer": !option.disabled
505
- }),
506
- children: /* @__PURE__ */ jsxs4(
507
- "div",
508
- {
509
- className: clsx5("overflow-hidden whitespace-nowrap text-ellipsis row items-center gap-x-2", option.className),
510
- onClick: () => {
511
- if (!option.disabled) {
731
+ "rounded-b-lg": !open,
732
+ "bg-menu-background border-menu-border hover:border-primary": !isDisabled,
733
+ "bg-disabled-background text-disabled-text border-disabled-background cursor-not-allowed": isDisabled
734
+ }
735
+ ),
736
+ onClick: () => setIsOpen(!isOpen),
737
+ disabled: isDisabled,
738
+ children: [
739
+ !isShowingHint && /* @__PURE__ */ jsx8("span", { className: "font-semibold text-menu-text", children: selectedDisplayOverwrite ?? (useChipDisplay && selectedItems ? /* @__PURE__ */ jsx8(ChipList, { list: selectedItems.map((value) => ({ children: value.label })) }) : translation("selected", { replacements: { amount: selectedItems.length.toString() } })) }),
740
+ isShowingHint && /* @__PURE__ */ jsx8("span", { className: "textstyle-description", children: hintText ?? translation("select") }),
741
+ isOpen ? /* @__PURE__ */ jsx8(ChevronUp, { size: 24, className: "min-w-6" }) : /* @__PURE__ */ jsx8(ChevronDown, { className: "min-w-6" })
742
+ ]
743
+ }
744
+ ),
745
+ isOpen && /* @__PURE__ */ jsxs6(
746
+ "div",
747
+ {
748
+ ref: menuRef,
749
+ className: "absolute w-full z-10 rounded-lg mt-0.5 bg-menu-background text-menu-text shadow-around-md max-h-[500px] overflow-y-auto p-2",
750
+ children: [
751
+ /* @__PURE__ */ jsx8(
752
+ SearchableList,
753
+ {
754
+ list: options,
755
+ minimumItemsForSearch: isSearchEnabled ? void 0 : options.length,
756
+ searchMapping: (item) => item.searchTags,
757
+ itemMapper: (option, index) => /* @__PURE__ */ jsx8(
758
+ Tile,
759
+ {
760
+ isSelected: option.selected,
761
+ className: "px-2 py-1 rounded-md",
762
+ disabledClassName: "text-disabled-text cursor-not-allowed",
763
+ title: { value: option.label, className: "font-semibold" },
764
+ onClick: () => {
512
765
  onChange(options.map((value) => value.value === option.value ? {
513
766
  ...option,
514
767
  selected: !value.selected
515
768
  } : value));
516
- }
769
+ },
770
+ isDisabled: option.disabled
517
771
  },
518
- children: [
519
- /* @__PURE__ */ jsx6(Checkbox, { checked: option.selected, disabled: option.disabled, size: "small" }),
520
- option.label
521
- ]
522
- }
523
- )
524
- },
525
- `item${index}`
526
- ))
527
- ]
528
- }
529
- )
772
+ index
773
+ )
774
+ }
775
+ ),
776
+ /* @__PURE__ */ jsxs6("div", { className: "row justify-between mt-2", children: [
777
+ /* @__PURE__ */ jsxs6("div", { className: "row gap-x-2", children: [
778
+ /* @__PURE__ */ jsx8(
779
+ SolidButton,
780
+ {
781
+ color: "neutral",
782
+ size: "small",
783
+ onClick: () => {
784
+ onChange(options.map((option) => ({
785
+ ...option,
786
+ selected: !option.disabled
787
+ })));
788
+ },
789
+ disabled: options.every((value) => value.selected || value.disabled),
790
+ children: translation("all")
791
+ }
792
+ ),
793
+ /* @__PURE__ */ jsx8(
794
+ SolidButton,
795
+ {
796
+ color: "neutral",
797
+ size: "small",
798
+ onClick: () => {
799
+ onChange(options.map((option) => ({
800
+ ...option,
801
+ selected: false
802
+ })));
803
+ },
804
+ children: translation("none")
805
+ }
806
+ )
807
+ ] }),
808
+ /* @__PURE__ */ jsx8(SolidButton, { size: "small", onClick: () => setIsOpen(false), children: "Done" })
809
+ ] })
810
+ ]
811
+ }
812
+ )
813
+ ] })
530
814
  ] });
531
815
  };
816
+ var MultiSelectUncontrolled = ({
817
+ options,
818
+ onChange,
819
+ ...props
820
+ }) => {
821
+ const [usedOptions, setUsedOptions] = useState6(options);
822
+ useEffect7(() => {
823
+ setUsedOptions(options);
824
+ }, [options]);
825
+ return /* @__PURE__ */ jsx8(
826
+ MultiSelect,
827
+ {
828
+ ...props,
829
+ options: usedOptions,
830
+ onChange: (options2) => {
831
+ setUsedOptions(options2);
832
+ onChange(options2);
833
+ }
834
+ }
835
+ );
836
+ };
532
837
  export {
533
- MultiSelect
838
+ MultiSelect,
839
+ MultiSelectUncontrolled
534
840
  };
535
841
  //# sourceMappingURL=MultiSelect.mjs.map