@brightlocal/ui-components 0.1.4 → 0.3.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/README.md +2 -1
- package/dist/alert.cjs +1 -1
- package/dist/alert.d.ts +10 -1
- package/dist/alert.d.ts.map +1 -1
- package/dist/alert.js +6 -2
- package/dist/card.cjs +1 -1
- package/dist/card.d.ts +6 -2
- package/dist/card.d.ts.map +1 -1
- package/dist/card.js +89 -73
- package/dist/centred-layout.cjs +1 -1
- package/dist/centred-layout.d.ts +49 -25
- package/dist/centred-layout.d.ts.map +1 -1
- package/dist/centred-layout.js +57 -32
- package/dist/checkbox.cjs +1 -1
- package/dist/checkbox.d.ts.map +1 -1
- package/dist/checkbox.js +19 -19
- package/dist/chip.cjs +1 -0
- package/dist/chip.d.ts +61 -0
- package/dist/chip.d.ts.map +1 -0
- package/dist/chip.js +165 -0
- package/dist/combobox.cjs +1 -1
- package/dist/combobox.d.ts +75 -59
- package/dist/combobox.d.ts.map +1 -1
- package/dist/combobox.js +244 -191
- package/dist/date-picker.cjs +1 -1
- package/dist/date-picker.d.ts +89 -52
- package/dist/date-picker.d.ts.map +1 -1
- package/dist/date-picker.js +228 -210
- package/dist/dropdown-menu.d.ts.map +1 -1
- package/dist/header.cjs +1 -0
- package/dist/header.d.ts +42 -0
- package/dist/header.d.ts.map +1 -0
- package/dist/header.js +22 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +428 -388
- package/dist/input-chip.cjs +1 -0
- package/dist/input-chip.d.ts +117 -0
- package/dist/input-chip.d.ts.map +1 -0
- package/dist/input-chip.js +284 -0
- package/dist/input-group.cjs +1 -1
- package/dist/input-group.d.ts +5 -0
- package/dist/input-group.d.ts.map +1 -1
- package/dist/input-group.js +47 -39
- package/dist/input-otp.cjs +1 -1
- package/dist/input-otp.d.ts +45 -32
- package/dist/input-otp.d.ts.map +1 -1
- package/dist/input-otp.js +138 -114
- package/dist/input-password.cjs +1 -1
- package/dist/input-password.d.ts +151 -19
- package/dist/input-password.d.ts.map +1 -1
- package/dist/input-password.js +197 -91
- package/dist/input.cjs +1 -1
- package/dist/input.d.ts +4 -0
- package/dist/input.d.ts.map +1 -1
- package/dist/input.js +26 -24
- package/dist/logo.cjs +1 -1
- package/dist/logo.js +13 -13
- package/dist/progress.cjs +1 -1
- package/dist/progress.d.ts +10 -0
- package/dist/progress.d.ts.map +1 -1
- package/dist/progress.js +45 -36
- package/dist/radio-group.cjs +1 -1
- package/dist/radio-group.d.ts +4 -0
- package/dist/radio-group.d.ts.map +1 -1
- package/dist/radio-group.js +49 -47
- package/dist/select.cjs +1 -1
- package/dist/select.d.ts +3 -1
- package/dist/select.d.ts.map +1 -1
- package/dist/select.js +57 -56
- package/dist/slider.cjs +1 -1
- package/dist/slider.d.ts +31 -3
- package/dist/slider.d.ts.map +1 -1
- package/dist/slider.js +53 -43
- package/dist/textarea.cjs +1 -1
- package/dist/textarea.d.ts +4 -0
- package/dist/textarea.d.ts.map +1 -1
- package/dist/textarea.js +19 -18
- package/dist/toggle.cjs +1 -1
- package/dist/toggle.d.ts.map +1 -1
- package/dist/toggle.js +17 -17
- package/package.json +1 -1
- package/src/components/alert.tsx +10 -1
- package/src/components/card.tsx +66 -38
- package/src/components/centred-layout.tsx +115 -38
- package/src/components/checkbox.tsx +2 -3
- package/src/components/chip.tsx +249 -0
- package/src/components/combobox.tsx +490 -298
- package/src/components/date-picker.tsx +410 -266
- package/src/components/dropdown-menu.tsx +6 -1
- package/src/components/header.tsx +69 -0
- package/src/components/input-chip.tsx +548 -0
- package/src/components/input-group.tsx +17 -2
- package/src/components/input-otp.tsx +161 -78
- package/src/components/input-password.tsx +473 -128
- package/src/components/input.tsx +11 -3
- package/src/components/logo.tsx +1 -1
- package/src/components/progress.tsx +21 -2
- package/src/components/radio-group.tsx +11 -0
- package/src/components/select.tsx +5 -2
- package/src/components/slider.tsx +85 -15
- package/src/components/textarea.tsx +15 -5
- package/src/components/toggle.tsx +13 -15
- package/src/index.ts +3 -0
package/dist/combobox.js
CHANGED
|
@@ -1,16 +1,73 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import * as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { jsx as n, jsxs as I, Fragment as j } from "react/jsx-runtime";
|
|
2
|
+
import * as t from "react";
|
|
3
|
+
import { ChevronsUpDownIcon as z, CheckIcon as P, LoaderIcon as M } from "@brightlocal/icons";
|
|
4
|
+
import { cva as G } from "class-variance-authority";
|
|
5
|
+
import { cn as w } from "@brightlocal/ui-components/lib/utils";
|
|
6
|
+
import { Popover as U, PopoverTrigger as _, PopoverContent as $ } from "@brightlocal/ui-components/popover";
|
|
7
|
+
import { Command as F, CommandInput as O, CommandList as D, CommandEmpty as H, CommandGroup as V, CommandItem as q, CommandSeparator as A } from "@brightlocal/ui-components/command";
|
|
8
|
+
const E = t.createContext(null);
|
|
9
|
+
function y() {
|
|
10
|
+
const o = t.useContext(E);
|
|
11
|
+
if (!o)
|
|
12
|
+
throw new Error("Combobox components must be used within a <Combobox>");
|
|
13
|
+
return o;
|
|
14
|
+
}
|
|
15
|
+
function io({
|
|
16
|
+
value: o,
|
|
17
|
+
onValueChange: e,
|
|
18
|
+
open: a,
|
|
19
|
+
onOpenChange: r,
|
|
20
|
+
shouldFilter: s = !0,
|
|
21
|
+
disabled: i = !1,
|
|
22
|
+
children: d
|
|
23
|
+
}) {
|
|
24
|
+
const [f, m] = t.useState(""), [b, x] = t.useState(!1), [u, l] = t.useState(
|
|
25
|
+
() => /* @__PURE__ */ new Map()
|
|
26
|
+
), g = o !== void 0, p = a !== void 0, C = g ? o : f, v = p ? a : b, h = t.useCallback(
|
|
27
|
+
(c) => {
|
|
28
|
+
p || x(c), r?.(c);
|
|
29
|
+
},
|
|
30
|
+
[p, r]
|
|
31
|
+
), N = t.useCallback(
|
|
32
|
+
(c) => {
|
|
33
|
+
g || m(c), e?.(c);
|
|
34
|
+
},
|
|
35
|
+
[g, e]
|
|
36
|
+
), R = t.useCallback((c, S) => {
|
|
37
|
+
l((k) => {
|
|
38
|
+
if (k.get(c) === S) return k;
|
|
39
|
+
const L = new Map(k);
|
|
40
|
+
return L.set(c, S), L;
|
|
41
|
+
});
|
|
42
|
+
}, []), T = t.useMemo(
|
|
43
|
+
() => ({
|
|
44
|
+
open: v,
|
|
45
|
+
setOpen: h,
|
|
46
|
+
value: C,
|
|
47
|
+
onValueChange: N,
|
|
48
|
+
shouldFilter: s,
|
|
49
|
+
disabled: i,
|
|
50
|
+
itemLabels: u,
|
|
51
|
+
registerItem: R
|
|
52
|
+
}),
|
|
53
|
+
[
|
|
54
|
+
v,
|
|
55
|
+
h,
|
|
56
|
+
C,
|
|
57
|
+
N,
|
|
58
|
+
s,
|
|
59
|
+
i,
|
|
60
|
+
u,
|
|
61
|
+
R
|
|
62
|
+
]
|
|
63
|
+
);
|
|
64
|
+
return /* @__PURE__ */ n(E.Provider, { value: T, children: /* @__PURE__ */ n(U, { open: v, onOpenChange: h, children: d }) });
|
|
65
|
+
}
|
|
66
|
+
const B = G(
|
|
10
67
|
[
|
|
11
68
|
// Base layout
|
|
12
|
-
"relative flex w-full items-center justify-
|
|
13
|
-
"px-4 py-2",
|
|
69
|
+
"relative flex w-full items-center justify-between gap-2",
|
|
70
|
+
"px-4 py-2 h-9",
|
|
14
71
|
// Base appearance
|
|
15
72
|
"border border-input rounded-md outline-none",
|
|
16
73
|
"bg-neutral-50 shadow-xs",
|
|
@@ -21,7 +78,7 @@ const h = "font-sans text-sm leading-normal font-normal text-foreground", Z = "b
|
|
|
21
78
|
"data-[placeholder=true]:text-muted-foreground",
|
|
22
79
|
// Hover state
|
|
23
80
|
"hover:bg-accent",
|
|
24
|
-
// Focus state
|
|
81
|
+
// Focus state
|
|
25
82
|
"focus-visible:outline-none focus-visible:border-ring dark:focus-visible:border-neutral-500 focus-visible:bg-background",
|
|
26
83
|
"focus-visible:shadow-default",
|
|
27
84
|
// Open dropdown state
|
|
@@ -29,206 +86,202 @@ const h = "font-sans text-sm leading-normal font-normal text-foreground", Z = "b
|
|
|
29
86
|
// Disabled state
|
|
30
87
|
"disabled:cursor-not-allowed disabled:opacity-50",
|
|
31
88
|
"disabled:hover:bg-neutral-50",
|
|
32
|
-
// Transitions
|
|
89
|
+
// Transitions
|
|
33
90
|
"transition-[background-color,border-color,box-shadow] duration-200 ease-out",
|
|
34
91
|
// Icon styles
|
|
35
92
|
"[&_svg]:pointer-events-none [&_svg]:shrink-0",
|
|
36
|
-
"[&_svg:not([class*='size-'])]:size-4"
|
|
37
|
-
"[&_svg:not([class*='text-'])]:text-muted-foreground"
|
|
93
|
+
"[&_svg:not([class*='size-'])]:size-4"
|
|
38
94
|
],
|
|
39
95
|
{
|
|
40
96
|
variants: {
|
|
41
97
|
variant: {
|
|
42
|
-
default: [
|
|
43
|
-
withGroupLabel: [
|
|
44
|
-
// Only variant-specific styles (removed duplicates from base)
|
|
45
|
-
"self-stretch"
|
|
46
|
-
]
|
|
98
|
+
default: []
|
|
47
99
|
}
|
|
48
100
|
},
|
|
49
101
|
defaultVariants: {
|
|
50
102
|
variant: "default"
|
|
51
103
|
}
|
|
52
104
|
}
|
|
53
|
-
)
|
|
54
|
-
function A({
|
|
55
|
-
src: i,
|
|
56
|
-
fallback: r,
|
|
57
|
-
alt: n,
|
|
58
|
-
dataSlot: b
|
|
59
|
-
}) {
|
|
60
|
-
return /* @__PURE__ */ o("span", { className: Z, "data-slot": b, children: i ? /* @__PURE__ */ o("img", { alt: n || "", className: ee, src: i }) : r || "?" });
|
|
61
|
-
}
|
|
62
|
-
const ae = m.forwardRef(
|
|
105
|
+
), J = t.forwardRef(
|
|
63
106
|
({
|
|
64
|
-
|
|
65
|
-
variant:
|
|
66
|
-
dataHook:
|
|
67
|
-
trackingEl:
|
|
68
|
-
trackingLabel:
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
className: "pointer-events-none self-center",
|
|
102
|
-
dataHook: `${n}-checkbox-${e.value}`
|
|
103
|
-
}
|
|
104
|
-
),
|
|
105
|
-
/* @__PURE__ */ o("span", { className: h, children: e.label })
|
|
106
|
-
] });
|
|
107
|
-
case "icon":
|
|
108
|
-
return /* @__PURE__ */ t(d, { children: [
|
|
109
|
-
a && /* @__PURE__ */ o(a, { className: "text-muted-foreground size-4 shrink-0" }),
|
|
110
|
-
/* @__PURE__ */ o("span", { className: h, children: e.label }),
|
|
111
|
-
f
|
|
112
|
-
] });
|
|
113
|
-
case "avatar":
|
|
114
|
-
return /* @__PURE__ */ t(d, { children: [
|
|
115
|
-
/* @__PURE__ */ o(
|
|
116
|
-
A,
|
|
117
|
-
{
|
|
118
|
-
alt: e.label,
|
|
119
|
-
dataSlot: "menu-item-avatar",
|
|
120
|
-
fallback: e.avatarFallback,
|
|
121
|
-
src: e.avatarSrc
|
|
122
|
-
}
|
|
123
|
-
),
|
|
124
|
-
/* @__PURE__ */ o("span", { className: h, children: e.label }),
|
|
125
|
-
f
|
|
126
|
-
] });
|
|
127
|
-
case "simple":
|
|
128
|
-
default:
|
|
129
|
-
return /* @__PURE__ */ t(d, { children: [
|
|
130
|
-
/* @__PURE__ */ o("span", { className: h, children: e.label }),
|
|
131
|
-
f
|
|
132
|
-
] });
|
|
107
|
+
className: o,
|
|
108
|
+
variant: e,
|
|
109
|
+
dataHook: a,
|
|
110
|
+
trackingEl: r,
|
|
111
|
+
trackingLabel: s,
|
|
112
|
+
children: i,
|
|
113
|
+
...d
|
|
114
|
+
}, f) => {
|
|
115
|
+
const { open: m, disabled: b, value: x } = y(), u = t.useId(), l = !x;
|
|
116
|
+
return /* @__PURE__ */ n(_, { asChild: !0, children: /* @__PURE__ */ I(
|
|
117
|
+
"button",
|
|
118
|
+
{
|
|
119
|
+
ref: f,
|
|
120
|
+
"aria-controls": m ? u : void 0,
|
|
121
|
+
"aria-expanded": m,
|
|
122
|
+
"aria-haspopup": "listbox",
|
|
123
|
+
className: w(B({ variant: e }), o),
|
|
124
|
+
"data-hook": a,
|
|
125
|
+
"data-placeholder": l,
|
|
126
|
+
"data-slot": "combobox-trigger",
|
|
127
|
+
"data-state": m ? "open" : "closed",
|
|
128
|
+
"data-tracking-el": r || "combobox-trigger",
|
|
129
|
+
"data-tracking-label": s,
|
|
130
|
+
disabled: b || d.disabled,
|
|
131
|
+
role: "combobox",
|
|
132
|
+
type: "button",
|
|
133
|
+
...d,
|
|
134
|
+
children: [
|
|
135
|
+
i,
|
|
136
|
+
/* @__PURE__ */ n(
|
|
137
|
+
z,
|
|
138
|
+
{
|
|
139
|
+
"aria-hidden": "true",
|
|
140
|
+
className: "text-muted-foreground ml-auto size-4 shrink-0"
|
|
141
|
+
}
|
|
142
|
+
)
|
|
143
|
+
]
|
|
133
144
|
}
|
|
134
|
-
};
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
145
|
+
) });
|
|
146
|
+
}
|
|
147
|
+
);
|
|
148
|
+
J.displayName = "ComboboxTrigger";
|
|
149
|
+
function co({ placeholder: o, className: e }) {
|
|
150
|
+
const { value: a, itemLabels: r } = y(), s = a ? r.get(a) || a : o;
|
|
151
|
+
return /* @__PURE__ */ n(
|
|
152
|
+
"span",
|
|
153
|
+
{
|
|
154
|
+
className: w(
|
|
155
|
+
"text-foreground overflow-hidden text-sm leading-normal font-medium text-ellipsis whitespace-nowrap",
|
|
156
|
+
e
|
|
157
|
+
),
|
|
158
|
+
"data-slot": "combobox-value",
|
|
159
|
+
children: s
|
|
160
|
+
}
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
function mo({
|
|
164
|
+
dataHook: o,
|
|
165
|
+
className: e,
|
|
166
|
+
children: a,
|
|
167
|
+
align: r = "start"
|
|
168
|
+
}) {
|
|
169
|
+
const { shouldFilter: s } = y();
|
|
170
|
+
return /* @__PURE__ */ n(
|
|
171
|
+
$,
|
|
172
|
+
{
|
|
173
|
+
align: r,
|
|
174
|
+
className: w("w-[var(--radix-popover-trigger-width)] p-0", e),
|
|
175
|
+
"data-slot": "combobox-popover",
|
|
176
|
+
children: /* @__PURE__ */ n(
|
|
177
|
+
F,
|
|
138
178
|
{
|
|
139
|
-
|
|
140
|
-
"
|
|
141
|
-
"
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
className: q(
|
|
145
|
-
oe({
|
|
146
|
-
variant: r
|
|
147
|
-
}),
|
|
148
|
-
T
|
|
149
|
-
),
|
|
150
|
-
"data-hook": n,
|
|
151
|
-
"data-placeholder": V,
|
|
152
|
-
"data-slot": "combobox-trigger",
|
|
153
|
-
"data-tracking-el": b || `combobox-${r}`,
|
|
154
|
-
"data-tracking-label": _,
|
|
155
|
-
disabled: L,
|
|
156
|
-
id: i,
|
|
157
|
-
role: "combobox",
|
|
158
|
-
type: "button",
|
|
159
|
-
children: r === "withGroupLabel" ? /* @__PURE__ */ t(d, { children: [
|
|
160
|
-
/* @__PURE__ */ t("div", { className: "flex w-full flex-col items-start pr-6", children: [
|
|
161
|
-
g && /* @__PURE__ */ o("span", { className: "text-muted-foreground overflow-hidden font-sans text-xs leading-4 font-normal text-ellipsis", children: g }),
|
|
162
|
-
/* @__PURE__ */ o("span", { className: "text-foreground overflow-hidden font-sans text-sm leading-5 font-medium text-ellipsis whitespace-nowrap", children: s ? s.label : x })
|
|
163
|
-
] }),
|
|
164
|
-
/* @__PURE__ */ o(P, { className: "text-muted-foreground absolute top-1/2 right-4 size-4 shrink-0 -translate-y-1/2" })
|
|
165
|
-
] }) : /* @__PURE__ */ t(d, { children: [
|
|
166
|
-
j && /* @__PURE__ */ o(
|
|
167
|
-
A,
|
|
168
|
-
{
|
|
169
|
-
alt: s?.label,
|
|
170
|
-
dataSlot: "combobox-avatar",
|
|
171
|
-
fallback: G,
|
|
172
|
-
src: E
|
|
173
|
-
}
|
|
174
|
-
),
|
|
175
|
-
/* @__PURE__ */ o("span", { className: "text-foreground overflow-hidden text-sm leading-normal font-medium text-ellipsis whitespace-nowrap", children: s ? s.label : x }),
|
|
176
|
-
/* @__PURE__ */ o(D, { className: "text-muted-foreground ml-auto size-4 shrink-0" })
|
|
177
|
-
] })
|
|
179
|
+
className: "border-0 shadow-none",
|
|
180
|
+
"data-slot": "combobox-command",
|
|
181
|
+
dataHook: o || "combobox-command",
|
|
182
|
+
shouldFilter: s,
|
|
183
|
+
children: a
|
|
178
184
|
}
|
|
179
|
-
)
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
185
|
+
)
|
|
186
|
+
}
|
|
187
|
+
);
|
|
188
|
+
}
|
|
189
|
+
const K = t.forwardRef((o, e) => /* @__PURE__ */ n(O, { ref: e, "data-slot": "combobox-input", ...o }));
|
|
190
|
+
K.displayName = "ComboboxInput";
|
|
191
|
+
const Q = t.forwardRef((o, e) => /* @__PURE__ */ n(D, { ref: e, "data-slot": "combobox-list", ...o }));
|
|
192
|
+
Q.displayName = "ComboboxList";
|
|
193
|
+
const W = t.forwardRef((o, e) => /* @__PURE__ */ n(H, { ref: e, "data-slot": "combobox-empty", ...o }));
|
|
194
|
+
W.displayName = "ComboboxEmpty";
|
|
195
|
+
const X = t.forwardRef((o, e) => /* @__PURE__ */ n(V, { ref: e, "data-slot": "combobox-group", ...o }));
|
|
196
|
+
X.displayName = "ComboboxGroup";
|
|
197
|
+
function Y(o, e, a) {
|
|
198
|
+
if (!e || !e.trim())
|
|
199
|
+
return o;
|
|
200
|
+
const r = new RegExp(
|
|
201
|
+
`(${e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")})`,
|
|
202
|
+
"gi"
|
|
203
|
+
), s = o.split(r);
|
|
204
|
+
return /* @__PURE__ */ n("span", { children: s.map(
|
|
205
|
+
(i, d) => d % 2 === 1 ? /* @__PURE__ */ n("span", { className: a, children: i }, d) : /* @__PURE__ */ n(t.Fragment, { children: i }, d)
|
|
206
|
+
) });
|
|
207
|
+
}
|
|
208
|
+
const Z = t.forwardRef(
|
|
209
|
+
({
|
|
210
|
+
value: o,
|
|
211
|
+
label: e,
|
|
212
|
+
dataHook: a,
|
|
213
|
+
children: r,
|
|
214
|
+
className: s,
|
|
215
|
+
highlight: i,
|
|
216
|
+
highlightClassName: d,
|
|
217
|
+
...f
|
|
218
|
+
}, m) => {
|
|
219
|
+
const { value: b, onValueChange: x, setOpen: u, registerItem: l } = y(), g = b === o, p = t.useMemo(() => e || (typeof r == "string" ? r : typeof r == "number" ? String(r) : o), [e, r, o]), C = t.useRef(l);
|
|
220
|
+
t.useEffect(() => {
|
|
221
|
+
C.current = l;
|
|
222
|
+
}, [l]), t.useEffect(() => {
|
|
223
|
+
C.current(o, p);
|
|
224
|
+
}, [o, p]);
|
|
225
|
+
const v = () => {
|
|
226
|
+
x(o === b ? "" : o), u(!1);
|
|
227
|
+
}, h = () => i && typeof r == "string" ? Y(
|
|
228
|
+
r,
|
|
229
|
+
i,
|
|
230
|
+
d || "text-sm leading-normal font-semibold"
|
|
231
|
+
) : r;
|
|
232
|
+
return /* @__PURE__ */ I(
|
|
233
|
+
q,
|
|
234
|
+
{
|
|
235
|
+
ref: m,
|
|
236
|
+
className: w("justify-between", s),
|
|
237
|
+
"data-slot": "combobox-item",
|
|
238
|
+
dataHook: a,
|
|
239
|
+
value: o,
|
|
240
|
+
onSelect: v,
|
|
241
|
+
...f,
|
|
242
|
+
children: [
|
|
243
|
+
h(),
|
|
244
|
+
g && /* @__PURE__ */ n(
|
|
245
|
+
P,
|
|
188
246
|
{
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
dataHook: `${n}-command`,
|
|
192
|
-
id: w,
|
|
193
|
-
children: [
|
|
194
|
-
/* @__PURE__ */ o(
|
|
195
|
-
W,
|
|
196
|
-
{
|
|
197
|
-
dataHook: `${n}-search`,
|
|
198
|
-
placeholder: z
|
|
199
|
-
}
|
|
200
|
-
),
|
|
201
|
-
/* @__PURE__ */ t(X, { children: [
|
|
202
|
-
/* @__PURE__ */ o(Y, { children: $ }),
|
|
203
|
-
r === "withGroupLabel" && Object.keys(k).length > 1 ? Object.entries(k).map(([e, l]) => /* @__PURE__ */ o(I, { heading: e, children: l.map((a) => /* @__PURE__ */ o(
|
|
204
|
-
S,
|
|
205
|
-
{
|
|
206
|
-
dataHook: `${n}-item-${a.value}`,
|
|
207
|
-
value: a.value,
|
|
208
|
-
onSelect: N,
|
|
209
|
-
children: C(a, u === a.value)
|
|
210
|
-
},
|
|
211
|
-
a.value
|
|
212
|
-
)) }, e)) : /* @__PURE__ */ o(I, { children: c.map((e) => /* @__PURE__ */ o(
|
|
213
|
-
S,
|
|
214
|
-
{
|
|
215
|
-
dataHook: `${n}-item-${e.value}`,
|
|
216
|
-
value: e.value,
|
|
217
|
-
onSelect: N,
|
|
218
|
-
children: C(e, u === e.value)
|
|
219
|
-
},
|
|
220
|
-
e.value
|
|
221
|
-
)) })
|
|
222
|
-
] })
|
|
223
|
-
]
|
|
247
|
+
"aria-hidden": "true",
|
|
248
|
+
className: "text-muted-foreground size-4 shrink-0"
|
|
224
249
|
}
|
|
225
250
|
)
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
251
|
+
]
|
|
252
|
+
}
|
|
253
|
+
);
|
|
229
254
|
}
|
|
230
255
|
);
|
|
231
|
-
|
|
256
|
+
Z.displayName = "ComboboxItem";
|
|
257
|
+
const oo = t.forwardRef((o, e) => /* @__PURE__ */ n(A, { ref: e, "data-slot": "combobox-separator", ...o }));
|
|
258
|
+
oo.displayName = "ComboboxSeparator";
|
|
259
|
+
function lo({ className: o, children: e }) {
|
|
260
|
+
return /* @__PURE__ */ n(
|
|
261
|
+
"div",
|
|
262
|
+
{
|
|
263
|
+
className: w(
|
|
264
|
+
"text-muted-foreground flex items-center justify-center gap-2 py-6 text-sm",
|
|
265
|
+
o
|
|
266
|
+
),
|
|
267
|
+
"data-slot": "combobox-loading",
|
|
268
|
+
children: e || /* @__PURE__ */ I(j, { children: [
|
|
269
|
+
/* @__PURE__ */ n(M, { "aria-hidden": "true", className: "size-4 animate-spin" }),
|
|
270
|
+
"Loading..."
|
|
271
|
+
] })
|
|
272
|
+
}
|
|
273
|
+
);
|
|
274
|
+
}
|
|
232
275
|
export {
|
|
233
|
-
|
|
276
|
+
io as Combobox,
|
|
277
|
+
mo as ComboboxContent,
|
|
278
|
+
W as ComboboxEmpty,
|
|
279
|
+
X as ComboboxGroup,
|
|
280
|
+
K as ComboboxInput,
|
|
281
|
+
Z as ComboboxItem,
|
|
282
|
+
Q as ComboboxList,
|
|
283
|
+
lo as ComboboxLoading,
|
|
284
|
+
oo as ComboboxSeparator,
|
|
285
|
+
J as ComboboxTrigger,
|
|
286
|
+
co as ComboboxValue
|
|
234
287
|
};
|
package/dist/date-picker.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),H=require("react"),k=require("date-fns"),M=require("@brightlocal/icons"),g=require("@brightlocal/ui-components/lib/utils"),L=require("./input.cjs"),S=require("@brightlocal/ui-components/calendar"),j=require("@brightlocal/ui-components/popover"),p=require("@brightlocal/ui-components/select");function A(e){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:()=>e[t]})}}return n.default=e,Object.freeze(n)}const D=A(H),v=D.createContext(null);function b(){const e=D.useContext(v);if(!e)throw new Error("DatePicker compound components must be used within DatePickerRoot");return e}function T({children:e,dataHook:n,trackingEl:t,trackingLabel:r,mode:s="single",date:d,onDateChange:u,dateRange:l,onDateRangeChange:c,placeholder:a,disabled:i,dateFormat:f,open:h,onOpenChange:P,defaultOpen:m=!1}){const[V,$]=D.useState(m),w=h!==void 0,x=w?h:V,y=D.useCallback(C=>{w||$(C),P?.(C)},[w,P]),_=D.useMemo(()=>({mode:s,open:x,setOpen:y,disabled:i,date:d,onDateChange:u,dateRange:l,onDateRangeChange:c,dateFormat:f??(s==="single"?"PPP":"PP"),placeholder:a??(s==="single"?"Pick a date":"Pick a date range"),dataHook:n,trackingEl:t,trackingLabel:r}),[s,x,y,i,d,u,l,c,f,a,n,t,r]);return o.jsx(v.Provider,{value:_,children:o.jsx(j.Popover,{open:x,onOpenChange:y,children:e})})}T.displayName="DatePickerRoot";const N=D.forwardRef(({className:e,children:n,id:t,...r},s)=>{const{mode:d,date:u,dateRange:l,dateFormat:c,placeholder:a,disabled:i,dataHook:f}=b(),P=d==="single"?u?k.format(u,c):null:l?.from?l.to?`${k.format(l.from,c)} - ${k.format(l.to,c)}`:k.format(l.from,c):null,m=P!==null;return o.jsx(j.PopoverTrigger,{asChild:!0,children:o.jsxs("button",{ref:s,"aria-label":r["aria-label"]??(d==="single"?"Select date":"Select date range"),className:g.cn(L.inputVariants({hasIcon:!0}),"relative cursor-pointer justify-start text-left",!m&&"text-muted-foreground",e),"data-hook":`${f}-trigger`,"data-slot":"date-picker-trigger",disabled:i,id:t,type:"button",...r,children:[o.jsx(M.Calendar,{className:g.cn("text-muted-foreground pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2",i&&"opacity-50"),"data-slot":"calendar-icon"}),n??(m?P:o.jsx("span",{children:a}))]})})});N.displayName="DatePickerTrigger";const R=D.forwardRef(({className:e,children:n,...t},r)=>{const{dataHook:s}=b();return o.jsx(j.PopoverContent,{ref:r,align:"start",className:g.cn("w-auto rounded-lg p-0",e),dataHook:`${s}-content`,...t,children:n})});R.displayName="DatePickerContent";function E({className:e,closeOnSelect:n=!0,...t}){const{mode:r,date:s,onDateChange:d,dateRange:u,onDateRangeChange:l,setOpen:c,disabled:a,dataHook:i}=b();return r==="single"?o.jsx(S.Calendar,{captionLayout:"dropdown",className:g.cn("border-0 shadow-none",e),dataHook:`${i}-calendar`,disabled:a,endMonth:new Date(2100,11,31),mode:"single",selected:s,startMonth:new Date(1900,0,1),onSelect:f=>{d?.(f),n&&c(!1)},...t}):o.jsx(S.Calendar,{captionLayout:"dropdown",className:g.cn("border-0 shadow-none",e),dataHook:`${i}-calendar`,disabled:a,endMonth:new Date(2100,11,31),mode:"range",selected:u,startMonth:new Date(1900,0,1),onSelect:l,...t})}E.displayName="DatePickerCalendar";const q=[{label:"Today",date:()=>new Date},{label:"Tomorrow",date:()=>{const e=new Date;return e.setDate(e.getDate()+1),e}},{label:"In 3 days",date:()=>{const e=new Date;return e.setDate(e.getDate()+3),e}},{label:"In a week",date:()=>{const e=new Date;return e.setDate(e.getDate()+7),e}}];function O({presets:e=q,placeholder:n="Select preset",className:t}){const{mode:r,date:s,onDateChange:d,disabled:u,dataHook:l}=b();if(r!=="single")return process.env.NODE_ENV!=="production"&&console.warn("DatePickerPresets only works with mode='single'"),null;const c=s?e.find(a=>a.date().toDateString()===s.toDateString())?.label:void 0;return o.jsxs(p.Select,{disabled:u,value:c,onValueChange:a=>{const i=e.find(f=>f.label===a);i&&d?.(i.date())},children:[o.jsx(p.SelectTrigger,{className:g.cn("w-full",t),dataHook:`${l}-preset-select`,children:o.jsx(p.SelectValue,{placeholder:n})}),o.jsx(p.SelectContent,{children:e.map(a=>o.jsx(p.SelectItem,{"data-hook":`${l}-preset-${a.label.toLowerCase().replace(/\s+/g,"-")}`,value:a.label,children:a.label},a.label))})]})}O.displayName="DatePickerPresets";exports.DEFAULT_DATE_PRESETS=q;exports.DatePickerCalendar=E;exports.DatePickerContent=R;exports.DatePickerPresets=O;exports.DatePickerRoot=T;exports.DatePickerTrigger=N;
|