@dfsj/components 3.1.1 → 3.1.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.
Files changed (75) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/components/Boards/index.d.ts +2 -2
  3. package/dist/components/Boards/src/Boards.vue.d.ts +21 -0
  4. package/dist/components/Boards/src/Boards.vue2.js +132 -31
  5. package/dist/components/Boards/src/props.d.ts +20 -0
  6. package/dist/components/Boards/src/props.js +19 -1
  7. package/dist/components/Editor/src/Editor.vue2.js +2 -3
  8. package/dist/components/Form/src/Form.vue2.js +16 -4
  9. package/dist/components/Modal/src/BasicModal.vue.d.ts +37 -2
  10. package/dist/components/Modal/src/BasicModal.vue2.js +11 -11
  11. package/dist/components/Modal/src/components/ModalHeader.vue.d.ts +9 -0
  12. package/dist/components/Modal/src/components/ModalHeader.vue2.js +17 -10
  13. package/dist/components/Modal/src/hooks/useModalDrag.js +2 -7
  14. package/dist/components/Modal/src/props.d.ts +18 -1
  15. package/dist/components/Modal/src/props.js +4 -0
  16. package/dist/components/Modal/src/utils/index.js +2 -2
  17. package/dist/components/NodeAxis/index.d.ts +6 -0
  18. package/dist/components/NodeAxis/src/AbstractNodeProvider.d.ts +15 -0
  19. package/dist/components/NodeAxis/src/AbstractNodeProvider.js +23 -0
  20. package/dist/components/NodeAxis/src/BCanvasNodeRender.d.ts +19 -0
  21. package/dist/components/NodeAxis/src/CanvasNodeRender.d.ts +28 -0
  22. package/dist/components/NodeAxis/src/CanvasNodeRender.js +400 -0
  23. package/dist/components/NodeAxis/src/NodeAxis.d.ts +12 -0
  24. package/dist/components/NodeAxis/src/NodeAxis.vue.d.ts +17 -0
  25. package/dist/components/NodeAxis/src/NodeAxis.vue.js +5 -0
  26. package/dist/components/NodeAxis/src/NodeAxis.vue2.js +68 -0
  27. package/dist/components/NodeAxis/src/NodeModel.d.ts +24 -0
  28. package/dist/components/NodeAxis/src/NodeModel.js +64 -0
  29. package/dist/components/NodeAxis/src/NodeProvider.d.ts +15 -0
  30. package/dist/components/NodeAxis/src/NodeRender.d.ts +17 -0
  31. package/dist/components/NodeAxis/src/NodeRender.js +30 -0
  32. package/dist/components/NodeAxis/src/NullLayerProvider.d.ts +23 -0
  33. package/dist/components/NodeAxis/src/NullLayerProvider.js +88 -0
  34. package/dist/components/NodeAxis/src/NullProvider.d.ts +17 -0
  35. package/dist/components/NodeAxis/src/NullProvider.js +67 -0
  36. package/dist/components/NodeAxis/src/TimerNodePlayer.d.ts +19 -0
  37. package/dist/components/NodeAxis/src/TimerNodePlayer.js +150 -0
  38. package/dist/components/NodeAxis/src/config/node-axis.options.d.ts +54 -0
  39. package/dist/components/NodeAxis/src/config/node-axis.options.js +56 -0
  40. package/dist/components/NodeAxis/src/enum/index.d.ts +15 -0
  41. package/dist/components/NodeAxis/src/enum/index.js +20 -0
  42. package/dist/components/NodeAxis/src/interface/NodePlayer.d.ts +9 -0
  43. package/dist/components/NodeAxis/src/interface/NodeProvider.d.ts +15 -0
  44. package/dist/components/NodeAxis/src/utils/assign.d.ts +1 -0
  45. package/dist/components/NodeAxis/src/utils/assign.js +43 -0
  46. package/dist/components/Stateful/src/Stateful.vue2.js +15 -8
  47. package/dist/components/Visual/index.d.ts +3 -0
  48. package/dist/components/Visual/src/BufferLayerPlayer.d.ts +27 -0
  49. package/dist/components/Visual/src/BufferLayerPlayer.js +293 -0
  50. package/dist/components/Visual/src/ResolvableLayerProvider.d.ts +36 -0
  51. package/dist/components/Visual/src/ResolvableLayerProvider.js +255 -0
  52. package/dist/components/Visual/src/config/default.manager.d.ts +6 -0
  53. package/dist/components/Visual/src/config/default.manager.js +7 -0
  54. package/dist/components/Visual/src/config/default.provider.d.ts +17 -0
  55. package/dist/components/Visual/src/config/default.provider.js +18 -0
  56. package/dist/components/Visual/src/interface/Disposable.d.ts +3 -0
  57. package/dist/components/Visual/src/interface/LayerFactory.d.ts +5 -0
  58. package/dist/components/Visual/src/interface/LayerManager.d.ts +8 -0
  59. package/dist/components/Visual/src/interface/LayerPlayer.d.ts +10 -0
  60. package/dist/components/Visual/src/interface/LayerProvider.d.ts +7 -0
  61. package/dist/components/Visual/src/interface/LayerResolver.d.ts +13 -0
  62. package/dist/components/Visual/src/mapping.d.ts +5 -0
  63. package/dist/components/Visual/src/mapping.js +7 -0
  64. package/dist/components/Visual/src/resolvers/IntervalResolver.d.ts +30 -0
  65. package/dist/components/Visual/src/resolvers/IntervalResolver.js +170 -0
  66. package/dist/components/Visual/src/resolvers/tools.resolver.d.ts +4 -0
  67. package/dist/components/Visual/src/resolvers/tools.resolver.js +145 -0
  68. package/dist/components/Visual/src/utils/NodeMath.d.ts +13 -0
  69. package/dist/components/Visual/src/utils/NodeMath.js +101 -0
  70. package/dist/index.d.ts +2 -0
  71. package/dist/index.js +9 -1
  72. package/dist/index.min.css +3 -3
  73. package/dist/node_modules/.pnpm/@vueuse_core@10.7.2_vue@3.4.21/node_modules/@vueuse/core/index.js +175 -4
  74. package/dist/node_modules/.pnpm/@vueuse_shared@10.7.2_vue@3.4.21/node_modules/@vueuse/shared/index.js +8 -2
  75. package/package.json +7 -5
