@oprt/react 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +105 -2
- package/dist/ActionStatus/ActionStatus.js +104 -0
- package/dist/ActionStatus/ActionStatus.manifest.js +64 -0
- package/dist/ActionStatus/index.js +7 -0
- package/dist/Alert/Alert.js +86 -0
- package/dist/Alert/Alert.manifest.js +36 -0
- package/dist/Alert/index.js +7 -0
- package/dist/AppShell/AppShell.js +103 -0
- package/dist/AppShell/AppShell.manifest.js +66 -0
- package/dist/AppShell/index.js +9 -0
- package/dist/AttachmentPreview/AttachmentPreview.js +145 -0
- package/dist/AttachmentPreview/AttachmentPreview.manifest.js +42 -0
- package/dist/AttachmentPreview/index.js +9 -0
- package/dist/Avatar/Avatar.js +87 -0
- package/dist/Avatar/Avatar.manifest.js +25 -0
- package/dist/Avatar/index.js +7 -0
- package/dist/Badge/Badge.js +124 -0
- package/dist/Badge/Badge.manifest.js +41 -0
- package/dist/Badge/index.js +7 -0
- package/dist/Breadcrumb/Breadcrumb.js +64 -0
- package/dist/Breadcrumb/Breadcrumb.manifest.js +28 -0
- package/dist/Breadcrumb/index.js +7 -0
- package/dist/BulkActionBar/BulkActionBar.js +145 -0
- package/dist/BulkActionBar/BulkActionBar.manifest.js +46 -0
- package/dist/BulkActionBar/index.js +9 -0
- package/dist/BulkActionBar/selection.js +44 -0
- package/dist/BulkResults/BulkResults.js +269 -0
- package/dist/BulkResults/BulkResults.manifest.js +45 -0
- package/dist/BulkResults/index.js +7 -0
- package/dist/Button/Button.js +170 -0
- package/dist/Button/Button.manifest.js +36 -0
- package/dist/Button/index.js +7 -0
- package/dist/ButtonGroup/ButtonGroup.js +60 -0
- package/dist/ButtonGroup/ButtonGroup.manifest.js +22 -0
- package/dist/ButtonGroup/index.js +7 -0
- package/dist/Calendar/Calendar.js +106 -0
- package/dist/Calendar/Calendar.manifest.js +32 -0
- package/dist/Calendar/index.js +7 -0
- package/dist/Card/Card.js +70 -0
- package/dist/Card/Card.manifest.js +57 -0
- package/dist/Card/index.js +16 -0
- package/dist/Chart/Chart.js +1200 -0
- package/dist/Chart/Chart.manifest.js +110 -0
- package/dist/Chart/ChartControls.js +190 -0
- package/dist/Chart/geometry.js +217 -0
- package/dist/Chart/index.js +9 -0
- package/dist/Checkbox/Checkbox.js +166 -0
- package/dist/Checkbox/Checkbox.manifest.js +38 -0
- package/dist/Checkbox/index.js +7 -0
- package/dist/Collapsible/Collapsible.js +177 -0
- package/dist/Collapsible/Collapsible.manifest.js +54 -0
- package/dist/Collapsible/index.js +12 -0
- package/dist/CollectionState/CollectionState.js +68 -0
- package/dist/CollectionState/CollectionState.manifest.js +44 -0
- package/dist/CollectionState/index.js +7 -0
- package/dist/ComboBox/ComboBox.js +221 -0
- package/dist/ComboBox/ComboBox.manifest.js +87 -0
- package/dist/ComboBox/index.js +7 -0
- package/dist/CommandPalette/CommandPalette.js +276 -0
- package/dist/CommandPalette/CommandPalette.manifest.js +24 -0
- package/dist/CommandPalette/index.js +7 -0
- package/dist/ConfirmDialog/ConfirmDialog.js +84 -0
- package/dist/ConfirmDialog/ConfirmDialog.manifest.js +32 -0
- package/dist/ConfirmDialog/index.js +7 -0
- package/dist/ContextMenu/ContextMenu.js +192 -0
- package/dist/ContextMenu/ContextMenu.manifest.js +41 -0
- package/dist/ContextMenu/index.js +7 -0
- package/dist/CoordinateInput/CoordinateInput.js +141 -0
- package/dist/CoordinateInput/CoordinateInput.manifest.js +36 -0
- package/dist/CoordinateInput/index.js +9 -0
- package/dist/CopyButton/CopyButton.js +110 -0
- package/dist/CopyButton/CopyButton.manifest.js +35 -0
- package/dist/CopyButton/index.js +7 -0
- package/dist/DataGrid/DataGrid.js +459 -0
- package/dist/DataGrid/DataGrid.manifest.js +135 -0
- package/dist/DataGrid/PageControls.js +41 -0
- package/dist/DataGrid/index.js +9 -0
- package/dist/DataTable/DataTable.js +375 -0
- package/dist/DataTable/DataTable.manifest.js +86 -0
- package/dist/DataTable/index.js +9 -0
- package/dist/DataTable/sort.js +45 -0
- package/dist/DataTable/useScrollsSideways.js +61 -0
- package/dist/DataTable/useTableWindow.js +185 -0
- package/dist/DatePicker/DatePicker.js +187 -0
- package/dist/DatePicker/DatePicker.manifest.js +40 -0
- package/dist/DatePicker/index.js +7 -0
- package/dist/DateRangePicker/DateRangePicker.js +156 -0
- package/dist/DateRangePicker/DateRangePicker.manifest.js +41 -0
- package/dist/DateRangePicker/index.js +7 -0
- package/dist/DateTimePicker/DateTimePicker.js +213 -0
- package/dist/DateTimePicker/DateTimePicker.manifest.js +44 -0
- package/dist/DateTimePicker/index.js +7 -0
- package/dist/DescriptionList/DescriptionList.js +93 -0
- package/dist/DescriptionList/DescriptionList.manifest.js +40 -0
- package/dist/DescriptionList/index.js +9 -0
- package/dist/Dialog/Dialog.js +214 -0
- package/dist/Dialog/Dialog.manifest.js +31 -0
- package/dist/Dialog/index.js +7 -0
- package/dist/Divider/Divider.js +64 -0
- package/dist/Divider/Divider.manifest.js +21 -0
- package/dist/Divider/index.js +7 -0
- package/dist/DropdownMenu/DropdownMenu.js +170 -0
- package/dist/DropdownMenu/DropdownMenu.manifest.js +82 -0
- package/dist/DropdownMenu/index.js +16 -0
- package/dist/EntityPreview/EntityPreview.js +82 -0
- package/dist/EntityPreview/EntityPreview.manifest.js +43 -0
- package/dist/EntityPreview/index.js +7 -0
- package/dist/EventTimeline/EventTimeline.js +249 -0
- package/dist/EventTimeline/EventTimeline.manifest.js +57 -0
- package/dist/EventTimeline/index.js +7 -0
- package/dist/Field/Field.js +81 -0
- package/dist/Field/Field.manifest.js +32 -0
- package/dist/Field/index.js +9 -0
- package/dist/FileUpload/FileUpload.js +215 -0
- package/dist/FileUpload/FileUpload.manifest.js +48 -0
- package/dist/FileUpload/index.js +7 -0
- package/dist/FilterBar/FilterBar.js +173 -0
- package/dist/FilterBar/FilterBar.manifest.js +49 -0
- package/dist/FilterBar/index.js +7 -0
- package/dist/FormErrorSummary/FormErrorSummary.js +70 -0
- package/dist/FormErrorSummary/FormErrorSummary.manifest.js +29 -0
- package/dist/FormErrorSummary/index.js +9 -0
- package/dist/FormSection/FormSection.js +51 -0
- package/dist/FormSection/FormSection.manifest.js +30 -0
- package/dist/FormSection/index.js +7 -0
- package/dist/InlineEdit/InlineEdit.js +261 -0
- package/dist/InlineEdit/InlineEdit.manifest.js +40 -0
- package/dist/InlineEdit/index.js +7 -0
- package/dist/Input/Input.js +126 -0
- package/dist/Input/Input.manifest.js +49 -0
- package/dist/Input/index.js +7 -0
- package/dist/Inspector/Inspector.js +63 -0
- package/dist/Inspector/Inspector.manifest.js +35 -0
- package/dist/Inspector/index.js +7 -0
- package/dist/JobStatus/JobStatus.js +118 -0
- package/dist/JobStatus/JobStatus.manifest.js +53 -0
- package/dist/JobStatus/index.js +7 -0
- package/dist/LayerControl/LayerControl.js +199 -0
- package/dist/LayerControl/LayerControl.manifest.js +34 -0
- package/dist/LayerControl/index.js +7 -0
- package/dist/Link/Link.js +83 -0
- package/dist/Link/Link.manifest.js +37 -0
- package/dist/Link/index.js +7 -0
- package/dist/MapControls/MapControls.js +122 -0
- package/dist/MapControls/MapControls.manifest.js +31 -0
- package/dist/MapControls/index.js +7 -0
- package/dist/MapLegend/MapLegend.js +89 -0
- package/dist/MapLegend/MapLegend.manifest.js +29 -0
- package/dist/MapLegend/index.js +7 -0
- package/dist/MapScale/MapScale.js +96 -0
- package/dist/MapScale/MapScale.manifest.js +31 -0
- package/dist/MapScale/index.js +7 -0
- package/dist/MediaFrame/MediaFrame.js +113 -0
- package/dist/MediaFrame/MediaFrame.manifest.js +57 -0
- package/dist/MediaFrame/index.js +7 -0
- package/dist/MultiSelect/MultiSelect.js +113 -0
- package/dist/MultiSelect/MultiSelect.manifest.js +51 -0
- package/dist/MultiSelect/index.js +7 -0
- package/dist/NumberInput/NumberInput.js +210 -0
- package/dist/NumberInput/NumberInput.manifest.js +56 -0
- package/dist/NumberInput/index.js +7 -0
- package/dist/OperationalStatus/OperationalStatus.js +89 -0
- package/dist/OperationalStatus/OperationalStatus.manifest.js +39 -0
- package/dist/OperationalStatus/index.js +9 -0
- package/dist/PlaybackControls/PlaybackControls.js +289 -0
- package/dist/PlaybackControls/PlaybackControls.manifest.js +85 -0
- package/dist/PlaybackControls/index.js +7 -0
- package/dist/Popover/Popover.js +302 -0
- package/dist/Popover/Popover.manifest.js +50 -0
- package/dist/Popover/index.js +7 -0
- package/dist/Progress/Progress.js +132 -0
- package/dist/Progress/Progress.manifest.js +30 -0
- package/dist/Progress/index.js +7 -0
- package/dist/PropertyFilter/PropertyFilter.js +306 -0
- package/dist/PropertyFilter/PropertyFilter.manifest.js +32 -0
- package/dist/PropertyFilter/index.js +11 -0
- package/dist/PropertyFilter/tokenError.js +17 -0
- package/dist/RadioGroup/RadioGroup.js +143 -0
- package/dist/RadioGroup/RadioGroup.manifest.js +44 -0
- package/dist/RadioGroup/index.js +9 -0
- package/dist/Select/Select.js +219 -0
- package/dist/Select/Select.manifest.js +77 -0
- package/dist/Select/index.js +9 -0
- package/dist/Sidebar/Sidebar.js +146 -0
- package/dist/Sidebar/Sidebar.manifest.js +72 -0
- package/dist/Sidebar/index.js +18 -0
- package/dist/Skeleton/Skeleton.js +76 -0
- package/dist/Skeleton/Skeleton.manifest.js +30 -0
- package/dist/Skeleton/index.js +7 -0
- package/dist/Slider/Slider.js +246 -0
- package/dist/Slider/Slider.manifest.js +56 -0
- package/dist/Slider/index.js +7 -0
- package/dist/Sparkline/Sparkline.js +135 -0
- package/dist/Sparkline/Sparkline.manifest.js +37 -0
- package/dist/Sparkline/index.js +7 -0
- package/dist/SplitPane/SplitPane.js +316 -0
- package/dist/SplitPane/SplitPane.manifest.js +79 -0
- package/dist/SplitPane/index.js +7 -0
- package/dist/StatCard/StatCard.js +163 -0
- package/dist/StatCard/StatCard.manifest.js +45 -0
- package/dist/StatCard/index.js +7 -0
- package/dist/Tabs/Tabs.js +181 -0
- package/dist/Tabs/Tabs.manifest.js +72 -0
- package/dist/Tabs/index.js +16 -0
- package/dist/Tabs/useTabsIndicator.js +71 -0
- package/dist/Tabs/useTabsScroll.js +123 -0
- package/dist/TagGroup/TagGroup.js +142 -0
- package/dist/TagGroup/TagGroup.manifest.js +35 -0
- package/dist/TagGroup/index.js +7 -0
- package/dist/Textarea/Textarea.js +68 -0
- package/dist/Textarea/Textarea.manifest.js +25 -0
- package/dist/Textarea/index.js +7 -0
- package/dist/TimeField/TimeField.js +118 -0
- package/dist/TimeField/TimeField.manifest.js +42 -0
- package/dist/TimeField/index.js +7 -0
- package/dist/TimeRange/TimeRange.js +184 -0
- package/dist/TimeRange/TimeRange.manifest.js +48 -0
- package/dist/TimeRange/index.js +9 -0
- package/dist/Toast/Toast.js +188 -0
- package/dist/Toast/Toast.manifest.js +77 -0
- package/dist/Toast/index.js +9 -0
- package/dist/Toggle/Toggle.js +154 -0
- package/dist/Toggle/Toggle.manifest.js +54 -0
- package/dist/Toggle/index.js +7 -0
- package/dist/Toolbar/Toolbar.js +86 -0
- package/dist/Toolbar/Toolbar.manifest.js +70 -0
- package/dist/Toolbar/index.js +12 -0
- package/dist/Tooltip/Tooltip.js +122 -0
- package/dist/Tooltip/Tooltip.manifest.js +27 -0
- package/dist/Tooltip/index.js +7 -0
- package/dist/TreeView/TreeView.js +129 -0
- package/dist/TreeView/TreeView.manifest.js +56 -0
- package/dist/TreeView/index.js +7 -0
- package/dist/UploadQueue/UploadQueue.js +296 -0
- package/dist/UploadQueue/UploadQueue.manifest.js +34 -0
- package/dist/UploadQueue/index.js +7 -0
- package/dist/_internal/MotionPopover.js +113 -0
- package/dist/_internal/aria.js +40 -0
- package/dist/_internal/bytes.js +18 -0
- package/dist/_internal/controlStyles.js +26 -0
- package/dist/_internal/date.js +179 -0
- package/dist/_internal/devValidate.js +51 -0
- package/dist/_internal/fieldIds.js +50 -0
- package/dist/_internal/hydration.js +74 -0
- package/dist/_internal/manifest-entry.js +0 -0
- package/dist/_internal/mergeRefs.js +68 -0
- package/dist/_internal/motion.js +138 -0
- package/dist/_internal/navigationLandmark.js +13 -0
- package/dist/_internal/numberText.js +176 -0
- package/dist/_internal/overlay.js +53 -0
- package/dist/_internal/segmentField.js +125 -0
- package/dist/_internal/suggestions.js +20 -0
- package/dist/_internal/timestamp.js +25 -0
- package/dist/_internal/unavailable.js +13 -0
- package/dist/_internal/useActionFocus.js +27 -0
- package/dist/_internal/useElementWidth.js +37 -0
- package/dist/_internal/useIsMounted.js +18 -0
- package/dist/_internal/useIsomorphicLayoutEffect.js +8 -0
- package/dist/_internal/useRestoreFocusOnRemoval.js +57 -0
- package/dist/index.cjs +17811 -0
- package/dist/index.d.cts +2330 -0
- package/dist/index.d.ts +2330 -0
- package/dist/index.js +407 -0
- package/dist/version.js +8 -0
- package/package.json +80 -3
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
// src/Sidebar/Sidebar.manifest.ts
|
|
2
|
+
var SidebarManifest = {
|
|
3
|
+
Sidebar: {
|
|
4
|
+
description: "Vertical navigation rail, never wider than its container. Use with SidebarLogo, SidebarSection, and SidebarFooter. For the frame of a whole app (the workspace's name, the data connection, the time), pass the Sidebar to AppShell as its navigation instead of laying the frame out by hand. Standing alone it is a navigation landmark named Sidebar; inside AppShell's navigation it is a plain block, and the shell's landmark names the navigation. In a host of bounded height the sections scroll in place between the logo and the footer, which stay put.",
|
|
5
|
+
props: {},
|
|
6
|
+
slots: {
|
|
7
|
+
children: { type: "SidebarLogo | SidebarSection | SidebarFooter", required: true }
|
|
8
|
+
},
|
|
9
|
+
composable_with: ["SidebarLogo", "SidebarSection", "SidebarFooter", "AppShell"],
|
|
10
|
+
never_inside: ["Sidebar", "Card"],
|
|
11
|
+
example: '<Sidebar>\n <SidebarLogo>OPERATOR</SidebarLogo>\n <SidebarSection label="NAVIGATION">\n <SidebarItem href="/overview" active>OVERVIEW</SidebarItem>\n <SidebarItem href="/metrics">METRICS</SidebarItem>\n </SidebarSection>\n <SidebarFooter>BUILD 1.0.0</SidebarFooter>\n</Sidebar>'
|
|
12
|
+
},
|
|
13
|
+
SidebarLogo: {
|
|
14
|
+
description: "Sidebar brand/header slot \u2014 uppercase wordmark row at the top of the rail.",
|
|
15
|
+
props: {},
|
|
16
|
+
slots: {
|
|
17
|
+
children: { type: "text", required: true }
|
|
18
|
+
},
|
|
19
|
+
composable_with: ["Sidebar"],
|
|
20
|
+
never_inside: ["SidebarSection", "SidebarFooter"],
|
|
21
|
+
example: "<SidebarLogo>OPERATOR</SidebarLogo>"
|
|
22
|
+
},
|
|
23
|
+
SidebarSection: {
|
|
24
|
+
description: "Grouped block of SidebarItems with an optional uppercase section label; a labeled section is a group named by its label.",
|
|
25
|
+
props: {
|
|
26
|
+
label: { type: "string" }
|
|
27
|
+
},
|
|
28
|
+
slots: {
|
|
29
|
+
children: { type: "SidebarItem", required: true }
|
|
30
|
+
},
|
|
31
|
+
composable_with: ["Sidebar"],
|
|
32
|
+
never_inside: ["SidebarLogo", "SidebarFooter"],
|
|
33
|
+
example: '<SidebarSection label="NAVIGATION">\n <SidebarItem href="/overview">OVERVIEW</SidebarItem>\n</SidebarSection>'
|
|
34
|
+
},
|
|
35
|
+
SidebarItem: {
|
|
36
|
+
description: "Uppercase navigation entry. Renders as an anchor when href is set, otherwise a button; marks the current page when active. Wrap case-sensitive names or IDs in a child with normal-case tracking-normal.",
|
|
37
|
+
props: {
|
|
38
|
+
active: { type: "boolean", default: false },
|
|
39
|
+
href: { type: "string" },
|
|
40
|
+
asChild: { type: "boolean", default: false }
|
|
41
|
+
},
|
|
42
|
+
slots: {
|
|
43
|
+
icon: { type: "ReactNode", required: false },
|
|
44
|
+
children: { type: "text", required: true }
|
|
45
|
+
},
|
|
46
|
+
composable_with: ["SidebarSection"],
|
|
47
|
+
never_inside: ["SidebarLogo", "SidebarFooter"],
|
|
48
|
+
example: '<SidebarItem href="/overview" active>OVERVIEW</SidebarItem>'
|
|
49
|
+
},
|
|
50
|
+
SidebarFooter: {
|
|
51
|
+
description: "Bottom-pinned sidebar slot \u2014 version string, account, or status controls.",
|
|
52
|
+
props: {},
|
|
53
|
+
slots: {
|
|
54
|
+
children: { type: "any", required: false }
|
|
55
|
+
},
|
|
56
|
+
composable_with: ["Sidebar"],
|
|
57
|
+
never_inside: ["SidebarLogo", "SidebarSection"],
|
|
58
|
+
example: "<SidebarFooter>BUILD 1.0.0</SidebarFooter>"
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
var SidebarCompositionRules = {
|
|
62
|
+
Sidebar: {
|
|
63
|
+
allowed_children: ["SidebarLogo", "SidebarSection", "SidebarFooter"],
|
|
64
|
+
children: {
|
|
65
|
+
SidebarSection: { allowed_children: ["SidebarItem"] }
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
export {
|
|
70
|
+
SidebarCompositionRules,
|
|
71
|
+
SidebarManifest
|
|
72
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// src/Sidebar/index.ts
|
|
2
|
+
import {
|
|
3
|
+
Sidebar,
|
|
4
|
+
SidebarLogo,
|
|
5
|
+
SidebarSection,
|
|
6
|
+
SidebarItem,
|
|
7
|
+
SidebarFooter
|
|
8
|
+
} from "./Sidebar.js";
|
|
9
|
+
import { SidebarManifest, SidebarCompositionRules } from "./Sidebar.manifest.js";
|
|
10
|
+
export {
|
|
11
|
+
Sidebar,
|
|
12
|
+
SidebarCompositionRules,
|
|
13
|
+
SidebarFooter,
|
|
14
|
+
SidebarItem,
|
|
15
|
+
SidebarLogo,
|
|
16
|
+
SidebarManifest,
|
|
17
|
+
SidebarSection
|
|
18
|
+
};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/Skeleton/Skeleton.tsx
|
|
4
|
+
import { cva } from "class-variance-authority";
|
|
5
|
+
import { forwardRef } from "react";
|
|
6
|
+
import clsx from "clsx";
|
|
7
|
+
import { SkeletonManifest } from "./Skeleton.manifest.js";
|
|
8
|
+
import { devValidate } from "../_internal/devValidate.js";
|
|
9
|
+
import { jsx } from "react/jsx-runtime";
|
|
10
|
+
var barStyles = cva(
|
|
11
|
+
"bg-oprt-surface-2 animate-pulse motion-reduce:animate-none forced-colors:bg-[color:GrayText] forced-colors:[forced-color-adjust:none]",
|
|
12
|
+
{
|
|
13
|
+
variants: {
|
|
14
|
+
variant: {
|
|
15
|
+
block: "w-full max-w-full h-oprt-md",
|
|
16
|
+
text: "h-2u w-full"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
defaultVariants: { variant: "block" }
|
|
20
|
+
}
|
|
21
|
+
);
|
|
22
|
+
var Skeleton = forwardRef((allProps, ref) => {
|
|
23
|
+
const { className, variant = "block", width, height, lines = 3, ...props } = allProps;
|
|
24
|
+
if (process.env.NODE_ENV !== "production") {
|
|
25
|
+
devValidate("Skeleton", SkeletonManifest.Skeleton.props, { ...allProps });
|
|
26
|
+
}
|
|
27
|
+
if (variant === "text") {
|
|
28
|
+
const count = Number.isFinite(lines) ? Math.max(1, Math.floor(lines)) : 3;
|
|
29
|
+
return /* @__PURE__ */ jsx(
|
|
30
|
+
"div",
|
|
31
|
+
{
|
|
32
|
+
ref,
|
|
33
|
+
role: "status",
|
|
34
|
+
"aria-busy": "true",
|
|
35
|
+
"aria-label": "Loading",
|
|
36
|
+
className: clsx("flex flex-col gap-1u", className),
|
|
37
|
+
...props,
|
|
38
|
+
children: Array.from({ length: count }, (_, i) => /* @__PURE__ */ jsx(
|
|
39
|
+
"div",
|
|
40
|
+
{
|
|
41
|
+
"aria-hidden": "true",
|
|
42
|
+
className: clsx(barStyles({ variant: "text" }), i === count - 1 && "w-2/3")
|
|
43
|
+
},
|
|
44
|
+
i
|
|
45
|
+
))
|
|
46
|
+
}
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
const style = {};
|
|
50
|
+
if (width !== void 0) style.width = width;
|
|
51
|
+
if (height !== void 0) style.height = height;
|
|
52
|
+
const hasStyle = width !== void 0 || height !== void 0;
|
|
53
|
+
return /* @__PURE__ */ jsx(
|
|
54
|
+
"div",
|
|
55
|
+
{
|
|
56
|
+
ref,
|
|
57
|
+
role: "status",
|
|
58
|
+
"aria-busy": "true",
|
|
59
|
+
"aria-label": "Loading",
|
|
60
|
+
className: clsx("flex flex-col", className),
|
|
61
|
+
...props,
|
|
62
|
+
children: /* @__PURE__ */ jsx(
|
|
63
|
+
"div",
|
|
64
|
+
{
|
|
65
|
+
"aria-hidden": "true",
|
|
66
|
+
className: barStyles({ variant: "block" }),
|
|
67
|
+
...hasStyle ? { style } : {}
|
|
68
|
+
}
|
|
69
|
+
)
|
|
70
|
+
}
|
|
71
|
+
);
|
|
72
|
+
});
|
|
73
|
+
Skeleton.displayName = "Skeleton";
|
|
74
|
+
export {
|
|
75
|
+
Skeleton
|
|
76
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// src/Skeleton/Skeleton.manifest.ts
|
|
2
|
+
var SkeletonManifest = {
|
|
3
|
+
Skeleton: {
|
|
4
|
+
description: "Loading placeholder. block renders one pulsing bar; text stacks `lines` bars with a shortened last line. Bars fill their container and never widen it, whatever width the caller asks for, and are drawn in a system color in forced-colors mode.",
|
|
5
|
+
props: {
|
|
6
|
+
variant: { type: "enum", values: ["block", "text"], default: "block" },
|
|
7
|
+
width: {
|
|
8
|
+
type: "union",
|
|
9
|
+
types: ["string", "number"],
|
|
10
|
+
description: "Caller dimension applied via style on the block bar (string or number). It is clamped to the container: it can ask for less, never more."
|
|
11
|
+
},
|
|
12
|
+
height: {
|
|
13
|
+
type: "union",
|
|
14
|
+
types: ["string", "number"],
|
|
15
|
+
description: "Caller dimension applied via style on the block bar (string or number)."
|
|
16
|
+
},
|
|
17
|
+
lines: {
|
|
18
|
+
type: "number",
|
|
19
|
+
default: 3,
|
|
20
|
+
description: "Number of stacked bars in the text variant, rounded down with a minimum of 1. Non-finite values fall back to 3."
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
composable_with: ["Card", "DataTable"],
|
|
24
|
+
never_inside: ["Button", "Badge"],
|
|
25
|
+
example: '<Skeleton variant="text" lines={3} />'
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
export {
|
|
29
|
+
SkeletonManifest
|
|
30
|
+
};
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/Slider/Slider.tsx
|
|
4
|
+
import {
|
|
5
|
+
Slider as AriaSlider,
|
|
6
|
+
SliderTrack,
|
|
7
|
+
SliderThumb,
|
|
8
|
+
SliderFill,
|
|
9
|
+
SliderStateContext
|
|
10
|
+
} from "react-aria-components";
|
|
11
|
+
import { mergeProps } from "react-aria";
|
|
12
|
+
import { cva } from "class-variance-authority";
|
|
13
|
+
import { Fragment, forwardRef, useContext, useRef } from "react";
|
|
14
|
+
import clsx from "clsx";
|
|
15
|
+
import { SliderManifest } from "./Slider.manifest.js";
|
|
16
|
+
import { devValidate } from "../_internal/devValidate.js";
|
|
17
|
+
import { definedOnly } from "../_internal/aria.js";
|
|
18
|
+
import { joinIds, useFieldWiring, usePartIds } from "../_internal/fieldIds.js";
|
|
19
|
+
import { keyForIds } from "../_internal/hydration.js";
|
|
20
|
+
import { NumberText } from "../_internal/numberText.js";
|
|
21
|
+
import { useIsomorphicLayoutEffect } from "../_internal/useIsomorphicLayoutEffect.js";
|
|
22
|
+
import {
|
|
23
|
+
FORCED_SLIDER_FILL,
|
|
24
|
+
FORCED_SLIDER_THUMB,
|
|
25
|
+
FORCED_SLIDER_TRACK
|
|
26
|
+
} from "../_internal/controlStyles.js";
|
|
27
|
+
import { Fragment as Fragment2, jsx, jsxs } from "react/jsx-runtime";
|
|
28
|
+
var rootStyles = cva(
|
|
29
|
+
"relative flex items-center gap-x-2u gap-y-1u min-h-3u select-none touch-none w-full data-[orientation=horizontal]:flex-wrap data-[orientation=vertical]:flex-col data-[orientation=vertical]:flex-grow data-[orientation=vertical]:w-auto data-[orientation=vertical]:min-w-3u data-[disabled]:opacity-50",
|
|
30
|
+
{
|
|
31
|
+
variants: {
|
|
32
|
+
size: { sm: "", md: "", lg: "" }
|
|
33
|
+
},
|
|
34
|
+
defaultVariants: { size: "md" }
|
|
35
|
+
}
|
|
36
|
+
);
|
|
37
|
+
var trackStyles = cva(
|
|
38
|
+
"relative flex-grow bg-oprt-border-control data-[orientation=horizontal]:mx-1.5u data-[orientation=horizontal]:min-w-16u data-[orientation=vertical]:my-1.5u",
|
|
39
|
+
{
|
|
40
|
+
variants: {
|
|
41
|
+
size: {
|
|
42
|
+
sm: "data-[orientation=horizontal]:h-oprt-track-sm data-[orientation=vertical]:w-oprt-track-sm",
|
|
43
|
+
md: "data-[orientation=horizontal]:h-oprt-track-md data-[orientation=vertical]:w-oprt-track-md",
|
|
44
|
+
lg: "data-[orientation=horizontal]:h-oprt-track-lg data-[orientation=vertical]:w-oprt-track-lg"
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
defaultVariants: { size: "md" }
|
|
48
|
+
}
|
|
49
|
+
);
|
|
50
|
+
var rangeStyles = "absolute bg-oprt-accent data-[orientation=horizontal]:h-full data-[orientation=vertical]:w-full";
|
|
51
|
+
var thumbStyles = cva(
|
|
52
|
+
"block bg-oprt-surface-1 border border-oprt-accent group-data-[invalid]/slider:border-oprt-error group-data-[focus-visible]/slider:border-oprt-border-focus group-data-[focus-visible]/slider:shadow-oprt-focus cursor-pointer group-data-[disabled]/slider:cursor-not-allowed",
|
|
53
|
+
{
|
|
54
|
+
variants: {
|
|
55
|
+
size: {
|
|
56
|
+
sm: "h-1.5u w-1.5u",
|
|
57
|
+
md: "h-2u w-2u",
|
|
58
|
+
lg: "h-2.5u w-2.5u"
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
defaultVariants: { size: "md" }
|
|
62
|
+
}
|
|
63
|
+
);
|
|
64
|
+
var valueStyles = "max-w-full font-mono text-oprt-base text-oprt-text tabular-nums";
|
|
65
|
+
function isRange(value) {
|
|
66
|
+
return Array.isArray(value);
|
|
67
|
+
}
|
|
68
|
+
function valueToArray(v, min, max) {
|
|
69
|
+
if (v === void 0) return void 0;
|
|
70
|
+
const values = Array.isArray(v) ? [...v] : [v];
|
|
71
|
+
return values.map((value) => Number.isFinite(value) ? Math.min(max, Math.max(min, value)) : min).sort((a, b) => a - b);
|
|
72
|
+
}
|
|
73
|
+
function ValueThumb({
|
|
74
|
+
formatValue,
|
|
75
|
+
nameIds,
|
|
76
|
+
index = 0,
|
|
77
|
+
...props
|
|
78
|
+
}) {
|
|
79
|
+
const inputRef = useRef(null);
|
|
80
|
+
const state = useContext(SliderStateContext);
|
|
81
|
+
useIsomorphicLayoutEffect(() => {
|
|
82
|
+
const input = inputRef.current;
|
|
83
|
+
if (!input) return;
|
|
84
|
+
const valueText = formatValue ? formatValue(state.values[index] ?? state.getThumbMinValue(index)) : state.getThumbValueLabel(index);
|
|
85
|
+
input.setAttribute("aria-valuetext", valueText);
|
|
86
|
+
if (nameIds) input.setAttribute("aria-labelledby", nameIds);
|
|
87
|
+
else input.removeAttribute("aria-labelledby");
|
|
88
|
+
});
|
|
89
|
+
return /* @__PURE__ */ jsx(SliderThumb, { ...props, index, inputRef });
|
|
90
|
+
}
|
|
91
|
+
var ENDS = ["lower", "upper"];
|
|
92
|
+
var Slider = forwardRef((props, ref) => {
|
|
93
|
+
const {
|
|
94
|
+
className,
|
|
95
|
+
style,
|
|
96
|
+
min = 0,
|
|
97
|
+
max = 100,
|
|
98
|
+
step = 1,
|
|
99
|
+
disabled,
|
|
100
|
+
orientation = "horizontal",
|
|
101
|
+
size = "md",
|
|
102
|
+
showValue,
|
|
103
|
+
formatValue,
|
|
104
|
+
name,
|
|
105
|
+
id,
|
|
106
|
+
"aria-label": ariaLabel,
|
|
107
|
+
"aria-labelledby": ariaLabelledBy,
|
|
108
|
+
"aria-describedby": ariaDescribedBy,
|
|
109
|
+
"aria-invalid": ariaInvalid,
|
|
110
|
+
...rest
|
|
111
|
+
} = props;
|
|
112
|
+
const value = rest.value;
|
|
113
|
+
const defaultValue = rest.defaultValue;
|
|
114
|
+
const onValueChange = rest.onValueChange;
|
|
115
|
+
const domProps = { ...rest };
|
|
116
|
+
delete domProps["value"];
|
|
117
|
+
delete domProps["defaultValue"];
|
|
118
|
+
delete domProps["onValueChange"];
|
|
119
|
+
if (disabled) domProps["aria-disabled"] = true;
|
|
120
|
+
const isRangeMode = isRange(value) || isRange(defaultValue);
|
|
121
|
+
const safeMin = Number.isFinite(min) ? min : 0;
|
|
122
|
+
const safeMax = Number.isFinite(max) && max > safeMin ? max : safeMin + 100;
|
|
123
|
+
const safeStep = Number.isFinite(step) && step > 0 ? step : 1;
|
|
124
|
+
const {
|
|
125
|
+
id: finalId,
|
|
126
|
+
labelledBy,
|
|
127
|
+
describedBy,
|
|
128
|
+
invalid
|
|
129
|
+
} = useFieldWiring(
|
|
130
|
+
{
|
|
131
|
+
id,
|
|
132
|
+
"aria-label": ariaLabel,
|
|
133
|
+
"aria-labelledby": ariaLabelledBy,
|
|
134
|
+
"aria-describedby": ariaDescribedBy,
|
|
135
|
+
"aria-invalid": ariaInvalid
|
|
136
|
+
},
|
|
137
|
+
{ label: "labelledby" }
|
|
138
|
+
);
|
|
139
|
+
const wrapper = useRef(null);
|
|
140
|
+
const ends = usePartIds(ENDS, {
|
|
141
|
+
readRendered: () => wrapper.current?.getAttribute("data-oprt-ids")
|
|
142
|
+
});
|
|
143
|
+
const handleChange = (next) => {
|
|
144
|
+
if (!onValueChange) return;
|
|
145
|
+
const arr = Array.isArray(next) ? next : [next];
|
|
146
|
+
if (isRangeMode) {
|
|
147
|
+
const tuple = [arr[0] ?? 0, arr[1] ?? 0];
|
|
148
|
+
onValueChange(tuple);
|
|
149
|
+
} else {
|
|
150
|
+
onValueChange(arr[0] ?? 0);
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
const ariaValue = valueToArray(value, safeMin, safeMax);
|
|
154
|
+
const ariaDefaultValue = valueToArray(defaultValue, safeMin, safeMax) ?? (isRangeMode ? [safeMin, safeMax] : [safeMin]);
|
|
155
|
+
const thumbValues = ariaValue ?? ariaDefaultValue;
|
|
156
|
+
const thumbCount = thumbValues.length;
|
|
157
|
+
const endOf = (i) => thumbCount === 1 ? void 0 : ENDS[i === 0 ? 0 : 1];
|
|
158
|
+
const thumbLabel = (i) => {
|
|
159
|
+
if (labelledBy || !ariaLabel) return void 0;
|
|
160
|
+
const end = endOf(i);
|
|
161
|
+
return end ? `${ariaLabel} (${end})` : ariaLabel;
|
|
162
|
+
};
|
|
163
|
+
const thumbNameIds = (i) => {
|
|
164
|
+
const end = endOf(i);
|
|
165
|
+
return labelledBy ? joinIds(labelledBy, end && ends[end]) : void 0;
|
|
166
|
+
};
|
|
167
|
+
const rootProps = {
|
|
168
|
+
ref,
|
|
169
|
+
className: clsx(rootStyles({ size }), className),
|
|
170
|
+
minValue: safeMin,
|
|
171
|
+
maxValue: safeMax,
|
|
172
|
+
step: safeStep,
|
|
173
|
+
orientation,
|
|
174
|
+
onChange: handleChange,
|
|
175
|
+
// The attributes RAC does not pass on itself (title, handlers) reach the root through its
|
|
176
|
+
// render function; RAC's own props win where both set one.
|
|
177
|
+
render: (rendered) => /* @__PURE__ */ jsx("div", { ...mergeProps(domProps, rendered) })
|
|
178
|
+
};
|
|
179
|
+
if (style !== void 0) rootProps["style"] = style;
|
|
180
|
+
if (disabled !== void 0) rootProps["isDisabled"] = disabled;
|
|
181
|
+
if (finalId !== void 0) rootProps["id"] = finalId;
|
|
182
|
+
if (describedBy !== void 0) rootProps["aria-describedby"] = describedBy;
|
|
183
|
+
if (ariaLabel !== void 0) rootProps["aria-label"] = ariaLabel;
|
|
184
|
+
if (labelledBy !== void 0) rootProps["aria-labelledby"] = labelledBy;
|
|
185
|
+
if (invalid) rootProps["data-invalid"] = true;
|
|
186
|
+
if (ariaValue !== void 0) {
|
|
187
|
+
rootProps["value"] = ariaValue;
|
|
188
|
+
} else {
|
|
189
|
+
rootProps["defaultValue"] = ariaDefaultValue;
|
|
190
|
+
}
|
|
191
|
+
if (process.env.NODE_ENV !== "production") {
|
|
192
|
+
devValidate("Slider", SliderManifest.Slider.props, { orientation, size });
|
|
193
|
+
}
|
|
194
|
+
return (
|
|
195
|
+
// RAC's Slider root is a <div> (Radix's was a <span>), so the wrapper is a
|
|
196
|
+
// <div> too — a <div> inside a <span> would be invalid nesting.
|
|
197
|
+
// A vertical slider takes the height its container gives it, and at least 128px (two 8u
|
|
198
|
+
// blocks), so its track has a length to fill; it sits at the start of a wide container.
|
|
199
|
+
/* @__PURE__ */ jsxs(
|
|
200
|
+
"div",
|
|
201
|
+
{
|
|
202
|
+
ref: wrapper,
|
|
203
|
+
"data-oprt-ids": ends.base,
|
|
204
|
+
className: orientation === "vertical" ? "flex h-full min-h-16u flex-col items-start" : "inline-flex w-full items-center",
|
|
205
|
+
children: [
|
|
206
|
+
labelledBy && thumbCount > 1 && /* @__PURE__ */ jsxs(Fragment2, { children: [
|
|
207
|
+
/* @__PURE__ */ jsx("span", { id: ends.lower, hidden: true, children: "(lower)" }),
|
|
208
|
+
/* @__PURE__ */ jsx("span", { id: ends.upper, hidden: true, children: "(upper)" })
|
|
209
|
+
] }),
|
|
210
|
+
/* @__PURE__ */ jsx(AriaSlider, { ...rootProps, children: ({ state }) => /* @__PURE__ */ jsxs(Fragment2, { children: [
|
|
211
|
+
/* @__PURE__ */ jsxs(SliderTrack, { className: clsx(trackStyles({ size }), FORCED_SLIDER_TRACK), children: [
|
|
212
|
+
/* @__PURE__ */ jsx(SliderFill, { className: clsx(rangeStyles, FORCED_SLIDER_FILL) }),
|
|
213
|
+
thumbValues.map((_, i) => /* @__PURE__ */ jsx(
|
|
214
|
+
ValueThumb,
|
|
215
|
+
{
|
|
216
|
+
index: i,
|
|
217
|
+
className: "group/slider flex items-center justify-center h-3u w-3u cursor-pointer data-[disabled]:cursor-not-allowed",
|
|
218
|
+
isInvalid: invalid,
|
|
219
|
+
"data-invalid": invalid || void 0,
|
|
220
|
+
...definedOnly({
|
|
221
|
+
"aria-label": thumbLabel(i),
|
|
222
|
+
// Its label for the server markup, before the thumb's effect names it.
|
|
223
|
+
"aria-labelledby": labelledBy,
|
|
224
|
+
nameIds: thumbNameIds(i),
|
|
225
|
+
name,
|
|
226
|
+
formatValue
|
|
227
|
+
}),
|
|
228
|
+
children: /* @__PURE__ */ jsx("span", { className: clsx(thumbStyles({ size }), FORCED_SLIDER_THUMB) })
|
|
229
|
+
},
|
|
230
|
+
i
|
|
231
|
+
))
|
|
232
|
+
] }),
|
|
233
|
+
showValue && /* @__PURE__ */ jsx("span", { className: valueStyles, "aria-hidden": "true", children: state.values.map((current, index) => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
234
|
+
index > 0 && " \u2013 ",
|
|
235
|
+
/* @__PURE__ */ jsx(NumberText, { value: formatValue ? formatValue(current) : current })
|
|
236
|
+
] }, index)) })
|
|
237
|
+
] }) }, keyForIds(finalId, labelledBy))
|
|
238
|
+
]
|
|
239
|
+
}
|
|
240
|
+
)
|
|
241
|
+
);
|
|
242
|
+
});
|
|
243
|
+
Slider.displayName = "Slider";
|
|
244
|
+
export {
|
|
245
|
+
Slider
|
|
246
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
// src/Slider/Slider.manifest.ts
|
|
2
|
+
var SliderManifest = {
|
|
3
|
+
Slider: {
|
|
4
|
+
description: "Single-thumb or range slider. Pass value: number for single, [number, number] for range. Track in the control outline color; active range in accent; square thumbs that stay inside the slider at both ends. Inside a Field it is named by the label (range thumbs add lower and upper) and a Field error marks it invalid, drawing its thumbs in the error color.",
|
|
5
|
+
props: {
|
|
6
|
+
value: {
|
|
7
|
+
type: "union",
|
|
8
|
+
types: ["number", "array"],
|
|
9
|
+
description: "Single thumb when number; pass [number, number] tuple for range mode."
|
|
10
|
+
},
|
|
11
|
+
defaultValue: {
|
|
12
|
+
type: "union",
|
|
13
|
+
types: ["number", "array"],
|
|
14
|
+
description: "Pass [number, number] tuple for range mode."
|
|
15
|
+
},
|
|
16
|
+
onValueChange: {
|
|
17
|
+
type: "function",
|
|
18
|
+
description: "(value: number | [number, number]) => void. Called as the value changes; a tuple in range mode."
|
|
19
|
+
},
|
|
20
|
+
min: {
|
|
21
|
+
type: "number",
|
|
22
|
+
default: 0,
|
|
23
|
+
description: "Finite lower bound. Non-finite values fall back to 0."
|
|
24
|
+
},
|
|
25
|
+
max: {
|
|
26
|
+
type: "number",
|
|
27
|
+
default: 100,
|
|
28
|
+
description: "Finite upper bound greater than min. Invalid values fall back to min + 100."
|
|
29
|
+
},
|
|
30
|
+
step: {
|
|
31
|
+
type: "number",
|
|
32
|
+
default: 1,
|
|
33
|
+
description: "Finite positive increment. Invalid values fall back to 1."
|
|
34
|
+
},
|
|
35
|
+
disabled: { type: "boolean", default: false },
|
|
36
|
+
orientation: { type: "enum", values: ["horizontal", "vertical"], default: "horizontal" },
|
|
37
|
+
size: { type: "enum", values: ["sm", "md", "lg"], default: "md" },
|
|
38
|
+
showValue: {
|
|
39
|
+
type: "boolean",
|
|
40
|
+
default: false,
|
|
41
|
+
description: "Render the current value(s) in mono next to the track; the readout moves under the track when the row cannot hold both."
|
|
42
|
+
},
|
|
43
|
+
formatValue: {
|
|
44
|
+
type: "function",
|
|
45
|
+
description: "(value: number) => string. Formats displayed values and each thumb's aria-valuetext. Applies separately to both values in range mode, including when showValue is false."
|
|
46
|
+
},
|
|
47
|
+
name: { type: "string" }
|
|
48
|
+
},
|
|
49
|
+
composable_with: ["Field"],
|
|
50
|
+
never_inside: ["Button", "Badge"],
|
|
51
|
+
example: '<Slider aria-label="Acceptable temperature" defaultValue={[18, 24]} min={-20} max={50} showValue />'
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
export {
|
|
55
|
+
SliderManifest
|
|
56
|
+
};
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/Sparkline/Sparkline.tsx
|
|
4
|
+
import { forwardRef, useId } from "react";
|
|
5
|
+
import { cva } from "class-variance-authority";
|
|
6
|
+
import clsx from "clsx";
|
|
7
|
+
import { devValidate } from "../_internal/devValidate.js";
|
|
8
|
+
import {
|
|
9
|
+
extent,
|
|
10
|
+
isFinitePoint,
|
|
11
|
+
linePath,
|
|
12
|
+
scale,
|
|
13
|
+
segments,
|
|
14
|
+
seriesColorClass
|
|
15
|
+
} from "../Chart/geometry.js";
|
|
16
|
+
import { SparklineManifest } from "./Sparkline.manifest.js";
|
|
17
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
18
|
+
var sparklineStyles = cva("inline-block w-16u max-w-full shrink-0 align-middle font-sans", {
|
|
19
|
+
variants: { variant: { line: "", area: "" } },
|
|
20
|
+
defaultVariants: { variant: "line" }
|
|
21
|
+
});
|
|
22
|
+
var Sparkline = forwardRef((allProps, ref) => {
|
|
23
|
+
const { label, data, unit, seriesId, color, variant = "line", className, ...props } = allProps;
|
|
24
|
+
if (process.env.NODE_ENV !== "production") {
|
|
25
|
+
devValidate("Sparkline", SparklineManifest.Sparkline.props, { ...allProps });
|
|
26
|
+
}
|
|
27
|
+
const id = useId();
|
|
28
|
+
const points = data.map((y2, x2) => ({ x: x2, y: y2 }));
|
|
29
|
+
const finite = points.filter(isFinitePoint);
|
|
30
|
+
const x = scale(extent(points.map((point) => point.x)), 4, 124);
|
|
31
|
+
const y = scale(
|
|
32
|
+
extent(
|
|
33
|
+
finite.map((point) => point.y),
|
|
34
|
+
variant === "area"
|
|
35
|
+
),
|
|
36
|
+
28,
|
|
37
|
+
4
|
|
38
|
+
);
|
|
39
|
+
const baseline = y(0);
|
|
40
|
+
const last = finite[finite.length - 1];
|
|
41
|
+
const values = data.map(
|
|
42
|
+
(value) => value !== null && Number.isFinite(value) ? `${value}${unit ? ` ${unit}` : ""}` : "Missing"
|
|
43
|
+
);
|
|
44
|
+
return /* @__PURE__ */ jsxs(
|
|
45
|
+
"div",
|
|
46
|
+
{
|
|
47
|
+
...props,
|
|
48
|
+
ref,
|
|
49
|
+
"data-oprt-sparkline": variant,
|
|
50
|
+
className: clsx(sparklineStyles({ variant }), seriesColorClass(seriesId, color), className),
|
|
51
|
+
children: [
|
|
52
|
+
/* @__PURE__ */ jsxs(
|
|
53
|
+
"svg",
|
|
54
|
+
{
|
|
55
|
+
role: "img",
|
|
56
|
+
"aria-label": label,
|
|
57
|
+
"aria-describedby": `${id}-values`,
|
|
58
|
+
viewBox: "0 0 128 32",
|
|
59
|
+
className: "block h-auto w-full overflow-visible",
|
|
60
|
+
children: [
|
|
61
|
+
variant === "area" && finite.length > 0 && /* @__PURE__ */ jsx(
|
|
62
|
+
"line",
|
|
63
|
+
{
|
|
64
|
+
x1: 4,
|
|
65
|
+
x2: 124,
|
|
66
|
+
y1: baseline,
|
|
67
|
+
y2: baseline,
|
|
68
|
+
"aria-hidden": "true",
|
|
69
|
+
className: "text-oprt-chart-grid",
|
|
70
|
+
stroke: "currentColor",
|
|
71
|
+
strokeWidth: "var(--oprt-chart-guide-width)",
|
|
72
|
+
vectorEffect: "non-scaling-stroke"
|
|
73
|
+
}
|
|
74
|
+
),
|
|
75
|
+
segments(points).map((segment, index) => {
|
|
76
|
+
const path = linePath(segment, x, y);
|
|
77
|
+
return /* @__PURE__ */ jsxs("g", { "data-chart-segment": "", "aria-hidden": "true", children: [
|
|
78
|
+
variant === "area" && /* @__PURE__ */ jsx(
|
|
79
|
+
"path",
|
|
80
|
+
{
|
|
81
|
+
d: `${path} L${x(segment[segment.length - 1].x)},${baseline} L${x(segment[0].x)},${baseline} Z`,
|
|
82
|
+
fill: "currentColor",
|
|
83
|
+
fillOpacity: "var(--oprt-chart-area-opacity)"
|
|
84
|
+
}
|
|
85
|
+
),
|
|
86
|
+
/* @__PURE__ */ jsx(
|
|
87
|
+
"path",
|
|
88
|
+
{
|
|
89
|
+
d: path,
|
|
90
|
+
fill: "none",
|
|
91
|
+
stroke: "currentColor",
|
|
92
|
+
strokeWidth: "var(--oprt-chart-stroke-width)",
|
|
93
|
+
strokeLinecap: "butt",
|
|
94
|
+
strokeLinejoin: "miter",
|
|
95
|
+
strokeMiterlimit: 2,
|
|
96
|
+
vectorEffect: "non-scaling-stroke"
|
|
97
|
+
}
|
|
98
|
+
),
|
|
99
|
+
segment.length === 1 && segment[0] !== last && /* @__PURE__ */ jsx(
|
|
100
|
+
"rect",
|
|
101
|
+
{
|
|
102
|
+
x: x(segment[0].x) - 1.5,
|
|
103
|
+
y: y(segment[0].y) - 1.5,
|
|
104
|
+
width: 3,
|
|
105
|
+
height: 3,
|
|
106
|
+
fill: "currentColor"
|
|
107
|
+
}
|
|
108
|
+
)
|
|
109
|
+
] }, index);
|
|
110
|
+
}),
|
|
111
|
+
last && /* @__PURE__ */ jsx(
|
|
112
|
+
"rect",
|
|
113
|
+
{
|
|
114
|
+
"data-sparkline-endpoint": "",
|
|
115
|
+
"aria-hidden": "true",
|
|
116
|
+
x: x(last.x) - 2,
|
|
117
|
+
y: y(last.y) - 2,
|
|
118
|
+
width: 4,
|
|
119
|
+
height: 4,
|
|
120
|
+
fill: "currentColor"
|
|
121
|
+
}
|
|
122
|
+
)
|
|
123
|
+
]
|
|
124
|
+
}
|
|
125
|
+
),
|
|
126
|
+
/* @__PURE__ */ jsx("span", { id: `${id}-values`, className: "sr-only", children: values.length ? values.join(", ") : "No data" }),
|
|
127
|
+
finite.length === 0 && /* @__PURE__ */ jsx("span", { className: "text-oprt-base text-oprt-text-dim", children: "No finite data" })
|
|
128
|
+
]
|
|
129
|
+
}
|
|
130
|
+
);
|
|
131
|
+
});
|
|
132
|
+
Sparkline.displayName = "Sparkline";
|
|
133
|
+
export {
|
|
134
|
+
Sparkline
|
|
135
|
+
};
|