@univerjs-pro/sheets-pivot 0.5.0-alpha.0 → 0.5.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/lib/cjs/facade.js +1 -1
  2. package/lib/cjs/index.js +1 -1
  3. package/lib/cjs/locale/en-US.js +1 -1
  4. package/lib/cjs/locale/fa-IR.js +1 -1
  5. package/lib/cjs/locale/ru-RU.js +1 -1
  6. package/lib/cjs/locale/vi-VN.js +1 -1
  7. package/lib/cjs/locale/zh-CN.js +1 -1
  8. package/lib/cjs/locale/zh-TW.js +1 -1
  9. package/lib/es/facade.js +1 -1
  10. package/lib/es/index.js +1 -1
  11. package/lib/es/locale/en-US.js +1 -1
  12. package/lib/es/locale/fa-IR.js +1 -1
  13. package/lib/es/locale/ru-RU.js +1 -1
  14. package/lib/es/locale/vi-VN.js +1 -1
  15. package/lib/es/locale/zh-CN.js +1 -1
  16. package/lib/es/locale/zh-TW.js +1 -1
  17. package/lib/types/commands/command/add-pivot-field.command.d.ts +11 -0
  18. package/lib/types/commands/command/add-pivot-table-with-config.command.d.ts +3 -0
  19. package/lib/types/commands/command/add-pivot-table.command.d.ts +9 -0
  20. package/lib/types/commands/command/move-pivot-field.command.d.ts +11 -0
  21. package/lib/types/commands/command/pivot-drill-down.command.d.ts +6 -0
  22. package/lib/types/commands/command/remove-pivot-field.command.d.ts +8 -0
  23. package/lib/types/commands/command/set-pivot-collapse.command.d.ts +9 -0
  24. package/lib/types/commands/command/set-pivot-filter.command.d.ts +10 -0
  25. package/lib/types/commands/command/set-pivot-sort.command.d.ts +10 -0
  26. package/lib/types/commands/command/update-pivot-setting.command.d.ts +15 -0
  27. package/lib/types/commands/command/update-pivot-source.command.d.ts +9 -0
  28. package/lib/types/commands/command/update-value-position.command.d.ts +8 -0
  29. package/lib/types/commands/command/util.d.ts +14 -0
  30. package/lib/types/commands/mutations/add-pivot-field.mutation.d.ts +3 -0
  31. package/lib/types/commands/mutations/add-pivot-table.mutation.d.ts +3 -0
  32. package/lib/types/commands/mutations/change-apply-util.d.ts +15 -0
  33. package/lib/types/commands/mutations/pivot-data-communication.mutation.d.ts +7 -0
  34. package/lib/types/commands/mutations/remove-pivot-field.mutation.d.ts +3 -0
  35. package/lib/types/commands/mutations/remove-pivot-table.mutation.d.ts +3 -0
  36. package/lib/types/commands/mutations/rename-pivot-field.mutation.d.ts +3 -0
  37. package/lib/types/commands/mutations/set-pivot-collapse.mutation.d.ts +3 -0
  38. package/lib/types/commands/mutations/set-pivot-field-format.mutation.d.ts +3 -0
  39. package/lib/types/commands/mutations/set-pivot-filter.mutation.d.ts +3 -0
  40. package/lib/types/commands/mutations/set-pivot-option.mutation.d.ts +3 -0
  41. package/lib/types/commands/mutations/set-pivot-position.mutation.d.ts +3 -0
  42. package/lib/types/commands/mutations/set-pivot-sort.mutation.d.ts +3 -0
  43. package/lib/types/commands/mutations/set-pivot-subtotal-type.mutation.d.ts +3 -0
  44. package/lib/types/commands/mutations/update-field-position.mutation.d.ts +3 -0
  45. package/lib/types/commands/mutations/update-pivot-field-source-info.mutation.d.ts +3 -0
  46. package/lib/types/commands/mutations/update-pivot-table-source.mutation.d.ts +3 -0
  47. package/lib/types/commands/mutations/update-value-position.mutation.d.ts +3 -0
  48. package/lib/types/commands/operations/pivot-table-dirty-view.operation.d.ts +3 -0
  49. package/lib/types/common/const.d.ts +64 -0
  50. package/lib/types/const/const.d.ts +107 -0
  51. package/lib/types/const/template.d.ts +885 -0
  52. package/lib/types/const/type.d.ts +525 -0
  53. package/lib/types/controllers/config.schema.d.ts +6 -0
  54. package/lib/types/controllers/const.d.ts +1 -0
  55. package/lib/types/controllers/sheets-pivot-caculate.controller.d.ts +44 -0
  56. package/lib/types/controllers/sheets-pivot-clear.controller.d.ts +12 -0
  57. package/lib/types/controllers/sheets-pivot-interceptor.controller.d.ts +21 -0
  58. package/lib/types/controllers/sheets-pivot-permission.controller.d.ts +7 -0
  59. package/lib/types/controllers/sheets-pivot-ref-range.controller.d.ts +21 -0
  60. package/lib/types/controllers/sheets-pivot-remove-sheet.controller.d.ts +9 -0
  61. package/lib/types/controllers/sheets-pivot-rpc.controller.d.ts +20 -0
  62. package/lib/types/facade/f-pivot-table.d.ts +83 -0
  63. package/lib/types/facade/f-workbook.d.ts +72 -0
  64. package/lib/types/facade/index.d.ts +2 -0
  65. package/lib/types/index.d.ts +52 -1158
  66. package/lib/types/locale/en-US.d.ts +3 -0
  67. package/lib/types/locale/fa-IR.d.ts +3 -0
  68. package/lib/types/locale/ru-RU.d.ts +3 -0
  69. package/lib/types/locale/vi-VN.d.ts +3 -0
  70. package/lib/types/locale/zh-CN.d.ts +31 -0
  71. package/lib/types/locale/zh-TW.d.ts +3 -0
  72. package/lib/types/models/sheets-pivot-config-model.d.ts +58 -0
  73. package/lib/types/models/sheets-pivot-data-field-manager.d.ts +77 -0
  74. package/lib/types/models/sheets-pivot-data-source-model.d.ts +101 -0
  75. package/lib/types/models/sheets-pivot-table-adaptor-model.d.ts +54 -0
  76. package/lib/types/models/view-util.d.ts +16 -0
  77. package/lib/types/plugin.d.ts +17 -0
  78. package/lib/types/services/sheets-pivot-rpc.service.d.ts +11 -0
  79. package/lib/types/services/sheets-pivot-table.service.d.ts +18 -0
  80. package/lib/types/util.d.ts +84 -0
  81. package/lib/umd/facade.js +1 -1
  82. package/lib/umd/index.js +1 -1
  83. package/lib/umd/locale/en-US.js +1 -1
  84. package/lib/umd/locale/fa-IR.js +1 -1
  85. package/lib/umd/locale/ru-RU.js +1 -1
  86. package/lib/umd/locale/vi-VN.js +1 -1
  87. package/lib/umd/locale/zh-CN.js +1 -1
  88. package/lib/umd/locale/zh-TW.js +1 -1
  89. package/package.json +14 -14
