@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.
Files changed (266) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +105 -2
  3. package/dist/ActionStatus/ActionStatus.js +104 -0
  4. package/dist/ActionStatus/ActionStatus.manifest.js +64 -0
  5. package/dist/ActionStatus/index.js +7 -0
  6. package/dist/Alert/Alert.js +86 -0
  7. package/dist/Alert/Alert.manifest.js +36 -0
  8. package/dist/Alert/index.js +7 -0
  9. package/dist/AppShell/AppShell.js +103 -0
  10. package/dist/AppShell/AppShell.manifest.js +66 -0
  11. package/dist/AppShell/index.js +9 -0
  12. package/dist/AttachmentPreview/AttachmentPreview.js +145 -0
  13. package/dist/AttachmentPreview/AttachmentPreview.manifest.js +42 -0
  14. package/dist/AttachmentPreview/index.js +9 -0
  15. package/dist/Avatar/Avatar.js +87 -0
  16. package/dist/Avatar/Avatar.manifest.js +25 -0
  17. package/dist/Avatar/index.js +7 -0
  18. package/dist/Badge/Badge.js +124 -0
  19. package/dist/Badge/Badge.manifest.js +41 -0
  20. package/dist/Badge/index.js +7 -0
  21. package/dist/Breadcrumb/Breadcrumb.js +64 -0
  22. package/dist/Breadcrumb/Breadcrumb.manifest.js +28 -0
  23. package/dist/Breadcrumb/index.js +7 -0
  24. package/dist/BulkActionBar/BulkActionBar.js +145 -0
  25. package/dist/BulkActionBar/BulkActionBar.manifest.js +46 -0
  26. package/dist/BulkActionBar/index.js +9 -0
  27. package/dist/BulkActionBar/selection.js +44 -0
  28. package/dist/BulkResults/BulkResults.js +269 -0
  29. package/dist/BulkResults/BulkResults.manifest.js +45 -0
  30. package/dist/BulkResults/index.js +7 -0
  31. package/dist/Button/Button.js +170 -0
  32. package/dist/Button/Button.manifest.js +36 -0
  33. package/dist/Button/index.js +7 -0
  34. package/dist/ButtonGroup/ButtonGroup.js +60 -0
  35. package/dist/ButtonGroup/ButtonGroup.manifest.js +22 -0
  36. package/dist/ButtonGroup/index.js +7 -0
  37. package/dist/Calendar/Calendar.js +106 -0
  38. package/dist/Calendar/Calendar.manifest.js +32 -0
  39. package/dist/Calendar/index.js +7 -0
  40. package/dist/Card/Card.js +70 -0
  41. package/dist/Card/Card.manifest.js +57 -0
  42. package/dist/Card/index.js +16 -0
  43. package/dist/Chart/Chart.js +1200 -0
  44. package/dist/Chart/Chart.manifest.js +110 -0
  45. package/dist/Chart/ChartControls.js +190 -0
  46. package/dist/Chart/geometry.js +217 -0
  47. package/dist/Chart/index.js +9 -0
  48. package/dist/Checkbox/Checkbox.js +166 -0
  49. package/dist/Checkbox/Checkbox.manifest.js +38 -0
  50. package/dist/Checkbox/index.js +7 -0
  51. package/dist/Collapsible/Collapsible.js +177 -0
  52. package/dist/Collapsible/Collapsible.manifest.js +54 -0
  53. package/dist/Collapsible/index.js +12 -0
  54. package/dist/CollectionState/CollectionState.js +68 -0
  55. package/dist/CollectionState/CollectionState.manifest.js +44 -0
  56. package/dist/CollectionState/index.js +7 -0
  57. package/dist/ComboBox/ComboBox.js +221 -0
  58. package/dist/ComboBox/ComboBox.manifest.js +87 -0
  59. package/dist/ComboBox/index.js +7 -0
  60. package/dist/CommandPalette/CommandPalette.js +276 -0
  61. package/dist/CommandPalette/CommandPalette.manifest.js +24 -0
  62. package/dist/CommandPalette/index.js +7 -0
  63. package/dist/ConfirmDialog/ConfirmDialog.js +84 -0
  64. package/dist/ConfirmDialog/ConfirmDialog.manifest.js +32 -0
  65. package/dist/ConfirmDialog/index.js +7 -0
  66. package/dist/ContextMenu/ContextMenu.js +192 -0
  67. package/dist/ContextMenu/ContextMenu.manifest.js +41 -0
  68. package/dist/ContextMenu/index.js +7 -0
  69. package/dist/CoordinateInput/CoordinateInput.js +141 -0
  70. package/dist/CoordinateInput/CoordinateInput.manifest.js +36 -0
  71. package/dist/CoordinateInput/index.js +9 -0
  72. package/dist/CopyButton/CopyButton.js +110 -0
  73. package/dist/CopyButton/CopyButton.manifest.js +35 -0
  74. package/dist/CopyButton/index.js +7 -0
  75. package/dist/DataGrid/DataGrid.js +459 -0
  76. package/dist/DataGrid/DataGrid.manifest.js +135 -0
  77. package/dist/DataGrid/PageControls.js +41 -0
  78. package/dist/DataGrid/index.js +9 -0
  79. package/dist/DataTable/DataTable.js +375 -0
  80. package/dist/DataTable/DataTable.manifest.js +86 -0
  81. package/dist/DataTable/index.js +9 -0
  82. package/dist/DataTable/sort.js +45 -0
  83. package/dist/DataTable/useScrollsSideways.js +61 -0
  84. package/dist/DataTable/useTableWindow.js +185 -0
  85. package/dist/DatePicker/DatePicker.js +187 -0
  86. package/dist/DatePicker/DatePicker.manifest.js +40 -0
  87. package/dist/DatePicker/index.js +7 -0
  88. package/dist/DateRangePicker/DateRangePicker.js +156 -0
  89. package/dist/DateRangePicker/DateRangePicker.manifest.js +41 -0
  90. package/dist/DateRangePicker/index.js +7 -0
  91. package/dist/DateTimePicker/DateTimePicker.js +213 -0
  92. package/dist/DateTimePicker/DateTimePicker.manifest.js +44 -0
  93. package/dist/DateTimePicker/index.js +7 -0
  94. package/dist/DescriptionList/DescriptionList.js +93 -0
  95. package/dist/DescriptionList/DescriptionList.manifest.js +40 -0
  96. package/dist/DescriptionList/index.js +9 -0
  97. package/dist/Dialog/Dialog.js +214 -0
  98. package/dist/Dialog/Dialog.manifest.js +31 -0
  99. package/dist/Dialog/index.js +7 -0
  100. package/dist/Divider/Divider.js +64 -0
  101. package/dist/Divider/Divider.manifest.js +21 -0
  102. package/dist/Divider/index.js +7 -0
  103. package/dist/DropdownMenu/DropdownMenu.js +170 -0
  104. package/dist/DropdownMenu/DropdownMenu.manifest.js +82 -0
  105. package/dist/DropdownMenu/index.js +16 -0
  106. package/dist/EntityPreview/EntityPreview.js +82 -0
  107. package/dist/EntityPreview/EntityPreview.manifest.js +43 -0
  108. package/dist/EntityPreview/index.js +7 -0
  109. package/dist/EventTimeline/EventTimeline.js +249 -0
  110. package/dist/EventTimeline/EventTimeline.manifest.js +57 -0
  111. package/dist/EventTimeline/index.js +7 -0
  112. package/dist/Field/Field.js +81 -0
  113. package/dist/Field/Field.manifest.js +32 -0
  114. package/dist/Field/index.js +9 -0
  115. package/dist/FileUpload/FileUpload.js +215 -0
  116. package/dist/FileUpload/FileUpload.manifest.js +48 -0
  117. package/dist/FileUpload/index.js +7 -0
  118. package/dist/FilterBar/FilterBar.js +173 -0
  119. package/dist/FilterBar/FilterBar.manifest.js +49 -0
  120. package/dist/FilterBar/index.js +7 -0
  121. package/dist/FormErrorSummary/FormErrorSummary.js +70 -0
  122. package/dist/FormErrorSummary/FormErrorSummary.manifest.js +29 -0
  123. package/dist/FormErrorSummary/index.js +9 -0
  124. package/dist/FormSection/FormSection.js +51 -0
  125. package/dist/FormSection/FormSection.manifest.js +30 -0
  126. package/dist/FormSection/index.js +7 -0
  127. package/dist/InlineEdit/InlineEdit.js +261 -0
  128. package/dist/InlineEdit/InlineEdit.manifest.js +40 -0
  129. package/dist/InlineEdit/index.js +7 -0
  130. package/dist/Input/Input.js +126 -0
  131. package/dist/Input/Input.manifest.js +49 -0
  132. package/dist/Input/index.js +7 -0
  133. package/dist/Inspector/Inspector.js +63 -0
  134. package/dist/Inspector/Inspector.manifest.js +35 -0
  135. package/dist/Inspector/index.js +7 -0
  136. package/dist/JobStatus/JobStatus.js +118 -0
  137. package/dist/JobStatus/JobStatus.manifest.js +53 -0
  138. package/dist/JobStatus/index.js +7 -0
  139. package/dist/LayerControl/LayerControl.js +199 -0
  140. package/dist/LayerControl/LayerControl.manifest.js +34 -0
  141. package/dist/LayerControl/index.js +7 -0
  142. package/dist/Link/Link.js +83 -0
  143. package/dist/Link/Link.manifest.js +37 -0
  144. package/dist/Link/index.js +7 -0
  145. package/dist/MapControls/MapControls.js +122 -0
  146. package/dist/MapControls/MapControls.manifest.js +31 -0
  147. package/dist/MapControls/index.js +7 -0
  148. package/dist/MapLegend/MapLegend.js +89 -0
  149. package/dist/MapLegend/MapLegend.manifest.js +29 -0
  150. package/dist/MapLegend/index.js +7 -0
  151. package/dist/MapScale/MapScale.js +96 -0
  152. package/dist/MapScale/MapScale.manifest.js +31 -0
  153. package/dist/MapScale/index.js +7 -0
  154. package/dist/MediaFrame/MediaFrame.js +113 -0
  155. package/dist/MediaFrame/MediaFrame.manifest.js +57 -0
  156. package/dist/MediaFrame/index.js +7 -0
  157. package/dist/MultiSelect/MultiSelect.js +113 -0
  158. package/dist/MultiSelect/MultiSelect.manifest.js +51 -0
  159. package/dist/MultiSelect/index.js +7 -0
  160. package/dist/NumberInput/NumberInput.js +210 -0
  161. package/dist/NumberInput/NumberInput.manifest.js +56 -0
  162. package/dist/NumberInput/index.js +7 -0
  163. package/dist/OperationalStatus/OperationalStatus.js +89 -0
  164. package/dist/OperationalStatus/OperationalStatus.manifest.js +39 -0
  165. package/dist/OperationalStatus/index.js +9 -0
  166. package/dist/PlaybackControls/PlaybackControls.js +289 -0
  167. package/dist/PlaybackControls/PlaybackControls.manifest.js +85 -0
  168. package/dist/PlaybackControls/index.js +7 -0
  169. package/dist/Popover/Popover.js +302 -0
  170. package/dist/Popover/Popover.manifest.js +50 -0
  171. package/dist/Popover/index.js +7 -0
  172. package/dist/Progress/Progress.js +132 -0
  173. package/dist/Progress/Progress.manifest.js +30 -0
  174. package/dist/Progress/index.js +7 -0
  175. package/dist/PropertyFilter/PropertyFilter.js +306 -0
  176. package/dist/PropertyFilter/PropertyFilter.manifest.js +32 -0
  177. package/dist/PropertyFilter/index.js +11 -0
  178. package/dist/PropertyFilter/tokenError.js +17 -0
  179. package/dist/RadioGroup/RadioGroup.js +143 -0
  180. package/dist/RadioGroup/RadioGroup.manifest.js +44 -0
  181. package/dist/RadioGroup/index.js +9 -0
  182. package/dist/Select/Select.js +219 -0
  183. package/dist/Select/Select.manifest.js +77 -0
  184. package/dist/Select/index.js +9 -0
  185. package/dist/Sidebar/Sidebar.js +146 -0
  186. package/dist/Sidebar/Sidebar.manifest.js +72 -0
  187. package/dist/Sidebar/index.js +18 -0
  188. package/dist/Skeleton/Skeleton.js +76 -0
  189. package/dist/Skeleton/Skeleton.manifest.js +30 -0
  190. package/dist/Skeleton/index.js +7 -0
  191. package/dist/Slider/Slider.js +246 -0
  192. package/dist/Slider/Slider.manifest.js +56 -0
  193. package/dist/Slider/index.js +7 -0
  194. package/dist/Sparkline/Sparkline.js +135 -0
  195. package/dist/Sparkline/Sparkline.manifest.js +37 -0
  196. package/dist/Sparkline/index.js +7 -0
  197. package/dist/SplitPane/SplitPane.js +316 -0
  198. package/dist/SplitPane/SplitPane.manifest.js +79 -0
  199. package/dist/SplitPane/index.js +7 -0
  200. package/dist/StatCard/StatCard.js +163 -0
  201. package/dist/StatCard/StatCard.manifest.js +45 -0
  202. package/dist/StatCard/index.js +7 -0
  203. package/dist/Tabs/Tabs.js +181 -0
  204. package/dist/Tabs/Tabs.manifest.js +72 -0
  205. package/dist/Tabs/index.js +16 -0
  206. package/dist/Tabs/useTabsIndicator.js +71 -0
  207. package/dist/Tabs/useTabsScroll.js +123 -0
  208. package/dist/TagGroup/TagGroup.js +142 -0
  209. package/dist/TagGroup/TagGroup.manifest.js +35 -0
  210. package/dist/TagGroup/index.js +7 -0
  211. package/dist/Textarea/Textarea.js +68 -0
  212. package/dist/Textarea/Textarea.manifest.js +25 -0
  213. package/dist/Textarea/index.js +7 -0
  214. package/dist/TimeField/TimeField.js +118 -0
  215. package/dist/TimeField/TimeField.manifest.js +42 -0
  216. package/dist/TimeField/index.js +7 -0
  217. package/dist/TimeRange/TimeRange.js +184 -0
  218. package/dist/TimeRange/TimeRange.manifest.js +48 -0
  219. package/dist/TimeRange/index.js +9 -0
  220. package/dist/Toast/Toast.js +188 -0
  221. package/dist/Toast/Toast.manifest.js +77 -0
  222. package/dist/Toast/index.js +9 -0
  223. package/dist/Toggle/Toggle.js +154 -0
  224. package/dist/Toggle/Toggle.manifest.js +54 -0
  225. package/dist/Toggle/index.js +7 -0
  226. package/dist/Toolbar/Toolbar.js +86 -0
  227. package/dist/Toolbar/Toolbar.manifest.js +70 -0
  228. package/dist/Toolbar/index.js +12 -0
  229. package/dist/Tooltip/Tooltip.js +122 -0
  230. package/dist/Tooltip/Tooltip.manifest.js +27 -0
  231. package/dist/Tooltip/index.js +7 -0
  232. package/dist/TreeView/TreeView.js +129 -0
  233. package/dist/TreeView/TreeView.manifest.js +56 -0
  234. package/dist/TreeView/index.js +7 -0
  235. package/dist/UploadQueue/UploadQueue.js +296 -0
  236. package/dist/UploadQueue/UploadQueue.manifest.js +34 -0
  237. package/dist/UploadQueue/index.js +7 -0
  238. package/dist/_internal/MotionPopover.js +113 -0
  239. package/dist/_internal/aria.js +40 -0
  240. package/dist/_internal/bytes.js +18 -0
  241. package/dist/_internal/controlStyles.js +26 -0
  242. package/dist/_internal/date.js +179 -0
  243. package/dist/_internal/devValidate.js +51 -0
  244. package/dist/_internal/fieldIds.js +50 -0
  245. package/dist/_internal/hydration.js +74 -0
  246. package/dist/_internal/manifest-entry.js +0 -0
  247. package/dist/_internal/mergeRefs.js +68 -0
  248. package/dist/_internal/motion.js +138 -0
  249. package/dist/_internal/navigationLandmark.js +13 -0
  250. package/dist/_internal/numberText.js +176 -0
  251. package/dist/_internal/overlay.js +53 -0
  252. package/dist/_internal/segmentField.js +125 -0
  253. package/dist/_internal/suggestions.js +20 -0
  254. package/dist/_internal/timestamp.js +25 -0
  255. package/dist/_internal/unavailable.js +13 -0
  256. package/dist/_internal/useActionFocus.js +27 -0
  257. package/dist/_internal/useElementWidth.js +37 -0
  258. package/dist/_internal/useIsMounted.js +18 -0
  259. package/dist/_internal/useIsomorphicLayoutEffect.js +8 -0
  260. package/dist/_internal/useRestoreFocusOnRemoval.js +57 -0
  261. package/dist/index.cjs +17811 -0
  262. package/dist/index.d.cts +2330 -0
  263. package/dist/index.d.ts +2330 -0
  264. package/dist/index.js +407 -0
  265. package/dist/version.js +8 -0
  266. package/package.json +80 -3
