@visactor/vtable 0.10.2-alpha.3 → 0.10.2

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 (103) hide show
  1. package/cjs/ListTable.d.ts +2 -1
  2. package/cjs/ListTable.js +6 -0
  3. package/cjs/ListTable.js.map +1 -1
  4. package/cjs/PivotChart.d.ts +1 -0
  5. package/cjs/PivotChart.js +3 -2
  6. package/cjs/PivotChart.js.map +1 -1
  7. package/cjs/PivotTable.d.ts +2 -1
  8. package/cjs/PivotTable.js +8 -2
  9. package/cjs/PivotTable.js.map +1 -1
  10. package/cjs/components/axis/axis.js +4 -0
  11. package/cjs/components/axis/axis.js.map +1 -1
  12. package/cjs/components/legend/continue-legend/continue-legend.d.ts +24 -0
  13. package/cjs/components/legend/continue-legend/continue-legend.js +93 -0
  14. package/cjs/components/legend/continue-legend/continue-legend.js.map +1 -0
  15. package/cjs/components/legend/continue-legend/get-continue-legend-attributes.d.ts +5 -0
  16. package/cjs/components/legend/continue-legend/get-continue-legend-attributes.js +139 -0
  17. package/cjs/components/legend/continue-legend/get-continue-legend-attributes.js.map +1 -0
  18. package/cjs/components/legend/create-legend.d.ts +5 -0
  19. package/cjs/components/legend/create-legend.js +14 -0
  20. package/cjs/components/legend/create-legend.js.map +1 -0
  21. package/{es/components/legend/legend.d.ts → cjs/components/legend/discrete-legend/discrete-legend.d.ts} +6 -6
  22. package/cjs/components/legend/{legend.js → discrete-legend/discrete-legend.js} +6 -6
  23. package/cjs/components/legend/discrete-legend/discrete-legend.js.map +1 -0
  24. package/cjs/components/legend/discrete-legend/get-discrete-legend-attributes.d.ts +5 -0
  25. package/cjs/components/legend/{get-legend-attributes.js → discrete-legend/get-discrete-legend-attributes.js} +2 -2
  26. package/cjs/components/legend/discrete-legend/get-discrete-legend-attributes.js.map +1 -0
  27. package/cjs/core/BaseTable.d.ts +1 -1
  28. package/cjs/core/BaseTable.js +4 -10
  29. package/cjs/core/BaseTable.js.map +1 -1
  30. package/cjs/core/TABLE_EVENT_TYPE.d.ts +1 -0
  31. package/cjs/core/TABLE_EVENT_TYPE.js +1 -0
  32. package/cjs/core/TABLE_EVENT_TYPE.js.map +1 -1
  33. package/cjs/dataset/dataset.d.ts +11 -8
  34. package/cjs/dataset/dataset.js +14 -3
  35. package/cjs/dataset/dataset.js.map +1 -1
  36. package/cjs/event/listener/table-group.js +42 -49
  37. package/cjs/event/listener/table-group.js.map +1 -1
  38. package/cjs/index.d.ts +1 -1
  39. package/cjs/index.js +1 -1
  40. package/cjs/index.js.map +1 -1
  41. package/cjs/ts-types/base-table.d.ts +3 -2
  42. package/cjs/ts-types/base-table.js.map +1 -1
  43. package/cjs/ts-types/component/legend.d.ts +15 -2
  44. package/cjs/ts-types/component/legend.js.map +1 -1
  45. package/cjs/ts-types/events.d.ts +6 -0
  46. package/cjs/ts-types/events.js.map +1 -1
  47. package/cjs/ts-types/table-engine.js.map +1 -1
  48. package/dist/vtable.js +1118 -26
  49. package/dist/vtable.min.js +3 -3
  50. package/es/ListTable.d.ts +2 -1
  51. package/es/ListTable.js +6 -0
  52. package/es/ListTable.js.map +1 -1
  53. package/es/PivotChart.d.ts +1 -0
  54. package/es/PivotChart.js +3 -2
  55. package/es/PivotChart.js.map +1 -1
  56. package/es/PivotTable.d.ts +2 -1
  57. package/es/PivotTable.js +8 -2
  58. package/es/PivotTable.js.map +1 -1
  59. package/es/components/axis/axis.js +4 -0
  60. package/es/components/axis/axis.js.map +1 -1
  61. package/es/components/legend/continue-legend/continue-legend.d.ts +24 -0
  62. package/es/components/legend/continue-legend/continue-legend.js +91 -0
  63. package/es/components/legend/continue-legend/continue-legend.js.map +1 -0
  64. package/es/components/legend/continue-legend/get-continue-legend-attributes.d.ts +5 -0
  65. package/es/components/legend/continue-legend/get-continue-legend-attributes.js +132 -0
  66. package/es/components/legend/continue-legend/get-continue-legend-attributes.js.map +1 -0
  67. package/es/components/legend/create-legend.d.ts +5 -0
  68. package/es/components/legend/create-legend.js +8 -0
  69. package/es/components/legend/create-legend.js.map +1 -0
  70. package/{cjs/components/legend/legend.d.ts → es/components/legend/discrete-legend/discrete-legend.d.ts} +6 -6
  71. package/es/components/legend/{legend.js → discrete-legend/discrete-legend.js} +5 -5
  72. package/es/components/legend/discrete-legend/discrete-legend.js.map +1 -0
  73. package/es/components/legend/discrete-legend/get-discrete-legend-attributes.d.ts +5 -0
  74. package/es/components/legend/{get-legend-attributes.js → discrete-legend/get-discrete-legend-attributes.js} +3 -3
  75. package/es/components/legend/discrete-legend/get-discrete-legend-attributes.js.map +1 -0
  76. package/es/core/BaseTable.d.ts +1 -1
  77. package/es/core/BaseTable.js +4 -10
  78. package/es/core/BaseTable.js.map +1 -1
  79. package/es/core/TABLE_EVENT_TYPE.d.ts +1 -0
  80. package/es/core/TABLE_EVENT_TYPE.js +1 -0
  81. package/es/core/TABLE_EVENT_TYPE.js.map +1 -1
  82. package/es/dataset/dataset.d.ts +11 -8
  83. package/es/dataset/dataset.js +13 -3
  84. package/es/dataset/dataset.js.map +1 -1
  85. package/es/event/listener/table-group.js +41 -48
  86. package/es/event/listener/table-group.js.map +1 -1
  87. package/es/index.d.ts +1 -1
  88. package/es/index.js +1 -1
  89. package/es/index.js.map +1 -1
  90. package/es/ts-types/base-table.d.ts +3 -2
  91. package/es/ts-types/base-table.js.map +1 -1
  92. package/es/ts-types/component/legend.d.ts +15 -2
  93. package/es/ts-types/component/legend.js.map +1 -1
  94. package/es/ts-types/events.d.ts +6 -0
  95. package/es/ts-types/events.js.map +1 -1
  96. package/es/ts-types/table-engine.js.map +1 -1
  97. package/package.json +1 -1
  98. package/cjs/components/legend/get-legend-attributes.d.ts +0 -5
  99. package/cjs/components/legend/get-legend-attributes.js.map +0 -1
  100. package/cjs/components/legend/legend.js.map +0 -1
  101. package/es/components/legend/get-legend-attributes.d.ts +0 -5
  102. package/es/components/legend/get-legend-attributes.js.map +0 -1
  103. package/es/components/legend/legend.js.map +0 -1
