@robert-stackflow/oneui 0.6.7 → 0.6.16

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 (114) hide show
  1. package/CHANGELOG.md +63 -0
  2. package/README.md +255 -188
  3. package/components/AccountItem.module.css +103 -103
  4. package/components/Alert.d.ts +2 -9
  5. package/components/Alert.js +2 -40
  6. package/components/AppShell.d.ts +7 -7
  7. package/components/AppShell.js +37 -33
  8. package/components/AppShell.module.css +223 -271
  9. package/components/AppearanceSettings.js +25 -32
  10. package/components/Badge.module.css +30 -30
  11. package/components/Banner.d.ts +17 -0
  12. package/components/Banner.js +99 -0
  13. package/components/Banner.module.css +143 -0
  14. package/components/BarChart.module.css +35 -34
  15. package/components/Breadcrumb.module.css +97 -97
  16. package/components/Button.module.css +120 -120
  17. package/components/Cascader.js +1 -0
  18. package/components/CharacterPicker.js +2 -0
  19. package/components/Checkbox.module.css +95 -95
  20. package/components/Combobox.js +1 -0
  21. package/components/Combobox.module.css +6 -1
  22. package/components/CommandPalette.js +2 -2
  23. package/components/ContributionCalendar.module.css +121 -121
  24. package/components/Control.module.css +86 -86
  25. package/components/DataTable.d.ts +3 -2
  26. package/components/DataTable.js +92 -66
  27. package/components/DataTable.module.css +3 -31
  28. package/components/DatePicker.js +1 -0
  29. package/components/DateRangePicker.js +1 -0
  30. package/components/Dialog.d.ts +3 -1
  31. package/components/Dialog.js +11 -4
  32. package/components/Dialog.module.css +139 -97
  33. package/components/DialogVariants.d.ts +2 -1
  34. package/components/DialogVariants.js +35 -7
  35. package/components/HierarchyPicker.module.css +185 -181
  36. package/components/IconPicker.js +2 -0
  37. package/components/Indicator.module.css +83 -83
  38. package/components/Layout.module.css +82 -82
  39. package/components/Markdown.d.ts +13 -0
  40. package/components/Markdown.js +164 -0
  41. package/components/Markdown.module.css +227 -0
  42. package/components/MenuItem.module.css +172 -172
  43. package/components/MultiSelect.js +1 -0
  44. package/components/MultiSelect.module.css +2 -0
  45. package/components/NavBar.d.ts +20 -0
  46. package/components/NavBar.js +197 -0
  47. package/components/NavBar.module.css +130 -0
  48. package/components/NavigationSurface.module.css +27 -0
  49. package/components/Picker.module.css +7 -0
  50. package/components/Popover.d.ts +6 -1
  51. package/components/Popover.js +39 -13
  52. package/components/Popover.module.css +8 -0
  53. package/components/Progress.module.css +33 -33
  54. package/components/RadioGroup.module.css +87 -87
  55. package/components/RangeSlider.module.css +141 -141
  56. package/components/ResizablePanel.module.css +101 -101
  57. package/components/ResourceCard.module.css +98 -98
  58. package/components/SelectSettingRow.d.ts +7 -0
  59. package/components/SelectSettingRow.js +58 -0
  60. package/components/SettingRow.d.ts +9 -3
  61. package/components/SettingRow.js +32 -8
  62. package/components/SettingRow.module.css +17 -0
  63. package/components/SettingsLayout.d.ts +15 -3
  64. package/components/SettingsLayout.js +46 -29
  65. package/components/SideBar.d.ts +9 -0
  66. package/components/SideBar.js +30 -0
  67. package/components/SidebarNavigation.d.ts +24 -3
  68. package/components/SidebarNavigation.js +274 -47
  69. package/components/SidebarNavigation.module.css +352 -130
  70. package/components/Slider.module.css +19 -19
  71. package/components/Steps.module.css +176 -176
  72. package/components/Switch.d.ts +3 -1
  73. package/components/Switch.js +5 -1
  74. package/components/Switch.module.css +59 -59
  75. package/components/SwitchSettingRow.d.ts +7 -0
  76. package/components/SwitchSettingRow.js +45 -0
  77. package/components/Tab.module.css +148 -148
  78. package/components/Table.d.ts +8 -1
  79. package/components/Table.js +34 -17
  80. package/components/Table.module.css +87 -48
  81. package/components/TableMarkup.d.ts +2 -1
  82. package/components/TableMarkup.js +18 -1
  83. package/components/TableOfContents.d.ts +22 -0
  84. package/components/TableOfContents.js +462 -0
  85. package/components/TableOfContents.module.css +252 -0
  86. package/components/TextAreaSettingRow.d.ts +9 -0
  87. package/components/TextAreaSettingRow.js +47 -0
  88. package/components/TextSettingRow.d.ts +9 -0
  89. package/components/TextSettingRow.js +45 -0
  90. package/components/ThemePicker.module.css +178 -178
  91. package/components/ThemeProvider.js +2 -0
  92. package/components/TimeColumns.module.css +47 -47
  93. package/components/Timeline.module.css +202 -202
  94. package/components/Toast.d.ts +8 -1
  95. package/components/Toast.js +49 -17
  96. package/components/Toast.module.css +25 -0
  97. package/components/ToastProvider.d.ts +4 -1
  98. package/components/ToastProvider.js +67 -12
  99. package/components/TreeSelect.js +1 -0
  100. package/components/TreeTable.d.ts +3 -3
  101. package/components/TreeTable.js +12 -2
  102. package/components/TreeTable.module.css +57 -53
  103. package/components/createToaster.d.ts +2 -1
  104. package/components/createToaster.js +28 -14
  105. package/components/index.d.ts +18 -1
  106. package/components/index.js +24 -0
  107. package/components/motion.d.ts +1 -0
  108. package/components/motion.js +18 -6
  109. package/components/settingRowControl.d.ts +7 -0
  110. package/components/settingRowControl.js +15 -0
  111. package/package.json +57 -3
  112. package/styles/base.css +206 -206
  113. package/styles/blue.css +270 -268
  114. package/styles/minimal.css +4 -25
