@orbcharts/core 3.0.0-beta.6 → 3.0.0-beta.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/LICENSE +200 -200
  2. package/dist/orbcharts-core.es.js +486 -483
  3. package/dist/orbcharts-core.umd.js +3 -3
  4. package/dist/src/defaults.d.ts +1 -1
  5. package/lib/core-types.ts +7 -7
  6. package/package.json +42 -42
  7. package/src/AbstractChart.ts +57 -57
  8. package/src/GridChart.ts +24 -24
  9. package/src/MultiGridChart.ts +24 -24
  10. package/src/MultiValueChart.ts +24 -24
  11. package/src/RelationshipChart.ts +24 -24
  12. package/src/SeriesChart.ts +24 -24
  13. package/src/TreeChart.ts +24 -24
  14. package/src/base/createBaseChart.ts +505 -505
  15. package/src/base/createBasePlugin.ts +153 -153
  16. package/src/base/validators/chartOptionsValidator.ts +23 -23
  17. package/src/base/validators/chartParamsValidator.ts +133 -133
  18. package/src/base/validators/elementValidator.ts +13 -13
  19. package/src/base/validators/pluginsValidator.ts +14 -14
  20. package/src/defaults.ts +238 -235
  21. package/src/defineGridPlugin.ts +3 -3
  22. package/src/defineMultiGridPlugin.ts +3 -3
  23. package/src/defineMultiValuePlugin.ts +3 -3
  24. package/src/defineNoneDataPlugin.ts +4 -4
  25. package/src/defineRelationshipPlugin.ts +3 -3
  26. package/src/defineSeriesPlugin.ts +3 -3
  27. package/src/defineTreePlugin.ts +3 -3
  28. package/src/grid/computedDataFn.ts +129 -129
  29. package/src/grid/contextObserverCallback.ts +176 -176
  30. package/src/grid/dataFormatterValidator.ts +101 -101
  31. package/src/grid/dataValidator.ts +12 -12
  32. package/src/index.ts +20 -20
  33. package/src/multiGrid/computedDataFn.ts +123 -123
  34. package/src/multiGrid/contextObserverCallback.ts +41 -41
  35. package/src/multiGrid/dataFormatterValidator.ts +115 -115
  36. package/src/multiGrid/dataValidator.ts +12 -12
  37. package/src/multiValue/computedDataFn.ts +110 -110
  38. package/src/multiValue/contextObserverCallback.ts +160 -160
  39. package/src/multiValue/dataFormatterValidator.ts +9 -9
  40. package/src/multiValue/dataValidator.ts +9 -9
  41. package/src/relationship/computedDataFn.ts +144 -144
  42. package/src/relationship/contextObserverCallback.ts +80 -80
  43. package/src/relationship/dataFormatterValidator.ts +9 -9
  44. package/src/relationship/dataValidator.ts +9 -9
  45. package/src/series/computedDataFn.ts +88 -88
  46. package/src/series/contextObserverCallback.ts +100 -100
  47. package/src/series/dataFormatterValidator.ts +41 -41
  48. package/src/series/dataValidator.ts +12 -12
  49. package/src/tree/computedDataFn.ts +129 -129
  50. package/src/tree/contextObserverCallback.ts +58 -58
  51. package/src/tree/dataFormatterValidator.ts +13 -13
  52. package/src/tree/dataValidator.ts +13 -13
  53. package/src/utils/commonUtils.ts +55 -55
  54. package/src/utils/d3Scale.ts +198 -198
  55. package/src/utils/errorMessage.ts +42 -42
  56. package/src/utils/gridObservables.ts +683 -683
  57. package/src/utils/index.ts +9 -9
  58. package/src/utils/multiGridObservables.ts +392 -392
  59. package/src/utils/multiValueObservables.ts +661 -661
  60. package/src/utils/observables.ts +219 -219
  61. package/src/utils/orbchartsUtils.ts +377 -377
  62. package/src/utils/relationshipObservables.ts +84 -84
  63. package/src/utils/seriesObservables.ts +175 -175
  64. package/src/utils/treeObservables.ts +105 -105
  65. package/src/utils/validator.ts +126 -126
  66. package/tsconfig.base.json +13 -13
  67. package/tsconfig.json +2 -2
  68. package/vite-env.d.ts +6 -6
  69. package/vite.config.js +22 -22
