@univerjs-pro/bases 1.0.0-alpha.2 → 1.0.0-alpha.3
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/README.md +8 -5
- package/lib/cjs/facade.js +1 -1
- package/lib/cjs/index.js +1 -1
- package/lib/cjs/locale/ar-SA.js +1 -1
- package/lib/cjs/locale/ca-ES.js +1 -1
- package/lib/cjs/locale/de-DE.js +1 -1
- package/lib/cjs/locale/en-US.js +1 -1
- package/lib/cjs/locale/es-ES.js +1 -1
- package/lib/cjs/locale/fa-IR.js +1 -1
- package/lib/cjs/locale/fr-FR.js +1 -1
- package/lib/cjs/locale/id-ID.js +1 -1
- package/lib/cjs/locale/it-IT.js +1 -1
- package/lib/cjs/locale/ja-JP.js +1 -1
- package/lib/cjs/locale/ko-KR.js +1 -1
- package/lib/cjs/locale/pl-PL.js +1 -1
- package/lib/cjs/locale/pt-BR.js +1 -1
- package/lib/cjs/locale/ru-RU.js +1 -1
- package/lib/cjs/locale/sk-SK.js +1 -1
- package/lib/cjs/locale/vi-VN.js +1 -1
- package/lib/cjs/locale/zh-CN.js +1 -1
- package/lib/cjs/locale/zh-HK.js +1 -1
- package/lib/cjs/locale/zh-TW.js +1 -1
- package/lib/es/facade.js +1 -1
- package/lib/es/index.js +1 -1
- package/lib/es/locale/ar-SA.js +1 -1
- package/lib/es/locale/ca-ES.js +1 -1
- package/lib/es/locale/de-DE.js +1 -1
- package/lib/es/locale/en-US.js +1 -1
- package/lib/es/locale/es-ES.js +1 -1
- package/lib/es/locale/fa-IR.js +1 -1
- package/lib/es/locale/fr-FR.js +1 -1
- package/lib/es/locale/id-ID.js +1 -1
- package/lib/es/locale/it-IT.js +1 -1
- package/lib/es/locale/ja-JP.js +1 -1
- package/lib/es/locale/ko-KR.js +1 -1
- package/lib/es/locale/pl-PL.js +1 -1
- package/lib/es/locale/pt-BR.js +1 -1
- package/lib/es/locale/ru-RU.js +1 -1
- package/lib/es/locale/sk-SK.js +1 -1
- package/lib/es/locale/vi-VN.js +1 -1
- package/lib/es/locale/zh-CN.js +1 -1
- package/lib/es/locale/zh-HK.js +1 -1
- package/lib/es/locale/zh-TW.js +1 -1
- package/lib/facade.js +1 -1
- package/lib/index.js +1 -1
- package/lib/locale/ar-SA.js +1 -1
- package/lib/locale/ca-ES.js +1 -1
- package/lib/locale/de-DE.js +1 -1
- package/lib/locale/en-US.js +1 -1
- package/lib/locale/es-ES.js +1 -1
- package/lib/locale/fa-IR.js +1 -1
- package/lib/locale/fr-FR.js +1 -1
- package/lib/locale/id-ID.js +1 -1
- package/lib/locale/it-IT.js +1 -1
- package/lib/locale/ja-JP.js +1 -1
- package/lib/locale/ko-KR.js +1 -1
- package/lib/locale/pl-PL.js +1 -1
- package/lib/locale/pt-BR.js +1 -1
- package/lib/locale/ru-RU.js +1 -1
- package/lib/locale/sk-SK.js +1 -1
- package/lib/locale/vi-VN.js +1 -1
- package/lib/locale/zh-CN.js +1 -1
- package/lib/locale/zh-HK.js +1 -1
- package/lib/locale/zh-TW.js +1 -1
- package/lib/types/commands/commands/set-base-view-filter.command.d.ts +2 -2
- package/lib/types/commands/commands/set-base-view-group.command.d.ts +2 -2
- package/lib/types/commands/commands/set-base-view-sort.command.d.ts +2 -2
- package/lib/types/commands/utils/base-validation.d.ts +6 -0
- package/lib/types/config/config.d.ts +1 -0
- package/lib/types/controllers/base-active-dirty.controller.d.ts +5 -6
- package/lib/types/controllers/base-formula-calculation.controller.d.ts +8 -14
- package/lib/types/embed-host-anchor.d.ts +46 -0
- package/lib/types/facade/f-base.d.ts +126 -577
- package/lib/types/facade/f-enum.d.ts +117 -89
- package/lib/types/facade/f-event.d.ts +255 -132
- package/lib/types/facade/f-field.d.ts +137 -313
- package/lib/types/facade/f-range.d.ts +86 -326
- package/lib/types/facade/f-record.d.ts +93 -216
- package/lib/types/facade/f-table.d.ts +473 -1317
- package/lib/types/facade/f-types.d.ts +1 -0
- package/lib/types/facade/f-univer.d.ts +27 -154
- package/lib/types/facade/f-view.d.ts +207 -484
- package/lib/types/facade/field-key.d.ts +6 -6
- package/lib/types/facade/index.d.ts +10 -20
- package/lib/types/fields/field-core-plugin.d.ts +9 -8
- package/lib/types/index.d.ts +10 -8
- package/lib/types/models/base-cell-data.d.ts +6 -6
- package/lib/types/models/default-table.d.ts +13 -0
- package/lib/types/ot/json1-adapter.d.ts +3 -3
- package/lib/types/ot/json1-invalidation.d.ts +2 -2
- package/lib/types/ot/json1-op-applier.d.ts +2 -2
- package/lib/types/ot/json1-op-factory.d.ts +9 -8
- package/lib/types/plugin.d.ts +0 -1
- package/lib/types/search/base-search.d.ts +4 -3
- package/lib/types/services/base-active-dirty.service.d.ts +2 -2
- package/lib/types/services/base-command.service.d.ts +16 -16
- package/lib/types/services/base-compression.service.d.ts +3 -3
- package/lib/types/services/base-field-registry.service.d.ts +5 -5
- package/lib/types/services/base-formula.service.d.ts +11 -20
- package/lib/types/services/base-view-registry.service.d.ts +3 -3
- package/lib/types/views/view-core-plugin.d.ts +4 -3
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +1 -1
- package/lib/umd/locale/ar-SA.js +1 -1
- package/lib/umd/locale/ca-ES.js +1 -1
- package/lib/umd/locale/de-DE.js +1 -1
- package/lib/umd/locale/en-US.js +1 -1
- package/lib/umd/locale/es-ES.js +1 -1
- package/lib/umd/locale/fa-IR.js +1 -1
- package/lib/umd/locale/fr-FR.js +1 -1
- package/lib/umd/locale/id-ID.js +1 -1
- package/lib/umd/locale/it-IT.js +1 -1
- package/lib/umd/locale/ja-JP.js +1 -1
- package/lib/umd/locale/ko-KR.js +1 -1
- package/lib/umd/locale/pl-PL.js +1 -1
- package/lib/umd/locale/pt-BR.js +1 -1
- package/lib/umd/locale/ru-RU.js +1 -1
- package/lib/umd/locale/sk-SK.js +1 -1
- package/lib/umd/locale/vi-VN.js +1 -1
- package/lib/umd/locale/zh-CN.js +1 -1
- package/lib/umd/locale/zh-HK.js +1 -1
- package/lib/umd/locale/zh-TW.js +1 -1
- package/package.json +7 -8
- package/lib/types/controllers/base-remote-formula.controller.d.ts +0 -13
- package/lib/types/facade/f-error.d.ts +0 -30
- package/lib/types/facade/f-permission.d.ts +0 -749
- package/lib/types/facade/transaction.d.ts +0 -19
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type { BaseCellValue,
|
|
2
|
-
|
|
1
|
+
import type { BaseCellValue, IBaseCellData, Injector, IRange } from '@univerjs/core';
|
|
2
|
+
import type { FBase } from './f-base';
|
|
3
|
+
import type { FBaseTable } from './f-table';
|
|
3
4
|
/**
|
|
4
5
|
* Facade API object bound to a rectangular Base table range.
|
|
5
6
|
*
|
|
@@ -13,252 +14,109 @@ export type BaseRangeValues = BaseCellValue[][];
|
|
|
13
14
|
*
|
|
14
15
|
* @example Read and write a rectangular block
|
|
15
16
|
* ```ts
|
|
16
|
-
* const
|
|
17
|
+
* const fBase = univerAPI.getActiveBase();
|
|
18
|
+
* const fBaseTable = fBase.getTableById('table-1');
|
|
19
|
+
*
|
|
20
|
+
* const range = fBaseTable.getRange(0, 0, 2, 2);
|
|
17
21
|
* console.log(range.getValues());
|
|
22
|
+
*
|
|
18
23
|
* range.setValues([
|
|
19
24
|
* ['Task A', 'todo'],
|
|
20
25
|
* ['Task B', 'done'],
|
|
21
26
|
* ]);
|
|
27
|
+
*
|
|
22
28
|
* const statusColumn = range.offset(0, 1, range.getNumRows(), 1);
|
|
23
29
|
* statusColumn.clear();
|
|
24
30
|
* ```
|
|
25
31
|
*/
|
|
26
|
-
export declare class
|
|
32
|
+
export declare class FBaseTableRange {
|
|
27
33
|
private readonly _base;
|
|
28
|
-
private readonly
|
|
34
|
+
private readonly _table;
|
|
29
35
|
private readonly _range;
|
|
30
|
-
private readonly
|
|
31
|
-
constructor(_base:
|
|
32
|
-
/**
|
|
33
|
-
* Get the Base unit id.
|
|
34
|
-
* @returns The Base unit id.
|
|
35
|
-
* @example
|
|
36
|
-
* ```ts
|
|
37
|
-
* console.log(range.getUnitId());
|
|
38
|
-
* ```
|
|
39
|
-
*
|
|
40
|
-
* @example Browser console
|
|
41
|
-
* ```ts
|
|
42
|
-
* console.log((() => {
|
|
43
|
-
* const unitId = `facade_example_${Date.now()}`;
|
|
44
|
-
* const base = univerAPI.createBase({ id: unitId, name: 'Facade Example', schemaVersion: 1, createdAt: Date.now(), updatedAt: Date.now(), tables: {}, tableOrder: [] }, { makeCurrent: false });
|
|
45
|
-
* try {
|
|
46
|
-
* const table = base.createTable({ id: `${unitId}_table`, name: 'Tasks', primaryFieldName: 'Title' });
|
|
47
|
-
* const field = table.addField({ id: `${unitId}_status`, name: 'Status', type: 'singleSelect', config: { options: [{ id: 'todo', name: 'Todo' }, { id: 'done', name: 'Done' }] }, defaultValue: 'todo' });
|
|
48
|
-
* table.addRecords([
|
|
49
|
-
* { id: `${unitId}_a`, values: { [table.getPrimaryFieldId()]: 'A', [field.getId()]: 'todo' } },
|
|
50
|
-
* { id: `${unitId}_b`, values: { [table.getPrimaryFieldId()]: 'B', [field.getId()]: 'done' } },
|
|
51
|
-
* ]);
|
|
52
|
-
* const range = table.getRange(0, 0, 2, 1);
|
|
53
|
-
* return range.getUnitId();
|
|
54
|
-
* } finally {
|
|
55
|
-
* univerAPI.disposeUnit(unitId);
|
|
56
|
-
* }
|
|
57
|
-
* })());
|
|
58
|
-
* ```
|
|
59
|
-
*/
|
|
60
|
-
getUnitId(): string;
|
|
36
|
+
private readonly _inject;
|
|
37
|
+
constructor(_base: FBase, _table: FBaseTable, _range: IRange, _inject: Injector);
|
|
61
38
|
/**
|
|
62
39
|
* Get the Base id.
|
|
63
|
-
* @returns The Base id.
|
|
40
|
+
* @returns {string} The Base id.
|
|
64
41
|
* @example
|
|
65
42
|
* ```ts
|
|
43
|
+
* const fBase = univerAPI.getActiveBase();
|
|
44
|
+
* const fBaseTable = fBase.getTableById('table-1');
|
|
45
|
+
* const range = fBaseTable.getDataRange();
|
|
66
46
|
* console.log(range.getBaseId());
|
|
67
47
|
* ```
|
|
68
|
-
*
|
|
69
|
-
* @example Browser console
|
|
70
|
-
* ```ts
|
|
71
|
-
* console.log((() => {
|
|
72
|
-
* const unitId = `facade_example_${Date.now()}`;
|
|
73
|
-
* const base = univerAPI.createBase({ id: unitId, name: 'Facade Example', schemaVersion: 1, createdAt: Date.now(), updatedAt: Date.now(), tables: {}, tableOrder: [] }, { makeCurrent: false });
|
|
74
|
-
* try {
|
|
75
|
-
* const table = base.createTable({ id: `${unitId}_table`, name: 'Tasks', primaryFieldName: 'Title' });
|
|
76
|
-
* const field = table.addField({ id: `${unitId}_status`, name: 'Status', type: 'singleSelect', config: { options: [{ id: 'todo', name: 'Todo' }, { id: 'done', name: 'Done' }] }, defaultValue: 'todo' });
|
|
77
|
-
* table.addRecords([
|
|
78
|
-
* { id: `${unitId}_a`, values: { [table.getPrimaryFieldId()]: 'A', [field.getId()]: 'todo' } },
|
|
79
|
-
* { id: `${unitId}_b`, values: { [table.getPrimaryFieldId()]: 'B', [field.getId()]: 'done' } },
|
|
80
|
-
* ]);
|
|
81
|
-
* const range = table.getRange(0, 0, 2, 1);
|
|
82
|
-
* return range.getBaseId();
|
|
83
|
-
* } finally {
|
|
84
|
-
* univerAPI.disposeUnit(unitId);
|
|
85
|
-
* }
|
|
86
|
-
* })());
|
|
87
|
-
* ```
|
|
88
48
|
*/
|
|
89
49
|
getBaseId(): string;
|
|
90
50
|
/**
|
|
91
51
|
* Get the table id.
|
|
92
|
-
* @returns The table id.
|
|
52
|
+
* @returns {string} The table id.
|
|
93
53
|
* @example
|
|
94
54
|
* ```ts
|
|
55
|
+
* const fBase = univerAPI.getActiveBase();
|
|
56
|
+
* const fBaseTable = fBase.getTableById('table-1');
|
|
57
|
+
* const range = fBaseTable.getDataRange();
|
|
95
58
|
* console.log(range.getTableId());
|
|
96
59
|
* ```
|
|
97
|
-
*
|
|
98
|
-
* @example Browser console
|
|
99
|
-
* ```ts
|
|
100
|
-
* console.log((() => {
|
|
101
|
-
* const unitId = `facade_example_${Date.now()}`;
|
|
102
|
-
* const base = univerAPI.createBase({ id: unitId, name: 'Facade Example', schemaVersion: 1, createdAt: Date.now(), updatedAt: Date.now(), tables: {}, tableOrder: [] }, { makeCurrent: false });
|
|
103
|
-
* try {
|
|
104
|
-
* const table = base.createTable({ id: `${unitId}_table`, name: 'Tasks', primaryFieldName: 'Title' });
|
|
105
|
-
* const field = table.addField({ id: `${unitId}_status`, name: 'Status', type: 'singleSelect', config: { options: [{ id: 'todo', name: 'Todo' }, { id: 'done', name: 'Done' }] }, defaultValue: 'todo' });
|
|
106
|
-
* table.addRecords([
|
|
107
|
-
* { id: `${unitId}_a`, values: { [table.getPrimaryFieldId()]: 'A', [field.getId()]: 'todo' } },
|
|
108
|
-
* { id: `${unitId}_b`, values: { [table.getPrimaryFieldId()]: 'B', [field.getId()]: 'done' } },
|
|
109
|
-
* ]);
|
|
110
|
-
* const range = table.getRange(0, 0, 2, 1);
|
|
111
|
-
* return range.getTableId();
|
|
112
|
-
* } finally {
|
|
113
|
-
* univerAPI.disposeUnit(unitId);
|
|
114
|
-
* }
|
|
115
|
-
* })());
|
|
116
|
-
* ```
|
|
117
60
|
*/
|
|
118
61
|
getTableId(): string;
|
|
119
62
|
/**
|
|
120
63
|
* Get the raw range position.
|
|
121
|
-
* @returns The range position.
|
|
64
|
+
* @returns {IRange} The range position.
|
|
122
65
|
* @example
|
|
123
66
|
* ```ts
|
|
124
|
-
* const
|
|
125
|
-
*
|
|
126
|
-
*
|
|
127
|
-
*
|
|
128
|
-
* ```ts
|
|
129
|
-
* console.log((() => {
|
|
130
|
-
* const unitId = `facade_example_${Date.now()}`;
|
|
131
|
-
* const base = univerAPI.createBase({ id: unitId, name: 'Facade Example', schemaVersion: 1, createdAt: Date.now(), updatedAt: Date.now(), tables: {}, tableOrder: [] }, { makeCurrent: false });
|
|
132
|
-
* try {
|
|
133
|
-
* const table = base.createTable({ id: `${unitId}_table`, name: 'Tasks', primaryFieldName: 'Title' });
|
|
134
|
-
* const field = table.addField({ id: `${unitId}_status`, name: 'Status', type: 'singleSelect', config: { options: [{ id: 'todo', name: 'Todo' }, { id: 'done', name: 'Done' }] }, defaultValue: 'todo' });
|
|
135
|
-
* table.addRecords([
|
|
136
|
-
* { id: `${unitId}_a`, values: { [table.getPrimaryFieldId()]: 'A', [field.getId()]: 'todo' } },
|
|
137
|
-
* { id: `${unitId}_b`, values: { [table.getPrimaryFieldId()]: 'B', [field.getId()]: 'done' } },
|
|
138
|
-
* ]);
|
|
139
|
-
* const range = table.getRange(0, 0, 2, 1);
|
|
140
|
-
* return range.getRange();
|
|
141
|
-
* } finally {
|
|
142
|
-
* univerAPI.disposeUnit(unitId);
|
|
143
|
-
* }
|
|
144
|
-
* })());
|
|
67
|
+
* const fBase = univerAPI.getActiveBase();
|
|
68
|
+
* const fBaseTable = fBase.getTableById('table-1');
|
|
69
|
+
* const range = fBaseTable.getDataRange();
|
|
70
|
+
* console.log(range.getRange());
|
|
145
71
|
* ```
|
|
146
72
|
*/
|
|
147
73
|
getRange(): IRange;
|
|
148
74
|
/**
|
|
149
75
|
* Get the first row index of this range.
|
|
150
|
-
* @returns The zero-based row index.
|
|
76
|
+
* @returns {number} The zero-based row index.
|
|
151
77
|
* @example
|
|
152
78
|
* ```ts
|
|
79
|
+
* const fBase = univerAPI.getActiveBase();
|
|
80
|
+
* const fBaseTable = fBase.getTableById('table-1');
|
|
81
|
+
* const range = fBaseTable.getDataRange();
|
|
153
82
|
* console.log(range.getRow());
|
|
154
83
|
* ```
|
|
155
|
-
*
|
|
156
|
-
* @example Browser console
|
|
157
|
-
* ```ts
|
|
158
|
-
* console.log((() => {
|
|
159
|
-
* const unitId = `facade_example_${Date.now()}`;
|
|
160
|
-
* const base = univerAPI.createBase({ id: unitId, name: 'Facade Example', schemaVersion: 1, createdAt: Date.now(), updatedAt: Date.now(), tables: {}, tableOrder: [] }, { makeCurrent: false });
|
|
161
|
-
* try {
|
|
162
|
-
* const table = base.createTable({ id: `${unitId}_table`, name: 'Tasks', primaryFieldName: 'Title' });
|
|
163
|
-
* const field = table.addField({ id: `${unitId}_status`, name: 'Status', type: 'singleSelect', config: { options: [{ id: 'todo', name: 'Todo' }, { id: 'done', name: 'Done' }] }, defaultValue: 'todo' });
|
|
164
|
-
* table.addRecords([
|
|
165
|
-
* { id: `${unitId}_a`, values: { [table.getPrimaryFieldId()]: 'A', [field.getId()]: 'todo' } },
|
|
166
|
-
* { id: `${unitId}_b`, values: { [table.getPrimaryFieldId()]: 'B', [field.getId()]: 'done' } },
|
|
167
|
-
* ]);
|
|
168
|
-
* const range = table.getRange(0, 0, 2, 1);
|
|
169
|
-
* return range.getRow();
|
|
170
|
-
* } finally {
|
|
171
|
-
* univerAPI.disposeUnit(unitId);
|
|
172
|
-
* }
|
|
173
|
-
* })());
|
|
174
|
-
* ```
|
|
175
84
|
*/
|
|
176
85
|
getRow(): number;
|
|
177
86
|
/**
|
|
178
87
|
* Get the first column index of this range.
|
|
179
|
-
* @returns The zero-based column index.
|
|
88
|
+
* @returns {number} The zero-based column index.
|
|
180
89
|
* @example
|
|
181
90
|
* ```ts
|
|
91
|
+
* const fBase = univerAPI.getActiveBase();
|
|
92
|
+
* const fBaseTable = fBase.getTableById('table-1');
|
|
93
|
+
* const range = fBaseTable.getDataRange();
|
|
182
94
|
* console.log(range.getColumn());
|
|
183
95
|
* ```
|
|
184
|
-
*
|
|
185
|
-
* @example Browser console
|
|
186
|
-
* ```ts
|
|
187
|
-
* console.log((() => {
|
|
188
|
-
* const unitId = `facade_example_${Date.now()}`;
|
|
189
|
-
* const base = univerAPI.createBase({ id: unitId, name: 'Facade Example', schemaVersion: 1, createdAt: Date.now(), updatedAt: Date.now(), tables: {}, tableOrder: [] }, { makeCurrent: false });
|
|
190
|
-
* try {
|
|
191
|
-
* const table = base.createTable({ id: `${unitId}_table`, name: 'Tasks', primaryFieldName: 'Title' });
|
|
192
|
-
* const field = table.addField({ id: `${unitId}_status`, name: 'Status', type: 'singleSelect', config: { options: [{ id: 'todo', name: 'Todo' }, { id: 'done', name: 'Done' }] }, defaultValue: 'todo' });
|
|
193
|
-
* table.addRecords([
|
|
194
|
-
* { id: `${unitId}_a`, values: { [table.getPrimaryFieldId()]: 'A', [field.getId()]: 'todo' } },
|
|
195
|
-
* { id: `${unitId}_b`, values: { [table.getPrimaryFieldId()]: 'B', [field.getId()]: 'done' } },
|
|
196
|
-
* ]);
|
|
197
|
-
* const range = table.getRange(0, 0, 2, 1);
|
|
198
|
-
* return range.getColumn();
|
|
199
|
-
* } finally {
|
|
200
|
-
* univerAPI.disposeUnit(unitId);
|
|
201
|
-
* }
|
|
202
|
-
* })());
|
|
203
|
-
* ```
|
|
204
96
|
*/
|
|
205
97
|
getColumn(): number;
|
|
206
98
|
/**
|
|
207
99
|
* Get the number of rows in this range.
|
|
208
|
-
* @returns The row count.
|
|
100
|
+
* @returns {number} The row count.
|
|
209
101
|
* @example
|
|
210
102
|
* ```ts
|
|
103
|
+
* const fBase = univerAPI.getActiveBase();
|
|
104
|
+
* const fBaseTable = fBase.getTableById('table-1');
|
|
105
|
+
* const range = fBaseTable.getDataRange();
|
|
211
106
|
* console.log(range.getNumRows());
|
|
212
107
|
* ```
|
|
213
|
-
*
|
|
214
|
-
* @example Browser console
|
|
215
|
-
* ```ts
|
|
216
|
-
* console.log((() => {
|
|
217
|
-
* const unitId = `facade_example_${Date.now()}`;
|
|
218
|
-
* const base = univerAPI.createBase({ id: unitId, name: 'Facade Example', schemaVersion: 1, createdAt: Date.now(), updatedAt: Date.now(), tables: {}, tableOrder: [] }, { makeCurrent: false });
|
|
219
|
-
* try {
|
|
220
|
-
* const table = base.createTable({ id: `${unitId}_table`, name: 'Tasks', primaryFieldName: 'Title' });
|
|
221
|
-
* const field = table.addField({ id: `${unitId}_status`, name: 'Status', type: 'singleSelect', config: { options: [{ id: 'todo', name: 'Todo' }, { id: 'done', name: 'Done' }] }, defaultValue: 'todo' });
|
|
222
|
-
* table.addRecords([
|
|
223
|
-
* { id: `${unitId}_a`, values: { [table.getPrimaryFieldId()]: 'A', [field.getId()]: 'todo' } },
|
|
224
|
-
* { id: `${unitId}_b`, values: { [table.getPrimaryFieldId()]: 'B', [field.getId()]: 'done' } },
|
|
225
|
-
* ]);
|
|
226
|
-
* const range = table.getRange(0, 0, 2, 1);
|
|
227
|
-
* return range.getNumRows();
|
|
228
|
-
* } finally {
|
|
229
|
-
* univerAPI.disposeUnit(unitId);
|
|
230
|
-
* }
|
|
231
|
-
* })());
|
|
232
|
-
* ```
|
|
233
108
|
*/
|
|
234
109
|
getNumRows(): number;
|
|
235
110
|
/**
|
|
236
111
|
* Get the number of columns in this range.
|
|
237
|
-
* @returns The column count.
|
|
112
|
+
* @returns {number} The column count.
|
|
238
113
|
* @example
|
|
239
114
|
* ```ts
|
|
115
|
+
* const fBase = univerAPI.getActiveBase();
|
|
116
|
+
* const fBaseTable = fBase.getTableById('table-1');
|
|
117
|
+
* const range = fBaseTable.getDataRange();
|
|
240
118
|
* console.log(range.getNumColumns());
|
|
241
119
|
* ```
|
|
242
|
-
*
|
|
243
|
-
* @example Browser console
|
|
244
|
-
* ```ts
|
|
245
|
-
* console.log((() => {
|
|
246
|
-
* const unitId = `facade_example_${Date.now()}`;
|
|
247
|
-
* const base = univerAPI.createBase({ id: unitId, name: 'Facade Example', schemaVersion: 1, createdAt: Date.now(), updatedAt: Date.now(), tables: {}, tableOrder: [] }, { makeCurrent: false });
|
|
248
|
-
* try {
|
|
249
|
-
* const table = base.createTable({ id: `${unitId}_table`, name: 'Tasks', primaryFieldName: 'Title' });
|
|
250
|
-
* const field = table.addField({ id: `${unitId}_status`, name: 'Status', type: 'singleSelect', config: { options: [{ id: 'todo', name: 'Todo' }, { id: 'done', name: 'Done' }] }, defaultValue: 'todo' });
|
|
251
|
-
* table.addRecords([
|
|
252
|
-
* { id: `${unitId}_a`, values: { [table.getPrimaryFieldId()]: 'A', [field.getId()]: 'todo' } },
|
|
253
|
-
* { id: `${unitId}_b`, values: { [table.getPrimaryFieldId()]: 'B', [field.getId()]: 'done' } },
|
|
254
|
-
* ]);
|
|
255
|
-
* const range = table.getRange(0, 0, 2, 1);
|
|
256
|
-
* return range.getNumColumns();
|
|
257
|
-
* } finally {
|
|
258
|
-
* univerAPI.disposeUnit(unitId);
|
|
259
|
-
* }
|
|
260
|
-
* })());
|
|
261
|
-
* ```
|
|
262
120
|
*/
|
|
263
121
|
getNumColumns(): number;
|
|
264
122
|
/**
|
|
@@ -267,196 +125,98 @@ export declare class FBaseRange {
|
|
|
267
125
|
* The outer array is rows and the inner array is columns. Empty cells are
|
|
268
126
|
* returned as `null`.
|
|
269
127
|
*
|
|
270
|
-
* @returns A two-dimensional array matching the range size.
|
|
128
|
+
* @returns {BaseCellValue[][]} A two-dimensional array matching the range size.
|
|
271
129
|
* @example
|
|
272
130
|
* ```ts
|
|
273
|
-
* const
|
|
274
|
-
*
|
|
275
|
-
*
|
|
276
|
-
*
|
|
277
|
-
* ```ts
|
|
278
|
-
* console.log((() => {
|
|
279
|
-
* const unitId = `facade_example_${Date.now()}`;
|
|
280
|
-
* const base = univerAPI.createBase({ id: unitId, name: 'Facade Example', schemaVersion: 1, createdAt: Date.now(), updatedAt: Date.now(), tables: {}, tableOrder: [] }, { makeCurrent: false });
|
|
281
|
-
* try {
|
|
282
|
-
* const table = base.createTable({ id: `${unitId}_table`, name: 'Tasks', primaryFieldName: 'Title' });
|
|
283
|
-
* const field = table.addField({ id: `${unitId}_status`, name: 'Status', type: 'singleSelect', config: { options: [{ id: 'todo', name: 'Todo' }, { id: 'done', name: 'Done' }] }, defaultValue: 'todo' });
|
|
284
|
-
* table.addRecords([
|
|
285
|
-
* { id: `${unitId}_a`, values: { [table.getPrimaryFieldId()]: 'A', [field.getId()]: 'todo' } },
|
|
286
|
-
* { id: `${unitId}_b`, values: { [table.getPrimaryFieldId()]: 'B', [field.getId()]: 'done' } },
|
|
287
|
-
* ]);
|
|
288
|
-
* const range = table.getRange(0, 0, 2, 1);
|
|
289
|
-
* return range.getValues();
|
|
290
|
-
* } finally {
|
|
291
|
-
* univerAPI.disposeUnit(unitId);
|
|
292
|
-
* }
|
|
293
|
-
* })());
|
|
131
|
+
* const fBase = univerAPI.getActiveBase();
|
|
132
|
+
* const fBaseTable = fBase.getTableById('table-1');
|
|
133
|
+
* const range = fBaseTable.getDataRange();
|
|
134
|
+
* console.log(range.getValues());
|
|
294
135
|
* ```
|
|
295
136
|
*/
|
|
296
|
-
getValues():
|
|
137
|
+
getValues(): BaseCellValue[][];
|
|
297
138
|
/**
|
|
298
139
|
* Get the first value in this range.
|
|
299
|
-
* @returns The top-left value.
|
|
140
|
+
* @returns {BaseCellValue} The top-left value.
|
|
300
141
|
* @example
|
|
301
142
|
* ```ts
|
|
302
|
-
* const
|
|
303
|
-
*
|
|
304
|
-
*
|
|
305
|
-
*
|
|
306
|
-
* ```ts
|
|
307
|
-
* console.log((() => {
|
|
308
|
-
* const unitId = `facade_example_${Date.now()}`;
|
|
309
|
-
* const base = univerAPI.createBase({ id: unitId, name: 'Facade Example', schemaVersion: 1, createdAt: Date.now(), updatedAt: Date.now(), tables: {}, tableOrder: [] }, { makeCurrent: false });
|
|
310
|
-
* try {
|
|
311
|
-
* const table = base.createTable({ id: `${unitId}_table`, name: 'Tasks', primaryFieldName: 'Title' });
|
|
312
|
-
* const field = table.addField({ id: `${unitId}_status`, name: 'Status', type: 'singleSelect', config: { options: [{ id: 'todo', name: 'Todo' }, { id: 'done', name: 'Done' }] }, defaultValue: 'todo' });
|
|
313
|
-
* table.addRecords([
|
|
314
|
-
* { id: `${unitId}_a`, values: { [table.getPrimaryFieldId()]: 'A', [field.getId()]: 'todo' } },
|
|
315
|
-
* { id: `${unitId}_b`, values: { [table.getPrimaryFieldId()]: 'B', [field.getId()]: 'done' } },
|
|
316
|
-
* ]);
|
|
317
|
-
* const range = table.getRange(0, 0, 2, 1);
|
|
318
|
-
* return range.offset(0, 0, 1, 1).getValue();
|
|
319
|
-
* } finally {
|
|
320
|
-
* univerAPI.disposeUnit(unitId);
|
|
321
|
-
* }
|
|
322
|
-
* })());
|
|
143
|
+
* const fBase = univerAPI.getActiveBase();
|
|
144
|
+
* const fBaseTable = fBase.getTableById('table-1');
|
|
145
|
+
* const range = fBaseTable.getDataRange();
|
|
146
|
+
* console.log(range.getValue());
|
|
323
147
|
* ```
|
|
324
148
|
*/
|
|
325
149
|
getValue(): BaseCellValue;
|
|
326
150
|
/**
|
|
327
151
|
* Set the top-left value in this range.
|
|
328
|
-
* @param value The value to write. It may be a raw Base cell value, a full
|
|
152
|
+
* @param {BaseCellValue | IBaseCellData} value The value to write. It may be a raw Base cell value, a full
|
|
329
153
|
* `IBaseCellData` object, or `null` to clear the cell.
|
|
154
|
+
* @returns {boolean} `true` if set value successfully, `false` if failed.
|
|
330
155
|
* @example
|
|
331
156
|
* ```ts
|
|
332
|
-
*
|
|
333
|
-
*
|
|
334
|
-
*
|
|
335
|
-
*
|
|
336
|
-
*
|
|
337
|
-
* console.log((() => {
|
|
338
|
-
* const unitId = `facade_example_${Date.now()}`;
|
|
339
|
-
* const base = univerAPI.createBase({ id: unitId, name: 'Facade Example', schemaVersion: 1, createdAt: Date.now(), updatedAt: Date.now(), tables: {}, tableOrder: [] }, { makeCurrent: false });
|
|
340
|
-
* try {
|
|
341
|
-
* const table = base.createTable({ id: `${unitId}_table`, name: 'Tasks', primaryFieldName: 'Title' });
|
|
342
|
-
* const field = table.addField({ id: `${unitId}_status`, name: 'Status', type: 'singleSelect', config: { options: [{ id: 'todo', name: 'Todo' }, { id: 'done', name: 'Done' }] }, defaultValue: 'todo' });
|
|
343
|
-
* table.addRecords([
|
|
344
|
-
* { id: `${unitId}_a`, values: { [table.getPrimaryFieldId()]: 'A', [field.getId()]: 'todo' } },
|
|
345
|
-
* { id: `${unitId}_b`, values: { [table.getPrimaryFieldId()]: 'B', [field.getId()]: 'done' } },
|
|
346
|
-
* ]);
|
|
347
|
-
* const range = table.getRange(0, 0, 2, 1);
|
|
348
|
-
* range.offset(0, 0, 1, 1).setValue('Updated');
|
|
349
|
-
* return range.offset(0, 0, 1, 1).getValue();
|
|
350
|
-
* } finally {
|
|
351
|
-
* univerAPI.disposeUnit(unitId);
|
|
352
|
-
* }
|
|
353
|
-
* })());
|
|
157
|
+
* const fBase = univerAPI.getActiveBase();
|
|
158
|
+
* const fBaseTable = fBase.getTableById('table-1');
|
|
159
|
+
* const range = fBaseTable.getRange(0, 0, 2, 3);
|
|
160
|
+
* const success = range.setValue('Task title');
|
|
161
|
+
* console.log(success ? 'Value set successfully' : 'Failed to set value');
|
|
354
162
|
* ```
|
|
355
163
|
*/
|
|
356
|
-
setValue(value: BaseCellValue | IBaseCellData
|
|
164
|
+
setValue(value: BaseCellValue | IBaseCellData): boolean;
|
|
357
165
|
/**
|
|
358
166
|
* Set all values in this range.
|
|
359
167
|
*
|
|
360
168
|
* The provided matrix must match `getNumRows()` by `getNumColumns()`.
|
|
361
169
|
* Passing the wrong shape throws before any command is executed.
|
|
362
170
|
*
|
|
363
|
-
* @param values A two-dimensional array matching the range size. Each cell
|
|
171
|
+
* @param {Array<Array<BaseCellValue | IBaseCellData>>} values A two-dimensional array matching the range size. Each cell
|
|
364
172
|
* may be a raw Base cell value, an `IBaseCellData` object, or `null`.
|
|
173
|
+
* @returns {boolean} `true` if set values successfully, `false` if failed.
|
|
365
174
|
* @example
|
|
366
175
|
* ```ts
|
|
367
|
-
*
|
|
176
|
+
* const fBase = univerAPI.getActiveBase();
|
|
177
|
+
* const fBaseTable = fBase.getTableById('table-1');
|
|
178
|
+
* const range = fBaseTable.getRange(0, 1, 2, 2);
|
|
179
|
+
* const success = range.setValues([
|
|
368
180
|
* ['todo', 10],
|
|
369
181
|
* ['done', 20],
|
|
370
182
|
* ]);
|
|
371
|
-
*
|
|
372
|
-
*
|
|
373
|
-
* @example Browser console
|
|
374
|
-
* ```ts
|
|
375
|
-
* console.log((() => {
|
|
376
|
-
* const unitId = `facade_example_${Date.now()}`;
|
|
377
|
-
* const base = univerAPI.createBase({ id: unitId, name: 'Facade Example', schemaVersion: 1, createdAt: Date.now(), updatedAt: Date.now(), tables: {}, tableOrder: [] }, { makeCurrent: false });
|
|
378
|
-
* try {
|
|
379
|
-
* const table = base.createTable({ id: `${unitId}_table`, name: 'Tasks', primaryFieldName: 'Title' });
|
|
380
|
-
* const field = table.addField({ id: `${unitId}_status`, name: 'Status', type: 'singleSelect', config: { options: [{ id: 'todo', name: 'Todo' }, { id: 'done', name: 'Done' }] }, defaultValue: 'todo' });
|
|
381
|
-
* table.addRecords([
|
|
382
|
-
* { id: `${unitId}_a`, values: { [table.getPrimaryFieldId()]: 'A', [field.getId()]: 'todo' } },
|
|
383
|
-
* { id: `${unitId}_b`, values: { [table.getPrimaryFieldId()]: 'B', [field.getId()]: 'done' } },
|
|
384
|
-
* ]);
|
|
385
|
-
* const range = table.getRange(0, 0, 2, 1);
|
|
386
|
-
* range.setValues([['A updated'], ['B updated']]);
|
|
387
|
-
* return range.getValues();
|
|
388
|
-
* } finally {
|
|
389
|
-
* univerAPI.disposeUnit(unitId);
|
|
390
|
-
* }
|
|
391
|
-
* })());
|
|
183
|
+
* console.log(success ? 'Values set successfully' : 'Failed to set values');
|
|
392
184
|
* ```
|
|
393
185
|
*/
|
|
394
|
-
setValues(values: Array<Array<BaseCellValue | IBaseCellData
|
|
186
|
+
setValues(values: Array<Array<BaseCellValue | IBaseCellData>>): boolean;
|
|
395
187
|
/**
|
|
396
188
|
* Clear all values in this range.
|
|
189
|
+
* @returns {boolean} `true` if cleared successfully, `false` if failed.
|
|
397
190
|
* @example
|
|
398
191
|
* ```ts
|
|
399
|
-
*
|
|
400
|
-
*
|
|
401
|
-
*
|
|
402
|
-
*
|
|
403
|
-
*
|
|
404
|
-
* console.log((() => {
|
|
405
|
-
* const unitId = `facade_example_${Date.now()}`;
|
|
406
|
-
* const base = univerAPI.createBase({ id: unitId, name: 'Facade Example', schemaVersion: 1, createdAt: Date.now(), updatedAt: Date.now(), tables: {}, tableOrder: [] }, { makeCurrent: false });
|
|
407
|
-
* try {
|
|
408
|
-
* const table = base.createTable({ id: `${unitId}_table`, name: 'Tasks', primaryFieldName: 'Title' });
|
|
409
|
-
* const field = table.addField({ id: `${unitId}_status`, name: 'Status', type: 'singleSelect', config: { options: [{ id: 'todo', name: 'Todo' }, { id: 'done', name: 'Done' }] }, defaultValue: 'todo' });
|
|
410
|
-
* table.addRecords([
|
|
411
|
-
* { id: `${unitId}_a`, values: { [table.getPrimaryFieldId()]: 'A', [field.getId()]: 'todo' } },
|
|
412
|
-
* { id: `${unitId}_b`, values: { [table.getPrimaryFieldId()]: 'B', [field.getId()]: 'done' } },
|
|
413
|
-
* ]);
|
|
414
|
-
* const range = table.getRange(0, 0, 2, 1);
|
|
415
|
-
* range.clear();
|
|
416
|
-
* return range.getValues();
|
|
417
|
-
* } finally {
|
|
418
|
-
* univerAPI.disposeUnit(unitId);
|
|
419
|
-
* }
|
|
420
|
-
* })());
|
|
192
|
+
* const fBase = univerAPI.getActiveBase();
|
|
193
|
+
* const fBaseTable = fBase.getTableById('table-1');
|
|
194
|
+
* const range = fBaseTable.getDataRange();
|
|
195
|
+
* const success = range.clear();
|
|
196
|
+
* console.log(success ? 'Range cleared successfully' : 'Failed to clear range');
|
|
421
197
|
* ```
|
|
422
198
|
*/
|
|
423
|
-
clear():
|
|
199
|
+
clear(): boolean;
|
|
424
200
|
/**
|
|
425
201
|
* Create a new range offset from this range.
|
|
426
202
|
*
|
|
427
203
|
* Offsets are validated against the table's current row and column bounds.
|
|
428
204
|
*
|
|
429
|
-
* @param rowOffset Number of rows to move. Positive values move down.
|
|
430
|
-
* @param columnOffset Number of columns to move. Positive values move right.
|
|
431
|
-
* @param numRows Number of rows in the returned range. Defaults to the current row count.
|
|
432
|
-
* @param numColumns Number of columns in the returned range. Defaults to the current column count.
|
|
433
|
-
* @returns
|
|
205
|
+
* @param {number} rowOffset Number of rows to move. Positive values move down.
|
|
206
|
+
* @param {number} columnOffset Number of columns to move. Positive values move right.
|
|
207
|
+
* @param {number} numRows Number of rows in the returned range. Defaults to the current row count.
|
|
208
|
+
* @param {number} numColumns Number of columns in the returned range. Defaults to the current column count.
|
|
209
|
+
* @returns {FBaseTableRange} A new range offset from this range.
|
|
434
210
|
* @example
|
|
435
211
|
* ```ts
|
|
212
|
+
* const fBase = univerAPI.getActiveBase();
|
|
213
|
+
* const fBaseTable = fBase.getTableById('table-1');
|
|
214
|
+
* const range = fBaseTable.getRange(0, 0);
|
|
436
215
|
* const nextColumn = range.offset(0, 1);
|
|
437
|
-
*
|
|
438
|
-
*
|
|
439
|
-
* @example Browser console
|
|
440
|
-
* ```ts
|
|
441
|
-
* console.log((() => {
|
|
442
|
-
* const unitId = `facade_example_${Date.now()}`;
|
|
443
|
-
* const base = univerAPI.createBase({ id: unitId, name: 'Facade Example', schemaVersion: 1, createdAt: Date.now(), updatedAt: Date.now(), tables: {}, tableOrder: [] }, { makeCurrent: false });
|
|
444
|
-
* try {
|
|
445
|
-
* const table = base.createTable({ id: `${unitId}_table`, name: 'Tasks', primaryFieldName: 'Title' });
|
|
446
|
-
* const field = table.addField({ id: `${unitId}_status`, name: 'Status', type: 'singleSelect', config: { options: [{ id: 'todo', name: 'Todo' }, { id: 'done', name: 'Done' }] }, defaultValue: 'todo' });
|
|
447
|
-
* table.addRecords([
|
|
448
|
-
* { id: `${unitId}_a`, values: { [table.getPrimaryFieldId()]: 'A', [field.getId()]: 'todo' } },
|
|
449
|
-
* { id: `${unitId}_b`, values: { [table.getPrimaryFieldId()]: 'B', [field.getId()]: 'done' } },
|
|
450
|
-
* ]);
|
|
451
|
-
* const range = table.getRange(0, 0, 2, 1);
|
|
452
|
-
* return range.offset(1, 0, 1, 1).getValues();
|
|
453
|
-
* } finally {
|
|
454
|
-
* univerAPI.disposeUnit(unitId);
|
|
455
|
-
* }
|
|
456
|
-
* })());
|
|
216
|
+
* console.log(nextColumn);
|
|
457
217
|
* ```
|
|
458
218
|
*/
|
|
459
|
-
offset(rowOffset: number, columnOffset: number, numRows?: number, numColumns?: number):
|
|
219
|
+
offset(rowOffset: number, columnOffset: number, numRows?: number, numColumns?: number): FBaseTableRange;
|
|
460
220
|
private _getTable;
|
|
461
221
|
private _assertInBounds;
|
|
462
222
|
}
|