@helpwave/hightide 0.1.27 → 0.1.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (134) hide show
  1. package/dist/coloring/index.d.mts +2 -0
  2. package/dist/coloring/index.d.ts +2 -0
  3. package/dist/coloring/index.js +85 -0
  4. package/dist/coloring/index.js.map +1 -0
  5. package/dist/coloring/index.mjs +48 -0
  6. package/dist/coloring/index.mjs.map +1 -0
  7. package/dist/components/branding/index.d.mts +3 -0
  8. package/dist/components/branding/index.d.ts +3 -0
  9. package/dist/components/branding/index.js +140 -0
  10. package/dist/components/branding/index.js.map +1 -0
  11. package/dist/components/branding/index.mjs +104 -0
  12. package/dist/components/branding/index.mjs.map +1 -0
  13. package/dist/components/date/index.d.mts +10 -0
  14. package/dist/components/date/index.d.ts +10 -0
  15. package/dist/components/date/index.js +1168 -0
  16. package/dist/components/date/index.js.map +1 -0
  17. package/dist/components/date/index.mjs +1124 -0
  18. package/dist/components/date/index.mjs.map +1 -0
  19. package/dist/components/dialog/index.js.map +1 -1
  20. package/dist/components/form/index.d.mts +5 -0
  21. package/dist/components/form/index.d.ts +5 -0
  22. package/dist/components/form/index.js +100 -0
  23. package/dist/components/form/index.js.map +1 -0
  24. package/dist/components/form/index.mjs +64 -0
  25. package/dist/components/form/index.mjs.map +1 -0
  26. package/dist/components/icons-and-geometry/index.d.mts +7 -0
  27. package/dist/components/icons-and-geometry/index.d.ts +7 -0
  28. package/dist/components/icons-and-geometry/index.js +3955 -0
  29. package/dist/components/icons-and-geometry/index.js.map +1 -0
  30. package/dist/components/icons-and-geometry/index.mjs +3939 -0
  31. package/dist/components/icons-and-geometry/index.mjs.map +1 -0
  32. package/dist/components/index.d.mts +83 -0
  33. package/dist/components/index.d.ts +83 -0
  34. package/dist/components/index.js +15471 -0
  35. package/dist/components/index.js.map +1 -0
  36. package/dist/components/index.mjs +15377 -0
  37. package/dist/components/index.mjs.map +1 -0
  38. package/dist/components/layout/index.d.mts +18 -0
  39. package/dist/components/layout/index.d.ts +18 -0
  40. package/dist/components/layout/index.js +3111 -0
  41. package/dist/components/layout/index.js.map +1 -0
  42. package/dist/components/layout/index.mjs +3064 -0
  43. package/dist/components/layout/index.mjs.map +1 -0
  44. package/dist/components/loading-states/index.d.mts +12 -0
  45. package/dist/components/loading-states/index.d.ts +12 -0
  46. package/dist/components/loading-states/index.js +614 -0
  47. package/dist/components/loading-states/index.js.map +1 -0
  48. package/dist/components/loading-states/index.mjs +573 -0
  49. package/dist/components/loading-states/index.mjs.map +1 -0
  50. package/dist/components/navigation/index.d.mts +9 -0
  51. package/dist/components/navigation/index.d.ts +9 -0
  52. package/dist/components/navigation/index.js +4660 -0
  53. package/dist/components/navigation/index.js.map +1 -0
  54. package/dist/components/navigation/index.mjs +4648 -0
  55. package/dist/components/navigation/index.mjs.map +1 -0
  56. package/dist/components/properties/index.d.mts +12 -0
  57. package/dist/components/properties/index.d.ts +12 -0
  58. package/dist/components/properties/index.js +2983 -0
  59. package/dist/components/properties/index.js.map +1 -0
  60. package/dist/components/properties/index.mjs +2951 -0
  61. package/dist/components/properties/index.mjs.map +1 -0
  62. package/dist/components/table/index.d.mts +10 -0
  63. package/dist/components/table/index.d.ts +10 -0
  64. package/dist/components/table/index.js +2329 -0
  65. package/dist/components/table/index.js.map +1 -0
  66. package/dist/components/table/index.mjs +2293 -0
  67. package/dist/components/table/index.mjs.map +1 -0
  68. package/dist/components/user-action/index.d.mts +30 -0
  69. package/dist/components/user-action/index.d.ts +30 -0
  70. package/dist/components/user-action/index.js +4257 -0
  71. package/dist/components/user-action/index.js.map +1 -0
  72. package/dist/components/user-action/index.mjs +4195 -0
  73. package/dist/components/user-action/index.mjs.map +1 -0
  74. package/dist/components/user-action/input/index.d.mts +6 -0
  75. package/dist/components/user-action/input/index.d.ts +6 -0
  76. package/dist/components/user-action/input/index.js +398 -0
  77. package/dist/components/user-action/input/index.js.map +1 -0
  78. package/dist/components/user-action/input/index.mjs +357 -0
  79. package/dist/components/user-action/input/index.mjs.map +1 -0
  80. package/dist/components/user-action/select/index.d.mts +4 -0
  81. package/dist/components/user-action/select/index.d.ts +4 -0
  82. package/dist/components/user-action/select/index.js +1369 -0
  83. package/dist/components/user-action/select/index.js.map +1 -0
  84. package/dist/components/user-action/select/index.mjs +1333 -0
  85. package/dist/components/user-action/select/index.mjs.map +1 -0
  86. package/dist/components/utils/index.d.mts +4 -0
  87. package/dist/components/utils/index.d.ts +4 -0
  88. package/dist/components/utils/index.js +302 -0
  89. package/dist/components/utils/index.js.map +1 -0
  90. package/dist/components/utils/index.mjs +275 -0
  91. package/dist/components/utils/index.mjs.map +1 -0
  92. package/dist/hooks/focus/index.d.mts +6 -0
  93. package/dist/hooks/focus/index.d.ts +6 -0
  94. package/dist/hooks/focus/index.js +379 -0
  95. package/dist/hooks/focus/index.js.map +1 -0
  96. package/dist/hooks/focus/index.mjs +339 -0
  97. package/dist/hooks/focus/index.mjs.map +1 -0
  98. package/dist/hooks/index.d.mts +16 -0
  99. package/dist/hooks/index.d.ts +16 -0
  100. package/dist/hooks/index.js +844 -0
  101. package/dist/hooks/index.js.map +1 -0
  102. package/dist/hooks/index.mjs +794 -0
  103. package/dist/hooks/index.mjs.map +1 -0
  104. package/dist/index.d.mts +110 -0
  105. package/dist/index.d.ts +110 -0
  106. package/dist/index.js +16101 -0
  107. package/dist/index.js.map +1 -0
  108. package/dist/index.mjs +15941 -0
  109. package/dist/index.mjs.map +1 -0
  110. package/dist/localization/defaults/index.d.mts +4 -0
  111. package/dist/localization/defaults/index.d.ts +4 -0
  112. package/dist/localization/defaults/index.js +223 -0
  113. package/dist/localization/defaults/index.js.map +1 -0
  114. package/dist/localization/defaults/index.mjs +195 -0
  115. package/dist/localization/defaults/index.mjs.map +1 -0
  116. package/dist/localization/index.d.mts +7 -0
  117. package/dist/localization/index.d.ts +7 -0
  118. package/dist/localization/index.js +415 -0
  119. package/dist/localization/index.js.map +1 -0
  120. package/dist/localization/index.mjs +380 -0
  121. package/dist/localization/index.mjs.map +1 -0
  122. package/dist/theming/index.d.mts +5 -0
  123. package/dist/theming/index.d.ts +5 -0
  124. package/dist/theming/index.js +174 -0
  125. package/dist/theming/index.js.map +1 -0
  126. package/dist/theming/index.mjs +145 -0
  127. package/dist/theming/index.mjs.map +1 -0
  128. package/dist/utils/index.d.mts +15 -0
  129. package/dist/utils/index.d.ts +15 -0
  130. package/dist/utils/index.js +553 -0
  131. package/dist/utils/index.js.map +1 -0
  132. package/dist/utils/index.mjs +493 -0
  133. package/dist/utils/index.mjs.map +1 -0
  134. package/package.json +25 -24
