@abraca/nuxt 2.35.1 → 2.37.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/module.d.mts +6 -0
- package/dist/module.json +1 -1
- package/dist/runtime/components/ADocPickModal.vue +1 -1
- package/dist/runtime/components/ADocSubPageList.d.vue.ts +46 -0
- package/dist/runtime/components/ADocSubPageList.vue +1006 -0
- package/dist/runtime/components/ADocSubPageList.vue.d.ts +46 -0
- package/dist/runtime/components/ADocumentTree.vue +3 -2
- package/dist/runtime/components/AEditor.d.vue.ts +9 -0
- package/dist/runtime/components/AEditor.vue +14 -2
- package/dist/runtime/components/AEditor.vue.d.ts +9 -0
- package/dist/runtime/components/AIconPicker.vue +27 -180
- package/dist/runtime/components/ANodePanel.d.vue.ts +8 -5
- package/dist/runtime/components/ANodePanel.vue +1 -1
- package/dist/runtime/components/ANodePanel.vue.d.ts +8 -5
- package/dist/runtime/components/AWindowLayer.vue +4 -2
- package/dist/runtime/components/aware/AMedia.d.vue.ts +1 -1
- package/dist/runtime/components/aware/AMedia.vue.d.ts +1 -1
- package/dist/runtime/components/docs/ADocsSearch.d.vue.ts +2 -2
- package/dist/runtime/components/docs/ADocsSearch.vue.d.ts +2 -2
- package/dist/runtime/components/editor/ADocSuggestMenu.vue +1 -1
- package/dist/runtime/components/editor/ALocationPickerPopover.vue +31 -16
- package/dist/runtime/components/renderers/ACalendarRenderer.d.vue.ts +1 -0
- package/dist/runtime/components/renderers/ACalendarRenderer.vue +309 -68
- package/dist/runtime/components/renderers/ACalendarRenderer.vue.d.ts +1 -0
- package/dist/runtime/components/renderers/AChecklistRenderer.vue +259 -40
- package/dist/runtime/components/renderers/ADashboardRenderer.vue +493 -89
- package/dist/runtime/components/renderers/AGraphRenderer.d.vue.ts +2 -0
- package/dist/runtime/components/renderers/AGraphRenderer.vue +2113 -576
- package/dist/runtime/components/renderers/AGraphRenderer.vue.d.ts +2 -0
- package/dist/runtime/components/renderers/AKanbanRenderer.vue +460 -86
- package/dist/runtime/components/renderers/AMapRenderer.d.vue.ts +7 -1
- package/dist/runtime/components/renderers/AMapRenderer.vue +999 -166
- package/dist/runtime/components/renderers/AMapRenderer.vue.d.ts +7 -1
- package/dist/runtime/components/renderers/AOutlineRenderer.d.vue.ts +2 -0
- package/dist/runtime/components/renderers/AOutlineRenderer.vue +285 -81
- package/dist/runtime/components/renderers/AOutlineRenderer.vue.d.ts +2 -0
- package/dist/runtime/components/renderers/AOverviewRenderer.vue +3 -2
- package/dist/runtime/components/renderers/ASheetsRenderer.client.vue +255 -87
- package/dist/runtime/components/renderers/ATimelineRenderer.d.vue.ts +1 -0
- package/dist/runtime/components/renderers/ATimelineRenderer.vue +224 -31
- package/dist/runtime/components/renderers/ATimelineRenderer.vue.d.ts +1 -0
- package/dist/runtime/components/renderers/calendar/ACalendarDayCell.d.vue.ts +8 -0
- package/dist/runtime/components/renderers/calendar/ACalendarDayCell.vue +12 -1
- package/dist/runtime/components/renderers/calendar/ACalendarDayCell.vue.d.ts +8 -0
- package/dist/runtime/components/renderers/calendar/ACalendarEventChip.d.vue.ts +10 -0
- package/dist/runtime/components/renderers/calendar/ACalendarEventChip.vue +15 -3
- package/dist/runtime/components/renderers/calendar/ACalendarEventChip.vue.d.ts +10 -0
- package/dist/runtime/components/renderers/calendar/ACalendarMonthView.d.vue.ts +14 -0
- package/dist/runtime/components/renderers/calendar/ACalendarMonthView.vue +6 -1
- package/dist/runtime/components/renderers/calendar/ACalendarMonthView.vue.d.ts +14 -0
- package/dist/runtime/components/renderers/sheets/ASheetsGrid.d.vue.ts +6 -6
- package/dist/runtime/components/renderers/sheets/ASheetsGrid.vue +25 -7
- package/dist/runtime/components/renderers/sheets/ASheetsGrid.vue.d.ts +6 -6
- package/dist/runtime/components/renderers/sheets/ASheetsMobileActionBar.d.vue.ts +2 -2
- package/dist/runtime/components/renderers/sheets/ASheetsMobileActionBar.vue.d.ts +2 -2
- package/dist/runtime/components/renderers/sheets/ASheetsToolbar.d.vue.ts +6 -0
- package/dist/runtime/components/renderers/sheets/ASheetsToolbar.vue +130 -23
- package/dist/runtime/components/renderers/sheets/ASheetsToolbar.vue.d.ts +6 -0
- package/dist/runtime/components/renderers/timeline/ATimelineAxis.vue +5 -3
- package/dist/runtime/components/renderers/timeline/ATimelineBar.vue +1 -1
- package/dist/runtime/components/renderers/timeline/ATimelineBarArea.d.vue.ts +0 -2
- package/dist/runtime/components/renderers/timeline/ATimelineBarArea.vue +16 -14
- package/dist/runtime/components/renderers/timeline/ATimelineBarArea.vue.d.ts +0 -2
- package/dist/runtime/components/renderers/timeline/ATimelineLabelPanel.vue +4 -2
- package/dist/runtime/composables/useCalendarView.js +34 -11
- package/dist/runtime/composables/useConnectionStatus.d.ts +1 -1
- package/dist/runtime/composables/useGraphReferenceEdges.d.ts +26 -0
- package/dist/runtime/composables/useGraphReferenceEdges.js +138 -0
- package/dist/runtime/composables/useGraphSim.d.ts +79 -0
- package/dist/runtime/composables/useGraphSim.js +231 -0
- package/dist/runtime/composables/useSheetsDependencyGraph.d.ts +26 -0
- package/dist/runtime/composables/useSheetsDependencyGraph.js +76 -0
- package/dist/runtime/composables/useSheetsFormulas.d.ts +4 -3
- package/dist/runtime/composables/useSheetsFormulas.js +575 -26
- package/dist/runtime/composables/useTimelineView.d.ts +4 -0
- package/dist/runtime/composables/useTimelineView.js +45 -11
- package/dist/runtime/composables/useWindowManager.d.ts +4 -0
- package/dist/runtime/composables/useWindowManager.js +11 -0
- package/dist/runtime/utils/dateField.d.ts +17 -0
- package/dist/runtime/utils/dateField.js +19 -0
- package/dist/runtime/utils/itemLabel.d.ts +27 -0
- package/dist/runtime/utils/itemLabel.js +8 -0
- package/dist/runtime/utils/localDate.d.ts +15 -0
- package/dist/runtime/utils/localDate.js +16 -0
- package/dist/runtime/utils/lucideIcons.d.ts +16 -10
- package/dist/runtime/utils/lucideIcons.js +1391 -69
- package/dist/runtime/utils/resolveDocColor.d.ts +7 -0
- package/dist/runtime/utils/resolveDocColor.js +32 -0
- package/dist/runtime/utils/resolveDocIcon.d.ts +10 -0
- package/dist/runtime/utils/resolveDocIcon.js +44 -0
- package/dist/runtime/utils/rowEdges.d.ts +22 -0
- package/dist/runtime/utils/rowEdges.js +29 -0
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script setup>
|
|
2
2
|
import { ref, computed, watch, inject, nextTick, onBeforeUnmount } from "vue";
|
|
3
|
-
import { useRuntimeConfig } from "#imports";
|
|
3
|
+
import { useRuntimeConfig, useToast } from "#imports";
|
|
4
4
|
import { useMediaQuery } from "@vueuse/core";
|
|
5
5
|
import { useRendererBase } from "../../composables/useRendererBase";
|
|
6
6
|
import { useNodePanel } from "../../composables/useNodePanel";
|
|
@@ -16,9 +16,11 @@ import {
|
|
|
16
16
|
extractCellRefs,
|
|
17
17
|
adjustFormulaRefs
|
|
18
18
|
} from "../../composables/useSheetsFormulas";
|
|
19
|
+
import { resolvePrecedents, computeRecalcOrder } from "../../composables/useSheetsDependencyGraph";
|
|
19
20
|
import { useDocumentPermissions } from "../../composables/useDocumentPermissions";
|
|
20
21
|
import { useAbracadabra } from "../../composables/useAbracadabra";
|
|
21
22
|
import { findMatches, replaceInCell } from "../../composables/useSheetsFind";
|
|
23
|
+
import { resolveValidation, validateValue } from "../../composables/useSheetsValidation";
|
|
22
24
|
import { DEFAULT_LOCALE } from "../../locale";
|
|
23
25
|
import ASheetsToolbar from "./sheets/ASheetsToolbar.vue";
|
|
24
26
|
import ASheetsGrid from "./sheets/ASheetsGrid.vue";
|
|
@@ -104,7 +106,7 @@ function getCellComputedValue(colIdx, rowIdx) {
|
|
|
104
106
|
if (entry.meta?.number !== void 0 && entry.meta.number !== null) return entry.meta.number;
|
|
105
107
|
const label = entry.label === "Untitled" ? "" : entry.label;
|
|
106
108
|
const num = Number(label);
|
|
107
|
-
return label !== "" && !isNaN(num) ? num : label;
|
|
109
|
+
return label !== "" && !Number.isNaN(num) ? num : label;
|
|
108
110
|
}
|
|
109
111
|
function makeFormulaCtx() {
|
|
110
112
|
return {
|
|
@@ -114,25 +116,36 @@ function makeFormulaCtx() {
|
|
|
114
116
|
evaluating: /* @__PURE__ */ new Set()
|
|
115
117
|
};
|
|
116
118
|
}
|
|
117
|
-
function recalcFormulas() {
|
|
118
|
-
const ctx = makeFormulaCtx();
|
|
119
|
+
function recalcFormulas(dirtyKeys = null) {
|
|
119
120
|
const cols = columns.value;
|
|
121
|
+
const formulaCells = [];
|
|
122
|
+
const byKey = /* @__PURE__ */ new Map();
|
|
120
123
|
for (let colIdx = 0; colIdx < cols.length; colIdx++) {
|
|
121
124
|
const cells = tree.childrenOf(cols[colIdx].id);
|
|
122
125
|
for (let rowIdx = 0; rowIdx < cells.length; rowIdx++) {
|
|
123
126
|
const cell = cells[rowIdx];
|
|
124
127
|
const formula = cell.meta?.formula;
|
|
125
128
|
if (!formula) continue;
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
ctx.evaluating.clear();
|
|
130
|
-
const display = formatFormulaResult(result);
|
|
131
|
-
if (cell.label !== display) tree.renameEntry(cell.id, display);
|
|
132
|
-
const numVal = result instanceof FormulaError ? void 0 : typeof result === "number" ? result : void 0;
|
|
133
|
-
if (cell.meta?.number !== numVal) tree.updateMeta(cell.id, { number: numVal });
|
|
129
|
+
const key = `${colIdx}:${rowIdx}`;
|
|
130
|
+
formulaCells.push({ key, colIdx, rowIdx, formula });
|
|
131
|
+
byKey.set(key, { cellId: cell.id, label: cell.label, number: cell.meta?.number, colIdx, rowIdx, formula });
|
|
134
132
|
}
|
|
135
133
|
}
|
|
134
|
+
if (formulaCells.length === 0) return;
|
|
135
|
+
const order = computeRecalcOrder(resolvePrecedents(formulaCells), dirtyKeys);
|
|
136
|
+
const ctx = makeFormulaCtx();
|
|
137
|
+
for (const key of order) {
|
|
138
|
+
const cell = byKey.get(key);
|
|
139
|
+
if (!cell) continue;
|
|
140
|
+
ctx.evaluating.clear();
|
|
141
|
+
ctx.evaluating.add(key);
|
|
142
|
+
const result = evaluateFormula(cell.formula, ctx);
|
|
143
|
+
ctx.evaluating.clear();
|
|
144
|
+
const display = formatFormulaResult(result);
|
|
145
|
+
if (cell.label !== display) tree.renameEntry(cell.cellId, display);
|
|
146
|
+
const numVal = result instanceof FormulaError ? void 0 : typeof result === "number" ? result : void 0;
|
|
147
|
+
if (cell.number !== numVal) tree.updateMeta(cell.cellId, { number: numVal });
|
|
148
|
+
}
|
|
136
149
|
}
|
|
137
150
|
function ensureCell(colIdx, rowIdx) {
|
|
138
151
|
let colsLive = childrenOfLive(null);
|
|
@@ -171,13 +184,20 @@ function writeCellValue(colIdx, rowIdx, value) {
|
|
|
171
184
|
const num = Number(value);
|
|
172
185
|
tree.updateMeta(cellId, {
|
|
173
186
|
formula: void 0,
|
|
174
|
-
number: value !== "" && !isNaN(num) ? num : void 0
|
|
187
|
+
number: value !== "" && !Number.isNaN(num) ? num : void 0
|
|
175
188
|
});
|
|
176
189
|
}
|
|
177
190
|
}
|
|
178
191
|
function commitCellValue(colIdx, rowIdx, value) {
|
|
192
|
+
if (value !== "" && !value.startsWith("=")) {
|
|
193
|
+
const v = resolveValidation(getCellEntry(colIdx, rowIdx)?.meta, columns.value[colIdx]?.meta);
|
|
194
|
+
if (v?.reject && !validateValue(value, v)) {
|
|
195
|
+
toast.add({ title: locale.value.validationRejected ?? "Value rejected by data validation", icon: "i-lucide-shield-x", color: "warning" });
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
179
199
|
writeCellValue(colIdx, rowIdx, value);
|
|
180
|
-
recalcFormulas();
|
|
200
|
+
recalcFormulas(/* @__PURE__ */ new Set([`${colIdx}:${rowIdx}`]));
|
|
181
201
|
stopUndoCapturing();
|
|
182
202
|
}
|
|
183
203
|
function clearCellValue(colIdx, rowIdx) {
|
|
@@ -189,9 +209,10 @@ function clearCellValue(colIdx, rowIdx) {
|
|
|
189
209
|
}
|
|
190
210
|
function clearCell(colIdx, rowIdx) {
|
|
191
211
|
clearCellValue(colIdx, rowIdx);
|
|
192
|
-
recalcFormulas();
|
|
212
|
+
recalcFormulas(/* @__PURE__ */ new Set([`${colIdx}:${rowIdx}`]));
|
|
193
213
|
stopUndoCapturing();
|
|
194
214
|
}
|
|
215
|
+
const toast = useToast();
|
|
195
216
|
function transact(fn) {
|
|
196
217
|
const doc = rootDoc.value;
|
|
197
218
|
if (doc) doc.transact(fn);
|
|
@@ -321,6 +342,45 @@ const cellDisplayValue = computed(() => {
|
|
|
321
342
|
if (entry?.meta?.formula) return `=${entry.meta.formula}`;
|
|
322
343
|
return getCellValue(selection.activeCell.value.colIdx, selection.activeCell.value.rowIdx);
|
|
323
344
|
});
|
|
345
|
+
const selectionStats = computed(() => {
|
|
346
|
+
const range = selection.selectionRange.value;
|
|
347
|
+
const ac = selection.activeCell.value;
|
|
348
|
+
if (!range || !ac) return null;
|
|
349
|
+
const startCol = Math.min(range.startCol, range.endCol);
|
|
350
|
+
const endCol = Math.max(range.startCol, range.endCol);
|
|
351
|
+
const startRow = Math.min(range.startRow, range.endRow);
|
|
352
|
+
const endRow = Math.max(range.startRow, range.endRow);
|
|
353
|
+
if (startCol === endCol && startRow === endRow) return null;
|
|
354
|
+
let count = 0;
|
|
355
|
+
let numCount = 0;
|
|
356
|
+
let sum = 0;
|
|
357
|
+
let min = Infinity;
|
|
358
|
+
let max = -Infinity;
|
|
359
|
+
for (let c = startCol; c <= endCol; c++) {
|
|
360
|
+
for (let r = startRow; r <= endRow; r++) {
|
|
361
|
+
const v = getCellComputedValue(c, r);
|
|
362
|
+
const raw = getCellValue(c, r);
|
|
363
|
+
if (raw !== "") count++;
|
|
364
|
+
if (typeof v === "number" && !Number.isNaN(v)) {
|
|
365
|
+
numCount++;
|
|
366
|
+
sum += v;
|
|
367
|
+
if (v < min) min = v;
|
|
368
|
+
if (v > max) max = v;
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
return {
|
|
373
|
+
count,
|
|
374
|
+
numCount,
|
|
375
|
+
sum,
|
|
376
|
+
avg: numCount ? sum / numCount : 0,
|
|
377
|
+
min: numCount ? min : 0,
|
|
378
|
+
max: numCount ? max : 0
|
|
379
|
+
};
|
|
380
|
+
});
|
|
381
|
+
function fmtStat(n) {
|
|
382
|
+
return String(Math.round(n * 1e10) / 1e10);
|
|
383
|
+
}
|
|
324
384
|
function getSelectionBounds() {
|
|
325
385
|
const range = selection.normalizedRange.value;
|
|
326
386
|
const ac = selection.activeCell.value;
|
|
@@ -368,8 +428,8 @@ function toggleFormat(key) {
|
|
|
368
428
|
}
|
|
369
429
|
const selectionFormats = computed(() => {
|
|
370
430
|
const bounds = getSelectionBounds();
|
|
371
|
-
if (!bounds) return { bold: false, italic: false, align: void 0, textColor: void 0, bgColor: void 0, numberFormat: void 0 };
|
|
372
|
-
const keys = ["bold", "italic", "align", "textColor", "bgColor", "numberFormat"];
|
|
431
|
+
if (!bounds) return { bold: false, italic: false, align: void 0, textColor: void 0, bgColor: void 0, numberFormat: void 0, numberDecimals: void 0, numberCurrency: void 0, numberThousands: void 0, numberNegativeRed: void 0 };
|
|
432
|
+
const keys = ["bold", "italic", "align", "textColor", "bgColor", "numberFormat", "numberDecimals", "numberCurrency", "numberThousands", "numberNegativeRed"];
|
|
373
433
|
const common = {};
|
|
374
434
|
const first = {};
|
|
375
435
|
let isFirst = true;
|
|
@@ -392,7 +452,11 @@ const selectionFormats = computed(() => {
|
|
|
392
452
|
align: common.align,
|
|
393
453
|
textColor: common.textColor,
|
|
394
454
|
bgColor: common.bgColor,
|
|
395
|
-
numberFormat: common.numberFormat
|
|
455
|
+
numberFormat: common.numberFormat,
|
|
456
|
+
numberDecimals: common.numberDecimals,
|
|
457
|
+
numberCurrency: common.numberCurrency,
|
|
458
|
+
numberThousands: common.numberThousands,
|
|
459
|
+
numberNegativeRed: common.numberNegativeRed
|
|
396
460
|
};
|
|
397
461
|
});
|
|
398
462
|
const selectionBold = computed(() => selectionFormats.value.bold);
|
|
@@ -401,6 +465,10 @@ const selectionAlign = computed(() => selectionFormats.value.align);
|
|
|
401
465
|
const selectionTextColor = computed(() => selectionFormats.value.textColor);
|
|
402
466
|
const selectionBgColor = computed(() => selectionFormats.value.bgColor);
|
|
403
467
|
const selectionNumberFormat = computed(() => selectionFormats.value.numberFormat);
|
|
468
|
+
const selectionNumberDecimals = computed(() => selectionFormats.value.numberDecimals);
|
|
469
|
+
const selectionNumberCurrency = computed(() => selectionFormats.value.numberCurrency);
|
|
470
|
+
const selectionNumberThousands = computed(() => selectionFormats.value.numberThousands);
|
|
471
|
+
const selectionNumberNegativeRed = computed(() => selectionFormats.value.numberNegativeRed);
|
|
404
472
|
const formulaRefMode = computed(
|
|
405
473
|
() => selection.editMode.value && selection.editValue.value.startsWith("=")
|
|
406
474
|
);
|
|
@@ -474,7 +542,7 @@ function orderBetween(list, targetIdx) {
|
|
|
474
542
|
return (prev.order + next.order) / 2;
|
|
475
543
|
}
|
|
476
544
|
function relabelColumns() {
|
|
477
|
-
const cols =
|
|
545
|
+
const cols = childrenOfLive(null);
|
|
478
546
|
for (let i = 0; i < cols.length; i++) {
|
|
479
547
|
const expected = sheetsView.indexToColLetter(i);
|
|
480
548
|
if (cols[i].label !== expected) {
|
|
@@ -482,6 +550,10 @@ function relabelColumns() {
|
|
|
482
550
|
}
|
|
483
551
|
}
|
|
484
552
|
}
|
|
553
|
+
function afterStructuralChange() {
|
|
554
|
+
recalcFormulas();
|
|
555
|
+
stopUndoCapturing();
|
|
556
|
+
}
|
|
485
557
|
function insertRowAt(rowIdx) {
|
|
486
558
|
transact(() => {
|
|
487
559
|
for (const col of columns.value) {
|
|
@@ -491,17 +563,19 @@ function insertRowAt(rowIdx) {
|
|
|
491
563
|
tree.moveEntry(id, col.id, order);
|
|
492
564
|
}
|
|
493
565
|
});
|
|
566
|
+
afterStructuralChange();
|
|
494
567
|
}
|
|
495
568
|
function insertColAt(colIdx) {
|
|
496
569
|
transact(() => {
|
|
497
570
|
const cols = columns.value;
|
|
498
571
|
const order = orderBetween(cols, colIdx);
|
|
499
572
|
tree.createChild(null, sheetsView.indexToColLetter(colIdx));
|
|
500
|
-
const newCols =
|
|
573
|
+
const newCols = childrenOfLive(null);
|
|
501
574
|
const created = newCols[newCols.length - 1];
|
|
502
575
|
if (created) tree.moveEntry(created.id, null, order);
|
|
503
576
|
relabelColumns();
|
|
504
577
|
});
|
|
578
|
+
afterStructuralChange();
|
|
505
579
|
}
|
|
506
580
|
function deleteColumnAt(colIdx) {
|
|
507
581
|
const col = columns.value[colIdx];
|
|
@@ -510,6 +584,7 @@ function deleteColumnAt(colIdx) {
|
|
|
510
584
|
tree.deleteEntry(col.id);
|
|
511
585
|
relabelColumns();
|
|
512
586
|
});
|
|
587
|
+
afterStructuralChange();
|
|
513
588
|
}
|
|
514
589
|
function deleteRowAt(rowIdx) {
|
|
515
590
|
transact(() => {
|
|
@@ -519,80 +594,118 @@ function deleteRowAt(rowIdx) {
|
|
|
519
594
|
if (cell) tree.deleteEntry(cell.id);
|
|
520
595
|
}
|
|
521
596
|
});
|
|
597
|
+
afterStructuralChange();
|
|
522
598
|
}
|
|
523
599
|
const fillTargetRow = ref(null);
|
|
524
|
-
const
|
|
525
|
-
|
|
526
|
-
if (target === null) return null;
|
|
600
|
+
const fillTargetCol = ref(null);
|
|
601
|
+
function fillSourceBounds() {
|
|
527
602
|
const range = selection.normalizedRange.value;
|
|
528
603
|
const ac = selection.activeCell.value;
|
|
529
604
|
if (!ac) return null;
|
|
530
|
-
const startCol = range?.startCol ?? ac.colIdx;
|
|
531
|
-
const endCol = range?.endCol ?? ac.colIdx;
|
|
532
|
-
const srcStartRow = range?.startRow ?? ac.rowIdx;
|
|
533
|
-
const srcEndRow = range?.endRow ?? ac.rowIdx;
|
|
534
|
-
if (target >= srcStartRow && target <= srcEndRow) return null;
|
|
535
|
-
const fillDown = target > srcEndRow;
|
|
536
605
|
return {
|
|
537
|
-
startCol,
|
|
538
|
-
endCol,
|
|
539
|
-
|
|
540
|
-
|
|
606
|
+
startCol: range?.startCol ?? ac.colIdx,
|
|
607
|
+
endCol: range?.endCol ?? ac.colIdx,
|
|
608
|
+
startRow: range?.startRow ?? ac.rowIdx,
|
|
609
|
+
endRow: range?.endRow ?? ac.rowIdx
|
|
610
|
+
};
|
|
611
|
+
}
|
|
612
|
+
function fillDirection(b, tr, tc) {
|
|
613
|
+
const rowOut = tr < b.startRow ? b.startRow - tr : tr > b.endRow ? tr - b.endRow : 0;
|
|
614
|
+
const colOut = tc < b.startCol ? b.startCol - tc : tc > b.endCol ? tc - b.endCol : 0;
|
|
615
|
+
if (rowOut === 0 && colOut === 0) return null;
|
|
616
|
+
return colOut > rowOut ? "h" : "v";
|
|
617
|
+
}
|
|
618
|
+
const fillPreview = computed(() => {
|
|
619
|
+
const tr = fillTargetRow.value;
|
|
620
|
+
const tc = fillTargetCol.value;
|
|
621
|
+
if (tr === null || tc === null) return null;
|
|
622
|
+
const b = fillSourceBounds();
|
|
623
|
+
if (!b) return null;
|
|
624
|
+
const axis = fillDirection(b, tr, tc);
|
|
625
|
+
if (!axis) return null;
|
|
626
|
+
if (axis === "v") {
|
|
627
|
+
const down = tr > b.endRow;
|
|
628
|
+
return {
|
|
629
|
+
fromCol: b.startCol,
|
|
630
|
+
toCol: b.endCol,
|
|
631
|
+
fromRow: down ? b.endRow + 1 : tr,
|
|
632
|
+
toRow: down ? tr : b.startRow - 1
|
|
633
|
+
};
|
|
634
|
+
}
|
|
635
|
+
const right = tc > b.endCol;
|
|
636
|
+
return {
|
|
637
|
+
fromRow: b.startRow,
|
|
638
|
+
toRow: b.endRow,
|
|
639
|
+
fromCol: right ? b.endCol + 1 : tc,
|
|
640
|
+
toCol: right ? tc : b.startCol - 1
|
|
541
641
|
};
|
|
542
642
|
});
|
|
543
|
-
function onFillDragStart(rowIdx) {
|
|
643
|
+
function onFillDragStart(rowIdx, colIdx) {
|
|
544
644
|
fillTargetRow.value = rowIdx;
|
|
645
|
+
fillTargetCol.value = colIdx;
|
|
545
646
|
}
|
|
546
|
-
function onFillDragMove(rowIdx) {
|
|
647
|
+
function onFillDragMove(rowIdx, colIdx) {
|
|
547
648
|
fillTargetRow.value = rowIdx;
|
|
649
|
+
fillTargetCol.value = colIdx;
|
|
548
650
|
}
|
|
549
651
|
function onFillDragEnd() {
|
|
550
|
-
const
|
|
652
|
+
const tr = fillTargetRow.value;
|
|
653
|
+
const tc = fillTargetCol.value;
|
|
551
654
|
fillTargetRow.value = null;
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
const
|
|
555
|
-
if (!
|
|
556
|
-
const
|
|
557
|
-
|
|
558
|
-
const srcStartRow = range?.startRow ?? ac.rowIdx;
|
|
559
|
-
const srcEndRow = range?.endRow ?? ac.rowIdx;
|
|
560
|
-
const srcLen = srcEndRow - srcStartRow + 1;
|
|
561
|
-
if (target <= srcEndRow && target >= srcStartRow) return;
|
|
655
|
+
fillTargetCol.value = null;
|
|
656
|
+
if (tr === null || tc === null) return;
|
|
657
|
+
const b = fillSourceBounds();
|
|
658
|
+
if (!b) return;
|
|
659
|
+
const axis = fillDirection(b, tr, tc);
|
|
660
|
+
if (!axis) return;
|
|
562
661
|
transact(() => {
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
const
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
const
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
}
|
|
586
|
-
}
|
|
587
|
-
writeCellValue(c, r, srcValue);
|
|
588
|
-
} else {
|
|
589
|
-
writeCellValue(c, r, srcValue);
|
|
662
|
+
if (axis === "v") {
|
|
663
|
+
const srcLen = b.endRow - b.startRow + 1;
|
|
664
|
+
const down = tr > b.endRow;
|
|
665
|
+
const fillStart = down ? b.endRow + 1 : tr;
|
|
666
|
+
const fillEnd = down ? tr : b.startRow - 1;
|
|
667
|
+
for (let r = fillStart; r <= fillEnd; r++) {
|
|
668
|
+
const srcRowIdx = b.startRow + ((r - fillStart) % srcLen + srcLen) % srcLen;
|
|
669
|
+
const rowOffset = r - srcRowIdx;
|
|
670
|
+
for (let c = b.startCol; c <= b.endCol; c++) {
|
|
671
|
+
fillCell(c, r, c, srcRowIdx, 0, rowOffset, srcLen, "v", b, r);
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
} else {
|
|
675
|
+
const srcLen = b.endCol - b.startCol + 1;
|
|
676
|
+
const right = tc > b.endCol;
|
|
677
|
+
const fillStart = right ? b.endCol + 1 : tc;
|
|
678
|
+
const fillEnd = right ? tc : b.startCol - 1;
|
|
679
|
+
for (let c = fillStart; c <= fillEnd; c++) {
|
|
680
|
+
const srcColIdx = b.startCol + ((c - fillStart) % srcLen + srcLen) % srcLen;
|
|
681
|
+
const colOffset = c - srcColIdx;
|
|
682
|
+
for (let r = b.startRow; r <= b.endRow; r++) {
|
|
683
|
+
fillCell(c, r, srcColIdx, r, colOffset, 0, srcLen, "h", b, c);
|
|
590
684
|
}
|
|
591
685
|
}
|
|
592
686
|
}
|
|
593
|
-
recalcFormulas();
|
|
594
687
|
});
|
|
595
|
-
|
|
688
|
+
afterStructuralChange();
|
|
689
|
+
}
|
|
690
|
+
function fillCell(destCol, destRow, srcCol, srcRow, dCol, dRow, srcLen, axis, b, series) {
|
|
691
|
+
const srcEntry = getCellEntry(srcCol, srcRow);
|
|
692
|
+
const srcFormula = srcEntry?.meta?.formula;
|
|
693
|
+
const srcValue = getCellValue(srcCol, srcRow);
|
|
694
|
+
if (srcFormula) {
|
|
695
|
+
writeCellValue(destCol, destRow, `=${adjustFormulaRefs(srcFormula, dCol, dRow)}`);
|
|
696
|
+
return;
|
|
697
|
+
}
|
|
698
|
+
if (srcLen >= 2 && srcValue !== "" && !Number.isNaN(Number(srcValue))) {
|
|
699
|
+
const first = Number(axis === "v" ? getCellValue(srcCol, b.startRow) : getCellValue(b.startCol, srcRow));
|
|
700
|
+
const last = Number(axis === "v" ? getCellValue(srcCol, b.endRow) : getCellValue(b.endCol, srcRow));
|
|
701
|
+
const step = (last - first) / (srcLen - 1);
|
|
702
|
+
const base = axis === "v" ? b.startRow : b.startCol;
|
|
703
|
+
if (step !== 0) {
|
|
704
|
+
writeCellValue(destCol, destRow, String(first + step * (series - base)));
|
|
705
|
+
return;
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
writeCellValue(destCol, destRow, srcValue);
|
|
596
709
|
}
|
|
597
710
|
function autoFitColumn(colId) {
|
|
598
711
|
const colIdx = columns.value.findIndex((c) => c.id === colId);
|
|
@@ -614,17 +727,32 @@ function sortByColumn(colIdx, ascending) {
|
|
|
614
727
|
const sortCol = columns.value[colIdx];
|
|
615
728
|
if (!sortCol) return;
|
|
616
729
|
transact(() => {
|
|
617
|
-
const
|
|
618
|
-
|
|
730
|
+
const cols = childrenOfLive(null);
|
|
731
|
+
let rowCount = 0;
|
|
732
|
+
for (const col of cols) {
|
|
733
|
+
rowCount = Math.max(rowCount, childrenOfLive(col.id).length);
|
|
734
|
+
}
|
|
735
|
+
for (const col of cols) {
|
|
736
|
+
const len = childrenOfLive(col.id).length;
|
|
737
|
+
for (let i = len; i < rowCount; i++) tree.createChild(col.id, "");
|
|
738
|
+
}
|
|
739
|
+
const sortCells = childrenOfLive(sortCol.id);
|
|
740
|
+
const indices = sortCells.map((cell, i) => ({
|
|
741
|
+
idx: i,
|
|
742
|
+
val: cell.label === "Untitled" ? "" : cell.label
|
|
743
|
+
}));
|
|
619
744
|
indices.sort((a, b) => {
|
|
745
|
+
if (a.val === "" || b.val === "") {
|
|
746
|
+
return a.val === b.val ? 0 : a.val === "" ? 1 : -1;
|
|
747
|
+
}
|
|
620
748
|
const na = Number(a.val);
|
|
621
749
|
const nb = Number(b.val);
|
|
622
|
-
const bothNum = !isNaN(na) &&
|
|
750
|
+
const bothNum = !Number.isNaN(na) && !Number.isNaN(nb);
|
|
623
751
|
const cmp = bothNum ? na - nb : a.val.localeCompare(b.val);
|
|
624
752
|
return ascending ? cmp : -cmp;
|
|
625
753
|
});
|
|
626
|
-
for (const col of
|
|
627
|
-
const cells =
|
|
754
|
+
for (const col of cols) {
|
|
755
|
+
const cells = childrenOfLive(col.id);
|
|
628
756
|
let order = 1e3;
|
|
629
757
|
for (const { idx } of indices) {
|
|
630
758
|
const cell = cells[idx];
|
|
@@ -632,8 +760,8 @@ function sortByColumn(colIdx, ascending) {
|
|
|
632
760
|
order += 1e3;
|
|
633
761
|
}
|
|
634
762
|
}
|
|
635
|
-
recalcFormulas();
|
|
636
763
|
});
|
|
764
|
+
afterStructuralChange();
|
|
637
765
|
}
|
|
638
766
|
const cellContextItems = computed(() => {
|
|
639
767
|
if (!canWrite.value) return [];
|
|
@@ -667,6 +795,7 @@ const cellContextItems = computed(() => {
|
|
|
667
795
|
});
|
|
668
796
|
function colHeaderContextItems(colIdx) {
|
|
669
797
|
if (!canWrite.value) return [];
|
|
798
|
+
const fmtLabels = locale.value;
|
|
670
799
|
return [
|
|
671
800
|
[
|
|
672
801
|
{ label: locale.value.sortAsc, icon: "i-lucide-arrow-up-a-z", onSelect: () => sortByColumn(colIdx, true) },
|
|
@@ -674,15 +803,30 @@ function colHeaderContextItems(colIdx) {
|
|
|
674
803
|
],
|
|
675
804
|
[
|
|
676
805
|
{ label: locale.value.renameColumn, icon: "i-lucide-pencil", onSelect: () => {
|
|
677
|
-
} }
|
|
806
|
+
} },
|
|
807
|
+
{
|
|
808
|
+
label: fmtLabels.columnFormat ?? "Column format",
|
|
809
|
+
icon: "i-lucide-hash",
|
|
810
|
+
children: [
|
|
811
|
+
{ label: fmtLabels.formatGeneral ?? "General", icon: "i-lucide-hash", onSelect: () => setColumnFormat(colIdx, void 0) },
|
|
812
|
+
{ label: fmtLabels.formatNumber ?? "Number", icon: "i-lucide-calculator", onSelect: () => setColumnFormat(colIdx, "number") },
|
|
813
|
+
{ label: fmtLabels.formatCurrency ?? "Currency", icon: "i-lucide-dollar-sign", onSelect: () => setColumnFormat(colIdx, "currency") },
|
|
814
|
+
{ label: fmtLabels.formatAccounting ?? "Accounting", icon: "i-lucide-landmark", onSelect: () => setColumnFormat(colIdx, "accounting") },
|
|
815
|
+
{ label: fmtLabels.formatPercent ?? "Percent", icon: "i-lucide-percent", onSelect: () => setColumnFormat(colIdx, "percent") },
|
|
816
|
+
{ label: fmtLabels.formatScientific ?? "Scientific", icon: "i-lucide-flask-conical", onSelect: () => setColumnFormat(colIdx, "scientific") },
|
|
817
|
+
{ label: fmtLabels.formatDate ?? "Date", icon: "i-lucide-calendar", onSelect: () => setColumnFormat(colIdx, "date") },
|
|
818
|
+
{ label: fmtLabels.formatTime ?? "Time", icon: "i-lucide-clock", onSelect: () => setColumnFormat(colIdx, "time") },
|
|
819
|
+
{ label: fmtLabels.formatDatetime ?? "Date & time", icon: "i-lucide-calendar-clock", onSelect: () => setColumnFormat(colIdx, "datetime") }
|
|
820
|
+
]
|
|
821
|
+
}
|
|
678
822
|
],
|
|
679
823
|
[
|
|
680
824
|
{ label: locale.value.insertColumnLeft, icon: "i-lucide-arrow-left", onSelect: () => insertColAt(colIdx) },
|
|
681
825
|
{ label: locale.value.insertColumnRight, icon: "i-lucide-arrow-right", onSelect: () => insertColAt(colIdx + 1) }
|
|
682
826
|
],
|
|
683
827
|
[
|
|
684
|
-
{ label: "Conditional formatting\u2026", icon: "i-lucide-palette", onSelect: () => openColumnConditional(colIdx) },
|
|
685
|
-
{ label: "Data validation\u2026", icon: "i-lucide-list-checks", onSelect: () => openColumnValidation(colIdx) }
|
|
828
|
+
{ label: fmtLabels.conditionalFormatting ?? "Conditional formatting\u2026", icon: "i-lucide-palette", onSelect: () => openColumnConditional(colIdx) },
|
|
829
|
+
{ label: fmtLabels.dataValidation ?? "Data validation\u2026", icon: "i-lucide-list-checks", onSelect: () => openColumnValidation(colIdx) }
|
|
686
830
|
],
|
|
687
831
|
[
|
|
688
832
|
{ label: locale.value.deleteColumn, icon: "i-lucide-trash-2", color: "error", onSelect: () => deleteColumnAt(colIdx) }
|
|
@@ -720,6 +864,12 @@ function renameColumn(colId, label) {
|
|
|
720
864
|
function resizeColumn(colId, width) {
|
|
721
865
|
sheetsView.setColWidth(colId, width);
|
|
722
866
|
}
|
|
867
|
+
function setColumnFormat(colIdx, format) {
|
|
868
|
+
const col = columns.value[colIdx];
|
|
869
|
+
if (!col) return;
|
|
870
|
+
tree.updateMeta(col.id, { numberFormat: format });
|
|
871
|
+
stopUndoCapturing();
|
|
872
|
+
}
|
|
723
873
|
function onStartEditFromBar() {
|
|
724
874
|
if (selection.activeCell.value) selection.startEdit(true);
|
|
725
875
|
}
|
|
@@ -743,9 +893,8 @@ const findMatchList = computed(() => {
|
|
|
743
893
|
return findMatches(findQuery.value, findCellText, columns.value.length, dataRowCount.value, findOptions.value);
|
|
744
894
|
});
|
|
745
895
|
watch(findMatchList, (list) => {
|
|
746
|
-
if (!list.length)
|
|
747
|
-
|
|
748
|
-
} else if (findIndex.value < 0 || findIndex.value >= list.length) findIndex.value = 0;
|
|
896
|
+
if (!list.length) findIndex.value = -1;
|
|
897
|
+
else if (findIndex.value < 0 || findIndex.value >= list.length) findIndex.value = 0;
|
|
749
898
|
});
|
|
750
899
|
function gotoMatch(i) {
|
|
751
900
|
const list = findMatchList.value;
|
|
@@ -865,6 +1014,10 @@ defineExpose({ connectedUsers });
|
|
|
865
1014
|
:selection-text-color="selectionTextColor"
|
|
866
1015
|
:selection-bg-color="selectionBgColor"
|
|
867
1016
|
:selection-number-format="selectionNumberFormat"
|
|
1017
|
+
:selection-number-decimals="selectionNumberDecimals"
|
|
1018
|
+
:selection-number-currency="selectionNumberCurrency"
|
|
1019
|
+
:selection-number-thousands="selectionNumberThousands"
|
|
1020
|
+
:selection-number-negative-red="selectionNumberNegativeRed"
|
|
868
1021
|
:labels="labels"
|
|
869
1022
|
@add-column="addColumn"
|
|
870
1023
|
@add-row="addRow"
|
|
@@ -878,6 +1031,7 @@ defineExpose({ connectedUsers });
|
|
|
878
1031
|
@set-bg-color="(c) => applyFormatting('bgColor', c)"
|
|
879
1032
|
@set-align="(a) => applyFormatting('align', a)"
|
|
880
1033
|
@set-number-format="(f) => applyFormatting('numberFormat', f)"
|
|
1034
|
+
@set-format-option="(k, v) => applyFormatting(k, v)"
|
|
881
1035
|
@open-find="openFind"
|
|
882
1036
|
@open-conditional="openConditional"
|
|
883
1037
|
@open-validation="openValidation"
|
|
@@ -983,6 +1137,20 @@ defineExpose({ connectedUsers });
|
|
|
983
1137
|
@cut="clipboard.onCut"
|
|
984
1138
|
/>
|
|
985
1139
|
|
|
1140
|
+
<!-- Selection status bar (Sum / Average / Count / Min / Max) — desktop only -->
|
|
1141
|
+
<div
|
|
1142
|
+
v-if="selectionStats"
|
|
1143
|
+
class="hidden sm:flex items-center justify-end gap-4 px-4 h-7 shrink-0 border-t border-(--ui-border) bg-elevated/40 text-xs text-(--ui-text-muted) tabular-nums select-none"
|
|
1144
|
+
>
|
|
1145
|
+
<template v-if="selectionStats.numCount > 0">
|
|
1146
|
+
<span>Sum: <span class="text-(--ui-text) font-medium">{{ fmtStat(selectionStats.sum) }}</span></span>
|
|
1147
|
+
<span>Avg: <span class="text-(--ui-text) font-medium">{{ fmtStat(selectionStats.avg) }}</span></span>
|
|
1148
|
+
<span>Min: <span class="text-(--ui-text) font-medium">{{ fmtStat(selectionStats.min) }}</span></span>
|
|
1149
|
+
<span>Max: <span class="text-(--ui-text) font-medium">{{ fmtStat(selectionStats.max) }}</span></span>
|
|
1150
|
+
</template>
|
|
1151
|
+
<span>Count: <span class="text-(--ui-text) font-medium">{{ selectionStats.count }}</span></span>
|
|
1152
|
+
</div>
|
|
1153
|
+
|
|
986
1154
|
<ASheetsMobileActionBar
|
|
987
1155
|
:visible="isMobile && !!selection.activeCell.value && !selection.editMode.value && columns.length > 0"
|
|
988
1156
|
:editable="canWrite"
|
|
@@ -3,6 +3,7 @@ import type { AbracadabraLocale } from '../../locale.js';
|
|
|
3
3
|
type __VLS_Props = RendererBaseProps & {
|
|
4
4
|
labels?: Partial<AbracadabraLocale['renderers']['timeline']>;
|
|
5
5
|
editable?: boolean;
|
|
6
|
+
followingUser?: string | null;
|
|
6
7
|
};
|
|
7
8
|
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {
|
|
8
9
|
connectedUsers: import("vue").ComputedRef<{
|