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