@robert-stackflow/oneui 0.6.8 → 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 (113) hide show
  1. package/CHANGELOG.md +58 -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/Table.d.ts +8 -1
  78. package/components/Table.js +34 -17
  79. package/components/Table.module.css +87 -48
  80. package/components/TableMarkup.d.ts +2 -1
  81. package/components/TableMarkup.js +18 -1
  82. package/components/TableOfContents.d.ts +22 -0
  83. package/components/TableOfContents.js +462 -0
  84. package/components/TableOfContents.module.css +252 -0
  85. package/components/TextAreaSettingRow.d.ts +9 -0
  86. package/components/TextAreaSettingRow.js +47 -0
  87. package/components/TextSettingRow.d.ts +9 -0
  88. package/components/TextSettingRow.js +45 -0
  89. package/components/ThemePicker.module.css +178 -178
  90. package/components/ThemeProvider.js +2 -0
  91. package/components/TimeColumns.module.css +47 -47
  92. package/components/Timeline.module.css +202 -202
  93. package/components/Toast.d.ts +8 -1
  94. package/components/Toast.js +49 -17
  95. package/components/Toast.module.css +25 -0
  96. package/components/ToastProvider.d.ts +4 -1
  97. package/components/ToastProvider.js +67 -12
  98. package/components/TreeSelect.js +1 -0
  99. package/components/TreeTable.d.ts +3 -3
  100. package/components/TreeTable.js +12 -2
  101. package/components/TreeTable.module.css +57 -53
  102. package/components/createToaster.d.ts +2 -1
  103. package/components/createToaster.js +28 -14
  104. package/components/index.d.ts +18 -1
  105. package/components/index.js +24 -0
  106. package/components/motion.d.ts +1 -0
  107. package/components/motion.js +18 -6
  108. package/components/settingRowControl.d.ts +7 -0
  109. package/components/settingRowControl.js +15 -0
  110. package/package.json +57 -3
  111. package/styles/base.css +206 -206
  112. package/styles/blue.css +270 -268
  113. package/styles/minimal.css +1 -0