@@ -0,0 +1,132 @@
1
+ var __rest = this && this.__rest || function(s, e) {
2
+ var t = {};
3
+ for (var p in s) Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0 && (t[p] = s[p]);
4
+ if (null != s && "function" == typeof Object.getOwnPropertySymbols) {
5
+ var i = 0;
6
+ for (p = Object.getOwnPropertySymbols(s); i < p.length; i++) e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]) && (t[p[i]] = s[p[i]]);
7
+ }
8
+ return t;
9
+ };
10
+
11
+ import { isEmpty, isValid, merge } from "@visactor/vutils";
12
+
13
+ import { transformComponentStyle, transformLegendTitleAttributes, transformToGraphic } from "../../util/transform";
14
+
15
+ const defaultContinueLegendSpec = {
16
+ orient: "right",
17
+ position: "middle",
18
+ padding: 30,
19
+ title: {
20
+ visible: !1,
21
+ padding: 0,
22
+ textStyle: {
23
+ fontSize: 14,
24
+ fontWeight: "normal",
25
+ fill: {
26
+ type: "palette",
27
+ key: "titleFontColor"
28
+ }
29
+ },
30
+ space: 12
31
+ },
32
+ handler: {
33
+ visible: !0
34
+ },
35
+ startText: {
36
+ style: {
37
+ fontSize: 14,
38
+ fontWeight: "normal",
39
+ fill: {
40
+ type: "palette",
41
+ key: "labelFontColor"
42
+ }
43
+ }
44
+ },
45
+ endText: {
46
+ style: {
47
+ fontSize: 14,
48
+ fontWeight: "normal",
49
+ fill: {
50
+ type: "palette",
51
+ key: "labelFontColor"
52
+ }
53
+ }
54
+ },
55
+ handlerText: {
56
+ style: {
57
+ fontSize: 14,
58
+ fontWeight: "normal",
59
+ fill: {
60
+ type: "palette",
61
+ key: "labelFontColor"
62
+ }
63
+ }
64
+ }
65
+ }, defaultColorLegendSpec = {
66
+ horizontal: Object.assign(Object.assign({}, defaultContinueLegendSpec), {
67
+ rail: {
68
+ width: 200,
69
+ height: 8,
70
+ style: {
71
+ fill: "rgba(0,0,0,0.04)"
72
+ }
73
+ }
74
+ }),
75
+ vertical: Object.assign(Object.assign({}, defaultContinueLegendSpec), {
76
+ rail: {
77
+ width: 8,
78
+ height: 200,
79
+ style: {
80
+ fill: "rgba(0,0,0,0.04)"
81
+ }
82
+ }
83
+ })
84
+ }, defaultSizeLegendSpec = {
85
+ horizontal: Object.assign({
86
+ sizeBackground: {
87
+ fill: "#cdcdcd"
88
+ },
89
+ track: {
90
+ style: {
91
+ fill: "rgba(20,20,20,0.1)"
92
+ }
93
+ },
94
+ rail: {
95
+ width: 200,
96
+ height: 4,
97
+ style: {
98
+ fill: "rgba(0,0,0,0.04)"
99
+ }
100
+ }
101
+ }, defaultContinueLegendSpec),
102
+ vertical: Object.assign({
103
+ sizeBackground: {
104
+ fill: "#cdcdcd"
105
+ },
106
+ track: {
107
+ style: {
108
+ fill: "rgba(20,20,20,0.1)"
109
+ }
110
+ },
111
+ rail: {
112
+ width: 4,
113
+ height: 200,
114
+ style: {
115
+ fill: "rgba(0,0,0,0.04)"
116
+ }
117
+ }
118
+ }, defaultContinueLegendSpec)
119
+ };
120
+
121
+ export function getContinuousLegendAttributes(spec, rect) {
122
+ const _a = merge({}, ("color" === spec.type ? defaultColorLegendSpec : defaultSizeLegendSpec)["bottom" === spec.orient || "top" === spec.orient ? "horizontal" : "vertical"], spec), {title: title = {}, handler: handler = {}, rail: rail = {}, track: track = {}, startText: startText, endText: endText, handlerText: handlerText, sizeBackground: sizeBackground, background: background = {}, type: type, id: id, visible: visible, orient: orient, position: position, data: data, defaultSelected: defaultSelected, field: field, filter: filter, regionId: regionId, regionIndex: regionIndex, seriesIndex: seriesIndex, seriesId: seriesId, padding: padding} = _a, attrs = __rest(_a, [ "title", "handler", "rail", "track", "startText", "endText", "handlerText", "sizeBackground", "background", "type", "id", "visible", "orient", "position", "data", "defaultSelected", "field", "filter", "regionId", "regionIndex", "seriesIndex", "seriesId", "padding" ]);
123
+ return title.visible && (attrs.title = transformLegendTitleAttributes(title)), attrs.showHandler = !1 !== handler.visible,
124
+ isEmpty(handler.style) || (attrs.handlerStyle = transformToGraphic(handler.style)),
125
+ isValid(rail.width) && (attrs.railWidth = rail.width), isValid(rail.height) && (attrs.railHeight = rail.height),
126
+ isEmpty(rail.style) || (attrs.railStyle = transformToGraphic(rail.style)), isEmpty(track.style) || (attrs.trackStyle = transformToGraphic(track.style)),
127
+ attrs.startText = transformComponentStyle(startText), attrs.endText = transformComponentStyle(endText),
128
+ attrs.handlerText = transformComponentStyle(handlerText), isEmpty(sizeBackground) || (attrs.sizeBackground = transformToGraphic(sizeBackground)),
129
+ background.visible && !isEmpty(background.style) && (merge(attrs, background.style),
130
+ isValid(background.padding) && (attrs.padding = background.padding)), attrs;
131
+ }
132
+ //# sourceMappingURL=get-continue-legend-attributes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["components/legend/continue-legend/get-continue-legend-attributes.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAE3D,OAAO,EAAE,uBAAuB,EAAE,8BAA8B,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAEnH,MAAM,yBAAyB,GAAG;IAChC,MAAM,EAAE,OAAO;IACf,QAAQ,EAAE,QAAQ;IAClB,OAAO,EAAE,EAAE;IACX,KAAK,EAAE;QACL,OAAO,EAAE,KAAK;QACd,OAAO,EAAE,CAAC;QACV,SAAS,EAAE;YACT,QAAQ,EAAE,EAAE;YACZ,UAAU,EAAE,QAAQ;YACpB,IAAI,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,EAAE,gBAAgB,EAAE;SACjD;QACD,KAAK,EAAE,EAAE;KACV;IACD,OAAO,EAAE;QACP,OAAO,EAAE,IAAI;KACd;IACD,SAAS,EAAE;QACT,KAAK,EAAE;YACL,QAAQ,EAAE,EAAE;YACZ,UAAU,EAAE,QAAQ;YACpB,IAAI,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,EAAE,gBAAgB,EAAE;SACjD;KACF;IACD,OAAO,EAAE;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M,CAAC,EAAE;QACxB,KAAK,CAAC,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC;KAChC;IACD,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE;QACxB,KAAK,CAAC,SAAS,GAAG,kBAAkB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;KAClD;IACD,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE;QACzB,KAAK,CAAC,UAAU,GAAG,kBAAkB,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;KACpD;IAED,KAAK,CAAC,SAAS,GAAG,uBAAuB,CAAC,SAAS,CAAC,CAAC;IACrD,KAAK,CAAC,OAAO,GAAG,uBAAuB,CAAC,OAAO,CAAC,CAAC;IACjD,KAAK,CAAC,WAAW,GAAG,uBAAuB,CAAC,WAAW,CAAC,CAAC;IAEzD,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,EAAE;QAC5B,KAAK,CAAC,cAAc,GAAG,kBAAkB,CAAC,cAAc,CAAC,CAAC;KAC3D;IAED,IAAI,UAAU,CAAC,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE;QACpD,KAAK,CAAC,KAAK,EAAE,UAAU,CAAC,KAAK,CAAC,CAAC;QAC/B,IAAI,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE;YAC/B,KAAK,CAAC,OAAO,GAAG,UAAU,CAAC,OAAO,CAAC;SACpC;KACF;IAED,OAAO,KAAK,CAAC;AACf,CAAC","file":"get-continue-legend-attributes.js","sourcesContent":["import { isEmpty, isValid, merge } from '@visactor/vutils';\nimport type { IColorTableLegendOption, ISizeTableLegendOption } from '../../../ts-types/component/legend';\nimport { transformComponentStyle, transformLegendTitleAttributes, transformToGraphic } from '../../util/transform';\n\nconst defaultContinueLegendSpec = {\n orient: 'right',\n position: 'middle',\n padding: 30,\n title: {\n visible: false,\n padding: 0,\n textStyle: {\n fontSize: 14,\n fontWeight: 'normal',\n fill: { type: 'palette', key: 'titleFontColor' }\n },\n space: 12\n },\n handler: {\n visible: true\n },\n startText: {\n style: {\n fontSize: 14,\n fontWeight: 'normal',\n fill: { type: 'palette', key: 'labelFontColor' }\n }\n },\n endText: {\n style: {\n fontSize: 14,\n fontWeight: 'normal',\n fill: { type: 'palette', key: 'labelFontColor' }\n }\n },\n handlerText: {\n style: {\n fontSize: 14,\n fontWeight: 'normal',\n fill: { type: 'palette', key: 'labelFontColor' }\n }\n }\n};\n\nconst defaultColorLegendSpec = {\n horizontal: {\n ...defaultContinueLegendSpec,\n rail: {\n width: 200,\n height: 8,\n style: {\n fill: 'rgba(0,0,0,0.04)'\n }\n }\n },\n vertical: {\n ...defaultContinueLegendSpec,\n rail: {\n width: 8,\n height: 200,\n style: {\n fill: 'rgba(0,0,0,0.04)'\n }\n }\n }\n};\n\nconst defaultSizeLegendSpec = {\n horizontal: {\n sizeBackground: {\n fill: '#cdcdcd'\n },\n track: {\n style: {\n fill: 'rgba(20,20,20,0.1)'\n }\n },\n rail: {\n width: 200,\n height: 4,\n style: {\n fill: 'rgba(0,0,0,0.04)'\n }\n },\n ...defaultContinueLegendSpec\n },\n vertical: {\n sizeBackground: {\n fill: '#cdcdcd'\n },\n track: {\n style: {\n fill: 'rgba(20,20,20,0.1)'\n }\n },\n rail: {\n width: 4,\n height: 200,\n style: {\n fill: 'rgba(0,0,0,0.04)'\n }\n },\n ...defaultContinueLegendSpec\n }\n};\n\nexport function getContinuousLegendAttributes(\n spec: IColorTableLegendOption | ISizeTableLegendOption,\n rect: { width: number; height: number }\n) {\n const {\n // 需要进行样式转换的属性\n title = {},\n handler = {},\n rail = {},\n track = {},\n startText,\n endText,\n handlerText,\n sizeBackground,\n background = {},\n\n // 以下不属于 legend 需要的属性,单独拿出来以免污染传递给组件的属性\n type,\n id,\n visible,\n orient,\n position,\n data,\n defaultSelected,\n field,\n filter,\n regionId,\n regionIndex,\n seriesIndex,\n seriesId,\n padding, // vchart 布局模块已经处理了\n\n ...restSpec\n } = merge(\n {},\n (spec.type === 'color' ? defaultColorLegendSpec : defaultSizeLegendSpec)[\n spec.orient === 'bottom' || spec.orient === 'top' ? 'horizontal' : 'vertical'\n ],\n spec\n );\n\n const attrs = restSpec;\n\n // transform title\n if (title.visible) {\n attrs.title = transformLegendTitleAttributes(title);\n }\n\n // handlerStyle\n attrs.showHandler = handler.visible !== false;\n if (!isEmpty(handler.style)) {\n attrs.handlerStyle = transformToGraphic(handler.style);\n }\n if (isValid(rail.width)) {\n attrs.railWidth = rail.width;\n }\n if (isValid(rail.height)) {\n attrs.railHeight = rail.height;\n }\n if (!isEmpty(rail.style)) {\n attrs.railStyle = transformToGraphic(rail.style);\n }\n if (!isEmpty(track.style)) {\n attrs.trackStyle = transformToGraphic(track.style);\n }\n\n attrs.startText = transformComponentStyle(startText);\n attrs.endText = transformComponentStyle(endText);\n attrs.handlerText = transformComponentStyle(handlerText);\n\n if (!isEmpty(sizeBackground)) {\n attrs.sizeBackground = transformToGraphic(sizeBackground);\n }\n\n if (background.visible && !isEmpty(background.style)) {\n merge(attrs, background.style);\n if (isValid(background.padding)) {\n attrs.padding = background.padding;\n }\n }\n\n return attrs;\n}\n"]}
@@ -0,0 +1,5 @@
1
+ import type { ITableLegendOption } from '../../ts-types/component/legend';
2
+ import { DiscreteTableLegend } from './discrete-legend/discrete-legend';
3
+ import type { BaseTableAPI } from '../../ts-types/base-table';
4
+ import { ContinueTableLegend } from './continue-legend/continue-legend';
5
+ export declare function createLegend(option: ITableLegendOption, table: BaseTableAPI): DiscreteTableLegend | ContinueTableLegend;
@@ -0,0 +1,8 @@
1
+ import { DiscreteTableLegend } from "./discrete-legend/discrete-legend";
2
+
3
+ import { ContinueTableLegend } from "./continue-legend/continue-legend";
4
+
5
+ export function createLegend(option, table) {
6
+ return "color" === option.type || "size" === option.type ? new ContinueTableLegend(option, table) : new DiscreteTableLegend(option, table);
7
+ }
8
+ //# sourceMappingURL=create-legend.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["components/legend/create-legend.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AAExE,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AAExE,MAAM,UAAU,YAAY,CAAC,MAA0B,EAAE,KAAmB;IAC1E,IAAI,MAAM,CAAC,IAAI,KAAK,OAAO,IAAI,MAAM,CAAC,IAAI,KAAK,MAAM,EAAE;QACrD,OAAO,IAAI,mBAAmB,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;KAC/C;IACD,OAAO,IAAI,mBAAmB,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;AAChD,CAAC","file":"create-legend.js","sourcesContent":["import type { ITableLegendOption } from '../../ts-types/component/legend';\nimport { DiscreteTableLegend } from './discrete-legend/discrete-legend';\nimport type { BaseTableAPI } from '../../ts-types/base-table';\nimport { ContinueTableLegend } from './continue-legend/continue-legend';\n\nexport function createLegend(option: ITableLegendOption, table: BaseTableAPI) {\n if (option.type === 'color' || option.type === 'size') {\n return new ContinueTableLegend(option, table);\n }\n return new DiscreteTableLegend(option, table);\n}\n"]}
@@ -1,16 +1,16 @@
1
- import type { ITableLegendOption } from '../../ts-types/component/legend';
2
- import type { BaseTableAPI } from '../../ts-types/base-table';
1
+ import type { IDiscreteTableLegendOption } from '../../../ts-types/component/legend';
2
+ import type { BaseTableAPI } from '../../../ts-types/base-table';
3
3
  import { DiscreteLegend } from '@visactor/vrender-components';
