@brightlocal/ui-components 0.5.0 → 1.0.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/dist/alert.d.ts +2 -2
- package/dist/blocks/sidebar.d.ts +2 -2
- package/dist/button.d.ts +2 -2
- package/dist/combobox.cjs +1 -1
- package/dist/combobox.d.ts +6 -2
- package/dist/combobox.d.ts.map +1 -1
- package/dist/combobox.js +144 -133
- package/dist/field.cjs +1 -1
- package/dist/field.d.ts +8 -1
- package/dist/field.d.ts.map +1 -1
- package/dist/field.js +113 -80
- package/dist/index.cjs +1 -1
- package/dist/index.js +253 -255
- package/dist/input-group.d.ts +1 -1
- package/dist/input-otp.cjs +1 -1
- package/dist/input-otp.d.ts +3 -20
- package/dist/input-otp.d.ts.map +1 -1
- package/dist/input-otp.js +91 -132
- package/dist/radio-group.cjs +1 -1
- package/dist/radio-group.d.ts +3 -19
- package/dist/radio-group.d.ts.map +1 -1
- package/dist/radio-group.js +92 -120
- package/dist/resizable.d.ts +1 -1
- package/dist/switch.cjs +1 -1
- package/dist/switch.d.ts +1 -21
- package/dist/switch.d.ts.map +1 -1
- package/dist/switch.js +31 -100
- package/package.json +2 -2
- package/src/components/combobox.tsx +22 -2
- package/src/components/field.tsx +45 -5
- package/src/components/input-otp.tsx +9 -89
- package/src/components/radio-group.tsx +65 -129
- package/src/components/switch.tsx +29 -140
- package/dist/link.figma.d.ts +0 -2
- package/dist/link.figma.d.ts.map +0 -1
- package/dist/switch.figma.d.ts +0 -2
- package/dist/switch.figma.d.ts.map +0 -1
- package/dist/toggle.figma.d.ts +0 -2
- package/dist/toggle.figma.d.ts.map +0 -1
- package/src/components/link.figma.tsx +0 -71
- package/src/components/switch.figma.tsx +0 -111
- package/src/components/toggle.figma.tsx +0 -75
package/dist/radio-group.js
CHANGED
|
@@ -1,56 +1,37 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import * as
|
|
3
|
-
import * as
|
|
4
|
-
import { Circle as
|
|
5
|
-
import { cva as
|
|
6
|
-
import { cn as
|
|
7
|
-
|
|
8
|
-
const k = l("grid", {
|
|
1
|
+
import { jsx as e, jsxs as h } from "react/jsx-runtime";
|
|
2
|
+
import * as d from "react";
|
|
3
|
+
import * as t from "@radix-ui/react-radio-group";
|
|
4
|
+
import { Circle as x } from "@brightlocal/icons";
|
|
5
|
+
import { cva as b } from "class-variance-authority";
|
|
6
|
+
import { cn as i } from "@brightlocal/ui-components/lib/utils";
|
|
7
|
+
const k = b("grid", {
|
|
9
8
|
variants: {
|
|
10
9
|
variant: {
|
|
11
10
|
default: ["gap-3"],
|
|
12
|
-
box: ["gap-
|
|
11
|
+
box: ["gap-3"],
|
|
13
12
|
boxIconVertical: ["grid-flow-col auto-cols-fr gap-3"],
|
|
14
|
-
boxIconHorizontal: ["gap-
|
|
13
|
+
boxIconHorizontal: ["gap-3"]
|
|
15
14
|
}
|
|
16
15
|
},
|
|
17
16
|
defaultVariants: {
|
|
18
17
|
variant: "default"
|
|
19
18
|
}
|
|
20
|
-
}), y =
|
|
21
|
-
"group relative flex cursor-pointer outline-none disabled:cursor-not-allowed disabled:opacity-50",
|
|
19
|
+
}), y = b(
|
|
20
|
+
"group relative flex cursor-pointer outline-none disabled:cursor-not-allowed disabled:opacity-50 after:absolute after:inset-0",
|
|
22
21
|
{
|
|
23
22
|
variants: {
|
|
24
23
|
variant: {
|
|
25
|
-
default: ["items-
|
|
26
|
-
box: [
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
"data-[state=checked]:border-primary data-[state=checked]:bg-primary/10",
|
|
30
|
-
"dark:data-[state=checked]:bg-alpha-10",
|
|
31
|
-
"focus-visible:outline-none"
|
|
32
|
-
],
|
|
33
|
-
boxIconVertical: [
|
|
34
|
-
"flex-col items-center gap-3 rounded-lg border border-border bg-background p-3",
|
|
35
|
-
"transition-colors",
|
|
36
|
-
"data-[state=checked]:border-primary data-[state=checked]:bg-primary/10",
|
|
37
|
-
"dark:data-[state=checked]:bg-alpha-10",
|
|
38
|
-
"focus-visible:outline-none focus-visible:shadow-default"
|
|
39
|
-
],
|
|
40
|
-
boxIconHorizontal: [
|
|
41
|
-
"flex-row items-start gap-3 rounded-lg border border-border bg-background p-3",
|
|
42
|
-
"transition-colors",
|
|
43
|
-
"data-[state=checked]:border-primary data-[state=checked]:bg-primary/10",
|
|
44
|
-
"dark:data-[state=checked]:bg-alpha-10",
|
|
45
|
-
"focus-visible:outline-none focus-visible:shadow-default"
|
|
46
|
-
]
|
|
24
|
+
default: ["items-center"],
|
|
25
|
+
box: ["items-center"],
|
|
26
|
+
boxIconVertical: ["items-center justify-center"],
|
|
27
|
+
boxIconHorizontal: ["items-center justify-center"]
|
|
47
28
|
}
|
|
48
29
|
},
|
|
49
30
|
defaultVariants: {
|
|
50
31
|
variant: "default"
|
|
51
32
|
}
|
|
52
33
|
}
|
|
53
|
-
), w =
|
|
34
|
+
), w = b(
|
|
54
35
|
"relative aspect-square size-4 shrink-0 rounded-full border transition-[border-color,border-width,box-shadow,background-color]",
|
|
55
36
|
{
|
|
56
37
|
variants: {
|
|
@@ -88,98 +69,89 @@ const k = l("grid", {
|
|
|
88
69
|
variant: "default"
|
|
89
70
|
}
|
|
90
71
|
}
|
|
91
|
-
),
|
|
92
|
-
"text-foreground flex flex-col gap-1.5 leading-none",
|
|
93
|
-
{
|
|
94
|
-
variants: {
|
|
95
|
-
variant: {
|
|
96
|
-
default: [],
|
|
97
|
-
box: ["text-left"],
|
|
98
|
-
boxIconVertical: ["items-center"],
|
|
99
|
-
boxIconHorizontal: ["text-left justify-center"]
|
|
100
|
-
}
|
|
101
|
-
},
|
|
102
|
-
defaultVariants: {
|
|
103
|
-
variant: "default"
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
), h = c.createContext({
|
|
72
|
+
), g = d.createContext({
|
|
107
73
|
variant: "default"
|
|
108
|
-
}),
|
|
74
|
+
}), I = d.forwardRef(
|
|
109
75
|
({
|
|
110
|
-
className:
|
|
111
|
-
variant:
|
|
112
|
-
dataHook:
|
|
113
|
-
trackingEl:
|
|
114
|
-
trackingLabel:
|
|
115
|
-
error:
|
|
76
|
+
className: s,
|
|
77
|
+
variant: r = "default",
|
|
78
|
+
dataHook: n,
|
|
79
|
+
trackingEl: c,
|
|
80
|
+
trackingLabel: l,
|
|
81
|
+
error: u,
|
|
82
|
+
orientation: a,
|
|
116
83
|
...o
|
|
117
|
-
},
|
|
118
|
-
const
|
|
119
|
-
return /* @__PURE__ */
|
|
120
|
-
|
|
84
|
+
}, f) => {
|
|
85
|
+
const m = r || "default", p = u || o["aria-invalid"] === !0 || o["aria-invalid"] === "true", v = r === "boxIconVertical" ? "horizontal" : a;
|
|
86
|
+
return /* @__PURE__ */ e(
|
|
87
|
+
g.Provider,
|
|
121
88
|
{
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
variant: d,
|
|
139
|
-
label: e,
|
|
140
|
-
description: t,
|
|
141
|
-
icon: s,
|
|
142
|
-
children: n,
|
|
143
|
-
...o
|
|
144
|
-
}, b) => {
|
|
145
|
-
const g = c.useContext(h), a = d ?? g.variant ?? "default", f = a === "boxIconVertical" || a === "boxIconHorizontal";
|
|
146
|
-
return /* @__PURE__ */ m(
|
|
147
|
-
i.Item,
|
|
148
|
-
{
|
|
149
|
-
ref: b,
|
|
150
|
-
className: p(y({ variant: a }), u),
|
|
151
|
-
"data-slot": "radio-group-item",
|
|
152
|
-
...o,
|
|
153
|
-
children: [
|
|
154
|
-
f && s && /* @__PURE__ */ r("div", { className: "relative flex shrink-0 items-center justify-center", children: s }),
|
|
155
|
-
!f && /* @__PURE__ */ r("div", { className: w({ variant: a }), children: /* @__PURE__ */ r(
|
|
156
|
-
i.Indicator,
|
|
157
|
-
{
|
|
158
|
-
className: "absolute inset-0 flex items-center justify-center",
|
|
159
|
-
"data-slot": "radio-group-indicator",
|
|
160
|
-
children: /* @__PURE__ */ r(
|
|
161
|
-
v,
|
|
162
|
-
{
|
|
163
|
-
className: p(
|
|
164
|
-
a === "default" ? "fill-primary text-primary" : "fill-background text-background"
|
|
165
|
-
),
|
|
166
|
-
size: 8
|
|
167
|
-
}
|
|
168
|
-
)
|
|
169
|
-
}
|
|
170
|
-
) }),
|
|
171
|
-
(e || t || n) && /* @__PURE__ */ m("div", { className: I({ variant: a }), children: [
|
|
172
|
-
e && /* @__PURE__ */ r(x, { className: "my-[1px] cursor-pointer", children: e }),
|
|
173
|
-
t && /* @__PURE__ */ r("p", { className: "text-muted-foreground text-sm", children: t }),
|
|
174
|
-
n
|
|
175
|
-
] })
|
|
176
|
-
]
|
|
89
|
+
value: { variant: m, error: p },
|
|
90
|
+
children: /* @__PURE__ */ e(
|
|
91
|
+
t.Root,
|
|
92
|
+
{
|
|
93
|
+
ref: f,
|
|
94
|
+
"aria-invalid": p ? "true" : void 0,
|
|
95
|
+
className: i(k({ variant: r }), s),
|
|
96
|
+
"data-hook": n,
|
|
97
|
+
"data-slot": "radio-group",
|
|
98
|
+
"data-tracking-el": c,
|
|
99
|
+
"data-tracking-label": l,
|
|
100
|
+
"data-variant": r,
|
|
101
|
+
orientation: v,
|
|
102
|
+
...o
|
|
103
|
+
}
|
|
104
|
+
)
|
|
177
105
|
}
|
|
178
106
|
);
|
|
179
107
|
}
|
|
180
108
|
);
|
|
181
|
-
|
|
109
|
+
I.displayName = t.Root.displayName;
|
|
110
|
+
const V = d.forwardRef(({ className: s, children: r, ...n }, c) => {
|
|
111
|
+
const { variant: l, error: u } = d.useContext(g), a = l ?? "default", o = a === "boxIconVertical" || a === "boxIconHorizontal";
|
|
112
|
+
return /* @__PURE__ */ h(
|
|
113
|
+
t.Item,
|
|
114
|
+
{
|
|
115
|
+
ref: c,
|
|
116
|
+
className: i(y({ variant: a }), s),
|
|
117
|
+
"data-slot": "radio-group-item",
|
|
118
|
+
...n,
|
|
119
|
+
children: [
|
|
120
|
+
!o && /* @__PURE__ */ e(
|
|
121
|
+
"div",
|
|
122
|
+
{
|
|
123
|
+
className: i(
|
|
124
|
+
w({ variant: a }),
|
|
125
|
+
u && [
|
|
126
|
+
"border-red-600/40 dark:border-red-400/60",
|
|
127
|
+
"group-focus-visible:border-destructive group-focus-visible:shadow-destructive"
|
|
128
|
+
]
|
|
129
|
+
),
|
|
130
|
+
children: /* @__PURE__ */ e(
|
|
131
|
+
t.Indicator,
|
|
132
|
+
{
|
|
133
|
+
className: "absolute inset-0 flex items-center justify-center",
|
|
134
|
+
"data-slot": "radio-group-indicator",
|
|
135
|
+
children: /* @__PURE__ */ e(
|
|
136
|
+
x,
|
|
137
|
+
{
|
|
138
|
+
className: i(
|
|
139
|
+
a === "default" ? "fill-primary text-primary" : "fill-background text-background"
|
|
140
|
+
),
|
|
141
|
+
size: 8
|
|
142
|
+
}
|
|
143
|
+
)
|
|
144
|
+
}
|
|
145
|
+
)
|
|
146
|
+
}
|
|
147
|
+
),
|
|
148
|
+
r
|
|
149
|
+
]
|
|
150
|
+
}
|
|
151
|
+
);
|
|
152
|
+
});
|
|
153
|
+
V.displayName = t.Item.displayName;
|
|
182
154
|
export {
|
|
183
|
-
|
|
184
|
-
|
|
155
|
+
I as RadioGroup,
|
|
156
|
+
V as RadioGroupItem
|
|
185
157
|
};
|
package/dist/resizable.d.ts
CHANGED
|
@@ -28,7 +28,7 @@ type ResizablePanelProps = React.ComponentProps<typeof ResizablePrimitive.Panel>
|
|
|
28
28
|
/**
|
|
29
29
|
* Individual resizable panel within a panel group.
|
|
30
30
|
*/
|
|
31
|
-
declare const ResizablePanel: React.ForwardRefExoticComponent<Omit<Omit<React.HTMLAttributes<HTMLElement | HTMLDivElement | HTMLObjectElement | HTMLSlotElement | HTMLStyleElement | HTMLButtonElement | HTMLDialogElement | HTMLFormElement | HTMLImageElement |
|
|
31
|
+
declare const ResizablePanel: React.ForwardRefExoticComponent<Omit<Omit<React.HTMLAttributes<HTMLElement | HTMLDivElement | HTMLObjectElement | HTMLSlotElement | HTMLStyleElement | HTMLLinkElement | HTMLMapElement | HTMLButtonElement | HTMLDialogElement | HTMLFormElement | HTMLImageElement | HTMLOptionElement | HTMLTableElement | HTMLTimeElement | HTMLVideoElement | HTMLAnchorElement | HTMLAreaElement | HTMLAudioElement | HTMLBaseElement | HTMLQuoteElement | HTMLBodyElement | HTMLBRElement | HTMLCanvasElement | HTMLTableColElement | HTMLDataElement | HTMLDataListElement | HTMLModElement | HTMLDetailsElement | HTMLDListElement | HTMLEmbedElement | HTMLFieldSetElement | HTMLHeadingElement | HTMLHeadElement | HTMLHRElement | HTMLHtmlElement | HTMLIFrameElement | HTMLInputElement | HTMLLabelElement | HTMLLegendElement | HTMLLIElement | HTMLMetaElement | HTMLMeterElement | HTMLOListElement | HTMLOptGroupElement | HTMLOutputElement | HTMLParagraphElement | HTMLPreElement | HTMLProgressElement | HTMLScriptElement | HTMLSelectElement | HTMLSourceElement | HTMLSpanElement | HTMLTemplateElement | HTMLTableSectionElement | HTMLTableCellElement | HTMLTextAreaElement | HTMLTitleElement | HTMLTableRowElement | HTMLTrackElement | HTMLUListElement | HTMLTableCaptionElement | HTMLMenuElement | HTMLPictureElement>, "id" | "onResize"> & {
|
|
32
32
|
className?: string;
|
|
33
33
|
collapsedSize?: number | undefined;
|
|
34
34
|
collapsible?: boolean | undefined;
|
package/dist/switch.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 n=require("react/jsx-runtime"),u=require("react"),b=require("@radix-ui/react-switch"),o=require("@brightlocal/ui-components/lib/utils");function i(e){const a=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(a,t,r.get?r:{enumerable:!0,get:()=>e[t]})}}return a.default=e,Object.freeze(a)}const h=i(u),c=i(b),s=h.forwardRef(({className:e,dataHook:a,trackingEl:t,trackingLabel:r,...d},l)=>n.jsx(c.Root,{ref:l,className:o.cn("peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:border-ring dark:focus-visible:border-neutral-500 dark:data-[state=unchecked]:bg-input/80","inline-flex h-5 w-9 shrink-0 items-center rounded-full border-1 border-transparent shadow-xs transition-[background-color,border-color,box-shadow] outline-none focus-visible:shadow-default","disabled:cursor-not-allowed disabled:opacity-50","pl-[1px]",e),"data-hook":a,"data-slot":"switch","data-tracking-el":t||"switch","data-tracking-label":r,...d,children:n.jsx(c.Thumb,{className:o.cn("bg-background","pointer-events-none block size-4 rounded-full ring-0 transition-transform","data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0"),"data-slot":"switch-thumb"})}));s.displayName="Switch";exports.Switch=s;
|
package/dist/switch.d.ts
CHANGED
|
@@ -1,32 +1,12 @@
|
|
|
1
|
-
import { VariantProps } from 'class-variance-authority';
|
|
2
1
|
import * as React from "react";
|
|
3
2
|
import * as SwitchPrimitive from "@radix-ui/react-switch";
|
|
4
|
-
|
|
5
|
-
* Visual style variants for Switch component
|
|
6
|
-
*/
|
|
7
|
-
export type SwitchVariant = "default" | "box";
|
|
8
|
-
/**
|
|
9
|
-
* Label position for switch (used in Default variant)
|
|
10
|
-
*/
|
|
11
|
-
export type SwitchSide = "left" | "right";
|
|
12
|
-
declare const switchVariants: (props?: ({
|
|
13
|
-
variant?: "box" | "default" | null | undefined;
|
|
14
|
-
} & import('class-variance-authority/types').ClassProp) | undefined) => string;
|
|
15
|
-
interface SwitchProps extends Omit<React.ComponentProps<typeof SwitchPrimitive.Root>, "asChild">, VariantProps<typeof switchVariants> {
|
|
3
|
+
interface SwitchProps extends Omit<React.ComponentProps<typeof SwitchPrimitive.Root>, "asChild"> {
|
|
16
4
|
/** Data hook for automated testing (REQUIRED) */
|
|
17
5
|
dataHook: string;
|
|
18
6
|
/** Tracking element identifier for analytics */
|
|
19
7
|
trackingEl?: string;
|
|
20
8
|
/** Tracking label for analytics context */
|
|
21
9
|
trackingLabel?: string;
|
|
22
|
-
/** Visual style variant */
|
|
23
|
-
variant?: SwitchVariant;
|
|
24
|
-
/** Label text for the switch */
|
|
25
|
-
label?: string;
|
|
26
|
-
/** Description text (visible in Box variant) */
|
|
27
|
-
description?: string;
|
|
28
|
-
/** Label position - left or right (for Default variant) */
|
|
29
|
-
side?: SwitchSide;
|
|
30
10
|
}
|
|
31
11
|
declare const Switch: React.ForwardRefExoticComponent<Omit<SwitchProps, "ref"> & React.RefAttributes<HTMLButtonElement>>;
|
|
32
12
|
export { Switch, type SwitchProps };
|
package/dist/switch.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"switch.d.ts","sourceRoot":"","sources":["../../src/components/switch.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,eAAe,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"switch.d.ts","sourceRoot":"","sources":["../../src/components/switch.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,eAAe,MAAM,wBAAwB,CAAC;AAI1D,UAAU,WACR,SAAQ,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,eAAe,CAAC,IAAI,CAAC,EAAE,SAAS,CAAC;IAC1E,iDAAiD;IACjD,QAAQ,EAAE,MAAM,CAAC;IACjB,gDAAgD;IAChD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,2CAA2C;IAC3C,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,QAAA,MAAM,MAAM,oGA8BV,CAAC;AAIH,OAAO,EAAE,MAAM,EAAE,KAAK,WAAW,EAAE,CAAC"}
|
package/dist/switch.js
CHANGED
|
@@ -1,106 +1,37 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import * as
|
|
3
|
-
import * as
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
[
|
|
8
|
-
"peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:border-ring dark:focus-visible:border-neutral-500 dark:data-[state=unchecked]:bg-input/80",
|
|
9
|
-
"inline-flex h-5 w-9 shrink-0 items-center rounded-full border-1 border-transparent shadow-xs transition-[background-color,border-color,box-shadow] outline-none focus-visible:shadow-default",
|
|
10
|
-
"disabled:cursor-not-allowed disabled:opacity-50",
|
|
11
|
-
"pl-[1px]"
|
|
12
|
-
],
|
|
1
|
+
import { jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import * as c from "react";
|
|
3
|
+
import * as a from "@radix-ui/react-switch";
|
|
4
|
+
import { cn as e } from "@brightlocal/ui-components/lib/utils";
|
|
5
|
+
const l = c.forwardRef(({ className: r, dataHook: o, trackingEl: i, trackingLabel: s, ...d }, n) => /* @__PURE__ */ t(
|
|
6
|
+
a.Root,
|
|
13
7
|
{
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
trackingEl: h,
|
|
30
|
-
trackingLabel: b,
|
|
31
|
-
label: r,
|
|
32
|
-
description: i,
|
|
33
|
-
side: s = "right",
|
|
34
|
-
...n
|
|
35
|
-
}, p) => {
|
|
36
|
-
const a = /* @__PURE__ */ e(
|
|
37
|
-
m.Root,
|
|
8
|
+
ref: n,
|
|
9
|
+
className: e(
|
|
10
|
+
"peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:border-ring dark:focus-visible:border-neutral-500 dark:data-[state=unchecked]:bg-input/80",
|
|
11
|
+
"inline-flex h-5 w-9 shrink-0 items-center rounded-full border-1 border-transparent shadow-xs transition-[background-color,border-color,box-shadow] outline-none focus-visible:shadow-default",
|
|
12
|
+
"disabled:cursor-not-allowed disabled:opacity-50",
|
|
13
|
+
"pl-[1px]",
|
|
14
|
+
r
|
|
15
|
+
),
|
|
16
|
+
"data-hook": o,
|
|
17
|
+
"data-slot": "switch",
|
|
18
|
+
"data-tracking-el": i || "switch",
|
|
19
|
+
"data-tracking-label": s,
|
|
20
|
+
...d,
|
|
21
|
+
children: /* @__PURE__ */ t(
|
|
22
|
+
a.Thumb,
|
|
38
23
|
{
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
"data-tracking-el": h || `switch-${t}`,
|
|
44
|
-
"data-tracking-label": b,
|
|
45
|
-
...n,
|
|
46
|
-
children: /* @__PURE__ */ e(
|
|
47
|
-
m.Thumb,
|
|
48
|
-
{
|
|
49
|
-
className: d(
|
|
50
|
-
"bg-background",
|
|
51
|
-
"pointer-events-none block size-4 rounded-full ring-0 transition-transform",
|
|
52
|
-
"data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0"
|
|
53
|
-
),
|
|
54
|
-
"data-slot": "switch-thumb"
|
|
55
|
-
}
|
|
56
|
-
)
|
|
57
|
-
}
|
|
58
|
-
);
|
|
59
|
-
if (t === "default")
|
|
60
|
-
return /* @__PURE__ */ o(
|
|
61
|
-
"div",
|
|
62
|
-
{
|
|
63
|
-
className: d(
|
|
64
|
-
"flex items-center gap-2",
|
|
65
|
-
s === "left" && "flex-row-reverse"
|
|
66
|
-
),
|
|
67
|
-
children: [
|
|
68
|
-
a,
|
|
69
|
-
r && /* @__PURE__ */ e(
|
|
70
|
-
"label",
|
|
71
|
-
{
|
|
72
|
-
className: "cursor-pointer text-sm leading-none font-medium peer-disabled:cursor-not-allowed peer-disabled:opacity-70",
|
|
73
|
-
htmlFor: n.id,
|
|
74
|
-
children: r
|
|
75
|
-
}
|
|
76
|
-
)
|
|
77
|
-
]
|
|
78
|
-
}
|
|
79
|
-
);
|
|
80
|
-
if (t === "box") {
|
|
81
|
-
const l = /* @__PURE__ */ o("div", { className: "flex flex-col gap-2", children: [
|
|
82
|
-
r && /* @__PURE__ */ e(
|
|
83
|
-
"label",
|
|
84
|
-
{
|
|
85
|
-
className: "cursor-pointer text-sm leading-none font-medium",
|
|
86
|
-
htmlFor: n.id,
|
|
87
|
-
children: r
|
|
88
|
-
}
|
|
24
|
+
className: e(
|
|
25
|
+
"bg-background",
|
|
26
|
+
"pointer-events-none block size-4 rounded-full ring-0 transition-transform",
|
|
27
|
+
"data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0"
|
|
89
28
|
),
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
a,
|
|
94
|
-
l
|
|
95
|
-
] }) : /* @__PURE__ */ o(c, { children: [
|
|
96
|
-
l,
|
|
97
|
-
a
|
|
98
|
-
] }) });
|
|
99
|
-
}
|
|
100
|
-
return a;
|
|
29
|
+
"data-slot": "switch-thumb"
|
|
30
|
+
}
|
|
31
|
+
)
|
|
101
32
|
}
|
|
102
|
-
);
|
|
103
|
-
|
|
33
|
+
));
|
|
34
|
+
l.displayName = "Switch";
|
|
104
35
|
export {
|
|
105
|
-
|
|
36
|
+
l as Switch
|
|
106
37
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@brightlocal/ui-components",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "BrightLocal Design System UI Components",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"private": false,
|
|
@@ -152,7 +152,7 @@
|
|
|
152
152
|
"sonner": "^2.0.7",
|
|
153
153
|
"tailwind-merge": "^3.4.0",
|
|
154
154
|
"vaul": "^1.1.2",
|
|
155
|
-
"@brightlocal/icons": "
|
|
155
|
+
"@brightlocal/icons": "2.0.0"
|
|
156
156
|
},
|
|
157
157
|
"size-limit": [
|
|
158
158
|
{
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import { ChevronsUpDown, Check } from "@brightlocal/icons";
|
|
5
5
|
import { cva, type VariantProps } from "class-variance-authority";
|
|
6
|
+
import { defaultFilter } from "cmdk";
|
|
6
7
|
|
|
7
8
|
import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
8
9
|
import {
|
|
@@ -34,6 +35,8 @@ interface ComboboxContextValue {
|
|
|
34
35
|
/** Map of value -> label for displaying selected value */
|
|
35
36
|
itemLabels: Map<string, string>;
|
|
36
37
|
registerItem: (value: string, label: string) => void;
|
|
38
|
+
/** Maps item value to a searchable string for filtering */
|
|
39
|
+
itemToStringValue?: (value: string) => string;
|
|
37
40
|
}
|
|
38
41
|
|
|
39
42
|
const ComboboxContext = React.createContext<ComboboxContextValue | null>(null);
|
|
@@ -63,6 +66,8 @@ export interface ComboboxProps {
|
|
|
63
66
|
shouldFilter?: boolean;
|
|
64
67
|
/** Disabled state */
|
|
65
68
|
disabled?: boolean;
|
|
69
|
+
/** Maps item value to a searchable string. When provided, filtering uses this string instead of the raw value. */
|
|
70
|
+
itemToStringValue?: (value: string) => string;
|
|
66
71
|
/** Children */
|
|
67
72
|
children: React.ReactNode;
|
|
68
73
|
}
|
|
@@ -74,6 +79,7 @@ function Combobox({
|
|
|
74
79
|
onOpenChange: controlledOnOpenChange,
|
|
75
80
|
shouldFilter = true,
|
|
76
81
|
disabled = false,
|
|
82
|
+
itemToStringValue,
|
|
77
83
|
children,
|
|
78
84
|
}: ComboboxProps) {
|
|
79
85
|
const [uncontrolledValue, setUncontrolledValue] = React.useState("");
|
|
@@ -127,6 +133,7 @@ function Combobox({
|
|
|
127
133
|
disabled,
|
|
128
134
|
itemLabels,
|
|
129
135
|
registerItem,
|
|
136
|
+
itemToStringValue,
|
|
130
137
|
}),
|
|
131
138
|
[
|
|
132
139
|
open,
|
|
@@ -137,6 +144,7 @@ function Combobox({
|
|
|
137
144
|
disabled,
|
|
138
145
|
itemLabels,
|
|
139
146
|
registerItem,
|
|
147
|
+
itemToStringValue,
|
|
140
148
|
]
|
|
141
149
|
);
|
|
142
150
|
|
|
@@ -324,11 +332,18 @@ function ComboboxContent({
|
|
|
324
332
|
align = "start",
|
|
325
333
|
hideList = false,
|
|
326
334
|
}: ComboboxContentProps) {
|
|
327
|
-
const { shouldFilter } = useComboboxContext();
|
|
335
|
+
const { shouldFilter, itemToStringValue } = useComboboxContext();
|
|
336
|
+
|
|
337
|
+
const filter = React.useMemo(() => {
|
|
338
|
+
if (!itemToStringValue) return undefined;
|
|
339
|
+
return (value: string, search: string, keywords?: string[]) =>
|
|
340
|
+
defaultFilter(itemToStringValue(value), search, keywords);
|
|
341
|
+
}, [itemToStringValue]);
|
|
328
342
|
|
|
329
343
|
return (
|
|
330
344
|
<PopoverContent
|
|
331
345
|
align={align}
|
|
346
|
+
aria-label="Options"
|
|
332
347
|
className={cn("w-[var(--radix-popover-trigger-width)] p-0", className)}
|
|
333
348
|
data-slot="combobox-popover"
|
|
334
349
|
side="bottom"
|
|
@@ -340,6 +355,7 @@ function ComboboxContent({
|
|
|
340
355
|
)}
|
|
341
356
|
data-slot="combobox-command"
|
|
342
357
|
dataHook={dataHook || "combobox-command"}
|
|
358
|
+
filter={filter}
|
|
343
359
|
shouldFilter={shouldFilter}
|
|
344
360
|
>
|
|
345
361
|
{children}
|
|
@@ -454,7 +470,7 @@ export interface ComboboxItemProps extends Omit<
|
|
|
454
470
|
> {
|
|
455
471
|
/** The value of the item (required) */
|
|
456
472
|
value: string;
|
|
457
|
-
/** Display label - if not provided,
|
|
473
|
+
/** Display label - if not provided, inferred from children text content. Required when children are React elements (not plain text) to enable label-based search and trigger display. */
|
|
458
474
|
label?: string;
|
|
459
475
|
/** Data hook for automated testing */
|
|
460
476
|
dataHook?: string;
|
|
@@ -462,6 +478,8 @@ export interface ComboboxItemProps extends Omit<
|
|
|
462
478
|
highlight?: string;
|
|
463
479
|
/** Class name for highlighted text */
|
|
464
480
|
highlightClassName?: string;
|
|
481
|
+
/** Additional keywords to match against when filtering. The item label is always included automatically. */
|
|
482
|
+
keywords?: string[];
|
|
465
483
|
}
|
|
466
484
|
|
|
467
485
|
const ComboboxItem = React.forwardRef<
|
|
@@ -477,6 +495,7 @@ const ComboboxItem = React.forwardRef<
|
|
|
477
495
|
className,
|
|
478
496
|
highlight,
|
|
479
497
|
highlightClassName,
|
|
498
|
+
keywords,
|
|
480
499
|
...props
|
|
481
500
|
},
|
|
482
501
|
ref
|
|
@@ -528,6 +547,7 @@ const ComboboxItem = React.forwardRef<
|
|
|
528
547
|
className={cn("justify-between", className)}
|
|
529
548
|
data-slot="combobox-item"
|
|
530
549
|
dataHook={dataHook}
|
|
550
|
+
keywords={keywords ? [childText, ...keywords] : [childText]}
|
|
531
551
|
value={itemValue}
|
|
532
552
|
onSelect={handleSelect}
|
|
533
553
|
{...props}
|