@digvation/ui 1.1.0

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.
package/dist/index.cjs ADDED
@@ -0,0 +1,4477 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ DAccordion: () => DAccordion,
24
+ DAccordionItem: () => DAccordionItem,
25
+ DAlert: () => DAlert,
26
+ DAvatar: () => DAvatar,
27
+ DBadge: () => DBadge,
28
+ DBreadcrumb: () => DBreadcrumb,
29
+ DBreadcrumbItem: () => DBreadcrumbItem,
30
+ DBreadcrumbLink: () => DBreadcrumbLink,
31
+ DBreadcrumbList: () => DBreadcrumbList,
32
+ DBreadcrumbSeparator: () => DBreadcrumbSeparator,
33
+ DButton: () => DButton,
34
+ DCard: () => DCard,
35
+ DCardContent: () => DCardContent,
36
+ DCardFooter: () => DCardFooter,
37
+ DCardHeader: () => DCardHeader,
38
+ DCardSkeleton: () => DCardSkeleton,
39
+ DCheckbox: () => DCheckbox,
40
+ DCombobox: () => DCombobox,
41
+ DConfirmDialog: () => DConfirmDialog,
42
+ DConnectionError: () => DConnectionError,
43
+ DCurrencyInput: () => DCurrencyInput,
44
+ DDataTable: () => DDataTable,
45
+ DDatePicker: () => DDatePicker,
46
+ DDateRangeFilter: () => DDateRangeFilter,
47
+ DDecimalInput: () => DDecimalInput,
48
+ DDialog: () => DDialog,
49
+ DDropdown: () => DDropdown,
50
+ DEmptyState: () => DEmptyState,
51
+ DExportButton: () => DExportButton,
52
+ DForm: () => DForm,
53
+ DFormField: () => DFormField,
54
+ DFormSkeleton: () => DFormSkeleton,
55
+ DInfoNote: () => DInfoNote,
56
+ DInput: () => DInput,
57
+ DLoadingIndicator: () => DLoadingIndicator,
58
+ DLoadingOverlay: () => DLoadingOverlay,
59
+ DLocalizationProvider: () => DLocalizationProvider,
60
+ DNotificationPanel: () => DNotificationPanel,
61
+ DPagination: () => DPagination,
62
+ DProgress: () => DProgress,
63
+ DRadio: () => DRadio,
64
+ DRangeDatePicker: () => DRangeDatePicker,
65
+ DSearchInput: () => DSearchInput,
66
+ DSelect: () => DSelect,
67
+ DSelectFilter: () => DSelectFilter,
68
+ DSeparator: () => DSeparator,
69
+ DSkeleton: () => DSkeleton,
70
+ DSpinner: () => DSpinner,
71
+ DSplashScreen: () => DSplashScreen,
72
+ DStatusFilter: () => DStatusFilter,
73
+ DTableSkeleton: () => DTableSkeleton,
74
+ DTabs: () => DTabs,
75
+ DTabsContent: () => DTabsContent,
76
+ DTabsList: () => DTabsList,
77
+ DTabsTrigger: () => DTabsTrigger,
78
+ DTextarea: () => DTextarea,
79
+ DThemeProvider: () => DThemeProvider,
80
+ DTimePicker: () => DTimePicker,
81
+ DToastContainer: () => DToastContainer,
82
+ DToastProvider: () => DToastProvider,
83
+ DToggle: () => DToggle,
84
+ DTooltip: () => DTooltip,
85
+ DValidationMessage: () => DValidationMessage,
86
+ DropdownContext: () => DropdownContext,
87
+ accepted: () => accepted,
88
+ cn: () => cn,
89
+ createCssVariableTheme: () => createCssVariableTheme,
90
+ createDTranslator: () => createDTranslator,
91
+ createProjectThemeTokens: () => createProjectThemeTokens,
92
+ customValidation: () => customValidation,
93
+ date: () => date,
94
+ defaultThemeTokens: () => defaultThemeTokens,
95
+ email: () => email,
96
+ enMessages: () => enMessages,
97
+ formatCurrencyInputValue: () => formatCurrencyInputValue,
98
+ getLocalizedMonthNames: () => getLocalizedMonthNames,
99
+ getLocalizedWeekdayNames: () => getLocalizedWeekdayNames,
100
+ getPaginationItems: () => getPaginationItems,
101
+ getPaginationPages: () => getPaginationPages,
102
+ idMessages: () => idMessages,
103
+ integer: () => integer,
104
+ maxLength: () => maxLength,
105
+ maxValue: () => maxValue,
106
+ minLength: () => minLength,
107
+ minValue: () => minValue,
108
+ normalizeDecimalInput: () => normalizeDecimalInput,
109
+ oneOf: () => oneOf,
110
+ parseCurrencyInputValue: () => parseCurrencyInputValue,
111
+ pattern: () => pattern,
112
+ required: () => required,
113
+ sameAs: () => sameAs,
114
+ selectOptionsFromChildren: () => selectOptionsFromChildren,
115
+ themeTokensToCss: () => themeTokensToCss,
116
+ time: () => time,
117
+ url: () => url,
118
+ useDFormField: () => useDFormField,
119
+ useDLocalization: () => useDLocalization,
120
+ useDropdown: () => useDropdown,
121
+ useDropdownClose: () => useDropdownClose,
122
+ useToast: () => useToast,
123
+ validateValue: () => validateValue
124
+ });
125
+ module.exports = __toCommonJS(index_exports);
126
+
127
+ // src/cn.ts
128
+ var import_clsx = require("clsx");
129
+ var import_tailwind_merge = require("tailwind-merge");
130
+ function cn(...inputs) {
131
+ return (0, import_tailwind_merge.twMerge)((0, import_clsx.clsx)(inputs));
132
+ }
133
+
134
+ // src/alert/alert.tsx
135
+ var import_jsx_runtime = require("react/jsx-runtime");
136
+ var alertClasses = {
137
+ neutral: "border-[var(--color-border)] bg-[var(--color-surface-muted)]/60 text-[var(--color-text)]",
138
+ info: "border-[var(--color-info)]/25 bg-[var(--color-info)]/10 text-[var(--color-text)]",
139
+ success: "border-[var(--color-success)]/25 bg-[var(--color-success)]/10 text-[var(--color-text)]",
140
+ warning: "border-[var(--color-warning)]/30 bg-[var(--color-warning)]/10 text-[var(--color-text)]",
141
+ danger: "border-[var(--color-danger)]/30 bg-[var(--color-danger)]/10 text-[var(--color-text)]"
142
+ };
143
+ function DAlert({ variant = "info", title, icon, className, children, ...props }) {
144
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { role: "alert", className: cn("flex gap-3 rounded-[var(--radius-control)] border p-3 text-sm", alertClasses[variant], className), ...props, children: [
145
+ icon ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "mt-0.5 shrink-0", children: icon }) : null,
146
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "min-w-0", children: [
147
+ title ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "font-semibold", children: title }) : null,
148
+ children ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: title ? "mt-1 text-xs leading-5" : "text-xs leading-5", children }) : null
149
+ ] })
150
+ ] });
151
+ }
152
+
153
+ // src/badge/badge.tsx
154
+ var import_jsx_runtime2 = require("react/jsx-runtime");
155
+ var variantClasses = {
156
+ default: "bg-[var(--color-surface-muted)] text-[var(--color-text-muted)]",
157
+ primary: "bg-[var(--color-brand)]/10 text-[var(--color-brand)]",
158
+ secondary: "bg-[var(--color-text)]/7 text-[var(--color-text)]",
159
+ info: "bg-[var(--color-info)]/10 text-[var(--color-info)]",
160
+ success: "bg-[var(--color-success)]/10 text-[var(--color-success)]",
161
+ warning: "bg-[var(--color-warning)]/10 text-[var(--color-warning)]",
162
+ danger: "bg-[var(--color-danger)]/10 text-[var(--color-danger)]",
163
+ outline: "border border-[var(--color-border)] bg-transparent text-[var(--color-text)]"
164
+ };
165
+ function DBadge({ className, variant = "default", dot = false, dotClassName, children, ...props }) {
166
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: cn("inline-flex items-center gap-1.5 rounded-full px-2.5 py-0.5 text-xs font-medium", variantClasses[variant], className), ...props, children: [
167
+ dot ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: cn("size-1.5 rounded-full bg-current", dotClassName), "aria-hidden": "true" }) : null,
168
+ children
169
+ ] });
170
+ }
171
+
172
+ // src/button/button.tsx
173
+ var import_react = require("react");
174
+ var import_jsx_runtime3 = require("react/jsx-runtime");
175
+ var variantClasses2 = {
176
+ primary: "bg-[var(--color-brand)] text-[var(--color-brand-foreground)] shadow-[var(--shadow-sm)] hover:bg-[var(--color-brand-hover)] active:bg-[var(--color-brand-active)]",
177
+ secondary: "bg-[var(--color-secondary)] text-[var(--color-secondary-foreground)] hover:bg-[var(--color-secondary-hover)] active:bg-[var(--color-secondary-active)]",
178
+ outline: "border border-[var(--color-border)] bg-[var(--color-surface)] text-[var(--color-text)] hover:bg-[var(--color-surface-muted)]",
179
+ ghost: "bg-transparent text-[var(--color-text)] hover:bg-[var(--color-surface-muted)]",
180
+ soft: "bg-[var(--color-brand)]/10 text-[var(--color-brand)] hover:bg-[var(--color-brand)]/15 active:bg-[var(--color-brand)]/20",
181
+ info: "bg-[var(--color-info)] text-white shadow-[var(--shadow-sm)] hover:brightness-95 active:brightness-90",
182
+ success: "bg-[var(--color-success)] text-white shadow-[var(--shadow-sm)] hover:brightness-95 active:brightness-90",
183
+ warning: "bg-[var(--color-warning)] text-white shadow-[var(--shadow-sm)] hover:brightness-95 active:brightness-90",
184
+ danger: "bg-[var(--color-danger)] text-white shadow-[var(--shadow-sm)] hover:brightness-95 active:brightness-90",
185
+ link: "h-auto bg-transparent px-0 text-[var(--color-brand)] underline-offset-4 hover:underline active:opacity-80"
186
+ };
187
+ var sizeClasses = {
188
+ sm: "h-8 gap-1.5 px-3 text-xs",
189
+ md: "h-10 gap-2 px-4 text-sm",
190
+ lg: "h-12 gap-2 px-6 text-base",
191
+ icon: "size-10 p-0"
192
+ };
193
+ var DButton = (0, import_react.forwardRef)(function DButton2({ className, variant = "primary", size = "md", loading = false, leftIcon, rightIcon, fullWidth = false, disabled, type = "button", children, ...props }, ref) {
194
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
195
+ "button",
196
+ {
197
+ ref,
198
+ "data-ds-component": "button",
199
+ type,
200
+ disabled: disabled || loading,
201
+ "aria-busy": loading || void 0,
202
+ className: cn(
203
+ "inline-flex items-center justify-center rounded-[var(--radius-control)] font-medium transition-[background-color,color,border-color,box-shadow,transform,opacity] duration-150 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-focus)]/25 focus-visible:ring-offset-2 focus-visible:ring-offset-[var(--color-background)] active:scale-[0.98] motion-reduce:transform-none disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50",
204
+ variantClasses2[variant],
205
+ variant !== "link" && sizeClasses[size],
206
+ variant === "link" && size === "sm" && "text-xs",
207
+ variant === "link" && size === "md" && "text-sm",
208
+ variant === "link" && size === "lg" && "text-base",
209
+ fullWidth && "w-full",
210
+ className
211
+ ),
212
+ ...props,
213
+ children: [
214
+ loading ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "size-4 animate-spin rounded-full border-2 border-current border-t-transparent", "aria-hidden": "true" }) : leftIcon,
215
+ children ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { children }) : null,
216
+ !loading ? rightIcon : null
217
+ ]
218
+ }
219
+ );
220
+ });
221
+
222
+ // src/card/card.tsx
223
+ var import_jsx_runtime4 = require("react/jsx-runtime");
224
+ var variants = {
225
+ default: "border border-[var(--color-border)] bg-[var(--color-surface)] shadow-[var(--shadow-sm)]",
226
+ outlined: "border border-[var(--color-border)] bg-[var(--color-surface)]",
227
+ elevated: "border border-transparent bg-[var(--color-surface)] shadow-[var(--shadow-md)]",
228
+ interactive: "border border-[var(--color-border)] bg-[var(--color-surface)] shadow-[var(--shadow-sm)] transition-[transform,box-shadow,border-color] hover:-translate-y-0.5 hover:border-[var(--color-brand)]/30 hover:shadow-[var(--shadow-md)]"
229
+ };
230
+ function DCard({ className, variant = "default", ...props }) {
231
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("section", { className: cn("rounded-[var(--radius-card)]", variants[variant], className), ...props });
232
+ }
233
+ function DCardHeader({ className, ...props }) {
234
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: cn("border-b border-[var(--color-border)] px-4 py-3", className), ...props });
235
+ }
236
+ function DCardContent({ className, ...props }) {
237
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: cn("p-4", className), ...props });
238
+ }
239
+ function DCardFooter({ className, ...props }) {
240
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: cn("border-t border-[var(--color-border)] px-4 py-3", className), ...props });
241
+ }
242
+
243
+ // src/checkbox/checkbox.tsx
244
+ var import_react2 = require("react");
245
+ var import_jsx_runtime5 = require("react/jsx-runtime");
246
+ var DCheckbox = (0, import_react2.forwardRef)(function DCheckbox2({ className, ...props }, ref) {
247
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { "data-ds-component": "checkbox", className: cn("inline-flex size-4 shrink-0", className), children: [
248
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("input", { ref, type: "checkbox", className: "peer sr-only", ...props }),
249
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "grid size-4 place-items-center rounded-[var(--radius-control)] border border-[var(--color-border)] bg-[var(--color-surface)] text-[var(--color-brand-foreground)] transition-colors peer-checked:border-[var(--color-brand)] peer-checked:bg-[var(--color-brand)] peer-checked:[&>svg]:opacity-100 peer-focus-visible:ring-2 peer-focus-visible:ring-[var(--color-brand)]/20 peer-disabled:cursor-not-allowed peer-disabled:opacity-50", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("svg", { viewBox: "0 0 12 12", className: "size-3 opacity-0", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
250
+ "path",
251
+ {
252
+ d: "m2 6 2.4 2.4L10 2.8",
253
+ fill: "none",
254
+ stroke: "currentColor",
255
+ strokeLinecap: "round",
256
+ strokeWidth: "1.8"
257
+ }
258
+ ) }) })
259
+ ] });
260
+ });
261
+
262
+ // src/combobox/combobox.tsx
263
+ var import_react7 = require("react");
264
+
265
+ // src/dropdown/dropdown.tsx
266
+ var import_react5 = require("react");
267
+ var import_react_dom = require("react-dom");
268
+
269
+ // src/internal/floating/use-floating-position.ts
270
+ var import_react3 = require("react");
271
+
272
+ // src/internal/scroll-lock.ts
273
+ var lockCount = 0;
274
+ var restore = null;
275
+ function lockDocumentScroll() {
276
+ if (typeof document === "undefined" || typeof window === "undefined") return () => {
277
+ };
278
+ lockCount += 1;
279
+ if (lockCount === 1) {
280
+ const body = document.body;
281
+ const previousOverflow = body.style.overflow;
282
+ const previousPaddingRight = body.style.paddingRight;
283
+ const previousCompensation = body.style.getPropertyValue("--ds-scrollbar-compensation");
284
+ const computedPaddingRight = Number.parseFloat(window.getComputedStyle(body).paddingRight) || 0;
285
+ const scrollbarWidth = Math.max(0, window.innerWidth - document.documentElement.clientWidth);
286
+ body.style.overflow = "hidden";
287
+ body.style.setProperty("--ds-scrollbar-compensation", `${scrollbarWidth}px`);
288
+ if (scrollbarWidth > 0) body.style.paddingRight = `${computedPaddingRight + scrollbarWidth}px`;
289
+ restore = () => {
290
+ body.style.overflow = previousOverflow;
291
+ body.style.paddingRight = previousPaddingRight;
292
+ if (previousCompensation) body.style.setProperty("--ds-scrollbar-compensation", previousCompensation);
293
+ else body.style.removeProperty("--ds-scrollbar-compensation");
294
+ };
295
+ }
296
+ let released = false;
297
+ return () => {
298
+ if (released) return;
299
+ released = true;
300
+ lockCount = Math.max(0, lockCount - 1);
301
+ if (lockCount === 0) {
302
+ restore?.();
303
+ restore = null;
304
+ }
305
+ };
306
+ }
307
+
308
+ // src/internal/floating/use-floating-position.ts
309
+ var HIDDEN_STYLE = {
310
+ position: "fixed",
311
+ visibility: "hidden",
312
+ pointerEvents: "none",
313
+ zIndex: 9999
314
+ };
315
+ var CLIPPING_OVERFLOW = /(auto|scroll|hidden|clip)/;
316
+ var MIN_REFERENCE_VISIBLE_RATIO = 0.5;
317
+ function intersectionArea(rect, bounds) {
318
+ const width = Math.max(0, Math.min(rect.right, bounds.right) - Math.max(rect.left, bounds.left));
319
+ const height = Math.max(0, Math.min(rect.bottom, bounds.bottom) - Math.max(rect.top, bounds.top));
320
+ return width * height;
321
+ }
322
+ function isReferenceVisible(reference, viewportPadding) {
323
+ if (typeof window === "undefined" || typeof document === "undefined") return true;
324
+ if (!reference.isConnected) return false;
325
+ const referenceStyle = window.getComputedStyle(reference);
326
+ if (referenceStyle.display === "none" || referenceStyle.visibility === "hidden") return false;
327
+ const rect = reference.getBoundingClientRect();
328
+ if (rect.width === 0 && rect.height === 0) return true;
329
+ let bounds = {
330
+ top: viewportPadding,
331
+ left: viewportPadding,
332
+ right: window.innerWidth - viewportPadding,
333
+ bottom: window.innerHeight - viewportPadding
334
+ };
335
+ let ancestor = reference.parentElement;
336
+ while (ancestor && ancestor !== document.body && ancestor !== document.documentElement) {
337
+ const styles = window.getComputedStyle(ancestor);
338
+ const overflow = `${styles.overflow} ${styles.overflowX} ${styles.overflowY}`;
339
+ if (CLIPPING_OVERFLOW.test(overflow)) {
340
+ const ancestorRect = ancestor.getBoundingClientRect();
341
+ bounds = {
342
+ top: Math.max(bounds.top, ancestorRect.top),
343
+ left: Math.max(bounds.left, ancestorRect.left),
344
+ right: Math.min(bounds.right, ancestorRect.right),
345
+ bottom: Math.min(bounds.bottom, ancestorRect.bottom)
346
+ };
347
+ if (bounds.right <= bounds.left || bounds.bottom <= bounds.top) return false;
348
+ }
349
+ ancestor = ancestor.parentElement;
350
+ }
351
+ const referenceArea = Math.max(1, rect.width * rect.height);
352
+ return intersectionArea(rect, bounds) / referenceArea >= MIN_REFERENCE_VISIBLE_RATIO;
353
+ }
354
+ function useFloatingPosition({
355
+ open,
356
+ referenceRef,
357
+ floatingRef,
358
+ placement = "bottom-start",
359
+ matchWidth = false,
360
+ offset = 6,
361
+ minWidth = 140,
362
+ viewportPadding = 8,
363
+ scrollBehavior = "reposition",
364
+ onRequestClose
365
+ }) {
366
+ const [style, setStyle] = (0, import_react3.useState)(HIDDEN_STYLE);
367
+ const [positioned, setPositioned] = (0, import_react3.useState)(false);
368
+ const animationFrameRef = (0, import_react3.useRef)(null);
369
+ const updatePosition = (0, import_react3.useCallback)(() => {
370
+ if (typeof window === "undefined") return;
371
+ const reference = referenceRef.current;
372
+ const floating = floatingRef.current;
373
+ if (!reference || !floating) return;
374
+ if (!isReferenceVisible(reference, viewportPadding)) {
375
+ onRequestClose?.();
376
+ return;
377
+ }
378
+ const rect = reference.getBoundingClientRect();
379
+ const measuredWidth = matchWidth ? rect.width : Math.max(floating.offsetWidth, minWidth);
380
+ const measuredHeight = floating.offsetHeight;
381
+ const roomBelow = Math.max(0, window.innerHeight - rect.bottom - offset - viewportPadding);
382
+ const roomAbove = Math.max(0, rect.top - offset - viewportPadding);
383
+ const wantsTop = placement.startsWith("top");
384
+ const alignEnd = placement.endsWith("end");
385
+ const placeTop = wantsTop ? roomAbove >= measuredHeight || roomAbove > roomBelow : roomBelow < measuredHeight && roomAbove > roomBelow;
386
+ const availableHeight = placeTop ? roomAbove : roomBelow;
387
+ let left = alignEnd ? rect.right - measuredWidth : rect.left;
388
+ left = Math.max(viewportPadding, Math.min(left, window.innerWidth - Math.min(measuredWidth, window.innerWidth - viewportPadding * 2) - viewportPadding));
389
+ const next = {
390
+ position: "fixed",
391
+ zIndex: 9999,
392
+ minWidth,
393
+ visibility: "visible",
394
+ pointerEvents: "auto",
395
+ left,
396
+ maxWidth: `calc(100vw - ${viewportPadding * 2}px)`,
397
+ maxHeight: Math.max(0, availableHeight),
398
+ overflowY: "auto",
399
+ overscrollBehavior: "contain",
400
+ ...matchWidth ? { width: rect.width } : {}
401
+ };
402
+ if (placeTop) {
403
+ next.bottom = window.innerHeight - rect.top + offset;
404
+ next.top = "auto";
405
+ } else {
406
+ next.top = rect.bottom + offset;
407
+ next.bottom = "auto";
408
+ }
409
+ setStyle(next);
410
+ setPositioned(true);
411
+ }, [floatingRef, matchWidth, minWidth, offset, onRequestClose, placement, referenceRef, viewportPadding]);
412
+ const schedulePositionUpdate = (0, import_react3.useCallback)(() => {
413
+ if (typeof window === "undefined" || animationFrameRef.current !== null) return;
414
+ animationFrameRef.current = window.requestAnimationFrame(() => {
415
+ animationFrameRef.current = null;
416
+ updatePosition();
417
+ });
418
+ }, [updatePosition]);
419
+ (0, import_react3.useLayoutEffect)(() => {
420
+ if (!open) {
421
+ setPositioned(false);
422
+ setStyle(HIDDEN_STYLE);
423
+ return;
424
+ }
425
+ setPositioned(false);
426
+ setStyle(HIDDEN_STYLE);
427
+ updatePosition();
428
+ const handleResize = () => schedulePositionUpdate();
429
+ const handleScroll = (event) => {
430
+ const target = event.target;
431
+ if (typeof Node !== "undefined" && target instanceof Node && floatingRef.current?.contains(target)) return;
432
+ if (scrollBehavior === "close") {
433
+ onRequestClose?.();
434
+ return;
435
+ }
436
+ schedulePositionUpdate();
437
+ };
438
+ window.addEventListener("resize", handleResize);
439
+ window.addEventListener("scroll", handleScroll, true);
440
+ const observer = typeof ResizeObserver !== "undefined" ? new ResizeObserver(schedulePositionUpdate) : null;
441
+ if (observer) {
442
+ if (referenceRef.current) observer.observe(referenceRef.current);
443
+ if (floatingRef.current) observer.observe(floatingRef.current);
444
+ }
445
+ const unlock = scrollBehavior === "lock" ? lockDocumentScroll() : () => {
446
+ };
447
+ return () => {
448
+ window.removeEventListener("resize", handleResize);
449
+ window.removeEventListener("scroll", handleScroll, true);
450
+ observer?.disconnect();
451
+ unlock();
452
+ if (animationFrameRef.current !== null) {
453
+ window.cancelAnimationFrame(animationFrameRef.current);
454
+ animationFrameRef.current = null;
455
+ }
456
+ };
457
+ }, [floatingRef, onRequestClose, open, referenceRef, schedulePositionUpdate, scrollBehavior, updatePosition]);
458
+ return { style, positioned, updatePosition };
459
+ }
460
+
461
+ // src/dropdown/dropdown-context.ts
462
+ var import_react4 = require("react");
463
+ var DropdownContext = (0, import_react4.createContext)(null);
464
+ function useDropdown() {
465
+ const context = (0, import_react4.useContext)(DropdownContext);
466
+ if (!context) throw new Error("useDropdown must be used inside DDropdown");
467
+ return context;
468
+ }
469
+ function useDropdownClose() {
470
+ return (0, import_react4.useContext)(DropdownContext)?.close ?? null;
471
+ }
472
+
473
+ // src/dropdown/dropdown.tsx
474
+ var import_jsx_runtime6 = require("react/jsx-runtime");
475
+ function DDropdown({
476
+ trigger,
477
+ children,
478
+ placement = "bottom-start",
479
+ matchWidth = false,
480
+ onClose,
481
+ closeOnItemClick = false,
482
+ closeOnEsc = true,
483
+ open: controlledOpen,
484
+ onOpenChange,
485
+ contentRole = "menu",
486
+ className,
487
+ contentClassName,
488
+ contentPadding = true,
489
+ offset = 6,
490
+ minWidth = 140,
491
+ viewportPadding = 8,
492
+ scrollBehavior = "reposition"
493
+ }) {
494
+ const referenceRef = (0, import_react5.useRef)(null);
495
+ const floatingRef = (0, import_react5.useRef)(null);
496
+ const [uncontrolledOpen, setUncontrolledOpen] = (0, import_react5.useState)(false);
497
+ const open = controlledOpen ?? uncontrolledOpen;
498
+ const setOpen = (0, import_react5.useCallback)(
499
+ (next) => {
500
+ const resolved = typeof next === "function" ? next(open) : next;
501
+ if (controlledOpen === void 0) setUncontrolledOpen(resolved);
502
+ onOpenChange?.(resolved);
503
+ },
504
+ [controlledOpen, onOpenChange, open]
505
+ );
506
+ const close = (0, import_react5.useCallback)(() => {
507
+ if (!open) return;
508
+ setOpen(false);
509
+ onClose?.();
510
+ }, [onClose, open, setOpen]);
511
+ const { style, positioned } = useFloatingPosition({
512
+ open,
513
+ referenceRef,
514
+ floatingRef,
515
+ placement,
516
+ matchWidth,
517
+ offset,
518
+ minWidth,
519
+ viewportPadding,
520
+ scrollBehavior,
521
+ onRequestClose: close
522
+ });
523
+ (0, import_react5.useEffect)(() => {
524
+ if (!open) return;
525
+ const outside = (event) => {
526
+ const target = event.target;
527
+ if (!referenceRef.current?.contains(target) && !floatingRef.current?.contains(target)) close();
528
+ };
529
+ const escape = (event) => {
530
+ if (closeOnEsc && event.key === "Escape") close();
531
+ };
532
+ document.addEventListener("mousedown", outside);
533
+ document.addEventListener("keydown", escape);
534
+ return () => {
535
+ document.removeEventListener("mousedown", outside);
536
+ document.removeEventListener("keydown", escape);
537
+ };
538
+ }, [close, closeOnEsc, open]);
539
+ const context = (0, import_react5.useMemo)(() => ({ close, open }), [close, open]);
540
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(DropdownContext.Provider, { value: context, children: [
541
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
542
+ "div",
543
+ {
544
+ ref: referenceRef,
545
+ "data-ds-component": "dropdown-trigger",
546
+ className: cn("inline-block", matchWidth && "w-full", className),
547
+ onClick: (event) => {
548
+ if (event.defaultPrevented) return;
549
+ event.stopPropagation();
550
+ setOpen((value) => !value);
551
+ },
552
+ onKeyDown: (event) => {
553
+ if (event.defaultPrevented) return;
554
+ if (event.key === "Enter" || event.key === " ") {
555
+ const target = event.target;
556
+ if (target.tagName === "BUTTON" || target.tagName === "INPUT") return;
557
+ event.preventDefault();
558
+ event.stopPropagation();
559
+ setOpen((value) => !value);
560
+ }
561
+ },
562
+ children: trigger({ open })
563
+ }
564
+ ),
565
+ open && typeof document !== "undefined" ? (0, import_react_dom.createPortal)(
566
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
567
+ "div",
568
+ {
569
+ ref: floatingRef,
570
+ role: contentRole,
571
+ tabIndex: -1,
572
+ style,
573
+ "data-ds-component": "dropdown",
574
+ "data-ds-surface": "floating",
575
+ "data-positioned": positioned ? "true" : "false",
576
+ "data-scroll-behavior": scrollBehavior,
577
+ onClick: (event) => {
578
+ if (!closeOnItemClick) return;
579
+ const target = event.target;
580
+ if (target.closest("button, [role='option'], [role='menuitem'], a")) close();
581
+ },
582
+ className: cn(
583
+ "z-[9999] min-w-[140px] overflow-hidden rounded-[var(--radius-panel)] border border-[var(--color-border)] bg-[var(--color-surface)] shadow-[var(--shadow-lg)] outline-none",
584
+ contentPadding && "py-1",
585
+ positioned && "animate-[dropdown-in_150ms_ease-out]",
586
+ contentClassName
587
+ ),
588
+ children
589
+ }
590
+ ),
591
+ document.body
592
+ ) : null
593
+ ] });
594
+ }
595
+
596
+ // src/localization/localization.tsx
597
+ var import_react6 = require("react");
598
+
599
+ // src/localization/messages.ts
600
+ var idMessages = {
601
+ "common.apply": "Terapkan",
602
+ "common.cancel": "Batal",
603
+ "common.optional": "Opsional",
604
+ "common.loading": "Memuat...",
605
+ "common.clear": "Hapus",
606
+ "common.search": "Cari...",
607
+ "common.previousMonth": "Bulan sebelumnya",
608
+ "common.nextMonth": "Bulan berikutnya",
609
+ "common.yes": "Ya",
610
+ "common.no": "Tidak",
611
+ "input.fieldInfo": "Informasi field",
612
+ "input.loading": "Memuat",
613
+ "input.clear": "Hapus input",
614
+ "input.showPassword": "Tampilkan password",
615
+ "input.hidePassword": "Sembunyikan password",
616
+ "textarea.clear": "Hapus textarea",
617
+ "searchInput.placeholder": "Cari...",
618
+ "searchInput.clear": "Hapus pencarian",
619
+ "selectFilter.placeholder": "Pilih...",
620
+ "selectFilter.searchPlaceholder": "Cari...",
621
+ "selectFilter.clear": "Hapus filter",
622
+ "statusFilter.all": "Semua",
623
+ "dateRangeFilter.period": "Periode",
624
+ "dateRangeFilter.from": "Dari",
625
+ "dateRangeFilter.to": "Sampai",
626
+ "dateRangeFilter.reset": "Reset",
627
+ "pagination.label": "Paginasi",
628
+ "pagination.previous": "Halaman sebelumnya",
629
+ "pagination.next": "Halaman berikutnya",
630
+ "pagination.page": "Halaman {page}",
631
+ "dataTable.empty": "Tidak ada data",
632
+ "dataTable.searchPlaceholder": "Cari...",
633
+ "dataTable.toggleFilters": "Tampilkan/sembunyikan filter",
634
+ "dataTable.actions": "Aksi",
635
+ "dataTable.showing": "Menampilkan",
636
+ "dataTable.ofData": "dari {total} data",
637
+ "confirmDialog.title": "Konfirmasi",
638
+ "confirmDialog.message": "Apakah Anda yakin ingin melakukan aksi ini?",
639
+ "confirmDialog.confirm": "Ya, Lanjutkan",
640
+ "confirmDialog.cancel": "Batal",
641
+ "dialog.close": "Tutup dialog",
642
+ "connectionError.title": "Koneksi Gagal",
643
+ "connectionError.message": "Tidak dapat terhubung ke server.",
644
+ "connectionError.detail": "Pastikan server backend sudah berjalan dan koneksi internet Anda stabil.",
645
+ "connectionError.retrying": "Menghubungkan...",
646
+ "connectionError.retry": "Coba Lagi",
647
+ "loading.default": "Memuat...",
648
+ "notification.title": "Notifikasi",
649
+ "notification.empty": "Tidak ada notifikasi",
650
+ "notification.markAllRead": "Tandai semua sudah dibaca",
651
+ "notification.close": "Tutup notifikasi",
652
+ "notification.dismiss": "Tutup {title}",
653
+ "export.label": "Ekspor",
654
+ "export.pdf": "Ekspor PDF",
655
+ "export.excel": "Ekspor Excel",
656
+ "select.placeholder": "Pilih...",
657
+ "select.empty": "Tidak ditemukan",
658
+ "select.asyncError": "Gagal memuat pilihan",
659
+ "select.searchPlaceholder": "Cari...",
660
+ "select.loading": "Memuat...",
661
+ "select.clear": "Hapus pilihan",
662
+ "combobox.placeholder": "Ketik untuk mencari...",
663
+ "combobox.asyncError": "Gagal memuat pilihan",
664
+ "combobox.searching": "Mencari...",
665
+ "combobox.empty": "Tidak ditemukan",
666
+ "combobox.useValue": "Gunakan \u201C{value}\u201D",
667
+ "combobox.clear": "Hapus pilihan",
668
+ "datePicker.placeholder": "Pilih tanggal",
669
+ "datePicker.today": "Hari ini",
670
+ "datePicker.time": "Waktu",
671
+ "datePicker.selectHour": "Pilih jam",
672
+ "datePicker.selectHourMinute": "Pilih jam dan menit",
673
+ "datePicker.clear": "Hapus tanggal",
674
+ "timePicker.placeholder": "Pilih waktu",
675
+ "timePicker.title": "Pilih waktu",
676
+ "timePicker.hourPrecision": "Presisi jam",
677
+ "timePicker.hourMinutePrecision": "Presisi jam dan menit",
678
+ "timePicker.now": "Sekarang",
679
+ "timePicker.hour": "Jam",
680
+ "timePicker.minute": "Menit",
681
+ "timePicker.hourOption": "Jam {value}",
682
+ "timePicker.minuteOption": "Menit {value}",
683
+ "timePicker.clear": "Hapus waktu",
684
+ "rangeDatePicker.placeholder": "Pilih periode",
685
+ "rangeDatePicker.quickRange": "Rentang cepat",
686
+ "rangeDatePicker.summaryAllTime": "Semua waktu",
687
+ "rangeDatePicker.summarySelect": "Pilih tanggal awal dan akhir",
688
+ "rangeDatePicker.today": "Hari ini",
689
+ "rangeDatePicker.yesterday": "Kemarin",
690
+ "rangeDatePicker.thisWeek": "Minggu ini",
691
+ "rangeDatePicker.lastWeek": "Minggu lalu",
692
+ "rangeDatePicker.thisMonth": "Bulan ini",
693
+ "rangeDatePicker.lastMonth": "Bulan lalu",
694
+ "rangeDatePicker.thisYear": "Tahun ini",
695
+ "rangeDatePicker.lastYear": "Tahun lalu",
696
+ "rangeDatePicker.allTime": "Semua waktu",
697
+ "rangeDatePicker.clear": "Hapus rentang tanggal",
698
+ "validation.required": "{label} wajib diisi.",
699
+ "validation.accepted": "{label} harus disetujui.",
700
+ "validation.email": "{label} harus berupa email yang valid.",
701
+ "validation.url": "{label} harus berupa URL yang valid.",
702
+ "validation.minLength": "{label} minimal {min} karakter.",
703
+ "validation.maxLength": "{label} maksimal {max} karakter.",
704
+ "validation.minValue": "{label} minimal {min}.",
705
+ "validation.maxValue": "{label} maksimal {max}.",
706
+ "validation.integer": "{label} harus berupa bilangan bulat.",
707
+ "validation.pattern": "Format {label} tidak valid.",
708
+ "validation.sameAs": "{label} harus sama dengan {otherLabel}.",
709
+ "validation.oneOf": "{label} berisi pilihan yang tidak valid.",
710
+ "validation.date": "{label} harus berupa tanggal yang valid.",
711
+ "validation.time": "{label} harus berupa waktu yang valid.",
712
+ "validation.invalid": "{label} tidak valid.",
713
+ "validation.defaultLabel": "Field"
714
+ };
715
+ var enMessages = {
716
+ "common.apply": "Apply",
717
+ "common.cancel": "Cancel",
718
+ "common.optional": "Optional",
719
+ "common.loading": "Loading...",
720
+ "common.clear": "Clear",
721
+ "common.search": "Search...",
722
+ "common.previousMonth": "Previous month",
723
+ "common.nextMonth": "Next month",
724
+ "common.yes": "Yes",
725
+ "common.no": "No",
726
+ "input.fieldInfo": "Field information",
727
+ "input.loading": "Loading",
728
+ "input.clear": "Clear input",
729
+ "input.showPassword": "Show password",
730
+ "input.hidePassword": "Hide password",
731
+ "textarea.clear": "Clear textarea",
732
+ "searchInput.placeholder": "Search...",
733
+ "searchInput.clear": "Clear search",
734
+ "selectFilter.placeholder": "Select...",
735
+ "selectFilter.searchPlaceholder": "Search...",
736
+ "selectFilter.clear": "Clear filter",
737
+ "statusFilter.all": "All",
738
+ "dateRangeFilter.period": "Period",
739
+ "dateRangeFilter.from": "From",
740
+ "dateRangeFilter.to": "To",
741
+ "dateRangeFilter.reset": "Reset",
742
+ "pagination.label": "Pagination",
743
+ "pagination.previous": "Previous page",
744
+ "pagination.next": "Next page",
745
+ "pagination.page": "Page {page}",
746
+ "dataTable.empty": "No data",
747
+ "dataTable.searchPlaceholder": "Search...",
748
+ "dataTable.toggleFilters": "Toggle filters",
749
+ "dataTable.actions": "Actions",
750
+ "dataTable.showing": "Showing",
751
+ "dataTable.ofData": "of {total} data",
752
+ "confirmDialog.title": "Confirmation",
753
+ "confirmDialog.message": "Are you sure you want to continue with this action?",
754
+ "confirmDialog.confirm": "Yes, Continue",
755
+ "confirmDialog.cancel": "Cancel",
756
+ "dialog.close": "Close dialog",
757
+ "connectionError.title": "Connection Failed",
758
+ "connectionError.message": "Unable to connect to the server.",
759
+ "connectionError.detail": "Make sure the backend server is running and your internet connection is stable.",
760
+ "connectionError.retrying": "Connecting...",
761
+ "connectionError.retry": "Try Again",
762
+ "loading.default": "Loading...",
763
+ "notification.title": "Notifications",
764
+ "notification.empty": "No notifications",
765
+ "notification.markAllRead": "Mark all read",
766
+ "notification.close": "Close notifications",
767
+ "notification.dismiss": "Dismiss {title}",
768
+ "export.label": "Export",
769
+ "export.pdf": "Export PDF",
770
+ "export.excel": "Export Excel",
771
+ "select.placeholder": "Select...",
772
+ "select.empty": "No results found",
773
+ "select.asyncError": "Failed to load options",
774
+ "select.searchPlaceholder": "Search...",
775
+ "select.loading": "Loading...",
776
+ "select.clear": "Clear selection",
777
+ "combobox.placeholder": "Type to search...",
778
+ "combobox.asyncError": "Failed to load options",
779
+ "combobox.searching": "Searching...",
780
+ "combobox.empty": "No results found",
781
+ "combobox.useValue": "Use \u201C{value}\u201D",
782
+ "combobox.clear": "Clear selection",
783
+ "datePicker.placeholder": "Select date",
784
+ "datePicker.today": "Today",
785
+ "datePicker.time": "Time",
786
+ "datePicker.selectHour": "Select hour",
787
+ "datePicker.selectHourMinute": "Select hour and minute",
788
+ "datePicker.clear": "Clear date",
789
+ "timePicker.placeholder": "Select time",
790
+ "timePicker.title": "Select time",
791
+ "timePicker.hourPrecision": "Hour precision",
792
+ "timePicker.hourMinutePrecision": "Hour and minute precision",
793
+ "timePicker.now": "Now",
794
+ "timePicker.hour": "Hour",
795
+ "timePicker.minute": "Minute",
796
+ "timePicker.hourOption": "Hour {value}",
797
+ "timePicker.minuteOption": "Minute {value}",
798
+ "timePicker.clear": "Clear time",
799
+ "rangeDatePicker.placeholder": "Select period",
800
+ "rangeDatePicker.quickRange": "Quick range",
801
+ "rangeDatePicker.summaryAllTime": "All time",
802
+ "rangeDatePicker.summarySelect": "Select start and end dates",
803
+ "rangeDatePicker.today": "Today",
804
+ "rangeDatePicker.yesterday": "Yesterday",
805
+ "rangeDatePicker.thisWeek": "This week",
806
+ "rangeDatePicker.lastWeek": "Last week",
807
+ "rangeDatePicker.thisMonth": "This month",
808
+ "rangeDatePicker.lastMonth": "Last month",
809
+ "rangeDatePicker.thisYear": "This year",
810
+ "rangeDatePicker.lastYear": "Last year",
811
+ "rangeDatePicker.allTime": "All time",
812
+ "rangeDatePicker.clear": "Clear date range",
813
+ "validation.required": "{label} is required.",
814
+ "validation.accepted": "{label} must be accepted.",
815
+ "validation.email": "{label} must be a valid email.",
816
+ "validation.url": "{label} must be a valid URL.",
817
+ "validation.minLength": "{label} must be at least {min} characters.",
818
+ "validation.maxLength": "{label} must be at most {max} characters.",
819
+ "validation.minValue": "{label} must be at least {min}.",
820
+ "validation.maxValue": "{label} must be at most {max}.",
821
+ "validation.integer": "{label} must be an integer.",
822
+ "validation.pattern": "{label} has an invalid format.",
823
+ "validation.sameAs": "{label} must match {otherLabel}.",
824
+ "validation.oneOf": "{label} contains an invalid option.",
825
+ "validation.date": "{label} must be a valid date.",
826
+ "validation.time": "{label} must be a valid time.",
827
+ "validation.invalid": "{label} is invalid.",
828
+ "validation.defaultLabel": "Field"
829
+ };
830
+
831
+ // src/localization/localization.tsx
832
+ var import_jsx_runtime7 = require("react/jsx-runtime");
833
+ function interpolate(template, params) {
834
+ return template.replace(/\{([^}]+)\}/g, (_, key) => String(params[key] ?? `{${key}}`));
835
+ }
836
+ function builtInMessages(locale) {
837
+ return locale.toLowerCase().startsWith("en") ? enMessages : idMessages;
838
+ }
839
+ function createDTranslator({
840
+ locale = "id-ID",
841
+ messages,
842
+ translate
843
+ } = {}) {
844
+ const builtIn = builtInMessages(locale);
845
+ return (key, params = {}, explicitFallback) => {
846
+ const fallback = explicitFallback ?? builtIn[key] ?? idMessages[key] ?? key;
847
+ const projectValue = translate?.(key, params, fallback);
848
+ const template = projectValue ?? messages?.[key] ?? builtIn[key] ?? idMessages[key] ?? fallback;
849
+ return interpolate(template, params);
850
+ };
851
+ }
852
+ var defaultContext = {
853
+ locale: "id-ID",
854
+ t: createDTranslator()
855
+ };
856
+ var LocalizationContext = (0, import_react6.createContext)(defaultContext);
857
+ function DLocalizationProvider({
858
+ children,
859
+ locale = "id-ID",
860
+ messages,
861
+ translate
862
+ }) {
863
+ const value = (0, import_react6.useMemo)(() => ({
864
+ locale,
865
+ t: createDTranslator({ locale, messages, translate })
866
+ }), [locale, messages, translate]);
867
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(LocalizationContext.Provider, { value, children });
868
+ }
869
+ function useDLocalization() {
870
+ return (0, import_react6.useContext)(LocalizationContext);
871
+ }
872
+
873
+ // src/localization/date-time.ts
874
+ function getLocalizedMonthNames(locale, format = "long") {
875
+ const formatter = new Intl.DateTimeFormat(locale, { month: format });
876
+ return Array.from({ length: 12 }, (_, month) => formatter.format(new Date(2026, month, 1)));
877
+ }
878
+ function getLocalizedWeekdayNames(locale, format = "short") {
879
+ const formatter = new Intl.DateTimeFormat(locale, { weekday: format });
880
+ const sunday = new Date(2026, 0, 4);
881
+ return Array.from({ length: 7 }, (_, day) => {
882
+ const date2 = new Date(sunday);
883
+ date2.setDate(sunday.getDate() + day);
884
+ return formatter.format(date2);
885
+ });
886
+ }
887
+
888
+ // src/shared/field-size.ts
889
+ var INPUT_SIZE_STYLES = {
890
+ sm: {
891
+ input: "box-border h-8 px-2 text-xs [font-family:var(--font-sans)]",
892
+ label: "text-xs",
893
+ icon: "size-3.5",
894
+ iconLeft: "left-2.5 size-3.5",
895
+ iconRight: "right-2",
896
+ clear: "right-1.5"
897
+ },
898
+ md: {
899
+ input: "box-border h-10 px-3 text-sm [font-family:var(--font-sans)]",
900
+ label: "text-sm",
901
+ icon: "size-4",
902
+ iconLeft: "left-3 size-4",
903
+ iconRight: "right-2.5",
904
+ clear: "right-2"
905
+ },
906
+ lg: {
907
+ input: "box-border h-12 px-4 text-base [font-family:var(--font-sans)]",
908
+ label: "text-base",
909
+ icon: "size-4",
910
+ iconLeft: "left-3.5 size-4",
911
+ iconRight: "right-3",
912
+ clear: "right-2.5"
913
+ }
914
+ };
915
+
916
+ // src/combobox/combobox.tsx
917
+ var import_jsx_runtime8 = require("react/jsx-runtime");
918
+ function SearchIcon({ className }) {
919
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", className, children: [
920
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("circle", { cx: "11", cy: "11", r: "7" }),
921
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("path", { d: "m20 20-4-4" })
922
+ ] });
923
+ }
924
+ function ClearIcon() {
925
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", className: "size-3.5", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("path", { d: "m18 6-12 12M6 6l12 12" }) });
926
+ }
927
+ function sameValue(left, right) {
928
+ return String(left ?? "") === String(right ?? "");
929
+ }
930
+ function DCombobox({
931
+ label,
932
+ placeholder,
933
+ options = [],
934
+ value,
935
+ size = "md",
936
+ onChange,
937
+ fetchOptions,
938
+ refetchKey,
939
+ onFetchError,
940
+ asyncErrorMessage,
941
+ error,
942
+ hint,
943
+ disabled = false,
944
+ clearable = true,
945
+ containerClassName,
946
+ allowCreate = false,
947
+ onCreateOption,
948
+ renderEmpty,
949
+ renderCreateOption,
950
+ renderOption,
951
+ onSearchChange,
952
+ loading = false,
953
+ idleMessage,
954
+ ariaLabel,
955
+ debounceMs = 300,
956
+ scrollBehavior = "reposition"
957
+ }) {
958
+ const id = (0, import_react7.useId)();
959
+ const { t } = useDLocalization();
960
+ const inputRef = (0, import_react7.useRef)(null);
961
+ const searchRequestIdRef = (0, import_react7.useRef)(0);
962
+ const resolveRequestIdRef = (0, import_react7.useRef)(0);
963
+ const [open, setOpen] = (0, import_react7.useState)(false);
964
+ const [inputValue, setInputValue] = (0, import_react7.useState)("");
965
+ const [activeIndex, setActiveIndex] = (0, import_react7.useState)(0);
966
+ const [asyncOptions, setAsyncOptions] = (0, import_react7.useState)([]);
967
+ const [isFetching, setFetching] = (0, import_react7.useState)(false);
968
+ const [fetchError, setFetchError] = (0, import_react7.useState)(null);
969
+ const [resolvedSelection, setResolvedSelection] = (0, import_react7.useState)(null);
970
+ const s = INPUT_SIZE_STYLES[size];
971
+ const isAsync = Boolean(fetchOptions);
972
+ const resolvedPlaceholder = placeholder ?? t("combobox.placeholder");
973
+ const resolvedAsyncErrorMessage = asyncErrorMessage ?? t("combobox.asyncError");
974
+ (0, import_react7.useEffect)(() => {
975
+ if (!fetchOptions || !open) return;
976
+ const requestId = ++searchRequestIdRef.current;
977
+ const timeout = window.setTimeout(() => {
978
+ setFetching(true);
979
+ setFetchError(null);
980
+ void fetchOptions(inputValue).then((result) => {
981
+ if (requestId === searchRequestIdRef.current) setAsyncOptions(result);
982
+ }).catch((nextError) => {
983
+ if (requestId !== searchRequestIdRef.current) return;
984
+ setFetchError(nextError);
985
+ onFetchError?.(nextError);
986
+ }).finally(() => {
987
+ if (requestId === searchRequestIdRef.current) setFetching(false);
988
+ });
989
+ }, debounceMs);
990
+ return () => window.clearTimeout(timeout);
991
+ }, [debounceMs, fetchOptions, inputValue, onFetchError, open, refetchKey]);
992
+ (0, import_react7.useEffect)(() => {
993
+ if (!fetchOptions || value == null || value === "" || sameValue(resolvedSelection?.value, value)) return;
994
+ const requestId = ++resolveRequestIdRef.current;
995
+ void fetchOptions("").then((result) => {
996
+ if (requestId !== resolveRequestIdRef.current) return;
997
+ const found = result.find((option) => sameValue(option.value, value));
998
+ setResolvedSelection(found ?? null);
999
+ }).catch((nextError) => onFetchError?.(nextError));
1000
+ }, [fetchOptions, onFetchError, refetchKey, resolvedSelection?.value, value]);
1001
+ const selectedOption = options.find((option) => sameValue(option.value, value)) ?? (sameValue(resolvedSelection?.value, value) ? resolvedSelection : null);
1002
+ const source = isAsync ? asyncOptions : options;
1003
+ const filtered = (0, import_react7.useMemo)(
1004
+ () => isAsync ? source : source.filter((option) => String(option.label).toLocaleLowerCase().includes(inputValue.toLocaleLowerCase())),
1005
+ [inputValue, isAsync, source]
1006
+ );
1007
+ (0, import_react7.useEffect)(() => {
1008
+ if (!open || inputValue) return;
1009
+ const selectedIndex = filtered.findIndex((option) => sameValue(option.value, value));
1010
+ setActiveIndex(selectedIndex >= 0 ? selectedIndex : 0);
1011
+ }, [filtered, inputValue, open, value]);
1012
+ const choose = (option) => {
1013
+ if (option.disabled) return;
1014
+ setResolvedSelection(option);
1015
+ onChange?.(option.value);
1016
+ setOpen(false);
1017
+ setInputValue("");
1018
+ };
1019
+ const clear = () => {
1020
+ onChange?.(null);
1021
+ setResolvedSelection(null);
1022
+ setInputValue("");
1023
+ setOpen(false);
1024
+ };
1025
+ const create = () => {
1026
+ const next = inputValue.trim();
1027
+ if (!next) return;
1028
+ onCreateOption?.(next);
1029
+ onChange?.(next);
1030
+ setResolvedSelection({ label: next, value: next });
1031
+ setOpen(false);
1032
+ setInputValue("");
1033
+ };
1034
+ const handleKeyDown = (event) => {
1035
+ if (event.key === "Escape") {
1036
+ setOpen(false);
1037
+ setInputValue("");
1038
+ return;
1039
+ }
1040
+ if (event.key === "ArrowDown" || event.key === "ArrowUp") {
1041
+ event.preventDefault();
1042
+ setOpen(true);
1043
+ setActiveIndex((current) => {
1044
+ const count = filtered.length || 1;
1045
+ return event.key === "ArrowDown" ? (current + 1) % count : (current - 1 + count) % count;
1046
+ });
1047
+ return;
1048
+ }
1049
+ if (event.key === "Home" && open) {
1050
+ event.preventDefault();
1051
+ setActiveIndex(0);
1052
+ return;
1053
+ }
1054
+ if (event.key === "End" && open) {
1055
+ event.preventDefault();
1056
+ setActiveIndex(Math.max(0, filtered.length - 1));
1057
+ return;
1058
+ }
1059
+ if (event.key === "Enter" && open) {
1060
+ const active = filtered[activeIndex];
1061
+ if (active && !active.disabled) {
1062
+ event.preventDefault();
1063
+ choose(active);
1064
+ } else if (allowCreate && inputValue.trim()) {
1065
+ event.preventDefault();
1066
+ create();
1067
+ }
1068
+ }
1069
+ };
1070
+ const showIdle = Boolean(idleMessage && !inputValue && !isAsync);
1071
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: cn("flex min-w-0 flex-col gap-1.5", containerClassName), children: [
1072
+ label ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("label", { htmlFor: id, className: cn(s.label, "w-fit font-medium text-[var(--color-text)]"), children: label }) : null,
1073
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(DDropdown, { matchWidth: true, open, onOpenChange: setOpen, contentRole: "listbox", contentPadding: false, contentClassName: "max-h-60 overflow-y-auto p-1.5", scrollBehavior, onClose: () => {
1074
+ setOpen(false);
1075
+ setInputValue("");
1076
+ }, trigger: () => /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "relative", children: [
1077
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(SearchIcon, { className: cn("pointer-events-none absolute top-1/2 -translate-y-1/2 text-[var(--color-text-muted)]", s.iconLeft) }),
1078
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1079
+ "input",
1080
+ {
1081
+ ref: inputRef,
1082
+ id,
1083
+ "aria-label": ariaLabel,
1084
+ role: "combobox",
1085
+ "aria-autocomplete": "list",
1086
+ "aria-expanded": open,
1087
+ "aria-invalid": Boolean(error) || void 0,
1088
+ "aria-controls": `${id}-listbox`,
1089
+ "aria-activedescendant": open && filtered[activeIndex] ? `${id}-option-${activeIndex}` : void 0,
1090
+ autoComplete: "off",
1091
+ type: "text",
1092
+ disabled,
1093
+ value: open ? inputValue : String(selectedOption?.label ?? ""),
1094
+ placeholder: selectedOption ? String(selectedOption.label) : resolvedPlaceholder,
1095
+ onClick: (event) => event.stopPropagation(),
1096
+ onFocus: () => {
1097
+ setOpen(true);
1098
+ const selectedIndex = filtered.findIndex((option) => sameValue(option.value, value));
1099
+ setActiveIndex(selectedIndex >= 0 ? selectedIndex : 0);
1100
+ },
1101
+ onChange: (event) => {
1102
+ const next = event.target.value;
1103
+ setInputValue(next);
1104
+ onSearchChange?.(next);
1105
+ setOpen(true);
1106
+ setActiveIndex(0);
1107
+ },
1108
+ onKeyDown: handleKeyDown,
1109
+ className: cn("w-full rounded-lg border bg-[var(--color-surface)] text-[var(--color-text)] focus:border-[var(--color-brand)] focus:outline-none focus:ring-2 focus:ring-[var(--color-brand)]/20 disabled:cursor-not-allowed disabled:bg-[var(--color-surface-muted)] disabled:opacity-50", s.input, "pl-10 pr-10", error ? "border-[var(--color-danger)] focus:ring-[var(--color-danger)]/20" : "border-[var(--color-border)]")
1110
+ }
1111
+ ),
1112
+ clearable && selectedOption && !disabled ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("button", { type: "button", tabIndex: -1, "aria-label": t("combobox.clear"), onMouseDown: (event) => event.preventDefault(), onClick: (event) => {
1113
+ event.preventDefault();
1114
+ event.stopPropagation();
1115
+ clear();
1116
+ }, className: cn("absolute top-1/2 -translate-y-1/2 rounded-md p-1 text-[var(--color-text-muted)] hover:bg-[var(--color-surface-muted)] hover:text-[var(--color-text)]", s.clear), children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ClearIcon, {}) }) : null
1117
+ ] }), children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { id: `${id}-listbox`, className: "space-y-0.5", children: loading || isFetching ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "px-3 py-6 text-center text-sm text-[var(--color-text-muted)]", children: t("combobox.searching") }) : fetchError ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "px-3 py-6 text-center text-sm text-[var(--color-danger)]", children: resolvedAsyncErrorMessage }) : showIdle ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "px-3 py-6 text-center text-sm text-[var(--color-text-muted)]", children: idleMessage }) : filtered.length === 0 ? renderEmpty ? renderEmpty(inputValue) : allowCreate && inputValue.trim() ? renderCreateOption ? renderCreateOption(inputValue, create) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("button", { type: "button", onMouseDown: (event) => event.preventDefault(), onClick: (event) => {
1118
+ event.stopPropagation();
1119
+ create();
1120
+ }, className: "w-full rounded-lg px-3 py-2 text-left text-sm font-medium text-[var(--color-brand)] hover:bg-[var(--color-surface-muted)]", children: t("combobox.useValue", { value: inputValue.trim() }) }) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "px-3 py-6 text-center text-sm text-[var(--color-text-muted)]", children: t("combobox.empty") }) : filtered.map((option, index) => {
1121
+ const isSelected = sameValue(option.value, value);
1122
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("button", { id: `${id}-option-${index}`, type: "button", role: "option", "aria-selected": isSelected, disabled: option.disabled, onMouseEnter: () => setActiveIndex(index), onMouseDown: (event) => event.preventDefault(), onClick: (event) => {
1123
+ event.stopPropagation();
1124
+ choose(option);
1125
+ }, className: cn("w-full rounded-lg px-3 py-2 text-left text-sm transition-colors hover:bg-[var(--color-surface-muted)] disabled:cursor-not-allowed disabled:opacity-50", isSelected && "bg-[var(--color-brand)]/10 font-medium text-[var(--color-brand)]", index === activeIndex && !isSelected && "bg-[var(--color-surface-muted)]"), children: renderOption ? renderOption(option, isSelected) : option.label }, String(option.value));
1126
+ }) }) }),
1127
+ error ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { className: "text-xs text-[var(--color-danger)]", children: error }) : null,
1128
+ !error && hint ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { className: "text-xs text-[var(--color-text-muted)]", children: hint }) : null
1129
+ ] });
1130
+ }
1131
+
1132
+ // src/dialog/dialog.tsx
1133
+ var import_react8 = require("react");
1134
+ var import_react_dom2 = require("react-dom");
1135
+
1136
+ // src/internal/icons.tsx
1137
+ var import_jsx_runtime9 = require("react/jsx-runtime");
1138
+ function baseProps(size, className) {
1139
+ return {
1140
+ viewBox: "0 0 24 24",
1141
+ fill: "none",
1142
+ stroke: "currentColor",
1143
+ strokeWidth: 2,
1144
+ strokeLinecap: "round",
1145
+ strokeLinejoin: "round",
1146
+ width: size,
1147
+ height: size,
1148
+ className,
1149
+ "aria-hidden": true
1150
+ };
1151
+ }
1152
+ function ChevronDownIcon({ size = 16, className, ...props }) {
1153
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("svg", { ...baseProps(size, className), ...props, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("path", { d: "m6 9 6 6 6-6" }) });
1154
+ }
1155
+ function ChevronLeftIcon({ size = 16, className, ...props }) {
1156
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("svg", { ...baseProps(size, className), ...props, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("path", { d: "m15 18-6-6 6-6" }) });
1157
+ }
1158
+ function ChevronRightIcon({ size = 16, className, ...props }) {
1159
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("svg", { ...baseProps(size, className), ...props, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("path", { d: "m9 18 6-6-6-6" }) });
1160
+ }
1161
+ function ArrowUpIcon({ size = 14, className, ...props }) {
1162
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("svg", { ...baseProps(size, className), ...props, children: [
1163
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("path", { d: "m18 15-6-6-6 6" }),
1164
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("path", { d: "M12 21V9" })
1165
+ ] });
1166
+ }
1167
+ function ArrowDownIcon({ size = 14, className, ...props }) {
1168
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("svg", { ...baseProps(size, className), ...props, children: [
1169
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("path", { d: "m6 9 6 6 6-6" }),
1170
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("path", { d: "M12 3v12" })
1171
+ ] });
1172
+ }
1173
+ function MoreHorizontalIcon({ size = 18, className, ...props }) {
1174
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("svg", { ...baseProps(size, className), ...props, children: [
1175
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("circle", { cx: "5", cy: "12", r: "1", fill: "currentColor", stroke: "none" }),
1176
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("circle", { cx: "12", cy: "12", r: "1", fill: "currentColor", stroke: "none" }),
1177
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("circle", { cx: "19", cy: "12", r: "1", fill: "currentColor", stroke: "none" })
1178
+ ] });
1179
+ }
1180
+ function XIcon({ size = 18, className, ...props }) {
1181
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("svg", { ...baseProps(size, className), ...props, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("path", { d: "M18 6 6 18M6 6l12 12" }) });
1182
+ }
1183
+ function CheckIcon({ size = 16, className, ...props }) {
1184
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("svg", { ...baseProps(size, className), ...props, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("path", { d: "m5 12 4 4L19 6" }) });
1185
+ }
1186
+
1187
+ // src/dialog/dialog.tsx
1188
+ var import_jsx_runtime10 = require("react/jsx-runtime");
1189
+ var FOCUSABLE_SELECTOR = [
1190
+ "a[href]",
1191
+ "button:not([disabled])",
1192
+ "input:not([disabled])",
1193
+ "select:not([disabled])",
1194
+ "textarea:not([disabled])",
1195
+ '[tabindex]:not([tabindex="-1"])'
1196
+ ].join(",");
1197
+ function getFocusableElements(container) {
1198
+ return Array.from(container.querySelectorAll(FOCUSABLE_SELECTOR)).filter(
1199
+ (element) => !element.hasAttribute("hidden") && element.getAttribute("aria-hidden") !== "true"
1200
+ );
1201
+ }
1202
+ function DialogRoot({
1203
+ open,
1204
+ onClose,
1205
+ children,
1206
+ ariaLabel,
1207
+ ariaLabelledBy,
1208
+ className,
1209
+ overlayClassName,
1210
+ closeOnOverlay = false,
1211
+ closeOnEscape = false
1212
+ }) {
1213
+ const dialogRef = (0, import_react8.useRef)(null);
1214
+ const previousActiveRef = (0, import_react8.useRef)(null);
1215
+ const [mounted, setMounted] = (0, import_react8.useState)(open);
1216
+ (0, import_react8.useEffect)(() => {
1217
+ if (open) {
1218
+ setMounted(true);
1219
+ return;
1220
+ }
1221
+ const timer = window.setTimeout(() => setMounted(false), 220);
1222
+ return () => window.clearTimeout(timer);
1223
+ }, [open]);
1224
+ (0, import_react8.useEffect)(() => {
1225
+ if (!mounted) return;
1226
+ return lockDocumentScroll();
1227
+ }, [mounted]);
1228
+ (0, import_react8.useLayoutEffect)(() => {
1229
+ if (!open || !mounted) return;
1230
+ const active = document.activeElement;
1231
+ if (active instanceof HTMLElement && active !== dialogRef.current) {
1232
+ previousActiveRef.current = active;
1233
+ }
1234
+ dialogRef.current?.focus({ preventScroll: true });
1235
+ }, [mounted, open]);
1236
+ (0, import_react8.useEffect)(() => () => {
1237
+ previousActiveRef.current?.focus({ preventScroll: true });
1238
+ }, []);
1239
+ (0, import_react8.useEffect)(() => {
1240
+ if (open || !mounted) return;
1241
+ previousActiveRef.current?.focus({ preventScroll: true });
1242
+ previousActiveRef.current = null;
1243
+ }, [mounted, open]);
1244
+ (0, import_react8.useEffect)(() => {
1245
+ if (!open || !mounted) return;
1246
+ const handleKeyDown = (event) => {
1247
+ if (event.key === "Escape" && closeOnEscape) {
1248
+ event.preventDefault();
1249
+ onClose();
1250
+ return;
1251
+ }
1252
+ if (event.key !== "Tab" || !dialogRef.current) return;
1253
+ const focusable = getFocusableElements(dialogRef.current);
1254
+ if (focusable.length === 0) {
1255
+ event.preventDefault();
1256
+ dialogRef.current.focus({ preventScroll: true });
1257
+ return;
1258
+ }
1259
+ const index = focusable.indexOf(document.activeElement);
1260
+ if (event.shiftKey && index <= 0) {
1261
+ event.preventDefault();
1262
+ focusable[focusable.length - 1]?.focus();
1263
+ } else if (!event.shiftKey && index === focusable.length - 1) {
1264
+ event.preventDefault();
1265
+ focusable[0]?.focus();
1266
+ }
1267
+ };
1268
+ document.addEventListener("keydown", handleKeyDown);
1269
+ return () => document.removeEventListener("keydown", handleKeyDown);
1270
+ }, [closeOnEscape, mounted, onClose, open]);
1271
+ if (!mounted || typeof document === "undefined") return null;
1272
+ return (0, import_react_dom2.createPortal)(
1273
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1274
+ "div",
1275
+ {
1276
+ className: cn(
1277
+ "fixed inset-0 z-50 flex items-end justify-center bg-slate-950/50 p-0 backdrop-blur-[1px] transition-opacity duration-200 motion-reduce:transition-none sm:items-center sm:p-4",
1278
+ open ? "opacity-100" : "pointer-events-none opacity-0",
1279
+ overlayClassName
1280
+ ),
1281
+ onMouseDown: (event) => {
1282
+ if (closeOnOverlay && event.target === event.currentTarget) onClose();
1283
+ },
1284
+ children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1285
+ "section",
1286
+ {
1287
+ ref: dialogRef,
1288
+ role: "dialog",
1289
+ "aria-modal": "true",
1290
+ "aria-label": ariaLabelledBy ? void 0 : ariaLabel,
1291
+ "aria-labelledby": ariaLabelledBy,
1292
+ "data-ds-component": "dialog",
1293
+ "data-ds-surface": "modal",
1294
+ tabIndex: -1,
1295
+ className,
1296
+ children
1297
+ }
1298
+ )
1299
+ }
1300
+ ),
1301
+ document.body
1302
+ );
1303
+ }
1304
+ var sizeClasses2 = {
1305
+ sm: "sm:max-w-sm",
1306
+ md: "sm:max-w-lg",
1307
+ lg: "sm:max-w-2xl",
1308
+ xl: "sm:max-w-4xl",
1309
+ full: "sm:max-w-[95vw]"
1310
+ };
1311
+ function DDialog({
1312
+ open,
1313
+ onClose,
1314
+ title,
1315
+ description,
1316
+ children,
1317
+ footer,
1318
+ size = "md",
1319
+ closeOnOverlay = true,
1320
+ closeOnEscape = true,
1321
+ showClose = true,
1322
+ noPadding = false,
1323
+ className,
1324
+ overlayClassName,
1325
+ ariaLabel,
1326
+ ariaLabelledBy
1327
+ }) {
1328
+ const { t } = useDLocalization();
1329
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
1330
+ DialogRoot,
1331
+ {
1332
+ open,
1333
+ onClose,
1334
+ closeOnOverlay,
1335
+ closeOnEscape,
1336
+ ariaLabelledBy,
1337
+ ariaLabel: ariaLabel ?? (typeof title === "string" ? title : "DDialog"),
1338
+ overlayClassName,
1339
+ className: cn(
1340
+ "flex max-h-[90vh] w-full flex-col rounded-t-2xl bg-[var(--color-surface)] shadow-[var(--shadow-lg)] transition-[transform,opacity] duration-200 ease-out motion-reduce:transition-none sm:max-h-[85vh] sm:rounded-[var(--radius-panel)]",
1341
+ open ? "translate-y-0 opacity-100 sm:scale-100" : "translate-y-6 opacity-0 sm:translate-y-0 sm:scale-[0.98]",
1342
+ sizeClasses2[size],
1343
+ className
1344
+ ),
1345
+ children: [
1346
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "flex justify-center pb-1 pt-3 sm:hidden", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "h-1 w-10 rounded-full bg-[var(--color-border)]" }) }),
1347
+ title || description || showClose ? /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "flex min-h-16 items-start justify-between gap-4 border-b border-[var(--color-border)] px-5 py-3 sm:px-5 sm:py-3", children: [
1348
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "min-w-0 flex-1 self-center", children: [
1349
+ title ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("h3", { className: "m-0 text-base font-semibold leading-6 text-[var(--color-text)]", children: title }) : null,
1350
+ description ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { className: "mb-0 mt-1 text-xs leading-5 text-[var(--color-text-muted)]", children: description }) : null
1351
+ ] }),
1352
+ showClose ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1353
+ "button",
1354
+ {
1355
+ type: "button",
1356
+ "aria-label": t("dialog.close"),
1357
+ onClick: onClose,
1358
+ className: "grid size-8 shrink-0 appearance-none place-items-center rounded-lg border-0 bg-transparent p-0 text-[var(--color-text-muted)] outline-none shadow-none transition-colors hover:bg-[var(--color-surface-muted)] hover:text-[var(--color-text)] focus-visible:ring-2 focus-visible:ring-[var(--color-focus)]/25",
1359
+ children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(XIcon, { size: 16 })
1360
+ }
1361
+ ) : null
1362
+ ] }) : null,
1363
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: cn("flex-1 overflow-y-auto", !noPadding && "px-5 py-4 sm:px-5"), children }),
1364
+ footer ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "border-t border-[var(--color-border)] bg-[var(--color-surface-muted)]/30 px-5 py-3 sm:rounded-b-[var(--radius-panel)]", children: footer }) : null
1365
+ ]
1366
+ }
1367
+ );
1368
+ }
1369
+
1370
+ // src/confirm-dialog/confirm-dialog.tsx
1371
+ var import_jsx_runtime11 = require("react/jsx-runtime");
1372
+ function DConfirmDialog({ open, onClose, onConfirm, title, message, confirmLabel, cancelLabel, variant = "danger", loading = false }) {
1373
+ const { t } = useDLocalization();
1374
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(DDialog, { open, onClose, title: title ?? t("confirmDialog.title"), size: "sm", footer: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "flex justify-end gap-2", children: [
1375
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(DButton, { variant: "outline", onClick: onClose, disabled: loading, children: cancelLabel ?? t("confirmDialog.cancel") }),
1376
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(DButton, { variant, onClick: onConfirm, loading, children: confirmLabel ?? t("confirmDialog.confirm") })
1377
+ ] }), children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("p", { className: "text-sm text-[var(--color-text-muted)]", children: message ?? t("confirmDialog.message") }) });
1378
+ }
1379
+
1380
+ // src/connection-error/connection-error.tsx
1381
+ var import_jsx_runtime12 = require("react/jsx-runtime");
1382
+ function OfflineIcon() {
1383
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", className: "size-9", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("path", { d: "M3 3l18 18M8.5 8.5A8 8 0 0 1 20 12M4 12a8 8 0 0 1 1.6-4.8M8.5 16.5A5 5 0 0 1 12 15c1.4 0 2.7.6 3.5 1.5M12 20h.01" }) });
1384
+ }
1385
+ function DConnectionError({ onRetry, isRetrying = false, title, message, detail, diagnostics }) {
1386
+ const { t } = useDLocalization();
1387
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "fixed inset-0 z-[99998] flex items-center justify-center bg-[var(--color-background)] px-4", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "w-full max-w-sm text-center", children: [
1388
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "mx-auto mb-6 flex size-20 items-center justify-center rounded-full bg-[var(--color-danger)]/10 text-[var(--color-danger)]", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(OfflineIcon, {}) }),
1389
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("h2", { className: "mb-2 text-xl font-bold text-[var(--color-text)]", children: title ?? t("connectionError.title") }),
1390
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { className: "mb-2 text-sm text-[var(--color-text-muted)]", children: message ?? t("connectionError.message") }),
1391
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { className: "mb-8 text-xs text-[var(--color-text-muted)]/70", children: detail ?? t("connectionError.detail") }),
1392
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(DButton, { onClick: onRetry, loading: isRetrying, fullWidth: true, children: isRetrying ? t("connectionError.retrying") : t("connectionError.retry") }),
1393
+ diagnostics ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "mt-6 rounded-lg border border-[var(--color-border)] bg-[var(--color-surface-muted)]/50 p-3 text-left text-[11px] text-[var(--color-text-muted)]", children: diagnostics }) : null
1394
+ ] }) });
1395
+ }
1396
+
1397
+ // src/date-picker/date-picker.tsx
1398
+ var import_react10 = require("react");
1399
+
1400
+ // src/internal/time/time-picker-panel.tsx
1401
+ var import_react9 = require("react");
1402
+
1403
+ // src/internal/time/time-utils.ts
1404
+ function pad(value) {
1405
+ return String(value).padStart(2, "0");
1406
+ }
1407
+ function parseTimeValue(value) {
1408
+ if (!value) return null;
1409
+ const match = /^(\d{1,2})(?::(\d{2}))?$/.exec(value.trim());
1410
+ if (!match) return null;
1411
+ const hour = Number(match[1]);
1412
+ const minute = Number(match[2] ?? "0");
1413
+ if (!Number.isInteger(hour) || !Number.isInteger(minute) || hour < 0 || hour > 23 || minute < 0 || minute > 59) return null;
1414
+ return { hour, minute };
1415
+ }
1416
+ function formatTimeValue(hour, minute = 0) {
1417
+ return `${pad(hour)}:${pad(minute)}`;
1418
+ }
1419
+ function normalizeTimeValue(value, precision) {
1420
+ const parsed = parseTimeValue(value);
1421
+ if (!parsed) return "";
1422
+ return formatTimeValue(parsed.hour, precision === "hour" ? 0 : parsed.minute);
1423
+ }
1424
+ function getMinuteOptions(step, selectedMinute) {
1425
+ const options = Array.from({ length: Math.ceil(60 / step) }, (_, index) => index * step).filter((minute) => minute < 60);
1426
+ if (selectedMinute !== void 0 && selectedMinute >= 0 && selectedMinute < 60 && !options.includes(selectedMinute)) {
1427
+ options.push(selectedMinute);
1428
+ options.sort((a, b) => a - b);
1429
+ }
1430
+ return options;
1431
+ }
1432
+ function getCurrentTimeValue(precision, minuteStep) {
1433
+ const now = /* @__PURE__ */ new Date();
1434
+ const minute = precision === "hour" ? 0 : Math.floor(now.getMinutes() / minuteStep) * minuteStep;
1435
+ return formatTimeValue(now.getHours(), minute);
1436
+ }
1437
+
1438
+ // src/internal/time/time-picker-panel.tsx
1439
+ var import_jsx_runtime13 = require("react/jsx-runtime");
1440
+ var HOURS = Array.from({ length: 24 }, (_, hour) => hour);
1441
+ var ITEM_HEIGHT = 44;
1442
+ var VISIBLE_ITEMS = 5;
1443
+ var WHEEL_PADDING = ITEM_HEIGHT * Math.floor(VISIBLE_ITEMS / 2);
1444
+ function WheelColumn({ label, optionAriaLabel, options, selected, onSelect }) {
1445
+ const scrollRef = (0, import_react9.useRef)(null);
1446
+ const settleTimerRef = (0, import_react9.useRef)(null);
1447
+ const selectedIndex = Math.max(0, options.indexOf(selected));
1448
+ (0, import_react9.useEffect)(() => {
1449
+ const node = scrollRef.current;
1450
+ if (!node) return;
1451
+ const top = selectedIndex * ITEM_HEIGHT;
1452
+ if (typeof node.scrollTo === "function") node.scrollTo({ top, behavior: "auto" });
1453
+ else node.scrollTop = top;
1454
+ }, [selectedIndex]);
1455
+ (0, import_react9.useEffect)(() => () => {
1456
+ if (settleTimerRef.current !== null) window.clearTimeout(settleTimerRef.current);
1457
+ }, []);
1458
+ const settleSelection = () => {
1459
+ const node = scrollRef.current;
1460
+ if (!node) return;
1461
+ const index = Math.max(0, Math.min(options.length - 1, Math.round(node.scrollTop / ITEM_HEIGHT)));
1462
+ const next = options[index];
1463
+ if (next !== void 0 && next !== selected) onSelect(next);
1464
+ };
1465
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "relative z-10 min-w-0 flex-1", children: [
1466
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "sr-only", children: label }),
1467
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1468
+ "div",
1469
+ {
1470
+ ref: scrollRef,
1471
+ role: "group",
1472
+ "aria-label": label,
1473
+ onScroll: () => {
1474
+ if (settleTimerRef.current !== null) window.clearTimeout(settleTimerRef.current);
1475
+ settleTimerRef.current = window.setTimeout(settleSelection, 90);
1476
+ },
1477
+ className: "h-[220px] snap-y snap-mandatory overflow-y-auto overscroll-contain [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",
1478
+ style: { paddingBlock: WHEEL_PADDING },
1479
+ children: options.map((option, index) => {
1480
+ const active = option === selected;
1481
+ const distance = Math.abs(index - selectedIndex);
1482
+ const text = String(option).padStart(2, "0");
1483
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1484
+ "button",
1485
+ {
1486
+ type: "button",
1487
+ "aria-label": optionAriaLabel(text),
1488
+ "aria-pressed": active,
1489
+ tabIndex: active ? 0 : -1,
1490
+ onClick: () => onSelect(option),
1491
+ className: cn(
1492
+ "flex h-11 w-full snap-center appearance-none items-center justify-center border-0 bg-transparent px-2 tabular-nums shadow-none outline-none transition-[color,opacity,font-size] duration-150 focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--color-focus)]/25",
1493
+ active ? "text-xl font-semibold text-[var(--color-text)] opacity-100" : distance === 1 ? "text-lg font-medium text-[var(--color-text-muted)] opacity-65" : distance === 2 ? "text-base text-[var(--color-text-muted)] opacity-35" : "text-sm text-[var(--color-text-muted)] opacity-20"
1494
+ ),
1495
+ children: text
1496
+ },
1497
+ option
1498
+ );
1499
+ })
1500
+ }
1501
+ )
1502
+ ] });
1503
+ }
1504
+ function TimePickerPanel({ value, variant, minuteStep, onChange, className }) {
1505
+ const { t } = useDLocalization();
1506
+ const parsed = parseTimeValue(value) ?? { hour: 0, minute: 0 };
1507
+ const minuteOptions = getMinuteOptions(minuteStep, parsed.minute);
1508
+ const hourLabel = t("timePicker.hour");
1509
+ const minuteLabel = t("timePicker.minute");
1510
+ const selectHour = (hour) => {
1511
+ onChange(formatTimeValue(hour, variant === "hour" ? 0 : parsed.minute));
1512
+ };
1513
+ const selectMinute = (minute) => {
1514
+ onChange(formatTimeValue(parsed.hour, minute));
1515
+ };
1516
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
1517
+ "div",
1518
+ {
1519
+ "data-time-picker-wheel": "true",
1520
+ className: cn(
1521
+ "relative mx-auto overflow-hidden rounded-[var(--radius-panel)] bg-[var(--color-surface)]",
1522
+ variant === "hour-minute" ? "w-full max-w-[244px]" : "w-full max-w-[112px]",
1523
+ className
1524
+ ),
1525
+ children: [
1526
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "pointer-events-none absolute inset-x-0 top-1/2 z-0 h-11 -translate-y-1/2 rounded-[var(--radius-control)] border border-[var(--color-border)] bg-[var(--color-surface-muted)]/55" }),
1527
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "pointer-events-none absolute inset-x-0 top-0 z-20 h-16 bg-gradient-to-b from-[var(--color-surface)] to-transparent" }),
1528
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "pointer-events-none absolute inset-x-0 bottom-0 z-20 h-16 bg-gradient-to-t from-[var(--color-surface)] to-transparent" }),
1529
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "relative z-10 flex items-center gap-2", children: [
1530
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1531
+ WheelColumn,
1532
+ {
1533
+ label: hourLabel,
1534
+ optionAriaLabel: (text) => t("timePicker.hourOption", { value: text }),
1535
+ options: HOURS,
1536
+ selected: parsed.hour,
1537
+ onSelect: selectHour
1538
+ }
1539
+ ),
1540
+ variant === "hour-minute" ? /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
1541
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { "aria-hidden": "true", className: "relative z-10 -mx-1 text-xl font-semibold text-[var(--color-text-muted)]", children: ":" }),
1542
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1543
+ WheelColumn,
1544
+ {
1545
+ label: minuteLabel,
1546
+ optionAriaLabel: (text) => t("timePicker.minuteOption", { value: text }),
1547
+ options: minuteOptions,
1548
+ selected: parsed.minute,
1549
+ onSelect: selectMinute
1550
+ }
1551
+ )
1552
+ ] }) : null
1553
+ ] })
1554
+ ]
1555
+ }
1556
+ );
1557
+ }
1558
+
1559
+ // src/date-picker/date-picker.tsx
1560
+ var import_jsx_runtime14 = require("react/jsx-runtime");
1561
+ function ChevronLeftIcon2() {
1562
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", className: "size-4", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "m15 18-6-6 6-6" }) });
1563
+ }
1564
+ function ChevronRightIcon2() {
1565
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", className: "size-4", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "m9 18 6-6-6-6" }) });
1566
+ }
1567
+ function CalendarIcon() {
1568
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", className: "size-3.5", children: [
1569
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("rect", { x: "3", y: "5", width: "18", height: "16", rx: "2" }),
1570
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M16 3v4M8 3v4M3 10h18" })
1571
+ ] });
1572
+ }
1573
+ function ClearIcon2() {
1574
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", className: "size-3.5", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "m18 6-12 12M6 6l12 12" }) });
1575
+ }
1576
+ function datePart(value) {
1577
+ return value?.split("T")[0] ?? "";
1578
+ }
1579
+ function timePart(value) {
1580
+ const separator = value?.indexOf("T") ?? -1;
1581
+ return separator >= 0 ? value?.slice(separator + 1) ?? "" : "";
1582
+ }
1583
+ function parseDate(value) {
1584
+ const raw = datePart(value);
1585
+ if (!raw) return null;
1586
+ const date2 = /* @__PURE__ */ new Date(`${raw}T00:00:00`);
1587
+ return Number.isNaN(date2.getTime()) ? null : date2;
1588
+ }
1589
+ function toValue(year, month, day) {
1590
+ return `${year}-${String(month + 1).padStart(2, "0")}-${String(day).padStart(2, "0")}`;
1591
+ }
1592
+ function compareDateValue(value, boundary) {
1593
+ if (!boundary) return 0;
1594
+ return value.localeCompare(datePart(boundary));
1595
+ }
1596
+ function timePrecision(variant) {
1597
+ return variant === "date-hour" ? "hour" : "hour-minute";
1598
+ }
1599
+ function formatDateDisplay(value, months) {
1600
+ const date2 = parseDate(value);
1601
+ return date2 ? `${date2.getDate()} ${months[date2.getMonth()]} ${date2.getFullYear()}` : "";
1602
+ }
1603
+ function formatDisplayValue(value, variant, months) {
1604
+ const dateDisplay = formatDateDisplay(value, months);
1605
+ if (!dateDisplay) return "";
1606
+ if (variant === "date") return dateDisplay;
1607
+ const timeDisplay = normalizeTimeValue(timePart(value), timePrecision(variant));
1608
+ return timeDisplay ? `${dateDisplay} \xB7 ${timeDisplay}` : dateDisplay;
1609
+ }
1610
+ function DatePickerContent({ value, onChange, minDate, maxDate, variant, minuteStep }) {
1611
+ const close = useDropdownClose();
1612
+ const { locale, t } = useDLocalization();
1613
+ const days = (0, import_react10.useMemo)(() => getLocalizedWeekdayNames(locale, "short"), [locale]);
1614
+ const months = (0, import_react10.useMemo)(() => getLocalizedMonthNames(locale), [locale]);
1615
+ const today = /* @__PURE__ */ new Date();
1616
+ const selectedDate = parseDate(value);
1617
+ const selectedDateValue = datePart(value);
1618
+ const precision = timePrecision(variant);
1619
+ const fallbackTime = () => getCurrentTimeValue(precision, minuteStep);
1620
+ const selectedTimeValue = normalizeTimeValue(timePart(value), precision) || fallbackTime();
1621
+ const [viewMonth, setViewMonth] = (0, import_react10.useState)(selectedDate?.getMonth() ?? today.getMonth());
1622
+ const [viewYear, setViewYear] = (0, import_react10.useState)(selectedDate?.getFullYear() ?? today.getFullYear());
1623
+ const [draftDate, setDraftDate] = (0, import_react10.useState)(selectedDateValue);
1624
+ const [draftTime, setDraftTime] = (0, import_react10.useState)(selectedTimeValue);
1625
+ (0, import_react10.useEffect)(() => {
1626
+ const nextDate = parseDate(value);
1627
+ setDraftDate(datePart(value));
1628
+ setDraftTime(normalizeTimeValue(timePart(value), precision) || fallbackTime());
1629
+ if (!nextDate) return;
1630
+ setViewMonth(nextDate.getMonth());
1631
+ setViewYear(nextDate.getFullYear());
1632
+ }, [value, variant, minuteStep]);
1633
+ const daysInMonth = new Date(viewYear, viewMonth + 1, 0).getDate();
1634
+ const firstDay = new Date(viewYear, viewMonth, 1).getDay();
1635
+ const move = (amount) => {
1636
+ const next = new Date(viewYear, viewMonth + amount, 1);
1637
+ setViewYear(next.getFullYear());
1638
+ setViewMonth(next.getMonth());
1639
+ };
1640
+ const selectDate = (day) => {
1641
+ const next = toValue(viewYear, viewMonth, day);
1642
+ if (minDate && compareDateValue(next, minDate) < 0 || maxDate && compareDateValue(next, maxDate) > 0) return;
1643
+ if (variant === "date") {
1644
+ onChange?.(next);
1645
+ close?.();
1646
+ return;
1647
+ }
1648
+ setDraftDate(next);
1649
+ };
1650
+ const todayValue = toValue(today.getFullYear(), today.getMonth(), today.getDate());
1651
+ const todayDisabled = minDate && compareDateValue(todayValue, minDate) < 0 || maxDate && compareDateValue(todayValue, maxDate) > 0;
1652
+ const selectToday = () => {
1653
+ if (variant === "date") {
1654
+ onChange?.(todayValue);
1655
+ close?.();
1656
+ return;
1657
+ }
1658
+ setDraftDate(todayValue);
1659
+ setViewMonth(today.getMonth());
1660
+ setViewYear(today.getFullYear());
1661
+ };
1662
+ const applyDateTime = () => {
1663
+ if (!draftDate) return;
1664
+ const normalizedTime = normalizeTimeValue(draftTime, precision) || fallbackTime();
1665
+ onChange?.(`${draftDate}T${normalizedTime}`);
1666
+ close?.();
1667
+ };
1668
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: cn("p-3", variant === "date" ? "w-[280px]" : "w-[min(320px,calc(100vw-16px))]"), children: [
1669
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "mb-2 flex items-center justify-between", children: [
1670
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("button", { type: "button", "aria-label": t("common.previousMonth"), onClick: () => move(-1), className: "flex size-8 appearance-none items-center justify-center rounded-[var(--radius-menu-item)] border-0 bg-transparent text-[var(--color-text-muted)] shadow-none hover:bg-[var(--color-surface-muted)]", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(ChevronLeftIcon2, {}) }),
1671
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("span", { className: "text-sm font-medium text-[var(--color-text)]", children: [
1672
+ months[viewMonth],
1673
+ " ",
1674
+ viewYear
1675
+ ] }),
1676
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("button", { type: "button", "aria-label": t("common.nextMonth"), onClick: () => move(1), className: "flex size-8 appearance-none items-center justify-center rounded-[var(--radius-menu-item)] border-0 bg-transparent text-[var(--color-text-muted)] shadow-none hover:bg-[var(--color-surface-muted)]", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(ChevronRightIcon2, {}) })
1677
+ ] }),
1678
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "mb-1 grid grid-cols-7 text-xs", children: days.map((day) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "text-center text-[var(--color-text-muted)]", children: day }, day)) }),
1679
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "grid grid-cols-7 gap-1", children: [
1680
+ Array.from({ length: firstDay }).map((_, index) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", {}, `empty-${index}`)),
1681
+ Array.from({ length: daysInMonth }, (_, index) => index + 1).map((day) => {
1682
+ const dateValue = toValue(viewYear, viewMonth, day);
1683
+ const selected = (variant === "date" ? selectedDateValue : draftDate) === dateValue;
1684
+ const outside = minDate && compareDateValue(dateValue, minDate) < 0 || maxDate && compareDateValue(dateValue, maxDate) > 0;
1685
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("button", { type: "button", disabled: Boolean(outside), onClick: () => selectDate(day), className: cn("aspect-square w-full appearance-none rounded-[var(--radius-control)] border-0 bg-transparent text-sm shadow-none transition-colors hover:bg-[var(--color-surface-muted)] disabled:cursor-not-allowed disabled:opacity-30", selected && "bg-[var(--color-brand)] font-medium text-[var(--color-brand-foreground)] hover:bg-[var(--color-brand)]"), children: day }, day);
1686
+ })
1687
+ ] }),
1688
+ variant !== "date" ? /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "mt-3 border-t border-[var(--color-border)] pt-3", children: [
1689
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "mb-3 flex items-center justify-between gap-3", children: [
1690
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { children: [
1691
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("p", { className: "text-xs font-semibold text-[var(--color-text)]", children: t("datePicker.time") }),
1692
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("p", { className: "mt-0.5 text-[11px] text-[var(--color-text-muted)]", children: variant === "date-hour" ? t("datePicker.selectHour") : t("datePicker.selectHourMinute") })
1693
+ ] }),
1694
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: "rounded-[var(--radius-menu-item)] bg-[var(--color-surface-muted)] px-2 py-1 text-xs font-semibold tabular-nums text-[var(--color-text)]", children: draftTime })
1695
+ ] }),
1696
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(TimePickerPanel, { value: draftTime, variant: precision, minuteStep, onChange: setDraftTime })
1697
+ ] }) : null,
1698
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "mt-3 flex items-center justify-between gap-2 border-t border-[var(--color-border)] pt-3", children: [
1699
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("button", { type: "button", disabled: Boolean(todayDisabled), onClick: selectToday, className: "h-8 appearance-none rounded-[var(--radius-menu-item)] border-0 bg-transparent px-2 text-xs font-medium text-[var(--color-brand)] shadow-none hover:bg-[var(--color-surface-muted)] disabled:cursor-not-allowed disabled:opacity-40", children: t("datePicker.today") }),
1700
+ variant !== "date" ? /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "flex items-center gap-2", children: [
1701
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("button", { type: "button", onClick: () => close?.(), className: "h-8 appearance-none rounded-[var(--radius-menu-item)] border-0 bg-transparent px-3 text-xs font-medium text-[var(--color-text-muted)] shadow-none hover:bg-[var(--color-surface-muted)]", children: t("common.cancel") }),
1702
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("button", { type: "button", disabled: !draftDate, onClick: applyDateTime, className: "h-8 appearance-none rounded-[var(--radius-menu-item)] border-0 bg-[var(--color-brand)] px-3 text-xs font-semibold text-[var(--color-brand-foreground)] shadow-none hover:brightness-95 disabled:cursor-not-allowed disabled:opacity-50", children: t("common.apply") })
1703
+ ] }) : null
1704
+ ] })
1705
+ ] });
1706
+ }
1707
+ function DDatePicker({ label, value, onChange, onClear, placeholder, error, hint, disabled = false, clearable = true, containerClassName, minDate, maxDate, size = "md", variant = "date", minuteStep = 1, scrollBehavior = "reposition" }) {
1708
+ const id = (0, import_react10.useId)();
1709
+ const { locale, t } = useDLocalization();
1710
+ const months = (0, import_react10.useMemo)(() => getLocalizedMonthNames(locale), [locale]);
1711
+ const s = INPUT_SIZE_STYLES[size];
1712
+ const display = formatDisplayValue(value, variant, months);
1713
+ const resolvedPlaceholder = placeholder ?? t("datePicker.placeholder");
1714
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { "data-ds-component": "date-picker", "data-date-picker-variant": variant, className: cn("flex min-w-0 flex-col gap-1.5", containerClassName), children: [
1715
+ label ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("label", { htmlFor: id, className: cn(s.label, "w-fit font-medium text-[var(--color-text)]"), children: label }) : null,
1716
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(DDropdown, { contentRole: "dialog", contentPadding: false, scrollBehavior, trigger: () => /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "relative", children: [
1717
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("button", { id, type: "button", disabled, "aria-invalid": Boolean(error) || void 0, className: cn("flex w-full items-center gap-2 rounded-[var(--radius-control)] border bg-[var(--color-surface)] text-left text-[var(--color-text)] transition-colors focus:border-[var(--color-brand)] focus:outline-none focus:ring-2 focus:ring-[var(--color-brand)]/20 disabled:cursor-not-allowed disabled:bg-[var(--color-surface-muted)] disabled:opacity-50", s.input, error ? "border-[var(--color-danger)]" : "border-[var(--color-border)]", !display && "text-[var(--color-text-muted)]/60", clearable && display && "pr-10"), children: [
1718
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: "text-[var(--color-text-muted)]", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(CalendarIcon, {}) }),
1719
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: "min-w-0 flex-1 truncate", children: display || resolvedPlaceholder })
1720
+ ] }),
1721
+ clearable && display && !disabled ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("button", { type: "button", "aria-label": t("datePicker.clear"), onMouseDown: (event) => event.preventDefault(), onClick: (event) => {
1722
+ event.preventDefault();
1723
+ event.stopPropagation();
1724
+ onChange?.("");
1725
+ onClear?.();
1726
+ }, className: "absolute right-2 top-1/2 -translate-y-1/2 appearance-none rounded-md border-0 bg-transparent p-1 text-[var(--color-text-muted)] shadow-none hover:bg-[var(--color-surface-muted)]", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(ClearIcon2, {}) }) : null
1727
+ ] }), children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(DatePickerContent, { value, onChange, minDate, maxDate, variant, minuteStep }) }),
1728
+ error ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("p", { className: "text-xs text-[var(--color-danger)]", children: error }) : null,
1729
+ !error && hint ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("p", { className: "text-xs text-[var(--color-text-muted)]", children: hint }) : null
1730
+ ] });
1731
+ }
1732
+
1733
+ // src/time-picker/time-picker.tsx
1734
+ var import_react11 = require("react");
1735
+ var import_jsx_runtime15 = require("react/jsx-runtime");
1736
+ function ClockIcon() {
1737
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", className: "size-3.5", children: [
1738
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("circle", { cx: "12", cy: "12", r: "9" }),
1739
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("path", { d: "M12 7v5l3 2" })
1740
+ ] });
1741
+ }
1742
+ function ClearIcon3() {
1743
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", className: "size-3.5", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("path", { d: "m18 6-12 12M6 6l12 12" }) });
1744
+ }
1745
+ function TimePickerContent({
1746
+ value,
1747
+ onChange,
1748
+ variant,
1749
+ minuteStep
1750
+ }) {
1751
+ const close = useDropdownClose();
1752
+ const { t } = useDLocalization();
1753
+ const fallback = () => getCurrentTimeValue(variant, minuteStep);
1754
+ const [draft, setDraft] = (0, import_react11.useState)(() => normalizeTimeValue(value, variant) || fallback());
1755
+ (0, import_react11.useEffect)(() => {
1756
+ setDraft(normalizeTimeValue(value, variant) || fallback());
1757
+ }, [value, variant, minuteStep]);
1758
+ const apply = () => {
1759
+ onChange?.(normalizeTimeValue(draft, variant));
1760
+ close?.();
1761
+ };
1762
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: cn("p-3", variant === "hour" ? "w-[min(232px,calc(100vw-16px))]" : "w-[min(320px,calc(100vw-16px))]"), children: [
1763
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "mb-3 flex items-center justify-between gap-3", children: [
1764
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { children: [
1765
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("p", { className: "text-xs font-semibold text-[var(--color-text)]", children: t("timePicker.title") }),
1766
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("p", { className: "mt-0.5 text-[11px] text-[var(--color-text-muted)]", children: variant === "hour" ? t("timePicker.hourPrecision") : t("timePicker.hourMinutePrecision") })
1767
+ ] }),
1768
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "rounded-[var(--radius-menu-item)] bg-[var(--color-surface-muted)] px-2 py-1 text-xs font-semibold tabular-nums text-[var(--color-text)]", children: draft })
1769
+ ] }),
1770
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(TimePickerPanel, { value: draft, variant, minuteStep, onChange: setDraft }),
1771
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "mt-3 flex items-center justify-between gap-2 border-t border-[var(--color-border)] pt-3", children: [
1772
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
1773
+ "button",
1774
+ {
1775
+ type: "button",
1776
+ onClick: () => setDraft(fallback()),
1777
+ className: "h-8 appearance-none rounded-[var(--radius-menu-item)] border-0 bg-transparent px-2 text-xs font-medium text-[var(--color-brand)] shadow-none hover:bg-[var(--color-surface-muted)]",
1778
+ children: t("timePicker.now")
1779
+ }
1780
+ ),
1781
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "flex items-center gap-2", children: [
1782
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
1783
+ "button",
1784
+ {
1785
+ type: "button",
1786
+ onClick: () => close?.(),
1787
+ className: "h-8 appearance-none rounded-[var(--radius-menu-item)] border-0 bg-transparent px-3 text-xs font-medium text-[var(--color-text-muted)] shadow-none hover:bg-[var(--color-surface-muted)]",
1788
+ children: t("common.cancel")
1789
+ }
1790
+ ),
1791
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
1792
+ "button",
1793
+ {
1794
+ type: "button",
1795
+ onClick: apply,
1796
+ className: "h-8 appearance-none rounded-[var(--radius-menu-item)] border-0 bg-[var(--color-brand)] px-3 text-xs font-semibold text-[var(--color-brand-foreground)] shadow-none hover:brightness-95",
1797
+ children: t("common.apply")
1798
+ }
1799
+ )
1800
+ ] })
1801
+ ] })
1802
+ ] });
1803
+ }
1804
+ function DTimePicker({
1805
+ label,
1806
+ value,
1807
+ onChange,
1808
+ onClear,
1809
+ placeholder,
1810
+ error,
1811
+ hint,
1812
+ disabled = false,
1813
+ clearable = true,
1814
+ containerClassName,
1815
+ size = "md",
1816
+ variant = "hour-minute",
1817
+ minuteStep = 1,
1818
+ scrollBehavior = "reposition"
1819
+ }) {
1820
+ const id = (0, import_react11.useId)();
1821
+ const { t } = useDLocalization();
1822
+ const s = INPUT_SIZE_STYLES[size];
1823
+ const display = normalizeTimeValue(value, variant);
1824
+ const resolvedPlaceholder = placeholder ?? t("timePicker.placeholder");
1825
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { "data-ds-component": "time-picker", className: cn("flex min-w-0 flex-col gap-1.5", containerClassName), children: [
1826
+ label ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("label", { htmlFor: id, className: cn(s.label, "w-fit font-medium text-[var(--color-text)]"), children: label }) : null,
1827
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(DDropdown, { contentRole: "dialog", contentPadding: false, scrollBehavior, trigger: () => /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "relative", children: [
1828
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
1829
+ "button",
1830
+ {
1831
+ id,
1832
+ type: "button",
1833
+ disabled,
1834
+ "aria-invalid": Boolean(error) || void 0,
1835
+ className: cn(
1836
+ "flex w-full items-center gap-2 rounded-[var(--radius-control)] border bg-[var(--color-surface)] text-left text-[var(--color-text)] transition-colors focus:border-[var(--color-brand)] focus:outline-none focus:ring-2 focus:ring-[var(--color-brand)]/20 disabled:cursor-not-allowed disabled:bg-[var(--color-surface-muted)] disabled:opacity-50",
1837
+ s.input,
1838
+ error ? "border-[var(--color-danger)]" : "border-[var(--color-border)]",
1839
+ !display && "text-[var(--color-text-muted)]/60",
1840
+ clearable && display && "pr-10"
1841
+ ),
1842
+ children: [
1843
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "text-[var(--color-text-muted)]", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(ClockIcon, {}) }),
1844
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "min-w-0 flex-1 truncate tabular-nums", children: display || resolvedPlaceholder })
1845
+ ]
1846
+ }
1847
+ ),
1848
+ clearable && display && !disabled ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
1849
+ "button",
1850
+ {
1851
+ type: "button",
1852
+ "aria-label": t("timePicker.clear"),
1853
+ onMouseDown: (event) => event.preventDefault(),
1854
+ onClick: (event) => {
1855
+ event.preventDefault();
1856
+ event.stopPropagation();
1857
+ onChange?.("");
1858
+ onClear?.();
1859
+ },
1860
+ className: "absolute right-2 top-1/2 -translate-y-1/2 appearance-none rounded-md border-0 bg-transparent p-1 text-[var(--color-text-muted)] shadow-none hover:bg-[var(--color-surface-muted)]",
1861
+ children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(ClearIcon3, {})
1862
+ }
1863
+ ) : null
1864
+ ] }), children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(TimePickerContent, { value, onChange, variant, minuteStep }) }),
1865
+ error ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("p", { className: "text-xs text-[var(--color-danger)]", children: error }) : null,
1866
+ !error && hint ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("p", { className: "text-xs text-[var(--color-text-muted)]", children: hint }) : null
1867
+ ] });
1868
+ }
1869
+
1870
+ // src/date-range-filter/date-range-filter.tsx
1871
+ var import_jsx_runtime16 = require("react/jsx-runtime");
1872
+ function DDateRangeFilter({ from, to, onFromChange, onToChange, onClear }) {
1873
+ const { t } = useDLocalization();
1874
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { "data-ds-component": "date-range-filter", className: "flex flex-wrap items-center gap-3", children: [
1875
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "hidden text-xs font-medium text-[var(--color-text-muted)] sm:inline", children: t("dateRangeFilter.period") }),
1876
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(DDatePicker, { value: from, onChange: onFromChange, containerClassName: "w-[160px]", placeholder: t("dateRangeFilter.from") }),
1877
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "text-sm text-[var(--color-text-muted)]", children: "\u2014" }),
1878
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(DDatePicker, { value: to, onChange: onToChange, minDate: from || void 0, containerClassName: "w-[160px]", placeholder: t("dateRangeFilter.to") }),
1879
+ onClear && (from || to) ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1880
+ "button",
1881
+ {
1882
+ type: "button",
1883
+ onClick: onClear,
1884
+ className: "h-9 rounded-[var(--radius-control)] border border-[var(--color-border)] bg-[var(--color-surface)] px-3 text-xs font-medium text-[var(--color-text-muted)] hover:bg-[var(--color-danger)]/5 hover:text-[var(--color-danger)]",
1885
+ children: t("dateRangeFilter.reset")
1886
+ }
1887
+ ) : null
1888
+ ] });
1889
+ }
1890
+
1891
+ // src/empty-state/empty-state.tsx
1892
+ var import_jsx_runtime17 = require("react/jsx-runtime");
1893
+ function DEmptyState({
1894
+ title,
1895
+ description,
1896
+ action,
1897
+ icon,
1898
+ className
1899
+ }) {
1900
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
1901
+ "div",
1902
+ {
1903
+ className: cn(
1904
+ "flex min-h-48 flex-col items-center justify-center rounded-[var(--radius-card)] border border-dashed border-[var(--color-border)] bg-[var(--color-surface-muted)]/20 px-4 py-10 text-center",
1905
+ className
1906
+ ),
1907
+ children: [
1908
+ icon ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "mb-3 text-[var(--color-text-muted)]", children: icon }) : null,
1909
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("p", { className: "text-sm font-semibold", children: title }),
1910
+ description ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("p", { className: "mt-1 max-w-sm text-xs leading-5 text-[var(--color-text-muted)]", children: description }) : null,
1911
+ action ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "mt-4", children: action }) : null
1912
+ ]
1913
+ }
1914
+ );
1915
+ }
1916
+
1917
+ // src/export-button/export-button.tsx
1918
+ var import_react12 = require("react");
1919
+ var import_jsx_runtime18 = require("react/jsx-runtime");
1920
+ function DownloadIcon() {
1921
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", className: "size-3.5", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("path", { d: "M12 3v12m0 0 4-4m-4 4-4-4M5 21h14" }) });
1922
+ }
1923
+ function ExportContent({ onExport, filename, onSuccess, onError, onProcessing, setLoading }) {
1924
+ const close = useDropdownClose();
1925
+ const { t } = useDLocalization();
1926
+ const run = async (format) => {
1927
+ close?.();
1928
+ setLoading(true);
1929
+ try {
1930
+ const result = onExport(format);
1931
+ if (result instanceof Promise) {
1932
+ const blob = await result;
1933
+ const url2 = URL.createObjectURL(blob);
1934
+ const anchor = document.createElement("a");
1935
+ anchor.href = url2;
1936
+ anchor.download = `${filename}.${format === "pdf" ? "pdf" : "xlsx"}`;
1937
+ document.body.appendChild(anchor);
1938
+ anchor.click();
1939
+ anchor.remove();
1940
+ URL.revokeObjectURL(url2);
1941
+ onSuccess?.(format);
1942
+ } else if (result instanceof Blob) {
1943
+ const url2 = URL.createObjectURL(result);
1944
+ const anchor = document.createElement("a");
1945
+ anchor.href = url2;
1946
+ anchor.download = `${filename}.${format === "pdf" ? "pdf" : "xlsx"}`;
1947
+ document.body.appendChild(anchor);
1948
+ anchor.click();
1949
+ anchor.remove();
1950
+ URL.revokeObjectURL(url2);
1951
+ onSuccess?.(format);
1952
+ } else onProcessing?.(format);
1953
+ } catch (error) {
1954
+ onError?.(error, format);
1955
+ } finally {
1956
+ setLoading(false);
1957
+ }
1958
+ };
1959
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "min-w-[140px] py-1", children: [
1960
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("button", { type: "button", onClick: () => void run("pdf"), className: "w-full px-3 py-2 text-left text-sm text-[var(--color-text)] hover:bg-[var(--color-surface-muted)]", children: t("export.pdf") }),
1961
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("button", { type: "button", onClick: () => void run("excel"), className: "w-full px-3 py-2 text-left text-sm text-[var(--color-text)] hover:bg-[var(--color-surface-muted)]", children: t("export.excel") })
1962
+ ] });
1963
+ }
1964
+ function DExportButton({ filename = "export", disabled, ...props }) {
1965
+ const [loading, setLoading] = (0, import_react12.useState)(false);
1966
+ const { t } = useDLocalization();
1967
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(DDropdown, { placement: "bottom-end", trigger: () => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(DButton, { variant: "outline", size: "sm", leftIcon: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(DownloadIcon, {}), loading, disabled, children: t("export.label") }), children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ExportContent, { ...props, filename, disabled, setLoading }) });
1968
+ }
1969
+
1970
+ // src/form-validation/form.tsx
1971
+ var import_react13 = require("react");
1972
+
1973
+ // src/form-validation/validation.ts
1974
+ function issue(key, params, message) {
1975
+ return { key, params, message };
1976
+ }
1977
+ function isEmpty(value) {
1978
+ if (value === void 0 || value === null || value === "" || value === false) return true;
1979
+ if (typeof value === "string") return value.trim() === "";
1980
+ if (Array.isArray(value)) return value.length === 0;
1981
+ if (typeof value === "object") {
1982
+ const entries = Object.values(value);
1983
+ return entries.length === 0 || entries.every(isEmpty);
1984
+ }
1985
+ return false;
1986
+ }
1987
+ function optionalEmpty(value) {
1988
+ return value === void 0 || value === null || typeof value === "string" && value.trim() === "";
1989
+ }
1990
+ function required(message) {
1991
+ return (value) => isEmpty(value) ? issue("validation.required", void 0, message) : null;
1992
+ }
1993
+ function accepted(message) {
1994
+ return (value) => value === true || value === "true" || value === 1 ? null : issue("validation.accepted", void 0, message);
1995
+ }
1996
+ function email(message) {
1997
+ const pattern2 = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
1998
+ return (value) => optionalEmpty(value) || pattern2.test(String(value)) ? null : issue("validation.email", void 0, message);
1999
+ }
2000
+ function url(message) {
2001
+ return (value) => {
2002
+ if (optionalEmpty(value)) return null;
2003
+ try {
2004
+ const parsed = new URL(String(value));
2005
+ return parsed.protocol === "http:" || parsed.protocol === "https:" ? null : issue("validation.url", void 0, message);
2006
+ } catch {
2007
+ return issue("validation.url", void 0, message);
2008
+ }
2009
+ };
2010
+ }
2011
+ function minLength(min, message) {
2012
+ return (value) => optionalEmpty(value) || String(value).length >= min ? null : issue("validation.minLength", { min }, message);
2013
+ }
2014
+ function maxLength(max, message) {
2015
+ return (value) => optionalEmpty(value) || String(value).length <= max ? null : issue("validation.maxLength", { max }, message);
2016
+ }
2017
+ function minValue(min, message) {
2018
+ return (value) => optionalEmpty(value) || Number.isFinite(Number(value)) && Number(value) >= min ? null : issue("validation.minValue", { min }, message);
2019
+ }
2020
+ function maxValue(max, message) {
2021
+ return (value) => optionalEmpty(value) || Number.isFinite(Number(value)) && Number(value) <= max ? null : issue("validation.maxValue", { max }, message);
2022
+ }
2023
+ function integer(message) {
2024
+ return (value) => optionalEmpty(value) || Number.isInteger(Number(value)) ? null : issue("validation.integer", void 0, message);
2025
+ }
2026
+ function pattern(regex, message) {
2027
+ return (value) => {
2028
+ if (optionalEmpty(value)) return null;
2029
+ regex.lastIndex = 0;
2030
+ return regex.test(String(value)) ? null : issue("validation.pattern", void 0, message);
2031
+ };
2032
+ }
2033
+ function sameAs(otherField, otherLabel = otherField, message) {
2034
+ return (value, context) => Object.is(value, context.values[otherField]) ? null : issue("validation.sameAs", { otherLabel }, message);
2035
+ }
2036
+ function oneOf(values, message) {
2037
+ return (value) => optionalEmpty(value) || values.some((candidate) => Object.is(candidate, value)) ? null : issue("validation.oneOf", void 0, message);
2038
+ }
2039
+ function date(message) {
2040
+ return (value) => {
2041
+ if (optionalEmpty(value)) return null;
2042
+ const raw = String(value).split("T")[0] ?? "";
2043
+ const match = /^(\d{4})-(\d{2})-(\d{2})$/.exec(raw);
2044
+ if (!match) return issue("validation.date", void 0, message);
2045
+ const year = Number(match[1]);
2046
+ const month = Number(match[2]);
2047
+ const day = Number(match[3]);
2048
+ const parsed = new Date(year, month - 1, day);
2049
+ return parsed.getFullYear() === year && parsed.getMonth() === month - 1 && parsed.getDate() === day ? null : issue("validation.date", void 0, message);
2050
+ };
2051
+ }
2052
+ function time(message) {
2053
+ return (value) => optionalEmpty(value) || /^(?:[01]\d|2[0-3]):[0-5]\d$/.test(String(value).split("T").pop() ?? "") ? null : issue("validation.time", void 0, message);
2054
+ }
2055
+ function customValidation(rule) {
2056
+ return rule;
2057
+ }
2058
+ async function validateValue(value, rules = [], context = { name: "", label: "Field", values: {} }) {
2059
+ for (const rule of rules) {
2060
+ const result = await rule(value, context);
2061
+ if (!result) continue;
2062
+ if (typeof result === "string") return { message: result };
2063
+ return result;
2064
+ }
2065
+ return null;
2066
+ }
2067
+
2068
+ // src/form-validation/form.tsx
2069
+ var import_jsx_runtime19 = require("react/jsx-runtime");
2070
+ var FormContext = (0, import_react13.createContext)(null);
2071
+ function normalizeValidateOn(value) {
2072
+ return typeof value === "string" ? [value] : value ?? ["submit"];
2073
+ }
2074
+ function formatIssue(issue2, label, t) {
2075
+ if (!issue2) return void 0;
2076
+ if (issue2.message) return issue2.message;
2077
+ return t(issue2.key ?? "validation.invalid", { label, ...issue2.params });
2078
+ }
2079
+ function DForm({
2080
+ children,
2081
+ values = {},
2082
+ schema,
2083
+ validateOn,
2084
+ onSubmit,
2085
+ onInvalid,
2086
+ className,
2087
+ ...props
2088
+ }) {
2089
+ const { t } = useDLocalization();
2090
+ const [errors, setErrors] = (0, import_react13.useState)({});
2091
+ const [submitted, setSubmitted] = (0, import_react13.useState)(false);
2092
+ const fieldsRef = (0, import_react13.useRef)(/* @__PURE__ */ new Map());
2093
+ const modes = (0, import_react13.useMemo)(() => normalizeValidateOn(validateOn), [validateOn]);
2094
+ const mergedValues = (0, import_react13.useCallback)(() => {
2095
+ const next = { ...values };
2096
+ fieldsRef.current.forEach((field, name) => {
2097
+ next[name] = field.value;
2098
+ });
2099
+ return next;
2100
+ }, [values]);
2101
+ const register = (0, import_react13.useCallback)((name, field) => {
2102
+ fieldsRef.current.set(name, field);
2103
+ }, []);
2104
+ const unregister = (0, import_react13.useCallback)((name) => {
2105
+ fieldsRef.current.delete(name);
2106
+ }, []);
2107
+ const setFieldError = (0, import_react13.useCallback)((name, error) => {
2108
+ setErrors((current) => {
2109
+ if (current[name] === error) return current;
2110
+ const next = { ...current };
2111
+ if (error) next[name] = error;
2112
+ else delete next[name];
2113
+ return next;
2114
+ });
2115
+ }, []);
2116
+ const validateField = (0, import_react13.useCallback)(async (name, override) => {
2117
+ const registered = override ?? fieldsRef.current.get(name);
2118
+ const allValues = mergedValues();
2119
+ const label = registered?.label ?? name ?? t("validation.defaultLabel");
2120
+ const rules = [
2121
+ ...schema?.[name] ?? [],
2122
+ ...registered?.rules ?? []
2123
+ ];
2124
+ const issue2 = await validateValue(registered?.value ?? allValues[name], rules, { name, label, values: allValues });
2125
+ const error = formatIssue(issue2, label, t);
2126
+ setFieldError(name, error);
2127
+ return error;
2128
+ }, [mergedValues, schema, setFieldError, t]);
2129
+ const clearErrors = (0, import_react13.useCallback)(() => setErrors({}), []);
2130
+ const handleSubmit = async (event) => {
2131
+ event.preventDefault();
2132
+ setSubmitted(true);
2133
+ const allValues = mergedValues();
2134
+ const names = /* @__PURE__ */ new Set([...Object.keys(schema ?? {}), ...fieldsRef.current.keys()]);
2135
+ const nextErrors = {};
2136
+ for (const name of names) {
2137
+ const registered = fieldsRef.current.get(name);
2138
+ const label = registered?.label ?? name ?? t("validation.defaultLabel");
2139
+ const rules = [...schema?.[name] ?? [], ...registered?.rules ?? []];
2140
+ const issue2 = await validateValue(registered?.value ?? allValues[name], rules, { name, label, values: allValues });
2141
+ const error = formatIssue(issue2, label, t);
2142
+ if (error) nextErrors[name] = error;
2143
+ }
2144
+ setErrors(nextErrors);
2145
+ if (Object.keys(nextErrors).length > 0) {
2146
+ onInvalid?.(nextErrors, allValues);
2147
+ return;
2148
+ }
2149
+ await onSubmit?.(allValues);
2150
+ };
2151
+ const context = (0, import_react13.useMemo)(() => ({
2152
+ values: mergedValues(),
2153
+ errors,
2154
+ schema,
2155
+ validateOn: modes,
2156
+ submitted,
2157
+ register,
2158
+ unregister,
2159
+ validateField,
2160
+ setFieldError,
2161
+ clearErrors
2162
+ }), [clearErrors, errors, mergedValues, modes, register, schema, setFieldError, submitted, unregister, validateField]);
2163
+ const renderProps = {
2164
+ errors,
2165
+ isValid: Object.keys(errors).length === 0,
2166
+ clearErrors
2167
+ };
2168
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(FormContext.Provider, { value: context, children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("form", { ...props, noValidate: true, onSubmit: handleSubmit, className, "data-ds-component": "form", children: typeof children === "function" ? children(renderProps) : children }) });
2169
+ }
2170
+ function useDFormField({ name, value, label, rules = [], validateOn }) {
2171
+ const form = (0, import_react13.useContext)(FormContext);
2172
+ const { t } = useDLocalization();
2173
+ const [localError, setLocalError] = (0, import_react13.useState)(void 0);
2174
+ const mountedRef = (0, import_react13.useRef)(false);
2175
+ const localModes = (0, import_react13.useMemo)(() => normalizeValidateOn(validateOn), [validateOn]);
2176
+ const modes = validateOn ? localModes : form?.validateOn ?? localModes;
2177
+ const resolvedLabel = label ?? name ?? t("validation.defaultLabel");
2178
+ (0, import_react13.useEffect)(() => {
2179
+ form?.register(name, { value, rules, label: resolvedLabel });
2180
+ return () => form?.unregister(name);
2181
+ }, [form, name, resolvedLabel, rules, value]);
2182
+ const validate = (0, import_react13.useCallback)(async () => {
2183
+ if (form) return form.validateField(name, { value, rules, label: resolvedLabel });
2184
+ const issue2 = await validateValue(value, rules, { name, label: resolvedLabel, values: { [name]: value } });
2185
+ const error2 = formatIssue(issue2, resolvedLabel, t);
2186
+ setLocalError(error2);
2187
+ return error2;
2188
+ }, [form, name, resolvedLabel, rules, t, value]);
2189
+ (0, import_react13.useEffect)(() => {
2190
+ if (!mountedRef.current) {
2191
+ mountedRef.current = true;
2192
+ return;
2193
+ }
2194
+ if (modes.includes("change")) void validate();
2195
+ }, [form, modes, validate, value]);
2196
+ const clearError = (0, import_react13.useCallback)(() => {
2197
+ if (form) form.setFieldError(name, void 0);
2198
+ else setLocalError(void 0);
2199
+ }, [form, name]);
2200
+ const error = form?.errors[name] ?? localError;
2201
+ return {
2202
+ error,
2203
+ invalid: Boolean(error),
2204
+ onBlur: () => {
2205
+ if (modes.includes("blur")) void validate();
2206
+ },
2207
+ validate,
2208
+ clearError
2209
+ };
2210
+ }
2211
+ function DFormField({ children, ...options }) {
2212
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_jsx_runtime19.Fragment, { children: children(useDFormField(options)) });
2213
+ }
2214
+ function DValidationMessage({ error, className }) {
2215
+ return error ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("p", { role: "alert", className: cn("mt-1.5 text-xs text-[var(--color-danger)]", className), children: error }) : null;
2216
+ }
2217
+
2218
+ // src/info-note/info-note.tsx
2219
+ var import_jsx_runtime20 = require("react/jsx-runtime");
2220
+ function Icon({ type }) {
2221
+ if (type === "warning" || type === "danger") return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", className: "size-4", children: [
2222
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("path", { d: "M12 3 2 21h20L12 3Z" }),
2223
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("path", { d: "M12 9v4M12 17h.01" })
2224
+ ] });
2225
+ if (type === "success") return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", className: "size-4", children: [
2226
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("circle", { cx: "12", cy: "12", r: "9" }),
2227
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("path", { d: "m8 12 3 3 5-6" })
2228
+ ] });
2229
+ if (type === "tip") return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", className: "size-4", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("path", { d: "M9 18h6M10 22h4M8.5 14.5A7 7 0 1 1 15.5 14.5C14.5 15.5 14 16 14 18h-4c0-2-.5-2.5-1.5-3.5Z" }) });
2230
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", className: "size-4", children: [
2231
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("circle", { cx: "12", cy: "12", r: "9" }),
2232
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("path", { d: "M12 10v6M12 7h.01" })
2233
+ ] });
2234
+ }
2235
+ var variants2 = {
2236
+ neutral: { wrap: "border-[var(--color-border)] bg-[var(--color-surface-muted)]/60", icon: "bg-[var(--color-text)]/7 text-[var(--color-text-muted)]", title: "text-[var(--color-text)]" },
2237
+ info: { wrap: "border-[var(--color-info)]/20 bg-[var(--color-info)]/5", icon: "bg-[var(--color-info)]/10 text-[var(--color-info)]", title: "text-[var(--color-info)]" },
2238
+ warning: { wrap: "border-[var(--color-warning)]/20 bg-[var(--color-warning)]/5", icon: "bg-[var(--color-warning)]/10 text-[var(--color-warning)]", title: "text-[var(--color-warning)]" },
2239
+ success: { wrap: "border-[var(--color-success)]/20 bg-[var(--color-success)]/5", icon: "bg-[var(--color-success)]/10 text-[var(--color-success)]", title: "text-[var(--color-success)]" },
2240
+ danger: { wrap: "border-[var(--color-danger)]/20 bg-[var(--color-danger)]/5", icon: "bg-[var(--color-danger)]/10 text-[var(--color-danger)]", title: "text-[var(--color-danger)]" },
2241
+ tip: { wrap: "border-[var(--color-brand)]/15 bg-[var(--color-surface-muted)]", icon: "bg-[var(--color-brand)]/10 text-[var(--color-brand)]", title: "text-[var(--color-text)]" }
2242
+ };
2243
+ function DInfoNote({ variant = "info", title, icon, children, className }) {
2244
+ const meta = variants2[variant];
2245
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { role: "note", className: cn("flex items-start gap-3 rounded-2xl border p-3.5", meta.wrap, className), children: [
2246
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: cn("flex size-8 shrink-0 items-center justify-center rounded-lg", meta.icon), children: icon ?? /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Icon, { type: variant }) }),
2247
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "min-w-0 flex-1 space-y-0.5", children: [
2248
+ title ? /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("p", { className: cn("text-xs font-semibold", meta.title), children: title }) : null,
2249
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "text-xs leading-relaxed text-[var(--color-text)]/80", children })
2250
+ ] })
2251
+ ] });
2252
+ }
2253
+
2254
+ // src/input/input.tsx
2255
+ var import_react14 = require("react");
2256
+ var import_jsx_runtime21 = require("react/jsx-runtime");
2257
+ function ClearIcon4({ className }) {
2258
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", className, children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("path", { d: "m18 6-12 12M6 6l12 12" }) });
2259
+ }
2260
+ function EyeIcon({ closed, className }) {
2261
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", className, children: [
2262
+ closed ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("path", { d: "m3 3 18 18" }) : null,
2263
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("path", { d: "M2 12s3.5-6 10-6 10 6 10 6-3.5 6-10 6S2 12 2 12Z" }),
2264
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("circle", { cx: "12", cy: "12", r: "2.5" })
2265
+ ] });
2266
+ }
2267
+ function InfoIcon({ className }) {
2268
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", className, children: [
2269
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("circle", { cx: "12", cy: "12", r: "9" }),
2270
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("path", { d: "M12 10v6M12 7h.01" })
2271
+ ] });
2272
+ }
2273
+ function assignRef(ref, value) {
2274
+ if (typeof ref === "function") ref(value);
2275
+ else if (ref) ref.current = value;
2276
+ }
2277
+ function formatLegacyCurrency(value) {
2278
+ const raw = String(value).replace(/\D/g, "");
2279
+ if (!raw || Number(raw) === 0) return "";
2280
+ return raw.replace(/\B(?=(\d{3})+(?!\d))/g, ".");
2281
+ }
2282
+ function eventWithValue(value) {
2283
+ return { target: { value }, currentTarget: { value } };
2284
+ }
2285
+ function countDigitsAfterCaret(value, caret) {
2286
+ if (caret === null) return 0;
2287
+ return value.slice(caret).replace(/\D/g, "").length;
2288
+ }
2289
+ function caretFromDigitsAfter(value, digitsAfter) {
2290
+ if (digitsAfter <= 0) return value.length;
2291
+ let remaining = digitsAfter;
2292
+ for (let index = value.length - 1; index >= 0; index -= 1) {
2293
+ if (/\d/.test(value[index] ?? "")) remaining -= 1;
2294
+ if (remaining === 0) return index;
2295
+ }
2296
+ return 0;
2297
+ }
2298
+ var DInput = (0, import_react14.forwardRef)(function DInput2({
2299
+ label,
2300
+ labelInfo,
2301
+ error,
2302
+ hint,
2303
+ type = "text",
2304
+ clearable = true,
2305
+ size = "md",
2306
+ onClear,
2307
+ onChange,
2308
+ onNativeChange,
2309
+ leftIcon,
2310
+ rightIcon,
2311
+ leftAdornment,
2312
+ rightAdornment,
2313
+ prefix,
2314
+ suffix,
2315
+ format = "plain",
2316
+ loading = false,
2317
+ containerClassName,
2318
+ className,
2319
+ value,
2320
+ defaultValue,
2321
+ disabled,
2322
+ readOnly,
2323
+ id: externalId,
2324
+ ...props
2325
+ }, forwardedRef) {
2326
+ const { t } = useDLocalization();
2327
+ const autoId = (0, import_react14.useId)();
2328
+ const id = externalId ?? autoId;
2329
+ const inputRef = (0, import_react14.useRef)(null);
2330
+ const pendingCaretDigitsAfterRef = (0, import_react14.useRef)(null);
2331
+ const [showPassword, setShowPassword] = (0, import_react14.useState)(false);
2332
+ const [showTooltip, setShowTooltip] = (0, import_react14.useState)(false);
2333
+ const [internalValue, setInternalValue] = (0, import_react14.useState)(() => defaultValue == null ? "" : String(defaultValue));
2334
+ const tooltipRef = (0, import_react14.useRef)(null);
2335
+ const s = INPUT_SIZE_STYLES[size];
2336
+ const isControlled = value !== void 0;
2337
+ const currentValue = isControlled ? value : internalValue;
2338
+ const inputType = type === "password" && showPassword ? "text" : type === "number" ? "text" : type;
2339
+ const isZero = (type === "number" || format === "currency") && currentValue !== "" && currentValue != null && Number(currentValue) === 0;
2340
+ const hasValue = currentValue !== void 0 && currentValue !== null && currentValue !== "" && !isZero;
2341
+ const showClear = clearable && hasValue && !disabled && !readOnly && !loading;
2342
+ const leadingIcon = leftAdornment ?? leftIcon;
2343
+ const trailingIcon = rightAdornment ?? rightIcon;
2344
+ const resolvedPrefix = prefix ?? (format === "currency" ? "Rp" : void 0);
2345
+ const resolvedSuffix = suffix ?? (format === "percentage" ? "%" : void 0);
2346
+ const hasLeading = Boolean(leadingIcon || resolvedPrefix);
2347
+ const hasTrailing = Boolean(trailingIcon || resolvedSuffix || showClear || type === "password" || loading);
2348
+ (0, import_react14.useEffect)(() => {
2349
+ const handleClickOutside = (event) => {
2350
+ if (!tooltipRef.current?.contains(event.target)) setShowTooltip(false);
2351
+ };
2352
+ document.addEventListener("mousedown", handleClickOutside);
2353
+ return () => document.removeEventListener("mousedown", handleClickOutside);
2354
+ }, []);
2355
+ const displayValue = (() => {
2356
+ if (currentValue === void 0 || currentValue === null) return "";
2357
+ if (type === "number" && (currentValue === 0 || currentValue === "0")) return "";
2358
+ if (format === "currency") return formatLegacyCurrency(currentValue);
2359
+ return String(currentValue);
2360
+ })();
2361
+ (0, import_react14.useLayoutEffect)(() => {
2362
+ const pending = pendingCaretDigitsAfterRef.current;
2363
+ const input = inputRef.current;
2364
+ if (pending === null || !input || document.activeElement !== input) return;
2365
+ const nextCaret = caretFromDigitsAfter(input.value, pending);
2366
+ input.setSelectionRange(nextCaret, nextCaret);
2367
+ pendingCaretDigitsAfterRef.current = null;
2368
+ }, [displayValue]);
2369
+ const handleChange = (event) => {
2370
+ let next = event.target.value;
2371
+ if (format === "currency") {
2372
+ pendingCaretDigitsAfterRef.current = countDigitsAfterCaret(event.target.value, event.target.selectionStart);
2373
+ next = next.replace(/\D/g, "");
2374
+ } else if (format !== "plain") {
2375
+ next = next.replace(/[^0-9.,-]/g, "");
2376
+ }
2377
+ if (!isControlled) setInternalValue(next);
2378
+ onChange?.(next, event);
2379
+ onNativeChange?.(event);
2380
+ };
2381
+ const handleClear = () => {
2382
+ const event = eventWithValue("");
2383
+ if (!isControlled) setInternalValue("");
2384
+ onClear?.();
2385
+ onChange?.("", event);
2386
+ onNativeChange?.(event);
2387
+ pendingCaretDigitsAfterRef.current = null;
2388
+ inputRef.current?.focus();
2389
+ };
2390
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { "data-ds-component": "input", className: cn("flex min-w-0 flex-col gap-1.5", containerClassName), children: [
2391
+ label ? /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "flex w-fit items-center gap-1.5", children: [
2392
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("label", { htmlFor: id, className: cn(s.label, "font-medium text-[var(--color-text)]"), children: label }),
2393
+ labelInfo ? /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { ref: tooltipRef, className: "group relative flex items-center", children: [
2394
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("button", { type: "button", "aria-label": t("input.fieldInfo"), "aria-expanded": showTooltip, onClick: () => setShowTooltip((v) => !v), className: "text-[var(--color-text-muted)] hover:text-[var(--color-text)]", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(InfoIcon, { className: "size-3.5" }) }),
2395
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { role: "tooltip", className: cn("invisible absolute bottom-full left-1/2 z-50 mb-2 w-max max-w-[220px] -translate-x-1/2 opacity-0 transition-all duration-150 group-hover:visible group-hover:opacity-100", showTooltip && "visible opacity-100"), children: /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "relative rounded-lg bg-[var(--color-tooltip)] px-3 py-2 text-xs text-white shadow-lg", children: [
2396
+ labelInfo,
2397
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "absolute left-1/2 top-full size-0 -translate-x-1/2 border-x-4 border-x-transparent border-t-4 border-t-[var(--color-tooltip)]" })
2398
+ ] }) })
2399
+ ] }) : null
2400
+ ] }) : null,
2401
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "relative flex min-w-0 items-center", children: [
2402
+ leadingIcon ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { className: cn("pointer-events-none absolute top-1/2 z-10 -translate-y-1/2 text-[var(--color-text-muted)]", size === "sm" ? "left-2.5 [&_svg]:size-3.5" : "left-3 [&_svg]:size-4"), children: leadingIcon }) : null,
2403
+ resolvedPrefix ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { className: cn("pointer-events-none absolute left-3 top-1/2 z-10 -translate-y-1/2 font-medium text-[var(--color-text-muted)]", size === "sm" ? "text-xs" : "text-sm"), children: resolvedPrefix }) : null,
2404
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
2405
+ "input",
2406
+ {
2407
+ ...props,
2408
+ ref: (node) => {
2409
+ inputRef.current = node;
2410
+ assignRef(forwardedRef, node);
2411
+ },
2412
+ id,
2413
+ autoComplete: props.autoComplete ?? "off",
2414
+ type: inputType,
2415
+ inputMode: props.inputMode ?? (type === "number" || format !== "plain" ? "numeric" : void 0),
2416
+ value: displayValue,
2417
+ onChange: handleChange,
2418
+ disabled: disabled || loading,
2419
+ readOnly,
2420
+ "aria-invalid": Boolean(error) || void 0,
2421
+ "aria-busy": loading || void 0,
2422
+ className: cn(
2423
+ "w-full min-w-0 rounded-[var(--radius-control)] border bg-[var(--color-surface)] text-[var(--color-text)] transition-colors duration-150 placeholder:text-[var(--color-text-muted)]/60 focus:border-[var(--color-brand)] focus:outline-none focus:ring-2 focus:ring-[var(--color-brand)]/20 disabled:cursor-not-allowed disabled:bg-[var(--color-surface-muted)] disabled:opacity-50 read-only:bg-[var(--color-surface-muted)]",
2424
+ s.input,
2425
+ error ? "border-[var(--color-danger)] focus:border-[var(--color-danger)] focus:ring-[var(--color-danger)]/20" : "border-[var(--color-border)]",
2426
+ hasLeading && (size === "sm" ? "pl-8" : "pl-10"),
2427
+ hasTrailing && (size === "sm" ? "pr-8" : "pr-10"),
2428
+ className
2429
+ )
2430
+ }
2431
+ ),
2432
+ resolvedSuffix ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { className: cn("pointer-events-none absolute top-1/2 -translate-y-1/2 font-medium text-[var(--color-text-muted)]", size === "sm" ? "right-2.5 text-xs" : "right-3 text-sm"), children: resolvedSuffix }) : null,
2433
+ showClear || type === "password" || trailingIcon || loading ? /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: cn("absolute top-1/2 flex -translate-y-1/2 items-center text-[var(--color-text-muted)]", size === "sm" ? "right-1.5 gap-0.5" : "right-2 gap-1", resolvedSuffix && "pointer-events-none opacity-0"), children: [
2434
+ loading ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { "aria-label": t("input.loading"), className: "size-4 animate-spin rounded-full border-2 border-current border-t-transparent" }) : null,
2435
+ !loading && showClear ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("button", { type: "button", tabIndex: -1, "aria-label": t("input.clear"), onMouseDown: (event) => event.preventDefault(), onClick: handleClear, className: cn("rounded-md hover:bg-[var(--color-surface-muted)] hover:text-[var(--color-text)]", size === "sm" ? "p-0.5" : "p-1"), children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(ClearIcon4, { className: size === "sm" ? "size-3" : "size-3.5" }) }) : null,
2436
+ !loading && type === "password" ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("button", { type: "button", tabIndex: -1, "aria-label": showPassword ? t("input.hidePassword") : t("input.showPassword"), onMouseDown: (event) => event.preventDefault(), onClick: () => setShowPassword((v) => !v), className: cn("rounded-md hover:bg-[var(--color-surface-muted)] hover:text-[var(--color-text)]", size === "sm" ? "p-0.5" : "p-1"), children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(EyeIcon, { closed: showPassword, className: size === "sm" ? "size-3" : "size-3.5" }) }) : null,
2437
+ !loading && trailingIcon ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { className: "flex items-center", children: trailingIcon }) : null
2438
+ ] }) : null
2439
+ ] }),
2440
+ error ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("p", { className: "text-xs text-[var(--color-danger)]", children: error }) : null,
2441
+ !error && hint ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("p", { className: "text-xs text-[var(--color-text-muted)]", children: hint }) : null
2442
+ ] });
2443
+ });
2444
+ DInput.displayName = "DInput";
2445
+ function normalizeDecimalInput(input, { scale = 4, integer: integer2 = false } = {}) {
2446
+ const decimalIndex = Math.max(input.lastIndexOf("."), input.lastIndexOf(","));
2447
+ const hasDecimal = !integer2 && decimalIndex >= 0;
2448
+ const rawWhole = (hasDecimal ? input.slice(0, decimalIndex) : input).replace(/\D/g, "");
2449
+ const rawFraction = hasDecimal ? input.slice(decimalIndex + 1).replace(/\D/g, "") : "";
2450
+ const whole = rawWhole.replace(/^0+(?=\d)/, "");
2451
+ if (!hasDecimal) return whole;
2452
+ return `${whole || "0"}.${rawFraction.slice(0, Math.max(0, scale))}`;
2453
+ }
2454
+ var DDecimalInput = (0, import_react14.forwardRef)(function DDecimalInput2({ value, onValueChange, scale = 4, integer: integer2 = false, ...props }, ref) {
2455
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(DInput, { ref, ...props, value, type: "text", inputMode: integer2 ? "numeric" : "decimal", onNativeChange: (event) => onValueChange(normalizeDecimalInput(event.target.value, { scale, integer: integer2 })) });
2456
+ });
2457
+ function formatCurrencyInputValue(value, { groupSeparator = ".", decimalSeparator = "," } = {}) {
2458
+ if (!value) return "";
2459
+ const normalized = normalizeDecimalInput(value);
2460
+ const [whole = "", fraction] = normalized.split(".");
2461
+ const grouped = (whole || "0").replace(/\B(?=(\d{3})+(?!\d))/g, groupSeparator);
2462
+ return fraction === void 0 ? grouped : `${grouped}${decimalSeparator}${fraction}`;
2463
+ }
2464
+ function parseCurrencyInputValue(value, { groupSeparator = ".", decimalSeparator = "," } = {}) {
2465
+ const normalized = String(value).trim();
2466
+ if (!normalized) return "";
2467
+ const decimalIndex = normalized.lastIndexOf(decimalSeparator);
2468
+ const hasDecimal = decimalIndex >= 0;
2469
+ const wholeSource = hasDecimal ? normalized.slice(0, decimalIndex) : normalized;
2470
+ const fractionSource = hasDecimal ? normalized.slice(decimalIndex + decimalSeparator.length) : "";
2471
+ const whole = wholeSource.split(groupSeparator).join("").replace(/\D/g, "").replace(/^0+(?=\d)/, "");
2472
+ const fraction = fractionSource.replace(/\D/g, "");
2473
+ if (!hasDecimal) return whole;
2474
+ return `${whole || "0"}.${fraction}`;
2475
+ }
2476
+ var DCurrencyInput = (0, import_react14.forwardRef)(function DCurrencyInput2({
2477
+ value,
2478
+ onValueChange,
2479
+ currencySymbol = "Rp",
2480
+ groupSeparator = ".",
2481
+ decimalSeparator = ",",
2482
+ ...props
2483
+ }, forwardedRef) {
2484
+ const inputRef = (0, import_react14.useRef)(null);
2485
+ const pendingCaretDigitsAfterRef = (0, import_react14.useRef)(null);
2486
+ const displayed = formatCurrencyInputValue(value, { groupSeparator, decimalSeparator });
2487
+ (0, import_react14.useLayoutEffect)(() => {
2488
+ const pending = pendingCaretDigitsAfterRef.current;
2489
+ const input = inputRef.current;
2490
+ if (pending === null || !input || document.activeElement !== input) return;
2491
+ const nextCaret = caretFromDigitsAfter(input.value, pending);
2492
+ input.setSelectionRange(nextCaret, nextCaret);
2493
+ pendingCaretDigitsAfterRef.current = null;
2494
+ }, [displayed]);
2495
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
2496
+ DInput,
2497
+ {
2498
+ ref: (node) => {
2499
+ inputRef.current = node;
2500
+ assignRef(forwardedRef, node);
2501
+ },
2502
+ ...props,
2503
+ value: displayed,
2504
+ type: "text",
2505
+ inputMode: "decimal",
2506
+ prefix: currencySymbol,
2507
+ onNativeChange: (event) => {
2508
+ pendingCaretDigitsAfterRef.current = countDigitsAfterCaret(event.target.value, event.target.selectionStart);
2509
+ onValueChange(parseCurrencyInputValue(event.target.value, { groupSeparator, decimalSeparator }));
2510
+ }
2511
+ }
2512
+ );
2513
+ });
2514
+
2515
+ // src/loading/loading.tsx
2516
+ var import_jsx_runtime22 = require("react/jsx-runtime");
2517
+ function DLoadingIndicator({ label, className }) {
2518
+ const { t } = useDLocalization();
2519
+ return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { role: "status", className: cn("inline-flex items-center gap-2 text-sm text-[var(--color-text-muted)]", className), children: [
2520
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { className: "size-4 animate-spin rounded-full border-2 border-[var(--color-brand)] border-t-transparent" }),
2521
+ label ?? t("loading.default")
2522
+ ] });
2523
+ }
2524
+ function DLoadingOverlay({ label }) {
2525
+ return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: "fixed inset-0 z-[90] grid place-items-center bg-[var(--color-background)]/75 backdrop-blur-sm", children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DLoadingIndicator, { label }) });
2526
+ }
2527
+
2528
+ // src/notification-panel/notification-panel.tsx
2529
+ var import_react15 = require("react");
2530
+ var import_react_dom3 = require("react-dom");
2531
+ var import_jsx_runtime23 = require("react/jsx-runtime");
2532
+ var dotClass = {
2533
+ info: "bg-[var(--color-info)]",
2534
+ success: "bg-[var(--color-success)]",
2535
+ warning: "bg-[var(--color-warning)]",
2536
+ error: "bg-[var(--color-danger)]"
2537
+ };
2538
+ var iconButtonClass = "grid size-8 appearance-none place-items-center rounded-lg border-0 bg-transparent p-0 text-[var(--color-text-muted)] shadow-none outline-none transition-colors hover:bg-[var(--color-surface-muted)] hover:text-[var(--color-text)] focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--color-focus)]/25";
2539
+ function DNotificationPanel({
2540
+ notifications,
2541
+ open,
2542
+ onClose,
2543
+ onMarkRead,
2544
+ onMarkAllRead,
2545
+ onDismiss,
2546
+ anchorRef,
2547
+ title,
2548
+ emptyMessage,
2549
+ className,
2550
+ offset = 8,
2551
+ scrollBehavior = "reposition"
2552
+ }) {
2553
+ const { t } = useDLocalization();
2554
+ const resolvedTitle = title ?? t("notification.title");
2555
+ const resolvedEmptyMessage = emptyMessage ?? t("notification.empty");
2556
+ const floatingRef = (0, import_react15.useRef)(null);
2557
+ const emptyReference = (0, import_react15.useRef)(null);
2558
+ const referenceRef = anchorRef ?? emptyReference;
2559
+ const hasAnchor = Boolean(anchorRef);
2560
+ const { style, positioned } = useFloatingPosition({
2561
+ open: open && hasAnchor,
2562
+ referenceRef,
2563
+ floatingRef,
2564
+ placement: "bottom-end",
2565
+ matchWidth: false,
2566
+ minWidth: 320,
2567
+ offset,
2568
+ scrollBehavior,
2569
+ onRequestClose: onClose
2570
+ });
2571
+ (0, import_react15.useEffect)(() => {
2572
+ if (!open) return;
2573
+ const onPointerDown = (event) => {
2574
+ const target = event.target;
2575
+ if (floatingRef.current?.contains(target) || anchorRef?.current?.contains(target)) return;
2576
+ onClose();
2577
+ };
2578
+ const onKeyDown = (event) => {
2579
+ if (event.key === "Escape") {
2580
+ event.preventDefault();
2581
+ onClose();
2582
+ }
2583
+ };
2584
+ document.addEventListener("mousedown", onPointerDown);
2585
+ document.addEventListener("keydown", onKeyDown);
2586
+ return () => {
2587
+ document.removeEventListener("mousedown", onPointerDown);
2588
+ document.removeEventListener("keydown", onKeyDown);
2589
+ };
2590
+ }, [anchorRef, onClose, open]);
2591
+ if (!open || typeof document === "undefined") return null;
2592
+ const unread = notifications.filter((item) => !item.read).length;
2593
+ const fallbackStyle = { position: "fixed", top: 72, right: 24, zIndex: 9999, visibility: "visible" };
2594
+ return (0, import_react_dom3.createPortal)(
2595
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
2596
+ "div",
2597
+ {
2598
+ ref: floatingRef,
2599
+ role: "dialog",
2600
+ "aria-label": resolvedTitle,
2601
+ "data-ds-component": "notification-panel",
2602
+ "data-ds-surface": "floating",
2603
+ "data-positioned": hasAnchor ? positioned ? "true" : "false" : "fallback",
2604
+ "data-scroll-behavior": scrollBehavior,
2605
+ style: hasAnchor ? style : fallbackStyle,
2606
+ className: cn(
2607
+ "w-[min(24rem,calc(100vw-16px))] overflow-hidden rounded-[var(--radius-panel)] border border-[var(--color-border)] bg-[var(--color-surface)] shadow-[var(--shadow-lg)]",
2608
+ hasAnchor && positioned && "animate-[dropdown-in_150ms_ease-out]",
2609
+ className
2610
+ ),
2611
+ children: [
2612
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "flex min-h-12 items-center justify-between border-b border-[var(--color-border)] px-4 py-2", children: [
2613
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "flex min-w-0 items-center gap-2", children: [
2614
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: "truncate text-sm font-semibold text-[var(--color-text)]", children: resolvedTitle }),
2615
+ unread > 0 ? /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: "flex h-5 min-w-5 items-center justify-center rounded-full bg-[var(--color-brand)] px-1.5 text-[10px] font-bold text-[var(--color-brand-foreground)]", children: unread }) : null
2616
+ ] }),
2617
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "flex shrink-0 items-center gap-0.5", children: [
2618
+ unread > 0 ? /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("button", { type: "button", "aria-label": t("notification.markAllRead"), onClick: onMarkAllRead, className: iconButtonClass, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(CheckIcon, { size: 15 }) }) : null,
2619
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("button", { type: "button", "aria-label": t("notification.close"), onClick: onClose, className: iconButtonClass, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(XIcon, { size: 15 }) })
2620
+ ] })
2621
+ ] }),
2622
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: "flex max-h-[min(24rem,60vh)] flex-col gap-1.5 overflow-y-auto p-2", children: notifications.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: "px-4 py-10 text-center text-sm text-[var(--color-text-muted)]", children: resolvedEmptyMessage }) : notifications.map((item) => /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
2623
+ "div",
2624
+ {
2625
+ className: cn(
2626
+ "group flex items-start gap-1 rounded-[var(--radius-menu-item)] px-1 py-0.5 transition-colors hover:bg-[var(--color-surface-muted)]/65",
2627
+ !item.read && "bg-[var(--color-brand)]/5"
2628
+ ),
2629
+ children: [
2630
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
2631
+ "button",
2632
+ {
2633
+ type: "button",
2634
+ onClick: () => onMarkRead(item.id),
2635
+ className: "flex min-w-0 flex-1 appearance-none items-start gap-3 rounded-[var(--radius-menu-item)] border-0 bg-transparent px-2 py-2 text-left shadow-none outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--color-focus)]/25",
2636
+ children: [
2637
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: cn("mt-1.5 size-2 shrink-0 rounded-full", !item.read ? dotClass[item.type] : "bg-transparent") }),
2638
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("span", { className: "min-w-0 flex-1", children: [
2639
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: "block truncate text-sm font-medium text-[var(--color-text)]", children: item.title }),
2640
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: "mt-0.5 line-clamp-2 block text-xs leading-5 text-[var(--color-text-muted)]", children: item.message }),
2641
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: "mt-1 block text-[10px] text-[var(--color-text-muted)]/70", children: item.createdAt })
2642
+ ] })
2643
+ ]
2644
+ }
2645
+ ),
2646
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
2647
+ "button",
2648
+ {
2649
+ type: "button",
2650
+ "aria-label": t("notification.dismiss", { title: item.title }),
2651
+ onClick: () => onDismiss(item.id),
2652
+ className: "mt-1 grid size-7 shrink-0 appearance-none place-items-center rounded-md border-0 bg-transparent p-0 text-[var(--color-text-muted)]/55 opacity-65 shadow-none outline-none transition-colors hover:bg-[var(--color-surface-muted)] hover:text-[var(--color-text)] focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--color-focus)]/25 group-hover:opacity-100",
2653
+ children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(XIcon, { size: 13 })
2654
+ }
2655
+ )
2656
+ ]
2657
+ },
2658
+ item.id
2659
+ )) })
2660
+ ]
2661
+ }
2662
+ ),
2663
+ document.body
2664
+ );
2665
+ }
2666
+
2667
+ // src/progress/progress.tsx
2668
+ var import_jsx_runtime24 = require("react/jsx-runtime");
2669
+ function clampProgress(value) {
2670
+ return Math.min(100, Math.max(0, value));
2671
+ }
2672
+ function DProgress({ value, label, className, ...props }) {
2673
+ const isIndeterminate = value === void 0;
2674
+ const percentage = isIndeterminate ? void 0 : clampProgress(value);
2675
+ return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
2676
+ "div",
2677
+ {
2678
+ role: "progressbar",
2679
+ "aria-label": label,
2680
+ "aria-valuemin": isIndeterminate ? void 0 : 0,
2681
+ "aria-valuemax": isIndeterminate ? void 0 : 100,
2682
+ "aria-valuenow": percentage,
2683
+ className: cn(
2684
+ "relative h-2 w-full overflow-hidden rounded-full bg-[var(--color-surface-muted)]",
2685
+ className
2686
+ ),
2687
+ ...props,
2688
+ children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
2689
+ "span",
2690
+ {
2691
+ className: cn(
2692
+ "block h-full rounded-full bg-[var(--color-brand)] transition-[width] duration-200",
2693
+ isIndeterminate && "w-2/5 animate-[boot-progress_1.2s_ease-in-out_infinite]"
2694
+ ),
2695
+ style: isIndeterminate ? void 0 : { width: `${percentage}%` }
2696
+ }
2697
+ )
2698
+ }
2699
+ );
2700
+ }
2701
+
2702
+ // src/range-date-picker/range-date-picker.tsx
2703
+ var import_react16 = require("react");
2704
+ var import_jsx_runtime25 = require("react/jsx-runtime");
2705
+ var formatDate = (date2) => `${date2.getFullYear()}-${String(date2.getMonth() + 1).padStart(2, "0")}-${String(date2.getDate()).padStart(2, "0")}`;
2706
+ var parseDate2 = (value) => value ? /* @__PURE__ */ new Date(`${value}T00:00:00`) : null;
2707
+ var startOfMonth = (date2) => new Date(date2.getFullYear(), date2.getMonth(), 1);
2708
+ var addMonth = (date2, amount) => new Date(date2.getFullYear(), date2.getMonth() + amount, 1);
2709
+ var isSameDate = (a, b) => Boolean(a && b && formatDate(a) === formatDate(b));
2710
+ var getStartOfWeek = (date2) => {
2711
+ const result = new Date(date2);
2712
+ const day = result.getDay();
2713
+ result.setDate(result.getDate() + (day === 0 ? -6 : 1 - day));
2714
+ result.setHours(0, 0, 0, 0);
2715
+ return result;
2716
+ };
2717
+ var getEndOfWeek = (date2) => {
2718
+ const result = getStartOfWeek(date2);
2719
+ result.setDate(result.getDate() + 6);
2720
+ return result;
2721
+ };
2722
+ var getStartOfMonth = (date2) => new Date(date2.getFullYear(), date2.getMonth(), 1);
2723
+ var getEndOfMonth = (date2) => new Date(date2.getFullYear(), date2.getMonth() + 1, 0);
2724
+ var getStartOfYear = (date2) => new Date(date2.getFullYear(), 0, 1);
2725
+ var getEndOfYear = (date2) => new Date(date2.getFullYear(), 11, 31);
2726
+ var QUICK_RANGE_TYPES = ["today", "yesterday", "this_week", "last_week", "this_month", "last_month", "this_year", "last_year", "all_time"];
2727
+ var QUICK_RANGE_KEYS = {
2728
+ today: "rangeDatePicker.today",
2729
+ yesterday: "rangeDatePicker.yesterday",
2730
+ this_week: "rangeDatePicker.thisWeek",
2731
+ last_week: "rangeDatePicker.lastWeek",
2732
+ this_month: "rangeDatePicker.thisMonth",
2733
+ last_month: "rangeDatePicker.lastMonth",
2734
+ this_year: "rangeDatePicker.thisYear",
2735
+ last_year: "rangeDatePicker.lastYear",
2736
+ all_time: "rangeDatePicker.allTime"
2737
+ };
2738
+ function quickRange(type) {
2739
+ const now = /* @__PURE__ */ new Date();
2740
+ if (type === "today") return { start: now, end: now };
2741
+ if (type === "yesterday") {
2742
+ const date2 = new Date(now);
2743
+ date2.setDate(date2.getDate() - 1);
2744
+ return { start: date2, end: new Date(date2) };
2745
+ }
2746
+ if (type === "this_week") return { start: getStartOfWeek(now), end: getEndOfWeek(now) };
2747
+ if (type === "last_week") {
2748
+ const date2 = new Date(now);
2749
+ date2.setDate(date2.getDate() - 7);
2750
+ return { start: getStartOfWeek(date2), end: getEndOfWeek(date2) };
2751
+ }
2752
+ if (type === "this_month") return { start: getStartOfMonth(now), end: getEndOfMonth(now) };
2753
+ if (type === "last_month") {
2754
+ const date2 = new Date(now.getFullYear(), now.getMonth() - 1, 1);
2755
+ return { start: getStartOfMonth(date2), end: getEndOfMonth(date2) };
2756
+ }
2757
+ if (type === "this_year") return { start: getStartOfYear(now), end: getEndOfYear(now) };
2758
+ if (type === "last_year") {
2759
+ const date2 = new Date(now.getFullYear() - 1, 0, 1);
2760
+ return { start: getStartOfYear(date2), end: getEndOfYear(date2) };
2761
+ }
2762
+ return { start: null, end: null };
2763
+ }
2764
+ function getQuickActive(type, start, end) {
2765
+ if (type === "all_time") return !start && !end;
2766
+ const target = quickRange(type);
2767
+ return isSameDate(start, target.start) && isSameDate(end, target.end);
2768
+ }
2769
+ function ChevronIcon({ direction }) {
2770
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", className: "size-4", children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("path", { d: direction === "left" ? "m15 18-6-6 6-6" : "m9 18 6-6-6-6" }) });
2771
+ }
2772
+ function CalendarIcon2() {
2773
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", className: "size-4", children: [
2774
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("rect", { x: "3", y: "5", width: "18", height: "16", rx: "2" }),
2775
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("path", { d: "M16 3v4M8 3v4M3 10h18" })
2776
+ ] });
2777
+ }
2778
+ function ChevronDownIcon2({ open }) {
2779
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", className: cn("size-3.5 transition-transform", open && "rotate-180"), children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("path", { d: "m6 9 6 6 6-6" }) });
2780
+ }
2781
+ function ClearIcon5() {
2782
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", className: "size-3.5", children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("path", { d: "m18 6-12 12M6 6l12 12" }) });
2783
+ }
2784
+ function CheckIcon2() {
2785
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", className: "size-3.5", children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("path", { d: "m5 12 4 4L19 6" }) });
2786
+ }
2787
+ function RangeDropdownContent({ value, onChange }) {
2788
+ const close = useDropdownClose();
2789
+ const { locale, t } = useDLocalization();
2790
+ const days = (0, import_react16.useMemo)(() => getLocalizedWeekdayNames(locale, "short"), [locale]);
2791
+ const months = (0, import_react16.useMemo)(() => getLocalizedMonthNames(locale), [locale]);
2792
+ const today = (0, import_react16.useMemo)(() => /* @__PURE__ */ new Date(), []);
2793
+ const selectedStart = (0, import_react16.useMemo)(() => parseDate2(value?.start), [value?.start]);
2794
+ const selectedEnd = (0, import_react16.useMemo)(() => parseDate2(value?.end), [value?.end]);
2795
+ const [tempStart, setTempStart] = (0, import_react16.useState)(selectedStart);
2796
+ const [tempEnd, setTempEnd] = (0, import_react16.useState)(selectedEnd);
2797
+ const [quickType, setQuickType] = (0, import_react16.useState)(null);
2798
+ const [leftMonth, setLeftMonth] = (0, import_react16.useState)(() => startOfMonth(selectedStart || today));
2799
+ const rightMonth = (0, import_react16.useMemo)(() => addMonth(leftMonth, 1), [leftMonth]);
2800
+ const syncTempFromValue = () => {
2801
+ const nextStart = parseDate2(value?.start);
2802
+ const nextEnd = parseDate2(value?.end);
2803
+ setTempStart(nextStart);
2804
+ setTempEnd(nextEnd);
2805
+ setQuickType(null);
2806
+ setLeftMonth(startOfMonth(nextStart || today));
2807
+ };
2808
+ (0, import_react16.useEffect)(() => {
2809
+ syncTempFromValue();
2810
+ }, [value?.start, value?.end]);
2811
+ const selectDate = (date2) => {
2812
+ setQuickType(null);
2813
+ if (!tempStart || tempEnd || date2 < tempStart) {
2814
+ setTempStart(date2);
2815
+ setTempEnd(null);
2816
+ setLeftMonth(startOfMonth(date2));
2817
+ return;
2818
+ }
2819
+ setTempEnd(date2);
2820
+ };
2821
+ const selectQuick = (type) => {
2822
+ const range = quickRange(type);
2823
+ setQuickType(type);
2824
+ setTempStart(range.start);
2825
+ setTempEnd(range.end);
2826
+ setLeftMonth(startOfMonth(range.start || today));
2827
+ };
2828
+ const apply = () => {
2829
+ if (quickType === "all_time") {
2830
+ onChange?.({ start: void 0, end: void 0 });
2831
+ close?.();
2832
+ return;
2833
+ }
2834
+ if (!tempStart || !tempEnd) return;
2835
+ onChange?.({ start: formatDate(tempStart), end: formatDate(tempEnd) });
2836
+ close?.();
2837
+ };
2838
+ const renderCalendar = (monthDate, side) => {
2839
+ const year = monthDate.getFullYear();
2840
+ const month = monthDate.getMonth();
2841
+ const daysInMonth = new Date(year, month + 1, 0).getDate();
2842
+ const firstDay = new Date(year, month, 1).getDay();
2843
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "min-w-0 flex-1", children: [
2844
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "mb-2 flex items-center justify-between", children: [
2845
+ side === "left" ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("button", { type: "button", "aria-label": t("common.previousMonth"), onClick: () => setLeftMonth((prev) => addMonth(prev, -1)), className: "flex size-7 items-center justify-center rounded-lg text-[var(--color-text-muted)] hover:bg-[var(--color-surface-muted)]", children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ChevronIcon, { direction: "left" }) }) : /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "size-7" }),
2846
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("span", { className: "text-xs font-semibold text-[var(--color-text)] sm:text-sm", children: [
2847
+ months[month],
2848
+ " ",
2849
+ year
2850
+ ] }),
2851
+ side === "right" ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("button", { type: "button", "aria-label": t("common.nextMonth"), onClick: () => setLeftMonth((prev) => addMonth(prev, 1)), className: "flex size-7 items-center justify-center rounded-lg text-[var(--color-text-muted)] hover:bg-[var(--color-surface-muted)]", children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ChevronIcon, { direction: "right" }) }) : /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("button", { type: "button", "aria-label": t("common.nextMonth"), onClick: () => setLeftMonth((prev) => addMonth(prev, 1)), className: "flex size-7 items-center justify-center rounded-lg text-[var(--color-text-muted)] hover:bg-[var(--color-surface-muted)] sm:invisible", children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ChevronIcon, { direction: "right" }) })
2852
+ ] }),
2853
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "mb-1.5 grid grid-cols-7 gap-0.5 text-[10px] text-[var(--color-text-muted)] sm:text-xs", children: days.map((day) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "text-center font-medium", children: day }, `${side}-${day}`)) }),
2854
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "grid grid-cols-7 gap-0.5", children: [
2855
+ Array.from({ length: firstDay }).map((_, index) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", {}, `${side}-empty-${index}`)),
2856
+ Array.from({ length: daysInMonth }, (_, index) => {
2857
+ const date2 = new Date(year, month, index + 1);
2858
+ const start = isSameDate(date2, tempStart);
2859
+ const end = isSameDate(date2, tempEnd);
2860
+ const selected = start || end;
2861
+ const inRange = Boolean(tempStart && tempEnd && date2 > tempStart && date2 < tempEnd);
2862
+ const isToday = isSameDate(date2, today);
2863
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("button", { type: "button", onClick: () => selectDate(date2), className: cn("h-8 rounded-md text-xs transition-colors sm:h-8 sm:text-sm", selected && "bg-[var(--color-brand)] font-semibold text-white", !selected && inRange && "bg-[var(--color-brand)]/10 text-[var(--color-brand)]", !selected && !inRange && "hover:bg-[var(--color-surface-muted)]", !selected && isToday && "ring-1 ring-[var(--color-brand)]/40"), children: index + 1 }, `${side}-${formatDate(date2)}`);
2864
+ })
2865
+ ] })
2866
+ ] });
2867
+ };
2868
+ const summary = tempStart && tempEnd ? `${formatDate(tempStart)} \u2014 ${formatDate(tempEnd)}` : quickType === "all_time" ? t("rangeDatePicker.summaryAllTime") : t("rangeDatePicker.summarySelect");
2869
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "w-[min(560px,calc(100vw-16px))] p-3", children: [
2870
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "mb-3", children: [
2871
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "mb-2 flex items-center justify-between", children: [
2872
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("p", { className: "text-xs font-semibold text-[var(--color-text)]", children: t("rangeDatePicker.quickRange") }),
2873
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: "text-[10px] text-[var(--color-text-muted)]", children: t("common.optional") })
2874
+ ] }),
2875
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "grid grid-cols-3 gap-1 sm:grid-cols-5", children: QUICK_RANGE_TYPES.map((type) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("button", { type: "button", onClick: () => selectQuick(type), className: cn("min-h-8 rounded-lg px-2 py-1.5 text-center text-[11px] font-medium leading-tight transition-colors", getQuickActive(type, tempStart, tempEnd) ? "bg-[var(--color-brand)]/10 text-[var(--color-brand)]" : "bg-[var(--color-surface-muted)]/55 text-[var(--color-text-muted)] hover:bg-[var(--color-surface-muted)] hover:text-[var(--color-text)]"), children: t(QUICK_RANGE_KEYS[type]) }, type)) })
2876
+ ] }),
2877
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "grid gap-3 border-t border-[var(--color-border)] pt-3 sm:grid-cols-2", children: [
2878
+ renderCalendar(leftMonth, "left"),
2879
+ renderCalendar(rightMonth, "right")
2880
+ ] }),
2881
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "mt-3 flex flex-col gap-2 border-t border-[var(--color-border)] pt-3 sm:flex-row sm:items-center sm:justify-between", children: [
2882
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "min-w-0 truncate text-[11px] text-[var(--color-text-muted)]", children: summary }),
2883
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "flex shrink-0 items-center justify-end gap-2", children: [
2884
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("button", { type: "button", onClick: () => {
2885
+ syncTempFromValue();
2886
+ close?.();
2887
+ }, className: "h-8 rounded-lg px-3 text-xs font-medium text-[var(--color-text-muted)] hover:bg-[var(--color-surface-muted)]", children: t("common.cancel") }),
2888
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("button", { type: "button", disabled: quickType !== "all_time" && (!tempStart || !tempEnd), onClick: apply, className: "inline-flex h-8 items-center gap-1.5 rounded-lg bg-[var(--color-brand)] px-3 text-xs font-semibold text-white hover:brightness-95 disabled:cursor-not-allowed disabled:opacity-50", children: [
2889
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(CheckIcon2, {}),
2890
+ t("common.apply")
2891
+ ] })
2892
+ ] })
2893
+ ] })
2894
+ ] });
2895
+ }
2896
+ function DRangeDatePicker({ label, placeholder, value, size = "md", onChange, error, hint, disabled = false, clearable = true, containerClassName, scrollBehavior = "close" }) {
2897
+ const id = (0, import_react16.useId)();
2898
+ const { locale, t } = useDLocalization();
2899
+ const months = (0, import_react16.useMemo)(() => getLocalizedMonthNames(locale), [locale]);
2900
+ const s = INPUT_SIZE_STYLES[size];
2901
+ const formatDisplayDate = (raw) => {
2902
+ const date2 = parseDate2(raw);
2903
+ return date2 ? `${date2.getDate()} ${months[date2.getMonth()]} ${date2.getFullYear()}` : "";
2904
+ };
2905
+ const displayValue = (0, import_react16.useMemo)(() => value?.start && value?.end ? `${formatDisplayDate(value.start)} - ${formatDisplayDate(value.end)}` : "", [value?.start, value?.end, months]);
2906
+ const resolvedPlaceholder = placeholder ?? t("rangeDatePicker.placeholder");
2907
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: cn("flex min-w-0 flex-col gap-1.5", containerClassName), children: [
2908
+ label ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("label", { htmlFor: id, className: cn(s.label, "inline-block w-fit font-medium text-[var(--color-text)]"), children: label }) : null,
2909
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(DDropdown, { placement: "bottom-end", contentRole: "dialog", contentPadding: false, contentClassName: "overflow-hidden", scrollBehavior, trigger: ({ open }) => /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "relative", children: [
2910
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("button", { id, type: "button", disabled, "aria-invalid": Boolean(error) || void 0, className: cn("flex w-full items-center gap-2 rounded-lg border bg-[var(--color-surface)] pr-10 text-left focus:border-[var(--color-brand)] focus:outline-none focus:ring-2 focus:ring-[var(--color-brand)]/20 disabled:cursor-not-allowed disabled:bg-[var(--color-surface-muted)] disabled:opacity-50", s.input, error ? "border-[var(--color-danger)]" : "border-[var(--color-border)]", displayValue ? "text-[var(--color-text)]" : "text-[var(--color-text-muted)]/60"), children: [
2911
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: "shrink-0 text-[var(--color-text-muted)]", children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(CalendarIcon2, {}) }),
2912
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: "min-w-0 flex-1 truncate", children: displayValue || resolvedPlaceholder })
2913
+ ] }),
2914
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: cn("absolute top-1/2 flex -translate-y-1/2 items-center gap-1 text-[var(--color-text-muted)]", s.iconRight), children: [
2915
+ clearable && displayValue && !disabled ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("button", { type: "button", "aria-label": t("rangeDatePicker.clear"), onMouseDown: (event) => event.preventDefault(), onClick: (event) => {
2916
+ event.preventDefault();
2917
+ event.stopPropagation();
2918
+ onChange?.({ start: void 0, end: void 0 });
2919
+ }, className: "rounded-md p-1 hover:bg-[var(--color-surface-muted)]", children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ClearIcon5, {}) }) : null,
2920
+ !disabled ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ChevronDownIcon2, { open }) : null
2921
+ ] })
2922
+ ] }), children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(RangeDropdownContent, { value, onChange }) }),
2923
+ error ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("p", { className: "text-xs text-[var(--color-danger)]", children: error }) : null,
2924
+ !error && hint ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("p", { className: "text-xs text-[var(--color-text-muted)]", children: hint }) : null
2925
+ ] });
2926
+ }
2927
+
2928
+ // src/search-input/search-input.tsx
2929
+ var import_react17 = require("react");
2930
+ var import_jsx_runtime26 = require("react/jsx-runtime");
2931
+ function SearchIcon2() {
2932
+ return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", className: "size-4", children: [
2933
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("circle", { cx: "11", cy: "11", r: "7" }),
2934
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("path", { d: "m20 20-4-4" })
2935
+ ] });
2936
+ }
2937
+ function ClearIcon6() {
2938
+ return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", className: "size-3.5", children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("path", { d: "m18 6-12 12M6 6l12 12" }) });
2939
+ }
2940
+ function DSearchInput({
2941
+ value,
2942
+ onChange,
2943
+ placeholder,
2944
+ debounceMs = 300,
2945
+ className,
2946
+ align = "right",
2947
+ expandedWidth = "280px"
2948
+ }) {
2949
+ const { t } = useDLocalization();
2950
+ const resolvedPlaceholder = placeholder ?? t("searchInput.placeholder");
2951
+ const wrapperRef = (0, import_react17.useRef)(null);
2952
+ const desktopInputRef = (0, import_react17.useRef)(null);
2953
+ const debounceRef = (0, import_react17.useRef)(null);
2954
+ const mountedRef = (0, import_react17.useRef)(false);
2955
+ const lastEmittedRef = (0, import_react17.useRef)(value);
2956
+ const [active, setActive] = (0, import_react17.useState)(Boolean(value));
2957
+ const [localValue, setLocalValue] = (0, import_react17.useState)(value);
2958
+ (0, import_react17.useEffect)(() => {
2959
+ if (value === lastEmittedRef.current) return;
2960
+ setLocalValue(value);
2961
+ lastEmittedRef.current = value;
2962
+ if (value) setActive(true);
2963
+ }, [value]);
2964
+ (0, import_react17.useEffect)(() => {
2965
+ if (!mountedRef.current) {
2966
+ mountedRef.current = true;
2967
+ return;
2968
+ }
2969
+ if (debounceRef.current) clearTimeout(debounceRef.current);
2970
+ debounceRef.current = setTimeout(() => {
2971
+ if (localValue === lastEmittedRef.current) return;
2972
+ lastEmittedRef.current = localValue;
2973
+ onChange(localValue);
2974
+ }, debounceMs);
2975
+ return () => {
2976
+ if (debounceRef.current) clearTimeout(debounceRef.current);
2977
+ };
2978
+ }, [debounceMs, localValue, onChange]);
2979
+ (0, import_react17.useEffect)(() => {
2980
+ if (!active) return;
2981
+ requestAnimationFrame(() => desktopInputRef.current?.focus());
2982
+ }, [active]);
2983
+ (0, import_react17.useEffect)(() => {
2984
+ const handleClickOutside = (event) => {
2985
+ if (!wrapperRef.current) return;
2986
+ if (!wrapperRef.current.contains(event.target) && !localValue) setActive(false);
2987
+ };
2988
+ document.addEventListener("mousedown", handleClickOutside);
2989
+ return () => document.removeEventListener("mousedown", handleClickOutside);
2990
+ }, [localValue]);
2991
+ const emitImmediately = (next) => {
2992
+ if (debounceRef.current) {
2993
+ clearTimeout(debounceRef.current);
2994
+ debounceRef.current = null;
2995
+ }
2996
+ lastEmittedRef.current = next;
2997
+ onChange(next);
2998
+ };
2999
+ const clearSearch = () => {
3000
+ setLocalValue("");
3001
+ emitImmediately("");
3002
+ setActive(false);
3003
+ };
3004
+ return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(
3005
+ "div",
3006
+ {
3007
+ ref: wrapperRef,
3008
+ "data-ds-component": "search-input",
3009
+ className: cn("w-full sm:w-auto", align === "right" ? "sm:mr-3" : "sm:ml-0", className),
3010
+ children: [
3011
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: "relative block w-full sm:hidden", children: [
3012
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { className: "pointer-events-none absolute left-3 top-1/2 -translate-y-1/2 text-[var(--color-text-muted)]", children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(SearchIcon2, {}) }),
3013
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
3014
+ "input",
3015
+ {
3016
+ type: "text",
3017
+ value: localValue,
3018
+ onChange: (event) => {
3019
+ setLocalValue(event.target.value);
3020
+ if (event.target.value) setActive(true);
3021
+ },
3022
+ placeholder: resolvedPlaceholder,
3023
+ className: "h-9 w-full appearance-none rounded-xl border border-[var(--color-border)] bg-[var(--color-background)] pl-9 pr-9 text-sm text-[var(--color-text)] outline-none shadow-sm placeholder:text-[var(--color-text-muted)]/70 focus:border-[var(--color-brand)] focus:ring-2 focus:ring-[var(--color-brand)]/20"
3024
+ }
3025
+ ),
3026
+ localValue ? /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
3027
+ "button",
3028
+ {
3029
+ type: "button",
3030
+ "aria-label": t("searchInput.clear"),
3031
+ onClick: clearSearch,
3032
+ className: "absolute right-2 top-1/2 -translate-y-1/2 appearance-none rounded-md border-0 bg-transparent p-1 text-[var(--color-text-muted)] hover:bg-[var(--color-surface-muted)] hover:text-[var(--color-text)]",
3033
+ children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(ClearIcon6, {})
3034
+ }
3035
+ ) : null
3036
+ ] }),
3037
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
3038
+ "div",
3039
+ {
3040
+ className: cn("relative hidden items-center transition-[width] duration-200 ease-out sm:flex", align === "right" ? "justify-end" : "justify-start"),
3041
+ style: { width: active ? expandedWidth : "44px" },
3042
+ children: /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(
3043
+ "div",
3044
+ {
3045
+ className: cn(
3046
+ "relative h-9 w-full overflow-hidden rounded-xl border border-[var(--color-border)] bg-[var(--color-background)] shadow-sm transition-all duration-200 ease-out focus-within:border-[var(--color-brand)] focus-within:ring-2 focus-within:ring-[var(--color-brand)]/20",
3047
+ active ? "cursor-text" : "cursor-pointer hover:bg-[var(--color-surface-muted)]"
3048
+ ),
3049
+ onClick: () => setActive(true),
3050
+ children: [
3051
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { className: cn("pointer-events-none absolute top-1/2 -translate-y-1/2 text-[var(--color-text-muted)] transition-all duration-200 ease-out", active ? "left-3" : "left-1/2 -translate-x-1/2"), children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(SearchIcon2, {}) }),
3052
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
3053
+ "input",
3054
+ {
3055
+ ref: desktopInputRef,
3056
+ type: "text",
3057
+ value: localValue,
3058
+ onChange: (event) => {
3059
+ setLocalValue(event.target.value);
3060
+ if (event.target.value) setActive(true);
3061
+ },
3062
+ onKeyDown: (event) => {
3063
+ if (event.key === "Escape") clearSearch();
3064
+ },
3065
+ placeholder: resolvedPlaceholder,
3066
+ className: cn(
3067
+ "h-full w-full appearance-none border-0 bg-transparent pl-9 pr-9 text-sm text-[var(--color-text)] outline-none placeholder:text-[var(--color-text-muted)]/70 transition-opacity duration-150 ease-out",
3068
+ active ? "opacity-100" : "pointer-events-none opacity-0"
3069
+ )
3070
+ }
3071
+ ),
3072
+ active && localValue ? /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
3073
+ "button",
3074
+ {
3075
+ type: "button",
3076
+ "aria-label": t("searchInput.clear"),
3077
+ onClick: (event) => {
3078
+ event.preventDefault();
3079
+ event.stopPropagation();
3080
+ clearSearch();
3081
+ },
3082
+ className: "absolute right-2 top-1/2 -translate-y-1/2 appearance-none rounded-md border-0 bg-transparent p-1 text-[var(--color-text-muted)] hover:bg-[var(--color-surface-muted)] hover:text-[var(--color-text)]",
3083
+ children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(ClearIcon6, {})
3084
+ }
3085
+ ) : null
3086
+ ]
3087
+ }
3088
+ )
3089
+ }
3090
+ )
3091
+ ]
3092
+ }
3093
+ );
3094
+ }
3095
+
3096
+ // src/select/select.tsx
3097
+ var import_react18 = require("react");
3098
+ var import_jsx_runtime27 = require("react/jsx-runtime");
3099
+ function ChevronDownIcon3({ open }) {
3100
+ return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", className: cn("size-3.5 transition-transform", open && "rotate-180"), "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("path", { d: "m6 9 6 6 6-6" }) });
3101
+ }
3102
+ function ClearIcon7() {
3103
+ return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", className: "size-3.5", children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("path", { d: "m18 6-12 12M6 6l12 12" }) });
3104
+ }
3105
+ function selectOptionsFromChildren(children) {
3106
+ return import_react18.Children.toArray(children).flatMap((child) => {
3107
+ if (!(0, import_react18.isValidElement)(child)) return [];
3108
+ if (child.type !== "option" || child.props.value === void 0) return [];
3109
+ return [{ value: child.props.value, label: child.props.children, ...child.props.disabled === void 0 ? {} : { disabled: child.props.disabled } }];
3110
+ });
3111
+ }
3112
+ function sameValue2(left, right) {
3113
+ return String(left ?? "") === String(right ?? "");
3114
+ }
3115
+ var DSelect = (0, import_react18.forwardRef)(function DSelect2({
3116
+ className,
3117
+ children,
3118
+ label,
3119
+ hint,
3120
+ error,
3121
+ containerClassName,
3122
+ id: providedId,
3123
+ options,
3124
+ placeholder,
3125
+ clearable = true,
3126
+ searchable = false,
3127
+ loading = false,
3128
+ emptyMessage,
3129
+ asyncErrorMessage,
3130
+ fetchOptions,
3131
+ refetchKey,
3132
+ onFetchError,
3133
+ onValueChange,
3134
+ onChange,
3135
+ value,
3136
+ defaultValue = null,
3137
+ disabled = false,
3138
+ size = "md",
3139
+ debounceMs = 300,
3140
+ scrollBehavior = "reposition",
3141
+ ...props
3142
+ }, ref) {
3143
+ const generatedId = (0, import_react18.useId)();
3144
+ const id = providedId ?? generatedId;
3145
+ const { t } = useDLocalization();
3146
+ const s = INPUT_SIZE_STYLES[size];
3147
+ const requestIdRef = (0, import_react18.useRef)(0);
3148
+ const resolveRequestIdRef = (0, import_react18.useRef)(0);
3149
+ const [query, setQuery] = (0, import_react18.useState)("");
3150
+ const [activeIndex, setActiveIndex] = (0, import_react18.useState)(0);
3151
+ const [isOpen, setOpen] = (0, import_react18.useState)(false);
3152
+ const [internalValue, setInternalValue] = (0, import_react18.useState)(defaultValue);
3153
+ const [resolvedAsyncSelection, setResolvedAsyncSelection] = (0, import_react18.useState)(null);
3154
+ const [asyncOptions, setAsyncOptions] = (0, import_react18.useState)([]);
3155
+ const [isFetching, setFetching] = (0, import_react18.useState)(false);
3156
+ const [fetchError, setFetchError] = (0, import_react18.useState)(null);
3157
+ const selectedValue = value === void 0 ? internalValue : value;
3158
+ const resolvedPlaceholder = placeholder ?? t("select.placeholder");
3159
+ const resolvedEmptyMessage = emptyMessage ?? t("select.empty");
3160
+ const resolvedAsyncErrorMessage = asyncErrorMessage ?? t("select.asyncError");
3161
+ const staticOptions = (0, import_react18.useMemo)(() => options?.slice() ?? selectOptionsFromChildren(children), [children, options]);
3162
+ const isAsync = Boolean(fetchOptions);
3163
+ const sourceOptions = isAsync ? asyncOptions : staticOptions;
3164
+ const filteredOptions = (0, import_react18.useMemo)(
3165
+ () => !isAsync && searchable && query ? sourceOptions.filter((option) => String(option.label).toLocaleLowerCase().includes(query.toLocaleLowerCase())) : sourceOptions,
3166
+ [isAsync, query, searchable, sourceOptions]
3167
+ );
3168
+ const selected = staticOptions.find((option) => sameValue2(option.value, selectedValue)) ?? (sameValue2(resolvedAsyncSelection?.value, selectedValue) ? resolvedAsyncSelection : null);
3169
+ const showClear = Boolean(clearable && selected && !disabled);
3170
+ (0, import_react18.useEffect)(() => {
3171
+ if (!isAsync || !fetchOptions || !isOpen) return;
3172
+ const requestId = ++requestIdRef.current;
3173
+ const timeout = window.setTimeout(() => {
3174
+ setFetching(true);
3175
+ setFetchError(null);
3176
+ void fetchOptions(query).then((result) => {
3177
+ if (requestId === requestIdRef.current) setAsyncOptions(result);
3178
+ }).catch((nextError) => {
3179
+ if (requestId !== requestIdRef.current) return;
3180
+ setFetchError(nextError);
3181
+ onFetchError?.(nextError);
3182
+ }).finally(() => {
3183
+ if (requestId === requestIdRef.current) setFetching(false);
3184
+ });
3185
+ }, debounceMs);
3186
+ return () => window.clearTimeout(timeout);
3187
+ }, [debounceMs, fetchOptions, isAsync, isOpen, onFetchError, query, refetchKey]);
3188
+ (0, import_react18.useEffect)(() => {
3189
+ if (!isAsync || !fetchOptions || selectedValue == null || selectedValue === "" || sameValue2(resolvedAsyncSelection?.value, selectedValue)) return;
3190
+ const requestId = ++resolveRequestIdRef.current;
3191
+ void fetchOptions("").then((result) => {
3192
+ if (requestId !== resolveRequestIdRef.current) return;
3193
+ const found = result.find((option) => sameValue2(option.value, selectedValue));
3194
+ if (found) setResolvedAsyncSelection(found);
3195
+ }).catch((nextError) => onFetchError?.(nextError));
3196
+ }, [fetchOptions, isAsync, onFetchError, refetchKey, resolvedAsyncSelection?.value, selectedValue]);
3197
+ const selectedIndex = () => {
3198
+ const index = filteredOptions.findIndex((option) => sameValue2(option.value, selectedValue));
3199
+ return index >= 0 ? index : 0;
3200
+ };
3201
+ const choose = (option) => {
3202
+ if (value === void 0) setInternalValue(option.value);
3203
+ setResolvedAsyncSelection(option);
3204
+ onValueChange?.(option.value);
3205
+ onChange?.(option.value);
3206
+ setOpen(false);
3207
+ setQuery("");
3208
+ };
3209
+ const clear = (event) => {
3210
+ event.preventDefault();
3211
+ event.stopPropagation();
3212
+ if (value === void 0) setInternalValue(null);
3213
+ setResolvedAsyncSelection(null);
3214
+ onValueChange?.(null);
3215
+ onChange?.(null);
3216
+ setQuery("");
3217
+ };
3218
+ const handleTriggerKeyDown = (event) => {
3219
+ if (event.key === "Escape") {
3220
+ setOpen(false);
3221
+ setQuery("");
3222
+ return;
3223
+ }
3224
+ if (event.key === "ArrowDown" || event.key === "ArrowUp") {
3225
+ event.preventDefault();
3226
+ const count = filteredOptions.length || 1;
3227
+ if (!isOpen) {
3228
+ const start = selectedIndex();
3229
+ setOpen(true);
3230
+ setActiveIndex(event.key === "ArrowDown" ? (start + 1) % count : (start - 1 + count) % count);
3231
+ return;
3232
+ }
3233
+ setActiveIndex((index) => event.key === "ArrowDown" ? (index + 1) % count : (index - 1 + count) % count);
3234
+ return;
3235
+ }
3236
+ if (event.key === "Enter" || event.key === " ") {
3237
+ event.preventDefault();
3238
+ const active = filteredOptions[activeIndex];
3239
+ if (isOpen && active && !active.disabled) choose(active);
3240
+ else {
3241
+ setActiveIndex(selectedIndex());
3242
+ setOpen(true);
3243
+ }
3244
+ }
3245
+ };
3246
+ return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { "data-ds-component": "select", className: cn("flex min-w-0 flex-col gap-1.5", containerClassName), children: [
3247
+ label ? /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("label", { htmlFor: id, className: cn(s.label, "inline-block w-fit font-medium text-[var(--color-text)]"), children: label }) : null,
3248
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(DDropdown, { matchWidth: true, open: isOpen, onOpenChange: (next) => {
3249
+ setOpen(next);
3250
+ if (next && !query) setActiveIndex(selectedIndex());
3251
+ }, contentRole: "listbox", contentPadding: false, contentClassName: "overflow-hidden", scrollBehavior, onClose: () => {
3252
+ setOpen(false);
3253
+ setQuery("");
3254
+ }, trigger: ({ open }) => /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: "relative", children: [
3255
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("button", { ...props, ref, id, type: "button", disabled, "aria-invalid": Boolean(error) || void 0, "aria-haspopup": "listbox", "aria-expanded": open, "aria-controls": `${id}-listbox`, onKeyDown: handleTriggerKeyDown, className: cn("flex w-full items-center rounded-[var(--radius-control)] border bg-[var(--color-surface)] text-left transition-colors duration-150 focus:border-[var(--color-brand)] focus:outline-none focus:ring-2 focus:ring-[var(--color-brand)]/20 disabled:cursor-not-allowed disabled:bg-[var(--color-surface-muted)] disabled:opacity-50", s.input, error ? "border-[var(--color-danger)]" : "border-[var(--color-border)]", selected ? "text-[var(--color-text)]" : "text-[var(--color-text-muted)]/60", showClear ? size === "sm" ? "pr-14" : "pr-16" : "pr-10", className), children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { className: "min-w-0 flex-1 truncate", children: selected ? selected.label : resolvedPlaceholder }) }),
3256
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: cn("absolute top-1/2 flex -translate-y-1/2 items-center gap-1.5 text-[var(--color-text-muted)]", size === "sm" ? "right-2" : "right-2.5"), children: [
3257
+ showClear ? /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("button", { type: "button", tabIndex: -1, "aria-label": t("select.clear"), onMouseDown: (event) => event.preventDefault(), onClick: clear, className: "appearance-none rounded-md border-0 bg-transparent p-1 shadow-none hover:bg-[var(--color-surface-muted)] hover:text-[var(--color-text)]", children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(ClearIcon7, {}) }) : null,
3258
+ !disabled ? /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(ChevronDownIcon3, { open }) : null
3259
+ ] })
3260
+ ] }), children: /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { id: `${id}-listbox`, className: "max-h-60 overflow-hidden", children: [
3261
+ searchable ? /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: "border-b border-[var(--color-border)] p-1.5", children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("input", { autoFocus: true, value: query, onChange: (event) => {
3262
+ setQuery(event.target.value);
3263
+ setActiveIndex(0);
3264
+ }, placeholder: t("select.searchPlaceholder"), className: "h-8 w-full rounded-[var(--radius-control)] border border-[var(--color-border)] bg-[var(--color-background)] px-2.5 text-xs text-[var(--color-text)] outline-none focus:border-[var(--color-brand)] focus:ring-2 focus:ring-[var(--color-brand)]/20" }) }) : null,
3265
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: "max-h-48 space-y-0.5 overflow-y-auto p-1.5", children: loading || isFetching ? /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("p", { className: "px-3 py-2 text-sm text-[var(--color-text-muted)]", children: t("select.loading") }) : fetchError ? /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("p", { className: "px-3 py-2 text-sm text-[var(--color-danger)]", children: resolvedAsyncErrorMessage }) : filteredOptions.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("p", { className: "px-3 py-2 text-sm text-[var(--color-text-muted)]", children: resolvedEmptyMessage }) : filteredOptions.map((option, index) => {
3266
+ const isSelected = sameValue2(option.value, selectedValue);
3267
+ return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("button", { type: "button", role: "option", "aria-selected": isSelected, disabled: option.disabled, onMouseEnter: () => setActiveIndex(index), onMouseDown: (event) => event.preventDefault(), onClick: (event) => {
3268
+ event.stopPropagation();
3269
+ if (!option.disabled) choose(option);
3270
+ }, className: cn("w-full rounded-[var(--radius-menu-item)] px-3 py-2 text-left text-sm text-[var(--color-text)] transition-colors hover:bg-[var(--color-surface-muted)] disabled:cursor-not-allowed disabled:opacity-50", isSelected && "bg-[var(--color-brand)]/10 font-medium text-[var(--color-brand)]", index === activeIndex && !isSelected && "bg-[var(--color-surface-muted)]"), children: option.label }, String(option.value));
3271
+ }) })
3272
+ ] }) }),
3273
+ error ? /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("p", { className: "text-xs text-[var(--color-danger)]", children: error }) : null,
3274
+ !error && hint ? /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("p", { className: "text-xs text-[var(--color-text-muted)]", children: hint }) : null
3275
+ ] });
3276
+ });
3277
+ DSelect.displayName = "DSelect";
3278
+
3279
+ // src/select-filter/select-filter.tsx
3280
+ var import_react19 = require("react");
3281
+ var import_jsx_runtime28 = require("react/jsx-runtime");
3282
+ function ClearIcon8() {
3283
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", className: "size-3.5", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("path", { d: "m18 6-12 12M6 6l12 12" }) });
3284
+ }
3285
+ function ChevronIcon2({ open }) {
3286
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", className: cn("size-3.5 transition-transform", open && "rotate-180"), children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("path", { d: "m6 9 6 6 6-6" }) });
3287
+ }
3288
+ function DSelectFilter({
3289
+ label,
3290
+ placeholder,
3291
+ options,
3292
+ value,
3293
+ onChange,
3294
+ error,
3295
+ hint,
3296
+ disabled = false,
3297
+ clearable = true,
3298
+ searchable = false,
3299
+ containerClassName,
3300
+ scrollBehavior = "close"
3301
+ }) {
3302
+ const { t } = useDLocalization();
3303
+ const id = (0, import_react19.useId)();
3304
+ const searchRef = (0, import_react19.useRef)(null);
3305
+ const [search, setSearch] = (0, import_react19.useState)("");
3306
+ const selectedOption = options.find((option) => String(option.value) === String(value ?? ""));
3307
+ const resolvedPlaceholder = placeholder ?? t("selectFilter.placeholder");
3308
+ const filtered = (0, import_react19.useMemo)(() => {
3309
+ if (!searchable || !search) return options;
3310
+ const query = search.toLocaleLowerCase();
3311
+ return options.filter((option) => String(option.label).toLocaleLowerCase().includes(query));
3312
+ }, [options, search, searchable]);
3313
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { "data-ds-component": "select-filter", className: cn("flex min-w-0 flex-col gap-1.5", containerClassName), children: [
3314
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
3315
+ DDropdown,
3316
+ {
3317
+ matchWidth: true,
3318
+ contentPadding: false,
3319
+ contentClassName: "overflow-hidden",
3320
+ scrollBehavior,
3321
+ onOpenChange: (open) => {
3322
+ if (open && searchable) requestAnimationFrame(() => searchRef.current?.focus());
3323
+ if (!open) setSearch("");
3324
+ },
3325
+ trigger: ({ open }) => /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(
3326
+ "div",
3327
+ {
3328
+ className: cn(
3329
+ "relative flex h-10 w-full items-center rounded-[var(--radius-control)] border bg-[var(--color-surface)] px-3 pr-8 text-left text-sm transition-colors focus-within:border-[var(--color-brand)] focus-within:ring-2 focus-within:ring-[var(--color-brand)]/20",
3330
+ error ? "border-[var(--color-danger)]" : "border-[var(--color-border)]",
3331
+ disabled && "cursor-not-allowed bg-[var(--color-surface-muted)] opacity-50"
3332
+ ),
3333
+ children: [
3334
+ label ? /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "flex shrink-0 items-center gap-2 text-[var(--color-text-muted)]", children: [
3335
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("label", { htmlFor: id, className: "text-sm font-medium", children: label }),
3336
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { "aria-hidden": "true", className: "opacity-45", children: "|" })
3337
+ ] }) : null,
3338
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
3339
+ "button",
3340
+ {
3341
+ id,
3342
+ type: "button",
3343
+ disabled,
3344
+ "aria-invalid": Boolean(error) || void 0,
3345
+ className: cn(
3346
+ "min-w-0 flex-1 truncate pl-3 pr-6 text-left outline-none",
3347
+ selectedOption ? "text-[var(--color-text)]" : "text-[var(--color-text-muted)]/60"
3348
+ ),
3349
+ children: selectedOption ? selectedOption.label : resolvedPlaceholder
3350
+ }
3351
+ ),
3352
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "absolute right-2 top-1/2 flex -translate-y-1/2 items-center gap-1 text-[var(--color-text-muted)]", children: [
3353
+ clearable && selectedOption && !disabled ? /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
3354
+ "button",
3355
+ {
3356
+ type: "button",
3357
+ "aria-label": t("selectFilter.clear"),
3358
+ onMouseDown: (event) => event.preventDefault(),
3359
+ onClick: (event) => {
3360
+ event.stopPropagation();
3361
+ onChange?.(null);
3362
+ },
3363
+ className: "rounded-md p-0.5 hover:bg-[var(--color-surface-muted)] hover:text-[var(--color-text)]",
3364
+ children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(ClearIcon8, {})
3365
+ }
3366
+ ) : null,
3367
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(ChevronIcon2, { open })
3368
+ ] })
3369
+ ]
3370
+ }
3371
+ ),
3372
+ children: /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "max-h-60 overflow-hidden", children: [
3373
+ searchable ? /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: "border-b border-[var(--color-border)] p-1.5", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
3374
+ "input",
3375
+ {
3376
+ ref: searchRef,
3377
+ value: search,
3378
+ onChange: (event) => setSearch(event.target.value),
3379
+ placeholder: t("selectFilter.searchPlaceholder"),
3380
+ className: "h-8 w-full rounded-[var(--radius-control)] border border-[var(--color-border)] bg-[var(--color-background)] px-2.5 text-sm text-[var(--color-text)] outline-none focus:border-[var(--color-brand)] focus:ring-2 focus:ring-[var(--color-brand)]/20"
3381
+ }
3382
+ ) }) : null,
3383
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: "max-h-48 space-y-0.5 overflow-y-auto p-1.5", children: filtered.map((option) => {
3384
+ const selected = String(option.value) === String(value ?? "");
3385
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
3386
+ "button",
3387
+ {
3388
+ type: "button",
3389
+ role: "option",
3390
+ "aria-selected": selected,
3391
+ disabled: option.disabled,
3392
+ onClick: () => {
3393
+ if (option.disabled) return;
3394
+ onChange?.(option.value);
3395
+ setSearch("");
3396
+ },
3397
+ className: cn(
3398
+ "w-full rounded-[var(--radius-menu-item)] px-3 py-2 text-left text-sm text-[var(--color-text)] transition-colors hover:bg-[var(--color-surface-muted)] disabled:cursor-not-allowed disabled:opacity-50",
3399
+ selected && "bg-[var(--color-brand)]/10 font-medium text-[var(--color-brand)]"
3400
+ ),
3401
+ children: option.label
3402
+ },
3403
+ String(option.value)
3404
+ );
3405
+ }) })
3406
+ ] })
3407
+ }
3408
+ ),
3409
+ error ? /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("p", { className: "text-xs text-[var(--color-danger)]", children: error }) : null,
3410
+ !error && hint ? /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("p", { className: "text-xs text-[var(--color-text-muted)]", children: hint }) : null
3411
+ ] });
3412
+ }
3413
+
3414
+ // src/skeleton/skeleton.tsx
3415
+ var import_jsx_runtime29 = require("react/jsx-runtime");
3416
+ var roundedClasses = { sm: "rounded-sm", md: "rounded-md", lg: "rounded-lg", full: "rounded-full" };
3417
+ function SkeletonBlock({ className, width, height, rounded = "md", style, ...props }) {
3418
+ const dimensions = {
3419
+ ...style,
3420
+ ...width !== void 0 ? { width: typeof width === "number" ? `${width}px` : width } : {},
3421
+ ...height !== void 0 ? { height: typeof height === "number" ? `${height}px` : height } : {}
3422
+ };
3423
+ return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: cn("animate-pulse bg-[var(--color-surface-muted)]", roundedClasses[rounded], className), style: dimensions, ...props });
3424
+ }
3425
+ function DSkeleton({ height = 16, count = 1, ...props }) {
3426
+ return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_jsx_runtime29.Fragment, { children: Array.from({ length: count }).map((_, index) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(SkeletonBlock, { ...props, height }, index)) });
3427
+ }
3428
+ function DTableSkeleton({ rows = 5, cols = 4 }) {
3429
+ return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "space-y-3", children: [
3430
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: "flex gap-4", children: Array.from({ length: cols }).map((_, i) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(DSkeleton, { height: 14, width: i === 0 ? "30%" : "20%" }, i)) }),
3431
+ Array.from({ length: rows }).map((_, r) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: "flex gap-4 border-b border-[var(--color-border)]/50 py-3", children: Array.from({ length: cols }).map((_2, c) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(DSkeleton, { height: 12, width: c === 0 ? "30%" : "20%" }, c)) }, r))
3432
+ ] });
3433
+ }
3434
+ function DCardSkeleton() {
3435
+ return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "space-y-3 rounded-xl border border-[var(--color-border)] bg-[var(--color-surface)] p-5", children: [
3436
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(DSkeleton, { height: 12, width: "40%" }),
3437
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(DSkeleton, { height: 28, width: "60%" }),
3438
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(DSkeleton, { height: 10, width: "80%" })
3439
+ ] });
3440
+ }
3441
+ function DFormSkeleton({ fields = 4 }) {
3442
+ return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: "space-y-5", children: Array.from({ length: fields }).map((_, i) => /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "space-y-2", children: [
3443
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(DSkeleton, { height: 12, width: "25%" }),
3444
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(DSkeleton, { height: 40, width: "100%", rounded: "lg" })
3445
+ ] }, i)) });
3446
+ }
3447
+
3448
+ // src/splash-screen/splash-screen.tsx
3449
+ var import_react20 = require("react");
3450
+ var import_jsx_runtime30 = require("react/jsx-runtime");
3451
+ function DSplashScreen({ onFinish, minDuration = 1800, title = "DIGVENT.", subtitle = "Inventory Management System", mark = "D." }) {
3452
+ const [leaving, setLeaving] = (0, import_react20.useState)(false);
3453
+ (0, import_react20.useEffect)(() => {
3454
+ if (!onFinish) return;
3455
+ const leaveTimer = setTimeout(() => setLeaving(true), minDuration);
3456
+ const finishTimer = setTimeout(onFinish, minDuration + 500);
3457
+ return () => {
3458
+ clearTimeout(leaveTimer);
3459
+ clearTimeout(finishTimer);
3460
+ };
3461
+ }, [minDuration, onFinish]);
3462
+ return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { className: cn("fixed inset-0 z-[99999] grid place-items-center bg-[var(--color-background)] transition-opacity duration-500", leaving && "opacity-0"), children: /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("div", { className: cn("flex flex-col items-center transition-all duration-700 ease-out", leaving && "-translate-y-5 scale-95 opacity-0"), children: [
3463
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("div", { className: "relative mb-6", children: [
3464
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { className: "flex size-16 items-center justify-center rounded-2xl bg-[var(--color-brand)] text-2xl font-bold tracking-tight text-white shadow-lg shadow-blue-500/20", children: mark }),
3465
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { className: "absolute inset-0 animate-ping rounded-2xl bg-[var(--color-brand)]/20 [animation-duration:2s]" })
3466
+ ] }),
3467
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("h1", { className: "mb-2 text-3xl font-bold tracking-tight text-[var(--color-text)]", children: title }),
3468
+ subtitle ? /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("p", { className: "mb-8 text-sm text-[var(--color-text-muted)]", children: subtitle }) : null,
3469
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { className: "flex gap-1.5", children: [0, 1, 2].map((index) => /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("span", { className: "size-2 rounded-full bg-[var(--color-brand)]", style: { animation: "splash-dot 1.4s ease-in-out infinite", animationDelay: `${index * 0.2}s` } }, index)) })
3470
+ ] }) });
3471
+ }
3472
+
3473
+ // src/status-filter/status-filter.tsx
3474
+ var import_jsx_runtime31 = require("react/jsx-runtime");
3475
+ function DStatusFilter({ label, options, value, onChange, allLabel }) {
3476
+ const { t } = useDLocalization();
3477
+ const resolvedAllLabel = allLabel ?? t("statusFilter.all");
3478
+ const button = (active) => cn(
3479
+ "rounded-[var(--radius-control)] px-3 py-1.5 text-xs font-medium transition-all duration-150",
3480
+ active ? "bg-[var(--color-brand)] text-[var(--color-brand-foreground)] shadow-[var(--shadow-sm)]" : "border border-[var(--color-border)] bg-[var(--color-surface)] text-[var(--color-text-muted)] hover:bg-[var(--color-surface-muted)] hover:text-[var(--color-text)]"
3481
+ );
3482
+ return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", { "data-ds-component": "status-filter", className: "flex flex-wrap items-center gap-3", children: [
3483
+ label ? /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("span", { className: "text-xs font-medium text-[var(--color-text-muted)]", children: label }) : null,
3484
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", { className: "flex flex-wrap items-center gap-1.5", children: [
3485
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("button", { type: "button", onClick: () => onChange(""), className: button(!value), children: resolvedAllLabel }),
3486
+ options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("button", { type: "button", onClick: () => onChange(option.value), className: button(value === option.value), children: [
3487
+ option.label,
3488
+ option.count !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("span", { className: "ml-1 opacity-70", children: [
3489
+ "(",
3490
+ option.count,
3491
+ ")"
3492
+ ] }) : null
3493
+ ] }, option.value))
3494
+ ] })
3495
+ ] });
3496
+ }
3497
+
3498
+ // src/data-table/data-table.tsx
3499
+ var import_react21 = require("react");
3500
+ var import_jsx_runtime32 = require("react/jsx-runtime");
3501
+ function getPaginationPages(page, totalPages) {
3502
+ const count = Math.min(Math.max(totalPages, 1), 5);
3503
+ if (totalPages <= 5) return Array.from({ length: count }, (_, index) => index + 1);
3504
+ const start = Math.min(Math.max(page - 2, 1), totalPages - 4);
3505
+ return Array.from({ length: 5 }, (_, index) => start + index);
3506
+ }
3507
+ function rawValue(row, key) {
3508
+ if (row && typeof row === "object") return row[key];
3509
+ return void 0;
3510
+ }
3511
+ function toDisplay(value, t) {
3512
+ if (value === null || value === void 0 || value === "") return "-";
3513
+ if (typeof value === "boolean") return value ? t("common.yes") : t("common.no");
3514
+ if (typeof value === "string" || typeof value === "number") return String(value);
3515
+ return "-";
3516
+ }
3517
+ function toNumber(value) {
3518
+ if (typeof value === "number") return Number.isFinite(value) ? value : 0;
3519
+ const parsed = Number(String(value ?? "").replace(/[^\d.-]/g, ""));
3520
+ return Number.isFinite(parsed) ? parsed : 0;
3521
+ }
3522
+ function formatValue(column, row, index, locale, t) {
3523
+ const value = rawValue(row, String(column.key));
3524
+ if (column.render) {
3525
+ const render = column.render;
3526
+ return render.length >= 3 ? render(value, row, index) : render(row, index);
3527
+ }
3528
+ let formatted;
3529
+ if (column.type === "currency") formatted = new Intl.NumberFormat(locale, { style: "currency", currency: "IDR", maximumFractionDigits: 0 }).format(toNumber(value));
3530
+ else if (column.type === "number") formatted = new Intl.NumberFormat(locale).format(toNumber(value));
3531
+ else if (column.type === "date") {
3532
+ const date2 = value instanceof Date ? value : typeof value === "string" ? new Date(value) : null;
3533
+ formatted = date2 && !Number.isNaN(date2.getTime()) ? new Intl.DateTimeFormat(locale, { day: "2-digit", month: "short", year: "numeric" }).format(date2) : "-";
3534
+ } else formatted = toDisplay(value, t);
3535
+ const transform = column.transform ?? column.trasform;
3536
+ if (typeof transform === "function") return transform(formatted);
3537
+ if (typeof formatted !== "string") return formatted;
3538
+ if (transform === "uppercase") return formatted.toUpperCase();
3539
+ if (transform === "lowercase") return formatted.toLowerCase();
3540
+ if (transform === "capitalize") return formatted.charAt(0).toUpperCase() + formatted.slice(1);
3541
+ return formatted;
3542
+ }
3543
+ function alignmentClass(column) {
3544
+ return cn(column.align === "center" && "text-center", column.align === "right" && "text-right", (!column.align || column.align === "left") && "text-left");
3545
+ }
3546
+ function FilterIcon() {
3547
+ return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", className: "size-4", children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("path", { d: "M4 6h16M7 12h10M10 18h4" }) });
3548
+ }
3549
+ function PageSizeSelect({ value, onChange }) {
3550
+ if (!onChange) return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("span", { className: "font-medium text-[var(--color-text)]", children: value });
3551
+ return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(DDropdown, { placement: "top-start", closeOnItemClick: true, scrollBehavior: "close", trigger: ({ open }) => /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("button", { type: "button", className: "relative flex h-8 appearance-none items-center rounded-lg border border-[var(--color-border)] bg-[var(--color-background)] px-2 pr-6 text-sm text-[var(--color-text)] outline-none hover:bg-[var(--color-surface-muted)] focus-visible:ring-2 focus-visible:ring-[var(--color-focus)]/25", children: [
3552
+ value,
3553
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(ChevronDownIcon, { size: 14, className: cn("absolute right-1.5 transition-transform duration-150", open && "rotate-180") })
3554
+ ] }), children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { className: "min-w-[72px] py-1", children: [10, 25, 50, 100].map((size) => /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("button", { type: "button", onClick: () => onChange(size), className: cn("w-full appearance-none rounded-[var(--radius-menu-item)] border-0 bg-transparent px-3 py-1.5 text-left text-sm hover:bg-[var(--color-surface-muted)]", size === value && "bg-[var(--color-brand)]/10 font-medium text-[var(--color-brand)]"), children: size }, size)) }) });
3555
+ }
3556
+ function ActionMenu({ actions, row }) {
3557
+ const visible = actions.filter((action) => !action.show || action.show(row));
3558
+ if (!visible.length) return null;
3559
+ return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(DDropdown, { placement: "bottom-end", closeOnItemClick: true, scrollBehavior: "close", trigger: ({ open }) => /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("span", { className: cn("inline-flex size-8 items-center justify-center rounded-lg border border-[var(--color-border)] bg-[var(--color-background)] text-[var(--color-text-muted)] hover:bg-[var(--color-surface-muted)]", open && "bg-[var(--color-surface-muted)] text-[var(--color-text)]"), children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(MoreHorizontalIcon, { size: 16 }) }), children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { className: "min-w-[180px] py-1", children: visible.map((action, index) => /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("button", { type: "button", onClick: () => action.onClick(row), className: cn("flex w-full appearance-none items-center gap-2.5 rounded-[var(--radius-menu-item)] border-0 bg-transparent px-3 py-2.5 text-left text-sm hover:bg-[var(--color-surface-muted)]", action.variant === "danger" ? "text-[var(--color-danger)]" : "text-[var(--color-text)]"), children: [
3560
+ action.icon,
3561
+ action.label
3562
+ ] }, index)) }) });
3563
+ }
3564
+ function DDataTable({ columns, data, rowKey = "id", loading = false, emptyMessage, onRowClick, sortBy, sortDirection, sortDir, onSort, pagination, onPageChange, onPageSizeChange, actions, searchable = false, searchPlaceholder, searchValue = "", onSearchChange, headerActions, filters }) {
3565
+ const { locale, t } = useDLocalization();
3566
+ const [showFilters, setShowFilters] = (0, import_react21.useState)(false);
3567
+ const direction = sortDirection ?? sortDir ?? "asc";
3568
+ const totalPages = pagination ? Math.max(1, Math.ceil(pagination.total / pagination.pageSize)) : 1;
3569
+ const resolvedEmpty = emptyMessage ?? t("dataTable.empty");
3570
+ const resolvedSearch = searchPlaceholder ?? t("dataTable.searchPlaceholder");
3571
+ const getKey = (row, index) => {
3572
+ if (typeof rowKey === "function") return rowKey(row, index);
3573
+ const value = rawValue(row, String(rowKey));
3574
+ return value === null || value === void 0 || value === "" ? String(index) : String(value);
3575
+ };
3576
+ const changeSort = (column) => {
3577
+ if (!column.sortable || !onSort) return;
3578
+ onSort(String(column.key), sortBy === String(column.key) && direction === "asc" ? "desc" : "asc");
3579
+ };
3580
+ const actionArray = Array.isArray(actions) ? actions : null;
3581
+ const actionRenderer = typeof actions === "function" ? actions : null;
3582
+ const hasActions = Boolean(actionArray?.length || actionRenderer);
3583
+ const renderActions = (row, index) => actionRenderer ? actionRenderer(row, index) : actionArray ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(ActionMenu, { actions: actionArray, row }) : null;
3584
+ const renderValue = (column, row, index) => formatValue(column, row, index, locale, t);
3585
+ return /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("div", { "data-ds-component": "data-table", className: "overflow-visible rounded-[var(--radius-card)] border border-[var(--color-border)] bg-[var(--color-surface)]", children: [
3586
+ searchable || headerActions || filters ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { className: "space-y-4 border-b border-[var(--color-border)] px-4 py-3", children: /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("div", { className: "flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between", children: [
3587
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("div", { className: "flex w-full items-center gap-2 sm:w-auto", children: [
3588
+ searchable ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(DSearchInput, { value: searchValue, onChange: (query) => onSearchChange?.(query), placeholder: resolvedSearch, debounceMs: 500, align: "left", expandedWidth: "260px" }) : null,
3589
+ filters ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("button", { type: "button", "aria-label": t("dataTable.toggleFilters"), onClick: () => setShowFilters((value) => !value), className: cn("inline-flex h-9 w-11 appearance-none items-center justify-center rounded-xl border text-sm shadow-sm outline-none transition-all focus-visible:ring-2 focus-visible:ring-[var(--color-focus)]/25", showFilters ? "border-[var(--color-brand)] bg-[var(--color-brand)] text-[var(--color-brand-foreground)]" : "border-[var(--color-border)] bg-[var(--color-background)] text-[var(--color-text-muted)] hover:bg-[var(--color-surface-muted)]"), children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(FilterIcon, {}) }) : null
3590
+ ] }),
3591
+ headerActions ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { className: "flex w-full shrink-0 items-center justify-end gap-2 sm:w-auto", children: headerActions }) : null
3592
+ ] }) }) : null,
3593
+ filters ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { className: cn("overflow-hidden transition-all duration-300", showFilters ? "max-h-[220px] opacity-100" : "max-h-0 opacity-0"), children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { className: "flex flex-wrap items-center gap-2 border-b border-[var(--color-border)] px-4 py-3", children: filters }) }) : null,
3594
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { className: "divide-y divide-[var(--color-border)] sm:hidden", children: loading ? Array.from({ length: 3 }, (_, index) => /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("div", { className: "space-y-2 p-4", children: [
3595
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(DSkeleton, { height: 16, width: "70%" }),
3596
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(DSkeleton, { height: 12, width: "50%" }),
3597
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(DSkeleton, { height: 12, width: "40%" })
3598
+ ] }, index)) : data.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { className: "px-4 py-16 text-center text-sm text-[var(--color-text-muted)]", children: resolvedEmpty }) : data.map((row, index) => /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("div", { onClick: () => onRowClick?.(row), className: cn("p-4", onRowClick && "cursor-pointer active:bg-[var(--color-surface-muted)]/30"), children: [
3599
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("div", { className: "flex items-start justify-between gap-2", children: [
3600
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { className: "min-w-0 flex-1", children: columns.slice(0, 2).map((column, columnIndex) => /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { className: columnIndex === 0 ? "truncate text-sm font-medium text-[var(--color-text)]" : "mt-0.5 truncate text-xs text-[var(--color-text-muted)]", children: renderValue(column, row, index) }, String(column.key))) }),
3601
+ hasActions ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { onClick: (event) => event.stopPropagation(), children: renderActions(row, index) }) : null
3602
+ ] }),
3603
+ columns.length > 2 ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { className: "mt-2 flex flex-wrap gap-x-4 gap-y-1", children: columns.slice(2).map((column) => /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("div", { className: "text-xs", children: [
3604
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("span", { className: "text-[var(--color-text-muted)]", children: [
3605
+ column.label,
3606
+ ": "
3607
+ ] }),
3608
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("span", { className: "font-medium text-[var(--color-text)]", children: renderValue(column, row, index) })
3609
+ ] }, String(column.key))) }) : null
3610
+ ] }, getKey(row, index))) }),
3611
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { className: "hidden overflow-x-auto sm:block", children: /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("table", { className: "w-full text-sm", children: [
3612
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("tr", { className: "border-b border-[var(--color-border)] bg-[var(--color-surface-muted)]/40", children: [
3613
+ columns.map((column) => /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("th", { style: column.width ? { width: column.width } : void 0, className: cn("whitespace-nowrap px-4 py-3 text-xs font-semibold text-[var(--color-text-muted)]", alignmentClass(column)), children: /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("button", { type: "button", disabled: !column.sortable, onClick: () => changeSort(column), className: cn("inline-flex appearance-none items-center gap-1 border-0 bg-transparent p-0 text-inherit outline-none", column.sortable && "cursor-pointer hover:text-[var(--color-text)] focus-visible:ring-2 focus-visible:ring-[var(--color-focus)]/25"), children: [
3614
+ column.label,
3615
+ column.sortable && sortBy === String(column.key) ? direction === "asc" ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(ArrowUpIcon, {}) : /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(ArrowDownIcon, {}) : null
3616
+ ] }) }, String(column.key))),
3617
+ hasActions ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("th", { className: "w-16 px-4 py-3 text-right text-xs font-semibold text-[var(--color-text-muted)]", children: t("dataTable.actions") }) : null
3618
+ ] }) }),
3619
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("tbody", { children: [
3620
+ loading ? Array.from({ length: 5 }, (_, rowIndex) => /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("tr", { className: "border-b border-[var(--color-border)]/60 last:border-0", children: [
3621
+ columns.map((column, columnIndex) => /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("td", { className: "px-4 py-3", children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(DSkeleton, { height: 12, width: columnIndex === 0 ? "70%" : "50%" }) }, String(column.key))),
3622
+ hasActions ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("td", { className: "px-4 py-3", children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(DSkeleton, { height: 24, width: 24 }) }) : null
3623
+ ] }, rowIndex)) : data.map((row, rowIndex) => /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("tr", { onClick: () => onRowClick?.(row), className: cn("border-b border-[var(--color-border)]/60 last:border-0 hover:bg-[var(--color-surface-muted)]/35", onRowClick && "cursor-pointer"), children: [
3624
+ columns.map((column) => /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("td", { className: cn("px-4 py-3", alignmentClass(column)), children: renderValue(column, row, rowIndex) }, String(column.key))),
3625
+ hasActions ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("td", { className: "px-4 py-3 text-right", onClick: (event) => event.stopPropagation(), children: renderActions(row, rowIndex) }) : null
3626
+ ] }, getKey(row, rowIndex))),
3627
+ !loading && data.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("tr", { children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("td", { colSpan: columns.length + (hasActions ? 1 : 0), className: "px-4 py-16 text-center text-sm text-[var(--color-text-muted)]", children: resolvedEmpty }) }) : null
3628
+ ] })
3629
+ ] }) }),
3630
+ pagination ? /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("footer", { className: "flex flex-col items-center justify-between gap-3 border-t border-[var(--color-border)] px-4 py-3 text-xs text-[var(--color-text-muted)] sm:flex-row", children: [
3631
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("div", { className: "flex items-center gap-2", children: [
3632
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("span", { children: t("dataTable.showing") }),
3633
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(PageSizeSelect, { value: pagination.pageSize, onChange: onPageSizeChange }),
3634
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("span", { children: t("dataTable.ofData", { total: pagination.total }) })
3635
+ ] }),
3636
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("div", { className: "flex items-center gap-1", children: [
3637
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("button", { type: "button", "aria-label": t("pagination.previous"), disabled: pagination.page <= 1, onClick: () => onPageChange?.(pagination.page - 1), className: "grid size-8 appearance-none place-items-center rounded-md border-0 bg-transparent text-[var(--color-text-muted)] outline-none hover:bg-[var(--color-surface-muted)] focus-visible:ring-2 focus-visible:ring-[var(--color-focus)]/25 disabled:opacity-40", children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(ChevronLeftIcon, { size: 16 }) }),
3638
+ getPaginationPages(pagination.page, totalPages).map((page) => /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("button", { type: "button", "aria-label": t("pagination.page", { page }), onClick: () => onPageChange?.(page), className: cn("grid size-8 appearance-none place-items-center rounded-md border-0 bg-transparent outline-none transition-colors focus-visible:ring-2 focus-visible:ring-[var(--color-focus)]/25", page === pagination.page ? "bg-[var(--color-brand)] text-[var(--color-brand-foreground)]" : "text-[var(--color-text)] hover:bg-[var(--color-surface-muted)]"), children: page }, page)),
3639
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("button", { type: "button", "aria-label": t("pagination.next"), disabled: pagination.page >= totalPages, onClick: () => onPageChange?.(pagination.page + 1), className: "grid size-8 appearance-none place-items-center rounded-md border-0 bg-transparent text-[var(--color-text-muted)] outline-none hover:bg-[var(--color-surface-muted)] focus-visible:ring-2 focus-visible:ring-[var(--color-focus)]/25 disabled:opacity-40", children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(ChevronRightIcon, { size: 16 }) })
3640
+ ] })
3641
+ ] }) : null
3642
+ ] });
3643
+ }
3644
+
3645
+ // src/textarea/textarea.tsx
3646
+ var import_react22 = require("react");
3647
+ var import_jsx_runtime33 = require("react/jsx-runtime");
3648
+ function ClearIcon9() {
3649
+ return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", className: "size-3.5", children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("path", { d: "m18 6-12 12M6 6l12 12" }) });
3650
+ }
3651
+ function eventWithValue2(value) {
3652
+ return { target: { value }, currentTarget: { value } };
3653
+ }
3654
+ var DTextarea = (0, import_react22.forwardRef)(function DTextarea2({
3655
+ label,
3656
+ error,
3657
+ hint,
3658
+ clearable = true,
3659
+ onClear,
3660
+ onChange,
3661
+ onNativeChange,
3662
+ containerClassName,
3663
+ className,
3664
+ value,
3665
+ disabled,
3666
+ readOnly,
3667
+ id: externalId,
3668
+ ...props
3669
+ }, ref) {
3670
+ const { t } = useDLocalization();
3671
+ const autoId = (0, import_react22.useId)();
3672
+ const id = externalId ?? autoId;
3673
+ const hasValue = value !== void 0 && value !== null && value !== "";
3674
+ const clear = () => {
3675
+ const event = eventWithValue2("");
3676
+ onClear?.();
3677
+ onChange?.("", event);
3678
+ onNativeChange?.(event);
3679
+ };
3680
+ return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { "data-ds-component": "textarea", className: cn("flex min-w-0 flex-col gap-1.5", containerClassName), children: [
3681
+ label ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("label", { htmlFor: id, className: "inline-block w-fit text-sm font-medium text-[var(--color-text)]", children: label }) : null,
3682
+ /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: "relative", children: [
3683
+ /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
3684
+ "textarea",
3685
+ {
3686
+ ...props,
3687
+ ref,
3688
+ id,
3689
+ value,
3690
+ disabled,
3691
+ readOnly,
3692
+ "aria-invalid": Boolean(error) || void 0,
3693
+ onChange: (event) => {
3694
+ onChange?.(event.target.value, event);
3695
+ onNativeChange?.(event);
3696
+ },
3697
+ className: cn(
3698
+ "min-h-[80px] w-full resize-y rounded-[var(--radius-control)] border bg-[var(--color-surface)] px-3 py-2 text-sm text-[var(--color-text)] transition-colors duration-150 placeholder:text-[var(--color-text-muted)]/60 focus:border-[var(--color-brand)] focus:outline-none focus:ring-2 focus:ring-[var(--color-brand)]/20 disabled:cursor-not-allowed disabled:bg-[var(--color-surface-muted)] disabled:opacity-50 read-only:bg-[var(--color-surface-muted)]",
3699
+ error ? "border-[var(--color-danger)] focus:ring-[var(--color-danger)]/20" : "border-[var(--color-border)]",
3700
+ clearable && hasValue && !disabled && !readOnly && "pr-10",
3701
+ className
3702
+ )
3703
+ }
3704
+ ),
3705
+ clearable && hasValue && !disabled && !readOnly ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("button", { type: "button", tabIndex: -1, "aria-label": t("textarea.clear"), onMouseDown: (event) => event.preventDefault(), onClick: clear, className: "absolute right-2 top-2 rounded-md p-1 text-[var(--color-text-muted)] transition-colors hover:bg-[var(--color-surface-muted)] hover:text-[var(--color-text)]", children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(ClearIcon9, {}) }) : null
3706
+ ] }),
3707
+ error ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("p", { className: "text-xs text-[var(--color-danger)]", children: error }) : null,
3708
+ !error && hint ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("p", { className: "text-xs text-[var(--color-text-muted)]", children: hint }) : null
3709
+ ] });
3710
+ });
3711
+
3712
+ // src/toast/toast.tsx
3713
+ var import_react23 = require("react");
3714
+ var import_jsx_runtime34 = require("react/jsx-runtime");
3715
+ var ToastContext = (0, import_react23.createContext)(null);
3716
+ var toastSequence = 0;
3717
+ function createToastId() {
3718
+ toastSequence += 1;
3719
+ return `toast-${toastSequence}`;
3720
+ }
3721
+ function DToastProvider({
3722
+ children,
3723
+ limit = 3,
3724
+ defaultDuration = 4e3
3725
+ }) {
3726
+ const [toasts, setToasts] = (0, import_react23.useState)([]);
3727
+ const timers = (0, import_react23.useRef)(/* @__PURE__ */ new Map());
3728
+ const dismissToast = (0, import_react23.useCallback)((id) => {
3729
+ const timer = timers.current.get(id);
3730
+ if (timer) clearTimeout(timer);
3731
+ timers.current.delete(id);
3732
+ setToasts((current) => current.filter((toast) => toast.id !== id));
3733
+ }, []);
3734
+ const showToast = (0, import_react23.useCallback)(
3735
+ (input) => {
3736
+ const id = createToastId();
3737
+ const toast = { ...input, id };
3738
+ setToasts((current) => [...current, toast].slice(-Math.max(1, limit)));
3739
+ const duration = input.duration ?? defaultDuration;
3740
+ if (duration > 0) {
3741
+ timers.current.set(
3742
+ id,
3743
+ setTimeout(() => dismissToast(id), duration)
3744
+ );
3745
+ }
3746
+ return id;
3747
+ },
3748
+ [defaultDuration, dismissToast, limit]
3749
+ );
3750
+ (0, import_react23.useEffect)(
3751
+ () => () => {
3752
+ timers.current.forEach((timer) => clearTimeout(timer));
3753
+ timers.current.clear();
3754
+ },
3755
+ []
3756
+ );
3757
+ const value = (0, import_react23.useMemo)(
3758
+ () => ({ toasts, showToast, dismissToast }),
3759
+ [dismissToast, showToast, toasts]
3760
+ );
3761
+ return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(ToastContext.Provider, { value, children: [
3762
+ children,
3763
+ /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(DToastContainer, { toasts, onDismiss: dismissToast })
3764
+ ] });
3765
+ }
3766
+ function useToast() {
3767
+ const context = (0, import_react23.useContext)(ToastContext);
3768
+ if (!context) throw new Error("useToast must be used within a DToastProvider.");
3769
+ return context;
3770
+ }
3771
+ var toastStyle = {
3772
+ info: { wrap: "border-[var(--color-brand)]/30 bg-[var(--color-brand)]/10", icon: "text-[var(--color-brand)]" },
3773
+ success: { wrap: "border-[var(--color-success)]/30 bg-[var(--color-success)]/10", icon: "text-[var(--color-success)]" },
3774
+ warning: { wrap: "border-[var(--color-warning)]/30 bg-[var(--color-warning)]/10", icon: "text-[var(--color-warning)]" },
3775
+ danger: { wrap: "border-[var(--color-danger)]/30 bg-[var(--color-danger)]/10", icon: "text-[var(--color-danger)]" },
3776
+ error: { wrap: "border-[var(--color-danger)]/30 bg-[var(--color-danger)]/10", icon: "text-[var(--color-danger)]" }
3777
+ };
3778
+ function ToastIcon({ variant }) {
3779
+ if (variant === "success") return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", className: "size-[18px]", children: [
3780
+ /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("circle", { cx: "12", cy: "12", r: "9" }),
3781
+ /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("path", { d: "m8 12 3 3 5-6" })
3782
+ ] });
3783
+ if (variant === "warning") return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", className: "size-[18px]", children: [
3784
+ /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("path", { d: "M12 3 2 21h20L12 3Z" }),
3785
+ /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("path", { d: "M12 9v4M12 17h.01" })
3786
+ ] });
3787
+ if (variant === "danger" || variant === "error") return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", className: "size-[18px]", children: [
3788
+ /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("circle", { cx: "12", cy: "12", r: "9" }),
3789
+ /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("path", { d: "M12 8v5M12 16h.01" })
3790
+ ] });
3791
+ return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", className: "size-[18px]", children: [
3792
+ /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("circle", { cx: "12", cy: "12", r: "9" }),
3793
+ /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("path", { d: "M12 10v6M12 7h.01" })
3794
+ ] });
3795
+ }
3796
+ function ToastCloseIcon() {
3797
+ return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", className: "size-3.5", children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("path", { d: "m18 6-12 12M6 6l12 12" }) });
3798
+ }
3799
+ function DToastContainer({ toasts, onDismiss, className }) {
3800
+ if (!toasts.length) return null;
3801
+ return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { "aria-live": "polite", "aria-relevant": "additions", className: cn("pointer-events-none fixed right-4 top-4 z-[9998] flex w-full max-w-sm flex-col gap-2", className), children: toasts.map((toast) => {
3802
+ const variant = toast.variant ?? "info";
3803
+ const style = toastStyle[variant];
3804
+ return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("section", { role: "status", className: cn("pointer-events-auto flex items-start gap-3 rounded-lg border px-4 py-3 shadow-lg backdrop-blur-sm animate-[toast-in_180ms_ease-out]", style.wrap), children: [
3805
+ /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("span", { className: cn("shrink-0", style.icon), children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(ToastIcon, { variant }) }),
3806
+ /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: "min-w-0 flex-1", children: [
3807
+ /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("p", { className: "text-sm font-medium text-[var(--color-text)]", children: toast.title }),
3808
+ toast.description ? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: "mt-0.5 text-xs text-[var(--color-text-muted)]", children: toast.description }) : null
3809
+ ] }),
3810
+ /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("button", { type: "button", "aria-label": "Dismiss notification", onClick: () => onDismiss(toast.id), className: "shrink-0 rounded p-0.5 text-[var(--color-text-muted)] transition-colors hover:text-[var(--color-text)]", children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(ToastCloseIcon, {}) })
3811
+ ] }, toast.id);
3812
+ }) });
3813
+ }
3814
+
3815
+ // src/radio/radio.tsx
3816
+ var import_react24 = require("react");
3817
+ var import_jsx_runtime35 = require("react/jsx-runtime");
3818
+ var DRadio = (0, import_react24.forwardRef)(function DRadio2({ className, ...props }, ref) {
3819
+ return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("input", { "data-ds-component": "radio", ref, type: "radio", className: cn("size-4 accent-[var(--color-brand)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-focus)]/20", className), ...props });
3820
+ });
3821
+
3822
+ // src/toggle/toggle.tsx
3823
+ var import_jsx_runtime36 = require("react/jsx-runtime");
3824
+ function DToggle({
3825
+ label,
3826
+ checked = false,
3827
+ onChange,
3828
+ disabled = false,
3829
+ fullWidth = false,
3830
+ size = "md",
3831
+ labelPosition = "left",
3832
+ gap = "gap-2.5",
3833
+ className,
3834
+ ariaLabel
3835
+ }) {
3836
+ const trackSize = size === "sm" ? "h-4 w-8" : "h-5 w-10";
3837
+ const thumbSize = size === "sm" ? "h-3 w-3" : "h-4 w-4";
3838
+ const translate = size === "sm" ? "translate-x-4" : "translate-x-5";
3839
+ const isVertical = labelPosition === "top" || labelPosition === "bottom";
3840
+ const labelEl = label ? /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { className: "text-sm text-[var(--color-text)]", children: label }) : null;
3841
+ const toggleEl = /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
3842
+ "button",
3843
+ {
3844
+ type: "button",
3845
+ role: "switch",
3846
+ "aria-label": ariaLabel,
3847
+ "aria-checked": checked,
3848
+ disabled,
3849
+ onClick: () => !disabled && onChange?.(!checked),
3850
+ className: cn(
3851
+ "relative inline-flex items-center rounded-full transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-[var(--color-brand)]/20",
3852
+ trackSize,
3853
+ checked ? "bg-[var(--color-brand)]" : "bg-[var(--color-border)]",
3854
+ disabled ? "cursor-not-allowed" : "cursor-pointer"
3855
+ ),
3856
+ children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { className: cn("inline-block rounded-full bg-[var(--color-surface)] shadow-sm transition-transform duration-200", thumbSize, checked ? translate : "translate-x-0.5") })
3857
+ }
3858
+ );
3859
+ const content = labelPosition === "right" ? /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(import_jsx_runtime36.Fragment, { children: [
3860
+ toggleEl,
3861
+ labelEl
3862
+ ] }) : labelPosition === "top" ? /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(import_jsx_runtime36.Fragment, { children: [
3863
+ labelEl,
3864
+ toggleEl
3865
+ ] }) : labelPosition === "bottom" ? /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(import_jsx_runtime36.Fragment, { children: [
3866
+ toggleEl,
3867
+ labelEl
3868
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(import_jsx_runtime36.Fragment, { children: [
3869
+ labelEl,
3870
+ toggleEl
3871
+ ] });
3872
+ return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { "data-ds-component": "toggle", className: cn(fullWidth ? "flex w-full items-center justify-between" : "inline-flex items-center", isVertical && "flex-col items-start", gap, disabled && "opacity-50", className), children: content });
3873
+ }
3874
+
3875
+ // src/theme/theme.tsx
3876
+ var import_react25 = require("react");
3877
+ var import_jsx_runtime37 = require("react/jsx-runtime");
3878
+ var variableMap = {
3879
+ background: "--color-background",
3880
+ surface: "--color-surface",
3881
+ surfaceMuted: "--color-surface-muted",
3882
+ text: "--color-text",
3883
+ textMuted: "--color-text-muted",
3884
+ border: "--color-border",
3885
+ brand: "--color-brand",
3886
+ brandHover: "--color-brand-hover",
3887
+ brandActive: "--color-brand-active",
3888
+ brandForeground: "--color-brand-foreground",
3889
+ secondary: "--color-secondary",
3890
+ secondaryHover: "--color-secondary-hover",
3891
+ secondaryActive: "--color-secondary-active",
3892
+ secondaryForeground: "--color-secondary-foreground",
3893
+ focus: "--color-focus",
3894
+ info: "--color-info",
3895
+ success: "--color-success",
3896
+ warning: "--color-warning",
3897
+ danger: "--color-danger",
3898
+ tooltip: "--color-tooltip",
3899
+ accentYellow: "--color-accent-yellow",
3900
+ accentMint: "--color-accent-mint",
3901
+ accentSky: "--color-accent-sky",
3902
+ accentLavender: "--color-accent-lavender",
3903
+ accentCoral: "--color-accent-coral",
3904
+ radiusControl: "--radius-control",
3905
+ radiusCard: "--radius-card",
3906
+ radiusPanel: "--radius-panel",
3907
+ shadowSm: "--shadow-sm",
3908
+ shadowMd: "--shadow-md",
3909
+ shadowLg: "--shadow-lg",
3910
+ shadowPanel: "--shadow-panel",
3911
+ fontSans: "--font-sans"
3912
+ };
3913
+ var defaultThemeTokens = {
3914
+ background: "hsl(220 25% 98%)",
3915
+ surface: "#ffffff",
3916
+ surfaceMuted: "hsl(220 15% 95%)",
3917
+ text: "hsl(220 20% 12%)",
3918
+ textMuted: "hsl(220 10% 50%)",
3919
+ border: "hsl(220 18% 90%)",
3920
+ brand: "hsl(217 91% 53%)",
3921
+ brandHover: "hsl(217 91% 47%)",
3922
+ brandActive: "hsl(217 91% 41%)",
3923
+ brandForeground: "#ffffff",
3924
+ secondary: "hsl(220 15% 95%)",
3925
+ secondaryHover: "hsl(220 15% 92%)",
3926
+ secondaryActive: "hsl(220 15% 88%)",
3927
+ secondaryForeground: "hsl(220 20% 12%)",
3928
+ focus: "hsl(217 91% 53%)",
3929
+ info: "hsl(200 90% 45%)",
3930
+ success: "hsl(145 65% 38%)",
3931
+ warning: "hsl(38 92% 50%)",
3932
+ danger: "hsl(0 72% 51%)",
3933
+ tooltip: "#1f2a44",
3934
+ accentYellow: "#f8e85d",
3935
+ accentMint: "#bfe4d2",
3936
+ accentSky: "#b9d8ef",
3937
+ accentLavender: "#cec4f5",
3938
+ accentCoral: "#f3a08b",
3939
+ radiusControl: "8px",
3940
+ radiusCard: "16px",
3941
+ radiusPanel: "16px",
3942
+ shadowSm: "0 1px 2px rgb(15 23 42 / 0.06)",
3943
+ shadowMd: "0 8px 24px rgb(15 23 42 / 0.10)",
3944
+ shadowLg: "0 18px 50px rgb(15 23 42 / 0.16)",
3945
+ shadowPanel: "0 8px 24px rgb(15 23 42 / 0.10)",
3946
+ fontSans: "'Plus Jakarta Sans', ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif"
3947
+ };
3948
+ function themeTokensToCss(tokens) {
3949
+ return Object.entries(tokens).filter(([, value]) => value != null && value !== "").map(([key, value]) => `${variableMap[key]}: ${value};`).join("\n");
3950
+ }
3951
+ function createProjectThemeTokens(project) {
3952
+ return {
3953
+ background: project.background,
3954
+ surface: project.surface,
3955
+ surfaceMuted: project.surfaceMuted,
3956
+ text: project.text,
3957
+ textMuted: project.textMuted,
3958
+ border: project.border,
3959
+ brand: project.primary,
3960
+ brandHover: project.primaryHover ?? project.primary,
3961
+ brandActive: project.primaryActive ?? project.primaryHover ?? project.primary,
3962
+ brandForeground: project.onPrimary,
3963
+ secondary: project.secondary,
3964
+ secondaryHover: project.secondaryHover ?? project.secondary,
3965
+ secondaryActive: project.secondaryActive ?? project.secondaryHover ?? project.secondary,
3966
+ secondaryForeground: project.onSecondary,
3967
+ focus: project.focus ?? project.primary,
3968
+ info: project.info,
3969
+ success: project.success,
3970
+ warning: project.warning,
3971
+ danger: project.danger,
3972
+ tooltip: project.tooltip,
3973
+ radiusControl: project.radiusControl,
3974
+ radiusCard: project.radiusCard,
3975
+ radiusPanel: project.radiusPanel,
3976
+ shadowSm: project.shadowSm,
3977
+ shadowMd: project.shadowMd,
3978
+ shadowLg: project.shadowLg,
3979
+ shadowPanel: project.shadowMd,
3980
+ fontSans: project.fontSans
3981
+ };
3982
+ }
3983
+ function asCssVariable(variableName) {
3984
+ const normalized = variableName.startsWith("--") ? variableName : `--${variableName}`;
3985
+ return `var(${normalized})`;
3986
+ }
3987
+ function createCssVariableTheme(map) {
3988
+ const project = Object.fromEntries(
3989
+ Object.entries(map).map(([key, variableName]) => [key, variableName ? asCssVariable(variableName) : void 0])
3990
+ );
3991
+ return createProjectThemeTokens(project);
3992
+ }
3993
+ function DThemeProvider({ children, tokens = {}, radius = "inherit", mode = "inherit" }) {
3994
+ (0, import_react25.useEffect)(() => {
3995
+ if (typeof document === "undefined") return;
3996
+ const root = document.documentElement;
3997
+ const previousMode = root.getAttribute("data-ds-mode");
3998
+ const previousRadius = root.getAttribute("data-theme-radius");
3999
+ const previous = /* @__PURE__ */ new Map();
4000
+ Object.entries(tokens).forEach(([key, value]) => {
4001
+ if (value == null || value === "") return;
4002
+ const variable = variableMap[key];
4003
+ previous.set(variable, root.style.getPropertyValue(variable));
4004
+ root.style.setProperty(variable, value);
4005
+ });
4006
+ if (mode !== "inherit") root.setAttribute("data-ds-mode", mode);
4007
+ if (radius !== "inherit") root.setAttribute("data-theme-radius", radius.toUpperCase());
4008
+ return () => {
4009
+ previous.forEach((value, variable) => {
4010
+ if (value) root.style.setProperty(variable, value);
4011
+ else root.style.removeProperty(variable);
4012
+ });
4013
+ if (mode !== "inherit") {
4014
+ if (previousMode == null) root.removeAttribute("data-ds-mode");
4015
+ else root.setAttribute("data-ds-mode", previousMode);
4016
+ }
4017
+ if (radius !== "inherit") {
4018
+ if (previousRadius == null) root.removeAttribute("data-theme-radius");
4019
+ else root.setAttribute("data-theme-radius", previousRadius);
4020
+ }
4021
+ };
4022
+ }, [mode, radius, tokens]);
4023
+ return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_jsx_runtime37.Fragment, { children });
4024
+ }
4025
+
4026
+ // src/avatar/avatar.tsx
4027
+ var import_jsx_runtime38 = require("react/jsx-runtime");
4028
+ var sizeClass = { xs: "size-6 text-[9px]", sm: "size-8 text-xs", md: "size-10 text-sm", lg: "size-12 text-base", xl: "size-16 text-lg" };
4029
+ var dotSize = { xs: "size-1.5", sm: "size-2", md: "size-2.5", lg: "size-3", xl: "size-3.5" };
4030
+ var statusClass = { online: "bg-[var(--color-success)]", offline: "bg-[var(--color-text-muted)]", busy: "bg-[var(--color-danger)]", away: "bg-[var(--color-warning)]" };
4031
+ function initials(name) {
4032
+ return name?.trim().split(/\s+/).slice(0, 2).map((part) => part[0]?.toUpperCase()).join("") || "?";
4033
+ }
4034
+ function DAvatar({ src, alt, name, fallback, size = "md", status, className, ...props }) {
4035
+ return /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: cn("relative inline-flex shrink-0", className), ...props, children: [
4036
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: cn("grid place-items-center overflow-hidden rounded-full border border-[var(--color-border)] bg-[var(--color-surface-muted)] font-semibold text-[var(--color-text-muted)]", sizeClass[size]), children: src ? /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("img", { src, alt: alt ?? name ?? "", className: "size-full object-cover" }) : fallback ?? initials(name) }),
4037
+ status ? /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("span", { "aria-label": status, className: cn("absolute bottom-0 right-0 rounded-full ring-2 ring-[var(--color-surface)]", dotSize[size], statusClass[status]) }) : null
4038
+ ] });
4039
+ }
4040
+
4041
+ // src/tooltip/tooltip.tsx
4042
+ var import_react26 = require("react");
4043
+ var import_jsx_runtime39 = require("react/jsx-runtime");
4044
+ var placementClass = {
4045
+ top: "bottom-full left-1/2 mb-2 -translate-x-1/2",
4046
+ bottom: "left-1/2 top-full mt-2 -translate-x-1/2",
4047
+ left: "right-full top-1/2 mr-2 -translate-y-1/2",
4048
+ right: "left-full top-1/2 ml-2 -translate-y-1/2"
4049
+ };
4050
+ function DTooltip({ content, children, placement = "top", className, delayMs = 120 }) {
4051
+ const id = (0, import_react26.useId)();
4052
+ const [open, setOpen] = (0, import_react26.useState)(false);
4053
+ const timerRef = (0, import_react26.useRef)(null);
4054
+ const child = children;
4055
+ const clearTimer = () => {
4056
+ if (timerRef.current !== null) {
4057
+ clearTimeout(timerRef.current);
4058
+ timerRef.current = null;
4059
+ }
4060
+ };
4061
+ const show = () => {
4062
+ clearTimer();
4063
+ timerRef.current = setTimeout(() => {
4064
+ timerRef.current = null;
4065
+ setOpen(true);
4066
+ }, delayMs);
4067
+ };
4068
+ const hide = () => {
4069
+ clearTimer();
4070
+ setOpen(false);
4071
+ };
4072
+ (0, import_react26.useEffect)(() => clearTimer, []);
4073
+ const trigger = (0, import_react26.cloneElement)(child, {
4074
+ "aria-describedby": open ? id : child.props["aria-describedby"]
4075
+ });
4076
+ return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(
4077
+ "span",
4078
+ {
4079
+ className: "relative inline-flex",
4080
+ onMouseEnter: show,
4081
+ onMouseLeave: hide,
4082
+ onFocus: () => {
4083
+ clearTimer();
4084
+ setOpen(true);
4085
+ },
4086
+ onBlur: hide,
4087
+ children: [
4088
+ trigger,
4089
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
4090
+ "span",
4091
+ {
4092
+ id,
4093
+ role: "tooltip",
4094
+ className: cn(
4095
+ "pointer-events-none absolute z-[100] w-max max-w-64 rounded-lg bg-[var(--color-tooltip)] px-2.5 py-1.5 text-xs leading-relaxed text-white shadow-lg transition-all duration-150",
4096
+ placementClass[placement],
4097
+ open ? "visible opacity-100" : "invisible opacity-0",
4098
+ className
4099
+ ),
4100
+ children: content
4101
+ }
4102
+ )
4103
+ ]
4104
+ }
4105
+ );
4106
+ }
4107
+
4108
+ // src/separator/separator.tsx
4109
+ var import_jsx_runtime40 = require("react/jsx-runtime");
4110
+ function DSeparator({ orientation = "horizontal", decorative = true, className, ...props }) {
4111
+ return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("div", { role: decorative ? "none" : "separator", "aria-orientation": decorative ? void 0 : orientation, className: cn("shrink-0 bg-[var(--color-border)]", orientation === "horizontal" ? "h-px w-full" : "h-full min-h-4 w-px", className), ...props });
4112
+ }
4113
+
4114
+ // src/spinner/spinner.tsx
4115
+ var import_jsx_runtime41 = require("react/jsx-runtime");
4116
+ var sizes = { sm: "size-3.5 border-2", md: "size-5 border-2", lg: "size-8 border-[3px]" };
4117
+ function DSpinner({ size = "md", label = "Loading", className, ...props }) {
4118
+ return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("span", { role: "status", "aria-label": label, className: cn("inline-block animate-spin rounded-full border-current border-t-transparent text-[var(--color-brand)]", sizes[size], className), ...props });
4119
+ }
4120
+
4121
+ // src/pagination/pagination.tsx
4122
+ var import_jsx_runtime42 = require("react/jsx-runtime");
4123
+ function getPaginationItems(page, total, sibling = 1) {
4124
+ if (total <= 7) return Array.from({ length: Math.max(total, 0) }, (_, i) => i + 1);
4125
+ const start = Math.max(2, page - sibling);
4126
+ const end = Math.min(total - 1, page + sibling);
4127
+ const items = [1];
4128
+ if (start > 2) items.push("ellipsis");
4129
+ for (let i = start; i <= end; i += 1) items.push(i);
4130
+ if (end < total - 1) items.push("ellipsis");
4131
+ items.push(total);
4132
+ return items;
4133
+ }
4134
+ var pageButtonBase = "grid size-9 appearance-none place-items-center rounded-lg text-sm font-medium outline-none transition-colors duration-150 focus-visible:ring-2 focus-visible:ring-[var(--color-focus)]/25 disabled:cursor-not-allowed disabled:opacity-40";
4135
+ function DPagination({
4136
+ page,
4137
+ totalPages,
4138
+ onChange,
4139
+ siblingCount = 1,
4140
+ disabled = false,
4141
+ className
4142
+ }) {
4143
+ const { t } = useDLocalization();
4144
+ const go = (next) => {
4145
+ if (!disabled && next >= 1 && next <= totalPages && next !== page) onChange(next);
4146
+ };
4147
+ return /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("nav", { "data-ds-component": "pagination", "aria-label": t("pagination.label"), className: cn("flex items-center gap-1", className), children: [
4148
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
4149
+ "button",
4150
+ {
4151
+ type: "button",
4152
+ "aria-label": t("pagination.previous"),
4153
+ disabled: disabled || page <= 1,
4154
+ onClick: () => go(page - 1),
4155
+ className: cn(pageButtonBase, "border border-[var(--color-border)] bg-[var(--color-surface)] text-[var(--color-text-muted)] hover:bg-[var(--color-surface-muted)]"),
4156
+ children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(ChevronLeftIcon, { size: 16 })
4157
+ }
4158
+ ),
4159
+ getPaginationItems(page, totalPages, siblingCount).map((item, index) => item === "ellipsis" ? /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("span", { "aria-hidden": "true", className: "grid size-9 place-items-center text-[var(--color-text-muted)]", children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(MoreHorizontalIcon, { size: 16 }) }, `e-${index}`) : /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
4160
+ "button",
4161
+ {
4162
+ type: "button",
4163
+ "aria-current": item === page ? "page" : void 0,
4164
+ onClick: () => go(item),
4165
+ className: cn(
4166
+ pageButtonBase,
4167
+ item === page ? "border border-[var(--color-brand)] bg-[var(--color-brand)] text-[var(--color-brand-foreground)]" : "border border-[var(--color-border)] bg-[var(--color-surface)] text-[var(--color-text)] hover:bg-[var(--color-surface-muted)]"
4168
+ ),
4169
+ children: item
4170
+ },
4171
+ item
4172
+ )),
4173
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
4174
+ "button",
4175
+ {
4176
+ type: "button",
4177
+ "aria-label": t("pagination.next"),
4178
+ disabled: disabled || page >= totalPages,
4179
+ onClick: () => go(page + 1),
4180
+ className: cn(pageButtonBase, "border border-[var(--color-border)] bg-[var(--color-surface)] text-[var(--color-text-muted)] hover:bg-[var(--color-surface-muted)]"),
4181
+ children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(ChevronRightIcon, { size: 16 })
4182
+ }
4183
+ )
4184
+ ] });
4185
+ }
4186
+
4187
+ // src/tabs/tabs.tsx
4188
+ var import_react27 = require("react");
4189
+ var import_jsx_runtime43 = require("react/jsx-runtime");
4190
+ var TabsContext = (0, import_react27.createContext)(null);
4191
+ function useTabs() {
4192
+ const ctx = (0, import_react27.useContext)(TabsContext);
4193
+ if (!ctx) throw new Error("DTabs components must be inside <DTabs>.");
4194
+ return ctx;
4195
+ }
4196
+ function DTabs({ value, defaultValue, onValueChange, children, className, ...props }) {
4197
+ const [internal, setInternal] = (0, import_react27.useState)(defaultValue);
4198
+ const current = value ?? internal;
4199
+ const baseId = (0, import_react27.useId)();
4200
+ const setValue = (next) => {
4201
+ if (value === void 0) setInternal(next);
4202
+ onValueChange?.(next);
4203
+ };
4204
+ return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(TabsContext.Provider, { value: { value: current, setValue, baseId }, children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { "data-ds-component": "tabs", className, ...props, children }) });
4205
+ }
4206
+ function DTabsList({ className, onKeyDown, ...props }) {
4207
+ return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
4208
+ "div",
4209
+ {
4210
+ role: "tablist",
4211
+ className: cn("inline-flex items-center rounded-xl bg-[var(--color-surface-muted)] p-1", className),
4212
+ onKeyDown: (event) => {
4213
+ onKeyDown?.(event);
4214
+ if (event.defaultPrevented || !["ArrowLeft", "ArrowRight", "Home", "End"].includes(event.key)) return;
4215
+ const tabs = Array.from(event.currentTarget.querySelectorAll("[role=tab]:not(:disabled)"));
4216
+ if (!tabs.length) return;
4217
+ const index = tabs.indexOf(document.activeElement);
4218
+ const next = event.key === "Home" ? 0 : event.key === "End" ? tabs.length - 1 : event.key === "ArrowRight" ? (index + 1 + tabs.length) % tabs.length : (index - 1 + tabs.length) % tabs.length;
4219
+ event.preventDefault();
4220
+ tabs[next]?.focus();
4221
+ tabs[next]?.click();
4222
+ },
4223
+ ...props
4224
+ }
4225
+ );
4226
+ }
4227
+ function DTabsTrigger({ value, disabled, className, children, ...props }) {
4228
+ const ctx = useTabs();
4229
+ const active = ctx.value === value;
4230
+ return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
4231
+ "button",
4232
+ {
4233
+ type: "button",
4234
+ role: "tab",
4235
+ id: `${ctx.baseId}-tab-${value}`,
4236
+ "aria-selected": active,
4237
+ "aria-controls": `${ctx.baseId}-panel-${value}`,
4238
+ disabled,
4239
+ onClick: () => ctx.setValue(value),
4240
+ className: cn(
4241
+ "appearance-none rounded-lg border-0 bg-transparent px-3 py-1.5 text-sm font-medium outline-none transition-all duration-150 focus-visible:ring-2 focus-visible:ring-[var(--color-focus)]/25",
4242
+ active ? "bg-[var(--color-surface)] text-[var(--color-text)] shadow-sm" : "text-[var(--color-text-muted)] hover:text-[var(--color-text)]",
4243
+ disabled && "cursor-not-allowed opacity-40",
4244
+ className
4245
+ ),
4246
+ ...props,
4247
+ children
4248
+ }
4249
+ );
4250
+ }
4251
+ function DTabsContent({ value, className, ...props }) {
4252
+ const ctx = useTabs();
4253
+ if (ctx.value !== value) return null;
4254
+ return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { role: "tabpanel", id: `${ctx.baseId}-panel-${value}`, "aria-labelledby": `${ctx.baseId}-tab-${value}`, className, ...props });
4255
+ }
4256
+
4257
+ // src/accordion/accordion.tsx
4258
+ var import_react28 = require("react");
4259
+ var import_jsx_runtime44 = require("react/jsx-runtime");
4260
+ var AccordionContext = (0, import_react28.createContext)(null);
4261
+ function useAccordion() {
4262
+ const context = (0, import_react28.useContext)(AccordionContext);
4263
+ if (!context) throw new Error("DAccordionItem must be inside <DAccordion>.");
4264
+ return context;
4265
+ }
4266
+ function DAccordion({
4267
+ type = "single",
4268
+ value,
4269
+ defaultValue = [],
4270
+ onValueChange,
4271
+ variant = "default",
4272
+ className,
4273
+ ...props
4274
+ }) {
4275
+ const [internal, setInternal] = (0, import_react28.useState)(defaultValue);
4276
+ const current = value ?? internal;
4277
+ const baseId = (0, import_react28.useId)();
4278
+ const toggle = (itemValue) => {
4279
+ const next = current.includes(itemValue) ? current.filter((item) => item !== itemValue) : type === "multiple" ? [...current, itemValue] : [itemValue];
4280
+ if (value === void 0) setInternal(next);
4281
+ onValueChange?.(next);
4282
+ };
4283
+ return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(AccordionContext.Provider, { value: { open: current, toggle, baseId, variant }, children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
4284
+ "div",
4285
+ {
4286
+ "data-ds-component": "accordion",
4287
+ "data-accordion-variant": variant,
4288
+ className: cn(
4289
+ variant === "card" && "overflow-hidden rounded-[var(--radius-card)] border border-[var(--color-border)] bg-[var(--color-surface)]",
4290
+ variant === "separated" && "space-y-2",
4291
+ className
4292
+ ),
4293
+ ...props
4294
+ }
4295
+ ) });
4296
+ }
4297
+ function DAccordionItem({ value, title, disabled, className, children, ...props }) {
4298
+ const context = useAccordion();
4299
+ const open = context.open.includes(value);
4300
+ const id = `${context.baseId}-${value.replace(/[^a-zA-Z0-9_-]/g, "-")}`;
4301
+ const triggerId = `${id}-trigger`;
4302
+ const contentId = `${id}-content`;
4303
+ return /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)(
4304
+ "div",
4305
+ {
4306
+ className: cn(
4307
+ context.variant === "separator" && "border-b border-[var(--color-border)] last:border-b-0",
4308
+ context.variant === "card" && "border-b border-[var(--color-border)] px-4 last:border-b-0",
4309
+ context.variant === "separated" && "overflow-hidden rounded-[var(--radius-control)] border border-[var(--color-border)] bg-[var(--color-surface)] px-4",
4310
+ (context.variant === "default" || context.variant === "separator") && "px-0",
4311
+ className
4312
+ ),
4313
+ ...props,
4314
+ children: [
4315
+ /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)(
4316
+ "button",
4317
+ {
4318
+ id: triggerId,
4319
+ type: "button",
4320
+ disabled,
4321
+ "aria-expanded": open,
4322
+ "aria-controls": contentId,
4323
+ onClick: () => context.toggle(value),
4324
+ className: "group flex w-full appearance-none items-center justify-between gap-4 border-0 bg-transparent py-3 text-left text-sm font-medium text-[var(--color-text)] outline-none transition-colors duration-150 hover:text-[var(--color-brand)] focus-visible:ring-2 focus-visible:ring-[var(--color-focus)]/25 disabled:cursor-not-allowed disabled:opacity-40",
4325
+ children: [
4326
+ /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("span", { children: title }),
4327
+ /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
4328
+ ChevronDownIcon,
4329
+ {
4330
+ size: 17,
4331
+ className: cn("shrink-0 text-[var(--color-text-muted)] transition-transform duration-200 ease-out group-hover:text-current", open && "rotate-180")
4332
+ }
4333
+ )
4334
+ ]
4335
+ }
4336
+ ),
4337
+ /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
4338
+ "div",
4339
+ {
4340
+ id: contentId,
4341
+ role: "region",
4342
+ "aria-labelledby": triggerId,
4343
+ "aria-hidden": !open,
4344
+ className: cn(
4345
+ "grid transition-[grid-template-rows,opacity] duration-200 ease-out motion-reduce:transition-none",
4346
+ open ? "grid-rows-[1fr] opacity-100" : "grid-rows-[0fr] opacity-0"
4347
+ ),
4348
+ children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("div", { className: "min-h-0 overflow-hidden", children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("div", { className: "pb-4 text-sm leading-relaxed text-[var(--color-text-muted)]", children }) })
4349
+ }
4350
+ )
4351
+ ]
4352
+ }
4353
+ );
4354
+ }
4355
+
4356
+ // src/breadcrumb/breadcrumb.tsx
4357
+ var import_jsx_runtime45 = require("react/jsx-runtime");
4358
+ function DBreadcrumb({ className, ...props }) {
4359
+ return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("nav", { "aria-label": "DBreadcrumb", className, ...props });
4360
+ }
4361
+ function DBreadcrumbList({ className, ...props }) {
4362
+ return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("ol", { className: cn("flex flex-wrap items-center gap-2 text-sm text-[var(--color-text-muted)]", className), ...props });
4363
+ }
4364
+ function DBreadcrumbItem({ className, ...props }) {
4365
+ return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("li", { className: cn("inline-flex items-center gap-2", className), ...props });
4366
+ }
4367
+ function DBreadcrumbLink({ active = false, className, ...props }) {
4368
+ return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("a", { "aria-current": active ? "page" : void 0, className: cn(active ? "font-medium text-[var(--color-text)]" : "transition-colors hover:text-[var(--color-text)]", className), ...props });
4369
+ }
4370
+ function DBreadcrumbSeparator({ children = "/", className, ...props }) {
4371
+ return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("span", { "aria-hidden": "true", className: cn("text-[var(--color-border)]", className), ...props, children });
4372
+ }
4373
+ // Annotate the CommonJS export names for ESM import in node:
4374
+ 0 && (module.exports = {
4375
+ DAccordion,
4376
+ DAccordionItem,
4377
+ DAlert,
4378
+ DAvatar,
4379
+ DBadge,
4380
+ DBreadcrumb,
4381
+ DBreadcrumbItem,
4382
+ DBreadcrumbLink,
4383
+ DBreadcrumbList,
4384
+ DBreadcrumbSeparator,
4385
+ DButton,
4386
+ DCard,
4387
+ DCardContent,
4388
+ DCardFooter,
4389
+ DCardHeader,
4390
+ DCardSkeleton,
4391
+ DCheckbox,
4392
+ DCombobox,
4393
+ DConfirmDialog,
4394
+ DConnectionError,
4395
+ DCurrencyInput,
4396
+ DDataTable,
4397
+ DDatePicker,
4398
+ DDateRangeFilter,
4399
+ DDecimalInput,
4400
+ DDialog,
4401
+ DDropdown,
4402
+ DEmptyState,
4403
+ DExportButton,
4404
+ DForm,
4405
+ DFormField,
4406
+ DFormSkeleton,
4407
+ DInfoNote,
4408
+ DInput,
4409
+ DLoadingIndicator,
4410
+ DLoadingOverlay,
4411
+ DLocalizationProvider,
4412
+ DNotificationPanel,
4413
+ DPagination,
4414
+ DProgress,
4415
+ DRadio,
4416
+ DRangeDatePicker,
4417
+ DSearchInput,
4418
+ DSelect,
4419
+ DSelectFilter,
4420
+ DSeparator,
4421
+ DSkeleton,
4422
+ DSpinner,
4423
+ DSplashScreen,
4424
+ DStatusFilter,
4425
+ DTableSkeleton,
4426
+ DTabs,
4427
+ DTabsContent,
4428
+ DTabsList,
4429
+ DTabsTrigger,
4430
+ DTextarea,
4431
+ DThemeProvider,
4432
+ DTimePicker,
4433
+ DToastContainer,
4434
+ DToastProvider,
4435
+ DToggle,
4436
+ DTooltip,
4437
+ DValidationMessage,
4438
+ DropdownContext,
4439
+ accepted,
4440
+ cn,
4441
+ createCssVariableTheme,
4442
+ createDTranslator,
4443
+ createProjectThemeTokens,
4444
+ customValidation,
4445
+ date,
4446
+ defaultThemeTokens,
4447
+ email,
4448
+ enMessages,
4449
+ formatCurrencyInputValue,
4450
+ getLocalizedMonthNames,
4451
+ getLocalizedWeekdayNames,
4452
+ getPaginationItems,
4453
+ getPaginationPages,
4454
+ idMessages,
4455
+ integer,
4456
+ maxLength,
4457
+ maxValue,
4458
+ minLength,
4459
+ minValue,
4460
+ normalizeDecimalInput,
4461
+ oneOf,
4462
+ parseCurrencyInputValue,
4463
+ pattern,
4464
+ required,
4465
+ sameAs,
4466
+ selectOptionsFromChildren,
4467
+ themeTokensToCss,
4468
+ time,
4469
+ url,
4470
+ useDFormField,
4471
+ useDLocalization,
4472
+ useDropdown,
4473
+ useDropdownClose,
4474
+ useToast,
4475
+ validateValue
4476
+ });
4477
+ //# sourceMappingURL=index.cjs.map