@arshad-shah/cynosure 0.1.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -8
- package/dist/components/Accordion/Accordion.d.ts +14 -0
- package/dist/components/Accordion/Accordion.js.map +1 -1
- package/dist/components/Announcer/Announcer.d.ts +1 -0
- package/dist/components/Announcer/Announcer.js.map +1 -1
- package/dist/components/AppShell/AppShell.d.ts +22 -1
- package/dist/components/AppShell/AppShell.js +95 -83
- package/dist/components/AppShell/AppShell.js.map +1 -1
- package/dist/components/AppShell/index.d.ts +1 -1
- package/dist/components/AspectRatio/AspectRatio.d.ts +29 -0
- package/dist/components/AspectRatio/AspectRatio.js +21 -0
- package/dist/components/AspectRatio/AspectRatio.js.map +1 -0
- package/dist/components/AspectRatio/index.d.ts +1 -0
- package/dist/components/Avatar/Avatar.d.ts +96 -0
- package/dist/components/Avatar/Avatar.js +90 -0
- package/dist/components/Avatar/Avatar.js.map +1 -0
- package/dist/components/Avatar/index.d.ts +1 -0
- package/dist/components/Badge/Badge.d.ts +6 -0
- package/dist/components/Badge/Badge.js.map +1 -1
- package/dist/components/Breadcrumbs/Breadcrumbs.d.ts +55 -0
- package/dist/components/Breadcrumbs/Breadcrumbs.js +85 -0
- package/dist/components/Breadcrumbs/Breadcrumbs.js.map +1 -0
- package/dist/components/Breadcrumbs/index.d.ts +1 -0
- package/dist/components/Button/Button.d.ts +13 -2
- package/dist/components/Button/Button.js +28 -26
- package/dist/components/Button/Button.js.map +1 -1
- package/dist/components/Calendar/Calendar.d.ts +65 -7
- package/dist/components/Calendar/Calendar.js +207 -95
- package/dist/components/Calendar/Calendar.js.map +1 -1
- package/dist/components/Calendar/dates.d.ts +4 -0
- package/dist/components/Calendar/dates.js +41 -27
- package/dist/components/Calendar/dates.js.map +1 -1
- package/dist/components/Calendar/index.d.ts +1 -1
- package/dist/components/Card/Card.d.ts +27 -0
- package/dist/components/Card/Card.js +48 -36
- package/dist/components/Card/Card.js.map +1 -1
- package/dist/components/Card/index.d.ts +1 -1
- package/dist/components/Checkbox/Checkbox.d.ts +8 -1
- package/dist/components/Checkbox/Checkbox.js +7 -6
- package/dist/components/Checkbox/Checkbox.js.map +1 -1
- package/dist/components/Checkbox/ChoiceRow.d.ts +17 -1
- package/dist/components/Checkbox/ChoiceRow.js +19 -18
- package/dist/components/Checkbox/ChoiceRow.js.map +1 -1
- package/dist/components/Checklist/Checklist.d.ts +65 -0
- package/dist/components/Checklist/Checklist.js +163 -0
- package/dist/components/Checklist/Checklist.js.map +1 -0
- package/dist/components/Checklist/index.d.ts +1 -0
- package/dist/components/CodeBlock/CodeBlock.d.ts +5 -0
- package/dist/components/CodeBlock/CodeBlock.js.map +1 -1
- package/dist/components/ColorField/ColorField.d.ts +12 -0
- package/dist/components/ColorField/ColorField.js +19 -19
- package/dist/components/ColorField/ColorField.js.map +1 -1
- package/dist/components/ColorSwatches/ColorSwatches.d.ts +5 -0
- package/dist/components/ColorSwatches/ColorSwatches.js +6 -6
- package/dist/components/ColorSwatches/ColorSwatches.js.map +1 -1
- package/dist/components/Combobox/Combobox.d.ts +20 -1
- package/dist/components/Combobox/Combobox.js +38 -34
- package/dist/components/Combobox/Combobox.js.map +1 -1
- package/dist/components/CommandPalette/CommandPalette.d.ts +9 -0
- package/dist/components/CommandPalette/CommandPalette.js +10 -10
- package/dist/components/CommandPalette/CommandPalette.js.map +1 -1
- package/dist/components/CompareSlider/CompareSlider.d.ts +4 -0
- package/dist/components/CompareSlider/CompareSlider.js +4 -4
- package/dist/components/CompareSlider/CompareSlider.js.map +1 -1
- package/dist/components/Container/Container.d.ts +44 -0
- package/dist/components/Container/Container.js +24 -0
- package/dist/components/Container/Container.js.map +1 -0
- package/dist/components/Container/index.d.ts +1 -0
- package/dist/components/ContextMenu/ContextMenu.d.ts +11 -0
- package/dist/components/ContextMenu/ContextMenu.js.map +1 -1
- package/dist/components/CopyButton/CopyButton.d.ts +8 -0
- package/dist/components/CopyButton/CopyButton.js.map +1 -1
- package/dist/components/DateField/DateField.d.ts +17 -0
- package/dist/components/DateField/DateField.js +6 -6
- package/dist/components/DateField/DateField.js.map +1 -1
- package/dist/components/DescriptionList/DescriptionList.d.ts +3 -0
- package/dist/components/DescriptionList/DescriptionList.js.map +1 -1
- package/dist/components/Dialog/Dialog.d.ts +16 -2
- package/dist/components/Dialog/Dialog.js +82 -70
- package/dist/components/Dialog/Dialog.js.map +1 -1
- package/dist/components/Disclosure/Disclosure.d.ts +7 -0
- package/dist/components/Disclosure/Disclosure.js.map +1 -1
- package/dist/components/Divider/Divider.d.ts +59 -0
- package/dist/components/Divider/Divider.js +32 -0
- package/dist/components/Divider/Divider.js.map +1 -0
- package/dist/components/Divider/index.d.ts +1 -0
- package/dist/components/DocumentViewport/DocumentViewport.d.ts +8 -0
- package/dist/components/DocumentViewport/DocumentViewport.js.map +1 -1
- package/dist/components/EmptyState/EmptyState.d.ts +3 -0
- package/dist/components/EmptyState/EmptyState.js.map +1 -1
- package/dist/components/Field/Field.d.ts +6 -0
- package/dist/components/Field/Field.js.map +1 -1
- package/dist/components/FileDrop/FileDrop.d.ts +8 -0
- package/dist/components/FileDrop/FileDrop.js.map +1 -1
- package/dist/components/FloatingToolbar/FloatingToolbar.d.ts +4 -0
- package/dist/components/FloatingToolbar/FloatingToolbar.js +4 -4
- package/dist/components/FloatingToolbar/FloatingToolbar.js.map +1 -1
- package/dist/components/Grid/Grid.d.ts +33 -7
- package/dist/components/Grid/Grid.js +46 -25
- package/dist/components/Grid/Grid.js.map +1 -1
- package/dist/components/Grid/index.d.ts +1 -1
- package/dist/components/Heading/Heading.d.ts +57 -0
- package/dist/components/Heading/Heading.js +33 -0
- package/dist/components/Heading/Heading.js.map +1 -0
- package/dist/components/Heading/index.d.ts +1 -0
- package/dist/components/HoverCard/HoverCard.d.ts +1 -0
- package/dist/components/HoverCard/HoverCard.js.map +1 -1
- package/dist/components/IconButton/IconButton.d.ts +1 -0
- package/dist/components/IconButton/IconButton.js.map +1 -1
- package/dist/components/Image/Image.d.ts +62 -0
- package/dist/components/Image/Image.js +75 -0
- package/dist/components/Image/Image.js.map +1 -0
- package/dist/components/Image/index.d.ts +1 -0
- package/dist/components/Inline/Inline.d.ts +7 -3
- package/dist/components/Inline/Inline.js +19 -13
- package/dist/components/Inline/Inline.js.map +1 -1
- package/dist/components/Kbd/Kbd.d.ts +2 -0
- package/dist/components/Kbd/Kbd.js.map +1 -1
- package/dist/components/KeyValueEditor/KeyValueEditor.d.ts +7 -0
- package/dist/components/KeyValueEditor/KeyValueEditor.js +8 -8
- package/dist/components/KeyValueEditor/KeyValueEditor.js.map +1 -1
- package/dist/components/Link/Link.d.ts +7 -0
- package/dist/components/Link/Link.js.map +1 -1
- package/dist/components/LoadingDots/LoadingDots.d.ts +2 -0
- package/dist/components/LoadingDots/LoadingDots.js.map +1 -1
- package/dist/components/Menu/Menu.d.ts +13 -1
- package/dist/components/Menu/Menu.js +37 -35
- package/dist/components/Menu/Menu.js.map +1 -1
- package/dist/components/Notice/Notice.d.ts +5 -0
- package/dist/components/Notice/Notice.js.map +1 -1
- package/dist/components/NumberField/NumberField.d.ts +17 -0
- package/dist/components/NumberField/NumberField.js +8 -8
- package/dist/components/NumberField/NumberField.js.map +1 -1
- package/dist/components/PageHeader/PageHeader.d.ts +61 -0
- package/dist/components/PageHeader/PageHeader.js +63 -0
- package/dist/components/PageHeader/PageHeader.js.map +1 -0
- package/dist/components/PageHeader/index.d.ts +1 -0
- package/dist/components/Pagination/Pagination.d.ts +77 -0
- package/dist/components/Pagination/Pagination.js +120 -0
- package/dist/components/Pagination/Pagination.js.map +1 -0
- package/dist/components/Pagination/index.d.ts +1 -0
- package/dist/components/PanZoomCanvas/PanZoomCanvas.d.ts +4 -0
- package/dist/components/PanZoomCanvas/PanZoomCanvas.js.map +1 -1
- package/dist/components/Popover/Popover.d.ts +10 -0
- package/dist/components/Popover/Popover.js.map +1 -1
- package/dist/components/ProgressBar/ProgressBar.d.ts +5 -0
- package/dist/components/ProgressBar/ProgressBar.js.map +1 -1
- package/dist/components/ProgressOverlay/ProgressOverlay.d.ts +3 -0
- package/dist/components/ProgressOverlay/ProgressOverlay.js.map +1 -1
- package/dist/components/Prose/Prose.d.ts +1 -0
- package/dist/components/Prose/Prose.js.map +1 -1
- package/dist/components/RadioGroup/RadioGroup.d.ts +13 -0
- package/dist/components/RadioGroup/RadioGroup.js.map +1 -1
- package/dist/components/SegmentedControl/SegmentedControl.d.ts +9 -0
- package/dist/components/SegmentedControl/SegmentedControl.js +35 -27
- package/dist/components/SegmentedControl/SegmentedControl.js.map +1 -1
- package/dist/components/Select/Select.d.ts +18 -1
- package/dist/components/Select/Select.js +97 -88
- package/dist/components/Select/Select.js.map +1 -1
- package/dist/components/Select/index.d.ts +1 -0
- package/dist/components/SelectionFrame/SelectionFrame.d.ts +6 -0
- package/dist/components/SelectionFrame/SelectionFrame.js.map +1 -1
- package/dist/components/SideNav/SideNav.d.ts +37 -1
- package/dist/components/SideNav/SideNav.js +100 -73
- package/dist/components/SideNav/SideNav.js.map +1 -1
- package/dist/components/SideNav/index.d.ts +1 -1
- package/dist/components/SignaturePad/SignaturePad.d.ts +3 -0
- package/dist/components/SignaturePad/SignaturePad.js.map +1 -1
- package/dist/components/Skeleton/Skeleton.d.ts +1 -0
- package/dist/components/Skeleton/Skeleton.js.map +1 -1
- package/dist/components/Slider/Slider.d.ts +11 -0
- package/dist/components/Slider/Slider.js +6 -6
- package/dist/components/Slider/Slider.js.map +1 -1
- package/dist/components/SortableList/SortableList.d.ts +6 -0
- package/dist/components/SortableList/SortableList.js.map +1 -1
- package/dist/components/SplitPane/SplitPane.d.ts +5 -0
- package/dist/components/SplitPane/SplitPane.js +4 -4
- package/dist/components/SplitPane/SplitPane.js.map +1 -1
- package/dist/components/Stack/Stack.d.ts +7 -3
- package/dist/components/Stack/Stack.js +18 -12
- package/dist/components/Stack/Stack.js.map +1 -1
- package/dist/components/Stack/index.d.ts +1 -0
- package/dist/components/Stack/space.d.ts +18 -0
- package/dist/components/Stack/space.js +12 -0
- package/dist/components/Stack/space.js.map +1 -0
- package/dist/components/Steps/Steps.d.ts +4 -0
- package/dist/components/Steps/Steps.js.map +1 -1
- package/dist/components/Table/Table.d.ts +12 -0
- package/dist/components/Table/Table.js.map +1 -1
- package/dist/components/Tabs/Tabs.d.ts +14 -0
- package/dist/components/Tabs/Tabs.js +4 -4
- package/dist/components/Tabs/Tabs.js.map +1 -1
- package/dist/components/TagInput/TagInput.d.ts +18 -0
- package/dist/components/TagInput/TagInput.js +5 -5
- package/dist/components/TagInput/TagInput.js.map +1 -1
- package/dist/components/Text/Text.d.ts +72 -0
- package/dist/components/Text/Text.js +30 -0
- package/dist/components/Text/Text.js.map +1 -0
- package/dist/components/Text/index.d.ts +1 -0
- package/dist/components/TextArea/TextArea.d.ts +10 -0
- package/dist/components/TextArea/TextArea.js +4 -4
- package/dist/components/TextArea/TextArea.js.map +1 -1
- package/dist/components/TextField/TextField.d.ts +13 -0
- package/dist/components/TextField/TextField.js +4 -4
- package/dist/components/TextField/TextField.js.map +1 -1
- package/dist/components/ThemeToggle/ThemeToggle.d.ts +4 -0
- package/dist/components/ThemeToggle/ThemeToggle.js.map +1 -1
- package/dist/components/TimeField/TimeField.d.ts +62 -8
- package/dist/components/TimeField/TimeField.js +308 -72
- package/dist/components/TimeField/TimeField.js.map +1 -1
- package/dist/components/Toast/Toast.d.ts +25 -1
- package/dist/components/Toast/Toast.js +134 -125
- package/dist/components/Toast/Toast.js.map +1 -1
- package/dist/components/Toast/index.d.ts +1 -1
- package/dist/components/Toolbar/Toolbar.d.ts +3 -0
- package/dist/components/Toolbar/Toolbar.js.map +1 -1
- package/dist/components/Tooltip/Tooltip.d.ts +1 -0
- package/dist/components/Tooltip/Tooltip.js.map +1 -1
- package/dist/components/Tree/Tree.d.ts +8 -0
- package/dist/components/Tree/Tree.js.map +1 -1
- package/dist/components/VirtualList/VirtualList.d.ts +8 -0
- package/dist/components/VirtualList/VirtualList.js +4 -4
- package/dist/components/VirtualList/VirtualList.js.map +1 -1
- package/dist/components/ZoomControls/ZoomControls.d.ts +4 -0
- package/dist/components/ZoomControls/ZoomControls.js.map +1 -1
- package/dist/foundations/ChoiceBase/ChoiceBase.d.ts +1 -0
- package/dist/foundations/ChoiceBase/ChoiceBase.js.map +1 -1
- package/dist/foundations/HiddenValue/HiddenValue.d.ts +3 -0
- package/dist/foundations/HiddenValue/HiddenValue.js.map +1 -1
- package/dist/foundations/Icon/Icon.d.ts +3 -0
- package/dist/foundations/Icon/Icon.js.map +1 -1
- package/dist/foundations/image-outcome.d.ts +15 -0
- package/dist/foundations/image-outcome.js +39 -0
- package/dist/foundations/image-outcome.js.map +1 -0
- package/dist/foundations/option-icon.d.ts +26 -0
- package/dist/foundations/option-icon.js +16 -0
- package/dist/foundations/option-icon.js.map +1 -0
- package/dist/icons/index.d.ts +1 -0
- package/dist/icons/index.js +476 -474
- package/dist/icons/keywords.d.ts +249 -0
- package/dist/icons/keywords.js +1728 -0
- package/dist/icons/keywords.js.map +1 -0
- package/dist/index.d.ts +20 -9
- package/dist/index.js +240 -213
- package/dist/styles/app-shell.css +1 -1
- package/dist/styles/aspect-ratio.css +1 -0
- package/dist/styles/avatar.css +1 -0
- package/dist/styles/breadcrumbs.css +1 -0
- package/dist/styles/calendar.css +1 -1
- package/dist/styles/card.css +1 -1
- package/dist/styles/checkbox.css +1 -1
- package/dist/styles/checklist.css +1 -0
- package/dist/styles/container.css +1 -0
- package/dist/styles/divider.css +1 -0
- package/dist/styles/generated-css.d.ts +1 -1
- package/dist/styles/generated-css.js +1 -1
- package/dist/styles/generated-css.js.map +1 -1
- package/dist/styles/grid.css +1 -1
- package/dist/styles/heading.css +1 -0
- package/dist/styles/image.css +1 -0
- package/dist/styles/menu.css +1 -1
- package/dist/styles/page-header.css +1 -0
- package/dist/styles/pagination.css +1 -0
- package/dist/styles/segmented-control.css +1 -1
- package/dist/styles/side-nav.css +1 -1
- package/dist/styles/stack.css +1 -1
- package/dist/styles/text.css +1 -0
- package/dist/styles/time-field.css +1 -1
- package/dist/styles/toast.css +1 -1
- package/dist/styles.css +1 -1
- package/dist/theme/CynosureTheme.d.ts +4 -0
- package/dist/theme/CynosureTheme.js.map +1 -1
- package/dist/tokens/to-css.js +12 -12
- package/dist/tokens/to-css.js.map +1 -1
- package/package.json +4 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProgressBar.js","names":["useId","jsx","jsxs","percent","value","max","ProgressBar","label","labelHidden","indeterminate","showValue","segments","offset","marker","markerLabel","tone","size","labels","className","style","id","top","unknown","now","parts","total","sum","p","unknownBar","shownNow","at","v","text","spoken","start","q"],"sources":["../../../src/components/ProgressBar/ProgressBar.tsx"],"sourcesContent":["import { type CSSProperties, useId } from \"react\";\nimport type { Size, Tone } from \"../../tokens/schema.js\";\n\nexport interface ProgressBarTokens {\n heightSm: string;\n heightMd: string;\n heightLg: string;\n radius: string;\n track: string;\n}\n\ndeclare module \"../../tokens/schema.js\" {\n interface ComponentTokens {\n progressBar: ProgressBarTokens;\n }\n}\n\nexport interface ProgressBarLabels {\n /** Text for the current value, shown with `showValue` and read by screen readers. Default: \"42%\". */\n value: (value: number, max: number) => string;\n}\n\nexport interface ProgressSegment {\n value: number;\n /** Read out with the value (\"Connect 30\"). */\n label: string;\n tone?: Exclude<Tone, \"neutral\"> | \"neutral\";\n /** A category colour (any CSS colour); overrides `tone`. */\n color?: string;\n}\n\nexport interface ProgressBarProps {\n /** Accessible name, shown above the bar unless `labelHidden`. */\n label: string;\n labelHidden?: boolean;\n /** Current value between 0 and `max`. Leave it out (or pass `indeterminate`) when progress is unknown. */\n value?: number | undefined;\n max?: number;\n /** Progress is happening but its amount is unknown. */\n indeterminate?: boolean;\n /** Show the value text at the end of the label row. */\n showValue?: boolean;\n /**\n * Parts drawn end to end instead of one fill, from `offset`: a request's timing (DNS, connect, wait, download) or a\n * waterfall row. Each has a `label` (read out) and a `tone` or category `color`.\n */\n segments?: ProgressSegment[] | undefined;\n /** Where the first segment starts, in the same units as `max`. Default 0. */\n offset?: number;\n /** A thin mark across the track at this value (a target, a second position). */\n marker?: number | undefined;\n /** Read with the value when there is a marker. Default \"marker at 75%\". */\n markerLabel?: string | undefined;\n tone?: Exclude<Tone, \"neutral\"> | \"neutral\";\n /** Bar thickness. */\n size?: Size;\n labels?: Partial<ProgressBarLabels>;\n className?: string;\n /** Layout only. Restyle through --cy-progress-bar-* tokens. */\n style?: CSSProperties;\n}\n\nconst percent = (value: number, max: number) => `${Math.round((value / max) * 100)}%`;\n\n/** How far a task has got: a labelled `role=\"progressbar\"`, determinate or indeterminate. */\nexport function ProgressBar({\n label,\n labelHidden = false,\n value,\n max = 100,\n indeterminate = false,\n showValue = false,\n segments,\n offset = 0,\n marker,\n markerLabel,\n tone = \"accent\",\n size = \"md\",\n labels,\n className,\n style,\n}: ProgressBarProps) {\n const id = useId();\n const top = max > 0 ? max : 100;\n const unknown = indeterminate || value === undefined || Number.isNaN(value);\n const now = unknown ? 0 : Math.min(Math.max(value, 0), top);\n const parts = segments?.length ? segments : null;\n const total = parts ? offset + parts.reduce((sum, p) => sum + Math.max(0, p.value), 0) : 0;\n const unknownBar = parts ? false : unknown;\n const shownNow = parts ? Math.min(total, top) : now;\n const at = (v: number) => `${(Math.min(Math.max(v, 0), top) / top) * 100}%`;\n const text = parts\n ? parts.map((p) => `${p.label} ${p.value}`).join(\", \")\n : unknown\n ? \"\"\n : (labels?.value ?? percent)(now, top);\n const spoken =\n marker === undefined\n ? text\n : [text, markerLabel ?? `marker at ${percent(marker, top)}`].filter(Boolean).join(\", \");\n return (\n <div\n className={className ? `cy-progress-bar ${className}` : \"cy-progress-bar\"}\n data-size={size}\n data-tone={tone}\n data-indeterminate={unknownBar || undefined}\n style={style}\n >\n {(!labelHidden || (showValue && !unknown)) && (\n <div className=\"cy-progress-bar-head cy-reset\">\n {!labelHidden && (\n <span id={`${id}-label`} className=\"cy-progress-bar-label cy-reset\">\n {label}\n </span>\n )}\n {showValue && !unknownBar && (\n <span className=\"cy-progress-bar-value cy-reset\" aria-hidden=\"true\">\n {text}\n </span>\n )}\n </div>\n )}\n <div\n role=\"progressbar\"\n className=\"cy-progress-bar-track cy-reset\"\n {...(labelHidden ? { \"aria-label\": label } : { \"aria-labelledby\": `${id}-label` })}\n aria-valuemin={0}\n aria-valuemax={top}\n aria-valuenow={unknownBar ? undefined : shownNow}\n aria-valuetext={unknownBar ? undefined : spoken}\n aria-busy={unknownBar || undefined}\n style={{ \"--_fill\": unknownBar || parts ? undefined : `${(now / top) * 100}%` } as CSSProperties}\n >\n {parts ? (\n parts.map((p, i) => {\n const start = offset + parts.slice(0, i).reduce((sum, q) => sum + Math.max(0, q.value), 0);\n return (\n <div\n key={`${p.label}-${i}`}\n className=\"cy-progress-bar-segment cy-reset\"\n data-tone={p.color ? undefined : (p.tone ?? tone)}\n style={\n {\n \"--_from\": at(start),\n \"--_to\": at(start + Math.max(0, p.value)),\n ...(p.color ? { \"--_seg\": p.color } : {}),\n } as CSSProperties\n }\n />\n );\n })\n ) : (\n <div className=\"cy-progress-bar-fill cy-reset\" />\n )}\n {marker !== undefined && (\n <div className=\"cy-progress-bar-marker cy-reset\" style={{ \"--_at\": at(marker) } as CSSProperties} />\n )}\n </div>\n </div>\n );\n}\n"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"ProgressBar.js","names":["useId","jsx","jsxs","percent","value","max","ProgressBar","label","labelHidden","indeterminate","showValue","segments","offset","marker","markerLabel","tone","size","labels","className","style","id","top","unknown","now","parts","total","sum","p","unknownBar","shownNow","at","v","text","spoken","start","q"],"sources":["../../../src/components/ProgressBar/ProgressBar.tsx"],"sourcesContent":["import { type CSSProperties, useId } from \"react\";\nimport type { Size, Tone } from \"../../tokens/schema.js\";\n\nexport interface ProgressBarTokens {\n heightSm: string;\n heightMd: string;\n heightLg: string;\n radius: string;\n track: string;\n}\n\ndeclare module \"../../tokens/schema.js\" {\n interface ComponentTokens {\n progressBar: ProgressBarTokens;\n }\n}\n\nexport interface ProgressBarLabels {\n /** Text for the current value, shown with `showValue` and read by screen readers. Default: \"42%\". */\n value: (value: number, max: number) => string;\n}\n\nexport interface ProgressSegment {\n value: number;\n /** Read out with the value (\"Connect 30\"). */\n label: string;\n tone?: Exclude<Tone, \"neutral\"> | \"neutral\";\n /** A category colour (any CSS colour); overrides `tone`. */\n color?: string;\n}\n\nexport interface ProgressBarProps {\n /** Accessible name, shown above the bar unless `labelHidden`. */\n label: string;\n /** Visually hide the label (it still names the bar). */\n labelHidden?: boolean;\n /** Current value between 0 and `max`. Leave it out (or pass `indeterminate`) when progress is unknown. */\n value?: number | undefined;\n /** The value that means complete. Default 100. */\n max?: number;\n /** Progress is happening but its amount is unknown. */\n indeterminate?: boolean;\n /** Show the value text at the end of the label row. */\n showValue?: boolean;\n /**\n * Parts drawn end to end instead of one fill, from `offset`: a request's timing (DNS, connect, wait, download) or a\n * waterfall row. Each has a `label` (read out) and a `tone` or category `color`.\n */\n segments?: ProgressSegment[] | undefined;\n /** Where the first segment starts, in the same units as `max`. Default 0. */\n offset?: number;\n /** A thin mark across the track at this value (a target, a second position). */\n marker?: number | undefined;\n /** Read with the value when there is a marker. Default \"marker at 75%\". */\n markerLabel?: string | undefined;\n /** Colour of the fill. Default \"accent\". */\n tone?: Exclude<Tone, \"neutral\"> | \"neutral\";\n /** Bar thickness. */\n size?: Size;\n /** Replace the built-in English text: the value text. */\n labels?: Partial<ProgressBarLabels>;\n /** Added to the root element, for layout. */\n className?: string;\n /** Layout only. Restyle through --cy-progress-bar-* tokens. */\n style?: CSSProperties;\n}\n\nconst percent = (value: number, max: number) => `${Math.round((value / max) * 100)}%`;\n\n/** How far a task has got: a labelled `role=\"progressbar\"`, determinate or indeterminate. */\nexport function ProgressBar({\n label,\n labelHidden = false,\n value,\n max = 100,\n indeterminate = false,\n showValue = false,\n segments,\n offset = 0,\n marker,\n markerLabel,\n tone = \"accent\",\n size = \"md\",\n labels,\n className,\n style,\n}: ProgressBarProps) {\n const id = useId();\n const top = max > 0 ? max : 100;\n const unknown = indeterminate || value === undefined || Number.isNaN(value);\n const now = unknown ? 0 : Math.min(Math.max(value, 0), top);\n const parts = segments?.length ? segments : null;\n const total = parts ? offset + parts.reduce((sum, p) => sum + Math.max(0, p.value), 0) : 0;\n const unknownBar = parts ? false : unknown;\n const shownNow = parts ? Math.min(total, top) : now;\n const at = (v: number) => `${(Math.min(Math.max(v, 0), top) / top) * 100}%`;\n const text = parts\n ? parts.map((p) => `${p.label} ${p.value}`).join(\", \")\n : unknown\n ? \"\"\n : (labels?.value ?? percent)(now, top);\n const spoken =\n marker === undefined\n ? text\n : [text, markerLabel ?? `marker at ${percent(marker, top)}`].filter(Boolean).join(\", \");\n return (\n <div\n className={className ? `cy-progress-bar ${className}` : \"cy-progress-bar\"}\n data-size={size}\n data-tone={tone}\n data-indeterminate={unknownBar || undefined}\n style={style}\n >\n {(!labelHidden || (showValue && !unknown)) && (\n <div className=\"cy-progress-bar-head cy-reset\">\n {!labelHidden && (\n <span id={`${id}-label`} className=\"cy-progress-bar-label cy-reset\">\n {label}\n </span>\n )}\n {showValue && !unknownBar && (\n <span className=\"cy-progress-bar-value cy-reset\" aria-hidden=\"true\">\n {text}\n </span>\n )}\n </div>\n )}\n <div\n role=\"progressbar\"\n className=\"cy-progress-bar-track cy-reset\"\n {...(labelHidden ? { \"aria-label\": label } : { \"aria-labelledby\": `${id}-label` })}\n aria-valuemin={0}\n aria-valuemax={top}\n aria-valuenow={unknownBar ? undefined : shownNow}\n aria-valuetext={unknownBar ? undefined : spoken}\n aria-busy={unknownBar || undefined}\n style={{ \"--_fill\": unknownBar || parts ? undefined : `${(now / top) * 100}%` } as CSSProperties}\n >\n {parts ? (\n parts.map((p, i) => {\n const start = offset + parts.slice(0, i).reduce((sum, q) => sum + Math.max(0, q.value), 0);\n return (\n <div\n key={`${p.label}-${i}`}\n className=\"cy-progress-bar-segment cy-reset\"\n data-tone={p.color ? undefined : (p.tone ?? tone)}\n style={\n {\n \"--_from\": at(start),\n \"--_to\": at(start + Math.max(0, p.value)),\n ...(p.color ? { \"--_seg\": p.color } : {}),\n } as CSSProperties\n }\n />\n );\n })\n ) : (\n <div className=\"cy-progress-bar-fill cy-reset\" />\n )}\n {marker !== undefined && (\n <div className=\"cy-progress-bar-marker cy-reset\" style={{ \"--_at\": at(marker) } as CSSProperties} />\n )}\n </div>\n </div>\n );\n}\n"],"mappings":";;;AAmEA,IAAMG,IAAA,CAAWC,GAAeC,MAAgB,GAAG,KAAK,MAAOD,IAAQC,IAAO,GAAG,CAAA;AAGjF,SAAgBC,EAAY,EAC1B,OAAAC,GACA,aAAAC,IAAc,IACd,OAAAJ,GACA,KAAAC,IAAM,KACN,eAAAI,IAAgB,IAChB,WAAAC,IAAY,IACZ,UAAAC,GACA,QAAAC,IAAS,GACT,QAAAC,GACA,aAAAC,GACA,MAAAC,IAAO,UACP,MAAAC,IAAO,MACP,QAAAC,GACA,WAAAC,GACA,OAAAC,EAAA,GACmB;AACnB,QAAMC,IAAKpB,EAAM,GACXqB,IAAMhB,IAAM,IAAIA,IAAM,KACtBiB,IAAUb,KAAiBL,MAAU,UAAa,OAAO,MAAMA,CAAK,GACpEmB,IAAMD,IAAU,IAAI,KAAK,IAAI,KAAK,IAAIlB,GAAO,CAAC,GAAGiB,CAAG,GACpDG,IAAQb,GAAU,SAASA,IAAW,MACtCc,IAAQD,IAAQZ,IAASY,EAAM,OAAA,CAAQE,GAAKC,MAAMD,IAAM,KAAK,IAAI,GAAGC,EAAE,KAAK,GAAG,CAAC,IAAI,GACnFC,IAAaJ,IAAQ,KAAQF,GAC7BO,IAAWL,IAAQ,KAAK,IAAIC,GAAOJ,CAAG,IAAIE,GAC1CO,IAAA,CAAMC,MAAc,GAAI,KAAK,IAAI,KAAK,IAAIA,GAAG,CAAC,GAAGV,CAAG,IAAIA,IAAO,GAAA,KAC/DW,IAAOR,IACTA,EAAM,IAAA,CAAKG,MAAM,GAAGA,EAAE,KAAA,IAASA,EAAE,KAAA,EAAO,EAAE,KAAK,IAAI,IACnDL,IACE,MACCL,GAAQ,SAASd,GAASoB,GAAKF,CAAG,GACnCY,IACJpB,MAAW,SACPmB,IACA,CAACA,GAAMlB,KAAe,aAAaX,EAAQU,GAAQQ,CAAG,CAAA,EAAG,EAAE,OAAO,OAAO,EAAE,KAAK,IAAI;AAC1F,SACE,gBAAAnB,EAAC,OAAD;AAAA,IACE,WAAWgB,IAAY,mBAAmBA,CAAA,KAAc;AAAA,IACxD,aAAWF;AAAA,IACX,aAAWD;AAAA,IACX,sBAAoBa,KAAc;AAAA,IAC3B,OAAAT;AAAA,IALT,UAAA,EAOI,CAACX,KAAgBE,KAAa,CAACY,MAC/B,gBAAApB,EAAC,OAAD;AAAA,MAAK,WAAU;AAAA,MAAf,UAAA,CACG,CAACM,KACA,gBAAAP,EAAC,QAAD;AAAA,QAAM,IAAI,GAAGmB,CAAA;AAAA,QAAY,WAAU;AAAA,QAChC,UAAAb;AAAA,MACG,CAAA,GAEPG,KAAa,CAACkB,KACb,gBAAA3B,EAAC,QAAD;AAAA,QAAM,WAAU;AAAA,QAAiC,eAAY;AAAA,QAC1D,UAAA+B;AAAA,MACG,CAAA,CAEL;AAAA,IAEP,CAAA,GAAA,gBAAA9B,EAAC,OAAD;AAAA,MACE,MAAK;AAAA,MACL,WAAU;AAAA,MACV,GAAKM,IAAc,EAAE,cAAcD,EAAM,IAAI,EAAE,mBAAmB,GAAGa,CAAA,SAAW;AAAA,MAChF,iBAAe;AAAA,MACf,iBAAeC;AAAA,MACf,iBAAeO,IAAa,SAAYC;AAAA,MACxC,kBAAgBD,IAAa,SAAYK;AAAA,MACzC,aAAWL,KAAc;AAAA,MACzB,OAAO,EAAE,WAAWA,KAAcJ,IAAQ,SAAY,GAAID,IAAMF,IAAO,GAAA,IAAO;AAAA,MAThF,UAAA,CAWGG,IACCA,EAAM,IAAA,CAAKG,GAAG,MAAM;AAClB,cAAMO,IAAQtB,IAASY,EAAM,MAAM,GAAG,CAAC,EAAE,OAAA,CAAQE,GAAKS,MAAMT,IAAM,KAAK,IAAI,GAAGS,EAAE,KAAK,GAAG,CAAC;AACzF,eACE,gBAAAlC,EAAC,OAAD;AAAA,UAEE,WAAU;AAAA,UACV,aAAW0B,EAAE,QAAQ,SAAaA,EAAE,QAAQZ;AAAA,UAC5C,OACE;AAAA,YACE,WAAWe,EAAGI,CAAK;AAAA,YACnB,SAASJ,EAAGI,IAAQ,KAAK,IAAI,GAAGP,EAAE,KAAK,CAAC;AAAA,YACxC,GAAIA,EAAE,QAAQ,EAAE,UAAUA,EAAE,MAAM,IAAI,CAAC;AAAA,UACzC;AAAA,QAEH,GAVM,GAAGA,EAAE,KAAA,IAAS,CAAA,EAUpB;AAAA,MAEL,CAAC,IAED,gBAAA1B,EAAC,OAAD,EAAK,WAAU,gCAAiC,CAAA,GAEjDY,MAAW,UACV,gBAAAZ,EAAC,OAAD;AAAA,QAAK,WAAU;AAAA,QAAkC,OAAO,EAAE,SAAS6B,EAAGjB,CAAM,EAAE;AAAA,MAAqB,CAAA,CAElG;AAAA,IACF,CAAA,CAAA;AAAA,E;AAET"}
|
|
@@ -14,12 +14,15 @@ export interface ProgressOverlayProps {
|
|
|
14
14
|
title: string;
|
|
15
15
|
/** How far it has got; leave undefined while the amount is unknown. */
|
|
16
16
|
value?: number | undefined;
|
|
17
|
+
/** The value that means complete. Default 100. */
|
|
17
18
|
max?: number | undefined;
|
|
18
19
|
/** A line under the bar ("Page 3: images"). Default: the count, or "Working…". Read out politely as it changes. */
|
|
19
20
|
status?: string | undefined;
|
|
20
21
|
/** Cancels the work: the Cancel button and Escape. Without it the overlay cannot be closed. */
|
|
21
22
|
onCancel?: (() => void) | undefined;
|
|
23
|
+
/** Replace the built-in English text: the Cancel button and the status line. */
|
|
22
24
|
labels?: Partial<ProgressOverlayLabels>;
|
|
25
|
+
/** Added to the dialog's panel, for layout. */
|
|
23
26
|
className?: string;
|
|
24
27
|
/** Layout only. */
|
|
25
28
|
style?: CSSProperties;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProgressOverlay.js","names":["Button","Dialog","ProgressBar","jsx","jsxs","DEFAULT_LABELS","value","max","ProgressOverlay","open","title","status","onCancel","labels","className","style","text","known","line","next"],"sources":["../../../src/components/ProgressOverlay/ProgressOverlay.tsx"],"sourcesContent":["import type { CSSProperties } from \"react\";\nimport { Button } from \"../Button/Button.js\";\nimport { Dialog } from \"../Dialog/Dialog.js\";\nimport { ProgressBar } from \"../ProgressBar/ProgressBar.js\";\n\nexport interface ProgressOverlayLabels {\n /** The Cancel button. Default \"Cancel\". */\n cancel: string;\n /** Status while the amount is unknown. Default \"Working…\". */\n working: string;\n /** Status from the counts. Default \"3 of 12\". */\n count: (value: number, max: number) => string;\n}\n\nexport interface ProgressOverlayProps {\n /** Show it. */\n open: boolean;\n /** What is happening (\"Compressing the PDF\"). Names the dialog and the progress bar. */\n title: string;\n /** How far it has got; leave undefined while the amount is unknown. */\n value?: number | undefined;\n max?: number | undefined;\n /** A line under the bar (\"Page 3: images\"). Default: the count, or \"Working…\". Read out politely as it changes. */\n status?: string | undefined;\n /** Cancels the work: the Cancel button and Escape. Without it the overlay cannot be closed. */\n onCancel?: (() => void) | undefined;\n labels?: Partial<ProgressOverlayLabels>;\n className?: string;\n /** Layout only. */\n style?: CSSProperties;\n}\n\nconst DEFAULT_LABELS: ProgressOverlayLabels = {\n cancel: \"Cancel\",\n working: \"Working…\",\n count: (value, max) => `${value} of ${max}`,\n};\n\n/**\n * Modal progress for long work the page must wait for (exporting, compressing, converting): a Dialog with a\n * ProgressBar and a status line. Escape and Cancel call `onCancel`; with no `onCancel` it stays until the work ends.\n */\nexport function ProgressOverlay({\n open,\n title,\n value,\n max = 100,\n status,\n onCancel,\n labels,\n className,\n style,\n}: ProgressOverlayProps) {\n const text = { ...DEFAULT_LABELS, ...labels };\n const known = value !== undefined;\n const line = status ?? (known ? text.count(Math.min(Math.max(value, 0), max), max) : text.working);\n return (\n <Dialog\n open={open}\n onOpenChange={(next) => !next && onCancel?.()}\n title={title}\n size=\"sm\"\n dismissible={!!onCancel}\n actions={onCancel && <Button onClick={onCancel}>{text.cancel}</Button>}\n className={className ? `cy-progress-overlay ${className}` : \"cy-progress-overlay\"}\n {...(style ? { style } : {})}\n >\n <ProgressBar\n label={title}\n labelHidden\n value={value}\n max={max}\n indeterminate={!known}\n labels={{ value: text.count }}\n />\n <p className=\"cy-progress-overlay-status cy-reset\" aria-live=\"polite\">\n {line}\n </p>\n </Dialog>\n );\n}\n"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"ProgressOverlay.js","names":["Button","Dialog","ProgressBar","jsx","jsxs","DEFAULT_LABELS","value","max","ProgressOverlay","open","title","status","onCancel","labels","className","style","text","known","line","next"],"sources":["../../../src/components/ProgressOverlay/ProgressOverlay.tsx"],"sourcesContent":["import type { CSSProperties } from \"react\";\nimport { Button } from \"../Button/Button.js\";\nimport { Dialog } from \"../Dialog/Dialog.js\";\nimport { ProgressBar } from \"../ProgressBar/ProgressBar.js\";\n\nexport interface ProgressOverlayLabels {\n /** The Cancel button. Default \"Cancel\". */\n cancel: string;\n /** Status while the amount is unknown. Default \"Working…\". */\n working: string;\n /** Status from the counts. Default \"3 of 12\". */\n count: (value: number, max: number) => string;\n}\n\nexport interface ProgressOverlayProps {\n /** Show it. */\n open: boolean;\n /** What is happening (\"Compressing the PDF\"). Names the dialog and the progress bar. */\n title: string;\n /** How far it has got; leave undefined while the amount is unknown. */\n value?: number | undefined;\n /** The value that means complete. Default 100. */\n max?: number | undefined;\n /** A line under the bar (\"Page 3: images\"). Default: the count, or \"Working…\". Read out politely as it changes. */\n status?: string | undefined;\n /** Cancels the work: the Cancel button and Escape. Without it the overlay cannot be closed. */\n onCancel?: (() => void) | undefined;\n /** Replace the built-in English text: the Cancel button and the status line. */\n labels?: Partial<ProgressOverlayLabels>;\n /** Added to the dialog's panel, for layout. */\n className?: string;\n /** Layout only. */\n style?: CSSProperties;\n}\n\nconst DEFAULT_LABELS: ProgressOverlayLabels = {\n cancel: \"Cancel\",\n working: \"Working…\",\n count: (value, max) => `${value} of ${max}`,\n};\n\n/**\n * Modal progress for long work the page must wait for (exporting, compressing, converting): a Dialog with a\n * ProgressBar and a status line. Escape and Cancel call `onCancel`; with no `onCancel` it stays until the work ends.\n */\nexport function ProgressOverlay({\n open,\n title,\n value,\n max = 100,\n status,\n onCancel,\n labels,\n className,\n style,\n}: ProgressOverlayProps) {\n const text = { ...DEFAULT_LABELS, ...labels };\n const known = value !== undefined;\n const line = status ?? (known ? text.count(Math.min(Math.max(value, 0), max), max) : text.working);\n return (\n <Dialog\n open={open}\n onOpenChange={(next) => !next && onCancel?.()}\n title={title}\n size=\"sm\"\n dismissible={!!onCancel}\n actions={onCancel && <Button onClick={onCancel}>{text.cancel}</Button>}\n className={className ? `cy-progress-overlay ${className}` : \"cy-progress-overlay\"}\n {...(style ? { style } : {})}\n >\n <ProgressBar\n label={title}\n labelHidden\n value={value}\n max={max}\n indeterminate={!known}\n labels={{ value: text.count }}\n />\n <p className=\"cy-progress-overlay-status cy-reset\" aria-live=\"polite\">\n {line}\n </p>\n </Dialog>\n );\n}\n"],"mappings":";;;;;AAmCA,IAAMK,IAAwC;AAAA,EAC5C,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,OAAA,CAAQC,GAAOC,MAAQ,GAAGD,CAAA,OAAYC,CAAA;AACxC;AAMA,SAAgBC,EAAgB,EAC9B,MAAAC,GACA,OAAAC,GACA,OAAAJ,GACA,KAAAC,IAAM,KACN,QAAAI,GACA,UAAAC,GACA,QAAAC,GACA,WAAAC,GACA,OAAAC,EAAA,GACuB;AACvB,QAAMC,IAAO;AAAA,IAAE,GAAGX;AAAA,IAAgB,GAAGQ;AAAA,EAAO,GACtCI,IAAQX,MAAU,QAClBY,IAAOP,MAAWM,IAAQD,EAAK,MAAM,KAAK,IAAI,KAAK,IAAIV,GAAO,CAAC,GAAGC,CAAG,GAAGA,CAAG,IAAIS,EAAK;AAC1F,SACE,gBAAAZ,EAACH,GAAD;AAAA,IACQ,MAAAQ;AAAA,IACN,cAAA,CAAeU,MAAS,CAACA,KAAQP,IAAW;AAAA,IACrC,OAAAF;AAAA,IACP,MAAK;AAAA,IACL,aAAa,CAAC,CAACE;AAAA,IACf,SAASA,KAAY,gBAAAT,EAACH,GAAD;AAAA,MAAQ,SAASY;AAAA,MAAW,UAAAI,EAAK;AAAA,IAAe,CAAA;AAAA,IACrE,WAAWF,IAAY,uBAAuBA,CAAA,KAAc;AAAA,IAC5D,GAAKC,IAAQ,EAAE,OAAAA,EAAM,IAAI,CAAC;AAAA,IAR5B,UAAA,CAUE,gBAAAZ,EAACD,GAAD;AAAA,MACE,OAAOQ;AAAA,MACP,aAAA;AAAA,MACO,OAAAJ;AAAA,MACF,KAAAC;AAAA,MACL,eAAe,CAACU;AAAA,MAChB,QAAQ,EAAE,OAAOD,EAAK,MAAM;AAAA,IAC7B,CAAA,GACD,gBAAAb,EAAC,KAAD;AAAA,MAAG,WAAU;AAAA,MAAsC,aAAU;AAAA,MAC1D,UAAAe;AAAA,IACA,CAAA,CACG;AAAA,E;AAEZ"}
|
|
@@ -20,6 +20,7 @@ export interface ProseProps {
|
|
|
20
20
|
size?: Size;
|
|
21
21
|
/** Neutral element to render. Use `article` for a standalone piece of writing. */
|
|
22
22
|
as?: "div" | "article" | "section";
|
|
23
|
+
/** Added to the root element, for layout. */
|
|
23
24
|
className?: string;
|
|
24
25
|
/** Layout only. Restyle through --cy-prose-* tokens. */
|
|
25
26
|
style?: CSSProperties;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Prose.js","names":["jsx","Prose","size","Tag","className","style","children"],"sources":["../../../src/components/Prose/Prose.tsx"],"sourcesContent":["import type { CSSProperties, ReactNode } from \"react\";\nimport type { Size } from \"../../tokens/schema.js\";\n\nexport interface ProseTokens {\n /** Longest line length. */\n measure: string;\n /** Space between blocks (paragraphs, lists, headings). */\n flow: string;\n /** Link colour. */\n link: string;\n /** Background of inline code and code blocks. */\n codeBackground: string;\n}\n\ndeclare module \"../../tokens/schema.js\" {\n interface ComponentTokens {\n prose: ProseTokens;\n }\n}\n\nexport interface ProseProps {\n /** Body text size; headings scale from it. */\n size?: Size;\n /** Neutral element to render. Use `article` for a standalone piece of writing. */\n as?: \"div\" | \"article\" | \"section\";\n className?: string;\n /** Layout only. Restyle through --cy-prose-* tokens. */\n style?: CSSProperties;\n /** Rendered Markdown or other long-form HTML. Cynosure components inside keep their own styles. */\n children?: ReactNode;\n}\n\n/** Typography for long text you do not style element by element: rendered Markdown, docs, release notes, help. */\nexport function Prose({ size = \"md\", as: Tag = \"div\", className, style, children }: ProseProps) {\n return (\n <Tag className={className ? `cy-prose ${className}` : \"cy-prose\"} data-size={size} style={style}>\n {children}\n </Tag>\n );\n}\n"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"Prose.js","names":["jsx","Prose","size","Tag","className","style","children"],"sources":["../../../src/components/Prose/Prose.tsx"],"sourcesContent":["import type { CSSProperties, ReactNode } from \"react\";\nimport type { Size } from \"../../tokens/schema.js\";\n\nexport interface ProseTokens {\n /** Longest line length. */\n measure: string;\n /** Space between blocks (paragraphs, lists, headings). */\n flow: string;\n /** Link colour. */\n link: string;\n /** Background of inline code and code blocks. */\n codeBackground: string;\n}\n\ndeclare module \"../../tokens/schema.js\" {\n interface ComponentTokens {\n prose: ProseTokens;\n }\n}\n\nexport interface ProseProps {\n /** Body text size; headings scale from it. */\n size?: Size;\n /** Neutral element to render. Use `article` for a standalone piece of writing. */\n as?: \"div\" | \"article\" | \"section\";\n /** Added to the root element, for layout. */\n className?: string;\n /** Layout only. Restyle through --cy-prose-* tokens. */\n style?: CSSProperties;\n /** Rendered Markdown or other long-form HTML. Cynosure components inside keep their own styles. */\n children?: ReactNode;\n}\n\n/** Typography for long text you do not style element by element: rendered Markdown, docs, release notes, help. */\nexport function Prose({ size = \"md\", as: Tag = \"div\", className, style, children }: ProseProps) {\n return (\n <Tag className={className ? `cy-prose ${className}` : \"cy-prose\"} data-size={size} style={style}>\n {children}\n </Tag>\n );\n}\n"],"mappings":";;AAkCA,SAAgBC,EAAM,EAAE,MAAAC,IAAO,MAAM,IAAIC,IAAM,OAAO,WAAAC,GAAW,OAAAC,GAAO,UAAAC,EAAA,GAAwB;AAC9F,SACE,gBAAAN,EAACG,GAAD;AAAA,IAAK,WAAWC,IAAY,YAAYA,CAAA,KAAc;AAAA,IAAY,aAAWF;AAAA,IAAa,OAAAG;AAAA,IACvF,UAAAC;AAAA,EACE,CAAA;AAET"}
|
|
@@ -7,22 +7,35 @@ export interface RadioOption {
|
|
|
7
7
|
disabled?: boolean;
|
|
8
8
|
}
|
|
9
9
|
export interface RadioGroupProps {
|
|
10
|
+
/** Names the group, shown above the options. */
|
|
10
11
|
label: ReactNode;
|
|
11
12
|
/** Visually hide the label (it still names the control). Prefer visible labels. */
|
|
12
13
|
labelHidden?: boolean | undefined;
|
|
14
|
+
/** Help text shown below the options. */
|
|
13
15
|
description?: ReactNode;
|
|
16
|
+
/** Error message shown below the options and announced. */
|
|
14
17
|
error?: ReactNode;
|
|
18
|
+
/** The choices: `{ value, label, description?, disabled? }`. */
|
|
15
19
|
options: RadioOption[];
|
|
16
20
|
/** Native group name (generated when omitted). */
|
|
17
21
|
name?: string;
|
|
22
|
+
/** Controlled selected value. */
|
|
18
23
|
value?: string;
|
|
24
|
+
/** Selected value at first, when uncontrolled. */
|
|
19
25
|
defaultValue?: string | undefined;
|
|
26
|
+
/** Called with the option's value when it is chosen. */
|
|
20
27
|
onChange?: (value: string) => void;
|
|
28
|
+
/** Stack the options, or lay them in a row that wraps. Default "vertical". */
|
|
21
29
|
orientation?: "vertical" | "horizontal";
|
|
30
|
+
/** The form will not submit until an option is chosen; also draws the required marker. */
|
|
22
31
|
required?: boolean;
|
|
32
|
+
/** Disables every option. */
|
|
23
33
|
disabled?: boolean;
|
|
34
|
+
/** Size of the radios and their text. Default "md". */
|
|
24
35
|
size?: Size;
|
|
36
|
+
/** Colour of the chosen radio. Default "accent". */
|
|
25
37
|
tone?: Tone;
|
|
38
|
+
/** Added to the root element, for layout. */
|
|
26
39
|
className?: string;
|
|
27
40
|
/** Layout only. */
|
|
28
41
|
style?: CSSProperties;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RadioGroup.js","names":["ChoiceRow","Field","useId","jsx","RadioGroup","label","labelHidden","description","error","options","name","value","defaultValue","onChange","orientation","required","disabled","size","tone","className","style","generated","groupName","option","checked"],"sources":["../../../src/components/RadioGroup/RadioGroup.tsx"],"sourcesContent":["import { type CSSProperties, type ReactNode, useId } from \"react\";\nimport type { Size, Tone } from \"../../tokens/schema.js\";\nimport { ChoiceRow } from \"../Checkbox/ChoiceRow.js\";\nimport { Field } from \"../Field/Field.js\";\n\nexport interface RadioOption {\n value: string;\n label: ReactNode;\n description?: ReactNode;\n disabled?: boolean;\n}\n\nexport interface RadioGroupProps {\n label: ReactNode;\n /** Visually hide the label (it still names the control). Prefer visible labels. */\n labelHidden?: boolean | undefined;\n description?: ReactNode;\n error?: ReactNode;\n options: RadioOption[];\n /** Native group name (generated when omitted). */\n name?: string;\n value?: string;\n defaultValue?: string | undefined;\n onChange?: (value: string) => void;\n orientation?: \"vertical\" | \"horizontal\";\n required?: boolean;\n disabled?: boolean;\n size?: Size;\n tone?: Tone;\n className?: string;\n /** Layout only. */\n style?: CSSProperties;\n}\n\n/** One choice from a list, on native radios: arrows, wrap, disabled skipping, RTL, forms and reset are native. */\nexport function RadioGroup({\n label,\n labelHidden,\n description,\n error,\n options,\n name,\n value,\n defaultValue,\n onChange,\n orientation = \"vertical\",\n required,\n disabled,\n size = \"md\",\n tone = \"accent\",\n className,\n style,\n}: RadioGroupProps) {\n const generated = useId();\n const groupName = name ?? `cy-radio-${generated}`;\n return (\n <Field\n group\n label={label}\n labelHidden={labelHidden}\n description={description}\n error={error}\n required={required}\n size={size}\n className={className}\n style={style}\n >\n {() => (\n <div className=\"cy-radio-group\" data-orientation={orientation}>\n {options.map((option) => (\n <ChoiceRow\n key={option.value}\n kind=\"radio\"\n label={option.label}\n description={option.description}\n name={groupName}\n value={option.value}\n required={required}\n disabled={disabled || option.disabled}\n size={size}\n tone={tone}\n {...(value !== undefined\n ? { checked: value === option.value }\n : { defaultChecked: defaultValue === option.value })}\n onChange={(checked) => checked && onChange?.(option.value)}\n />\n ))}\n </div>\n )}\n </Field>\n );\n}\n"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"RadioGroup.js","names":["ChoiceRow","Field","useId","jsx","RadioGroup","label","labelHidden","description","error","options","name","value","defaultValue","onChange","orientation","required","disabled","size","tone","className","style","generated","groupName","option","checked"],"sources":["../../../src/components/RadioGroup/RadioGroup.tsx"],"sourcesContent":["import { type CSSProperties, type ReactNode, useId } from \"react\";\nimport type { Size, Tone } from \"../../tokens/schema.js\";\nimport { ChoiceRow } from \"../Checkbox/ChoiceRow.js\";\nimport { Field } from \"../Field/Field.js\";\n\nexport interface RadioOption {\n value: string;\n label: ReactNode;\n description?: ReactNode;\n disabled?: boolean;\n}\n\nexport interface RadioGroupProps {\n /** Names the group, shown above the options. */\n label: ReactNode;\n /** Visually hide the label (it still names the control). Prefer visible labels. */\n labelHidden?: boolean | undefined;\n /** Help text shown below the options. */\n description?: ReactNode;\n /** Error message shown below the options and announced. */\n error?: ReactNode;\n /** The choices: `{ value, label, description?, disabled? }`. */\n options: RadioOption[];\n /** Native group name (generated when omitted). */\n name?: string;\n /** Controlled selected value. */\n value?: string;\n /** Selected value at first, when uncontrolled. */\n defaultValue?: string | undefined;\n /** Called with the option's value when it is chosen. */\n onChange?: (value: string) => void;\n /** Stack the options, or lay them in a row that wraps. Default \"vertical\". */\n orientation?: \"vertical\" | \"horizontal\";\n /** The form will not submit until an option is chosen; also draws the required marker. */\n required?: boolean;\n /** Disables every option. */\n disabled?: boolean;\n /** Size of the radios and their text. Default \"md\". */\n size?: Size;\n /** Colour of the chosen radio. Default \"accent\". */\n tone?: Tone;\n /** Added to the root element, for layout. */\n className?: string;\n /** Layout only. */\n style?: CSSProperties;\n}\n\n/** One choice from a list, on native radios: arrows, wrap, disabled skipping, RTL, forms and reset are native. */\nexport function RadioGroup({\n label,\n labelHidden,\n description,\n error,\n options,\n name,\n value,\n defaultValue,\n onChange,\n orientation = \"vertical\",\n required,\n disabled,\n size = \"md\",\n tone = \"accent\",\n className,\n style,\n}: RadioGroupProps) {\n const generated = useId();\n const groupName = name ?? `cy-radio-${generated}`;\n return (\n <Field\n group\n label={label}\n labelHidden={labelHidden}\n description={description}\n error={error}\n required={required}\n size={size}\n className={className}\n style={style}\n >\n {() => (\n <div className=\"cy-radio-group\" data-orientation={orientation}>\n {options.map((option) => (\n <ChoiceRow\n key={option.value}\n kind=\"radio\"\n label={option.label}\n description={option.description}\n name={groupName}\n value={option.value}\n required={required}\n disabled={disabled || option.disabled}\n size={size}\n tone={tone}\n {...(value !== undefined\n ? { checked: value === option.value }\n : { defaultChecked: defaultValue === option.value })}\n onChange={(checked) => checked && onChange?.(option.value)}\n />\n ))}\n </div>\n )}\n </Field>\n );\n}\n"],"mappings":";;;;;AAgDA,SAAgBI,EAAW,EACzB,OAAAC,GACA,aAAAC,GACA,aAAAC,GACA,OAAAC,GACA,SAAAC,GACA,MAAAC,GACA,OAAAC,GACA,cAAAC,GACA,UAAAC,GACA,aAAAC,IAAc,YACd,UAAAC,GACA,UAAAC,GACA,MAAAC,IAAO,MACP,MAAAC,IAAO,UACP,WAAAC,GACA,OAAAC,EAAA,GACkB;AAClB,QAAMC,IAAYnB,EAAM,GAClBoB,IAAYZ,KAAQ,YAAYW,CAAA;AACtC,SACE,gBAAAlB,EAACF,GAAD;AAAA,IACE,OAAA;AAAA,IACO,OAAAI;AAAA,IACM,aAAAC;AAAA,IACA,aAAAC;AAAA,IACN,OAAAC;AAAA,IACG,UAAAO;AAAA,IACJ,MAAAE;AAAA,IACK,WAAAE;AAAA,IACJ,OAAAC;AAAA,IAGL,UAAA,MAAA,gBAAAjB,EAAC,OAAD;AAAA,MAAK,WAAU;AAAA,MAAiB,oBAAkBW;AAAA,MAC/C,UAAAL,EAAQ,IAAA,CAAKc,MACZ,gBAAApB,EAACH,GAAD;AAAA,QAEE,MAAK;AAAA,QACL,OAAOuB,EAAO;AAAA,QACd,aAAaA,EAAO;AAAA,QACpB,MAAMD;AAAA,QACN,OAAOC,EAAO;AAAA,QACJ,UAAAR;AAAA,QACV,UAAUC,KAAYO,EAAO;AAAA,QACvB,MAAAN;AAAA,QACA,MAAAC;AAAA,QACN,GAAKP,MAAU,SACX,EAAE,SAASA,MAAUY,EAAO,MAAM,IAClC,EAAE,gBAAgBX,MAAiBW,EAAO,MAAM;AAAA,QACpD,UAAA,CAAWC,MAAYA,KAAWX,IAAWU,EAAO,KAAK;AAAA,MAC1D,GAdMA,EAAO,KAcb,CACF;AAAA,IACE,CAAA;AAAA,EAEF,CAAA;AAEX"}
|
|
@@ -22,18 +22,27 @@ export interface SegmentOption {
|
|
|
22
22
|
export interface SegmentedControlProps {
|
|
23
23
|
/** Accessible name of the group. */
|
|
24
24
|
label: string;
|
|
25
|
+
/** The segments: `{ value, label, icon?, disabled? }`. */
|
|
25
26
|
options: SegmentOption[];
|
|
27
|
+
/** Submits the value with its form under this name. Two controls may share a name and stay independent. */
|
|
26
28
|
name?: string;
|
|
29
|
+
/** Controlled selected value. */
|
|
27
30
|
value?: string;
|
|
31
|
+
/** Selected value at first, when uncontrolled. */
|
|
28
32
|
defaultValue?: string;
|
|
33
|
+
/** Called with the segment's value when it is chosen. */
|
|
29
34
|
onChange?: (value: string) => void;
|
|
30
35
|
/** Show icons only; labels stay as accessible names. */
|
|
31
36
|
iconOnly?: boolean;
|
|
37
|
+
/** Stretch to the full width of the container. */
|
|
32
38
|
fullWidth?: boolean;
|
|
39
|
+
/** Disables every segment; the value is not submitted. */
|
|
33
40
|
disabled?: boolean;
|
|
41
|
+
/** Height and text size of the segments. Default "md". */
|
|
34
42
|
size?: Size;
|
|
35
43
|
/** Colour of the active segment's content. */
|
|
36
44
|
tone?: Tone;
|
|
45
|
+
/** Added to the root element, for layout. */
|
|
37
46
|
className?: string | undefined;
|
|
38
47
|
/** Layout only. */
|
|
39
48
|
style?: CSSProperties | undefined;
|
|
@@ -1,45 +1,53 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
import { useControllableState as x } from "../../foundations/controllable.js";
|
|
3
|
+
import { Icon as N } from "../../foundations/Icon/Icon.js";
|
|
4
|
+
import { ChoiceBase as j } from "../../foundations/ChoiceBase/ChoiceBase.js";
|
|
5
|
+
import { HiddenValue as k } from "../../foundations/HiddenValue/HiddenValue.js";
|
|
6
|
+
import { useId as I } from "react";
|
|
7
|
+
import { jsx as a, jsxs as t } from "react/jsx-runtime";
|
|
8
|
+
function R({ label: i, options: n, name: u, value: o, defaultValue: s, onChange: v, iconOnly: c = !1, fullWidth: b = !1, disabled: l, size: f = "md", tone: g = "neutral", className: m, style: h }) {
|
|
9
|
+
const r = `cy-seg-${I()}`, [d, $, y] = x(o, s, v);
|
|
10
|
+
return /* @__PURE__ */ t("div", {
|
|
9
11
|
role: "radiogroup",
|
|
10
|
-
"aria-label":
|
|
11
|
-
className: `cy-segmented${
|
|
12
|
-
"data-size":
|
|
13
|
-
"data-tone":
|
|
14
|
-
"data-full":
|
|
15
|
-
"data-icon-only":
|
|
16
|
-
style:
|
|
17
|
-
children:
|
|
18
|
-
|
|
12
|
+
"aria-label": i,
|
|
13
|
+
className: `cy-segmented${m ? ` ${m}` : ""}`,
|
|
14
|
+
"data-size": f,
|
|
15
|
+
"data-tone": g,
|
|
16
|
+
"data-full": b ? "" : void 0,
|
|
17
|
+
"data-icon-only": c ? "" : void 0,
|
|
18
|
+
style: h,
|
|
19
|
+
children: [/* @__PURE__ */ a(k, {
|
|
20
|
+
name: u,
|
|
21
|
+
value: d ?? "",
|
|
22
|
+
disabled: l || d === void 0,
|
|
23
|
+
onReset: () => y(s)
|
|
24
|
+
}), n.map((e) => /* @__PURE__ */ t("label", {
|
|
25
|
+
htmlFor: `${r}-${e.value}`,
|
|
19
26
|
className: "cy-segment",
|
|
20
|
-
"data-disabled":
|
|
27
|
+
"data-disabled": l || e.disabled ? "" : void 0,
|
|
21
28
|
children: [
|
|
22
|
-
/* @__PURE__ */ a(
|
|
23
|
-
id: `${
|
|
29
|
+
/* @__PURE__ */ a(j, {
|
|
30
|
+
id: `${r}-${e.value}`,
|
|
24
31
|
type: "radio",
|
|
25
|
-
name:
|
|
32
|
+
name: r,
|
|
33
|
+
form: "",
|
|
26
34
|
value: e.value,
|
|
27
|
-
disabled:
|
|
35
|
+
disabled: l || e.disabled,
|
|
28
36
|
"aria-label": e.label,
|
|
29
|
-
|
|
30
|
-
onChange: (
|
|
37
|
+
checked: d === e.value,
|
|
38
|
+
onChange: (C) => C.currentTarget.checked && $(e.value)
|
|
31
39
|
}),
|
|
32
|
-
e.icon && /* @__PURE__ */ a(
|
|
33
|
-
!
|
|
40
|
+
e.icon && /* @__PURE__ */ a(N, { icon: e.icon }),
|
|
41
|
+
!c && /* @__PURE__ */ a("span", {
|
|
34
42
|
className: "cy-segment-label",
|
|
35
43
|
children: e.label
|
|
36
44
|
})
|
|
37
45
|
]
|
|
38
|
-
}, e.value))
|
|
46
|
+
}, e.value))]
|
|
39
47
|
});
|
|
40
48
|
}
|
|
41
49
|
export {
|
|
42
|
-
|
|
50
|
+
R as SegmentedControl
|
|
43
51
|
};
|
|
44
52
|
|
|
45
53
|
//# sourceMappingURL=SegmentedControl.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SegmentedControl.js","names":["Icon","ChoiceBase","useId","jsx","jsxs","SegmentedControl","label","options","name","value","defaultValue","onChange","iconOnly","fullWidth","disabled","size","tone","className","style","
|
|
1
|
+
{"version":3,"file":"SegmentedControl.js","names":["useControllableState","Icon","ChoiceBase","HiddenValue","useId","jsx","jsxs","SegmentedControl","label","options","name","value","defaultValue","onChange","iconOnly","fullWidth","disabled","size","tone","className","style","groupName","current","setCurrent","reset","option","e"],"sources":["../../../src/components/SegmentedControl/SegmentedControl.tsx"],"sourcesContent":["import { type CSSProperties, useId } from \"react\";\nimport { ChoiceBase } from \"../../foundations/ChoiceBase/ChoiceBase.js\";\nimport { useControllableState } from \"../../foundations/controllable.js\";\nimport { HiddenValue } from \"../../foundations/HiddenValue/HiddenValue.js\";\nimport { Icon } from \"../../foundations/Icon/Icon.js\";\nimport type { IconData } from \"../../icons/types.js\";\nimport type { Size, Tone } from \"../../tokens/schema.js\";\n\nexport interface SegmentedControlTokens {\n radius: string;\n trackBg: string;\n activeBg: string;\n padding: string;\n}\n\ndeclare module \"../../tokens/schema.js\" {\n interface ComponentTokens {\n segmentedControl: SegmentedControlTokens;\n }\n}\n\nexport interface SegmentOption {\n value: string;\n /** Visible text, and always the accessible name (also for icon-only segments). */\n label: string;\n icon?: IconData;\n disabled?: boolean;\n}\n\nexport interface SegmentedControlProps {\n /** Accessible name of the group. */\n label: string;\n /** The segments: `{ value, label, icon?, disabled? }`. */\n options: SegmentOption[];\n /** Submits the value with its form under this name. Two controls may share a name and stay independent. */\n name?: string;\n /** Controlled selected value. */\n value?: string;\n /** Selected value at first, when uncontrolled. */\n defaultValue?: string;\n /** Called with the segment's value when it is chosen. */\n onChange?: (value: string) => void;\n /** Show icons only; labels stay as accessible names. */\n iconOnly?: boolean;\n /** Stretch to the full width of the container. */\n fullWidth?: boolean;\n /** Disables every segment; the value is not submitted. */\n disabled?: boolean;\n /** Height and text size of the segments. Default \"md\". */\n size?: Size;\n /** Colour of the active segment's content. */\n tone?: Tone;\n /** Added to the root element, for layout. */\n className?: string | undefined;\n /** Layout only. */\n style?: CSSProperties | undefined;\n}\n\n/** A compact single choice (view switchers, modes) on native radios. */\nexport function SegmentedControl({\n label,\n options,\n name,\n value,\n defaultValue,\n onChange,\n iconOnly = false,\n fullWidth = false,\n disabled,\n size = \"md\",\n tone = \"neutral\",\n className,\n style,\n}: SegmentedControlProps) {\n // The radios are grouped under a name of the control's own, never the caller's: two controls given the same\n // `name` (rows of a list, two panels) would otherwise be one native radio group with clashing ids, and choosing in\n // one would clear the other. The caller's `name` submits the value through a hidden field instead.\n const groupName = `cy-seg-${useId()}`;\n const [current, setCurrent, reset] = useControllableState<string, string | undefined>(\n value,\n defaultValue,\n onChange,\n );\n return (\n <div\n role=\"radiogroup\"\n aria-label={label}\n className={`cy-segmented${className ? ` ${className}` : \"\"}`}\n data-size={size}\n data-tone={tone}\n data-full={fullWidth ? \"\" : undefined}\n data-icon-only={iconOnly ? \"\" : undefined}\n style={style}\n >\n {/* Always present, so a form's reset restores the default; it submits only when there is a name and a value. */}\n <HiddenValue\n name={name}\n value={current ?? \"\"}\n disabled={disabled || current === undefined}\n onReset={() => reset(defaultValue)}\n />\n {options.map((option) => (\n <label\n key={option.value}\n htmlFor={`${groupName}-${option.value}`}\n className=\"cy-segment\"\n data-disabled={disabled || option.disabled ? \"\" : undefined}\n >\n <ChoiceBase\n id={`${groupName}-${option.value}`}\n type=\"radio\"\n name={groupName}\n // Belongs to no form: the hidden field above submits the value under the caller's name.\n form=\"\"\n value={option.value}\n disabled={disabled || option.disabled}\n aria-label={option.label}\n checked={current === option.value}\n onChange={(e) => e.currentTarget.checked && setCurrent(option.value)}\n />\n {option.icon && <Icon icon={option.icon} />}\n {!iconOnly && <span className=\"cy-segment-label\">{option.label}</span>}\n </label>\n ))}\n </div>\n );\n}\n"],"mappings":";;;;;;;AA2DA,SAAgBO,EAAiB,EAC/B,OAAAC,GACA,SAAAC,GACA,MAAAC,GACA,OAAAC,GACA,cAAAC,GACA,UAAAC,GACA,UAAAC,IAAW,IACX,WAAAC,IAAY,IACZ,UAAAC,GACA,MAAAC,IAAO,MACP,MAAAC,IAAO,WACP,WAAAC,GACA,OAAAC,EAAA,GACwB;AAIxB,QAAMC,IAAY,UAAUjB,EAAM,CAAA,IAC5B,CAACkB,GAASC,GAAYC,CAAA,IAASxB,EACnCW,GACAC,GACAC,CACF;AACA,SACE,gBAAAP,EAAC,OAAD;AAAA,IACE,MAAK;AAAA,IACL,cAAYE;AAAA,IACZ,WAAW,eAAeW,IAAY,IAAIA,CAAA,KAAc,EAAA;AAAA,IACxD,aAAWF;AAAA,IACX,aAAWC;AAAA,IACX,aAAWH,IAAY,KAAK;AAAA,IAC5B,kBAAgBD,IAAW,KAAK;AAAA,IACzB,OAAAM;AAAA,IART,UAAA,CAWE,gBAAAf,EAACF,GAAD;AAAA,MACQ,MAAAO;AAAA,MACN,OAAOY,KAAW;AAAA,MAClB,UAAUN,KAAYM,MAAY;AAAA,MAClC,SAAA,MAAeE,EAAMZ,CAAY;AAAA,IAClC,CAAA,GACAH,EAAQ,IAAA,CAAKgB,MACZ,gBAAAnB,EAAC,SAAD;AAAA,MAEE,SAAS,GAAGe,CAAA,IAAaI,EAAO,KAAA;AAAA,MAChC,WAAU;AAAA,MACV,iBAAeT,KAAYS,EAAO,WAAW,KAAK;AAAA,MAJpD,UAAA;AAAA,QAME,gBAAApB,EAACH,GAAD;AAAA,UACE,IAAI,GAAGmB,CAAA,IAAaI,EAAO,KAAA;AAAA,UAC3B,MAAK;AAAA,UACL,MAAMJ;AAAA,UAEN,MAAK;AAAA,UACL,OAAOI,EAAO;AAAA,UACd,UAAUT,KAAYS,EAAO;AAAA,UAC7B,cAAYA,EAAO;AAAA,UACnB,SAASH,MAAYG,EAAO;AAAA,UAC5B,UAAA,CAAWC,MAAMA,EAAE,cAAc,WAAWH,EAAWE,EAAO,KAAK;AAAA,QACpE,CAAA;AAAA,QACAA,EAAO,QAAQ,gBAAApB,EAACJ,GAAD,EAAM,MAAMwB,EAAO,KAAO,CAAA;AAAA,QACzC,CAACX,KAAY,gBAAAT,EAAC,QAAD;AAAA,UAAM,WAAU;AAAA,UAAoB,UAAAoB,EAAO;AAAA,QAAY,CAAA;AAAA,MAChE;AAAA,IAnBA,GAAAA,EAAO,KAmBP,CACR,CACE;AAAA,E;AAET"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type CSSProperties, type ReactNode } from "react";
|
|
2
|
+
import { type OptionIconColor } from "../../foundations/option-icon.js";
|
|
2
3
|
import type { IconData } from "../../icons/types.js";
|
|
3
4
|
import type { Size } from "../../tokens/schema.js";
|
|
4
5
|
export interface SelectTokens {
|
|
@@ -15,36 +16,52 @@ declare module "../../tokens/schema.js" {
|
|
|
15
16
|
select: SelectTokens;
|
|
16
17
|
}
|
|
17
18
|
}
|
|
18
|
-
export interface SelectOption {
|
|
19
|
+
export interface SelectOption extends OptionIconColor {
|
|
19
20
|
value: string;
|
|
20
21
|
label: string;
|
|
21
22
|
description?: string;
|
|
23
|
+
/** Icon before the label, in the list and in the trigger when chosen. Colour it with `iconTone` or `iconColor`. */
|
|
22
24
|
icon?: IconData;
|
|
23
25
|
disabled?: boolean;
|
|
24
26
|
/** Options next to each other with the same `group` are listed under that heading. */
|
|
25
27
|
group?: string;
|
|
26
28
|
}
|
|
27
29
|
export interface SelectProps {
|
|
30
|
+
/** Names the control, shown above it. */
|
|
28
31
|
label: ReactNode;
|
|
29
32
|
/** Visually hide the label (it still names the control). Prefer visible labels. */
|
|
30
33
|
labelHidden?: boolean | undefined;
|
|
34
|
+
/** Help text shown below the control. */
|
|
31
35
|
description?: ReactNode;
|
|
36
|
+
/** Your own error; it replaces the built-in required message. */
|
|
32
37
|
error?: ReactNode;
|
|
38
|
+
/** The choices: `{ value, label, description?, icon?, iconTone?, iconColor?, disabled?, group? }`. */
|
|
33
39
|
options: SelectOption[];
|
|
40
|
+
/** Controlled selected value. */
|
|
34
41
|
value?: string;
|
|
42
|
+
/** Selected value at first, when uncontrolled. */
|
|
35
43
|
defaultValue?: string;
|
|
44
|
+
/** Called with the chosen option's value when it changes. */
|
|
36
45
|
onChange?: (value: string) => void;
|
|
46
|
+
/** Shown while nothing is chosen. Default "Select…". */
|
|
37
47
|
placeholder?: string;
|
|
48
|
+
/** Submits the value with its form under this name. */
|
|
38
49
|
name?: string;
|
|
50
|
+
/** The form will not submit until a value is chosen; also draws the required marker. */
|
|
39
51
|
required?: boolean;
|
|
52
|
+
/** Cannot be opened or changed, and is not submitted. */
|
|
40
53
|
disabled?: boolean;
|
|
54
|
+
/** Height and text size of the control. Default "md". */
|
|
41
55
|
size?: Size;
|
|
56
|
+
/** `outline`, or `soft` (tinted, no border). Default "outline". */
|
|
42
57
|
variant?: "outline" | "soft";
|
|
58
|
+
/** Replace the built-in English text: the placeholder, the empty list and the required message. */
|
|
43
59
|
labels?: {
|
|
44
60
|
placeholder?: string;
|
|
45
61
|
empty?: string;
|
|
46
62
|
required?: string;
|
|
47
63
|
};
|
|
64
|
+
/** Added to the root element, for layout. */
|
|
48
65
|
className?: string;
|
|
49
66
|
/** Layout only. */
|
|
50
67
|
style?: CSSProperties;
|