@volverjs/ui-vue 0.0.10-beta.20 → 0.0.10-beta.22
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/VvAccordion/VvAccordion.vue.d.ts +1 -1
- package/dist/components/VvAccordionGroup/VvAccordionGroup.vue.d.ts +1 -1
- package/dist/components/VvAction/VvAction.vue.d.ts +1 -1
- package/dist/components/VvAlert/VvAlert.vue.d.ts +1 -1
- package/dist/components/VvAlertGroup/VvAlertGroup.vue.d.ts +1 -1
- package/dist/components/VvAvatar/VvAvatar.vue.d.ts +1 -1
- package/dist/components/VvAvatarGroup/VvAvatarGroup.vue.d.ts +1 -1
- package/dist/components/VvBadge/VvBadge.vue.d.ts +1 -1
- package/dist/components/VvBreadcrumb/VvBreadcrumb.vue.d.ts +1 -1
- package/dist/components/VvButton/VvButton.vue.d.ts +1 -1
- package/dist/components/VvButtonGroup/VvButtonGroup.vue.d.ts +1 -1
- package/dist/components/VvCard/VvCard.vue.d.ts +1 -1
- package/dist/components/VvCheckbox/VvCheckbox.vue.d.ts +1 -1
- package/dist/components/VvCheckboxGroup/VvCheckboxGroup.vue.d.ts +1 -1
- package/dist/components/VvCombobox/VvCombobox.vue.d.ts +67 -67
- package/dist/components/VvCombobox/index.d.ts +8 -8
- package/dist/components/VvDialog/VvDialog.vue.d.ts +1 -1
- package/dist/components/VvDropdown/VvDropdown.vue.d.ts +70 -70
- package/dist/components/VvDropdown/VvDropdownAction.vue.d.ts +1 -1
- package/dist/components/VvDropdown/VvDropdownItem.vue.d.ts +1 -1
- package/dist/components/VvDropdown/VvDropdownOptgroup.vue.d.ts +1 -1
- package/dist/components/VvDropdown/VvDropdownOption.vue.d.ts +1 -1
- package/dist/components/VvDropdown/index.d.ts +8 -8
- package/dist/components/VvIcon/VvIcon.vue.d.ts +1 -1
- package/dist/components/VvIcon/index.d.ts +12 -0
- package/dist/components/VvInputFile/VvInputFile.es.js +231 -67
- package/dist/components/VvInputFile/VvInputFile.umd.js +1 -1
- package/dist/components/VvInputFile/VvInputFile.vue.d.ts +152 -29
- package/dist/components/VvInputFile/index.d.ts +119 -14
- package/dist/components/VvInputText/VvInputClearAction.d.ts +6 -4
- package/dist/components/VvInputText/VvInputPasswordAction.d.ts +10 -8
- package/dist/components/VvInputText/VvInputStepAction.d.ts +1 -1
- package/dist/components/VvInputText/VvInputText.es.js +73 -65
- package/dist/components/VvInputText/VvInputText.umd.js +1 -1
- package/dist/components/VvInputText/VvInputText.vue.d.ts +10 -10
- package/dist/components/VvInputText/index.d.ts +6 -15
- package/dist/components/VvNav/VvNav.vue.d.ts +1 -1
- package/dist/components/VvNav/VvNavItem.vue.d.ts +1 -1
- package/dist/components/VvNav/VvNavSeparator.vue.d.ts +1 -1
- package/dist/components/VvProgress/VvProgress.vue.d.ts +1 -1
- package/dist/components/VvRadio/VvRadio.vue.d.ts +1 -1
- package/dist/components/VvRadioGroup/VvRadioGroup.vue.d.ts +1 -1
- package/dist/components/VvSelect/VvSelect.vue.d.ts +1 -1
- package/dist/components/VvTab/VvTab.vue.d.ts +1 -1
- package/dist/components/VvTextarea/VvTextarea.vue.d.ts +1 -1
- package/dist/components/VvTooltip/VvTooltip.vue.d.ts +1 -1
- package/dist/components/common/HintSlot.d.ts +1 -1
- package/dist/components/index.es.js +247 -96
- package/dist/components/index.umd.js +1 -1
- package/dist/composables/alert/useAlert.d.ts +1 -1
- package/dist/composables/dropdown/useProvideDropdown.d.ts +1 -1
- package/dist/icons.es.js +210 -210
- package/dist/icons.umd.js +1 -1
- package/dist/index.es.js +20 -12
- package/dist/index.umd.js +1 -1
- package/dist/props/index.d.ts +8 -14
- package/dist/resolvers/unplugin.es.js +20 -12
- package/dist/resolvers/unplugin.umd.js +1 -1
- package/dist/stories/InputFile/InputFile.stories.d.ts +1 -2
- package/dist/stories/InputFile/{InputFileModifiers.stories.d.ts → InputFileDropArea.stories.d.ts} +4 -4
- package/dist/stories/InputFile/InputFileIconPosition.stories.d.ts +8 -0
- package/dist/stories/InputFile/InputFileSlots.stories.d.ts +1 -0
- package/dist/types/input-file.d.ts +2 -0
- package/package.json +49 -49
- package/src/assets/icons/detailed.json +1 -1
- package/src/assets/icons/normal.json +1 -1
- package/src/assets/icons/simple.json +1 -1
- package/src/components/VvIcon/index.ts +13 -0
- package/src/components/VvInputFile/VvInputFile.vue +108 -40
- package/src/components/VvInputFile/index.ts +88 -10
- package/src/components/VvInputText/VvInputClearAction.ts +10 -6
- package/src/components/VvInputText/VvInputPasswordAction.ts +13 -9
- package/src/components/VvInputText/VvInputText.vue +6 -6
- package/src/components/VvInputText/index.ts +7 -15
- package/src/stories/InputFile/InputFile.settings.ts +1 -1
- package/src/stories/InputFile/InputFile.stories.ts +7 -16
- package/src/stories/InputFile/{InputFileModifiers.stories.ts → InputFileDropArea.stories.ts} +18 -13
- package/src/stories/InputFile/InputFileIconPosition.stories.ts +43 -0
- package/src/stories/InputFile/InputFileSlots.stories.ts +11 -3
- package/src/types/input-file.ts +4 -2
|
@@ -1223,6 +1223,18 @@ const _sfc_main$v = /* @__PURE__ */ defineComponent({
|
|
|
1223
1223
|
};
|
|
1224
1224
|
}
|
|
1225
1225
|
});
|
|
1226
|
+
const ACTION_ICONS = {
|
|
1227
|
+
showPassword: "eye-on",
|
|
1228
|
+
hidePassword: "eye-off",
|
|
1229
|
+
showDatePicker: "calendar",
|
|
1230
|
+
showTimePicker: "time",
|
|
1231
|
+
showColorPicker: "color",
|
|
1232
|
+
clear: "close",
|
|
1233
|
+
add: "add",
|
|
1234
|
+
remove: "trash",
|
|
1235
|
+
edit: "edit",
|
|
1236
|
+
download: "download"
|
|
1237
|
+
};
|
|
1226
1238
|
const VvIconPropsDefaults = {
|
|
1227
1239
|
prefix: "normal"
|
|
1228
1240
|
/* normal */
|
|
@@ -5074,14 +5086,6 @@ const INPUT_TYPES = {
|
|
|
5074
5086
|
MONTH: "month",
|
|
5075
5087
|
WEEK: "week"
|
|
5076
5088
|
};
|
|
5077
|
-
const TYPES_ICON = {
|
|
5078
|
-
PASSWORD_SHOW: "eye-on",
|
|
5079
|
-
PASSWORD_HIDE: "eye-off",
|
|
5080
|
-
DATE: "calendar",
|
|
5081
|
-
TIME: "time",
|
|
5082
|
-
COLOR: "color",
|
|
5083
|
-
SEARCH: "close"
|
|
5084
|
-
};
|
|
5085
5089
|
const VvInputTextEvents = [
|
|
5086
5090
|
"update:modelValue",
|
|
5087
5091
|
"update:masked",
|
|
@@ -5150,24 +5154,24 @@ const VvInputTextProps = {
|
|
|
5150
5154
|
* @see VVIcon
|
|
5151
5155
|
*/
|
|
5152
5156
|
iconShowPassword: {
|
|
5153
|
-
type: String,
|
|
5154
|
-
default:
|
|
5157
|
+
type: [String, Object],
|
|
5158
|
+
default: ACTION_ICONS.showPassword
|
|
5155
5159
|
},
|
|
5156
5160
|
/**
|
|
5157
5161
|
* VvIcon name for hide password button
|
|
5158
5162
|
* @see VVIcon
|
|
5159
5163
|
*/
|
|
5160
5164
|
iconHidePassword: {
|
|
5161
|
-
type: String,
|
|
5162
|
-
default:
|
|
5165
|
+
type: [String, Object],
|
|
5166
|
+
default: ACTION_ICONS.hidePassword
|
|
5163
5167
|
},
|
|
5164
5168
|
/**
|
|
5165
5169
|
* VvIcon name for clear button
|
|
5166
5170
|
* @see VVIcon
|
|
5167
5171
|
*/
|
|
5168
5172
|
iconClear: {
|
|
5169
|
-
type: String,
|
|
5170
|
-
default:
|
|
5173
|
+
type: [String, Object],
|
|
5174
|
+
default: ACTION_ICONS.clear
|
|
5171
5175
|
},
|
|
5172
5176
|
/**
|
|
5173
5177
|
* Label for step up button
|
|
@@ -5265,12 +5269,12 @@ const VvInputPasswordAction = defineComponent({
|
|
|
5265
5269
|
default: "Hide password"
|
|
5266
5270
|
},
|
|
5267
5271
|
iconShow: {
|
|
5268
|
-
type: String,
|
|
5269
|
-
default:
|
|
5272
|
+
type: [String, Object],
|
|
5273
|
+
default: ACTION_ICONS.showPassword
|
|
5270
5274
|
},
|
|
5271
5275
|
iconHide: {
|
|
5272
|
-
type: String,
|
|
5273
|
-
default:
|
|
5276
|
+
type: [String, Object],
|
|
5277
|
+
default: ACTION_ICONS.hidePassword
|
|
5274
5278
|
}
|
|
5275
5279
|
},
|
|
5276
5280
|
emits: ["toggle-password"],
|
|
@@ -5279,6 +5283,7 @@ const VvInputPasswordAction = defineComponent({
|
|
|
5279
5283
|
const activeIcon = computed(
|
|
5280
5284
|
() => active.value ? props.iconHide : props.iconShow
|
|
5281
5285
|
);
|
|
5286
|
+
const { hasIcon } = useComponentIcon(activeIcon);
|
|
5282
5287
|
function onClick(e) {
|
|
5283
5288
|
e == null ? void 0 : e.stopPropagation();
|
|
5284
5289
|
if (!props.disabled) {
|
|
@@ -5289,14 +5294,15 @@ const VvInputPasswordAction = defineComponent({
|
|
|
5289
5294
|
return {
|
|
5290
5295
|
active,
|
|
5291
5296
|
activeIcon,
|
|
5297
|
+
hasIcon,
|
|
5292
5298
|
onClick
|
|
5293
5299
|
};
|
|
5294
5300
|
},
|
|
5295
5301
|
render() {
|
|
5296
|
-
const icon = h(_sfc_main$u, {
|
|
5297
|
-
|
|
5302
|
+
const icon = this.hasIcon ? h(_sfc_main$u, {
|
|
5303
|
+
...this.hasIcon,
|
|
5298
5304
|
class: "vv-input-text__icon"
|
|
5299
|
-
});
|
|
5305
|
+
}) : void 0;
|
|
5300
5306
|
return h(
|
|
5301
5307
|
"button",
|
|
5302
5308
|
{
|
|
@@ -5369,12 +5375,13 @@ const VvInputClearAction = defineComponent({
|
|
|
5369
5375
|
default: "Clear"
|
|
5370
5376
|
},
|
|
5371
5377
|
icon: {
|
|
5372
|
-
type: String,
|
|
5378
|
+
type: [String, Object],
|
|
5373
5379
|
default: "close"
|
|
5374
5380
|
}
|
|
5375
5381
|
},
|
|
5376
5382
|
emits: ["clear"],
|
|
5377
5383
|
setup(props, { emit }) {
|
|
5384
|
+
const { hasIcon } = useComponentIcon(computed(() => props.icon));
|
|
5378
5385
|
function onClick(e) {
|
|
5379
5386
|
e == null ? void 0 : e.stopPropagation();
|
|
5380
5387
|
if (!props.disabled) {
|
|
@@ -5382,14 +5389,15 @@ const VvInputClearAction = defineComponent({
|
|
|
5382
5389
|
}
|
|
5383
5390
|
}
|
|
5384
5391
|
return {
|
|
5392
|
+
hasIcon,
|
|
5385
5393
|
onClick
|
|
5386
5394
|
};
|
|
5387
5395
|
},
|
|
5388
5396
|
render() {
|
|
5389
|
-
const icon = h(_sfc_main$u, {
|
|
5390
|
-
|
|
5397
|
+
const icon = this.hasIcon ? h(_sfc_main$u, {
|
|
5398
|
+
...this.hasIcon,
|
|
5391
5399
|
class: "vv-input-text__icon"
|
|
5392
|
-
});
|
|
5400
|
+
}) : void 0;
|
|
5393
5401
|
return h(
|
|
5394
5402
|
"button",
|
|
5395
5403
|
{
|
|
@@ -5749,14 +5757,14 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
|
|
|
5749
5757
|
}
|
|
5750
5758
|
switch (props.type) {
|
|
5751
5759
|
case INPUT_TYPES.COLOR:
|
|
5752
|
-
return { name:
|
|
5760
|
+
return { name: ACTION_ICONS.showColorPicker };
|
|
5753
5761
|
case INPUT_TYPES.DATE:
|
|
5754
5762
|
case INPUT_TYPES.DATETIME_LOCAL:
|
|
5755
5763
|
case INPUT_TYPES.WEEK:
|
|
5756
5764
|
case INPUT_TYPES.MONTH:
|
|
5757
|
-
return { name:
|
|
5765
|
+
return { name: ACTION_ICONS.showDatePicker };
|
|
5758
5766
|
case INPUT_TYPES.TIME:
|
|
5759
|
-
return { name:
|
|
5767
|
+
return { name: ACTION_ICONS.showTimePicker };
|
|
5760
5768
|
}
|
|
5761
5769
|
return void 0;
|
|
5762
5770
|
});
|
|
@@ -5789,8 +5797,8 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
|
|
|
5789
5797
|
loading: loading.value,
|
|
5790
5798
|
disabled: props.disabled,
|
|
5791
5799
|
readonly: props.readonly,
|
|
5792
|
-
"icon-before": hasIconBefore.value
|
|
5793
|
-
"icon-after": iconAfter.value
|
|
5800
|
+
"icon-before": !!hasIconBefore.value,
|
|
5801
|
+
"icon-after": !!iconAfter.value,
|
|
5794
5802
|
floating: props.floating && !isEmpty(props.label),
|
|
5795
5803
|
dirty: isDirty.value,
|
|
5796
5804
|
focus: isFocused.value,
|
|
@@ -6946,6 +6954,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
6946
6954
|
}
|
|
6947
6955
|
});
|
|
6948
6956
|
const VvInputFileProps = {
|
|
6957
|
+
...IdNameProps,
|
|
6949
6958
|
...ModifiersProps,
|
|
6950
6959
|
...ValidProps,
|
|
6951
6960
|
...InvalidProps,
|
|
@@ -6953,32 +6962,107 @@ const VvInputFileProps = {
|
|
|
6953
6962
|
...LabelProps,
|
|
6954
6963
|
...LoadingProps,
|
|
6955
6964
|
...ReadonlyProps,
|
|
6956
|
-
|
|
6957
|
-
|
|
6965
|
+
...IconProps,
|
|
6966
|
+
/**
|
|
6967
|
+
* Input value
|
|
6968
|
+
*/
|
|
6958
6969
|
modelValue: {
|
|
6959
6970
|
type: Object,
|
|
6960
6971
|
required: true
|
|
6961
6972
|
},
|
|
6962
|
-
|
|
6963
|
-
|
|
6964
|
-
|
|
6965
|
-
|
|
6966
|
-
|
|
6967
|
-
|
|
6968
|
-
|
|
6969
|
-
|
|
6973
|
+
/**
|
|
6974
|
+
* Whether to show progress bar
|
|
6975
|
+
*/
|
|
6976
|
+
progress: { type: [Number, String], default: void 0 },
|
|
6977
|
+
/**
|
|
6978
|
+
* Input
|
|
6979
|
+
* Text that appears in the form control when it has no value set
|
|
6980
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#placeholder
|
|
6981
|
+
*/
|
|
6982
|
+
placeholder: { type: String, default: void 0 },
|
|
6983
|
+
/**
|
|
6984
|
+
* File types to accept
|
|
6985
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/accept
|
|
6986
|
+
*/
|
|
6987
|
+
accept: { type: String, default: "*" },
|
|
6988
|
+
/**
|
|
6989
|
+
* Whether to allow multiple values
|
|
6990
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#multiple
|
|
6991
|
+
*/
|
|
6992
|
+
multiple: { type: Boolean, default: false },
|
|
6993
|
+
/**
|
|
6994
|
+
* Max number of files
|
|
6995
|
+
*/
|
|
6996
|
+
max: { type: [Number, String], default: void 0 },
|
|
6997
|
+
/**
|
|
6998
|
+
* Show drop area
|
|
6999
|
+
*/
|
|
7000
|
+
dropArea: { type: Boolean, default: false },
|
|
7001
|
+
/**
|
|
7002
|
+
* Label for add button
|
|
7003
|
+
*/
|
|
7004
|
+
labelAdd: {
|
|
7005
|
+
type: String,
|
|
7006
|
+
default: "Add file"
|
|
7007
|
+
},
|
|
7008
|
+
/**
|
|
7009
|
+
* VvIcon name for add button
|
|
7010
|
+
* @see VVIcon
|
|
7011
|
+
*/
|
|
7012
|
+
iconAdd: {
|
|
7013
|
+
type: [String, Object],
|
|
7014
|
+
default: ACTION_ICONS.add
|
|
7015
|
+
},
|
|
7016
|
+
/**
|
|
7017
|
+
* Label for replace button
|
|
7018
|
+
*/
|
|
7019
|
+
labelReplace: {
|
|
7020
|
+
type: String,
|
|
7021
|
+
default: "Replace file"
|
|
7022
|
+
},
|
|
7023
|
+
/**
|
|
7024
|
+
* VvIcon name for replace button
|
|
7025
|
+
* @see VVIcon
|
|
7026
|
+
*/
|
|
7027
|
+
iconReplace: {
|
|
7028
|
+
type: [String, Object],
|
|
7029
|
+
default: ACTION_ICONS.edit
|
|
7030
|
+
},
|
|
7031
|
+
/**
|
|
7032
|
+
* Label for download button
|
|
7033
|
+
*/
|
|
7034
|
+
labelDownload: {
|
|
7035
|
+
type: String,
|
|
7036
|
+
default: "Downlaod file"
|
|
7037
|
+
},
|
|
7038
|
+
/**
|
|
7039
|
+
* VvIcon name for download button
|
|
7040
|
+
* @see VVIcon
|
|
7041
|
+
*/
|
|
7042
|
+
iconDownload: {
|
|
7043
|
+
type: [String, Object],
|
|
7044
|
+
default: ACTION_ICONS.download
|
|
7045
|
+
},
|
|
7046
|
+
/**
|
|
7047
|
+
* Label for remove button
|
|
7048
|
+
*/
|
|
7049
|
+
labelRemove: {
|
|
7050
|
+
type: String,
|
|
7051
|
+
default: "Remove file"
|
|
7052
|
+
}
|
|
6970
7053
|
};
|
|
6971
7054
|
const _hoisted_1 = ["for"];
|
|
6972
7055
|
const _hoisted_2 = { class: "vv-input-file__preview" };
|
|
6973
7056
|
const _hoisted_3 = ["src", "alt"];
|
|
6974
7057
|
const _hoisted_4 = { class: "vv-input-file__wrapper" };
|
|
6975
7058
|
const _hoisted_5 = ["id", "readonly", "placeholder", "aria-describedby", "aria-invalid", "aria-errormessage", "multiple", "accept", "name"];
|
|
6976
|
-
const _hoisted_6 =
|
|
6977
|
-
const _hoisted_7 =
|
|
7059
|
+
const _hoisted_6 = ["value"];
|
|
7060
|
+
const _hoisted_7 = { class: "vv-input-file__list" };
|
|
6978
7061
|
const _hoisted_8 = ["onClick"];
|
|
6979
|
-
const _hoisted_9 =
|
|
6980
|
-
const _hoisted_10 = { class: "vv-input-file__item-
|
|
6981
|
-
const _hoisted_11 =
|
|
7062
|
+
const _hoisted_9 = ["title", "onClick"];
|
|
7063
|
+
const _hoisted_10 = { class: "vv-input-file__item-name" };
|
|
7064
|
+
const _hoisted_11 = { class: "vv-input-file__item-info" };
|
|
7065
|
+
const _hoisted_12 = ["title", "onClick"];
|
|
6982
7066
|
const __default__ = {
|
|
6983
7067
|
name: "VvInputFile"
|
|
6984
7068
|
};
|
|
@@ -6995,19 +7079,29 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
6995
7079
|
VvInputFileProps,
|
|
6996
7080
|
props
|
|
6997
7081
|
);
|
|
6998
|
-
const { modifiers, id, readonly } = toRefs(props);
|
|
7082
|
+
const { modifiers, id, readonly, icon, iconPosition, iconDownload } = toRefs(props);
|
|
6999
7083
|
const hasId = useUniqueId(id);
|
|
7000
7084
|
const hasHintId = computed(() => `${hasId.value}-hint`);
|
|
7085
|
+
const hasProgress = computed(() => {
|
|
7086
|
+
if (!props.progress) {
|
|
7087
|
+
return false;
|
|
7088
|
+
}
|
|
7089
|
+
const progress = typeof props.progress === "string" ? parseInt(props.progress) : props.progress;
|
|
7090
|
+
return progress > 0 && progress < 100;
|
|
7091
|
+
});
|
|
7092
|
+
const { hasIconBefore, hasIconAfter } = useComponentIcon(icon, iconPosition);
|
|
7093
|
+
const { hasIcon: hasIconDownload } = useComponentIcon(iconDownload);
|
|
7001
7094
|
const bemCssClasses = useModifiers(
|
|
7002
7095
|
"vv-input-file",
|
|
7003
7096
|
modifiers,
|
|
7004
7097
|
computed(() => ({
|
|
7005
7098
|
dragging: isDragging.value,
|
|
7006
|
-
loading: props.loading,
|
|
7099
|
+
loading: props.loading && !hasProgress.value,
|
|
7007
7100
|
valid: props.valid === true,
|
|
7008
7101
|
invalid: props.invalid === true,
|
|
7009
|
-
"icon-before": !!
|
|
7010
|
-
"icon-after": !!
|
|
7102
|
+
"icon-before": !!hasIconBefore.value,
|
|
7103
|
+
"icon-after": !!hasIconAfter.value,
|
|
7104
|
+
"drop-area": hasDropArea.value
|
|
7011
7105
|
}))
|
|
7012
7106
|
);
|
|
7013
7107
|
const {
|
|
@@ -7028,8 +7122,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
7028
7122
|
return typeof props.max === "string" ? parseInt(props.max) : props.max;
|
|
7029
7123
|
});
|
|
7030
7124
|
const hasDropArea = computed(() => {
|
|
7031
|
-
|
|
7032
|
-
return (_a = modifiers == null ? void 0 : modifiers.value) == null ? void 0 : _a.includes("drop-area");
|
|
7125
|
+
return props.dropArea && !readonly.value;
|
|
7033
7126
|
});
|
|
7034
7127
|
const isMultiple = computed(() => {
|
|
7035
7128
|
if (!props.multiple) {
|
|
@@ -7086,8 +7179,9 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
7086
7179
|
toReturn.push(file);
|
|
7087
7180
|
}
|
|
7088
7181
|
localModelValue.value = toReturn;
|
|
7182
|
+
selectedFileIndex.value = toReturn.length - 1;
|
|
7089
7183
|
};
|
|
7090
|
-
const
|
|
7184
|
+
const onClickDropArea = () => {
|
|
7091
7185
|
if (!inputEl.value) {
|
|
7092
7186
|
return;
|
|
7093
7187
|
}
|
|
@@ -7100,21 +7194,42 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
7100
7194
|
localModelValue.value = void 0;
|
|
7101
7195
|
return;
|
|
7102
7196
|
}
|
|
7197
|
+
if (selectedFileIndex.value === index) {
|
|
7198
|
+
selectedFileIndex.value = 0;
|
|
7199
|
+
}
|
|
7103
7200
|
const toReturn = [...localModelValue.value];
|
|
7104
7201
|
toReturn.splice(index, 1);
|
|
7105
7202
|
localModelValue.value = toReturn;
|
|
7106
7203
|
};
|
|
7107
|
-
const
|
|
7204
|
+
const selectedFileIndex = ref(0);
|
|
7205
|
+
const PREVIEW_MIME_TYPES = ["image/jpeg", "image/png"];
|
|
7108
7206
|
const previewSrc = computed(() => {
|
|
7109
7207
|
if (files.value.length === 0) {
|
|
7110
7208
|
return;
|
|
7111
7209
|
}
|
|
7112
|
-
if (files.value[
|
|
7113
|
-
return
|
|
7114
|
-
|
|
7115
|
-
|
|
7210
|
+
if (!files.value[selectedFileIndex.value]) {
|
|
7211
|
+
return void 0;
|
|
7212
|
+
}
|
|
7213
|
+
if (files.value[selectedFileIndex.value] instanceof File) {
|
|
7214
|
+
const currentFile2 = files.value[selectedFileIndex.value];
|
|
7215
|
+
if (!PREVIEW_MIME_TYPES.includes(currentFile2.type)) {
|
|
7216
|
+
return void 0;
|
|
7217
|
+
}
|
|
7218
|
+
return URL.createObjectURL(currentFile2);
|
|
7219
|
+
}
|
|
7220
|
+
const currentFile = files.value[selectedFileIndex.value];
|
|
7221
|
+
if (currentFile.thumbnailUrl) {
|
|
7222
|
+
return currentFile.thumbnailUrl;
|
|
7223
|
+
}
|
|
7224
|
+
if (!PREVIEW_MIME_TYPES.includes(currentFile.type)) {
|
|
7225
|
+
return void 0;
|
|
7226
|
+
}
|
|
7227
|
+
return currentFile.url;
|
|
7228
|
+
});
|
|
7229
|
+
watch(previewSrc, (_newValue, oldValue) => {
|
|
7230
|
+
if (oldValue) {
|
|
7231
|
+
URL.revokeObjectURL(oldValue);
|
|
7116
7232
|
}
|
|
7117
|
-
return files.value[currentFileIndex.value].url;
|
|
7118
7233
|
});
|
|
7119
7234
|
onBeforeUnmount(() => {
|
|
7120
7235
|
if (previewSrc.value) {
|
|
@@ -7137,7 +7252,24 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
7137
7252
|
link.setAttribute("download", file.name);
|
|
7138
7253
|
document.body.appendChild(link);
|
|
7139
7254
|
link.click();
|
|
7255
|
+
document.body.removeChild(link);
|
|
7256
|
+
URL.revokeObjectURL(link.href);
|
|
7140
7257
|
};
|
|
7258
|
+
const onClickSelectFile = (index) => {
|
|
7259
|
+
selectedFileIndex.value = index;
|
|
7260
|
+
};
|
|
7261
|
+
const dropdAreaActionLabel = computed(() => {
|
|
7262
|
+
if (files.value.length === 0 || isMultiple.value) {
|
|
7263
|
+
return props.labelAdd;
|
|
7264
|
+
}
|
|
7265
|
+
return props.labelReplace;
|
|
7266
|
+
});
|
|
7267
|
+
const dropAreaActionIcon = computed(() => {
|
|
7268
|
+
if (files.value.length === 0 || isMultiple.value) {
|
|
7269
|
+
return props.iconAdd;
|
|
7270
|
+
}
|
|
7271
|
+
return props.iconReplace;
|
|
7272
|
+
});
|
|
7141
7273
|
return (_ctx, _cache) => {
|
|
7142
7274
|
return openBlock(), createElementBlock(
|
|
7143
7275
|
"div",
|
|
@@ -7159,42 +7291,46 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
7159
7291
|
onDrop: withModifiers(onDrop, ["prevent", "stop"]),
|
|
7160
7292
|
onDragover: _cache[0] || (_cache[0] = withModifiers(() => {
|
|
7161
7293
|
}, ["prevent", "stop"])),
|
|
7162
|
-
onClick: withModifiers(
|
|
7294
|
+
onClick: withModifiers(onClickDropArea, ["stop"])
|
|
7163
7295
|
},
|
|
7164
7296
|
[
|
|
7165
7297
|
renderSlot(_ctx.$slots, "drop-area", {}, () => [
|
|
7166
|
-
!unref(readonly) ? (openBlock(), createBlock(_sfc_main$n, {
|
|
7167
|
-
key: 0,
|
|
7168
|
-
modifiers: "action",
|
|
7169
|
-
"aria-label": "upload",
|
|
7170
|
-
label: !previewSrc.value ? _ctx.labelButton : void 0,
|
|
7171
|
-
class: normalizeClass([{
|
|
7172
|
-
"absolute top-8 right-8": previewSrc.value
|
|
7173
|
-
}, "z-1"]),
|
|
7174
|
-
icon: !previewSrc.value ? "image" : isMultiple.value ? "add" : "edit",
|
|
7175
|
-
onClick: withModifiers(onClick, ["stop"])
|
|
7176
|
-
}, null, 8, ["label", "class", "icon"])) : createCommentVNode("v-if", true),
|
|
7177
7298
|
createElementVNode("picture", _hoisted_2, [
|
|
7178
7299
|
previewSrc.value ? (openBlock(), createElementBlock("img", {
|
|
7179
7300
|
key: 0,
|
|
7180
7301
|
src: previewSrc.value,
|
|
7181
|
-
alt: files.value[
|
|
7302
|
+
alt: files.value[selectedFileIndex.value].name
|
|
7182
7303
|
}, null, 8, _hoisted_3)) : createCommentVNode("v-if", true)
|
|
7183
|
-
])
|
|
7304
|
+
]),
|
|
7305
|
+
!unref(readonly) ? (openBlock(), createBlock(_sfc_main$n, {
|
|
7306
|
+
key: 0,
|
|
7307
|
+
modifiers: "action",
|
|
7308
|
+
label: !previewSrc.value ? dropdAreaActionLabel.value : void 0,
|
|
7309
|
+
title: previewSrc.value ? dropdAreaActionLabel.value : void 0,
|
|
7310
|
+
class: normalizeClass({
|
|
7311
|
+
"vv-input-file__drop-area-action": previewSrc.value
|
|
7312
|
+
}),
|
|
7313
|
+
icon: dropAreaActionIcon.value,
|
|
7314
|
+
onClick: withModifiers(onClickDropArea, ["stop"])
|
|
7315
|
+
}, null, 8, ["label", "title", "class", "icon"])) : createCommentVNode("v-if", true)
|
|
7184
7316
|
])
|
|
7185
7317
|
],
|
|
7186
7318
|
32
|
|
7187
7319
|
/* NEED_HYDRATION */
|
|
7188
7320
|
)) : createCommentVNode("v-if", true),
|
|
7189
7321
|
createElementVNode("div", _hoisted_4, [
|
|
7190
|
-
|
|
7191
|
-
|
|
7192
|
-
|
|
7193
|
-
|
|
7322
|
+
unref(hasIconBefore) ? (openBlock(), createBlock(
|
|
7323
|
+
_sfc_main$u,
|
|
7324
|
+
normalizeProps(mergeProps({ key: 0 }, unref(hasIconBefore))),
|
|
7325
|
+
null,
|
|
7326
|
+
16
|
|
7327
|
+
/* FULL_PROPS */
|
|
7328
|
+
)) : createCommentVNode("v-if", true),
|
|
7194
7329
|
createElementVNode("input", {
|
|
7195
7330
|
id: unref(hasId),
|
|
7196
7331
|
ref_key: "inputEl",
|
|
7197
7332
|
ref: inputEl,
|
|
7333
|
+
type: "file",
|
|
7198
7334
|
readonly: unref(readonly),
|
|
7199
7335
|
placeholder: _ctx.placeholder,
|
|
7200
7336
|
"aria-describedby": unref(hasHintLabelOrSlot) ? hasHintId.value : void 0,
|
|
@@ -7202,57 +7338,72 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
7202
7338
|
"aria-errormessage": unref(hasInvalidLabelOrSlot) ? hasHintId.value : void 0,
|
|
7203
7339
|
multiple: isMultiple.value,
|
|
7204
7340
|
accept: _ctx.accept,
|
|
7205
|
-
type: "file",
|
|
7206
7341
|
name: _ctx.name,
|
|
7207
7342
|
onChange
|
|
7208
7343
|
}, null, 40, _hoisted_5),
|
|
7209
|
-
|
|
7344
|
+
hasProgress.value ? (openBlock(), createElementBlock("progress", {
|
|
7210
7345
|
key: 1,
|
|
7211
|
-
|
|
7212
|
-
|
|
7346
|
+
class: "vv-input-file__progress",
|
|
7347
|
+
value: _ctx.progress,
|
|
7348
|
+
max: "100"
|
|
7349
|
+
}, toDisplayString(_ctx.progress) + "% ", 9, _hoisted_6)) : createCommentVNode("v-if", true),
|
|
7350
|
+
unref(hasIconAfter) ? (openBlock(), createBlock(
|
|
7351
|
+
_sfc_main$u,
|
|
7352
|
+
normalizeProps(mergeProps({ key: 2 }, unref(hasIconAfter))),
|
|
7353
|
+
null,
|
|
7354
|
+
16
|
|
7355
|
+
/* FULL_PROPS */
|
|
7356
|
+
)) : createCommentVNode("v-if", true)
|
|
7213
7357
|
]),
|
|
7214
|
-
createElementVNode("ul",
|
|
7358
|
+
createElementVNode("ul", _hoisted_7, [
|
|
7215
7359
|
(openBlock(true), createElementBlock(
|
|
7216
7360
|
Fragment,
|
|
7217
7361
|
null,
|
|
7218
7362
|
renderList(files.value, (file, index) => {
|
|
7219
7363
|
return openBlock(), createElementBlock("li", {
|
|
7220
7364
|
key: index,
|
|
7221
|
-
class: "vv-input-file__item",
|
|
7222
|
-
|
|
7365
|
+
class: normalizeClass(["vv-input-file__item", {
|
|
7366
|
+
active: index === selectedFileIndex.value && hasDropArea.value && files.value.length > 1
|
|
7367
|
+
}]),
|
|
7368
|
+
onClick: withModifiers(($event) => onClickSelectFile(index), ["stop"])
|
|
7223
7369
|
}, [
|
|
7224
|
-
|
|
7370
|
+
unref(hasIconDownload) ? (openBlock(), createElementBlock("button", {
|
|
7371
|
+
key: 0,
|
|
7225
7372
|
type: "button",
|
|
7226
|
-
class: "vv-input-file__item-
|
|
7227
|
-
title:
|
|
7228
|
-
"aria-label": "download-file",
|
|
7373
|
+
class: "vv-input-file__item-action",
|
|
7374
|
+
title: _ctx.labelDownload,
|
|
7229
7375
|
onClick: withModifiers(($event) => onClickDownloadFile(file), ["stop"])
|
|
7230
7376
|
}, [
|
|
7231
|
-
createVNode(
|
|
7232
|
-
|
|
7377
|
+
createVNode(
|
|
7378
|
+
_sfc_main$u,
|
|
7379
|
+
normalizeProps(guardReactiveProps(unref(hasIconDownload))),
|
|
7380
|
+
null,
|
|
7381
|
+
16
|
|
7382
|
+
/* FULL_PROPS */
|
|
7383
|
+
)
|
|
7384
|
+
], 8, _hoisted_9)) : createCommentVNode("v-if", true),
|
|
7233
7385
|
createElementVNode(
|
|
7234
7386
|
"div",
|
|
7235
|
-
|
|
7387
|
+
_hoisted_10,
|
|
7236
7388
|
toDisplayString(file.name),
|
|
7237
7389
|
1
|
|
7238
7390
|
/* TEXT */
|
|
7239
7391
|
),
|
|
7240
7392
|
createElementVNode(
|
|
7241
7393
|
"small",
|
|
7242
|
-
|
|
7394
|
+
_hoisted_11,
|
|
7243
7395
|
toDisplayString(sizeInKiB(file.size)) + " KB ",
|
|
7244
7396
|
1
|
|
7245
7397
|
/* TEXT */
|
|
7246
7398
|
),
|
|
7247
7399
|
!unref(readonly) ? (openBlock(), createElementBlock("button", {
|
|
7248
|
-
key:
|
|
7400
|
+
key: 1,
|
|
7249
7401
|
type: "button",
|
|
7250
7402
|
class: "vv-input-file__item-remove",
|
|
7251
|
-
title:
|
|
7252
|
-
"aria-label": "remove-file",
|
|
7403
|
+
title: _ctx.labelRemove,
|
|
7253
7404
|
onClick: withModifiers(($event) => onClickRemoveFile(index), ["stop"])
|
|
7254
|
-
}, null, 8,
|
|
7255
|
-
],
|
|
7405
|
+
}, null, 8, _hoisted_12)) : createCommentVNode("v-if", true)
|
|
7406
|
+
], 10, _hoisted_8);
|
|
7256
7407
|
}),
|
|
7257
7408
|
128
|
|
7258
7409
|
/* KEYED_FRAGMENT */
|