@nocobase/plugin-data-visualization 0.10.1-alpha.1

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 (108) hide show
  1. package/LICENSE +661 -0
  2. package/README.md +88 -0
  3. package/client.d.ts +3 -0
  4. package/client.js +65 -0
  5. package/lib/client/Settings.d.ts +2 -0
  6. package/lib/client/Settings.js +81 -0
  7. package/lib/client/block/ChartBlock.d.ts +2 -0
  8. package/lib/client/block/ChartBlock.js +73 -0
  9. package/lib/client/block/ChartBlockDesigner.d.ts +2 -0
  10. package/lib/client/block/ChartBlockDesigner.js +35 -0
  11. package/lib/client/block/ChartBlockInitializer.d.ts +6 -0
  12. package/lib/client/block/ChartBlockInitializer.js +114 -0
  13. package/lib/client/block/ChartConfigure.d.ts +33 -0
  14. package/lib/client/block/ChartConfigure.js +501 -0
  15. package/lib/client/block/formatters.d.ts +15 -0
  16. package/lib/client/block/formatters.js +58 -0
  17. package/lib/client/block/index.d.ts +4 -0
  18. package/lib/client/block/index.js +49 -0
  19. package/lib/client/block/schemas/configure.d.ts +4 -0
  20. package/lib/client/block/schemas/configure.js +492 -0
  21. package/lib/client/block/transformers.d.ts +6 -0
  22. package/lib/client/block/transformers.js +69 -0
  23. package/lib/client/hooks.d.ts +312 -0
  24. package/lib/client/hooks.js +275 -0
  25. package/lib/client/index.d.ts +5 -0
  26. package/lib/client/index.js +70 -0
  27. package/lib/client/locale/en-US.d.ts +23 -0
  28. package/lib/client/locale/en-US.js +29 -0
  29. package/lib/client/locale/index.d.ts +3 -0
  30. package/lib/client/locale/index.js +39 -0
  31. package/lib/client/locale/ja-JP.d.ts +2 -0
  32. package/lib/client/locale/ja-JP.js +8 -0
  33. package/lib/client/locale/pt-BR.d.ts +23 -0
  34. package/lib/client/locale/pt-BR.js +29 -0
  35. package/lib/client/locale/ru-RU.d.ts +2 -0
  36. package/lib/client/locale/ru-RU.js +8 -0
  37. package/lib/client/locale/tr-TR.d.ts +2 -0
  38. package/lib/client/locale/tr-TR.js +8 -0
  39. package/lib/client/locale/zh-CN.d.ts +70 -0
  40. package/lib/client/locale/zh-CN.js +76 -0
  41. package/lib/client/renderer/ChartLibrary.d.ts +71 -0
  42. package/lib/client/renderer/ChartLibrary.js +140 -0
  43. package/lib/client/renderer/ChartRenderer.d.ts +7 -0
  44. package/lib/client/renderer/ChartRenderer.js +258 -0
  45. package/lib/client/renderer/ChartRendererProvider.d.ts +43 -0
  46. package/lib/client/renderer/ChartRendererProvider.js +38 -0
  47. package/lib/client/renderer/index.d.ts +4 -0
  48. package/lib/client/renderer/index.js +49 -0
  49. package/lib/client/renderer/library/AntdLibrary.d.ts +2 -0
  50. package/lib/client/renderer/library/AntdLibrary.js +123 -0
  51. package/lib/client/renderer/library/G2PlotLibrary.d.ts +2 -0
  52. package/lib/client/renderer/library/G2PlotLibrary.js +288 -0
  53. package/lib/client/renderer/library/index.d.ts +3 -0
  54. package/lib/client/renderer/library/index.js +15 -0
  55. package/lib/client/utils.d.ts +96 -0
  56. package/lib/client/utils.js +137 -0
  57. package/lib/index.d.ts +1 -0
  58. package/lib/index.js +13 -0
  59. package/lib/server/actions/formatter.d.ts +3 -0
  60. package/lib/server/actions/formatter.js +44 -0
  61. package/lib/server/actions/query.d.ts +86 -0
  62. package/lib/server/actions/query.js +326 -0
  63. package/lib/server/index.d.ts +1 -0
  64. package/lib/server/index.js +13 -0
  65. package/lib/server/plugin.d.ts +13 -0
  66. package/lib/server/plugin.js +64 -0
  67. package/package.json +23 -0
  68. package/server.d.ts +3 -0
  69. package/server.js +65 -0
  70. package/src/client/Settings.tsx +43 -0
  71. package/src/client/__tests__/chart-configure.test.tsx +14 -0
  72. package/src/client/__tests__/chart-library.test.ts +78 -0
  73. package/src/client/__tests__/chart-renderer.test.tsx +30 -0
  74. package/src/client/__tests__/hooks.test.ts +261 -0
  75. package/src/client/block/ChartBlock.tsx +22 -0
  76. package/src/client/block/ChartBlockDesigner.tsx +19 -0
  77. package/src/client/block/ChartBlockInitializer.tsx +83 -0
  78. package/src/client/block/ChartConfigure.tsx +450 -0
  79. package/src/client/block/formatters.ts +70 -0
  80. package/src/client/block/index.ts +4 -0
  81. package/src/client/block/schemas/configure.ts +474 -0
  82. package/src/client/block/transformers.ts +52 -0
  83. package/src/client/hooks.ts +239 -0
  84. package/src/client/index.tsx +41 -0
  85. package/src/client/locale/en-US.ts +23 -0
  86. package/src/client/locale/index.ts +19 -0
  87. package/src/client/locale/ja-JP.ts +1 -0
  88. package/src/client/locale/pt-BR.ts +23 -0
  89. package/src/client/locale/ru-RU.ts +1 -0
  90. package/src/client/locale/tr-TR.ts +1 -0
  91. package/src/client/locale/zh-CN.ts +71 -0
  92. package/src/client/renderer/ChartLibrary.tsx +178 -0
  93. package/src/client/renderer/ChartRenderer.tsx +201 -0
  94. package/src/client/renderer/ChartRendererProvider.tsx +58 -0
  95. package/src/client/renderer/index.ts +4 -0
  96. package/src/client/renderer/library/AntdLibrary.tsx +94 -0
  97. package/src/client/renderer/library/G2PlotLibrary.tsx +236 -0
  98. package/src/client/renderer/library/index.tsx +4 -0
  99. package/src/client/utils.ts +102 -0
  100. package/src/index.ts +1 -0
  101. package/src/server/__tests__/api.test.ts +105 -0
  102. package/src/server/__tests__/formatter.test.ts +49 -0
  103. package/src/server/__tests__/query.test.ts +220 -0
  104. package/src/server/actions/formatter.ts +49 -0
  105. package/src/server/actions/query.ts +285 -0
  106. package/src/server/collections/.gitkeep +0 -0
  107. package/src/server/index.ts +1 -0
  108. package/src/server/plugin.ts +37 -0