@@ -0,0 +1,188 @@
1
+ "use client";
2
+
3
+ // src/Toast/Toast.tsx
4
+ import { Info, CheckCircle, AlertTriangle, XCircle, X } from "@oprt/icons";
5
+ import * as RadixToast from "@radix-ui/react-toast";
6
+ import { cva } from "class-variance-authority";
7
+ import {
8
+ createContext,
9
+ forwardRef,
10
+ useContext,
11
+ useEffect,
12
+ useRef
13
+ } from "react";
14
+ import clsx from "clsx";
15
+ import { ToastManifest } from "./Toast.manifest.js";
16
+ import { devValidate } from "../_internal/devValidate.js";
17
+ import { useMergedRefs } from "../_internal/mergeRefs.js";
18
+ import { jsx, jsxs } from "react/jsx-runtime";
19
+ var ICONS = {
20
+ info: Info,
21
+ success: CheckCircle,
22
+ warning: AlertTriangle,
23
+ error: XCircle
24
+ };
25
+ function severityOf(variant) {
26
+ return typeof variant === "string" && Object.prototype.hasOwnProperty.call(ICONS, variant) ? variant : "info";
27
+ }
28
+ var SwipeDirectionContext = createContext("right");
29
+ function useNewestInView(region) {
30
+ useEffect(() => {
31
+ const list = region.current;
32
+ if (!list) return;
33
+ const atEnd = () => list.scrollHeight - list.clientHeight - list.scrollTop <= 1;
34
+ const toEnd = () => {
35
+ list.scrollTop = list.scrollHeight;
36
+ };
37
+ let following = true;
38
+ const onScroll = () => {
39
+ following = atEnd();
40
+ };
41
+ const observer = new MutationObserver((records) => {
42
+ if (records.some((record) => record.addedNodes.length > 0)) {
43
+ if (following) toEnd();
44
+ } else {
45
+ following = atEnd();
46
+ }
47
+ });
48
+ list.addEventListener("scroll", onScroll, { passive: true });
49
+ observer.observe(list, { childList: true });
50
+ if (list.childElementCount > 0) toEnd();
51
+ return () => {
52
+ observer.disconnect();
53
+ list.removeEventListener("scroll", onScroll);
54
+ };
55
+ }, [region]);
56
+ }
57
+ var ToastProvider = forwardRef((props, ref) => {
58
+ const { children, label = "Notifications", swipeDirection = "right", duration } = props;
59
+ const providerProps = { label, swipeDirection };
60
+ if (duration !== void 0) providerProps["duration"] = duration;
61
+ const region = useRef(null);
62
+ const regionRef = useMergedRefs(ref, region);
63
+ useNewestInView(region);
64
+ if (process.env.NODE_ENV !== "production") {
65
+ devValidate("ToastProvider", ToastManifest.ToastProvider.props, props);
66
+ }
67
+ return /* @__PURE__ */ jsxs(RadixToast.Provider, { ...providerProps, children: [
68
+ /* @__PURE__ */ jsx(SwipeDirectionContext.Provider, { value: swipeDirection, children }),
69
+ /* @__PURE__ */ jsx(
70
+ RadixToast.Viewport,
71
+ {
72
+ ref: regionRef,
73
+ label: `${label} ({hotkey})`,
74
+ className: "fixed bottom-0 right-0 z-50 flex max-h-dvh [@supports_not_(height:100dvh)]:max-h-screen flex-col gap-2u overflow-y-auto overscroll-contain p-4u m-0 w-full max-w-sm list-none"
75
+ }
76
+ )
77
+ ] });
78
+ });
79
+ ToastProvider.displayName = "ToastProvider";
80
+ var rootStyles = cva(
81
+ "bg-oprt-surface-1 border border-oprt-border border-l-2 px-3u py-2u flex gap-2u items-start font-sans",
82
+ {
83
+ variants: {
84
+ variant: {
85
+ info: "border-l-oprt-info",
86
+ success: "border-l-oprt-success",
87
+ warning: "border-l-oprt-warning",
88
+ error: "border-l-oprt-error"
89
+ }
90
+ },
91
+ defaultVariants: { variant: "info" }
92
+ }
93
+ );
94
+ var iconStyles = cva("shrink-0", {
95
+ variants: {
96
+ variant: {
97
+ info: "text-oprt-info",
98
+ success: "text-oprt-success",
99
+ warning: "text-oprt-warning",
100
+ error: "text-oprt-error"
101
+ }
102
+ },
103
+ defaultVariants: { variant: "info" }
104
+ });
105
+ var titleStyles = cva("m-0 text-oprt-sm uppercase tracking-oprt-sm", {
106
+ variants: {
107
+ variant: {
108
+ info: "text-oprt-info",
109
+ success: "text-oprt-success",
110
+ warning: "text-oprt-warning",
111
+ error: "text-oprt-error"
112
+ }
113
+ },
114
+ defaultVariants: { variant: "info" }
115
+ });
116
+ var Toast = forwardRef((allProps, ref) => {
117
+ const {
118
+ className,
119
+ variant,
120
+ title,
121
+ description,
122
+ persistent = false,
123
+ open,
124
+ defaultOpen,
125
+ onOpenChange,
126
+ duration,
127
+ type,
128
+ style,
129
+ onPointerMove,
130
+ ...props
131
+ } = allProps;
132
+ const severity = severityOf(variant);
133
+ const SeverityIcon = ICONS[severity];
134
+ const swipeDirection = useContext(SwipeDirectionContext);
135
+ if (process.env.NODE_ENV !== "production") {
136
+ devValidate("Toast", ToastManifest.Toast.props, allProps);
137
+ }
138
+ const rootProps = {};
139
+ if (open !== void 0) rootProps["open"] = open;
140
+ if (defaultOpen !== void 0) rootProps["defaultOpen"] = defaultOpen;
141
+ if (onOpenChange !== void 0) rootProps["onOpenChange"] = onOpenChange;
142
+ if (persistent) {
143
+ rootProps["duration"] = Infinity;
144
+ } else if (duration !== void 0) {
145
+ rootProps["duration"] = duration;
146
+ }
147
+ rootProps["type"] = type ?? (severity === "error" || severity === "warning" ? "foreground" : "background");
148
+ return /* @__PURE__ */ jsxs(
149
+ RadixToast.Root,
150
+ {
151
+ ref,
152
+ className: clsx(rootStyles({ variant: severity }), className),
153
+ ...rootProps,
154
+ ...props,
155
+ onPointerMove: (event) => {
156
+ onPointerMove?.(event);
157
+ if (event.pointerType !== "touch") event.defaultPrevented = true;
158
+ },
159
+ style: {
160
+ touchAction: swipeDirection === "up" || swipeDirection === "down" ? "pan-x" : "pan-y",
161
+ ...style
162
+ },
163
+ children: [
164
+ /* @__PURE__ */ jsx(SeverityIcon, { size: 16, className: iconStyles({ variant: severity }) }),
165
+ /* @__PURE__ */ jsxs("div", { className: "flex min-w-0 flex-1 select-text flex-col gap-1u oprt-wrap-anywhere", children: [
166
+ /* @__PURE__ */ jsx(RadixToast.Title, { className: titleStyles({ variant: severity }), children: title }),
167
+ description && /* @__PURE__ */ jsxs(RadixToast.Description, { className: "m-0 text-oprt-base normal-case text-oprt-text", children: [
168
+ /* @__PURE__ */ jsx("span", { className: "sr-only", children: ". " }),
169
+ description
170
+ ] })
171
+ ] }),
172
+ /* @__PURE__ */ jsx(
173
+ RadixToast.Close,
174
+ {
175
+ "aria-label": "Dismiss",
176
+ className: "inline-flex items-center justify-center shrink-0 h-oprt-sm w-3u border border-transparent text-oprt-text-dim hover:text-oprt-text focus-visible:border-oprt-border-focus focus-visible:shadow-oprt-focus focus-visible:outline-hidden",
177
+ children: /* @__PURE__ */ jsx(X, { size: 12 })
178
+ }
179
+ )
180
+ ]
181
+ }
182
+ );
183
+ });
184
+ Toast.displayName = "Toast";
185
+ export {
186
+ Toast,
187
+ ToastProvider
188
+ };
@@ -0,0 +1,77 @@
1
+ // src/Toast/Toast.manifest.ts
2
+ var ToastManifest = {
3
+ ToastProvider: {
4
+ description: "Wraps the app and renders the notification region, a fixed corner of the window where Toast notifications stack and announce. The region never outgrows the window: a tall stack scrolls inside it, and a new notice is scrolled into view unless the reader has scrolled away from the newest.",
5
+ props: {
6
+ label: {
7
+ type: "string",
8
+ default: "Notifications",
9
+ description: "Names the notification region, as '<label> (F8)', F8 being the key that moves focus to it, and is spoken before each announcement. Set it for a translated or more specific name."
10
+ },
11
+ swipeDirection: {
12
+ type: "enum",
13
+ values: ["right", "left", "up", "down"],
14
+ default: "right",
15
+ description: "The direction a touch swipe dismisses a toast; a mouse or pen drag selects text instead. With right or left, a vertical touch drag on a toast scrolls the region; with up or down, that drag is the swipe, so the region does not scroll by dragging a toast."
16
+ },
17
+ duration: {
18
+ type: "number",
19
+ description: "Milliseconds before a toast closes itself. Defaults to 5000."
20
+ }
21
+ },
22
+ slots: {
23
+ children: { type: "Toast", required: true }
24
+ },
25
+ never_inside: ["ToastProvider", "Toast"],
26
+ example: '<ToastProvider>\n <Toast variant="success" title="DEPLOYED" description="Build promoted to prod." open={open} onOpenChange={setOpen} />\n</ToastProvider>'
27
+ },
28
+ Toast: {
29
+ description: "A single transient notification with a severity icon, title, optional description, and dismiss control. It closes itself after its duration or when dismissed, by calling onOpenChange(false); the application removes it.",
30
+ props: {
31
+ variant: {
32
+ type: "enum",
33
+ values: ["info", "success", "warning", "error"],
34
+ default: "info",
35
+ description: "Severity. Drives the icon, the accent color and, unless type is set, how the toast is announced: error and warning interrupt a screen reader, info and success wait."
36
+ },
37
+ title: { type: "string", required: true },
38
+ description: { type: "string" },
39
+ open: {
40
+ type: "boolean",
41
+ description: "Controlled open state. A toast that is open and never closed stays on screen: pass onOpenChange and remove the toast, or clear open, when it is called."
42
+ },
43
+ defaultOpen: {
44
+ type: "boolean",
45
+ default: true,
46
+ description: "Initial open state when open is not controlled."
47
+ },
48
+ onOpenChange: {
49
+ type: "function",
50
+ description: "Called with false when the toast closes itself after its duration, or when Dismiss, Escape or a touch swipe closes it."
51
+ },
52
+ type: {
53
+ type: "enum",
54
+ values: ["foreground", "background"],
55
+ description: "How the toast is announced: foreground interrupts a screen reader, background waits. Defaults to foreground for error and warning and background for info and success."
56
+ },
57
+ duration: { type: "number" },
58
+ persistent: {
59
+ type: "boolean",
60
+ default: false,
61
+ description: "Disables automatic dismissal (duration Infinity). The toast stays until dismissed."
62
+ }
63
+ },
64
+ composable_with: ["ToastProvider"],
65
+ never_inside: ["Toast"],
66
+ example: '<Toast variant="error" title="LINK LOST" description="No telemetry for 12s." open={open} onOpenChange={setOpen} />'
67
+ }
68
+ };
69
+ var ToastCompositionRules = {
70
+ ToastProvider: {
71
+ allowed_children: ["Toast"]
72
+ }
73
+ };
74
+ export {
75
+ ToastCompositionRules,
76
+ ToastManifest
77
+ };
@@ -0,0 +1,9 @@
1
+ // src/Toast/index.ts
2
+ import { ToastProvider, Toast } from "./Toast.js";
3
+ import { ToastManifest, ToastCompositionRules } from "./Toast.manifest.js";
4
+ export {
5
+ Toast,
6
+ ToastCompositionRules,
7
+ ToastManifest,
8
+ ToastProvider
9
+ };
@@ -0,0 +1,154 @@
1
+ "use client";
2
+
3
+ // src/Toggle/Toggle.tsx
4
+ import { Switch as AriaSwitch } from "react-aria-components";
5
+ import { cva } from "class-variance-authority";
6
+ import { forwardRef, useCallback } from "react";
7
+ import clsx from "clsx";
8
+ import { useMotion } from "../_internal/motion.js";
9
+ import { useFieldWiring } from "../_internal/fieldIds.js";
10
+ import { ToggleManifest } from "./Toggle.manifest.js";
11
+ import { devValidate } from "../_internal/devValidate.js";
12
+ import { definedOnly, switchValidationProps, useAriaInvalidRef } from "../_internal/aria.js";
13
+ import { keyForIds } from "../_internal/hydration.js";
14
+ import { useInputRefObject } from "../_internal/mergeRefs.js";
15
+ import { jsx } from "react/jsx-runtime";
16
+ var trackStyles = cva(
17
+ [
18
+ "relative inline-flex items-center border oprt-motion-track cursor-pointer",
19
+ // The thumb's resting distance from the border, named once because its travel uses it too.
20
+ "[--toggle-inset:2px] px-[var(--toggle-inset)]",
21
+ // The resting boundary is the control outline (design call DC-3); on, it is the accent.
22
+ // Invalid draws the error color whether the switch is on or off: Tailwind sorts these state
23
+ // variants by name, so `selected` would win a tie, and `[&&]` raises the invalid rule above it.
24
+ "bg-oprt-surface-2 border-oprt-border-control",
25
+ "group-data-[selected]/toggle:bg-oprt-accent group-data-[selected]/toggle:border-oprt-accent-light",
26
+ "group-data-[selected]/toggle:[&_.oprt-toggle-thumb]:bg-oprt-bg",
27
+ "group-data-[invalid]/toggle:[&&]:border-oprt-error",
28
+ "group-data-[focus-visible]/toggle:border-oprt-border-focus group-data-[focus-visible]/toggle:shadow-oprt-focus",
29
+ "group-data-[disabled]/toggle:opacity-50 group-data-[disabled]/toggle:cursor-not-allowed",
30
+ // Forced colors replace every background with the page color and drop box-shadow, so the
31
+ // thumb, the on fill and the focus ring would all vanish. Each is redrawn from system colors,
32
+ // which forced colors keep, and the focus ring becomes an outline.
33
+ "forced-colors:[forced-color-adjust:none] forced-colors:bg-[color:Canvas] forced-colors:border-[color:CanvasText]",
34
+ "forced-colors:group-data-[selected]/toggle:bg-[color:Highlight] forced-colors:group-data-[selected]/toggle:border-[color:Highlight]",
35
+ "forced-colors:group-data-[selected]/toggle:[&_.oprt-toggle-thumb]:bg-[color:HighlightText]",
36
+ "forced-colors:group-data-[focus-visible]/toggle:outline-solid forced-colors:group-data-[focus-visible]/toggle:outline-2 forced-colors:group-data-[focus-visible]/toggle:outline-offset-2 forced-colors:group-data-[focus-visible]/toggle:outline-[color:CanvasText]",
37
+ // Disabled wins over on (`[&&]` raises it above the `selected` rules, which Tailwind writes
38
+ // later): a disabled switch that is on is a Canvas track with GrayText edge and thumb, and the
39
+ // thumb's place still says it is on.
40
+ "forced-colors:group-data-[disabled]/toggle:[&&]:bg-[color:Canvas] forced-colors:group-data-[disabled]/toggle:[&&]:border-[color:GrayText] forced-colors:[&&]:group-data-[disabled]/toggle:[&_.oprt-toggle-thumb]:bg-[color:GrayText]"
41
+ ].join(" "),
42
+ {
43
+ variants: {
44
+ // The thumb travels the track's width less its two 1px borders and both insets, less its own
45
+ // width, so it ends as far from the border as it starts (14, 18 and 22 px).
46
+ size: {
47
+ sm: "w-4u h-2u group-data-[selected]/toggle:[&_.oprt-toggle-thumb]:translate-x-[calc(var(--oprt-space-4)-var(--oprt-space-1)*1.5-2px-var(--toggle-inset)*2)]",
48
+ md: "w-5u h-2.5u group-data-[selected]/toggle:[&_.oprt-toggle-thumb]:translate-x-[calc(var(--oprt-space-5)-var(--oprt-space-2)-2px-var(--toggle-inset)*2)]",
49
+ lg: "w-6u h-3u group-data-[selected]/toggle:[&_.oprt-toggle-thumb]:translate-x-[calc(var(--oprt-space-6)-var(--oprt-space-1)*2.5-2px-var(--toggle-inset)*2)]"
50
+ }
51
+ },
52
+ defaultVariants: { size: "md" }
53
+ }
54
+ );
55
+ var thumbStyles = cva(
56
+ "oprt-toggle-thumb block oprt-motion-thumb bg-oprt-text-dim forced-colors:bg-[color:CanvasText]",
57
+ {
58
+ variants: {
59
+ size: {
60
+ sm: "h-1.5u w-1.5u",
61
+ md: "h-2u w-2u",
62
+ lg: "h-2.5u w-2.5u"
63
+ }
64
+ },
65
+ defaultVariants: { size: "md" }
66
+ }
67
+ );
68
+ var Toggle = forwardRef((allProps, ref) => {
69
+ const {
70
+ className,
71
+ motion = "auto",
72
+ size = "md",
73
+ id,
74
+ checked,
75
+ defaultChecked,
76
+ onCheckedChange,
77
+ disabled,
78
+ required,
79
+ name,
80
+ value,
81
+ "aria-label": ariaLabel,
82
+ "aria-labelledby": ariaLabelledBy,
83
+ "aria-describedby": ariaDescribedBy,
84
+ "aria-invalid": ariaInvalid
85
+ } = allProps;
86
+ const motionState = useMotion(motion, "Toggle");
87
+ const {
88
+ id: finalId,
89
+ labelledBy,
90
+ describedBy,
91
+ invalid: isInvalid,
92
+ required: isRequired
93
+ } = useFieldWiring(
94
+ {
95
+ id,
96
+ "aria-label": ariaLabel,
97
+ "aria-labelledby": ariaLabelledBy,
98
+ "aria-describedby": ariaDescribedBy,
99
+ "aria-invalid": ariaInvalid,
100
+ required
101
+ },
102
+ { label: "labelledby" }
103
+ );
104
+ if (process.env.NODE_ENV !== "production") {
105
+ devValidate("Toggle", ToggleManifest.Toggle.props, { ...allProps });
106
+ }
107
+ const setInvalidNode = useAriaInvalidRef(ref, isInvalid);
108
+ const setNode = useCallback(
109
+ (node) => {
110
+ if (node) {
111
+ if (isRequired) node.setAttribute("aria-required", "true");
112
+ else node.removeAttribute("aria-required");
113
+ node.required = isRequired;
114
+ }
115
+ return setInvalidNode(node);
116
+ },
117
+ [setInvalidNode, isRequired]
118
+ );
119
+ const inputRef = useInputRefObject(setNode);
120
+ const rootProps = {
121
+ isDisabled: disabled ?? false,
122
+ ...definedOnly({
123
+ id: finalId,
124
+ "aria-label": ariaLabel,
125
+ "aria-labelledby": labelledBy,
126
+ "aria-describedby": describedBy,
127
+ name,
128
+ value
129
+ })
130
+ };
131
+ Object.assign(rootProps, switchValidationProps({ invalid: isInvalid, required: isRequired }));
132
+ if (checked !== void 0) rootProps["isSelected"] = checked;
133
+ if (defaultChecked !== void 0) rootProps["defaultSelected"] = defaultChecked;
134
+ if (onCheckedChange) rootProps["onChange"] = onCheckedChange;
135
+ return /* @__PURE__ */ jsx(
136
+ AriaSwitch,
137
+ {
138
+ ...rootProps,
139
+ ...motionState.props,
140
+ render: (domProps) => /* @__PURE__ */ jsx("label", { ...domProps, ...motionState.props }),
141
+ inputRef,
142
+ className: clsx(
143
+ "oprt-motion group/toggle inline-flex self-start w-fit items-center justify-center min-h-3u cursor-pointer data-[disabled]:cursor-not-allowed",
144
+ className
145
+ ),
146
+ children: /* @__PURE__ */ jsx("span", { className: trackStyles({ size: size ?? void 0 }), children: /* @__PURE__ */ jsx("span", { className: thumbStyles({ size: size ?? void 0 }) }) })
147
+ },
148
+ keyForIds(finalId, labelledBy)
149
+ );
150
+ });
151
+ Toggle.displayName = "Toggle";
152
+ export {
153
+ Toggle
154
+ };
@@ -0,0 +1,54 @@
1
+ // src/Toggle/Toggle.manifest.ts
2
+ var ToggleManifest = {
3
+ Toggle: {
4
+ description: "Binary on/off switch. Square thumb sliding inside a square track. Accent fill when on; an invalid switch draws its track in the error color. In forced-colors mode the on state, the thumb and keyboard focus use system colors.",
5
+ props: {
6
+ motion: {
7
+ type: "enum",
8
+ values: ["auto", "none"],
9
+ default: "auto",
10
+ description: "Tactile pointer/touch feedback. None disables motion; keyboard and system reduced motion are always immediate."
11
+ },
12
+ checked: { type: "boolean" },
13
+ defaultChecked: { type: "boolean", default: false },
14
+ onCheckedChange: { type: "function", description: "Receives the new checked value." },
15
+ disabled: { type: "boolean", default: false },
16
+ required: {
17
+ type: "boolean",
18
+ default: false,
19
+ description: "Announced as required. Like a required Checkbox, it blocks native form submission until the switch is on. The native attribute is added when the page hydrates (the server markup has aria-required), so a form submitted earlier is not blocked: validate on the server too."
20
+ },
21
+ size: { type: "enum", values: ["sm", "md", "lg"], default: "md" },
22
+ name: { type: "string" },
23
+ value: { type: "string" },
24
+ id: {
25
+ type: "string",
26
+ description: "Id of the switch input. Inside a Field it defaults to the Field's id."
27
+ },
28
+ className: { type: "string", description: "Classes applied to the switch's label root." },
29
+ "aria-label": {
30
+ type: "string",
31
+ description: "Accessible name when there is no visible label. Inside a Field the Field's label names the switch."
32
+ },
33
+ "aria-labelledby": {
34
+ type: "string",
35
+ description: "Id of the element that names the switch."
36
+ },
37
+ "aria-describedby": {
38
+ type: "string",
39
+ description: "Id of the element that describes the switch. A Field supplies its help or error."
40
+ },
41
+ "aria-invalid": {
42
+ type: "union",
43
+ types: ["boolean", "string"],
44
+ description: "Marks the switch invalid: announced as invalid, with its track in the error color. A Field with an error sets it."
45
+ }
46
+ },
47
+ composable_with: ["Field", "Toolbar"],
48
+ never_inside: ["Button", "Badge"],
49
+ example: '<Field label="ENABLE TELEMETRY">\n <Toggle defaultChecked />\n</Field>'
50
+ }
51
+ };
52
+ export {
53
+ ToggleManifest
54
+ };
@@ -0,0 +1,7 @@
1
+ // src/Toggle/index.ts
2
+ import { Toggle } from "./Toggle.js";
3
+ import { ToggleManifest } from "./Toggle.manifest.js";
4
+ export {
5
+ Toggle,
6
+ ToggleManifest
7
+ };
@@ -0,0 +1,86 @@
1
+ "use client";
2
+
3
+ // src/Toolbar/Toolbar.tsx
4
+ import { Toolbar as AriaToolbar, Separator as AriaSeparator } from "react-aria-components";
5
+ import { cva } from "class-variance-authority";
6
+ import { createContext, forwardRef, useContext } from "react";
7
+ import clsx from "clsx";
8
+ import { ToolbarManifest } from "./Toolbar.manifest.js";
9
+ import { devValidate } from "../_internal/devValidate.js";
10
+ import { jsx } from "react/jsx-runtime";
11
+ var toolbarStyles = cva("flex bg-oprt-surface-1 border border-oprt-border font-sans", {
12
+ variants: {
13
+ orientation: {
14
+ horizontal: "flex-wrap items-center gap-x-2u gap-y-1u px-2u min-h-oprt-lg py-[calc((var(--oprt-height-lg)-2px-var(--oprt-height-md))/2)]",
15
+ vertical: "flex-col items-stretch gap-2u px-2u py-2u w-auto h-auto"
16
+ }
17
+ },
18
+ defaultVariants: { orientation: "horizontal" }
19
+ });
20
+ var ToolbarOrientationContext = createContext(void 0);
21
+ var Toolbar = forwardRef((allProps, ref) => {
22
+ const {
23
+ className,
24
+ orientation = "horizontal",
25
+ ariaLabel,
26
+ "aria-label": nativeLabel,
27
+ "aria-labelledby": labelledBy,
28
+ children,
29
+ id,
30
+ ...props
31
+ } = allProps;
32
+ if (process.env.NODE_ENV !== "production") {
33
+ devValidate("Toolbar", ToolbarManifest.Toolbar.props, { ...allProps });
34
+ }
35
+ const label = ariaLabel ?? nativeLabel;
36
+ const name = label ?? (labelledBy === void 0 ? "Toolbar" : void 0);
37
+ const axis = orientation ?? "horizontal";
38
+ return /* @__PURE__ */ jsx(ToolbarOrientationContext.Provider, { value: axis, children: /* @__PURE__ */ jsx(
39
+ AriaToolbar,
40
+ {
41
+ ref,
42
+ orientation: axis,
43
+ ...id !== void 0 ? { id } : {},
44
+ ...name !== void 0 ? { "aria-label": name } : {},
45
+ ...labelledBy !== void 0 ? { "aria-labelledby": labelledBy } : {},
46
+ className: clsx(toolbarStyles({ orientation: axis }), className),
47
+ ...props,
48
+ children
49
+ }
50
+ ) });
51
+ });
52
+ Toolbar.displayName = "Toolbar";
53
+ var separatorStyles = cva("bg-oprt-border self-stretch", {
54
+ variants: {
55
+ orientation: {
56
+ horizontal: "w-px mx-1u",
57
+ vertical: "h-px my-1u"
58
+ }
59
+ },
60
+ defaultVariants: { orientation: "horizontal" }
61
+ });
62
+ var ToolbarSeparator = forwardRef(
63
+ (allProps, ref) => {
64
+ const { className, orientation: given, ...props } = allProps;
65
+ const inherited = useContext(ToolbarOrientationContext);
66
+ const orientation = given ?? inherited ?? "horizontal";
67
+ if (process.env.NODE_ENV !== "production") {
68
+ devValidate("ToolbarSeparator", ToolbarManifest.ToolbarSeparator.props, { ...allProps });
69
+ }
70
+ return /* @__PURE__ */ jsx(
71
+ AriaSeparator,
72
+ {
73
+ ref,
74
+ orientation: orientation === "horizontal" ? "vertical" : "horizontal",
75
+ elementType: "div",
76
+ className: clsx(separatorStyles({ orientation }), className),
77
+ ...props
78
+ }
79
+ );
80
+ }
81
+ );
82
+ ToolbarSeparator.displayName = "ToolbarSeparator";
83
+ export {
84
+ Toolbar,
85
+ ToolbarSeparator
86
+ };
@@ -0,0 +1,70 @@
1
+ // src/Toolbar/Toolbar.manifest.ts
2
+ var ToolbarManifest = {
3
+ Toolbar: {
4
+ description: "Horizontal or vertical action bar with roving-tabindex arrow-key navigation over its focusable children. A horizontal toolbar that does not fit wraps onto more rows and grows taller, so no action is hidden; arrow keys follow reading order across rows. A vertical toolbar stacks.",
5
+ props: {
6
+ orientation: {
7
+ type: "enum",
8
+ values: ["horizontal", "vertical"],
9
+ default: "horizontal"
10
+ },
11
+ ariaLabel: {
12
+ type: "string",
13
+ description: "The toolbar's accessible name (native aria-label works too). With aria-labelledby and no label the toolbar is named by that element; a toolbar given neither is called Toolbar."
14
+ }
15
+ },
16
+ slots: {
17
+ children: {
18
+ type: "Button | ButtonGroup | Badge | Toggle | CopyButton | ConfirmDialog | DropdownMenu | Tooltip | ToolbarSeparator",
19
+ required: true
20
+ }
21
+ },
22
+ composable_with: [
23
+ "Button",
24
+ "ButtonGroup",
25
+ "Badge",
26
+ "Toggle",
27
+ "CopyButton",
28
+ "ConfirmDialog",
29
+ "DropdownMenu",
30
+ "Tooltip",
31
+ "ToolbarSeparator"
32
+ ],
33
+ never_inside: ["Toolbar"],
34
+ example: '<Toolbar ariaLabel="Track actions">\n <Button>ZOOM</Button>\n <ToolbarSeparator />\n <Button>RESET</Button>\n</Toolbar>'
35
+ },
36
+ ToolbarSeparator: {
37
+ description: "Visual divider between Toolbar action groups. It follows its Toolbar: a rule across a vertical toolbar, a rule between the actions of a horizontal one.",
38
+ props: {
39
+ orientation: {
40
+ type: "enum",
41
+ values: ["horizontal", "vertical"],
42
+ default: "horizontal",
43
+ description: "The axis of the toolbar the separator is in; the rule runs across it. It follows its Toolbar when omitted, so pass it only to say otherwise."
44
+ }
45
+ },
46
+ composable_with: ["Toolbar"],
47
+ never_inside: ["ToolbarSeparator"],
48
+ example: "<ToolbarSeparator />"
49
+ }
50
+ };
51
+ var ToolbarCompositionRules = {
52
+ Toolbar: {
53
+ allowed_children: [
54
+ "Button",
55
+ "ButtonGroup",
56
+ "Badge",
57
+ "Toggle",
58
+ "CopyButton",
59
+ // Each puts one control in the bar and draws its overlay outside it.
60
+ "ConfirmDialog",
61
+ "DropdownMenu",
62
+ "Tooltip",
63
+ "ToolbarSeparator"
64
+ ]
65
+ }
66
+ };
67
+ export {
68
+ ToolbarCompositionRules,
69
+ ToolbarManifest
70
+ };
@@ -0,0 +1,12 @@
1
+ // src/Toolbar/index.ts
2
+ import {
3
+ Toolbar,
4
+ ToolbarSeparator
5
+ } from "./Toolbar.js";
6
+ import { ToolbarManifest, ToolbarCompositionRules } from "./Toolbar.manifest.js";
7
+ export {
8
+ Toolbar,
9
+ ToolbarCompositionRules,
10
+ ToolbarManifest,
11
+ ToolbarSeparator
12
+ };