aloha-vue 2.52.0 → 2.53.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.
- package/CHANGELOG.md +4 -0
- package/dist/aloha-vue.es.js +61000 -61096
- package/dist/aloha-vue.umd.js +209 -209
- package/package.json +1 -1
- package/src/ADropdown/compositionAPI/AttributesAPI.js +100 -101
- package/src/ui/AInputCurrency/AInputCurrency.js +1 -1
- package/src/ui/AInputCurrency/compositionAPI/IncreaseDecreaseAPI.js +76 -76
- package/src/ui/AInputCurrency/compositionAPI/InputEventsAPI.js +26 -26
- package/src/ui/AInputCurrency/compositionAPI/ModelAPI.js +82 -82
- package/src/ui/compositionApi/UiAPI.js +185 -176
|
@@ -1,82 +1,82 @@
|
|
|
1
|
-
import {
|
|
2
|
-
computed,
|
|
3
|
-
ref,
|
|
4
|
-
toRef,
|
|
5
|
-
} from "vue";
|
|
6
|
-
|
|
7
|
-
import {
|
|
8
|
-
isNil,
|
|
9
|
-
times,
|
|
10
|
-
} from "lodash-es";
|
|
11
|
-
|
|
12
|
-
export default function ModelAPI(props, {
|
|
13
|
-
adjustFloatPartAndDivider = () => {},
|
|
14
|
-
changeModel = () => {},
|
|
15
|
-
}) {
|
|
16
|
-
const required = toRef(props, "required");
|
|
17
|
-
const modelValue = toRef(props, "modelValue");
|
|
18
|
-
const modelType = toRef(props, "modelType");
|
|
19
|
-
const modelUndefined = toRef(props, "modelUndefined");
|
|
20
|
-
const decimalDivider = toRef(props, "decimalDivider");
|
|
21
|
-
const disabled = toRef(props, "disabled");
|
|
22
|
-
const decimalPartLength = toRef(props, "decimalPartLength");
|
|
23
|
-
const thousandDivider = toRef(props, "thousandDivider");
|
|
24
|
-
|
|
25
|
-
const displayValue = ref(undefined);
|
|
26
|
-
const isInternalChange = ref(false);
|
|
27
|
-
const localModel = ref(undefined);
|
|
28
|
-
|
|
29
|
-
const initLocalVars = () => {
|
|
30
|
-
displayValue.value = adjustFloatPartAndDivider(modelValue.value);
|
|
31
|
-
localModel.value = modelValue.value;
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
const modelNumber = computed(() => {
|
|
35
|
-
return Number(`${ displayValue.value }`.replaceAll(thousandDivider.value, "").replace(decimalDivider.value, "."));
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
const modelUndefinedLocal = computed(() => {
|
|
39
|
-
return required.value
|
|
40
|
-
? [
|
|
41
|
-
"0",
|
|
42
|
-
decimalDivider.value,
|
|
43
|
-
times(decimalPartLength.value, () => "0").join(""),
|
|
44
|
-
].join("")
|
|
45
|
-
: modelUndefined.value;
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
const setCurrentValue = (value, updateOutside = false) => {
|
|
49
|
-
displayValue.value = isNil(value) ? "" : value;
|
|
50
|
-
let newVal;
|
|
51
|
-
if (!required.value && isNil(value)) {
|
|
52
|
-
newVal = modelUndefinedLocal.value;
|
|
53
|
-
} else {
|
|
54
|
-
newVal = modelType.value === "number" ?
|
|
55
|
-
Number(`${ value }`.replaceAll(thousandDivider.value, "").replace(decimalDivider.value, ".")) :
|
|
56
|
-
value;
|
|
57
|
-
}
|
|
58
|
-
if (!updateOutside) {
|
|
59
|
-
isInternalChange.value = true;
|
|
60
|
-
localModel.value = newVal;
|
|
61
|
-
changeModel({ model: newVal });
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
const clearModel = () => {
|
|
66
|
-
if (disabled.value) {
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
setCurrentValue(modelUndefinedLocal.value);
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
return {
|
|
73
|
-
clearModel,
|
|
74
|
-
displayValue,
|
|
75
|
-
initLocalVars,
|
|
76
|
-
isInternalChange,
|
|
77
|
-
localModel,
|
|
78
|
-
modelNumber,
|
|
79
|
-
modelUndefinedLocal,
|
|
80
|
-
setCurrentValue,
|
|
81
|
-
};
|
|
82
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
computed,
|
|
3
|
+
ref,
|
|
4
|
+
toRef,
|
|
5
|
+
} from "vue";
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
isNil,
|
|
9
|
+
times,
|
|
10
|
+
} from "lodash-es";
|
|
11
|
+
|
|
12
|
+
export default function ModelAPI(props, {
|
|
13
|
+
adjustFloatPartAndDivider = () => {},
|
|
14
|
+
changeModel = () => {},
|
|
15
|
+
}) {
|
|
16
|
+
const required = toRef(props, "required");
|
|
17
|
+
const modelValue = toRef(props, "modelValue");
|
|
18
|
+
const modelType = toRef(props, "modelType");
|
|
19
|
+
const modelUndefined = toRef(props, "modelUndefined");
|
|
20
|
+
const decimalDivider = toRef(props, "decimalDivider");
|
|
21
|
+
const disabled = toRef(props, "disabled");
|
|
22
|
+
const decimalPartLength = toRef(props, "decimalPartLength");
|
|
23
|
+
const thousandDivider = toRef(props, "thousandDivider");
|
|
24
|
+
|
|
25
|
+
const displayValue = ref(undefined);
|
|
26
|
+
const isInternalChange = ref(false);
|
|
27
|
+
const localModel = ref(undefined);
|
|
28
|
+
|
|
29
|
+
const initLocalVars = () => {
|
|
30
|
+
displayValue.value = adjustFloatPartAndDivider(modelValue.value);
|
|
31
|
+
localModel.value = modelValue.value;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const modelNumber = computed(() => {
|
|
35
|
+
return Number(`${ displayValue.value }`.replaceAll(thousandDivider.value, "").replace(decimalDivider.value, "."));
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
const modelUndefinedLocal = computed(() => {
|
|
39
|
+
return required.value
|
|
40
|
+
? [
|
|
41
|
+
"0",
|
|
42
|
+
decimalDivider.value,
|
|
43
|
+
times(decimalPartLength.value, () => "0").join(""),
|
|
44
|
+
].join("")
|
|
45
|
+
: modelUndefined.value;
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
const setCurrentValue = ({ value, updateOutside = false, trigger, triggerDetails } = {}) => {
|
|
49
|
+
displayValue.value = isNil(value) ? "" : value;
|
|
50
|
+
let newVal;
|
|
51
|
+
if (!required.value && isNil(value)) {
|
|
52
|
+
newVal = modelUndefinedLocal.value;
|
|
53
|
+
} else {
|
|
54
|
+
newVal = modelType.value === "number" ?
|
|
55
|
+
Number(`${ value }`.replaceAll(thousandDivider.value, "").replace(decimalDivider.value, ".")) :
|
|
56
|
+
value;
|
|
57
|
+
}
|
|
58
|
+
if (!updateOutside) {
|
|
59
|
+
isInternalChange.value = true;
|
|
60
|
+
localModel.value = newVal;
|
|
61
|
+
changeModel({ model: newVal, trigger, triggerDetails });
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const clearModel = () => {
|
|
66
|
+
if (disabled.value) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
setCurrentValue({ value: modelUndefinedLocal.value, triggerDetails: "clear" });
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
return {
|
|
73
|
+
clearModel,
|
|
74
|
+
displayValue,
|
|
75
|
+
initLocalVars,
|
|
76
|
+
isInternalChange,
|
|
77
|
+
localModel,
|
|
78
|
+
modelNumber,
|
|
79
|
+
modelUndefinedLocal,
|
|
80
|
+
setCurrentValue,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
@@ -1,176 +1,185 @@
|
|
|
1
|
-
import {
|
|
2
|
-
computed,
|
|
3
|
-
ref,
|
|
4
|
-
toRef,
|
|
5
|
-
toRefs,
|
|
6
|
-
} from "vue";
|
|
7
|
-
|
|
8
|
-
import UiErrorsAPI from "./UiErrorsAPI";
|
|
9
|
-
|
|
10
|
-
import {
|
|
11
|
-
isUndefined,
|
|
12
|
-
} from "lodash-es";
|
|
13
|
-
|
|
14
|
-
export default function UiAPI(props, { emit }, {
|
|
15
|
-
setFocus = () => {},
|
|
16
|
-
} = {}) {
|
|
17
|
-
const change = toRef(props, "change");
|
|
18
|
-
const defaultProps = toRef(props, "default");
|
|
19
|
-
const disabled = toRef(props, "disabled");
|
|
20
|
-
const helpText = toRef(props, "helpText");
|
|
21
|
-
const htmlId = toRef(props, "htmlId");
|
|
22
|
-
const id = toRef(props, "id");
|
|
23
|
-
const idPrefix = toRef(props, "idPrefix");
|
|
24
|
-
const isLabelFloat = toRef(props, "isLabelFloat");
|
|
25
|
-
const labelDescription = toRef(props, "labelDescription");
|
|
26
|
-
const modelUndefined = toRef(props, "modelUndefined");
|
|
27
|
-
const modelValue = toRef(props, "modelValue");
|
|
28
|
-
|
|
29
|
-
const isFocus = ref(false);
|
|
30
|
-
const isFocusIn = ref(false);
|
|
31
|
-
const rootRef = ref(undefined);
|
|
32
|
-
|
|
33
|
-
const htmlIdLocal = computed(() => {
|
|
34
|
-
return getHtmlId({
|
|
35
|
-
id: id.value,
|
|
36
|
-
idPrefix: idPrefix.value,
|
|
37
|
-
htmlId: htmlId.value,
|
|
38
|
-
});
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
const {
|
|
42
|
-
errorsId,
|
|
43
|
-
isErrors,
|
|
44
|
-
} = UiErrorsAPI(props, {
|
|
45
|
-
htmlIdLocal,
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
const changeModel = ({ model, currentModel, item, init }) => {
|
|
49
|
-
emit("update:modelValue", model);
|
|
50
|
-
|
|
51
|
-
currentModel,
|
|
52
|
-
id: id.value,
|
|
53
|
-
item,
|
|
54
|
-
model,
|
|
55
|
-
props: toRefs(props),
|
|
56
|
-
init,
|
|
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
|
-
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
const
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
const
|
|
108
|
-
isFocus.value =
|
|
109
|
-
emit("
|
|
110
|
-
event: $event,
|
|
111
|
-
props,
|
|
112
|
-
});
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
const
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
1
|
+
import {
|
|
2
|
+
computed,
|
|
3
|
+
ref,
|
|
4
|
+
toRef,
|
|
5
|
+
toRefs,
|
|
6
|
+
} from "vue";
|
|
7
|
+
|
|
8
|
+
import UiErrorsAPI from "./UiErrorsAPI";
|
|
9
|
+
|
|
10
|
+
import {
|
|
11
|
+
isUndefined,
|
|
12
|
+
} from "lodash-es";
|
|
13
|
+
|
|
14
|
+
export default function UiAPI(props, { emit }, {
|
|
15
|
+
setFocus = () => {},
|
|
16
|
+
} = {}) {
|
|
17
|
+
const change = toRef(props, "change");
|
|
18
|
+
const defaultProps = toRef(props, "default");
|
|
19
|
+
const disabled = toRef(props, "disabled");
|
|
20
|
+
const helpText = toRef(props, "helpText");
|
|
21
|
+
const htmlId = toRef(props, "htmlId");
|
|
22
|
+
const id = toRef(props, "id");
|
|
23
|
+
const idPrefix = toRef(props, "idPrefix");
|
|
24
|
+
const isLabelFloat = toRef(props, "isLabelFloat");
|
|
25
|
+
const labelDescription = toRef(props, "labelDescription");
|
|
26
|
+
const modelUndefined = toRef(props, "modelUndefined");
|
|
27
|
+
const modelValue = toRef(props, "modelValue");
|
|
28
|
+
|
|
29
|
+
const isFocus = ref(false);
|
|
30
|
+
const isFocusIn = ref(false);
|
|
31
|
+
const rootRef = ref(undefined);
|
|
32
|
+
|
|
33
|
+
const htmlIdLocal = computed(() => {
|
|
34
|
+
return getHtmlId({
|
|
35
|
+
id: id.value,
|
|
36
|
+
idPrefix: idPrefix.value,
|
|
37
|
+
htmlId: htmlId.value,
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
const {
|
|
42
|
+
errorsId,
|
|
43
|
+
isErrors,
|
|
44
|
+
} = UiErrorsAPI(props, {
|
|
45
|
+
htmlIdLocal,
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
const changeModel = ({ model, currentModel, item, init, trigger = "change", triggerDetails } = {}) => {
|
|
49
|
+
emit("update:modelValue", model);
|
|
50
|
+
const RETURN_ARGS = {
|
|
51
|
+
currentModel,
|
|
52
|
+
id: id.value,
|
|
53
|
+
item,
|
|
54
|
+
model,
|
|
55
|
+
props: toRefs(props),
|
|
56
|
+
init,
|
|
57
|
+
trigger,
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
if (triggerDetails) {
|
|
61
|
+
RETURN_ARGS.triggerDetails = triggerDetails;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
change.value(RETURN_ARGS);
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
const isModel = computed(() => {
|
|
68
|
+
return !!(modelValue.value || modelValue.value === 0);
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
const clearModel = () => {
|
|
72
|
+
if (disabled.value) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
changeModel({
|
|
77
|
+
model: modelUndefined.value,
|
|
78
|
+
triggerDetails: "clear",
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
setFocus();
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
const helpTextId = computed(() => {
|
|
85
|
+
return `${ htmlIdLocal.value }_help_text`;
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
const labelDescriptionId = computed(() => {
|
|
89
|
+
return `${ htmlIdLocal.value }_label_description`;
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
const ariaDescribedbyLocal = computed(() => {
|
|
93
|
+
const ariaDescribedby = [];
|
|
94
|
+
if (labelDescription.value && !isLabelFloat.value) {
|
|
95
|
+
ariaDescribedby.push(labelDescriptionId.value);
|
|
96
|
+
}
|
|
97
|
+
if (helpText.value) {
|
|
98
|
+
ariaDescribedby.push(helpTextId.value);
|
|
99
|
+
}
|
|
100
|
+
if (isErrors.value) {
|
|
101
|
+
ariaDescribedby.push(errorsId.value);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return ariaDescribedby.join(" ") || undefined;
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
const onFocus = $event => {
|
|
108
|
+
isFocus.value = true;
|
|
109
|
+
emit("focus", {
|
|
110
|
+
event: $event,
|
|
111
|
+
props,
|
|
112
|
+
});
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
const onBlur = $event => {
|
|
116
|
+
isFocus.value = false;
|
|
117
|
+
emit("blur", {
|
|
118
|
+
event: $event,
|
|
119
|
+
props,
|
|
120
|
+
});
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
const onFocusin = $event => {
|
|
124
|
+
if (!isFocusIn.value) {
|
|
125
|
+
isFocusIn.value = true;
|
|
126
|
+
emit("focusin", {
|
|
127
|
+
event: $event,
|
|
128
|
+
props,
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
const onFocusout = $event => {
|
|
134
|
+
if (isFocusIn.value) {
|
|
135
|
+
if (rootRef.value && !rootRef.value.contains($event.relatedTarget)) {
|
|
136
|
+
isFocusIn.value = false;
|
|
137
|
+
emit("focusout", {
|
|
138
|
+
event: $event,
|
|
139
|
+
props,
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
const initDefaultModel = () => {
|
|
146
|
+
if (isUndefined(defaultProps.value) ||
|
|
147
|
+
!isUndefined(modelValue.value)) {
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
changeModel({
|
|
152
|
+
model: defaultProps.value,
|
|
153
|
+
currentModel: defaultProps.value,
|
|
154
|
+
init: true,
|
|
155
|
+
triggerDetails: "init",
|
|
156
|
+
});
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
return {
|
|
160
|
+
ariaDescribedbyLocal,
|
|
161
|
+
changeModel,
|
|
162
|
+
clearModel,
|
|
163
|
+
errorsId,
|
|
164
|
+
helpTextId,
|
|
165
|
+
htmlIdLocal,
|
|
166
|
+
initDefaultModel,
|
|
167
|
+
isErrors,
|
|
168
|
+
isFocus,
|
|
169
|
+
isFocusIn,
|
|
170
|
+
isModel,
|
|
171
|
+
labelDescriptionId,
|
|
172
|
+
onBlur,
|
|
173
|
+
onFocus,
|
|
174
|
+
onFocusin,
|
|
175
|
+
onFocusout,
|
|
176
|
+
rootRef,
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
export function getHtmlId({ id, idPrefix, htmlId }) {
|
|
181
|
+
if (htmlId) {
|
|
182
|
+
return htmlId;
|
|
183
|
+
}
|
|
184
|
+
return `${ idPrefix || "" }${ id }`;
|
|
185
|
+
}
|