@@ -1,153 +1,153 @@
1
- import {
2
- catchError,
3
- of,
4
- takeUntil,
5
- map,
6
- switchMap,
7
- shareReplay,
8
- startWith,
9
- EMPTY,
10
- Subject,
11
- BehaviorSubject,
12
- Observable
13
- } from 'rxjs'
14
- import type {
15
- ChartType,
16
- CreateBasePlugin,
17
- DefinePluginConfig,
18
- PluginInitFn,
19
- PluginContext,
20
- PluginEntity } from '../../lib/core-types'
21
- import { mergeOptionsWithDefault } from '../utils'
22
- import { createValidatorErrorMessage, createValidatorWarningMessage, createOrbChartsErrorMessage } from '../utils/errorMessage'
23
- import { validateColumns } from '../utils/validator'
24
-
25
- // 建立plugin實例
26
- function createPluginEntity <T extends ChartType, PluginName, PluginParams>({ chartType, config, initFn }: {
27
- chartType: T
28
- config: DefinePluginConfig<PluginName, PluginParams>
29
- initFn: PluginInitFn<T, PluginName, PluginParams>
30
- }): PluginEntity<T, PluginName, PluginParams> {
31
-
32
- const destroy$ = new Subject()
33
- const EntityWeakMap = new WeakMap() // <selection, pluginEntity> 避免只移除selection而沒回收pluginEntity的memory leak
34
- let pluginDestroyFn = () => {}
35
- let pluginContext: PluginContext<T, PluginName, PluginParams> | undefined
36
- const mergedDefaultParams$ = new BehaviorSubject(config.defaultParams)
37
- const params$: Subject<Partial<typeof config.defaultParams>> = new BehaviorSubject({})
38
- const fullParams$ = mergedDefaultParams$.pipe(
39
- switchMap(mergedDefaultParams => {
40
- return params$
41
- .pipe(
42
- takeUntil(destroy$),
43
- map(d => {
44
- try {
45
- // 檢查 data$ 資料格式是否正確
46
- const { status, columnName, expectToBe } = config.validator(d, {
47
- validateColumns
48
- })
49
- if (status === 'error') {
50
- throw new Error(createValidatorErrorMessage({
51
- columnName,
52
- expectToBe,
53
- from: `${config.name}.params$`
54
- }))
55
- } else if (status === 'warning') {
56
- console.warn(createValidatorWarningMessage({
57
- columnName,
58
- expectToBe,
59
- from: `${config.name}.params$`
60
- }))
61
- }
62
- } catch (e) {
63
- // throw new Error(e.message)
64
- // 驗證失敗仍繼續執行,才不會把 Observable 資料流給中斷掉
65
- console.error(createOrbChartsErrorMessage(e))
66
- }
67
- return mergeOptionsWithDefault(d, mergedDefaultParams)
68
- }),
69
- // catchError((e) => {
70
- // console.error(createOrbChartsErrorMessage(e))
71
- // return EMPTY
72
- // })
73
- )
74
- }),
75
- shareReplay(1)
76
- )
77
-
78
- // 建立plugin實例
79
- return {
80
- params$,
81
- name: config.name,
82
- chartType,
83
- defaultParams: config.defaultParams,
84
- layerIndex: config.layerIndex,
85
- init () {
86
- if (!pluginContext) {
87
- return
88
- }
89
- // 執行
90
- pluginDestroyFn = (initFn(pluginContext) ?? (() => {})) // plugin執行會回傳destroy函式
91
- EntityWeakMap.set(pluginContext.selection, pluginContext)
92
- },
93
- destroy () {
94
- pluginDestroyFn()
95
- if (pluginContext) {
96
- pluginContext.selection.remove()
97
- pluginContext = undefined
98
- }
99
- destroy$.next(undefined)
100
- },
101
- setPresetParams: (presetParams: Partial<PluginParams>) => {
102
- mergedDefaultParams$.next(mergeOptionsWithDefault(presetParams, config.defaultParams))
103
-
104
- },
105
- setContext: (_pluginContext: PluginContext<T, PluginName, PluginParams>) => {
106
- pluginContext = _pluginContext
107
- pluginContext.observer.fullParams$ = fullParams$
108
- }
109
- }
110
- }
111
-
112
- // 建立plugin類別
113
- export const createBasePlugin: CreateBasePlugin = <T extends ChartType>(chartType: T) => {
114
-
115
- // 定義plugin
116
- return function definePlugin<PluginName, PluginParams>(config: DefinePluginConfig<PluginName, PluginParams>) {
117
-
118
- // 定義plugin的初始化function
119
- return function definePluginInitFn (initFn: PluginInitFn<T, PluginName, PluginParams>) {
120
-
121
- return class Plugin {
122
- params$: Subject<Partial<PluginParams>>
123
- name: PluginName
124
- chartType: T
125
- defaultParams: PluginParams
126
- layerIndex: number
127
- // presetParams: Partial<PluginParams>
128
- init: () => void
129
- destroy: () => void
130
- setPresetParams: (presetParams: Partial<PluginParams>) => void
131
- setContext: (pluginContext: PluginContext<T, PluginName, PluginParams>) => void
132
- constructor () {
133
- const pluginEntity = createPluginEntity<T, PluginName, PluginParams>({
134
- chartType,
135
- config,
136
- initFn
137
- })
138
-
139
- this.params$ = pluginEntity.params$
140
- this.name = pluginEntity.name
141
- this.chartType = pluginEntity.chartType
142
- this.defaultParams = pluginEntity.defaultParams
143
- this.layerIndex = pluginEntity.layerIndex
144
- // this.presetParams = pluginEntity.presetParams
145
- this.init = pluginEntity.init
146
- this.destroy = pluginEntity.destroy
147
- this.setPresetParams = pluginEntity.setPresetParams
148
- this.setContext = pluginEntity.setContext
149
- }
150
- }
151
- }
152
- }
153
- }
1
+ import {
2
+ catchError,
3
+ of,
4
+ takeUntil,
5
+ map,
6
+ switchMap,
7
+ shareReplay,
8
+ startWith,
9
+ EMPTY,
10
+ Subject,
11
+ BehaviorSubject,
12
+ Observable
13
+ } from 'rxjs'
14
+ import type {
15
+ ChartType,
16
+ CreateBasePlugin,
17
+ DefinePluginConfig,
18
+ PluginInitFn,
19
+ PluginContext,
20
+ PluginEntity } from '../../lib/core-types'
21
+ import { mergeOptionsWithDefault } from '../utils'
22
+ import { createValidatorErrorMessage, createValidatorWarningMessage, createOrbChartsErrorMessage } from '../utils/errorMessage'
23
+ import { validateColumns } from '../utils/validator'
24
+
25
+ // 建立plugin實例
26
+ function createPluginEntity <T extends ChartType, PluginName, PluginParams>({ chartType, config, initFn }: {
27
+ chartType: T
28
+ config: DefinePluginConfig<PluginName, PluginParams>
29
+ initFn: PluginInitFn<T, PluginName, PluginParams>
30
+ }): PluginEntity<T, PluginName, PluginParams> {
31
+
32
+ const destroy$ = new Subject()
33
+ const EntityWeakMap = new WeakMap() // <selection, pluginEntity> 避免只移除selection而沒回收pluginEntity的memory leak
34
+ let pluginDestroyFn = () => {}
35
+ let pluginContext: PluginContext<T, PluginName, PluginParams> | undefined
36
+ const mergedDefaultParams$ = new BehaviorSubject(config.defaultParams)
37
+ const params$: Subject<Partial<typeof config.defaultParams>> = new BehaviorSubject({})
38
+ const fullParams$ = mergedDefaultParams$.pipe(
39
+ switchMap(mergedDefaultParams => {
40
+ return params$
41
+ .pipe(
42
+ takeUntil(destroy$),
43
+ map(d => {
44
+ try {
45
+ // 檢查 data$ 資料格式是否正確
46
+ const { status, columnName, expectToBe } = config.validator(d, {
47
+ validateColumns
48
+ })
49
+ if (status === 'error') {
50
+ throw new Error(createValidatorErrorMessage({
51
+ columnName,
52
+ expectToBe,
53
+ from: `${config.name}.params$`
54
+ }))
55
+ } else if (status === 'warning') {
56
+ console.warn(createValidatorWarningMessage({
57
+ columnName,
58
+ expectToBe,
59
+ from: `${config.name}.params$`
60
+ }))
61
+ }
62
+ } catch (e) {
63
+ // throw new Error(e.message)
64
+ // 驗證失敗仍繼續執行,才不會把 Observable 資料流給中斷掉
65
+ console.error(createOrbChartsErrorMessage(e))
66
+ }
67
+ return mergeOptionsWithDefault(d, mergedDefaultParams)
68
+ }),
69
+ // catchError((e) => {
70
+ // console.error(createOrbChartsErrorMessage(e))
71
+ // return EMPTY
72
+ // })
73
+ )
74
+ }),
75
+ shareReplay(1)
76
+ )
77
+
78
+ // 建立plugin實例
79
+ return {
80
+ params$,
81
+ name: config.name,
82
+ chartType,
83
+ defaultParams: config.defaultParams,
84
+ layerIndex: config.layerIndex,
85
+ init () {
86
+ if (!pluginContext) {
87
+ return
88
+ }
89
+ // 執行
90
+ pluginDestroyFn = (initFn(pluginContext) ?? (() => {})) // plugin執行會回傳destroy函式
91
+ EntityWeakMap.set(pluginContext.selection, pluginContext)
92
+ },
93
+ destroy () {
94
+ pluginDestroyFn()
95
+ if (pluginContext) {
96
+ pluginContext.selection.remove()
97
+ pluginContext = undefined
98
+ }
99
+ destroy$.next(undefined)
100
+ },
101
+ setPresetParams: (presetParams: Partial<PluginParams>) => {
102
+ mergedDefaultParams$.next(mergeOptionsWithDefault(presetParams, config.defaultParams))
103
+
104
+ },
105
+ setContext: (_pluginContext: PluginContext<T, PluginName, PluginParams>) => {
106
+ pluginContext = _pluginContext
107
+ pluginContext.observer.fullParams$ = fullParams$
108
+ }
109
+ }
110
+ }
111
+
112
+ // 建立plugin類別
113
+ export const createBasePlugin: CreateBasePlugin = <T extends ChartType>(chartType: T) => {
114
+
115
+ // 定義plugin
116
+ return function definePlugin<PluginName, PluginParams>(config: DefinePluginConfig<PluginName, PluginParams>) {
117
+
118
+ // 定義plugin的初始化function
119
+ return function definePluginInitFn (initFn: PluginInitFn<T, PluginName, PluginParams>) {
120
+
121
+ return class Plugin {
122
+ params$: Subject<Partial<PluginParams>>
123
+ name: PluginName
124
+ chartType: T
125
+ defaultParams: PluginParams
126
+ layerIndex: number
127
+ // presetParams: Partial<PluginParams>
128
+ init: () => void
129
+ destroy: () => void
130
+ setPresetParams: (presetParams: Partial<PluginParams>) => void
131
+ setContext: (pluginContext: PluginContext<T, PluginName, PluginParams>) => void
132
+ constructor () {
133
+ const pluginEntity = createPluginEntity<T, PluginName, PluginParams>({
134
+ chartType,
135
+ config,
136
+ initFn
137
+ })
138
+
139
+ this.params$ = pluginEntity.params$
140
+ this.name = pluginEntity.name
141
+ this.chartType = pluginEntity.chartType
142
+ this.defaultParams = pluginEntity.defaultParams
143
+ this.layerIndex = pluginEntity.layerIndex
144
+ // this.presetParams = pluginEntity.presetParams
145
+ this.init = pluginEntity.init
146
+ this.destroy = pluginEntity.destroy
147
+ this.setPresetParams = pluginEntity.setPresetParams
148
+ this.setContext = pluginEntity.setContext
149
+ }
150
+ }
151
+ }
152
+ }
153
+ }
@@ -1,24 +1,24 @@
1
- import type { ChartOptionsPartial, ChartType, ValidatorResult } from '../../../lib/core-types'
2
- import { validateColumns } from '../../utils/validator'
3
-
4
- export function chartOptionsValidator<T extends ChartType> (chartOptionsPartial: ChartOptionsPartial<T>): ValidatorResult {
5
- if (!chartOptionsPartial) {
6
- // chartOptions 可為空值
7
- return { status: 'success', columnName: '', expectToBe: '' }
8
- }
9
- const result = validateColumns(chartOptionsPartial, {
10
- width: {
11
- toBe: '"auto" | number',
12
- test: (value: any) => value === 'auto' || typeof value === 'number'
13
- },
14
- height: {
15
- toBe: '"auto" | number',
16
- test: (value: any) => value === 'auto' || typeof value === 'number'
17
- },
18
- preset: {
19
- toBeTypes: ['object']
20
- }
21
- })
22
-
23
- return result
1
+ import type { ChartOptionsPartial, ChartType, ValidatorResult } from '../../../lib/core-types'
2
+ import { validateColumns } from '../../utils/validator'
3
+
4
+ export function chartOptionsValidator<T extends ChartType> (chartOptionsPartial: ChartOptionsPartial<T>): ValidatorResult {
5
+ if (!chartOptionsPartial) {
6
+ // chartOptions 可為空值
7
+ return { status: 'success', columnName: '', expectToBe: '' }
8
+ }
9
+ const result = validateColumns(chartOptionsPartial, {
10
+ width: {
11
+ toBe: '"auto" | number',
12
+ test: (value: any) => value === 'auto' || typeof value === 'number'
13
+ },
14
+ height: {
15
+ toBe: '"auto" | number',
16
+ test: (value: any) => value === 'auto' || typeof value === 'number'
17
+ },
18
+ preset: {
19
+ toBeTypes: ['object']
20
+ }
21
+ })
22
+
23
+ return result
24
24
  }
@@ -1,134 +1,134 @@
1
- import type { ChartParamsPartial, ChartType, ValidatorResult } from '../../../lib/core-types'
2
- import { validateColumns } from '../../utils/validator'
3
-
4
- export function chartParamsValidator (chartType: ChartType, chartParamsPartial: ChartParamsPartial | undefined): ValidatorResult {
5
- const highlightTargetToBe: {[key in ChartType]: string[]} = {
6
- series: ['series', 'datum', 'none'],
7
- grid: ['series', 'group', 'datum', 'none'],
8
- multiGrid: ['series', 'group', 'datum', 'none'],
9
- multiValue: ['category', 'datum', 'none'],
10
- relationship: ['category', 'datum', 'none'],
11
- tree: ['category', 'datum', 'none'],
12
- noneData: ['none']
13
- }
14
-
15
- const result = validateColumns(chartParamsPartial, {
16
- padding: {
17
- toBeTypes: ['object'],
18
- },
19
- highlightTarget: {
20
- toBe: highlightTargetToBe[chartType].map(d => `"${d}"`).join(' | '),
21
- test: (value: any) => {
22
- return highlightTargetToBe[chartType].includes(value)
23
- }
24
- },
25
- highlightDefault: {
26
- toBeTypes: ['string', 'null']
27
- },
28
- colorScheme: {
29
- toBe: '"dark" | "light"',
30
- test: (value: any) => value === 'dark' || value === 'light'
31
- },
32
- colors: {
33
- toBeTypes: ['object'],
34
- test: (value: any) => {
35
- return value.light && value.dark
36
- }
37
- },
38
- styles: {
39
- toBeTypes: ['object'],
40
- },
41
- transitionDuration: {
42
- toBeTypes: ['number'],
43
- },
44
- transitionEase: {
45
- toBeTypes: ['string'],
46
- }
47
- })
48
-
49
- if (chartParamsPartial && chartParamsPartial.padding) {
50
- const paddingResult = validateColumns(chartParamsPartial.padding, {
51
- top: {
52
- toBeTypes: ['number'],
53
- },
54
- right: {
55
- toBeTypes: ['number'],
56
- },
57
- bottom: {
58
- toBeTypes: ['number'],
59
- },
60
- left: {
61
- toBeTypes: ['number'],
62
- },
63
- })
64
-
65
- if (paddingResult.status === 'error') {
66
- return paddingResult
67
- }
68
- }
69
-
70
- if (chartParamsPartial && chartParamsPartial.colors) {
71
- const colorsResult = validateColumns(chartParamsPartial.colors, {
72
- light: {
73
- toBeTypes: ['object'],
74
- },
75
- dark: {
76
- toBeTypes: ['object'],
77
- },
78
- })
79
-
80
- if (colorsResult.status === 'error') {
81
- return colorsResult
82
- }
83
-
84
- if (chartParamsPartial.colors.light) {
85
- const lightResult = validateColumns(chartParamsPartial.colors.light, {
86
- label: {
87
- toBeTypes: ['string[]'],
88
- },
89
- primary: {
90
- toBeTypes: ['string'],
91
- },
92
- secondary: {
93
- toBeTypes: ['string'],
94
- },
95
- white: {
96
- toBeTypes: ['string'],
97
- },
98
- background: {
99
- toBeTypes: ['string'],
100
- },
101
- })
102
-
103
- if (lightResult.status === 'error') {
104
- return lightResult
105
- }
106
- }
107
-
108
- if (chartParamsPartial.colors.dark) {
109
- const darkResult = validateColumns(chartParamsPartial.colors.dark, {
110
- label: {
111
- toBeTypes: ['string[]'],
112
- },
113
- primary: {
114
- toBeTypes: ['string'],
115
- },
116
- secondary: {
117
- toBeTypes: ['string'],
118
- },
119
- white: {
120
- toBeTypes: ['string'],
121
- },
122
- background: {
123
- toBeTypes: ['string'],
124
- },
125
- })
126
-
127
- if (darkResult.status === 'error') {
128
- return darkResult
129
- }
130
- }
131
- }
132
-
133
- return result
1
+ import type { ChartParamsPartial, ChartType, ValidatorResult } from '../../../lib/core-types'
2
+ import { validateColumns } from '../../utils/validator'
3
+
4
+ export function chartParamsValidator (chartType: ChartType, chartParamsPartial: ChartParamsPartial | undefined): ValidatorResult {
5
+ const highlightTargetToBe: {[key in ChartType]: string[]} = {
6
+ series: ['series', 'datum', 'none'],
7
+ grid: ['series', 'group', 'datum', 'none'],
8
+ multiGrid: ['series', 'group', 'datum', 'none'],
9
+ multiValue: ['category', 'datum', 'none'],
10
+ relationship: ['category', 'datum', 'none'],
11
+ tree: ['category', 'datum', 'none'],
12
+ noneData: ['none']
13
+ }
14
+
15
+ const result = validateColumns(chartParamsPartial, {
16
+ padding: {
17
+ toBeTypes: ['object'],
18
+ },
19
+ highlightTarget: {
20
+ toBe: highlightTargetToBe[chartType].map(d => `"${d}"`).join(' | '),
21
+ test: (value: any) => {
22
+ return highlightTargetToBe[chartType].includes(value)
23
+ }
24
+ },
25
+ highlightDefault: {
26
+ toBeTypes: ['string', 'null']
27
+ },
28
+ colorScheme: {
29
+ toBe: '"dark" | "light"',
30
+ test: (value: any) => value === 'dark' || value === 'light'
31
+ },
32
+ colors: {
33
+ toBeTypes: ['object'],
34
+ test: (value: any) => {
35
+ return value.light && value.dark
36
+ }
37
+ },
38
+ styles: {
39
+ toBeTypes: ['object'],
40
+ },
41
+ transitionDuration: {
42
+ toBeTypes: ['number'],
43
+ },
44
+ transitionEase: {
45
+ toBeTypes: ['string'],
46
+ }
47
+ })
48
+
49
+ if (chartParamsPartial && chartParamsPartial.padding) {
50
+ const paddingResult = validateColumns(chartParamsPartial.padding, {
51
+ top: {
52
+ toBeTypes: ['number'],
53
+ },
54
+ right: {
55
+ toBeTypes: ['number'],
56
+ },
57
+ bottom: {
58
+ toBeTypes: ['number'],
59
+ },
60
+ left: {
61
+ toBeTypes: ['number'],
62
+ },
63
+ })
64
+
65
+ if (paddingResult.status === 'error') {
66
+ return paddingResult
67
+ }
68
+ }
69
+
70
+ if (chartParamsPartial && chartParamsPartial.colors) {
71
+ const colorsResult = validateColumns(chartParamsPartial.colors, {
72
+ light: {
73
+ toBeTypes: ['object'],
74
+ },
75
+ dark: {
76
+ toBeTypes: ['object'],
77
+ },
78
+ })
79
+
80
+ if (colorsResult.status === 'error') {
81
+ return colorsResult
82
+ }
83
+
84
+ if (chartParamsPartial.colors.light) {
85
+ const lightResult = validateColumns(chartParamsPartial.colors.light, {
86
+ label: {
87
+ toBeTypes: ['string[]'],
88
+ },
89
+ primary: {
90
+ toBeTypes: ['string'],
91
+ },
92
+ secondary: {
93
+ toBeTypes: ['string'],
94
+ },
95
+ white: {
96
+ toBeTypes: ['string'],
97
+ },
98
+ background: {
99
+ toBeTypes: ['string'],
100
+ },
101
+ })
102
+
103
+ if (lightResult.status === 'error') {
104
+ return lightResult
105
+ }
106
+ }
107
+
108
+ if (chartParamsPartial.colors.dark) {
109
+ const darkResult = validateColumns(chartParamsPartial.colors.dark, {
110
+ label: {
111
+ toBeTypes: ['string[]'],
112
+ },
113
+ primary: {
114
+ toBeTypes: ['string'],
115
+ },
116
+ secondary: {
117
+ toBeTypes: ['string'],
118
+ },
119
+ white: {
120
+ toBeTypes: ['string'],
121
+ },
122
+ background: {
123
+ toBeTypes: ['string'],
124
+ },
125
+ })
126
+
127
+ if (darkResult.status === 'error') {
128
+ return darkResult
129
+ }
130
+ }
131
+ }
132
+
133
+ return result
134
134
  }
@@ -1,14 +1,14 @@
1
- import type { ValidatorResult } from '../../../lib/core-types'
2
- import { validateColumns } from '../../utils/validator'
3
- import { isDom } from '../../utils/commonUtils'
4
-
5
- export function elementValidator (element: HTMLElement | Element): ValidatorResult {
6
- const result = validateColumns({ element }, {
7
- element: {
8
- toBe: 'Dom',
9
- test: (value: any) => isDom(value)
10
- },
11
- })
12
-
13
- return result
1
+ import type { ValidatorResult } from '../../../lib/core-types'
2
+ import { validateColumns } from '../../utils/validator'
3
+ import { isDom } from '../../utils/commonUtils'
4
+
5
+ export function elementValidator (element: HTMLElement | Element): ValidatorResult {
6
+ const result = validateColumns({ element }, {
7
+ element: {
8
+ toBe: 'Dom',
9
+ test: (value: any) => isDom(value)
10
+ },
11
+ })
12
+
13
+ return result
14
14
  }