@robert-stackflow/oneui 0.1.0 → 0.3.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 (94) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/README.md +58 -2
  3. package/components/AppShell.d.ts +11 -4
  4. package/components/AppShell.js +79 -54
  5. package/components/AppShell.module.css +16 -4
  6. package/components/AppearanceSettings.js +1 -1
  7. package/components/Button.d.ts +9 -2
  8. package/components/Button.js +30 -7
  9. package/components/Button.module.css +16 -7
  10. package/components/Calendar.d.ts +2 -1
  11. package/components/Calendar.js +4 -3
  12. package/components/Card.d.ts +2 -1
  13. package/components/Card.js +13 -3
  14. package/components/Card.module.css +19 -0
  15. package/components/Checkbox.module.css +3 -3
  16. package/components/Combobox.d.ts +4 -2
  17. package/components/Combobox.js +162 -76
  18. package/components/Combobox.module.css +5 -7
  19. package/components/Control.module.css +18 -5
  20. package/components/DatePicker.d.ts +3 -0
  21. package/components/DatePicker.js +41 -21
  22. package/components/DatePicker.module.css +3 -0
  23. package/components/Dialog.d.ts +6 -1
  24. package/components/Dialog.js +19 -6
  25. package/components/Dialog.module.css +17 -0
  26. package/components/DialogVariants.d.ts +27 -0
  27. package/components/DialogVariants.js +161 -0
  28. package/components/DialogVariants.module.css +29 -0
  29. package/components/HierarchyPicker.module.css +35 -0
  30. package/components/IconButton.module.css +5 -2
  31. package/components/IconPicker.d.ts +14 -4
  32. package/components/IconPicker.js +67 -25
  33. package/components/Indicator.module.css +1 -1
  34. package/components/Input.d.ts +2 -1
  35. package/components/Input.js +12 -4
  36. package/components/Input.module.css +18 -1
  37. package/components/LoadingState.d.ts +3 -1
  38. package/components/LoadingState.js +26 -15
  39. package/components/LoadingState.module.css +3 -0
  40. package/components/MenuItem.d.ts +2 -1
  41. package/components/MenuItem.js +2 -0
  42. package/components/MenuItem.module.css +9 -0
  43. package/components/MultiSelect.d.ts +2 -1
  44. package/components/MultiSelect.js +66 -2
  45. package/components/MultiSelect.module.css +38 -0
  46. package/components/NumberInput.js +1 -0
  47. package/components/OptionList.module.css +12 -0
  48. package/components/PasswordField.js +1 -0
  49. package/components/PinInput.js +1 -0
  50. package/components/Popover.d.ts +4 -1
  51. package/components/Popover.js +11 -5
  52. package/components/Popover.module.css +3 -0
  53. package/components/RadioGroup.module.css +2 -2
  54. package/components/SearchField.js +1 -0
  55. package/components/Select.js +1 -0
  56. package/components/Select.module.css +3 -0
  57. package/components/SelectionTag.d.ts +8 -0
  58. package/components/SelectionTag.js +39 -0
  59. package/components/SettingsLayout.d.ts +3 -1
  60. package/components/SettingsLayout.js +19 -3
  61. package/components/SettingsLayout.module.css +20 -0
  62. package/components/Switch.module.css +8 -5
  63. package/components/Table.d.ts +6 -2
  64. package/components/Table.js +14 -4
  65. package/components/TagInput.js +11 -23
  66. package/components/TagInput.module.css +1 -1
  67. package/components/ThemeProvider.js +17 -3
  68. package/components/ToastProvider.d.ts +4 -4
  69. package/components/ToastProvider.js +19 -22
  70. package/components/TreeGuides.d.ts +9 -0
  71. package/components/TreeGuides.js +39 -0
  72. package/components/TreeGuides.module.css +45 -0
  73. package/components/TreeSelect.d.ts +3 -0
  74. package/components/TreeSelect.js +49 -21
  75. package/components/TreeTable.d.ts +15 -0
  76. package/components/TreeTable.js +151 -0
  77. package/components/TreeTable.module.css +53 -0
  78. package/components/VirtualPickerList.d.ts +2 -0
  79. package/components/VirtualPickerList.js +1 -1
  80. package/components/VirtualPickerList.module.css +4 -0
  81. package/components/appearance.d.ts +1 -0
  82. package/components/appearance.js +15 -6
  83. package/components/calendarNow.d.ts +5 -0
  84. package/components/calendarNow.js +27 -0
  85. package/components/createToaster.d.ts +12 -0
  86. package/components/createToaster.js +40 -0
  87. package/components/hierarchy.d.ts +1 -0
  88. package/components/index.d.ts +6 -3
  89. package/components/index.js +13 -1
  90. package/components/usePopover.d.ts +2 -2
  91. package/package.json +36 -4
  92. package/styles/base.css +20 -3
  93. package/styles/blue.css +49 -35
  94. package/styles/minimal.css +2 -1
