@asyra/selection 0.2.5 → 0.5.0
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 +12 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -9
- package/dist/index.js.map +1 -1
- package/dist/selection-manager.d.ts +5 -4
- package/dist/selection-manager.d.ts.map +1 -1
- package/dist/selection-manager.js +24 -5
- package/dist/selection-manager.js.map +1 -1
- package/dist/selections/base-selection.d.ts +18 -5
- package/dist/selections/base-selection.d.ts.map +1 -1
- package/dist/selections/base-selection.js +51 -16
- package/dist/selections/base-selection.js.map +1 -1
- package/package.json +21 -4
- package/.turbo/turbo-test$colon$ci.log +0 -62
- package/.turbo/turbo-test$colon$local.log +0 -16
- package/.turbo/turbo-test.log +0 -592
- package/CHANGELOG.md +0 -46
- package/coverage/base.css +0 -224
- package/coverage/block-navigation.js +0 -87
- package/coverage/clover.xml +0 -128
- package/coverage/coverage-final.json +0 -2152
- package/coverage/favicon.png +0 -0
- package/coverage/index.html +0 -146
- 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 -131
- package/coverage/src/index.ts.html +0 -127
- package/coverage/src/selection-manager.ts.html +0 -163
- package/coverage/src/selections/base-selection.ts.html +0 -259
- package/coverage/src/selections/element-selection.ts.html +0 -100
- package/coverage/src/selections/index.html +0 -146
- package/coverage/src/selections/vertex-selection.ts.html +0 -100
- package/coverage/src/subscribes/element-selection.ts.html +0 -133
- package/coverage/src/subscribes/index.html +0 -131
- package/coverage/src/subscribes/index.ts.html +0 -100
- package/dist/__tests__/selection-manager.test.d.ts +0 -2
- package/dist/__tests__/selection-manager.test.d.ts.map +0 -1
- package/dist/__tests__/selection-manager.test.js +0 -39
- package/dist/__tests__/selection-manager.test.js.map +0 -1
- package/dist/__tests__/selection.test.d.ts +0 -2
- package/dist/__tests__/selection.test.d.ts.map +0 -1
- package/dist/__tests__/selection.test.js +0 -44
- package/dist/__tests__/selection.test.js.map +0 -1
- package/dist/__tests__/seletion.test.d.ts +0 -2
- package/dist/__tests__/seletion.test.d.ts.map +0 -1
- package/dist/__tests__/seletion.test.js +0 -44
- package/dist/__tests__/seletion.test.js.map +0 -1
- package/dist/selections/element-selection.d.ts +0 -5
- package/dist/selections/element-selection.d.ts.map +0 -1
- package/dist/selections/element-selection.js +0 -5
- package/dist/selections/element-selection.js.map +0 -1
- package/dist/selections/vertex-selection.d.ts +0 -5
- package/dist/selections/vertex-selection.d.ts.map +0 -1
- package/dist/selections/vertex-selection.js +0 -5
- package/dist/selections/vertex-selection.js.map +0 -1
- package/dist/subscribes/element-selection.d.ts +0 -2
- package/dist/subscribes/element-selection.d.ts.map +0 -1
- package/dist/subscribes/element-selection.js +0 -12
- package/dist/subscribes/element-selection.js.map +0 -1
- package/dist/subscribes/index.d.ts +0 -2
- package/dist/subscribes/index.d.ts.map +0 -1
- package/dist/subscribes/index.js +0 -5
- package/dist/subscribes/index.js.map +0 -1
- package/src/__tests__/selection-manager.test.ts +0 -60
- package/src/__tests__/selection.test.ts +0 -59
- package/src/index.ts +0 -14
- package/src/selection-manager.ts +0 -26
- package/src/selections/base-selection.ts +0 -58
- package/src/selections/element-selection.ts +0 -5
- package/src/selections/vertex-selection.ts +0 -5
- package/src/subscribes/element-selection.ts +0 -16
- package/src/subscribes/index.ts +0 -5
- package/tsconfig.json +0 -17
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
2
|
-
import { SELECTION_TYPES } from '@asyra/utils';
|
|
3
|
-
import SelectionManager from '../selection-manager';
|
|
4
|
-
// Mock BaseSelection
|
|
5
|
-
const mockBaseSelection = {
|
|
6
|
-
clear: vi.fn(),
|
|
7
|
-
select: vi.fn(),
|
|
8
|
-
deselect: vi.fn(),
|
|
9
|
-
getSelectedIds: vi.fn(() => new Set()),
|
|
10
|
-
getPrevSelectedIds: vi.fn(() => new Set()),
|
|
11
|
-
addChange: vi.fn(),
|
|
12
|
-
cleanChanges: vi.fn()
|
|
13
|
-
};
|
|
14
|
-
describe('SelectionManager', () => {
|
|
15
|
-
let manager;
|
|
16
|
-
beforeEach(() => {
|
|
17
|
-
vi.clearAllMocks();
|
|
18
|
-
manager = new SelectionManager();
|
|
19
|
-
});
|
|
20
|
-
it('should register and retrieve selections correctly', () => {
|
|
21
|
-
manager.register(SELECTION_TYPES.ELEMENT, mockBaseSelection);
|
|
22
|
-
const selection = manager.get(SELECTION_TYPES.ELEMENT);
|
|
23
|
-
expect(selection).toBe(mockBaseSelection);
|
|
24
|
-
});
|
|
25
|
-
it('should return undefined for an unregistered selection type', () => {
|
|
26
|
-
const selection = manager.get(SELECTION_TYPES.VERTEX);
|
|
27
|
-
expect(selection).toBeUndefined();
|
|
28
|
-
});
|
|
29
|
-
it('should call clear() on all registered selections when clearAllSelections is called', () => {
|
|
30
|
-
const mockSelection1 = { ...mockBaseSelection, clear: vi.fn() };
|
|
31
|
-
const mockSelection2 = { ...mockBaseSelection, clear: vi.fn() };
|
|
32
|
-
manager.register(SELECTION_TYPES.ELEMENT, mockSelection1);
|
|
33
|
-
manager.register(SELECTION_TYPES.VERTEX, mockSelection2);
|
|
34
|
-
manager.clearAllSelections();
|
|
35
|
-
expect(mockSelection1.clear).toHaveBeenCalledTimes(1);
|
|
36
|
-
expect(mockSelection2.clear).toHaveBeenCalledTimes(1);
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
//# sourceMappingURL=selection-manager.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"selection-manager.test.js","sourceRoot":"","sources":["../../src/__tests__/selection-manager.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,UAAU,EAAE,MAAM,Q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CAAA;IAEF,EAAE,CAAC,oFAAoF,EAAE,GAAG,EAAE;QAC5F,MAAM,cAAc,GAAG,EAAE,GAAG,iBAAiB,EAAE,KAAK,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,CAAA;QAC/D,MAAM,cAAc,GAAG,EAAE,GAAG,iBAAiB,EAAE,KAAK,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,CAAA;QAC/D,OAAO,CAAC,QAAQ,CACd,eAAe,CAAC,OAAO,EACvB,cAA0C,CAC3C,CAAA;QACD,OAAO,CAAC,QAAQ,CACd,eAAe,CAAC,MAAM,EACtB,cAA0C,CAC3C,CAAA;QAED,OAAO,CAAC,kBAAkB,EAAE,CAAA;QAE5B,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAA;QACrD,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAA;IACvD,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"selection.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/selection.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, beforeEach } from 'vitest';
|
|
2
|
-
import Selection from '../selections/base-selection';
|
|
3
|
-
describe('Selection', () => {
|
|
4
|
-
let selection;
|
|
5
|
-
beforeEach(() => {
|
|
6
|
-
selection = new Selection();
|
|
7
|
-
});
|
|
8
|
-
it('should initialize with no selected ids', () => {
|
|
9
|
-
expect(selection.getSelectedIds()).toEqual(new Set([]));
|
|
10
|
-
expect(selection.getPrevSelectedIds()).toEqual(new Set([]));
|
|
11
|
-
});
|
|
12
|
-
it('should select ids correctly', () => {
|
|
13
|
-
selection.select(['id1', 'id2']);
|
|
14
|
-
expect(selection.getSelectedIds()).toEqual(new Set(['id1', 'id2']));
|
|
15
|
-
});
|
|
16
|
-
it('should deselect id correctly', () => {
|
|
17
|
-
selection.select(['id1', 'id2']);
|
|
18
|
-
selection.deselect(['id1']);
|
|
19
|
-
expect(selection.getSelectedIds()).toEqual(new Set(['id2']));
|
|
20
|
-
});
|
|
21
|
-
it('should clear selection correctly', () => {
|
|
22
|
-
selection.select(['id1', 'id2']);
|
|
23
|
-
selection.clear();
|
|
24
|
-
expect(selection.getSelectedIds()).toEqual(new Set([]));
|
|
25
|
-
});
|
|
26
|
-
it('should store previous selected ids when selecting', () => {
|
|
27
|
-
expect(selection.getPrevSelectedIds()).toEqual(new Set([]));
|
|
28
|
-
selection.select(['id1', 'id2']);
|
|
29
|
-
expect(selection.getPrevSelectedIds()).toEqual(new Set([]));
|
|
30
|
-
selection.select(['id3']);
|
|
31
|
-
expect(selection.getPrevSelectedIds()).toEqual(new Set(['id1', 'id2']));
|
|
32
|
-
});
|
|
33
|
-
it('should store previous selected ids when deselecting', () => {
|
|
34
|
-
selection.select(['id1', 'id2']);
|
|
35
|
-
selection.deselect(['id1']);
|
|
36
|
-
expect(selection.getPrevSelectedIds()).toEqual(new Set(['id1', 'id2']));
|
|
37
|
-
});
|
|
38
|
-
it('should store previous selected ids when clearing', () => {
|
|
39
|
-
selection.select(['id1', 'id2']);
|
|
40
|
-
selection.clear();
|
|
41
|
-
expect(selection.getPrevSelectedIds()).toEqual(new Set(['id1', 'id2']));
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
|
-
//# sourceMappingURL=selection.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"selection.test.js","sourceRoot":"","sources":["../../src/__tests__/selection.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAA;AACzD,OAAO,SAAS,MAAM,8BAA8B,CAAA;AAEpD,QAAQ,CAAC,WAAW,EAAE,GAAG,EAAE;IACzB,IAAI,SAAoB,CAAA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ACzE,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"seletion.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/seletion.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, beforeEach } from 'vitest';
|
|
2
|
-
import Selection from '../selections/base-selection';
|
|
3
|
-
describe('Selection', () => {
|
|
4
|
-
let selection;
|
|
5
|
-
beforeEach(() => {
|
|
6
|
-
selection = new Selection();
|
|
7
|
-
});
|
|
8
|
-
it('should initialize with no selected ids', () => {
|
|
9
|
-
expect(selection.getSelectedIds()).toEqual(new Set([]));
|
|
10
|
-
expect(selection.getPrevSelectedIds()).toEqual(new Set([]));
|
|
11
|
-
});
|
|
12
|
-
it('should select ids correctly', () => {
|
|
13
|
-
selection.select(['id1', 'id2']);
|
|
14
|
-
expect(selection.getSelectedIds()).toEqual(new Set(['id1', 'id2']));
|
|
15
|
-
});
|
|
16
|
-
it('should deselect id correctly', () => {
|
|
17
|
-
selection.select(['id1', 'id2']);
|
|
18
|
-
selection.deselect(['id1']);
|
|
19
|
-
expect(selection.getSelectedIds()).toEqual(new Set(['id2']));
|
|
20
|
-
});
|
|
21
|
-
it('should clear selection correctly', () => {
|
|
22
|
-
selection.select(['id1', 'id2']);
|
|
23
|
-
selection.clear();
|
|
24
|
-
expect(selection.getSelectedIds()).toEqual(new Set([]));
|
|
25
|
-
});
|
|
26
|
-
it('should store previous selected ids when selecting', () => {
|
|
27
|
-
expect(selection.getPrevSelectedIds()).toEqual(new Set([]));
|
|
28
|
-
selection.select(['id1', 'id2']);
|
|
29
|
-
expect(selection.getPrevSelectedIds()).toEqual(new Set([]));
|
|
30
|
-
selection.select(['id3']);
|
|
31
|
-
expect(selection.getPrevSelectedIds()).toEqual(new Set(['id1', 'id2']));
|
|
32
|
-
});
|
|
33
|
-
it('should store previous selected ids when deselecting', () => {
|
|
34
|
-
selection.select(['id1', 'id2']);
|
|
35
|
-
selection.deselect(['id1']);
|
|
36
|
-
expect(selection.getPrevSelectedIds()).toEqual(new Set(['id1', 'id2']));
|
|
37
|
-
});
|
|
38
|
-
it('should store previous selected ids when clearing', () => {
|
|
39
|
-
selection.select(['id1', 'id2']);
|
|
40
|
-
selection.clear();
|
|
41
|
-
expect(selection.getPrevSelectedIds()).toEqual(new Set(['id1', 'id2']));
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
|
-
//# sourceMappingURL=seletion.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"seletion.test.js","sourceRoot":"","sources":["../../src/__tests__/seletion.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAA;AACzD,OAAO,SAAS,MAAM,8BAA8B,CAAA;AAEpD,QAAQ,CAAC,WAAW,EAAE,GAAG,EAAE;IACzB,IAAI,SAAoB,CAAA;IAExB,UAAU,CAAC,GAAG,EAAE;QACd,SAAS,GAAG,IAAI,SAAS,EAAE,CAAA;IAC7B,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,wCAAwC,EAAE,GAAG,EAAE;QAChD,MAAM,CAAC,SAAS,CAAC,cAAc,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,GAAG,CAAC,EAAE,CAAC,CAAC,CAAA;QACvD,MAAM,CAAC,SAAS,CAAC,kBAAkB,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,GAAG,CAAC,EAAE,CAAC,CAAC,CAAA;IAC7D,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,6BAA6B,EAAE,GAAG,EAAE;QACrC,SAAS,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAA;QAEhC,MAAM,CAAC,SAAS,CAAC,cAAc,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,GAAG,CAAC,CAAC,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,CAAA;IAEF,EAAE,CAAC,qDAAqD,EAAE,GAAG,EAAE;QAC7D,SAAS,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAA;QAChC,SAAS,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,CAAC,CAAA;QAE3B,MAAM,CAAC,SAAS,CAAC,kBAAkB,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,CAAA;IACzE,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,kDAAkD,EAAE,GAAG,EAAE;QAC1D,SAAS,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAA;QAChC,SAAS,CAAC,KAAK,EAAE,CAAA;QAEjB,MAAM,CAAC,SAAS,CAAC,kBAAkB,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,CAAA;IACzE,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"element-selection.d.ts","sourceRoot":"","sources":["../../src/selections/element-selection.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,MAAM,kBAAkB,CAAA;AAE5C,MAAM,CAAC,OAAO,OAAO,gBAAiB,SAAQ,aAAa;CAAG;AAE9D,eAAO,MAAM,gBAAgB,kBAAyB,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"element-selection.js","sourceRoot":"","sources":["../../src/selections/element-selection.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,MAAM,kBAAkB,CAAA;AAE5C,MAAM,CAAC,OAAO,OAAO,gBAAiB,SAAQ,aAAa;CAAG;AAE9D,MAAM,CAAC,MAAM,gBAAgB,GAAG,IAAI,gBAAgB,EAAE,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"vertex-selection.d.ts","sourceRoot":"","sources":["../../src/selections/vertex-selection.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,MAAM,kBAAkB,CAAA;AAE5C,MAAM,CAAC,OAAO,OAAO,eAAgB,SAAQ,aAAa;CAAG;AAE7D,eAAO,MAAM,eAAe,iBAAwB,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"vertex-selection.js","sourceRoot":"","sources":["../../src/selections/vertex-selection.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,MAAM,kBAAkB,CAAA;AAE5C,MAAM,CAAC,OAAO,OAAO,eAAgB,SAAQ,aAAa;CAAG;AAE7D,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,eAAe,EAAE,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"element-selection.d.ts","sourceRoot":"","sources":["../../src/subscribes/element-selection.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,8BAA8B,YAS1C,CAAA"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { subscribeToSelectElements, updateTransaction } from '@asyra/reactive-events';
|
|
2
|
-
import { elementSelection } from '../selections/element-selection';
|
|
3
|
-
export const initElementSelectionSubscribes = () => {
|
|
4
|
-
subscribeToSelectElements(({ payload }) => {
|
|
5
|
-
elementSelection.select(payload.after);
|
|
6
|
-
elementSelection.changes.forEach((change) => {
|
|
7
|
-
updateTransaction(change.eventName, change);
|
|
8
|
-
});
|
|
9
|
-
elementSelection.cleanChanges();
|
|
10
|
-
});
|
|
11
|
-
};
|
|
12
|
-
//# sourceMappingURL=element-selection.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"element-selection.js","sourceRoot":"","sources":["../../src/subscribes/element-selection.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yBAAyB,EACzB,iBAAiB,EAClB,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAA;AAElE,MAAM,CAAC,MAAM,8BAA8B,GAAG,GAAG,EAAE;IACjD,yBAAyB,CAAC,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE;QACxC,gBAAgB,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;QAEtC,gBAAgB,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE;YAC1C,iBAAiB,CAAC,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,CAAA;QAC7C,CAAC,CAAC,CAAA;QACF,gBAAgB,CAAC,YAAY,EAAE,CAAA;IACjC,CAAC,CAAC,CAAA;AACJ,CAAC,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/subscribes/index.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,uBAAuB,YAEnC,CAAA"}
|
package/dist/subscribes/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/subscribes/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,8BAA8B,EAAE,MAAM,qBAAqB,CAAA;AAEpE,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAAG,EAAE;IAC1C,8BAA8B,EAAE,CAAA;AAClC,CAAC,CAAA"}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, vi, beforeEach } from 'vitest'
|
|
2
|
-
import { SELECTION_TYPES } from '@asyra/utils'
|
|
3
|
-
import SelectionManager from '../selection-manager'
|
|
4
|
-
import BaseSelection from '../selections/base-selection'
|
|
5
|
-
|
|
6
|
-
// Mock BaseSelection
|
|
7
|
-
const mockBaseSelection = {
|
|
8
|
-
clear: vi.fn(),
|
|
9
|
-
select: vi.fn(),
|
|
10
|
-
deselect: vi.fn(),
|
|
11
|
-
getSelectedIds: vi.fn(() => new Set()),
|
|
12
|
-
getPrevSelectedIds: vi.fn(() => new Set()),
|
|
13
|
-
addChange: vi.fn(),
|
|
14
|
-
cleanChanges: vi.fn()
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
describe('SelectionManager', () => {
|
|
18
|
-
let manager: SelectionManager
|
|
19
|
-
|
|
20
|
-
beforeEach(() => {
|
|
21
|
-
vi.clearAllMocks()
|
|
22
|
-
|
|
23
|
-
manager = new SelectionManager()
|
|
24
|
-
})
|
|
25
|
-
|
|
26
|
-
it('should register and retrieve selections correctly', () => {
|
|
27
|
-
manager.register(
|
|
28
|
-
SELECTION_TYPES.ELEMENT,
|
|
29
|
-
mockBaseSelection as unknown as BaseSelection
|
|
30
|
-
)
|
|
31
|
-
|
|
32
|
-
const selection = manager.get(SELECTION_TYPES.ELEMENT)
|
|
33
|
-
|
|
34
|
-
expect(selection).toBe(mockBaseSelection)
|
|
35
|
-
})
|
|
36
|
-
|
|
37
|
-
it('should return undefined for an unregistered selection type', () => {
|
|
38
|
-
const selection = manager.get(SELECTION_TYPES.VERTEX)
|
|
39
|
-
|
|
40
|
-
expect(selection).toBeUndefined()
|
|
41
|
-
})
|
|
42
|
-
|
|
43
|
-
it('should call clear() on all registered selections when clearAllSelections is called', () => {
|
|
44
|
-
const mockSelection1 = { ...mockBaseSelection, clear: vi.fn() }
|
|
45
|
-
const mockSelection2 = { ...mockBaseSelection, clear: vi.fn() }
|
|
46
|
-
manager.register(
|
|
47
|
-
SELECTION_TYPES.ELEMENT,
|
|
48
|
-
mockSelection1 as unknown as BaseSelection
|
|
49
|
-
)
|
|
50
|
-
manager.register(
|
|
51
|
-
SELECTION_TYPES.VERTEX,
|
|
52
|
-
mockSelection2 as unknown as BaseSelection
|
|
53
|
-
)
|
|
54
|
-
|
|
55
|
-
manager.clearAllSelections()
|
|
56
|
-
|
|
57
|
-
expect(mockSelection1.clear).toHaveBeenCalledTimes(1)
|
|
58
|
-
expect(mockSelection2.clear).toHaveBeenCalledTimes(1)
|
|
59
|
-
})
|
|
60
|
-
})
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, beforeEach } from 'vitest'
|
|
2
|
-
import Selection from '../selections/base-selection'
|
|
3
|
-
|
|
4
|
-
describe('Selection', () => {
|
|
5
|
-
let selection: Selection
|
|
6
|
-
|
|
7
|
-
beforeEach(() => {
|
|
8
|
-
selection = new Selection()
|
|
9
|
-
})
|
|
10
|
-
|
|
11
|
-
it('should initialize with no selected ids', () => {
|
|
12
|
-
expect(selection.getSelectedIds()).toEqual(new Set([]))
|
|
13
|
-
expect(selection.getPrevSelectedIds()).toEqual(new Set([]))
|
|
14
|
-
})
|
|
15
|
-
|
|
16
|
-
it('should select ids correctly', () => {
|
|
17
|
-
selection.select(['id1', 'id2'])
|
|
18
|
-
|
|
19
|
-
expect(selection.getSelectedIds()).toEqual(new Set(['id1', 'id2']))
|
|
20
|
-
})
|
|
21
|
-
|
|
22
|
-
it('should deselect id correctly', () => {
|
|
23
|
-
selection.select(['id1', 'id2'])
|
|
24
|
-
selection.deselect(['id1'])
|
|
25
|
-
|
|
26
|
-
expect(selection.getSelectedIds()).toEqual(new Set(['id2']))
|
|
27
|
-
})
|
|
28
|
-
|
|
29
|
-
it('should clear selection correctly', () => {
|
|
30
|
-
selection.select(['id1', 'id2'])
|
|
31
|
-
selection.clear()
|
|
32
|
-
|
|
33
|
-
expect(selection.getSelectedIds()).toEqual(new Set([]))
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
it('should store previous selected ids when selecting', () => {
|
|
37
|
-
expect(selection.getPrevSelectedIds()).toEqual(new Set([]))
|
|
38
|
-
|
|
39
|
-
selection.select(['id1', 'id2'])
|
|
40
|
-
expect(selection.getPrevSelectedIds()).toEqual(new Set([]))
|
|
41
|
-
|
|
42
|
-
selection.select(['id3'])
|
|
43
|
-
expect(selection.getPrevSelectedIds()).toEqual(new Set(['id1', 'id2']))
|
|
44
|
-
})
|
|
45
|
-
|
|
46
|
-
it('should store previous selected ids when deselecting', () => {
|
|
47
|
-
selection.select(['id1', 'id2'])
|
|
48
|
-
selection.deselect(['id1'])
|
|
49
|
-
|
|
50
|
-
expect(selection.getPrevSelectedIds()).toEqual(new Set(['id1', 'id2']))
|
|
51
|
-
})
|
|
52
|
-
|
|
53
|
-
it('should store previous selected ids when clearing', () => {
|
|
54
|
-
selection.select(['id1', 'id2'])
|
|
55
|
-
selection.clear()
|
|
56
|
-
|
|
57
|
-
expect(selection.getPrevSelectedIds()).toEqual(new Set(['id1', 'id2']))
|
|
58
|
-
})
|
|
59
|
-
})
|
package/src/index.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { SELECTION_TYPES } from '@asyra/utils'
|
|
2
|
-
import SelectionManager from './selection-manager'
|
|
3
|
-
import { elementSelection } from './selections/element-selection'
|
|
4
|
-
import { vertexSelection } from './selections/vertex-selection'
|
|
5
|
-
import { initSelectionSubscribes } from './subscribes'
|
|
6
|
-
|
|
7
|
-
initSelectionSubscribes()
|
|
8
|
-
|
|
9
|
-
const selectionManager = new SelectionManager()
|
|
10
|
-
selectionManager.register(SELECTION_TYPES.ELEMENT, elementSelection)
|
|
11
|
-
selectionManager.register(SELECTION_TYPES.VERTEX, vertexSelection)
|
|
12
|
-
|
|
13
|
-
export { SelectionManager }
|
|
14
|
-
export default selectionManager
|
package/src/selection-manager.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { SELECTION_TYPES } from '@asyra/utils'
|
|
2
|
-
import Selection from './selections/base-selection'
|
|
3
|
-
|
|
4
|
-
class SelectionManager {
|
|
5
|
-
private selections: Map<string, Selection> = new Map()
|
|
6
|
-
|
|
7
|
-
register(type: SELECTION_TYPES, selection: Selection): void {
|
|
8
|
-
this.selections.set(type, selection)
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
get(type: SELECTION_TYPES): Selection | undefined {
|
|
12
|
-
return this.selections.get(type)
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
clearAllSelections(): void {
|
|
16
|
-
this.selections.forEach((selection) => selection.clear())
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
getElementSelectionIds(): string[] {
|
|
20
|
-
return Array.from(
|
|
21
|
-
this.selections.get(SELECTION_TYPES.ELEMENT)?.getSelectedIds() || []
|
|
22
|
-
)
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export default SelectionManager
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { EventTypes } from '@asyra/reactive-events'
|
|
2
|
-
import { OWNER, SELECTION_ACTIONS } from '@asyra/utils'
|
|
3
|
-
import type { SelectionChange } from '@asyra/utils'
|
|
4
|
-
|
|
5
|
-
export default class BaseSelection {
|
|
6
|
-
protected selectedIds: Set<string> = new Set()
|
|
7
|
-
protected prevSelectedIds: Set<string> = new Set()
|
|
8
|
-
changes: SelectionChange[] = []
|
|
9
|
-
|
|
10
|
-
private _updatePrevSelectedIds(): void {
|
|
11
|
-
this.prevSelectedIds = new Set(this.selectedIds)
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
select(ids: string[]): void {
|
|
15
|
-
const before = [...this.getSelectedIds()]
|
|
16
|
-
this._updatePrevSelectedIds()
|
|
17
|
-
this.selectedIds = new Set(ids)
|
|
18
|
-
this.addChange(SELECTION_ACTIONS.SELECT_ELEMENTS, before, [...ids])
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
deselect(ids: string[]): void {
|
|
22
|
-
const before = [...this.getSelectedIds()]
|
|
23
|
-
this._updatePrevSelectedIds()
|
|
24
|
-
ids.forEach((id) => {
|
|
25
|
-
this.selectedIds.delete(id)
|
|
26
|
-
})
|
|
27
|
-
this.addChange(SELECTION_ACTIONS.SELECT_ELEMENTS, before, [...ids])
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
clear(): void {
|
|
31
|
-
const before = [...this.getSelectedIds()]
|
|
32
|
-
this._updatePrevSelectedIds()
|
|
33
|
-
this.selectedIds.clear()
|
|
34
|
-
this.addChange(SELECTION_ACTIONS.SELECT_ELEMENTS, before, [])
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
getSelectedIds(): Set<string> {
|
|
38
|
-
return this.selectedIds
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
getPrevSelectedIds(): Set<string> {
|
|
42
|
-
return this.prevSelectedIds
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
addChange(action: SELECTION_ACTIONS, before: string[], after: string[]) {
|
|
46
|
-
this.changes.push({
|
|
47
|
-
action,
|
|
48
|
-
owner: OWNER.ELEMENT_SELECTION,
|
|
49
|
-
eventName: EventTypes.SELECT_ELEMENTS,
|
|
50
|
-
before,
|
|
51
|
-
after
|
|
52
|
-
})
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
cleanChanges() {
|
|
56
|
-
this.changes = []
|
|
57
|
-
}
|
|
58
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
subscribeToSelectElements,
|
|
3
|
-
updateTransaction
|
|
4
|
-
} from '@asyra/reactive-events'
|
|
5
|
-
import { elementSelection } from '../selections/element-selection'
|
|
6
|
-
|
|
7
|
-
export const initElementSelectionSubscribes = () => {
|
|
8
|
-
subscribeToSelectElements(({ payload }) => {
|
|
9
|
-
elementSelection.select(payload.after)
|
|
10
|
-
|
|
11
|
-
elementSelection.changes.forEach((change) => {
|
|
12
|
-
updateTransaction(change.eventName, change)
|
|
13
|
-
})
|
|
14
|
-
elementSelection.cleanChanges()
|
|
15
|
-
})
|
|
16
|
-
}
|
package/src/subscribes/index.ts
DELETED
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
|
-
}
|