@@ -0,0 +1,255 @@
1
+ import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
2
+ import _classCallCheck from '@babel/runtime/helpers/classCallCheck';
3
+ import _createClass from '@babel/runtime/helpers/createClass';
4
+ import _possibleConstructorReturn from '@babel/runtime/helpers/possibleConstructorReturn';
5
+ import _getPrototypeOf from '@babel/runtime/helpers/getPrototypeOf';
6
+ import _assertThisInitialized from '@babel/runtime/helpers/assertThisInitialized';
7
+ import _inherits from '@babel/runtime/helpers/inherits';
8
+ import _defineProperty from '@babel/runtime/helpers/defineProperty';
9
+ import clamp from 'lodash-es/clamp';
10
+ import NodeMath from './utils/NodeMath.js';
11
+ import { Extensible } from '../../NodeAxis/src/enum/index.js';
12
+ import AbstractNodeProvider from '../../NodeAxis/src/AbstractNodeProvider.js';
13
+ import mapping from './mapping.js';
14
+ import def from './config/default.provider.js';
15
+
16
+ function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
17
+ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
18
+ var EMPTY_ARRAY = [];
19
+ var ResolvableLayerProvider = /*#__PURE__*/function (_AbstractNodeProvider) {
20
+ _inherits(ResolvableLayerProvider, _AbstractNodeProvider);
21
+ function ResolvableLayerProvider(factory, data, injection, interceptor, config) {
22
+ var _this;
23
+ _classCallCheck(this, ResolvableLayerProvider);
24
+ _this = _callSuper(this, ResolvableLayerProvider);
25
+ _defineProperty(_assertThisInitialized(_this), "factory", void 0);
26
+ _defineProperty(_assertThisInitialized(_this), "interceptor", void 0);
27
+ _defineProperty(_assertThisInitialized(_this), "config", void 0);
28
+ _defineProperty(_assertThisInitialized(_this), "cache", [-1, null]);
29
+ _defineProperty(_assertThisInitialized(_this), "total", 0);
30
+ _defineProperty(_assertThisInitialized(_this), "marks", []);
31
+ _defineProperty(_assertThisInitialized(_this), "init", void 0);
32
+ _defineProperty(_assertThisInitialized(_this), "back", void 0);
33
+ _defineProperty(_assertThisInitialized(_this), "options", null);
34
+ _defineProperty(_assertThisInitialized(_this), "extended", 0);
35
+ _defineProperty(_assertThisInitialized(_this), "nodes", []);
36
+ _this.factory = factory;
37
+ _this.interceptor = interceptor;
38
+ _this.config = Object.assign({}, def, config);
39
+ _this.read(data, injection);
40
+ return _this;
41
+ }
42
+ _createClass(ResolvableLayerProvider, [{
43
+ key: "read",
44
+ value: function read(options, injection) {
45
+ this.options = options;
46
+ var resolvers = options.nodes.map(function (e) {
47
+ return new mapping[e.type](e, injection);
48
+ });
49
+ var count = resolvers.reduce(function (p, v) {
50
+ return p + v.count;
51
+ }, 0);
52
+ var range = options.range;
53
+ var index = clamp(options.index, 0, count - 1) || 0;
54
+ if (range == null) {
55
+ var nodeCount = options.availableNodeCount || this.config.availableNodeCount;
56
+ var padding = Array.isArray(nodeCount) ? nodeCount : null;
57
+ if (padding == null) {
58
+ var half = Math.floor(nodeCount / 2);
59
+ padding = [nodeCount % 2 === 0 ? half - 1 : half, half];
60
+ }
61
+ if (index - padding[0] < 0) {
62
+ padding[1] = padding[1] + (padding[0] - index);
63
+ padding[0] = index;
64
+ } else if (index + padding[1] >= count) {
65
+ padding[0] = padding[0] + (index + padding[1] - count) + 1;
66
+ padding[1] = count - index;
67
+ }
68
+ range = [Math.max(0, index - padding[0]), Math.min(count, index + padding[1] + 1)];
69
+ }
70
+ var extensible = options.extensible;
71
+ if (typeof extensible === "string") {
72
+ this.extended = (extensible.includes("L") ? Extensible.HEAD : 0) | (extensible.includes("R") ? Extensible.TAIL : 0);
73
+ } else if (typeof extensible === "number") {
74
+ this.extended = extensible;
75
+ } else {
76
+ this.extended = Extensible.NONE;
77
+ }
78
+ this.total = count;
79
+ this.nodes = resolvers;
80
+ this.init = Object.seal([range[0], range[1], index]);
81
+ this.back = this.init.slice();
82
+ this.makeSections();
83
+ }
84
+ }, {
85
+ key: "findNode",
86
+ value: function findNode(index) {
87
+ var accept = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.cache;
88
+ for (var i = 0, start = 0, ii = this.nodes.length; i < ii; i++) {
89
+ var node = this.nodes[i];
90
+ if (index >= start && index < start + node.count) {
91
+ accept[0] = start;
92
+ accept[1] = node;
93
+ return accept;
94
+ }
95
+ start += node.count;
96
+ }
97
+ return EMPTY_ARRAY;
98
+ }
99
+ }, {
100
+ key: "makeSections",
101
+ value: function makeSections() {
102
+ this.marks.length = 0;
103
+ for (var i = 0, start = 0, ii = this.nodes.length; i < ii; i++) {
104
+ var node = this.nodes[i];
105
+ start += node.count;
106
+ if (node.period) {
107
+ this.marks.push({
108
+ range: [start - node.count, start],
109
+ color: this.config.sectionColor[node.period]
110
+ });
111
+ }
112
+ }
113
+ }
114
+ }, {
115
+ key: "get",
116
+ value: function get(index) {
117
+ var _this$findNode = this.findNode(index),
118
+ _this$findNode2 = _slicedToArray(_this$findNode, 2),
119
+ start = _this$findNode2[0],
120
+ node = _this$findNode2[1];
121
+ if (node != null) {
122
+ var config = node.get(index - start);
123
+ if (this.interceptor) {
124
+ config = this.interceptor(config);
125
+ }
126
+ return config;
127
+ }
128
+ return null;
129
+ }
130
+ }, {
131
+ key: "getNodeInfo",
132
+ value: function getNodeInfo(index) {
133
+ var _this$findNode3 = this.findNode(index),
134
+ _this$findNode4 = _slicedToArray(_this$findNode3, 2),
135
+ start = _this$findNode4[0],
136
+ node = _this$findNode4[1];
137
+ if (node != null) {
138
+ return node.getNodeInfo(index - start);
139
+ }
140
+ }
141
+ }, {
142
+ key: "extent",
143
+ get: function get() {
144
+ return this.init;
145
+ }
146
+ }, {
147
+ key: "count",
148
+ get: function get() {
149
+ return this.total;
150
+ }
151
+ }, {
152
+ key: "sections",
153
+ get: function get() {
154
+ return this.marks;
155
+ }
156
+ }, {
157
+ key: "extensible",
158
+ get: function get() {
159
+ return this.extended;
160
+ }
161
+ }, {
162
+ key: "color",
163
+ value: function color(index) {
164
+ return null;
165
+ }
166
+ }, {
167
+ key: "format",
168
+ value: function format(index, type) {
169
+ var _this$findNode5 = this.findNode(index),
170
+ _this$findNode6 = _slicedToArray(_this$findNode5, 2),
171
+ start = _this$findNode6[0],
172
+ node = _this$findNode6[1];
173
+ if (node != null) {
174
+ return node.format(index - start, type);
175
+ }
176
+ }
177
+ }, {
178
+ key: "formatByInject",
179
+ value: function formatByInject(index, type, finalFormat) {
180
+ var _this$findNode7 = this.findNode(index),
181
+ _this$findNode8 = _slicedToArray(_this$findNode7, 2),
182
+ start = _this$findNode8[0],
183
+ node = _this$findNode8[1];
184
+ if (node != null) {
185
+ return node.formatByInject(index - start, type, finalFormat);
186
+ }
187
+ }
188
+ }, {
189
+ key: "find",
190
+ value: function find(query) {
191
+ var index = null,
192
+ head = this.nodes[0];
193
+ if ((index = head.find(query)) != null) {
194
+ return index;
195
+ }
196
+ var size = this.nodes.length;
197
+ var tail = this.nodes[size - 1];
198
+ if ((index = tail.find(query)) != null) {
199
+ return this.total + index;
200
+ }
201
+ for (var i = 1, s = head.count, ii = size - 1; i < ii; i++) {
202
+ var node = this.nodes[i];
203
+ if ((index = node.find(query)) != null) {
204
+ if (index > node.count) {
205
+ break;
206
+ }
207
+ return s + index;
208
+ }
209
+ s += node.count;
210
+ }
211
+ return null;
212
+ }
213
+ }, {
214
+ key: "extends",
215
+ value: function _extends(direction, minimum) {
216
+ var oldCount = this.total,
217
+ extended = 0;
218
+ var amount = Math.max(minimum, this.extent[1] - this.extent[0]);
219
+ if (amount !== 0) {
220
+ var node = this.nodes[direction < 0 ? 0 : this.nodes.length - 1];
221
+ var side = direction < 0 ? Extensible.HEAD : Extensible.TAIL;
222
+ var extensible = !!(this.extensible & side) && node.isAutoExtensible;
223
+ if (extensible) {
224
+ extended = node["extends"](direction, amount);
225
+ this.total += Math.abs(extended);
226
+ }
227
+ }
228
+ if (direction < 0 && this.count !== oldCount) {
229
+ NodeMath.translation(this.init, extended);
230
+ NodeMath.translation(this.back, extended);
231
+ }
232
+ this.makeSections();
233
+ return extended;
234
+ }
235
+ }, {
236
+ key: "reset",
237
+ value: function reset() {
238
+ this.init = this.back.slice();
239
+ }
240
+ }, {
241
+ key: "dispose",
242
+ value: function dispose() {
243
+ this.total = 0;
244
+ this.nodes = null;
245
+ this.marks = null;
246
+ this.cache = null;
247
+ this.config = null;
248
+ this.options = null;
249
+ this.factory = null;
250
+ }
251
+ }]);
252
+ return ResolvableLayerProvider;
253
+ }(AbstractNodeProvider);
254
+
255
+ export { ResolvableLayerProvider as default };
@@ -0,0 +1,6 @@
1
+ declare const _default: {
2
+ buffer: number;
3
+ transition: number;
4
+ opacity: number;
5
+ };
6
+ export default _default;
@@ -0,0 +1,7 @@
1
+ var def = {
2
+ buffer: 1,
3
+ transition: 0,
4
+ opacity: 0.6
5
+ };
6
+
7
+ export { def as default };
@@ -0,0 +1,17 @@
1
+ declare const _default: {
2
+ sectionColor: {
3
+ history: string;
4
+ short: string;
5
+ long: string;
6
+ tend: string;
7
+ forecast: string;
8
+ };
9
+ statusColor: {
10
+ ready: any;
11
+ loading: string;
12
+ success: string;
13
+ error: string;
14
+ };
15
+ availableNodeCount: number[];
16
+ };
17
+ export default _default;
@@ -0,0 +1,18 @@
1
+ var def = {
2
+ sectionColor: {
3
+ history: "rgba(51,51,51,0.45)",
4
+ "short": "rgba(51,183,255,0.45)",
5
+ "long": "rgba(235,255,121,0.45)",
6
+ tend: "rgba(255,99,13,0.45)",
7
+ forecast: "rgba(255,99,13,0.45)"
8
+ },
9
+ statusColor: {
10
+ ready: null,
11
+ loading: "#d076ff",
12
+ success: "#07ff23",
13
+ error: "#ff0059"
14
+ },
15
+ availableNodeCount: [2, 3]
16
+ };
17
+
18
+ export { def as default };
@@ -0,0 +1,3 @@
1
+ export default interface Disposable {
2
+ dispose(): void;
3
+ }
@@ -0,0 +1,5 @@
1
+ import { Layer } from "../types";
2
+ import { LayerConfig } from "../types";
3
+ export default interface LayerFactory {
4
+ create(options: LayerConfig | LayerConfig[]): Promise<Layer | Layer[]>;
5
+ }
@@ -0,0 +1,8 @@
1
+ import { Layer } from "../types";
2
+ export default interface LayerManager {
3
+ addition(layer: Layer | Layer[]): void;
4
+ remove(layer: Layer | Layer[]): void;
5
+ clear(): void;
6
+ modify(layer: Layer, property: string, value: any): void;
7
+ query(layer: Layer, property: string): any;
8
+ }
@@ -0,0 +1,10 @@
1
+ export default interface LayerPlayer {
2
+ backward(): any;
3
+ forward(): any;
4
+ jump(index: number): any;
5
+ visible(value: boolean): any;
6
+ status(index: number): string;
7
+ update(index: number): void;
8
+ clear(): any;
9
+ dispose(): any;
10
+ }
@@ -0,0 +1,7 @@
1
+ import { Visual } from "../types";
2
+ import NodeProvider from "../../../NodeAxis/src/interface/NodeProvider";
3
+ export default interface LayerProvider extends NodeProvider {
4
+ get(index: number): Promise<object>;
5
+ find(query: Visual.Condition): number;
6
+ getNodeInfo(index: number): Visual.NodeInfo | undefined;
7
+ }
@@ -0,0 +1,13 @@
1
+ import { NodeAxis } from "../../../NodeAxis/src/types";
2
+ import { LayerConfig, Visual } from "../types";
3
+ export default interface LayerResolver {
4
+ get count(): number;
5
+ get period(): string;
6
+ get isAutoExtensible(): boolean;
7
+ get(index: number): LayerConfig;
8
+ getNodeInfo(index: number): Visual.NodeInfo;
9
+ format(index: number, type: NodeAxis.Format): any;
10
+ find(query: Visual.Condition): number | null;
11
+ extends(direction: any, minimum: any): number;
12
+ dispose(): any;
13
+ }
@@ -0,0 +1,5 @@
1
+ import IntervalResolver from "./resolvers/IntervalResolver";
2
+ declare const _default: {
3
+ interval: typeof IntervalResolver;
4
+ };
5
+ export default _default;
@@ -0,0 +1,7 @@
1
+ import IntervalResolver from './resolvers/IntervalResolver.js';
2
+
3
+ var mapping = {
4
+ interval: IntervalResolver
5
+ };
6
+
7
+ export { mapping as default };
@@ -0,0 +1,30 @@
1
+ import { DateTime } from "luxon";
2
+ import { NodeAxis } from "../../../NodeAxis/src/types";
3
+ import { LayerConfig } from "../types";
4
+ import LayerResolver from "../interface/LayerResolver";
5
+ import { Visual } from "../types";
6
+ export declare const EMPTY_STRING: string;
7
+ export default class IntervalResolver implements LayerResolver {
8
+ protected options: any;
9
+ protected injection: any;
10
+ protected range: Visual.DateRange;
11
+ protected step: number;
12
+ protected unit: Visual.DateUnit;
13
+ protected transform: Visual.Transform[];
14
+ protected layer: any;
15
+ protected total: number;
16
+ constructor(options: Visual.Node, injection: any);
17
+ get count(): number;
18
+ get period(): string;
19
+ get isAutoExtensible(): boolean;
20
+ get(index: number): LayerConfig;
21
+ getNodeInfo(index: number): Visual.NodeInfo;
22
+ format(index: number, type: NodeAxis.Format): string;
23
+ formatByInject(index: number, type: NodeAxis.Format, finalFormat: string): string;
24
+ find(query: Visual.Condition): number | null;
25
+ extends(direction: number, minimum: number): number;
26
+ dispose(): void;
27
+ protected getQuery(index: number): any;
28
+ protected getNodeInfoByTime(time: DateTime): Visual.NodeInfo;
29
+ protected getTime(index: number): DateTime;
30
+ }
@@ -0,0 +1,170 @@
1
+ import _classCallCheck from '@babel/runtime/helpers/classCallCheck';
2
+ import _createClass from '@babel/runtime/helpers/createClass';
3
+ import _defineProperty from '@babel/runtime/helpers/defineProperty';
4
+ import { DateTime } from 'luxon';
5
+ import { toFormat, getFormatDate, getCount } from './tools.resolver.js';
6
+
7
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
8
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
9
+ var EMPTY_STRING = Object.freeze("");
10
+ var IntervalResolver = /*#__PURE__*/function () {
11
+ function IntervalResolver(options, injection) {
12
+ _classCallCheck(this, IntervalResolver);
13
+ _defineProperty(this, "options", void 0);
14
+ _defineProperty(this, "injection", void 0);
15
+ _defineProperty(this, "range", void 0);
16
+ _defineProperty(this, "step", void 0);
17
+ _defineProperty(this, "unit", void 0);
18
+ _defineProperty(this, "transform", void 0);
19
+ _defineProperty(this, "layer", void 0);
20
+ _defineProperty(this, "total", void 0);
21
+ this.options = options;
22
+ this.injection = injection;
23
+ this.transform = options.transform;
24
+ this.step = options.interval;
25
+ this.unit = options.symbol;
26
+ this.layer = options.layer;
27
+ this.range = options.range.map(function (e) {
28
+ return DateTime.fromSQL(e);
29
+ });
30
+ this.total = getCount(this.range, this.unit, this.step);
31
+ }
32
+ _createClass(IntervalResolver, [{
33
+ key: "count",
34
+ get: function get() {
35
+ return this.total;
36
+ }
37
+ }, {
38
+ key: "period",
39
+ get: function get() {
40
+ return this.options.period;
41
+ }
42
+ }, {
43
+ key: "isAutoExtensible",
44
+ get: function get() {
45
+ return true;
46
+ }
47
+ }, {
48
+ key: "get",
49
+ value: function get(index) {
50
+ var name = this.format(index, "short");
51
+ var custom = this.getQuery(index);
52
+ var injection = this.injection;
53
+ if (this.layer.type === "group") {
54
+ return {
55
+ injection: injection,
56
+ type: "group",
57
+ opacity: this.layer.opacity,
58
+ layers: this.layer.layers.map(function (layer) {
59
+ return Object.assign({
60
+ name: name
61
+ }, layer, {
62
+ custom: custom
63
+ });
64
+ })
65
+ };
66
+ }
67
+ return Object.assign({
68
+ name: name,
69
+ injection: injection
70
+ }, this.layer, {
71
+ custom: custom
72
+ });
73
+ }
74
+ }, {
75
+ key: "getNodeInfo",
76
+ value: function getNodeInfo(index) {
77
+ return Object.assign(this.getNodeInfoByTime(this.getTime(index)), {
78
+ extend: this.options.extend,
79
+ fields: this.getQuery(index),
80
+ layer: this.options.layer
81
+ });
82
+ }
83
+ }, {
84
+ key: "format",
85
+ value: function format(index, type) {
86
+ var pattern = this.options.format[type];
87
+ if (pattern != null) {
88
+ return toFormat(pattern, this.getNodeInfo(index));
89
+ }
90
+ return EMPTY_STRING;
91
+ }
92
+ }, {
93
+ key: "formatByInject",
94
+ value: function formatByInject(index, type, finalFormat) {
95
+ var pattern = this.options.format[type];
96
+ if (pattern != null) {
97
+ return getFormatDate(pattern, this.getNodeInfo(index), finalFormat);
98
+ }
99
+ return EMPTY_STRING;
100
+ }
101
+ }, {
102
+ key: "find",
103
+ value: function find(query) {
104
+ if (query.time != null) {
105
+ var target = DateTime.fromSQL(query.time),
106
+ begin = this.range[0];
107
+ if (this.unit === "xun") {
108
+ return Math.round(target.diff(begin, "month").months * 3);
109
+ }
110
+ return Math.round(target.diff(begin, this.unit).get(this.unit) / this.step);
111
+ }
112
+ return null;
113
+ }
114
+ }, {
115
+ key: "extends",
116
+ value: function _extends(direction, minimum) {
117
+ var side = direction < 0 ? 0 : 1,
118
+ unit = this.unit,
119
+ step = this.step,
120
+ time = this.range[side];
121
+ this.range[side] = time.plus(_defineProperty({}, unit, minimum * direction * step));
122
+ this.total += minimum;
123
+ return minimum;
124
+ }
125
+ }, {
126
+ key: "dispose",
127
+ value: function dispose() {
128
+ this.options = null;
129
+ this.transform = null;
130
+ this.injection = null;
131
+ }
132
+ }, {
133
+ key: "getQuery",
134
+ value: function getQuery(index) {
135
+ var _this = this;
136
+ var time = this.getTime(index);
137
+ var now = DateTime.fromMillis(Date.now());
138
+ return this.transform.reduce(function (model, item) {
139
+ var clone = time,
140
+ offset = item.offset;
141
+ if (clone.hasSame(now, "day") && clone.hour < item.split) offset = 0;
142
+ if (offset) clone = clone.plus({
143
+ "millisecond": offset
144
+ });
145
+ model[item.field] = toFormat(item.pattern, _this.getNodeInfoByTime(clone));
146
+ return model;
147
+ }, {});
148
+ }
149
+ }, {
150
+ key: "getNodeInfoByTime",
151
+ value: function getNodeInfoByTime(time) {
152
+ return _objectSpread({
153
+ time: time,
154
+ unit: this.unit,
155
+ step: this.step
156
+ }, this.injection);
157
+ }
158
+ }, {
159
+ key: "getTime",
160
+ value: function getTime(index) {
161
+ if (index === 0) {
162
+ return this.range[0];
163
+ }
164
+ return this.range[0].plus(_defineProperty({}, this.unit, index * this.step));
165
+ }
166
+ }]);
167
+ return IntervalResolver;
168
+ }();
169
+
170
+ export { EMPTY_STRING, IntervalResolver as default };
@@ -0,0 +1,4 @@
1
+ import { Visual } from "../types";
2
+ export declare function getCount(range: Visual.DateRange, symbol: Visual.DateUnit, interval: number): number;
3
+ export declare function toFormat(pattern: string, nodeInfo: Visual.NodeInfo): string;
4
+ export declare function getFormatDate(pattern: string, nodeInfo: Visual.NodeInfo, resolveFormat?: string): any;