skandha-facets 0.9.0 → 0.10.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.d.ts CHANGED
@@ -1,11 +1,11 @@
1
- import { AdditionCbs, GenericObjectT } from './AdditionCbs';
1
+ import { GenericObjectT } from './AdditionCbs';
2
2
  export type { AdditionCbs } from './AdditionCbs';
3
3
  export declare class Addition<ValueT = any> {
4
4
  static className: () => string;
5
5
  item?: ValueT;
6
6
  parentId?: string;
7
- add(values: GenericObjectT): (cbs: AdditionCbs<ValueT>['add']) => void;
8
- confirm(): (cbs: AdditionCbs<ValueT>['confirm']) => void;
9
- cancel(): (cbs: AdditionCbs<ValueT>['cancel']) => void;
7
+ add(values: GenericObjectT): Promise<void>;
8
+ confirm(): Promise<void>;
9
+ cancel(): Promise<void>;
10
10
  _reset(): void;
11
11
  }
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 } from 'aspiration';
7
+ import { getCallbacks, host } from 'aspiration';
8
8
  import { data, operation } from 'skandha';
9
9
  export class Addition {
10
10
  constructor() {
@@ -22,23 +22,24 @@ export class Addition {
22
22
  });
23
23
  }
24
24
  add(values) {
25
- return (cbs) => {
26
- cbs.storeLocation && cbs.storeLocation();
27
- this.item = cbs.createItem();
25
+ const cbs = getCallbacks(this);
26
+ cbs.storeLocation && cbs.storeLocation();
27
+ return Promise.resolve(cbs.createItem()).then((item) => {
28
+ this.item = item;
28
29
  cbs.highlightNewItem && cbs.highlightNewItem();
29
- };
30
+ });
30
31
  }
31
32
  confirm() {
32
- return (cbs) => {
33
- cbs.confirm();
33
+ const cbs = getCallbacks(this);
34
+ return Promise.resolve(cbs.confirm()).then(() => {
34
35
  this._reset();
35
- };
36
+ });
36
37
  }
37
38
  cancel() {
38
- return (cbs) => {
39
- this._reset();
39
+ const cbs = getCallbacks(this);
40
+ return Promise.resolve(this._reset()).then(() => {
40
41
  cbs.restoreLocation && cbs.restoreLocation();
41
- };
42
+ });
42
43
  }
