@nmorph/nmorph-ui-kit 2.2.37 → 2.2.38
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/components/data/nmorph-card/NmorphCard.vue2.js +19 -16
- package/dist/components/form/nmorph-autocomplete/NmorphAutocomplete.vue2.js +67 -65
- package/dist/components/form/nmorph-checkbox/NmorphCheckbox.css +1 -1
- package/dist/components/form/nmorph-checkbox/NmorphCheckbox.vue2.js +28 -26
- package/dist/components/form/nmorph-checkbox-group/NmorphCheckboxGroup.vue2.js +25 -20
- package/dist/components/form/nmorph-color-picker/NmorphColorPicker.vue2.js +43 -42
- package/dist/components/form/nmorph-date-picker/NmorphDatePicker.vue2.js +52 -40
- package/dist/components/form/nmorph-file-upload/NmorphFileUpload.vue.js +20 -16
- package/dist/components/form/nmorph-file-upload/NmorphFileUpload.vue2.js +113 -86
- package/dist/components/form/nmorph-form/NmorphForm.vue2.js +9 -9
- package/dist/components/form/nmorph-form/components/nmorph-form-item/NmorphFormItem.vue2.js +33 -24
- package/dist/components/form/nmorph-form/use-form-item-input.js +29 -8
- package/dist/components/form/nmorph-number-input/NmorphNumberInput.vue2.js +41 -35
- package/dist/components/form/nmorph-otp-input/NmorphOTPInput.vue2.js +65 -61
- package/dist/components/form/nmorph-radio/NmorphRadio.css +1 -1
- package/dist/components/form/nmorph-radio-group/NmorphRadioGroup.vue2.js +24 -22
- package/dist/components/form/nmorph-select/NmorphSelect.css +1 -1
- package/dist/components/form/nmorph-select/NmorphSelect.vue2.js +91 -81
- package/dist/components/form/nmorph-select-button/NmorphSelectButton.vue2.js +28 -26
- package/dist/components/form/nmorph-slider/NmorphSlider.vue2.js +49 -48
- package/dist/components/form/nmorph-switch/NmorphSwitch.vue2.js +37 -36
- package/dist/components/form/nmorph-text-input/NmorphTextInput.css +1 -1
- package/dist/components/form/nmorph-text-input/NmorphTextInput.vue.js +1 -1
- package/dist/components/form/nmorph-text-input/NmorphTextInput.vue2.js +34 -30
- package/dist/components/form/nmorph-textarea/NmorphTextarea.vue.js +1 -1
- package/dist/components/form/nmorph-textarea/NmorphTextarea.vue2.js +29 -25
- package/dist/components/form/nmorph-time-picker/NmorphTimePicker.vue.js +1 -1
- package/dist/components/form/nmorph-time-picker/NmorphTimePicker.vue2.js +69 -68
- package/dist/hooks/use-field-validation.js +71 -42
- package/dist/hooks/use-form-validation.js +62 -24
- package/dist/index.umd.js +26 -26
- package/dist/package.json.js +1 -1
- package/dist/src/components/basic/nmorph-button/NmorphButton.vue.d.ts +1 -1
- package/dist/src/components/basic/nmorph-link/NmorphLink.vue.d.ts +1 -1
- package/dist/src/components/data/nmorph-avatar/NmorphAvatar.vue.d.ts +1 -1
- package/dist/src/components/data/nmorph-badge/NmorphBadge.vue.d.ts +1 -1
- package/dist/src/components/data/nmorph-empty/NmorphEmpty.vue.d.ts +1 -1
- package/dist/src/components/data/nmorph-progress/NmorphProgress.vue.d.ts +1 -1
- package/dist/src/components/data/nmorph-table/NmorphTable.vue.d.ts +1 -1
- package/dist/src/components/feedback/nmorph-callout/NmorphCallout.vue.d.ts +1 -1
- package/dist/src/components/form/nmorph-checkbox-group/NmorphCheckboxGroup.vue.d.ts +2 -2
- package/dist/src/components/form/nmorph-date-picker/NmorphDatePicker.vue.d.ts +2 -2
- package/dist/src/components/form/nmorph-file-upload/NmorphFileUpload.vue.d.ts +6 -3
- package/dist/src/components/form/nmorph-file-upload/types.d.ts +4 -0
- package/dist/src/components/form/nmorph-form/types.d.ts +15 -5
- package/dist/src/components/form/nmorph-form/use-form-item-input.d.ts +10 -0
- package/dist/src/components/form/nmorph-radio-group/NmorphRadioGroup.vue.d.ts +2 -2
- package/dist/src/hooks/use-field-validation.d.ts +15 -0
- package/dist/src/hooks/use-form-validation.d.ts +5 -0
- package/dist/style.css +1 -1
- package/dist/utils/common.js +6 -7
- package/package.json +1 -1
|
@@ -1,30 +1,34 @@
|
|
|
1
1
|
import './NmorphFileUpload.css';
|
|
2
|
-
import
|
|
3
|
-
import { openBlock as o, createElementBlock as r, normalizeClass as
|
|
2
|
+
import p from "./NmorphFileUpload.vue2.js";
|
|
3
|
+
import { openBlock as o, createElementBlock as r, normalizeClass as s, createElementVNode as l, renderSlot as _, createVNode as n, TransitionGroup as h, withCtx as t, Fragment as f, renderList as v, createBlock as a, createCommentVNode as m, resolveDynamicComponent as u, toDisplayString as g } from "vue";
|
|
4
4
|
/* empty css */
|
|
5
|
-
import
|
|
6
|
-
const
|
|
5
|
+
import b from "../../../_virtual/_plugin-vue_export-helper.js";
|
|
6
|
+
const x = { class: "nmorph-file-upload__trigger" }, y = ["id", "name", "autocomplete", "tabindex", "multiple", "disabled", "accept"], k = {
|
|
7
7
|
key: 0,
|
|
8
8
|
class: "nmorph-file-upload__list"
|
|
9
|
-
},
|
|
10
|
-
function B(
|
|
9
|
+
}, N = { class: "nmorph-file-upload__file-info" }, C = { class: "nmorph-file-upload__file-name" }, F = { class: "nmorph-file-upload__remove-file" };
|
|
10
|
+
function B(d, I, w, e, D, S) {
|
|
11
11
|
return o(), r(
|
|
12
12
|
"div",
|
|
13
13
|
{
|
|
14
|
-
class:
|
|
14
|
+
class: s(e.modifiers)
|
|
15
15
|
},
|
|
16
16
|
[
|
|
17
|
-
l("div",
|
|
17
|
+
l("div", x, [
|
|
18
18
|
l("input", {
|
|
19
|
+
id: e.id,
|
|
19
20
|
ref: "inputDOMRef",
|
|
21
|
+
name: e.name,
|
|
22
|
+
autocomplete: e.autocomplete,
|
|
23
|
+
tabindex: e.tabindex,
|
|
20
24
|
type: "file",
|
|
21
25
|
multiple: e.props.multiple,
|
|
22
26
|
disabled: e.props.disabled,
|
|
23
27
|
accept: e.inputAccept,
|
|
24
28
|
class: "nmorph-native-input",
|
|
25
29
|
onChange: e.handleFileUpload
|
|
26
|
-
}, null, 40,
|
|
27
|
-
_(
|
|
30
|
+
}, null, 40, y),
|
|
31
|
+
_(d.$slots, "trigger", {}, () => [
|
|
28
32
|
n(e.NmorphButton, {
|
|
29
33
|
text: e.computedButtonText,
|
|
30
34
|
fill: "",
|
|
@@ -33,7 +37,7 @@ function B(s, I, w, e, D, S) {
|
|
|
33
37
|
}, null, 8, ["text", "disabled"])
|
|
34
38
|
])
|
|
35
39
|
]),
|
|
36
|
-
e.files.length > 0 ? (o(), r("div",
|
|
40
|
+
e.files.length > 0 ? (o(), r("div", k, [
|
|
37
41
|
n(h, {
|
|
38
42
|
name: "list",
|
|
39
43
|
tag: "div"
|
|
@@ -49,8 +53,8 @@ function B(s, I, w, e, D, S) {
|
|
|
49
53
|
e.props.photoWithPreview && e.isImageFile(i) ? (o(), a(e.NmorphImagePreview, {
|
|
50
54
|
key: 0,
|
|
51
55
|
src: c
|
|
52
|
-
}, null, 8, ["src"])) :
|
|
53
|
-
l("div",
|
|
56
|
+
}, null, 8, ["src"])) : m("v-if", !0),
|
|
57
|
+
l("div", N, [
|
|
54
58
|
n(
|
|
55
59
|
e.NmorphIcon,
|
|
56
60
|
{
|
|
@@ -69,7 +73,7 @@ function B(s, I, w, e, D, S) {
|
|
|
69
73
|
),
|
|
70
74
|
l(
|
|
71
75
|
"span",
|
|
72
|
-
|
|
76
|
+
C,
|
|
73
77
|
g(i.name),
|
|
74
78
|
1
|
|
75
79
|
/* TEXT */
|
|
@@ -96,13 +100,13 @@ function B(s, I, w, e, D, S) {
|
|
|
96
100
|
_: 1
|
|
97
101
|
/* STABLE */
|
|
98
102
|
})
|
|
99
|
-
])) :
|
|
103
|
+
])) : m("v-if", !0)
|
|
100
104
|
],
|
|
101
105
|
2
|
|
102
106
|
/* CLASS */
|
|
103
107
|
);
|
|
104
108
|
}
|
|
105
|
-
const T = /* @__PURE__ */
|
|
109
|
+
const T = /* @__PURE__ */ b(p, [["render", B], ["__file", "/builds/ketjo/nmorph/library/src/components/form/nmorph-file-upload/NmorphFileUpload.vue"]]);
|
|
106
110
|
export {
|
|
107
111
|
T as default
|
|
108
112
|
};
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import './NmorphFileUpload.css';
|
|
2
|
-
import { defineComponent as
|
|
3
|
-
import { useModifiers as
|
|
4
|
-
import { useI18n as
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
|
|
2
|
+
import { defineComponent as X, computed as C, inject as Y, ref as q, watch as Z, onBeforeUnmount as ee } from "vue";
|
|
3
|
+
import { useModifiers as te } from "../../../utils/create-modifiers.js";
|
|
4
|
+
import { useI18n as oe } from "vue-i18n";
|
|
5
|
+
import { useFormItemInput as re, useFormItemModel as ne } from "../nmorph-form/use-form-item-input.js";
|
|
6
|
+
import { resolution as B, NmorphImageResolution as V, NmorphAudioResolution as se, NmorphVideoResolution as ae, NmorphArchiveResolution as ie } from "./types.js";
|
|
7
|
+
import le from "../../../assets/icons/doc.svg.js";
|
|
8
|
+
import ue from "../../data/nmorph-image-preview/NmorphImagePreview.vue.js";
|
|
9
|
+
import de from "../../basic/nmorph-icon/NmorphIcon.vue.js";
|
|
10
|
+
import pe from "../../basic/nmorph-button/NmorphButton.vue.js";
|
|
11
|
+
import me from "../../../assets/icons/audio.svg.js";
|
|
12
|
+
import ce from "../../../assets/icons/video.svg.js";
|
|
13
|
+
import fe from "../../../assets/icons/archive.svg.js";
|
|
14
|
+
import ve from "../../../assets/icons/cross.svg.js";
|
|
15
|
+
import ye from "../../../assets/icons/image.svg.js";
|
|
16
|
+
const Pe = /* @__PURE__ */ X({
|
|
16
17
|
__name: "NmorphFileUpload",
|
|
17
18
|
props: {
|
|
18
19
|
modelValue: { type: Array, required: !1, default: () => [] },
|
|
@@ -20,107 +21,133 @@ const ye = /* @__PURE__ */ M({
|
|
|
20
21
|
multiple: { type: Boolean, required: !1, default: !1 },
|
|
21
22
|
allowedTypes: { type: Array, required: !1, default: () => [] },
|
|
22
23
|
photoWithPreview: { type: Boolean, required: !1, default: !0 },
|
|
23
|
-
buttonText: { type: String, required: !1, default: "" }
|
|
24
|
+
buttonText: { type: String, required: !1, default: "" },
|
|
25
|
+
id: { type: String, required: !1 },
|
|
26
|
+
name: { type: String, required: !1 },
|
|
27
|
+
autocomplete: { type: String, required: !1 },
|
|
28
|
+
tabindex: { type: Number, required: !1 }
|
|
24
29
|
},
|
|
25
|
-
emits: ["update:model-value", "on-unsupported-file-type-error"],
|
|
26
|
-
setup(
|
|
27
|
-
const { t:
|
|
30
|
+
emits: ["update:model-value", "on-unsupported-file-type-error", "on-file-validation-error"],
|
|
31
|
+
setup(M, { expose: j, emit: O }) {
|
|
32
|
+
const { t: N } = oe(), r = M, c = O, k = C(() => r.buttonText ? r.buttonText : N("selectFile")), { id: f, name: E, autocomplete: W, tabindex: D } = re(r), { modelValue: F, updateModelValue: L } = ne(
|
|
33
|
+
r,
|
|
34
|
+
(e) => c("update:model-value", e),
|
|
35
|
+
[]
|
|
36
|
+
), v = Y("form-data", void 0), R = Object.entries(B), T = {
|
|
28
37
|
"svg-xml": "svg",
|
|
29
38
|
"audio-ogg": "ogg",
|
|
30
39
|
"wideo-ogg": "ogg"
|
|
31
|
-
},
|
|
32
|
-
const
|
|
33
|
-
return
|
|
34
|
-
},
|
|
40
|
+
}, A = (e) => e.split("/")[1]?.toLowerCase() || "", I = (e) => {
|
|
41
|
+
const t = e.split(".").pop()?.toLowerCase();
|
|
42
|
+
return t && t !== e.toLowerCase() ? t : "";
|
|
43
|
+
}, S = (e) => R.find(([, t]) => t.toLowerCase() === e.toLowerCase())?.[0] || "", y = (e) => Array.from(
|
|
35
44
|
new Set(
|
|
36
45
|
[
|
|
37
46
|
e.type.toLowerCase(),
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
].filter(Boolean).map((
|
|
47
|
+
S(e.type),
|
|
48
|
+
I(e.name),
|
|
49
|
+
A(e.type)
|
|
50
|
+
].filter(Boolean).map((t) => t.toLowerCase())
|
|
42
51
|
)
|
|
43
|
-
), i = (e,
|
|
44
|
-
const
|
|
45
|
-
return e.type.toLowerCase().startsWith("image/") ||
|
|
46
|
-
},
|
|
47
|
-
if (
|
|
48
|
-
const
|
|
49
|
-
return
|
|
50
|
-
},
|
|
51
|
-
if (
|
|
52
|
+
), i = (e, t) => Object.prototype.hasOwnProperty.call(t, e), K = (e) => {
|
|
53
|
+
const t = y(e);
|
|
54
|
+
return e.type.toLowerCase().startsWith("image/") || t.some((o) => i(o, V));
|
|
55
|
+
}, P = (e) => {
|
|
56
|
+
if (r.allowedTypes.length === 0) return !0;
|
|
57
|
+
const t = y(e);
|
|
58
|
+
return r.allowedTypes.some((o) => t.includes(String(o).toLowerCase()));
|
|
59
|
+
}, $ = C(() => {
|
|
60
|
+
if (r.allowedTypes.length !== 0)
|
|
52
61
|
return Array.from(
|
|
53
62
|
new Set(
|
|
54
|
-
|
|
55
|
-
const
|
|
56
|
-
return
|
|
63
|
+
r.allowedTypes.flatMap((e) => {
|
|
64
|
+
const t = String(e).toLowerCase(), o = B[t], n = T[t] || t;
|
|
65
|
+
return t.includes("/") ? t : o ? [`.${n}`, o] : `.${n}`;
|
|
57
66
|
})
|
|
58
67
|
)
|
|
59
68
|
).join(",");
|
|
60
|
-
}),
|
|
61
|
-
const
|
|
62
|
-
let
|
|
63
|
-
return (e.type.toLowerCase().startsWith("image/") ||
|
|
64
|
-
},
|
|
65
|
-
const e =
|
|
69
|
+
}), z = (e) => {
|
|
70
|
+
const t = y(e);
|
|
71
|
+
let o = le;
|
|
72
|
+
return (e.type.toLowerCase().startsWith("image/") || t.some((n) => i(n, V))) && (o = ye), (e.type.toLowerCase().startsWith("audio/") || t.some((n) => i(n, se))) && (o = me), (e.type.toLowerCase().startsWith("video/") || t.some((n) => i(n, ae))) && (o = ce), t.some((n) => i(n, ie)) && (o = fe), o;
|
|
73
|
+
}, u = q(null), a = q([...F.value]), l = /* @__PURE__ */ new Set(), h = () => {
|
|
74
|
+
const e = u.value;
|
|
66
75
|
e && (e.value = "");
|
|
67
|
-
},
|
|
76
|
+
}, g = (e) => {
|
|
68
77
|
l.has(e) && (URL.revokeObjectURL(e), l.delete(e));
|
|
69
|
-
},
|
|
70
|
-
const
|
|
71
|
-
Array.from(l).forEach((
|
|
72
|
-
|
|
78
|
+
}, x = (e) => {
|
|
79
|
+
const t = new Set(e.map((o) => o.previewUrl));
|
|
80
|
+
Array.from(l).forEach((o) => {
|
|
81
|
+
t.has(o) || g(o);
|
|
73
82
|
});
|
|
74
|
-
},
|
|
75
|
-
const
|
|
76
|
-
a.value =
|
|
77
|
-
},
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
83
|
+
}, b = (e) => {
|
|
84
|
+
const t = [...e];
|
|
85
|
+
a.value = t, L(t);
|
|
86
|
+
}, U = (e) => {
|
|
87
|
+
const t = v?.validateField(f.value, e);
|
|
88
|
+
return {
|
|
89
|
+
valid: t?.valid.value ?? !0,
|
|
90
|
+
errors: t?.errors.value ?? []
|
|
91
|
+
};
|
|
92
|
+
}, G = () => {
|
|
93
|
+
r.disabled || !u.value || u.value.click();
|
|
94
|
+
}, H = (e) => {
|
|
95
|
+
if (r.disabled) return;
|
|
96
|
+
const t = e.target, o = Array.from(t.files || []), n = r.multiple ? o : o.slice(0, 1), d = [];
|
|
97
|
+
if (n.forEach((s) => {
|
|
98
|
+
if (!P(s)) {
|
|
99
|
+
c("on-unsupported-file-type-error", s.type || I(s.name) || s.name);
|
|
85
100
|
return;
|
|
86
101
|
}
|
|
87
|
-
const
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
const
|
|
95
|
-
|
|
102
|
+
const p = r.multiple ? [...a.value.map((w) => w.data), ...d, s] : [s], m = U(p);
|
|
103
|
+
if (!m.valid) {
|
|
104
|
+
c("on-file-validation-error", { file: s, errors: m.errors });
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
d.push(s);
|
|
108
|
+
}), h(), d.length > 0) {
|
|
109
|
+
const s = d.map((m) => {
|
|
110
|
+
const w = URL.createObjectURL(m);
|
|
111
|
+
return l.add(w), { data: m, previewUrl: w };
|
|
112
|
+
}), p = r.multiple ? [...a.value, ...s] : s;
|
|
113
|
+
x(p), b(p), v?.validateField(f.value, p);
|
|
114
|
+
}
|
|
115
|
+
}, J = (e) => {
|
|
116
|
+
if (r.disabled) return;
|
|
117
|
+
const t = a.value.findIndex((o) => o.data.name === e);
|
|
118
|
+
if (t !== -1) {
|
|
119
|
+
const o = a.value[t];
|
|
120
|
+
g(o.previewUrl), h();
|
|
121
|
+
const n = a.value.filter((d, s) => s !== t);
|
|
122
|
+
b(n), v?.validateField(f.value, n);
|
|
96
123
|
}
|
|
97
124
|
};
|
|
98
|
-
|
|
99
|
-
|
|
125
|
+
Z(
|
|
126
|
+
F,
|
|
100
127
|
(e) => {
|
|
101
|
-
const
|
|
102
|
-
|
|
128
|
+
const t = [...e];
|
|
129
|
+
x(t), a.value = t, t.length === 0 && h();
|
|
103
130
|
},
|
|
104
131
|
{ deep: !0 }
|
|
105
|
-
),
|
|
106
|
-
Array.from(l).forEach((e) =>
|
|
107
|
-
}),
|
|
108
|
-
const
|
|
109
|
-
() =>
|
|
110
|
-
"nmorph-file-upload": [
|
|
132
|
+
), ee(() => {
|
|
133
|
+
Array.from(l).forEach((e) => g(e));
|
|
134
|
+
}), j({ inputDOMRef: u });
|
|
135
|
+
const Q = C(
|
|
136
|
+
() => te({
|
|
137
|
+
"nmorph-file-upload": [r.disabled && "disabled"]
|
|
111
138
|
})
|
|
112
|
-
),
|
|
113
|
-
return
|
|
139
|
+
), _ = { t: N, props: r, emit: c, computedButtonText: k, id: f, name: E, autocomplete: W, tabindex: D, modelValue: F, updateModelValue: L, formData: v, knownResolutionEntries: R, extensionByResolution: T, getPlainType: A, getFileExtension: I, getKnownResolutionByMime: S, getFileTypeCandidates: y, isKnownFileType: i, isImageFile: K, isFileAllowed: P, inputAccept: $, typeFileIconMap: z, inputDOMRef: u, files: a, createdPreviewUrls: l, resetInputValue: h, revokePreviewUrl: g, revokeRemovedPreviewUrls: x, filesChanged: b, getFormValidationResult: U, openFileSelector: G, handleFileUpload: H, removeFile: J, modifiers: Q, get NmorphButton() {
|
|
140
|
+
return pe;
|
|
114
141
|
}, get NmorphIcon() {
|
|
115
|
-
return
|
|
142
|
+
return de;
|
|
116
143
|
}, get NmorphImagePreview() {
|
|
117
|
-
return
|
|
144
|
+
return ue;
|
|
118
145
|
}, get NmorphIconCross() {
|
|
119
|
-
return
|
|
146
|
+
return ve;
|
|
120
147
|
} };
|
|
121
|
-
return Object.defineProperty(
|
|
148
|
+
return Object.defineProperty(_, "__isScriptSetup", { enumerable: !1, value: !0 }), _;
|
|
122
149
|
}
|
|
123
150
|
});
|
|
124
151
|
export {
|
|
125
|
-
|
|
152
|
+
Pe as default
|
|
126
153
|
};
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import { defineComponent as i, computed as p, provide as
|
|
2
|
-
import { useModifiers as
|
|
3
|
-
import { useFormValidation as
|
|
4
|
-
const
|
|
1
|
+
import { defineComponent as i, computed as p, provide as n } from "vue";
|
|
2
|
+
import { useModifiers as s } from "../../../utils/create-modifiers.js";
|
|
3
|
+
import { useFormValidation as d } from "../../../hooks/use-form-validation.js";
|
|
4
|
+
const _ = /* @__PURE__ */ i({
|
|
5
5
|
__name: "NmorphForm",
|
|
6
6
|
props: {
|
|
7
|
-
value: { type:
|
|
7
|
+
value: { type: null, required: !0 },
|
|
8
8
|
validateImmediately: { type: Boolean, required: !1, default: !1 }
|
|
9
9
|
},
|
|
10
10
|
setup(t, { expose: a }) {
|
|
11
11
|
const e = t, m = p(
|
|
12
|
-
() =>
|
|
12
|
+
() => s({
|
|
13
13
|
"nmorph-form": []
|
|
14
14
|
})
|
|
15
|
-
), o =
|
|
16
|
-
a({ formData: o }),
|
|
15
|
+
), o = d(e.value, e.validateImmediately);
|
|
16
|
+
a({ formData: o }), n("form-data", o);
|
|
17
17
|
const r = { props: e, modifiers: m, formValidationData: o };
|
|
18
18
|
return Object.defineProperty(r, "__isScriptSetup", { enumerable: !1, value: !0 }), r;
|
|
19
19
|
}
|
|
20
20
|
});
|
|
21
21
|
export {
|
|
22
|
-
|
|
22
|
+
_ as default
|
|
23
23
|
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import './NmorphFormItem.css';
|
|
2
|
-
import { defineComponent as
|
|
3
|
-
import { useModifiers as
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import { nmorphFormItemInputDataKey as
|
|
7
|
-
const
|
|
2
|
+
import { defineComponent as y, inject as S, computed as e, unref as d, provide as b, toRef as I } from "vue";
|
|
3
|
+
import { useModifiers as g } from "../../../../../utils/create-modifiers.js";
|
|
4
|
+
import q from "./inner-components/nmorph-error-box/NmorphErrorBox.vue.js";
|
|
5
|
+
import B from "./inner-components/nmorph-validation-icon/NmorphValidationIcon.vue.js";
|
|
6
|
+
import { nmorphFormItemInputDataKey as x } from "../../use-form-item-input.js";
|
|
7
|
+
const T = /* @__PURE__ */ y({
|
|
8
8
|
__name: "NmorphFormItem",
|
|
9
9
|
props: {
|
|
10
10
|
id: { type: String, required: !0 },
|
|
@@ -15,31 +15,40 @@ const B = /* @__PURE__ */ p({
|
|
|
15
15
|
showValidationIcon: { type: Boolean, required: !1, default: !0 },
|
|
16
16
|
staticErrorBoxSpace: { type: Boolean, required: !1, default: !1 }
|
|
17
17
|
},
|
|
18
|
-
setup(
|
|
19
|
-
|
|
20
|
-
const
|
|
21
|
-
() => !!
|
|
22
|
-
),
|
|
23
|
-
|
|
24
|
-
id:
|
|
25
|
-
name:
|
|
26
|
-
autocomplete:
|
|
18
|
+
setup(v, { expose: h }) {
|
|
19
|
+
h();
|
|
20
|
+
const o = v, t = S("form-data"), a = e(() => t?.fields[o.id]), r = e(() => t?.formValue[o.id]), u = e(() => r.value?.value), n = e(() => r.value?.rules || []), s = e(() => d(a.value?.errors) || []), f = e(() => d(a.value?.valid) ?? !0), p = e(() => d(a.value?.touched) ?? !1), l = e(() => a.value), V = e(
|
|
21
|
+
() => !!l.value && !!a?.value?.touched && o.showValidationIcon
|
|
22
|
+
), m = e(() => l.value && a.value?.touched);
|
|
23
|
+
b(x, {
|
|
24
|
+
id: I(o, "id"),
|
|
25
|
+
name: e(() => o.name || o.id),
|
|
26
|
+
autocomplete: e(() => o.autocomplete || void 0),
|
|
27
|
+
value: u,
|
|
28
|
+
rules: n,
|
|
29
|
+
errors: s,
|
|
30
|
+
valid: f,
|
|
31
|
+
touched: p,
|
|
32
|
+
updateValue: (i) => t?.updateFieldValue(o.id, i),
|
|
33
|
+
validate: (i) => {
|
|
34
|
+
t?.validateField(o.id, i);
|
|
35
|
+
}
|
|
27
36
|
});
|
|
28
|
-
const
|
|
29
|
-
() =>
|
|
37
|
+
const _ = e(
|
|
38
|
+
() => g({
|
|
30
39
|
"nmorph-form-item": [
|
|
31
|
-
|
|
32
|
-
|
|
40
|
+
o.label && "labeled",
|
|
41
|
+
m.value && (a.value?.valid ? "valid" : "invalid")
|
|
33
42
|
]
|
|
34
43
|
})
|
|
35
|
-
),
|
|
36
|
-
return
|
|
44
|
+
), c = { props: o, formData: t, validationData: a, fieldData: r, fieldValue: u, fieldRules: n, fieldErrors: s, fieldValid: f, fieldTouched: p, ableToShowValidation: l, showStatusIcon: V, ableToAddValidationModifiers: m, modifiers: _, get NmorphValidationIcon() {
|
|
45
|
+
return B;
|
|
37
46
|
}, get NmorphErrorBox() {
|
|
38
|
-
return
|
|
47
|
+
return q;
|
|
39
48
|
} };
|
|
40
|
-
return Object.defineProperty(
|
|
49
|
+
return Object.defineProperty(c, "__isScriptSetup", { enumerable: !1, value: !0 }), c;
|
|
41
50
|
}
|
|
42
51
|
});
|
|
43
52
|
export {
|
|
44
|
-
|
|
53
|
+
T as default
|
|
45
54
|
};
|
|
@@ -1,14 +1,35 @@
|
|
|
1
|
-
import { inject as
|
|
2
|
-
const
|
|
3
|
-
const o =
|
|
1
|
+
import { inject as r, getCurrentInstance as s, computed as n, useId as v } from "vue";
|
|
2
|
+
const i = "nmorph-form-item-input-data", f = (e) => {
|
|
3
|
+
const o = r(i, void 0), u = `nmorph-${v()}`, a = n(() => e.id || o?.id.value || u), m = n(() => e.name || o?.name.value || a.value), l = n(() => e.autocomplete || o?.autocomplete.value || void 0), d = n(() => e.tabindex ?? 0);
|
|
4
4
|
return {
|
|
5
|
-
id:
|
|
5
|
+
id: a,
|
|
6
6
|
name: m,
|
|
7
|
-
autocomplete:
|
|
8
|
-
tabindex:
|
|
7
|
+
autocomplete: l,
|
|
8
|
+
tabindex: d
|
|
9
|
+
};
|
|
10
|
+
}, c = (e, o) => Object.prototype.hasOwnProperty.call(e, o), h = (e, o, u) => {
|
|
11
|
+
const a = r(i, void 0), m = s(), l = n(() => {
|
|
12
|
+
const t = m?.vnode.props || {};
|
|
13
|
+
return c(t, "modelValue") || c(t, "model-value");
|
|
14
|
+
}), d = n(() => {
|
|
15
|
+
if (l.value) return e.modelValue !== void 0 ? e.modelValue : u;
|
|
16
|
+
const t = a?.value.value;
|
|
17
|
+
return t !== void 0 ? t : e.modelValue !== void 0 ? e.modelValue : u;
|
|
18
|
+
});
|
|
19
|
+
return {
|
|
20
|
+
formItemInputData: a,
|
|
21
|
+
modelValue: d,
|
|
22
|
+
modelValueIsControlled: l,
|
|
23
|
+
updateModelValue: (t) => {
|
|
24
|
+
l.value || a?.updateValue(t), o(t);
|
|
25
|
+
},
|
|
26
|
+
validateModelValue: (t = d.value) => {
|
|
27
|
+
a?.validate(t);
|
|
28
|
+
}
|
|
9
29
|
};
|
|
10
30
|
};
|
|
11
31
|
export {
|
|
12
|
-
|
|
13
|
-
|
|
32
|
+
i as nmorphFormItemInputDataKey,
|
|
33
|
+
f as useFormItemInput,
|
|
34
|
+
h as useFormItemModel
|
|
14
35
|
};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import './NmorphNumberInput.css';
|
|
2
|
-
import { defineComponent as
|
|
3
|
-
import { NmorphComponentHeight as
|
|
4
|
-
import { useModifiers as
|
|
5
|
-
import { useFormItemInput as
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
const
|
|
2
|
+
import { defineComponent as H, computed as n, ref as s, watch as p } from "vue";
|
|
3
|
+
import { NmorphComponentHeight as R } from "../../../types/index.js";
|
|
4
|
+
import { useModifiers as T } from "../../../utils/create-modifiers.js";
|
|
5
|
+
import { useFormItemInput as D, useFormItemModel as V } from "../nmorph-form/use-form-item-input.js";
|
|
6
|
+
import k from "../../../assets/icons/plus-thin.svg.js";
|
|
7
|
+
import z from "../../../assets/icons/minus-thin.svg.js";
|
|
8
|
+
import C from "../../basic/nmorph-icon/NmorphIcon.vue.js";
|
|
9
|
+
import F from "../../basic/nmorph-button/NmorphButton.vue.js";
|
|
10
|
+
const L = /* @__PURE__ */ H({
|
|
11
11
|
__name: "NmorphNumberInput",
|
|
12
12
|
props: {
|
|
13
13
|
modelValue: { type: Number, required: !1, default: 0 },
|
|
@@ -23,17 +23,13 @@ const E = /* @__PURE__ */ S({
|
|
|
23
23
|
tabindex: { type: Number, required: !1 }
|
|
24
24
|
},
|
|
25
25
|
emits: ["update:model-value"],
|
|
26
|
-
setup(
|
|
27
|
-
const e =
|
|
28
|
-
() =>
|
|
29
|
-
nmorph: [
|
|
26
|
+
setup(d, { expose: c, emit: f }) {
|
|
27
|
+
const e = d, { id: h, name: g, autocomplete: b, tabindex: x } = D(e), N = n(
|
|
28
|
+
() => T({
|
|
29
|
+
nmorph: [R[e.height]],
|
|
30
30
|
"nmorph-number-input": [e.disabled && "disabled", e.actionBtnPositionRight && "action-btn-position-right"]
|
|
31
31
|
})
|
|
32
|
-
),
|
|
33
|
-
t.value += e.step;
|
|
34
|
-
}, x = () => {
|
|
35
|
-
t.value -= e.step;
|
|
36
|
-
}, N = n(() => t.value <= e.min), y = n(() => t.value >= e.max), v = n(() => e.height === "thick" ? "16px" : "12px"), o = {
|
|
32
|
+
), a = {
|
|
37
33
|
thick: {
|
|
38
34
|
default: "12px",
|
|
39
35
|
right: "8px"
|
|
@@ -46,31 +42,41 @@ const E = /* @__PURE__ */ S({
|
|
|
46
42
|
default: "8px",
|
|
47
43
|
right: "5px"
|
|
48
44
|
}
|
|
49
|
-
},
|
|
45
|
+
}, v = n(() => {
|
|
50
46
|
const i = e.actionBtnPositionRight ? "right" : "default";
|
|
51
|
-
return
|
|
52
|
-
}),
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
47
|
+
return a[e.height][i];
|
|
48
|
+
}), u = f, { modelValue: o, updateModelValue: l } = V(
|
|
49
|
+
e,
|
|
50
|
+
(i) => u("update:model-value", i),
|
|
51
|
+
0
|
|
52
|
+
), t = s(o.value), y = () => {
|
|
53
|
+
t.value += e.step;
|
|
54
|
+
}, I = () => {
|
|
55
|
+
t.value -= e.step;
|
|
56
|
+
}, q = n(() => t.value <= e.min), B = n(() => t.value >= e.max), _ = n(() => e.height === "thick" ? "16px" : "12px"), M = (i) => {
|
|
57
|
+
const S = i.target;
|
|
58
|
+
let P = Number(S.value);
|
|
59
|
+
t.value = P;
|
|
56
60
|
};
|
|
57
|
-
|
|
58
|
-
i > e.max && (t.value = e.max, r.value?.blur()), t.value < e.min && (t.value = e.min, r.value?.blur()),
|
|
61
|
+
p(t, (i) => {
|
|
62
|
+
i > e.max && (t.value = e.max, r.value?.blur()), t.value < e.min && (t.value = e.min, r.value?.blur()), l(i);
|
|
63
|
+
}), p(o, (i) => {
|
|
64
|
+
t.value = i;
|
|
59
65
|
});
|
|
60
|
-
const r =
|
|
61
|
-
|
|
62
|
-
const
|
|
63
|
-
return
|
|
66
|
+
const r = s(null);
|
|
67
|
+
c({ inputDOMRef: r });
|
|
68
|
+
const m = { props: e, id: h, name: g, autocomplete: b, tabindex: x, modifiers: N, iconSizeMap: a, actionBtnIconSize: v, emit: u, modelValue: o, updateModelValue: l, initialValue: t, increaseHandler: y, decreaseHandler: I, minBtnDisabled: q, maxBtnDisabled: B, rightActionBtnHeight: _, inputHandler: M, inputDOMRef: r, get NmorphButton() {
|
|
69
|
+
return F;
|
|
64
70
|
}, get NmorphIcon() {
|
|
65
|
-
return
|
|
71
|
+
return C;
|
|
66
72
|
}, get NmorphIconMinusThin() {
|
|
67
|
-
return
|
|
73
|
+
return z;
|
|
68
74
|
}, get NmorphIconPlusThin() {
|
|
69
|
-
return
|
|
75
|
+
return k;
|
|
70
76
|
} };
|
|
71
|
-
return Object.defineProperty(
|
|
77
|
+
return Object.defineProperty(m, "__isScriptSetup", { enumerable: !1, value: !0 }), m;
|
|
72
78
|
}
|
|
73
79
|
});
|
|
74
80
|
export {
|
|
75
|
-
|
|
81
|
+
L as default
|
|
76
82
|
};
|