@vantageos/mosaic 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +39 -15
- package/README.md +114 -5
- package/dist/PipelineBoard-FucyGArR.d.cts +759 -0
- package/dist/PipelineBoard-FucyGArR.d.ts +759 -0
- package/dist/PipelineBoard.markdown-DIcvrS-2.d.cts +16 -0
- package/dist/PipelineBoard.markdown-DIcvrS-2.d.ts +16 -0
- package/dist/{StatusBadge.schema-1tOjB4Ir.d.cts → StatusBadge.schema-BEjSH2_4.d.cts} +2 -2
- package/dist/{StatusBadge.schema-1tOjB4Ir.d.ts → StatusBadge.schema-BEjSH2_4.d.ts} +2 -2
- package/dist/{Tabs.schema-BzcEyeq8.d.cts → Tabs.schema-Dqr6vwV3.d.cts} +2 -2
- package/dist/{Tabs.schema-BzcEyeq8.d.ts → Tabs.schema-Dqr6vwV3.d.ts} +2 -2
- package/dist/Timeline-Coo_3tA_.d.cts +114 -0
- package/dist/Timeline-Coo_3tA_.d.ts +114 -0
- package/dist/Timeline.markdown-C6UPDv1H.d.cts +4 -0
- package/dist/Timeline.markdown-C6UPDv1H.d.ts +4 -0
- package/dist/TransactionPreview-BzWDn8kE.d.cts +391 -0
- package/dist/TransactionPreview-BzWDn8kE.d.ts +391 -0
- package/dist/TransactionPreview.markdown-Dpb0VYgN.d.cts +7 -0
- package/dist/TransactionPreview.markdown-Dpb0VYgN.d.ts +7 -0
- package/dist/artifacts.cjs +186 -2
- package/dist/artifacts.cjs.map +1 -1
- package/dist/artifacts.js +186 -2
- package/dist/artifacts.js.map +1 -1
- package/dist/confirmation.cjs +724 -2
- package/dist/confirmation.cjs.map +1 -1
- package/dist/confirmation.d.cts +2 -1
- package/dist/confirmation.d.ts +2 -1
- package/dist/confirmation.js +722 -4
- package/dist/confirmation.js.map +1 -1
- package/dist/display.cjs +1551 -203
- package/dist/display.cjs.map +1 -1
- package/dist/display.d.cts +6 -229
- package/dist/display.d.ts +6 -229
- package/dist/display.js +1535 -206
- package/dist/display.js.map +1 -1
- package/dist/forms.cjs +139 -46
- package/dist/forms.cjs.map +1 -1
- package/dist/forms.d.cts +2 -2
- package/dist/forms.d.ts +2 -2
- package/dist/forms.js +139 -46
- package/dist/forms.js.map +1 -1
- package/dist/host.cjs +822 -0
- package/dist/host.cjs.map +1 -0
- package/dist/host.d.cts +287 -0
- package/dist/host.d.ts +287 -0
- package/dist/host.js +794 -0
- package/dist/host.js.map +1 -0
- package/dist/{index-CwXVgtGb.d.cts → index-BadRcCbm.d.cts} +28 -11
- package/dist/{index-CwXVgtGb.d.ts → index-BadRcCbm.d.ts} +28 -11
- package/dist/index.cjs +2198 -247
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +42 -8
- package/dist/index.d.ts +42 -8
- package/dist/index.js +2163 -251
- package/dist/index.js.map +1 -1
- package/dist/input.d.cts +2 -2
- package/dist/input.d.ts +2 -2
- package/dist/media.cjs +186 -2
- package/dist/media.cjs.map +1 -1
- package/dist/media.d.cts +1 -1
- package/dist/media.d.ts +1 -1
- package/dist/media.js +186 -2
- package/dist/media.js.map +1 -1
- package/dist/preact/artifacts.js +186 -2
- package/dist/preact/artifacts.js.map +1 -1
- package/dist/preact/confirmation.d.ts +321 -1
- package/dist/preact/confirmation.js +625 -4
- package/dist/preact/confirmation.js.map +1 -1
- package/dist/preact/display.d.ts +544 -47
- package/dist/preact/display.js +1190 -126
- package/dist/preact/display.js.map +1 -1
- package/dist/preact/forms.d.ts +32 -15
- package/dist/preact/forms.js +139 -46
- package/dist/preact/forms.js.map +1 -1
- package/dist/preact/host.d.ts +307 -0
- package/dist/preact/host.js +875 -0
- package/dist/preact/host.js.map +1 -0
- package/dist/preact/media.d.ts +37 -1
- package/dist/preact/media.js +423 -0
- package/dist/preact/media.js.map +1 -1
- package/dist/preact/progress.d.ts +92 -1
- package/dist/preact/progress.js +465 -3
- package/dist/preact/progress.js.map +1 -1
- package/dist/progress.cjs +521 -2
- package/dist/progress.cjs.map +1 -1
- package/dist/progress.d.cts +2 -1
- package/dist/progress.d.ts +2 -1
- package/dist/progress.js +518 -3
- package/dist/progress.js.map +1 -1
- package/dist/react/artifacts.cjs +186 -2
- package/dist/react/artifacts.cjs.map +1 -1
- package/dist/react/artifacts.js +186 -2
- package/dist/react/artifacts.js.map +1 -1
- package/dist/react/confirmation.cjs +626 -2
- package/dist/react/confirmation.cjs.map +1 -1
- package/dist/react/confirmation.d.cts +3 -3
- package/dist/react/confirmation.d.ts +3 -3
- package/dist/react/confirmation.js +625 -4
- package/dist/react/confirmation.js.map +1 -1
- package/dist/react/display.cjs +1076 -123
- package/dist/react/display.cjs.map +1 -1
- package/dist/react/display.d.cts +13 -27
- package/dist/react/display.d.ts +13 -27
- package/dist/react/display.js +1064 -126
- package/dist/react/display.js.map +1 -1
- package/dist/react/forms.cjs +139 -46
- package/dist/react/forms.cjs.map +1 -1
- package/dist/react/forms.d.cts +1 -1
- package/dist/react/forms.d.ts +1 -1
- package/dist/react/forms.js +139 -46
- package/dist/react/forms.js.map +1 -1
- package/dist/react/host.cjs +910 -0
- package/dist/react/host.cjs.map +1 -0
- package/dist/react/host.d.cts +24 -0
- package/dist/react/host.d.ts +24 -0
- package/dist/react/host.js +875 -0
- package/dist/react/host.js.map +1 -0
- package/dist/react/input.d.cts +1 -1
- package/dist/react/input.d.ts +1 -1
- package/dist/react/media.cjs +426 -0
- package/dist/react/media.cjs.map +1 -1
- package/dist/react/media.d.cts +19 -1
- package/dist/react/media.d.ts +19 -1
- package/dist/react/media.js +423 -0
- package/dist/react/media.js.map +1 -1
- package/dist/react/progress.cjs +467 -2
- package/dist/react/progress.cjs.map +1 -1
- package/dist/react/progress.d.cts +1 -1
- package/dist/react/progress.d.ts +1 -1
- package/dist/react/progress.js +465 -3
- package/dist/react/progress.js.map +1 -1
- package/dist/server/resource.cjs +151 -0
- package/dist/server/resource.cjs.map +1 -0
- package/dist/server/resource.d.cts +90 -0
- package/dist/server/resource.d.ts +90 -0
- package/dist/server/resource.js +147 -0
- package/dist/server/resource.js.map +1 -0
- package/dist/server.cjs +1100 -25
- package/dist/server.cjs.map +1 -1
- package/dist/server.d.cts +84 -5
- package/dist/server.d.ts +84 -5
- package/dist/server.js +1087 -27
- package/dist/server.js.map +1 -1
- package/package.json +250 -233
- package/registry.yaml +44 -2
- package/dist/Alert.schema-LPJE5gFP.d.cts +0 -71
- package/dist/Alert.schema-LPJE5gFP.d.ts +0 -71
- package/dist/ProgressBar.schema-CdVYx0Wq.d.cts +0 -22
- package/dist/ProgressBar.schema-CdVYx0Wq.d.ts +0 -22
- package/dist/{ConfirmDialog-B3CQQGmJ.d.cts → ConfirmDialog-BCtOcmHe.d.cts} +1 -1
- package/dist/{ConfirmDialog-B3CQQGmJ.d.ts → ConfirmDialog-BCtOcmHe.d.ts} +1 -1
package/dist/preact/forms.d.ts
CHANGED
|
@@ -373,6 +373,8 @@ declare const MultiSelectPropsSchema: z.ZodObject<{
|
|
|
373
373
|
disabled: z.ZodOptional<z.ZodBoolean>;
|
|
374
374
|
searchable: z.ZodOptional<z.ZodBoolean>;
|
|
375
375
|
maxItems: z.ZodOptional<z.ZodNumber>;
|
|
376
|
+
/** `chips`: every option is a visible toggle button (aria-pressed), no dropdown. */
|
|
377
|
+
appearance: z.ZodDefault<z.ZodEnum<["default", "chips"]>>;
|
|
376
378
|
}, "strip", z.ZodTypeAny, {
|
|
377
379
|
options: {
|
|
378
380
|
value: string;
|
|
@@ -380,6 +382,7 @@ declare const MultiSelectPropsSchema: z.ZodObject<{
|
|
|
380
382
|
}[];
|
|
381
383
|
name: string;
|
|
382
384
|
label: string;
|
|
385
|
+
appearance: "default" | "chips";
|
|
383
386
|
disabled?: boolean | undefined;
|
|
384
387
|
placeholder?: string | undefined;
|
|
385
388
|
searchable?: boolean | undefined;
|
|
@@ -395,6 +398,7 @@ declare const MultiSelectPropsSchema: z.ZodObject<{
|
|
|
395
398
|
placeholder?: string | undefined;
|
|
396
399
|
searchable?: boolean | undefined;
|
|
397
400
|
maxItems?: number | undefined;
|
|
401
|
+
appearance?: "default" | "chips" | undefined;
|
|
398
402
|
}>;
|
|
399
403
|
type MultiSelectOption = z.infer<typeof MultiSelectOptionSchema>;
|
|
400
404
|
|
|
@@ -406,6 +410,8 @@ interface MultiSelectProps {
|
|
|
406
410
|
disabled?: boolean;
|
|
407
411
|
searchable?: boolean;
|
|
408
412
|
maxItems?: number;
|
|
413
|
+
/** `chips`: every option is a visible toggle button (aria-pressed), no dropdown. */
|
|
414
|
+
appearance?: "default" | "chips";
|
|
409
415
|
className?: string;
|
|
410
416
|
}
|
|
411
417
|
/**
|
|
@@ -428,6 +434,8 @@ interface RadioGroupProps {
|
|
|
428
434
|
}>;
|
|
429
435
|
orientation?: "vertical" | "horizontal";
|
|
430
436
|
disabled?: boolean;
|
|
437
|
+
/** `segmented` / `chips`: always-visible options; same radiogroup semantics. */
|
|
438
|
+
appearance?: "default" | "segmented" | "chips";
|
|
431
439
|
className?: string;
|
|
432
440
|
}
|
|
433
441
|
/**
|
|
@@ -733,13 +741,13 @@ declare const RadioGroupOptionSchema: z.ZodObject<{
|
|
|
733
741
|
description: z.ZodOptional<z.ZodString>;
|
|
734
742
|
disabled: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
735
743
|
}, "strip", z.ZodTypeAny, {
|
|
744
|
+
label: string;
|
|
736
745
|
value: string;
|
|
737
746
|
disabled: boolean;
|
|
738
|
-
label: string;
|
|
739
747
|
description?: string | undefined;
|
|
740
748
|
}, {
|
|
741
|
-
value: string;
|
|
742
749
|
label: string;
|
|
750
|
+
value: string;
|
|
743
751
|
description?: string | undefined;
|
|
744
752
|
disabled?: boolean | undefined;
|
|
745
753
|
}>;
|
|
@@ -753,43 +761,51 @@ declare const RadioGroupPropsSchema: z.ZodObject<{
|
|
|
753
761
|
description: z.ZodOptional<z.ZodString>;
|
|
754
762
|
disabled: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
755
763
|
}, "strip", z.ZodTypeAny, {
|
|
764
|
+
label: string;
|
|
756
765
|
value: string;
|
|
757
766
|
disabled: boolean;
|
|
758
|
-
label: string;
|
|
759
767
|
description?: string | undefined;
|
|
760
768
|
}, {
|
|
761
|
-
value: string;
|
|
762
769
|
label: string;
|
|
770
|
+
value: string;
|
|
763
771
|
description?: string | undefined;
|
|
764
772
|
disabled?: boolean | undefined;
|
|
765
773
|
}>, "many">;
|
|
766
774
|
orientation: z.ZodDefault<z.ZodEnum<["vertical", "horizontal"]>>;
|
|
775
|
+
/**
|
|
776
|
+
* `segmented` / `chips` render the options as always-visible controls (Claude design
|
|
777
|
+
* guidelines prefer visible options over menus, which clip inside the iframe). The ARIA
|
|
778
|
+
* radiogroup semantics are identical in every appearance.
|
|
779
|
+
*/
|
|
780
|
+
appearance: z.ZodDefault<z.ZodEnum<["default", "segmented", "chips"]>>;
|
|
767
781
|
disabled: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
768
782
|
locale: z.ZodDefault<z.ZodEnum<["en", "fr"]>>;
|
|
769
783
|
}, "strip", z.ZodTypeAny, {
|
|
784
|
+
label: string;
|
|
770
785
|
options: {
|
|
786
|
+
label: string;
|
|
771
787
|
value: string;
|
|
772
788
|
disabled: boolean;
|
|
773
|
-
label: string;
|
|
774
789
|
description?: string | undefined;
|
|
775
790
|
}[];
|
|
776
|
-
disabled: boolean;
|
|
777
|
-
name: string;
|
|
778
|
-
label: string;
|
|
779
|
-
orientation: "vertical" | "horizontal";
|
|
780
791
|
locale: "en" | "fr";
|
|
792
|
+
appearance: "default" | "segmented" | "chips";
|
|
793
|
+
name: string;
|
|
794
|
+
disabled: boolean;
|
|
795
|
+
orientation: "horizontal" | "vertical";
|
|
781
796
|
}, {
|
|
797
|
+
label: string;
|
|
782
798
|
options: {
|
|
783
|
-
value: string;
|
|
784
799
|
label: string;
|
|
800
|
+
value: string;
|
|
785
801
|
description?: string | undefined;
|
|
786
802
|
disabled?: boolean | undefined;
|
|
787
803
|
}[];
|
|
788
804
|
name: string;
|
|
789
|
-
label: string;
|
|
790
|
-
disabled?: boolean | undefined;
|
|
791
|
-
orientation?: "vertical" | "horizontal" | undefined;
|
|
792
805
|
locale?: "en" | "fr" | undefined;
|
|
806
|
+
appearance?: "default" | "segmented" | "chips" | undefined;
|
|
807
|
+
disabled?: boolean | undefined;
|
|
808
|
+
orientation?: "horizontal" | "vertical" | undefined;
|
|
793
809
|
}>;
|
|
794
810
|
type RadioGroupPropsValidated = z.infer<typeof RadioGroupPropsSchema>;
|
|
795
811
|
declare function validateRadioGroupProps(raw: unknown): RadioGroupPropsValidated;
|
|
@@ -864,9 +880,10 @@ declare function getOptionLabelId(instanceId: string, name: string, optionValue:
|
|
|
864
880
|
/** Stable DOM id for an option description span (linked by radio aria-describedby). */
|
|
865
881
|
declare function getOptionDescriptionId(instanceId: string, name: string, optionValue: string): string;
|
|
866
882
|
/** Tailwind classes for the root radiogroup container. */
|
|
867
|
-
|
|
883
|
+
type RadioAppearance = "default" | "segmented" | "chips";
|
|
884
|
+
declare function getGroupClasses(orientation: RadioOrientation, appearance?: RadioAppearance): string;
|
|
868
885
|
/** Tailwind classes for a single radio row (label + control + description). */
|
|
869
|
-
declare function getOptionRowClasses(isDisabled: boolean, orientation: RadioOrientation): string;
|
|
886
|
+
declare function getOptionRowClasses(isDisabled: boolean, orientation: RadioOrientation, appearance?: RadioAppearance): string;
|
|
870
887
|
/** Tailwind classes for the visible radio control (the round dot). */
|
|
871
888
|
declare function getRadioControlClasses(isSelected: boolean, isDisabled: boolean): string;
|
|
872
889
|
/** Whether a keyboard event should activate the focused radio (Space / Enter). */
|
package/dist/preact/forms.js
CHANGED
|
@@ -512,7 +512,9 @@ var MultiSelectPropsSchema = z.object({
|
|
|
512
512
|
placeholder: z.string().optional(),
|
|
513
513
|
disabled: z.boolean().optional(),
|
|
514
514
|
searchable: z.boolean().optional(),
|
|
515
|
-
maxItems: z.number().int().positive().optional()
|
|
515
|
+
maxItems: z.number().int().positive().optional(),
|
|
516
|
+
/** `chips`: every option is a visible toggle button (aria-pressed), no dropdown. */
|
|
517
|
+
appearance: z.enum(["default", "chips"]).default("default")
|
|
516
518
|
});
|
|
517
519
|
function MultiSelect(props) {
|
|
518
520
|
const parsed = MultiSelectPropsSchema.parse({
|
|
@@ -522,15 +524,32 @@ function MultiSelect(props) {
|
|
|
522
524
|
placeholder: props.placeholder,
|
|
523
525
|
disabled: props.disabled,
|
|
524
526
|
searchable: props.searchable,
|
|
525
|
-
maxItems: props.maxItems
|
|
527
|
+
maxItems: props.maxItems,
|
|
528
|
+
appearance: props.appearance
|
|
526
529
|
});
|
|
527
|
-
const { name, label, options, placeholder, disabled, searchable, maxItems } = parsed;
|
|
530
|
+
const { name, label, options, placeholder, disabled, searchable, maxItems, appearance } = parsed;
|
|
528
531
|
const reactId = useId();
|
|
529
532
|
const triggerId = `${reactId}-trigger`;
|
|
530
533
|
const listboxId = `${reactId}-listbox`;
|
|
531
534
|
const labelId = `${reactId}-label`;
|
|
532
535
|
return /* @__PURE__ */ jsx(FormField, { name, children: ({ field }) => {
|
|
533
536
|
const value = Array.isArray(field.value) ? field.value : [];
|
|
537
|
+
if (appearance === "chips") {
|
|
538
|
+
return /* @__PURE__ */ jsx(
|
|
539
|
+
ChipToggles,
|
|
540
|
+
{
|
|
541
|
+
labelId,
|
|
542
|
+
label,
|
|
543
|
+
options,
|
|
544
|
+
value,
|
|
545
|
+
disabled,
|
|
546
|
+
maxItems,
|
|
547
|
+
onChange: (next) => field.onChange(next),
|
|
548
|
+
onBlur: () => field.onBlur(),
|
|
549
|
+
className: props.className
|
|
550
|
+
}
|
|
551
|
+
);
|
|
552
|
+
}
|
|
534
553
|
return /* @__PURE__ */ jsx(
|
|
535
554
|
Inner,
|
|
536
555
|
{
|
|
@@ -551,6 +570,39 @@ function MultiSelect(props) {
|
|
|
551
570
|
);
|
|
552
571
|
} });
|
|
553
572
|
}
|
|
573
|
+
function ChipToggles(p) {
|
|
574
|
+
const atMax = isAtMaxItems(p.value, p.maxItems);
|
|
575
|
+
return /* @__PURE__ */ jsxs(
|
|
576
|
+
"fieldset",
|
|
577
|
+
{
|
|
578
|
+
"aria-labelledby": p.labelId,
|
|
579
|
+
"data-appearance": "chips",
|
|
580
|
+
className: `m-0 min-w-0 border-0 p-0 ${p.className ?? "mosaic-multiselect mosaic-multiselect--chips"}`,
|
|
581
|
+
onBlur: p.onBlur,
|
|
582
|
+
children: [
|
|
583
|
+
/* @__PURE__ */ jsx("span", { id: p.labelId, className: "mosaic-multiselect-label", children: p.label }),
|
|
584
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-row flex-wrap gap-2", children: p.options.map((opt) => {
|
|
585
|
+
const on = p.value.includes(opt.value);
|
|
586
|
+
return /* @__PURE__ */ jsx(
|
|
587
|
+
"button",
|
|
588
|
+
{
|
|
589
|
+
type: "button",
|
|
590
|
+
"aria-pressed": on,
|
|
591
|
+
disabled: p.disabled || !on && atMax,
|
|
592
|
+
"data-chip-value": opt.value,
|
|
593
|
+
className: `mosaic-multiselect-chip inline-flex items-center rounded-full border px-3 py-1 text-sm ${on ? "border-slate-900 bg-slate-900 text-white" : "border-slate-300 bg-white text-slate-700 hover:bg-slate-50"} disabled:cursor-not-allowed disabled:opacity-50`,
|
|
594
|
+
onClick: () => p.onChange(
|
|
595
|
+
on ? removeValue(p.value, opt.value) : addValue(p.value, opt.value, p.maxItems)
|
|
596
|
+
),
|
|
597
|
+
children: opt.label
|
|
598
|
+
},
|
|
599
|
+
opt.value
|
|
600
|
+
);
|
|
601
|
+
}) })
|
|
602
|
+
]
|
|
603
|
+
}
|
|
604
|
+
);
|
|
605
|
+
}
|
|
554
606
|
function Inner(p) {
|
|
555
607
|
const [open, setOpen] = useState(false);
|
|
556
608
|
const [query, setQuery] = useState("");
|
|
@@ -761,10 +813,21 @@ function getOptionLabelId(instanceId, name, optionValue) {
|
|
|
761
813
|
function getOptionDescriptionId(instanceId, name, optionValue) {
|
|
762
814
|
return `${instanceId}-${name}-${optionValue}-desc`;
|
|
763
815
|
}
|
|
764
|
-
function getGroupClasses(orientation) {
|
|
816
|
+
function getGroupClasses(orientation, appearance = "default") {
|
|
817
|
+
if (appearance === "segmented") {
|
|
818
|
+
return "inline-flex flex-row overflow-hidden rounded-md border border-slate-300";
|
|
819
|
+
}
|
|
820
|
+
if (appearance === "chips") return "flex flex-row flex-wrap gap-2";
|
|
765
821
|
return orientation === "vertical" ? "flex flex-col gap-2" : "flex flex-row flex-wrap gap-4";
|
|
766
822
|
}
|
|
767
|
-
function getOptionRowClasses(isDisabled, orientation) {
|
|
823
|
+
function getOptionRowClasses(isDisabled, orientation, appearance = "default") {
|
|
824
|
+
const state0 = isDisabled ? "opacity-50 cursor-not-allowed" : "cursor-pointer";
|
|
825
|
+
if (appearance !== "default") {
|
|
826
|
+
return [
|
|
827
|
+
"relative inline-flex items-center focus-within:outline focus-within:outline-2 focus-within:outline-blue-600",
|
|
828
|
+
state0
|
|
829
|
+
].join(" ");
|
|
830
|
+
}
|
|
768
831
|
const base = "flex items-start gap-2";
|
|
769
832
|
const orient = orientation === "vertical" ? "flex-row" : "flex-row";
|
|
770
833
|
const state = isDisabled ? "opacity-50 cursor-not-allowed" : "cursor-pointer";
|
|
@@ -778,6 +841,13 @@ function getRadioControlClasses(isSelected, isDisabled) {
|
|
|
778
841
|
function isActivationKey(key) {
|
|
779
842
|
return key === " " || key === "Space" || key === "Enter";
|
|
780
843
|
}
|
|
844
|
+
function getOptionLabelClasses(appearance, isSelected) {
|
|
845
|
+
if (appearance === "default") return "mosaic-forms-radiogroup-option-label";
|
|
846
|
+
const base = "mosaic-forms-radiogroup-option-label inline-flex items-center px-3 py-1 text-sm";
|
|
847
|
+
const shape = appearance === "chips" ? "rounded-full border" : "";
|
|
848
|
+
const tone = isSelected ? "bg-slate-900 text-white border-slate-900" : "bg-white text-slate-700 border-slate-300 hover:bg-slate-50";
|
|
849
|
+
return [base, shape, tone].filter(Boolean).join(" ");
|
|
850
|
+
}
|
|
781
851
|
var RadioGroupOptionSchema = z.object({
|
|
782
852
|
value: z.string().min(1),
|
|
783
853
|
label: z.string().min(1),
|
|
@@ -789,6 +859,12 @@ var RadioGroupPropsSchema = z.object({
|
|
|
789
859
|
label: z.string().min(1),
|
|
790
860
|
options: z.array(RadioGroupOptionSchema).min(1),
|
|
791
861
|
orientation: z.enum(["vertical", "horizontal"]).default("vertical"),
|
|
862
|
+
/**
|
|
863
|
+
* `segmented` / `chips` render the options as always-visible controls (Claude design
|
|
864
|
+
* guidelines prefer visible options over menus, which clip inside the iframe). The ARIA
|
|
865
|
+
* radiogroup semantics are identical in every appearance.
|
|
866
|
+
*/
|
|
867
|
+
appearance: z.enum(["default", "segmented", "chips"]).default("default"),
|
|
792
868
|
disabled: z.boolean().optional().default(false),
|
|
793
869
|
locale: z.enum(["en", "fr"]).default("en")
|
|
794
870
|
});
|
|
@@ -801,9 +877,10 @@ function RadioGroup(props) {
|
|
|
801
877
|
label: props.label,
|
|
802
878
|
options: props.options,
|
|
803
879
|
orientation: props.orientation,
|
|
804
|
-
disabled: props.disabled
|
|
880
|
+
disabled: props.disabled,
|
|
881
|
+
appearance: props.appearance
|
|
805
882
|
});
|
|
806
|
-
const { name, label, options, orientation, disabled } = validated;
|
|
883
|
+
const { name, label, options, orientation, disabled, appearance } = validated;
|
|
807
884
|
const instanceId = useId();
|
|
808
885
|
const groupLabelId = getGroupLabelId(instanceId, name);
|
|
809
886
|
const { prev: prevKey, next: nextKey } = getNavKeys(orientation);
|
|
@@ -858,51 +935,67 @@ function RadioGroup(props) {
|
|
|
858
935
|
"aria-labelledby": groupLabelId,
|
|
859
936
|
"aria-orientation": orientation,
|
|
860
937
|
"aria-disabled": disabled || void 0,
|
|
861
|
-
|
|
938
|
+
"data-appearance": appearance === "default" ? void 0 : appearance,
|
|
939
|
+
className: getGroupClasses(orientation, appearance),
|
|
862
940
|
children: options.map((option, index) => {
|
|
863
941
|
const isSelected = selectedValue === option.value;
|
|
864
942
|
const isDisabled = !!(disabled || option.disabled);
|
|
865
943
|
const optLabelId = getOptionLabelId(instanceId, name, option.value);
|
|
866
944
|
const optDescId = option.description ? getOptionDescriptionId(instanceId, name, option.value) : void 0;
|
|
867
945
|
const tabIdx = index === rovingIdx ? 0 : -1;
|
|
868
|
-
return /* @__PURE__ */ jsxs(
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
{
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
946
|
+
return /* @__PURE__ */ jsxs(
|
|
947
|
+
"div",
|
|
948
|
+
{
|
|
949
|
+
className: getOptionRowClasses(isDisabled, orientation, appearance),
|
|
950
|
+
children: [
|
|
951
|
+
/* @__PURE__ */ jsx(
|
|
952
|
+
"input",
|
|
953
|
+
{
|
|
954
|
+
ref: (el) => {
|
|
955
|
+
radioRefs.current[index] = el;
|
|
956
|
+
},
|
|
957
|
+
type: "radio",
|
|
958
|
+
id: `${instanceId}-${name}-${option.value}`,
|
|
959
|
+
name: field.name,
|
|
960
|
+
value: option.value,
|
|
961
|
+
checked: isSelected,
|
|
962
|
+
disabled: isDisabled,
|
|
963
|
+
"aria-labelledby": optLabelId,
|
|
964
|
+
"aria-describedby": optDescId,
|
|
965
|
+
tabIndex: isDisabled ? -1 : tabIdx,
|
|
966
|
+
className: "mosaic-forms-radiogroup-input sr-only",
|
|
967
|
+
onChange: () => {
|
|
968
|
+
field.onChange(option.value);
|
|
969
|
+
},
|
|
970
|
+
onKeyDown: (e) => {
|
|
971
|
+
if (!isDisabled) handleKeyDown(e, index);
|
|
972
|
+
},
|
|
973
|
+
onBlur: field.onBlur
|
|
974
|
+
}
|
|
975
|
+
),
|
|
976
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-0.5", children: [
|
|
977
|
+
/* @__PURE__ */ jsx(
|
|
978
|
+
"span",
|
|
979
|
+
{
|
|
980
|
+
id: optLabelId,
|
|
981
|
+
"data-selected": isSelected ? "true" : void 0,
|
|
982
|
+
className: getOptionLabelClasses(appearance, isSelected),
|
|
983
|
+
children: option.label
|
|
984
|
+
}
|
|
985
|
+
),
|
|
986
|
+
option.description ? /* @__PURE__ */ jsx(
|
|
987
|
+
"span",
|
|
988
|
+
{
|
|
989
|
+
id: optDescId,
|
|
990
|
+
className: "mosaic-forms-radiogroup-option-description text-sm text-slate-500",
|
|
991
|
+
children: option.description
|
|
992
|
+
}
|
|
993
|
+
) : null
|
|
994
|
+
] })
|
|
995
|
+
]
|
|
996
|
+
},
|
|
997
|
+
option.value
|
|
998
|
+
);
|
|
906
999
|
})
|
|
907
1000
|
}
|
|
908
1001
|
),
|