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