@@ -1,103 +1,103 @@
1
- .item {
2
- display: grid;
3
- grid-template-columns: 40px minmax(0, 1fr) auto;
4
- gap: 16px;
5
- align-items: start;
6
- padding: 20px;
7
- border: 1px solid var(--line);
8
- border-radius: var(--card-radius);
9
- background: var(--surface);
10
- min-width: 0;
11
- }
12
- .item[data-highlighted] {
13
- background: color-mix(in srgb, var(--selected) 35%, var(--surface));
14
- }
15
- .icon {
16
- display: grid;
17
- place-items: center;
18
- width: 40px;
19
- height: 40px;
20
- border-radius: var(--radius);
21
- background: var(--selected);
22
- color: var(--accent);
23
- }
24
- .icon svg {
25
- width: 21px;
26
- height: 21px;
27
- }
28
- .body {
29
- min-width: 0;
30
- }
31
- .heading {
32
- display: flex;
33
- align-items: center;
34
- flex-wrap: wrap;
35
- gap: 10px;
36
- }
37
- .heading strong {
38
- font-size: 14px;
39
- font-weight: 600;
40
- color: var(--fg);
41
- overflow-wrap: anywhere;
42
- }
43
- .description {
44
- font-size: 12px;
45
- color: var(--muted);
46
- margin-top: 5px;
47
- overflow-wrap: anywhere;
48
- }
49
- .metadata {
50
- display: flex;
51
- flex-wrap: wrap;
52
- gap: 14px 28px;
53
- margin: 16px 0 0;
54
- }
55
- .metadata > div {
56
- min-width: 0;
57
- }
58
- .metadata dt {
59
- font-size: 11px;
60
- color: var(--muted);
61
- }
62
- .metadata dd {
63
- margin: 4px 0 0;
64
- font-size: 12px;
65
- color: var(--fg);
66
- font-variant-numeric: tabular-nums;
67
- overflow-wrap: anywhere;
68
- }
69
- .actions {
70
- display: flex;
71
- align-items: center;
72
- gap: 6px;
73
- justify-content: flex-end;
74
- }
75
- @media (max-width: 700px) {
76
- .item {
77
- grid-template-columns: 36px minmax(0, 1fr);
78
- gap: 12px;
79
- padding: 16px;
80
- }
81
- .icon {
82
- width: 36px;
83
- height: 36px;
84
- }
85
- .actions {
86
- grid-column: 2;
87
- }
88
- .metadata {
89
- display: flex;
90
- flex-direction: column;
91
- gap: 10px;
92
- }
93
- .metadata > div {
94
- display: flex;
95
- align-items: baseline;
96
- justify-content: space-between;
97
- gap: 12px;
98
- }
99
- .metadata dd {
100
- margin: 0;
101
- text-align: right;
102
- }
103
- }
1
+ .item {
2
+ display: grid;
3
+ grid-template-columns: 40px minmax(0, 1fr) auto;
4
+ gap: 16px;
5
+ align-items: start;
6
+ padding: 20px;
7
+ border: 1px solid var(--line);
8
+ border-radius: var(--card-radius);
9
+ background: var(--surface);
10
+ min-width: 0;
11
+ }
12
+ .item[data-highlighted] {
13
+ background: color-mix(in srgb, var(--selected) 35%, var(--surface));
14
+ }
15
+ .icon {
16
+ display: grid;
17
+ place-items: center;
18
+ width: 40px;
19
+ height: 40px;
20
+ border-radius: var(--radius);
21
+ background: var(--selected);
22
+ color: var(--fg);
23
+ }
24
+ .icon svg {
25
+ width: 21px;
26
+ height: 21px;
27
+ }
28
+ .body {
29
+ min-width: 0;
30
+ }
31
+ .heading {
32
+ display: flex;
33
+ align-items: center;
34
+ flex-wrap: wrap;
35
+ gap: 10px;
36
+ }
37
+ .heading strong {
38
+ font-size: 14px;
39
+ font-weight: 600;
40
+ color: var(--fg);
41
+ overflow-wrap: anywhere;
42
+ }
43
+ .description {
44
+ font-size: 12px;
45
+ color: var(--muted);
46
+ margin-top: 5px;
47
+ overflow-wrap: anywhere;
48
+ }
49
+ .metadata {
50
+ display: flex;
51
+ flex-wrap: wrap;
52
+ gap: 14px 28px;
53
+ margin: 16px 0 0;
54
+ }
55
+ .metadata > div {
56
+ min-width: 0;
57
+ }
58
+ .metadata dt {
59
+ font-size: 11px;
60
+ color: var(--muted);
61
+ }
62
+ .metadata dd {
63
+ margin: 4px 0 0;
64
+ font-size: 12px;
65
+ color: var(--fg);
66
+ font-variant-numeric: tabular-nums;
67
+ overflow-wrap: anywhere;
68
+ }
69
+ .actions {
70
+ display: flex;
71
+ align-items: center;
72
+ gap: 6px;
73
+ justify-content: flex-end;
74
+ }
75
+ @media (max-width: 700px) {
76
+ .item {
77
+ grid-template-columns: 36px minmax(0, 1fr);
78
+ gap: 12px;
79
+ padding: 16px;
80
+ }
81
+ .icon {
82
+ width: 36px;
83
+ height: 36px;
84
+ }
85
+ .actions {
86
+ grid-column: 2;
87
+ }
88
+ .metadata {
89
+ display: flex;
90
+ flex-direction: column;
91
+ gap: 10px;
92
+ }
93
+ .metadata > div {
94
+ display: flex;
95
+ align-items: baseline;
96
+ justify-content: space-between;
97
+ gap: 12px;
98
+ }
99
+ .metadata dd {
100
+ margin: 0;
101
+ text-align: right;
102
+ }
103
+ }
@@ -1,9 +1,2 @@
1
- import type { ReactNode } from "react";
2
- export declare function Alert({ tone, title, children, icon, action, onClose, }: {
3
- tone?: "info" | "success" | "warning" | "danger" | "neutral";
4
- title?: string;
5
- children?: ReactNode;
6
- icon?: boolean | ReactNode;
7
- action?: ReactNode;
8
- onClose?(): void;
9
- }): import("react").JSX.Element;
1
+ /** @deprecated Use Banner. Kept as an alias for existing published consumers. */
2
+ export { Banner as Alert } from "./Banner";
@@ -1,42 +1,4 @@
1
- import { jsx, jsxs } from "react/jsx-runtime";
2
- import { Info, CircleCheck, TriangleAlert, CircleX, X } from "lucide-react";
3
- import s from "./Alert.module.css";
4
- function Alert({
5
- tone = "info",
6
- title,
7
- children,
8
- icon = true,
9
- action,
10
- onClose
11
- }) {
12
- const Icon = tone === "success" ? CircleCheck : tone === "warning" ? TriangleAlert : tone === "danger" ? CircleX : Info, color = tone === "success" ? "var(--success)" : tone === "warning" ? "var(--warning)" : tone === "danger" ? "var(--danger)" : tone === "neutral" ? "var(--muted)" : "var(--accent)";
13
- return /* @__PURE__ */ jsxs(
14
- "div",
15
- {
16
- className: s.alert,
17
- style: { "--alert-color": color },
18
- role: tone === "danger" ? "alert" : "status",
19
- children: [
20
- icon && /* @__PURE__ */ jsx("span", { className: s.icon, children: icon === true ? /* @__PURE__ */ jsx(Icon, {}) : icon }),
21
- /* @__PURE__ */ jsxs("div", { className: s.copy, children: [
22
- title && /* @__PURE__ */ jsx("strong", { children: title }),
23
- children && /* @__PURE__ */ jsx("div", { children })
24
- ] }),
25
- action && /* @__PURE__ */ jsx("div", { className: s.action, children: action }),
26
- onClose && /* @__PURE__ */ jsx(
27
- "button",
28
- {
29
- type: "button",
30
- className: s.close,
31
- "aria-label": "\u5173\u95ED\u63D0\u793A",
32
- onClick: onClose,
33
- children: /* @__PURE__ */ jsx(X, {})
34
- }
35
- )
36
- ]
37
- }
38
- );
39
- }
1
+ import { Banner } from "./Banner.js";
40
2
  export {
41
- Alert
3
+ Banner as Alert
42
4
  };
