@zenera/chat-widget 0.1.5 → 0.1.6
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 +45 -1
- package/dist/catalog-BYJPdVB0.js +358 -0
- package/dist/index-Dw5Lv6cs.js +3151 -0
- package/dist/index.js +22 -14
- package/dist/shadow-CEK6vAGQ.js +4 -0
- package/dist/styles.css +1 -1
- package/dist/types/packages/chat-widget/src/index.d.ts +4 -2
- package/dist/types/packages/chat-widget/src/interceptors.d.ts +50 -0
- package/dist/types/packages/chat-widget/src/reducer.d.ts +14 -0
- package/dist/types/packages/chat-widget/src/transport.d.ts +32 -2
- package/dist/types/packages/chat-widget/src/ui/ChatThreadView.d.ts +22 -2
- package/dist/types/packages/chat-widget/src/ui/ZeneraChat.d.ts +8 -2
- package/dist/types/packages/chat-widget/src/useAttachments.d.ts +32 -0
- package/dist/types/packages/chat-widget/src/useChatThread.d.ts +3 -2
- package/dist/types/packages/chat-widget/src/widget.d.ts +8 -2
- package/dist/types/shared/components/A2uiSurface.d.ts +3 -0
- package/dist/types/shared/components/a2ui/Chart.d.ts +2 -0
- package/dist/types/shared/components/a2ui/ChartView.d.ts +3 -0
- package/dist/types/shared/components/a2ui/DataTable.d.ts +2 -0
- package/dist/types/shared/components/a2ui/Notice.d.ts +6 -0
- package/dist/types/shared/components/a2ui/catalog.d.ts +2 -0
- package/dist/types/shared/components/a2ui/catalogApi.d.ts +16 -0
- package/dist/types/shared/components/a2ui/chartData.d.ts +8 -0
- package/dist/types/shared/components/a2ui/tableData.d.ts +21 -0
- package/dist/types/shared/components/a2ui/useChartPayload.d.ts +9 -0
- package/dist/types/shared/lib/a2ui.d.ts +22 -0
- package/dist/types/shared/lib/a2uiData.d.ts +2 -0
- package/dist/types/shared/lib/a2uiFeed.d.ts +40 -0
- package/dist/ui.js +15 -2822
- package/dist/useThreadList-BbWSgDw_.js +899 -0
- package/dist/widget/chat-widget.iife.js +6179 -88
- package/package.json +7 -9
- package/dist/shadow-BRAwePHz.js +0 -4
- package/dist/useThreadList-Pg29akQ4.js +0 -576
package/README.md
CHANGED
|
@@ -33,7 +33,9 @@ Visitors can talk to your agent, see responses as they arrive, and return to pre
|
|
|
33
33
|
|
|
34
34
|
- **Live responses** — see replies as the agent generates them.
|
|
35
35
|
- **Conversation history** — start new chats or return to earlier ones.
|
|
36
|
-
- **Rich messages** — display formatted text, code blocks, and tool activity.
|
|
36
|
+
- **Rich messages** — display formatted text, code blocks, Mermaid diagrams, interactive A2UI interfaces, and tool activity.
|
|
37
|
+
- **File attachments** — drop, paste or pick files; they upload at once and go with the next
|
|
38
|
+
message (up to 20 files of 100 MB each), for backends that take them.
|
|
37
39
|
- **Easy access** — open and close chat using a button on the page.
|
|
38
40
|
- **Basic customization** — adjust the chat's position, size, and appearance.
|
|
39
41
|
|
|
@@ -80,8 +82,50 @@ Set these options inside `ZeneraChatWidget.mount({ ... })`:
|
|
|
80
82
|
| `placeholder` | Text shown in the message input before typing. |
|
|
81
83
|
| `starterMessages` | Text displayed at the start of a new conversation. |
|
|
82
84
|
| `theme` | Chat colors and appearance. |
|
|
85
|
+
| `interceptors` | Functions that change each message before it goes to the agent, e.g. to add who the user is. See [Adding context to messages](#adding-context-to-messages). |
|
|
83
86
|
| `historyKey` | Any string you choose. The messages sent with it are kept in the browser's `localStorage` under that key, so use a different key for each user and project; users who share a key share their history. Without `historyKey`, ↑/↓ does nothing. Only messages sent after you set it are recalled. |
|
|
84
87
|
|
|
88
|
+
### Adding context to messages
|
|
89
|
+
|
|
90
|
+
`appContext` adds information from your page to the end of every message the user sends:
|
|
91
|
+
|
|
92
|
+
```js
|
|
93
|
+
const chatWidget = ZeneraChatWidget.mount({
|
|
94
|
+
baseUrl: 'https://runtime.example.com',
|
|
95
|
+
token: jwt,
|
|
96
|
+
interceptors: [
|
|
97
|
+
// A function is called for each message, so the values are always current.
|
|
98
|
+
ZeneraChatWidget.appContext(() => ({ 'User id': user.id, 'User name': user.name })),
|
|
99
|
+
],
|
|
100
|
+
});
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
The agent receives:
|
|
104
|
+
|
|
105
|
+
```
|
|
106
|
+
Summarize the attached report
|
|
107
|
+
|
|
108
|
+
<app_context>
|
|
109
|
+
User id = 42
|
|
110
|
+
User name = John
|
|
111
|
+
</app_context>
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
The user sees only what they typed, also after reloading the page. Values that are empty, `null` or `undefined` are left out. A message with files and no text gets no block, so the chat is still named after its files; pass `{ withFilesOnly: true }` as the second argument to add it anyway. To change the values later, call `chatWidget.update({ interceptors: [...] })`.
|
|
115
|
+
|
|
116
|
+
The block reaches the model as part of the user's message, so a user could type the same thing. Use it for hints such as names, language or the current page, never to grant access. It also adds to the length of every message. Tell the agent what the block is in its instructions.
|
|
117
|
+
|
|
118
|
+
You can write your own interceptor. `outgoing` changes the text that is sent; `display` turns it back into what the user wrote, for when the chat shows the message again:
|
|
119
|
+
|
|
120
|
+
```js
|
|
121
|
+
const signature = {
|
|
122
|
+
outgoing: ({ text }) => `${text}\n-- sent from the pricing page`,
|
|
123
|
+
display: (text) => text.replace(/\n-- sent from the pricing page$/, ''),
|
|
124
|
+
};
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
Interceptors run in order, and `outgoing` may be async. In React, pass `interceptors` to `<ZeneraChatWidget>` or `<ZeneraChat>`, and import `appContext` from `@zenera/chat-widget`. Without the components, use `withInterceptors(transport, interceptors)`.
|
|
128
|
+
|
|
85
129
|
### Launcher
|
|
86
130
|
|
|
87
131
|
Set these options inside `presentation: { ... }` in `ZeneraChatWidget.mountLauncher()`:
|
|
@@ -0,0 +1,358 @@
|
|
|
1
|
+
var M = Object.defineProperty;
|
|
2
|
+
var I = (e, t, r) => t in e ? M(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
|
|
3
|
+
var w = (e, t, r) => I(e, typeof t != "symbol" ? t + "" : t, r);
|
|
4
|
+
import { jsx as a, jsxs as g } from "react/jsx-runtime";
|
|
5
|
+
import { createComponentImplementation as _ } from "@a2ui/react/v0_9";
|
|
6
|
+
import { TriangleAlert as N, Loader2 as L, ArrowUp as U, ArrowDown as Y, ChevronLeft as F, ChevronRight as G } from "lucide-react";
|
|
7
|
+
import { useRef as B, useEffect as A, useState as h, Component as X, useMemo as P } from "react";
|
|
8
|
+
import { basicCatalog as C } from "@a2ui/web_core/v0_9";
|
|
9
|
+
import { z as p } from "zod/v3";
|
|
10
|
+
import * as $ from "echarts";
|
|
11
|
+
import { u as K, N as m, c as T, B as E } from "./index-Dw5Lv6cs.js";
|
|
12
|
+
const Z = "https://zenera.ai/a2ui/catalogs/zenera/v1/catalog.json", H = {
|
|
13
|
+
name: "EChart",
|
|
14
|
+
schema: p.object({
|
|
15
|
+
apiUrl: p.string().describe(
|
|
16
|
+
"URL the chart is loaded from (GET). It answers an Apache ECharts option as JSON, exactly as echarts.setOption takes it (any series type), with the data inside it."
|
|
17
|
+
)
|
|
18
|
+
})
|
|
19
|
+
}, J = {
|
|
20
|
+
name: "DataTable",
|
|
21
|
+
schema: p.object({
|
|
22
|
+
apiUrl: p.string().describe(
|
|
23
|
+
'URL the table is loaded from (GET). The table adds the query `page` (from 1) and `pageSize` and expects one page as JSON: {"columns":[{"key","label","type":"string|number|date|boolean"}],"rows":[{...}],"total":<all rows>,"page","pageSize"}.'
|
|
24
|
+
),
|
|
25
|
+
pageSize: p.number().int().min(1).max(100).optional().describe("Rows per page, 1-100 (default 10).")
|
|
26
|
+
})
|
|
27
|
+
}, V = (e) => C.derive({
|
|
28
|
+
catalogId: Z,
|
|
29
|
+
components: [
|
|
30
|
+
...C.components.keys(),
|
|
31
|
+
...e
|
|
32
|
+
]
|
|
33
|
+
}), W = 10;
|
|
34
|
+
function q(e) {
|
|
35
|
+
const t = getComputedStyle(e), r = (u, f) => t.getPropertyValue(u).trim() || f, o = r("--border", "#e4e4e7"), n = r("--muted-foreground", "#71717b"), s = {
|
|
36
|
+
axisLine: { lineStyle: { color: o } },
|
|
37
|
+
axisTick: { lineStyle: { color: o } },
|
|
38
|
+
axisLabel: { color: n, fontSize: 12 },
|
|
39
|
+
splitLine: { lineStyle: { color: o } },
|
|
40
|
+
nameTextStyle: { color: n }
|
|
41
|
+
}, l = r("--foreground", "#09090b"), i = { color: n, textBorderWidth: 0, textShadowBlur: 0 };
|
|
42
|
+
return {
|
|
43
|
+
color: Array.from({ length: W }, (u, f) => r(`--chart-${f + 1}`, "#2563eb")),
|
|
44
|
+
backgroundColor: "transparent",
|
|
45
|
+
textStyle: { color: n, fontSize: 12 },
|
|
46
|
+
title: {
|
|
47
|
+
textStyle: { color: l },
|
|
48
|
+
subtextStyle: { color: n }
|
|
49
|
+
},
|
|
50
|
+
legend: { textStyle: { color: n, fontSize: 12 } },
|
|
51
|
+
categoryAxis: s,
|
|
52
|
+
valueAxis: s,
|
|
53
|
+
logAxis: s,
|
|
54
|
+
timeAxis: s,
|
|
55
|
+
pie: {
|
|
56
|
+
itemStyle: { borderColor: r("--surface-data", "#ffffff") },
|
|
57
|
+
label: i,
|
|
58
|
+
labelLine: { lineStyle: { color: n } }
|
|
59
|
+
},
|
|
60
|
+
bar: { label: i },
|
|
61
|
+
// The default 'emptyCircle' symbol is hollow, and echarts fills its legend icon with a fixed white.
|
|
62
|
+
line: { label: i, symbol: "circle" },
|
|
63
|
+
scatter: { label: i },
|
|
64
|
+
funnel: { label: i },
|
|
65
|
+
sankey: { label: i },
|
|
66
|
+
treemap: { label: i },
|
|
67
|
+
sunburst: { label: i },
|
|
68
|
+
gauge: { detail: { color: l }, title: { color: n } },
|
|
69
|
+
// The tooltip is an HTML overlay, so CSS variables work in it as they are.
|
|
70
|
+
tooltip: {
|
|
71
|
+
backgroundColor: "var(--popover)",
|
|
72
|
+
borderColor: "var(--border)",
|
|
73
|
+
borderRadius: 6,
|
|
74
|
+
textStyle: { color: "var(--popover-foreground)", fontSize: 12 }
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
function Q(e) {
|
|
79
|
+
const t = Array.isArray(e.title) ? e.title[0] : e.title, r = t == null ? void 0 : t.text;
|
|
80
|
+
return typeof r == "string" && r ? r : "chart";
|
|
81
|
+
}
|
|
82
|
+
function ee({ option: e }) {
|
|
83
|
+
const t = B(null), r = K();
|
|
84
|
+
return A(() => {
|
|
85
|
+
const o = t.current, n = $.init(o, q(o), { renderer: "svg" });
|
|
86
|
+
n.setOption({ animation: !1, ...e });
|
|
87
|
+
const s = new ResizeObserver(() => n.resize());
|
|
88
|
+
return s.observe(o), () => {
|
|
89
|
+
s.disconnect(), n.dispose();
|
|
90
|
+
};
|
|
91
|
+
}, [e, r]), /* @__PURE__ */ a("div", { ref: t, className: "h-full w-full" });
|
|
92
|
+
}
|
|
93
|
+
function te({ option: e }) {
|
|
94
|
+
return /* @__PURE__ */ a("figure", { className: "my-2 w-full overflow-hidden rounded-lg border border-border bg-surface-data p-3", children: /* @__PURE__ */ a("div", { role: "img", "aria-label": Q(e), className: "h-100 w-full", children: /* @__PURE__ */ a(ee, { option: e }) }) });
|
|
95
|
+
}
|
|
96
|
+
function R(e) {
|
|
97
|
+
return typeof e == "object" && e !== null && !Array.isArray(e);
|
|
98
|
+
}
|
|
99
|
+
const re = 24, ne = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]), oe = /* @__PURE__ */ new Set(["link", "sublink", "target", "subtarget", "image", "extraCssText"]);
|
|
100
|
+
function x(e, t = 0) {
|
|
101
|
+
if (t > re) return;
|
|
102
|
+
if (typeof e == "string")
|
|
103
|
+
return /^\s*image:\/\//i.test(e) ? void 0 : e;
|
|
104
|
+
if (Array.isArray(e)) return e.map((o) => x(o, t + 1));
|
|
105
|
+
if (!R(e)) return e;
|
|
106
|
+
const r = {};
|
|
107
|
+
for (const [o, n] of Object.entries(e)) {
|
|
108
|
+
if (ne.has(o) || oe.has(o) || o === "formatter" && typeof n == "string" && n.includes("<")) continue;
|
|
109
|
+
const s = x(n, t + 1);
|
|
110
|
+
s !== void 0 && (r[o] = s);
|
|
111
|
+
}
|
|
112
|
+
return r;
|
|
113
|
+
}
|
|
114
|
+
function se(e) {
|
|
115
|
+
if (!R(e)) return null;
|
|
116
|
+
const t = x(e);
|
|
117
|
+
return Object.keys(t).length === 0 ? null : t;
|
|
118
|
+
}
|
|
119
|
+
const ae = 15e3;
|
|
120
|
+
async function j(e, t, r = location.origin) {
|
|
121
|
+
const o = new URL(e, r);
|
|
122
|
+
if (!/^https?:$/.test(o.protocol) || o.username || o.password)
|
|
123
|
+
throw new Error("Not a web address");
|
|
124
|
+
const n = AbortSignal.timeout(ae), s = o.origin === r, l = await fetch(o, {
|
|
125
|
+
method: "GET",
|
|
126
|
+
headers: { Accept: "application/json" },
|
|
127
|
+
referrerPolicy: "no-referrer",
|
|
128
|
+
signal: t ? AbortSignal.any([t, n]) : n,
|
|
129
|
+
credentials: s ? "same-origin" : "omit",
|
|
130
|
+
...!s && { redirect: "error" }
|
|
131
|
+
});
|
|
132
|
+
if (!l.ok) throw new Error(`HTTP ${l.status}`);
|
|
133
|
+
return l.json();
|
|
134
|
+
}
|
|
135
|
+
function ie(e) {
|
|
136
|
+
const [t, r] = h({ status: "loading" });
|
|
137
|
+
return A(() => {
|
|
138
|
+
const o = new AbortController();
|
|
139
|
+
return r({ status: "loading" }), j(e, o.signal).then(
|
|
140
|
+
(n) => r({ status: "ready", payload: n }),
|
|
141
|
+
() => o.signal.aborted || r({ status: "failed" })
|
|
142
|
+
), () => o.abort();
|
|
143
|
+
}, [e]), t;
|
|
144
|
+
}
|
|
145
|
+
class le extends X {
|
|
146
|
+
constructor() {
|
|
147
|
+
super(...arguments);
|
|
148
|
+
w(this, "state", { failed: !1 });
|
|
149
|
+
}
|
|
150
|
+
static getDerivedStateFromError() {
|
|
151
|
+
return { failed: !0 };
|
|
152
|
+
}
|
|
153
|
+
render() {
|
|
154
|
+
return this.state.failed ? /* @__PURE__ */ a(m, { icon: /* @__PURE__ */ a(N, { className: "size-3.5" }), children: "Not possible to draw this chart" }) : this.props.children;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
function ce({ apiUrl: e }) {
|
|
158
|
+
const t = ie(e), r = P(
|
|
159
|
+
() => t.status === "ready" ? se(t.payload) : null,
|
|
160
|
+
[t]
|
|
161
|
+
);
|
|
162
|
+
return t.status === "loading" ? /* @__PURE__ */ a(m, { icon: /* @__PURE__ */ a(L, { className: "size-3.5 animate-spin" }), children: "Loading chart…" }) : t.status === "failed" ? /* @__PURE__ */ a(m, { icon: /* @__PURE__ */ a(N, { className: "size-3.5" }), children: "Could not load the chart data" }) : r ? /* @__PURE__ */ a(te, { option: r }) : /* @__PURE__ */ a(m, { children: "No data to chart" });
|
|
163
|
+
}
|
|
164
|
+
const de = _(
|
|
165
|
+
H,
|
|
166
|
+
({ props: e }) => /* @__PURE__ */ a(le, { children: /* @__PURE__ */ a(ce, { ...e }) })
|
|
167
|
+
), z = 50, ue = 100, D = 1e3, fe = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]), ge = /* @__PURE__ */ new Set(["string", "number", "date", "boolean"]), me = /* @__PURE__ */ new Set(["left", "right", "center"]);
|
|
168
|
+
function S(e) {
|
|
169
|
+
return typeof e == "object" && e !== null && !Array.isArray(e);
|
|
170
|
+
}
|
|
171
|
+
function be(e) {
|
|
172
|
+
return typeof e == "string" ? e.slice(0, D) : typeof e == "boolean" || typeof e == "number" && Number.isFinite(e) ? e : null;
|
|
173
|
+
}
|
|
174
|
+
function O(e) {
|
|
175
|
+
if (!S(e) || typeof e.key != "string" || fe.has(e.key)) return null;
|
|
176
|
+
const t = typeof e.type == "string" && ge.has(e.type) ? e.type : "string";
|
|
177
|
+
return {
|
|
178
|
+
key: e.key,
|
|
179
|
+
label: typeof e.label == "string" && e.label ? e.label.slice(0, D) : e.key,
|
|
180
|
+
type: t,
|
|
181
|
+
sortable: e.sortable !== !1,
|
|
182
|
+
align: typeof e.align == "string" && me.has(e.align) ? e.align : t === "number" ? "right" : "left"
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
function pe(e) {
|
|
186
|
+
if (!S(e) || !Array.isArray(e.rows)) return null;
|
|
187
|
+
const t = e.rows.slice(0, ue).filter(S);
|
|
188
|
+
let r = [];
|
|
189
|
+
if (Array.isArray(e.columns) ? r = e.columns.slice(0, z).map(O).filter((s) => s !== null) : t.length && (r = Object.keys(t[0]).slice(0, z).map((s) => O({ key: s })).filter((s) => s !== null)), r.length === 0) return null;
|
|
190
|
+
const o = t.map((s) => {
|
|
191
|
+
const l = {};
|
|
192
|
+
for (const { key: i } of r)
|
|
193
|
+
l[i] = Object.hasOwn(s, i) ? be(s[i]) : null;
|
|
194
|
+
return l;
|
|
195
|
+
}), n = e.total;
|
|
196
|
+
return {
|
|
197
|
+
columns: r,
|
|
198
|
+
rows: o,
|
|
199
|
+
total: typeof n == "number" && Number.isInteger(n) && n >= o.length ? n : o.length
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
function he(e, t) {
|
|
203
|
+
if (e === null) return "";
|
|
204
|
+
if (t === "boolean" || typeof e == "boolean") return e ? "Yes" : "No";
|
|
205
|
+
if (t === "number" && typeof e == "number") return e.toLocaleString();
|
|
206
|
+
if (t === "date" && typeof e == "string") {
|
|
207
|
+
const r = new Date(e);
|
|
208
|
+
return Number.isNaN(r.getTime()) ? e : r.toLocaleDateString();
|
|
209
|
+
}
|
|
210
|
+
return String(e);
|
|
211
|
+
}
|
|
212
|
+
function ye(e, t, r) {
|
|
213
|
+
return r === "number" ? Number(e) - Number(t) : r === "date" ? (Date.parse(String(e)) || 0) - (Date.parse(String(t)) || 0) : r === "boolean" ? Number(e) - Number(t) : String(e).localeCompare(String(t));
|
|
214
|
+
}
|
|
215
|
+
function xe(e, t, r) {
|
|
216
|
+
const o = r === "desc" ? -1 : 1;
|
|
217
|
+
return e.map((n, s) => ({ row: n, index: s })).sort((n, s) => {
|
|
218
|
+
const l = n.row[t.key], i = s.row[t.key];
|
|
219
|
+
return l === null || i === null ? +(l === null) - +(i === null) || n.index - s.index : o * ye(l, i, t.type) || n.index - s.index;
|
|
220
|
+
}).map(({ row: n }) => n);
|
|
221
|
+
}
|
|
222
|
+
const Se = 10;
|
|
223
|
+
function Ne(e, t, r) {
|
|
224
|
+
const o = new URL(e, location.origin);
|
|
225
|
+
return o.searchParams.set("page", String(t)), o.searchParams.set("pageSize", String(r)), o.href;
|
|
226
|
+
}
|
|
227
|
+
function Ae(e, t, r) {
|
|
228
|
+
const [o, n] = h({ status: "loading" });
|
|
229
|
+
return A(() => {
|
|
230
|
+
const s = new AbortController();
|
|
231
|
+
return n((l) => l.status === "ready" ? l : { status: "loading" }), j(Ne(e, t, r), s.signal).then(
|
|
232
|
+
(l) => {
|
|
233
|
+
const i = pe(l);
|
|
234
|
+
n(i ? { status: "ready", table: i } : { status: "failed" });
|
|
235
|
+
},
|
|
236
|
+
() => s.signal.aborted || n({ status: "failed" })
|
|
237
|
+
), () => s.abort();
|
|
238
|
+
}, [e, t, r]), o;
|
|
239
|
+
}
|
|
240
|
+
function ke({ apiUrl: e, pageSize: t = Se }) {
|
|
241
|
+
const [r, o] = h(1), [n, s] = h(null), l = Ae(e, r, t), i = l.status === "ready" ? l.table : null, u = P(() => {
|
|
242
|
+
const c = i == null ? void 0 : i.columns.find((d) => d.key === (n == null ? void 0 : n.key));
|
|
243
|
+
return i && c && n ? xe(i.rows, c, n.direction) : i == null ? void 0 : i.rows;
|
|
244
|
+
}, [i, n]);
|
|
245
|
+
if (l.status === "loading")
|
|
246
|
+
return /* @__PURE__ */ a(m, { icon: /* @__PURE__ */ a(L, { className: "size-3.5 animate-spin" }), children: "Loading table…" });
|
|
247
|
+
if (l.status === "failed")
|
|
248
|
+
return /* @__PURE__ */ a(m, { icon: /* @__PURE__ */ a(N, { className: "size-3.5" }), children: "Could not load the table data" });
|
|
249
|
+
const { columns: f, total: k } = l.table, y = Math.max(1, Math.ceil(k / t)), v = (c) => s(
|
|
250
|
+
(d) => (d == null ? void 0 : d.key) !== c.key ? { key: c.key, direction: "asc" } : d.direction === "asc" ? { key: c.key, direction: "desc" } : null
|
|
251
|
+
);
|
|
252
|
+
return /* @__PURE__ */ g("div", { className: "my-2 w-full overflow-hidden rounded-lg border border-border bg-surface-data text-sm", children: [
|
|
253
|
+
/* @__PURE__ */ a("div", { className: "overflow-x-auto", children: /* @__PURE__ */ g("table", { className: "data-table w-full border-collapse", children: [
|
|
254
|
+
/* @__PURE__ */ a("thead", { className: "bg-muted text-xs text-muted-foreground", children: /* @__PURE__ */ a("tr", { children: f.map((c) => {
|
|
255
|
+
const d = (n == null ? void 0 : n.key) === c.key ? n.direction : null;
|
|
256
|
+
return /* @__PURE__ */ a(
|
|
257
|
+
"th",
|
|
258
|
+
{
|
|
259
|
+
scope: "col",
|
|
260
|
+
"aria-sort": d === "asc" ? "ascending" : d === "desc" ? "descending" : void 0,
|
|
261
|
+
className: T(
|
|
262
|
+
"px-3 py-2.5 text-left font-medium",
|
|
263
|
+
c.align === "right" && "text-right",
|
|
264
|
+
c.align === "center" && "text-center"
|
|
265
|
+
),
|
|
266
|
+
children: c.sortable ? /* @__PURE__ */ g(
|
|
267
|
+
"button",
|
|
268
|
+
{
|
|
269
|
+
type: "button",
|
|
270
|
+
onClick: () => v(c),
|
|
271
|
+
className: "inline-flex cursor-pointer items-center gap-1 font-medium hover:text-foreground",
|
|
272
|
+
children: [
|
|
273
|
+
c.label,
|
|
274
|
+
d === "asc" && /* @__PURE__ */ a(U, { className: "size-3" }),
|
|
275
|
+
d === "desc" && /* @__PURE__ */ a(Y, { className: "size-3" })
|
|
276
|
+
]
|
|
277
|
+
}
|
|
278
|
+
) : c.label
|
|
279
|
+
},
|
|
280
|
+
c.key
|
|
281
|
+
);
|
|
282
|
+
}) }) }),
|
|
283
|
+
/* @__PURE__ */ a("tbody", { children: u != null && u.length ? u.map((c, d) => /* @__PURE__ */ a(
|
|
284
|
+
"tr",
|
|
285
|
+
{
|
|
286
|
+
className: "border-t border-border transition-colors hover:bg-muted/60",
|
|
287
|
+
children: f.map((b) => /* @__PURE__ */ a(
|
|
288
|
+
"td",
|
|
289
|
+
{
|
|
290
|
+
className: T(
|
|
291
|
+
"px-3 py-3 text-left align-top",
|
|
292
|
+
b.align === "right" && "text-right tabular-nums",
|
|
293
|
+
b.align === "center" && "text-center"
|
|
294
|
+
),
|
|
295
|
+
children: he(c[b.key], b.type)
|
|
296
|
+
},
|
|
297
|
+
b.key
|
|
298
|
+
))
|
|
299
|
+
},
|
|
300
|
+
d
|
|
301
|
+
)) : /* @__PURE__ */ a("tr", { className: "border-t border-border", children: /* @__PURE__ */ a(
|
|
302
|
+
"td",
|
|
303
|
+
{
|
|
304
|
+
colSpan: f.length,
|
|
305
|
+
className: "px-3 py-4 text-center text-muted-foreground",
|
|
306
|
+
children: "No rows"
|
|
307
|
+
}
|
|
308
|
+
) }) })
|
|
309
|
+
] }) }),
|
|
310
|
+
y > 1 && /* @__PURE__ */ g("div", { className: "flex items-center justify-between border-t border-border px-3 py-2 text-xs text-muted-foreground", children: [
|
|
311
|
+
/* @__PURE__ */ g("span", { children: [
|
|
312
|
+
"Page ",
|
|
313
|
+
r,
|
|
314
|
+
" of ",
|
|
315
|
+
y,
|
|
316
|
+
" · ",
|
|
317
|
+
k.toLocaleString(),
|
|
318
|
+
" rows"
|
|
319
|
+
] }),
|
|
320
|
+
/* @__PURE__ */ g("div", { className: "flex gap-1", children: [
|
|
321
|
+
/* @__PURE__ */ a(
|
|
322
|
+
E,
|
|
323
|
+
{
|
|
324
|
+
variant: "outline",
|
|
325
|
+
size: "icon",
|
|
326
|
+
className: "size-7",
|
|
327
|
+
"aria-label": "Previous page",
|
|
328
|
+
disabled: r <= 1,
|
|
329
|
+
onClick: () => o(r - 1),
|
|
330
|
+
children: /* @__PURE__ */ a(F, {})
|
|
331
|
+
}
|
|
332
|
+
),
|
|
333
|
+
/* @__PURE__ */ a(
|
|
334
|
+
E,
|
|
335
|
+
{
|
|
336
|
+
variant: "outline",
|
|
337
|
+
size: "icon",
|
|
338
|
+
className: "size-7",
|
|
339
|
+
"aria-label": "Next page",
|
|
340
|
+
disabled: r >= y,
|
|
341
|
+
onClick: () => o(r + 1),
|
|
342
|
+
children: /* @__PURE__ */ a(G, {})
|
|
343
|
+
}
|
|
344
|
+
)
|
|
345
|
+
] })
|
|
346
|
+
] })
|
|
347
|
+
] });
|
|
348
|
+
}
|
|
349
|
+
const we = _(
|
|
350
|
+
J,
|
|
351
|
+
({ props: e }) => /* @__PURE__ */ a(ke, { ...e })
|
|
352
|
+
), Re = V([
|
|
353
|
+
de,
|
|
354
|
+
we
|
|
355
|
+
]);
|
|
356
|
+
export {
|
|
357
|
+
Re as zeneraCatalog
|
|
358
|
+
};
|