@yuno-payments/dashboard-design-system 1.0.0 → 1.0.3
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/components/atoms/filter/filter-multi-input.d.ts +69 -0
- package/dist/components/atoms/filter/filter-multi-input.js +50 -0
- package/dist/components/atoms/filter/filter.js +34 -34
- package/dist/components/atoms/filter/index.d.ts +1 -0
- package/dist/components/atoms/filter-dropdown/filter-dropdown.js +12 -13
- package/dist/components/atoms/index.d.ts +1 -1
- package/dist/components/atoms/search-field/search-field.js +1 -1
- package/dist/components/atoms/time-picker/time-picker.js +38 -38
- package/dist/index.css +1 -1
- package/dist/index.js +134 -132
- package/dist/vendor/shadcn/card.js +14 -14
- package/dist/vendor/shadcn/combobox.js +1 -1
- package/dist/vendor/shadcn/dropdown-menu.js +2 -2
- package/package.json +1 -1
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Props for FilterMultiInput component
|
|
3
|
+
*/
|
|
4
|
+
export interface FilterMultiInputProps {
|
|
5
|
+
/**
|
|
6
|
+
* Title displayed above the input section
|
|
7
|
+
*/
|
|
8
|
+
title: string;
|
|
9
|
+
/**
|
|
10
|
+
* Current array of values
|
|
11
|
+
*/
|
|
12
|
+
value: string[];
|
|
13
|
+
/**
|
|
14
|
+
* Callback fired when values change
|
|
15
|
+
*/
|
|
16
|
+
onChange: (values: string[]) => void;
|
|
17
|
+
/**
|
|
18
|
+
* Placeholder text for the input
|
|
19
|
+
*/
|
|
20
|
+
placeholder?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Helper text displayed below the title
|
|
23
|
+
*/
|
|
24
|
+
description?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Error message to display
|
|
27
|
+
*/
|
|
28
|
+
error?: string;
|
|
29
|
+
/**
|
|
30
|
+
* Whether to only allow numeric values
|
|
31
|
+
* @default false
|
|
32
|
+
*/
|
|
33
|
+
numericOnly?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Maximum number of values allowed
|
|
36
|
+
*/
|
|
37
|
+
maxItems?: number;
|
|
38
|
+
/**
|
|
39
|
+
* Whether the field is disabled
|
|
40
|
+
* @default false
|
|
41
|
+
*/
|
|
42
|
+
disabled?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Additional CSS classes
|
|
45
|
+
*/
|
|
46
|
+
className?: string;
|
|
47
|
+
/**
|
|
48
|
+
* Whether to allow duplicate values
|
|
49
|
+
* @default false
|
|
50
|
+
*/
|
|
51
|
+
allowDuplicates?: boolean;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Filter section component for entering multiple values via an input field.
|
|
55
|
+
* Values are displayed as badges/tags and can be removed individually.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```tsx
|
|
59
|
+
* <FilterMultiInput
|
|
60
|
+
* title="BIN Filter"
|
|
61
|
+
* value={selectedBins}
|
|
62
|
+
* onChange={setSelectedBins}
|
|
63
|
+
* placeholder="Enter BIN(s) separated by comma"
|
|
64
|
+
* numericOnly
|
|
65
|
+
* />
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
declare const FilterMultiInput: import('react').ForwardRefExoticComponent<FilterMultiInputProps & import('react').RefAttributes<HTMLDivElement>>;
|
|
69
|
+
export { FilterMultiInput };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { j as e } from "../../../_virtual/jsx-runtime.js";
|
|
2
|
+
import { forwardRef as x } from "react";
|
|
3
|
+
import { cn as j } from "../../../lib/utils.js";
|
|
4
|
+
import { Separator as b } from "../../../vendor/shadcn/separator.js";
|
|
5
|
+
import { MultiValuesField as h } from "../multi-values-field/multi-values-field.js";
|
|
6
|
+
const v = x(
|
|
7
|
+
({
|
|
8
|
+
title: t,
|
|
9
|
+
value: l,
|
|
10
|
+
onChange: r,
|
|
11
|
+
placeholder: s = "Type and press Enter...",
|
|
12
|
+
description: a,
|
|
13
|
+
error: i,
|
|
14
|
+
numericOnly: o = !1,
|
|
15
|
+
maxItems: m,
|
|
16
|
+
disabled: n = !1,
|
|
17
|
+
className: f,
|
|
18
|
+
allowDuplicates: d = !1
|
|
19
|
+
}, u) => {
|
|
20
|
+
const c = o ? (p) => /^\d+$/.test(p) ? !0 : "Only numeric values are allowed" : void 0;
|
|
21
|
+
return /* @__PURE__ */ e.jsxs("div", { ref: u, className: j("flex flex-col h-full", f), children: [
|
|
22
|
+
/* @__PURE__ */ e.jsx("div", { className: "flex items-center justify-between mb-1", children: /* @__PURE__ */ e.jsx("span", { className: "text-sm font-normal text-foreground", children: t }) }),
|
|
23
|
+
/* @__PURE__ */ e.jsx(b, { className: "w-full mb-6" }),
|
|
24
|
+
/* @__PURE__ */ e.jsx(
|
|
25
|
+
h,
|
|
26
|
+
{
|
|
27
|
+
value: l,
|
|
28
|
+
onChange: r,
|
|
29
|
+
placeholder: s,
|
|
30
|
+
description: a,
|
|
31
|
+
error: i,
|
|
32
|
+
disabled: n,
|
|
33
|
+
maxItems: m,
|
|
34
|
+
allowDuplicates: d,
|
|
35
|
+
validate: c,
|
|
36
|
+
triggerKeys: ["Enter", "Tab", "Comma"],
|
|
37
|
+
deleteAll: l.length > 0 ? {
|
|
38
|
+
label: "Clear all",
|
|
39
|
+
length: 1,
|
|
40
|
+
onClick: () => r([])
|
|
41
|
+
} : void 0
|
|
42
|
+
}
|
|
43
|
+
)
|
|
44
|
+
] });
|
|
45
|
+
}
|
|
46
|
+
);
|
|
47
|
+
v.displayName = "FilterMultiInput";
|
|
48
|
+
export {
|
|
49
|
+
v as FilterMultiInput
|
|
50
|
+
};
|
|
@@ -40,25 +40,25 @@ const X = x(
|
|
|
40
40
|
onClearAll: n,
|
|
41
41
|
maxVisibleTags: t = 4,
|
|
42
42
|
className: i,
|
|
43
|
-
...
|
|
44
|
-
},
|
|
45
|
-
const
|
|
43
|
+
...c
|
|
44
|
+
}, d) => {
|
|
45
|
+
const o = s.length > 0, N = s.slice(0, t), g = s.length - t;
|
|
46
46
|
return /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-4", children: [
|
|
47
47
|
/* @__PURE__ */ e.jsxs(
|
|
48
48
|
f,
|
|
49
49
|
{
|
|
50
|
-
ref:
|
|
50
|
+
ref: d,
|
|
51
51
|
variant: "outline",
|
|
52
52
|
size: "sm",
|
|
53
53
|
className: u("h-8 gap-2 px-3 py-2", i),
|
|
54
|
-
...
|
|
54
|
+
...c,
|
|
55
55
|
children: [
|
|
56
56
|
/* @__PURE__ */ e.jsx(y, { name: "FunnelSimple", className: "size-4" }),
|
|
57
57
|
/* @__PURE__ */ e.jsx("span", { className: "text-xs font-medium leading-none", children: "Add filter" })
|
|
58
58
|
]
|
|
59
59
|
}
|
|
60
60
|
),
|
|
61
|
-
|
|
61
|
+
o && /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
|
|
62
62
|
/* @__PURE__ */ e.jsx(v, { orientation: "vertical", className: "h-5" }),
|
|
63
63
|
/* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-2", children: [
|
|
64
64
|
N.map((h) => /* @__PURE__ */ e.jsx(
|
|
@@ -86,7 +86,7 @@ const X = x(
|
|
|
86
86
|
)
|
|
87
87
|
] })
|
|
88
88
|
] }),
|
|
89
|
-
!
|
|
89
|
+
!o && /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
|
|
90
90
|
/* @__PURE__ */ e.jsx(v, { orientation: "vertical", className: "h-5" }),
|
|
91
91
|
/* @__PURE__ */ e.jsx("span", { className: "text-sm font-normal text-muted-foreground", children: "No filters applied" })
|
|
92
92
|
] })
|
|
@@ -100,38 +100,38 @@ const q = x(
|
|
|
100
100
|
title: n,
|
|
101
101
|
items: t,
|
|
102
102
|
className: i,
|
|
103
|
-
searchable:
|
|
104
|
-
searchPlaceholder:
|
|
105
|
-
showActions:
|
|
103
|
+
searchable: c = !1,
|
|
104
|
+
searchPlaceholder: d = "Search...",
|
|
105
|
+
showActions: o = !1,
|
|
106
106
|
enableSelectAll: N = !0,
|
|
107
107
|
enableInverse: g = !0,
|
|
108
108
|
enableNone: h = !0,
|
|
109
109
|
description: b
|
|
110
|
-
} = s,
|
|
110
|
+
} = s, m = s.type || "checkbox", z = m === "radio", I = m === "checkbox" || !s.type, [j, R] = M(""), C = $(() => j ? t.filter(
|
|
111
111
|
(a) => a.label.toLowerCase().includes(j.toLowerCase())
|
|
112
112
|
) : t, [t, j]), T = () => {
|
|
113
|
-
if (
|
|
114
|
-
const a = t.map((
|
|
113
|
+
if (m === "checkbox" && "selectedValues" in s) {
|
|
114
|
+
const a = t.map((r) => r.value);
|
|
115
115
|
s.onChange(a);
|
|
116
116
|
}
|
|
117
117
|
}, P = () => {
|
|
118
|
-
if (
|
|
119
|
-
const a = t.filter((
|
|
118
|
+
if (m === "checkbox" && "selectedValues" in s) {
|
|
119
|
+
const a = t.filter((r) => !s.selectedValues.includes(r.value)).map((r) => r.value);
|
|
120
120
|
s.onChange(a);
|
|
121
121
|
}
|
|
122
122
|
}, B = () => {
|
|
123
|
-
|
|
124
|
-
}, G = (a) => {
|
|
125
|
-
if (
|
|
126
|
-
const O = s.selectedValues
|
|
123
|
+
m === "checkbox" && "selectedValues" in s ? s.onChange([]) : m === "radio" && "selectedValue" in s && s.onChange("");
|
|
124
|
+
}, G = (a, r) => {
|
|
125
|
+
if (m === "checkbox" && "selectedValues" in s) {
|
|
126
|
+
const O = r ? [...s.selectedValues, a] : s.selectedValues.filter((A) => A !== a);
|
|
127
127
|
s.onChange(O);
|
|
128
128
|
}
|
|
129
129
|
};
|
|
130
130
|
return /* @__PURE__ */ e.jsxs("div", { ref: l, className: u("flex flex-col h-full", i), children: [
|
|
131
|
-
|
|
131
|
+
c && /* @__PURE__ */ e.jsx(
|
|
132
132
|
w,
|
|
133
133
|
{
|
|
134
|
-
placeholder:
|
|
134
|
+
placeholder: d,
|
|
135
135
|
value: j,
|
|
136
136
|
onChange: (a) => R(a.target.value),
|
|
137
137
|
startIcon: "MagnifyingGlass",
|
|
@@ -141,7 +141,7 @@ const q = x(
|
|
|
141
141
|
b && /* @__PURE__ */ e.jsx("p", { className: "text-xs font-normal text-muted-foreground mb-4", children: b }),
|
|
142
142
|
/* @__PURE__ */ e.jsxs("div", { className: "flex items-center justify-between mb-1", children: [
|
|
143
143
|
/* @__PURE__ */ e.jsx("span", { className: "text-sm font-normal text-foreground", children: n }),
|
|
144
|
-
|
|
144
|
+
o && m === "checkbox" && /* @__PURE__ */ e.jsxs("div", { className: "flex items-center justify-end gap-4", children: [
|
|
145
145
|
N && /* @__PURE__ */ e.jsx(
|
|
146
146
|
f,
|
|
147
147
|
{
|
|
@@ -198,7 +198,7 @@ const q = x(
|
|
|
198
198
|
description: a.description,
|
|
199
199
|
icon: a.icon,
|
|
200
200
|
checked: s.selectedValues.includes(a.value),
|
|
201
|
-
onCheckedChange: () => G(a.value)
|
|
201
|
+
onCheckedChange: (r) => G(a.value, r)
|
|
202
202
|
},
|
|
203
203
|
a.value
|
|
204
204
|
)) }) : null
|
|
@@ -206,16 +206,16 @@ const q = x(
|
|
|
206
206
|
}
|
|
207
207
|
);
|
|
208
208
|
q.displayName = "FilterSection";
|
|
209
|
-
const V = x(({ label: s, checked: l, onCheckedChange: n, description: t, className: i, icon:
|
|
210
|
-
/* @__PURE__ */ e.jsx(E, { ref:
|
|
211
|
-
|
|
209
|
+
const V = x(({ label: s, checked: l, onCheckedChange: n, description: t, className: i, icon: c }, d) => /* @__PURE__ */ e.jsxs("label", { className: u("flex items-start gap-2 cursor-pointer", i), children: [
|
|
210
|
+
/* @__PURE__ */ e.jsx(E, { ref: d, checked: l, onCheckedChange: n }),
|
|
211
|
+
c && /* @__PURE__ */ e.jsx(
|
|
212
212
|
"img",
|
|
213
213
|
{
|
|
214
|
-
src:
|
|
214
|
+
src: c,
|
|
215
215
|
alt: "",
|
|
216
216
|
className: "size-4 object-contain shrink-0",
|
|
217
|
-
onError: (
|
|
218
|
-
|
|
217
|
+
onError: (o) => {
|
|
218
|
+
o.currentTarget.style.display = "none";
|
|
219
219
|
}
|
|
220
220
|
}
|
|
221
221
|
),
|
|
@@ -249,14 +249,14 @@ const D = x(
|
|
|
249
249
|
searchPlaceholder: n = "Search...",
|
|
250
250
|
searchValue: t,
|
|
251
251
|
onSearchChange: i,
|
|
252
|
-
className:
|
|
253
|
-
},
|
|
252
|
+
className: c
|
|
253
|
+
}, d) => /* @__PURE__ */ e.jsxs(
|
|
254
254
|
"div",
|
|
255
255
|
{
|
|
256
|
-
ref:
|
|
256
|
+
ref: d,
|
|
257
257
|
className: u(
|
|
258
258
|
"flex flex-col gap-6 bg-input rounded-md p-6 min-w-[448px]",
|
|
259
|
-
|
|
259
|
+
c
|
|
260
260
|
),
|
|
261
261
|
children: [
|
|
262
262
|
l && /* @__PURE__ */ e.jsx("div", { className: "flex flex-col gap-2", children: /* @__PURE__ */ e.jsxs("div", { className: "relative", children: [
|
|
@@ -272,7 +272,7 @@ const D = x(
|
|
|
272
272
|
{
|
|
273
273
|
placeholder: n,
|
|
274
274
|
value: t,
|
|
275
|
-
onChange: (
|
|
275
|
+
onChange: (o) => i?.(o.target.value),
|
|
276
276
|
className: "pl-9"
|
|
277
277
|
}
|
|
278
278
|
)
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
export { FilterButton, FilterTag, FilterSection, FilterCheckboxOption, FilterRadioOption, FilterContent, type FilterButtonProps, type FilterTagProps, type FilterSectionProps, type FilterCheckboxOptionProps, type FilterRadioOptionProps, type FilterContentProps, } from './filter';
|
|
2
2
|
export { FilterDateRange, FilterDateRangeOption, FilterDateRangeValue, type FilterDateRangeProps, type FilterDateRangeOptionProps, } from './filter-date-range';
|
|
3
|
+
export { FilterMultiInput, type FilterMultiInputProps, } from './filter-multi-input';
|
|
@@ -1,25 +1,24 @@
|
|
|
1
1
|
import { j as n } from "../../../_virtual/jsx-runtime.js";
|
|
2
|
-
import { forwardRef as
|
|
2
|
+
import { forwardRef as j, useState as E, useCallback as S, useRef as X, useEffect as Y } from "react";
|
|
3
3
|
import { Button as b } from "../../../vendor/shadcn/button.js";
|
|
4
4
|
import { Separator as k } from "../../../vendor/shadcn/separator.js";
|
|
5
|
-
import { Icon as
|
|
5
|
+
import { Icon as v } from "../icon/icon.js";
|
|
6
6
|
import { FilterSection as M } from "../filter/filter.js";
|
|
7
7
|
import { FilterDateRange as $, FilterDateRangeValue as C } from "../filter/filter-date-range.js";
|
|
8
8
|
import { cn as d } from "../../../lib/utils.js";
|
|
9
|
-
const A =
|
|
9
|
+
const A = j(
|
|
10
10
|
({ icon: r, label: h, isActive: l = !1, showChevron: m = !1, className: u, ...o }, p) => /* @__PURE__ */ n.jsxs(
|
|
11
11
|
"button",
|
|
12
12
|
{
|
|
13
13
|
ref: p,
|
|
14
14
|
className: d(
|
|
15
|
-
"flex items-center gap-2 h-8 px-2 rounded-md w-full transition-colors",
|
|
16
|
-
"hover:bg-secondary",
|
|
15
|
+
"flex items-center gap-2 h-8 px-2 rounded-md w-full transition-colors shrink-0 hover:bg-secondary",
|
|
17
16
|
u
|
|
18
17
|
),
|
|
19
18
|
...o,
|
|
20
19
|
children: [
|
|
21
20
|
r && /* @__PURE__ */ n.jsx(
|
|
22
|
-
|
|
21
|
+
v,
|
|
23
22
|
{
|
|
24
23
|
name: r,
|
|
25
24
|
className: d(
|
|
@@ -39,7 +38,7 @@ const A = v(
|
|
|
39
38
|
}
|
|
40
39
|
),
|
|
41
40
|
(l || m) && /* @__PURE__ */ n.jsx(
|
|
42
|
-
|
|
41
|
+
v,
|
|
43
42
|
{
|
|
44
43
|
name: "CaretRight",
|
|
45
44
|
className: d(
|
|
@@ -53,13 +52,13 @@ const A = v(
|
|
|
53
52
|
)
|
|
54
53
|
);
|
|
55
54
|
A.displayName = "FilterMenuItem";
|
|
56
|
-
const V =
|
|
55
|
+
const V = j(
|
|
57
56
|
({ items: r, activeItemId: h, onItemClick: l, className: m }, u) => /* @__PURE__ */ n.jsx(
|
|
58
57
|
"div",
|
|
59
58
|
{
|
|
60
59
|
ref: u,
|
|
61
60
|
className: d(
|
|
62
|
-
"flex flex-col gap-2 w-64 h-full p-2 bg-surface border border-border rounded-md",
|
|
61
|
+
"flex flex-col gap-2 w-64 h-full p-2 bg-surface border border-border rounded-md overflow-y-auto",
|
|
63
62
|
m
|
|
64
63
|
),
|
|
65
64
|
children: r.map((o) => /* @__PURE__ */ n.jsx(
|
|
@@ -77,7 +76,7 @@ const V = v(
|
|
|
77
76
|
)
|
|
78
77
|
);
|
|
79
78
|
V.displayName = "FilterMenu";
|
|
80
|
-
const q =
|
|
79
|
+
const q = j(
|
|
81
80
|
({
|
|
82
81
|
filters: r,
|
|
83
82
|
buttonText: h = "Add filter",
|
|
@@ -234,7 +233,7 @@ const q = v(
|
|
|
234
233
|
onClick: () => g(!x),
|
|
235
234
|
disabled: O,
|
|
236
235
|
children: [
|
|
237
|
-
/* @__PURE__ */ n.jsx(
|
|
236
|
+
/* @__PURE__ */ n.jsx(v, { name: "FunnelSimple", className: "size-4" }),
|
|
238
237
|
h
|
|
239
238
|
]
|
|
240
239
|
}
|
|
@@ -261,7 +260,7 @@ const q = v(
|
|
|
261
260
|
},
|
|
262
261
|
className: "inline-flex items-center justify-center",
|
|
263
262
|
"aria-label": `Remove ${t.label} filter`,
|
|
264
|
-
children: /* @__PURE__ */ n.jsx(
|
|
263
|
+
children: /* @__PURE__ */ n.jsx(v, { name: "X", className: "size-4" })
|
|
265
264
|
}
|
|
266
265
|
)
|
|
267
266
|
]
|
|
@@ -294,7 +293,7 @@ const q = v(
|
|
|
294
293
|
"div",
|
|
295
294
|
{
|
|
296
295
|
className: d(
|
|
297
|
-
"z-
|
|
296
|
+
"z-popover shadow-lg",
|
|
298
297
|
"absolute top-full left-0 mt-1",
|
|
299
298
|
"flex flex-row gap-2",
|
|
300
299
|
"w-[728px] h-[448px]",
|
|
@@ -10,7 +10,7 @@ export { CurrencyField, type CurrencyFieldProps } from './currency-field';
|
|
|
10
10
|
export { DatePicker, type DatePickerProps } from './date-picker';
|
|
11
11
|
export { DateRangePicker, type DateRangePickerProps, } from './date-range-picker';
|
|
12
12
|
export { TimePicker, type TimePickerProps } from './time-picker';
|
|
13
|
-
export { FilterButton, FilterTag, FilterSection, FilterCheckboxOption, FilterRadioOption, FilterContent, FilterDateRange, FilterDateRangeOption, FilterDateRangeValue, type FilterButtonProps, type FilterTagProps, type FilterSectionProps, type FilterCheckboxOptionProps, type FilterRadioOptionProps, type FilterContentProps, type FilterDateRangeProps, type FilterDateRangeOptionProps, } from './filter';
|
|
13
|
+
export { FilterButton, FilterTag, FilterSection, FilterCheckboxOption, FilterRadioOption, FilterContent, FilterDateRange, FilterDateRangeOption, FilterDateRangeValue, FilterMultiInput, type FilterButtonProps, type FilterTagProps, type FilterSectionProps, type FilterCheckboxOptionProps, type FilterRadioOptionProps, type FilterContentProps, type FilterDateRangeProps, type FilterDateRangeOptionProps, type FilterMultiInputProps, } from './filter';
|
|
14
14
|
export { FilterDropdown, FilterMenu, FilterMenuItem, type FilterDropdownProps, type FilterConfig, type FilterMenuProps, type FilterMenuItemProps, } from './filter-dropdown';
|
|
15
15
|
export { DropdownMenu, DropdownMenuPortal, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuGroup, DropdownMenuLabel, DropdownMenuItem, DropdownMenuCheckboxItem, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubTrigger, DropdownMenuSubContent, type DropdownMenuProps, type DropdownMenuPortalProps, type DropdownMenuTriggerProps, type DropdownMenuContentProps, type DropdownMenuGroupProps, type DropdownMenuLabelProps, type DropdownMenuItemProps, type DropdownMenuCheckboxItemProps, type DropdownMenuRadioGroupProps, type DropdownMenuRadioItemProps, type DropdownMenuSeparatorProps, type DropdownMenuShortcutProps, type DropdownMenuSubProps, type DropdownMenuSubTriggerProps, type DropdownMenuSubContentProps, } from './dropdown-menu';
|
|
16
16
|
export { DotsMenu, type DotsMenuProps, type DotsMenuAction, type DotsMenuOptions, } from './dots-menu';
|
|
@@ -150,7 +150,7 @@ const P = D("flex gap-2 w-full", {
|
|
|
150
150
|
onMouseEnter: () => I(!0),
|
|
151
151
|
onMouseLeave: () => I(!1),
|
|
152
152
|
className: r(
|
|
153
|
-
"absolute z-
|
|
153
|
+
"absolute z-popover w-full mt-1 rounded-md border bg-popover text-popover-foreground shadow-md",
|
|
154
154
|
"max-h-[300px] overflow-y-auto"
|
|
155
155
|
),
|
|
156
156
|
children: /* @__PURE__ */ t.jsx("div", { className: "py-1", children: C.map((e, s) => /* @__PURE__ */ t.jsx(
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { j as
|
|
1
|
+
import { j as r } from "../../../_virtual/jsx-runtime.js";
|
|
2
2
|
import * as G from "react";
|
|
3
3
|
import { useId as J, useState as $, useRef as C, useEffect as E } from "react";
|
|
4
4
|
import { cn as c } from "../../../lib/utils.js";
|
|
5
5
|
import { Icon as K } from "../icon/icon.js";
|
|
6
6
|
import { TimePicker as Q } from "../../../vendor/shadcn/time-picker.js";
|
|
7
7
|
import { Field as R, FieldLabel as T, FieldDescription as O, FieldError as _ } from "../../../vendor/shadcn/field.js";
|
|
8
|
-
const X = Array.from({ length: 12 }, (e,
|
|
8
|
+
const X = Array.from({ length: 12 }, (e, n) => n + 1), Y = Array.from({ length: 24 }, (e, n) => n), Z = ["AM", "PM"], H = (e) => {
|
|
9
9
|
if (e === 0)
|
|
10
10
|
return Array.from({ length: 60 }, (o, i) => i);
|
|
11
|
-
const
|
|
12
|
-
return Array.from({ length:
|
|
11
|
+
const n = 60 / e;
|
|
12
|
+
return Array.from({ length: n }, (o, i) => i * e);
|
|
13
13
|
}, d = (e) => e.toString().padStart(2, "0"), ee = (e) => {
|
|
14
|
-
const
|
|
15
|
-
return { hour: e === 0 ? 12 : e > 12 ? e - 12 : e, meridiem:
|
|
16
|
-
}, te = (e,
|
|
14
|
+
const n = e >= 12 ? "PM" : "AM";
|
|
15
|
+
return { hour: e === 0 ? 12 : e > 12 ? e - 12 : e, meridiem: n };
|
|
16
|
+
}, te = (e, n) => e === 12 ? n === "AM" ? 0 : 12 : n === "PM" ? e + 12 : e, re = G.forwardRef(
|
|
17
17
|
({
|
|
18
18
|
className: e,
|
|
19
|
-
label:
|
|
19
|
+
label: n,
|
|
20
20
|
error: o,
|
|
21
21
|
description: i,
|
|
22
22
|
orientation: x = "vertical",
|
|
@@ -32,7 +32,7 @@ const X = Array.from({ length: 12 }, (e, r) => r + 1), Y = Array.from({ length:
|
|
|
32
32
|
}, P) => {
|
|
33
33
|
const S = J(), u = m || S, v = !!o;
|
|
34
34
|
if (y === "native") {
|
|
35
|
-
const k = /* @__PURE__ */
|
|
35
|
+
const k = /* @__PURE__ */ r.jsx(
|
|
36
36
|
Q,
|
|
37
37
|
{
|
|
38
38
|
ref: P,
|
|
@@ -41,7 +41,7 @@ const X = Array.from({ length: 12 }, (e, r) => r + 1), Y = Array.from({ length:
|
|
|
41
41
|
disabled: p,
|
|
42
42
|
className: c(
|
|
43
43
|
v && "border-destructive focus-visible:border-destructive",
|
|
44
|
-
!(
|
|
44
|
+
!(n || o || i) && e
|
|
45
45
|
),
|
|
46
46
|
"aria-invalid": v ? !0 : void 0,
|
|
47
47
|
"aria-describedby": i || o ? `${u}-description` : void 0,
|
|
@@ -51,31 +51,31 @@ const X = Array.from({ length: 12 }, (e, r) => r + 1), Y = Array.from({ length:
|
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
);
|
|
54
|
-
return
|
|
54
|
+
return n || o || i ? /* @__PURE__ */ r.jsxs(
|
|
55
55
|
R,
|
|
56
56
|
{
|
|
57
57
|
orientation: x,
|
|
58
58
|
"data-invalid": v,
|
|
59
59
|
className: c("w-full", e),
|
|
60
60
|
children: [
|
|
61
|
-
|
|
62
|
-
/* @__PURE__ */
|
|
61
|
+
n && /* @__PURE__ */ r.jsx(T, { htmlFor: u, children: n }),
|
|
62
|
+
/* @__PURE__ */ r.jsxs("div", { className: "flex flex-col gap-2 flex-1", children: [
|
|
63
63
|
k,
|
|
64
|
-
i && !o && /* @__PURE__ */
|
|
65
|
-
o && /* @__PURE__ */
|
|
64
|
+
i && !o && /* @__PURE__ */ r.jsx(O, { id: `${u}-description`, children: i }),
|
|
65
|
+
o && /* @__PURE__ */ r.jsx(_, { id: `${u}-description`, children: o })
|
|
66
66
|
] })
|
|
67
67
|
]
|
|
68
68
|
}
|
|
69
69
|
) : k;
|
|
70
70
|
}
|
|
71
|
-
return /* @__PURE__ */
|
|
72
|
-
|
|
71
|
+
return /* @__PURE__ */ r.jsx(
|
|
72
|
+
ne,
|
|
73
73
|
{
|
|
74
74
|
value: l || (w ? "00:00" : "12:00"),
|
|
75
75
|
onChange: f,
|
|
76
76
|
divisorMinutes: j,
|
|
77
77
|
width: s,
|
|
78
|
-
label:
|
|
78
|
+
label: n,
|
|
79
79
|
error: o,
|
|
80
80
|
description: i,
|
|
81
81
|
disabled: p,
|
|
@@ -85,10 +85,10 @@ const X = Array.from({ length: 12 }, (e, r) => r + 1), Y = Array.from({ length:
|
|
|
85
85
|
);
|
|
86
86
|
}
|
|
87
87
|
);
|
|
88
|
-
|
|
89
|
-
const
|
|
88
|
+
re.displayName = "TimePicker";
|
|
89
|
+
const ne = ({
|
|
90
90
|
value: e,
|
|
91
|
-
onChange:
|
|
91
|
+
onChange: n,
|
|
92
92
|
divisorMinutes: o,
|
|
93
93
|
width: i,
|
|
94
94
|
label: x,
|
|
@@ -109,22 +109,22 @@ const re = ({
|
|
|
109
109
|
let t;
|
|
110
110
|
s ? t = a : t = te(a, M);
|
|
111
111
|
const g = `${d(t)}:${d(b)}`;
|
|
112
|
-
|
|
113
|
-
}, [a, b, M,
|
|
112
|
+
n?.(g);
|
|
113
|
+
}, [a, b, M, n, s]), E(() => {
|
|
114
114
|
const t = (g) => {
|
|
115
115
|
h.current && !h.current.contains(g.target) && p(!1);
|
|
116
116
|
};
|
|
117
117
|
if (l)
|
|
118
118
|
return document.addEventListener("mousedown", t), () => document.removeEventListener("mousedown", t);
|
|
119
119
|
}, [l]);
|
|
120
|
-
const V = s ? `${d(a)}:${d(b)}` : `${d(a)}:${d(b)} ${M}`, z = s ? Y : X, I = /* @__PURE__ */
|
|
120
|
+
const V = s ? `${d(a)}:${d(b)}` : `${d(a)}:${d(b)} ${M}`, z = s ? Y : X, I = /* @__PURE__ */ r.jsxs(
|
|
121
121
|
"div",
|
|
122
122
|
{
|
|
123
123
|
ref: h,
|
|
124
124
|
className: c("relative inline-block", j),
|
|
125
125
|
style: { width: typeof i == "number" ? `${i}px` : i },
|
|
126
126
|
children: [
|
|
127
|
-
/* @__PURE__ */
|
|
127
|
+
/* @__PURE__ */ r.jsxs(
|
|
128
128
|
"button",
|
|
129
129
|
{
|
|
130
130
|
type: "button",
|
|
@@ -139,8 +139,8 @@ const re = ({
|
|
|
139
139
|
m && "border-destructive"
|
|
140
140
|
),
|
|
141
141
|
children: [
|
|
142
|
-
/* @__PURE__ */
|
|
143
|
-
/* @__PURE__ */
|
|
142
|
+
/* @__PURE__ */ r.jsx("span", { children: V }),
|
|
143
|
+
/* @__PURE__ */ r.jsx(
|
|
144
144
|
K,
|
|
145
145
|
{
|
|
146
146
|
name: l ? "CaretUp" : "CaretDown",
|
|
@@ -151,17 +151,17 @@ const re = ({
|
|
|
151
151
|
]
|
|
152
152
|
}
|
|
153
153
|
),
|
|
154
|
-
l && /* @__PURE__ */
|
|
154
|
+
l && /* @__PURE__ */ r.jsxs(
|
|
155
155
|
"div",
|
|
156
156
|
{
|
|
157
157
|
ref: w,
|
|
158
158
|
className: c(
|
|
159
|
-
"absolute z-
|
|
159
|
+
"absolute z-popover mt-1 bg-popover border border-border rounded-md shadow-lg",
|
|
160
160
|
"flex divide-x divide-border"
|
|
161
161
|
),
|
|
162
162
|
style: { width: "fit-content", minWidth: s ? "140px" : "200px" },
|
|
163
163
|
children: [
|
|
164
|
-
/* @__PURE__ */
|
|
164
|
+
/* @__PURE__ */ r.jsx("div", { className: "flex flex-col overflow-y-auto max-h-[200px] min-w-[60px]", children: z.map((t) => /* @__PURE__ */ r.jsx(
|
|
165
165
|
"button",
|
|
166
166
|
{
|
|
167
167
|
type: "button",
|
|
@@ -174,7 +174,7 @@ const re = ({
|
|
|
174
174
|
},
|
|
175
175
|
t
|
|
176
176
|
)) }),
|
|
177
|
-
/* @__PURE__ */
|
|
177
|
+
/* @__PURE__ */ r.jsx("div", { className: "flex flex-col overflow-y-auto max-h-[200px] min-w-[60px]", children: U.map((t) => /* @__PURE__ */ r.jsx(
|
|
178
178
|
"button",
|
|
179
179
|
{
|
|
180
180
|
type: "button",
|
|
@@ -187,7 +187,7 @@ const re = ({
|
|
|
187
187
|
},
|
|
188
188
|
t
|
|
189
189
|
)) }),
|
|
190
|
-
!s && /* @__PURE__ */
|
|
190
|
+
!s && /* @__PURE__ */ r.jsx("div", { className: "flex flex-col min-w-[60px]", children: Z.map((t) => /* @__PURE__ */ r.jsx(
|
|
191
191
|
"button",
|
|
192
192
|
{
|
|
193
193
|
type: "button",
|
|
@@ -206,15 +206,15 @@ const re = ({
|
|
|
206
206
|
]
|
|
207
207
|
}
|
|
208
208
|
);
|
|
209
|
-
return x || m || f ? /* @__PURE__ */
|
|
210
|
-
x && /* @__PURE__ */
|
|
211
|
-
/* @__PURE__ */
|
|
209
|
+
return x || m || f ? /* @__PURE__ */ r.jsxs(R, { orientation: "vertical", className: c("w-full", j), children: [
|
|
210
|
+
x && /* @__PURE__ */ r.jsx(T, { children: x }),
|
|
211
|
+
/* @__PURE__ */ r.jsxs("div", { className: "flex flex-col gap-2 flex-1", children: [
|
|
212
212
|
I,
|
|
213
|
-
f && !m && /* @__PURE__ */
|
|
214
|
-
m && /* @__PURE__ */
|
|
213
|
+
f && !m && /* @__PURE__ */ r.jsx(O, { children: f }),
|
|
214
|
+
m && /* @__PURE__ */ r.jsx(_, { children: m })
|
|
215
215
|
] })
|
|
216
216
|
] }) : I;
|
|
217
217
|
};
|
|
218
218
|
export {
|
|
219
|
-
|
|
219
|
+
re as TimePicker
|
|
220
220
|
};
|