@sidecar-ai/native 0.1.0-alpha.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.
@@ -0,0 +1,1628 @@
1
+ // packages/native/src/components/index.tsx
2
+ import * as React from "react";
3
+ var Button = React.forwardRef(function Button2({
4
+ block = false,
5
+ children,
6
+ color,
7
+ disabled,
8
+ disabledTone,
9
+ gutterSize,
10
+ iconSize,
11
+ inert = false,
12
+ intent,
13
+ loading = false,
14
+ opticallyAlign,
15
+ pill = true,
16
+ recipe = "auto",
17
+ selected = false,
18
+ size = "md",
19
+ type = "button",
20
+ uniform = false,
21
+ variant,
22
+ ...props
23
+ }, ref) {
24
+ const visual = normalizeButtonVisual({ color, intent, variant });
25
+ return React.createElement(
26
+ "button",
27
+ {
28
+ ref,
29
+ "aria-busy": loading || void 0,
30
+ "data-sc-block": block ? "" : void 0,
31
+ "data-sc-color": visual.color,
32
+ "data-sc-component": "button",
33
+ "data-sc-disabled-tone": disabledTone,
34
+ "data-sc-gutter-size": gutterSize,
35
+ "data-sc-icon-size": iconSize,
36
+ "data-sc-inert": inert ? "" : void 0,
37
+ "data-sc-intent": visual.color,
38
+ "data-sc-loading": loading ? "" : void 0,
39
+ "data-sc-optically-align": opticallyAlign,
40
+ "data-sc-pill": pill ? "" : void 0,
41
+ "data-sc-recipe": recipe,
42
+ "data-sc-selected": selected ? "" : void 0,
43
+ "data-sc-size": size,
44
+ "data-sc-uniform": uniform ? "" : void 0,
45
+ "data-sc-variant": visual.variant,
46
+ disabled: disabled || loading || void 0,
47
+ type,
48
+ ...props
49
+ },
50
+ loading ? React.createElement(LoadingIndicator, { "aria-hidden": true, size: "1em" }) : null,
51
+ React.createElement("span", { "data-sc-component": "button-label" }, children)
52
+ );
53
+ });
54
+ var ButtonLink = React.forwardRef(function ButtonLink2({
55
+ block = false,
56
+ children,
57
+ color,
58
+ disabledTone,
59
+ external,
60
+ gutterSize,
61
+ href,
62
+ iconSize,
63
+ inert = false,
64
+ intent,
65
+ loading = false,
66
+ opticallyAlign,
67
+ pill = true,
68
+ recipe = "auto",
69
+ rel,
70
+ selected = false,
71
+ size = "md",
72
+ target,
73
+ uniform = false,
74
+ variant,
75
+ ...props
76
+ }, ref) {
77
+ const visual = normalizeButtonVisual({ color, intent, variant });
78
+ const isExternal = external ?? Boolean(href && /^(?:[a-z][a-z0-9+.-]*:)?\/\//i.test(href));
79
+ return React.createElement(
80
+ "a",
81
+ {
82
+ ref,
83
+ "data-sc-block": block ? "" : void 0,
84
+ "data-sc-color": visual.color,
85
+ "data-sc-component": "button",
86
+ "data-sc-disabled-tone": disabledTone,
87
+ "data-sc-gutter-size": gutterSize,
88
+ "data-sc-icon-size": iconSize,
89
+ "data-sc-inert": inert ? "" : void 0,
90
+ "data-sc-loading": loading ? "" : void 0,
91
+ "data-sc-optically-align": opticallyAlign,
92
+ "data-sc-pill": pill ? "" : void 0,
93
+ "data-sc-recipe": recipe,
94
+ "data-sc-selected": selected ? "" : void 0,
95
+ "data-sc-size": size,
96
+ "data-sc-uniform": uniform ? "" : void 0,
97
+ "data-sc-variant": visual.variant,
98
+ href,
99
+ rel: isExternal && target === "_blank" ? mergeRel(rel, "noopener noreferrer") : rel,
100
+ target,
101
+ ...props
102
+ },
103
+ loading ? React.createElement(LoadingIndicator, { "aria-hidden": true, size: "1em" }) : null,
104
+ React.createElement("span", { "data-sc-component": "button-label" }, children)
105
+ );
106
+ });
107
+ function CopyButton({ children = "Copy", copyValue, onClick, ...restProps }) {
108
+ const [copied, setCopied] = React.useState(false);
109
+ React.useEffect(() => {
110
+ if (!copied) {
111
+ return;
112
+ }
113
+ const timeout = window.setTimeout(() => setCopied(false), 1400);
114
+ return () => window.clearTimeout(timeout);
115
+ }, [copied]);
116
+ return React.createElement(
117
+ Button,
118
+ {
119
+ ...restProps,
120
+ onClick: async (event) => {
121
+ onClick?.(event);
122
+ if (event.defaultPrevented) {
123
+ return;
124
+ }
125
+ const resolved = typeof copyValue === "function" ? copyValue() : copyValue;
126
+ await copyToClipboard(resolved);
127
+ setCopied(true);
128
+ }
129
+ },
130
+ typeof children === "function" ? children({ copied }) : children
131
+ );
132
+ }
133
+ var Text = React.forwardRef(function Text2({ tone = "default", recipe = "auto", ...props }, ref) {
134
+ return React.createElement("p", {
135
+ ref,
136
+ "data-sc-component": "text",
137
+ "data-sc-recipe": recipe,
138
+ "data-sc-tone": tone,
139
+ ...props
140
+ });
141
+ });
142
+ var Heading = React.forwardRef(function Heading2({ level = 2, recipe = "auto", ...props }, ref) {
143
+ return React.createElement(`h${level}`, {
144
+ ref,
145
+ "data-sc-component": "heading",
146
+ "data-sc-level": level,
147
+ "data-sc-recipe": recipe,
148
+ ...props
149
+ });
150
+ });
151
+ var Input = React.forwardRef(function Input2({
152
+ allowAutofillExtensions: _allowAutofillExtensions,
153
+ autoSelect = false,
154
+ block = false,
155
+ disabled = false,
156
+ endAdornment,
157
+ gutterSize,
158
+ id,
159
+ invalid,
160
+ onAutofill: _onAutofill,
161
+ opticallyAlign,
162
+ pill = false,
163
+ recipe = "auto",
164
+ size = "md",
165
+ startAdornment,
166
+ variant = "outline",
167
+ ...props
168
+ }, ref) {
169
+ const field = React.useContext(FieldContext);
170
+ const inputRef = React.useRef(null);
171
+ const mergedRef = useMergedRefs(ref, inputRef);
172
+ const inputId = id ?? field?.controlId;
173
+ const resolvedInvalid = invalid ?? field?.invalid ?? false;
174
+ React.useEffect(() => {
175
+ if (autoSelect) {
176
+ inputRef.current?.select();
177
+ }
178
+ }, [autoSelect]);
179
+ return React.createElement(
180
+ "span",
181
+ {
182
+ "data-sc-block": block ? "" : void 0,
183
+ "data-sc-component": "input-shell",
184
+ "data-sc-disabled": disabled ? "" : void 0,
185
+ "data-sc-gutter-size": gutterSize,
186
+ "data-sc-has-end-adornment": endAdornment ? "" : void 0,
187
+ "data-sc-has-start-adornment": startAdornment ? "" : void 0,
188
+ "data-sc-invalid": resolvedInvalid ? "" : void 0,
189
+ "data-sc-optically-align": opticallyAlign,
190
+ "data-sc-pill": pill ? "" : void 0,
191
+ "data-sc-recipe": recipe,
192
+ "data-sc-size": size,
193
+ "data-sc-variant": variant
194
+ },
195
+ startAdornment ? React.createElement("span", { "data-sc-component": "input-adornment" }, startAdornment) : null,
196
+ React.createElement("input", {
197
+ ref: mergedRef,
198
+ "aria-describedby": describedBy(props["aria-describedby"], field, resolvedInvalid),
199
+ "aria-invalid": resolvedInvalid || void 0,
200
+ disabled,
201
+ id: inputId,
202
+ "data-sc-component": "input",
203
+ ...props
204
+ }),
205
+ endAdornment ? React.createElement("span", { "data-sc-component": "input-adornment" }, endAdornment) : null
206
+ );
207
+ });
208
+ var TextField = Input;
209
+ var Textarea = React.forwardRef(function Textarea2({
210
+ allowAutofillExtensions: _allowAutofillExtensions,
211
+ autoResize = false,
212
+ autoSelect = false,
213
+ block = false,
214
+ disabled = false,
215
+ gutterSize,
216
+ id,
217
+ invalid,
218
+ maxRows: _maxRows,
219
+ onAutofill: _onAutofill,
220
+ opticallyAlign,
221
+ pill = false,
222
+ recipe = "auto",
223
+ rows = 3,
224
+ size = "md",
225
+ variant = "outline",
226
+ ...props
227
+ }, ref) {
228
+ const field = React.useContext(FieldContext);
229
+ const textareaRef = React.useRef(null);
230
+ const mergedRef = useMergedRefs(ref, textareaRef);
231
+ const inputId = id ?? field?.controlId;
232
+ const resolvedInvalid = invalid ?? field?.invalid ?? false;
233
+ React.useEffect(() => {
234
+ if (autoSelect) {
235
+ textareaRef.current?.select();
236
+ }
237
+ }, [autoSelect]);
238
+ React.useLayoutEffect(() => {
239
+ const node = textareaRef.current;
240
+ if (!node || !autoResize) {
241
+ return;
242
+ }
243
+ node.style.height = "auto";
244
+ node.style.height = `${node.scrollHeight}px`;
245
+ }, [autoResize, props.value, props.defaultValue]);
246
+ return React.createElement("textarea", {
247
+ ref: mergedRef,
248
+ "aria-describedby": describedBy(props["aria-describedby"], field, resolvedInvalid),
249
+ "aria-invalid": resolvedInvalid || void 0,
250
+ disabled,
251
+ id: inputId,
252
+ "data-sc-block": block ? "" : void 0,
253
+ "data-sc-component": "textarea",
254
+ "data-sc-disabled": disabled ? "" : void 0,
255
+ "data-sc-gutter-size": gutterSize,
256
+ "data-sc-invalid": resolvedInvalid ? "" : void 0,
257
+ "data-sc-optically-align": opticallyAlign,
258
+ "data-sc-pill": pill ? "" : void 0,
259
+ "data-sc-recipe": recipe,
260
+ "data-sc-size": size,
261
+ "data-sc-variant": variant,
262
+ rows,
263
+ ...props
264
+ });
265
+ });
266
+ function Checkbox({
267
+ checked,
268
+ className,
269
+ defaultChecked = false,
270
+ disabled = false,
271
+ id,
272
+ label,
273
+ name,
274
+ onBlur,
275
+ onCheckedChange,
276
+ onFocus,
277
+ orientation = "left",
278
+ recipe = "auto",
279
+ required = false,
280
+ value = "on"
281
+ }) {
282
+ const generatedId = React.useId();
283
+ const controlId = id ?? generatedId;
284
+ const [state, setState] = useControllableValue({
285
+ controlled: checked,
286
+ defaultValue: defaultChecked,
287
+ onChange: (next) => onCheckedChange?.(next === true)
288
+ });
289
+ const isChecked = state === true;
290
+ const isMixed = state === "indeterminate";
291
+ const button = React.createElement("button", {
292
+ "aria-checked": isMixed ? "mixed" : isChecked,
293
+ "aria-labelledby": label ? `${controlId}-label` : void 0,
294
+ disabled,
295
+ id: controlId,
296
+ onBlur,
297
+ onClick: () => {
298
+ if (!disabled) {
299
+ setState(!isChecked);
300
+ }
301
+ },
302
+ onFocus,
303
+ role: "checkbox",
304
+ type: "button",
305
+ "data-sc-checked": isChecked ? "" : void 0,
306
+ "data-sc-component": "checkbox",
307
+ "data-sc-disabled": disabled ? "" : void 0,
308
+ "data-sc-indeterminate": isMixed ? "" : void 0,
309
+ "data-sc-recipe": recipe
310
+ });
311
+ const labelNode = label ? React.createElement("span", { id: `${controlId}-label`, "data-sc-component": "checkbox-label-text" }, label) : null;
312
+ return React.createElement(
313
+ "label",
314
+ {
315
+ className,
316
+ "data-sc-component": "checkbox-label",
317
+ "data-sc-orientation": orientation,
318
+ "data-sc-recipe": recipe
319
+ },
320
+ orientation === "right" ? labelNode : button,
321
+ React.createElement("input", {
322
+ checked: isChecked,
323
+ disabled,
324
+ name,
325
+ readOnly: true,
326
+ required,
327
+ tabIndex: -1,
328
+ type: "checkbox",
329
+ value,
330
+ "data-sc-component": "visually-hidden-input"
331
+ }),
332
+ orientation === "right" ? button : labelNode
333
+ );
334
+ }
335
+ function Switch({
336
+ checked,
337
+ className,
338
+ defaultChecked = false,
339
+ disabled = false,
340
+ id,
341
+ label,
342
+ labelPosition = "end",
343
+ name,
344
+ onBlur,
345
+ onCheckedChange,
346
+ onFocus,
347
+ recipe = "auto",
348
+ required = false,
349
+ value = "on"
350
+ }) {
351
+ const generatedId = React.useId();
352
+ const controlId = id ?? generatedId;
353
+ const [state, setState] = useControllableValue({
354
+ controlled: checked,
355
+ defaultValue: defaultChecked,
356
+ onChange: onCheckedChange
357
+ });
358
+ const button = React.createElement(
359
+ "button",
360
+ {
361
+ "aria-checked": state,
362
+ "aria-labelledby": label ? `${controlId}-label` : void 0,
363
+ disabled,
364
+ id: controlId,
365
+ onBlur,
366
+ onClick: () => {
367
+ if (!disabled) {
368
+ setState(!state);
369
+ }
370
+ },
371
+ onFocus,
372
+ role: "switch",
373
+ type: "button",
374
+ "data-sc-checked": state ? "" : void 0,
375
+ "data-sc-component": "switch",
376
+ "data-sc-disabled": disabled ? "" : void 0,
377
+ "data-sc-recipe": recipe
378
+ },
379
+ React.createElement("span", { "data-sc-component": "switch-thumb" })
380
+ );
381
+ const labelNode = label ? React.createElement("span", { id: `${controlId}-label`, "data-sc-component": "switch-label-text" }, label) : null;
382
+ return React.createElement(
383
+ "label",
384
+ {
385
+ className,
386
+ "data-sc-component": "switch-label",
387
+ "data-sc-label-position": labelPosition,
388
+ "data-sc-recipe": recipe
389
+ },
390
+ labelPosition === "start" ? labelNode : button,
391
+ React.createElement("input", {
392
+ checked: state,
393
+ disabled,
394
+ name,
395
+ readOnly: true,
396
+ required,
397
+ tabIndex: -1,
398
+ type: "checkbox",
399
+ value,
400
+ "data-sc-component": "visually-hidden-input"
401
+ }),
402
+ labelPosition === "start" ? button : labelNode
403
+ );
404
+ }
405
+ var RadioGroupContext = React.createContext(null);
406
+ function RadioGroupRoot({
407
+ children,
408
+ className,
409
+ defaultValue,
410
+ direction = "row",
411
+ disabled = false,
412
+ name,
413
+ onChange,
414
+ recipe = "auto",
415
+ required = false,
416
+ value,
417
+ ...restProps
418
+ }) {
419
+ const [selected, setSelected] = useControllableValue({
420
+ controlled: value,
421
+ defaultValue,
422
+ onChange: (next) => {
423
+ if (next !== void 0) {
424
+ onChange?.(next);
425
+ }
426
+ }
427
+ });
428
+ return React.createElement(
429
+ RadioGroupContext.Provider,
430
+ {
431
+ value: {
432
+ disabled,
433
+ name,
434
+ onChange: setSelected,
435
+ recipe,
436
+ required,
437
+ value: selected
438
+ }
439
+ },
440
+ React.createElement(
441
+ "div",
442
+ {
443
+ ...restProps,
444
+ className,
445
+ role: "radiogroup",
446
+ "data-sc-component": "radio-group",
447
+ "data-sc-direction": direction,
448
+ "data-sc-disabled": disabled ? "" : void 0,
449
+ "data-sc-recipe": recipe
450
+ },
451
+ children
452
+ )
453
+ );
454
+ }
455
+ function RadioGroupItem({
456
+ block = false,
457
+ children,
458
+ className,
459
+ disabled = false,
460
+ required,
461
+ value
462
+ }) {
463
+ const context = useRequiredContext(RadioGroupContext, "RadioGroup.Item must be rendered inside RadioGroup");
464
+ const itemDisabled = context.disabled || disabled;
465
+ const checked = context.value === value;
466
+ return React.createElement(
467
+ "button",
468
+ {
469
+ "aria-checked": checked,
470
+ className,
471
+ disabled: itemDisabled,
472
+ onClick: () => {
473
+ if (!itemDisabled) {
474
+ context.onChange(value);
475
+ }
476
+ },
477
+ role: "radio",
478
+ type: "button",
479
+ "data-sc-block": block ? "" : void 0,
480
+ "data-sc-checked": checked ? "" : void 0,
481
+ "data-sc-component": "radio-item",
482
+ "data-sc-disabled": itemDisabled ? "" : void 0,
483
+ "data-sc-recipe": context.recipe
484
+ },
485
+ React.createElement("span", { "data-sc-component": "radio-indicator" }),
486
+ React.createElement("span", { "data-sc-component": "radio-label" }, children),
487
+ context.name ? React.createElement("input", {
488
+ checked,
489
+ disabled: itemDisabled,
490
+ name: context.name,
491
+ readOnly: true,
492
+ required: required ?? context.required,
493
+ tabIndex: -1,
494
+ type: "radio",
495
+ value,
496
+ "data-sc-component": "visually-hidden-input"
497
+ }) : null
498
+ );
499
+ }
500
+ var RadioGroup = Object.assign(RadioGroupRoot, {
501
+ Item: RadioGroupItem
502
+ });
503
+ var SegmentedControlContext = React.createContext(null);
504
+ function SegmentedControlRoot({
505
+ block = false,
506
+ children,
507
+ className,
508
+ defaultValue,
509
+ disabled = false,
510
+ gutterSize,
511
+ onChange,
512
+ onClick,
513
+ pill = false,
514
+ recipe = "auto",
515
+ size = "md",
516
+ value,
517
+ ...restProps
518
+ }) {
519
+ const [selected, setSelected] = useControllableValue({
520
+ controlled: value,
521
+ defaultValue,
522
+ onChange: (next) => {
523
+ if (next !== void 0) {
524
+ onChange?.(next);
525
+ }
526
+ }
527
+ });
528
+ return React.createElement(
529
+ SegmentedControlContext.Provider,
530
+ {
531
+ value: {
532
+ disabled,
533
+ onChange: setSelected,
534
+ onClick,
535
+ recipe,
536
+ selected
537
+ }
538
+ },
539
+ React.createElement(
540
+ "div",
541
+ {
542
+ ...restProps,
543
+ className,
544
+ role: "group",
545
+ "data-sc-block": block ? "" : void 0,
546
+ "data-sc-component": "segmented-control",
547
+ "data-sc-disabled": disabled ? "" : void 0,
548
+ "data-sc-gutter-size": gutterSize,
549
+ "data-sc-pill": pill ? "" : void 0,
550
+ "data-sc-recipe": recipe,
551
+ "data-sc-size": size
552
+ },
553
+ children
554
+ )
555
+ );
556
+ }
557
+ function SegmentedControlOption({
558
+ children,
559
+ disabled = false,
560
+ value,
561
+ ...restProps
562
+ }) {
563
+ const context = useRequiredContext(
564
+ SegmentedControlContext,
565
+ "SegmentedControl.Option must be rendered inside SegmentedControl"
566
+ );
567
+ const selected = context.selected === value;
568
+ const optionDisabled = context.disabled || disabled;
569
+ return React.createElement(
570
+ "button",
571
+ {
572
+ ...restProps,
573
+ "aria-pressed": selected,
574
+ disabled: optionDisabled,
575
+ onClick: () => {
576
+ context.onClick?.();
577
+ if (!optionDisabled) {
578
+ context.onChange(value);
579
+ }
580
+ },
581
+ type: "button",
582
+ "data-sc-component": "segmented-option",
583
+ "data-sc-disabled": optionDisabled ? "" : void 0,
584
+ "data-sc-recipe": context.recipe,
585
+ "data-sc-selected": selected ? "" : void 0
586
+ },
587
+ children
588
+ );
589
+ }
590
+ var SegmentedControl = Object.assign(SegmentedControlRoot, {
591
+ Option: SegmentedControlOption
592
+ });
593
+ function Select({
594
+ actions,
595
+ block = true,
596
+ clearable = false,
597
+ defaultOpen = false,
598
+ disabled = false,
599
+ dropdownIconType = "dropdown",
600
+ id,
601
+ loading = false,
602
+ loadingPlaceholder = "Loading...",
603
+ multiple,
604
+ name,
605
+ onChange,
606
+ OptionView,
607
+ options,
608
+ opticallyAlign,
609
+ pill = false,
610
+ placeholder = "Select...",
611
+ recipe = "auto",
612
+ required = false,
613
+ searchEmptyMessage = "No results",
614
+ searchPlaceholder = "Search...",
615
+ searchPredicate = defaultSearchPredicate,
616
+ size = "md",
617
+ TriggerStartIcon,
618
+ TriggerView,
619
+ triggerClassName,
620
+ value,
621
+ variant = "outline"
622
+ }) {
623
+ const [open, setOpen] = React.useState(defaultOpen);
624
+ const [search, setSearch] = React.useState("");
625
+ const allOptions = React.useMemo(() => flattenOptions(options), [options]);
626
+ const filteredOptions = React.useMemo(
627
+ () => allOptions.filter((option) => searchPredicate(option, search)),
628
+ [allOptions, search, searchPredicate]
629
+ );
630
+ const selectedOptions = React.useMemo(() => {
631
+ const values = Array.isArray(value) ? value : [value];
632
+ return allOptions.filter((option) => values.includes(option.value));
633
+ }, [allOptions, value]);
634
+ const selected = selectedOptions[0];
635
+ const triggerContent = renderSelectTriggerContent({
636
+ loading,
637
+ loadingPlaceholder,
638
+ multiple: Boolean(multiple),
639
+ placeholder,
640
+ selected,
641
+ selectedOptions,
642
+ TriggerView
643
+ });
644
+ const commitOption = (option) => {
645
+ if (option.disabled) {
646
+ return;
647
+ }
648
+ if (multiple) {
649
+ const current = selectedOptions.some((selectedOption) => selectedOption.value === option.value) ? selectedOptions.filter((selectedOption) => selectedOption.value !== option.value) : [...selectedOptions, option];
650
+ onChange(current);
651
+ return;
652
+ }
653
+ onChange(option);
654
+ setOpen(false);
655
+ };
656
+ return React.createElement(
657
+ "div",
658
+ {
659
+ "data-sc-block": block ? "" : void 0,
660
+ "data-sc-component": "select",
661
+ "data-sc-open": open ? "" : void 0,
662
+ "data-sc-recipe": recipe
663
+ },
664
+ React.createElement(SelectControl, {
665
+ block,
666
+ children: triggerContent,
667
+ className: triggerClassName,
668
+ disabled,
669
+ dropdownIconType,
670
+ id,
671
+ loading,
672
+ onClearClick: clearable && selectedOptions.length > 0 ? () => {
673
+ if (multiple) {
674
+ onChange([]);
675
+ } else {
676
+ onChange({ label: "", value: "" });
677
+ }
678
+ } : void 0,
679
+ onInteract: () => setOpen((next) => !next),
680
+ opticallyAlign,
681
+ pill,
682
+ recipe,
683
+ selected: selectedOptions.length > 0,
684
+ size,
685
+ StartIcon: TriggerStartIcon,
686
+ variant
687
+ }),
688
+ name ? renderHiddenSelectInputs({
689
+ disabled,
690
+ multiple: Boolean(multiple),
691
+ name,
692
+ required,
693
+ selectedOptions,
694
+ value
695
+ }) : null,
696
+ open ? React.createElement(
697
+ "div",
698
+ {
699
+ role: "listbox",
700
+ "aria-multiselectable": multiple || void 0,
701
+ "data-sc-component": "select-list",
702
+ "data-sc-recipe": recipe
703
+ },
704
+ React.createElement(Input, {
705
+ "aria-label": searchPlaceholder,
706
+ onChange: (event) => setSearch(event.currentTarget.value),
707
+ placeholder: searchPlaceholder,
708
+ recipe,
709
+ size: "sm",
710
+ value: search
711
+ }),
712
+ filteredOptions.length === 0 ? React.createElement("div", { "data-sc-component": "select-empty" }, searchEmptyMessage) : filteredOptions.map((option) => {
713
+ const selectedOption = selectedOptions.some((selectedCandidate) => selectedCandidate.value === option.value);
714
+ return React.createElement(
715
+ "button",
716
+ {
717
+ className: void 0,
718
+ disabled: option.disabled,
719
+ key: option.value,
720
+ onClick: () => commitOption(option),
721
+ role: "option",
722
+ type: "button",
723
+ "aria-selected": selectedOption,
724
+ "data-sc-component": "select-option",
725
+ "data-sc-disabled": option.disabled ? "" : void 0,
726
+ "data-sc-selected": selectedOption ? "" : void 0
727
+ },
728
+ OptionView ? React.createElement(OptionView, option) : React.createElement(
729
+ React.Fragment,
730
+ null,
731
+ React.createElement("span", { "data-sc-component": "select-option-label" }, option.label),
732
+ option.description ? React.createElement("span", { "data-sc-component": "select-option-description" }, option.description) : null
733
+ )
734
+ );
735
+ }),
736
+ actions?.length ? React.createElement(
737
+ "div",
738
+ { "data-sc-component": "select-actions" },
739
+ actions.map(
740
+ (action) => React.createElement(
741
+ "button",
742
+ {
743
+ className: action.className,
744
+ key: action.id,
745
+ onClick: () => action.onSelect(action.id),
746
+ type: "button",
747
+ "data-sc-component": "select-action"
748
+ },
749
+ action.Icon ? React.createElement(action.Icon, { "aria-hidden": true }) : null,
750
+ action.label
751
+ )
752
+ )
753
+ ) : null
754
+ ) : null
755
+ );
756
+ }
757
+ var SelectControl = React.forwardRef(function SelectControl2({
758
+ block = true,
759
+ children,
760
+ disabled = false,
761
+ dropdownIconType = "dropdown",
762
+ invalid = false,
763
+ loading = false,
764
+ onClearClick,
765
+ onInteract,
766
+ opticallyAlign,
767
+ pill = false,
768
+ recipe = "auto",
769
+ selected = false,
770
+ size = "md",
771
+ StartIcon,
772
+ tabIndex,
773
+ variant = "outline",
774
+ ...props
775
+ }, ref) {
776
+ return React.createElement(
777
+ "span",
778
+ {
779
+ ref,
780
+ role: "button",
781
+ tabIndex: disabled ? -1 : tabIndex ?? 0,
782
+ onClick: () => {
783
+ if (!disabled) {
784
+ onInteract?.();
785
+ }
786
+ },
787
+ onKeyDown: (event) => {
788
+ props.onKeyDown?.(event);
789
+ if (!disabled && !event.defaultPrevented && (event.key === "Enter" || event.key === " ")) {
790
+ event.preventDefault();
791
+ onInteract?.();
792
+ }
793
+ },
794
+ "data-sc-block": block ? "" : void 0,
795
+ "data-sc-component": "select-control",
796
+ "data-sc-disabled": disabled ? "" : void 0,
797
+ "data-sc-invalid": invalid ? "" : void 0,
798
+ "data-sc-optically-align": opticallyAlign,
799
+ "data-sc-pill": pill ? "" : void 0,
800
+ "data-sc-recipe": recipe,
801
+ "data-sc-selected": selected ? "" : void 0,
802
+ "data-sc-size": size,
803
+ "data-sc-variant": variant,
804
+ ...props
805
+ },
806
+ StartIcon ? React.createElement(StartIcon, { "aria-hidden": true }) : null,
807
+ React.createElement("span", { "data-sc-component": "select-control-value" }, children),
808
+ loading ? React.createElement(LoadingIndicator, { "aria-hidden": true, size: "1em" }) : null,
809
+ onClearClick ? React.createElement(
810
+ "button",
811
+ {
812
+ "aria-label": "Clear selection",
813
+ onClick: (event) => {
814
+ event.stopPropagation();
815
+ onClearClick();
816
+ },
817
+ type: "button",
818
+ "data-sc-component": "select-clear"
819
+ },
820
+ "\xD7"
821
+ ) : null,
822
+ dropdownIconType === "none" ? null : React.createElement("span", { "aria-hidden": true, "data-sc-component": "select-dropdown-icon" }, dropdownIconType === "chevronDown" ? "\u2304" : "\u25BE")
823
+ );
824
+ });
825
+ var Badge = React.forwardRef(function Badge2({
826
+ children,
827
+ color,
828
+ pill = false,
829
+ recipe = "auto",
830
+ size = "sm",
831
+ tone,
832
+ variant = "soft",
833
+ ...props
834
+ }, ref) {
835
+ const resolvedColor = color ?? toneToColor(tone) ?? "secondary";
836
+ return React.createElement(
837
+ "span",
838
+ {
839
+ ref,
840
+ "data-sc-color": resolvedColor,
841
+ "data-sc-component": "badge",
842
+ "data-sc-pill": pill ? "" : void 0,
843
+ "data-sc-recipe": recipe,
844
+ "data-sc-size": size,
845
+ "data-sc-tone": tone,
846
+ "data-sc-variant": variant,
847
+ ...props
848
+ },
849
+ children
850
+ );
851
+ });
852
+ var Alert = React.forwardRef(function Alert2({
853
+ actions,
854
+ actionsClassName,
855
+ actionsPlacement,
856
+ children,
857
+ color,
858
+ description,
859
+ indicator,
860
+ recipe = "auto",
861
+ role = "note",
862
+ title,
863
+ tone,
864
+ variant = "soft",
865
+ ...props
866
+ }, ref) {
867
+ const resolvedColor = color ?? toneToColor(tone) ?? "primary";
868
+ return React.createElement(
869
+ "div",
870
+ {
871
+ ref,
872
+ role,
873
+ "data-sc-actions-placement": actionsPlacement,
874
+ "data-sc-color": resolvedColor,
875
+ "data-sc-component": "alert",
876
+ "data-sc-recipe": recipe,
877
+ "data-sc-tone": tone,
878
+ "data-sc-variant": variant,
879
+ ...props
880
+ },
881
+ indicator === false ? null : React.createElement(
882
+ "span",
883
+ { "aria-hidden": true, "data-sc-component": "alert-indicator" },
884
+ indicator ?? "\u2022"
885
+ ),
886
+ React.createElement(
887
+ "div",
888
+ { "data-sc-component": "alert-content" },
889
+ title ? React.createElement("div", { "data-sc-component": "alert-title" }, title) : null,
890
+ description ? React.createElement("div", { "data-sc-component": "alert-description" }, description) : null,
891
+ children
892
+ ),
893
+ actions ? React.createElement(
894
+ "div",
895
+ { className: actionsClassName, "data-sc-component": "alert-actions" },
896
+ actions
897
+ ) : null
898
+ );
899
+ });
900
+ var Callout = Alert;
901
+ var Avatar = React.forwardRef(function Avatar2({
902
+ alt = "",
903
+ color = "secondary",
904
+ fallback,
905
+ Icon,
906
+ imageUrl,
907
+ name,
908
+ overflowCount,
909
+ recipe = "auto",
910
+ size = 28,
911
+ src,
912
+ variant = "soft",
913
+ ...props
914
+ }, ref) {
915
+ const url = imageUrl ?? src;
916
+ const label = overflowCount !== void 0 ? formatOverflow(overflowCount) : initialsFromName(name);
917
+ const interactive = Boolean(props.onClick || props.onPointerDown);
918
+ return React.createElement(
919
+ "span",
920
+ {
921
+ ref,
922
+ role: interactive ? "button" : void 0,
923
+ tabIndex: interactive ? 0 : void 0,
924
+ "data-sc-color": color,
925
+ "data-sc-component": "avatar",
926
+ "data-sc-interactive": interactive ? "" : void 0,
927
+ "data-sc-recipe": recipe,
928
+ "data-sc-variant": variant,
929
+ style: { "--sc-avatar-size": `${size}px`, ...props.style },
930
+ ...props
931
+ },
932
+ url ? React.createElement("img", { alt, src: url }) : null,
933
+ !url && Icon ? React.createElement(Icon, { "aria-hidden": true }) : null,
934
+ !url && !Icon ? fallback ?? label : null
935
+ );
936
+ });
937
+ function AvatarGroup({ children, className, recipe = "auto", size, stack = "start" }) {
938
+ return React.createElement(
939
+ "div",
940
+ {
941
+ className,
942
+ "data-sc-component": "avatar-group",
943
+ "data-sc-recipe": recipe,
944
+ "data-sc-stack": stack,
945
+ style: size ? { "--sc-avatar-size": `${size}px` } : void 0
946
+ },
947
+ children
948
+ );
949
+ }
950
+ var EmptyMessageContext = React.createContext("auto");
951
+ function EmptyMessageRoot({ children, className, fill = "static", recipe = "auto" }) {
952
+ return React.createElement(
953
+ EmptyMessageContext.Provider,
954
+ { value: recipe },
955
+ React.createElement(
956
+ "div",
957
+ {
958
+ className,
959
+ "data-sc-component": "empty-message",
960
+ "data-sc-fill": fill,
961
+ "data-sc-recipe": recipe
962
+ },
963
+ children
964
+ )
965
+ );
966
+ }
967
+ function EmptyMessageIcon({ children, className, color = "secondary", recipe, size = "sm" }) {
968
+ const inheritedRecipe = React.useContext(EmptyMessageContext);
969
+ return React.createElement(
970
+ "div",
971
+ {
972
+ className,
973
+ "data-sc-color": color,
974
+ "data-sc-component": "empty-message-icon",
975
+ "data-sc-recipe": recipe ?? inheritedRecipe,
976
+ "data-sc-size": size
977
+ },
978
+ children
979
+ );
980
+ }
981
+ function EmptyMessageTitle({ children, className, color = "secondary", recipe }) {
982
+ const inheritedRecipe = React.useContext(EmptyMessageContext);
983
+ return React.createElement(
984
+ "div",
985
+ {
986
+ className,
987
+ "data-sc-color": color,
988
+ "data-sc-component": "empty-message-title",
989
+ "data-sc-recipe": recipe ?? inheritedRecipe
990
+ },
991
+ children
992
+ );
993
+ }
994
+ function EmptyMessageDescription({
995
+ children,
996
+ className
997
+ }) {
998
+ return React.createElement("div", { className, "data-sc-component": "empty-message-description" }, children);
999
+ }
1000
+ function EmptyMessageActionRow({
1001
+ children,
1002
+ className
1003
+ }) {
1004
+ return React.createElement("div", { className, "data-sc-component": "empty-message-actions" }, children);
1005
+ }
1006
+ var EmptyMessage = Object.assign(EmptyMessageRoot, {
1007
+ ActionRow: EmptyMessageActionRow,
1008
+ Description: EmptyMessageDescription,
1009
+ Icon: EmptyMessageIcon,
1010
+ Title: EmptyMessageTitle
1011
+ });
1012
+ var EmptyState = React.forwardRef(function EmptyState2({ action, children, recipe = "auto", title, ...props }, ref) {
1013
+ return React.createElement(
1014
+ "div",
1015
+ { ref, ...props },
1016
+ React.createElement(
1017
+ EmptyMessage,
1018
+ {
1019
+ recipe,
1020
+ children: [
1021
+ React.createElement(EmptyMessage.Title, { children: title, key: "title" }),
1022
+ children ? React.createElement(EmptyMessage.Description, { children, key: "description" }) : null,
1023
+ action ? React.createElement(EmptyMessage.ActionRow, { children: action, key: "action" }) : null
1024
+ ]
1025
+ }
1026
+ )
1027
+ );
1028
+ });
1029
+ function LoadingDots({ recipe = "auto", ...props }) {
1030
+ return React.createElement(
1031
+ "div",
1032
+ {
1033
+ "aria-hidden": true,
1034
+ "data-sc-component": "loading-dots",
1035
+ "data-sc-recipe": recipe,
1036
+ ...props
1037
+ },
1038
+ React.createElement("span", null),
1039
+ React.createElement("span", null),
1040
+ React.createElement("span", null)
1041
+ );
1042
+ }
1043
+ function LoadingIndicator({
1044
+ className,
1045
+ recipe = "auto",
1046
+ size = "1em",
1047
+ strokeWidth = 2,
1048
+ style,
1049
+ ...props
1050
+ }) {
1051
+ return React.createElement(
1052
+ "div",
1053
+ {
1054
+ className,
1055
+ "data-sc-component": "loading-indicator",
1056
+ "data-sc-recipe": recipe,
1057
+ style: { "--sc-indicator-size": typeof size === "number" ? `${size}px` : size, ...style },
1058
+ ...props
1059
+ },
1060
+ React.createElement(
1061
+ "svg",
1062
+ {
1063
+ viewBox: "0 0 24 24",
1064
+ "aria-hidden": true
1065
+ },
1066
+ React.createElement("circle", {
1067
+ cx: 12,
1068
+ cy: 12,
1069
+ r: 9,
1070
+ fill: "none",
1071
+ stroke: "currentColor",
1072
+ strokeLinecap: "round",
1073
+ strokeWidth
1074
+ })
1075
+ )
1076
+ );
1077
+ }
1078
+ function CircularProgress({
1079
+ className,
1080
+ done = false,
1081
+ progress,
1082
+ recipe = "auto",
1083
+ size = 28,
1084
+ strokeWidth = 2,
1085
+ style,
1086
+ trackActiveColor = "currentColor",
1087
+ trackColor = "color-mix(in srgb, currentColor 18%, transparent)",
1088
+ ...props
1089
+ }) {
1090
+ const value = done ? 100 : Math.max(0, Math.min(100, progress ?? 66));
1091
+ const radius = 10;
1092
+ const circumference = 2 * Math.PI * radius;
1093
+ const dashOffset = circumference - value / 100 * circumference;
1094
+ return React.createElement(
1095
+ "div",
1096
+ {
1097
+ className,
1098
+ role: "progressbar",
1099
+ "aria-valuemax": 100,
1100
+ "aria-valuemin": 0,
1101
+ "aria-valuenow": value,
1102
+ "data-sc-component": "circular-progress",
1103
+ "data-sc-recipe": recipe,
1104
+ style: { "--sc-progress-size": typeof size === "number" ? `${size}px` : size, ...style },
1105
+ ...props
1106
+ },
1107
+ React.createElement(
1108
+ "svg",
1109
+ { viewBox: "0 0 24 24", "aria-hidden": true },
1110
+ React.createElement("circle", {
1111
+ cx: 12,
1112
+ cy: 12,
1113
+ fill: "none",
1114
+ r: radius,
1115
+ stroke: trackColor,
1116
+ strokeWidth
1117
+ }),
1118
+ React.createElement("circle", {
1119
+ cx: 12,
1120
+ cy: 12,
1121
+ fill: "none",
1122
+ r: radius,
1123
+ stroke: trackActiveColor,
1124
+ strokeDasharray: circumference,
1125
+ strokeDashoffset: dashOffset,
1126
+ strokeLinecap: "round",
1127
+ strokeWidth,
1128
+ transform: "rotate(-90 12 12)"
1129
+ })
1130
+ )
1131
+ );
1132
+ }
1133
+ var Spinner = LoadingIndicator;
1134
+ var Progress = React.forwardRef(function Progress2({ recipe = "auto", ...props }, ref) {
1135
+ return React.createElement("progress", {
1136
+ ref,
1137
+ "data-sc-component": "progress",
1138
+ "data-sc-recipe": recipe,
1139
+ ...props
1140
+ });
1141
+ });
1142
+ function ShimmerText({ as: Tag = "span", children, className, recipe = "auto" }) {
1143
+ return React.createElement(
1144
+ Tag,
1145
+ {
1146
+ className,
1147
+ "data-sc-component": "shimmer-text",
1148
+ "data-sc-recipe": recipe
1149
+ },
1150
+ children
1151
+ );
1152
+ }
1153
+ var TextLink = React.forwardRef(function TextLink2({
1154
+ children,
1155
+ forceExternal,
1156
+ href,
1157
+ primary = false,
1158
+ recipe = "auto",
1159
+ rel,
1160
+ target,
1161
+ underline = true,
1162
+ ...props
1163
+ }, ref) {
1164
+ const external = forceExternal ?? Boolean(href && /^(?:[a-z][a-z0-9+.-]*:)?\/\//i.test(href));
1165
+ return React.createElement(
1166
+ "a",
1167
+ {
1168
+ ref,
1169
+ "data-sc-component": "text-link",
1170
+ "data-sc-primary": primary ? "" : void 0,
1171
+ "data-sc-recipe": recipe,
1172
+ "data-sc-underline": underline ? "" : void 0,
1173
+ href,
1174
+ rel: external && target === "_blank" ? mergeRel(rel, "noopener noreferrer") : rel,
1175
+ target,
1176
+ ...props
1177
+ },
1178
+ children
1179
+ );
1180
+ });
1181
+ var Image = React.forwardRef(function Image2({ forceRenderAfterLoadFail: _forceRenderAfterLoadFail, recipe = "auto", ...props }, ref) {
1182
+ return React.createElement("img", {
1183
+ ref,
1184
+ "data-sc-component": "image",
1185
+ "data-sc-recipe": recipe,
1186
+ ...props
1187
+ });
1188
+ });
1189
+ var Skeleton = React.forwardRef(function Skeleton2({ height, recipe = "auto", style, width, ...props }, ref) {
1190
+ return React.createElement("div", {
1191
+ ref,
1192
+ "aria-hidden": true,
1193
+ "data-sc-component": "skeleton",
1194
+ "data-sc-recipe": recipe,
1195
+ style: { width, height, ...style },
1196
+ ...props
1197
+ });
1198
+ });
1199
+ var FieldContext = React.createContext(null);
1200
+ function FormField({
1201
+ children,
1202
+ disabled = false,
1203
+ id,
1204
+ invalid = false,
1205
+ recipe = "auto",
1206
+ required = false,
1207
+ ...props
1208
+ }) {
1209
+ const generatedId = React.useId();
1210
+ const controlId = id ?? generatedId;
1211
+ const context = React.useMemo(
1212
+ () => ({
1213
+ controlId,
1214
+ descriptionId: `${controlId}-description`,
1215
+ disabled,
1216
+ errorId: `${controlId}-error`,
1217
+ invalid,
1218
+ required
1219
+ }),
1220
+ [controlId, disabled, invalid, required]
1221
+ );
1222
+ return React.createElement(
1223
+ FieldContext.Provider,
1224
+ { value: context },
1225
+ React.createElement(
1226
+ "div",
1227
+ {
1228
+ "data-sc-component": "form-field",
1229
+ "data-sc-disabled": disabled ? "" : void 0,
1230
+ "data-sc-invalid": invalid ? "" : void 0,
1231
+ "data-sc-recipe": recipe,
1232
+ ...props
1233
+ },
1234
+ children
1235
+ )
1236
+ );
1237
+ }
1238
+ var FieldLabel = React.forwardRef(function FieldLabel2({ children, htmlFor, recipe = "auto", ...props }, ref) {
1239
+ const field = React.useContext(FieldContext);
1240
+ return React.createElement(
1241
+ "label",
1242
+ {
1243
+ ref,
1244
+ htmlFor: htmlFor ?? field?.controlId,
1245
+ "data-sc-component": "field-label",
1246
+ "data-sc-recipe": recipe,
1247
+ ...props
1248
+ },
1249
+ children,
1250
+ field?.required ? React.createElement("span", { "aria-hidden": true, "data-sc-component": "field-required" }, "*") : null
1251
+ );
1252
+ });
1253
+ var FieldDescription = React.forwardRef(function FieldDescription2({ id, recipe = "auto", ...props }, ref) {
1254
+ const field = React.useContext(FieldContext);
1255
+ return React.createElement("p", {
1256
+ ref,
1257
+ id: id ?? field?.descriptionId,
1258
+ "data-sc-component": "field-description",
1259
+ "data-sc-recipe": recipe,
1260
+ ...props
1261
+ });
1262
+ });
1263
+ var FieldError = React.forwardRef(function FieldError2({ id, recipe = "auto", ...props }, ref) {
1264
+ const field = React.useContext(FieldContext);
1265
+ return React.createElement("p", {
1266
+ ref,
1267
+ id: id ?? field?.errorId,
1268
+ role: "alert",
1269
+ "data-sc-component": "field-error",
1270
+ "data-sc-recipe": recipe,
1271
+ ...props
1272
+ });
1273
+ });
1274
+ var Surface = React.forwardRef(function Surface2({ recipe = "auto", variant = "plain", ...props }, ref) {
1275
+ return React.createElement("div", {
1276
+ ref,
1277
+ "data-sc-component": "surface",
1278
+ "data-sc-recipe": recipe,
1279
+ "data-sc-variant": variant,
1280
+ ...props
1281
+ });
1282
+ });
1283
+ var Stack = React.forwardRef(function Stack2({ gap = "md", recipe = "auto", ...props }, ref) {
1284
+ return React.createElement("div", {
1285
+ ref,
1286
+ "data-sc-component": "stack",
1287
+ "data-sc-gap": gap,
1288
+ "data-sc-recipe": recipe,
1289
+ ...props
1290
+ });
1291
+ });
1292
+ var Inline = React.forwardRef(function Inline2({ align = "center", gap = "sm", recipe = "auto", wrap = true, ...props }, ref) {
1293
+ return React.createElement("div", {
1294
+ ref,
1295
+ "data-sc-align": align,
1296
+ "data-sc-component": "inline",
1297
+ "data-sc-gap": gap,
1298
+ "data-sc-recipe": recipe,
1299
+ "data-sc-wrap": wrap ? "" : void 0,
1300
+ ...props
1301
+ });
1302
+ });
1303
+ var Divider = React.forwardRef(function Divider2({ recipe = "auto", ...props }, ref) {
1304
+ return React.createElement("hr", {
1305
+ ref,
1306
+ "data-sc-component": "divider",
1307
+ "data-sc-recipe": recipe,
1308
+ ...props
1309
+ });
1310
+ });
1311
+ var Code = React.forwardRef(function Code2({ recipe = "auto", ...props }, ref) {
1312
+ return React.createElement("code", {
1313
+ ref,
1314
+ "data-sc-component": "code",
1315
+ "data-sc-recipe": recipe,
1316
+ ...props
1317
+ });
1318
+ });
1319
+ var Tabs = React.forwardRef(function Tabs2({ recipe = "auto", ...props }, ref) {
1320
+ return React.createElement("div", {
1321
+ ref,
1322
+ "data-sc-component": "tabs",
1323
+ "data-sc-recipe": recipe,
1324
+ ...props
1325
+ });
1326
+ });
1327
+ var Slider = React.forwardRef(function Slider2({ recipe = "auto", ...props }, ref) {
1328
+ return React.createElement("input", {
1329
+ ref,
1330
+ type: "range",
1331
+ "data-sc-component": "slider",
1332
+ "data-sc-recipe": recipe,
1333
+ ...props
1334
+ });
1335
+ });
1336
+ var Table = React.forwardRef(function Table2({ recipe = "auto", ...props }, ref) {
1337
+ return React.createElement("table", {
1338
+ ref,
1339
+ "data-sc-component": "table",
1340
+ "data-sc-recipe": recipe,
1341
+ ...props
1342
+ });
1343
+ });
1344
+ var KeyValue = React.forwardRef(function KeyValue2({ items, recipe = "auto", ...props }, ref) {
1345
+ return React.createElement(
1346
+ "dl",
1347
+ {
1348
+ ref,
1349
+ "data-sc-component": "key-value",
1350
+ "data-sc-recipe": recipe,
1351
+ ...props
1352
+ },
1353
+ items.map(
1354
+ (item, index) => React.createElement(
1355
+ "div",
1356
+ { "data-sc-component": "key-value-row", key: index },
1357
+ React.createElement("dt", null, item.key),
1358
+ React.createElement("dd", null, item.value)
1359
+ )
1360
+ )
1361
+ );
1362
+ });
1363
+ function createPrimitiveComponents(recipe) {
1364
+ return {
1365
+ Alert: pinRecipe(Alert, recipe),
1366
+ Avatar: pinRecipe(Avatar, recipe),
1367
+ AvatarGroup: pinRecipe(AvatarGroup, recipe),
1368
+ Badge: pinRecipe(Badge, recipe),
1369
+ Button: pinRecipe(Button, recipe),
1370
+ ButtonLink: pinRecipe(ButtonLink, recipe),
1371
+ Callout: pinRecipe(Callout, recipe),
1372
+ Checkbox: pinRecipe(Checkbox, recipe),
1373
+ CircularProgress: pinRecipe(CircularProgress, recipe),
1374
+ Code: pinRecipe(Code, recipe),
1375
+ CopyButton: pinRecipe(CopyButton, recipe),
1376
+ Divider: pinRecipe(Divider, recipe),
1377
+ EmptyMessage: pinRecipe(EmptyMessage, recipe),
1378
+ EmptyState: pinRecipe(EmptyState, recipe),
1379
+ FieldDescription: pinRecipe(FieldDescription, recipe),
1380
+ FieldError: pinRecipe(FieldError, recipe),
1381
+ FieldLabel: pinRecipe(FieldLabel, recipe),
1382
+ FormField: pinRecipe(FormField, recipe),
1383
+ Heading: pinRecipe(Heading, recipe),
1384
+ Image: pinRecipe(Image, recipe),
1385
+ Inline: pinRecipe(Inline, recipe),
1386
+ Input: pinRecipe(Input, recipe),
1387
+ KeyValue: pinRecipe(KeyValue, recipe),
1388
+ LoadingDots: pinRecipe(LoadingDots, recipe),
1389
+ LoadingIndicator: pinRecipe(LoadingIndicator, recipe),
1390
+ Progress: pinRecipe(Progress, recipe),
1391
+ RadioGroup: pinRecipe(RadioGroup, recipe),
1392
+ SegmentedControl: pinRecipe(SegmentedControl, recipe),
1393
+ Select: pinRecipe(Select, recipe),
1394
+ SelectControl: pinRecipe(SelectControl, recipe),
1395
+ ShimmerText: pinRecipe(ShimmerText, recipe),
1396
+ Skeleton: pinRecipe(Skeleton, recipe),
1397
+ Slider: pinRecipe(Slider, recipe),
1398
+ Spinner: pinRecipe(Spinner, recipe),
1399
+ Stack: pinRecipe(Stack, recipe),
1400
+ Surface: pinRecipe(Surface, recipe),
1401
+ Switch: pinRecipe(Switch, recipe),
1402
+ Table: pinRecipe(Table, recipe),
1403
+ Tabs: pinRecipe(Tabs, recipe),
1404
+ Text: pinRecipe(Text, recipe),
1405
+ Textarea: pinRecipe(Textarea, recipe),
1406
+ TextField: pinRecipe(TextField, recipe),
1407
+ TextLink: pinRecipe(TextLink, recipe)
1408
+ };
1409
+ }
1410
+ function normalizeButtonVisual({
1411
+ color,
1412
+ intent,
1413
+ variant
1414
+ }) {
1415
+ if (variant && isSemanticColor(variant)) {
1416
+ return { color: variant, variant: defaultVariantForColor(variant) };
1417
+ }
1418
+ if (variant === "ghost") {
1419
+ return { color: color ?? "secondary", variant: "ghost" };
1420
+ }
1421
+ if (intent === "ghost") {
1422
+ return { color: color ?? "secondary", variant: "ghost" };
1423
+ }
1424
+ const resolvedColor = color ?? (intent && isSemanticColor(intent) ? intent : "secondary");
1425
+ return { color: resolvedColor, variant: variant ?? defaultVariantForColor(resolvedColor) };
1426
+ }
1427
+ function defaultVariantForColor(color) {
1428
+ return color === "secondary" ? "soft" : "solid";
1429
+ }
1430
+ function isSemanticColor(value) {
1431
+ return ["primary", "secondary", "danger", "success", "warning", "caution", "discovery", "info"].includes(value);
1432
+ }
1433
+ function toneToColor(tone) {
1434
+ switch (tone) {
1435
+ case "success":
1436
+ return "success";
1437
+ case "warning":
1438
+ return "warning";
1439
+ case "danger":
1440
+ return "danger";
1441
+ case "default":
1442
+ case void 0:
1443
+ return void 0;
1444
+ }
1445
+ }
1446
+ function mergeRel(current, required) {
1447
+ return [.../* @__PURE__ */ new Set([...current?.split(/\s+/).filter(Boolean) ?? [], ...required.split(/\s+/)])].join(" ");
1448
+ }
1449
+ function useControllableValue({
1450
+ controlled,
1451
+ defaultValue,
1452
+ onChange
1453
+ }) {
1454
+ const [uncontrolled, setUncontrolled] = React.useState(defaultValue);
1455
+ const value = controlled ?? uncontrolled;
1456
+ const setValue = React.useCallback(
1457
+ (nextValue) => {
1458
+ if (controlled === void 0) {
1459
+ setUncontrolled(nextValue);
1460
+ }
1461
+ onChange?.(nextValue);
1462
+ },
1463
+ [controlled, onChange]
1464
+ );
1465
+ return [value, setValue];
1466
+ }
1467
+ function useRequiredContext(context, message) {
1468
+ const value = React.useContext(context);
1469
+ if (value === null) {
1470
+ throw new Error(message);
1471
+ }
1472
+ return value;
1473
+ }
1474
+ function useMergedRefs(...refs) {
1475
+ return React.useCallback(
1476
+ (node) => {
1477
+ for (const ref of refs) {
1478
+ if (!ref) {
1479
+ continue;
1480
+ }
1481
+ if (typeof ref === "function") {
1482
+ ref(node);
1483
+ } else {
1484
+ ref.current = node;
1485
+ }
1486
+ }
1487
+ },
1488
+ [refs]
1489
+ );
1490
+ }
1491
+ function describedBy(existing, field, invalid) {
1492
+ const ids = [existing, field?.descriptionId, invalid ? field?.errorId : void 0].filter(Boolean);
1493
+ return ids.length ? ids.join(" ") : void 0;
1494
+ }
1495
+ function flattenOptions(options) {
1496
+ return options.flatMap((entry) => isOptionGroup(entry) ? entry.options : [entry]);
1497
+ }
1498
+ function isOptionGroup(entry) {
1499
+ return Array.isArray(entry.options);
1500
+ }
1501
+ function defaultSearchPredicate(option, searchTerm) {
1502
+ if (!searchTerm) {
1503
+ return true;
1504
+ }
1505
+ return `${option.label} ${option.description ?? ""}`.toLowerCase().includes(searchTerm.toLowerCase());
1506
+ }
1507
+ function renderSelectTriggerContent({
1508
+ loading,
1509
+ loadingPlaceholder,
1510
+ multiple,
1511
+ placeholder,
1512
+ selected,
1513
+ selectedOptions,
1514
+ TriggerView
1515
+ }) {
1516
+ if (loading && selectedOptions.length === 0) {
1517
+ return loadingPlaceholder;
1518
+ }
1519
+ if (TriggerView) {
1520
+ const View = TriggerView;
1521
+ return multiple ? React.createElement(View, {
1522
+ selectedAll: false,
1523
+ values: selectedOptions
1524
+ }) : selected ? React.createElement(View, selected) : placeholder;
1525
+ }
1526
+ if (multiple) {
1527
+ return selectedOptions.length ? `${selectedOptions.length} selected` : placeholder;
1528
+ }
1529
+ return selected?.label || placeholder;
1530
+ }
1531
+ function renderHiddenSelectInputs({
1532
+ disabled,
1533
+ multiple,
1534
+ name,
1535
+ required,
1536
+ selectedOptions,
1537
+ value
1538
+ }) {
1539
+ if (multiple) {
1540
+ return selectedOptions.map(
1541
+ (option) => React.createElement("input", {
1542
+ disabled,
1543
+ key: option.value,
1544
+ name,
1545
+ readOnly: true,
1546
+ required,
1547
+ type: "hidden",
1548
+ value: option.value
1549
+ })
1550
+ );
1551
+ }
1552
+ return React.createElement("input", {
1553
+ disabled,
1554
+ name,
1555
+ readOnly: true,
1556
+ required,
1557
+ type: "hidden",
1558
+ value: Array.isArray(value) ? "" : value
1559
+ });
1560
+ }
1561
+ function initialsFromName(name) {
1562
+ if (!name) {
1563
+ return null;
1564
+ }
1565
+ const initials = name.trim().split(/\s+/).slice(0, 2).map((part) => part[0]?.toUpperCase()).join("");
1566
+ return initials || null;
1567
+ }
1568
+ function formatOverflow(count) {
1569
+ return count > 99 ? "99+" : `+${count}`;
1570
+ }
1571
+ async function copyToClipboard(value) {
1572
+ if (typeof navigator !== "undefined" && navigator.clipboard?.writeText) {
1573
+ await navigator.clipboard.writeText(typeof value === "string" ? value : Object.values(value).join("\n"));
1574
+ }
1575
+ }
1576
+ function pinRecipe(Component, recipe) {
1577
+ const ComponentWithRecipe = Component;
1578
+ const Wrapped = ((props) => React.createElement(ComponentWithRecipe, { ...props, recipe }));
1579
+ Object.assign(Wrapped, Component);
1580
+ return Wrapped;
1581
+ }
1582
+ export {
1583
+ Alert,
1584
+ Avatar,
1585
+ AvatarGroup,
1586
+ Badge,
1587
+ Button,
1588
+ ButtonLink,
1589
+ Callout,
1590
+ Checkbox,
1591
+ CircularProgress,
1592
+ Code,
1593
+ CopyButton,
1594
+ Divider,
1595
+ EmptyMessage,
1596
+ EmptyState,
1597
+ FieldDescription,
1598
+ FieldError,
1599
+ FieldLabel,
1600
+ FormField,
1601
+ Heading,
1602
+ Image,
1603
+ Inline,
1604
+ Input,
1605
+ KeyValue,
1606
+ LoadingDots,
1607
+ LoadingIndicator,
1608
+ Progress,
1609
+ RadioGroup,
1610
+ SegmentedControl,
1611
+ Select,
1612
+ SelectControl,
1613
+ ShimmerText,
1614
+ Skeleton,
1615
+ Slider,
1616
+ Spinner,
1617
+ Stack,
1618
+ Surface,
1619
+ Switch,
1620
+ Table,
1621
+ Tabs,
1622
+ Text,
1623
+ TextField,
1624
+ TextLink,
1625
+ Textarea,
1626
+ createPrimitiveComponents
1627
+ };
1628
+ //# sourceMappingURL=index.js.map