@slipstream-ui/core 0.11.3 → 0.11.6
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/dist/index.d.mts +126 -7
- package/dist/index.d.ts +126 -7
- package/dist/index.js +605 -444
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +500 -340
- package/dist/index.mjs.map +1 -1
- package/dist/manifests/accordion.manifest.json +1 -1
- package/dist/manifests/alert.manifest.json +1 -1
- package/dist/manifests/announcement-bar.manifest.json +1 -1
- package/dist/manifests/app-shell.manifest.json +1 -1
- package/dist/manifests/applied-filters.manifest.json +1 -1
- package/dist/manifests/article-card.manifest.json +1 -1
- package/dist/manifests/auth-layout.manifest.json +1 -1
- package/dist/manifests/autocomplete.manifest.json +1 -1
- package/dist/manifests/avatar.manifest.json +1 -1
- package/dist/manifests/badge.manifest.json +1 -1
- package/dist/manifests/block.manifest.json +1 -1
- package/dist/manifests/bottom-nav.manifest.json +1 -1
- package/dist/manifests/breadcrumb.manifest.json +1 -1
- package/dist/manifests/button-group.manifest.json +1 -1
- package/dist/manifests/button.manifest.json +1 -1
- package/dist/manifests/calendar.manifest.json +1 -1
- package/dist/manifests/card.manifest.json +1 -1
- package/dist/manifests/checkbox.manifest.json +1 -1
- package/dist/manifests/comparison-table.manifest.json +1 -1
- package/dist/manifests/confirm-dialog.manifest.json +1 -1
- package/dist/manifests/contact-strip.manifest.json +1 -1
- package/dist/manifests/container.manifest.json +1 -1
- package/dist/manifests/cover-image.manifest.json +151 -0
- package/dist/manifests/cta-section.manifest.json +1 -1
- package/dist/manifests/data-table.manifest.json +1 -1
- package/dist/manifests/date-picker-popover.manifest.json +1 -1
- package/dist/manifests/date-picker.manifest.json +1 -1
- package/dist/manifests/date-range-picker.manifest.json +1 -1
- package/dist/manifests/deal-card.manifest.json +1 -1
- package/dist/manifests/dialog.manifest.json +1 -1
- package/dist/manifests/document-card.manifest.json +1 -1
- package/dist/manifests/drawer.manifest.json +1 -1
- package/dist/manifests/empty-state.manifest.json +45 -1
- package/dist/manifests/entity-card.manifest.json +1 -1
- package/dist/manifests/feature-grid.manifest.json +1 -1
- package/dist/manifests/feature-row.manifest.json +1 -1
- package/dist/manifests/fieldset.manifest.json +1 -1
- package/dist/manifests/file-upload.manifest.json +1 -1
- package/dist/manifests/filter-bar.manifest.json +1 -1
- package/dist/manifests/filter-chips.manifest.json +1 -1
- package/dist/manifests/filter-panel.manifest.json +1 -1
- package/dist/manifests/flex.manifest.json +1 -1
- package/dist/manifests/form-field.manifest.json +1 -1
- package/dist/manifests/form-layout.manifest.json +16 -4
- package/dist/manifests/form.manifest.json +1 -1
- package/dist/manifests/grid.manifest.json +1 -1
- package/dist/manifests/heading.manifest.json +1 -1
- package/dist/manifests/hero.manifest.json +1 -1
- package/dist/manifests/image.manifest.json +7 -1
- package/dist/manifests/input-group.manifest.json +1 -1
- package/dist/manifests/input.manifest.json +1 -1
- package/dist/manifests/label.manifest.json +1 -1
- package/dist/manifests/link-tabs.manifest.json +1 -1
- package/dist/manifests/link.manifest.json +1 -1
- package/dist/manifests/list.manifest.json +1 -1
- package/dist/manifests/load-more.manifest.json +1 -1
- package/dist/manifests/logo-cloud.manifest.json +1 -1
- package/dist/manifests/menu.manifest.json +1 -1
- package/dist/manifests/metric-card.manifest.json +1 -1
- package/dist/manifests/multi-select.manifest.json +1 -1
- package/dist/manifests/newsletter.manifest.json +1 -1
- package/dist/manifests/page-header.manifest.json +1 -1
- package/dist/manifests/pagination.manifest.json +1 -1
- package/dist/manifests/password-input.manifest.json +1 -1
- package/dist/manifests/popover.manifest.json +1 -1
- package/dist/manifests/process-steps.manifest.json +1 -1
- package/dist/manifests/progress.manifest.json +1 -1
- package/dist/manifests/prose.manifest.json +1 -1
- package/dist/manifests/radio.manifest.json +1 -1
- package/dist/manifests/range-slider.manifest.json +1 -1
- package/dist/manifests/search.manifest.json +1 -1
- package/dist/manifests/section-heading.manifest.json +1 -1
- package/dist/manifests/section.manifest.json +1 -1
- package/dist/manifests/segmented-control.manifest.json +29 -2
- package/dist/manifests/select-menu.manifest.json +1 -1
- package/dist/manifests/select.manifest.json +1 -1
- package/dist/manifests/separator.manifest.json +1 -1
- package/dist/manifests/site-footer.manifest.json +1 -1
- package/dist/manifests/site-header.manifest.json +1 -1
- package/dist/manifests/skeleton.manifest.json +1 -1
- package/dist/manifests/spinner.manifest.json +1 -1
- package/dist/manifests/stat-band.manifest.json +23 -1
- package/dist/manifests/stepper.manifest.json +1 -1
- package/dist/manifests/switch.manifest.json +1 -1
- package/dist/manifests/table-card.manifest.json +1 -1
- package/dist/manifests/table-of-contents.manifest.json +1 -1
- package/dist/manifests/table.manifest.json +1 -1
- package/dist/manifests/tabs.manifest.json +1 -1
- package/dist/manifests/testimonial.manifest.json +1 -1
- package/dist/manifests/text.manifest.json +1 -1
- package/dist/manifests/textarea.manifest.json +1 -1
- package/dist/manifests/theme-toggle.manifest.json +1 -1
- package/dist/manifests/time-picker.manifest.json +1 -1
- package/dist/manifests/timeline.manifest.json +1 -1
- package/dist/manifests/toast.manifest.json +1 -1
- package/dist/manifests/tombstone-card.manifest.json +1 -1
- package/dist/manifests/tooltip.manifest.json +1 -1
- package/dist/src/components/cover-image/CoverImage.d.ts +34 -0
- package/dist/src/components/cover-image/CoverImage.js +94 -0
- package/dist/src/components/cover-image/CoverImage.js.map +1 -0
- package/dist/src/components/cover-image/CoverImage.mjs +70 -0
- package/dist/src/components/cover-image/CoverImage.mjs.map +1 -0
- package/dist/src/components/cover-image/index.d.ts +1 -0
- package/dist/src/components/cover-image/index.js +29 -0
- package/dist/src/components/cover-image/index.js.map +1 -0
- package/dist/src/components/cover-image/index.mjs +5 -0
- package/dist/src/components/cover-image/index.mjs.map +1 -0
- package/dist/src/components/empty-state/EmptyState.d.ts +24 -0
- package/dist/src/components/empty-state/EmptyState.js +16 -6
- package/dist/src/components/empty-state/EmptyState.js.map +1 -1
- package/dist/src/components/empty-state/EmptyState.mjs +16 -6
- package/dist/src/components/empty-state/EmptyState.mjs.map +1 -1
- package/dist/src/components/form-layout/FormLayout.d.ts +26 -4
- package/dist/src/components/form-layout/FormLayout.js +16 -3
- package/dist/src/components/form-layout/FormLayout.js.map +1 -1
- package/dist/src/components/form-layout/FormLayout.mjs +16 -3
- package/dist/src/components/form-layout/FormLayout.mjs.map +1 -1
- package/dist/src/components/image/Image.d.ts +3 -1
- package/dist/src/components/image/Image.js +2 -0
- package/dist/src/components/image/Image.js.map +1 -1
- package/dist/src/components/image/Image.mjs +2 -0
- package/dist/src/components/image/Image.mjs.map +1 -1
- package/dist/src/components/segmented-control/SegmentedControl.d.ts +21 -0
- package/dist/src/components/segmented-control/SegmentedControl.js +47 -16
- package/dist/src/components/segmented-control/SegmentedControl.js.map +1 -1
- package/dist/src/components/segmented-control/SegmentedControl.mjs +48 -17
- package/dist/src/components/segmented-control/SegmentedControl.mjs.map +1 -1
- package/dist/src/components/stat-band/StatBand.d.ts +16 -0
- package/dist/src/components/stat-band/StatBand.js +46 -9
- package/dist/src/components/stat-band/StatBand.js.map +1 -1
- package/dist/src/components/stat-band/StatBand.mjs +46 -9
- package/dist/src/components/stat-band/StatBand.mjs.map +1 -1
- package/dist/src/index.d.ts +1 -0
- package/dist/styles-full.css +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
- package/src/components/cover-image/CoverImage.test.tsx +88 -0
- package/src/components/cover-image/CoverImage.tsx +109 -0
- package/src/components/cover-image/index.ts +1 -0
- package/src/components/empty-state/EmptyState.test.tsx +33 -0
- package/src/components/empty-state/EmptyState.tsx +34 -6
- package/src/components/form-layout/FormLayout.test.tsx +26 -0
- package/src/components/form-layout/FormLayout.tsx +37 -5
- package/src/components/image/Image.tsx +4 -0
- package/src/components/segmented-control/SegmentedControl.test.tsx +64 -0
- package/src/components/segmented-control/SegmentedControl.tsx +69 -15
- package/src/components/stat-band/StatBand.test.tsx +26 -0
- package/src/components/stat-band/StatBand.tsx +52 -7
- package/src/index.ts +1 -0
- package/src/manifests/accordion.manifest.json +1 -1
- package/src/manifests/alert.manifest.json +1 -1
- package/src/manifests/announcement-bar.manifest.json +1 -1
- package/src/manifests/app-shell.manifest.json +1 -1
- package/src/manifests/applied-filters.manifest.json +1 -1
- package/src/manifests/article-card.manifest.json +1 -1
- package/src/manifests/auth-layout.manifest.json +1 -1
- package/src/manifests/autocomplete.manifest.json +1 -1
- package/src/manifests/avatar.manifest.json +1 -1
- package/src/manifests/badge.manifest.json +1 -1
- package/src/manifests/block.manifest.json +1 -1
- package/src/manifests/bottom-nav.manifest.json +1 -1
- package/src/manifests/breadcrumb.manifest.json +1 -1
- package/src/manifests/button-group.manifest.json +1 -1
- package/src/manifests/button.manifest.json +1 -1
- package/src/manifests/calendar.manifest.json +1 -1
- package/src/manifests/card.manifest.json +1 -1
- package/src/manifests/checkbox.manifest.json +1 -1
- package/src/manifests/comparison-table.manifest.json +1 -1
- package/src/manifests/confirm-dialog.manifest.json +1 -1
- package/src/manifests/contact-strip.manifest.json +1 -1
- package/src/manifests/container.manifest.json +1 -1
- package/src/manifests/cover-image.manifest.json +151 -0
- package/src/manifests/cta-section.manifest.json +1 -1
- package/src/manifests/data-table.manifest.json +1 -1
- package/src/manifests/date-picker-popover.manifest.json +1 -1
- package/src/manifests/date-picker.manifest.json +1 -1
- package/src/manifests/date-range-picker.manifest.json +1 -1
- package/src/manifests/deal-card.manifest.json +1 -1
- package/src/manifests/dialog.manifest.json +1 -1
- package/src/manifests/document-card.manifest.json +1 -1
- package/src/manifests/drawer.manifest.json +1 -1
- package/src/manifests/empty-state.manifest.json +45 -1
- package/src/manifests/entity-card.manifest.json +1 -1
- package/src/manifests/feature-grid.manifest.json +1 -1
- package/src/manifests/feature-row.manifest.json +1 -1
- package/src/manifests/fieldset.manifest.json +1 -1
- package/src/manifests/file-upload.manifest.json +1 -1
- package/src/manifests/filter-bar.manifest.json +1 -1
- package/src/manifests/filter-chips.manifest.json +1 -1
- package/src/manifests/filter-panel.manifest.json +1 -1
- package/src/manifests/flex.manifest.json +1 -1
- package/src/manifests/form-field.manifest.json +1 -1
- package/src/manifests/form-layout.manifest.json +16 -4
- package/src/manifests/form.manifest.json +1 -1
- package/src/manifests/grid.manifest.json +1 -1
- package/src/manifests/heading.manifest.json +1 -1
- package/src/manifests/hero.manifest.json +1 -1
- package/src/manifests/image.manifest.json +7 -1
- package/src/manifests/input-group.manifest.json +1 -1
- package/src/manifests/input.manifest.json +1 -1
- package/src/manifests/label.manifest.json +1 -1
- package/src/manifests/link-tabs.manifest.json +1 -1
- package/src/manifests/link.manifest.json +1 -1
- package/src/manifests/list.manifest.json +1 -1
- package/src/manifests/load-more.manifest.json +1 -1
- package/src/manifests/logo-cloud.manifest.json +1 -1
- package/src/manifests/menu.manifest.json +1 -1
- package/src/manifests/metric-card.manifest.json +1 -1
- package/src/manifests/multi-select.manifest.json +1 -1
- package/src/manifests/newsletter.manifest.json +1 -1
- package/src/manifests/page-header.manifest.json +1 -1
- package/src/manifests/pagination.manifest.json +1 -1
- package/src/manifests/password-input.manifest.json +1 -1
- package/src/manifests/popover.manifest.json +1 -1
- package/src/manifests/process-steps.manifest.json +1 -1
- package/src/manifests/progress.manifest.json +1 -1
- package/src/manifests/prose.manifest.json +1 -1
- package/src/manifests/radio.manifest.json +1 -1
- package/src/manifests/range-slider.manifest.json +1 -1
- package/src/manifests/search.manifest.json +1 -1
- package/src/manifests/section-heading.manifest.json +1 -1
- package/src/manifests/section.manifest.json +1 -1
- package/src/manifests/segmented-control.manifest.json +29 -2
- package/src/manifests/select-menu.manifest.json +1 -1
- package/src/manifests/select.manifest.json +1 -1
- package/src/manifests/separator.manifest.json +1 -1
- package/src/manifests/site-footer.manifest.json +1 -1
- package/src/manifests/site-header.manifest.json +1 -1
- package/src/manifests/skeleton.manifest.json +1 -1
- package/src/manifests/spinner.manifest.json +1 -1
- package/src/manifests/stat-band.manifest.json +23 -1
- package/src/manifests/stepper.manifest.json +1 -1
- package/src/manifests/switch.manifest.json +1 -1
- package/src/manifests/table-card.manifest.json +1 -1
- package/src/manifests/table-of-contents.manifest.json +1 -1
- package/src/manifests/table.manifest.json +1 -1
- package/src/manifests/tabs.manifest.json +1 -1
- package/src/manifests/testimonial.manifest.json +1 -1
- package/src/manifests/text.manifest.json +1 -1
- package/src/manifests/textarea.manifest.json +1 -1
- package/src/manifests/theme-toggle.manifest.json +1 -1
- package/src/manifests/time-picker.manifest.json +1 -1
- package/src/manifests/timeline.manifest.json +1 -1
- package/src/manifests/toast.manifest.json +1 -1
- package/src/manifests/tombstone-card.manifest.json +1 -1
- package/src/manifests/tooltip.manifest.json +1 -1
- package/src/styles.css +5 -0
|
@@ -41,13 +41,26 @@ const GRID_COLUMNS = {
|
|
|
41
41
|
3: "grid-cols-3",
|
|
42
42
|
4: "grid-cols-4"
|
|
43
43
|
};
|
|
44
|
+
const GRID_BREAKPOINTS = ["sm", "md", "lg", "xl"];
|
|
45
|
+
function gridColumnClasses(columns) {
|
|
46
|
+
if (typeof columns === "number") return GRID_COLUMNS[columns];
|
|
47
|
+
return [
|
|
48
|
+
columns.base !== void 0 ? GRID_COLUMNS[columns.base] : "",
|
|
49
|
+
...GRID_BREAKPOINTS.map((bp) => {
|
|
50
|
+
const count = columns[bp];
|
|
51
|
+
return count !== void 0 ? `${bp}:${GRID_COLUMNS[count]}` : "";
|
|
52
|
+
})
|
|
53
|
+
].filter(Boolean).join(" ");
|
|
54
|
+
}
|
|
44
55
|
const FormLayout = React.forwardRef(
|
|
45
56
|
({
|
|
46
57
|
layout = "stack",
|
|
47
58
|
columns = 2,
|
|
48
59
|
gap,
|
|
49
60
|
legend,
|
|
61
|
+
legendClassName,
|
|
50
62
|
description,
|
|
63
|
+
descriptionClassName,
|
|
51
64
|
as = "div",
|
|
52
65
|
className,
|
|
53
66
|
style,
|
|
@@ -64,15 +77,15 @@ const FormLayout = React.forwardRef(
|
|
|
64
77
|
"flex min-w-0",
|
|
65
78
|
layout === "stack" && "flex-col",
|
|
66
79
|
layout === "row" && "flex-row flex-wrap items-end",
|
|
67
|
-
layout === "grid" && `grid ${
|
|
80
|
+
layout === "grid" && `grid ${gridColumnClasses(columns)}`,
|
|
68
81
|
gapResolved.className,
|
|
69
82
|
className
|
|
70
83
|
),
|
|
71
84
|
style: { ...gapResolved.style, ...style },
|
|
72
85
|
...props,
|
|
73
86
|
children: [
|
|
74
|
-
legend && as === "fieldset" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("legend", { className: "col-span-full p-0 text-sm font-medium leading-none", children: legend }),
|
|
75
|
-
description && as === "fieldset" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "col-span-full text-xs text-muted-foreground", children: description }),
|
|
87
|
+
legend && as === "fieldset" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("legend", { className: (0, import_cn.cn)("col-span-full p-0 text-sm font-medium leading-none", legendClassName), children: legend }),
|
|
88
|
+
description && as === "fieldset" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: (0, import_cn.cn)("col-span-full text-xs text-muted-foreground", descriptionClassName), children: description }),
|
|
76
89
|
children
|
|
77
90
|
]
|
|
78
91
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/form-layout/FormLayout.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cn } from '../../utils/cn';\nimport { resolveGap, type GapValue } from '../../utils/gap';\n\n// Literal classes so Tailwind's scanner keeps them (runtime-built\n// grid-cols-${n} would be purged — same rule as Grid).\nconst GRID_COLUMNS: Record<number, string> = {\n 1: 'grid-cols-1',\n 2: 'grid-cols-2',\n 3: 'grid-cols-3',\n 4: 'grid-cols-4',\n};\n\nexport type FormLayoutProps = React.HTMLAttributes<HTMLElement> & {\n /** Grouping layout: even vertical stack (default), horizontal row, or responsive grid. */\n layout?: 'stack' | 'row' | 'grid';\n
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/form-layout/FormLayout.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cn } from '../../utils/cn';\nimport { resolveGap, type GapValue } from '../../utils/gap';\n\n// Literal classes so Tailwind's scanner keeps them (runtime-built\n// grid-cols-${n} would be purged — same rule as Grid).\nconst GRID_COLUMNS: Record<number, string> = {\n 1: 'grid-cols-1',\n 2: 'grid-cols-2',\n 3: 'grid-cols-3',\n 4: 'grid-cols-4',\n};\n\nconst GRID_BREAKPOINTS = ['sm', 'md', 'lg', 'xl'] as const;\n\n/** Column count per breakpoint; `base` applies at every width. */\nexport type FormLayoutColumns =\n | 1\n | 2\n | 3\n | 4\n | { base?: 1 | 2 | 3 | 4; sm?: 1 | 2 | 3 | 4; md?: 1 | 2 | 3 | 4; lg?: 1 | 2 | 3 | 4; xl?: 1 | 2 | 3 | 4 };\n\nfunction gridColumnClasses(columns: FormLayoutColumns): string {\n if (typeof columns === 'number') return GRID_COLUMNS[columns];\n return [\n columns.base !== undefined ? GRID_COLUMNS[columns.base] : '',\n ...GRID_BREAKPOINTS.map((bp) => {\n const count = columns[bp];\n return count !== undefined ? `${bp}:${GRID_COLUMNS[count]}` : '';\n }),\n ]\n .filter(Boolean)\n .join(' ');\n}\n\nexport type FormLayoutProps = React.HTMLAttributes<HTMLElement> & {\n /** Grouping layout: even vertical stack (default), horizontal row, or responsive grid. */\n layout?: 'stack' | 'row' | 'grid';\n /**\n * Grid column count (1-4) at every width, or per breakpoint\n * (`{ base: 1, md: 2 }`) for responsive grids without className overrides.\n */\n columns?: FormLayoutColumns;\n /** Even spacing between children — token ('md') or exact pixels (16). */\n gap?: GapValue;\n /** Group label; renders a semantic <legend> when as=\"fieldset\". */\n legend?: string;\n /** Extra classes for the legend (fieldset mode). */\n legendClassName?: string;\n /** Supporting line under the legend (fieldset mode). */\n description?: string;\n /** Extra classes for the description (fieldset mode). */\n descriptionClassName?: string;\n /** Render as a semantic fieldset (default 'div'). */\n as?: 'div' | 'fieldset';\n};\n\n/**\n * Groups form fields with even, tokenized spacing — the layout half of\n * form composition (FormField/Fieldset provide the per-control semantics).\n * stack keeps one field per row, row flows fields inline, grid spreads\n * them across columns (1-4, literal classes so they survive purging).\n */\nconst FormLayout = React.forwardRef<HTMLElement, FormLayoutProps>(\n (\n {\n layout = 'stack',\n columns = 2,\n gap,\n legend,\n legendClassName,\n description,\n descriptionClassName,\n as = 'div',\n className,\n style,\n children,\n ...props\n },\n ref,\n ) => {\n const Tag = as as 'div' | 'fieldset';\n const gapResolved = resolveGap(gap ?? 'md');\n return (\n <Tag\n ref={ref as never}\n className={cn(\n 'flex min-w-0',\n layout === 'stack' && 'flex-col',\n layout === 'row' && 'flex-row flex-wrap items-end',\n layout === 'grid' && `grid ${gridColumnClasses(columns)}`,\n gapResolved.className,\n className\n )}\n style={{ ...gapResolved.style, ...style }}\n {...props}\n >\n {legend && as === 'fieldset' && (\n <legend className={cn('col-span-full p-0 text-sm font-medium leading-none', legendClassName)}>{legend}</legend>\n )}\n {description && as === 'fieldset' && (\n <p className={cn('col-span-full text-xs text-muted-foreground', descriptionClassName)}>{description}</p>\n )}\n {children}\n </Tag>\n );\n }\n);\nFormLayout.displayName = 'FormLayout';\n\nexport { FormLayout };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAqFM;AArFN,YAAuB;AACvB,gBAAmB;AACnB,iBAA0C;AAI1C,MAAM,eAAuC;AAAA,EAC3C,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AACL;AAEA,MAAM,mBAAmB,CAAC,MAAM,MAAM,MAAM,IAAI;AAUhD,SAAS,kBAAkB,SAAoC;AAC7D,MAAI,OAAO,YAAY,SAAU,QAAO,aAAa,OAAO;AAC5D,SAAO;AAAA,IACL,QAAQ,SAAS,SAAY,aAAa,QAAQ,IAAI,IAAI;AAAA,IAC1D,GAAG,iBAAiB,IAAI,CAAC,OAAO;AAC9B,YAAM,QAAQ,QAAQ,EAAE;AACxB,aAAO,UAAU,SAAY,GAAG,EAAE,IAAI,aAAa,KAAK,CAAC,KAAK;AAAA,IAChE,CAAC;AAAA,EACH,EACG,OAAO,OAAO,EACd,KAAK,GAAG;AACb;AA8BA,MAAM,aAAa,MAAM;AAAA,EACvB,CACE;AAAA,IACE,SAAS;AAAA,IACT,UAAU;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,KAAK;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EACL,GACA,QACG;AACH,UAAM,MAAM;AACZ,UAAM,kBAAc,uBAAW,OAAO,IAAI;AAC1C,WACE;AAAA,MAAC;AAAA;AAAA,QACC;AAAA,QACA,eAAW;AAAA,UACT;AAAA,UACA,WAAW,WAAW;AAAA,UACtB,WAAW,SAAS;AAAA,UACpB,WAAW,UAAU,QAAQ,kBAAkB,OAAO,CAAC;AAAA,UACvD,YAAY;AAAA,UACZ;AAAA,QACF;AAAA,QACA,OAAO,EAAE,GAAG,YAAY,OAAO,GAAG,MAAM;AAAA,QACvC,GAAG;AAAA,QAEH;AAAA,oBAAU,OAAO,cAChB,4CAAC,YAAO,eAAW,cAAG,sDAAsD,eAAe,GAAI,kBAAO;AAAA,UAEvG,eAAe,OAAO,cACrB,4CAAC,OAAE,eAAW,cAAG,+CAA+C,oBAAoB,GAAI,uBAAY;AAAA,UAErG;AAAA;AAAA;AAAA,IACH;AAAA,EAEJ;AACF;AACA,WAAW,cAAc;","names":[]}
|
|
@@ -8,13 +8,26 @@ const GRID_COLUMNS = {
|
|
|
8
8
|
3: "grid-cols-3",
|
|
9
9
|
4: "grid-cols-4"
|
|
10
10
|
};
|
|
11
|
+
const GRID_BREAKPOINTS = ["sm", "md", "lg", "xl"];
|
|
12
|
+
function gridColumnClasses(columns) {
|
|
13
|
+
if (typeof columns === "number") return GRID_COLUMNS[columns];
|
|
14
|
+
return [
|
|
15
|
+
columns.base !== void 0 ? GRID_COLUMNS[columns.base] : "",
|
|
16
|
+
...GRID_BREAKPOINTS.map((bp) => {
|
|
17
|
+
const count = columns[bp];
|
|
18
|
+
return count !== void 0 ? `${bp}:${GRID_COLUMNS[count]}` : "";
|
|
19
|
+
})
|
|
20
|
+
].filter(Boolean).join(" ");
|
|
21
|
+
}
|
|
11
22
|
const FormLayout = React.forwardRef(
|
|
12
23
|
({
|
|
13
24
|
layout = "stack",
|
|
14
25
|
columns = 2,
|
|
15
26
|
gap,
|
|
16
27
|
legend,
|
|
28
|
+
legendClassName,
|
|
17
29
|
description,
|
|
30
|
+
descriptionClassName,
|
|
18
31
|
as = "div",
|
|
19
32
|
className,
|
|
20
33
|
style,
|
|
@@ -31,15 +44,15 @@ const FormLayout = React.forwardRef(
|
|
|
31
44
|
"flex min-w-0",
|
|
32
45
|
layout === "stack" && "flex-col",
|
|
33
46
|
layout === "row" && "flex-row flex-wrap items-end",
|
|
34
|
-
layout === "grid" && `grid ${
|
|
47
|
+
layout === "grid" && `grid ${gridColumnClasses(columns)}`,
|
|
35
48
|
gapResolved.className,
|
|
36
49
|
className
|
|
37
50
|
),
|
|
38
51
|
style: { ...gapResolved.style, ...style },
|
|
39
52
|
...props,
|
|
40
53
|
children: [
|
|
41
|
-
legend && as === "fieldset" && /* @__PURE__ */ jsx("legend", { className: "col-span-full p-0 text-sm font-medium leading-none", children: legend }),
|
|
42
|
-
description && as === "fieldset" && /* @__PURE__ */ jsx("p", { className: "col-span-full text-xs text-muted-foreground", children: description }),
|
|
54
|
+
legend && as === "fieldset" && /* @__PURE__ */ jsx("legend", { className: cn("col-span-full p-0 text-sm font-medium leading-none", legendClassName), children: legend }),
|
|
55
|
+
description && as === "fieldset" && /* @__PURE__ */ jsx("p", { className: cn("col-span-full text-xs text-muted-foreground", descriptionClassName), children: description }),
|
|
43
56
|
children
|
|
44
57
|
]
|
|
45
58
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/form-layout/FormLayout.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cn } from '../../utils/cn';\nimport { resolveGap, type GapValue } from '../../utils/gap';\n\n// Literal classes so Tailwind's scanner keeps them (runtime-built\n// grid-cols-${n} would be purged — same rule as Grid).\nconst GRID_COLUMNS: Record<number, string> = {\n 1: 'grid-cols-1',\n 2: 'grid-cols-2',\n 3: 'grid-cols-3',\n 4: 'grid-cols-4',\n};\n\nexport type FormLayoutProps = React.HTMLAttributes<HTMLElement> & {\n /** Grouping layout: even vertical stack (default), horizontal row, or responsive grid. */\n layout?: 'stack' | 'row' | 'grid';\n
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/form-layout/FormLayout.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cn } from '../../utils/cn';\nimport { resolveGap, type GapValue } from '../../utils/gap';\n\n// Literal classes so Tailwind's scanner keeps them (runtime-built\n// grid-cols-${n} would be purged — same rule as Grid).\nconst GRID_COLUMNS: Record<number, string> = {\n 1: 'grid-cols-1',\n 2: 'grid-cols-2',\n 3: 'grid-cols-3',\n 4: 'grid-cols-4',\n};\n\nconst GRID_BREAKPOINTS = ['sm', 'md', 'lg', 'xl'] as const;\n\n/** Column count per breakpoint; `base` applies at every width. */\nexport type FormLayoutColumns =\n | 1\n | 2\n | 3\n | 4\n | { base?: 1 | 2 | 3 | 4; sm?: 1 | 2 | 3 | 4; md?: 1 | 2 | 3 | 4; lg?: 1 | 2 | 3 | 4; xl?: 1 | 2 | 3 | 4 };\n\nfunction gridColumnClasses(columns: FormLayoutColumns): string {\n if (typeof columns === 'number') return GRID_COLUMNS[columns];\n return [\n columns.base !== undefined ? GRID_COLUMNS[columns.base] : '',\n ...GRID_BREAKPOINTS.map((bp) => {\n const count = columns[bp];\n return count !== undefined ? `${bp}:${GRID_COLUMNS[count]}` : '';\n }),\n ]\n .filter(Boolean)\n .join(' ');\n}\n\nexport type FormLayoutProps = React.HTMLAttributes<HTMLElement> & {\n /** Grouping layout: even vertical stack (default), horizontal row, or responsive grid. */\n layout?: 'stack' | 'row' | 'grid';\n /**\n * Grid column count (1-4) at every width, or per breakpoint\n * (`{ base: 1, md: 2 }`) for responsive grids without className overrides.\n */\n columns?: FormLayoutColumns;\n /** Even spacing between children — token ('md') or exact pixels (16). */\n gap?: GapValue;\n /** Group label; renders a semantic <legend> when as=\"fieldset\". */\n legend?: string;\n /** Extra classes for the legend (fieldset mode). */\n legendClassName?: string;\n /** Supporting line under the legend (fieldset mode). */\n description?: string;\n /** Extra classes for the description (fieldset mode). */\n descriptionClassName?: string;\n /** Render as a semantic fieldset (default 'div'). */\n as?: 'div' | 'fieldset';\n};\n\n/**\n * Groups form fields with even, tokenized spacing — the layout half of\n * form composition (FormField/Fieldset provide the per-control semantics).\n * stack keeps one field per row, row flows fields inline, grid spreads\n * them across columns (1-4, literal classes so they survive purging).\n */\nconst FormLayout = React.forwardRef<HTMLElement, FormLayoutProps>(\n (\n {\n layout = 'stack',\n columns = 2,\n gap,\n legend,\n legendClassName,\n description,\n descriptionClassName,\n as = 'div',\n className,\n style,\n children,\n ...props\n },\n ref,\n ) => {\n const Tag = as as 'div' | 'fieldset';\n const gapResolved = resolveGap(gap ?? 'md');\n return (\n <Tag\n ref={ref as never}\n className={cn(\n 'flex min-w-0',\n layout === 'stack' && 'flex-col',\n layout === 'row' && 'flex-row flex-wrap items-end',\n layout === 'grid' && `grid ${gridColumnClasses(columns)}`,\n gapResolved.className,\n className\n )}\n style={{ ...gapResolved.style, ...style }}\n {...props}\n >\n {legend && as === 'fieldset' && (\n <legend className={cn('col-span-full p-0 text-sm font-medium leading-none', legendClassName)}>{legend}</legend>\n )}\n {description && as === 'fieldset' && (\n <p className={cn('col-span-full text-xs text-muted-foreground', descriptionClassName)}>{description}</p>\n )}\n {children}\n </Tag>\n );\n }\n);\nFormLayout.displayName = 'FormLayout';\n\nexport { FormLayout };\n"],"mappings":"AAqFM,SAcI,KAdJ;AArFN,YAAY,WAAW;AACvB,SAAS,UAAU;AACnB,SAAS,kBAAiC;AAI1C,MAAM,eAAuC;AAAA,EAC3C,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GA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18,6 +18,8 @@ export type ImageProps = {
|
|
|
18
18
|
className?: string;
|
|
19
19
|
/** Classes for the image when a consumer wants to keep them separate. */
|
|
20
20
|
imgClassName?: string;
|
|
21
|
+
/** Responsive `sizes` hint for the browser's source selection. */
|
|
22
|
+
sizes?: string;
|
|
21
23
|
style?: React.CSSProperties;
|
|
22
24
|
};
|
|
23
25
|
/**
|
|
@@ -28,7 +30,7 @@ export type ImageProps = {
|
|
|
28
30
|
* intrinsic dimensions are always rendered and only the priority image is
|
|
29
31
|
* eager.
|
|
30
32
|
*/
|
|
31
|
-
export declare function Image({ src, alt, fallbackSrc, fallback, priority, width, height, className, imgClassName, style, }: ImageProps): React.JSX.Element;
|
|
33
|
+
export declare function Image({ src, alt, fallbackSrc, fallback, priority, width, height, className, imgClassName, sizes, style, }: ImageProps): React.JSX.Element;
|
|
32
34
|
export declare namespace Image {
|
|
33
35
|
var displayName: string;
|
|
34
36
|
}
|
|
@@ -45,6 +45,7 @@ function Image({
|
|
|
45
45
|
height = 630,
|
|
46
46
|
className,
|
|
47
47
|
imgClassName,
|
|
48
|
+
sizes,
|
|
48
49
|
style
|
|
49
50
|
}) {
|
|
50
51
|
const [stage, setStage] = React.useState(0);
|
|
@@ -66,6 +67,7 @@ function Image({
|
|
|
66
67
|
loading: priority ? "eager" : "lazy",
|
|
67
68
|
fetchPriority: priority ? "high" : "auto",
|
|
68
69
|
decoding: "async",
|
|
70
|
+
sizes,
|
|
69
71
|
className: (0, import_cn.cn)(className, imgClassName),
|
|
70
72
|
style,
|
|
71
73
|
onError
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/image/Image.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { cn } from '../../utils/cn';\n\nexport type ImageProps = {\n /** Primary image URL. Hotlinked sources are expected. */\n src: string;\n /** Required: describes the image, not the component. */\n alt: string;\n /** Second chance before the fallback node (e.g. generated placeholder art). */\n fallbackSrc?: string;\n /** Rendered when every URL has failed (icon, initials, empty panel). */\n fallback?: React.ReactNode;\n /** Load eagerly and fetch at high priority for the LCP image. */\n priority?: boolean;\n /** Intrinsic width; always emitted so the browser reserves space. */\n width?: number;\n /** Intrinsic height; always emitted so the browser reserves space. */\n height?: number;\n /** Classes for the image; merged with imgClassName. */\n className?: string;\n /** Classes for the image when a consumer wants to keep them separate. */\n imgClassName?: string;\n style?: React.CSSProperties;\n};\n\n/**\n * Resilient image: `src` -> `fallbackSrc` -> `fallback` node.\n *\n * Organizer images are hotlinked and occasionally 403, move, or die. Cards\n * must never show a broken-image box or shift layout when that happens, so\n * intrinsic dimensions are always rendered and only the priority image is\n * eager.\n */\nexport function Image({\n src,\n alt,\n fallbackSrc,\n fallback,\n priority = false,\n width = 1200,\n height = 630,\n className,\n imgClassName,\n style,\n}: ImageProps) {\n const [stage, setStage] = React.useState<0 | 1 | 2>(0);\n // Restart the src -> fallbackSrc -> fallback chain whenever the URLs\n // change, so a reused component never sticks on a stale fallback.\n const [prevUrls, setPrevUrls] = React.useState({ src, fallbackSrc });\n if (prevUrls.src !== src || prevUrls.fallbackSrc !== fallbackSrc) {\n setPrevUrls({ src, fallbackSrc });\n setStage(0);\n }\n\n const onError = () => setStage((current) => (current === 0 && fallbackSrc ? 1 : 2));\n const current = stage === 0 ? src : stage === 1 ? fallbackSrc : null;\n\n if (!current || stage === 2) return <>{fallback ?? null}</>;\n\n return (\n <img\n src={current}\n alt={alt}\n width={width}\n height={height}\n loading={priority ? 'eager' : 'lazy'}\n fetchPriority={priority ? 'high' : 'auto'}\n decoding=\"async\"\n className={cn(className, imgClassName)}\n style={style}\n onError={onError}\n />\n );\n}\n\nImage.displayName = 'Image';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/image/Image.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { cn } from '../../utils/cn';\n\nexport type ImageProps = {\n /** Primary image URL. Hotlinked sources are expected. */\n src: string;\n /** Required: describes the image, not the component. */\n alt: string;\n /** Second chance before the fallback node (e.g. generated placeholder art). */\n fallbackSrc?: string;\n /** Rendered when every URL has failed (icon, initials, empty panel). */\n fallback?: React.ReactNode;\n /** Load eagerly and fetch at high priority for the LCP image. */\n priority?: boolean;\n /** Intrinsic width; always emitted so the browser reserves space. */\n width?: number;\n /** Intrinsic height; always emitted so the browser reserves space. */\n height?: number;\n /** Classes for the image; merged with imgClassName. */\n className?: string;\n /** Classes for the image when a consumer wants to keep them separate. */\n imgClassName?: string;\n /** Responsive `sizes` hint for the browser's source selection. */\n sizes?: string;\n style?: React.CSSProperties;\n};\n\n/**\n * Resilient image: `src` -> `fallbackSrc` -> `fallback` node.\n *\n * Organizer images are hotlinked and occasionally 403, move, or die. Cards\n * must never show a broken-image box or shift layout when that happens, so\n * intrinsic dimensions are always rendered and only the priority image is\n * eager.\n */\nexport function Image({\n src,\n alt,\n fallbackSrc,\n fallback,\n priority = false,\n width = 1200,\n height = 630,\n className,\n imgClassName,\n sizes,\n style,\n}: ImageProps) {\n const [stage, setStage] = React.useState<0 | 1 | 2>(0);\n // Restart the src -> fallbackSrc -> fallback chain whenever the URLs\n // change, so a reused component never sticks on a stale fallback.\n const [prevUrls, setPrevUrls] = React.useState({ src, fallbackSrc });\n if (prevUrls.src !== src || prevUrls.fallbackSrc !== fallbackSrc) {\n setPrevUrls({ src, fallbackSrc });\n setStage(0);\n }\n\n const onError = () => setStage((current) => (current === 0 && fallbackSrc ? 1 : 2));\n const current = stage === 0 ? src : stage === 1 ? fallbackSrc : null;\n\n if (!current || stage === 2) return <>{fallback ?? null}</>;\n\n return (\n <img\n src={current}\n alt={alt}\n width={width}\n height={height}\n loading={priority ? 'eager' : 'lazy'}\n fetchPriority={priority ? 'high' : 'auto'}\n decoding=\"async\"\n sizes={sizes}\n className={cn(className, imgClassName)}\n style={style}\n onError={onError}\n />\n );\n}\n\nImage.displayName = 'Image';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA8DsC;AA5DtC,YAAuB;AACvB,gBAAmB;AAkCZ,SAAS,MAAM;AAAA,EACpB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,WAAW;AAAA,EACX,QAAQ;AAAA,EACR,SAAS;AAAA,EACT;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAAe;AACb,QAAM,CAAC,OAAO,QAAQ,IAAI,MAAM,SAAoB,CAAC;AAGrD,QAAM,CAAC,UAAU,WAAW,IAAI,MAAM,SAAS,EAAE,KAAK,YAAY,CAAC;AACnE,MAAI,SAAS,QAAQ,OAAO,SAAS,gBAAgB,aAAa;AAChE,gBAAY,EAAE,KAAK,YAAY,CAAC;AAChC,aAAS,CAAC;AAAA,EACZ;AAEA,QAAM,UAAU,MAAM,SAAS,CAACA,aAAaA,aAAY,KAAK,cAAc,IAAI,CAAE;AAClF,QAAM,UAAU,UAAU,IAAI,MAAM,UAAU,IAAI,cAAc;AAEhE,MAAI,CAAC,WAAW,UAAU,EAAG,QAAO,2EAAG,sBAAY,MAAK;AAExD,SACE;AAAA,IAAC;AAAA;AAAA,MACC,KAAK;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA,SAAS,WAAW,UAAU;AAAA,MAC9B,eAAe,WAAW,SAAS;AAAA,MACnC,UAAS;AAAA,MACT;AAAA,MACA,eAAW,cAAG,WAAW,YAAY;AAAA,MACrC;AAAA,MACA;AAAA;AAAA,EACF;AAEJ;AAEA,MAAM,cAAc;","names":["current"]}
|
|
@@ -12,6 +12,7 @@ function Image({
|
|
|
12
12
|
height = 630,
|
|
13
13
|
className,
|
|
14
14
|
imgClassName,
|
|
15
|
+
sizes,
|
|
15
16
|
style
|
|
16
17
|
}) {
|
|
17
18
|
const [stage, setStage] = React.useState(0);
|
|
@@ -33,6 +34,7 @@ function Image({
|
|
|
33
34
|
loading: priority ? "eager" : "lazy",
|
|
34
35
|
fetchPriority: priority ? "high" : "auto",
|
|
35
36
|
decoding: "async",
|
|
37
|
+
sizes,
|
|
36
38
|
className: cn(className, imgClassName),
|
|
37
39
|
style,
|
|
38
40
|
onError
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/image/Image.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { cn } from '../../utils/cn';\n\nexport type ImageProps = {\n /** Primary image URL. Hotlinked sources are expected. */\n src: string;\n /** Required: describes the image, not the component. */\n alt: string;\n /** Second chance before the fallback node (e.g. generated placeholder art). */\n fallbackSrc?: string;\n /** Rendered when every URL has failed (icon, initials, empty panel). */\n fallback?: React.ReactNode;\n /** Load eagerly and fetch at high priority for the LCP image. */\n priority?: boolean;\n /** Intrinsic width; always emitted so the browser reserves space. */\n width?: number;\n /** Intrinsic height; always emitted so the browser reserves space. */\n height?: number;\n /** Classes for the image; merged with imgClassName. */\n className?: string;\n /** Classes for the image when a consumer wants to keep them separate. */\n imgClassName?: string;\n style?: React.CSSProperties;\n};\n\n/**\n * Resilient image: `src` -> `fallbackSrc` -> `fallback` node.\n *\n * Organizer images are hotlinked and occasionally 403, move, or die. Cards\n * must never show a broken-image box or shift layout when that happens, so\n * intrinsic dimensions are always rendered and only the priority image is\n * eager.\n */\nexport function Image({\n src,\n alt,\n fallbackSrc,\n fallback,\n priority = false,\n width = 1200,\n height = 630,\n className,\n imgClassName,\n style,\n}: ImageProps) {\n const [stage, setStage] = React.useState<0 | 1 | 2>(0);\n // Restart the src -> fallbackSrc -> fallback chain whenever the URLs\n // change, so a reused component never sticks on a stale fallback.\n const [prevUrls, setPrevUrls] = React.useState({ src, fallbackSrc });\n if (prevUrls.src !== src || prevUrls.fallbackSrc !== fallbackSrc) {\n setPrevUrls({ src, fallbackSrc });\n setStage(0);\n }\n\n const onError = () => setStage((current) => (current === 0 && fallbackSrc ? 1 : 2));\n const current = stage === 0 ? src : stage === 1 ? fallbackSrc : null;\n\n if (!current || stage === 2) return <>{fallback ?? null}</>;\n\n return (\n <img\n src={current}\n alt={alt}\n width={width}\n height={height}\n loading={priority ? 'eager' : 'lazy'}\n fetchPriority={priority ? 'high' : 'auto'}\n decoding=\"async\"\n className={cn(className, imgClassName)}\n style={style}\n onError={onError}\n />\n );\n}\n\nImage.displayName = 'Image';\n"],"mappings":";
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/image/Image.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { cn } from '../../utils/cn';\n\nexport type ImageProps = {\n /** Primary image URL. Hotlinked sources are expected. */\n src: string;\n /** Required: describes the image, not the component. */\n alt: string;\n /** Second chance before the fallback node (e.g. generated placeholder art). */\n fallbackSrc?: string;\n /** Rendered when every URL has failed (icon, initials, empty panel). */\n fallback?: React.ReactNode;\n /** Load eagerly and fetch at high priority for the LCP image. */\n priority?: boolean;\n /** Intrinsic width; always emitted so the browser reserves space. */\n width?: number;\n /** Intrinsic height; always emitted so the browser reserves space. */\n height?: number;\n /** Classes for the image; merged with imgClassName. */\n className?: string;\n /** Classes for the image when a consumer wants to keep them separate. */\n imgClassName?: string;\n /** Responsive `sizes` hint for the browser's source selection. */\n sizes?: string;\n style?: React.CSSProperties;\n};\n\n/**\n * Resilient image: `src` -> `fallbackSrc` -> `fallback` node.\n *\n * Organizer images are hotlinked and occasionally 403, move, or die. Cards\n * must never show a broken-image box or shift layout when that happens, so\n * intrinsic dimensions are always rendered and only the priority image is\n * eager.\n */\nexport function Image({\n src,\n alt,\n fallbackSrc,\n fallback,\n priority = false,\n width = 1200,\n height = 630,\n className,\n imgClassName,\n sizes,\n style,\n}: ImageProps) {\n const [stage, setStage] = React.useState<0 | 1 | 2>(0);\n // Restart the src -> fallbackSrc -> fallback chain whenever the URLs\n // change, so a reused component never sticks on a stale fallback.\n const [prevUrls, setPrevUrls] = React.useState({ src, fallbackSrc });\n if (prevUrls.src !== src || prevUrls.fallbackSrc !== fallbackSrc) {\n setPrevUrls({ src, fallbackSrc });\n setStage(0);\n }\n\n const onError = () => setStage((current) => (current === 0 && fallbackSrc ? 1 : 2));\n const current = stage === 0 ? src : stage === 1 ? fallbackSrc : null;\n\n if (!current || stage === 2) return <>{fallback ?? null}</>;\n\n return (\n <img\n src={current}\n alt={alt}\n width={width}\n height={height}\n loading={priority ? 'eager' : 'lazy'}\n fetchPriority={priority ? 'high' : 'auto'}\n decoding=\"async\"\n sizes={sizes}\n className={cn(className, imgClassName)}\n style={style}\n onError={onError}\n />\n );\n}\n\nImage.displayName = 'Image';\n"],"mappings":";AA8DsC;AA5DtC,YAAY,WAAW;AACvB,SAAS,UAAU;AAkCZ,SAAS,MAAM;AAAA,EACpB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,WAAW;AAAA,EACX,QAAQ;AAAA,EACR,SAAS;AAAA,EACT;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAAe;AACb,QAAM,CAAC,OAAO,QAAQ,IAAI,MAAM,SAAoB,CAAC;AAGrD,QAAM,CAAC,UAAU,WAAW,IAAI,MAAM,SAAS,EAAE,KAAK,YAAY,CAAC;AACnE,MAAI,SAAS,QAAQ,OAAO,SAAS,gBAAgB,aAAa;AAChE,gBAAY,EAAE,KAAK,YAAY,CAAC;AAChC,aAAS,CAAC;AAAA,EACZ;AAEA,QAAM,UAAU,MAAM,SAAS,CAACA,aAAaA,aAAY,KAAK,cAAc,IAAI,CAAE;AAClF,QAAM,UAAU,UAAU,IAAI,MAAM,UAAU,IAAI,cAAc;AAEhE,MAAI,CAAC,WAAW,UAAU,EAAG,QAAO,gCAAG,sBAAY,MAAK;AAExD,SACE;AAAA,IAAC;AAAA;AAAA,MACC,KAAK;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA,SAAS,WAAW,UAAU;AAAA,MAC9B,eAAe,WAAW,SAAS;AAAA,MACnC,UAAS;AAAA,MACT;AAAA,MACA,WAAW,GAAG,WAAW,YAAY;AAAA,MACrC;AAAA,MACA;AAAA;AAAA,EACF;AAEJ;AAEA,MAAM,cAAc;","names":["current"]}
|
|
@@ -5,6 +5,13 @@ export type SegmentedOption = {
|
|
|
5
5
|
/** Optional leading icon. */
|
|
6
6
|
icon?: React.ReactNode;
|
|
7
7
|
disabled?: boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Destination URL. When set the segment renders as a link instead of a
|
|
10
|
+
* button - use this for view switches that must survive refresh and work
|
|
11
|
+
* without JavaScript. The active segment renders as a non-link
|
|
12
|
+
* `aria-current="page"` marker.
|
|
13
|
+
*/
|
|
14
|
+
href?: string;
|
|
8
15
|
};
|
|
9
16
|
export type SegmentedControlProps = Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange'> & {
|
|
10
17
|
/** Options rendered as segments. */
|
|
@@ -21,12 +28,22 @@ export type SegmentedControlProps = Omit<React.HTMLAttributes<HTMLDivElement>, '
|
|
|
21
28
|
size?: 'sm' | 'md' | 'lg';
|
|
22
29
|
/** Stretch segments to fill the container width. */
|
|
23
30
|
fullWidth?: boolean;
|
|
31
|
+
/** Custom link element for routers (Next Link, react-router Link). */
|
|
32
|
+
linkComponent?: React.ElementType;
|
|
33
|
+
/** Prop used to pass the destination to `linkComponent`. */
|
|
34
|
+
linkHrefProp?: 'href' | 'to';
|
|
24
35
|
};
|
|
25
36
|
/**
|
|
26
37
|
* Segmented control for switching a view or filter. Single-select uses radio
|
|
27
38
|
* semantics and arrow-key navigation; multiple-select uses pressed buttons.
|
|
28
39
|
* Use it for filters such as All / Investors / Advisors, not for tab panels
|
|
29
40
|
* (use Tabs when each segment owns a tabpanel).
|
|
41
|
+
*
|
|
42
|
+
* Give an option an `href` to render it as a real link - the pattern for
|
|
43
|
+
* view switches that must survive refresh, work without JavaScript, and stay
|
|
44
|
+
* cacheable. The active segment then renders as a non-link
|
|
45
|
+
* `aria-current="page"` marker and link segments use normal tab navigation
|
|
46
|
+
* instead of roving tabindex. Link mode is intended for single-select.
|
|
30
47
|
*/
|
|
31
48
|
export declare const SegmentedControl: React.ForwardRefExoticComponent<Omit<React.HTMLAttributes<HTMLDivElement>, "onChange"> & {
|
|
32
49
|
/** Options rendered as segments. */
|
|
@@ -43,4 +60,8 @@ export declare const SegmentedControl: React.ForwardRefExoticComponent<Omit<Reac
|
|
|
43
60
|
size?: "sm" | "md" | "lg";
|
|
44
61
|
/** Stretch segments to fill the container width. */
|
|
45
62
|
fullWidth?: boolean;
|
|
63
|
+
/** Custom link element for routers (Next Link, react-router Link). */
|
|
64
|
+
linkComponent?: React.ElementType;
|
|
65
|
+
/** Prop used to pass the destination to `linkComponent`. */
|
|
66
|
+
linkHrefProp?: "href" | "to";
|
|
46
67
|
} & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -49,6 +49,8 @@ const SegmentedControl = React.forwardRef(
|
|
|
49
49
|
multiple = false,
|
|
50
50
|
size = "md",
|
|
51
51
|
fullWidth = false,
|
|
52
|
+
linkComponent,
|
|
53
|
+
linkHrefProp = "href",
|
|
52
54
|
className,
|
|
53
55
|
"aria-label": ariaLabel = "Segmented control",
|
|
54
56
|
...props
|
|
@@ -59,6 +61,9 @@ const SegmentedControl = React.forwardRef(
|
|
|
59
61
|
);
|
|
60
62
|
const current = isControlled ? value : internal;
|
|
61
63
|
const selected = multiple ? Array.isArray(current) ? current : [] : typeof current === "string" ? current : "";
|
|
64
|
+
const linkMode = options.some((option) => option.href !== void 0);
|
|
65
|
+
const LinkEl = linkComponent ?? "a";
|
|
66
|
+
const destination = (href) => linkHrefProp === "to" ? { to: href } : { href };
|
|
62
67
|
const refs = React.useRef([]);
|
|
63
68
|
const commit = (next) => {
|
|
64
69
|
if (!isControlled) setInternal(next);
|
|
@@ -113,7 +118,7 @@ const SegmentedControl = React.forwardRef(
|
|
|
113
118
|
"div",
|
|
114
119
|
{
|
|
115
120
|
ref,
|
|
116
|
-
role: multiple ? "group" : "radiogroup",
|
|
121
|
+
role: multiple || linkMode ? "group" : "radiogroup",
|
|
117
122
|
"aria-label": ariaLabel,
|
|
118
123
|
className: (0, import_cn.cn)(
|
|
119
124
|
"inline-flex items-center gap-1 rounded-lg border border-border bg-muted p-1",
|
|
@@ -125,32 +130,58 @@ const SegmentedControl = React.forwardRef(
|
|
|
125
130
|
const active = multiple ? Array.isArray(selected) && selected.includes(option.value) : selected === option.value;
|
|
126
131
|
const firstEnabled = options.findIndex((entry) => !entry.disabled);
|
|
127
132
|
const focusable = multiple || active || !selected && index === firstEnabled;
|
|
128
|
-
|
|
133
|
+
const segmentClass = (0, import_cn.cn)(
|
|
134
|
+
"inline-flex items-center justify-center gap-2 rounded-md font-medium transition-colors",
|
|
135
|
+
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background",
|
|
136
|
+
"disabled:pointer-events-none disabled:opacity-50",
|
|
137
|
+
sizeClasses[size],
|
|
138
|
+
fullWidth && "flex-1",
|
|
139
|
+
active ? "bg-background text-foreground shadow-sm" : "text-muted-foreground hover:text-foreground"
|
|
140
|
+
);
|
|
141
|
+
const segmentContent = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
142
|
+
option.icon && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "shrink-0 [&_svg]:size-4", children: option.icon }),
|
|
143
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "truncate", children: option.label })
|
|
144
|
+
] });
|
|
145
|
+
if (option.href !== void 0) {
|
|
146
|
+
if (option.disabled || active) {
|
|
147
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
148
|
+
"span",
|
|
149
|
+
{
|
|
150
|
+
"aria-current": active ? "page" : void 0,
|
|
151
|
+
"aria-disabled": option.disabled || void 0,
|
|
152
|
+
className: (0, import_cn.cn)(segmentClass, option.disabled && "opacity-50"),
|
|
153
|
+
children: segmentContent
|
|
154
|
+
},
|
|
155
|
+
option.value
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
159
|
+
LinkEl,
|
|
160
|
+
{
|
|
161
|
+
...destination(option.href),
|
|
162
|
+
className: segmentClass,
|
|
163
|
+
children: segmentContent
|
|
164
|
+
},
|
|
165
|
+
option.value
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
129
169
|
"button",
|
|
130
170
|
{
|
|
131
171
|
ref: (node) => {
|
|
132
172
|
refs.current[index] = node;
|
|
133
173
|
},
|
|
134
174
|
type: "button",
|
|
135
|
-
role: multiple ? void 0 : "radio",
|
|
136
|
-
"aria-checked": multiple ? void 0 : active,
|
|
175
|
+
role: multiple || linkMode ? void 0 : "radio",
|
|
176
|
+
"aria-checked": multiple || linkMode ? void 0 : active,
|
|
137
177
|
"aria-pressed": multiple ? active : void 0,
|
|
178
|
+
"aria-current": linkMode && active ? "page" : void 0,
|
|
138
179
|
disabled: option.disabled,
|
|
139
180
|
tabIndex: focusable ? 0 : -1,
|
|
140
181
|
onClick: () => select(option),
|
|
141
182
|
onKeyDown,
|
|
142
|
-
className:
|
|
143
|
-
|
|
144
|
-
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background",
|
|
145
|
-
"disabled:pointer-events-none disabled:opacity-50",
|
|
146
|
-
sizeClasses[size],
|
|
147
|
-
fullWidth && "flex-1",
|
|
148
|
-
active ? "bg-background text-foreground shadow-sm" : "text-muted-foreground hover:text-foreground"
|
|
149
|
-
),
|
|
150
|
-
children: [
|
|
151
|
-
option.icon && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "shrink-0 [&_svg]:size-4", children: option.icon }),
|
|
152
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "truncate", children: option.label })
|
|
153
|
-
]
|
|
183
|
+
className: segmentClass,
|
|
184
|
+
children: segmentContent
|
|
154
185
|
},
|
|
155
186
|
option.value
|
|
156
187
|
);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/segmented-control/SegmentedControl.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { cn } from '../../utils/cn';\n\nexport type SegmentedOption = {\n value: string;\n label: React.ReactNode;\n /** Optional leading icon. */\n icon?: React.ReactNode;\n disabled?: boolean;\n};\n\nexport type SegmentedControlProps = Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange'> & {\n /** Options rendered as segments. */\n options: SegmentedOption[];\n /** Controlled selected value. Use string[] when multiple. */\n value?: string | string[];\n /** Initial selection when uncontrolled. */\n defaultValue?: string | string[];\n /** Fires with the next selection. */\n onValueChange?: (value: string | string[]) => void;\n /** Allow more than one segment to be active. Default false. */\n multiple?: boolean;\n /** Control density. Default 'md'. */\n size?: 'sm' | 'md' | 'lg';\n /** Stretch segments to fill the container width. */\n fullWidth?: boolean;\n};\n\nconst sizeClasses = {\n sm: 'h-8 px-2.5 text-xs',\n md: 'h-9 px-3 text-sm',\n lg: 'h-10 px-4 text-sm',\n} as const;\n\n/**\n * Segmented control for switching a view or filter. Single-select uses radio\n * semantics and arrow-key navigation; multiple-select uses pressed buttons.\n * Use it for filters such as All / Investors / Advisors, not for tab panels\n * (use Tabs when each segment owns a tabpanel).\n */\nexport const SegmentedControl = React.forwardRef<HTMLDivElement, SegmentedControlProps>(\n function SegmentedControl(\n {\n options,\n value,\n defaultValue,\n onValueChange,\n multiple = false,\n size = 'md',\n fullWidth = false,\n className,\n 'aria-label': ariaLabel = 'Segmented control',\n ...props\n },\n ref\n ) {\n const isControlled = value !== undefined;\n const [internal, setInternal] = React.useState<string | string[]>(() =>\n multiple\n ? Array.isArray(defaultValue)\n ? defaultValue\n : []\n : typeof defaultValue === 'string'\n ? defaultValue\n : ''\n );\n const current = isControlled ? value : internal;\n const selected = multiple\n ? Array.isArray(current)\n ? current\n : []\n : typeof current === 'string'\n ? current\n : '';\n\n const refs = React.useRef<Array<HTMLButtonElement | null>>([]);\n\n const commit = (next: string | string[]) => {\n if (!isControlled) setInternal(next);\n onValueChange?.(next);\n };\n\n const select = (option: SegmentedOption) => {\n if (option.disabled) return;\n if (multiple) {\n const currentValues = Array.isArray(selected) ? selected : [];\n commit(\n currentValues.includes(option.value)\n ? currentValues.filter((entry) => entry !== option.value)\n : [...currentValues, option.value]\n );\n } else {\n commit(option.value);\n }\n };\n\n const moveFocus = (direction: 1 | -1 | 'first' | 'last') => {\n if (multiple) return;\n const enabled = options\n .map((option, index) => ({ option, index }))\n .filter(({ option }) => !option.disabled);\n if (enabled.length === 0) return;\n const activeValue = typeof selected === 'string' ? selected : '';\n const currentIndex = enabled.findIndex(({ option }) => option.value === activeValue);\n let nextIndex: number;\n if (direction === 'first') nextIndex = 0;\n else if (direction === 'last') nextIndex = enabled.length - 1;\n else {\n const from = currentIndex === -1 ? 0 : currentIndex;\n nextIndex = (from + direction + enabled.length) % enabled.length;\n }\n const next = enabled[nextIndex];\n if (!next) return;\n commit(next.option.value);\n refs.current[next.index]?.focus();\n };\n\n const onKeyDown = (event: React.KeyboardEvent<HTMLButtonElement>) => {\n if (multiple) return;\n if (event.key === 'ArrowRight' || event.key === 'ArrowDown') {\n event.preventDefault();\n moveFocus(1);\n } else if (event.key === 'ArrowLeft' || event.key === 'ArrowUp') {\n event.preventDefault();\n moveFocus(-1);\n } else if (event.key === 'Home') {\n event.preventDefault();\n moveFocus('first');\n } else if (event.key === 'End') {\n event.preventDefault();\n moveFocus('last');\n }\n };\n\n return (\n <div\n ref={ref}\n role={multiple ? 'group' : 'radiogroup'}\n aria-label={ariaLabel}\n className={cn(\n 'inline-flex items-center gap-1 rounded-lg border border-border bg-muted p-1',\n fullWidth && 'flex w-full',\n className\n )}\n {...props}\n >\n {options.map((option, index) => {\n const active = multiple\n ? Array.isArray(selected) && selected.includes(option.value)\n : selected === option.value;\n const firstEnabled = options.findIndex((entry) => !entry.disabled);\n const focusable = multiple || active || (!selected && index === firstEnabled);\n\n return (\n <button\n key={option.value}\n ref={(node) => {\n refs.current[index] = node;\n }}\n type=\"button\"\n role={multiple ? undefined : 'radio'}\n aria-checked={multiple ? undefined : active}\n aria-pressed={multiple ? active : undefined}\n disabled={option.disabled}\n tabIndex={focusable ? 0 : -1}\n onClick={() => select(option)}\n onKeyDown={onKeyDown}\n className={cn(\n 'inline-flex items-center justify-center gap-2 rounded-md font-medium transition-colors',\n 'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background',\n 'disabled:pointer-events-none disabled:opacity-50',\n sizeClasses[size],\n fullWidth && 'flex-1',\n active\n ? 'bg-background text-foreground shadow-sm'\n : 'text-muted-foreground hover:text-foreground'\n )}\n >\n {option.icon && <span className=\"shrink-0 [&_svg]:size-4\">{option.icon}</span>}\n <span className=\"truncate\">{option.label}</span>\n </button>\n );\n })}\n </div>\n );\n }\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA4JY;AA1JZ,YAAuB;AACvB,gBAAmB;AA2BnB,MAAM,cAAc;AAAA,EAClB,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AACN;AAQO,MAAM,mBAAmB,MAAM;AAAA,EACpC,SAASA,kBACP;AAAA,IACE;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,WAAW;AAAA,IACX,OAAO;AAAA,IACP,YAAY;AAAA,IACZ;AAAA,IACA,cAAc,YAAY;AAAA,IAC1B,GAAG;AAAA,EACL,GACA,KACA;AACA,UAAM,eAAe,UAAU;AAC/B,UAAM,CAAC,UAAU,WAAW,IAAI,MAAM;AAAA,MAA4B,MAChE,WACI,MAAM,QAAQ,YAAY,IACxB,eACA,CAAC,IACH,OAAO,iBAAiB,WACtB,eACA;AAAA,IACR;AACA,UAAM,UAAU,eAAe,QAAQ;AACvC,UAAM,WAAW,WACb,MAAM,QAAQ,OAAO,IACnB,UACA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AAA,cAEC;AAAA,uBAAO,QAAQ,4CAAC,UAAK,WAAU,2BAA2B,iBAAO,MAAK;AAAA,gBACvE,4CAAC,UAAK,WAAU,YAAY,iBAAO,OAAM;AAAA;AAAA;AAAA,YAxBpC,OAAO;AAAA,UAyBd;AAAA,QAEJ,CAAC;AAAA;AAAA,IACH;AAAA,EAEJ;AACF;","names":["SegmentedControl"]}
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/segmented-control/SegmentedControl.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { cn } from '../../utils/cn';\n\nexport type SegmentedOption = {\n value: string;\n label: React.ReactNode;\n /** Optional leading icon. */\n icon?: React.ReactNode;\n disabled?: boolean;\n /**\n * Destination URL. When set the segment renders as a link instead of a\n * button - use this for view switches that must survive refresh and work\n * without JavaScript. The active segment renders as a non-link\n * `aria-current=\"page\"` marker.\n */\n href?: string;\n};\n\nexport type SegmentedControlProps = Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange'> & {\n /** Options rendered as segments. */\n options: SegmentedOption[];\n /** Controlled selected value. Use string[] when multiple. */\n value?: string | string[];\n /** Initial selection when uncontrolled. */\n defaultValue?: string | string[];\n /** Fires with the next selection. */\n onValueChange?: (value: string | string[]) => void;\n /** Allow more than one segment to be active. Default false. */\n multiple?: boolean;\n /** Control density. Default 'md'. */\n size?: 'sm' | 'md' | 'lg';\n /** Stretch segments to fill the container width. */\n fullWidth?: boolean;\n /** Custom link element for routers (Next Link, react-router Link). */\n linkComponent?: React.ElementType;\n /** Prop used to pass the destination to `linkComponent`. */\n linkHrefProp?: 'href' | 'to';\n};\n\nconst sizeClasses = {\n sm: 'h-8 px-2.5 text-xs',\n md: 'h-9 px-3 text-sm',\n lg: 'h-10 px-4 text-sm',\n} as const;\n\n/**\n * Segmented control for switching a view or filter. Single-select uses radio\n * semantics and arrow-key navigation; multiple-select uses pressed buttons.\n * Use it for filters such as All / Investors / Advisors, not for tab panels\n * (use Tabs when each segment owns a tabpanel).\n *\n * Give an option an `href` to render it as a real link - the pattern for\n * view switches that must survive refresh, work without JavaScript, and stay\n * cacheable. The active segment then renders as a non-link\n * `aria-current=\"page\"` marker and link segments use normal tab navigation\n * instead of roving tabindex. Link mode is intended for single-select.\n */\nexport const SegmentedControl = React.forwardRef<HTMLDivElement, SegmentedControlProps>(\n function SegmentedControl(\n {\n options,\n value,\n defaultValue,\n onValueChange,\n multiple = false,\n size = 'md',\n fullWidth = false,\n linkComponent,\n linkHrefProp = 'href',\n className,\n 'aria-label': ariaLabel = 'Segmented control',\n ...props\n },\n ref\n ) {\n const isControlled = value !== undefined;\n const [internal, setInternal] = React.useState<string | string[]>(() =>\n multiple\n ? Array.isArray(defaultValue)\n ? defaultValue\n : []\n : typeof defaultValue === 'string'\n ? defaultValue\n : ''\n );\n const current = isControlled ? value : internal;\n const selected = multiple\n ? Array.isArray(current)\n ? current\n : []\n : typeof current === 'string'\n ? current\n : '';\n\n const linkMode = options.some((option) => option.href !== undefined);\n const LinkEl = linkComponent ?? 'a';\n const destination = (href: string) => (linkHrefProp === 'to' ? { to: href } : { href });\n\n const refs = React.useRef<Array<HTMLButtonElement | null>>([]);\n\n const commit = (next: string | string[]) => {\n if (!isControlled) setInternal(next);\n onValueChange?.(next);\n };\n\n const select = (option: SegmentedOption) => {\n if (option.disabled) return;\n if (multiple) {\n const currentValues = Array.isArray(selected) ? selected : [];\n commit(\n currentValues.includes(option.value)\n ? currentValues.filter((entry) => entry !== option.value)\n : [...currentValues, option.value]\n );\n } else {\n commit(option.value);\n }\n };\n\n const moveFocus = (direction: 1 | -1 | 'first' | 'last') => {\n if (multiple) return;\n const enabled = options\n .map((option, index) => ({ option, index }))\n .filter(({ option }) => !option.disabled);\n if (enabled.length === 0) return;\n const activeValue = typeof selected === 'string' ? selected : '';\n const currentIndex = enabled.findIndex(({ option }) => option.value === activeValue);\n let nextIndex: number;\n if (direction === 'first') nextIndex = 0;\n else if (direction === 'last') nextIndex = enabled.length - 1;\n else {\n const from = currentIndex === -1 ? 0 : currentIndex;\n nextIndex = (from + direction + enabled.length) % enabled.length;\n }\n const next = enabled[nextIndex];\n if (!next) return;\n commit(next.option.value);\n refs.current[next.index]?.focus();\n };\n\n const onKeyDown = (event: React.KeyboardEvent<HTMLButtonElement>) => {\n if (multiple) return;\n if (event.key === 'ArrowRight' || event.key === 'ArrowDown') {\n event.preventDefault();\n moveFocus(1);\n } else if (event.key === 'ArrowLeft' || event.key === 'ArrowUp') {\n event.preventDefault();\n moveFocus(-1);\n } else if (event.key === 'Home') {\n event.preventDefault();\n moveFocus('first');\n } else if (event.key === 'End') {\n event.preventDefault();\n moveFocus('last');\n }\n };\n\n return (\n <div\n ref={ref}\n role={multiple || linkMode ? 'group' : 'radiogroup'}\n aria-label={ariaLabel}\n className={cn(\n 'inline-flex items-center gap-1 rounded-lg border border-border bg-muted p-1',\n fullWidth && 'flex w-full',\n className\n )}\n {...props}\n >\n {options.map((option, index) => {\n const active = multiple\n ? Array.isArray(selected) && selected.includes(option.value)\n : selected === option.value;\n const firstEnabled = options.findIndex((entry) => !entry.disabled);\n const focusable = multiple || active || (!selected && index === firstEnabled);\n const segmentClass = cn(\n 'inline-flex items-center justify-center gap-2 rounded-md font-medium transition-colors',\n 'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background',\n 'disabled:pointer-events-none disabled:opacity-50',\n sizeClasses[size],\n fullWidth && 'flex-1',\n active\n ? 'bg-background text-foreground shadow-sm'\n : 'text-muted-foreground hover:text-foreground'\n );\n const segmentContent = (\n <>\n {option.icon && <span className=\"shrink-0 [&_svg]:size-4\">{option.icon}</span>}\n <span className=\"truncate\">{option.label}</span>\n </>\n );\n\n if (option.href !== undefined) {\n if (option.disabled || active) {\n return (\n <span\n key={option.value}\n aria-current={active ? 'page' : undefined}\n aria-disabled={option.disabled || undefined}\n className={cn(segmentClass, option.disabled && 'opacity-50')}\n >\n {segmentContent}\n </span>\n );\n }\n return (\n <LinkEl\n key={option.value}\n {...destination(option.href)}\n className={segmentClass}\n >\n {segmentContent}\n </LinkEl>\n );\n }\n\n return (\n <button\n key={option.value}\n ref={(node) => {\n refs.current[index] = node;\n }}\n type=\"button\"\n role={multiple || linkMode ? undefined : 'radio'}\n aria-checked={multiple || linkMode ? undefined : active}\n aria-pressed={multiple ? active : undefined}\n aria-current={linkMode && active ? 'page' : undefined}\n disabled={option.disabled}\n tabIndex={focusable ? 0 : -1}\n onClick={() => select(option)}\n onKeyDown={onKeyDown}\n className={segmentClass}\n >\n {segmentContent}\n </button>\n );\n })}\n </div>\n );\n }\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA4LY;AA1LZ,YAAuB;AACvB,gBAAmB;AAsCnB,MAAM,cAAc;AAAA,EAClB,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AACN;AAcO,MAAM,mBAAmB,MAAM;AAAA,EACpC,SAASA,kBACP;AAAA,IACE;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,WAAW;AAAA,IACX,OAAO;AAAA,IACP,YAAY;AAAA,IACZ;AAAA,IACA,eAAe;AAAA,IACf;AAAA,IACA,cAAc,YAAY;AAAA,IAC1B,GAAG;AAAA,EACL,GACA,KACA;AACA,UAAM,eAAe,UAAU;AAC/B,UAAM,CAAC,UAAU,WAAW,IAAI,MAAM;AAAA,MAA4B,MAChE,WACI,MAAM,QAAQ,YAAY,IACxB,eACA,CAAC,IACH,OAAO,iBAAiB,WACtB,eACA;AAAA,IACR;AACA,UAAM,UAAU,eAAe,QAAQ;AACvC,UAAM,WAAW,WACb,MAAM,QAAQ,OAAO,IACnB,UACA,CAAC,IACH,OAAO,YAAY,WACjB,UACA;AAEN,UAAM,WAAW,QAAQ,KAAK,CAAC,WAAW,OAAO,SAAS,MAAS;AACnE,UAAM,SAAS,iBAAiB;AAChC,UAAM,cAAc,CAAC,SAAkB,iBAAiB,OAA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AA,kBAClC,eAAW,cAAG,cAAc,OAAO,YAAY,YAAY;AAAA,kBAE1D;AAAA;AAAA,gBALI,OAAO;AAAA,cAMd;AAAA,YAEJ;AACA,mBACE;AAAA,cAAC;AAAA;AAAA,gBAEE,GAAG,YAAY,OAAO,IAAI;AAAA,gBAC3B,WAAW;AAAA,gBAEV;AAAA;AAAA,cAJI,OAAO;AAAA,YAKd;AAAA,UAEJ;AAEA,iBACE;AAAA,YAAC;AAAA;AAAA,cAEC,KAAK,CAAC,SAAS;AACb,qBAAK,QAAQ,KAAK,IAAI;AAAA,cACxB;AAAA,cACA,MAAK;AAAA,cACL,MAAM,YAAY,WAAW,SAAY;AAAA,cACzC,gBAAc,YAAY,WAAW,SAAY;AAAA,cACjD,gBAAc,WAAW,SAAS;AAAA,cAClC,gBAAc,YAAY,SAAS,SAAS;AAAA,cAC5C,UAAU,OAAO;AAAA,cACjB,UAAU,YAAY,IAAI;AAAA,cAC1B,SAAS,MAAM,OAAO,MAAM;AAAA,cAC5B;AAAA,cACA,WAAW;AAAA,cAEV;AAAA;AAAA,YAfI,OAAO;AAAA,UAgBd;AAAA,QAEJ,CAAC;AAAA;AAAA,IACH;AAAA,EAEJ;AACF;","names":["SegmentedControl"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import { cn } from "../../utils/cn.mjs";
|
|
5
5
|
const sizeClasses = {
|
|
@@ -16,6 +16,8 @@ const SegmentedControl = React.forwardRef(
|
|
|
16
16
|
multiple = false,
|
|
17
17
|
size = "md",
|
|
18
18
|
fullWidth = false,
|
|
19
|
+
linkComponent,
|
|
20
|
+
linkHrefProp = "href",
|
|
19
21
|
className,
|
|
20
22
|
"aria-label": ariaLabel = "Segmented control",
|
|
21
23
|
...props
|
|
@@ -26,6 +28,9 @@ const SegmentedControl = React.forwardRef(
|
|
|
26
28
|
);
|
|
27
29
|
const current = isControlled ? value : internal;
|
|
28
30
|
const selected = multiple ? Array.isArray(current) ? current : [] : typeof current === "string" ? current : "";
|
|
31
|
+
const linkMode = options.some((option) => option.href !== void 0);
|
|
32
|
+
const LinkEl = linkComponent ?? "a";
|
|
33
|
+
const destination = (href) => linkHrefProp === "to" ? { to: href } : { href };
|
|
29
34
|
const refs = React.useRef([]);
|
|
30
35
|
const commit = (next) => {
|
|
31
36
|
if (!isControlled) setInternal(next);
|
|
@@ -80,7 +85,7 @@ const SegmentedControl = React.forwardRef(
|
|
|
80
85
|
"div",
|
|
81
86
|
{
|
|
82
87
|
ref,
|
|
83
|
-
role: multiple ? "group" : "radiogroup",
|
|
88
|
+
role: multiple || linkMode ? "group" : "radiogroup",
|
|
84
89
|
"aria-label": ariaLabel,
|
|
85
90
|
className: cn(
|
|
86
91
|
"inline-flex items-center gap-1 rounded-lg border border-border bg-muted p-1",
|
|
@@ -92,32 +97,58 @@ const SegmentedControl = React.forwardRef(
|
|
|
92
97
|
const active = multiple ? Array.isArray(selected) && selected.includes(option.value) : selected === option.value;
|
|
93
98
|
const firstEnabled = options.findIndex((entry) => !entry.disabled);
|
|
94
99
|
const focusable = multiple || active || !selected && index === firstEnabled;
|
|
95
|
-
|
|
100
|
+
const segmentClass = cn(
|
|
101
|
+
"inline-flex items-center justify-center gap-2 rounded-md font-medium transition-colors",
|
|
102
|
+
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background",
|
|
103
|
+
"disabled:pointer-events-none disabled:opacity-50",
|
|
104
|
+
sizeClasses[size],
|
|
105
|
+
fullWidth && "flex-1",
|
|
106
|
+
active ? "bg-background text-foreground shadow-sm" : "text-muted-foreground hover:text-foreground"
|
|
107
|
+
);
|
|
108
|
+
const segmentContent = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
109
|
+
option.icon && /* @__PURE__ */ jsx("span", { className: "shrink-0 [&_svg]:size-4", children: option.icon }),
|
|
110
|
+
/* @__PURE__ */ jsx("span", { className: "truncate", children: option.label })
|
|
111
|
+
] });
|
|
112
|
+
if (option.href !== void 0) {
|
|
113
|
+
if (option.disabled || active) {
|
|
114
|
+
return /* @__PURE__ */ jsx(
|
|
115
|
+
"span",
|
|
116
|
+
{
|
|
117
|
+
"aria-current": active ? "page" : void 0,
|
|
118
|
+
"aria-disabled": option.disabled || void 0,
|
|
119
|
+
className: cn(segmentClass, option.disabled && "opacity-50"),
|
|
120
|
+
children: segmentContent
|
|
121
|
+
},
|
|
122
|
+
option.value
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
return /* @__PURE__ */ jsx(
|
|
126
|
+
LinkEl,
|
|
127
|
+
{
|
|
128
|
+
...destination(option.href),
|
|
129
|
+
className: segmentClass,
|
|
130
|
+
children: segmentContent
|
|
131
|
+
},
|
|
132
|
+
option.value
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
return /* @__PURE__ */ jsx(
|
|
96
136
|
"button",
|
|
97
137
|
{
|
|
98
138
|
ref: (node) => {
|
|
99
139
|
refs.current[index] = node;
|
|
100
140
|
},
|
|
101
141
|
type: "button",
|
|
102
|
-
role: multiple ? void 0 : "radio",
|
|
103
|
-
"aria-checked": multiple ? void 0 : active,
|
|
142
|
+
role: multiple || linkMode ? void 0 : "radio",
|
|
143
|
+
"aria-checked": multiple || linkMode ? void 0 : active,
|
|
104
144
|
"aria-pressed": multiple ? active : void 0,
|
|
145
|
+
"aria-current": linkMode && active ? "page" : void 0,
|
|
105
146
|
disabled: option.disabled,
|
|
106
147
|
tabIndex: focusable ? 0 : -1,
|
|
107
148
|
onClick: () => select(option),
|
|
108
149
|
onKeyDown,
|
|
109
|
-
className:
|
|
110
|
-
|
|
111
|
-
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background",
|
|
112
|
-
"disabled:pointer-events-none disabled:opacity-50",
|
|
113
|
-
sizeClasses[size],
|
|
114
|
-
fullWidth && "flex-1",
|
|
115
|
-
active ? "bg-background text-foreground shadow-sm" : "text-muted-foreground hover:text-foreground"
|
|
116
|
-
),
|
|
117
|
-
children: [
|
|
118
|
-
option.icon && /* @__PURE__ */ jsx("span", { className: "shrink-0 [&_svg]:size-4", children: option.icon }),
|
|
119
|
-
/* @__PURE__ */ jsx("span", { className: "truncate", children: option.label })
|
|
120
|
-
]
|
|
150
|
+
className: segmentClass,
|
|
151
|
+
children: segmentContent
|
|
121
152
|
},
|
|
122
153
|
option.value
|
|
123
154
|
);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/segmented-control/SegmentedControl.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { cn } from '../../utils/cn';\n\nexport type SegmentedOption = {\n value: string;\n label: React.ReactNode;\n /** Optional leading icon. */\n icon?: React.ReactNode;\n disabled?: boolean;\n};\n\nexport type SegmentedControlProps = Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange'> & {\n /** Options rendered as segments. */\n options: SegmentedOption[];\n /** Controlled selected value. Use string[] when multiple. */\n value?: string | string[];\n /** Initial selection when uncontrolled. */\n defaultValue?: string | string[];\n /** Fires with the next selection. */\n onValueChange?: (value: string | string[]) => void;\n /** Allow more than one segment to be active. Default false. */\n multiple?: boolean;\n /** Control density. Default 'md'. */\n size?: 'sm' | 'md' | 'lg';\n /** Stretch segments to fill the container width. */\n fullWidth?: boolean;\n};\n\nconst sizeClasses = {\n sm: 'h-8 px-2.5 text-xs',\n md: 'h-9 px-3 text-sm',\n lg: 'h-10 px-4 text-sm',\n} as const;\n\n/**\n * Segmented control for switching a view or filter. Single-select uses radio\n * semantics and arrow-key navigation; multiple-select uses pressed buttons.\n * Use it for filters such as All / Investors / Advisors, not for tab panels\n * (use Tabs when each segment owns a tabpanel).\n */\nexport const SegmentedControl = React.forwardRef<HTMLDivElement, SegmentedControlProps>(\n function SegmentedControl(\n {\n options,\n value,\n defaultValue,\n onValueChange,\n multiple = false,\n size = 'md',\n fullWidth = false,\n className,\n 'aria-label': ariaLabel = 'Segmented control',\n ...props\n },\n ref\n ) {\n const isControlled = value !== undefined;\n const [internal, setInternal] = React.useState<string | string[]>(() =>\n multiple\n ? Array.isArray(defaultValue)\n ? defaultValue\n : []\n : typeof defaultValue === 'string'\n ? defaultValue\n : ''\n );\n const current = isControlled ? value : internal;\n const selected = multiple\n ? Array.isArray(current)\n ? current\n : []\n : typeof current === 'string'\n ? current\n : '';\n\n const refs = React.useRef<Array<HTMLButtonElement | null>>([]);\n\n const commit = (next: string | string[]) => {\n if (!isControlled) setInternal(next);\n onValueChange?.(next);\n };\n\n const select = (option: SegmentedOption) => {\n if (option.disabled) return;\n if (multiple) {\n const currentValues = Array.isArray(selected) ? selected : [];\n commit(\n currentValues.includes(option.value)\n ? currentValues.filter((entry) => entry !== option.value)\n : [...currentValues, option.value]\n );\n } else {\n commit(option.value);\n }\n };\n\n const moveFocus = (direction: 1 | -1 | 'first' | 'last') => {\n if (multiple) return;\n const enabled = options\n .map((option, index) => ({ option, index }))\n .filter(({ option }) => !option.disabled);\n if (enabled.length === 0) return;\n const activeValue = typeof selected === 'string' ? selected : '';\n const currentIndex = enabled.findIndex(({ option }) => option.value === activeValue);\n let nextIndex: number;\n if (direction === 'first') nextIndex = 0;\n else if (direction === 'last') nextIndex = enabled.length - 1;\n else {\n const from = currentIndex === -1 ? 0 : currentIndex;\n nextIndex = (from + direction + enabled.length) % enabled.length;\n }\n const next = enabled[nextIndex];\n if (!next) return;\n commit(next.option.value);\n refs.current[next.index]?.focus();\n };\n\n const onKeyDown = (event: React.KeyboardEvent<HTMLButtonElement>) => {\n if (multiple) return;\n if (event.key === 'ArrowRight' || event.key === 'ArrowDown') {\n event.preventDefault();\n moveFocus(1);\n } else if (event.key === 'ArrowLeft' || event.key === 'ArrowUp') {\n event.preventDefault();\n moveFocus(-1);\n } else if (event.key === 'Home') {\n event.preventDefault();\n moveFocus('first');\n } else if (event.key === 'End') {\n event.preventDefault();\n moveFocus('last');\n }\n };\n\n return (\n <div\n ref={ref}\n role={multiple ? 'group' : 'radiogroup'}\n aria-label={ariaLabel}\n className={cn(\n 'inline-flex items-center gap-1 rounded-lg border border-border bg-muted p-1',\n fullWidth && 'flex w-full',\n className\n )}\n {...props}\n >\n {options.map((option, index) => {\n const active = multiple\n ? Array.isArray(selected) && selected.includes(option.value)\n : selected === option.value;\n const firstEnabled = options.findIndex((entry) => !entry.disabled);\n const focusable = multiple || active || (!selected && index === firstEnabled);\n\n return (\n <button\n key={option.value}\n ref={(node) => {\n refs.current[index] = node;\n }}\n type=\"button\"\n role={multiple ? undefined : 'radio'}\n aria-checked={multiple ? undefined : active}\n aria-pressed={multiple ? active : undefined}\n disabled={option.disabled}\n tabIndex={focusable ? 0 : -1}\n onClick={() => select(option)}\n onKeyDown={onKeyDown}\n className={cn(\n 'inline-flex items-center justify-center gap-2 rounded-md font-medium transition-colors',\n 'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background',\n 'disabled:pointer-events-none disabled:opacity-50',\n sizeClasses[size],\n fullWidth && 'flex-1',\n active\n ? 'bg-background text-foreground shadow-sm'\n : 'text-muted-foreground hover:text-foreground'\n )}\n >\n {option.icon && <span className=\"shrink-0 [&_svg]:size-4\">{option.icon}</span>}\n <span className=\"truncate\">{option.label}</span>\n </button>\n );\n })}\n </div>\n );\n }\n);\n"],"mappings":";AA4JY,SAwBkB,KAxBlB;AA1JZ,YAAY,WAAW;AACvB,SAAS,UAAU;AA2BnB,MAAM,cAAc;AAAA,EAClB,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AACN;AAQO,MAAM,mBAAmB,MAAM;AAAA,EACpC,SAASA,kBACP;AAAA,IACE;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,WAAW;AAAA,IACX,OAAO;AAAA,IACP,YAAY;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,cACL,MAAM,WAAW,SAAY;AAAA,cAC7B,gBAAc,WAAW,SAAY;AAAA,cACrC,gBAAc,WAAW,SAAS;AAAA,cAClC,UAAU,OAAO;AAAA,cACjB,UAAU,YAAY,IAAI;AAAA,cAC1B,SAAS,MAAM,OAAO,MAAM;AAAA,cAC5B;AAAA,cACA,WAAW;AAAA,gBACT;AAAA,gBACA;AAAA,gBACA;AAAA,gBACA,YAAY,IAAI;AAAA,gBAChB,aAAa;AAAA,gBACb,SACI,4CACA;AAAA,cACN;AAAA,cAEC;AAAA,uBAAO,QAAQ,oBAAC,UAAK,WAAU,2BAA2B,iBAAO,MAAK;AAAA,gBACvE,oBAAC,UAAK,WAAU,YAAY,iBAAO,OAAM;AAAA;AAAA;AAAA,YAxBpC,OAAO;AAAA,UAyBd;AAAA,QAEJ,CAAC;AAAA;AAAA,IACH;AAAA,EAEJ;AACF;","names":["SegmentedControl"]}
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/segmented-control/SegmentedControl.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { cn } from '../../utils/cn';\n\nexport type SegmentedOption = {\n value: string;\n label: React.ReactNode;\n /** Optional leading icon. */\n icon?: React.ReactNode;\n disabled?: boolean;\n /**\n * Destination URL. When set the segment renders as a link instead of a\n * button - use this for view switches that must survive refresh and work\n * without JavaScript. The active segment renders as a non-link\n * `aria-current=\"page\"` marker.\n */\n href?: string;\n};\n\nexport type SegmentedControlProps = Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange'> & {\n /** Options rendered as segments. */\n options: SegmentedOption[];\n /** Controlled selected value. Use string[] when multiple. */\n value?: string | string[];\n /** Initial selection when uncontrolled. */\n defaultValue?: string | string[];\n /** Fires with the next selection. */\n onValueChange?: (value: string | string[]) => void;\n /** Allow more than one segment to be active. Default false. */\n multiple?: boolean;\n /** Control density. Default 'md'. */\n size?: 'sm' | 'md' | 'lg';\n /** Stretch segments to fill the container width. */\n fullWidth?: boolean;\n /** Custom link element for routers (Next Link, react-router Link). */\n linkComponent?: React.ElementType;\n /** Prop used to pass the destination to `linkComponent`. */\n linkHrefProp?: 'href' | 'to';\n};\n\nconst sizeClasses = {\n sm: 'h-8 px-2.5 text-xs',\n md: 'h-9 px-3 text-sm',\n lg: 'h-10 px-4 text-sm',\n} as const;\n\n/**\n * Segmented control for switching a view or filter. Single-select uses radio\n * semantics and arrow-key navigation; multiple-select uses pressed buttons.\n * Use it for filters such as All / Investors / Advisors, not for tab panels\n * (use Tabs when each segment owns a tabpanel).\n *\n * Give an option an `href` to render it as a real link - the pattern for\n * view switches that must survive refresh, work without JavaScript, and stay\n * cacheable. The active segment then renders as a non-link\n * `aria-current=\"page\"` marker and link segments use normal tab navigation\n * instead of roving tabindex. Link mode is intended for single-select.\n */\nexport const SegmentedControl = React.forwardRef<HTMLDivElement, SegmentedControlProps>(\n function SegmentedControl(\n {\n options,\n value,\n defaultValue,\n onValueChange,\n multiple = false,\n size = 'md',\n fullWidth = false,\n linkComponent,\n linkHrefProp = 'href',\n className,\n 'aria-label': ariaLabel = 'Segmented control',\n ...props\n },\n ref\n ) {\n const isControlled = value !== undefined;\n const [internal, setInternal] = React.useState<string | string[]>(() =>\n multiple\n ? Array.isArray(defaultValue)\n ? defaultValue\n : []\n : typeof defaultValue === 'string'\n ? defaultValue\n : ''\n );\n const current = isControlled ? value : internal;\n const selected = multiple\n ? Array.isArray(current)\n ? current\n : []\n : typeof current === 'string'\n ? current\n : '';\n\n const linkMode = options.some((option) => option.href !== undefined);\n const LinkEl = linkComponent ?? 'a';\n const destination = (href: string) => (linkHrefProp === 'to' ? { to: href } : { href });\n\n const refs = React.useRef<Array<HTMLButtonElement | null>>([]);\n\n const commit = (next: string | string[]) => {\n if (!isControlled) setInternal(next);\n onValueChange?.(next);\n };\n\n const select = (option: SegmentedOption) => {\n if (option.disabled) return;\n if (multiple) {\n const currentValues = Array.isArray(selected) ? selected : [];\n commit(\n currentValues.includes(option.value)\n ? currentValues.filter((entry) => entry !== option.value)\n : [...currentValues, option.value]\n );\n } else {\n commit(option.value);\n }\n };\n\n const moveFocus = (direction: 1 | -1 | 'first' | 'last') => {\n if (multiple) return;\n const enabled = options\n .map((option, index) => ({ option, index }))\n .filter(({ option }) => !option.disabled);\n if (enabled.length === 0) return;\n const activeValue = typeof selected === 'string' ? selected : '';\n const currentIndex = enabled.findIndex(({ option }) => option.value === activeValue);\n let nextIndex: number;\n if (direction === 'first') nextIndex = 0;\n else if (direction === 'last') nextIndex = enabled.length - 1;\n else {\n const from = currentIndex === -1 ? 0 : currentIndex;\n nextIndex = (from + direction + enabled.length) % enabled.length;\n }\n const next = enabled[nextIndex];\n if (!next) return;\n commit(next.option.value);\n refs.current[next.index]?.focus();\n };\n\n const onKeyDown = (event: React.KeyboardEvent<HTMLButtonElement>) => {\n if (multiple) return;\n if (event.key === 'ArrowRight' || event.key === 'ArrowDown') {\n event.preventDefault();\n moveFocus(1);\n } else if (event.key === 'ArrowLeft' || event.key === 'ArrowUp') {\n event.preventDefault();\n moveFocus(-1);\n } else if (event.key === 'Home') {\n event.preventDefault();\n moveFocus('first');\n } else if (event.key === 'End') {\n event.preventDefault();\n moveFocus('last');\n }\n };\n\n return (\n <div\n ref={ref}\n role={multiple || linkMode ? 'group' : 'radiogroup'}\n aria-label={ariaLabel}\n className={cn(\n 'inline-flex items-center gap-1 rounded-lg border border-border bg-muted p-1',\n fullWidth && 'flex w-full',\n className\n )}\n {...props}\n >\n {options.map((option, index) => {\n const active = multiple\n ? Array.isArray(selected) && selected.includes(option.value)\n : selected === option.value;\n const firstEnabled = options.findIndex((entry) => !entry.disabled);\n const focusable = multiple || active || (!selected && index === firstEnabled);\n const segmentClass = cn(\n 'inline-flex items-center justify-center gap-2 rounded-md font-medium transition-colors',\n 'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background',\n 'disabled:pointer-events-none disabled:opacity-50',\n sizeClasses[size],\n fullWidth && 'flex-1',\n active\n ? 'bg-background text-foreground shadow-sm'\n : 'text-muted-foreground hover:text-foreground'\n );\n const segmentContent = (\n <>\n {option.icon && <span className=\"shrink-0 [&_svg]:size-4\">{option.icon}</span>}\n <span className=\"truncate\">{option.label}</span>\n </>\n );\n\n if (option.href !== undefined) {\n if (option.disabled || active) {\n return (\n <span\n key={option.value}\n aria-current={active ? 'page' : undefined}\n aria-disabled={option.disabled || undefined}\n className={cn(segmentClass, option.disabled && 'opacity-50')}\n >\n {segmentContent}\n </span>\n );\n }\n return (\n <LinkEl\n key={option.value}\n {...destination(option.href)}\n className={segmentClass}\n >\n {segmentContent}\n </LinkEl>\n );\n }\n\n return (\n <button\n key={option.value}\n ref={(node) => {\n refs.current[index] = node;\n }}\n type=\"button\"\n role={multiple || linkMode ? undefined : 'radio'}\n aria-checked={multiple || linkMode ? undefined : active}\n aria-pressed={multiple ? active : undefined}\n aria-current={linkMode && active ? 'page' : undefined}\n disabled={option.disabled}\n tabIndex={focusable ? 0 : -1}\n onClick={() => select(option)}\n onKeyDown={onKeyDown}\n className={segmentClass}\n >\n {segmentContent}\n </button>\n );\n })}\n </div>\n );\n }\n);\n"],"mappings":";AA4LY,mBACkB,KADlB;AA1LZ,YAAY,WAAW;AACvB,SAAS,UAAU;AAsCnB,MAAM,cAAc;AAAA,EAClB,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AACN;AAcO,MAAM,mBAAmB,MAAM;AAAA,EACpC,SAASA,kBACP;AAAA,IACE;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,WAAW;AAAA,IACX,OAAO;AAAA,IACP,YAAY;AAAA,IACZ;AAAA,IACA,eAAe;AAAA,IACf;AAAA,IACA,cAAc,YAAY;AAAA,IAC1B,GAAG;AAAA,EACL,GACA,KACA;AACA,UAAM,eAAe,UAAU;AAC/B,UAAM,CAAC,UAAU,WAAW,IAAI,MAAM;AAAA,MAA4B,MAChE,WACI,MAAM,QAAQ,YAAY,IACxB,eACA,CAAC,IACH,OA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