skandha-facets 0.10.1 → 0.11.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.
Files changed (101) hide show
  1. package/facets/Addition.d.ts +28 -0
  2. package/{Addition.js → facets/Addition.js} +24 -13
  3. package/facets/Deletion.d.ts +16 -0
  4. package/{Deletion.js → facets/Deletion.js} +17 -5
  5. package/facets/Display.d.ts +7 -0
  6. package/facets/Display.js +36 -0
  7. package/facets/DragAndDrop.d.ts +15 -0
  8. package/facets/DragAndDrop.js +31 -0
  9. package/facets/DragAndDropUIConnector.d.ts +34 -0
  10. package/{DragAndDrop.js → facets/DragAndDropUIConnector.js} +23 -31
  11. package/facets/Edit.d.ts +22 -0
  12. package/{Editing.js → facets/Edit.js} +27 -18
  13. package/{handlers → facets}/EditWithKeys.d.ts +1 -1
  14. package/{handlers → facets}/EditWithKeys.js +6 -6
  15. package/facets/Filtering.d.ts +21 -0
  16. package/{Filtering.js → facets/Filtering.js} +10 -9
  17. package/facets/Highlight.d.ts +17 -0
  18. package/{Highlight.js → facets/Highlight.js} +16 -6
  19. package/facets/HighlightUIConnector.d.ts +36 -0
  20. package/facets/HighlightUIConnector.js +104 -0
  21. package/facets/Insertion.d.ts +24 -0
  22. package/{Insertion.js → facets/Insertion.js} +7 -6
  23. package/facets/Labelling.d.ts +28 -0
  24. package/{Labelling.js → facets/Labelling.js} +6 -5
  25. package/facets/Selection.d.ts +26 -0
  26. package/{Selection.js → facets/Selection.js} +19 -18
  27. package/facets/SelectionUIConnector.d.ts +39 -0
  28. package/facets/SelectionUIConnector.js +137 -0
  29. package/facets/Store.d.ts +7 -0
  30. package/facets/Store.js +35 -0
  31. package/index.d.ts +13 -1
  32. package/index.js +13 -1
  33. package/internal/utils.d.ts +4 -0
  34. package/internal/utils.js +21 -0
  35. package/package.json +3 -3
  36. package/policies/DragSourceFromNewItem.d.ts +1 -1
  37. package/policies/DragSourceFromNewItem.js +2 -2
  38. package/policies/cancelNewItemOnHighlightChange.d.ts +1 -1
  39. package/policies/cancelNewItemOnHighlightChange.js +2 -2
  40. package/policies/correctHighlight.d.ts +2 -0
  41. package/policies/correctHighlight.js +21 -0
  42. package/policies/createInsertionPreview.d.ts +2 -0
  43. package/policies/{insertionPreviewUsesDragSources.js → createInsertionPreview.js} +1 -1
  44. package/policies/filteringIsDisabledOnNewItem.d.ts +1 -1
  45. package/policies/filteringIsDisabledOnNewItem.js +3 -3
  46. package/policies/highlightFollowsSelection.d.ts +6 -2
  47. package/policies/highlightFollowsSelection.js +5 -5
  48. package/policies/highlightNewItem.d.ts +1 -1
  49. package/policies/highlightNewItem.js +3 -3
  50. package/policies/index.d.ts +13 -14
  51. package/policies/index.js +13 -14
  52. package/policies/newItemsAreAddedBelowTheHighlight.d.ts +1 -1
  53. package/policies/newItemsAreAddedBelowTheHighlight.js +3 -3
  54. package/policies/newItemsAreConfirmedOnEditSaved.d.ts +3 -0
  55. package/policies/newItemsAreConfirmedOnEditSaved.js +16 -0
  56. package/policies/newItemsAreCreatedAtTheTop.d.ts +1 -1
  57. package/policies/newItemsAreCreatedAtTheTop.js +1 -1
  58. package/policies/newItemsAreEdited.d.ts +2 -2
  59. package/policies/newItemsAreEdited.js +10 -10
  60. package/policies/newItemsAreInsertedWhenConfirmed.d.ts +1 -1
  61. package/policies/newItemsAreInsertedWhenConfirmed.js +4 -4
  62. package/policies/selectionIsInsertedOnDragAndDrop.d.ts +2 -2
  63. package/policies/selectionIsInsertedOnDragAndDrop.js +6 -4
  64. package/Addition.d.ts +0 -11
  65. package/AdditionCbs.d.ts +0 -19
  66. package/AdditionCbs.js +0 -1
  67. package/Deletion.d.ts +0 -5
  68. package/DeletionCbs.d.ts +0 -8
  69. package/DeletionCbs.js +0 -1
  70. package/DragAndDrop.d.ts +0 -30
  71. package/DragAndDropCbs.d.ts +0 -9
  72. package/DragAndDropCbs.js +0 -1
  73. package/Editing.d.ts +0 -8
  74. package/EditingCbs.d.ts +0 -15
  75. package/EditingCbs.js +0 -1
  76. package/Filtering.d.ts +0 -11
  77. package/FilteringCbs.d.ts +0 -12
  78. package/FilteringCbs.js +0 -1
  79. package/Highlight.d.ts +0 -7
  80. package/HighlightCbs.d.ts +0 -8
  81. package/HighlightCbs.js +0 -1
  82. package/Insertion.d.ts +0 -9
  83. package/InsertionCbs.d.ts +0 -15
  84. package/InsertionCbs.js +0 -1
  85. package/Labelling.d.ts +0 -9
  86. package/LabellingCbs.d.ts +0 -19
  87. package/LabellingCbs.js +0 -1
  88. package/Selection.d.ts +0 -11
  89. package/SelectionCbs.d.ts +0 -14
  90. package/SelectionCbs.js +0 -1
  91. package/handlers/ClickToSelectItems.d.ts +0 -23
  92. package/handlers/ClickToSelectItems.js +0 -53
  93. package/handlers/SelectWithKeys.d.ts +0 -10
  94. package/handlers/SelectWithKeys.js +0 -53
  95. package/handlers/index.d.ts +0 -3
  96. package/handlers/index.js +0 -3
  97. package/policies/highlightIsCorrectedOnFilterChange.d.ts +0 -4
  98. package/policies/highlightIsCorrectedOnFilterChange.js +0 -28
  99. package/policies/insertionPreviewUsesDragSources.d.ts +0 -2
  100. package/policies/newItemsAreConfirmedWhenSaved.d.ts +0 -3
  101. package/policies/newItemsAreConfirmedWhenSaved.js +0 -19