43
44
  _reset() {
44
45
  this.item = undefined;
package/AdditionCbs.d.ts CHANGED
@@ -1,19 +1,19 @@
1
- import { Cbs } from "aspiration";
1
+ import { Cbs } from 'aspiration';
2
2
  export declare type GenericObjectT = any;
3
- export declare class Addition_add<ValueT = any> extends Cbs {
3
+ export interface Addition_add<ValueT> extends Cbs {
4
4
  values: GenericObjectT;
5
5
  storeLocation(): void;
6
6
  createItem(): ValueT;
7
7
  highlightNewItem(): void;
8
8
  }
9
- export declare class Addition_confirm extends Cbs {
9
+ export interface Addition_confirm extends Cbs {
10
10
  confirm(): void;
11
11
  }
12
- export declare class Addition_cancel extends Cbs {
12
+ export interface Addition_cancel extends Cbs {
13
13
  restoreLocation(): void;
14
14
  }
15
- export declare type AdditionCbs<ValueT = any> = {
15
+ export interface AdditionCbs<ValueT = any> {
16
16
  add: Addition_add<ValueT>;
17
17
  confirm: Addition_confirm;
18
18
  cancel: Addition_cancel;
19
- };
19
+ }
package/AdditionCbs.js CHANGED
@@ -1,23 +1 @@
1
- import { stub, Cbs } from "aspiration";
2
- export class Addition_add extends Cbs {
3
- constructor() {
4
- super(...arguments);
5
- Object.defineProperty(this, "values", {
6
- enumerable: true,
7
- configurable: true,
8
- writable: true,
9
- value: void 0
10
- });
11
- }
12
- storeLocation() { }
13
- createItem() {
14
- return stub();
15
- }
16
- highlightNewItem() { }
17
- }
18
- export class Addition_confirm extends Cbs {
19
- confirm() { }
20
- }
21
- export class Addition_cancel extends Cbs {
22
- restoreLocation() { }
23
- }
1
+ export {};
package/Deletion.d.ts CHANGED
@@ -1,6 +1,5 @@
1
- import { DeletionCbs } from './DeletionCbs';
2
1
  export type { DeletionCbs } from './DeletionCbs';
3
2
  export declare class Deletion {
4
3
  static className: () => string;
5
- delete(itemIds: string[]): (cbs: DeletionCbs['delete']) => any;
4
+ delete(itemIds: string[]): Promise<any>;
6
5
  }
package/Deletion.js CHANGED
@@ -4,13 +4,12 @@ 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 { getCallbacks, host } from 'aspiration';
8
8
  import { operation } from 'skandha';
9
9
  export class Deletion {
10
10
  delete(itemIds) {
11
- return (cbs) => {
12
- return cbs.deleteItems();
13
- };
11
+ const cbs = getCallbacks(this);
12
+ return Promise.resolve(cbs.deleteItems());
14
13
  }
15
14
  }
16
15
  Object.defineProperty(Deletion, "className", {
package/DeletionCbs.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Cbs } from 'aspiration';
2
- export declare class Deletion_delete extends Cbs {
2
+ export interface Deletion_delete extends Cbs {
3
3
  itemIds: string[];
4
- deleteItems(): any;
4
+ deleteItems(): Promise<any>;
5
5
  }
6
6
  export declare type DeletionCbs = {
7
7
  delete: Deletion_delete;
package/DeletionCbs.js CHANGED
@@ -1,13 +1 @@
1
- import { Cbs, stub } from 'aspiration';
2
- export class Deletion_delete extends Cbs {
3
- constructor() {
4
- super(...arguments);
5
- Object.defineProperty(this, "itemIds", {
6
- enumerable: true,
7
- configurable: true,
8
- writable: true,
9
- value: stub()
10
- });
11
- }
12
- deleteItems() { }
13
- }
1
+ export {};
package/DragAndDrop.d.ts CHANGED
@@ -1,10 +1,9 @@
1
- import { DragAndDropCbs } from './DragAndDropCbs';
2
1
  import { DropPositionT } from './Insertion';
3
2
  export type { DragAndDropCbs } from './DragAndDropCbs';
4
3
  export declare class DragAndDrop {
5
4
  static className: () => string;
6
5
  hoverPosition?: DropPositionT;
7
- drop(dropPosition: DropPositionT): (cbs: DragAndDropCbs['drop']) => void;
6
+ drop(dropPosition: DropPositionT): Promise<void>;
8
7
  setHoverPosition(x?: DropPositionT): void;
9
8
  handle(itemId: string): {
10
9
  draggable: boolean;
@@ -14,3 +13,18 @@ export declare class DragAndDrop {
14
13
  onDrop: () => void;
15
14
  };
16
15
  }
16
+ export declare type DragHandlersT = {
17
+ draggable?: boolean;
18
+ onDragStart?: (event: any) => void;
19
+ onDragOver?: (event: any) => void;
20
+ onDragEnd?: (event: any) => void;
21
+ onDrop?: (event: any) => void;
22
+ };
23
+ export declare function dragState(hoverPosition: any, itemId: string): "before" | "after" | "none";
24
+ export declare function dragHandlers<T extends DragHandlersT>(props: T): {
25
+ draggable: boolean | undefined;
26
+ onDragStart: ((event: any) => void) | undefined;
27
+ onDragOver: ((event: any) => void) | undefined;
28
+ onDrop: ((event: any) => void) | undefined;
29
+ onDragEnd: ((event: any) => void) | undefined;
30
+ };
package/DragAndDrop.js CHANGED
@@ -4,9 +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 { host } from 'aspiration';
7
+ import { getCallbacks, host } from 'aspiration';
8
8
  import { data, operation } from 'skandha';
9
9
  import { isBefore } from './internal/utils';
10
+ import { selectionIsInsertedOnDragAndDrop } from './policies/selectionIsInsertedOnDragAndDrop';
11
+ const dropDefaultCbs = (dragAndDrop) => ({
12
+ drop: function () {
13
+ selectionIsInsertedOnDragAndDrop(dragAndDrop, this.dropPosition);
14
+ },
15
+ });
10
16
  export class DragAndDrop {
11
17
  constructor() {
12
18
  Object.defineProperty(this, "hoverPosition", {
@@ -17,9 +23,8 @@ export class DragAndDrop {
17
23
  });
18
24
  }
19
25
  drop(dropPosition) {
20
- return (cbs) => {
21
- cbs.drop();
22
- };
26
+ const cbs = getCallbacks(this);
27
+ return Promise.resolve(cbs.drop());
23
28
  }
24
29
  setHoverPosition(x) {
25
30
  this.hoverPosition = x;
@@ -40,8 +45,9 @@ export class DragAndDrop {
40
45
  },
41
46
  onDrop: () => {
42
47
  if (this.hoverPosition) {
43
- this.drop(this.hoverPosition);
44
- this.setHoverPosition(undefined);
48
+ this.drop(this.hoverPosition).then(() => {
49
+ this.setHoverPosition(undefined);
50
+ });
45
51
  }
46
52
  },
47
53
  };
@@ -58,8 +64,24 @@ __decorate([
58
64
  ], DragAndDrop.prototype, "hoverPosition", void 0);
59
65
  __decorate([
60
66
  operation,
61
- host(['dropPosition'])
67
+ host(['dropPosition'], dropDefaultCbs)
62
68
  ], DragAndDrop.prototype, "drop", null);
63
69
  __decorate([
64
70
  operation({ log: false })
65
71
  ], DragAndDrop.prototype, "setHoverPosition", null);
72
+ export function dragState(hoverPosition, itemId) {
73
+ return (hoverPosition === null || hoverPosition === void 0 ? void 0 : hoverPosition.targetItemId) === itemId
74
+ ? (hoverPosition === null || hoverPosition === void 0 ? void 0 : hoverPosition.isBefore)
75
+ ? 'before'
76
+ : 'after'
77
+ : 'none';
78
+ }
79
+ export function dragHandlers(props) {
80
+ return {
81
+ draggable: props.draggable,
82
+ onDragStart: props.onDragStart,
83
+ onDragOver: props.onDragOver,
84
+ onDrop: props.onDrop,
85
+ onDragEnd: props.onDragEnd,
86
+ };
87
+ }
@@ -1,9 +1,9 @@
1
- import { Cbs } from "aspiration";
2
- import { DropPositionT } from "./Insertion";
3
- export declare class DragAndDrop_drop extends Cbs {
1
+ import { Cbs } from 'aspiration';
2
+ import { DropPositionT } from './Insertion';
3
+ export interface DragAndDrop_drop extends Cbs {
4
4
  dropPosition: DropPositionT;
5
5
  drop(): void;
6
6
  }
7
- export declare type DragAndDropCbs = {
7
+ export interface DragAndDropCbs {
8
8
  drop: DragAndDrop_drop;
9
- };
9
+ }
package/DragAndDropCbs.js CHANGED
@@ -1,13 +1 @@
1
- import { stub, Cbs } from "aspiration";
2
- export class DragAndDrop_drop extends Cbs {
3
- constructor() {
4
- super(...arguments);
5
- Object.defineProperty(this, "dropPosition", {
6
- enumerable: true,
7
- configurable: true,
8
- writable: true,
9
- value: stub()
10
- });
11
- }
12
- drop() { }
13
- }
1
+ export {};
package/Editing.d.ts CHANGED
@@ -1,9 +1,8 @@
1
- import { EditingCbs } from './EditingCbs';
2
1
  export type { EditingCbs } from './EditingCbs';
3
2
  export declare class Editing {
4
3
  static className: () => string;
5
4
  isEditing: boolean;
6
- save(values: any): (cbs: EditingCbs['save']) => void;
7
- cancel(): (cbs: EditingCbs['cancel']) => void;
8
- enable(): (cbs: EditingCbs['enable']) => void;
5
+ save(values: any): Promise<void>;
6
+ cancel(): void;
7
+ enable(): void;
9
8
  }
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 } from 'aspiration';
7
+ import { getCallbacks, host } from 'aspiration';
8
8
  import { data, operation } from 'skandha';
9
9
  export class Editing {
10
10
  constructor() {
@@ -16,21 +16,17 @@ export class Editing {
16
16
  });
17
17
  }
18
18
  save(values) {
19
- return (cbs) => {
20
- cbs.saveItem();
19
+ const cbs = getCallbacks(this);
20
+ return Promise.resolve(cbs.saveItem()).then(() => {
21
21
  this.isEditing = false;
22
22
  cbs.refreshView && cbs.refreshView();
23
- };
23
+ });
24
24
  }
25
25
  cancel() {
26
- return (cbs) => {
27
- this.isEditing = false;
28
- };
26
+ this.isEditing = false;
29
27
  }
30
28
  enable() {
31
- return (cbs) => {
32
- this.isEditing = true;
33
- };
29
+ this.isEditing = true;
34
30
  }
35
31
  }
36
32
  Object.defineProperty(Editing, "className", {
package/EditingCbs.d.ts CHANGED
@@ -1,15 +1,15 @@
1
- import { Cbs } from "aspiration";
2
- export declare class Editing_save extends Cbs {
1
+ import type { Cbs } from 'aspiration';
2
+ export interface Editing_save extends Cbs {
3
3
  values: any;
4
- saveItem(): void;
4
+ saveItem(): Promise<any>;
5
5
  refreshView(): void;
6
6
  }
7
- export declare class Editing_cancel extends Cbs {
7
+ export interface Editing_cancel extends Cbs {
8
8
  }
9
- export declare class Editing_enable extends Cbs {
9
+ export interface Editing_enable extends Cbs {
10
10
  }
11
- export declare type EditingCbs = {
11
+ export interface EditingCbs {
12
12
  save: Editing_save;
13
13
  cancel: Editing_cancel;
14
14
  enable: Editing_enable;
15
- };
15
+ }
package/EditingCbs.js CHANGED
@@ -1,18 +1 @@
1
- import { Cbs } from "aspiration";
2
- export class Editing_save extends Cbs {
3
- constructor() {
4
- super(...arguments);
5
- Object.defineProperty(this, "values", {
6
- enumerable: true,
7
- configurable: true,
8
- writable: true,
9
- value: void 0
10
- });
11
- }
12
- saveItem() { }
13
- refreshView() { }
14
- }
15
- export class Editing_cancel extends Cbs {
16
- }
17
- export class Editing_enable extends Cbs {
18
- }
1
+ export {};
package/Filtering.d.ts CHANGED
@@ -1,11 +1,11 @@
1
- import { FilteringCbs, FilterT } from './FilteringCbs';
1
+ import { FilterT } from './FilteringCbs';
2
2
  export type { FilteringCbs } from './FilteringCbs';
3
3
  export declare class Filtering<ValueT = any> {
4
4
  static className: () => string;
5
5
  isEnabled: boolean;
6
- filter: FilterT;
6
+ filter: FilterT<ValueT>;
7
7
  inputItems: Array<ValueT>;
8
- get filteredItems(): any[];
9
- apply(filter: FilterT): (cbs: FilteringCbs['apply']) => void;
10
- setEnabled(flag: boolean): (cbs: FilteringCbs['setEnabled']) => void;
8
+ get filteredItems(): ValueT[];
9
+ apply(filter: FilterT<ValueT>): void;
10
+ setEnabled(flag: boolean): void;
11
11
  }
package/Filtering.js CHANGED
@@ -24,22 +24,18 @@ export class Filtering {
24
24
  enumerable: true,
25
25
  configurable: true,
26
26
  writable: true,
27
- value: stub()
27
+ value: stub
28
28
  });
29
29
  }
30
30
  get filteredItems() {
31
31
  return this.isEnabled ? this.filter(this.inputItems) : this.inputItems;
32
32
  }
33
33
  apply(filter) {
34
- return (cbs) => {
35
- this.filter = filter;
36
- this.setEnabled(true);
37
- };
34
+ this.filter = filter;
35
+ this.setEnabled(true);
38
36
  }
39
37
  setEnabled(flag) {
40
- return (cbs) => {
41
- this.isEnabled = flag;
42
- };
38
+ this.isEnabled = flag;
43
39
  }
44
40
  }
45
41
  Object.defineProperty(Filtering, "className", {
package/FilteringCbs.d.ts CHANGED
@@ -1,12 +1,12 @@
1
- import { Cbs } from "aspiration";
2
- export declare type FilterT = (x: any) => Array<any>;
3
- export declare class Filtering_apply extends Cbs {
4
- filter: FilterT;
1
+ import { Cbs } from 'aspiration';
2
+ export declare type FilterT<ValueT> = (x: ValueT[]) => ValueT[];
3
+ export interface Filtering_apply<ValueT> extends Cbs {
4
+ filter: FilterT<ValueT>;
5
5
  }
6
- export declare class Filtering_setEnabled extends Cbs {
6
+ export interface Filtering_setEnabled<ValueT> extends Cbs {
7
7
  flag: boolean;
8
8
  }
9
- export declare type FilteringCbs = {
10
- apply: Filtering_apply;
11
- setEnabled: Filtering_setEnabled;
12
- };
9
+ export interface FilteringCbs<ValueT = any> {
10
+ apply: Filtering_apply<ValueT>;
11
+ setEnabled: Filtering_setEnabled<ValueT>;
12
+ }
package/FilteringCbs.js CHANGED
@@ -1,23 +1 @@
1
- import { stub, Cbs } from "aspiration";
2
- export class Filtering_apply extends Cbs {
3
- constructor() {
4
- super(...arguments);
5
- Object.defineProperty(this, "filter", {
6
- enumerable: true,
7
- configurable: true,
8
- writable: true,
9
- value: stub()
10
- });
11
- }
12
- }
13
- export class Filtering_setEnabled extends Cbs {
14
- constructor() {
15
- super(...arguments);
16
- Object.defineProperty(this, "flag", {
17
- enumerable: true,
18
- configurable: true,
19
- writable: true,
20
- value: stub()
21
- });
22
- }
23
- }
1
+ export {};
package/Highlight.d.ts CHANGED
@@ -1,8 +1,7 @@
1
- import { HighlightCbs } from './HighlightCbs';
2
1
  export type { HighlightCbs } from './HighlightCbs';
3
2
  export declare class Highlight<ValueT = any> {
4
3
  static className: () => string;
5
4
  id: string | undefined;
6
5
  item?: ValueT;
7
- highlightItem(id: string): (cbs: HighlightCbs['highlightItem']) => void;
6
+ highlightItem(id: string | undefined): void;
8
7
  }
package/Highlight.js CHANGED
@@ -4,8 +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';
7
+ import { getCallbacks, host } from 'aspiration';
8
8
  import { data, operation, output } from 'skandha';
9
+ const highlightItemDefaultCbs = (highlight) => ({});
9
10
  export class Highlight {
10
11
  constructor() {
11
12
  Object.defineProperty(this, "id", {
@@ -22,10 +23,9 @@ export class Highlight {
22
23
  });
23
24
  }
24
25
  highlightItem(id) {
25
- return (cbs) => {
26
- this.id = id;
27
- cbs.scrollItemIntoView && cbs.scrollItemIntoView();
28
- };
26
+ const cbs = getCallbacks(this);
27
+ this.id = id;
28
+ cbs.scrollItemIntoView && cbs.scrollItemIntoView();
29
29
  }
30
30
  }
31
31
  Object.defineProperty(Highlight, "className", {
@@ -42,5 +42,5 @@ __decorate([
42
42
  ], Highlight.prototype, "item", void 0);
43
43
  __decorate([
44
44
  operation,
45
- host(['id'])
45
+ host(['id'], highlightItemDefaultCbs)
46
46
  ], Highlight.prototype, "highlightItem", null);
package/HighlightCbs.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { Cbs } from "aspiration";
2
- export declare class Highlight_highlightItem extends Cbs {
1
+ import { Cbs } from 'aspiration';
2
+ export interface Highlight_highlightItem extends Cbs {
3
3
  id: string;
4
4
  scrollItemIntoView(): void;
5
5
  }
6
- export declare type HighlightCbs = {
6
+ export interface HighlightCbs {
7
7
  highlightItem: Highlight_highlightItem;
8
- };
8
+ }
package/HighlightCbs.js CHANGED
@@ -1,13 +1 @@
1
- import { Cbs, stub } from "aspiration";
2
- export class Highlight_highlightItem extends Cbs {
3
- constructor() {
4
- super(...arguments);
5
- Object.defineProperty(this, "id", {
6
- enumerable: true,
7
- configurable: true,
8
- writable: true,
9
- value: stub()
10
- });
11
- }
12
- scrollItemIntoView() { }
13
- }
1
+ export {};
package/Insertion.d.ts CHANGED
@@ -1,9 +1,9 @@
1
- import { DragT, InsertionCbs } from './InsertionCbs';
1
+ import { DragT } from './InsertionCbs';
2
2
  export type { DragT, DropPositionT, InsertionCbs } from './InsertionCbs';
3
3
  export declare type DragSourceT = (ctr: any) => DragT | undefined;
4
4
  export declare class Insertion<ValueT = any> {
5
5
  static className: () => string;
6
6
  inputItems: Array<ValueT>;
7
7
  preview: Array<ValueT>;
8
- insertItems(drag: DragT): (cbs: InsertionCbs['insertItems']) => void;
8
+ insertItems(drag: DragT): Promise<any>;
9
9
  }
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, stub } from 'aspiration';
7
+ import { getCallbacks, host, stub } from 'aspiration';
8
8
  import { input, operation, output } from 'skandha';
9
9
  import { getPreview } from './lib/getPreview';
10
10
  export class Insertion {
@@ -13,22 +13,22 @@ export class Insertion {
13
13
  enumerable: true,
14
14
  configurable: true,
15
15
  writable: true,
16
- value: stub()
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: stub()
22
+ value: stub
23
23
  });
24
24
  }
25
25
  insertItems(drag) {
26
- return (cbs) => {
27
- if (this.inputItems) {
28
- const preview = getPreview(this.inputItems, drag.targetItemId, drag.isBefore, drag.payload);
29
- cbs.insertItems(preview);
30
- }
31
- };
26
+ const cbs = getCallbacks(this);
27
+ if (this.inputItems) {
28
+ const preview = getPreview(this.inputItems, drag.targetItemId, drag.isBefore, drag.payload);
29
+ return Promise.resolve(cbs.insertItems(preview));
30
+ }
31
+ return Promise.resolve();
32
32
  }
33
33
  }
34
34
  Object.defineProperty(Insertion, "className", {
package/InsertionCbs.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Cbs } from "aspiration";
1
+ import { Cbs } from 'aspiration';
2
2
  export declare type DropPositionT = {
3
3
  isBefore: boolean;
4
4
  targetItemId: string;
@@ -6,10 +6,10 @@ export declare type DropPositionT = {
6
6
  export declare type DragT = DropPositionT & {
7
7
  payload: any;
8
8
  };
9
- export declare class Insertion_insertItems<ValueT = any> extends Cbs {
9
+ export interface Insertion_insertItems<ValueT> extends Cbs {
10
10
  drag: DragT;
11
- insertItems(preview: Array<ValueT>): void;
11
+ insertItems(preview: Array<ValueT>): Promise<any>;
12
+ }
13
+ export interface InsertionCbs<ValueT = any> {
14
+ insertItems: Insertion_insertItems<ValueT>;
12
15
  }
13
- export declare type InsertionCbs = {
14
- insertItems: Insertion_insertItems;
15
- };
package/InsertionCbs.js CHANGED
@@ -1,13 +1 @@
1
- import { Cbs, stub } from "aspiration";
2
- export class Insertion_insertItems extends Cbs {
3
- constructor() {
4
- super(...arguments);
5
- Object.defineProperty(this, "drag", {
6
- enumerable: true,
7
- configurable: true,
8
- writable: true,
9
- value: stub()
10
- });
11
- }
12
- insertItems(preview) { }
13
- }
1
+ export {};
package/Labelling.d.ts CHANGED
@@ -1,9 +1,9 @@
1
- import { IdsByLabelT, ItemsByLabelT, LabellingCbs, LabelValueT } from './LabellingCbs';
1
+ import { IdsByLabelT, ItemsByLabelT, LabelValueT } from './LabellingCbs';
2
2
  export type { LabellingCbs } from './LabellingCbs';
3
3
  export declare class Labelling {
4
4
  static className: () => string;
5
5
  idsByLabel: IdsByLabelT;
6
6
  ids: (label: string) => any[];
7
7
  itemsByLabel: ItemsByLabelT;
8
- setLabel(labelValue: LabelValueT): (cbs: LabellingCbs['setLabel']) => void;
8
+ setLabel(labelValue: LabelValueT): Promise<any>;
9
9
  }
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, stub } from 'aspiration';
7
+ import { getCallbacks, host, stub } from 'aspiration';
8
8
  import { data, input, operation } from 'skandha';
9
9
  export class Labelling {
10
10
  constructor() {
@@ -24,22 +24,22 @@ export class Labelling {
24
24
  enumerable: true,
25
25
  configurable: true,
26
26
  writable: true,
27
- value: stub()
27
+ value: stub
28
28
  });
29
29
  }
30
30
  setLabel(labelValue) {
31
- return (cbs) => {
32
- const { label, id, flag } = labelValue;
33
- this.idsByLabel[label] = this.idsByLabel[label] || [];
34
- if (flag && !this.idsByLabel[label].includes(id)) {
35
- this.idsByLabel[label].push(id);
36
- cbs.saveIds(label, this.idsByLabel[label]);
37
- }
38
- if (!flag && this.idsByLabel[label].includes(id)) {
39
- this.idsByLabel[label] = this.idsByLabel[label].filter((x) => x !== id);
40
- cbs.saveIds(label, this.idsByLabel[label]);
41
- }
42
- };
31
+ const cbs = getCallbacks(this);
32
+ const { label, id, flag } = labelValue;
33
+ this.idsByLabel[label] = this.idsByLabel[label] || [];
34
+ if (flag && !this.idsByLabel[label].includes(id)) {
35
+ this.idsByLabel[label].push(id);
36
+ return Promise.resolve(cbs.saveIds(label, this.idsByLabel[label]));
37
+ }
38
+ if (!flag && this.idsByLabel[label].includes(id)) {
39
+ this.idsByLabel[label] = this.idsByLabel[label].filter((x) => x !== id);
40
+ return Promise.resolve(cbs.saveIds(label, this.idsByLabel[label]));
41
+ }
42
+ return Promise.resolve();
43
43
  }
44
44
  }
45
45
  Object.defineProperty(Labelling, "className", {
package/LabellingCbs.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Cbs } from "aspiration";
1
+ import { Cbs } from 'aspiration';
2
2
  export declare type LabelValueT = {
3
3
  label: string;
4
4
  id: string;
@@ -10,10 +10,10 @@ export declare type IdsByLabelT = {
10
10
  export declare type ItemsByLabelT = {
11
11
  [label: string]: Array<any>;
12
12
  };
13
- export declare class Labelling_setLabel extends Cbs {
13
+ export interface Labelling_setLabel extends Cbs {
14
14
  labelValue: LabelValueT;
15
- saveIds(label: string, ids: string[]): void;
15
+ saveIds(label: string, ids: string[]): Promise<any>;
16
16
  }
17
- export declare type LabellingCbs = {
17
+ export interface LabellingCbs {
18
18
  setLabel: Labelling_setLabel;
19
- };
19
+ }
package/LabellingCbs.js CHANGED
@@ -1,13 +1 @@
1
- import { Cbs, stub } from "aspiration";
2
- export class Labelling_setLabel extends Cbs {
3
- constructor() {
4
- super(...arguments);
5
- Object.defineProperty(this, "labelValue", {
6
- enumerable: true,
7
- configurable: true,
8
- writable: true,
9
- value: stub()
10
- });
11
- }
12
- saveIds(label, ids) { }
13
- }
1
+ export {};
package/Selection.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { SelectionCbs, SelectionParamsT } from './SelectionCbs';
1
+ import { SelectionParamsT } from './SelectionCbs';
2
2
  export type { SelectionCbs, SelectionParamsT } from './SelectionCbs';
3
3
  export declare class Selection<ValueT = any> {
4
4
  static className: () => string;
@@ -6,6 +6,6 @@ export declare class Selection<ValueT = any> {
6
6
  ids: Array<string>;
7
7
  anchorId?: string;
8
8
  items: Array<ValueT>;
9
- selectItem(selectionParams: SelectionParamsT): (cbs: SelectionCbs['selectItem']) => void;
9
+ selectItem(selectionParams: SelectionParamsT): void;
10
10
  }
11
11
  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, stub } from 'aspiration';
7
+ import { getCallbacks, host, stub } from 'aspiration';
8
8
  import { data, input, operation, output } from 'skandha';
9
9
  import { 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: stub()
21
+ value: stub
22
22
  });
23
23
  Object.defineProperty(this, "ids", {
24
24
  enumerable: true,
@@ -36,13 +36,12 @@ export class Selection {
36
36
  enumerable: true,
37
37
  configurable: true,
38
38
  writable: true,
39
- value: stub()
39
+ value: stub
40
40
  });
41
41
  }
42
42
  selectItem(selectionParams) {
43
- return (cbs) => {
44
- cbs.selectItem();
45
- };
43
+ const cbs = getCallbacks(this);
44
+ cbs.selectItem();
46
45
  }
47
46
  }
48
47
  Object.defineProperty(Selection, "className", {
package/SelectionCbs.d.ts CHANGED
@@ -1,14 +1,14 @@
1
- import { Cbs } from "aspiration";
1
+ import { Cbs } from 'aspiration';
2
2
  export declare type SelectionParamsT = {
3
3
  itemId: string | undefined;
4
4
  isShift?: boolean;
5
5
  isCtrl?: boolean;
6
6
  context?: any;
7
7
  };
8
- export declare class Selection_selectItem extends Cbs {
8
+ export interface Selection_selectItem extends Cbs {
9
9
  selectionParams: SelectionParamsT;
10
10
  selectItem(): void;
11
11
  }
12
- export declare type SelectionCbs = {
12
+ export interface SelectionCbs {
13
13
  selectItem: Selection_selectItem;
14
- };
14
+ }
package/SelectionCbs.js CHANGED
@@ -1,13 +1 @@
1
- import { Cbs, stub } from "aspiration";
2
- export class Selection_selectItem extends Cbs {
3
- constructor() {
4
- super(...arguments);
5
- Object.defineProperty(this, "selectionParams", {
6
- enumerable: true,
7
- configurable: true,
8
- writable: true,
9
- value: stub()
10
- });
11
- }
12
- selectItem() { }
13
- }
1
+ export {};
@@ -11,3 +11,13 @@ export declare class ClickToSelectItems {
11
11
  onMouseUp: (e: any) => void;
12
12
  };
13
13
  }
14
+ export declare type ClickHandlersT = {
15
+ onClick?: any;
16
+ onMouseDown?: any;
17
+ onMouseUp?: any;
18
+ };
19
+ export declare function clickHandlers<T extends ClickHandlersT>(props: T): {
20
+ onClick: any;
21
+ onMouseDown: any;
22
+ onMouseUp: any;
23
+ };
@@ -44,3 +44,10 @@ export class ClickToSelectItems {
44
44
  };
45
45
  }
46
46
  }
47
+ export function clickHandlers(props) {
48
+ return {
49
+ onClick: props.onClick,
50
+ onMouseDown: props.onMouseDown,
51
+ onMouseUp: props.onMouseUp,
52
+ };
53
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "skandha-facets",
3
- "version": "0.9.0",
3
+ "version": "0.10.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.9.0",
13
- "aspiration": ">=0.3.1"
12
+ "skandha": ">=0.10.1",
13
+ "aspiration": ">=0.4.0"
14
14
  },
15
15
  "devDependencies": {
16
16
  "typescript": "^4.0.3"