@robert-stackflow/oneui 0.6.19 → 0.6.21

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 (202) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +6 -0
  3. package/components/Accordion.d.ts +1 -1
  4. package/components/Accordion.js +1 -0
  5. package/components/AccountItem.js +1 -0
  6. package/components/ActionSheet.js +1 -0
  7. package/components/Alert.js +1 -0
  8. package/components/AppShell.js +1 -0
  9. package/components/AppearanceSettings.js +1 -0
  10. package/components/AuthLayout.js +1 -0
  11. package/components/Avatar.js +1 -0
  12. package/components/AvatarGroup.js +1 -0
  13. package/components/Badge.js +1 -0
  14. package/components/Banner.d.ts +3 -3
  15. package/components/Banner.js +12 -4
  16. package/components/BarChart.js +1 -0
  17. package/components/BlockedTab.js +1 -0
  18. package/components/Breadcrumb.js +1 -0
  19. package/components/Button.d.ts +4 -2
  20. package/components/Button.js +24 -0
  21. package/components/Calendar.js +19 -13
  22. package/components/Card.d.ts +5 -4
  23. package/components/Card.js +8 -4
  24. package/components/Card.module.css +10 -0
  25. package/components/Cascader.js +1 -0
  26. package/components/CatalogIcon.js +1 -0
  27. package/components/CharacterPicker.js +1 -0
  28. package/components/Checkbox.d.ts +5 -3
  29. package/components/Checkbox.js +17 -5
  30. package/components/ColorField.js +1 -0
  31. package/components/ColorPicker.js +1 -0
  32. package/components/Combobox.js +1 -0
  33. package/components/CommandPalette.js +1 -0
  34. package/components/ContextMenu.js +1 -0
  35. package/components/ContextMenuPanel.js +1 -0
  36. package/components/ContributionCalendar.js +1 -0
  37. package/components/ContributionCell.js +1 -0
  38. package/components/CopyButton.js +1 -0
  39. package/components/DataTable.js +1 -0
  40. package/components/DatePicker.js +8 -4
  41. package/components/DateRangePicker.js +1 -0
  42. package/components/Descriptions.js +1 -0
  43. package/components/Dialog.d.ts +9 -3
  44. package/components/Dialog.js +33 -11
  45. package/components/DialogVariants.js +1 -0
  46. package/components/DisclosureChevron.js +1 -0
  47. package/components/Divider.js +1 -0
  48. package/components/Drawer.d.ts +5 -2
  49. package/components/Drawer.js +20 -5
  50. package/components/EmojiPicker.js +1 -0
  51. package/components/EmptyState.js +1 -0
  52. package/components/FieldLabel.d.ts +2 -1
  53. package/components/FieldLabel.js +1 -0
  54. package/components/FieldMessages.d.ts +3 -2
  55. package/components/FieldMessages.js +1 -0
  56. package/components/FileDropOverlay.js +1 -0
  57. package/components/FileDropZone.js +1 -0
  58. package/components/FilePicker.d.ts +3 -2
  59. package/components/FilePicker.js +21 -5
  60. package/components/FileSelectionFeedback.js +1 -0
  61. package/components/FileTree.js +1 -0
  62. package/components/Form.js +1 -0
  63. package/components/FormErrorSummary.js +1 -0
  64. package/components/FormField.js +1 -0
  65. package/components/FormGroup.js +1 -0
  66. package/components/FormLayout.js +1 -0
  67. package/components/IconButton.js +1 -0
  68. package/components/IconPicker.js +1 -0
  69. package/components/Indicator.js +1 -0
  70. package/components/Input.js +1 -0
  71. package/components/Layout.js +1 -0
  72. package/components/Link.d.ts +8 -0
  73. package/components/Link.js +36 -0
  74. package/components/Link.module.css +18 -0
  75. package/components/LoadingOverlay.js +1 -0
  76. package/components/LoadingState.js +1 -0
  77. package/components/Markdown.d.ts +3 -1
  78. package/components/Markdown.js +3 -1
  79. package/components/Menu.js +1 -0
  80. package/components/MenuItem.d.ts +8 -3
  81. package/components/MenuItem.js +24 -1
  82. package/components/MenuItemContent.js +1 -0
  83. package/components/MultiSelect.js +1 -0
  84. package/components/NavBar.d.ts +2 -1
  85. package/components/NavBar.js +3 -1
  86. package/components/NumberInput.js +1 -0
  87. package/components/Page.d.ts +2 -1
  88. package/components/Page.js +4 -2
  89. package/components/Page.module.css +9 -0
  90. package/components/Pagination.d.ts +4 -1
  91. package/components/Pagination.js +28 -14
  92. package/components/PasskeyItem.js +1 -0
  93. package/components/PasswordField.js +1 -0
  94. package/components/PinInput.js +1 -0
  95. package/components/Placeholder.js +1 -0
  96. package/components/Popconfirm.js +1 -0
  97. package/components/Popover.d.ts +3 -2
  98. package/components/Popover.js +9 -2
  99. package/components/Progress.js +1 -0
  100. package/components/RadioGroup.js +1 -0
  101. package/components/RangeSlider.js +1 -0
  102. package/components/ResizablePanel.js +1 -0
  103. package/components/ResourceCard.js +1 -0
  104. package/components/SearchField.js +1 -0
  105. package/components/Section.js +1 -0
  106. package/components/Segmented.d.ts +1 -0
  107. package/components/Segmented.js +32 -20
  108. package/components/Select.d.ts +3 -1
  109. package/components/Select.js +12 -2
  110. package/components/SelectOptionContent.js +1 -0
  111. package/components/SelectSettingRow.js +1 -0
  112. package/components/SelectTrigger.js +1 -0
  113. package/components/SelectionTag.js +1 -0
  114. package/components/SessionItem.js +1 -0
  115. package/components/SettingRow.d.ts +3 -2
  116. package/components/SettingRow.js +9 -2
  117. package/components/SettingsLayout.js +1 -0
  118. package/components/ShortcutInput.js +1 -0
  119. package/components/SideBar.js +1 -0
  120. package/components/SidebarNavigation.js +1 -0
  121. package/components/Skeleton.js +1 -0
  122. package/components/SkeletonRows.js +1 -0
  123. package/components/SkinTonePicker.js +1 -0
  124. package/components/Slider.js +2 -1
  125. package/components/Spinner.js +1 -0
  126. package/components/SplitButton.js +1 -0
  127. package/components/Statistic.js +1 -0
  128. package/components/Steps.js +1 -0
  129. package/components/Switch.d.ts +5 -0
  130. package/components/Switch.js +26 -2
  131. package/components/Switch.module.css +101 -59
  132. package/components/SwitchSettingRow.js +1 -0
  133. package/components/SymbolPicker.js +1 -0
  134. package/components/TabList.js +1 -0
  135. package/components/Table.js +1 -0
  136. package/components/TableColumnFilter.js +1 -0
  137. package/components/TableColumnVisibility.js +1 -0
  138. package/components/TableMarkup.d.ts +2 -2
  139. package/components/TableMarkup.js +5 -2
  140. package/components/TableOfContents.js +1 -0
  141. package/components/Tabs.js +1 -0
  142. package/components/TagInput.js +1 -0
  143. package/components/TextAreaSettingRow.js +1 -0
  144. package/components/TextSettingRow.js +1 -0
  145. package/components/Textarea.js +1 -0
  146. package/components/ThemePicker.js +1 -0
  147. package/components/ThemeProvider.js +1 -0
  148. package/components/ThemeStylePicker.js +1 -0
  149. package/components/TimeColumns.js +8 -1
  150. package/components/Timeline.js +1 -0
  151. package/components/Toast.js +4 -1
  152. package/components/ToastProvider.js +1 -0
  153. package/components/Tooltip.js +7 -3
  154. package/components/TreeGuides.js +1 -0
  155. package/components/TreeSelect.js +1 -0
  156. package/components/TreeTable.js +1 -0
  157. package/components/UIProvider.d.ts +1 -0
  158. package/components/UIProvider.js +2 -0
  159. package/components/UnderlinedTab.js +1 -0
  160. package/components/Upload.js +1 -0
  161. package/components/UploadList.js +1 -0
  162. package/components/UploadListItem.js +1 -0
  163. package/components/UptimeChart.js +1 -0
  164. package/components/VirtualPickerList.js +1 -0
  165. package/components/appearance.js +1 -0
  166. package/components/calendarNow.js +1 -0
  167. package/components/characterCatalog.js +1 -0
  168. package/components/color.js +1 -0
  169. package/components/contribution.js +1 -0
  170. package/components/createToaster.js +1 -0
  171. package/components/dateConstraints.js +1 -0
  172. package/components/field.d.ts +7 -7
  173. package/components/field.js +3 -2
  174. package/components/fileSelection.js +1 -0
  175. package/components/hierarchy.js +1 -0
  176. package/components/iconCatalog.js +1 -0
  177. package/components/index.d.ts +2 -0
  178. package/components/index.js +5 -0
  179. package/components/menuFocus.js +1 -0
  180. package/components/menuPointer.js +1 -0
  181. package/components/menuTypes.js +1 -0
  182. package/components/motion.js +1 -0
  183. package/components/rangeMath.js +1 -0
  184. package/components/settingRowControl.js +1 -0
  185. package/components/surfacePortal.js +1 -0
  186. package/components/tooltipState.js +1 -0
  187. package/components/types.js +1 -0
  188. package/components/uploadTypes.js +1 -0
  189. package/components/useFormState.js +1 -0
  190. package/components/useHierarchy.js +1 -0
  191. package/components/useMenuLayers.js +1 -0
  192. package/components/useModalFocus.d.ts +1 -1
  193. package/components/useModalFocus.js +9 -3
  194. package/components/useModalScrollLock.js +1 -0
  195. package/components/usePopover.js +1 -0
  196. package/components/usePortalRoot.d.ts +2 -0
  197. package/components/usePortalRoot.js +12 -0
  198. package/components/useTabIndicator.js +1 -0
  199. package/components/useUIText.d.ts +5 -0
  200. package/components/useUIText.js +14 -0
  201. package/components/useUploadQueue.js +1 -0
  202. package/package.json +7 -1
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import { createContext, useContext, useId } from "react";
2
3
  const FieldContext = createContext(null);
