@humandialog/forms.svelte 1.8.9 → 1.8.10
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,5 +1,5 @@
|
|
|
1
1
|
<script>import { setContext, getContext, afterUpdate, tick } from "svelte";
|
|
2
|
-
import { KanbanColumnBottom, KanbanColumnTop, rKanban_definition } from "./Kanban";
|
|
2
|
+
import { KanbanColumnBottom, KanbanColumnTop, rKanban_definition, rKanban_column } from "./Kanban";
|
|
3
3
|
import { parseWidthDirective, clearActiveItem, getPrev, getNext, remove, insertAt, insertAfter, swapElements, getActive } from "../../utils";
|
|
4
4
|
import { contextItemsStore, contextTypesStore, data_tick_store } from "../../stores";
|
|
5
5
|
import KanbanColumn from "./internal/kanban.column.svelte";
|
|
@@ -102,7 +102,7 @@ export async function reload(data, selectElement = KEEP_SELECTION) {
|
|
|
102
102
|
else
|
|
103
103
|
definition.self = data;
|
|
104
104
|
definition.items = null;
|
|
105
|
-
columns
|
|
105
|
+
columns?.forEach((c2) => c2?.reload());
|
|
106
106
|
await tick();
|
|
107
107
|
allItems = definition.getItems();
|
|
108
108
|
if (selectElementId > 0) {
|
|
@@ -192,6 +192,74 @@ export function moveDown(item) {
|
|
|
192
192
|
pushChanges();
|
|
193
193
|
column.reload();
|
|
194
194
|
}
|
|
195
|
+
export function moveTop(item) {
|
|
196
|
+
let allItems = definition.getItems();
|
|
197
|
+
const oa = definition.orderAttrib;
|
|
198
|
+
const sa = definition.stateAttrib;
|
|
199
|
+
const columnIdx = getColumnIdx(item);
|
|
200
|
+
const columnState = definition.columns[columnIdx].state;
|
|
201
|
+
const toListTop = allItems.find((e) => e[sa] == columnState);
|
|
202
|
+
const toListBottom = allItems.findLast((e) => e[sa] == columnState);
|
|
203
|
+
if (item == toListTop)
|
|
204
|
+
return;
|
|
205
|
+
const columnElement = columns[columnIdx];
|
|
206
|
+
const prevItem = getPrev(allItems, toListTop);
|
|
207
|
+
if (!prevItem) {
|
|
208
|
+
item[oa] = toListTop[oa] - ORDER_STEP;
|
|
209
|
+
informModification(item, oa);
|
|
210
|
+
remove(allItems, item);
|
|
211
|
+
insertAt(allItems, 0, item);
|
|
212
|
+
} else {
|
|
213
|
+
let prevOrder = prevItem[oa];
|
|
214
|
+
let nextOrder = toListTop[oa];
|
|
215
|
+
let orderSpace = nextOrder - prevOrder;
|
|
216
|
+
if (orderSpace < 2) {
|
|
217
|
+
reorderElements(allItems, prevItem, false);
|
|
218
|
+
prevOrder = prevItem[oa];
|
|
219
|
+
nextOrder = toListTop[oa];
|
|
220
|
+
orderSpace = nextOrder - prevOrder;
|
|
221
|
+
}
|
|
222
|
+
item[oa] = prevOrder + Math.floor(orderSpace / 2);
|
|
223
|
+
informModification(item, oa);
|
|
224
|
+
remove(allItems, item);
|
|
225
|
+
insertAfter(allItems, prevItem, item);
|
|
226
|
+
}
|
|
227
|
+
columnElement.reload();
|
|
228
|
+
}
|
|
229
|
+
export function moveBottom(item) {
|
|
230
|
+
let allItems = definition.getItems();
|
|
231
|
+
const oa = definition.orderAttrib;
|
|
232
|
+
const sa = definition.stateAttrib;
|
|
233
|
+
const columnIdx = getColumnIdx(item);
|
|
234
|
+
const columnState = definition.columns[columnIdx].state;
|
|
235
|
+
const toListTop = allItems.find((e) => e[sa] == columnState);
|
|
236
|
+
const toListBottom = allItems.findLast((e) => e[sa] == columnState);
|
|
237
|
+
if (item == toListBottom)
|
|
238
|
+
return;
|
|
239
|
+
const columnElement = columns[columnIdx];
|
|
240
|
+
const nextItem = getNext(allItems, toListBottom);
|
|
241
|
+
if (!nextItem) {
|
|
242
|
+
item[oa] = toListBottom[oa] + ORDER_STEP;
|
|
243
|
+
informModification(item, oa);
|
|
244
|
+
remove(allItems, item);
|
|
245
|
+
insertAfter(allItems, toListBottom, item);
|
|
246
|
+
} else {
|
|
247
|
+
let nextOrder = nextItem[oa];
|
|
248
|
+
let prevOrder = toListBottom[oa];
|
|
249
|
+
let orderSpace = nextOrder - prevOrder;
|
|
250
|
+
if (orderSpace < 2) {
|
|
251
|
+
reorderElements(allItems, toListBottom, false);
|
|
252
|
+
prevOrder = toListBottom[oa];
|
|
253
|
+
nextOrder = nextItem[oa];
|
|
254
|
+
orderSpace = nextOrder - prevOrder;
|
|
255
|
+
}
|
|
256
|
+
item[oa] = prevOrder + Math.floor(orderSpace / 2);
|
|
257
|
+
informModification(item, oa);
|
|
258
|
+
remove(allItems, item);
|
|
259
|
+
insertAfter(allItems, toListBottom, item);
|
|
260
|
+
}
|
|
261
|
+
columnElement.reload();
|
|
262
|
+
}
|
|
195
263
|
const ORDER_STEP = 64;
|
|
196
264
|
const MIN_ORDER = 0;
|
|
197
265
|
function reorderElements(items, from = null, pushImediatelly = true) {
|
|
@@ -426,13 +494,26 @@ export function setCardsState(items, state) {
|
|
|
426
494
|
item[sa] = state;
|
|
427
495
|
informModification(item, sa);
|
|
428
496
|
});
|
|
429
|
-
pushChanges();
|
|
430
497
|
}
|
|
431
498
|
export function add(item, columnIdx = -1) {
|
|
432
499
|
if (columnIdx < 0)
|
|
433
500
|
columnIdx = getColumnIdx(item);
|
|
434
501
|
columns[columnIdx].add(item);
|
|
435
502
|
}
|
|
503
|
+
export function setColumns(columnsDefinition) {
|
|
504
|
+
definition.columns = [];
|
|
505
|
+
columnsDefinition.forEach((c2) => {
|
|
506
|
+
let column = new rKanban_column();
|
|
507
|
+
column.id = definition.columns.length + 1;
|
|
508
|
+
column.title = c2.title;
|
|
509
|
+
column.width = c2.width ?? "";
|
|
510
|
+
column.state = c2.state;
|
|
511
|
+
column.finishing = c2.finishing ?? false;
|
|
512
|
+
column.operations = c2.operations ?? void 0;
|
|
513
|
+
column.onTitleChanged = c2.onTitleChanged ?? void 0;
|
|
514
|
+
definition.columns.push(column);
|
|
515
|
+
});
|
|
516
|
+
}
|
|
436
517
|
</script>
|
|
437
518
|
|
|
438
519
|
{#key renderToken}
|
|
@@ -455,7 +536,7 @@ export function add(item, columnIdx = -1) {
|
|
|
455
536
|
divide-stone-500 dark:divide-stone-700
|
|
456
537
|
pb-20
|
|
457
538
|
"> <!--sm:justify-center -->
|
|
458
|
-
{#each definition.columns as column, idx (column.
|
|
539
|
+
{#each definition.columns as column, idx (column.title + column.state)}
|
|
459
540
|
<KanbanColumn currentColumnIdx={idx}
|
|
460
541
|
{onInsert}
|
|
461
542
|
bind:this={columns[idx]}>
|
|
@@ -20,12 +20,15 @@ declare const __propDef: {
|
|
|
20
20
|
scrollViewToCard?: ((item: any) => void) | undefined;
|
|
21
21
|
moveUp?: ((item: object) => void) | undefined;
|
|
22
22
|
moveDown?: ((item: object) => void) | undefined;
|
|
23
|
+
moveTop?: ((item: object) => void) | undefined;
|
|
24
|
+
moveBottom?: ((item: object) => void) | undefined;
|
|
23
25
|
replace?: ((item: any, toColumnIdx: any, afterElement: any) => Promise<void>) | undefined;
|
|
24
26
|
activateColumn?: ((columnIdx: number) => void) | undefined;
|
|
25
27
|
editColumnName?: ((columnIdx: number, onFinish?: Function | undefined) => void) | undefined;
|
|
26
28
|
moveCardsTo?: ((items: object[], toColumnIdx: number) => void) | undefined;
|
|
27
29
|
setCardsState?: ((items: object[], state: number) => void) | undefined;
|
|
28
30
|
add?: ((item: object | number, columnIdx?: number) => void) | undefined;
|
|
31
|
+
setColumns?: ((columnsDefinition: any) => void) | undefined;
|
|
29
32
|
};
|
|
30
33
|
events: {
|
|
31
34
|
[evt: string]: CustomEvent<any>;
|
|
@@ -61,11 +64,14 @@ export default class Kanban extends SvelteComponentTyped<KanbanProps, KanbanEven
|
|
|
61
64
|
get scrollViewToCard(): (item: any) => void;
|
|
62
65
|
get moveUp(): (item: object) => void;
|
|
63
66
|
get moveDown(): (item: object) => void;
|
|
67
|
+
get moveTop(): (item: object) => void;
|
|
68
|
+
get moveBottom(): (item: object) => void;
|
|
64
69
|
get replace(): (item: any, toColumnIdx: any, afterElement: any) => Promise<void>;
|
|
65
70
|
get activateColumn(): (columnIdx: number) => void;
|
|
66
71
|
get editColumnName(): (columnIdx: number, onFinish?: Function | undefined) => void;
|
|
67
72
|
get moveCardsTo(): (items: object[], toColumnIdx: number) => void;
|
|
68
73
|
get setCardsState(): (items: object[], state: number) => void;
|
|
69
74
|
get add(): (item: number | object, columnIdx?: number) => void;
|
|
75
|
+
get setColumns(): (columnsDefinition: any) => void;
|
|
70
76
|
}
|
|
71
77
|
export {};
|
package/modal.svelte
CHANGED
|
@@ -37,6 +37,15 @@ export function hide() {
|
|
|
37
37
|
preventScrollRestorer = null;
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
|
+
export function setTitle(t) {
|
|
41
|
+
title = t;
|
|
42
|
+
}
|
|
43
|
+
export function setOkCaption(cap) {
|
|
44
|
+
okCaption = cap;
|
|
45
|
+
}
|
|
46
|
+
export function setCancelCaption(cap) {
|
|
47
|
+
cancelCaption = cap;
|
|
48
|
+
}
|
|
40
49
|
let root;
|
|
41
50
|
afterUpdate(
|
|
42
51
|
async () => {
|
package/modal.svelte.d.ts
CHANGED
|
@@ -16,6 +16,9 @@ declare const __propDef: {
|
|
|
16
16
|
onCancelCallback?: Function | undefined;
|
|
17
17
|
show?: ((on_close_callback?: Function | undefined) => void) | undefined;
|
|
18
18
|
hide?: (() => void) | undefined;
|
|
19
|
+
setTitle?: ((t: string) => void) | undefined;
|
|
20
|
+
setOkCaption?: ((cap: string) => void) | undefined;
|
|
21
|
+
setCancelCaption?: ((cap: string) => void) | undefined;
|
|
19
22
|
};
|
|
20
23
|
events: {
|
|
21
24
|
[evt: string]: CustomEvent<any>;
|
|
@@ -35,5 +38,8 @@ export default class Modal extends SvelteComponentTyped<ModalProps, ModalEvents,
|
|
|
35
38
|
get Custom(): 3;
|
|
36
39
|
get show(): (on_close_callback?: Function | undefined) => void;
|
|
37
40
|
get hide(): () => void;
|
|
41
|
+
get setTitle(): (t: string) => void;
|
|
42
|
+
get setOkCaption(): (cap: string) => void;
|
|
43
|
+
get setCancelCaption(): (cap: string) => void;
|
|
38
44
|
}
|
|
39
45
|
export {};
|