@orbcharts/core 3.0.0-alpha.51 → 3.0.0-alpha.53
Sign up to get free protection for your applications and to get access to all the features.
- package/LICENSE +200 -200
- package/dist/orbcharts-core.es.js +547 -544
- package/dist/orbcharts-core.umd.js +2 -2
- package/dist/src/types/ContextObserverMultiGrid.d.ts +2 -1
- package/dist/vite.config.d.ts +1 -1
- package/package.json +41 -41
- package/src/AbstractChart.ts +48 -48
- package/src/GridChart.ts +20 -20
- package/src/MultiGridChart.ts +20 -20
- package/src/MultiValueChart.ts +20 -20
- package/src/RelationshipChart.ts +20 -20
- package/src/SeriesChart.ts +20 -20
- package/src/TreeChart.ts +20 -20
- package/src/base/createBaseChart.ts +369 -369
- package/src/base/createBasePlugin.ts +95 -95
- package/src/defaults.ts +226 -226
- package/src/defineGridPlugin.ts +3 -3
- package/src/defineMultiGridPlugin.ts +3 -3
- package/src/defineMultiValuePlugin.ts +3 -3
- package/src/defineNoneDataPlugin.ts +4 -4
- package/src/defineRelationshipPlugin.ts +3 -3
- package/src/defineSeriesPlugin.ts +3 -3
- package/src/defineTreePlugin.ts +3 -3
- package/src/grid/computeGridData.ts +134 -134
- package/src/grid/createGridContextObserver.ts +155 -155
- package/src/grid/gridObservables.ts +607 -604
- package/src/index.ts +21 -21
- package/src/multiGrid/computeMultiGridData.ts +130 -130
- package/src/multiGrid/createMultiGridContextObserver.ts +41 -40
- package/src/multiGrid/multiGridObservables.ts +365 -364
- package/src/multiValue/computeMultiValueData.ts +143 -143
- package/src/multiValue/createMultiValueContextObserver.ts +12 -12
- package/src/relationship/computeRelationshipData.ts +118 -118
- package/src/relationship/createRelationshipContextObserver.ts +12 -12
- package/src/series/computeSeriesData.ts +90 -90
- package/src/series/createSeriesContextObserver.ts +93 -93
- package/src/series/seriesObservables.ts +175 -175
- package/src/tree/computeTreeData.ts +132 -132
- package/src/tree/createTreeContextObserver.ts +61 -61
- package/src/tree/treeObservables.ts +94 -94
- package/src/types/Chart.ts +50 -50
- package/src/types/ChartParams.ts +51 -51
- package/src/types/ComputedData.ts +83 -83
- package/src/types/ComputedDataGrid.ts +13 -13
- package/src/types/ComputedDataMultiGrid.ts +2 -2
- package/src/types/ComputedDataMultiValue.ts +9 -9
- package/src/types/ComputedDataRelationship.ts +19 -19
- package/src/types/ComputedDataSeries.ts +7 -7
- package/src/types/ComputedDataTree.ts +19 -19
- package/src/types/ContextObserver.ts +38 -38
- package/src/types/ContextObserverGrid.ts +42 -42
- package/src/types/ContextObserverMultiGrid.ts +16 -15
- package/src/types/ContextObserverMultiValue.ts +4 -4
- package/src/types/ContextObserverRelationship.ts +4 -4
- package/src/types/ContextObserverSeries.ts +29 -29
- package/src/types/ContextObserverTree.ts +11 -11
- package/src/types/ContextSubject.ts +18 -18
- package/src/types/Data.ts +45 -45
- package/src/types/DataFormatter.ts +74 -74
- package/src/types/DataFormatterGrid.ts +67 -67
- package/src/types/DataFormatterMultiGrid.ts +44 -44
- package/src/types/DataFormatterMultiValue.ts +23 -23
- package/src/types/DataFormatterRelationship.ts +25 -25
- package/src/types/DataFormatterSeries.ts +20 -20
- package/src/types/DataFormatterTree.ts +12 -12
- package/src/types/DataGrid.ts +11 -11
- package/src/types/DataMultiGrid.ts +6 -6
- package/src/types/DataMultiValue.ts +12 -12
- package/src/types/DataRelationship.ts +27 -27
- package/src/types/DataSeries.ts +11 -11
- package/src/types/DataTree.ts +20 -20
- package/src/types/Event.ts +153 -153
- package/src/types/Layout.ts +11 -11
- package/src/types/Padding.ts +5 -5
- package/src/types/Plugin.ts +60 -60
- package/src/types/TransformData.ts +7 -7
- package/src/types/index.ts +37 -37
- package/src/utils/commonUtils.ts +50 -50
- package/src/utils/d3Utils.ts +89 -89
- package/src/utils/index.ts +4 -4
- package/src/utils/observables.ts +201 -201
- package/src/utils/orbchartsUtils.ts +349 -349
- package/tsconfig.json +13 -13
- package/vite.config.js +22 -44
package/src/utils/observables.ts
CHANGED
@@ -1,202 +1,202 @@
|
|
1
|
-
import {
|
2
|
-
combineLatest,
|
3
|
-
distinctUntilChanged,
|
4
|
-
filter,
|
5
|
-
map,
|
6
|
-
merge,
|
7
|
-
takeUntil,
|
8
|
-
shareReplay,
|
9
|
-
switchMap,
|
10
|
-
Subject,
|
11
|
-
Observable } from 'rxjs'
|
12
|
-
import type {
|
13
|
-
ChartType,
|
14
|
-
ChartParams,
|
15
|
-
ComputedDataTypeMap,
|
16
|
-
ComputedDatumTypeMap,
|
17
|
-
DataFormatterTypeMap,
|
18
|
-
EventTypeMap,
|
19
|
-
HighlightTarget,
|
20
|
-
Layout,
|
21
|
-
TransformData } from '../types'
|
22
|
-
|
23
|
-
// interface DatumUnknown {
|
24
|
-
// value: number | null
|
25
|
-
// id: string
|
26
|
-
// // label: string
|
27
|
-
// seriesLabel?: string // 要符合每一種computedData所以不一定會有seriesLabel
|
28
|
-
// groupLabel?: string // 要符合每一種computedData所以不一定會有groupLabel
|
29
|
-
// }
|
30
|
-
|
31
|
-
// 通用 highlight Observable
|
32
|
-
export const highlightObservable = <T extends ChartType, D>({ datumList$, fullChartParams$, event$ }: {
|
33
|
-
datumList$: Observable<D[]>
|
34
|
-
fullChartParams$: Observable<ChartParams>
|
35
|
-
event$: Subject<EventTypeMap<T>>
|
36
|
-
}): Observable<D[]> => {
|
37
|
-
const destroy$ = new Subject()
|
38
|
-
|
39
|
-
// 預設的highlight
|
40
|
-
const highlightDefault$ = fullChartParams$.pipe(
|
41
|
-
takeUntil(destroy$),
|
42
|
-
map(d => {
|
43
|
-
return {
|
44
|
-
id: null,
|
45
|
-
seriesLabel: null,
|
46
|
-
groupLabel: null,
|
47
|
-
categoryLabel: null,
|
48
|
-
highlightDefault: d.highlightDefault
|
49
|
-
}
|
50
|
-
}),
|
51
|
-
distinctUntilChanged()
|
52
|
-
)
|
53
|
-
|
54
|
-
// 事件觸發的highlight
|
55
|
-
const highlightMouseover$ = event$.pipe(
|
56
|
-
takeUntil(destroy$),
|
57
|
-
filter(d => d.eventName === 'mouseover' || d.eventName === 'mousemove'),
|
58
|
-
// distinctUntilChanged((prev, current) => prev.eventName === current.eventName)
|
59
|
-
map(d => {
|
60
|
-
return d.datum
|
61
|
-
? {
|
62
|
-
id: (d.datum as any).id,
|
63
|
-
seriesLabel: (d.datum as any).seriesLabel,
|
64
|
-
groupLabel: (d.datum as any).groupLabel,
|
65
|
-
categoryLabel: (d.datum as any).categoryLabel,
|
66
|
-
highlightDefault: null
|
67
|
-
}
|
68
|
-
: {
|
69
|
-
id: null,
|
70
|
-
seriesLabel: null,
|
71
|
-
groupLabel: null,
|
72
|
-
categoryLabel: null,
|
73
|
-
highlightDefault: null
|
74
|
-
}
|
75
|
-
})
|
76
|
-
)
|
77
|
-
const highlightMouseout$ = event$.pipe(
|
78
|
-
takeUntil(destroy$),
|
79
|
-
filter(d => d.eventName === 'mouseout'),
|
80
|
-
// distinctUntilChanged((prev, current) => prev.eventName === current.eventName)
|
81
|
-
// map(d => {
|
82
|
-
// return { id: '', label: '' }
|
83
|
-
// })
|
84
|
-
switchMap(d => highlightDefault$)
|
85
|
-
)
|
86
|
-
|
87
|
-
function getDatumIds (datumList: ComputedDatumTypeMap<T>[], id: string | null) {
|
88
|
-
const datum = datumList.find(d => d.id === id)
|
89
|
-
return datum ? [datum] : []
|
90
|
-
}
|
91
|
-
|
92
|
-
function getSeriesIds (datumList: ComputedDatumTypeMap<T>[], seriesLabel: string | null) {
|
93
|
-
return seriesLabel == null
|
94
|
-
? []
|
95
|
-
: datumList.filter(d => (d as ComputedDatumTypeMap<"series">).seriesLabel === seriesLabel)
|
96
|
-
}
|
97
|
-
|
98
|
-
function getGroupIds (datumList: ComputedDatumTypeMap<T>[], groupLabel: string | null) {
|
99
|
-
return groupLabel == null
|
100
|
-
? []
|
101
|
-
: datumList.filter(d => (d as ComputedDatumTypeMap<"grid">).groupLabel === groupLabel)
|
102
|
-
}
|
103
|
-
|
104
|
-
function getCategoryIds (datumList: ComputedDatumTypeMap<T>[], categoryLabel: string | null) {
|
105
|
-
return categoryLabel == null
|
106
|
-
? []
|
107
|
-
: datumList.filter(d => (d as ComputedDatumTypeMap<"multiValue" | "relationship" | "tree">).categoryLabel === categoryLabel)
|
108
|
-
}
|
109
|
-
|
110
|
-
return new Observable<D[]>(subscriber => {
|
111
|
-
combineLatest({
|
112
|
-
target: merge(highlightMouseover$, highlightMouseout$, highlightDefault$),
|
113
|
-
datumList: datumList$,
|
114
|
-
fullChartParams: fullChartParams$,
|
115
|
-
}).pipe(
|
116
|
-
takeUntil(destroy$),
|
117
|
-
switchMap(async d => d)
|
118
|
-
).subscribe(data => {
|
119
|
-
let datumList: ComputedDatumTypeMap<T>[] = []
|
120
|
-
if (data.fullChartParams.highlightTarget === 'datum') {
|
121
|
-
datumList = getDatumIds(data.datumList as ComputedDatumTypeMap<T>[], data.target.id)
|
122
|
-
} else if (data.fullChartParams.highlightTarget === 'series') {
|
123
|
-
datumList = getSeriesIds(data.datumList as ComputedDatumTypeMap<T>[], data.target.seriesLabel)
|
124
|
-
} else if (data.fullChartParams.highlightTarget === 'group') {
|
125
|
-
datumList = getGroupIds(data.datumList as ComputedDatumTypeMap<T>[], data.target.groupLabel)
|
126
|
-
} else if (data.fullChartParams.highlightTarget === 'category') {
|
127
|
-
datumList = getCategoryIds(data.datumList as ComputedDatumTypeMap<T>[], data.target.categoryLabel)
|
128
|
-
}
|
129
|
-
subscriber.next(datumList as D[])
|
130
|
-
})
|
131
|
-
|
132
|
-
return function unsubscribe () {
|
133
|
-
destroy$.next(undefined)
|
134
|
-
}
|
135
|
-
})
|
136
|
-
}
|
137
|
-
|
138
|
-
export const seriesDataMapObservable = <DatumType extends ComputedDatumTypeMap<'series' | 'grid'>>({ datumList$ }: { datumList$: Observable<DatumType[]> }) => {
|
139
|
-
return datumList$.pipe(
|
140
|
-
map(data => {
|
141
|
-
const SeriesDataMap: Map<string, DatumType[]> = new Map()
|
142
|
-
data.forEach(d => {
|
143
|
-
const seriesData = SeriesDataMap.get(d.seriesLabel) ?? []
|
144
|
-
seriesData.push(d)
|
145
|
-
SeriesDataMap.set(d.seriesLabel, seriesData)
|
146
|
-
})
|
147
|
-
return SeriesDataMap
|
148
|
-
})
|
149
|
-
)
|
150
|
-
}
|
151
|
-
|
152
|
-
export const groupDataMapObservable = <DatumType extends ComputedDatumTypeMap<'grid'>> ({ datumList$ }: { datumList$: Observable<DatumType[]> }) => {
|
153
|
-
return datumList$.pipe(
|
154
|
-
map(data => {
|
155
|
-
const GroupDataMap: Map<string, DatumType[]> = new Map()
|
156
|
-
data.forEach(d => {
|
157
|
-
const groupData = GroupDataMap.get(d.groupLabel) ?? []
|
158
|
-
groupData.push(d)
|
159
|
-
GroupDataMap.set(d.groupLabel, groupData)
|
160
|
-
})
|
161
|
-
return GroupDataMap
|
162
|
-
})
|
163
|
-
)
|
164
|
-
}
|
165
|
-
|
166
|
-
export const categoryDataMapObservable = <DatumType extends ComputedDatumTypeMap<'multiValue' | 'relationship' | 'tree'>> ({ datumList$ }: { datumList$: Observable<DatumType[]> }) => {
|
167
|
-
return datumList$.pipe(
|
168
|
-
map(data => {
|
169
|
-
const GroupDataMap: Map<string, DatumType[]> = new Map()
|
170
|
-
data
|
171
|
-
.filter(d => d.categoryLabel != null)
|
172
|
-
.forEach(d => {
|
173
|
-
const groupData = GroupDataMap.get(d.categoryLabel) ?? []
|
174
|
-
groupData.push(d)
|
175
|
-
GroupDataMap.set(d.categoryLabel, groupData)
|
176
|
-
})
|
177
|
-
return GroupDataMap
|
178
|
-
})
|
179
|
-
)
|
180
|
-
}
|
181
|
-
|
182
|
-
export const textSizePxObservable = (chartParams$: Observable<ChartParams>) => {
|
183
|
-
return chartParams$.pipe(
|
184
|
-
map(d => d.styles.textSize),
|
185
|
-
distinctUntilChanged(),
|
186
|
-
map(data => {
|
187
|
-
let value = NaN
|
188
|
-
if (typeof data === 'string') {
|
189
|
-
if (data.includes('rem')) {
|
190
|
-
const rootFontSizePx = parseFloat(getComputedStyle(document.documentElement).fontSize)
|
191
|
-
const num = parseFloat(data)
|
192
|
-
value = num * rootFontSizePx
|
193
|
-
} else if (data.includes('px')) {
|
194
|
-
value = parseFloat(data)
|
195
|
-
}
|
196
|
-
} else if (typeof data === 'number') {
|
197
|
-
return data
|
198
|
-
}
|
199
|
-
return value ? value : 14 // default
|
200
|
-
})
|
201
|
-
)
|
1
|
+
import {
|
2
|
+
combineLatest,
|
3
|
+
distinctUntilChanged,
|
4
|
+
filter,
|
5
|
+
map,
|
6
|
+
merge,
|
7
|
+
takeUntil,
|
8
|
+
shareReplay,
|
9
|
+
switchMap,
|
10
|
+
Subject,
|
11
|
+
Observable } from 'rxjs'
|
12
|
+
import type {
|
13
|
+
ChartType,
|
14
|
+
ChartParams,
|
15
|
+
ComputedDataTypeMap,
|
16
|
+
ComputedDatumTypeMap,
|
17
|
+
DataFormatterTypeMap,
|
18
|
+
EventTypeMap,
|
19
|
+
HighlightTarget,
|
20
|
+
Layout,
|
21
|
+
TransformData } from '../types'
|
22
|
+
|
23
|
+
// interface DatumUnknown {
|
24
|
+
// value: number | null
|
25
|
+
// id: string
|
26
|
+
// // label: string
|
27
|
+
// seriesLabel?: string // 要符合每一種computedData所以不一定會有seriesLabel
|
28
|
+
// groupLabel?: string // 要符合每一種computedData所以不一定會有groupLabel
|
29
|
+
// }
|
30
|
+
|
31
|
+
// 通用 highlight Observable
|
32
|
+
export const highlightObservable = <T extends ChartType, D>({ datumList$, fullChartParams$, event$ }: {
|
33
|
+
datumList$: Observable<D[]>
|
34
|
+
fullChartParams$: Observable<ChartParams>
|
35
|
+
event$: Subject<EventTypeMap<T>>
|
36
|
+
}): Observable<D[]> => {
|
37
|
+
const destroy$ = new Subject()
|
38
|
+
|
39
|
+
// 預設的highlight
|
40
|
+
const highlightDefault$ = fullChartParams$.pipe(
|
41
|
+
takeUntil(destroy$),
|
42
|
+
map(d => {
|
43
|
+
return {
|
44
|
+
id: null,
|
45
|
+
seriesLabel: null,
|
46
|
+
groupLabel: null,
|
47
|
+
categoryLabel: null,
|
48
|
+
highlightDefault: d.highlightDefault
|
49
|
+
}
|
50
|
+
}),
|
51
|
+
distinctUntilChanged()
|
52
|
+
)
|
53
|
+
|
54
|
+
// 事件觸發的highlight
|
55
|
+
const highlightMouseover$ = event$.pipe(
|
56
|
+
takeUntil(destroy$),
|
57
|
+
filter(d => d.eventName === 'mouseover' || d.eventName === 'mousemove'),
|
58
|
+
// distinctUntilChanged((prev, current) => prev.eventName === current.eventName)
|
59
|
+
map(d => {
|
60
|
+
return d.datum
|
61
|
+
? {
|
62
|
+
id: (d.datum as any).id,
|
63
|
+
seriesLabel: (d.datum as any).seriesLabel,
|
64
|
+
groupLabel: (d.datum as any).groupLabel,
|
65
|
+
categoryLabel: (d.datum as any).categoryLabel,
|
66
|
+
highlightDefault: null
|
67
|
+
}
|
68
|
+
: {
|
69
|
+
id: null,
|
70
|
+
seriesLabel: null,
|
71
|
+
groupLabel: null,
|
72
|
+
categoryLabel: null,
|
73
|
+
highlightDefault: null
|
74
|
+
}
|
75
|
+
})
|
76
|
+
)
|
77
|
+
const highlightMouseout$ = event$.pipe(
|
78
|
+
takeUntil(destroy$),
|
79
|
+
filter(d => d.eventName === 'mouseout'),
|
80
|
+
// distinctUntilChanged((prev, current) => prev.eventName === current.eventName)
|
81
|
+
// map(d => {
|
82
|
+
// return { id: '', label: '' }
|
83
|
+
// })
|
84
|
+
switchMap(d => highlightDefault$)
|
85
|
+
)
|
86
|
+
|
87
|
+
function getDatumIds (datumList: ComputedDatumTypeMap<T>[], id: string | null) {
|
88
|
+
const datum = datumList.find(d => d.id === id)
|
89
|
+
return datum ? [datum] : []
|
90
|
+
}
|
91
|
+
|
92
|
+
function getSeriesIds (datumList: ComputedDatumTypeMap<T>[], seriesLabel: string | null) {
|
93
|
+
return seriesLabel == null
|
94
|
+
? []
|
95
|
+
: datumList.filter(d => (d as ComputedDatumTypeMap<"series">).seriesLabel === seriesLabel)
|
96
|
+
}
|
97
|
+
|
98
|
+
function getGroupIds (datumList: ComputedDatumTypeMap<T>[], groupLabel: string | null) {
|
99
|
+
return groupLabel == null
|
100
|
+
? []
|
101
|
+
: datumList.filter(d => (d as ComputedDatumTypeMap<"grid">).groupLabel === groupLabel)
|
102
|
+
}
|
103
|
+
|
104
|
+
function getCategoryIds (datumList: ComputedDatumTypeMap<T>[], categoryLabel: string | null) {
|
105
|
+
return categoryLabel == null
|
106
|
+
? []
|
107
|
+
: datumList.filter(d => (d as ComputedDatumTypeMap<"multiValue" | "relationship" | "tree">).categoryLabel === categoryLabel)
|
108
|
+
}
|
109
|
+
|
110
|
+
return new Observable<D[]>(subscriber => {
|
111
|
+
combineLatest({
|
112
|
+
target: merge(highlightMouseover$, highlightMouseout$, highlightDefault$),
|
113
|
+
datumList: datumList$,
|
114
|
+
fullChartParams: fullChartParams$,
|
115
|
+
}).pipe(
|
116
|
+
takeUntil(destroy$),
|
117
|
+
switchMap(async d => d)
|
118
|
+
).subscribe(data => {
|
119
|
+
let datumList: ComputedDatumTypeMap<T>[] = []
|
120
|
+
if (data.fullChartParams.highlightTarget === 'datum') {
|
121
|
+
datumList = getDatumIds(data.datumList as ComputedDatumTypeMap<T>[], data.target.id)
|
122
|
+
} else if (data.fullChartParams.highlightTarget === 'series') {
|
123
|
+
datumList = getSeriesIds(data.datumList as ComputedDatumTypeMap<T>[], data.target.seriesLabel)
|
124
|
+
} else if (data.fullChartParams.highlightTarget === 'group') {
|
125
|
+
datumList = getGroupIds(data.datumList as ComputedDatumTypeMap<T>[], data.target.groupLabel)
|
126
|
+
} else if (data.fullChartParams.highlightTarget === 'category') {
|
127
|
+
datumList = getCategoryIds(data.datumList as ComputedDatumTypeMap<T>[], data.target.categoryLabel)
|
128
|
+
}
|
129
|
+
subscriber.next(datumList as D[])
|
130
|
+
})
|
131
|
+
|
132
|
+
return function unsubscribe () {
|
133
|
+
destroy$.next(undefined)
|
134
|
+
}
|
135
|
+
})
|
136
|
+
}
|
137
|
+
|
138
|
+
export const seriesDataMapObservable = <DatumType extends ComputedDatumTypeMap<'series' | 'grid'>>({ datumList$ }: { datumList$: Observable<DatumType[]> }) => {
|
139
|
+
return datumList$.pipe(
|
140
|
+
map(data => {
|
141
|
+
const SeriesDataMap: Map<string, DatumType[]> = new Map()
|
142
|
+
data.forEach(d => {
|
143
|
+
const seriesData = SeriesDataMap.get(d.seriesLabel) ?? []
|
144
|
+
seriesData.push(d)
|
145
|
+
SeriesDataMap.set(d.seriesLabel, seriesData)
|
146
|
+
})
|
147
|
+
return SeriesDataMap
|
148
|
+
})
|
149
|
+
)
|
150
|
+
}
|
151
|
+
|
152
|
+
export const groupDataMapObservable = <DatumType extends ComputedDatumTypeMap<'grid'>> ({ datumList$ }: { datumList$: Observable<DatumType[]> }) => {
|
153
|
+
return datumList$.pipe(
|
154
|
+
map(data => {
|
155
|
+
const GroupDataMap: Map<string, DatumType[]> = new Map()
|
156
|
+
data.forEach(d => {
|
157
|
+
const groupData = GroupDataMap.get(d.groupLabel) ?? []
|
158
|
+
groupData.push(d)
|
159
|
+
GroupDataMap.set(d.groupLabel, groupData)
|
160
|
+
})
|
161
|
+
return GroupDataMap
|
162
|
+
})
|
163
|
+
)
|
164
|
+
}
|
165
|
+
|
166
|
+
export const categoryDataMapObservable = <DatumType extends ComputedDatumTypeMap<'multiValue' | 'relationship' | 'tree'>> ({ datumList$ }: { datumList$: Observable<DatumType[]> }) => {
|
167
|
+
return datumList$.pipe(
|
168
|
+
map(data => {
|
169
|
+
const GroupDataMap: Map<string, DatumType[]> = new Map()
|
170
|
+
data
|
171
|
+
.filter(d => d.categoryLabel != null)
|
172
|
+
.forEach(d => {
|
173
|
+
const groupData = GroupDataMap.get(d.categoryLabel) ?? []
|
174
|
+
groupData.push(d)
|
175
|
+
GroupDataMap.set(d.categoryLabel, groupData)
|
176
|
+
})
|
177
|
+
return GroupDataMap
|
178
|
+
})
|
179
|
+
)
|
180
|
+
}
|
181
|
+
|
182
|
+
export const textSizePxObservable = (chartParams$: Observable<ChartParams>) => {
|
183
|
+
return chartParams$.pipe(
|
184
|
+
map(d => d.styles.textSize),
|
185
|
+
distinctUntilChanged(),
|
186
|
+
map(data => {
|
187
|
+
let value = NaN
|
188
|
+
if (typeof data === 'string') {
|
189
|
+
if (data.includes('rem')) {
|
190
|
+
const rootFontSizePx = parseFloat(getComputedStyle(document.documentElement).fontSize)
|
191
|
+
const num = parseFloat(data)
|
192
|
+
value = num * rootFontSizePx
|
193
|
+
} else if (data.includes('px')) {
|
194
|
+
value = parseFloat(data)
|
195
|
+
}
|
196
|
+
} else if (typeof data === 'number') {
|
197
|
+
return data
|
198
|
+
}
|
199
|
+
return value ? value : 14 // default
|
200
|
+
})
|
201
|
+
)
|
202
202
|
}
|