@@ -0,0 +1,58 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { Select } from "./Select.js";
3
+ import { FormField } from "./FormField.js";
4
+ import { SettingRow } from "./SettingRow.js";
5
+ import {
6
+ useSettingRowControl
7
+ } from "./settingRowControl.js";
8
+ function SelectSettingRow({
9
+ title,
10
+ description,
11
+ divider,
12
+ titleBold,
13
+ align,
14
+ controlWidth = 220,
15
+ label = title,
16
+ id,
17
+ "aria-describedby": describedBy,
18
+ ...select
19
+ }) {
20
+ const control = useSettingRowControl(id, description, describedBy);
21
+ return /* @__PURE__ */ jsx(
22
+ SettingRow,
23
+ {
24
+ title,
25
+ description,
26
+ divider,
27
+ titleBold,
28
+ align,
29
+ controlWidth,
30
+ controlId: control.controlId,
31
+ descriptionId: control.descriptionId,
32
+ children: /* @__PURE__ */ jsx(
33
+ FormField,
34
+ {
35
+ id: control.controlId,
36
+ error: select.error,
37
+ hint: select.hint,
38
+ disabled: select.disabled,
39
+ readOnly: select.readOnly,
40
+ required: select.required,
41
+ "aria-describedby": control.describedBy,
42
+ children: /* @__PURE__ */ jsx(
43
+ Select,
44
+ {
45
+ ...select,
46
+ id: control.controlId,
47
+ label,
48
+ "aria-describedby": control.describedBy
49
+ }
50
+ )
51
+ }
52
+ )
53
+ }
54
+ );
55
+ }
56
+ export {
57
+ SelectSettingRow
58
+ };
@@ -1,7 +1,13 @@
1
- import type { ReactNode } from "react";
2
- export declare function SettingRow({ title, description, children, divider, }: {
1
+ import type { CSSProperties, ReactNode } from "react";
2
+ export type SettingRowProps = {
3
3
  title: string;
4
4
  description?: string;
5
5
  children: ReactNode;
6
6
  divider?: boolean;
7
- }): import("react").JSX.Element;
7
+ titleBold?: boolean;
8
+ align?: "center" | "start";
9
+ controlWidth?: CSSProperties["width"];
10
+ controlId?: string;
11
+ descriptionId?: string;
12
+ };
13
+ export declare function SettingRow({ title, description, children, divider, titleBold, align, controlWidth, controlId, descriptionId, }: SettingRowProps): import("react").JSX.Element;
@@ -4,15 +4,39 @@ function SettingRow({
4
4
  title,
5
5
  description,
6
6
  children,
7
- divider = true
7
+ divider = true,
8
+ titleBold = false,
9
+ align = "center",
10
+ controlWidth,
11
+ controlId,
12
+ descriptionId
8
13
  }) {
9
- return /* @__PURE__ */ jsxs("div", { className: s.settingRow, "data-divider": divider, children: [
10
- /* @__PURE__ */ jsxs("div", { className: s.settingCopy, children: [
11
- /* @__PURE__ */ jsx("h3", { children: title }),
12
- description && /* @__PURE__ */ jsx("p", { children: description })
13
- ] }),
14
- /* @__PURE__ */ jsx("div", { className: s.settingControl, children })
15
- ] });
14
+ return /* @__PURE__ */ jsxs(
15
+ "div",
16
+ {
17
+ className: s.settingRow,
18
+ "data-divider": divider,
19
+ "data-title-bold": titleBold,
20
+ "data-align": align,
21
+ "data-sized": controlWidth !== void 0,
22
+ children: [
23
+ /* @__PURE__ */ jsxs("div", { className: s.settingCopy, children: [
24
+ /* @__PURE__ */ jsx("h3", { children: controlId ? /* @__PURE__ */ jsx("label", { htmlFor: controlId, children: title }) : title }),
25
+ description && /* @__PURE__ */ jsx("p", { id: descriptionId, children: description })
26
+ ] }),
27
+ /* @__PURE__ */ jsx(
28
+ "div",
29
+ {
30
+ className: s.settingControl,
31
+ style: controlWidth === void 0 ? void 0 : {
32
+ "--setting-control-width": typeof controlWidth === "number" ? `${controlWidth}px` : controlWidth
33
+ },
34
+ children
35
+ }
36
+ )
37
+ ]
38
+ }
39
+ );
16
40
  }
