@surflane/ui 0.1.0 → 0.2.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.
- package/README.md +8 -8
- package/dist/advanced-forms.d.ts +2 -2
- package/dist/advanced-forms.js +39 -39
- package/dist/app-shell.d.ts +1 -1
- package/dist/app-shell.js +11 -11
- package/dist/button.d.ts +5 -5
- package/dist/button.js +12 -12
- package/dist/chart.d.ts +3 -3
- package/dist/chart.js +36 -34
- package/dist/commands.d.ts +5 -5
- package/dist/commands.js +17 -17
- package/dist/content.d.ts +2 -2
- package/dist/content.js +66 -28
- package/dist/context-overlays.d.ts +3 -3
- package/dist/context-overlays.js +11 -11
- package/dist/data.d.ts +1 -1
- package/dist/data.js +18 -18
- package/dist/date-picker.d.ts +8 -8
- package/dist/date-picker.js +18 -18
- package/dist/dialog-focus.js +7 -7
- package/dist/dialog.d.ts +5 -5
- package/dist/dialog.js +16 -16
- package/dist/feedback.d.ts +5 -5
- package/dist/feedback.js +20 -20
- package/dist/file-upload.d.ts +9 -9
- package/dist/file-upload.js +64 -63
- package/dist/filter-bar.d.ts +1 -1
- package/dist/filter-bar.js +9 -9
- package/dist/form-state.d.ts +1 -1
- package/dist/form-state.js +11 -11
- package/dist/forms.d.ts +5 -5
- package/dist/forms.js +32 -32
- package/dist/foundations.d.ts +10 -10
- package/dist/foundations.js +26 -26
- package/dist/icon.d.ts +7 -7
- package/dist/icon.js +22 -22
- package/dist/index.d.ts +37 -37
- package/dist/index.js +38 -38
- package/dist/input-extensions.d.ts +3 -3
- package/dist/input-extensions.js +21 -21
- package/dist/input.d.ts +2 -2
- package/dist/input.js +7 -7
- package/dist/markdown.d.ts +2 -2
- package/dist/markdown.js +38 -38
- package/dist/menu.d.ts +2 -2
- package/dist/menu.js +19 -19
- package/dist/messages.d.ts +2 -2
- package/dist/messages.js +18 -18
- package/dist/navigation-menu.d.ts +2 -2
- package/dist/navigation-menu.js +16 -16
- package/dist/navigation.d.ts +5 -5
- package/dist/navigation.js +40 -40
- package/dist/otp-field.d.ts +1 -1
- package/dist/otp-field.js +14 -14
- package/dist/pagination.d.ts +2 -2
- package/dist/pagination.js +12 -12
- package/dist/panels.d.ts +8 -8
- package/dist/panels.js +39 -39
- package/dist/parts.d.ts +2 -2
- package/dist/parts.js +8 -8
- package/dist/popover.d.ts +3 -3
- package/dist/popover.js +6 -6
- package/dist/scroll-area.d.ts +1 -1
- package/dist/scroll-area.js +20 -20
- package/dist/select.d.ts +8 -8
- package/dist/select.js +21 -21
- package/dist/sizing.d.ts +3 -3
- package/dist/sizing.js +9 -9
- package/dist/slot.d.ts +1 -1
- package/dist/slot.js +4 -4
- package/dist/status.d.ts +4 -4
- package/dist/status.js +8 -8
- package/dist/syntax-engine.js +43 -43
- package/dist/syntax-highlighter.d.ts +2 -2
- package/dist/syntax-highlighter.js +32 -32
- package/dist/toast.d.ts +4 -4
- package/dist/toast.js +33 -33
- package/dist/tone-transition.d.ts +1 -1
- package/dist/tone-transition.js +17 -17
- package/dist/tooltip.d.ts +1 -1
- package/dist/tooltip.js +4 -4
- package/dist/tree.d.ts +4 -4
- package/dist/tree.js +60 -60
- package/package.json +2 -2
- package/src/styles.css +233 -142
package/dist/status.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
-
import * as React from
|
|
4
|
-
import { useComponentSize } from
|
|
5
|
-
import { useToneTransition } from
|
|
6
|
-
export const Badge = React.forwardRef(function Badge({ tone =
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { useComponentSize } from './sizing.js';
|
|
5
|
+
import { useToneTransition } from './tone-transition.js';
|
|
6
|
+
export const Badge = React.forwardRef(function Badge({ tone = 'neutral', icon, children, className, size, ...props }, ref) {
|
|
7
7
|
const scheme = useComponentSize(size);
|
|
8
8
|
const elementRef = useToneTransition(tone, ref);
|
|
9
|
-
return (_jsxs("span", { ...props, ref: elementRef, className: [
|
|
9
|
+
return (_jsxs("span", { ...props, ref: elementRef, className: ['pui-badge', className].filter(Boolean).join(' '), "data-tone": tone, "data-ui-size": scheme, children: [icon && (_jsx("span", { className: 'pui-badge-icon', "aria-hidden": 'true', children: icon })), children] }));
|
|
10
10
|
});
|
|
11
11
|
export function StatusIcon({ tone }) {
|
|
12
|
-
return (_jsx("svg", { width:
|
|
12
|
+
return (_jsx("svg", { width: '13', height: '13', viewBox: '0 0 24 24', fill: 'none', stroke: 'currentColor', strokeWidth: '1.7', "aria-hidden": 'true', children: tone === 'success' ? (_jsx("path", { d: 'm5 12 4 4L19 6' })) : tone === 'caution' ? (_jsxs(_Fragment, { children: [_jsx("path", { d: 'm12 3 10 18H2L12 3Z' }), _jsx("path", { d: 'M12 9v4m0 3v1' })] })) : tone === 'danger' ? (_jsxs(_Fragment, { children: [_jsx("circle", { cx: '12', cy: '12', r: '9' }), _jsx("path", { d: 'M12 7v6m0 3v1' })] })) : tone === 'progress' ? (_jsxs(_Fragment, { children: [_jsx("circle", { cx: '12', cy: '12', r: '9' }), _jsx("path", { d: 'M12 7v6l4 2' })] })) : (_jsxs(_Fragment, { children: [_jsx("circle", { cx: '12', cy: '12', r: '9' }), _jsx("path", { d: 'M8 12h8' })] })) }));
|
|
13
13
|
}
|
|
14
14
|
/** Domain status labels and live announcements remain the caller's responsibility. */
|
|
15
|
-
export const StatusBadge = React.forwardRef(function StatusBadge({ tone =
|
|
15
|
+
export const StatusBadge = React.forwardRef(function StatusBadge({ tone = 'neutral', icon, ...props }, ref) {
|
|
16
16
|
return (_jsx(Badge, { ...props, ref: ref, tone: tone, icon: icon === undefined ? _jsx(StatusIcon, { tone: tone }) : icon }));
|
|
17
17
|
});
|
package/dist/syntax-engine.js
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import { createHighlighterCore } from
|
|
2
|
-
import { createJavaScriptRegexEngine } from
|
|
1
|
+
import { createHighlighterCore } from 'shiki/core';
|
|
2
|
+
import { createJavaScriptRegexEngine } from 'shiki/engine/javascript';
|
|
3
3
|
const loaders = {
|
|
4
|
-
tsx: () => import(
|
|
5
|
-
jsx: () => import(
|
|
6
|
-
typescript: () => import(
|
|
7
|
-
javascript: () => import(
|
|
8
|
-
css: () => import(
|
|
9
|
-
html: () => import(
|
|
10
|
-
json: () => import(
|
|
11
|
-
bash: () => import(
|
|
12
|
-
yaml: () => import(
|
|
13
|
-
python: () => import(
|
|
14
|
-
sql: () => import(
|
|
15
|
-
markdown: () => import(
|
|
4
|
+
tsx: () => import('shiki/langs/tsx.mjs'),
|
|
5
|
+
jsx: () => import('shiki/langs/jsx.mjs'),
|
|
6
|
+
typescript: () => import('shiki/langs/typescript.mjs'),
|
|
7
|
+
javascript: () => import('shiki/langs/javascript.mjs'),
|
|
8
|
+
css: () => import('shiki/langs/css.mjs'),
|
|
9
|
+
html: () => import('shiki/langs/html.mjs'),
|
|
10
|
+
json: () => import('shiki/langs/json.mjs'),
|
|
11
|
+
bash: () => import('shiki/langs/bash.mjs'),
|
|
12
|
+
yaml: () => import('shiki/langs/yaml.mjs'),
|
|
13
|
+
python: () => import('shiki/langs/python.mjs'),
|
|
14
|
+
sql: () => import('shiki/langs/sql.mjs'),
|
|
15
|
+
markdown: () => import('shiki/langs/markdown.mjs'),
|
|
16
16
|
};
|
|
17
17
|
const roles = [
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
18
|
+
'plain',
|
|
19
|
+
'comment',
|
|
20
|
+
'keyword',
|
|
21
|
+
'string',
|
|
22
|
+
'number',
|
|
23
|
+
'function',
|
|
24
|
+
'tag',
|
|
25
|
+
'attribute',
|
|
26
|
+
'punctuation',
|
|
27
27
|
];
|
|
28
28
|
const colors = Object.fromEntries(roles.map((role, i) => [`#00000${i + 1}`, role]));
|
|
29
29
|
const color = (index) => `#00000${index + 1}`;
|
|
@@ -35,53 +35,53 @@ function highlighter() {
|
|
|
35
35
|
langs: [],
|
|
36
36
|
themes: [
|
|
37
37
|
{
|
|
38
|
-
name:
|
|
39
|
-
type:
|
|
38
|
+
name: 'platform-quiet',
|
|
39
|
+
type: 'dark',
|
|
40
40
|
colors: {
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
'editor.foreground': color(0),
|
|
42
|
+
'editor.background': '#000000',
|
|
43
43
|
},
|
|
44
44
|
tokenColors: [
|
|
45
45
|
{
|
|
46
|
-
scope: [
|
|
46
|
+
scope: ['comment', 'punctuation.definition.comment'],
|
|
47
47
|
settings: { foreground: color(1) },
|
|
48
48
|
},
|
|
49
49
|
{
|
|
50
|
-
scope: [
|
|
50
|
+
scope: ['keyword', 'storage', 'constant.language'],
|
|
51
51
|
settings: { foreground: color(2) },
|
|
52
52
|
},
|
|
53
53
|
{
|
|
54
|
-
scope: [
|
|
54
|
+
scope: ['string', 'markup.inline.raw', 'markup.fenced_code.block'],
|
|
55
55
|
settings: { foreground: color(3) },
|
|
56
56
|
},
|
|
57
57
|
{
|
|
58
|
-
scope: [
|
|
58
|
+
scope: ['constant.numeric', 'constant.character'],
|
|
59
59
|
settings: { foreground: color(4) },
|
|
60
60
|
},
|
|
61
61
|
{
|
|
62
62
|
scope: [
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
63
|
+
'entity.name.function',
|
|
64
|
+
'support.function',
|
|
65
|
+
'entity.name.type',
|
|
66
|
+
'support.type',
|
|
67
|
+
'entity.name.class',
|
|
68
68
|
],
|
|
69
69
|
settings: { foreground: color(5) },
|
|
70
70
|
},
|
|
71
71
|
{
|
|
72
|
-
scope: [
|
|
72
|
+
scope: ['entity.name.tag', 'markup.heading'],
|
|
73
73
|
settings: { foreground: color(6) },
|
|
74
74
|
},
|
|
75
75
|
{
|
|
76
76
|
scope: [
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
77
|
+
'entity.other.attribute-name',
|
|
78
|
+
'support.type.property-name',
|
|
79
|
+
'variable.other.property',
|
|
80
80
|
],
|
|
81
81
|
settings: { foreground: color(7) },
|
|
82
82
|
},
|
|
83
83
|
{
|
|
84
|
-
scope: [
|
|
84
|
+
scope: ['punctuation', 'meta.brace'],
|
|
85
85
|
settings: { foreground: color(8) },
|
|
86
86
|
},
|
|
87
87
|
],
|
|
@@ -115,10 +115,10 @@ export async function highlightCode(code, language) {
|
|
|
115
115
|
}));
|
|
116
116
|
await languages.get(language);
|
|
117
117
|
const tokens = instance
|
|
118
|
-
.codeToTokensBase(code, { lang: language, theme:
|
|
118
|
+
.codeToTokensBase(code, { lang: language, theme: 'platform-quiet' })
|
|
119
119
|
.map((line) => line.map((token) => ({
|
|
120
120
|
content: token.content,
|
|
121
|
-
role: colors[token.color?.toLowerCase() ??
|
|
121
|
+
role: colors[token.color?.toLowerCase() ?? ''] ?? 'plain',
|
|
122
122
|
})));
|
|
123
123
|
if (code.length <= 8000) {
|
|
124
124
|
cache.set(key, tokens);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import * as React from
|
|
1
|
+
import * as React from 'react';
|
|
2
2
|
export declare const syntaxLanguages: readonly ["tsx", "jsx", "typescript", "javascript", "css", "html", "json", "bash", "yaml", "python", "sql", "markdown", "text"];
|
|
3
|
-
export type SyntaxHighlighterProps = Omit<React.ComponentPropsWithoutRef<
|
|
3
|
+
export type SyntaxHighlighterProps = Omit<React.ComponentPropsWithoutRef<'code'>, 'children'> & {
|
|
4
4
|
code: string;
|
|
5
5
|
language?: string;
|
|
6
6
|
inline?: boolean;
|
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
|
|
1
|
+
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import * as React from
|
|
4
|
-
import { ScrollArea } from
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { ScrollArea } from './scroll-area.js';
|
|
5
5
|
export const syntaxLanguages = [
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
6
|
+
'tsx',
|
|
7
|
+
'jsx',
|
|
8
|
+
'typescript',
|
|
9
|
+
'javascript',
|
|
10
|
+
'css',
|
|
11
|
+
'html',
|
|
12
|
+
'json',
|
|
13
|
+
'bash',
|
|
14
|
+
'yaml',
|
|
15
|
+
'python',
|
|
16
|
+
'sql',
|
|
17
|
+
'markdown',
|
|
18
|
+
'text',
|
|
19
19
|
];
|
|
20
20
|
const aliases = {
|
|
21
|
-
ts:
|
|
22
|
-
js:
|
|
23
|
-
sh:
|
|
24
|
-
shell:
|
|
25
|
-
yml:
|
|
26
|
-
py:
|
|
27
|
-
md:
|
|
28
|
-
xml:
|
|
29
|
-
plaintext:
|
|
30
|
-
txt:
|
|
21
|
+
ts: 'typescript',
|
|
22
|
+
js: 'javascript',
|
|
23
|
+
sh: 'bash',
|
|
24
|
+
shell: 'bash',
|
|
25
|
+
yml: 'yaml',
|
|
26
|
+
py: 'python',
|
|
27
|
+
md: 'markdown',
|
|
28
|
+
xml: 'html',
|
|
29
|
+
plaintext: 'text',
|
|
30
|
+
txt: 'text',
|
|
31
31
|
};
|
|
32
32
|
/** Rendering remains selectable React text; it never inserts executable HTML. */
|
|
33
|
-
export const SyntaxHighlighter = React.forwardRef(function SyntaxHighlighter({ code, language =
|
|
33
|
+
export const SyntaxHighlighter = React.forwardRef(function SyntaxHighlighter({ code, language = 'text', inline = false, label = 'Highlighted source', wrap = false, className, ...props }, ref) {
|
|
34
34
|
const name = language.trim().toLowerCase();
|
|
35
35
|
const lang = aliases[name] ?? name;
|
|
36
36
|
const [result, setResult] = React.useState();
|
|
37
37
|
React.useEffect(() => {
|
|
38
38
|
let current = true;
|
|
39
|
-
if (lang ===
|
|
39
|
+
if (lang === 'text' ||
|
|
40
40
|
!syntaxLanguages.includes(lang) ||
|
|
41
41
|
code.length > 50000)
|
|
42
42
|
return;
|
|
43
|
-
import(
|
|
43
|
+
import('./syntax-engine.js')
|
|
44
44
|
.then((engine) => engine.highlightCode(code, lang))
|
|
45
45
|
.then((tokens) => {
|
|
46
46
|
if (current)
|
|
@@ -57,8 +57,8 @@ export const SyntaxHighlighter = React.forwardRef(function SyntaxHighlighter({ c
|
|
|
57
57
|
const tokens = result?.code === code && result.language === lang ? result.tokens : null;
|
|
58
58
|
const eols = code.match(/\r\n|\n|\r/g) ?? [];
|
|
59
59
|
const valid = tokens && tokens.length === eols.length + 1;
|
|
60
|
-
const element = (_jsx("code", { ...props, ref: ref, className: [
|
|
61
|
-
? tokens.map((line, i) => (_jsxs(React.Fragment, { children: [line.map((token, j) => (_jsx("span", { "data-syntax": token.role, children: token.content }, j))), eols[i] ??
|
|
60
|
+
const element = (_jsx("code", { ...props, ref: ref, className: ['pui-syntax', className].filter(Boolean).join(' '), "data-language": lang, "data-highlighted": valid ? 'true' : 'false', children: valid
|
|
61
|
+
? tokens.map((line, i) => (_jsxs(React.Fragment, { children: [line.map((token, j) => (_jsx("span", { "data-syntax": token.role, children: token.content }, j))), eols[i] ?? ''] }, i)))
|
|
62
62
|
: code }));
|
|
63
|
-
return inline ? (element) : (_jsx(ScrollArea, { label: label, orientation:
|
|
63
|
+
return inline ? (element) : (_jsx(ScrollArea, { label: label, orientation: 'horizontal', rootClassName: 'pui-syntax-scroll', children: _jsx("pre", { className: 'pui-syntax-pre', "data-wrap": wrap || undefined, children: element }) }));
|
|
64
64
|
});
|
package/dist/toast.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import * as React from
|
|
2
|
-
import { Toast as BaseToast } from
|
|
3
|
-
import { type StatusTone } from
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { Toast as BaseToast } from '@base-ui/react/toast';
|
|
3
|
+
import { type StatusTone } from './status.js';
|
|
4
4
|
export type ToastRootProps = React.ComponentPropsWithoutRef<typeof BaseToast.Root> & {
|
|
5
5
|
tone?: StatusTone;
|
|
6
6
|
};
|
|
7
7
|
export type ToastViewportProps = React.ComponentPropsWithoutRef<typeof BaseToast.Viewport> & {
|
|
8
|
-
layout?:
|
|
8
|
+
layout?: 'stack' | 'list' | 'anchored';
|
|
9
9
|
};
|
|
10
10
|
export declare const Toast: {
|
|
11
11
|
Root: React.ForwardRefExoticComponent<Omit<Omit<import("@base-ui/react/toast").ToastRootProps, "ref"> & React.RefAttributes<HTMLDivElement>, "ref"> & {
|
package/dist/toast.js
CHANGED
|
@@ -1,74 +1,74 @@
|
|
|
1
|
-
|
|
1
|
+
'use client';
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
import * as React from
|
|
4
|
-
import { useComponentSize } from
|
|
5
|
-
import { Toast as BaseToast } from
|
|
6
|
-
import { part, skin } from
|
|
7
|
-
import { StatusIcon } from
|
|
8
|
-
const ToneContext = React.createContext(
|
|
9
|
-
const Root = React.forwardRef(function Root({ tone =
|
|
10
|
-
return (_jsx(ToneContext.Provider, { value: tone, children: _jsx(BaseToast.Root, { ...props, ref: ref, "data-tone": tone, className: skin(
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { useComponentSize } from './sizing.js';
|
|
5
|
+
import { Toast as BaseToast } from '@base-ui/react/toast';
|
|
6
|
+
import { part, skin } from './parts.js';
|
|
7
|
+
import { StatusIcon } from './status.js';
|
|
8
|
+
const ToneContext = React.createContext('neutral');
|
|
9
|
+
const Root = React.forwardRef(function Root({ tone = 'neutral', className, ...props }, ref) {
|
|
10
|
+
return (_jsx(ToneContext.Provider, { value: tone, children: _jsx(BaseToast.Root, { ...props, ref: ref, "data-tone": tone, className: skin('pui-toast', className) }) }));
|
|
11
11
|
});
|
|
12
12
|
const Icon = React.forwardRef(function Icon({ tone, children, className, ...props }, ref) {
|
|
13
13
|
const inherited = React.useContext(ToneContext);
|
|
14
|
-
return (_jsx("span", { ...props, ref: ref, "aria-hidden":
|
|
14
|
+
return (_jsx("span", { ...props, ref: ref, "aria-hidden": 'true', className: ['pui-toast-icon', className].filter(Boolean).join(' '), children: children ?? _jsx(StatusIcon, { tone: tone ?? inherited }) }));
|
|
15
15
|
});
|
|
16
16
|
const Close = React.forwardRef(function Close({ className, children, ...props }, ref) {
|
|
17
|
-
return (_jsx(BaseToast.Close, { "aria-label":
|
|
17
|
+
return (_jsx(BaseToast.Close, { "aria-label": 'Dismiss notification', "aria-hidden": false, "data-variant": 'ghost', "data-size": 'icon', ...props, ref: ref, className: skin('pui-button pui-toast-close', className), children: children ?? (_jsx("svg", { width: '16', height: '16', viewBox: '0 0 24 24', fill: 'none', stroke: 'currentColor', strokeWidth: '1.6', "aria-hidden": 'true', children: _jsx("path", { d: 'm6 6 12 12M18 6 6 18' }) })) }));
|
|
18
18
|
});
|
|
19
19
|
const Action = React.forwardRef(function Action({ className, ...props }, ref) {
|
|
20
|
-
return (_jsx(BaseToast.Action, { "data-variant":
|
|
20
|
+
return (_jsx(BaseToast.Action, { "data-variant": 'outline', "data-size": 'sm', ...props, ref: ref, className: skin('pui-button pui-toast-action', className) }));
|
|
21
21
|
});
|
|
22
|
-
const Viewport = React.forwardRef(function Viewport({ layout =
|
|
22
|
+
const Viewport = React.forwardRef(function Viewport({ layout = 'stack', className, ...props }, ref) {
|
|
23
23
|
const viewportRef = React.useRef(null);
|
|
24
24
|
React.useLayoutEffect(() => {
|
|
25
25
|
const viewport = viewportRef.current;
|
|
26
|
-
if (!viewport || layout !==
|
|
26
|
+
if (!viewport || layout !== 'stack')
|
|
27
27
|
return;
|
|
28
28
|
const resize = new ResizeObserver(update);
|
|
29
29
|
function update() {
|
|
30
|
-
const cards = Array.from(viewport.querySelectorAll(
|
|
30
|
+
const cards = Array.from(viewport.querySelectorAll('.pui-toast:not([data-limited])'));
|
|
31
31
|
const gap = parseFloat(getComputedStyle(viewport).rowGap) || 0;
|
|
32
32
|
const height = cards.reduce((sum, card) => {
|
|
33
|
-
const natural = parseFloat(getComputedStyle(card).getPropertyValue(
|
|
33
|
+
const natural = parseFloat(getComputedStyle(card).getPropertyValue('--toast-height'));
|
|
34
34
|
return (sum + (Number.isFinite(natural) ? natural : card.offsetHeight));
|
|
35
35
|
}, 0) +
|
|
36
36
|
Math.max(0, cards.length - 1) * gap;
|
|
37
|
-
const wasOverflow = viewport.hasAttribute(
|
|
37
|
+
const wasOverflow = viewport.hasAttribute('data-stack-overflow');
|
|
38
38
|
const pinned = viewport.scrollTop >=
|
|
39
39
|
viewport.scrollHeight - viewport.clientHeight - 8;
|
|
40
40
|
const overflowing = height + 48 > window.innerHeight;
|
|
41
|
-
viewport.toggleAttribute(
|
|
41
|
+
viewport.toggleAttribute('data-stack-overflow', overflowing);
|
|
42
42
|
const value = `${height}px`;
|
|
43
|
-
if (viewport.style.getPropertyValue(
|
|
44
|
-
viewport.style.setProperty(
|
|
43
|
+
if (viewport.style.getPropertyValue('--toast-stack-height') !== value)
|
|
44
|
+
viewport.style.setProperty('--toast-stack-height', value);
|
|
45
45
|
if (overflowing && (!wasOverflow || pinned))
|
|
46
46
|
viewport.scrollTop = viewport.scrollHeight;
|
|
47
47
|
}
|
|
48
48
|
function refresh() {
|
|
49
49
|
resize.disconnect();
|
|
50
50
|
viewport
|
|
51
|
-
.querySelectorAll(
|
|
51
|
+
.querySelectorAll('.pui-toast:not([data-limited])')
|
|
52
52
|
.forEach((card) => resize.observe(card));
|
|
53
53
|
update();
|
|
54
54
|
}
|
|
55
55
|
const mutation = new MutationObserver((records) => {
|
|
56
56
|
// Natural-height variables are on roots; ignore our own viewport sizing writes.
|
|
57
57
|
if (records.some((record) => record.target !== viewport ||
|
|
58
|
-
record.attributeName ===
|
|
58
|
+
record.attributeName === 'data-expanded'))
|
|
59
59
|
refresh();
|
|
60
60
|
});
|
|
61
61
|
mutation.observe(viewport, {
|
|
62
62
|
childList: true,
|
|
63
63
|
subtree: true,
|
|
64
64
|
attributes: true,
|
|
65
|
-
attributeFilter: [
|
|
65
|
+
attributeFilter: ['data-limited', 'data-expanded', 'style'],
|
|
66
66
|
});
|
|
67
67
|
refresh();
|
|
68
|
-
window.addEventListener(
|
|
68
|
+
window.addEventListener('resize', update);
|
|
69
69
|
return () => {
|
|
70
|
-
window.removeEventListener(
|
|
71
|
-
viewport.removeAttribute(
|
|
70
|
+
window.removeEventListener('resize', update);
|
|
71
|
+
viewport.removeAttribute('data-stack-overflow');
|
|
72
72
|
resize.disconnect();
|
|
73
73
|
mutation.disconnect();
|
|
74
74
|
};
|
|
@@ -76,11 +76,11 @@ const Viewport = React.forwardRef(function Viewport({ layout = "stack", classNam
|
|
|
76
76
|
const scheme = useComponentSize();
|
|
77
77
|
return (_jsx(BaseToast.Viewport, { ...props, ref: (element) => {
|
|
78
78
|
viewportRef.current = element;
|
|
79
|
-
if (typeof ref ===
|
|
79
|
+
if (typeof ref === 'function')
|
|
80
80
|
ref(element);
|
|
81
81
|
else if (ref)
|
|
82
82
|
ref.current = element;
|
|
83
|
-
}, "data-layout": layout, "data-ui-size": scheme, className: skin(
|
|
83
|
+
}, "data-layout": layout, "data-ui-size": scheme, className: skin('pui-toast-viewport', className) }));
|
|
84
84
|
});
|
|
85
85
|
export const Toast = {
|
|
86
86
|
...BaseToast,
|
|
@@ -89,11 +89,11 @@ export const Toast = {
|
|
|
89
89
|
Close,
|
|
90
90
|
Action,
|
|
91
91
|
Viewport,
|
|
92
|
-
Content: part(BaseToast.Content,
|
|
93
|
-
Title: part(BaseToast.Title,
|
|
94
|
-
Description: part(BaseToast.Description,
|
|
95
|
-
Text: part(
|
|
96
|
-
Positioner: part(BaseToast.Positioner,
|
|
92
|
+
Content: part(BaseToast.Content, 'pui-toast-content'),
|
|
93
|
+
Title: part(BaseToast.Title, 'pui-toast-title'),
|
|
94
|
+
Description: part(BaseToast.Description, 'pui-toast-description'),
|
|
95
|
+
Text: part('div', 'pui-toast-text'),
|
|
96
|
+
Positioner: part(BaseToast.Positioner, 'pui-positioner'),
|
|
97
97
|
};
|
|
98
98
|
// Flat names for React Server Components, which cannot dot into client exports.
|
|
99
99
|
export const { Action: ToastAction, Arrow: ToastArrow, Close: ToastClose, Content: ToastContent, Description: ToastDescription, Portal: ToastPortal, Positioner: ToastPositioner, Provider: ToastProvider, Root: ToastRoot, Title: ToastTitle, Viewport: ToastViewport, Icon: ToastIcon, Text: ToastText, } = Toast;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as React from
|
|
1
|
+
import * as React from 'react';
|
|
2
2
|
/** Animate a scalar so the color-mix expression, not a browser's default
|
|
3
3
|
* color interpolation space, determines every intermediate status color. */
|
|
4
4
|
export declare function useToneTransition<Element extends HTMLElement>(tone: string, forwardedRef: React.ForwardedRef<Element>): React.RefObject<Element | null>;
|
package/dist/tone-transition.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
import * as React from
|
|
1
|
+
'use client';
|
|
2
|
+
import * as React from 'react';
|
|
3
3
|
/** Animate a scalar so the color-mix expression, not a browser's default
|
|
4
4
|
* color interpolation space, determines every intermediate status color. */
|
|
5
5
|
export function useToneTransition(tone, forwardedRef) {
|
|
@@ -16,7 +16,7 @@ export function useToneTransition(tone, forwardedRef) {
|
|
|
16
16
|
animation.current?.cancel();
|
|
17
17
|
animation.current = null;
|
|
18
18
|
const element = ref.current;
|
|
19
|
-
element?.removeAttribute(
|
|
19
|
+
element?.removeAttribute('data-status-transition');
|
|
20
20
|
for (let i = 0; i < 3; i++) {
|
|
21
21
|
element?.style.removeProperty(`--pui-status-from-${i}`);
|
|
22
22
|
element?.style.removeProperty(`--pui-status-to-${i}`);
|
|
@@ -34,23 +34,23 @@ export function useToneTransition(tone, forwardedRef) {
|
|
|
34
34
|
paint.current = to;
|
|
35
35
|
if (!changed ||
|
|
36
36
|
!element.animate ||
|
|
37
|
-
matchMedia(
|
|
37
|
+
matchMedia('(prefers-reduced-motion: reduce), (forced-colors: active)')
|
|
38
38
|
.matches ||
|
|
39
|
-
document.documentElement.hasAttribute(
|
|
39
|
+
document.documentElement.hasAttribute('data-theme-switching'))
|
|
40
40
|
return;
|
|
41
41
|
const durationToken = getComputedStyle(element)
|
|
42
|
-
.getPropertyValue(
|
|
42
|
+
.getPropertyValue('--motion-feedback')
|
|
43
43
|
.trim();
|
|
44
|
-
const duration = parseFloat(durationToken) * (durationToken.endsWith(
|
|
44
|
+
const duration = parseFloat(durationToken) * (durationToken.endsWith('ms') ? 1 : 1000);
|
|
45
45
|
if (!Number.isFinite(duration) || duration <= 0)
|
|
46
46
|
return;
|
|
47
47
|
from.forEach((value, i) => element.style.setProperty(`--pui-status-from-${i}`, value));
|
|
48
48
|
to.forEach((value, i) => element.style.setProperty(`--pui-status-to-${i}`, value));
|
|
49
|
-
element.setAttribute(
|
|
50
|
-
animation.current = element.animate([{
|
|
49
|
+
element.setAttribute('data-status-transition', '');
|
|
50
|
+
animation.current = element.animate([{ '--pui-status-progress': '0' }, { '--pui-status-progress': '1' }], {
|
|
51
51
|
duration,
|
|
52
|
-
easing: getComputedStyle(element).getPropertyValue(
|
|
53
|
-
|
|
52
|
+
easing: getComputedStyle(element).getPropertyValue('--ease-out').trim() ||
|
|
53
|
+
'ease-out',
|
|
54
54
|
});
|
|
55
55
|
animation.current.onfinish = clear;
|
|
56
56
|
}, [tone, clear]);
|
|
@@ -63,17 +63,17 @@ export function useToneTransition(tone, forwardedRef) {
|
|
|
63
63
|
const observer = new MutationObserver(refresh);
|
|
64
64
|
observer.observe(document.documentElement, {
|
|
65
65
|
attributes: true,
|
|
66
|
-
attributeFilter: [
|
|
66
|
+
attributeFilter: ['data-theme', 'data-theme-switching'],
|
|
67
67
|
});
|
|
68
68
|
const media = [
|
|
69
|
-
matchMedia(
|
|
70
|
-
matchMedia(
|
|
71
|
-
matchMedia(
|
|
69
|
+
matchMedia('(prefers-reduced-motion: reduce)'),
|
|
70
|
+
matchMedia('(forced-colors: active)'),
|
|
71
|
+
matchMedia('(prefers-color-scheme: light)'),
|
|
72
72
|
];
|
|
73
|
-
media.forEach((query) => query.addEventListener(
|
|
73
|
+
media.forEach((query) => query.addEventListener('change', refresh));
|
|
74
74
|
return () => {
|
|
75
75
|
observer.disconnect();
|
|
76
|
-
media.forEach((query) => query.removeEventListener(
|
|
76
|
+
media.forEach((query) => query.removeEventListener('change', refresh));
|
|
77
77
|
clear();
|
|
78
78
|
};
|
|
79
79
|
}, [clear]);
|
package/dist/tooltip.d.ts
CHANGED
package/dist/tooltip.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { useComponentSize } from
|
|
4
|
-
import { Tooltip as BaseTooltip } from
|
|
3
|
+
import { useComponentSize } from './sizing.js';
|
|
4
|
+
import { Tooltip as BaseTooltip } from '@base-ui/react/tooltip';
|
|
5
5
|
export function TooltipProvider({ delayDuration = 150, skipDelayDuration = 300, children, }) {
|
|
6
6
|
return (_jsx(BaseTooltip.Provider, { delay: delayDuration, closeDelay: 0, timeout: skipDelayDuration, children: children }));
|
|
7
7
|
}
|
|
@@ -9,5 +9,5 @@ export function Tooltip({ label, enabled = true, children, }) {
|
|
|
9
9
|
const scheme = useComponentSize();
|
|
10
10
|
if (!enabled)
|
|
11
11
|
return children;
|
|
12
|
-
return (_jsxs(BaseTooltip.Root, { children: [_jsx(BaseTooltip.Trigger, { render: children }), _jsx(BaseTooltip.Portal, { children: _jsx(BaseTooltip.Positioner, { side:
|
|
12
|
+
return (_jsxs(BaseTooltip.Root, { children: [_jsx(BaseTooltip.Trigger, { render: children }), _jsx(BaseTooltip.Portal, { children: _jsx(BaseTooltip.Positioner, { side: 'right', sideOffset: 10, collisionPadding: 8, className: 'pui-positioner pui-tooltip-positioner', children: _jsx(BaseTooltip.Popup, { className: 'pui-tooltip', "data-ui-size": scheme, children: label }) }) })] }));
|
|
13
13
|
}
|
package/dist/tree.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as React from
|
|
2
|
-
import { type ComponentSize } from
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { type ComponentSize } from './sizing.js';
|
|
3
3
|
export type TreeNode = {
|
|
4
4
|
id: string;
|
|
5
5
|
label: string;
|
|
@@ -15,13 +15,13 @@ export type TreeProps = {
|
|
|
15
15
|
selectedIds?: readonly string[];
|
|
16
16
|
defaultSelectedIds?: readonly string[];
|
|
17
17
|
onSelectedIdsChange?: (ids: string[]) => void;
|
|
18
|
-
selectionMode?:
|
|
18
|
+
selectionMode?: 'single' | 'multiple';
|
|
19
19
|
height?: number;
|
|
20
20
|
rowHeight?: number;
|
|
21
21
|
size?: ComponentSize;
|
|
22
22
|
virtualized?: boolean;
|
|
23
23
|
emptyLabel?: string;
|
|
24
|
-
dir?:
|
|
24
|
+
dir?: 'ltr' | 'rtl';
|
|
25
25
|
className?: string;
|
|
26
26
|
};
|
|
27
27
|
/** Loaded, immutable hierarchy. Remote loading, permission checks and mutations remain caller-owned. */
|