@@ -0,0 +1,27 @@
1
+ import { type ReactNode } from "react";
2
+ import type { FormController } from "./useFormState";
3
+ type ShellProps = {
4
+ open: boolean;
5
+ onClose(): void;
6
+ title: string;
7
+ children: ReactNode;
8
+ };
9
+ type Result = void | boolean;
10
+ export declare function MessageDialog({ open, onClose, title, children, tone, closeLabel, }: ShellProps & {
11
+ tone?: "info" | "success" | "warning" | "error";
12
+ closeLabel?: string;
13
+ }): import("react").JSX.Element;
14
+ export declare function ConfirmDialog({ open, onClose, title, children, onConfirm, danger, confirmLabel, cancelLabel, }: ShellProps & {
15
+ onConfirm(): Result | Promise<Result>;
16
+ danger?: boolean;
17
+ confirmLabel?: string;
18
+ cancelLabel?: string;
19
+ }): import("react").JSX.Element;
20
+ export declare function FormDialog<T extends Record<string, unknown>>({ open, onClose, title, children, onSubmit, controller, submitLabel, cancelLabel, wide, }: ShellProps & {
21
+ controller: FormController<T>;
22
+ onSubmit(values: T): Result | Promise<Result>;
23
+ submitLabel?: string;
24
+ cancelLabel?: string;
25
+ wide?: boolean;
26
+ }): import("react").JSX.Element;
27
+ export {};
@@ -0,0 +1,161 @@
1
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
+ import {
3
+ useId,
4
+ useLayoutEffect,
5
+ useRef,
6
+ useState
7
+ } from "react";
8
+ import { Dialog } from "./Dialog.js";
9
+ import { Button } from "./Button.js";
10
+ import { Form } from "./Form.js";
11
+ import { Alert } from "./Alert.js";
12
+ import s from "./DialogVariants.module.css";
13
+ function useDialogAction(open, onClose) {
14
+ const [busy, setBusy] = useState(false), [error, setError] = useState(""), revision = useRef(0), close = useRef(onClose);
15
+ close.current = onClose;
16
+ useLayoutEffect(() => {
17
+ revision.current++;
18
+ setBusy(false);
19
+ setError("");
20
+ return () => {
21
+ revision.current++;
22
+ };
23
+ }, [open]);
24
+ const run = async (action) => {
25
+ if (busy) return;
26
+ const id = ++revision.current;
27
+ setBusy(true);
28
+ setError("");
29
+ try {
30
+ const result = await action();
31
+ if (id === revision.current && result !== false) close.current();
32
+ } catch (e) {
33
+ if (id === revision.current)
34
+ setError(e instanceof Error ? e.message : "\u64CD\u4F5C\u672A\u5B8C\u6210\uFF0C\u8BF7\u91CD\u8BD5");
35
+ } finally {
36
+ if (id === revision.current) setBusy(false);
37
+ }
38
+ };
39
+ return { busy, error, run };
40
+ }
41
+ function MessageDialog({
42
+ open,
43
+ onClose,
44
+ title,
45
+ children,
46
+ tone = "info",
47
+ closeLabel = "\u77E5\u9053\u4E86"
48
+ }) {
49
+ const id = useId();
50
+ return /* @__PURE__ */ jsx(
51
+ Dialog,
52
+ {
53
+ open,
54
+ onClose,
55
+ title,
56
+ size: "small",
57
+ variant: "message",
58
+ role: "alertdialog",
59
+ 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 })
62
+ }
63
+ );
64
+ }
65
+ function ConfirmDialog({
66
+ open,
67
+ onClose,
68
+ title,
69
+ children,
70
+ onConfirm,
71
+ danger = false,
72
+ confirmLabel = "\u786E\u8BA4",
73
+ cancelLabel = "\u53D6\u6D88"
74
+ }) {
75
+ const action = useDialogAction(open, onClose), id = useId();
76
+ return /* @__PURE__ */ jsxs(
77
+ Dialog,
78
+ {
79
+ open,
80
+ onClose,
81
+ title,
82
+ size: "small",
83
+ variant: "confirm",
84
+ role: "alertdialog",
85
+ descriptionId: id,
86
+ busy: action.busy,
87
+ footer: /* @__PURE__ */ jsxs(Fragment, { children: [
88
+ /* @__PURE__ */ jsx(
89
+ Button,
90
+ {
91
+ "data-dialog-initial-focus": true,
92
+ disabled: action.busy,
93
+ onClick: onClose,
94
+ children: cancelLabel
95
+ }
96
+ ),
97
+ /* @__PURE__ */ jsx(
98
+ Button,
99
+ {
100
+ variant: danger ? "danger" : "primary",
101
+ className: danger ? s.destructive : void 0,
102
+ loading: action.busy,
103
+ onClick: () => void action.run(onConfirm),
104
+ children: confirmLabel
105
+ }
106
+ )
107
+ ] }),
108
+ children: [
109
+ /* @__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 }) })
111
+ ]
112
+ }
113
+ );
114
+ }
115
+ function FormDialog({
116
+ open,
117
+ onClose,
118
+ title,
119
+ children,
120
+ onSubmit,
121
+ controller,
122
+ submitLabel = "\u4FDD\u5B58",
123
+ cancelLabel = "\u53D6\u6D88",
124
+ wide = false
125
+ }) {
126
+ const action = useDialogAction(open, onClose), id = useId(), busy = action.busy || controller.isSubmitting;
127
+ return /* @__PURE__ */ jsx(
128
+ Dialog,
129
+ {
130
+ open,
131
+ onClose,
132
+ title,
133
+ variant: "form",
134
+ wide,
135
+ busy,
136
+ footer: /* @__PURE__ */ jsxs(Fragment, { children: [
137
+ /* @__PURE__ */ jsx(Button, { disabled: busy, onClick: onClose, children: cancelLabel }),
138
+ /* @__PURE__ */ jsx(Button, { type: "submit", form: id, variant: "primary", loading: busy, children: submitLabel })
139
+ ] }),
140
+ children: /* @__PURE__ */ jsxs(
141
+ Form,
142
+ {
143
+ id,
144
+ "aria-label": title,
145
+ className: s.fields,
146
+ controller,
147
+ onSubmit: (values) => action.run(() => onSubmit(values)),
148
+ children: [
149
+ children,
150
+ action.error && /* @__PURE__ */ jsx(Alert, { tone: "danger", icon: false, children: action.error })
151
+ ]
152
+ }
153
+ )
154
+ }
155
+ );
156
+ }
157
+ export {
158
+ ConfirmDialog,
159
+ FormDialog,
160
+ MessageDialog
161
+ };
@@ -0,0 +1,29 @@
1
+ .description {
2
+ padding-top: 2px;
3
+ min-width: 0;
4
+ color: var(--muted);
5
+ font-size: 13px;
6
+ line-height: 1.85;
7
+ overflow-wrap: anywhere;
8
+ }
9
+ .feedback {
10
+ margin-top: 16px;
11
+ }
12
+ .destructive {
13
+ background: var(--danger);
14
+ border-color: var(--danger);
15
+ color: var(--on-danger, #fff);
16
+ }
17
+ .destructive:hover:not(:disabled) {
18
+ background: color-mix(in srgb, var(--danger) 86%, var(--surface));
19
+ border-color: transparent;
20
+ }
21
+ .fields {
22
+ display: flex;
23
+ flex-direction: column;
24
+ gap: 20px;
25
+ border: 0;
26
+ padding: 0;
27
+ margin: 0;
28
+ min-width: 0;
29
+ }
@@ -7,6 +7,7 @@
7
7
  margin: 3px 3px 8px;
8
8
  }
9
9
  .tree {
10
+ composes: stack from "./OptionList.module.css";
10
11
  max-height: 292px;
11
12
  overflow: auto;
12
13
  padding: 2px;
@@ -90,6 +91,11 @@
90
91
  font-size: 11px;
91
92
  color: var(--muted);
92
93
  }
94
+ .footerActions {
95
+ display: flex;
96
+ align-items: center;
97
+ gap: 8px;
98
+ }
93
99
  .columns {
94
100
  display: flex;
95
101
  min-height: 240px;
@@ -98,6 +104,7 @@
98
104
  overscroll-behavior: contain;
99
105
  }
100
106
  .column {
107
+ composes: stack from "./OptionList.module.css";
101
108
  flex: 1 0 170px;
102
109
  min-width: 170px;
103
110
  max-height: 292px;
@@ -110,8 +117,36 @@
110
117
  var(--separator-color);
111
118
  }
112
119
  .treeRow {
120
+ position: relative;
113
121
  animation: rowIn 140ms var(--ease);
114
122
  }
123
+ .categoryRow {
124
+ --tree-elbow-gap: 6px;
125
+ --tree-stem-inset: 12px;
126
+ min-height: 42px;
127
+ }
128
+ .categoryRow[data-branch="true"] [data-menu-label] {
129
+ font-weight: 600;
130
+ }
131
+ .categoryRow [data-menu-icon] {
132
+ width: 26px;
133
+ height: 26px;
134
+ flex-basis: 26px;
135
+ border-radius: 7px;
136
+ background: var(--field);
137
+ border: 1px solid var(--line);
138
+ color: var(--muted);
139
+ }
140
+ .categoryRow[data-branch="true"] [data-menu-icon] {
141
+ background: var(--selected);
142
+ color: var(--accent);
143
+ }
144
+ .categoryRow [data-menu-trailing] > span {
145
+ border-radius: 999px;
146
+ }
147
+ .categoryRow .mixed {
148
+ border-radius: 999px;
149
+ }
115
150
  .treeRow[aria-disabled="true"] .expander {
116
151
  pointer-events: none;
117
152
  }
@@ -26,8 +26,11 @@
26
26
  min-width: 30px;
27
27
  }
28
28
  .iconButton[data-variant="primary"] {
29
- background: var(--accent);
30
- color: var(--on-accent);
29
+ background: var(--accent-fill, var(--accent));
30
+ color: var(--on-accent-fill, var(--on-accent));
31
+ }
32
+ .iconButton[data-variant="primary"]:hover:not(:disabled) {
33
+ background: var(--accent-fill-hover, var(--accent));
31
34
  }
32
35
  .iconButton[data-variant="secondary"] {
33
36
  border: 1px solid var(--border);
@@ -1,6 +1,16 @@
1
- export declare function IconPicker({ value, onChange, label, disabled, }: {
1
+ import { type ReactNode } from "react";
2
+ import { type FieldOptions } from "./field";
3
+ export type IconPickerOption = {
4
+ value: string;
5
+ label: string;
6
+ icon: ReactNode;
7
+ keywords?: string[];
8
+ category?: string;
9
+ };
10
+ export type IconPickerProps = FieldOptions & {
2
11
  value: string;
3
12
  onChange(value: string): void;
4
- label?: string;
5
- disabled?: boolean;
6
- }): import("react").JSX.Element;
13
+ options?: IconPickerOption[];
14
+ valuePrefix?: string;
15
+ };
16
+ export declare function IconPicker({ value, onChange, label, options, valuePrefix, ...props }: IconPickerProps): import("react").JSX.Element;
@@ -1,5 +1,5 @@
1
1
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
- import { useCallback, useMemo, useRef, useState } from "react";
2
+ import { useCallback, useMemo, useState } from "react";
3
3
  import { Popover } from "./Popover.js";
4
4
  import { SearchField } from "./SearchField.js";
5
5
  import { CatalogIcon } from "./CatalogIcon.js";
@@ -10,16 +10,48 @@ import {
10
10
  VirtualPickerList
11
11
  } from "./VirtualPickerList.js";
12
12
  import { useIconCatalog, iconCategories } from "./iconCatalog.js";
13
+ import { usePopover } from "./usePopover.js";
14
+ import { useFieldControl, fieldTriggerProps } from "./field.js";
13
15
  import s from "./Picker.module.css";
14
16
  function IconPicker({
15
17
  value,
16
18
  onChange,
17
- label = "\u56FE\u6807",
18
- disabled = false
19
+ label,
20
+ options,
21
+ valuePrefix = "",
22
+ ...props
19
23
  }) {
20
- const anchor = useRef(null), [open, setOpen] = useState(false), [query, setQuery] = useState("");
21
- const { items, error, retry } = useIconCatalog(open);
24
+ const field = useFieldControl({ ...props, label }), pickerLabel = field.label || "\u56FE\u6807", blocked = field.disabled || field.readOnly, pop = usePopover(blocked), [query, setQuery] = useState("");
25
+ const name = valuePrefix && value.startsWith(valuePrefix) ? value.slice(valuePrefix.length) : value;
26
+ const selected = options?.find((option) => option.value === value);
27
+ const { items, error, retry } = useIconCatalog(
28
+ pop.open && options === void 0
29
+ );
22
30
  const groups = useMemo(() => {
31
+ if (options) {
32
+ const categories = /* @__PURE__ */ new Map();
33
+ for (const option of options) {
34
+ const category = option.category || "\u5168\u90E8";
35
+ if (!categories.has(category))
36
+ categories.set(category, {
37
+ id: category,
38
+ label: category,
39
+ items: []
40
+ });
41
+ categories.get(category).items.push({
42
+ id: option.value,
43
+ label: option.label,
44
+ content: option.icon,
45
+ search: [
46
+ option.value,
47
+ option.label,
48
+ category,
49
+ ...option.keywords || []
50
+ ].join(" ").toLowerCase()
51
+ });
52
+ }
53
+ return [...categories.values()];
54
+ }
23
55
  if (!items) return [];
24
56
  const indexed = items.map((icon) => ({
25
57
  id: icon.name,
@@ -40,43 +72,53 @@ function IconPicker({
40
72
  )
41
73
  })
42
74
  ).filter((group) => group.items.length);
43
- }, [items]);
75
+ }, [items, options]);
44
76
  const choose = useCallback(
45
77
  (item) => {
46
- onChange(item.id);
47
- setOpen(false);
48
- anchor.current?.focus();
78
+ if (blocked) return;
79
+ onChange(options ? item.id : valuePrefix + item.id);
80
+ pop.closeAndFocus();
49
81
  },
50
- [onChange]
82
+ [onChange, blocked, options, valuePrefix, pop.closeAndFocus]
51
83
  );
52
84
  return /* @__PURE__ */ jsxs(Fragment, { children: [
53
85
  /* @__PURE__ */ jsx(
54
86
  SelectTrigger,
55
87
  {
56
- ref: anchor,
57
- expanded: open,
58
- disabled,
59
- "aria-label": label,
88
+ ...fieldTriggerProps(field),
89
+ "aria-label": pickerLabel,
90
+ ref: pop.anchor,
91
+ expanded: pop.open,
92
+ "data-readonly": field.readOnly || void 0,
60
93
  "aria-haspopup": "dialog",
61
- onClick: () => setOpen((x) => !x),
94
+ onClick: pop.toggle,
62
95
  onKeyDown: (e) => {
63
96
  if (e.key === "ArrowDown" || e.key === "ArrowUp") {
64
97
  e.preventDefault();
65
- setOpen(true);
98
+ pop.show();
66
99
  }
67
100
  },
68
- icon: /* @__PURE__ */ jsx(CatalogIcon, { name: value }),
69
- children: /* @__PURE__ */ jsx("span", { children: value || "\u9009\u62E9\u56FE\u6807" })
101
+ icon: options ? selected?.icon : /* @__PURE__ */ jsx(CatalogIcon, { name }),
102
+ children: /* @__PURE__ */ jsx("span", { children: selected?.label || name || "\u9009\u62E9\u56FE\u6807" })
103
+ }
104
+ ),
105
+ field.name && /* @__PURE__ */ jsx(
106
+ "input",
107
+ {
108
+ type: "hidden",
109
+ name: field.name,
110
+ value,
111
+ disabled: field.disabled
70
112
  }
71
113
  ),
72
114
  /* @__PURE__ */ jsx(
73
115
  Popover,
74
116
  {
75
- open,
76
- onClose: () => setOpen(false),
77
- anchor,
117
+ open: pop.open,
118
+ onClose: pop.close,
119
+ anchor: pop.anchor,
78
120
  width: 470,
79
- label: label + "\u9009\u62E9\u5668",
121
+ label: pickerLabel + "\u9009\u62E9\u5668",
80
122
  children: /* @__PURE__ */ jsxs("div", { className: s.panel, children: [
81
123
  /* @__PURE__ */ jsx(
82
124
  SearchField,
@@ -87,18 +129,18 @@ function IconPicker({
87
129
  onChange: setQuery
88
130
  }
89
131
  ),
90
- error ? /* @__PURE__ */ jsx(Button, { onClick: retry, children: "\u91CD\u65B0\u52A0\u8F7D" }) : !items ? /* @__PURE__ */ jsx("div", { className: s.loading, children: /* @__PURE__ */ jsx(Spinner, { label: "\u52A0\u8F7D\u56FE\u6807" }) }) : /* @__PURE__ */ jsx(
132
+ options === void 0 && error ? /* @__PURE__ */ jsx(Button, { onClick: retry, children: "\u91CD\u65B0\u52A0\u8F7D" }) : options === void 0 && !items ? /* @__PURE__ */ jsx("div", { className: s.loading, children: /* @__PURE__ */ jsx(Spinner, { label: "\u52A0\u8F7D\u56FE\u6807" }) }) : /* @__PURE__ */ jsx(
91
133
  VirtualPickerList,
92
134
  {
93
135
  groups,
94
136
  query,
95
- value,
137
+ value: options ? value : name,
96
138
  label: "\u56FE\u6807",
97
139
  onChoose: choose
98
140
  }
99
141
  ),
100
142
  /* @__PURE__ */ jsx("div", { className: s.footer, children: /* @__PURE__ */ jsxs("span", { children: [
101
- items?.length || 0,
143
+ options?.length ?? items?.length ?? 0,
102
144
  " \u4E2A\u56FE\u6807"
103
145
  ] }) })
104
146
  ] })
@@ -42,7 +42,7 @@
42
42
  color: var(--fg);
43
43
  }
44
44
  .indicator button[aria-current="page"] {
45
- color: var(--fg);
45
+ color: var(--navigation-active-color, var(--fg));
46
46
  }
47
47
  .indicator button:focus-visible {
48
48
  outline-offset: -2px;
@@ -1,7 +1,8 @@
1
1
  import type { ComponentPropsWithRef, ReactNode } from "react";
2
- export declare function Input({ label, error, hint, leading, ...props }: ComponentPropsWithRef<"input"> & {
2
+ export declare function Input({ label, error, hint, leading, trailing, ...props }: ComponentPropsWithRef<"input"> & {
3
3
  label?: string;
4
4
  error?: string;
5
5
  hint?: string;
6
6
  leading?: ReactNode;
7
+ trailing?: ReactNode;
7
8
  }): import("react").JSX.Element;
@@ -7,6 +7,7 @@ function Input({
7
7
  error,
8
8
  hint,
9
9
  leading,
10
+ trailing,
10
11
  ...props
11
12
  }) {
12
13
  const field = useFieldControl({ ...props, label, error, hint });
@@ -18,10 +19,17 @@ function Input({
18
19
  className: [s.input, props.className].filter(Boolean).join(" ")
19
20
  }
20
21
  );
21
- const content = leading ? /* @__PURE__ */ jsxs("div", { className: s.withIcon, children: [
22
- /* @__PURE__ */ jsx("span", { className: s.leading, children: leading }),
23
- control
24
- ] }) : control;
22
+ const content = leading || trailing ? /* @__PURE__ */ jsxs(
23
+ "div",
24
+ {
25
+ className: `${s.withIcon} ${leading ? s.hasLeading : ""} ${trailing ? s.hasTrailing : ""}`,
26
+ children: [
27
+ leading && /* @__PURE__ */ jsx("span", { className: s.leading, children: leading }),
28
+ control,
29
+ trailing && /* @__PURE__ */ jsx("span", { className: s.trailing, children: trailing })
30
+ ]
31
+ }
32
+ ) : control;
25
33
  return field.wrapped ? content : /* @__PURE__ */ jsx(FormField, { ...field, children: content });
26
34
  }
27
35
  export {
@@ -8,9 +8,26 @@
8
8
  width: 100%;
9
9
  min-width: 0;
10
10
  }
11
- .withIcon .input {
11
+ .hasLeading .input {
12
12
  padding-left: 38px;
13
13
  }
14
+ .hasTrailing .input {
15
+ padding-right: 36px;
16
+ }
17
+ .trailing {
18
+ position: absolute;
19
+ right: 10px;
20
+ top: 50%;
21
+ transform: translateY(-50%);
22
+ display: flex;
23
+ align-items: center;
24
+ color: var(--muted);
25
+ pointer-events: none;
26
+ }
27
+ .trailing > svg {
28
+ width: 16px;
29
+ height: 16px;
30
+ }
14
31
  .leading {
15
32
  position: absolute;
16
33
  left: 12px;
@@ -1,5 +1,7 @@
1
- export declare function LoadingState({ variant, label, progress, }: {
1
+ export declare function LoadingState({ variant, label, progress, showLabel, fullPage, }: {
2
2
  variant?: "spinner" | "dots" | "skeleton" | "progress";
3
3
  label?: string;
4
4
  progress?: number;
5
+ showLabel?: boolean;
6
+ fullPage?: boolean;
5
7
  }): import("react").JSX.Element;
@@ -6,23 +6,34 @@ import s from "./LoadingState.module.css";
6
6
  function LoadingState({
7
7
  variant = "spinner",
8
8
  label = "\u6B63\u5728\u52A0\u8F7D",
9
- progress
9
+ progress,
10
+ showLabel = true,
11
+ fullPage = false
10
12
  }) {
11
13
  if (variant === "skeleton") return /* @__PURE__ */ jsx(SkeletonRows, { label });
12
- return /* @__PURE__ */ jsxs("div", { className: s.loading, role: "status", "aria-label": label, children: [
13
- variant === "progress" ? /* @__PURE__ */ jsx(Progress, { value: progress ?? 0, label }) : /* @__PURE__ */ jsx(
14
- Spinner,
15
- {
16
- size: 24,
17
- variant: variant === "dots" ? "dots" : "ring",
18
- decorative: true
19
- }
20
- ),
21
- /* @__PURE__ */ jsxs("span", { children: [
22
- label,
23
- variant === "progress" && progress !== void 0 ? " " + Math.round(progress) + "%" : ""
24
- ] })
25
- ] });
14
+ return /* @__PURE__ */ jsxs(
15
+ "div",
16
+ {
17
+ className: s.loading,
18
+ role: "status",
19
+ "aria-label": label,
20
+ "data-full-page": fullPage || void 0,
21
+ children: [
22
+ variant === "progress" ? /* @__PURE__ */ jsx(Progress, { value: progress ?? 0, label }) : /* @__PURE__ */ jsx(
23
+ Spinner,
24
+ {
25
+ size: 24,
26
+ variant: variant === "dots" ? "dots" : "ring",
27
+ decorative: true
28
+ }
29
+ ),
30
+ showLabel && /* @__PURE__ */ jsxs("span", { children: [
31
+ label,
32
+ variant === "progress" && progress !== void 0 ? " " + Math.round(progress) + "%" : ""
33
+ ] })
34
+ ]
35
+ }
36
+ );
26
37
  }
27
38
  export {
28
39
  LoadingState
@@ -12,3 +12,6 @@
12
12
  .loading > div {
13
13
  width: min(260px, 100%);
14
14
  }
15
+ .loading[data-full-page="true"] {
16
+ min-height: calc(100dvh - 200px);
17
+ }
@@ -5,10 +5,11 @@ export type MenuItemProps = Omit<HTMLAttributes<HTMLElement>, "children" | "pref
5
5
  prefix?: ReactNode;
6
6
  shortcut?: string;
7
7
  trailing?: ReactNode;
8
+ meta?: ReactNode;
8
9
  selected?: boolean;
9
10
  active?: boolean;
10
11
  disabled?: boolean;
11
12
  selection?: "check" | "checkbox" | "radio";
12
13
  tone?: "default" | "danger";
13
14
  };
14
- export declare function MenuItem({ as, prefix, label, description, icon, reserveIcon, shortcut, trailing, selected, active, disabled, selection, tone, className, ...props }: MenuItemProps): import("react").JSX.Element;
15
+ export declare function MenuItem({ as, prefix, label, description, icon, reserveIcon, shortcut, trailing, meta, selected, active, disabled, selection, tone, className, ...props }: MenuItemProps): import("react").JSX.Element;
@@ -11,6 +11,7 @@ function MenuItem({
11
11
  reserveIcon = false,
12
12
  shortcut,
13
13
  trailing,
14
+ meta,
14
15
  selected = false,
15
16
  active = false,
16
17
  disabled = false,
@@ -31,6 +32,7 @@ function MenuItem({
31
32
  }
32
33
  ),
33
34
  shortcut && /* @__PURE__ */ jsx("kbd", { className: s.shortcut, children: shortcut }),
35
+ meta && /* @__PURE__ */ jsx("span", { "aria-hidden": "true", children: meta }),
34
36
  /* @__PURE__ */ jsx("span", { className: s.trailing, "data-menu-trailing": true, "aria-hidden": "true", children: trailing || (selection === "checkbox" ? /* @__PURE__ */ jsx("span", { className: s.checkbox, "data-checked": selected, children: selected && /* @__PURE__ */ jsx(Check, {}) }) : selection === "radio" ? /* @__PURE__ */ jsx("span", { className: s.radio, "data-checked": selected, children: /* @__PURE__ */ jsx("i", {}) }) : selection === "check" && selected ? /* @__PURE__ */ jsx(Check, { className: s.check }) : null) })
35
37
  ] });
36
38
  const common = {
@@ -104,6 +104,11 @@
104
104
  .shortcut {
105
105
  flex-shrink: 0;
106
106
  margin-left: auto;
107
+ padding: 0;
108
+ border: 0;
109
+ border-radius: 0;
110
+ background: transparent;
111
+ box-shadow: none;
107
112
  font-family: var(--ui-font);
108
113
  font-size: var(--menu-shortcut-font-size);
109
114
  font-weight: 400;
@@ -111,6 +116,10 @@
111
116
  font-variant-numeric: tabular-nums;
112
117
  color: var(--muted);
113
118
  white-space: nowrap;
119
+ text-align: right;
120
+ }
121
+ .shortcut ~ .trailing:empty {
122
+ display: none;
114
123
  }
115
124
  .check {
116
125
  color: var(--accent);