fds-vue-core 8.2.3 → 8.2.4

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.
@@ -9875,13 +9875,13 @@ const _sfc_main$s = /* @__PURE__ */ defineComponent({
9875
9875
  }
9876
9876
  });
9877
9877
  const _hoisted_1$j = ["for", "id"];
9878
- const _hoisted_2$f = ["type", "required", "disabled", "tabindex", "aria-invalid", "aria-label", "aria-labelledby", "aria-describedby", "autocomplete", "placeholder", "pattern", "searchIcon"];
9879
- const _hoisted_3$f = { class: "whitespace-pre text-base leading-6 tabular-nums" };
9878
+ const _hoisted_2$f = { class: "relative" };
9879
+ const _hoisted_3$f = ["type", "required", "disabled", "tabindex", "aria-invalid", "aria-label", "aria-labelledby", "aria-describedby", "autocomplete", "placeholder", "pattern", "searchIcon"];
9880
9880
  const _hoisted_4$e = {
9881
9881
  key: 0,
9882
9882
  class: "text-red-700 font-bold mt-1"
9883
9883
  };
9884
- const maskFieldPaddingClasses = "px-3 py-[calc(0.75rem-1px)]";
9884
+ const inputPaddingClasses = "px-3 py-[calc(0.75rem-1px)]";
9885
9885
  const _sfc_main$r = /* @__PURE__ */ defineComponent({
9886
9886
  ...{
9887
9887
  inheritAttrs: false
@@ -9898,7 +9898,6 @@ const _sfc_main$r = /* @__PURE__ */ defineComponent({
9898
9898
  labelLeft: { type: Boolean, default: false },
9899
9899
  clearButton: { type: Boolean, default: false },
9900
9900
  mask: { default: void 0 },
9901
- displayChar: { default: void 0 },
9902
9901
  modelValue: {},
9903
9902
  value: { default: void 0 },
9904
9903
  type: {},
@@ -9933,7 +9932,7 @@ const _sfc_main$r = /* @__PURE__ */ defineComponent({
9933
9932
  "modelValue": { default: void 0, required: false },
9934
9933
  "modelModifiers": {}
9935
9934
  }),
9936
- emits: /* @__PURE__ */ mergeModels(["input", "change", "clearInput", "update:value", "keyup", "keyup.enter", "blur"], ["update:modelValue"]),
9935
+ emits: /* @__PURE__ */ mergeModels(["input", "autocomplete", "clearInput", "update:value", "keyup", "keyup.enter", "blur"], ["update:modelValue"]),
9937
9936
  setup(__props, { emit: __emit }) {
9938
9937
  const modelValue = useModel(__props, "modelValue");
9939
9938
  const props = __props;
@@ -10014,86 +10013,26 @@ const _sfc_main$r = /* @__PURE__ */ defineComponent({
10014
10013
  return "pr-40";
10015
10014
  });
10016
10015
  const externalClass = computed(() => props.class ?? attrs.class);
10017
- const maskDisplayValue = ref("");
10018
- const maskPlaceholderChar = ref("");
10019
- const resolvedPlaceholderChar = computed(() => props.displayChar ?? props.maskOptions?.placeholderChar ?? null);
10020
- const useMaskPlaceholderStyle = computed(() => {
10021
- if (!props.mask || !resolvedPlaceholderChar.value) return false;
10022
- const lazy = props.maskOptions?.lazy ?? (props.displayChar ? false : true);
10023
- return !lazy;
10024
- });
10025
- const maskFieldWrapperClasses = computed(() => {
10026
- if (!useMaskPlaceholderStyle.value) return void 0;
10027
- return [
10028
- "rounded-md border border-gray-500 bg-white bg-clip-padding",
10029
- props.disabled && "outline-dashed outline-2 outline-gray-400 cursor-not-allowed border-transparent",
10030
- isInvalid.value ? "outline-2 -outline-offset-2 outline-red-600" : "focus-within:outline-2 focus-within:outline-blue-500 focus-within:outline-offset-0",
10031
- "focus-within:border-transparent"
10032
- ];
10033
- });
10034
- const maskOverlayClasses = computed(() => [
10035
- "pointer-events-none absolute inset-0 z-[3] flex items-center",
10036
- maskFieldPaddingClasses,
10037
- inputPaddingRight.value
10016
+ const inputClasses = computed(() => [
10017
+ "block rounded-md border border-gray-500",
10018
+ maxlength.value ? "" : "w-full",
10019
+ inputPaddingClasses,
10020
+ inputPaddingRight.value,
10021
+ "focus:outline-2 focus:outline-blue-500 -outline-offset-2 focus:border-transparent",
10022
+ showDateIcon.value && "[&::-webkit-calendar-picker-indicator]:opacity-0 [&::-webkit-calendar-picker-indicator]:pointer-events-none",
10023
+ props.disabled ? "text-gray-800 outline-dashed outline-2 outline-gray-400 cursor-not-allowed border-transparent" : "text-gray-900 bg-white",
10024
+ isInvalid.value && "outline-2 outline-red-600",
10025
+ props.inputClass
10038
10026
  ]);
10039
- const maskDisplayChars = computed(() => {
10040
- const display = maskDisplayValue.value;
10041
- const placeholder = maskPlaceholderChar.value || resolvedPlaceholderChar.value;
10042
- if (!display || !placeholder) return [];
10043
- return [...display].map((char) => ({
10044
- char,
10045
- isPlaceholder: char === placeholder
10046
- }));
10047
- });
10048
- function maskCharStyle(isPlaceholder) {
10049
- if (isPlaceholder) {
10050
- return { color: props.disabled ? "var(--color-gray-500)" : "var(--color-gray-400)" };
10051
- }
10052
- return { color: props.disabled ? "var(--color-gray-800)" : "var(--color-gray-900)" };
10053
- }
10054
- const inputClasses = computed(() => {
10055
- const shared = [
10056
- "block rounded-md",
10057
- maxlength.value ? "" : "w-full",
10058
- inputPaddingRight.value,
10059
- showDateIcon.value && "[&::-webkit-calendar-picker-indicator]:opacity-0 [&::-webkit-calendar-picker-indicator]:pointer-events-none",
10060
- props.inputClass
10061
- ];
10062
- if (useMaskPlaceholderStyle.value) {
10063
- return [
10064
- ...shared,
10065
- "relative z-[2] border-0 bg-transparent shadow-none focus:outline-none",
10066
- maskFieldPaddingClasses,
10067
- "text-base leading-6 tabular-nums",
10068
- props.disabled ? "cursor-not-allowed" : ""
10069
- ];
10070
- }
10071
- return [
10072
- ...shared,
10073
- "rounded-md border border-gray-500",
10074
- maskFieldPaddingClasses,
10075
- "focus:outline-2 focus:outline-blue-500 -outline-offset-2 focus:border-transparent",
10076
- props.disabled ? "text-gray-800 outline-dashed outline-2 outline-gray-400 cursor-not-allowed border-transparent" : "text-gray-900 bg-white",
10077
- isInvalid.value && "outline-2 outline-red-600"
10078
- ];
10079
- });
10080
10027
  const inputStyle = computed(() => {
10081
- const size = maxlength.value ? {
10028
+ if (!maxlength.value) return void 0;
10029
+ return {
10082
10030
  width: `calc(${maxlength.value}ch + 1.5rem + 0.25rem)`,
10083
10031
  maxWidth: "100%"
10084
- } : {};
10085
- if (!useMaskPlaceholderStyle.value) {
10086
- return size;
10087
- }
10088
- return {
10089
- ...size,
10090
- color: "transparent",
10091
- WebkitTextFillColor: "transparent",
10092
- caretColor: props.disabled ? "#1f2937" : "#111827"
10093
10032
  };
10094
10033
  });
10095
10034
  const rightIconsContainerClasses = computed(() => [
10096
- "absolute z-10 flex gap-2 top-1/2 -translate-y-1/2 items-center justify-end",
10035
+ "absolute flex gap-2 top-1/2 -translate-y-1/2 items-center justify-end",
10097
10036
  showClearButton.value ? "right-2" : "right-3"
10098
10037
  ]);
10099
10038
  const inputBindings = computed(() => ({
@@ -10113,7 +10052,6 @@ const _sfc_main$r = /* @__PURE__ */ defineComponent({
10113
10052
  internalValue.value = "";
10114
10053
  if (maskInstance) {
10115
10054
  maskInstance.value = "";
10116
- nextTick(syncMaskDisplay);
10117
10055
  }
10118
10056
  emit("clearInput");
10119
10057
  }
@@ -10143,57 +10081,25 @@ const _sfc_main$r = /* @__PURE__ */ defineComponent({
10143
10081
  }
10144
10082
  const inputRef = ref(null);
10145
10083
  let maskInstance = null;
10146
- function getMaskEmittedValue(instance) {
10147
- if (!instance) return "";
10148
- const raw = String(instance.value ?? "");
10149
- if (!useMaskPlaceholderStyle.value) return raw;
10150
- const placeholder = instance.masked?.placeholderChar ?? resolvedPlaceholderChar.value;
10151
- if (!placeholder) return raw;
10152
- return raw.split(placeholder).join("").replace(/\s+$/, "");
10153
- }
10154
- function syncMaskDisplay() {
10155
- if (!inputRef.value) {
10156
- maskDisplayValue.value = "";
10157
- maskPlaceholderChar.value = "";
10158
- return;
10159
- }
10160
- maskPlaceholderChar.value = maskInstance?.masked?.placeholderChar ?? resolvedPlaceholderChar.value ?? "";
10161
- maskDisplayValue.value = maskInstance?.displayValue ?? inputRef.value.value ?? maskInstance?.value ?? "";
10162
- }
10163
10084
  const createMask2 = () => {
10164
10085
  if (maskInstance) {
10165
10086
  maskInstance.destroy();
10166
10087
  maskInstance = null;
10167
10088
  }
10168
10089
  if (props.mask && inputRef.value) {
10169
- const maskConfig = {
10090
+ maskInstance = IMask(inputRef.value, {
10170
10091
  mask: props.mask,
10171
10092
  ...props.maskOptions,
10172
- ...props.displayChar ? {
10173
- placeholderChar: props.displayChar,
10174
- lazy: props.maskOptions?.lazy ?? false
10175
- } : {}
10176
- };
10177
- maskInstance = IMask(inputRef.value, maskConfig);
10093
+ lazy: props.maskOptions?.lazy ?? true
10094
+ });
10178
10095
  if (internalValue.value) {
10179
10096
  maskInstance.value = internalValue.value;
10180
10097
  }
10181
10098
  maskInstance.on("accept", () => {
10182
10099
  if (maskInstance) {
10183
- internalValue.value = getMaskEmittedValue(maskInstance);
10184
- nextTick(syncMaskDisplay);
10100
+ internalValue.value = maskInstance.value;
10185
10101
  }
10186
10102
  });
10187
- maskInstance.on("complete", () => {
10188
- nextTick(syncMaskDisplay);
10189
- });
10190
- nextTick(() => {
10191
- syncMaskDisplay();
10192
- nextTick(syncMaskDisplay);
10193
- });
10194
- } else {
10195
- maskDisplayValue.value = "";
10196
- maskPlaceholderChar.value = "";
10197
10103
  }
10198
10104
  };
10199
10105
  onMounted(() => {
@@ -10222,7 +10128,7 @@ const _sfc_main$r = /* @__PURE__ */ defineComponent({
10222
10128
  return props.meta ? metaId.value : void 0;
10223
10129
  });
10224
10130
  watch(
10225
- () => [props.mask, props.displayChar, props.maskOptions],
10131
+ () => [props.mask, props.maskOptions],
10226
10132
  () => {
10227
10133
  nextTick(() => {
10228
10134
  createMask2();
@@ -10230,13 +10136,23 @@ const _sfc_main$r = /* @__PURE__ */ defineComponent({
10230
10136
  },
10231
10137
  { deep: true }
10232
10138
  );
10139
+ function shouldSyncMaskFromModel(newValue, currentMaskedValue) {
10140
+ if (newValue === void 0) {
10141
+ return false;
10142
+ }
10143
+ if (document.activeElement !== inputRef.value) {
10144
+ return true;
10145
+ }
10146
+ const newDigits = String(newValue).replace(/\D/g, "");
10147
+ const currentDigits = String(currentMaskedValue ?? "").replace(/\D/g, "");
10148
+ return newDigits !== currentDigits;
10149
+ }
10233
10150
  watch(
10234
10151
  () => props.value,
10235
10152
  (newValue) => {
10236
- if (maskInstance && newValue !== void 0 && newValue !== getMaskEmittedValue(maskInstance)) {
10237
- if (document.activeElement !== inputRef.value) {
10153
+ if (maskInstance && newValue !== void 0 && newValue !== maskInstance.value) {
10154
+ if (shouldSyncMaskFromModel(newValue, maskInstance.value)) {
10238
10155
  maskInstance.value = newValue;
10239
- nextTick(syncMaskDisplay);
10240
10156
  }
10241
10157
  }
10242
10158
  }
@@ -10244,10 +10160,9 @@ const _sfc_main$r = /* @__PURE__ */ defineComponent({
10244
10160
  watch(
10245
10161
  () => modelValue.value,
10246
10162
  (newValue) => {
10247
- if (maskInstance && newValue !== void 0 && newValue !== getMaskEmittedValue(maskInstance)) {
10248
- if (document.activeElement !== inputRef.value) {
10163
+ if (maskInstance && newValue !== void 0 && newValue !== maskInstance.value) {
10164
+ if (shouldSyncMaskFromModel(newValue, maskInstance.value)) {
10249
10165
  maskInstance.value = newValue;
10250
- nextTick(syncMaskDisplay);
10251
10166
  }
10252
10167
  }
10253
10168
  }
@@ -10282,9 +10197,7 @@ const _sfc_main$r = /* @__PURE__ */ defineComponent({
10282
10197
  createElementVNode("div", {
10283
10198
  class: normalizeClass({ "flex-1": props.labelLeft })
10284
10199
  }, [
10285
- createElementVNode("div", {
10286
- class: normalizeClass(["relative", maskFieldWrapperClasses.value])
10287
- }, [
10200
+ createElementVNode("div", _hoisted_2$f, [
10288
10201
  createElementVNode("input", mergeProps({
10289
10202
  ref_key: "inputRef",
10290
10203
  ref: inputRef,
@@ -10305,26 +10218,13 @@ const _sfc_main$r = /* @__PURE__ */ defineComponent({
10305
10218
  }, inputBindings.value, {
10306
10219
  onInput: handleInputChange,
10307
10220
  onChange: handleInputChange,
10308
- onBlur: _cache[0] || (_cache[0] = ($event) => _ctx.$emit("blur", $event)),
10309
- onKeyup: _cache[1] || (_cache[1] = (ev) => {
10221
+ onAutocomplete: _cache[0] || (_cache[0] = ($event) => _ctx.$emit("autocomplete", $event)),
10222
+ onBlur: _cache[1] || (_cache[1] = ($event) => _ctx.$emit("blur", $event)),
10223
+ onKeyup: _cache[2] || (_cache[2] = (ev) => {
10310
10224
  _ctx.$emit("keyup", ev);
10311
10225
  if (ev.key === "Enter") _ctx.$emit("keyup.enter", ev);
10312
10226
  })
10313
- }), null, 16, _hoisted_2$f),
10314
- useMaskPlaceholderStyle.value ? (openBlock(), createElementBlock("div", {
10315
- key: 0,
10316
- class: normalizeClass(maskOverlayClasses.value),
10317
- "aria-hidden": "true"
10318
- }, [
10319
- createElementVNode("span", _hoisted_3$f, [
10320
- (openBlock(true), createElementBlock(Fragment, null, renderList(maskDisplayChars.value, (item, index) => {
10321
- return openBlock(), createElementBlock("span", {
10322
- key: index,
10323
- style: normalizeStyle(maskCharStyle(item.isPlaceholder))
10324
- }, toDisplayString(item.char), 5);
10325
- }), 128))
10326
- ])
10327
- ], 2)) : createCommentVNode("", true),
10227
+ }), null, 16, _hoisted_3$f),
10328
10228
  createElementVNode("div", {
10329
10229
  class: normalizeClass(rightIconsContainerClasses.value)
10330
10230
  }, [
@@ -10366,11 +10266,11 @@ const _sfc_main$r = /* @__PURE__ */ defineComponent({
10366
10266
  }, null, 8, ["icon", "text"])) : createCommentVNode("", true)
10367
10267
  ], 2),
10368
10268
  showTodaySuffixInField.value ? (openBlock(), createElementBlock("span", {
10369
- key: 1,
10269
+ key: 0,
10370
10270
  class: normalizeClass(todaySuffixClasses.value),
10371
10271
  style: normalizeStyle(todaySuffixStyle.value)
10372
10272
  }, toDisplayString(todayLabel.value), 7)) : createCommentVNode("", true)
10373
- ], 2)
10273
+ ])
10374
10274
  ], 2)
10375
10275
  ], 2),
10376
10276
  showInvalidMessage.value ? (openBlock(), createElementBlock("div", _hoisted_4$e, toDisplayString(props.invalidMessage), 1)) : createCommentVNode("", true)
@@ -18613,6 +18513,11 @@ function parsePhoneNumber$1() {
18613
18513
  function getCountries$1(metadata2) {
18614
18514
  return new Metadata(metadata2).getCountries();
18615
18515
  }
18516
+ function getExampleNumber$1(country, examples2, metadata2) {
18517
+ if (examples2[country]) {
18518
+ return new PhoneNumber$1(country, examples2[country], metadata2);
18519
+ }
18520
+ }
18616
18521
  class PhoneNumber2 extends PhoneNumber$1 {
18617
18522
  constructor(number) {
18618
18523
  super(number, metadata);
@@ -18627,6 +18532,9 @@ function getCountries() {
18627
18532
  function getCountryCallingCode() {
18628
18533
  return withMetadataArgument(getCountryCallingCode$1, arguments);
18629
18534
  }
18535
+ function getExampleNumber() {
18536
+ return withMetadataArgument(getExampleNumber$1, arguments);
18537
+ }
18630
18538
  function resolveDisplayLocale(locale) {
18631
18539
  const trimmed = locale.trim();
18632
18540
  if (!trimmed) {
@@ -18700,6 +18608,90 @@ function filterCountryOptions(options, query) {
18700
18608
  return option.label.toLowerCase().includes(normalizedQuery) || option.countryName.toLowerCase().includes(normalizedQuery) || option.value.toLowerCase().includes(normalizedQuery) || dialCode.includes(normalizedQuery) || `+${dialCode}`.includes(normalizedQuery);
18701
18609
  });
18702
18610
  }
18611
+ const examples = { "AC": "40123", "AD": "312345", "AE": "501234567", "AF": "701234567", "AG": "2684641234", "AI": "2642351234", "AL": "672123456", "AM": "77123456", "AO": "923123456", "AR": "91123456789", "AS": "6847331234", "AT": "664123456", "AU": "412345678", "AW": "5601234", "AX": "412345678", "AZ": "401234567", "BA": "61123456", "BB": "2462501234", "BD": "1812345678", "BE": "450001234", "BF": "70123456", "BG": "43012345", "BH": "36001234", "BI": "79561234", "BJ": "0195123456", "BL": "690001234", "BM": "4413701234", "BN": "7123456", "BO": "71234567", "BQ": "3181234", "BR": "11961234567", "BS": "2423591234", "BT": "17123456", "BW": "71123456", "BY": "294911911", "BZ": "6221234", "CA": "5062345678", "CC": "412345678", "CD": "991234567", "CF": "70012345", "CG": "061234567", "CH": "781234567", "CI": "0123456789", "CK": "71234", "CL": "221234567", "CM": "671234567", "CN": "13123456789", "CO": "3211234567", "CR": "83123456", "CU": "51234567", "CV": "9911234", "CW": "95181234", "CX": "412345678", "CY": "96123456", "CZ": "601123456", "DE": "15123456789", "DJ": "77831001", "DK": "34412345", "DM": "7672251234", "DO": "8092345678", "DZ": "551234567", "EC": "991234567", "EE": "51234567", "EG": "1001234567", "EH": "650123456", "ER": "7123456", "ES": "612345678", "ET": "911234567", "FI": "412345678", "FJ": "7012345", "FK": "51234", "FM": "3501234", "FO": "211234", "FR": "612345678", "GA": "06031234", "GB": "7400123456", "GD": "4734031234", "GE": "555123456", "GF": "694201234", "GG": "7781123456", "GH": "231234567", "GI": "57123456", "GL": "221234", "GM": "3012345", "GN": "601123456", "GP": "690001234", "GQ": "222123456", "GR": "6912345678", "GT": "51234567", "GU": "6713001234", "GW": "955012345", "GY": "6091234", "HK": "51234567", "HN": "91234567", "HR": "921234567", "HT": "34101234", "HU": "201234567", "ID": "812345678", "IE": "850123456", "IL": "502345678", "IM": "7924123456", "IN": "8123456789", "IO": "3801234", "IQ": "7912345678", "IR": "9123456789", "IS": "6111234", "IT": "3123456789", "JE": "7797712345", "JM": "8762101234", "JO": "790123456", "JP": "9012345678", "KE": "712123456", "KG": "700123456", "KH": "91234567", "KI": "72001234", "KM": "3212345", "KN": "8697652917", "KP": "1921234567", "KR": "1020000000", "KW": "50012345", "KY": "3453231234", "KZ": "7710009998", "LA": "2023123456", "LB": "71123456", "LC": "7582845678", "LI": "660234567", "LK": "712345678", "LR": "770123456", "LS": "50123456", "LT": "61234567", "LU": "628123456", "LV": "21234567", "LY": "912345678", "MA": "650123456", "MC": "612345678", "MD": "62112345", "ME": "60123456", "MF": "690001234", "MG": "321234567", "MH": "2351234", "MK": "72345678", "ML": "65012345", "MM": "92123456", "MN": "88123456", "MO": "66123456", "MP": "6702345678", "MQ": "696201234", "MR": "22123456", "MS": "6644923456", "MT": "96961234", "MU": "52512345", "MV": "7712345", "MW": "991234567", "MX": "2221234567", "MY": "123456789", "MZ": "821234567", "NA": "811234567", "NC": "751234", "NE": "93123456", "NF": "381234", "NG": "8021234567", "NI": "81234567", "NL": "612345678", "NO": "40612345", "NP": "9841234567", "NR": "5551234", "NU": "8884012", "NZ": "211234567", "OM": "92123456", "PA": "61234567", "PE": "912345678", "PF": "87123456", "PG": "70123456", "PH": "9051234567", "PK": "3012345678", "PL": "512345678", "PM": "551234", "PR": "7872345678", "PS": "599123456", "PT": "912345678", "PW": "6201234", "PY": "961456789", "QA": "33123456", "RE": "692123456", "RO": "712034567", "RS": "601234567", "RU": "9123456789", "RW": "720123456", "SA": "512345678", "SB": "7421234", "SC": "2510123", "SD": "911231234", "SE": "701234567", "SG": "81234567", "SH": "51234", "SI": "31234567", "SJ": "41234567", "SK": "912123456", "SL": "25123456", "SM": "66661212", "SN": "701234567", "SO": "71123456", "SR": "7412345", "SS": "977123456", "ST": "9812345", "SV": "70123456", "SX": "7215205678", "SY": "944567890", "SZ": "76123456", "TA": "8999", "TC": "6492311234", "TD": "63012345", "TG": "90112345", "TH": "812345678", "TJ": "917123456", "TK": "7290", "TL": "77212345", "TM": "66123456", "TN": "20123456", "TO": "7715123", "TR": "5012345678", "TT": "8682911234", "TV": "901234", "TW": "912345678", "TZ": "621234567", "UA": "501234567", "UG": "712345678", "US": "2015550123", "UY": "94231234", "UZ": "912345678", "VA": "3123456789", "VC": "7844301234", "VE": "4121234567", "VG": "2843001234", "VI": "3406421234", "VN": "912345678", "VU": "5912345", "WF": "821234", "WS": "7212345", "XK": "43201234", "YE": "712345678", "YT": "639012345", "ZA": "711234567", "ZM": "955123456", "ZW": "712345678" };
18612
+ const maskCache = /* @__PURE__ */ new Map();
18613
+ const getPhoneMaskForCountry = (countryIso2) => {
18614
+ const country = countryIso2.trim().toUpperCase();
18615
+ const cached = maskCache.get(country);
18616
+ if (cached) {
18617
+ return cached;
18618
+ }
18619
+ const example = getExampleNumber(country, examples);
18620
+ if (!example) {
18621
+ return void 0;
18622
+ }
18623
+ const groups = example.formatNational().split(/\D+/).filter(Boolean).map((part) => part.length);
18624
+ const mask = groups.map((size) => "0".repeat(size)).join(" ");
18625
+ maskCache.set(country, mask);
18626
+ return mask;
18627
+ };
18628
+ const nationalDigitsForMask = (parsed) => parsed.formatNational().replace(/\D/g, "");
18629
+ const tryParseForCountry = (candidate, country) => {
18630
+ const parsed = parsePhoneNumber(candidate, country) ?? parsePhoneNumber(candidate);
18631
+ if (!parsed?.isValid() || parsed.country !== country) {
18632
+ return void 0;
18633
+ }
18634
+ return parsed;
18635
+ };
18636
+ const shouldNormalizePhoneInput = (value, countryIso2) => {
18637
+ const trimmed = value.trim();
18638
+ if (!trimmed) {
18639
+ return false;
18640
+ }
18641
+ if (trimmed.includes("+") || trimmed.startsWith("00")) {
18642
+ return true;
18643
+ }
18644
+ const digits = trimmed.replace(/\D/g, "");
18645
+ const mask = getPhoneMaskForCountry(countryIso2);
18646
+ if (!mask) {
18647
+ return false;
18648
+ }
18649
+ const maxDigits = (mask.match(/0/g) ?? []).length;
18650
+ if (digits.length > maxDigits) {
18651
+ return true;
18652
+ }
18653
+ try {
18654
+ const callingCode = getCountryCallingCode(countryIso2);
18655
+ if (digits.startsWith(callingCode) && digits.length > maxDigits - 1) {
18656
+ return true;
18657
+ }
18658
+ } catch {
18659
+ return false;
18660
+ }
18661
+ return false;
18662
+ };
18663
+ const normalizeNationalPhoneInput = (value, countryIso2) => {
18664
+ const trimmed = value.trim();
18665
+ if (!trimmed) {
18666
+ return "";
18667
+ }
18668
+ const country = countryIso2.trim().toUpperCase();
18669
+ const digits = trimmed.replace(/\D/g, "");
18670
+ const candidates = /* @__PURE__ */ new Set([trimmed]);
18671
+ if (digits) {
18672
+ candidates.add(digits);
18673
+ candidates.add(`+${digits}`);
18674
+ }
18675
+ for (const candidate of candidates) {
18676
+ const parsed = tryParseForCountry(candidate, country);
18677
+ if (parsed) {
18678
+ return nationalDigitsForMask(parsed);
18679
+ }
18680
+ }
18681
+ try {
18682
+ const callingCode = getCountryCallingCode(country);
18683
+ if (digits.startsWith(callingCode) && digits.length > callingCode.length) {
18684
+ const withoutCode = digits.slice(callingCode.length);
18685
+ const parsed = tryParseForCountry(withoutCode, country) ?? tryParseForCountry(`0${withoutCode}`, country);
18686
+ if (parsed) {
18687
+ return nationalDigitsForMask(parsed);
18688
+ }
18689
+ }
18690
+ } catch {
18691
+ return trimmed;
18692
+ }
18693
+ return trimmed;
18694
+ };
18703
18695
  const _hoisted_1$5 = { class: "relative w-full" };
18704
18696
  const _hoisted_2$4 = { class: "absolute left-3 top-1/2 -translate-y-1/2 text-xl leading-none" };
18705
18697
  const _hoisted_3$4 = ["aria-expanded", "aria-label", "aria-controls", "aria-activedescendant", "value", "disabled"];
@@ -19184,12 +19176,9 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
19184
19176
  autocomplete: { default: "tel" },
19185
19177
  required: { type: Boolean, default: false },
19186
19178
  placeholder: { default: void 0 },
19187
- maxlength: { default: void 0 },
19188
- minlength: { default: void 0 },
19189
19179
  name: { default: void 0 },
19190
19180
  autofocus: { type: Boolean, default: false },
19191
- readonly: { type: Boolean, default: false },
19192
- pattern: { default: void 0 }
19181
+ readonly: { type: Boolean, default: false }
19193
19182
  }, {
19194
19183
  "modelValue": { default: "" },
19195
19184
  "modelModifiers": {},
@@ -19198,7 +19187,7 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
19198
19187
  }),
19199
19188
  emits: /* @__PURE__ */ mergeModels(["update:modelValue", "update:country", "update:e164", "valid", "noCountryResults", "blur"], ["update:modelValue", "update:country"]),
19200
19189
  setup(__props, { emit: __emit }) {
19201
- const [nationalNumber, modelModifiers] = useModel(__props, "modelValue");
19190
+ const [nationalNumber] = useModel(__props, "modelValue");
19202
19191
  const country = useModel(__props, "country");
19203
19192
  const attrs = useAttrs();
19204
19193
  const props = __props;
@@ -19217,12 +19206,10 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
19217
19206
  autocomplete: props.autocomplete,
19218
19207
  required: props.required,
19219
19208
  placeholder: props.placeholder,
19220
- maxlength: props.maxlength,
19221
- minlength: props.minlength,
19222
19209
  name: props.name,
19223
19210
  autofocus: props.autofocus,
19224
19211
  readonly: props.readonly,
19225
- pattern: props.pattern,
19212
+ inputmode: "tel",
19226
19213
  ...inputAttrs.value
19227
19214
  }));
19228
19215
  const countryItems = computed(() => {
@@ -19233,6 +19220,10 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
19233
19220
  props.defaultCountry
19234
19221
  );
19235
19222
  });
19223
+ const phoneMask = computed(() => getPhoneMaskForCountry(country.value ?? props.defaultCountry));
19224
+ const phoneMaskOptions = computed(() => ({
19225
+ prepare: (value) => applyPhoneNormalization(value, country.value ?? props.defaultCountry)
19226
+ }));
19236
19227
  const committedValid = ref(null);
19237
19228
  const resolvedLabel = computed(() => props.label === void 0 ? t("FdsPhonenumber.phoneNumber") : props.label);
19238
19229
  const resolvedInvalidMessage = computed(
@@ -19256,6 +19247,18 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
19256
19247
  const result2 = validatePhoneNumber(nationalNumber.value ?? "", country.value ?? "SE");
19257
19248
  emit("update:e164", result2.isValid && result2.phoneNumber ? result2.phoneNumber : "");
19258
19249
  }
19250
+ function applyPhoneNormalization(value, countryCode = country.value ?? props.defaultCountry) {
19251
+ if (!shouldNormalizePhoneInput(value, countryCode)) {
19252
+ return value;
19253
+ }
19254
+ return normalizeNationalPhoneInput(value, countryCode);
19255
+ }
19256
+ watch(nationalNumber, (value) => {
19257
+ const normalized = applyPhoneNormalization(value ?? "");
19258
+ if (normalized !== (value ?? "")) {
19259
+ nationalNumber.value = normalized;
19260
+ }
19261
+ });
19259
19262
  watch(country, () => {
19260
19263
  if (committedValid.value === null) {
19261
19264
  return;
@@ -19263,6 +19266,10 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
19263
19266
  runValidation();
19264
19267
  });
19265
19268
  function handleBlur(ev) {
19269
+ const normalized = applyPhoneNormalization(nationalNumber.value ?? "");
19270
+ if (normalized !== (nationalNumber.value ?? "")) {
19271
+ nationalNumber.value = normalized;
19272
+ }
19266
19273
  runValidation();
19267
19274
  emit("blur", ev);
19268
19275
  }
@@ -19292,15 +19299,15 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
19292
19299
  createVNode(_sfc_main$r, mergeProps({
19293
19300
  modelValue: unref(nationalNumber),
19294
19301
  "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => isRef(nationalNumber) ? nationalNumber.value = $event : null),
19295
- modelModifiers: unref(modelModifiers),
19296
- type: "tel",
19302
+ mask: phoneMask.value,
19303
+ "mask-options": phoneMaskOptions.value,
19297
19304
  valid: displayValid.value,
19298
19305
  disabled: __props.disabled,
19299
19306
  optional: __props.optional,
19300
19307
  ariaLabel: unref(t)("FdsPhonenumber.phoneNumber"),
19301
19308
  "data-testid": __props.dataTestid ? `${__props.dataTestid}-number` : void 0,
19302
19309
  class: ["mb-0! min-w-0 flex-1", __props.inputClass ?? ""]
19303
- }, forwardedInputProps.value, { onBlur: handleBlur }), null, 16, ["modelValue", "modelModifiers", "valid", "disabled", "optional", "ariaLabel", "data-testid", "class"])
19310
+ }, forwardedInputProps.value, { onBlur: handleBlur }), null, 16, ["modelValue", "mask", "mask-options", "valid", "disabled", "optional", "ariaLabel", "data-testid", "class"])
19304
19311
  ]),
19305
19312
  noCountryResults.value ? (openBlock(), createElementBlock("div", _hoisted_4$3, toDisplayString(unref(t)("FdsPhonenumber.noCountryResults")), 1)) : createCommentVNode("", true),
19306
19313
  showInvalidMessage.value ? (openBlock(), createElementBlock("div", _hoisted_5$3, toDisplayString(resolvedInvalidMessage.value), 1)) : createCommentVNode("", true)