@brightlocal/ui-components 0.1.4 → 0.3.0

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