17
41
  export {
18
42
  SettingRow
@@ -10,6 +10,9 @@
10
10
  border-top: var(--separator-width) var(--separator-style)
11
11
  var(--separator-color);
12
12
  }
13
+ .settingRow[data-align="start"] {
14
+ align-items: flex-start;
15
+ }
13
16
  .settingCopy {
14
17
  flex: 1;
15
18
  min-width: 0;
@@ -18,6 +21,14 @@
18
21
  font-size: 13px;
19
22
  font-weight: 400;
20
23
  }
24
+ .settingCopy label {
25
+ font: inherit;
26
+ color: inherit;
27
+ cursor: pointer;
28
+ }
29
+ .settingRow[data-title-bold="true"] .settingCopy h3 {
30
+ font-weight: 600;
31
+ }
21
32
  .settingCopy p {
22
33
  font-size: 11px;
23
34
  color: var(--muted);
@@ -25,6 +36,7 @@
25
36
  max-width: 440px;
26
37
  }
27
38
  .settingControl {
39
+ width: var(--setting-control-width, auto);
28
40
  display: flex;
29
41
  align-items: center;
30
42
  justify-content: flex-end;
@@ -41,4 +53,9 @@
41
53
  margin-left: auto;
42
54
  max-width: 100%;
43
55
  }
56
+ .settingRow[data-sized="true"] .settingCopy,
57
+ .settingRow[data-sized="true"] .settingControl {
58
+ flex-basis: 100%;
59
+ width: 100%;
60
+ }
44
61
  }
@@ -1,10 +1,22 @@
1
1
  import type { ReactNode } from "react";
