@yuno-payments/dashboard-design-system 0.0.164 → 0.0.165
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.
|
@@ -1,134 +1,158 @@
|
|
|
1
|
-
import { j as
|
|
2
|
-
import { forwardRef as
|
|
3
|
-
import { cn as
|
|
4
|
-
import { Field as
|
|
5
|
-
import { Badge as
|
|
6
|
-
import { Icon as
|
|
7
|
-
const
|
|
1
|
+
import { j as r } from "../../../_virtual/jsx-runtime.js";
|
|
2
|
+
import { forwardRef as O, useId as Q, useState as b } from "react";
|
|
3
|
+
import { cn as y } from "../../../lib/utils.js";
|
|
4
|
+
import { Field as U, FieldLabel as W, FieldDescription as Y, FieldError as Z } from "../../../vendor/shadcn/field.js";
|
|
5
|
+
import { Badge as E } from "../badge/badge.js";
|
|
6
|
+
import { Icon as _ } from "../icon/icon.js";
|
|
7
|
+
const A = O(
|
|
8
8
|
({
|
|
9
9
|
value: t = [],
|
|
10
|
-
onChange:
|
|
11
|
-
label:
|
|
12
|
-
description:
|
|
13
|
-
error:
|
|
14
|
-
placeholder:
|
|
15
|
-
disabled:
|
|
16
|
-
id:
|
|
10
|
+
onChange: p,
|
|
11
|
+
label: w,
|
|
12
|
+
description: f,
|
|
13
|
+
error: k,
|
|
14
|
+
placeholder: v = "Type and press Enter...",
|
|
15
|
+
disabled: l = !1,
|
|
16
|
+
id: C,
|
|
17
17
|
name: V,
|
|
18
|
-
triggerKeys:
|
|
18
|
+
triggerKeys: c = ["Enter", "Tab", "Comma", "Space"],
|
|
19
19
|
addOnBlur: B = !0,
|
|
20
|
-
allowDuplicates:
|
|
21
|
-
maxItems:
|
|
22
|
-
validate:
|
|
23
|
-
badgeVariant:
|
|
24
|
-
orientation:
|
|
25
|
-
className:
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
20
|
+
allowDuplicates: I = !1,
|
|
21
|
+
maxItems: m,
|
|
22
|
+
validate: j,
|
|
23
|
+
badgeVariant: N = "outline",
|
|
24
|
+
orientation: $ = "vertical",
|
|
25
|
+
className: T,
|
|
26
|
+
deleteAll: a
|
|
27
|
+
}, R) => {
|
|
28
|
+
const M = Q(), o = C || M, h = !!k, [x, D] = b(""), [S, F] = b(!1), [g, i] = b(""), s = (e) => {
|
|
29
|
+
const n = e.trim();
|
|
30
|
+
if (n !== "") {
|
|
31
|
+
if (m && t.length >= m) {
|
|
32
|
+
i(`Maximum ${m} items allowed`);
|
|
32
33
|
return;
|
|
33
34
|
}
|
|
34
|
-
if (!
|
|
35
|
-
|
|
35
|
+
if (!I && t.includes(n)) {
|
|
36
|
+
i("Duplicate values are not allowed");
|
|
36
37
|
return;
|
|
37
38
|
}
|
|
38
|
-
if (
|
|
39
|
-
const
|
|
40
|
-
if (
|
|
41
|
-
|
|
42
|
-
typeof
|
|
39
|
+
if (j) {
|
|
40
|
+
const d = j(n);
|
|
41
|
+
if (d !== !0) {
|
|
42
|
+
i(
|
|
43
|
+
typeof d == "string" ? d : "Invalid value"
|
|
43
44
|
);
|
|
44
45
|
return;
|
|
45
46
|
}
|
|
46
47
|
}
|
|
47
|
-
|
|
48
|
+
i(""), p([...t, n]), D("");
|
|
48
49
|
}
|
|
49
|
-
},
|
|
50
|
-
|
|
51
|
-
},
|
|
52
|
-
const
|
|
53
|
-
e.key === "Enter" &&
|
|
54
|
-
},
|
|
55
|
-
|
|
56
|
-
},
|
|
57
|
-
|
|
58
|
-
},
|
|
59
|
-
|
|
60
|
-
},
|
|
61
|
-
e.preventDefault(), e.stopPropagation(),
|
|
62
|
-
},
|
|
63
|
-
|
|
64
|
-
|
|
50
|
+
}, P = (e) => {
|
|
51
|
+
p(t.filter((n) => n !== e)), i("");
|
|
52
|
+
}, L = (e) => {
|
|
53
|
+
const n = e.currentTarget.value;
|
|
54
|
+
e.key === "Enter" && c.includes("Enter") ? (e.preventDefault(), s(n)) : e.key === "Tab" && c.includes("Tab") ? n.trim() !== "" && (e.preventDefault(), s(n)) : (e.key === "," || e.key === ",") && c.includes("Comma") || e.key === " " && c.includes("Space") ? (e.preventDefault(), s(n)) : e.key === "Backspace" && n === "" && t.length > 0 && p(t.slice(0, -1));
|
|
55
|
+
}, X = (e) => {
|
|
56
|
+
D(e.target.value), i("");
|
|
57
|
+
}, q = () => {
|
|
58
|
+
F(!0);
|
|
59
|
+
}, z = () => {
|
|
60
|
+
F(!1), B && x.trim() !== "" && s(x);
|
|
61
|
+
}, G = (e, n) => {
|
|
62
|
+
e.preventDefault(), e.stopPropagation(), P(n);
|
|
63
|
+
}, H = () => {
|
|
64
|
+
l || !a?.onClick || a.onClick();
|
|
65
|
+
}, u = k || g;
|
|
66
|
+
return /* @__PURE__ */ r.jsxs(
|
|
67
|
+
U,
|
|
65
68
|
{
|
|
66
|
-
orientation:
|
|
67
|
-
"data-invalid":
|
|
68
|
-
className:
|
|
69
|
+
orientation: $,
|
|
70
|
+
"data-invalid": h,
|
|
71
|
+
className: y("w-full", T),
|
|
69
72
|
children: [
|
|
70
|
-
|
|
71
|
-
/* @__PURE__ */
|
|
72
|
-
/* @__PURE__ */
|
|
73
|
+
w && /* @__PURE__ */ r.jsx(W, { htmlFor: o, children: w }),
|
|
74
|
+
/* @__PURE__ */ r.jsxs("div", { className: "flex flex-col gap-2 flex-1", children: [
|
|
75
|
+
/* @__PURE__ */ r.jsxs(
|
|
73
76
|
"div",
|
|
74
77
|
{
|
|
75
|
-
className:
|
|
78
|
+
className: y(
|
|
76
79
|
"font-normal file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input flex min-h-9 w-full min-w-0 rounded-md border bg-background px-3 py-1.5 text-base shadow-xs transition-[color,box-shadow] outline-none disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 text-sm",
|
|
77
80
|
"flex-wrap gap-1.5 items-center",
|
|
78
|
-
|
|
79
|
-
(
|
|
80
|
-
|
|
81
|
+
S && "border-ring ring-ring/50 ring-[3px]",
|
|
82
|
+
(h || g) && "border-destructive ring-destructive/20 dark:ring-destructive/40",
|
|
83
|
+
l && "opacity-50 cursor-not-allowed"
|
|
81
84
|
),
|
|
82
85
|
onClick: () => {
|
|
83
|
-
|
|
86
|
+
l || document.getElementById(o)?.focus();
|
|
84
87
|
},
|
|
85
88
|
children: [
|
|
86
|
-
|
|
87
|
-
e
|
|
88
|
-
/* @__PURE__ */
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
89
|
+
(() => {
|
|
90
|
+
const e = a && !l && t.length >= a.length;
|
|
91
|
+
return /* @__PURE__ */ r.jsxs(r.Fragment, { children: [
|
|
92
|
+
e && /* @__PURE__ */ r.jsx(
|
|
93
|
+
"div",
|
|
94
|
+
{
|
|
95
|
+
onClick: (n) => {
|
|
96
|
+
n.preventDefault(), n.stopPropagation(), H();
|
|
97
|
+
},
|
|
98
|
+
children: /* @__PURE__ */ r.jsx(
|
|
99
|
+
E,
|
|
100
|
+
{
|
|
101
|
+
variant: "secondary",
|
|
102
|
+
className: "gap-1 cursor-pointer flex items-center",
|
|
103
|
+
children: a.label || "Delete all"
|
|
104
|
+
}
|
|
105
|
+
)
|
|
106
|
+
}
|
|
107
|
+
),
|
|
108
|
+
t.map((n, d) => /* @__PURE__ */ r.jsxs(E, { variant: N, children: [
|
|
109
|
+
n,
|
|
110
|
+
/* @__PURE__ */ r.jsx(
|
|
111
|
+
"button",
|
|
112
|
+
{
|
|
113
|
+
type: "button",
|
|
114
|
+
onClick: (J) => G(J, n),
|
|
115
|
+
children: /* @__PURE__ */ r.jsx(_, { name: "X", className: "h-3 w-3" })
|
|
116
|
+
}
|
|
117
|
+
)
|
|
118
|
+
] }, `${n}-${d}`))
|
|
119
|
+
] });
|
|
120
|
+
})(),
|
|
121
|
+
/* @__PURE__ */ r.jsx(
|
|
98
122
|
"input",
|
|
99
123
|
{
|
|
100
|
-
ref:
|
|
124
|
+
ref: R,
|
|
101
125
|
id: o,
|
|
102
126
|
name: V,
|
|
103
127
|
type: "text",
|
|
104
128
|
value: x,
|
|
105
|
-
onChange:
|
|
106
|
-
onKeyDown:
|
|
107
|
-
onFocus:
|
|
108
|
-
onBlur:
|
|
109
|
-
placeholder: t.length === 0 ?
|
|
110
|
-
disabled:
|
|
111
|
-
className:
|
|
129
|
+
onChange: X,
|
|
130
|
+
onKeyDown: L,
|
|
131
|
+
onFocus: q,
|
|
132
|
+
onBlur: z,
|
|
133
|
+
placeholder: t.length === 0 ? v : "",
|
|
134
|
+
disabled: l,
|
|
135
|
+
className: y(
|
|
112
136
|
"flex-1 min-w-[120px] outline-none bg-transparent border-none shadow-none p-0 h-6",
|
|
113
137
|
"placeholder:text-muted-foreground",
|
|
114
138
|
"disabled:cursor-not-allowed"
|
|
115
139
|
),
|
|
116
|
-
"aria-invalid":
|
|
117
|
-
"aria-describedby":
|
|
140
|
+
"aria-invalid": h || !!g,
|
|
141
|
+
"aria-describedby": f || u ? `${o}-description` : void 0
|
|
118
142
|
}
|
|
119
143
|
)
|
|
120
144
|
]
|
|
121
145
|
}
|
|
122
146
|
),
|
|
123
|
-
|
|
124
|
-
|
|
147
|
+
f && !u && /* @__PURE__ */ r.jsx(Y, { id: `${o}-description`, children: f }),
|
|
148
|
+
u && /* @__PURE__ */ r.jsx(Z, { id: `${o}-description`, children: u })
|
|
125
149
|
] })
|
|
126
150
|
]
|
|
127
151
|
}
|
|
128
152
|
);
|
|
129
153
|
}
|
|
130
154
|
);
|
|
131
|
-
|
|
155
|
+
A.displayName = "MultiValuesField";
|
|
132
156
|
export {
|
|
133
|
-
|
|
157
|
+
A as MultiValuesField
|
|
134
158
|
};
|
|
@@ -81,4 +81,21 @@ export interface MultiValuesFieldProps {
|
|
|
81
81
|
* Additional CSS classes
|
|
82
82
|
*/
|
|
83
83
|
className?: string;
|
|
84
|
+
/**
|
|
85
|
+
* Configuration for "Delete All" chip functionality
|
|
86
|
+
*/
|
|
87
|
+
deleteAll?: {
|
|
88
|
+
/**
|
|
89
|
+
* Label for the delete all chip
|
|
90
|
+
*/
|
|
91
|
+
label?: string;
|
|
92
|
+
/**
|
|
93
|
+
* Minimum number of selected items to show delete all
|
|
94
|
+
*/
|
|
95
|
+
length: number;
|
|
96
|
+
/**
|
|
97
|
+
* Callback fired when delete all is clicked
|
|
98
|
+
*/
|
|
99
|
+
onClick: () => void;
|
|
100
|
+
};
|
|
84
101
|
}
|