skandha-facets 0.10.1 → 0.12.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 (104) hide show
  1. package/facets/Addition.d.ts +30 -0
  2. package/{Addition.js → facets/Addition.js} +37 -15
  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 +31 -0
  10. package/facets/DragAndDropUIConnector.js +61 -0
  11. package/facets/Edit.d.ts +23 -0
  12. package/{Editing.js → facets/Edit.js} +32 -17
  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 +30 -0
  20. package/facets/HighlightUIConnector.js +70 -0
  21. package/facets/Hovering.d.ts +10 -0
  22. package/facets/Hovering.js +33 -0
  23. package/facets/Insertion.d.ts +18 -0
  24. package/{Insertion.js → facets/Insertion.js} +7 -6
  25. package/facets/Selection.d.ts +26 -0
  26. package/{Selection.js → facets/Selection.js} +20 -19
  27. package/facets/SelectionUIConnector.d.ts +39 -0
  28. package/facets/SelectionUIConnector.js +108 -0
  29. package/facets/Store.d.ts +8 -0
  30. package/facets/Store.js +41 -0
  31. package/index.d.ts +14 -1
  32. package/index.js +14 -1
  33. package/internal/utils.d.ts +4 -0
  34. package/internal/utils.js +30 -2
  35. package/package.json +3 -3
  36. package/policies/DragSourceFromNewItem.d.ts +2 -2
  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/createInsertionPreview.js +8 -0
  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 +6 -6
  62. package/policies/selectionIsInsertedOnDragAndDrop.d.ts +3 -3
  63. package/policies/selectionIsInsertedOnDragAndDrop.js +10 -5
  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/DragAndDrop.js +0 -87
  72. package/DragAndDropCbs.d.ts +0 -9
  73. package/DragAndDropCbs.js +0 -1
  74. package/Editing.d.ts +0 -8
  75. package/EditingCbs.d.ts +0 -15
  76. package/EditingCbs.js +0 -1
  77. package/Filtering.d.ts +0 -11
  78. package/FilteringCbs.d.ts +0 -12
  79. package/FilteringCbs.js +0 -1
  80. package/Highlight.d.ts +0 -7
  81. package/HighlightCbs.d.ts +0 -8
  82. package/HighlightCbs.js +0 -1
  83. package/Insertion.d.ts +0 -9
  84. package/InsertionCbs.d.ts +0 -15
  85. package/InsertionCbs.js +0 -1
  86. package/Labelling.d.ts +0 -9
  87. package/Labelling.js +0 -60
  88. package/LabellingCbs.d.ts +0 -19
  89. package/LabellingCbs.js +0 -1
  90. package/Selection.d.ts +0 -11
  91. package/SelectionCbs.d.ts +0 -14
  92. package/SelectionCbs.js +0 -1
  93. package/handlers/ClickToSelectItems.d.ts +0 -23
  94. package/handlers/ClickToSelectItems.js +0 -53
  95. package/handlers/SelectWithKeys.d.ts +0 -10
  96. package/handlers/SelectWithKeys.js +0 -53
  97. package/handlers/index.d.ts +0 -3
  98. package/handlers/index.js +0 -3
  99. package/policies/highlightIsCorrectedOnFilterChange.d.ts +0 -4
  100. package/policies/highlightIsCorrectedOnFilterChange.js +0 -28
  101. package/policies/insertionPreviewUsesDragSources.d.ts +0 -2
  102. package/policies/insertionPreviewUsesDragSources.js +0 -8
  103. package/policies/newItemsAreConfirmedWhenSaved.d.ts +0 -3
  104. package/policies/newItemsAreConfirmedWhenSaved.js +0 -19
