@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,6 +1,8 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
import {
|
|
1
|
+
import type { BaseViewProjection, IFilterConfig, IGroupConfig, Injector, ISortConfig, IViewFieldSetting, IViewSnapshot, ViewSpecificConfig } from '@univerjs/core';
|
|
2
|
+
import type { FBase } from './f-base';
|
|
3
|
+
import type { FBaseTable } from './f-table';
|
|
4
|
+
import { BaseViewType } from '@univerjs/core';
|
|
5
|
+
import { FBaseTableField } from './f-field';
|
|
4
6
|
/**
|
|
5
7
|
* Facade API object bound to a Base view.
|
|
6
8
|
*
|
|
@@ -10,125 +12,72 @@ import { FField } from './f-field';
|
|
|
10
12
|
*
|
|
11
13
|
* @example Configure a grid projection
|
|
12
14
|
* ```ts
|
|
13
|
-
* const
|
|
15
|
+
* const fBase = univerAPI.getActiveBase();
|
|
16
|
+
* const fBaseTable = fBase.getTableById('table-1');
|
|
17
|
+
*
|
|
18
|
+
* const grid = fBaseTable.createView('Main Grid', univerAPI.Enum.BaseViewType.Grid);
|
|
14
19
|
* grid.updateConfig({ frozenFieldCount: 1 });
|
|
15
20
|
* grid.setFilter({
|
|
16
|
-
* conjunction:
|
|
17
|
-
* conditions: [
|
|
21
|
+
* conjunction: univerAPI.Enum.BaseFilterConjunction.AND,
|
|
22
|
+
* conditions: [
|
|
23
|
+
* {
|
|
24
|
+
* fieldId: 'status',
|
|
25
|
+
* operator: univerAPI.Enum.BaseFilterOperator.IS,
|
|
26
|
+
* operand: 'done'
|
|
27
|
+
* }
|
|
28
|
+
* ],
|
|
18
29
|
* });
|
|
19
|
-
* grid.setSort([
|
|
30
|
+
* grid.setSort([
|
|
31
|
+
* {
|
|
32
|
+
* fieldId: 'progress',
|
|
33
|
+
* direction: univerAPI.Enum.BaseSortDirection.DESC
|
|
34
|
+
* }
|
|
35
|
+
* ]);
|
|
20
36
|
* grid.setFieldVisible('internalNotes', false);
|
|
37
|
+
*
|
|
21
38
|
* const projection = grid.getProjection();
|
|
39
|
+
* console.log(projection);
|
|
22
40
|
* ```
|
|
23
41
|
*/
|
|
24
|
-
export declare class
|
|
42
|
+
export declare class FBaseTableView {
|
|
25
43
|
private readonly _base;
|
|
26
|
-
private readonly
|
|
44
|
+
private readonly _table;
|
|
27
45
|
private readonly _viewId;
|
|
28
|
-
private readonly
|
|
29
|
-
|
|
30
|
-
constructor(_base: BaseDataModel, _tableId: string, _viewId: string, _commandService: ICommandService, _projectionService: IBaseProjectionService);
|
|
46
|
+
private readonly _injector;
|
|
47
|
+
constructor(_base: FBase, _table: FBaseTable, _viewId: string, _injector: Injector);
|
|
31
48
|
/**
|
|
32
49
|
* Get the view id.
|
|
33
|
-
* @returns The view id.
|
|
50
|
+
* @returns {string} The view id.
|
|
34
51
|
* @example
|
|
35
52
|
* ```ts
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
* ```ts
|
|
41
|
-
* console.log((() => {
|
|
42
|
-
* const unitId = `facade_example_${Date.now()}`;
|
|
43
|
-
* const base = univerAPI.createBase({ id: unitId, name: 'Facade Example', schemaVersion: 1, createdAt: Date.now(), updatedAt: Date.now(), tables: {}, tableOrder: [] }, { makeCurrent: false });
|
|
44
|
-
* try {
|
|
45
|
-
* const table = base.createTable({ id: `${unitId}_table`, name: 'Tasks', primaryFieldName: 'Title' });
|
|
46
|
-
* const field = table.addField({ id: `${unitId}_status`, name: 'Status', type: 'singleSelect', config: { options: [{ id: 'todo', name: 'Todo' }, { id: 'done', name: 'Done' }] }, defaultValue: 'todo' });
|
|
47
|
-
* const record = table.addRecord({ id: `${unitId}_record`, values: { [table.getPrimaryFieldId()]: 'Alpha', [field.getId()]: 'todo' } });
|
|
48
|
-
* const view = table.createView({ id: `${unitId}_view`, name: 'Grid', type: 'grid' });
|
|
49
|
-
* return view.getId();
|
|
50
|
-
* } finally {
|
|
51
|
-
* univerAPI.disposeUnit(unitId);
|
|
52
|
-
* }
|
|
53
|
-
* })());
|
|
53
|
+
* const fBase = univerAPI.getActiveBase();
|
|
54
|
+
* const fBaseTable = fBase.getTableById('table-1');
|
|
55
|
+
* const views = fBaseTable.getViews();
|
|
56
|
+
* console.log(views[0]?.getId());
|
|
54
57
|
* ```
|
|
55
58
|
*/
|
|
56
59
|
getId(): string;
|
|
57
60
|
/**
|
|
58
61
|
* Get the view snapshot.
|
|
59
|
-
* @returns The view snapshot.
|
|
62
|
+
* @returns {IViewSnapshot} The view snapshot.
|
|
60
63
|
* @example
|
|
61
64
|
* ```ts
|
|
62
|
-
* const
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
* ```ts
|
|
67
|
-
* console.log((() => {
|
|
68
|
-
* const unitId = `facade_example_${Date.now()}`;
|
|
69
|
-
* const base = univerAPI.createBase({ id: unitId, name: 'Facade Example', schemaVersion: 1, createdAt: Date.now(), updatedAt: Date.now(), tables: {}, tableOrder: [] }, { makeCurrent: false });
|
|
70
|
-
* try {
|
|
71
|
-
* const table = base.createTable({ id: `${unitId}_table`, name: 'Tasks', primaryFieldName: 'Title' });
|
|
72
|
-
* const field = table.addField({ id: `${unitId}_status`, name: 'Status', type: 'singleSelect', config: { options: [{ id: 'todo', name: 'Todo' }, { id: 'done', name: 'Done' }] }, defaultValue: 'todo' });
|
|
73
|
-
* const record = table.addRecord({ id: `${unitId}_record`, values: { [table.getPrimaryFieldId()]: 'Alpha', [field.getId()]: 'todo' } });
|
|
74
|
-
* const view = table.createView({ id: `${unitId}_view`, name: 'Grid', type: 'grid' });
|
|
75
|
-
* return view.getView();
|
|
76
|
-
* } finally {
|
|
77
|
-
* univerAPI.disposeUnit(unitId);
|
|
78
|
-
* }
|
|
79
|
-
* })());
|
|
65
|
+
* const fBase = univerAPI.getActiveBase();
|
|
66
|
+
* const fBaseTable = fBase.getTableById('table-1');
|
|
67
|
+
* const views = fBaseTable.getViews();
|
|
68
|
+
* console.log(views[0]?.getView());
|
|
80
69
|
* ```
|
|
81
70
|
*/
|
|
82
71
|
getView(): IViewSnapshot;
|
|
83
|
-
/**
|
|
84
|
-
* Get the view snapshot.
|
|
85
|
-
* @returns The view snapshot.
|
|
86
|
-
* @example
|
|
87
|
-
* ```ts
|
|
88
|
-
* const snapshot = view.getSnapshot();
|
|
89
|
-
* ```
|
|
90
|
-
*
|
|
91
|
-
* @example Browser console
|
|
92
|
-
* ```ts
|
|
93
|
-
* console.log((() => {
|
|
94
|
-
* const unitId = `facade_example_${Date.now()}`;
|
|
95
|
-
* const base = univerAPI.createBase({ id: unitId, name: 'Facade Example', schemaVersion: 1, createdAt: Date.now(), updatedAt: Date.now(), tables: {}, tableOrder: [] }, { makeCurrent: false });
|
|
96
|
-
* try {
|
|
97
|
-
* const table = base.createTable({ id: `${unitId}_table`, name: 'Tasks', primaryFieldName: 'Title' });
|
|
98
|
-
* const field = table.addField({ id: `${unitId}_status`, name: 'Status', type: 'singleSelect', config: { options: [{ id: 'todo', name: 'Todo' }, { id: 'done', name: 'Done' }] }, defaultValue: 'todo' });
|
|
99
|
-
* const record = table.addRecord({ id: `${unitId}_record`, values: { [table.getPrimaryFieldId()]: 'Alpha', [field.getId()]: 'todo' } });
|
|
100
|
-
* const view = table.createView({ id: `${unitId}_view`, name: 'Grid', type: 'grid' });
|
|
101
|
-
* return view.getSnapshot();
|
|
102
|
-
* } finally {
|
|
103
|
-
* univerAPI.disposeUnit(unitId);
|
|
104
|
-
* }
|
|
105
|
-
* })());
|
|
106
|
-
* ```
|
|
107
|
-
*/
|
|
108
|
-
getSnapshot(): IViewSnapshot;
|
|
109
72
|
/**
|
|
110
73
|
* Get the view name.
|
|
111
|
-
* @returns The view name.
|
|
74
|
+
* @returns {string} The view name.
|
|
112
75
|
* @example
|
|
113
76
|
* ```ts
|
|
114
|
-
*
|
|
115
|
-
*
|
|
116
|
-
*
|
|
117
|
-
*
|
|
118
|
-
* ```ts
|
|
119
|
-
* console.log((() => {
|
|
120
|
-
* const unitId = `facade_example_${Date.now()}`;
|
|
121
|
-
* const base = univerAPI.createBase({ id: unitId, name: 'Facade Example', schemaVersion: 1, createdAt: Date.now(), updatedAt: Date.now(), tables: {}, tableOrder: [] }, { makeCurrent: false });
|
|
122
|
-
* try {
|
|
123
|
-
* const table = base.createTable({ id: `${unitId}_table`, name: 'Tasks', primaryFieldName: 'Title' });
|
|
124
|
-
* const field = table.addField({ id: `${unitId}_status`, name: 'Status', type: 'singleSelect', config: { options: [{ id: 'todo', name: 'Todo' }, { id: 'done', name: 'Done' }] }, defaultValue: 'todo' });
|
|
125
|
-
* const record = table.addRecord({ id: `${unitId}_record`, values: { [table.getPrimaryFieldId()]: 'Alpha', [field.getId()]: 'todo' } });
|
|
126
|
-
* const view = table.createView({ id: `${unitId}_view`, name: 'Grid', type: 'grid' });
|
|
127
|
-
* return view.getName();
|
|
128
|
-
* } finally {
|
|
129
|
-
* univerAPI.disposeUnit(unitId);
|
|
130
|
-
* }
|
|
131
|
-
* })());
|
|
77
|
+
* const fBase = univerAPI.getActiveBase();
|
|
78
|
+
* const fBaseTable = fBase.getTableById('table-1');
|
|
79
|
+
* const views = fBaseTable.getViews();
|
|
80
|
+
* console.log(views[0]?.getName());
|
|
132
81
|
* ```
|
|
133
82
|
*/
|
|
134
83
|
getName(): string;
|
|
@@ -137,255 +86,149 @@ export declare class FView {
|
|
|
137
86
|
* @returns The view type.
|
|
138
87
|
* @example
|
|
139
88
|
* ```ts
|
|
140
|
-
*
|
|
141
|
-
*
|
|
142
|
-
*
|
|
143
|
-
*
|
|
144
|
-
* ```ts
|
|
145
|
-
* console.log((() => {
|
|
146
|
-
* const unitId = `facade_example_${Date.now()}`;
|
|
147
|
-
* const base = univerAPI.createBase({ id: unitId, name: 'Facade Example', schemaVersion: 1, createdAt: Date.now(), updatedAt: Date.now(), tables: {}, tableOrder: [] }, { makeCurrent: false });
|
|
148
|
-
* try {
|
|
149
|
-
* const table = base.createTable({ id: `${unitId}_table`, name: 'Tasks', primaryFieldName: 'Title' });
|
|
150
|
-
* const field = table.addField({ id: `${unitId}_status`, name: 'Status', type: 'singleSelect', config: { options: [{ id: 'todo', name: 'Todo' }, { id: 'done', name: 'Done' }] }, defaultValue: 'todo' });
|
|
151
|
-
* const record = table.addRecord({ id: `${unitId}_record`, values: { [table.getPrimaryFieldId()]: 'Alpha', [field.getId()]: 'todo' } });
|
|
152
|
-
* const view = table.createView({ id: `${unitId}_view`, name: 'Grid', type: 'grid' });
|
|
153
|
-
* return view.getType();
|
|
154
|
-
* } finally {
|
|
155
|
-
* univerAPI.disposeUnit(unitId);
|
|
156
|
-
* }
|
|
157
|
-
* })());
|
|
89
|
+
* const fBase = univerAPI.getActiveBase();
|
|
90
|
+
* const fBaseTable = fBase.getTableById('table-1');
|
|
91
|
+
* const views = fBaseTable.getViews();
|
|
92
|
+
* console.log(views[0]?.getType());
|
|
158
93
|
* ```
|
|
159
94
|
*/
|
|
160
|
-
getType():
|
|
95
|
+
getType(): BaseViewType;
|
|
161
96
|
/**
|
|
162
97
|
* Rename this view.
|
|
163
|
-
* @param name The new view name.
|
|
98
|
+
* @param {string} name The new view name.
|
|
99
|
+
* @returns {boolean} True if the rename succeeded, false if the name was unchanged.
|
|
164
100
|
* @example
|
|
165
101
|
* ```ts
|
|
166
|
-
*
|
|
167
|
-
*
|
|
168
|
-
*
|
|
169
|
-
*
|
|
170
|
-
*
|
|
171
|
-
*
|
|
172
|
-
*
|
|
173
|
-
* const base = univerAPI.createBase({ id: unitId, name: 'Facade Example', schemaVersion: 1, createdAt: Date.now(), updatedAt: Date.now(), tables: {}, tableOrder: [] }, { makeCurrent: false });
|
|
174
|
-
* try {
|
|
175
|
-
* const table = base.createTable({ id: `${unitId}_table`, name: 'Tasks', primaryFieldName: 'Title' });
|
|
176
|
-
* const field = table.addField({ id: `${unitId}_status`, name: 'Status', type: 'singleSelect', config: { options: [{ id: 'todo', name: 'Todo' }, { id: 'done', name: 'Done' }] }, defaultValue: 'todo' });
|
|
177
|
-
* const record = table.addRecord({ id: `${unitId}_record`, values: { [table.getPrimaryFieldId()]: 'Alpha', [field.getId()]: 'todo' } });
|
|
178
|
-
* const view = table.createView({ id: `${unitId}_view`, name: 'Grid', type: 'grid' });
|
|
179
|
-
* view.setName('Renamed Grid');
|
|
180
|
-
* return view.getName();
|
|
181
|
-
* } finally {
|
|
182
|
-
* univerAPI.disposeUnit(unitId);
|
|
183
|
-
* }
|
|
184
|
-
* })());
|
|
102
|
+
* const fBase = univerAPI.getActiveBase();
|
|
103
|
+
* const fBaseTable = fBase.getTableById('table-1');
|
|
104
|
+
* const view = fBaseTable.getViewByName('Grid');
|
|
105
|
+
* if (view) {
|
|
106
|
+
* const success = view.setName('Release view');
|
|
107
|
+
* console.log(success ? 'View renamed' : 'Rename failed');
|
|
108
|
+
* }
|
|
185
109
|
* ```
|
|
186
110
|
*/
|
|
187
|
-
setName(name: string):
|
|
111
|
+
setName(name: string): boolean;
|
|
188
112
|
/**
|
|
189
113
|
* Get the view-specific config.
|
|
190
|
-
* @returns The view config.
|
|
114
|
+
* @returns {ViewSpecificConfig} The view-specific config.
|
|
191
115
|
* @example
|
|
192
116
|
* ```ts
|
|
117
|
+
* const fBase = univerAPI.getActiveBase();
|
|
118
|
+
* const fBaseTable = fBase.getTableById('table-1');
|
|
119
|
+
* const view = fBaseTable.getViewByName('Grid');
|
|
193
120
|
* const config = view.getConfig();
|
|
194
|
-
*
|
|
195
|
-
*
|
|
196
|
-
* @example Browser console
|
|
197
|
-
* ```ts
|
|
198
|
-
* console.log((() => {
|
|
199
|
-
* const unitId = `facade_example_${Date.now()}`;
|
|
200
|
-
* const base = univerAPI.createBase({ id: unitId, name: 'Facade Example', schemaVersion: 1, createdAt: Date.now(), updatedAt: Date.now(), tables: {}, tableOrder: [] }, { makeCurrent: false });
|
|
201
|
-
* try {
|
|
202
|
-
* const table = base.createTable({ id: `${unitId}_table`, name: 'Tasks', primaryFieldName: 'Title' });
|
|
203
|
-
* const field = table.addField({ id: `${unitId}_status`, name: 'Status', type: 'singleSelect', config: { options: [{ id: 'todo', name: 'Todo' }, { id: 'done', name: 'Done' }] }, defaultValue: 'todo' });
|
|
204
|
-
* const record = table.addRecord({ id: `${unitId}_record`, values: { [table.getPrimaryFieldId()]: 'Alpha', [field.getId()]: 'todo' } });
|
|
205
|
-
* const view = table.createView({ id: `${unitId}_view`, name: 'Grid', type: 'grid' });
|
|
206
|
-
* return view.getConfig();
|
|
207
|
-
* } finally {
|
|
208
|
-
* univerAPI.disposeUnit(unitId);
|
|
209
|
-
* }
|
|
210
|
-
* })());
|
|
121
|
+
* console.log(config);
|
|
211
122
|
* ```
|
|
212
123
|
*/
|
|
213
|
-
getConfig
|
|
124
|
+
getConfig(): ViewSpecificConfig;
|
|
214
125
|
/**
|
|
215
126
|
* Update the view-specific config.
|
|
216
|
-
*
|
|
217
|
-
*
|
|
218
|
-
* frozen field counts for grid, date field ids for calendar, and timeline
|
|
219
|
-
* field ids for gantt.
|
|
220
|
-
*
|
|
221
|
-
* @param patch Partial config to merge into the existing view config.
|
|
127
|
+
* @param {Partial<ViewSpecificConfig>} patch The config fields to update.
|
|
128
|
+
* @returns {boolean} True if the update succeeded, false if the config was unchanged.
|
|
222
129
|
* @example
|
|
223
130
|
* ```ts
|
|
224
|
-
*
|
|
225
|
-
*
|
|
131
|
+
* const fBase = univerAPI.getActiveBase();
|
|
132
|
+
* const fBaseTable = fBase.getTableById('table-1');
|
|
226
133
|
*
|
|
227
|
-
*
|
|
228
|
-
*
|
|
229
|
-
*
|
|
230
|
-
*
|
|
231
|
-
*
|
|
232
|
-
* try {
|
|
233
|
-
* const table = base.createTable({ id: `${unitId}_table`, name: 'Tasks', primaryFieldName: 'Title' });
|
|
234
|
-
* const field = table.addField({ id: `${unitId}_status`, name: 'Status', type: 'singleSelect', config: { options: [{ id: 'todo', name: 'Todo' }, { id: 'done', name: 'Done' }] }, defaultValue: 'todo' });
|
|
235
|
-
* const record = table.addRecord({ id: `${unitId}_record`, values: { [table.getPrimaryFieldId()]: 'Alpha', [field.getId()]: 'todo' } });
|
|
236
|
-
* const view = table.createView({ id: `${unitId}_view`, name: 'Grid', type: 'grid' });
|
|
237
|
-
* view.updateConfig({ frozenFieldCount: 1 });
|
|
238
|
-
* return view.getConfig();
|
|
239
|
-
* } finally {
|
|
240
|
-
* univerAPI.disposeUnit(unitId);
|
|
241
|
-
* }
|
|
242
|
-
* })());
|
|
134
|
+
* const view = fBaseTable.getViewByName('Grid');
|
|
135
|
+
* const gridConfig = view.getConfig() as IGridViewConfig;
|
|
136
|
+
* gridConfig.frozenFieldCount = 2;
|
|
137
|
+
* const success = view.updateConfig(gridConfig);
|
|
138
|
+
* console.log(success ? 'Config updated' : 'Update failed');
|
|
243
139
|
* ```
|
|
244
140
|
*/
|
|
245
|
-
updateConfig
|
|
141
|
+
updateConfig(patch: Partial<ViewSpecificConfig>): boolean;
|
|
246
142
|
/**
|
|
247
143
|
* Get the view filter.
|
|
248
|
-
* @returns The filter
|
|
144
|
+
* @returns {IFilterConfig | null} The view filter, or `null` if no filter is set.
|
|
249
145
|
* @example
|
|
250
146
|
* ```ts
|
|
251
|
-
* const
|
|
252
|
-
*
|
|
253
|
-
*
|
|
254
|
-
*
|
|
255
|
-
* ```ts
|
|
256
|
-
* console.log((() => {
|
|
257
|
-
* const unitId = `facade_example_${Date.now()}`;
|
|
258
|
-
* const base = univerAPI.createBase({ id: unitId, name: 'Facade Example', schemaVersion: 1, createdAt: Date.now(), updatedAt: Date.now(), tables: {}, tableOrder: [] }, { makeCurrent: false });
|
|
259
|
-
* try {
|
|
260
|
-
* const table = base.createTable({ id: `${unitId}_table`, name: 'Tasks', primaryFieldName: 'Title' });
|
|
261
|
-
* const field = table.addField({ id: `${unitId}_status`, name: 'Status', type: 'singleSelect', config: { options: [{ id: 'todo', name: 'Todo' }, { id: 'done', name: 'Done' }] }, defaultValue: 'todo' });
|
|
262
|
-
* const record = table.addRecord({ id: `${unitId}_record`, values: { [table.getPrimaryFieldId()]: 'Alpha', [field.getId()]: 'todo' } });
|
|
263
|
-
* const view = table.createView({ id: `${unitId}_view`, name: 'Grid', type: 'grid' });
|
|
264
|
-
* return view.getFilter();
|
|
265
|
-
* } finally {
|
|
266
|
-
* univerAPI.disposeUnit(unitId);
|
|
267
|
-
* }
|
|
268
|
-
* })());
|
|
147
|
+
* const fBase = univerAPI.getActiveBase();
|
|
148
|
+
* const fBaseTable = fBase.getTableById('table-1');
|
|
149
|
+
* const view = fBaseTable.getViewByName('Grid');
|
|
150
|
+
* console.log(view.getFilter());
|
|
269
151
|
* ```
|
|
270
152
|
*/
|
|
271
|
-
getFilter():
|
|
153
|
+
getFilter(): IFilterConfig | null;
|
|
272
154
|
/**
|
|
273
155
|
* Set the view filter.
|
|
274
|
-
*
|
|
275
|
-
*
|
|
276
|
-
* such as `table.getRecords({ viewId })` and `base.searchTable(..., { viewId })`.
|
|
277
|
-
*
|
|
278
|
-
* @param filter The filter config, or `null` to clear it.
|
|
156
|
+
* @param {IFilterConfig | null} filter The filter to set, or `null` to clear the filter.
|
|
157
|
+
* @returns {boolean} True if the filter was set, false if the filter was unchanged.
|
|
279
158
|
* @example
|
|
280
159
|
* ```ts
|
|
281
|
-
*
|
|
282
|
-
*
|
|
283
|
-
*
|
|
284
|
-
*
|
|
285
|
-
*
|
|
160
|
+
* const fBase = univerAPI.getActiveBase();
|
|
161
|
+
* const fBaseTable = fBase.getTableById('table-1');
|
|
162
|
+
*
|
|
163
|
+
* const fields = fBaseTable.getFields();
|
|
164
|
+
* const conditions = fields.map((field) => {
|
|
165
|
+
* if (field.getId() === 'status') {
|
|
166
|
+
* return {
|
|
167
|
+
* fieldId: field.getId(),
|
|
168
|
+
* operator: univerAPI.Enum.BaseFilterOperator.IS,
|
|
169
|
+
* operand: 'done',
|
|
170
|
+
* }
|
|
171
|
+
* }
|
|
286
172
|
*
|
|
287
|
-
*
|
|
288
|
-
*
|
|
289
|
-
*
|
|
290
|
-
*
|
|
291
|
-
* const base = univerAPI.createBase({ id: unitId, name: 'Facade Example', schemaVersion: 1, createdAt: Date.now(), updatedAt: Date.now(), tables: {}, tableOrder: [] }, { makeCurrent: false });
|
|
292
|
-
* try {
|
|
293
|
-
* const table = base.createTable({ id: `${unitId}_table`, name: 'Tasks', primaryFieldName: 'Title' });
|
|
294
|
-
* const field = table.addField({ id: `${unitId}_status`, name: 'Status', type: 'singleSelect', config: { options: [{ id: 'todo', name: 'Todo' }, { id: 'done', name: 'Done' }] }, defaultValue: 'todo' });
|
|
295
|
-
* const record = table.addRecord({ id: `${unitId}_record`, values: { [table.getPrimaryFieldId()]: 'Alpha', [field.getId()]: 'todo' } });
|
|
296
|
-
* const view = table.createView({ id: `${unitId}_view`, name: 'Grid', type: 'grid' });
|
|
297
|
-
* view.setFilter({ conjunction: 'and', conditions: [{ fieldId: field.getId(), operator: 'is', value: 'todo' }] });
|
|
298
|
-
* return view.getFilter();
|
|
299
|
-
* } finally {
|
|
300
|
-
* univerAPI.disposeUnit(unitId);
|
|
173
|
+
* return {
|
|
174
|
+
* fieldId: field.getId(),
|
|
175
|
+
* operator: univerAPI.Enum.BaseFilterOperator.IS_NOT,
|
|
176
|
+
* operand: 'done',
|
|
301
177
|
* }
|
|
302
|
-
* })
|
|
178
|
+
* });
|
|
179
|
+
*
|
|
180
|
+
* const view = fBaseTable.getViewByName('Grid');
|
|
181
|
+
* const success = view.setFilter({
|
|
182
|
+
* conjunction: univerAPI.Enum.BaseFilterConjunction.AND,
|
|
183
|
+
* conditions,
|
|
184
|
+
* });
|
|
185
|
+
* console.log(success ? 'Filter set' : 'Set filter failed');
|
|
303
186
|
* ```
|
|
304
187
|
*/
|
|
305
|
-
setFilter(filter:
|
|
188
|
+
setFilter(filter: IFilterConfig | null): boolean;
|
|
306
189
|
/**
|
|
307
190
|
* Get the view sort rules.
|
|
308
|
-
* @returns
|
|
191
|
+
* @returns {ISortConfig[]} The sort rules.
|
|
309
192
|
* @example
|
|
310
193
|
* ```ts
|
|
311
|
-
* const
|
|
312
|
-
*
|
|
313
|
-
*
|
|
314
|
-
*
|
|
315
|
-
* ```ts
|
|
316
|
-
* console.log((() => {
|
|
317
|
-
* const unitId = `facade_example_${Date.now()}`;
|
|
318
|
-
* const base = univerAPI.createBase({ id: unitId, name: 'Facade Example', schemaVersion: 1, createdAt: Date.now(), updatedAt: Date.now(), tables: {}, tableOrder: [] }, { makeCurrent: false });
|
|
319
|
-
* try {
|
|
320
|
-
* const table = base.createTable({ id: `${unitId}_table`, name: 'Tasks', primaryFieldName: 'Title' });
|
|
321
|
-
* const field = table.addField({ id: `${unitId}_status`, name: 'Status', type: 'singleSelect', config: { options: [{ id: 'todo', name: 'Todo' }, { id: 'done', name: 'Done' }] }, defaultValue: 'todo' });
|
|
322
|
-
* const record = table.addRecord({ id: `${unitId}_record`, values: { [table.getPrimaryFieldId()]: 'Alpha', [field.getId()]: 'todo' } });
|
|
323
|
-
* const view = table.createView({ id: `${unitId}_view`, name: 'Grid', type: 'grid' });
|
|
324
|
-
* return view.getSort();
|
|
325
|
-
* } finally {
|
|
326
|
-
* univerAPI.disposeUnit(unitId);
|
|
327
|
-
* }
|
|
328
|
-
* })());
|
|
194
|
+
* const fBase = univerAPI.getActiveBase();
|
|
195
|
+
* const fBaseTable = fBase.getTableById('table-1');
|
|
196
|
+
* const view = fBaseTable.getViewByName('Grid');
|
|
197
|
+
* console.log(view.getSort());
|
|
329
198
|
* ```
|
|
330
199
|
*/
|
|
331
|
-
getSort():
|
|
200
|
+
getSort(): ISortConfig[];
|
|
332
201
|
/**
|
|
333
202
|
* Set the view sort rules.
|
|
334
|
-
*
|
|
335
|
-
*
|
|
336
|
-
* not a display name.
|
|
337
|
-
*
|
|
338
|
-
* @param sort Sort rules. Pass `[]` to clear sorting.
|
|
203
|
+
* @param {ISortConfig[]} sort The sort rules.
|
|
204
|
+
* @returns {boolean} True if the sort was set, false if the sort was unchanged.
|
|
339
205
|
* @example
|
|
340
206
|
* ```ts
|
|
341
|
-
*
|
|
342
|
-
*
|
|
343
|
-
*
|
|
344
|
-
*
|
|
345
|
-
*
|
|
346
|
-
*
|
|
347
|
-
*
|
|
348
|
-
* const base = univerAPI.createBase({ id: unitId, name: 'Facade Example', schemaVersion: 1, createdAt: Date.now(), updatedAt: Date.now(), tables: {}, tableOrder: [] }, { makeCurrent: false });
|
|
349
|
-
* try {
|
|
350
|
-
* const table = base.createTable({ id: `${unitId}_table`, name: 'Tasks', primaryFieldName: 'Title' });
|
|
351
|
-
* const field = table.addField({ id: `${unitId}_status`, name: 'Status', type: 'singleSelect', config: { options: [{ id: 'todo', name: 'Todo' }, { id: 'done', name: 'Done' }] }, defaultValue: 'todo' });
|
|
352
|
-
* const record = table.addRecord({ id: `${unitId}_record`, values: { [table.getPrimaryFieldId()]: 'Alpha', [field.getId()]: 'todo' } });
|
|
353
|
-
* const view = table.createView({ id: `${unitId}_view`, name: 'Grid', type: 'grid' });
|
|
354
|
-
* view.setSort([{ fieldId: table.getPrimaryFieldId(), direction: 'asc' }]);
|
|
355
|
-
* return view.getSort();
|
|
356
|
-
* } finally {
|
|
357
|
-
* univerAPI.disposeUnit(unitId);
|
|
207
|
+
* const fBase = univerAPI.getActiveBase();
|
|
208
|
+
* const fBaseTable = fBase.getTableById('table-1');
|
|
209
|
+
* const view = fBaseTable.getViewByName('Grid');
|
|
210
|
+
* const success = view.setSort([
|
|
211
|
+
* {
|
|
212
|
+
* fieldId: 'priority',
|
|
213
|
+
* direction: univerAPI.Enum.BaseSortDirection.ASC
|
|
358
214
|
* }
|
|
359
|
-
*
|
|
215
|
+
* ]);
|
|
216
|
+
* console.log(success ? 'Sort set' : 'Set sort failed');
|
|
360
217
|
* ```
|
|
361
218
|
*/
|
|
362
|
-
setSort(sort:
|
|
219
|
+
setSort(sort: ISortConfig[]): boolean;
|
|
363
220
|
/**
|
|
364
221
|
* Get the view group rules.
|
|
365
|
-
* @returns
|
|
222
|
+
* @returns {IGroupConfig[]} The group rules.
|
|
366
223
|
* @example
|
|
367
224
|
* ```ts
|
|
368
|
-
* const
|
|
369
|
-
*
|
|
370
|
-
*
|
|
371
|
-
*
|
|
372
|
-
* ```ts
|
|
373
|
-
* console.log((() => {
|
|
374
|
-
* const unitId = `facade_example_${Date.now()}`;
|
|
375
|
-
* const base = univerAPI.createBase({ id: unitId, name: 'Facade Example', schemaVersion: 1, createdAt: Date.now(), updatedAt: Date.now(), tables: {}, tableOrder: [] }, { makeCurrent: false });
|
|
376
|
-
* try {
|
|
377
|
-
* const table = base.createTable({ id: `${unitId}_table`, name: 'Tasks', primaryFieldName: 'Title' });
|
|
378
|
-
* const field = table.addField({ id: `${unitId}_status`, name: 'Status', type: 'singleSelect', config: { options: [{ id: 'todo', name: 'Todo' }, { id: 'done', name: 'Done' }] }, defaultValue: 'todo' });
|
|
379
|
-
* const record = table.addRecord({ id: `${unitId}_record`, values: { [table.getPrimaryFieldId()]: 'Alpha', [field.getId()]: 'todo' } });
|
|
380
|
-
* const view = table.createView({ id: `${unitId}_view`, name: 'Grid', type: 'grid' });
|
|
381
|
-
* return view.getGroup();
|
|
382
|
-
* } finally {
|
|
383
|
-
* univerAPI.disposeUnit(unitId);
|
|
384
|
-
* }
|
|
385
|
-
* })());
|
|
225
|
+
* const fBase = univerAPI.getActiveBase();
|
|
226
|
+
* const fBaseTable = fBase.getTableById('table-1');
|
|
227
|
+
* const view = fBaseTable.getViewByName('Grid');
|
|
228
|
+
* console.log(view.getGroup());
|
|
386
229
|
* ```
|
|
387
230
|
*/
|
|
388
|
-
getGroup():
|
|
231
|
+
getGroup(): IGroupConfig[];
|
|
389
232
|
/**
|
|
390
233
|
* Set the view group rules.
|
|
391
234
|
*
|
|
@@ -395,237 +238,131 @@ export declare class FView {
|
|
|
395
238
|
* @param group Group rules. Pass `[]` to clear grouping.
|
|
396
239
|
* @example
|
|
397
240
|
* ```ts
|
|
398
|
-
*
|
|
399
|
-
*
|
|
400
|
-
*
|
|
401
|
-
*
|
|
402
|
-
*
|
|
403
|
-
*
|
|
404
|
-
*
|
|
405
|
-
* const base = univerAPI.createBase({ id: unitId, name: 'Facade Example', schemaVersion: 1, createdAt: Date.now(), updatedAt: Date.now(), tables: {}, tableOrder: [] }, { makeCurrent: false });
|
|
406
|
-
* try {
|
|
407
|
-
* const table = base.createTable({ id: `${unitId}_table`, name: 'Tasks', primaryFieldName: 'Title' });
|
|
408
|
-
* const field = table.addField({ id: `${unitId}_status`, name: 'Status', type: 'singleSelect', config: { options: [{ id: 'todo', name: 'Todo' }, { id: 'done', name: 'Done' }] }, defaultValue: 'todo' });
|
|
409
|
-
* const record = table.addRecord({ id: `${unitId}_record`, values: { [table.getPrimaryFieldId()]: 'Alpha', [field.getId()]: 'todo' } });
|
|
410
|
-
* const view = table.createView({ id: `${unitId}_view`, name: 'Grid', type: 'grid' });
|
|
411
|
-
* view.setGroup([{ fieldId: field.getId() }]);
|
|
412
|
-
* return view.getGroup();
|
|
413
|
-
* } finally {
|
|
414
|
-
* univerAPI.disposeUnit(unitId);
|
|
241
|
+
* const fBase = univerAPI.getActiveBase();
|
|
242
|
+
* const fBaseTable = fBase.getTableById('table-1');
|
|
243
|
+
* const view = fBaseTable.getViewByName('Grid');
|
|
244
|
+
* const success = view.setGroup([
|
|
245
|
+
* {
|
|
246
|
+
* fieldId: 'status',
|
|
247
|
+
* direction: univerAPI.Enum.BaseSortDirection.ASC
|
|
415
248
|
* }
|
|
416
|
-
*
|
|
249
|
+
* ]);
|
|
250
|
+
* console.log(success ? 'Group set' : 'Set group failed');
|
|
417
251
|
* ```
|
|
418
252
|
*/
|
|
419
|
-
setGroup(group:
|
|
253
|
+
setGroup(group: IGroupConfig[]): boolean;
|
|
420
254
|
/**
|
|
421
255
|
* Get settings for a field in this view.
|
|
422
|
-
* @param fieldId The field id
|
|
423
|
-
* @returns The field settings
|
|
256
|
+
* @param {string} fieldId The field id.
|
|
257
|
+
* @returns {IViewFieldSetting} The field settings, or an empty object if no settings are set.
|
|
424
258
|
* @example
|
|
425
259
|
* ```ts
|
|
260
|
+
* const fBase = univerAPI.getActiveBase();
|
|
261
|
+
* const fBaseTable = fBase.getTableById('table-1');
|
|
262
|
+
* const view = fBaseTable.getViewByName('Grid');
|
|
426
263
|
* const settings = view.getFieldSettings('status');
|
|
427
|
-
*
|
|
428
|
-
*
|
|
429
|
-
* @example Browser console
|
|
430
|
-
* ```ts
|
|
431
|
-
* console.log((() => {
|
|
432
|
-
* const unitId = `facade_example_${Date.now()}`;
|
|
433
|
-
* const base = univerAPI.createBase({ id: unitId, name: 'Facade Example', schemaVersion: 1, createdAt: Date.now(), updatedAt: Date.now(), tables: {}, tableOrder: [] }, { makeCurrent: false });
|
|
434
|
-
* try {
|
|
435
|
-
* const table = base.createTable({ id: `${unitId}_table`, name: 'Tasks', primaryFieldName: 'Title' });
|
|
436
|
-
* const field = table.addField({ id: `${unitId}_status`, name: 'Status', type: 'singleSelect', config: { options: [{ id: 'todo', name: 'Todo' }, { id: 'done', name: 'Done' }] }, defaultValue: 'todo' });
|
|
437
|
-
* const record = table.addRecord({ id: `${unitId}_record`, values: { [table.getPrimaryFieldId()]: 'Alpha', [field.getId()]: 'todo' } });
|
|
438
|
-
* const view = table.createView({ id: `${unitId}_view`, name: 'Grid', type: 'grid' });
|
|
439
|
-
* return view.getFieldSettings(field.getId());
|
|
440
|
-
* } finally {
|
|
441
|
-
* univerAPI.disposeUnit(unitId);
|
|
442
|
-
* }
|
|
443
|
-
* })());
|
|
264
|
+
* console.log(settings);
|
|
444
265
|
* ```
|
|
445
266
|
*/
|
|
446
|
-
getFieldSettings(fieldId: string):
|
|
267
|
+
getFieldSettings(fieldId: string): IViewFieldSetting;
|
|
447
268
|
/**
|
|
448
269
|
* Get visible fields in this view.
|
|
449
|
-
* @returns
|
|
270
|
+
* @returns {FBaseTableField[]} An array of visible fields in this view.
|
|
450
271
|
* @example
|
|
451
272
|
* ```ts
|
|
452
|
-
* const
|
|
453
|
-
*
|
|
454
|
-
*
|
|
455
|
-
*
|
|
456
|
-
* ```ts
|
|
457
|
-
* console.log((() => {
|
|
458
|
-
* const unitId = `facade_example_${Date.now()}`;
|
|
459
|
-
* const base = univerAPI.createBase({ id: unitId, name: 'Facade Example', schemaVersion: 1, createdAt: Date.now(), updatedAt: Date.now(), tables: {}, tableOrder: [] }, { makeCurrent: false });
|
|
460
|
-
* try {
|
|
461
|
-
* const table = base.createTable({ id: `${unitId}_table`, name: 'Tasks', primaryFieldName: 'Title' });
|
|
462
|
-
* const field = table.addField({ id: `${unitId}_status`, name: 'Status', type: 'singleSelect', config: { options: [{ id: 'todo', name: 'Todo' }, { id: 'done', name: 'Done' }] }, defaultValue: 'todo' });
|
|
463
|
-
* const record = table.addRecord({ id: `${unitId}_record`, values: { [table.getPrimaryFieldId()]: 'Alpha', [field.getId()]: 'todo' } });
|
|
464
|
-
* const view = table.createView({ id: `${unitId}_view`, name: 'Grid', type: 'grid' });
|
|
465
|
-
* return view.getVisibleFields().map((field) => field.getName());
|
|
466
|
-
* } finally {
|
|
467
|
-
* univerAPI.disposeUnit(unitId);
|
|
468
|
-
* }
|
|
469
|
-
* })());
|
|
273
|
+
* const fBase = univerAPI.getActiveBase();
|
|
274
|
+
* const fBaseTable = fBase.getTableById('table-1');
|
|
275
|
+
* const view = fBaseTable.getViewByName('Grid');
|
|
276
|
+
* console.log(view.getVisibleFields());
|
|
470
277
|
* ```
|
|
471
278
|
*/
|
|
472
|
-
getVisibleFields():
|
|
279
|
+
getVisibleFields(): FBaseTableField[];
|
|
473
280
|
/**
|
|
474
281
|
* Show or hide a field in this view.
|
|
475
282
|
*
|
|
476
283
|
* This changes only the view-local field setting. The table field remains
|
|
477
284
|
* present and other views are not affected.
|
|
478
285
|
*
|
|
479
|
-
* @param fieldId The field id.
|
|
480
|
-
* @param visible
|
|
286
|
+
* @param {string} fieldId The field id.
|
|
287
|
+
* @param {boolean} visible True to show the field, false to hide it.
|
|
288
|
+
* @returns {boolean} True if the visibility was changed, false if the visibility was unchanged.
|
|
481
289
|
* @example
|
|
482
290
|
* ```ts
|
|
483
|
-
*
|
|
484
|
-
*
|
|
485
|
-
*
|
|
486
|
-
*
|
|
487
|
-
*
|
|
488
|
-
* console.log((() => {
|
|
489
|
-
* const unitId = `facade_example_${Date.now()}`;
|
|
490
|
-
* const base = univerAPI.createBase({ id: unitId, name: 'Facade Example', schemaVersion: 1, createdAt: Date.now(), updatedAt: Date.now(), tables: {}, tableOrder: [] }, { makeCurrent: false });
|
|
491
|
-
* try {
|
|
492
|
-
* const table = base.createTable({ id: `${unitId}_table`, name: 'Tasks', primaryFieldName: 'Title' });
|
|
493
|
-
* const field = table.addField({ id: `${unitId}_status`, name: 'Status', type: 'singleSelect', config: { options: [{ id: 'todo', name: 'Todo' }, { id: 'done', name: 'Done' }] }, defaultValue: 'todo' });
|
|
494
|
-
* const record = table.addRecord({ id: `${unitId}_record`, values: { [table.getPrimaryFieldId()]: 'Alpha', [field.getId()]: 'todo' } });
|
|
495
|
-
* const view = table.createView({ id: `${unitId}_view`, name: 'Grid', type: 'grid' });
|
|
496
|
-
* view.setFieldVisible(field.getId(), false);
|
|
497
|
-
* return view.getVisibleFields().map((field) => field.getId());
|
|
498
|
-
* } finally {
|
|
499
|
-
* univerAPI.disposeUnit(unitId);
|
|
500
|
-
* }
|
|
501
|
-
* })());
|
|
291
|
+
* const fBase = univerAPI.getActiveBase();
|
|
292
|
+
* const fBaseTable = fBase.getTableById('table-1');
|
|
293
|
+
* const view = fBaseTable.getViewByName('Grid');
|
|
294
|
+
* const success = view.setFieldVisible('progress', false);
|
|
295
|
+
* console.log(success ? 'Field visibility changed' : 'Set field visibility failed');
|
|
502
296
|
* ```
|
|
503
297
|
*/
|
|
504
|
-
setFieldVisible(fieldId: string, visible: boolean):
|
|
298
|
+
setFieldVisible(fieldId: string, visible: boolean): boolean;
|
|
505
299
|
/**
|
|
506
300
|
* Set a field width in this view.
|
|
507
|
-
* @param fieldId The field id.
|
|
508
|
-
* @param width The width in pixels
|
|
509
|
-
*
|
|
301
|
+
* @param {string} fieldId The field id.
|
|
302
|
+
* @param {number} width The field width in pixels.
|
|
303
|
+
* @returns {boolean} True if the width was set, false if the width was unchanged.
|
|
510
304
|
* @example
|
|
511
305
|
* ```ts
|
|
512
|
-
*
|
|
513
|
-
*
|
|
514
|
-
*
|
|
515
|
-
*
|
|
516
|
-
*
|
|
517
|
-
* console.log((() => {
|
|
518
|
-
* const unitId = `facade_example_${Date.now()}`;
|
|
519
|
-
* const base = univerAPI.createBase({ id: unitId, name: 'Facade Example', schemaVersion: 1, createdAt: Date.now(), updatedAt: Date.now(), tables: {}, tableOrder: [] }, { makeCurrent: false });
|
|
520
|
-
* try {
|
|
521
|
-
* const table = base.createTable({ id: `${unitId}_table`, name: 'Tasks', primaryFieldName: 'Title' });
|
|
522
|
-
* const field = table.addField({ id: `${unitId}_status`, name: 'Status', type: 'singleSelect', config: { options: [{ id: 'todo', name: 'Todo' }, { id: 'done', name: 'Done' }] }, defaultValue: 'todo' });
|
|
523
|
-
* const record = table.addRecord({ id: `${unitId}_record`, values: { [table.getPrimaryFieldId()]: 'Alpha', [field.getId()]: 'todo' } });
|
|
524
|
-
* const view = table.createView({ id: `${unitId}_view`, name: 'Grid', type: 'grid' });
|
|
525
|
-
* view.setFieldWidth(field.getId(), 240);
|
|
526
|
-
* return view.getFieldSettings(field.getId());
|
|
527
|
-
* } finally {
|
|
528
|
-
* univerAPI.disposeUnit(unitId);
|
|
529
|
-
* }
|
|
530
|
-
* })());
|
|
306
|
+
* const fBase = univerAPI.getActiveBase();
|
|
307
|
+
* const fBaseTable = fBase.getTableById('table-1');
|
|
308
|
+
* const view = fBaseTable.getViewByName('Grid');
|
|
309
|
+
* const success = view.setFieldWidth('title', 240);
|
|
310
|
+
* console.log(success ? 'Field width set' : 'Set field width failed');
|
|
531
311
|
* ```
|
|
532
312
|
*/
|
|
533
|
-
setFieldWidth(fieldId: string, width: number):
|
|
313
|
+
setFieldWidth(fieldId: string, width: number): boolean;
|
|
534
314
|
/**
|
|
535
315
|
* Move a field in this view.
|
|
536
|
-
* @param fieldId The field id.
|
|
537
|
-
* @param target Target position descriptor. Pass exactly one of
|
|
538
|
-
*
|
|
539
|
-
* @param target.
|
|
540
|
-
* @
|
|
316
|
+
* @param {string} fieldId The field id.
|
|
317
|
+
* @param {object} target Target position descriptor. Pass exactly one of `beforeFieldId` or `afterFieldId`.
|
|
318
|
+
* @param {string} [target.beforeFieldId] Optional field id to move this field before.
|
|
319
|
+
* @param {string} [target.afterFieldId] Optional field id to move this field after.
|
|
320
|
+
* @returns {boolean} True if the field was moved, false if the field was already in the target position.
|
|
541
321
|
* @example
|
|
542
322
|
* ```ts
|
|
543
|
-
*
|
|
544
|
-
*
|
|
545
|
-
*
|
|
546
|
-
*
|
|
547
|
-
*
|
|
548
|
-
* console.log((() => {
|
|
549
|
-
* const unitId = `facade_example_${Date.now()}`;
|
|
550
|
-
* const base = univerAPI.createBase({ id: unitId, name: 'Facade Example', schemaVersion: 1, createdAt: Date.now(), updatedAt: Date.now(), tables: {}, tableOrder: [] }, { makeCurrent: false });
|
|
551
|
-
* try {
|
|
552
|
-
* const table = base.createTable({ id: `${unitId}_table`, name: 'Tasks', primaryFieldName: 'Title' });
|
|
553
|
-
* const field = table.addField({ id: `${unitId}_status`, name: 'Status', type: 'singleSelect', config: { options: [{ id: 'todo', name: 'Todo' }, { id: 'done', name: 'Done' }] }, defaultValue: 'todo' });
|
|
554
|
-
* const record = table.addRecord({ id: `${unitId}_record`, values: { [table.getPrimaryFieldId()]: 'Alpha', [field.getId()]: 'todo' } });
|
|
555
|
-
* const view = table.createView({ id: `${unitId}_view`, name: 'Grid', type: 'grid' });
|
|
556
|
-
* view.moveField(field.getId(), { afterFieldId: table.getPrimaryFieldId() });
|
|
557
|
-
* return view.getVisibleFields().map((field) => field.getId());
|
|
558
|
-
* } finally {
|
|
559
|
-
* univerAPI.disposeUnit(unitId);
|
|
560
|
-
* }
|
|
561
|
-
* })());
|
|
323
|
+
* const fBase = univerAPI.getActiveBase();
|
|
324
|
+
* const fBaseTable = fBase.getTableById('table-1');
|
|
325
|
+
* const view = fBaseTable.getViewByName('Grid');
|
|
326
|
+
* const success = view.moveField('status', { afterFieldId: 'title' });
|
|
327
|
+
* console.log(success ? 'Field moved' : 'Move field failed');
|
|
562
328
|
* ```
|
|
563
329
|
*/
|
|
564
330
|
moveField(fieldId: string, target: {
|
|
565
331
|
beforeFieldId?: string;
|
|
566
332
|
afterFieldId?: string;
|
|
567
|
-
}):
|
|
333
|
+
}): boolean;
|
|
568
334
|
/**
|
|
569
335
|
* Move this view relative to another view.
|
|
570
|
-
* @param target Target position descriptor. Pass exactly one of
|
|
571
|
-
*
|
|
572
|
-
* @param target.
|
|
573
|
-
* @
|
|
336
|
+
* @param {object} target Target position descriptor. Pass exactly one of `beforeViewId` or `afterViewId`.
|
|
337
|
+
* @param {string} [target.beforeViewId] Optional view id to move this view before.
|
|
338
|
+
* @param {string} [target.afterViewId] Optional view id to move this view after.
|
|
339
|
+
* @returns {boolean} True if the view was moved, false if the view was already in the target position.
|
|
574
340
|
* @example
|
|
575
341
|
* ```ts
|
|
576
|
-
*
|
|
577
|
-
*
|
|
578
|
-
*
|
|
579
|
-
*
|
|
580
|
-
*
|
|
581
|
-
* console.log((() => {
|
|
582
|
-
* const unitId = `facade_example_${Date.now()}`;
|
|
583
|
-
* const base = univerAPI.createBase({ id: unitId, name: 'Facade Example', schemaVersion: 1, createdAt: Date.now(), updatedAt: Date.now(), tables: {}, tableOrder: [] }, { makeCurrent: false });
|
|
584
|
-
* try {
|
|
585
|
-
* const table = base.createTable({ id: `${unitId}_table`, name: 'Tasks', primaryFieldName: 'Title' });
|
|
586
|
-
* const field = table.addField({ id: `${unitId}_status`, name: 'Status', type: 'singleSelect', config: { options: [{ id: 'todo', name: 'Todo' }, { id: 'done', name: 'Done' }] }, defaultValue: 'todo' });
|
|
587
|
-
* const record = table.addRecord({ id: `${unitId}_record`, values: { [table.getPrimaryFieldId()]: 'Alpha', [field.getId()]: 'todo' } });
|
|
588
|
-
* const view = table.createView({ id: `${unitId}_view`, name: 'Grid', type: 'grid' });
|
|
589
|
-
* const second = table.createView({ id: `${unitId}_view_2`, name: 'Second Grid', type: 'grid' });
|
|
590
|
-
* second.move({ beforeViewId: view.getId() });
|
|
591
|
-
* return table.getViews().map((view) => view.getId());
|
|
592
|
-
* } finally {
|
|
593
|
-
* univerAPI.disposeUnit(unitId);
|
|
594
|
-
* }
|
|
595
|
-
* })());
|
|
342
|
+
* const fBase = univerAPI.getActiveBase();
|
|
343
|
+
* const fBaseTable = fBase.getTableById('table-1');
|
|
344
|
+
* const view = fBaseTable.getViewByName('Grid');
|
|
345
|
+
* const success = view.move({ beforeViewId: 'calendar' });
|
|
346
|
+
* console.log(success ? 'View moved' : 'Move view failed');
|
|
596
347
|
* ```
|
|
597
348
|
*/
|
|
598
349
|
move(target: {
|
|
599
350
|
beforeViewId?: string;
|
|
600
351
|
afterViewId?: string;
|
|
601
|
-
}):
|
|
352
|
+
}): boolean;
|
|
602
353
|
/**
|
|
603
354
|
* Delete this view.
|
|
355
|
+
* @returns {boolean} True if the view was deleted, false if the view was already deleted.
|
|
604
356
|
* @example
|
|
605
357
|
* ```ts
|
|
606
|
-
*
|
|
607
|
-
*
|
|
608
|
-
*
|
|
609
|
-
*
|
|
610
|
-
*
|
|
611
|
-
* console.log((() => {
|
|
612
|
-
* const unitId = `facade_example_${Date.now()}`;
|
|
613
|
-
* const base = univerAPI.createBase({ id: unitId, name: 'Facade Example', schemaVersion: 1, createdAt: Date.now(), updatedAt: Date.now(), tables: {}, tableOrder: [] }, { makeCurrent: false });
|
|
614
|
-
* try {
|
|
615
|
-
* const table = base.createTable({ id: `${unitId}_table`, name: 'Tasks', primaryFieldName: 'Title' });
|
|
616
|
-
* const field = table.addField({ id: `${unitId}_status`, name: 'Status', type: 'singleSelect', config: { options: [{ id: 'todo', name: 'Todo' }, { id: 'done', name: 'Done' }] }, defaultValue: 'todo' });
|
|
617
|
-
* const record = table.addRecord({ id: `${unitId}_record`, values: { [table.getPrimaryFieldId()]: 'Alpha', [field.getId()]: 'todo' } });
|
|
618
|
-
* const view = table.createView({ id: `${unitId}_view`, name: 'Grid', type: 'grid' });
|
|
619
|
-
* const viewId = view.getId();
|
|
620
|
-
* view.delete();
|
|
621
|
-
* return table.getView(viewId);
|
|
622
|
-
* } finally {
|
|
623
|
-
* univerAPI.disposeUnit(unitId);
|
|
624
|
-
* }
|
|
625
|
-
* })());
|
|
358
|
+
* const fBase = univerAPI.getActiveBase();
|
|
359
|
+
* const fBaseTable = fBase.getTableById('table-1');
|
|
360
|
+
* const view = fBaseTable.getViewByName('Grid');
|
|
361
|
+
* const success = view.delete();
|
|
362
|
+
* console.log(success ? 'View deleted' : 'Delete view failed');
|
|
626
363
|
* ```
|
|
627
364
|
*/
|
|
628
|
-
delete():
|
|
365
|
+
delete(): boolean;
|
|
629
366
|
/**
|
|
630
367
|
* Get the projected rows and fields for this view.
|
|
631
368
|
*
|
|
@@ -633,29 +370,15 @@ export declare class FView {
|
|
|
633
370
|
* view's filter, sort, group, field order, visibility, and type-specific
|
|
634
371
|
* config.
|
|
635
372
|
*
|
|
636
|
-
* @returns The
|
|
373
|
+
* @returns {BaseViewProjection} The projected rows and fields.
|
|
637
374
|
* @example
|
|
638
375
|
* ```ts
|
|
639
|
-
* const
|
|
640
|
-
*
|
|
641
|
-
*
|
|
642
|
-
*
|
|
643
|
-
* ```ts
|
|
644
|
-
* console.log((() => {
|
|
645
|
-
* const unitId = `facade_example_${Date.now()}`;
|
|
646
|
-
* const base = univerAPI.createBase({ id: unitId, name: 'Facade Example', schemaVersion: 1, createdAt: Date.now(), updatedAt: Date.now(), tables: {}, tableOrder: [] }, { makeCurrent: false });
|
|
647
|
-
* try {
|
|
648
|
-
* const table = base.createTable({ id: `${unitId}_table`, name: 'Tasks', primaryFieldName: 'Title' });
|
|
649
|
-
* const field = table.addField({ id: `${unitId}_status`, name: 'Status', type: 'singleSelect', config: { options: [{ id: 'todo', name: 'Todo' }, { id: 'done', name: 'Done' }] }, defaultValue: 'todo' });
|
|
650
|
-
* const record = table.addRecord({ id: `${unitId}_record`, values: { [table.getPrimaryFieldId()]: 'Alpha', [field.getId()]: 'todo' } });
|
|
651
|
-
* const view = table.createView({ id: `${unitId}_view`, name: 'Grid', type: 'grid' });
|
|
652
|
-
* return view.getProjection();
|
|
653
|
-
* } finally {
|
|
654
|
-
* univerAPI.disposeUnit(unitId);
|
|
655
|
-
* }
|
|
656
|
-
* })());
|
|
376
|
+
* const fBase = univerAPI.getActiveBase();
|
|
377
|
+
* const fBaseTable = fBase.getTableById('table-1');
|
|
378
|
+
* const view = fBaseTable.getViewByName('Grid');
|
|
379
|
+
* console.log(view.getProjection());
|
|
657
380
|
* ```
|
|
658
381
|
*/
|
|
659
|
-
getProjection():
|
|
382
|
+
getProjection(): BaseViewProjection;
|
|
660
383
|
private _getView;
|
|
661
384
|
}
|