aloha-vue 2.57.2 → 2.57.4
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/CHANGELOG.md +11 -0
- package/dist/aloha-vue.es.js +12616 -12549
- package/dist/aloha-vue.umd.js +56 -56
- package/package.json +1 -1
- package/src/ATableForm/ATableForm.js +31 -27
- package/src/ATableForm/ATableFormCellAction/ATableFormCellAction.js +34 -7
- package/src/ATableForm/ATableFormCellAction/compositionAPI/DeleteAPI.js +1 -6
- package/src/ATableForm/ATableFormCellAction/compositionAPI/IdsAPI.js +31 -0
- package/src/ATableForm/ATableFormRow/ATableFormRow.js +26 -20
- package/src/ATableForm/ATableFormRow/compositionAPI/EditAPI.js +5 -4
- package/src/ATableForm/compositionAPI/ClassesAPI.js +23 -23
- package/src/ATableForm/compositionAPI/EditAPI.js +119 -107
- package/src/ui/AInputCurrency/AInputCurrency.js +4 -0
- package/src/ui/AInputCurrency/compositionAPI/InputEventsAPI.js +20 -4
- package/src/ui/AInputCurrency/compositionAPI/ModelAPI.js +3 -2
|
@@ -1,107 +1,119 @@
|
|
|
1
|
-
import {
|
|
2
|
-
computed,
|
|
3
|
-
ref,
|
|
4
|
-
toRef,
|
|
5
|
-
} from "vue";
|
|
6
|
-
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
const
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
if (
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
};
|
|
107
|
-
|
|
1
|
+
import {
|
|
2
|
+
computed,
|
|
3
|
+
ref,
|
|
4
|
+
toRef,
|
|
5
|
+
} from "vue";
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
setFocusToElement,
|
|
9
|
+
} from "../../utils/utilsDOM";
|
|
10
|
+
import {
|
|
11
|
+
cloneDeep,
|
|
12
|
+
isFunction,
|
|
13
|
+
} from "lodash-es";
|
|
14
|
+
|
|
15
|
+
export default function EditAPI(props, {
|
|
16
|
+
getRowKey = () => {},
|
|
17
|
+
}) {
|
|
18
|
+
const addRow = toRef(props, "addRow");
|
|
19
|
+
const columns = toRef(props, "columns");
|
|
20
|
+
const isAddable = toRef(props, "isAddable");
|
|
21
|
+
const isEditable = toRef(props, "isEditable");
|
|
22
|
+
const prepareEditModel = toRef(props, "prepareEditModel");
|
|
23
|
+
const rows = toRef(props, "rows");
|
|
24
|
+
|
|
25
|
+
const activeEditRowKey = ref(undefined);
|
|
26
|
+
const activeEditModel = ref(undefined);
|
|
27
|
+
const isAddRowActive = ref(false);
|
|
28
|
+
|
|
29
|
+
const hasActiveEditRow = computed(() => {
|
|
30
|
+
return !!activeEditRowKey.value || isAddRowActive.value;
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
const canAddRow = computed(() => {
|
|
34
|
+
if (!isAddable.value) {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return isFunction(addRow.value);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
const hasRequiredEditableColumns = computed(() => {
|
|
42
|
+
if (!isEditable.value) {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return columns.value.some(column => {
|
|
47
|
+
return !!column.formElement?.required;
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
const getPreparedEditModel = params => {
|
|
52
|
+
if (!isFunction(prepareEditModel.value)) {
|
|
53
|
+
return undefined;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const result = prepareEditModel.value(params);
|
|
57
|
+
|
|
58
|
+
if (result?.model === undefined) {
|
|
59
|
+
return undefined;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return cloneDeep(result.model);
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const onAddRow = () => {
|
|
66
|
+
if (hasActiveEditRow.value || !canAddRow.value) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
activeEditRowKey.value = undefined;
|
|
71
|
+
activeEditModel.value = getPreparedEditModel({
|
|
72
|
+
rows: rows.value,
|
|
73
|
+
});
|
|
74
|
+
isAddRowActive.value = true;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
const onCancelEditRow = ({ trigger, id } = {}) => {
|
|
78
|
+
activeEditRowKey.value = undefined;
|
|
79
|
+
activeEditModel.value = undefined;
|
|
80
|
+
isAddRowActive.value = false;
|
|
81
|
+
if (trigger === "cancel") {
|
|
82
|
+
setTimeout(() => {
|
|
83
|
+
setFocusToElement({ selector: `#${ id }_edit` });
|
|
84
|
+
});
|
|
85
|
+
} else if (trigger === "save") {
|
|
86
|
+
setTimeout(() => {
|
|
87
|
+
setFocusToElement({ selector: `#${ id }` });
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
const onEditRow = ({ row, rowIndex }) => {
|
|
93
|
+
if (isAddRowActive.value) {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
activeEditModel.value = getPreparedEditModel({
|
|
98
|
+
row,
|
|
99
|
+
rowIndex,
|
|
100
|
+
rows: rows.value,
|
|
101
|
+
});
|
|
102
|
+
activeEditRowKey.value = getRowKey({
|
|
103
|
+
row,
|
|
104
|
+
rowIndex,
|
|
105
|
+
});
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
return {
|
|
109
|
+
activeEditRowKey,
|
|
110
|
+
activeEditModel,
|
|
111
|
+
canAddRow,
|
|
112
|
+
hasActiveEditRow,
|
|
113
|
+
hasRequiredEditableColumns,
|
|
114
|
+
isAddRowActive,
|
|
115
|
+
onAddRow,
|
|
116
|
+
onCancelEditRow,
|
|
117
|
+
onEditRow,
|
|
118
|
+
};
|
|
119
|
+
}
|
|
@@ -242,6 +242,10 @@ export default {
|
|
|
242
242
|
required: false,
|
|
243
243
|
default: () => AInputCurrencyPluginOptions.propsDefault.modelUndefined,
|
|
244
244
|
},
|
|
245
|
+
skipRequiredModelInit: {
|
|
246
|
+
type: Boolean,
|
|
247
|
+
required: false,
|
|
248
|
+
},
|
|
245
249
|
modelValue: {
|
|
246
250
|
type: [String, Number],
|
|
247
251
|
required: false,
|
|
@@ -30,6 +30,7 @@ export default function InputEventsAPI(props, {
|
|
|
30
30
|
const modelValue = toRef(props, "modelValue");
|
|
31
31
|
const readonly = toRef(props, "readonly");
|
|
32
32
|
const required = toRef(props, "required");
|
|
33
|
+
const skipRequiredModelInit = toRef(props, "skipRequiredModelInit");
|
|
33
34
|
const decimalPartLength = toRef(props, "decimalPartLength");
|
|
34
35
|
const thousandDivider = toRef(props, "thousandDivider");
|
|
35
36
|
const validationOnChange = toRef(props, "validationOnChange");
|
|
@@ -60,6 +61,10 @@ export default function InputEventsAPI(props, {
|
|
|
60
61
|
return `${ value.slice(0, start) }${ replacement }${ value.slice(end) }`;
|
|
61
62
|
};
|
|
62
63
|
|
|
64
|
+
const isZeroIntegerPart = value => {
|
|
65
|
+
return value === "0" || value === "-0";
|
|
66
|
+
};
|
|
67
|
+
|
|
63
68
|
const setValueLocal = ({ value, updateOutside, trigger, triggerDetails }) => {
|
|
64
69
|
setCurrentValue({ value, updateOutside, trigger, triggerDetails });
|
|
65
70
|
};
|
|
@@ -117,7 +122,7 @@ export default function InputEventsAPI(props, {
|
|
|
117
122
|
};
|
|
118
123
|
|
|
119
124
|
const handleInput = ($event, { value: _value, updateOutside = false, triggerDetails = "keydown" } = {}) => {
|
|
120
|
-
if (!required.value && isNil(_value) && !$event?.target?.value) {
|
|
125
|
+
if ((!required.value || skipRequiredModelInit.value) && isNil(_value) && !$event?.target?.value) {
|
|
121
126
|
setValueLocal({ value: _value, updateOutside, triggerDetails });
|
|
122
127
|
|
|
123
128
|
return;
|
|
@@ -381,6 +386,7 @@ export default function InputEventsAPI(props, {
|
|
|
381
386
|
const keyCode = $event.keyCode;
|
|
382
387
|
const keyValue = $event.key;
|
|
383
388
|
const keyIsNumber = keyCode >= 48 && keyCode <= 57 || keyCode >= 96 && keyCode <= 105;
|
|
389
|
+
const keyIsZero = keyCode === 48 || keyCode === 96;
|
|
384
390
|
const keyIsDecimalDivider = keyValue === decimalDivider.value && !!decimalPartLength.value;
|
|
385
391
|
const decimalDividerIndex = $event.target.value.indexOf(decimalDivider.value);
|
|
386
392
|
const hasDecimalDivider = decimalDividerIndex !== -1;
|
|
@@ -512,6 +518,11 @@ export default function InputEventsAPI(props, {
|
|
|
512
518
|
}
|
|
513
519
|
} else {
|
|
514
520
|
const intValWithoutDivider = intVal.replaceAll(thousandDivider.value, "");
|
|
521
|
+
if (keyIsZero && isZeroIntegerPart(intValWithoutDivider) && !hasSelection) {
|
|
522
|
+
$event.preventDefault();
|
|
523
|
+
|
|
524
|
+
return;
|
|
525
|
+
}
|
|
515
526
|
if (intValWithoutDivider.length >= integerPartMaxLength.value && !hasSelection) {
|
|
516
527
|
$event.preventDefault();
|
|
517
528
|
|
|
@@ -520,6 +531,11 @@ export default function InputEventsAPI(props, {
|
|
|
520
531
|
}
|
|
521
532
|
} else {
|
|
522
533
|
const intValWithoutDivider = value.replaceAll(thousandDivider.value, "");
|
|
534
|
+
if (keyIsZero && isZeroIntegerPart(intValWithoutDivider) && !hasSelection) {
|
|
535
|
+
$event.preventDefault();
|
|
536
|
+
|
|
537
|
+
return;
|
|
538
|
+
}
|
|
523
539
|
if (intValWithoutDivider.length >= integerPartMaxLength.value && !hasSelection) {
|
|
524
540
|
$event.preventDefault();
|
|
525
541
|
|
|
@@ -540,7 +556,7 @@ export default function InputEventsAPI(props, {
|
|
|
540
556
|
$event.preventDefault();
|
|
541
557
|
}
|
|
542
558
|
|
|
543
|
-
if (
|
|
559
|
+
if (keyIsNumber && !$event.ctrlKey && $event.keyCode) {
|
|
544
560
|
if (cursorPosition === 0 && value.length && value[0] === "0") {
|
|
545
561
|
$event.preventDefault();
|
|
546
562
|
const newVal = `${ keyValue }${ value.slice(1) }`;
|
|
@@ -711,7 +727,7 @@ export default function InputEventsAPI(props, {
|
|
|
711
727
|
valueToSet = `${ setMinusSymbol }${ intPart }${ decimalDivider.value }${ floatPart }${ zerosToAdd }`;
|
|
712
728
|
}
|
|
713
729
|
} else {
|
|
714
|
-
valueToSet = required.value ?
|
|
730
|
+
valueToSet = required.value && !skipRequiredModelInit.value ?
|
|
715
731
|
[
|
|
716
732
|
"0",
|
|
717
733
|
decimalDivider.value,
|
|
@@ -719,7 +735,7 @@ export default function InputEventsAPI(props, {
|
|
|
719
735
|
].join("") :
|
|
720
736
|
modelUndefinedLocal.value;
|
|
721
737
|
}
|
|
722
|
-
const shouldInitModel = required.value && !hasModel;
|
|
738
|
+
const shouldInitModel = required.value && !skipRequiredModelInit.value && !hasModel;
|
|
723
739
|
handleInput(null, { value: valueToSet, updateOutside: !shouldInitModel, triggerDetails: "init" });
|
|
724
740
|
});
|
|
725
741
|
};
|
|
@@ -17,6 +17,7 @@ export default function ModelAPI(props, {
|
|
|
17
17
|
const modelValue = toRef(props, "modelValue");
|
|
18
18
|
const modelType = toRef(props, "modelType");
|
|
19
19
|
const modelUndefined = toRef(props, "modelUndefined");
|
|
20
|
+
const skipRequiredModelInit = toRef(props, "skipRequiredModelInit");
|
|
20
21
|
const decimalDivider = toRef(props, "decimalDivider");
|
|
21
22
|
const disabled = toRef(props, "disabled");
|
|
22
23
|
const decimalPartLength = toRef(props, "decimalPartLength");
|
|
@@ -36,7 +37,7 @@ export default function ModelAPI(props, {
|
|
|
36
37
|
});
|
|
37
38
|
|
|
38
39
|
const modelUndefinedLocal = computed(() => {
|
|
39
|
-
if (!required.value) {
|
|
40
|
+
if (!required.value || skipRequiredModelInit.value) {
|
|
40
41
|
return modelUndefined.value;
|
|
41
42
|
}
|
|
42
43
|
if (!decimalPartLength.value) {
|
|
@@ -53,7 +54,7 @@ export default function ModelAPI(props, {
|
|
|
53
54
|
const setCurrentValue = ({ value, updateOutside = false, trigger, triggerDetails } = {}) => {
|
|
54
55
|
displayValue.value = isNil(value) ? "" : value;
|
|
55
56
|
let newVal;
|
|
56
|
-
if (!required.value && isNil(value)) {
|
|
57
|
+
if ((!required.value || skipRequiredModelInit.value) && isNil(value)) {
|
|
57
58
|
newVal = modelUndefinedLocal.value;
|
|
58
59
|
} else {
|
|
59
60
|
newVal = modelType.value === "number" ?
|