aloha-vue 2.58.0 → 2.60.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 (33) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/aloha-vue.css +5 -0
  3. package/dist/aloha-vue.css.map +1 -1
  4. package/dist/aloha-vue.es.js +12294 -12208
  5. package/dist/aloha-vue.umd.js +48 -46
  6. package/package.json +1 -1
  7. package/scss/components/ATableForm.scss +261 -256
  8. package/src/ATableForm/ATableForm.js +613 -606
  9. package/src/ATableForm/ATableFormCellDnd/ATableFormCellDnd.js +182 -176
  10. package/src/ATableForm/__tests__/ATableForm.DragAndDropAPI.test.js +162 -0
  11. package/src/ATableForm/compositionAPI/DragAndDropAPI.js +302 -268
  12. package/src/ATableForm/compositionAPI/TextsAPI.js +35 -34
  13. package/src/ATableForm/i18n/ar.json +18 -17
  14. package/src/ATableForm/i18n/de.json +18 -17
  15. package/src/ATableForm/i18n/en.json +18 -17
  16. package/src/ATableForm/i18n/es.json +18 -17
  17. package/src/ATableForm/i18n/fr.json +18 -17
  18. package/src/ATableForm/i18n/hr.json +18 -17
  19. package/src/ATableForm/i18n/it.json +18 -17
  20. package/src/ATableForm/i18n/ru.json +18 -17
  21. package/src/plugins/AMultiselectOrderedPlugin.js +1 -0
  22. package/src/plugins/ASelectPlugin.js +5 -4
  23. package/src/ui/ACheckbox/ACheckbox.js +10 -5
  24. package/src/ui/AMultiselectOrdered/AMultiselectOrdered.js +13 -7
  25. package/src/ui/ARadio/ARadio.js +10 -5
  26. package/src/ui/ASelect/ASelect.js +18 -11
  27. package/src/ui/ASelect/ASelectValueCloseable/ASelectValueCloseable.js +5 -0
  28. package/src/ui/ASelect/ASelectValueCloseable/compositionAPI/GroupAPI.js +17 -2
  29. package/src/ui/ASelect/compositionAPI/SelectedTitleAPI.js +17 -2
  30. package/src/ui/ASelectIcon/ASelectIcon.js +11 -6
  31. package/src/ui/ASelectStyle/ASelectStyle.js +11 -6
  32. package/src/ui/compositionApi/UIDataGroupAPI.js +52 -39
  33. package/src/ui/compositionApi/__tests__/UIDataGroupAPI.test.js +106 -0