@@ -0,0 +1,30 @@
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
+ setParentId(parentId?: string): void;
8
+ setItem(item?: T): void;
9
+ add(args: {
10
+ values?: GenericObjectT;
11
+ }): any;
12
+ confirm(): Promise<void>;
13
+ cancel(): void;
14
+ _reset(): void;
15
+ }
16
+ type Cbs<T> = {
17
+ add: {
18
+ stageAdd(): void;
19
+ createItem(): T;
20
+ highlightNewItem(): void;
21
+ };
22
+ cancel: {
23
+ unstageAdd(parentId: string | undefined): void;
24
+ };
25
+ confirm: {
26
+ confirmAdd(): void;
27
+ };
28
+ };
29
+ export type AdditionCbs<T = any> = DefineCbs<Addition<T>, Cbs<T>>;
30
+ 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';
7
+ import { getCallbacks, withCbs } from 'aspiration';
8
8
  import { data, operation } from 'skandha';
9
- export class Addition {
9
+ class Addition {
10
10
  constructor() {
11
11
  Object.defineProperty(this, "item", {
12
12
  enumerable: true,
@@ -21,27 +21,39 @@ export class Addition {
21
21
  value: void 0
22
22
  });
23
23
  }
24
- add(values) {
24
+ setParentId(parentId) {
25
+ this.parentId = parentId;
26
+ }
27
+ setItem(item) {
28
+ this.item = item;
29
+ }
30
+ add(args) {
31
+ var _a;
25
32
  const cbs = getCallbacks(this);
26
- cbs.storeLocation && cbs.storeLocation();
27
- return Promise.resolve(cbs.createItem()).then((item) => {
28
- this.item = item;
29
- cbs.highlightNewItem && cbs.highlightNewItem();
30
- });
33
+ cbs.stageAdd && cbs.stageAdd();
34
+ const newItem = (_a = args.values) !== null && _a !== void 0 ? _a : cbs.createItem();
35
+ this.setItem(newItem);
36
+ cbs.highlightNewItem && cbs.highlightNewItem();
37
+ return newItem;
31
38
  }
32
39
  confirm() {
33
40
  const cbs = getCallbacks(this);
34
- return Promise.resolve(cbs.confirm()).then(() => {
41
+ const result = cbs.confirmAdd ? cbs.confirmAdd() : undefined;
42
+ return Promise.resolve(result).then(() => {
35
43
  this._reset();
36
44
  });
37
45
  }
38
46
  cancel() {
39
47
  const cbs = getCallbacks(this);
40
- cbs.restoreLocation && cbs.restoreLocation();
48
+ if (this.item) {
49
+ const parentId = this.parentId;
50
+ this._reset();
51
+ cbs.unstageAdd && cbs.unstageAdd(parentId);
52
+ }
41
53
  }
42
54
  _reset() {
43
- this.item = undefined;
44
- this.parentId = undefined;
55
+ this.setItem(undefined);
56
+ this.setParentId(undefined);
45
57
  }
46
58
  }
47
59
  Object.defineProperty(Addition, "className", {
@@ -56,15 +68,25 @@ __decorate([
56
68
  __decorate([
57
69
  data
58
70
  ], Addition.prototype, "parentId", void 0);
71
+ __decorate([
72
+ operation({ log: false })
73
+ ], Addition.prototype, "setParentId", null);
74
+ __decorate([
75
+ operation({ log: false })
76
+ ], Addition.prototype, "setItem", null);
59
77
  __decorate([
60
78
  operation,
61
- host(['values'])
79
+ withCbs()
62
80
  ], Addition.prototype, "add", null);
63
81
  __decorate([
64
82
  operation,
65
- host
83
+ withCbs()
66
84
  ], Addition.prototype, "confirm", null);
67
85
  __decorate([
68
86
  operation,
69
- host
87
+ withCbs()
70
88
  ], Addition.prototype, "cancel", null);
89
+ __decorate([
90
+ operation({ log: false })
91
+ ], Addition.prototype, "_reset", null);
92
+ 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 { HoverPositionT } from './Hovering';
3
+ export declare class DragAndDrop {
4
+ static className: () => string;
5
+ drop(args: {
6
+ hoverPosition: HoverPositionT;
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.hoverPosition);
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,31 @@
1
+ import { DragAndDrop } from './DragAndDrop';
2
+ import { Hovering } from './Hovering';
3
+ export interface DragAndDropUIConnectorT {
4
+ handle(itemId: string): DragAndDropUIPropsT;
5
+ }
6
+ export type PropsT = {
7
+ dragAndDrop: DragAndDrop;
8
+ hovering: Hovering;
9
+ };
10
+ export declare class DragAndDropUIConnector implements DragAndDropUIConnectorT {
11
+ props: PropsT;
12
+ constructor(props: PropsT);
13
+ handle(itemId: string): DragAndDropUIPropsT;
14
+ }
15
+ export declare function getDragState(hoverPosition: any, itemId: string): "before" | "after" | "none";
16
+ export type DragAndDropUIPropsT = {
17
+ draggable?: boolean;
18
+ dragState?: string;
19
+ onDragStart?: (event: any) => void;
20
+ onDragOver?: (event: any) => void;
21
+ onDragEnd?: (event: any) => void;
22
+ onDrop?: (event: any) => void;
23
+ };
24
+ export declare function dragAndDropUIHandlers<T extends DragAndDropUIPropsT>(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
+ };
31
+ export declare function createDragAndDropUIConnector(dragAndDrop: DragAndDrop, hovering: Hovering): DragAndDropUIConnector;
@@ -0,0 +1,61 @@
1
+ import { isBefore } from '../internal/utils';
2
+ export class DragAndDropUIConnector {
3
+ constructor(props) {
4
+ Object.defineProperty(this, "props", {
5
+ enumerable: true,
6
+ configurable: true,
7
+ writable: true,
8
+ value: void 0
9
+ });
10
+ this.props = props;
11
+ }
12
+ handle(itemId) {
13
+ return {
14
+ draggable: true,
15
+ onDragStart: () => { },
16
+ onDragOver: (e) => {
17
+ e.preventDefault();
18
+ this.props.hovering.setHoverPosition({
19
+ targetItemId: itemId,
20
+ isBefore: isBefore(e),
21
+ });
22
+ },
23
+ onDragEnd: () => {
24
+ this.props.hovering.setHoverPosition(undefined);
25
+ },
26
+ onDrop: () => {
27
+ const hoverPosition = this.props.hovering.hoverPosition;
28
+ if (hoverPosition) {
29
+ this.props.dragAndDrop
30
+ .drop({ hoverPosition: hoverPosition })
31
+ .then(() => {
32
+ this.props.hovering.setHoverPosition(undefined);
33
+ });
34
+ }
35
+ },
36
+ dragState: getDragState(this.props.hovering.hoverPosition, itemId),
37
+ };
38
+ }
39
+ }
40
+ export function getDragState(hoverPosition, itemId) {
41
+ return (hoverPosition === null || hoverPosition === void 0 ? void 0 : hoverPosition.targetItemId) === itemId
42
+ ? (hoverPosition === null || hoverPosition === void 0 ? void 0 : hoverPosition.isBefore)
43
+ ? 'before'
44
+ : 'after'
45
+ : 'none';
46
+ }
47
+ export function dragAndDropUIHandlers(props) {
48
+ return {
49
+ draggable: props.draggable,
50
+ onDragStart: props.onDragStart,
51
+ onDragOver: props.onDragOver,
52
+ onDrop: props.onDrop,
53
+ onDragEnd: props.onDragEnd,
54
+ };
55
+ }
56
+ export function createDragAndDropUIConnector(dragAndDrop, hovering) {
57
+ return new DragAndDropUIConnector({
58
+ dragAndDrop,
59
+ hovering,
60
+ });
61
+ }
@@ -0,0 +1,23 @@
1
+ import { DefineCbs } from 'aspiration';
2
+ export declare class Edit {
3
+ static className: () => string;
4
+ isEditing: boolean;
5
+ reset(): void;
6
+ save(args: {
7
+ values: any;
8
+ }): Promise<any>;
9
+ cancel(): void;
10
+ enable(): void;
11
+ }
12
+ export type Cbs = {
13
+ save: {
14
+ saveItem(): any;
15
+ };
16
+ cancel: {
17
+ onCancel(): void;
18
+ };
19
+ enable: {
20
+ onEnable(): void;
21
+ };
22
+ };
23
+ 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';
7
+ import { getCallbacks, withCbs } from 'aspiration';
8
8
  import { data, operation } from 'skandha';
9
- export class Editing {
9
+ class Edit {
10
10
  constructor() {
11
11
  Object.defineProperty(this, "isEditing", {
12
12
  enumerable: true,
@@ -15,38 +15,53 @@ export class Editing {
15
15
  value: false
16
16
  });
17
17
  }
18
- save(values) {
18
+ reset() {
19
+ this.isEditing = false;
20
+ }
21
+ save(args) {
19
22
  const cbs = getCallbacks(this);
20
- return Promise.resolve(cbs.saveItem()).then(() => {
21
- this.isEditing = false;
22
- cbs.refreshView && cbs.refreshView();
23
+ return Promise.resolve(cbs.saveItem()).then((savedObj) => {
24
+ this.reset();
25
+ return savedObj;
23
26
  });
24
27
  }
25
28
  cancel() {
26
- this.isEditing = false;
29
+ const cbs = getCallbacks(this);
30
+ if (this.isEditing) {
31
+ this.reset();
32
+ cbs.onCancel && cbs.onCancel();
33
+ }
27
34
  }
28
35
  enable() {
29
- this.isEditing = true;
36
+ const cbs = getCallbacks(this);
37
+ if (!this.isEditing) {
38
+ this.isEditing = true;
39
+ cbs.onEnable && cbs.onEnable();
40
+ }
30
41
  }
31
42
  }
32
- Object.defineProperty(Editing, "className", {
43
+ Object.defineProperty(Edit, "className", {
33
44
  enumerable: true,
34
45
  configurable: true,
35
46
  writable: true,
36
- value: () => 'Editing'
47
+ value: () => 'Edit'
37
48
  });
38
49
  __decorate([
39
50
  data
40
- ], Editing.prototype, "isEditing", void 0);
51
+ ], Edit.prototype, "isEditing", void 0);
52
+ __decorate([
53
+ operation
54
+ ], Edit.prototype, "reset", null);
41
55
  __decorate([
42
56
  operation,
43
- host(['values'])
44
- ], Editing.prototype, "save", null);
57
+ withCbs()
58
+ ], Edit.prototype, "save", null);
45
59
  __decorate([
46
60
  operation,
47
- host
48
- ], Editing.prototype, "cancel", null);
61
+ withCbs()
62
+ ], Edit.prototype, "cancel", null);
49
63
  __decorate([
50
64
  operation,
51
- host
52
- ], Editing.prototype, "enable", null);
65
+ withCbs()
66
+ ], Edit.prototype, "enable", null);
67
+ 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 };
@@ -0,0 +1,30 @@
1
+ import { Highlight } from './Highlight';
2
+ export interface HighlightUIConnectorT {
3
+ handle(itemId: string): HighlightUIPropsT;
4
+ }
5
+ export type PropsT = {
6
+ highlight: Highlight;
7
+ };
8
+ export declare class HighlightUIConnector implements HighlightUIConnectorT {
9
+ props: PropsT;
10
+ _handleMouseDown: any;
11
+ constructor(props: PropsT);
12
+ _highlight(e: any, itemId: string): void;
13
+ _createMouseDownHandler(): (e: any, itemId: string) => void;
14
+ handle(itemId: any): HighlightUIPropsT;
15
+ }
16
+ export type HighlightUIPropsT = {
17
+ isHighlighted: boolean;
18
+ onMouseDown?: any;
19
+ };
20
+ export declare function highlightUIHandlers<T extends HighlightUIPropsT>(props: T): {
21
+ onMouseDown: any;
22
+ };
23
+ export declare function createHighlightUIConnector(highlight: Highlight): HighlightUIConnector;
24
+ export declare const createHighlightKeyHandlers: (highlight: Highlight, options?: {
25
+ keyDown?: string;
26
+ keyUp?: string;
27
+ getHighlightableIds?: () => string[];
28
+ }) => {
29
+ [x: string]: () => void;
30
+ };