3
4
  function fieldInputProps(field) {
@@ -41,8 +42,8 @@ function useFieldControl(options) {
41
42
  descriptionId: joinIds(
42
43
  inherited?.descriptionId,
43
44
  options["aria-describedby"],
44
- hint ? id + "-hint" : void 0,
45
- error ? id + "-error" : void 0
45
+ hint && (!inherited || id === inherited.id || options.hint !== void 0) ? id + "-hint" : void 0,
46
+ error && (!inherited || id === inherited.id || options.error !== void 0) ? id + "-error" : void 0
46
47
  ),
47
48
  invalid: error ? true : options["aria-invalid"] ?? inherited?.invalid ?? false,
48
49
  wrapped: !!inherited
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  function formatFileSize(bytes) {
2
3
  const unit = bytes >= 1024 * 1024 ? "MB" : bytes >= 1024 ? "KB" : "B", divisor = unit === "MB" ? 1024 * 1024 : unit === "KB" ? 1024 : 1;
3
4
  return `${Math.round(bytes / divisor * 100) / 100} ${unit}`;
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  function indexHierarchy(options, children, lazy = false) {
2
3
  const entries = /* @__PURE__ */ new Map();
3
4
  const walk = (nodes, path, disabled) => {
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import { useEffect, useState } from "react";
2
3
  let cache;
3
4
  let pending;
@@ -1,6 +1,7 @@
1
1
  export { Badge } from "./Badge";
2
2
  export { ActionSheet, type ActionSheetItem } from "./ActionSheet";
3
3
  export { Button } from "./Button";
4
+ export { Link, type LinkProps } from "./Link";
4
5
  export { Checkbox } from "./Checkbox";
5
6
  export { ColorField } from "./ColorField";
6
7
  export { DatePicker } from "./DatePicker";
@@ -27,6 +28,7 @@ export { SelectSettingRow, type SelectSettingRowProps, } from "./SelectSettingRo
27
28
  export { Skeleton } from "./Skeleton";
28
29
  export { SkeletonRows } from "./SkeletonRows";
29
30
  export { Switch } from "./Switch";
31
+ export { SwitchInput } from "./Switch";
30
32
  export { ToastProvider } from "./ToastProvider";
31
33
  export { Tooltip } from "./Tooltip";
32
34
  export type { SelectOption } from "./types";
@@ -1,6 +1,8 @@
1
+ "use client";
1
2
  import { Badge } from "./Badge.js";
2
3
  import { ActionSheet } from "./ActionSheet.js";
3
4
  import { Button } from "./Button.js";
5
+ import { Link } from "./Link.js";
4
6
  import { Checkbox } from "./Checkbox.js";
5
7
  import { ColorField } from "./ColorField.js";
6
8
  import { DatePicker } from "./DatePicker.js";
@@ -33,6 +35,7 @@ import {
33
35
  import { Skeleton } from "./Skeleton.js";
34
36
  import { SkeletonRows } from "./SkeletonRows.js";
35
37
  import { Switch } from "./Switch.js";
38
+ import { SwitchInput } from "./Switch.js";
36
39
  import { ToastProvider } from "./ToastProvider.js";
37
40
  import { Tooltip } from "./Tooltip.js";
38
41
  import { FileDropOverlay } from "./FileDropOverlay.js";
@@ -213,6 +216,7 @@ export {
213
216
  IconSurface,
214
217
  Indicator,
215
218
  Input,
219
+ Link,
216
220
  LoadingOverlay,
217
221
  LoadingState,
218
222
  Mark,
@@ -266,6 +270,7 @@ export {
266
270
  Steps,
267
271
  Surface,
268
272
  Switch,
273
+ SwitchInput,
269
274
  SwitchSettingRow,
270
275
  SymbolPicker,
271
276
  Table,
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  function moveMenuFocus(event, root) {
2
3
  if (!root || event.defaultPrevented || !["ArrowDown", "ArrowUp", "Home", "End"].includes(event.key))
3
4
  return false;
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  function movingTowardSubmenu(origin, point, rect) {
2
3
  if (!origin || point.time - origin.time > 400) return false;
3
4
  const edge = rect.left >= origin.x ? rect.left : rect.right <= origin.x ? rect.right : void 0;
@@ -0,0 +1 @@
1
+ "use client";
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  const runs = /* @__PURE__ */ new WeakMap();
2
3
  const reducedMotion = () => ["false", "off"].includes(document.documentElement.dataset.motion || "") || matchMedia("(prefers-reduced-motion: reduce)").matches;
3
4
  function motionDuration(token, fallback = 180) {
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  const finite = (n, fallback) => typeof n === "number" && Number.isFinite(n) ? n : fallback;
2
3
  const round = (n) => Number(n.toFixed(10));
3
4
  function rangeSettings(minimum = 0, maximum = 100, increment = 1, minDistance = 0) {
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import { useId } from "react";
2
3
  import { joinIds } from "./field.js";
3
4
  function useSettingRowControl(id, description, describedBy) {
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import {
2
3
  createContext,
3
4
  useCallback,
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  let active;
2
3
  let lastHidden = -Infinity, keyboard = false, users = 0;
3
4
  const dismiss = () => active?.();
@@ -0,0 +1 @@
1
+ "use client";
@@ -0,0 +1 @@
1
+ "use client";
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import { useCallback, useEffect, useId, useRef, useState } from "react";
2
3
  function useFormState({
3
4
  initialValues,
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import { useEffect, useMemo, useRef, useState } from "react";
2
3
  import {
3
4
  indexHierarchy
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import { useCallback, useLayoutEffect, useState } from "react";
2
3
  function useMenuLayers(desired) {
3
4
  const [layers, setLayers] = useState([]);
@@ -1,6 +1,6 @@
1
1
  import { type RefObject } from "react";
2
2
  /** Shared lifecycle for animated closure and conditionally mounted surfaces. */
3
- export declare function useModalFocus(ref: RefObject<HTMLDialogElement | null>, returnFocus?: RefObject<HTMLElement | null>): {
3
+ export declare function useModalFocus(ref: RefObject<HTMLDialogElement | null>, returnFocus?: RefObject<HTMLElement | null>, fallbackFocus?: RefObject<HTMLElement | null>): {
4
4
  rememberFocus: () => void;
5
5
  restoreFocus: () => void;
6
6
  };
@@ -1,25 +1,31 @@
1
+ "use client";
1
2
  import { useCallback, useEffect, useRef } from "react";
2
- function useModalFocus(ref, returnFocus) {
3
+ function useModalFocus(ref, returnFocus, fallbackFocus) {
4
+ const fallback = useRef(fallbackFocus);
5
+ fallback.current = fallbackFocus;
6
+ const lastNode = useRef(null);
3
7
  const previous = useRef(null);
4
8
  const requested = useRef(returnFocus);
5
9
  const mounted = useRef(false);
6
10
  requested.current = returnFocus;
7
11
  const rememberFocus = useCallback(() => {
12
+ lastNode.current = ref.current;
8
13
  const active = document.activeElement;
9
14
  if (active instanceof HTMLElement && active !== document.body && !ref.current?.contains(active))
10
15
  previous.current = active;
11
16
  }, [ref]);
12
17
  const restoreFocus = useCallback(() => {
13
- const target = requested.current?.current || previous.current;
18
+ const preferred = requested.current?.current || previous.current;
19
+ const target = preferred?.isConnected ? preferred : fallback.current?.current;
14
20
  const modal = [...document.querySelectorAll("dialog:modal")].at(-1);
15
21
  if (target?.isConnected && !target.matches(":disabled") && !target.closest("[inert]") && (!modal || modal.contains(target)))
16
22
  target.focus({ preventScroll: true });
17
23
  }, []);
18
24
  useEffect(() => {
19
25
  mounted.current = true;
20
- const node = ref.current;
21
26
  return () => {
22
27
  mounted.current = false;
28
+ const node = ref.current ?? lastNode.current;
23
29
  if (!node?.open) return;
24
30
  requestAnimationFrame(() => {
25
31
  if (mounted.current) return;
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import { useEffect } from "react";
2
3
  let locks = 0;
3
4
  let previous = "";
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import { useCallback, useEffect, useRef, useState } from "react";
2
3
  function usePopover(blocked = false) {
3
4
  const anchor = useRef(null), [open, setOpen] = useState(false);
@@ -0,0 +1,2 @@
1
+ /** Render portals only after hydration, including initially open surfaces. */
2
+ export declare function usePortalRoot(): HTMLElement | null;
@@ -0,0 +1,12 @@
1
+ "use client";
2
+ import { useLayoutEffect, useState } from "react";
3
+ function usePortalRoot() {
4
+ const [root, setRoot] = useState(null);
5
+ useLayoutEffect(() => {
6
+ setRoot(document.body);
7
+ }, []);
8
+ return root;
9
+ }
10
+ export {
11
+ usePortalRoot
12
+ };
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import { useLayoutEffect, useRef } from "react";
2
3
  function useTabIndicator(value, options, onChange, orientation) {
3
4
  const root = useRef(null);
@@ -0,0 +1,5 @@
1
+ /** Shared built-in copy follows the host application's language. */
2
+ export declare function useUIText(): {
3
+ english: boolean;
4
+ text: (simplified: string, en: string, tw?: string) => string;
5
+ };
@@ -0,0 +1,14 @@
1
+ "use client";
2
+ import { useUIConfig } from "./UIProvider.js";
3
+ function useUIText() {
4
+ const { locale } = useUIConfig();
5
+ const english = locale.toLowerCase().startsWith("en");
6
+ const traditional = /zh-(tw|hant|hk)/i.test(locale);
7
+ return {
8
+ english,
9
+ text: (simplified, en, tw = simplified) => english ? en : traditional ? tw : simplified
10
+ };
11
+ }
12
+ export {
13
+ useUIText
14
+ };
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import { useEffect, useRef, useState } from "react";
2
3
  function useUploadQueue({
3
4
  value,
package/package.json CHANGED
@@ -1,12 +1,18 @@
1
1
  {
2
2
  "name": "@robert-stackflow/oneui",
3
- "version": "0.6.19",
3
+ "version": "0.6.21",
4
4
  "description": "OneUI React components, application shell and portable visual themes",
5
5
  "type": "module",
6
6
  "sideEffects": [
7
7
  "**/*.css"
8
8
  ],
9
9
  "exports": {
10
+ "./Link": {
11
+ "types": "./components/Link.d.ts",
12
+ "import": "./components/Link.js",
13
+ "default": "./components/Link.js"
14
+ },
15
+ "./Link.module.css": "./components/Link.module.css",
10
16
  ".": {
11
17
  "types": "./components/index.d.ts",
12
18
  "import": "./components/index.js",