@@ -1,606 +1,613 @@
1
- import {
2
- computed,
3
- h,
4
- onBeforeUnmount,
5
- onMounted,
6
- toRef,
7
- } from "vue";
8
-
9
- import AButton from "../AButton/AButton";
10
- import ARequired from "../ui/ARequired/ARequired";
11
- import ATableFormRow from "./ATableFormRow/ATableFormRow";
12
- import ATranslation from "../ATranslation/ATranslation";
13
-
14
- import ClassesAPI from "./compositionAPI/ClassesAPI";
15
- import ColumnsAPI from "./compositionAPI/ColumnsAPI";
16
- import ColumnsGrowAPI from "./compositionAPI/ColumnsGrowAPI";
17
- import DeleteAPI from "./compositionAPI/DeleteAPI";
18
- import DragAndDropAPI from "./compositionAPI/DragAndDropAPI";
19
- import EditAPI from "./compositionAPI/EditAPI";
20
- import IconsAPI from "./compositionAPI/IconsAPI";
21
- import RowsAPI from "./compositionAPI/RowsAPI";
22
- import TextsAPI from "./compositionAPI/TextsAPI";
23
- import WidthsAPI from "./compositionAPI/WidthsAPI";
24
-
25
- import ExclamationCircleFill from "aloha-svg/dist/js/bootstrap/ExclamationCircleFill";
26
- import {
27
- get,
28
- isFunction,
29
- uniqueId,
30
- } from "lodash-es";
31
-
32
- export default {
33
- name: "ATableForm",
34
- props: {
35
- actionsClasses: {
36
- type: Object,
37
- required: false,
38
- default: () => ({}),
39
- },
40
- actionsDisabledCallback: {
41
- type: Object,
42
- required: false,
43
- default: () => ({}),
44
- },
45
- actionsHideCallback: {
46
- type: Object,
47
- required: false,
48
- default: () => ({}),
49
- },
50
- actionsTitleCallback: {
51
- type: Object,
52
- required: false,
53
- default: () => ({}),
54
- },
55
- addRow: {
56
- type: Function,
57
- required: false,
58
- default: undefined,
59
- },
60
- columns: {
61
- type: Array,
62
- required: true,
63
- },
64
- columnsDefaultValue: {
65
- type: [String, Number],
66
- required: false,
67
- default: "",
68
- },
69
- changeModel: {
70
- type: Function,
71
- required: false,
72
- default: undefined,
73
- },
74
- errorIcon: {
75
- type: String,
76
- required: false,
77
- default: ExclamationCircleFill,
78
- },
79
- extra: {
80
- type: Object,
81
- required: false,
82
- default: undefined,
83
- },
84
- focusAfterMove: {
85
- type: Boolean,
86
- required: false,
87
- default: true,
88
- },
89
- icons: {
90
- type: Object,
91
- required: false,
92
- default: () => ({}),
93
- },
94
- id: {
95
- type: String,
96
- required: false,
97
- default: () => uniqueId("a_table_form_"),
98
- },
99
- isActionsSticky: {
100
- type: Boolean,
101
- required: false,
102
- default: false,
103
- },
104
- isAddable: {
105
- type: Boolean,
106
- required: false,
107
- default: false,
108
- },
109
- isColumnsGrow: {
110
- type: Boolean,
111
- required: false,
112
- default: false,
113
- },
114
- isDeletable: {
115
- type: Boolean,
116
- required: false,
117
- default: false,
118
- },
119
- isDeletableConfirm: {
120
- type: Boolean,
121
- required: false,
122
- default: false,
123
- },
124
- isDragAndDrop: {
125
- type: Boolean,
126
- required: false,
127
- default: false,
128
- },
129
- isEditable: {
130
- type: Boolean,
131
- required: false,
132
- default: false,
133
- },
134
- keyId: {
135
- type: String,
136
- required: false,
137
- default: undefined,
138
- },
139
- label: {
140
- type: [String, Number],
141
- required: false,
142
- default: "",
143
- },
144
- labelClass: {
145
- type: [String, Object, Array],
146
- required: false,
147
- default: undefined,
148
- },
149
- labelTag: {
150
- type: String,
151
- required: false,
152
- default: "h2",
153
- },
154
- prepareEditModel: {
155
- type: Function,
156
- required: false,
157
- default: undefined,
158
- },
159
- rowClass: {
160
- type: [String, Object, Array, Function],
161
- required: false,
162
- default: undefined,
163
- },
164
- rows: {
165
- type: Array,
166
- required: false,
167
- default: () => [],
168
- },
169
- rowsFooter: {
170
- type: Array,
171
- required: false,
172
- default: () => [],
173
- },
174
- saveRow: {
175
- type: Function,
176
- required: false,
177
- default: () => undefined,
178
- },
179
- texts: {
180
- type: Object,
181
- required: false,
182
- default: () => ({}),
183
- },
184
- widths: {
185
- type: Object,
186
- required: false,
187
- default: () => ({}),
188
- },
189
- },
190
- emits: [
191
- "deleteRow",
192
- "moveRow",
193
- "updateRows",
194
- ],
195
- setup(props, context) {
196
- const actionsDisabledCallback = toRef(props, "actionsDisabledCallback");
197
- const actionsTitleCallback = toRef(props, "actionsTitleCallback");
198
-
199
- const {
200
- allColumnsLength,
201
- columnsVisible,
202
- hasActionsColumn,
203
- } = ColumnsAPI(props);
204
-
205
- const {
206
- getRowKey,
207
- hasRows,
208
- hasRowsFooter,
209
- } = RowsAPI(props);
210
-
211
- const {
212
- textsLocal,
213
- } = TextsAPI(props);
214
-
215
- const {
216
- widthsLocal,
217
- } = WidthsAPI(props);
218
-
219
- const {
220
- iconsLocal,
221
- } = IconsAPI(props);
222
-
223
- const {
224
- actionsClassesLocal,
225
- } = ClassesAPI(props);
226
-
227
- const {
228
- columnsStylesGrow,
229
- destroyColumnsGrowObserver,
230
- initColumnsGrowObserver,
231
- } = ColumnsGrowAPI(props, {
232
- columnsVisible,
233
- hasActionsColumn,
234
- widthsLocal,
235
- });
236
-
237
- onMounted(() => {
238
- initColumnsGrowObserver();
239
- });
240
-
241
- onBeforeUnmount(() => {
242
- destroyColumnsGrowObserver();
243
- });
244
-
245
- const {
246
- activeEditRowKey,
247
- activeEditModel,
248
- canAddRow,
249
- hasActiveEditRow,
250
- hasRequiredEditableColumns,
251
- isAddRowActive,
252
- onAddRow,
253
- onCancelEditRow,
254
- onEditRow,
255
- } = EditAPI(props, {
256
- columnsVisible,
257
- getRowKey,
258
- });
259
-
260
- const {
261
- canMoveRowDown,
262
- canMoveRowUp,
263
- dragOverPosition,
264
- dragOverRowIndex,
265
- draggedRowIndex,
266
- moveRowDown,
267
- moveRowUp,
268
- onDragend,
269
- onDragleave,
270
- onDragover,
271
- onDragstart,
272
- onDrop,
273
- } = DragAndDropAPI(props, context, {
274
- isDndDisabled: hasActiveEditRow,
275
- });
276
-
277
- const {
278
- onDeleteRow,
279
- } = DeleteAPI(props, context);
280
-
281
- const isAddDisabled = computed(() => {
282
- if (hasActiveEditRow.value) {
283
- return true;
284
- }
285
-
286
- const addDisabledCallback = get(actionsDisabledCallback.value, "add");
287
-
288
- if (isFunction(addDisabledCallback)) {
289
- return addDisabledCallback();
290
- }
291
-
292
- return false;
293
- });
294
-
295
- const addTitle = computed(() => {
296
- const addTitleCallback = get(actionsTitleCallback.value, "add");
297
-
298
- if (isFunction(addTitleCallback)) {
299
- return addTitleCallback();
300
- }
301
-
302
- return textsLocal.value.actionAddRow;
303
- });
304
-
305
- return {
306
- activeEditRowKey,
307
- activeEditModel,
308
- allColumnsLength,
309
- addTitle,
310
- canAddRow,
311
- canMoveRowDown,
312
- canMoveRowUp,
313
- actionsClassesLocal,
314
- columnsStylesGrow,
315
- columnsVisible,
316
- draggedRowIndex,
317
- dragOverPosition,
318
- dragOverRowIndex,
319
- getRowKey,
320
- hasActionsColumn,
321
- hasActiveEditRow,
322
- hasRequiredEditableColumns,
323
- hasRows,
324
- hasRowsFooter,
325
- iconsLocal,
326
- isAddDisabled,
327
- isAddRowActive,
328
- moveRowDown,
329
- moveRowUp,
330
- onAddRow,
331
- onCancelEditRow,
332
- onDeleteRow,
333
- onDragend,
334
- onDragleave,
335
- onDragover,
336
- onDragstart,
337
- onDrop,
338
- onEditRow,
339
- textsLocal,
340
- widthsLocal,
341
- };
342
- },
343
- render() {
344
- return h("div", {
345
- class: "a_table_form",
346
- }, [
347
- this.label && h(ATranslation, {
348
- class: [
349
- "a_table_form__label",
350
- this.labelClass,
351
- ],
352
- html: this.label,
353
- tag: this.labelTag,
354
- }),
355
- this.hasRequiredEditableColumns && h(ARequired),
356
- h("div", {
357
- class: "a_table_form__wrapper",
358
- }, [
359
- h("table", {
360
- id: this.id,
361
- class: [
362
- "a_table_form__table",
363
- {
364
- a_table_form_drag_active: this.draggedRowIndex !== undefined,
365
- },
366
- ],
367
- }, [
368
- h("thead", {
369
- class: "a_table_form__head",
370
- }, [
371
- h(ATableFormRow, {
372
- id: this.id,
373
- actionsClasses: this.actionsClasses,
374
- actionsDisabledCallback: this.actionsDisabledCallback,
375
- actionsHideCallback: this.actionsHideCallback,
376
- actionsTitleCallback: this.actionsTitleCallback,
377
- allColumnsLength: this.allColumnsLength,
378
- canMoveRowDown: this.canMoveRowDown,
379
- canMoveRowUp: this.canMoveRowUp,
380
- cellTag: "th",
381
- changeModel: this.changeModel,
382
- columns: this.columnsVisible,
383
- columnsStylesGrow: this.columnsStylesGrow,
384
- draggedRowIndex: this.draggedRowIndex,
385
- extra: this.extra,
386
- hasActionsColumn: this.hasActionsColumn,
387
- hasActiveEditRow: false,
388
- isActionsSticky: this.isActionsSticky,
389
- isActiveEditMode: false,
390
- isDeletable: this.isDeletable,
391
- isDeletableConfirm: this.isDeletableConfirm,
392
- isDndDisabled: this.hasActiveEditRow,
393
- isDragAndDrop: this.isDragAndDrop,
394
- isEditable: this.isEditable,
395
- isHeader: true,
396
- moveRowDown: this.moveRowDown,
397
- moveRowUp: this.moveRowUp,
398
- onCancelEditRow: this.onCancelEditRow,
399
- onDeleteRow: this.onDeleteRow,
400
- onDragend: this.onDragend,
401
- onDragstart: this.onDragstart,
402
- onEditRow: this.onEditRow,
403
- row: {},
404
- rowIndex: 0,
405
- rows: this.rows,
406
- saveRow: this.saveRow,
407
- texts: this.textsLocal,
408
- trClass: "a_table_form__row a_table_form__row_head",
409
- widths: this.widthsLocal,
410
- }, this.$slots),
411
- ]),
412
- h("tbody", {
413
- class: "a_table_form__body",
414
- }, this.hasRows || this.isAddRowActive ?
415
- [
416
- ...this.rows.map((row, rowIndex) => {
417
- const rowKey = this.getRowKey({
418
- row,
419
- rowIndex,
420
- });
421
-
422
- return h(ATableFormRow, {
423
- key: rowKey,
424
- id: this.id,
425
- actionsClasses: this.actionsClassesLocal,
426
- actionsDisabledCallback: this.actionsDisabledCallback,
427
- actionsHideCallback: this.actionsHideCallback,
428
- actionsTitleCallback: this.actionsTitleCallback,
429
- allColumnsLength: this.allColumnsLength,
430
- canMoveRowDown: this.canMoveRowDown,
431
- canMoveRowUp: this.canMoveRowUp,
432
- changeModel: this.changeModel,
433
- columns: this.columnsVisible,
434
- columnsStylesGrow: this.columnsStylesGrow,
435
- draggedRowIndex: this.draggedRowIndex,
436
- editModel: this.activeEditRowKey === rowKey ? this.activeEditModel : undefined,
437
- errorIcon: this.errorIcon,
438
- extra: this.extra,
439
- hasActionsColumn: this.hasActionsColumn,
440
- hasActiveEditRow: this.hasActiveEditRow,
441
- isActionsSticky: this.isActionsSticky,
442
- isActiveEditMode: this.activeEditRowKey === rowKey,
443
- isCreateMode: false,
444
- isDeletable: this.isDeletable,
445
- isDeletableConfirm: this.isDeletableConfirm,
446
- isDndDisabled: this.hasActiveEditRow,
447
- isDragAndDrop: this.isDragAndDrop,
448
- isEditable: this.isEditable,
449
- moveRowDown: this.moveRowDown,
450
- moveRowUp: this.moveRowUp,
451
- onCancelEditRow: this.onCancelEditRow,
452
- onDeleteRow: this.onDeleteRow,
453
- onDragend: this.onDragend,
454
- onDragleave: this.onDragleave,
455
- onDragover: this.onDragover,
456
- onDragstart: this.onDragstart,
457
- onDrop: this.onDrop,
458
- onEditRow: this.onEditRow,
459
- row,
460
- rowClass: this.rowClass,
461
- rowIndex,
462
- rows: this.rows,
463
- saveRow: this.saveRow,
464
- texts: this.textsLocal,
465
- widths: this.widthsLocal,
466
- trClass: [
467
- "a_table_form__row",
468
- {
469
- a_table_form__row_drag_after: this.dragOverRowIndex === rowIndex &&
470
- this.dragOverPosition === "after",
471
- a_table_form__row_drag_before: this.dragOverRowIndex === rowIndex &&
472
- this.dragOverPosition === "before",
473
- a_table_form__row_drag_over: this.dragOverRowIndex === rowIndex,
474
- a_table_form__row_dragging: this.draggedRowIndex === rowIndex,
475
- },
476
- ],
477
- }, this.$slots);
478
- }),
479
- this.isAddRowActive && h(ATableFormRow, {
480
- id: this.id,
481
- actionsClasses: this.actionsClassesLocal,
482
- actionsDisabledCallback: this.actionsDisabledCallback,
483
- actionsHideCallback: this.actionsHideCallback,
484
- actionsTitleCallback: this.actionsTitleCallback,
485
- allColumnsLength: this.allColumnsLength,
486
- canMoveRowDown: this.canMoveRowDown,
487
- canMoveRowUp: this.canMoveRowUp,
488
- changeModel: this.changeModel,
489
- columns: this.columnsVisible,
490
- columnsStylesGrow: this.columnsStylesGrow,
491
- draggedRowIndex: this.draggedRowIndex,
492
- editModel: this.activeEditModel,
493
- errorIcon: this.errorIcon,
494
- extra: this.extra,
495
- hasActionsColumn: this.hasActionsColumn,
496
- hasActiveEditRow: this.hasActiveEditRow,
497
- isActionsSticky: this.isActionsSticky,
498
- isActiveEditMode: true,
499
- isCreateMode: true,
500
- isDeletable: false,
501
- isDeletableConfirm: false,
502
- isDndDisabled: true,
503
- isDragAndDrop: this.isDragAndDrop,
504
- isEditable: this.isEditable,
505
- key: "body_create",
506
- moveRowDown: this.moveRowDown,
507
- moveRowUp: this.moveRowUp,
508
- onCancelEditRow: this.onCancelEditRow,
509
- onDeleteRow: this.onDeleteRow,
510
- onDragend: this.onDragend,
511
- onDragleave: this.onDragleave,
512
- onDragover: this.onDragover,
513
- onDragstart: this.onDragstart,
514
- onDrop: this.onDrop,
515
- onEditRow: this.onEditRow,
516
- row: {},
517
- rowClass: this.rowClass,
518
- rowIndex: this.rows.length,
519
- rows: this.rows,
520
- saveRow: this.addRow,
521
- texts: this.textsLocal,
522
- trClass: "a_table_form__row a_table_form__row_create",
523
- widths: this.widthsLocal,
524
- }, this.$slots),
525
- ] :
526
- [h("tr", {
527
- class: "a_table_form__row a_table_form__row_empty",
528
- }, [
529
- h("td", {
530
- class: "a_table_form__cell a_table_form__empty",
531
- colspan: this.allColumnsLength,
532
- }, [
533
- h(ATranslation, {
534
- tag: "span",
535
- text: this.textsLocal.emptyText,
536
- }),
537
- ]),
538
- ])]),
539
- this.hasRowsFooter && h("tfoot", {
540
- class: "a_table_form__foot",
541
- }, this.rowsFooter.map((row, rowIndex) => {
542
- return h(ATableFormRow, {
543
- id: this.id,
544
- actionsClasses: this.actionsClassesLocal,
545
- actionsDisabledCallback: this.actionsDisabledCallback,
546
- actionsHideCallback: this.actionsHideCallback,
547
- actionsTitleCallback: this.actionsTitleCallback,
548
- allColumnsLength: this.allColumnsLength,
549
- canMoveRowDown: this.canMoveRowDown,
550
- canMoveRowUp: this.canMoveRowUp,
551
- changeModel: this.changeModel,
552
- columns: this.columnsVisible,
553
- columnsStylesGrow: this.columnsStylesGrow,
554
- draggedRowIndex: this.draggedRowIndex,
555
- extra: this.extra,
556
- hasActionsColumn: this.hasActionsColumn,
557
- hasActiveEditRow: this.hasActiveEditRow,
558
- isActionsSticky: this.isActionsSticky,
559
- isActiveEditMode: false,
560
- isDeletable: this.isDeletable,
561
- isDeletableConfirm: this.isDeletableConfirm,
562
- isDndDisabled: this.hasActiveEditRow,
563
- isDragAndDrop: this.isDragAndDrop,
564
- isEditable: this.isEditable,
565
- isFooter: true,
566
- key: this.getRowKey({
567
- isFooter: true,
568
- row,
569
- rowIndex,
570
- }),
571
- moveRowDown: this.moveRowDown,
572
- moveRowUp: this.moveRowUp,
573
- onCancelEditRow: this.onCancelEditRow,
574
- onDeleteRow: this.onDeleteRow,
575
- onDragend: this.onDragend,
576
- onDragstart: this.onDragstart,
577
- onEditRow: this.onEditRow,
578
- row,
579
- rowClass: this.rowClass,
580
- rowIndex,
581
- rows: this.rowsFooter,
582
- saveRow: this.saveRow,
583
- texts: this.textsLocal,
584
- widths: this.widthsLocal,
585
- trClass: "a_table_form__row a_table_form__row_footer",
586
- }, this.$slots);
587
- })),
588
- ]),
589
- ]),
590
- this.canAddRow && h("div", {
591
- class: "a_mt_3 a_text_right",
592
- }, [
593
- h(AButton, {
594
- class: this.actionsClassesLocal.addRow,
595
- disabled: this.isAddDisabled,
596
- extra: this.extra,
597
- iconLeft: this.iconsLocal.actionAddRow,
598
- text: this.textsLocal.actionAddRow,
599
- textScreenReader: this.addTitle,
600
- title: this.addTitle,
601
- onClick: this.onAddRow,
602
- }),
603
- ]),
604
- ]);
605
- },
606
- };
1
+ import {
2
+ computed,
3
+ h,
4
+ onBeforeUnmount,
5
+ onMounted,
6
+ toRef,
7
+ } from "vue";
8
+
9
+ import AButton from "../AButton/AButton";
10
+ import ARequired from "../ui/ARequired/ARequired";
11
+ import ATableFormRow from "./ATableFormRow/ATableFormRow";
12
+ import ATranslation from "../ATranslation/ATranslation";
13
+
14
+ import ClassesAPI from "./compositionAPI/ClassesAPI";
15
+ import ColumnsAPI from "./compositionAPI/ColumnsAPI";
16
+ import ColumnsGrowAPI from "./compositionAPI/ColumnsGrowAPI";
17
+ import DeleteAPI from "./compositionAPI/DeleteAPI";
18
+ import DragAndDropAPI from "./compositionAPI/DragAndDropAPI";
19
+ import EditAPI from "./compositionAPI/EditAPI";
20
+ import IconsAPI from "./compositionAPI/IconsAPI";
21
+ import RowsAPI from "./compositionAPI/RowsAPI";
22
+ import TextsAPI from "./compositionAPI/TextsAPI";
23
+ import WidthsAPI from "./compositionAPI/WidthsAPI";
24
+
25
+ import ExclamationCircleFill from "aloha-svg/dist/js/bootstrap/ExclamationCircleFill";
26
+ import {
27
+ get,
28
+ isFunction,
29
+ uniqueId,
30
+ } from "lodash-es";
31
+
32
+ export default {
33
+ name: "ATableForm",
34
+ props: {
35
+ actionsClasses: {
36
+ type: Object,
37
+ required: false,
38
+ default: () => ({}),
39
+ },
40
+ actionsDisabledCallback: {
41
+ type: Object,
42
+ required: false,
43
+ default: () => ({}),
44
+ },
45
+ actionsHideCallback: {
46
+ type: Object,
47
+ required: false,
48
+ default: () => ({}),
49
+ },
50
+ actionsTitleCallback: {
51
+ type: Object,
52
+ required: false,
53
+ default: () => ({}),
54
+ },
55
+ addRow: {
56
+ type: Function,
57
+ required: false,
58
+ default: undefined,
59
+ },
60
+ columns: {
61
+ type: Array,
62
+ required: true,
63
+ },
64
+ columnsDefaultValue: {
65
+ type: [String, Number],
66
+ required: false,
67
+ default: "",
68
+ },
69
+ dndDisabledCallback: {
70
+ type: Function,
71
+ required: false,
72
+ default: undefined,
73
+ },
74
+ changeModel: {
75
+ type: Function,
76
+ required: false,
77
+ default: undefined,
78
+ },
79
+ errorIcon: {
80
+ type: String,
81
+ required: false,
82
+ default: ExclamationCircleFill,
83
+ },
84
+ extra: {
85
+ type: Object,
86
+ required: false,
87
+ default: undefined,
88
+ },
89
+ focusAfterMove: {
90
+ type: Boolean,
91
+ required: false,
92
+ default: true,
93
+ },
94
+ icons: {
95
+ type: Object,
96
+ required: false,
97
+ default: () => ({}),
98
+ },
99
+ id: {
100
+ type: String,
101
+ required: false,
102
+ default: () => uniqueId("a_table_form_"),
103
+ },
104
+ isActionsSticky: {
105
+ type: Boolean,
106
+ required: false,
107
+ default: false,
108
+ },
109
+ isAddable: {
110
+ type: Boolean,
111
+ required: false,
112
+ default: false,
113
+ },
114
+ isColumnsGrow: {
115
+ type: Boolean,
116
+ required: false,
117
+ default: false,
118
+ },
119
+ isDeletable: {
120
+ type: Boolean,
121
+ required: false,
122
+ default: false,
123
+ },
124
+ isDeletableConfirm: {
125
+ type: Boolean,
126
+ required: false,
127
+ default: false,
128
+ },
129
+ isDragAndDrop: {
130
+ type: Boolean,
131
+ required: false,
132
+ default: false,
133
+ },
134
+ isEditable: {
135
+ type: Boolean,
136
+ required: false,
137
+ default: false,
138
+ },
139
+ keyId: {
140
+ type: String,
141
+ required: false,
142
+ default: undefined,
143
+ },
144
+ label: {
145
+ type: [String, Number],
146
+ required: false,
147
+ default: "",
148
+ },
149
+ labelClass: {
150
+ type: [String, Object, Array],
151
+ required: false,
152
+ default: undefined,
153
+ },
154
+ labelTag: {
155
+ type: String,
156
+ required: false,
157
+ default: "h2",
158
+ },
159
+ prepareEditModel: {
160
+ type: Function,
161
+ required: false,
162
+ default: undefined,
163
+ },
164
+ rowClass: {
165
+ type: [String, Object, Array, Function],
166
+ required: false,
167
+ default: undefined,
168
+ },
169
+ rows: {
170
+ type: Array,
171
+ required: false,
172
+ default: () => [],
173
+ },
174
+ rowsFooter: {
175
+ type: Array,
176
+ required: false,
177
+ default: () => [],
178
+ },
179
+ saveRow: {
180
+ type: Function,
181
+ required: false,
182
+ default: () => undefined,
183
+ },
184
+ texts: {
185
+ type: Object,
186
+ required: false,
187
+ default: () => ({}),
188
+ },
189
+ widths: {
190
+ type: Object,
191
+ required: false,
192
+ default: () => ({}),
193
+ },
194
+ },
195
+ emits: [
196
+ "deleteRow",
197
+ "moveRow",
198
+ "updateRows",
199
+ ],
200
+ setup(props, context) {
201
+ const actionsDisabledCallback = toRef(props, "actionsDisabledCallback");
202
+ const actionsTitleCallback = toRef(props, "actionsTitleCallback");
203
+
204
+ const {
205
+ allColumnsLength,
206
+ columnsVisible,
207
+ hasActionsColumn,
208
+ } = ColumnsAPI(props);
209
+
210
+ const {
211
+ getRowKey,
212
+ hasRows,
213
+ hasRowsFooter,
214
+ } = RowsAPI(props);
215
+
216
+ const {
217
+ textsLocal,
218
+ } = TextsAPI(props);
219
+
220
+ const {
221
+ widthsLocal,
222
+ } = WidthsAPI(props);
223
+
224
+ const {
225
+ iconsLocal,
226
+ } = IconsAPI(props);
227
+
228
+ const {
229
+ actionsClassesLocal,
230
+ } = ClassesAPI(props);
231
+
232
+ const {
233
+ columnsStylesGrow,
234
+ destroyColumnsGrowObserver,
235
+ initColumnsGrowObserver,
236
+ } = ColumnsGrowAPI(props, {
237
+ columnsVisible,
238
+ hasActionsColumn,
239
+ widthsLocal,
240
+ });
241
+
242
+ onMounted(() => {
243
+ initColumnsGrowObserver();
244
+ });
245
+
246
+ onBeforeUnmount(() => {
247
+ destroyColumnsGrowObserver();
248
+ });
249
+
250
+ const {
251
+ activeEditRowKey,
252
+ activeEditModel,
253
+ canAddRow,
254
+ hasActiveEditRow,
255
+ hasRequiredEditableColumns,
256
+ isAddRowActive,
257
+ onAddRow,
258
+ onCancelEditRow,
259
+ onEditRow,
260
+ } = EditAPI(props, {
261
+ columnsVisible,
262
+ getRowKey,
263
+ });
264
+
265
+ const {
266
+ canMoveRowDown,
267
+ canMoveRowUp,
268
+ dragOverPosition,
269
+ dragOverRowIndex,
270
+ draggedRowIndex,
271
+ isDndDisabledForRow,
272
+ moveRowDown,
273
+ moveRowUp,
274
+ onDragend,
275
+ onDragleave,
276
+ onDragover,
277
+ onDragstart,
278
+ onDrop,
279
+ } = DragAndDropAPI(props, context, {
280
+ isDndDisabled: hasActiveEditRow,
281
+ });
282
+
283
+ const {
284
+ onDeleteRow,
285
+ } = DeleteAPI(props, context);
286
+
287
+ const isAddDisabled = computed(() => {
288
+ if (hasActiveEditRow.value) {
289
+ return true;
290
+ }
291
+
292
+ const addDisabledCallback = get(actionsDisabledCallback.value, "add");
293
+
294
+ if (isFunction(addDisabledCallback)) {
295
+ return addDisabledCallback();
296
+ }
297
+
298
+ return false;
299
+ });
300
+
301
+ const addTitle = computed(() => {
302
+ const addTitleCallback = get(actionsTitleCallback.value, "add");
303
+
304
+ if (isFunction(addTitleCallback)) {
305
+ return addTitleCallback();
306
+ }
307
+
308
+ return textsLocal.value.actionAddRow;
309
+ });
310
+
311
+ return {
312
+ activeEditRowKey,
313
+ activeEditModel,
314
+ allColumnsLength,
315
+ addTitle,
316
+ canAddRow,
317
+ canMoveRowDown,
318
+ canMoveRowUp,
319
+ actionsClassesLocal,
320
+ columnsStylesGrow,
321
+ columnsVisible,
322
+ draggedRowIndex,
323
+ dragOverPosition,
324
+ dragOverRowIndex,
325
+ isDndDisabledForRow,
326
+ getRowKey,
327
+ hasActionsColumn,
328
+ hasActiveEditRow,
329
+ hasRequiredEditableColumns,
330
+ hasRows,
331
+ hasRowsFooter,
332
+ iconsLocal,
333
+ isAddDisabled,
334
+ isAddRowActive,
335
+ moveRowDown,
336
+ moveRowUp,
337
+ onAddRow,
338
+ onCancelEditRow,
339
+ onDeleteRow,
340
+ onDragend,
341
+ onDragleave,
342
+ onDragover,
343
+ onDragstart,
344
+ onDrop,
345
+ onEditRow,
346
+ textsLocal,
347
+ widthsLocal,
348
+ };
349
+ },
350
+ render() {
351
+ return h("div", {
352
+ class: "a_table_form",
353
+ }, [
354
+ this.label && h(ATranslation, {
355
+ class: [
356
+ "a_table_form__label",
357
+ this.labelClass,
358
+ ],
359
+ html: this.label,
360
+ tag: this.labelTag,
361
+ }),
362
+ this.hasRequiredEditableColumns && h(ARequired),
363
+ h("div", {
364
+ class: "a_table_form__wrapper",
365
+ }, [
366
+ h("table", {
367
+ id: this.id,
368
+ class: [
369
+ "a_table_form__table",
370
+ {
371
+ a_table_form_drag_active: this.draggedRowIndex !== undefined,
372
+ },
373
+ ],
374
+ }, [
375
+ h("thead", {
376
+ class: "a_table_form__head",
377
+ }, [
378
+ h(ATableFormRow, {
379
+ id: this.id,
380
+ actionsClasses: this.actionsClasses,
381
+ actionsDisabledCallback: this.actionsDisabledCallback,
382
+ actionsHideCallback: this.actionsHideCallback,
383
+ actionsTitleCallback: this.actionsTitleCallback,
384
+ allColumnsLength: this.allColumnsLength,
385
+ canMoveRowDown: this.canMoveRowDown,
386
+ canMoveRowUp: this.canMoveRowUp,
387
+ cellTag: "th",
388
+ changeModel: this.changeModel,
389
+ columns: this.columnsVisible,
390
+ columnsStylesGrow: this.columnsStylesGrow,
391
+ draggedRowIndex: this.draggedRowIndex,
392
+ extra: this.extra,
393
+ hasActionsColumn: this.hasActionsColumn,
394
+ hasActiveEditRow: false,
395
+ isActionsSticky: this.isActionsSticky,
396
+ isActiveEditMode: false,
397
+ isDeletable: this.isDeletable,
398
+ isDeletableConfirm: this.isDeletableConfirm,
399
+ isDndDisabled: this.hasActiveEditRow,
400
+ isDragAndDrop: this.isDragAndDrop,
401
+ isEditable: this.isEditable,
402
+ isHeader: true,
403
+ moveRowDown: this.moveRowDown,
404
+ moveRowUp: this.moveRowUp,
405
+ onCancelEditRow: this.onCancelEditRow,
406
+ onDeleteRow: this.onDeleteRow,
407
+ onDragend: this.onDragend,
408
+ onDragstart: this.onDragstart,
409
+ onEditRow: this.onEditRow,
410
+ row: {},
411
+ rowIndex: 0,
412
+ rows: this.rows,
413
+ saveRow: this.saveRow,
414
+ texts: this.textsLocal,
415
+ trClass: "a_table_form__row a_table_form__row_head",
416
+ widths: this.widthsLocal,
417
+ }, this.$slots),
418
+ ]),
419
+ h("tbody", {
420
+ class: "a_table_form__body",
421
+ }, this.hasRows || this.isAddRowActive ?
422
+ [
423
+ ...this.rows.map((row, rowIndex) => {
424
+ const rowKey = this.getRowKey({
425
+ row,
426
+ rowIndex,
427
+ });
428
+
429
+ return h(ATableFormRow, {
430
+ key: rowKey,
431
+ id: this.id,
432
+ actionsClasses: this.actionsClassesLocal,
433
+ actionsDisabledCallback: this.actionsDisabledCallback,
434
+ actionsHideCallback: this.actionsHideCallback,
435
+ actionsTitleCallback: this.actionsTitleCallback,
436
+ allColumnsLength: this.allColumnsLength,
437
+ canMoveRowDown: this.canMoveRowDown,
438
+ canMoveRowUp: this.canMoveRowUp,
439
+ changeModel: this.changeModel,
440
+ columns: this.columnsVisible,
441
+ columnsStylesGrow: this.columnsStylesGrow,
442
+ draggedRowIndex: this.draggedRowIndex,
443
+ editModel: this.activeEditRowKey === rowKey ? this.activeEditModel : undefined,
444
+ errorIcon: this.errorIcon,
445
+ extra: this.extra,
446
+ hasActionsColumn: this.hasActionsColumn,
447
+ hasActiveEditRow: this.hasActiveEditRow,
448
+ isActionsSticky: this.isActionsSticky,
449
+ isActiveEditMode: this.activeEditRowKey === rowKey,
450
+ isCreateMode: false,
451
+ isDeletable: this.isDeletable,
452
+ isDeletableConfirm: this.isDeletableConfirm,
453
+ isDndDisabled: this.isDndDisabledForRow(rowIndex),
454
+ isDragAndDrop: this.isDragAndDrop,
455
+ isEditable: this.isEditable,
456
+ moveRowDown: this.moveRowDown,
457
+ moveRowUp: this.moveRowUp,
458
+ onCancelEditRow: this.onCancelEditRow,
459
+ onDeleteRow: this.onDeleteRow,
460
+ onDragend: this.onDragend,
461
+ onDragleave: this.onDragleave,
462
+ onDragover: this.onDragover,
463
+ onDragstart: this.onDragstart,
464
+ onDrop: this.onDrop,
465
+ onEditRow: this.onEditRow,
466
+ row,
467
+ rowClass: this.rowClass,
468
+ rowIndex,
469
+ rows: this.rows,
470
+ saveRow: this.saveRow,
471
+ texts: this.textsLocal,
472
+ widths: this.widthsLocal,
473
+ trClass: [
474
+ "a_table_form__row",
475
+ {
476
+ a_table_form__row_drag_after: this.dragOverRowIndex === rowIndex &&
477
+ this.dragOverPosition === "after",
478
+ a_table_form__row_drag_before: this.dragOverRowIndex === rowIndex &&
479
+ this.dragOverPosition === "before",
480
+ a_table_form__row_drag_over: this.dragOverRowIndex === rowIndex,
481
+ a_table_form__row_dragging: this.draggedRowIndex === rowIndex,
482
+ },
483
+ ],
484
+ }, this.$slots);
485
+ }),
486
+ this.isAddRowActive && h(ATableFormRow, {
487
+ id: this.id,
488
+ actionsClasses: this.actionsClassesLocal,
489
+ actionsDisabledCallback: this.actionsDisabledCallback,
490
+ actionsHideCallback: this.actionsHideCallback,
491
+ actionsTitleCallback: this.actionsTitleCallback,
492
+ allColumnsLength: this.allColumnsLength,
493
+ canMoveRowDown: this.canMoveRowDown,
494
+ canMoveRowUp: this.canMoveRowUp,
495
+ changeModel: this.changeModel,
496
+ columns: this.columnsVisible,
497
+ columnsStylesGrow: this.columnsStylesGrow,
498
+ draggedRowIndex: this.draggedRowIndex,
499
+ editModel: this.activeEditModel,
500
+ errorIcon: this.errorIcon,
501
+ extra: this.extra,
502
+ hasActionsColumn: this.hasActionsColumn,
503
+ hasActiveEditRow: this.hasActiveEditRow,
504
+ isActionsSticky: this.isActionsSticky,
505
+ isActiveEditMode: true,
506
+ isCreateMode: true,
507
+ isDeletable: false,
508
+ isDeletableConfirm: false,
509
+ isDndDisabled: true,
510
+ isDragAndDrop: this.isDragAndDrop,
511
+ isEditable: this.isEditable,
512
+ key: "body_create",
513
+ moveRowDown: this.moveRowDown,
514
+ moveRowUp: this.moveRowUp,
515
+ onCancelEditRow: this.onCancelEditRow,
516
+ onDeleteRow: this.onDeleteRow,
517
+ onDragend: this.onDragend,
518
+ onDragleave: this.onDragleave,
519
+ onDragover: this.onDragover,
520
+ onDragstart: this.onDragstart,
521
+ onDrop: this.onDrop,
522
+ onEditRow: this.onEditRow,
523
+ row: {},
524
+ rowClass: this.rowClass,
525
+ rowIndex: this.rows.length,
526
+ rows: this.rows,
527
+ saveRow: this.addRow,
528
+ texts: this.textsLocal,
529
+ trClass: "a_table_form__row a_table_form__row_create",
530
+ widths: this.widthsLocal,
531
+ }, this.$slots),
532
+ ] :
533
+ [h("tr", {
534
+ class: "a_table_form__row a_table_form__row_empty",
535
+ }, [
536
+ h("td", {
537
+ class: "a_table_form__cell a_table_form__empty",
538
+ colspan: this.allColumnsLength,
539
+ }, [
540
+ h(ATranslation, {
541
+ tag: "span",
542
+ text: this.textsLocal.emptyText,
543
+ }),
544
+ ]),
545
+ ])]),
546
+ this.hasRowsFooter && h("tfoot", {
547
+ class: "a_table_form__foot",
548
+ }, this.rowsFooter.map((row, rowIndex) => {
549
+ return h(ATableFormRow, {
550
+ id: this.id,
551
+ actionsClasses: this.actionsClassesLocal,
552
+ actionsDisabledCallback: this.actionsDisabledCallback,
553
+ actionsHideCallback: this.actionsHideCallback,
554
+ actionsTitleCallback: this.actionsTitleCallback,
555
+ allColumnsLength: this.allColumnsLength,
556
+ canMoveRowDown: this.canMoveRowDown,
557
+ canMoveRowUp: this.canMoveRowUp,
558
+ changeModel: this.changeModel,
559
+ columns: this.columnsVisible,
560
+ columnsStylesGrow: this.columnsStylesGrow,
561
+ draggedRowIndex: this.draggedRowIndex,
562
+ extra: this.extra,
563
+ hasActionsColumn: this.hasActionsColumn,
564
+ hasActiveEditRow: this.hasActiveEditRow,
565
+ isActionsSticky: this.isActionsSticky,
566
+ isActiveEditMode: false,
567
+ isDeletable: this.isDeletable,
568
+ isDeletableConfirm: this.isDeletableConfirm,
569
+ isDndDisabled: this.hasActiveEditRow,
570
+ isDragAndDrop: this.isDragAndDrop,
571
+ isEditable: this.isEditable,
572
+ isFooter: true,
573
+ key: this.getRowKey({
574
+ isFooter: true,
575
+ row,
576
+ rowIndex,
577
+ }),
578
+ moveRowDown: this.moveRowDown,
579
+ moveRowUp: this.moveRowUp,
580
+ onCancelEditRow: this.onCancelEditRow,
581
+ onDeleteRow: this.onDeleteRow,
582
+ onDragend: this.onDragend,
583
+ onDragstart: this.onDragstart,
584
+ onEditRow: this.onEditRow,
585
+ row,
586
+ rowClass: this.rowClass,
587
+ rowIndex,
588
+ rows: this.rowsFooter,
589
+ saveRow: this.saveRow,
590
+ texts: this.textsLocal,
591
+ widths: this.widthsLocal,
592
+ trClass: "a_table_form__row a_table_form__row_footer",
593
+ }, this.$slots);
594
+ })),
595
+ ]),
596
+ ]),
597
+ this.canAddRow && h("div", {
598
+ class: "a_mt_3 a_text_right",
599
+ }, [
600
+ h(AButton, {
601
+ class: this.actionsClassesLocal.addRow,
602
+ disabled: this.isAddDisabled,
603
+ extra: this.extra,
604
+ iconLeft: this.iconsLocal.actionAddRow,
605
+ text: this.textsLocal.actionAddRow,
606
+ textScreenReader: this.addTitle,
607
+ title: this.addTitle,
608
+ onClick: this.onAddRow,
609
+ }),
610
+ ]),
611
+ ]);
612
+ },
613
+ };