@ishibashi0112/spreadsheet-grid 1.13.0 → 1.14.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/API_REFERENCE.md +127 -3
- package/README.md +2 -0
- package/dist/ai/useGridAgentTools.d.ts +8 -0
- package/dist/ai.cjs +1 -1
- package/dist/ai.d.ts +4 -0
- package/dist/ai.js +186 -125
- package/dist/common.d.ts +1 -1
- package/dist/hooks/useServerSideRowModel.d.ts +2 -1
- package/dist/index.cjs +2 -2
- package/dist/index.js +4 -0
- package/dist/lite/{createSpreadsheetGrid-cOTbng_2.js → createSpreadsheetGrid-Bn5cneMS.js} +4 -0
- package/dist/lite/{createSpreadsheetGrid-DNoVKiwo.cjs → createSpreadsheetGrid-Di5iNqyu.cjs} +1 -1
- package/dist/lite/createSpreadsheetGrid.cjs +1 -1
- package/dist/lite/createSpreadsheetGrid.js +1 -1
- package/dist/lite/features/serverSide.cjs +1 -1
- package/dist/lite/features/serverSide.js +1 -1
- package/dist/lite/{serverSide-CLb4dLUK.js → serverSide-BWZPpSkL.js} +1 -0
- package/dist/lite/serverSide-BXmZ_co8.cjs +1 -0
- package/dist/lite.cjs +1 -1
- package/dist/lite.js +2 -2
- package/package.json +2 -2
- package/skills/spreadsheet-grid/SKILL.md +2 -0
- package/dist/lite/serverSide-COYBN6Pt.cjs +0 -1
package/dist/ai.js
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
import { useEffect as e,
|
|
2
|
-
import { Fragment as
|
|
3
|
-
import { systemColorSchemeStore as
|
|
4
|
-
import { resolveGridThemeClassName as
|
|
5
|
-
import { resolveGridAskLocaleText as
|
|
6
|
-
import { formatLocaleText as
|
|
7
|
-
import { createGridAskRequest as
|
|
1
|
+
import { useEffect as e, useMemo as t, useRef as n, useState as r, useSyncExternalStore as i } from "react";
|
|
2
|
+
import { Fragment as a, jsx as o, jsxs as s } from "react/jsx-runtime";
|
|
3
|
+
import { systemColorSchemeStore as c } from "@ishibashi0112/spreadsheet-grid-core/internal/controllers/systemColorSchemeStore";
|
|
4
|
+
import { resolveGridThemeClassName as l } from "@ishibashi0112/spreadsheet-grid-core/internal/logic/theme";
|
|
5
|
+
import { resolveGridAskLocaleText as u } from "@ishibashi0112/spreadsheet-grid-core/internal/logic/gridAskLocaleText";
|
|
6
|
+
import { formatLocaleText as d } from "@ishibashi0112/spreadsheet-grid-core/internal/logic/localeTextFilters";
|
|
7
|
+
import { createGridAskRequest as f, createGridAskRequest as p, describeGridAskView as m, describeGridAskView as h, gridAskSystemPrompt as g, isGridAskColumnsChanged as _, isGridAskColumnsChanged as v, isSameGridAskView as y, isSameGridAskView as b, readGridAskAnswer as x, readGridAskAnswer as S, removeGridAskItem as C, removeGridAskItem as w } from "@ishibashi0112/spreadsheet-grid-core/internal/logic/gridAsk";
|
|
8
|
+
import { createGridAgentTools as T, createGridAgentTools as E, registerGridAgentTools as D } from "@ishibashi0112/spreadsheet-grid-core/internal/logic/gridAgentTools";
|
|
8
9
|
//#region src/ai/useGridAsk.ts
|
|
9
|
-
var
|
|
10
|
+
var O = 1e3, k = 400, A = (e, t, n) => n ? b(e, t) : b({
|
|
10
11
|
...e,
|
|
11
12
|
columns: void 0
|
|
12
13
|
}, {
|
|
13
14
|
...t,
|
|
14
15
|
columns: void 0
|
|
15
|
-
}),
|
|
16
|
+
}), j = (e) => ({
|
|
16
17
|
columns: e.columns,
|
|
17
18
|
columnHints: e.columnHints,
|
|
18
19
|
allowFilter: e.allowFilter,
|
|
@@ -20,10 +21,10 @@ var w = 1e3, T = 400, E = (e, t, n) => n ? y(e, t) : y({
|
|
|
20
21
|
allowSearch: e.allowSearch,
|
|
21
22
|
allowColumnVisibility: e.allowColumnVisibility,
|
|
22
23
|
localeText: e.localeText
|
|
23
|
-
}),
|
|
24
|
+
}), M = (e, t) => v(e, t) ? t : {
|
|
24
25
|
...t,
|
|
25
26
|
columns: void 0
|
|
26
|
-
},
|
|
27
|
+
}, N = (e, t, n) => {
|
|
27
28
|
if (!n) return {
|
|
28
29
|
...e,
|
|
29
30
|
filters: t.filters,
|
|
@@ -44,97 +45,97 @@ var w = 1e3, T = 400, E = (e, t, n) => n ? y(e, t) : y({
|
|
|
44
45
|
})
|
|
45
46
|
};
|
|
46
47
|
};
|
|
47
|
-
function
|
|
48
|
-
let [i, a] =
|
|
48
|
+
function P(t) {
|
|
49
|
+
let [i, a] = r("idle"), [o, s] = r(null), [c, l] = r(null), [d, f] = r(null), m = n(null), g = n(t);
|
|
49
50
|
e(() => {
|
|
50
|
-
g.current =
|
|
51
|
+
g.current = t;
|
|
51
52
|
}), e(() => () => {
|
|
52
|
-
let e =
|
|
53
|
-
e !== null && (
|
|
53
|
+
let e = m.current;
|
|
54
|
+
e !== null && (m.current = null, e.abort(), a("idle"));
|
|
54
55
|
}, []);
|
|
55
|
-
let _ =
|
|
56
|
+
let _ = j(t), v = u(t.localeText), y = (e) => h(e, _), b = t.allowColumnVisibility ?? !1, x = process.env.NODE_ENV === "production" || !t.columnHints ? "" : Object.keys(t.columnHints).filter((e) => !t.columns.some((t) => t.key === e)).join(", "), C = n("");
|
|
56
57
|
e(() => {
|
|
57
|
-
|
|
58
|
-
}, [
|
|
59
|
-
let
|
|
58
|
+
x !== "" && x !== C.current && (C.current = x, console.warn(`[spreadsheet-grid] GridAskBar / useGridAsk の columnHints に列に無いキーがあります: ${x}。列の key と同じ名前にしてください(この補足や \`false\` は効いていません)。\n[spreadsheet-grid] columnHints of GridAskBar / useGridAsk has keys that are not columns: ${x}. Use the column keys (these hints and \`false\` have no effect).`));
|
|
59
|
+
}, [x]);
|
|
60
|
+
let T = d !== null && d.view.phase === "applied" ? d : null;
|
|
60
61
|
e(() => {
|
|
61
|
-
if (
|
|
62
|
+
if (T === null) return;
|
|
62
63
|
let e = null, t = () => {
|
|
63
|
-
if (
|
|
64
|
+
if (m.current !== null) return;
|
|
64
65
|
let e = g.current.grid.current;
|
|
65
|
-
e === null ||
|
|
66
|
+
e === null || A(e.getState(), T.applied, b) || (f((e) => e === T ? {
|
|
66
67
|
...e,
|
|
67
68
|
view: {
|
|
68
69
|
...e.view,
|
|
69
70
|
phase: "changed"
|
|
70
71
|
}
|
|
71
|
-
} : e), u(
|
|
72
|
+
} : e), l(u(g.current.localeText).changedNotice));
|
|
72
73
|
}, n = () => {
|
|
73
74
|
e === null && (e = setTimeout(() => {
|
|
74
75
|
e = null, t();
|
|
75
|
-
},
|
|
76
|
-
}, r = setInterval(t,
|
|
76
|
+
}, k));
|
|
77
|
+
}, r = setInterval(t, O);
|
|
77
78
|
return document.addEventListener("click", n, !0), document.addEventListener("keyup", n, !0), () => {
|
|
78
79
|
clearInterval(r), e !== null && clearTimeout(e), document.removeEventListener("click", n, !0), document.removeEventListener("keyup", n, !0);
|
|
79
80
|
};
|
|
80
|
-
}, [
|
|
81
|
-
let
|
|
82
|
-
let
|
|
83
|
-
if (
|
|
84
|
-
let
|
|
85
|
-
if (
|
|
81
|
+
}, [T, b]);
|
|
82
|
+
let E = async (e) => {
|
|
83
|
+
let n = e.trim();
|
|
84
|
+
if (n === "" || m.current !== null) return !1;
|
|
85
|
+
let r = t.grid.current;
|
|
86
|
+
if (r === null) return s(v.noGrid), !1;
|
|
86
87
|
let i = new AbortController();
|
|
87
|
-
|
|
88
|
+
m.current = i, a("asking"), s(null), l(null);
|
|
88
89
|
let o;
|
|
89
90
|
try {
|
|
90
|
-
o = await
|
|
91
|
+
o = await t.ask(p(n, r.getState(), _), { signal: i.signal });
|
|
91
92
|
} catch (e) {
|
|
92
|
-
return i.signal.aborted ? !1 : (
|
|
93
|
+
return i.signal.aborted ? !1 : (m.current = null, a("idle"), g.current.onError?.(e), s(v.askFailed), !1);
|
|
93
94
|
}
|
|
94
95
|
if (i.signal.aborted) return !1;
|
|
95
|
-
|
|
96
|
-
let c = g.current,
|
|
96
|
+
m.current = null, a("idle");
|
|
97
|
+
let c = g.current, u = j(c), d = c.grid.current;
|
|
97
98
|
if (d === null) return s(v.noGrid), !1;
|
|
98
|
-
let y = d.getState(), b =
|
|
99
|
+
let y = d.getState(), b = S(o, y, u);
|
|
99
100
|
if (!b.ok) return s(b.message), !1;
|
|
100
|
-
let
|
|
101
|
-
text:
|
|
101
|
+
let x = {
|
|
102
|
+
text: n,
|
|
102
103
|
dropped: b.dropped,
|
|
103
104
|
unsupported: b.unsupported
|
|
104
105
|
};
|
|
105
|
-
return
|
|
106
|
+
return l(null), b.changed ? (d.applyState(M(y, b.state)), f({
|
|
106
107
|
view: {
|
|
107
|
-
...
|
|
108
|
+
...x,
|
|
108
109
|
phase: "applied",
|
|
109
|
-
items:
|
|
110
|
+
items: h(b.state, u)
|
|
110
111
|
},
|
|
111
112
|
before: y,
|
|
112
113
|
applied: b.state
|
|
113
114
|
}), c.onApply?.({
|
|
114
|
-
text:
|
|
115
|
+
text: n,
|
|
115
116
|
state: b.state,
|
|
116
117
|
dropped: b.dropped,
|
|
117
118
|
unsupported: b.unsupported
|
|
118
|
-
}), !0) : (
|
|
119
|
+
}), !0) : (f({
|
|
119
120
|
view: {
|
|
120
|
-
...
|
|
121
|
+
...x,
|
|
121
122
|
phase: "unchanged",
|
|
122
|
-
items:
|
|
123
|
+
items: h(y, u)
|
|
123
124
|
},
|
|
124
125
|
before: y,
|
|
125
126
|
applied: y
|
|
126
127
|
}), !0);
|
|
127
|
-
},
|
|
128
|
-
let e =
|
|
129
|
-
e !== null && (
|
|
128
|
+
}, D = () => {
|
|
129
|
+
let e = m.current;
|
|
130
|
+
e !== null && (m.current = null, e.abort(), a("idle"));
|
|
130
131
|
}, P = (e) => {
|
|
131
|
-
let
|
|
132
|
-
if (
|
|
133
|
-
let
|
|
134
|
-
return
|
|
135
|
-
target:
|
|
136
|
-
now:
|
|
137
|
-
} : (
|
|
132
|
+
let n = t.grid.current;
|
|
133
|
+
if (n === null || e.view.phase !== "applied") return null;
|
|
134
|
+
let r = n.getState();
|
|
135
|
+
return A(r, e.applied, b) ? {
|
|
136
|
+
target: n,
|
|
137
|
+
now: r
|
|
138
|
+
} : (l(v.changedNotice), f({
|
|
138
139
|
...e,
|
|
139
140
|
view: {
|
|
140
141
|
...e.view,
|
|
@@ -147,14 +148,14 @@ function A(r) {
|
|
|
147
148
|
error: o,
|
|
148
149
|
notice: c,
|
|
149
150
|
session: d?.view ?? null,
|
|
150
|
-
submit:
|
|
151
|
-
cancel:
|
|
151
|
+
submit: E,
|
|
152
|
+
cancel: D,
|
|
152
153
|
undo: () => {
|
|
153
154
|
if (d === null) return;
|
|
154
155
|
let e = P(d);
|
|
155
156
|
if (e === null) return;
|
|
156
|
-
let t =
|
|
157
|
-
e.target.applyState(
|
|
157
|
+
let t = N(e.now, d.before, b);
|
|
158
|
+
e.target.applyState(M(e.now, t)), l(null), f({
|
|
158
159
|
...d,
|
|
159
160
|
view: {
|
|
160
161
|
...d.view,
|
|
@@ -166,8 +167,8 @@ function A(r) {
|
|
|
166
167
|
if (d === null) return;
|
|
167
168
|
let t = P(d);
|
|
168
169
|
if (t === null) return;
|
|
169
|
-
let n =
|
|
170
|
-
t.target.applyState(
|
|
170
|
+
let n = w(t.now, e);
|
|
171
|
+
t.target.applyState(M(t.now, n)), f({
|
|
171
172
|
...d,
|
|
172
173
|
applied: n,
|
|
173
174
|
view: {
|
|
@@ -177,18 +178,18 @@ function A(r) {
|
|
|
177
178
|
});
|
|
178
179
|
},
|
|
179
180
|
dismiss: () => {
|
|
180
|
-
|
|
181
|
+
f(null), l(null), s(null);
|
|
181
182
|
}
|
|
182
183
|
};
|
|
183
184
|
}
|
|
184
185
|
//#endregion
|
|
185
186
|
//#region src/ai/GridAskBar.tsx
|
|
186
|
-
var
|
|
187
|
-
function
|
|
188
|
-
let _ =
|
|
187
|
+
var F = (...e) => e.filter(Boolean).join(" ");
|
|
188
|
+
function I({ examples: t, placeholder: f, label: p, className: m, theme: h = "light", ...g }) {
|
|
189
|
+
let _ = P(g), v = u(g.localeText), [y, b] = r(""), x = l(h, i(c.subscribe, c.getSnapshot, c.getServerSnapshot)), S = _.status === "asking", C = _.session, w = _.cancel, [T, E] = r(""), D = n(null), O = n(null), k = n(null), A = n(null);
|
|
189
190
|
e(() => {
|
|
190
|
-
let e =
|
|
191
|
-
if (
|
|
191
|
+
let e = A.current;
|
|
192
|
+
if (A.current = null, e === null || performance.now() - e.at > 1e3) return;
|
|
192
193
|
let t = document.activeElement;
|
|
193
194
|
if (t !== null && t !== document.body) return;
|
|
194
195
|
let n = k.current?.querySelectorAll(".ssg-ask-chip-remove");
|
|
@@ -202,41 +203,41 @@ function M({ examples: d, placeholder: f, label: p, className: m, theme: h = "li
|
|
|
202
203
|
};
|
|
203
204
|
return t.addEventListener("keydown", n), () => t.removeEventListener("keydown", n);
|
|
204
205
|
}, [S, w]);
|
|
205
|
-
let
|
|
206
|
-
|
|
206
|
+
let j = (e = null) => {
|
|
207
|
+
A.current = {
|
|
207
208
|
chip: e,
|
|
208
209
|
at: performance.now()
|
|
209
210
|
};
|
|
210
|
-
},
|
|
211
|
+
}, M = (e) => {
|
|
211
212
|
if (S || e.trim() === "") return;
|
|
212
213
|
let t = e.trim();
|
|
213
214
|
E(t), _.submit(e).then((e) => {
|
|
214
215
|
e && b((e) => e.trim() === t ? "" : e);
|
|
215
216
|
});
|
|
216
217
|
};
|
|
217
|
-
return /* @__PURE__ */
|
|
218
|
+
return /* @__PURE__ */ s("div", {
|
|
218
219
|
ref: D,
|
|
219
|
-
className:
|
|
220
|
+
className: F("ssg-ask", x, m),
|
|
220
221
|
"data-ssg-ask": "",
|
|
221
222
|
children: [
|
|
222
|
-
/* @__PURE__ */
|
|
223
|
+
/* @__PURE__ */ s("form", {
|
|
223
224
|
className: "ssg-ask-form",
|
|
224
225
|
onSubmit: (e) => {
|
|
225
|
-
e.preventDefault(),
|
|
226
|
+
e.preventDefault(), M(y);
|
|
226
227
|
},
|
|
227
228
|
children: [
|
|
228
|
-
/* @__PURE__ */
|
|
229
|
+
/* @__PURE__ */ o("svg", {
|
|
229
230
|
className: "ssg-ask-icon",
|
|
230
231
|
viewBox: "0 0 16 16",
|
|
231
232
|
width: "16",
|
|
232
233
|
height: "16",
|
|
233
234
|
"aria-hidden": "true",
|
|
234
|
-
children: /* @__PURE__ */
|
|
235
|
+
children: /* @__PURE__ */ o("path", {
|
|
235
236
|
d: "M6 1.5l1.1 3.4L10.5 6 7.1 7.1 6 10.5 4.9 7.1 1.5 6l3.4-1.1L6 1.5zm6 7l.6 1.9 1.9.6-1.9.6-.6 1.9-.6-1.9-1.9-.6 1.9-.6.6-1.9z",
|
|
236
237
|
fill: "currentColor"
|
|
237
238
|
})
|
|
238
239
|
}),
|
|
239
|
-
/* @__PURE__ */
|
|
240
|
+
/* @__PURE__ */ o("input", {
|
|
240
241
|
ref: O,
|
|
241
242
|
className: "ssg-ask-input",
|
|
242
243
|
type: "text",
|
|
@@ -249,14 +250,14 @@ function M({ examples: d, placeholder: f, label: p, className: m, theme: h = "li
|
|
|
249
250
|
e.key === "Enter" && (e.nativeEvent.isComposing || e.keyCode === 229) && e.preventDefault();
|
|
250
251
|
}
|
|
251
252
|
}),
|
|
252
|
-
S ? /* @__PURE__ */
|
|
253
|
+
S ? /* @__PURE__ */ o("button", {
|
|
253
254
|
type: "button",
|
|
254
255
|
className: "ssg-ask-button",
|
|
255
256
|
onClick: (e) => {
|
|
256
257
|
e.preventDefault(), !(e.detail > 1) && w();
|
|
257
258
|
},
|
|
258
259
|
children: v.stop
|
|
259
|
-
}) : /* @__PURE__ */
|
|
260
|
+
}) : /* @__PURE__ */ o("button", {
|
|
260
261
|
type: "submit",
|
|
261
262
|
className: "ssg-ask-button ssg-ask-button--primary",
|
|
262
263
|
disabled: y.trim() === "",
|
|
@@ -267,155 +268,155 @@ function M({ examples: d, placeholder: f, label: p, className: m, theme: h = "li
|
|
|
267
268
|
})
|
|
268
269
|
]
|
|
269
270
|
}),
|
|
270
|
-
|
|
271
|
+
t && t.length > 0 && /* @__PURE__ */ s("div", {
|
|
271
272
|
className: "ssg-ask-examples",
|
|
272
|
-
children: [/* @__PURE__ */
|
|
273
|
+
children: [/* @__PURE__ */ o("span", {
|
|
273
274
|
className: "ssg-ask-examples-label",
|
|
274
275
|
children: v.examples
|
|
275
|
-
}),
|
|
276
|
+
}), t.map((e, t) => /* @__PURE__ */ o("button", {
|
|
276
277
|
type: "button",
|
|
277
278
|
className: "ssg-ask-example",
|
|
278
279
|
"aria-disabled": S || void 0,
|
|
279
280
|
title: e,
|
|
280
281
|
onClick: () => {
|
|
281
|
-
S || (b(e),
|
|
282
|
+
S || (b(e), M(e));
|
|
282
283
|
},
|
|
283
284
|
children: e
|
|
284
285
|
}, t))]
|
|
285
286
|
}),
|
|
286
|
-
/* @__PURE__ */
|
|
287
|
+
/* @__PURE__ */ s("div", {
|
|
287
288
|
className: "ssg-ask-output",
|
|
288
289
|
"aria-live": "polite",
|
|
289
290
|
children: [
|
|
290
|
-
S && /* @__PURE__ */
|
|
291
|
+
S && /* @__PURE__ */ s("div", {
|
|
291
292
|
className: "ssg-ask-status",
|
|
292
293
|
children: [
|
|
293
|
-
/* @__PURE__ */
|
|
294
|
+
/* @__PURE__ */ o("span", {
|
|
294
295
|
className: "ssg-ask-spinner",
|
|
295
296
|
"aria-hidden": "true"
|
|
296
297
|
}),
|
|
297
298
|
v.thinking,
|
|
298
|
-
/* @__PURE__ */
|
|
299
|
+
/* @__PURE__ */ o("span", {
|
|
299
300
|
className: "ssg-ask-hint",
|
|
300
301
|
children: v.escHint
|
|
301
302
|
})
|
|
302
303
|
]
|
|
303
304
|
}),
|
|
304
|
-
!S && _.error !== null && /* @__PURE__ */
|
|
305
|
+
!S && _.error !== null && /* @__PURE__ */ s("div", {
|
|
305
306
|
className: "ssg-ask-note ssg-ask-note--error",
|
|
306
|
-
children: [/* @__PURE__ */
|
|
307
|
+
children: [/* @__PURE__ */ o("span", { children: _.error }), T !== "" && /* @__PURE__ */ o("button", {
|
|
307
308
|
type: "button",
|
|
308
309
|
className: "ssg-ask-link",
|
|
309
310
|
onClick: () => {
|
|
310
|
-
|
|
311
|
+
j(), M(T);
|
|
311
312
|
},
|
|
312
313
|
children: v.retry
|
|
313
314
|
})]
|
|
314
315
|
}),
|
|
315
|
-
!S && C !== null && /* @__PURE__ */
|
|
316
|
-
C.phase === "applied" && /* @__PURE__ */
|
|
316
|
+
!S && C !== null && /* @__PURE__ */ s(a, { children: [
|
|
317
|
+
C.phase === "applied" && /* @__PURE__ */ s("div", {
|
|
317
318
|
className: "ssg-ask-result",
|
|
318
|
-
children: [/* @__PURE__ */
|
|
319
|
+
children: [/* @__PURE__ */ s("div", {
|
|
319
320
|
className: "ssg-ask-result-head",
|
|
320
|
-
children: [/* @__PURE__ */
|
|
321
|
+
children: [/* @__PURE__ */ o("span", {
|
|
321
322
|
className: "ssg-ask-result-title",
|
|
322
323
|
children: v.appliedTitle
|
|
323
|
-
}), /* @__PURE__ */
|
|
324
|
+
}), /* @__PURE__ */ s("span", {
|
|
324
325
|
className: "ssg-ask-result-actions",
|
|
325
|
-
children: [/* @__PURE__ */
|
|
326
|
+
children: [/* @__PURE__ */ o("button", {
|
|
326
327
|
type: "button",
|
|
327
328
|
className: "ssg-ask-link",
|
|
328
329
|
onClick: () => {
|
|
329
|
-
|
|
330
|
+
j(), _.undo();
|
|
330
331
|
},
|
|
331
332
|
children: v.undo
|
|
332
|
-
}), /* @__PURE__ */
|
|
333
|
+
}), /* @__PURE__ */ o("button", {
|
|
333
334
|
type: "button",
|
|
334
335
|
className: "ssg-ask-link",
|
|
335
336
|
onClick: () => {
|
|
336
|
-
|
|
337
|
+
j(), _.dismiss();
|
|
337
338
|
},
|
|
338
339
|
children: v.close
|
|
339
340
|
})]
|
|
340
341
|
})]
|
|
341
|
-
}), C.items.length > 0 ? /* @__PURE__ */
|
|
342
|
+
}), C.items.length > 0 ? /* @__PURE__ */ o("ul", {
|
|
342
343
|
ref: k,
|
|
343
344
|
className: "ssg-ask-chips",
|
|
344
|
-
children: C.items.map((e, t) => /* @__PURE__ */
|
|
345
|
+
children: C.items.map((e, t) => /* @__PURE__ */ s("li", {
|
|
345
346
|
className: "ssg-ask-chip",
|
|
346
347
|
title: `${e.label}: ${e.text}`,
|
|
347
348
|
children: [
|
|
348
|
-
/* @__PURE__ */
|
|
349
|
+
/* @__PURE__ */ o("span", {
|
|
349
350
|
className: "ssg-ask-chip-label",
|
|
350
351
|
children: e.label
|
|
351
352
|
}),
|
|
352
|
-
/* @__PURE__ */
|
|
353
|
+
/* @__PURE__ */ o("span", {
|
|
353
354
|
className: "ssg-ask-chip-text",
|
|
354
355
|
children: e.text
|
|
355
356
|
}),
|
|
356
|
-
/* @__PURE__ */
|
|
357
|
+
/* @__PURE__ */ o("button", {
|
|
357
358
|
type: "button",
|
|
358
359
|
className: "ssg-ask-chip-remove",
|
|
359
|
-
"aria-label":
|
|
360
|
+
"aria-label": d(v.removeItem, {
|
|
360
361
|
label: e.label,
|
|
361
362
|
text: e.text
|
|
362
363
|
}),
|
|
363
364
|
onClick: () => {
|
|
364
|
-
|
|
365
|
+
j(t), _.remove(e.id);
|
|
365
366
|
},
|
|
366
367
|
children: "×"
|
|
367
368
|
})
|
|
368
369
|
]
|
|
369
370
|
}, e.id))
|
|
370
|
-
}) : /* @__PURE__ */
|
|
371
|
+
}) : /* @__PURE__ */ o("div", {
|
|
371
372
|
className: "ssg-ask-empty",
|
|
372
373
|
children: v.allRemoved
|
|
373
374
|
})]
|
|
374
375
|
}),
|
|
375
|
-
C.phase === "unchanged" && /* @__PURE__ */
|
|
376
|
+
C.phase === "unchanged" && /* @__PURE__ */ s("div", {
|
|
376
377
|
className: "ssg-ask-note",
|
|
377
|
-
children: [/* @__PURE__ */
|
|
378
|
+
children: [/* @__PURE__ */ o("span", { children: v.unchanged }), /* @__PURE__ */ o("button", {
|
|
378
379
|
type: "button",
|
|
379
380
|
className: "ssg-ask-link",
|
|
380
381
|
onClick: () => {
|
|
381
|
-
|
|
382
|
+
j(), _.dismiss();
|
|
382
383
|
},
|
|
383
384
|
children: v.close
|
|
384
385
|
})]
|
|
385
386
|
}),
|
|
386
|
-
C.phase === "undone" && /* @__PURE__ */
|
|
387
|
+
C.phase === "undone" && /* @__PURE__ */ s("div", {
|
|
387
388
|
className: "ssg-ask-note",
|
|
388
|
-
children: [/* @__PURE__ */
|
|
389
|
+
children: [/* @__PURE__ */ o("span", { children: v.undone }), /* @__PURE__ */ o("button", {
|
|
389
390
|
type: "button",
|
|
390
391
|
className: "ssg-ask-link",
|
|
391
392
|
onClick: () => {
|
|
392
|
-
|
|
393
|
+
j(), _.dismiss();
|
|
393
394
|
},
|
|
394
395
|
children: v.close
|
|
395
396
|
})]
|
|
396
397
|
}),
|
|
397
|
-
C.phase !== "undone" && C.phase !== "changed" && C.dropped.length > 0 && /* @__PURE__ */
|
|
398
|
+
C.phase !== "undone" && C.phase !== "changed" && C.dropped.length > 0 && /* @__PURE__ */ s("div", {
|
|
398
399
|
className: "ssg-ask-note ssg-ask-note--warn",
|
|
399
|
-
children: [/* @__PURE__ */
|
|
400
|
+
children: [/* @__PURE__ */ o("span", {
|
|
400
401
|
className: "ssg-ask-note-title",
|
|
401
402
|
children: v.droppedTitle
|
|
402
|
-
}), /* @__PURE__ */
|
|
403
|
+
}), /* @__PURE__ */ o("ul", {
|
|
403
404
|
className: "ssg-ask-dropped",
|
|
404
|
-
children: C.dropped.map((e, t) => /* @__PURE__ */
|
|
405
|
+
children: C.dropped.map((e, t) => /* @__PURE__ */ o("li", { children: e }, t))
|
|
405
406
|
})]
|
|
406
407
|
}),
|
|
407
|
-
C.phase !== "undone" && C.phase !== "changed" && C.unsupported !== null && /* @__PURE__ */
|
|
408
|
+
C.phase !== "undone" && C.phase !== "changed" && C.unsupported !== null && /* @__PURE__ */ o("div", {
|
|
408
409
|
className: "ssg-ask-note",
|
|
409
|
-
children: /* @__PURE__ */
|
|
410
|
+
children: /* @__PURE__ */ o("span", { children: d(v.fromAi, { text: C.unsupported }) })
|
|
410
411
|
})
|
|
411
412
|
] }),
|
|
412
|
-
_.notice !== null && /* @__PURE__ */
|
|
413
|
+
_.notice !== null && /* @__PURE__ */ s("div", {
|
|
413
414
|
className: "ssg-ask-note ssg-ask-note--warn",
|
|
414
|
-
children: [/* @__PURE__ */
|
|
415
|
+
children: [/* @__PURE__ */ o("span", { children: _.notice }), C?.phase === "changed" && /* @__PURE__ */ o("button", {
|
|
415
416
|
type: "button",
|
|
416
417
|
className: "ssg-ask-link",
|
|
417
418
|
onClick: () => {
|
|
418
|
-
|
|
419
|
+
j(), _.dismiss();
|
|
419
420
|
},
|
|
420
421
|
children: v.close
|
|
421
422
|
})]
|
|
@@ -426,4 +427,64 @@ function M({ examples: d, placeholder: f, label: p, className: m, theme: h = "li
|
|
|
426
427
|
});
|
|
427
428
|
}
|
|
428
429
|
//#endregion
|
|
429
|
-
|
|
430
|
+
//#region src/ai/useGridAgentTools.ts
|
|
431
|
+
var L = (e) => {
|
|
432
|
+
let t = e;
|
|
433
|
+
return {
|
|
434
|
+
update: (e) => {
|
|
435
|
+
t = e;
|
|
436
|
+
},
|
|
437
|
+
grid: () => {
|
|
438
|
+
let e = t.grid;
|
|
439
|
+
return typeof e == "function" ? e() : e.current;
|
|
440
|
+
},
|
|
441
|
+
confirm: (e) => t.confirm ? t.confirm(e) : !0,
|
|
442
|
+
onToolCall: (e) => {
|
|
443
|
+
t.onToolCall?.(e);
|
|
444
|
+
},
|
|
445
|
+
localeText: () => t.localeText
|
|
446
|
+
};
|
|
447
|
+
}, R = (e, t) => e === void 0 || typeof e == "boolean" ? e : e[t] ?? !0, z = (e, t) => typeof e == "number" ? { [t]: e } : e, B = (n) => {
|
|
448
|
+
let [i] = r(() => L(n));
|
|
449
|
+
e(() => {
|
|
450
|
+
i.update(n);
|
|
451
|
+
});
|
|
452
|
+
let { columns: a, name: o, description: s, allowFilter: c, allowSort: l, allowSearch: u, allowColumnVisibility: d } = n, f = n.columnHints === void 0 ? void 0 : JSON.stringify(n.columnHints), p = R(n.readRows, "maxRows"), m = R(n.readSelection, "maxCells"), h = R(n.editCells, "maxCells"), g = n.now?.getTime(), _ = n.confirm !== void 0;
|
|
453
|
+
return t(() => E({
|
|
454
|
+
grid: i.grid,
|
|
455
|
+
columns: a,
|
|
456
|
+
name: o,
|
|
457
|
+
description: s,
|
|
458
|
+
columnHints: f === void 0 ? void 0 : JSON.parse(f),
|
|
459
|
+
allowFilter: c,
|
|
460
|
+
allowSort: l,
|
|
461
|
+
allowSearch: u,
|
|
462
|
+
allowColumnVisibility: d,
|
|
463
|
+
get localeText() {
|
|
464
|
+
return i.localeText();
|
|
465
|
+
},
|
|
466
|
+
now: g === void 0 ? void 0 : new Date(g),
|
|
467
|
+
readRows: z(p, "maxRows"),
|
|
468
|
+
readSelection: z(m, "maxCells"),
|
|
469
|
+
editCells: z(h, "maxCells"),
|
|
470
|
+
confirm: _ ? i.confirm : void 0,
|
|
471
|
+
onToolCall: i.onToolCall
|
|
472
|
+
}), [
|
|
473
|
+
i,
|
|
474
|
+
a,
|
|
475
|
+
o,
|
|
476
|
+
s,
|
|
477
|
+
f,
|
|
478
|
+
c,
|
|
479
|
+
l,
|
|
480
|
+
u,
|
|
481
|
+
d,
|
|
482
|
+
g,
|
|
483
|
+
p,
|
|
484
|
+
m,
|
|
485
|
+
h,
|
|
486
|
+
_
|
|
487
|
+
]);
|
|
488
|
+
};
|
|
489
|
+
//#endregion
|
|
490
|
+
export { I as GridAskBar, T as createGridAgentTools, f as createGridAskRequest, m as describeGridAskView, g as gridAskSystemPrompt, _ as isGridAskColumnsChanged, y as isSameGridAskView, x as readGridAskAnswer, D as registerGridAgentTools, C as removeGridAskItem, B as useGridAgentTools, P as useGridAsk };
|
package/dist/common.d.ts
CHANGED
|
@@ -2,6 +2,6 @@ export { numberFormatter } from '@ishibashi0112/spreadsheet-grid-core/internal/l
|
|
|
2
2
|
export { numberParser } from '@ishibashi0112/spreadsheet-grid-core/internal/logic/valueParsers';
|
|
3
3
|
export { restoreColumnsFromState } from '@ishibashi0112/spreadsheet-grid-core/internal/logic/gridState';
|
|
4
4
|
export { preloadGridPopups } from './view/lazyPopups.js';
|
|
5
|
-
export type { SpreadsheetGridProps, GridColumn, GridColumnPinned, GridColumnEditor, EditorCommitDirection, EditorEnterMove, CellEditorContext, GridSelectEditorOption, GridSelectLoadOptionsParams, GridSelectFillRowContext, GridValidationMode, CellValidationContext, CellValidationResult, GridInvalidCell, EditorCommitResult, GridChanges, GridChangedRow, GridChangesSummary, GridChangesSavedTarget, GridAddedRow, GridRemovedRow, GridTrackChangesOptions, GridRangeDecoration, GridTreeDataOptions, GridTreeRow, CellTreeContext, CellTreeState, TreeRowOpenChangeParams, GridRevealRowOptions, GridRowKey, GridAggFuncName, GridAggFuncParams, GridAggFunc, GridGroupRow, GridSelectFilterOption, GetFilterOptionsParams, GetFilterOptionsResult, ColumnFilterTypeOption, ColumnFilterUiType, CellRenderContext, HeaderRenderContext, GridColumnGroup, GridColumnGroupCollapsible, ColumnGroupHeaderRenderContext, ColumnGroupOpenChangeParams, GridExportColumnGroup, CellStyleContext, CanEditCellContext, GridConditionalFormat, RowStyleContext, DetailRowOptions, GridClassNames, GridSlotProps, GridFrameworkTypes, ReactGridTypes, DetailRowRenderContext, CellDetailContext, LabelRowOptions, LabelRowRenderContext, GridLabelRow, LabelRowSortMode, TotalRowOptions, TotalRowCellContext, TotalRowCellKind, FillHandleOptions, GridFillValueParams, GridFillDirection, GridFillKind, RowDragContext, RowMoveParams, RowDropParams, GridCellRef, GridCellEventParams, GridCellDoubleClickParams, CellValueFormatter, CellValueFormatterParams, SpreadsheetGridSlotContext, SpreadsheetGridDerivedSummary, SpreadsheetGridSelectionStats, GridLocaleText, GridLocaleTextTemplate, GridVerticalAlign, GridTextEditorEnterKey, GlobalFilterStatus, GridSelectionAggregates, CellCoord, CellRange, GridSelection, GridSortState, GridSortEntry, GridSortDirection, ColumnFilterValue, GridFilterState, SetColumnFilterValue, NumberColumnFilterValue, NumberSetColumnFilterValue, ParsedNumberFilter, TextSetColumnFilterValue, ParsedTextFilter, DateSetColumnFilterValue, ParsedDateFilter, DateFilterPreset, DateFilterPresetOption, CustomDateFilterPreset, DateFilterPresetRange, FilterDateInputContext, TextColumnFilterValue, DateColumnFilterValue, SelectColumnFilterValue, CustomColumnFilterValue, ServerSideDataSource, ServerSideQuery, ServerSideGetRowsParams, ServerSideGetRowsResult, ServerSideLoadErrorParams, ServerSideCellChange, ServerSideRowUpdate, ServerSideUpdateRowsParams, ServerSideUpdateRowsResult, ServerSideWriteErrorParams, RowModel, SpreadsheetGridHandle, RowSelectionModel, RowSelectionMode, ScrollAlign, GridScrollPosition, GridScrollEventParams, CsvExportScope, CsvExportOptions, GridExportOptions, GridExportCell, GridExportData, GridState, GridStatePatch, GridColumnState, GridDensity, GridTheme, UndoRedoState, GridMotion, GridPopupContainer, GridGlobalFilterMatch, GridPasteSkippedCell, GridPasteSkippedParams, GridExcelShortcutsOptions, GridNewRowOptions, GridApplyRowsOptions, GridPinnedRowPosition, FindOptions, FindChangeParams, GridFindOpenOptions, GridFindReplaceResult, GridDataBarFormat, GridColorScaleFormat, GridChipTone, GridChipSpec, GridChipMap, AutoSizeColumnsMode, GridContextMenuTarget, GridContextMenuParams, GridContextMenuItem, GridContextMenuActionItem, GridContextMenuLabelItem, GridContextMenuSeparatorItem, GridContextMenuCustomItem, ScrollHintOptions, ScrollHintTrigger, ScrollHintRenderArgs, } from './model/gridTypes.js';
|
|
5
|
+
export type { SpreadsheetGridProps, GridColumn, GridColumnPinned, GridColumnEditor, EditorCommitDirection, EditorEnterMove, CellEditorContext, GridSelectEditorOption, GridSelectLoadOptionsParams, GridSelectFillRowContext, GridValidationMode, CellValidationContext, CellValidationResult, GridInvalidCell, EditorCommitResult, GridChanges, GridChangedRow, GridChangesSummary, GridChangesSavedTarget, GridAddedRow, GridRemovedRow, GridTrackChangesOptions, GridRangeDecoration, GridTreeDataOptions, GridTreeRow, CellTreeContext, CellTreeState, TreeRowOpenChangeParams, GridRevealRowOptions, GridRowKey, GridAggFuncName, GridAggFuncParams, GridAggFunc, GridGroupRow, GridSelectFilterOption, GetFilterOptionsParams, GetFilterOptionsResult, ColumnFilterTypeOption, ColumnFilterUiType, CellRenderContext, HeaderRenderContext, GridColumnGroup, GridColumnGroupCollapsible, ColumnGroupHeaderRenderContext, ColumnGroupOpenChangeParams, GridExportColumnGroup, CellStyleContext, CanEditCellContext, GridConditionalFormat, RowStyleContext, DetailRowOptions, GridClassNames, GridSlotProps, GridFrameworkTypes, ReactGridTypes, DetailRowRenderContext, CellDetailContext, LabelRowOptions, LabelRowRenderContext, GridLabelRow, LabelRowSortMode, TotalRowOptions, TotalRowCellContext, TotalRowCellKind, FillHandleOptions, GridFillValueParams, GridFillDirection, GridFillKind, RowDragContext, RowMoveParams, RowDropParams, GridCellRef, GridCellEventParams, GridCellDoubleClickParams, CellValueFormatter, CellValueFormatterParams, SpreadsheetGridSlotContext, SpreadsheetGridDerivedSummary, SpreadsheetGridSelectionStats, GridLocaleText, GridLocaleTextTemplate, GridVerticalAlign, GridTextEditorEnterKey, GlobalFilterStatus, GridSelectionAggregates, CellCoord, CellRange, GridSelection, GridSortState, GridSortEntry, GridSortDirection, ColumnFilterValue, GridFilterState, SetColumnFilterValue, NumberColumnFilterValue, NumberSetColumnFilterValue, ParsedNumberFilter, TextSetColumnFilterValue, ParsedTextFilter, DateSetColumnFilterValue, ParsedDateFilter, DateFilterPreset, DateFilterPresetOption, CustomDateFilterPreset, DateFilterPresetRange, FilterDateInputContext, TextColumnFilterValue, DateColumnFilterValue, SelectColumnFilterValue, CustomColumnFilterValue, ServerSideDataSource, ServerSideQuery, ServerSideGetRowsParams, ServerSideGetRowsResult, ServerSideLoadErrorParams, ServerSideCellChange, ServerSideRowUpdate, ServerSideUpdateRowsParams, ServerSideUpdateRowsResult, ServerSideWriteErrorParams, RowModel, SpreadsheetGridHandle, RowSelectionModel, RowSelectionMode, ScrollAlign, GridScrollPosition, GridScrollEventParams, CsvExportScope, CsvExportOptions, GridExportOptions, GridExportCell, GridExportData, GridState, GridStatePatch, GridColumnState, GridDensity, GridTheme, UndoRedoState, GridMotion, GridPopupContainer, GridGlobalFilterMatch, GridPasteSkippedCell, GridPasteSkippedParams, GridExcelShortcutsOptions, GridNewRowOptions, GridApplyRowsOptions, GridCellValueEdit, GridCellValueSkip, GridCellValueSkipReason, GridCellValueMarked, GridSetCellValuesOptions, GridSetCellValuesResult, GridRowCounts, GridPinnedRowPosition, FindOptions, FindChangeParams, GridFindOpenOptions, GridFindReplaceResult, GridDataBarFormat, GridColorScaleFormat, GridChipTone, GridChipSpec, GridChipMap, AutoSizeColumnsMode, GridContextMenuTarget, GridContextMenuParams, GridContextMenuItem, GridContextMenuActionItem, GridContextMenuLabelItem, GridContextMenuSeparatorItem, GridContextMenuCustomItem, ScrollHintOptions, ScrollHintTrigger, ScrollHintRenderArgs, } from './model/gridTypes.js';
|
|
6
6
|
export type { NumberFormatterOptions } from '@ishibashi0112/spreadsheet-grid-core/internal/logic/valueFormatters';
|
|
7
7
|
export type { NumberParserOptions } from '@ishibashi0112/spreadsheet-grid-core/internal/logic/valueParsers';
|
|
@@ -11,8 +11,9 @@ export type UseServerSideRowModelResult<T> = {
|
|
|
11
11
|
refresh: () => void;
|
|
12
12
|
loadError: ServerSideLoadErrorState | null;
|
|
13
13
|
retryFailedBlocks: () => void;
|
|
14
|
+
isLoading: () => boolean;
|
|
14
15
|
canUpdateRows: boolean;
|
|
15
|
-
applyCellEdits: (edits: ServerSideCellEditInput<T>[]) => number;
|
|
16
|
+
applyCellEdits: (edits: ServerSideCellEditInput<T>[], onSettled?: (saved: boolean) => void) => number;
|
|
16
17
|
writeError: ServerSideWriteErrorState | null;
|
|
17
18
|
refetching: boolean;
|
|
18
19
|
};
|