@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.js CHANGED
@@ -64,34 +64,54 @@ var sizeClasses = {
64
64
  lg: "h-12 gap-2 px-6 text-base",
65
65
  icon: "size-10 p-0"
66
66
  };
67
- var DButton = forwardRef(function DButton2({ className, variant = "primary", size = "md", loading = false, leftIcon, rightIcon, fullWidth = false, disabled, type = "button", children, ...props }, ref) {
68
- return /* @__PURE__ */ jsxs3(
69
- "button",
70
- {
71
- ref,
72
- "data-ds-component": "button",
73
- type,
74
- disabled: disabled || loading,
75
- "aria-busy": loading || void 0,
76
- className: cn(
77
- "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",
78
- variantClasses2[variant],
79
- variant !== "link" && sizeClasses[size],
80
- variant === "link" && size === "sm" && "text-xs",
81
- variant === "link" && size === "md" && "text-sm",
82
- variant === "link" && size === "lg" && "text-base",
83
- fullWidth && "w-full",
84
- className
85
- ),
86
- ...props,
87
- children: [
88
- loading ? /* @__PURE__ */ jsx3("span", { className: "size-4 animate-spin rounded-full border-2 border-current border-t-transparent", "aria-hidden": "true" }) : leftIcon,
89
- children ? /* @__PURE__ */ jsx3("span", { children }) : null,
90
- !loading ? rightIcon : null
91
- ]
92
- }
93
- );
94
- });
67
+ var DButton = forwardRef(
68
+ function DButton2({
69
+ className,
70
+ variant = "primary",
71
+ size = "md",
72
+ loading = false,
73
+ leftIcon,
74
+ rightIcon,
75
+ fullWidth = false,
76
+ disabled,
77
+ type = "button",
78
+ children,
79
+ ...props
80
+ }, ref) {
81
+ return /* @__PURE__ */ jsxs3(
82
+ "button",
83
+ {
84
+ ref,
85
+ "data-ds-component": "button",
86
+ type,
87
+ disabled: disabled || loading,
88
+ "aria-busy": loading || void 0,
89
+ className: cn(
90
+ "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",
91
+ variantClasses2[variant],
92
+ variant !== "link" && sizeClasses[size],
93
+ variant === "link" && size === "sm" && "text-xs",
94
+ variant === "link" && size === "md" && "text-sm",
95
+ variant === "link" && size === "lg" && "text-base",
96
+ fullWidth && "w-full",
97
+ className
98
+ ),
99
+ ...props,
100
+ children: [
101
+ loading ? /* @__PURE__ */ jsx3(
102
+ "span",
103
+ {
104
+ className: "size-4 animate-spin rounded-full border-2 border-current border-t-transparent",
105
+ "aria-hidden": "true"
106
+ }
107
+ ) : leftIcon,
108
+ children ? /* @__PURE__ */ jsx3("span", { children }) : null,
109
+ !loading ? rightIcon : null
110
+ ]
111
+ }
112
+ );
113
+ }
114
+ );
95
115
 
96
116
  // src/card/card.tsx
97
117
  import { jsx as jsx4 } from "react/jsx-runtime";
@@ -117,21 +137,76 @@ function DCardFooter({ className, ...props }) {
117
137
  // src/checkbox/checkbox.tsx
118
138
  import { forwardRef as forwardRef2 } from "react";
119
139
  import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
120
- var DCheckbox = forwardRef2(function DCheckbox2({ className, ...props }, ref) {
121
- return /* @__PURE__ */ jsxs4("span", { "data-ds-component": "checkbox", className: cn("inline-flex size-4 shrink-0", className), children: [
122
- /* @__PURE__ */ jsx5("input", { ref, type: "checkbox", className: "peer sr-only", ...props }),
123
- /* @__PURE__ */ jsx5("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__ */ jsx5("svg", { viewBox: "0 0 12 12", className: "size-3 opacity-0", "aria-hidden": "true", children: /* @__PURE__ */ jsx5(
124
- "path",
140
+ var DCheckbox = forwardRef2(
141
+ function DCheckbox2({ className, disabled, ...props }, ref) {
142
+ return /* @__PURE__ */ jsxs4(
143
+ "label",
125
144
  {
126
- d: "m2 6 2.4 2.4L10 2.8",
127
- fill: "none",
128
- stroke: "currentColor",
129
- strokeLinecap: "round",
130
- strokeWidth: "1.8"
145
+ "data-ds-component": "checkbox",
146
+ className: cn(
147
+ "inline-flex size-4.5 shrink-0 cursor-pointer",
148
+ disabled && "cursor-not-allowed",
149
+ className
150
+ ),
151
+ children: [
152
+ /* @__PURE__ */ jsx5(
153
+ "input",
154
+ {
155
+ ref,
156
+ type: "checkbox",
157
+ disabled,
158
+ className: "peer sr-only",
159
+ ...props
160
+ }
161
+ ),
162
+ /* @__PURE__ */ jsx5(
163
+ "span",
164
+ {
165
+ "aria-hidden": "true",
166
+ className: cn(
167
+ "grid size-4.5 shrink-0 place-items-center",
168
+ "rounded-(--radius-control)",
169
+ "border-[1.5px] border-(--color-brand)",
170
+ "bg-(--color-surface)",
171
+ "text-(--color-brand-foreground)",
172
+ "transition-colors",
173
+ // Checked
174
+ "peer-checked:border-(--color-brand)",
175
+ "peer-checked:bg-(--color-brand)",
176
+ "peer-checked:[&>svg]:opacity-100",
177
+ // Focus
178
+ "peer-focus-visible:ring-2",
179
+ "peer-focus-visible:ring-(--color-brand)/20",
180
+ // Disabled
181
+ "peer-disabled:cursor-not-allowed",
182
+ "peer-disabled:opacity-50"
183
+ ),
184
+ children: /* @__PURE__ */ jsx5(
185
+ "svg",
186
+ {
187
+ viewBox: "0 0 14 14",
188
+ className: "size-3 opacity-0 transition-opacity",
189
+ "aria-hidden": "true",
190
+ children: /* @__PURE__ */ jsx5(
191
+ "path",
192
+ {
193
+ d: "m2.5 8 2.4 2.4L12 3.4",
194
+ fill: "none",
195
+ stroke: "white",
196
+ strokeLinecap: "round",
197
+ strokeLinejoin: "round",
198
+ strokeWidth: "1.8"
199
+ }
200
+ )
201
+ }
202
+ )
203
+ }
204
+ )
205
+ ]
131
206
  }
132
- ) }) })
133
- ] });
134
- });
207
+ );
208
+ }
209
+ );
135
210
 
136
211
  // src/combobox/combobox.tsx