@@ -0,0 +1,492 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.transformSchema = exports.querySchema = exports.getConfigSchema = void 0;
7
+ function _shared() {
8
+ const data = require("@formily/shared");
9
+ _shared = function _shared() {
10
+ return data;
11
+ };
12
+ return data;
13
+ }
14
+ var _locale = require("../../locale");
15
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
16
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
17
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
18
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
19
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
20
+ const getArraySchema = (fields = {}, extra = {}) => _objectSpread(_objectSpread({
21
+ type: 'array',
22
+ 'x-decorator': 'FormItem',
23
+ 'x-component': 'ArrayItems'
24
+ }, extra), {}, {
25
+ items: {
26
+ type: 'object',
27
+ properties: {
28
+ space: {
29
+ type: 'void',
30
+ 'x-component': 'Space',
31
+ properties: _objectSpread(_objectSpread({
32
+ sort: {
33
+ type: 'void',
34
+ 'x-decorator': 'FormItem',
35
+ 'x-component': 'ArrayItems.SortHandle'
36
+ }
37
+ }, fields), {}, {
38
+ remove: {
39
+ type: 'void',
40
+ 'x-decorator': 'FormItem',
41
+ 'x-component': 'ArrayItems.Remove'
42
+ }
43
+ })
44
+ }
45
+ }
46
+ },
47
+ properties: {
48
+ add: {
49
+ type: 'void',
50
+ title: '{{t("Add field")}}',
51
+ 'x-component': 'ArrayItems.Addition'
52
+ }
53
+ }
54
+ });
55
+ const getConfigSchema = general => ({
56
+ type: 'void',
57
+ properties: {
58
+ config: {
59
+ type: 'object',
60
+ properties: {
61
+ chartType: {
62
+ type: 'string',
63
+ title: '{{t("Chart type")}}',
64
+ 'x-decorator': 'FormItem',
65
+ 'x-component': 'Select',
66
+ 'x-component-props': {
67
+ placeholder: '{{t("Please select a chart type.")}}'
68
+ },
69
+ enum: '{{ chartTypes }}'
70
+ },
71
+ [(0, _shared().uid)()]: {
72
+ type: 'void',
73
+ properties: {
74
+ general
75
+ }
76
+ },
77
+ [(0, _shared().uid)()]: {
78
+ type: 'void',
79
+ properties: {
80
+ advanced: {
81
+ type: 'json',
82
+ title: '{{t("JSON config")}}',
83
+ 'x-decorator': 'FormItem',
84
+ 'x-decorator-props': {
85
+ extra: (0, _locale.lang)('Same properties set in the form above will be overwritten by this JSON config.')
86
+ },
87
+ 'x-component': 'Input.JSON',
88
+ 'x-component-props': {
89
+ autoSize: {
90
+ minRows: 3
91
+ }
92
+ }
93
+ }
94
+ }
95
+ },
96
+ reference: {
97
+ type: 'string',
98
+ 'x-reactions': {
99
+ dependencies: ['.chartType'],
100
+ fulfill: {
101
+ schema: {
102
+ 'x-content': '{{ getReference($deps[0]) }}'
103
+ }
104
+ }
105
+ }
106
+ }
107
+ }
108
+ }
109
+ }
110
+ });
111
+ exports.getConfigSchema = getConfigSchema;
112
+ const querySchema = {
113
+ type: 'void',
114
+ properties: {
115
+ settings: {
116
+ type: 'void',
117
+ // 'x-component': 'FormItem',
118
+ properties: {
119
+ // mode: {
120
+ // type: 'string',
121
+ // 'x-decorator': 'FormItem',
122
+ // 'x-decorator-props': {
123
+ // style: {
124
+ // display: 'inline-block',
125
+ // width: '45%',
126
+ // },
127
+ // },
128
+ // 'x-component': 'Radio.Group',
129
+ // 'x-component-props': {
130
+ // defaultValue: 'builder',
131
+ // optionType: 'button',
132
+ // buttonStyle: 'solid',
133
+ // },
134
+ // enum: [
135
+ // {
136
+ // label: lang('Builder mode'),
137
+ // value: 'builder',
138
+ // },
139
+ // {
140
+ // label: lang('SQL mode'),
141
+ // value: 'sql',
142
+ // },
143
+ // ],
144
+ // 'x-reactions': [
145
+ // {
146
+ // target: 'query.builder',
147
+ // fulfill: {
148
+ // state: {
149
+ // visible: '{{ $self.value !== "sql" }}',
150
+ // },
151
+ // },
152
+ // },
153
+ // {
154
+ // target: 'query.sql',
155
+ // fulfill: {
156
+ // state: {
157
+ // visible: '{{ $self.value === "sql" }}',
158
+ // },
159
+ // },
160
+ // },
161
+ // ],
162
+ // },
163
+ collection: {
164
+ title: '{{t("Collection")}}',
165
+ type: 'string',
166
+ 'x-decorator': 'FormItem',
167
+ 'x-component': 'Select',
168
+ 'x-component-props': {
169
+ options: '{{ collectionOptions }}',
170
+ onChange: '{{ onCollectionChange }}',
171
+ placeholder: (0, _locale.lang)('Collection')
172
+ }
173
+ }
174
+ }
175
+ },
176
+ query: {
177
+ type: 'object',
178
+ properties: {
179
+ builder: {
180
+ type: 'void',
181
+ properties: {
182
+ collapse: {
183
+ type: 'void',
184
+ 'x-decorator': 'FormItem',
185
+ 'x-component': 'FormCollapse',
186
+ 'x-component-props': {
187
+ formCollapse: '{{formCollapse}}'
188
+ },
189
+ properties: {
190
+ pane1: {
191
+ type: 'void',
192
+ 'x-component': 'FormCollapse.CollapsePanel',
193
+ 'x-component-props': {
194
+ header: (0, _locale.lang)('Measures'),
195
+ key: 'measures'
196
+ },
197
+ properties: {
198
+ measures: getArraySchema({
199
+ field: {
200
+ type: 'string',
201
+ 'x-decorator': 'FormItem',
202
+ 'x-component': 'Cascader',
203
+ 'x-component-props': {
204
+ placeholder: '{{t("Field")}}',
205
+ fieldNames: {
206
+ label: 'title',
207
+ value: 'name',
208
+ children: 'children'
209
+ }
210
+ },
211
+ enum: '{{ fieldOptions }}',
212
+ required: true
213
+ },
214
+ aggregation: {
215
+ type: 'string',
216
+ 'x-decorator': 'FormItem',
217
+ 'x-component': 'Select',
218
+ 'x-component-props': {
219
+ placeholder: '{{t("Aggregation")}}'
220
+ },
221
+ enum: [{
222
+ label: (0, _locale.lang)('Sum'),
223
+ value: 'sum'
224
+ }, {
225
+ label: (0, _locale.lang)('Count'),
226
+ value: 'count'
227
+ }, {
228
+ label: (0, _locale.lang)('Avg'),
229
+ value: 'avg'
230
+ }, {
231
+ label: (0, _locale.lang)('Max'),
232
+ value: 'max'
233
+ }, {
234
+ label: (0, _locale.lang)('Min'),
235
+ value: 'min'
236
+ }]
237
+ },
238
+ alias: {
239
+ type: 'string',
240
+ 'x-decorator': 'FormItem',
241
+ 'x-component': 'Input',
242
+ 'x-component-props': {
243
+ placeholder: '{{t("Alias")}}'
244
+ }
245
+ }
246
+ }, {
247
+ required: true
248
+ })
249
+ }
250
+ },
251
+ pane2: {
252
+ type: 'void',
253
+ 'x-component': 'FormCollapse.CollapsePanel',
254
+ 'x-component-props': {
255
+ header: (0, _locale.lang)('Dimensions'),
256
+ key: 'dimensions'
257
+ },
258
+ properties: {
259
+ dimensions: getArraySchema({
260
+ field: {
261
+ type: 'string',
262
+ 'x-decorator': 'FormItem',
263
+ 'x-component': 'Cascader',
264
+ 'x-component-props': {
265
+ placeholder: '{{t("Field")}}',
266
+ fieldNames: {
267
+ label: 'title',
268
+ value: 'name',
269
+ children: 'children'
270
+ }
271
+ },
272
+ enum: '{{ fieldOptions }}',
273
+ required: true
274
+ },
275
+ format: {
276
+ type: 'string',
277
+ 'x-decorator': 'FormItem',
278
+ 'x-component': 'Select',
279
+ 'x-component-props': {
280
+ placeholder: '{{t("Format")}}',
281
+ style: {
282
+ maxWidth: '120px'
283
+ }
284
+ },
285
+ 'x-reactions': '{{ useFormatterOptions }}',
286
+ 'x-visible': '{{ $self.dataSource && $self.dataSource.length }}'
287
+ },
288
+ alias: {
289
+ type: 'string',
290
+ 'x-decorator': 'FormItem',
291
+ 'x-component': 'Input',
292
+ 'x-component-props': {
293
+ placeholder: '{{t("Alias")}}'
294
+ }
295
+ }
296
+ })
297
+ }
298
+ },
299
+ pane3: {
300
+ type: 'void',
301
+ 'x-component': 'FormCollapse.CollapsePanel',
302
+ 'x-component-props': {
303
+ header: (0, _locale.lang)('Filter'),
304
+ key: 'filter'
305
+ },
306
+ properties: {
307
+ filter: {
308
+ type: 'object',
309
+ 'x-decorator': 'FormItem',
310
+ 'x-decorator-props': {
311
+ style: {
312
+ overflow: 'scroll'
313
+ }
314
+ },
315
+ 'x-component': 'Filter',
316
+ 'x-component-props': {
317
+ options: '{{ filterOptions }}'
318
+ // dynamicComponent: 'Input',
319
+ }
320
+ }
321
+ }
322
+ },
323
+
324
+ pane4: {
325
+ type: 'void',
326
+ 'x-component': 'FormCollapse.CollapsePanel',
327
+ 'x-component-props': {
328
+ header: (0, _locale.lang)('Sort'),
329
+ key: 'sort'
330
+ },
331
+ properties: {
332
+ orders: getArraySchema({
333
+ field: {
334
+ type: 'string',
335
+ 'x-decorator': 'FormItem',
336
+ 'x-component': 'Cascader',
337
+ 'x-component-props': {
338
+ placeholder: '{{t("Field")}}'
339
+ },
340
+ 'x-reactions': '{{ useOrderOptions }}',
341
+ required: true
342
+ },
343
+ order: {
344
+ type: 'string',
345
+ 'x-decorator': 'FormItem',
346
+ 'x-component': 'Radio.Group',
347
+ 'x-component-props': {
348
+ defaultValue: 'ASC',
349
+ optionType: 'button'
350
+ },
351
+ enum: ['ASC', 'DESC']
352
+ }
353
+ }, {
354
+ 'x-reactions': '{{ useOrderReaction }}'
355
+ })
356
+ }
357
+ }
358
+ }
359
+ },
360
+ limit: {
361
+ title: '{{t("Limit")}}',
362
+ type: 'number',
363
+ 'x-decorator': 'FormItem',
364
+ 'x-component': 'InputNumber',
365
+ 'x-component-props': {
366
+ defaultValue: 2000,
367
+ max: 2000,
368
+ min: 1,
369
+ style: {
370
+ width: '100px'
371
+ }
372
+ }
373
+ }
374
+ }
375
+ },
376
+ // sql: {
377
+ // type: 'object',
378
+ // properties: {
379
+ // select: {
380
+ // type: 'void',
381
+ // 'x-decorator': 'p',
382
+ // 'x-component': 'Text',
383
+ // 'x-component-props': {
384
+ // code: true,
385
+ // },
386
+ // 'x-content': 'SELECT',
387
+ // },
388
+ // fields: {
389
+ // type: 'string',
390
+ // 'x-decorator': 'FormItem',
391
+ // 'x-component': 'Input.TextArea',
392
+ // 'x-component-props': {
393
+ // autoSize: {
394
+ // minRows: 2,
395
+ // },
396
+ // placeholder: 'Fields',
397
+ // },
398
+ // required: true,
399
+ // },
400
+ // from: {
401
+ // type: 'void',
402
+ // 'x-decorator': 'p',
403
+ // 'x-component': 'FromSql',
404
+ // },
405
+ // clauses: {
406
+ // type: 'string',
407
+ // 'x-decorator': 'FormItem',
408
+ // 'x-component': 'Input.TextArea',
409
+ // 'x-component-props': {
410
+ // autoSize: {
411
+ // minRows: 5,
412
+ // },
413
+ // placeholder: 'Join, Where, Group By, Having, Order By, Limit',
414
+ // },
415
+ // required: true,
416
+ // },
417
+ // },
418
+ // },
419
+ cache: {
420
+ type: 'object',
421
+ properties: {
422
+ enabled: {
423
+ type: 'boolean',
424
+ title: '{{t("Enable cache")}}',
425
+ 'x-decorator': 'FormItem',
426
+ 'x-component': 'Switch'
427
+ },
428
+ ttl: {
429
+ type: 'number',
430
+ title: '{{t("TTL (second)")}}',
431
+ 'x-decorator': 'FormItem',
432
+ 'x-component': 'InputNumber',
433
+ 'x-component-props': {
434
+ defaultValue: 60,
435
+ min: 1,
436
+ style: {
437
+ width: '100px'
438
+ }
439
+ }
440
+ }
441
+ }
442
+ }
443
+ }
444
+ }
445
+ }
446
+ };
447
+ exports.querySchema = querySchema;
448
+ const transformSchema = {
449
+ type: 'void',
450
+ properties: {
451
+ transform: getArraySchema({
452
+ field: {
453
+ type: 'string',
454
+ 'x-decorator': 'FormItem',
455
+ 'x-component': 'Select',
456
+ 'x-component-props': {
457
+ placeholder: '{{t("Field")}}',
458
+ style: {
459
+ maxWidth: '100px'
460
+ }
461
+ },
462
+ 'x-reactions': '{{ useChartFields }}'
463
+ },
464
+ type: {
465
+ type: 'string',
466
+ 'x-decorator': 'FormItem',
467
+ 'x-component': 'Select',
468
+ 'x-component-props': {
469
+ placeholder: '{{t("Type")}}'
470
+ },
471
+ 'x-reactions': '{{ useFieldTypeOptions }}'
472
+ },
473
+ format: {
474
+ type: 'string',
475
+ 'x-decorator': 'FormItem',
476
+ 'x-component': 'Select',
477
+ 'x-component-props': {
478
+ placeholder: '{{t("Format")}}'
479
+ },
480
+ 'x-reactions': '{{ useTransformers }}',
481
+ 'x-visible': '{{ $self.dataSource && $self.dataSource.length }}'
482
+ }
483
+ }, {
484
+ 'x-decorator-props': {
485
+ style: {
486
+ width: '50%'
487
+ }
488
+ }
489
+ })
490
+ }
491
+ };
492
+ exports.transformSchema = transformSchema;
@@ -0,0 +1,6 @@
1
+ declare const transformers: {
2
+ [key: string]: {
3
+ [key: string]: (val: any, locale?: string) => string | number;
4
+ };
5
+ };
6
+ export default transformers;
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ function _dayjs() {
8
+ const data = _interopRequireDefault(require("dayjs"));
9
+ _dayjs = function _dayjs() {
10
+ return data;
11
+ };
12
+ return data;
13
+ }
14
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
+ const transformers = {
16
+ datetime: {
17
+ YYYY: val => (0, _dayjs().default)(val).format('YYYY'),
18
+ MM: val => (0, _dayjs().default)(val).format('MM'),
19
+ DD: val => (0, _dayjs().default)(val).format('DD'),
20
+ 'YYYY-MM': val => (0, _dayjs().default)(val).format('YYYY-MM'),
21
+ 'YYYY-MM-DD': val => (0, _dayjs().default)(val).format('YYYY-MM-DD'),
22
+ 'YYYY-MM-DD hh:mm': val => (0, _dayjs().default)(val).format('YYYY-MM-DD hh:mm'),
23
+ 'YYYY-MM-DD hh:mm:ss': val => (0, _dayjs().default)(val).format('YYYY-MM-DD hh:mm:ss')
24
+ },
25
+ date: {
26
+ YYYY: val => (0, _dayjs().default)(val).format('YYYY'),
27
+ MM: val => (0, _dayjs().default)(val).format('MM'),
28
+ DD: val => (0, _dayjs().default)(val).format('DD'),
29
+ 'YYYY-MM': val => (0, _dayjs().default)(val).format('YYYY-MM'),
30
+ 'YYYY-MM-DD': val => (0, _dayjs().default)(val).format('YYYY-MM-DD')
31
+ },
32
+ time: {
33
+ 'hh:mm:ss': val => (0, _dayjs().default)(val).format('hh:mm:ss'),
34
+ 'hh:mm': val => (0, _dayjs().default)(val).format('hh:mm'),
35
+ hh: val => (0, _dayjs().default)(val).format('hh')
36
+ },
37
+ number: {
38
+ Percent: val => new Intl.NumberFormat('en-US', {
39
+ style: 'percent',
40
+ minimumFractionDigits: 2,
41
+ maximumFractionDigits: 2
42
+ }).format(val),
43
+ Currency: (val, locale = 'en-US') => {
44
+ const currency = {
45
+ 'zh-CN': 'CNY',
46
+ 'en-US': 'USD',
47
+ 'ja-JP': 'JPY',
48
+ 'ko-KR': 'KRW',
49
+ 'pt-BR': 'BRL',
50
+ 'ru-RU': 'RUB',
51
+ 'tr-TR': 'TRY',
52
+ 'es-ES': 'EUR'
53
+ }[locale];
54
+ return new Intl.NumberFormat(locale, {
55
+ style: 'currency',
56
+ currency
57
+ }).format(val);
58
+ },
59
+ Exponential: val => {
60
+ var _val;
61
+ return (_val = +val) === null || _val === void 0 ? void 0 : _val.toExponential();
62
+ },
63
+ Abbreviation: (val, locale = 'en-US') => new Intl.NumberFormat(locale, {
64
+ notation: 'compact'
65
+ }).format(val)
66
+ }
67
+ };
68
+ var _default = transformers;
69
+ exports.default = _default;