4
- import type { IOrientType } from '../../ts-types/component/util';
5
- export declare class TableLegend {
4
+ import type { IOrientType } from '../../../ts-types/component/util';
5
+ export declare class DiscreteTableLegend {
6
6
  table: BaseTableAPI;
7
- option: ITableLegendOption;
7
+ option: IDiscreteTableLegendOption;
8
8
  orient: IOrientType;
9
9
  visible: boolean;
10
10
  position: 'start' | 'middle' | 'end';
11
11
  selectedData: (string | number)[];
12
12
  legendComponent: DiscreteLegend;
13
- constructor(option: ITableLegendOption, table: BaseTableAPI);
13
+ constructor(option: IDiscreteTableLegendOption, table: BaseTableAPI);
14
14
  createComponent(): void;
15
15
  resize(): void;
16
16
  adjustTableSize(attrs: any): void;
@@ -2,13 +2,13 @@ import { cloneDeep, get, merge } from "@visactor/vutils";
2
2
 
3
3
  import { DiscreteLegend, LegendEvent } from "@visactor/vrender-components";
4
4
 
5
- import { getLegendAttributes } from "./get-legend-attributes";
5
+ import { getLegendAttributes } from "./get-discrete-legend-attributes";
6
6
 
7
- import { TABLE_EVENT_TYPE } from "../../core/TABLE_EVENT_TYPE";
7
+ import { TABLE_EVENT_TYPE } from "../../../core/TABLE_EVENT_TYPE";
8
8
 
9
- import { getQuadProps } from "../../scenegraph/utils/padding";
9
+ import { getQuadProps } from "../../../scenegraph/utils/padding";
10
10
 
11
- export class TableLegend {
11
+ export class DiscreteTableLegend {
12
12
  constructor(option, table) {
13
13
  var _a, _b, _c, _d;
14
14
  this.table = table, this.option = cloneDeep(option), this.orient = null !== (_a = option.orient) && void 0 !== _a ? _a : "left",
@@ -102,4 +102,4 @@ export class TableLegend {
102
102
  this.legendComponent = null;
103
103
  }
104
104
  }
105
- //# sourceMappingURL=legend.js.map
105
+ //# sourceMappingURL=discrete-legend.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["components/legend/discrete-legend/discrete-legend.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAGzD,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3E,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AACvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AAGjE,MAAM,OAAO,mBAAmB;IAS9B,YAAY,MAAkC,EAAE,KAAmB;;QACjE,IAAI,CAAC,KAAK,GAAG,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DiscreteTableLegendOption } from '../../../ts-types/component/legend';\nimport type { BaseTableAPI } from '../../../ts-types/base-table';\nimport { DiscreteLegend, LegendEvent } from '@visactor/vrender-components';\nimport { getLegendAttributes } from './get-discrete-legend-attributes';\nimport { TABLE_EVENT_TYPE } from '../../../core/TABLE_EVENT_TYPE';\nimport { getQuadProps } from '../../../scenegraph/utils/padding';\nimport type { IOrientType } from '../../../ts-types/component/util';\n\nexport class DiscreteTableLegend {\n table: BaseTableAPI;\n option: IDiscreteTableLegendOption;\n orient: IOrientType;\n visible: boolean;\n position: 'start' | 'middle' | 'end';\n selectedData: (string | number)[];\n legendComponent: DiscreteLegend;\n\n constructor(option: IDiscreteTableLegendOption, table: BaseTableAPI) {\n this.table = table;\n this.option = cloneDeep(option);\n this.orient = option.orient ?? 'left';\n this.visible = option.visible ?? true;\n this.position = option.position ?? 'middle';\n this.selectedData = option.defaultSelected ?? [];\n\n this.createComponent();\n this.initEvent();\n }\n\n createComponent() {\n const attrs = this.getLegendAttributes({\n width: this.table.tableNoFrameWidth,\n height: this.table.tableNoFrameHeight\n });\n const legend = new DiscreteLegend(\n merge({}, attrs, {\n defaultSelected: this.selectedData\n })\n );\n legend.name = 'legend';\n this.legendComponent = legend;\n this.table.scenegraph.stage.defaultLayer.appendChild(legend);\n\n this.adjustTableSize(attrs);\n }\n\n resize() {\n if (!this.legendComponent) {\n return;\n }\n\n this.legendComponent.setAttributes({\n width: this.table.tableNoFrameWidth,\n height: this.table.tableNoFrameHeight\n });\n\n this.adjustTableSize(this.legendComponent.attribute);\n }\n\n adjustTableSize(attrs: any) {\n // 调整位置\n let width = isFinite(this.legendComponent.AABBBounds.width()) ? this.legendComponent.AABBBounds.width() : 0;\n let height = isFinite(this.legendComponent.AABBBounds.height()) ? this.legendComponent.AABBBounds.height() : 0;\n const rectWidth = this.table.tableNoFrameWidth;\n const rectHeight = this.table.tableNoFrameHeight;\n const padding = getQuadProps(attrs.padding ?? this.option.padding ?? 10);\n\n let x = 0;\n let y = 0;\n if (this.orient === 'left') {\n x = padding[3];\n y = 0;\n width += padding[1] + padding[3];\n } else if (this.orient === 'top') {\n x = 0;\n y = padding[0];\n height += padding[0] + padding[2];\n } else if (this.orient === 'right') {\n x = rectWidth - width - padding[1];\n y = 0;\n width += padding[1] + padding[3];\n } else if (this.orient === 'bottom') {\n x = 0;\n y = rectHeight - height - padding[2];\n height += padding[0] + padding[2];\n }\n\n const layout = this.orient === 'bottom' || this.orient === 'top' ? 'horizontal' : 'vertical';\n const position = this.position;\n // const { width: rectWidth, height: rectHeight } = fullSpace;\n let offsetX = 0;\n let offsetY = 0;\n if (layout === 'horizontal') {\n if (position === 'middle') {\n offsetX = (rectWidth - width) / 2;\n } else if (position === 'end') {\n offsetX = rectWidth - width - padding[1];\n } else {\n offsetX = padding[3];\n }\n } else {\n if (position === 'middle') {\n offsetY = (rectHeight - height) / 2;\n } else if (position === 'end') {\n offsetY = rectHeight - height - padding[2];\n } else {\n offsetY = padding[0];\n }\n }\n\n this.legendComponent.setAttributes({\n dx: offsetX,\n dy: offsetY,\n x,\n y\n });\n\n // update table size\n if (this.orient === 'left') {\n this.table.tableNoFrameWidth = this.table.tableNoFrameWidth - Math.ceil(width);\n this.table.tableX += Math.ceil(width);\n } else if (this.orient === 'top') {\n this.table.tableNoFrameHeight = this.table.tableNoFrameHeight - Math.ceil(height);\n this.table.tableY += Math.ceil(height);\n } else if (this.orient === 'right') {\n this.table.tableNoFrameWidth = this.table.tableNoFrameWidth - Math.ceil(width);\n } else if (this.orient === 'bottom') {\n this.table.tableNoFrameHeight = this.table.tableNoFrameHeight - Math.ceil(height);\n }\n }\n\n getLegendAttributes(rect: any) {\n const layout = this.orient === 'bottom' || this.orient === 'top' ? 'horizontal' : 'vertical';\n const attrs = {\n layout,\n items: this.getLegendItems(),\n // zIndex: this.layoutZIndex,\n maxWidth: rect.width,\n maxHeight: rect.height,\n ...getLegendAttributes(this.option, rect)\n };\n return attrs;\n }\n\n getLegendItems() {\n return this.option.data;\n }\n\n initEvent() {\n if (this.legendComponent) {\n this.legendComponent.addEventListener(LegendEvent.legendItemClick, (e: any) => {\n const selectedData = get(e, 'detail.currentSelected');\n this.table.fireListeners(TABLE_EVENT_TYPE.LEGEND_ITEM_CLICK, { model: this, value: selectedData, event: e });\n });\n\n this.legendComponent.addEventListener(LegendEvent.legendItemHover, (e: any) => {\n const detail = get(e, 'detail');\n this.table.fireListeners(TABLE_EVENT_TYPE.LEGEND_ITEM_HOVER, { model: this, value: detail, event: e });\n });\n\n this.legendComponent.addEventListener(LegendEvent.legendItemUnHover, (e: any) => {\n const detail = get(e, 'detail');\n this.table.fireListeners(TABLE_EVENT_TYPE.LEGEND_ITEM_UNHOVER, { model: this, value: detail, event: e });\n });\n\n // wait for vrender-vcomponent version update\n this.legendComponent.addEventListener('legendItemAttributeUpdate', (e: any) => {\n this.table.scenegraph.updateNextFrame();\n });\n }\n }\n\n getLegendBounds() {\n const width = isFinite(this.legendComponent.AABBBounds.width()) ? this.legendComponent.AABBBounds.width() : 0;\n const height = isFinite(this.legendComponent.AABBBounds.height()) ? this.legendComponent.AABBBounds.height() : 0;\n\n return {\n width: width,\n height: height\n };\n }\n release() {\n this.legendComponent && this.table.scenegraph.stage.defaultLayer.removeChild(this.legendComponent);\n this.legendComponent = null;\n }\n}\n"]}
@@ -0,0 +1,5 @@
1
+ import type { IDiscreteTableLegendOption } from '../../../ts-types/component/legend';
2
+ export declare function getLegendAttributes(spec: IDiscreteTableLegendOption, rect: {
3
+ width: number;
4
+ height: number;
5
+ }): any;
@@ -10,9 +10,9 @@ var __rest = this && this.__rest || function(s, e) {
10
10
 
11
11
  import { isEmpty, isValid, merge } from "@visactor/vutils";
12
12
 
13
- import { isPercent } from "../../tools/calc";
13
+ import { isPercent } from "../../../tools/calc";
14
14
 
15
- import { transformComponentStyle, transformLegendTitleAttributes, transformToGraphic } from "../util/transform";
15
+ import { transformComponentStyle, transformLegendTitleAttributes, transformToGraphic } from "../../util/transform";
16
16
 
17
17
  const defaultLegendSpec = {
18
18
  orient: "bottom",
@@ -81,4 +81,4 @@ export function getLegendAttributes(spec, rect) {
81
81
  transformComponentStyle(pager.handler), attrs.pager = pager, background.visible && !isEmpty(background.style) && (merge(attrs, background.style),
82
82
  isValid(background.padding) && (attrs.padding = background.padding)), attrs;
83
83
  }
84
- //# sourceMappingURL=get-legend-attributes.js.map
84
+ //# sourceMappingURL=get-discrete-legend-attributes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["components/legend/discrete-legend/get-discrete-legend-attributes.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAE3D,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,uBAAuB,EAAE,8BAA8B,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAEnH,MAAM,iBAAiB,GAAG;IACxB,MAAM,EAAE,QAAQ;IAChB,QAAQ,EAAE,QAAQ;IAClB,OAAO,EAAE,EAAE;IACX,KAAK,EAAE;QACL,OAAO,EAAE,KAAK;QACd,OAAO,EAAE,CAAC;QACV,SAAS,EAAE;YACT,QAAQ,EAAE,EAAE;YACZ,IAAI,EAAE,SAAS;YACf,UAAU,EAAE,QAAQ;SACrB;QACD,KAAK,EAAE,EAAE;KACV;IACD,IAAI,EAAE;QACJ,OAAO,EAAE,IAAI;QACb,QAAQ,EAAE,EAAE;QACZ,QAAQ,EAAE,EAAE;QACZ,OAAO,EAAE,CAAC;QACV,UAAU,EAAE;YACV,KAAK,EAAE;gBACL,aAAa,EAAE;oBACb,IAAI,EAAE,MAAM;oBACZ,WAAW,EAAE,GAAG;iBACjB;gBACD,eAAe,EAAE;oBACf,IAAI,EAAE,MAAM;oBACZ,WAAW,EAAE,GAAG;iBACjB;aACF;SACF;QACD,KAAK,EAAE;YACL,KAAK,EAAE,CAAC;YACR,KAAK,EAAE;gBACL,UA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AAC;SACpC;KACF;IAED,OAAO,KAAK,CAAC;AACf,CAAC","file":"get-discrete-legend-attributes.js","sourcesContent":["import { isEmpty, isValid, merge } from '@visactor/vutils';\nimport type { IDiscreteTableLegendOption } from '../../../ts-types/component/legend';\nimport { isPercent } from '../../../tools/calc';\nimport { transformComponentStyle, transformLegendTitleAttributes, transformToGraphic } from '../../util/transform';\n\nconst defaultLegendSpec = {\n orient: 'bottom',\n position: 'middle',\n padding: 30,\n title: {\n visible: false,\n padding: 0,\n textStyle: {\n fontSize: 14,\n fill: '#000000',\n fontWeight: 'normal'\n },\n space: 12\n },\n item: {\n visible: true,\n spaceCol: 10,\n spaceRow: 10,\n padding: 2,\n background: {\n state: {\n selectedHover: {\n fill: 'gray',\n fillOpacity: 0.7\n },\n unSelectedHover: {\n fill: 'gray',\n fillOpacity: 0.2\n }\n }\n },\n shape: {\n space: 4,\n state: {\n unSelected: {\n fillOpacity: 0.5\n }\n }\n },\n label: {\n space: 4,\n style: {\n fill: '#89909D',\n fontSize: 14\n },\n state: {\n unSelected: {\n fillOpacity: 0.5\n }\n }\n }\n },\n allowAllCanceled: true,\n visible: true\n};\n\nexport function getLegendAttributes(spec: IDiscreteTableLegendOption, rect: { width: number; height: number }) {\n const {\n // 需要进行样式转换的属性\n title = {},\n item = {},\n pager = {},\n background = {},\n\n // 以下不属于 legend 需要的属性,单独拿出来以免污染传递给组件的属性\n type,\n id,\n visible,\n orient,\n position,\n data,\n filter,\n regionId,\n regionIndex,\n seriesIndex,\n seriesId,\n padding, // vchart 布局模块已经处理了\n\n ...restSpec\n } = merge({}, defaultLegendSpec, spec);\n\n const attrs: any = restSpec;\n\n // transform title\n if (title.visible) {\n attrs.title = transformLegendTitleAttributes(title);\n }\n\n // transform item\n if (!isEmpty(item.focusIconStyle)) {\n transformToGraphic(item.focusIconStyle);\n }\n transformComponentStyle(item.shape);\n transformComponentStyle(item.label);\n transformComponentStyle(item.value);\n transformComponentStyle(item.background);\n\n if (isPercent(item.maxWidth)) {\n item.maxWidth = (Number(item.maxWidth.substring(0, item.maxWidth.length - 1)) * rect.width) / 100;\n }\n if (isPercent(item.width)) {\n item.width = (Number(item.width.substring(0, item.width.length - 1)) * rect.width) / 100;\n }\n if (isPercent(item.height)) {\n item.height = (Number(item.height.substring(0, item.height.length - 1)) * rect.width) / 100;\n }\n attrs.item = item;\n\n // transform pager\n if (!isEmpty(pager.textStyle)) {\n transformToGraphic(pager.textStyle);\n }\n transformComponentStyle(pager.handler);\n attrs.pager = pager;\n\n if (background.visible && !isEmpty(background.style)) {\n merge(attrs, background.style);\n if (isValid(background.padding)) {\n attrs.padding = background.padding;\n }\n }\n\n return attrs;\n}\n"]}
@@ -225,7 +225,7 @@ export declare abstract class BaseTable extends EventTarget implements BaseTable
225
225
  abstract getCellOriginRecord(col: number, row: number): MaybePromiseOrUndefined;
226
226
  abstract getCellValue(col: number, row: number): FieldData;
227
227
  abstract getCellOriginValue(col: number, row: number): FieldData;
228
- updatePagination(cof: IPagination): void;
228
+ abstract updatePagination(pagination: IPagination): void;
229
229
  get allowFrozenColCount(): number;
230
230
  get rowHeaderLevelCount(): number;
231
231
  get columnHeaderLevelCount(): number;
@@ -54,7 +54,7 @@ import { FocusInput } from "./FouseInput";
54
54
 
55
55
  import { defaultPixelRatio } from "../tools/pixel-ratio";
56
56
 
57
- import { TableLegend } from "../components/legend/legend";
57
+ import { createLegend } from "../components/legend/create-legend";
58
58
 
59
59
  import { DataSet } from "@visactor/vdataset";
60
60
 
@@ -74,7 +74,7 @@ export class BaseTable extends EventTarget {
74
74
  }
75
75
  constructor(container, options = {}) {
76
76
  var _a, _b, _c, _d, _e, _f, _g;
77
- if (super(), this.showFrozenIcon = !0, this.showSort = !0, this.version = "0.10.2-alpha.3",
77
+ if (super(), this.showFrozenIcon = !0, this.showSort = !0, this.version = "0.10.2",
78
78
  this.id = `VTable${Date.now()}`, this.throttleInvalidate = throttle2(this.render.bind(this), 200),
79
79
  !container) throw new Error("vtable's container is undefined");
80
80
  const {frozenColCount: frozenColCount = 0, defaultRowHeight: defaultRowHeight = 40, defaultHeaderRowHeight: defaultHeaderRowHeight, defaultColWidth: defaultColWidth = 80, defaultHeaderColWidth: defaultHeaderColWidth, widthMode: widthMode = "standard", heightMode: heightMode = "standard", autoFillWidth: autoFillWidth = !1, keyboardOptions: keyboardOptions, columnResizeMode: columnResizeMode, dragHeaderMode: dragHeaderMode, showFrozenIcon: showFrozenIcon, allowFrozenColCount: allowFrozenColCount, padding: padding, hover: hover, menu: menu, select: click, customRender: customRender, pixelRatio: pixelRatio = defaultPixelRatio, renderChartAsync: renderChartAsync, renderChartAsyncBatchCount: renderChartAsyncBatchCount} = options;
@@ -116,7 +116,7 @@ export class BaseTable extends EventTarget {
116
116
  internalProps.autoWrapText = options.autoWrapText, internalProps.allowFrozenColCount = null !== (_c = options.allowFrozenColCount) && void 0 !== _c ? _c : internalProps.colCount,
117
117
  internalProps.limitMaxAutoWidth = null !== (_d = options.limitMaxAutoWidth) && void 0 !== _d ? _d : 450,
118
118
  this._vDataSet = new DataSet, this.scenegraph = new Scenegraph(this), this.stateManeger = new StateManeger(this),
119
- this.eventManeger = new EventManeger(this), options.legends && (internalProps.legends = new TableLegend(options.legends, this),
119
+ this.eventManeger = new EventManeger(this), options.legends && (internalProps.legends = createLegend(options.legends, this),
120
120
  this.scenegraph.tableGroup.setAttributes({
121
121
  x: this.tableX,
122
122
  y: this.tableY
@@ -689,7 +689,7 @@ export class BaseTable extends EventTarget {
689
689
  this._vDataSet = new DataSet, null === (_d = internalProps.legends) || void 0 === _d || _d.release(),
690
690
  null === (_e = internalProps.title) || void 0 === _e || _e.release(), internalProps.layoutMap.release(),
691
691
  this.scenegraph.clearCells(), this.stateManeger.initState(), this._updateSize(),
692
- options.legends && (internalProps.legends = new TableLegend(options.legends, this),
692
+ options.legends && (internalProps.legends = createLegend(options.legends, this),
693
693
  this.scenegraph.tableGroup.setAttributes({
694
694
  x: this.tableX,
695
695
  y: this.tableY
@@ -862,12 +862,6 @@ export class BaseTable extends EventTarget {
862
862
  selectCell(col, row) {
863
863
  this.stateManeger.updateSelectPos(col, row), this.stateManeger.endSelectCells();
864
864
  }
865
- updatePagination(cof) {
866
- this.pagination && ("number" == typeof cof.currentPage && cof.currentPage >= 0 && (this.pagination.currentPage = cof.currentPage),
867
- cof.perPageCount && (this.pagination.perPageCount = cof.perPageCount || this.pagination.perPageCount),
868
- this.scenegraph.clearCells(), this.dataSource.updatePagination(this.pagination),
869
- this.refreshRowColCount(), this.scenegraph.createSceneGraph(), this.render());
870
- }
871
865
  get allowFrozenColCount() {
872
866
  return this.internalProps.allowFrozenColCount;
873
867
  }