@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
@@ -97,6 +97,7 @@ function DateRangePicker({
97
97
  /* @__PURE__ */ jsxs(
98
98
  Popover,
99
99
  {
100
+ maxHeight: Infinity,
100
101
  anchor: pop.anchor,
101
102
  open: pop.open,
102
103
  onClose: pop.close,
@@ -1,5 +1,5 @@
1
1
  import { type ReactNode, type RefObject } from "react";
2
- export declare function Dialog({ open: requestedOpen, onClose, title, children, footer, wide, size, role, descriptionId, busy, variant, returnFocus, }: {
2
+ export declare function Dialog({ open: requestedOpen, onClose, title, children, footer, wide, size, role, descriptionId, busy, variant, headerIcon, tone, returnFocus, }: {
3
3
  open: boolean;
4
4
  onClose(): void;
5
5
  title: string;
@@ -11,6 +11,8 @@ export declare function Dialog({ open: requestedOpen, onClose, title, children,
11
11
  descriptionId?: string;
12
12
  busy?: boolean;
13
13
  variant?: "default" | "message" | "confirm" | "form";
14
+ headerIcon?: ReactNode;
15
+ tone?: "neutral" | "info" | "success" | "warning" | "danger";
14
16
  /** Trigger to focus after closing, including surfaces opened asynchronously. */
15
17
  returnFocus?: RefObject<HTMLElement | null>;
16
18
  }): import("react").ReactPortal;
@@ -31,6 +31,8 @@ function Dialog({
31
31
  descriptionId,
32
32
  busy = false,
33
33
  variant = "default",
34
+ headerIcon,
35
+ tone = "neutral",
34
36
  returnFocus
35
37
  }) {
36
38
  const owner = useSurfacePortal(), open = requestedOpen && owner?.active !== false;
@@ -41,9 +43,9 @@ function Dialog({
41
43
  useModalScrollLock(open || closing);
42
44
  const opened = useRef(open);
43
45
  opened.current = open;
44
- const lastContent = useRef({ title, children, footer });
45
- if (open) lastContent.current = { title, children, footer };
46
- const content = !open && (closing || ref.current?.open) ? lastContent.current : { title, children, footer };
46
+ const lastContent = useRef({ title, children, footer, headerIcon, tone });
47
+ if (open) lastContent.current = { title, children, footer, headerIcon, tone };
48
+ const content = !open && (closing || ref.current?.open) ? lastContent.current : { title, children, footer, headerIcon, tone };
47
49
  useEffect(() => {
48
50
  if (requestedOpen && owner?.active === false) onClose();
49
51
  }, [requestedOpen, owner?.active, onClose]);
@@ -95,6 +97,8 @@ function Dialog({
95
97
  "aria-busy": busy || void 0,
96
98
  role,
97
99
  "data-variant": variant,
100
+ "data-tone": content.tone,
101
+ "data-header-icon": !!content.headerIcon,
98
102
  className: `${s.dialog} ${wide || size === "large" ? s.wide : ""} ${size === "small" ? s.small : ""} ${closing ? s.closing : ""}`,
99
103
  onCancel: (e) => {
100
104
  e.preventDefault();
@@ -110,7 +114,10 @@ function Dialog({
110
114
  },
111
115
  children: [
112
116
  /* @__PURE__ */ jsxs("header", { className: s.dialogHeader, children: [
113
- /* @__PURE__ */ jsx("h2", { id: titleId, children: content.title }),
117
+ /* @__PURE__ */ jsxs("div", { className: s.dialogHeading, children: [
118
+ content.headerIcon && /* @__PURE__ */ jsx("span", { className: s.dialogIcon, "aria-hidden": "true", children: content.headerIcon }),
119
+ /* @__PURE__ */ jsx("h2", { id: titleId, children: content.title })
120
+ ] }),
114
121
  /* @__PURE__ */ jsx(IconButton, { label: "\u5173\u95ED\u5F39\u7A97", onClick: onClose, disabled: busy, children: /* @__PURE__ */ jsx(X, {}) })
115
122
  ] }),
116
123
  /* @__PURE__ */ jsx("div", { className: s.dialogBody, children: content.children }),
@@ -1,97 +1,139 @@
1
- .dialog {
2
- width: min(var(--dialog-width), calc(100vw - 32px));
3
- max-height: calc(100dvh - var(--dialog-inset));
4
- padding: 0;
5
- color: var(--fg);
6
- background: var(--surface);
7
- border: 1px solid var(--line);
8
- border-radius: calc(var(--radius) + 3px);
9
- box-shadow: var(--shadow-dialog);
10
- overflow: auto;
11
- }
12
-
13
- .dialog::backdrop {
14
- background: var(--overlay);
15
- backdrop-filter: blur(3px);
16
- animation: fade-in var(--popup-enter);
17
- }
18
- .dialogHeader {
19
- border-bottom: var(--dialog-header-border);
20
- display: flex;
21
- align-items: center;
22
- justify-content: space-between;
23
- padding: var(--dialog-header-padding);
24
- }
25
- .dialogBody {
26
- padding: var(--dialog-body-padding);
27
- }
28
- .dialogBody > p {
29
- color: var(--muted);
30
- font-size: 12px;
31
- line-height: 1.8;
32
- }
33
- .dialogFooter {
34
- flex-wrap: wrap;
35
- display: flex;
36
- justify-content: flex-end;
37
- gap: 8px;
38
- padding: 14px 22px;
39
- border-top: var(--separator-width) var(--separator-style)
40
- var(--separator-color);
41
- background: var(--canvas);
42
- }
43
- .wide {
44
- width: min(var(--dialog-wide-width), calc(100vw - 32px));
45
- }
46
- .small {
47
- width: min(420px, calc(100vw - 32px));
48
- }
49
- .dialog[data-variant="message"] .dialogHeader {
50
- border: 0;
51
- padding-bottom: 12px;
52
- }
53
- .dialog[data-variant="message"] .dialogBody {
54
- padding-top: 0;
55
- padding-bottom: 24px;
56
- }
57
- .dialog[data-variant="message"] .dialogFooter {
58
- border: 0;
59
- background: transparent;
60
- padding-top: 0;
61
- padding-bottom: 18px;
62
- }
63
- .closing {
64
- pointer-events: none;
65
- }
66
- .dialog.closing::backdrop {
67
- background: transparent;
68
- backdrop-filter: blur(0);
69
- transition:
70
- background var(--popup-exit),
71
- backdrop-filter var(--popup-exit);
72
- }
73
-
74
- .dialogHeader h2 {
75
- font-size: var(--dialog-title-size);
76
- }
77
- @media (max-width: 600px) {
78
- .dialog {
79
- max-height: calc(100dvh - 24px);
80
- }
81
- .dialogBody {
82
- padding: 18px;
83
- }
84
- .dialogHeader,
85
- .dialogFooter {
86
- padding: 14px 18px;
87
- }
88
- }
89
-
90
- @keyframes fade-in {
91
- from {
92
- opacity: 0;
93
- }
94
- to {
95
- opacity: 1;
96
- }
97
- }
1
+ .dialog {
2
+ width: min(var(--dialog-width), calc(100vw - 32px));
3
+ max-height: calc(100dvh - var(--dialog-inset));
4
+ padding: 0;
5
+ color: var(--fg);
6
+ background: var(--surface);
7
+ border: 1px solid var(--line);
8
+ border-radius: calc(var(--radius) + 3px);
9
+ box-shadow: var(--shadow-dialog);
10
+ overflow: auto;
11
+ }
12
+
13
+ .dialog::backdrop {
14
+ background: var(--overlay);
15
+ backdrop-filter: blur(3px);
16
+ animation: fade-in var(--popup-enter);
17
+ }
18
+ .dialogHeader {
19
+ display: flex;
20
+ align-items: flex-start;
21
+ justify-content: space-between;
22
+ gap: 16px;
23
+ padding: 24px 24px 20px;
24
+ }
25
+ .dialogHeading {
26
+ display: flex;
27
+ align-items: center;
28
+ gap: 14px;
29
+ min-width: 0;
30
+ }
31
+ .dialogHeading h2 {
32
+ min-width: 0;
33
+ overflow-wrap: anywhere;
34
+ font-size: 18px;
35
+ font-weight: 600;
36
+ line-height: 1.5;
37
+ }
38
+ .dialogHeader > button {
39
+ flex-shrink: 0;
40
+ margin-top: -3px;
41
+ margin-right: -6px;
42
+ color: var(--muted);
43
+ }
44
+ .dialogIcon {
45
+ display: inline-flex;
46
+ align-items: center;
47
+ justify-content: center;
48
+ flex: 0 0 21px;
49
+ width: 21px;
50
+ height: 25px;
51
+ color: var(--dialog-tone, var(--accent-ink, var(--accent)));
52
+ }
53
+ .dialogIcon > svg {
54
+ width: 21px;
55
+ height: 21px;
56
+ stroke-width: 1.7;
57
+ }
58
+ .dialog[data-tone="info"] {
59
+ --dialog-tone: var(--accent-ink, var(--accent));
60
+ }
61
+ .dialog[data-tone="success"] {
62
+ --dialog-tone: var(--success);
63
+ }
64
+ .dialog[data-tone="warning"] {
65
+ --dialog-tone: var(--warning);
66
+ }
67
+ .dialog[data-tone="danger"] {
68
+ --dialog-tone: var(--danger);
69
+ }
70
+ .dialogBody {
71
+ padding: 0 24px 24px;
72
+ }
73
+ .dialogBody > p {
74
+ color: var(--muted);
75
+ font-size: 12px;
76
+ line-height: 1.8;
77
+ }
78
+ .dialogFooter {
79
+ flex-wrap: wrap;
80
+ display: flex;
81
+ justify-content: flex-end;
82
+ gap: 8px;
83
+ padding: 14px 24px;
84
+ border-top: var(--separator-width) var(--separator-style)
85
+ var(--separator-color);
86
+ background: var(--canvas);
87
+ }
88
+ .wide {
89
+ width: min(var(--dialog-wide-width), calc(100vw - 32px));
90
+ }
91
+ .small {
92
+ width: min(420px, calc(100vw - 32px));
93
+ }
94
+ .dialog:is([data-variant="message"], [data-variant="confirm"]) .dialogHeader {
95
+ padding: 22px 24px 12px;
96
+ }
97
+ .dialog:is([data-variant="message"], [data-variant="confirm"]) .dialogHeading {
98
+ gap: 10px;
99
+ }
100
+ .dialog:is([data-variant="message"], [data-variant="confirm"])
101
+ .dialogHeader
102
+ h2 {
103
+ font-size: 17px;
104
+ }
105
+ .dialog:is([data-variant="message"], [data-variant="confirm"]) .dialogBody {
106
+ padding: 0 24px 24px;
107
+ }
108
+ .closing {
109
+ pointer-events: none;
110
+ }
111
+ .dialog.closing::backdrop {
112
+ background: transparent;
113
+ backdrop-filter: blur(0);
114
+ transition:
115
+ background var(--popup-exit),
116
+ backdrop-filter var(--popup-exit);
117
+ }
118
+
119
+ @media (max-width: 600px) {
120
+ .dialog {
121
+ max-height: calc(100dvh - 24px);
122
+ }
123
+ .dialogBody {
124
+ padding: 0 20px 20px;
125
+ }
126
+ .dialogHeader,
127
+ .dialogFooter {
128
+ padding: 18px 20px;
129
+ }
130
+ }
131
+
132
+ @keyframes fade-in {
133
+ from {
134
+ opacity: 0;
135
+ }
136
+ to {
137
+ opacity: 1;
138
+ }
139
+ }
@@ -7,9 +7,10 @@ type ShellProps = {
7
7
  children: ReactNode;
8
8
  };
9
9
  type Result = void | boolean;
10
- export declare function MessageDialog({ open, onClose, title, children, tone, closeLabel, }: ShellProps & {
10
+ export declare function MessageDialog({ open, onClose, title, children, tone, closeLabel, onAction, }: ShellProps & {
11
11
  tone?: "info" | "success" | "warning" | "error";
12
12
  closeLabel?: string;
13
+ onAction?(): Result | Promise<Result>;
13
14
  }): import("react").JSX.Element;
14
15
  export declare function ConfirmDialog({ open, onClose, title, children, onConfirm, danger, confirmLabel, cancelLabel, }: ShellProps & {
15
16
  onConfirm(): Result | Promise<Result>;
@@ -8,7 +8,15 @@ import {
8
8
  import { Dialog } from "./Dialog.js";
9
9
  import { Button } from "./Button.js";
10
10
  import { Form } from "./Form.js";
11
- import { Alert } from "./Alert.js";
11
+ import { Banner } from "./Banner.js";
12
+ import {
13
+ Info,
14
+ CircleCheck,
15
+ TriangleAlert,
16
+ CircleX,
17
+ CircleHelp,
18
+ Trash2
19
+ } from "lucide-react";
12
20
  import s from "./DialogVariants.module.css";
13
21
  function useDialogAction(open, onClose) {
14
22
  const [busy, setBusy] = useState(false), [error, setError] = useState(""), revision = useRef(0), close = useRef(onClose);
@@ -44,10 +52,13 @@ function MessageDialog({
44
52
  title,
45
53
  children,
46
54
  tone = "info",
47
- closeLabel = "\u77E5\u9053\u4E86"
55
+ closeLabel = "\u77E5\u9053\u4E86",
56
+ onAction
48
57
  }) {
49
58
  const id = useId();
50
- return /* @__PURE__ */ jsx(
59
+ const action = useDialogAction(open, onClose);
60
+ const Icon = tone === "success" ? CircleCheck : tone === "warning" ? TriangleAlert : tone === "error" ? CircleX : Info;
61
+ return /* @__PURE__ */ jsxs(
51
62
  Dialog,
52
63
  {
53
64
  open,
@@ -55,10 +66,25 @@ function MessageDialog({
55
66
  title,
56
67
  size: "small",
57
68
  variant: "message",
69
+ tone: tone === "error" ? "danger" : tone,
70
+ headerIcon: /* @__PURE__ */ jsx(Icon, {}),
71
+ busy: action.busy,
58
72
  role: "alertdialog",
59
73
  descriptionId: id,
60
- footer: /* @__PURE__ */ jsx(Button, { variant: "primary", "data-dialog-initial-focus": true, onClick: onClose, children: closeLabel }),
61
- children: /* @__PURE__ */ jsx("div", { id, "data-tone": tone, className: s.description, children })
74
+ footer: /* @__PURE__ */ jsx(
75
+ Button,
76
+ {
77
+ variant: "primary",
78
+ "data-dialog-initial-focus": true,
79
+ loading: action.busy,
80
+ onClick: () => onAction ? void action.run(onAction) : onClose(),
81
+ children: closeLabel
82
+ }
83
+ ),
84
+ children: [
85
+ /* @__PURE__ */ jsx("div", { id, "data-tone": tone, className: s.description, children }),
86
+ action.error && /* @__PURE__ */ jsx("div", { className: s.feedback, children: /* @__PURE__ */ jsx(Banner, { tone: "danger", icon: false, children: action.error }) })
87
+ ]
62
88
  }
63
89
  );
64
90
  }
@@ -81,6 +107,8 @@ function ConfirmDialog({
81
107
  title,
82
108
  size: "small",
83
109
  variant: "confirm",
110
+ tone: danger ? "danger" : "info",
111
+ headerIcon: danger ? /* @__PURE__ */ jsx(Trash2, {}) : /* @__PURE__ */ jsx(CircleHelp, {}),
84
112
  role: "alertdialog",
85
113
  descriptionId: id,
86
114
  busy: action.busy,
@@ -107,7 +135,7 @@ function ConfirmDialog({
107
135
  ] }),
108
136
  children: [
109
137
  /* @__PURE__ */ jsx("div", { id, className: s.description, children }),
110
- action.error && /* @__PURE__ */ jsx("div", { className: s.feedback, children: /* @__PURE__ */ jsx(Alert, { tone: "danger", icon: false, children: action.error }) })
138
+ action.error && /* @__PURE__ */ jsx("div", { className: s.feedback, children: /* @__PURE__ */ jsx(Banner, { tone: "danger", icon: false, children: action.error }) })
111
139
  ]
112
140
  }
113
141
  );
@@ -147,7 +175,7 @@ function FormDialog({
147
175
  onSubmit: (values) => action.run(() => onSubmit(values)),
148
176
  children: [
149
177
  children,
150
- action.error && /* @__PURE__ */ jsx(Alert, { tone: "danger", icon: false, children: action.error })
178
+ action.error && /* @__PURE__ */ jsx(Banner, { tone: "danger", icon: false, children: action.error })
151
179
  ]
152
180
  }
153
181
  )