@casualoffice/sheets 0.18.0 → 0.20.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/{api-DJhuCjhn.d.cts → api-cyO4EA4_.d.cts} +1 -1
- package/dist/{api-DJhuCjhn.d.ts → api-cyO4EA4_.d.ts} +1 -1
- package/dist/{attachCollab-BmCRT4V_.d.ts → attachCollab-BT4fVzxP.d.ts} +1 -1
- package/dist/{attachCollab-DIUQCCrq.d.cts → attachCollab-DHjb5XYK.d.cts} +1 -1
- package/dist/chrome.cjs +60 -3
- package/dist/chrome.cjs.map +1 -1
- package/dist/chrome.d.cts +3 -3
- package/dist/chrome.d.ts +3 -3
- package/dist/chrome.js +60 -3
- package/dist/chrome.js.map +1 -1
- package/dist/collab.d.cts +2 -2
- package/dist/collab.d.ts +2 -2
- package/dist/embed/embed-runtime.js +205 -161
- package/dist/{extensions-DZnqTEN2.d.ts → extensions-Cni7mbEm.d.ts} +1 -1
- package/dist/{extensions-FFqdLpk_.d.cts → extensions-DMmPnIYB.d.cts} +1 -1
- package/dist/index.cjs +6424 -1559
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +6409 -1530
- package/dist/index.js.map +1 -1
- package/dist/sheets.cjs +5426 -561
- package/dist/sheets.cjs.map +1 -1
- package/dist/sheets.d.cts +5 -5
- package/dist/sheets.d.ts +5 -5
- package/dist/sheets.js +5415 -536
- package/dist/sheets.js.map +1 -1
- package/package.json +8 -7
- package/src/charts/ChartContextMenu.tsx +264 -0
- package/src/charts/ChartLayer.tsx +333 -0
- package/src/charts/ChartOverlay.tsx +293 -0
- package/src/charts/ChartsPanel.tsx +232 -0
- package/src/charts/FormatChartDialog.tsx +419 -0
- package/src/charts/InsertChartDialog.tsx +478 -0
- package/src/charts/build-option.ts +476 -0
- package/src/charts/charts-context.tsx +205 -0
- package/src/charts/echarts-init.ts +58 -0
- package/src/charts/hit-test.ts +130 -0
- package/src/charts/insert-chart.ts +106 -0
- package/src/charts/naming.ts +38 -0
- package/src/charts/render-to-png.ts +117 -0
- package/src/charts/resources.ts +108 -0
- package/src/charts/types.ts +239 -0
- package/src/charts/univer-dom.ts +102 -0
- package/src/chrome/CommentsPanel.tsx +418 -0
- package/src/chrome/HistoryPanel.tsx +304 -0
- package/src/chrome/InsertPivotDialog.tsx +74 -2
- package/src/chrome/PanelHost.tsx +56 -0
- package/src/chrome/PanelRail.tsx +90 -0
- package/src/chrome/PivotFieldsPanel.tsx +1021 -0
- package/src/chrome/TablesPanel.tsx +283 -0
- package/src/chrome/Toolbar.tsx +7 -1
- package/src/chrome/panel-context.tsx +55 -0
- package/src/chrome/panel-registry.ts +48 -0
- package/src/chrome/panel-shell.tsx +151 -0
- package/src/pivots/apply.ts +139 -0
- package/src/pivots/compute.ts +604 -0
- package/src/pivots/fields-model.ts +267 -0
- package/src/pivots/types.ts +137 -0
- package/src/sheets/CasualSheets.tsx +61 -35
- package/src/sheets/api.ts +37 -2
|
@@ -225,6 +225,6 @@ interface CasualSheetsAPI {
|
|
|
225
225
|
* to {@link CasualSheetsAPI} for hosts, while the `<CasualSheets>` wrapper casts
|
|
226
226
|
* back to reach `emit` / `markDirty`.
|
|
227
227
|
*/
|
|
228
|
-
declare function createCasualSheetsAPI(univerAPI: FUniver): CasualSheetsAPI;
|
|
228
|
+
declare function createCasualSheetsAPI(univerAPI: FUniver, initialResources?: IWorkbookData['resources']): CasualSheetsAPI;
|
|
229
229
|
|
|
230
230
|
export { type CasualSheetsAPI as C, type DocumentMode as D, type RangeRef as R, type CasualSheetsEvents as a, type CommandRecord as b, createCasualSheetsAPI as c };
|
|
@@ -225,6 +225,6 @@ interface CasualSheetsAPI {
|
|
|
225
225
|
* to {@link CasualSheetsAPI} for hosts, while the `<CasualSheets>` wrapper casts
|
|
226
226
|
* back to reach `emit` / `markDirty`.
|
|
227
227
|
*/
|
|
228
|
-
declare function createCasualSheetsAPI(univerAPI: FUniver): CasualSheetsAPI;
|
|
228
|
+
declare function createCasualSheetsAPI(univerAPI: FUniver, initialResources?: IWorkbookData['resources']): CasualSheetsAPI;
|
|
229
229
|
|
|
230
230
|
export { type CasualSheetsAPI as C, type DocumentMode as D, type RangeRef as R, type CasualSheetsEvents as a, type CommandRecord as b, createCasualSheetsAPI as c };
|
|
@@ -2,7 +2,7 @@ import * as Y from 'yjs';
|
|
|
2
2
|
import { HocuspocusProvider } from '@hocuspocus/provider';
|
|
3
3
|
import { IWorkbookData } from '@univerjs/core';
|
|
4
4
|
import { FUniver } from '@univerjs/core/facade';
|
|
5
|
-
import { C as CasualSheetsAPI } from './api-
|
|
5
|
+
import { C as CasualSheetsAPI } from './api-cyO4EA4_.js';
|
|
6
6
|
|
|
7
7
|
type ReplayClassification = 'transient' | 'permanent';
|
|
8
8
|
interface ReplayFailureRecord {
|
|
@@ -2,7 +2,7 @@ import * as Y from 'yjs';
|
|
|
2
2
|
import { HocuspocusProvider } from '@hocuspocus/provider';
|
|
3
3
|
import { IWorkbookData } from '@univerjs/core';
|
|
4
4
|
import { FUniver } from '@univerjs/core/facade';
|
|
5
|
-
import { C as CasualSheetsAPI } from './api-
|
|
5
|
+
import { C as CasualSheetsAPI } from './api-cyO4EA4_.cjs';
|
|
6
6
|
|
|
7
7
|
type ReplayClassification = 'transient' | 'permanent';
|
|
8
8
|
interface ReplayFailureRecord {
|
package/dist/chrome.cjs
CHANGED
|
@@ -4016,6 +4016,28 @@ function toA1(row, col) {
|
|
|
4016
4016
|
} while (n >= 0);
|
|
4017
4017
|
return `${letters}${row + 1}`;
|
|
4018
4018
|
}
|
|
4019
|
+
var PIVOTS_RESOURCE_NAME = "__casual_sheets_pivots__";
|
|
4020
|
+
function persistPivotModel(api, model) {
|
|
4021
|
+
const data = api.getContent();
|
|
4022
|
+
if (!data) return;
|
|
4023
|
+
const resources = data.resources ? [...data.resources] : [];
|
|
4024
|
+
const idx = resources.findIndex((r) => r.name === PIVOTS_RESOURCE_NAME);
|
|
4025
|
+
let pivots = [];
|
|
4026
|
+
if (idx >= 0 && resources[idx]?.data) {
|
|
4027
|
+
try {
|
|
4028
|
+
const parsed = JSON.parse(resources[idx].data);
|
|
4029
|
+
if (parsed?.v === 1 && Array.isArray(parsed.pivots)) pivots = parsed.pivots;
|
|
4030
|
+
} catch {
|
|
4031
|
+
pivots = [];
|
|
4032
|
+
}
|
|
4033
|
+
}
|
|
4034
|
+
const merged = pivots.some((p) => p.id === model.id) ? pivots.map((p) => p.id === model.id ? model : p) : [...pivots, model];
|
|
4035
|
+
const entry = { name: PIVOTS_RESOURCE_NAME, data: JSON.stringify({ v: 1, pivots: merged }) };
|
|
4036
|
+
if (idx >= 0) resources[idx] = entry;
|
|
4037
|
+
else resources.push(entry);
|
|
4038
|
+
const nextData = { ...data, resources };
|
|
4039
|
+
api.setContent(nextData);
|
|
4040
|
+
}
|
|
4019
4041
|
var RANGE_NOTE_STYLE10 = {
|
|
4020
4042
|
fontSize: 12,
|
|
4021
4043
|
color: "var(--cs-chrome-muted, #605e5c)",
|
|
@@ -4075,13 +4097,27 @@ function InsertPivotDialog({ api, onClose }) {
|
|
|
4075
4097
|
setError("No active workbook.");
|
|
4076
4098
|
return;
|
|
4077
4099
|
}
|
|
4100
|
+
const srcRange = activeRange11(api);
|
|
4101
|
+
const activeWs = wb.getActiveSheet();
|
|
4102
|
+
const srcRow = srcRange?.getRow?.() ?? 0;
|
|
4103
|
+
const srcCol = srcRange?.getColumn?.() ?? 0;
|
|
4104
|
+
const sourceSheetId = activeWs?.getSheetId?.() ?? "";
|
|
4105
|
+
const sourceRange = {
|
|
4106
|
+
startRow: srcRow,
|
|
4107
|
+
startColumn: srcCol,
|
|
4108
|
+
endRow: srcRow + source.length - 1,
|
|
4109
|
+
endColumn: srcCol + (source[0]?.length ?? 1) - 1
|
|
4110
|
+
};
|
|
4111
|
+
let targetSheetId = sourceSheetId;
|
|
4112
|
+
let target = { row: 0, column: 0 };
|
|
4078
4113
|
try {
|
|
4079
4114
|
if (state.destination === "newSheet") {
|
|
4080
4115
|
const name = state.sheetName.trim() || "Pivot";
|
|
4081
4116
|
const rows = Math.max(pivot.grid.length + 2, 10);
|
|
4082
4117
|
const sheet = wb.create(name, rows, 4);
|
|
4083
|
-
|
|
4084
|
-
|
|
4118
|
+
sheet.getRange(`A1:${toA1(pivot.grid.length - 1, 1)}`).setValues(pivot.grid);
|
|
4119
|
+
targetSheetId = sheet.getSheetId?.() ?? sourceSheetId;
|
|
4120
|
+
target = { row: 0, column: 0 };
|
|
4085
4121
|
} else {
|
|
4086
4122
|
const anchor = state.anchor.trim().toUpperCase();
|
|
4087
4123
|
if (!/^[A-Z]+[0-9]+$/.test(anchor)) {
|
|
@@ -4100,11 +4136,26 @@ function InsertPivotDialog({ api, onClose }) {
|
|
|
4100
4136
|
const startRow = Number(m[2]) - 1;
|
|
4101
4137
|
const end = toA1(startRow + pivot.grid.length - 1, col + 1);
|
|
4102
4138
|
sheet.getRange(`${anchor}:${end}`).setValues(pivot.grid);
|
|
4139
|
+
target = { row: startRow, column: col };
|
|
4103
4140
|
}
|
|
4104
4141
|
} catch (e) {
|
|
4105
4142
|
setError(e instanceof Error ? e.message : "Failed to create the pivot table.");
|
|
4106
4143
|
return;
|
|
4107
4144
|
}
|
|
4145
|
+
if (state.useHeader && sourceSheetId && targetSheetId) {
|
|
4146
|
+
persistPivotModel(api, {
|
|
4147
|
+
id: `pivot-${targetSheetId}-${target.row}-${target.column}`,
|
|
4148
|
+
sourceSheetId,
|
|
4149
|
+
source: sourceRange,
|
|
4150
|
+
targetSheetId,
|
|
4151
|
+
target,
|
|
4152
|
+
rows: [{ column: state.groupCol }],
|
|
4153
|
+
cols: [],
|
|
4154
|
+
values: [{ column: state.valueCol, agg: state.aggFn }],
|
|
4155
|
+
filters: [],
|
|
4156
|
+
lastOutputExtent: { rows: pivot.grid.length, cols: pivot.grid[0]?.length ?? 0 }
|
|
4157
|
+
});
|
|
4158
|
+
}
|
|
4108
4159
|
onClose();
|
|
4109
4160
|
};
|
|
4110
4161
|
return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
|
|
@@ -4630,7 +4681,13 @@ var BAR_STYLE = {
|
|
|
4630
4681
|
background: "var(--cs-chrome-bg, #eef1f5)",
|
|
4631
4682
|
flex: "0 0 auto",
|
|
4632
4683
|
userSelect: "none",
|
|
4633
|
-
|
|
4684
|
+
// Single row that scrolls horizontally when the controls don't fit — never
|
|
4685
|
+
// wrap into a broken second row with orphaned icons (matches Google Sheets /
|
|
4686
|
+
// the standalone app's overflow-scroll toolbar). Scrollbar hidden; the row
|
|
4687
|
+
// stays one line and the groups keep their order.
|
|
4688
|
+
flexWrap: "nowrap",
|
|
4689
|
+
overflowX: "auto",
|
|
4690
|
+
scrollbarWidth: "none"
|
|
4634
4691
|
};
|
|
4635
4692
|
var BTN_STYLE4 = {
|
|
4636
4693
|
width: 30,
|