@conscia-labs/design-system 0.4.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.
@@ -1,723 +0,0 @@
1
- import {
2
- Button,
3
- Card,
4
- CardContent,
5
- CardDescription,
6
- CardHeader,
7
- CardTitle,
8
- Checkbox,
9
- Input,
10
- Select,
11
- SelectContent,
12
- SelectGroup,
13
- SelectItem,
14
- SelectTrigger,
15
- SelectValue,
16
- Table,
17
- TableBody,
18
- TableCell,
19
- TableHead,
20
- TableHeader,
21
- TableRow
22
- } from "./chunk-RAGHGWLB.js";
23
- import {
24
- cn
25
- } from "./chunk-JU5DQXFC.js";
26
-
27
- // src/primitives/alert.tsx
28
- import { cva } from "class-variance-authority";
29
- import { jsx } from "react/jsx-runtime";
30
- var alertVariants = cva(
31
- "relative grid w-full grid-cols-[auto_1fr] items-start gap-x-3 rounded-[var(--ds-radius-surface)] border px-4 py-3.5 text-sm [&>svg]:mt-0.5 [&>svg]:size-5",
32
- {
33
- variants: {
34
- variant: {
35
- default: "border-border-default bg-card text-foreground",
36
- information: "border-information-border bg-information-background text-information-foreground",
37
- success: "border-success-border bg-success-background text-success-foreground",
38
- warning: "border-warning-border bg-warning-background text-warning-foreground",
39
- danger: "border-danger-border bg-danger-background text-danger-foreground"
40
- }
41
- },
42
- defaultVariants: {
43
- variant: "default"
44
- }
45
- }
46
- );
47
- function Alert({
48
- className,
49
- variant,
50
- ...props
51
- }) {
52
- return /* @__PURE__ */ jsx(
53
- "div",
54
- {
55
- "data-slot": "alert",
56
- className: cn(alertVariants({ variant }), className),
57
- ...props
58
- }
59
- );
60
- }
61
- function AlertTitle({ className, ...props }) {
62
- return /* @__PURE__ */ jsx(
63
- "div",
64
- {
65
- "data-slot": "alert-title",
66
- className: cn("font-medium leading-5", className),
67
- ...props
68
- }
69
- );
70
- }
71
- function AlertDescription({ className, ...props }) {
72
- return /* @__PURE__ */ jsx(
73
- "div",
74
- {
75
- "data-slot": "alert-description",
76
- className: cn("col-start-2 mt-0.5 text-sm leading-5 opacity-80", className),
77
- ...props
78
- }
79
- );
80
- }
81
-
82
- // src/primitives/avatar.tsx
83
- import * as AvatarPrimitive from "@radix-ui/react-avatar";
84
- import { jsx as jsx2 } from "react/jsx-runtime";
85
- function Avatar({
86
- className,
87
- ...props
88
- }) {
89
- return /* @__PURE__ */ jsx2(
90
- AvatarPrimitive.Root,
91
- {
92
- "data-slot": "avatar",
93
- className: cn("relative flex size-8 shrink-0 overflow-hidden rounded-full", className),
94
- ...props
95
- }
96
- );
97
- }
98
- function AvatarImage({
99
- className,
100
- ...props
101
- }) {
102
- return /* @__PURE__ */ jsx2(
103
- AvatarPrimitive.Image,
104
- {
105
- "data-slot": "avatar-image",
106
- className: cn("aspect-square size-full", className),
107
- ...props
108
- }
109
- );
110
- }
111
- function AvatarFallback({
112
- className,
113
- ...props
114
- }) {
115
- return /* @__PURE__ */ jsx2(
116
- AvatarPrimitive.Fallback,
117
- {
118
- "data-slot": "avatar-fallback",
119
- className: cn("flex size-full items-center justify-center rounded-full bg-surface-muted text-xs font-medium text-muted-foreground", className),
120
- ...props
121
- }
122
- );
123
- }
124
-
125
- // src/primitives/badge.tsx
126
- import { cva as cva2 } from "class-variance-authority";
127
- import { jsx as jsx3 } from "react/jsx-runtime";
128
- var badgeVariants = cva2(
129
- "inline-flex items-center rounded-md border px-1.5 py-0.5 text-[var(--ds-metadata)] font-medium leading-4 transition-colors",
130
- {
131
- variants: {
132
- variant: {
133
- default: "border-primary bg-primary text-primary-foreground",
134
- accent: "border-selection-border bg-selection-background text-selection-foreground",
135
- secondary: "border-neutral-border bg-neutral-background text-neutral-foreground",
136
- neutral: "border-neutral-border bg-neutral-background text-neutral-foreground",
137
- outline: "border-border-default text-foreground",
138
- information: "border-information-border bg-information-background text-information-foreground",
139
- info: "border-information-border bg-information-background text-information-foreground",
140
- success: "border-success-border bg-success-background text-success-foreground",
141
- warning: "border-warning-border bg-warning-background text-warning-foreground",
142
- danger: "border-danger-border bg-danger-background text-danger-foreground",
143
- destructive: "border-danger-border bg-danger-background text-danger-foreground"
144
- }
145
- },
146
- defaultVariants: {
147
- variant: "neutral"
148
- }
149
- }
150
- );
151
- function Badge({
152
- className,
153
- variant,
154
- ...props
155
- }) {
156
- return /* @__PURE__ */ jsx3("span", { "data-slot": "badge", className: cn(badgeVariants({ variant, className })), ...props });
157
- }
158
-
159
- // src/primitives/brand-icon.tsx
160
- import { jsx as jsx4 } from "react/jsx-runtime";
161
- var CONSCIA_SYMBOL_PATH = [
162
- "M171.225 63.8139L173.637 66.1116L203.794 34.4551L201.382 32.1575L171.225 63.8139Z",
163
- "M184.012 78.9693L185.769 81.8487L223.091 59.076L221.334 56.1966L184.012 78.9693Z",
164
- "M192.436 96.8858L193.417 100.222L235.362 87.8847L234.381 84.5488L192.436 96.8858Z",
165
- "M195.949 116.334L196.037 119.987L239.746 118.926L239.657 115.273L195.949 116.334Z",
166
- "M194.341 135.989L193.42 139.796L235.913 150.084L236.835 146.277L194.341 135.989Z",
167
- "M187.759 154.526L185.708 158.285L224.091 179.221L226.142 175.461L187.759 154.526Z",
168
- "M176.683 170.712L173.394 174.165L205.05 204.322L208.34 200.868L176.683 170.712Z",
169
- "M161.899 183.49L157.288 186.304L180.06 223.626L184.672 220.812L161.899 183.49Z",
170
- "M144.425 192.058L138.472 193.809L150.809 235.754L156.762 234.003L144.425 192.058Z",
171
- "M125.438 195.913L118.244 196.088L119.305 239.796L126.499 239.622L125.438 195.913Z",
172
- "M106.176 194.873L98.0421 192.903L87.754 235.397L95.8882 237.366L106.176 194.873Z",
173
- "M87.8408 189.056L79.3505 184.425L58.4147 222.808L66.905 227.439L87.8408 189.056Z",
174
- "M71.5444 178.838L63.5819 171.253L33.4252 202.91L41.3878 210.495L71.5444 178.838Z",
175
- "M58.2896 164.821L51.9185 154.379L14.5961 177.152L20.9672 187.593L58.2896 164.821Z",
176
- "M48.9443 147.836L45.1912 135.075L3.24659 147.412L6.99972 160.173L48.9443 147.836Z",
177
- "M44.1724 128.938L43.8283 114.759L0.119827 115.82L0.463868 129.998L44.1724 128.938Z",
178
- "M44.3613 109.352L47.8648 94.8809L5.37116 84.5928L1.86766 99.0635L44.3613 109.352Z",
179
- "M49.563 90.3812L56.9571 76.825L18.5742 55.8893L11.18 69.4455L49.563 90.3812Z",
180
- "M59.4839 73.314L70.4267 61.8269L38.7702 31.6703L27.8274 43.1574L59.4839 73.314Z",
181
- "M73.4951 59.3251L87.307 50.8976L64.5343 13.5752L50.7224 22.0027L73.4951 59.3251Z",
182
- "M90.6772 49.3891L106.414 44.7604L94.0775 2.81575L78.3402 7.44453L90.6772 49.3891Z",
183
- "M109.88 44.2086L126.426 43.8071L125.366 0.098614L108.82 0.500089L109.88 44.2086Z",
184
- "M129.802 44.1632L145.967 48.0768L156.255 5.58318L140.09 1.66954L129.802 44.1632Z",
185
- "M149.087 49.2798L163.709 57.2553L184.645 18.8723L170.023 10.8969L149.087 49.2798Z",
186
- "M152.448 160.384L141.06 167.332L154.089 188.685L165.477 181.736L152.448 160.384Z",
187
- "M140.881 167.41L128.103 171.168L135.161 195.165L147.939 191.407L140.881 167.41Z",
188
- "M127.834 171.202L114.653 171.522L115.26 196.528L128.441 196.209L127.834 171.202Z",
189
- "M114.192 171.456L101.624 168.413L95.738 192.724L108.306 195.767L114.192 171.456Z",
190
- "M100.907 168.109L89.889 162.1L77.9114 184.059L88.9296 190.069L100.907 168.109Z",
191
- "M88.9224 161.353L80.2035 153.047L62.9505 171.158L71.6694 179.464L88.9224 161.353Z",
192
- "M79.1143 151.631L73.1721 141.893L51.8195 154.921L57.7617 164.66L79.1143 151.631Z",
193
- "M72.2163 139.615L69.2075 129.385L45.2105 136.444L48.2193 146.673L72.2163 139.615Z",
194
- "M68.7593 126.163L68.5209 116.339L43.5147 116.946L43.7531 126.77L68.7593 126.163Z",
195
- "M69.0161 112.256L71.1176 103.576L46.8064 97.6899L44.7049 106.37L69.0161 112.256Z",
196
- "M72.979 98.9209L76.8146 91.8888L54.8552 79.9112L51.0196 86.9432L72.979 98.9209Z",
197
- "M80.3506 87.1414L85.2494 81.999L67.1383 64.746L62.2395 69.8884L80.3506 87.1414Z",
198
- "M90.5762 77.7753L95.9023 74.5255L82.8738 53.1729L77.5476 56.4227L90.5762 77.7753Z",
199
- "M102.889 71.4875L108.114 69.9508L101.056 45.9537L95.831 47.4905L102.889 71.4875Z",
200
- "M116.381 68.7043L121.119 68.5894L120.513 43.5832L115.775 43.6981L116.381 68.7043Z",
201
- "M130.08 69.5886L134.092 70.56L139.978 46.2488L135.966 45.2775L130.08 69.5886Z",
202
- "M143.01 74.0389L146.183 75.7697L158.161 53.8103L154.988 52.0795L143.01 74.0389Z",
203
- "M154.273 81.705L156.588 83.9108L173.841 65.7997L171.526 63.5939L154.273 81.705Z",
204
- "M163.102 92.0197L164.599 94.4735L185.952 81.445L184.455 78.9911L163.102 92.0197Z",
205
- "M168.91 104.243L169.655 106.775L193.652 99.7164L192.907 97.1844L168.91 104.243Z",
206
- "M171.325 117.515L171.386 120.001L196.392 119.394L196.331 116.909L171.325 117.515Z",
207
- "M170.21 130.922L169.644 133.264L193.955 139.15L194.522 136.808L170.21 130.922Z",
208
- "M165.673 143.549L164.523 145.658L186.482 157.636L187.633 155.527L165.673 143.549Z",
209
- "M158.032 154.558L156.355 156.318L174.467 173.571L176.143 171.811L158.032 154.558Z"
210
- ].join(" ");
211
- function BrandIcon({
212
- "aria-label": ariaLabel,
213
- className,
214
- ...props
215
- }) {
216
- return /* @__PURE__ */ jsx4(
217
- "svg",
218
- {
219
- "data-slot": "brand-icon",
220
- xmlns: "http://www.w3.org/2000/svg",
221
- width: "240",
222
- height: "240",
223
- viewBox: "0 0 240 240",
224
- fill: "none",
225
- focusable: "false",
226
- role: ariaLabel ? "img" : void 0,
227
- "aria-hidden": ariaLabel ? void 0 : true,
228
- "aria-label": ariaLabel,
229
- className: cn("size-6 shrink-0 text-foreground dark:text-white", className),
230
- ...props,
231
- children: /* @__PURE__ */ jsx4("path", { d: CONSCIA_SYMBOL_PATH, fill: "currentColor" })
232
- }
233
- );
234
- }
235
-
236
- // src/primitives/switch.tsx
237
- import * as SwitchPrimitive from "@radix-ui/react-switch";
238
- import { jsx as jsx5 } from "react/jsx-runtime";
239
- function Switch({
240
- className,
241
- size = "default",
242
- ...props
243
- }) {
244
- return /* @__PURE__ */ jsx5(
245
- SwitchPrimitive.Root,
246
- {
247
- "data-slot": "switch",
248
- "data-size": size,
249
- className: cn(
250
- "peer group/switch inline-flex shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-[1.15rem] data-[size=default]:w-8 data-[size=sm]:h-3.5 data-[size=sm]:w-6 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input dark:data-[state=unchecked]:bg-input/80",
251
- className
252
- ),
253
- ...props,
254
- children: /* @__PURE__ */ jsx5(
255
- SwitchPrimitive.Thumb,
256
- {
257
- "data-slot": "switch-thumb",
258
- className: "pointer-events-none block rounded-full bg-background ring-0 transition-transform group-data-[size=default]/switch:size-4 group-data-[size=sm]/switch:size-3 data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0 dark:data-[state=checked]:bg-primary-foreground dark:data-[state=unchecked]:bg-foreground"
259
- }
260
- )
261
- }
262
- );
263
- }
264
-
265
- // src/primitives/textarea.tsx
266
- import { jsx as jsx6 } from "react/jsx-runtime";
267
- function Textarea({ className, ...props }) {
268
- return /* @__PURE__ */ jsx6(
269
- "textarea",
270
- {
271
- "data-slot": "textarea",
272
- className: cn("ds-type-control min-h-28 w-full rounded-[var(--ds-field-control-radius)] border border-input bg-surface-control px-[var(--ds-field-control-padding-x)] py-3 outline-none transition-colors placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50", className),
273
- ...props
274
- }
275
- );
276
- }
277
-
278
- // src/primitives/compat.tsx
279
- import { jsx as jsx7, jsxs } from "react/jsx-runtime";
280
- var ConsciaButton = Button;
281
- function ConsciaIconButton({
282
- size = "icon",
283
- ...props
284
- }) {
285
- return /* @__PURE__ */ jsx7(Button, { size, ...props });
286
- }
287
- var ConsciaCard = Card;
288
- var ConsciaCardContent = CardContent;
289
- var ConsciaCardDescription = CardDescription;
290
- function ConsciaCardHeader({
291
- actionRight,
292
- className,
293
- children,
294
- ...props
295
- }) {
296
- if (!actionRight) {
297
- return /* @__PURE__ */ jsx7(CardHeader, { className, ...props, children });
298
- }
299
- return /* @__PURE__ */ jsxs(
300
- CardHeader,
301
- {
302
- className: cn(
303
- "grid grid-cols-[minmax(0,1fr)_auto] items-start gap-4",
304
- className
305
- ),
306
- ...props,
307
- children: [
308
- /* @__PURE__ */ jsx7("div", { className: "grid gap-2", children }),
309
- /* @__PURE__ */ jsx7("div", { className: "justify-self-end", children: actionRight })
310
- ]
311
- }
312
- );
313
- }
314
- var ConsciaCardTitle = CardTitle;
315
- var ConsciaCheckbox = Checkbox;
316
- var ConsciaInput = Input;
317
- var ConsciaSwitch = Switch;
318
- var ConsciaTextarea = Textarea;
319
- var ConsciaSelect = Select;
320
- var ConsciaSelectContent = SelectContent;
321
- var ConsciaSelectGroup = SelectGroup;
322
- var ConsciaSelectItem = SelectItem;
323
- var ConsciaSelectTrigger = SelectTrigger;
324
- var ConsciaSelectValue = SelectValue;
325
- var ConsciaTable = Table;
326
- var ConsciaTableBody = TableBody;
327
- var ConsciaTableCell = TableCell;
328
- var ConsciaTableHeader = TableHeader;
329
- var ConsciaTableHead = TableHead;
330
- var ConsciaTableRow = TableRow;
331
-
332
- // src/primitives/field.tsx
333
- import { jsx as jsx8 } from "react/jsx-runtime";
334
- function Field({
335
- className,
336
- ...props
337
- }) {
338
- return /* @__PURE__ */ jsx8(
339
- "div",
340
- {
341
- "data-slot": "field",
342
- className: cn("grid gap-[var(--ds-field-label-gap)]", className),
343
- ...props
344
- }
345
- );
346
- }
347
- function FieldGroup({
348
- className,
349
- ...props
350
- }) {
351
- return /* @__PURE__ */ jsx8(
352
- "div",
353
- {
354
- "data-slot": "field-group",
355
- className: cn("grid gap-[var(--ds-field-gap)]", className),
356
- ...props
357
- }
358
- );
359
- }
360
- function FieldLabel({
361
- className,
362
- ...props
363
- }) {
364
- return /* @__PURE__ */ jsx8(
365
- "label",
366
- {
367
- "data-slot": "field-label",
368
- className: cn("ds-type-label text-foreground", className),
369
- ...props
370
- }
371
- );
372
- }
373
- function FieldDescription({
374
- className,
375
- ...props
376
- }) {
377
- return /* @__PURE__ */ jsx8(
378
- "p",
379
- {
380
- "data-slot": "field-description",
381
- className: cn("ds-type-metadata mt-[var(--ds-field-message-gap)] text-muted-foreground", className),
382
- ...props
383
- }
384
- );
385
- }
386
- function FieldError({
387
- className,
388
- ...props
389
- }) {
390
- return /* @__PURE__ */ jsx8(
391
- "p",
392
- {
393
- "data-slot": "field-error",
394
- className: cn("ds-type-metadata mt-[var(--ds-field-message-gap)] font-medium text-danger-foreground", className),
395
- ...props
396
- }
397
- );
398
- }
399
-
400
- // src/primitives/form-select.tsx
401
- import * as React from "react";
402
- import { jsx as jsx9, jsxs as jsxs2 } from "react/jsx-runtime";
403
- var emptyValue = "__conscia_empty_select_value__";
404
- function toSelectValue(value) {
405
- if (value === void 0) {
406
- return void 0;
407
- }
408
- return value === "" ? emptyValue : value;
409
- }
410
- function fromSelectValue(value) {
411
- return value === emptyValue ? "" : value;
412
- }
413
- function FormSelect({
414
- name,
415
- id,
416
- value,
417
- defaultValue,
418
- required,
419
- disabled,
420
- placeholder,
421
- options,
422
- className,
423
- triggerClassName,
424
- contentClassName,
425
- onValueChange,
426
- onClick,
427
- "aria-label": ariaLabel
428
- }) {
429
- const [internalValue, setInternalValue] = React.useState(defaultValue ?? "");
430
- const currentValue = value ?? internalValue;
431
- function handleValueChange(nextValue) {
432
- const actualValue = fromSelectValue(nextValue);
433
- if (value === void 0) {
434
- setInternalValue(actualValue);
435
- }
436
- onValueChange?.(actualValue);
437
- }
438
- return /* @__PURE__ */ jsx9("div", { className: cn("min-w-0", className), onClick, children: /* @__PURE__ */ jsxs2(
439
- Select,
440
- {
441
- name,
442
- value: toSelectValue(currentValue),
443
- required,
444
- disabled,
445
- onValueChange: handleValueChange,
446
- children: [
447
- /* @__PURE__ */ jsx9(SelectTrigger, { id, "aria-label": ariaLabel, className: triggerClassName, children: /* @__PURE__ */ jsx9(SelectValue, { placeholder }) }),
448
- /* @__PURE__ */ jsx9(SelectContent, { className: contentClassName, children: /* @__PURE__ */ jsx9(SelectGroup, { children: options.map((option) => /* @__PURE__ */ jsx9(
449
- SelectItem,
450
- {
451
- value: toSelectValue(option.value) ?? emptyValue,
452
- disabled: option.disabled,
453
- children: option.label
454
- },
455
- option.value
456
- )) }) })
457
- ]
458
- }
459
- ) });
460
- }
461
- var ConsciaFormSelect = FormSelect;
462
-
463
- // src/primitives/label.tsx
464
- import * as LabelPrimitive from "@radix-ui/react-label";
465
- import { jsx as jsx10 } from "react/jsx-runtime";
466
- function Label({
467
- className,
468
- ...props
469
- }) {
470
- return /* @__PURE__ */ jsx10(
471
- LabelPrimitive.Root,
472
- {
473
- "data-slot": "label",
474
- className: cn(
475
- "ds-type-label flex items-center gap-2 text-foreground select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",
476
- className
477
- ),
478
- ...props
479
- }
480
- );
481
- }
482
-
483
- // src/primitives/searchable-select.tsx
484
- import * as React2 from "react";
485
- import { Check, ChevronsUpDown, Search, X } from "lucide-react";
486
- import { jsx as jsx11, jsxs as jsxs3 } from "react/jsx-runtime";
487
- function SearchableSelect({
488
- id,
489
- name,
490
- value = "",
491
- options,
492
- onValueChange,
493
- placeholder = "Select an option",
494
- searchPlaceholder = "Search...",
495
- emptyMessage = "No matching options.",
496
- disabled = false,
497
- clearable = false,
498
- clearLabel = "Clear selection",
499
- optionsLabel,
500
- className,
501
- "aria-label": ariaLabel
502
- }) {
503
- const generatedId = React2.useId();
504
- const listboxId = `${id ?? generatedId}-listbox`;
505
- const rootRef = React2.useRef(null);
506
- const activeOptionRef = React2.useRef(null);
507
- const [open, setOpen] = React2.useState(false);
508
- const [search, setSearch] = React2.useState("");
509
- const [activeIndex, setActiveIndex] = React2.useState(0);
510
- const selected = options.find((option) => option.value === value);
511
- const normalizedSearch = search.trim().toLowerCase();
512
- const filteredOptions = normalizedSearch ? options.filter(
513
- (option) => [option.label, option.description, ...option.keywords ?? []].filter(Boolean).join(" ").toLowerCase().includes(normalizedSearch)
514
- ) : options;
515
- const enabledIndexes = filteredOptions.reduce((indexes, option, index) => {
516
- if (!option.disabled) {
517
- indexes.push(index);
518
- }
519
- return indexes;
520
- }, []);
521
- const resolvedActiveIndex = enabledIndexes.includes(activeIndex) ? activeIndex : enabledIndexes[0] ?? -1;
522
- React2.useEffect(() => {
523
- if (!open) {
524
- return;
525
- }
526
- function closeWhenOutside(event) {
527
- if (!rootRef.current?.contains(event.target)) {
528
- setOpen(false);
529
- setSearch("");
530
- }
531
- }
532
- document.addEventListener("pointerdown", closeWhenOutside);
533
- return () => document.removeEventListener("pointerdown", closeWhenOutside);
534
- }, [open]);
535
- React2.useEffect(() => {
536
- if (open) {
537
- activeOptionRef.current?.scrollIntoView({ block: "nearest" });
538
- }
539
- }, [open, resolvedActiveIndex]);
540
- function select(option) {
541
- if (option.disabled) {
542
- return;
543
- }
544
- onValueChange(option.value);
545
- setSearch("");
546
- setOpen(false);
547
- }
548
- function onKeyDown(event) {
549
- if (event.key === "ArrowDown") {
550
- event.preventDefault();
551
- setOpen(true);
552
- setActiveIndex((current) => {
553
- const position = enabledIndexes.indexOf(current);
554
- return enabledIndexes[Math.min(enabledIndexes.length - 1, position + 1)] ?? -1;
555
- });
556
- } else if (event.key === "ArrowUp") {
557
- event.preventDefault();
558
- setOpen(true);
559
- setActiveIndex((current) => {
560
- const position = enabledIndexes.indexOf(current);
561
- return enabledIndexes[Math.max(0, position === -1 ? 0 : position - 1)] ?? -1;
562
- });
563
- } else if (event.key === "Home") {
564
- event.preventDefault();
565
- setOpen(true);
566
- setActiveIndex(enabledIndexes[0] ?? -1);
567
- } else if (event.key === "End") {
568
- event.preventDefault();
569
- setOpen(true);
570
- setActiveIndex(enabledIndexes.at(-1) ?? -1);
571
- } else if (event.key === "Enter" && open && filteredOptions[resolvedActiveIndex]) {
572
- event.preventDefault();
573
- select(filteredOptions[resolvedActiveIndex]);
574
- } else if (event.key === "Escape") {
575
- setOpen(false);
576
- setSearch("");
577
- } else if (event.key === "Tab") {
578
- setOpen(false);
579
- setSearch("");
580
- }
581
- }
582
- return /* @__PURE__ */ jsxs3("div", { ref: rootRef, "data-slot": "searchable-select", className: cn("relative min-w-0", className), children: [
583
- name ? /* @__PURE__ */ jsx11("input", { type: "hidden", name, value }) : null,
584
- /* @__PURE__ */ jsxs3("div", { className: "relative", children: [
585
- /* @__PURE__ */ jsx11(Search, { className: "pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground", "aria-hidden": "true" }),
586
- /* @__PURE__ */ jsx11(
587
- Input,
588
- {
589
- id,
590
- role: "combobox",
591
- "aria-label": ariaLabel,
592
- "aria-autocomplete": "list",
593
- "aria-expanded": open,
594
- "aria-controls": open ? listboxId : void 0,
595
- "aria-activedescendant": open && filteredOptions[resolvedActiveIndex] ? `${listboxId}-${resolvedActiveIndex}` : void 0,
596
- autoComplete: "off",
597
- className: "px-9",
598
- disabled,
599
- placeholder: open ? searchPlaceholder : placeholder,
600
- value: open ? search : selected?.label ?? "",
601
- onFocus: (event) => {
602
- setOpen(true);
603
- setSearch("");
604
- event.currentTarget.select();
605
- },
606
- onClick: () => {
607
- if (!open) {
608
- setOpen(true);
609
- setSearch("");
610
- }
611
- },
612
- onChange: (event) => {
613
- setSearch(event.target.value);
614
- setOpen(true);
615
- setActiveIndex(0);
616
- },
617
- onKeyDown
618
- }
619
- ),
620
- clearable && value ? /* @__PURE__ */ jsx11(
621
- Button,
622
- {
623
- type: "button",
624
- variant: "ghost",
625
- size: "icon",
626
- disabled,
627
- className: "absolute right-8 top-1/2 -translate-y-1/2",
628
- "aria-label": clearLabel,
629
- onMouseDown: (event) => event.preventDefault(),
630
- onClick: () => {
631
- onValueChange("");
632
- setSearch("");
633
- },
634
- children: /* @__PURE__ */ jsx11(X, {})
635
- }
636
- ) : null,
637
- /* @__PURE__ */ jsx11(ChevronsUpDown, { className: "pointer-events-none absolute right-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground", "aria-hidden": "true" })
638
- ] }),
639
- open ? /* @__PURE__ */ jsx11(
640
- "div",
641
- {
642
- id: listboxId,
643
- role: "listbox",
644
- "aria-label": optionsLabel ?? (ariaLabel ? `${ariaLabel} options` : "Options"),
645
- className: "absolute z-50 mt-1 max-h-72 w-full overflow-y-auto rounded-md border border-border-subtle bg-popover p-1 text-popover-foreground shadow-md",
646
- children: filteredOptions.length ? filteredOptions.map((option, index) => /* @__PURE__ */ jsxs3(
647
- "button",
648
- {
649
- id: `${listboxId}-${index}`,
650
- type: "button",
651
- role: "option",
652
- "aria-selected": option.value === value,
653
- "aria-disabled": option.disabled || void 0,
654
- disabled: option.disabled,
655
- tabIndex: -1,
656
- ref: index === resolvedActiveIndex ? activeOptionRef : void 0,
657
- "data-active": index === resolvedActiveIndex,
658
- className: "ds-type-menu-item flex w-full items-center gap-3 rounded-sm px-3 py-2 text-left outline-none hover:bg-surface-muted focus-visible:bg-surface-muted data-[active=true]:bg-surface-muted disabled:pointer-events-none disabled:opacity-50",
659
- onMouseDown: (event) => event.preventDefault(),
660
- onMouseEnter: () => setActiveIndex(index),
661
- onClick: () => select(option),
662
- children: [
663
- /* @__PURE__ */ jsxs3("span", { className: "grid min-w-0 flex-1 gap-0.5", children: [
664
- /* @__PURE__ */ jsx11("span", { className: "truncate font-medium", children: option.label }),
665
- option.description ? /* @__PURE__ */ jsx11("span", { className: "ds-type-menu-label truncate text-muted-foreground", children: option.description }) : null
666
- ] }),
667
- option.value === value ? /* @__PURE__ */ jsx11(Check, { className: "size-4 shrink-0 text-success-foreground", "aria-hidden": "true" }) : null
668
- ]
669
- },
670
- option.value
671
- )) : /* @__PURE__ */ jsx11("p", { className: "ds-type-menu-item px-3 py-6 text-center text-muted-foreground", children: emptyMessage })
672
- }
673
- ) : null
674
- ] });
675
- }
676
-
677
- export {
678
- alertVariants,
679
- Alert,
680
- AlertTitle,
681
- AlertDescription,
682
- Avatar,
683
- AvatarImage,
684
- AvatarFallback,
685
- badgeVariants,
686
- Badge,
687
- BrandIcon,
688
- Switch,
689
- Textarea,
690
- ConsciaButton,
691
- ConsciaIconButton,
692
- ConsciaCard,
693
- ConsciaCardContent,
694
- ConsciaCardDescription,
695
- ConsciaCardHeader,
696
- ConsciaCardTitle,
697
- ConsciaCheckbox,
698
- ConsciaInput,
699
- ConsciaSwitch,
700
- ConsciaTextarea,
701
- ConsciaSelect,
702
- ConsciaSelectContent,
703
- ConsciaSelectGroup,
704
- ConsciaSelectItem,
705
- ConsciaSelectTrigger,
706
- ConsciaSelectValue,
707
- ConsciaTable,
708
- ConsciaTableBody,
709
- ConsciaTableCell,
710
- ConsciaTableHeader,
711
- ConsciaTableHead,
712
- ConsciaTableRow,
713
- Field,
714
- FieldGroup,
715
- FieldLabel,
716
- FieldDescription,
717
- FieldError,
718
- FormSelect,
719
- ConsciaFormSelect,
720
- Label,
721
- SearchableSelect
722
- };
723
- //# sourceMappingURL=chunk-C44RGLGF.js.map