@asyra/ui-context 0.2.5 → 0.5.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.
- package/LICENSE +21 -0
- package/README.md +13 -1
- package/dist/index.d.ts +5 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -3
- package/dist/index.js.map +1 -1
- package/dist/property-registry.d.ts +78 -0
- package/dist/property-registry.d.ts.map +1 -0
- package/dist/property-registry.js +119 -0
- package/dist/property-registry.js.map +1 -0
- package/dist/ui-context.d.ts +9 -21
- package/dist/ui-context.d.ts.map +1 -1
- package/dist/ui-context.js +58 -81
- package/dist/ui-context.js.map +1 -1
- package/package.json +24 -9
- package/.turbo/turbo-test$colon$ci.log +0 -117
- package/.turbo/turbo-test$colon$local.log +0 -23
- package/.turbo/turbo-test.log +0 -0
- package/CHANGELOG.md +0 -61
- package/coverage/base.css +0 -224
- package/coverage/block-navigation.js +0 -87
- package/coverage/clover.xml +0 -538
- package/coverage/coverage-final.json +0 -7443
- package/coverage/favicon.png +0 -0
- package/coverage/index.html +0 -176
- package/coverage/prettify.css +0 -1
- package/coverage/prettify.js +0 -2
- package/coverage/sort-arrow-sprite.png +0 -0
- package/coverage/sorter.js +0 -196
- package/coverage/src/index.html +0 -146
- package/coverage/src/index.ts.html +0 -97
- package/coverage/src/stores/index.html +0 -146
- package/coverage/src/stores/render.ts.html +0 -106
- package/coverage/src/stores/scene-tree.ts.html +0 -790
- package/coverage/src/stores/selection.ts.html +0 -220
- package/coverage/src/stores/system-context/index.html +0 -146
- package/coverage/src/stores/system-context/index.ts.html +0 -88
- package/coverage/src/stores/system-context/primary-tool.ts.html +0 -109
- package/coverage/src/stores/system-context/system-context.ts.html +0 -85
- package/coverage/src/subscribes/index.html +0 -161
- package/coverage/src/subscribes/index.ts.html +0 -124
- package/coverage/src/subscribes/render.ts.html +0 -151
- package/coverage/src/subscribes/scene-tree.ts.html +0 -373
- package/coverage/src/subscribes/selection.ts.html +0 -253
- package/coverage/src/subscribes/system-context/index.html +0 -131
- package/coverage/src/subscribes/system-context/index.ts.html +0 -100
- package/coverage/src/subscribes/system-context/primary-tool.ts.html +0 -151
- package/coverage/src/types.ts.html +0 -124
- package/coverage/src/ui-context.ts.html +0 -568
- package/dist/__tests__/ui-context.test.d.ts +0 -2
- package/dist/__tests__/ui-context.test.d.ts.map +0 -1
- package/dist/__tests__/ui-context.test.js +0 -170
- package/dist/__tests__/ui-context.test.js.map +0 -1
- package/dist/stores/__tests__/render.test.d.ts +0 -2
- package/dist/stores/__tests__/render.test.d.ts.map +0 -1
- package/dist/stores/__tests__/render.test.js +0 -30
- package/dist/stores/__tests__/render.test.js.map +0 -1
- package/dist/stores/__tests__/selection.test.d.ts +0 -2
- package/dist/stores/__tests__/selection.test.d.ts.map +0 -1
- package/dist/stores/__tests__/selection.test.js +0 -128
- package/dist/stores/__tests__/selection.test.js.map +0 -1
- package/dist/stores/render.d.ts +0 -4
- package/dist/stores/render.d.ts.map +0 -1
- package/dist/stores/render.js +0 -7
- package/dist/stores/render.js.map +0 -1
- package/dist/stores/scene-tree.d.ts +0 -35
- package/dist/stores/scene-tree.d.ts.map +0 -1
- package/dist/stores/scene-tree.js +0 -158
- package/dist/stores/scene-tree.js.map +0 -1
- package/dist/stores/selection.d.ts +0 -8
- package/dist/stores/selection.d.ts.map +0 -1
- package/dist/stores/selection.js +0 -38
- package/dist/stores/selection.js.map +0 -1
- package/dist/stores/system-context/__tests__/primary-tool.test.d.ts +0 -2
- package/dist/stores/system-context/__tests__/primary-tool.test.d.ts.map +0 -1
- package/dist/stores/system-context/__tests__/primary-tool.test.js +0 -27
- package/dist/stores/system-context/__tests__/primary-tool.test.js.map +0 -1
- package/dist/stores/system-context/index.d.ts +0 -2
- package/dist/stores/system-context/index.d.ts.map +0 -1
- package/dist/stores/system-context/index.js +0 -2
- package/dist/stores/system-context/index.js.map +0 -1
- package/dist/stores/system-context/primary-tool.d.ts +0 -5
- package/dist/stores/system-context/primary-tool.d.ts.map +0 -1
- package/dist/stores/system-context/primary-tool.js +0 -7
- package/dist/stores/system-context/primary-tool.js.map +0 -1
- package/dist/stores/system-context/system-context.d.ts +0 -1
- package/dist/stores/system-context/system-context.d.ts.map +0 -1
- package/dist/stores/system-context/system-context.js +0 -2
- package/dist/stores/system-context/system-context.js.map +0 -1
- package/dist/subscribes/index.d.ts +0 -5
- package/dist/subscribes/index.d.ts.map +0 -1
- package/dist/subscribes/index.js +0 -12
- package/dist/subscribes/index.js.map +0 -1
- package/dist/subscribes/render.d.ts +0 -2
- package/dist/subscribes/render.d.ts.map +0 -1
- package/dist/subscribes/render.js +0 -15
- package/dist/subscribes/render.js.map +0 -1
- package/dist/subscribes/scene-tree.d.ts +0 -5
- package/dist/subscribes/scene-tree.d.ts.map +0 -1
- package/dist/subscribes/scene-tree.js +0 -71
- package/dist/subscribes/scene-tree.js.map +0 -1
- package/dist/subscribes/selection.d.ts +0 -5
- package/dist/subscribes/selection.d.ts.map +0 -1
- package/dist/subscribes/selection.js +0 -42
- package/dist/subscribes/selection.js.map +0 -1
- package/dist/subscribes/system-context/index.d.ts +0 -2
- package/dist/subscribes/system-context/index.d.ts.map +0 -1
- package/dist/subscribes/system-context/index.js +0 -5
- package/dist/subscribes/system-context/index.js.map +0 -1
- package/dist/subscribes/system-context/primary-tool.d.ts +0 -4
- package/dist/subscribes/system-context/primary-tool.d.ts.map +0 -1
- package/dist/subscribes/system-context/primary-tool.js +0 -15
- package/dist/subscribes/system-context/primary-tool.js.map +0 -1
- package/dist/types.d.ts +0 -11
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -2
- package/dist/types.js.map +0 -1
- package/src/__tests__/ui-context.test.ts +0 -220
- package/src/index.ts +0 -4
- package/src/stores/__tests__/render.test.ts +0 -38
- package/src/stores/__tests__/selection.test.ts +0 -190
- package/src/stores/render.ts +0 -7
- package/src/stores/scene-tree.ts +0 -235
- package/src/stores/selection.ts +0 -45
- package/src/stores/system-context/__tests__/primary-tool.test.ts +0 -37
- package/src/stores/system-context/index.ts +0 -1
- package/src/stores/system-context/primary-tool.ts +0 -8
- package/src/stores/system-context/system-context.ts +0 -0
- package/src/subscribes/index.ts +0 -13
- package/src/subscribes/render.ts +0 -22
- package/src/subscribes/scene-tree.ts +0 -96
- package/src/subscribes/selection.ts +0 -56
- package/src/subscribes/system-context/index.ts +0 -5
- package/src/subscribes/system-context/primary-tool.ts +0 -22
- package/src/types.ts +0 -13
- package/src/ui-context.ts +0 -161
- package/tsconfig.json +0 -17
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
SceneTreeYjsChange,
|
|
3
|
-
AddRemoveElementChange,
|
|
4
|
-
UpdateElementChange,
|
|
5
|
-
ComputedAttrs
|
|
6
|
-
} from '@asyra/utils'
|
|
7
|
-
import { SCENE_TREE_ACTIONS } from '@asyra/utils'
|
|
8
|
-
import factory from '@asyra/factory'
|
|
9
|
-
import sceneTree from '@asyra/scene-tree'
|
|
10
|
-
import {
|
|
11
|
-
requestElementSelection,
|
|
12
|
-
subscribeToEndTransaction,
|
|
13
|
-
subscribeToSceneTreeLoadComplete
|
|
14
|
-
} from '@asyra/reactive-events'
|
|
15
|
-
import SceneTreeStore from '../stores/scene-tree'
|
|
16
|
-
import uiContext from '../ui-context'
|
|
17
|
-
|
|
18
|
-
export const sceneTreeStore = new SceneTreeStore(sceneTree)
|
|
19
|
-
|
|
20
|
-
const updateUISceneTree = (change: SceneTreeYjsChange['payload']) => {
|
|
21
|
-
switch (change.action) {
|
|
22
|
-
case SCENE_TREE_ACTIONS.ADD_ELEMENT: {
|
|
23
|
-
const { data } = change as AddRemoveElementChange
|
|
24
|
-
sceneTreeStore.addElement(data)
|
|
25
|
-
break
|
|
26
|
-
}
|
|
27
|
-
case SCENE_TREE_ACTIONS.REMOVE_ELEMENT: {
|
|
28
|
-
const { parentId, data } = change as AddRemoveElementChange
|
|
29
|
-
sceneTreeStore.removeElement(data, parentId as string)
|
|
30
|
-
break
|
|
31
|
-
}
|
|
32
|
-
case SCENE_TREE_ACTIONS.UPDATE_ELEMENT_COMPUTED_DATA: {
|
|
33
|
-
const { id, key, after } = change as UpdateElementChange
|
|
34
|
-
sceneTreeStore.updateElement(id, key, after)
|
|
35
|
-
break
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
// @ts-expect-error: It's YJS event
|
|
41
|
-
export const collectSceneTreeChange = (event) => {
|
|
42
|
-
const updatedComputedDataKeys = new Set() as Set<keyof ComputedAttrs>
|
|
43
|
-
|
|
44
|
-
const processChanges = (
|
|
45
|
-
items: typeof event.changes.added | typeof event.changes.deleted
|
|
46
|
-
) => {
|
|
47
|
-
// @ts-expect-error: It's YJS event
|
|
48
|
-
items.forEach((item) => {
|
|
49
|
-
item.content
|
|
50
|
-
.getContent()
|
|
51
|
-
.forEach((change: SceneTreeYjsChange['payload']) => {
|
|
52
|
-
if (
|
|
53
|
-
change.action === SCENE_TREE_ACTIONS.UPDATE_ELEMENT_COMPUTED_DATA &&
|
|
54
|
-
'key' in change
|
|
55
|
-
) {
|
|
56
|
-
updatedComputedDataKeys.add(change.key as keyof ComputedAttrs)
|
|
57
|
-
}
|
|
58
|
-
updateUISceneTree(change)
|
|
59
|
-
})
|
|
60
|
-
})
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
processChanges(event.changes.added)
|
|
64
|
-
processChanges(event.changes.deleted)
|
|
65
|
-
|
|
66
|
-
updatedComputedDataKeys.forEach(async (key) => {
|
|
67
|
-
const elementSelection = await requestElementSelection()
|
|
68
|
-
const propertyData = [...elementSelection].map((elementId) => {
|
|
69
|
-
const elementData = sceneTreeStore.getElementGeneralData(elementId)
|
|
70
|
-
return elementData?.[key]
|
|
71
|
-
}) as ComputedAttrs[keyof ComputedAttrs][]
|
|
72
|
-
uiContext.updateComputedProperty(key, propertyData)
|
|
73
|
-
})
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
let hasInit = false
|
|
77
|
-
|
|
78
|
-
export const initSceneTreeDataSubscribe = () => {
|
|
79
|
-
if (hasInit) {
|
|
80
|
-
return
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
const sceneTreeArray = factory.sceneTreeMap
|
|
84
|
-
sceneTreeArray.observe(collectSceneTreeChange)
|
|
85
|
-
|
|
86
|
-
subscribeToSceneTreeLoadComplete(() => {
|
|
87
|
-
sceneTreeStore.reload()
|
|
88
|
-
sceneTreeStore.fireChange()
|
|
89
|
-
})
|
|
90
|
-
|
|
91
|
-
subscribeToEndTransaction(() => {
|
|
92
|
-
sceneTreeStore.fireChange()
|
|
93
|
-
})
|
|
94
|
-
|
|
95
|
-
hasInit = true
|
|
96
|
-
}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import type { SelectionYjsChange } from '@asyra/utils'
|
|
2
|
-
import { SELECTION_ACTIONS, SELECTION_TYPES } from '@asyra/utils'
|
|
3
|
-
import factory from '@asyra/factory'
|
|
4
|
-
import {
|
|
5
|
-
finishRequestElementSelection,
|
|
6
|
-
subscribeToRequestElementSelection
|
|
7
|
-
} from '@asyra/reactive-events'
|
|
8
|
-
import SelectionStore from '../stores/selection'
|
|
9
|
-
import uiContext from '../ui-context'
|
|
10
|
-
|
|
11
|
-
export const selectionStore = new SelectionStore()
|
|
12
|
-
|
|
13
|
-
const updateUIElementSelection = (change: SelectionYjsChange['payload']) => {
|
|
14
|
-
switch (change.action) {
|
|
15
|
-
case SELECTION_ACTIONS.SELECT_ELEMENTS:
|
|
16
|
-
case SELECTION_ACTIONS.DESELECT_ELEMENTS:
|
|
17
|
-
selectionStore.updateSelection(SELECTION_TYPES.ELEMENT)
|
|
18
|
-
break
|
|
19
|
-
case SELECTION_ACTIONS.SELECT_VERTICES:
|
|
20
|
-
case SELECTION_ACTIONS.DESELECT_VERTICES:
|
|
21
|
-
selectionStore.updateSelection(SELECTION_TYPES.VERTEX)
|
|
22
|
-
break
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
// @ts-expect-error: It's YJS event
|
|
27
|
-
export const collectElementSelectionChange = (event) => {
|
|
28
|
-
const processChanges = (
|
|
29
|
-
items: typeof event.changes.added | typeof event.changes.deleted
|
|
30
|
-
) => {
|
|
31
|
-
// @ts-expect-error: It's YJS event
|
|
32
|
-
items.forEach((item) => {
|
|
33
|
-
item.content.getContent().forEach(updateUIElementSelection)
|
|
34
|
-
})
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
processChanges(event.changes.added)
|
|
38
|
-
processChanges(event.changes.deleted)
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
let hasInit = false
|
|
42
|
-
|
|
43
|
-
export const initSelectionDataSubscribe = () => {
|
|
44
|
-
if (hasInit) {
|
|
45
|
-
return
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
const elementSelectionArray = factory.elementSelectionMap
|
|
49
|
-
elementSelectionArray.observe(collectElementSelectionChange)
|
|
50
|
-
|
|
51
|
-
subscribeToRequestElementSelection(() => {
|
|
52
|
-
finishRequestElementSelection(uiContext.elementSelection.getValue())
|
|
53
|
-
})
|
|
54
|
-
|
|
55
|
-
hasInit = true
|
|
56
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
requestCurrentPrimaryTool,
|
|
3
|
-
subscribeToEmitSwitchPrimaryTool
|
|
4
|
-
} from '@asyra/reactive-events'
|
|
5
|
-
import { PrimaryToolStore } from '../../stores/system-context'
|
|
6
|
-
|
|
7
|
-
export const primaryToolStore = new PrimaryToolStore()
|
|
8
|
-
|
|
9
|
-
let hasInit = false
|
|
10
|
-
|
|
11
|
-
export const initPrimaryToolSubscribe = () => {
|
|
12
|
-
if (hasInit) {
|
|
13
|
-
return
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
subscribeToEmitSwitchPrimaryTool(async () => {
|
|
17
|
-
const primaryTool = await requestCurrentPrimaryTool()
|
|
18
|
-
primaryToolStore.updatePrimaryTool(primaryTool)
|
|
19
|
-
})
|
|
20
|
-
|
|
21
|
-
hasInit = true
|
|
22
|
-
}
|
package/src/types.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { MIXED_STRING } from '@asyra/utils'
|
|
2
|
-
|
|
3
|
-
type MixedType = typeof MIXED_STRING
|
|
4
|
-
|
|
5
|
-
export interface ElementProperties {
|
|
6
|
-
x: number | MixedType
|
|
7
|
-
y: number | MixedType
|
|
8
|
-
width: number | MixedType
|
|
9
|
-
height: number | MixedType
|
|
10
|
-
rotation: number | MixedType
|
|
11
|
-
// fills: string[] | MixedType
|
|
12
|
-
// fill: FillAttrs | MixedType
|
|
13
|
-
}
|
package/src/ui-context.ts
DELETED
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
import { BehaviorSubject } from 'rxjs'
|
|
2
|
-
import { ComputedAttrs, MIXED_STRING, PrimaryToolType } from '@asyra/utils'
|
|
3
|
-
import { isEqual } from 'lodash'
|
|
4
|
-
import { ElementProperties } from './types'
|
|
5
|
-
|
|
6
|
-
const generalKeysToCompare: (keyof ElementProperties)[] = [
|
|
7
|
-
'x',
|
|
8
|
-
'y',
|
|
9
|
-
'width',
|
|
10
|
-
'height',
|
|
11
|
-
'rotation'
|
|
12
|
-
]
|
|
13
|
-
|
|
14
|
-
class UIContext {
|
|
15
|
-
zoom: BehaviorSubject<number>
|
|
16
|
-
flattenedElementIds: BehaviorSubject<string[]>
|
|
17
|
-
elementSelection: BehaviorSubject<Set<string>>
|
|
18
|
-
vertexSelection: BehaviorSubject<Set<string>>
|
|
19
|
-
x: BehaviorSubject<ElementProperties['x']>
|
|
20
|
-
y: BehaviorSubject<ElementProperties['y']>
|
|
21
|
-
width: BehaviorSubject<ElementProperties['width']>
|
|
22
|
-
height: BehaviorSubject<ElementProperties['height']>
|
|
23
|
-
rotation: BehaviorSubject<ElementProperties['rotation']>
|
|
24
|
-
// fills: BehaviorSubject<ElementProperties['fills']>
|
|
25
|
-
|
|
26
|
-
// System Context
|
|
27
|
-
primaryTool: BehaviorSubject<PrimaryToolType>
|
|
28
|
-
|
|
29
|
-
constructor() {
|
|
30
|
-
this.zoom = new BehaviorSubject<number>(1)
|
|
31
|
-
this.flattenedElementIds = new BehaviorSubject<string[]>([])
|
|
32
|
-
this.elementSelection = new BehaviorSubject<Set<string>>(new Set())
|
|
33
|
-
this.vertexSelection = new BehaviorSubject<Set<string>>(new Set())
|
|
34
|
-
this.x = new BehaviorSubject<ElementProperties['x']>(0)
|
|
35
|
-
this.y = new BehaviorSubject<ElementProperties['y']>(0)
|
|
36
|
-
this.width = new BehaviorSubject<ElementProperties['width']>(0)
|
|
37
|
-
this.height = new BehaviorSubject<ElementProperties['height']>(0)
|
|
38
|
-
this.rotation = new BehaviorSubject<ElementProperties['rotation']>(0)
|
|
39
|
-
// this.fills = new BehaviorSubject<ElementProperties['fills']>([])
|
|
40
|
-
|
|
41
|
-
this.primaryTool = new BehaviorSubject<PrimaryToolType>(
|
|
42
|
-
PrimaryToolType.SELECT
|
|
43
|
-
)
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
updateElementSelection(selectedIds: Set<string>) {
|
|
47
|
-
if (!isEqual(this.elementSelection.getValue(), selectedIds)) {
|
|
48
|
-
this.elementSelection.next(selectedIds)
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
updateVertexSelection(selectedIds: Set<string>) {
|
|
53
|
-
if (!isEqual(this.vertexSelection.getValue(), selectedIds)) {
|
|
54
|
-
this.vertexSelection.next(selectedIds)
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
updateComputedProperty<K extends keyof ComputedAttrs>(
|
|
59
|
-
key: K,
|
|
60
|
-
data: ComputedAttrs[K][]
|
|
61
|
-
) {
|
|
62
|
-
if (!data.length) {
|
|
63
|
-
return
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
const compareKey = key as keyof ElementProperties
|
|
67
|
-
if (generalKeysToCompare.includes(compareKey)) {
|
|
68
|
-
const result = this.computedSharedProperty(
|
|
69
|
-
data as ElementProperties[keyof ElementProperties][]
|
|
70
|
-
)
|
|
71
|
-
if (result !== this[compareKey].getValue()) {
|
|
72
|
-
this[compareKey].next(result)
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
updateComputedProperties(allElementData: ComputedAttrs[]) {
|
|
78
|
-
const result = this.computeSharedProperties(allElementData)
|
|
79
|
-
|
|
80
|
-
generalKeysToCompare.forEach((key) => {
|
|
81
|
-
if (result[key] !== this[key].getValue()) {
|
|
82
|
-
this[key].next(result[key])
|
|
83
|
-
}
|
|
84
|
-
})
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
computedSharedProperty<K extends keyof ElementProperties>(
|
|
88
|
-
data: ElementProperties[K][]
|
|
89
|
-
) {
|
|
90
|
-
return compareValue(data)
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
computeSharedProperties(allElementData: ComputedAttrs[]): ElementProperties {
|
|
94
|
-
const result = {} as ElementProperties
|
|
95
|
-
|
|
96
|
-
result.x = compareValues(allElementData, 'x') as ElementProperties['x']
|
|
97
|
-
result.y = compareValues(allElementData, 'y') as ElementProperties['y']
|
|
98
|
-
result.width = compareValues(
|
|
99
|
-
allElementData,
|
|
100
|
-
'width'
|
|
101
|
-
) as ElementProperties['width']
|
|
102
|
-
result.height = compareValues(
|
|
103
|
-
allElementData,
|
|
104
|
-
'height'
|
|
105
|
-
) as ElementProperties['height']
|
|
106
|
-
result.rotation = compareValues(
|
|
107
|
-
allElementData,
|
|
108
|
-
'rotation'
|
|
109
|
-
) as ElementProperties['rotation']
|
|
110
|
-
|
|
111
|
-
return result
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
updateZoom(newZoom: number) {
|
|
115
|
-
this.zoom.next(newZoom)
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
updatePrimaryTool(tool: PrimaryToolType) {
|
|
119
|
-
if (tool !== this.primaryTool.getValue()) {
|
|
120
|
-
this.primaryTool.next(tool)
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
const uiContext = new UIContext()
|
|
126
|
-
|
|
127
|
-
export default uiContext
|
|
128
|
-
export { UIContext }
|
|
129
|
-
|
|
130
|
-
const compareValue = <K extends keyof ElementProperties>(
|
|
131
|
-
allElementData: ElementProperties[K][]
|
|
132
|
-
) => {
|
|
133
|
-
const firstValue = allElementData[0]
|
|
134
|
-
let isMixed = false
|
|
135
|
-
|
|
136
|
-
for (let i = 1; i < allElementData.length; i++) {
|
|
137
|
-
if (allElementData[i] !== firstValue) {
|
|
138
|
-
isMixed = true
|
|
139
|
-
break
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
return isMixed ? MIXED_STRING : firstValue
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
const compareValues = (
|
|
147
|
-
allElementData: ComputedAttrs[],
|
|
148
|
-
compareKey: keyof ComputedAttrs
|
|
149
|
-
) => {
|
|
150
|
-
const firstValue = allElementData[0][compareKey]
|
|
151
|
-
let isMixed = false
|
|
152
|
-
|
|
153
|
-
for (let i = 1; i < allElementData.length; i++) {
|
|
154
|
-
if (allElementData[i][compareKey] !== firstValue) {
|
|
155
|
-
isMixed = true
|
|
156
|
-
break
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
return isMixed ? MIXED_STRING : firstValue
|
|
161
|
-
}
|
package/tsconfig.json
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ES2020",
|
|
4
|
-
"module": "ESNext",
|
|
5
|
-
"declaration": true,
|
|
6
|
-
"declarationMap": true,
|
|
7
|
-
"sourceMap": true,
|
|
8
|
-
"outDir": "./dist",
|
|
9
|
-
"strict": true,
|
|
10
|
-
"esModuleInterop": true,
|
|
11
|
-
"skipLibCheck": true,
|
|
12
|
-
"moduleResolution": "Node",
|
|
13
|
-
"resolveJsonModule": true
|
|
14
|
-
},
|
|
15
|
-
"include": ["src"],
|
|
16
|
-
"exclude": ["node_modules", "dist"]
|
|
17
|
-
}
|