maz-ui 3.22.0 → 3.22.1
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/components/MazInput.d.ts +38 -22
- package/components/MazInput.mjs +1 -2
- package/components/MazInputNumber.mjs +1 -1
- package/components/MazInputPrice.mjs +1 -1
- package/components/MazInputTags.mjs +1 -1
- package/components/MazPhoneNumberInput.d.ts +41 -1
- package/components/MazPhoneNumberInput.mjs +1 -1
- package/components/MazPicker.mjs +1 -1
- package/components/MazSelect.d.ts +33 -1
- package/components/MazSelect.mjs +1 -1
- package/components/MazTextarea.d.ts +17 -17
- package/components/MazTextarea.mjs +7 -8
- package/components/assets/MazInput.css +1 -1
- package/components/assets/MazInputPrice.css +1 -1
- package/components/assets/MazInputTags.css +1 -1
- package/components/assets/MazPhoneNumberInput.css +1 -1
- package/components/assets/MazSelect.css +1 -1
- package/components/assets/MazTextarea.css +1 -1
- package/components/chunks/{MazBtn-001d4174.mjs → MazBtn-0e02f0da.mjs} +2 -2
- package/components/chunks/{MazBtn-a3a285eb.mjs → MazBtn-2f4fa942.mjs} +2 -2
- package/components/chunks/{MazBtn-97d9e521.mjs → MazBtn-30723941.mjs} +2 -2
- package/components/chunks/{MazBtn-080c9397.mjs → MazBtn-4e1e116e.mjs} +2 -2
- package/components/chunks/{MazBtn-7f413085.mjs → MazBtn-b42e3575.mjs} +2 -2
- package/components/chunks/{MazBtn-29a43072.mjs → MazBtn-f48da79c.mjs} +2 -2
- package/components/chunks/{MazCheckbox-0595c207.mjs → MazCheckbox-9fa9179a.mjs} +1 -1
- package/components/chunks/{MazCheckbox-90f20e7f.mjs → MazCheckbox-e0bbe6ec.mjs} +1 -1
- package/components/chunks/MazInput-713b00d0.mjs +326 -0
- package/components/chunks/MazInput-b9386887.mjs +341 -0
- package/components/chunks/MazInput-c33627dd.mjs +334 -0
- package/components/chunks/{MazInputPrice-eb36a7dd.mjs → MazInputPrice-452297f5.mjs} +171 -191
- package/components/chunks/{MazInputTags-24164d56.mjs → MazInputTags-7a463b81.mjs} +176 -196
- package/components/chunks/{MazPhoneNumberInput-4cec4ade.mjs → MazPhoneNumberInput-31bc05f9.mjs} +241 -226
- package/components/chunks/{MazPicker-9f4c724c.mjs → MazPicker-50fc11d1.mjs} +4 -4
- package/components/chunks/{MazPickerCalendar-35fe36ab.mjs → MazPickerCalendar-cacb361c.mjs} +5 -5
- package/components/chunks/{MazPickerHeader-d8687abf.mjs → MazPickerHeader-63d45179.mjs} +1 -1
- package/components/chunks/{MazPickerMonthSwitcher-739ed62a.mjs → MazPickerMonthSwitcher-913c6e2c.mjs} +2 -2
- package/components/chunks/{MazPickerShortcuts-68622fe8.mjs → MazPickerShortcuts-c6fabfc6.mjs} +2 -2
- package/components/chunks/{MazPickerTime-031062b2.mjs → MazPickerTime-5e4475da.mjs} +2 -2
- package/components/chunks/{MazPickerYearSwitcher-2a006a30.mjs → MazPickerYearSwitcher-dd4fa89c.mjs} +3 -3
- package/components/chunks/{MazSelect-757bffd7.mjs → MazSelect-2e5cd411.mjs} +199 -206
- package/components/chunks/{MazSpinner-d356ad25.mjs → MazSpinner-100c99b8.mjs} +1 -1
- package/components/chunks/{MazSpinner-7bd9b831.mjs → MazSpinner-191ad23b.mjs} +1 -1
- package/components/chunks/{MazSpinner-89743727.mjs → MazSpinner-339a9006.mjs} +1 -1
- package/components/chunks/{MazSpinner-85c86950.mjs → MazSpinner-8859d658.mjs} +1 -1
- package/components/chunks/{MazSpinner-d669a3af.mjs → MazSpinner-cb6f99f3.mjs} +1 -1
- package/components/chunks/{MazSpinner-ac429216.mjs → MazSpinner-db6fc59d.mjs} +1 -1
- package/css/main.css +1 -1
- package/nuxt/index.json +1 -1
- package/package.json +1 -1
- package/types/components/MazInput.vue.d.ts +38 -22
- package/types/components/MazPhoneNumberInput.vue.d.ts +41 -1
- package/types/components/MazSelect.vue.d.ts +33 -1
- package/types/components/MazTextarea.vue.d.ts +17 -17
- package/components/chunks/MazInput-12a098d4.mjs +0 -361
- package/components/chunks/MazInput-20ea773f.mjs +0 -354
- package/components/chunks/MazInput-4313d3cc.mjs +0 -346
|
@@ -0,0 +1,341 @@
|
|
|
1
|
+
import "../assets/MazInput.css";
|
|
2
|
+
import { computed, defineComponent, defineAsyncComponent, ref, getCurrentInstance, onMounted, useSlots, openBlock, createElementBlock, normalizeClass, normalizeStyle, createElementVNode, renderSlot, createVNode, unref, createCommentVNode, withDirectives, mergeProps, toHandlers, vModelDynamic, createTextVNode, toDisplayString, createBlock, withModifiers, withCtx } from "vue";
|
|
3
|
+
function debounce(fn, delay) {
|
|
4
|
+
let timeout;
|
|
5
|
+
return function(...args) {
|
|
6
|
+
clearTimeout(timeout);
|
|
7
|
+
timeout = setTimeout(() => {
|
|
8
|
+
fn.apply(this, args);
|
|
9
|
+
}, delay);
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
const useInstanceUniqId = ({
|
|
13
|
+
componentName,
|
|
14
|
+
instance,
|
|
15
|
+
providedId
|
|
16
|
+
}) => {
|
|
17
|
+
return computed(() => providedId ?? `${componentName}-${instance == null ? void 0 : instance.uid}`);
|
|
18
|
+
};
|
|
19
|
+
const _hoisted_1 = {
|
|
20
|
+
key: 0,
|
|
21
|
+
class: "m-input-wrapper-left"
|
|
22
|
+
};
|
|
23
|
+
const _hoisted_2 = { class: "m-input-wrapper-input" };
|
|
24
|
+
const _hoisted_3 = ["id", "type", "name", "placeholder", "aria-label", "disabled", "readonly", "required"];
|
|
25
|
+
const _hoisted_4 = { key: 0 };
|
|
26
|
+
const _hoisted_5 = {
|
|
27
|
+
key: 1,
|
|
28
|
+
class: "m-input-wrapper-right"
|
|
29
|
+
};
|
|
30
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
31
|
+
...{
|
|
32
|
+
inheritAttrs: false
|
|
33
|
+
},
|
|
34
|
+
__name: "MazInput",
|
|
35
|
+
props: {
|
|
36
|
+
style: { type: [String, Array, Object], default: void 0 },
|
|
37
|
+
class: { type: String, default: void 0 },
|
|
38
|
+
modelValue: {
|
|
39
|
+
type: [String, Number, Boolean],
|
|
40
|
+
default: void 0
|
|
41
|
+
},
|
|
42
|
+
placeholder: { type: String, default: void 0 },
|
|
43
|
+
color: {
|
|
44
|
+
type: String,
|
|
45
|
+
default: "primary"
|
|
46
|
+
},
|
|
47
|
+
label: { type: String, default: void 0 },
|
|
48
|
+
name: { type: String, default: "input" },
|
|
49
|
+
type: {
|
|
50
|
+
type: String,
|
|
51
|
+
default: "text",
|
|
52
|
+
validator: (value) => {
|
|
53
|
+
return [
|
|
54
|
+
"text",
|
|
55
|
+
"date",
|
|
56
|
+
"number",
|
|
57
|
+
"tel",
|
|
58
|
+
"search",
|
|
59
|
+
"url",
|
|
60
|
+
"password",
|
|
61
|
+
"month",
|
|
62
|
+
"time",
|
|
63
|
+
"week",
|
|
64
|
+
"email"
|
|
65
|
+
].includes(value);
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
required: { type: Boolean, default: false },
|
|
69
|
+
disabled: { type: Boolean, default: false },
|
|
70
|
+
readonly: { type: Boolean, default: false },
|
|
71
|
+
id: { type: String, default: void 0 },
|
|
72
|
+
error: { type: Boolean, default: false },
|
|
73
|
+
success: { type: Boolean, default: false },
|
|
74
|
+
warning: { type: Boolean, default: false },
|
|
75
|
+
hint: { type: String, default: void 0 },
|
|
76
|
+
inputClasses: { type: String, default: void 0 },
|
|
77
|
+
noBorder: { type: Boolean, default: false },
|
|
78
|
+
noRadius: { type: Boolean, default: false },
|
|
79
|
+
size: {
|
|
80
|
+
type: String,
|
|
81
|
+
default: "md",
|
|
82
|
+
validator: (value) => {
|
|
83
|
+
return ["mini", "xs", "sm", "md", "lg", "xl"].includes(value);
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
debounce: { type: Boolean, default: false },
|
|
87
|
+
debounceDelay: { type: Number, default: 500 },
|
|
88
|
+
validButton: { type: Boolean, default: false },
|
|
89
|
+
validButtonLoading: { type: Boolean, default: false },
|
|
90
|
+
autoFocus: { type: Boolean, default: false },
|
|
91
|
+
borderActive: { type: Boolean, default: false },
|
|
92
|
+
leftIcon: { type: String, default: void 0 },
|
|
93
|
+
rightIcon: { type: String, default: void 0 }
|
|
94
|
+
},
|
|
95
|
+
emits: ["focus", "blur", "update:model-value", "click", "change", "update"],
|
|
96
|
+
setup(__props, { emit: __emit }) {
|
|
97
|
+
const MazBtn = defineAsyncComponent(() => import("./MazBtn-f48da79c.mjs"));
|
|
98
|
+
const MazIcon = defineAsyncComponent(() => import("./MazIcon-bda198b4.mjs"));
|
|
99
|
+
const EyeOffIcon = defineAsyncComponent(() => import("./eye-slash-342420ff.mjs"));
|
|
100
|
+
const EyeIcon = defineAsyncComponent(() => import("./eye-fbb13657.mjs"));
|
|
101
|
+
const CheckIcon = defineAsyncComponent(() => import("./check-f2fcce10.mjs"));
|
|
102
|
+
const props = __props;
|
|
103
|
+
const emits = __emit;
|
|
104
|
+
const hasPasswordVisible = ref(false);
|
|
105
|
+
const isFocused = ref(false);
|
|
106
|
+
const input = ref();
|
|
107
|
+
const instance = getCurrentInstance();
|
|
108
|
+
const instanceId = useInstanceUniqId({
|
|
109
|
+
componentName: "MazInput",
|
|
110
|
+
instance,
|
|
111
|
+
providedId: props.id
|
|
112
|
+
});
|
|
113
|
+
onMounted(() => {
|
|
114
|
+
var _a;
|
|
115
|
+
if (props.autoFocus) {
|
|
116
|
+
(_a = input.value) == null ? void 0 : _a.focus();
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
const inheritClasses = computed(() => props.class);
|
|
120
|
+
const isPasswordType = computed(() => props.type === "password");
|
|
121
|
+
const inputType = computed(() => hasPasswordVisible.value ? "text" : props.type);
|
|
122
|
+
const borderStyle = computed(() => {
|
|
123
|
+
if (props.noBorder)
|
|
124
|
+
return void 0;
|
|
125
|
+
if (props.error)
|
|
126
|
+
return "maz-border-danger";
|
|
127
|
+
if (props.success)
|
|
128
|
+
return "maz-border-success";
|
|
129
|
+
if (props.warning)
|
|
130
|
+
return "maz-border-warning";
|
|
131
|
+
if (isFocused.value || props.borderActive) {
|
|
132
|
+
if (props.color === "black")
|
|
133
|
+
return "maz-border-black";
|
|
134
|
+
if (props.color === "danger")
|
|
135
|
+
return "maz-border-danger";
|
|
136
|
+
if (props.color === "info")
|
|
137
|
+
return "maz-border-info";
|
|
138
|
+
if (props.color === "primary")
|
|
139
|
+
return "maz-border-primary";
|
|
140
|
+
if (props.color === "secondary")
|
|
141
|
+
return "maz-border-secondary";
|
|
142
|
+
if (props.color === "success")
|
|
143
|
+
return "maz-border-success";
|
|
144
|
+
if (props.color === "warning")
|
|
145
|
+
return "maz-border-warning";
|
|
146
|
+
if (props.color === "white")
|
|
147
|
+
return "maz-border-white";
|
|
148
|
+
}
|
|
149
|
+
return "--default-border";
|
|
150
|
+
});
|
|
151
|
+
const slots = useSlots();
|
|
152
|
+
const computedPlaceholder = computed(() => {
|
|
153
|
+
const { required, placeholder } = props;
|
|
154
|
+
if (!placeholder)
|
|
155
|
+
return void 0;
|
|
156
|
+
return required ? `${placeholder} *` : placeholder;
|
|
157
|
+
});
|
|
158
|
+
const hasValue = computed(() => props.modelValue !== void 0 && props.modelValue !== "");
|
|
159
|
+
const inputValue = computed({
|
|
160
|
+
get: () => props.modelValue,
|
|
161
|
+
set: (value) => emitValue(value)
|
|
162
|
+
});
|
|
163
|
+
const shouldUp = computed(() => {
|
|
164
|
+
return (!!props.label || !!props.hint) && (isFocused.value || !!hasValue.value || !!props.placeholder || ["date", "month", "week"].includes(props.type));
|
|
165
|
+
});
|
|
166
|
+
const hasLabel = computed(() => !!props.label || !!props.hint);
|
|
167
|
+
const hasRightPart = () => {
|
|
168
|
+
return !!slots["right-icon"] || isPasswordType.value || !!slots["valid-button"] || props.validButton || !!props.rightIcon;
|
|
169
|
+
};
|
|
170
|
+
const hasLeftPart = () => {
|
|
171
|
+
return !!slots["left-icon"] || !!props.leftIcon;
|
|
172
|
+
};
|
|
173
|
+
const focus = (event) => {
|
|
174
|
+
emits("focus", event);
|
|
175
|
+
isFocused.value = true;
|
|
176
|
+
};
|
|
177
|
+
const blur = (event) => {
|
|
178
|
+
emits("blur", event);
|
|
179
|
+
isFocused.value = false;
|
|
180
|
+
};
|
|
181
|
+
const change = (event) => emits("change", event);
|
|
182
|
+
const debounceEmitValue = debounce((value) => {
|
|
183
|
+
emits("update:model-value", value);
|
|
184
|
+
}, props.debounceDelay);
|
|
185
|
+
const emitValue = (value) => {
|
|
186
|
+
if (props.debounce)
|
|
187
|
+
return debounceEmitValue(value);
|
|
188
|
+
emits("update:model-value", value);
|
|
189
|
+
};
|
|
190
|
+
return (_ctx, _cache) => {
|
|
191
|
+
return openBlock(), createElementBlock(
|
|
192
|
+
"div",
|
|
193
|
+
{
|
|
194
|
+
class: normalizeClass(["m-input", [
|
|
195
|
+
{
|
|
196
|
+
"--is-focused": isFocused.value || __props.borderActive,
|
|
197
|
+
"--should-up": shouldUp.value,
|
|
198
|
+
"--has-label": hasLabel.value,
|
|
199
|
+
"--is-disabled": __props.disabled,
|
|
200
|
+
"--is-readonly": __props.readonly,
|
|
201
|
+
"--has-z-2": __props.error || __props.warning || __props.success,
|
|
202
|
+
"--has-state": __props.error || __props.warning || __props.success
|
|
203
|
+
},
|
|
204
|
+
inheritClasses.value,
|
|
205
|
+
`--${__props.color}`,
|
|
206
|
+
`--${__props.size}`
|
|
207
|
+
]]),
|
|
208
|
+
style: normalizeStyle(__props.style)
|
|
209
|
+
},
|
|
210
|
+
[
|
|
211
|
+
createElementVNode(
|
|
212
|
+
"div",
|
|
213
|
+
{
|
|
214
|
+
class: normalizeClass(["m-input-wrapper", [__props.inputClasses, borderStyle.value, { "maz-rounded": !__props.noRadius }]])
|
|
215
|
+
},
|
|
216
|
+
[
|
|
217
|
+
hasLeftPart() ? (openBlock(), createElementBlock("div", _hoisted_1, [
|
|
218
|
+
_ctx.$slots["left-icon"] || __props.leftIcon ? renderSlot(_ctx.$slots, "left-icon", { key: 0 }, () => [
|
|
219
|
+
createVNode(unref(MazIcon), {
|
|
220
|
+
name: __props.leftIcon,
|
|
221
|
+
class: "maz-text-xl maz-text-muted"
|
|
222
|
+
}, null, 8, ["name"])
|
|
223
|
+
], true) : createCommentVNode("v-if", true)
|
|
224
|
+
])) : createCommentVNode("v-if", true),
|
|
225
|
+
createElementVNode("div", _hoisted_2, [
|
|
226
|
+
withDirectives(createElementVNode("input", mergeProps({
|
|
227
|
+
id: unref(instanceId),
|
|
228
|
+
ref_key: "input",
|
|
229
|
+
ref: input,
|
|
230
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => inputValue.value = $event),
|
|
231
|
+
type: inputType.value,
|
|
232
|
+
name: __props.name
|
|
233
|
+
}, _ctx.$attrs, {
|
|
234
|
+
placeholder: computedPlaceholder.value,
|
|
235
|
+
"aria-label": __props.label || __props.placeholder,
|
|
236
|
+
disabled: __props.disabled,
|
|
237
|
+
readonly: __props.readonly,
|
|
238
|
+
required: __props.required,
|
|
239
|
+
class: "m-input-input"
|
|
240
|
+
}, toHandlers({
|
|
241
|
+
blur,
|
|
242
|
+
focus,
|
|
243
|
+
change
|
|
244
|
+
}, true), {
|
|
245
|
+
onClick: _cache[1] || (_cache[1] = ($event) => _ctx.$emit("click", $event))
|
|
246
|
+
}), null, 16, _hoisted_3), [
|
|
247
|
+
[vModelDynamic, inputValue.value]
|
|
248
|
+
]),
|
|
249
|
+
__props.label || __props.hint ? (openBlock(), createElementBlock(
|
|
250
|
+
"span",
|
|
251
|
+
{
|
|
252
|
+
key: 0,
|
|
253
|
+
ref: "label",
|
|
254
|
+
class: normalizeClass(["m-input-label", [
|
|
255
|
+
{
|
|
256
|
+
"maz-text-danger-600": __props.error,
|
|
257
|
+
"maz-text-success-600": __props.success,
|
|
258
|
+
"maz-text-warning-600": __props.warning
|
|
259
|
+
}
|
|
260
|
+
]])
|
|
261
|
+
},
|
|
262
|
+
[
|
|
263
|
+
createTextVNode(
|
|
264
|
+
toDisplayString(__props.hint || __props.label) + " ",
|
|
265
|
+
1
|
|
266
|
+
/* TEXT */
|
|
267
|
+
),
|
|
268
|
+
__props.required ? (openBlock(), createElementBlock("sup", _hoisted_4, "*")) : createCommentVNode("v-if", true)
|
|
269
|
+
],
|
|
270
|
+
2
|
|
271
|
+
/* CLASS */
|
|
272
|
+
)) : createCommentVNode("v-if", true)
|
|
273
|
+
]),
|
|
274
|
+
hasRightPart() ? (openBlock(), createElementBlock("div", _hoisted_5, [
|
|
275
|
+
_ctx.$slots["right-icon"] || __props.rightIcon ? renderSlot(_ctx.$slots, "right-icon", { key: 0 }, () => [
|
|
276
|
+
createVNode(unref(MazIcon), {
|
|
277
|
+
name: __props.rightIcon,
|
|
278
|
+
class: "maz-text-xl maz-text-muted"
|
|
279
|
+
}, null, 8, ["name"])
|
|
280
|
+
], true) : createCommentVNode("v-if", true),
|
|
281
|
+
isPasswordType.value ? (openBlock(), createBlock(unref(MazBtn), {
|
|
282
|
+
key: 1,
|
|
283
|
+
color: "transparent",
|
|
284
|
+
tabindex: "-1",
|
|
285
|
+
size: "mini",
|
|
286
|
+
onClick: _cache[2] || (_cache[2] = withModifiers(($event) => hasPasswordVisible.value = !hasPasswordVisible.value, ["stop"]))
|
|
287
|
+
}, {
|
|
288
|
+
default: withCtx(() => [
|
|
289
|
+
hasPasswordVisible.value ? (openBlock(), createBlock(unref(EyeOffIcon), {
|
|
290
|
+
key: 0,
|
|
291
|
+
class: "maz-text-xl maz-text-muted"
|
|
292
|
+
})) : (openBlock(), createBlock(unref(EyeIcon), {
|
|
293
|
+
key: 1,
|
|
294
|
+
class: "maz-text-xl maz-text-muted"
|
|
295
|
+
}))
|
|
296
|
+
]),
|
|
297
|
+
_: 1
|
|
298
|
+
/* STABLE */
|
|
299
|
+
})) : createCommentVNode("v-if", true),
|
|
300
|
+
_ctx.$slots["valid-button"] || __props.validButton ? renderSlot(_ctx.$slots, "valid-button", { key: 2 }, () => [
|
|
301
|
+
createVNode(unref(MazBtn), {
|
|
302
|
+
color: "transparent",
|
|
303
|
+
disabled: __props.disabled,
|
|
304
|
+
tabindex: "-1",
|
|
305
|
+
loading: __props.validButtonLoading,
|
|
306
|
+
class: "m-input-valid-button",
|
|
307
|
+
size: "mini",
|
|
308
|
+
type: "submit"
|
|
309
|
+
}, {
|
|
310
|
+
default: withCtx(() => [
|
|
311
|
+
createVNode(unref(CheckIcon), { class: "maz-text-2xl maz-text-normal" })
|
|
312
|
+
]),
|
|
313
|
+
_: 1
|
|
314
|
+
/* STABLE */
|
|
315
|
+
}, 8, ["disabled", "loading"])
|
|
316
|
+
], true) : createCommentVNode("v-if", true)
|
|
317
|
+
])) : createCommentVNode("v-if", true)
|
|
318
|
+
],
|
|
319
|
+
2
|
|
320
|
+
/* CLASS */
|
|
321
|
+
)
|
|
322
|
+
],
|
|
323
|
+
6
|
|
324
|
+
/* CLASS, STYLE */
|
|
325
|
+
);
|
|
326
|
+
};
|
|
327
|
+
}
|
|
328
|
+
});
|
|
329
|
+
const MazInput_vue_vue_type_style_index_0_scoped_32fa5093_lang = "";
|
|
330
|
+
const _export_sfc = (sfc, props) => {
|
|
331
|
+
const target = sfc.__vccOpts || sfc;
|
|
332
|
+
for (const [key, val] of props) {
|
|
333
|
+
target[key] = val;
|
|
334
|
+
}
|
|
335
|
+
return target;
|
|
336
|
+
};
|
|
337
|
+
const MazInput = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-32fa5093"]]);
|
|
338
|
+
export {
|
|
339
|
+
MazInput as M,
|
|
340
|
+
_export_sfc as _
|
|
341
|
+
};
|
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
import "../assets/MazInput.css";
|
|
2
|
+
import { computed, defineComponent, defineAsyncComponent, ref, getCurrentInstance, onMounted, useSlots, openBlock, createElementBlock, normalizeClass, normalizeStyle, createElementVNode, renderSlot, createVNode, unref, createCommentVNode, withDirectives, mergeProps, toHandlers, vModelDynamic, createTextVNode, toDisplayString, createBlock, withModifiers, withCtx } from "vue";
|
|
3
|
+
import { _ as _export_sfc } from "./_plugin-vue_export-helper-cc2b3d55.mjs";
|
|
4
|
+
function debounce(fn, delay) {
|
|
5
|
+
let timeout;
|
|
6
|
+
return function(...args) {
|
|
7
|
+
clearTimeout(timeout);
|
|
8
|
+
timeout = setTimeout(() => {
|
|
9
|
+
fn.apply(this, args);
|
|
10
|
+
}, delay);
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
const useInstanceUniqId = ({
|
|
14
|
+
componentName,
|
|
15
|
+
instance,
|
|
16
|
+
providedId
|
|
17
|
+
}) => {
|
|
18
|
+
return computed(() => providedId ?? `${componentName}-${instance == null ? void 0 : instance.uid}`);
|
|
19
|
+
};
|
|
20
|
+
const _hoisted_1 = {
|
|
21
|
+
key: 0,
|
|
22
|
+
class: "m-input-wrapper-left"
|
|
23
|
+
};
|
|
24
|
+
const _hoisted_2 = { class: "m-input-wrapper-input" };
|
|
25
|
+
const _hoisted_3 = ["id", "type", "name", "placeholder", "aria-label", "disabled", "readonly", "required"];
|
|
26
|
+
const _hoisted_4 = { key: 0 };
|
|
27
|
+
const _hoisted_5 = {
|
|
28
|
+
key: 1,
|
|
29
|
+
class: "m-input-wrapper-right"
|
|
30
|
+
};
|
|
31
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
32
|
+
...{
|
|
33
|
+
inheritAttrs: false
|
|
34
|
+
},
|
|
35
|
+
__name: "MazInput",
|
|
36
|
+
props: {
|
|
37
|
+
style: { type: [String, Array, Object], default: void 0 },
|
|
38
|
+
class: { type: String, default: void 0 },
|
|
39
|
+
modelValue: {
|
|
40
|
+
type: [String, Number, Boolean],
|
|
41
|
+
default: void 0
|
|
42
|
+
},
|
|
43
|
+
placeholder: { type: String, default: void 0 },
|
|
44
|
+
color: {
|
|
45
|
+
type: String,
|
|
46
|
+
default: "primary"
|
|
47
|
+
},
|
|
48
|
+
label: { type: String, default: void 0 },
|
|
49
|
+
name: { type: String, default: "input" },
|
|
50
|
+
type: {
|
|
51
|
+
type: String,
|
|
52
|
+
default: "text",
|
|
53
|
+
validator: (value) => {
|
|
54
|
+
return [
|
|
55
|
+
"text",
|
|
56
|
+
"date",
|
|
57
|
+
"number",
|
|
58
|
+
"tel",
|
|
59
|
+
"search",
|
|
60
|
+
"url",
|
|
61
|
+
"password",
|
|
62
|
+
"month",
|
|
63
|
+
"time",
|
|
64
|
+
"week",
|
|
65
|
+
"email"
|
|
66
|
+
].includes(value);
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
required: { type: Boolean, default: false },
|
|
70
|
+
disabled: { type: Boolean, default: false },
|
|
71
|
+
readonly: { type: Boolean, default: false },
|
|
72
|
+
id: { type: String, default: void 0 },
|
|
73
|
+
error: { type: Boolean, default: false },
|
|
74
|
+
success: { type: Boolean, default: false },
|
|
75
|
+
warning: { type: Boolean, default: false },
|
|
76
|
+
hint: { type: String, default: void 0 },
|
|
77
|
+
inputClasses: { type: String, default: void 0 },
|
|
78
|
+
noBorder: { type: Boolean, default: false },
|
|
79
|
+
noRadius: { type: Boolean, default: false },
|
|
80
|
+
size: {
|
|
81
|
+
type: String,
|
|
82
|
+
default: "md",
|
|
83
|
+
validator: (value) => {
|
|
84
|
+
return ["mini", "xs", "sm", "md", "lg", "xl"].includes(value);
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
debounce: { type: Boolean, default: false },
|
|
88
|
+
debounceDelay: { type: Number, default: 500 },
|
|
89
|
+
validButton: { type: Boolean, default: false },
|
|
90
|
+
validButtonLoading: { type: Boolean, default: false },
|
|
91
|
+
autoFocus: { type: Boolean, default: false },
|
|
92
|
+
borderActive: { type: Boolean, default: false },
|
|
93
|
+
leftIcon: { type: String, default: void 0 },
|
|
94
|
+
rightIcon: { type: String, default: void 0 }
|
|
95
|
+
},
|
|
96
|
+
emits: ["focus", "blur", "update:model-value", "click", "change", "update"],
|
|
97
|
+
setup(__props, { emit: __emit }) {
|
|
98
|
+
const MazBtn = defineAsyncComponent(() => import("./MazBtn-cf0c8fcb.mjs"));
|
|
99
|
+
const MazIcon = defineAsyncComponent(() => import("./MazIcon-bda198b4.mjs"));
|
|
100
|
+
const EyeOffIcon = defineAsyncComponent(() => import("./eye-slash-342420ff.mjs"));
|
|
101
|
+
const EyeIcon = defineAsyncComponent(() => import("./eye-fbb13657.mjs"));
|
|
102
|
+
const CheckIcon = defineAsyncComponent(() => import("./check-f2fcce10.mjs"));
|
|
103
|
+
const props = __props;
|
|
104
|
+
const emits = __emit;
|
|
105
|
+
const hasPasswordVisible = ref(false);
|
|
106
|
+
const isFocused = ref(false);
|
|
107
|
+
const input = ref();
|
|
108
|
+
const instance = getCurrentInstance();
|
|
109
|
+
const instanceId = useInstanceUniqId({
|
|
110
|
+
componentName: "MazInput",
|
|
111
|
+
instance,
|
|
112
|
+
providedId: props.id
|
|
113
|
+
});
|
|
114
|
+
onMounted(() => {
|
|
115
|
+
var _a;
|
|
116
|
+
if (props.autoFocus) {
|
|
117
|
+
(_a = input.value) == null ? void 0 : _a.focus();
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
const inheritClasses = computed(() => props.class);
|
|
121
|
+
const isPasswordType = computed(() => props.type === "password");
|
|
122
|
+
const inputType = computed(() => hasPasswordVisible.value ? "text" : props.type);
|
|
123
|
+
const borderStyle = computed(() => {
|
|
124
|
+
if (props.noBorder)
|
|
125
|
+
return void 0;
|
|
126
|
+
if (props.error)
|
|
127
|
+
return "maz-border-danger";
|
|
128
|
+
if (props.success)
|
|
129
|
+
return "maz-border-success";
|
|
130
|
+
if (props.warning)
|
|
131
|
+
return "maz-border-warning";
|
|
132
|
+
if (isFocused.value || props.borderActive) {
|
|
133
|
+
if (props.color === "black")
|
|
134
|
+
return "maz-border-black";
|
|
135
|
+
if (props.color === "danger")
|
|
136
|
+
return "maz-border-danger";
|
|
137
|
+
if (props.color === "info")
|
|
138
|
+
return "maz-border-info";
|
|
139
|
+
if (props.color === "primary")
|
|
140
|
+
return "maz-border-primary";
|
|
141
|
+
if (props.color === "secondary")
|
|
142
|
+
return "maz-border-secondary";
|
|
143
|
+
if (props.color === "success")
|
|
144
|
+
return "maz-border-success";
|
|
145
|
+
if (props.color === "warning")
|
|
146
|
+
return "maz-border-warning";
|
|
147
|
+
if (props.color === "white")
|
|
148
|
+
return "maz-border-white";
|
|
149
|
+
}
|
|
150
|
+
return "--default-border";
|
|
151
|
+
});
|
|
152
|
+
const slots = useSlots();
|
|
153
|
+
const computedPlaceholder = computed(() => {
|
|
154
|
+
const { required, placeholder } = props;
|
|
155
|
+
if (!placeholder)
|
|
156
|
+
return void 0;
|
|
157
|
+
return required ? `${placeholder} *` : placeholder;
|
|
158
|
+
});
|
|
159
|
+
const hasValue = computed(() => props.modelValue !== void 0 && props.modelValue !== "");
|
|
160
|
+
const inputValue = computed({
|
|
161
|
+
get: () => props.modelValue,
|
|
162
|
+
set: (value) => emitValue(value)
|
|
163
|
+
});
|
|
164
|
+
const shouldUp = computed(() => {
|
|
165
|
+
return (!!props.label || !!props.hint) && (isFocused.value || !!hasValue.value || !!props.placeholder || ["date", "month", "week"].includes(props.type));
|
|
166
|
+
});
|
|
167
|
+
const hasLabel = computed(() => !!props.label || !!props.hint);
|
|
168
|
+
const hasRightPart = () => {
|
|
169
|
+
return !!slots["right-icon"] || isPasswordType.value || !!slots["valid-button"] || props.validButton || !!props.rightIcon;
|
|
170
|
+
};
|
|
171
|
+
const hasLeftPart = () => {
|
|
172
|
+
return !!slots["left-icon"] || !!props.leftIcon;
|
|
173
|
+
};
|
|
174
|
+
const focus = (event) => {
|
|
175
|
+
emits("focus", event);
|
|
176
|
+
isFocused.value = true;
|
|
177
|
+
};
|
|
178
|
+
const blur = (event) => {
|
|
179
|
+
emits("blur", event);
|
|
180
|
+
isFocused.value = false;
|
|
181
|
+
};
|
|
182
|
+
const change = (event) => emits("change", event);
|
|
183
|
+
const debounceEmitValue = debounce((value) => {
|
|
184
|
+
emits("update:model-value", value);
|
|
185
|
+
}, props.debounceDelay);
|
|
186
|
+
const emitValue = (value) => {
|
|
187
|
+
if (props.debounce)
|
|
188
|
+
return debounceEmitValue(value);
|
|
189
|
+
emits("update:model-value", value);
|
|
190
|
+
};
|
|
191
|
+
return (_ctx, _cache) => {
|
|
192
|
+
return openBlock(), createElementBlock(
|
|
193
|
+
"div",
|
|
194
|
+
{
|
|
195
|
+
class: normalizeClass(["m-input", [
|
|
196
|
+
{
|
|
197
|
+
"--is-focused": isFocused.value || __props.borderActive,
|
|
198
|
+
"--should-up": shouldUp.value,
|
|
199
|
+
"--has-label": hasLabel.value,
|
|
200
|
+
"--is-disabled": __props.disabled,
|
|
201
|
+
"--is-readonly": __props.readonly,
|
|
202
|
+
"--has-z-2": __props.error || __props.warning || __props.success,
|
|
203
|
+
"--has-state": __props.error || __props.warning || __props.success
|
|
204
|
+
},
|
|
205
|
+
inheritClasses.value,
|
|
206
|
+
`--${__props.color}`,
|
|
207
|
+
`--${__props.size}`
|
|
208
|
+
]]),
|
|
209
|
+
style: normalizeStyle(__props.style)
|
|
210
|
+
},
|
|
211
|
+
[
|
|
212
|
+
createElementVNode(
|
|
213
|
+
"div",
|
|
214
|
+
{
|
|
215
|
+
class: normalizeClass(["m-input-wrapper", [__props.inputClasses, borderStyle.value, { "maz-rounded": !__props.noRadius }]])
|
|
216
|
+
},
|
|
217
|
+
[
|
|
218
|
+
hasLeftPart() ? (openBlock(), createElementBlock("div", _hoisted_1, [
|
|
219
|
+
_ctx.$slots["left-icon"] || __props.leftIcon ? renderSlot(_ctx.$slots, "left-icon", { key: 0 }, () => [
|
|
220
|
+
createVNode(unref(MazIcon), {
|
|
221
|
+
name: __props.leftIcon,
|
|
222
|
+
class: "maz-text-xl maz-text-muted"
|
|
223
|
+
}, null, 8, ["name"])
|
|
224
|
+
], true) : createCommentVNode("v-if", true)
|
|
225
|
+
])) : createCommentVNode("v-if", true),
|
|
226
|
+
createElementVNode("div", _hoisted_2, [
|
|
227
|
+
withDirectives(createElementVNode("input", mergeProps({
|
|
228
|
+
id: unref(instanceId),
|
|
229
|
+
ref_key: "input",
|
|
230
|
+
ref: input,
|
|
231
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => inputValue.value = $event),
|
|
232
|
+
type: inputType.value,
|
|
233
|
+
name: __props.name
|
|
234
|
+
}, _ctx.$attrs, {
|
|
235
|
+
placeholder: computedPlaceholder.value,
|
|
236
|
+
"aria-label": __props.label || __props.placeholder,
|
|
237
|
+
disabled: __props.disabled,
|
|
238
|
+
readonly: __props.readonly,
|
|
239
|
+
required: __props.required,
|
|
240
|
+
class: "m-input-input"
|
|
241
|
+
}, toHandlers({
|
|
242
|
+
blur,
|
|
243
|
+
focus,
|
|
244
|
+
change
|
|
245
|
+
}, true), {
|
|
246
|
+
onClick: _cache[1] || (_cache[1] = ($event) => _ctx.$emit("click", $event))
|
|
247
|
+
}), null, 16, _hoisted_3), [
|
|
248
|
+
[vModelDynamic, inputValue.value]
|
|
249
|
+
]),
|
|
250
|
+
__props.label || __props.hint ? (openBlock(), createElementBlock(
|
|
251
|
+
"span",
|
|
252
|
+
{
|
|
253
|
+
key: 0,
|
|
254
|
+
ref: "label",
|
|
255
|
+
class: normalizeClass(["m-input-label", [
|
|
256
|
+
{
|
|
257
|
+
"maz-text-danger-600": __props.error,
|
|
258
|
+
"maz-text-success-600": __props.success,
|
|
259
|
+
"maz-text-warning-600": __props.warning
|
|
260
|
+
}
|
|
261
|
+
]])
|
|
262
|
+
},
|
|
263
|
+
[
|
|
264
|
+
createTextVNode(
|
|
265
|
+
toDisplayString(__props.hint || __props.label) + " ",
|
|
266
|
+
1
|
|
267
|
+
/* TEXT */
|
|
268
|
+
),
|
|
269
|
+
__props.required ? (openBlock(), createElementBlock("sup", _hoisted_4, "*")) : createCommentVNode("v-if", true)
|
|
270
|
+
],
|
|
271
|
+
2
|
|
272
|
+
/* CLASS */
|
|
273
|
+
)) : createCommentVNode("v-if", true)
|
|
274
|
+
]),
|
|
275
|
+
hasRightPart() ? (openBlock(), createElementBlock("div", _hoisted_5, [
|
|
276
|
+
_ctx.$slots["right-icon"] || __props.rightIcon ? renderSlot(_ctx.$slots, "right-icon", { key: 0 }, () => [
|
|
277
|
+
createVNode(unref(MazIcon), {
|
|
278
|
+
name: __props.rightIcon,
|
|
279
|
+
class: "maz-text-xl maz-text-muted"
|
|
280
|
+
}, null, 8, ["name"])
|
|
281
|
+
], true) : createCommentVNode("v-if", true),
|
|
282
|
+
isPasswordType.value ? (openBlock(), createBlock(unref(MazBtn), {
|
|
283
|
+
key: 1,
|
|
284
|
+
color: "transparent",
|
|
285
|
+
tabindex: "-1",
|
|
286
|
+
size: "mini",
|
|
287
|
+
onClick: _cache[2] || (_cache[2] = withModifiers(($event) => hasPasswordVisible.value = !hasPasswordVisible.value, ["stop"]))
|
|
288
|
+
}, {
|
|
289
|
+
default: withCtx(() => [
|
|
290
|
+
hasPasswordVisible.value ? (openBlock(), createBlock(unref(EyeOffIcon), {
|
|
291
|
+
key: 0,
|
|
292
|
+
class: "maz-text-xl maz-text-muted"
|
|
293
|
+
})) : (openBlock(), createBlock(unref(EyeIcon), {
|
|
294
|
+
key: 1,
|
|
295
|
+
class: "maz-text-xl maz-text-muted"
|
|
296
|
+
}))
|
|
297
|
+
]),
|
|
298
|
+
_: 1
|
|
299
|
+
/* STABLE */
|
|
300
|
+
})) : createCommentVNode("v-if", true),
|
|
301
|
+
_ctx.$slots["valid-button"] || __props.validButton ? renderSlot(_ctx.$slots, "valid-button", { key: 2 }, () => [
|
|
302
|
+
createVNode(unref(MazBtn), {
|
|
303
|
+
color: "transparent",
|
|
304
|
+
disabled: __props.disabled,
|
|
305
|
+
tabindex: "-1",
|
|
306
|
+
loading: __props.validButtonLoading,
|
|
307
|
+
class: "m-input-valid-button",
|
|
308
|
+
size: "mini",
|
|
309
|
+
type: "submit"
|
|
310
|
+
}, {
|
|
311
|
+
default: withCtx(() => [
|
|
312
|
+
createVNode(unref(CheckIcon), { class: "maz-text-2xl maz-text-normal" })
|
|
313
|
+
]),
|
|
314
|
+
_: 1
|
|
315
|
+
/* STABLE */
|
|
316
|
+
}, 8, ["disabled", "loading"])
|
|
317
|
+
], true) : createCommentVNode("v-if", true)
|
|
318
|
+
])) : createCommentVNode("v-if", true)
|
|
319
|
+
],
|
|
320
|
+
2
|
|
321
|
+
/* CLASS */
|
|
322
|
+
)
|
|
323
|
+
],
|
|
324
|
+
6
|
|
325
|
+
/* CLASS, STYLE */
|
|
326
|
+
);
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
});
|
|
330
|
+
const MazInput_vue_vue_type_style_index_0_scoped_32fa5093_lang = "";
|
|
331
|
+
const MazInput = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-32fa5093"]]);
|
|
332
|
+
export {
|
|
333
|
+
MazInput as default
|
|
334
|
+
};
|