@digvation/ui 1.1.0 → 1.2.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 CHANGED
@@ -190,34 +190,54 @@ var sizeClasses = {
190
190
  lg: "h-12 gap-2 px-6 text-base",
191
191
  icon: "size-10 p-0"
192
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
- });
193
+ var DButton = (0, import_react.forwardRef)(
194
+ function DButton2({
195
+ className,
196
+ variant = "primary",
197
+ size = "md",
198
+ loading = false,
199
+ leftIcon,
200
+ rightIcon,
201
+ fullWidth = false,
202
+ disabled,
203
+ type = "button",
204
+ children,
205
+ ...props
206
+ }, ref) {
207
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
208
+ "button",
209
+ {
210
+ ref,
211
+ "data-ds-component": "button",
212
+ type,
213
+ disabled: disabled || loading,
214
+ "aria-busy": loading || void 0,
215
+ className: cn(
216
+ "cursor-pointer inline-flex items-center justify-center rounded-(--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-(--color-focus)/25 focus-visible:ring-offset-2 focus-visible:ring-offset-(--color-background) active:scale-[0.98] motion-reduce:transform-none disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50",
217
+ variantClasses2[variant],
218
+ variant !== "link" && sizeClasses[size],
219
+ variant === "link" && size === "sm" && "text-xs",
220
+ variant === "link" && size === "md" && "text-sm",
221
+ variant === "link" && size === "lg" && "text-base",
222
+ fullWidth && "w-full",
223
+ className
224
+ ),
225
+ ...props,
226
+ children: [
227
+ loading ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
228
+ "span",
229
+ {
230
+ className: "size-4 animate-spin rounded-full border-2 border-current border-t-transparent",
231
+ "aria-hidden": "true"
232
+ }
233
+ ) : leftIcon,
234
+ children ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { children }) : null,
235
+ !loading ? rightIcon : null
236
+ ]
237
+ }
238
+ );
239
+ }
240
+ );
221
241
 
222
242
  // src/card/card.tsx
223
243
  var import_jsx_runtime4 = require("react/jsx-runtime");
@@ -243,21 +263,76 @@ function DCardFooter({ className, ...props }) {
243
263
  // src/checkbox/checkbox.tsx
244
264
  var import_react2 = require("react");
245
265
  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",
266
+ var DCheckbox = (0, import_react2.forwardRef)(
267
+ function DCheckbox2({ className, disabled, ...props }, ref) {
268
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
269
+ "label",
251
270
  {
252
- d: "m2 6 2.4 2.4L10 2.8",
253
- fill: "none",
254
- stroke: "currentColor",
255
- strokeLinecap: "round",
256
- strokeWidth: "1.8"
271
+ "data-ds-component": "checkbox",
272
+ className: cn(
273
+ "inline-flex size-4.5 shrink-0 cursor-pointer",
274
+ disabled && "cursor-not-allowed",
275
+ className
276
+ ),
277
+ children: [
278
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
279
+ "input",
280
+ {
281
+ ref,
282
+ type: "checkbox",
283
+ disabled,
284
+ className: "peer sr-only",
285
+ ...props
286
+ }
287
+ ),
288
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
289
+ "span",
290
+ {
291
+ "aria-hidden": "true",
292
+ className: cn(
293
+ "grid size-4.5 shrink-0 place-items-center",
294
+ "rounded-(--radius-control)",
295
+ "border-[1.5px] border-(--color-brand)",
296
+ "bg-(--color-surface)",
297
+ "text-(--color-brand-foreground)",
298
+ "transition-colors",
299
+ // Checked
300
+ "peer-checked:border-(--color-brand)",
301
+ "peer-checked:bg-(--color-brand)",
302
+ "peer-checked:[&>svg]:opacity-100",
303
+ // Focus
304
+ "peer-focus-visible:ring-2",
305
+ "peer-focus-visible:ring-(--color-brand)/20",
306
+ // Disabled
307
+ "peer-disabled:cursor-not-allowed",
308
+ "peer-disabled:opacity-50"
309
+ ),
310
+ children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
311
+ "svg",
312
+ {
313
+ viewBox: "0 0 14 14",
314
+ className: "size-3 opacity-0 transition-opacity",
315
+ "aria-hidden": "true",
316
+ children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
317
+ "path",
318
+ {
319
+ d: "m2.5 8 2.4 2.4L12 3.4",
320
+ fill: "none",
321
+ stroke: "white",
322
+ strokeLinecap: "round",
323
+ strokeLinejoin: "round",
324
+ strokeWidth: "1.8"
325
+ }
326
+ )
327
+ }
328
+ )
329
+ }
330
+ )
331
+ ]
257
332
  }
258
- ) }) })
259
- ] });
260
- });
333
+ );
334
+ }
335
+ );
261
336
 
262
337
  // src/combobox/combobox.tsx
263
338
  var import_react7 = require("react");
@@ -524,7 +599,8 @@ function DDropdown({
524
599
  if (!open) return;
525
600
  const outside = (event) => {
526
601
  const target = event.target;
527
- if (!referenceRef.current?.contains(target) && !floatingRef.current?.contains(target)) close();
602
+ if (!referenceRef.current?.contains(target) && !floatingRef.current?.contains(target))
603
+ close();
528
604
  };
529
605
  const escape = (event) => {
530
606
  if (closeOnEsc && event.key === "Escape") close();
@@ -553,7 +629,8 @@ function DDropdown({
553
629
  if (event.defaultPrevented) return;
554
630
  if (event.key === "Enter" || event.key === " ") {
555
631
  const target = event.target;
556
- if (target.tagName === "BUTTON" || target.tagName === "INPUT") return;
632
+ if (target.tagName === "BUTTON" || target.tagName === "INPUT")
633
+ return;
557
634
  event.preventDefault();
558
635
  event.stopPropagation();
559
636
  setOpen((value) => !value);
@@ -577,10 +654,13 @@ function DDropdown({
577
654
  onClick: (event) => {
578
655
  if (!closeOnItemClick) return;
579
656
  const target = event.target;
580
- if (target.closest("button, [role='option'], [role='menuitem'], a")) close();
657
+ if (target.closest(
658
+ "button, [role='option'], [role='menuitem'], a"
659
+ ))
660
+ close();
581
661
  },
582
662
  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",
663
+ "z-9999 min-w-35 overflow-hidden rounded-(--radius-panel) border border-(--color-border) bg-(--color-surface) shadow-(--shadow-lg) outline-none",
584
664
  contentPadding && "py-1",
585
665
  positioned && "animate-[dropdown-in_150ms_ease-out]",
586
666
  contentClassName
@@ -916,13 +996,33 @@ var INPUT_SIZE_STYLES = {
916
996
  // src/combobox/combobox.tsx
917
997
  var import_jsx_runtime8 = require("react/jsx-runtime");
918
998
  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
- ] });
999
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
1000
+ "svg",
1001
+ {
1002
+ viewBox: "0 0 24 24",
1003
+ fill: "none",
1004
+ stroke: "currentColor",
1005
+ strokeWidth: "2",
1006
+ className,
1007
+ children: [
1008
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("circle", { cx: "11", cy: "11", r: "7" }),
1009
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("path", { d: "m20 20-4-4" })
1010
+ ]
1011
+ }
1012
+ );
923
1013
  }
924
1014
  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" }) });
1015
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1016
+ "svg",
1017
+ {
1018
+ viewBox: "0 0 24 24",
1019
+ fill: "none",
1020
+ stroke: "currentColor",
1021
+ strokeWidth: "2",
1022
+ className: "size-3.5",
1023
+ children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("path", { d: "m18 6-12 12M6 6l12 12" })
1024
+ }
1025
+ );
926
1026
  }
927
1027
  function sameValue(left, right) {
928
1028
  return String(left ?? "") === String(right ?? "");
@@ -990,7 +1090,8 @@ function DCombobox({
990
1090
  return () => window.clearTimeout(timeout);
991
1091
  }, [debounceMs, fetchOptions, inputValue, onFetchError, open, refetchKey]);
992
1092
  (0, import_react7.useEffect)(() => {
993
- if (!fetchOptions || value == null || value === "" || sameValue(resolvedSelection?.value, value)) return;
1093
+ if (!fetchOptions || value == null || value === "" || sameValue(resolvedSelection?.value, value))
1094
+ return;
994
1095
  const requestId = ++resolveRequestIdRef.current;
995
1096
  void fetchOptions("").then((result) => {
996
1097
  if (requestId !== resolveRequestIdRef.current) return;
@@ -1001,12 +1102,16 @@ function DCombobox({
1001
1102
  const selectedOption = options.find((option) => sameValue(option.value, value)) ?? (sameValue(resolvedSelection?.value, value) ? resolvedSelection : null);
1002
1103
  const source = isAsync ? asyncOptions : options;
1003
1104
  const filtered = (0, import_react7.useMemo)(
1004
- () => isAsync ? source : source.filter((option) => String(option.label).toLocaleLowerCase().includes(inputValue.toLocaleLowerCase())),
1105
+ () => isAsync ? source : source.filter(
1106
+ (option) => String(option.label).toLocaleLowerCase().includes(inputValue.toLocaleLowerCase())
1107
+ ),
1005
1108
  [inputValue, isAsync, source]
1006
1109
  );
1007
1110
  (0, import_react7.useEffect)(() => {
1008
1111
  if (!open || inputValue) return;
1009
- const selectedIndex = filtered.findIndex((option) => sameValue(option.value, value));
1112
+ const selectedIndex = filtered.findIndex(
1113
+ (option) => sameValue(option.value, value)
1114
+ );
1010
1115
  setActiveIndex(selectedIndex >= 0 ? selectedIndex : 0);
1011
1116
  }, [filtered, inputValue, open, value]);
1012
1117
  const choose = (option) => {
@@ -1069,63 +1174,141 @@ function DCombobox({
1069
1174
  };
1070
1175
  const showIdle = Boolean(idleMessage && !inputValue && !isAsync);
1071
1176
  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
1177
+ label ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1178
+ "label",
1179
+ {
1180
+ htmlFor: id,
1181
+ className: cn(s.label, "w-fit font-medium text-(--color-text)"),
1182
+ children: label
1183
+ }
1184
+ ) : null,
1185
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1186
+ DDropdown,
1187
+ {
1188
+ matchWidth: true,
1189
+ open,
1190
+ onOpenChange: setOpen,
1191
+ contentRole: "listbox",
1192
+ contentPadding: false,
1193
+ contentClassName: "max-h-60 overflow-y-auto p-1.5",
1194
+ scrollBehavior,
1195
+ onClose: () => {
1196
+ setOpen(false);
1197
+ setInputValue("");
1198
+ },
1199
+ trigger: () => /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "relative", children: [
1200
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1201
+ SearchIcon,
1202
+ {
1203
+ className: cn(
1204
+ "pointer-events-none absolute top-1/2 -translate-y-1/2 text-(--color-text-muted)",
1205
+ s.iconLeft
1206
+ )
1207
+ }
1208
+ ),
1209
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1210
+ "input",
1211
+ {
1212
+ ref: inputRef,
1213
+ id,
1214
+ "aria-label": ariaLabel,
1215
+ role: "combobox",
1216
+ "aria-autocomplete": "list",
1217
+ "aria-expanded": open,
1218
+ "aria-invalid": Boolean(error) || void 0,
1219
+ "aria-controls": `${id}-listbox`,
1220
+ "aria-activedescendant": open && filtered[activeIndex] ? `${id}-option-${activeIndex}` : void 0,
1221
+ autoComplete: "off",
1222
+ type: "text",
1223
+ disabled,
1224
+ value: open ? inputValue : String(selectedOption?.label ?? ""),
1225
+ placeholder: selectedOption ? String(selectedOption.label) : resolvedPlaceholder,
1226
+ onClick: (event) => event.stopPropagation(),
1227
+ onFocus: () => {
1228
+ setOpen(true);
1229
+ const selectedIndex = filtered.findIndex(
1230
+ (option) => sameValue(option.value, value)
1231
+ );
1232
+ setActiveIndex(selectedIndex >= 0 ? selectedIndex : 0);
1233
+ },
1234
+ onChange: (event) => {
1235
+ const next = event.target.value;
1236
+ setInputValue(next);
1237
+ onSearchChange?.(next);
1238
+ setOpen(true);
1239
+ setActiveIndex(0);
1240
+ },
1241
+ onKeyDown: handleKeyDown,
1242
+ className: cn(
1243
+ "w-full rounded-lg border bg-(--color-surface) text-(--color-text) focus:border-(--color-brand) focus:outline-none focus:ring-2 focus:ring-(--color-brand)/20 disabled:cursor-not-allowed disabled:bg-(--color-surface-muted) disabled:opacity-50",
1244
+ s.input,
1245
+ "pl-10 pr-10",
1246
+ error ? "border-(--color-danger) focus:ring-(--color-danger)/20" : "border-(--color-border)"
1247
+ )
1248
+ }
1249
+ ),
1250
+ clearable && selectedOption && !disabled ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1251
+ "button",
1252
+ {
1253
+ type: "button",
1254
+ tabIndex: -1,
1255
+ "aria-label": t("combobox.clear"),
1256
+ onMouseDown: (event) => event.preventDefault(),
1257
+ onClick: (event) => {
1258
+ event.preventDefault();
1259
+ event.stopPropagation();
1260
+ clear();
1261
+ },
1262
+ className: cn(
1263
+ "absolute top-1/2 -translate-y-1/2 cursor-pointer flex size-5 shrink-0 items-center justify-center self-center rounded-md hover:bg-(--color-surface-muted) text-(--color-text-muted) transition-colors",
1264
+ s.clear
1265
+ ),
1266
+ children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ClearIcon, {})
1267
+ }
1268
+ ) : null
1269
+ ] }),
1270
+ 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-(--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-(--color-danger)", children: resolvedAsyncErrorMessage }) : showIdle ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "px-3 py-6 text-center text-sm text-(--color-text-muted)", children: idleMessage }) : filtered.length === 0 ? renderEmpty ? renderEmpty(inputValue) : allowCreate && inputValue.trim() ? renderCreateOption ? renderCreateOption(inputValue, create) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1271
+ "button",
1272
+ {
1273
+ type: "button",
1274
+ onMouseDown: (event) => event.preventDefault(),
1275
+ onClick: (event) => {
1276
+ event.stopPropagation();
1277
+ create();
1278
+ },
1279
+ className: "w-full rounded-lg px-3 py-2 text-left text-sm font-medium text-(--color-brand) hover:bg-(--color-surface-muted)",
1280
+ children: t("combobox.useValue", { value: inputValue.trim() })
1281
+ }
1282
+ ) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "px-3 py-6 text-center text-sm text-(--color-text-muted)", children: t("combobox.empty") }) : filtered.map((option, index) => {
1283
+ const isSelected = sameValue(option.value, value);
1284
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1285
+ "button",
1286
+ {
1287
+ id: `${id}-option-${index}`,
1288
+ type: "button",
1289
+ role: "option",
1290
+ "aria-selected": isSelected,
1291
+ disabled: option.disabled,
1292
+ onMouseEnter: () => setActiveIndex(index),
1293
+ onMouseDown: (event) => event.preventDefault(),
1294
+ onClick: (event) => {
1295
+ event.stopPropagation();
1296
+ choose(option);
1297
+ },
1298
+ className: cn(
1299
+ "cursor-pointer w-full rounded-lg px-3 py-2 text-left text-sm transition-colors hover:bg-(--color-surface-muted) disabled:cursor-not-allowed disabled:opacity-50",
1300
+ isSelected && "bg-(--color-brand)/10 font-medium text-(--color-brand)",
1301
+ index === activeIndex && !isSelected && "bg-(--color-surface-muted)"
1302
+ ),
1303
+ children: renderOption ? renderOption(option, isSelected) : option.label
1304
+ },
1305
+ String(option.value)
1306
+ );
1307
+ }) })
1308
+ }
1309
+ ),
1310
+ error ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { className: "text-xs text-(--color-danger)", children: error }) : null,
1311
+ !error && hint ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { className: "text-xs text-(--color-text-muted)", children: hint }) : null
1129
1312
  ] });
1130
1313
  }
1131
1314
 
@@ -1380,17 +1563,34 @@ function DConfirmDialog({ open, onClose, onConfirm, title, message, confirmLabel
1380
1563
  // src/connection-error/connection-error.tsx
1381
1564
  var import_jsx_runtime12 = require("react/jsx-runtime");
1382
1565
  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" }) });
1566
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1567
+ "svg",
1568
+ {
1569
+ viewBox: "0 0 24 24",
1570
+ fill: "none",
1571
+ stroke: "currentColor",
1572
+ strokeWidth: "2",
1573
+ className: "size-9",
1574
+ 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" })
1575
+ }
1576
+ );
1384
1577
  }
