nish-ui 2.1.3 → 3.0.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 +6 -2
- package/dist/chart.js +1 -1
- package/dist/elements-all.js +58 -58
- package/dist/elements-charts.js +1 -1
- package/dist/elements-data.js +1 -1
- package/dist/elements-forms.js +1 -1
- package/dist/elements.js +4 -4
- package/dist/esm/components/accordion.js +3 -2
- package/dist/esm/components/app-shell.js +3 -2
- package/dist/esm/components/avatar.js +4 -3
- package/dist/esm/components/breadcrumbs.js +3 -2
- package/dist/esm/components/calendar-base.js +292 -0
- package/dist/esm/components/calendar-classes.js +78 -0
- package/dist/esm/components/calendar.js +22 -254
- package/dist/esm/components/canvas/legend.js +3 -2
- package/dist/esm/components/canvas/node.js +3 -2
- package/dist/esm/components/canvas/system-canvas.js +3 -2
- package/dist/esm/components/carousel.js +3 -2
- package/dist/esm/components/charts.js +8 -7
- package/dist/esm/components/combobox.js +3 -2
- package/dist/esm/components/command.js +4 -3
- package/dist/esm/components/context-menu.js +3 -2
- package/dist/esm/components/data.js +4 -3
- package/dist/esm/components/date-picker.js +4 -3
- package/dist/esm/components/date-range-picker.js +214 -0
- package/dist/esm/components/display.js +7 -6
- package/dist/esm/components/drawer.js +3 -2
- package/dist/esm/components/error-boundary.js +4 -2
- package/dist/esm/components/feedback.js +7 -6
- package/dist/esm/components/file-dropzone.js +3 -2
- package/dist/esm/components/filters.js +4 -3
- package/dist/esm/components/flow.js +6 -5
- package/dist/esm/components/forms.js +14 -8
- package/dist/esm/components/hooks.js +2 -2
- package/dist/esm/components/hover-card.js +2 -2
- package/dist/esm/components/inbox.js +4 -2
- package/dist/esm/components/layout.js +5 -4
- package/dist/esm/components/media.js +3 -2
- package/dist/esm/components/menu.js +5 -4
- package/dist/esm/components/modal.js +4 -3
- package/dist/esm/components/more-sheet.js +3 -2
- package/dist/esm/components/multi-select.js +3 -2
- package/dist/esm/components/nav-items.js +4 -3
- package/dist/esm/components/nav.js +5 -4
- package/dist/esm/components/overlay-dialog.js +3 -2
- package/dist/esm/components/pagination.js +3 -2
- package/dist/esm/components/popover.js +2 -2
- package/dist/esm/components/portal.js +2 -2
- package/dist/esm/components/progress.js +3 -2
- package/dist/esm/components/provider.js +34 -5
- package/dist/esm/components/range-calendar.js +123 -0
- package/dist/esm/components/service-tokens.js +4 -3
- package/dist/esm/components/settings.js +4 -3
- package/dist/esm/components/slider.js +3 -2
- package/dist/esm/components/split.js +4 -3
- package/dist/esm/components/strings.js +178 -60
- package/dist/esm/components/tag-input.js +3 -2
- package/dist/esm/components/theme-toggle.js +3 -2
- package/dist/esm/components/time-field-classes.js +110 -0
- package/dist/esm/components/time-field.js +309 -0
- package/dist/esm/components/toast-card.js +155 -0
- package/dist/esm/components/toast-store.js +136 -0
- package/dist/esm/components/toast.js +38 -241
- package/dist/esm/components/tooltip.js +2 -2
- package/dist/esm/components/tree-view.js +40 -46
- package/dist/esm/components/virtual-table.js +3 -2
- package/dist/esm/index.js +6 -20
- package/dist/esm/runtime.js +1 -1
- package/dist/esm/system-canvas.js +4 -0
- package/dist/esm/theme.js +7 -7
- package/dist/format.js +1 -1
- package/dist/index.d.ts +172 -24
- package/dist/system-canvas.d.ts +183 -2
- package/dist/theme.d.ts +21 -3
- package/dist/theme.global.js +21 -136
- package/dist/theme.js +21 -136
- package/package.json +1 -1
- package/dist/system-canvas-BLuWd69H.d.ts +0 -183
|
@@ -1,159 +1,23 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
// src/components/toast.tsx
|
|
4
|
-
import {
|
|
5
|
-
useEffect,
|
|
6
|
-
useRef,
|
|
7
|
-
useState,
|
|
8
|
-
useSyncExternalStore
|
|
9
|
-
} from "react";
|
|
4
|
+
import { useEffect, useRef, useState } from "react";
|
|
10
5
|
import { cn } from "../cn.js";
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
6
|
+
import { XIcon } from "./icons.js";
|
|
7
|
+
import { lazyModule, preloadWhenIdle, useLazyModule } from "./lazy-module.js";
|
|
13
8
|
import { Portal } from "./portal.js";
|
|
14
|
-
import {
|
|
9
|
+
import { useStrings } from "./provider.js";
|
|
10
|
+
import { DISPLAY_STRINGS } from "./strings.js";
|
|
11
|
+
import { dismissToast, useToasts } from "./toast-store.js";
|
|
12
|
+
import { toast, useToast, dismissToast as dismissToast2 } from "./toast-store.js";
|
|
15
13
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
16
|
-
var
|
|
17
|
-
var
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
subs: /* @__PURE__ */ new Set(),
|
|
24
|
-
timers: /* @__PURE__ */ new Map()
|
|
25
|
-
}));
|
|
26
|
-
}
|
|
27
|
-
var emit = () => store().subs.forEach((fn) => fn());
|
|
28
|
-
function startTimer(id, ms) {
|
|
29
|
-
const t = {
|
|
30
|
-
handle: null,
|
|
31
|
-
remaining: ms,
|
|
32
|
-
started: Date.now(),
|
|
33
|
-
paused: 0
|
|
34
|
-
};
|
|
35
|
-
t.handle = setTimeout(() => dismissToast(id), ms);
|
|
36
|
-
store().timers.set(id, t);
|
|
37
|
-
}
|
|
38
|
-
function clearTimer(id) {
|
|
39
|
-
const { timers } = store();
|
|
40
|
-
const t = timers.get(id);
|
|
41
|
-
if (t?.handle != null) clearTimeout(t.handle);
|
|
42
|
-
timers.delete(id);
|
|
43
|
-
}
|
|
44
|
-
function pauseTimer(id) {
|
|
45
|
-
const t = store().timers.get(id);
|
|
46
|
-
if (!t) return;
|
|
47
|
-
t.paused += 1;
|
|
48
|
-
if (t.paused > 1 || t.handle == null) return;
|
|
49
|
-
clearTimeout(t.handle);
|
|
50
|
-
t.handle = null;
|
|
51
|
-
t.remaining = Math.max(0, t.remaining - (Date.now() - t.started));
|
|
52
|
-
}
|
|
53
|
-
function resumeTimer(id) {
|
|
54
|
-
const t = store().timers.get(id);
|
|
55
|
-
if (!t || t.paused === 0) return;
|
|
56
|
-
t.paused -= 1;
|
|
57
|
-
if (t.paused > 0) return;
|
|
58
|
-
t.started = Date.now();
|
|
59
|
-
t.handle = setTimeout(() => dismissToast(id), Math.max(t.remaining, 1e3));
|
|
60
|
-
}
|
|
61
|
-
function dismissToast(id) {
|
|
62
|
-
clearTimer(id);
|
|
63
|
-
const s = store();
|
|
64
|
-
const next = s.items.filter((t) => t.id !== id);
|
|
65
|
-
if (next.length === s.items.length) return;
|
|
66
|
-
s.items = next;
|
|
67
|
-
emit();
|
|
68
|
-
}
|
|
69
|
-
var isKept = (t) => t.duration === "sticky" || t.tone === "error";
|
|
70
|
-
function push(tone, title, bodyOrOptions) {
|
|
71
|
-
const o = typeof bodyOrOptions === "string" ? { body: bodyOrOptions } : bodyOrOptions ?? {};
|
|
72
|
-
const s = store();
|
|
73
|
-
const id = s.nextId++;
|
|
74
|
-
const asked = o.duration === Infinity ? "sticky" : o.duration;
|
|
75
|
-
const duration = asked ?? (tone === "error" ? "sticky" : AUTO_DISMISS_MS);
|
|
76
|
-
const item = {
|
|
77
|
-
id,
|
|
78
|
-
tone,
|
|
79
|
-
title,
|
|
80
|
-
body: o.body,
|
|
81
|
-
action: o.action,
|
|
82
|
-
slot: o.id,
|
|
83
|
-
duration
|
|
84
|
-
};
|
|
85
|
-
const old = o.id ? s.items.find((t) => t.slot === o.id) : void 0;
|
|
86
|
-
if (old) {
|
|
87
|
-
clearTimer(old.id);
|
|
88
|
-
s.items = s.items.map((t) => t === old ? item : t);
|
|
89
|
-
} else {
|
|
90
|
-
let excess = s.items.length + 1 - MAX_VISIBLE;
|
|
91
|
-
const kept = [];
|
|
92
|
-
for (const t of s.items) {
|
|
93
|
-
if (excess > 0 && !isKept(t)) {
|
|
94
|
-
excess--;
|
|
95
|
-
clearTimer(t.id);
|
|
96
|
-
} else {
|
|
97
|
-
kept.push(t);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
s.items = [...kept, item];
|
|
101
|
-
}
|
|
102
|
-
emit();
|
|
103
|
-
if (duration !== "sticky") startTimer(id, duration);
|
|
104
|
-
return id;
|
|
105
|
-
}
|
|
106
|
-
var toast = /* @__PURE__ */ Object.assign((title, o) => push("info", title, o), {
|
|
107
|
-
success: (title, o) => push("success", title, o),
|
|
108
|
-
error: (title, o) => push("error", title, o),
|
|
109
|
-
warn: (title, o) => push("warn", title, o),
|
|
110
|
-
info: (title, o) => push("info", title, o),
|
|
111
|
-
promise: (promise, messages) => {
|
|
112
|
-
const slot = "nish-promise-" + store().nextId;
|
|
113
|
-
push("info", messages.loading, { duration: "sticky", id: slot });
|
|
114
|
-
promise.then(
|
|
115
|
-
(value) => {
|
|
116
|
-
push("success", typeof messages.success === "function" ? messages.success(value) : messages.success, { id: slot });
|
|
117
|
-
},
|
|
118
|
-
(error) => {
|
|
119
|
-
push("error", typeof messages.error === "function" ? messages.error(error) : messages.error, { id: slot });
|
|
120
|
-
}
|
|
121
|
-
);
|
|
122
|
-
return promise;
|
|
123
|
-
}
|
|
124
|
-
});
|
|
125
|
-
function useToast() {
|
|
126
|
-
return toast;
|
|
127
|
-
}
|
|
128
|
-
function useToasts() {
|
|
129
|
-
return useSyncExternalStore(
|
|
130
|
-
(fn) => {
|
|
131
|
-
const { subs } = store();
|
|
132
|
-
subs.add(fn);
|
|
133
|
-
return () => subs.delete(fn);
|
|
134
|
-
},
|
|
135
|
-
() => store().items,
|
|
136
|
-
() => store().items
|
|
137
|
-
);
|
|
138
|
-
}
|
|
139
|
-
var TONE = {
|
|
140
|
-
success: {
|
|
141
|
-
icon: /* @__PURE__ */ jsx(CheckCircleIcon, { size: 15, className: "text-th-ok" }),
|
|
142
|
-
className: "border-th-ok/35"
|
|
143
|
-
},
|
|
144
|
-
error: {
|
|
145
|
-
icon: /* @__PURE__ */ jsx(AlertTriangleIcon, { size: 15, className: "text-th-loss" }),
|
|
146
|
-
className: "border-th-loss/40"
|
|
147
|
-
},
|
|
148
|
-
warn: {
|
|
149
|
-
icon: /* @__PURE__ */ jsx(AlertTriangleIcon, { size: 15, className: "text-th-warn" }),
|
|
150
|
-
className: "border-th-warn/40"
|
|
151
|
-
},
|
|
152
|
-
info: {
|
|
153
|
-
icon: /* @__PURE__ */ jsx(InfoIcon, { size: 15, className: "text-th-accent" }),
|
|
154
|
-
className: "border-th-line-strong"
|
|
155
|
-
}
|
|
156
|
-
};
|
|
14
|
+
var cardFailed = false;
|
|
15
|
+
var cardModule = /* @__PURE__ */ lazyModule(
|
|
16
|
+
() => import("./toast-card.js").catch((e) => {
|
|
17
|
+
cardFailed = true;
|
|
18
|
+
throw e;
|
|
19
|
+
})
|
|
20
|
+
);
|
|
157
21
|
var DESKTOP_BOTTOM = {
|
|
158
22
|
sm: "sm:bottom-0 sm:pb-[calc(var(--nish-bottom-inset,0px)+1.25rem+min(var(--nish-bottom-bar-h,0px),1rem))]",
|
|
159
23
|
md: "sm:bottom-0 sm:pb-[var(--nish-toast-offset,calc(var(--nish-bottom-inset,0px)+1.25rem+min(var(--nish-bottom-bar-h,0px),1rem)))] md:pb-[calc(var(--nish-bottom-inset,0px)+1.25rem+min(var(--nish-bottom-bar-h,0px),1rem))]",
|
|
@@ -161,6 +25,20 @@ var DESKTOP_BOTTOM = {
|
|
|
161
25
|
};
|
|
162
26
|
function Toaster({ className, offset, offsetUntil = "md", style: userStyle, ref, ...rest }) {
|
|
163
27
|
const list = useToasts();
|
|
28
|
+
useEffect(() => cardFailed ? void 0 : preloadWhenIdle(cardModule), []);
|
|
29
|
+
const card = useLazyModule(cardModule, list.length > 0 && !cardFailed);
|
|
30
|
+
const Card = card?.ToastCard;
|
|
31
|
+
const stack = useRef(null);
|
|
32
|
+
const focused = useRef(null);
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
const f = focused.current;
|
|
35
|
+
if (!Card || !f || document.activeElement !== document.body) return;
|
|
36
|
+
const at = list.findIndex((i) => i.id === f[0]);
|
|
37
|
+
const btn = [...stack.current?.children[at]?.querySelectorAll("button") ?? []].find(
|
|
38
|
+
(b) => (b.getAttribute("aria-label") ?? b.textContent) === f[1]
|
|
39
|
+
);
|
|
40
|
+
btn?.focus();
|
|
41
|
+
}, [Card]);
|
|
164
42
|
const [polite, setPolite] = useState({ text: "", seq: 0 });
|
|
165
43
|
const [assertive, setAssertive] = useState({ text: "", seq: 0 });
|
|
166
44
|
const announced = useRef(/* @__PURE__ */ new Set());
|
|
@@ -224,105 +102,22 @@ function Toaster({ className, offset, offsetUntil = "md", style: userStyle, ref,
|
|
|
224
102
|
children: [
|
|
225
103
|
/* @__PURE__ */ jsx("div", { role: "status", "aria-live": "polite", "aria-atomic": "true", className: "sr-only", children: /* @__PURE__ */ jsx("span", { children: polite.text }, polite.seq) }),
|
|
226
104
|
/* @__PURE__ */ jsx("div", { role: "alert", "aria-live": "assertive", "aria-atomic": "true", className: "sr-only", children: /* @__PURE__ */ jsx("span", { children: assertive.text }, assertive.seq) }),
|
|
227
|
-
list.map((t) => /* @__PURE__ */ jsx(
|
|
105
|
+
/* @__PURE__ */ jsx("div", { ref: stack, className: "contents", children: list.map((t) => Card ? /* @__PURE__ */ jsx(Card, { t }, t.id) : /* @__PURE__ */ jsx(ToastFallback, { t, focusedRef: focused }, t.id)) })
|
|
228
106
|
]
|
|
229
107
|
}
|
|
230
108
|
) });
|
|
231
109
|
}
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
const strings = useNishStrings();
|
|
237
|
-
const ref = useRef(null);
|
|
238
|
-
const drag = useRef(null);
|
|
239
|
-
const setOffset = (dx, width) => {
|
|
240
|
-
const el = ref.current;
|
|
241
|
-
if (!el) return;
|
|
242
|
-
el.style.transform = dx === 0 ? "" : `translateX(${dx}px)`;
|
|
243
|
-
el.style.opacity = dx === 0 ? "" : String(Math.max(0, 1 - Math.abs(dx) / width));
|
|
244
|
-
};
|
|
245
|
-
const onDown = (e) => {
|
|
246
|
-
if (e.pointerType === "mouse") return;
|
|
247
|
-
drag.current = {
|
|
248
|
-
pointerId: e.pointerId,
|
|
249
|
-
startX: e.clientX,
|
|
250
|
-
startY: e.clientY,
|
|
251
|
-
lastX: e.clientX,
|
|
252
|
-
lastT: e.timeStamp,
|
|
253
|
-
velocity: 0,
|
|
254
|
-
active: false
|
|
255
|
-
};
|
|
256
|
-
};
|
|
257
|
-
const onMove = (e) => {
|
|
258
|
-
const d = drag.current;
|
|
259
|
-
const el = ref.current;
|
|
260
|
-
if (!d || !el || d.pointerId !== e.pointerId) return;
|
|
261
|
-
const dx = e.clientX - d.startX;
|
|
262
|
-
if (!d.active) {
|
|
263
|
-
if (Math.abs(dx) < SWIPE_SLOP || Math.abs(dx) < Math.abs(e.clientY - d.startY)) return;
|
|
264
|
-
d.active = true;
|
|
265
|
-
el.setPointerCapture(e.pointerId);
|
|
266
|
-
pauseTimer(t.id);
|
|
267
|
-
}
|
|
268
|
-
const dt = e.timeStamp - d.lastT;
|
|
269
|
-
if (dt > 0) d.velocity = (e.clientX - d.lastX) / dt;
|
|
270
|
-
d.lastX = e.clientX;
|
|
271
|
-
d.lastT = e.timeStamp;
|
|
272
|
-
setOffset(dx, el.offsetWidth);
|
|
273
|
-
};
|
|
274
|
-
const onUp = (e) => {
|
|
275
|
-
const d = drag.current;
|
|
276
|
-
const el = ref.current;
|
|
277
|
-
drag.current = null;
|
|
278
|
-
if (!d || !el || d.pointerId !== e.pointerId || !d.active) return;
|
|
279
|
-
const dx = e.clientX - d.startX;
|
|
280
|
-
const width = el.offsetWidth;
|
|
281
|
-
const flung = Math.abs(d.velocity) > SWIPE_DISMISS_VELOCITY && Math.sign(d.velocity) === Math.sign(dx);
|
|
282
|
-
if (Math.abs(dx) > width * SWIPE_DISMISS_FRACTION || flung) {
|
|
283
|
-
dismissToast(t.id);
|
|
284
|
-
return;
|
|
285
|
-
}
|
|
286
|
-
el.style.transition = "transform 160ms var(--nish-ease-out), opacity 160ms var(--nish-ease-out)";
|
|
287
|
-
setOffset(0, width);
|
|
288
|
-
window.setTimeout(() => {
|
|
289
|
-
if (ref.current) ref.current.style.transition = "";
|
|
290
|
-
}, 180);
|
|
291
|
-
resumeTimer(t.id);
|
|
292
|
-
};
|
|
293
|
-
const onCancel = (e) => {
|
|
294
|
-
const d = drag.current;
|
|
295
|
-
drag.current = null;
|
|
296
|
-
if (!d?.active || d.pointerId !== e.pointerId) return;
|
|
297
|
-
setOffset(0, ref.current?.offsetWidth || 1);
|
|
298
|
-
resumeTimer(t.id);
|
|
299
|
-
};
|
|
300
|
-
const leave = (e) => {
|
|
301
|
-
if (!e.currentTarget.contains(e.relatedTarget)) resumeTimer(t.id);
|
|
302
|
-
};
|
|
303
|
-
const enter = (e) => {
|
|
304
|
-
if (!e.currentTarget.contains(e.relatedTarget)) pauseTimer(t.id);
|
|
110
|
+
function ToastFallback({ t, focusedRef }) {
|
|
111
|
+
const strings = useStrings(DISPLAY_STRINGS);
|
|
112
|
+
const track = (e) => {
|
|
113
|
+
focusedRef.current = [t.id, e.currentTarget.getAttribute("aria-label") ?? e.currentTarget.textContent];
|
|
305
114
|
};
|
|
306
115
|
return /* @__PURE__ */ jsxs(
|
|
307
116
|
"div",
|
|
308
117
|
{
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
onPointerMove: onMove,
|
|
312
|
-
onPointerUp: onUp,
|
|
313
|
-
onPointerCancel: onCancel,
|
|
314
|
-
onPointerEnter: (e) => e.pointerType === "mouse" && pauseTimer(t.id),
|
|
315
|
-
onPointerLeave: (e) => e.pointerType === "mouse" && resumeTimer(t.id),
|
|
316
|
-
onFocus: enter,
|
|
317
|
-
onBlur: leave,
|
|
318
|
-
className: cn(
|
|
319
|
-
"pointer-events-auto flex w-full max-w-md items-start gap-2.5 rounded-xl border bg-th-elevated px-3.5 py-3 shadow-pop",
|
|
320
|
-
"touch-pan-y animate-[nish-rise-in_160ms_var(--nish-ease-out)]",
|
|
321
|
-
"max-sm:[html[data-nish-layer-open]_&]:animate-[nish-toast-in-top_200ms_var(--nish-ease-out)]",
|
|
322
|
-
TONE[t.tone].className
|
|
323
|
-
),
|
|
118
|
+
"data-nish-toast-fallback": "",
|
|
119
|
+
className: "pointer-events-auto flex w-full max-w-md items-start gap-2.5 rounded-xl border border-th-line-strong bg-th-elevated px-3.5 py-3 shadow-pop animate-[nish-rise-in_160ms_var(--nish-ease-out)]",
|
|
324
120
|
children: [
|
|
325
|
-
/* @__PURE__ */ jsx("span", { className: "mt-0.5 shrink-0", children: TONE[t.tone].icon }),
|
|
326
121
|
/* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1", children: [
|
|
327
122
|
/* @__PURE__ */ jsx("p", { className: "text-sm font-medium leading-snug text-th-hi", children: t.title }),
|
|
328
123
|
t.body ? /* @__PURE__ */ jsx("p", { className: "mt-0.5 break-words text-xs leading-snug text-th-hi2", children: t.body }) : null
|
|
@@ -331,6 +126,7 @@ function ToastCard({ t }) {
|
|
|
331
126
|
"button",
|
|
332
127
|
{
|
|
333
128
|
type: "button",
|
|
129
|
+
onFocus: track,
|
|
334
130
|
onClick: () => {
|
|
335
131
|
t.action?.onClick();
|
|
336
132
|
dismissToast(t.id);
|
|
@@ -343,6 +139,7 @@ function ToastCard({ t }) {
|
|
|
343
139
|
"button",
|
|
344
140
|
{
|
|
345
141
|
type: "button",
|
|
142
|
+
onFocus: track,
|
|
346
143
|
onClick: () => dismissToast(t.id),
|
|
347
144
|
"aria-label": strings.dismiss,
|
|
348
145
|
className: "-m-1 inline-flex shrink-0 items-center justify-center rounded-md p-1 text-th-hi3 transition-colors hover:bg-th-overlay hover:text-th-hi pointer-coarse:-my-2 pointer-coarse:min-h-11 pointer-coarse:min-w-11",
|
|
@@ -355,7 +152,7 @@ function ToastCard({ t }) {
|
|
|
355
152
|
}
|
|
356
153
|
export {
|
|
357
154
|
Toaster,
|
|
358
|
-
dismissToast,
|
|
155
|
+
dismissToast2 as dismissToast,
|
|
359
156
|
toast,
|
|
360
157
|
useToast
|
|
361
158
|
};
|
|
@@ -6,7 +6,7 @@ import { createPortal } from "react-dom";
|
|
|
6
6
|
import { cn } from "../cn.js";
|
|
7
7
|
import { shared } from "../runtime.js";
|
|
8
8
|
import { useIsoLayoutEffect } from "./client.js";
|
|
9
|
-
import {
|
|
9
|
+
import { useNishContext } from "./provider.js";
|
|
10
10
|
import { keyboardFocused, touchTracker } from "./overlay-classes.js";
|
|
11
11
|
import { FOCUSABLE, layerHost, useMergedRef } from "./overlay-core.js";
|
|
12
12
|
import { EDGE, useAnchoredPosition, floatingStyle } from "./overlay-position.js";
|
|
@@ -146,7 +146,7 @@ function FloatingTip({
|
|
|
146
146
|
onPointerEnter,
|
|
147
147
|
onPointerLeave
|
|
148
148
|
}) {
|
|
149
|
-
const config =
|
|
149
|
+
const config = useNishContext();
|
|
150
150
|
const tipRef = useRef(null);
|
|
151
151
|
const pos = useAnchoredPosition(anchor, tipRef, true, side, "center");
|
|
152
152
|
return createPortal(
|
|
@@ -46,11 +46,10 @@ var TreeItem = memo(function TreeItem2({
|
|
|
46
46
|
labelId,
|
|
47
47
|
itemRef,
|
|
48
48
|
onRowClick,
|
|
49
|
-
onToggle
|
|
50
|
-
children
|
|
49
|
+
onToggle
|
|
51
50
|
}) {
|
|
52
51
|
const parent = hasChildren(node);
|
|
53
|
-
return /* @__PURE__ */
|
|
52
|
+
return /* @__PURE__ */ jsx(
|
|
54
53
|
"li",
|
|
55
54
|
{
|
|
56
55
|
ref: itemRef,
|
|
@@ -67,35 +66,32 @@ var TreeItem = memo(function TreeItem2({
|
|
|
67
66
|
"data-disabled": node.disabled ? "" : void 0,
|
|
68
67
|
tabIndex: isTarget ? 0 : -1,
|
|
69
68
|
className: "outline-none [&:focus-visible>div]:outline-2 [&:focus-visible>div]:-outline-offset-2 [&:focus-visible>div]:outline-th-accent",
|
|
70
|
-
children:
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
{
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
),
|
|
97
|
-
open ? /* @__PURE__ */ jsx("ul", { role: "group", className: "grid gap-px", children }) : null
|
|
98
|
-
]
|
|
69
|
+
children: /* @__PURE__ */ jsxs(
|
|
70
|
+
"div",
|
|
71
|
+
{
|
|
72
|
+
className: treeRowClass({ selected: selectable && selected, disabled: node.disabled }),
|
|
73
|
+
style: { paddingInlineStart: `calc(${level - 1} * 1.25rem + 0.25rem)` },
|
|
74
|
+
onClick: () => onRowClick(node),
|
|
75
|
+
children: [
|
|
76
|
+
/* @__PURE__ */ jsx(
|
|
77
|
+
"span",
|
|
78
|
+
{
|
|
79
|
+
"aria-hidden": "true",
|
|
80
|
+
"data-tree-toggle": "",
|
|
81
|
+
onClick: parent ? (e) => {
|
|
82
|
+
e.stopPropagation();
|
|
83
|
+
onToggle(node);
|
|
84
|
+
} : void 0,
|
|
85
|
+
className: "inline-flex w-6 shrink-0 self-stretch items-center justify-center text-th-hi3 pointer-coarse:w-11",
|
|
86
|
+
children: parent ? /* @__PURE__ */ jsx(Chevron, { open }) : null
|
|
87
|
+
}
|
|
88
|
+
),
|
|
89
|
+
node.icon ? /* @__PURE__ */ jsx("span", { "aria-hidden": "true", className: "inline-flex shrink-0 text-th-hi3", children: node.icon }) : null,
|
|
90
|
+
/* @__PURE__ */ jsx("span", { id: labelId, className: "min-w-0 flex-1 truncate", children: node.label }),
|
|
91
|
+
node.trailing != null ? /* @__PURE__ */ jsx("span", { className: "ms-auto shrink-0 text-xs text-th-hi3", children: node.trailing }) : null
|
|
92
|
+
]
|
|
93
|
+
}
|
|
94
|
+
)
|
|
99
95
|
}
|
|
100
96
|
);
|
|
101
97
|
});
|
|
@@ -290,29 +286,27 @@ function TreeView(props) {
|
|
|
290
286
|
},
|
|
291
287
|
[latest]
|
|
292
288
|
);
|
|
293
|
-
|
|
294
|
-
const open = hasChildren(node) && expandedSet.has(node.id);
|
|
289
|
+
return /* @__PURE__ */ jsx("ul", { ...rest, ref, role: "tree", className: cn("grid gap-px text-sm", className), onKeyDown, onFocus, onBlur, children: flat.map((f) => {
|
|
290
|
+
const open = hasChildren(f.node) && expandedSet.has(f.node.id);
|
|
295
291
|
return /* @__PURE__ */ jsx(
|
|
296
292
|
TreeItem,
|
|
297
293
|
{
|
|
298
|
-
node,
|
|
299
|
-
level,
|
|
300
|
-
posinset:
|
|
301
|
-
setsize:
|
|
294
|
+
node: f.node,
|
|
295
|
+
level: f.level,
|
|
296
|
+
posinset: f.posInSet,
|
|
297
|
+
setsize: f.setSize,
|
|
302
298
|
open,
|
|
303
299
|
selectable,
|
|
304
|
-
selected: selectedId === node.id,
|
|
305
|
-
isTarget: node.id === targetId,
|
|
306
|
-
labelId: `${uid}-${encodeURIComponent(node.id)}`,
|
|
300
|
+
selected: selectedId === f.node.id,
|
|
301
|
+
isTarget: f.node.id === targetId,
|
|
302
|
+
labelId: `${uid}-${encodeURIComponent(f.node.id)}`,
|
|
307
303
|
itemRef,
|
|
308
304
|
onRowClick,
|
|
309
|
-
onToggle
|
|
310
|
-
children: open ? renderNodes(node.children, level + 1) : null
|
|
305
|
+
onToggle
|
|
311
306
|
},
|
|
312
|
-
node.id
|
|
307
|
+
f.node.id
|
|
313
308
|
);
|
|
314
|
-
});
|
|
315
|
-
return /* @__PURE__ */ jsx("ul", { ...rest, ref, role: "tree", className: cn("grid gap-px text-sm", className), onKeyDown, onFocus, onBlur, children: renderNodes(items, 1) });
|
|
309
|
+
}) });
|
|
316
310
|
}
|
|
317
311
|
export {
|
|
318
312
|
TreeView
|
|
@@ -12,7 +12,8 @@ import {
|
|
|
12
12
|
import { cn } from "../cn.js";
|
|
13
13
|
import { useIsoLayoutEffect } from "./client.js";
|
|
14
14
|
import { sortRows } from "./data-classes.js";
|
|
15
|
-
import {
|
|
15
|
+
import { useStrings } from "./provider.js";
|
|
16
|
+
import { TABLE_STRINGS, STATUS_STRINGS } from "./strings.js";
|
|
16
17
|
import { useLatest } from "./latest.js";
|
|
17
18
|
import { Table, TableWrap, Td, Th, Tr } from "./table.js";
|
|
18
19
|
import { useVirtualRows } from "./virtual.js";
|
|
@@ -46,7 +47,7 @@ function VirtualTable({
|
|
|
46
47
|
ref,
|
|
47
48
|
...rest
|
|
48
49
|
}) {
|
|
49
|
-
const t =
|
|
50
|
+
const t = useStrings(TABLE_STRINGS, STATUS_STRINGS);
|
|
50
51
|
const size = rowHeight ?? (onRowClick ? 44 : dense ? 33 : 41);
|
|
51
52
|
const [innerSort, setInnerSort] = useState(null);
|
|
52
53
|
const [announcement, setAnnouncement] = useState("");
|
package/dist/esm/index.js
CHANGED
|
@@ -87,12 +87,6 @@ import {
|
|
|
87
87
|
AnimatedList,
|
|
88
88
|
usePrefersReducedMotion
|
|
89
89
|
} from "./components/flow.js";
|
|
90
|
-
import { SystemCanvas, layoutSystem, pickLayout, routeEdges } from "./system-canvas.js";
|
|
91
|
-
import { DEFAULT_CANVAS_LABELS } from "./components/canvas/types.js";
|
|
92
|
-
import { Inbox } from "./components/inbox.js";
|
|
93
|
-
import { DEFAULT_INBOX_LABELS } from "./components/inbox-classes.js";
|
|
94
|
-
import { INBOX_SOURCE_LABELS, INBOX_DEFAULT_SETTINGS } from "./inbox-types.js";
|
|
95
|
-
import { INBOX_ACTION_HEADER, INBOX_ACTION_TIMEOUT_MS } from "./inbox-types.js";
|
|
96
90
|
import { AppShell } from "./components/app-shell.js";
|
|
97
91
|
import { useResource } from "./components/resource.js";
|
|
98
92
|
import { apiFetch, ApiError, configureApi } from "./components/resource-classes.js";
|
|
@@ -100,10 +94,12 @@ import { AppErrorBoundary } from "./components/error-boundary.js";
|
|
|
100
94
|
import { FilterBar, FilterSheet } from "./components/filters.js";
|
|
101
95
|
import { useUrlState, locationAdapter } from "./components/url-state.js";
|
|
102
96
|
import { SettingsSection, SettingRow, NumberField, useSaveStatus } from "./components/settings.js";
|
|
103
|
-
import { ServiceTokensSection, useServiceTokens } from "./components/service-tokens.js";
|
|
104
97
|
import { Combobox } from "./components/combobox.js";
|
|
105
98
|
import { Calendar } from "./components/calendar.js";
|
|
106
99
|
import { DatePicker } from "./components/date-picker.js";
|
|
100
|
+
import { RangeCalendar } from "./components/range-calendar.js";
|
|
101
|
+
import { DateRangePicker } from "./components/date-range-picker.js";
|
|
102
|
+
import { TimeField } from "./components/time-field.js";
|
|
107
103
|
import { MultiSelect } from "./components/multi-select.js";
|
|
108
104
|
import { Carousel } from "./components/carousel.js";
|
|
109
105
|
import {
|
|
@@ -192,11 +188,10 @@ export {
|
|
|
192
188
|
ConnectionBanner,
|
|
193
189
|
ContextMenu,
|
|
194
190
|
CopyButton,
|
|
195
|
-
DEFAULT_CANVAS_LABELS,
|
|
196
|
-
DEFAULT_INBOX_LABELS,
|
|
197
191
|
DEFAULT_STRINGS,
|
|
198
192
|
DEFAULT_THEME,
|
|
199
193
|
DatePicker,
|
|
194
|
+
DateRangePicker,
|
|
200
195
|
Disclosure,
|
|
201
196
|
Drawer,
|
|
202
197
|
DropdownMenu,
|
|
@@ -211,12 +206,7 @@ export {
|
|
|
211
206
|
FlowSteps,
|
|
212
207
|
HUE_ROLES,
|
|
213
208
|
HoverCard,
|
|
214
|
-
INBOX_ACTION_HEADER,
|
|
215
|
-
INBOX_ACTION_TIMEOUT_MS,
|
|
216
|
-
INBOX_DEFAULT_SETTINGS,
|
|
217
|
-
INBOX_SOURCE_LABELS,
|
|
218
209
|
IconButton,
|
|
219
|
-
Inbox,
|
|
220
210
|
InfoIcon,
|
|
221
211
|
Input,
|
|
222
212
|
Kbd,
|
|
@@ -261,6 +251,7 @@ export {
|
|
|
261
251
|
Radio,
|
|
262
252
|
RadioGroup,
|
|
263
253
|
RangeBar,
|
|
254
|
+
RangeCalendar,
|
|
264
255
|
RelativeTime,
|
|
265
256
|
ResponsiveTable,
|
|
266
257
|
RotateIcon,
|
|
@@ -274,7 +265,6 @@ export {
|
|
|
274
265
|
Segmented,
|
|
275
266
|
Select,
|
|
276
267
|
Separator,
|
|
277
|
-
ServiceTokensSection,
|
|
278
268
|
SettingRow,
|
|
279
269
|
SettingsIcon,
|
|
280
270
|
SettingsSection,
|
|
@@ -296,7 +286,6 @@ export {
|
|
|
296
286
|
StickyBar,
|
|
297
287
|
SunIcon,
|
|
298
288
|
Switch,
|
|
299
|
-
SystemCanvas,
|
|
300
289
|
THEMES,
|
|
301
290
|
TabPanel,
|
|
302
291
|
Table,
|
|
@@ -308,6 +297,7 @@ export {
|
|
|
308
297
|
Th,
|
|
309
298
|
ThemeToggle,
|
|
310
299
|
TickerText,
|
|
300
|
+
TimeField,
|
|
311
301
|
Toaster,
|
|
312
302
|
Tooltip,
|
|
313
303
|
Tr,
|
|
@@ -335,16 +325,13 @@ export {
|
|
|
335
325
|
googleFavicon,
|
|
336
326
|
iconButtonClass,
|
|
337
327
|
isRtl,
|
|
338
|
-
layoutSystem,
|
|
339
328
|
linkClass,
|
|
340
329
|
locationAdapter,
|
|
341
330
|
menuItemClass,
|
|
342
331
|
navigateFromLayer,
|
|
343
332
|
paginationRange,
|
|
344
|
-
pickLayout,
|
|
345
333
|
presetOptions,
|
|
346
334
|
revealClass,
|
|
347
|
-
routeEdges,
|
|
348
335
|
safeUrl,
|
|
349
336
|
setDefaultLocale,
|
|
350
337
|
signTone,
|
|
@@ -371,7 +358,6 @@ export {
|
|
|
371
358
|
useSaveStatus,
|
|
372
359
|
useScrollEdges,
|
|
373
360
|
useScrollSpy,
|
|
374
|
-
useServiceTokens,
|
|
375
361
|
useStuck,
|
|
376
362
|
useTheme,
|
|
377
363
|
useToast,
|
package/dist/esm/runtime.js
CHANGED
package/dist/esm/theme.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { DEFAULT_THEME, THEMES } from "./tokens.mjs";
|
|
3
3
|
import { shared } from "./runtime.js";
|
|
4
4
|
import { safeUrl } from "./url.js";
|
|
5
|
-
import {
|
|
5
|
+
import { DISPLAY_STRINGS, OVERLAY_STRINGS, THEME_STRINGS } from "./components/strings.js";
|
|
6
6
|
function buildPresets() {
|
|
7
7
|
return Object.keys(THEMES).map((id) => ({
|
|
8
8
|
id,
|
|
@@ -201,9 +201,9 @@ var TOGGLE_ICONS = {
|
|
|
201
201
|
dark: [["path", { d: "M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9" }]]
|
|
202
202
|
};
|
|
203
203
|
var defaultToggleLabels = () => ({
|
|
204
|
-
system:
|
|
205
|
-
light:
|
|
206
|
-
dark:
|
|
204
|
+
system: THEME_STRINGS.themeSystem,
|
|
205
|
+
light: THEME_STRINGS.themeLight,
|
|
206
|
+
dark: THEME_STRINGS.themeDark
|
|
207
207
|
});
|
|
208
208
|
var DEFAULT_ELSEWHERE = "set on another site";
|
|
209
209
|
function nextChoice(choice) {
|
|
@@ -217,7 +217,7 @@ function themeLabel(choice, words) {
|
|
|
217
217
|
}
|
|
218
218
|
function mountThemeToggle(button, opts = {}) {
|
|
219
219
|
const words = { ...defaultToggleLabels(), ...opts.labels };
|
|
220
|
-
const sentence = opts.strings?.themeToggleLabel ??
|
|
220
|
+
const sentence = opts.strings?.themeToggleLabel ?? THEME_STRINGS.themeToggleLabel;
|
|
221
221
|
const elsewhereWords = opts.elsewhereLabel ?? DEFAULT_ELSEWHERE;
|
|
222
222
|
if (button.tagName === "BUTTON" && !button.getAttribute("type")) button.setAttribute("type", "button");
|
|
223
223
|
const children = Object.keys(TOGGLE_ICONS).map(
|
|
@@ -341,7 +341,7 @@ function showToast(content, opts = {}) {
|
|
|
341
341
|
const close = document.createElement("button");
|
|
342
342
|
close.type = "button";
|
|
343
343
|
close.className = "nish-toast-close";
|
|
344
|
-
close.setAttribute("aria-label", opts.dismissLabel ?? opts.strings?.dismiss ??
|
|
344
|
+
close.setAttribute("aria-label", opts.dismissLabel ?? opts.strings?.dismiss ?? DISPLAY_STRINGS.dismiss);
|
|
345
345
|
close.append(svgIcon(14, [["path", { d: "M18 6 6 18M6 6l12 12" }]]));
|
|
346
346
|
close.addEventListener("click", hide);
|
|
347
347
|
box.append(close);
|
|
@@ -391,7 +391,7 @@ function confirmDialog(opts) {
|
|
|
391
391
|
b.textContent = label;
|
|
392
392
|
return b;
|
|
393
393
|
};
|
|
394
|
-
const cancelBtn = button(opts.cancelLabel ?? opts.strings?.cancel ??
|
|
394
|
+
const cancelBtn = button(opts.cancelLabel ?? opts.strings?.cancel ?? OVERLAY_STRINGS.cancel, "nish-btn");
|
|
395
395
|
const confirmBtn = button(opts.confirmLabel ?? "Confirm", `nish-btn ${danger ? "nish-btn--danger" : "nish-btn--primary"}`);
|
|
396
396
|
(danger ? cancelBtn : confirmBtn).autofocus = true;
|
|
397
397
|
actions.append(cancelBtn, confirmBtn);
|
package/dist/format.js
CHANGED