@volverjs/ui-vue 0.0.9-beta.9 → 0.0.9
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/auto-imports.d.ts +2 -2
- package/dist/components/VvAccordion/VvAccordion.es.js +8 -7
- package/dist/components/VvAccordionGroup/VvAccordionGroup.es.js +8 -7
- package/dist/components/VvAction/VvAction.es.js +8 -7
- package/dist/components/VvAlert/VvAlert.es.js +8 -7
- package/dist/components/VvAlertGroup/VvAlertGroup.es.js +8 -7
- package/dist/components/VvAlertGroup/VvAlertGroup.vue.d.ts +6 -6
- package/dist/components/VvAlertGroup/index.d.ts +2 -2
- package/dist/components/VvAvatar/VvAvatar.es.js +8 -7
- package/dist/components/VvAvatarGroup/VvAvatarGroup.es.js +8 -7
- package/dist/components/VvBadge/VvBadge.es.js +8 -7
- package/dist/components/VvBreadcrumb/VvBreadcrumb.es.js +8 -7
- package/dist/components/VvButton/VvButton.es.js +8 -7
- package/dist/components/VvButtonGroup/VvButtonGroup.es.js +8 -7
- package/dist/components/VvCard/VvCard.es.js +8 -7
- package/dist/components/VvCheckbox/VvCheckbox.es.js +8 -7
- package/dist/components/VvCheckboxGroup/VvCheckboxGroup.es.js +8 -7
- package/dist/components/VvCombobox/VvCombobox.es.js +145 -116
- package/dist/components/VvCombobox/VvCombobox.umd.js +1 -1
- package/dist/components/VvCombobox/VvCombobox.vue.d.ts +306 -90
- package/dist/components/VvCombobox/index.d.ts +108 -31
- package/dist/components/VvDialog/VvDialog.es.js +16 -11
- package/dist/components/VvDialog/VvDialog.umd.js +1 -1
- package/dist/components/VvDropdown/VvDropdown.es.js +19 -16
- package/dist/components/VvDropdown/VvDropdown.umd.js +1 -1
- package/dist/components/VvDropdown/VvDropdown.vue.d.ts +299 -91
- package/dist/components/VvDropdown/index.d.ts +99 -30
- package/dist/components/VvDropdownAction/VvDropdownAction.es.js +8 -7
- package/dist/components/VvDropdownOptgroup/VvDropdownOptgroup.es.js +8 -7
- package/dist/components/VvDropdownOption/VvDropdownOption.es.js +8 -7
- package/dist/components/VvInputText/VvInputText.es.js +193 -103
- package/dist/components/VvInputText/VvInputText.umd.js +1 -1
- package/dist/components/VvInputText/VvInputText.vue.d.ts +19 -37
- package/dist/components/VvInputText/index.d.ts +15 -33
- package/dist/components/VvNav/VvNav.es.js +8 -7
- package/dist/components/VvProgress/VvProgress.es.js +8 -7
- package/dist/components/VvRadio/VvRadio.es.js +8 -7
- package/dist/components/VvRadioGroup/VvRadioGroup.es.js +8 -7
- package/dist/components/VvSelect/VvSelect.es.js +8 -7
- package/dist/components/VvSelect/VvSelect.vue.d.ts +1 -1
- package/dist/components/VvTab/VvTab.es.js +8 -7
- package/dist/components/VvTextarea/VvTextarea.es.js +16 -12
- package/dist/components/VvTextarea/VvTextarea.umd.js +1 -1
- package/dist/components/VvTooltip/VvTooltip.es.js +8 -7
- package/dist/components/index.es.js +346 -221
- package/dist/components/index.umd.js +1 -1
- package/dist/constants.d.ts +4 -0
- package/dist/directives/index.es.js +8 -7
- package/dist/directives/v-tooltip.es.js +8 -7
- package/dist/icons.es.js +3 -3
- package/dist/icons.umd.js +1 -1
- package/dist/props/index.d.ts +100 -31
- package/dist/stories/AccordionGroup/AccordionGroup.stories.d.ts +2 -2
- package/dist/stories/AccordionGroup/AccordionGroupSlots.stories.d.ts +18 -18
- package/dist/stories/Combobox/Combobox.settings.d.ts +8 -0
- package/dist/stories/InputText/InputText.settings.d.ts +31 -9
- package/dist/stories/InputText/InputText.stories.d.ts +0 -1
- package/dist/stories/InputText/InputTextMask.stories.d.ts +12 -0
- package/package.json +60 -59
- 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/VvCombobox/VvCombobox.vue +40 -19
- package/src/components/VvCombobox/index.ts +13 -0
- package/src/components/VvDialog/VvDialog.vue +6 -2
- package/src/components/VvDropdown/VvDropdown.vue +18 -16
- package/src/components/VvInputText/VvInputText.vue +170 -55
- package/src/components/VvInputText/index.ts +32 -34
- package/src/components/VvTextarea/VvTextarea.vue +8 -5
- package/src/constants.ts +5 -0
- package/src/props/index.ts +7 -11
- package/src/stories/Combobox/Combobox.settings.ts +8 -0
- package/src/stories/Combobox/Combobox.test.ts +1 -1
- package/src/stories/InputText/InputText.settings.ts +36 -15
- package/src/stories/InputText/InputText.stories.ts +4 -12
- package/src/stories/InputText/InputText.test.ts +31 -15
- package/src/stories/InputText/InputTextMask.stories.ts +122 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { unref, computed, isRef, defineComponent, h, inject, ref, toRefs, openBlock, createBlock, mergeProps, createCommentVNode, watch, useSlots, createElementBlock, normalizeClass, toDisplayString, createElementVNode, renderSlot, normalizeProps, guardReactiveProps, withModifiers,
|
|
2
|
-
import {
|
|
1
|
+
import { unref, computed, isRef, defineComponent, h, inject, ref, toRefs, openBlock, createBlock, mergeProps, createCommentVNode, watch, useSlots, onMounted, createElementBlock, normalizeClass, toDisplayString, createElementVNode, renderSlot, normalizeProps, guardReactiveProps, withModifiers, createTextVNode, createVNode, createSlots, withCtx } from "vue";
|
|
2
|
+
import { useIMask } from "vue-imask";
|
|
3
3
|
import { iconExists, Icon, addIcon } from "@iconify/vue";
|
|
4
4
|
import { nanoid } from "nanoid";
|
|
5
5
|
import { useFocus, useElementVisibility } from "@vueuse/core";
|
|
@@ -221,6 +221,11 @@ const VvIconProps = {
|
|
|
221
221
|
type: [String, Array]
|
|
222
222
|
}
|
|
223
223
|
};
|
|
224
|
+
var Strategy = /* @__PURE__ */ ((Strategy2) => {
|
|
225
|
+
Strategy2["absolute"] = "absolute";
|
|
226
|
+
Strategy2["fixed"] = "fixed";
|
|
227
|
+
return Strategy2;
|
|
228
|
+
})(Strategy || {});
|
|
224
229
|
var Side = /* @__PURE__ */ ((Side2) => {
|
|
225
230
|
Side2["left"] = "left";
|
|
226
231
|
Side2["right"] = "right";
|
|
@@ -537,19 +542,15 @@ const IdProps = {
|
|
|
537
542
|
placement: {
|
|
538
543
|
type: String,
|
|
539
544
|
default: Side.bottom,
|
|
540
|
-
validator: (value) =>
|
|
541
|
-
return Object.values(Side).includes(value) || Object.values(Placement).includes(value);
|
|
542
|
-
}
|
|
545
|
+
validator: (value) => Object.values(Side).includes(value) || Object.values(Placement).includes(value)
|
|
543
546
|
},
|
|
544
547
|
/**
|
|
545
548
|
* Dropdown strategy
|
|
546
549
|
*/
|
|
547
550
|
strategy: {
|
|
548
551
|
type: String,
|
|
549
|
-
default:
|
|
550
|
-
validator: (value) =>
|
|
551
|
-
return ["fixed", "absolute"].includes(value);
|
|
552
|
-
}
|
|
552
|
+
default: void 0,
|
|
553
|
+
validator: (value) => Object.values(Strategy).includes(value)
|
|
553
554
|
},
|
|
554
555
|
/**
|
|
555
556
|
* Dropdown show / hide transition name
|
|
@@ -740,7 +741,23 @@ const TYPES_ICON = {
|
|
|
740
741
|
COLOR: "color",
|
|
741
742
|
SEARCH: "close"
|
|
742
743
|
};
|
|
743
|
-
const VvInputTextEvents = [
|
|
744
|
+
const VvInputTextEvents = [
|
|
745
|
+
"update:modelValue",
|
|
746
|
+
"update:masked",
|
|
747
|
+
"accept",
|
|
748
|
+
"accept:typed",
|
|
749
|
+
"accept:masked",
|
|
750
|
+
"accept:unmasked",
|
|
751
|
+
"complete",
|
|
752
|
+
"complete:typed",
|
|
753
|
+
"complete:masked",
|
|
754
|
+
"complete:unmasked",
|
|
755
|
+
"focus",
|
|
756
|
+
"blur",
|
|
757
|
+
"keyup",
|
|
758
|
+
"keydown",
|
|
759
|
+
"keypress"
|
|
760
|
+
];
|
|
744
761
|
const VvInputTextProps = {
|
|
745
762
|
...InputTextareaProps,
|
|
746
763
|
/**
|
|
@@ -847,44 +864,19 @@ const VvInputTextProps = {
|
|
|
847
864
|
default: "Clear"
|
|
848
865
|
},
|
|
849
866
|
/**
|
|
850
|
-
*
|
|
851
|
-
* @see https://
|
|
852
|
-
*/
|
|
853
|
-
mask: {
|
|
854
|
-
type: String,
|
|
855
|
-
default: void 0
|
|
856
|
-
},
|
|
857
|
-
/**
|
|
858
|
-
* Show mask before typing
|
|
859
|
-
* @see https://beholdr.github.io/maska/#/?id=maskinput-options
|
|
860
|
-
*/
|
|
861
|
-
maskEager: {
|
|
862
|
-
type: Boolean,
|
|
863
|
-
default: false
|
|
864
|
-
},
|
|
865
|
-
/**
|
|
866
|
-
* Write values reverse (ex. for numbers)
|
|
867
|
-
* @see https://beholdr.github.io/maska/#/?id=maskinput-options
|
|
868
|
-
*/
|
|
869
|
-
maskReversed: {
|
|
870
|
-
type: Boolean,
|
|
871
|
-
default: false
|
|
872
|
-
},
|
|
873
|
-
/**
|
|
874
|
-
* Add mask custom tokens
|
|
875
|
-
* @see https://beholdr.github.io/maska/#/?id=custom-tokens
|
|
867
|
+
* iMask options
|
|
868
|
+
* @see https://imask.js.org/guide.html
|
|
876
869
|
*/
|
|
877
|
-
|
|
870
|
+
iMask: {
|
|
878
871
|
type: Object,
|
|
879
872
|
default: void 0
|
|
880
873
|
},
|
|
881
874
|
/**
|
|
882
|
-
*
|
|
883
|
-
* @see https://beholdr.github.io/maska/#/?id=custom-tokens
|
|
875
|
+
* Masked value
|
|
884
876
|
*/
|
|
885
|
-
|
|
886
|
-
type:
|
|
887
|
-
default:
|
|
877
|
+
masked: {
|
|
878
|
+
type: String,
|
|
879
|
+
default: void 0
|
|
888
880
|
},
|
|
889
881
|
/**
|
|
890
882
|
* Adjust input width to content
|
|
@@ -905,6 +897,13 @@ const VvInputTextProps = {
|
|
|
905
897
|
*/
|
|
906
898
|
unit: {
|
|
907
899
|
type: String
|
|
900
|
+
},
|
|
901
|
+
/**
|
|
902
|
+
* Select input text on focus
|
|
903
|
+
*/
|
|
904
|
+
selectOnFocus: {
|
|
905
|
+
type: Boolean,
|
|
906
|
+
default: false
|
|
908
907
|
}
|
|
909
908
|
};
|
|
910
909
|
const VvInputPasswordAction = defineComponent({
|
|
@@ -1327,9 +1326,6 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1327
1326
|
VvInputTextProps,
|
|
1328
1327
|
props
|
|
1329
1328
|
);
|
|
1330
|
-
const inputEl = ref();
|
|
1331
|
-
const innerEl = ref();
|
|
1332
|
-
__expose({ $inner: innerEl });
|
|
1333
1329
|
const {
|
|
1334
1330
|
id,
|
|
1335
1331
|
icon,
|
|
@@ -1339,39 +1335,131 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1339
1335
|
count,
|
|
1340
1336
|
valid,
|
|
1341
1337
|
invalid,
|
|
1342
|
-
loading
|
|
1338
|
+
loading,
|
|
1339
|
+
debounce,
|
|
1340
|
+
maxlength,
|
|
1341
|
+
minlength,
|
|
1342
|
+
type,
|
|
1343
|
+
iMask,
|
|
1344
|
+
step
|
|
1343
1345
|
} = toRefs(props);
|
|
1344
1346
|
const hasId = useUniqueId(id);
|
|
1345
1347
|
const hasHintId = computed(() => `${hasId.value}-hint`);
|
|
1346
1348
|
const inputTextPlaceholder = computed(
|
|
1347
1349
|
() => props.floating && isEmpty(props.placeholder) ? " " : props.placeholder
|
|
1348
1350
|
);
|
|
1349
|
-
const
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1351
|
+
const maskReady = ref(false);
|
|
1352
|
+
const { el, mask, typed, masked, unmasked } = useIMask(
|
|
1353
|
+
computed(
|
|
1354
|
+
() => (iMask == null ? void 0 : iMask.value) ?? {
|
|
1355
|
+
mask: /./
|
|
1356
|
+
}
|
|
1357
|
+
),
|
|
1353
1358
|
{
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1359
|
+
emit,
|
|
1360
|
+
onAccept: () => {
|
|
1361
|
+
if (!maskReady.value) {
|
|
1362
|
+
return;
|
|
1363
|
+
}
|
|
1364
|
+
emit("update:masked", masked.value);
|
|
1365
|
+
if (type.value === INPUT_TYPES.NUMBER) {
|
|
1366
|
+
if (masked.value === "") {
|
|
1367
|
+
if (localModelValue.value === null || localModelValue.value === void 0) {
|
|
1368
|
+
return;
|
|
1369
|
+
}
|
|
1370
|
+
localModelValue.value = void 0;
|
|
1371
|
+
return;
|
|
1372
|
+
}
|
|
1373
|
+
if (typeof typed.value !== "number") {
|
|
1374
|
+
localModelValue.value = Number(typed.value);
|
|
1375
|
+
return;
|
|
1376
|
+
}
|
|
1377
|
+
localModelValue.value = typed.value;
|
|
1378
|
+
return;
|
|
1379
|
+
}
|
|
1380
|
+
if (type.value === INPUT_TYPES.DATE) {
|
|
1381
|
+
if (el.value instanceof HTMLInputElement && el.value.type === "date") {
|
|
1382
|
+
localModelValue.value = el.value.value;
|
|
1383
|
+
return;
|
|
1384
|
+
}
|
|
1385
|
+
let date = typed.value;
|
|
1386
|
+
if (date === null || date === "") {
|
|
1387
|
+
if (!localModelValue.value) {
|
|
1388
|
+
return;
|
|
1389
|
+
}
|
|
1390
|
+
localModelValue.value = "";
|
|
1391
|
+
return;
|
|
1392
|
+
}
|
|
1393
|
+
if (!(date instanceof Date)) {
|
|
1394
|
+
date = new Date(date);
|
|
1395
|
+
}
|
|
1396
|
+
localModelValue.value = `${date.getFullYear()}-${("0" + (date.getMonth() + 1)).slice(-2)}-${("0" + date.getDate()).slice(-2)}`;
|
|
1397
|
+
return;
|
|
1357
1398
|
}
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1399
|
+
if (type.value === INPUT_TYPES.DATETIME_LOCAL) {
|
|
1400
|
+
if (el.value instanceof HTMLInputElement && el.value.type === "datetime-local") {
|
|
1401
|
+
localModelValue.value = el.value.value;
|
|
1402
|
+
return;
|
|
1403
|
+
}
|
|
1404
|
+
let date = typed.value;
|
|
1405
|
+
if (date === null || date === "") {
|
|
1406
|
+
if (!localModelValue.value) {
|
|
1407
|
+
return;
|
|
1408
|
+
}
|
|
1409
|
+
localModelValue.value = "";
|
|
1410
|
+
return;
|
|
1411
|
+
}
|
|
1412
|
+
if (!(typed.value instanceof Date)) {
|
|
1413
|
+
date = new Date(date);
|
|
1414
|
+
}
|
|
1415
|
+
localModelValue.value = `${date.getFullYear()}-${("0" + (date.getMonth() + 1)).slice(-2)}-${("0" + date.getDate()).slice(-2)}T${("0" + date.getHours()).slice(-2)}:${("0" + date.getMinutes()).slice(-2)}`;
|
|
1416
|
+
return;
|
|
1363
1417
|
}
|
|
1364
|
-
if (
|
|
1365
|
-
return
|
|
1418
|
+
if (!localModelValue.value && !unmasked.value) {
|
|
1419
|
+
return;
|
|
1366
1420
|
}
|
|
1367
|
-
|
|
1421
|
+
localModelValue.value = unmasked.value;
|
|
1422
|
+
}
|
|
1423
|
+
}
|
|
1424
|
+
);
|
|
1425
|
+
onMounted(() => {
|
|
1426
|
+
if (mask.value) {
|
|
1427
|
+
maskReady.value = true;
|
|
1428
|
+
typed.value = localModelValue.value ?? "";
|
|
1429
|
+
}
|
|
1430
|
+
});
|
|
1431
|
+
watch(
|
|
1432
|
+
() => props.modelValue,
|
|
1433
|
+
(newValue) => {
|
|
1434
|
+
var _a;
|
|
1435
|
+
if (mask.value) {
|
|
1436
|
+
typed.value = newValue && ((_a = iMask == null ? void 0 : iMask.value) == null ? void 0 : _a.mask) === Date ? new Date(newValue) : newValue ?? "";
|
|
1368
1437
|
}
|
|
1369
1438
|
}
|
|
1370
1439
|
);
|
|
1440
|
+
watch(
|
|
1441
|
+
() => props.masked,
|
|
1442
|
+
(newValue) => {
|
|
1443
|
+
masked.value = newValue ?? "";
|
|
1444
|
+
}
|
|
1445
|
+
);
|
|
1446
|
+
const inputEl = el;
|
|
1447
|
+
const innerEl = ref();
|
|
1448
|
+
__expose({ $inner: innerEl });
|
|
1449
|
+
const localModelValue = useDebouncedInput(
|
|
1450
|
+
modelValue,
|
|
1451
|
+
emit,
|
|
1452
|
+
(debounce == null ? void 0 : debounce.value) ?? 0
|
|
1453
|
+
);
|
|
1371
1454
|
const { focused } = useComponentFocus(inputEl, emit);
|
|
1372
1455
|
const isFocused = computed(
|
|
1373
1456
|
() => focused.value && !props.disabled && !props.readonly
|
|
1374
1457
|
);
|
|
1458
|
+
watch(isFocused, (newValue) => {
|
|
1459
|
+
if (newValue && propsDefaults.value.selectOnFocus && inputEl.value) {
|
|
1460
|
+
inputEl.value.select();
|
|
1461
|
+
}
|
|
1462
|
+
});
|
|
1375
1463
|
const isVisible = useElementVisibility(inputEl);
|
|
1376
1464
|
watch(isVisible, (newValue) => {
|
|
1377
1465
|
if (newValue && props.autofocus && !props.disabled && !props.readonly) {
|
|
@@ -1389,19 +1477,27 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1389
1477
|
const isNumber = computed(() => props.type === INPUT_TYPES.NUMBER);
|
|
1390
1478
|
const onStepUp = () => {
|
|
1391
1479
|
if (isClickable.value) {
|
|
1480
|
+
if (iMask == null ? void 0 : iMask.value) {
|
|
1481
|
+
typed.value = typed.value + Number((step == null ? void 0 : step.value) ?? 1);
|
|
1482
|
+
return;
|
|
1483
|
+
}
|
|
1392
1484
|
inputEl.value.stepUp();
|
|
1393
1485
|
localModelValue.value = unref(inputEl).value;
|
|
1394
1486
|
}
|
|
1395
1487
|
};
|
|
1396
1488
|
const onStepDown = () => {
|
|
1397
1489
|
if (isClickable.value) {
|
|
1490
|
+
if (iMask == null ? void 0 : iMask.value) {
|
|
1491
|
+
typed.value = typed.value - Number((step == null ? void 0 : step.value) ?? 1);
|
|
1492
|
+
return;
|
|
1493
|
+
}
|
|
1398
1494
|
inputEl.value.stepDown();
|
|
1399
1495
|
localModelValue.value = unref(inputEl).value;
|
|
1400
1496
|
}
|
|
1401
1497
|
};
|
|
1402
1498
|
const isSearch = computed(() => props.type === INPUT_TYPES.SEARCH);
|
|
1403
1499
|
const onClear = () => {
|
|
1404
|
-
localModelValue.value =
|
|
1500
|
+
localModelValue.value = "";
|
|
1405
1501
|
};
|
|
1406
1502
|
const { hasIcon, hasIconBefore, hasIconAfter } = useComponentIcon(
|
|
1407
1503
|
icon,
|
|
@@ -1423,9 +1519,9 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1423
1519
|
}
|
|
1424
1520
|
});
|
|
1425
1521
|
const { formatted: countFormatted } = useTextCount(localModelValue, {
|
|
1426
|
-
mode:
|
|
1427
|
-
upperLimit: Number(
|
|
1428
|
-
lowerLimit: Number(
|
|
1522
|
+
mode: count.value,
|
|
1523
|
+
upperLimit: Number(maxlength == null ? void 0 : maxlength.value),
|
|
1524
|
+
lowerLimit: Number(minlength == null ? void 0 : minlength.value)
|
|
1429
1525
|
});
|
|
1430
1526
|
const isClickable = computed(() => !props.disabled && !props.readonly);
|
|
1431
1527
|
const hasTabindex = computed(
|
|
@@ -1460,17 +1556,20 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1460
1556
|
}))
|
|
1461
1557
|
);
|
|
1462
1558
|
const hasAttrs = computed(() => {
|
|
1463
|
-
const
|
|
1559
|
+
const type2 = (() => {
|
|
1464
1560
|
if (isPassword.value && showPassword.value) {
|
|
1465
1561
|
return INPUT_TYPES.TEXT;
|
|
1466
1562
|
}
|
|
1467
1563
|
if (isDateTime.value && !isDirty.value && !focused.value) {
|
|
1468
1564
|
return INPUT_TYPES.TEXT;
|
|
1469
1565
|
}
|
|
1566
|
+
if (iMask == null ? void 0 : iMask.value) {
|
|
1567
|
+
return INPUT_TYPES.TEXT;
|
|
1568
|
+
}
|
|
1470
1569
|
return props.type;
|
|
1471
1570
|
})();
|
|
1472
1571
|
const toReturn = {
|
|
1473
|
-
type,
|
|
1572
|
+
type: type2,
|
|
1474
1573
|
name: props.name,
|
|
1475
1574
|
tabindex: hasTabindex.value,
|
|
1476
1575
|
disabled: props.disabled,
|
|
@@ -1481,20 +1580,20 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1481
1580
|
"aria-describedby": hasHintLabelOrSlot.value ? hasHintId.value : void 0,
|
|
1482
1581
|
"aria-errormessage": hasInvalidLabelOrSlot.value ? hasHintId.value : void 0
|
|
1483
1582
|
};
|
|
1484
|
-
if (
|
|
1583
|
+
if (type2 === INPUT_TYPES.DATE || type2 === INPUT_TYPES.MONTH || type2 === INPUT_TYPES.WEEK || type2 === INPUT_TYPES.TIME || type2 === INPUT_TYPES.DATETIME_LOCAL || type2 === INPUT_TYPES.NUMBER) {
|
|
1485
1584
|
toReturn.step = props.step;
|
|
1486
1585
|
toReturn.max = props.max !== void 0 ? String(props.max) : void 0;
|
|
1487
1586
|
toReturn.min = props.min !== void 0 ? String(props.min) : void 0;
|
|
1488
1587
|
}
|
|
1489
|
-
if (
|
|
1588
|
+
if (type2 === INPUT_TYPES.TEXT || type2 === INPUT_TYPES.SEARCH || type2 === INPUT_TYPES.URL || type2 === INPUT_TYPES.TEL || type2 === INPUT_TYPES.EMAIL || type2 === INPUT_TYPES.PASSWORD || type2 === INPUT_TYPES.NUMBER) {
|
|
1490
1589
|
toReturn.placeholder = inputTextPlaceholder.value;
|
|
1491
1590
|
}
|
|
1492
|
-
if (
|
|
1591
|
+
if (type2 === INPUT_TYPES.TEXT || type2 === INPUT_TYPES.SEARCH || type2 === INPUT_TYPES.URL || type2 === INPUT_TYPES.TEL || type2 === INPUT_TYPES.EMAIL || type2 === INPUT_TYPES.PASSWORD) {
|
|
1493
1592
|
toReturn.minlength = props.minlength;
|
|
1494
1593
|
toReturn.maxlength = props.maxlength;
|
|
1495
1594
|
toReturn.pattern = props.pattern;
|
|
1496
1595
|
}
|
|
1497
|
-
if (
|
|
1596
|
+
if (type2 === INPUT_TYPES.EMAIL) {
|
|
1498
1597
|
toReturn.multiple = props.multiple;
|
|
1499
1598
|
}
|
|
1500
1599
|
return toReturn;
|
|
@@ -1526,31 +1625,6 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1526
1625
|
INPUT_TYPES.SEARCH,
|
|
1527
1626
|
props
|
|
1528
1627
|
);
|
|
1529
|
-
const mask = ref();
|
|
1530
|
-
watch(
|
|
1531
|
-
[
|
|
1532
|
-
() => props.mask,
|
|
1533
|
-
() => props.type,
|
|
1534
|
-
() => props.maskEager,
|
|
1535
|
-
() => props.maskReversed,
|
|
1536
|
-
() => props.maskTokens,
|
|
1537
|
-
() => props.maskTokensReplace
|
|
1538
|
-
],
|
|
1539
|
-
([newMask, newType, eager, reversed, tokens, tokensReplace]) => {
|
|
1540
|
-
if (newMask && newType === INPUT_TYPES.TEXT) {
|
|
1541
|
-
mask.value = new Mask({
|
|
1542
|
-
mask: newMask,
|
|
1543
|
-
eager,
|
|
1544
|
-
reversed,
|
|
1545
|
-
tokens,
|
|
1546
|
-
tokensReplace
|
|
1547
|
-
});
|
|
1548
|
-
return;
|
|
1549
|
-
}
|
|
1550
|
-
mask.value = void 0;
|
|
1551
|
-
},
|
|
1552
|
-
{ immediate: true }
|
|
1553
|
-
);
|
|
1554
1628
|
const onClickInner = () => {
|
|
1555
1629
|
if (isClickable.value) {
|
|
1556
1630
|
focused.value = true;
|
|
@@ -1564,6 +1638,23 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1564
1638
|
width: localModelValue.value !== void 0 ? `${String(localModelValue.value).length + 1}ch` : void 0
|
|
1565
1639
|
};
|
|
1566
1640
|
});
|
|
1641
|
+
const onKeyDown = (event) => {
|
|
1642
|
+
switch (event.code) {
|
|
1643
|
+
case "ArrowUp":
|
|
1644
|
+
if (isNumber.value) {
|
|
1645
|
+
onStepUp();
|
|
1646
|
+
event.preventDefault();
|
|
1647
|
+
}
|
|
1648
|
+
break;
|
|
1649
|
+
case "ArrowDown":
|
|
1650
|
+
if (isNumber.value) {
|
|
1651
|
+
onStepDown();
|
|
1652
|
+
event.preventDefault();
|
|
1653
|
+
}
|
|
1654
|
+
break;
|
|
1655
|
+
}
|
|
1656
|
+
emit("keydown", event);
|
|
1657
|
+
};
|
|
1567
1658
|
return (_ctx, _cache) => {
|
|
1568
1659
|
return openBlock(), createElementBlock("div", {
|
|
1569
1660
|
class: normalizeClass(unref(bemCssClasses))
|
|
@@ -1587,17 +1678,16 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1587
1678
|
key: 0,
|
|
1588
1679
|
class: "vv-input-text__icon"
|
|
1589
1680
|
}, unref(hasIcon)), null, 16)) : createCommentVNode("", true),
|
|
1590
|
-
|
|
1681
|
+
createElementVNode("input", mergeProps({
|
|
1591
1682
|
id: unref(hasId),
|
|
1592
1683
|
ref_key: "inputEl",
|
|
1593
|
-
ref: inputEl
|
|
1594
|
-
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => isRef(localModelValue) ? localModelValue.value = $event : null)
|
|
1684
|
+
ref: inputEl
|
|
1595
1685
|
}, unref(hasAttrs), {
|
|
1596
1686
|
style: unref(hasStyle),
|
|
1597
|
-
onKeyup: _cache[
|
|
1598
|
-
|
|
1599
|
-
[
|
|
1600
|
-
|
|
1687
|
+
onKeyup: _cache[0] || (_cache[0] = ($event) => emit("keyup", $event)),
|
|
1688
|
+
onKeydown: onKeyDown,
|
|
1689
|
+
onKeypress: _cache[1] || (_cache[1] = ($event) => emit("keypress", $event))
|
|
1690
|
+
}), null, 16, _hoisted_5),
|
|
1601
1691
|
(_ctx.unit || _ctx.$slots.unit) && unref(isDirty) ? (openBlock(), createElementBlock("div", _hoisted_6, [
|
|
1602
1692
|
renderSlot(_ctx.$slots, "default", normalizeProps(guardReactiveProps(unref(slotProps))), () => [
|
|
1603
1693
|
createTextVNode(toDisplayString(_ctx.unit), 1)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("vue"),require("maska"),require("@iconify/vue"),require("nanoid"),require("@vueuse/core")):"function"==typeof define&&define.amd?define(["vue","maska","@iconify/vue","nanoid","@vueuse/core"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).VvInputText=t(e.vue,e.maska,e.vue$1,e.nanoid,e.core)}(this,(function(e,t,o,l,n){"use strict";function a(t){return null==(o=e.unref(t))||""===o||Array.isArray(o)&&0===o.length||!(o instanceof Date)&&"object"==typeof o&&0===Object.keys(o).length;var o}function i(e){return Array.isArray(e)?e.filter((e=>{return"string"==typeof(t=e)||t instanceof String;var t})).join(" "):e}const r={color:String,width:{type:[String,Number]},height:{type:[String,Number]},name:{type:String,required:!0},provider:{type:String},prefix:{type:String,default:"normal"},src:String,horizontalFlip:Boolean,verticalFlip:Boolean,flip:String,mode:String,inline:Boolean,rotate:[Number,String],onLoad:Function,svg:String,modifiers:{type:[String,Array]}};var u=(e=>(e.left="left",e.right="right",e.top="top",e.bottom="bottom",e))(u||{}),s=(e=>(e.before="before",e.after="after",e))(s||{}),d=(e=>(e.button="button",e.submit="submit",e.reset="reset",e))(d||{});const c=Symbol.for("volver");function p(){return e.inject(c)}function v(t,o,l){return e.computed((()=>{const n={[t]:!0},a="string"==typeof(null==o?void 0:o.value)?o.value.split(" "):null==o?void 0:o.value;return a&&Array.isArray(a)&&a.forEach((e=>{e&&(n[`${t}--${e}`]=!0)})),l&&Object.keys(l.value).forEach((o=>{n[`${t}--${o}`]=e.unref(l.value[o])})),n}))}const m=e.defineComponent({name:"VvIcon",props:r,setup(t){const l=t,n=e.computed((()=>"string"==typeof l.rotate?parseFloat(l.rotate):l.rotate)),a=e.ref(!0),i=p(),{modifiers:r}=e.toRefs(l),u=v("vv-icon",r),s=e.computed((()=>l.provider||(null==i?void 0:i.iconsProvider))),d=e.computed((()=>{const e=l.name??"",t=`@${s.value}:${l.prefix}:${e}`;if(o.iconExists(t))return t;const n=null==i?void 0:i.iconsCollections.find((t=>{const l=`@${s.value}:${t.prefix}:${e}`;return o.iconExists(l)}));return n?`@${s.value}:${n.prefix}:${e}`:e}));function c(e){const t=function(e){let t;if("undefined"==typeof window){const{JSDOM:e}=require("jsdom");t=(new e).window}return(t?new t.DOMParser:new window.DOMParser).parseFromString(e,"text/html").querySelector("svg")}(e),n=(null==t?void 0:t.innerHTML.trim())||"";t&&n&&o.addIcon(`@${s.value}:${l.prefix}:${l.name}`,{body:n,height:t.viewBox.baseVal.height,width:t.viewBox.baseVal.width})}return i&&l.src&&!o.iconExists(`@${s.value}:${l.prefix}:${l.name}`)&&(a.value=!1,i.fetchIcon(l.src).then((e=>{e&&(c(e),a.value=!0)})).catch((e=>{throw new Error(`Error during fetch icon: ${null==e?void 0:e.message}`)}))),l.svg&&c(l.svg),(t,l)=>e.unref(a)?(e.openBlock(),e.createBlock(e.unref(o.Icon),e.mergeProps({key:0,class:e.unref(u)},{inline:t.inline,width:t.width,height:t.height,horizontalFlip:t.horizontalFlip,verticalFlip:t.verticalFlip,flip:t.flip,rotate:e.unref(n),color:t.color,onLoad:t.onLoad,icon:e.unref(d)}),null,16,["class"])):e.createCommentVNode("",!0)}}),f={valid:Boolean,validLabel:[String,Array]},h={invalid:Boolean,invalidLabel:[String,Array]},b={loading:Boolean,loadingLabel:{type:String,default:"Loading..."}},g={disabled:Boolean},S=(Boolean,Boolean,{label:[String,Number]}),y={readonly:Boolean},w={modifiers:[String,Array]},k={hintLabel:{type:String,default:""}},B={count:{type:[Boolean,String],default:!1,validator:e=>[!0,!1,"limit","countdown"].includes(e)}},L={debounce:[Number,String]},E={icon:{type:[String,Object]},iconPosition:{type:String,default:s.before,validation:e=>Object.values(s).includes(e)}},x={tabindex:{type:[String,Number],default:0}},P={floating:Boolean},T={id:[String,Number]};u.bottom,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean;const C={...{...T,name:{type:String,required:!0}},...{autofocus:Boolean},...{autocomplete:{type:String,default:"off"}},...x,...g,...y,...f,...h,...k,...b,...w,...B,...L,...E,...P,...S,minlength:[String,Number],maxlength:[String,Number],placeholder:String,required:Boolean};d.button;const A={TEXT:"text",PASSWORD:"password",NUMBER:"number",EMAIL:"email",TEL:"tel",URL:"url",COLOR:"color",SEARCH:"search",DATE:"date",TIME:"time",DATETIME_LOCAL:"datetime-local",MONTH:"month",WEEK:"week"},$="eye-on",I="eye-off",V="calendar",O="time",_="color",N={...C,modelValue:[String,Number],type:{type:String,default:A.TEXT,validator:e=>Object.values(A).includes(e)},min:[Number,Date,String],max:[Number,Date,String],step:{type:[String,Number],default:1},pattern:String,multiple:Boolean,iconShowPassword:{type:String,default:$},iconHidePassword:{type:String,default:I},iconClear:{type:String,default:"close"},labelStepUp:{type:String,default:"Increase value"},labelStepDown:{type:String,default:"Decrease value"},labelShowPassword:{type:String,default:"Show password"},labelHidePassword:{type:String,default:"Hide password"},labelClear:{type:String,default:"Clear"},mask:{type:String,default:void 0},maskEager:{type:Boolean,default:!1},maskReversed:{type:Boolean,default:!1},maskTokens:{type:Object,default:void 0},maskTokensReplace:{type:Boolean,default:!1},autoWidth:{type:Boolean,default:!1},hideActions:{type:Boolean,default:!1},unit:{type:String}},R=e.defineComponent({components:{VvIcon:m},props:{disabled:{type:Boolean,default:!1},labelShow:{type:String,default:"Show password"},labelHide:{type:String,default:"Hide password"},iconShow:{type:String,default:$},iconHide:{type:String,default:I}},emits:["toggle-password"],setup(t,{emit:o}){const l=e.ref(!1),n=e.computed((()=>l.value?t.iconHide:t.iconShow));return{active:l,activeIcon:n,onClick:function(e){null==e||e.stopPropagation(),t.disabled||(l.value=!l.value,o("toggle-password",l.value))}}},render(){const t=e.h(m,{name:this.activeIcon,class:"vv-input-text__icon"});return e.h("button",{disabled:this.disabled,class:"vv-input-text__action",ariaLabel:this.active?this.labelHide:this.labelShow,type:"button",onClick:this.onClick},t)}}),D=e.defineComponent({components:{VvIcon:m},props:{disabled:{type:Boolean,default:!1},label:{type:String},mode:{type:String,validator:e=>["up","down"].includes(e),default:"up"}},emits:["step-up","step-down"],setup(t,{emit:o}){const l=e.computed((()=>"up"===t.mode));return{isUp:l,onClick:e=>{null==e||e.stopPropagation(),t.disabled||o(l.value?"step-up":"step-down")}}},render(){return e.h("button",{class:["vv-input-text__action vv-input-text__action-chevron",this.isUp&&"vv-input-text__action-chevron-up"],disabled:this.disabled,ariaLabel:this.label,type:"button",onClick:this.onClick})}}),H=e.defineComponent({components:{VvIcon:m},props:{disabled:{type:Boolean,default:!1},label:{type:String,default:"Clear"},icon:{type:String,default:"close"}},emits:["clear"],setup:(e,{emit:t})=>({onClick:function(o){null==o||o.stopPropagation(),e.disabled||t("clear")}}),render(){const t=e.h(m,{name:this.icon,class:"vv-input-text__icon"});return e.h("button",{disabled:this.disabled,class:"vv-input-text__action",ariaLabel:this.label,type:"button",onClick:this.onClick},t)}});function M(t,o){return{name:"VvInputTextActions",components:{VvIcon:m,VvInputPasswordAction:R,VvInputStepAction:D,VvInputClearAction:H},setup:()=>({isDisabled:e.computed((()=>o.disabled||o.readonly)),labelStepUp:o.labelStepUp,labelStepDown:o.labelStepDown,labelShowPassword:o.labelShowPassword,labelHidePassword:o.labelHidePassword,labelClear:o.labelClear,iconShowPassword:o.iconShowPassword,iconHidePassword:o.iconHidePassword}),render(){let l=null;switch(t){case A.SEARCH:{const{onClear:t}=this.$attrs;l=[e.h(H,{disabled:this.isDisabled,label:this.labelShowPassword,onClear:t})];break}case A.PASSWORD:{const{onTogglePassword:t}=this.$attrs;l=[e.h(R,{disabled:this.isDisabled,onTogglePassword:t,labelShow:this.labelShowPassword,labelHide:this.labelHidePassword,iconShow:this.iconShowPassword,iconHide:this.iconHidePassword})];break}case A.NUMBER:{const{onStepUp:t,onStepDown:n}=this.$attrs;l=[e.h(D,{mode:"up",disabled:this.isDisabled||void 0!==o.max&&o.modelValue===o.max,label:this.labelStepUp,onStepUp:t,onStepDown:n}),e.h(D,{mode:"down",disabled:this.isDisabled||void 0!==o.min&&o.modelValue===o.min,label:this.labelStepDown,onStepUp:t,onStepDown:n})];break}}return Array.isArray(l)?e.h("div",{class:"vv-input-text__actions-group"},l):l}}}const U=["for"],j={class:"vv-input-text__wrapper"},W={key:0,class:"vv-input-text__input-before"},q=["onClick"],z=["id"],F={key:1,class:"vv-input-text__unit"},X={key:5,class:"vv-input-text__input-after"},K={key:6,class:"vv-input-text__limit"};return e.defineComponent({name:"VvInputText",props:N,emits:["update:modelValue","focus","blur","keyup"],setup(o,{expose:r,emit:d}){const c=o,f=e.useSlots(),h=function(t,o,l){const n=p(),a=e.computed((()=>{var e;if(n&&(null==(e=n.defaults.value)?void 0:e[t]))return n.defaults.value[t]}));return e.computed((()=>{if(void 0===a.value)return l;const e=a.value,t=o,n=l;return Object.keys(t).reduce(((o,l)=>{const a=n[l];if(o[l]=a,l in e){if(Array.isArray(t[l])){const n=t[l];n.length&&n[0]===a&&(o[l]=e[l])}if("function"==typeof t[l]&&(0,t[l])()===a&&(o[l]=e[l]),"object"==typeof t[l]){let n=t[l].default;"function"==typeof n&&(n=n()),"object"==typeof n?JSON.stringify(n)===JSON.stringify(a)&&(o[l]=e[l]):n===a&&(o[l]=e[l])}}return o}),{})}))}("VvInputText",N,c),b=e.ref(),g=e.ref();r({$inner:g});const{id:S,icon:y,iconPosition:w,label:k,modelValue:B,count:L,valid:E,invalid:x,loading:P}=e.toRefs(c),T=(t=>e.computed((()=>String((null==t?void 0:t.value)||l.nanoid()))))(S),C=e.computed((()=>`${T.value}-hint`)),$=e.computed((()=>c.floating&&a(c.placeholder)?" ":c.placeholder)),I=function(t,o,l=0,{getter:n=(e=>e),setter:a=(e=>e)}={}){let i;return"string"==typeof l&&(l=parseInt(l)),e.computed({get:()=>n(null==t?void 0:t.value),set:e=>{i&&clearTimeout(i),i=setTimeout((()=>{o("update:modelValue",a(e))}),l)}})}(B,d,c.debounce,{getter:e=>Le.value?Le.value.masked(e??""):e,setter:e=>(Le.value&&(e=Le.value.unmasked(e)),c.type===A.NUMBER?Number(e):e)}),{focused:R}=function(t,o){const{focused:l}=n.useFocus(t);return e.watch(l,(l=>{o(l?"focus":"blur",e.unref(t))})),{focused:l}}(b,d),D=e.computed((()=>R.value&&!c.disabled&&!c.readonly)),H=n.useElementVisibility(b);e.watch(H,(e=>{e&&c.autofocus&&!c.disabled&&!c.readonly&&(R.value=!0)}));const J=e.ref(!1),G=e.computed((()=>c.type===A.PASSWORD)),Q=()=>{J.value=!J.value},Y=e.computed((()=>c.type===A.TIME||c.type===A.DATETIME_LOCAL||c.type===A.DATE||c.type===A.WEEK||c.type===A.MONTH)),Z=e.computed((()=>c.type===A.NUMBER)),ee=()=>{se.value&&(b.value.stepUp(),I.value=e.unref(b).value)},te=()=>{se.value&&(b.value.stepDown(),I.value=e.unref(b).value)},oe=e.computed((()=>c.type===A.SEARCH)),le=()=>{I.value=void 0},{hasIcon:ne,hasIconBefore:ae,hasIconAfter:ie}=function(t,o){const l=e.computed((()=>Boolean((null==t?void 0:t.value)&&o.value===s.before))),n=e.computed((()=>Boolean((null==t?void 0:t.value)&&o.value===s.after))),a=e.computed((()=>Boolean((null==t?void 0:t.value)&&o.value===u.left))),i=e.computed((()=>Boolean((null==t?void 0:t.value)&&o.value===u.right))),r=e.computed((()=>Boolean((null==t?void 0:t.value)&&o.value===u.top))),d=e.computed((()=>Boolean((null==t?void 0:t.value)&&o.value===u.bottom)));return{hasIcon:e.computed((()=>"string"==typeof(null==t?void 0:t.value)?{name:null==t?void 0:t.value}:null==t?void 0:t.value)),hasIconLeft:a,hasIconRight:i,hasIconTop:r,hasIconBottom:d,hasIconBefore:l,hasIconAfter:n}}(y,w),re=e.computed((()=>{switch(c.type){case A.COLOR:return{name:_};case A.DATE:case A.DATETIME_LOCAL:case A.WEEK:case A.MONTH:return{name:V};case A.TIME:return{name:O};default:return""}})),{formatted:ue}=function(t,o){const l=e.computed((()=>(e.unref(t)??"").length)),n=e.computed((()=>void 0!==(null==o?void 0:o.lowerLimit)&&l.value<(null==o?void 0:o.lowerLimit)?l.value-o.lowerLimit:void 0!==(null==o?void 0:o.upperLimit)&&l.value<(null==o?void 0:o.upperLimit)?o.upperLimit-l.value:0)),a=e.computed((()=>{if(!1===(null==o?void 0:o.mode))return"";if("limit"===(null==o?void 0:o.mode)&&(null==o?void 0:o.upperLimit))return`${l.value} / ${o.lowerLimit?`${o.lowerLimit}-`:""}${o.upperLimit}`;if("countdown"===(null==o?void 0:o.mode)){if(0===n.value)return;return n}return l.value}));return{length:l,gap:n,formatted:a}}(I,{mode:c.count,upperLimit:Number(c.maxlength),lowerLimit:Number(c.minlength)}),se=e.computed((()=>!c.disabled&&!c.readonly)),de=e.computed((()=>se.value?c.tabindex:-1)),ce=e.computed((()=>!a(B))),pe=e.computed((()=>!0===x.value||!0!==E.value&&void 0)),{modifiers:ve}=e.toRefs(c),me=v("vv-input-text",ve,e.computed((()=>({valid:E.value,invalid:x.value,loading:P.value,disabled:c.disabled,readonly:c.readonly,"icon-before":ae.value,"icon-after":ie.value||!a(re),floating:c.floating&&!a(c.label),dirty:ce.value,focus:D.value,"auto-width":c.autoWidth})))),fe=e.computed((()=>{const e=G.value&&J.value?A.TEXT:!Y.value||ce.value||R.value?c.type:A.TEXT,t={type:e,name:c.name,tabindex:de.value,disabled:c.disabled,readonly:c.readonly,required:c.required,autocomplete:c.autocomplete,"aria-invalid":pe.value,"aria-describedby":ge.value?C.value:void 0,"aria-errormessage":Se.value?C.value:void 0};return e!==A.DATE&&e!==A.MONTH&&e!==A.WEEK&&e!==A.TIME&&e!==A.DATETIME_LOCAL&&e!==A.NUMBER||(t.step=c.step,t.max=void 0!==c.max?String(c.max):void 0,t.min=void 0!==c.min?String(c.min):void 0),e!==A.TEXT&&e!==A.SEARCH&&e!==A.URL&&e!==A.TEL&&e!==A.EMAIL&&e!==A.PASSWORD&&e!==A.NUMBER||(t.placeholder=$.value),e!==A.TEXT&&e!==A.SEARCH&&e!==A.URL&&e!==A.TEL&&e!==A.EMAIL&&e!==A.PASSWORD||(t.minlength=c.minlength,t.maxlength=c.maxlength,t.pattern=c.pattern),e===A.EMAIL&&(t.multiple=c.multiple),t})),he=e.computed((()=>({valid:c.valid,invalid:c.invalid,modelValue:c.modelValue,togglePassword:Q,stepUp:ee,stepDown:te,clear:le}))),{HintSlot:be,hasHintLabelOrSlot:ge,hasInvalidLabelOrSlot:Se,hintSlotScope:ye}=function(t,o){const l=e.computed((()=>e.isRef(t)?t.value:t)),n=e.computed((()=>i(l.value.invalidLabel))),a=e.computed((()=>i(l.value.validLabel))),r=e.computed((()=>l.value.loadingLabel)),u=e.computed((()=>l.value.hintLabel)),s=e.computed((()=>Boolean(l.value.loading&&(o.loading||r.value)))),d=e.computed((()=>!s.value&&Boolean(l.value.invalid&&(o.invalid||n.value)))),c=e.computed((()=>!s.value&&!d.value&&Boolean(l.value.valid&&(o.valid||a.value)))),p=e.computed((()=>!s.value&&!d.value&&!c.value&&Boolean(o.hint||u.value))),v=e.computed((()=>d.value||c.value||s.value||p.value)),m=e.computed((()=>({modelValue:l.value.modelValue,valid:l.value.valid,invalid:l.value.invalid,loading:l.value.loading}))),f=e.defineComponent({name:"HintSlot",props:{tag:{type:String,default:"small"}},setup:()=>({isVisible:v,invalidLabel:n,validLabel:a,loadingLabel:r,hintLabel:u,hasInvalidLabelOrSlot:d,hasValidLabelOrSlot:c,hasLoadingLabelOrSlot:s,hasHintLabelOrSlot:p}),render(){var t,o,l,n,a,i,r,u;if(this.isVisible){let s;return this.hasInvalidLabelOrSlot&&(s="alert"),this.hasValidLabelOrSlot&&(s="status"),this.hasLoadingLabelOrSlot?e.h(this.tag,{role:s},(null==(o=(t=this.$slots).loading)?void 0:o.call(t))??this.loadingLabel):this.hasInvalidLabelOrSlot?e.h(this.tag,{role:s},(null==(n=(l=this.$slots).invalid)?void 0:n.call(l))??this.$slots.invalid??this.invalidLabel):this.hasValidLabelOrSlot?e.h(this.tag,{role:s},(null==(i=(a=this.$slots).valid)?void 0:i.call(a))??this.validLabel):e.h(this.tag,{role:s},(null==(u=(r=this.$slots).hint)?void 0:u.call(r))??this.$slots.hint??this.hintLabel)}return null}});return{hasInvalidLabelOrSlot:d,hasHintLabelOrSlot:p,hasValidLabelOrSlot:c,hasLoadingLabelOrSlot:s,hintSlotScope:m,HintSlot:f}}(h,f),we=M(A.PASSWORD,c),ke=M(A.NUMBER,c),Be=M(A.SEARCH,c),Le=e.ref();e.watch([()=>c.mask,()=>c.type,()=>c.maskEager,()=>c.maskReversed,()=>c.maskTokens,()=>c.maskTokensReplace],(([e,o,l,n,a,i])=>{Le.value=e&&o===A.TEXT?new t.Mask({mask:e,eager:l,reversed:n,tokens:a,tokensReplace:i}):void 0}),{immediate:!0});const Ee=()=>{se.value&&(R.value=!0)},xe=e.computed((()=>{if(c.autoWidth)return{width:void 0!==I.value?`${String(I.value).length+1}ch`:void 0}}));return(t,o)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(e.unref(me))},[e.unref(k)?(e.openBlock(),e.createElementBlock("label",{key:0,for:e.unref(T),class:"vv-input-text__label"},e.toDisplayString(e.unref(k)),9,U)):e.createCommentVNode("",!0),e.createElementVNode("div",j,[t.$slots.before?(e.openBlock(),e.createElementBlock("div",W,[e.renderSlot(t.$slots,"before",e.normalizeProps(e.guardReactiveProps(e.unref(he))))])):e.createCommentVNode("",!0),e.createElementVNode("div",{ref_key:"innerEl",ref:g,class:"vv-input-text__inner",onClick:e.withModifiers(Ee,["stop"])},[e.unref(ae)?(e.openBlock(),e.createBlock(m,e.mergeProps({key:0,class:"vv-input-text__icon"},e.unref(ne)),null,16)):e.createCommentVNode("",!0),e.withDirectives(e.createElementVNode("input",e.mergeProps({id:e.unref(T),ref_key:"inputEl",ref:b,"onUpdate:modelValue":o[0]||(o[0]=t=>e.isRef(I)?I.value=t:null)},e.unref(fe),{style:e.unref(xe),onKeyup:o[1]||(o[1]=e=>d("keyup",e))}),null,16,z),[[e.vModelDynamic,e.unref(I)]]),(t.unit||t.$slots.unit)&&e.unref(ce)?(e.openBlock(),e.createElementBlock("div",F,[e.renderSlot(t.$slots,"default",e.normalizeProps(e.guardReactiveProps(e.unref(he))),(()=>[e.createTextVNode(e.toDisplayString(t.unit),1)]))])):e.createCommentVNode("",!0)],8,q),e.unref(ie)||e.unref(re)?(e.openBlock(),e.createBlock(m,e.mergeProps({key:1,class:"vv-input-text__icon vv-input-text__icon-after"},e.unref(ie)?e.unref(ne):e.unref(re)),null,16)):e.unref(G)&&!t.hideActions&&e.unref(se)?(e.openBlock(),e.createBlock(e.unref(we),{key:2,onTogglePassword:Q})):e.unref(Z)&&!t.hideActions&&e.unref(se)?(e.openBlock(),e.createBlock(e.unref(ke),{key:3,onStepUp:ee,onStepDown:te})):e.unref(oe)&&!t.hideActions&&e.unref(se)?(e.openBlock(),e.createBlock(e.unref(Be),{key:4,onClear:le})):e.createCommentVNode("",!0),t.$slots.after?(e.openBlock(),e.createElementBlock("div",X,[e.renderSlot(t.$slots,"after",e.normalizeProps(e.guardReactiveProps(e.unref(he))))])):e.createCommentVNode("",!0),e.unref(L)?(e.openBlock(),e.createElementBlock("span",K,[e.renderSlot(t.$slots,"count",e.normalizeProps(e.guardReactiveProps(e.unref(he))),(()=>[e.createTextVNode(e.toDisplayString(e.unref(ue)),1)]))])):e.createCommentVNode("",!0)]),e.createVNode(e.unref(be),{id:e.unref(C),class:"vv-input-text__hint"},e.createSlots({_:2},[t.$slots.hint?{name:"hint",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"hint",e.normalizeProps(e.guardReactiveProps(e.unref(ye))))])),key:"0"}:void 0,t.$slots.loading?{name:"loading",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"loading",e.normalizeProps(e.guardReactiveProps(e.unref(ye))))])),key:"1"}:void 0,t.$slots.valid?{name:"valid",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"valid",e.normalizeProps(e.guardReactiveProps(e.unref(ye))))])),key:"2"}:void 0,t.$slots.invalid?{name:"invalid",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"invalid",e.normalizeProps(e.guardReactiveProps(e.unref(ye))))])),key:"3"}:void 0]),1032,["id"])],2))}})}));
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("vue"),require("vue-imask"),require("@iconify/vue"),require("nanoid"),require("@vueuse/core")):"function"==typeof define&&define.amd?define(["vue","vue-imask","@iconify/vue","nanoid","@vueuse/core"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).VvInputText=t(e.vue,e.vueImask,e.vue$1,e.nanoid,e.core)}(this,(function(e,t,l,o,a){"use strict";function n(t){return null==(l=e.unref(t))||""===l||Array.isArray(l)&&0===l.length||!(l instanceof Date)&&"object"==typeof l&&0===Object.keys(l).length;var l}function i(e){return Array.isArray(e)?e.filter((e=>{return"string"==typeof(t=e)||t instanceof String;var t})).join(" "):e}const r={color:String,width:{type:[String,Number]},height:{type:[String,Number]},name:{type:String,required:!0},provider:{type:String},prefix:{type:String,default:"normal"},src:String,horizontalFlip:Boolean,verticalFlip:Boolean,flip:String,mode:String,inline:Boolean,rotate:[Number,String],onLoad:Function,svg:String,modifiers:{type:[String,Array]}};var u=(e=>(e.left="left",e.right="right",e.top="top",e.bottom="bottom",e))(u||{}),s=(e=>(e.before="before",e.after="after",e))(s||{}),d=(e=>(e.button="button",e.submit="submit",e.reset="reset",e))(d||{});const c=Symbol.for("volver");function v(){return e.inject(c)}function p(t,l,o){return e.computed((()=>{const a={[t]:!0},n="string"==typeof(null==l?void 0:l.value)?l.value.split(" "):null==l?void 0:l.value;return n&&Array.isArray(n)&&n.forEach((e=>{e&&(a[`${t}--${e}`]=!0)})),o&&Object.keys(o.value).forEach((l=>{a[`${t}--${l}`]=e.unref(o.value[l])})),a}))}const m=e.defineComponent({name:"VvIcon",props:r,setup(t){const o=t,a=e.computed((()=>"string"==typeof o.rotate?parseFloat(o.rotate):o.rotate)),n=e.ref(!0),i=v(),{modifiers:r}=e.toRefs(o),u=p("vv-icon",r),s=e.computed((()=>o.provider||(null==i?void 0:i.iconsProvider))),d=e.computed((()=>{const e=o.name??"",t=`@${s.value}:${o.prefix}:${e}`;if(l.iconExists(t))return t;const a=null==i?void 0:i.iconsCollections.find((t=>{const o=`@${s.value}:${t.prefix}:${e}`;return l.iconExists(o)}));return a?`@${s.value}:${a.prefix}:${e}`:e}));function c(e){const t=function(e){let t;if("undefined"==typeof window){const{JSDOM:e}=require("jsdom");t=(new e).window}return(t?new t.DOMParser:new window.DOMParser).parseFromString(e,"text/html").querySelector("svg")}(e),a=(null==t?void 0:t.innerHTML.trim())||"";t&&a&&l.addIcon(`@${s.value}:${o.prefix}:${o.name}`,{body:a,height:t.viewBox.baseVal.height,width:t.viewBox.baseVal.width})}return i&&o.src&&!l.iconExists(`@${s.value}:${o.prefix}:${o.name}`)&&(n.value=!1,i.fetchIcon(o.src).then((e=>{e&&(c(e),n.value=!0)})).catch((e=>{throw new Error(`Error during fetch icon: ${null==e?void 0:e.message}`)}))),o.svg&&c(o.svg),(t,o)=>e.unref(n)?(e.openBlock(),e.createBlock(e.unref(l.Icon),e.mergeProps({key:0,class:e.unref(u)},{inline:t.inline,width:t.width,height:t.height,horizontalFlip:t.horizontalFlip,verticalFlip:t.verticalFlip,flip:t.flip,rotate:e.unref(a),color:t.color,onLoad:t.onLoad,icon:e.unref(d)}),null,16,["class"])):e.createCommentVNode("",!0)}}),f={valid:Boolean,validLabel:[String,Array]},h={invalid:Boolean,invalidLabel:[String,Array]},b={loading:Boolean,loadingLabel:{type:String,default:"Loading..."}},g={disabled:Boolean},S=(Boolean,Boolean,{label:[String,Number]}),y={readonly:Boolean},w={modifiers:[String,Array]},k={hintLabel:{type:String,default:""}},L={count:{type:[Boolean,String],default:!1,validator:e=>[!0,!1,"limit","countdown"].includes(e)}},B={debounce:[Number,String]},E={icon:{type:[String,Object]},iconPosition:{type:String,default:s.before,validation:e=>Object.values(s).includes(e)}},$={tabindex:{type:[String,Number],default:0}},x={floating:Boolean},A={id:[String,Number]};u.bottom,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean;const T={...{...A,name:{type:String,required:!0}},...{autofocus:Boolean},...{autocomplete:{type:String,default:"off"}},...$,...g,...y,...f,...h,...k,...b,...w,...L,...B,...E,...x,...S,minlength:[String,Number],maxlength:[String,Number],placeholder:String,required:Boolean};d.button;const P={TEXT:"text",PASSWORD:"password",NUMBER:"number",EMAIL:"email",TEL:"tel",URL:"url",COLOR:"color",SEARCH:"search",DATE:"date",TIME:"time",DATETIME_LOCAL:"datetime-local",MONTH:"month",WEEK:"week"},C="eye-on",D="eye-off",I="calendar",O="time",V="color",_={...T,modelValue:[String,Number],type:{type:String,default:P.TEXT,validator:e=>Object.values(P).includes(e)},min:[Number,Date,String],max:[Number,Date,String],step:{type:[String,Number],default:1},pattern:String,multiple:Boolean,iconShowPassword:{type:String,default:C},iconHidePassword:{type:String,default:D},iconClear:{type:String,default:"close"},labelStepUp:{type:String,default:"Increase value"},labelStepDown:{type:String,default:"Decrease value"},labelShowPassword:{type:String,default:"Show password"},labelHidePassword:{type:String,default:"Hide password"},labelClear:{type:String,default:"Clear"},iMask:{type:Object,default:void 0},masked:{type:String,default:void 0},autoWidth:{type:Boolean,default:!1},hideActions:{type:Boolean,default:!1},unit:{type:String},selectOnFocus:{type:Boolean,default:!1}},N=e.defineComponent({components:{VvIcon:m},props:{disabled:{type:Boolean,default:!1},labelShow:{type:String,default:"Show password"},labelHide:{type:String,default:"Hide password"},iconShow:{type:String,default:C},iconHide:{type:String,default:D}},emits:["toggle-password"],setup(t,{emit:l}){const o=e.ref(!1),a=e.computed((()=>o.value?t.iconHide:t.iconShow));return{active:o,activeIcon:a,onClick:function(e){null==e||e.stopPropagation(),t.disabled||(o.value=!o.value,l("toggle-password",o.value))}}},render(){const t=e.h(m,{name:this.activeIcon,class:"vv-input-text__icon"});return e.h("button",{disabled:this.disabled,class:"vv-input-text__action",ariaLabel:this.active?this.labelHide:this.labelShow,type:"button",onClick:this.onClick},t)}}),M=e.defineComponent({components:{VvIcon:m},props:{disabled:{type:Boolean,default:!1},label:{type:String},mode:{type:String,validator:e=>["up","down"].includes(e),default:"up"}},emits:["step-up","step-down"],setup(t,{emit:l}){const o=e.computed((()=>"up"===t.mode));return{isUp:o,onClick:e=>{null==e||e.stopPropagation(),t.disabled||l(o.value?"step-up":"step-down")}}},render(){return e.h("button",{class:["vv-input-text__action vv-input-text__action-chevron",this.isUp&&"vv-input-text__action-chevron-up"],disabled:this.disabled,ariaLabel:this.label,type:"button",onClick:this.onClick})}}),R=e.defineComponent({components:{VvIcon:m},props:{disabled:{type:Boolean,default:!1},label:{type:String,default:"Clear"},icon:{type:String,default:"close"}},emits:["clear"],setup:(e,{emit:t})=>({onClick:function(l){null==l||l.stopPropagation(),e.disabled||t("clear")}}),render(){const t=e.h(m,{name:this.icon,class:"vv-input-text__icon"});return e.h("button",{disabled:this.disabled,class:"vv-input-text__action",ariaLabel:this.label,type:"button",onClick:this.onClick},t)}});function H(t,l){return{name:"VvInputTextActions",components:{VvIcon:m,VvInputPasswordAction:N,VvInputStepAction:M,VvInputClearAction:R},setup:()=>({isDisabled:e.computed((()=>l.disabled||l.readonly)),labelStepUp:l.labelStepUp,labelStepDown:l.labelStepDown,labelShowPassword:l.labelShowPassword,labelHidePassword:l.labelHidePassword,labelClear:l.labelClear,iconShowPassword:l.iconShowPassword,iconHidePassword:l.iconHidePassword}),render(){let o=null;switch(t){case P.SEARCH:{const{onClear:t}=this.$attrs;o=[e.h(R,{disabled:this.isDisabled,label:this.labelShowPassword,onClear:t})];break}case P.PASSWORD:{const{onTogglePassword:t}=this.$attrs;o=[e.h(N,{disabled:this.isDisabled,onTogglePassword:t,labelShow:this.labelShowPassword,labelHide:this.labelHidePassword,iconShow:this.iconShowPassword,iconHide:this.iconHidePassword})];break}case P.NUMBER:{const{onStepUp:t,onStepDown:a}=this.$attrs;o=[e.h(M,{mode:"up",disabled:this.isDisabled||void 0!==l.max&&l.modelValue===l.max,label:this.labelStepUp,onStepUp:t,onStepDown:a}),e.h(M,{mode:"down",disabled:this.isDisabled||void 0!==l.min&&l.modelValue===l.min,label:this.labelStepDown,onStepUp:t,onStepDown:a})];break}}return Array.isArray(o)?e.h("div",{class:"vv-input-text__actions-group"},o):o}}}const U=["for"],j={class:"vv-input-text__wrapper"},F={key:0,class:"vv-input-text__input-before"},W=["onClick"],q=["id"],z={key:1,class:"vv-input-text__unit"},K={key:5,class:"vv-input-text__input-after"},X={key:6,class:"vv-input-text__limit"};return e.defineComponent({name:"VvInputText",props:_,emits:["update:modelValue","update:masked","accept","accept:typed","accept:masked","accept:unmasked","complete","complete:typed","complete:masked","complete:unmasked","focus","blur","keyup","keydown","keypress"],setup(l,{expose:r,emit:d}){const c=l,f=e.useSlots(),h=function(t,l,o){const a=v(),n=e.computed((()=>{var e;if(a&&(null==(e=a.defaults.value)?void 0:e[t]))return a.defaults.value[t]}));return e.computed((()=>{if(void 0===n.value)return o;const e=n.value,t=l,a=o;return Object.keys(t).reduce(((l,o)=>{const n=a[o];if(l[o]=n,o in e){if(Array.isArray(t[o])){const a=t[o];a.length&&a[0]===n&&(l[o]=e[o])}if("function"==typeof t[o]&&(0,t[o])()===n&&(l[o]=e[o]),"object"==typeof t[o]){let a=t[o].default;"function"==typeof a&&(a=a()),"object"==typeof a?JSON.stringify(a)===JSON.stringify(n)&&(l[o]=e[o]):a===n&&(l[o]=e[o])}}return l}),{})}))}("VvInputText",_,c),{id:b,icon:g,iconPosition:S,label:y,modelValue:w,count:k,valid:L,invalid:B,loading:E,debounce:$,maxlength:x,minlength:A,type:T,iMask:C,step:D}=e.toRefs(c),N=(t=>e.computed((()=>String((null==t?void 0:t.value)||o.nanoid()))))(b),M=e.computed((()=>`${N.value}-hint`)),R=e.computed((()=>c.floating&&n(c.placeholder)?" ":c.placeholder)),J=e.ref(!1),{el:Y,mask:G,typed:Q,masked:Z,unmasked:ee}=t.useIMask(e.computed((()=>(null==C?void 0:C.value)??{mask:/./})),{emit:d,onAccept:()=>{if(J.value){if(d("update:masked",Z.value),T.value===P.NUMBER){if(""===Z.value){if(null===oe.value||void 0===oe.value)return;return void(oe.value=void 0)}return"number"!=typeof Q.value?void(oe.value=Number(Q.value)):void(oe.value=Q.value)}if(T.value===P.DATE){if(Y.value instanceof HTMLInputElement&&"date"===Y.value.type)return void(oe.value=Y.value.value);let e=Q.value;if(null===e||""===e){if(!oe.value)return;return void(oe.value="")}return e instanceof Date||(e=new Date(e)),void(oe.value=`${e.getFullYear()}-${("0"+(e.getMonth()+1)).slice(-2)}-${("0"+e.getDate()).slice(-2)}`)}if(T.value===P.DATETIME_LOCAL){if(Y.value instanceof HTMLInputElement&&"datetime-local"===Y.value.type)return void(oe.value=Y.value.value);let e=Q.value;if(null===e||""===e){if(!oe.value)return;return void(oe.value="")}return Q.value instanceof Date||(e=new Date(e)),void(oe.value=`${e.getFullYear()}-${("0"+(e.getMonth()+1)).slice(-2)}-${("0"+e.getDate()).slice(-2)}T${("0"+e.getHours()).slice(-2)}:${("0"+e.getMinutes()).slice(-2)}`)}(oe.value||ee.value)&&(oe.value=ee.value)}}});e.onMounted((()=>{G.value&&(J.value=!0,Q.value=oe.value??"")})),e.watch((()=>c.modelValue),(e=>{var t;G.value&&(Q.value=e&&(null==(t=null==C?void 0:C.value)?void 0:t.mask)===Date?new Date(e):e??"")})),e.watch((()=>c.masked),(e=>{Z.value=e??""}));const te=Y,le=e.ref();r({$inner:le});const oe=function(t,l,o=0,{getter:a=(e=>e),setter:n=(e=>e)}={}){let i;return"string"==typeof o&&(o=parseInt(o)),e.computed({get:()=>a(null==t?void 0:t.value),set:e=>{i&&clearTimeout(i),i=setTimeout((()=>{l("update:modelValue",n(e))}),o)}})}(w,d,(null==$?void 0:$.value)??0),{focused:ae}=function(t,l){const{focused:o}=a.useFocus(t);return e.watch(o,(o=>{l(o?"focus":"blur",e.unref(t))})),{focused:o}}(te,d),ne=e.computed((()=>ae.value&&!c.disabled&&!c.readonly));e.watch(ne,(e=>{e&&h.value.selectOnFocus&&te.value&&te.value.select()}));const ie=a.useElementVisibility(te);e.watch(ie,(e=>{e&&c.autofocus&&!c.disabled&&!c.readonly&&(ae.value=!0)}));const re=e.ref(!1),ue=e.computed((()=>c.type===P.PASSWORD)),se=()=>{re.value=!re.value},de=e.computed((()=>c.type===P.TIME||c.type===P.DATETIME_LOCAL||c.type===P.DATE||c.type===P.WEEK||c.type===P.MONTH)),ce=e.computed((()=>c.type===P.NUMBER)),ve=()=>{if(we.value){if(null==C?void 0:C.value)return void(Q.value=Q.value+Number((null==D?void 0:D.value)??1));te.value.stepUp(),oe.value=e.unref(te).value}},pe=()=>{if(we.value){if(null==C?void 0:C.value)return void(Q.value=Q.value-Number((null==D?void 0:D.value)??1));te.value.stepDown(),oe.value=e.unref(te).value}},me=e.computed((()=>c.type===P.SEARCH)),fe=()=>{oe.value=""},{hasIcon:he,hasIconBefore:be,hasIconAfter:ge}=function(t,l){const o=e.computed((()=>Boolean((null==t?void 0:t.value)&&l.value===s.before))),a=e.computed((()=>Boolean((null==t?void 0:t.value)&&l.value===s.after))),n=e.computed((()=>Boolean((null==t?void 0:t.value)&&l.value===u.left))),i=e.computed((()=>Boolean((null==t?void 0:t.value)&&l.value===u.right))),r=e.computed((()=>Boolean((null==t?void 0:t.value)&&l.value===u.top))),d=e.computed((()=>Boolean((null==t?void 0:t.value)&&l.value===u.bottom)));return{hasIcon:e.computed((()=>"string"==typeof(null==t?void 0:t.value)?{name:null==t?void 0:t.value}:null==t?void 0:t.value)),hasIconLeft:n,hasIconRight:i,hasIconTop:r,hasIconBottom:d,hasIconBefore:o,hasIconAfter:a}}(g,S),Se=e.computed((()=>{switch(c.type){case P.COLOR:return{name:V};case P.DATE:case P.DATETIME_LOCAL:case P.WEEK:case P.MONTH:return{name:I};case P.TIME:return{name:O};default:return""}})),{formatted:ye}=function(t,l){const o=e.computed((()=>(e.unref(t)??"").length)),a=e.computed((()=>void 0!==(null==l?void 0:l.lowerLimit)&&o.value<(null==l?void 0:l.lowerLimit)?o.value-l.lowerLimit:void 0!==(null==l?void 0:l.upperLimit)&&o.value<(null==l?void 0:l.upperLimit)?l.upperLimit-o.value:0)),n=e.computed((()=>{if(!1===(null==l?void 0:l.mode))return"";if("limit"===(null==l?void 0:l.mode)&&(null==l?void 0:l.upperLimit))return`${o.value} / ${l.lowerLimit?`${l.lowerLimit}-`:""}${l.upperLimit}`;if("countdown"===(null==l?void 0:l.mode)){if(0===a.value)return;return a}return o.value}));return{length:o,gap:a,formatted:n}}(oe,{mode:k.value,upperLimit:Number(null==x?void 0:x.value),lowerLimit:Number(null==A?void 0:A.value)}),we=e.computed((()=>!c.disabled&&!c.readonly)),ke=e.computed((()=>we.value?c.tabindex:-1)),Le=e.computed((()=>!n(w))),Be=e.computed((()=>!0===B.value||!0!==L.value&&void 0)),{modifiers:Ee}=e.toRefs(c),$e=p("vv-input-text",Ee,e.computed((()=>({valid:L.value,invalid:B.value,loading:E.value,disabled:c.disabled,readonly:c.readonly,"icon-before":be.value,"icon-after":ge.value||!n(Se),floating:c.floating&&!n(c.label),dirty:Le.value,focus:ne.value,"auto-width":c.autoWidth})))),xe=e.computed((()=>{const e=ue.value&&re.value?P.TEXT:!de.value||Le.value||ae.value?(null==C?void 0:C.value)?P.TEXT:c.type:P.TEXT,t={type:e,name:c.name,tabindex:ke.value,disabled:c.disabled,readonly:c.readonly,required:c.required,autocomplete:c.autocomplete,"aria-invalid":Be.value,"aria-describedby":Pe.value?M.value:void 0,"aria-errormessage":Ce.value?M.value:void 0};return e!==P.DATE&&e!==P.MONTH&&e!==P.WEEK&&e!==P.TIME&&e!==P.DATETIME_LOCAL&&e!==P.NUMBER||(t.step=c.step,t.max=void 0!==c.max?String(c.max):void 0,t.min=void 0!==c.min?String(c.min):void 0),e!==P.TEXT&&e!==P.SEARCH&&e!==P.URL&&e!==P.TEL&&e!==P.EMAIL&&e!==P.PASSWORD&&e!==P.NUMBER||(t.placeholder=R.value),e!==P.TEXT&&e!==P.SEARCH&&e!==P.URL&&e!==P.TEL&&e!==P.EMAIL&&e!==P.PASSWORD||(t.minlength=c.minlength,t.maxlength=c.maxlength,t.pattern=c.pattern),e===P.EMAIL&&(t.multiple=c.multiple),t})),Ae=e.computed((()=>({valid:c.valid,invalid:c.invalid,modelValue:c.modelValue,togglePassword:se,stepUp:ve,stepDown:pe,clear:fe}))),{HintSlot:Te,hasHintLabelOrSlot:Pe,hasInvalidLabelOrSlot:Ce,hintSlotScope:De}=function(t,l){const o=e.computed((()=>e.isRef(t)?t.value:t)),a=e.computed((()=>i(o.value.invalidLabel))),n=e.computed((()=>i(o.value.validLabel))),r=e.computed((()=>o.value.loadingLabel)),u=e.computed((()=>o.value.hintLabel)),s=e.computed((()=>Boolean(o.value.loading&&(l.loading||r.value)))),d=e.computed((()=>!s.value&&Boolean(o.value.invalid&&(l.invalid||a.value)))),c=e.computed((()=>!s.value&&!d.value&&Boolean(o.value.valid&&(l.valid||n.value)))),v=e.computed((()=>!s.value&&!d.value&&!c.value&&Boolean(l.hint||u.value))),p=e.computed((()=>d.value||c.value||s.value||v.value)),m=e.computed((()=>({modelValue:o.value.modelValue,valid:o.value.valid,invalid:o.value.invalid,loading:o.value.loading}))),f=e.defineComponent({name:"HintSlot",props:{tag:{type:String,default:"small"}},setup:()=>({isVisible:p,invalidLabel:a,validLabel:n,loadingLabel:r,hintLabel:u,hasInvalidLabelOrSlot:d,hasValidLabelOrSlot:c,hasLoadingLabelOrSlot:s,hasHintLabelOrSlot:v}),render(){var t,l,o,a,n,i,r,u;if(this.isVisible){let s;return this.hasInvalidLabelOrSlot&&(s="alert"),this.hasValidLabelOrSlot&&(s="status"),this.hasLoadingLabelOrSlot?e.h(this.tag,{role:s},(null==(l=(t=this.$slots).loading)?void 0:l.call(t))??this.loadingLabel):this.hasInvalidLabelOrSlot?e.h(this.tag,{role:s},(null==(a=(o=this.$slots).invalid)?void 0:a.call(o))??this.$slots.invalid??this.invalidLabel):this.hasValidLabelOrSlot?e.h(this.tag,{role:s},(null==(i=(n=this.$slots).valid)?void 0:i.call(n))??this.validLabel):e.h(this.tag,{role:s},(null==(u=(r=this.$slots).hint)?void 0:u.call(r))??this.$slots.hint??this.hintLabel)}return null}});return{hasInvalidLabelOrSlot:d,hasHintLabelOrSlot:v,hasValidLabelOrSlot:c,hasLoadingLabelOrSlot:s,hintSlotScope:m,HintSlot:f}}(h,f),Ie=H(P.PASSWORD,c),Oe=H(P.NUMBER,c),Ve=H(P.SEARCH,c),_e=()=>{we.value&&(ae.value=!0)},Ne=e.computed((()=>{if(c.autoWidth)return{width:void 0!==oe.value?`${String(oe.value).length+1}ch`:void 0}})),Me=e=>{switch(e.code){case"ArrowUp":ce.value&&(ve(),e.preventDefault());break;case"ArrowDown":ce.value&&(pe(),e.preventDefault())}d("keydown",e)};return(t,l)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(e.unref($e))},[e.unref(y)?(e.openBlock(),e.createElementBlock("label",{key:0,for:e.unref(N),class:"vv-input-text__label"},e.toDisplayString(e.unref(y)),9,U)):e.createCommentVNode("",!0),e.createElementVNode("div",j,[t.$slots.before?(e.openBlock(),e.createElementBlock("div",F,[e.renderSlot(t.$slots,"before",e.normalizeProps(e.guardReactiveProps(e.unref(Ae))))])):e.createCommentVNode("",!0),e.createElementVNode("div",{ref_key:"innerEl",ref:le,class:"vv-input-text__inner",onClick:e.withModifiers(_e,["stop"])},[e.unref(be)?(e.openBlock(),e.createBlock(m,e.mergeProps({key:0,class:"vv-input-text__icon"},e.unref(he)),null,16)):e.createCommentVNode("",!0),e.createElementVNode("input",e.mergeProps({id:e.unref(N),ref_key:"inputEl",ref:te},e.unref(xe),{style:e.unref(Ne),onKeyup:l[0]||(l[0]=e=>d("keyup",e)),onKeydown:Me,onKeypress:l[1]||(l[1]=e=>d("keypress",e))}),null,16,q),(t.unit||t.$slots.unit)&&e.unref(Le)?(e.openBlock(),e.createElementBlock("div",z,[e.renderSlot(t.$slots,"default",e.normalizeProps(e.guardReactiveProps(e.unref(Ae))),(()=>[e.createTextVNode(e.toDisplayString(t.unit),1)]))])):e.createCommentVNode("",!0)],8,W),e.unref(ge)||e.unref(Se)?(e.openBlock(),e.createBlock(m,e.mergeProps({key:1,class:"vv-input-text__icon vv-input-text__icon-after"},e.unref(ge)?e.unref(he):e.unref(Se)),null,16)):e.unref(ue)&&!t.hideActions&&e.unref(we)?(e.openBlock(),e.createBlock(e.unref(Ie),{key:2,onTogglePassword:se})):e.unref(ce)&&!t.hideActions&&e.unref(we)?(e.openBlock(),e.createBlock(e.unref(Oe),{key:3,onStepUp:ve,onStepDown:pe})):e.unref(me)&&!t.hideActions&&e.unref(we)?(e.openBlock(),e.createBlock(e.unref(Ve),{key:4,onClear:fe})):e.createCommentVNode("",!0),t.$slots.after?(e.openBlock(),e.createElementBlock("div",K,[e.renderSlot(t.$slots,"after",e.normalizeProps(e.guardReactiveProps(e.unref(Ae))))])):e.createCommentVNode("",!0),e.unref(k)?(e.openBlock(),e.createElementBlock("span",X,[e.renderSlot(t.$slots,"count",e.normalizeProps(e.guardReactiveProps(e.unref(Ae))),(()=>[e.createTextVNode(e.toDisplayString(e.unref(ye)),1)]))])):e.createCommentVNode("",!0)]),e.createVNode(e.unref(Te),{id:e.unref(M),class:"vv-input-text__hint"},e.createSlots({_:2},[t.$slots.hint?{name:"hint",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"hint",e.normalizeProps(e.guardReactiveProps(e.unref(De))))])),key:"0"}:void 0,t.$slots.loading?{name:"loading",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"loading",e.normalizeProps(e.guardReactiveProps(e.unref(De))))])),key:"1"}:void 0,t.$slots.valid?{name:"valid",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"valid",e.normalizeProps(e.guardReactiveProps(e.unref(De))))])),key:"2"}:void 0,t.$slots.invalid?{name:"invalid",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"invalid",e.normalizeProps(e.guardReactiveProps(e.unref(De))))])),key:"3"}:void 0]),1032,["id"])],2))}})}));
|
|
@@ -45,26 +45,14 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
|
45
45
|
type: StringConstructor;
|
|
46
46
|
default: string;
|
|
47
47
|
};
|
|
48
|
-
|
|
49
|
-
type:
|
|
48
|
+
iMask: {
|
|
49
|
+
type: globalThis.PropType<import("imask/esm/index").FactoryOpts>;
|
|
50
50
|
default: undefined;
|
|
51
51
|
};
|
|
52
|
-
|
|
53
|
-
type:
|
|
54
|
-
default: boolean;
|
|
55
|
-
};
|
|
56
|
-
maskReversed: {
|
|
57
|
-
type: BooleanConstructor;
|
|
58
|
-
default: boolean;
|
|
59
|
-
};
|
|
60
|
-
maskTokens: {
|
|
61
|
-
type: globalThis.PropType<import("maska").MaskTokens>;
|
|
52
|
+
masked: {
|
|
53
|
+
type: StringConstructor;
|
|
62
54
|
default: undefined;
|
|
63
55
|
};
|
|
64
|
-
maskTokensReplace: {
|
|
65
|
-
type: BooleanConstructor;
|
|
66
|
-
default: boolean;
|
|
67
|
-
};
|
|
68
56
|
autoWidth: {
|
|
69
57
|
type: BooleanConstructor;
|
|
70
58
|
default: boolean;
|
|
@@ -76,6 +64,10 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
|
76
64
|
unit: {
|
|
77
65
|
type: StringConstructor;
|
|
78
66
|
};
|
|
67
|
+
selectOnFocus: {
|
|
68
|
+
type: BooleanConstructor;
|
|
69
|
+
default: boolean;
|
|
70
|
+
};
|
|
79
71
|
minlength: (StringConstructor | NumberConstructor)[];
|
|
80
72
|
maxlength: (StringConstructor | NumberConstructor)[];
|
|
81
73
|
placeholder: StringConstructor;
|
|
@@ -175,26 +167,14 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
|
175
167
|
type: StringConstructor;
|
|
176
168
|
default: string;
|
|
177
169
|
};
|
|
178
|
-
|
|
179
|
-
type:
|
|
170
|
+
iMask: {
|
|
171
|
+
type: globalThis.PropType<import("imask/esm/index").FactoryOpts>;
|
|
180
172
|
default: undefined;
|
|
181
173
|
};
|
|
182
|
-
|
|
183
|
-
type:
|
|
184
|
-
default: boolean;
|
|
185
|
-
};
|
|
186
|
-
maskReversed: {
|
|
187
|
-
type: BooleanConstructor;
|
|
188
|
-
default: boolean;
|
|
189
|
-
};
|
|
190
|
-
maskTokens: {
|
|
191
|
-
type: globalThis.PropType<import("maska").MaskTokens>;
|
|
174
|
+
masked: {
|
|
175
|
+
type: StringConstructor;
|
|
192
176
|
default: undefined;
|
|
193
177
|
};
|
|
194
|
-
maskTokensReplace: {
|
|
195
|
-
type: BooleanConstructor;
|
|
196
|
-
default: boolean;
|
|
197
|
-
};
|
|
198
178
|
autoWidth: {
|
|
199
179
|
type: BooleanConstructor;
|
|
200
180
|
default: boolean;
|
|
@@ -206,6 +186,10 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
|
206
186
|
unit: {
|
|
207
187
|
type: StringConstructor;
|
|
208
188
|
};
|
|
189
|
+
selectOnFocus: {
|
|
190
|
+
type: BooleanConstructor;
|
|
191
|
+
default: boolean;
|
|
192
|
+
};
|
|
209
193
|
minlength: (StringConstructor | NumberConstructor)[];
|
|
210
194
|
maxlength: (StringConstructor | NumberConstructor)[];
|
|
211
195
|
placeholder: StringConstructor;
|
|
@@ -262,7 +246,6 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
|
262
246
|
disabled: boolean;
|
|
263
247
|
floating: boolean;
|
|
264
248
|
type: import("../VvInputText").InputType;
|
|
265
|
-
mask: string;
|
|
266
249
|
tabindex: string | number;
|
|
267
250
|
required: boolean;
|
|
268
251
|
iconPosition: "before" | "after";
|
|
@@ -284,12 +267,11 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
|
284
267
|
labelShowPassword: string;
|
|
285
268
|
labelHidePassword: string;
|
|
286
269
|
labelClear: string;
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
maskTokens: import("maska").MaskTokens;
|
|
290
|
-
maskTokensReplace: boolean;
|
|
270
|
+
iMask: import("imask/esm/index").FactoryOpts;
|
|
271
|
+
masked: string;
|
|
291
272
|
autoWidth: boolean;
|
|
292
273
|
hideActions: boolean;
|
|
274
|
+
selectOnFocus: boolean;
|
|
293
275
|
count: string | boolean;
|
|
294
276
|
}, {}>, {
|
|
295
277
|
before?(_: {
|