skandha-facets 0.7.0 → 0.9.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/Addition.js +5 -5
- package/Deletion.js +1 -1
- package/DragAndDrop.js +1 -1
- package/Editing.js +3 -3
- package/Filtering.d.ts +2 -4
- package/Filtering.js +5 -6
- package/Highlight.d.ts +0 -2
- package/Highlight.js +4 -11
- package/Insertion.d.ts +2 -4
- package/Insertion.js +5 -6
- package/Labelling.d.ts +1 -3
- package/Labelling.js +4 -12
- package/Selection.d.ts +2 -5
- package/Selection.js +6 -14
- package/index.d.ts +1 -4
- package/index.js +1 -4
- package/package.json +3 -3
- package/policies/highlightIsCorrectedOnFilterChange.d.ts +3 -1
- package/policies/highlightIsCorrectedOnFilterChange.js +20 -22
- package/policies/insertionPreviewUsesDragSources.d.ts +2 -2
- package/policies/insertionPreviewUsesDragSources.js +5 -10
package/Addition.js
CHANGED
|
@@ -4,7 +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 { host
|
|
7
|
+
import { host } from 'aspiration';
|
|
8
8
|
import { data, operation } from 'skandha';
|
|
9
9
|
export class Addition {
|
|
10
10
|
constructor() {
|
|
@@ -23,9 +23,9 @@ export class Addition {
|
|
|
23
23
|
}
|
|
24
24
|
add(values) {
|
|
25
25
|
return (cbs) => {
|
|
26
|
-
|
|
26
|
+
cbs.storeLocation && cbs.storeLocation();
|
|
27
27
|
this.item = cbs.createItem();
|
|
28
|
-
|
|
28
|
+
cbs.highlightNewItem && cbs.highlightNewItem();
|
|
29
29
|
};
|
|
30
30
|
}
|
|
31
31
|
confirm() {
|
|
@@ -37,7 +37,7 @@ export class Addition {
|
|
|
37
37
|
cancel() {
|
|
38
38
|
return (cbs) => {
|
|
39
39
|
this._reset();
|
|
40
|
-
|
|
40
|
+
cbs.restoreLocation && cbs.restoreLocation();
|
|
41
41
|
};
|
|
42
42
|
}
|
|
43
43
|
_reset() {
|
|
@@ -59,7 +59,7 @@ __decorate([
|
|
|
59
59
|
], Addition.prototype, "parentId", void 0);
|
|
60
60
|
__decorate([
|
|
61
61
|
operation,
|
|
62
|
-
host
|
|
62
|
+
host(['values'])
|
|
63
63
|
], Addition.prototype, "add", null);
|
|
64
64
|
__decorate([
|
|
65
65
|
operation,
|
package/Deletion.js
CHANGED
package/DragAndDrop.js
CHANGED
package/Editing.js
CHANGED
|
@@ -4,7 +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 { host
|
|
7
|
+
import { host } from 'aspiration';
|
|
8
8
|
import { data, operation } from 'skandha';
|
|
9
9
|
export class Editing {
|
|
10
10
|
constructor() {
|
|
@@ -19,7 +19,7 @@ export class Editing {
|
|
|
19
19
|
return (cbs) => {
|
|
20
20
|
cbs.saveItem();
|
|
21
21
|
this.isEditing = false;
|
|
22
|
-
|
|
22
|
+
cbs.refreshView && cbs.refreshView();
|
|
23
23
|
};
|
|
24
24
|
}
|
|
25
25
|
cancel() {
|
|
@@ -44,7 +44,7 @@ __decorate([
|
|
|
44
44
|
], Editing.prototype, "isEditing", void 0);
|
|
45
45
|
__decorate([
|
|
46
46
|
operation,
|
|
47
|
-
host
|
|
47
|
+
host(['values'])
|
|
48
48
|
], Editing.prototype, "save", null);
|
|
49
49
|
__decorate([
|
|
50
50
|
operation,
|
package/Filtering.d.ts
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import { GetterT } from 'skandha';
|
|
2
1
|
import { FilteringCbs, FilterT } from './FilteringCbs';
|
|
3
2
|
export type { FilteringCbs } from './FilteringCbs';
|
|
4
3
|
export declare class Filtering<ValueT = any> {
|
|
5
4
|
static className: () => string;
|
|
6
5
|
isEnabled: boolean;
|
|
7
6
|
filter: FilterT;
|
|
8
|
-
inputItems
|
|
9
|
-
get filteredItems(): any[]
|
|
7
|
+
inputItems: Array<ValueT>;
|
|
8
|
+
get filteredItems(): any[];
|
|
10
9
|
apply(filter: FilterT): (cbs: FilteringCbs['apply']) => void;
|
|
11
10
|
setEnabled(flag: boolean): (cbs: FilteringCbs['setEnabled']) => void;
|
|
12
11
|
}
|
|
13
|
-
export declare const filteringUsesInputItems: (getItems: GetterT, transform?: Function) => (ctr: any) => void;
|
package/Filtering.js
CHANGED
|
@@ -4,8 +4,8 @@ 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 { host } from 'aspiration';
|
|
8
|
-
import { data,
|
|
7
|
+
import { host, stub } from 'aspiration';
|
|
8
|
+
import { data, operation } from 'skandha';
|
|
9
9
|
export class Filtering {
|
|
10
10
|
constructor() {
|
|
11
11
|
Object.defineProperty(this, "isEnabled", {
|
|
@@ -24,7 +24,7 @@ export class Filtering {
|
|
|
24
24
|
enumerable: true,
|
|
25
25
|
configurable: true,
|
|
26
26
|
writable: true,
|
|
27
|
-
value:
|
|
27
|
+
value: stub()
|
|
28
28
|
});
|
|
29
29
|
}
|
|
30
30
|
get filteredItems() {
|
|
@@ -62,10 +62,9 @@ __decorate([
|
|
|
62
62
|
], Filtering.prototype, "filteredItems", null);
|
|
63
63
|
__decorate([
|
|
64
64
|
operation,
|
|
65
|
-
host
|
|
65
|
+
host(['filter'])
|
|
66
66
|
], Filtering.prototype, "apply", null);
|
|
67
67
|
__decorate([
|
|
68
68
|
operation,
|
|
69
|
-
host
|
|
69
|
+
host(['flag'])
|
|
70
70
|
], Filtering.prototype, "setEnabled", null);
|
|
71
|
-
export const filteringUsesInputItems = (getItems, transform) => mapDataToFacet([Filtering, 'inputItems'], getItems, transform);
|
package/Highlight.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { GetterT } from 'skandha';
|
|
2
1
|
import { HighlightCbs } from './HighlightCbs';
|
|
3
2
|
export type { HighlightCbs } from './HighlightCbs';
|
|
4
3
|
export declare class Highlight<ValueT = any> {
|
|
@@ -7,4 +6,3 @@ export declare class Highlight<ValueT = any> {
|
|
|
7
6
|
item?: ValueT;
|
|
8
7
|
highlightItem(id: string): (cbs: HighlightCbs['highlightItem']) => void;
|
|
9
8
|
}
|
|
10
|
-
export declare const highlightUsesItemLookUpTable: (getItemById: GetterT) => (ctr: any) => void;
|
package/Highlight.js
CHANGED
|
@@ -4,8 +4,8 @@ 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 { host
|
|
8
|
-
import { data,
|
|
7
|
+
import { host } from 'aspiration';
|
|
8
|
+
import { data, operation, output } from 'skandha';
|
|
9
9
|
export class Highlight {
|
|
10
10
|
constructor() {
|
|
11
11
|
Object.defineProperty(this, "id", {
|
|
@@ -24,7 +24,7 @@ export class Highlight {
|
|
|
24
24
|
highlightItem(id) {
|
|
25
25
|
return (cbs) => {
|
|
26
26
|
this.id = id;
|
|
27
|
-
|
|
27
|
+
cbs.scrollItemIntoView && cbs.scrollItemIntoView();
|
|
28
28
|
};
|
|
29
29
|
}
|
|
30
30
|
}
|
|
@@ -42,12 +42,5 @@ __decorate([
|
|
|
42
42
|
], Highlight.prototype, "item", void 0);
|
|
43
43
|
__decorate([
|
|
44
44
|
operation,
|
|
45
|
-
host
|
|
45
|
+
host(['id'])
|
|
46
46
|
], Highlight.prototype, "highlightItem", null);
|
|
47
|
-
export const highlightUsesItemLookUpTable = (getItemById) => mapDatasToFacet([Highlight, 'item'], [
|
|
48
|
-
//
|
|
49
|
-
getItemById,
|
|
50
|
-
getm([Highlight, 'id']),
|
|
51
|
-
], (itemById, id) => {
|
|
52
|
-
return itemById[id];
|
|
53
|
-
});
|
package/Insertion.d.ts
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import { GetterT } from 'skandha';
|
|
2
1
|
import { DragT, InsertionCbs } from './InsertionCbs';
|
|
3
2
|
export type { DragT, DropPositionT, InsertionCbs } from './InsertionCbs';
|
|
4
3
|
export declare type DragSourceT = (ctr: any) => DragT | undefined;
|
|
5
4
|
export declare class Insertion<ValueT = any> {
|
|
6
5
|
static className: () => string;
|
|
7
|
-
inputItems
|
|
8
|
-
preview
|
|
6
|
+
inputItems: Array<ValueT>;
|
|
7
|
+
preview: Array<ValueT>;
|
|
9
8
|
insertItems(drag: DragT): (cbs: InsertionCbs['insertItems']) => void;
|
|
10
9
|
}
|
|
11
|
-
export declare const insertionUsesInputItems: (getItems: GetterT, transform?: Function) => (ctr: any) => void;
|
package/Insertion.js
CHANGED
|
@@ -4,8 +4,8 @@ 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 { host } from 'aspiration';
|
|
8
|
-
import { input,
|
|
7
|
+
import { host, stub } from 'aspiration';
|
|
8
|
+
import { input, operation, output } from 'skandha';
|
|
9
9
|
import { getPreview } from './lib/getPreview';
|
|
10
10
|
export class Insertion {
|
|
11
11
|
constructor() {
|
|
@@ -13,13 +13,13 @@ export class Insertion {
|
|
|
13
13
|
enumerable: true,
|
|
14
14
|
configurable: true,
|
|
15
15
|
writable: true,
|
|
16
|
-
value:
|
|
16
|
+
value: stub()
|
|
17
17
|
});
|
|
18
18
|
Object.defineProperty(this, "preview", {
|
|
19
19
|
enumerable: true,
|
|
20
20
|
configurable: true,
|
|
21
21
|
writable: true,
|
|
22
|
-
value:
|
|
22
|
+
value: stub()
|
|
23
23
|
});
|
|
24
24
|
}
|
|
25
25
|
insertItems(drag) {
|
|
@@ -45,6 +45,5 @@ __decorate([
|
|
|
45
45
|
], Insertion.prototype, "preview", void 0);
|
|
46
46
|
__decorate([
|
|
47
47
|
operation,
|
|
48
|
-
host
|
|
48
|
+
host(['drag'])
|
|
49
49
|
], Insertion.prototype, "insertItems", null);
|
|
50
|
-
export const insertionUsesInputItems = (getItems, transform) => mapDataToFacet([Insertion, 'inputItems'], getItems, transform);
|
package/Labelling.d.ts
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import { GetterT } from 'skandha';
|
|
2
1
|
import { IdsByLabelT, ItemsByLabelT, LabellingCbs, LabelValueT } from './LabellingCbs';
|
|
3
2
|
export type { LabellingCbs } from './LabellingCbs';
|
|
4
3
|
export declare class Labelling {
|
|
5
4
|
static className: () => string;
|
|
6
5
|
idsByLabel: IdsByLabelT;
|
|
7
6
|
ids: (label: string) => any[];
|
|
8
|
-
itemsByLabel
|
|
7
|
+
itemsByLabel: ItemsByLabelT;
|
|
9
8
|
setLabel(labelValue: LabelValueT): (cbs: LabellingCbs['setLabel']) => void;
|
|
10
9
|
}
|
|
11
|
-
export declare const labellingActsOnItems: (getItemById: GetterT) => (ctr: any) => void;
|
package/Labelling.js
CHANGED
|
@@ -4,9 +4,8 @@ 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 { host } from 'aspiration';
|
|
8
|
-
import { data,
|
|
9
|
-
import { lookUp } from './internal/utils';
|
|
7
|
+
import { host, stub } from 'aspiration';
|
|
8
|
+
import { data, input, operation } from 'skandha';
|
|
10
9
|
export class Labelling {
|
|
11
10
|
constructor() {
|
|
12
11
|
Object.defineProperty(this, "idsByLabel", {
|
|
@@ -25,7 +24,7 @@ export class Labelling {
|
|
|
25
24
|
enumerable: true,
|
|
26
25
|
configurable: true,
|
|
27
26
|
writable: true,
|
|
28
|
-
value:
|
|
27
|
+
value: stub()
|
|
29
28
|
});
|
|
30
29
|
}
|
|
31
30
|
setLabel(labelValue) {
|
|
@@ -57,12 +56,5 @@ __decorate([
|
|
|
57
56
|
], Labelling.prototype, "itemsByLabel", void 0);
|
|
58
57
|
__decorate([
|
|
59
58
|
operation,
|
|
60
|
-
host
|
|
59
|
+
host(['labelValue'])
|
|
61
60
|
], Labelling.prototype, "setLabel", null);
|
|
62
|
-
export const labellingActsOnItems = (getItemById) => {
|
|
63
|
-
return mapDatasToFacet([Labelling, 'itemsByLabel'], [
|
|
64
|
-
//
|
|
65
|
-
getItemById,
|
|
66
|
-
getm([Labelling, 'idsByLabel']),
|
|
67
|
-
], (itemById, idsByLabel) => Object.fromEntries(Object.entries(idsByLabel).map(([label, ids]) => lookUp(ids, itemById))));
|
|
68
|
-
};
|
package/Selection.d.ts
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
import { GetterT } from 'skandha';
|
|
2
1
|
import { SelectionCbs, SelectionParamsT } from './SelectionCbs';
|
|
3
2
|
export type { SelectionCbs, SelectionParamsT } from './SelectionCbs';
|
|
4
3
|
export declare class Selection<ValueT = any> {
|
|
5
4
|
static className: () => string;
|
|
6
|
-
selectableIds
|
|
5
|
+
selectableIds: Array<string>;
|
|
7
6
|
ids: Array<string>;
|
|
8
7
|
anchorId?: string;
|
|
9
|
-
items
|
|
8
|
+
items: Array<ValueT>;
|
|
10
9
|
selectItem(selectionParams: SelectionParamsT): (cbs: SelectionCbs['selectItem']) => void;
|
|
11
10
|
}
|
|
12
11
|
export declare function handleSelectItem(facet: Selection, { itemId, isShift, isCtrl }: SelectionParamsT): void;
|
|
13
|
-
export declare const selectionUsesItemLookUpTable: (getItemById: GetterT) => (ctr: any) => void;
|
|
14
|
-
export declare const selectionUsesSelectableIds: (getIds: GetterT, transform?: ((x: any) => string[]) | undefined) => (ctr: any) => void;
|
package/Selection.js
CHANGED
|
@@ -4,9 +4,9 @@ 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 { host } from 'aspiration';
|
|
8
|
-
import { data,
|
|
9
|
-
import {
|
|
7
|
+
import { host, stub } from 'aspiration';
|
|
8
|
+
import { data, input, operation, output } from 'skandha';
|
|
9
|
+
import { range } from './internal/utils';
|
|
10
10
|
const selectItemDefaultCbs = (selection) => ({
|
|
11
11
|
selectItem: function () {
|
|
12
12
|
handleSelectItem(selection, this.selectionParams);
|
|
@@ -18,7 +18,7 @@ export class Selection {
|
|
|
18
18
|
enumerable: true,
|
|
19
19
|
configurable: true,
|
|
20
20
|
writable: true,
|
|
21
|
-
value:
|
|
21
|
+
value: stub()
|
|
22
22
|
});
|
|
23
23
|
Object.defineProperty(this, "ids", {
|
|
24
24
|
enumerable: true,
|
|
@@ -36,7 +36,7 @@ export class Selection {
|
|
|
36
36
|
enumerable: true,
|
|
37
37
|
configurable: true,
|
|
38
38
|
writable: true,
|
|
39
|
-
value:
|
|
39
|
+
value: stub()
|
|
40
40
|
});
|
|
41
41
|
}
|
|
42
42
|
selectItem(selectionParams) {
|
|
@@ -65,7 +65,7 @@ __decorate([
|
|
|
65
65
|
], Selection.prototype, "items", void 0);
|
|
66
66
|
__decorate([
|
|
67
67
|
operation,
|
|
68
|
-
host(selectItemDefaultCbs)
|
|
68
|
+
host(['selectionParams'], selectItemDefaultCbs)
|
|
69
69
|
], Selection.prototype, "selectItem", null);
|
|
70
70
|
export function handleSelectItem(facet, { itemId, isShift, isCtrl }) {
|
|
71
71
|
if (itemId === undefined) {
|
|
@@ -98,11 +98,3 @@ export function handleSelectItem(facet, { itemId, isShift, isCtrl }) {
|
|
|
98
98
|
facet.anchorId = itemId;
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
|
-
export const selectionUsesItemLookUpTable = (getItemById) => mapDatasToFacet([Selection, 'items'], [
|
|
102
|
-
//
|
|
103
|
-
getItemById,
|
|
104
|
-
getm([Selection, 'ids']),
|
|
105
|
-
], (itemById, ids) => {
|
|
106
|
-
return lookUp(ids, itemById);
|
|
107
|
-
});
|
|
108
|
-
export const selectionUsesSelectableIds = (getIds, transform) => mapDataToFacet([Selection, 'selectableIds'], getIds, transform);
|
package/index.d.ts
CHANGED
|
@@ -1,4 +1 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export { highlightUsesItemLookUpTable } from "./Highlight";
|
|
3
|
-
export { filteringUsesInputItems } from "./Filtering";
|
|
4
|
-
export { insertionUsesInputItems } from "./Insertion";
|
|
1
|
+
export {};
|
package/index.js
CHANGED
|
@@ -1,4 +1 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export { highlightUsesItemLookUpTable } from "./Highlight";
|
|
3
|
-
export { filteringUsesInputItems } from "./Filtering";
|
|
4
|
-
export { insertionUsesInputItems } from "./Insertion";
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "skandha-facets",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.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.9.0",
|
|
13
|
+
"aspiration": ">=0.3.1"
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
16
|
"typescript": "^4.0.3"
|
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
import { Filtering } from
|
|
1
|
+
import { Filtering } from '../Filtering';
|
|
2
|
+
import { Highlight } from '../Highlight';
|
|
2
3
|
export declare function highlightIsCorrectedOnFilterChange(facet: Filtering): void;
|
|
4
|
+
export declare function correctHighlight(highlight: Highlight, inputItemIds: any[], filteredItemIds: any[]): void;
|
|
@@ -1,5 +1,23 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Highlight } from
|
|
1
|
+
import { getc, getf } from 'skandha';
|
|
2
|
+
import { Highlight } from '../Highlight';
|
|
3
|
+
export function highlightIsCorrectedOnFilterChange(facet) {
|
|
4
|
+
var _a;
|
|
5
|
+
if (facet.isEnabled) {
|
|
6
|
+
correctHighlight(getf(Highlight, getc(facet)), (facet.inputItems || []).map((x) => x.id), ((_a = facet.filteredItems) !== null && _a !== void 0 ? _a : []).map((x) => x.id));
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
export function correctHighlight(highlight, inputItemIds, filteredItemIds) {
|
|
10
|
+
if (highlight.id &&
|
|
11
|
+
inputItemIds.includes(highlight.id) &&
|
|
12
|
+
!filteredItemIds.includes(highlight.id)) {
|
|
13
|
+
const highlightedItemIdx = inputItemIds.indexOf(highlight.id);
|
|
14
|
+
const newIdx = _findNeighbourIdx(filteredItemIds, inputItemIds, highlightedItemIdx, inputItemIds.length, 1) ||
|
|
15
|
+
_findNeighbourIdx(filteredItemIds, inputItemIds, highlightedItemIdx, -1, -1);
|
|
16
|
+
if (newIdx) {
|
|
17
|
+
highlight.highlightItem(inputItemIds[newIdx.result]);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
3
21
|
function _findNeighbourIdx(filteredItems, allItems, beginIndex, endIndex, step) {
|
|
4
22
|
for (var idx = beginIndex; idx !== endIndex; idx += step) {
|
|
5
23
|
if (filteredItems.includes(allItems[idx])) {
|
|
@@ -8,23 +26,3 @@ function _findNeighbourIdx(filteredItems, allItems, beginIndex, endIndex, step)
|
|
|
8
26
|
}
|
|
9
27
|
return undefined;
|
|
10
28
|
}
|
|
11
|
-
export function highlightIsCorrectedOnFilterChange(facet) {
|
|
12
|
-
var _a;
|
|
13
|
-
const ctr = getc(facet);
|
|
14
|
-
if (facet.isEnabled) {
|
|
15
|
-
const highlight = getf(Highlight, ctr).id;
|
|
16
|
-
const inputItems = facet.inputItems;
|
|
17
|
-
const filteredItemIds = ((_a = facet.filteredItems) !== null && _a !== void 0 ? _a : []).map((x) => x.id);
|
|
18
|
-
const inputIds = (inputItems || []).map((x) => x.id);
|
|
19
|
-
if (highlight &&
|
|
20
|
-
inputIds.includes(highlight) &&
|
|
21
|
-
!filteredItemIds.includes(highlight)) {
|
|
22
|
-
const highlightedItemIdx = inputIds.indexOf(highlight);
|
|
23
|
-
const newIdx = _findNeighbourIdx(filteredItemIds, inputIds, highlightedItemIdx, inputIds.length, 1) ||
|
|
24
|
-
_findNeighbourIdx(filteredItemIds, inputIds, highlightedItemIdx, -1, -1);
|
|
25
|
-
if (newIdx) {
|
|
26
|
-
getf(Highlight, ctr).highlightItem(inputIds[newIdx.result]);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { DragSourceT } from
|
|
2
|
-
export declare const insertionPreviewUsesDragSources: (dragSources: DragSourceT[]) => (
|
|
1
|
+
import { DragSourceT } from '../Insertion';
|
|
2
|
+
export declare const insertionPreviewUsesDragSources: (dragSources: DragSourceT[], ctr: any) => (inputItems: any[]) => any[];
|
|
@@ -1,13 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
import { mapDataToFacet, getf, getc } from "skandha";
|
|
5
|
-
export const insertionPreviewUsesDragSources = (dragSources) => mapDataToFacet([Insertion, "preview"], getf(Insertion), (insertion) => {
|
|
6
|
-
const ctr = getc(insertion);
|
|
1
|
+
import { findMap } from '../internal/utils';
|
|
2
|
+
import { getPreview } from '../lib/getPreview';
|
|
3
|
+
export const insertionPreviewUsesDragSources = (dragSources, ctr) => (inputItems) => {
|
|
7
4
|
const drag = findMap((dragSource) => dragSource(ctr), dragSources);
|
|
8
|
-
|
|
9
|
-
const preview = drag
|
|
5
|
+
return drag
|
|
10
6
|
? getPreview(inputItems !== null && inputItems !== void 0 ? inputItems : [], drag.targetItemId, drag.isBefore, drag.payload)
|
|
11
7
|
: inputItems !== null && inputItems !== void 0 ? inputItems : [];
|
|
12
|
-
|
|
13
|
-
});
|
|
8
|
+
};
|