@omegagrid/core 0.6.89 → 0.6.91
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/dist/model/component.d.ts +1 -0
- package/dist/model/component.d.ts.map +1 -1
- package/dist/model/component.js +6 -0
- package/dist/model/component.js.map +1 -1
- package/dist/ui/sortableList.d.ts +2 -1
- package/dist/ui/sortableList.d.ts.map +1 -1
- package/dist/ui/sortableList.js +15 -17
- package/dist/ui/sortableList.js.map +1 -1
- package/package.json +2 -2
|
@@ -10,6 +10,7 @@ export declare abstract class OmegaComponent<TState extends ComponentState = Com
|
|
|
10
10
|
set state(val: TState);
|
|
11
11
|
getState(): TState;
|
|
12
12
|
setState(state: TState): void;
|
|
13
|
+
updateState(state: Partial<TState>): void;
|
|
13
14
|
connectedCallback(): void;
|
|
14
15
|
disconnectedCallback(): void;
|
|
15
16
|
dispatchStateEvent(): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../src/model/component.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,UAAU,EAAO,MAAM,KAAK,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAKrD,8BAAsB,cAAc,CAAC,MAAM,SAAS,cAAc,GAAG,cAAc,CAAE,SAAQ,UAAW,YAAW,SAAS;;IAE3H,MAAM,CAAC,MAAM,EAAE,cAAc,CAU3B;IAEF,IAAI,eAAe,IAC8D,UAAU,CAC1F;IAED,IAAI,oBAAoB,IAC6D,cAAc,CAClG;IAED,OAAO,CAAC,MAAM,CAAS;IACvB,IACI,KAAK,IAIM,MAAM,CAFpB;IAED,IAAI,KAAK,CAAC,GAAG,EAAE,MAAM,EAIpB;IAED,QAAQ,IAAI,MAAM;IAIlB,QAAQ,CAAC,KAAK,EAAE,MAAM;IAItB,iBAAiB,IAAI,IAAI;IAKzB,oBAAoB,IAAI,IAAI;IAS5B,kBAAkB;CAIlB"}
|
|
1
|
+
{"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../src/model/component.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,UAAU,EAAO,MAAM,KAAK,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAKrD,8BAAsB,cAAc,CAAC,MAAM,SAAS,cAAc,GAAG,cAAc,CAAE,SAAQ,UAAW,YAAW,SAAS;;IAE3H,MAAM,CAAC,MAAM,EAAE,cAAc,CAU3B;IAEF,IAAI,eAAe,IAC8D,UAAU,CAC1F;IAED,IAAI,oBAAoB,IAC6D,cAAc,CAClG;IAED,OAAO,CAAC,MAAM,CAAS;IACvB,IACI,KAAK,IAIM,MAAM,CAFpB;IAED,IAAI,KAAK,CAAC,GAAG,EAAE,MAAM,EAIpB;IAED,QAAQ,IAAI,MAAM;IAIlB,QAAQ,CAAC,KAAK,EAAE,MAAM;IAItB,WAAW,CAAC,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC;IAMlC,iBAAiB,IAAI,IAAI;IAKzB,oBAAoB,IAAI,IAAI;IAS5B,kBAAkB;CAIlB"}
|
package/dist/model/component.js
CHANGED
|
@@ -42,6 +42,12 @@ export class OmegaComponent extends LitElement {
|
|
|
42
42
|
setState(state) {
|
|
43
43
|
this._state = state;
|
|
44
44
|
}
|
|
45
|
+
updateState(state) {
|
|
46
|
+
if (!this._state)
|
|
47
|
+
this._state = {};
|
|
48
|
+
Object.assign(this._state, state);
|
|
49
|
+
__classPrivateFieldGet(this, _OmegaComponent_debounceDispatchStateEvent, "f").call(this);
|
|
50
|
+
}
|
|
45
51
|
connectedCallback() {
|
|
46
52
|
super.connectedCallback();
|
|
47
53
|
this.dispatchEvent(new Event('connected'));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component.js","sourceRoot":"","sources":["../../src/model/component.ts"],"names":[],"mappings":"AAAA,qDAAqD;;;;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AM,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC;QAC7B,IAAI,CAAC,MAAM,GAAG,GAAG,CAAC;QAClB,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IACvC,CAAC;IAED,QAAQ;QACP,OAAO,IAAI,CAAC,MAAM,CAAC;IACpB,CAAC;IAED,QAAQ,CAAC,KAAa;QACrB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACrB,CAAC;IAED,WAAW,CAAC,KAAsB;QACjC,IAAI,CAAC,IAAI,CAAC,MAAM;YAAE,IAAI,CAAC,MAAM,GAAG,EAAY,CAAC;QAC7C,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;QAClC,uBAAA,IAAI,kDAA4B,MAAhC,IAAI,CAA8B,CAAC;IACpC,CAAC;IAED,iBAAiB;QAChB,KAAK,CAAC,iBAAiB,EAAE,CAAC;QAC1B,IAAI,CAAC,aAAa,CAAC,IAAI,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC;IAC5C,CAAC;IAED,oBAAoB;QACnB,KAAK,CAAC,oBAAoB,EAAE,CAAC;QAC7B,IAAI,CAAC,aAAa,CAAC,IAAI,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC;IAC/C,CAAC;IAMD,kBAAkB;QACjB,uBAAA,IAAI,kDAA4B,MAAhC,IAAI,CAA8B,CAAC;IACpC,CAAC;;;AA9DM,qBAAM,GAAmB,GAAG,CAAA;;;;;;;;;;EAUlC,AAVY,CAUX;AAYF;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,IAAI,EAAC,CAAC;2CAG1C","sourcesContent":["/* eslint-disable @typescript-eslint/no-this-alias */\n\nimport { CSSResultGroup, LitElement, css } from \"lit\";\nimport { ComponentState, Statefull } from \"../types\";\nimport { debounce } from \"ts-debounce\";\nimport { dom } from \"../common\";\nimport { property } from \"lit/decorators.js\";\n\nexport abstract class OmegaComponent<TState extends ComponentState = ComponentState> extends LitElement implements Statefull {\n\n\tstatic styles: CSSResultGroup = css`\n\t\t* {\n\t\t\tbox-sizing: border-box;\n\t\t}\n\n\t\t:host {\n\t\t\tdisplay: block;\n\t\t\tfont-size: var(--og-font-size);\n\t\t\tfont-family: var(--og-font-family);\n\t\t}\n\t`;\n\n\tget parentComponent() {\n\t\treturn dom.findParent(this, (elm: HTMLElement) => elm instanceof LitElement) as LitElement;\n\t}\n\n\tget parentOmegaComponent() {\n\t\treturn dom.findParent(this, (elm: HTMLElement) => elm instanceof OmegaComponent) as OmegaComponent;\n\t}\n\n\tprivate _state: TState;\n\t@property({type: Object, noAccessor: true})\n\tget state() {\n\t\treturn this._state;\n\t}\n\n\tset state(val: TState) {\n\t\tconst oldState = this._state;\n\t\tthis._state = val;\n\t\tthis.requestUpdate('state', oldState);\n\t}\n\n\tgetState(): TState {\n\t\treturn this._state;\n\t}\n\n\tsetState(state: TState) {\n\t\tthis._state = state;\n\t}\n\n\tupdateState(state: Partial<TState>) {\n\t\tif (!this._state) this._state = {} as TState;\n\t\tObject.assign(this._state, state);\n\t\tthis.#debounceDispatchStateEvent();\n\t}\n\n\tconnectedCallback(): void {\n\t\tsuper.connectedCallback();\n\t\tthis.dispatchEvent(new Event('connected'));\n\t}\n\n\tdisconnectedCallback(): void {\n\t\tsuper.disconnectedCallback();\n\t\tthis.dispatchEvent(new Event('disconnected'));\n\t}\n\n\t#debounceDispatchStateEvent = debounce(() => {\n\t\tthis.dispatchEvent(new Event('state', {bubbles: true, composed: true}));\n\t});\n\t\n\tdispatchStateEvent() {\n\t\tthis.#debounceDispatchStateEvent();\n\t}\n\n}"]}
|
|
@@ -9,7 +9,7 @@ export declare class ListSortEvent extends Event {
|
|
|
9
9
|
readonly sourceList: SortableList;
|
|
10
10
|
readonly targetList: SortableList;
|
|
11
11
|
readonly drop: 'before' | 'after';
|
|
12
|
-
constructor(type: string, args
|
|
12
|
+
constructor(type: string, args?: Partial<ListSortEvent>);
|
|
13
13
|
}
|
|
14
14
|
export declare class SortableList extends List {
|
|
15
15
|
static sourceList: SortableList;
|
|
@@ -21,6 +21,7 @@ export declare class SortableList extends List {
|
|
|
21
21
|
private sortIndex;
|
|
22
22
|
private targetIndex;
|
|
23
23
|
private markedItem;
|
|
24
|
+
private drop;
|
|
24
25
|
private autoscrollTimer;
|
|
25
26
|
private autoscrollDirection;
|
|
26
27
|
static contentStyles: import("lit").CSSResult[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sortableList.d.ts","sourceRoot":"","sources":["../../src/ui/sortableList.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,IAAI,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAE/C,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAGrC,MAAM,WAAW,gBAAiB,SAAQ,WAAW;IACpD,UAAU,CAAC,EAAE,WAAW,CAAC;CACzB;AAED,qBAAa,aAAc,SAAQ,KAAK;IAEvC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,UAAU,EAAE,YAAY,CAAC;IAClC,QAAQ,CAAC,UAAU,EAAE,YAAY,CAAC;IAClC,QAAQ,CAAC,IAAI,EAAE,QAAQ,GAAC,OAAO,CAAC;gBAEpB,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,CAAC,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"sortableList.d.ts","sourceRoot":"","sources":["../../src/ui/sortableList.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,IAAI,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAE/C,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAGrC,MAAM,WAAW,gBAAiB,SAAQ,WAAW;IACpD,UAAU,CAAC,EAAE,WAAW,CAAC;CACzB;AAED,qBAAa,aAAc,SAAQ,KAAK;IAEvC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,UAAU,EAAE,YAAY,CAAC;IAClC,QAAQ,CAAC,UAAU,EAAE,YAAY,CAAC;IAClC,QAAQ,CAAC,IAAI,EAAE,QAAQ,GAAC,OAAO,CAAC;gBAEpB,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC;CAKvD;AAED,qBACa,YAAa,SAAQ,IAAI;IAErC,MAAM,CAAC,UAAU,EAAE,YAAY,CAAC;IAChC,cAAc,EAAE,YAAY,EAAE,CAAC;IAG/B,YAAY,UAAS;IAErB,OAAO,CAAC,QAAQ,CAAS;IACzB,IAAI,OAAO,IAAK,OAAO,CAAyB;IAChD,IAAI,gBAAgB,IAAK,OAAO,CAE/B;IAED,OAAO,CAAC,SAAS,CAAM;IACvB,OAAO,CAAC,WAAW,CAAM;IACzB,OAAO,CAAC,UAAU,CAAkB;IACpC,OAAO,CAAC,IAAI,CAAmB;IAC/B,OAAO,CAAC,eAAe,CAAS;IAChC,OAAO,CAAC,mBAAmB,CAAY;IAEvC,MAAM,CAAC,aAAa,4BAgBjB;;IAMH,YAAY,CAAC,IAAI,EAAE,eAAe;IAQlC,UAAU;IAIV,WAAW,CAAC,aAAa,CAAC,EAAE,OAAO;IAsBnC,eAAe,CAAC,SAAS,EAAE,SAAS;IAcpC,cAAc;IAQd,YAAY,MAAO,UAAU,UAc5B;IAED,UAAU,aAET;IAED,YAAY,MAAO,UAAU,UAgC5B;IAED,YAAY;CAOZ"}
|
package/dist/ui/sortableList.js
CHANGED
|
@@ -13,7 +13,8 @@ import constants from '../constants';
|
|
|
13
13
|
export class ListSortEvent extends Event {
|
|
14
14
|
constructor(type, args) {
|
|
15
15
|
super(`list.${type}`, { bubbles: true, composed: true });
|
|
16
|
-
|
|
16
|
+
if (args)
|
|
17
|
+
Object.assign(this, args);
|
|
17
18
|
}
|
|
18
19
|
}
|
|
19
20
|
let SortableList = SortableList_1 = class SortableList extends List {
|
|
@@ -64,19 +65,16 @@ let SortableList = SortableList_1 = class SortableList extends List {
|
|
|
64
65
|
}
|
|
65
66
|
if (this.markedItem)
|
|
66
67
|
this.markedItem.classList.remove('target-prev', 'target-next');
|
|
67
|
-
let targetIndex = item.index;
|
|
68
68
|
if (e.offsetY > item.clientHeight / 2) {
|
|
69
|
-
if (this.sortIndex > targetIndex)
|
|
70
|
-
targetIndex++;
|
|
71
69
|
item.classList.add('target-next');
|
|
70
|
+
this.drop = 'after';
|
|
72
71
|
}
|
|
73
72
|
else {
|
|
74
|
-
if (this.sortIndex < targetIndex)
|
|
75
|
-
targetIndex--;
|
|
76
73
|
item.classList.add('target-prev');
|
|
74
|
+
this.drop = 'before';
|
|
77
75
|
}
|
|
78
76
|
this.markedItem = item;
|
|
79
|
-
this.targetIndex =
|
|
77
|
+
this.targetIndex = item.index;
|
|
80
78
|
}
|
|
81
79
|
};
|
|
82
80
|
}
|
|
@@ -94,20 +92,20 @@ let SortableList = SortableList_1 = class SortableList extends List {
|
|
|
94
92
|
this._sorting = false;
|
|
95
93
|
this.stopAutoscroll();
|
|
96
94
|
this.removeMark();
|
|
97
|
-
if (this.targetIndex > -1) {
|
|
98
|
-
|
|
99
|
-
this.
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
}));
|
|
106
|
-
}
|
|
95
|
+
if (this.targetIndex > -1 && dispatchEvent) {
|
|
96
|
+
this.dispatchEvent(new ListSortEvent('sort', {
|
|
97
|
+
fromIndex: (SortableList_1.sourceList ? SortableList_1.sourceList : this).sortIndex,
|
|
98
|
+
toIndex: this.targetIndex,
|
|
99
|
+
sourceList: SortableList_1.sourceList,
|
|
100
|
+
targetList: this,
|
|
101
|
+
drop: this.drop
|
|
102
|
+
}));
|
|
107
103
|
}
|
|
108
104
|
this.targetIndex = -1;
|
|
109
105
|
this.sortIndex = -1;
|
|
110
106
|
SortableList_1.sourceList = null;
|
|
107
|
+
if (dispatchEvent)
|
|
108
|
+
this.dispatchEvent(new ListSortEvent('sortend'));
|
|
111
109
|
}
|
|
112
110
|
startAutoscroll(direction) {
|
|
113
111
|
if (this.autoscrollDirection == direction)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sortableList.js","sourceRoot":"","sources":["../../src/ui/sortableList.ts"],"names":[],"mappings":";;;;;;;AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAC1B,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,IAAI,EAAmB,MAAM,QAAQ,CAAC;AAC/C,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAEhC,OAAO,SAAS,MAAM,cAAc,CAAC;AAMrC,MAAM,OAAO,aAAc,SAAQ,KAAK;IAQvC,YAAY,IAAY,EAAE,IAA4B;QACrD,KAAK,CAAC,QAAQ,IAAI,EAAE,EAAE,EAAC,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAC,CAAC,CAAC;QACvD,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAC3B,CAAC;CAED;AAGM,IAAM,YAAY,oBAAlB,MAAM,YAAa,SAAQ,IAAI;IASrC,IAAI,OAAO,KAAe,OAAO,IAAI,CAAC,QAAQ,CAAA,CAAC,CAAC;IAChD,IAAI,gBAAgB;QACnB,OAAO,IAAI,CAAC,cAAc,IAAI,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC9E,CAAC;IA0BD;QACC,KAAK,EAAE,CAAC;QAjCT,iBAAY,GAAG,KAAK,CAAC;QAEb,aAAQ,GAAG,KAAK,CAAC;QAMjB,cAAS,GAAG,CAAC,CAAC,CAAC;QACf,gBAAW,GAAG,C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,eAAe,CAAC,CAAC;YACpC,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC;YAC5B,IAAI,CAAC,mBAAmB,GAAG,IAAI,CAAC;QACjC,CAAC;IACF,CAAC;IAyDD,YAAY;QACX,KAAK,CAAC,YAAY,EAAE,CAAC;QACrB,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAAC,WAAW,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;QAChE,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAAC,WAAW,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;QAChE,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAAC,SAAS,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;IAC7D,CAAC;;AAxIM,0BAAa,GAAG,CAAC,GAAG,IAAI,CAAC,aAAa,EAAE,GAAG,CAAA;;;;;;;;;;;;;;;;EAgBjD,CAAC,AAhBkB,CAgBjB;AA9BH;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAC,CAAC;kDACpB;AANT,YAAY;IADxB,aAAa,CAAC,iBAAiB,CAAC;GACpB,YAAY,CA8JxB","sourcesContent":["import { css } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\nimport { List, ListItemElement } from './list';\nimport { dom } from '../common';\nimport { Direction } from '../types';\nimport constants from '../constants';\n\nexport interface SortableListItem extends HTMLElement {\n\tmoveHandle?: HTMLElement;\n}\n\nexport class ListSortEvent extends Event {\n\n\treadonly fromIndex: number;\n\treadonly toIndex: number;\n\treadonly sourceList: SortableList;\n\treadonly targetList: SortableList;\n\treadonly drop: 'before'|'after';\n\n\tconstructor(type: string, args: Partial<ListSortEvent>) {\n\t\tsuper(`list.${type}`, {bubbles: true, composed: true});\n\t\tObject.assign(this, args);\n\t}\n\n}\n\n@customElement(`og-sortablelist`)\nexport class SortableList extends List {\n\n\tstatic sourceList: SortableList;\n\tconnectedLists: SortableList[];\n\n\t@property({type: Boolean, reflect: true})\n\tcustomHandle = false;\n\n\tprivate _sorting = false;\n\tget sorting() : boolean { return this._sorting }\n\tget connectedSorting() : boolean { \n\t\treturn this.connectedLists && this.connectedLists.some(list => list.sorting);\n\t}\n\n\tprivate sortIndex = -1;\n\tprivate targetIndex = -1;\n\tprivate markedItem: ListItemElement;\n\tprivate autoscrollTimer: number;\n\tprivate autoscrollDirection: Direction;\n\n\tstatic contentStyles = [...List.contentStyles, css`\n\t\t.item {\n\t\t\tcursor: move !important;\n\t\t}\n\n\t\t:host([customHandle]) .item {\n\t\t\tcursor: default !important;\t\t\t\n\t\t}\n\n\t\t.item.target-prev {\n\t\t\tborder-top: 2px solid var(--og-accent-color);\n\t\t}\n\n\t\t.item.target-next {\n\t\t\tborder-bottom: 2px solid var(--og-accent-color);\n\t\t}\n\t`];\n\n\tconstructor() {\n\t\tsuper();\n\t}\n\n\tstartSorting(item: ListItemElement) {\n\t\tSortableList.sourceList = this;\n\t\tthis._sorting = true;\n\t\tthis.sortIndex = item.index;\n\t\tthis.dispatchEvent(new ListSortEvent('sortstart', {fromIndex: this.sortIndex, sourceList: this}));\n\t\tdocument.body.addEventListener('mouseup', () => this.stopSorting(false), {once: true});\n\t}\n\n\tremoveMark() {\n\t\tthis.markedItem?.classList.remove('target-prev', 'target-next');\n\t}\n\n\tstopSorting(dispatchEvent?: boolean) {\n\t\tthis._sorting = false;\n\t\tthis.stopAutoscroll();\n\t\tthis.removeMark();\n\t\tif (this.targetIndex > -1) {\n\t\t\tif (dispatchEvent) {\n\t\t\t\tthis.dispatchEvent(new ListSortEvent('sort', {\n\t\t\t\t\tfromIndex: (SortableList.sourceList ? SortableList.sourceList : this).sortIndex, \n\t\t\t\t\ttoIndex: this.targetIndex,\n\t\t\t\t\tsourceList: SortableList.sourceList,\n\t\t\t\t\ttargetList: this,\n\t\t\t\t\tdrop: this.markedItem.index > this.targetIndex ? 'before' : 'after'\n\t\t\t\t}));\n\t\t\t}\n\t\t}\n\t\tthis.targetIndex = -1;\n\t\tthis.sortIndex = -1;\n\t\tSortableList.sourceList = null;\n\t}\n\n\tstartAutoscroll(direction: Direction) {\n\t\tif (this.autoscrollDirection == direction) return;\n\t\tthis.autoscrollDirection = direction;\n\t\tthis.autoscrollTimer = window.setInterval(() => {\n\t\t\tif (this.autoscrollDirection == 'down') {\n\t\t\t\tconst offset = Math.min(this.offset + this.itemHeight, this.size * this.itemHeight - this.clientHeight);\n\t\t\t\tif (offset > this.offset) this.scrollToOffset(offset);\n\t\t\t} else {\n\t\t\t\tconst offset = Math.max(0, this.offset - this.itemHeight);\n\t\t\t\tif (offset < this.offset) this.scrollToOffset(offset);\n\t\t\t}\n\t\t}, constants.LIST_AUTOSCROLL_DELAY);\n\t}\n\n\tstopAutoscroll() {\n\t\tif (this.autoscrollTimer != null) {\n\t\t\tclearInterval(this.autoscrollTimer);\n\t\t\tthis.autoscrollTimer = null;\n\t\t\tthis.autoscrollDirection = null;\n\t\t}\n\t}\n\n\t_onMouseDown = (e: MouseEvent) => {\n\t\tconst path = e.composedPath();\n\t\tconst item = path.find((el: HTMLElement) => el.classList && el.classList.contains('item')) as ListItemElement;\n\t\t\n\t\tif (this.customHandle) {\n\t\t\tlet handle = item && (item as SortableListItem).moveHandle;\n\t\t\tif (!handle && item?.firstElementChild) {\n\t\t\t\thandle = (item.firstElementChild as SortableListItem).moveHandle;\n\t\t\t}\n\n\t\t\tif (handle && path.find((el: HTMLElement) => el == handle)) {\n\t\t\t\tthis.startSorting(item);\n\t\t\t}\n\t\t} else if (item) this.startSorting(item);\n\t}\n\n\t_onMouseUp = () => {\n\t\tthis.stopSorting(true);\n\t}\n\n\t_onMouseMove = (e: MouseEvent) => {\n\t\tif (this.sorting || this.connectedSorting) {\n\t\t\tthis.connectedLists?.forEach(list => list.removeMark());\n\n\t\t\tconst item = e.composedPath().find(\n\t\t\t\t(el: HTMLElement) => el.classList && el.classList.contains('item')\n\t\t\t) as ListItemElement;\n\t\t\tif (!(item instanceof HTMLElement)) return;\n\t\t\tconst offset = dom.getElementOffset(item as HTMLElement, this.container);\n\t\t\tconst top = offset.top + e.offsetY;\n\n\t\t\tif (top < constants.LIST_AUTOSCROLL_TRESHOLD) {\n\t\t\t\tthis.startAutoscroll('up');\n\t\t\t} else if (this.container.clientHeight - top < constants.LIST_AUTOSCROLL_TRESHOLD) {\n\t\t\t\tthis.startAutoscroll('down');\n\t\t\t} else {\n\t\t\t\tthis.stopAutoscroll();\n\t\t\t}\n\t\t\t\n\t\t\tif (this.markedItem) this.markedItem.classList.remove('target-prev', 'target-next');\n\n\t\t\tlet targetIndex = item.index;\n\t\t\tif (e.offsetY > item.clientHeight / 2) {\n\t\t\t\tif (this.sortIndex > targetIndex) targetIndex++;\n\t\t\t\titem.classList.add('target-next');\n\t\t\t} else {\n\t\t\t\tif (this.sortIndex < targetIndex) targetIndex--;\n\t\t\t\titem.classList.add('target-prev');\n\t\t\t}\n\n\t\t\tthis.markedItem = item;\n\t\t\tthis.targetIndex = Math.max(0, targetIndex);\n\t\t}\n\t}\n\t\n\tfirstUpdated() {\n\t\tsuper.firstUpdated();\n\t\tthis.container.addEventListener('mousedown', this._onMouseDown);\n\t\tthis.container.addEventListener('mousemove', this._onMouseMove);\n\t\tthis.container.addEventListener('mouseup', this._onMouseUp);\n\t}\n\t\n}"]}
|
|
1
|
+
{"version":3,"file":"sortableList.js","sourceRoot":"","sources":["../../src/ui/sortableList.ts"],"names":[],"mappings":";;;;;;;AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAC1B,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,IAAI,EAAmB,MAAM,QAAQ,CAAC;AAC/C,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAEhC,OAAO,SAAS,MAAM,cAAc,CAAC;AAMrC,MAAM,OAAO,aAAc,SAAQ,KAAK;IAQvC,YAAY,IAAY,EAAE,IAA6B;QACtD,KAAK,CAAC,QAAQ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\nimport { List, ListItemElement } from './list';\nimport { dom } from '../common';\nimport { Direction } from '../types';\nimport constants from '../constants';\n\nexport interface SortableListItem extends HTMLElement {\n\tmoveHandle?: HTMLElement;\n}\n\nexport class ListSortEvent extends Event {\n\n\treadonly fromIndex: number;\n\treadonly toIndex: number;\n\treadonly sourceList: SortableList;\n\treadonly targetList: SortableList;\n\treadonly drop: 'before'|'after';\n\n\tconstructor(type: string, args?: Partial<ListSortEvent>) {\n\t\tsuper(`list.${type}`, {bubbles: true, composed: true});\n\t\tif (args) Object.assign(this, args);\n\t}\n\n}\n\n@customElement(`og-sortablelist`)\nexport class SortableList extends List {\n\n\tstatic sourceList: SortableList;\n\tconnectedLists: SortableList[];\n\n\t@property({type: Boolean, reflect: true})\n\tcustomHandle = false;\n\n\tprivate _sorting = false;\n\tget sorting() : boolean { return this._sorting }\n\tget connectedSorting() : boolean { \n\t\treturn this.connectedLists && this.connectedLists.some(list => list.sorting);\n\t}\n\n\tprivate sortIndex = -1;\n\tprivate targetIndex = -1;\n\tprivate markedItem: ListItemElement;\n\tprivate drop: 'before'|'after';\n\tprivate autoscrollTimer: number;\n\tprivate autoscrollDirection: Direction;\n\n\tstatic contentStyles = [...List.contentStyles, css`\n\t\t.item {\n\t\t\tcursor: move !important;\n\t\t}\n\n\t\t:host([customHandle]) .item {\n\t\t\tcursor: default !important;\t\t\t\n\t\t}\n\n\t\t.item.target-prev {\n\t\t\tborder-top: 2px solid var(--og-accent-color);\n\t\t}\n\n\t\t.item.target-next {\n\t\t\tborder-bottom: 2px solid var(--og-accent-color);\n\t\t}\n\t`];\n\n\tconstructor() {\n\t\tsuper();\n\t}\n\n\tstartSorting(item: ListItemElement) {\n\t\tSortableList.sourceList = this;\n\t\tthis._sorting = true;\n\t\tthis.sortIndex = item.index;\n\t\tthis.dispatchEvent(new ListSortEvent('sortstart', {fromIndex: this.sortIndex, sourceList: this}));\n\t\tdocument.body.addEventListener('mouseup', () => this.stopSorting(false), {once: true});\n\t}\n\n\tremoveMark() {\n\t\tthis.markedItem?.classList.remove('target-prev', 'target-next');\n\t}\n\n\tstopSorting(dispatchEvent?: boolean) {\n\t\tthis._sorting = false;\n\t\tthis.stopAutoscroll();\n\t\tthis.removeMark();\n\n\t\tif (this.targetIndex > -1 && dispatchEvent) {\n\t\t\tthis.dispatchEvent(new ListSortEvent('sort', {\n\t\t\t\tfromIndex: (SortableList.sourceList ? SortableList.sourceList : this).sortIndex, \n\t\t\t\ttoIndex: this.targetIndex,\n\t\t\t\tsourceList: SortableList.sourceList,\n\t\t\t\ttargetList: this,\n\t\t\t\tdrop: this.drop\n\t\t\t}));\n\t\t}\n\n\t\tthis.targetIndex = -1;\n\t\tthis.sortIndex = -1;\n\t\tSortableList.sourceList = null;\n\n\t\tif (dispatchEvent) this.dispatchEvent(new ListSortEvent('sortend'));\n\t}\n\n\tstartAutoscroll(direction: Direction) {\n\t\tif (this.autoscrollDirection == direction) return;\n\t\tthis.autoscrollDirection = direction;\n\t\tthis.autoscrollTimer = window.setInterval(() => {\n\t\t\tif (this.autoscrollDirection == 'down') {\n\t\t\t\tconst offset = Math.min(this.offset + this.itemHeight, this.size * this.itemHeight - this.clientHeight);\n\t\t\t\tif (offset > this.offset) this.scrollToOffset(offset);\n\t\t\t} else {\n\t\t\t\tconst offset = Math.max(0, this.offset - this.itemHeight);\n\t\t\t\tif (offset < this.offset) this.scrollToOffset(offset);\n\t\t\t}\n\t\t}, constants.LIST_AUTOSCROLL_DELAY);\n\t}\n\n\tstopAutoscroll() {\n\t\tif (this.autoscrollTimer != null) {\n\t\t\tclearInterval(this.autoscrollTimer);\n\t\t\tthis.autoscrollTimer = null;\n\t\t\tthis.autoscrollDirection = null;\n\t\t}\n\t}\n\n\t_onMouseDown = (e: MouseEvent) => {\n\t\tconst path = e.composedPath();\n\t\tconst item = path.find((el: HTMLElement) => el.classList && el.classList.contains('item')) as ListItemElement;\n\t\t\n\t\tif (this.customHandle) {\n\t\t\tlet handle = item && (item as SortableListItem).moveHandle;\n\t\t\tif (!handle && item?.firstElementChild) {\n\t\t\t\thandle = (item.firstElementChild as SortableListItem).moveHandle;\n\t\t\t}\n\n\t\t\tif (handle && path.find((el: HTMLElement) => el == handle)) {\n\t\t\t\tthis.startSorting(item);\n\t\t\t}\n\t\t} else if (item) this.startSorting(item);\n\t}\n\n\t_onMouseUp = () => {\n\t\tthis.stopSorting(true);\n\t}\n\n\t_onMouseMove = (e: MouseEvent) => {\n\t\tif (this.sorting || this.connectedSorting) {\n\t\t\tthis.connectedLists?.forEach(list => list.removeMark());\n\n\t\t\tconst item = e.composedPath().find(\n\t\t\t\t(el: HTMLElement) => el.classList && el.classList.contains('item')\n\t\t\t) as ListItemElement;\n\t\t\tif (!(item instanceof HTMLElement)) return;\n\t\t\tconst offset = dom.getElementOffset(item as HTMLElement, this.container);\n\t\t\tconst top = offset.top + e.offsetY;\n\n\t\t\tif (top < constants.LIST_AUTOSCROLL_TRESHOLD) {\n\t\t\t\tthis.startAutoscroll('up');\n\t\t\t} else if (this.container.clientHeight - top < constants.LIST_AUTOSCROLL_TRESHOLD) {\n\t\t\t\tthis.startAutoscroll('down');\n\t\t\t} else {\n\t\t\t\tthis.stopAutoscroll();\n\t\t\t}\n\t\t\t\n\t\t\tif (this.markedItem) this.markedItem.classList.remove('target-prev', 'target-next');\n\n\t\t\tif (e.offsetY > item.clientHeight / 2) {\n\t\t\t\titem.classList.add('target-next');\n\t\t\t\tthis.drop = 'after';\n\t\t\t} else {\n\t\t\t\titem.classList.add('target-prev');\n\t\t\t\tthis.drop = 'before';\n\t\t\t}\n\n\t\t\tthis.markedItem = item;\n\t\t\tthis.targetIndex = item.index;\n\t\t}\n\t}\n\t\n\tfirstUpdated() {\n\t\tsuper.firstUpdated();\n\t\tthis.container.addEventListener('mousedown', this._onMouseDown);\n\t\tthis.container.addEventListener('mousemove', this._onMouseMove);\n\t\tthis.container.addEventListener('mouseup', this._onMouseUp);\n\t}\n\t\n}"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@omegagrid/core",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.91",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"description": "Core components",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@fortawesome/fontawesome-svg-core": "6.4.2",
|
|
39
|
-
"@omegagrid/localize": "^0.6.
|
|
39
|
+
"@omegagrid/localize": "^0.6.91",
|
|
40
40
|
"@riovir/wc-fontawesome": "^0.1.9",
|
|
41
41
|
"color": "^4.2.3",
|
|
42
42
|
"date-fns": "^3.2.0",
|