@robert-stackflow/oneui 0.6.38 → 0.6.40

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.
@@ -1,153 +1,153 @@
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: hidden;
11
- }
12
-
13
- .dialog[open] {
14
- display: flex;
15
- flex-direction: column;
16
- }
17
-
18
- .dialog::backdrop {
19
- background: var(--overlay);
20
- backdrop-filter: blur(3px);
21
- animation: fade-in var(--popup-enter);
22
- }
23
- .dialog[data-placement="top"] {
24
- margin-top: min(10dvh, 96px);
25
- margin-bottom: auto;
26
- }
27
- .dialogHeader {
28
- flex-shrink: 0;
29
- display: flex;
30
- align-items: flex-start;
31
- justify-content: space-between;
32
- gap: 16px;
33
- padding: 24px 24px 20px;
34
- }
35
- .dialogHeading {
36
- display: flex;
37
- align-items: center;
38
- gap: 14px;
39
- min-width: 0;
40
- }
41
- .dialogHeading h2 {
42
- min-width: 0;
43
- overflow-wrap: anywhere;
44
- font-size: 18px;
45
- font-weight: 600;
46
- line-height: 1.5;
47
- }
48
- .dialogHeader > button {
49
- flex-shrink: 0;
50
- margin-top: -3px;
51
- margin-right: -6px;
52
- color: var(--muted);
53
- }
54
- .dialogIcon {
55
- display: inline-flex;
56
- align-items: center;
57
- justify-content: center;
58
- flex: 0 0 21px;
59
- width: 21px;
60
- height: 25px;
61
- color: var(--dialog-tone, var(--accent-ink, var(--accent)));
62
- }
63
- .dialogIcon > svg {
64
- width: 21px;
65
- height: 21px;
66
- stroke-width: 1.7;
67
- }
68
- .dialog[data-tone="info"] {
69
- --dialog-tone: var(--accent-ink, var(--accent));
70
- }
71
- .dialog[data-tone="success"] {
72
- --dialog-tone: var(--success);
73
- }
74
- .dialog[data-tone="warning"] {
75
- --dialog-tone: var(--warning);
76
- }
77
- .dialog[data-tone="danger"] {
78
- --dialog-tone: var(--danger);
79
- }
80
- .dialogBody {
81
- min-height: 0;
82
- overflow: auto;
83
- overscroll-behavior: contain;
84
- padding: 0 24px 24px;
85
- }
86
- .dialogBody > p {
87
- color: var(--muted);
88
- font-size: 12px;
89
- line-height: 1.8;
90
- }
91
- .dialogFooter {
92
- flex-shrink: 0;
93
- flex-wrap: wrap;
94
- display: flex;
95
- justify-content: flex-end;
96
- gap: 8px;
97
- padding: 14px 24px;
98
- border-top: var(--separator-width) var(--separator-style)
99
- var(--separator-color);
100
- background: var(--canvas);
101
- }
102
- .wide {
103
- width: min(var(--dialog-wide-width), calc(100vw - 32px));
104
- }
105
- .small {
106
- width: min(420px, calc(100vw - 32px));
107
- }
108
- .dialog:is([data-variant="message"], [data-variant="confirm"]) .dialogHeader {
109
- padding: 22px 24px 12px;
110
- }
111
- .dialog:is([data-variant="message"], [data-variant="confirm"]) .dialogHeading {
112
- gap: 10px;
113
- }
114
- .dialog:is([data-variant="message"], [data-variant="confirm"])
115
- .dialogHeader
116
- h2 {
117
- font-size: 17px;
118
- }
119
- .dialog:is([data-variant="message"], [data-variant="confirm"]) .dialogBody {
120
- padding: 0 24px 24px;
121
- }
122
- .closing {
123
- pointer-events: none;
124
- }
125
- .dialog.closing::backdrop {
126
- background: transparent;
127
- backdrop-filter: blur(0);
128
- transition:
129
- background var(--popup-exit),
130
- backdrop-filter var(--popup-exit);
131
- }
132
-
133
- @media (max-width: 600px) {
134
- .dialog {
135
- max-height: calc(100dvh - 24px);
136
- }
137
- .dialogBody {
138
- padding: 0 20px 20px;
139
- }
140
- .dialogHeader,
141
- .dialogFooter {
142
- padding: 18px 20px;
143
- }
144
- }
145
-
146
- @keyframes fade-in {
147
- from {
148
- opacity: 0;
149
- }
150
- to {
151
- opacity: 1;
152
- }
153
- }
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: hidden;
11
+ }
12
+
13
+ .dialog[open] {
14
+ display: flex;
15
+ flex-direction: column;
16
+ }
17
+
18
+ .dialog::backdrop {
19
+ background: var(--overlay);
20
+ backdrop-filter: blur(3px);
21
+ animation: fade-in var(--popup-enter);
22
+ }
23
+ .dialog[data-placement="top"] {
24
+ margin-top: min(10dvh, 96px);
25
+ margin-bottom: auto;
26
+ }
27
+ .dialogHeader {
28
+ flex-shrink: 0;
29
+ display: flex;
30
+ align-items: flex-start;
31
+ justify-content: space-between;
32
+ gap: 16px;
33
+ padding: 24px 24px 20px;
34
+ }
35
+ .dialogHeading {
36
+ display: flex;
37
+ align-items: center;
38
+ gap: 14px;
39
+ min-width: 0;
40
+ }
41
+ .dialogHeading h2 {
42
+ min-width: 0;
43
+ overflow-wrap: anywhere;
44
+ font-size: 18px;
45
+ font-weight: 600;
46
+ line-height: 1.5;
47
+ }
48
+ .dialogHeader > button {
49
+ flex-shrink: 0;
50
+ margin-top: -3px;
51
+ margin-right: -6px;
52
+ color: var(--muted);
53
+ }
54
+ .dialogIcon {
55
+ display: inline-flex;
56
+ align-items: center;
57
+ justify-content: center;
58
+ flex: 0 0 21px;
59
+ width: 21px;
60
+ height: 25px;
61
+ color: var(--dialog-tone, var(--accent-ink, var(--accent)));
62
+ }
63
+ .dialogIcon > svg {
64
+ width: 21px;
65
+ height: 21px;
66
+ stroke-width: 1.7;
67
+ }
68
+ .dialog[data-tone="info"] {
69
+ --dialog-tone: var(--accent-ink, var(--accent));
70
+ }
71
+ .dialog[data-tone="success"] {
72
+ --dialog-tone: var(--success);
73
+ }
74
+ .dialog[data-tone="warning"] {
75
+ --dialog-tone: var(--warning);
76
+ }
77
+ .dialog[data-tone="danger"] {
78
+ --dialog-tone: var(--danger);
79
+ }
80
+ .dialogBody {
81
+ min-height: 0;
82
+ overflow: auto;
83
+ overscroll-behavior: contain;
84
+ padding: 0 24px 24px;
85
+ }
86
+ .dialogBody > p {
87
+ color: var(--muted);
88
+ font-size: 12px;
89
+ line-height: 1.8;
90
+ }
91
+ .dialogFooter {
92
+ flex-shrink: 0;
93
+ flex-wrap: wrap;
94
+ display: flex;
95
+ justify-content: flex-end;
96
+ gap: 8px;
97
+ padding: 14px 24px;
98
+ border-top: var(--separator-width) var(--separator-style)
99
+ var(--separator-color);
100
+ background: var(--canvas);
101
+ }
102
+ .wide {
103
+ width: min(var(--dialog-wide-width), calc(100vw - 32px));
104
+ }
105
+ .small {
106
+ width: min(420px, calc(100vw - 32px));
107
+ }
108
+ .dialog:is([data-variant="message"], [data-variant="confirm"]) .dialogHeader {
109
+ padding: 22px 24px 12px;
110
+ }
111
+ .dialog:is([data-variant="message"], [data-variant="confirm"]) .dialogHeading {
112
+ gap: 10px;
113
+ }
114
+ .dialog:is([data-variant="message"], [data-variant="confirm"])
115
+ .dialogHeader
116
+ h2 {
117
+ font-size: 17px;
118
+ }
119
+ .dialog:is([data-variant="message"], [data-variant="confirm"]) .dialogBody {
120
+ padding: 0 24px 24px;
121
+ }
122
+ .closing {
123
+ pointer-events: none;
124
+ }
125
+ .dialog.closing::backdrop {
126
+ background: transparent;
127
+ backdrop-filter: blur(0);
128
+ transition:
129
+ background var(--popup-exit),
130
+ backdrop-filter var(--popup-exit);
131
+ }
132
+
133
+ @media (max-width: 600px) {
134
+ .dialog {
135
+ max-height: calc(100dvh - 24px);
136
+ }
137
+ .dialogBody {
138
+ padding: 0 20px 20px;
139
+ }
140
+ .dialogHeader,
141
+ .dialogFooter {
142
+ padding: 18px 20px;
143
+ }
144
+ }
145
+
146
+ @keyframes fade-in {
147
+ from {
148
+ opacity: 0;
149
+ }
150
+ to {
151
+ opacity: 1;
152
+ }
153
+ }
@@ -8,7 +8,8 @@
8
8
  display: inline-flex;