1385
- function DConnectionError({ onRetry, isRetrying = false, title, message, detail, diagnostics }) {
1578
+ function DConnectionError({
1579
+ onRetry,
1580
+ isRetrying = false,
1581
+ title,
1582
+ message,
1583
+ detail,
1584
+ diagnostics
1585
+ }) {
1386
1586
  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") }),
1587
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "fixed inset-0 z-99998 flex items-center justify-center bg-(--color-background) px-4", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "w-full max-w-sm text-center", children: [
1588
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "mx-auto mb-6 flex size-20 items-center justify-center rounded-full bg-(--color-danger)/10 text-(--color-danger)", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(OfflineIcon, {}) }),
1589
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("h2", { className: "mb-2 text-xl font-bold text-(--color-text)", children: title ?? t("connectionError.title") }),
1590
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { className: "mb-2 text-sm text-(--color-text-muted)", children: message ?? t("connectionError.message") }),
1591
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { className: "mb-8 text-xs text-(--color-text-muted)/70", children: detail ?? t("connectionError.detail") }),
1392
1592
  /* @__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
1593
+ diagnostics ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "mt-6 rounded-lg border border-(--color-border) bg-(--color-surface-muted)/50 p-3 text-left text-[11px] text-(--color-text-muted)", children: diagnostics }) : null
1394
1594
  ] }) });
1395
1595
  }
1396
1596
 
@@ -1441,7 +1641,13 @@ var HOURS = Array.from({ length: 24 }, (_, hour) => hour);
1441
1641
  var ITEM_HEIGHT = 44;
1442
1642
  var VISIBLE_ITEMS = 5;
1443
1643
  var WHEEL_PADDING = ITEM_HEIGHT * Math.floor(VISIBLE_ITEMS / 2);
1444
- function WheelColumn({ label, optionAriaLabel, options, selected, onSelect }) {
1644
+ function WheelColumn({
1645
+ label,
1646
+ optionAriaLabel,
1647
+ options,
1648
+ selected,
1649
+ onSelect
1650
+ }) {
1445
1651
  const scrollRef = (0, import_react9.useRef)(null);
1446
1652
  const settleTimerRef = (0, import_react9.useRef)(null);
1447
1653
  const selectedIndex = Math.max(0, options.indexOf(selected));
@@ -1449,16 +1655,24 @@ function WheelColumn({ label, optionAriaLabel, options, selected, onSelect }) {
1449
1655
  const node = scrollRef.current;
1450
1656
  if (!node) return;
1451
1657
  const top = selectedIndex * ITEM_HEIGHT;
1452
- if (typeof node.scrollTo === "function") node.scrollTo({ top, behavior: "auto" });
1658
+ if (typeof node.scrollTo === "function")
1659
+ node.scrollTo({ top, behavior: "auto" });
1453
1660
  else node.scrollTop = top;
1454
1661
  }, [selectedIndex]);
1455
- (0, import_react9.useEffect)(() => () => {
1456
- if (settleTimerRef.current !== null) window.clearTimeout(settleTimerRef.current);
1457
- }, []);
1662
+ (0, import_react9.useEffect)(
1663
+ () => () => {
1664
+ if (settleTimerRef.current !== null)
1665
+ window.clearTimeout(settleTimerRef.current);
1666
+ },
1667
+ []
1668
+ );
1458
1669
  const settleSelection = () => {
1459
1670
  const node = scrollRef.current;
1460
1671
  if (!node) return;
1461
- const index = Math.max(0, Math.min(options.length - 1, Math.round(node.scrollTop / ITEM_HEIGHT)));
1672
+ const index = Math.max(
1673
+ 0,
1674
+ Math.min(options.length - 1, Math.round(node.scrollTop / ITEM_HEIGHT))
1675
+ );
1462
1676
  const next = options[index];
1463
1677
  if (next !== void 0 && next !== selected) onSelect(next);
1464
1678
  };
@@ -1471,10 +1685,11 @@ function WheelColumn({ label, optionAriaLabel, options, selected, onSelect }) {
1471
1685
  role: "group",
1472
1686
  "aria-label": label,
1473
1687
  onScroll: () => {
1474
- if (settleTimerRef.current !== null) window.clearTimeout(settleTimerRef.current);
1688
+ if (settleTimerRef.current !== null)
1689
+ window.clearTimeout(settleTimerRef.current);
1475
1690
  settleTimerRef.current = window.setTimeout(settleSelection, 90);
1476
1691
  },
1477
- className: "h-[220px] snap-y snap-mandatory overflow-y-auto overscroll-contain [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",
1692
+ className: "h-55 snap-y snap-mandatory overflow-y-auto overscroll-contain scrollbar-none [&::-webkit-scrollbar]:hidden",
1478
1693
  style: { paddingBlock: WHEEL_PADDING },
1479
1694
  children: options.map((option, index) => {
1480
1695
  const active = option === selected;
@@ -1489,8 +1704,8 @@ function WheelColumn({ label, optionAriaLabel, options, selected, onSelect }) {
1489
1704
  tabIndex: active ? 0 : -1,
1490
1705
  onClick: () => onSelect(option),
1491
1706
  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"
1707
+ "cursor-pointer 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-(--color-focus)/25",
1708
+ active ? "text-xl font-semibold text-(--color-text) opacity-100" : distance === 1 ? "text-lg font-medium text-(--color-text-muted) opacity-65" : distance === 2 ? "text-base text-(--color-text-muted) opacity-35" : "text-sm text-(--color-text-muted) opacity-20"
1494
1709
  ),
1495
1710
  children: text
1496
1711
  },
@@ -1501,7 +1716,13 @@ function WheelColumn({ label, optionAriaLabel, options, selected, onSelect }) {
1501
1716
  )
1502
1717
  ] });
1503
1718
  }
1504
- function TimePickerPanel({ value, variant, minuteStep, onChange, className }) {
1719
+ function TimePickerPanel({
1720
+ value,
1721
+ variant,
1722
+ minuteStep,
1723
+ onChange,
1724
+ className
1725
+ }) {
1505
1726
  const { t } = useDLocalization();
1506
1727
  const parsed = parseTimeValue(value) ?? { hour: 0, minute: 0 };
1507
1728
  const minuteOptions = getMinuteOptions(minuteStep, parsed.minute);
@@ -1518,14 +1739,14 @@ function TimePickerPanel({ value, variant, minuteStep, onChange, className }) {
1518
1739
  {
1519
1740
  "data-time-picker-wheel": "true",
1520
1741
  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]",
1742
+ "relative mx-auto overflow-hidden rounded-(--radius-panel) bg-(--color-surface)",
1743
+ variant === "hour-minute" ? "w-full max-w-61" : "w-full max-w-28",
1523
1744
  className
1524
1745
  ),
1525
1746
  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" }),
1747
+ /* @__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-(--radius-control) border border-(--color-border) bg-(--color-surface-muted)/55" }),
1748
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "pointer-events-none absolute inset-x-0 top-0 z-20 h-16 bg-linear-to-b from-(--color-surface) to-transparent" }),
1749
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "pointer-events-none absolute inset-x-0 bottom-0 z-20 h-16 bg-linear-to-t from-(--color-surface) to-transparent" }),
1529
1750
  /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "relative z-10 flex items-center gap-2", children: [
1530
1751
  /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1531
1752
  WheelColumn,
@@ -1538,7 +1759,14 @@ function TimePickerPanel({ value, variant, minuteStep, onChange, className }) {
1538
1759
  }
1539
1760
  ),
1540
1761
  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: ":" }),
1762
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1763
+ "span",
1764
+ {
1765
+ "aria-hidden": "true",
1766
+ className: "relative z-10 -mx-1 text-xl font-semibold text-(--color-text-muted)",
1767
+ children: ":"
1768
+ }
1769
+ ),
1542
1770
  /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1543
1771
  WheelColumn,
1544
1772
  {
@@ -1559,19 +1787,75 @@ function TimePickerPanel({ value, variant, minuteStep, onChange, className }) {
1559
1787
  // src/date-picker/date-picker.tsx
1560
1788
  var import_jsx_runtime14 = require("react/jsx-runtime");
1561
1789
  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" }) });
1790
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1791
+ "svg",
1792
+ {
1793
+ viewBox: "0 0 24 24",
1794
+ fill: "none",
1795
+ stroke: "currentColor",
1796
+ strokeWidth: "2",
1797
+ className: "size-4",
1798
+ children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "m15 18-6-6 6-6" })
1799
+ }
1800
+ );
1563
1801
  }
1564
1802
  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" }) });
1803
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1804
+ "svg",
1805
+ {
1806
+ viewBox: "0 0 24 24",
1807
+ fill: "none",
1808
+ stroke: "currentColor",
1809
+ strokeWidth: "2",
1810
+ className: "size-4",
1811
+ children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "m9 18 6-6-6-6" })
1812
+ }
1813
+ );
1566
1814
  }
1567
1815
  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
- ] });
1816
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
1817
+ "svg",
1818
+ {
1819
+ viewBox: "0 0 24 24",
1820
+ fill: "none",
1821
+ stroke: "currentColor",
1822
+ strokeWidth: "2",
1823
+ className: "size-3.5",
1824
+ children: [
1825
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("rect", { x: "3", y: "5", width: "18", height: "16", rx: "2" }),
1826
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M16 3v4M8 3v4M3 10h18" })
1827
+ ]
1828
+ }
1829
+ );
1830
+ }
1831
+ function ClockIcon() {
1832
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
1833
+ "svg",
1834
+ {
1835
+ viewBox: "0 0 24 24",
1836
+ fill: "none",
1837
+ stroke: "currentColor",
1838
+ strokeWidth: "2",
1839
+ className: "size-4",
1840
+ children: [
1841
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("circle", { cx: "12", cy: "12", r: "9" }),
1842
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M12 7v5l3 2" })
1843
+ ]
1844
+ }
1845
+ );
1572
1846
  }
1573
1847
  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" }) });
1848
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1849
+ "svg",
1850
+ {
1851
+ viewBox: "0 0 24 24",
1852
+ fill: "none",
1853
+ stroke: "currentColor",
1854
+ strokeWidth: "2",
1855
+ className: "size-3.5",
1856
+ children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "m18 6-12 12M6 6l12 12" })
1857
+ }
1858
+ );
1575
1859
  }
1576
1860
  function datePart(value) {
1577
1861
  return value?.split("T")[0] ?? "";
@@ -1604,42 +1888,230 @@ function formatDisplayValue(value, variant, months) {
1604
1888
  const dateDisplay = formatDateDisplay(value, months);
1605
1889
  if (!dateDisplay) return "";
1606
1890
  if (variant === "date") return dateDisplay;
1607
- const timeDisplay = normalizeTimeValue(timePart(value), timePrecision(variant));
1891
+ const timeDisplay = normalizeTimeValue(
1892
+ timePart(value),
1893
+ timePrecision(variant)
1894
+ );
1608
1895
  return timeDisplay ? `${dateDisplay} \xB7 ${timeDisplay}` : dateDisplay;
1609
1896
  }
1610
- function DatePickerContent({ value, onChange, minDate, maxDate, variant, minuteStep }) {
1897
+ function TimePickerPopover({
1898
+ value,
1899
+ precision,
1900
+ minuteStep,
1901
+ rootRef,
1902
+ triggerRef,
1903
+ onCancel,
1904
+ onSelect
1905
+ }) {
1906
+ const { t } = useDLocalization();
1907
+ const popoverRef = (0, import_react10.useRef)(null);
1908
+ const interactedRef = (0, import_react10.useRef)(false);
1909
+ const initialTime = normalizeTimeValue(value, precision) || getCurrentTimeValue(precision, minuteStep);
1910
+ const [draftTime, setDraftTime] = (0, import_react10.useState)(initialTime);
1911
+ const [hasPickedTime, setHasPickedTime] = (0, import_react10.useState)(Boolean(value));
1912
+ const [position, setPosition] = (0, import_react10.useState)({ left: 0, top: 0 });
1913
+ (0, import_react10.useEffect)(() => {
1914
+ const nextTime = normalizeTimeValue(value, precision) || getCurrentTimeValue(precision, minuteStep);
1915
+ setDraftTime(nextTime);
1916
+ setHasPickedTime(Boolean(value));
1917
+ interactedRef.current = false;
1918
+ }, [value, precision, minuteStep]);
1919
+ const updatePosition = () => {
1920
+ const root = rootRef.current;
1921
+ const trigger = triggerRef.current;
1922
+ const popover = popoverRef.current;
1923
+ if (!root || !trigger || !popover) return;
1924
+ const rootRect = root.getBoundingClientRect();
1925
+ const triggerRect = trigger.getBoundingClientRect();
1926
+ const popoverRect = popover.getBoundingClientRect();
1927
+ const gap = 8;
1928
+ const viewportPadding = 8;
1929
+ let left;
1930
+ let top;
1931
+ const roomLeft = rootRect.left - viewportPadding;
1932
+ const roomRight = window.innerWidth - rootRect.right - viewportPadding;
1933
+ if (roomLeft >= popoverRect.width + gap) {
1934
+ left = -popoverRect.width - gap;
1935
+ } else if (roomRight >= popoverRect.width + gap) {
1936
+ left = rootRect.width + gap;
1937
+ } else {
1938
+ left = Math.max(
1939
+ 0,
1940
+ Math.min(
1941
+ rootRect.width - popoverRect.width,
1942
+ triggerRect.right - rootRect.left - popoverRect.width
1943
+ )
1944
+ );
1945
+ }
1946
+ top = triggerRect.top - rootRect.top + triggerRect.height / 2 - popoverRect.height / 2;
1947
+ const viewportTop = rootRect.top + top;
1948
+ const viewportBottom = viewportTop + popoverRect.height;
1949
+ if (viewportTop < viewportPadding) {
1950
+ top += viewportPadding - viewportTop;
1951
+ }
1952
+ if (viewportBottom > window.innerHeight - viewportPadding) {
1953
+ top -= viewportBottom - (window.innerHeight - viewportPadding);
1954
+ }
1955
+ setPosition({ left, top });
1956
+ };
1957
+ (0, import_react10.useLayoutEffect)(() => {
1958
+ updatePosition();
1959
+ const handleViewportChange = () => updatePosition();
1960
+ window.addEventListener("resize", handleViewportChange);
1961
+ window.addEventListener("scroll", handleViewportChange, true);
1962
+ return () => {
1963
+ window.removeEventListener("resize", handleViewportChange);
1964
+ window.removeEventListener("scroll", handleViewportChange, true);
1965
+ };
1966
+ }, []);
1967
+ const markInteraction = () => {
1968
+ interactedRef.current = true;
1969
+ };
1970
+ const handleTimeChange = (nextValue) => {
1971
+ const normalized = normalizeTimeValue(nextValue, precision);
1972
+ if (!normalized) return;
1973
+ setDraftTime(normalized);
1974
+ if (interactedRef.current) {
1975
+ setHasPickedTime(true);
1976
+ }
1977
+ };
1978
+ const confirm = () => {
1979
+ if (!hasPickedTime) return;
1980
+ const normalized = normalizeTimeValue(draftTime, precision);
1981
+ if (!normalized) return;
1982
+ onSelect(normalized);
1983
+ };
1984
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
1985
+ "div",
1986
+ {
1987
+ ref: popoverRef,
1988
+ role: "dialog",
1989
+ "aria-modal": "false",
1990
+ className: "absolute z-50 w-[min(300px,calc(100vw-24px))] overflow-hidden rounded-(--radius-card) border border-(--color-border) bg-(--color-surface) shadow-xl",
1991
+ style: {
1992
+ left: position.left,
1993
+ top: position.top
1994
+ },
1995
+ onPointerDown: (event) => {
1996
+ event.stopPropagation();
1997
+ markInteraction();
1998
+ },
1999
+ onMouseDown: (event) => event.stopPropagation(),
2000
+ onClick: (event) => event.stopPropagation(),
2001
+ onKeyDownCapture: markInteraction,
2002
+ onWheelCapture: markInteraction,
2003
+ children: [
2004
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "flex items-start justify-between gap-3 border-b border-(--color-border) px-3 py-3", children: [
2005
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { children: [
2006
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("p", { className: "text-xs font-semibold text-(--color-text)", children: t("datePicker.time") }),
2007
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("p", { className: "mt-0.5 text-[11px] text-(--color-text-muted)", children: precision === "hour" ? t("datePicker.selectHour") : t("datePicker.selectHourMinute") })
2008
+ ] }),
2009
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("span", { className: "inline-flex items-center gap-1.5 rounded-(--radius-menu-item) bg-(--color-surface-muted) px-2 py-1 text-xs font-semibold tabular-nums text-(--color-text)", children: [
2010
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(ClockIcon, {}),
2011
+ draftTime
2012
+ ] })
2013
+ ] }),
2014
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "px-3 py-3", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
2015
+ TimePickerPanel,
2016
+ {
2017
+ value: draftTime,
2018
+ variant: precision,
2019
+ minuteStep,
2020
+ onChange: handleTimeChange
2021
+ }
2022
+ ) }),
2023
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "flex items-center justify-end gap-2 border-t border-(--color-border) bg-(--color-surface) px-3 py-2.5", children: [
2024
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
2025
+ "button",
2026
+ {
2027
+ type: "button",
2028
+ onPointerDown: (event) => event.stopPropagation(),
2029
+ onMouseDown: (event) => event.stopPropagation(),
2030
+ onClick: (event) => {
2031
+ event.preventDefault();
2032
+ event.stopPropagation();
2033
+ onCancel();
2034
+ },
2035
+ className: "cursor-pointer h-8 appearance-none rounded-(--radius-menu-item) border-0 bg-transparent px-3 text-xs font-medium text-(--color-text-muted) shadow-none hover:bg-(--color-surface-muted)",
2036
+ children: t("common.cancel")
2037
+ }
2038
+ ),
2039
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
2040
+ "button",
2041
+ {
2042
+ type: "button",
2043
+ disabled: !hasPickedTime,
2044
+ onPointerDown: (event) => {
2045
+ event.stopPropagation();
2046
+ markInteraction();
2047
+ },
2048
+ onMouseDown: (event) => event.stopPropagation(),
2049
+ onClick: (event) => {
2050
+ event.preventDefault();
2051
+ event.stopPropagation();
2052
+ confirm();
2053
+ },
2054
+ className: "cursor-pointer h-8 appearance-none rounded-(--radius-menu-item) border-0 bg-(--color-brand) px-3 text-xs font-semibold text-(--color-brand-foreground) shadow-none hover:brightness-95 disabled:cursor-not-allowed disabled:opacity-50",
2055
+ children: t("common.apply")
2056
+ }
2057
+ )
2058
+ ] })
2059
+ ]
2060
+ }
2061
+ );
2062
+ }
2063
+ function DatePickerContent({
2064
+ value,
2065
+ onChange,
2066
+ minDate,
2067
+ maxDate,
2068
+ variant,
2069
+ minuteStep
2070
+ }) {
1611
2071
  const close = useDropdownClose();
1612
2072
  const { locale, t } = useDLocalization();
1613
- const days = (0, import_react10.useMemo)(() => getLocalizedWeekdayNames(locale, "short"), [locale]);
2073
+ const days = (0, import_react10.useMemo)(
2074
+ () => getLocalizedWeekdayNames(locale, "short"),
2075
+ [locale]
2076
+ );
1614
2077
  const months = (0, import_react10.useMemo)(() => getLocalizedMonthNames(locale), [locale]);
1615
- const today = /* @__PURE__ */ new Date();
2078
+ const today = (0, import_react10.useMemo)(() => /* @__PURE__ */ new Date(), []);
1616
2079
  const selectedDate = parseDate(value);
1617
2080
  const selectedDateValue = datePart(value);
1618
2081
  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());
2082
+ const selectedTimeValue = normalizeTimeValue(timePart(value), precision);
2083
+ const [viewMonth, setViewMonth] = (0, import_react10.useState)(
2084
+ selectedDate?.getMonth() ?? today.getMonth()
2085
+ );
2086
+ const [viewYear, setViewYear] = (0, import_react10.useState)(
2087
+ selectedDate?.getFullYear() ?? today.getFullYear()
2088
+ );
1623
2089
  const [draftDate, setDraftDate] = (0, import_react10.useState)(selectedDateValue);
1624
2090
  const [draftTime, setDraftTime] = (0, import_react10.useState)(selectedTimeValue);
2091
+ const [timePopoverOpen, setTimePopoverOpen] = (0, import_react10.useState)(false);
2092
+ const rootRef = (0, import_react10.useRef)(null);
2093
+ const timeTriggerRef = (0, import_react10.useRef)(null);
1625
2094
  (0, import_react10.useEffect)(() => {
1626
2095
  const nextDate = parseDate(value);
1627
2096
  setDraftDate(datePart(value));
1628
- setDraftTime(normalizeTimeValue(timePart(value), precision) || fallbackTime());
2097
+ setDraftTime(normalizeTimeValue(timePart(value), precision));
2098
+ setTimePopoverOpen(false);
1629
2099
  if (!nextDate) return;
1630
2100
  setViewMonth(nextDate.getMonth());
1631
2101
  setViewYear(nextDate.getFullYear());
1632
- }, [value, variant, minuteStep]);
2102
+ }, [value, precision]);
1633
2103
  const daysInMonth = new Date(viewYear, viewMonth + 1, 0).getDate();
1634
2104
  const firstDay = new Date(viewYear, viewMonth, 1).getDay();
1635
2105
  const move = (amount) => {
1636
2106
  const next = new Date(viewYear, viewMonth + amount, 1);
1637
- setViewYear(next.getFullYear());
1638
2107
  setViewMonth(next.getMonth());
2108
+ setViewYear(next.getFullYear());
1639
2109
  };
