@univerjs-pro/bases 1.0.0-alpha.7 → 1.0.0-alpha.8
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/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/controllers/base-formula-calculation.controller.d.ts +6 -1
- package/lib/types/facade/f-base.d.ts +3 -2
- package/lib/types/facade/f-enum.d.ts +72 -5
- package/lib/types/facade/f-field.d.ts +37 -4
- package/lib/types/facade/f-record.d.ts +52 -1
- package/lib/types/facade/f-table.d.ts +43 -9
- package/lib/types/facade/index.d.ts +2 -1
- package/lib/types/fields/field-core-plugin.d.ts +0 -1
- package/lib/types/fields/number-format.d.ts +3 -3
- package/lib/types/index.d.ts +2 -2
- package/lib/types/models/default-table.d.ts +0 -1
- package/lib/types/ot/json1-adapter.d.ts +0 -1
- package/lib/types/ot/json1-op-factory.d.ts +0 -3
- package/lib/types/search/base-search.d.ts +0 -3
- package/lib/types/services/base-active-dirty.service.d.ts +0 -1
- package/lib/types/services/base-command.service.d.ts +0 -1
- package/lib/types/services/base-compression.service.d.ts +0 -5
- package/lib/types/services/base-formula.service.d.ts +1 -3
- package/lib/types/services/base-permission.service.d.ts +0 -4
- package/lib/types/views/view-core-plugin.d.ts +0 -2
- 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 -6
- package/lib/types/facade/f-types.d.ts +0 -1
package/lib/locale/zh-TW.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
const _0x564dec=_0x3e86;function _0x4939(){const _0x288876=['創建人','484VWJIQa','記錄\x20ID','577460FBNLPF','日曆需要日期字段','雙向關聯','甘特視圖需要開始和結束日期字段','18zyUOqu','創建時間','1881003ixENKL','輸入內容','修改人','2406985VQhfgJ','更新時間','173105WWUABD','電話號碼','看板需要可分組字段','164916JnVIph','刪除記錄','1927944jSQktR','8xdPepI','更新視圖設置','32361yUjZFR','9EQFbxd','40oEgteH','創建字段','刪除字段','創建記錄','複選框','字段類型無效','輸入\x20URL(例如\x20univer.ai\x20或\x20https://univer.ai/skills)。'];_0x4939=function(){return _0x288876;};return _0x4939();}function _0x3e86(_0x2fb346,_0x1d0c63){_0x2fb346=_0x2fb346-0xf9;const _0x4939bb=_0x4939();let _0x3e86b5=_0x4939bb[_0x2fb346];return _0x3e86b5;}(function(_0x474408,_0x491b15){const _0x271ec7=_0x3e86,_0xa62d46=_0x474408();while(!![]){try{const _0x2ea46e=parseInt(_0x271ec7(0x108))/0x1*(parseInt(_0x271ec7(0x10a))/0x2)+parseInt(_0x271ec7(0xfb))/0x3+-parseInt(_0x271ec7(0x105))/0x4+parseInt(_0x271ec7(0x100))/0x5*(-parseInt(_0x271ec7(0xf9))/0x6)+parseInt(_0x271ec7(0xfe))/0x7*(parseInt(_0x271ec7(0x106))/0x8)+parseInt(_0x271ec7(0x109))/0x9*(-parseInt(_0x271ec7(0x114))/0xa)+parseInt(_0x271ec7(0x112))/0xb*(-parseInt(_0x271ec7(0x103))/0xc);if(_0x2ea46e===_0x491b15)break;else _0xa62d46['push'](_0xa62d46['shift']());}catch(_0x4153a9){_0xa62d46['push'](_0xa62d46['shift']());}}}(_0x4939,0x5a47d));const e={'bases':{'fieldType':{'text':'文本','singleSelect':'單選','multiSelect':'多選','person':'人員','group':'分組','date':'日期','attachment':'附件','number':'數字','checkbox':_0x564dec(0x10e),'link':'鏈接','formula':'公式','lookup':'查找','flow':'流程','button':'按鈕','numbering':'編號','phone':_0x564dec(0x101),'email':'郵箱','location':'位置','barcode':'條碼','progress':'進度','currency':'貨幣','rating':'評分','twoWayLink':_0x564dec(0x116),'recordId':_0x564dec(0x113),'createdBy':_0x564dec(0x111),'updatedBy':_0x564dec(0xfd),'createdAt':_0x564dec(0xfa),'updatedAt':_0x564dec(0xff),'summary':'彙總'},'fieldConfig':{'textPlaceholder':_0x564dec(0xfc),'linkPlaceholder':_0x564dec(0x110)},'viewType':{'grid':'表格','kanban':'看板','calendar':'日曆','gantt':'甘特','gallery':'畫廊'},'error':{'fieldNameRequired':'字段標題不能為空','invalidFieldType':_0x564dec(0x10f),'invalidCellValue':'單元格值無效','invalidKanbanGroupField':_0x564dec(0x102),'invalidCalendarDateField':_0x564dec(0x115),'invalidGanttDateField':_0x564dec(0x117)},'command':{'updateCell':'更新單元格','createField':_0x564dec(0x10b),'deleteField':_0x564dec(0x10c),'createRecord':_0x564dec(0x10d),'deleteRecord':_0x564dec(0x104),'updateViewConfig':_0x564dec(0x107)}}};export{e as default};
|
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
import { FormulaCalculationTriggerService } from '@univerjs-pro/engine-formula';
|
|
2
2
|
import { Disposable, ICommandService, IUniverInstanceService } from '@univerjs/core';
|
|
3
|
+
import { FormulaCalculationSessionService } from '@univerjs/engine-formula';
|
|
3
4
|
export declare class BaseFormulaCalculationController extends Disposable {
|
|
4
5
|
private readonly _commandService;
|
|
5
6
|
private readonly _univerInstanceService;
|
|
7
|
+
protected readonly _formulaCalculationTriggerService: FormulaCalculationTriggerService;
|
|
8
|
+
private readonly _formulaCalculationSessionService;
|
|
6
9
|
private readonly _formulaService;
|
|
7
10
|
private readonly _registeredSuperTableNames;
|
|
11
|
+
private readonly _scheduledSuperTableSyncs;
|
|
8
12
|
private _formulaSyncQueue;
|
|
9
13
|
private _applyingFormulaResults;
|
|
10
|
-
constructor(_commandService: ICommandService, _univerInstanceService: IUniverInstanceService,
|
|
14
|
+
constructor(_commandService: ICommandService, _univerInstanceService: IUniverInstanceService, _formulaCalculationTriggerService: FormulaCalculationTriggerService, _formulaCalculationSessionService: FormulaCalculationSessionService);
|
|
11
15
|
private _initialize;
|
|
12
16
|
private _onCommandExecuted;
|
|
17
|
+
private _scheduleSuperTableSync;
|
|
13
18
|
private _syncSuperTables;
|
|
14
19
|
private _removeSuperTables;
|
|
15
20
|
private _enqueueFormulaSync;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { BaseDataModel, IBaseSnapshot, ITableSnapshot } from '@univerjs/core';
|
|
2
2
|
import type { IBaseTableSchemaSnapshot } from './f-table';
|
|
3
|
-
import { Injector } from '@univerjs/core';
|
|
3
|
+
import { Injector, IResourceLoaderService } from '@univerjs/core';
|
|
4
4
|
import { FBaseTable } from './f-table';
|
|
5
5
|
export interface IBaseSchemaSnapshot {
|
|
6
6
|
id: string;
|
|
@@ -13,7 +13,8 @@ export interface IBaseSchemaSnapshot {
|
|
|
13
13
|
export declare class FBase {
|
|
14
14
|
private readonly _base;
|
|
15
15
|
protected readonly _injector: Injector;
|
|
16
|
-
|
|
16
|
+
private readonly _resourceLoaderService;
|
|
17
|
+
constructor(_base: BaseDataModel, _injector: Injector, _resourceLoaderService: IResourceLoaderService);
|
|
17
18
|
/**
|
|
18
19
|
* Get the underlying Base data model.
|
|
19
20
|
* @returns {BaseDataModel} The underlying Base data model.
|
|
@@ -3,13 +3,80 @@ import { FEnum } from '@univerjs/core/facade';
|
|
|
3
3
|
import { BaseFieldKeyEnum } from './field-key';
|
|
4
4
|
export interface IFBaseEnumMixin {
|
|
5
5
|
/**
|
|
6
|
-
* Base field types.
|
|
7
|
-
*
|
|
6
|
+
* Base field types. The Base plugin currently exposes the 21 field types demonstrated below.
|
|
7
|
+
* Other enum members are reserved for field plugins that are not enabled by default.
|
|
8
|
+
* @example Create and populate every field type exposed by the Base UI
|
|
8
9
|
* ```ts
|
|
9
10
|
* const fBase = univerAPI.getActiveBase();
|
|
10
|
-
*
|
|
11
|
-
* const
|
|
12
|
-
*
|
|
11
|
+
* if (!fBase) throw new Error('No active Base.');
|
|
12
|
+
* const table = fBase.insertTable(`Field examples ${Date.now()}`, { primaryFieldName: 'Title' });
|
|
13
|
+
* const title = table.getPrimaryField(); // Primary fields are Text fields.
|
|
14
|
+
* if (title.getType() !== univerAPI.Enum.BaseFieldType.Text) throw new Error('Expected a Text primary field.');
|
|
15
|
+
*
|
|
16
|
+
* table.addField('Status', univerAPI.Enum.BaseFieldType.SingleSelect, {
|
|
17
|
+
* field: { config: { options: [{ id: 'todo', name: 'Todo', color: 'blue' }, { id: 'done', name: 'Done', color: 'green' }] } }
|
|
18
|
+
* });
|
|
19
|
+
* table.addField('Tags', univerAPI.Enum.BaseFieldType.MultiSelect, {
|
|
20
|
+
* field: { config: { options: [{ id: 'api', name: 'API', color: 'purple' }, { id: 'docs', name: 'Docs', color: 'orange' }] } }
|
|
21
|
+
* });
|
|
22
|
+
* table.addField('Owner', univerAPI.Enum.BaseFieldType.Person, { field: { config: { allowMultiple: false, provider: 'person' } } });
|
|
23
|
+
* table.addField('Teams', univerAPI.Enum.BaseFieldType.Group, { field: { config: { allowMultiple: true, provider: 'group' } } });
|
|
24
|
+
* table.addField('Due Date', univerAPI.Enum.BaseFieldType.Date, { field: { config: { pattern: 'yyyy/mm/dd', includeTime: false } } });
|
|
25
|
+
* const attachments = table.addField('Attachments', univerAPI.Enum.BaseFieldType.Attachment);
|
|
26
|
+
* table.addField('Amount', univerAPI.Enum.BaseFieldType.Number, { field: { config: { pattern: '#,##0.00', decimalPlaces: 2 } } });
|
|
27
|
+
* table.addField('Approved', univerAPI.Enum.BaseFieldType.Checkbox);
|
|
28
|
+
* table.addField('Website', univerAPI.Enum.BaseFieldType.Link);
|
|
29
|
+
* table.addField('Phone', univerAPI.Enum.BaseFieldType.Phone);
|
|
30
|
+
* table.addField('Email', univerAPI.Enum.BaseFieldType.Email);
|
|
31
|
+
* table.addField('Progress', univerAPI.Enum.BaseFieldType.Progress, { field: { config: { start: 0, end: 100 } } });
|
|
32
|
+
* table.addField('Budget', univerAPI.Enum.BaseFieldType.Currency, { field: { config: { currencySymbol: '$', decimalPlaces: 2 } } });
|
|
33
|
+
* table.addField('Rating', univerAPI.Enum.BaseFieldType.Rating, { field: { config: { min: 1, max: 5 } } });
|
|
34
|
+
* const formula = table.addField('Total', univerAPI.Enum.BaseFieldType.Formula, {
|
|
35
|
+
* field: { config: { formula: '=SUM([Amount],[Budget])' } },
|
|
36
|
+
* externalReferences: [], // Required; this formula only uses fields in the Host Base.
|
|
37
|
+
* });
|
|
38
|
+
* const numbering = table.addField('Sequence', univerAPI.Enum.BaseFieldType.Numbering);
|
|
39
|
+
* const createdBy = table.addField('Created By', univerAPI.Enum.BaseFieldType.CreatedBy);
|
|
40
|
+
* const updatedBy = table.addField('Updated By', univerAPI.Enum.BaseFieldType.UpdatedBy);
|
|
41
|
+
* const createdAt = table.addField('Created At', univerAPI.Enum.BaseFieldType.CreatedAt);
|
|
42
|
+
* const updatedAt = table.addField('Updated At', univerAPI.Enum.BaseFieldType.UpdatedAt);
|
|
43
|
+
*
|
|
44
|
+
* const record = table.addRecord({
|
|
45
|
+
* Title: 'Document every field type',
|
|
46
|
+
* Status: 'todo',
|
|
47
|
+
* Tags: ['api', 'docs'],
|
|
48
|
+
* Owner: 'user-1',
|
|
49
|
+
* Teams: ['group-1'],
|
|
50
|
+
* 'Due Date': 45839, // Excel serial for 2025-07-01.
|
|
51
|
+
* Attachments: [], // Populate with record.setAttachments(...) after creating the record.
|
|
52
|
+
* Amount: 1250.5,
|
|
53
|
+
* Approved: true,
|
|
54
|
+
* Website: { text: 'Univer', url: 'https://univer.ai' },
|
|
55
|
+
* Phone: '+1 555 0100',
|
|
56
|
+
* Email: 'agent@example.com',
|
|
57
|
+
* Progress: 75,
|
|
58
|
+
* Budget: 5000,
|
|
59
|
+
* Rating: 4,
|
|
60
|
+
* }, univerAPI.Enum.BaseFieldKeyEnum.Name, { createdBy: 'user-1', updatedBy: 'user-1' });
|
|
61
|
+
*
|
|
62
|
+
* const previewDataUrl = 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==';
|
|
63
|
+
* record.setAttachments(attachments.getId(), [{
|
|
64
|
+
* id: 'local-preview',
|
|
65
|
+
* name: 'preview.gif',
|
|
66
|
+
* mimeType: 'image/gif',
|
|
67
|
+
* sourceType: univerAPI.Enum.ImageSourceType.BASE64,
|
|
68
|
+
* source: previewDataUrl
|
|
69
|
+
* }]);
|
|
70
|
+
*
|
|
71
|
+
* // Formula, numbering, and audit fields are generated and cannot be written directly.
|
|
72
|
+
* console.log({
|
|
73
|
+
* formula: record.getValue(formula.getId()),
|
|
74
|
+
* numbering: record.getValue(numbering.getId()),
|
|
75
|
+
* createdBy: record.getValue(createdBy.getId()),
|
|
76
|
+
* updatedBy: record.getValue(updatedBy.getId()),
|
|
77
|
+
* createdAt: record.getValue(createdAt.getId()),
|
|
78
|
+
* updatedAt: record.getValue(updatedAt.getId()),
|
|
79
|
+
* });
|
|
13
80
|
* ```
|
|
14
81
|
*/
|
|
15
82
|
BaseFieldType: typeof BaseFieldType;
|
|
@@ -1,6 +1,17 @@
|
|
|
1
|
+
import type { IHostExternalReference } from '@univerjs-pro/engine-formula';
|
|
1
2
|
import type { BaseFieldType, FieldConfig, IFieldSnapshot, Injector } from '@univerjs/core';
|
|
2
3
|
import type { FBase } from './f-base';
|
|
3
4
|
import type { FBaseTable } from './f-table';
|
|
5
|
+
import { BaseFieldType as BaseFieldTypeEnum } from '@univerjs/core';
|
|
6
|
+
export interface IBaseFormulaFieldWriteOptions {
|
|
7
|
+
/**
|
|
8
|
+
* Required, complete Host-owned bindings for this formula write.
|
|
9
|
+
*
|
|
10
|
+
* Use `[]` only when the formula has no external Unit qualifier. Include every
|
|
11
|
+
* external Sheet/Base Source referenced by the formula, including dynamic references.
|
|
12
|
+
*/
|
|
13
|
+
externalReferences: readonly IHostExternalReference[];
|
|
14
|
+
}
|
|
4
15
|
/**
|
|
5
16
|
* Facade API object bound to a Base field.
|
|
6
17
|
*
|
|
@@ -155,7 +166,13 @@ export declare class FBaseTableField {
|
|
|
155
166
|
* formula expressions, number/date formatting, and similar field metadata
|
|
156
167
|
* here so formulas and renderers can resolve behavior from the field.
|
|
157
168
|
*
|
|
169
|
+
* Formula fields additionally require `options.externalReferences`. The Facade
|
|
170
|
+
* persists those Host bindings before it updates the field config; if binding
|
|
171
|
+
* fails, the field is left unchanged. Pass `[]` only when the formula references
|
|
172
|
+
* fields in this Host Base and has no external Unit qualifier.
|
|
173
|
+
*
|
|
158
174
|
* @param {FieldConfig} config The new field configuration.
|
|
175
|
+
* @param {IBaseFormulaFieldWriteOptions} [options] Required for Formula fields.
|
|
159
176
|
* @returns {boolean} True if the config update was successful, false otherwise.
|
|
160
177
|
* @example
|
|
161
178
|
* ```ts
|
|
@@ -163,16 +180,22 @@ export declare class FBaseTableField {
|
|
|
163
180
|
* const fBaseTable = fBase.getTableById('table-1');
|
|
164
181
|
* const field = fBaseTable.getFieldByName('Total');
|
|
165
182
|
* const success = field.setConfig({
|
|
166
|
-
* formula: '=SUM(
|
|
183
|
+
* formula: '=SUM([Pricing]!Tax[Amount])',
|
|
167
184
|
* numberFormat: {
|
|
168
185
|
* type: 'currency',
|
|
169
186
|
* pattern: '"$"#,##0.00'
|
|
170
187
|
* },
|
|
188
|
+
* }, {
|
|
189
|
+
* externalReferences: [{
|
|
190
|
+
* qualifier: 'Pricing',
|
|
191
|
+
* sourceUnitId: 'pricing-base',
|
|
192
|
+
* sourceUnitType: univerAPI.Enum.UniverInstanceType.UNIVER_BASE,
|
|
193
|
+
* }],
|
|
171
194
|
* });
|
|
172
195
|
* console.log(success ? 'Field config updated' : 'Failed to update field config');
|
|
173
196
|
* ```
|
|
174
197
|
*/
|
|
175
|
-
setConfig(config: FieldConfig): boolean;
|
|
198
|
+
setConfig(config: FieldConfig, options?: IBaseFormulaFieldWriteOptions): boolean;
|
|
176
199
|
/**
|
|
177
200
|
* Set the default value for this field.
|
|
178
201
|
* @param {IFieldSnapshot['defaultValue']} defaultValue The new default value.
|
|
@@ -189,7 +212,13 @@ export declare class FBaseTableField {
|
|
|
189
212
|
setDefaultValue(defaultValue: IFieldSnapshot['defaultValue']): boolean;
|
|
190
213
|
/**
|
|
191
214
|
* Update this field.
|
|
215
|
+
* When this operation writes Formula config or changes the field type to Formula,
|
|
216
|
+
* `options.externalReferences` is required. Metadata-only updates to an existing
|
|
217
|
+
* Formula field, such as changing its name or description, do not need the mapping
|
|
218
|
+
* again.
|
|
219
|
+
*
|
|
192
220
|
* @param {Partial<IFieldSnapshot>} patch The field snapshot patch to apply.
|
|
221
|
+
* @param {IBaseFormulaFieldWriteOptions} [options] Required when this update writes a Formula field.
|
|
193
222
|
* @returns {boolean} True if the update was successful, false otherwise.
|
|
194
223
|
* @example
|
|
195
224
|
* ```ts
|
|
@@ -203,11 +232,12 @@ export declare class FBaseTableField {
|
|
|
203
232
|
* console.log(success ? 'Field updated' : 'Failed to update field');
|
|
204
233
|
* ```
|
|
205
234
|
*/
|
|
206
|
-
update(patch: Partial<IFieldSnapshot
|
|
235
|
+
update(patch: Partial<IFieldSnapshot>, options?: IBaseFormulaFieldWriteOptions): boolean;
|
|
207
236
|
/**
|
|
208
237
|
* Change this field type.
|
|
209
238
|
* @param {BaseFieldType} type The new field type.
|
|
210
239
|
* @param {FieldConfig} config The new field configuration.
|
|
240
|
+
* @param {IBaseFormulaFieldWriteOptions} [options] Required when `type` is Formula.
|
|
211
241
|
* @returns {boolean} True if the type change was successful, false otherwise.
|
|
212
242
|
* @example
|
|
213
243
|
* ```ts
|
|
@@ -223,7 +253,9 @@ export declare class FBaseTableField {
|
|
|
223
253
|
* console.log(success ? 'Field type changed' : 'Failed to change field type');
|
|
224
254
|
* ```
|
|
225
255
|
*/
|
|
226
|
-
changeType(type:
|
|
256
|
+
changeType(type: BaseFieldTypeEnum.Formula, config: FieldConfig, options: IBaseFormulaFieldWriteOptions): boolean;
|
|
257
|
+
changeType(type: Exclude<BaseFieldType, BaseFieldTypeEnum.Formula>, config?: FieldConfig): boolean;
|
|
258
|
+
changeType(type: BaseFieldType, config: FieldConfig, options: IBaseFormulaFieldWriteOptions): boolean;
|
|
227
259
|
/**
|
|
228
260
|
* Delete this field.
|
|
229
261
|
*
|
|
@@ -261,4 +293,5 @@ export declare class FBaseTableField {
|
|
|
261
293
|
afterFieldId?: string;
|
|
262
294
|
}): boolean;
|
|
263
295
|
private _getField;
|
|
296
|
+
private _writeFormulaExternalReferences;
|
|
264
297
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BaseCellValue, FieldId, Injector, IRecordSnapshot } from '@univerjs/core';
|
|
1
|
+
import type { BaseCellValue, FieldId, IBaseAttachment, Injector, IRecordSnapshot } from '@univerjs/core';
|
|
2
2
|
import type { FBase } from './f-base';
|
|
3
3
|
import type { FBaseTable } from './f-table';
|
|
4
4
|
import { BaseFieldKeyEnum } from './field-key';
|
|
@@ -94,6 +94,57 @@ export declare class FBaseTableRecord {
|
|
|
94
94
|
* ```
|
|
95
95
|
*/
|
|
96
96
|
setValue(fieldId: FieldId, value: BaseCellValue): boolean;
|
|
97
|
+
/**
|
|
98
|
+
* Set the attachments stored in one attachment field through the Base command path.
|
|
99
|
+
* Uploading or encoding the file is intentionally handled by the caller, so this API works in browser and
|
|
100
|
+
* headless environments and participates in collaboration and undo/redo.
|
|
101
|
+
* @param {FieldId} fieldId The attachment field id.
|
|
102
|
+
* @param {IBaseAttachment[]} attachments Attachment descriptors to store. Pass an empty array to clear the field.
|
|
103
|
+
* @returns {boolean} `true` if the undoable command succeeded, `false` otherwise.
|
|
104
|
+
* @example Store the file id returned by a gRPC upload in a headless process
|
|
105
|
+
* ```ts
|
|
106
|
+
* const fBase = univerAPI.getActiveBase();
|
|
107
|
+
* if (!fBase) throw new Error('No active Base.');
|
|
108
|
+
* const table = fBase.getTableById('table-1');
|
|
109
|
+
* if (!table) throw new Error('Table not found.');
|
|
110
|
+
* const record = table.getRecordById('record-1');
|
|
111
|
+
* if (!record) throw new Error('Record not found.');
|
|
112
|
+
*
|
|
113
|
+
* const uploadedFileId = 'file-id-returned-by-grpc';
|
|
114
|
+
* const success = record.setAttachments('attachments', [{
|
|
115
|
+
* id: uploadedFileId,
|
|
116
|
+
* name: 'report.pdf',
|
|
117
|
+
* mimeType: 'application/pdf',
|
|
118
|
+
* sourceType: univerAPI.Enum.ImageSourceType.UUID,
|
|
119
|
+
* source: uploadedFileId
|
|
120
|
+
* }]);
|
|
121
|
+
* console.log(success);
|
|
122
|
+
* ```
|
|
123
|
+
* @example Encode a local file in a Node/headless process and store it directly
|
|
124
|
+
* ```ts
|
|
125
|
+
* import { readFile } from 'node:fs/promises';
|
|
126
|
+
*
|
|
127
|
+
* const fBase = univerAPI.getActiveBase();
|
|
128
|
+
* if (!fBase) throw new Error('No active Base.');
|
|
129
|
+
* const table = fBase.getTableById('table-1');
|
|
130
|
+
* if (!table) throw new Error('Table not found.');
|
|
131
|
+
* const record = table.getRecordById('record-1');
|
|
132
|
+
* if (!record) throw new Error('Record not found.');
|
|
133
|
+
*
|
|
134
|
+
* const file = await readFile('/path/to/hello.txt');
|
|
135
|
+
* const source = `data:text/plain;base64,${file.toString('base64')}`;
|
|
136
|
+
* const success = record.setAttachments('attachments', [{
|
|
137
|
+
* id: `local-${Date.now()}`,
|
|
138
|
+
* name: 'hello.txt',
|
|
139
|
+
* mimeType: 'text/plain',
|
|
140
|
+
* size: file.byteLength,
|
|
141
|
+
* sourceType: univerAPI.Enum.ImageSourceType.BASE64,
|
|
142
|
+
* source
|
|
143
|
+
* }]);
|
|
144
|
+
* console.log(success);
|
|
145
|
+
* ```
|
|
146
|
+
*/
|
|
147
|
+
setAttachments(fieldId: FieldId, attachments: IBaseAttachment[]): boolean;
|
|
97
148
|
/**
|
|
98
149
|
* Set multiple field values in this record.
|
|
99
150
|
* @param {Record<string, BaseCellValue>} values Field-id keyed values to write. Only the provided fields are
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { IBaseTableSearchRequest, IBaseTableSearchResult } from '@univerjs-pro/bases';
|
|
2
|
+
import type { IHostExternalReference } from '@univerjs-pro/engine-formula';
|
|
2
3
|
import type { BaseCellValue, BaseDataModel, BaseFilterOperator, FieldId, IFieldSnapshot, Injector, IRecordSnapshot, ISortConfig, ITableSnapshot, IViewSnapshot } from '@univerjs/core';
|
|
3
4
|
import type { FBase } from './f-base';
|
|
4
5
|
import { BaseFieldType, BaseFilterConjunction, BaseViewType } from '@univerjs/core';
|
|
@@ -46,6 +47,21 @@ export interface IBaseTableSchemaSnapshot {
|
|
|
46
47
|
fields: Array<Pick<IFieldSnapshot, 'id' | 'name' | 'type' | 'config' | 'readonly' | 'description'>>;
|
|
47
48
|
views: Array<Pick<IViewSnapshot, 'id' | 'name' | 'type'>>;
|
|
48
49
|
}
|
|
50
|
+
export interface IBaseAddFieldOptions {
|
|
51
|
+
/** Optional insertion index in the table field order. */
|
|
52
|
+
index?: number;
|
|
53
|
+
/** Optional partial field snapshot to merge into the new field. */
|
|
54
|
+
field?: Partial<Omit<IFieldSnapshot, 'id'>>;
|
|
55
|
+
}
|
|
56
|
+
export interface IBaseAddFormulaFieldOptions extends IBaseAddFieldOptions {
|
|
57
|
+
/**
|
|
58
|
+
* Required, complete Host-owned bindings for this formula write.
|
|
59
|
+
*
|
|
60
|
+
* Use `[]` only when the formula has no external Unit qualifier. Include every
|
|
61
|
+
* external Sheet/Base Source referenced by the formula, including dynamic references.
|
|
62
|
+
*/
|
|
63
|
+
externalReferences: readonly IHostExternalReference[];
|
|
64
|
+
}
|
|
49
65
|
/**
|
|
50
66
|
* Facade API object bound to a Base table.
|
|
51
67
|
*
|
|
@@ -286,6 +302,7 @@ export declare class FBaseTable {
|
|
|
286
302
|
* @param {object} [options] Optional field parameters.
|
|
287
303
|
* @param {number} [options.index] Optional insertion index in the table field order.
|
|
288
304
|
* @param {Partial<Omit<IFieldSnapshot, 'id'>>} [options.field] Optional partial field snapshot to merge into the new field.
|
|
305
|
+
* @param {readonly IHostExternalReference[]} [options.externalReferences] Required when `type` is Formula. Pass `[]` only for a Host-local formula.
|
|
289
306
|
* @returns {FBaseTableField} The new field facade.
|
|
290
307
|
*
|
|
291
308
|
* @example
|
|
@@ -306,7 +323,6 @@ export declare class FBaseTable {
|
|
|
306
323
|
* {
|
|
307
324
|
* index: 1,
|
|
308
325
|
* field: {
|
|
309
|
-
* id: 'status',
|
|
310
326
|
* config: {
|
|
311
327
|
* options: [
|
|
312
328
|
* { id: 'todo', name: 'Todo', color: 'blue' },
|
|
@@ -353,37 +369,55 @@ export declare class FBaseTable {
|
|
|
353
369
|
* config: {
|
|
354
370
|
* formula: '=SUM([Amount],[Tax])'
|
|
355
371
|
* }
|
|
356
|
-
* }
|
|
372
|
+
* },
|
|
373
|
+
* externalReferences: [], // Required; this formula only uses fields in the Host Base.
|
|
357
374
|
* }
|
|
358
375
|
* );
|
|
359
376
|
* ```
|
|
360
377
|
*
|
|
361
|
-
* @example
|
|
378
|
+
* @example Cross-Unit Formula field
|
|
362
379
|
* ```ts
|
|
363
380
|
* const fBase = univerAPI.getActiveBase();
|
|
364
381
|
* const fBaseTable = fBase.getTableById('table-1');
|
|
382
|
+
* const pricingBase = {
|
|
383
|
+
* unitId: 'pricing-base',
|
|
384
|
+
* formulaQualifier: 'Pricing',
|
|
385
|
+
* };
|
|
386
|
+
* const taxAmount = univerAPI.getFormula().buildReference({
|
|
387
|
+
* hostUnitId: fBase.getId(),
|
|
388
|
+
* unit: pricingBase,
|
|
389
|
+
* target: {
|
|
390
|
+
* kind: univerAPI.Enum.FormulaReferenceType.TABLE_COLUMN,
|
|
391
|
+
* tableName: 'Tax Rates',
|
|
392
|
+
* columnName: 'Amount',
|
|
393
|
+
* },
|
|
394
|
+
* });
|
|
365
395
|
* const total = fBaseTable.addField(
|
|
366
396
|
* 'Total',
|
|
367
397
|
* univerAPI.Enum.BaseFieldType.Formula,
|
|
368
398
|
* {
|
|
369
399
|
* field: {
|
|
370
400
|
* config: {
|
|
371
|
-
* formula:
|
|
401
|
+
* formula: `=SUM([Amount])+SUM(${taxAmount})`,
|
|
372
402
|
* numberFormat: {
|
|
373
403
|
* type: 'currency',
|
|
374
404
|
* pattern: '"$"#,##0.00'
|
|
375
405
|
* },
|
|
376
406
|
* },
|
|
377
407
|
* readonly: true,
|
|
378
|
-
* }
|
|
408
|
+
* },
|
|
409
|
+
* externalReferences: [{
|
|
410
|
+
* qualifier: pricingBase.formulaQualifier,
|
|
411
|
+
* sourceUnitId: pricingBase.unitId,
|
|
412
|
+
* sourceUnitType: univerAPI.Enum.UniverInstanceType.UNIVER_BASE,
|
|
413
|
+
* }],
|
|
379
414
|
* }
|
|
380
415
|
* );
|
|
381
416
|
* ```
|
|
382
417
|
*/
|
|
383
|
-
addField(name: string, type: BaseFieldType, options
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
}): FBaseTableField;
|
|
418
|
+
addField(name: string, type: BaseFieldType.Formula, options: IBaseAddFormulaFieldOptions): FBaseTableField;
|
|
419
|
+
addField(name: string, type: Exclude<BaseFieldType, BaseFieldType.Formula>, options?: IBaseAddFieldOptions): FBaseTableField;
|
|
420
|
+
addField(name: string, type: BaseFieldType, options: IBaseAddFieldOptions | IBaseAddFormulaFieldOptions): FBaseTableField;
|
|
387
421
|
/**
|
|
388
422
|
* Get all records in this table, optionally filtered, sorted, and paginated.
|
|
389
423
|
* @returns {FBaseTableRecord[]} An array of record facades ordered by the table record order.
|
|
@@ -4,9 +4,10 @@ export { FBase } from './f-base';
|
|
|
4
4
|
export type { IBaseSchemaSnapshot } from './f-base';
|
|
5
5
|
export * from './f-event';
|
|
6
6
|
export { FBaseTableField } from './f-field';
|
|
7
|
+
export type { IBaseFormulaFieldWriteOptions } from './f-field';
|
|
7
8
|
export { FBaseTableRange } from './f-range';
|
|
8
9
|
export { FBaseTableRecord } from './f-record';
|
|
9
10
|
export { FBaseTable } from './f-table';
|
|
10
|
-
export type { IBaseRecordFilter, IBaseRecordFilterCondition, IBaseTableSchemaSnapshot, IListRecordOptions, IQueryRecordsResult, } from './f-table';
|
|
11
|
+
export type { IBaseAddFieldOptions, IBaseAddFormulaFieldOptions, IBaseRecordFilter, IBaseRecordFilterCondition, IBaseTableSchemaSnapshot, IListRecordOptions, IQueryRecordsResult, } from './f-table';
|
|
11
12
|
export { FBaseTableView } from './f-view';
|
|
12
13
|
export { BaseFieldKeyEnum, resolveBaseFieldKey, resolveBaseFieldValues } from './field-key';
|
|
@@ -26,5 +26,4 @@ export declare function matchesBaseCondition(value: unknown, operator: BaseFilte
|
|
|
26
26
|
config?: FieldConfig;
|
|
27
27
|
}, options?: IBaseConditionMatchOptions): boolean;
|
|
28
28
|
export declare function createCoreFieldPlugins(): IFieldCorePlugin[];
|
|
29
|
-
export type FieldTypePlugin = IFieldTypePlugin;
|
|
30
29
|
export type FieldCorePlugin<TValue extends BaseCellValue = BaseCellValue, TConfig = FieldConfig> = IFieldCorePlugin<TValue, TConfig>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
type BaseSeparatorStyle = 'local' | 'commaPeriod' | 'periodComma' | 'spaceComma' | 'spacePeriod';
|
|
2
|
+
type BaseNumberAbbreviation = 'none' | 'K' | 'M' | 'B';
|
|
3
3
|
export interface IBaseNumberFormatConfig {
|
|
4
4
|
decimalPlaces?: number;
|
|
5
5
|
separatorStyle?: BaseSeparatorStyle | string;
|
|
@@ -12,4 +12,4 @@ export interface IBaseNumberFormatConfig {
|
|
|
12
12
|
export declare function buildBaseNumberFormatPattern(config: IBaseNumberFormatConfig): string;
|
|
13
13
|
export declare function formatBaseNumberValue(value: number, config: IBaseNumberFormatConfig): string;
|
|
14
14
|
export declare function inferBaseSeparatorStyle(locale?: string): Exclude<BaseSeparatorStyle, 'local'>;
|
|
15
|
-
export
|
|
15
|
+
export {};
|
package/lib/types/index.d.ts
CHANGED
|
@@ -81,10 +81,10 @@ export { BaseJson1OpFactory } from './ot/json1-op-factory';
|
|
|
81
81
|
export { UniverBasesPlugin, UniverRemoteBasesPlugin, } from './plugin';
|
|
82
82
|
export { searchBaseTable } from './search/base-search';
|
|
83
83
|
export type { IBaseTableSearchRequest } from './search/base-search';
|
|
84
|
-
export type {
|
|
84
|
+
export type { IBaseTableSearchMatch, IBaseTableSearchResult, } from './search/base-search';
|
|
85
85
|
export { IBaseCommandService } from './services/base-command.service';
|
|
86
86
|
export { traceBasePerformance } from './services/base-performance.service';
|
|
87
87
|
export { IBasePermissionService } from './services/base-permission.service';
|
|
88
|
-
export type {
|
|
88
|
+
export type { IBaseFieldPermission, IBasePermissionSnapshot, IBaseRecordPermission, IBaseTablePermission, } from './services/base-permission.service';
|
|
89
89
|
export { IBaseProjectionService } from './services/base-projection.service';
|
|
90
90
|
export { IBaseViewRegistryService } from './services/base-view-registry.service';
|
|
@@ -10,4 +10,3 @@ export interface ICreateDefaultBaseTableSnapshotOptions {
|
|
|
10
10
|
now?: number;
|
|
11
11
|
}
|
|
12
12
|
export declare function createDefaultBaseTableSnapshot(options: ICreateDefaultBaseTableSnapshotOptions): ITableSnapshot;
|
|
13
|
-
export type CreateDefaultBaseTableSnapshotOptions = ICreateDefaultBaseTableSnapshotOptions;
|
|
@@ -100,4 +100,3 @@ export declare class BaseJson1Adapter implements IBaseJson1Adapter {
|
|
|
100
100
|
invertOp(snapshot: IBaseSnapshot, op: JSONXActions): JSONXActions;
|
|
101
101
|
getAffectedRanges(op: JSONXActions): IBaseInvalidation[];
|
|
102
102
|
}
|
|
103
|
-
export type BaseCollaborativeOp = IBaseCollaborativeOp;
|
|
@@ -63,6 +63,3 @@ export declare class BaseJson1OpFactory {
|
|
|
63
63
|
private _replaceOptional;
|
|
64
64
|
}
|
|
65
65
|
export declare function renameBaseFormulaTableReferences(formula: string, oldName: string, newName: string): string;
|
|
66
|
-
export type CreateFieldOpInput = ICreateFieldOpInput;
|
|
67
|
-
export type SetRecordValuesPatch = ISetRecordValuesPatch;
|
|
68
|
-
export type SetRangeValuesPatch = ISetRangeValuesPatch;
|
|
@@ -20,6 +20,3 @@ export interface IBaseTableSearchResult {
|
|
|
20
20
|
matches: IBaseTableSearchMatch[];
|
|
21
21
|
}
|
|
22
22
|
export declare function searchBaseTable(request: IBaseTableSearchRequest): IBaseTableSearchResult;
|
|
23
|
-
export type BaseTableSearchRequest = IBaseTableSearchRequest;
|
|
24
|
-
export type BaseTableSearchMatch = IBaseTableSearchMatch;
|
|
25
|
-
export type BaseTableSearchResult = IBaseTableSearchResult;
|
|
@@ -21,4 +21,3 @@ export interface IBaseFormulaDirtyRange {
|
|
|
21
21
|
export type BaseFormulaDirtySuperTableMap = Record<string, Record<string, string>>;
|
|
22
22
|
export declare function setBaseRangeValuesToDirtyRanges(params: IBaseRangeValueDirtyParams): IBaseFormulaDirtyRange[];
|
|
23
23
|
export declare function createBaseStructureDirtySuperTableMap(unitId: string, tableIds: string[]): BaseFormulaDirtySuperTableMap;
|
|
24
|
-
export type BaseFormulaDirtyRange = IBaseFormulaDirtyRange;
|
|
@@ -39,8 +39,3 @@ export declare function isCompressedBaseRangeValuesPayload(payload: unknown): pa
|
|
|
39
39
|
export declare function compressBaseSnapshot(snapshot: IBaseSnapshot): ICompressedBaseSnapshot;
|
|
40
40
|
export declare function decompressBaseSnapshot(snapshot: IBaseSnapshot | ICompressedBaseSnapshot): IBaseSnapshot;
|
|
41
41
|
export declare function isCompressedBaseSnapshot(snapshot: unknown): snapshot is ICompressedBaseSnapshot;
|
|
42
|
-
export type BaseRangeValuesPayload = IBaseRangeValuesPayload;
|
|
43
|
-
export type CompressedBaseRangeValuesPayload = ICompressedBaseRangeValuesPayload;
|
|
44
|
-
export type CompressedBaseCellData = ICompressedBaseCellData;
|
|
45
|
-
export type CompressedBaseTableSnapshot = ICompressedBaseTableSnapshot;
|
|
46
|
-
export type CompressedBaseSnapshot = ICompressedBaseSnapshot;
|
|
@@ -27,7 +27,6 @@ export interface IBaseFormulaCalculationDataset {
|
|
|
27
27
|
unitStylesData: Record<string, Record<string, unknown>>;
|
|
28
28
|
unitSheetNameMap: Record<string, Record<string, string>>;
|
|
29
29
|
}
|
|
30
|
-
export type IBaseFormulaCalculationResult = ISetFormulaCalculationResultMutation;
|
|
31
30
|
export interface IBaseSuperTableRegistration {
|
|
32
31
|
tableId: string;
|
|
33
32
|
tableName: string;
|
|
@@ -55,5 +54,4 @@ export declare class BaseFormulaService {
|
|
|
55
54
|
getStructuredDependencies(formula: string, table: ITableSnapshot, context?: IBaseFormulaContext): IBaseFormulaDependency[];
|
|
56
55
|
}
|
|
57
56
|
export declare function createBaseFormulaCalculationDataset(snapshot: IBaseSnapshot): IBaseFormulaCalculationDataset;
|
|
58
|
-
export declare function createBaseFormulaResultPatches(snapshot: IBaseSnapshot, result:
|
|
59
|
-
export type BaseFormulaValidationResult = IBaseFormulaValidationResult;
|
|
57
|
+
export declare function createBaseFormulaResultPatches(snapshot: IBaseSnapshot, result: ISetFormulaCalculationResultMutation): IBaseFormulaResultPatchGroup[];
|
|
@@ -70,7 +70,3 @@ export declare class BasePermissionService implements IBasePermissionService {
|
|
|
70
70
|
clearRecordPermission(tableId: string, recordId: string): void;
|
|
71
71
|
getSnapshot(): IBasePermissionSnapshot;
|
|
72
72
|
}
|
|
73
|
-
export type BaseTablePermission = IBaseTablePermission;
|
|
74
|
-
export type BaseFieldPermission = IBaseFieldPermission;
|
|
75
|
-
export type BaseRecordPermission = IBaseRecordPermission;
|
|
76
|
-
export type BasePermissionSnapshot = IBasePermissionSnapshot;
|
|
@@ -18,6 +18,4 @@ export interface IViewCorePlugin<TConfig extends ViewSpecificConfig = ViewSpecif
|
|
|
18
18
|
export declare function resolveDefaultBaseCardTitleFieldId(table: ITableSnapshot): string;
|
|
19
19
|
export declare function resolveDefaultBaseCardFieldIds(table: ITableSnapshot, excludedFieldIds?: Array<string | null | undefined>, limit?: number): string[];
|
|
20
20
|
export declare function createCoreViewPlugins(): IViewCorePlugin[];
|
|
21
|
-
export type ProjectionContext = IProjectionContext;
|
|
22
|
-
export type ViewRepairResult = IViewRepairResult;
|
|
23
21
|
export type ViewCorePlugin<TConfig extends ViewSpecificConfig = ViewSpecificConfig> = IViewCorePlugin<TConfig>;
|