wave-ui 1.47.0 → 1.48.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/dist/wave-ui.cjs.js +1 -1
- package/dist/wave-ui.css +1 -1
- package/dist/wave-ui.es.js +65 -21
- package/dist/wave-ui.umd.js +1 -1
- package/package.json +4 -2
- package/src/wave-ui/components/w-input.vue +117 -34
package/dist/wave-ui.es.js
CHANGED
|
@@ -2531,7 +2531,6 @@ var wImage = /* @__PURE__ */ function() {
|
|
|
2531
2531
|
return __component__$v.exports;
|
|
2532
2532
|
}();
|
|
2533
2533
|
var render$u = function() {
|
|
2534
|
-
var _obj, _obj$1;
|
|
2535
2534
|
var _vm = this;
|
|
2536
2535
|
var _h = _vm.$createElement;
|
|
2537
2536
|
var _c = _vm._self._c || _h;
|
|
@@ -2545,7 +2544,7 @@ var render$u = function() {
|
|
|
2545
2544
|
return;
|
|
2546
2545
|
}
|
|
2547
2546
|
_vm.inputValue = $event.target.value;
|
|
2548
|
-
} } }) : [_vm.labelPosition === "left" ? [_vm.$slots.default ? _c("label", { staticClass: "w-input__label w-input__label--left w-form-el-shakable", attrs: { "for": "w-input--" + _vm._uid } }, [_vm._t("default")], 2) : _vm.label ? _c("label", { staticClass: "w-input__label w-input__label--left w-form-el-shakable", attrs: { "for": "w-input--" + _vm._uid }, domProps: { "innerHTML": _vm._s(_vm.label) } }) : _vm._e()] : _vm._e(), _c("div", { staticClass: "w-input__input-wrap", class: _vm.inputWrapClasses }, [_vm.innerIconLeft ? _c("w-icon", { staticClass: "w-input__icon w-input__icon--inner-left", attrs: { "tag": "label", "for": "w-input--" + _vm._uid }, on: { "click": function($event) {
|
|
2547
|
+
} } }) : [_vm.labelPosition === "left" ? [_vm.$slots.default ? _c("label", { staticClass: "w-input__label w-input__label--left w-form-el-shakable", class: _vm.validationClasses, attrs: { "for": "w-input--" + _vm._uid } }, [_vm._t("default")], 2) : _vm.label ? _c("label", { staticClass: "w-input__label w-input__label--left w-form-el-shakable", class: _vm.validationClasses, attrs: { "for": "w-input--" + _vm._uid }, domProps: { "innerHTML": _vm._s(_vm.label) } }) : _vm._e()] : _vm._e(), _c("div", { staticClass: "w-input__input-wrap", class: _vm.inputWrapClasses }, [_vm.innerIconLeft ? _c("w-icon", { staticClass: "w-input__icon w-input__icon--inner-left", attrs: { "tag": "label", "for": "w-input--" + _vm._uid }, on: { "click": function($event) {
|
|
2549
2548
|
return _vm.$emit("click:inner-icon-left", $event);
|
|
2550
2549
|
} } }, [_vm._v(_vm._s(_vm.innerIconLeft))]) : _vm._e(), _vm.type === "checkbox" && _vm.type !== "file" ? _c("input", _vm._g(_vm._b({ directives: [{ name: "model", rawName: "v-model", value: _vm.inputValue, expression: "inputValue" }], ref: "input", staticClass: "w-input__input", attrs: { "id": "w-input--" + _vm._uid, "name": _vm.inputName, "placeholder": _vm.placeholder || null, "step": _vm.step || null, "min": _vm.min || null, "max": _vm.max || null, "minlength": _vm.minlength || null, "maxlength": _vm.maxlength || null, "readonly": _vm.isReadonly || null, "aria-readonly": _vm.isReadonly ? "true" : "false", "disabled": _vm.isDisabled || null, "required": _vm.required || null, "tabindex": _vm.tabindex || null, "type": "checkbox" }, domProps: { "checked": Array.isArray(_vm.inputValue) ? _vm._i(_vm.inputValue, null) > -1 : _vm.inputValue }, on: { "input": _vm.onInput, "focus": _vm.onFocus, "blur": _vm.onBlur, "change": function($event) {
|
|
2551
2550
|
var $$a = _vm.inputValue, $$el = $event.target, $$c = $$el.checked ? true : false;
|
|
@@ -2566,15 +2565,15 @@ var render$u = function() {
|
|
|
2566
2565
|
return;
|
|
2567
2566
|
}
|
|
2568
2567
|
_vm.inputValue = $event.target.value;
|
|
2569
|
-
}, _vm.onInput], "focus": _vm.onFocus, "blur": _vm.onBlur } }, "input", _vm.attrs, false), _vm.listeners)) : [_c("input", _vm._b({ ref: "input", attrs: { "id": "w-input--" + _vm._uid, "type": "file", "name": _vm.name || null, "multiple": _vm.multiple || null }, on: { "focus": _vm.onFocus, "blur": _vm.onBlur, "change": _vm.onFileChange } }, "input", _vm.attrs, false)), _c("transition-group", { staticClass: "w-input__input w-input__input--file", attrs: { "tag": "label", "name": "fade", "for": "w-input--" + _vm._uid } }, [!_vm.inputFiles.length && _vm.isFocused ? _c("span", { key: "no-file", staticClass: "w-input__no-file" }, [_vm._t("no-file", function() {
|
|
2568
|
+
}, _vm.onInput], "focus": _vm.onFocus, "blur": _vm.onBlur } }, "input", _vm.attrs, false), _vm.listeners)) : [_c("input", _vm._b({ ref: "input", attrs: { "id": "w-input--" + _vm._uid, "type": "file", "name": _vm.name || null, "multiple": _vm.multiple || null, "data-progress": _vm.overallFilesProgress }, on: { "focus": _vm.onFocus, "blur": _vm.onBlur, "change": _vm.onFileChange } }, "input", _vm.attrs, false)), _c("transition-group", { staticClass: "w-input__input w-input__input--file", attrs: { "tag": "label", "name": "fade", "for": "w-input--" + _vm._uid } }, [!_vm.inputFiles.length && _vm.isFocused ? _c("span", { key: "no-file", staticClass: "w-input__no-file" }, [_vm._t("no-file", function() {
|
|
2570
2569
|
return [_vm.$slots["no-file"] === void 0 ? [_vm._v("No file")] : _vm._e()];
|
|
2571
2570
|
})], 2) : _vm._e(), _vm._l(_vm.inputFiles, function(file, i) {
|
|
2572
|
-
return _c("span", { key: file.lastModified }, [_vm._v(_vm._s(i ? ", " : "")), _c("span", { key: i + "b", staticClass: "filename" }, [_vm._v(_vm._s(file.base))]), _vm._v(_vm._s(file.extension))]);
|
|
2573
|
-
})], 2)], _vm.labelPosition === "inside" && _vm.showLabelInside ? [_vm.$slots.default ? _c("label", { staticClass: "w-input__label w-input__label--inside w-form-el-shakable", class: _vm.
|
|
2571
|
+
return _c("span", { key: file.lastModified }, [_vm._v(_vm._s(i ? ", " : "")), _c("span", { key: i + "b", staticClass: "filename" }, [_vm._v(_vm._s(file.base))]), _vm._v(_vm._s(file.extension ? "." + file.extension : ""))]);
|
|
2572
|
+
})], 2)], _vm.labelPosition === "inside" && _vm.showLabelInside ? [_vm.$slots.default ? _c("label", { staticClass: "w-input__label w-input__label--inside w-form-el-shakable", class: _vm.validationClasses, attrs: { "for": "w-input--" + _vm._uid } }, [_vm._t("default")], 2) : _vm.label ? _c("label", { staticClass: "w-input__label w-input__label--inside w-form-el-shakable", class: _vm.validationClasses, attrs: { "for": "w-input--" + _vm._uid }, domProps: { "innerHTML": _vm._s(_vm.label) } }) : _vm._e()] : _vm._e(), _vm.innerIconRight ? _c("w-icon", { staticClass: "w-input__icon w-input__icon--inner-right", attrs: { "tag": "label", "for": "w-input--" + _vm._uid }, on: { "click": function($event) {
|
|
2574
2573
|
return _vm.$emit("click:inner-icon-right", $event);
|
|
2575
|
-
} } }, [_vm._v(_vm._s(_vm.innerIconRight))]) : _vm._e()], 2), _vm.type === "file" && _vm.inputFiles.length ? _c("label", { staticClass: "d-flex", attrs: { "for": "w-input--" + _vm._uid } }, [_vm._l(_vm.inputFiles, function(file, i) {
|
|
2576
|
-
return [file.progress < 100 ? _c("i", { key: i, staticClass: "w-icon wi-spinner w-icon--spin size--sm w-input__file-preview primary" }) : file.preview ? _c("img", { key: i, staticClass: "w-input__file-preview", attrs: { "src": file.preview, "alt": "" } }) : _c("i", { key: i, staticClass: "w-icon
|
|
2577
|
-
})], 2) : _vm._e(), _vm.labelPosition === "right" ? [_vm.$slots.default ? _c("label", { staticClass: "w-input__label w-input__label--right w-form-el-shakable", attrs: { "for": "w-input--" + _vm._uid } }, [_vm._t("default")], 2) : _vm.label ? _c("label", { staticClass: "w-input__label w-input__label--right w-form-el-shakable", attrs: { "for": "w-input--" + _vm._uid }, domProps: { "innerHTML": _vm._s(_vm.label) } }) : _vm._e()] : _vm._e()
|
|
2574
|
+
} } }, [_vm._v(_vm._s(_vm.innerIconRight))]) : _vm._e(), _vm.hasLoading || _vm.showProgress && (_vm.uploadInProgress || _vm.uploadComplete) ? _c("w-progress", { staticClass: "fill-width", attrs: { "size": "2", "color": _vm.progressColor || _vm.color, "value": _vm.showProgress ? (_vm.uploadInProgress || _vm.uploadComplete) && _vm.overallFilesProgress : _vm.loadingValue } }) : _vm._e()], 2), _vm.type === "file" && _vm.preview && _vm.inputFiles.length ? _c("label", { staticClass: "d-flex", attrs: { "for": "w-input--" + _vm._uid } }, [_vm._l(_vm.inputFiles, function(file, i) {
|
|
2575
|
+
return [file.progress < 100 ? _c("i", { key: i, staticClass: "w-icon wi-spinner w-icon--spin size--sm w-input__file-preview primary" }) : file.preview ? _c("img", { key: i, staticClass: "w-input__file-preview", attrs: { "src": file.preview, "alt": "" } }) : _c("i", { key: i, staticClass: "w-icon w-input__file-preview primary size--md", class: _vm.preview && typeof _vm.preview === "string" ? _vm.preview : "wi-file" })];
|
|
2576
|
+
})], 2) : _vm._e(), _vm.labelPosition === "right" ? [_vm.$slots.default ? _c("label", { staticClass: "w-input__label w-input__label--right w-form-el-shakable", class: _vm.validationClasses, attrs: { "for": "w-input--" + _vm._uid } }, [_vm._t("default")], 2) : _vm.label ? _c("label", { staticClass: "w-input__label w-input__label--right w-form-el-shakable", class: _vm.validationClasses, attrs: { "for": "w-input--" + _vm._uid }, domProps: { "innerHTML": _vm._s(_vm.label) } }) : _vm._e()] : _vm._e()]], 2);
|
|
2578
2577
|
};
|
|
2579
2578
|
var staticRenderFns$u = [];
|
|
2580
2579
|
var wInput_vue_vue_type_style_index_0_lang = "";
|
|
@@ -2604,10 +2603,12 @@ const __vue2_script$u = {
|
|
|
2604
2603
|
shadow: { type: Boolean },
|
|
2605
2604
|
tile: { type: Boolean },
|
|
2606
2605
|
multiple: { type: Boolean },
|
|
2607
|
-
preview: { type: Boolean },
|
|
2608
|
-
loading: { type: Boolean }
|
|
2606
|
+
preview: { type: [Boolean, String], default: true },
|
|
2607
|
+
loading: { type: [Boolean, Number], default: false },
|
|
2608
|
+
showProgress: { type: [Boolean] },
|
|
2609
|
+
files: { type: Array }
|
|
2609
2610
|
},
|
|
2610
|
-
emits: ["input", "update:modelValue", "focus", "blur", "click:inner-icon-left", "click:inner-icon-right"],
|
|
2611
|
+
emits: ["input", "update:modelValue", "focus", "blur", "click:inner-icon-left", "click:inner-icon-right", "update:overallProgress"],
|
|
2611
2612
|
data() {
|
|
2612
2613
|
return {
|
|
2613
2614
|
inputValue: this.value,
|
|
@@ -2628,14 +2629,48 @@ const __vue2_script$u = {
|
|
|
2628
2629
|
return listeners;
|
|
2629
2630
|
},
|
|
2630
2631
|
hasValue() {
|
|
2631
|
-
|
|
2632
|
+
switch (this.type) {
|
|
2633
|
+
case "file":
|
|
2634
|
+
return !!this.inputFiles.length;
|
|
2635
|
+
case "number":
|
|
2636
|
+
return this.inputNumberError;
|
|
2637
|
+
case "date":
|
|
2638
|
+
case "time":
|
|
2639
|
+
return true;
|
|
2640
|
+
default:
|
|
2641
|
+
return this.inputValue || this.inputValue === 0;
|
|
2642
|
+
}
|
|
2632
2643
|
},
|
|
2633
2644
|
hasLabel() {
|
|
2634
2645
|
return this.label || this.$slots.default;
|
|
2635
2646
|
},
|
|
2647
|
+
hasLoading() {
|
|
2648
|
+
return ![void 0, false].includes(this.loading);
|
|
2649
|
+
},
|
|
2650
|
+
loadingValue() {
|
|
2651
|
+
let value;
|
|
2652
|
+
if (typeof this.loading === "number")
|
|
2653
|
+
value = this.loading;
|
|
2654
|
+
else if (this.loading) {
|
|
2655
|
+
value = this.type === "file" && this.overallFilesProgress ? this.overallFilesProgress : void 0;
|
|
2656
|
+
}
|
|
2657
|
+
return value;
|
|
2658
|
+
},
|
|
2636
2659
|
showLabelInside() {
|
|
2637
2660
|
return !this.staticLabel || !this.hasValue && !this.placeholder;
|
|
2638
2661
|
},
|
|
2662
|
+
overallFilesProgress() {
|
|
2663
|
+
const progress = this.inputFiles.reduce((total2, file) => total2 + file.progress, 0);
|
|
2664
|
+
const total = progress / this.inputFiles.length;
|
|
2665
|
+
this.$emit("update:overallProgress", this.inputFiles.length ? total : void 0);
|
|
2666
|
+
return total;
|
|
2667
|
+
},
|
|
2668
|
+
uploadInProgress() {
|
|
2669
|
+
return this.overallFilesProgress > 0 && this.overallFilesProgress < 100;
|
|
2670
|
+
},
|
|
2671
|
+
uploadComplete() {
|
|
2672
|
+
return this.overallFilesProgress === 100;
|
|
2673
|
+
},
|
|
2639
2674
|
classes() {
|
|
2640
2675
|
return {
|
|
2641
2676
|
"w-input": true,
|
|
@@ -2652,6 +2687,11 @@ const __vue2_script$u = {
|
|
|
2652
2687
|
"w-input--inner-icon-right": this.innerIconRight
|
|
2653
2688
|
};
|
|
2654
2689
|
},
|
|
2690
|
+
validationClasses() {
|
|
2691
|
+
return this.isFocused && {
|
|
2692
|
+
[this.valid === false ? "error" : this.color]: this.color || this.valid === false
|
|
2693
|
+
};
|
|
2694
|
+
},
|
|
2655
2695
|
inputWrapClasses() {
|
|
2656
2696
|
return {
|
|
2657
2697
|
[this.valid === false ? "error" : this.color]: this.color || this.valid === false,
|
|
@@ -2663,7 +2703,8 @@ const __vue2_script$u = {
|
|
|
2663
2703
|
"w-input__input-wrap--underline": !this.outline,
|
|
2664
2704
|
"w-input__input-wrap--shadow": this.shadow,
|
|
2665
2705
|
"w-input__input-wrap--no-padding": !this.outline && !this.bgColor && !this.shadow && !this.round,
|
|
2666
|
-
"w-input__input-wrap--loading": this.loading
|
|
2706
|
+
"w-input__input-wrap--loading": this.loading || this.showProgress && this.uploadInProgress,
|
|
2707
|
+
"w-input__input-wrap--upload-complete": this.uploadComplete
|
|
2667
2708
|
};
|
|
2668
2709
|
}
|
|
2669
2710
|
},
|
|
@@ -2683,31 +2724,34 @@ const __vue2_script$u = {
|
|
|
2683
2724
|
},
|
|
2684
2725
|
onFileChange(e) {
|
|
2685
2726
|
this.$set(this, "inputFiles", [...e.target.files].map((original) => {
|
|
2686
|
-
const [, base, extension] = original.name.match(/^(
|
|
2727
|
+
const [, base = "", extension = "", full = ""] = original.name.match(/^(.*?)\.([^.]*)$|(.*)/);
|
|
2687
2728
|
const file = Object.assign({}, {
|
|
2688
2729
|
name: original.name,
|
|
2689
|
-
base,
|
|
2730
|
+
base: base || full,
|
|
2690
2731
|
extension,
|
|
2691
2732
|
type: original.type,
|
|
2692
2733
|
size: original.size,
|
|
2693
2734
|
lastModified: original.lastModified,
|
|
2694
2735
|
preview: null,
|
|
2695
|
-
progress: 0
|
|
2736
|
+
progress: 0,
|
|
2737
|
+
file: original
|
|
2696
2738
|
});
|
|
2697
|
-
this.
|
|
2739
|
+
this.readFile(original, file);
|
|
2698
2740
|
return file;
|
|
2699
2741
|
}));
|
|
2700
2742
|
this.$emit("update:modelValue", this.inputFiles);
|
|
2701
2743
|
this.$emit("input", this.inputFiles);
|
|
2702
|
-
this.$emit("change", this.inputFiles);
|
|
2703
2744
|
},
|
|
2704
|
-
|
|
2745
|
+
readFile(original, file) {
|
|
2705
2746
|
const reader = new FileReader();
|
|
2706
|
-
|
|
2747
|
+
const isPreviewAnIcon = typeof this.preview === "string";
|
|
2748
|
+
const isFileAnImage = original.type && original.type.startsWith("image/");
|
|
2749
|
+
if (this.preview && !isPreviewAnIcon && isFileAnImage) {
|
|
2707
2750
|
reader.addEventListener("load", (e) => {
|
|
2708
2751
|
this.$set(file, "preview", e.target.result);
|
|
2709
2752
|
});
|
|
2710
|
-
}
|
|
2753
|
+
} else
|
|
2754
|
+
delete file.preview;
|
|
2711
2755
|
reader.addEventListener("progress", (event) => {
|
|
2712
2756
|
if (event.loaded && event.total) {
|
|
2713
2757
|
this.$set(file, "progress", event.loaded * 100 / event.total);
|