@@ -0,0 +1,83 @@
1
+ import { Injector, Nullable } from '@univerjs/core';
2
+ import { IPivotTableSortInfo, PivotSubtotalTypeEnum, PivotTableFiledAreaEnum, PivotTableValuePositionEnum } from '@univerjs-pro/engine-pivot';
3
+ import { IPivotTableConfig } from '@univerjs-pro/sheets-pivot';
4
+ export declare class FPivotTable {
5
+ unitId: string;
6
+ subUnitId: string;
7
+ pivotTableId: string;
8
+ private _injector;
9
+ constructor(unitId: string, subUnitId: string, pivotTableId: string, injector: Injector);
10
+ /**
11
+ * @description Get the pivot table config by the pivot table id.
12
+ * @typedef NPivotTableConfig
13
+ * @property {TargetInfo} targetCellInfo The target cell info of the pivot table.
14
+ * @property {SourceInfo} sourceRangeInfo The source data range info of the pivot table.
15
+ * @property {boolean} isEmpty The pivot table is empty or not.
16
+ * @property {object} fieldsConfig The snapshot of the pivot table fields config.
17
+ * @returns {PivotTableConfig|undefined} The pivot table config or undefined.
18
+ */
19
+ getConfig(): Nullable<IPivotTableConfig>;
20
+ /**
21
+ * @description Remove a pivot table from the workbook by pivot table id
22
+ */
23
+ remove(): Promise<boolean>;
24
+ /**
25
+ *@description Add a pivot field to the pivot table.
26
+ * @param {string|number} dataFieldIdOrIndex The data field id.
27
+ * @param {PivotTableFiledAreaEnum} fieldArea The area of the field.
28
+ * @param {number} index The index of the field in the target area.
29
+ * @returns {boolean} Whether the pivot field is added successfully.
30
+ */
31
+ addField(dataFieldIdOrIndex: string | number, fieldArea: PivotTableFiledAreaEnum, index: number): Promise<boolean>;
32
+ /**
33
+ * @description Remove a pivot field from the pivot table
34
+ * @param {string[]} fieldIds The deleted field ids.
35
+ * @returns {boolean} Whether the pivot field is removed successfully.
36
+ */
37
+ removeField(fieldIds: string[]): Promise<boolean>;
38
+ /**
39
+ * @description Update the pivot table field position.
40
+ * @param {string} fieldId - The moved field id.
41
+ * @param {PivotTableFiledAreaEnum} area - The target area of the field.
42
+ * @param {number} index - The target index of the field, if the index is bigger than the field count in the target area, the field will be moved to the last, if the index is smaller than 0, the field will be moved to the first.
43
+ * @returns {boolean} Whether the pivot field is moved successfully.
44
+ */
45
+ updateFieldPosition(fieldId: string, area: PivotTableFiledAreaEnum, index: number): Promise<boolean>;
46
+ /**
47
+ * @description If there are multiple value fields in the pivot table, you can update the position of the value field, which only can be position in row or column.
48
+ * @param {PivotTableValuePositionEnum} position - The position of the value field.
49
+ * @param {number} index - The index of the value field.
50
+ * @returns {boolean} Whether the pivot value field is moved successfully.
51
+ */
52
+ updateValuePosition(position: PivotTableValuePositionEnum, index: number): Promise<boolean>;
53
+ /**
54
+ * @description Set the pivot table subtotal type for value field, it only works for the value field.
55
+ * @param {string} fieldId - The field id.
56
+ * @param {PivotSubtotalTypeEnum} subtotalType - The subtotal type of the field.
57
+ * @returns {boolean} Whether the pivot table subtotal type is set successfully.
58
+ */
59
+ setSubtotalType(fieldId: string, subtotalType: PivotSubtotalTypeEnum): Promise<boolean>;
60
+ /**
61
+ * @description Set the pivot table sort info.
62
+ * @param {string} tableFieldId - The field id of the sort.
63
+ * @param {PivotTableSortInfo} info - The sort info.
64
+ * @typedef PivotTableSortInfo
65
+ * @property {PivotDataFieldSortOperatorEnum} type The sort operator of the field items.
66
+ * @returns {boolean} Whether the pivot table sort info is set successfully.
67
+ */
68
+ setLabelSort(tableFieldId: string, info: IPivotTableSortInfo): Promise<boolean>;
69
+ /**
70
+ * @description Set the pivot table manual filter.
71
+ * @param {string} tableFieldId - The field id of the filter.
72
+ * @param {string[]} items - The items of the filter.
73
+ * @returns {boolean} Whether the pivot table filter is set successfully.
74
+ */
75
+ setLabelManualFilter(tableFieldId: string, items: string[], isAll?: boolean): Promise<boolean>;
76
+ /**
77
+ * @description Rename the pivot table field.
78
+ * @param {string} fieldId - The field id.
79
+ * @param {string} name - The new name of the field.
80
+ * @returns {boolean} Whether the pivot table field is renamed successfully.
81
+ */
82
+ renameField(fieldId: string, name: string): Promise<boolean>;
83
+ }
@@ -0,0 +1,72 @@
1
+ import { IUnitRangeName } from '@univerjs/core';
2
+ import { IPivotCellPositionInfo, PositionType } from '@univerjs-pro/sheets-pivot';
3
+ import { FPivotTable } from './f-pivot-table';
4
+ interface IFWorkbookSheetsPivotMixin {
5
+ /**
6
+ * @description Add a pivot table to the Workbook.
7
+ * @typedef SourceInfo
8
+ * @property {string} unitId - The unit id of the source data.
9
+ * @property {string} subUnitId - The sub unit id of the source data.
10
+ * @property {string} sheetName - The sheet name of the source data.
11
+ * @property {IRange} range - The range of the source data.
12
+ * @typedef AnchorCellInfo - The target cell info of the pivot table.
13
+ * @property {string} unitId - The unit id of the target data.
14
+ * @property {string} subUnitId - The sub unit id of the target data.
15
+ * @property {number} row - The range of the target data.
16
+ * @property {number} col - The range of the target data.
17
+ * @param {SourceInfo} sourceInfo The source data range info of the pivot table.
18
+ * @param {PositionType} positionType whether new a sheet or insert a pivot table to the existing sheet.
19
+ * @param {AnchorCellInfo} anchorCellInfo The target cell info of the pivot table.
20
+ * @returns {string|undefined} The added pivot table id.
21
+ * @example
22
+ * ```typescript
23
+ * // should ensure the sheet range {0,0,8,6} is not empty
24
+ * const fWorkbook = univerAPI.getActiveWorkbook()
25
+ * const unitId = fWorkbook.getId()
26
+ * const fSheet = fWorkbook.getActiveSheet();
27
+ * const subUnitId = fSheet.getSheetId()
28
+ * const sheetName = fSheet.getSheetName();
29
+ * const sourceInfo = {
30
+ * unitId,
31
+ * subUnitId,
32
+ * sheetName,
33
+ * range: {
34
+ * startRow: 0,
35
+ * endRow: 8,
36
+ * startColumn: 0,
37
+ * endColumn: 6
38
+ * }
39
+ * }
40
+ * const anchorCellInfo = {
41
+ * unitId,
42
+ * subUnitId,
43
+ * row: 0,
44
+ * col: 8
45
+ * }
46
+ * const fp = await fWorkbook.addPivotTable(sourceInfo, 'exiting', anchorCellInfo)
47
+ * // the addPivotTable is async, you can add pivot fields after the pivot table is added
48
+ * // in the future, we will support pivot table added event, you can add pivot fields in the event handler
49
+ * setTimeout(function() {
50
+ * fp.addField(1, 2)
51
+ * fp.addField(1, 3)
52
+ * }, 1000)
53
+ * ```
54
+ */
55
+ addPivotTable(sourceInfo: IUnitRangeName & {
56
+ subUnitId: string;
57
+ }, positionType: PositionType, anchorCellInfo: IPivotCellPositionInfo): Promise<FPivotTable | undefined>;
58
+ /**
59
+ * @description Get the pivot table id by the cell.
60
+ * @param {string} unitId The unit id of workbook.
61
+ * @param {string} subUnitId The sheet id, which pivot table belongs to.
62
+ * @param {number} row The checked row.
63
+ * @param {number} col The checked column.
64
+ * @returns {string|undefined} The pivot table id or undefined.
65
+ */
66
+ getPivotTableByCell(unitId: string, subUnitId: string, row: number, col: number): FPivotTable | undefined;
67
+ }
68
+ declare module '@univerjs/sheets/facade' {
69
+ interface FWorkbook extends IFWorkbookSheetsPivotMixin {
70
+ }
71
+ }
72
+ export {};
@@ -0,0 +1,2 @@
1
+ import './f-workbook';
2
+ export { FPivotTable } from './f-pivot-table';