@brightlocal/ui-components 3.1.0 → 3.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/README.md +6 -1
- package/component-meta.json +663 -38
- package/deprecations.json +1 -1
- package/dist/alert-dialog.cjs +1 -1
- package/dist/alert-dialog.d.ts +32 -3
- package/dist/alert-dialog.d.ts.map +1 -1
- package/dist/alert-dialog.js +61 -58
- package/dist/alert.cjs +1 -1
- package/dist/alert.d.ts.map +1 -1
- package/dist/alert.js +58 -57
- package/dist/badge.cjs +1 -1
- package/dist/badge.d.ts +9 -0
- package/dist/badge.d.ts.map +1 -1
- package/dist/badge.js +50 -30
- package/dist/banner.cjs +1 -0
- package/dist/banner.d.ts +81 -0
- package/dist/banner.d.ts.map +1 -0
- package/dist/banner.js +176 -0
- package/dist/blocks/empty-state.cjs +1 -1
- package/dist/blocks/empty-state.d.ts +4 -3
- package/dist/blocks/empty-state.d.ts.map +1 -1
- package/dist/blocks/empty-state.js +21 -20
- package/dist/blocks/progress-state.d.ts +2 -2
- package/dist/blocks/sidebar.cjs +1 -1
- package/dist/blocks/sidebar.d.ts +17 -0
- package/dist/blocks/sidebar.d.ts.map +1 -1
- package/dist/blocks/sidebar.js +8 -2
- package/dist/brand-illustration-motif.d.ts +1 -1
- package/dist/card.cjs +1 -1
- package/dist/card.d.ts +86 -6
- package/dist/card.d.ts.map +1 -1
- package/dist/card.js +185 -96
- package/dist/chart.cjs +3 -3
- package/dist/chart.d.ts +231 -13
- package/dist/chart.d.ts.map +1 -1
- package/dist/chart.js +466 -306
- package/dist/checkbox.cjs +1 -1
- package/dist/checkbox.d.ts +1 -1
- package/dist/checkbox.d.ts.map +1 -1
- package/dist/checkbox.js +2 -1
- package/dist/combobox.cjs +1 -1
- package/dist/combobox.js +2 -2
- package/dist/command.cjs +1 -1
- package/dist/command.js +1 -1
- package/dist/data-table.cjs +1 -1
- package/dist/data-table.d.ts +169 -22
- package/dist/data-table.d.ts.map +1 -1
- package/dist/data-table.js +695 -561
- package/dist/grid.d.ts +24 -1
- package/dist/grid.d.ts.map +1 -1
- package/dist/hooks/use-breakpoint.cjs +1 -1
- package/dist/hooks/use-breakpoint.d.ts +1 -1
- package/dist/hooks/use-breakpoint.d.ts.map +1 -1
- package/dist/hooks/use-breakpoint.js +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +593 -561
- package/dist/info-tooltip.cjs +1 -0
- package/dist/info-tooltip.d.ts +39 -0
- package/dist/info-tooltip.d.ts.map +1 -0
- package/dist/info-tooltip.js +41 -0
- package/dist/input-chip.cjs +1 -1
- package/dist/input-chip.js +1 -1
- package/dist/input-group.cjs +1 -1
- package/dist/input-group.d.ts +33 -2
- package/dist/input-group.d.ts.map +1 -1
- package/dist/input-group.js +167 -54
- package/dist/input-otp.cjs +1 -1
- package/dist/input-otp.js +9 -9
- package/dist/input-password.cjs +1 -1
- package/dist/input-password.d.ts +28 -6
- package/dist/input-password.d.ts.map +1 -1
- package/dist/input-password.js +5 -5
- package/dist/input.cjs +1 -1
- package/dist/input.js +10 -10
- package/dist/lib/block-illustration.cjs +1 -1
- package/dist/lib/block-illustration.d.ts +4 -1
- package/dist/lib/block-illustration.d.ts.map +1 -1
- package/dist/lib/block-illustration.js +12 -11
- package/dist/lib/utils.cjs +1 -1
- package/dist/lib/utils.d.ts.map +1 -1
- package/dist/lib/utils.js +4 -3
- package/dist/list.cjs +1 -1
- package/dist/list.js +1 -1
- package/dist/multi-select-filter.cjs +1 -0
- package/dist/multi-select-filter.d.ts +178 -0
- package/dist/multi-select-filter.d.ts.map +1 -0
- package/dist/multi-select-filter.js +463 -0
- package/dist/progress.cjs +1 -1
- package/dist/progress.d.ts +123 -16
- package/dist/progress.d.ts.map +1 -1
- package/dist/progress.js +89 -75
- package/dist/rating.cjs +1 -1
- package/dist/rating.js +18 -18
- package/dist/relative-date.cjs +1 -0
- package/dist/relative-date.d.ts +65 -0
- package/dist/relative-date.d.ts.map +1 -0
- package/dist/relative-date.js +128 -0
- package/dist/select.cjs +2 -2
- package/dist/select.d.ts +11 -1
- package/dist/select.d.ts.map +1 -1
- package/dist/select.js +97 -81
- package/dist/sheet.cjs +1 -1
- package/dist/sheet.d.ts +78 -2
- package/dist/sheet.d.ts.map +1 -1
- package/dist/sheet.js +192 -85
- package/dist/single-select-filter.cjs +1 -0
- package/dist/single-select-filter.d.ts +81 -0
- package/dist/single-select-filter.d.ts.map +1 -0
- package/dist/single-select-filter.js +226 -0
- package/dist/sonner.cjs +1 -1
- package/dist/sonner.d.ts.map +1 -1
- package/dist/sonner.js +22 -22
- package/dist/split-layout.cjs +1 -1
- package/dist/split-layout.d.ts +1 -1
- package/dist/split-layout.js +13 -13
- package/dist/table.cjs +1 -1
- package/dist/table.d.ts +45 -4
- package/dist/table.d.ts.map +1 -1
- package/dist/table.js +90 -73
- package/dist/tabs.cjs +1 -1
- package/dist/tabs.d.ts +12 -1
- package/dist/tabs.d.ts.map +1 -1
- package/dist/tabs.js +148 -126
- package/dist/textarea.cjs +1 -1
- package/dist/textarea.js +1 -1
- package/dist/tooltip.cjs +1 -1
- package/dist/tooltip.d.ts +38 -36
- package/dist/tooltip.d.ts.map +1 -1
- package/dist/tooltip.js +262 -73
- package/dist/typography-text.d.ts +1 -2
- package/dist/typography-text.d.ts.map +1 -1
- package/dist/typography.d.ts +1 -1
- package/package.json +5 -6
- package/src/blocks/empty-state.tsx +8 -3
- package/src/blocks/progress-state.tsx +2 -2
- package/src/blocks/sidebar.tsx +26 -2
- package/src/components/alert-dialog.tsx +50 -5
- package/src/components/alert.tsx +16 -8
- package/src/components/badge.tsx +40 -3
- package/src/components/banner.tsx +288 -0
- package/src/components/brand-illustration-motif.tsx +1 -1
- package/src/components/card.tsx +211 -24
- package/src/components/chart.tsx +523 -35
- package/src/components/checkbox.tsx +1 -1
- package/src/components/combobox.tsx +2 -2
- package/src/components/command.tsx +1 -1
- package/src/components/data-table.tsx +778 -195
- package/src/components/grid.tsx +32 -1
- package/src/components/info-tooltip.tsx +94 -0
- package/src/components/input-chip.tsx +1 -1
- package/src/components/input-group.tsx +246 -11
- package/src/components/input-otp.tsx +1 -1
- package/src/components/input-password.tsx +33 -11
- package/src/components/input.tsx +1 -1
- package/src/components/list.tsx +1 -1
- package/src/components/multi-select-filter.tsx +912 -0
- package/src/components/progress.tsx +190 -31
- package/src/components/rating.tsx +1 -1
- package/src/components/relative-date.tsx +230 -0
- package/src/components/select.tsx +35 -5
- package/src/components/sheet.tsx +240 -4
- package/src/components/single-select-filter.tsx +443 -0
- package/src/components/sonner.tsx +16 -5
- package/src/components/split-layout.tsx +2 -2
- package/src/components/table.tsx +71 -11
- package/src/components/tabs.tsx +93 -46
- package/src/components/textarea.tsx +1 -1
- package/src/components/tooltip.tsx +440 -68
- package/src/components/typography-text.tsx +1 -2
- package/src/components/typography.tsx +1 -1
- package/src/hooks/use-breakpoint.ts +2 -1
- package/src/index.ts +5 -0
- package/src/lib/block-illustration.tsx +5 -1
- package/src/lib/utils.ts +1 -0
package/dist/sheet.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { jsx as o, jsxs as
|
|
2
|
-
import * as
|
|
3
|
-
import * as
|
|
4
|
-
import { cva as
|
|
5
|
-
import { X as
|
|
6
|
-
import { cn as
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
|
|
1
|
+
import { jsx as o, jsxs as h } from "react/jsx-runtime";
|
|
2
|
+
import * as l from "react";
|
|
3
|
+
import * as d from "@radix-ui/react-dialog";
|
|
4
|
+
import { cva as $ } from "class-variance-authority";
|
|
5
|
+
import { X as j, ChevronUp as H, ChevronDown as K } from "@brightlocal/icons";
|
|
6
|
+
import { cn as c } from "@brightlocal/ui-components/lib/utils";
|
|
7
|
+
import { Button as R } from "@brightlocal/ui-components/button";
|
|
8
|
+
import { ScrollArea as V } from "@brightlocal/ui-components/scroll-area";
|
|
9
|
+
import { useOverlayPointerLock as E } from "@brightlocal/ui-components/hooks/use-overlay-pointer-lock";
|
|
10
|
+
const F = $(
|
|
10
11
|
[
|
|
11
12
|
"bg-background",
|
|
12
13
|
"data-[state=open]:animate-in",
|
|
@@ -95,33 +96,33 @@ const S = x(
|
|
|
95
96
|
}
|
|
96
97
|
}
|
|
97
98
|
);
|
|
98
|
-
function
|
|
99
|
-
return /* @__PURE__ */ o(
|
|
99
|
+
function U({ ...e }) {
|
|
100
|
+
return /* @__PURE__ */ o(d.Root, { "data-slot": "sheet", modal: !0, ...e });
|
|
100
101
|
}
|
|
101
|
-
|
|
102
|
-
const
|
|
103
|
-
|
|
102
|
+
U.displayName = "Sheet";
|
|
103
|
+
const I = l.forwardRef(({ dataHook: e, ...t }, s) => /* @__PURE__ */ o(
|
|
104
|
+
d.Trigger,
|
|
104
105
|
{
|
|
105
|
-
ref:
|
|
106
|
+
ref: s,
|
|
106
107
|
"data-slot": "sheet-trigger",
|
|
107
108
|
...e != null && { "data-hook": e },
|
|
108
109
|
...t
|
|
109
110
|
}
|
|
110
111
|
));
|
|
111
|
-
|
|
112
|
-
const
|
|
113
|
-
|
|
114
|
-
function
|
|
112
|
+
I.displayName = "SheetTrigger";
|
|
113
|
+
const X = l.forwardRef(({ ...e }, t) => /* @__PURE__ */ o(d.Close, { ref: t, "data-slot": "sheet-close", ...e }));
|
|
114
|
+
X.displayName = "SheetClose";
|
|
115
|
+
function T({
|
|
115
116
|
...e
|
|
116
117
|
}) {
|
|
117
|
-
return /* @__PURE__ */ o(
|
|
118
|
+
return /* @__PURE__ */ o(d.Portal, { "data-slot": "sheet-portal", ...e });
|
|
118
119
|
}
|
|
119
|
-
|
|
120
|
-
const
|
|
121
|
-
|
|
120
|
+
T.displayName = "SheetPortal";
|
|
121
|
+
const z = l.forwardRef(({ className: e, ...t }, s) => /* @__PURE__ */ o(
|
|
122
|
+
d.Overlay,
|
|
122
123
|
{
|
|
123
|
-
ref:
|
|
124
|
-
className:
|
|
124
|
+
ref: s,
|
|
125
|
+
className: c(
|
|
125
126
|
"data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",
|
|
126
127
|
e
|
|
127
128
|
),
|
|
@@ -129,69 +130,174 @@ const m = i.forwardRef(({ className: e, ...t }, a) => /* @__PURE__ */ o(
|
|
|
129
130
|
...t
|
|
130
131
|
}
|
|
131
132
|
));
|
|
132
|
-
|
|
133
|
-
const
|
|
133
|
+
z.displayName = "SheetOverlay";
|
|
134
|
+
const _ = l.forwardRef(
|
|
134
135
|
({
|
|
135
136
|
className: e,
|
|
136
137
|
children: t,
|
|
137
|
-
side:
|
|
138
|
+
side: s,
|
|
138
139
|
size: r,
|
|
139
|
-
dataHook:
|
|
140
|
-
trackingEl:
|
|
141
|
-
trackingLabel:
|
|
142
|
-
closeLabel:
|
|
143
|
-
...
|
|
144
|
-
},
|
|
145
|
-
/* @__PURE__ */ o(
|
|
146
|
-
/* @__PURE__ */
|
|
147
|
-
|
|
140
|
+
dataHook: n,
|
|
141
|
+
trackingEl: f,
|
|
142
|
+
trackingLabel: b,
|
|
143
|
+
closeLabel: m,
|
|
144
|
+
...w
|
|
145
|
+
}, S) => (E(), /* @__PURE__ */ h(T, { children: [
|
|
146
|
+
/* @__PURE__ */ o(z, {}),
|
|
147
|
+
/* @__PURE__ */ h(
|
|
148
|
+
d.Content,
|
|
148
149
|
{
|
|
149
|
-
ref:
|
|
150
|
-
className:
|
|
151
|
-
"data-hook":
|
|
150
|
+
ref: S,
|
|
151
|
+
className: c(F({ side: s, size: r }), e),
|
|
152
|
+
"data-hook": n,
|
|
152
153
|
"data-slot": "sheet-content",
|
|
153
|
-
"data-tracking-el":
|
|
154
|
-
"data-tracking-label":
|
|
155
|
-
...
|
|
154
|
+
"data-tracking-el": f,
|
|
155
|
+
"data-tracking-label": b,
|
|
156
|
+
...w,
|
|
156
157
|
children: [
|
|
157
158
|
t,
|
|
158
|
-
/* @__PURE__ */
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
159
|
+
/* @__PURE__ */ o(d.Close, { asChild: !0, children: /* @__PURE__ */ h(
|
|
160
|
+
R,
|
|
161
|
+
{
|
|
162
|
+
iconOnly: !0,
|
|
163
|
+
className: "absolute top-6 right-4",
|
|
164
|
+
dataHook: "sheet-close",
|
|
165
|
+
variant: "ghost",
|
|
166
|
+
children: [
|
|
167
|
+
/* @__PURE__ */ o(j, {}),
|
|
168
|
+
/* @__PURE__ */ o("span", { className: "sr-only", children: m ?? "Close" })
|
|
169
|
+
]
|
|
170
|
+
}
|
|
171
|
+
) })
|
|
162
172
|
]
|
|
163
173
|
}
|
|
164
174
|
)
|
|
165
175
|
] }))
|
|
166
176
|
);
|
|
167
|
-
|
|
168
|
-
const
|
|
177
|
+
_.displayName = "SheetContent";
|
|
178
|
+
const q = l.forwardRef(({ className: e, ...t }, s) => /* @__PURE__ */ o(
|
|
169
179
|
"div",
|
|
170
180
|
{
|
|
171
|
-
ref:
|
|
172
|
-
className:
|
|
181
|
+
ref: s,
|
|
182
|
+
className: c("flex flex-col gap-2 text-center sm:text-left", e),
|
|
173
183
|
"data-slot": "sheet-header",
|
|
174
184
|
...t
|
|
175
185
|
}
|
|
176
186
|
));
|
|
177
|
-
|
|
178
|
-
const
|
|
179
|
-
|
|
187
|
+
q.displayName = "SheetHeader";
|
|
188
|
+
const G = l.forwardRef(
|
|
189
|
+
({
|
|
190
|
+
className: e,
|
|
191
|
+
onPrevious: t,
|
|
192
|
+
onNext: s,
|
|
193
|
+
current: r,
|
|
194
|
+
total: n,
|
|
195
|
+
hasPrevious: f,
|
|
196
|
+
hasNext: b,
|
|
197
|
+
renderPosition: m,
|
|
198
|
+
ariaLabel: w,
|
|
199
|
+
prevAriaLabel: S,
|
|
200
|
+
nextAriaLabel: P,
|
|
201
|
+
dataHook: v,
|
|
202
|
+
trackingEl: B,
|
|
203
|
+
trackingLabel: A,
|
|
204
|
+
...O
|
|
205
|
+
}, L) => {
|
|
206
|
+
const p = f ?? (r == null || r > 1), g = b ?? (r == null || n == null || r < n), x = l.useRef(null), y = l.useRef(null), u = l.useRef(null);
|
|
207
|
+
l.useEffect(() => {
|
|
208
|
+
const a = u.current;
|
|
209
|
+
if (u.current = null, !a) return;
|
|
210
|
+
const i = document.activeElement;
|
|
211
|
+
i !== a && i !== document.body || (!p && a === x.current && g ? y.current?.focus() : !g && a === y.current && p && x.current?.focus());
|
|
212
|
+
});
|
|
213
|
+
const C = (a) => {
|
|
214
|
+
const i = a.relatedTarget;
|
|
215
|
+
i && i !== x.current && i !== y.current && (u.current = null);
|
|
216
|
+
}, N = (a, i) => {
|
|
217
|
+
if (a === "previous") {
|
|
218
|
+
if (!p) return;
|
|
219
|
+
u.current = i, t();
|
|
220
|
+
} else {
|
|
221
|
+
if (!g) return;
|
|
222
|
+
u.current = i, s();
|
|
223
|
+
}
|
|
224
|
+
}, D = (a) => {
|
|
225
|
+
a.key === "ArrowUp" || a.key === "ArrowLeft" ? (a.preventDefault(), N("previous", a.currentTarget)) : (a.key === "ArrowDown" || a.key === "ArrowRight") && (a.preventDefault(), N("next", a.currentTarget));
|
|
226
|
+
};
|
|
227
|
+
let k = null;
|
|
228
|
+
return m !== null && r != null && n != null && (k = m ? m({ current: r, total: n }) : `${r} of ${n}`), /* @__PURE__ */ h(
|
|
229
|
+
"div",
|
|
230
|
+
{
|
|
231
|
+
ref: L,
|
|
232
|
+
"aria-label": w ?? "Item navigation",
|
|
233
|
+
className: c("mb-2 flex items-center gap-1", e),
|
|
234
|
+
"data-hook": v,
|
|
235
|
+
"data-slot": "sheet-pagination",
|
|
236
|
+
"data-tracking-el": B,
|
|
237
|
+
"data-tracking-label": A,
|
|
238
|
+
role: "group",
|
|
239
|
+
...O,
|
|
240
|
+
children: [
|
|
241
|
+
/* @__PURE__ */ o(
|
|
242
|
+
R,
|
|
243
|
+
{
|
|
244
|
+
ref: x,
|
|
245
|
+
ariaLabel: S ?? "Previous item",
|
|
246
|
+
dataHook: `${v}-previous`,
|
|
247
|
+
disabled: !p,
|
|
248
|
+
variant: "ghost",
|
|
249
|
+
onBlur: C,
|
|
250
|
+
onClick: (a) => N("previous", a.currentTarget),
|
|
251
|
+
onKeyDown: D,
|
|
252
|
+
children: /* @__PURE__ */ o(H, {})
|
|
253
|
+
}
|
|
254
|
+
),
|
|
255
|
+
/* @__PURE__ */ o(
|
|
256
|
+
R,
|
|
257
|
+
{
|
|
258
|
+
ref: y,
|
|
259
|
+
ariaLabel: P ?? "Next item",
|
|
260
|
+
dataHook: `${v}-next`,
|
|
261
|
+
disabled: !g,
|
|
262
|
+
variant: "ghost",
|
|
263
|
+
onBlur: C,
|
|
264
|
+
onClick: (a) => N("next", a.currentTarget),
|
|
265
|
+
onKeyDown: D,
|
|
266
|
+
children: /* @__PURE__ */ o(K, {})
|
|
267
|
+
}
|
|
268
|
+
),
|
|
269
|
+
k != null && /* @__PURE__ */ o(
|
|
270
|
+
"span",
|
|
271
|
+
{
|
|
272
|
+
"aria-live": "polite",
|
|
273
|
+
className: "text-body-sm text-muted-foreground",
|
|
274
|
+
"data-slot": "sheet-pagination-position",
|
|
275
|
+
children: k
|
|
276
|
+
}
|
|
277
|
+
)
|
|
278
|
+
]
|
|
279
|
+
}
|
|
280
|
+
);
|
|
281
|
+
}
|
|
282
|
+
);
|
|
283
|
+
G.displayName = "SheetPagination";
|
|
284
|
+
const J = l.forwardRef(({ className: e, children: t, dataHook: s, ...r }, n) => /* @__PURE__ */ o(
|
|
285
|
+
V,
|
|
180
286
|
{
|
|
181
|
-
ref:
|
|
182
|
-
className:
|
|
287
|
+
ref: n,
|
|
288
|
+
className: c("-mx-6 min-h-0 flex-1", e),
|
|
183
289
|
"data-slot": "sheet-body",
|
|
184
|
-
dataHook:
|
|
290
|
+
dataHook: s ?? "sheet-body",
|
|
185
291
|
...r,
|
|
186
292
|
children: /* @__PURE__ */ o("div", { className: "px-5", "data-slot": "sheet-body-content", children: t })
|
|
187
293
|
}
|
|
188
294
|
));
|
|
189
|
-
|
|
190
|
-
const
|
|
295
|
+
J.displayName = "SheetBody";
|
|
296
|
+
const M = l.forwardRef(({ className: e, ...t }, s) => /* @__PURE__ */ o(
|
|
191
297
|
"div",
|
|
192
298
|
{
|
|
193
|
-
ref:
|
|
194
|
-
className:
|
|
299
|
+
ref: s,
|
|
300
|
+
className: c(
|
|
195
301
|
"mt-auto flex flex-col gap-2 sm:flex-row sm:justify-end",
|
|
196
302
|
e
|
|
197
303
|
),
|
|
@@ -199,47 +305,48 @@ const T = i.forwardRef(({ className: e, ...t }, a) => /* @__PURE__ */ o(
|
|
|
199
305
|
...t
|
|
200
306
|
}
|
|
201
307
|
));
|
|
202
|
-
|
|
203
|
-
const
|
|
204
|
-
|
|
308
|
+
M.displayName = "SheetFooter";
|
|
309
|
+
const Q = l.forwardRef(({ className: e, icon: t, children: s, dataHook: r, ...n }, f) => /* @__PURE__ */ h(
|
|
310
|
+
d.Title,
|
|
205
311
|
{
|
|
206
|
-
ref:
|
|
207
|
-
className:
|
|
312
|
+
ref: f,
|
|
313
|
+
className: c(
|
|
208
314
|
"text-foreground text-heading-section",
|
|
209
315
|
t && "flex items-center gap-2",
|
|
210
316
|
e
|
|
211
317
|
),
|
|
212
318
|
"data-hook": r,
|
|
213
319
|
"data-slot": "sheet-title",
|
|
214
|
-
...
|
|
320
|
+
...n,
|
|
215
321
|
children: [
|
|
216
322
|
t && /* @__PURE__ */ o("span", { className: "shrink-0 [&_svg]:size-5", "data-slot": "sheet-title-icon", children: t }),
|
|
217
|
-
|
|
323
|
+
s
|
|
218
324
|
]
|
|
219
325
|
}
|
|
220
326
|
));
|
|
221
|
-
|
|
222
|
-
const
|
|
223
|
-
|
|
327
|
+
Q.displayName = "SheetTitle";
|
|
328
|
+
const W = l.forwardRef(({ className: e, dataHook: t, ...s }, r) => /* @__PURE__ */ o(
|
|
329
|
+
d.Description,
|
|
224
330
|
{
|
|
225
331
|
ref: r,
|
|
226
|
-
className:
|
|
332
|
+
className: c("text-body-sm text-muted-foreground", e),
|
|
227
333
|
"data-hook": t,
|
|
228
334
|
"data-slot": "sheet-description",
|
|
229
|
-
...
|
|
335
|
+
...s
|
|
230
336
|
}
|
|
231
337
|
));
|
|
232
|
-
|
|
338
|
+
W.displayName = "SheetDescription";
|
|
233
339
|
export {
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
340
|
+
U as Sheet,
|
|
341
|
+
J as SheetBody,
|
|
342
|
+
X as SheetClose,
|
|
343
|
+
_ as SheetContent,
|
|
344
|
+
W as SheetDescription,
|
|
345
|
+
M as SheetFooter,
|
|
346
|
+
q as SheetHeader,
|
|
347
|
+
z as SheetOverlay,
|
|
348
|
+
G as SheetPagination,
|
|
349
|
+
T as SheetPortal,
|
|
350
|
+
Q as SheetTitle,
|
|
351
|
+
I as SheetTrigger
|
|
245
352
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),Q=require("react"),W=require("@brightlocal/icons"),G=require("@brightlocal/ui-components/button"),i=require("@brightlocal/ui-components/drawer"),X=require("@brightlocal/ui-components/hooks/use-breakpoint"),Y=require("@brightlocal/ui-components/label"),R=require("@brightlocal/ui-components/radio-group"),g=require("@brightlocal/ui-components/select"),P=require("@brightlocal/ui-components/lib/utils"),_=require("@brightlocal/ui-components/multi-select-filter");function Z(n){const l=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const a in n)if(a!=="default"){const c=Object.getOwnPropertyDescriptor(n,a);Object.defineProperty(l,a,c.get?c:{enumerable:!0,get:()=>n[a]})}}return l.default=n,Object.freeze(l)}const h=Z(Q);function E({value:n,defaultValue:l,onValueChange:a,open:c,onOpenChange:x}){const[m,p]=h.useState(l),d=n!==void 0,b=d?n:m,[j,S]=h.useState(!1),u=c!==void 0,v=u?c:j,f=h.useCallback(o=>{d||p(o),a?.(o)},[d,a]),w=h.useCallback(o=>{u||S(o),x?.(o)},[u,x]);return{clear:()=>f(l),onOpenChange:w,open:v,setValue:f,value:b}}function H({count:n}){return e.jsx("span",{className:"text-muted-foreground text-label-sm ml-auto tabular-nums",children:n})}function y({children:n,dataHook:l}){return e.jsx("span",{"aria-hidden":"true",className:"flex shrink-0 items-center [&_svg]:size-4","data-hook":l,children:n})}function M({className:n,dataHook:l,label:a,options:c,value:x,defaultValue:m="",onValueChange:p,open:d,onOpenChange:b,size:j="default",icon:S,presentation:u="menu",disabled:v=!1,clearLabel:f,doneLabel:w,drawerDescription:o,trackingEl:N,trackingLabel:O,"aria-label":k,ref:q,...F}){const s=E({defaultValue:m,onOpenChange:b,onValueChange:p,open:d,value:x}),L=X.useIsBelowBreakpoint("md"),U=u==="drawer"||u==="auto"&&L,z=h.useId(),C=s.value===""?void 0:c.find(t=>t.value===s.value),D=C?.label,$=C!==void 0,A=$?D:a,T=S??C?.icon,I=T?e.jsx(y,{dataHook:`${l}-icon`,children:T}):null,V=$?`${a}: ${D}`:a;if(U){const t=e.jsxs("button",{ref:q,"aria-label":k??V,className:P.cn(_.multiSelectFilterTriggerVariants({size:j}),n),"data-hook":l,"data-slot":"single-select-filter","data-tracking-el":N??"single-select-filter","data-tracking-label":O,disabled:v,type:"button",...F,children:[I,e.jsx("span",{"data-hook":`${l}-summary`,children:A}),e.jsx(W.ChevronDown,{"aria-hidden":"true",className:"text-muted-foreground"})]});return e.jsxs(i.Drawer,{open:s.open,onOpenChange:s.onOpenChange,children:[e.jsx(i.DrawerTrigger,{asChild:!0,children:t}),e.jsxs(i.DrawerContent,{dataHook:`${l}-drawer`,children:[e.jsxs(i.DrawerHeader,{children:[e.jsx(i.DrawerTitle,{children:a}),e.jsx(i.DrawerDescription,{className:"sr-only",children:o??"Pick one option."})]}),e.jsxs(i.DrawerBody,{className:"flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto pb-2",children:[e.jsx(R.RadioGroup,{className:"grid grid-cols-2 gap-x-4 gap-y-3",dataHook:`${l}-radio-group`,value:s.value,onValueChange:r=>{s.setValue(r)},children:c.map((r,J)=>{const K=r.disabled||r.count===0,B=`${z}-${J}`;return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(R.RadioGroupItem,{"data-hook":`${l}-option-${r.value}`,disabled:K,id:B,value:r.value}),e.jsxs(Y.Label,{className:"flex-1 gap-2",htmlFor:B,children:[r.icon?e.jsx(y,{dataHook:`${l}-option-${r.value}-icon`,children:r.icon}):null,r.label]}),r.count!==void 0?e.jsx(H,{count:r.count}):null]},r.value)})}),$&&s.value!==m?e.jsx(G.Button,{dataHook:`${l}-clear`,variant:"ghost",onClick:()=>s.clear(),children:f??"Clear filters"}):null]}),e.jsx(i.DrawerFooter,{children:e.jsx(i.DrawerClose,{asChild:!0,children:e.jsx(G.Button,{dataHook:`${l}-done`,children:w??"Done"})})})]})]})}return e.jsx("span",{"data-hook":l,"data-slot":"single-select-filter","data-tracking-el":N??"single-select-filter","data-tracking-label":O,children:e.jsxs(g.Select,{disabled:v,open:s.open,value:s.value,onOpenChange:s.onOpenChange,onValueChange:t=>s.setValue(t),children:[e.jsxs(g.SelectTrigger,{ref:q,className:P.cn(_.multiSelectFilterTriggerVariants({size:j}),"data-[placeholder]:text-foreground w-auto",n),dataHook:`${l}-trigger`,selectLabel:k??V,...F,children:[I,e.jsx(g.SelectValue,{placeholder:a,children:D})]}),e.jsx(g.SelectContent,{align:"start",children:c.map(t=>{const r=t.disabled||t.count===0;return e.jsx(g.SelectItem,{"data-hook":`${l}-option-${t.value}`,disabled:r,hint:t.count!==void 0?e.jsx("span",{className:"tabular-nums",children:t.count}):void 0,value:t.value,children:e.jsxs("span",{className:"flex items-center gap-2",children:[t.icon?e.jsx(y,{dataHook:`${l}-option-${t.value}-icon`,children:t.icon}):null,t.label]})},t.value)})})]})})}const ee=M;M.displayName="SingleSelectFilter";exports.SingleSelectFilter=ee;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { VariantProps } from 'class-variance-authority';
|
|
2
|
+
import { multiSelectFilterTriggerVariants } from './multi-select-filter';
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
interface SingleSelectFilterOption<Value extends string = string> {
|
|
5
|
+
value: Value;
|
|
6
|
+
label: string;
|
|
7
|
+
count?: number;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Glyph before the label in the menu and the drawer — the option's own
|
|
11
|
+
* mark (a source's logo, a period's clock), 16px. The trigger wears the
|
|
12
|
+
* picked option's glyph when no `icon` is set. Hidden from assistive tech.
|
|
13
|
+
*/
|
|
14
|
+
icon?: React.ReactNode;
|
|
15
|
+
}
|
|
16
|
+
interface SingleSelectFilterProps<Value extends string = string> extends Omit<React.ComponentPropsWithoutRef<"button">, "value" | "defaultValue" | "onChange" | "children">, VariantProps<typeof multiSelectFilterTriggerVariants> {
|
|
17
|
+
/** Data hook for automated testing (REQUIRED). */
|
|
18
|
+
dataHook: string;
|
|
19
|
+
/**
|
|
20
|
+
* The dimension's name — drawer title, Select accessible label.
|
|
21
|
+
* Use the product's words ("Time period"), never an internal field name.
|
|
22
|
+
*/
|
|
23
|
+
label: string;
|
|
24
|
+
/**
|
|
25
|
+
* The selectable options, in the dimension's own order. Values must be
|
|
26
|
+
* non-empty — `""` means "nothing picked", so make "All" an explicit value.
|
|
27
|
+
*/
|
|
28
|
+
options: readonly SingleSelectFilterOption<Value>[];
|
|
29
|
+
/** Controlled selected value. */
|
|
30
|
+
value?: Value;
|
|
31
|
+
/**
|
|
32
|
+
* Initial value for uncontrolled mode.
|
|
33
|
+
* @default ""
|
|
34
|
+
*/
|
|
35
|
+
defaultValue?: Value;
|
|
36
|
+
/** Callback on every pick. */
|
|
37
|
+
onValueChange?: (value: Value) => void;
|
|
38
|
+
/** Controlled open state. */
|
|
39
|
+
open?: boolean;
|
|
40
|
+
/** Callback when the surface opens or closes. */
|
|
41
|
+
onOpenChange?: (open: boolean) => void;
|
|
42
|
+
/**
|
|
43
|
+
* Fixed glyph leading the trigger — the dimension's own icon (a calendar,
|
|
44
|
+
* a funnel), 16px. Without it the trigger wears the picked option's
|
|
45
|
+
* `option.icon`. Hidden from assistive tech.
|
|
46
|
+
*/
|
|
47
|
+
icon?: React.ReactNode;
|
|
48
|
+
/**
|
|
49
|
+
* How the options open: the DS Select `menu`, a bottom `drawer`, or `auto`
|
|
50
|
+
* — the menu from the md breakpoint up and the drawer below it.
|
|
51
|
+
* @default "menu"
|
|
52
|
+
*/
|
|
53
|
+
presentation?: "menu" | "drawer" | "auto";
|
|
54
|
+
/** Disables the trigger. */
|
|
55
|
+
disabled?: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Label of the clear action inside the drawer.
|
|
58
|
+
* @default "Clear filters"
|
|
59
|
+
*/
|
|
60
|
+
clearLabel?: string;
|
|
61
|
+
/**
|
|
62
|
+
* Label of the drawer's Done button.
|
|
63
|
+
* @default "Done"
|
|
64
|
+
*/
|
|
65
|
+
doneLabel?: string;
|
|
66
|
+
/**
|
|
67
|
+
* Screen-reader description of the drawer.
|
|
68
|
+
* @default "Pick one option."
|
|
69
|
+
*/
|
|
70
|
+
drawerDescription?: string;
|
|
71
|
+
/** Analytics element identifier. @default "single-select-filter" */
|
|
72
|
+
trackingEl?: string;
|
|
73
|
+
/** Analytics label */
|
|
74
|
+
trackingLabel?: string;
|
|
75
|
+
}
|
|
76
|
+
declare const SingleSelectFilter: <Value extends string = string>(props: SingleSelectFilterProps<Value> & {
|
|
77
|
+
ref?: React.Ref<HTMLButtonElement>;
|
|
78
|
+
}) => React.ReactElement | null;
|
|
79
|
+
export { SingleSelectFilter, type SingleSelectFilterOption };
|
|
80
|
+
export type { SingleSelectFilterProps };
|
|
81
|
+
//# sourceMappingURL=single-select-filter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"single-select-filter.d.ts","sourceRoot":"","sources":["../../src/components/single-select-filter.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AA6B7D,OAAO,EAAE,gCAAgC,EAAE,MAAM,gDAAgD,CAAC;AAwBlG,UAAU,wBAAwB,CAAC,KAAK,SAAS,MAAM,GAAG,MAAM;IAC9D,KAAK,EAAE,KAAK,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;;OAIG;IACH,IAAI,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CACxB;AAED,UAAU,uBAAuB,CAAC,KAAK,SAAS,MAAM,GAAG,MAAM,CAC7D,SACE,IAAI,CACF,KAAK,CAAC,wBAAwB,CAAC,QAAQ,CAAC,EACxC,OAAO,GAAG,cAAc,GAAG,UAAU,GAAG,UAAU,CACnD,EACD,YAAY,CAAC,OAAO,gCAAgC,CAAC;IACvD,kDAAkD;IAClD,QAAQ,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,OAAO,EAAE,SAAS,wBAAwB,CAAC,KAAK,CAAC,EAAE,CAAC;IACpD,iCAAiC;IACjC,KAAK,CAAC,EAAE,KAAK,CAAC;IACd;;;OAGG;IACH,YAAY,CAAC,EAAE,KAAK,CAAC;IACrB,8BAA8B;IAC9B,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACvC,6BAA6B;IAC7B,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,iDAAiD;IACjD,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACvC;;;;OAIG;IACH,IAAI,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACvB;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,MAAM,CAAC;IAC1C,4BAA4B;IAC5B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,oEAAoE;IACpE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,sBAAsB;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAySD,QAAA,MAAM,kBAAkB,EAA8B,CACpD,KAAK,SAAS,MAAM,GAAG,MAAM,EAE7B,KAAK,EAAE,uBAAuB,CAAC,KAAK,CAAC,GAAG;IACtC,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;CACpC,KACE,KAAK,CAAC,YAAY,GAAG,IAAI,CAAC;AAI/B,OAAO,EAAE,kBAAkB,EAAE,KAAK,wBAAwB,EAAE,CAAC;AAC7D,YAAY,EAAE,uBAAuB,EAAE,CAAC"}
|