@@ -0,0 +1,1124 @@
1
+ // src/components/date/DatePicker.tsx
2
+ import { useEffect as useEffect5, useState as useState6 } from "react";
3
+ import { ArrowDown, ArrowUp, ChevronDown as ChevronDown2 } from "lucide-react";
4
+
5
+ // src/localization/LanguageProvider.tsx
6
+ import { createContext, useContext, useEffect, useState as useState2 } from "react";
7
+
8
+ // src/hooks/useLocalStorage.ts
9
+ import { useCallback, useState } from "react";
10
+
11
+ // src/localization/util.ts
12
+ var languages = ["en", "de"];
13
+ var languagesLocalNames = {
14
+ en: "English",
15
+ de: "Deutsch"
16
+ };
17
+ var DEFAULT_LANGUAGE = "en";
18
+ var LanguageUtil = {
19
+ languages,
20
+ DEFAULT_LANGUAGE,
21
+ languagesLocalNames
22
+ };
23
+
24
+ // src/localization/LanguageProvider.tsx
25
+ import { jsx } from "react/jsx-runtime";
26
+ var LanguageContext = createContext({
27
+ language: LanguageUtil.DEFAULT_LANGUAGE,
28
+ setLanguage: (v) => v
29
+ });
30
+ var useLanguage = () => useContext(LanguageContext);
31
+ var useLocale = (overWriteLanguage) => {
32
+ const { language } = useLanguage();
33
+ const mapping = {
34
+ en: "en-US",
35
+ de: "de-DE"
36
+ };
37
+ return mapping[overWriteLanguage ?? language];
38
+ };
39
+
40
+ // src/localization/useTranslation.ts
41
+ var TranslationPluralCount = {
42
+ zero: 0,
43
+ one: 1,
44
+ two: 2,
45
+ few: 3,
46
+ many: 11,
47
+ other: -1
48
+ };
49
+ var useTranslation = (translations, overwriteTranslation = {}) => {
50
+ const { language: languageProp, translation: overwrite } = overwriteTranslation;
51
+ const { language: inferredLanguage } = useLanguage();
52
+ const usedLanguage = languageProp ?? inferredLanguage;
53
+ const usedTranslations = [...translations];
54
+ if (overwrite) {
55
+ usedTranslations.push(overwrite);
56
+ }
57
+ return (key, options) => {
58
+ const { count, replacements } = { ...{ count: 0, replacements: {} }, ...options };
59
+ try {
60
+ for (let i = translations.length - 1; i >= 0; i--) {
61
+ const translation = translations[i];
62
+ const localizedTranslation = translation[usedLanguage];
63
+ if (!localizedTranslation) {
64
+ continue;
65
+ }
66
+ const value = localizedTranslation[key];
67
+ if (!value) {
68
+ continue;
69
+ }
70
+ let forProcessing;
71
+ if (typeof value !== "string") {
72
+ if (count === TranslationPluralCount.zero && value?.zero) {
73
+ forProcessing = value.zero;
74
+ } else if (count === TranslationPluralCount.one && value?.one) {
75
+ forProcessing = value.one;
76
+ } else if (count === TranslationPluralCount.two && value?.two) {
77
+ forProcessing = value.two;
78
+ } else if (TranslationPluralCount.few <= count && count < TranslationPluralCount.many && value?.few) {
79
+ forProcessing = value.few;
80
+ } else if (count > TranslationPluralCount.many && value?.many) {
81
+ forProcessing = value.many;
82
+ } else {
83
+ forProcessing = value.other;
84
+ }
85
+ } else {
86
+ forProcessing = value;
87
+ }
88
+ forProcessing = forProcessing.replace(/\{\{(\w+)}}/g, (_, placeholder) => {
89
+ return replacements[placeholder] ?? `{{key:${placeholder}}}`;
90
+ });
91
+ return forProcessing;
92
+ }
93
+ } catch (e) {
94
+ console.error(e);
95
+ }
96
+ return `{{${usedLanguage}:${key}}}`;
97
+ };
98
+ };
99
+
100
+ // src/utils/noop.ts
101
+ var noop = () => void 0;
102
+
103
+ // src/utils/array.ts
104
+ var equalSizeGroups = (array, groupSize) => {
105
+ if (groupSize <= 0) {
106
+ console.warn(`group size should be greater than 0: groupSize = ${groupSize}`);
107
+ return [[...array]];
108
+ }
109
+ const groups = [];
110
+ for (let i = 0; i < array.length; i += groupSize) {
111
+ groups.push(array.slice(i, Math.min(i + groupSize, array.length)));
112
+ }
113
+ return groups;
114
+ };
115
+ var defaultRangeOptions = {
116
+ allowEmptyRange: false,
117
+ stepSize: 1,
118
+ exclusiveStart: false,
119
+ exclusiveEnd: true
120
+ };
121
+ var range = (endOrRange, options) => {
122
+ const { allowEmptyRange, stepSize, exclusiveStart, exclusiveEnd } = { ...defaultRangeOptions, ...options };
123
+ let start = 0;
124
+ let end;
125
+ if (typeof endOrRange === "number") {
126
+ end = endOrRange;
127
+ } else {
128
+ start = endOrRange[0];
129
+ end = endOrRange[1];
130
+ }
131
+ if (!exclusiveEnd) {
132
+ end -= 1;
133
+ }
134
+ if (exclusiveStart) {
135
+ start += 1;
136
+ }
137
+ if (end - 1 < start) {
138
+ if (!allowEmptyRange) {
139
+ console.warn(`range: end (${end}) < start (${start}) should be allowed explicitly, set options.allowEmptyRange to true`);
140
+ }
141
+ return [];
142
+ }
143
+ return Array.from({ length: end - start }, (_, index) => index * stepSize + start);
144
+ };
145
+ var closestMatch = (list, firstCloser) => {
146
+ return list.reduce((item1, item2) => {
147
+ return firstCloser(item1, item2) ? item1 : item2;
148
+ });
149
+ };
150
+
151
+ // src/utils/date.ts
152
+ var monthsList = ["january", "february", "march", "april", "may", "june", "july", "august", "september", "october", "november", "december"];
153
+ var weekDayList = ["sunday", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday"];
154
+ var changeDuration = (date, duration, isAdding) => {
155
+ const {
156
+ years = 0,
157
+ months = 0,
158
+ days = 0,
159
+ hours = 0,
160
+ minutes = 0,
161
+ seconds = 0,
162
+ milliseconds = 0
163
+ } = duration;
164
+ if (years < 0) {
165
+ console.error(`Range error years must be greater than 0: received ${years}`);
166
+ return new Date(date);
167
+ }
168
+ if (months < 0 || months > 11) {
169
+ console.error(`Range error month must be 0 <= month <= 11: received ${months}`);
170
+ return new Date(date);
171
+ }
172
+ if (days < 0) {
173
+ console.error(`Range error days must be greater than 0: received ${days}`);
174
+ return new Date(date);
175
+ }
176
+ if (hours < 0 || hours > 23) {
177
+ console.error(`Range error hours must be 0 <= hours <= 23: received ${hours}`);
178
+ return new Date(date);
179
+ }
180
+ if (minutes < 0 || minutes > 59) {
181
+ console.error(`Range error minutes must be 0 <= minutes <= 59: received ${minutes}`);
182
+ return new Date(date);
183
+ }
184
+ if (seconds < 0 || seconds > 59) {
185
+ console.error(`Range error seconds must be 0 <= seconds <= 59: received ${seconds}`);
186
+ return new Date(date);
187
+ }
188
+ if (milliseconds < 0) {
189
+ console.error(`Range error seconds must be greater than 0: received ${milliseconds}`);
190
+ return new Date(date);
191
+ }
192
+ const multiplier = isAdding ? 1 : -1;
193
+ const newDate = new Date(date);
194
+ newDate.setFullYear(newDate.getFullYear() + multiplier * years);
195
+ newDate.setMonth(newDate.getMonth() + multiplier * months);
196
+ newDate.setDate(newDate.getDate() + multiplier * days);
197
+ newDate.setHours(newDate.getHours() + multiplier * hours);
198
+ newDate.setMinutes(newDate.getMinutes() + multiplier * minutes);
199
+ newDate.setSeconds(newDate.getSeconds() + multiplier * seconds);
200
+ newDate.setMilliseconds(newDate.getMilliseconds() + multiplier * milliseconds);
201
+ return newDate;
202
+ };
203
+ var addDuration = (date, duration) => {
204
+ return changeDuration(date, duration, true);
205
+ };
206
+ var subtractDuration = (date, duration) => {
207
+ return changeDuration(date, duration, false);
208
+ };
209
+ var isInTimeSpan = (value, startDate, endDate) => {
210
+ if (startDate && endDate) {
211
+ console.assert(startDate <= endDate);
212
+ return startDate <= value && value <= endDate;
213
+ } else if (startDate) {
214
+ return startDate <= value;
215
+ } else if (endDate) {
216
+ return endDate >= value;
217
+ } else {
218
+ return true;
219
+ }
220
+ };
221
+ var equalDate = (date1, date2) => {
222
+ return date1.getFullYear() === date2.getFullYear() && date1.getMonth() === date2.getMonth() && date1.getDate() === date2.getDate();
223
+ };
224
+ var getWeeksForCalenderMonth = (date, weekStart, weeks = 6) => {
225
+ const month = date.getMonth();
226
+ const year = date.getFullYear();
227
+ const dayList = [];
228
+ let currentDate = new Date(year, month, 1);
229
+ const weekStartIndex = weekDayList.indexOf(weekStart);
230
+ while (currentDate.getDay() !== weekStartIndex) {
231
+ currentDate = subtractDuration(currentDate, { days: 1 });
232
+ }
233
+ while (dayList.length < 7 * weeks) {
234
+ const date2 = new Date(currentDate);
235
+ date2.setHours(date2.getHours(), date2.getMinutes());
236
+ dayList.push(date2);
237
+ currentDate = addDuration(currentDate, { days: 1 });
238
+ }
239
+ return equalSizeGroups(dayList, 7);
240
+ };
241
+
242
+ // src/components/date/DatePicker.tsx
243
+ import clsx5 from "clsx";
244
+
245
+ // src/components/user-action/Button.tsx
246
+ import { forwardRef } from "react";
247
+ import clsx from "clsx";
248
+ import { jsx as jsx2, jsxs } from "react/jsx-runtime";
249
+ var ButtonColorUtil = {
250
+ solid: ["primary", "secondary", "tertiary", "positive", "warning", "negative", "neutral"],
251
+ text: ["primary", "negative", "neutral"],
252
+ outline: ["primary"]
253
+ };
254
+ var IconButtonUtil = {
255
+ icon: [...ButtonColorUtil.solid, "transparent"]
256
+ };
257
+ var paddingMapping = {
258
+ small: "btn-sm",
259
+ medium: "btn-md",
260
+ large: "btn-lg"
261
+ };
262
+ var iconPaddingMapping = {
263
+ tiny: "icon-btn-xs",
264
+ small: "icon-btn-sm",
265
+ medium: "icon-btn-md",
266
+ large: "icon-btn-lg"
267
+ };
268
+ var ButtonUtil = {
269
+ paddingMapping,
270
+ iconPaddingMapping
271
+ };
272
+ var SolidButton = forwardRef(function SolidButton2({
273
+ children,
274
+ color = "primary",
275
+ size = "medium",
276
+ startIcon,
277
+ endIcon,
278
+ onClick,
279
+ className,
280
+ ...restProps
281
+ }, ref) {
282
+ const colorClasses = {
283
+ primary: "not-disabled:bg-button-solid-primary-background not-disabled:text-button-solid-primary-text",
284
+ secondary: "not-disabled:bg-button-solid-secondary-background not-disabled:text-button-solid-secondary-text",
285
+ tertiary: "not-disabled:bg-button-solid-tertiary-background not-disabled:text-button-solid-tertiary-text",
286
+ positive: "not-disabled:bg-button-solid-positive-background not-disabled:text-button-solid-positive-text",
287
+ warning: "not-disabled:bg-button-solid-warning-background not-disabled:text-button-solid-warning-text",
288
+ negative: "not-disabled:bg-button-solid-negative-background not-disabled:text-button-solid-negative-text",
289
+ neutral: "not-disabled:bg-button-solid-neutral-background not-disabled:text-button-solid-neutral-text"
290
+ }[color];
291
+ const iconColorClasses = {
292
+ primary: "not-group-disabled:text-button-solid-primary-icon",
293
+ secondary: "not-group-disabled:text-button-solid-secondary-icon",
294
+ tertiary: "not-group-disabled:text-button-solid-tertiary-icon",
295
+ positive: "not-group-disabled:text-button-solid-positive-icon",
296
+ warning: "not-group-disabled:text-button-solid-warning-icon",
297
+ negative: "not-group-disabled:text-button-solid-negative-icon",
298
+ neutral: "not-group-disabled:text-button-solid-neutral-icon"
299
+ }[color];
300
+ return /* @__PURE__ */ jsxs(
301
+ "button",
302
+ {
303
+ ref,
304
+ onClick,
305
+ className: clsx(
306
+ "group font-semibold",
307
+ colorClasses,
308
+ "not-disabled:hover:brightness-90",
309
+ "disabled:text-disabled-text disabled:bg-disabled-background",
310
+ ButtonUtil.paddingMapping[size],
311
+ className
312
+ ),
313
+ ...restProps,
314
+ children: [
315
+ startIcon && /* @__PURE__ */ jsx2(
316
+ "span",
317
+ {
318
+ className: clsx(
319
+ iconColorClasses,
320
+ "group-disabled:text-disabled-icon"
321
+ ),
322
+ children: startIcon
323
+ }
324
+ ),
325
+ children,
326
+ endIcon && /* @__PURE__ */ jsx2(
327
+ "span",
328
+ {
329
+ className: clsx(
330
+ iconColorClasses,
331
+ "group-disabled:text-disabled-icon"
332
+ ),
333
+ children: endIcon
334
+ }
335
+ )
336
+ ]
337
+ }
338
+ );
339
+ });
340
+ var TextButton = ({
341
+ children,
342
+ color = "neutral",
343
+ size = "medium",
344
+ startIcon,
345
+ endIcon,
346
+ onClick,
347
+ coloredHoverBackground = true,
348
+ className,
349
+ ...restProps
350
+ }) => {
351
+ const colorClasses = {
352
+ primary: "not-disabled:bg-transparent not-disabled:text-button-text-primary-text focus-style-none focus-visible:ring-2 not-disabled:focus-visible:ring-button-text-primary-text",
353
+ negative: "not-disabled:bg-transparent not-disabled:text-button-text-negative-text focus-style-none focus-visible:ring-2 not-disabled:focus-visible:ring-button-text-negative-text",
354
+ neutral: "not-disabled:bg-transparent not-disabled:text-button-text-neutral-text focus-style-none focus-visible:ring-2 not-disabled:focus-visible:ring-button-text-neutral-text"
355
+ }[color];
356
+ const backgroundColor = {
357
+ primary: "not-disabled:hover:bg-button-text-primary-text/20 not-disabled:focus-visible:bg-button-text-primary-text/20",
358
+ negative: "not-disabled:hover:bg-button-text-negative-text/20 not-disabled:focus-visible:bg-button-text-negative-text/20",
359
+ neutral: "not-disabled:hover:bg-button-text-neutral-text/20 not-disabled:focus-visible:bg-button-text-neutral-text/20"
360
+ }[color];
361
+ const iconColorClasses = {
362
+ primary: "not-group-disabled:text-button-text-primary-icon",
363
+ negative: "not-group-disabled:text-button-text-negative-icon",
364
+ neutral: "not-group-disabled:text-button-text-neutral-icon"
365
+ }[color];
366
+ return /* @__PURE__ */ jsxs(
367
+ "button",
368
+ {
369
+ onClick,
370
+ className: clsx(
371
+ "group font-semibold",
372
+ "disabled:text-disabled-text",
373
+ colorClasses,
374
+ {
375
+ [backgroundColor]: coloredHoverBackground,
376
+ "not-disabled:hover:bg-button-text-hover-background": !coloredHoverBackground
377
+ },
378
+ ButtonUtil.paddingMapping[size],
379
+ className
380
+ ),
381
+ ...restProps,
382
+ children: [
383
+ startIcon && /* @__PURE__ */ jsx2(
384
+ "span",
385
+ {
386
+ className: clsx(
387
+ iconColorClasses,
388
+ "group-disabled:text-disabled-icon"
389
+ ),
390
+ children: startIcon
391
+ }
392
+ ),
393
+ children,
394
+ endIcon && /* @__PURE__ */ jsx2(
395
+ "span",
396
+ {
397
+ className: clsx(
398
+ iconColorClasses,
399
+ "group-disabled:text-disabled-icon"
400
+ ),
401
+ children: endIcon
402
+ }
403
+ )
404
+ ]
405
+ }
406
+ );
407
+ };
408
+ var IconButton = forwardRef(function IconButton2({
409
+ children,
410
+ color = "primary",
411
+ size = "medium",
412
+ className,
413
+ ...restProps
414
+ }, ref) {
415
+ const colorClasses = {
416
+ primary: "not-disabled:bg-button-solid-primary-background not-disabled:text-button-solid-primary-text",
417
+ secondary: "not-disabled:bg-button-solid-secondary-background not-disabled:text-button-solid-secondary-text",
418
+ tertiary: "not-disabled:bg-button-solid-tertiary-background not-disabled:text-button-solid-tertiary-text",
419
+ positive: "not-disabled:bg-button-solid-positive-background not-disabled:text-button-solid-positive-text",
420
+ warning: "not-disabled:bg-button-solid-warning-background not-disabled:text-button-solid-warning-text",
421
+ negative: "not-disabled:bg-button-solid-negative-background not-disabled:text-button-solid-negative-text",
422
+ neutral: "not-disabled:bg-button-solid-neutral-background not-disabled:text-button-solid-neutral-text",
423
+ transparent: "not-disabled:bg-transparent"
424
+ }[color];
425
+ return /* @__PURE__ */ jsx2(
426
+ "button",
427
+ {
428
+ ref,
429
+ className: clsx(
430
+ colorClasses,
431
+ "not-disabled:hover:brightness-90",
432
+ "disabled:text-disabled-text",
433
+ {
434
+ "disabled:bg-disabled-background": color !== "transparent",
435
+ "disabled:opacity-70": color === "transparent",
436
+ "not-disabled:hover:bg-button-text-hover-background": color === "transparent"
437
+ },
438
+ ButtonUtil.iconPaddingMapping[size],
439
+ className
440
+ ),
441
+ ...restProps,
442
+ children
443
+ }
444
+ );
445
+ });
446
+
447
+ // src/components/date/YearMonthPicker.tsx
448
+ import { useEffect as useEffect3, useRef, useState as useState4 } from "react";
449
+ import { Scrollbars } from "react-custom-scrollbars-2";
450
+ import clsx3 from "clsx";
451
+
452
+ // src/components/layout/Expandable.tsx
453
+ import { forwardRef as forwardRef2, useCallback as useCallback2, useEffect as useEffect2, useId, useState as useState3 } from "react";
454
+ import { ChevronDown } from "lucide-react";
455
+ import clsx2 from "clsx";
456
+ import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
457
+ var ExpansionIcon = ({ isExpanded, className }) => {
458
+ return /* @__PURE__ */ jsx3(
459
+ ChevronDown,
460
+ {
461
+ "aria-hidden": true,
462
+ className: clsx2(
463
+ "min-w-6 w-6 min-h-6 h-6 transition-transform motion-safe:duration-200 motion-reduce:duration-0 ease-in-out",
464
+ { "rotate-180": isExpanded },
465
+ className
466
+ )
467
+ }
468
+ );
469
+ };
470
+ var Expandable = forwardRef2(function Expandable2({
471
+ children,
472
+ id: providedId,
473
+ label,
474
+ icon,
475
+ isExpanded = false,
476
+ onChange = noop,
477
+ clickOnlyOnHeader = true,
478
+ disabled = false,
479
+ className,
480
+ headerClassName,
481
+ contentClassName,
482
+ contentExpandedClassName
483
+ }, ref) {
484
+ const defaultIcon = useCallback2((expanded) => /* @__PURE__ */ jsx3(ExpansionIcon, { isExpanded: expanded }), []);
485
+ icon ??= defaultIcon;
486
+ const generatedId = useId();
487
+ const id = providedId ?? generatedId;
488
+ return /* @__PURE__ */ jsxs2(
489
+ "div",
490
+ {
491
+ ref,
492
+ onClick: () => !clickOnlyOnHeader && !disabled && onChange(!isExpanded),
493
+ className: clsx2(
494
+ "flex-col-0 bg-surface text-on-surface group rounded-lg shadow-sm",
495
+ { "cursor-pointer": !clickOnlyOnHeader && !disabled },
496
+ className
497
+ ),
498
+ children: [
499
+ /* @__PURE__ */ jsxs2(
500
+ "button",
501
+ {
502
+ onClick: () => clickOnlyOnHeader && !disabled && onChange(!isExpanded),
503
+ className: clsx2(
504
+ "flex-row-2 py-2 px-4 rounded-lg justify-between items-center bg-surface text-on-surface select-none",
505
+ {
506
+ "group-hover:brightness-97": !isExpanded,
507
+ "hover:brightness-97": isExpanded && !disabled,
508
+ "cursor-pointer": clickOnlyOnHeader && !disabled
509
+ },
510
+ headerClassName
511
+ ),
512
+ "aria-expanded": isExpanded,
513
+ "aria-controls": `${id}-content`,
514
+ "aria-disabled": disabled ?? void 0,
515
+ children: [
516
+ label,
517
+ icon(isExpanded)
518
+ ]
519
+ }
520
+ ),
521
+ /* @__PURE__ */ jsx3(
522
+ "div",
523
+ {
524
+ id: `${id}-content`,
525
+ className: clsx2(
526
+ "flex-col-2 px-4 transition-all duration-300 ease-in-out",
527
+ {
528
+ [clsx2("max-h-96 opacity-100 pb-2 overflow-y-auto", contentExpandedClassName)]: isExpanded,
529
+ "max-h-0 opacity-0 overflow-hidden": !isExpanded
530
+ },
531
+ contentClassName
532
+ ),
533
+ role: "region",
534
+ children
535
+ }
536
+ )
537
+ ]
538
+ }
539
+ );
540
+ });
541
+ var ExpandableUncontrolled = forwardRef2(function ExpandableUncontrolled2({
542
+ isExpanded,
543
+ onChange = noop,
544
+ ...props
545
+ }, ref) {
546
+ const [usedIsExpanded, setUsedIsExpanded] = useState3(isExpanded);
547
+ useEffect2(() => {
548
+ setUsedIsExpanded(isExpanded);
549
+ }, [isExpanded]);
550
+ return /* @__PURE__ */ jsx3(
551
+ Expandable,
552
+ {
553
+ ...props,
554
+ ref,
555
+ isExpanded: usedIsExpanded,
556
+ onChange: (value) => {
557
+ onChange(value);
558
+ setUsedIsExpanded(value);
559
+ }
560
+ }
561
+ );
562
+ });
563
+
564
+ // src/components/date/YearMonthPicker.tsx
565
+ import { jsx as jsx4 } from "react/jsx-runtime";
566
+ var YearMonthPicker = ({
567
+ displayedYearMonth = /* @__PURE__ */ new Date(),
568
+ start = subtractDuration(/* @__PURE__ */ new Date(), { years: 50 }),
569
+ end = addDuration(/* @__PURE__ */ new Date(), { years: 50 }),
570
+ onChange = noop,
571
+ className = "",
572
+ maxHeight = 300,
573
+ showValueOpen = true
574
+ }) => {
575
+ const locale = useLocale();
576
+ const ref = useRef(null);
577
+ useEffect3(() => {
578
+ const scrollToItem = () => {
579
+ if (ref.current) {
580
+ ref.current.scrollIntoView({
581
+ behavior: "instant",
582
+ block: "center"
583
+ });
584
+ }
585
+ };
586
+ scrollToItem();
587
+ }, [ref]);
588
+ if (end < start) {
589
+ console.error(`startYear: (${start}) less than endYear: (${end})`);
590
+ return null;
591
+ }
592
+ const years = range([start.getFullYear(), end.getFullYear()], { exclusiveEnd: false });
593
+ return /* @__PURE__ */ jsx4("div", { className: clsx3("flex-col-0 select-none", className), children: /* @__PURE__ */ jsx4(Scrollbars, { autoHeight: true, autoHeightMax: maxHeight, style: { height: "100%" }, children: /* @__PURE__ */ jsx4("div", { className: "flex-col-1 mr-3", children: years.map((year) => {
594
+ const selectedYear = displayedYearMonth.getFullYear() === year;
595
+ return /* @__PURE__ */ jsx4(
596
+ ExpandableUncontrolled,
597
+ {
598
+ ref: (displayedYearMonth.getFullYear() ?? (/* @__PURE__ */ new Date()).getFullYear()) === year ? ref : void 0,
599
+ label: /* @__PURE__ */ jsx4("span", { className: clsx3({ "text-primary font-bold": selectedYear }), children: year }),
600
+ isExpanded: showValueOpen && selectedYear,
601
+ contentClassName: "gap-y-1",
602
+ children: equalSizeGroups([...monthsList], 3).map((monthList, index) => /* @__PURE__ */ jsx4("div", { className: "flex-row-1", children: monthList.map((month) => {
603
+ const monthIndex = monthsList.indexOf(month);
604
+ const newDate = new Date(year, monthIndex);
605
+ const selectedMonth = selectedYear && monthIndex === displayedYearMonth.getMonth();
606
+ const firstOfMonth = new Date(year, monthIndex, 1);
607
+ const lastOfMonth = new Date(year, monthIndex, 1);
608
+ const isAfterStart = start === void 0 || start <= addDuration(subtractDuration(lastOfMonth, { days: 1 }), { months: 1 });
609
+ const isBeforeEnd = end === void 0 || firstOfMonth <= end;
610
+ const isValid = isAfterStart && isBeforeEnd;
611
+ return /* @__PURE__ */ jsx4(
612
+ SolidButton,
613
+ {
614
+ disabled: !isValid,
615
+ color: selectedMonth && isValid ? "primary" : "neutral",
616
+ className: "flex-1",
617
+ size: "small",
618
+ onClick: () => {
619
+ onChange(newDate);
620
+ },
621
+ children: new Intl.DateTimeFormat(locale, { month: "short" }).format(newDate)
622
+ },
623
+ month
624
+ );
625
+ }) }, index))
626
+ },
627
+ year
628
+ );
629
+ }) }) }) });
630
+ };
631
+ var YearMonthPickerUncontrolled = ({
632
+ displayedYearMonth,
633
+ onChange = noop,
634
+ ...props
635
+ }) => {
636
+ const [yearMonth, setYearMonth] = useState4(displayedYearMonth ?? /* @__PURE__ */ new Date());
637
+ useEffect3(() => setYearMonth(displayedYearMonth), [displayedYearMonth]);
638
+ return /* @__PURE__ */ jsx4(
639
+ YearMonthPicker,
640
+ {
641
+ displayedYearMonth: yearMonth,
642
+ onChange: (date) => {
643
+ setYearMonth(date);
644
+ onChange(date);
645
+ },
646
+ ...props
647
+ }
648
+ );
649
+ };
650
+
651
+ // src/components/date/DayPicker.tsx
652
+ import clsx4 from "clsx";
653
+ import { useEffect as useEffect4, useState as useState5 } from "react";
654
+ import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
655
+ var DayPicker = ({
656
+ displayedMonth,
657
+ selected,
658
+ start,
659
+ end,
660
+ onChange = noop,
661
+ weekStart = "monday",
662
+ markToday = true,
663
+ className = ""
664
+ }) => {
665
+ const locale = useLocale();
666
+ const month = displayedMonth.getMonth();
667
+ const weeks = getWeeksForCalenderMonth(displayedMonth, weekStart);
668
+ return /* @__PURE__ */ jsxs3("div", { className: clsx4("flex-col-1 min-w-[220px] select-none", className), children: [
669
+ /* @__PURE__ */ jsx5("div", { className: "flex-row-2 text-center", children: weeks[0].map((weekDay, index) => /* @__PURE__ */ jsx5("div", { className: "flex-1 font-semibold", children: new Intl.DateTimeFormat(locale, { weekday: "long" }).format(weekDay).substring(0, 2) }, index)) }),
670
+ weeks.map((week, index) => /* @__PURE__ */ jsx5("div", { className: "flex-row-2 text-center", children: week.map((date) => {
671
+ const isSelected = !!selected && equalDate(selected, date);
672
+ const isToday = equalDate(/* @__PURE__ */ new Date(), date);
673
+ const isSameMonth = date.getMonth() === month;
674
+ const isDayValid = isInTimeSpan(date, start, end);
675
+ return /* @__PURE__ */ jsx5(
676
+ "button",
677
+ {
678
+ disabled: !isDayValid,
679
+ className: clsx4(
680
+ "flex-1 rounded-full border-2",
681
+ {
682
+ "text-description": !isSameMonth && !isSelected && isDayValid,
683
+ "text-button-solid-neutral-text bg-button-solid-neutral-background": !isSelected && isSameMonth && isDayValid,
684
+ "text-button-solid-primary-text bg-button-solid-primary-background": isSelected && isDayValid,
685
+ "hover:brightness-90 hover:bg-button-solid-primary-background hover:text-button-solid-primary-text": isDayValid,
686
+ "text-disabled-text bg-disabled-background cursor-not-allowed": !isDayValid,
687
+ "border-secondary": isToday && markToday,
688
+ "border-transparent": !isToday || !markToday
689
+ }
690
+ ),
691
+ onClick: () => onChange(date),
692
+ children: date.getDate()
693
+ },
694
+ date.getDate()
695
+ );
696
+ }) }, index))
697
+ ] });
698
+ };
699
+ var DayPickerUncontrolled = ({
700
+ displayedMonth,
701
+ selected,
702
+ onChange = noop,
703
+ ...restProps
704
+ }) => {
705
+ const [date, setDate] = useState5(selected);
706
+ const [usedDisplayedMonth, setUsedDDisplayedMonth] = useState5(displayedMonth);
707
+ useEffect4(() => {
708
+ setDate(selected);
709
+ setUsedDDisplayedMonth(selected);
710
+ }, [selected]);
711
+ return /* @__PURE__ */ jsx5(
712
+ DayPicker,
713
+ {
714
+ displayedMonth: usedDisplayedMonth,
715
+ selected: date,
716
+ onChange: (newDate) => {
717
+ setDate(newDate);
718
+ setUsedDDisplayedMonth(newDate);
719
+ onChange(newDate);
720
+ },
721
+ ...restProps
722
+ }
723
+ );
724
+ };
725
+
726
+ // src/localization/defaults/time.ts
727
+ var monthTranslation = {
728
+ en: {
729
+ january: "January",
730
+ february: "Febuary",
731
+ march: "March",
732
+ april: "April",
733
+ may: "May",
734
+ june: "June",
735
+ july: "July",
736
+ august: "August",
737
+ september: "September",
738
+ october: "October",
739
+ november: "November",
740
+ december: "December"
741
+ },
742
+ de: {
743
+ january: "Januar",
744
+ february: "Febuar",
745
+ march: "M\xE4rz",
746
+ april: "April",
747
+ may: "Mai",
748
+ june: "Juni",
749
+ july: "Juli",
750
+ august: "August",
751
+ september: "September",
752
+ october: "October",
753
+ november: "November",
754
+ december: "December"
755
+ }
756
+ };
757
+ var timeTranslation = {
758
+ en: {
759
+ ...monthTranslation.en,
760
+ century: { one: "Century", other: "Centuries" },
761
+ decade: { one: "Decade", other: "Decades" },
762
+ year: { one: "Year", other: "Years" },
763
+ month: { one: "Month", other: "Months" },
764
+ day: { one: "Day", other: "Days" },
765
+ hour: { one: "Hour", other: "Hours" },
766
+ minute: { one: "Minute", other: "Minutes" },
767
+ second: { one: "Second", other: "Seconds" },
768
+ millisecond: { one: "Millisecond", other: "Milliseconds" },
769
+ microsecond: { one: "Microsecond", other: "Microseconds" },
770
+ nanosecond: { one: "Nanosecond", other: "Nanoseconds" },
771
+ yesterday: "Yesterday",
772
+ today: "Today",
773
+ tomorrow: "Tomorrow",
774
+ in: "in",
775
+ ago: "ago"
776
+ },
777
+ de: {
778
+ ...monthTranslation.de,
779
+ century: { one: "Jahrhundert", other: "Jahrhunderte" },
780
+ decade: { one: "Jahrzehnt", other: "Jahrzehnte" },
781
+ year: { one: "Jahr", other: "Jahre" },
782
+ month: { one: "Monat", other: "Monate" },
783
+ day: { one: "Tag", other: "Tage" },
784
+ hour: { one: "Stunde", other: "Stunden" },
785
+ minute: { one: "Minute", other: "Minuten" },
786
+ second: { one: "Sekunde", other: "Sekunden" },
787
+ millisecond: { one: "Millisekunde", other: "Millisekunden" },
788
+ microsecond: { one: "Mikrosekunde", other: "Mikrosekunden" },
789
+ nanosecond: { one: "Nanosekunde", other: "Nanosekunden" },
790
+ yesterday: "Gestern",
791
+ today: "Heute",
792
+ tomorrow: "Morgen",
793
+ in: "in",
794
+ ago: "vor"
795
+ }
796
+ };
797
+
798
+ // src/components/date/DatePicker.tsx
799
+ import { jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
800
+ var DatePicker = ({
801
+ overwriteTranslation,
802
+ value = /* @__PURE__ */ new Date(),
803
+ start = subtractDuration(/* @__PURE__ */ new Date(), { years: 50 }),
804
+ end = addDuration(/* @__PURE__ */ new Date(), { years: 50 }),
805
+ initialDisplay = "day",
806
+ onChange = noop,
807
+ yearMonthPickerProps,
808
+ dayPickerProps,
809
+ className = ""
810
+ }) => {
811
+ const locale = useLocale();
812
+ const translation = useTranslation([timeTranslation], overwriteTranslation);
813
+ const [displayedMonth, setDisplayedMonth] = useState6(value);
814
+ const [displayMode, setDisplayMode] = useState6(initialDisplay);
815
+ useEffect5(() => {
816
+ setDisplayedMonth(value);
817
+ }, [value]);
818
+ return /* @__PURE__ */ jsxs4("div", { className: clsx5("flex-col-4", className), children: [
819
+ /* @__PURE__ */ jsxs4("div", { className: "flex-row-2 items-center justify-between h-7", children: [
820
+ /* @__PURE__ */ jsxs4(
821
+ TextButton,
822
+ {
823
+ className: clsx5("flex-row-1 items-center cursor-pointer select-none", {
824
+ "text-disabled-text": displayMode !== "day"
825
+ }),
826
+ onClick: () => setDisplayMode(displayMode === "day" ? "yearMonth" : "day"),
827
+ children: [
828
+ `${new Intl.DateTimeFormat(locale, { month: "long" }).format(displayedMonth)} ${displayedMonth.getFullYear()}`,
829
+ /* @__PURE__ */ jsx6(ChevronDown2, { size: 16 })
830
+ ]
831
+ }
832
+ ),
833
+ displayMode === "day" && /* @__PURE__ */ jsxs4("div", { className: "flex-row-2 justify-end", children: [
834
+ /* @__PURE__ */ jsx6(
835
+ SolidButton,
836
+ {
837
+ size: "small",
838
+ color: "primary",
839
+ disabled: !isInTimeSpan(subtractDuration(displayedMonth, { months: 1 }), start, end),
840
+ onClick: () => {
841
+ setDisplayedMonth(subtractDuration(displayedMonth, { months: 1 }));
842
+ },
843
+ children: /* @__PURE__ */ jsx6(ArrowUp, { size: 20 })
844
+ }
845
+ ),
846
+ /* @__PURE__ */ jsx6(
847
+ SolidButton,
848
+ {
849
+ size: "small",
850
+ color: "primary",
851
+ disabled: !isInTimeSpan(addDuration(displayedMonth, { months: 1 }), start, end),
852
+ onClick: () => {
853
+ setDisplayedMonth(addDuration(displayedMonth, { months: 1 }));
854
+ },
855
+ children: /* @__PURE__ */ jsx6(ArrowDown, { size: 20 })
856
+ }
857
+ )
858
+ ] })
859
+ ] }),
860
+ displayMode === "yearMonth" ? /* @__PURE__ */ jsx6(
861
+ YearMonthPicker,
862
+ {
863
+ ...yearMonthPickerProps,
864
+ displayedYearMonth: value,
865
+ start,
866
+ end,
867
+ onChange: (newDate) => {
868
+ setDisplayedMonth(newDate);
869
+ setDisplayMode("day");
870
+ }
871
+ }
872
+ ) : /* @__PURE__ */ jsxs4("div", { children: [
873
+ /* @__PURE__ */ jsx6(
874
+ DayPicker,
875
+ {
876
+ ...dayPickerProps,
877
+ displayedMonth,
878
+ start,
879
+ end,
880
+ selected: value,
881
+ onChange: (date) => {
882
+ onChange(date);
883
+ }
884
+ }
885
+ ),
886
+ /* @__PURE__ */ jsx6("div", { className: "mt-2", children: /* @__PURE__ */ jsx6(
887
+ TextButton,
888
+ {
889
+ color: "primary",
890
+ onClick: () => {
891
+ const newDate = /* @__PURE__ */ new Date();
892
+ newDate.setHours(value.getHours(), value.getMinutes());
893
+ onChange(newDate);
894
+ },
895
+ children: translation("today")
896
+ }
897
+ ) })
898
+ ] })
899
+ ] });
900
+ };
901
+ var DatePickerUncontrolled = ({
902
+ value = /* @__PURE__ */ new Date(),
903
+ onChange = noop,
904
+ ...props
905
+ }) => {
906
+ const [date, setDate] = useState6(value);
907
+ useEffect5(() => setDate(value), [value]);
908
+ return /* @__PURE__ */ jsx6(
909
+ DatePicker,
910
+ {
911
+ ...props,
912
+ value: date,
913
+ onChange: (date1) => {
914
+ setDate(date1);
915
+ onChange(date1);
916
+ }
917
+ }
918
+ );
919
+ };
920
+
921
+ // src/components/date/TimeDisplay.tsx
922
+ import { jsx as jsx7 } from "react/jsx-runtime";
923
+ var defaultTimeDisplayTranslations = {
924
+ en: {
925
+ ...timeTranslation.en,
926
+ inDays: `in {{days}} days`,
927
+ agoDays: `{{days}} days ago`
928
+ },
929
+ de: {
930
+ ...timeTranslation.de,
931
+ inDays: `in {{days}} Tagen`,
932
+ agoDays: `vor {{days}} Tagen`
933
+ }
934
+ };
935
+ var TimeDisplay = ({
936
+ overwriteTranslation,
937
+ date,
938
+ mode = "daysFromToday"
939
+ }) => {
940
+ const translation = useTranslation([defaultTimeDisplayTranslations], overwriteTranslation);
941
+ const difference = (/* @__PURE__ */ new Date()).setHours(0, 0, 0, 0).valueOf() - new Date(date).setHours(0, 0, 0, 0).valueOf();
942
+ const isBefore = difference > 0;
943
+ const differenceInDays = Math.floor(Math.abs(difference) / (1e3 * 3600 * 24));
944
+ let displayString;
945
+ if (differenceInDays === 0) {
946
+ displayString = translation("today");
947
+ } else if (differenceInDays === 1) {
948
+ displayString = isBefore ? translation("yesterday") : translation("tomorrow");
949
+ } else {
950
+ displayString = isBefore ? translation("agoDays", { replacements: { days: differenceInDays.toString() } }) : translation("inDays", { replacements: { days: differenceInDays.toString() } });
951
+ }
952
+ const monthToTranslation = {
953
+ 0: translation("january"),
954
+ 1: translation("february"),
955
+ 2: translation("march"),
956
+ 3: translation("april"),
957
+ 4: translation("may"),
958
+ 5: translation("june"),
959
+ 6: translation("july"),
960
+ 7: translation("august"),
961
+ 8: translation("september"),
962
+ 9: translation("october"),
963
+ 10: translation("november"),
964
+ 11: translation("december")
965
+ };
966
+ let fullString;
967
+ if (mode === "daysFromToday") {
968
+ fullString = `${date.getHours().toString().padStart(2, "0")}:${date.getMinutes().toString().padStart(2, "0")} - ${displayString}`;
969
+ } else {
970
+ fullString = `${date.getDate()}. ${monthToTranslation[date.getMonth()]} ${date.getFullYear()}`;
971
+ }
972
+ return /* @__PURE__ */ jsx7("span", { children: fullString });
973
+ };
974
+
975
+ // src/components/date/TimePicker.tsx
976
+ import { useEffect as useEffect6, useRef as useRef2, useState as useState7 } from "react";
977
+ import { Scrollbars as Scrollbars2 } from "react-custom-scrollbars-2";
978
+ import clsx6 from "clsx";
979
+ import { jsx as jsx8, jsxs as jsxs5 } from "react/jsx-runtime";
980
+ var TimePicker = ({
981
+ time = /* @__PURE__ */ new Date(),
982
+ onChange = noop,
983
+ is24HourFormat = true,
984
+ minuteIncrement = "5min",
985
+ maxHeight = 300,
986
+ className = ""
987
+ }) => {
988
+ const minuteRef = useRef2(null);
989
+ const hourRef = useRef2(null);
990
+ const isPM = time.getHours() >= 11;
991
+ const hours = is24HourFormat ? range(24) : range([1, 12], { exclusiveEnd: false });
992
+ let minutes = range(60);
993
+ useEffect6(() => {
994
+ const scrollToItem = () => {
995
+ if (minuteRef.current) {
996
+ const container = minuteRef.current.parentElement;
997
+ const hasOverflow = container.scrollHeight > maxHeight;
998
+ if (hasOverflow) {
999
+ minuteRef.current.scrollIntoView({
1000
+ behavior: "instant",
1001
+ block: "nearest"
1002
+ });
1003
+ }
1004
+ }
1005
+ };
1006
+ scrollToItem();
1007
+ }, [minuteRef, minuteRef.current]);
1008
+ useEffect6(() => {
1009
+ const scrollToItem = () => {
1010
+ if (hourRef.current) {
1011
+ const container = hourRef.current.parentElement;
1012
+ const hasOverflow = container.scrollHeight > maxHeight;
1013
+ if (hasOverflow) {
1014
+ hourRef.current.scrollIntoView({
1015
+ behavior: "instant",
1016
+ block: "nearest"
1017
+ });
1018
+ }
1019
+ }
1020
+ };
1021
+ scrollToItem();
1022
+ }, [hourRef, hourRef.current]);
1023
+ switch (minuteIncrement) {
1024
+ case "5min":
1025
+ minutes = minutes.filter((value) => value % 5 === 0);
1026
+ break;
1027
+ case "10min":
1028
+ minutes = minutes.filter((value) => value % 10 === 0);
1029
+ break;
1030
+ case "15min":
1031
+ minutes = minutes.filter((value) => value % 15 === 0);
1032
+ break;
1033
+ case "30min":
1034
+ minutes = minutes.filter((value) => value % 30 === 0);
1035
+ break;
1036
+ }
1037
+ const closestMinute = closestMatch(minutes, (item1, item2) => Math.abs(item1 - time.getMinutes()) < Math.abs(item2 - time.getMinutes()));
1038
+ const style = (selected) => clsx6(
1039
+ "chip-full hover:brightness-90 hover:bg-primary hover:text-on-primary rounded-md mr-3",
1040
+ { "bg-primary text-on-primary": selected, "bg-white text-black": !selected }
1041
+ );
1042
+ const onChangeWrapper = (transformer) => {
1043
+ const newDate = new Date(time);
1044
+ transformer(newDate);
1045
+ onChange(newDate);
1046
+ };
1047
+ return /* @__PURE__ */ jsxs5("div", { className: clsx6("flex-row-2 w-fit min-w-[150px] select-none", className), children: [
1048
+ /* @__PURE__ */ jsx8(Scrollbars2, { autoHeight: true, autoHeightMax: maxHeight, style: { height: "100%" }, children: /* @__PURE__ */ jsx8("div", { className: "flex-col-1 h-full", children: hours.map((hour) => {
1049
+ const currentHour = hour === time.getHours() - (!is24HourFormat && isPM ? 12 : 0);
1050
+ return /* @__PURE__ */ jsx8(
1051
+ "button",
1052
+ {
1053
+ ref: currentHour ? hourRef : void 0,
1054
+ className: style(currentHour),
1055
+ onClick: () => onChangeWrapper((newDate) => newDate.setHours(hour + (!is24HourFormat && isPM ? 12 : 0))),
1056
+ children: hour.toString().padStart(2, "0")
1057
+ },
1058
+ hour
1059
+ );
1060
+ }) }) }),
1061
+ /* @__PURE__ */ jsx8(Scrollbars2, { autoHeight: true, autoHeightMax: maxHeight, style: { height: "100%" }, children: /* @__PURE__ */ jsx8("div", { className: "flex-col-1 h-full", children: minutes.map((minute) => {
1062
+ const currentMinute = minute === closestMinute;
1063
+ return /* @__PURE__ */ jsx8(
1064
+ "button",
1065
+ {
1066
+ ref: currentMinute ? minuteRef : void 0,
1067
+ className: style(currentMinute),
1068
+ onClick: () => onChangeWrapper((newDate) => newDate.setMinutes(minute)),
1069
+ children: minute.toString().padStart(2, "0")
1070
+ },
1071
+ minute + minuteIncrement
1072
+ );
1073
+ }) }) }),
1074
+ !is24HourFormat && /* @__PURE__ */ jsxs5("div", { className: "flex-col-1", children: [
1075
+ /* @__PURE__ */ jsx8(
1076
+ "button",
1077
+ {
1078
+ className: style(!isPM),
1079
+ onClick: () => onChangeWrapper((newDate) => isPM && newDate.setHours(newDate.getHours() - 12)),
1080
+ children: "AM"
1081
+ }
1082
+ ),
1083
+ /* @__PURE__ */ jsx8(
1084
+ "button",
1085
+ {
1086
+ className: style(isPM),
1087
+ onClick: () => onChangeWrapper((newDate) => !isPM && newDate.setHours(newDate.getHours() + 12)),
1088
+ children: "PM"
1089
+ }
1090
+ )
1091
+ ] })
1092
+ ] });
1093
+ };
1094
+ var TimePickerUncontrolled = ({
1095
+ time,
1096
+ onChange = noop,
1097
+ ...props
1098
+ }) => {
1099
+ const [value, setValue] = useState7(time);
1100
+ useEffect6(() => setValue(time), [time]);
1101
+ return /* @__PURE__ */ jsx8(
1102
+ TimePicker,
1103
+ {
1104
+ ...props,
1105
+ time: value,
1106
+ onChange: (time1) => {
1107
+ setValue(time1);
1108
+ onChange(time1);
1109
+ }
1110
+ }
1111
+ );
1112
+ };
1113
+ export {
1114
+ DatePicker,
1115
+ DatePickerUncontrolled,
1116
+ DayPicker,
1117
+ DayPickerUncontrolled,
1118
+ TimeDisplay,
1119
+ TimePicker,
1120
+ TimePickerUncontrolled,
1121
+ YearMonthPicker,
1122
+ YearMonthPickerUncontrolled
1123
+ };
1124
+ //# sourceMappingURL=index.mjs.map