@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/progress.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import * as
|
|
3
|
-
import * as
|
|
4
|
-
import { motion as
|
|
5
|
-
import { cn as
|
|
6
|
-
import { usePrefersReducedMotion as
|
|
7
|
-
import { SPRING_GENTLE as
|
|
8
|
-
const
|
|
1
|
+
import { jsx as a, jsxs as k } from "react/jsx-runtime";
|
|
2
|
+
import * as N from "react";
|
|
3
|
+
import * as R from "@radix-ui/react-progress";
|
|
4
|
+
import { motion as H } from "framer-motion";
|
|
5
|
+
import { cn as n } from "@brightlocal/ui-components/lib/utils";
|
|
6
|
+
import { usePrefersReducedMotion as O } from "@brightlocal/ui-components/hooks/use-prefers-reduced-motion";
|
|
7
|
+
import { SPRING_GENTLE as V } from "./lib/motion.js";
|
|
8
|
+
const L = {
|
|
9
9
|
sm: { text: "text-body-sm", bar: "h-2" },
|
|
10
10
|
md: { text: "text-body", bar: "h-3" }
|
|
11
|
-
},
|
|
11
|
+
}, P = {
|
|
12
12
|
green: {
|
|
13
13
|
track: "bg-brand-primary-foreground/20",
|
|
14
14
|
indicator: "bg-green-400"
|
|
@@ -25,126 +25,140 @@ const k = {
|
|
|
25
25
|
track: "bg-brand-yellow/20",
|
|
26
26
|
indicator: "bg-brand-yellow"
|
|
27
27
|
}
|
|
28
|
-
},
|
|
29
|
-
function
|
|
30
|
-
if (
|
|
28
|
+
}, Y = "40%";
|
|
29
|
+
function F(t, e, r) {
|
|
30
|
+
if (t == null)
|
|
31
31
|
return "–";
|
|
32
32
|
if (r === "%")
|
|
33
|
-
return `${
|
|
34
|
-
const
|
|
35
|
-
return
|
|
33
|
+
return `${e > 0 ? Math.min(100, Math.max(0, Math.round(t / e * 100))) : 0}%`;
|
|
34
|
+
const i = r ? ` ${r}` : "";
|
|
35
|
+
return e > 0 ? `${t} / ${e}${i}` : `${t}${i}`;
|
|
36
36
|
}
|
|
37
|
-
const
|
|
37
|
+
const U = N.forwardRef(
|
|
38
38
|
({
|
|
39
|
-
className:
|
|
40
|
-
value:
|
|
39
|
+
className: t,
|
|
40
|
+
value: e,
|
|
41
41
|
max: r = 100,
|
|
42
|
-
dataHook:
|
|
43
|
-
trackingEl:
|
|
44
|
-
trackingLabel:
|
|
45
|
-
ariaLabel:
|
|
46
|
-
label:
|
|
47
|
-
labelWidth:
|
|
48
|
-
color:
|
|
49
|
-
size:
|
|
50
|
-
showValue:
|
|
51
|
-
unit:
|
|
52
|
-
|
|
42
|
+
dataHook: i,
|
|
43
|
+
trackingEl: m,
|
|
44
|
+
trackingLabel: S,
|
|
45
|
+
ariaLabel: T = "Progress",
|
|
46
|
+
label: o,
|
|
47
|
+
labelWidth: f = Y,
|
|
48
|
+
color: $ = "green",
|
|
49
|
+
size: E = "sm",
|
|
50
|
+
showValue: l = !1,
|
|
51
|
+
unit: I = "%",
|
|
52
|
+
valueFormatter: M,
|
|
53
|
+
indicatorClassName: _,
|
|
53
54
|
disabled: p,
|
|
54
|
-
...
|
|
55
|
-
},
|
|
56
|
-
const
|
|
57
|
-
|
|
55
|
+
...z
|
|
56
|
+
}, B) => {
|
|
57
|
+
const u = N.useId(), s = o != null && o !== "", b = typeof o == "string" || typeof o == "number", h = s && b, d = M ?? ((D, G) => F(D, G, I)), w = d(e, r), j = O(), y = P[$] ?? P.green, c = L[E] ?? L.sm, g = f === "auto", A = s || l, v = Math.min(r, Math.max(0, e ?? 0)), C = r > 0 ? v / r * 100 : 0, x = /* @__PURE__ */ a(
|
|
58
|
+
R.Root,
|
|
58
59
|
{
|
|
59
|
-
ref:
|
|
60
|
-
"aria-label":
|
|
61
|
-
"aria-labelledby":
|
|
62
|
-
className:
|
|
60
|
+
ref: B,
|
|
61
|
+
"aria-label": h ? void 0 : T,
|
|
62
|
+
"aria-labelledby": h ? u : void 0,
|
|
63
|
+
className: n(
|
|
63
64
|
"relative w-full overflow-hidden rounded-full",
|
|
64
65
|
// Inside the row wrapper the bar fills whatever the fixed label and
|
|
65
66
|
// value columns leave over; standalone it must not flex at all.
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
!
|
|
70
|
-
|
|
67
|
+
A && "min-w-0 flex-1",
|
|
68
|
+
c.bar,
|
|
69
|
+
y.track,
|
|
70
|
+
!s && !l && p && "opacity-50",
|
|
71
|
+
t
|
|
71
72
|
),
|
|
72
|
-
"data-hook":
|
|
73
|
+
"data-hook": i,
|
|
73
74
|
"data-slot": "progress",
|
|
74
|
-
"data-tracking-el":
|
|
75
|
-
"data-tracking-label":
|
|
75
|
+
"data-tracking-el": m,
|
|
76
|
+
"data-tracking-label": S,
|
|
77
|
+
getValueLabel: () => w,
|
|
76
78
|
max: r,
|
|
77
|
-
value:
|
|
78
|
-
...
|
|
79
|
-
children: /* @__PURE__ */
|
|
80
|
-
|
|
79
|
+
value: v,
|
|
80
|
+
...z,
|
|
81
|
+
children: /* @__PURE__ */ a(R.Indicator, { asChild: !0, children: /* @__PURE__ */ a(
|
|
82
|
+
H.div,
|
|
81
83
|
{
|
|
82
84
|
animate: {
|
|
83
|
-
transform: `translateX(-${100 -
|
|
85
|
+
transform: `translateX(-${100 - C}%)`
|
|
84
86
|
},
|
|
85
|
-
className:
|
|
87
|
+
className: n(
|
|
86
88
|
"h-full w-full flex-1",
|
|
87
|
-
|
|
88
|
-
|
|
89
|
+
y.indicator,
|
|
90
|
+
_
|
|
89
91
|
),
|
|
90
92
|
"data-slot": "progress-indicator",
|
|
91
93
|
initial: !1,
|
|
92
|
-
transition:
|
|
94
|
+
transition: j ? { duration: 0 } : V
|
|
93
95
|
}
|
|
94
96
|
) })
|
|
95
97
|
}
|
|
96
98
|
);
|
|
97
|
-
return !
|
|
99
|
+
return !s && !l ? x : /* @__PURE__ */ k(
|
|
98
100
|
"div",
|
|
99
101
|
{
|
|
100
|
-
className:
|
|
102
|
+
className: n(
|
|
101
103
|
"flex w-full items-center gap-2",
|
|
102
104
|
p && "opacity-50"
|
|
103
105
|
),
|
|
104
106
|
"data-slot": "progress-wrapper",
|
|
105
107
|
children: [
|
|
106
|
-
|
|
107
|
-
"
|
|
108
|
+
s && /* @__PURE__ */ a(
|
|
109
|
+
"div",
|
|
108
110
|
{
|
|
109
|
-
className:
|
|
111
|
+
className: n(
|
|
110
112
|
"text-foreground shrink-0 break-words",
|
|
111
113
|
// `auto`: hug the text but never take more than 40% of the row,
|
|
112
114
|
// so an overlong label still wraps instead of squeezing the bar.
|
|
113
|
-
|
|
114
|
-
|
|
115
|
+
g && "max-w-2/5",
|
|
116
|
+
// A node label (Rating, icon) sits on the row's centre line like
|
|
117
|
+
// text would; text keeps inline flow so it can wrap.
|
|
118
|
+
!b && "flex items-center",
|
|
119
|
+
c.text
|
|
115
120
|
),
|
|
116
|
-
"data-label-width":
|
|
121
|
+
"data-label-width": g ? "auto" : void 0,
|
|
117
122
|
"data-slot": "progress-label",
|
|
118
|
-
id:
|
|
119
|
-
style:
|
|
120
|
-
children:
|
|
123
|
+
id: u,
|
|
124
|
+
style: g ? void 0 : { width: f },
|
|
125
|
+
children: o
|
|
121
126
|
}
|
|
122
127
|
),
|
|
123
|
-
|
|
124
|
-
|
|
128
|
+
x,
|
|
129
|
+
l && /* @__PURE__ */ k(
|
|
125
130
|
"span",
|
|
126
131
|
{
|
|
127
|
-
className:
|
|
132
|
+
className: n(
|
|
128
133
|
"text-muted-foreground grid min-w-10 shrink-0 text-right tabular-nums",
|
|
129
|
-
|
|
134
|
+
c.text
|
|
130
135
|
),
|
|
131
136
|
"data-slot": "progress-value",
|
|
132
137
|
children: [
|
|
133
|
-
/* @__PURE__ */
|
|
138
|
+
/* @__PURE__ */ a(
|
|
134
139
|
"span",
|
|
135
140
|
{
|
|
136
141
|
"aria-hidden": "true",
|
|
137
142
|
className: "invisible col-start-1 row-start-1",
|
|
138
143
|
"data-slot": "progress-value-sizer",
|
|
139
|
-
children:
|
|
144
|
+
children: d(r, r)
|
|
145
|
+
}
|
|
146
|
+
),
|
|
147
|
+
/* @__PURE__ */ a(
|
|
148
|
+
"span",
|
|
149
|
+
{
|
|
150
|
+
"aria-hidden": "true",
|
|
151
|
+
className: "invisible col-start-1 row-start-1",
|
|
152
|
+
"data-slot": "progress-value-sizer-min",
|
|
153
|
+
children: d(0, r)
|
|
140
154
|
}
|
|
141
155
|
),
|
|
142
|
-
/* @__PURE__ */
|
|
156
|
+
/* @__PURE__ */ a(
|
|
143
157
|
"span",
|
|
144
158
|
{
|
|
145
159
|
className: "col-start-1 row-start-1",
|
|
146
160
|
"data-slot": "progress-value-text",
|
|
147
|
-
children:
|
|
161
|
+
children: w
|
|
148
162
|
}
|
|
149
163
|
)
|
|
150
164
|
]
|
|
@@ -155,7 +169,7 @@ const C = y.forwardRef(
|
|
|
155
169
|
);
|
|
156
170
|
}
|
|
157
171
|
);
|
|
158
|
-
|
|
172
|
+
U.displayName = "Progress";
|
|
159
173
|
export {
|
|
160
|
-
|
|
174
|
+
U as Progress
|
|
161
175
|
};
|
package/dist/rating.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 i=require("react/jsx-runtime"),h=require("react"),d=require("@brightlocal/icons"),y=require("@brightlocal/ui-components/lib/utils");function S(t){const a=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const e in t)if(e!=="default"){const r=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(a,e,r.get?r:{enumerable:!0,get:()=>t[e]})}}return a.default=t,Object.freeze(a)}const v=S(h),N={sm:16,md:24},u=v.forwardRef(({value:t,dataHook:a,size:e="sm",ariaLabel:r,trackingEl:g,trackingLabel:m,className:f,...p},b)=>{const s=Math.max(0,Math.min(5,t)),o=N[e];return i.jsx("div",{ref:b,"aria-label":r?r.replace("{value}",String(s)):`Rating: ${s} out of 5 stars`,className:y.cn("flex items-center gap-0.5",f),"data-hook":a,"data-slot":"rating","data-tracking-el":g,"data-tracking-label":m,role:"img",...p,children:[...Array(5)].map((k,n)=>{const j=n+1,l=s>=j,c=!l&&s>n,R=c?((s-n)*100).toFixed(0):l?"100":"0";return i.jsxs("div",{className:"relative","data-slot":"rating-star",children:[i.jsx(d.StarRating,{className:"fill-muted stroke-muted","data-slot":"rating-star-base",size:o}),(l||c)&&i.jsx("div",{"aria-hidden":"true",className:"absolute inset-0 overflow-hidden","data-slot":"rating-star-fill",style:{width:`${R}%`},children:i.jsx(d.StarRating,{className:"fill-rating stroke-rating",size:o})})]},n)})})});u.displayName="Rating";exports.Rating=u;
|
package/dist/rating.js
CHANGED
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
import { jsx as e, jsxs as
|
|
2
|
-
import * as
|
|
1
|
+
import { jsx as e, jsxs as N } from "react/jsx-runtime";
|
|
2
|
+
import * as R from "react";
|
|
3
3
|
import { StarRating as o } from "@brightlocal/icons";
|
|
4
|
-
import { cn as
|
|
5
|
-
const
|
|
4
|
+
import { cn as k } from "@brightlocal/ui-components/lib/utils";
|
|
5
|
+
const y = {
|
|
6
6
|
sm: 16,
|
|
7
7
|
md: 24
|
|
8
|
-
},
|
|
8
|
+
}, z = R.forwardRef(
|
|
9
9
|
({
|
|
10
10
|
value: n,
|
|
11
11
|
dataHook: m,
|
|
12
12
|
size: c = "sm",
|
|
13
|
-
ariaLabel:
|
|
13
|
+
ariaLabel: s,
|
|
14
14
|
trackingEl: d,
|
|
15
15
|
trackingLabel: g,
|
|
16
16
|
className: f,
|
|
17
17
|
...p
|
|
18
18
|
}, u) => {
|
|
19
|
-
const a = Math.max(0, Math.min(5, n)),
|
|
19
|
+
const a = Math.max(0, Math.min(5, n)), i = y[c];
|
|
20
20
|
return /* @__PURE__ */ e(
|
|
21
21
|
"div",
|
|
22
22
|
{
|
|
23
23
|
ref: u,
|
|
24
|
-
"aria-label":
|
|
25
|
-
className:
|
|
24
|
+
"aria-label": s ? s.replace("{value}", String(a)) : `Rating: ${a} out of 5 stars`,
|
|
25
|
+
className: k("flex items-center gap-0.5", f),
|
|
26
26
|
"data-hook": m,
|
|
27
27
|
"data-slot": "rating",
|
|
28
28
|
"data-tracking-el": d,
|
|
29
29
|
"data-tracking-label": g,
|
|
30
30
|
role: "img",
|
|
31
31
|
...p,
|
|
32
|
-
children: [...Array(5)].map((
|
|
33
|
-
const h = t + 1,
|
|
34
|
-
return /* @__PURE__ */
|
|
32
|
+
children: [...Array(5)].map((S, t) => {
|
|
33
|
+
const h = t + 1, r = a >= h, l = !r && a > t, v = l ? ((a - t) * 100).toFixed(0) : r ? "100" : "0";
|
|
34
|
+
return /* @__PURE__ */ N("div", { className: "relative", "data-slot": "rating-star", children: [
|
|
35
35
|
/* @__PURE__ */ e(
|
|
36
36
|
o,
|
|
37
37
|
{
|
|
38
38
|
className: "fill-muted stroke-muted",
|
|
39
39
|
"data-slot": "rating-star-base",
|
|
40
|
-
size:
|
|
40
|
+
size: i
|
|
41
41
|
}
|
|
42
42
|
),
|
|
43
|
-
(
|
|
43
|
+
(r || l) && /* @__PURE__ */ e(
|
|
44
44
|
"div",
|
|
45
45
|
{
|
|
46
46
|
"aria-hidden": "true",
|
|
@@ -52,8 +52,8 @@ const k = {
|
|
|
52
52
|
children: /* @__PURE__ */ e(
|
|
53
53
|
o,
|
|
54
54
|
{
|
|
55
|
-
className: "fill-
|
|
56
|
-
size:
|
|
55
|
+
className: "fill-rating stroke-rating",
|
|
56
|
+
size: i
|
|
57
57
|
}
|
|
58
58
|
)
|
|
59
59
|
}
|
|
@@ -64,7 +64,7 @@ const k = {
|
|
|
64
64
|
);
|
|
65
65
|
}
|
|
66
66
|
);
|
|
67
|
-
|
|
67
|
+
z.displayName = "Rating";
|
|
68
68
|
export {
|
|
69
|
-
|
|
69
|
+
z as Rating
|
|
70
70
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),h=require("react"),w=require("@brightlocal/ui-components/lib/utils"),l=require("@brightlocal/ui-components/tooltip"),D={justNow:"just now",minuteAgo:"1 minute ago",minutesAgo:"{n} minutes ago",hourAgo:"1 hour ago",hoursAgo:"{n} hours ago",today:"today",yesterday:"yesterday",daysAgo:"{n} days ago",unknown:"unknown"},T=1e3,M=60*T,$=60*M,E=24*$,v=/^\d{4}-\d{2}-\d{2}$/;function m(t){return typeof t=="string"&&v.test(t)}function x(t){return t instanceof Date?t:new Date(m(t)?`${t}T00:00:00`:t)}const L=t=>new Date(t.getFullYear(),t.getMonth(),t.getDate()).getTime(),f=(t,n)=>t.replace("{n}",String(n));function y(t,n=new Date){return t.toLocaleDateString("en-US",{month:"long",day:"numeric",...t.getFullYear()===n.getFullYear()?{}:{year:"numeric"}})}function j(t,n){const e=t.toLocaleDateString("en-US",{month:"long",day:"numeric",year:"numeric"});if(n)return e;const i=t.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit"}),o=-t.getTimezoneOffset(),r=o>=0?"+":"-",c=Math.floor(Math.abs(o)/60),a=Math.abs(o)%60,u=`${r}${c}${a?`:${String(a).padStart(2,"0")}`:""}`;return`${e} at ${i} UTC${u}`}function p(t,n,e=D){const i=x(t);if(m(t)){const d=Math.max(0,Math.round((L(n)-L(i))/E));return d===0?e.today:d===1?e.yesterday:d<7?f(e.daysAgo,d):y(i,n)}const o=Math.max(0,n.getTime()-i.getTime()),r=o/T,c=o/M,a=o/$,u=o/E;return r<45?e.justNow:r<90?e.minuteAgo:c<45?f(e.minutesAgo,Math.round(c)):c<90?e.hourAgo:a<22?f(e.hoursAgo,Math.round(a)):a<36?e.yesterday:u<7?f(e.daysAgo,Math.round(u)):y(i,n)}function N(t=30*T){const[n,e]=h.useState(()=>new Date);return h.useEffect(()=>{const i=()=>e(new Date),o=window.setInterval(i,t),r=()=>{document.visibilityState==="visible"&&i()};return document.addEventListener("visibilitychange",r),()=>{window.clearInterval(o),document.removeEventListener("visibilitychange",r)}},[t]),n}const R=h.forwardRef(function({value:n,label:e,labels:i,className:o,dataHook:r,trackingEl:c,trackingLabel:a},u){const d=N(),S={...D,...i};if(n==null)return s.jsxs("span",{ref:u,className:w.cn("text-body-xs text-muted-foreground",o),"data-hook":r,"data-slot":"relative-date","data-tracking-el":c,"data-tracking-label":a,children:[e&&s.jsxs(s.Fragment,{children:[e," "]}),S.unknown]});const A=m(n),g=x(n),O=A?`${g.getFullYear()}-${String(g.getMonth()+1).padStart(2,"0")}-${String(g.getDate()).padStart(2,"0")}`:g.toISOString();return s.jsxs("span",{ref:u,className:w.cn("text-body-xs text-muted-foreground",o),"data-hook":r,"data-slot":"relative-date","data-tracking-el":c,"data-tracking-label":a,children:[e&&s.jsxs(s.Fragment,{children:[e," "]}),s.jsxs(l.Tooltip,{children:[s.jsx(l.TooltipTrigger,{className:"focus-visible:shadow-default cursor-default rounded-xs underline decoration-dotted decoration-1 underline-offset-4 focus-visible:outline-none",dataHook:`${r}-trigger`,children:s.jsx("time",{dateTime:O,children:p(n,d,S)})}),s.jsx(l.TooltipContent,{dataHook:`${r}-tooltip`,side:"bottom",children:j(g,A)})]})]})});exports.DEFAULT_RELATIVE_DATE_LABELS=D;exports.RelativeDate=R;exports.dateLabel=y;exports.exactText=j;exports.isDateOnly=m;exports.relativeWords=p;exports.toDate=x;exports.useNow=N;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
export interface RelativeDateLabels {
|
|
2
|
+
/** @default "just now" */
|
|
3
|
+
justNow: string;
|
|
4
|
+
/** @default "1 minute ago" */
|
|
5
|
+
minuteAgo: string;
|
|
6
|
+
/**
|
|
7
|
+
* `{n}` is replaced with the count.
|
|
8
|
+
* @default "{n} minutes ago"
|
|
9
|
+
*/
|
|
10
|
+
minutesAgo: string;
|
|
11
|
+
/** @default "1 hour ago" */
|
|
12
|
+
hourAgo: string;
|
|
13
|
+
/**
|
|
14
|
+
* `{n}` is replaced with the count.
|
|
15
|
+
* @default "{n} hours ago"
|
|
16
|
+
*/
|
|
17
|
+
hoursAgo: string;
|
|
18
|
+
/** @default "today" */
|
|
19
|
+
today: string;
|
|
20
|
+
/** @default "yesterday" */
|
|
21
|
+
yesterday: string;
|
|
22
|
+
/**
|
|
23
|
+
* `{n}` is replaced with the count.
|
|
24
|
+
* @default "{n} days ago"
|
|
25
|
+
*/
|
|
26
|
+
daysAgo: string;
|
|
27
|
+
/** @default "unknown" */
|
|
28
|
+
unknown: string;
|
|
29
|
+
}
|
|
30
|
+
export declare const DEFAULT_RELATIVE_DATE_LABELS: RelativeDateLabels;
|
|
31
|
+
export interface RelativeDateProps {
|
|
32
|
+
/**
|
|
33
|
+
* When it happened. An ISO 8601 timestamp (UTC from the API) or a Date for
|
|
34
|
+
* a value with a time of day; a plain `YYYY-MM-DD` string for a calendar
|
|
35
|
+
* date with no time of day. `null` or `undefined` renders the `unknown`
|
|
36
|
+
* label, plain.
|
|
37
|
+
*/
|
|
38
|
+
value: string | Date | null | undefined;
|
|
39
|
+
/**
|
|
40
|
+
* Contextual label rendered before the value (e.g. "Last updated").
|
|
41
|
+
* The component owns its styling — consumers never need to style it.
|
|
42
|
+
*/
|
|
43
|
+
label?: string;
|
|
44
|
+
/**
|
|
45
|
+
* Translatable words. Each key defaults to its English value.
|
|
46
|
+
* @default DEFAULT_RELATIVE_DATE_LABELS
|
|
47
|
+
*/
|
|
48
|
+
labels?: Partial<RelativeDateLabels>;
|
|
49
|
+
/** Outer layout only (margin, placement). The look is the component's. */
|
|
50
|
+
className?: string;
|
|
51
|
+
/** Required test hook identifier */
|
|
52
|
+
dataHook: string;
|
|
53
|
+
/** Analytics element identifier */
|
|
54
|
+
trackingEl?: string;
|
|
55
|
+
/** Analytics label */
|
|
56
|
+
trackingLabel?: string;
|
|
57
|
+
}
|
|
58
|
+
export declare function isDateOnly(value: string | Date): boolean;
|
|
59
|
+
export declare function toDate(value: string | Date): Date;
|
|
60
|
+
export declare function dateLabel(date: Date, now?: Date): string;
|
|
61
|
+
export declare function exactText(date: Date, dateOnly: boolean): string;
|
|
62
|
+
export declare function relativeWords(value: string | Date, now: Date, labels?: RelativeDateLabels): string;
|
|
63
|
+
export declare function useNow(every?: number): Date;
|
|
64
|
+
export declare const RelativeDate: import('react').ForwardRefExoticComponent<RelativeDateProps & import('react').RefAttributes<HTMLElement>>;
|
|
65
|
+
//# sourceMappingURL=relative-date.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"relative-date.d.ts","sourceRoot":"","sources":["../../src/components/relative-date.tsx"],"names":[],"mappings":"AAUA,MAAM,WAAW,kBAAkB;IACjC,0BAA0B;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,8BAA8B;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB,4BAA4B;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,QAAQ,EAAE,MAAM,CAAC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
1
|
+
import { jsxs as g, Fragment as w, jsx as m } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as N, useState as O, useEffect as k } from "react";
|
|
3
|
+
import { cn as S } from "@brightlocal/ui-components/lib/utils";
|
|
4
|
+
import { Tooltip as U, TooltipTrigger as v, TooltipContent as F } from "@brightlocal/ui-components/tooltip";
|
|
5
|
+
const x = {
|
|
6
|
+
justNow: "just now",
|
|
7
|
+
minuteAgo: "1 minute ago",
|
|
8
|
+
minutesAgo: "{n} minutes ago",
|
|
9
|
+
hourAgo: "1 hour ago",
|
|
10
|
+
hoursAgo: "{n} hours ago",
|
|
11
|
+
today: "today",
|
|
12
|
+
yesterday: "yesterday",
|
|
13
|
+
daysAgo: "{n} days ago",
|
|
14
|
+
unknown: "unknown"
|
|
15
|
+
}, h = 1e3, $ = 60 * h, M = 60 * $, T = 24 * M, Y = /^\d{4}-\d{2}-\d{2}$/;
|
|
16
|
+
function y(t) {
|
|
17
|
+
return typeof t == "string" && Y.test(t);
|
|
18
|
+
}
|
|
19
|
+
function E(t) {
|
|
20
|
+
return t instanceof Date ? t : new Date(y(t) ? `${t}T00:00:00` : t);
|
|
21
|
+
}
|
|
22
|
+
const A = (t) => new Date(t.getFullYear(), t.getMonth(), t.getDate()).getTime(), f = (t, e) => t.replace("{n}", String(e));
|
|
23
|
+
function p(t, e = /* @__PURE__ */ new Date()) {
|
|
24
|
+
return t.toLocaleDateString("en-US", {
|
|
25
|
+
month: "long",
|
|
26
|
+
day: "numeric",
|
|
27
|
+
...t.getFullYear() === e.getFullYear() ? {} : { year: "numeric" }
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
function j(t, e) {
|
|
31
|
+
const n = t.toLocaleDateString("en-US", {
|
|
32
|
+
month: "long",
|
|
33
|
+
day: "numeric",
|
|
34
|
+
year: "numeric"
|
|
35
|
+
});
|
|
36
|
+
if (e) return n;
|
|
37
|
+
const i = t.toLocaleTimeString("en-US", {
|
|
38
|
+
hour: "numeric",
|
|
39
|
+
minute: "2-digit"
|
|
40
|
+
}), o = -t.getTimezoneOffset(), r = o >= 0 ? "+" : "-", s = Math.floor(Math.abs(o) / 60), a = Math.abs(o) % 60, c = `${r}${s}${a ? `:${String(a).padStart(2, "0")}` : ""}`;
|
|
41
|
+
return `${n} at ${i} UTC${c}`;
|
|
42
|
+
}
|
|
43
|
+
function I(t, e, n = x) {
|
|
44
|
+
const i = E(t);
|
|
45
|
+
if (y(t)) {
|
|
46
|
+
const d = Math.max(
|
|
47
|
+
0,
|
|
48
|
+
Math.round((A(e) - A(i)) / T)
|
|
49
|
+
);
|
|
50
|
+
return d === 0 ? n.today : d === 1 ? n.yesterday : d < 7 ? f(n.daysAgo, d) : p(i, e);
|
|
51
|
+
}
|
|
52
|
+
const o = Math.max(0, e.getTime() - i.getTime()), r = o / h, s = o / $, a = o / M, c = o / T;
|
|
53
|
+
return r < 45 ? n.justNow : r < 90 ? n.minuteAgo : s < 45 ? f(n.minutesAgo, Math.round(s)) : s < 90 ? n.hourAgo : a < 22 ? f(n.hoursAgo, Math.round(a)) : a < 36 ? n.yesterday : c < 7 ? f(n.daysAgo, Math.round(c)) : p(i, e);
|
|
54
|
+
}
|
|
55
|
+
function R(t = 30 * h) {
|
|
56
|
+
const [e, n] = O(() => /* @__PURE__ */ new Date());
|
|
57
|
+
return k(() => {
|
|
58
|
+
const i = () => n(/* @__PURE__ */ new Date()), o = window.setInterval(i, t), r = () => {
|
|
59
|
+
document.visibilityState === "visible" && i();
|
|
60
|
+
};
|
|
61
|
+
return document.addEventListener("visibilitychange", r), () => {
|
|
62
|
+
window.clearInterval(o), document.removeEventListener("visibilitychange", r);
|
|
63
|
+
};
|
|
64
|
+
}, [t]), e;
|
|
65
|
+
}
|
|
66
|
+
const z = N(
|
|
67
|
+
function({ value: e, label: n, labels: i, className: o, dataHook: r, trackingEl: s, trackingLabel: a }, c) {
|
|
68
|
+
const d = R(), l = { ...x, ...i };
|
|
69
|
+
if (e == null)
|
|
70
|
+
return /* @__PURE__ */ g(
|
|
71
|
+
"span",
|
|
72
|
+
{
|
|
73
|
+
ref: c,
|
|
74
|
+
className: S("text-body-xs text-muted-foreground", o),
|
|
75
|
+
"data-hook": r,
|
|
76
|
+
"data-slot": "relative-date",
|
|
77
|
+
"data-tracking-el": s,
|
|
78
|
+
"data-tracking-label": a,
|
|
79
|
+
children: [
|
|
80
|
+
n && /* @__PURE__ */ g(w, { children: [
|
|
81
|
+
n,
|
|
82
|
+
" "
|
|
83
|
+
] }),
|
|
84
|
+
l.unknown
|
|
85
|
+
]
|
|
86
|
+
}
|
|
87
|
+
);
|
|
88
|
+
const D = y(e), u = E(e), L = D ? `${u.getFullYear()}-${String(u.getMonth() + 1).padStart(2, "0")}-${String(u.getDate()).padStart(2, "0")}` : u.toISOString();
|
|
89
|
+
return /* @__PURE__ */ g(
|
|
90
|
+
"span",
|
|
91
|
+
{
|
|
92
|
+
ref: c,
|
|
93
|
+
className: S("text-body-xs text-muted-foreground", o),
|
|
94
|
+
"data-hook": r,
|
|
95
|
+
"data-slot": "relative-date",
|
|
96
|
+
"data-tracking-el": s,
|
|
97
|
+
"data-tracking-label": a,
|
|
98
|
+
children: [
|
|
99
|
+
n && /* @__PURE__ */ g(w, { children: [
|
|
100
|
+
n,
|
|
101
|
+
" "
|
|
102
|
+
] }),
|
|
103
|
+
/* @__PURE__ */ g(U, { children: [
|
|
104
|
+
/* @__PURE__ */ m(
|
|
105
|
+
v,
|
|
106
|
+
{
|
|
107
|
+
className: "focus-visible:shadow-default cursor-default rounded-xs underline decoration-dotted decoration-1 underline-offset-4 focus-visible:outline-none",
|
|
108
|
+
dataHook: `${r}-trigger`,
|
|
109
|
+
children: /* @__PURE__ */ m("time", { dateTime: L, children: I(e, d, l) })
|
|
110
|
+
}
|
|
111
|
+
),
|
|
112
|
+
/* @__PURE__ */ m(F, { dataHook: `${r}-tooltip`, side: "bottom", children: j(u, D) })
|
|
113
|
+
] })
|
|
114
|
+
]
|
|
115
|
+
}
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
);
|
|
119
|
+
export {
|
|
120
|
+
x as DEFAULT_RELATIVE_DATE_LABELS,
|
|
121
|
+
z as RelativeDate,
|
|
122
|
+
p as dateLabel,
|
|
123
|
+
j as exactText,
|
|
124
|
+
y as isDateOnly,
|
|
125
|
+
I as relativeWords,
|
|
126
|
+
E as toDate,
|
|
127
|
+
R as useNow
|
|
128
|
+
};
|
package/dist/select.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
2
|
-
Import: import { Combobox } from "@brightlocal/ui-components/combobox"`,[r]);const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),T=require("react"),R=require("@radix-ui/react-select"),v=require("@brightlocal/icons"),_=require("class-variance-authority"),s=require("@brightlocal/ui-components/lib/utils"),D=require("./lib/use-dev-warning.cjs"),B=require("@brightlocal/ui-components/hooks/use-overlay-pointer-lock");function y(t){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const a in t)if(a!=="default"){const o=Object.getOwnPropertyDescriptor(t,a);Object.defineProperty(r,a,o.get?o:{enumerable:!0,get:()=>t[a]})}}return r.default=t,Object.freeze(r)}const p=y(T),n=y(R);function j({children:t,onClose:r,onOpenChange:a,open:o,defaultOpen:c,...f}){const[i,l]=p.useState(c??!1),u=o!==void 0,d=u?o:i,x=p.useCallback(g=>{u||l(g),a?.(g)},[u,a]),m=p.useRef(r);p.useEffect(()=>{m.current=r},[r]);const b=p.useRef(d);return p.useEffect(()=>{b.current&&!d&&m.current?.(),b.current=d},[d]),p.useEffect(()=>()=>{b.current&&m.current?.()},[]),e.jsx(n.Root,{"data-slot":"select",defaultOpen:c,open:o,onOpenChange:x,...f,children:t})}j.displayName="Select";function w(t){return e.jsx(n.Group,{"data-slot":"select-group",...t})}w.displayName="SelectGroup";function N(t){return e.jsx(n.Value,{"data-slot":"select-value",...t})}N.displayName="SelectValue";const L=_.cva(["relative flex w-full h-9 items-center justify-between gap-2","px-3 py-2","border border-border rounded-sm outline-none transition-[border-color,box-shadow,background-color] duration-fast ease-out","bg-neutral-50 border-neutral-300","dark:bg-white/5 dark:border-white/15","text-field text-foreground","[&>span]:block [&>span]:truncate","data-[placeholder]:text-muted-foreground","focus-visible:outline-none focus-visible:border-ring dark:focus-visible:border-neutral-500 focus-visible:bg-background","focus-visible:shadow-default","data-[state=open]:border-ring","disabled:cursor-not-allowed disabled:opacity-50","[&_svg]:pointer-events-none [&_svg]:shrink-0"]);function k({className:t,children:r,placeholder:a,dataHook:o,error:c,selectLabel:f,reserveValues:i,...l}){const u=c||l["aria-invalid"]===!0||l["aria-invalid"]==="true",d=l["aria-required"]===!0||l["aria-required"]==="true",x=l["aria-label"]||f||a||"Select an option",m=u?"border-destructive-40 dark:border-destructive-40 focus-visible:border-destructive-40 dark:focus-visible:border-destructive-40 focus-visible:shadow-destructive data-[state=open]:border-destructive-40 dark:data-[state=open]:border-destructive-40 data-[state=open]:shadow-destructive":"";return e.jsxs(n.Trigger,{...l,"aria-invalid":u?"true":void 0,"aria-label":x,"aria-required":d?"true":void 0,className:s.cn(L(),m,t),"data-hook":o,"data-slot":"select-trigger",children:[i?.length?e.jsxs("span",{className:"!grid min-w-0 text-left","data-slot":"select-reserve",children:[i.map((b,g)=>e.jsx("span",{"aria-hidden":"true",className:"invisible col-start-1 row-start-1 truncate",children:b},g)),e.jsx("span",{className:"col-start-1 row-start-1 truncate",children:r})]}):r,e.jsx(n.Icon,{asChild:!0,children:e.jsx(v.ChevronDown,{className:"text-muted-foreground"})})]})}k.displayName="SelectTrigger";function C({className:t,children:r,position:a="popper",maxHeight:o,style:c,...f}){B.useOverlayPointerLock();const i=p.useRef(null);D.useDevWarning(()=>i.current?i.current.querySelectorAll('[data-slot="select-item"]').length>=100:!1,`Select contains many items. For large lists (100+), consider using <Combobox> which supports search and filtering.
|
|
2
|
+
Import: import { Combobox } from "@brightlocal/ui-components/combobox"`,[r]);const l=s.cn("relative z-50 overflow-hidden","min-w-[8rem]","rounded-md border border-border bg-popover shadow-md","text-popover-foreground","max-h-[var(--radix-select-content-available-height)]","origin-[var(--radix-select-content-transform-origin)]",s.FLOATING_CONTENT_ANIMATION),u=a==="popper"&&s.cn("data-[side=bottom]:translate-y-1","data-[side=left]:-translate-x-1","data-[side=right]:translate-x-1","data-[side=top]:-translate-y-1"),d=o!==void 0?{...c,maxHeight:`min(${o}px, var(--radix-select-content-available-height))`}:c;return e.jsx(n.Portal,{children:e.jsxs(n.Content,{className:s.cn(l,u,t),"data-slot":"select-content",position:a,style:d,...f,children:[e.jsx(S,{}),e.jsx(n.Viewport,{ref:i,className:s.cn("p-1",a==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"),children:r}),e.jsx(h,{})]})})}C.displayName="SelectContent";function O({className:t,...r}){return e.jsx(n.Label,{className:s.cn("text-muted-foreground text-label-sm px-2 py-1.5",t),"data-slot":"select-label",...r})}O.displayName="SelectLabel";function q({className:t,children:r,hint:a,...o}){const c=s.cn("relative flex w-full cursor-default select-none items-center gap-2","rounded py-1.5 pl-2 pr-8","text-label text-popover-foreground","focus:bg-accent focus:text-accent-foreground","hover:bg-accent/50 hover:text-accent-foreground","outline-none focus:outline-none","data-[disabled]:pointer-events-none data-[disabled]:opacity-50","[&_svg]:pointer-events-none [&_svg]:shrink-0");return e.jsxs(n.Item,{className:s.cn(c,t),"data-slot":"select-item",...o,children:[e.jsx("span",{className:"absolute right-2 flex size-4 items-center justify-center",children:e.jsx(n.ItemIndicator,{children:e.jsx(v.Check,{})})}),e.jsx(n.ItemText,{children:r}),a!=null&&e.jsx("span",{className:"text-label-sm text-muted-foreground ml-auto","data-slot":"select-item-hint",children:a})]})}q.displayName="SelectItem";function I({className:t,...r}){return e.jsx(n.Separator,{className:s.cn("bg-border pointer-events-none -mx-1 my-1 h-px",t),"data-slot":"select-separator",...r})}I.displayName="SelectSeparator";function S({className:t,...r}){return e.jsx(n.ScrollUpButton,{className:s.cn("flex cursor-default items-center justify-center py-1",t),"data-slot":"select-scroll-up-button",...r,children:e.jsx(v.ChevronUp,{})})}S.displayName="SelectScrollUpButton";function h({className:t,...r}){return e.jsx(n.ScrollDownButton,{className:s.cn("flex cursor-default items-center justify-center py-1",t),"data-slot":"select-scroll-down-button",...r,children:e.jsx(v.ChevronDown,{})})}h.displayName="SelectScrollDownButton";exports.Select=j;exports.SelectContent=C;exports.SelectGroup=w;exports.SelectItem=q;exports.SelectLabel=O;exports.SelectScrollDownButton=h;exports.SelectScrollUpButton=S;exports.SelectSeparator=I;exports.SelectTrigger=k;exports.SelectValue=N;
|
package/dist/select.d.ts
CHANGED
|
@@ -78,11 +78,21 @@ interface SelectTriggerProps extends React.ComponentProps<typeof SelectPrimitive
|
|
|
78
78
|
* @default "Select an option"
|
|
79
79
|
*/
|
|
80
80
|
selectLabel?: string;
|
|
81
|
+
/**
|
|
82
|
+
* The visible labels this select can show, rendered invisibly inside the
|
|
83
|
+
* trigger so it always reserves the width of the widest one. Keeps the
|
|
84
|
+
* trigger — and the row around it, e.g. a CardToolbar filter row — from
|
|
85
|
+
* resizing and reflowing when the selection changes (DS-989). Include the
|
|
86
|
+
* placeholder if it can be the longest. For long option lists pass just a
|
|
87
|
+
* handful of the longest labels — every entry renders a hidden span.
|
|
88
|
+
* @example <SelectTrigger reserveValues={["All ratings", "4 stars and up"]}>
|
|
89
|
+
*/
|
|
90
|
+
reserveValues?: React.ReactNode[];
|
|
81
91
|
}
|
|
82
92
|
/**
|
|
83
93
|
* SelectTrigger - The button that opens the select dropdown
|
|
84
94
|
*/
|
|
85
|
-
declare function SelectTrigger({ className, children, placeholder, dataHook, error, selectLabel, ...props }: SelectTriggerProps): import("react/jsx-runtime").JSX.Element;
|
|
95
|
+
declare function SelectTrigger({ className, children, placeholder, dataHook, error, selectLabel, reserveValues, ...props }: SelectTriggerProps): import("react/jsx-runtime").JSX.Element;
|
|
86
96
|
declare namespace SelectTrigger {
|
|
87
97
|
var displayName: string;
|
|
88
98
|
}
|
package/dist/select.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"select.d.ts","sourceRoot":"","sources":["../../src/components/select.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,eAAe,MAAM,wBAAwB,CAAC;AAe1D,UAAU,WAAY,SAAQ,KAAK,CAAC,cAAc,CAChD,OAAO,eAAe,CAAC,IAAI,CAC5B;IACC,2CAA2C;IAC3C,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B;;;;;;;;;;;;;OAaG;IACH,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB;AAED,UAAU,kBAAmB,SAAQ,KAAK,CAAC,cAAc,CACvD,OAAO,eAAe,CAAC,OAAO,CAC/B;IACC;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAMD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,iBAAS,MAAM,CAAC,EACd,QAAQ,EACR,OAAO,EACP,YAAY,EACZ,IAAI,EAAE,QAAQ,EACd,WAAW,EACX,GAAG,KAAK,EACT,EAAE,WAAW,2CAgEb;kBAvEQ,MAAM;;;AA2Ef;;GAEG;AACH,iBAAS,WAAW,CAClB,KAAK,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,eAAe,CAAC,KAAK,CAAC,2CAG1D;kBAJQ,WAAW;;;AAQpB;;GAEG;AACH,iBAAS,WAAW,CAClB,KAAK,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,eAAe,CAAC,KAAK,CAAC,2CAG1D;kBAJQ,WAAW;;;AA8CpB,UAAU,kBAAmB,SAAQ,KAAK,CAAC,cAAc,CACvD,OAAO,eAAe,CAAC,OAAO,CAC/B;IACC,iDAAiD;IACjD,WAAW,CAAC,EA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