2
- import { type IndicatorGroup } from "./Indicator";
3
- export declare function SettingsLayout({ value, onChange, children, groups, }: {
2
+ import { type NavigationGroup } from "./SideBar";
3
+ import type { IndicatorItem, IndicatorGroup } from "./Indicator";
4
+ export type SettingsNavigationItem = IndicatorItem & {
5
+ children?: readonly SettingsNavigationItem[];
6
+ trailing?: ReactNode;
7
+ };
8
+ export type SettingsNavigationGroup = Omit<IndicatorGroup, "items"> & {
9
+ items: readonly SettingsNavigationItem[];
10
+ collapsible?: boolean;
11
+ headerBold?: boolean;
12
+ trailing?: NavigationGroup["trailing"];
13
+ };
14
+ export declare function SettingsLayout({ value, onChange, children, groups, groupHeaderBold, }: {
4
15
  value: string;
5
16
  onChange(value: string): void;
6
17
  children: ReactNode;
7
- groups?: IndicatorGroup<string>[];
18
+ groups?: SettingsNavigationGroup[];
19
+ groupHeaderBold?: boolean;
8
20
  }): import("react").JSX.Element;
9
21
  export declare function SettingsCard({ children }: {
10
22
  children: ReactNode;
@@ -1,51 +1,68 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { Settings2, Palette } from "lucide-react";
3
- import { Indicator } from "./Indicator.js";
3
+ import { SideBar } from "./SideBar.js";
4
4
  import { Select } from "./Select.js";
5
5
  import s from "./SettingsLayout.module.css";
6
+ function navigationItems(items) {
7
+ return items.map((item) => ({
8
+ id: item.value,
9
+ path: item.value,
10
+ label: item.label,
11
+ icon: item.icon,
12
+ disabled: item.disabled,
13
+ trailing: item.trailing,
14
+ children: item.children ? navigationItems(item.children) : void 0
15
+ }));
16
+ }
6
17
  function SettingsLayout({
7
18
  value,
8
19
  onChange,
9
20
  children,
10
- groups
21
+ groups,
22
+ groupHeaderBold
11
23
  }) {
12
- return /* @__PURE__ */ jsxs("div", { className: s.layout, "data-grouped": groups ? true : void 0, children: [
24
+ const categories = groups ?? [
25
+ {
26
+ id: "settings",
27
+ items: [
28
+ { value: "general", label: "\u901A\u7528", icon: /* @__PURE__ */ jsx(Settings2, { size: 17 }) },
29
+ { value: "appearance", label: "\u5916\u89C2", icon: /* @__PURE__ */ jsx(Palette, { size: 17 }) }
30
+ ]
31
+ }
32
+ ];
33
+ const options = (items, prefix = "") => items.flatMap((item) => [
34
+ {
35
+ value: item.value,
36
+ label: prefix + item.label,
37
+ disabled: item.disabled,
38
+ trailing: item.trailing
39
+ },
40
+ ...options(item.children ?? [], prefix + item.label + " \xB7 ")
41
+ ]);
42
+ return /* @__PURE__ */ jsxs("div", { className: s.layout, "data-grouped": true, children: [
13
43
  /* @__PURE__ */ jsx(
14
- Indicator,
44
+ SideBar,
15
45
  {
46
+ variant: "indicator",
47
+ groupHeaderBold,
48
+ mode: "buttons",
16
49
  label: "\u8BBE\u7F6E\u5206\u7C7B",
17
- value,
18
- onChange,
19
- groups: groups ?? [
20
- {
21
- id: "settings",
22
- items: [
23
- {
24
- value: "general",
25
- label: "\u901A\u7528",
26
- icon: /* @__PURE__ */ jsx(Settings2, { size: 17 })
27
- },
28
- {
29
- value: "appearance",
30
- label: "\u5916\u89C2",
31
- icon: /* @__PURE__ */ jsx(Palette, { size: 17 })
32
- }
33
- ]
34
- }
35
- ]
50
+ active: value,
51
+ onNavigate: onChange,
52
+ groups: categories.map((group) => ({
53
+ ...group,
54
+ items: navigationItems(group.items)
55
+ }))
36
56
  }
37
57
  ),
38
- groups && /* @__PURE__ */ jsx("div", { className: s.mobileCategories, children: /* @__PURE__ */ jsx(
58
+ /* @__PURE__ */ jsx("div", { className: s.mobileCategories, children: /* @__PURE__ */ jsx(
39
59
  Select,
40
60
  {
41
61
  label: "\u8BBE\u7F6E\u5206\u7C7B",
42
62
  value,
43
63
  onChange,
44
- options: groups.flatMap(
45
- (group) => group.items.map((item) => ({
46
- value: item.value,
47
- label: (group.label ? group.label + " \xB7 " : "") + item.label
48
- }))
64
+ options: categories.flatMap(
65
+ (group) => options(group.items, group.label ? group.label + " \xB7 " : "")
49
66
  )
50
67
  }
51
68
  ) }),
@@ -0,0 +1,9 @@
1
+ import { type SidebarNavigationProps } from "./SidebarNavigation";
2
+ export type SideBarProps = SidebarNavigationProps & {
3
+ variant?: "sidebar" | "card" | "indicator";
4
+ label?: string;
5
+ className?: string;
6
+ };
7
+ /** Application navigation; the host owns branding, sizing and its footer. */
8
+ export declare function SideBar({ label, className, variant, ...props }: SideBarProps): import("react").JSX.Element;
9
+ export type { NavigationItem, NavigationGroup } from "./SidebarNavigation";
@@ -0,0 +1,30 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import {
3
+ SidebarNavigation
4
+ } from "./SidebarNavigation.js";
5
+ import s from "./NavigationSurface.module.css";
6
+ function SideBar({
7
+ label = "\u4E3B\u5BFC\u822A",
8
+ className = "",
9
+ variant = "sidebar",
10
+ ...props
11
+ }) {
12
+ return /* @__PURE__ */ jsx(
13
+ "nav",
14
+ {
15
+ "aria-label": label,
16
+ className: `${s.surface} ${variant === "card" ? s.card : ""} ${className}`,
17
+ "data-navigation": variant,
18
+ children: /* @__PURE__ */ jsx(
19
+ SidebarNavigation,
20
+ {
21
+ collapsibleGroups: variant !== "indicator",
22
+ ...props
23
+ }
24
+ )
25
+ }
26
+ );
27
+ }
28
+ export {
29
+ SideBar
30
+ };
@@ -4,7 +4,9 @@ export interface NavigationItem {
4
4
  id: string;
5
5
  path: string;
6
6
  label: string;
7
- icon: ReactNode;
7
+ icon?: ReactNode;
8
+ trailing?: ReactNode;
9
+ disabled?: boolean;
8
10
  children?: readonly NavigationItem[];
9
11
  /** Loading, empty or error UI for lazily loaded children. */
10
12
  content?: ReactNode;
@@ -15,8 +17,27 @@ export declare function NavigationButton({ label, icon, active, className, ...pr
15
17
  icon?: ReactNode;
16
18
  active?: boolean;
17
19
  }): import("react").JSX.Element;
18
- export interface SidebarNavigationProps {
20
+ export interface NavigationGroup {
21
+ id: string;
22
+ label?: string;
19
23
  items: readonly NavigationItem[];
24
+ collapsible?: boolean;
25
+ headerBold?: boolean;
26
+ trailing?: ReactNode | ((state: {
27
+ collapsed: boolean;
28
+ active: boolean;
29
+ }) => ReactNode);
30
+ }
31
+ export interface SidebarNavigationProps {
32
+ items?: readonly NavigationItem[];
33
+ groups?: readonly NavigationGroup[];
34
+ collapsibleGroups?: boolean;
35
+ groupHeaderBold?: boolean;
36
+ collapsedGroupIds?: readonly string[];
37
+ defaultCollapsedGroupIds?: readonly string[];
38
+ onCollapsedGroupsChange?(ids: string[]): void;
39
+ /** Buttons for in-page navigation; links preserve browser navigation semantics. */
40
+ mode?: "links" | "buttons";
20
41
  active: string;
21
42
  onNavigate(path: string): void;
22
43
  basePath?: string;
@@ -26,4 +47,4 @@ export interface SidebarNavigationProps {
26
47
  onExpandedChange?(ids: string[]): void;
27
48
  }
28
49
  /** Links and disclosure buttons are siblings, preserving native link behavior. */
29
- export declare function SidebarNavigation({ items, active, onNavigate, basePath, compact, expandedIds, defaultExpandedIds, onExpandedChange, }: SidebarNavigationProps): import("react").JSX.Element;
50
+ export declare function SidebarNavigation({ items, groups, collapsibleGroups, groupHeaderBold, collapsedGroupIds, defaultCollapsedGroupIds, onCollapsedGroupsChange, mode, active, onNavigate, basePath, compact, expandedIds, defaultExpandedIds, onExpandedChange, }: SidebarNavigationProps): import("react").JSX.Element;