9
9
  align-items: baseline;
10
10
  gap: 5px;
11
- font-size: 12px;
11
+ font-size: var(--field-label-size, 13px);
12
+ font-weight: var(--field-label-weight, 400);
12
13
  color: var(--fg);
13
14
  }
14
15
  .required {
@@ -18,7 +19,7 @@
18
19
  }
19
20
  .optional {
20
21
  color: var(--muted);
21
- font-size: 11px;
22
+ font-size: var(--field-message-size, 12px);
22
23
  }
23
24
  .hint,
24
25
  .error {
@@ -56,7 +57,14 @@
56
57
  }
57
58
  .group > legend {
58
59
  padding: 0;
59
- margin-bottom: 10px;
60
+ margin-bottom: var(--section-title-gap, 12px);
61
+ color: var(--fg);
62
+ font-size: var(--section-title-size, 14px);
63
+ font-weight: var(--section-title-weight, 600);
64
+ line-height: var(--section-title-line-height, 1.5);
65
+ }
66
+ .group > legend > span {
67
+ font: inherit;
60
68
  }
61
69
 
62
70
  .labelRow {
@@ -1,92 +1,88 @@
1
- .iconButton {
2
- position: relative;
3
- display: grid;
4
- place-items: center;
5
- width: 32px;
6
- height: 32px;
7
- padding: 0;
8
- border: 0;
9
- background: transparent;
10
- border-radius: calc(var(--radius) - 3px);
11
- color: var(--muted);
12
- transition:
13
- background var(--motion-hover),
14
- color var(--motion-hover),
15
- opacity var(--motion-hover);
16
- }
17
- .iconButton:hover:not(:disabled):not([aria-disabled="true"]) {
18
- color: var(--fg);
19
- background: var(--hover);
20
- }
21
- .icon {
22
- display: contents;
23
- }
24
- .iconButton[data-size="small"] {
25
- width: 30px;
26
- height: 30px;
27
- min-width: 30px;
28
- }
29
- .iconButton[data-has-text] {
30
- display: inline-flex;
31
- align-items: center;
32
- justify-content: center;
33
- width: auto;
34
- gap: 6px;
35
- padding-inline: 9px;
36
- font-size: 13px;
37
- line-height: 1.4;
38
- }
39
- .iconButton[data-has-text] .icon {
40
- display: inline-flex;
41
- align-items: center;
42
- justify-content: center;
43
- flex-shrink: 0;
44
- gap: 3px;
45
- }
46
- .text {
47
- white-space: nowrap;
48
- font-variant-numeric: tabular-nums;
49
- }
50
- .iconButton[data-variant="primary"] {
51
- background: var(--accent-fill, var(--accent));
52
- color: var(--on-accent-fill, var(--on-accent));
53
- }
54
- .iconButton[data-variant="primary"]:hover:not(:disabled) {
55
- background: var(--accent-fill-hover, var(--accent));
56
- }
57
- .iconButton[data-variant="secondary"] {
58
- border: 1px solid var(--border);
59
- background: var(--surface);
60
- }
61
- .iconButton[data-variant="danger"] {
62
- color: var(--danger);
63
- background: var(--danger-soft);
64
- }
65
- .iconButton[data-disclosure] {
66
- width: auto;
67
- padding-inline: 7px;
68
- }
69
- .iconButton[data-disclosure] .icon {
70
- display: flex;
71
- align-items: center;
72
- gap: 3px;
73
- }
74
- .iconButton[data-disclosure][aria-expanded="true"] {
75
- color: var(--accent-ink, var(--fg));
76
- background: var(--hover);
77
- }
78
-
79
- /* Toggle tools use the theme selection surface, without a second outlined button. */
80
- .iconButton[data-variant="ghost"][aria-pressed="true"] {
81
- background: var(--selected);
82
- color: var(--fg);
83
- }
84
- .iconButton[data-variant="ghost"][aria-pressed="true"]:hover:not(:disabled) {
85
- background: color-mix(in srgb, var(--selected) 70%, var(--hover));
86
- }
87
-
88
- .iconButton:disabled,
89
- .iconButton[aria-disabled="true"] {
90
- opacity: 0.35;
91
- cursor: not-allowed;
92
- }
1
+ .iconButton {
2
+ position: relative;
3
+ display: grid;
4
+ place-items: center;
5
+ width: 32px;
6
+ height: 32px;
7
+ padding: 0;
8
+ border: 0;
9
+ background: transparent;
10
+ border-radius: calc(var(--radius) - 3px);
11
+ color: var(--muted);
12
+ transition:
13
+ background var(--motion-hover),
14
+ color var(--motion-hover),
15
+ opacity var(--motion-hover);
16
+ }
17
+ .iconButton:hover:not(:disabled):not([aria-disabled="true"]) {
18
+ color: var(--fg);
19
+ background: var(--hover);
20
+ }
21
+ .icon {
22
+ display: contents;
23
+ }
24
+ .iconButton[data-size="small"] {
25
+ width: 30px;
26
+ height: 30px;
27
+ min-width: 30px;
28
+ }
29
+ .iconButton[data-has-text] {
30
+ display: inline-flex;
31
+ align-items: center;
32
+ justify-content: center;
33
+ width: auto;
34
+ gap: 6px;
35
+ padding-inline: 9px;
36
+ font-size: 13px;
37
+ line-height: 1.4;
38
+ }
39
+ .iconButton[data-has-text] .icon {
40
+ display: inline-flex;
41
+ align-items: center;
42
+ justify-content: center;
43
+ flex-shrink: 0;
44
+ gap: 3px;
45
+ }
46
+ .text {
47
+ white-space: nowrap;
48
+ font-variant-numeric: tabular-nums;
49
+ }
50
+ .iconButton[data-variant="primary"] {
51
+ background: var(--accent-fill, var(--accent));
52
+ color: var(--on-accent-fill, var(--on-accent));
53
+ }
54
+ .iconButton[data-variant="primary"]:hover:not(:disabled) {
55
+ background: var(--accent-fill-hover, var(--accent));
56
+ }
57
+ .iconButton[data-variant="secondary"] {
58
+ border: 1px solid var(--border);
59
+ background: var(--surface);
60
+ }
61
+ .iconButton[data-variant="danger"] {
62
+ color: var(--danger);
63
+ background: var(--danger-soft);
64
+ }
65
+ .iconButton[data-disclosure] {
66
+ width: auto;
67
+ padding-inline: 7px;
68
+ }
69
+ .iconButton[data-disclosure] .icon {
70
+ display: flex;
71
+ align-items: center;
72
+ gap: 3px;
73
+ }
74
+ .iconButton[data-variant="ghost"][aria-expanded="true"]:not(:disabled):not(
75
+ [aria-disabled="true"]
76
+ ),
77
+ .iconButton[data-variant="ghost"][aria-pressed="true"]:not(:disabled):not(
78
+ [aria-disabled="true"]
79
+ ) {
80
+ color: var(--accent-ink, var(--fg));
81
+ background: var(--hover);
82
+ }
83
+
84
+ .iconButton:disabled,
85
+ .iconButton[aria-disabled="true"] {
86
+ opacity: 0.35;
87
+ cursor: not-allowed;
88
+ }
@@ -17,4 +17,4 @@ export type MenuItemProps = Omit<HTMLAttributes<HTMLElement>, "children" | "pref
17
17
  selection?: "check" | "checkbox" | "radio";
18
18
  tone?: "default" | "danger";
19
19
  };
