@pixerate/editor-svelte 0.3.0 → 0.3.2
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/dist/index.d.ts +10 -1
- package/dist/index.js +88 -63
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/TemplateRenderer.svelte +2 -0
- package/src/index.d.ts +10 -1
- package/src/spreadsheet/FormulaBar.svelte +49 -9
- package/src/spreadsheet/SpreadsheetEditor.svelte +27 -41
- package/src/spreadsheet/spreadsheet.svelte.ts +13 -0
package/dist/index.d.ts
CHANGED
|
@@ -94,8 +94,15 @@ import type {
|
|
|
94
94
|
export interface SpreadsheetEditorProps {
|
|
95
95
|
sheetState: ReturnType<typeof createReactiveSpreadsheet>;
|
|
96
96
|
readonly?: boolean;
|
|
97
|
+
readOnly?: boolean;
|
|
98
|
+
showFormulaBar?: boolean;
|
|
97
99
|
class?: string;
|
|
98
|
-
customCellRenderer?:
|
|
100
|
+
customCellRenderer?:
|
|
101
|
+
| ((cell: CellData, col: SpreadsheetColumn, row: SpreadsheetRow) => any)
|
|
102
|
+
| ((args: { cell: CellData; col: SpreadsheetColumn; row: SpreadsheetRow }) => any)
|
|
103
|
+
| ((args: { row: SpreadsheetRow; col: SpreadsheetColumn; cell: CellData }) => any);
|
|
104
|
+
onAddColumnClick?: () => void;
|
|
105
|
+
onColumnHeaderClick?: (col: SpreadsheetColumn) => void;
|
|
99
106
|
}
|
|
100
107
|
|
|
101
108
|
export interface FormulaBarProps {
|
|
@@ -126,6 +133,8 @@ export declare function createReactiveSpreadsheet(options?: SpreadsheetControlle
|
|
|
126
133
|
insertRow(index: number, config?: Partial<SpreadsheetRow>): void;
|
|
127
134
|
deleteRow(rowId: string): void;
|
|
128
135
|
setColumnWidth(colId: string, width: number): void;
|
|
136
|
+
loadDocument(document: SpreadsheetDocument): void;
|
|
137
|
+
syncWithDataSource(): void;
|
|
129
138
|
registerDataSource(ds: SpreadsheetDataSource): void;
|
|
130
139
|
setPrimaryDataSource(id: string | undefined): void;
|
|
131
140
|
recalculateAll(): void;
|
package/dist/index.js
CHANGED
|
@@ -226,27 +226,60 @@ import { indexToColName as indexToColName2 } from "@pixerate/editor";
|
|
|
226
226
|
import "svelte/internal/disclose-version";
|
|
227
227
|
import * as $5 from "svelte/internal/client";
|
|
228
228
|
import { indexToColName } from "@pixerate/editor";
|
|
229
|
-
var root4 = $5.from_html(`<div
|
|
229
|
+
var root4 = $5.from_html(`<div><div class="flex h-6 min-w-[3rem] items-center justify-center rounded border border-border bg-background px-1.5 font-semibold text-foreground"> </div> <div class="flex items-center text-muted-foreground select-none"><span class="italic font-serif font-bold text-sm text-primary">fx</span></div> <input type="text" class="flex-1 bg-transparent px-2 py-0.5 outline-none font-sans text-xs text-foreground placeholder:text-muted-foreground/60 focus:bg-background focus:ring-1 focus:ring-primary rounded" placeholder="Enter a value or formula (e.g. =SUM(A1:A5))"/></div>`);
|
|
230
230
|
function FormulaBar($$anchor, $$props) {
|
|
231
231
|
$5.push($$props, true);
|
|
232
|
-
let activeCoord = $5.prop($$props, "activeCoord", 3, null), value = $5.prop($$props, "value", 15, "");
|
|
232
|
+
let sheetState = $5.prop($$props, "sheetState", 7), activeCoord = $5.prop($$props, "activeCoord", 3, null), value = $5.prop($$props, "value", 15, ""), className = $5.prop($$props, "class", 3, "");
|
|
233
|
+
let effectiveCoord = $5.derived(() => {
|
|
234
|
+
if (sheetState()) return sheetState().activeCell;
|
|
235
|
+
return activeCoord();
|
|
236
|
+
});
|
|
233
237
|
let coordLabel = $5.derived(() => {
|
|
234
|
-
if (
|
|
235
|
-
const colName = indexToColName(
|
|
236
|
-
return `${colName}${
|
|
238
|
+
if (!$5.get(effectiveCoord)) return "--";
|
|
239
|
+
const colName = indexToColName($5.get(effectiveCoord).col);
|
|
240
|
+
return `${colName}${$5.get(effectiveCoord).row + 1}`;
|
|
241
|
+
});
|
|
242
|
+
let effectiveValue = $5.derived(() => {
|
|
243
|
+
if (sheetState()) {
|
|
244
|
+
if (sheetState().editingCell) return sheetState().draftValue;
|
|
245
|
+
if (!sheetState().activeCell) return "";
|
|
246
|
+
const row = sheetState().document.rows[sheetState().activeCell.row];
|
|
247
|
+
const col = sheetState().document.columns[sheetState().activeCell.col];
|
|
248
|
+
if (!row || !col) return "";
|
|
249
|
+
return sheetState().getCell(row.id, col.id).raw || "";
|
|
250
|
+
}
|
|
251
|
+
return value();
|
|
237
252
|
});
|
|
238
253
|
function handleKeyDown(e) {
|
|
239
254
|
if (e.key === "Enter") {
|
|
240
255
|
e.preventDefault();
|
|
241
|
-
|
|
256
|
+
if (sheetState() && sheetState().activeCell) {
|
|
257
|
+
const row = sheetState().document.rows[sheetState().activeCell.row];
|
|
258
|
+
const col = sheetState().document.columns[sheetState().activeCell.col];
|
|
259
|
+
if (row && col) {
|
|
260
|
+
sheetState().setCellValue(row.id, col.id, $5.get(effectiveValue));
|
|
261
|
+
}
|
|
262
|
+
sheetState().commitEditing();
|
|
263
|
+
}
|
|
264
|
+
$$props.onCommit?.($5.get(effectiveValue));
|
|
242
265
|
} else if (e.key === "Escape") {
|
|
243
266
|
e.preventDefault();
|
|
267
|
+
if (sheetState()) {
|
|
268
|
+
sheetState().cancelEditing();
|
|
269
|
+
}
|
|
244
270
|
$$props.onCancel?.();
|
|
245
271
|
}
|
|
246
272
|
}
|
|
247
273
|
function handleInput(e) {
|
|
248
274
|
const target = e.target;
|
|
249
|
-
|
|
275
|
+
if (sheetState()) {
|
|
276
|
+
sheetState().draftValue = target.value;
|
|
277
|
+
if (sheetState().activeCell && !sheetState().editingCell) {
|
|
278
|
+
sheetState().startEditing(sheetState().activeCell.row, sheetState().activeCell.col, target.value);
|
|
279
|
+
}
|
|
280
|
+
} else {
|
|
281
|
+
value(target.value);
|
|
282
|
+
}
|
|
250
283
|
$$props.onChange?.(target.value);
|
|
251
284
|
}
|
|
252
285
|
var div = root4();
|
|
@@ -256,8 +289,9 @@ function FormulaBar($$anchor, $$props) {
|
|
|
256
289
|
$5.remove_input_defaults(input);
|
|
257
290
|
$5.reset(div);
|
|
258
291
|
$5.template_effect(() => {
|
|
292
|
+
$5.set_class(div, 1, `flex items-center gap-2 border-b border-border bg-muted/20 px-3 py-1.5 text-xs font-mono ${className() ?? ""}`);
|
|
259
293
|
$5.set_text(text, $5.get(coordLabel));
|
|
260
|
-
$5.set_value(input,
|
|
294
|
+
$5.set_value(input, $5.get(effectiveValue));
|
|
261
295
|
});
|
|
262
296
|
$5.delegated("input", input, handleInput);
|
|
263
297
|
$5.delegated("keydown", input, handleKeyDown);
|
|
@@ -381,6 +415,19 @@ function createReactiveSpreadsheet(options = {}) {
|
|
|
381
415
|
controller.setColumnWidth(colId, width);
|
|
382
416
|
$6.set(doc, { ...controller.document }, true);
|
|
383
417
|
},
|
|
418
|
+
loadDocument(document2) {
|
|
419
|
+
controller.loadDocument(document2);
|
|
420
|
+
$6.set(doc, { ...controller.document }, true);
|
|
421
|
+
$6.set(activeCell, controller.activeCell, true);
|
|
422
|
+
$6.set(selectedRange, controller.selectedRange, true);
|
|
423
|
+
$6.set(editingCell, controller.editingCell, true);
|
|
424
|
+
$6.set(draftValue, controller.draftValue, true);
|
|
425
|
+
},
|
|
426
|
+
syncWithDataSource() {
|
|
427
|
+
controller.syncWithDataSource();
|
|
428
|
+
controller.recalculateAll();
|
|
429
|
+
$6.set(doc, { ...controller.document }, true);
|
|
430
|
+
},
|
|
384
431
|
registerDataSource(ds) {
|
|
385
432
|
controller.registerDataSource(ds);
|
|
386
433
|
$6.set(doc, { ...controller.document }, true);
|
|
@@ -412,28 +459,22 @@ function createReactiveSpreadsheet(options = {}) {
|
|
|
412
459
|
}
|
|
413
460
|
|
|
414
461
|
// src/spreadsheet/SpreadsheetEditor.svelte
|
|
415
|
-
var root5 = $7.from_html(`<th class="relative border-r border-border px-2 text-left font-medium text-muted-foreground hover:bg-muted/90 transition-colors group cursor-pointer"><div class="flex items-center justify-between gap-1 truncate"><span class="truncate font-semibold text-foreground text-xs"> </span> <span class="text-[10px] text-muted-foreground/70 font-mono font-normal"> </span></div>
|
|
462
|
+
var root5 = $7.from_html(`<th class="relative border-r border-border px-2 text-left font-medium text-muted-foreground hover:bg-muted/90 transition-colors group cursor-pointer"><div class="flex items-center justify-between gap-1 truncate"><span class="truncate font-semibold text-foreground text-xs"> </span> <span class="text-[10px] text-muted-foreground/70 font-mono font-normal"> </span></div> <div class="absolute right-0 top-0 bottom-0 w-1.5 cursor-col-resize hover:bg-primary/50 group-hover:bg-primary/20 z-10" role="separator" aria-orientation="vertical" tabindex="-1"></div></th>`);
|
|
416
463
|
var root_13 = $7.from_html(`<th class="w-10 min-w-[2.5rem] px-1 text-center bg-muted/40 hover:bg-muted cursor-pointer transition-colors" title="Add Column"><span class="text-xs font-bold text-muted-foreground">+</span></th>`);
|
|
417
464
|
var root_22 = $7.from_html(`<input type="text" class="absolute inset-0 w-full h-full px-2 py-1 bg-background text-foreground outline-none font-sans text-xs border-2 border-primary z-20"/>`);
|
|
418
465
|
var root_32 = $7.from_html(`<span> </span>`);
|
|
419
466
|
var root_42 = $7.from_html(`<td><!></td>`);
|
|
420
467
|
var root_5 = $7.from_html(`<td class="w-10 min-w-[2.5rem] bg-muted/10 border-r border-border"></td>`);
|
|
421
468
|
var root_6 = $7.from_html(`<tr class="border-b border-border hover:bg-muted/10 transition-colors"><td class="w-12 min-w-[3rem] sticky left-0 z-10 bg-muted/50 border-r border-border text-center text-[10px] text-muted-foreground font-mono select-none"> </td><!><!></tr>`);
|
|
422
|
-
var root_7 = $7.from_html(`<div
|
|
469
|
+
var root_7 = $7.from_html(`<div tabindex="0" role="grid" aria-label="Spreadsheet"><!> <div class="relative flex-1 overflow-auto"><table class="border-collapse table-fixed w-max min-w-full"><thead><tr class="h-7 bg-muted/60 sticky top-0 z-20 border-b border-border shadow-xs"><th class="w-12 min-w-[3rem] sticky left-0 z-30 bg-muted/90 border-r border-border text-center text-[10px] text-muted-foreground font-medium">#</th><!><!></tr></thead><tbody></tbody></table></div></div>`);
|
|
423
470
|
function SpreadsheetEditor($$anchor, $$props) {
|
|
424
471
|
$7.push($$props, true);
|
|
425
|
-
let sheetState = $7.prop($$props, "sheetState", 23, createReactiveSpreadsheet), readOnly = $7.prop($$props, "readOnly", 3, false);
|
|
472
|
+
let sheetState = $7.prop($$props, "sheetState", 23, createReactiveSpreadsheet), readOnly = $7.prop($$props, "readOnly", 3, false), readonly = $7.prop($$props, "readonly", 3, false), showFormulaBar = $7.prop($$props, "showFormulaBar", 3, true), className = $7.prop($$props, "class", 3, "");
|
|
473
|
+
let isReadOnly = $7.derived(() => readOnly() || readonly());
|
|
426
474
|
let gridContainer = $7.state(null);
|
|
427
475
|
let resizingColId = $7.state(null);
|
|
428
476
|
let resizeStartX = $7.state(0);
|
|
429
477
|
let resizeStartWidth = $7.state(0);
|
|
430
|
-
let activeRawValue = $7.derived(() => {
|
|
431
|
-
if (!sheetState().activeCell) return "";
|
|
432
|
-
const row = sheetState().document.rows[sheetState().activeCell.row];
|
|
433
|
-
const col = sheetState().document.columns[sheetState().activeCell.col];
|
|
434
|
-
if (!row || !col) return "";
|
|
435
|
-
return sheetState().getCell(row.id, col.id).raw;
|
|
436
|
-
});
|
|
437
478
|
function handleCellClick(rIdx, cIdx, e) {
|
|
438
479
|
if (sheetState().editingCell && (sheetState().editingCell.row !== rIdx || sheetState().editingCell.col !== cIdx)) {
|
|
439
480
|
sheetState().commitEditing();
|
|
@@ -441,20 +482,18 @@ function SpreadsheetEditor($$anchor, $$props) {
|
|
|
441
482
|
sheetState().selectCell(rIdx, cIdx, e.shiftKey);
|
|
442
483
|
}
|
|
443
484
|
function handleCellDblClick(rIdx, cIdx) {
|
|
444
|
-
if (
|
|
485
|
+
if ($7.get(isReadOnly)) return;
|
|
445
486
|
const col = sheetState().document.columns[cIdx];
|
|
446
487
|
if (col?.readOnly) return;
|
|
447
488
|
sheetState().startEditing(rIdx, cIdx);
|
|
448
489
|
}
|
|
449
490
|
function handleKeyDown(e) {
|
|
450
491
|
if (sheetState().editingCell) {
|
|
451
|
-
if (e.key === "
|
|
452
|
-
|
|
492
|
+
if (e.key === "Escape") {
|
|
493
|
+
sheetState().cancelEditing();
|
|
494
|
+
} else if (e.key === "Enter") {
|
|
453
495
|
sheetState().commitEditing();
|
|
454
496
|
sheetState().moveCursor("down");
|
|
455
|
-
} else if (e.key === "Escape") {
|
|
456
|
-
e.preventDefault();
|
|
457
|
-
sheetState().cancelEditing();
|
|
458
497
|
} else if (e.key === "Tab") {
|
|
459
498
|
e.preventDefault();
|
|
460
499
|
sheetState().commitEditing();
|
|
@@ -481,11 +520,11 @@ function SpreadsheetEditor($$anchor, $$props) {
|
|
|
481
520
|
} else if (e.key === "Enter") {
|
|
482
521
|
e.preventDefault();
|
|
483
522
|
const col = sheetState().document.columns[sheetState().activeCell.col];
|
|
484
|
-
if (
|
|
523
|
+
if (!$7.get(isReadOnly) && !col?.readOnly) {
|
|
485
524
|
sheetState().startEditing();
|
|
486
525
|
}
|
|
487
526
|
} else if (e.key === "Backspace" || e.key === "Delete") {
|
|
488
|
-
if (
|
|
527
|
+
if ($7.get(isReadOnly)) return;
|
|
489
528
|
const row = sheetState().document.rows[sheetState().activeCell.row];
|
|
490
529
|
const col = sheetState().document.columns[sheetState().activeCell.col];
|
|
491
530
|
if (row && col && !col.readOnly) {
|
|
@@ -503,7 +542,7 @@ function SpreadsheetEditor($$anchor, $$props) {
|
|
|
503
542
|
e.preventDefault();
|
|
504
543
|
const tsv = sheetState().exportToTsv();
|
|
505
544
|
navigator.clipboard?.writeText(tsv);
|
|
506
|
-
} else if (
|
|
545
|
+
} else if (!$7.get(isReadOnly) && e.key.length === 1 && !e.ctrlKey && !e.metaKey && !e.altKey) {
|
|
507
546
|
const col = sheetState().document.columns[sheetState().activeCell.col];
|
|
508
547
|
if (!col?.readOnly) {
|
|
509
548
|
sheetState().startEditing(sheetState().activeCell.row, sheetState().activeCell.col, e.key);
|
|
@@ -543,31 +582,15 @@ function SpreadsheetEditor($$anchor, $$props) {
|
|
|
543
582
|
var div = root_7();
|
|
544
583
|
var node = $7.child(div);
|
|
545
584
|
{
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
},
|
|
551
|
-
get value() {
|
|
552
|
-
return $7.get($0);
|
|
553
|
-
},
|
|
554
|
-
onChange: (val) => {
|
|
555
|
-
if (sheetState().activeCell) {
|
|
556
|
-
sheetState().draftValue = val;
|
|
557
|
-
}
|
|
558
|
-
},
|
|
559
|
-
onCommit: (val) => {
|
|
560
|
-
if (sheetState().activeCell) {
|
|
561
|
-
const row = sheetState().document.rows[sheetState().activeCell.row];
|
|
562
|
-
const col = sheetState().document.columns[sheetState().activeCell.col];
|
|
563
|
-
if (row && col) {
|
|
564
|
-
sheetState().setCellValue(row.id, col.id, val);
|
|
565
|
-
}
|
|
585
|
+
var consequent = ($$anchor2) => {
|
|
586
|
+
FormulaBar($$anchor2, {
|
|
587
|
+
get sheetState() {
|
|
588
|
+
return sheetState();
|
|
566
589
|
}
|
|
567
|
-
}
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
590
|
+
});
|
|
591
|
+
};
|
|
592
|
+
$7.if(node, ($$render) => {
|
|
593
|
+
if (showFormulaBar()) $$render(consequent);
|
|
571
594
|
});
|
|
572
595
|
}
|
|
573
596
|
var div_1 = $7.sibling(node, 2);
|
|
@@ -596,7 +619,7 @@ function SpreadsheetEditor($$anchor, $$props) {
|
|
|
596
619
|
});
|
|
597
620
|
var node_2 = $7.sibling(node_1);
|
|
598
621
|
{
|
|
599
|
-
var
|
|
622
|
+
var consequent_1 = ($$anchor2) => {
|
|
600
623
|
var th_1 = root_13();
|
|
601
624
|
$7.delegated("click", th_1, function(...$$args) {
|
|
602
625
|
$$props.onAddColumnClick?.apply(this, $$args);
|
|
@@ -604,7 +627,7 @@ function SpreadsheetEditor($$anchor, $$props) {
|
|
|
604
627
|
$7.append($$anchor2, th_1);
|
|
605
628
|
};
|
|
606
629
|
$7.if(node_2, ($$render) => {
|
|
607
|
-
if ($$props.onAddColumnClick) $$render(
|
|
630
|
+
if ($$props.onAddColumnClick) $$render(consequent_1);
|
|
608
631
|
});
|
|
609
632
|
}
|
|
610
633
|
$7.reset(tr);
|
|
@@ -623,18 +646,19 @@ function SpreadsheetEditor($$anchor, $$props) {
|
|
|
623
646
|
var td_1 = root_42();
|
|
624
647
|
var node_4 = $7.child(td_1);
|
|
625
648
|
{
|
|
626
|
-
var
|
|
649
|
+
var consequent_2 = ($$anchor4) => {
|
|
627
650
|
var input = root_22();
|
|
628
651
|
$7.remove_input_defaults(input);
|
|
629
652
|
$7.event("blur", input, () => sheetState().commitEditing());
|
|
630
653
|
$7.bind_value(input, () => sheetState().draftValue, ($$value) => sheetState().draftValue = $$value);
|
|
631
654
|
$7.append($$anchor4, input);
|
|
632
655
|
};
|
|
633
|
-
var
|
|
634
|
-
|
|
635
|
-
var
|
|
636
|
-
|
|
637
|
-
$7.
|
|
656
|
+
var consequent_3 = ($$anchor4) => {
|
|
657
|
+
const cellArg = $7.derived(() => Object.assign({ row: $7.get(row), col: $7.get(col), cell: $7.get(cell) }, $7.get(cell)));
|
|
658
|
+
var fragment_1 = $7.comment();
|
|
659
|
+
var node_5 = $7.first_child(fragment_1);
|
|
660
|
+
$7.snippet(node_5, () => $$props.customCellRenderer, () => $7.get(cellArg), () => $7.get(col), () => $7.get(row));
|
|
661
|
+
$7.append($$anchor4, fragment_1);
|
|
638
662
|
};
|
|
639
663
|
var alternate = ($$anchor4) => {
|
|
640
664
|
var span_2 = root_32();
|
|
@@ -646,8 +670,8 @@ function SpreadsheetEditor($$anchor, $$props) {
|
|
|
646
670
|
$7.append($$anchor4, span_2);
|
|
647
671
|
};
|
|
648
672
|
$7.if(node_4, ($$render) => {
|
|
649
|
-
if ($7.get(isEditing)) $$render(
|
|
650
|
-
else if ($$props.customCellRenderer) $$render(
|
|
673
|
+
if ($7.get(isEditing)) $$render(consequent_2);
|
|
674
|
+
else if ($$props.customCellRenderer) $$render(consequent_3, 1);
|
|
651
675
|
else $$render(alternate, -1);
|
|
652
676
|
});
|
|
653
677
|
}
|
|
@@ -662,12 +686,12 @@ function SpreadsheetEditor($$anchor, $$props) {
|
|
|
662
686
|
});
|
|
663
687
|
var node_6 = $7.sibling(node_3);
|
|
664
688
|
{
|
|
665
|
-
var
|
|
689
|
+
var consequent_4 = ($$anchor3) => {
|
|
666
690
|
var td_2 = root_5();
|
|
667
691
|
$7.append($$anchor3, td_2);
|
|
668
692
|
};
|
|
669
693
|
$7.if(node_6, ($$render) => {
|
|
670
|
-
if ($$props.onAddColumnClick) $$render(
|
|
694
|
+
if ($$props.onAddColumnClick) $$render(consequent_4);
|
|
671
695
|
});
|
|
672
696
|
}
|
|
673
697
|
$7.reset(tr_1);
|
|
@@ -682,6 +706,7 @@ function SpreadsheetEditor($$anchor, $$props) {
|
|
|
682
706
|
$7.reset(div_1);
|
|
683
707
|
$7.reset(div);
|
|
684
708
|
$7.bind_this(div, ($$value) => $7.set(gridContainer, $$value), () => $7.get(gridContainer));
|
|
709
|
+
$7.template_effect(() => $7.set_class(div, 1, `flex flex-col h-full w-full overflow-hidden border border-border bg-background select-none outline-none text-foreground font-sans text-xs ${className() ?? ""}`));
|
|
685
710
|
$7.delegated("keydown", div, handleKeyDown);
|
|
686
711
|
$7.append($$anchor, div);
|
|
687
712
|
$7.pop();
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/EditableTextNodeEditor.svelte","../src/editor.svelte.ts","../src/BubbleMenu.svelte","../src/TemplateRenderer.svelte","../src/spreadsheet/SpreadsheetEditor.svelte","../src/spreadsheet/FormulaBar.svelte","../src/spreadsheet/spreadsheet.svelte.ts","../src/index.ts"],"sourcesContent":["import 'EditableTextNodeEditor.svelte.css';import 'svelte/internal/disclose-version';\nimport * as $ from 'svelte/internal/client';\nimport { onDestroy, onMount } from \"svelte\";\nimport Placeholder from \"@tiptap/extension-placeholder\";\nimport { initiateEditor } from \"./editor.svelte\";\n\nvar root = $.from_html(`<div class=\"flex items-center justify-center p-4 text-sm text-gray-500\">Loading editor...</div>`);\nvar root_1 = $.from_html(`<div draggable=\"false\"><!> <div class=\"pixerate-editor-content prose w-full max-w-none focus:outline-none\"></div></div>`);\n\nexport default function EditableTextNodeEditor($$anchor, $$props) {\n\t$.push($$props, true);\n\n\tlet className = $.prop($$props, 'class', 3, \"\"),\n\t\tcontent = $.prop($$props, 'content', 3, undefined),\n\t\tshowMenu = $.prop($$props, 'showMenu', 3, true),\n\t\teditable = $.prop($$props, 'editable', 3, true),\n\t\teditor = $.prop($$props, 'editor', 15),\n\t\textensions = $.prop($$props, 'extensions', 19, () => []),\n\t\tplaceholder = $.prop($$props, 'placeholder', 3, \"\");\n\n\tlet element = $.state(void 0);\n\n\t$.user_effect(() => {\n\t\tif (editor() && editor().isEditable !== editable()) {\n\t\t\teditor().setEditable(editable());\n\t\t}\n\t});\n\n\tonMount(() => {\n\t\teditor(initiateEditor(\n\t\t\t$.get(element),\n\t\t\tcontent(),\n\t\t\t[\n\t\t\t\tPlaceholder.configure({ placeholder: placeholder() }),\n\t\t\t\t...extensions()\n\t\t\t],\n\t\t\t{\n\t\t\t\teditable: editable(),\n\t\t\t\tonCreate: $$props.onCreate,\n\t\t\t\tonUpdate: $$props.onUpdate,\n\t\t\t\tonFocus() {\n\t\t\t\t\tif ($$props.onFocus) $$props.onFocus();\n\t\t\t\t},\n\n\t\t\t\tonBlur() {\n\t\t\t\t\tif ($$props.onBlur) $$props.onBlur();\n\t\t\t\t}\n\t\t\t}\n\t\t));\n\t});\n\n\tonDestroy(() => {\n\t\tif (editor()) {\n\t\t\teditor().destroy();\n\t\t}\n\t});\n\n\tvar div = root_1();\n\tvar node = $.child(div);\n\n\t{\n\t\tvar consequent = ($$anchor) => {\n\t\t\tvar div_1 = root();\n\n\t\t\t$.append($$anchor, div_1);\n\t\t};\n\n\t\t$.if(node, ($$render) => {\n\t\t\tif (!editor()) $$render(consequent);\n\t\t});\n\t}\n\n\tvar div_2 = $.sibling(node, 2);\n\n\t$.bind_this(div_2, ($$value) => $.set(element, $$value), () => $.get(element));\n\t$.reset(div);\n\t$.template_effect(() => $.set_class(div, 1, `pixerate-editor-container ${className()}`));\n\t$.append($$anchor, div);\n\t$.pop();\n}","import { Editor } from \"@tiptap/core\";\nimport { createRichTextPreset } from \"@pixerate/editor\";\nexport const initiateEditor = (element, content, extensions, options) => {\n const { richTextOptions, ...editorOptions } = options || {};\n const defaultPreset = createRichTextPreset(richTextOptions);\n const editor = new Editor({\n element,\n content,\n extensions: [\n ...defaultPreset,\n ...extensions ?? []\n ],\n autofocus: true,\n ...editorOptions\n });\n return editor;\n};\nexport function createReactiveEditor(initialContent = \"\", extensions = [], options = {}) {\n let editorInstance;\n return {\n get current() {\n return editorInstance;\n },\n mount(element) {\n editorInstance = initiateEditor(element, initialContent, extensions, options);\n return editorInstance;\n },\n destroy() {\n if (editorInstance) {\n editorInstance.destroy();\n editorInstance = void 0;\n }\n }\n };\n}\n","import 'svelte/internal/disclose-version';\nimport * as $ from 'svelte/internal/client';\nimport { BubbleMenuPlugin } from \"@tiptap/extension-bubble-menu\";\n\nvar root = $.from_html(`<div style=\"visibility: hidden;\"><!></div>`);\n\nexport default function BubbleMenu($$anchor, $$props) {\n\t$.push($$props, true);\n\n\tlet className = $.prop($$props, 'class', 3, \"flex h-fit w-fit items-center gap-1 rounded-md border border-gray-200 bg-white p-1 shadow-md\"),\n\t\tpluginKey = $.prop($$props, 'pluginKey', 3, \"bubbleMenu\"),\n\t\tshouldShow = $.prop($$props, 'shouldShow', 3, null),\n\t\tupdateDelay = $.prop($$props, 'updateDelay', 3, 250),\n\t\ttippyOptions = $.prop($$props, 'tippyOptions', 19, () => ({}));\n\n\tlet menuElement = $.state(void 0);\n\n\t$.user_effect(() => {\n\t\tif ($$props.editor && $.get(menuElement)) {\n\t\t\tconst plugin = BubbleMenuPlugin({\n\t\t\t\tpluginKey: pluginKey(),\n\t\t\t\teditor: $$props.editor,\n\t\t\t\telement: $.get(menuElement),\n\t\t\t\ttippyOptions: {\n\t\t\t\t\tduration: 100,\n\t\t\t\t\tappendTo: () => document.body,\n\t\t\t\t\t...tippyOptions()\n\t\t\t\t},\n\t\t\t\tshouldShow: shouldShow(),\n\t\t\t\tupdateDelay: updateDelay()\n\t\t\t});\n\n\t\t\t$$props.editor.registerPlugin(plugin);\n\n\t\t\treturn () => {\n\t\t\t\t$$props.editor.unregisterPlugin(pluginKey());\n\t\t\t};\n\t\t}\n\t});\n\n\tvar div = root();\n\tvar node = $.child(div);\n\n\t{\n\t\tvar consequent = ($$anchor) => {\n\t\t\tvar fragment = $.comment();\n\t\t\tvar node_1 = $.first_child(fragment);\n\n\t\t\t$.snippet(node_1, () => $$props.children);\n\t\t\t$.append($$anchor, fragment);\n\t\t};\n\n\t\t$.if(node, ($$render) => {\n\t\t\tif ($$props.children) $$render(consequent);\n\t\t});\n\t}\n\n\t$.reset(div);\n\t$.bind_this(div, ($$value) => $.set(menuElement, $$value), () => $.get(menuElement));\n\t$.template_effect(() => $.set_class(div, 1, $.clsx(className())));\n\t$.append($$anchor, div);\n\t$.pop();\n}","import 'svelte/internal/disclose-version';\nimport * as $ from 'svelte/internal/client';\nimport { tokenizePrompt, resolveTemplates } from \"@pixerate/editor\";\n\nvar root = $.from_html(`<span class=\"inline-flex items-center px-1.5 py-0.5 mx-0.5 text-xs font-semibold rounded-md border border-[var(--color-to)]/40 bg-gradient-to-r from-[var(--color-from)]/15 to-[var(--color-to)]/15 text-[var(--color-to)] hover:brightness-110 cursor-pointer transition-all\"> </span>`);\nvar root_1 = $.from_html(`<span class=\"inline-flex items-center px-1.5 py-0.5 mx-0.5 text-xs font-medium rounded-md border border-violet-400/40 bg-violet-400/15 text-violet-600 hover:brightness-110 cursor-pointer transition-all\"> </span>`);\nvar root_2 = $.from_html(`<span class=\"inline-flex items-center px-1.5 py-0.5 mx-0.5 text-xs italic font-medium rounded-md border border-rose-400/40 bg-rose-400/15 text-rose-600\"> </span>`);\nvar root_3 = $.from_html(`<span> </span>`);\nvar root_4 = $.from_html(`<div></div>`);\n\nexport default function TemplateRenderer($$anchor, $$props) {\n\t$.push($$props, true);\n\n\tlet templates = $.prop($$props, 'templates', 19, () => []),\n\t\tresolve = $.prop($$props, 'resolve', 3, false),\n\t\tclassName = $.prop($$props, 'class', 3, \"font-mono text-sm leading-relaxed whitespace-pre-wrap break-words\");\n\n\tlet displayText = $.derived(() => resolve() && templates().length > 0\n\t\t? resolveTemplates($$props.content, templates())\n\t\t: $$props.content);\n\n\tlet tokens = $.derived(() => tokenizePrompt($.get(displayText)));\n\tvar div = root_4();\n\n\t$.each(div, 21, () => $.get(tokens), $.index, ($$anchor, token) => {\n\t\tvar fragment = $.comment();\n\t\tvar node = $.first_child(fragment);\n\n\t\t{\n\t\t\tvar consequent = ($$anchor) => {\n\t\t\t\tconst colors = $.derived(() => $$props.templateColorMap?.get($.get(token).value) || { from: \"#f43f5e\", to: \"#8b5cf6\" });\n\t\t\t\tvar span = root();\n\t\t\t\tvar text = $.only_child(span, true);\n\n\t\t\t\t$.template_effect(() => {\n\t\t\t\t\t$.set_style(span, `--color-from: ${$.get(colors).from}; --color-to: ${$.get(colors).to};`);\n\t\t\t\t\t$.set_attribute(span, 'title', `Template: ${$.get(token).value}`);\n\t\t\t\t\t$.set_text(text, `{{${$.get(token).value}}}`);\n\t\t\t\t});\n\n\t\t\t\t$.delegated('click', span, () => $$props.onTemplateClick?.($.get(token).value));\n\t\t\t\t$.append($$anchor, span);\n\t\t\t};\n\n\t\t\tvar consequent_1 = ($$anchor) => {\n\t\t\t\tvar span_1 = root_1();\n\t\t\t\tvar text_1 = $.only_child(span_1, true);\n\n\t\t\t\t$.template_effect(() => {\n\t\t\t\t\t$.set_attribute(span_1, 'title', `Variable: ${$.get(token).value}`);\n\t\t\t\t\t$.set_text(text_1, `{${$.get(token).value}}`);\n\t\t\t\t});\n\n\t\t\t\t$.delegated('click', span_1, () => $$props.onVariableClick?.($.get(token).value));\n\t\t\t\t$.append($$anchor, span_1);\n\t\t\t};\n\n\t\t\tvar consequent_2 = ($$anchor) => {\n\t\t\t\tvar span_2 = root_2();\n\t\t\t\tvar text_2 = $.only_child(span_2, true);\n\n\t\t\t\t$.template_effect(() => {\n\t\t\t\t\t$.set_attribute(span_2, 'title', `Instruction: ${$.get(token).value}`);\n\t\t\t\t\t$.set_text(text_2, `__${$.get(token).value}__`);\n\t\t\t\t});\n\n\t\t\t\t$.append($$anchor, span_2);\n\t\t\t};\n\n\t\t\tvar alternate = ($$anchor) => {\n\t\t\t\tvar span_3 = root_3();\n\t\t\t\tvar text_3 = $.only_child(span_3, true);\n\n\t\t\t\t$.template_effect(() => $.set_text(text_3, $.get(token).value));\n\t\t\t\t$.append($$anchor, span_3);\n\t\t\t};\n\n\t\t\t$.if(node, ($$render) => {\n\t\t\t\tif ($.get(token).type === \"template\") $$render(consequent); else if ($.get(token).type === \"variable\") $$render(consequent_1, 1); else if ($.get(token).type === \"instruction\") $$render(consequent_2, 2); else $$render(alternate, -1);\n\t\t\t});\n\t\t}\n\n\t\t$.append($$anchor, fragment);\n\t});\n\n\t$.reset(div);\n\t$.template_effect(() => $.set_class(div, 1, $.clsx(className())));\n\t$.append($$anchor, div);\n\t$.pop();\n}\n\n$.delegate(['click']);","import 'svelte/internal/disclose-version';\nimport * as $ from 'svelte/internal/client';\nimport { indexToColName } from '@pixerate/editor';\nimport FormulaBar from './FormulaBar.svelte';\nimport { createReactiveSpreadsheet } from './spreadsheet.svelte';\n\nvar root = $.from_html(`<th class=\"relative border-r border-border px-2 text-left font-medium text-muted-foreground hover:bg-muted/90 transition-colors group cursor-pointer\"><div class=\"flex items-center justify-between gap-1 truncate\"><span class=\"truncate font-semibold text-foreground text-xs\"> </span> <span class=\"text-[10px] text-muted-foreground/70 font-mono font-normal\"> </span></div> <div class=\"absolute right-0 top-0 bottom-0 w-1.5 cursor-col-resize hover:bg-primary/50 group-hover:bg-primary/20 z-10\" role=\"separator\" aria-orientation=\"vertical\"></div></th>`);\nvar root_1 = $.from_html(`<th class=\"w-10 min-w-[2.5rem] px-1 text-center bg-muted/40 hover:bg-muted cursor-pointer transition-colors\" title=\"Add Column\"><span class=\"text-xs font-bold text-muted-foreground\">+</span></th>`);\nvar root_2 = $.from_html(`<input type=\"text\" class=\"absolute inset-0 w-full h-full px-2 py-1 bg-background text-foreground outline-none font-sans text-xs border-2 border-primary z-20\"/>`);\nvar root_3 = $.from_html(`<span> </span>`);\nvar root_4 = $.from_html(`<td><!></td>`);\nvar root_5 = $.from_html(`<td class=\"w-10 min-w-[2.5rem] bg-muted/10 border-r border-border\"></td>`);\nvar root_6 = $.from_html(`<tr class=\"border-b border-border hover:bg-muted/10 transition-colors\"><td class=\"w-12 min-w-[3rem] sticky left-0 z-10 bg-muted/50 border-r border-border text-center text-[10px] text-muted-foreground font-mono select-none\"> </td><!><!></tr>`);\nvar root_7 = $.from_html(`<div class=\"flex flex-col h-full w-full overflow-hidden border border-border bg-background select-none outline-none text-foreground font-sans text-xs\" tabindex=\"0\" role=\"grid\" aria-label=\"Spreadsheet\"><!> <div class=\"relative flex-1 overflow-auto\"><table class=\"border-collapse table-fixed w-max min-w-full\"><thead><tr class=\"h-7 bg-muted/60 sticky top-0 z-20 border-b border-border shadow-xs\"><th class=\"w-12 min-w-[3rem] sticky left-0 z-30 bg-muted/90 border-r border-border text-center text-[10px] text-muted-foreground font-medium\">#</th><!><!></tr></thead><tbody></tbody></table></div></div>`);\n\nexport default function SpreadsheetEditor($$anchor, $$props) {\n\t$.push($$props, true);\n\n\tlet sheetState = $.prop($$props, 'sheetState', 23, createReactiveSpreadsheet),\n\t\treadOnly = $.prop($$props, 'readOnly', 3, false);\n\n\tlet gridContainer = $.state(null);\n\tlet resizingColId = $.state(null);\n\tlet resizeStartX = $.state(0);\n\tlet resizeStartWidth = $.state(0);\n\n\t// Active cell formula bar binding\n\tlet activeRawValue = $.derived(() => {\n\t\tif (!sheetState().activeCell) return '';\n\n\t\tconst row = sheetState().document.rows[sheetState().activeCell.row];\n\t\tconst col = sheetState().document.columns[sheetState().activeCell.col];\n\n\t\tif (!row || !col) return '';\n\n\t\treturn sheetState().getCell(row.id, col.id).raw;\n\t});\n\n\tfunction handleCellClick(rIdx, cIdx, e) {\n\t\tif (sheetState().editingCell && (sheetState().editingCell.row !== rIdx || sheetState().editingCell.col !== cIdx)) {\n\t\t\tsheetState().commitEditing();\n\t\t}\n\n\t\tsheetState().selectCell(rIdx, cIdx, e.shiftKey);\n\t}\n\n\tfunction handleCellDblClick(rIdx, cIdx) {\n\t\tif (readOnly()) return;\n\n\t\tconst col = sheetState().document.columns[cIdx];\n\n\t\tif (col?.readOnly) return;\n\n\t\tsheetState().startEditing(rIdx, cIdx);\n\t}\n\n\tfunction handleKeyDown(e) {\n\t\tif (sheetState().editingCell) {\n\t\t\tif (e.key === 'Enter') {\n\t\t\t\te.preventDefault();\n\t\t\t\tsheetState().commitEditing();\n\t\t\t\tsheetState().moveCursor('down');\n\t\t\t} else if (e.key === 'Escape') {\n\t\t\t\te.preventDefault();\n\t\t\t\tsheetState().cancelEditing();\n\t\t\t} else if (e.key === 'Tab') {\n\t\t\t\te.preventDefault();\n\t\t\t\tsheetState().commitEditing();\n\t\t\t\tsheetState().moveCursor(e.shiftKey ? 'left' : 'right');\n\t\t\t}\n\n\t\t\treturn;\n\t\t}\n\n\t\tif (!sheetState().activeCell) return;\n\n\t\tif (e.key === 'ArrowUp') {\n\t\t\te.preventDefault();\n\t\t\tsheetState().moveCursor('up', e.shiftKey);\n\t\t} else if (e.key === 'ArrowDown') {\n\t\t\te.preventDefault();\n\t\t\tsheetState().moveCursor('down', e.shiftKey);\n\t\t} else if (e.key === 'ArrowLeft') {\n\t\t\te.preventDefault();\n\t\t\tsheetState().moveCursor('left', e.shiftKey);\n\t\t} else if (e.key === 'ArrowRight') {\n\t\t\te.preventDefault();\n\t\t\tsheetState().moveCursor('right', e.shiftKey);\n\t\t} else if (e.key === 'Tab') {\n\t\t\te.preventDefault();\n\t\t\tsheetState().moveCursor(e.shiftKey ? 'left' : 'right');\n\t\t} else if (e.key === 'Enter') {\n\t\t\te.preventDefault();\n\n\t\t\tconst col = sheetState().document.columns[sheetState().activeCell.col];\n\n\t\t\tif (!readOnly() && !col?.readOnly) {\n\t\t\t\tsheetState().startEditing();\n\t\t\t}\n\t\t} else if (e.key === 'Backspace' || e.key === 'Delete') {\n\t\t\tif (readOnly()) return;\n\n\t\t\tconst row = sheetState().document.rows[sheetState().activeCell.row];\n\t\t\tconst col = sheetState().document.columns[sheetState().activeCell.col];\n\n\t\t\tif (row && col && !col.readOnly) {\n\t\t\t\te.preventDefault();\n\t\t\t\tsheetState().setCellValue(row.id, col.id, '');\n\t\t\t}\n\t\t} else if ((e.metaKey || e.ctrlKey) && e.key === 'z') {\n\t\t\te.preventDefault();\n\n\t\t\tif (e.shiftKey) {\n\t\t\t\tsheetState().redo();\n\t\t\t} else {\n\t\t\t\tsheetState().undo();\n\t\t\t}\n\t\t} else if ((e.metaKey || e.ctrlKey) && e.key === 'c') {\n\t\t\te.preventDefault();\n\n\t\t\tconst tsv = sheetState().exportToTsv();\n\n\t\t\tnavigator.clipboard?.writeText(tsv);\n\t\t} else if (!readOnly() && e.key.length === 1 && !e.ctrlKey && !e.metaKey && !e.altKey) {\n\t\t\t// Direct typing into cell starts editing\n\t\t\tconst col = sheetState().document.columns[sheetState().activeCell.col];\n\n\t\t\tif (!col?.readOnly) {\n\t\t\t\tsheetState().startEditing(sheetState().activeCell.row, sheetState().activeCell.col, e.key);\n\t\t\t}\n\t\t}\n\t}\n\n\tfunction handleResizeStart(colId, width, e) {\n\t\te.preventDefault();\n\t\te.stopPropagation();\n\t\t$.set(resizingColId, colId, true);\n\t\t$.set(resizeStartX, e.clientX, true);\n\t\t$.set(resizeStartWidth, width, true);\n\n\t\tconst handleMouseMove = (moveEvent) => {\n\t\t\tif (!$.get(resizingColId)) return;\n\n\t\t\tconst delta = moveEvent.clientX - $.get(resizeStartX);\n\n\t\t\tsheetState().setColumnWidth($.get(resizingColId), Math.max(60, $.get(resizeStartWidth) + delta));\n\t\t};\n\n\t\tconst handleMouseUp = () => {\n\t\t\t$.set(resizingColId, null);\n\t\t\twindow.removeEventListener('mousemove', handleMouseMove);\n\t\t\twindow.removeEventListener('mouseup', handleMouseUp);\n\t\t};\n\n\t\twindow.addEventListener('mousemove', handleMouseMove);\n\t\twindow.addEventListener('mouseup', handleMouseUp);\n\t}\n\n\tfunction isCellSelected(rIdx, cIdx) {\n\t\tif (!sheetState().selectedRange) return false;\n\n\t\tconst minR = Math.min(sheetState().selectedRange.startRow, sheetState().selectedRange.endRow);\n\t\tconst maxR = Math.max(sheetState().selectedRange.startRow, sheetState().selectedRange.endRow);\n\t\tconst minC = Math.min(sheetState().selectedRange.startCol, sheetState().selectedRange.endCol);\n\t\tconst maxC = Math.max(sheetState().selectedRange.startCol, sheetState().selectedRange.endCol);\n\n\t\treturn rIdx >= minR && rIdx <= maxR && cIdx >= minC && cIdx <= maxC;\n\t}\n\n\tfunction isActiveCell(rIdx, cIdx) {\n\t\treturn sheetState().activeCell?.row === rIdx && sheetState().activeCell?.col === cIdx;\n\t}\n\n\tvar div = root_7();\n\tvar node = $.child(div);\n\n\t{\n\t\tlet $0 = $.derived(() => sheetState().editingCell ? sheetState().draftValue : $.get(activeRawValue));\n\n\t\tFormulaBar(node, {\n\t\t\tget activeCoord() {\n\t\t\t\treturn sheetState().activeCell;\n\t\t\t},\n\n\t\t\tget value() {\n\t\t\t\treturn $.get($0);\n\t\t\t},\n\n\t\t\tonChange: (val) => {\n\t\t\t\tif (sheetState().activeCell) {\n\t\t\t\t\tsheetState().draftValue = val;\n\t\t\t\t}\n\t\t\t},\n\n\t\t\tonCommit: (val) => {\n\t\t\t\tif (sheetState().activeCell) {\n\t\t\t\t\tconst row = sheetState().document.rows[sheetState().activeCell.row];\n\t\t\t\t\tconst col = sheetState().document.columns[sheetState().activeCell.col];\n\n\t\t\t\t\tif (row && col) {\n\t\t\t\t\t\tsheetState().setCellValue(row.id, col.id, val);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\n\t\t\tonCancel: () => {\n\t\t\t\tsheetState().cancelEditing();\n\t\t\t}\n\t\t});\n\t}\n\n\tvar div_1 = $.sibling(node, 2);\n\tvar table = $.child(div_1);\n\tvar thead = $.child(table);\n\tvar tr = $.child(thead);\n\tvar node_1 = $.sibling($.child(tr));\n\n\t$.each(node_1, 19, () => sheetState().document.columns, (col) => col.id, ($$anchor, col) => {\n\t\tvar th = root();\n\t\tvar div_2 = $.child(th);\n\t\tvar span = $.child(div_2);\n\t\tvar text = $.only_child(span, true);\n\t\tvar span_1 = $.sibling(span, 2);\n\t\tvar text_1 = $.only_child(span_1);\n\n\t\t$.reset(div_2);\n\n\t\tvar div_3 = $.sibling(div_2, 2);\n\n\t\t$.reset(th);\n\n\t\t$.template_effect(() => {\n\t\t\t$.set_style(th, `width: ${($.get(col).width || 130) ?? ''}px; min-width: ${($.get(col).width || 130) ?? ''}px; max-width: ${($.get(col).width || 130) ?? ''}px;`);\n\t\t\t$.set_text(text, $.get(col).title);\n\t\t\t$.set_text(text_1, `(${$.get(col).key ?? ''})`);\n\t\t});\n\n\t\t$.delegated('click', th, () => $$props.onColumnHeaderClick?.($.get(col)));\n\t\t$.delegated('mousedown', div_3, (e) => handleResizeStart($.get(col).id, $.get(col).width || 130, e));\n\t\t$.append($$anchor, th);\n\t});\n\n\tvar node_2 = $.sibling(node_1);\n\n\t{\n\t\tvar consequent = ($$anchor) => {\n\t\t\tvar th_1 = root_1();\n\n\t\t\t$.delegated('click', th_1, function (...$$args) {\n\t\t\t\t$$props.onAddColumnClick?.apply(this, $$args);\n\t\t\t});\n\n\t\t\t$.append($$anchor, th_1);\n\t\t};\n\n\t\t$.if(node_2, ($$render) => {\n\t\t\tif ($$props.onAddColumnClick) $$render(consequent);\n\t\t});\n\t}\n\n\t$.reset(tr);\n\t$.reset(thead);\n\n\tvar tbody = $.sibling(thead);\n\n\t$.each(tbody, 23, () => sheetState().document.rows, (row) => row.id, ($$anchor, row, rIdx) => {\n\t\tvar tr_1 = root_6();\n\t\tvar td = $.child(tr_1);\n\t\tvar text_2 = $.only_child(td, true);\n\t\tvar node_3 = $.sibling(td);\n\n\t\t$.each(node_3, 19, () => sheetState().document.columns, (col) => col.id, ($$anchor, col, cIdx) => {\n\t\t\tconst cell = $.derived(() => sheetState().getCell($.get(row).id, $.get(col).id));\n\t\t\tconst selected = $.derived(() => isCellSelected($.get(rIdx), $.get(cIdx)));\n\t\t\tconst active = $.derived(() => isActiveCell($.get(rIdx), $.get(cIdx)));\n\t\t\tconst isEditing = $.derived(() => sheetState().editingCell?.row === $.get(rIdx) && sheetState().editingCell?.col === $.get(cIdx));\n\t\t\tvar td_1 = root_4();\n\t\t\tvar node_4 = $.child(td_1);\n\n\t\t\t{\n\t\t\t\tvar consequent_1 = ($$anchor) => {\n\t\t\t\t\tvar input = root_2();\n\n\t\t\t\t\t$.remove_input_defaults(input);\n\t\t\t\t\t$.event('blur', input, () => sheetState().commitEditing());\n\t\t\t\t\t$.bind_value(input, () => sheetState().draftValue, ($$value) => sheetState().draftValue = $$value);\n\t\t\t\t\t$.append($$anchor, input);\n\t\t\t\t};\n\n\t\t\t\tvar consequent_2 = ($$anchor) => {\n\t\t\t\t\tvar fragment = $.comment();\n\t\t\t\t\tvar node_5 = $.first_child(fragment);\n\n\t\t\t\t\t$.snippet(node_5, () => $$props.customCellRenderer, () => ({ row: $.get(row), col: $.get(col), cell: $.get(cell) }));\n\t\t\t\t\t$.append($$anchor, fragment);\n\t\t\t\t};\n\n\t\t\t\tvar alternate = ($$anchor) => {\n\t\t\t\t\tvar span_2 = root_3();\n\t\t\t\t\tvar text_3 = $.only_child(span_2, true);\n\n\t\t\t\t\t$.template_effect(() => {\n\t\t\t\t\t\t$.set_class(span_2, 1, `truncate block ${$.get(cell).error ? 'text-destructive font-semibold' : ''}`);\n\t\t\t\t\t\t$.set_text(text_3, $.get(cell).error || ($.get(cell).value ?? ''));\n\t\t\t\t\t});\n\n\t\t\t\t\t$.append($$anchor, span_2);\n\t\t\t\t};\n\n\t\t\t\t$.if(node_4, ($$render) => {\n\t\t\t\t\tif ($.get(isEditing)) $$render(consequent_1); else if ($$props.customCellRenderer) $$render(consequent_2, 1); else $$render(alternate, -1);\n\t\t\t\t});\n\t\t\t}\n\n\t\t\t$.reset(td_1);\n\n\t\t\t$.template_effect(() => {\n\t\t\t\t$.set_class(td_1, 1, `relative border-r border-border px-2 py-1 truncate text-foreground transition-all ${$.get(selected) ? 'bg-primary/10' : ''} ${$.get(active) ? 'ring-2 ring-primary ring-inset z-10' : ''}`);\n\t\t\t\t$.set_style(td_1, `width: ${($.get(col).width || 130) ?? ''}px; min-width: ${($.get(col).width || 130) ?? ''}px; max-width: ${($.get(col).width || 130) ?? ''}px;`);\n\t\t\t});\n\n\t\t\t$.delegated('click', td_1, (e) => handleCellClick($.get(rIdx), $.get(cIdx), e));\n\t\t\t$.delegated('dblclick', td_1, () => handleCellDblClick($.get(rIdx), $.get(cIdx)));\n\t\t\t$.append($$anchor, td_1);\n\t\t});\n\n\t\tvar node_6 = $.sibling(node_3);\n\n\t\t{\n\t\t\tvar consequent_3 = ($$anchor) => {\n\t\t\t\tvar td_2 = root_5();\n\n\t\t\t\t$.append($$anchor, td_2);\n\t\t\t};\n\n\t\t\t$.if(node_6, ($$render) => {\n\t\t\t\tif ($$props.onAddColumnClick) $$render(consequent_3);\n\t\t\t});\n\t\t}\n\n\t\t$.reset(tr_1);\n\n\t\t$.template_effect(() => {\n\t\t\t$.set_style(tr_1, `height: ${($.get(row).height || 32) ?? ''}px;`);\n\t\t\t$.set_text(text_2, $.get(rIdx) + 1);\n\t\t});\n\n\t\t$.append($$anchor, tr_1);\n\t});\n\n\t$.reset(tbody);\n\t$.reset(table);\n\t$.reset(div_1);\n\t$.reset(div);\n\t$.bind_this(div, ($$value) => $.set(gridContainer, $$value), () => $.get(gridContainer));\n\t$.delegated('keydown', div, handleKeyDown);\n\t$.append($$anchor, div);\n\t$.pop();\n}\n\n$.delegate(['keydown', 'click', 'mousedown', 'dblclick']);","import 'svelte/internal/disclose-version';\nimport * as $ from 'svelte/internal/client';\nimport { indexToColName } from '@pixerate/editor';\n\nvar root = $.from_html(`<div class=\"flex items-center gap-2 border-b border-border bg-muted/20 px-3 py-1.5 text-xs font-mono\"><div class=\"flex h-6 min-w-[3rem] items-center justify-center rounded border border-border bg-background px-1.5 font-semibold text-foreground\"> </div> <div class=\"flex items-center text-muted-foreground select-none\"><span class=\"italic font-serif font-bold text-sm text-primary\">fx</span></div> <input type=\"text\" class=\"flex-1 bg-transparent px-2 py-0.5 outline-none font-sans text-xs text-foreground placeholder:text-muted-foreground/60 focus:bg-background focus:ring-1 focus:ring-primary rounded\" placeholder=\"Enter a value or formula (e.g. =SUM(A1:A5))\"/></div>`);\n\nexport default function FormulaBar($$anchor, $$props) {\n\t$.push($$props, true);\n\n\tlet activeCoord = $.prop($$props, 'activeCoord', 3, null),\n\t\tvalue = $.prop($$props, 'value', 15, '');\n\n\tlet coordLabel = $.derived(() => {\n\t\tif (!activeCoord()) return '--';\n\n\t\tconst colName = indexToColName(activeCoord().col);\n\n\t\treturn `${colName}${activeCoord().row + 1}`;\n\t});\n\n\tfunction handleKeyDown(e) {\n\t\tif (e.key === 'Enter') {\n\t\t\te.preventDefault();\n\t\t\t$$props.onCommit?.(value());\n\t\t} else if (e.key === 'Escape') {\n\t\t\te.preventDefault();\n\t\t\t$$props.onCancel?.();\n\t\t}\n\t}\n\n\tfunction handleInput(e) {\n\t\tconst target = e.target;\n\n\t\tvalue(target.value);\n\t\t$$props.onChange?.(target.value);\n\t}\n\n\tvar div = root();\n\tvar div_1 = $.child(div);\n\tvar text = $.only_child(div_1, true);\n\tvar input = $.sibling(div_1, 4);\n\n\t$.remove_input_defaults(input);\n\t$.reset(div);\n\n\t$.template_effect(() => {\n\t\t$.set_text(text, $.get(coordLabel));\n\t\t$.set_value(input, value());\n\t});\n\n\t$.delegated('input', input, handleInput);\n\t$.delegated('keydown', input, handleKeyDown);\n\t$.append($$anchor, div);\n\t$.pop();\n}\n\n$.delegate(['input', 'keydown']);","import {\n SpreadsheetController\n} from \"@pixerate/editor\";\nexport function createReactiveSpreadsheet(options = {}) {\n let doc = $state({\n id: options.document?.id || `sheet_${Date.now()}`,\n name: options.document?.name || \"Sheet 1\",\n columns: options.document?.columns || [],\n rows: options.document?.rows || [],\n cells: options.document?.cells || {},\n createdAt: options.document?.createdAt || Date.now(),\n updatedAt: options.document?.updatedAt || Date.now()\n });\n let activeCell = $state(null);\n let selectedRange = $state(null);\n let editingCell = $state(null);\n let draftValue = $state(\"\");\n const controller = new SpreadsheetController({\n ...options,\n document: options.document,\n onDocumentChange: (updated) => {\n doc = { ...updated };\n options.onDocumentChange?.(updated);\n },\n onSelectionChange: (active, range) => {\n activeCell = active;\n selectedRange = range;\n options.onSelectionChange?.(active, range);\n },\n onCellCommit: (rowId, colId, raw, value) => {\n options.onCellCommit?.(rowId, colId, raw, value);\n }\n });\n doc = { ...controller.document };\n activeCell = controller.activeCell;\n selectedRange = controller.selectedRange;\n return {\n get document() {\n return doc;\n },\n get activeCell() {\n return activeCell;\n },\n get selectedRange() {\n return selectedRange;\n },\n get editingCell() {\n return editingCell;\n },\n get draftValue() {\n return draftValue;\n },\n set draftValue(val) {\n draftValue = val;\n controller.draftValue = val;\n },\n controller,\n getCell(rowId, colId) {\n return controller.getCell(rowId, colId);\n },\n setCellValue(rowId, colId, raw) {\n controller.setCellValue(rowId, colId, raw);\n doc = { ...controller.document };\n },\n selectCell(row, col, extendSelection = false) {\n controller.selectCell(row, col, extendSelection);\n activeCell = controller.activeCell;\n selectedRange = controller.selectedRange;\n },\n selectRange(range) {\n controller.selectRange(range);\n selectedRange = controller.selectedRange;\n },\n startEditing(row, col, initialVal) {\n controller.startEditing(row, col, initialVal);\n activeCell = controller.activeCell;\n editingCell = controller.editingCell;\n draftValue = controller.draftValue;\n },\n commitEditing(val) {\n controller.commitEditing(val);\n editingCell = null;\n draftValue = \"\";\n doc = { ...controller.document };\n },\n cancelEditing() {\n controller.cancelEditing();\n editingCell = null;\n draftValue = \"\";\n },\n moveCursor(dir, extend = false) {\n controller.moveCursor(dir, extend);\n activeCell = controller.activeCell;\n selectedRange = controller.selectedRange;\n },\n insertColumn(index, config) {\n controller.insertColumn(index, config);\n doc = { ...controller.document };\n },\n deleteColumn(colId) {\n controller.deleteColumn(colId);\n doc = { ...controller.document };\n },\n insertRow(index, config) {\n controller.insertRow(index, config);\n doc = { ...controller.document };\n },\n deleteRow(rowId) {\n controller.deleteRow(rowId);\n doc = { ...controller.document };\n },\n setColumnWidth(colId, width) {\n controller.setColumnWidth(colId, width);\n doc = { ...controller.document };\n },\n registerDataSource(ds) {\n controller.registerDataSource(ds);\n doc = { ...controller.document };\n },\n setPrimaryDataSource(id) {\n controller.setPrimaryDataSource(id);\n doc = { ...controller.document };\n },\n recalculateAll() {\n controller.recalculateAll();\n doc = { ...controller.document };\n },\n exportToTsv() {\n return controller.exportToTsv();\n },\n importFromTsv(data) {\n controller.importFromTsv(data);\n doc = { ...controller.document };\n },\n undo() {\n controller.undo();\n doc = { ...controller.document };\n },\n redo() {\n controller.redo();\n doc = { ...controller.document };\n }\n };\n}\n","import type { Component } from \"svelte\";\nimport type { Editor, Content, Extensions } from \"@tiptap/core\";\nimport type { Template, ColorGradient } from \"@pixerate/editor\";\n\nimport EditableTextNodeEditorComponent from \"./EditableTextNodeEditor.svelte\";\nimport BubbleMenuComponent from \"./BubbleMenu.svelte\";\nimport TemplateRendererComponent from \"./TemplateRenderer.svelte\";\n\nexport * from \"./editor.svelte\";\n\nexport interface EditableTextNodeEditorProps {\n class?: string;\n content?: Content;\n showMenu?: boolean;\n editable?: boolean;\n editor?: Editor;\n extensions?: Extensions;\n onUpdate?: () => void;\n onFocus?: () => void;\n onBlur?: () => void;\n onCreate?: () => void;\n placeholder?: string;\n}\n\nexport interface BubbleMenuProps {\n editor?: Editor;\n class?: string;\n children?: any;\n}\n\nexport interface TemplateRendererProps {\n content: string;\n templates?: Template[];\n templateColorMap?: Map<string, ColorGradient>;\n resolve?: boolean;\n class?: string;\n onTemplateClick?: (templateName: string) => void;\n onVariableClick?: (variableName: string) => void;\n}\n\nexport const EditableTextNodeEditor = EditableTextNodeEditorComponent as unknown as Component<EditableTextNodeEditorProps>;\nexport const BubbleMenu = BubbleMenuComponent as unknown as Component<BubbleMenuProps>;\nexport const TemplateRenderer = TemplateRendererComponent as unknown as Component<TemplateRendererProps>;\n\nexport type {\n Template,\n TemplateVersion,\n Token,\n TokenType,\n ColorGradient,\n RichTextPresetOptions,\n} from \"@pixerate/editor\";\n\nexport * from \"./spreadsheet\";\n"],"mappings":";AAA2C,OAAO;AAClD,YAAYA,QAAO;AACnB,SAAS,WAAW,eAAe;AACnC,OAAO,iBAAiB;;;;ACHxB,SAAS,cAAc;AACvB,SAAS,4BAA4B;AAC9B,IAAM,iBAAc,CAAI,SAAS,SAAS,YAAY,YAAY;AACvE,QAAM,EAAE,iBAAe,GAAK,cAAa,IAAK,WAAO,CAAA;AACrD,QAAM,gBAAgB,qBAAqB,eAAe;AAC1D,QAAM,SAAS,IAAI,OAAM;IACvB;IACA;IACA,YAAU,CAAA,GACL,eAAa,GACb,cAAU,CAAA,CAAA;IAEf,WAAW;OACR;;AAEL,SAAO;AACT;AACO,SAAS,qBAAqB,iBAAiB,IAAI,aAAU,CAAA,GAAO,UAAO,CAAA,GAAO;AACvF,MAAI;AACJ,SAAM;IACJ,IAAI,UAAU;AACZ,aAAO;IACT;IACA,MAAM,SAAS;AACb,uBAAiB,eAAe,SAAS,gBAAgB,YAAY,OAAO;AAC5E,aAAO;IACT;IACA,UAAU;AACR,UAAI,gBAAgB;AAClB,uBAAe,QAAO;AACtB,yBAAc;MAChB;IACF;;AAEJ;;;AD5BA,IAAI,OAAS,aAAU,iGAAiG;AACxH,IAAI,SAAW,aAAU,yHAAyH;AAEnI,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AAMC,oBAAmB;","names":["$","$$anchor","$","root","$$anchor","$","root","root_1","$$anchor","$","indexToColName","$","root","index","root","root_1","root_2","root_3","root_4","$$anchor","EditableTextNodeEditor","BubbleMenu","TemplateRenderer"]}
|
|
1
|
+
{"version":3,"sources":["../src/EditableTextNodeEditor.svelte","../src/editor.svelte.ts","../src/BubbleMenu.svelte","../src/TemplateRenderer.svelte","../src/spreadsheet/SpreadsheetEditor.svelte","../src/spreadsheet/FormulaBar.svelte","../src/spreadsheet/spreadsheet.svelte.ts","../src/index.ts"],"sourcesContent":["import 'EditableTextNodeEditor.svelte.css';import 'svelte/internal/disclose-version';\nimport * as $ from 'svelte/internal/client';\nimport { onDestroy, onMount } from \"svelte\";\nimport Placeholder from \"@tiptap/extension-placeholder\";\nimport { initiateEditor } from \"./editor.svelte\";\n\nvar root = $.from_html(`<div class=\"flex items-center justify-center p-4 text-sm text-gray-500\">Loading editor...</div>`);\nvar root_1 = $.from_html(`<div draggable=\"false\"><!> <div class=\"pixerate-editor-content prose w-full max-w-none focus:outline-none\"></div></div>`);\n\nexport default function EditableTextNodeEditor($$anchor, $$props) {\n\t$.push($$props, true);\n\n\tlet className = $.prop($$props, 'class', 3, \"\"),\n\t\tcontent = $.prop($$props, 'content', 3, undefined),\n\t\tshowMenu = $.prop($$props, 'showMenu', 3, true),\n\t\teditable = $.prop($$props, 'editable', 3, true),\n\t\teditor = $.prop($$props, 'editor', 15),\n\t\textensions = $.prop($$props, 'extensions', 19, () => []),\n\t\tplaceholder = $.prop($$props, 'placeholder', 3, \"\");\n\n\tlet element = $.state(void 0);\n\n\t$.user_effect(() => {\n\t\tif (editor() && editor().isEditable !== editable()) {\n\t\t\teditor().setEditable(editable());\n\t\t}\n\t});\n\n\tonMount(() => {\n\t\teditor(initiateEditor(\n\t\t\t$.get(element),\n\t\t\tcontent(),\n\t\t\t[\n\t\t\t\tPlaceholder.configure({ placeholder: placeholder() }),\n\t\t\t\t...extensions()\n\t\t\t],\n\t\t\t{\n\t\t\t\teditable: editable(),\n\t\t\t\tonCreate: $$props.onCreate,\n\t\t\t\tonUpdate: $$props.onUpdate,\n\t\t\t\tonFocus() {\n\t\t\t\t\tif ($$props.onFocus) $$props.onFocus();\n\t\t\t\t},\n\n\t\t\t\tonBlur() {\n\t\t\t\t\tif ($$props.onBlur) $$props.onBlur();\n\t\t\t\t}\n\t\t\t}\n\t\t));\n\t});\n\n\tonDestroy(() => {\n\t\tif (editor()) {\n\t\t\teditor().destroy();\n\t\t}\n\t});\n\n\tvar div = root_1();\n\tvar node = $.child(div);\n\n\t{\n\t\tvar consequent = ($$anchor) => {\n\t\t\tvar div_1 = root();\n\n\t\t\t$.append($$anchor, div_1);\n\t\t};\n\n\t\t$.if(node, ($$render) => {\n\t\t\tif (!editor()) $$render(consequent);\n\t\t});\n\t}\n\n\tvar div_2 = $.sibling(node, 2);\n\n\t$.bind_this(div_2, ($$value) => $.set(element, $$value), () => $.get(element));\n\t$.reset(div);\n\t$.template_effect(() => $.set_class(div, 1, `pixerate-editor-container ${className()}`));\n\t$.append($$anchor, div);\n\t$.pop();\n}","import { Editor } from \"@tiptap/core\";\nimport { createRichTextPreset } from \"@pixerate/editor\";\nexport const initiateEditor = (element, content, extensions, options) => {\n const { richTextOptions, ...editorOptions } = options || {};\n const defaultPreset = createRichTextPreset(richTextOptions);\n const editor = new Editor({\n element,\n content,\n extensions: [\n ...defaultPreset,\n ...extensions ?? []\n ],\n autofocus: true,\n ...editorOptions\n });\n return editor;\n};\nexport function createReactiveEditor(initialContent = \"\", extensions = [], options = {}) {\n let editorInstance;\n return {\n get current() {\n return editorInstance;\n },\n mount(element) {\n editorInstance = initiateEditor(element, initialContent, extensions, options);\n return editorInstance;\n },\n destroy() {\n if (editorInstance) {\n editorInstance.destroy();\n editorInstance = void 0;\n }\n }\n };\n}\n","import 'svelte/internal/disclose-version';\nimport * as $ from 'svelte/internal/client';\nimport { BubbleMenuPlugin } from \"@tiptap/extension-bubble-menu\";\n\nvar root = $.from_html(`<div style=\"visibility: hidden;\"><!></div>`);\n\nexport default function BubbleMenu($$anchor, $$props) {\n\t$.push($$props, true);\n\n\tlet className = $.prop($$props, 'class', 3, \"flex h-fit w-fit items-center gap-1 rounded-md border border-gray-200 bg-white p-1 shadow-md\"),\n\t\tpluginKey = $.prop($$props, 'pluginKey', 3, \"bubbleMenu\"),\n\t\tshouldShow = $.prop($$props, 'shouldShow', 3, null),\n\t\tupdateDelay = $.prop($$props, 'updateDelay', 3, 250),\n\t\ttippyOptions = $.prop($$props, 'tippyOptions', 19, () => ({}));\n\n\tlet menuElement = $.state(void 0);\n\n\t$.user_effect(() => {\n\t\tif ($$props.editor && $.get(menuElement)) {\n\t\t\tconst plugin = BubbleMenuPlugin({\n\t\t\t\tpluginKey: pluginKey(),\n\t\t\t\teditor: $$props.editor,\n\t\t\t\telement: $.get(menuElement),\n\t\t\t\ttippyOptions: {\n\t\t\t\t\tduration: 100,\n\t\t\t\t\tappendTo: () => document.body,\n\t\t\t\t\t...tippyOptions()\n\t\t\t\t},\n\t\t\t\tshouldShow: shouldShow(),\n\t\t\t\tupdateDelay: updateDelay()\n\t\t\t});\n\n\t\t\t$$props.editor.registerPlugin(plugin);\n\n\t\t\treturn () => {\n\t\t\t\t$$props.editor.unregisterPlugin(pluginKey());\n\t\t\t};\n\t\t}\n\t});\n\n\tvar div = root();\n\tvar node = $.child(div);\n\n\t{\n\t\tvar consequent = ($$anchor) => {\n\t\t\tvar fragment = $.comment();\n\t\t\tvar node_1 = $.first_child(fragment);\n\n\t\t\t$.snippet(node_1, () => $$props.children);\n\t\t\t$.append($$anchor, fragment);\n\t\t};\n\n\t\t$.if(node, ($$render) => {\n\t\t\tif ($$props.children) $$render(consequent);\n\t\t});\n\t}\n\n\t$.reset(div);\n\t$.bind_this(div, ($$value) => $.set(menuElement, $$value), () => $.get(menuElement));\n\t$.template_effect(() => $.set_class(div, 1, $.clsx(className())));\n\t$.append($$anchor, div);\n\t$.pop();\n}","import 'svelte/internal/disclose-version';\nimport * as $ from 'svelte/internal/client';\nimport { tokenizePrompt, resolveTemplates } from \"@pixerate/editor\";\n\nvar root = $.from_html(`<span class=\"inline-flex items-center px-1.5 py-0.5 mx-0.5 text-xs font-semibold rounded-md border border-[var(--color-to)]/40 bg-gradient-to-r from-[var(--color-from)]/15 to-[var(--color-to)]/15 text-[var(--color-to)] hover:brightness-110 cursor-pointer transition-all\"> </span>`);\nvar root_1 = $.from_html(`<span class=\"inline-flex items-center px-1.5 py-0.5 mx-0.5 text-xs font-medium rounded-md border border-violet-400/40 bg-violet-400/15 text-violet-600 hover:brightness-110 cursor-pointer transition-all\"> </span>`);\nvar root_2 = $.from_html(`<span class=\"inline-flex items-center px-1.5 py-0.5 mx-0.5 text-xs italic font-medium rounded-md border border-rose-400/40 bg-rose-400/15 text-rose-600\"> </span>`);\nvar root_3 = $.from_html(`<span> </span>`);\nvar root_4 = $.from_html(`<div></div>`);\n\nexport default function TemplateRenderer($$anchor, $$props) {\n\t$.push($$props, true);\n\n\tlet templates = $.prop($$props, 'templates', 19, () => []),\n\t\tresolve = $.prop($$props, 'resolve', 3, false),\n\t\tclassName = $.prop($$props, 'class', 3, \"font-mono text-sm leading-relaxed whitespace-pre-wrap break-words\");\n\n\tlet displayText = $.derived(() => resolve() && templates().length > 0\n\t\t? resolveTemplates($$props.content, templates())\n\t\t: $$props.content);\n\n\tlet tokens = $.derived(() => tokenizePrompt($.get(displayText)));\n\tvar div = root_4();\n\n\t$.each(div, 21, () => $.get(tokens), $.index, ($$anchor, token) => {\n\t\tvar fragment = $.comment();\n\t\tvar node = $.first_child(fragment);\n\n\t\t{\n\t\t\tvar consequent = ($$anchor) => {\n\t\t\t\tconst colors = $.derived(() => $$props.templateColorMap?.get($.get(token).value) || { from: \"#f43f5e\", to: \"#8b5cf6\" });\n\t\t\t\tvar span = root();\n\t\t\t\tvar text = $.only_child(span, true);\n\n\t\t\t\t$.template_effect(() => {\n\t\t\t\t\t$.set_style(span, `--color-from: ${$.get(colors).from}; --color-to: ${$.get(colors).to};`);\n\t\t\t\t\t$.set_attribute(span, 'title', `Template: ${$.get(token).value}`);\n\t\t\t\t\t$.set_text(text, `{{${$.get(token).value}}}`);\n\t\t\t\t});\n\n\t\t\t\t$.delegated('click', span, () => $$props.onTemplateClick?.($.get(token).value));\n\t\t\t\t$.append($$anchor, span);\n\t\t\t};\n\n\t\t\tvar consequent_1 = ($$anchor) => {\n\t\t\t\tvar span_1 = root_1();\n\t\t\t\tvar text_1 = $.only_child(span_1, true);\n\n\t\t\t\t$.template_effect(() => {\n\t\t\t\t\t$.set_attribute(span_1, 'title', `Variable: ${$.get(token).value}`);\n\t\t\t\t\t$.set_text(text_1, `{${$.get(token).value}}`);\n\t\t\t\t});\n\n\t\t\t\t$.delegated('click', span_1, () => $$props.onVariableClick?.($.get(token).value));\n\t\t\t\t$.append($$anchor, span_1);\n\t\t\t};\n\n\t\t\tvar consequent_2 = ($$anchor) => {\n\t\t\t\tvar span_2 = root_2();\n\t\t\t\tvar text_2 = $.only_child(span_2, true);\n\n\t\t\t\t$.template_effect(() => {\n\t\t\t\t\t$.set_attribute(span_2, 'title', `Instruction: ${$.get(token).value}`);\n\t\t\t\t\t$.set_text(text_2, `__${$.get(token).value}__`);\n\t\t\t\t});\n\n\t\t\t\t$.append($$anchor, span_2);\n\t\t\t};\n\n\t\t\tvar alternate = ($$anchor) => {\n\t\t\t\tvar span_3 = root_3();\n\t\t\t\tvar text_3 = $.only_child(span_3, true);\n\n\t\t\t\t$.template_effect(() => $.set_text(text_3, $.get(token).value));\n\t\t\t\t$.append($$anchor, span_3);\n\t\t\t};\n\n\t\t\t$.if(node, ($$render) => {\n\t\t\t\tif ($.get(token).type === \"template\") $$render(consequent); else if ($.get(token).type === \"variable\") $$render(consequent_1, 1); else if ($.get(token).type === \"instruction\") $$render(consequent_2, 2); else $$render(alternate, -1);\n\t\t\t});\n\t\t}\n\n\t\t$.append($$anchor, fragment);\n\t});\n\n\t$.reset(div);\n\t$.template_effect(() => $.set_class(div, 1, $.clsx(className())));\n\t$.append($$anchor, div);\n\t$.pop();\n}\n\n$.delegate(['click']);","import 'svelte/internal/disclose-version';\nimport * as $ from 'svelte/internal/client';\nimport { indexToColName } from '@pixerate/editor';\nimport FormulaBar from './FormulaBar.svelte';\nimport { createReactiveSpreadsheet } from './spreadsheet.svelte';\n\nvar root = $.from_html(`<th class=\"relative border-r border-border px-2 text-left font-medium text-muted-foreground hover:bg-muted/90 transition-colors group cursor-pointer\"><div class=\"flex items-center justify-between gap-1 truncate\"><span class=\"truncate font-semibold text-foreground text-xs\"> </span> <span class=\"text-[10px] text-muted-foreground/70 font-mono font-normal\"> </span></div> <div class=\"absolute right-0 top-0 bottom-0 w-1.5 cursor-col-resize hover:bg-primary/50 group-hover:bg-primary/20 z-10\" role=\"separator\" aria-orientation=\"vertical\" tabindex=\"-1\"></div></th>`);\nvar root_1 = $.from_html(`<th class=\"w-10 min-w-[2.5rem] px-1 text-center bg-muted/40 hover:bg-muted cursor-pointer transition-colors\" title=\"Add Column\"><span class=\"text-xs font-bold text-muted-foreground\">+</span></th>`);\nvar root_2 = $.from_html(`<input type=\"text\" class=\"absolute inset-0 w-full h-full px-2 py-1 bg-background text-foreground outline-none font-sans text-xs border-2 border-primary z-20\"/>`);\nvar root_3 = $.from_html(`<span> </span>`);\nvar root_4 = $.from_html(`<td><!></td>`);\nvar root_5 = $.from_html(`<td class=\"w-10 min-w-[2.5rem] bg-muted/10 border-r border-border\"></td>`);\nvar root_6 = $.from_html(`<tr class=\"border-b border-border hover:bg-muted/10 transition-colors\"><td class=\"w-12 min-w-[3rem] sticky left-0 z-10 bg-muted/50 border-r border-border text-center text-[10px] text-muted-foreground font-mono select-none\"> </td><!><!></tr>`);\nvar root_7 = $.from_html(`<div tabindex=\"0\" role=\"grid\" aria-label=\"Spreadsheet\"><!> <div class=\"relative flex-1 overflow-auto\"><table class=\"border-collapse table-fixed w-max min-w-full\"><thead><tr class=\"h-7 bg-muted/60 sticky top-0 z-20 border-b border-border shadow-xs\"><th class=\"w-12 min-w-[3rem] sticky left-0 z-30 bg-muted/90 border-r border-border text-center text-[10px] text-muted-foreground font-medium\">#</th><!><!></tr></thead><tbody></tbody></table></div></div>`);\n\nexport default function SpreadsheetEditor($$anchor, $$props) {\n\t$.push($$props, true);\n\n\tlet sheetState = $.prop($$props, 'sheetState', 23, createReactiveSpreadsheet),\n\t\treadOnly = $.prop($$props, 'readOnly', 3, false),\n\t\treadonly = $.prop($$props, 'readonly', 3, false),\n\t\tshowFormulaBar = $.prop($$props, 'showFormulaBar', 3, true),\n\t\tclassName = $.prop($$props, 'class', 3, '');\n\n\tlet isReadOnly = $.derived(() => readOnly() || readonly());\n\tlet gridContainer = $.state(null);\n\tlet resizingColId = $.state(null);\n\tlet resizeStartX = $.state(0);\n\tlet resizeStartWidth = $.state(0);\n\n\tfunction handleCellClick(rIdx, cIdx, e) {\n\t\tif (sheetState().editingCell && (sheetState().editingCell.row !== rIdx || sheetState().editingCell.col !== cIdx)) {\n\t\t\tsheetState().commitEditing();\n\t\t}\n\n\t\tsheetState().selectCell(rIdx, cIdx, e.shiftKey);\n\t}\n\n\tfunction handleCellDblClick(rIdx, cIdx) {\n\t\tif ($.get(isReadOnly)) return;\n\n\t\tconst col = sheetState().document.columns[cIdx];\n\n\t\tif (col?.readOnly) return;\n\n\t\tsheetState().startEditing(rIdx, cIdx);\n\t}\n\n\tfunction handleKeyDown(e) {\n\t\tif (sheetState().editingCell) {\n\t\t\tif (e.key === 'Escape') {\n\t\t\t\tsheetState().cancelEditing();\n\t\t\t} else if (e.key === 'Enter') {\n\t\t\t\tsheetState().commitEditing();\n\t\t\t\tsheetState().moveCursor('down');\n\t\t\t} else if (e.key === 'Tab') {\n\t\t\t\te.preventDefault();\n\t\t\t\tsheetState().commitEditing();\n\t\t\t\tsheetState().moveCursor(e.shiftKey ? 'left' : 'right');\n\t\t\t}\n\n\t\t\treturn;\n\t\t}\n\n\t\tif (!sheetState().activeCell) return;\n\n\t\tif (e.key === 'ArrowUp') {\n\t\t\te.preventDefault();\n\t\t\tsheetState().moveCursor('up', e.shiftKey);\n\t\t} else if (e.key === 'ArrowDown') {\n\t\t\te.preventDefault();\n\t\t\tsheetState().moveCursor('down', e.shiftKey);\n\t\t} else if (e.key === 'ArrowLeft') {\n\t\t\te.preventDefault();\n\t\t\tsheetState().moveCursor('left', e.shiftKey);\n\t\t} else if (e.key === 'ArrowRight') {\n\t\t\te.preventDefault();\n\t\t\tsheetState().moveCursor('right', e.shiftKey);\n\t\t} else if (e.key === 'Tab') {\n\t\t\te.preventDefault();\n\t\t\tsheetState().moveCursor(e.shiftKey ? 'left' : 'right');\n\t\t} else if (e.key === 'Enter') {\n\t\t\te.preventDefault();\n\n\t\t\tconst col = sheetState().document.columns[sheetState().activeCell.col];\n\n\t\t\tif (!$.get(isReadOnly) && !col?.readOnly) {\n\t\t\t\tsheetState().startEditing();\n\t\t\t}\n\t\t} else if (e.key === 'Backspace' || e.key === 'Delete') {\n\t\t\tif ($.get(isReadOnly)) return;\n\n\t\t\tconst row = sheetState().document.rows[sheetState().activeCell.row];\n\t\t\tconst col = sheetState().document.columns[sheetState().activeCell.col];\n\n\t\t\tif (row && col && !col.readOnly) {\n\t\t\t\te.preventDefault();\n\t\t\t\tsheetState().setCellValue(row.id, col.id, '');\n\t\t\t}\n\t\t} else if ((e.metaKey || e.ctrlKey) && e.key === 'z') {\n\t\t\te.preventDefault();\n\n\t\t\tif (e.shiftKey) {\n\t\t\t\tsheetState().redo();\n\t\t\t} else {\n\t\t\t\tsheetState().undo();\n\t\t\t}\n\t\t} else if ((e.metaKey || e.ctrlKey) && e.key === 'c') {\n\t\t\te.preventDefault();\n\n\t\t\tconst tsv = sheetState().exportToTsv();\n\n\t\t\tnavigator.clipboard?.writeText(tsv);\n\t\t} else if (!$.get(isReadOnly) && e.key.length === 1 && !e.ctrlKey && !e.metaKey && !e.altKey) {\n\t\t\t// Direct typing into cell starts editing\n\t\t\tconst col = sheetState().document.columns[sheetState().activeCell.col];\n\n\t\t\tif (!col?.readOnly) {\n\t\t\t\tsheetState().startEditing(sheetState().activeCell.row, sheetState().activeCell.col, e.key);\n\t\t\t}\n\t\t}\n\t}\n\n\tfunction handleResizeStart(colId, width, e) {\n\t\te.preventDefault();\n\t\te.stopPropagation();\n\t\t$.set(resizingColId, colId, true);\n\t\t$.set(resizeStartX, e.clientX, true);\n\t\t$.set(resizeStartWidth, width, true);\n\n\t\tconst handleMouseMove = (moveEvent) => {\n\t\t\tif (!$.get(resizingColId)) return;\n\n\t\t\tconst delta = moveEvent.clientX - $.get(resizeStartX);\n\n\t\t\tsheetState().setColumnWidth($.get(resizingColId), Math.max(60, $.get(resizeStartWidth) + delta));\n\t\t};\n\n\t\tconst handleMouseUp = () => {\n\t\t\t$.set(resizingColId, null);\n\t\t\twindow.removeEventListener('mousemove', handleMouseMove);\n\t\t\twindow.removeEventListener('mouseup', handleMouseUp);\n\t\t};\n\n\t\twindow.addEventListener('mousemove', handleMouseMove);\n\t\twindow.addEventListener('mouseup', handleMouseUp);\n\t}\n\n\tfunction isCellSelected(rIdx, cIdx) {\n\t\tif (!sheetState().selectedRange) return false;\n\n\t\tconst minR = Math.min(sheetState().selectedRange.startRow, sheetState().selectedRange.endRow);\n\t\tconst maxR = Math.max(sheetState().selectedRange.startRow, sheetState().selectedRange.endRow);\n\t\tconst minC = Math.min(sheetState().selectedRange.startCol, sheetState().selectedRange.endCol);\n\t\tconst maxC = Math.max(sheetState().selectedRange.startCol, sheetState().selectedRange.endCol);\n\n\t\treturn rIdx >= minR && rIdx <= maxR && cIdx >= minC && cIdx <= maxC;\n\t}\n\n\tfunction isActiveCell(rIdx, cIdx) {\n\t\treturn sheetState().activeCell?.row === rIdx && sheetState().activeCell?.col === cIdx;\n\t}\n\n\tvar div = root_7();\n\tvar node = $.child(div);\n\n\t{\n\t\tvar consequent = ($$anchor) => {\n\t\t\tFormulaBar($$anchor, {\n\t\t\t\tget sheetState() {\n\t\t\t\t\treturn sheetState();\n\t\t\t\t}\n\t\t\t});\n\t\t};\n\n\t\t$.if(node, ($$render) => {\n\t\t\tif (showFormulaBar()) $$render(consequent);\n\t\t});\n\t}\n\n\tvar div_1 = $.sibling(node, 2);\n\tvar table = $.child(div_1);\n\tvar thead = $.child(table);\n\tvar tr = $.child(thead);\n\tvar node_1 = $.sibling($.child(tr));\n\n\t$.each(node_1, 19, () => sheetState().document.columns, (col) => col.id, ($$anchor, col) => {\n\t\tvar th = root();\n\t\tvar div_2 = $.child(th);\n\t\tvar span = $.child(div_2);\n\t\tvar text = $.only_child(span, true);\n\t\tvar span_1 = $.sibling(span, 2);\n\t\tvar text_1 = $.only_child(span_1);\n\n\t\t$.reset(div_2);\n\n\t\tvar div_3 = $.sibling(div_2, 2);\n\n\t\t$.reset(th);\n\n\t\t$.template_effect(() => {\n\t\t\t$.set_style(th, `width: ${($.get(col).width || 130) ?? ''}px; min-width: ${($.get(col).width || 130) ?? ''}px; max-width: ${($.get(col).width || 130) ?? ''}px;`);\n\t\t\t$.set_text(text, $.get(col).title);\n\t\t\t$.set_text(text_1, `(${$.get(col).key ?? ''})`);\n\t\t});\n\n\t\t$.delegated('click', th, () => $$props.onColumnHeaderClick?.($.get(col)));\n\t\t$.delegated('mousedown', div_3, (e) => handleResizeStart($.get(col).id, $.get(col).width || 130, e));\n\t\t$.append($$anchor, th);\n\t});\n\n\tvar node_2 = $.sibling(node_1);\n\n\t{\n\t\tvar consequent_1 = ($$anchor) => {\n\t\t\tvar th_1 = root_1();\n\n\t\t\t$.delegated('click', th_1, function (...$$args) {\n\t\t\t\t$$props.onAddColumnClick?.apply(this, $$args);\n\t\t\t});\n\n\t\t\t$.append($$anchor, th_1);\n\t\t};\n\n\t\t$.if(node_2, ($$render) => {\n\t\t\tif ($$props.onAddColumnClick) $$render(consequent_1);\n\t\t});\n\t}\n\n\t$.reset(tr);\n\t$.reset(thead);\n\n\tvar tbody = $.sibling(thead);\n\n\t$.each(tbody, 23, () => sheetState().document.rows, (row) => row.id, ($$anchor, row, rIdx) => {\n\t\tvar tr_1 = root_6();\n\t\tvar td = $.child(tr_1);\n\t\tvar text_2 = $.only_child(td, true);\n\t\tvar node_3 = $.sibling(td);\n\n\t\t$.each(node_3, 19, () => sheetState().document.columns, (col) => col.id, ($$anchor, col, cIdx) => {\n\t\t\tconst cell = $.derived(() => sheetState().getCell($.get(row).id, $.get(col).id));\n\t\t\tconst selected = $.derived(() => isCellSelected($.get(rIdx), $.get(cIdx)));\n\t\t\tconst active = $.derived(() => isActiveCell($.get(rIdx), $.get(cIdx)));\n\t\t\tconst isEditing = $.derived(() => sheetState().editingCell?.row === $.get(rIdx) && sheetState().editingCell?.col === $.get(cIdx));\n\t\t\tvar td_1 = root_4();\n\t\t\tvar node_4 = $.child(td_1);\n\n\t\t\t{\n\t\t\t\tvar consequent_2 = ($$anchor) => {\n\t\t\t\t\tvar input = root_2();\n\n\t\t\t\t\t$.remove_input_defaults(input);\n\t\t\t\t\t$.event('blur', input, () => sheetState().commitEditing());\n\t\t\t\t\t$.bind_value(input, () => sheetState().draftValue, ($$value) => sheetState().draftValue = $$value);\n\t\t\t\t\t$.append($$anchor, input);\n\t\t\t\t};\n\n\t\t\t\tvar consequent_3 = ($$anchor) => {\n\t\t\t\t\tconst cellArg = $.derived(() => Object.assign({ row: $.get(row), col: $.get(col), cell: $.get(cell) }, $.get(cell)));\n\t\t\t\t\tvar fragment_1 = $.comment();\n\t\t\t\t\tvar node_5 = $.first_child(fragment_1);\n\n\t\t\t\t\t$.snippet(node_5, () => $$props.customCellRenderer, () => $.get(cellArg), () => $.get(col), () => $.get(row));\n\t\t\t\t\t$.append($$anchor, fragment_1);\n\t\t\t\t};\n\n\t\t\t\tvar alternate = ($$anchor) => {\n\t\t\t\t\tvar span_2 = root_3();\n\t\t\t\t\tvar text_3 = $.only_child(span_2, true);\n\n\t\t\t\t\t$.template_effect(() => {\n\t\t\t\t\t\t$.set_class(span_2, 1, `truncate block ${$.get(cell).error ? 'text-destructive font-semibold' : ''}`);\n\t\t\t\t\t\t$.set_text(text_3, $.get(cell).error || ($.get(cell).value ?? ''));\n\t\t\t\t\t});\n\n\t\t\t\t\t$.append($$anchor, span_2);\n\t\t\t\t};\n\n\t\t\t\t$.if(node_4, ($$render) => {\n\t\t\t\t\tif ($.get(isEditing)) $$render(consequent_2); else if ($$props.customCellRenderer) $$render(consequent_3, 1); else $$render(alternate, -1);\n\t\t\t\t});\n\t\t\t}\n\n\t\t\t$.reset(td_1);\n\n\t\t\t$.template_effect(() => {\n\t\t\t\t$.set_class(td_1, 1, `relative border-r border-border px-2 py-1 truncate text-foreground transition-all ${$.get(selected) ? 'bg-primary/10' : ''} ${$.get(active) ? 'ring-2 ring-primary ring-inset z-10' : ''}`);\n\t\t\t\t$.set_style(td_1, `width: ${($.get(col).width || 130) ?? ''}px; min-width: ${($.get(col).width || 130) ?? ''}px; max-width: ${($.get(col).width || 130) ?? ''}px;`);\n\t\t\t});\n\n\t\t\t$.delegated('click', td_1, (e) => handleCellClick($.get(rIdx), $.get(cIdx), e));\n\t\t\t$.delegated('dblclick', td_1, () => handleCellDblClick($.get(rIdx), $.get(cIdx)));\n\t\t\t$.append($$anchor, td_1);\n\t\t});\n\n\t\tvar node_6 = $.sibling(node_3);\n\n\t\t{\n\t\t\tvar consequent_4 = ($$anchor) => {\n\t\t\t\tvar td_2 = root_5();\n\n\t\t\t\t$.append($$anchor, td_2);\n\t\t\t};\n\n\t\t\t$.if(node_6, ($$render) => {\n\t\t\t\tif ($$props.onAddColumnClick) $$render(consequent_4);\n\t\t\t});\n\t\t}\n\n\t\t$.reset(tr_1);\n\n\t\t$.template_effect(() => {\n\t\t\t$.set_style(tr_1, `height: ${($.get(row).height || 32) ?? ''}px;`);\n\t\t\t$.set_text(text_2, $.get(rIdx) + 1);\n\t\t});\n\n\t\t$.append($$anchor, tr_1);\n\t});\n\n\t$.reset(tbody);\n\t$.reset(table);\n\t$.reset(div_1);\n\t$.reset(div);\n\t$.bind_this(div, ($$value) => $.set(gridContainer, $$value), () => $.get(gridContainer));\n\t$.template_effect(() => $.set_class(div, 1, `flex flex-col h-full w-full overflow-hidden border border-border bg-background select-none outline-none text-foreground font-sans text-xs ${className() ?? ''}`));\n\t$.delegated('keydown', div, handleKeyDown);\n\t$.append($$anchor, div);\n\t$.pop();\n}\n\n$.delegate(['keydown', 'click', 'mousedown', 'dblclick']);","import 'svelte/internal/disclose-version';\nimport * as $ from 'svelte/internal/client';\nimport { indexToColName } from '@pixerate/editor';\n\nvar root = $.from_html(`<div><div class=\"flex h-6 min-w-[3rem] items-center justify-center rounded border border-border bg-background px-1.5 font-semibold text-foreground\"> </div> <div class=\"flex items-center text-muted-foreground select-none\"><span class=\"italic font-serif font-bold text-sm text-primary\">fx</span></div> <input type=\"text\" class=\"flex-1 bg-transparent px-2 py-0.5 outline-none font-sans text-xs text-foreground placeholder:text-muted-foreground/60 focus:bg-background focus:ring-1 focus:ring-primary rounded\" placeholder=\"Enter a value or formula (e.g. =SUM(A1:A5))\"/></div>`);\n\nexport default function FormulaBar($$anchor, $$props) {\n\t$.push($$props, true);\n\n\tlet sheetState = $.prop($$props, 'sheetState', 7),\n\t\tactiveCoord = $.prop($$props, 'activeCoord', 3, null),\n\t\tvalue = $.prop($$props, 'value', 15, ''),\n\t\tclassName = $.prop($$props, 'class', 3, '');\n\n\tlet effectiveCoord = $.derived(() => {\n\t\tif (sheetState()) return sheetState().activeCell;\n\n\t\treturn activeCoord();\n\t});\n\n\tlet coordLabel = $.derived(() => {\n\t\tif (!$.get(effectiveCoord)) return '--';\n\n\t\tconst colName = indexToColName($.get(effectiveCoord).col);\n\n\t\treturn `${colName}${$.get(effectiveCoord).row + 1}`;\n\t});\n\n\tlet effectiveValue = $.derived(() => {\n\t\tif (sheetState()) {\n\t\t\tif (sheetState().editingCell) return sheetState().draftValue;\n\t\t\tif (!sheetState().activeCell) return '';\n\n\t\t\tconst row = sheetState().document.rows[sheetState().activeCell.row];\n\t\t\tconst col = sheetState().document.columns[sheetState().activeCell.col];\n\n\t\t\tif (!row || !col) return '';\n\n\t\t\treturn sheetState().getCell(row.id, col.id).raw || '';\n\t\t}\n\n\t\treturn value();\n\t});\n\n\tfunction handleKeyDown(e) {\n\t\tif (e.key === 'Enter') {\n\t\t\te.preventDefault();\n\n\t\t\tif (sheetState() && sheetState().activeCell) {\n\t\t\t\tconst row = sheetState().document.rows[sheetState().activeCell.row];\n\t\t\t\tconst col = sheetState().document.columns[sheetState().activeCell.col];\n\n\t\t\t\tif (row && col) {\n\t\t\t\t\tsheetState().setCellValue(row.id, col.id, $.get(effectiveValue));\n\t\t\t\t}\n\n\t\t\t\tsheetState().commitEditing();\n\t\t\t}\n\n\t\t\t$$props.onCommit?.($.get(effectiveValue));\n\t\t} else if (e.key === 'Escape') {\n\t\t\te.preventDefault();\n\n\t\t\tif (sheetState()) {\n\t\t\t\tsheetState().cancelEditing();\n\t\t\t}\n\n\t\t\t$$props.onCancel?.();\n\t\t}\n\t}\n\n\tfunction handleInput(e) {\n\t\tconst target = e.target;\n\n\t\tif (sheetState()) {\n\t\t\tsheetState().draftValue = target.value;\n\n\t\t\tif (sheetState().activeCell && !sheetState().editingCell) {\n\t\t\t\tsheetState().startEditing(sheetState().activeCell.row, sheetState().activeCell.col, target.value);\n\t\t\t}\n\t\t} else {\n\t\t\tvalue(target.value);\n\t\t}\n\n\t\t$$props.onChange?.(target.value);\n\t}\n\n\tvar div = root();\n\tvar div_1 = $.child(div);\n\tvar text = $.only_child(div_1, true);\n\tvar input = $.sibling(div_1, 4);\n\n\t$.remove_input_defaults(input);\n\t$.reset(div);\n\n\t$.template_effect(() => {\n\t\t$.set_class(div, 1, `flex items-center gap-2 border-b border-border bg-muted/20 px-3 py-1.5 text-xs font-mono ${className() ?? ''}`);\n\t\t$.set_text(text, $.get(coordLabel));\n\t\t$.set_value(input, $.get(effectiveValue));\n\t});\n\n\t$.delegated('input', input, handleInput);\n\t$.delegated('keydown', input, handleKeyDown);\n\t$.append($$anchor, div);\n\t$.pop();\n}\n\n$.delegate(['input', 'keydown']);","import {\n SpreadsheetController\n} from \"@pixerate/editor\";\nexport function createReactiveSpreadsheet(options = {}) {\n let doc = $state({\n id: options.document?.id || `sheet_${Date.now()}`,\n name: options.document?.name || \"Sheet 1\",\n columns: options.document?.columns || [],\n rows: options.document?.rows || [],\n cells: options.document?.cells || {},\n createdAt: options.document?.createdAt || Date.now(),\n updatedAt: options.document?.updatedAt || Date.now()\n });\n let activeCell = $state(null);\n let selectedRange = $state(null);\n let editingCell = $state(null);\n let draftValue = $state(\"\");\n const controller = new SpreadsheetController({\n ...options,\n document: options.document,\n onDocumentChange: (updated) => {\n doc = { ...updated };\n options.onDocumentChange?.(updated);\n },\n onSelectionChange: (active, range) => {\n activeCell = active;\n selectedRange = range;\n options.onSelectionChange?.(active, range);\n },\n onCellCommit: (rowId, colId, raw, value) => {\n options.onCellCommit?.(rowId, colId, raw, value);\n }\n });\n doc = { ...controller.document };\n activeCell = controller.activeCell;\n selectedRange = controller.selectedRange;\n return {\n get document() {\n return doc;\n },\n get activeCell() {\n return activeCell;\n },\n get selectedRange() {\n return selectedRange;\n },\n get editingCell() {\n return editingCell;\n },\n get draftValue() {\n return draftValue;\n },\n set draftValue(val) {\n draftValue = val;\n controller.draftValue = val;\n },\n controller,\n getCell(rowId, colId) {\n return controller.getCell(rowId, colId);\n },\n setCellValue(rowId, colId, raw) {\n controller.setCellValue(rowId, colId, raw);\n doc = { ...controller.document };\n },\n selectCell(row, col, extendSelection = false) {\n controller.selectCell(row, col, extendSelection);\n activeCell = controller.activeCell;\n selectedRange = controller.selectedRange;\n },\n selectRange(range) {\n controller.selectRange(range);\n selectedRange = controller.selectedRange;\n },\n startEditing(row, col, initialVal) {\n controller.startEditing(row, col, initialVal);\n activeCell = controller.activeCell;\n editingCell = controller.editingCell;\n draftValue = controller.draftValue;\n },\n commitEditing(val) {\n controller.commitEditing(val);\n editingCell = null;\n draftValue = \"\";\n doc = { ...controller.document };\n },\n cancelEditing() {\n controller.cancelEditing();\n editingCell = null;\n draftValue = \"\";\n },\n moveCursor(dir, extend = false) {\n controller.moveCursor(dir, extend);\n activeCell = controller.activeCell;\n selectedRange = controller.selectedRange;\n },\n insertColumn(index, config) {\n controller.insertColumn(index, config);\n doc = { ...controller.document };\n },\n deleteColumn(colId) {\n controller.deleteColumn(colId);\n doc = { ...controller.document };\n },\n insertRow(index, config) {\n controller.insertRow(index, config);\n doc = { ...controller.document };\n },\n deleteRow(rowId) {\n controller.deleteRow(rowId);\n doc = { ...controller.document };\n },\n setColumnWidth(colId, width) {\n controller.setColumnWidth(colId, width);\n doc = { ...controller.document };\n },\n loadDocument(document) {\n controller.loadDocument(document);\n doc = { ...controller.document };\n activeCell = controller.activeCell;\n selectedRange = controller.selectedRange;\n editingCell = controller.editingCell;\n draftValue = controller.draftValue;\n },\n syncWithDataSource() {\n controller.syncWithDataSource();\n controller.recalculateAll();\n doc = { ...controller.document };\n },\n registerDataSource(ds) {\n controller.registerDataSource(ds);\n doc = { ...controller.document };\n },\n setPrimaryDataSource(id) {\n controller.setPrimaryDataSource(id);\n doc = { ...controller.document };\n },\n recalculateAll() {\n controller.recalculateAll();\n doc = { ...controller.document };\n },\n exportToTsv() {\n return controller.exportToTsv();\n },\n importFromTsv(data) {\n controller.importFromTsv(data);\n doc = { ...controller.document };\n },\n undo() {\n controller.undo();\n doc = { ...controller.document };\n },\n redo() {\n controller.redo();\n doc = { ...controller.document };\n }\n };\n}\n","import type { Component } from \"svelte\";\nimport type { Editor, Content, Extensions } from \"@tiptap/core\";\nimport type { Template, ColorGradient } from \"@pixerate/editor\";\n\nimport EditableTextNodeEditorComponent from \"./EditableTextNodeEditor.svelte\";\nimport BubbleMenuComponent from \"./BubbleMenu.svelte\";\nimport TemplateRendererComponent from \"./TemplateRenderer.svelte\";\n\nexport * from \"./editor.svelte\";\n\nexport interface EditableTextNodeEditorProps {\n class?: string;\n content?: Content;\n showMenu?: boolean;\n editable?: boolean;\n editor?: Editor;\n extensions?: Extensions;\n onUpdate?: () => void;\n onFocus?: () => void;\n onBlur?: () => void;\n onCreate?: () => void;\n placeholder?: string;\n}\n\nexport interface BubbleMenuProps {\n editor?: Editor;\n class?: string;\n children?: any;\n}\n\nexport interface TemplateRendererProps {\n content: string;\n templates?: Template[];\n templateColorMap?: Map<string, ColorGradient>;\n resolve?: boolean;\n class?: string;\n onTemplateClick?: (templateName: string) => void;\n onVariableClick?: (variableName: string) => void;\n}\n\nexport const EditableTextNodeEditor = EditableTextNodeEditorComponent as unknown as Component<EditableTextNodeEditorProps>;\nexport const BubbleMenu = BubbleMenuComponent as unknown as Component<BubbleMenuProps>;\nexport const TemplateRenderer = TemplateRendererComponent as unknown as Component<TemplateRendererProps>;\n\nexport type {\n Template,\n TemplateVersion,\n Token,\n TokenType,\n ColorGradient,\n RichTextPresetOptions,\n} from \"@pixerate/editor\";\n\nexport * from \"./spreadsheet\";\n"],"mappings":";AAA2C,OAAO;AAClD,YAAYA,QAAO;AACnB,SAAS,WAAW,eAAe;AACnC,OAAO,iBAAiB;;;;ACHxB,SAAS,cAAc;AACvB,SAAS,4BAA4B;AAC9B,IAAM,iBAAc,CAAI,SAAS,SAAS,YAAY,YAAY;AACvE,QAAM,EAAE,iBAAe,GAAK,cAAa,IAAK,WAAO,CAAA;AACrD,QAAM,gBAAgB,qBAAqB,eAAe;AAC1D,QAAM,SAAS,IAAI,OAAM;IACvB;IACA;IACA,YAAU,CAAA,GACL,eAAa,GACb,cAAU,CAAA,CAAA;IAEf,WAAW;OACR;;AAEL,SAAO;AACT;AACO,SAAS,qBAAqB,iBAAiB,IAAI,aAAU,CAAA,GAAO,UAAO,CAAA,GAAO;AACvF,MAAI;AACJ,SAAM;IACJ,IAAI,UAAU;AACZ,aAAO;IACT;IACA,MAAM,SAAS;AACb,uBAAiB,eAAe,SAAS,gBAAgB,YAAY,OAAO;AAC5E,aAAO;IACT;IACA,UAAU;AACR,UAAI,gBAAgB;AAClB,uBAAe,QAAO;AACtB,yBAAc;MACh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AEE,YAAS,CAAC,WAAW,SAAS,aAAa,UAAU,CAAC;;;AGnSjD,IAAMC,0BAAyB;AAC/B,IAAMC,cAAa;AACnB,IAAMC,oBAAmB;","names":["$","$$anchor","$","root","$$anchor","$","root","root_1","$$anchor","$","indexToColName","$","root","index","document","root","root_1","root_2","root_3","root_4","$$anchor","EditableTextNodeEditor","BubbleMenu","TemplateRenderer"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pixerate/editor-svelte",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"description": "Svelte bindings and prompt/rich-text components for @pixerate/editor",
|
|
5
5
|
"author": "Pixerate",
|
|
6
6
|
"license": "MIT",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"@tiptap/extension-placeholder": "^2.11.5",
|
|
33
33
|
"@tiptap/pm": "^2.11.5",
|
|
34
34
|
"@tiptap/starter-kit": "^2.11.5",
|
|
35
|
-
"@pixerate/editor": "0.4.
|
|
35
|
+
"@pixerate/editor": "0.4.1"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
38
|
"svelte": "^4.0.0 || ^5.0.0"
|
|
@@ -39,6 +39,7 @@
|
|
|
39
39
|
{#each tokens as token}
|
|
40
40
|
{#if token.type === "template"}
|
|
41
41
|
{@const colors = templateColorMap?.get(token.value) || { from: "#f43f5e", to: "#8b5cf6" }}
|
|
42
|
+
<!-- svelte-ignore a11y_click_events_have_key_events, a11y_no_static_element_interactions -->
|
|
42
43
|
<span
|
|
43
44
|
style={`--color-from: ${colors.from}; --color-to: ${colors.to};`}
|
|
44
45
|
onclick={() => onTemplateClick?.(token.value)}
|
|
@@ -48,6 +49,7 @@
|
|
|
48
49
|
{`{{${token.value}}}`}
|
|
49
50
|
</span>
|
|
50
51
|
{:else if token.type === "variable"}
|
|
52
|
+
<!-- svelte-ignore a11y_click_events_have_key_events, a11y_no_static_element_interactions -->
|
|
51
53
|
<span
|
|
52
54
|
onclick={() => onVariableClick?.(token.value)}
|
|
53
55
|
class="inline-flex items-center px-1.5 py-0.5 mx-0.5 text-xs font-medium rounded-md border border-violet-400/40 bg-violet-400/15 text-violet-600 hover:brightness-110 cursor-pointer transition-all"
|
package/src/index.d.ts
CHANGED
|
@@ -94,8 +94,15 @@ import type {
|
|
|
94
94
|
export interface SpreadsheetEditorProps {
|
|
95
95
|
sheetState: ReturnType<typeof createReactiveSpreadsheet>;
|
|
96
96
|
readonly?: boolean;
|
|
97
|
+
readOnly?: boolean;
|
|
98
|
+
showFormulaBar?: boolean;
|
|
97
99
|
class?: string;
|
|
98
|
-
customCellRenderer?:
|
|
100
|
+
customCellRenderer?:
|
|
101
|
+
| ((cell: CellData, col: SpreadsheetColumn, row: SpreadsheetRow) => any)
|
|
102
|
+
| ((args: { cell: CellData; col: SpreadsheetColumn; row: SpreadsheetRow }) => any)
|
|
103
|
+
| ((args: { row: SpreadsheetRow; col: SpreadsheetColumn; cell: CellData }) => any);
|
|
104
|
+
onAddColumnClick?: () => void;
|
|
105
|
+
onColumnHeaderClick?: (col: SpreadsheetColumn) => void;
|
|
99
106
|
}
|
|
100
107
|
|
|
101
108
|
export interface FormulaBarProps {
|
|
@@ -126,6 +133,8 @@ export declare function createReactiveSpreadsheet(options?: SpreadsheetControlle
|
|
|
126
133
|
insertRow(index: number, config?: Partial<SpreadsheetRow>): void;
|
|
127
134
|
deleteRow(rowId: string): void;
|
|
128
135
|
setColumnWidth(colId: string, width: number): void;
|
|
136
|
+
loadDocument(document: SpreadsheetDocument): void;
|
|
137
|
+
syncWithDataSource(): void;
|
|
129
138
|
registerDataSource(ds: SpreadsheetDataSource): void;
|
|
130
139
|
setPrimaryDataSource(id: string | undefined): void;
|
|
131
140
|
recalculateAll(): void;
|
|
@@ -1,46 +1,86 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { indexToColName } from '@pixerate/editor';
|
|
3
|
+
import type { createReactiveSpreadsheet } from './spreadsheet.svelte';
|
|
3
4
|
|
|
4
5
|
interface Props {
|
|
6
|
+
sheetState?: ReturnType<typeof createReactiveSpreadsheet>;
|
|
5
7
|
activeCoord?: { row: number; col: number } | null;
|
|
6
|
-
value
|
|
8
|
+
value?: string;
|
|
7
9
|
onChange?: (val: string) => void;
|
|
8
10
|
onCommit?: (val: string) => void;
|
|
9
11
|
onCancel?: () => void;
|
|
12
|
+
class?: string;
|
|
10
13
|
}
|
|
11
14
|
|
|
12
15
|
let {
|
|
16
|
+
sheetState,
|
|
13
17
|
activeCoord = null,
|
|
14
18
|
value = $bindable(''),
|
|
15
19
|
onChange,
|
|
16
20
|
onCommit,
|
|
17
|
-
onCancel
|
|
21
|
+
onCancel,
|
|
22
|
+
class: className = ''
|
|
18
23
|
}: Props = $props();
|
|
19
24
|
|
|
25
|
+
let effectiveCoord = $derived.by(() => {
|
|
26
|
+
if (sheetState) return sheetState.activeCell;
|
|
27
|
+
return activeCoord;
|
|
28
|
+
});
|
|
29
|
+
|
|
20
30
|
let coordLabel = $derived.by(() => {
|
|
21
|
-
if (!
|
|
22
|
-
const colName = indexToColName(
|
|
23
|
-
return `${colName}${
|
|
31
|
+
if (!effectiveCoord) return '--';
|
|
32
|
+
const colName = indexToColName(effectiveCoord.col);
|
|
33
|
+
return `${colName}${effectiveCoord.row + 1}`;
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
let effectiveValue = $derived.by(() => {
|
|
37
|
+
if (sheetState) {
|
|
38
|
+
if (sheetState.editingCell) return sheetState.draftValue;
|
|
39
|
+
if (!sheetState.activeCell) return '';
|
|
40
|
+
const row = sheetState.document.rows[sheetState.activeCell.row];
|
|
41
|
+
const col = sheetState.document.columns[sheetState.activeCell.col];
|
|
42
|
+
if (!row || !col) return '';
|
|
43
|
+
return sheetState.getCell(row.id, col.id).raw || '';
|
|
44
|
+
}
|
|
45
|
+
return value;
|
|
24
46
|
});
|
|
25
47
|
|
|
26
48
|
function handleKeyDown(e: KeyboardEvent) {
|
|
27
49
|
if (e.key === 'Enter') {
|
|
28
50
|
e.preventDefault();
|
|
29
|
-
|
|
51
|
+
if (sheetState && sheetState.activeCell) {
|
|
52
|
+
const row = sheetState.document.rows[sheetState.activeCell.row];
|
|
53
|
+
const col = sheetState.document.columns[sheetState.activeCell.col];
|
|
54
|
+
if (row && col) {
|
|
55
|
+
sheetState.setCellValue(row.id, col.id, effectiveValue);
|
|
56
|
+
}
|
|
57
|
+
sheetState.commitEditing();
|
|
58
|
+
}
|
|
59
|
+
onCommit?.(effectiveValue);
|
|
30
60
|
} else if (e.key === 'Escape') {
|
|
31
61
|
e.preventDefault();
|
|
62
|
+
if (sheetState) {
|
|
63
|
+
sheetState.cancelEditing();
|
|
64
|
+
}
|
|
32
65
|
onCancel?.();
|
|
33
66
|
}
|
|
34
67
|
}
|
|
35
68
|
|
|
36
69
|
function handleInput(e: Event) {
|
|
37
70
|
const target = e.target as HTMLInputElement;
|
|
38
|
-
|
|
71
|
+
if (sheetState) {
|
|
72
|
+
sheetState.draftValue = target.value;
|
|
73
|
+
if (sheetState.activeCell && !sheetState.editingCell) {
|
|
74
|
+
sheetState.startEditing(sheetState.activeCell.row, sheetState.activeCell.col, target.value);
|
|
75
|
+
}
|
|
76
|
+
} else {
|
|
77
|
+
value = target.value;
|
|
78
|
+
}
|
|
39
79
|
onChange?.(target.value);
|
|
40
80
|
}
|
|
41
81
|
</script>
|
|
42
82
|
|
|
43
|
-
<div class="flex items-center gap-2 border-b border-border bg-muted/20 px-3 py-1.5 text-xs font-mono">
|
|
83
|
+
<div class="flex items-center gap-2 border-b border-border bg-muted/20 px-3 py-1.5 text-xs font-mono {className}">
|
|
44
84
|
<div class="flex h-6 min-w-[3rem] items-center justify-center rounded border border-border bg-background px-1.5 font-semibold text-foreground">
|
|
45
85
|
{coordLabel}
|
|
46
86
|
</div>
|
|
@@ -51,7 +91,7 @@
|
|
|
51
91
|
type="text"
|
|
52
92
|
class="flex-1 bg-transparent px-2 py-0.5 outline-none font-sans text-xs text-foreground placeholder:text-muted-foreground/60 focus:bg-background focus:ring-1 focus:ring-primary rounded"
|
|
53
93
|
placeholder="Enter a value or formula (e.g. =SUM(A1:A5))"
|
|
54
|
-
{
|
|
94
|
+
value={effectiveValue}
|
|
55
95
|
oninput={handleInput}
|
|
56
96
|
onkeydown={handleKeyDown}
|
|
57
97
|
/>
|
|
@@ -7,7 +7,12 @@
|
|
|
7
7
|
interface Props {
|
|
8
8
|
sheetState?: ReturnType<typeof createReactiveSpreadsheet>;
|
|
9
9
|
readOnly?: boolean;
|
|
10
|
-
|
|
10
|
+
readonly?: boolean;
|
|
11
|
+
showFormulaBar?: boolean;
|
|
12
|
+
class?: string;
|
|
13
|
+
customCellRenderer?:
|
|
14
|
+
| Snippet<[CellData, SpreadsheetColumn, SpreadsheetRow]>
|
|
15
|
+
| Snippet<[{ row: SpreadsheetRow; col: SpreadsheetColumn; cell: CellData }]>;
|
|
11
16
|
onAddColumnClick?: () => void;
|
|
12
17
|
onColumnHeaderClick?: (col: SpreadsheetColumn) => void;
|
|
13
18
|
}
|
|
@@ -15,24 +20,22 @@
|
|
|
15
20
|
let {
|
|
16
21
|
sheetState = createReactiveSpreadsheet(),
|
|
17
22
|
readOnly = false,
|
|
23
|
+
readonly = false,
|
|
24
|
+
showFormulaBar = true,
|
|
25
|
+
class: className = '',
|
|
18
26
|
customCellRenderer,
|
|
19
27
|
onAddColumnClick,
|
|
20
28
|
onColumnHeaderClick
|
|
21
29
|
}: Props = $props();
|
|
22
30
|
|
|
31
|
+
let isReadOnly = $derived(readOnly || readonly);
|
|
32
|
+
|
|
23
33
|
let gridContainer = $state<HTMLDivElement | null>(null);
|
|
24
34
|
let resizingColId = $state<string | null>(null);
|
|
25
35
|
let resizeStartX = $state(0);
|
|
26
36
|
let resizeStartWidth = $state(0);
|
|
27
37
|
|
|
28
|
-
|
|
29
|
-
let activeRawValue = $derived.by(() => {
|
|
30
|
-
if (!sheetState.activeCell) return '';
|
|
31
|
-
const row = sheetState.document.rows[sheetState.activeCell.row];
|
|
32
|
-
const col = sheetState.document.columns[sheetState.activeCell.col];
|
|
33
|
-
if (!row || !col) return '';
|
|
34
|
-
return sheetState.getCell(row.id, col.id).raw;
|
|
35
|
-
});
|
|
38
|
+
|
|
36
39
|
|
|
37
40
|
function handleCellClick(rIdx: number, cIdx: number, e: MouseEvent) {
|
|
38
41
|
if (sheetState.editingCell && (sheetState.editingCell.row !== rIdx || sheetState.editingCell.col !== cIdx)) {
|
|
@@ -42,7 +45,7 @@
|
|
|
42
45
|
}
|
|
43
46
|
|
|
44
47
|
function handleCellDblClick(rIdx: number, cIdx: number) {
|
|
45
|
-
if (
|
|
48
|
+
if (isReadOnly) return;
|
|
46
49
|
const col = sheetState.document.columns[cIdx];
|
|
47
50
|
if (col?.readOnly) return;
|
|
48
51
|
sheetState.startEditing(rIdx, cIdx);
|
|
@@ -50,13 +53,11 @@
|
|
|
50
53
|
|
|
51
54
|
function handleKeyDown(e: KeyboardEvent) {
|
|
52
55
|
if (sheetState.editingCell) {
|
|
53
|
-
if (e.key === '
|
|
54
|
-
|
|
56
|
+
if (e.key === 'Escape') {
|
|
57
|
+
sheetState.cancelEditing();
|
|
58
|
+
} else if (e.key === 'Enter') {
|
|
55
59
|
sheetState.commitEditing();
|
|
56
60
|
sheetState.moveCursor('down');
|
|
57
|
-
} else if (e.key === 'Escape') {
|
|
58
|
-
e.preventDefault();
|
|
59
|
-
sheetState.cancelEditing();
|
|
60
61
|
} else if (e.key === 'Tab') {
|
|
61
62
|
e.preventDefault();
|
|
62
63
|
sheetState.commitEditing();
|
|
@@ -85,11 +86,11 @@
|
|
|
85
86
|
} else if (e.key === 'Enter') {
|
|
86
87
|
e.preventDefault();
|
|
87
88
|
const col = sheetState.document.columns[sheetState.activeCell.col];
|
|
88
|
-
if (!
|
|
89
|
+
if (!isReadOnly && !col?.readOnly) {
|
|
89
90
|
sheetState.startEditing();
|
|
90
91
|
}
|
|
91
92
|
} else if (e.key === 'Backspace' || e.key === 'Delete') {
|
|
92
|
-
if (
|
|
93
|
+
if (isReadOnly) return;
|
|
93
94
|
const row = sheetState.document.rows[sheetState.activeCell.row];
|
|
94
95
|
const col = sheetState.document.columns[sheetState.activeCell.col];
|
|
95
96
|
if (row && col && !col.readOnly) {
|
|
@@ -107,7 +108,7 @@
|
|
|
107
108
|
e.preventDefault();
|
|
108
109
|
const tsv = sheetState.exportToTsv();
|
|
109
110
|
navigator.clipboard?.writeText(tsv);
|
|
110
|
-
} else if (!
|
|
111
|
+
} else if (!isReadOnly && e.key.length === 1 && !e.ctrlKey && !e.metaKey && !e.altKey) {
|
|
111
112
|
// Direct typing into cell starts editing
|
|
112
113
|
const col = sheetState.document.columns[sheetState.activeCell.col];
|
|
113
114
|
if (!col?.readOnly) {
|
|
@@ -155,34 +156,16 @@
|
|
|
155
156
|
|
|
156
157
|
<div
|
|
157
158
|
bind:this={gridContainer}
|
|
158
|
-
class="flex flex-col h-full w-full overflow-hidden border border-border bg-background select-none outline-none text-foreground font-sans text-xs"
|
|
159
|
+
class="flex flex-col h-full w-full overflow-hidden border border-border bg-background select-none outline-none text-foreground font-sans text-xs {className}"
|
|
159
160
|
tabindex="0"
|
|
160
161
|
onkeydown={handleKeyDown}
|
|
161
162
|
role="grid"
|
|
162
163
|
aria-label="Spreadsheet"
|
|
163
164
|
>
|
|
164
165
|
<!-- Formula Bar -->
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
onChange={(val) => {
|
|
169
|
-
if (sheetState.activeCell) {
|
|
170
|
-
sheetState.draftValue = val;
|
|
171
|
-
}
|
|
172
|
-
}}
|
|
173
|
-
onCommit={(val) => {
|
|
174
|
-
if (sheetState.activeCell) {
|
|
175
|
-
const row = sheetState.document.rows[sheetState.activeCell.row];
|
|
176
|
-
const col = sheetState.document.columns[sheetState.activeCell.col];
|
|
177
|
-
if (row && col) {
|
|
178
|
-
sheetState.setCellValue(row.id, col.id, val);
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
}}
|
|
182
|
-
onCancel={() => {
|
|
183
|
-
sheetState.cancelEditing();
|
|
184
|
-
}}
|
|
185
|
-
/>
|
|
166
|
+
{#if showFormulaBar}
|
|
167
|
+
<FormulaBar {sheetState} />
|
|
168
|
+
{/if}
|
|
186
169
|
|
|
187
170
|
<!-- Main Scrollable Grid -->
|
|
188
171
|
<div class="relative flex-1 overflow-auto">
|
|
@@ -205,11 +188,13 @@
|
|
|
205
188
|
<span class="text-[10px] text-muted-foreground/70 font-mono font-normal">({col.key})</span>
|
|
206
189
|
</div>
|
|
207
190
|
<!-- Column Resize Handle -->
|
|
191
|
+
<!-- svelte-ignore a11y_no_noninteractive_element_interactions -->
|
|
208
192
|
<div
|
|
209
193
|
class="absolute right-0 top-0 bottom-0 w-1.5 cursor-col-resize hover:bg-primary/50 group-hover:bg-primary/20 z-10"
|
|
210
194
|
onmousedown={(e) => handleResizeStart(col.id, col.width || 130, e)}
|
|
211
195
|
role="separator"
|
|
212
196
|
aria-orientation="vertical"
|
|
197
|
+
tabindex="-1"
|
|
213
198
|
></div>
|
|
214
199
|
</th>
|
|
215
200
|
{/each}
|
|
@@ -252,7 +237,8 @@
|
|
|
252
237
|
|
|
253
238
|
/>
|
|
254
239
|
{:else if customCellRenderer}
|
|
255
|
-
{@
|
|
240
|
+
{@const cellArg = Object.assign({ row, col, cell }, cell)}
|
|
241
|
+
{@render (customCellRenderer as any)(cellArg, col, row)}
|
|
256
242
|
{:else}
|
|
257
243
|
<span class="truncate block {cell.error ? 'text-destructive font-semibold' : ''}">
|
|
258
244
|
{cell.error || (cell.value ?? '')}
|
|
@@ -128,6 +128,19 @@ export function createReactiveSpreadsheet(options: SpreadsheetControllerOptions
|
|
|
128
128
|
controller.setColumnWidth(colId, width);
|
|
129
129
|
doc = { ...controller.document };
|
|
130
130
|
},
|
|
131
|
+
loadDocument(document: SpreadsheetDocument) {
|
|
132
|
+
controller.loadDocument(document);
|
|
133
|
+
doc = { ...controller.document };
|
|
134
|
+
activeCell = controller.activeCell;
|
|
135
|
+
selectedRange = controller.selectedRange;
|
|
136
|
+
editingCell = controller.editingCell;
|
|
137
|
+
draftValue = controller.draftValue;
|
|
138
|
+
},
|
|
139
|
+
syncWithDataSource() {
|
|
140
|
+
controller.syncWithDataSource();
|
|
141
|
+
controller.recalculateAll();
|
|
142
|
+
doc = { ...controller.document };
|
|
143
|
+
},
|
|
131
144
|
registerDataSource(ds: SpreadsheetDataSource) {
|
|
132
145
|
controller.registerDataSource(ds);
|
|
133
146
|
doc = { ...controller.document };
|