@xlsx-editor.dev/core 0.0.0-placeholder.0 → 0.1.0-beta.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/LICENSE +217 -0
- package/README.md +254 -2
- package/THIRD_PARTY_NOTICES.md +78 -0
- package/dist/automation.d.ts +299 -0
- package/dist/automation.js +42 -0
- package/dist/builtins-nmHrq2Et.d.ts +37 -0
- package/dist/cascade.d.ts +196 -0
- package/dist/cascade.js +60 -0
- package/dist/cell-format-DW8yF-c-.d.ts +226 -0
- package/dist/chunk-2DLJYRJC.js +3171 -0
- package/dist/chunk-2ZU4337U.js +204 -0
- package/dist/chunk-44L37ENZ.js +8219 -0
- package/dist/chunk-77N55BLP.js +911 -0
- package/dist/chunk-7PV5HQPE.js +84 -0
- package/dist/chunk-E4VJJ556.js +756 -0
- package/dist/chunk-KG4IL4JI.js +436 -0
- package/dist/chunk-PLDK4XO6.js +9125 -0
- package/dist/chunk-PRHLYXHL.js +1699 -0
- package/dist/chunk-TE4FXG5T.js +3156 -0
- package/dist/contracts.d.ts +32 -0
- package/dist/contracts.js +0 -0
- package/dist/dist-C7NLNUMD.js +2850 -0
- package/dist/editor.d.ts +3167 -0
- package/dist/editor.js +309 -0
- package/dist/harfbuzz-measurer-CkKfsEyu.d.ts +128 -0
- package/dist/harfbuzz.wasm +0 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +309 -0
- package/dist/layout.d.ts +111 -0
- package/dist/layout.js +104 -0
- package/dist/merge-commands-DthcNpfw.d.ts +53 -0
- package/dist/node-module-shim-LQXGL47O.js +18 -0
- package/dist/ops-CfUCjyph.d.ts +629 -0
- package/dist/output.d.ts +177 -0
- package/dist/output.js +29 -0
- package/dist/sheet-index-P5vevMWX.d.ts +52 -0
- package/dist/sheet-layout-D9M_4EBn.d.ts +494 -0
- package/dist/sheet-protection-D8goxm58.d.ts +209 -0
- package/dist/store.d.ts +615 -0
- package/dist/store.js +272 -0
- package/dist/theme-BprDji6x.d.ts +16 -0
- package/dist/units-D6CD_A5I.d.ts +13 -0
- package/dist/workbook-index-DsbeR8Kb.d.ts +294 -0
- package/licenses/Emscripten-LICENSE.txt +102 -0
- package/licenses/HarfBuzz-COPYING.txt +42 -0
- package/licenses/HarfBuzz-USE-MIT.txt +21 -0
- package/licenses/HarfBuzz-source-notices.txt +4508 -0
- package/licenses/README.md +19 -0
- package/licenses/Unicode-LICENSE.txt +39 -0
- package/licenses/compiler-rt-LICENSE.txt +311 -0
- package/licenses/harfbuzz-manifest.json +84 -0
- package/licenses/musl-COPYRIGHT.txt +193 -0
- package/package.json +79 -6
- package/src/styles/editor.css +1933 -0
- package/src/styles/editor.css.d.ts +2 -0
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
export { C as ClearKind, a as CommandOps, F as FormatToggle, M as MergeOptions, c as clearOps, f as formatOps, m as mergeOps, t as togglePatch, u as unmergeOp } from './merge-commands-DthcNpfw.js';
|
|
2
|
+
import { GridSelection } from './contracts.js';
|
|
3
|
+
import { StructuralOpName, WorkbookOp } from './store.js';
|
|
4
|
+
import './cell-format-DW8yF-c-.js';
|
|
5
|
+
import './workbook-index-DsbeR8Kb.js';
|
|
6
|
+
|
|
7
|
+
/** The kind of band that a selection is: whole rows, whole columns, or neither. */
|
|
8
|
+
type SelectionBand = 'rows' | 'columns' | null;
|
|
9
|
+
/** Whether a selection covers whole rows or whole columns. A whole sheet is neither. */
|
|
10
|
+
declare function selectionBand(selection: GridSelection): SelectionBand;
|
|
11
|
+
/** Whether a selection covers the whole sheet, which a structural command refuses. */
|
|
12
|
+
declare function isWholeSheet(selection: GridSelection): boolean;
|
|
13
|
+
/** The structural op of a command on a selection of a sheet that is not the whole sheet. */
|
|
14
|
+
declare function structureOp(sheet: string, selection: GridSelection, name: StructuralOpName): WorkbookOp;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Why a workbook could not be opened, as a stable public code.
|
|
18
|
+
*
|
|
19
|
+
* @public
|
|
20
|
+
*/
|
|
21
|
+
type WorkbookOpenDiagnosticCode = 'open.zip-corrupt' | 'open.zip-invalid-entry-name' | 'open.zip-entry-limit' | 'open.zip-size-limit' | 'open.zip-ratio-limit' | 'open.xml-malformed' | 'open.xml-dtd-forbidden' | 'open.xml-part-size-limit' | 'open.xml-depth-limit' | 'open.xml-element-limit' | 'open.invalid-limits' | 'open.content-types-invalid' | 'open.missing-workbook' | 'open.failed';
|
|
22
|
+
/**
|
|
23
|
+
* The reader limit that a refused open passed, with the names of DOCX Editor's `limit`.
|
|
24
|
+
*
|
|
25
|
+
* @public
|
|
26
|
+
*/
|
|
27
|
+
type WorkbookOpenLimit = 'zip.maxEntries' | 'zip.maxTotalBytes' | 'zip.maxRatio' | 'xml.maxBytes' | 'xml.maxElements' | 'xml.maxDepth';
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* What a host supports, fixed at construction and frozen.
|
|
31
|
+
*
|
|
32
|
+
* @public
|
|
33
|
+
*/
|
|
34
|
+
interface AutomationCapabilities {
|
|
35
|
+
/** Reading and editing the workbook. Every operation needs it. */
|
|
36
|
+
readonly document: boolean;
|
|
37
|
+
/** Serializing the current workbook back to `.xlsx` bytes. */
|
|
38
|
+
readonly save: boolean;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Why an operation was refused, as a value to branch on.
|
|
42
|
+
*
|
|
43
|
+
* @public
|
|
44
|
+
*/
|
|
45
|
+
type AutomationErrorCode =
|
|
46
|
+
/** Nothing was applied: `expectedRevision` did not match the host's revision. */
|
|
47
|
+
'stale-revision'
|
|
48
|
+
/** An argument outside its range: an address, a value, a size. */
|
|
49
|
+
| 'invalid-argument'
|
|
50
|
+
/** The operation, argument form, or content is outside the subset that this host implements. */
|
|
51
|
+
| 'unsupported'
|
|
52
|
+
/** The operation would read or write more cells than one operation or batch may. */
|
|
53
|
+
| 'resource-limit'
|
|
54
|
+
/** The host has been disposed. Every later call fails this way. */
|
|
55
|
+
| 'disposed'
|
|
56
|
+
/** The store refused the transaction; nothing was applied. */
|
|
57
|
+
| 'transaction-refused'
|
|
58
|
+
/** The operation is not one this protocol version defines. */
|
|
59
|
+
| 'unknown-operation'
|
|
60
|
+
/** A lookup by key found nothing, and the caller did not ask for null. */
|
|
61
|
+
| 'item-not-found';
|
|
62
|
+
/**
|
|
63
|
+
* One refused operation. Plain data, not an `Error`: it crosses transports. `code` is the stable
|
|
64
|
+
* part. `detail` selects a diagnostic in the object model, which never copies it into a message.
|
|
65
|
+
*
|
|
66
|
+
* @public
|
|
67
|
+
*/
|
|
68
|
+
interface AutomationError {
|
|
69
|
+
readonly code: AutomationErrorCode;
|
|
70
|
+
/** Human-readable, for a log. Never parsed. */
|
|
71
|
+
readonly message: string;
|
|
72
|
+
/** Machine-ish specifics: the store's rejection code, the name of the bad argument. */
|
|
73
|
+
readonly detail?: string;
|
|
74
|
+
/**
|
|
75
|
+
* For a refusal of the content of a cell: the A1 reference of the first such cell, such as
|
|
76
|
+
* `B3`. The host makes it from the cell position, never from file text.
|
|
77
|
+
*/
|
|
78
|
+
readonly cell?: string;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* One worksheet, as plain values. `id` is opaque, and it follows the worksheet through a rename
|
|
82
|
+
* or a move.
|
|
83
|
+
*
|
|
84
|
+
* @public
|
|
85
|
+
*/
|
|
86
|
+
interface AutomationWorksheetRead {
|
|
87
|
+
readonly id: string;
|
|
88
|
+
readonly name: string;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* A cell value as the file stores it. An empty cell reads as `""` and an error value as its
|
|
92
|
+
* text, such as `#DIV/0!`.
|
|
93
|
+
*
|
|
94
|
+
* @public
|
|
95
|
+
*/
|
|
96
|
+
type AutomationCellValue = number | string | boolean;
|
|
97
|
+
/**
|
|
98
|
+
* A value to store in one cell: a number, text as written, a boolean, `empty` to clear the
|
|
99
|
+
* value, or `null` to leave the cell as it is.
|
|
100
|
+
*
|
|
101
|
+
* @public
|
|
102
|
+
*/
|
|
103
|
+
type AutomationCellWrite = {
|
|
104
|
+
readonly type: 'number';
|
|
105
|
+
readonly value: number;
|
|
106
|
+
} | {
|
|
107
|
+
readonly type: 'string';
|
|
108
|
+
readonly value: string;
|
|
109
|
+
} | {
|
|
110
|
+
readonly type: 'boolean';
|
|
111
|
+
readonly value: boolean;
|
|
112
|
+
} | {
|
|
113
|
+
readonly type: 'empty';
|
|
114
|
+
} | null;
|
|
115
|
+
/**
|
|
116
|
+
* One range, as plain values, rows first.
|
|
117
|
+
*
|
|
118
|
+
* @public
|
|
119
|
+
*/
|
|
120
|
+
interface AutomationRangeRead {
|
|
121
|
+
/** The address with its sheet, such as `Sheet1!A1:B2`. */
|
|
122
|
+
readonly address: string;
|
|
123
|
+
readonly values?: readonly (readonly AutomationCellValue[])[];
|
|
124
|
+
/** The number format code of each cell, such as `General` or `0.00%`. */
|
|
125
|
+
readonly numberFormat?: readonly (readonly string[])[];
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* The worksheet that an operation addresses: by its id, by its name (matched without letter
|
|
129
|
+
* case), or the active worksheet.
|
|
130
|
+
*
|
|
131
|
+
* @public
|
|
132
|
+
*/
|
|
133
|
+
type AutomationWorksheetSelector = {
|
|
134
|
+
readonly id: string;
|
|
135
|
+
} | {
|
|
136
|
+
readonly name: string;
|
|
137
|
+
} | {
|
|
138
|
+
readonly active: true;
|
|
139
|
+
};
|
|
140
|
+
/**
|
|
141
|
+
* One operation of a batch. A range read of values or formats after a value write in the same
|
|
142
|
+
* batch is refused: the batch reads the workbook as it was before the batch.
|
|
143
|
+
*
|
|
144
|
+
* @public
|
|
145
|
+
*/
|
|
146
|
+
type AutomationOperation =
|
|
147
|
+
/** The worksheets of the workbook in tab order. Chartsheets are not worksheets. */
|
|
148
|
+
{
|
|
149
|
+
readonly op: 'listWorksheets';
|
|
150
|
+
}
|
|
151
|
+
/** One worksheet. With `orNull`, a selector that matches none answers `null`. */
|
|
152
|
+
| {
|
|
153
|
+
readonly op: 'getWorksheet';
|
|
154
|
+
readonly sheet: AutomationWorksheetSelector;
|
|
155
|
+
readonly orNull?: boolean;
|
|
156
|
+
}
|
|
157
|
+
/** Read a range of a worksheet (`A1` or `A1:B2`). */
|
|
158
|
+
| {
|
|
159
|
+
readonly op: 'readRange';
|
|
160
|
+
readonly sheet: AutomationWorksheetSelector;
|
|
161
|
+
readonly address: string;
|
|
162
|
+
readonly values?: boolean;
|
|
163
|
+
readonly numberFormat?: boolean;
|
|
164
|
+
}
|
|
165
|
+
/** Store values in a range. The array has exactly the rows and columns of the range. */
|
|
166
|
+
| {
|
|
167
|
+
readonly op: 'writeValues';
|
|
168
|
+
readonly sheet: AutomationWorksheetSelector;
|
|
169
|
+
readonly address: string;
|
|
170
|
+
readonly values: readonly (readonly AutomationCellWrite[])[];
|
|
171
|
+
};
|
|
172
|
+
/**
|
|
173
|
+
* What one operation answered.
|
|
174
|
+
*
|
|
175
|
+
* @public
|
|
176
|
+
*/
|
|
177
|
+
type AutomationValue = null | AutomationWorksheetRead | readonly AutomationWorksheetRead[] | AutomationRangeRead;
|
|
178
|
+
/**
|
|
179
|
+
* The result of one operation: its value, its refusal, or `skipped` when another operation of
|
|
180
|
+
* the batch was refused.
|
|
181
|
+
*
|
|
182
|
+
* @public
|
|
183
|
+
*/
|
|
184
|
+
type AutomationOperationResult = {
|
|
185
|
+
readonly status: 'ok';
|
|
186
|
+
readonly value: AutomationValue;
|
|
187
|
+
} | {
|
|
188
|
+
readonly status: 'error';
|
|
189
|
+
readonly error: AutomationError;
|
|
190
|
+
} | {
|
|
191
|
+
readonly status: 'skipped';
|
|
192
|
+
};
|
|
193
|
+
/**
|
|
194
|
+
* A batch: operations in order, and the revision that the caller last read. When the host is at
|
|
195
|
+
* another revision, the batch is refused with `stale-revision` and nothing applies.
|
|
196
|
+
*
|
|
197
|
+
* @public
|
|
198
|
+
*/
|
|
199
|
+
interface AutomationBatchRequest {
|
|
200
|
+
readonly operations: readonly AutomationOperation[];
|
|
201
|
+
readonly expectedRevision?: number;
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* The answer to a batch. All or nothing: when `ok` is false, nothing was applied.
|
|
205
|
+
*
|
|
206
|
+
* @public
|
|
207
|
+
*/
|
|
208
|
+
interface AutomationBatchResponse {
|
|
209
|
+
readonly ok: boolean;
|
|
210
|
+
readonly results: readonly AutomationOperationResult[];
|
|
211
|
+
/** The host revision after the batch. */
|
|
212
|
+
readonly revision: number;
|
|
213
|
+
/** The batch committed a change. */
|
|
214
|
+
readonly changed: boolean;
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* The bytes of a save, or why there are none.
|
|
218
|
+
*
|
|
219
|
+
* @public
|
|
220
|
+
*/
|
|
221
|
+
type AutomationSaveResult = {
|
|
222
|
+
readonly ok: true;
|
|
223
|
+
readonly bytes: Uint8Array;
|
|
224
|
+
} | {
|
|
225
|
+
readonly ok: false;
|
|
226
|
+
readonly error: AutomationError;
|
|
227
|
+
};
|
|
228
|
+
/**
|
|
229
|
+
* A host over opened bytes, or why the bytes do not open: `code` says whether the bytes are
|
|
230
|
+
* malformed or pass a reader limit, `reason` is the public open diagnostic, and `limit` names the
|
|
231
|
+
* reader limit that the bytes passed.
|
|
232
|
+
*
|
|
233
|
+
* @public
|
|
234
|
+
*/
|
|
235
|
+
type AutomationOpenResult = {
|
|
236
|
+
readonly ok: true;
|
|
237
|
+
readonly host: AutomationHost;
|
|
238
|
+
} | {
|
|
239
|
+
readonly ok: false;
|
|
240
|
+
readonly code: 'invalid-argument' | 'resource-limit';
|
|
241
|
+
readonly reason: WorkbookOpenDiagnosticCode;
|
|
242
|
+
readonly limit?: WorkbookOpenLimit;
|
|
243
|
+
};
|
|
244
|
+
/**
|
|
245
|
+
* A workbook automation host.
|
|
246
|
+
*
|
|
247
|
+
* @public
|
|
248
|
+
*/
|
|
249
|
+
interface AutomationHost {
|
|
250
|
+
readonly capabilities: AutomationCapabilities;
|
|
251
|
+
/** The current revision of the workbook. */
|
|
252
|
+
revision(): number;
|
|
253
|
+
/** Run a batch. Never throws for a refusal: the response names it. */
|
|
254
|
+
execute(request: AutomationBatchRequest): AutomationBatchResponse;
|
|
255
|
+
/** The current workbook as `.xlsx` bytes. */
|
|
256
|
+
save(): AutomationSaveResult;
|
|
257
|
+
/** Release the host. Idempotent. */
|
|
258
|
+
dispose(): void;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/** The most operations one batch may carry. */
|
|
262
|
+
declare const MAX_BATCH_OPERATIONS = 10000;
|
|
263
|
+
/** The most cells that the range reads and writes of one batch may reach in all. */
|
|
264
|
+
declare const MAX_BATCH_CELLS = 1000000;
|
|
265
|
+
/** The most cells that the value writes of one batch may reach in all. */
|
|
266
|
+
declare const MAX_BATCH_WRITE_CELLS = 10000;
|
|
267
|
+
/**
|
|
268
|
+
* The most merged ranges that the value writes of one batch may compare their bounds with, in
|
|
269
|
+
* all. Each write compares its bounds with each merged range of its worksheet.
|
|
270
|
+
*/
|
|
271
|
+
declare const MAX_BATCH_MERGE_CHECKS = 50000000;
|
|
272
|
+
/** The most worksheets that the lists of one batch may give in all. */
|
|
273
|
+
declare const MAX_BATCH_LISTED_WORKSHEETS = 100000;
|
|
274
|
+
/**
|
|
275
|
+
* The most array formula and data table ranges of a worksheet whose values a batch reads or
|
|
276
|
+
* writes. Each range operation compares its bounds with each of them.
|
|
277
|
+
*/
|
|
278
|
+
declare const MAX_ARRAY_RANGES = 10000;
|
|
279
|
+
/**
|
|
280
|
+
* The most child nodes of a cell whose value a batch reads or writes. Each operation on a cell
|
|
281
|
+
* reads its children, so a cell with more refuses, and a batch of operations on one cell stays
|
|
282
|
+
* bounded.
|
|
283
|
+
*/
|
|
284
|
+
declare const MAX_CELL_CHILDREN = 1000;
|
|
285
|
+
/**
|
|
286
|
+
* Open XLSX bytes as a headless host. Opening is the bounded package reader and one store, as
|
|
287
|
+
* the editor opens a workbook. Malformed bytes answer `invalid-argument`, and bytes over a reader
|
|
288
|
+
* limit `resource-limit` with the limit. Each refusal gives its public open diagnostic. The
|
|
289
|
+
* answer carries no file content.
|
|
290
|
+
*
|
|
291
|
+
* @public
|
|
292
|
+
*/
|
|
293
|
+
declare function openAutomationHost(bytes: Uint8Array): AutomationOpenResult;
|
|
294
|
+
|
|
295
|
+
/** The most cells that one range operation reads or writes. */
|
|
296
|
+
declare const MAX_RANGE_CELLS = 100000;
|
|
297
|
+
|
|
298
|
+
export { MAX_ARRAY_RANGES, MAX_BATCH_CELLS, MAX_BATCH_LISTED_WORKSHEETS, MAX_BATCH_MERGE_CHECKS, MAX_BATCH_OPERATIONS, MAX_BATCH_WRITE_CELLS, MAX_CELL_CHILDREN, MAX_RANGE_CELLS, isWholeSheet, openAutomationHost, selectionBand, structureOp };
|
|
299
|
+
export type { AutomationBatchRequest, AutomationBatchResponse, AutomationCapabilities, AutomationCellValue, AutomationCellWrite, AutomationError, AutomationErrorCode, AutomationHost, AutomationOpenResult, AutomationOperation, AutomationOperationResult, AutomationRangeRead, AutomationSaveResult, AutomationValue, AutomationWorksheetRead, AutomationWorksheetSelector, SelectionBand, WorkbookOpenDiagnosticCode, WorkbookOpenLimit };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import {
|
|
2
|
+
MAX_ARRAY_RANGES,
|
|
3
|
+
MAX_BATCH_CELLS,
|
|
4
|
+
MAX_BATCH_LISTED_WORKSHEETS,
|
|
5
|
+
MAX_BATCH_MERGE_CHECKS,
|
|
6
|
+
MAX_BATCH_OPERATIONS,
|
|
7
|
+
MAX_BATCH_WRITE_CELLS,
|
|
8
|
+
MAX_CELL_CHILDREN,
|
|
9
|
+
MAX_RANGE_CELLS,
|
|
10
|
+
clearOps,
|
|
11
|
+
formatOps,
|
|
12
|
+
isWholeSheet,
|
|
13
|
+
mergeOps,
|
|
14
|
+
openAutomationHost,
|
|
15
|
+
selectionBand,
|
|
16
|
+
structureOp,
|
|
17
|
+
togglePatch,
|
|
18
|
+
unmergeOp
|
|
19
|
+
} from "./chunk-E4VJJ556.js";
|
|
20
|
+
import "./chunk-2ZU4337U.js";
|
|
21
|
+
import "./chunk-PRHLYXHL.js";
|
|
22
|
+
import "./chunk-44L37ENZ.js";
|
|
23
|
+
import "./chunk-2DLJYRJC.js";
|
|
24
|
+
export {
|
|
25
|
+
MAX_ARRAY_RANGES,
|
|
26
|
+
MAX_BATCH_CELLS,
|
|
27
|
+
MAX_BATCH_LISTED_WORKSHEETS,
|
|
28
|
+
MAX_BATCH_MERGE_CHECKS,
|
|
29
|
+
MAX_BATCH_OPERATIONS,
|
|
30
|
+
MAX_BATCH_WRITE_CELLS,
|
|
31
|
+
MAX_CELL_CHILDREN,
|
|
32
|
+
MAX_RANGE_CELLS,
|
|
33
|
+
clearOps,
|
|
34
|
+
formatOps,
|
|
35
|
+
isWholeSheet,
|
|
36
|
+
mergeOps,
|
|
37
|
+
openAutomationHost,
|
|
38
|
+
selectionBand,
|
|
39
|
+
structureOp,
|
|
40
|
+
togglePatch,
|
|
41
|
+
unmergeOp
|
|
42
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The separators of a number locale, and its built-in format codes, for the shown values.
|
|
3
|
+
*
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
6
|
+
interface NumberLocale {
|
|
7
|
+
/** The decimal separator. */
|
|
8
|
+
readonly decimal: string;
|
|
9
|
+
/** The thousands group separator. */
|
|
10
|
+
readonly group: string;
|
|
11
|
+
/** Built-in codes that replace the ECMA-376 table, by format id. */
|
|
12
|
+
readonly builtins?: Readonly<Record<number, string>>;
|
|
13
|
+
/**
|
|
14
|
+
* The currency symbol of the currency and accounting entries of the number format list, as
|
|
15
|
+
* the text before the number. `$` when absent. A symbol is 1 to 8 UTF-16 code units of
|
|
16
|
+
* plain text: no control code, no U+FFFE or U+FFFF, and no lone surrogate. With any other
|
|
17
|
+
* symbol, the list leaves out the two entries: the editor never writes another symbol in its
|
|
18
|
+
* place. The symbol changes only the code that a list entry writes, never a shown value.
|
|
19
|
+
*/
|
|
20
|
+
readonly currencySymbol?: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Whether two number locales format the same: equal separators, equal built-in codes, and the
|
|
24
|
+
* same currency symbol. A host can pass a new object with each render; only a change of value
|
|
25
|
+
* applies.
|
|
26
|
+
*/
|
|
27
|
+
declare function sameNumberLocale(a: NumberLocale | undefined, b: NumberLocale | undefined): boolean;
|
|
28
|
+
/** The ECMA-376 built-in codes with `.` and `,`. */
|
|
29
|
+
declare const EN_US: NumberLocale;
|
|
30
|
+
/**
|
|
31
|
+
* The code of a built-in format id in a locale, or undefined for an id that has no known code
|
|
32
|
+
* (the locale-dependent ids 5 to 8, 23 to 36, 41 to 44, and 50 to 163).
|
|
33
|
+
*/
|
|
34
|
+
declare function builtinFormatCode(id: number, locale: NumberLocale): string | undefined;
|
|
35
|
+
|
|
36
|
+
export { EN_US as E, builtinFormatCode as b, sameNumberLocale as s };
|
|
37
|
+
export type { NumberLocale as N };
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import { C as CellValue, R as ResolvedCellFormat, c as CascadeProblem } from './cell-format-DW8yF-c-.js';
|
|
2
|
+
export { B as BorderEdge, d as CascadeProblemCode, e as CellFormatResult, f as ColorContext, g as ColorUse, G as GradientRect, h as ResolvedAlignment, i as ResolvedBorder, b as ResolvedFill, j as ResolvedFont, k as ResolvedProtection, l as ResolvedValue, a as Rgb, m as RichTextRun, S as StringItem, n as TextRun, U as UnderlineStyle, o as cellFormat, p as cellValue, q as defaultFont, r as parseDouble, s as resolveColor, t as richTextRuns, u as sheetStale, v as stringItem } from './cell-format-DW8yF-c-.js';
|
|
3
|
+
export { W as WorkbookTheme, w as workbookTheme } from './theme-BprDji6x.js';
|
|
4
|
+
import { XlsxPackage, WorkbookIndex, Element } from './store.js';
|
|
5
|
+
import { N as NumberLocale } from './builtins-nmHrq2Et.js';
|
|
6
|
+
export { E as EN_US, b as builtinFormatCode, s as sameNumberLocale } from './builtins-nmHrq2Et.js';
|
|
7
|
+
|
|
8
|
+
/** `ST_ConditionalFormattingOperator`, Part 1, 18.18.15, for `cellIs`. */
|
|
9
|
+
type CellIsOperator = 'lessThan' | 'lessThanOrEqual' | 'equal' | 'notEqual' | 'greaterThanOrEqual' | 'greaterThan' | 'between' | 'notBetween';
|
|
10
|
+
/** A literal operand of a `cellIs` rule. */
|
|
11
|
+
type Operand = {
|
|
12
|
+
readonly kind: 'number';
|
|
13
|
+
readonly value: number;
|
|
14
|
+
} | {
|
|
15
|
+
readonly kind: 'string';
|
|
16
|
+
readonly text: string;
|
|
17
|
+
/** The text in lowercase, made once when the rule is read. */
|
|
18
|
+
readonly lower: string;
|
|
19
|
+
} | {
|
|
20
|
+
readonly kind: 'boolean';
|
|
21
|
+
readonly value: boolean;
|
|
22
|
+
};
|
|
23
|
+
/** A range of a rule, 0-based and inclusive. */
|
|
24
|
+
interface RuleRange {
|
|
25
|
+
readonly firstRow: number;
|
|
26
|
+
readonly firstCol: number;
|
|
27
|
+
readonly lastRow: number;
|
|
28
|
+
readonly lastCol: number;
|
|
29
|
+
}
|
|
30
|
+
/** Why the engine does not show a rule. */
|
|
31
|
+
type NotShownReason = 'needs-formula' | 'unsupported' | 'malformed';
|
|
32
|
+
/** One `x:cfRule` (`CT_CfRule`) with the ranges of its `x:conditionalFormatting`. */
|
|
33
|
+
interface ConditionalRule {
|
|
34
|
+
/** 0-based ordinal of the `x:cfRule` in document order. */
|
|
35
|
+
readonly ordinal: number;
|
|
36
|
+
/** `@priority` (`xsd:int`). */
|
|
37
|
+
readonly priority: number;
|
|
38
|
+
readonly ranges: readonly RuleRange[];
|
|
39
|
+
/** The `x:dxf` index (`@dxfId`, `ST_DxfId`), when the rule names one. */
|
|
40
|
+
readonly dxfId: number | undefined;
|
|
41
|
+
/** `@stopIfTrue` (`xsd:boolean`, default false). */
|
|
42
|
+
readonly stopIfTrue: boolean;
|
|
43
|
+
/** The test of a shown rule. */
|
|
44
|
+
readonly test?: {
|
|
45
|
+
readonly operator: CellIsOperator;
|
|
46
|
+
readonly operands: readonly Operand[];
|
|
47
|
+
};
|
|
48
|
+
/** Why the rule is not shown. */
|
|
49
|
+
readonly notShown?: NotShownReason;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* The rule ranges that the cells of one layout may check, over all cells. Past it, the rest of
|
|
53
|
+
* the cells of the layout keep their cell formats.
|
|
54
|
+
*/
|
|
55
|
+
declare const LAYOUT_CHECK_BUDGET = 4000000;
|
|
56
|
+
/** A count of rule-range checks that callers share across the cells of one layout. */
|
|
57
|
+
interface CheckBudget {
|
|
58
|
+
left: number;
|
|
59
|
+
/**
|
|
60
|
+
* Charge each row once as a new row, also a row in the cache, so the result depends only on
|
|
61
|
+
* the cells and not on the cache history. A copy sets it and walks its rows in order; a layout
|
|
62
|
+
* does not.
|
|
63
|
+
*/
|
|
64
|
+
readonly everyRow?: boolean;
|
|
65
|
+
/** With `everyRow`, the last row that was charged: the other cells of that row pay no more. */
|
|
66
|
+
charged?: number;
|
|
67
|
+
}
|
|
68
|
+
/** The rules of a worksheet in walk order: ascending `@priority`, then document order. */
|
|
69
|
+
interface SheetRules {
|
|
70
|
+
readonly rules: readonly ConditionalRule[];
|
|
71
|
+
/** `x:cfRule` elements past {@link MAX_RULES} or {@link MAX_PAIRS}, which are not read. */
|
|
72
|
+
readonly skipped: number;
|
|
73
|
+
/** The rule and range pairs that were read. */
|
|
74
|
+
readonly pairs: number;
|
|
75
|
+
/** The pairs of the shown rules: the cost of building the ranges of one row. */
|
|
76
|
+
readonly shownPairs: number;
|
|
77
|
+
}
|
|
78
|
+
/** The conditional formatting rules of a worksheet root. Cached per root. */
|
|
79
|
+
declare function sheetRules(worksheet: Element): SheetRules;
|
|
80
|
+
/**
|
|
81
|
+
* Whether a worksheet has conditional formatting that the grid can leave out: a rule that is
|
|
82
|
+
* not shown, rules past the read limits, more shown rules or ranges than the caps of one cell
|
|
83
|
+
* or one row take, or rules in an extension list (`x:extLst`), which the engine keeps and never
|
|
84
|
+
* reads. The chrome tells the user, so no rule is dropped silently.
|
|
85
|
+
*/
|
|
86
|
+
declare function sheetHasHiddenRules(worksheet: Element): boolean;
|
|
87
|
+
/**
|
|
88
|
+
* Whether a shown rule meets a row. Layout asks it before it checks the blank cells of the row,
|
|
89
|
+
* so a row that no rule meets costs no check for each cell. Past the budget, it is false: the
|
|
90
|
+
* cells keep their formats, as {@link conditionalFormat} keeps them.
|
|
91
|
+
*/
|
|
92
|
+
declare function rowHasShownRules(worksheet: Element, row: number, budget?: CheckBudget): boolean;
|
|
93
|
+
/**
|
|
94
|
+
* `format` with the formats of the true rules over the cell at `row` and `col` laid over it.
|
|
95
|
+
* The walk takes rules by ascending priority; each property takes the first value that a true
|
|
96
|
+
* rule sets, and a true rule with `stopIfTrue` ends the walk. A rule that is not shown is
|
|
97
|
+
* skipped. At most {@link MAX_ENTRIES_PER_ROW} rule ranges of the row are checked, and at
|
|
98
|
+
* most {@link MAX_RULES_PER_CELL} rules over the cell are walked.
|
|
99
|
+
*/
|
|
100
|
+
declare function conditionalFormat(pkg: XlsxPackage, index: WorkbookIndex, worksheet: Element, row: number, col: number, value: CellValue, format: ResolvedCellFormat, budget?: CheckBudget): ResolvedCellFormat;
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* The built-in format codes of ECMA-376 Part 1, 18.8.30. Id 47 is `mm:ss.0`: the printed table
|
|
104
|
+
* gives `mmss.0`, and the measured `number-formats` fixture shows the minutes and seconds
|
|
105
|
+
* separated by `:`.
|
|
106
|
+
*/
|
|
107
|
+
declare const BUILTIN_FORMATS: Readonly<Record<number, string>>;
|
|
108
|
+
|
|
109
|
+
/** A space of `text` at `index` that is as wide as the character `char`. */
|
|
110
|
+
interface Pad {
|
|
111
|
+
readonly index: number;
|
|
112
|
+
readonly char: string;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* The date of a serial: year, month 1 to 12, day 0 to 31, and weekday 0 (Sunday) to 6. Day 0
|
|
117
|
+
* is only serial 0 of the 1900 system (1900-01-00).
|
|
118
|
+
*/
|
|
119
|
+
interface CalendarDate {
|
|
120
|
+
readonly year: number;
|
|
121
|
+
readonly month: number;
|
|
122
|
+
readonly day: number;
|
|
123
|
+
/** 0 is Sunday. */
|
|
124
|
+
readonly weekday: number;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* The calendar date of a whole serial day, or undefined outside 0 to 9999-12-31. In the 1900
|
|
128
|
+
* system, serial 60 is 1900-02-29, a day that the 1900 system counts.
|
|
129
|
+
*/
|
|
130
|
+
declare function serialToDate(serial: number, date1904: boolean): CalendarDate | undefined;
|
|
131
|
+
/**
|
|
132
|
+
* The serial of an ISO 8601 date or date-time (`2024-03-01`, `2024-03-01T12:30:00`, an optional
|
|
133
|
+
* fraction of a second and `Z`), or undefined when the text is not a valid date in the system.
|
|
134
|
+
*/
|
|
135
|
+
declare function dateToSerial(iso: string, date1904: boolean): number | undefined;
|
|
136
|
+
|
|
137
|
+
interface FormatOptions {
|
|
138
|
+
readonly locale: NumberLocale;
|
|
139
|
+
/** `x:workbookPr/@date1904`. */
|
|
140
|
+
readonly date1904: boolean;
|
|
141
|
+
}
|
|
142
|
+
interface FormattedValue {
|
|
143
|
+
/** The shown text, without the fill run. */
|
|
144
|
+
readonly text: string;
|
|
145
|
+
/** `RRGGBB` of the section's color token. */
|
|
146
|
+
readonly color?: string;
|
|
147
|
+
/** A character repeated to fill the column width, inserted at `index` of `text`. */
|
|
148
|
+
readonly fill?: {
|
|
149
|
+
readonly char: string;
|
|
150
|
+
readonly index: number;
|
|
151
|
+
};
|
|
152
|
+
/**
|
|
153
|
+
* The spaces of `text` that are as wide as another character: a `?` placeholder is as wide as
|
|
154
|
+
* a digit, and `_x` as wide as `x` (ECMA-376 Part 1, 18.8.31). Indexes skip the fill run.
|
|
155
|
+
*/
|
|
156
|
+
readonly pads?: readonly Pad[];
|
|
157
|
+
/**
|
|
158
|
+
* A number shown through a text section (`@`): `general` alignment treats it as text
|
|
159
|
+
* (number-formats.pdf draws `42` through `@` at the left of its cell).
|
|
160
|
+
*/
|
|
161
|
+
readonly alignAsText?: boolean;
|
|
162
|
+
/** Why the code fell back to `General`. */
|
|
163
|
+
readonly problem?: CascadeProblem;
|
|
164
|
+
}
|
|
165
|
+
/** Formats a number, text, or boolean value through a format code. */
|
|
166
|
+
declare function formatValue(value: number | string | boolean, code: string, options: FormatOptions): FormattedValue;
|
|
167
|
+
/**
|
|
168
|
+
* True when the first section of the code formats a date or time: the section that a
|
|
169
|
+
* non-negative value, such as a converted `t="d"` date, uses.
|
|
170
|
+
*/
|
|
171
|
+
declare function isDateFormat(code: string): boolean;
|
|
172
|
+
/**
|
|
173
|
+
* The digits of fractions of a second that the first section of a date code shows, as in
|
|
174
|
+
* `mm:ss.0`, or 0 for a code that shows none or is not valid.
|
|
175
|
+
*/
|
|
176
|
+
declare function subsecondDigits(code: string): number;
|
|
177
|
+
/** The problem of a code that falls back to `General`, or undefined for a valid code. */
|
|
178
|
+
declare function formatCodeProblem(code: string): CascadeProblem | undefined;
|
|
179
|
+
|
|
180
|
+
interface DisplayOptions {
|
|
181
|
+
readonly locale: NumberLocale;
|
|
182
|
+
readonly date1904: boolean;
|
|
183
|
+
}
|
|
184
|
+
/** The format code of a cell format: its custom code, the built-in code, or `General`. */
|
|
185
|
+
declare function formatCodeOf(format: ResolvedCellFormat, locale: NumberLocale): string;
|
|
186
|
+
/** The text that a cell shows, with the color and fill of its number format. */
|
|
187
|
+
declare function displayValue(value: CellValue, format: ResolvedCellFormat, options: DisplayOptions): FormattedValue;
|
|
188
|
+
/**
|
|
189
|
+
* The text that a cell shows before layout fits it to its box: rich text runs as stored, every
|
|
190
|
+
* other value through {@link displayValue}, as layout's cell text does. The editor's
|
|
191
|
+
* announcement reads it, so assistive technology hears the text that the grid paints.
|
|
192
|
+
*/
|
|
193
|
+
declare function shownText(value: CellValue, format: ResolvedCellFormat, options: DisplayOptions): string;
|
|
194
|
+
|
|
195
|
+
export { BUILTIN_FORMATS, CascadeProblem, CellValue, LAYOUT_CHECK_BUDGET, NumberLocale, ResolvedCellFormat, conditionalFormat, dateToSerial, displayValue, formatCodeOf, formatCodeProblem, formatValue, isDateFormat, rowHasShownRules, serialToDate, sheetHasHiddenRules, sheetRules, shownText, subsecondDigits };
|
|
196
|
+
export type { CalendarDate, CheckBudget, ConditionalRule, DisplayOptions, FormatOptions, FormattedValue, NotShownReason, SheetRules };
|
package/dist/cascade.js
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import {
|
|
2
|
+
EN_US,
|
|
3
|
+
LAYOUT_CHECK_BUDGET,
|
|
4
|
+
builtinFormatCode,
|
|
5
|
+
cellFormat,
|
|
6
|
+
cellValue,
|
|
7
|
+
conditionalFormat,
|
|
8
|
+
dateToSerial,
|
|
9
|
+
defaultFont,
|
|
10
|
+
displayValue,
|
|
11
|
+
formatCodeOf,
|
|
12
|
+
formatCodeProblem,
|
|
13
|
+
formatValue,
|
|
14
|
+
isDateFormat,
|
|
15
|
+
parseDouble,
|
|
16
|
+
resolveColor,
|
|
17
|
+
richTextRuns,
|
|
18
|
+
rowHasShownRules,
|
|
19
|
+
sameNumberLocale,
|
|
20
|
+
serialToDate,
|
|
21
|
+
sheetHasHiddenRules,
|
|
22
|
+
sheetRules,
|
|
23
|
+
sheetStale,
|
|
24
|
+
shownText,
|
|
25
|
+
stringItem,
|
|
26
|
+
subsecondDigits,
|
|
27
|
+
workbookTheme
|
|
28
|
+
} from "./chunk-PRHLYXHL.js";
|
|
29
|
+
import {
|
|
30
|
+
BUILTIN_FORMATS
|
|
31
|
+
} from "./chunk-2DLJYRJC.js";
|
|
32
|
+
export {
|
|
33
|
+
BUILTIN_FORMATS,
|
|
34
|
+
EN_US,
|
|
35
|
+
LAYOUT_CHECK_BUDGET,
|
|
36
|
+
builtinFormatCode,
|
|
37
|
+
cellFormat,
|
|
38
|
+
cellValue,
|
|
39
|
+
conditionalFormat,
|
|
40
|
+
dateToSerial,
|
|
41
|
+
defaultFont,
|
|
42
|
+
displayValue,
|
|
43
|
+
formatCodeOf,
|
|
44
|
+
formatCodeProblem,
|
|
45
|
+
formatValue,
|
|
46
|
+
isDateFormat,
|
|
47
|
+
parseDouble,
|
|
48
|
+
resolveColor,
|
|
49
|
+
richTextRuns,
|
|
50
|
+
rowHasShownRules,
|
|
51
|
+
sameNumberLocale,
|
|
52
|
+
serialToDate,
|
|
53
|
+
sheetHasHiddenRules,
|
|
54
|
+
sheetRules,
|
|
55
|
+
sheetStale,
|
|
56
|
+
shownText,
|
|
57
|
+
stringItem,
|
|
58
|
+
subsecondDigits,
|
|
59
|
+
workbookTheme
|
|
60
|
+
};
|