@slipstream-ui/core 0.11.8 → 0.11.9
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 +61 -9
- package/dist/index.d.ts +61 -9
- package/dist/index.js +604 -469
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +603 -469
- 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 +4 -2
- 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 +1 -1
- package/dist/manifests/cta-section.manifest.json +1 -1
- package/dist/manifests/data-table.manifest.json +22 -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 +1 -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 +1 -1
- 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 +1 -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-toolbar.manifest.json +120 -0
- 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 +4 -4
- 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 +1 -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/button/Button.d.ts +2 -2
- package/dist/src/components/button/Button.js +1 -0
- package/dist/src/components/button/Button.js.map +1 -1
- package/dist/src/components/button/Button.mjs +1 -0
- package/dist/src/components/button/Button.mjs.map +1 -1
- package/dist/src/components/data-table/DataTable.d.ts +12 -1
- package/dist/src/components/data-table/DataTable.js +189 -112
- package/dist/src/components/data-table/DataTable.js.map +1 -1
- package/dist/src/components/data-table/DataTable.mjs +189 -112
- package/dist/src/components/data-table/DataTable.mjs.map +1 -1
- package/dist/src/components/list-toolbar/ListToolbar.d.ts +25 -0
- package/dist/src/components/list-toolbar/ListToolbar.js +68 -0
- package/dist/src/components/list-toolbar/ListToolbar.js.map +1 -0
- package/dist/src/components/list-toolbar/ListToolbar.mjs +44 -0
- package/dist/src/components/list-toolbar/ListToolbar.mjs.map +1 -0
- package/dist/src/components/list-toolbar/index.d.ts +1 -0
- package/dist/src/components/list-toolbar/index.js +23 -0
- package/dist/src/components/list-toolbar/index.js.map +1 -0
- package/dist/src/components/list-toolbar/index.mjs +2 -0
- package/dist/src/components/list-toolbar/index.mjs.map +1 -0
- package/dist/src/components/segmented-control/SegmentedControl.d.ts +20 -4
- package/dist/src/components/segmented-control/SegmentedControl.js +17 -3
- package/dist/src/components/segmented-control/SegmentedControl.js.map +1 -1
- package/dist/src/components/segmented-control/SegmentedControl.mjs +17 -3
- package/dist/src/components/segmented-control/SegmentedControl.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 +3 -3
- package/src/components/button/Button.ssr.test.tsx +1 -1
- package/src/components/button/Button.test.tsx +6 -0
- package/src/components/button/Button.tsx +1 -0
- package/src/components/data-table/DataTable.test.tsx +99 -0
- package/src/components/data-table/DataTable.tsx +115 -1
- package/src/components/list-toolbar/ListToolbar.test.tsx +50 -0
- package/src/components/list-toolbar/ListToolbar.tsx +64 -0
- package/src/components/list-toolbar/index.ts +1 -0
- package/src/components/segmented-control/SegmentedControl.test.tsx +51 -0
- package/src/components/segmented-control/SegmentedControl.tsx +36 -4
- 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 +4 -2
- 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 +1 -1
- package/src/manifests/cta-section.manifest.json +1 -1
- package/src/manifests/data-table.manifest.json +22 -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 +1 -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 +1 -1
- 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 +1 -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-toolbar.manifest.json +120 -0
- 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 +4 -4
- 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 +1 -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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/list-toolbar/ListToolbar.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cn } from '../../utils/cn';\n\nexport type ListToolbarProps = React.HTMLAttributes<HTMLDivElement> & {\n /** Number of matching results; renders \"{count} {countLabel}\". */\n count?: number;\n /** Noun for the result count. Default \"results\". */\n countLabel?: string;\n /** Page/range position text, e.g. \"Page 2 of 5\" or \"Showing 21–40 of 137\". */\n position?: React.ReactNode;\n /** Muted note at the end of the summary line, e.g. \"Sorted by date, soonest first\". */\n note?: React.ReactNode;\n /** Controls rendered at the far end: SegmentedControl view switch, sort Select. */\n children?: React.ReactNode;\n /** Distribution of the bar. Default 'between' (summary left, controls right). */\n align?: 'between' | 'start' | 'center' | 'end';\n};\n\nconst alignClasses = {\n between: 'justify-between',\n start: 'justify-start',\n center: 'justify-center',\n end: 'justify-end',\n} as const;\n\n/**\n * Slim result bar for filtered lists and directories: result count, optional\n * page position and a \"sorted by\" note on the left; a view switch (e.g.\n * SegmentedControl in link mode) and sort control on the right. Pair with\n * FilterBar for the input row above and Pagination below.\n */\nexport function ListToolbar({\n count,\n countLabel = 'results',\n position,\n note,\n align = 'between',\n className,\n children,\n ...props\n}: ListToolbarProps) {\n const hasSummary = count !== undefined || position !== undefined || note !== undefined;\n return (\n <div\n className={cn('flex flex-wrap items-center gap-x-4 gap-y-2 text-sm', alignClasses[align], className)}\n {...props}\n >\n {hasSummary && (\n <p className=\"flex flex-wrap items-baseline gap-x-2 text-muted-foreground\" aria-live=\"polite\">\n {count !== undefined && (\n <span className=\"font-medium text-foreground\">\n {count} {countLabel}\n </span>\n )}\n {position && <span>{position}</span>}\n {note && <span className=\"text-xs\">{note}</span>}\n </p>\n )}\n {children && <div className=\"flex flex-wrap items-center gap-2\">{children}</div>}\n </div>\n );\n}\n\nListToolbar.displayName = 'ListToolbar';\n"],"mappings":"AAkDY,SAIW,KAJX;AAjDZ,SAAS,UAAU;AAiBnB,MAAM,eAAe;AAAA,EACnB,SAAS;AAAA,EACT,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,KAAK;AACP;AAQO,SAAS,YAAY;AAAA,EAC1B;AAAA,EACA,aAAa;AAAA,EACb;AAAA,EACA;AAAA,EACA,QAAQ;AAAA,EACR;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAqB;AACnB,QAAM,aAAa,UAAU,UAAa,aAAa,UAAa,SAAS;AAC7E,SACE;AAAA,IAAC;AAAA;AAAA,MACC,WAAW,GAAG,uDAAuD,aAAa,KAAK,GAAG,SAAS;AAAA,MAClG,GAAG;AAAA,MAEH;AAAA,sBACC,qBAAC,OAAE,WAAU,+DAA8D,aAAU,UAClF;AAAA,oBAAU,UACT,qBAAC,UAAK,WAAU,+BACb;AAAA;AAAA,YAAM;AAAA,YAAE;AAAA,aACX;AAAA,UAED,YAAY,oBAAC,UAAM,oBAAS;AAAA,UAC5B,QAAQ,oBAAC,UAAK,WAAU,WAAW,gBAAK;AAAA,WAC3C;AAAA,QAED,YAAY,oBAAC,SAAI,WAAU,qCAAqC,UAAS;AAAA;AAAA;AAAA,EAC5E;AAEJ;AAEA,YAAY,cAAc;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ListToolbar';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
+
var list_toolbar_exports = {};
|
|
17
|
+
module.exports = __toCommonJS(list_toolbar_exports);
|
|
18
|
+
__reExport(list_toolbar_exports, require("./ListToolbar.js"), module.exports);
|
|
19
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
20
|
+
0 && (module.exports = {
|
|
21
|
+
...require("./ListToolbar.js")
|
|
22
|
+
});
|
|
23
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/list-toolbar/index.ts"],"sourcesContent":["export * from './ListToolbar';\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,iCAAc,0BAAd;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/list-toolbar/index.ts"],"sourcesContent":["export * from './ListToolbar';\n"],"mappings":"AAAA,cAAc;","names":[]}
|
|
@@ -4,6 +4,12 @@ export type SegmentedOption = {
|
|
|
4
4
|
label: React.ReactNode;
|
|
5
5
|
/** Optional leading icon. */
|
|
6
6
|
icon?: React.ReactNode;
|
|
7
|
+
/**
|
|
8
|
+
* Optional trailing note (e.g. "no Pro-Am ladder"). Rendered as a small
|
|
9
|
+
* muted marker after the label and exposed to assistive tech via
|
|
10
|
+
* `aria-description`, so it does not change the accessible name.
|
|
11
|
+
*/
|
|
12
|
+
hint?: string;
|
|
7
13
|
disabled?: boolean;
|
|
8
14
|
/**
|
|
9
15
|
* Destination URL. When set the segment renders as a link instead of a
|
|
@@ -26,8 +32,13 @@ export type SegmentedControlProps = Omit<React.HTMLAttributes<HTMLDivElement>, '
|
|
|
26
32
|
multiple?: boolean;
|
|
27
33
|
/** Control density. Default 'md'. */
|
|
28
34
|
size?: 'sm' | 'md' | 'lg';
|
|
29
|
-
/**
|
|
30
|
-
|
|
35
|
+
/**
|
|
36
|
+
* Stretch segments to fill the container width. `true` fills at every
|
|
37
|
+
* viewport; a breakpoint string ('sm' | 'md' | 'lg' | 'xl' | '2xl') fills
|
|
38
|
+
* only *below* that breakpoint and hugs content at and above it — the
|
|
39
|
+
* responsive pattern for "full-width on mobile, compact on desktop".
|
|
40
|
+
*/
|
|
41
|
+
fullWidth?: boolean | 'sm' | 'md' | 'lg' | 'xl' | '2xl';
|
|
31
42
|
/** Custom link element for routers (Next Link, react-router Link). */
|
|
32
43
|
linkComponent?: React.ElementType;
|
|
33
44
|
/** Prop used to pass the destination to `linkComponent`. */
|
|
@@ -58,8 +69,13 @@ export declare const SegmentedControl: React.ForwardRefExoticComponent<Omit<Reac
|
|
|
58
69
|
multiple?: boolean;
|
|
59
70
|
/** Control density. Default 'md'. */
|
|
60
71
|
size?: "sm" | "md" | "lg";
|
|
61
|
-
/**
|
|
62
|
-
|
|
72
|
+
/**
|
|
73
|
+
* Stretch segments to fill the container width. `true` fills at every
|
|
74
|
+
* viewport; a breakpoint string ('sm' | 'md' | 'lg' | 'xl' | '2xl') fills
|
|
75
|
+
* only *below* that breakpoint and hugs content at and above it — the
|
|
76
|
+
* responsive pattern for "full-width on mobile, compact on desktop".
|
|
77
|
+
*/
|
|
78
|
+
fullWidth?: boolean | "sm" | "md" | "lg" | "xl" | "2xl";
|
|
63
79
|
/** Custom link element for routers (Next Link, react-router Link). */
|
|
64
80
|
linkComponent?: React.ElementType;
|
|
65
81
|
/** Prop used to pass the destination to `linkComponent`. */
|
|
@@ -40,6 +40,13 @@ const sizeClasses = {
|
|
|
40
40
|
md: "h-9 px-3 text-sm",
|
|
41
41
|
lg: "h-10 px-4 text-sm"
|
|
42
42
|
};
|
|
43
|
+
const fullWidthBreakpoints = {
|
|
44
|
+
sm: "max-sm",
|
|
45
|
+
md: "max-md",
|
|
46
|
+
lg: "max-lg",
|
|
47
|
+
xl: "max-xl",
|
|
48
|
+
"2xl": "max-2xl"
|
|
49
|
+
};
|
|
43
50
|
const SegmentedControl = React.forwardRef(
|
|
44
51
|
function SegmentedControl2({
|
|
45
52
|
options,
|
|
@@ -61,6 +68,7 @@ const SegmentedControl = React.forwardRef(
|
|
|
61
68
|
);
|
|
62
69
|
const current = isControlled ? value : internal;
|
|
63
70
|
const selected = multiple ? Array.isArray(current) ? current : [] : typeof current === "string" ? current : "";
|
|
71
|
+
const fullWidthBelow = typeof fullWidth === "string" ? fullWidthBreakpoints[fullWidth] : null;
|
|
64
72
|
const linkMode = options.some((option) => option.href !== void 0);
|
|
65
73
|
const LinkEl = linkComponent ?? "a";
|
|
66
74
|
const destination = (href) => linkHrefProp === "to" ? { to: href } : { href };
|
|
@@ -122,7 +130,8 @@ const SegmentedControl = React.forwardRef(
|
|
|
122
130
|
"aria-label": ariaLabel,
|
|
123
131
|
className: (0, import_cn.cn)(
|
|
124
132
|
"inline-flex items-center gap-1 rounded-lg border border-border bg-muted p-1",
|
|
125
|
-
fullWidth && "flex w-full",
|
|
133
|
+
fullWidth === true && "flex w-full",
|
|
134
|
+
fullWidthBelow && `${fullWidthBelow}:flex ${fullWidthBelow}:w-full`,
|
|
126
135
|
className
|
|
127
136
|
),
|
|
128
137
|
...props,
|
|
@@ -135,12 +144,14 @@ const SegmentedControl = React.forwardRef(
|
|
|
135
144
|
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background",
|
|
136
145
|
"disabled:pointer-events-none disabled:opacity-50",
|
|
137
146
|
sizeClasses[size],
|
|
138
|
-
fullWidth && "flex-1",
|
|
147
|
+
fullWidth === true && "flex-1",
|
|
148
|
+
fullWidthBelow && `${fullWidthBelow}:flex-1`,
|
|
139
149
|
active ? "bg-background text-foreground shadow-sm" : "text-muted-foreground hover:text-foreground"
|
|
140
150
|
);
|
|
141
151
|
const segmentContent = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
142
152
|
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 })
|
|
153
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "truncate", children: option.label }),
|
|
154
|
+
option.hint && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { "aria-hidden": "true", className: "shrink-0 text-[10px] font-normal text-muted-foreground/70", children: option.hint })
|
|
144
155
|
] });
|
|
145
156
|
if (option.href !== void 0) {
|
|
146
157
|
if (option.disabled || active) {
|
|
@@ -149,6 +160,7 @@ const SegmentedControl = React.forwardRef(
|
|
|
149
160
|
{
|
|
150
161
|
"aria-current": active ? "page" : void 0,
|
|
151
162
|
"aria-disabled": option.disabled || void 0,
|
|
163
|
+
"aria-description": option.hint,
|
|
152
164
|
className: (0, import_cn.cn)(segmentClass, option.disabled && "opacity-50"),
|
|
153
165
|
children: segmentContent
|
|
154
166
|
},
|
|
@@ -159,6 +171,7 @@ const SegmentedControl = React.forwardRef(
|
|
|
159
171
|
LinkEl,
|
|
160
172
|
{
|
|
161
173
|
...destination(option.href),
|
|
174
|
+
"aria-description": option.hint,
|
|
162
175
|
className: segmentClass,
|
|
163
176
|
children: segmentContent
|
|
164
177
|
},
|
|
@@ -176,6 +189,7 @@ const SegmentedControl = React.forwardRef(
|
|
|
176
189
|
"aria-checked": multiple || linkMode ? void 0 : active,
|
|
177
190
|
"aria-pressed": multiple ? active : void 0,
|
|
178
191
|
"aria-current": linkMode && active ? "page" : void 0,
|
|
192
|
+
"aria-description": option.hint,
|
|
179
193
|
disabled: option.disabled,
|
|
180
194
|
tabIndex: focusable ? 0 : -1,
|
|
181
195
|
onClick: () => select(option),
|
|
@@ -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 * 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,OAAO,EAAE,IAAI,KAAK,IAAI,EAAE,KAAK;AAErF,UAAM,OAAO,MAAM,OAAwC,CAAC,CAAC;AAE7D,UAAM,SAAS,CAAC,SAA4B;AAC1C,UAAI,CAAC,aAAc,aAAY,IAAI;AACnC,sBAAgB,IAAI;AAAA,IACtB;AAEA,UAAM,SAAS,CAAC,WAA4B;AAC1C,UAAI,OAAO,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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
|
+
{"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 /**\n * Optional trailing note (e.g. \"no Pro-Am ladder\"). Rendered as a small\n * muted marker after the label and exposed to assistive tech via\n * `aria-description`, so it does not change the accessible name.\n */\n hint?: string;\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 /**\n * Stretch segments to fill the container width. `true` fills at every\n * viewport; a breakpoint string ('sm' | 'md' | 'lg' | 'xl' | '2xl') fills\n * only *below* that breakpoint and hugs content at and above it — the\n * responsive pattern for \"full-width on mobile, compact on desktop\".\n */\n fullWidth?: boolean | 'sm' | 'md' | 'lg' | 'xl' | '2xl';\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\nconst fullWidthBreakpoints = {\n sm: 'max-sm',\n md: 'max-md',\n lg: 'max-lg',\n xl: 'max-xl',\n '2xl': 'max-2xl',\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 fullWidthBelow =\n typeof fullWidth === 'string' ? fullWidthBreakpoints[fullWidth] : null;\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 === true && 'flex w-full',\n fullWidthBelow && `${fullWidthBelow}:flex ${fullWidthBelow}: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 === true && 'flex-1',\n fullWidthBelow && `${fullWidthBelow}: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 {option.hint && (\n <span aria-hidden=\"true\" className=\"shrink-0 text-[10px] font-normal text-muted-foreground/70\">\n {option.hint}\n </span>\n )}\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 aria-description={option.hint}\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 aria-description={option.hint}\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 aria-description={option.hint}\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;AAoNY;AAlNZ,YAAuB;AACvB,gBAAmB;AAiDnB,MAAM,cAAc;AAAA,EAClB,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AACN;AAEA,MAAM,uBAAuB;AAAA,EAC3B,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,OAAO;AACT;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,iBACJ,OAAO,cAAc,WAAW,qBAAqB,SAAS,IAAI;AAEpE,UAAM,WAAW,QAAQ,KAAK,CAAC,WAAW,OAAO,SAAS,MAAS;AACnE,UAAM,SAAS,iBAAiB;AAChC,UAAM,cAAc,CAAC,SAAkB,iBAAiB,OAAO,EAAE,IAAI,KAAK,IAAI,EAAE,KAAK;AAErF,UAAM,OAAO,MAAM,OAAwC,CAAC,CAAC;AAE7D,UAAM,SAAS,C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AAA,kBAEC,gBAAc,SAAS,SAAS;AAAA,kBAChC,iBAAe,OAAO,YAAY;AAAA,kBAClC,oBAAkB,OAAO;AAAA,kBACzB,eAAW,cAAG,cAAc,OAAO,YAAY,YAAY;AAAA,kBAE1D;AAAA;AAAA,gBANI,OAAO;AAAA,cAOd;AAAA,YAEJ;AACA,mBACE;AAAA,cAAC;AAAA;AAAA,gBAEE,GAAG,YAAY,OAAO,IAAI;AAAA,gBAC3B,oBAAkB,OAAO;AAAA,gBACzB,WAAW;AAAA,gBAEV;AAAA;AAAA,cALI,OAAO;AAAA,YAMd;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,oBAAkB,OAAO;AAAA,cACzB,UAAU,OAAO;AAAA,cACjB,UAAU,YAAY,IAAI;AAAA,cAC1B,SAAS,MAAM,OAAO,MAAM;AAAA,cAC5B;AAAA,cACA,WAAW;AAAA,cAEV;AAAA;AAAA,YAhBI,OAAO;AAAA,UAiBd;AAAA,QAEJ,CAAC;AAAA;AAAA,IACH;AAAA,EAEJ;AACF;","names":["SegmentedControl"]}
|
|
@@ -7,6 +7,13 @@ const sizeClasses = {
|
|
|
7
7
|
md: "h-9 px-3 text-sm",
|
|
8
8
|
lg: "h-10 px-4 text-sm"
|
|
9
9
|
};
|
|
10
|
+
const fullWidthBreakpoints = {
|
|
11
|
+
sm: "max-sm",
|
|
12
|
+
md: "max-md",
|
|
13
|
+
lg: "max-lg",
|
|
14
|
+
xl: "max-xl",
|
|
15
|
+
"2xl": "max-2xl"
|
|
16
|
+
};
|
|
10
17
|
const SegmentedControl = React.forwardRef(
|
|
11
18
|
function SegmentedControl2({
|
|
12
19
|
options,
|
|
@@ -28,6 +35,7 @@ const SegmentedControl = React.forwardRef(
|
|
|
28
35
|
);
|
|
29
36
|
const current = isControlled ? value : internal;
|
|
30
37
|
const selected = multiple ? Array.isArray(current) ? current : [] : typeof current === "string" ? current : "";
|
|
38
|
+
const fullWidthBelow = typeof fullWidth === "string" ? fullWidthBreakpoints[fullWidth] : null;
|
|
31
39
|
const linkMode = options.some((option) => option.href !== void 0);
|
|
32
40
|
const LinkEl = linkComponent ?? "a";
|
|
33
41
|
const destination = (href) => linkHrefProp === "to" ? { to: href } : { href };
|
|
@@ -89,7 +97,8 @@ const SegmentedControl = React.forwardRef(
|
|
|
89
97
|
"aria-label": ariaLabel,
|
|
90
98
|
className: cn(
|
|
91
99
|
"inline-flex items-center gap-1 rounded-lg border border-border bg-muted p-1",
|
|
92
|
-
fullWidth && "flex w-full",
|
|
100
|
+
fullWidth === true && "flex w-full",
|
|
101
|
+
fullWidthBelow && `${fullWidthBelow}:flex ${fullWidthBelow}:w-full`,
|
|
93
102
|
className
|
|
94
103
|
),
|
|
95
104
|
...props,
|
|
@@ -102,12 +111,14 @@ const SegmentedControl = React.forwardRef(
|
|
|
102
111
|
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background",
|
|
103
112
|
"disabled:pointer-events-none disabled:opacity-50",
|
|
104
113
|
sizeClasses[size],
|
|
105
|
-
fullWidth && "flex-1",
|
|
114
|
+
fullWidth === true && "flex-1",
|
|
115
|
+
fullWidthBelow && `${fullWidthBelow}:flex-1`,
|
|
106
116
|
active ? "bg-background text-foreground shadow-sm" : "text-muted-foreground hover:text-foreground"
|
|
107
117
|
);
|
|
108
118
|
const segmentContent = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
109
119
|
option.icon && /* @__PURE__ */ jsx("span", { className: "shrink-0 [&_svg]:size-4", children: option.icon }),
|
|
110
|
-
/* @__PURE__ */ jsx("span", { className: "truncate", children: option.label })
|
|
120
|
+
/* @__PURE__ */ jsx("span", { className: "truncate", children: option.label }),
|
|
121
|
+
option.hint && /* @__PURE__ */ jsx("span", { "aria-hidden": "true", className: "shrink-0 text-[10px] font-normal text-muted-foreground/70", children: option.hint })
|
|
111
122
|
] });
|
|
112
123
|
if (option.href !== void 0) {
|
|
113
124
|
if (option.disabled || active) {
|
|
@@ -116,6 +127,7 @@ const SegmentedControl = React.forwardRef(
|
|
|
116
127
|
{
|
|
117
128
|
"aria-current": active ? "page" : void 0,
|
|
118
129
|
"aria-disabled": option.disabled || void 0,
|
|
130
|
+
"aria-description": option.hint,
|
|
119
131
|
className: cn(segmentClass, option.disabled && "opacity-50"),
|
|
120
132
|
children: segmentContent
|
|
121
133
|
},
|
|
@@ -126,6 +138,7 @@ const SegmentedControl = React.forwardRef(
|
|
|
126
138
|
LinkEl,
|
|
127
139
|
{
|
|
128
140
|
...destination(option.href),
|
|
141
|
+
"aria-description": option.hint,
|
|
129
142
|
className: segmentClass,
|
|
130
143
|
children: segmentContent
|
|
131
144
|
},
|
|
@@ -143,6 +156,7 @@ const SegmentedControl = React.forwardRef(
|
|
|
143
156
|
"aria-checked": multiple || linkMode ? void 0 : active,
|
|
144
157
|
"aria-pressed": multiple ? active : void 0,
|
|
145
158
|
"aria-current": linkMode && active ? "page" : void 0,
|
|
159
|
+
"aria-description": option.hint,
|
|
146
160
|
disabled: option.disabled,
|
|
147
161
|
tabIndex: focusable ? 0 : -1,
|
|
148
162
|
onClick: () => select(option),
|
|
@@ -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 * 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,IAA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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
|
+
{"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 /**\n * Optional trailing note (e.g. \"no Pro-Am ladder\"). Rendered as a small\n * muted marker after the label and exposed to assistive tech via\n * `aria-description`, so it does not change the accessible name.\n */\n hint?: string;\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 /**\n * Stretch segments to fill the container width. `true` fills at every\n * viewport; a breakpoint string ('sm' | 'md' | 'lg' | 'xl' | '2xl') fills\n * only *below* that breakpoint and hugs content at and above it — the\n * responsive pattern for \"full-width on mobile, compact on desktop\".\n */\n fullWidth?: boolean | 'sm' | 'md' | 'lg' | 'xl' | '2xl';\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\nconst fullWidthBreakpoints = {\n sm: 'max-sm',\n md: 'max-md',\n lg: 'max-lg',\n xl: 'max-xl',\n '2xl': 'max-2xl',\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 fullWidthBelow =\n typeof fullWidth === 'string' ? fullWidthBreakpoints[fullWidth] : null;\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 === true && 'flex w-full',\n fullWidthBelow && `${fullWidthBelow}:flex ${fullWidthBelow}: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 === true && 'flex-1',\n fullWidthBelow && `${fullWidthBelow}: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 {option.hint && (\n <span aria-hidden=\"true\" className=\"shrink-0 text-[10px] font-normal text-muted-foreground/70\">\n {option.hint}\n </span>\n )}\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 aria-description={option.hint}\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 aria-description={option.hint}\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 aria-description={option.hint}\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":";AAoNY,mBACkB,KADlB;AAlNZ,YAAY,WAAW;AACvB,SAAS,UAAU;AAiDnB,MAAM,cAAc;AAAA,EAClB,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AACN;AAEA,MAAM,uBAAuB;AAAA,EAC3B,IAAI;AAAA,EACJ,IAAI;AAA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AAAA,YAMd;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,oBAAkB,OAAO;AAAA,cACzB,UAAU,OAAO;AAAA,cACjB,UAAU,YAAY,IAAI;AAAA,cAC1B,SAAS,MAAM,OAAO,MAAM;AAAA,cAC5B;AAAA,cACA,WAAW;AAAA,cAEV;AAAA;AAAA,YAhBI,OAAO;AAAA,UAiBd;AAAA,QAEJ,CAAC;AAAA;AAAA,IACH;AAAA,EAEJ;AACF;","names":["SegmentedControl"]}
|
package/dist/src/index.d.ts
CHANGED
|
@@ -58,6 +58,7 @@ export * from './components/metric-card';
|
|
|
58
58
|
export * from './components/password-input';
|
|
59
59
|
export * from './components/auth-layout';
|
|
60
60
|
export * from './components/filter-bar';
|
|
61
|
+
export * from './components/list-toolbar';
|
|
61
62
|
export * from './components/date-picker';
|
|
62
63
|
export * from './components/date-picker-popover';
|
|
63
64
|
export * from './components/time-picker';
|