@@ -0,0 +1,28 @@
1
+ import { DefineCbs } from 'aspiration';
2
+ export type GenericObjectT = any;
3
+ export declare class Addition<T = any> {
4
+ static className: () => string;
5
+ item?: T;
6
+ parentId?: string;
7
+ add(args: {
8
+ values?: GenericObjectT;
9
+ }): Promise<any>;
10
+ confirm(): Promise<void>;
11
+ cancel(): void;
12
+ _reset(): void;
13
+ }
14
+ type Cbs<T> = {
15
+ add: {
16
+ stageAdd(): void;
17
+ createItem(): T;
18
+ highlightNewItem(): void;
19
+ };
20
+ cancel: {
21
+ unstageAdd(): void;
22
+ };
23
+ confirm: {
24
+ confirmAdd(): void;
25
+ };
26
+ };
27
+ export type AdditionCbs<T = any> = DefineCbs<Addition<T>, Cbs<T>>;
28
+ export {};
@@ -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 { getCallbacks, host } from 'aspiration';
8
- import { data, operation } from 'skandha';
9
- export class Addition {
7
+ import { getCallbacks, withCbs } from 'aspiration';
8
+ import { data, decorateCb, operation } from 'skandha';
9
+ class Addition {
10
10
  constructor() {
11
11
  Object.defineProperty(this, "item", {
12
12
  enumerable: true,
@@ -21,23 +21,30 @@ export class Addition {
21
21
  value: void 0
22
22
  });
23
23
  }
24
- add(values) {
24
+ add(args) {
25
+ var _a;
25
26
  const cbs = getCallbacks(this);
26
- cbs.storeLocation && cbs.storeLocation();
27
- return Promise.resolve(cbs.createItem()).then((item) => {
27
+ cbs.stageAdd && cbs.stageAdd();
28
+ const newItem = (_a = args.values) !== null && _a !== void 0 ? _a : cbs.createItem();
29
+ return Promise.resolve(newItem).then(decorateCb((item) => {
28
30
  this.item = item;
29
31
  cbs.highlightNewItem && cbs.highlightNewItem();
30
- });
32
+ return item;
33
+ }));
31
34
  }
32
35
  confirm() {
33
36
  const cbs = getCallbacks(this);
34
- return Promise.resolve(cbs.confirm()).then(() => {
37
+ const result = cbs.confirmAdd ? cbs.confirmAdd() : undefined;
38
+ return Promise.resolve(result).then(decorateCb(() => {
35
39
  this._reset();
36
- });
40
+ }));
37
41
  }
38
42
  cancel() {
39
43
  const cbs = getCallbacks(this);
40
- cbs.restoreLocation && cbs.restoreLocation();
44
+ if (this.item) {
45
+ this._reset();
46
+ cbs.unstageAdd && cbs.unstageAdd();
47
+ }
41
48
  }
42
49
  _reset() {
43
50
  this.item = undefined;
@@ -58,13 +65,17 @@ __decorate([
58
65
  ], Addition.prototype, "parentId", void 0);
59
66
  __decorate([
60
67
  operation,
61
- host(['values'])
68
+ withCbs()
62
69
  ], Addition.prototype, "add", null);
63
70
  __decorate([
64
71
  operation,
65
- host
72
+ withCbs()
66
73
  ], Addition.prototype, "confirm", null);
67
74
  __decorate([
68
75
  operation,
69
- host
76
+ withCbs()
70
77
  ], Addition.prototype, "cancel", null);
78
+ __decorate([
79
+ operation({ log: false })
80
+ ], Addition.prototype, "_reset", null);
81
+ export { Addition };
@@ -0,0 +1,16 @@
1
+ import { DefineCbs } from 'aspiration';
2
+ export declare class Deletion {
3
+ static className: () => string;
4
+ disabled?: boolean;
5
+ delete(args: {
6
+ itemIds: string[];
7
+ moveToTrash?: boolean;
8
+ }): Promise<any>;
9
+ }
10
+ type Cbs = {
11
+ delete: {
12
+ deleteItems(): any;
13
+ };
14
+ };
15
+ export type DeletionCbs = DefineCbs<Deletion, Cbs>;
16
+ export {};
@@ -4,10 +4,18 @@ 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 { getCallbacks, host } from 'aspiration';
8
- import { operation } from 'skandha';
9
- export class Deletion {
10
- delete(itemIds) {
7
+ import { getCallbacks, withCbs } from 'aspiration';
8
+ import { data, operation } from 'skandha';
9
+ class Deletion {
10
+ constructor() {
11
+ Object.defineProperty(this, "disabled", {
12
+ enumerable: true,
13
+ configurable: true,
14
+ writable: true,
15
+ value: undefined
16
+ });
17
+ }
18
+ delete(args) {
11
19
  const cbs = getCallbacks(this);
12
20
  return Promise.resolve(cbs.deleteItems());
13
21
  }
@@ -18,7 +26,11 @@ Object.defineProperty(Deletion, "className", {
18
26
  writable: true,
19
27
  value: () => 'Deletion'
20
28
  });
29
+ __decorate([
30
+ data
31
+ ], Deletion.prototype, "disabled", void 0);
21
32
  __decorate([
22
33
  operation,
23
- host(['itemIds'])
34
+ withCbs()
24
35
  ], Deletion.prototype, "delete", null);
36
+ export { Deletion };
@@ -0,0 +1,7 @@
1
+ export declare class Display<T = any> {
2
+ static className: () => string;
3
+ items: T[];
4
+ get itemById(): {
5
+ [id: string]: T;
6
+ };
7
+ }
@@ -0,0 +1,36 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { stub } from 'aspiration';
8
+ import { data, output } from 'skandha';
9
+ import { listToItemById } from '../internal/utils';
10
+ class Display {
11
+ constructor() {
12
+ Object.defineProperty(this, "items", {
13
+ enumerable: true,
14
+ configurable: true,
15
+ writable: true,
16
+ value: stub
17
+ });
18
+ }
19
+ get itemById() {
20
+ var _a;
21
+ return listToItemById((_a = this.items) !== null && _a !== void 0 ? _a : []);
22
+ }
23
+ }
24
+ Object.defineProperty(Display, "className", {
25
+ enumerable: true,
26
+ configurable: true,
27
+ writable: true,
28
+ value: () => 'Display'
29
+ });
30
+ __decorate([
31
+ data
32
+ ], Display.prototype, "items", void 0);
33
+ __decorate([
34
+ output
35
+ ], Display.prototype, "itemById", null);
36
+ export { Display };
@@ -0,0 +1,15 @@
1
+ import { DefineCbs } from 'aspiration';
2
+ import { DropPositionT } from './Insertion';
3
+ export declare class DragAndDrop {
4
+ static className: () => string;
5
+ drop(args: {
6
+ dropPosition: DropPositionT;
7
+ }): Promise<void>;
8
+ }
9
+ type Cbs = {
10
+ drop: {
11
+ drop(): void;
12
+ };
13
+ };
14
+ export type DragAndDropCbs = DefineCbs<DragAndDrop, Cbs>;
15
+ export {};
@@ -0,0 +1,31 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { getCallbacks, withCbs } from 'aspiration';
8
+ import { operation } from 'skandha';
9
+ import { selectionIsInsertedOnDragAndDrop } from '../policies/selectionIsInsertedOnDragAndDrop';
10
+ const dropDefaultCbs = (dragAndDrop) => ({
11
+ drop: function () {
12
+ selectionIsInsertedOnDragAndDrop(dragAndDrop, this.args.dropPosition);
13
+ },
14
+ });
15
+ class DragAndDrop {
16
+ drop(args) {
17
+ const cbs = getCallbacks(this);
18
+ return Promise.resolve(cbs.drop());
19
+ }
20
+ }
21
+ Object.defineProperty(DragAndDrop, "className", {
22
+ enumerable: true,
23
+ configurable: true,
24
+ writable: true,
25
+ value: () => 'DragAndDrop'
26
+ });
27
+ __decorate([
28
+ operation,
29
+ withCbs(dropDefaultCbs)
30
+ ], DragAndDrop.prototype, "drop", null);
31
+ export { DragAndDrop };
@@ -0,0 +1,34 @@
1
+ import { DragAndDrop } from './DragAndDrop';
2
+ import { DropPositionT } from './Insertion';
3
+ export interface DragAndDropUIConnectorT {
4
+ hoverPosition?: DropPositionT;
5
+ setHoverPosition(x?: DropPositionT): void;
6
+ handle(itemId: string): DragAndDropUIPropsT;
7
+ }
8
+ export type PropsT = {
9
+ dragAndDrop: DragAndDrop;
10
+ };
11
+ export declare class DragAndDropUIConnector implements DragAndDropUIConnectorT {
12
+ props: PropsT;
13
+ hoverPosition?: DropPositionT;
14
+ constructor(props: PropsT);
15
+ setHoverPosition(x?: DropPositionT): void;
16
+ handle(itemId: string): DragAndDropUIPropsT;
17
+ }
18
+ export declare function getDragState(hoverPosition: any, itemId: string): "before" | "after" | "none";
19
+ export type DragAndDropUIPropsT = {
20
+ draggable?: boolean;
21
+ dragState?: string;
22
+ onDragStart?: (event: any) => void;
23
+ onDragOver?: (event: any) => void;
24
+ onDragEnd?: (event: any) => void;
25
+ onDrop?: (event: any) => void;
26
+ };
27
+ export declare function dragAndDropUIHandlers<T extends DragAndDropUIPropsT>(props: T): {
28
+ draggable: boolean | undefined;
29
+ onDragStart: ((event: any) => void) | undefined;
30
+ onDragOver: ((event: any) => void) | undefined;
31
+ onDrop: ((event: any) => void) | undefined;
32
+ onDragEnd: ((event: any) => void) | undefined;
33
+ };
34
+ export declare function createDragAndDropUIConnector(dragAndDrop: DragAndDrop): DragAndDropUIConnector;
@@ -4,27 +4,23 @@ 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 { getCallbacks, host } from 'aspiration';
8
- import { data, operation } from 'skandha';
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
- });
16
- export class DragAndDrop {
17
- constructor() {
7
+ import { data, decorateCb, operation } from 'skandha';
8
+ import { isBefore } from '../internal/utils';
9
+ export class DragAndDropUIConnector {
10
+ constructor(props) {
11
+ Object.defineProperty(this, "props", {
12
+ enumerable: true,
13
+ configurable: true,
14
+ writable: true,
15
+ value: void 0
16
+ });
18
17
  Object.defineProperty(this, "hoverPosition", {
19
18
  enumerable: true,
20
19
  configurable: true,
21
20
  writable: true,
22
21
  value: void 0
23
22
  });
24
- }
25
- drop(dropPosition) {
26
- const cbs = getCallbacks(this);
27
- return Promise.resolve(cbs.drop());
23
+ this.props = props;
28
24
  }
29
25
  setHoverPosition(x) {
30
26
  this.hoverPosition = x;
@@ -45,38 +41,31 @@ export class DragAndDrop {
45
41
  },
46
42
  onDrop: () => {
47
43
  if (this.hoverPosition) {
48
- this.drop(this.hoverPosition).then(() => {
44
+ this.props.dragAndDrop
45
+ .drop({ dropPosition: this.hoverPosition })
46
+ .then(decorateCb(() => {
49
47
  this.setHoverPosition(undefined);
50
- });
48
+ }));
51
49
  }
52
50
  },
51
+ dragState: getDragState(this.hoverPosition, itemId),
53
52
  };
54
53
  }
55
54
  }
56
- Object.defineProperty(DragAndDrop, "className", {
57
- enumerable: true,
58
- configurable: true,
59
- writable: true,
60
- value: () => 'DragAndDrop'
61
- });
62
55
  __decorate([
63
56
  data
64
- ], DragAndDrop.prototype, "hoverPosition", void 0);
65
- __decorate([
66
- operation,
67
- host(['dropPosition'], dropDefaultCbs)
68
- ], DragAndDrop.prototype, "drop", null);
57
+ ], DragAndDropUIConnector.prototype, "hoverPosition", void 0);
69
58
  __decorate([
70
59
  operation({ log: false })
71
- ], DragAndDrop.prototype, "setHoverPosition", null);
72
- export function dragState(hoverPosition, itemId) {
60
+ ], DragAndDropUIConnector.prototype, "setHoverPosition", null);
61
+ export function getDragState(hoverPosition, itemId) {
73
62
  return (hoverPosition === null || hoverPosition === void 0 ? void 0 : hoverPosition.targetItemId) === itemId
74
63
  ? (hoverPosition === null || hoverPosition === void 0 ? void 0 : hoverPosition.isBefore)
75
64
  ? 'before'
76
65
  : 'after'
77
66
  : 'none';
78
67
  }
79
- export function dragHandlers(props) {
68
+ export function dragAndDropUIHandlers(props) {
80
69
  return {
81
70
  draggable: props.draggable,
82
71
  onDragStart: props.onDragStart,
@@ -85,3 +74,6 @@ export function dragHandlers(props) {
85
74
  onDragEnd: props.onDragEnd,
86
75
  };
87
76
  }
77
+ export function createDragAndDropUIConnector(dragAndDrop) {
78
+ return new DragAndDropUIConnector({ dragAndDrop });
79
+ }
@@ -0,0 +1,22 @@
1
+ import { DefineCbs } from 'aspiration';
2
+ export declare class Edit {
3
+ static className: () => string;
4
+ isEditing: boolean;
5
+ save(args: {
6
+ values: any;
7
+ }): Promise<any>;
8
+ cancel(): void;
9
+ enable(): void;
10
+ }
11
+ export type Cbs = {
12
+ save: {
13
+ saveItem(): any;
14
+ };
15
+ cancel: {
16
+ onCancel(): void;
17
+ };
18
+ enable: {
19
+ onEnable(): void;
20
+ };
21
+ };
22
+ export type EditCbs = DefineCbs<Edit, Cbs>;
@@ -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 { getCallbacks, host } from 'aspiration';
8
- import { data, operation } from 'skandha';
9
- export class Editing {
7
+ import { getCallbacks, withCbs } from 'aspiration';
8
+ import { data, decorateCb, operation } from 'skandha';
9
+ class Edit {
10
10
  constructor() {
11
11
  Object.defineProperty(this, "isEditing", {
12
12
  enumerable: true,
@@ -15,38 +15,47 @@ export class Editing {
15
15
  value: false
16
16
  });
17
17
  }
18
- save(values) {
18
+ save(args) {
19
19
  const cbs = getCallbacks(this);
20
- return Promise.resolve(cbs.saveItem()).then(() => {
20
+ return Promise.resolve(cbs.saveItem()).then(decorateCb((localItem) => {
21
21
  this.isEditing = false;
22
- cbs.refreshView && cbs.refreshView();
23
- });
22
+ return localItem;
23
+ }));
24
24
  }
25
25
  cancel() {
26
- this.isEditing = false;
26
+ const cbs = getCallbacks(this);
27
+ if (this.isEditing) {
28
+ this.isEditing = false;
29
+ cbs.onCancel && cbs.onCancel();
30
+ }
27
31
  }
28
32
  enable() {
29
- this.isEditing = true;
33
+ const cbs = getCallbacks(this);
34
+ if (!this.isEditing) {
35
+ this.isEditing = true;
36
+ cbs.onEnable && cbs.onEnable();
37
+ }
30
38
  }
31
39
  }
32
- Object.defineProperty(Editing, "className", {
40
+ Object.defineProperty(Edit, "className", {
33
41
  enumerable: true,
34
42
  configurable: true,
35
43
  writable: true,
36
- value: () => 'Editing'
44
+ value: () => 'Edit'
37
45
  });
38
46
  __decorate([
39
47
  data
40
- ], Editing.prototype, "isEditing", void 0);
48
+ ], Edit.prototype, "isEditing", void 0);
41
49
  __decorate([
42
50
  operation,
43
- host(['values'])
44
- ], Editing.prototype, "save", null);
51
+ withCbs()
52
+ ], Edit.prototype, "save", null);
45
53
  __decorate([
46
54
  operation,
47
- host
48
- ], Editing.prototype, "cancel", null);
55
+ withCbs()
56
+ ], Edit.prototype, "cancel", null);
49
57
  __decorate([
50
58
  operation,
51
- host
52
- ], Editing.prototype, "enable", null);
59
+ withCbs()
60
+ ], Edit.prototype, "enable", null);
61
+ export { Edit };
@@ -1,4 +1,4 @@
1
- export declare type PropsT = {
1
+ export type PropsT = {
2
2
  container: any;
3
3
  };
4
4
  export declare class EditWithKeys {
@@ -1,5 +1,5 @@
1
- import { Editing } from "../Editing";
2
- import { getf } from "skandha";
1
+ import { getf } from 'skandha';
2
+ import { Edit } from './Edit';
3
3
  export class EditWithKeys {
4
4
  constructor(props) {
5
5
  Object.defineProperty(this, "props", {
@@ -17,12 +17,12 @@ export class EditWithKeys {
17
17
  if (key === keyEdit) {
18
18
  e.preventDefault();
19
19
  e.stopPropagation();
20
- const editing = getf(Editing, ctr);
21
- if (editing.isEditing) {
22
- editing.cancel();
20
+ const edit = getf(Edit, ctr);
21
+ if (edit.isEditing) {
22
+ edit.cancel();
23
23
  }
24
24
  else {
25
- editing.enable();
25
+ edit.enable();
26
26
  }
27
27
  }
28
28
  },
@@ -0,0 +1,21 @@
1
+ import { DefineCbs } from 'aspiration';
2
+ export type FilterT<T> = (x: T[]) => T[];
3
+ export declare class Filtering<T = any> {
4
+ static className: () => string;
5
+ isEnabled: boolean;
6
+ filter: FilterT<T>;
7
+ inputItems: Array<T>;
8
+ get filteredItems(): T[];
9
+ apply(args: {
10
+ filter: FilterT<T>;
11
+ }): void;
12
+ setEnabled(args: {
13
+ flag: boolean;
14
+ }): void;
15
+ }
16
+ type Cbs<T> = {
17
+ apply: {};
18
+ setEnabled: {};
19
+ };
20
+ export type FilteringCbs<T = any> = DefineCbs<Filtering<T>, Cbs<T>>;
21
+ export {};
@@ -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, stub } from 'aspiration';
7
+ import { stub, withCbs } from 'aspiration';
8
8
  import { data, operation } from 'skandha';
9
- export class Filtering {
9
+ class Filtering {
10
10
  constructor() {
11
11
  Object.defineProperty(this, "isEnabled", {
12
12
  enumerable: true,
@@ -30,12 +30,12 @@ export class Filtering {
30
30
  get filteredItems() {
31
31
  return this.isEnabled ? this.filter(this.inputItems) : this.inputItems;
32
32
  }
33
- apply(filter) {
34
- this.filter = filter;
35
- this.setEnabled(true);
33
+ apply(args) {
34
+ this.filter = args.filter;
35
+ this.setEnabled({ flag: true });
36
36
  }
37
- setEnabled(flag) {
38
- this.isEnabled = flag;
37
+ setEnabled(args) {
38
+ this.isEnabled = args.flag;
39
39
  }
40
40
  }
41
41
  Object.defineProperty(Filtering, "className", {
@@ -58,9 +58,10 @@ __decorate([
58
58
  ], Filtering.prototype, "filteredItems", null);
59
59
  __decorate([
60
60
  operation,
61
- host(['filter'])
61
+ withCbs()
62
62
  ], Filtering.prototype, "apply", null);
63
63
  __decorate([
64
64
  operation,
65
- host(['flag'])
65
+ withCbs()
66
66
  ], Filtering.prototype, "setEnabled", null);
67
+ export { Filtering };
@@ -0,0 +1,17 @@
1
+ import { DefineCbs } from 'aspiration';
2
+ export declare class Highlight<T = any> {
3
+ static className: () => string;
4
+ highlightableIds: Array<string>;
5
+ id: string | undefined;
6
+ item?: T;
7
+ highlightItem(args: {
8
+ id: string | undefined;
9
+ }): void;
10
+ }
11
+ type Cbs<T> = {
12
+ highlightItem: {
13
+ scrollItemIntoView(): void;
14
+ };
15
+ };
16
+ export type HighlightCbs<T = any> = DefineCbs<Highlight<T>, Cbs<T>>;
17
+ export {};
@@ -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 { getCallbacks, host } from 'aspiration';
8
- import { data, operation, output } from 'skandha';
7
+ import { getCallbacks, stub, withCbs } from 'aspiration';
8
+ import { data, input, operation, output } from 'skandha';
9
9
  const highlightItemDefaultCbs = (highlight) => ({});
10
- export class Highlight {
10
+ class Highlight {
11
11
  constructor() {
12
+ Object.defineProperty(this, "highlightableIds", {
13
+ enumerable: true,
14
+ configurable: true,
15
+ writable: true,
16
+ value: stub
17
+ });
12
18
  Object.defineProperty(this, "id", {
13
19
  enumerable: true,
14
20
  configurable: true,
@@ -22,9 +28,9 @@ export class Highlight {
22
28
  value: void 0
23
29
  });
24
30
  }
25
- highlightItem(id) {
31
+ highlightItem(args) {
26
32
  const cbs = getCallbacks(this);
27
- this.id = id;
33
+ this.id = args.id;
28
34
  cbs.scrollItemIntoView && cbs.scrollItemIntoView();
29
35
  }
30
36
  }
@@ -34,6 +40,9 @@ Object.defineProperty(Highlight, "className", {
34
40
  writable: true,
35
41
  value: () => 'Highlight'
36
42
  });
43
+ __decorate([
44
+ input
45
+ ], Highlight.prototype, "highlightableIds", void 0);
37
46
  __decorate([
38
47
  data
39
48
  ], Highlight.prototype, "id", void 0);
@@ -42,5 +51,6 @@ __decorate([
42
51
  ], Highlight.prototype, "item", void 0);
43
52
  __decorate([
44
53
  operation,
45
- host(['id'], highlightItemDefaultCbs)
54
+ withCbs(highlightItemDefaultCbs)
46
55
  ], Highlight.prototype, "highlightItem", null);
56
+ export { Highlight };