137
212
  import {
@@ -410,7 +485,8 @@ function DDropdown({
410
485
  if (!open) return;
411
486
  const outside = (event) => {
412
487
  const target = event.target;
413
- if (!referenceRef.current?.contains(target) && !floatingRef.current?.contains(target)) close();
488
+ if (!referenceRef.current?.contains(target) && !floatingRef.current?.contains(target))
489
+ close();
414
490
  };
415
491
  const escape = (event) => {
416
492
  if (closeOnEsc && event.key === "Escape") close();
@@ -439,7 +515,8 @@ function DDropdown({
439
515
  if (event.defaultPrevented) return;
440
516
  if (event.key === "Enter" || event.key === " ") {
441
517
  const target = event.target;
442
- if (target.tagName === "BUTTON" || target.tagName === "INPUT") return;
518
+ if (target.tagName === "BUTTON" || target.tagName === "INPUT")
519
+ return;
443
520
  event.preventDefault();
444
521
  event.stopPropagation();
445
522
  setOpen((value) => !value);
@@ -463,10 +540,13 @@ function DDropdown({
463
540
  onClick: (event) => {
464
541
  if (!closeOnItemClick) return;
465
542
  const target = event.target;
466
- if (target.closest("button, [role='option'], [role='menuitem'], a")) close();
543
+ if (target.closest(
544
+ "button, [role='option'], [role='menuitem'], a"
545
+ ))
546
+ close();
467
547
  },
468
548
  className: cn(
469
- "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",
549
+ "z-9999 min-w-35 overflow-hidden rounded-(--radius-panel) border border-(--color-border) bg-(--color-surface) shadow-(--shadow-lg) outline-none",
470
550
  contentPadding && "py-1",
471
551
  positioned && "animate-[dropdown-in_150ms_ease-out]",
472
552
  contentClassName
@@ -802,13 +882,33 @@ var INPUT_SIZE_STYLES = {
802
882
  // src/combobox/combobox.tsx
803
883
  import { jsx as jsx8, jsxs as jsxs6 } from "react/jsx-runtime";
804
884
  function SearchIcon({ className }) {
805
- return /* @__PURE__ */ jsxs6("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", className, children: [
806
- /* @__PURE__ */ jsx8("circle", { cx: "11", cy: "11", r: "7" }),
807
- /* @__PURE__ */ jsx8("path", { d: "m20 20-4-4" })
808
- ] });
885
+ return /* @__PURE__ */ jsxs6(
886
+ "svg",
887
+ {
888
+ viewBox: "0 0 24 24",
889
+ fill: "none",
890
+ stroke: "currentColor",
891
+ strokeWidth: "2",
892
+ className,
893
+ children: [
894
+ /* @__PURE__ */ jsx8("circle", { cx: "11", cy: "11", r: "7" }),
895
+ /* @__PURE__ */ jsx8("path", { d: "m20 20-4-4" })
896
+ ]
897
+ }
898
+ );
809
899
  }
810
900
  function ClearIcon() {
811
- return /* @__PURE__ */ jsx8("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", className: "size-3.5", children: /* @__PURE__ */ jsx8("path", { d: "m18 6-12 12M6 6l12 12" }) });
901
+ return /* @__PURE__ */ jsx8(
902
+ "svg",
903
+ {
904
+ viewBox: "0 0 24 24",
905
+ fill: "none",
906
+ stroke: "currentColor",
907
+ strokeWidth: "2",
908
+ className: "size-3.5",
909
+ children: /* @__PURE__ */ jsx8("path", { d: "m18 6-12 12M6 6l12 12" })
910
+ }
911
+ );
812
912
  }
813
913
  function sameValue(left, right) {
814
914
  return String(left ?? "") === String(right ?? "");
@@ -876,7 +976,8 @@ function DCombobox({
876
976
  return () => window.clearTimeout(timeout);
877
977
  }, [debounceMs, fetchOptions, inputValue, onFetchError, open, refetchKey]);
878
978
  useEffect2(() => {
879
- if (!fetchOptions || value == null || value === "" || sameValue(resolvedSelection?.value, value)) return;
979
+ if (!fetchOptions || value == null || value === "" || sameValue(resolvedSelection?.value, value))
980
+ return;
880
981
  const requestId = ++resolveRequestIdRef.current;
881
982
  void fetchOptions("").then((result) => {
882
983
  if (requestId !== resolveRequestIdRef.current) return;
@@ -887,12 +988,16 @@ function DCombobox({
887
988
  const selectedOption = options.find((option) => sameValue(option.value, value)) ?? (sameValue(resolvedSelection?.value, value) ? resolvedSelection : null);
888
989
  const source = isAsync ? asyncOptions : options;
889
990
  const filtered = useMemo3(
890
- () => isAsync ? source : source.filter((option) => String(option.label).toLocaleLowerCase().includes(inputValue.toLocaleLowerCase())),
991
+ () => isAsync ? source : source.filter(
992
+ (option) => String(option.label).toLocaleLowerCase().includes(inputValue.toLocaleLowerCase())
993
+ ),
891
994
  [inputValue, isAsync, source]
892
995
  );
893
996
  useEffect2(() => {
894
997
  if (!open || inputValue) return;
895
- const selectedIndex = filtered.findIndex((option) => sameValue(option.value, value));
998
+ const selectedIndex = filtered.findIndex(
999
+ (option) => sameValue(option.value, value)
1000
+ );
896
1001
  setActiveIndex(selectedIndex >= 0 ? selectedIndex : 0);
897
1002
  }, [filtered, inputValue, open, value]);
898
1003
  const choose = (option) => {
@@ -955,63 +1060,141 @@ function DCombobox({
955
1060
  };
956
1061
  const showIdle = Boolean(idleMessage && !inputValue && !isAsync);
957
1062
  return /* @__PURE__ */ jsxs6("div", { className: cn("flex min-w-0 flex-col gap-1.5", containerClassName), children: [
958
- label ? /* @__PURE__ */ jsx8("label", { htmlFor: id, className: cn(s.label, "w-fit font-medium text-[var(--color-text)]"), children: label }) : null,
959
- /* @__PURE__ */ jsx8(DDropdown, { matchWidth: true, open, onOpenChange: setOpen, contentRole: "listbox", contentPadding: false, contentClassName: "max-h-60 overflow-y-auto p-1.5", scrollBehavior, onClose: () => {
960
- setOpen(false);
961
- setInputValue("");
962
- }, trigger: () => /* @__PURE__ */ jsxs6("div", { className: "relative", children: [
963
- /* @__PURE__ */ jsx8(SearchIcon, { className: cn("pointer-events-none absolute top-1/2 -translate-y-1/2 text-[var(--color-text-muted)]", s.iconLeft) }),
964
- /* @__PURE__ */ jsx8(
965
- "input",
966
- {
967
- ref: inputRef,
968
- id,
969
- "aria-label": ariaLabel,
970
- role: "combobox",
971
- "aria-autocomplete": "list",
972
- "aria-expanded": open,
973
- "aria-invalid": Boolean(error) || void 0,
974
- "aria-controls": `${id}-listbox`,
975
- "aria-activedescendant": open && filtered[activeIndex] ? `${id}-option-${activeIndex}` : void 0,
976
- autoComplete: "off",
977
- type: "text",
978
- disabled,
979
- value: open ? inputValue : String(selectedOption?.label ?? ""),
980
- placeholder: selectedOption ? String(selectedOption.label) : resolvedPlaceholder,
981
- onClick: (event) => event.stopPropagation(),
982
- onFocus: () => {
983
- setOpen(true);
984
- const selectedIndex = filtered.findIndex((option) => sameValue(option.value, value));
985
- setActiveIndex(selectedIndex >= 0 ? selectedIndex : 0);
986
- },
987
- onChange: (event) => {
988
- const next = event.target.value;
989
- setInputValue(next);
990
- onSearchChange?.(next);
991
- setOpen(true);
992
- setActiveIndex(0);
993
- },
994
- onKeyDown: handleKeyDown,
995
- 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)]")
996
- }
997
- ),
998
- clearable && selectedOption && !disabled ? /* @__PURE__ */ jsx8("button", { type: "button", tabIndex: -1, "aria-label": t("combobox.clear"), onMouseDown: (event) => event.preventDefault(), onClick: (event) => {
999
- event.preventDefault();
1000
- event.stopPropagation();
1001
- clear();
1002
- }, 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__ */ jsx8(ClearIcon, {}) }) : null
1003
- ] }), children: /* @__PURE__ */ jsx8("div", { id: `${id}-listbox`, className: "space-y-0.5", children: loading || isFetching ? /* @__PURE__ */ jsx8("div", { className: "px-3 py-6 text-center text-sm text-[var(--color-text-muted)]", children: t("combobox.searching") }) : fetchError ? /* @__PURE__ */ jsx8("div", { className: "px-3 py-6 text-center text-sm text-[var(--color-danger)]", children: resolvedAsyncErrorMessage }) : showIdle ? /* @__PURE__ */ jsx8("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__ */ jsx8("button", { type: "button", onMouseDown: (event) => event.preventDefault(), onClick: (event) => {
1004
- event.stopPropagation();
1005
- create();
1006
- }, 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__ */ jsx8("div", { className: "px-3 py-6 text-center text-sm text-[var(--color-text-muted)]", children: t("combobox.empty") }) : filtered.map((option, index) => {
1007
- const isSelected = sameValue(option.value, value);
1008
- return /* @__PURE__ */ jsx8("button", { id: `${id}-option-${index}`, type: "button", role: "option", "aria-selected": isSelected, disabled: option.disabled, onMouseEnter: () => setActiveIndex(index), onMouseDown: (event) => event.preventDefault(), onClick: (event) => {
1009
- event.stopPropagation();
1010
- choose(option);
1011
- }, 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));
1012
- }) }) }),
1013
- error ? /* @__PURE__ */ jsx8("p", { className: "text-xs text-[var(--color-danger)]", children: error }) : null,
1014
- !error && hint ? /* @__PURE__ */ jsx8("p", { className: "text-xs text-[var(--color-text-muted)]", children: hint }) : null
1063
+ label ? /* @__PURE__ */ jsx8(
1064
+ "label",
1065
+ {
1066
+ htmlFor: id,
1067
+ className: cn(s.label, "w-fit font-medium text-(--color-text)"),
1068
+ children: label
1069
+ }
1070
+ ) : null,
1071
+ /* @__PURE__ */ jsx8(
1072
+ DDropdown,
1073
+ {
1074
+ matchWidth: true,
1075
+ open,
1076
+ onOpenChange: setOpen,
1077
+ contentRole: "listbox",
1078
+ contentPadding: false,
1079
+ contentClassName: "max-h-60 overflow-y-auto p-1.5",
1080
+ scrollBehavior,
1081
+ onClose: () => {
1082
+ setOpen(false);
1083
+ setInputValue("");
1084
+ },
1085
+ trigger: () => /* @__PURE__ */ jsxs6("div", { className: "relative", children: [
1086
+ /* @__PURE__ */ jsx8(
1087
+ SearchIcon,
1088
+ {
1089
+ className: cn(
1090
+ "pointer-events-none absolute top-1/2 -translate-y-1/2 text-(--color-text-muted)",
1091
+ s.iconLeft
1092
+ )
1093
+ }
1094
+ ),
1095
+ /* @__PURE__ */ jsx8(
1096
+ "input",
1097
+ {
1098
+ ref: inputRef,
1099
+ id,
1100
+ "aria-label": ariaLabel,
1101
+ role: "combobox",
1102
+ "aria-autocomplete": "list",
1103
+ "aria-expanded": open,
1104
+ "aria-invalid": Boolean(error) || void 0,
1105
+ "aria-controls": `${id}-listbox`,
1106
+ "aria-activedescendant": open && filtered[activeIndex] ? `${id}-option-${activeIndex}` : void 0,
1107
+ autoComplete: "off",
1108
+ type: "text",
1109
+ disabled,
1110
+ value: open ? inputValue : String(selectedOption?.label ?? ""),
1111
+ placeholder: selectedOption ? String(selectedOption.label) : resolvedPlaceholder,
1112
+ onClick: (event) => event.stopPropagation(),
1113
+ onFocus: () => {
1114
+ setOpen(true);
1115
+ const selectedIndex = filtered.findIndex(
1116
+ (option) => sameValue(option.value, value)
1117
+ );
1118
+ setActiveIndex(selectedIndex >= 0 ? selectedIndex : 0);
1119
+ },
1120
+ onChange: (event) => {
1121
+ const next = event.target.value;
1122
+ setInputValue(next);
1123
+ onSearchChange?.(next);
1124
+ setOpen(true);
1125
+ setActiveIndex(0);
1126
+ },
1127
+ onKeyDown: handleKeyDown,
1128
+ className: cn(
1129
+ "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",
1130
+ s.input,
1131
+ "pl-10 pr-10",
1132
+ error ? "border-(--color-danger) focus:ring-(--color-danger)/20" : "border-(--color-border)"
1133
+ )
1134
+ }
1135
+ ),
1136
+ clearable && selectedOption && !disabled ? /* @__PURE__ */ jsx8(
1137
+ "button",
1138
+ {
1139
+ type: "button",
1140
+ tabIndex: -1,
1141
+ "aria-label": t("combobox.clear"),
1142
+ onMouseDown: (event) => event.preventDefault(),
1143
+ onClick: (event) => {
1144
+ event.preventDefault();
1145
+ event.stopPropagation();
1146
+ clear();
1147
+ },
1148
+ className: cn(
1149
+ "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",
1150
+ s.clear
1151
+ ),
1152
+ children: /* @__PURE__ */ jsx8(ClearIcon, {})
1153
+ }
1154
+ ) : null
1155
+ ] }),
1156
+ children: /* @__PURE__ */ jsx8("div", { id: `${id}-listbox`, className: "space-y-0.5", children: loading || isFetching ? /* @__PURE__ */ jsx8("div", { className: "px-3 py-6 text-center text-sm text-(--color-text-muted)", children: t("combobox.searching") }) : fetchError ? /* @__PURE__ */ jsx8("div", { className: "px-3 py-6 text-center text-sm text-(--color-danger)", children: resolvedAsyncErrorMessage }) : showIdle ? /* @__PURE__ */ jsx8("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__ */ jsx8(
1157
+ "button",
1158
+ {
1159
+ type: "button",
1160
+ onMouseDown: (event) => event.preventDefault(),
1161
+ onClick: (event) => {
1162
+ event.stopPropagation();
1163
+ create();
1164
+ },
1165
+ className: "w-full rounded-lg px-3 py-2 text-left text-sm font-medium text-(--color-brand) hover:bg-(--color-surface-muted)",
1166
+ children: t("combobox.useValue", { value: inputValue.trim() })
1167
+ }
1168
+ ) : /* @__PURE__ */ jsx8("div", { className: "px-3 py-6 text-center text-sm text-(--color-text-muted)", children: t("combobox.empty") }) : filtered.map((option, index) => {
1169
+ const isSelected = sameValue(option.value, value);
1170
+ return /* @__PURE__ */ jsx8(
1171
+ "button",
1172
+ {
1173
+ id: `${id}-option-${index}`,
1174
+ type: "button",
1175
+ role: "option",
1176
+ "aria-selected": isSelected,
1177
+ disabled: option.disabled,
1178
+ onMouseEnter: () => setActiveIndex(index),
1179
+ onMouseDown: (event) => event.preventDefault(),
1180
+ onClick: (event) => {
1181
+ event.stopPropagation();
1182
+ choose(option);
1183
+ },
1184
+ className: cn(
1185
+ "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",
1186
+ isSelected && "bg-(--color-brand)/10 font-medium text-(--color-brand)",
1187
+ index === activeIndex && !isSelected && "bg-(--color-surface-muted)"
1188
+ ),
1189
+ children: renderOption ? renderOption(option, isSelected) : option.label
1190
+ },
1191
+ String(option.value)
1192
+ );
1193
+ }) })
1194
+ }
1195
+ ),
1196
+ error ? /* @__PURE__ */ jsx8("p", { className: "text-xs text-(--color-danger)", children: error }) : null,
1197
+ !error && hint ? /* @__PURE__ */ jsx8("p", { className: "text-xs text-(--color-text-muted)", children: hint }) : null
1015
1198
  ] });
1016
1199
  }
1017
1200
 
@@ -1266,22 +1449,46 @@ function DConfirmDialog({ open, onClose, onConfirm, title, message, confirmLabel
1266
1449
  // src/connection-error/connection-error.tsx
1267
1450
  import { jsx as jsx12, jsxs as jsxs10 } from "react/jsx-runtime";
1268
1451
  function OfflineIcon() {
1269
- return /* @__PURE__ */ jsx12("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", className: "size-9", children: /* @__PURE__ */ jsx12("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" }) });
1452
+ return /* @__PURE__ */ jsx12(
1453
+ "svg",
1454
+ {
1455
+ viewBox: "0 0 24 24",
1456
+ fill: "none",
1457
+ stroke: "currentColor",
1458
+ strokeWidth: "2",
1459
+ className: "size-9",
1460
+ children: /* @__PURE__ */ jsx12("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" })
1461
+ }
1462
+ );
1270
1463
  }
1271
- function DConnectionError({ onRetry, isRetrying = false, title, message, detail, diagnostics }) {
1464
+ function DConnectionError({
1465
+ onRetry,
1466
+ isRetrying = false,
1467
+ title,
1468
+ message,
1469
+ detail,
1470
+ diagnostics
1471
+ }) {
1272
1472
  const { t } = useDLocalization();
1273
- return /* @__PURE__ */ jsx12("div", { className: "fixed inset-0 z-[99998] flex items-center justify-center bg-[var(--color-background)] px-4", children: /* @__PURE__ */ jsxs10("div", { className: "w-full max-w-sm text-center", children: [
1274
- /* @__PURE__ */ jsx12("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__ */ jsx12(OfflineIcon, {}) }),
1275
- /* @__PURE__ */ jsx12("h2", { className: "mb-2 text-xl font-bold text-[var(--color-text)]", children: title ?? t("connectionError.title") }),
1276
- /* @__PURE__ */ jsx12("p", { className: "mb-2 text-sm text-[var(--color-text-muted)]", children: message ?? t("connectionError.message") }),
1277
- /* @__PURE__ */ jsx12("p", { className: "mb-8 text-xs text-[var(--color-text-muted)]/70", children: detail ?? t("connectionError.detail") }),
1473
+ return /* @__PURE__ */ jsx12("div", { className: "fixed inset-0 z-99998 flex items-center justify-center bg-(--color-background) px-4", children: /* @__PURE__ */ jsxs10("div", { className: "w-full max-w-sm text-center", children: [
1474
+ /* @__PURE__ */ jsx12("div", { className: "mx-auto mb-6 flex size-20 items-center justify-center rounded-full bg-(--color-danger)/10 text-(--color-danger)", children: /* @__PURE__ */ jsx12(OfflineIcon, {}) }),
1475
+ /* @__PURE__ */ jsx12("h2", { className: "mb-2 text-xl font-bold text-(--color-text)", children: title ?? t("connectionError.title") }),
1476
+ /* @__PURE__ */ jsx12("p", { className: "mb-2 text-sm text-(--color-text-muted)", children: message ?? t("connectionError.message") }),
1477
+ /* @__PURE__ */ jsx12("p", { className: "mb-8 text-xs text-(--color-text-muted)/70", children: detail ?? t("connectionError.detail") }),
1278
1478
  /* @__PURE__ */ jsx12(DButton, { onClick: onRetry, loading: isRetrying, fullWidth: true, children: isRetrying ? t("connectionError.retrying") : t("connectionError.retry") }),
1279
- diagnostics ? /* @__PURE__ */ jsx12("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
1479
+ diagnostics ? /* @__PURE__ */ jsx12("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
1280
1480
  ] }) });
1281
1481
  }
1282
1482
 
1283
1483
  // src/date-picker/date-picker.tsx
1284
- import { useEffect as useEffect5, useId as useId2, useMemo as useMemo4, useState as useState5 } from "react";
1484
+ import {
1485
+ useEffect as useEffect5,
1486
+ useId as useId2,
1487
+ useLayoutEffect as useLayoutEffect3,
1488
+ useMemo as useMemo4,
1489
+ useRef as useRef6,
1490
+ useState as useState5
1491
+ } from "react";
1285
1492
 
1286
1493
  // src/internal/time/time-picker-panel.tsx
1287
1494
  import { useEffect as useEffect4, useRef as useRef5 } from "react";
@@ -1327,7 +1534,13 @@ var HOURS = Array.from({ length: 24 }, (_, hour) => hour);
1327
1534
  var ITEM_HEIGHT = 44;
1328
1535
  var VISIBLE_ITEMS = 5;
1329
1536
  var WHEEL_PADDING = ITEM_HEIGHT * Math.floor(VISIBLE_ITEMS / 2);
1330
- function WheelColumn({ label, optionAriaLabel, options, selected, onSelect }) {
1537
+ function WheelColumn({
1538
+ label,
1539
+ optionAriaLabel,
1540
+ options,
1541
+ selected,
1542
+ onSelect
1543
+ }) {
1331
1544
  const scrollRef = useRef5(null);
1332
1545
  const settleTimerRef = useRef5(null);
1333
1546
  const selectedIndex = Math.max(0, options.indexOf(selected));
@@ -1335,16 +1548,24 @@ function WheelColumn({ label, optionAriaLabel, options, selected, onSelect }) {
1335
1548
  const node = scrollRef.current;
1336
1549
  if (!node) return;
1337
1550
  const top = selectedIndex * ITEM_HEIGHT;
1338
- if (typeof node.scrollTo === "function") node.scrollTo({ top, behavior: "auto" });
1551
+ if (typeof node.scrollTo === "function")
1552
+ node.scrollTo({ top, behavior: "auto" });
1339
1553
  else node.scrollTop = top;
1340
1554
  }, [selectedIndex]);
1341
- useEffect4(() => () => {
1342
- if (settleTimerRef.current !== null) window.clearTimeout(settleTimerRef.current);
1343
- }, []);
1555
+ useEffect4(
1556
+ () => () => {
1557
+ if (settleTimerRef.current !== null)
1558
+ window.clearTimeout(settleTimerRef.current);
1559
+ },
1560
+ []
1561
+ );
1344
1562
  const settleSelection = () => {
1345
1563
  const node = scrollRef.current;
1346
1564
  if (!node) return;
1347
- const index = Math.max(0, Math.min(options.length - 1, Math.round(node.scrollTop / ITEM_HEIGHT)));
1565
+ const index = Math.max(
1566
+ 0,
1567
+ Math.min(options.length - 1, Math.round(node.scrollTop / ITEM_HEIGHT))
1568
+ );
1348
1569
  const next = options[index];
1349
1570
  if (next !== void 0 && next !== selected) onSelect(next);
1350
1571
  };
@@ -1357,10 +1578,11 @@ function WheelColumn({ label, optionAriaLabel, options, selected, onSelect }) {
1357
1578
  role: "group",
1358
1579
  "aria-label": label,
1359
1580
  onScroll: () => {
1360
- if (settleTimerRef.current !== null) window.clearTimeout(settleTimerRef.current);
1581
+ if (settleTimerRef.current !== null)
1582
+ window.clearTimeout(settleTimerRef.current);
1361
1583
  settleTimerRef.current = window.setTimeout(settleSelection, 90);
1362
1584
  },
1363
- className: "h-[220px] snap-y snap-mandatory overflow-y-auto overscroll-contain [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",
1585
+ className: "h-55 snap-y snap-mandatory overflow-y-auto overscroll-contain scrollbar-none [&::-webkit-scrollbar]:hidden",
1364
1586
  style: { paddingBlock: WHEEL_PADDING },
1365
1587
  children: options.map((option, index) => {
1366
1588
  const active = option === selected;
@@ -1375,8 +1597,8 @@ function WheelColumn({ label, optionAriaLabel, options, selected, onSelect }) {
1375
1597
  tabIndex: active ? 0 : -1,
1376
1598
  onClick: () => onSelect(option),
1377
1599
  className: cn(
1378
- "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",
1379
- 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"
1600
+ "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",
1601
+ 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"
1380
1602
  ),
1381
1603
  children: text
1382
1604
  },
@@ -1387,7 +1609,13 @@ function WheelColumn({ label, optionAriaLabel, options, selected, onSelect }) {
1387
1609
  )
1388
1610
  ] });
1389
1611
  }
1390
- function TimePickerPanel({ value, variant, minuteStep, onChange, className }) {
1612
+ function TimePickerPanel({
1613
+ value,
1614
+ variant,
1615
+ minuteStep,
1616
+ onChange,
1617
+ className
1618
+ }) {
1391
1619
  const { t } = useDLocalization();
1392
1620
  const parsed = parseTimeValue(value) ?? { hour: 0, minute: 0 };
1393
1621
  const minuteOptions = getMinuteOptions(minuteStep, parsed.minute);
@@ -1404,14 +1632,14 @@ function TimePickerPanel({ value, variant, minuteStep, onChange, className }) {
1404
1632
  {
1405
1633
  "data-time-picker-wheel": "true",
1406
1634
  className: cn(
1407
- "relative mx-auto overflow-hidden rounded-[var(--radius-panel)] bg-[var(--color-surface)]",
1408
- variant === "hour-minute" ? "w-full max-w-[244px]" : "w-full max-w-[112px]",
1635
+ "relative mx-auto overflow-hidden rounded-(--radius-panel) bg-(--color-surface)",
1636
+ variant === "hour-minute" ? "w-full max-w-61" : "w-full max-w-28",
1409
1637
  className
1410
1638
  ),
1411
1639
  children: [
1412
- /* @__PURE__ */ jsx13("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" }),
1413
- /* @__PURE__ */ jsx13("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" }),
1414
- /* @__PURE__ */ jsx13("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" }),
1640
+ /* @__PURE__ */ jsx13("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" }),
1641
+ /* @__PURE__ */ jsx13("div", { className: "pointer-events-none absolute inset-x-0 top-0 z-20 h-16 bg-linear-to-b from-(--color-surface) to-transparent" }),
1642
+ /* @__PURE__ */ jsx13("div", { className: "pointer-events-none absolute inset-x-0 bottom-0 z-20 h-16 bg-linear-to-t from-(--color-surface) to-transparent" }),
1415
1643
  /* @__PURE__ */ jsxs11("div", { className: "relative z-10 flex items-center gap-2", children: [
1416
1644
  /* @__PURE__ */ jsx13(
1417
1645
  WheelColumn,
@@ -1424,7 +1652,14 @@ function TimePickerPanel({ value, variant, minuteStep, onChange, className }) {
1424
1652
  }
1425
1653
  ),
1426
1654
  variant === "hour-minute" ? /* @__PURE__ */ jsxs11(Fragment, { children: [
1427
- /* @__PURE__ */ jsx13("span", { "aria-hidden": "true", className: "relative z-10 -mx-1 text-xl font-semibold text-[var(--color-text-muted)]", children: ":" }),
1655
+ /* @__PURE__ */ jsx13(
1656
+ "span",
1657
+ {
1658
+ "aria-hidden": "true",
1659
+ className: "relative z-10 -mx-1 text-xl font-semibold text-(--color-text-muted)",
1660
+ children: ":"
1661
+ }
1662
+ ),
1428
1663
  /* @__PURE__ */ jsx13(
1429
1664
  WheelColumn,
1430
1665
  {
@@ -1445,19 +1680,75 @@ function TimePickerPanel({ value, variant, minuteStep, onChange, className }) {
1445
1680
  // src/date-picker/date-picker.tsx
1446
1681
  import { jsx as jsx14, jsxs as jsxs12 } from "react/jsx-runtime";
1447
1682
  function ChevronLeftIcon2() {
1448
- return /* @__PURE__ */ jsx14("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", className: "size-4", children: /* @__PURE__ */ jsx14("path", { d: "m15 18-6-6 6-6" }) });
1683
+ return /* @__PURE__ */ jsx14(
1684
+ "svg",
1685
+ {
1686
+ viewBox: "0 0 24 24",
1687
+ fill: "none",
1688
+ stroke: "currentColor",
1689
+ strokeWidth: "2",
1690
+ className: "size-4",
1691
+ children: /* @__PURE__ */ jsx14("path", { d: "m15 18-6-6 6-6" })
1692
+ }
1693
+ );
1449
1694
  }
1450
1695
  function ChevronRightIcon2() {
1451
- return /* @__PURE__ */ jsx14("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", className: "size-4", children: /* @__PURE__ */ jsx14("path", { d: "m9 18 6-6-6-6" }) });
1696
+ return /* @__PURE__ */ jsx14(
1697
+ "svg",
1698
+ {
1699
+ viewBox: "0 0 24 24",
1700
+ fill: "none",
1701
+ stroke: "currentColor",
1702
+ strokeWidth: "2",
1703
+ className: "size-4",
1704
+ children: /* @__PURE__ */ jsx14("path", { d: "m9 18 6-6-6-6" })
1705
+ }
1706
+ );
1452
1707
  }
1453
1708
  function CalendarIcon() {
1454
- return /* @__PURE__ */ jsxs12("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", className: "size-3.5", children: [
1455
- /* @__PURE__ */ jsx14("rect", { x: "3", y: "5", width: "18", height: "16", rx: "2" }),
1456
- /* @__PURE__ */ jsx14("path", { d: "M16 3v4M8 3v4M3 10h18" })
1457
- ] });
1709
+ return /* @__PURE__ */ jsxs12(
1710
+ "svg",
1711
+ {
1712
+ viewBox: "0 0 24 24",
1713
+ fill: "none",
1714
+ stroke: "currentColor",
1715
+ strokeWidth: "2",
1716
+ className: "size-3.5",
1717
+ children: [
1718
+ /* @__PURE__ */ jsx14("rect", { x: "3", y: "5", width: "18", height: "16", rx: "2" }),
1719
+ /* @__PURE__ */ jsx14("path", { d: "M16 3v4M8 3v4M3 10h18" })
1720
+ ]
1721
+ }
1722
+ );
1723
+ }
1724
+ function ClockIcon() {
1725
+ return /* @__PURE__ */ jsxs12(
1726
+ "svg",
1727
+ {
1728
+ viewBox: "0 0 24 24",
1729
+ fill: "none",
1730
+ stroke: "currentColor",
1731
+ strokeWidth: "2",
1732
+ className: "size-4",
1733
+ children: [
1734
+ /* @__PURE__ */ jsx14("circle", { cx: "12", cy: "12", r: "9" }),
1735
+ /* @__PURE__ */ jsx14("path", { d: "M12 7v5l3 2" })
1736
+ ]
1737
+ }
1738
+ );
1458
1739
  }
1459
1740
  function ClearIcon2() {
1460
- return /* @__PURE__ */ jsx14("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", className: "size-3.5", children: /* @__PURE__ */ jsx14("path", { d: "m18 6-12 12M6 6l12 12" }) });
1741
+ return /* @__PURE__ */ jsx14(
1742
+ "svg",
1743
+ {
1744
+ viewBox: "0 0 24 24",
1745
+ fill: "none",
1746
+ stroke: "currentColor",
1747
+ strokeWidth: "2",
1748
+ className: "size-3.5",
1749
+ children: /* @__PURE__ */ jsx14("path", { d: "m18 6-12 12M6 6l12 12" })
1750
+ }
1751
+ );
1461
1752
  }
1462
1753
  function datePart(value) {
1463
1754
  return value?.split("T")[0] ?? "";
@@ -1490,42 +1781,230 @@ function formatDisplayValue(value, variant, months) {
1490
1781
  const dateDisplay = formatDateDisplay(value, months);
1491
1782
  if (!dateDisplay) return "";
1492
1783
  if (variant === "date") return dateDisplay;
1493
- const timeDisplay = normalizeTimeValue(timePart(value), timePrecision(variant));
1784
+ const timeDisplay = normalizeTimeValue(
1785
+ timePart(value),
1786
+ timePrecision(variant)
1787
+ );
1494
1788
  return timeDisplay ? `${dateDisplay} \xB7 ${timeDisplay}` : dateDisplay;
1495
1789
  }
1496
- function DatePickerContent({ value, onChange, minDate, maxDate, variant, minuteStep }) {
1790
+ function TimePickerPopover({
1791
+ value,
1792
+ precision,
1793
+ minuteStep,
1794
+ rootRef,
1795
+ triggerRef,
1796
+ onCancel,
1797
+ onSelect
1798
+ }) {
1799
+ const { t } = useDLocalization();
1800
+ const popoverRef = useRef6(null);
1801
+ const interactedRef = useRef6(false);
1802
+ const initialTime = normalizeTimeValue(value, precision) || getCurrentTimeValue(precision, minuteStep);
1803
+ const [draftTime, setDraftTime] = useState5(initialTime);
1804
+ const [hasPickedTime, setHasPickedTime] = useState5(Boolean(value));
1805
+ const [position, setPosition] = useState5({ left: 0, top: 0 });
1806
+ useEffect5(() => {
1807
+ const nextTime = normalizeTimeValue(value, precision) || getCurrentTimeValue(precision, minuteStep);
1808
+ setDraftTime(nextTime);
1809
+ setHasPickedTime(Boolean(value));
1810
+ interactedRef.current = false;
1811
+ }, [value, precision, minuteStep]);
1812
+ const updatePosition = () => {
1813
+ const root = rootRef.current;
1814
+ const trigger = triggerRef.current;
1815
+ const popover = popoverRef.current;
1816
+ if (!root || !trigger || !popover) return;
1817
+ const rootRect = root.getBoundingClientRect();
1818
+ const triggerRect = trigger.getBoundingClientRect();
1819
+ const popoverRect = popover.getBoundingClientRect();
1820
+ const gap = 8;
1821
+ const viewportPadding = 8;
1822
+ let left;
1823
+ let top;
1824
+ const roomLeft = rootRect.left - viewportPadding;
1825
+ const roomRight = window.innerWidth - rootRect.right - viewportPadding;
1826
+ if (roomLeft >= popoverRect.width + gap) {
1827
+ left = -popoverRect.width - gap;
1828
+ } else if (roomRight >= popoverRect.width + gap) {
1829
+ left = rootRect.width + gap;
1830
+ } else {
1831
+ left = Math.max(
1832
+ 0,
1833
+ Math.min(
1834
+ rootRect.width - popoverRect.width,
1835
+ triggerRect.right - rootRect.left - popoverRect.width
1836
+ )
1837
+ );
1838
+ }
1839
+ top = triggerRect.top - rootRect.top + triggerRect.height / 2 - popoverRect.height / 2;
1840
+ const viewportTop = rootRect.top + top;
1841
+ const viewportBottom = viewportTop + popoverRect.height;
1842
+ if (viewportTop < viewportPadding) {
1843
+ top += viewportPadding - viewportTop;
1844
+ }
1845
+ if (viewportBottom > window.innerHeight - viewportPadding) {
1846
+ top -= viewportBottom - (window.innerHeight - viewportPadding);
1847
+ }
1848
+ setPosition({ left, top });
1849
+ };
1850
+ useLayoutEffect3(() => {
1851
+ updatePosition();
1852
+ const handleViewportChange = () => updatePosition();
1853
+ window.addEventListener("resize", handleViewportChange);
1854
+ window.addEventListener("scroll", handleViewportChange, true);
1855
+ return () => {
1856
+ window.removeEventListener("resize", handleViewportChange);
1857
+ window.removeEventListener("scroll", handleViewportChange, true);
1858
+ };
1859
+ }, []);
1860
+ const markInteraction = () => {
1861
+ interactedRef.current = true;
1862
+ };
1863
+ const handleTimeChange = (nextValue) => {
1864
+ const normalized = normalizeTimeValue(nextValue, precision);
1865
+ if (!normalized) return;
1866
+ setDraftTime(normalized);
1867
+ if (interactedRef.current) {
1868
+ setHasPickedTime(true);
1869
+ }
1870
+ };
1871
+ const confirm = () => {
1872
+ if (!hasPickedTime) return;
1873
+ const normalized = normalizeTimeValue(draftTime, precision);
1874
+ if (!normalized) return;
1875
+ onSelect(normalized);
1876
+ };
1877
+ return /* @__PURE__ */ jsxs12(
1878
+ "div",
1879
+ {
1880
+ ref: popoverRef,
1881
+ role: "dialog",
1882
+ "aria-modal": "false",
1883
+ className: "absolute z-50 w-[min(300px,calc(100vw-24px))] overflow-hidden rounded-(--radius-card) border border-(--color-border) bg-(--color-surface) shadow-xl",
1884
+ style: {
1885
+ left: position.left,
1886
+ top: position.top
1887
+ },
1888
+ onPointerDown: (event) => {
1889
+ event.stopPropagation();
1890
+ markInteraction();
1891
+ },
1892
+ onMouseDown: (event) => event.stopPropagation(),
1893
+ onClick: (event) => event.stopPropagation(),
1894
+ onKeyDownCapture: markInteraction,
1895
+ onWheelCapture: markInteraction,
1896
+ children: [
1897
+ /* @__PURE__ */ jsxs12("div", { className: "flex items-start justify-between gap-3 border-b border-(--color-border) px-3 py-3", children: [
1898
+ /* @__PURE__ */ jsxs12("div", { children: [
1899
+ /* @__PURE__ */ jsx14("p", { className: "text-xs font-semibold text-(--color-text)", children: t("datePicker.time") }),
1900
+ /* @__PURE__ */ jsx14("p", { className: "mt-0.5 text-[11px] text-(--color-text-muted)", children: precision === "hour" ? t("datePicker.selectHour") : t("datePicker.selectHourMinute") })
1901
+ ] }),
1902
+ /* @__PURE__ */ jsxs12("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: [
1903
+ /* @__PURE__ */ jsx14(ClockIcon, {}),
1904
+ draftTime
1905
+ ] })
1906
+ ] }),
1907
+ /* @__PURE__ */ jsx14("div", { className: "px-3 py-3", children: /* @__PURE__ */ jsx14(
1908
+ TimePickerPanel,
1909
+ {
1910
+ value: draftTime,
1911
+ variant: precision,
1912
+ minuteStep,
1913
+ onChange: handleTimeChange
1914
+ }
1915
+ ) }),
1916
+ /* @__PURE__ */ jsxs12("div", { className: "flex items-center justify-end gap-2 border-t border-(--color-border) bg-(--color-surface) px-3 py-2.5", children: [
1917
+ /* @__PURE__ */ jsx14(
1918
+ "button",
1919
+ {
1920
+ type: "button",
1921
+ onPointerDown: (event) => event.stopPropagation(),
1922
+ onMouseDown: (event) => event.stopPropagation(),
1923
+ onClick: (event) => {
1924
+ event.preventDefault();
1925
+ event.stopPropagation();
1926
+ onCancel();
1927
+ },
1928
+ 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)",
1929
+ children: t("common.cancel")
1930
+ }
1931
+ ),
1932
+ /* @__PURE__ */ jsx14(
1933
+ "button",
1934
+ {
1935
+ type: "button",
1936
+ disabled: !hasPickedTime,
1937
+ onPointerDown: (event) => {
1938
+ event.stopPropagation();
1939
+ markInteraction();
1940
+ },
1941
+ onMouseDown: (event) => event.stopPropagation(),
1942
+ onClick: (event) => {
1943
+ event.preventDefault();
1944
+ event.stopPropagation();
1945
+ confirm();
1946
+ },
1947
+ 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",
1948
+ children: t("common.apply")
1949
+ }
1950
+ )
1951
+ ] })
1952
+ ]
1953
+ }
1954
+ );
1955
+ }
1956
+ function DatePickerContent({
1957
+ value,
1958
+ onChange,
1959
+ minDate,
1960
+ maxDate,
1961
+ variant,
1962
+ minuteStep
1963
+ }) {
1497
1964
  const close = useDropdownClose();
1498
1965
  const { locale, t } = useDLocalization();
1499
- const days = useMemo4(() => getLocalizedWeekdayNames(locale, "short"), [locale]);
1966
+ const days = useMemo4(
1967
+ () => getLocalizedWeekdayNames(locale, "short"),
1968
+ [locale]
1969
+ );
1500
1970
  const months = useMemo4(() => getLocalizedMonthNames(locale), [locale]);
1501
- const today = /* @__PURE__ */ new Date();
1971
+ const today = useMemo4(() => /* @__PURE__ */ new Date(), []);
1502
1972
  const selectedDate = parseDate(value);
1503
1973
  const selectedDateValue = datePart(value);
1504
1974
  const precision = timePrecision(variant);
1505
- const fallbackTime = () => getCurrentTimeValue(precision, minuteStep);
1506
- const selectedTimeValue = normalizeTimeValue(timePart(value), precision) || fallbackTime();
1507
- const [viewMonth, setViewMonth] = useState5(selectedDate?.getMonth() ?? today.getMonth());
1508
- const [viewYear, setViewYear] = useState5(selectedDate?.getFullYear() ?? today.getFullYear());
1975
+ const selectedTimeValue = normalizeTimeValue(timePart(value), precision);
1976
+ const [viewMonth, setViewMonth] = useState5(
1977
+ selectedDate?.getMonth() ?? today.getMonth()
1978
+ );
1979
+ const [viewYear, setViewYear] = useState5(
1980
+ selectedDate?.getFullYear() ?? today.getFullYear()
1981
+ );
1509
1982
  const [draftDate, setDraftDate] = useState5(selectedDateValue);
1510
1983
  const [draftTime, setDraftTime] = useState5(selectedTimeValue);
1984
+ const [timePopoverOpen, setTimePopoverOpen] = useState5(false);
1985
+ const rootRef = useRef6(null);
1986
+ const timeTriggerRef = useRef6(null);
1511
1987
  useEffect5(() => {
1512
1988
  const nextDate = parseDate(value);
1513
1989
  setDraftDate(datePart(value));
1514
- setDraftTime(normalizeTimeValue(timePart(value), precision) || fallbackTime());
1990
+ setDraftTime(normalizeTimeValue(timePart(value), precision));
1991
+ setTimePopoverOpen(false);
1515
1992
  if (!nextDate) return;
1516
1993
  setViewMonth(nextDate.getMonth());
1517
1994
  setViewYear(nextDate.getFullYear());
1518
- }, [value, variant, minuteStep]);
1995
+ }, [value, precision]);
1519
1996
  const daysInMonth = new Date(viewYear, viewMonth + 1, 0).getDate();
1520
1997
  const firstDay = new Date(viewYear, viewMonth, 1).getDay();
1521
1998
  const move = (amount) => {
1522
1999
  const next = new Date(viewYear, viewMonth + amount, 1);
1523
- setViewYear(next.getFullYear());
1524
2000
  setViewMonth(next.getMonth());
2001
+ setViewYear(next.getFullYear());
1525
2002
  };
1526
2003
  const selectDate = (day) => {
1527
2004
  const next = toValue(viewYear, viewMonth, day);
1528
- if (minDate && compareDateValue(next, minDate) < 0 || maxDate && compareDateValue(next, maxDate) > 0) return;
2005
+ if (minDate && compareDateValue(next, minDate) < 0 || maxDate && compareDateValue(next, maxDate) > 0) {
2006
+ return;
2007
+ }
1529
2008
  if (variant === "date") {
1530
2009
  onChange?.(next);
1531
2010
  close?.();
@@ -1533,9 +2012,14 @@ function DatePickerContent({ value, onChange, minDate, maxDate, variant, minuteS
1533
2012
  }
1534
2013
  setDraftDate(next);
1535
2014
  };
1536
- const todayValue = toValue(today.getFullYear(), today.getMonth(), today.getDate());
1537
- const todayDisabled = minDate && compareDateValue(todayValue, minDate) < 0 || maxDate && compareDateValue(todayValue, maxDate) > 0;
2015
+ const todayValue = toValue(
2016
+ today.getFullYear(),
2017
+ today.getMonth(),
2018
+ today.getDate()
2019
+ );
2020
+ const todayDisabled = Boolean(minDate && compareDateValue(todayValue, minDate) < 0) || Boolean(maxDate && compareDateValue(todayValue, maxDate) > 0);
1538
2021
  const selectToday = () => {
2022
+ if (todayDisabled) return;
1539
2023
  if (variant === "date") {
1540
2024
  onChange?.(todayValue);
1541
2025
  close?.();
@@ -1546,88 +2030,306 @@ function DatePickerContent({ value, onChange, minDate, maxDate, variant, minuteS
1546
2030
  setViewYear(today.getFullYear());
1547
2031
  };
1548
2032
  const applyDateTime = () => {
1549
- if (!draftDate) return;
1550
- const normalizedTime = normalizeTimeValue(draftTime, precision) || fallbackTime();
1551
- onChange?.(`${draftDate}T${normalizedTime}`);
2033
+ if (!draftDate || !draftTime) return;
2034
+ onChange?.(`${draftDate}T${draftTime}`);
1552
2035
  close?.();
1553
2036
  };
1554
- return /* @__PURE__ */ jsxs12("div", { className: cn("p-3", variant === "date" ? "w-[280px]" : "w-[min(320px,calc(100vw-16px))]"), children: [
1555
- /* @__PURE__ */ jsxs12("div", { className: "mb-2 flex items-center justify-between", children: [
1556
- /* @__PURE__ */ jsx14("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__ */ jsx14(ChevronLeftIcon2, {}) }),
1557
- /* @__PURE__ */ jsxs12("span", { className: "text-sm font-medium text-[var(--color-text)]", children: [
1558
- months[viewMonth],
1559
- " ",
1560
- viewYear
1561
- ] }),
1562
- /* @__PURE__ */ jsx14("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__ */ jsx14(ChevronRightIcon2, {}) })
1563
- ] }),
1564
- /* @__PURE__ */ jsx14("div", { className: "mb-1 grid grid-cols-7 text-xs", children: days.map((day) => /* @__PURE__ */ jsx14("div", { className: "text-center text-[var(--color-text-muted)]", children: day }, day)) }),
1565
- /* @__PURE__ */ jsxs12("div", { className: "grid grid-cols-7 gap-1", children: [
1566
- Array.from({ length: firstDay }).map((_, index) => /* @__PURE__ */ jsx14("div", {}, `empty-${index}`)),
1567
- Array.from({ length: daysInMonth }, (_, index) => index + 1).map((day) => {
1568
- const dateValue = toValue(viewYear, viewMonth, day);
1569
- const selected = (variant === "date" ? selectedDateValue : draftDate) === dateValue;
1570
- const outside = minDate && compareDateValue(dateValue, minDate) < 0 || maxDate && compareDateValue(dateValue, maxDate) > 0;
1571
- return /* @__PURE__ */ jsx14("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);
1572
- })
1573
- ] }),
1574
- variant !== "date" ? /* @__PURE__ */ jsxs12("div", { className: "mt-3 border-t border-[var(--color-border)] pt-3", children: [
1575
- /* @__PURE__ */ jsxs12("div", { className: "mb-3 flex items-center justify-between gap-3", children: [
1576
- /* @__PURE__ */ jsxs12("div", { children: [
1577
- /* @__PURE__ */ jsx14("p", { className: "text-xs font-semibold text-[var(--color-text)]", children: t("datePicker.time") }),
1578
- /* @__PURE__ */ jsx14("p", { className: "mt-0.5 text-[11px] text-[var(--color-text-muted)]", children: variant === "date-hour" ? t("datePicker.selectHour") : t("datePicker.selectHourMinute") })
1579
- ] }),
1580
- /* @__PURE__ */ jsx14("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 })
1581
- ] }),
1582
- /* @__PURE__ */ jsx14(TimePickerPanel, { value: draftTime, variant: precision, minuteStep, onChange: setDraftTime })
1583
- ] }) : null,
1584
- /* @__PURE__ */ jsxs12("div", { className: "mt-3 flex items-center justify-between gap-2 border-t border-[var(--color-border)] pt-3", children: [
1585
- /* @__PURE__ */ jsx14("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") }),
1586
- variant !== "date" ? /* @__PURE__ */ jsxs12("div", { className: "flex items-center gap-2", children: [
1587
- /* @__PURE__ */ jsx14("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") }),
1588
- /* @__PURE__ */ jsx14("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") })
1589
- ] }) : null
1590
- ] })
1591
- ] });
1592
- }
1593
- function DDatePicker({ label, value, onChange, onClear, placeholder, error, hint, disabled = false, clearable = true, containerClassName, minDate, maxDate, size = "md", variant = "date", minuteStep = 1, scrollBehavior = "reposition" }) {
1594
- const id = useId2();
1595
- const { locale, t } = useDLocalization();
1596
- const months = useMemo4(() => getLocalizedMonthNames(locale), [locale]);
1597
- const s = INPUT_SIZE_STYLES[size];
1598
- const display = formatDisplayValue(value, variant, months);
1599
- const resolvedPlaceholder = placeholder ?? t("datePicker.placeholder");
1600
- return /* @__PURE__ */ jsxs12("div", { "data-ds-component": "date-picker", "data-date-picker-variant": variant, className: cn("flex min-w-0 flex-col gap-1.5", containerClassName), children: [
1601
- label ? /* @__PURE__ */ jsx14("label", { htmlFor: id, className: cn(s.label, "w-fit font-medium text-[var(--color-text)]"), children: label }) : null,
1602
- /* @__PURE__ */ jsx14(DDropdown, { contentRole: "dialog", contentPadding: false, scrollBehavior, trigger: () => /* @__PURE__ */ jsxs12("div", { className: "relative", children: [
1603
- /* @__PURE__ */ jsxs12("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: [
1604
- /* @__PURE__ */ jsx14("span", { className: "text-[var(--color-text-muted)]", children: /* @__PURE__ */ jsx14(CalendarIcon, {}) }),
1605
- /* @__PURE__ */ jsx14("span", { className: "min-w-0 flex-1 truncate", children: display || resolvedPlaceholder })
1606
- ] }),
1607
- clearable && display && !disabled ? /* @__PURE__ */ jsx14("button", { type: "button", "aria-label": t("datePicker.clear"), onMouseDown: (event) => event.preventDefault(), onClick: (event) => {
1608
- event.preventDefault();
1609
- event.stopPropagation();
1610
- onChange?.("");
1611
- onClear?.();
1612
- }, 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__ */ jsx14(ClearIcon2, {}) }) : null
1613
- ] }), children: /* @__PURE__ */ jsx14(DatePickerContent, { value, onChange, minDate, maxDate, variant, minuteStep }) }),
1614
- error ? /* @__PURE__ */ jsx14("p", { className: "text-xs text-[var(--color-danger)]", children: error }) : null,
1615
- !error && hint ? /* @__PURE__ */ jsx14("p", { className: "text-xs text-[var(--color-text-muted)]", children: hint }) : null
1616
- ] });
1617
- }
1618
-
1619
- // src/time-picker/time-picker.tsx
1620
- import { useEffect as useEffect6, useId as useId3, useState as useState6 } from "react";
1621
- import { jsx as jsx15, jsxs as jsxs13 } from "react/jsx-runtime";
1622
- function ClockIcon() {
1623
- return /* @__PURE__ */ jsxs13("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", className: "size-3.5", children: [
1624
- /* @__PURE__ */ jsx15("circle", { cx: "12", cy: "12", r: "9" }),
1625
- /* @__PURE__ */ jsx15("path", { d: "M12 7v5l3 2" })
1626
- ] });
1627
- }
1628
- function ClearIcon3() {
1629
- return /* @__PURE__ */ jsx15("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", className: "size-3.5", children: /* @__PURE__ */ jsx15("path", { d: "m18 6-12 12M6 6l12 12" }) });
1630
- }
2037
+ const canApply = Boolean(draftDate) && Boolean(draftTime);
2038
+ return /* @__PURE__ */ jsxs12(
2039
+ "div",
2040
+ {
2041
+ ref: rootRef,
2042
+ className: cn(
2043
+ "relative",
2044
+ variant === "date" ? "w-70" : "w-[min(340px,calc(100vw-16px))]"
2045
+ ),
2046
+ children: [
2047
+ /* @__PURE__ */ jsxs12("div", { className: "flex max-h-[min(560px,calc(100dvh-24px))] flex-col overflow-hidden rounded-(--radius-card) bg-(--color-surface)", children: [
2048
+ /* @__PURE__ */ jsxs12("div", { className: "min-h-0 flex-1 overflow-y-auto overscroll-contain p-3", children: [
2049
+ /* @__PURE__ */ jsxs12("div", { className: "mb-2 flex items-center justify-between", children: [
2050
+ /* @__PURE__ */ jsx14(
2051
+ "button",
2052
+ {
2053
+ type: "button",
2054
+ "aria-label": t("common.previousMonth"),
2055
+ onClick: () => move(-1),
2056
+ 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)",
2057
+ children: /* @__PURE__ */ jsx14(ChevronLeftIcon2, {})
2058
+ }
2059
+ ),
2060
+ /* @__PURE__ */ jsxs12("span", { className: "text-sm font-medium text-(--color-text)", children: [
2061
+ months[viewMonth],
2062
+ " ",
2063
+ viewYear
2064
+ ] }),
2065
+ /* @__PURE__ */ jsx14(
2066
+ "button",
2067
+ {
2068
+ type: "button",
2069
+ "aria-label": t("common.nextMonth"),
2070
+ onClick: () => move(1),
2071
+ 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)",
2072
+ children: /* @__PURE__ */ jsx14(ChevronRightIcon2, {})
2073
+ }
2074
+ )
2075
+ ] }),
2076
+ /* @__PURE__ */ jsx14("div", { className: "mb-1 grid grid-cols-7 text-xs", children: days.map((day) => /* @__PURE__ */ jsx14("div", { className: "text-center text-(--color-text-muted)", children: day }, day)) }),
2077
+ /* @__PURE__ */ jsxs12("div", { className: "grid grid-cols-7 gap-1", children: [
2078
+ Array.from({ length: firstDay }).map((_, index) => /* @__PURE__ */ jsx14("div", {}, `empty-${index}`)),
2079
+ Array.from({ length: daysInMonth }, (_, index) => index + 1).map(
2080
+ (day) => {
2081
+ const dateValue = toValue(viewYear, viewMonth, day);
2082
+ const selected = (variant === "date" ? selectedDateValue : draftDate) === dateValue;
2083
+ const outside = Boolean(
2084
+ minDate && compareDateValue(dateValue, minDate) < 0
2085
+ ) || Boolean(maxDate && compareDateValue(dateValue, maxDate) > 0);
2086
+ return /* @__PURE__ */ jsx14(
2087
+ "button",
2088
+ {
2089
+ type: "button",
2090
+ disabled: outside,
2091
+ onClick: () => selectDate(day),
2092
+ className: cn(
2093
+ "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",
2094
+ selected && "bg-(--color-brand) font-medium text-(--color-brand-foreground) hover:bg-(--color-brand)"
2095
+ ),
2096
+ children: day
2097
+ },
2098
+ day
2099
+ );
2100
+ }
2101
+ )
2102
+ ] }),
2103
+ variant !== "date" ? /* @__PURE__ */ jsxs12("div", { className: "mt-3 border-t border-(--color-border) pt-3", children: [
2104
+ /* @__PURE__ */ jsxs12("div", { className: "flex items-center justify-between gap-3", children: [
2105
+ /* @__PURE__ */ jsxs12("div", { className: "min-w-0", children: [
2106
+ /* @__PURE__ */ jsx14("p", { className: "text-xs font-semibold text-(--color-text)", children: t("datePicker.time") }),
2107
+ /* @__PURE__ */ jsx14("p", { className: "mt-0.5 text-[11px] text-(--color-text-muted)", children: variant === "date-hour" ? t("datePicker.selectHour") : t("datePicker.selectHourMinute") })
2108
+ ] }),
2109
+ /* @__PURE__ */ jsx14(
2110
+ "span",
2111
+ {
2112
+ className: cn(
2113
+ "shrink-0 rounded-(--radius-menu-item) bg-(--color-surface-muted) px-2 py-1 text-xs font-semibold tabular-nums",
2114
+ draftTime ? "text-(--color-text)" : "text-(--color-text-muted)"
2115
+ ),
2116
+ children: draftTime || "--:--"
2117
+ }
2118
+ )
2119
+ ] }),
2120
+ /* @__PURE__ */ jsxs12(
2121
+ "button",
2122
+ {
2123
+ ref: timeTriggerRef,
2124
+ type: "button",
2125
+ onPointerDown: (event) => event.stopPropagation(),
2126
+ onMouseDown: (event) => {
2127
+ event.preventDefault();
2128
+ event.stopPropagation();
2129
+ },
2130
+ onClick: (event) => {
2131
+ event.preventDefault();
2132
+ event.stopPropagation();
2133
+ setTimePopoverOpen((open) => !open);
2134
+ },
2135
+ 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",
2136
+ children: [
2137
+ /* @__PURE__ */ jsx14(ClockIcon, {}),
2138
+ draftTime ? "Ubah waktu" : "Pilih waktu"
2139
+ ]
2140
+ }
2141
+ )
2142
+ ] }) : null
2143
+ ] }),
2144
+ /* @__PURE__ */ jsx14("div", { className: "shrink-0 border-t border-(--color-border) bg-(--color-surface) px-3 py-2.5", children: /* @__PURE__ */ jsxs12("div", { className: "flex items-center justify-between gap-2", children: [
2145
+ /* @__PURE__ */ jsx14(
2146
+ "button",
2147
+ {
2148
+ type: "button",
2149
+ disabled: todayDisabled,
2150
+ onClick: selectToday,
2151
+ 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",
2152
+ children: t("datePicker.today")
2153
+ }
2154
+ ),
2155
+ variant !== "date" ? /* @__PURE__ */ jsxs12("div", { className: "flex items-center gap-2", children: [
2156
+ /* @__PURE__ */ jsx14(
2157
+ "button",
2158
+ {
2159
+ type: "button",
2160
+ onClick: () => close?.(),
2161
+ 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)",
2162
+ children: t("common.cancel")
2163
+ }
2164
+ ),
2165
+ /* @__PURE__ */ jsx14(
2166
+ "button",
2167
+ {
2168
+ type: "button",
2169
+ disabled: !canApply,
2170
+ onClick: applyDateTime,
2171
+ 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",
2172
+ children: t("common.apply")
2173
+ }
2174
+ )
2175
+ ] }) : null
2176
+ ] }) })
2177
+ ] }),
2178
+ timePopoverOpen ? /* @__PURE__ */ jsx14(
2179
+ TimePickerPopover,
2180
+ {
2181
+ value: draftTime,
2182
+ precision,
2183
+ minuteStep,
2184
+ rootRef,
2185
+ triggerRef: timeTriggerRef,
2186
+ onCancel: () => setTimePopoverOpen(false),
2187
+ onSelect: (nextTime) => {
2188
+ setDraftTime(nextTime);
2189
+ setTimePopoverOpen(false);
2190
+ }
2191
+ }
2192
+ ) : null
2193
+ ]
2194
+ }
2195
+ );
2196
+ }
2197
+ function DDatePicker({
2198
+ label,
2199
+ value,
2200
+ onChange,
2201
+ onClear,
2202
+ placeholder,
2203
+ error,
2204
+ hint,
2205
+ disabled = false,
2206
+ clearable = true,
2207
+ containerClassName,
2208
+ minDate,
2209
+ maxDate,
2210
+ size = "md",
2211
+ variant = "date",
2212
+ minuteStep = 1,
2213
+ scrollBehavior = "reposition"
2214
+ }) {
2215
+ const id = useId2();
2216
+ const { locale, t } = useDLocalization();
2217
+ const months = useMemo4(() => getLocalizedMonthNames(locale), [locale]);
2218
+ const s = INPUT_SIZE_STYLES[size];
2219
+ const display = formatDisplayValue(value, variant, months);
2220
+ const resolvedPlaceholder = placeholder ?? t("datePicker.placeholder");
2221
+ return /* @__PURE__ */ jsxs12(
2222
+ "div",
2223
+ {
2224
+ "data-ds-component": "date-picker",
2225
+ "data-date-picker-variant": variant,
2226
+ className: cn("flex min-w-0 flex-col gap-1.5", containerClassName),
2227
+ children: [
2228
+ label ? /* @__PURE__ */ jsx14(
2229
+ "label",
2230
+ {
2231
+ htmlFor: id,
2232
+ className: cn(s.label, "w-fit font-medium text-(--color-text)"),
2233
+ children: label
2234
+ }
2235
+ ) : null,
2236
+ /* @__PURE__ */ jsx14(
2237
+ DDropdown,
2238
+ {
2239
+ contentRole: "dialog",
2240
+ contentPadding: false,
2241
+ contentClassName: "!overflow-visible",
2242
+ scrollBehavior,
2243
+ trigger: () => /* @__PURE__ */ jsxs12("div", { className: "relative", children: [
2244
+ /* @__PURE__ */ jsxs12(
2245
+ "button",
2246
+ {
2247
+ id,
2248
+ type: "button",
2249
+ disabled,
2250
+ "aria-invalid": Boolean(error) || void 0,
2251
+ className: cn(
2252
+ "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",
2253
+ s.input,
2254
+ error ? "border-(--color-danger)" : "border-(--color-border)",
2255
+ !display && "text-(--color-text-muted)/60",
2256
+ clearable && display && "pr-10"
2257
+ ),
2258
+ children: [
2259
+ /* @__PURE__ */ jsx14("span", { className: "text-(--color-text-muted)", children: /* @__PURE__ */ jsx14(CalendarIcon, {}) }),
2260
+ /* @__PURE__ */ jsx14("span", { className: "min-w-0 flex-1 truncate", children: display || resolvedPlaceholder })
2261
+ ]
2262
+ }
2263
+ ),
2264
+ clearable && display && !disabled ? /* @__PURE__ */ jsx14(
2265
+ "button",
2266
+ {
2267
+ type: "button",
2268
+ "aria-label": t("datePicker.clear"),
2269
+ onMouseDown: (event) => event.preventDefault(),
2270
+ onClick: (event) => {
2271
+ event.preventDefault();
2272
+ event.stopPropagation();
2273
+ onChange?.("");
2274
+ onClear?.();
2275
+ },
2276
+ 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)",
2277
+ children: /* @__PURE__ */ jsx14(ClearIcon2, {})
2278
+ }
2279
+ ) : null
2280
+ ] }),
2281
+ children: /* @__PURE__ */ jsx14(
2282
+ DatePickerContent,
2283
+ {
2284
+ value,
2285
+ onChange,
2286
+ minDate,
2287
+ maxDate,
2288
+ variant,
2289
+ minuteStep
2290
+ }
2291
+ )
2292
+ }
2293
+ ),
2294
+ error ? /* @__PURE__ */ jsx14("p", { className: "text-xs text-(--color-danger)", children: error }) : null,
2295
+ !error && hint ? /* @__PURE__ */ jsx14("p", { className: "text-xs text-(--color-text-muted)", children: hint }) : null
2296
+ ]
2297
+ }
2298
+ );
2299
+ }
2300
+
2301
+ // src/time-picker/time-picker.tsx
2302
+ import { useEffect as useEffect6, useId as useId3, useState as useState6 } from "react";
2303
+ import { jsx as jsx15, jsxs as jsxs13 } from "react/jsx-runtime";
2304
+ function ClockIcon2() {
2305
+ return /* @__PURE__ */ jsxs13(
2306
+ "svg",
2307
+ {
2308
+ viewBox: "0 0 24 24",
2309
+ fill: "none",
2310
+ stroke: "currentColor",
2311
+ strokeWidth: "2",
2312
+ className: "size-3.5",
2313
+ children: [
2314
+ /* @__PURE__ */ jsx15("circle", { cx: "12", cy: "12", r: "9" }),
2315
+ /* @__PURE__ */ jsx15("path", { d: "M12 7v5l3 2" })
2316
+ ]
2317
+ }
2318
+ );
2319
+ }
2320
+ function ClearIcon3() {
2321
+ return /* @__PURE__ */ jsx15(
2322
+ "svg",
2323
+ {
2324
+ viewBox: "0 0 24 24",
2325
+ fill: "none",
2326
+ stroke: "currentColor",
2327
+ strokeWidth: "2",
2328
+ className: "size-3.5",
2329
+ children: /* @__PURE__ */ jsx15("path", { d: "m18 6-12 12M6 6l12 12" })
2330
+ }
2331
+ );
2332
+ }
1631
2333
  function TimePickerContent({
1632
2334
  value,
1633
2335
  onChange,
@@ -1637,7 +2339,9 @@ function TimePickerContent({
1637
2339
  const close = useDropdownClose();
1638
2340
  const { t } = useDLocalization();
1639
2341
  const fallback = () => getCurrentTimeValue(variant, minuteStep);
1640
- const [draft, setDraft] = useState6(() => normalizeTimeValue(value, variant) || fallback());
2342
+ const [draft, setDraft] = useState6(
2343
+ () => normalizeTimeValue(value, variant) || fallback()
2344
+ );
1641
2345
  useEffect6(() => {
1642
2346
  setDraft(normalizeTimeValue(value, variant) || fallback());
1643
2347
  }, [value, variant, minuteStep]);
@@ -1645,47 +2349,64 @@ function TimePickerContent({
1645
2349
  onChange?.(normalizeTimeValue(draft, variant));
1646
2350
  close?.();
1647
2351
  };
1648
- return /* @__PURE__ */ jsxs13("div", { className: cn("p-3", variant === "hour" ? "w-[min(232px,calc(100vw-16px))]" : "w-[min(320px,calc(100vw-16px))]"), children: [
1649
- /* @__PURE__ */ jsxs13("div", { className: "mb-3 flex items-center justify-between gap-3", children: [
1650
- /* @__PURE__ */ jsxs13("div", { children: [
1651
- /* @__PURE__ */ jsx15("p", { className: "text-xs font-semibold text-[var(--color-text)]", children: t("timePicker.title") }),
1652
- /* @__PURE__ */ jsx15("p", { className: "mt-0.5 text-[11px] text-[var(--color-text-muted)]", children: variant === "hour" ? t("timePicker.hourPrecision") : t("timePicker.hourMinutePrecision") })
1653
- ] }),
1654
- /* @__PURE__ */ jsx15("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 })
1655
- ] }),
1656
- /* @__PURE__ */ jsx15(TimePickerPanel, { value: draft, variant, minuteStep, onChange: setDraft }),
1657
- /* @__PURE__ */ jsxs13("div", { className: "mt-3 flex items-center justify-between gap-2 border-t border-[var(--color-border)] pt-3", children: [
1658
- /* @__PURE__ */ jsx15(
1659
- "button",
1660
- {
1661
- type: "button",
1662
- onClick: () => setDraft(fallback()),
1663
- 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)]",
1664
- children: t("timePicker.now")
1665
- }
2352
+ return /* @__PURE__ */ jsxs13(
2353
+ "div",
2354
+ {
2355
+ className: cn(
2356
+ "p-3",
2357
+ variant === "hour" ? "w-[min(232px,calc(100vw-16px))]" : "w-[min(320px,calc(100vw-16px))]"
1666
2358
  ),
1667
- /* @__PURE__ */ jsxs13("div", { className: "flex items-center gap-2", children: [
2359
+ children: [
2360
+ /* @__PURE__ */ jsxs13("div", { className: "mb-3 flex items-center justify-between gap-3", children: [
2361
+ /* @__PURE__ */ jsxs13("div", { children: [
2362
+ /* @__PURE__ */ jsx15("p", { className: "text-xs font-semibold text-(--color-text)", children: t("timePicker.title") }),
2363
+ /* @__PURE__ */ jsx15("p", { className: "mt-0.5 text-[11px] text-(--color-text-muted)", children: variant === "hour" ? t("timePicker.hourPrecision") : t("timePicker.hourMinutePrecision") })
2364
+ ] }),
2365
+ /* @__PURE__ */ jsx15("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 })
2366
+ ] }),
1668
2367
  /* @__PURE__ */ jsx15(
1669
- "button",
2368
+ TimePickerPanel,
1670
2369
  {
1671
- type: "button",
1672
- onClick: () => close?.(),
1673
- 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)]",
1674
- children: t("common.cancel")
2370
+ value: draft,
2371
+ variant,
2372
+ minuteStep,
2373
+ onChange: setDraft
1675
2374
  }
1676
2375
  ),
1677
- /* @__PURE__ */ jsx15(
1678
- "button",
1679
- {
1680
- type: "button",
1681
- onClick: apply,
1682
- 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",
1683
- children: t("common.apply")
1684
- }
1685
- )
1686
- ] })
1687
- ] })
1688
- ] });
2376
+ /* @__PURE__ */ jsxs13("div", { className: "mt-3 flex items-center justify-between gap-2 border-t border-(--color-border) pt-3", children: [
2377
+ /* @__PURE__ */ jsx15(
2378
+ "button",
2379
+ {
2380
+ type: "button",
2381
+ onClick: () => setDraft(fallback()),
2382
+ 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)",
2383
+ children: t("timePicker.now")
2384
+ }
2385
+ ),
2386
+ /* @__PURE__ */ jsxs13("div", { className: "flex items-center gap-2", children: [
2387
+ /* @__PURE__ */ jsx15(
2388
+ "button",
2389
+ {
2390
+ type: "button",
2391
+ onClick: () => close?.(),
2392
+ 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)",
2393
+ children: t("common.cancel")
2394
+ }
2395
+ ),
2396
+ /* @__PURE__ */ jsx15(
2397
+ "button",
2398
+ {
2399
+ type: "button",
2400
+ onClick: apply,
2401
+ 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",
2402
+ children: t("common.apply")
2403
+ }
2404
+ )
2405
+ ] })
2406
+ ] })
2407
+ ]
2408
+ }
2409
+ );
1689
2410
  }
1690
2411
  function DTimePicker({
1691
2412
  label,
@@ -1708,49 +2429,80 @@ function DTimePicker({
1708
2429
  const s = INPUT_SIZE_STYLES[size];
1709
2430
  const display = normalizeTimeValue(value, variant);
1710
2431
  const resolvedPlaceholder = placeholder ?? t("timePicker.placeholder");
1711
- return /* @__PURE__ */ jsxs13("div", { "data-ds-component": "time-picker", className: cn("flex min-w-0 flex-col gap-1.5", containerClassName), children: [
1712
- label ? /* @__PURE__ */ jsx15("label", { htmlFor: id, className: cn(s.label, "w-fit font-medium text-[var(--color-text)]"), children: label }) : null,
1713
- /* @__PURE__ */ jsx15(DDropdown, { contentRole: "dialog", contentPadding: false, scrollBehavior, trigger: () => /* @__PURE__ */ jsxs13("div", { className: "relative", children: [
1714
- /* @__PURE__ */ jsxs13(
1715
- "button",
1716
- {
1717
- id,
1718
- type: "button",
1719
- disabled,
1720
- "aria-invalid": Boolean(error) || void 0,
1721
- className: cn(
1722
- "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",
1723
- s.input,
1724
- error ? "border-[var(--color-danger)]" : "border-[var(--color-border)]",
1725
- !display && "text-[var(--color-text-muted)]/60",
1726
- clearable && display && "pr-10"
1727
- ),
1728
- children: [
1729
- /* @__PURE__ */ jsx15("span", { className: "text-[var(--color-text-muted)]", children: /* @__PURE__ */ jsx15(ClockIcon, {}) }),
1730
- /* @__PURE__ */ jsx15("span", { className: "min-w-0 flex-1 truncate tabular-nums", children: display || resolvedPlaceholder })
1731
- ]
1732
- }
1733
- ),
1734
- clearable && display && !disabled ? /* @__PURE__ */ jsx15(
1735
- "button",
1736
- {
1737
- type: "button",
1738
- "aria-label": t("timePicker.clear"),
1739
- onMouseDown: (event) => event.preventDefault(),
1740
- onClick: (event) => {
1741
- event.preventDefault();
1742
- event.stopPropagation();
1743
- onChange?.("");
1744
- onClear?.();
1745
- },
1746
- 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)]",
1747
- children: /* @__PURE__ */ jsx15(ClearIcon3, {})
1748
- }
1749
- ) : null
1750
- ] }), children: /* @__PURE__ */ jsx15(TimePickerContent, { value, onChange, variant, minuteStep }) }),
1751
- error ? /* @__PURE__ */ jsx15("p", { className: "text-xs text-[var(--color-danger)]", children: error }) : null,
1752
- !error && hint ? /* @__PURE__ */ jsx15("p", { className: "text-xs text-[var(--color-text-muted)]", children: hint }) : null
1753
- ] });
2432
+ return /* @__PURE__ */ jsxs13(
2433
+ "div",
2434
+ {
2435
+ "data-ds-component": "time-picker",
2436
+ className: cn("flex min-w-0 flex-col gap-1.5", containerClassName),
2437
+ children: [
2438
+ label ? /* @__PURE__ */ jsx15(
2439
+ "label",
2440
+ {
2441
+ htmlFor: id,
2442
+ className: cn(s.label, "w-fit font-medium text-(--color-text)"),
2443
+ children: label
2444
+ }
2445
+ ) : null,
2446
+ /* @__PURE__ */ jsx15(
2447
+ DDropdown,
2448
+ {
2449
+ contentRole: "dialog",
2450
+ contentPadding: false,
2451
+ scrollBehavior,
2452
+ trigger: () => /* @__PURE__ */ jsxs13("div", { className: "relative", children: [
2453
+ /* @__PURE__ */ jsxs13(
2454
+ "button",
2455
+ {
2456
+ id,
2457
+ type: "button",
2458
+ disabled,
2459
+ "aria-invalid": Boolean(error) || void 0,
2460
+ className: cn(
2461
+ "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",
2462
+ s.input,
2463
+ error ? "border-(--color-danger)" : "border-(--color-border)",
2464
+ !display && "text-(--color-text-muted)/60",
2465
+ clearable && display && "pr-10"
2466
+ ),
2467
+ children: [
2468
+ /* @__PURE__ */ jsx15("span", { className: "text-(--color-text-muted)", children: /* @__PURE__ */ jsx15(ClockIcon2, {}) }),
2469
+ /* @__PURE__ */ jsx15("span", { className: "min-w-0 flex-1 truncate tabular-nums", children: display || resolvedPlaceholder })
2470
+ ]
2471
+ }
2472
+ ),
2473
+ clearable && display && !disabled ? /* @__PURE__ */ jsx15(
2474
+ "button",
2475
+ {
2476
+ type: "button",
2477
+ "aria-label": t("timePicker.clear"),
2478
+ onMouseDown: (event) => event.preventDefault(),
2479
+ onClick: (event) => {
2480
+ event.preventDefault();
2481
+ event.stopPropagation();
2482
+ onChange?.("");
2483
+ onClear?.();
2484
+ },
2485
+ 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)",
2486
+ children: /* @__PURE__ */ jsx15(ClearIcon3, {})
2487
+ }
2488
+ ) : null
2489
+ ] }),
2490
+ children: /* @__PURE__ */ jsx15(
2491
+ TimePickerContent,
2492
+ {
2493
+ value,
2494
+ onChange,
2495
+ variant,
2496
+ minuteStep
2497
+ }
2498
+ )
2499
+ }
2500
+ ),
2501
+ error ? /* @__PURE__ */ jsx15("p", { className: "text-xs text-(--color-danger)", children: error }) : null,
2502
+ !error && hint ? /* @__PURE__ */ jsx15("p", { className: "text-xs text-(--color-text-muted)", children: hint }) : null
2503
+ ]
2504
+ }
2505
+ );
1754
2506
  }
1755
2507
 
1756
2508
  // src/date-range-filter/date-range-filter.tsx
@@ -1804,9 +2556,26 @@ function DEmptyState({
1804
2556
  import { useState as useState7 } from "react";
1805
2557
  import { jsx as jsx18, jsxs as jsxs16 } from "react/jsx-runtime";
1806
2558
  function DownloadIcon() {
1807
- return /* @__PURE__ */ jsx18("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", className: "size-3.5", children: /* @__PURE__ */ jsx18("path", { d: "M12 3v12m0 0 4-4m-4 4-4-4M5 21h14" }) });
2559
+ return /* @__PURE__ */ jsx18(
2560
+ "svg",
2561
+ {
2562
+ viewBox: "0 0 24 24",
2563
+ fill: "none",
2564
+ stroke: "currentColor",
2565
+ strokeWidth: "2",
2566
+ className: "size-3.5",
2567
+ children: /* @__PURE__ */ jsx18("path", { d: "M12 3v12m0 0 4-4m-4 4-4-4M5 21h14" })
2568
+ }
2569
+ );
1808
2570
  }
1809
- function ExportContent({ onExport, filename, onSuccess, onError, onProcessing, setLoading }) {
2571
+ function ExportContent({
2572
+ onExport,
2573
+ filename,
2574
+ onSuccess,
2575
+ onError,
2576
+ onProcessing,
2577
+ setLoading
2578
+ }) {
1810
2579
  const close = useDropdownClose();
1811
2580
  const { t } = useDLocalization();
1812
2581
  const run = async (format) => {
@@ -1842,15 +2611,60 @@ function ExportContent({ onExport, filename, onSuccess, onError, onProcessing, s
1842
2611
  setLoading(false);
1843
2612
  }
1844
2613
  };
1845
- return /* @__PURE__ */ jsxs16("div", { className: "min-w-[140px] py-1", children: [
1846
- /* @__PURE__ */ jsx18("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") }),
1847
- /* @__PURE__ */ jsx18("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") })
2614
+ return /* @__PURE__ */ jsxs16("div", { className: "min-w-35 py-1", children: [
2615
+ /* @__PURE__ */ jsx18(
2616
+ "button",
2617
+ {
2618
+ type: "button",
2619
+ onClick: () => void run("pdf"),
2620
+ className: "w-full px-3 py-2 text-left text-sm text-(--color-text) hover:bg-(--color-surface-muted)",
2621
+ children: t("export.pdf")
2622
+ }
2623
+ ),
2624
+ /* @__PURE__ */ jsx18(
2625
+ "button",
2626
+ {
2627
+ type: "button",
2628
+ onClick: () => void run("excel"),
2629
+ className: "w-full px-3 py-2 text-left text-sm text-(--color-text) hover:bg-(--color-surface-muted)",
2630
+ children: t("export.excel")
2631
+ }
2632
+ )
1848
2633
  ] });
1849
2634
  }
1850
- function DExportButton({ filename = "export", disabled, ...props }) {
2635
+ function DExportButton({
2636
+ filename = "export",
2637
+ disabled,
2638
+ ...props
2639
+ }) {
1851
2640
  const [loading, setLoading] = useState7(false);
1852
2641
  const { t } = useDLocalization();
1853
- return /* @__PURE__ */ jsx18(DDropdown, { placement: "bottom-end", trigger: () => /* @__PURE__ */ jsx18(DButton, { variant: "outline", size: "sm", leftIcon: /* @__PURE__ */ jsx18(DownloadIcon, {}), loading, disabled, children: t("export.label") }), children: /* @__PURE__ */ jsx18(ExportContent, { ...props, filename, disabled, setLoading }) });
2642
+ return /* @__PURE__ */ jsx18(
2643
+ DDropdown,
2644
+ {
2645
+ placement: "bottom-end",
2646
+ trigger: () => /* @__PURE__ */ jsx18(
2647
+ DButton,
2648
+ {
2649
+ variant: "outline",
2650
+ size: "sm",
2651
+ leftIcon: /* @__PURE__ */ jsx18(DownloadIcon, {}),
2652
+ loading,
2653
+ disabled,
2654
+ children: t("export.label")
2655
+ }
2656
+ ),
2657
+ children: /* @__PURE__ */ jsx18(
2658
+ ExportContent,
2659
+ {
2660
+ ...props,
2661
+ filename,
2662
+ disabled,
2663
+ setLoading
2664
+ }
2665
+ )
2666
+ }
2667
+ );
1854
2668
  }
1855
2669
 
1856
2670
  // src/form-validation/form.tsx
@@ -1860,7 +2674,7 @@ import {
1860
2674
  useContext as useContext3,
1861
2675
  useEffect as useEffect7,
1862
2676
  useMemo as useMemo5,
1863
- useRef as useRef6,
2677
+ useRef as useRef7,
1864
2678
  useState as useState8
1865
2679
  } from "react";
1866
2680
 
@@ -1983,7 +2797,7 @@ function DForm({
1983
2797
  const { t } = useDLocalization();
1984
2798
  const [errors, setErrors] = useState8({});
1985
2799
  const [submitted, setSubmitted] = useState8(false);
1986
- const fieldsRef = useRef6(/* @__PURE__ */ new Map());
2800
+ const fieldsRef = useRef7(/* @__PURE__ */ new Map());
1987
2801
  const modes = useMemo5(() => normalizeValidateOn(validateOn), [validateOn]);
1988
2802
  const mergedValues = useCallback3(() => {
1989
2803
  const next = { ...values };
@@ -2065,7 +2879,7 @@ function useDFormField({ name, value, label, rules = [], validateOn }) {
2065
2879
  const form = useContext3(FormContext);
2066
2880
  const { t } = useDLocalization();
2067
2881
  const [localError, setLocalError] = useState8(void 0);
2068
- const mountedRef = useRef6(false);
2882
+ const mountedRef = useRef7(false);
2069
2883
  const localModes = useMemo5(() => normalizeValidateOn(validateOn), [validateOn]);
2070
2884
  const modes = validateOn ? localModes : form?.validateOn ?? localModes;
2071
2885
  const resolvedLabel = label ?? name ?? t("validation.defaultLabel");
@@ -2150,26 +2964,59 @@ import {
2150
2964
  forwardRef as forwardRef3,
2151
2965
  useEffect as useEffect8,
2152
2966
  useId as useId4,
2153
- useLayoutEffect as useLayoutEffect3,
2154
- useRef as useRef7,
2967
+ useLayoutEffect as useLayoutEffect4,
2968
+ useRef as useRef8,
2155
2969
  useState as useState9
2156
2970
  } from "react";
2157
2971
  import { jsx as jsx21, jsxs as jsxs18 } from "react/jsx-runtime";
2158
2972
  function ClearIcon4({ className }) {
2159
- return /* @__PURE__ */ jsx21("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", className, children: /* @__PURE__ */ jsx21("path", { d: "m18 6-12 12M6 6l12 12" }) });
2973
+ return /* @__PURE__ */ jsx21(
2974
+ "svg",
2975
+ {
2976
+ viewBox: "0 0 24 24",
2977
+ fill: "none",
2978
+ stroke: "currentColor",
2979
+ strokeWidth: "2",
2980
+ className,
2981
+ children: /* @__PURE__ */ jsx21("path", { d: "m18 6-12 12M6 6l12 12" })
2982
+ }
2983
+ );
2160
2984
  }
2161
- function EyeIcon({ closed, className }) {
2162
- return /* @__PURE__ */ jsxs18("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", className, children: [
2163
- closed ? /* @__PURE__ */ jsx21("path", { d: "m3 3 18 18" }) : null,
2164
- /* @__PURE__ */ jsx21("path", { d: "M2 12s3.5-6 10-6 10 6 10 6-3.5 6-10 6S2 12 2 12Z" }),
2165
- /* @__PURE__ */ jsx21("circle", { cx: "12", cy: "12", r: "2.5" })
2166
- ] });
2985
+ function EyeIcon({
2986
+ closed,
2987
+ className
2988
+ }) {
2989
+ return /* @__PURE__ */ jsxs18(
2990
+ "svg",
2991
+ {
2992
+ viewBox: "0 0 24 24",
2993
+ fill: "none",
2994
+ stroke: "currentColor",
2995
+ strokeWidth: "2",
2996
+ className,
2997
+ children: [
2998
+ closed ? /* @__PURE__ */ jsx21("path", { d: "m3 3 18 18" }) : null,
2999
+ /* @__PURE__ */ jsx21("path", { d: "M2 12s3.5-6 10-6 10 6 10 6-3.5 6-10 6S2 12 2 12Z" }),
3000
+ /* @__PURE__ */ jsx21("circle", { cx: "12", cy: "12", r: "2.5" })
3001
+ ]
3002
+ }
3003
+ );
2167
3004
  }
2168
3005
  function InfoIcon({ className }) {
2169
- return /* @__PURE__ */ jsxs18("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", className, children: [
2170
- /* @__PURE__ */ jsx21("circle", { cx: "12", cy: "12", r: "9" }),
2171
- /* @__PURE__ */ jsx21("path", { d: "M12 10v6M12 7h.01" })
2172
- ] });
3006
+ return /* @__PURE__ */ jsxs18(
3007
+ "svg",
3008
+ {
3009
+ viewBox: "0 0 24 24",
3010
+ fill: "none",
3011
+ stroke: "currentColor",
3012
+ strokeWidth: "2",
3013
+ className,
3014
+ children: [
3015
+ /* @__PURE__ */ jsx21("circle", { cx: "12", cy: "12", r: "9" }),
3016
+ /* @__PURE__ */ jsx21("path", { d: "M12 10v6M12 7h.01" })
3017
+ ]
3018
+ }
3019
+ );
2173
3020
  }
2174
3021
  function assignRef(ref, value) {
2175
3022
  if (typeof ref === "function") ref(value);
@@ -2181,7 +3028,10 @@ function formatLegacyCurrency(value) {
2181
3028
  return raw.replace(/\B(?=(\d{3})+(?!\d))/g, ".");
2182
3029
  }
2183
3030
  function eventWithValue(value) {
2184
- return { target: { value }, currentTarget: { value } };
3031
+ return {
3032
+ target: { value },
3033
+ currentTarget: { value }
3034
+ };
2185
3035
  }
2186
3036
  function countDigitsAfterCaret(value, caret) {
2187
3037
  if (caret === null) return 0;
@@ -2227,12 +3077,14 @@ var DInput = forwardRef3(function DInput2({
2227
3077
  const { t } = useDLocalization();
2228
3078
  const autoId = useId4();
2229
3079
  const id = externalId ?? autoId;
2230
- const inputRef = useRef7(null);
2231
- const pendingCaretDigitsAfterRef = useRef7(null);
3080
+ const inputRef = useRef8(null);
3081
+ const pendingCaretDigitsAfterRef = useRef8(null);
2232
3082
  const [showPassword, setShowPassword] = useState9(false);
2233
3083
  const [showTooltip, setShowTooltip] = useState9(false);
2234
- const [internalValue, setInternalValue] = useState9(() => defaultValue == null ? "" : String(defaultValue));
2235
- const tooltipRef = useRef7(null);
3084
+ const [internalValue, setInternalValue] = useState9(
3085
+ () => defaultValue == null ? "" : String(defaultValue)
3086
+ );
3087
+ const tooltipRef = useRef8(null);
2236
3088
  const s = INPUT_SIZE_STYLES[size];
2237
3089
  const isControlled = value !== void 0;
2238
3090
  const currentValue = isControlled ? value : internalValue;
@@ -2245,21 +3097,26 @@ var DInput = forwardRef3(function DInput2({
2245
3097
  const resolvedPrefix = prefix ?? (format === "currency" ? "Rp" : void 0);
2246
3098
  const resolvedSuffix = suffix ?? (format === "percentage" ? "%" : void 0);
2247
3099
  const hasLeading = Boolean(leadingIcon || resolvedPrefix);
2248
- const hasTrailing = Boolean(trailingIcon || resolvedSuffix || showClear || type === "password" || loading);
3100
+ const hasTrailing = Boolean(
3101
+ trailingIcon || resolvedSuffix || showClear || type === "password" || loading
3102
+ );
2249
3103
  useEffect8(() => {
2250
3104
  const handleClickOutside = (event) => {
2251
- if (!tooltipRef.current?.contains(event.target)) setShowTooltip(false);
3105
+ if (!tooltipRef.current?.contains(event.target))
3106
+ setShowTooltip(false);
2252
3107
  };
2253
3108
  document.addEventListener("mousedown", handleClickOutside);
2254
3109
  return () => document.removeEventListener("mousedown", handleClickOutside);
2255
3110
  }, []);
2256
3111
  const displayValue = (() => {
2257
3112
  if (currentValue === void 0 || currentValue === null) return "";
2258
- if (type === "number" && (currentValue === 0 || currentValue === "0")) return "";
2259
- if (format === "currency") return formatLegacyCurrency(currentValue);
3113
+ if (type === "number" && (currentValue === 0 || currentValue === "0"))
3114
+ return "";
3115
+ if (format === "currency")
3116
+ return formatLegacyCurrency(currentValue);
2260
3117
  return String(currentValue);
2261
3118
  })();
2262
- useLayoutEffect3(() => {
3119
+ useLayoutEffect4(() => {
2263
3120
  const pending = pendingCaretDigitsAfterRef.current;
2264
3121
  const input = inputRef.current;
2265
3122
  if (pending === null || !input || document.activeElement !== input) return;
@@ -2270,7 +3127,10 @@ var DInput = forwardRef3(function DInput2({
2270
3127
  const handleChange = (event) => {
2271
3128
  let next = event.target.value;
2272
3129
  if (format === "currency") {
2273
- pendingCaretDigitsAfterRef.current = countDigitsAfterCaret(event.target.value, event.target.selectionStart);
3130
+ pendingCaretDigitsAfterRef.current = countDigitsAfterCaret(
3131
+ event.target.value,
3132
+ event.target.selectionStart
3133
+ );
2274
3134
  next = next.replace(/\D/g, "");
2275
3135
  } else if (format !== "plain") {
2276
3136
  next = next.replace(/[^0-9.,-]/g, "");
@@ -2288,78 +3148,209 @@ var DInput = forwardRef3(function DInput2({
2288
3148
  pendingCaretDigitsAfterRef.current = null;
2289
3149
  inputRef.current?.focus();
2290
3150
  };
2291
- return /* @__PURE__ */ jsxs18("div", { "data-ds-component": "input", className: cn("flex min-w-0 flex-col gap-1.5", containerClassName), children: [
2292
- label ? /* @__PURE__ */ jsxs18("div", { className: "flex w-fit items-center gap-1.5", children: [
2293
- /* @__PURE__ */ jsx21("label", { htmlFor: id, className: cn(s.label, "font-medium text-[var(--color-text)]"), children: label }),
2294
- labelInfo ? /* @__PURE__ */ jsxs18("div", { ref: tooltipRef, className: "group relative flex items-center", children: [
2295
- /* @__PURE__ */ jsx21("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__ */ jsx21(InfoIcon, { className: "size-3.5" }) }),
2296
- /* @__PURE__ */ jsx21("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__ */ jsxs18("div", { className: "relative rounded-lg bg-[var(--color-tooltip)] px-3 py-2 text-xs text-white shadow-lg", children: [
2297
- labelInfo,
2298
- /* @__PURE__ */ jsx21("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)]" })
2299
- ] }) })
2300
- ] }) : null
2301
- ] }) : null,
2302
- /* @__PURE__ */ jsxs18("div", { className: "relative flex min-w-0 items-center", children: [
2303
- leadingIcon ? /* @__PURE__ */ jsx21("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,
2304
- resolvedPrefix ? /* @__PURE__ */ jsx21("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,
2305
- /* @__PURE__ */ jsx21(
2306
- "input",
2307
- {
2308
- ...props,
2309
- ref: (node) => {
2310
- inputRef.current = node;
2311
- assignRef(forwardedRef, node);
2312
- },
2313
- id,
2314
- autoComplete: props.autoComplete ?? "off",
2315
- type: inputType,
2316
- inputMode: props.inputMode ?? (type === "number" || format !== "plain" ? "numeric" : void 0),
2317
- value: displayValue,
2318
- onChange: handleChange,
2319
- disabled: disabled || loading,
2320
- readOnly,
2321
- "aria-invalid": Boolean(error) || void 0,
2322
- "aria-busy": loading || void 0,
2323
- className: cn(
2324
- "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)]",
2325
- s.input,
2326
- error ? "border-[var(--color-danger)] focus:border-[var(--color-danger)] focus:ring-[var(--color-danger)]/20" : "border-[var(--color-border)]",
2327
- hasLeading && (size === "sm" ? "pl-8" : "pl-10"),
2328
- hasTrailing && (size === "sm" ? "pr-8" : "pr-10"),
2329
- className
2330
- )
2331
- }
2332
- ),
2333
- resolvedSuffix ? /* @__PURE__ */ jsx21("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,
2334
- showClear || type === "password" || trailingIcon || loading ? /* @__PURE__ */ jsxs18("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: [
2335
- loading ? /* @__PURE__ */ jsx21("span", { "aria-label": t("input.loading"), className: "size-4 animate-spin rounded-full border-2 border-current border-t-transparent" }) : null,
2336
- !loading && showClear ? /* @__PURE__ */ jsx21("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__ */ jsx21(ClearIcon4, { className: size === "sm" ? "size-3" : "size-3.5" }) }) : null,
2337
- !loading && type === "password" ? /* @__PURE__ */ jsx21("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__ */ jsx21(EyeIcon, { closed: showPassword, className: size === "sm" ? "size-3" : "size-3.5" }) }) : null,
2338
- !loading && trailingIcon ? /* @__PURE__ */ jsx21("span", { className: "flex items-center", children: trailingIcon }) : null
2339
- ] }) : null
2340
- ] }),
2341
- error ? /* @__PURE__ */ jsx21("p", { className: "text-xs text-[var(--color-danger)]", children: error }) : null,
2342
- !error && hint ? /* @__PURE__ */ jsx21("p", { className: "text-xs text-[var(--color-text-muted)]", children: hint }) : null
2343
- ] });
3151
+ return /* @__PURE__ */ jsxs18(
3152
+ "div",
3153
+ {
3154
+ "data-ds-component": "input",
3155
+ className: cn("flex min-w-0 flex-col gap-1.5", containerClassName),
3156
+ children: [
3157
+ label ? /* @__PURE__ */ jsxs18("div", { className: "flex w-fit items-center gap-1.5", children: [
3158
+ /* @__PURE__ */ jsx21(
3159
+ "label",
3160
+ {
3161
+ htmlFor: id,
3162
+ className: cn(s.label, "font-medium text-(--color-text)"),
3163
+ children: label
3164
+ }
3165
+ ),
3166
+ labelInfo ? /* @__PURE__ */ jsxs18("div", { ref: tooltipRef, className: "group relative flex items-center", children: [
3167
+ /* @__PURE__ */ jsx21(
3168
+ "button",
3169
+ {
3170
+ type: "button",
3171
+ "aria-label": t("input.fieldInfo"),
3172
+ "aria-expanded": showTooltip,
3173
+ onClick: () => setShowTooltip((v) => !v),
3174
+ className: "text-(--color-text-muted) hover:text-(--color-text)",
3175
+ children: /* @__PURE__ */ jsx21(InfoIcon, { className: "size-3.5" })
3176
+ }
3177
+ ),
3178
+ /* @__PURE__ */ jsx21(
3179
+ "div",
3180
+ {
3181
+ role: "tooltip",
3182
+ className: cn(
3183
+ "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",
3184
+ showTooltip && "visible opacity-100"
3185
+ ),
3186
+ children: /* @__PURE__ */ jsxs18("div", { className: "relative rounded-lg bg-(--color-tooltip) px-3 py-2 text-xs text-white shadow-lg", children: [
3187
+ labelInfo,
3188
+ /* @__PURE__ */ jsx21("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)" })
3189
+ ] })
3190
+ }
3191
+ )
3192
+ ] }) : null
3193
+ ] }) : null,
3194
+ /* @__PURE__ */ jsxs18("div", { className: "relative flex min-w-0 items-center", children: [
3195
+ leadingIcon ? /* @__PURE__ */ jsx21(
3196
+ "span",
3197
+ {
3198
+ className: cn(
3199
+ "pointer-events-none absolute top-1/2 z-10 -translate-y-1/2 text-(--color-text-muted)",
3200
+ size === "sm" ? "left-2.5 [&_svg]:size-3.5" : "left-3 [&_svg]:size-4"
3201
+ ),
3202
+ children: leadingIcon
3203
+ }
3204
+ ) : null,
3205
+ resolvedPrefix ? /* @__PURE__ */ jsx21(
3206
+ "span",
3207
+ {
3208
+ className: cn(
3209
+ "pointer-events-none absolute left-3 top-1/2 z-10 -translate-y-1/2 font-medium text-(--color-text-muted)",
3210
+ size === "sm" ? "text-xs" : "text-sm"
3211
+ ),
3212
+ children: resolvedPrefix
3213
+ }
3214
+ ) : null,
3215
+ /* @__PURE__ */ jsx21(
3216
+ "input",
3217
+ {
3218
+ ...props,
3219
+ ref: (node) => {
3220
+ inputRef.current = node;
3221
+ assignRef(forwardedRef, node);
3222
+ },
3223
+ id,
3224
+ autoComplete: props.autoComplete ?? "off",
3225
+ type: inputType,
3226
+ inputMode: props.inputMode ?? (type === "number" || format !== "plain" ? "numeric" : void 0),
3227
+ value: displayValue,
3228
+ onChange: handleChange,
3229
+ disabled: disabled || loading,
3230
+ readOnly,
3231
+ "aria-invalid": Boolean(error) || void 0,
3232
+ "aria-busy": loading || void 0,
3233
+ className: cn(
3234
+ "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)",
3235
+ s.input,
3236
+ error ? "border-(--color-danger) focus:border-(--color-danger) focus:ring-(--color-danger)/20" : "border-(--color-border)",
3237
+ hasLeading && (size === "sm" ? "pl-8" : "pl-10"),
3238
+ hasTrailing && (size === "sm" ? "pr-8" : "pr-10"),
3239
+ className
3240
+ )
3241
+ }
3242
+ ),
3243
+ resolvedSuffix ? /* @__PURE__ */ jsx21(
3244
+ "span",
3245
+ {
3246
+ className: cn(
3247
+ "pointer-events-none absolute top-1/2 -translate-y-1/2 font-medium text-(--color-text-muted)",
3248
+ size === "sm" ? "right-2.5 text-xs" : "right-3 text-sm"
3249
+ ),
3250
+ children: resolvedSuffix
3251
+ }
3252
+ ) : null,
3253
+ showClear || type === "password" || trailingIcon || loading ? /* @__PURE__ */ jsxs18(
3254
+ "div",
3255
+ {
3256
+ className: cn(
3257
+ "absolute top-1/2 flex -translate-y-1/2 items-center text-(--color-text-muted)",
3258
+ size === "sm" ? "right-1.5 gap-0.5" : "right-2 gap-1",
3259
+ resolvedSuffix && "pointer-events-none opacity-0"
3260
+ ),
3261
+ children: [
3262
+ loading ? /* @__PURE__ */ jsx21(
3263
+ "span",
3264
+ {
3265
+ "aria-label": t("input.loading"),
3266
+ className: "size-4 animate-spin rounded-full border-2 border-current border-t-transparent"
3267
+ }
3268
+ ) : null,
3269
+ !loading && showClear ? /* @__PURE__ */ jsx21(
3270
+ "button",
3271
+ {
3272
+ type: "button",
3273
+ tabIndex: -1,
3274
+ "aria-label": t("input.clear"),
3275
+ onMouseDown: (event) => event.preventDefault(),
3276
+ onClick: handleClear,
3277
+ className: cn(
3278
+ "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",
3279
+ size === "sm" ? "p-0.5" : "p-1"
3280
+ ),
3281
+ children: /* @__PURE__ */ jsx21(ClearIcon4, { className: size === "sm" ? "size-3" : "size-3.5" })
3282
+ }
3283
+ ) : null,
3284
+ !loading && type === "password" ? /* @__PURE__ */ jsx21(
3285
+ "button",
3286
+ {
3287
+ type: "button",
3288
+ tabIndex: -1,
3289
+ "aria-label": showPassword ? t("input.hidePassword") : t("input.showPassword"),
3290
+ onMouseDown: (event) => event.preventDefault(),
3291
+ onClick: () => setShowPassword((v) => !v),
3292
+ className: cn(
3293
+ "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",
3294
+ size === "sm" ? "p-0.5" : "p-1"
3295
+ ),
3296
+ children: /* @__PURE__ */ jsx21(
3297
+ EyeIcon,
3298
+ {
3299
+ closed: showPassword,
3300
+ className: size === "sm" ? "size-3" : "size-3.5"
3301
+ }
3302
+ )
3303
+ }
3304
+ ) : null,
3305
+ !loading && trailingIcon ? /* @__PURE__ */ jsx21("span", { className: "flex items-center", children: trailingIcon }) : null
3306
+ ]
3307
+ }
3308
+ ) : null
3309
+ ] }),
3310
+ error ? /* @__PURE__ */ jsx21("p", { className: "text-xs text-(--color-danger)", children: error }) : null,
3311
+ !error && hint ? /* @__PURE__ */ jsx21("p", { className: "text-xs text-(--color-text-muted)", children: hint }) : null
3312
+ ]
3313
+ }
3314
+ );
2344
3315
  });
2345
3316
  DInput.displayName = "DInput";
2346
3317
  function normalizeDecimalInput(input, { scale = 4, integer: integer2 = false } = {}) {
2347
3318
  const decimalIndex = Math.max(input.lastIndexOf("."), input.lastIndexOf(","));
2348
3319
  const hasDecimal = !integer2 && decimalIndex >= 0;
2349
- const rawWhole = (hasDecimal ? input.slice(0, decimalIndex) : input).replace(/\D/g, "");
3320
+ const rawWhole = (hasDecimal ? input.slice(0, decimalIndex) : input).replace(
3321
+ /\D/g,
3322
+ ""
3323
+ );
2350
3324
  const rawFraction = hasDecimal ? input.slice(decimalIndex + 1).replace(/\D/g, "") : "";
2351
3325
  const whole = rawWhole.replace(/^0+(?=\d)/, "");
2352
3326
  if (!hasDecimal) return whole;
2353
3327
  return `${whole || "0"}.${rawFraction.slice(0, Math.max(0, scale))}`;
2354
3328
  }
2355
- var DDecimalInput = forwardRef3(function DDecimalInput2({ value, onValueChange, scale = 4, integer: integer2 = false, ...props }, ref) {
2356
- return /* @__PURE__ */ jsx21(DInput, { ref, ...props, value, type: "text", inputMode: integer2 ? "numeric" : "decimal", onNativeChange: (event) => onValueChange(normalizeDecimalInput(event.target.value, { scale, integer: integer2 })) });
2357
- });
3329
+ var DDecimalInput = forwardRef3(
3330
+ function DDecimalInput2({ value, onValueChange, scale = 4, integer: integer2 = false, ...props }, ref) {
3331
+ return /* @__PURE__ */ jsx21(
3332
+ DInput,
3333
+ {
3334
+ ref,
3335
+ ...props,
3336
+ value,
3337
+ type: "text",
3338
+ inputMode: integer2 ? "numeric" : "decimal",
3339
+ onNativeChange: (event) => onValueChange(
3340
+ normalizeDecimalInput(event.target.value, { scale, integer: integer2 })
3341
+ )
3342
+ }
3343
+ );
3344
+ }
3345
+ );
2358
3346
  function formatCurrencyInputValue(value, { groupSeparator = ".", decimalSeparator = "," } = {}) {
2359
3347
  if (!value) return "";
2360
3348
  const normalized = normalizeDecimalInput(value);
2361
3349
  const [whole = "", fraction] = normalized.split(".");
2362
- const grouped = (whole || "0").replace(/\B(?=(\d{3})+(?!\d))/g, groupSeparator);
3350
+ const grouped = (whole || "0").replace(
3351
+ /\B(?=(\d{3})+(?!\d))/g,
3352
+ groupSeparator
3353
+ );
2363
3354
  return fraction === void 0 ? grouped : `${grouped}${decimalSeparator}${fraction}`;
2364
3355
  }
2365
3356
  function parseCurrencyInputValue(value, { groupSeparator = ".", decimalSeparator = "," } = {}) {
@@ -2374,44 +3365,58 @@ function parseCurrencyInputValue(value, { groupSeparator = ".", decimalSeparator
2374
3365
  if (!hasDecimal) return whole;
2375
3366
  return `${whole || "0"}.${fraction}`;
2376
3367
  }
2377
- var DCurrencyInput = forwardRef3(function DCurrencyInput2({
2378
- value,
2379
- onValueChange,
2380
- currencySymbol = "Rp",
2381
- groupSeparator = ".",
2382
- decimalSeparator = ",",
2383
- ...props
2384
- }, forwardedRef) {
2385
- const inputRef = useRef7(null);
2386
- const pendingCaretDigitsAfterRef = useRef7(null);
2387
- const displayed = formatCurrencyInputValue(value, { groupSeparator, decimalSeparator });
2388
- useLayoutEffect3(() => {
2389
- const pending = pendingCaretDigitsAfterRef.current;
2390
- const input = inputRef.current;
2391
- if (pending === null || !input || document.activeElement !== input) return;
2392
- const nextCaret = caretFromDigitsAfter(input.value, pending);
2393
- input.setSelectionRange(nextCaret, nextCaret);
2394
- pendingCaretDigitsAfterRef.current = null;
2395
- }, [displayed]);
2396
- return /* @__PURE__ */ jsx21(
2397
- DInput,
2398
- {
2399
- ref: (node) => {
2400
- inputRef.current = node;
2401
- assignRef(forwardedRef, node);
2402
- },
2403
- ...props,
2404
- value: displayed,
2405
- type: "text",
2406
- inputMode: "decimal",
2407
- prefix: currencySymbol,
2408
- onNativeChange: (event) => {
2409
- pendingCaretDigitsAfterRef.current = countDigitsAfterCaret(event.target.value, event.target.selectionStart);
2410
- onValueChange(parseCurrencyInputValue(event.target.value, { groupSeparator, decimalSeparator }));
3368
+ var DCurrencyInput = forwardRef3(
3369
+ function DCurrencyInput2({
3370
+ value,
3371
+ onValueChange,
3372
+ currencySymbol = "Rp",
3373
+ groupSeparator = ".",
3374
+ decimalSeparator = ",",
3375
+ ...props
3376
+ }, forwardedRef) {
3377
+ const inputRef = useRef8(null);
3378
+ const pendingCaretDigitsAfterRef = useRef8(null);
3379
+ const displayed = formatCurrencyInputValue(value, {
3380
+ groupSeparator,
3381
+ decimalSeparator
3382
+ });
3383
+ useLayoutEffect4(() => {
3384
+ const pending = pendingCaretDigitsAfterRef.current;
3385
+ const input = inputRef.current;
3386
+ if (pending === null || !input || document.activeElement !== input)
3387
+ return;
3388
+ const nextCaret = caretFromDigitsAfter(input.value, pending);
3389
+ input.setSelectionRange(nextCaret, nextCaret);
3390
+ pendingCaretDigitsAfterRef.current = null;
3391
+ }, [displayed]);
3392
+ return /* @__PURE__ */ jsx21(
3393
+ DInput,
3394
+ {
3395
+ ref: (node) => {
3396
+ inputRef.current = node;
3397
+ assignRef(forwardedRef, node);
3398
+ },
3399
+ ...props,
3400
+ value: displayed,
3401
+ type: "text",
3402
+ inputMode: "decimal",
3403
+ prefix: currencySymbol,
3404
+ onNativeChange: (event) => {
3405
+ pendingCaretDigitsAfterRef.current = countDigitsAfterCaret(
3406
+ event.target.value,
3407
+ event.target.selectionStart
3408
+ );
3409
+ onValueChange(
3410
+ parseCurrencyInputValue(event.target.value, {
3411
+ groupSeparator,
3412
+ decimalSeparator
3413
+ })
3414
+ );
3415
+ }
2411
3416
  }
2412
- }
2413
- );
2414
- });
3417
+ );
3418
+ }
3419
+ );
2415
3420
 
2416
3421
  // src/loading/loading.tsx
2417
3422
  import { jsx as jsx22, jsxs as jsxs19 } from "react/jsx-runtime";
@@ -2427,7 +3432,7 @@ function DLoadingOverlay({ label }) {
2427
3432
  }
2428
3433
 
2429
3434
  // src/notification-panel/notification-panel.tsx
2430
- import { useEffect as useEffect9, useRef as useRef8 } from "react";
3435
+ import { useEffect as useEffect9, useRef as useRef9 } from "react";
2431
3436
  import { createPortal as createPortal3 } from "react-dom";
2432
3437
  import { jsx as jsx23, jsxs as jsxs20 } from "react/jsx-runtime";
2433
3438
  var dotClass = {
@@ -2436,7 +3441,7 @@ var dotClass = {
2436
3441
  warning: "bg-[var(--color-warning)]",
2437
3442
  error: "bg-[var(--color-danger)]"
2438
3443
  };
2439
- 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";
3444
+ 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";
2440
3445
  function DNotificationPanel({
2441
3446
  notifications,
2442
3447
  open,
@@ -2454,8 +3459,8 @@ function DNotificationPanel({
2454
3459
  const { t } = useDLocalization();
2455
3460
  const resolvedTitle = title ?? t("notification.title");
2456
3461
  const resolvedEmptyMessage = emptyMessage ?? t("notification.empty");
2457
- const floatingRef = useRef8(null);
2458
- const emptyReference = useRef8(null);
3462
+ const floatingRef = useRef9(null);
3463
+ const emptyReference = useRef9(null);
2459
3464
  const referenceRef = anchorRef ?? emptyReference;
2460
3465
  const hasAnchor = Boolean(anchorRef);
2461
3466
  const { style, positioned } = useFloatingPosition({
@@ -2473,7 +3478,8 @@ function DNotificationPanel({
2473
3478
  if (!open) return;
2474
3479
  const onPointerDown = (event) => {
2475
3480
  const target = event.target;
2476
- if (floatingRef.current?.contains(target) || anchorRef?.current?.contains(target)) return;
3481
+ if (floatingRef.current?.contains(target) || anchorRef?.current?.contains(target))
3482
+ return;
2477
3483
  onClose();
2478
3484
  };
2479
3485
  const onKeyDown = (event) => {
@@ -2491,7 +3497,13 @@ function DNotificationPanel({
2491
3497
  }, [anchorRef, onClose, open]);
2492
3498
  if (!open || typeof document === "undefined") return null;
2493
3499
  const unread = notifications.filter((item) => !item.read).length;
2494
- const fallbackStyle = { position: "fixed", top: 72, right: 24, zIndex: 9999, visibility: "visible" };
3500
+ const fallbackStyle = {
3501
+ position: "fixed",
3502
+ top: 72,
3503
+ right: 24,
3504
+ zIndex: 9999,
3505
+ visibility: "visible"
3506
+ };
2495
3507
  return createPortal3(
2496
3508
  /* @__PURE__ */ jsxs20(
2497
3509
  "div",
@@ -2505,27 +3517,45 @@ function DNotificationPanel({
2505
3517
  "data-scroll-behavior": scrollBehavior,
2506
3518
  style: hasAnchor ? style : fallbackStyle,
2507
3519
  className: cn(
2508
- "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)]",
3520
+ "w-[min(24rem,calc(100vw-16px))] overflow-hidden rounded-(--radius-panel) border border-(--color-border) bg-(--color-surface) shadow-(--shadow-lg)",
2509
3521
  hasAnchor && positioned && "animate-[dropdown-in_150ms_ease-out]",
2510
3522
  className
2511
3523
  ),
2512
3524
  children: [
2513
- /* @__PURE__ */ jsxs20("div", { className: "flex min-h-12 items-center justify-between border-b border-[var(--color-border)] px-4 py-2", children: [
3525
+ /* @__PURE__ */ jsxs20("div", { className: "flex min-h-12 items-center justify-between border-b border-(--color-border) px-4 py-2", children: [
2514
3526
  /* @__PURE__ */ jsxs20("div", { className: "flex min-w-0 items-center gap-2", children: [
2515
- /* @__PURE__ */ jsx23("span", { className: "truncate text-sm font-semibold text-[var(--color-text)]", children: resolvedTitle }),
2516
- unread > 0 ? /* @__PURE__ */ jsx23("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
3527
+ /* @__PURE__ */ jsx23("span", { className: "truncate text-sm font-semibold text-(--color-text)", children: resolvedTitle }),
3528
+ unread > 0 ? /* @__PURE__ */ jsx23("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
2517
3529
  ] }),
2518
3530
  /* @__PURE__ */ jsxs20("div", { className: "flex shrink-0 items-center gap-0.5", children: [
2519
- unread > 0 ? /* @__PURE__ */ jsx23("button", { type: "button", "aria-label": t("notification.markAllRead"), onClick: onMarkAllRead, className: iconButtonClass, children: /* @__PURE__ */ jsx23(CheckIcon, { size: 15 }) }) : null,
2520
- /* @__PURE__ */ jsx23("button", { type: "button", "aria-label": t("notification.close"), onClick: onClose, className: iconButtonClass, children: /* @__PURE__ */ jsx23(XIcon, { size: 15 }) })
3531
+ unread > 0 ? /* @__PURE__ */ jsx23(
3532
+ "button",
3533
+ {
3534
+ type: "button",
3535
+ "aria-label": t("notification.markAllRead"),
3536
+ onClick: onMarkAllRead,
3537
+ className: iconButtonClass,
3538
+ children: /* @__PURE__ */ jsx23(CheckIcon, { size: 15 })
3539
+ }
3540
+ ) : null,
3541
+ /* @__PURE__ */ jsx23(
3542
+ "button",
3543
+ {
3544
+ type: "button",
3545
+ "aria-label": t("notification.close"),
3546
+ onClick: onClose,
3547
+ className: iconButtonClass,
3548
+ children: /* @__PURE__ */ jsx23(XIcon, { size: 15 })
3549
+ }
3550
+ )
2521
3551
  ] })
2522
3552
  ] }),
2523
- /* @__PURE__ */ jsx23("div", { className: "flex max-h-[min(24rem,60vh)] flex-col gap-1.5 overflow-y-auto p-2", children: notifications.length === 0 ? /* @__PURE__ */ jsx23("div", { className: "px-4 py-10 text-center text-sm text-[var(--color-text-muted)]", children: resolvedEmptyMessage }) : notifications.map((item) => /* @__PURE__ */ jsxs20(
3553
+ /* @__PURE__ */ jsx23("div", { className: "flex max-h-[min(24rem,60vh)] flex-col gap-1.5 overflow-y-auto p-2", children: notifications.length === 0 ? /* @__PURE__ */ jsx23("div", { className: "px-4 py-10 text-center text-sm text-(--color-text-muted)", children: resolvedEmptyMessage }) : notifications.map((item) => /* @__PURE__ */ jsxs20(
2524
3554
  "div",
2525
3555
  {
2526
3556
  className: cn(
2527
- "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",
2528
- !item.read && "bg-[var(--color-brand)]/5"
3557
+ "group flex items-start gap-1 rounded-(--radius-menu-item) px-1 py-0.5 transition-colors hover:bg-(--color-surface-muted)/65",
3558
+ !item.read && "bg-(--color-brand)/5"
2529
3559
  ),
2530
3560
  children: [
2531
3561
  /* @__PURE__ */ jsxs20(
@@ -2533,13 +3563,21 @@ function DNotificationPanel({
2533
3563
  {
2534
3564
  type: "button",
2535
3565
  onClick: () => onMarkRead(item.id),
2536
- 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",
3566
+ 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",
2537
3567
  children: [
2538
- /* @__PURE__ */ jsx23("span", { className: cn("mt-1.5 size-2 shrink-0 rounded-full", !item.read ? dotClass[item.type] : "bg-transparent") }),
3568
+ /* @__PURE__ */ jsx23(
3569
+ "span",
3570
+ {
3571
+ className: cn(
3572
+ "mt-1.5 size-2 shrink-0 rounded-full",
3573
+ !item.read ? dotClass[item.type] : "bg-transparent"
3574
+ )
3575
+ }
3576
+ ),
2539
3577
  /* @__PURE__ */ jsxs20("span", { className: "min-w-0 flex-1", children: [
2540
- /* @__PURE__ */ jsx23("span", { className: "block truncate text-sm font-medium text-[var(--color-text)]", children: item.title }),
2541
- /* @__PURE__ */ jsx23("span", { className: "mt-0.5 line-clamp-2 block text-xs leading-5 text-[var(--color-text-muted)]", children: item.message }),
2542
- /* @__PURE__ */ jsx23("span", { className: "mt-1 block text-[10px] text-[var(--color-text-muted)]/70", children: item.createdAt })
3578
+ /* @__PURE__ */ jsx23("span", { className: "block truncate text-sm font-medium text-(--color-text)", children: item.title }),
3579
+ /* @__PURE__ */ jsx23("span", { className: "mt-0.5 line-clamp-2 block text-xs leading-5 text-(--color-text-muted)", children: item.message }),
3580
+ /* @__PURE__ */ jsx23("span", { className: "mt-1 block text-[10px] text-(--color-text-muted)/70", children: item.createdAt })
2543
3581
  ] })
2544
3582
  ]
2545
3583
  }
@@ -2550,7 +3588,7 @@ function DNotificationPanel({
2550
3588
  type: "button",
2551
3589
  "aria-label": t("notification.dismiss", { title: item.title }),
2552
3590
  onClick: () => onDismiss(item.id),
2553
- 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",
3591
+ 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",
2554
3592
  children: /* @__PURE__ */ jsx23(XIcon, { size: 13 })
2555
3593
  }
2556
3594
  )
@@ -2624,7 +3662,17 @@ var getStartOfMonth = (date2) => new Date(date2.getFullYear(), date2.getMonth(),
2624
3662
  var getEndOfMonth = (date2) => new Date(date2.getFullYear(), date2.getMonth() + 1, 0);
2625
3663
  var getStartOfYear = (date2) => new Date(date2.getFullYear(), 0, 1);
2626
3664
  var getEndOfYear = (date2) => new Date(date2.getFullYear(), 11, 31);
2627
- var QUICK_RANGE_TYPES = ["today", "yesterday", "this_week", "last_week", "this_month", "last_month", "this_year", "last_year", "all_time"];
3665
+ var QUICK_RANGE_TYPES = [
3666
+ "today",
3667
+ "yesterday",
3668
+ "this_week",
3669
+ "last_week",
3670
+ "this_month",
3671
+ "last_month",
3672
+ "this_year",
3673
+ "last_year",
3674
+ "all_time"
3675
+ ];
2628
3676
  var QUICK_RANGE_KEYS = {
2629
3677
  today: "rangeDatePicker.today",
2630
3678
  yesterday: "rangeDatePicker.yesterday",
@@ -2644,18 +3692,21 @@ function quickRange(type) {
2644
3692
  date2.setDate(date2.getDate() - 1);
2645
3693
  return { start: date2, end: new Date(date2) };
2646
3694
  }
2647
- if (type === "this_week") return { start: getStartOfWeek(now), end: getEndOfWeek(now) };
3695
+ if (type === "this_week")
3696
+ return { start: getStartOfWeek(now), end: getEndOfWeek(now) };
2648
3697
  if (type === "last_week") {
2649
3698
  const date2 = new Date(now);
2650
3699
  date2.setDate(date2.getDate() - 7);
2651
3700
  return { start: getStartOfWeek(date2), end: getEndOfWeek(date2) };
2652
3701
  }
2653
- if (type === "this_month") return { start: getStartOfMonth(now), end: getEndOfMonth(now) };
3702
+ if (type === "this_month")
3703
+ return { start: getStartOfMonth(now), end: getEndOfMonth(now) };
2654
3704
  if (type === "last_month") {
2655
3705
  const date2 = new Date(now.getFullYear(), now.getMonth() - 1, 1);
2656
3706
  return { start: getStartOfMonth(date2), end: getEndOfMonth(date2) };
2657
3707
  }
2658
- if (type === "this_year") return { start: getStartOfYear(now), end: getEndOfYear(now) };
3708
+ if (type === "this_year")
3709
+ return { start: getStartOfYear(now), end: getEndOfYear(now) };
2659
3710
  if (type === "last_year") {
2660
3711
  const date2 = new Date(now.getFullYear() - 1, 0, 1);
2661
3712
  return { start: getStartOfYear(date2), end: getEndOfYear(date2) };
@@ -2668,27 +3719,83 @@ function getQuickActive(type, start, end) {
2668
3719
  return isSameDate(start, target.start) && isSameDate(end, target.end);
2669
3720
  }
2670
3721
  function ChevronIcon({ direction }) {
2671
- return /* @__PURE__ */ jsx25("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", className: "size-4", children: /* @__PURE__ */ jsx25("path", { d: direction === "left" ? "m15 18-6-6 6-6" : "m9 18 6-6-6-6" }) });
3722
+ return /* @__PURE__ */ jsx25(
3723
+ "svg",
3724
+ {
3725
+ viewBox: "0 0 24 24",
3726
+ fill: "none",
3727
+ stroke: "currentColor",
3728
+ strokeWidth: "2",
3729
+ className: "size-4",
3730
+ children: /* @__PURE__ */ jsx25("path", { d: direction === "left" ? "m15 18-6-6 6-6" : "m9 18 6-6-6-6" })
3731
+ }
3732
+ );
2672
3733
  }
2673
3734
  function CalendarIcon2() {
2674
- return /* @__PURE__ */ jsxs21("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", className: "size-4", children: [
2675
- /* @__PURE__ */ jsx25("rect", { x: "3", y: "5", width: "18", height: "16", rx: "2" }),
2676
- /* @__PURE__ */ jsx25("path", { d: "M16 3v4M8 3v4M3 10h18" })
2677
- ] });
3735
+ return /* @__PURE__ */ jsxs21(
3736
+ "svg",
3737
+ {
3738
+ viewBox: "0 0 24 24",
3739
+ fill: "none",
3740
+ stroke: "currentColor",
3741
+ strokeWidth: "2",
3742
+ className: "size-4",
3743
+ children: [
3744
+ /* @__PURE__ */ jsx25("rect", { x: "3", y: "5", width: "18", height: "16", rx: "2" }),
3745
+ /* @__PURE__ */ jsx25("path", { d: "M16 3v4M8 3v4M3 10h18" })
3746
+ ]
3747
+ }
3748
+ );
2678
3749
  }
2679
3750
  function ChevronDownIcon2({ open }) {
2680
- return /* @__PURE__ */ jsx25("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", className: cn("size-3.5 transition-transform", open && "rotate-180"), children: /* @__PURE__ */ jsx25("path", { d: "m6 9 6 6 6-6" }) });
3751
+ return /* @__PURE__ */ jsx25(
3752
+ "svg",
3753
+ {
3754
+ viewBox: "0 0 24 24",
3755
+ fill: "none",
3756
+ stroke: "currentColor",
3757
+ strokeWidth: "2",
3758
+ className: cn("size-3.5 transition-transform", open && "rotate-180"),
3759
+ children: /* @__PURE__ */ jsx25("path", { d: "m6 9 6 6 6-6" })
3760
+ }
3761
+ );
2681
3762
  }
2682
3763
  function ClearIcon5() {
2683
- return /* @__PURE__ */ jsx25("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", className: "size-3.5", children: /* @__PURE__ */ jsx25("path", { d: "m18 6-12 12M6 6l12 12" }) });
3764
+ return /* @__PURE__ */ jsx25(
3765
+ "svg",
3766
+ {
3767
+ viewBox: "0 0 24 24",
3768
+ fill: "none",
3769
+ stroke: "currentColor",
3770
+ strokeWidth: "2",
3771
+ className: "size-3.5",
3772
+ children: /* @__PURE__ */ jsx25("path", { d: "m18 6-12 12M6 6l12 12" })
3773
+ }
3774
+ );
2684
3775
  }
2685
3776
  function CheckIcon2() {
2686
- return /* @__PURE__ */ jsx25("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", className: "size-3.5", children: /* @__PURE__ */ jsx25("path", { d: "m5 12 4 4L19 6" }) });
3777
+ return /* @__PURE__ */ jsx25(
3778
+ "svg",
3779
+ {
3780
+ viewBox: "0 0 24 24",
3781
+ fill: "none",
3782
+ stroke: "currentColor",
3783
+ strokeWidth: "2",
3784
+ className: "size-3.5",
3785
+ children: /* @__PURE__ */ jsx25("path", { d: "m5 12 4 4L19 6" })
3786
+ }
3787
+ );
2687
3788
  }
2688
- function RangeDropdownContent({ value, onChange }) {
3789
+ function RangeDropdownContent({
3790
+ value,
3791
+ onChange
3792
+ }) {
2689
3793
  const close = useDropdownClose();
2690
3794
  const { locale, t } = useDLocalization();
2691
- const days = useMemo6(() => getLocalizedWeekdayNames(locale, "short"), [locale]);
3795
+ const days = useMemo6(
3796
+ () => getLocalizedWeekdayNames(locale, "short"),
3797
+ [locale]
3798
+ );
2692
3799
  const months = useMemo6(() => getLocalizedMonthNames(locale), [locale]);
2693
3800
  const today = useMemo6(() => /* @__PURE__ */ new Date(), []);
2694
3801
  const selectedStart = useMemo6(() => parseDate2(value?.start), [value?.start]);
@@ -2696,7 +3803,9 @@ function RangeDropdownContent({ value, onChange }) {
2696
3803
  const [tempStart, setTempStart] = useState10(selectedStart);
2697
3804
  const [tempEnd, setTempEnd] = useState10(selectedEnd);
2698
3805
  const [quickType, setQuickType] = useState10(null);
2699
- const [leftMonth, setLeftMonth] = useState10(() => startOfMonth(selectedStart || today));
3806
+ const [leftMonth, setLeftMonth] = useState10(
3807
+ () => startOfMonth(selectedStart || today)
3808
+ );
2700
3809
  const rightMonth = useMemo6(() => addMonth(leftMonth, 1), [leftMonth]);
2701
3810
  const syncTempFromValue = () => {
2702
3811
  const nextStart = parseDate2(value?.start);
@@ -2743,15 +3852,42 @@ function RangeDropdownContent({ value, onChange }) {
2743
3852
  const firstDay = new Date(year, month, 1).getDay();
2744
3853
  return /* @__PURE__ */ jsxs21("div", { className: "min-w-0 flex-1", children: [
2745
3854
  /* @__PURE__ */ jsxs21("div", { className: "mb-2 flex items-center justify-between", children: [
2746
- side === "left" ? /* @__PURE__ */ jsx25("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__ */ jsx25(ChevronIcon, { direction: "left" }) }) : /* @__PURE__ */ jsx25("div", { className: "size-7" }),
2747
- /* @__PURE__ */ jsxs21("span", { className: "text-xs font-semibold text-[var(--color-text)] sm:text-sm", children: [
3855
+ side === "left" ? /* @__PURE__ */ jsx25(
3856
+ "button",
3857
+ {
3858
+ type: "button",
3859
+ "aria-label": t("common.previousMonth"),
3860
+ onClick: () => setLeftMonth((prev) => addMonth(prev, -1)),
3861
+ className: "cursor-pointer flex size-7 items-center justify-center rounded-lg text-(--color-text-muted) hover:bg-(--color-surface-muted)",
3862
+ children: /* @__PURE__ */ jsx25(ChevronIcon, { direction: "left" })
3863
+ }
3864
+ ) : /* @__PURE__ */ jsx25("div", { className: "size-7" }),
3865
+ /* @__PURE__ */ jsxs21("span", { className: "text-xs font-semibold text-(--color-text) sm:text-sm", children: [
2748
3866
  months[month],
2749
3867
  " ",
2750
3868
  year
2751
3869
  ] }),
2752
- side === "right" ? /* @__PURE__ */ jsx25("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__ */ jsx25(ChevronIcon, { direction: "right" }) }) : /* @__PURE__ */ jsx25("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__ */ jsx25(ChevronIcon, { direction: "right" }) })
3870
+ side === "right" ? /* @__PURE__ */ jsx25(
3871
+ "button",
3872
+ {
3873
+ type: "button",
3874
+ "aria-label": t("common.nextMonth"),
3875
+ onClick: () => setLeftMonth((prev) => addMonth(prev, 1)),
3876
+ className: "cursor-pointer flex size-7 items-center justify-center rounded-lg text-(--color-text-muted) hover:bg-(--color-surface-muted)",
3877
+ children: /* @__PURE__ */ jsx25(ChevronIcon, { direction: "right" })
3878
+ }
3879
+ ) : /* @__PURE__ */ jsx25(
3880
+ "button",
3881
+ {
3882
+ type: "button",
3883
+ "aria-label": t("common.nextMonth"),
3884
+ onClick: () => setLeftMonth((prev) => addMonth(prev, 1)),
3885
+ className: "cursor-pointer flex size-7 items-center justify-center rounded-lg text-(--color-text-muted) hover:bg-(--color-surface-muted) sm:invisible",
3886
+ children: /* @__PURE__ */ jsx25(ChevronIcon, { direction: "right" })
3887
+ }
3888
+ )
2753
3889
  ] }),
2754
- /* @__PURE__ */ jsx25("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__ */ jsx25("div", { className: "text-center font-medium", children: day }, `${side}-${day}`)) }),
3890
+ /* @__PURE__ */ jsx25("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__ */ jsx25("div", { className: "text-center font-medium", children: day }, `${side}-${day}`)) }),
2755
3891
  /* @__PURE__ */ jsxs21("div", { className: "grid grid-cols-7 gap-0.5", children: [
2756
3892
  Array.from({ length: firstDay }).map((_, index) => /* @__PURE__ */ jsx25("div", {}, `${side}-empty-${index}`)),
2757
3893
  Array.from({ length: daysInMonth }, (_, index) => {
@@ -2759,9 +3895,26 @@ function RangeDropdownContent({ value, onChange }) {
2759
3895
  const start = isSameDate(date2, tempStart);
2760
3896
  const end = isSameDate(date2, tempEnd);
2761
3897
  const selected = start || end;
2762
- const inRange = Boolean(tempStart && tempEnd && date2 > tempStart && date2 < tempEnd);
3898
+ const inRange = Boolean(
3899
+ tempStart && tempEnd && date2 > tempStart && date2 < tempEnd
3900
+ );
2763
3901
  const isToday = isSameDate(date2, today);
2764
- return /* @__PURE__ */ jsx25("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)}`);
3902
+ return /* @__PURE__ */ jsx25(
3903
+ "button",
3904
+ {
3905
+ type: "button",
3906
+ onClick: () => selectDate(date2),
3907
+ className: cn(
3908
+ "cursor-pointer h-8 rounded-md text-xs transition-colors sm:h-8 sm:text-sm",
3909
+ selected && "bg-(--color-brand) font-semibold text-white",
3910
+ !selected && inRange && "bg-(--color-brand)/10 text-(--color-brand)",
3911
+ !selected && !inRange && "hover:bg-(--color-surface-muted)",
3912
+ !selected && isToday && "ring-1 ring-(--color-brand)/40"
3913
+ ),
3914
+ children: index + 1
3915
+ },
3916
+ `${side}-${formatDate(date2)}`
3917
+ );
2765
3918
  })
2766
3919
  ] })
2767
3920
  ] });
@@ -2770,31 +3923,72 @@ function RangeDropdownContent({ value, onChange }) {
2770
3923
  return /* @__PURE__ */ jsxs21("div", { className: "w-[min(560px,calc(100vw-16px))] p-3", children: [
2771
3924
  /* @__PURE__ */ jsxs21("div", { className: "mb-3", children: [
2772
3925
  /* @__PURE__ */ jsxs21("div", { className: "mb-2 flex items-center justify-between", children: [
2773
- /* @__PURE__ */ jsx25("p", { className: "text-xs font-semibold text-[var(--color-text)]", children: t("rangeDatePicker.quickRange") }),
2774
- /* @__PURE__ */ jsx25("span", { className: "text-[10px] text-[var(--color-text-muted)]", children: t("common.optional") })
3926
+ /* @__PURE__ */ jsx25("p", { className: "text-xs font-semibold text-(--color-text)", children: t("rangeDatePicker.quickRange") }),
3927
+ /* @__PURE__ */ jsx25("span", { className: "text-[10px] text-(--color-text-muted)", children: t("common.optional") })
2775
3928
  ] }),
2776
- /* @__PURE__ */ jsx25("div", { className: "grid grid-cols-3 gap-1 sm:grid-cols-5", children: QUICK_RANGE_TYPES.map((type) => /* @__PURE__ */ jsx25("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)) })
3929
+ /* @__PURE__ */ jsx25("div", { className: "grid grid-cols-3 gap-1 sm:grid-cols-5", children: QUICK_RANGE_TYPES.map((type) => /* @__PURE__ */ jsx25(
3930
+ "button",
3931
+ {
3932
+ type: "button",
3933
+ onClick: () => selectQuick(type),
3934
+ className: cn(
3935
+ "cursor-pointer min-h-8 rounded-lg px-2 py-1.5 text-center text-[11px] font-medium leading-tight transition-colors",
3936
+ 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)"
3937
+ ),
3938
+ children: t(QUICK_RANGE_KEYS[type])
3939
+ },
3940
+ type
3941
+ )) })
2777
3942
  ] }),
2778
- /* @__PURE__ */ jsxs21("div", { className: "grid gap-3 border-t border-[var(--color-border)] pt-3 sm:grid-cols-2", children: [
3943
+ /* @__PURE__ */ jsxs21("div", { className: "grid gap-3 border-t border-(--color-border) pt-3 sm:grid-cols-2", children: [
2779
3944
  renderCalendar(leftMonth, "left"),
2780
3945
  renderCalendar(rightMonth, "right")
2781
3946
  ] }),
2782
- /* @__PURE__ */ jsxs21("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: [
2783
- /* @__PURE__ */ jsx25("div", { className: "min-w-0 truncate text-[11px] text-[var(--color-text-muted)]", children: summary }),
3947
+ /* @__PURE__ */ jsxs21("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: [
3948
+ /* @__PURE__ */ jsx25("div", { className: "min-w-0 truncate text-[11px] text-(--color-text-muted)", children: summary }),
2784
3949
  /* @__PURE__ */ jsxs21("div", { className: "flex shrink-0 items-center justify-end gap-2", children: [
2785
- /* @__PURE__ */ jsx25("button", { type: "button", onClick: () => {
2786
- syncTempFromValue();
2787
- close?.();
2788
- }, 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") }),
2789
- /* @__PURE__ */ jsxs21("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: [
2790
- /* @__PURE__ */ jsx25(CheckIcon2, {}),
2791
- t("common.apply")
2792
- ] })
3950
+ /* @__PURE__ */ jsx25(
3951
+ "button",
3952
+ {
3953
+ type: "button",
3954
+ onClick: () => {
3955
+ syncTempFromValue();
3956
+ close?.();
3957
+ },
3958
+ className: "cursor-pointer h-8 rounded-lg px-3 text-xs font-medium text-(--color-text-muted) hover:bg-(--color-surface-muted)",
3959
+ children: t("common.cancel")
3960
+ }
3961
+ ),
3962
+ /* @__PURE__ */ jsxs21(
3963
+ "button",
3964
+ {
3965
+ type: "button",
3966
+ disabled: quickType !== "all_time" && (!tempStart || !tempEnd),
3967
+ onClick: apply,
3968
+ 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",
3969
+ children: [
3970
+ /* @__PURE__ */ jsx25(CheckIcon2, {}),
3971
+ t("common.apply")
3972
+ ]
3973
+ }
3974
+ )
2793
3975
  ] })
2794
3976
  ] })
2795
3977
  ] });
2796
3978
  }
2797
- function DRangeDatePicker({ label, placeholder, value, size = "md", onChange, error, hint, disabled = false, clearable = true, containerClassName, scrollBehavior = "close" }) {
3979
+ function DRangeDatePicker({
3980
+ label,
3981
+ placeholder,
3982
+ value,
3983
+ size = "md",
3984
+ onChange,
3985
+ error,
3986
+ hint,
3987
+ disabled = false,
3988
+ clearable = true,
3989
+ containerClassName,
3990
+ scrollBehavior = "close"
3991
+ }) {
2798
3992
  const id = useId5();
2799
3993
  const { locale, t } = useDLocalization();
2800
3994
  const months = useMemo6(() => getLocalizedMonthNames(locale), [locale]);
@@ -2803,40 +3997,124 @@ function DRangeDatePicker({ label, placeholder, value, size = "md", onChange, er
2803
3997
  const date2 = parseDate2(raw);
2804
3998
  return date2 ? `${date2.getDate()} ${months[date2.getMonth()]} ${date2.getFullYear()}` : "";
2805
3999
  };
2806
- const displayValue = useMemo6(() => value?.start && value?.end ? `${formatDisplayDate(value.start)} - ${formatDisplayDate(value.end)}` : "", [value?.start, value?.end, months]);
4000
+ const displayValue = useMemo6(
4001
+ () => value?.start && value?.end ? `${formatDisplayDate(value.start)} - ${formatDisplayDate(value.end)}` : "",
4002
+ [value?.start, value?.end, months]
4003
+ );
2807
4004
  const resolvedPlaceholder = placeholder ?? t("rangeDatePicker.placeholder");
2808
- return /* @__PURE__ */ jsxs21("div", { className: cn("flex min-w-0 flex-col gap-1.5", containerClassName), children: [
2809
- label ? /* @__PURE__ */ jsx25("label", { htmlFor: id, className: cn(s.label, "inline-block w-fit font-medium text-[var(--color-text)]"), children: label }) : null,
2810
- /* @__PURE__ */ jsx25(DDropdown, { placement: "bottom-end", contentRole: "dialog", contentPadding: false, contentClassName: "overflow-hidden", scrollBehavior, trigger: ({ open }) => /* @__PURE__ */ jsxs21("div", { className: "relative", children: [
2811
- /* @__PURE__ */ jsxs21("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: [
2812
- /* @__PURE__ */ jsx25("span", { className: "shrink-0 text-[var(--color-text-muted)]", children: /* @__PURE__ */ jsx25(CalendarIcon2, {}) }),
2813
- /* @__PURE__ */ jsx25("span", { className: "min-w-0 flex-1 truncate", children: displayValue || resolvedPlaceholder })
2814
- ] }),
2815
- /* @__PURE__ */ jsxs21("div", { className: cn("absolute top-1/2 flex -translate-y-1/2 items-center gap-1 text-[var(--color-text-muted)]", s.iconRight), children: [
2816
- clearable && displayValue && !disabled ? /* @__PURE__ */ jsx25("button", { type: "button", "aria-label": t("rangeDatePicker.clear"), onMouseDown: (event) => event.preventDefault(), onClick: (event) => {
2817
- event.preventDefault();
2818
- event.stopPropagation();
2819
- onChange?.({ start: void 0, end: void 0 });
2820
- }, className: "rounded-md p-1 hover:bg-[var(--color-surface-muted)]", children: /* @__PURE__ */ jsx25(ClearIcon5, {}) }) : null,
2821
- !disabled ? /* @__PURE__ */ jsx25(ChevronDownIcon2, { open }) : null
2822
- ] })
2823
- ] }), children: /* @__PURE__ */ jsx25(RangeDropdownContent, { value, onChange }) }),
2824
- error ? /* @__PURE__ */ jsx25("p", { className: "text-xs text-[var(--color-danger)]", children: error }) : null,
2825
- !error && hint ? /* @__PURE__ */ jsx25("p", { className: "text-xs text-[var(--color-text-muted)]", children: hint }) : null
2826
- ] });
4005
+ const hasClearButton = clearable && Boolean(displayValue) && !disabled;
4006
+ return /* @__PURE__ */ jsxs21(
4007
+ "div",
4008
+ {
4009
+ className: cn(
4010
+ "flex min-w-0 flex-col items-start gap-1.5",
4011
+ containerClassName
4012
+ ),
4013
+ children: [
4014
+ label ? /* @__PURE__ */ jsx25(
4015
+ "label",
4016
+ {
4017
+ htmlFor: id,
4018
+ className: cn(
4019
+ s.label,
4020
+ "inline-block w-fit font-medium text-(--color-text)"
4021
+ ),
4022
+ children: label
4023
+ }
4024
+ ) : null,
4025
+ /* @__PURE__ */ jsx25(
4026
+ DDropdown,
4027
+ {
4028
+ placement: "bottom-end",
4029
+ contentRole: "dialog",
4030
+ contentPadding: false,
4031
+ contentClassName: "overflow-hidden",
4032
+ scrollBehavior,
4033
+ trigger: ({ open }) => /* @__PURE__ */ jsxs21(
4034
+ "button",
4035
+ {
4036
+ id,
4037
+ type: "button",
4038
+ disabled,
4039
+ "aria-invalid": Boolean(error) || void 0,
4040
+ className: cn(
4041
+ "inline-flex w-82.5 max-w-full items-center gap-2 rounded-lg border bg-(--color-surface) text-left",
4042
+ "focus:border-(--color-brand) focus:outline-none focus:ring-2 focus:ring-(--color-brand)/20",
4043
+ "disabled:cursor-not-allowed disabled:bg-(--color-surface-muted) disabled:opacity-50",
4044
+ s.input,
4045
+ error ? "border-(--color-danger)" : "border-(--color-border)",
4046
+ displayValue ? "text-(--color-text)" : "text-(--color-text-muted)/60"
4047
+ ),
4048
+ children: [
4049
+ /* @__PURE__ */ jsx25("span", { className: "flex size-4 shrink-0 items-center justify-center text-(--color-text-muted)", children: /* @__PURE__ */ jsx25(CalendarIcon2, {}) }),
4050
+ /* @__PURE__ */ jsx25("span", { className: "min-w-0 flex-1 truncate whitespace-nowrap", children: displayValue || resolvedPlaceholder }),
4051
+ clearable && displayValue && !disabled ? /* @__PURE__ */ jsx25(
4052
+ "span",
4053
+ {
4054
+ role: "button",
4055
+ tabIndex: 0,
4056
+ "aria-label": t("rangeDatePicker.clear"),
4057
+ onMouseDown: (event) => {
4058
+ event.preventDefault();
4059
+ event.stopPropagation();
4060
+ },
4061
+ onClick: (event) => {
4062
+ event.preventDefault();
4063
+ event.stopPropagation();
4064
+ onChange?.({
4065
+ start: void 0,
4066
+ end: void 0
4067
+ });
4068
+ },
4069
+ 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",
4070
+ children: /* @__PURE__ */ jsx25(ClearIcon5, {})
4071
+ }
4072
+ ) : null,
4073
+ !disabled ? /* @__PURE__ */ jsx25("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__ */ jsx25(ChevronDownIcon2, { open }) }) : null
4074
+ ]
4075
+ }
4076
+ ),
4077
+ children: /* @__PURE__ */ jsx25(RangeDropdownContent, { value, onChange })
4078
+ }
4079
+ ),
4080
+ error ? /* @__PURE__ */ jsx25("p", { className: "text-xs text-(--color-danger)", children: error }) : null,
4081
+ !error && hint ? /* @__PURE__ */ jsx25("p", { className: "text-xs text-(--color-text-muted)", children: hint }) : null
4082
+ ]
4083
+ }
4084
+ );
2827
4085
  }
2828
4086
 
2829
4087
  // src/search-input/search-input.tsx
2830
- import { useEffect as useEffect11, useRef as useRef9, useState as useState11 } from "react";
4088
+ import { useEffect as useEffect11, useRef as useRef10, useState as useState11 } from "react";
2831
4089
  import { jsx as jsx26, jsxs as jsxs22 } from "react/jsx-runtime";
2832
4090
  function SearchIcon2() {
2833
- return /* @__PURE__ */ jsxs22("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", className: "size-4", children: [
2834
- /* @__PURE__ */ jsx26("circle", { cx: "11", cy: "11", r: "7" }),
2835
- /* @__PURE__ */ jsx26("path", { d: "m20 20-4-4" })
2836
- ] });
4091
+ return /* @__PURE__ */ jsxs22(
4092
+ "svg",
4093
+ {
4094
+ viewBox: "0 0 24 24",
4095
+ fill: "none",
4096
+ stroke: "currentColor",
4097
+ strokeWidth: "2",
4098
+ className: "size-3.5",
4099
+ children: [
4100
+ /* @__PURE__ */ jsx26("circle", { cx: "11", cy: "11", r: "7" }),
4101
+ /* @__PURE__ */ jsx26("path", { d: "m20 20-4-4" })
4102
+ ]
4103
+ }
4104
+ );
2837
4105
  }
2838
4106
  function ClearIcon6() {
2839
- return /* @__PURE__ */ jsx26("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", className: "size-3.5", children: /* @__PURE__ */ jsx26("path", { d: "m18 6-12 12M6 6l12 12" }) });
4107
+ return /* @__PURE__ */ jsx26(
4108
+ "svg",
4109
+ {
4110
+ viewBox: "0 0 24 24",
4111
+ fill: "none",
4112
+ stroke: "currentColor",
4113
+ strokeWidth: "2",
4114
+ className: "size-3.5",
4115
+ children: /* @__PURE__ */ jsx26("path", { d: "m18 6-12 12M6 6l12 12" })
4116
+ }
4117
+ );
2840
4118
  }
2841
4119
  function DSearchInput({
2842
4120
  value,
@@ -2849,11 +4127,11 @@ function DSearchInput({
2849
4127
  }) {
2850
4128
  const { t } = useDLocalization();
2851
4129
  const resolvedPlaceholder = placeholder ?? t("searchInput.placeholder");
2852
- const wrapperRef = useRef9(null);
2853
- const desktopInputRef = useRef9(null);
2854
- const debounceRef = useRef9(null);
2855
- const mountedRef = useRef9(false);
2856
- const lastEmittedRef = useRef9(value);
4130
+ const wrapperRef = useRef10(null);
4131
+ const desktopInputRef = useRef10(null);
4132
+ const debounceRef = useRef10(null);
4133
+ const mountedRef = useRef10(false);
4134
+ const lastEmittedRef = useRef10(value);
2857
4135
  const [active, setActive] = useState11(Boolean(value));
2858
4136
  const [localValue, setLocalValue] = useState11(value);
2859
4137
  useEffect11(() => {
@@ -2884,7 +4162,8 @@ function DSearchInput({
2884
4162
  useEffect11(() => {
2885
4163
  const handleClickOutside = (event) => {
2886
4164
  if (!wrapperRef.current) return;
2887
- if (!wrapperRef.current.contains(event.target) && !localValue) setActive(false);
4165
+ if (!wrapperRef.current.contains(event.target) && !localValue)
4166
+ setActive(false);
2888
4167
  };
2889
4168
  document.addEventListener("mousedown", handleClickOutside);
2890
4169
  return () => document.removeEventListener("mousedown", handleClickOutside);
@@ -2907,10 +4186,14 @@ function DSearchInput({
2907
4186
  {
2908
4187
  ref: wrapperRef,
2909
4188
  "data-ds-component": "search-input",
2910
- className: cn("w-full sm:w-auto", align === "right" ? "sm:mr-3" : "sm:ml-0", className),
4189
+ className: cn(
4190
+ "w-full sm:w-auto",
4191
+ align === "right" ? "sm:mr-3" : "sm:ml-0",
4192
+ className
4193
+ ),
2911
4194
  children: [
2912
4195
  /* @__PURE__ */ jsxs22("div", { className: "relative block w-full sm:hidden", children: [
2913
- /* @__PURE__ */ jsx26("span", { className: "pointer-events-none absolute left-3 top-1/2 -translate-y-1/2 text-[var(--color-text-muted)]", children: /* @__PURE__ */ jsx26(SearchIcon2, {}) }),
4196
+ /* @__PURE__ */ jsx26("span", { className: "pointer-events-none absolute left-3 top-1/2 -translate-y-1/2 text-(--color-text-muted)", children: /* @__PURE__ */ jsx26(SearchIcon2, {}) }),
2914
4197
  /* @__PURE__ */ jsx26(
2915
4198
  "input",
2916
4199
  {
@@ -2921,7 +4204,7 @@ function DSearchInput({
2921
4204
  if (event.target.value) setActive(true);
2922
4205
  },
2923
4206
  placeholder: resolvedPlaceholder,
2924
- 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"
4207
+ 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"
2925
4208
  }
2926
4209
  ),
2927
4210
  localValue ? /* @__PURE__ */ jsx26(
@@ -2930,7 +4213,7 @@ function DSearchInput({
2930
4213
  type: "button",
2931
4214
  "aria-label": t("searchInput.clear"),
2932
4215
  onClick: clearSearch,
2933
- 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)]",
4216
+ 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",
2934
4217
  children: /* @__PURE__ */ jsx26(ClearIcon6, {})
2935
4218
  }
2936
4219
  ) : null
@@ -2938,18 +4221,30 @@ function DSearchInput({
2938
4221
  /* @__PURE__ */ jsx26(
2939
4222
  "div",
2940
4223
  {
2941
- className: cn("relative hidden items-center transition-[width] duration-200 ease-out sm:flex", align === "right" ? "justify-end" : "justify-start"),
4224
+ className: cn(
4225
+ "relative hidden items-center transition-[width] duration-200 ease-out sm:flex",
4226
+ align === "right" ? "justify-end" : "justify-start"
4227
+ ),
2942
4228
  style: { width: active ? expandedWidth : "44px" },
2943
4229
  children: /* @__PURE__ */ jsxs22(
2944
4230
  "div",
2945
4231
  {
2946
4232
  className: cn(
2947
- "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",
2948
- active ? "cursor-text" : "cursor-pointer hover:bg-[var(--color-surface-muted)]"
4233
+ "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",
4234
+ active ? "cursor-text" : "cursor-pointer hover:bg-(--color-surface-muted)"
2949
4235
  ),
2950
4236
  onClick: () => setActive(true),
2951
4237
  children: [
2952
- /* @__PURE__ */ jsx26("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__ */ jsx26(SearchIcon2, {}) }),
4238
+ /* @__PURE__ */ jsx26(
4239
+ "span",
4240
+ {
4241
+ className: cn(
4242
+ "pointer-events-none absolute top-1/2 -translate-y-1/2 text-(--color-text-muted) transition-all duration-200 ease-out",
4243
+ active ? "left-3" : "left-1/2 -translate-x-1/2"
4244
+ ),
4245
+ children: /* @__PURE__ */ jsx26(SearchIcon2, {})
4246
+ }
4247
+ ),
2953
4248
  /* @__PURE__ */ jsx26(
2954
4249
  "input",
2955
4250
  {
@@ -2965,7 +4260,7 @@ function DSearchInput({
2965
4260
  },
2966
4261
  placeholder: resolvedPlaceholder,
2967
4262
  className: cn(
2968
- "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",
4263
+ "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",
2969
4264
  active ? "opacity-100" : "pointer-events-none opacity-0"
2970
4265
  )
2971
4266
  }
@@ -2980,7 +4275,7 @@ function DSearchInput({
2980
4275
  event.stopPropagation();
2981
4276
  clearSearch();
2982
4277
  },
2983
- 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)]",
4278
+ 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",
2984
4279
  children: /* @__PURE__ */ jsx26(ClearIcon6, {})
2985
4280
  }
2986
4281
  ) : null
@@ -3002,192 +4297,356 @@ import {
3002
4297
  useEffect as useEffect12,
3003
4298
  useId as useId6,
3004
4299
  useMemo as useMemo7,
3005
- useRef as useRef10,
4300
+ useRef as useRef11,
3006
4301
  useState as useState12
3007
4302
  } from "react";
3008
4303
  import { jsx as jsx27, jsxs as jsxs23 } from "react/jsx-runtime";
3009
4304
  function ChevronDownIcon3({ open }) {
3010
- return /* @__PURE__ */ jsx27("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__ */ jsx27("path", { d: "m6 9 6 6 6-6" }) });
4305
+ return /* @__PURE__ */ jsx27(
4306
+ "svg",
4307
+ {
4308
+ viewBox: "0 0 24 24",
4309
+ fill: "none",
4310
+ stroke: "currentColor",
4311
+ strokeWidth: "2",
4312
+ className: cn("size-3.5 transition-transform", open && "rotate-180"),
4313
+ "aria-hidden": "true",
4314
+ children: /* @__PURE__ */ jsx27("path", { d: "m6 9 6 6 6-6" })
4315
+ }
4316
+ );
3011
4317
  }
3012
4318
  function ClearIcon7() {
3013
- return /* @__PURE__ */ jsx27("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", className: "size-3.5", children: /* @__PURE__ */ jsx27("path", { d: "m18 6-12 12M6 6l12 12" }) });
4319
+ return /* @__PURE__ */ jsx27(
4320
+ "svg",
4321
+ {
4322
+ viewBox: "0 0 24 24",
4323
+ fill: "none",
4324
+ stroke: "currentColor",
4325
+ strokeWidth: "2",
4326
+ className: "size-3.5",
4327
+ children: /* @__PURE__ */ jsx27("path", { d: "m18 6-12 12M6 6l12 12" })
4328
+ }
4329
+ );
3014
4330
  }
3015
4331
  function selectOptionsFromChildren(children) {
3016
4332
  return Children.toArray(children).flatMap((child) => {
3017
- if (!isValidElement(child)) return [];
4333
+ if (!isValidElement(child))
4334
+ return [];
3018
4335
  if (child.type !== "option" || child.props.value === void 0) return [];
3019
- return [{ value: child.props.value, label: child.props.children, ...child.props.disabled === void 0 ? {} : { disabled: child.props.disabled } }];
4336
+ return [
4337
+ {
4338
+ value: child.props.value,
4339
+ label: child.props.children,
4340
+ ...child.props.disabled === void 0 ? {} : { disabled: child.props.disabled }
4341
+ }
4342
+ ];
3020
4343
  });
3021
4344
  }
3022
4345
  function sameValue2(left, right) {
3023
4346
  return String(left ?? "") === String(right ?? "");
3024
4347
  }
3025
- var DSelect = forwardRef4(function DSelect2({
3026
- className,
3027
- children,
3028
- label,
3029
- hint,
3030
- error,
3031
- containerClassName,
3032
- id: providedId,
3033
- options,
3034
- placeholder,
3035
- clearable = true,
3036
- searchable = false,
3037
- loading = false,
3038
- emptyMessage,
3039
- asyncErrorMessage,
3040
- fetchOptions,
3041
- refetchKey,
3042
- onFetchError,
3043
- onValueChange,
3044
- onChange,
3045
- value,
3046
- defaultValue = null,
3047
- disabled = false,
3048
- size = "md",
3049
- debounceMs = 300,
3050
- scrollBehavior = "reposition",
3051
- ...props
3052
- }, ref) {
3053
- const generatedId = useId6();
3054
- const id = providedId ?? generatedId;
3055
- const { t } = useDLocalization();
3056
- const s = INPUT_SIZE_STYLES[size];
3057
- const requestIdRef = useRef10(0);
3058
- const resolveRequestIdRef = useRef10(0);
3059
- const [query, setQuery] = useState12("");
3060
- const [activeIndex, setActiveIndex] = useState12(0);
3061
- const [isOpen, setOpen] = useState12(false);
3062
- const [internalValue, setInternalValue] = useState12(defaultValue);
3063
- const [resolvedAsyncSelection, setResolvedAsyncSelection] = useState12(null);
3064
- const [asyncOptions, setAsyncOptions] = useState12([]);
3065
- const [isFetching, setFetching] = useState12(false);
3066
- const [fetchError, setFetchError] = useState12(null);
3067
- const selectedValue = value === void 0 ? internalValue : value;
3068
- const resolvedPlaceholder = placeholder ?? t("select.placeholder");
3069
- const resolvedEmptyMessage = emptyMessage ?? t("select.empty");
3070
- const resolvedAsyncErrorMessage = asyncErrorMessage ?? t("select.asyncError");
3071
- const staticOptions = useMemo7(() => options?.slice() ?? selectOptionsFromChildren(children), [children, options]);
3072
- const isAsync = Boolean(fetchOptions);
3073
- const sourceOptions = isAsync ? asyncOptions : staticOptions;
3074
- const filteredOptions = useMemo7(
3075
- () => !isAsync && searchable && query ? sourceOptions.filter((option) => String(option.label).toLocaleLowerCase().includes(query.toLocaleLowerCase())) : sourceOptions,
3076
- [isAsync, query, searchable, sourceOptions]
3077
- );
3078
- const selected = staticOptions.find((option) => sameValue2(option.value, selectedValue)) ?? (sameValue2(resolvedAsyncSelection?.value, selectedValue) ? resolvedAsyncSelection : null);
3079
- const showClear = Boolean(clearable && selected && !disabled);
3080
- useEffect12(() => {
3081
- if (!isAsync || !fetchOptions || !isOpen) return;
3082
- const requestId = ++requestIdRef.current;
3083
- const timeout = window.setTimeout(() => {
3084
- setFetching(true);
3085
- setFetchError(null);
3086
- void fetchOptions(query).then((result) => {
3087
- if (requestId === requestIdRef.current) setAsyncOptions(result);
3088
- }).catch((nextError) => {
3089
- if (requestId !== requestIdRef.current) return;
3090
- setFetchError(nextError);
3091
- onFetchError?.(nextError);
3092
- }).finally(() => {
3093
- if (requestId === requestIdRef.current) setFetching(false);
3094
- });
3095
- }, debounceMs);
3096
- return () => window.clearTimeout(timeout);
3097
- }, [debounceMs, fetchOptions, isAsync, isOpen, onFetchError, query, refetchKey]);
3098
- useEffect12(() => {
3099
- if (!isAsync || !fetchOptions || selectedValue == null || selectedValue === "" || sameValue2(resolvedAsyncSelection?.value, selectedValue)) return;
3100
- const requestId = ++resolveRequestIdRef.current;
3101
- void fetchOptions("").then((result) => {
3102
- if (requestId !== resolveRequestIdRef.current) return;
3103
- const found = result.find((option) => sameValue2(option.value, selectedValue));
3104
- if (found) setResolvedAsyncSelection(found);
3105
- }).catch((nextError) => onFetchError?.(nextError));
3106
- }, [fetchOptions, isAsync, onFetchError, refetchKey, resolvedAsyncSelection?.value, selectedValue]);
3107
- const selectedIndex = () => {
3108
- const index = filteredOptions.findIndex((option) => sameValue2(option.value, selectedValue));
3109
- return index >= 0 ? index : 0;
3110
- };
3111
- const choose = (option) => {
3112
- if (value === void 0) setInternalValue(option.value);
3113
- setResolvedAsyncSelection(option);
3114
- onValueChange?.(option.value);
3115
- onChange?.(option.value);
3116
- setOpen(false);
3117
- setQuery("");
3118
- };
3119
- const clear = (event) => {
3120
- event.preventDefault();
3121
- event.stopPropagation();
3122
- if (value === void 0) setInternalValue(null);
3123
- setResolvedAsyncSelection(null);
3124
- onValueChange?.(null);
3125
- onChange?.(null);
3126
- setQuery("");
3127
- };
3128
- const handleTriggerKeyDown = (event) => {
3129
- if (event.key === "Escape") {
4348
+ var DSelect = forwardRef4(
4349
+ function DSelect2({
4350
+ className,
4351
+ children,
4352
+ label,
4353
+ hint,
4354
+ error,
4355
+ containerClassName,
4356
+ id: providedId,
4357
+ options,
4358
+ placeholder,
4359
+ clearable = true,
4360
+ searchable = false,
4361
+ loading = false,
4362
+ emptyMessage,
4363
+ asyncErrorMessage,
4364
+ fetchOptions,
4365
+ refetchKey,
4366
+ onFetchError,
4367
+ onValueChange,
4368
+ onChange,
4369
+ value,
4370
+ defaultValue = null,
4371
+ disabled = false,
4372
+ size = "md",
4373
+ debounceMs = 300,
4374
+ scrollBehavior = "reposition",
4375
+ ...props
4376
+ }, ref) {
4377
+ const generatedId = useId6();
4378
+ const id = providedId ?? generatedId;
4379
+ const { t } = useDLocalization();
4380
+ const s = INPUT_SIZE_STYLES[size];
4381
+ const requestIdRef = useRef11(0);
4382
+ const resolveRequestIdRef = useRef11(0);
4383
+ const [query, setQuery] = useState12("");
4384
+ const [activeIndex, setActiveIndex] = useState12(0);
4385
+ const [isOpen, setOpen] = useState12(false);
4386
+ const [internalValue, setInternalValue] = useState12(
4387
+ defaultValue
4388
+ );
4389
+ const [resolvedAsyncSelection, setResolvedAsyncSelection] = useState12(null);
4390
+ const [asyncOptions, setAsyncOptions] = useState12(
4391
+ []
4392
+ );
4393
+ const [isFetching, setFetching] = useState12(false);
4394
+ const [fetchError, setFetchError] = useState12(null);
4395
+ const selectedValue = value === void 0 ? internalValue : value;
4396
+ const resolvedPlaceholder = placeholder ?? t("select.placeholder");
4397
+ const resolvedEmptyMessage = emptyMessage ?? t("select.empty");
4398
+ const resolvedAsyncErrorMessage = asyncErrorMessage ?? t("select.asyncError");
4399
+ const staticOptions = useMemo7(
4400
+ () => options?.slice() ?? selectOptionsFromChildren(children),
4401
+ [children, options]
4402
+ );
4403
+ const isAsync = Boolean(fetchOptions);
4404
+ const sourceOptions = isAsync ? asyncOptions : staticOptions;
4405
+ const filteredOptions = useMemo7(
4406
+ () => !isAsync && searchable && query ? sourceOptions.filter(
4407
+ (option) => String(option.label).toLocaleLowerCase().includes(query.toLocaleLowerCase())
4408
+ ) : sourceOptions,
4409
+ [isAsync, query, searchable, sourceOptions]
4410
+ );
4411
+ const selected = staticOptions.find((option) => sameValue2(option.value, selectedValue)) ?? (sameValue2(resolvedAsyncSelection?.value, selectedValue) ? resolvedAsyncSelection : null);
4412
+ const showClear = Boolean(clearable && selected && !disabled);
4413
+ useEffect12(() => {
4414
+ if (!isAsync || !fetchOptions || !isOpen) return;
4415
+ const requestId = ++requestIdRef.current;
4416
+ const timeout = window.setTimeout(() => {
4417
+ setFetching(true);
4418
+ setFetchError(null);
4419
+ void fetchOptions(query).then((result) => {
4420
+ if (requestId === requestIdRef.current) setAsyncOptions(result);
4421
+ }).catch((nextError) => {
4422
+ if (requestId !== requestIdRef.current) return;
4423
+ setFetchError(nextError);
4424
+ onFetchError?.(nextError);
4425
+ }).finally(() => {
4426
+ if (requestId === requestIdRef.current) setFetching(false);
4427
+ });
4428
+ }, debounceMs);
4429
+ return () => window.clearTimeout(timeout);
4430
+ }, [
4431
+ debounceMs,
4432
+ fetchOptions,
4433
+ isAsync,
4434
+ isOpen,
4435
+ onFetchError,
4436
+ query,
4437
+ refetchKey
4438
+ ]);
4439
+ useEffect12(() => {
4440
+ if (!isAsync || !fetchOptions || selectedValue == null || selectedValue === "" || sameValue2(resolvedAsyncSelection?.value, selectedValue))
4441
+ return;
4442
+ const requestId = ++resolveRequestIdRef.current;
4443
+ void fetchOptions("").then((result) => {
4444
+ if (requestId !== resolveRequestIdRef.current) return;
4445
+ const found = result.find(
4446
+ (option) => sameValue2(option.value, selectedValue)
4447
+ );
4448
+ if (found) setResolvedAsyncSelection(found);
4449
+ }).catch((nextError) => onFetchError?.(nextError));
4450
+ }, [
4451
+ fetchOptions,
4452
+ isAsync,
4453
+ onFetchError,
4454
+ refetchKey,
4455
+ resolvedAsyncSelection?.value,
4456
+ selectedValue
4457
+ ]);
4458
+ const selectedIndex = () => {
4459
+ const index = filteredOptions.findIndex(
4460
+ (option) => sameValue2(option.value, selectedValue)
4461
+ );
4462
+ return index >= 0 ? index : 0;
4463
+ };
4464
+ const choose = (option) => {
4465
+ if (value === void 0) setInternalValue(option.value);
4466
+ setResolvedAsyncSelection(option);
4467
+ onValueChange?.(option.value);
4468
+ onChange?.(option.value);
3130
4469
  setOpen(false);
3131
4470
  setQuery("");
3132
- return;
3133
- }
3134
- if (event.key === "ArrowDown" || event.key === "ArrowUp") {
4471
+ };
4472
+ const clear = (event) => {
3135
4473
  event.preventDefault();
3136
- const count = filteredOptions.length || 1;
3137
- if (!isOpen) {
3138
- const start = selectedIndex();
3139
- setOpen(true);
3140
- setActiveIndex(event.key === "ArrowDown" ? (start + 1) % count : (start - 1 + count) % count);
4474
+ event.stopPropagation();
4475
+ if (value === void 0) setInternalValue(null);
4476
+ setResolvedAsyncSelection(null);
4477
+ onValueChange?.(null);
4478
+ onChange?.(null);
4479
+ setQuery("");
4480
+ };
4481
+ const handleTriggerKeyDown = (event) => {
4482
+ if (event.key === "Escape") {
4483
+ setOpen(false);
4484
+ setQuery("");
3141
4485
  return;
3142
4486
  }
3143
- setActiveIndex((index) => event.key === "ArrowDown" ? (index + 1) % count : (index - 1 + count) % count);
3144
- return;
3145
- }
3146
- if (event.key === "Enter" || event.key === " ") {
3147
- event.preventDefault();
3148
- const active = filteredOptions[activeIndex];
3149
- if (isOpen && active && !active.disabled) choose(active);
3150
- else {
3151
- setActiveIndex(selectedIndex());
3152
- setOpen(true);
4487
+ if (event.key === "ArrowDown" || event.key === "ArrowUp") {
4488
+ event.preventDefault();
4489
+ const count = filteredOptions.length || 1;
4490
+ if (!isOpen) {
4491
+ const start = selectedIndex();
4492
+ setOpen(true);
4493
+ setActiveIndex(
4494
+ event.key === "ArrowDown" ? (start + 1) % count : (start - 1 + count) % count
4495
+ );
4496
+ return;
4497
+ }
4498
+ setActiveIndex(
4499
+ (index) => event.key === "ArrowDown" ? (index + 1) % count : (index - 1 + count) % count
4500
+ );
4501
+ return;
3153
4502
  }
3154
- }
3155
- };
3156
- return /* @__PURE__ */ jsxs23("div", { "data-ds-component": "select", className: cn("flex min-w-0 flex-col gap-1.5", containerClassName), children: [
3157
- label ? /* @__PURE__ */ jsx27("label", { htmlFor: id, className: cn(s.label, "inline-block w-fit font-medium text-[var(--color-text)]"), children: label }) : null,
3158
- /* @__PURE__ */ jsx27(DDropdown, { matchWidth: true, open: isOpen, onOpenChange: (next) => {
3159
- setOpen(next);
3160
- if (next && !query) setActiveIndex(selectedIndex());
3161
- }, contentRole: "listbox", contentPadding: false, contentClassName: "overflow-hidden", scrollBehavior, onClose: () => {
3162
- setOpen(false);
3163
- setQuery("");
3164
- }, trigger: ({ open }) => /* @__PURE__ */ jsxs23("div", { className: "relative", children: [
3165
- /* @__PURE__ */ jsx27("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__ */ jsx27("span", { className: "min-w-0 flex-1 truncate", children: selected ? selected.label : resolvedPlaceholder }) }),
3166
- /* @__PURE__ */ jsxs23("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: [
3167
- showClear ? /* @__PURE__ */ jsx27("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__ */ jsx27(ClearIcon7, {}) }) : null,
3168
- !disabled ? /* @__PURE__ */ jsx27(ChevronDownIcon3, { open }) : null
3169
- ] })
3170
- ] }), children: /* @__PURE__ */ jsxs23("div", { id: `${id}-listbox`, className: "max-h-60 overflow-hidden", children: [
3171
- searchable ? /* @__PURE__ */ jsx27("div", { className: "border-b border-[var(--color-border)] p-1.5", children: /* @__PURE__ */ jsx27("input", { autoFocus: true, value: query, onChange: (event) => {
3172
- setQuery(event.target.value);
3173
- setActiveIndex(0);
3174
- }, 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,
3175
- /* @__PURE__ */ jsx27("div", { className: "max-h-48 space-y-0.5 overflow-y-auto p-1.5", children: loading || isFetching ? /* @__PURE__ */ jsx27("p", { className: "px-3 py-2 text-sm text-[var(--color-text-muted)]", children: t("select.loading") }) : fetchError ? /* @__PURE__ */ jsx27("p", { className: "px-3 py-2 text-sm text-[var(--color-danger)]", children: resolvedAsyncErrorMessage }) : filteredOptions.length === 0 ? /* @__PURE__ */ jsx27("p", { className: "px-3 py-2 text-sm text-[var(--color-text-muted)]", children: resolvedEmptyMessage }) : filteredOptions.map((option, index) => {
3176
- const isSelected = sameValue2(option.value, selectedValue);
3177
- return /* @__PURE__ */ jsx27("button", { type: "button", role: "option", "aria-selected": isSelected, disabled: option.disabled, onMouseEnter: () => setActiveIndex(index), onMouseDown: (event) => event.preventDefault(), onClick: (event) => {
3178
- event.stopPropagation();
3179
- if (!option.disabled) choose(option);
3180
- }, 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));
3181
- }) })
3182
- ] }) }),
3183
- error ? /* @__PURE__ */ jsx27("p", { className: "text-xs text-[var(--color-danger)]", children: error }) : null,
3184
- !error && hint ? /* @__PURE__ */ jsx27("p", { className: "text-xs text-[var(--color-text-muted)]", children: hint }) : null
3185
- ] });
3186
- });
4503
+ if (event.key === "Enter" || event.key === " ") {
4504
+ event.preventDefault();
4505
+ const active = filteredOptions[activeIndex];
4506
+ if (isOpen && active && !active.disabled) choose(active);
4507
+ else {
4508
+ setActiveIndex(selectedIndex());
4509
+ setOpen(true);
4510
+ }
4511
+ }
4512
+ };
4513
+ return /* @__PURE__ */ jsxs23(
4514
+ "div",
4515
+ {
4516
+ "data-ds-component": "select",
4517
+ className: cn("flex min-w-0 flex-col gap-1.5", containerClassName),
4518
+ children: [
4519
+ label ? /* @__PURE__ */ jsx27(
4520
+ "label",
4521
+ {
4522
+ htmlFor: id,
4523
+ className: cn(
4524
+ s.label,
4525
+ "inline-block w-fit font-medium text-(--color-text)"
4526
+ ),
4527
+ children: label
4528
+ }
4529
+ ) : null,
4530
+ /* @__PURE__ */ jsx27(
4531
+ DDropdown,
4532
+ {
4533
+ matchWidth: true,
4534
+ open: isOpen,
4535
+ onOpenChange: (next) => {
4536
+ setOpen(next);
4537
+ if (next && !query) setActiveIndex(selectedIndex());
4538
+ },
4539
+ contentRole: "listbox",
4540
+ contentPadding: false,
4541
+ contentClassName: "overflow-hidden",
4542
+ scrollBehavior,
4543
+ onClose: () => {
4544
+ setOpen(false);
4545
+ setQuery("");
4546
+ },
4547
+ trigger: ({ open }) => /* @__PURE__ */ jsxs23("div", { className: "relative", children: [
4548
+ /* @__PURE__ */ jsx27(
4549
+ "button",
4550
+ {
4551
+ ...props,
4552
+ ref,
4553
+ id,
4554
+ type: "button",
4555
+ disabled,
4556
+ "aria-invalid": Boolean(error) || void 0,
4557
+ "aria-haspopup": "listbox",
4558
+ "aria-expanded": open,
4559
+ "aria-controls": `${id}-listbox`,
4560
+ onKeyDown: handleTriggerKeyDown,
4561
+ className: cn(
4562
+ "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",
4563
+ s.input,
4564
+ error ? "border-(--color-danger)" : "border-(--color-border)",
4565
+ selected ? "text-(--color-text)" : "text-(--color-text-muted)/60",
4566
+ showClear ? size === "sm" ? "pr-14" : "pr-16" : "pr-10",
4567
+ className
4568
+ ),
4569
+ children: /* @__PURE__ */ jsx27("span", { className: "min-w-0 flex-1 truncate", children: selected ? selected.label : resolvedPlaceholder })
4570
+ }
4571
+ ),
4572
+ /* @__PURE__ */ jsxs23(
4573
+ "div",
4574
+ {
4575
+ className: cn(
4576
+ "absolute top-1/2 flex -translate-y-1/2 items-center gap-1.5 text-(--color-text-muted)",
4577
+ size === "sm" ? "right-2" : "right-2.5"
4578
+ ),
4579
+ children: [
4580
+ showClear ? /* @__PURE__ */ jsx27(
4581
+ "span",
4582
+ {
4583
+ role: "button",
4584
+ tabIndex: -1,
4585
+ "aria-label": t("select.clear"),
4586
+ onMouseDown: (event) => event.preventDefault(),
4587
+ onClick: clear,
4588
+ 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",
4589
+ children: /* @__PURE__ */ jsx27(ClearIcon7, {})
4590
+ }
4591
+ ) : null,
4592
+ !disabled ? /* @__PURE__ */ jsx27(ChevronDownIcon3, { open }) : null
4593
+ ]
4594
+ }
4595
+ )
4596
+ ] }),
4597
+ children: /* @__PURE__ */ jsxs23("div", { id: `${id}-listbox`, className: "max-h-60 overflow-hidden", children: [
4598
+ searchable ? /* @__PURE__ */ jsx27("div", { className: "border-b border-(--color-border) p-1.5", children: /* @__PURE__ */ jsx27(
4599
+ "input",
4600
+ {
4601
+ autoFocus: true,
4602
+ value: query,
4603
+ onChange: (event) => {
4604
+ setQuery(event.target.value);
4605
+ setActiveIndex(0);
4606
+ },
4607
+ placeholder: t("select.searchPlaceholder"),
4608
+ 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"
4609
+ }
4610
+ ) }) : null,
4611
+ /* @__PURE__ */ jsx27("div", { className: "max-h-48 space-y-0.5 overflow-y-auto p-1.5", children: loading || isFetching ? /* @__PURE__ */ jsx27("p", { className: "px-3 py-2 text-sm text-(--color-text-muted)", children: t("select.loading") }) : fetchError ? /* @__PURE__ */ jsx27("p", { className: "px-3 py-2 text-sm text-(--color-danger)", children: resolvedAsyncErrorMessage }) : filteredOptions.length === 0 ? /* @__PURE__ */ jsx27("p", { className: "px-3 py-2 text-sm text-(--color-text-muted)", children: resolvedEmptyMessage }) : filteredOptions.map((option, index) => {
4612
+ const isSelected = sameValue2(option.value, selectedValue);
4613
+ return /* @__PURE__ */ jsx27(
4614
+ "button",
4615
+ {
4616
+ type: "button",
4617
+ role: "option",
4618
+ "aria-selected": isSelected,
4619
+ disabled: option.disabled,
4620
+ onMouseEnter: () => setActiveIndex(index),
4621
+ onMouseDown: (event) => event.preventDefault(),
4622
+ onClick: (event) => {
4623
+ event.stopPropagation();
4624
+ if (!option.disabled) choose(option);
4625
+ },
4626
+ className: cn(
4627
+ "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",
4628
+ isSelected && "bg-(--color-brand)/10 font-medium text-(--color-brand)",
4629
+ index === activeIndex && !isSelected && "bg-(--color-surface-muted)"
4630
+ ),
4631
+ children: option.label
4632
+ },
4633
+ String(option.value)
4634
+ );
4635
+ }) })
4636
+ ] })
4637
+ }
4638
+ ),
4639
+ error ? /* @__PURE__ */ jsx27("p", { className: "text-xs text-(--color-danger)", children: error }) : null,
4640
+ !error && hint ? /* @__PURE__ */ jsx27("p", { className: "text-xs text-(--color-text-muted)", children: hint }) : null
4641
+ ]
4642
+ }
4643
+ );
4644
+ }
4645
+ );
3187
4646
  DSelect.displayName = "DSelect";
3188
4647
 
3189
4648
  // src/select-filter/select-filter.tsx
3190
- import { useId as useId7, useMemo as useMemo8, useRef as useRef11, useState as useState13 } from "react";
4649
+ import { useId as useId7, useMemo as useMemo8, useRef as useRef12, useState as useState13 } from "react";
3191
4650
  import { jsx as jsx28, jsxs as jsxs24 } from "react/jsx-runtime";
3192
4651
  function ClearIcon8() {
3193
4652
  return /* @__PURE__ */ jsx28("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", className: "size-3.5", children: /* @__PURE__ */ jsx28("path", { d: "m18 6-12 12M6 6l12 12" }) });
@@ -3211,7 +4670,7 @@ function DSelectFilter({
3211
4670
  }) {
3212
4671
  const { t } = useDLocalization();
3213
4672
  const id = useId7();
3214
- const searchRef = useRef11(null);
4673
+ const searchRef = useRef12(null);
3215
4674
  const [search, setSearch] = useState13("");
3216
4675
  const selectedOption = options.find((option) => String(option.value) === String(value ?? ""));
3217
4676
  const resolvedPlaceholder = placeholder ?? t("selectFilter.placeholder");
@@ -3410,18 +4869,22 @@ import { useState as useState15 } from "react";
3410
4869
  import { jsx as jsx32, jsxs as jsxs28 } from "react/jsx-runtime";
3411
4870
  function getPaginationPages(page, totalPages) {
3412
4871
  const count = Math.min(Math.max(totalPages, 1), 5);
3413
- if (totalPages <= 5) return Array.from({ length: count }, (_, index) => index + 1);
4872
+ if (totalPages <= 5)
4873
+ return Array.from({ length: count }, (_, index) => index + 1);
3414
4874
  const start = Math.min(Math.max(page - 2, 1), totalPages - 4);
3415
4875
  return Array.from({ length: 5 }, (_, index) => start + index);
3416
4876
  }
3417
4877
  function rawValue(row, key) {
3418
- if (row && typeof row === "object") return row[key];
4878
+ if (row && typeof row === "object")
4879
+ return row[key];
3419
4880
  return void 0;
3420
4881
  }
3421
4882
  function toDisplay(value, t) {
3422
4883
  if (value === null || value === void 0 || value === "") return "-";
3423
- if (typeof value === "boolean") return value ? t("common.yes") : t("common.no");
3424
- if (typeof value === "string" || typeof value === "number") return String(value);
4884
+ if (typeof value === "boolean")
4885
+ return value ? t("common.yes") : t("common.no");
4886
+ if (typeof value === "string" || typeof value === "number")
4887
+ return String(value);
3425
4888
  return "-";
3426
4889
  }
3427
4890
  function toNumber(value) {
@@ -3436,42 +4899,166 @@ function formatValue(column, row, index, locale, t) {
3436
4899
  return render.length >= 3 ? render(value, row, index) : render(row, index);
3437
4900
  }
3438
4901
  let formatted;
3439
- if (column.type === "currency") formatted = new Intl.NumberFormat(locale, { style: "currency", currency: "IDR", maximumFractionDigits: 0 }).format(toNumber(value));
3440
- else if (column.type === "number") formatted = new Intl.NumberFormat(locale).format(toNumber(value));
4902
+ if (column.type === "currency")
4903
+ formatted = new Intl.NumberFormat(locale, {
4904
+ style: "currency",
4905
+ currency: "IDR",
4906
+ maximumFractionDigits: 0
4907
+ }).format(toNumber(value));
4908
+ else if (column.type === "number")
4909
+ formatted = new Intl.NumberFormat(locale).format(toNumber(value));
3441
4910
  else if (column.type === "date") {
3442
4911
  const date2 = value instanceof Date ? value : typeof value === "string" ? new Date(value) : null;
3443
- formatted = date2 && !Number.isNaN(date2.getTime()) ? new Intl.DateTimeFormat(locale, { day: "2-digit", month: "short", year: "numeric" }).format(date2) : "-";
4912
+ formatted = date2 && !Number.isNaN(date2.getTime()) ? new Intl.DateTimeFormat(locale, {
4913
+ day: "2-digit",
4914
+ month: "short",
4915
+ year: "numeric"
4916
+ }).format(date2) : "-";
3444
4917
  } else formatted = toDisplay(value, t);
3445
4918
  const transform = column.transform ?? column.trasform;
3446
4919
  if (typeof transform === "function") return transform(formatted);
3447
4920
  if (typeof formatted !== "string") return formatted;
3448
4921
  if (transform === "uppercase") return formatted.toUpperCase();
3449
4922
  if (transform === "lowercase") return formatted.toLowerCase();
3450
- if (transform === "capitalize") return formatted.charAt(0).toUpperCase() + formatted.slice(1);
4923
+ if (transform === "capitalize")
4924
+ return formatted.charAt(0).toUpperCase() + formatted.slice(1);
3451
4925
  return formatted;
3452
4926
  }
3453
4927
  function alignmentClass(column) {
3454
- return cn(column.align === "center" && "text-center", column.align === "right" && "text-right", (!column.align || column.align === "left") && "text-left");
4928
+ return cn(
4929
+ column.align === "center" && "text-center",
4930
+ column.align === "right" && "text-right",
4931
+ (!column.align || column.align === "left") && "text-left"
4932
+ );
3455
4933
  }
3456
4934
  function FilterIcon() {
3457
- return /* @__PURE__ */ jsx32("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", className: "size-4", children: /* @__PURE__ */ jsx32("path", { d: "M4 6h16M7 12h10M10 18h4" }) });
4935
+ return /* @__PURE__ */ jsx32(
4936
+ "svg",
4937
+ {
4938
+ viewBox: "0 0 24 24",
4939
+ fill: "none",
4940
+ stroke: "currentColor",
4941
+ strokeWidth: "2",
4942
+ className: "size-4",
4943
+ children: /* @__PURE__ */ jsx32("path", { d: "M4 6h16M7 12h10M10 18h4" })
4944
+ }
4945
+ );
3458
4946
  }
3459
- function PageSizeSelect({ value, onChange }) {
3460
- if (!onChange) return /* @__PURE__ */ jsx32("span", { className: "font-medium text-[var(--color-text)]", children: value });
3461
- return /* @__PURE__ */ jsx32(DDropdown, { placement: "top-start", closeOnItemClick: true, scrollBehavior: "close", trigger: ({ open }) => /* @__PURE__ */ jsxs28("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: [
3462
- value,
3463
- /* @__PURE__ */ jsx32(ChevronDownIcon, { size: 14, className: cn("absolute right-1.5 transition-transform duration-150", open && "rotate-180") })
3464
- ] }), children: /* @__PURE__ */ jsx32("div", { className: "min-w-[72px] py-1", children: [10, 25, 50, 100].map((size) => /* @__PURE__ */ jsx32("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)) }) });
4947
+ var DEFAULT_PAGE_SIZE_OPTIONS = [10, 25, 50, 100];
4948
+ function PageSizeSelect({
4949
+ value,
4950
+ onChange,
4951
+ options = DEFAULT_PAGE_SIZE_OPTIONS
4952
+ }) {
4953
+ if (!onChange)
4954
+ return /* @__PURE__ */ jsx32("span", { className: "font-medium text-(--color-text)", children: value });
4955
+ return /* @__PURE__ */ jsx32(
4956
+ DDropdown,
4957
+ {
4958
+ placement: "top-start",
4959
+ closeOnItemClick: true,
4960
+ scrollBehavior: "close",
4961
+ contentPadding: false,
4962
+ trigger: ({ open }) => /* @__PURE__ */ jsxs28(
4963
+ "button",
4964
+ {
4965
+ type: "button",
4966
+ 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",
4967
+ children: [
4968
+ value,
4969
+ /* @__PURE__ */ jsx32(
4970
+ ChevronDownIcon,
4971
+ {
4972
+ size: 14,
4973
+ className: cn(
4974
+ "absolute right-1.5 transition-transform duration-150",
4975
+ open && "rotate-180"
4976
+ )
4977
+ }
4978
+ )
4979
+ ]
4980
+ }
4981
+ ),
4982
+ children: /* @__PURE__ */ jsx32("div", { className: "min-w-18 space-y-0.5 p-1.5", children: options.map((size) => /* @__PURE__ */ jsx32(
4983
+ "button",
4984
+ {
4985
+ type: "button",
4986
+ onClick: () => onChange(size),
4987
+ className: cn(
4988
+ "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)",
4989
+ size === value && "bg-(--color-brand)/10 font-medium text-(--color-brand)"
4990
+ ),
4991
+ children: size
4992
+ },
4993
+ size
4994
+ )) })
4995
+ }
4996
+ );
3465
4997
  }
3466
- function ActionMenu({ actions, row }) {
4998
+ function ActionMenu({
4999
+ actions,
5000
+ row
5001
+ }) {
3467
5002
  const visible = actions.filter((action) => !action.show || action.show(row));
3468
5003
  if (!visible.length) return null;
3469
- return /* @__PURE__ */ jsx32(DDropdown, { placement: "bottom-end", closeOnItemClick: true, scrollBehavior: "close", trigger: ({ open }) => /* @__PURE__ */ jsx32("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__ */ jsx32(MoreHorizontalIcon, { size: 16 }) }), children: /* @__PURE__ */ jsx32("div", { className: "min-w-[180px] py-1", children: visible.map((action, index) => /* @__PURE__ */ jsxs28("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: [
3470
- action.icon,
3471
- action.label
3472
- ] }, index)) }) });
5004
+ return /* @__PURE__ */ jsx32(
5005
+ DDropdown,
5006
+ {
5007
+ placement: "bottom-end",
5008
+ closeOnItemClick: true,
5009
+ scrollBehavior: "close",
5010
+ trigger: ({ open }) => /* @__PURE__ */ jsx32(
5011
+ "span",
5012
+ {
5013
+ className: cn(
5014
+ "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)",
5015
+ open && "bg-(--color-surface-muted) text-(--color-text)"
5016
+ ),
5017
+ children: /* @__PURE__ */ jsx32(MoreHorizontalIcon, { size: 16 })
5018
+ }
5019
+ ),
5020
+ children: /* @__PURE__ */ jsx32("div", { className: "min-w-45 px-1.5 py-1", children: visible.map((action, index) => /* @__PURE__ */ jsxs28(
5021
+ "button",
5022
+ {
5023
+ type: "button",
5024
+ onClick: () => action.onClick(row),
5025
+ className: cn(
5026
+ "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)",
5027
+ action.variant === "danger" ? "text-(--color-danger)" : "text-(--color-text)"
5028
+ ),
5029
+ children: [
5030
+ action.icon,
5031
+ action.label
5032
+ ]
5033
+ },
5034
+ index
5035
+ )) })
5036
+ }
5037
+ );
3473
5038
  }
3474
- 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 }) {
5039
+ function DDataTable({
5040
+ columns,
5041
+ data,
5042
+ rowKey = "id",
5043
+ loading = false,
5044
+ emptyMessage,
5045
+ onRowClick,
5046
+ sortBy,
5047
+ sortDirection,
5048
+ sortDir,
5049
+ onSort,
5050
+ pagination,
5051
+ onPageChange,
5052
+ onPageSizeChange,
5053
+ pageSizeOptions,
5054
+ actions,
5055
+ searchable = false,
5056
+ searchPlaceholder,
5057
+ searchValue = "",
5058
+ onSearchChange,
5059
+ headerActions,
5060
+ filters
5061
+ }) {
3475
5062
  const { locale, t } = useDLocalization();
3476
5063
  const [showFilters, setShowFilters] = useState15(false);
3477
5064
  const direction = sortDirection ?? sortDir ?? "asc";
@@ -3485,71 +5072,246 @@ function DDataTable({ columns, data, rowKey = "id", loading = false, emptyMessag
3485
5072
  };
3486
5073
  const changeSort = (column) => {
3487
5074
  if (!column.sortable || !onSort) return;
3488
- onSort(String(column.key), sortBy === String(column.key) && direction === "asc" ? "desc" : "asc");
5075
+ onSort(
5076
+ String(column.key),
5077
+ sortBy === String(column.key) && direction === "asc" ? "desc" : "asc"
5078
+ );
3489
5079
  };
3490
5080
  const actionArray = Array.isArray(actions) ? actions : null;
3491
5081
  const actionRenderer = typeof actions === "function" ? actions : null;
3492
5082
  const hasActions = Boolean(actionArray?.length || actionRenderer);
3493
5083
  const renderActions = (row, index) => actionRenderer ? actionRenderer(row, index) : actionArray ? /* @__PURE__ */ jsx32(ActionMenu, { actions: actionArray, row }) : null;
3494
5084
  const renderValue = (column, row, index) => formatValue(column, row, index, locale, t);
3495
- return /* @__PURE__ */ jsxs28("div", { "data-ds-component": "data-table", className: "overflow-visible rounded-[var(--radius-card)] border border-[var(--color-border)] bg-[var(--color-surface)]", children: [
3496
- searchable || headerActions || filters ? /* @__PURE__ */ jsx32("div", { className: "space-y-4 border-b border-[var(--color-border)] px-4 py-3", children: /* @__PURE__ */ jsxs28("div", { className: "flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between", children: [
3497
- /* @__PURE__ */ jsxs28("div", { className: "flex w-full items-center gap-2 sm:w-auto", children: [
3498
- searchable ? /* @__PURE__ */ jsx32(DSearchInput, { value: searchValue, onChange: (query) => onSearchChange?.(query), placeholder: resolvedSearch, debounceMs: 500, align: "left", expandedWidth: "260px" }) : null,
3499
- filters ? /* @__PURE__ */ jsx32("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__ */ jsx32(FilterIcon, {}) }) : null
3500
- ] }),
3501
- headerActions ? /* @__PURE__ */ jsx32("div", { className: "flex w-full shrink-0 items-center justify-end gap-2 sm:w-auto", children: headerActions }) : null
3502
- ] }) }) : null,
3503
- filters ? /* @__PURE__ */ jsx32("div", { className: cn("overflow-hidden transition-all duration-300", showFilters ? "max-h-[220px] opacity-100" : "max-h-0 opacity-0"), children: /* @__PURE__ */ jsx32("div", { className: "flex flex-wrap items-center gap-2 border-b border-[var(--color-border)] px-4 py-3", children: filters }) }) : null,
3504
- /* @__PURE__ */ jsx32("div", { className: "divide-y divide-[var(--color-border)] sm:hidden", children: loading ? Array.from({ length: 3 }, (_, index) => /* @__PURE__ */ jsxs28("div", { className: "space-y-2 p-4", children: [
3505
- /* @__PURE__ */ jsx32(DSkeleton, { height: 16, width: "70%" }),
3506
- /* @__PURE__ */ jsx32(DSkeleton, { height: 12, width: "50%" }),
3507
- /* @__PURE__ */ jsx32(DSkeleton, { height: 12, width: "40%" })
3508
- ] }, index)) : data.length === 0 ? /* @__PURE__ */ jsx32("div", { className: "px-4 py-16 text-center text-sm text-[var(--color-text-muted)]", children: resolvedEmpty }) : data.map((row, index) => /* @__PURE__ */ jsxs28("div", { onClick: () => onRowClick?.(row), className: cn("p-4", onRowClick && "cursor-pointer active:bg-[var(--color-surface-muted)]/30"), children: [
3509
- /* @__PURE__ */ jsxs28("div", { className: "flex items-start justify-between gap-2", children: [
3510
- /* @__PURE__ */ jsx32("div", { className: "min-w-0 flex-1", children: columns.slice(0, 2).map((column, columnIndex) => /* @__PURE__ */ jsx32("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))) }),
3511
- hasActions ? /* @__PURE__ */ jsx32("div", { onClick: (event) => event.stopPropagation(), children: renderActions(row, index) }) : null
3512
- ] }),
3513
- columns.length > 2 ? /* @__PURE__ */ jsx32("div", { className: "mt-2 flex flex-wrap gap-x-4 gap-y-1", children: columns.slice(2).map((column) => /* @__PURE__ */ jsxs28("div", { className: "text-xs", children: [
3514
- /* @__PURE__ */ jsxs28("span", { className: "text-[var(--color-text-muted)]", children: [
3515
- column.label,
3516
- ": "
3517
- ] }),
3518
- /* @__PURE__ */ jsx32("span", { className: "font-medium text-[var(--color-text)]", children: renderValue(column, row, index) })
3519
- ] }, String(column.key))) }) : null
3520
- ] }, getKey(row, index))) }),
3521
- /* @__PURE__ */ jsx32("div", { className: "hidden overflow-x-auto sm:block", children: /* @__PURE__ */ jsxs28("table", { className: "w-full text-sm", children: [
3522
- /* @__PURE__ */ jsx32("thead", { children: /* @__PURE__ */ jsxs28("tr", { className: "border-b border-[var(--color-border)] bg-[var(--color-surface-muted)]/40", children: [
3523
- columns.map((column) => /* @__PURE__ */ jsx32("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__ */ jsxs28("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: [
3524
- column.label,
3525
- column.sortable && sortBy === String(column.key) ? direction === "asc" ? /* @__PURE__ */ jsx32(ArrowUpIcon, {}) : /* @__PURE__ */ jsx32(ArrowDownIcon, {}) : null
3526
- ] }) }, String(column.key))),
3527
- hasActions ? /* @__PURE__ */ jsx32("th", { className: "w-16 px-4 py-3 text-right text-xs font-semibold text-[var(--color-text-muted)]", children: t("dataTable.actions") }) : null
3528
- ] }) }),
3529
- /* @__PURE__ */ jsxs28("tbody", { children: [
3530
- loading ? Array.from({ length: 5 }, (_, rowIndex) => /* @__PURE__ */ jsxs28("tr", { className: "border-b border-[var(--color-border)]/60 last:border-0", children: [
3531
- columns.map((column, columnIndex) => /* @__PURE__ */ jsx32("td", { className: "px-4 py-3", children: /* @__PURE__ */ jsx32(DSkeleton, { height: 12, width: columnIndex === 0 ? "70%" : "50%" }) }, String(column.key))),
3532
- hasActions ? /* @__PURE__ */ jsx32("td", { className: "px-4 py-3", children: /* @__PURE__ */ jsx32(DSkeleton, { height: 24, width: 24 }) }) : null
3533
- ] }, rowIndex)) : data.map((row, rowIndex) => /* @__PURE__ */ jsxs28("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: [
3534
- columns.map((column) => /* @__PURE__ */ jsx32("td", { className: cn("px-4 py-3", alignmentClass(column)), children: renderValue(column, row, rowIndex) }, String(column.key))),
3535
- hasActions ? /* @__PURE__ */ jsx32("td", { className: "px-4 py-3 text-right", onClick: (event) => event.stopPropagation(), children: renderActions(row, rowIndex) }) : null
3536
- ] }, getKey(row, rowIndex))),
3537
- !loading && data.length === 0 ? /* @__PURE__ */ jsx32("tr", { children: /* @__PURE__ */ jsx32("td", { colSpan: columns.length + (hasActions ? 1 : 0), className: "px-4 py-16 text-center text-sm text-[var(--color-text-muted)]", children: resolvedEmpty }) }) : null
3538
- ] })
3539
- ] }) }),
3540
- pagination ? /* @__PURE__ */ jsxs28("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: [
3541
- /* @__PURE__ */ jsxs28("div", { className: "flex items-center gap-2", children: [
3542
- /* @__PURE__ */ jsx32("span", { children: t("dataTable.showing") }),
3543
- /* @__PURE__ */ jsx32(PageSizeSelect, { value: pagination.pageSize, onChange: onPageSizeChange }),
3544
- /* @__PURE__ */ jsx32("span", { children: t("dataTable.ofData", { total: pagination.total }) })
3545
- ] }),
3546
- /* @__PURE__ */ jsxs28("div", { className: "flex items-center gap-1", children: [
3547
- /* @__PURE__ */ jsx32("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__ */ jsx32(ChevronLeftIcon, { size: 16 }) }),
3548
- getPaginationPages(pagination.page, totalPages).map((page) => /* @__PURE__ */ jsx32("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)),
3549
- /* @__PURE__ */ jsx32("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__ */ jsx32(ChevronRightIcon, { size: 16 }) })
3550
- ] })
3551
- ] }) : null
3552
- ] });
5085
+ return /* @__PURE__ */ jsxs28(
5086
+ "div",
5087
+ {
5088
+ "data-ds-component": "data-table",
5089
+ className: "overflow-visible rounded-(--radius-card) border border-(--color-border) bg-(--color-surface)",
5090
+ children: [
5091
+ searchable || headerActions || filters ? /* @__PURE__ */ jsx32("div", { className: "space-y-4 border-b border-(--color-border) px-4 py-3", children: /* @__PURE__ */ jsxs28("div", { className: "flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between", children: [
5092
+ /* @__PURE__ */ jsxs28("div", { className: "flex w-full items-center gap-2 sm:w-auto", children: [
5093
+ searchable ? /* @__PURE__ */ jsx32(
5094
+ DSearchInput,
5095
+ {
5096
+ value: searchValue,
5097
+ onChange: (query) => onSearchChange?.(query),
5098
+ placeholder: resolvedSearch,
5099
+ debounceMs: 500,
5100
+ align: "left",
5101
+ expandedWidth: "260px"
5102
+ }
5103
+ ) : null,
5104
+ filters ? /* @__PURE__ */ jsx32(
5105
+ "button",
5106
+ {
5107
+ type: "button",
5108
+ "aria-label": t("dataTable.toggleFilters"),
5109
+ onClick: () => setShowFilters((value) => !value),
5110
+ className: cn(
5111
+ "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",
5112
+ 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)"
5113
+ ),
5114
+ children: /* @__PURE__ */ jsx32(FilterIcon, {})
5115
+ }
5116
+ ) : null
5117
+ ] }),
5118
+ headerActions ? /* @__PURE__ */ jsx32("div", { className: "flex w-full shrink-0 items-center justify-end gap-2 sm:w-auto", children: headerActions }) : null
5119
+ ] }) }) : null,
5120
+ filters ? /* @__PURE__ */ jsx32(
5121
+ "div",
5122
+ {
5123
+ className: cn(
5124
+ "overflow-hidden transition-all duration-300",
5125
+ showFilters ? "max-h-55 opacity-100" : "max-h-0 opacity-0"
5126
+ ),
5127
+ children: /* @__PURE__ */ jsx32("div", { className: "flex flex-wrap items-center gap-2 border-b border-(--color-border) px-4 py-3", children: filters })
5128
+ }
5129
+ ) : null,
5130
+ /* @__PURE__ */ jsx32("div", { className: "divide-y divide-(--color-border) sm:hidden", children: loading ? Array.from({ length: 3 }, (_, index) => /* @__PURE__ */ jsxs28("div", { className: "space-y-2 p-4", children: [
5131
+ /* @__PURE__ */ jsx32(DSkeleton, { height: 16, width: "70%" }),
5132
+ /* @__PURE__ */ jsx32(DSkeleton, { height: 12, width: "50%" }),
5133
+ /* @__PURE__ */ jsx32(DSkeleton, { height: 12, width: "40%" })
5134
+ ] }, index)) : data.length === 0 ? /* @__PURE__ */ jsx32("div", { className: "px-4 py-16 text-center text-sm text-(--color-text-muted)", children: resolvedEmpty }) : data.map((row, index) => /* @__PURE__ */ jsxs28(
5135
+ "div",
5136
+ {
5137
+ onClick: () => onRowClick?.(row),
5138
+ className: cn(
5139
+ "p-4",
5140
+ onRowClick && "cursor-pointer active:bg-(--color-surface-muted)/30"
5141
+ ),
5142
+ children: [
5143
+ /* @__PURE__ */ jsxs28("div", { className: "flex items-start justify-between gap-2", children: [
5144
+ /* @__PURE__ */ jsx32("div", { className: "min-w-0 flex-1", children: columns.slice(0, 2).map((column, columnIndex) => /* @__PURE__ */ jsx32(
5145
+ "div",
5146
+ {
5147
+ className: columnIndex === 0 ? "truncate text-sm font-medium text-(--color-text)" : "mt-0.5 truncate text-xs text-(--color-text-muted)",
5148
+ children: renderValue(column, row, index)
5149
+ },
5150
+ String(column.key)
5151
+ )) }),
5152
+ hasActions ? /* @__PURE__ */ jsx32("div", { onClick: (event) => event.stopPropagation(), children: renderActions(row, index) }) : null
5153
+ ] }),
5154
+ columns.length > 2 ? /* @__PURE__ */ jsx32("div", { className: "mt-2 flex flex-wrap gap-x-4 gap-y-1", children: columns.slice(2).map((column) => /* @__PURE__ */ jsxs28("div", { className: "text-xs", children: [
5155
+ /* @__PURE__ */ jsxs28("span", { className: "text-(--color-text-muted)", children: [
5156
+ column.label,
5157
+ ":",
5158
+ " "
5159
+ ] }),
5160
+ /* @__PURE__ */ jsx32("span", { className: "font-medium text-(--color-text)", children: renderValue(column, row, index) })
5161
+ ] }, String(column.key))) }) : null
5162
+ ]
5163
+ },
5164
+ getKey(row, index)
5165
+ )) }),
5166
+ /* @__PURE__ */ jsx32("div", { className: "hidden overflow-x-auto sm:block", children: /* @__PURE__ */ jsxs28("table", { className: "w-full text-sm", children: [
5167
+ /* @__PURE__ */ jsx32("thead", { children: /* @__PURE__ */ jsxs28("tr", { className: "border-b border-(--color-border) bg-(--color-surface-muted)/40", children: [
5168
+ columns.map((column, columnIndex) => /* @__PURE__ */ jsx32(
5169
+ "th",
5170
+ {
5171
+ style: column.width ? { width: column.width } : void 0,
5172
+ className: cn(
5173
+ "whitespace-nowrap px-4 py-3 text-xs font-semibold text-(--color-text-muted)",
5174
+ columnIndex === 0 && "pl-6",
5175
+ columnIndex === columns.length - 1 && !hasActions && "pr-6",
5176
+ alignmentClass(column)
5177
+ ),
5178
+ children: /* @__PURE__ */ jsxs28(
5179
+ "button",
5180
+ {
5181
+ type: "button",
5182
+ disabled: !column.sortable,
5183
+ onClick: () => changeSort(column),
5184
+ className: cn(
5185
+ "inline-flex appearance-none items-center gap-1 border-0 bg-transparent p-0 text-inherit outline-none",
5186
+ column.sortable && "cursor-pointer hover:text-(--color-text) focus-visible:ring-2 focus-visible:ring-(--color-focus)/25"
5187
+ ),
5188
+ children: [
5189
+ column.label,
5190
+ column.sortable && sortBy === String(column.key) ? direction === "asc" ? /* @__PURE__ */ jsx32(ArrowUpIcon, {}) : /* @__PURE__ */ jsx32(ArrowDownIcon, {}) : null
5191
+ ]
5192
+ }
5193
+ )
5194
+ },
5195
+ String(column.key)
5196
+ )),
5197
+ hasActions ? /* @__PURE__ */ jsx32("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
5198
+ ] }) }),
5199
+ /* @__PURE__ */ jsxs28("tbody", { children: [
5200
+ loading ? Array.from({ length: 5 }, (_, rowIndex) => /* @__PURE__ */ jsxs28(
5201
+ "tr",
5202
+ {
5203
+ className: "border-b border-(--color-border)/60 last:border-0",
5204
+ children: [
5205
+ columns.map((column, columnIndex) => /* @__PURE__ */ jsx32("td", { className: "px-4 py-3", children: /* @__PURE__ */ jsx32(
5206
+ DSkeleton,
5207
+ {
5208
+ height: 12,
5209
+ width: columnIndex === 0 ? "70%" : "50%"
5210
+ }
5211
+ ) }, String(column.key))),
5212
+ hasActions ? /* @__PURE__ */ jsx32("td", { className: "px-4 py-3", children: /* @__PURE__ */ jsx32(DSkeleton, { height: 24, width: 24 }) }) : null
5213
+ ]
5214
+ },
5215
+ rowIndex
5216
+ )) : data.map((row, rowIndex) => /* @__PURE__ */ jsxs28(
5217
+ "tr",
5218
+ {
5219
+ onClick: () => onRowClick?.(row),
5220
+ className: cn(
5221
+ "border-b border-(--color-border)/60 last:border-0 hover:bg-(--color-surface-muted)/35",
5222
+ onRowClick && "cursor-pointer"
5223
+ ),
5224
+ children: [
5225
+ columns.map((column, columnIndex) => /* @__PURE__ */ jsx32(
5226
+ "td",
5227
+ {
5228
+ className: cn(
5229
+ "px-4 py-3",
5230
+ columnIndex === 0 && "pl-6",
5231
+ columnIndex === columns.length - 1 && !hasActions && "pr-6",
5232
+ alignmentClass(column)
5233
+ ),
5234
+ children: renderValue(column, row, rowIndex)
5235
+ },
5236
+ String(column.key)
5237
+ )),
5238
+ hasActions ? /* @__PURE__ */ jsx32(
5239
+ "td",
5240
+ {
5241
+ className: "py-3 pl-4 pr-6 text-right",
5242
+ onClick: (event) => event.stopPropagation(),
5243
+ children: renderActions(row, rowIndex)
5244
+ }
5245
+ ) : null
5246
+ ]
5247
+ },
5248
+ getKey(row, rowIndex)
5249
+ )),
5250
+ !loading && data.length === 0 ? /* @__PURE__ */ jsx32("tr", { children: /* @__PURE__ */ jsx32(
5251
+ "td",
5252
+ {
5253
+ colSpan: columns.length + (hasActions ? 1 : 0),
5254
+ className: "px-4 py-16 text-center text-sm text-(--color-text-muted)",
5255
+ children: resolvedEmpty
5256
+ }
5257
+ ) }) : null
5258
+ ] })
5259
+ ] }) }),
5260
+ pagination ? /* @__PURE__ */ jsxs28("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: [
5261
+ /* @__PURE__ */ jsxs28("div", { className: "flex items-center gap-2", children: [
5262
+ /* @__PURE__ */ jsx32("span", { children: t("dataTable.showing") }),
5263
+ /* @__PURE__ */ jsx32(
5264
+ PageSizeSelect,
5265
+ {
5266
+ value: pagination.pageSize,
5267
+ onChange: onPageSizeChange,
5268
+ options: pageSizeOptions
5269
+ }
5270
+ ),
5271
+ /* @__PURE__ */ jsx32("span", { children: t("dataTable.ofData", { total: pagination.total }) })
5272
+ ] }),
5273
+ /* @__PURE__ */ jsxs28("div", { className: "flex items-center gap-1", children: [
5274
+ /* @__PURE__ */ jsx32(
5275
+ "button",
5276
+ {
5277
+ type: "button",
5278
+ "aria-label": t("pagination.previous"),
5279
+ disabled: pagination.page <= 1,
5280
+ onClick: () => onPageChange?.(pagination.page - 1),
5281
+ 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",
5282
+ children: /* @__PURE__ */ jsx32(ChevronLeftIcon, { size: 16 })
5283
+ }
5284
+ ),
5285
+ getPaginationPages(pagination.page, totalPages).map((page) => /* @__PURE__ */ jsx32(
5286
+ "button",
5287
+ {
5288
+ type: "button",
5289
+ "aria-label": t("pagination.page", { page }),
5290
+ onClick: () => onPageChange?.(page),
5291
+ className: cn(
5292
+ "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",
5293
+ page === pagination.page ? "bg-(--color-brand) text-(--color-brand-foreground)" : "text-(--color-text) hover:bg-(--color-surface-muted)"
5294
+ ),
5295
+ children: page
5296
+ },
5297
+ page
5298
+ )),
5299
+ /* @__PURE__ */ jsx32(
5300
+ "button",
5301
+ {
5302
+ type: "button",
5303
+ "aria-label": t("pagination.next"),
5304
+ disabled: pagination.page >= totalPages,
5305
+ onClick: () => onPageChange?.(pagination.page + 1),
5306
+ 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",
5307
+ children: /* @__PURE__ */ jsx32(ChevronRightIcon, { size: 16 })
5308
+ }
5309
+ )
5310
+ ] })
5311
+ ] }) : null
5312
+ ]
5313
+ }
5314
+ );
3553
5315
  }
3554
5316
 
3555
5317
  // src/textarea/textarea.tsx
@@ -3559,68 +5321,108 @@ import {
3559
5321
  } from "react";
3560
5322
  import { jsx as jsx33, jsxs as jsxs29 } from "react/jsx-runtime";
3561
5323
  function ClearIcon9() {
3562
- return /* @__PURE__ */ jsx33("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", className: "size-3.5", children: /* @__PURE__ */ jsx33("path", { d: "m18 6-12 12M6 6l12 12" }) });
5324
+ return /* @__PURE__ */ jsx33(
5325
+ "svg",
5326
+ {
5327
+ viewBox: "0 0 24 24",
5328
+ fill: "none",
5329
+ stroke: "currentColor",
5330
+ strokeWidth: "2",
5331
+ className: "size-3.5",
5332
+ children: /* @__PURE__ */ jsx33("path", { d: "m18 6-12 12M6 6l12 12" })
5333
+ }
5334
+ );
3563
5335
  }
3564
5336
  function eventWithValue2(value) {
3565
- return { target: { value }, currentTarget: { value } };
3566
- }
3567
- var DTextarea = forwardRef5(function DTextarea2({
3568
- label,
3569
- error,
3570
- hint,
3571
- clearable = true,
3572
- onClear,
3573
- onChange,
3574
- onNativeChange,
3575
- containerClassName,
3576
- className,
3577
- value,
3578
- disabled,
3579
- readOnly,
3580
- id: externalId,
3581
- ...props
3582
- }, ref) {
3583
- const { t } = useDLocalization();
3584
- const autoId = useId8();
3585
- const id = externalId ?? autoId;
3586
- const hasValue = value !== void 0 && value !== null && value !== "";
3587
- const clear = () => {
3588
- const event = eventWithValue2("");
3589
- onClear?.();
3590
- onChange?.("", event);
3591
- onNativeChange?.(event);
5337
+ return {
5338
+ target: { value },
5339
+ currentTarget: { value }
3592
5340
  };
3593
- return /* @__PURE__ */ jsxs29("div", { "data-ds-component": "textarea", className: cn("flex min-w-0 flex-col gap-1.5", containerClassName), children: [
3594
- label ? /* @__PURE__ */ jsx33("label", { htmlFor: id, className: "inline-block w-fit text-sm font-medium text-[var(--color-text)]", children: label }) : null,
3595
- /* @__PURE__ */ jsxs29("div", { className: "relative", children: [
3596
- /* @__PURE__ */ jsx33(
3597
- "textarea",
3598
- {
3599
- ...props,
3600
- ref,
3601
- id,
3602
- value,
3603
- disabled,
3604
- readOnly,
3605
- "aria-invalid": Boolean(error) || void 0,
3606
- onChange: (event) => {
3607
- onChange?.(event.target.value, event);
3608
- onNativeChange?.(event);
3609
- },
3610
- className: cn(
3611
- "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)]",
3612
- error ? "border-[var(--color-danger)] focus:ring-[var(--color-danger)]/20" : "border-[var(--color-border)]",
3613
- clearable && hasValue && !disabled && !readOnly && "pr-10",
3614
- className
3615
- )
3616
- }
3617
- ),
3618
- clearable && hasValue && !disabled && !readOnly ? /* @__PURE__ */ jsx33("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__ */ jsx33(ClearIcon9, {}) }) : null
3619
- ] }),
3620
- error ? /* @__PURE__ */ jsx33("p", { className: "text-xs text-[var(--color-danger)]", children: error }) : null,
3621
- !error && hint ? /* @__PURE__ */ jsx33("p", { className: "text-xs text-[var(--color-text-muted)]", children: hint }) : null
3622
- ] });
3623
- });
5341
+ }
5342
+ var DTextarea = forwardRef5(
5343
+ function DTextarea2({
5344
+ label,
5345
+ error,
5346
+ hint,
5347
+ clearable = true,
5348
+ onClear,
5349
+ onChange,
5350
+ onNativeChange,
5351
+ containerClassName,
5352
+ className,
5353
+ value,
5354
+ disabled,
5355
+ readOnly,
5356
+ id: externalId,
5357
+ ...props
5358
+ }, ref) {
5359
+ const { t } = useDLocalization();
5360
+ const autoId = useId8();
5361
+ const id = externalId ?? autoId;
5362
+ const hasValue = value !== void 0 && value !== null && value !== "";
5363
+ const clear = () => {
5364
+ const event = eventWithValue2("");
5365
+ onClear?.();
5366
+ onChange?.("", event);
5367
+ onNativeChange?.(event);
5368
+ };
5369
+ return /* @__PURE__ */ jsxs29(
5370
+ "div",
5371
+ {
5372
+ "data-ds-component": "textarea",
5373
+ className: cn("flex min-w-0 flex-col gap-1.5", containerClassName),
5374
+ children: [
5375
+ label ? /* @__PURE__ */ jsx33(
5376
+ "label",
5377
+ {
5378
+ htmlFor: id,
5379
+ className: "inline-block w-fit text-sm font-medium text-(--color-text)",
5380
+ children: label
5381
+ }
5382
+ ) : null,
5383
+ /* @__PURE__ */ jsxs29("div", { className: "relative", children: [
5384
+ /* @__PURE__ */ jsx33(
5385
+ "textarea",
5386
+ {
5387
+ ...props,
5388
+ ref,
5389
+ id,
5390
+ value,
5391
+ disabled,
5392
+ readOnly,
5393
+ "aria-invalid": Boolean(error) || void 0,
5394
+ onChange: (event) => {
5395
+ onChange?.(event.target.value, event);
5396
+ onNativeChange?.(event);
5397
+ },
5398
+ className: cn(
5399
+ "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)",
5400
+ error ? "border-(--color-danger) focus:ring-(--color-danger)/20" : "border-(--color-border)",
5401
+ clearable && hasValue && !disabled && !readOnly && "pr-10",
5402
+ className
5403
+ )
5404
+ }
5405
+ ),
5406
+ clearable && hasValue && !disabled && !readOnly ? /* @__PURE__ */ jsx33(
5407
+ "button",
5408
+ {
5409
+ type: "button",
5410
+ tabIndex: -1,
5411
+ "aria-label": t("textarea.clear"),
5412
+ onMouseDown: (event) => event.preventDefault(),
5413
+ onClick: clear,
5414
+ 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",
5415
+ children: /* @__PURE__ */ jsx33(ClearIcon9, {})
5416
+ }
5417
+ ) : null
5418
+ ] }),
5419
+ error ? /* @__PURE__ */ jsx33("p", { className: "text-xs text-(--color-danger)", children: error }) : null,
5420
+ !error && hint ? /* @__PURE__ */ jsx33("p", { className: "text-xs text-(--color-text-muted)", children: hint }) : null
5421
+ ]
5422
+ }
5423
+ );
5424
+ }
5425
+ );
3624
5426
 
3625
5427
  // src/toast/toast.tsx
3626
5428
  import {
@@ -3629,7 +5431,7 @@ import {
3629
5431
  useContext as useContext4,
3630
5432
  useEffect as useEffect14,
3631
5433
  useMemo as useMemo9,
3632
- useRef as useRef12,
5434
+ useRef as useRef13,
3633
5435
  useState as useState16
3634
5436
  } from "react";
3635
5437
  import { jsx as jsx34, jsxs as jsxs30 } from "react/jsx-runtime";
@@ -3645,7 +5447,7 @@ function DToastProvider({
3645
5447
  defaultDuration = 4e3
3646
5448
  }) {
3647
5449
  const [toasts, setToasts] = useState16([]);
3648
- const timers = useRef12(/* @__PURE__ */ new Map());
5450
+ const timers = useRef13(/* @__PURE__ */ new Map());
3649
5451
  const dismissToast = useCallback4((id) => {
3650
5452
  const timer = timers.current.get(id);
3651
5453
  if (timer) clearTimeout(timer);
@@ -3737,7 +5539,19 @@ function DToastContainer({ toasts, onDismiss, className }) {
3737
5539
  import { forwardRef as forwardRef6 } from "react";
3738
5540
  import { jsx as jsx35 } from "react/jsx-runtime";
3739
5541
  var DRadio = forwardRef6(function DRadio2({ className, ...props }, ref) {
3740
- return /* @__PURE__ */ jsx35("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 });
5542
+ return /* @__PURE__ */ jsx35(
5543
+ "input",
5544
+ {
5545
+ "data-ds-component": "radio",
5546
+ ref,
5547
+ type: "radio",
5548
+ className: cn(
5549
+ "cursor-pointer size-4 accent-(--color-brand) focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-(--color-focus)/20",
5550
+ className
5551
+ ),
5552
+ ...props
5553
+ }
5554
+ );
3741
5555
  });
3742
5556
 
3743
5557
  // src/toggle/toggle.tsx
@@ -3960,7 +5774,7 @@ function DAvatar({ src, alt, name, fallback, size = "md", status, className, ...
3960
5774
  }
3961
5775
 
3962
5776
  // src/tooltip/tooltip.tsx
3963
- import { cloneElement, useEffect as useEffect16, useId as useId9, useRef as useRef13, useState as useState17 } from "react";
5777
+ import { cloneElement, useEffect as useEffect16, useId as useId9, useRef as useRef14, useState as useState17 } from "react";
3964
5778
  import { jsx as jsx39, jsxs as jsxs33 } from "react/jsx-runtime";
3965
5779
  var placementClass = {
3966
5780
  top: "bottom-full left-1/2 mb-2 -translate-x-1/2",
@@ -3971,7 +5785,7 @@ var placementClass = {
3971
5785
  function DTooltip({ content, children, placement = "top", className, delayMs = 120 }) {
3972
5786
  const id = useId9();
3973
5787
  const [open, setOpen] = useState17(false);
3974
- const timerRef = useRef13(null);
5788
+ const timerRef = useRef14(null);
3975
5789
  const child = children;
3976
5790
  const clearTimer = () => {
3977
5791
  if (timerRef.current !== null) {
@@ -4042,7 +5856,8 @@ function DSpinner({ size = "md", label = "Loading", className, ...props }) {
4042
5856
  // src/pagination/pagination.tsx
4043
5857
  import { jsx as jsx42, jsxs as jsxs34 } from "react/jsx-runtime";
4044
5858
  function getPaginationItems(page, total, sibling = 1) {
4045
- if (total <= 7) return Array.from({ length: Math.max(total, 0) }, (_, i) => i + 1);
5859
+ if (total <= 7)
5860
+ return Array.from({ length: Math.max(total, 0) }, (_, i) => i + 1);
4046
5861
  const start = Math.max(2, page - sibling);
4047
5862
  const end = Math.min(total - 1, page + sibling);
4048
5863
  const items = [1];
@@ -4052,7 +5867,7 @@ function getPaginationItems(page, total, sibling = 1) {
4052
5867
  items.push(total);
4053
5868
  return items;
4054
5869
  }
4055
- 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";
5870
+ 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";
4056
5871
  function DPagination({
4057
5872
  page,
4058
5873
  totalPages,
@@ -4063,50 +5878,80 @@ function DPagination({
4063
5878
  }) {
4064
5879
  const { t } = useDLocalization();
4065
5880
  const go = (next) => {
4066
- if (!disabled && next >= 1 && next <= totalPages && next !== page) onChange(next);
5881
+ if (!disabled && next >= 1 && next <= totalPages && next !== page)
5882
+ onChange(next);
4067
5883
  };
4068
- return /* @__PURE__ */ jsxs34("nav", { "data-ds-component": "pagination", "aria-label": t("pagination.label"), className: cn("flex items-center gap-1", className), children: [
4069
- /* @__PURE__ */ jsx42(
4070
- "button",
4071
- {
4072
- type: "button",
4073
- "aria-label": t("pagination.previous"),
4074
- disabled: disabled || page <= 1,
4075
- onClick: () => go(page - 1),
4076
- className: cn(pageButtonBase, "border border-[var(--color-border)] bg-[var(--color-surface)] text-[var(--color-text-muted)] hover:bg-[var(--color-surface-muted)]"),
4077
- children: /* @__PURE__ */ jsx42(ChevronLeftIcon, { size: 16 })
4078
- }
4079
- ),
4080
- getPaginationItems(page, totalPages, siblingCount).map((item, index) => item === "ellipsis" ? /* @__PURE__ */ jsx42("span", { "aria-hidden": "true", className: "grid size-9 place-items-center text-[var(--color-text-muted)]", children: /* @__PURE__ */ jsx42(MoreHorizontalIcon, { size: 16 }) }, `e-${index}`) : /* @__PURE__ */ jsx42(
4081
- "button",
4082
- {
4083
- type: "button",
4084
- "aria-current": item === page ? "page" : void 0,
4085
- onClick: () => go(item),
4086
- className: cn(
4087
- pageButtonBase,
4088
- 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)]"
5884
+ return /* @__PURE__ */ jsxs34(
5885
+ "nav",
5886
+ {
5887
+ "data-ds-component": "pagination",
5888
+ "aria-label": t("pagination.label"),
5889
+ className: cn("flex items-center gap-1", className),
5890
+ children: [
5891
+ /* @__PURE__ */ jsx42(
5892
+ "button",
5893
+ {
5894
+ type: "button",
5895
+ "aria-label": t("pagination.previous"),
5896
+ disabled: disabled || page <= 1,
5897
+ onClick: () => go(page - 1),
5898
+ className: cn(
5899
+ pageButtonBase,
5900
+ "border border-(--color-border) bg-(--color-surface) text-(--color-text-muted) hover:bg-(--color-surface-muted)"
5901
+ ),
5902
+ children: /* @__PURE__ */ jsx42(ChevronLeftIcon, { size: 16 })
5903
+ }
4089
5904
  ),
4090
- children: item
4091
- },
4092
- item
4093
- )),
4094
- /* @__PURE__ */ jsx42(
4095
- "button",
4096
- {
4097
- type: "button",
4098
- "aria-label": t("pagination.next"),
4099
- disabled: disabled || page >= totalPages,
4100
- onClick: () => go(page + 1),
4101
- className: cn(pageButtonBase, "border border-[var(--color-border)] bg-[var(--color-surface)] text-[var(--color-text-muted)] hover:bg-[var(--color-surface-muted)]"),
4102
- children: /* @__PURE__ */ jsx42(ChevronRightIcon, { size: 16 })
4103
- }
4104
- )
4105
- ] });
5905
+ getPaginationItems(page, totalPages, siblingCount).map(
5906
+ (item, index) => item === "ellipsis" ? /* @__PURE__ */ jsx42(
5907
+ "span",
5908
+ {
5909
+ "aria-hidden": "true",
5910
+ className: "grid size-9 place-items-center text-(--color-text-muted)",
5911
+ children: /* @__PURE__ */ jsx42(MoreHorizontalIcon, { size: 16 })
5912
+ },
5913
+ `e-${index}`
5914
+ ) : /* @__PURE__ */ jsx42(
5915
+ "button",
5916
+ {
5917
+ type: "button",
5918
+ "aria-current": item === page ? "page" : void 0,
5919
+ onClick: () => go(item),
5920
+ className: cn(
5921
+ pageButtonBase,
5922
+ 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)"
5923
+ ),
5924
+ children: item
5925
+ },
5926
+ item
5927
+ )
5928
+ ),
5929
+ /* @__PURE__ */ jsx42(
5930
+ "button",
5931
+ {
5932
+ type: "button",
5933
+ "aria-label": t("pagination.next"),
5934
+ disabled: disabled || page >= totalPages,
5935
+ onClick: () => go(page + 1),
5936
+ className: cn(
5937
+ pageButtonBase,
5938
+ "border border-(--color-border) bg-(--color-surface) text-(--color-text-muted) hover:bg-(--color-surface-muted)"
5939
+ ),
5940
+ children: /* @__PURE__ */ jsx42(ChevronRightIcon, { size: 16 })
5941
+ }
5942
+ )
5943
+ ]
5944
+ }
5945
+ );
4106
5946
  }
4107
5947
 
4108
5948
  // src/tabs/tabs.tsx
4109
- import { createContext as createContext5, useContext as useContext5, useId as useId10, useState as useState18 } from "react";
5949
+ import {
5950
+ createContext as createContext5,
5951
+ useContext as useContext5,
5952
+ useId as useId10,
5953
+ useState as useState18
5954
+ } from "react";
4110
5955
  import { jsx as jsx43 } from "react/jsx-runtime";
4111
5956
  var TabsContext = createContext5(null);
4112
5957
  function useTabs() {
@@ -4114,7 +5959,14 @@ function useTabs() {
4114
5959
  if (!ctx) throw new Error("DTabs components must be inside <DTabs>.");
4115
5960
  return ctx;
4116
5961
  }
4117
- function DTabs({ value, defaultValue, onValueChange, children, className, ...props }) {
5962
+ function DTabs({
5963
+ value,
5964
+ defaultValue,
5965
+ onValueChange,
5966
+ children,
5967
+ className,
5968
+ ...props
5969
+ }) {
4118
5970
  const [internal, setInternal] = useState18(defaultValue);
4119
5971
  const current = value ?? internal;
4120
5972
  const baseId = useId10();
@@ -4124,16 +5976,26 @@ function DTabs({ value, defaultValue, onValueChange, children, className, ...pro
4124
5976
  };
4125
5977
  return /* @__PURE__ */ jsx43(TabsContext.Provider, { value: { value: current, setValue, baseId }, children: /* @__PURE__ */ jsx43("div", { "data-ds-component": "tabs", className, ...props, children }) });
4126
5978
  }
4127
- function DTabsList({ className, onKeyDown, ...props }) {
5979
+ function DTabsList({
5980
+ className,
5981
+ onKeyDown,
5982
+ ...props
5983
+ }) {
4128
5984
  return /* @__PURE__ */ jsx43(
4129
5985
  "div",
4130
5986
  {
4131
5987
  role: "tablist",
4132
- className: cn("inline-flex items-center rounded-xl bg-[var(--color-surface-muted)] p-1", className),
5988
+ className: cn(
5989
+ "inline-flex items-center rounded-xl bg-(--color-surface-muted) p-1",
5990
+ className
5991
+ ),
4133
5992
  onKeyDown: (event) => {
4134
5993
  onKeyDown?.(event);
4135
- if (event.defaultPrevented || !["ArrowLeft", "ArrowRight", "Home", "End"].includes(event.key)) return;
4136
- const tabs = Array.from(event.currentTarget.querySelectorAll("[role=tab]:not(:disabled)"));
5994
+ if (event.defaultPrevented || !["ArrowLeft", "ArrowRight", "Home", "End"].includes(event.key))
5995
+ return;
5996
+ const tabs = Array.from(
5997
+ event.currentTarget.querySelectorAll("[role=tab]:not(:disabled)")
5998
+ );
4137
5999
  if (!tabs.length) return;
4138
6000
  const index = tabs.indexOf(document.activeElement);
4139
6001
  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;
@@ -4145,7 +6007,13 @@ function DTabsList({ className, onKeyDown, ...props }) {
4145
6007
  }
4146
6008
  );
4147
6009
  }
4148
- function DTabsTrigger({ value, disabled, className, children, ...props }) {
6010
+ function DTabsTrigger({
6011
+ value,
6012
+ disabled,
6013
+ className,
6014
+ children,
6015
+ ...props
6016
+ }) {
4149
6017
  const ctx = useTabs();
4150
6018
  const active = ctx.value === value;
4151
6019
  return /* @__PURE__ */ jsx43(
@@ -4159,8 +6027,8 @@ function DTabsTrigger({ value, disabled, className, children, ...props }) {
4159
6027
  disabled,
4160
6028
  onClick: () => ctx.setValue(value),
4161
6029
  className: cn(
4162
- "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",
4163
- active ? "bg-[var(--color-surface)] text-[var(--color-text)] shadow-sm" : "text-[var(--color-text-muted)] hover:text-[var(--color-text)]",
6030
+ "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",
6031
+ active ? "bg-(--color-surface) text-(--color-text) shadow-sm" : "text-(--color-text-muted) hover:text-(--color-text)",
4164
6032
  disabled && "cursor-not-allowed opacity-40",
4165
6033
  className
4166
6034
  ),
@@ -4172,11 +6040,25 @@ function DTabsTrigger({ value, disabled, className, children, ...props }) {
4172
6040
  function DTabsContent({ value, className, ...props }) {
4173
6041
  const ctx = useTabs();
4174
6042
  if (ctx.value !== value) return null;
4175
- return /* @__PURE__ */ jsx43("div", { role: "tabpanel", id: `${ctx.baseId}-panel-${value}`, "aria-labelledby": `${ctx.baseId}-tab-${value}`, className, ...props });
6043
+ return /* @__PURE__ */ jsx43(
6044
+ "div",
6045
+ {
6046
+ role: "tabpanel",
6047
+ id: `${ctx.baseId}-panel-${value}`,
6048
+ "aria-labelledby": `${ctx.baseId}-tab-${value}`,
6049
+ className,
6050
+ ...props
6051
+ }
6052
+ );
4176
6053
  }
4177
6054
 
4178
6055
  // src/accordion/accordion.tsx
4179
- import { createContext as createContext6, useContext as useContext6, useId as useId11, useState as useState19 } from "react";
6056
+ import {
6057
+ createContext as createContext6,
6058
+ useContext as useContext6,
6059
+ useId as useId11,
6060
+ useState as useState19
6061
+ } from "react";
4180
6062
  import { jsx as jsx44, jsxs as jsxs35 } from "react/jsx-runtime";
4181
6063
  var AccordionContext = createContext6(null);
4182
6064
  function useAccordion() {
@@ -4201,21 +6083,34 @@ function DAccordion({
4201
6083
  if (value === void 0) setInternal(next);
4202
6084
  onValueChange?.(next);
4203
6085
  };
4204
- return /* @__PURE__ */ jsx44(AccordionContext.Provider, { value: { open: current, toggle, baseId, variant }, children: /* @__PURE__ */ jsx44(
4205
- "div",
6086
+ return /* @__PURE__ */ jsx44(
6087
+ AccordionContext.Provider,
4206
6088
  {
4207
- "data-ds-component": "accordion",
4208
- "data-accordion-variant": variant,
4209
- className: cn(
4210
- variant === "card" && "overflow-hidden rounded-[var(--radius-card)] border border-[var(--color-border)] bg-[var(--color-surface)]",
4211
- variant === "separated" && "space-y-2",
4212
- className
4213
- ),
4214
- ...props
6089
+ value: { open: current, toggle, baseId, variant },
6090
+ children: /* @__PURE__ */ jsx44(
6091
+ "div",
6092
+ {
6093
+ "data-ds-component": "accordion",
6094
+ "data-accordion-variant": variant,
6095
+ className: cn(
6096
+ variant === "card" && "overflow-hidden rounded-(--radius-card) border border-(--color-border) bg-(--color-surface)",
6097
+ variant === "separated" && "space-y-2",
6098
+ className
6099
+ ),
6100
+ ...props
6101
+ }
6102
+ )
4215
6103
  }
4216
- ) });
6104
+ );
4217
6105
  }
4218
- function DAccordionItem({ value, title, disabled, className, children, ...props }) {
6106
+ function DAccordionItem({
6107
+ value,
6108
+ title,
6109
+ disabled,
6110
+ className,
6111
+ children,
6112
+ ...props
6113
+ }) {
4219
6114
  const context = useAccordion();
4220
6115
  const open = context.open.includes(value);
4221
6116
  const id = `${context.baseId}-${value.replace(/[^a-zA-Z0-9_-]/g, "-")}`;
@@ -4225,9 +6120,9 @@ function DAccordionItem({ value, title, disabled, className, children, ...props
4225
6120
  "div",
4226
6121
  {
4227
6122
  className: cn(
4228
- context.variant === "separator" && "border-b border-[var(--color-border)] last:border-b-0",
4229
- context.variant === "card" && "border-b border-[var(--color-border)] px-4 last:border-b-0",
4230
- context.variant === "separated" && "overflow-hidden rounded-[var(--radius-control)] border border-[var(--color-border)] bg-[var(--color-surface)] px-4",
6123
+ context.variant === "separator" && "border-b border-(--color-border) last:border-b-0",
6124
+ context.variant === "card" && "border-b border-(--color-border) px-4 last:border-b-0",
6125
+ context.variant === "separated" && "overflow-hidden rounded-(--radius-control) border border-(--color-border) bg-(--color-surface) px-4",
4231
6126
  (context.variant === "default" || context.variant === "separator") && "px-0",
4232
6127
  className
4233
6128
  ),
@@ -4242,14 +6137,17 @@ function DAccordionItem({ value, title, disabled, className, children, ...props
4242
6137
  "aria-expanded": open,
4243
6138
  "aria-controls": contentId,
4244
6139
  onClick: () => context.toggle(value),
4245
- 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",
6140
+ 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",
4246
6141
  children: [
4247
6142
  /* @__PURE__ */ jsx44("span", { children: title }),
4248
6143
  /* @__PURE__ */ jsx44(
4249
6144
  ChevronDownIcon,
4250
6145
  {
4251
6146
  size: 17,
4252
- className: cn("shrink-0 text-[var(--color-text-muted)] transition-transform duration-200 ease-out group-hover:text-current", open && "rotate-180")
6147
+ className: cn(
6148
+ "shrink-0 text-(--color-text-muted) transition-transform duration-200 ease-out group-hover:text-current",
6149
+ open && "rotate-180"
6150
+ )
4253
6151
  }
4254
6152
  )
4255
6153
  ]
@@ -4266,7 +6164,7 @@ function DAccordionItem({ value, title, disabled, className, children, ...props
4266
6164
  "grid transition-[grid-template-rows,opacity] duration-200 ease-out motion-reduce:transition-none",
4267
6165
  open ? "grid-rows-[1fr] opacity-100" : "grid-rows-[0fr] opacity-0"
4268
6166
  ),
4269
- children: /* @__PURE__ */ jsx44("div", { className: "min-h-0 overflow-hidden", children: /* @__PURE__ */ jsx44("div", { className: "pb-4 text-sm leading-relaxed text-[var(--color-text-muted)]", children }) })
6167
+ children: /* @__PURE__ */ jsx44("div", { className: "min-h-0 overflow-hidden", children: /* @__PURE__ */ jsx44("div", { className: "pb-4 text-sm leading-relaxed text-(--color-text-muted)", children }) })
4270
6168
  }
4271
6169
  )
4272
6170
  ]