@newtone-dev/ui-react-web 0.67.0 → 0.69.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/dist/dialog/dialog.css +101 -0
- package/dist/dialog/dialog.d.ts +40 -0
- package/dist/dialog/dialog.d.ts.map +1 -0
- package/dist/dialog/dialog.js +49 -0
- package/dist/dialog/dialog.js.map +1 -0
- package/dist/dialog/index.d.ts +5 -0
- package/dist/dialog/index.d.ts.map +1 -0
- package/dist/dialog/index.js +3 -0
- package/dist/dialog/index.js.map +1 -0
- package/dist/dialog/use-scrolled-to-end.d.ts +17 -0
- package/dist/dialog/use-scrolled-to-end.d.ts.map +1 -0
- package/dist/dialog/use-scrolled-to-end.js +33 -0
- package/dist/dialog/use-scrolled-to-end.js.map +1 -0
- package/dist/index.d.ts +5 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/nav-list/nav-list.d.ts +8 -1
- package/dist/nav-list/nav-list.d.ts.map +1 -1
- package/dist/nav-list/nav-list.js +6 -2
- package/dist/nav-list/nav-list.js.map +1 -1
- package/dist/node-map/beads-gl.d.ts +5 -0
- package/dist/node-map/beads-gl.d.ts.map +1 -1
- package/dist/node-map/beads-gl.js +10 -3
- package/dist/node-map/beads-gl.js.map +1 -1
- package/dist/node-map/index.d.ts +1 -1
- package/dist/node-map/index.d.ts.map +1 -1
- package/dist/node-map/index.js.map +1 -1
- package/dist/node-map/node-map-3d.d.ts +5 -0
- package/dist/node-map/node-map-3d.d.ts.map +1 -1
- package/dist/node-map/node-map-3d.js +74 -15
- package/dist/node-map/node-map-3d.js.map +1 -1
- package/dist/node-map/node-map.css +110 -24
- package/dist/node-map/node-map.d.ts +28 -8
- package/dist/node-map/node-map.d.ts.map +1 -1
- package/dist/node-map/node-map.js.map +1 -1
- package/dist/node-map/over.d.ts +5 -8
- package/dist/node-map/over.d.ts.map +1 -1
- package/dist/node-map/over.js +16 -3
- package/dist/node-map/over.js.map +1 -1
- package/dist/node-map/space.d.ts +2 -2
- package/dist/node-map/space.d.ts.map +1 -1
- package/dist/tag/tag.css +10 -0
- package/dist/tag/tag.d.ts +8 -1
- package/dist/tag/tag.d.ts.map +1 -1
- package/dist/tag/tag.js +3 -2
- package/dist/tag/tag.js.map +1 -1
- package/dist/toast/index.d.ts +3 -0
- package/dist/toast/index.d.ts.map +1 -0
- package/dist/toast/index.js +2 -0
- package/dist/toast/index.js.map +1 -0
- package/dist/toast/toast.css +61 -0
- package/dist/toast/toast.d.ts +23 -0
- package/dist/toast/toast.d.ts.map +1 -0
- package/dist/toast/toast.js +76 -0
- package/dist/toast/toast.js.map +1 -0
- package/package.json +11 -1
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
// The subpaths, not the barrel (the repo blueprint, section 4.3).
|
|
4
|
+
import { useEffect, useRef, useState } from 'react';
|
|
5
|
+
import { Text } from '../text/index.js';
|
|
6
|
+
import { Icon } from '../icon/index.js';
|
|
7
|
+
import { Control } from '../control/index.js';
|
|
8
|
+
/** The glyph each tone wears before its words, when no `icon` is given. Neutral has none. */
|
|
9
|
+
const GLYPH = {
|
|
10
|
+
neutral: null,
|
|
11
|
+
success: 'check_circle',
|
|
12
|
+
warning: 'warning',
|
|
13
|
+
error: 'error',
|
|
14
|
+
};
|
|
15
|
+
/** How long to wait for the fade's own end before calling `onDone` anyway. The fade itself is `motion.duration.quick`. */
|
|
16
|
+
const FADE_BACKSTOP_MS = 600;
|
|
17
|
+
/**
|
|
18
|
+
* A short notice that appears at the foot of the window, stays a few seconds, fades out by itself and is then done: the
|
|
19
|
+
* consumer renders it while something is worth saying and removes it in `onDone`. One at a time. Announced politely
|
|
20
|
+
* (`role="status"`); under `prefers-reduced-motion` it does not fade, it goes. Dismissible. components/toast.md.
|
|
21
|
+
*/
|
|
22
|
+
export function Toast({ message, tone = 'neutral', icon, duration = 5000, onDone, dismissLabel = 'Dismiss', className, ...rest }) {
|
|
23
|
+
const ref = useRef(null);
|
|
24
|
+
const [leaving, setLeaving] = useState(false);
|
|
25
|
+
const [held, setHeld] = useState(false);
|
|
26
|
+
const done = useRef(onDone);
|
|
27
|
+
done.current = onDone;
|
|
28
|
+
const finished = useRef(false);
|
|
29
|
+
const finish = () => {
|
|
30
|
+
if (finished.current)
|
|
31
|
+
return;
|
|
32
|
+
finished.current = true;
|
|
33
|
+
done.current();
|
|
34
|
+
};
|
|
35
|
+
const leave = () => {
|
|
36
|
+
if (typeof window.matchMedia === 'function' &&
|
|
37
|
+
window.matchMedia('(prefers-reduced-motion: reduce)').matches) {
|
|
38
|
+
finish();
|
|
39
|
+
}
|
|
40
|
+
else
|
|
41
|
+
setLeaving(true);
|
|
42
|
+
};
|
|
43
|
+
// Over everything, a modal dialog's top layer included, where the browser has popovers.
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
const el = ref.current;
|
|
46
|
+
el?.showPopover?.();
|
|
47
|
+
return () => {
|
|
48
|
+
try {
|
|
49
|
+
el?.hidePopover?.();
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
/* already gone */
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
}, []);
|
|
56
|
+
useEffect(() => {
|
|
57
|
+
if (!duration || held || leaving)
|
|
58
|
+
return;
|
|
59
|
+
const t = setTimeout(leave, duration);
|
|
60
|
+
return () => clearTimeout(t);
|
|
61
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
62
|
+
}, [duration, held, leaving, message]);
|
|
63
|
+
useEffect(() => {
|
|
64
|
+
if (!leaving)
|
|
65
|
+
return;
|
|
66
|
+
const t = setTimeout(finish, FADE_BACKSTOP_MS);
|
|
67
|
+
return () => clearTimeout(t);
|
|
68
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
69
|
+
}, [leaving]);
|
|
70
|
+
const glyph = icon ?? GLYPH[tone];
|
|
71
|
+
return (_jsxs("div", { ref: ref, "data-newtone-surface": "", "data-newtone-theme": "default", ...{ popover: 'manual' }, role: "status", "aria-live": "polite", className: ['newtone-toast', className].filter(Boolean).join(' '), "data-newtone-tone": tone, "data-newtone-leaving": leaving ? '' : undefined, onAnimationEnd: (e) => {
|
|
72
|
+
if (leaving && e.target === e.currentTarget)
|
|
73
|
+
finish();
|
|
74
|
+
}, onPointerEnter: () => setHeld(true), onPointerLeave: () => setHeld(false), onFocus: () => setHeld(true), onBlur: () => setHeld(false), ...rest, children: [glyph ? _jsx(Icon, { name: glyph, size: "sm", className: "newtone-toast-glyph" }) : null, _jsx(Text, { as: "span", scale: "body-sm", className: "newtone-toast-message", children: message }), _jsx(Control, { className: "newtone-toast-dismiss", icon: "close", size: "sm", variant: "secondary", ariaLabel: dismissLabel, onClick: leave })] }));
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=toast.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toast.js","sourceRoot":"","sources":["../../src/toast/toast.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,kEAAkE;AAClE,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAuB,MAAM,OAAO,CAAA;AACxE,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAI7C,6FAA6F;AAC7F,MAAM,KAAK,GAAqC;IAC5C,OAAO,EAAE,IAAI;IACb,OAAO,EAAE,cAAc;IACvB,OAAO,EAAE,SAAS;IAClB,KAAK,EAAE,OAAO;CACjB,CAAA;AAiBD,0HAA0H;AAC1H,MAAM,gBAAgB,GAAG,GAAG,CAAA;AAE5B;;;;GAIG;AACH,MAAM,UAAU,KAAK,CAAC,EAClB,OAAO,EACP,IAAI,GAAG,SAAS,EA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E,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,EAC5B,MAAM,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,KACxB,IAAI,aAEP,KAAK,CAAC,CAAC,CAAC,KAAC,IAAI,IAAC,IAAI,EAAE,KAAK,EAAE,IAAI,EAAC,IAAI,EAAC,SAAS,EAAC,qBAAqB,GAAG,CAAC,CAAC,CAAC,IAAI,EAC/E,KAAC,IAAI,IAAC,EAAE,EAAC,MAAM,EAAC,KAAK,EAAC,SAAS,EAAC,SAAS,EAAC,uBAAuB,YAC5D,OAAO,GACL,EACP,KAAC,OAAO,IACJ,SAAS,EAAC,uBAAuB,EACjC,IAAI,EAAC,OAAO,EACZ,IAAI,EAAC,IAAI,EACT,OAAO,EAAC,WAAW,EACnB,SAAS,EAAE,YAAY,EACvB,OAAO,EAAE,KAAK,GAChB,IACA,CACT,CAAA;AACL,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@newtone-dev/ui-react-web",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.69.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -242,6 +242,14 @@
|
|
|
242
242
|
"types": "./dist/side-panel/index.d.ts",
|
|
243
243
|
"default": "./dist/side-panel/index.js"
|
|
244
244
|
},
|
|
245
|
+
"./dialog": {
|
|
246
|
+
"types": "./dist/dialog/index.d.ts",
|
|
247
|
+
"default": "./dist/dialog/index.js"
|
|
248
|
+
},
|
|
249
|
+
"./toast": {
|
|
250
|
+
"types": "./dist/toast/index.d.ts",
|
|
251
|
+
"default": "./dist/toast/index.js"
|
|
252
|
+
},
|
|
245
253
|
"./meter": {
|
|
246
254
|
"types": "./dist/meter/index.d.ts",
|
|
247
255
|
"default": "./dist/meter/index.js"
|
|
@@ -547,6 +555,8 @@
|
|
|
547
555
|
"./code-block.css": "./dist/code-block/code-block.css",
|
|
548
556
|
"./fold.css": "./dist/fold/fold.css",
|
|
549
557
|
"./side-panel.css": "./dist/side-panel/side-panel.css",
|
|
558
|
+
"./dialog.css": "./dist/dialog/dialog.css",
|
|
559
|
+
"./toast.css": "./dist/toast/toast.css",
|
|
550
560
|
"./meter.css": "./dist/meter/meter.css",
|
|
551
561
|
"./chat.css": "./dist/chat/chat.css",
|
|
552
562
|
"./prose.css": "./dist/prose/prose.css",
|