@vantageos/mosaic 0.3.1 → 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 +88 -2
- package/LICENSE +110 -0
- package/README.md +193 -21
- 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 +190 -2
- package/dist/artifacts.cjs.map +1 -1
- package/dist/artifacts.js +190 -2
- package/dist/artifacts.js.map +1 -1
- package/dist/confirmation.cjs +728 -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 +726 -4
- package/dist/confirmation.js.map +1 -1
- package/dist/display.cjs +1555 -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 +1539 -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 +2202 -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 +2167 -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 +190 -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 +190 -2
- package/dist/media.js.map +1 -1
- package/dist/preact/artifacts.js +190 -2
- package/dist/preact/artifacts.js.map +1 -1
- package/dist/preact/confirmation.d.ts +321 -1
- package/dist/preact/confirmation.js +629 -4
- package/dist/preact/confirmation.js.map +1 -1
- package/dist/preact/display.d.ts +570 -31
- package/dist/preact/display.js +1248 -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 +469 -3
- package/dist/preact/progress.js.map +1 -1
- package/dist/progress.cjs +525 -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 +522 -3
- package/dist/progress.js.map +1 -1
- package/dist/react/artifacts.cjs +190 -2
- package/dist/react/artifacts.cjs.map +1 -1
- package/dist/react/artifacts.js +190 -2
- package/dist/react/artifacts.js.map +1 -1
- package/dist/react/confirmation.cjs +630 -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 +629 -4
- package/dist/react/confirmation.js.map +1 -1
- package/dist/react/display.cjs +1137 -123
- package/dist/react/display.cjs.map +1 -1
- package/dist/react/display.d.cts +42 -14
- package/dist/react/display.d.ts +42 -14
- package/dist/react/display.js +1122 -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 +471 -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 +469 -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/dist/tokens.cjs +73 -22
- package/dist/tokens.cjs.map +1 -1
- package/dist/tokens.d.cts +23 -3
- package/dist/tokens.d.ts +23 -3
- package/dist/tokens.js +73 -22
- package/dist/tokens.js.map +1 -1
- package/package.json +250 -231
- package/registry.yaml +51 -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/forms.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { M as MosaicFormMode, F as FieldErrorShape, I as InputType, a as MultiSelectOption, S as SelectOption } from './index-
|
|
2
|
-
export { C as Checkbox, b as CheckboxPropsSchema, c as CheckboxPropsValidated, D as DEFAULT_TEXTAREA_ROWS, E as ErrorDisplay, d as ErrorDisplayPropsSchema, e as FieldArray, f as FieldArrayPropsSchema, g as FieldErrorShapeSchema, h as FormField, i as FormFieldPropsSchema, j as FormProvider, k as FormProviderPropsSchema, l as Input, m as InputPropsSchema, n as InputPropsValidated, o as InputTypeSchema, p as MosaicFormModeSchema, q as MultiSelect, r as MultiSelectOptionSchema, s as MultiSelectPropsSchema, R as RadioGroup, t as RadioGroupOption, u as RadioGroupOptionSchema, v as RadioGroupPropsSchema, w as RadioGroupPropsValidated, x as RadioOrientation, y as Select, z as SelectOptionSchema, A as SelectPropsSchema, B as SelectPropsValidated, G as SubmitButton, H as SubmitButtonPropsSchema, T as Textarea, J as TextareaPropsSchema, K as TextareaPropsValidated, U as UseFieldArrayOptionsSchema, L as UseMosaicFormOptions, N as UseMosaicFormOptionsSchema, O as UseMosaicFormReturn, P as buildAddAriaLabel, Q as buildListAriaLabel, V as buildRemoveAriaLabel, W as clampToMaxLength, X as computeAutoResizeHeight, Y as findFirstEnabledIndex, Z as findLastEnabledIndex, _ as findNextEnabledIndex, $ as findSelectedIndex, a0 as getGroupClasses, a1 as getGroupLabelId, a2 as getNavKeys, a3 as getOptionDescriptionId, a4 as getOptionLabelId, a5 as getOptionRowClasses, a6 as getRadioControlClasses, a7 as getRovingTabIndex, a8 as isActivationKey, a9 as nextFocusIndexAfterRemove, aa as resolveAriaChecked, ab as resolveDescribedBy, ac as resolveRows, ad as useFieldArray, ae as useMosaicForm, af as useMosaicFormContext, ag as validateCheckboxProps, ah as validateOptions, ai as validateRadioGroupProps, aj as validateSelectProps, ak as validateSubmitButtonProps, al as validateTextareaProps } from './index-
|
|
1
|
+
import { M as MosaicFormMode, F as FieldErrorShape, I as InputType, a as MultiSelectOption, S as SelectOption } from './index-BadRcCbm.cjs';
|
|
2
|
+
export { C as Checkbox, b as CheckboxPropsSchema, c as CheckboxPropsValidated, D as DEFAULT_TEXTAREA_ROWS, E as ErrorDisplay, d as ErrorDisplayPropsSchema, e as FieldArray, f as FieldArrayPropsSchema, g as FieldErrorShapeSchema, h as FormField, i as FormFieldPropsSchema, j as FormProvider, k as FormProviderPropsSchema, l as Input, m as InputPropsSchema, n as InputPropsValidated, o as InputTypeSchema, p as MosaicFormModeSchema, q as MultiSelect, r as MultiSelectOptionSchema, s as MultiSelectPropsSchema, R as RadioGroup, t as RadioGroupOption, u as RadioGroupOptionSchema, v as RadioGroupPropsSchema, w as RadioGroupPropsValidated, x as RadioOrientation, y as Select, z as SelectOptionSchema, A as SelectPropsSchema, B as SelectPropsValidated, G as SubmitButton, H as SubmitButtonPropsSchema, T as Textarea, J as TextareaPropsSchema, K as TextareaPropsValidated, U as UseFieldArrayOptionsSchema, L as UseMosaicFormOptions, N as UseMosaicFormOptionsSchema, O as UseMosaicFormReturn, P as buildAddAriaLabel, Q as buildListAriaLabel, V as buildRemoveAriaLabel, W as clampToMaxLength, X as computeAutoResizeHeight, Y as findFirstEnabledIndex, Z as findLastEnabledIndex, _ as findNextEnabledIndex, $ as findSelectedIndex, a0 as getGroupClasses, a1 as getGroupLabelId, a2 as getNavKeys, a3 as getOptionDescriptionId, a4 as getOptionLabelId, a5 as getOptionRowClasses, a6 as getRadioControlClasses, a7 as getRovingTabIndex, a8 as isActivationKey, a9 as nextFocusIndexAfterRemove, aa as resolveAriaChecked, ab as resolveDescribedBy, ac as resolveRows, ad as useFieldArray, ae as useMosaicForm, af as useMosaicFormContext, ag as validateCheckboxProps, ah as validateOptions, ai as validateRadioGroupProps, aj as validateSelectProps, ak as validateSubmitButtonProps, al as validateTextareaProps } from './index-BadRcCbm.cjs';
|
|
3
3
|
import 'react-hook-form';
|
|
4
4
|
import 'zod';
|
|
5
5
|
import 'react/jsx-runtime';
|
package/dist/forms.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { M as MosaicFormMode, F as FieldErrorShape, I as InputType, a as MultiSelectOption, S as SelectOption } from './index-
|
|
2
|
-
export { C as Checkbox, b as CheckboxPropsSchema, c as CheckboxPropsValidated, D as DEFAULT_TEXTAREA_ROWS, E as ErrorDisplay, d as ErrorDisplayPropsSchema, e as FieldArray, f as FieldArrayPropsSchema, g as FieldErrorShapeSchema, h as FormField, i as FormFieldPropsSchema, j as FormProvider, k as FormProviderPropsSchema, l as Input, m as InputPropsSchema, n as InputPropsValidated, o as InputTypeSchema, p as MosaicFormModeSchema, q as MultiSelect, r as MultiSelectOptionSchema, s as MultiSelectPropsSchema, R as RadioGroup, t as RadioGroupOption, u as RadioGroupOptionSchema, v as RadioGroupPropsSchema, w as RadioGroupPropsValidated, x as RadioOrientation, y as Select, z as SelectOptionSchema, A as SelectPropsSchema, B as SelectPropsValidated, G as SubmitButton, H as SubmitButtonPropsSchema, T as Textarea, J as TextareaPropsSchema, K as TextareaPropsValidated, U as UseFieldArrayOptionsSchema, L as UseMosaicFormOptions, N as UseMosaicFormOptionsSchema, O as UseMosaicFormReturn, P as buildAddAriaLabel, Q as buildListAriaLabel, V as buildRemoveAriaLabel, W as clampToMaxLength, X as computeAutoResizeHeight, Y as findFirstEnabledIndex, Z as findLastEnabledIndex, _ as findNextEnabledIndex, $ as findSelectedIndex, a0 as getGroupClasses, a1 as getGroupLabelId, a2 as getNavKeys, a3 as getOptionDescriptionId, a4 as getOptionLabelId, a5 as getOptionRowClasses, a6 as getRadioControlClasses, a7 as getRovingTabIndex, a8 as isActivationKey, a9 as nextFocusIndexAfterRemove, aa as resolveAriaChecked, ab as resolveDescribedBy, ac as resolveRows, ad as useFieldArray, ae as useMosaicForm, af as useMosaicFormContext, ag as validateCheckboxProps, ah as validateOptions, ai as validateRadioGroupProps, aj as validateSelectProps, ak as validateSubmitButtonProps, al as validateTextareaProps } from './index-
|
|
1
|
+
import { M as MosaicFormMode, F as FieldErrorShape, I as InputType, a as MultiSelectOption, S as SelectOption } from './index-BadRcCbm.js';
|
|
2
|
+
export { C as Checkbox, b as CheckboxPropsSchema, c as CheckboxPropsValidated, D as DEFAULT_TEXTAREA_ROWS, E as ErrorDisplay, d as ErrorDisplayPropsSchema, e as FieldArray, f as FieldArrayPropsSchema, g as FieldErrorShapeSchema, h as FormField, i as FormFieldPropsSchema, j as FormProvider, k as FormProviderPropsSchema, l as Input, m as InputPropsSchema, n as InputPropsValidated, o as InputTypeSchema, p as MosaicFormModeSchema, q as MultiSelect, r as MultiSelectOptionSchema, s as MultiSelectPropsSchema, R as RadioGroup, t as RadioGroupOption, u as RadioGroupOptionSchema, v as RadioGroupPropsSchema, w as RadioGroupPropsValidated, x as RadioOrientation, y as Select, z as SelectOptionSchema, A as SelectPropsSchema, B as SelectPropsValidated, G as SubmitButton, H as SubmitButtonPropsSchema, T as Textarea, J as TextareaPropsSchema, K as TextareaPropsValidated, U as UseFieldArrayOptionsSchema, L as UseMosaicFormOptions, N as UseMosaicFormOptionsSchema, O as UseMosaicFormReturn, P as buildAddAriaLabel, Q as buildListAriaLabel, V as buildRemoveAriaLabel, W as clampToMaxLength, X as computeAutoResizeHeight, Y as findFirstEnabledIndex, Z as findLastEnabledIndex, _ as findNextEnabledIndex, $ as findSelectedIndex, a0 as getGroupClasses, a1 as getGroupLabelId, a2 as getNavKeys, a3 as getOptionDescriptionId, a4 as getOptionLabelId, a5 as getOptionRowClasses, a6 as getRadioControlClasses, a7 as getRovingTabIndex, a8 as isActivationKey, a9 as nextFocusIndexAfterRemove, aa as resolveAriaChecked, ab as resolveDescribedBy, ac as resolveRows, ad as useFieldArray, ae as useMosaicForm, af as useMosaicFormContext, ag as validateCheckboxProps, ah as validateOptions, ai as validateRadioGroupProps, aj as validateSelectProps, ak as validateSubmitButtonProps, al as validateTextareaProps } from './index-BadRcCbm.js';
|
|
3
3
|
import 'react-hook-form';
|
|
4
4
|
import 'zod';
|
|
5
5
|
import 'react/jsx-runtime';
|
package/dist/forms.js
CHANGED
|
@@ -515,7 +515,9 @@ var MultiSelectPropsSchema = z.object({
|
|
|
515
515
|
placeholder: z.string().optional(),
|
|
516
516
|
disabled: z.boolean().optional(),
|
|
517
517
|
searchable: z.boolean().optional(),
|
|
518
|
-
maxItems: z.number().int().positive().optional()
|
|
518
|
+
maxItems: z.number().int().positive().optional(),
|
|
519
|
+
/** `chips`: every option is a visible toggle button (aria-pressed), no dropdown. */
|
|
520
|
+
appearance: z.enum(["default", "chips"]).default("default")
|
|
519
521
|
});
|
|
520
522
|
function MultiSelect(props) {
|
|
521
523
|
const parsed = MultiSelectPropsSchema.parse({
|
|
@@ -525,15 +527,32 @@ function MultiSelect(props) {
|
|
|
525
527
|
placeholder: props.placeholder,
|
|
526
528
|
disabled: props.disabled,
|
|
527
529
|
searchable: props.searchable,
|
|
528
|
-
maxItems: props.maxItems
|
|
530
|
+
maxItems: props.maxItems,
|
|
531
|
+
appearance: props.appearance
|
|
529
532
|
});
|
|
530
|
-
const { name, label, options, placeholder, disabled, searchable, maxItems } = parsed;
|
|
533
|
+
const { name, label, options, placeholder, disabled, searchable, maxItems, appearance } = parsed;
|
|
531
534
|
const reactId = useId();
|
|
532
535
|
const triggerId = `${reactId}-trigger`;
|
|
533
536
|
const listboxId = `${reactId}-listbox`;
|
|
534
537
|
const labelId = `${reactId}-label`;
|
|
535
538
|
return /* @__PURE__ */ jsx(FormField, { name, children: ({ field }) => {
|
|
536
539
|
const value = Array.isArray(field.value) ? field.value : [];
|
|
540
|
+
if (appearance === "chips") {
|
|
541
|
+
return /* @__PURE__ */ jsx(
|
|
542
|
+
ChipToggles,
|
|
543
|
+
{
|
|
544
|
+
labelId,
|
|
545
|
+
label,
|
|
546
|
+
options,
|
|
547
|
+
value,
|
|
548
|
+
disabled,
|
|
549
|
+
maxItems,
|
|
550
|
+
onChange: (next) => field.onChange(next),
|
|
551
|
+
onBlur: () => field.onBlur(),
|
|
552
|
+
className: props.className
|
|
553
|
+
}
|
|
554
|
+
);
|
|
555
|
+
}
|
|
537
556
|
return /* @__PURE__ */ jsx(
|
|
538
557
|
Inner,
|
|
539
558
|
{
|
|
@@ -554,6 +573,39 @@ function MultiSelect(props) {
|
|
|
554
573
|
);
|
|
555
574
|
} });
|
|
556
575
|
}
|
|
576
|
+
function ChipToggles(p) {
|
|
577
|
+
const atMax = isAtMaxItems(p.value, p.maxItems);
|
|
578
|
+
return /* @__PURE__ */ jsxs(
|
|
579
|
+
"fieldset",
|
|
580
|
+
{
|
|
581
|
+
"aria-labelledby": p.labelId,
|
|
582
|
+
"data-appearance": "chips",
|
|
583
|
+
className: `m-0 min-w-0 border-0 p-0 ${p.className ?? "mosaic-multiselect mosaic-multiselect--chips"}`,
|
|
584
|
+
onBlur: p.onBlur,
|
|
585
|
+
children: [
|
|
586
|
+
/* @__PURE__ */ jsx("span", { id: p.labelId, className: "mosaic-multiselect-label", children: p.label }),
|
|
587
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-row flex-wrap gap-2", children: p.options.map((opt) => {
|
|
588
|
+
const on = p.value.includes(opt.value);
|
|
589
|
+
return /* @__PURE__ */ jsx(
|
|
590
|
+
"button",
|
|
591
|
+
{
|
|
592
|
+
type: "button",
|
|
593
|
+
"aria-pressed": on,
|
|
594
|
+
disabled: p.disabled || !on && atMax,
|
|
595
|
+
"data-chip-value": opt.value,
|
|
596
|
+
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`,
|
|
597
|
+
onClick: () => p.onChange(
|
|
598
|
+
on ? removeValue(p.value, opt.value) : addValue(p.value, opt.value, p.maxItems)
|
|
599
|
+
),
|
|
600
|
+
children: opt.label
|
|
601
|
+
},
|
|
602
|
+
opt.value
|
|
603
|
+
);
|
|
604
|
+
}) })
|
|
605
|
+
]
|
|
606
|
+
}
|
|
607
|
+
);
|
|
608
|
+
}
|
|
557
609
|
function Inner(p) {
|
|
558
610
|
const [open, setOpen] = useState(false);
|
|
559
611
|
const [query, setQuery] = useState("");
|
|
@@ -764,10 +816,21 @@ function getOptionLabelId(instanceId, name, optionValue) {
|
|
|
764
816
|
function getOptionDescriptionId(instanceId, name, optionValue) {
|
|
765
817
|
return `${instanceId}-${name}-${optionValue}-desc`;
|
|
766
818
|
}
|
|
767
|
-
function getGroupClasses(orientation) {
|
|
819
|
+
function getGroupClasses(orientation, appearance = "default") {
|
|
820
|
+
if (appearance === "segmented") {
|
|
821
|
+
return "inline-flex flex-row overflow-hidden rounded-md border border-slate-300";
|
|
822
|
+
}
|
|
823
|
+
if (appearance === "chips") return "flex flex-row flex-wrap gap-2";
|
|
768
824
|
return orientation === "vertical" ? "flex flex-col gap-2" : "flex flex-row flex-wrap gap-4";
|
|
769
825
|
}
|
|
770
|
-
function getOptionRowClasses(isDisabled, orientation) {
|
|
826
|
+
function getOptionRowClasses(isDisabled, orientation, appearance = "default") {
|
|
827
|
+
const state0 = isDisabled ? "opacity-50 cursor-not-allowed" : "cursor-pointer";
|
|
828
|
+
if (appearance !== "default") {
|
|
829
|
+
return [
|
|
830
|
+
"relative inline-flex items-center focus-within:outline focus-within:outline-2 focus-within:outline-blue-600",
|
|
831
|
+
state0
|
|
832
|
+
].join(" ");
|
|
833
|
+
}
|
|
771
834
|
const base = "flex items-start gap-2";
|
|
772
835
|
const orient = orientation === "vertical" ? "flex-row" : "flex-row";
|
|
773
836
|
const state = isDisabled ? "opacity-50 cursor-not-allowed" : "cursor-pointer";
|
|
@@ -781,6 +844,13 @@ function getRadioControlClasses(isSelected, isDisabled) {
|
|
|
781
844
|
function isActivationKey(key) {
|
|
782
845
|
return key === " " || key === "Space" || key === "Enter";
|
|
783
846
|
}
|
|
847
|
+
function getOptionLabelClasses(appearance, isSelected) {
|
|
848
|
+
if (appearance === "default") return "mosaic-forms-radiogroup-option-label";
|
|
849
|
+
const base = "mosaic-forms-radiogroup-option-label inline-flex items-center px-3 py-1 text-sm";
|
|
850
|
+
const shape = appearance === "chips" ? "rounded-full border" : "";
|
|
851
|
+
const tone = isSelected ? "bg-slate-900 text-white border-slate-900" : "bg-white text-slate-700 border-slate-300 hover:bg-slate-50";
|
|
852
|
+
return [base, shape, tone].filter(Boolean).join(" ");
|
|
853
|
+
}
|
|
784
854
|
var RadioGroupOptionSchema = z.object({
|
|
785
855
|
value: z.string().min(1),
|
|
786
856
|
label: z.string().min(1),
|
|
@@ -792,6 +862,12 @@ var RadioGroupPropsSchema = z.object({
|
|
|
792
862
|
label: z.string().min(1),
|
|
793
863
|
options: z.array(RadioGroupOptionSchema).min(1),
|
|
794
864
|
orientation: z.enum(["vertical", "horizontal"]).default("vertical"),
|
|
865
|
+
/**
|
|
866
|
+
* `segmented` / `chips` render the options as always-visible controls (Claude design
|
|
867
|
+
* guidelines prefer visible options over menus, which clip inside the iframe). The ARIA
|
|
868
|
+
* radiogroup semantics are identical in every appearance.
|
|
869
|
+
*/
|
|
870
|
+
appearance: z.enum(["default", "segmented", "chips"]).default("default"),
|
|
795
871
|
disabled: z.boolean().optional().default(false),
|
|
796
872
|
locale: z.enum(["en", "fr"]).default("en")
|
|
797
873
|
});
|
|
@@ -804,9 +880,10 @@ function RadioGroup(props) {
|
|
|
804
880
|
label: props.label,
|
|
805
881
|
options: props.options,
|
|
806
882
|
orientation: props.orientation,
|
|
807
|
-
disabled: props.disabled
|
|
883
|
+
disabled: props.disabled,
|
|
884
|
+
appearance: props.appearance
|
|
808
885
|
});
|
|
809
|
-
const { name, label, options, orientation, disabled } = validated;
|
|
886
|
+
const { name, label, options, orientation, disabled, appearance } = validated;
|
|
810
887
|
const instanceId = useId();
|
|
811
888
|
const groupLabelId = getGroupLabelId(instanceId, name);
|
|
812
889
|
const { prev: prevKey, next: nextKey } = getNavKeys(orientation);
|
|
@@ -861,51 +938,67 @@ function RadioGroup(props) {
|
|
|
861
938
|
"aria-labelledby": groupLabelId,
|
|
862
939
|
"aria-orientation": orientation,
|
|
863
940
|
"aria-disabled": disabled || void 0,
|
|
864
|
-
|
|
941
|
+
"data-appearance": appearance === "default" ? void 0 : appearance,
|
|
942
|
+
className: getGroupClasses(orientation, appearance),
|
|
865
943
|
children: options.map((option, index) => {
|
|
866
944
|
const isSelected = selectedValue === option.value;
|
|
867
945
|
const isDisabled = !!(disabled || option.disabled);
|
|
868
946
|
const optLabelId = getOptionLabelId(instanceId, name, option.value);
|
|
869
947
|
const optDescId = option.description ? getOptionDescriptionId(instanceId, name, option.value) : void 0;
|
|
870
948
|
const tabIdx = index === rovingIdx ? 0 : -1;
|
|
871
|
-
return /* @__PURE__ */ jsxs(
|
|
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
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
949
|
+
return /* @__PURE__ */ jsxs(
|
|
950
|
+
"div",
|
|
951
|
+
{
|
|
952
|
+
className: getOptionRowClasses(isDisabled, orientation, appearance),
|
|
953
|
+
children: [
|
|
954
|
+
/* @__PURE__ */ jsx(
|
|
955
|
+
"input",
|
|
956
|
+
{
|
|
957
|
+
ref: (el) => {
|
|
958
|
+
radioRefs.current[index] = el;
|
|
959
|
+
},
|
|
960
|
+
type: "radio",
|
|
961
|
+
id: `${instanceId}-${name}-${option.value}`,
|
|
962
|
+
name: field.name,
|
|
963
|
+
value: option.value,
|
|
964
|
+
checked: isSelected,
|
|
965
|
+
disabled: isDisabled,
|
|
966
|
+
"aria-labelledby": optLabelId,
|
|
967
|
+
"aria-describedby": optDescId,
|
|
968
|
+
tabIndex: isDisabled ? -1 : tabIdx,
|
|
969
|
+
className: "mosaic-forms-radiogroup-input sr-only",
|
|
970
|
+
onChange: () => {
|
|
971
|
+
field.onChange(option.value);
|
|
972
|
+
},
|
|
973
|
+
onKeyDown: (e) => {
|
|
974
|
+
if (!isDisabled) handleKeyDown(e, index);
|
|
975
|
+
},
|
|
976
|
+
onBlur: field.onBlur
|
|
977
|
+
}
|
|
978
|
+
),
|
|
979
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-0.5", children: [
|
|
980
|
+
/* @__PURE__ */ jsx(
|
|
981
|
+
"span",
|
|
982
|
+
{
|
|
983
|
+
id: optLabelId,
|
|
984
|
+
"data-selected": isSelected ? "true" : void 0,
|
|
985
|
+
className: getOptionLabelClasses(appearance, isSelected),
|
|
986
|
+
children: option.label
|
|
987
|
+
}
|
|
988
|
+
),
|
|
989
|
+
option.description ? /* @__PURE__ */ jsx(
|
|
990
|
+
"span",
|
|
991
|
+
{
|
|
992
|
+
id: optDescId,
|
|
993
|
+
className: "mosaic-forms-radiogroup-option-description text-sm text-slate-500",
|
|
994
|
+
children: option.description
|
|
995
|
+
}
|
|
996
|
+
) : null
|
|
997
|
+
] })
|
|
998
|
+
]
|
|
999
|
+
},
|
|
1000
|
+
option.value
|
|
1001
|
+
);
|
|
909
1002
|
})
|
|
910
1003
|
}
|
|
911
1004
|
),
|