skandha-facets 0.13.0 → 0.14.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/facets/Addition.d.ts +16 -18
- package/facets/Addition.js +30 -24
- package/facets/Deletion.d.ts +7 -10
- package/facets/Deletion.js +10 -13
- package/facets/Display.js +1 -2
- package/facets/DragAndDrop.d.ts +14 -9
- package/facets/DragAndDrop.js +25 -11
- package/facets/Edit.d.ts +15 -16
- package/facets/Edit.js +29 -23
- package/facets/Filtering.d.ts +2 -7
- package/facets/Filtering.js +9 -6
- package/facets/Highlight.d.ts +7 -9
- package/facets/Highlight.js +13 -8
- package/facets/Insertion.d.ts +7 -9
- package/facets/Insertion.js +20 -14
- package/facets/Selection.d.ts +9 -9
- package/facets/Selection.js +25 -11
- package/index.d.ts +8 -8
- package/index.js +1 -1
- package/package.json +3 -3
package/facets/Addition.d.ts
CHANGED
|
@@ -1,7 +1,20 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CallbackMap } from 'aspiration';
|
|
2
2
|
export type GenericObjectT = any;
|
|
3
3
|
export declare class Addition<T = any> {
|
|
4
4
|
static className: () => string;
|
|
5
|
+
callbackMap: CallbackMap<{
|
|
6
|
+
add: {
|
|
7
|
+
stageAdd?: () => void;
|
|
8
|
+
createItem?: () => T;
|
|
9
|
+
highlightNewItem?: () => void;
|
|
10
|
+
};
|
|
11
|
+
cancel: {
|
|
12
|
+
unstageAdd(parentId: string | undefined): void;
|
|
13
|
+
};
|
|
14
|
+
confirm: {
|
|
15
|
+
confirmAdd(): void;
|
|
16
|
+
};
|
|
17
|
+
}>;
|
|
5
18
|
item?: T;
|
|
6
19
|
parentId?: string;
|
|
7
20
|
setParentId(parentId?: string): void;
|
|
@@ -9,22 +22,7 @@ export declare class Addition<T = any> {
|
|
|
9
22
|
add(args: {
|
|
10
23
|
values?: GenericObjectT;
|
|
11
24
|
}): any;
|
|
12
|
-
confirm():
|
|
13
|
-
cancel():
|
|
25
|
+
confirm(): any;
|
|
26
|
+
cancel(): any;
|
|
14
27
|
_reset(): void;
|
|
15
28
|
}
|
|
16
|
-
type Cbs<T> = {
|
|
17
|
-
add: {
|
|
18
|
-
stageAdd(): void;
|
|
19
|
-
createItem(): T;
|
|
20
|
-
highlightNewItem(): void;
|
|
21
|
-
};
|
|
22
|
-
cancel: {
|
|
23
|
-
unstageAdd(parentId: string | undefined): void;
|
|
24
|
-
};
|
|
25
|
-
confirm: {
|
|
26
|
-
confirmAdd(): void;
|
|
27
|
-
};
|
|
28
|
-
};
|
|
29
|
-
export type AdditionCbs<T = any> = DefineCbs<Addition<T>, Cbs<T>>;
|
|
30
|
-
export {};
|
package/facets/Addition.js
CHANGED
|
@@ -4,10 +4,16 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
import {
|
|
7
|
+
import { withCbs } from 'aspiration';
|
|
8
8
|
import { data, operation } from 'skandha';
|
|
9
9
|
class Addition {
|
|
10
10
|
constructor() {
|
|
11
|
+
Object.defineProperty(this, "callbackMap", {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
configurable: true,
|
|
14
|
+
writable: true,
|
|
15
|
+
value: {}
|
|
16
|
+
});
|
|
11
17
|
Object.defineProperty(this, "item", {
|
|
12
18
|
enumerable: true,
|
|
13
19
|
configurable: true,
|
|
@@ -28,28 +34,31 @@ class Addition {
|
|
|
28
34
|
this.item = item;
|
|
29
35
|
}
|
|
30
36
|
add(args) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
37
|
+
return withCbs(this.callbackMap, 'add', args, (cbs) => {
|
|
38
|
+
var _a;
|
|
39
|
+
cbs.stageAdd && cbs.stageAdd();
|
|
40
|
+
const newItem = (_a = args.values) !== null && _a !== void 0 ? _a : cbs.createItem();
|
|
41
|
+
this.setItem(newItem);
|
|
42
|
+
cbs.highlightNewItem && cbs.highlightNewItem();
|
|
43
|
+
return newItem;
|
|
44
|
+
});
|
|
38
45
|
}
|
|
39
46
|
confirm() {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
47
|
+
return withCbs(this.callbackMap, 'confirm', {}, (cbs) => {
|
|
48
|
+
const result = cbs.confirmAdd ? cbs.confirmAdd() : undefined;
|
|
49
|
+
return Promise.resolve(result).then(() => {
|
|
50
|
+
this._reset();
|
|
51
|
+
});
|
|
44
52
|
});
|
|
45
53
|
}
|
|
46
54
|
cancel() {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
55
|
+
return withCbs(this.callbackMap, 'cancel', {}, (cbs) => {
|
|
56
|
+
if (this.item) {
|
|
57
|
+
const parentId = this.parentId;
|
|
58
|
+
this._reset();
|
|
59
|
+
cbs.unstageAdd && cbs.unstageAdd(parentId);
|
|
60
|
+
}
|
|
61
|
+
});
|
|
53
62
|
}
|
|
54
63
|
_reset() {
|
|
55
64
|
this.setItem(undefined);
|
|
@@ -75,16 +84,13 @@ __decorate([
|
|
|
75
84
|
operation({ log: false })
|
|
76
85
|
], Addition.prototype, "setItem", null);
|
|
77
86
|
__decorate([
|
|
78
|
-
operation
|
|
79
|
-
withCbs()
|
|
87
|
+
operation
|
|
80
88
|
], Addition.prototype, "add", null);
|
|
81
89
|
__decorate([
|
|
82
|
-
operation
|
|
83
|
-
withCbs()
|
|
90
|
+
operation
|
|
84
91
|
], Addition.prototype, "confirm", null);
|
|
85
92
|
__decorate([
|
|
86
|
-
operation
|
|
87
|
-
withCbs()
|
|
93
|
+
operation
|
|
88
94
|
], Addition.prototype, "cancel", null);
|
|
89
95
|
__decorate([
|
|
90
96
|
operation({ log: false })
|
package/facets/Deletion.d.ts
CHANGED
|
@@ -1,18 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { type CallbackMap } from 'aspiration';
|
|
2
2
|
export declare class Deletion {
|
|
3
3
|
static className: () => string;
|
|
4
|
-
|
|
4
|
+
callbackMap: CallbackMap<{
|
|
5
|
+
delete: {
|
|
6
|
+
deleteItems: () => {};
|
|
7
|
+
};
|
|
8
|
+
}>;
|
|
5
9
|
isDeleting: boolean;
|
|
6
10
|
setIsDeleting(isDeleting: boolean): void;
|
|
7
11
|
delete(args: {
|
|
8
12
|
itemIds: string[];
|
|
9
13
|
moveToTrash?: boolean;
|
|
10
|
-
}):
|
|
14
|
+
}): any;
|
|
11
15
|
}
|
|
12
|
-
type Cbs = {
|
|
13
|
-
delete: {
|
|
14
|
-
deleteItems(): any;
|
|
15
|
-
};
|
|
16
|
-
};
|
|
17
|
-
export type DeletionCbs = DefineCbs<Deletion, Cbs>;
|
|
18
|
-
export {};
|
package/facets/Deletion.js
CHANGED
|
@@ -4,15 +4,15 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
import {
|
|
7
|
+
import { withCbs } from 'aspiration';
|
|
8
8
|
import { data, operation } from 'skandha';
|
|
9
9
|
class Deletion {
|
|
10
10
|
constructor() {
|
|
11
|
-
Object.defineProperty(this, "
|
|
11
|
+
Object.defineProperty(this, "callbackMap", {
|
|
12
12
|
enumerable: true,
|
|
13
13
|
configurable: true,
|
|
14
14
|
writable: true,
|
|
15
|
-
value:
|
|
15
|
+
value: {}
|
|
16
16
|
});
|
|
17
17
|
Object.defineProperty(this, "isDeleting", {
|
|
18
18
|
enumerable: true,
|
|
@@ -25,11 +25,12 @@ class Deletion {
|
|
|
25
25
|
this.isDeleting = isDeleting;
|
|
26
26
|
}
|
|
27
27
|
delete(args) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
28
|
+
return withCbs(this.callbackMap, 'delete', args, (cbs) => {
|
|
29
|
+
this.setIsDeleting(true);
|
|
30
|
+
return Promise.resolve(cbs.deleteItems()).then((response) => {
|
|
31
|
+
this.setIsDeleting(false);
|
|
32
|
+
return response;
|
|
33
|
+
});
|
|
33
34
|
});
|
|
34
35
|
}
|
|
35
36
|
}
|
|
@@ -39,9 +40,6 @@ Object.defineProperty(Deletion, "className", {
|
|
|
39
40
|
writable: true,
|
|
40
41
|
value: () => 'Deletion'
|
|
41
42
|
});
|
|
42
|
-
__decorate([
|
|
43
|
-
data
|
|
44
|
-
], Deletion.prototype, "disabled", void 0);
|
|
45
43
|
__decorate([
|
|
46
44
|
data
|
|
47
45
|
], Deletion.prototype, "isDeleting", void 0);
|
|
@@ -49,7 +47,6 @@ __decorate([
|
|
|
49
47
|
operation({ log: false })
|
|
50
48
|
], Deletion.prototype, "setIsDeleting", null);
|
|
51
49
|
__decorate([
|
|
52
|
-
operation
|
|
53
|
-
withCbs()
|
|
50
|
+
operation
|
|
54
51
|
], Deletion.prototype, "delete", null);
|
|
55
52
|
export { Deletion };
|
package/facets/Display.js
CHANGED
|
@@ -4,8 +4,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
import { stub } from '
|
|
8
|
-
import { data, output } from 'skandha';
|
|
7
|
+
import { data, output, stub } from 'skandha';
|
|
9
8
|
import { listToItemById } from '../internal/utils';
|
|
10
9
|
class Display {
|
|
11
10
|
constructor() {
|
package/facets/DragAndDrop.d.ts
CHANGED
|
@@ -1,17 +1,22 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { type CallbackMap, type Cbs } from 'aspiration';
|
|
2
2
|
import { HoverPositionT } from './Hovering';
|
|
3
|
+
export declare const defaultCallbackMap: (dragAndDrop: DragAndDrop) => {
|
|
4
|
+
drop: {
|
|
5
|
+
drop: (this: Cbs<DragAndDrop['drop']>) => void;
|
|
6
|
+
};
|
|
7
|
+
};
|
|
3
8
|
export declare class DragAndDrop {
|
|
4
9
|
static className: () => string;
|
|
10
|
+
callbackMap_: CallbackMap<{
|
|
11
|
+
drop?: {
|
|
12
|
+
drop?: (() => void) | undefined;
|
|
13
|
+
} | undefined;
|
|
14
|
+
}>;
|
|
15
|
+
get callbackMap(): typeof this.callbackMap_;
|
|
16
|
+
set callbackMap(cbs: typeof this.callbackMap_);
|
|
5
17
|
isDropping: boolean;
|
|
6
18
|
setIsDropping(isDropping: boolean): void;
|
|
7
19
|
drop(args: {
|
|
8
20
|
hoverPosition: HoverPositionT;
|
|
9
|
-
}):
|
|
21
|
+
}): any;
|
|
10
22
|
}
|
|
11
|
-
type Cbs = {
|
|
12
|
-
drop: {
|
|
13
|
-
drop(): void;
|
|
14
|
-
};
|
|
15
|
-
};
|
|
16
|
-
export type DragAndDropCbs = DefineCbs<DragAndDrop, Cbs>;
|
|
17
|
-
export {};
|
package/facets/DragAndDrop.js
CHANGED
|
@@ -4,16 +4,24 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
import {
|
|
7
|
+
import { mergeDeepLeft, withCbs } from 'aspiration';
|
|
8
8
|
import { data, operation } from 'skandha';
|
|
9
9
|
import { selectionIsInsertedOnDragAndDrop } from '../policies/selectionIsInsertedOnDragAndDrop';
|
|
10
|
-
const
|
|
11
|
-
drop:
|
|
12
|
-
|
|
10
|
+
export const defaultCallbackMap = (dragAndDrop) => ({
|
|
11
|
+
drop: {
|
|
12
|
+
drop: function () {
|
|
13
|
+
selectionIsInsertedOnDragAndDrop(dragAndDrop, this.args.hoverPosition);
|
|
14
|
+
},
|
|
13
15
|
},
|
|
14
16
|
});
|
|
15
17
|
class DragAndDrop {
|
|
16
18
|
constructor() {
|
|
19
|
+
Object.defineProperty(this, "callbackMap_", {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
configurable: true,
|
|
22
|
+
writable: true,
|
|
23
|
+
value: {}
|
|
24
|
+
});
|
|
17
25
|
Object.defineProperty(this, "isDropping", {
|
|
18
26
|
enumerable: true,
|
|
19
27
|
configurable: true,
|
|
@@ -21,15 +29,22 @@ class DragAndDrop {
|
|
|
21
29
|
value: false
|
|
22
30
|
});
|
|
23
31
|
}
|
|
32
|
+
get callbackMap() {
|
|
33
|
+
return this.callbackMap_;
|
|
34
|
+
}
|
|
35
|
+
set callbackMap(cbs) {
|
|
36
|
+
this.callbackMap_ = mergeDeepLeft(cbs, defaultCallbackMap(this));
|
|
37
|
+
}
|
|
24
38
|
setIsDropping(isDropping) {
|
|
25
39
|
this.isDropping = isDropping;
|
|
26
40
|
}
|
|
27
41
|
drop(args) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
42
|
+
return withCbs(this.callbackMap, 'drop', args, (cbs) => {
|
|
43
|
+
this.setIsDropping(true);
|
|
44
|
+
return Promise.resolve(cbs.drop()).then((response) => {
|
|
45
|
+
this.setIsDropping(false);
|
|
46
|
+
return response;
|
|
47
|
+
});
|
|
33
48
|
});
|
|
34
49
|
}
|
|
35
50
|
}
|
|
@@ -46,7 +61,6 @@ __decorate([
|
|
|
46
61
|
operation({ log: false })
|
|
47
62
|
], DragAndDrop.prototype, "setIsDropping", null);
|
|
48
63
|
__decorate([
|
|
49
|
-
operation
|
|
50
|
-
withCbs(dropDefaultCbs)
|
|
64
|
+
operation
|
|
51
65
|
], DragAndDrop.prototype, "drop", null);
|
|
52
66
|
export { DragAndDrop };
|
package/facets/Edit.d.ts
CHANGED
|
@@ -1,25 +1,24 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CallbackMap } from 'aspiration';
|
|
2
2
|
export declare class Edit {
|
|
3
3
|
static className: () => string;
|
|
4
|
+
callbackMap: CallbackMap<{
|
|
5
|
+
save: {
|
|
6
|
+
saveItem: () => any;
|
|
7
|
+
};
|
|
8
|
+
cancel?: {
|
|
9
|
+
onCancel?: (() => void) | undefined;
|
|
10
|
+
} | undefined;
|
|
11
|
+
enable?: {
|
|
12
|
+
onEnable?: (() => void) | undefined;
|
|
13
|
+
} | undefined;
|
|
14
|
+
}>;
|
|
4
15
|
isEditing: boolean;
|
|
5
16
|
isSaving: boolean;
|
|
6
17
|
reset(): void;
|
|
7
18
|
setIsSaving(isSaving: boolean): void;
|
|
8
19
|
save(args: {
|
|
9
20
|
values: any;
|
|
10
|
-
}):
|
|
11
|
-
cancel():
|
|
12
|
-
enable():
|
|
21
|
+
}): any;
|
|
22
|
+
cancel(): any;
|
|
23
|
+
enable(): any;
|
|
13
24
|
}
|
|
14
|
-
export type Cbs = {
|
|
15
|
-
save: {
|
|
16
|
-
saveItem(): any;
|
|
17
|
-
};
|
|
18
|
-
cancel: {
|
|
19
|
-
onCancel(): void;
|
|
20
|
-
};
|
|
21
|
-
enable: {
|
|
22
|
-
onEnable(): void;
|
|
23
|
-
};
|
|
24
|
-
};
|
|
25
|
-
export type EditCbs = DefineCbs<Edit, Cbs>;
|
package/facets/Edit.js
CHANGED
|
@@ -4,10 +4,16 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
import {
|
|
7
|
+
import { withCbs } from 'aspiration';
|
|
8
8
|
import { data, operation } from 'skandha';
|
|
9
9
|
class Edit {
|
|
10
10
|
constructor() {
|
|
11
|
+
Object.defineProperty(this, "callbackMap", {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
configurable: true,
|
|
14
|
+
writable: true,
|
|
15
|
+
value: {}
|
|
16
|
+
});
|
|
11
17
|
Object.defineProperty(this, "isEditing", {
|
|
12
18
|
enumerable: true,
|
|
13
19
|
configurable: true,
|
|
@@ -28,27 +34,30 @@ class Edit {
|
|
|
28
34
|
this.isSaving = isSaving;
|
|
29
35
|
}
|
|
30
36
|
save(args) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
+
return withCbs(this.callbackMap, 'save', args, (cbs) => {
|
|
38
|
+
this.setIsSaving(true);
|
|
39
|
+
return Promise.resolve(cbs.saveItem()).then((savedObj) => {
|
|
40
|
+
this.reset();
|
|
41
|
+
this.setIsSaving(false);
|
|
42
|
+
return savedObj;
|
|
43
|
+
});
|
|
37
44
|
});
|
|
38
45
|
}
|
|
39
46
|
cancel() {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
47
|
+
return withCbs(this.callbackMap, 'cancel', {}, (cbs) => {
|
|
48
|
+
if (this.isEditing) {
|
|
49
|
+
this.reset();
|
|
50
|
+
(cbs === null || cbs === void 0 ? void 0 : cbs.onCancel) && cbs.onCancel();
|
|
51
|
+
}
|
|
52
|
+
});
|
|
45
53
|
}
|
|
46
54
|
enable() {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
55
|
+
return withCbs(this.callbackMap, 'enable', {}, (cbs) => {
|
|
56
|
+
if (!this.isEditing) {
|
|
57
|
+
this.isEditing = true;
|
|
58
|
+
(cbs === null || cbs === void 0 ? void 0 : cbs.onEnable) && cbs.onEnable();
|
|
59
|
+
}
|
|
60
|
+
});
|
|
52
61
|
}
|
|
53
62
|
}
|
|
54
63
|
Object.defineProperty(Edit, "className", {
|
|
@@ -70,15 +79,12 @@ __decorate([
|
|
|
70
79
|
operation({ log: false })
|
|
71
80
|
], Edit.prototype, "setIsSaving", null);
|
|
72
81
|
__decorate([
|
|
73
|
-
operation
|
|
74
|
-
withCbs()
|
|
82
|
+
operation
|
|
75
83
|
], Edit.prototype, "save", null);
|
|
76
84
|
__decorate([
|
|
77
|
-
operation
|
|
78
|
-
withCbs()
|
|
85
|
+
operation
|
|
79
86
|
], Edit.prototype, "cancel", null);
|
|
80
87
|
__decorate([
|
|
81
|
-
operation
|
|
82
|
-
withCbs()
|
|
88
|
+
operation
|
|
83
89
|
], Edit.prototype, "enable", null);
|
|
84
90
|
export { Edit };
|
package/facets/Filtering.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { type CallbackMap } from 'aspiration';
|
|
2
2
|
export type FilterT<T> = (x: T[]) => T[];
|
|
3
3
|
export declare class Filtering<T = any> {
|
|
4
4
|
static className: () => string;
|
|
5
|
+
callbackMap: CallbackMap<{}>;
|
|
5
6
|
isEnabled: boolean;
|
|
6
7
|
filter: FilterT<T>;
|
|
7
8
|
inputItems: Array<T>;
|
|
@@ -13,9 +14,3 @@ export declare class Filtering<T = any> {
|
|
|
13
14
|
flag: boolean;
|
|
14
15
|
}): void;
|
|
15
16
|
}
|
|
16
|
-
type Cbs<T> = {
|
|
17
|
-
apply: {};
|
|
18
|
-
setEnabled: {};
|
|
19
|
-
};
|
|
20
|
-
export type FilteringCbs<T = any> = DefineCbs<Filtering<T>, Cbs<T>>;
|
|
21
|
-
export {};
|
package/facets/Filtering.js
CHANGED
|
@@ -4,10 +4,15 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
import {
|
|
8
|
-
import { data, operation } from 'skandha';
|
|
7
|
+
import { data, operation, stub } from 'skandha';
|
|
9
8
|
class Filtering {
|
|
10
9
|
constructor() {
|
|
10
|
+
Object.defineProperty(this, "callbackMap", {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
configurable: true,
|
|
13
|
+
writable: true,
|
|
14
|
+
value: {}
|
|
15
|
+
});
|
|
11
16
|
Object.defineProperty(this, "isEnabled", {
|
|
12
17
|
enumerable: true,
|
|
13
18
|
configurable: true,
|
|
@@ -57,11 +62,9 @@ __decorate([
|
|
|
57
62
|
data
|
|
58
63
|
], Filtering.prototype, "filteredItems", null);
|
|
59
64
|
__decorate([
|
|
60
|
-
operation
|
|
61
|
-
withCbs()
|
|
65
|
+
operation
|
|
62
66
|
], Filtering.prototype, "apply", null);
|
|
63
67
|
__decorate([
|
|
64
|
-
operation
|
|
65
|
-
withCbs()
|
|
68
|
+
operation
|
|
66
69
|
], Filtering.prototype, "setEnabled", null);
|
|
67
70
|
export { Filtering };
|
package/facets/Highlight.d.ts
CHANGED
|
@@ -1,17 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { type CallbackMap } from 'aspiration';
|
|
2
2
|
export declare class Highlight<T = any> {
|
|
3
3
|
static className: () => string;
|
|
4
|
+
callbackMap: CallbackMap<{
|
|
5
|
+
set: {
|
|
6
|
+
scrollItemIntoView?: () => void;
|
|
7
|
+
};
|
|
8
|
+
}>;
|
|
4
9
|
highlightableIds: Array<string>;
|
|
5
10
|
itemId: string | undefined;
|
|
6
11
|
item?: T;
|
|
7
12
|
set(args: {
|
|
8
13
|
itemId: string | undefined;
|
|
9
|
-
}):
|
|
14
|
+
}): any;
|
|
10
15
|
}
|
|
11
|
-
type Cbs<T> = {
|
|
12
|
-
set: {
|
|
13
|
-
scrollItemIntoView(): void;
|
|
14
|
-
};
|
|
15
|
-
};
|
|
16
|
-
export type HighlightCbs<T = any> = DefineCbs<Highlight<T>, Cbs<T>>;
|
|
17
|
-
export {};
|
package/facets/Highlight.js
CHANGED
|
@@ -4,11 +4,16 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
import {
|
|
8
|
-
import { data, input, operation, output } from 'skandha';
|
|
9
|
-
const highlightItemDefaultCbs = (highlight) => ({});
|
|
7
|
+
import { withCbs } from 'aspiration';
|
|
8
|
+
import { data, input, operation, output, stub } from 'skandha';
|
|
10
9
|
class Highlight {
|
|
11
10
|
constructor() {
|
|
11
|
+
Object.defineProperty(this, "callbackMap", {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
configurable: true,
|
|
14
|
+
writable: true,
|
|
15
|
+
value: {}
|
|
16
|
+
});
|
|
12
17
|
Object.defineProperty(this, "highlightableIds", {
|
|
13
18
|
enumerable: true,
|
|
14
19
|
configurable: true,
|
|
@@ -29,9 +34,10 @@ class Highlight {
|
|
|
29
34
|
});
|
|
30
35
|
}
|
|
31
36
|
set(args) {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
37
|
+
return withCbs(this.callbackMap, 'set', args, (cbs) => {
|
|
38
|
+
this.itemId = args.itemId;
|
|
39
|
+
cbs.scrollItemIntoView && cbs.scrollItemIntoView();
|
|
40
|
+
});
|
|
35
41
|
}
|
|
36
42
|
}
|
|
37
43
|
Object.defineProperty(Highlight, "className", {
|
|
@@ -50,7 +56,6 @@ __decorate([
|
|
|
50
56
|
output
|
|
51
57
|
], Highlight.prototype, "item", void 0);
|
|
52
58
|
__decorate([
|
|
53
|
-
operation
|
|
54
|
-
withCbs(highlightItemDefaultCbs)
|
|
59
|
+
operation
|
|
55
60
|
], Highlight.prototype, "set", null);
|
|
56
61
|
export { Highlight };
|
package/facets/Insertion.d.ts
CHANGED
|
@@ -1,20 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { type CallbackMap } from 'aspiration';
|
|
2
2
|
import { HoverPositionT } from './Hovering';
|
|
3
3
|
export type DragSourceT = (ctr: any) => HoverPositionT | undefined;
|
|
4
4
|
export declare class Insertion<T = any> {
|
|
5
5
|
static className: () => string;
|
|
6
|
+
callbackMap: CallbackMap<{
|
|
7
|
+
insertItems: {
|
|
8
|
+
insertItems: (preview: Array<T>) => any;
|
|
9
|
+
};
|
|
10
|
+
}>;
|
|
6
11
|
isInserting: boolean;
|
|
7
12
|
inputItems: Array<T>;
|
|
8
13
|
preview: Array<T>;
|
|
9
14
|
setIsInserting(isInserting: boolean): void;
|
|
10
15
|
insertItems(args: {
|
|
11
16
|
hoverPosition: HoverPositionT;
|
|
12
|
-
}):
|
|
17
|
+
}): any;
|
|
13
18
|
}
|
|
14
|
-
type Cbs<T> = {
|
|
15
|
-
insertItems: {
|
|
16
|
-
insertItems(preview: Array<T>): any;
|
|
17
|
-
};
|
|
18
|
-
};
|
|
19
|
-
export type InsertionCbs<T = any> = DefineCbs<Insertion<T>, Cbs<T>>;
|
|
20
|
-
export {};
|
package/facets/Insertion.js
CHANGED
|
@@ -4,11 +4,17 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
import {
|
|
8
|
-
import { data, input, operation, output } from 'skandha';
|
|
7
|
+
import { withCbs } from 'aspiration';
|
|
8
|
+
import { data, input, operation, output, stub } from 'skandha';
|
|
9
9
|
import { getPreview } from '../lib/getPreview';
|
|
10
10
|
class Insertion {
|
|
11
11
|
constructor() {
|
|
12
|
+
Object.defineProperty(this, "callbackMap", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
configurable: true,
|
|
15
|
+
writable: true,
|
|
16
|
+
value: {}
|
|
17
|
+
});
|
|
12
18
|
Object.defineProperty(this, "isInserting", {
|
|
13
19
|
enumerable: true,
|
|
14
20
|
configurable: true,
|
|
@@ -32,16 +38,17 @@ class Insertion {
|
|
|
32
38
|
this.isInserting = isInserting;
|
|
33
39
|
}
|
|
34
40
|
insertItems(args) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
41
|
+
return withCbs(this.callbackMap, 'insertItems', args, (cbs) => {
|
|
42
|
+
if (this.inputItems) {
|
|
43
|
+
this.setIsInserting(true);
|
|
44
|
+
const preview = getPreview(this.inputItems, args.hoverPosition.targetItemId, args.hoverPosition.isBefore, args.hoverPosition.payload);
|
|
45
|
+
return Promise.resolve(cbs.insertItems(preview)).then((response) => {
|
|
46
|
+
this.setIsInserting(false);
|
|
47
|
+
return response;
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
return Promise.resolve();
|
|
51
|
+
});
|
|
45
52
|
}
|
|
46
53
|
}
|
|
47
54
|
Object.defineProperty(Insertion, "className", {
|
|
@@ -63,7 +70,6 @@ __decorate([
|
|
|
63
70
|
operation({ log: false })
|
|
64
71
|
], Insertion.prototype, "setIsInserting", null);
|
|
65
72
|
__decorate([
|
|
66
|
-
operation
|
|
67
|
-
withCbs()
|
|
73
|
+
operation
|
|
68
74
|
], Insertion.prototype, "insertItems", null);
|
|
69
75
|
export { Insertion };
|
package/facets/Selection.d.ts
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { type CallbackMap } from 'aspiration';
|
|
2
2
|
export declare class Selection<T = any> {
|
|
3
3
|
static className: () => string;
|
|
4
|
+
callbackMap_: CallbackMap<{
|
|
5
|
+
selectItem?: {
|
|
6
|
+
selectItem: () => void;
|
|
7
|
+
} | undefined;
|
|
8
|
+
}>;
|
|
9
|
+
get callbackMap(): typeof this.callbackMap_;
|
|
10
|
+
set callbackMap(cbs: typeof this.callbackMap_);
|
|
4
11
|
selectableIds: Array<string>;
|
|
5
12
|
itemIds: Array<string>;
|
|
6
13
|
anchorId?: string;
|
|
@@ -10,17 +17,10 @@ export declare class Selection<T = any> {
|
|
|
10
17
|
isShift?: boolean;
|
|
11
18
|
isCtrl?: boolean;
|
|
12
19
|
context?: any;
|
|
13
|
-
}):
|
|
20
|
+
}): any;
|
|
14
21
|
}
|
|
15
|
-
type Cbs<T> = {
|
|
16
|
-
selectItem: {
|
|
17
|
-
selectItem(): void;
|
|
18
|
-
};
|
|
19
|
-
};
|
|
20
|
-
export type SelectionCbs<T = any> = DefineCbs<Selection<T>, Cbs<T>>;
|
|
21
22
|
export declare function handleSelectItem(facet: Selection, args: {
|
|
22
23
|
itemId: string | undefined;
|
|
23
24
|
isShift?: boolean;
|
|
24
25
|
isCtrl?: boolean;
|
|
25
26
|
}): void;
|
|
26
|
-
export {};
|
package/facets/Selection.js
CHANGED
|
@@ -4,16 +4,17 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
import {
|
|
8
|
-
import { data, input, operation, output } from 'skandha';
|
|
7
|
+
import { mergeDeepLeft, withCbs } from 'aspiration';
|
|
8
|
+
import { data, input, operation, output, stub } from 'skandha';
|
|
9
9
|
import { range } from '../internal/utils';
|
|
10
|
-
const selectItemDefaultCbs = (selection) => ({
|
|
11
|
-
selectItem: function () {
|
|
12
|
-
handleSelectItem(selection, this.args);
|
|
13
|
-
},
|
|
14
|
-
});
|
|
15
10
|
class Selection {
|
|
16
11
|
constructor() {
|
|
12
|
+
Object.defineProperty(this, "callbackMap_", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
configurable: true,
|
|
15
|
+
writable: true,
|
|
16
|
+
value: {}
|
|
17
|
+
});
|
|
17
18
|
Object.defineProperty(this, "selectableIds", {
|
|
18
19
|
enumerable: true,
|
|
19
20
|
configurable: true,
|
|
@@ -39,9 +40,16 @@ class Selection {
|
|
|
39
40
|
value: stub
|
|
40
41
|
});
|
|
41
42
|
}
|
|
43
|
+
get callbackMap() {
|
|
44
|
+
return this.callbackMap_;
|
|
45
|
+
}
|
|
46
|
+
set callbackMap(cbs) {
|
|
47
|
+
this.callbackMap_ = mergeDeepLeft(cbs, defaultCallbackMap(this));
|
|
48
|
+
}
|
|
42
49
|
selectItem(args) {
|
|
43
|
-
|
|
44
|
-
|
|
50
|
+
return withCbs(this.callbackMap, 'selectItem', args, (cbs) => {
|
|
51
|
+
cbs.selectItem();
|
|
52
|
+
});
|
|
45
53
|
}
|
|
46
54
|
}
|
|
47
55
|
Object.defineProperty(Selection, "className", {
|
|
@@ -63,8 +71,7 @@ __decorate([
|
|
|
63
71
|
output
|
|
64
72
|
], Selection.prototype, "items", void 0);
|
|
65
73
|
__decorate([
|
|
66
|
-
operation
|
|
67
|
-
withCbs(selectItemDefaultCbs)
|
|
74
|
+
operation
|
|
68
75
|
], Selection.prototype, "selectItem", null);
|
|
69
76
|
export { Selection };
|
|
70
77
|
export function handleSelectItem(facet, args) {
|
|
@@ -98,3 +105,10 @@ export function handleSelectItem(facet, args) {
|
|
|
98
105
|
facet.anchorId = args.itemId;
|
|
99
106
|
}
|
|
100
107
|
}
|
|
108
|
+
const defaultCallbackMap = (selection) => ({
|
|
109
|
+
selectItem: {
|
|
110
|
+
selectItem: function () {
|
|
111
|
+
handleSelectItem(selection, this.args);
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
});
|
package/index.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
export { Addition
|
|
2
|
-
export { Deletion
|
|
1
|
+
export { Addition } from './facets/Addition';
|
|
2
|
+
export { Deletion } from './facets/Deletion';
|
|
3
3
|
export { Display } from './facets/Display';
|
|
4
|
-
export { DragAndDrop
|
|
4
|
+
export { DragAndDrop } from './facets/DragAndDrop';
|
|
5
5
|
export { DragAndDropUIConnector, dragAndDropUIHandlers, type DragAndDropUIConnectorT, type DragAndDropUIPropsT, } from './facets/DragAndDropUIConnector';
|
|
6
|
-
export { Edit
|
|
7
|
-
export { Filtering
|
|
8
|
-
export { Highlight
|
|
6
|
+
export { Edit } from './facets/Edit';
|
|
7
|
+
export { Filtering } from './facets/Filtering';
|
|
8
|
+
export { Highlight } from './facets/Highlight';
|
|
9
9
|
export { HighlightUIConnector, createHighlightKeyHandlers, highlightUIHandlers, type HighlightUIConnectorT, type HighlightUIPropsT, } from './facets/HighlightUIConnector';
|
|
10
10
|
export { Hovering, type HoverPositionT } from './facets/Hovering';
|
|
11
|
-
export { Insertion
|
|
12
|
-
export { Selection, handleSelectItem
|
|
11
|
+
export { Insertion } from './facets/Insertion';
|
|
12
|
+
export { Selection, handleSelectItem } from './facets/Selection';
|
|
13
13
|
export { SelectionUIConnector, createSelectionKeyHandlers, selectionUIHandlers, type SelectionUIConnectorT, type SelectionUIPropsT, } from './facets/SelectionUIConnector';
|
|
14
14
|
export { Store } from './facets/Store';
|
|
15
15
|
export { topOfTheList } from './lib/getPreview';
|
package/index.js
CHANGED
|
@@ -9,7 +9,7 @@ export { Highlight } from './facets/Highlight';
|
|
|
9
9
|
export { HighlightUIConnector, createHighlightKeyHandlers, highlightUIHandlers, } from './facets/HighlightUIConnector';
|
|
10
10
|
export { Hovering } from './facets/Hovering';
|
|
11
11
|
export { Insertion } from './facets/Insertion';
|
|
12
|
-
export { Selection, handleSelectItem
|
|
12
|
+
export { Selection, handleSelectItem } from './facets/Selection';
|
|
13
13
|
export { SelectionUIConnector, createSelectionKeyHandlers, selectionUIHandlers, } from './facets/SelectionUIConnector';
|
|
14
14
|
export { Store } from './facets/Store';
|
|
15
15
|
export { topOfTheList } from './lib/getPreview';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "skandha-facets",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0",
|
|
4
4
|
"description": "Facets for use with the skandha library",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"repository": "https://github.com/mnieber/skandha-facets.git",
|
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
"types": "index.d.ts",
|
|
10
10
|
"prepublish": "tsc",
|
|
11
11
|
"peerDependencies": {
|
|
12
|
-
"skandha": ">=0.
|
|
13
|
-
"aspiration": ">=0.
|
|
12
|
+
"skandha": ">=0.14.0",
|
|
13
|
+
"aspiration": ">=0.6.0"
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
16
|
"typescript": "^4.0.3"
|