nish-ui 1.8.0 → 2.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 +223 -61
- package/dist/base-tailwind.css +1757 -0
- package/dist/base.css +1590 -1445
- package/dist/chart.d.ts +4 -1
- package/dist/chart.js +122 -49
- package/dist/elements-all.d.ts +8 -0
- package/dist/elements-all.js +178 -0
- package/dist/elements-charts.d.ts +124 -2
- package/dist/elements-charts.js +131 -1
- package/dist/elements-data.d.ts +166 -2
- package/dist/elements-data.js +46 -1
- package/dist/elements-forms.d.ts +71 -0
- package/dist/elements-forms.js +24 -25
- package/dist/elements.d.ts +71 -0
- package/dist/elements.js +4 -5
- package/dist/esm/chart-values.js +58 -0
- package/dist/esm/chart.js +10 -0
- package/dist/esm/cn.js +19 -0
- package/dist/esm/combobox-filter.js +13 -0
- package/dist/esm/components/accordion.js +166 -0
- package/dist/esm/components/app-shell.js +198 -0
- package/dist/esm/components/avatar-classes.js +28 -0
- package/dist/esm/components/avatar.js +113 -0
- package/dist/esm/components/breadcrumbs.js +154 -0
- package/dist/esm/components/canvas/follow-caption.js +32 -0
- package/dist/esm/components/canvas/follow.js +119 -0
- package/dist/esm/components/canvas/icons.js +70 -0
- package/dist/esm/components/canvas/index.js +10 -0
- package/dist/esm/components/canvas/layout.js +258 -0
- package/dist/esm/components/canvas/legend.js +93 -0
- package/dist/esm/components/canvas/minimap.js +127 -0
- package/dist/esm/components/canvas/node.js +87 -0
- package/dist/esm/components/canvas/route.js +262 -0
- package/dist/esm/components/canvas/system-canvas.js +837 -0
- package/dist/esm/components/canvas/types.js +10 -0
- package/dist/esm/components/canvas/view.js +47 -0
- package/dist/esm/components/chart-hooks.js +19 -0
- package/dist/esm/components/charts.js +467 -0
- package/dist/esm/components/client.js +24 -0
- package/dist/esm/components/combobox.js +343 -0
- package/dist/esm/components/command.js +403 -0
- package/dist/esm/components/data-classes.js +159 -0
- package/dist/esm/components/data.js +517 -0
- package/dist/esm/components/display-classes.js +130 -0
- package/dist/esm/components/display.js +755 -0
- package/dist/esm/components/error-boundary.js +64 -0
- package/dist/esm/components/feedback.js +136 -0
- package/dist/esm/components/file-dropzone.js +184 -0
- package/dist/esm/components/filters.js +108 -0
- package/dist/esm/components/flow.js +746 -0
- package/dist/esm/components/forms-classes.js +43 -0
- package/dist/esm/components/forms.js +581 -0
- package/dist/esm/components/hooks-classes.js +9 -0
- package/dist/esm/components/hooks.js +236 -0
- package/dist/esm/components/icons.js +96 -0
- package/dist/esm/components/inbox-classes.js +29 -0
- package/dist/esm/components/inbox.js +257 -0
- package/dist/esm/components/latest.js +13 -0
- package/dist/esm/components/layout-vars.js +96 -0
- package/dist/esm/components/layout.js +272 -0
- package/dist/esm/components/media.js +143 -0
- package/dist/esm/components/nav.js +614 -0
- package/dist/esm/components/overlay-classes.js +66 -0
- package/dist/esm/components/overlay.js +1447 -0
- package/dist/esm/components/pagination-classes.js +29 -0
- package/dist/esm/components/pagination.js +154 -0
- package/dist/esm/components/portal.js +16 -0
- package/dist/esm/components/primitives-classes.js +198 -0
- package/dist/esm/components/primitives.js +268 -0
- package/dist/esm/components/progress.js +77 -0
- package/dist/esm/components/provider.js +32 -0
- package/dist/esm/components/radio-group.js +186 -0
- package/dist/esm/components/resource-classes.js +133 -0
- package/dist/esm/components/resource.js +209 -0
- package/dist/esm/components/segmented.js +178 -0
- package/dist/esm/components/separator.js +38 -0
- package/dist/esm/components/service-tokens.js +221 -0
- package/dist/esm/components/settings.js +301 -0
- package/dist/esm/components/slider.js +262 -0
- package/dist/esm/components/split-classes.js +8 -0
- package/dist/esm/components/split.js +411 -0
- package/dist/esm/components/strings.js +119 -0
- package/dist/esm/components/table.js +144 -0
- package/dist/esm/components/tabs-classes.js +21 -0
- package/dist/esm/components/tabs.js +201 -0
- package/dist/esm/components/tag-input.js +257 -0
- package/dist/esm/components/theme-toggle.js +177 -0
- package/dist/esm/components/toast.js +361 -0
- package/dist/esm/components/url-state.js +118 -0
- package/dist/esm/components/visually-hidden.js +20 -0
- package/dist/esm/format.js +320 -0
- package/dist/esm/inbox-client.js +2 -0
- package/dist/esm/inbox-types.js +2 -0
- package/dist/esm/index.js +320 -0
- package/dist/esm/runtime.js +37 -0
- package/dist/esm/server/inbox/client.js +297 -0
- package/dist/esm/server/inbox/types.js +24 -0
- package/dist/esm/sparkline-path.js +59 -0
- package/dist/esm/split-layout.js +419 -0
- package/dist/esm/system-canvas.js +2 -0
- package/dist/esm/theme.js +804 -0
- package/dist/esm/tokens.mjs +425 -0
- package/dist/esm/url.js +20 -0
- package/dist/files.json +5 -1
- package/dist/fonts/LICENSE-Inter.txt +93 -0
- package/dist/format.d.ts +32 -18
- package/dist/format.js +227 -82
- package/dist/inbox-client.js +3 -1
- package/dist/index.d.ts +1689 -667
- package/dist/nish-components.css +4701 -3169
- package/dist/nish-components.min.css +1 -0
- package/dist/nish.css +1603 -1450
- package/dist/nish.min.css +1 -0
- package/dist/node/eslint.js +29 -14
- package/dist/node/th-check.js +29 -14
- package/dist/node/vite.d.ts +12 -0
- package/dist/node/vite.js +12 -2
- package/dist/server/hono.d.ts +15 -6
- package/dist/server/hono.js +30 -25
- package/dist/server/index.d.ts +3 -10
- package/dist/server/index.js +71 -38
- package/dist/{spa-DuVB5O7S.d.ts → spa-BLlMc0eI.d.ts} +38 -5
- package/dist/system-canvas-BLuWd69H.d.ts +183 -0
- package/dist/system-canvas.d.ts +2 -168
- package/dist/tailwind-core.css +114 -0
- package/dist/tailwind.css +3 -7
- package/dist/theme-init.js +23 -9
- package/dist/theme-init.sha256 +1 -0
- package/dist/theme.d.ts +246 -4
- package/dist/theme.global.js +357 -90
- package/dist/theme.js +338 -68
- package/dist/tokens.css +14 -6
- package/dist/tokens.dtcg.json +1513 -0
- package/dist/tokens.js +29 -14
- package/dist/tokens.json +512 -0
- package/package.json +51 -13
- package/dist/chart.js.map +0 -1
- package/dist/elements-charts.js.map +0 -1
- package/dist/elements-data.js.map +0 -1
- package/dist/elements-forms.js.map +0 -1
- package/dist/elements.js.map +0 -1
- package/dist/format.js.map +0 -1
- package/dist/inbox-client.js.map +0 -1
- package/dist/index.js +0 -10260
- package/dist/index.js.map +0 -1
- package/dist/server/hono.js.map +0 -1
- package/dist/server/index.js.map +0 -1
- package/dist/split-layout.js.map +0 -1
- package/dist/system-canvas.js +0 -2204
- package/dist/system-canvas.js.map +0 -1
- package/dist/theme.global.js.map +0 -1
- package/dist/theme.js.map +0 -1
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/components/hooks.tsx
|
|
4
|
+
import {
|
|
5
|
+
useCallback,
|
|
6
|
+
useEffect,
|
|
7
|
+
useMemo,
|
|
8
|
+
useState,
|
|
9
|
+
useSyncExternalStore
|
|
10
|
+
} from "react";
|
|
11
|
+
import { cn } from "../cn.js";
|
|
12
|
+
import { ago, dateTime } from "../format.js";
|
|
13
|
+
import { BREAKPOINTS, NARROW_QUERY, PHONE_QUERY } from "./hooks-classes.js";
|
|
14
|
+
import { useNishConfig } from "./provider.js";
|
|
15
|
+
import { jsx } from "react/jsx-runtime";
|
|
16
|
+
var queries = /* @__PURE__ */ new Map();
|
|
17
|
+
function hasMatchMedia() {
|
|
18
|
+
return typeof window !== "undefined" && typeof window.matchMedia === "function";
|
|
19
|
+
}
|
|
20
|
+
function subscribeQuery(query, cb) {
|
|
21
|
+
if (!hasMatchMedia()) return () => {
|
|
22
|
+
};
|
|
23
|
+
let entry = queries.get(query);
|
|
24
|
+
if (!entry) {
|
|
25
|
+
const mql = window.matchMedia(query);
|
|
26
|
+
const created = {
|
|
27
|
+
mql,
|
|
28
|
+
matches: mql.matches,
|
|
29
|
+
subs: /* @__PURE__ */ new Set(),
|
|
30
|
+
onChange: () => {
|
|
31
|
+
created.matches = mql.matches;
|
|
32
|
+
created.subs.forEach((fn) => fn());
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
mql.addEventListener("change", created.onChange);
|
|
36
|
+
queries.set(query, created);
|
|
37
|
+
entry = created;
|
|
38
|
+
}
|
|
39
|
+
const owner = entry;
|
|
40
|
+
owner.subs.add(cb);
|
|
41
|
+
return () => {
|
|
42
|
+
owner.subs.delete(cb);
|
|
43
|
+
if (owner.subs.size === 0) {
|
|
44
|
+
owner.mql.removeEventListener("change", owner.onChange);
|
|
45
|
+
if (queries.get(query) === owner) queries.delete(query);
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
function queryMatches(query) {
|
|
50
|
+
return queries.get(query)?.matches ?? false;
|
|
51
|
+
}
|
|
52
|
+
function useMediaQuery(query) {
|
|
53
|
+
const subscribe = useCallback((onChange) => subscribeQuery(query, onChange), [query]);
|
|
54
|
+
const get = useCallback(() => queryMatches(query), [query]);
|
|
55
|
+
return useSyncExternalStore(subscribe, get, () => false);
|
|
56
|
+
}
|
|
57
|
+
var BREAKPOINT_QUERIES = ["xl", "lg", "md", "sm"].map((name) => [
|
|
58
|
+
name,
|
|
59
|
+
`(min-width: ${BREAKPOINTS[name]}px)`
|
|
60
|
+
]);
|
|
61
|
+
function usePhone() {
|
|
62
|
+
return useMediaQuery(PHONE_QUERY);
|
|
63
|
+
}
|
|
64
|
+
function useNarrow() {
|
|
65
|
+
return useMediaQuery(NARROW_QUERY);
|
|
66
|
+
}
|
|
67
|
+
function currentBreakpoint() {
|
|
68
|
+
for (const [name, q] of BREAKPOINT_QUERIES) if (queryMatches(q)) return name;
|
|
69
|
+
return "base";
|
|
70
|
+
}
|
|
71
|
+
function subscribeBreakpoint(onChange) {
|
|
72
|
+
const stops = BREAKPOINT_QUERIES.map(([, q]) => subscribeQuery(q, onChange));
|
|
73
|
+
return () => stops.forEach((stop) => stop());
|
|
74
|
+
}
|
|
75
|
+
function useBreakpoint() {
|
|
76
|
+
return useSyncExternalStore(subscribeBreakpoint, currentBreakpoint, () => "base");
|
|
77
|
+
}
|
|
78
|
+
function useDocumentTitle(title, o = {}) {
|
|
79
|
+
const app = o.app;
|
|
80
|
+
useEffect(() => {
|
|
81
|
+
if (typeof document === "undefined") return;
|
|
82
|
+
const next = title && app ? `${title} \xB7 ${app}` : title || app;
|
|
83
|
+
if (!next) return;
|
|
84
|
+
const previous = document.title;
|
|
85
|
+
document.title = next;
|
|
86
|
+
return () => {
|
|
87
|
+
document.title = previous;
|
|
88
|
+
};
|
|
89
|
+
}, [title, app]);
|
|
90
|
+
}
|
|
91
|
+
function useNow(intervalMs = 3e4) {
|
|
92
|
+
const [now, setNow] = useState(() => Date.now());
|
|
93
|
+
useEffect(() => {
|
|
94
|
+
if (typeof document === "undefined") return;
|
|
95
|
+
let id;
|
|
96
|
+
const start = () => {
|
|
97
|
+
if (id === void 0) id = setInterval(() => setNow(Date.now()), intervalMs);
|
|
98
|
+
};
|
|
99
|
+
const stop = () => {
|
|
100
|
+
if (id !== void 0) clearInterval(id);
|
|
101
|
+
id = void 0;
|
|
102
|
+
};
|
|
103
|
+
const onVisibility = () => {
|
|
104
|
+
if (document.visibilityState === "visible") {
|
|
105
|
+
setNow(Date.now());
|
|
106
|
+
start();
|
|
107
|
+
} else stop();
|
|
108
|
+
};
|
|
109
|
+
if (document.visibilityState !== "hidden") start();
|
|
110
|
+
document.addEventListener("visibilitychange", onVisibility);
|
|
111
|
+
return () => {
|
|
112
|
+
stop();
|
|
113
|
+
document.removeEventListener("visibilitychange", onVisibility);
|
|
114
|
+
};
|
|
115
|
+
}, [intervalMs]);
|
|
116
|
+
return now;
|
|
117
|
+
}
|
|
118
|
+
var storeSubs = /* @__PURE__ */ new Map();
|
|
119
|
+
var memory = /* @__PURE__ */ new Map();
|
|
120
|
+
var warned = /* @__PURE__ */ new Set();
|
|
121
|
+
var storageListening = false;
|
|
122
|
+
function notify(key) {
|
|
123
|
+
if (key === null) storeSubs.forEach((set) => set.forEach((fn) => fn()));
|
|
124
|
+
else storeSubs.get(key)?.forEach((fn) => fn());
|
|
125
|
+
}
|
|
126
|
+
function onStorageEvent(e) {
|
|
127
|
+
if (e.key !== null) memory.delete(e.key);
|
|
128
|
+
else memory.clear();
|
|
129
|
+
notify(e.key);
|
|
130
|
+
}
|
|
131
|
+
function subscribeKey(key, cb) {
|
|
132
|
+
if (typeof window === "undefined") return () => {
|
|
133
|
+
};
|
|
134
|
+
let set = storeSubs.get(key);
|
|
135
|
+
if (!set) storeSubs.set(key, set = /* @__PURE__ */ new Set());
|
|
136
|
+
const subs = set;
|
|
137
|
+
subs.add(cb);
|
|
138
|
+
if (!storageListening) {
|
|
139
|
+
storageListening = true;
|
|
140
|
+
window.addEventListener("storage", onStorageEvent);
|
|
141
|
+
}
|
|
142
|
+
return () => {
|
|
143
|
+
subs.delete(cb);
|
|
144
|
+
if (subs.size === 0 && storeSubs.get(key) === subs) storeSubs.delete(key);
|
|
145
|
+
if (storeSubs.size === 0 && storageListening) {
|
|
146
|
+
storageListening = false;
|
|
147
|
+
window.removeEventListener("storage", onStorageEvent);
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
function readText(key) {
|
|
152
|
+
const kept = memory.get(key);
|
|
153
|
+
if (kept !== void 0) return kept;
|
|
154
|
+
try {
|
|
155
|
+
return window.localStorage.getItem(key);
|
|
156
|
+
} catch {
|
|
157
|
+
return null;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
function parseStored(key, text, initial, raw) {
|
|
161
|
+
if (text === null) return initial;
|
|
162
|
+
if (raw) return text;
|
|
163
|
+
try {
|
|
164
|
+
return JSON.parse(text);
|
|
165
|
+
} catch {
|
|
166
|
+
const id = key + "\0" + text;
|
|
167
|
+
if (globalThis.process?.env?.NODE_ENV !== "production" && !warned.has(id)) {
|
|
168
|
+
warned.add(id);
|
|
169
|
+
console.warn(`nish-ui: useLocalStorage("${key}") found text that is not valid JSON; using the initial value.`);
|
|
170
|
+
}
|
|
171
|
+
return initial;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
function useLocalStorage(key, initial, o = {}) {
|
|
175
|
+
const raw = !!o.raw;
|
|
176
|
+
const [first] = useState(() => initial);
|
|
177
|
+
const subscribe = useCallback((onChange) => subscribeKey(key, onChange), [key]);
|
|
178
|
+
const get = useCallback(() => readText(key), [key]);
|
|
179
|
+
const text = useSyncExternalStore(subscribe, get, () => null);
|
|
180
|
+
const value = useMemo(() => parseStored(key, text, first, raw), [key, text, first, raw]);
|
|
181
|
+
const setValue = useCallback(
|
|
182
|
+
(next) => {
|
|
183
|
+
const resolved = typeof next === "function" ? next(parseStored(key, readText(key), first, raw)) : next;
|
|
184
|
+
const out = raw ? String(resolved) : JSON.stringify(resolved);
|
|
185
|
+
try {
|
|
186
|
+
window.localStorage.setItem(key, out);
|
|
187
|
+
memory.delete(key);
|
|
188
|
+
} catch {
|
|
189
|
+
memory.set(key, out);
|
|
190
|
+
}
|
|
191
|
+
notify(key);
|
|
192
|
+
},
|
|
193
|
+
[key, raw, first]
|
|
194
|
+
);
|
|
195
|
+
return [value, setValue];
|
|
196
|
+
}
|
|
197
|
+
function RelativeTime({
|
|
198
|
+
value,
|
|
199
|
+
style: textStyle = "short",
|
|
200
|
+
refreshMs = 3e4,
|
|
201
|
+
locale,
|
|
202
|
+
className,
|
|
203
|
+
ref,
|
|
204
|
+
...rest
|
|
205
|
+
}) {
|
|
206
|
+
const now = useNow(refreshMs);
|
|
207
|
+
const config = useNishConfig();
|
|
208
|
+
const loc = locale ?? config.locale;
|
|
209
|
+
const d = new Date(value);
|
|
210
|
+
const iso = Number.isNaN(d.getTime()) ? void 0 : d.toISOString();
|
|
211
|
+
return /* @__PURE__ */ jsx(
|
|
212
|
+
"time",
|
|
213
|
+
{
|
|
214
|
+
...rest,
|
|
215
|
+
ref,
|
|
216
|
+
dateTime: iso,
|
|
217
|
+
title: dateTime(value, { locale: loc }),
|
|
218
|
+
className: cn("tabular-nums", className),
|
|
219
|
+
suppressHydrationWarning: true,
|
|
220
|
+
children: ago(value, { now, style: textStyle, locale: loc })
|
|
221
|
+
}
|
|
222
|
+
);
|
|
223
|
+
}
|
|
224
|
+
export {
|
|
225
|
+
BREAKPOINTS,
|
|
226
|
+
NARROW_QUERY,
|
|
227
|
+
PHONE_QUERY,
|
|
228
|
+
RelativeTime,
|
|
229
|
+
useBreakpoint,
|
|
230
|
+
useDocumentTitle,
|
|
231
|
+
useLocalStorage,
|
|
232
|
+
useMediaQuery,
|
|
233
|
+
useNarrow,
|
|
234
|
+
useNow,
|
|
235
|
+
usePhone
|
|
236
|
+
};
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
// src/components/icons.tsx
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
function Svg({ size = 16, children, ...rest }) {
|
|
4
|
+
return /* @__PURE__ */ jsx(
|
|
5
|
+
"svg",
|
|
6
|
+
{
|
|
7
|
+
width: size,
|
|
8
|
+
height: size,
|
|
9
|
+
viewBox: "0 0 24 24",
|
|
10
|
+
fill: "none",
|
|
11
|
+
stroke: "currentColor",
|
|
12
|
+
strokeWidth: 2,
|
|
13
|
+
strokeLinecap: "round",
|
|
14
|
+
strokeLinejoin: "round",
|
|
15
|
+
"aria-hidden": "true",
|
|
16
|
+
focusable: "false",
|
|
17
|
+
...rest,
|
|
18
|
+
children
|
|
19
|
+
}
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
var XIcon = (p) => /* @__PURE__ */ jsx(Svg, { ...p, children: /* @__PURE__ */ jsx("path", { d: "M18 6 6 18M6 6l12 12" }) });
|
|
23
|
+
var CheckCircleIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
|
|
24
|
+
/* @__PURE__ */ jsx("circle", { cx: "12", cy: "12", r: "10" }),
|
|
25
|
+
/* @__PURE__ */ jsx("path", { d: "m9 12 2 2 4-4" })
|
|
26
|
+
] });
|
|
27
|
+
var AlertTriangleIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
|
|
28
|
+
/* @__PURE__ */ jsx("path", { d: "m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3" }),
|
|
29
|
+
/* @__PURE__ */ jsx("path", { d: "M12 9v4M12 17h.01" })
|
|
30
|
+
] });
|
|
31
|
+
var InfoIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
|
|
32
|
+
/* @__PURE__ */ jsx("circle", { cx: "12", cy: "12", r: "10" }),
|
|
33
|
+
/* @__PURE__ */ jsx("path", { d: "M12 16v-4M12 8h.01" })
|
|
34
|
+
] });
|
|
35
|
+
var RotateIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
|
|
36
|
+
/* @__PURE__ */ jsx("path", { d: "M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8" }),
|
|
37
|
+
/* @__PURE__ */ jsx("path", { d: "M21 3v5h-5" })
|
|
38
|
+
] });
|
|
39
|
+
var LoaderIcon = (p) => /* @__PURE__ */ jsx(Svg, { ...p, children: /* @__PURE__ */ jsx("path", { d: "M21 12a9 9 0 1 1-6.22-8.56" }) });
|
|
40
|
+
var SunIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
|
|
41
|
+
/* @__PURE__ */ jsx("circle", { cx: "12", cy: "12", r: "4" }),
|
|
42
|
+
/* @__PURE__ */ jsx("path", { d: "M12 2v2M12 20v2m-7.07-2.93 1.41-1.41M17.66 6.34l1.41-1.41M2 12h2m16 0h2M4.93 4.93l1.41 1.41m11.32 11.32 1.41 1.41" })
|
|
43
|
+
] });
|
|
44
|
+
var MoonIcon = (p) => /* @__PURE__ */ jsx(Svg, { ...p, children: /* @__PURE__ */ jsx("path", { d: "M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9" }) });
|
|
45
|
+
var MonitorIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
|
|
46
|
+
/* @__PURE__ */ jsx("rect", { width: "20", height: "14", x: "2", y: "3", rx: "2" }),
|
|
47
|
+
/* @__PURE__ */ jsx("path", { d: "M8 21h8M12 17v4" })
|
|
48
|
+
] });
|
|
49
|
+
var ChevronDownIcon = (p) => /* @__PURE__ */ jsx(Svg, { ...p, children: /* @__PURE__ */ jsx("path", { d: "m6 9 6 6 6-6" }) });
|
|
50
|
+
var CheckIcon = (p) => /* @__PURE__ */ jsx(Svg, { ...p, children: /* @__PURE__ */ jsx("path", { d: "M20 6 9 17l-5-5" }) });
|
|
51
|
+
var ClockIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
|
|
52
|
+
/* @__PURE__ */ jsx("circle", { cx: "12", cy: "12", r: "10" }),
|
|
53
|
+
/* @__PURE__ */ jsx("path", { d: "M12 6v6l4 2" })
|
|
54
|
+
] });
|
|
55
|
+
var MoreIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
|
|
56
|
+
/* @__PURE__ */ jsx("circle", { cx: "12", cy: "12", r: "1" }),
|
|
57
|
+
/* @__PURE__ */ jsx("circle", { cx: "19", cy: "12", r: "1" }),
|
|
58
|
+
/* @__PURE__ */ jsx("circle", { cx: "5", cy: "12", r: "1" })
|
|
59
|
+
] });
|
|
60
|
+
var BellIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
|
|
61
|
+
/* @__PURE__ */ jsx("path", { d: "M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9" }),
|
|
62
|
+
/* @__PURE__ */ jsx("path", { d: "M10.3 21a1.94 1.94 0 0 0 3.4 0" })
|
|
63
|
+
] });
|
|
64
|
+
var SettingsIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
|
|
65
|
+
/* @__PURE__ */ jsx("path", { d: "M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z" }),
|
|
66
|
+
/* @__PURE__ */ jsx("circle", { cx: "12", cy: "12", r: "3" })
|
|
67
|
+
] });
|
|
68
|
+
var PanelLeftCloseIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
|
|
69
|
+
/* @__PURE__ */ jsx("rect", { width: "18", height: "18", x: "3", y: "3", rx: "2" }),
|
|
70
|
+
/* @__PURE__ */ jsx("path", { d: "M9 3v18" }),
|
|
71
|
+
/* @__PURE__ */ jsx("path", { d: "m16 15-3-3 3-3" })
|
|
72
|
+
] });
|
|
73
|
+
var PanelLeftOpenIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
|
|
74
|
+
/* @__PURE__ */ jsx("rect", { width: "18", height: "18", x: "3", y: "3", rx: "2" }),
|
|
75
|
+
/* @__PURE__ */ jsx("path", { d: "M9 3v18" }),
|
|
76
|
+
/* @__PURE__ */ jsx("path", { d: "m14 9 3 3-3 3" })
|
|
77
|
+
] });
|
|
78
|
+
export {
|
|
79
|
+
AlertTriangleIcon,
|
|
80
|
+
BellIcon,
|
|
81
|
+
CheckCircleIcon,
|
|
82
|
+
CheckIcon,
|
|
83
|
+
ChevronDownIcon,
|
|
84
|
+
ClockIcon,
|
|
85
|
+
InfoIcon,
|
|
86
|
+
LoaderIcon,
|
|
87
|
+
MonitorIcon,
|
|
88
|
+
MoonIcon,
|
|
89
|
+
MoreIcon,
|
|
90
|
+
PanelLeftCloseIcon,
|
|
91
|
+
PanelLeftOpenIcon,
|
|
92
|
+
RotateIcon,
|
|
93
|
+
SettingsIcon,
|
|
94
|
+
SunIcon,
|
|
95
|
+
XIcon
|
|
96
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// src/components/inbox-classes.ts
|
|
2
|
+
var DEFAULT_INBOX_LABELS = {
|
|
3
|
+
urgent: "Urgent",
|
|
4
|
+
normal: "Normal",
|
|
5
|
+
info: "Info",
|
|
6
|
+
snooze1h: "1 hour",
|
|
7
|
+
snooze4h: "4 hours",
|
|
8
|
+
snoozeTomorrow: "Tomorrow 8 AM",
|
|
9
|
+
snoozeMonday: "Monday 8 AM",
|
|
10
|
+
unsnooze: "Unsnooze",
|
|
11
|
+
moveBack: "Move back",
|
|
12
|
+
markAllHandled: "Mark all handled",
|
|
13
|
+
markAllTitle: (n) => `Mark ${n} ${n === 1 ? "item" : "items"} handled?`,
|
|
14
|
+
all: "All",
|
|
15
|
+
loadMore: "Load more",
|
|
16
|
+
less: "Less",
|
|
17
|
+
until: (when) => `Until ${when}`,
|
|
18
|
+
handledAgo: (when) => `Handled ${when}`,
|
|
19
|
+
handledByApp: " by the app",
|
|
20
|
+
handledAutomatically: " automatically",
|
|
21
|
+
actionRan: (label, at) => `${label} ran ${at}`,
|
|
22
|
+
actionFailed: (label, at, why) => `${label} failed ${at}${why ? ` \xB7 ${why}` : ""}`,
|
|
23
|
+
emptyOpen: (src) => `Nothing open${src ? ` from ${src}` : ""}`,
|
|
24
|
+
emptySnoozed: (src) => `Nothing snoozed${src ? ` from ${src}` : ""}`,
|
|
25
|
+
emptyHandled: (src) => `Nothing handled${src ? ` from ${src}` : ""} in the last 30 days`
|
|
26
|
+
};
|
|
27
|
+
export {
|
|
28
|
+
DEFAULT_INBOX_LABELS
|
|
29
|
+
};
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/components/inbox.tsx
|
|
4
|
+
import { useEffect, useId, useRef, useState } from "react";
|
|
5
|
+
import { cn } from "../cn.js";
|
|
6
|
+
import { ago, dateTime, time } from "../format.js";
|
|
7
|
+
import { INBOX_SOURCE_LABELS } from "../inbox-types.js";
|
|
8
|
+
import { safeUrl } from "../url.js";
|
|
9
|
+
import { ChipGroup, Chip } from "./forms.js";
|
|
10
|
+
import { StatusDot } from "./display.js";
|
|
11
|
+
import { EmptyState, ErrorState, SkeletonRows } from "./feedback.js";
|
|
12
|
+
import { RelativeTime, useMediaQuery } from "./hooks.js";
|
|
13
|
+
import { CheckIcon, ClockIcon, MoreIcon } from "./icons.js";
|
|
14
|
+
import { ConfirmDialog, DropdownMenu, MenuItem, MenuLabel, MenuSeparator } from "./overlay.js";
|
|
15
|
+
import { Button, Card, IconButton } from "./primitives.js";
|
|
16
|
+
import { useNishStrings } from "./provider.js";
|
|
17
|
+
import { Tabs } from "./tabs.js";
|
|
18
|
+
import { DEFAULT_INBOX_LABELS } from "./inbox-classes.js";
|
|
19
|
+
import { DEFAULT_INBOX_LABELS as DEFAULT_INBOX_LABELS2 } from "./inbox-classes.js";
|
|
20
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
21
|
+
var DOT_TONE = {
|
|
22
|
+
urgent: "loss",
|
|
23
|
+
normal: "accent",
|
|
24
|
+
info: "neutral"
|
|
25
|
+
};
|
|
26
|
+
function at8(now, days) {
|
|
27
|
+
const d = new Date(now);
|
|
28
|
+
d.setDate(d.getDate() + days);
|
|
29
|
+
d.setHours(8, 0, 0, 0);
|
|
30
|
+
return d;
|
|
31
|
+
}
|
|
32
|
+
var SNOOZE_OPTIONS = [
|
|
33
|
+
{ id: "snooze1h", until: (now) => new Date(now.getTime() + 36e5) },
|
|
34
|
+
{ id: "snooze4h", until: (now) => new Date(now.getTime() + 4 * 36e5) },
|
|
35
|
+
{ id: "snoozeTomorrow", until: (now) => at8(now, 1) },
|
|
36
|
+
// The next Monday; a week ahead when today is Monday.
|
|
37
|
+
{ id: "snoozeMonday", until: (now) => at8(now, (8 - now.getDay()) % 7 || 7) }
|
|
38
|
+
];
|
|
39
|
+
function looksClamped(body) {
|
|
40
|
+
return body.length > 100 || body.split("\n").length > 3;
|
|
41
|
+
}
|
|
42
|
+
function lastActionText(result, item, labels) {
|
|
43
|
+
const label = item.actions?.find((a) => a.id === result.actionId)?.label ?? result.actionId;
|
|
44
|
+
const ms = Date.parse(result.at);
|
|
45
|
+
const at = new Date(ms).toDateString() === (/* @__PURE__ */ new Date()).toDateString() ? time(ms) : dateTime(ms);
|
|
46
|
+
if (result.ok) return labels.actionRan(label, at);
|
|
47
|
+
const why = result.error ?? (result.status != null ? `HTTP ${result.status}` : null);
|
|
48
|
+
return labels.actionFailed(label, at, why);
|
|
49
|
+
}
|
|
50
|
+
function Row({ item, view, label, wide, selected, expanded, domId, onToggle, onHandle, onUnhandle, onSnooze, onUnsnooze, running, onAction, labels, strings }) {
|
|
51
|
+
const severity = item.severity in DOT_TONE ? item.severity : "normal";
|
|
52
|
+
const dot = { tone: DOT_TONE[severity], label: labels[severity] };
|
|
53
|
+
const long = item.body != null && looksClamped(item.body);
|
|
54
|
+
const href = item.url ? safeUrl(item.url) : null;
|
|
55
|
+
const actions = onAction && view !== "handled" ? item.actions ?? [] : [];
|
|
56
|
+
const last = item.lastAction ?? null;
|
|
57
|
+
const snoozeItems = SNOOZE_OPTIONS.map((o) => /* @__PURE__ */ jsx(MenuItem, { icon: wide ? void 0 : /* @__PURE__ */ jsx(ClockIcon, { size: 14 }), onSelect: () => onSnooze(item.id, o.until(/* @__PURE__ */ new Date())), children: labels[o.id] }, o.id));
|
|
58
|
+
return /* @__PURE__ */ jsxs(
|
|
59
|
+
"li",
|
|
60
|
+
{
|
|
61
|
+
id: domId,
|
|
62
|
+
"data-selected": selected || void 0,
|
|
63
|
+
className: cn("flex items-start gap-3 px-4 py-3", selected && "bg-th-accent-soft forced-colors:outline forced-colors:outline-2 forced-colors:-outline-offset-2 forced-colors:outline-[Highlight]"),
|
|
64
|
+
children: [
|
|
65
|
+
/* @__PURE__ */ jsx(StatusDot, { tone: dot.tone, label: dot.label, className: "mt-1.5 shrink-0" }),
|
|
66
|
+
/* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1", children: [
|
|
67
|
+
/* @__PURE__ */ jsxs("div", { className: cn("flex flex-wrap items-center gap-x-2 text-xs", selected ? "text-th-hi2" : "text-th-hi3"), children: [
|
|
68
|
+
/* @__PURE__ */ jsx("span", { children: label }),
|
|
69
|
+
/* @__PURE__ */ jsx(RelativeTime, { value: item.updatedAt, style: "short" }),
|
|
70
|
+
item.count > 1 ? /* @__PURE__ */ jsxs("span", { role: "img", "aria-label": strings.inboxHappened(item.count), className: "tabular-nums", children: [
|
|
71
|
+
"\xD7",
|
|
72
|
+
item.count
|
|
73
|
+
] }) : null
|
|
74
|
+
] }),
|
|
75
|
+
/* @__PURE__ */ jsx("p", { className: "m-0 line-clamp-2 break-words text-sm font-medium text-th-hi", children: href ? /* @__PURE__ */ jsx("a", { href, target: "_blank", rel: "noopener noreferrer", className: "break-words hover:underline", children: item.title }) : item.title }),
|
|
76
|
+
item.body ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
77
|
+
/* @__PURE__ */ jsx("p", { className: cn("m-0 mt-0.5 whitespace-pre-line break-words text-sm text-th-hi2", !expanded && "line-clamp-3"), children: item.body }),
|
|
78
|
+
long ? /* @__PURE__ */ jsx(Button, { variant: "link", size: "sm", className: "pointer-coarse:-mx-2 pointer-coarse:min-h-11 pointer-coarse:px-2", "aria-expanded": expanded, onClick: () => onToggle(item.id), children: expanded ? labels.less : strings.more }) : null
|
|
79
|
+
] }) : null,
|
|
80
|
+
actions.length > 0 ? /* @__PURE__ */ jsx("div", { className: "mt-2 flex flex-wrap gap-2", children: actions.map((a) => /* @__PURE__ */ jsx(
|
|
81
|
+
Button,
|
|
82
|
+
{
|
|
83
|
+
size: "sm",
|
|
84
|
+
variant: "secondary",
|
|
85
|
+
loading: running === a.id,
|
|
86
|
+
disabled: running !== null && running !== a.id,
|
|
87
|
+
onClick: () => onAction?.(item.id, a.id),
|
|
88
|
+
children: a.label
|
|
89
|
+
},
|
|
90
|
+
a.id
|
|
91
|
+
)) }) : null,
|
|
92
|
+
last && (actions.length > 0 || view === "handled") ? /* @__PURE__ */ jsx("p", { className: cn("m-0 mt-1 text-xs", last.ok ? "text-th-hi3" : "text-th-loss"), children: lastActionText(last, item, labels) }) : null,
|
|
93
|
+
view === "snoozed" && item.snoozedUntil ? /* @__PURE__ */ jsx("p", { className: "m-0 mt-0.5 text-xs text-th-hi3", children: labels.until(dateTime(item.snoozedUntil)) }) : null,
|
|
94
|
+
view === "handled" && item.handledAt ? /* @__PURE__ */ jsxs("p", { className: "m-0 mt-0.5 text-xs text-th-hi3", children: [
|
|
95
|
+
labels.handledAgo(ago(item.handledAt)),
|
|
96
|
+
item.handledBy === "source" ? labels.handledByApp : item.handledBy === "expired" ? labels.handledAutomatically : ""
|
|
97
|
+
] }) : null
|
|
98
|
+
] }),
|
|
99
|
+
/* @__PURE__ */ jsxs("div", { className: "flex shrink-0 items-center gap-1", children: [
|
|
100
|
+
view === "open" && wide ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
101
|
+
/* @__PURE__ */ jsx(IconButton, { label: strings.inboxMarkHandled, onClick: () => onHandle(item.id), children: /* @__PURE__ */ jsx(CheckIcon, { size: 18 }) }),
|
|
102
|
+
/* @__PURE__ */ jsx(DropdownMenu, { align: "end", trigger: /* @__PURE__ */ jsx(IconButton, { label: strings.inboxSnooze, children: /* @__PURE__ */ jsx(ClockIcon, { size: 18 }) }), children: snoozeItems })
|
|
103
|
+
] }) : null,
|
|
104
|
+
view === "open" && !wide ? /* @__PURE__ */ jsxs(DropdownMenu, { align: "end", sheetBelow: "sm", sheetTitle: strings.inboxActions, trigger: /* @__PURE__ */ jsx(IconButton, { label: strings.inboxActions, children: /* @__PURE__ */ jsx(MoreIcon, { size: 18 }) }), children: [
|
|
105
|
+
/* @__PURE__ */ jsx(MenuItem, { icon: /* @__PURE__ */ jsx(CheckIcon, { size: 14 }), onSelect: () => onHandle(item.id), children: strings.inboxMarkHandled }),
|
|
106
|
+
/* @__PURE__ */ jsx(MenuSeparator, {}),
|
|
107
|
+
/* @__PURE__ */ jsx(MenuLabel, { children: strings.inboxSnooze }),
|
|
108
|
+
snoozeItems
|
|
109
|
+
] }) : null,
|
|
110
|
+
view === "snoozed" ? /* @__PURE__ */ jsx(Button, { size: "sm", onClick: () => onUnsnooze(item.id), children: labels.unsnooze }) : null,
|
|
111
|
+
view === "handled" ? /* @__PURE__ */ jsx(Button, { size: "sm", onClick: () => onUnhandle(item.id), children: labels.moveBack }) : null
|
|
112
|
+
] })
|
|
113
|
+
]
|
|
114
|
+
}
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
function Inbox({
|
|
118
|
+
items,
|
|
119
|
+
view,
|
|
120
|
+
onViewChange,
|
|
121
|
+
counts,
|
|
122
|
+
sources,
|
|
123
|
+
source,
|
|
124
|
+
onSourceChange,
|
|
125
|
+
onHandle,
|
|
126
|
+
onUnhandle,
|
|
127
|
+
onSnooze,
|
|
128
|
+
onUnsnooze,
|
|
129
|
+
onHandleAll,
|
|
130
|
+
onAction,
|
|
131
|
+
loading = false,
|
|
132
|
+
error = null,
|
|
133
|
+
onRetry,
|
|
134
|
+
hasMore = false,
|
|
135
|
+
onLoadMore,
|
|
136
|
+
loadingMore = false,
|
|
137
|
+
selectedId = null,
|
|
138
|
+
sourceLabels = INBOX_SOURCE_LABELS,
|
|
139
|
+
labels: labelOverrides,
|
|
140
|
+
className,
|
|
141
|
+
ref,
|
|
142
|
+
...rest
|
|
143
|
+
}) {
|
|
144
|
+
const strings = useNishStrings();
|
|
145
|
+
const labels = { ...DEFAULT_INBOX_LABELS, ...labelOverrides };
|
|
146
|
+
const idBase = useId().replace(/:/g, "");
|
|
147
|
+
const wide = useMediaQuery("(min-width: 480px)");
|
|
148
|
+
const [expanded, setExpanded] = useState(() => /* @__PURE__ */ new Set());
|
|
149
|
+
const [confirmAll, setConfirmAll] = useState(false);
|
|
150
|
+
const [running, setRunning] = useState(() => /* @__PURE__ */ new Map());
|
|
151
|
+
const scrolled = useRef(null);
|
|
152
|
+
const labelOf = (id) => sourceLabels[id] ?? id;
|
|
153
|
+
const rowId = (id) => `${idBase}-item-${id}`;
|
|
154
|
+
useEffect(() => {
|
|
155
|
+
if (selectedId == null || scrolled.current === selectedId) return;
|
|
156
|
+
const el = document.getElementById(rowId(selectedId));
|
|
157
|
+
if (!el) return;
|
|
158
|
+
scrolled.current = selectedId;
|
|
159
|
+
el.scrollIntoView({ block: "center" });
|
|
160
|
+
}, [selectedId, items]);
|
|
161
|
+
const toggle = (id) => setExpanded((prev) => {
|
|
162
|
+
const next = new Set(prev);
|
|
163
|
+
if (next.has(id)) next.delete(id);
|
|
164
|
+
else next.add(id);
|
|
165
|
+
return next;
|
|
166
|
+
});
|
|
167
|
+
const runAction = (itemId, actionId) => {
|
|
168
|
+
if (!onAction || running.has(itemId)) return;
|
|
169
|
+
setRunning((prev) => new Map(prev).set(itemId, actionId));
|
|
170
|
+
const done = () => setRunning((prev) => {
|
|
171
|
+
const next = new Map(prev);
|
|
172
|
+
next.delete(itemId);
|
|
173
|
+
return next;
|
|
174
|
+
});
|
|
175
|
+
Promise.resolve().then(() => onAction(itemId, actionId)).catch(() => void 0).finally(done);
|
|
176
|
+
};
|
|
177
|
+
const tabs = [
|
|
178
|
+
{ value: "open", label: strings.inboxOpen, count: counts.open },
|
|
179
|
+
{ value: "snoozed", label: strings.inboxSnoozed, count: counts.snoozed },
|
|
180
|
+
{ value: "handled", label: strings.inboxHandled }
|
|
181
|
+
];
|
|
182
|
+
const handleAllCount = source ? sources.find((s) => s.id === source)?.open ?? items.length : counts.open;
|
|
183
|
+
const showHandleAll = view === "open" && !!onHandleAll && items.length > 0 && !loading && !error;
|
|
184
|
+
let body;
|
|
185
|
+
if (loading) {
|
|
186
|
+
body = /* @__PURE__ */ jsx(SkeletonRows, { rows: 4, height: 64, label: strings.loading, className: "p-4" });
|
|
187
|
+
} else if (error) {
|
|
188
|
+
body = /* @__PURE__ */ jsx(ErrorState, { message: error, onRetry, retryLabel: strings.retry, compact: true, className: "py-8" });
|
|
189
|
+
} else if (items.length === 0) {
|
|
190
|
+
const from = source ? labelOf(source) : null;
|
|
191
|
+
const title = view === "open" ? labels.emptyOpen(from) : view === "snoozed" ? labels.emptySnoozed(from) : labels.emptyHandled(from);
|
|
192
|
+
body = /* @__PURE__ */ jsx(EmptyState, { title, compact: true, className: "py-10" });
|
|
193
|
+
} else {
|
|
194
|
+
body = /* @__PURE__ */ jsx("ul", { className: "m-0 list-none divide-y divide-th-line p-0", children: items.map((item) => /* @__PURE__ */ jsx(
|
|
195
|
+
Row,
|
|
196
|
+
{
|
|
197
|
+
item,
|
|
198
|
+
view,
|
|
199
|
+
label: labelOf(item.source),
|
|
200
|
+
wide,
|
|
201
|
+
labels,
|
|
202
|
+
strings,
|
|
203
|
+
selected: item.id === selectedId,
|
|
204
|
+
expanded: expanded.has(item.id),
|
|
205
|
+
domId: rowId(item.id),
|
|
206
|
+
onToggle: toggle,
|
|
207
|
+
onHandle,
|
|
208
|
+
onUnhandle,
|
|
209
|
+
onSnooze,
|
|
210
|
+
onUnsnooze,
|
|
211
|
+
running: running.get(item.id) ?? null,
|
|
212
|
+
onAction: onAction ? runAction : void 0
|
|
213
|
+
},
|
|
214
|
+
item.id
|
|
215
|
+
)) });
|
|
216
|
+
}
|
|
217
|
+
return /* @__PURE__ */ jsxs(Card, { ...rest, ref, padding: "none", className: cn("min-w-0 overflow-hidden", className), children: [
|
|
218
|
+
/* @__PURE__ */ jsx(Tabs, { label: strings.inboxViews, value: view, onValueChange: (v) => onViewChange(v), items: tabs, className: "px-4" }),
|
|
219
|
+
sources.length > 1 ? /* @__PURE__ */ jsx("div", { className: "min-w-0 border-b border-th-line py-2", children: /* @__PURE__ */ jsxs(ChipGroup, { label: strings.inboxFilterBySource, scroll: true, className: "px-4", children: [
|
|
220
|
+
/* @__PURE__ */ jsx(Chip, { size: "sm", pressed: source === null, onClick: () => onSourceChange(null), children: labels.all }),
|
|
221
|
+
sources.map((s) => /* @__PURE__ */ jsx(
|
|
222
|
+
Chip,
|
|
223
|
+
{
|
|
224
|
+
size: "sm",
|
|
225
|
+
pressed: source === s.id,
|
|
226
|
+
onClick: () => onSourceChange(s.id),
|
|
227
|
+
trailing: /* @__PURE__ */ jsx("span", { className: "tabular-nums text-th-hi3", children: s.open }),
|
|
228
|
+
className: "shrink-0",
|
|
229
|
+
children: labelOf(s.id)
|
|
230
|
+
},
|
|
231
|
+
s.id
|
|
232
|
+
))
|
|
233
|
+
] }) }) : null,
|
|
234
|
+
showHandleAll ? /* @__PURE__ */ jsx("div", { className: "flex justify-end px-4 pt-2", children: /* @__PURE__ */ jsx(Button, { size: "sm", variant: "ghost", onClick: () => setConfirmAll(true), children: labels.markAllHandled }) }) : null,
|
|
235
|
+
body,
|
|
236
|
+
hasMore && !loading && !error ? /* @__PURE__ */ jsx("div", { className: "flex justify-center border-t border-th-line p-2", children: /* @__PURE__ */ jsx(Button, { variant: "ghost", loading: loadingMore, onClick: onLoadMore, children: labels.loadMore }) }) : null,
|
|
237
|
+
confirmAll ? /* @__PURE__ */ jsx(
|
|
238
|
+
ConfirmDialog,
|
|
239
|
+
{
|
|
240
|
+
title: labels.markAllTitle(handleAllCount),
|
|
241
|
+
confirmLabel: strings.inboxMarkHandled,
|
|
242
|
+
cancelLabel: strings.cancel,
|
|
243
|
+
tone: "primary",
|
|
244
|
+
onCancel: () => setConfirmAll(false),
|
|
245
|
+
onConfirm: () => {
|
|
246
|
+
setConfirmAll(false);
|
|
247
|
+
onHandleAll?.();
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
) : null
|
|
251
|
+
] });
|
|
252
|
+
}
|
|
253
|
+
export {
|
|
254
|
+
DEFAULT_INBOX_LABELS2 as DEFAULT_INBOX_LABELS,
|
|
255
|
+
Inbox,
|
|
256
|
+
SNOOZE_OPTIONS
|
|
257
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// src/components/latest.ts
|
|
2
|
+
import { useEffect, useLayoutEffect, useRef } from "react";
|
|
3
|
+
var useIsoLayoutEffect = typeof window === "undefined" ? useEffect : useLayoutEffect;
|
|
4
|
+
function useLatest(value) {
|
|
5
|
+
const ref = useRef(value);
|
|
6
|
+
useIsoLayoutEffect(() => {
|
|
7
|
+
ref.current = value;
|
|
8
|
+
});
|
|
9
|
+
return ref;
|
|
10
|
+
}
|
|
11
|
+
export {
|
|
12
|
+
useLatest
|
|
13
|
+
};
|