20
- export declare function MenuItem({ as, asChild, children, prefix, label, description, icon, reserveIcon, shortcut, trailing, meta, selected, active, disabled, selection, tone, className, ...props }: MenuItemProps): import("react").JSX.Element;
20
+ export declare function MenuItem({ as, asChild, children, prefix, label, description, descriptionLines, icon, reserveIcon, shortcut, trailing, meta, selected, active, disabled, selection, tone, className, ...props }: MenuItemProps): import("react").JSX.Element;
@@ -14,6 +14,7 @@ function MenuItem({
14
14
  prefix,
15
15
  label,
16
16
  description,
17
+ descriptionLines,
17
18
  icon,
18
19
  reserveIcon = false,
19
20
  shortcut,
@@ -34,6 +35,7 @@ function MenuItem({
34
35
  {
35
36
  label,
36
37
  description,
38
+ descriptionLines,
37
39
  icon,
38
40
  reserveIcon
39
41
  }
@@ -118,6 +118,15 @@
118
118
  white-space: nowrap;
119
119
  text-align: right;
120
120
  }
121
+ .description[data-lines="2"],
122
+ .description[data-lines="3"] {
123
+ display: -webkit-box;
124
+ -webkit-box-orient: vertical;
125
+ -webkit-line-clamp: 2;
126
+ white-space: pre-line;
127
+ overflow-wrap: anywhere;
128
+ }
129
+ .description[data-lines="3"] { -webkit-line-clamp: 3; }
121
130
  .shortcut ~ .trailing:empty {
122
131
  display: none;
123
132
  }
@@ -2,7 +2,8 @@ import type { ReactNode } from "react";
2
2
  export type MenuItemContentProps = {
3
3
  label: ReactNode;
4
4
  description?: ReactNode;
5
+ descriptionLines?: 1 | 2 | 3;
5
6
  icon?: ReactNode;
6
7
  reserveIcon?: boolean;
7
8
  };
8
- export declare function MenuItemContent({ label, description, icon, reserveIcon, }: MenuItemContentProps): import("react").JSX.Element;
9
+ export declare function MenuItemContent({ label, description, descriptionLines, icon, reserveIcon, }: MenuItemContentProps): import("react").JSX.Element;
@@ -4,6 +4,7 @@ import s from "./MenuItem.module.css";
4
4
  function MenuItemContent({
5
5
  label,
6
6
  description,
7
+ descriptionLines = 1,
7
8
  icon,
8
9
  reserveIcon = false
9
10
  }) {
@@ -11,7 +12,7 @@ function MenuItemContent({
11
12
  (icon || reserveIcon) && /* @__PURE__ */ jsx("span", { className: s.leading, "data-menu-icon": true, "aria-hidden": "true", children: icon }),
12
13
  /* @__PURE__ */ jsxs("span", { className: s.copy, children: [
13
14
  /* @__PURE__ */ jsx("span", { className: s.label, "data-menu-label": true, children: label }),
14
- description && /* @__PURE__ */ jsx("span", { className: s.description, children: description })
15
+ description && /* @__PURE__ */ jsx("span", { className: s.description, "data-lines": descriptionLines, title: typeof description === "string" ? description : void 0, children: description })
15
16
  ] })
16
17
  ] });
17
18
  }
@@ -14,7 +14,11 @@ import {
14
14
  cancelMotion
15
15
  } from "./motion.js";
16
16
  import s from "./Popover.module.css";
17
- import { useSurfacePortal } from "./surfacePortal.js";
17
+ import {
18
+ SurfacePortalContext,
19
+ useSurfaceHost,
20
+ useSurfacePortal
21
+ } from "./surfacePortal.js";
18
22
  function Popover({
19
23
  open: requestedOpen,
20
24
  onClose,
@@ -39,7 +43,8 @@ function Popover({
39
43
  }) {
40
44
  const root = usePortalRoot();
41
45
  const owner = useSurfacePortal(), portalHost = portalContainer || owner?.host || root, open = requestedOpen && owner?.active !== false;
42
- const ref = useRef(null), close = useRef(onClose);
46
+ const { ref, host, setRef } = useSurfaceHost();
47
+ const close = useRef(onClose);
43
48
  close.current = onClose;
44
49
  const opened = useRef(open);
45
50
  opened.current = open;
@@ -165,6 +170,8 @@ function Popover({
165
170
  };
166
171
  const key = (event) => {
167
172
  if (event.key === "Escape") {
173
+ if (surface.querySelector("[popover]:popover-open:not([inert])"))
174
+ return;
168
175
  event.preventDefault();
169
176
  event.stopPropagation();
170
177
  close.current();
@@ -208,7 +215,7 @@ function Popover({
208
215
  /* @__PURE__ */ jsx(
209
216
  "div",
210
217
  {
211
- ref,
218
+ ref: setRef,
212
219
  id,
213
220
  popover: "manual",
214
221
  role,
@@ -216,10 +223,10 @@ function Popover({
216
223
  "aria-describedby": descriptionId,
217
224
  onKeyDown,
218
225
  className: `${s.popover} ${scrollable ? "" : s.contained} ${arrow ? s.withArrow : ""} ${className}`,
219
- children: /* @__PURE__ */ jsx(FieldContext, { value: null, children: arrow ? /* @__PURE__ */ jsxs(Fragment, { children: [
226
+ children: /* @__PURE__ */ jsx(SurfacePortalContext, { value: { host, active: open }, children: /* @__PURE__ */ jsx(FieldContext, { value: null, children: arrow ? /* @__PURE__ */ jsxs(Fragment, { children: [
220
227
  /* @__PURE__ */ jsx("span", { className: s.arrow, "data-popover-arrow": true, "aria-hidden": "true" }),
221
228
  /* @__PURE__ */ jsx("div", { className: `${s.body} ${scrollable ? "" : s.bodyContained}`, children })
222
- ] }) : children })
229
+ ] }) : children }) })
223
230
  }
224
231
  ),
225
232
  portalHost
@@ -1,6 +1,9 @@
1
- import type { ReactNode } from "react";
2
- export declare function Section({ title, children, aside, }: {
3
- title: string;
1
+ import { type ComponentPropsWithoutRef, type ReactNode } from "react";
2
+ export type SectionProps = Omit<ComponentPropsWithoutRef<"section">, "title"> & {
3
+ title: ReactNode;
4
4
  children: ReactNode;
5
5
  aside?: ReactNode;
6
- }): import("react").JSX.Element;
6
+ headingLevel?: 2 | 3 | 4 | 5 | 6;
7
+ contentLayout?: "default" | "settings";
8
+ };
9
+ export declare function Section({ title, children, aside, headingLevel, contentLayout, className, ...props }: SectionProps): import("react").JSX.Element;