@@ -1,5 +1,6 @@
1
1
  import { type ReactNode } from "react";
2
- import { type NavigationItem } from "./SidebarNavigation";
2
+ import type { NavigationItem, NavigationGroup } from "./SidebarNavigation";
3
+ export type { NavigationGroup } from "./SidebarNavigation";
3
4
  export type { NavigationItem } from "./SidebarNavigation";
4
5
  export declare function ShellHeader({ title, collapsed, onToggle, onMenu, actions, windowControls, draggable, }: {
5
6
  title: string;
@@ -10,14 +11,10 @@ export declare function ShellHeader({ title, collapsed, onToggle, onMenu, action
10
11
  windowControls?: ReactNode;
11
12
  draggable?: boolean;
12
13
  }): import("react").JSX.Element;
13
- export interface NavigationGroup {
14
- id: string;
15
- label?: string;
16
- items: readonly NavigationItem[];
17
- }
18
14
  export interface AppShellProps {
19
15
  navigation: readonly NavigationItem[];
20
16
  navigationGroups?: readonly NavigationGroup[];
17
+ groupHeaderBold?: boolean;
21
18
  settingsItem?: NavigationItem;
22
19
  active: string;
23
20
  title: string;
@@ -38,5 +35,8 @@ export interface AppShellProps {
38
35
  expandedIds?: readonly string[];
39
36
  defaultExpandedIds?: readonly string[];
40
37
  onExpandedChange?(ids: string[]): void;
38
+ collapsedGroupIds?: readonly string[];
39
+ defaultCollapsedGroupIds?: readonly string[];
40
+ onCollapsedGroupsChange?(ids: string[]): void;
41
41
  }
42
- export declare function AppShell({ navigation, navigationGroups, settingsItem, active, title, collapsed, onCollapsedChange, onNavigate, children, headerActions, sidebarFooter, windowControls, draggable, brandName, brandIcon, brand, homePath, basePath, showHeader, expandedIds, defaultExpandedIds, onExpandedChange, }: AppShellProps): import("react").JSX.Element;
42
+ export declare function AppShell({ navigation, navigationGroups, groupHeaderBold, settingsItem, active, title, collapsed, onCollapsedChange, onNavigate, children, headerActions, sidebarFooter, windowControls, draggable, brandName, brandIcon, brand, homePath, basePath, showHeader, expandedIds, defaultExpandedIds, onExpandedChange, collapsedGroupIds, defaultCollapsedGroupIds, onCollapsedGroupsChange, }: AppShellProps): import("react").JSX.Element;
@@ -7,7 +7,7 @@ import {
7
7
  import { Layers2, Menu, PanelLeftClose, PanelLeftOpen } from "lucide-react";
8
8
  import { Drawer } from "./Drawer.js";
9
9
  import { IconButton } from "./IconButton.js";
10
- import { SidebarNavigation } from "./SidebarNavigation.js";
10
+ import { SideBar } from "./SideBar.js";
11
11
  import s from "./AppShell.module.css";
12
12
  function ShellHeader({
13
13
  title,
@@ -59,6 +59,7 @@ function ShellHeader({
59
59
  function AppShell({
60
60
  navigation,
61
61
  navigationGroups,
62
+ groupHeaderBold,
62
63
  settingsItem,
63
64
  active,
64
65
  title,
@@ -78,7 +79,10 @@ function AppShell({
78
79
  showHeader = true,
79
80
  expandedIds,
80
81
  defaultExpandedIds = [],
81
- onExpandedChange
82
+ onExpandedChange,
83
+ collapsedGroupIds,
84
+ defaultCollapsedGroupIds = [],
85
+ onCollapsedGroupsChange
82
86
  }) {
83
87
  const [mobile, setMobile] = useState(false);
84
88
  const [internalExpanded, setInternalExpanded] = useState(defaultExpandedIds);
@@ -87,6 +91,14 @@ function AppShell({
87
91
  if (expandedIds === void 0) setInternalExpanded(ids);
88
92
  onExpandedChange?.(ids);
89
93
  };
94
+ const [internalGroups, setInternalGroups] = useState(
95
+ defaultCollapsedGroupIds
96
+ );
97
+ const collapsedGroups = collapsedGroupIds ?? internalGroups;
98
+ const collapseGroups = (ids) => {
99
+ if (collapsedGroupIds === void 0) setInternalGroups(ids);
100
+ onCollapsedGroupsChange?.(ids);
101
+ };
90
102
  const scroll = useRef(null);
91
103
  const base = basePath.replace(/^\/+|\/+$/g, ""), href = (path) => (base ? "/" + base : "") + (path.startsWith("/") ? path : "/" + path);
92
104
  const navigate = (event, path) => {
@@ -100,29 +112,20 @@ function AppShell({
100
112
  setMobile(false);
101
113
  scroll.current?.scrollTo({ top: 0 });
102
114
  }, [active]);
103
- const item = (n) => /* @__PURE__ */ jsxs(
104
- "a",
105
- {
106
- href: href(n.path),
107
- "aria-current": active === n.id ? "page" : void 0,
108
- title: collapsed ? n.label : void 0,
109
- onClick: (event) => navigate(event, n.path),
110
- children: [
111
- n.icon,
112
- /* @__PURE__ */ jsx("span", { children: n.label })
113
- ]
114
- },
115
- n.id
116
- );
117
- const tree = (items, compact) => /* @__PURE__ */ jsx(
118
- SidebarNavigation,
115
+ const tree = (compact) => /* @__PURE__ */ jsx(
116
+ SideBar,
119
117
  {
120
- items,
118
+ className: s.navigation,
119
+ items: navigation,
120
+ groups: navigationGroups,
121
+ groupHeaderBold,
121
122
  active,
122
123
  basePath,
123
124
  compact,
124
125
  expandedIds: expanded,
125
126
  onExpandedChange: expand,
127
+ collapsedGroupIds: collapsedGroups,
128
+ onCollapsedGroupsChange: collapseGroups,
126
129
  onNavigate: (path) => {
127
130
  onNavigate(path);
128
131
  setMobile(false);
@@ -143,21 +146,22 @@ function AppShell({
143
146
  ] })
144
147
  }
145
148
  ),
146
- /* @__PURE__ */ jsx("nav", { "aria-label": "\u4E3B\u5BFC\u822A", className: s.navigation, children: navigationGroups ? navigationGroups.map((group) => /* @__PURE__ */ jsxs(
147
- "div",
148
- {
149
- className: s.navigationGroup,
150
- role: "group",
151
- "aria-label": group.label,
152
- children: [
153
- group.label && /* @__PURE__ */ jsx("div", { className: s.groupLabel, children: group.label }),
154
- tree(group.items, compact)
155
- ]
156
- },
157
- group.id
158
- )) : tree(navigation, compact) }),
149
+ tree(compact),
159
150
  (settingsItem || sidebarFooter) && /* @__PURE__ */ jsxs("div", { className: s.bottom, children: [
160
- settingsItem && /* @__PURE__ */ jsx("nav", { "aria-label": "\u8BBE\u7F6E", className: s.navigation, children: item(settingsItem) }),
151
+ settingsItem && /* @__PURE__ */ jsx(
152
+ SideBar,
153
+ {
154
+ label: "\u8BBE\u7F6E",
155
+ items: [settingsItem],
156
+ active,
157
+ compact,
158
+ basePath,
159
+ onNavigate: (path) => {
160
+ onNavigate(path);
161
+ setMobile(false);
162
+ }
163
+ }
164
+ ),
161
165
  sidebarFooter
162
166
  ] })
163
167
  ] });