skandha-facets 0.8.0 → 0.8.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/Filtering.d.ts +2 -2
- package/Filtering.js +2 -2
- package/Insertion.d.ts +2 -2
- package/Insertion.js +3 -3
- package/Labelling.d.ts +1 -1
- package/Labelling.js +2 -2
- package/Selection.d.ts +2 -2
- package/Selection.js +3 -3
- package/package.json +1 -1
- package/policies/highlightIsCorrectedOnFilterChange.d.ts +3 -1
- package/policies/highlightIsCorrectedOnFilterChange.js +20 -22
package/Filtering.d.ts
CHANGED
|
@@ -5,8 +5,8 @@ export declare class Filtering<ValueT = any> {
|
|
|
5
5
|
static className: () => string;
|
|
6
6
|
isEnabled: boolean;
|
|
7
7
|
filter: FilterT;
|
|
8
|
-
inputItems
|
|
9
|
-
get filteredItems(): any[]
|
|
8
|
+
inputItems: Array<ValueT>;
|
|
9
|
+
get filteredItems(): any[];
|
|
10
10
|
apply(filter: FilterT): (cbs: FilteringCbs['apply']) => void;
|
|
11
11
|
setEnabled(flag: boolean): (cbs: FilteringCbs['setEnabled']) => void;
|
|
12
12
|
}
|
package/Filtering.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 } from 'aspiration';
|
|
7
|
+
import { host, stub } from 'aspiration';
|
|
8
8
|
import { data, mapDataToFacet, operation } from 'skandha';
|
|
9
9
|
export class Filtering {
|
|
10
10
|
constructor() {
|
|
@@ -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() {
|
package/Insertion.d.ts
CHANGED
|
@@ -4,8 +4,8 @@ export type { DragT, DropPositionT, InsertionCbs } from './InsertionCbs';
|
|
|
4
4
|
export declare type DragSourceT = (ctr: any) => DragT | undefined;
|
|
5
5
|
export declare class Insertion<ValueT = any> {
|
|
6
6
|
static className: () => string;
|
|
7
|
-
inputItems
|
|
8
|
-
preview
|
|
7
|
+
inputItems: Array<ValueT>;
|
|
8
|
+
preview: Array<ValueT>;
|
|
9
9
|
insertItems(drag: DragT): (cbs: InsertionCbs['insertItems']) => void;
|
|
10
10
|
}
|
|
11
11
|
export declare const insertionUsesInputItems: (getItems: GetterT, transform?: Function) => (ctr: any) => void;
|
package/Insertion.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 } from 'aspiration';
|
|
7
|
+
import { host, stub } from 'aspiration';
|
|
8
8
|
import { input, mapDataToFacet, operation, output } from 'skandha';
|
|
9
9
|
import { getPreview } from './lib/getPreview';
|
|
10
10
|
export class Insertion {
|
|
@@ -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) {
|
package/Labelling.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export declare class Labelling {
|
|
|
5
5
|
static className: () => string;
|
|
6
6
|
idsByLabel: IdsByLabelT;
|
|
7
7
|
ids: (label: string) => any[];
|
|
8
|
-
itemsByLabel
|
|
8
|
+
itemsByLabel: ItemsByLabelT;
|
|
9
9
|
setLabel(labelValue: LabelValueT): (cbs: LabellingCbs['setLabel']) => void;
|
|
10
10
|
}
|
|
11
11
|
export declare const labellingActsOnItems: (getItemById: GetterT) => (ctr: any) => void;
|
package/Labelling.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 } from 'aspiration';
|
|
7
|
+
import { host, stub } from 'aspiration';
|
|
8
8
|
import { data, getm, input, mapDatasToFacet, operation, } from 'skandha';
|
|
9
9
|
import { lookUp } from './internal/utils';
|
|
10
10
|
export class Labelling {
|
|
@@ -25,7 +25,7 @@ export class Labelling {
|
|
|
25
25
|
enumerable: true,
|
|
26
26
|
configurable: true,
|
|
27
27
|
writable: true,
|
|
28
|
-
value:
|
|
28
|
+
value: stub()
|
|
29
29
|
});
|
|
30
30
|
}
|
|
31
31
|
setLabel(labelValue) {
|
package/Selection.d.ts
CHANGED
|
@@ -3,10 +3,10 @@ import { SelectionCbs, SelectionParamsT } from './SelectionCbs';
|
|
|
3
3
|
export type { SelectionCbs, SelectionParamsT } from './SelectionCbs';
|
|
4
4
|
export declare class Selection<ValueT = any> {
|
|
5
5
|
static className: () => string;
|
|
6
|
-
selectableIds
|
|
6
|
+
selectableIds: Array<string>;
|
|
7
7
|
ids: Array<string>;
|
|
8
8
|
anchorId?: string;
|
|
9
|
-
items
|
|
9
|
+
items: Array<ValueT>;
|
|
10
10
|
selectItem(selectionParams: SelectionParamsT): (cbs: SelectionCbs['selectItem']) => void;
|
|
11
11
|
}
|
|
12
12
|
export declare function handleSelectItem(facet: Selection, { itemId, isShift, isCtrl }: SelectionParamsT): void;
|
package/Selection.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 } from 'aspiration';
|
|
7
|
+
import { host, stub } from 'aspiration';
|
|
8
8
|
import { data, getm, input, mapDatasToFacet, mapDataToFacet, operation, output, } from 'skandha';
|
|
9
9
|
import { lookUp, range } from './internal/utils';
|
|
10
10
|
const selectItemDefaultCbs = (selection) => ({
|
|
@@ -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) {
|
package/package.json
CHANGED
|
@@ -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
|
-
}
|