@ishibashi0112/spreadsheet-grid-solid 0.1.2 → 1.4.1
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 +9 -8
- package/README.md +20 -18
- package/dist/{ColumnFilterPopover-CzSRfcDF.js → ColumnFilterPopover-mENgY4gl.js} +47 -47
- package/dist/ai/GridAskBar.d.ts +20 -0
- package/dist/ai/createGridAsk.d.ts +94 -0
- package/dist/ai.d.ts +7 -0
- package/dist/ai.js +412 -0
- package/dist/{columnVirtualizer-Bv79_vW1.js → columnVirtualizer-DdL7-ijS.js} +26 -19
- package/dist/devWarnings.d.ts +0 -1
- package/dist/editors/CellEditorLayer.d.ts +2 -0
- package/dist/editors/CustomCellEditor.d.ts +2 -0
- package/dist/index.js +2677 -2577
- package/dist/locales/en.d.ts +1 -1
- package/dist/locales/en.js +2 -2
- package/dist/primitives/effectApply.d.ts +1 -0
- package/dist/primitives/serverSnapshot.d.ts +5 -0
- package/dist/primitives/storeRows.d.ts +2 -0
- package/dist/source/ai.jsx +619 -0
- package/dist/source/chunks/{ColumnFilterPopover-2DW5SZT3.jsx → ColumnFilterPopover-D7INPNVB.jsx} +1 -1
- package/dist/source/chunks/{chunk-FTQFOPXC.jsx → chunk-ZZTXTW4Z.jsx} +10 -2
- package/dist/source/index.jsx +863 -621
- package/dist/view/DetailToggleButton.d.ts +1 -0
- package/package.json +8 -3
- package/skills/spreadsheet-grid-solid/SKILL.md +6 -4
package/dist/locales/en.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { localeTextEn } from '@ishibashi0112/spreadsheet-grid-core/internal/locales/en';
|
|
1
|
+
export { gridAskLocaleTextEn, localeTextEn } from '@ishibashi0112/spreadsheet-grid-core/internal/locales/en';
|
package/dist/locales/en.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { e as localeTextEn };
|
|
1
|
+
import { gridAskLocaleTextEn as e, localeTextEn as t } from "@ishibashi0112/spreadsheet-grid-core/internal/locales/en";
|
|
2
|
+
export { e as gridAskLocaleTextEn, t as localeTextEn };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function outsideGraphApply<V>(apply: (value: V) => void): (...values: [V]) => void;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { SpreadsheetGridProps } from '../model/gridTypes.js';
|
|
2
|
+
export declare const SERVER_FRAME_ATTRIBUTE = "data-ssg-ssr";
|
|
3
|
+
export declare const SERVER_SNAPSHOT_ATTRIBUTE = "data-ssg-ssr-snapshot";
|
|
4
|
+
export declare function createSnapshotProps<T extends object>(props: SpreadsheetGridProps<T>): SpreadsheetGridProps<T>;
|
|
5
|
+
export declare function revealServerFrame(root: Element | null | undefined, display?: string | undefined): void;
|
|
@@ -0,0 +1,619 @@
|
|
|
1
|
+
// src/ai/GridAskBar.tsx
|
|
2
|
+
import { For, Show, createEffect as createEffect2, createMemo as createMemo2, createSignal as createSignal2, isHydrating, omit, onSettled as onSettled2 } from "solid-js";
|
|
3
|
+
import { systemColorSchemeStore } from "@ishibashi0112/spreadsheet-grid-core/internal/controllers/systemColorSchemeStore";
|
|
4
|
+
import { resolveGridThemeClassName } from "@ishibashi0112/spreadsheet-grid-core/internal/logic/theme";
|
|
5
|
+
import { resolveGridAskLocaleText as resolveGridAskLocaleText2 } from "@ishibashi0112/spreadsheet-grid-core/internal/logic/gridAskLocaleText";
|
|
6
|
+
import { formatLocaleText } from "@ishibashi0112/spreadsheet-grid-core/internal/logic/localeTextFilters";
|
|
7
|
+
|
|
8
|
+
// src/ai/createGridAsk.ts
|
|
9
|
+
import { createEffect, createMemo, createSignal, onSettled } from "solid-js";
|
|
10
|
+
import {
|
|
11
|
+
createGridAskRequest,
|
|
12
|
+
describeGridAskView,
|
|
13
|
+
isGridAskColumnsChanged,
|
|
14
|
+
isSameGridAskView,
|
|
15
|
+
readGridAskAnswer,
|
|
16
|
+
removeGridAskItem
|
|
17
|
+
} from "@ishibashi0112/spreadsheet-grid-core/internal/logic/gridAsk";
|
|
18
|
+
import {
|
|
19
|
+
resolveGridAskLocaleText
|
|
20
|
+
} from "@ishibashi0112/spreadsheet-grid-core/internal/logic/gridAskLocaleText";
|
|
21
|
+
var CHANGE_CHECK_INTERVAL_MS = 1e3;
|
|
22
|
+
var CHANGE_CHECK_AFTER_INPUT_MS = 400;
|
|
23
|
+
var isViewUnchanged = (now, applied, columnVisibility) => columnVisibility ? isSameGridAskView(now, applied) : isSameGridAskView({ ...now, columns: void 0 }, { ...applied, columns: void 0 });
|
|
24
|
+
var toAskOptions = (options) => ({
|
|
25
|
+
columns: options.columns,
|
|
26
|
+
columnHints: options.columnHints,
|
|
27
|
+
allowFilter: options.allowFilter,
|
|
28
|
+
allowSort: options.allowSort,
|
|
29
|
+
allowSearch: options.allowSearch,
|
|
30
|
+
allowColumnVisibility: options.allowColumnVisibility,
|
|
31
|
+
localeText: options.localeText
|
|
32
|
+
});
|
|
33
|
+
var toApplicable = (current, next) => isGridAskColumnsChanged(current, next) ? next : { ...next, columns: void 0 };
|
|
34
|
+
var restoreView = (current, before, columnVisibility) => {
|
|
35
|
+
if (!columnVisibility) {
|
|
36
|
+
return { ...current, filters: before.filters, sort: before.sort };
|
|
37
|
+
}
|
|
38
|
+
const hidden = new Set((before.columns ?? []).filter((entry) => entry.visible === false).map((entry) => entry.key));
|
|
39
|
+
return {
|
|
40
|
+
...current,
|
|
41
|
+
filters: before.filters,
|
|
42
|
+
sort: before.sort,
|
|
43
|
+
columns: current.columns?.map((entry) => {
|
|
44
|
+
if (hidden.has(entry.key)) {
|
|
45
|
+
return { ...entry, visible: false };
|
|
46
|
+
}
|
|
47
|
+
const next = { ...entry };
|
|
48
|
+
delete next.visible;
|
|
49
|
+
return next;
|
|
50
|
+
})
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
var readTarget = (options) => {
|
|
54
|
+
const grid = options.grid;
|
|
55
|
+
const target = typeof grid === "function" ? grid() : grid;
|
|
56
|
+
return target ?? null;
|
|
57
|
+
};
|
|
58
|
+
function createGridAsk(options) {
|
|
59
|
+
const [status, setStatus] = createSignal("idle", { name: "gridAskStatus" });
|
|
60
|
+
const [error, setError] = createSignal(null, { name: "gridAskError" });
|
|
61
|
+
const [notice, setNotice] = createSignal(null, { name: "gridAskNotice" });
|
|
62
|
+
const [session, setSession] = createSignal(null, { name: "gridAskSession" });
|
|
63
|
+
let pending = null;
|
|
64
|
+
let currentSession = null;
|
|
65
|
+
const writeSession = (next) => {
|
|
66
|
+
currentSession = next;
|
|
67
|
+
setSession(() => next);
|
|
68
|
+
};
|
|
69
|
+
onSettled(() => () => {
|
|
70
|
+
const controller = pending;
|
|
71
|
+
if (controller === null) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
pending = null;
|
|
75
|
+
controller.abort();
|
|
76
|
+
});
|
|
77
|
+
const texts = () => resolveGridAskLocaleText(options.localeText);
|
|
78
|
+
const columnVisibility = () => options.allowColumnVisibility ?? false;
|
|
79
|
+
if (process.env.NODE_ENV !== "production") {
|
|
80
|
+
let warnedHintKeys = "";
|
|
81
|
+
const unknownHintKeys = createMemo(() => {
|
|
82
|
+
const hints = options.columnHints;
|
|
83
|
+
if (!hints) {
|
|
84
|
+
return "";
|
|
85
|
+
}
|
|
86
|
+
const columns = options.columns;
|
|
87
|
+
return Object.keys(hints).filter((key) => !columns.some((column) => column.key === key)).join(", ");
|
|
88
|
+
});
|
|
89
|
+
createEffect(
|
|
90
|
+
unknownHintKeys,
|
|
91
|
+
(keys) => {
|
|
92
|
+
if (keys !== "" && keys !== warnedHintKeys) {
|
|
93
|
+
warnedHintKeys = keys;
|
|
94
|
+
console.warn(
|
|
95
|
+
`[spreadsheet-grid] GridAskBar / createGridAsk \u306E columnHints \u306B\u5217\u306B\u7121\u3044\u30AD\u30FC\u304C\u3042\u308A\u307E\u3059: ${keys}\u3002\u5217\u306E key \u3068\u540C\u3058\u540D\u524D\u306B\u3057\u3066\u304F\u3060\u3055\u3044(\u3053\u306E\u88DC\u8DB3\u3084 \`false\` \u306F\u52B9\u3044\u3066\u3044\u307E\u305B\u3093)\u3002
|
|
96
|
+
[spreadsheet-grid] columnHints of GridAskBar / createGridAsk has keys that are not columns: ${keys}. Use the column keys (these hints and \`false\` have no effect).`
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
{ name: "gridAskHintWarning" }
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
const appliedSession = createMemo(() => {
|
|
104
|
+
const value = session();
|
|
105
|
+
return value !== null && value.view.phase === "applied" ? value : null;
|
|
106
|
+
});
|
|
107
|
+
createEffect(
|
|
108
|
+
appliedSession,
|
|
109
|
+
(applied) => {
|
|
110
|
+
if (applied === null) {
|
|
111
|
+
return void 0;
|
|
112
|
+
}
|
|
113
|
+
let inputTimer = null;
|
|
114
|
+
const check = () => {
|
|
115
|
+
if (pending !== null || currentSession !== applied) {
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
const target = readTarget(options);
|
|
119
|
+
if (target === null || isViewUnchanged(target.getState(), applied.applied, columnVisibility())) {
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
writeSession({ ...applied, view: { ...applied.view, phase: "changed" } });
|
|
123
|
+
setNotice(texts().changedNotice);
|
|
124
|
+
};
|
|
125
|
+
const checkSoon = () => {
|
|
126
|
+
if (inputTimer === null) {
|
|
127
|
+
inputTimer = setTimeout(() => {
|
|
128
|
+
inputTimer = null;
|
|
129
|
+
check();
|
|
130
|
+
}, CHANGE_CHECK_AFTER_INPUT_MS);
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
const timer = setInterval(check, CHANGE_CHECK_INTERVAL_MS);
|
|
134
|
+
document.addEventListener("click", checkSoon, true);
|
|
135
|
+
document.addEventListener("keyup", checkSoon, true);
|
|
136
|
+
return () => {
|
|
137
|
+
clearInterval(timer);
|
|
138
|
+
if (inputTimer !== null) {
|
|
139
|
+
clearTimeout(inputTimer);
|
|
140
|
+
}
|
|
141
|
+
document.removeEventListener("click", checkSoon, true);
|
|
142
|
+
document.removeEventListener("keyup", checkSoon, true);
|
|
143
|
+
};
|
|
144
|
+
},
|
|
145
|
+
{ name: "gridAskChangeCheck" }
|
|
146
|
+
);
|
|
147
|
+
const submit = async (raw) => {
|
|
148
|
+
const text = raw.trim();
|
|
149
|
+
if (text === "" || pending !== null) {
|
|
150
|
+
return false;
|
|
151
|
+
}
|
|
152
|
+
const grid = readTarget(options);
|
|
153
|
+
if (grid === null) {
|
|
154
|
+
setError(texts().noGrid);
|
|
155
|
+
return false;
|
|
156
|
+
}
|
|
157
|
+
const controller = new AbortController();
|
|
158
|
+
pending = controller;
|
|
159
|
+
setStatus("asking");
|
|
160
|
+
setError(null);
|
|
161
|
+
setNotice(null);
|
|
162
|
+
let answer;
|
|
163
|
+
try {
|
|
164
|
+
answer = await options.ask(createGridAskRequest(text, grid.getState(), toAskOptions(options)), {
|
|
165
|
+
signal: controller.signal
|
|
166
|
+
});
|
|
167
|
+
} catch (caught) {
|
|
168
|
+
if (controller.signal.aborted) {
|
|
169
|
+
return false;
|
|
170
|
+
}
|
|
171
|
+
pending = null;
|
|
172
|
+
setStatus("idle");
|
|
173
|
+
options.onError?.(caught);
|
|
174
|
+
setError(texts().askFailed);
|
|
175
|
+
return false;
|
|
176
|
+
}
|
|
177
|
+
if (controller.signal.aborted) {
|
|
178
|
+
return false;
|
|
179
|
+
}
|
|
180
|
+
pending = null;
|
|
181
|
+
setStatus("idle");
|
|
182
|
+
const latestOptions = toAskOptions(options);
|
|
183
|
+
const target = readTarget(options);
|
|
184
|
+
if (target === null) {
|
|
185
|
+
setError(texts().noGrid);
|
|
186
|
+
return false;
|
|
187
|
+
}
|
|
188
|
+
const before = target.getState();
|
|
189
|
+
const result = readGridAskAnswer(answer, before, latestOptions);
|
|
190
|
+
if (!result.ok) {
|
|
191
|
+
setError(result.message);
|
|
192
|
+
return false;
|
|
193
|
+
}
|
|
194
|
+
const view = { text, dropped: result.dropped, unsupported: result.unsupported };
|
|
195
|
+
setNotice(null);
|
|
196
|
+
if (!result.changed) {
|
|
197
|
+
writeSession({
|
|
198
|
+
view: { ...view, phase: "unchanged", items: describeGridAskView(before, latestOptions) },
|
|
199
|
+
before,
|
|
200
|
+
applied: before
|
|
201
|
+
});
|
|
202
|
+
return true;
|
|
203
|
+
}
|
|
204
|
+
target.applyState(toApplicable(before, result.state));
|
|
205
|
+
writeSession({
|
|
206
|
+
view: { ...view, phase: "applied", items: describeGridAskView(result.state, latestOptions) },
|
|
207
|
+
before,
|
|
208
|
+
applied: result.state
|
|
209
|
+
});
|
|
210
|
+
options.onApply?.({ text, state: result.state, dropped: result.dropped, unsupported: result.unsupported });
|
|
211
|
+
return true;
|
|
212
|
+
};
|
|
213
|
+
const cancel = () => {
|
|
214
|
+
const controller = pending;
|
|
215
|
+
if (controller === null) {
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
pending = null;
|
|
219
|
+
controller.abort();
|
|
220
|
+
setStatus("idle");
|
|
221
|
+
};
|
|
222
|
+
const readUnchanged = (current) => {
|
|
223
|
+
const target = readTarget(options);
|
|
224
|
+
if (target === null || current.view.phase !== "applied") {
|
|
225
|
+
return null;
|
|
226
|
+
}
|
|
227
|
+
const now = target.getState();
|
|
228
|
+
if (!isViewUnchanged(now, current.applied, columnVisibility())) {
|
|
229
|
+
setNotice(texts().changedNotice);
|
|
230
|
+
writeSession({ ...current, view: { ...current.view, phase: "changed" } });
|
|
231
|
+
return null;
|
|
232
|
+
}
|
|
233
|
+
return { target, now };
|
|
234
|
+
};
|
|
235
|
+
const undo = () => {
|
|
236
|
+
const current = currentSession;
|
|
237
|
+
if (current === null) {
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
const checked = readUnchanged(current);
|
|
241
|
+
if (checked === null) {
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
const restored = restoreView(checked.now, current.before, columnVisibility());
|
|
245
|
+
checked.target.applyState(toApplicable(checked.now, restored));
|
|
246
|
+
setNotice(null);
|
|
247
|
+
writeSession({ ...current, view: { ...current.view, phase: "undone" } });
|
|
248
|
+
};
|
|
249
|
+
const remove = (id) => {
|
|
250
|
+
const current = currentSession;
|
|
251
|
+
if (current === null) {
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
254
|
+
const checked = readUnchanged(current);
|
|
255
|
+
if (checked === null) {
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
const next = removeGridAskItem(checked.now, id);
|
|
259
|
+
checked.target.applyState(toApplicable(checked.now, next));
|
|
260
|
+
writeSession({
|
|
261
|
+
...current,
|
|
262
|
+
applied: next,
|
|
263
|
+
view: { ...current.view, items: describeGridAskView(next, toAskOptions(options)) }
|
|
264
|
+
});
|
|
265
|
+
};
|
|
266
|
+
const dismiss = () => {
|
|
267
|
+
writeSession(null);
|
|
268
|
+
setNotice(null);
|
|
269
|
+
setError(null);
|
|
270
|
+
};
|
|
271
|
+
return {
|
|
272
|
+
get status() {
|
|
273
|
+
return status();
|
|
274
|
+
},
|
|
275
|
+
get error() {
|
|
276
|
+
return error();
|
|
277
|
+
},
|
|
278
|
+
get notice() {
|
|
279
|
+
return notice();
|
|
280
|
+
},
|
|
281
|
+
get session() {
|
|
282
|
+
return session()?.view ?? null;
|
|
283
|
+
},
|
|
284
|
+
submit,
|
|
285
|
+
cancel,
|
|
286
|
+
undo,
|
|
287
|
+
remove,
|
|
288
|
+
dismiss
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
// src/ai/GridAskBar.tsx
|
|
293
|
+
var cx = (...names) => names.filter(Boolean).join(" ");
|
|
294
|
+
var createSystemPrefersDark = () => {
|
|
295
|
+
const initial = isHydrating() ? systemColorSchemeStore.getServerSnapshot() : systemColorSchemeStore.getSnapshot();
|
|
296
|
+
const [value, setValue] = createSignal2(initial, { name: "gridAskSystemColorScheme" });
|
|
297
|
+
onSettled2(() => {
|
|
298
|
+
setValue(systemColorSchemeStore.getSnapshot());
|
|
299
|
+
return systemColorSchemeStore.subscribe(() => setValue(systemColorSchemeStore.getSnapshot()));
|
|
300
|
+
});
|
|
301
|
+
return value;
|
|
302
|
+
};
|
|
303
|
+
function GridAskBar(props) {
|
|
304
|
+
const options = omit(props, "examples", "placeholder", "label", "className", "theme");
|
|
305
|
+
const ask = createGridAsk(options);
|
|
306
|
+
const texts = createMemo2(() => resolveGridAskLocaleText2(props.localeText));
|
|
307
|
+
const [text, setText] = createSignal2("", { name: "gridAskText" });
|
|
308
|
+
const systemPrefersDark = createSystemPrefersDark();
|
|
309
|
+
const themeClassName = () => resolveGridThemeClassName(props.theme ?? "light", systemPrefersDark());
|
|
310
|
+
const asking = createMemo2(() => ask.status === "asking");
|
|
311
|
+
let sentText = "";
|
|
312
|
+
const [hasSent, setHasSent] = createSignal2(false, { name: "gridAskHasSent" });
|
|
313
|
+
let rootEl;
|
|
314
|
+
let inputEl;
|
|
315
|
+
let chipsEl;
|
|
316
|
+
let focusAfter = null;
|
|
317
|
+
const [focusRequest, setFocusRequest] = createSignal2(0, { name: "gridAskFocusRequest" });
|
|
318
|
+
createEffect2(
|
|
319
|
+
() => [focusRequest(), ask.session, ask.notice, ask.error, ask.status],
|
|
320
|
+
() => {
|
|
321
|
+
const pending = focusAfter;
|
|
322
|
+
focusAfter = null;
|
|
323
|
+
if (pending === null || performance.now() - pending.at > 1e3) {
|
|
324
|
+
return;
|
|
325
|
+
}
|
|
326
|
+
const doc = rootEl?.ownerDocument ?? document;
|
|
327
|
+
const active = doc.activeElement;
|
|
328
|
+
if (active !== null && active !== doc.body) {
|
|
329
|
+
return;
|
|
330
|
+
}
|
|
331
|
+
const chips = chipsEl?.isConnected ? chipsEl.querySelectorAll(".ssg-ask-chip-remove") : void 0;
|
|
332
|
+
const target = pending.chip !== null && chips && chips.length > 0 ? chips[Math.min(pending.chip, chips.length - 1)] : inputEl;
|
|
333
|
+
target?.focus();
|
|
334
|
+
},
|
|
335
|
+
{ name: "gridAskFocusAfter" }
|
|
336
|
+
);
|
|
337
|
+
createEffect2(
|
|
338
|
+
asking,
|
|
339
|
+
(isAsking) => {
|
|
340
|
+
if (!isAsking) {
|
|
341
|
+
return void 0;
|
|
342
|
+
}
|
|
343
|
+
const root = rootEl;
|
|
344
|
+
const doc = root?.ownerDocument ?? document;
|
|
345
|
+
const handleKeyDown2 = (event) => {
|
|
346
|
+
if (event.key !== "Escape" || event.defaultPrevented || event.isComposing || event.keyCode === 229) {
|
|
347
|
+
return;
|
|
348
|
+
}
|
|
349
|
+
const inBar = root !== void 0 && event.composedPath().includes(root);
|
|
350
|
+
const active = doc.activeElement;
|
|
351
|
+
if (!inBar && active !== null && active !== doc.body) {
|
|
352
|
+
return;
|
|
353
|
+
}
|
|
354
|
+
event.preventDefault();
|
|
355
|
+
ask.cancel();
|
|
356
|
+
};
|
|
357
|
+
doc.addEventListener("keydown", handleKeyDown2);
|
|
358
|
+
return () => doc.removeEventListener("keydown", handleKeyDown2);
|
|
359
|
+
},
|
|
360
|
+
{ name: "gridAskEscape" }
|
|
361
|
+
);
|
|
362
|
+
const keepFocus = (chip = null) => {
|
|
363
|
+
focusAfter = { chip, at: performance.now() };
|
|
364
|
+
setFocusRequest((value) => value + 1);
|
|
365
|
+
};
|
|
366
|
+
const send = (value) => {
|
|
367
|
+
if (asking() || value.trim() === "") {
|
|
368
|
+
return;
|
|
369
|
+
}
|
|
370
|
+
const sent = value.trim();
|
|
371
|
+
sentText = sent;
|
|
372
|
+
setHasSent(true);
|
|
373
|
+
void ask.submit(value).then((answered) => {
|
|
374
|
+
if (answered) {
|
|
375
|
+
setText((current) => current.trim() === sent ? "" : current);
|
|
376
|
+
}
|
|
377
|
+
});
|
|
378
|
+
};
|
|
379
|
+
const handleKeyDown = (event) => {
|
|
380
|
+
if (event.key === "Enter" && (event.isComposing || event.keyCode === 229)) {
|
|
381
|
+
event.preventDefault();
|
|
382
|
+
}
|
|
383
|
+
};
|
|
384
|
+
const handleStop = (event) => {
|
|
385
|
+
event.preventDefault();
|
|
386
|
+
if (event.detail > 1) {
|
|
387
|
+
return;
|
|
388
|
+
}
|
|
389
|
+
ask.cancel();
|
|
390
|
+
};
|
|
391
|
+
const handleAsk = (event) => {
|
|
392
|
+
if (event.detail > 1) {
|
|
393
|
+
event.preventDefault();
|
|
394
|
+
}
|
|
395
|
+
};
|
|
396
|
+
const closeButton = () => <button
|
|
397
|
+
type="button"
|
|
398
|
+
class="ssg-ask-link"
|
|
399
|
+
onClick={() => {
|
|
400
|
+
keepFocus();
|
|
401
|
+
ask.dismiss();
|
|
402
|
+
}}
|
|
403
|
+
>
|
|
404
|
+
{texts().close}
|
|
405
|
+
</button>;
|
|
406
|
+
return <div ref={(node) => rootEl = node} class={cx("ssg-ask", themeClassName(), props.className)} data-ssg-ask="">
|
|
407
|
+
<form
|
|
408
|
+
class="ssg-ask-form"
|
|
409
|
+
onSubmit={(event) => {
|
|
410
|
+
event.preventDefault();
|
|
411
|
+
send(text());
|
|
412
|
+
}}
|
|
413
|
+
>
|
|
414
|
+
<svg class="ssg-ask-icon" viewBox="0 0 16 16" width="16" height="16" aria-hidden="true">
|
|
415
|
+
<path
|
|
416
|
+
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"
|
|
417
|
+
fill="currentColor"
|
|
418
|
+
/>
|
|
419
|
+
</svg>
|
|
420
|
+
<input
|
|
421
|
+
ref={(node) => inputEl = node}
|
|
422
|
+
class="ssg-ask-input"
|
|
423
|
+
type="text"
|
|
424
|
+
value={text()}
|
|
425
|
+
placeholder={props.placeholder ?? texts().placeholder}
|
|
426
|
+
aria-label={props.label ?? texts().label}
|
|
427
|
+
enterkeyhint="send"
|
|
428
|
+
onInput={(event) => setText(event.currentTarget.value)}
|
|
429
|
+
onKeyDown={handleKeyDown}
|
|
430
|
+
/>
|
|
431
|
+
<Show
|
|
432
|
+
when={asking()}
|
|
433
|
+
fallback={<button
|
|
434
|
+
type="submit"
|
|
435
|
+
class="ssg-ask-button ssg-ask-button--primary"
|
|
436
|
+
disabled={text().trim() === ""}
|
|
437
|
+
onClick={handleAsk}
|
|
438
|
+
>
|
|
439
|
+
{texts().submit}
|
|
440
|
+
</button>}
|
|
441
|
+
>
|
|
442
|
+
<button type="button" class="ssg-ask-button" onClick={handleStop}>
|
|
443
|
+
{texts().stop}
|
|
444
|
+
</button>
|
|
445
|
+
</Show>
|
|
446
|
+
</form>
|
|
447
|
+
<Show when={props.examples && props.examples.length > 0}>
|
|
448
|
+
<div class="ssg-ask-examples">
|
|
449
|
+
<span class="ssg-ask-examples-label">{texts().examples}</span>
|
|
450
|
+
{
|
|
451
|
+
/* 同じ例が 2 つあっても重ならないよう、位置で使い回します(React 版の key={index} と同じ)。 */
|
|
452
|
+
}
|
|
453
|
+
<For each={props.examples ?? []} keyed={false}>
|
|
454
|
+
{(example) => (
|
|
455
|
+
// 聞いている間は aria-disabled(disabled にすると押したボタンからフォーカスが外れ、Esc が届かない)。
|
|
456
|
+
<button
|
|
457
|
+
type="button"
|
|
458
|
+
class="ssg-ask-example"
|
|
459
|
+
aria-disabled={asking() ? "true" : void 0}
|
|
460
|
+
title={example()}
|
|
461
|
+
onClick={() => {
|
|
462
|
+
if (asking()) {
|
|
463
|
+
return;
|
|
464
|
+
}
|
|
465
|
+
const value = example();
|
|
466
|
+
setText(value);
|
|
467
|
+
send(value);
|
|
468
|
+
}}
|
|
469
|
+
>
|
|
470
|
+
{example()}
|
|
471
|
+
</button>
|
|
472
|
+
)}
|
|
473
|
+
</For>
|
|
474
|
+
</div>
|
|
475
|
+
</Show>
|
|
476
|
+
<div class="ssg-ask-output" aria-live="polite">
|
|
477
|
+
<Show when={asking()}>
|
|
478
|
+
<div class="ssg-ask-status">
|
|
479
|
+
<span class="ssg-ask-spinner" aria-hidden="true" />
|
|
480
|
+
{texts().thinking}
|
|
481
|
+
<span class="ssg-ask-hint">{texts().escHint}</span>
|
|
482
|
+
</div>
|
|
483
|
+
</Show>
|
|
484
|
+
{
|
|
485
|
+
/* 読み上げは .ssg-ask-output の aria-live で届きます(role="alert" を重ねると二重に読まれる)。 */
|
|
486
|
+
}
|
|
487
|
+
<Show when={!asking() && ask.error !== null}>
|
|
488
|
+
<div class="ssg-ask-note ssg-ask-note--error">
|
|
489
|
+
<span>{ask.error}</span>
|
|
490
|
+
<Show when={hasSent()}>
|
|
491
|
+
<button
|
|
492
|
+
type="button"
|
|
493
|
+
class="ssg-ask-link"
|
|
494
|
+
onClick={() => {
|
|
495
|
+
keepFocus();
|
|
496
|
+
send(sentText);
|
|
497
|
+
}}
|
|
498
|
+
>
|
|
499
|
+
{texts().retry}
|
|
500
|
+
</button>
|
|
501
|
+
</Show>
|
|
502
|
+
</div>
|
|
503
|
+
</Show>
|
|
504
|
+
<Show when={!asking() ? ask.session : null}>
|
|
505
|
+
{(session) => <>
|
|
506
|
+
<Show when={session().phase === "applied"}>
|
|
507
|
+
<div class="ssg-ask-result">
|
|
508
|
+
<div class="ssg-ask-result-head">
|
|
509
|
+
<span class="ssg-ask-result-title">{texts().appliedTitle}</span>
|
|
510
|
+
<span class="ssg-ask-result-actions">
|
|
511
|
+
<button
|
|
512
|
+
type="button"
|
|
513
|
+
class="ssg-ask-link"
|
|
514
|
+
onClick={() => {
|
|
515
|
+
keepFocus();
|
|
516
|
+
ask.undo();
|
|
517
|
+
}}
|
|
518
|
+
>
|
|
519
|
+
{texts().undo}
|
|
520
|
+
</button>
|
|
521
|
+
{closeButton()}
|
|
522
|
+
</span>
|
|
523
|
+
</div>
|
|
524
|
+
<Show
|
|
525
|
+
when={session().items.length > 0}
|
|
526
|
+
fallback={<div class="ssg-ask-empty">{texts().allRemoved}</div>}
|
|
527
|
+
>
|
|
528
|
+
<ul ref={(node) => chipsEl = node} class="ssg-ask-chips">
|
|
529
|
+
<For each={session().items} keyed={(item) => item.id}>
|
|
530
|
+
{(item, index) => <li class="ssg-ask-chip" title={`${item().label}: ${item().text}`}>
|
|
531
|
+
<span class="ssg-ask-chip-label">{item().label}</span>
|
|
532
|
+
<span class="ssg-ask-chip-text">{item().text}</span>
|
|
533
|
+
<button
|
|
534
|
+
type="button"
|
|
535
|
+
class="ssg-ask-chip-remove"
|
|
536
|
+
aria-label={formatLocaleText(texts().removeItem, {
|
|
537
|
+
label: item().label,
|
|
538
|
+
text: item().text
|
|
539
|
+
})}
|
|
540
|
+
onClick={() => {
|
|
541
|
+
keepFocus(index());
|
|
542
|
+
ask.remove(item().id);
|
|
543
|
+
}}
|
|
544
|
+
>
|
|
545
|
+
×
|
|
546
|
+
</button>
|
|
547
|
+
</li>}
|
|
548
|
+
</For>
|
|
549
|
+
</ul>
|
|
550
|
+
</Show>
|
|
551
|
+
</div>
|
|
552
|
+
</Show>
|
|
553
|
+
<Show when={session().phase === "unchanged"}>
|
|
554
|
+
<div class="ssg-ask-note">
|
|
555
|
+
<span>{texts().unchanged}</span>
|
|
556
|
+
{closeButton()}
|
|
557
|
+
</div>
|
|
558
|
+
</Show>
|
|
559
|
+
<Show when={session().phase === "undone"}>
|
|
560
|
+
<div class="ssg-ask-note">
|
|
561
|
+
<span>{texts().undone}</span>
|
|
562
|
+
{closeButton()}
|
|
563
|
+
</div>
|
|
564
|
+
</Show>
|
|
565
|
+
<Show
|
|
566
|
+
when={session().phase !== "undone" && session().phase !== "changed" && session().dropped.length > 0}
|
|
567
|
+
>
|
|
568
|
+
<div class="ssg-ask-note ssg-ask-note--warn">
|
|
569
|
+
<span class="ssg-ask-note-title">{texts().droppedTitle}</span>
|
|
570
|
+
<ul class="ssg-ask-dropped">
|
|
571
|
+
<For each={session().dropped} keyed={false}>
|
|
572
|
+
{(reason) => <li>{reason()}</li>}
|
|
573
|
+
</For>
|
|
574
|
+
</ul>
|
|
575
|
+
</div>
|
|
576
|
+
</Show>
|
|
577
|
+
<Show
|
|
578
|
+
when={session().phase !== "undone" && session().phase !== "changed" && session().unsupported !== null}
|
|
579
|
+
>
|
|
580
|
+
<div class="ssg-ask-note">
|
|
581
|
+
<span>{formatLocaleText(texts().fromAi, { text: session().unsupported ?? "" })}</span>
|
|
582
|
+
</div>
|
|
583
|
+
</Show>
|
|
584
|
+
</>}
|
|
585
|
+
</Show>
|
|
586
|
+
<Show when={ask.notice !== null}>
|
|
587
|
+
<div class="ssg-ask-note ssg-ask-note--warn">
|
|
588
|
+
<span>{ask.notice}</span>
|
|
589
|
+
{
|
|
590
|
+
/* 表が手で変わって反映した条件のチップを下げたときは、ここで閉じる。 */
|
|
591
|
+
}
|
|
592
|
+
<Show when={ask.session?.phase === "changed"}>{closeButton()}</Show>
|
|
593
|
+
</div>
|
|
594
|
+
</Show>
|
|
595
|
+
</div>
|
|
596
|
+
</div>;
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
// src/ai.ts
|
|
600
|
+
import {
|
|
601
|
+
createGridAskRequest as createGridAskRequest2,
|
|
602
|
+
describeGridAskView as describeGridAskView2,
|
|
603
|
+
gridAskSystemPrompt,
|
|
604
|
+
isGridAskColumnsChanged as isGridAskColumnsChanged2,
|
|
605
|
+
isSameGridAskView as isSameGridAskView2,
|
|
606
|
+
readGridAskAnswer as readGridAskAnswer2,
|
|
607
|
+
removeGridAskItem as removeGridAskItem2
|
|
608
|
+
} from "@ishibashi0112/spreadsheet-grid-core/internal/logic/gridAsk";
|
|
609
|
+
export {
|
|
610
|
+
GridAskBar,
|
|
611
|
+
createGridAsk,
|
|
612
|
+
createGridAskRequest2 as createGridAskRequest,
|
|
613
|
+
describeGridAskView2 as describeGridAskView,
|
|
614
|
+
gridAskSystemPrompt,
|
|
615
|
+
isGridAskColumnsChanged2 as isGridAskColumnsChanged,
|
|
616
|
+
isSameGridAskView2 as isSameGridAskView,
|
|
617
|
+
readGridAskAnswer2 as readGridAskAnswer,
|
|
618
|
+
removeGridAskItem2 as removeGridAskItem
|
|
619
|
+
};
|
|
@@ -69,6 +69,13 @@ function createExternalStoreSignal(store, name) {
|
|
|
69
69
|
// src/primitives/controller.ts
|
|
70
70
|
import { createEffect, createRenderEffect, createSignal as createSignal2, untrack as untrack2 } from "solid-js";
|
|
71
71
|
|
|
72
|
+
// src/primitives/effectApply.ts
|
|
73
|
+
function outsideGraphApply(apply) {
|
|
74
|
+
return (...values) => {
|
|
75
|
+
apply(values[0]);
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
|
|
72
79
|
// src/primitives/userCallback.ts
|
|
73
80
|
import { flush, getOwner, isDisposed } from "solid-js";
|
|
74
81
|
var gridUpdateDepth = 0;
|
|
@@ -186,9 +193,9 @@ function connectController(controller, args, timing = "render", name) {
|
|
|
186
193
|
};
|
|
187
194
|
const options = name === void 0 ? void 0 : { name };
|
|
188
195
|
if (timing === "render") {
|
|
189
|
-
createRenderEffect(compute, apply, options);
|
|
196
|
+
createRenderEffect(compute, outsideGraphApply(apply), options);
|
|
190
197
|
} else {
|
|
191
|
-
createEffect(compute, apply, options);
|
|
198
|
+
createEffect(compute, outsideGraphApply(apply), options);
|
|
192
199
|
}
|
|
193
200
|
onGridMounted(() => {
|
|
194
201
|
mounted = true;
|
|
@@ -282,6 +289,7 @@ export {
|
|
|
282
289
|
runHandleCall,
|
|
283
290
|
callInOwnFrame,
|
|
284
291
|
createUserCallbacks,
|
|
292
|
+
outsideGraphApply,
|
|
285
293
|
createMountGate,
|
|
286
294
|
runInMountGate,
|
|
287
295
|
flushMountGate,
|