1640
2110
  const selectDate = (day) => {
1641
2111
  const next = toValue(viewYear, viewMonth, day);
1642
- if (minDate && compareDateValue(next, minDate) < 0 || maxDate && compareDateValue(next, maxDate) > 0) return;
2112
+ if (minDate && compareDateValue(next, minDate) < 0 || maxDate && compareDateValue(next, maxDate) > 0) {
2113
+ return;
2114
+ }
1643
2115
  if (variant === "date") {
1644
2116
  onChange?.(next);
1645
2117
  close?.();
@@ -1647,9 +2119,14 @@ function DatePickerContent({ value, onChange, minDate, maxDate, variant, minuteS
1647
2119
  }
1648
2120
  setDraftDate(next);
1649
2121
  };
1650
- const todayValue = toValue(today.getFullYear(), today.getMonth(), today.getDate());
1651
- const todayDisabled = minDate && compareDateValue(todayValue, minDate) < 0 || maxDate && compareDateValue(todayValue, maxDate) > 0;
2122
+ const todayValue = toValue(
2123
+ today.getFullYear(),
2124
+ today.getMonth(),
2125
+ today.getDate()
2126
+ );
2127
+ const todayDisabled = Boolean(minDate && compareDateValue(todayValue, minDate) < 0) || Boolean(maxDate && compareDateValue(todayValue, maxDate) > 0);
1652
2128
  const selectToday = () => {
2129
+ if (todayDisabled) return;
1653
2130
  if (variant === "date") {
1654
2131
  onChange?.(todayValue);
1655
2132
  close?.();
@@ -1660,98 +2137,318 @@ function DatePickerContent({ value, onChange, minDate, maxDate, variant, minuteS
1660
2137
  setViewYear(today.getFullYear());
1661
2138
  };
1662
2139
  const applyDateTime = () => {
1663
- if (!draftDate) return;
1664
- const normalizedTime = normalizeTimeValue(draftTime, precision) || fallbackTime();
1665
- onChange?.(`${draftDate}T${normalizedTime}`);
2140
+ if (!draftDate || !draftTime) return;
2141
+ onChange?.(`${draftDate}T${draftTime}`);
1666
2142
  close?.();
1667
2143
  };
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
2144
+ const canApply = Boolean(draftDate) && Boolean(draftTime);
2145
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
2146
+ "div",
2147
+ {
2148
+ ref: rootRef,
2149
+ className: cn(
2150
+ "relative",
2151
+ variant === "date" ? "w-70" : "w-[min(340px,calc(100vw-16px))]"
2152
+ ),
2153
+ children: [
2154
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "flex max-h-[min(560px,calc(100dvh-24px))] flex-col overflow-hidden rounded-(--radius-card) bg-(--color-surface)", children: [
2155
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "min-h-0 flex-1 overflow-y-auto overscroll-contain p-3", children: [
2156
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "mb-2 flex items-center justify-between", children: [
2157
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
2158
+ "button",
2159
+ {
2160
+ type: "button",
2161
+ "aria-label": t("common.previousMonth"),
2162
+ onClick: () => move(-1),
2163
+ className: "cursor-pointer flex size-8 appearance-none items-center justify-center rounded-(--radius-menu-item) border-0 bg-transparent text-(--color-text-muted) shadow-none hover:bg-(--color-surface-muted)",
2164
+ children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(ChevronLeftIcon2, {})
2165
+ }
2166
+ ),
2167
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("span", { className: "text-sm font-medium text-(--color-text)", children: [
2168
+ months[viewMonth],
2169
+ " ",
2170
+ viewYear
2171
+ ] }),
2172
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
2173
+ "button",
2174
+ {
2175
+ type: "button",
2176
+ "aria-label": t("common.nextMonth"),
2177
+ onClick: () => move(1),
2178
+ className: "cursor-pointer flex size-8 appearance-none items-center justify-center rounded-(--radius-menu-item) border-0 bg-transparent text-(--color-text-muted) shadow-none hover:bg-(--color-surface-muted)",
2179
+ children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(ChevronRightIcon2, {})
2180
+ }
2181
+ )
2182
+ ] }),
2183
+ /* @__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-(--color-text-muted)", children: day }, day)) }),
2184
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "grid grid-cols-7 gap-1", children: [
2185
+ Array.from({ length: firstDay }).map((_, index) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", {}, `empty-${index}`)),
2186
+ Array.from({ length: daysInMonth }, (_, index) => index + 1).map(
2187
+ (day) => {
2188
+ const dateValue = toValue(viewYear, viewMonth, day);
2189
+ const selected = (variant === "date" ? selectedDateValue : draftDate) === dateValue;
2190
+ const outside = Boolean(
2191
+ minDate && compareDateValue(dateValue, minDate) < 0
2192
+ ) || Boolean(maxDate && compareDateValue(dateValue, maxDate) > 0);
2193
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
2194
+ "button",
2195
+ {
2196
+ type: "button",
2197
+ disabled: outside,
2198
+ onClick: () => selectDate(day),
2199
+ className: cn(
2200
+ "cursor-pointer aspect-square w-full appearance-none rounded-(--radius-control) border-0 bg-transparent text-sm shadow-none transition-colors hover:bg-(--color-surface-muted) disabled:cursor-not-allowed disabled:opacity-30",
2201
+ selected && "bg-(--color-brand) font-medium text-(--color-brand-foreground) hover:bg-(--color-brand)"
2202
+ ),
2203
+ children: day
2204
+ },
2205
+ day
2206
+ );
2207
+ }
2208
+ )
2209
+ ] }),
2210
+ variant !== "date" ? /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "mt-3 border-t border-(--color-border) pt-3", children: [
2211
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "flex items-center justify-between gap-3", children: [
2212
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "min-w-0", children: [
2213
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("p", { className: "text-xs font-semibold text-(--color-text)", children: t("datePicker.time") }),
2214
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("p", { className: "mt-0.5 text-[11px] text-(--color-text-muted)", children: variant === "date-hour" ? t("datePicker.selectHour") : t("datePicker.selectHourMinute") })
2215
+ ] }),
2216
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
2217
+ "span",
2218
+ {
2219
+ className: cn(
2220
+ "shrink-0 rounded-(--radius-menu-item) bg-(--color-surface-muted) px-2 py-1 text-xs font-semibold tabular-nums",
2221
+ draftTime ? "text-(--color-text)" : "text-(--color-text-muted)"
2222
+ ),
2223
+ children: draftTime || "--:--"
2224
+ }
2225
+ )
2226
+ ] }),
2227
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
2228
+ "button",
2229
+ {
2230
+ ref: timeTriggerRef,
2231
+ type: "button",
2232
+ onPointerDown: (event) => event.stopPropagation(),
2233
+ onMouseDown: (event) => {
2234
+ event.preventDefault();
2235
+ event.stopPropagation();
2236
+ },
2237
+ onClick: (event) => {
2238
+ event.preventDefault();
2239
+ event.stopPropagation();
2240
+ setTimePopoverOpen((open) => !open);
2241
+ },
2242
+ className: "cursor-pointer mt-3 flex h-10 w-full appearance-none items-center justify-center gap-2 rounded-(--radius-control) border border-(--color-border) bg-(--color-surface) px-3 text-sm font-medium text-(--color-text) shadow-none transition-colors hover:bg-(--color-surface-muted) focus:outline-none focus:ring-2 focus:ring-(--color-brand)/20",
2243
+ children: [
2244
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(ClockIcon, {}),
2245
+ draftTime ? "Ubah waktu" : "Pilih waktu"
2246
+ ]
2247
+ }
2248
+ )
2249
+ ] }) : null
2250
+ ] }),
2251
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "shrink-0 border-t border-(--color-border) bg-(--color-surface) px-3 py-2.5", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "flex items-center justify-between gap-2", children: [
2252
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
2253
+ "button",
2254
+ {
2255
+ type: "button",
2256
+ disabled: todayDisabled,
2257
+ onClick: selectToday,
2258
+ className: "cursor-pointer h-8 appearance-none rounded-(--radius-menu-item) border-0 bg-transparent px-2 text-xs font-medium text-(--color-brand) shadow-none hover:bg-(--color-surface-muted) disabled:cursor-not-allowed disabled:opacity-40",
2259
+ children: t("datePicker.today")
2260
+ }
2261
+ ),
2262
+ variant !== "date" ? /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "flex items-center gap-2", children: [
2263
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
2264
+ "button",
2265
+ {
2266
+ type: "button",
2267
+ onClick: () => close?.(),
2268
+ className: "cursor-pointer h-8 appearance-none rounded-(--radius-menu-item) border-0 bg-transparent px-3 text-xs font-medium text-(--color-text-muted) shadow-none hover:bg-(--color-surface-muted)",
2269
+ children: t("common.cancel")
2270
+ }
2271
+ ),
2272
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
2273
+ "button",
2274
+ {
2275
+ type: "button",
2276
+ disabled: !canApply,
2277
+ onClick: applyDateTime,
2278
+ className: "cursor-pointer h-8 appearance-none rounded-(--radius-menu-item) border-0 bg-(--color-brand) px-3 text-xs font-semibold text-(--color-brand-foreground) shadow-none hover:brightness-95 disabled:cursor-not-allowed disabled:opacity-50",
2279
+ children: t("common.apply")
2280
+ }
2281
+ )
2282
+ ] }) : null
2283
+ ] }) })
2284
+ ] }),
2285
+ timePopoverOpen ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
2286
+ TimePickerPopover,
2287
+ {
2288
+ value: draftTime,
2289
+ precision,
2290
+ minuteStep,
2291
+ rootRef,
2292
+ triggerRef: timeTriggerRef,
2293
+ onCancel: () => setTimePopoverOpen(false),
2294
+ onSelect: (nextTime) => {
2295
+ setDraftTime(nextTime);
2296
+ setTimePopoverOpen(false);
2297
+ }
2298
+ }
2299
+ ) : null
2300
+ ]
2301
+ }
2302
+ );
2303
+ }
2304
+ function DDatePicker({
2305
+ label,
2306
+ value,
2307
+ onChange,
2308
+ onClear,
2309
+ placeholder,
2310
+ error,
2311
+ hint,
2312
+ disabled = false,
2313
+ clearable = true,
2314
+ containerClassName,
2315
+ minDate,
2316
+ maxDate,
2317
+ size = "md",
2318
+ variant = "date",
2319
+ minuteStep = 1,
2320
+ scrollBehavior = "reposition"
2321
+ }) {
2322
+ const id = (0, import_react10.useId)();
2323
+ const { locale, t } = useDLocalization();
2324
+ const months = (0, import_react10.useMemo)(() => getLocalizedMonthNames(locale), [locale]);
2325
+ const s = INPUT_SIZE_STYLES[size];
2326
+ const display = formatDisplayValue(value, variant, months);
2327
+ const resolvedPlaceholder = placeholder ?? t("datePicker.placeholder");
2328
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
2329
+ "div",
2330
+ {
2331
+ "data-ds-component": "date-picker",
2332
+ "data-date-picker-variant": variant,
2333
+ className: cn("flex min-w-0 flex-col gap-1.5", containerClassName),
2334
+ children: [
2335
+ label ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
2336
+ "label",
2337
+ {
2338
+ htmlFor: id,
2339
+ className: cn(s.label, "w-fit font-medium text-(--color-text)"),
2340
+ children: label
2341
+ }
2342
+ ) : null,
2343
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
2344
+ DDropdown,
2345
+ {
2346
+ contentRole: "dialog",
2347
+ contentPadding: false,
2348
+ contentClassName: "!overflow-visible",
2349
+ scrollBehavior,
2350
+ trigger: () => /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "relative", children: [
2351
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
2352
+ "button",
2353
+ {
2354
+ id,
2355
+ type: "button",
2356
+ disabled,
2357
+ "aria-invalid": Boolean(error) || void 0,
2358
+ className: cn(
2359
+ "flex w-full items-center gap-2 rounded-(--radius-control) border bg-(--color-surface) text-left text-(--color-text) transition-colors focus:border-(--color-brand) focus:outline-none focus:ring-2 focus:ring-(--color-brand)/20 disabled:cursor-not-allowed disabled:bg-(--color-surface-muted) disabled:opacity-50",
2360
+ s.input,
2361
+ error ? "border-(--color-danger)" : "border-(--color-border)",
2362
+ !display && "text-(--color-text-muted)/60",
2363
+ clearable && display && "pr-10"
2364
+ ),
2365
+ children: [
2366
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: "text-(--color-text-muted)", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(CalendarIcon, {}) }),
2367
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: "min-w-0 flex-1 truncate", children: display || resolvedPlaceholder })
2368
+ ]
2369
+ }
2370
+ ),
2371
+ clearable && display && !disabled ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
2372
+ "button",
2373
+ {
2374
+ type: "button",
2375
+ "aria-label": t("datePicker.clear"),
2376
+ onMouseDown: (event) => event.preventDefault(),
2377
+ onClick: (event) => {
2378
+ event.preventDefault();
2379
+ event.stopPropagation();
2380
+ onChange?.("");
2381
+ onClear?.();
2382
+ },
2383
+ className: "cursor-pointer absolute right-2 top-1/2 -translate-y-1/2 appearance-none rounded-(--radius-menu-item) border-0 bg-transparent p-1 text-(--color-text-muted) shadow-none hover:bg-(--color-surface-muted)",
2384
+ children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(ClearIcon2, {})
2385
+ }
2386
+ ) : null
2387
+ ] }),
2388
+ children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
2389
+ DatePickerContent,
2390
+ {
2391
+ value,
2392
+ onChange,
2393
+ minDate,
2394
+ maxDate,
2395
+ variant,
2396
+ minuteStep
2397
+ }
2398
+ )
2399
+ }
2400
+ ),
2401
+ error ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("p", { className: "text-xs text-(--color-danger)", children: error }) : null,
2402
+ !error && hint ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("p", { className: "text-xs text-(--color-text-muted)", children: hint }) : null
2403
+ ]
2404
+ }
2405
+ );
2406
+ }
2407
+
2408
+ // src/time-picker/time-picker.tsx
2409
+ var import_react11 = require("react");
2410
+ var import_jsx_runtime15 = require("react/jsx-runtime");
2411
+ function ClockIcon2() {
2412
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
2413
+ "svg",
2414
+ {
2415
+ viewBox: "0 0 24 24",
2416
+ fill: "none",
2417
+ stroke: "currentColor",
2418
+ strokeWidth: "2",
2419
+ className: "size-3.5",
2420
+ children: [
2421
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("circle", { cx: "12", cy: "12", r: "9" }),
2422
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("path", { d: "M12 7v5l3 2" })
2423
+ ]
2424
+ }
2425
+ );
2426
+ }
2427
+ function ClearIcon3() {
2428
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
2429
+ "svg",
2430
+ {
2431
+ viewBox: "0 0 24 24",
2432
+ fill: "none",
2433
+ stroke: "currentColor",
2434
+ strokeWidth: "2",
2435
+ className: "size-3.5",
2436
+ children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("path", { d: "m18 6-12 12M6 6l12 12" })
2437
+ }
2438
+ );
2439
+ }
2440
+ function TimePickerContent({
2441
+ value,
2442
+ onChange,
2443
+ variant,
2444
+ minuteStep
1750
2445
  }) {
1751
2446
  const close = useDropdownClose();
1752
2447
  const { t } = useDLocalization();
1753
2448
  const fallback = () => getCurrentTimeValue(variant, minuteStep);
1754
- const [draft, setDraft] = (0, import_react11.useState)(() => normalizeTimeValue(value, variant) || fallback());
2449
+ const [draft, setDraft] = (0, import_react11.useState)(
2450
+ () => normalizeTimeValue(value, variant) || fallback()
2451
+ );
1755
2452
  (0, import_react11.useEffect)(() => {
1756
2453
  setDraft(normalizeTimeValue(value, variant) || fallback());
1757
2454
  }, [value, variant, minuteStep]);
@@ -1759,47 +2456,64 @@ function TimePickerContent({
1759
2456
  onChange?.(normalizeTimeValue(draft, variant));
1760
2457
  close?.();
1761
2458
  };
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
- }
2459
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
2460
+ "div",
2461
+ {
2462
+ className: cn(
2463
+ "p-3",
2464
+ variant === "hour" ? "w-[min(232px,calc(100vw-16px))]" : "w-[min(320px,calc(100vw-16px))]"
1780
2465
  ),
1781
- /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "flex items-center gap-2", children: [
2466
+ children: [
2467
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "mb-3 flex items-center justify-between gap-3", children: [
2468
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { children: [
2469
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("p", { className: "text-xs font-semibold text-(--color-text)", children: t("timePicker.title") }),
2470
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("p", { className: "mt-0.5 text-[11px] text-(--color-text-muted)", children: variant === "hour" ? t("timePicker.hourPrecision") : t("timePicker.hourMinutePrecision") })
2471
+ ] }),
2472
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "rounded-(--radius-menu-item) bg-(--color-surface-muted) px-2 py-1 text-xs font-semibold tabular-nums text-(--color-text)", children: draft })
2473
+ ] }),
1782
2474
  /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
1783
- "button",
2475
+ TimePickerPanel,
1784
2476
  {
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")
2477
+ value: draft,
2478
+ variant,
2479
+ minuteStep,
2480
+ onChange: setDraft
1789
2481
  }
1790
2482
  ),
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
- ] });
2483
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "mt-3 flex items-center justify-between gap-2 border-t border-(--color-border) pt-3", children: [
2484
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
2485
+ "button",
2486
+ {
2487
+ type: "button",
2488
+ onClick: () => setDraft(fallback()),
2489
+ className: "cursor-pointer h-8 appearance-none rounded-(--radius-menu-item) border-0 bg-transparent px-2 text-xs font-medium text-(--color-brand) shadow-none hover:bg-(--color-surface-muted)",
2490
+ children: t("timePicker.now")
2491
+ }
2492
+ ),
2493
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "flex items-center gap-2", children: [
2494
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
2495
+ "button",
2496
+ {
2497
+ type: "button",
2498
+ onClick: () => close?.(),
2499
+ className: "cursor-pointer h-8 appearance-none rounded-(--radius-menu-item) border-0 bg-transparent px-3 text-xs font-medium text-(--color-text-muted) shadow-none hover:bg-(--color-surface-muted)",
2500
+ children: t("common.cancel")
2501
+ }
2502
+ ),
2503
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
2504
+ "button",
2505
+ {
2506
+ type: "button",
2507
+ onClick: apply,
2508
+ className: "cursor-pointer h-8 appearance-none rounded-(--radius-menu-item) border-0 bg-(--color-brand) px-3 text-xs font-semibold text-(--color-brand-foreground) shadow-none hover:brightness-95",
2509
+ children: t("common.apply")
2510
+ }
2511
+ )
2512
+ ] })
2513
+ ] })
2514
+ ]
2515
+ }
2516
+ );
1803
2517
  }
1804
2518
  function DTimePicker({
1805
2519
  label,
@@ -1822,49 +2536,80 @@ function DTimePicker({
1822
2536
  const s = INPUT_SIZE_STYLES[size];
1823
2537
  const display = normalizeTimeValue(value, variant);
1824
2538
  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
- ] });
2539
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
2540
+ "div",
2541
+ {
2542
+ "data-ds-component": "time-picker",
2543
+ className: cn("flex min-w-0 flex-col gap-1.5", containerClassName),
2544
+ children: [
2545
+ label ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
2546
+ "label",
2547
+ {
2548
+ htmlFor: id,
2549
+ className: cn(s.label, "w-fit font-medium text-(--color-text)"),
2550
+ children: label
2551
+ }
2552
+ ) : null,
2553
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
2554
+ DDropdown,
2555
+ {
2556
+ contentRole: "dialog",
2557
+ contentPadding: false,
2558
+ scrollBehavior,
2559
+ trigger: () => /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "relative", children: [
2560
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
2561
+ "button",
2562
+ {
2563
+ id,
2564
+ type: "button",
2565
+ disabled,
2566
+ "aria-invalid": Boolean(error) || void 0,
2567
+ className: cn(
2568
+ "flex w-full items-center gap-2 rounded-(--radius-control) border bg-(--color-surface) text-left text-(--color-text) transition-colors focus:border-(--color-brand) focus:outline-none focus:ring-2 focus:ring-(--color-brand)/20 disabled:cursor-not-allowed disabled:bg-(--color-surface-muted) disabled:opacity-50",
2569
+ s.input,
2570
+ error ? "border-(--color-danger)" : "border-(--color-border)",
2571
+ !display && "text-(--color-text-muted)/60",
2572
+ clearable && display && "pr-10"
2573
+ ),
2574
+ children: [
2575
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "text-(--color-text-muted)", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(ClockIcon2, {}) }),
2576
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "min-w-0 flex-1 truncate tabular-nums", children: display || resolvedPlaceholder })
2577
+ ]
2578
+ }
2579
+ ),
2580
+ clearable && display && !disabled ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
2581
+ "button",
2582
+ {
2583
+ type: "button",
2584
+ "aria-label": t("timePicker.clear"),
2585
+ onMouseDown: (event) => event.preventDefault(),
2586
+ onClick: (event) => {
2587
+ event.preventDefault();
2588
+ event.stopPropagation();
2589
+ onChange?.("");
2590
+ onClear?.();
2591
+ },
2592
+ className: "absolute right-2 top-1/2 -translate-y-1/2 appearance-none rounded-md border-0 bg-transparent p-1 text-(--color-text-muted) shadow-none hover:bg-(--color-surface-muted)",
2593
+ children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(ClearIcon3, {})
2594
+ }
2595
+ ) : null
2596
+ ] }),
2597
+ children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
2598
+ TimePickerContent,
2599
+ {
2600
+ value,
2601
+ onChange,
2602
+ variant,
2603
+ minuteStep
2604
+ }
2605
+ )
2606
+ }
2607
+ ),
2608
+ error ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("p", { className: "text-xs text-(--color-danger)", children: error }) : null,
2609
+ !error && hint ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("p", { className: "text-xs text-(--color-text-muted)", children: hint }) : null
2610
+ ]
2611
+ }
2612
+ );
1868
2613
  }
1869
2614
 
1870
2615
  // src/date-range-filter/date-range-filter.tsx
@@ -1918,9 +2663,26 @@ function DEmptyState({
1918
2663
  var import_react12 = require("react");
1919
2664
  var import_jsx_runtime18 = require("react/jsx-runtime");
1920
2665
  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" }) });
2666
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2667
+ "svg",
2668
+ {
2669
+ viewBox: "0 0 24 24",
2670
+ fill: "none",
2671
+ stroke: "currentColor",
2672
+ strokeWidth: "2",
2673
+ className: "size-3.5",
2674
+ children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("path", { d: "M12 3v12m0 0 4-4m-4 4-4-4M5 21h14" })
2675
+ }
2676
+ );
1922
2677
  }
1923
- function ExportContent({ onExport, filename, onSuccess, onError, onProcessing, setLoading }) {
2678
+ function ExportContent({
2679
+ onExport,
2680
+ filename,
2681
+ onSuccess,
2682
+ onError,
2683
+ onProcessing,
2684
+ setLoading
2685
+ }) {
1924
2686
  const close = useDropdownClose();
1925
2687
  const { t } = useDLocalization();
1926
2688
  const run = async (format) => {
@@ -1956,15 +2718,60 @@ function ExportContent({ onExport, filename, onSuccess, onError, onProcessing, s
1956
2718
  setLoading(false);
1957
2719
  }
1958
2720
  };
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") })
2721
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "min-w-35 py-1", children: [
2722
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2723
+ "button",
2724
+ {
2725
+ type: "button",
2726
+ onClick: () => void run("pdf"),
2727
+ className: "w-full px-3 py-2 text-left text-sm text-(--color-text) hover:bg-(--color-surface-muted)",
2728
+ children: t("export.pdf")
2729
+ }
2730
+ ),
2731
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2732
+ "button",
2733
+ {
2734
+ type: "button",
2735
+ onClick: () => void run("excel"),
2736
+ className: "w-full px-3 py-2 text-left text-sm text-(--color-text) hover:bg-(--color-surface-muted)",
2737
+ children: t("export.excel")
2738
+ }
2739
+ )
1962
2740
  ] });
1963
2741
  }
1964
- function DExportButton({ filename = "export", disabled, ...props }) {
2742
+ function DExportButton({
2743
+ filename = "export",
2744
+ disabled,
2745
+ ...props
2746
+ }) {
1965
2747
  const [loading, setLoading] = (0, import_react12.useState)(false);
1966
2748
  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 }) });
2749
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2750
+ DDropdown,
2751
+ {
2752
+ placement: "bottom-end",
2753
+ trigger: () => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2754
+ DButton,
2755
+ {
2756
+ variant: "outline",
2757
+ size: "sm",
2758
+ leftIcon: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(DownloadIcon, {}),
2759
+ loading,
2760
+ disabled,
2761
+ children: t("export.label")
2762
+ }
2763
+ ),
2764
+ children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2765
+ ExportContent,
2766
+ {
2767
+ ...props,
2768
+ filename,
2769
+ disabled,
2770
+ setLoading
2771
+ }
2772
+ )
2773
+ }
2774
+ );
1968
2775
  }
1969
2776
 
1970
2777
  // src/form-validation/form.tsx
@@ -2255,20 +3062,53 @@ function DInfoNote({ variant = "info", title, icon, children, className }) {
2255
3062
  var import_react14 = require("react");
2256
3063
  var import_jsx_runtime21 = require("react/jsx-runtime");
2257
3064
  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" }) });
3065
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
3066
+ "svg",
3067
+ {
3068
+ viewBox: "0 0 24 24",
3069
+ fill: "none",
3070
+ stroke: "currentColor",
3071
+ strokeWidth: "2",
3072
+ className,
3073
+ children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("path", { d: "m18 6-12 12M6 6l12 12" })
3074
+ }
3075
+ );
2259
3076
  }
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
- ] });
3077
+ function EyeIcon({
3078
+ closed,
3079
+ className
3080
+ }) {
3081
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
3082
+ "svg",
3083
+ {
3084
+ viewBox: "0 0 24 24",
3085
+ fill: "none",
3086
+ stroke: "currentColor",
3087
+ strokeWidth: "2",
3088
+ className,
3089
+ children: [
3090
+ closed ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("path", { d: "m3 3 18 18" }) : null,
3091
+ /* @__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" }),
3092
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("circle", { cx: "12", cy: "12", r: "2.5" })
3093
+ ]
3094
+ }
3095
+ );
2266
3096
  }
2267
3097
  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
- ] });
3098
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
3099
+ "svg",
3100
+ {
3101
+ viewBox: "0 0 24 24",
3102
+ fill: "none",
3103
+ stroke: "currentColor",
3104
+ strokeWidth: "2",
3105
+ className,
3106
+ children: [
3107
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("circle", { cx: "12", cy: "12", r: "9" }),
3108
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("path", { d: "M12 10v6M12 7h.01" })
3109
+ ]
3110
+ }
3111
+ );
2272
3112
  }
2273
3113
  function assignRef(ref, value) {
2274
3114
  if (typeof ref === "function") ref(value);
@@ -2280,7 +3120,10 @@ function formatLegacyCurrency(value) {
2280
3120
  return raw.replace(/\B(?=(\d{3})+(?!\d))/g, ".");
2281
3121
  }
2282
3122
  function eventWithValue(value) {
2283
- return { target: { value }, currentTarget: { value } };
3123
+ return {
3124
+ target: { value },
3125
+ currentTarget: { value }
3126
+ };
2284
3127
  }
2285
3128
  function countDigitsAfterCaret(value, caret) {
2286
3129
  if (caret === null) return 0;
@@ -2330,7 +3173,9 @@ var DInput = (0, import_react14.forwardRef)(function DInput2({
2330
3173
  const pendingCaretDigitsAfterRef = (0, import_react14.useRef)(null);
2331
3174
  const [showPassword, setShowPassword] = (0, import_react14.useState)(false);
2332
3175
  const [showTooltip, setShowTooltip] = (0, import_react14.useState)(false);
2333
- const [internalValue, setInternalValue] = (0, import_react14.useState)(() => defaultValue == null ? "" : String(defaultValue));
3176
+ const [internalValue, setInternalValue] = (0, import_react14.useState)(
3177
+ () => defaultValue == null ? "" : String(defaultValue)
3178
+ );
2334
3179
  const tooltipRef = (0, import_react14.useRef)(null);
2335
3180
  const s = INPUT_SIZE_STYLES[size];
2336
3181
  const isControlled = value !== void 0;
@@ -2344,18 +3189,23 @@ var DInput = (0, import_react14.forwardRef)(function DInput2({
2344
3189
  const resolvedPrefix = prefix ?? (format === "currency" ? "Rp" : void 0);
2345
3190
  const resolvedSuffix = suffix ?? (format === "percentage" ? "%" : void 0);
2346
3191
  const hasLeading = Boolean(leadingIcon || resolvedPrefix);
2347
- const hasTrailing = Boolean(trailingIcon || resolvedSuffix || showClear || type === "password" || loading);
3192
+ const hasTrailing = Boolean(
3193
+ trailingIcon || resolvedSuffix || showClear || type === "password" || loading
3194
+ );
2348
3195
  (0, import_react14.useEffect)(() => {
2349
3196
  const handleClickOutside = (event) => {
2350
- if (!tooltipRef.current?.contains(event.target)) setShowTooltip(false);
3197
+ if (!tooltipRef.current?.contains(event.target))
3198
+ setShowTooltip(false);
2351
3199
  };
2352
3200
  document.addEventListener("mousedown", handleClickOutside);
2353
3201
  return () => document.removeEventListener("mousedown", handleClickOutside);
2354
3202
  }, []);
2355
3203
  const displayValue = (() => {
2356
3204
  if (currentValue === void 0 || currentValue === null) return "";
2357
- if (type === "number" && (currentValue === 0 || currentValue === "0")) return "";
2358
- if (format === "currency") return formatLegacyCurrency(currentValue);
3205
+ if (type === "number" && (currentValue === 0 || currentValue === "0"))
3206
+ return "";
3207
+ if (format === "currency")
3208
+ return formatLegacyCurrency(currentValue);
2359
3209
  return String(currentValue);
2360
3210
  })();
2361
3211
  (0, import_react14.useLayoutEffect)(() => {
@@ -2369,7 +3219,10 @@ var DInput = (0, import_react14.forwardRef)(function DInput2({
2369
3219
  const handleChange = (event) => {
2370
3220
  let next = event.target.value;
2371
3221
  if (format === "currency") {
2372
- pendingCaretDigitsAfterRef.current = countDigitsAfterCaret(event.target.value, event.target.selectionStart);
3222
+ pendingCaretDigitsAfterRef.current = countDigitsAfterCaret(
3223
+ event.target.value,
3224
+ event.target.selectionStart
3225
+ );
2373
3226
  next = next.replace(/\D/g, "");
2374
3227
  } else if (format !== "plain") {
2375
3228
  next = next.replace(/[^0-9.,-]/g, "");
@@ -2387,78 +3240,209 @@ var DInput = (0, import_react14.forwardRef)(function DInput2({
2387
3240
  pendingCaretDigitsAfterRef.current = null;
2388
3241
  inputRef.current?.focus();
2389
3242
  };
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
- ] });
3243
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
3244
+ "div",
3245
+ {
3246
+ "data-ds-component": "input",
3247
+ className: cn("flex min-w-0 flex-col gap-1.5", containerClassName),
3248
+ children: [
3249
+ label ? /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "flex w-fit items-center gap-1.5", children: [
3250
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
3251
+ "label",
3252
+ {
3253
+ htmlFor: id,
3254
+ className: cn(s.label, "font-medium text-(--color-text)"),
3255
+ children: label
3256
+ }
3257
+ ),
3258
+ labelInfo ? /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { ref: tooltipRef, className: "group relative flex items-center", children: [
3259
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
3260
+ "button",
3261
+ {
3262
+ type: "button",
3263
+ "aria-label": t("input.fieldInfo"),
3264
+ "aria-expanded": showTooltip,
3265
+ onClick: () => setShowTooltip((v) => !v),
3266
+ className: "text-(--color-text-muted) hover:text-(--color-text)",
3267
+ children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(InfoIcon, { className: "size-3.5" })
3268
+ }
3269
+ ),
3270
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
3271
+ "div",
3272
+ {
3273
+ role: "tooltip",
3274
+ className: cn(
3275
+ "invisible absolute bottom-full left-1/2 z-50 mb-2 w-max max-w-55 -translate-x-1/2 opacity-0 transition-all duration-150 group-hover:visible group-hover:opacity-100",
3276
+ showTooltip && "visible opacity-100"
3277
+ ),
3278
+ children: /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "relative rounded-lg bg-(--color-tooltip) px-3 py-2 text-xs text-white shadow-lg", children: [
3279
+ labelInfo,
3280
+ /* @__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-(--color-tooltip)" })
3281
+ ] })
3282
+ }
3283
+ )
3284
+ ] }) : null
3285
+ ] }) : null,
3286
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "relative flex min-w-0 items-center", children: [
3287
+ leadingIcon ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
3288
+ "span",
3289
+ {
3290
+ className: cn(
3291
+ "pointer-events-none absolute top-1/2 z-10 -translate-y-1/2 text-(--color-text-muted)",
3292
+ size === "sm" ? "left-2.5 [&_svg]:size-3.5" : "left-3 [&_svg]:size-4"
3293
+ ),
3294
+ children: leadingIcon
3295
+ }
3296
+ ) : null,
3297
+ resolvedPrefix ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
3298
+ "span",
3299
+ {
3300
+ className: cn(
3301
+ "pointer-events-none absolute left-3 top-1/2 z-10 -translate-y-1/2 font-medium text-(--color-text-muted)",
3302
+ size === "sm" ? "text-xs" : "text-sm"
3303
+ ),
3304
+ children: resolvedPrefix
3305
+ }
3306
+ ) : null,
3307
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
3308
+ "input",
3309
+ {
3310
+ ...props,
3311
+ ref: (node) => {
3312
+ inputRef.current = node;
3313
+ assignRef(forwardedRef, node);
3314
+ },
3315
+ id,
3316
+ autoComplete: props.autoComplete ?? "off",
3317
+ type: inputType,
3318
+ inputMode: props.inputMode ?? (type === "number" || format !== "plain" ? "numeric" : void 0),
3319
+ value: displayValue,
3320
+ onChange: handleChange,
3321
+ disabled: disabled || loading,
3322
+ readOnly,
3323
+ "aria-invalid": Boolean(error) || void 0,
3324
+ "aria-busy": loading || void 0,
3325
+ className: cn(
3326
+ "w-full min-w-0 rounded-(--radius-control) border bg-(--color-surface) text-(--color-text) transition-colors duration-150 placeholder:text-(--color-text-muted)/60 focus:border-(--color-brand) focus:outline-none focus:ring-2 focus:ring-(--color-brand)/20 disabled:cursor-not-allowed disabled:bg-(--color-surface-muted) disabled:opacity-50 read-only:bg-(--color-surface-muted)",
3327
+ s.input,
3328
+ error ? "border-(--color-danger) focus:border-(--color-danger) focus:ring-(--color-danger)/20" : "border-(--color-border)",
3329
+ hasLeading && (size === "sm" ? "pl-8" : "pl-10"),
3330
+ hasTrailing && (size === "sm" ? "pr-8" : "pr-10"),
3331
+ className
3332
+ )
3333
+ }
3334
+ ),
3335
+ resolvedSuffix ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
3336
+ "span",
3337
+ {
3338
+ className: cn(
3339
+ "pointer-events-none absolute top-1/2 -translate-y-1/2 font-medium text-(--color-text-muted)",
3340
+ size === "sm" ? "right-2.5 text-xs" : "right-3 text-sm"
3341
+ ),
3342
+ children: resolvedSuffix
3343
+ }
3344
+ ) : null,
3345
+ showClear || type === "password" || trailingIcon || loading ? /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
3346
+ "div",
3347
+ {
3348
+ className: cn(
3349
+ "absolute top-1/2 flex -translate-y-1/2 items-center text-(--color-text-muted)",
3350
+ size === "sm" ? "right-1.5 gap-0.5" : "right-2 gap-1",
3351
+ resolvedSuffix && "pointer-events-none opacity-0"
3352
+ ),
3353
+ children: [
3354
+ loading ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
3355
+ "span",
3356
+ {
3357
+ "aria-label": t("input.loading"),
3358
+ className: "size-4 animate-spin rounded-full border-2 border-current border-t-transparent"
3359
+ }
3360
+ ) : null,
3361
+ !loading && showClear ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
3362
+ "button",
3363
+ {
3364
+ type: "button",
3365
+ tabIndex: -1,
3366
+ "aria-label": t("input.clear"),
3367
+ onMouseDown: (event) => event.preventDefault(),
3368
+ onClick: handleClear,
3369
+ className: cn(
3370
+ "cursor-pointer flex size-5 shrink-0 items-center justify-center self-center rounded-md hover:bg-(--color-surface-muted) text-(--color-text-muted) transition-colors",
3371
+ size === "sm" ? "p-0.5" : "p-1"
3372
+ ),
3373
+ children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(ClearIcon4, { className: size === "sm" ? "size-3" : "size-3.5" })
3374
+ }
3375
+ ) : null,
3376
+ !loading && type === "password" ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
3377
+ "button",
3378
+ {
3379
+ type: "button",
3380
+ tabIndex: -1,
3381
+ "aria-label": showPassword ? t("input.hidePassword") : t("input.showPassword"),
3382
+ onMouseDown: (event) => event.preventDefault(),
3383
+ onClick: () => setShowPassword((v) => !v),
3384
+ className: cn(
3385
+ "cursor-pointer flex size-5 shrink-0 items-center justify-center self-center rounded-md hover:bg-(--color-surface-muted) text-(--color-text-muted) transition-colors",
3386
+ size === "sm" ? "p-0.5" : "p-1"
3387
+ ),
3388
+ children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
3389
+ EyeIcon,
3390
+ {
3391
+ closed: showPassword,
3392
+ className: size === "sm" ? "size-3" : "size-3.5"
3393
+ }
3394
+ )
3395
+ }
3396
+ ) : null,
3397
+ !loading && trailingIcon ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { className: "flex items-center", children: trailingIcon }) : null
3398
+ ]
3399
+ }
3400
+ ) : null
3401
+ ] }),
3402
+ error ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("p", { className: "text-xs text-(--color-danger)", children: error }) : null,
3403
+ !error && hint ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("p", { className: "text-xs text-(--color-text-muted)", children: hint }) : null
3404
+ ]
3405
+ }
3406
+ );
2443
3407
  });
2444
3408
  DInput.displayName = "DInput";
2445
3409
  function normalizeDecimalInput(input, { scale = 4, integer: integer2 = false } = {}) {
2446
3410
  const decimalIndex = Math.max(input.lastIndexOf("."), input.lastIndexOf(","));
2447
3411
  const hasDecimal = !integer2 && decimalIndex >= 0;
2448
- const rawWhole = (hasDecimal ? input.slice(0, decimalIndex) : input).replace(/\D/g, "");
3412
+ const rawWhole = (hasDecimal ? input.slice(0, decimalIndex) : input).replace(
3413
+ /\D/g,
3414
+ ""
3415
+ );
2449
3416
  const rawFraction = hasDecimal ? input.slice(decimalIndex + 1).replace(/\D/g, "") : "";
2450
3417
  const whole = rawWhole.replace(/^0+(?=\d)/, "");
2451
3418
  if (!hasDecimal) return whole;
2452
3419
  return `${whole || "0"}.${rawFraction.slice(0, Math.max(0, scale))}`;
2453
3420
  }
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
- });
3421
+ var DDecimalInput = (0, import_react14.forwardRef)(
3422
+ function DDecimalInput2({ value, onValueChange, scale = 4, integer: integer2 = false, ...props }, ref) {
3423
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
3424
+ DInput,
3425
+ {
3426
+ ref,
3427
+ ...props,
3428
+ value,
3429
+ type: "text",
3430
+ inputMode: integer2 ? "numeric" : "decimal",
3431
+ onNativeChange: (event) => onValueChange(
3432
+ normalizeDecimalInput(event.target.value, { scale, integer: integer2 })
3433
+ )
3434
+ }
3435
+ );
3436
+ }
3437
+ );
2457
3438
  function formatCurrencyInputValue(value, { groupSeparator = ".", decimalSeparator = "," } = {}) {
2458
3439
  if (!value) return "";
2459
3440
  const normalized = normalizeDecimalInput(value);
2460
3441
  const [whole = "", fraction] = normalized.split(".");
2461
- const grouped = (whole || "0").replace(/\B(?=(\d{3})+(?!\d))/g, groupSeparator);
3442
+ const grouped = (whole || "0").replace(
3443
+ /\B(?=(\d{3})+(?!\d))/g,
3444
+ groupSeparator
3445
+ );
2462
3446
  return fraction === void 0 ? grouped : `${grouped}${decimalSeparator}${fraction}`;
2463
3447
  }
2464
3448
  function parseCurrencyInputValue(value, { groupSeparator = ".", decimalSeparator = "," } = {}) {
@@ -2473,44 +3457,58 @@ function parseCurrencyInputValue(value, { groupSeparator = ".", decimalSeparator
2473
3457
  if (!hasDecimal) return whole;
2474
3458
  return `${whole || "0"}.${fraction}`;
2475
3459
  }
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 }));
3460
+ var DCurrencyInput = (0, import_react14.forwardRef)(
3461
+ function DCurrencyInput2({
3462
+ value,
3463
+ onValueChange,
3464
+ currencySymbol = "Rp",
3465
+ groupSeparator = ".",
3466
+ decimalSeparator = ",",
3467
+ ...props
3468
+ }, forwardedRef) {
3469
+ const inputRef = (0, import_react14.useRef)(null);
3470
+ const pendingCaretDigitsAfterRef = (0, import_react14.useRef)(null);
3471
+ const displayed = formatCurrencyInputValue(value, {
3472
+ groupSeparator,
3473
+ decimalSeparator
3474
+ });
3475
+ (0, import_react14.useLayoutEffect)(() => {
3476
+ const pending = pendingCaretDigitsAfterRef.current;
3477
+ const input = inputRef.current;
3478
+ if (pending === null || !input || document.activeElement !== input)
3479
+ return;
3480
+ const nextCaret = caretFromDigitsAfter(input.value, pending);
3481
+ input.setSelectionRange(nextCaret, nextCaret);
3482
+ pendingCaretDigitsAfterRef.current = null;
3483
+ }, [displayed]);
3484
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
3485
+ DInput,
3486
+ {
3487
+ ref: (node) => {
3488
+ inputRef.current = node;
3489
+ assignRef(forwardedRef, node);
3490
+ },
3491
+ ...props,
3492
+ value: displayed,
3493
+ type: "text",
3494
+ inputMode: "decimal",
3495
+ prefix: currencySymbol,
3496
+ onNativeChange: (event) => {
3497
+ pendingCaretDigitsAfterRef.current = countDigitsAfterCaret(
3498
+ event.target.value,
3499
+ event.target.selectionStart
3500
+ );
3501
+ onValueChange(
3502
+ parseCurrencyInputValue(event.target.value, {
3503
+ groupSeparator,
3504
+ decimalSeparator
3505
+ })
3506
+ );
3507
+ }
2510
3508
  }
2511
- }
2512
- );
2513
- });
3509
+ );
3510
+ }
3511
+ );
2514
3512
 
2515
3513
  // src/loading/loading.tsx
2516
3514
  var import_jsx_runtime22 = require("react/jsx-runtime");
@@ -2535,7 +3533,7 @@ var dotClass = {
2535
3533
  warning: "bg-[var(--color-warning)]",
2536
3534
  error: "bg-[var(--color-danger)]"
2537
3535
  };
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";
3536
+ var iconButtonClass = "cursor-pointer 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
3537
  function DNotificationPanel({
2540
3538
  notifications,
2541
3539
  open,
@@ -2572,7 +3570,8 @@ function DNotificationPanel({
2572
3570
  if (!open) return;
2573
3571
  const onPointerDown = (event) => {
2574
3572
  const target = event.target;
2575
- if (floatingRef.current?.contains(target) || anchorRef?.current?.contains(target)) return;
3573
+ if (floatingRef.current?.contains(target) || anchorRef?.current?.contains(target))
3574
+ return;
2576
3575
  onClose();
2577
3576
  };
2578
3577
  const onKeyDown = (event) => {
@@ -2590,7 +3589,13 @@ function DNotificationPanel({
2590
3589
  }, [anchorRef, onClose, open]);
2591
3590
  if (!open || typeof document === "undefined") return null;
2592
3591
  const unread = notifications.filter((item) => !item.read).length;
2593
- const fallbackStyle = { position: "fixed", top: 72, right: 24, zIndex: 9999, visibility: "visible" };
3592
+ const fallbackStyle = {
3593
+ position: "fixed",
3594
+ top: 72,
3595
+ right: 24,
3596
+ zIndex: 9999,
3597
+ visibility: "visible"
3598
+ };
2594
3599
  return (0, import_react_dom3.createPortal)(
2595
3600
  /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
2596
3601
  "div",
@@ -2604,27 +3609,45 @@ function DNotificationPanel({
2604
3609
  "data-scroll-behavior": scrollBehavior,
2605
3610
  style: hasAnchor ? style : fallbackStyle,
2606
3611
  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)]",
3612
+ "w-[min(24rem,calc(100vw-16px))] overflow-hidden rounded-(--radius-panel) border border-(--color-border) bg-(--color-surface) shadow-(--shadow-lg)",
2608
3613
  hasAnchor && positioned && "animate-[dropdown-in_150ms_ease-out]",
2609
3614
  className
2610
3615
  ),
2611
3616
  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: [
3617
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "flex min-h-12 items-center justify-between border-b border-(--color-border) px-4 py-2", children: [
2613
3618
  /* @__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
3619
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: "truncate text-sm font-semibold text-(--color-text)", children: resolvedTitle }),
3620
+ unread > 0 ? /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: "flex h-5 min-w-5 items-center justify-center rounded-full bg-(--color-brand) px-1.5 text-[10px] font-bold text-(--color-brand-foreground)", children: unread }) : null
2616
3621
  ] }),
2617
3622
  /* @__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 }) })
3623
+ unread > 0 ? /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
3624
+ "button",
3625
+ {
3626
+ type: "button",
3627
+ "aria-label": t("notification.markAllRead"),
3628
+ onClick: onMarkAllRead,
3629
+ className: iconButtonClass,
3630
+ children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(CheckIcon, { size: 15 })
3631
+ }
3632
+ ) : null,
3633
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
3634
+ "button",
3635
+ {
3636
+ type: "button",
3637
+ "aria-label": t("notification.close"),
3638
+ onClick: onClose,
3639
+ className: iconButtonClass,
3640
+ children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(XIcon, { size: 15 })
3641
+ }
3642
+ )
2620
3643
  ] })
2621
3644
  ] }),
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)(
3645
+ /* @__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-(--color-text-muted)", children: resolvedEmptyMessage }) : notifications.map((item) => /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
2623
3646
  "div",
2624
3647
  {
2625
3648
  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"
3649
+ "group flex items-start gap-1 rounded-(--radius-menu-item) px-1 py-0.5 transition-colors hover:bg-(--color-surface-muted)/65",
3650
+ !item.read && "bg-(--color-brand)/5"
2628
3651
  ),
2629
3652
  children: [
2630
3653
  /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
@@ -2632,13 +3655,21 @@ function DNotificationPanel({
2632
3655
  {
2633
3656
  type: "button",
2634
3657
  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",
3658
+ className: "cursor-pointer flex min-w-0 flex-1 appearance-none items-start gap-3 rounded-(--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-(--color-focus)/25",
2636
3659
  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") }),
3660
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
3661
+ "span",
3662
+ {
3663
+ className: cn(
3664
+ "mt-1.5 size-2 shrink-0 rounded-full",
3665
+ !item.read ? dotClass[item.type] : "bg-transparent"
3666
+ )
3667
+ }
3668
+ ),
2638
3669
  /* @__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 })
3670
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: "block truncate text-sm font-medium text-(--color-text)", children: item.title }),
3671
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: "mt-0.5 line-clamp-2 block text-xs leading-5 text-(--color-text-muted)", children: item.message }),
3672
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: "mt-1 block text-[10px] text-(--color-text-muted)/70", children: item.createdAt })
2642
3673
  ] })
2643
3674
  ]
2644
3675
  }
@@ -2649,7 +3680,7 @@ function DNotificationPanel({
2649
3680
  type: "button",
2650
3681
  "aria-label": t("notification.dismiss", { title: item.title }),
2651
3682
  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",
3683
+ className: "cursor-pointer mt-1 grid size-7 shrink-0 appearance-none place-items-center rounded-md border-0 bg-transparent p-0 text-(--color-text-muted)/55 opacity-65 shadow-none outline-none transition-colors hover:bg-red-200 hover:text-red-400 focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-(--color-focus)/25 group-hover:opacity-100",
2653
3684
  children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(XIcon, { size: 13 })
2654
3685
  }
2655
3686
  )
@@ -2723,7 +3754,17 @@ var getStartOfMonth = (date2) => new Date(date2.getFullYear(), date2.getMonth(),
2723
3754
  var getEndOfMonth = (date2) => new Date(date2.getFullYear(), date2.getMonth() + 1, 0);
2724
3755
  var getStartOfYear = (date2) => new Date(date2.getFullYear(), 0, 1);
2725
3756
  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"];
3757
+ var QUICK_RANGE_TYPES = [
3758
+ "today",
3759
+ "yesterday",
3760
+ "this_week",
3761
+ "last_week",
3762
+ "this_month",
3763
+ "last_month",
3764
+ "this_year",
3765
+ "last_year",
3766
+ "all_time"
3767
+ ];
2727
3768
  var QUICK_RANGE_KEYS = {
2728
3769
  today: "rangeDatePicker.today",
2729
3770
  yesterday: "rangeDatePicker.yesterday",
@@ -2743,18 +3784,21 @@ function quickRange(type) {
2743
3784
  date2.setDate(date2.getDate() - 1);
2744
3785
  return { start: date2, end: new Date(date2) };
2745
3786
  }
2746
- if (type === "this_week") return { start: getStartOfWeek(now), end: getEndOfWeek(now) };
3787
+ if (type === "this_week")
3788
+ return { start: getStartOfWeek(now), end: getEndOfWeek(now) };
2747
3789
  if (type === "last_week") {
2748
3790
  const date2 = new Date(now);
2749
3791
  date2.setDate(date2.getDate() - 7);
2750
3792
  return { start: getStartOfWeek(date2), end: getEndOfWeek(date2) };
2751
3793
  }
2752
- if (type === "this_month") return { start: getStartOfMonth(now), end: getEndOfMonth(now) };
3794
+ if (type === "this_month")
3795
+ return { start: getStartOfMonth(now), end: getEndOfMonth(now) };
2753
3796
  if (type === "last_month") {
2754
3797
  const date2 = new Date(now.getFullYear(), now.getMonth() - 1, 1);
2755
3798
  return { start: getStartOfMonth(date2), end: getEndOfMonth(date2) };
2756
3799
  }
2757
- if (type === "this_year") return { start: getStartOfYear(now), end: getEndOfYear(now) };
3800
+ if (type === "this_year")
3801
+ return { start: getStartOfYear(now), end: getEndOfYear(now) };
2758
3802
  if (type === "last_year") {
2759
3803
  const date2 = new Date(now.getFullYear() - 1, 0, 1);
2760
3804
  return { start: getStartOfYear(date2), end: getEndOfYear(date2) };
@@ -2767,27 +3811,83 @@ function getQuickActive(type, start, end) {
2767
3811
  return isSameDate(start, target.start) && isSameDate(end, target.end);
2768
3812
  }
2769
3813
  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" }) });
3814
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
3815
+ "svg",
3816
+ {
3817
+ viewBox: "0 0 24 24",
3818
+ fill: "none",
3819
+ stroke: "currentColor",
3820
+ strokeWidth: "2",
3821
+ className: "size-4",
3822
+ children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("path", { d: direction === "left" ? "m15 18-6-6 6-6" : "m9 18 6-6-6-6" })
3823
+ }
3824
+ );
2771
3825
  }
2772
3826
  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
- ] });
3827
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
3828
+ "svg",
3829
+ {
3830
+ viewBox: "0 0 24 24",
3831
+ fill: "none",
3832
+ stroke: "currentColor",
3833
+ strokeWidth: "2",
3834
+ className: "size-4",
3835
+ children: [
3836
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("rect", { x: "3", y: "5", width: "18", height: "16", rx: "2" }),
3837
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("path", { d: "M16 3v4M8 3v4M3 10h18" })
3838
+ ]
3839
+ }
3840
+ );
2777
3841
  }
2778
3842
  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" }) });
3843
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
3844
+ "svg",
3845
+ {
3846
+ viewBox: "0 0 24 24",
3847
+ fill: "none",
3848
+ stroke: "currentColor",
3849
+ strokeWidth: "2",
3850
+ className: cn("size-3.5 transition-transform", open && "rotate-180"),
3851
+ children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("path", { d: "m6 9 6 6 6-6" })
3852
+ }
3853
+ );
2780
3854
  }
2781
3855
  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" }) });
3856
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
3857
+ "svg",
3858
+ {
3859
+ viewBox: "0 0 24 24",
3860
+ fill: "none",
3861
+ stroke: "currentColor",
3862
+ strokeWidth: "2",
3863
+ className: "size-3.5",
3864
+ children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("path", { d: "m18 6-12 12M6 6l12 12" })
3865
+ }
3866
+ );
2783
3867
  }
2784
3868
  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" }) });
3869
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
3870
+ "svg",
3871
+ {
3872
+ viewBox: "0 0 24 24",
3873
+ fill: "none",
3874
+ stroke: "currentColor",
3875
+ strokeWidth: "2",
3876
+ className: "size-3.5",
3877
+ children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("path", { d: "m5 12 4 4L19 6" })
3878
+ }
3879
+ );
2786
3880
  }
2787
- function RangeDropdownContent({ value, onChange }) {
3881
+ function RangeDropdownContent({
3882
+ value,
3883
+ onChange
3884
+ }) {
2788
3885
  const close = useDropdownClose();
2789
3886
  const { locale, t } = useDLocalization();
2790
- const days = (0, import_react16.useMemo)(() => getLocalizedWeekdayNames(locale, "short"), [locale]);
3887
+ const days = (0, import_react16.useMemo)(
3888
+ () => getLocalizedWeekdayNames(locale, "short"),
3889
+ [locale]
3890
+ );
2791
3891
  const months = (0, import_react16.useMemo)(() => getLocalizedMonthNames(locale), [locale]);
2792
3892
  const today = (0, import_react16.useMemo)(() => /* @__PURE__ */ new Date(), []);
2793
3893
  const selectedStart = (0, import_react16.useMemo)(() => parseDate2(value?.start), [value?.start]);
@@ -2795,7 +3895,9 @@ function RangeDropdownContent({ value, onChange }) {
2795
3895
  const [tempStart, setTempStart] = (0, import_react16.useState)(selectedStart);
2796
3896
  const [tempEnd, setTempEnd] = (0, import_react16.useState)(selectedEnd);
2797
3897
  const [quickType, setQuickType] = (0, import_react16.useState)(null);
2798
- const [leftMonth, setLeftMonth] = (0, import_react16.useState)(() => startOfMonth(selectedStart || today));
3898
+ const [leftMonth, setLeftMonth] = (0, import_react16.useState)(
3899
+ () => startOfMonth(selectedStart || today)
3900
+ );
2799
3901
  const rightMonth = (0, import_react16.useMemo)(() => addMonth(leftMonth, 1), [leftMonth]);
2800
3902
  const syncTempFromValue = () => {
2801
3903
  const nextStart = parseDate2(value?.start);
@@ -2842,15 +3944,42 @@ function RangeDropdownContent({ value, onChange }) {
2842
3944
  const firstDay = new Date(year, month, 1).getDay();
2843
3945
  return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "min-w-0 flex-1", children: [
2844
3946
  /* @__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: [
3947
+ side === "left" ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
3948
+ "button",
3949
+ {
3950
+ type: "button",
3951
+ "aria-label": t("common.previousMonth"),
3952
+ onClick: () => setLeftMonth((prev) => addMonth(prev, -1)),
3953
+ className: "cursor-pointer flex size-7 items-center justify-center rounded-lg text-(--color-text-muted) hover:bg-(--color-surface-muted)",
3954
+ children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ChevronIcon, { direction: "left" })
3955
+ }
3956
+ ) : /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "size-7" }),
3957
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("span", { className: "text-xs font-semibold text-(--color-text) sm:text-sm", children: [
2847
3958
  months[month],
2848
3959
  " ",
2849
3960
  year
2850
3961
  ] }),
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" }) })
3962
+ side === "right" ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
3963
+ "button",
3964
+ {
3965
+ type: "button",
3966
+ "aria-label": t("common.nextMonth"),
3967
+ onClick: () => setLeftMonth((prev) => addMonth(prev, 1)),
3968
+ className: "cursor-pointer flex size-7 items-center justify-center rounded-lg text-(--color-text-muted) hover:bg-(--color-surface-muted)",
3969
+ children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ChevronIcon, { direction: "right" })
3970
+ }
3971
+ ) : /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
3972
+ "button",
3973
+ {
3974
+ type: "button",
3975
+ "aria-label": t("common.nextMonth"),
3976
+ onClick: () => setLeftMonth((prev) => addMonth(prev, 1)),
3977
+ className: "cursor-pointer flex size-7 items-center justify-center rounded-lg text-(--color-text-muted) hover:bg-(--color-surface-muted) sm:invisible",
3978
+ children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ChevronIcon, { direction: "right" })
3979
+ }
3980
+ )
2852
3981
  ] }),
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}`)) }),
3982
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "mb-1.5 grid grid-cols-7 gap-0.5 text-[10px] text-(--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
3983
  /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "grid grid-cols-7 gap-0.5", children: [
2855
3984
  Array.from({ length: firstDay }).map((_, index) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", {}, `${side}-empty-${index}`)),
2856
3985
  Array.from({ length: daysInMonth }, (_, index) => {
@@ -2858,9 +3987,26 @@ function RangeDropdownContent({ value, onChange }) {
2858
3987
  const start = isSameDate(date2, tempStart);
2859
3988
  const end = isSameDate(date2, tempEnd);
2860
3989
  const selected = start || end;
2861
- const inRange = Boolean(tempStart && tempEnd && date2 > tempStart && date2 < tempEnd);
3990
+ const inRange = Boolean(
3991
+ tempStart && tempEnd && date2 > tempStart && date2 < tempEnd
3992
+ );
2862
3993
  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)}`);
3994
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
3995
+ "button",
3996
+ {
3997
+ type: "button",
3998
+ onClick: () => selectDate(date2),
3999
+ className: cn(
4000
+ "cursor-pointer h-8 rounded-md text-xs transition-colors sm:h-8 sm:text-sm",
4001
+ selected && "bg-(--color-brand) font-semibold text-white",
4002
+ !selected && inRange && "bg-(--color-brand)/10 text-(--color-brand)",
4003
+ !selected && !inRange && "hover:bg-(--color-surface-muted)",
4004
+ !selected && isToday && "ring-1 ring-(--color-brand)/40"
4005
+ ),
4006
+ children: index + 1
4007
+ },
4008
+ `${side}-${formatDate(date2)}`
4009
+ );
2864
4010
  })
2865
4011
  ] })
2866
4012
  ] });
@@ -2869,31 +4015,72 @@ function RangeDropdownContent({ value, onChange }) {
2869
4015
  return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "w-[min(560px,calc(100vw-16px))] p-3", children: [
2870
4016
  /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "mb-3", children: [
2871
4017
  /* @__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") })
4018
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("p", { className: "text-xs font-semibold text-(--color-text)", children: t("rangeDatePicker.quickRange") }),
4019
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: "text-[10px] text-(--color-text-muted)", children: t("common.optional") })
2874
4020
  ] }),
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)) })
4021
+ /* @__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)(
4022
+ "button",
4023
+ {
4024
+ type: "button",
4025
+ onClick: () => selectQuick(type),
4026
+ className: cn(
4027
+ "cursor-pointer min-h-8 rounded-lg px-2 py-1.5 text-center text-[11px] font-medium leading-tight transition-colors",
4028
+ getQuickActive(type, tempStart, tempEnd) ? "bg-(--color-brand)/10 text-(--color-brand)" : "bg-(--color-surface-muted)/55 text-(--color-text-muted) hover:bg-(--color-surface-muted) hover:text-(--color-text)"
4029
+ ),
4030
+ children: t(QUICK_RANGE_KEYS[type])
4031
+ },
4032
+ type
4033
+ )) })
2876
4034
  ] }),
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: [
4035
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "grid gap-3 border-t border-(--color-border) pt-3 sm:grid-cols-2", children: [
2878
4036
  renderCalendar(leftMonth, "left"),
2879
4037
  renderCalendar(rightMonth, "right")
2880
4038
  ] }),
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 }),
4039
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "mt-3 flex flex-col gap-2 border-t border-(--color-border) pt-3 sm:flex-row sm:items-center sm:justify-between", children: [
4040
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "min-w-0 truncate text-[11px] text-(--color-text-muted)", children: summary }),
2883
4041
  /* @__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
- ] })
4042
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
4043
+ "button",
4044
+ {
4045
+ type: "button",
4046
+ onClick: () => {
4047
+ syncTempFromValue();
4048
+ close?.();
4049
+ },
4050
+ className: "cursor-pointer h-8 rounded-lg px-3 text-xs font-medium text-(--color-text-muted) hover:bg-(--color-surface-muted)",
4051
+ children: t("common.cancel")
4052
+ }
4053
+ ),
4054
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
4055
+ "button",
4056
+ {
4057
+ type: "button",
4058
+ disabled: quickType !== "all_time" && (!tempStart || !tempEnd),
4059
+ onClick: apply,
4060
+ className: "cursor-pointer inline-flex h-8 items-center gap-1.5 rounded-lg bg-(--color-brand) px-3 text-xs font-semibold text-white hover:brightness-95 disabled:cursor-not-allowed disabled:opacity-50",
4061
+ children: [
4062
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(CheckIcon2, {}),
4063
+ t("common.apply")
4064
+ ]
4065
+ }
4066
+ )
2892
4067
  ] })
2893
4068
  ] })
2894
4069
  ] });
2895
4070
  }
2896
- function DRangeDatePicker({ label, placeholder, value, size = "md", onChange, error, hint, disabled = false, clearable = true, containerClassName, scrollBehavior = "close" }) {
4071
+ function DRangeDatePicker({
4072
+ label,
4073
+ placeholder,
4074
+ value,
4075
+ size = "md",
4076
+ onChange,
4077
+ error,
4078
+ hint,
4079
+ disabled = false,
4080
+ clearable = true,
4081
+ containerClassName,
4082
+ scrollBehavior = "close"
4083
+ }) {
2897
4084
  const id = (0, import_react16.useId)();
2898
4085
  const { locale, t } = useDLocalization();
2899
4086
  const months = (0, import_react16.useMemo)(() => getLocalizedMonthNames(locale), [locale]);
@@ -2902,40 +4089,124 @@ function DRangeDatePicker({ label, placeholder, value, size = "md", onChange, er
2902
4089
  const date2 = parseDate2(raw);
2903
4090
  return date2 ? `${date2.getDate()} ${months[date2.getMonth()]} ${date2.getFullYear()}` : "";
2904
4091
  };
2905
- const displayValue = (0, import_react16.useMemo)(() => value?.start && value?.end ? `${formatDisplayDate(value.start)} - ${formatDisplayDate(value.end)}` : "", [value?.start, value?.end, months]);
4092
+ const displayValue = (0, import_react16.useMemo)(
4093
+ () => value?.start && value?.end ? `${formatDisplayDate(value.start)} - ${formatDisplayDate(value.end)}` : "",
4094
+ [value?.start, value?.end, months]
4095
+ );
2906
4096
  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
- ] });
4097
+ const hasClearButton = clearable && Boolean(displayValue) && !disabled;
4098
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
4099
+ "div",
4100
+ {
4101
+ className: cn(
4102
+ "flex min-w-0 flex-col items-start gap-1.5",
4103
+ containerClassName
4104
+ ),
4105
+ children: [
4106
+ label ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
4107
+ "label",
4108
+ {
4109
+ htmlFor: id,
4110
+ className: cn(
4111
+ s.label,
4112
+ "inline-block w-fit font-medium text-(--color-text)"
4113
+ ),
4114
+ children: label
4115
+ }
4116
+ ) : null,
4117
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
4118
+ DDropdown,
4119
+ {
4120
+ placement: "bottom-end",
4121
+ contentRole: "dialog",
4122
+ contentPadding: false,
4123
+ contentClassName: "overflow-hidden",
4124
+ scrollBehavior,
4125
+ trigger: ({ open }) => /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
4126
+ "button",
4127
+ {
4128
+ id,
4129
+ type: "button",
4130
+ disabled,
4131
+ "aria-invalid": Boolean(error) || void 0,
4132
+ className: cn(
4133
+ "inline-flex w-82.5 max-w-full items-center gap-2 rounded-lg border bg-(--color-surface) text-left",
4134
+ "focus:border-(--color-brand) focus:outline-none focus:ring-2 focus:ring-(--color-brand)/20",
4135
+ "disabled:cursor-not-allowed disabled:bg-(--color-surface-muted) disabled:opacity-50",
4136
+ s.input,
4137
+ error ? "border-(--color-danger)" : "border-(--color-border)",
4138
+ displayValue ? "text-(--color-text)" : "text-(--color-text-muted)/60"
4139
+ ),
4140
+ children: [
4141
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: "flex size-4 shrink-0 items-center justify-center text-(--color-text-muted)", children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(CalendarIcon2, {}) }),
4142
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: "min-w-0 flex-1 truncate whitespace-nowrap", children: displayValue || resolvedPlaceholder }),
4143
+ clearable && displayValue && !disabled ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
4144
+ "span",
4145
+ {
4146
+ role: "button",
4147
+ tabIndex: 0,
4148
+ "aria-label": t("rangeDatePicker.clear"),
4149
+ onMouseDown: (event) => {
4150
+ event.preventDefault();
4151
+ event.stopPropagation();
4152
+ },
4153
+ onClick: (event) => {
4154
+ event.preventDefault();
4155
+ event.stopPropagation();
4156
+ onChange?.({
4157
+ start: void 0,
4158
+ end: void 0
4159
+ });
4160
+ },
4161
+ className: "flex size-4 shrink-0 items-center justify-center self-center rounded-md hover:bg-(--color-surface-muted) cursor-pointer text-(--color-text-muted) transition-colors",
4162
+ children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ClearIcon5, {})
4163
+ }
4164
+ ) : null,
4165
+ !disabled ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: "flex size-4 shrink-0 items-center justify-center self-center rounded-md hover:bg-(--color-surface-muted) cursor-pointer text-(--color-text-muted) transition-colors", children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ChevronDownIcon2, { open }) }) : null
4166
+ ]
4167
+ }
4168
+ ),
4169
+ children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(RangeDropdownContent, { value, onChange })
4170
+ }
4171
+ ),
4172
+ error ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("p", { className: "text-xs text-(--color-danger)", children: error }) : null,
4173
+ !error && hint ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("p", { className: "text-xs text-(--color-text-muted)", children: hint }) : null
4174
+ ]
4175
+ }
4176
+ );
2926
4177
  }
2927
4178
 
2928
4179
  // src/search-input/search-input.tsx
2929
4180
  var import_react17 = require("react");
2930
4181
  var import_jsx_runtime26 = require("react/jsx-runtime");
2931
4182
  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
- ] });
4183
+ return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(
4184
+ "svg",
4185
+ {
4186
+ viewBox: "0 0 24 24",
4187
+ fill: "none",
4188
+ stroke: "currentColor",
4189
+ strokeWidth: "2",
4190
+ className: "size-3.5",
4191
+ children: [
4192
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("circle", { cx: "11", cy: "11", r: "7" }),
4193
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("path", { d: "m20 20-4-4" })
4194
+ ]
4195
+ }
4196
+ );
2936
4197
  }
2937
4198
  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" }) });
4199
+ return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
4200
+ "svg",
4201
+ {
4202
+ viewBox: "0 0 24 24",
4203
+ fill: "none",
4204
+ stroke: "currentColor",
4205
+ strokeWidth: "2",
4206
+ className: "size-3.5",
4207
+ children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("path", { d: "m18 6-12 12M6 6l12 12" })
4208
+ }
4209
+ );
2939
4210
  }
2940
4211
  function DSearchInput({
2941
4212
  value,
@@ -2983,7 +4254,8 @@ function DSearchInput({
2983
4254
  (0, import_react17.useEffect)(() => {
2984
4255
  const handleClickOutside = (event) => {
2985
4256
  if (!wrapperRef.current) return;
2986
- if (!wrapperRef.current.contains(event.target) && !localValue) setActive(false);
4257
+ if (!wrapperRef.current.contains(event.target) && !localValue)
4258
+ setActive(false);
2987
4259
  };
2988
4260
  document.addEventListener("mousedown", handleClickOutside);
2989
4261
  return () => document.removeEventListener("mousedown", handleClickOutside);
@@ -3006,10 +4278,14 @@ function DSearchInput({
3006
4278
  {
3007
4279
  ref: wrapperRef,
3008
4280
  "data-ds-component": "search-input",
3009
- className: cn("w-full sm:w-auto", align === "right" ? "sm:mr-3" : "sm:ml-0", className),
4281
+ className: cn(
4282
+ "w-full sm:w-auto",
4283
+ align === "right" ? "sm:mr-3" : "sm:ml-0",
4284
+ className
4285
+ ),
3010
4286
  children: [
3011
4287
  /* @__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, {}) }),
4288
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { className: "pointer-events-none absolute left-3 top-1/2 -translate-y-1/2 text-(--color-text-muted)", children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(SearchIcon2, {}) }),
3013
4289
  /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
3014
4290
  "input",
3015
4291
  {
@@ -3020,7 +4296,7 @@ function DSearchInput({
3020
4296
  if (event.target.value) setActive(true);
3021
4297
  },
3022
4298
  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"
4299
+ className: "cursor-pointer h-9 w-full appearance-none rounded-xl border border-(--color-border) bg-(--color-background) pl-9 pr-9 text-sm text-(--color-text) outline-none shadow-sm placeholder:text-(--color-text-muted)/70 focus:border-(--color-brand) focus:ring-2 focus:ring-(--color-brand)/20"
3024
4300
  }
3025
4301
  ),
3026
4302
  localValue ? /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
@@ -3029,7 +4305,7 @@ function DSearchInput({
3029
4305
  type: "button",
3030
4306
  "aria-label": t("searchInput.clear"),
3031
4307
  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)]",
4308
+ className: "absolute right-2 top-1/2 -translate-y-1/2 appearance-none cursor-pointer flex size-5 shrink-0 items-center justify-center self-center rounded-md hover:bg-(--color-surface-muted) text-(--color-text-muted) transition-colors",
3033
4309
  children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(ClearIcon6, {})
3034
4310
  }
3035
4311
  ) : null
@@ -3037,18 +4313,30 @@ function DSearchInput({
3037
4313
  /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
3038
4314
  "div",
3039
4315
  {
3040
- className: cn("relative hidden items-center transition-[width] duration-200 ease-out sm:flex", align === "right" ? "justify-end" : "justify-start"),
4316
+ className: cn(
4317
+ "relative hidden items-center transition-[width] duration-200 ease-out sm:flex",
4318
+ align === "right" ? "justify-end" : "justify-start"
4319
+ ),
3041
4320
  style: { width: active ? expandedWidth : "44px" },
3042
4321
  children: /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(
3043
4322
  "div",
3044
4323
  {
3045
4324
  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)]"
4325
+ "relative h-9 w-full overflow-hidden rounded-xl border border-(--color-border) bg-(--color-background) shadow-sm transition-all duration-200 ease-out focus-within:border-(--color-brand) focus-within:ring-2 focus-within:ring-(--color-brand)/20",
4326
+ active ? "cursor-text" : "cursor-pointer hover:bg-(--color-surface-muted)"
3048
4327
  ),
3049
4328
  onClick: () => setActive(true),
3050
4329
  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, {}) }),
4330
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
4331
+ "span",
4332
+ {
4333
+ className: cn(
4334
+ "pointer-events-none absolute top-1/2 -translate-y-1/2 text-(--color-text-muted) transition-all duration-200 ease-out",
4335
+ active ? "left-3" : "left-1/2 -translate-x-1/2"
4336
+ ),
4337
+ children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(SearchIcon2, {})
4338
+ }
4339
+ ),
3052
4340
  /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
3053
4341
  "input",
3054
4342
  {
@@ -3064,7 +4352,7 @@ function DSearchInput({
3064
4352
  },
3065
4353
  placeholder: resolvedPlaceholder,
3066
4354
  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",
4355
+ "h-full w-full appearance-none border-0 bg-transparent pl-9 pr-9 text-sm text-(--color-text) outline-none placeholder:text-(--color-text-muted)/70 transition-opacity duration-150 ease-out",
3068
4356
  active ? "opacity-100" : "pointer-events-none opacity-0"
3069
4357
  )
3070
4358
  }
@@ -3079,7 +4367,7 @@ function DSearchInput({
3079
4367
  event.stopPropagation();
3080
4368
  clearSearch();
3081
4369
  },
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)]",
4370
+ className: "absolute right-2 top-1/2 -translate-y-1/2 appearance-none cursor-pointer flex size-5 shrink-0 items-center justify-center self-center rounded-md hover:bg-(--color-surface-muted) text-(--color-text-muted) transition-colors",
3083
4371
  children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(ClearIcon6, {})
3084
4372
  }
3085
4373
  ) : null
@@ -3097,183 +4385,347 @@ function DSearchInput({
3097
4385
  var import_react18 = require("react");
3098
4386
  var import_jsx_runtime27 = require("react/jsx-runtime");
3099
4387
  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" }) });
4388
+ return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
4389
+ "svg",
4390
+ {
4391
+ viewBox: "0 0 24 24",
4392
+ fill: "none",
4393
+ stroke: "currentColor",
4394
+ strokeWidth: "2",
4395
+ className: cn("size-3.5 transition-transform", open && "rotate-180"),
4396
+ "aria-hidden": "true",
4397
+ children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("path", { d: "m6 9 6 6 6-6" })
4398
+ }
4399
+ );
3101
4400
  }
3102
4401
  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" }) });
4402
+ return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
4403
+ "svg",
4404
+ {
4405
+ viewBox: "0 0 24 24",
4406
+ fill: "none",
4407
+ stroke: "currentColor",
4408
+ strokeWidth: "2",
4409
+ className: "size-3.5",
4410
+ children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("path", { d: "m18 6-12 12M6 6l12 12" })
4411
+ }
4412
+ );
3104
4413
  }
3105
4414
  function selectOptionsFromChildren(children) {
3106
4415
  return import_react18.Children.toArray(children).flatMap((child) => {
3107
- if (!(0, import_react18.isValidElement)(child)) return [];
4416
+ if (!(0, import_react18.isValidElement)(child))
4417
+ return [];
3108
4418
  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 } }];
4419
+ return [
4420
+ {
4421
+ value: child.props.value,
4422
+ label: child.props.children,
4423
+ ...child.props.disabled === void 0 ? {} : { disabled: child.props.disabled }
4424
+ }
4425
+ ];
3110
4426
  });
3111
4427
  }
3112
4428
  function sameValue2(left, right) {
3113
4429
  return String(left ?? "") === String(right ?? "");
3114
4430
  }
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") {
4431
+ var DSelect = (0, import_react18.forwardRef)(
4432
+ function DSelect2({
4433
+ className,
4434
+ children,
4435
+ label,
4436
+ hint,
4437
+ error,
4438
+ containerClassName,
4439
+ id: providedId,
4440
+ options,
4441
+ placeholder,
4442
+ clearable = true,
4443
+ searchable = false,
4444
+ loading = false,
4445
+ emptyMessage,
4446
+ asyncErrorMessage,
4447
+ fetchOptions,
4448
+ refetchKey,
4449
+ onFetchError,
4450
+ onValueChange,
4451
+ onChange,
4452
+ value,
4453
+ defaultValue = null,
4454
+ disabled = false,
4455
+ size = "md",
4456
+ debounceMs = 300,
4457
+ scrollBehavior = "reposition",
4458
+ ...props
4459
+ }, ref) {
4460
+ const generatedId = (0, import_react18.useId)();
4461
+ const id = providedId ?? generatedId;
4462
+ const { t } = useDLocalization();
4463
+ const s = INPUT_SIZE_STYLES[size];
4464
+ const requestIdRef = (0, import_react18.useRef)(0);
4465
+ const resolveRequestIdRef = (0, import_react18.useRef)(0);
4466
+ const [query, setQuery] = (0, import_react18.useState)("");
4467
+ const [activeIndex, setActiveIndex] = (0, import_react18.useState)(0);
4468
+ const [isOpen, setOpen] = (0, import_react18.useState)(false);
4469
+ const [internalValue, setInternalValue] = (0, import_react18.useState)(
4470
+ defaultValue
4471
+ );
4472
+ const [resolvedAsyncSelection, setResolvedAsyncSelection] = (0, import_react18.useState)(null);
4473
+ const [asyncOptions, setAsyncOptions] = (0, import_react18.useState)(
4474
+ []
4475
+ );
4476
+ const [isFetching, setFetching] = (0, import_react18.useState)(false);
4477
+ const [fetchError, setFetchError] = (0, import_react18.useState)(null);
4478
+ const selectedValue = value === void 0 ? internalValue : value;
4479
+ const resolvedPlaceholder = placeholder ?? t("select.placeholder");
4480
+ const resolvedEmptyMessage = emptyMessage ?? t("select.empty");
4481
+ const resolvedAsyncErrorMessage = asyncErrorMessage ?? t("select.asyncError");
4482
+ const staticOptions = (0, import_react18.useMemo)(
4483
+ () => options?.slice() ?? selectOptionsFromChildren(children),
4484
+ [children, options]
4485
+ );
4486
+ const isAsync = Boolean(fetchOptions);
4487
+ const sourceOptions = isAsync ? asyncOptions : staticOptions;
4488
+ const filteredOptions = (0, import_react18.useMemo)(
4489
+ () => !isAsync && searchable && query ? sourceOptions.filter(
4490
+ (option) => String(option.label).toLocaleLowerCase().includes(query.toLocaleLowerCase())
4491
+ ) : sourceOptions,
4492
+ [isAsync, query, searchable, sourceOptions]
4493
+ );
4494
+ const selected = staticOptions.find((option) => sameValue2(option.value, selectedValue)) ?? (sameValue2(resolvedAsyncSelection?.value, selectedValue) ? resolvedAsyncSelection : null);
4495
+ const showClear = Boolean(clearable && selected && !disabled);
4496
+ (0, import_react18.useEffect)(() => {
4497
+ if (!isAsync || !fetchOptions || !isOpen) return;
4498
+ const requestId = ++requestIdRef.current;
4499
+ const timeout = window.setTimeout(() => {
4500
+ setFetching(true);
4501
+ setFetchError(null);
4502
+ void fetchOptions(query).then((result) => {
4503
+ if (requestId === requestIdRef.current) setAsyncOptions(result);
4504
+ }).catch((nextError) => {
4505
+ if (requestId !== requestIdRef.current) return;
4506
+ setFetchError(nextError);
4507
+ onFetchError?.(nextError);
4508
+ }).finally(() => {
4509
+ if (requestId === requestIdRef.current) setFetching(false);
4510
+ });
4511
+ }, debounceMs);
4512
+ return () => window.clearTimeout(timeout);
4513
+ }, [
4514
+ debounceMs,
4515
+ fetchOptions,
4516
+ isAsync,
4517
+ isOpen,
4518
+ onFetchError,
4519
+ query,
4520
+ refetchKey
4521
+ ]);
4522
+ (0, import_react18.useEffect)(() => {
4523
+ if (!isAsync || !fetchOptions || selectedValue == null || selectedValue === "" || sameValue2(resolvedAsyncSelection?.value, selectedValue))
4524
+ return;
4525
+ const requestId = ++resolveRequestIdRef.current;
4526
+ void fetchOptions("").then((result) => {
4527
+ if (requestId !== resolveRequestIdRef.current) return;
4528
+ const found = result.find(
4529
+ (option) => sameValue2(option.value, selectedValue)
4530
+ );
4531
+ if (found) setResolvedAsyncSelection(found);
4532
+ }).catch((nextError) => onFetchError?.(nextError));
4533
+ }, [
4534
+ fetchOptions,
4535
+ isAsync,
4536
+ onFetchError,
4537
+ refetchKey,
4538
+ resolvedAsyncSelection?.value,
4539
+ selectedValue
4540
+ ]);
4541
+ const selectedIndex = () => {
4542
+ const index = filteredOptions.findIndex(
4543
+ (option) => sameValue2(option.value, selectedValue)
4544
+ );
4545
+ return index >= 0 ? index : 0;
4546
+ };
4547
+ const choose = (option) => {
4548
+ if (value === void 0) setInternalValue(option.value);
4549
+ setResolvedAsyncSelection(option);
4550
+ onValueChange?.(option.value);
4551
+ onChange?.(option.value);
3220
4552
  setOpen(false);
3221
4553
  setQuery("");
3222
- return;
3223
- }
3224
- if (event.key === "ArrowDown" || event.key === "ArrowUp") {
4554
+ };
4555
+ const clear = (event) => {
3225
4556
  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);
4557
+ event.stopPropagation();
4558
+ if (value === void 0) setInternalValue(null);
4559
+ setResolvedAsyncSelection(null);
4560
+ onValueChange?.(null);
4561
+ onChange?.(null);
4562
+ setQuery("");
4563
+ };
4564
+ const handleTriggerKeyDown = (event) => {
4565
+ if (event.key === "Escape") {
4566
+ setOpen(false);
4567
+ setQuery("");
3231
4568
  return;
3232
4569
  }
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);
4570
+ if (event.key === "ArrowDown" || event.key === "ArrowUp") {
4571
+ event.preventDefault();
4572
+ const count = filteredOptions.length || 1;
4573
+ if (!isOpen) {
4574
+ const start = selectedIndex();
4575
+ setOpen(true);
4576
+ setActiveIndex(
4577
+ event.key === "ArrowDown" ? (start + 1) % count : (start - 1 + count) % count
4578
+ );
4579
+ return;
4580
+ }
4581
+ setActiveIndex(
4582
+ (index) => event.key === "ArrowDown" ? (index + 1) % count : (index - 1 + count) % count
4583
+ );
4584
+ return;
3243
4585
  }
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
- });
4586
+ if (event.key === "Enter" || event.key === " ") {
4587
+ event.preventDefault();
4588
+ const active = filteredOptions[activeIndex];
4589
+ if (isOpen && active && !active.disabled) choose(active);
4590
+ else {
4591
+ setActiveIndex(selectedIndex());
4592
+ setOpen(true);
4593
+ }
4594
+ }
4595
+ };
4596
+ return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
4597
+ "div",
4598
+ {
4599
+ "data-ds-component": "select",
4600
+ className: cn("flex min-w-0 flex-col gap-1.5", containerClassName),
4601
+ children: [
4602
+ label ? /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
4603
+ "label",
4604
+ {
4605
+ htmlFor: id,
4606
+ className: cn(
4607
+ s.label,
4608
+ "inline-block w-fit font-medium text-(--color-text)"
4609
+ ),
4610
+ children: label
4611
+ }
4612
+ ) : null,
4613
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
4614
+ DDropdown,
4615
+ {
4616
+ matchWidth: true,
4617
+ open: isOpen,
4618
+ onOpenChange: (next) => {
4619
+ setOpen(next);
4620
+ if (next && !query) setActiveIndex(selectedIndex());
4621
+ },
4622
+ contentRole: "listbox",
4623
+ contentPadding: false,
4624
+ contentClassName: "overflow-hidden",
4625
+ scrollBehavior,
4626
+ onClose: () => {
4627
+ setOpen(false);
4628
+ setQuery("");
4629
+ },
4630
+ trigger: ({ open }) => /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: "relative", children: [
4631
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
4632
+ "button",
4633
+ {
4634
+ ...props,
4635
+ ref,
4636
+ id,
4637
+ type: "button",
4638
+ disabled,
4639
+ "aria-invalid": Boolean(error) || void 0,
4640
+ "aria-haspopup": "listbox",
4641
+ "aria-expanded": open,
4642
+ "aria-controls": `${id}-listbox`,
4643
+ onKeyDown: handleTriggerKeyDown,
4644
+ className: cn(
4645
+ "cursor-pointer flex w-full items-center rounded-(--radius-control) border bg-(--color-surface) text-left transition-colors duration-150 focus:border-(--color-brand) focus:outline-none focus:ring-2 focus:ring-(--color-brand)/20 disabled:cursor-not-allowed disabled:bg-(--color-surface-muted) disabled:opacity-50",
4646
+ s.input,
4647
+ error ? "border-(--color-danger)" : "border-(--color-border)",
4648
+ selected ? "text-(--color-text)" : "text-(--color-text-muted)/60",
4649
+ showClear ? size === "sm" ? "pr-14" : "pr-16" : "pr-10",
4650
+ className
4651
+ ),
4652
+ children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { className: "min-w-0 flex-1 truncate", children: selected ? selected.label : resolvedPlaceholder })
4653
+ }
4654
+ ),
4655
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
4656
+ "div",
4657
+ {
4658
+ className: cn(
4659
+ "absolute top-1/2 flex -translate-y-1/2 items-center gap-1.5 text-(--color-text-muted)",
4660
+ size === "sm" ? "right-2" : "right-2.5"
4661
+ ),
4662
+ children: [
4663
+ showClear ? /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
4664
+ "span",
4665
+ {
4666
+ role: "button",
4667
+ tabIndex: -1,
4668
+ "aria-label": t("select.clear"),
4669
+ onMouseDown: (event) => event.preventDefault(),
4670
+ onClick: clear,
4671
+ className: "cursor-pointer flex size-4 shrink-0 items-center justify-center self-center rounded-md hover:bg-(--color-surface-muted) text-(--color-text-muted) transition-colors",
4672
+ children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(ClearIcon7, {})
4673
+ }
4674
+ ) : null,
4675
+ !disabled ? /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(ChevronDownIcon3, { open }) : null
4676
+ ]
4677
+ }
4678
+ )
4679
+ ] }),
4680
+ children: /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { id: `${id}-listbox`, className: "max-h-60 overflow-hidden", children: [
4681
+ searchable ? /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: "border-b border-(--color-border) p-1.5", children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
4682
+ "input",
4683
+ {
4684
+ autoFocus: true,
4685
+ value: query,
4686
+ onChange: (event) => {
4687
+ setQuery(event.target.value);
4688
+ setActiveIndex(0);
4689
+ },
4690
+ placeholder: t("select.searchPlaceholder"),
4691
+ className: "h-8 w-full rounded-(--radius-control) border border-(--color-border) bg-(--color-background) px-2.5 text-xs text-(--color-text) outline-none focus:border-(--color-brand) focus:ring-2 focus:ring-(--color-brand)/20"
4692
+ }
4693
+ ) }) : null,
4694
+ /* @__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-(--color-text-muted)", children: t("select.loading") }) : fetchError ? /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("p", { className: "px-3 py-2 text-sm text-(--color-danger)", children: resolvedAsyncErrorMessage }) : filteredOptions.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("p", { className: "px-3 py-2 text-sm text-(--color-text-muted)", children: resolvedEmptyMessage }) : filteredOptions.map((option, index) => {
4695
+ const isSelected = sameValue2(option.value, selectedValue);
4696
+ return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
4697
+ "button",
4698
+ {
4699
+ type: "button",
4700
+ role: "option",
4701
+ "aria-selected": isSelected,
4702
+ disabled: option.disabled,
4703
+ onMouseEnter: () => setActiveIndex(index),
4704
+ onMouseDown: (event) => event.preventDefault(),
4705
+ onClick: (event) => {
4706
+ event.stopPropagation();
4707
+ if (!option.disabled) choose(option);
4708
+ },
4709
+ className: cn(
4710
+ "cursor-pointer w-full rounded-(--radius-menu-item) px-3 py-2 text-left text-sm text-(--color-text) transition-colors hover:bg-(--color-surface-muted) disabled:cursor-not-allowed disabled:opacity-50",
4711
+ isSelected && "bg-(--color-brand)/10 font-medium text-(--color-brand)",
4712
+ index === activeIndex && !isSelected && "bg-(--color-surface-muted)"
4713
+ ),
4714
+ children: option.label
4715
+ },
4716
+ String(option.value)
4717
+ );
4718
+ }) })
4719
+ ] })
4720
+ }
4721
+ ),
4722
+ error ? /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("p", { className: "text-xs text-(--color-danger)", children: error }) : null,
4723
+ !error && hint ? /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("p", { className: "text-xs text-(--color-text-muted)", children: hint }) : null
4724
+ ]
4725
+ }
4726
+ );
4727
+ }
4728
+ );
3277
4729
  DSelect.displayName = "DSelect";
3278
4730
 
3279
4731
  // src/select-filter/select-filter.tsx
@@ -3500,18 +4952,22 @@ var import_react21 = require("react");
3500
4952
  var import_jsx_runtime32 = require("react/jsx-runtime");
3501
4953
  function getPaginationPages(page, totalPages) {
3502
4954
  const count = Math.min(Math.max(totalPages, 1), 5);
3503
- if (totalPages <= 5) return Array.from({ length: count }, (_, index) => index + 1);
4955
+ if (totalPages <= 5)
4956
+ return Array.from({ length: count }, (_, index) => index + 1);
3504
4957
  const start = Math.min(Math.max(page - 2, 1), totalPages - 4);
3505
4958
  return Array.from({ length: 5 }, (_, index) => start + index);
3506
4959
  }
3507
4960
  function rawValue(row, key) {
3508
- if (row && typeof row === "object") return row[key];
4961
+ if (row && typeof row === "object")
4962
+ return row[key];
3509
4963
  return void 0;
3510
4964
  }
3511
4965
  function toDisplay(value, t) {
3512
4966
  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);
4967
+ if (typeof value === "boolean")
4968
+ return value ? t("common.yes") : t("common.no");
4969
+ if (typeof value === "string" || typeof value === "number")
4970
+ return String(value);
3515
4971
  return "-";
3516
4972
  }
3517
4973
  function toNumber(value) {
@@ -3526,42 +4982,166 @@ function formatValue(column, row, index, locale, t) {
3526
4982
  return render.length >= 3 ? render(value, row, index) : render(row, index);
3527
4983
  }
3528
4984
  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));
4985
+ if (column.type === "currency")
4986
+ formatted = new Intl.NumberFormat(locale, {
4987
+ style: "currency",
4988
+ currency: "IDR",
4989
+ maximumFractionDigits: 0
4990
+ }).format(toNumber(value));
4991
+ else if (column.type === "number")
4992
+ formatted = new Intl.NumberFormat(locale).format(toNumber(value));
3531
4993
  else if (column.type === "date") {
3532
4994
  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) : "-";
4995
+ formatted = date2 && !Number.isNaN(date2.getTime()) ? new Intl.DateTimeFormat(locale, {
4996
+ day: "2-digit",
4997
+ month: "short",
4998
+ year: "numeric"
4999
+ }).format(date2) : "-";
3534
5000
  } else formatted = toDisplay(value, t);
3535
5001
  const transform = column.transform ?? column.trasform;
3536
5002
  if (typeof transform === "function") return transform(formatted);
3537
5003
  if (typeof formatted !== "string") return formatted;
3538
5004
  if (transform === "uppercase") return formatted.toUpperCase();
3539
5005
  if (transform === "lowercase") return formatted.toLowerCase();
3540
- if (transform === "capitalize") return formatted.charAt(0).toUpperCase() + formatted.slice(1);
5006
+ if (transform === "capitalize")
5007
+ return formatted.charAt(0).toUpperCase() + formatted.slice(1);
3541
5008
  return formatted;
3542
5009
  }
3543
5010
  function alignmentClass(column) {
3544
- return cn(column.align === "center" && "text-center", column.align === "right" && "text-right", (!column.align || column.align === "left") && "text-left");
5011
+ return cn(
5012
+ column.align === "center" && "text-center",
5013
+ column.align === "right" && "text-right",
5014
+ (!column.align || column.align === "left") && "text-left"
5015
+ );
3545
5016
  }
3546
5017
  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" }) });
5018
+ return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
5019
+ "svg",
5020
+ {
5021
+ viewBox: "0 0 24 24",
5022
+ fill: "none",
5023
+ stroke: "currentColor",
5024
+ strokeWidth: "2",
5025
+ className: "size-4",
5026
+ children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("path", { d: "M4 6h16M7 12h10M10 18h4" })
5027
+ }
5028
+ );
3548
5029
  }
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)) }) });
5030
+ var DEFAULT_PAGE_SIZE_OPTIONS = [10, 25, 50, 100];
5031
+ function PageSizeSelect({
5032
+ value,
5033
+ onChange,
5034
+ options = DEFAULT_PAGE_SIZE_OPTIONS
5035
+ }) {
5036
+ if (!onChange)
5037
+ return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("span", { className: "font-medium text-(--color-text)", children: value });
5038
+ return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
5039
+ DDropdown,
5040
+ {
5041
+ placement: "top-start",
5042
+ closeOnItemClick: true,
5043
+ scrollBehavior: "close",
5044
+ contentPadding: false,
5045
+ trigger: ({ open }) => /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(
5046
+ "button",
5047
+ {
5048
+ type: "button",
5049
+ className: "relative flex h-8 cursor-pointer appearance-none items-center rounded-lg border border-(--color-border) bg-(--color-background) px-2 pr-6 text-sm text-(--color-text) outline-none hover:bg-(--color-surface-muted) focus-visible:ring-2 focus-visible:ring-(--color-focus)/25",
5050
+ children: [
5051
+ value,
5052
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
5053
+ ChevronDownIcon,
5054
+ {
5055
+ size: 14,
5056
+ className: cn(
5057
+ "absolute right-1.5 transition-transform duration-150",
5058
+ open && "rotate-180"
5059
+ )
5060
+ }
5061
+ )
5062
+ ]
5063
+ }
5064
+ ),
5065
+ children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { className: "min-w-18 space-y-0.5 p-1.5", children: options.map((size) => /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
5066
+ "button",
5067
+ {
5068
+ type: "button",
5069
+ onClick: () => onChange(size),
5070
+ className: cn(
5071
+ "w-full cursor-pointer appearance-none rounded-(--radius-menu-item) border-0 bg-transparent px-3 py-2 text-left text-sm hover:bg-(--color-surface-muted)",
5072
+ size === value && "bg-(--color-brand)/10 font-medium text-(--color-brand)"
5073
+ ),
5074
+ children: size
5075
+ },
5076
+ size
5077
+ )) })
5078
+ }
5079
+ );
3555
5080
  }
3556
- function ActionMenu({ actions, row }) {
5081
+ function ActionMenu({
5082
+ actions,
5083
+ row
5084
+ }) {
3557
5085
  const visible = actions.filter((action) => !action.show || action.show(row));
3558
5086
  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)) }) });
5087
+ return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
5088
+ DDropdown,
5089
+ {
5090
+ placement: "bottom-end",
5091
+ closeOnItemClick: true,
5092
+ scrollBehavior: "close",
5093
+ trigger: ({ open }) => /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
5094
+ "span",
5095
+ {
5096
+ className: cn(
5097
+ "cursor-pointer inline-flex size-8 items-center justify-center rounded-lg border border-(--color-border) bg-(--color-background) text-(--color-text-muted) hover:bg-(--color-surface-muted)",
5098
+ open && "bg-(--color-surface-muted) text-(--color-text)"
5099
+ ),
5100
+ children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(MoreHorizontalIcon, { size: 16 })
5101
+ }
5102
+ ),
5103
+ children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { className: "min-w-45 px-1.5 py-1", children: visible.map((action, index) => /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(
5104
+ "button",
5105
+ {
5106
+ type: "button",
5107
+ onClick: () => action.onClick(row),
5108
+ className: cn(
5109
+ "cursor-pointer flex w-full appearance-none items-center gap-2.5 rounded-(--radius-menu-item) border-0 bg-transparent px-3 py-2.5 text-left text-sm hover:bg-(--color-surface-muted)",
5110
+ action.variant === "danger" ? "text-(--color-danger)" : "text-(--color-text)"
5111
+ ),
5112
+ children: [
5113
+ action.icon,
5114
+ action.label
5115
+ ]
5116
+ },
5117
+ index
5118
+ )) })
5119
+ }
5120
+ );
3563
5121
  }
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 }) {
5122
+ function DDataTable({
5123
+ columns,
5124
+ data,
5125
+ rowKey = "id",
5126
+ loading = false,
5127
+ emptyMessage,
5128
+ onRowClick,
5129
+ sortBy,
5130
+ sortDirection,
5131
+ sortDir,
5132
+ onSort,
5133
+ pagination,
5134
+ onPageChange,
5135
+ onPageSizeChange,
5136
+ pageSizeOptions,
5137
+ actions,
5138
+ searchable = false,
5139
+ searchPlaceholder,
5140
+ searchValue = "",
5141
+ onSearchChange,
5142
+ headerActions,
5143
+ filters
5144
+ }) {
3565
5145
  const { locale, t } = useDLocalization();
3566
5146
  const [showFilters, setShowFilters] = (0, import_react21.useState)(false);
3567
5147
  const direction = sortDirection ?? sortDir ?? "asc";
@@ -3575,139 +5155,354 @@ function DDataTable({ columns, data, rowKey = "id", loading = false, emptyMessag
3575
5155
  };
3576
5156
  const changeSort = (column) => {
3577
5157
  if (!column.sortable || !onSort) return;
3578
- onSort(String(column.key), sortBy === String(column.key) && direction === "asc" ? "desc" : "asc");
5158
+ onSort(
5159
+ String(column.key),
5160
+ sortBy === String(column.key) && direction === "asc" ? "desc" : "asc"
5161
+ );
3579
5162
  };
3580
5163
  const actionArray = Array.isArray(actions) ? actions : null;
3581
5164
  const actionRenderer = typeof actions === "function" ? actions : null;
3582
5165
  const hasActions = Boolean(actionArray?.length || actionRenderer);
3583
5166
  const renderActions = (row, index) => actionRenderer ? actionRenderer(row, index) : actionArray ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(ActionMenu, { actions: actionArray, row }) : null;
3584
5167
  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
- ] });
5168
+ return /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(
5169
+ "div",
5170
+ {
5171
+ "data-ds-component": "data-table",
5172
+ className: "overflow-visible rounded-(--radius-card) border border-(--color-border) bg-(--color-surface)",
5173
+ children: [
5174
+ searchable || headerActions || filters ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { className: "space-y-4 border-b border-(--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: [
5175
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("div", { className: "flex w-full items-center gap-2 sm:w-auto", children: [
5176
+ searchable ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
5177
+ DSearchInput,
5178
+ {
5179
+ value: searchValue,
5180
+ onChange: (query) => onSearchChange?.(query),
5181
+ placeholder: resolvedSearch,
5182
+ debounceMs: 500,
5183
+ align: "left",
5184
+ expandedWidth: "260px"
5185
+ }
5186
+ ) : null,
5187
+ filters ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
5188
+ "button",
5189
+ {
5190
+ type: "button",
5191
+ "aria-label": t("dataTable.toggleFilters"),
5192
+ onClick: () => setShowFilters((value) => !value),
5193
+ className: cn(
5194
+ "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-(--color-focus)/25",
5195
+ showFilters ? "border-(--color-brand) bg-(--color-brand) text-(--color-brand-foreground)" : "border-(--color-border) bg-(--color-background) text-(--color-text-muted) hover:bg-(--color-surface-muted)"
5196
+ ),
5197
+ children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(FilterIcon, {})
5198
+ }
5199
+ ) : null
5200
+ ] }),
5201
+ 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
5202
+ ] }) }) : null,
5203
+ filters ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
5204
+ "div",
5205
+ {
5206
+ className: cn(
5207
+ "overflow-hidden transition-all duration-300",
5208
+ showFilters ? "max-h-55 opacity-100" : "max-h-0 opacity-0"
5209
+ ),
5210
+ children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { className: "flex flex-wrap items-center gap-2 border-b border-(--color-border) px-4 py-3", children: filters })
5211
+ }
5212
+ ) : null,
5213
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { className: "divide-y divide-(--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: [
5214
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(DSkeleton, { height: 16, width: "70%" }),
5215
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(DSkeleton, { height: 12, width: "50%" }),
5216
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(DSkeleton, { height: 12, width: "40%" })
5217
+ ] }, index)) : data.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { className: "px-4 py-16 text-center text-sm text-(--color-text-muted)", children: resolvedEmpty }) : data.map((row, index) => /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(
5218
+ "div",
5219
+ {
5220
+ onClick: () => onRowClick?.(row),
5221
+ className: cn(
5222
+ "p-4",
5223
+ onRowClick && "cursor-pointer active:bg-(--color-surface-muted)/30"
5224
+ ),
5225
+ children: [
5226
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("div", { className: "flex items-start justify-between gap-2", children: [
5227
+ /* @__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)(
5228
+ "div",
5229
+ {
5230
+ className: columnIndex === 0 ? "truncate text-sm font-medium text-(--color-text)" : "mt-0.5 truncate text-xs text-(--color-text-muted)",
5231
+ children: renderValue(column, row, index)
5232
+ },
5233
+ String(column.key)
5234
+ )) }),
5235
+ hasActions ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { onClick: (event) => event.stopPropagation(), children: renderActions(row, index) }) : null
5236
+ ] }),
5237
+ 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: [
5238
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("span", { className: "text-(--color-text-muted)", children: [
5239
+ column.label,
5240
+ ":",
5241
+ " "
5242
+ ] }),
5243
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("span", { className: "font-medium text-(--color-text)", children: renderValue(column, row, index) })
5244
+ ] }, String(column.key))) }) : null
5245
+ ]
5246
+ },
5247
+ getKey(row, index)
5248
+ )) }),
5249
+ /* @__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: [
5250
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("tr", { className: "border-b border-(--color-border) bg-(--color-surface-muted)/40", children: [
5251
+ columns.map((column, columnIndex) => /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
5252
+ "th",
5253
+ {
5254
+ style: column.width ? { width: column.width } : void 0,
5255
+ className: cn(
5256
+ "whitespace-nowrap px-4 py-3 text-xs font-semibold text-(--color-text-muted)",
5257
+ columnIndex === 0 && "pl-6",
5258
+ columnIndex === columns.length - 1 && !hasActions && "pr-6",
5259
+ alignmentClass(column)
5260
+ ),
5261
+ children: /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(
5262
+ "button",
5263
+ {
5264
+ type: "button",
5265
+ disabled: !column.sortable,
5266
+ onClick: () => changeSort(column),
5267
+ className: cn(
5268
+ "inline-flex appearance-none items-center gap-1 border-0 bg-transparent p-0 text-inherit outline-none",
5269
+ column.sortable && "cursor-pointer hover:text-(--color-text) focus-visible:ring-2 focus-visible:ring-(--color-focus)/25"
5270
+ ),
5271
+ children: [
5272
+ column.label,
5273
+ column.sortable && sortBy === String(column.key) ? direction === "asc" ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(ArrowUpIcon, {}) : /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(ArrowDownIcon, {}) : null
5274
+ ]
5275
+ }
5276
+ )
5277
+ },
5278
+ String(column.key)
5279
+ )),
5280
+ hasActions ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("th", { className: "w-20 py-3 pl-4 pr-6 text-right text-xs font-semibold text-(--color-text-muted)", children: t("dataTable.actions") }) : null
5281
+ ] }) }),
5282
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("tbody", { children: [
5283
+ loading ? Array.from({ length: 5 }, (_, rowIndex) => /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(
5284
+ "tr",
5285
+ {
5286
+ className: "border-b border-(--color-border)/60 last:border-0",
5287
+ children: [
5288
+ columns.map((column, columnIndex) => /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("td", { className: "px-4 py-3", children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
5289
+ DSkeleton,
5290
+ {
5291
+ height: 12,
5292
+ width: columnIndex === 0 ? "70%" : "50%"
5293
+ }
5294
+ ) }, String(column.key))),
5295
+ 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
5296
+ ]
5297
+ },
5298
+ rowIndex
5299
+ )) : data.map((row, rowIndex) => /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(
5300
+ "tr",
5301
+ {
5302
+ onClick: () => onRowClick?.(row),
5303
+ className: cn(
5304
+ "border-b border-(--color-border)/60 last:border-0 hover:bg-(--color-surface-muted)/35",
5305
+ onRowClick && "cursor-pointer"
5306
+ ),
5307
+ children: [
5308
+ columns.map((column, columnIndex) => /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
5309
+ "td",
5310
+ {
5311
+ className: cn(
5312
+ "px-4 py-3",
5313
+ columnIndex === 0 && "pl-6",
5314
+ columnIndex === columns.length - 1 && !hasActions && "pr-6",
5315
+ alignmentClass(column)
5316
+ ),
5317
+ children: renderValue(column, row, rowIndex)
5318
+ },
5319
+ String(column.key)
5320
+ )),
5321
+ hasActions ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
5322
+ "td",
5323
+ {
5324
+ className: "py-3 pl-4 pr-6 text-right",
5325
+ onClick: (event) => event.stopPropagation(),
5326
+ children: renderActions(row, rowIndex)
5327
+ }
5328
+ ) : null
5329
+ ]
5330
+ },
5331
+ getKey(row, rowIndex)
5332
+ )),
5333
+ !loading && data.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("tr", { children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
5334
+ "td",
5335
+ {
5336
+ colSpan: columns.length + (hasActions ? 1 : 0),
5337
+ className: "px-4 py-16 text-center text-sm text-(--color-text-muted)",
5338
+ children: resolvedEmpty
5339
+ }
5340
+ ) }) : null
5341
+ ] })
5342
+ ] }) }),
5343
+ pagination ? /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("footer", { className: "flex flex-col items-center justify-between gap-3 border-t border-(--color-border) px-4 py-3 text-xs text-(--color-text-muted) sm:flex-row", children: [
5344
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("div", { className: "flex items-center gap-2", children: [
5345
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("span", { children: t("dataTable.showing") }),
5346
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
5347
+ PageSizeSelect,
5348
+ {
5349
+ value: pagination.pageSize,
5350
+ onChange: onPageSizeChange,
5351
+ options: pageSizeOptions
5352
+ }
5353
+ ),
5354
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("span", { children: t("dataTable.ofData", { total: pagination.total }) })
5355
+ ] }),
5356
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("div", { className: "flex items-center gap-1", children: [
5357
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
5358
+ "button",
5359
+ {
5360
+ type: "button",
5361
+ "aria-label": t("pagination.previous"),
5362
+ disabled: pagination.page <= 1,
5363
+ onClick: () => onPageChange?.(pagination.page - 1),
5364
+ className: "cursor-pointer grid size-8 appearance-none place-items-center rounded-md border-0 bg-transparent text-(--color-text-muted) outline-none hover:bg-(--color-surface-muted) focus-visible:ring-2 focus-visible:ring-(--color-focus)/25 disabled:opacity-40",
5365
+ children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(ChevronLeftIcon, { size: 16 })
5366
+ }
5367
+ ),
5368
+ getPaginationPages(pagination.page, totalPages).map((page) => /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
5369
+ "button",
5370
+ {
5371
+ type: "button",
5372
+ "aria-label": t("pagination.page", { page }),
5373
+ onClick: () => onPageChange?.(page),
5374
+ className: cn(
5375
+ "cursor-pointer 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-(--color-focus)/25",
5376
+ page === pagination.page ? "bg-(--color-brand) text-(--color-brand-foreground)" : "text-(--color-text) hover:bg-(--color-surface-muted)"
5377
+ ),
5378
+ children: page
5379
+ },
5380
+ page
5381
+ )),
5382
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
5383
+ "button",
5384
+ {
5385
+ type: "button",
5386
+ "aria-label": t("pagination.next"),
5387
+ disabled: pagination.page >= totalPages,
5388
+ onClick: () => onPageChange?.(pagination.page + 1),
5389
+ className: "cursor-pointer grid size-8 appearance-none place-items-center rounded-md border-0 bg-transparent text-(--color-text-muted) outline-none hover:bg-(--color-surface-muted) focus-visible:ring-2 focus-visible:ring-(--color-focus)/25 disabled:opacity-40",
5390
+ children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(ChevronRightIcon, { size: 16 })
5391
+ }
5392
+ )
5393
+ ] })
5394
+ ] }) : null
5395
+ ]
5396
+ }
5397
+ );
3643
5398
  }
3644
5399
 
3645
5400
  // src/textarea/textarea.tsx
3646
5401
  var import_react22 = require("react");
3647
5402
  var import_jsx_runtime33 = require("react/jsx-runtime");
3648
5403
  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" }) });
5404
+ return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
5405
+ "svg",
5406
+ {
5407
+ viewBox: "0 0 24 24",
5408
+ fill: "none",
5409
+ stroke: "currentColor",
5410
+ strokeWidth: "2",
5411
+ className: "size-3.5",
5412
+ children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("path", { d: "m18 6-12 12M6 6l12 12" })
5413
+ }
5414
+ );
3650
5415
  }
3651
5416
  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);
5417
+ return {
5418
+ target: { value },
5419
+ currentTarget: { value }
3679
5420
  };
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
- });
5421
+ }
5422
+ var DTextarea = (0, import_react22.forwardRef)(
5423
+ function DTextarea2({
5424
+ label,
5425
+ error,
5426
+ hint,
5427
+ clearable = true,
5428
+ onClear,
5429
+ onChange,
5430
+ onNativeChange,
5431
+ containerClassName,
5432
+ className,
5433
+ value,
5434
+ disabled,
5435
+ readOnly,
5436
+ id: externalId,
5437
+ ...props
5438
+ }, ref) {
5439
+ const { t } = useDLocalization();
5440
+ const autoId = (0, import_react22.useId)();
5441
+ const id = externalId ?? autoId;
5442
+ const hasValue = value !== void 0 && value !== null && value !== "";
5443
+ const clear = () => {
5444
+ const event = eventWithValue2("");
5445
+ onClear?.();
5446
+ onChange?.("", event);
5447
+ onNativeChange?.(event);
5448
+ };
5449
+ return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(
5450
+ "div",
5451
+ {
5452
+ "data-ds-component": "textarea",
5453
+ className: cn("flex min-w-0 flex-col gap-1.5", containerClassName),
5454
+ children: [
5455
+ label ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
5456
+ "label",
5457
+ {
5458
+ htmlFor: id,
5459
+ className: "inline-block w-fit text-sm font-medium text-(--color-text)",
5460
+ children: label
5461
+ }
5462
+ ) : null,
5463
+ /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: "relative", children: [
5464
+ /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
5465
+ "textarea",
5466
+ {
5467
+ ...props,
5468
+ ref,
5469
+ id,
5470
+ value,
5471
+ disabled,
5472
+ readOnly,
5473
+ "aria-invalid": Boolean(error) || void 0,
5474
+ onChange: (event) => {
5475
+ onChange?.(event.target.value, event);
5476
+ onNativeChange?.(event);
5477
+ },
5478
+ className: cn(
5479
+ "min-h-20 w-full resize-y rounded-(--radius-control) border bg-(--color-surface) px-3 py-2 text-sm text-(--color-text) transition-colors duration-150 placeholder:text-(--color-text-muted)/60 focus:border-(--color-brand) focus:outline-none focus:ring-2 focus:ring-(--color-brand)/20 disabled:cursor-not-allowed disabled:bg-(--color-surface-muted) disabled:opacity-50 read-only:bg-(--color-surface-muted)",
5480
+ error ? "border-(--color-danger) focus:ring-(--color-danger)/20" : "border-(--color-border)",
5481
+ clearable && hasValue && !disabled && !readOnly && "pr-10",
5482
+ className
5483
+ )
5484
+ }
5485
+ ),
5486
+ clearable && hasValue && !disabled && !readOnly ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
5487
+ "button",
5488
+ {
5489
+ type: "button",
5490
+ tabIndex: -1,
5491
+ "aria-label": t("textarea.clear"),
5492
+ onMouseDown: (event) => event.preventDefault(),
5493
+ onClick: clear,
5494
+ className: "absolute right-2 top-2 cursor-pointer flex size-5 shrink-0 items-center justify-center self-center rounded-md hover:bg-(--color-surface-muted) text-(--color-text-muted) transition-colors",
5495
+ children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(ClearIcon9, {})
5496
+ }
5497
+ ) : null
5498
+ ] }),
5499
+ error ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("p", { className: "text-xs text-(--color-danger)", children: error }) : null,
5500
+ !error && hint ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("p", { className: "text-xs text-(--color-text-muted)", children: hint }) : null
5501
+ ]
5502
+ }
5503
+ );
5504
+ }
5505
+ );
3711
5506
 
3712
5507
  // src/toast/toast.tsx
3713
5508
  var import_react23 = require("react");
@@ -3816,7 +5611,19 @@ function DToastContainer({ toasts, onDismiss, className }) {
3816
5611
  var import_react24 = require("react");
3817
5612
  var import_jsx_runtime35 = require("react/jsx-runtime");
3818
5613
  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 });
5614
+ return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
5615
+ "input",
5616
+ {
5617
+ "data-ds-component": "radio",
5618
+ ref,
5619
+ type: "radio",
5620
+ className: cn(
5621
+ "cursor-pointer size-4 accent-(--color-brand) focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-(--color-focus)/20",
5622
+ className
5623
+ ),
5624
+ ...props
5625
+ }
5626
+ );
3820
5627
  });
3821
5628
 
3822
5629
  // src/toggle/toggle.tsx
@@ -4121,7 +5928,8 @@ function DSpinner({ size = "md", label = "Loading", className, ...props }) {
4121
5928
  // src/pagination/pagination.tsx
4122
5929
  var import_jsx_runtime42 = require("react/jsx-runtime");
4123
5930
  function getPaginationItems(page, total, sibling = 1) {
4124
- if (total <= 7) return Array.from({ length: Math.max(total, 0) }, (_, i) => i + 1);
5931
+ if (total <= 7)
5932
+ return Array.from({ length: Math.max(total, 0) }, (_, i) => i + 1);
4125
5933
  const start = Math.max(2, page - sibling);
4126
5934
  const end = Math.min(total - 1, page + sibling);
4127
5935
  const items = [1];
@@ -4131,7 +5939,7 @@ function getPaginationItems(page, total, sibling = 1) {
4131
5939
  items.push(total);
4132
5940
  return items;
4133
5941
  }
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";
5942
+ var pageButtonBase = "cursor-pointer 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
5943
  function DPagination({
4136
5944
  page,
4137
5945
  totalPages,
@@ -4142,46 +5950,71 @@ function DPagination({
4142
5950
  }) {
4143
5951
  const { t } = useDLocalization();
4144
5952
  const go = (next) => {
4145
- if (!disabled && next >= 1 && next <= totalPages && next !== page) onChange(next);
5953
+ if (!disabled && next >= 1 && next <= totalPages && next !== page)
5954
+ onChange(next);
4146
5955
  };
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)]"
5956
+ return /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(
5957
+ "nav",
5958
+ {
5959
+ "data-ds-component": "pagination",
5960
+ "aria-label": t("pagination.label"),
5961
+ className: cn("flex items-center gap-1", className),
5962
+ children: [
5963
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
5964
+ "button",
5965
+ {
5966
+ type: "button",
5967
+ "aria-label": t("pagination.previous"),
5968
+ disabled: disabled || page <= 1,
5969
+ onClick: () => go(page - 1),
5970
+ className: cn(
5971
+ pageButtonBase,
5972
+ "border border-(--color-border) bg-(--color-surface) text-(--color-text-muted) hover:bg-(--color-surface-muted)"
5973
+ ),
5974
+ children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(ChevronLeftIcon, { size: 16 })
5975
+ }
4168
5976
  ),
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
- ] });
5977
+ getPaginationItems(page, totalPages, siblingCount).map(
5978
+ (item, index) => item === "ellipsis" ? /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
5979
+ "span",
5980
+ {
5981
+ "aria-hidden": "true",
5982
+ className: "grid size-9 place-items-center text-(--color-text-muted)",
5983
+ children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(MoreHorizontalIcon, { size: 16 })
5984
+ },
5985
+ `e-${index}`
5986
+ ) : /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
5987
+ "button",
5988
+ {
5989
+ type: "button",
5990
+ "aria-current": item === page ? "page" : void 0,
5991
+ onClick: () => go(item),
5992
+ className: cn(
5993
+ pageButtonBase,
5994
+ item === page ? "border border-(--color-brand) bg-(--color-brand) text-(--color-brand-foreground)" : "border border-(--color-border) bg-(--color-surface) text-(--color-text) hover:bg-(--color-surface-muted)"
5995
+ ),
5996
+ children: item
5997
+ },
5998
+ item
5999
+ )
6000
+ ),
6001
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
6002
+ "button",
6003
+ {
6004
+ type: "button",
6005
+ "aria-label": t("pagination.next"),
6006
+ disabled: disabled || page >= totalPages,
6007
+ onClick: () => go(page + 1),
6008
+ className: cn(
6009
+ pageButtonBase,
6010
+ "border border-(--color-border) bg-(--color-surface) text-(--color-text-muted) hover:bg-(--color-surface-muted)"
6011
+ ),
6012
+ children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(ChevronRightIcon, { size: 16 })
6013
+ }
6014
+ )
6015
+ ]
6016
+ }
6017
+ );
4185
6018
  }
4186
6019
 
4187
6020
  // src/tabs/tabs.tsx
@@ -4193,7 +6026,14 @@ function useTabs() {
4193
6026
  if (!ctx) throw new Error("DTabs components must be inside <DTabs>.");
4194
6027
  return ctx;
4195
6028
  }
4196
- function DTabs({ value, defaultValue, onValueChange, children, className, ...props }) {
6029
+ function DTabs({
6030
+ value,
6031
+ defaultValue,
6032
+ onValueChange,
6033
+ children,
6034
+ className,
6035
+ ...props
6036
+ }) {
4197
6037
  const [internal, setInternal] = (0, import_react27.useState)(defaultValue);
4198
6038
  const current = value ?? internal;
4199
6039
  const baseId = (0, import_react27.useId)();
@@ -4203,16 +6043,26 @@ function DTabs({ value, defaultValue, onValueChange, children, className, ...pro
4203
6043
  };
4204
6044
  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
6045
  }
4206
- function DTabsList({ className, onKeyDown, ...props }) {
6046
+ function DTabsList({
6047
+ className,
6048
+ onKeyDown,
6049
+ ...props
6050
+ }) {
4207
6051
  return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
4208
6052
  "div",
4209
6053
  {
4210
6054
  role: "tablist",
4211
- className: cn("inline-flex items-center rounded-xl bg-[var(--color-surface-muted)] p-1", className),
6055
+ className: cn(
6056
+ "inline-flex items-center rounded-xl bg-(--color-surface-muted) p-1",
6057
+ className
6058
+ ),
4212
6059
  onKeyDown: (event) => {
4213
6060
  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)"));
6061
+ if (event.defaultPrevented || !["ArrowLeft", "ArrowRight", "Home", "End"].includes(event.key))
6062
+ return;
6063
+ const tabs = Array.from(
6064
+ event.currentTarget.querySelectorAll("[role=tab]:not(:disabled)")
6065
+ );
4216
6066
  if (!tabs.length) return;
4217
6067
  const index = tabs.indexOf(document.activeElement);
4218
6068
  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;
@@ -4224,7 +6074,13 @@ function DTabsList({ className, onKeyDown, ...props }) {
4224
6074
  }
4225
6075
  );
4226
6076
  }
4227
- function DTabsTrigger({ value, disabled, className, children, ...props }) {
6077
+ function DTabsTrigger({
6078
+ value,
6079
+ disabled,
6080
+ className,
6081
+ children,
6082
+ ...props
6083
+ }) {
4228
6084
  const ctx = useTabs();
4229
6085
  const active = ctx.value === value;
4230
6086
  return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
@@ -4238,8 +6094,8 @@ function DTabsTrigger({ value, disabled, className, children, ...props }) {
4238
6094
  disabled,
4239
6095
  onClick: () => ctx.setValue(value),
4240
6096
  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)]",
6097
+ "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-(--color-focus)/25",
6098
+ active ? "bg-(--color-surface) text-(--color-text) shadow-sm" : "text-(--color-text-muted) hover:text-(--color-text)",
4243
6099
  disabled && "cursor-not-allowed opacity-40",
4244
6100
  className
4245
6101
  ),
@@ -4251,7 +6107,16 @@ function DTabsTrigger({ value, disabled, className, children, ...props }) {
4251
6107
  function DTabsContent({ value, className, ...props }) {
4252
6108
  const ctx = useTabs();
4253
6109
  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 });
6110
+ return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
6111
+ "div",
6112
+ {
6113
+ role: "tabpanel",
6114
+ id: `${ctx.baseId}-panel-${value}`,
6115
+ "aria-labelledby": `${ctx.baseId}-tab-${value}`,
6116
+ className,
6117
+ ...props
6118
+ }
6119
+ );
4255
6120
  }
4256
6121
 
4257
6122
  // src/accordion/accordion.tsx
@@ -4280,21 +6145,34 @@ function DAccordion({
4280
6145
  if (value === void 0) setInternal(next);
4281
6146
  onValueChange?.(next);
4282
6147
  };
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",
6148
+ return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
6149
+ AccordionContext.Provider,
4285
6150
  {
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
6151
+ value: { open: current, toggle, baseId, variant },
6152
+ children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
6153
+ "div",
6154
+ {
6155
+ "data-ds-component": "accordion",
6156
+ "data-accordion-variant": variant,
6157
+ className: cn(
6158
+ variant === "card" && "overflow-hidden rounded-(--radius-card) border border-(--color-border) bg-(--color-surface)",
6159
+ variant === "separated" && "space-y-2",
6160
+ className
6161
+ ),
6162
+ ...props
6163
+ }
6164
+ )
4294
6165
  }
4295
- ) });
6166
+ );
4296
6167
  }
4297
- function DAccordionItem({ value, title, disabled, className, children, ...props }) {
6168
+ function DAccordionItem({
6169
+ value,
6170
+ title,
6171
+ disabled,
6172
+ className,
6173
+ children,
6174
+ ...props
6175
+ }) {
4298
6176
  const context = useAccordion();
4299
6177
  const open = context.open.includes(value);
4300
6178
  const id = `${context.baseId}-${value.replace(/[^a-zA-Z0-9_-]/g, "-")}`;
@@ -4304,9 +6182,9 @@ function DAccordionItem({ value, title, disabled, className, children, ...props
4304
6182
  "div",
4305
6183
  {
4306
6184
  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",
6185
+ context.variant === "separator" && "border-b border-(--color-border) last:border-b-0",
6186
+ context.variant === "card" && "border-b border-(--color-border) px-4 last:border-b-0",
6187
+ context.variant === "separated" && "overflow-hidden rounded-(--radius-control) border border-(--color-border) bg-(--color-surface) px-4",
4310
6188
  (context.variant === "default" || context.variant === "separator") && "px-0",
4311
6189
  className
4312
6190
  ),
@@ -4321,14 +6199,17 @@ function DAccordionItem({ value, title, disabled, className, children, ...props
4321
6199
  "aria-expanded": open,
4322
6200
  "aria-controls": contentId,
4323
6201
  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",
6202
+ 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-(--color-text) outline-none transition-colors duration-150 hover:text-(--color-brand) focus-visible:ring-2 focus-visible:ring-(--color-focus)/25 disabled:cursor-not-allowed disabled:opacity-40",
4325
6203
  children: [
4326
6204
  /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("span", { children: title }),
4327
6205
  /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
4328
6206
  ChevronDownIcon,
4329
6207
  {
4330
6208
  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")
6209
+ className: cn(
6210
+ "shrink-0 text-(--color-text-muted) transition-transform duration-200 ease-out group-hover:text-current",
6211
+ open && "rotate-180"
6212
+ )
4332
6213
  }
4333
6214
  )
4334
6215
  ]
@@ -4345,7 +6226,7 @@ function DAccordionItem({ value, title, disabled, className, children, ...props
4345
6226
  "grid transition-[grid-template-rows,opacity] duration-200 ease-out motion-reduce:transition-none",
4346
6227
  open ? "grid-rows-[1fr] opacity-100" : "grid-rows-[0fr] opacity-0"
4347
6228
  ),
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 }) })
6229
+ 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-(--color-text-muted)", children }) })
4349
6230
  }
4350
6231
  )
4351
6232
  ]