fds-vue-core 7.2.2 → 7.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.
@@ -20,12 +20,22 @@ declare const _default: import('vue').DefineComponent<__VLS_PublicProps, {}, {},
20
20
  "onUpdate:e164"?: ((phoneNumber: string) => any) | undefined;
21
21
  }>, {
22
22
  disabled: boolean;
23
+ required: boolean;
24
+ id: string;
25
+ name: string;
26
+ placeholder: string;
27
+ maxlength: number;
23
28
  dataTestid: string;
24
29
  label: string;
25
30
  meta: string;
31
+ pattern: string;
32
+ autofocus: boolean;
26
33
  valid: boolean | null;
27
34
  optional: boolean;
28
35
  invalidMessage: string;
36
+ minlength: number;
37
+ autocomplete: string;
38
+ readonly: boolean;
29
39
  inputClass: string;
30
40
  locale: string;
31
41
  defaultCountry: string;
@@ -1,16 +1,18 @@
1
+ import { FdsInputProps } from '../FdsInput/types';
1
2
  import { CountryPhoneOption } from './countries';
2
3
  /**
3
4
  * `mobile` – mobile numbers only (Google libphonenumber metadata).
4
5
  * `any` – mobile and fixed-line numbers.
5
6
  */
6
7
  export type FdsPhonenumberNumberType = 'mobile' | 'any';
7
- export interface FdsPhonenumberProps {
8
+ type FdsPhonenumberInputPassthroughProps = Pick<FdsInputProps, 'id' | 'autocomplete' | 'required' | 'placeholder' | 'maxlength' | 'minlength' | 'name' | 'autofocus' | 'readonly' | 'pattern'>;
9
+ export interface FdsPhonenumberProps extends FdsPhonenumberInputPassthroughProps {
8
10
  label?: string;
9
11
  meta?: string;
10
12
  optional?: boolean;
11
13
  valid?: boolean | null;
12
14
  invalidMessage?: string;
13
- /** National number (without country calling code). */
15
+ /** National number as typed by the user (without country calling code). */
14
16
  modelValue?: string;
15
17
  /** ISO 3166-1 alpha-2 country code, e.g. `SE`. */
16
18
  country?: string;
@@ -26,6 +28,11 @@ export interface FdsPhonenumberProps {
26
28
  dataTestid?: string;
27
29
  selectClass?: string;
28
30
  inputClass?: string;
31
+ onValid?: ((value: boolean | null) => void) | Array<(value: boolean | null) => void>;
32
+ onNoCountryResults?: ((value: boolean) => void) | Array<(value: boolean) => void>;
33
+ onBlur?: ((event: FocusEvent) => void) | Array<(event: FocusEvent) => void>;
34
+ 'onUpdate:e164'?: ((value: string) => void) | Array<(value: string) => void>;
35
+ 'onUpdate:country'?: ((value: string) => void) | Array<(value: string) => void>;
29
36
  }
30
37
  export interface FdsPhonenumberEmits {
31
38
  'update:country': [country: string];
@@ -34,3 +41,4 @@ export interface FdsPhonenumberEmits {
34
41
  noCountryResults: [value: boolean];
35
42
  blur: [ev: FocusEvent];
36
43
  }
44
+ export {};
@@ -82,6 +82,7 @@ const en = {
82
82
  "FdsPagination.nextPage": "Go to next page",
83
83
  "FdsPagination.previousPage": "Go to previous page",
84
84
  "FdsPhonenumber.countryCode": "Country code",
85
+ "FdsPhonenumber.invalidPhone": "Enter a valid phone number",
85
86
  "FdsPhonenumber.noCountryResults": "No country matches your search",
86
87
  "FdsPhonenumber.phoneNumber": "Phone number",
87
88
  "FdsSearchSelectPro.loadingMore": "Loading more...",
@@ -148,6 +149,7 @@ const sv = {
148
149
  "FdsPagination.nextPage": "Gå till nästa sida",
149
150
  "FdsPagination.previousPage": "Gå till föregående sida",
150
151
  "FdsPhonenumber.countryCode": "Landskod",
152
+ "FdsPhonenumber.invalidPhone": "Ange ett giltigt telefonnummer",
151
153
  "FdsPhonenumber.noCountryResults": "Inget land matchar sökningen",
152
154
  "FdsPhonenumber.phoneNumber": "Telefonnummer",
153
155
  "FdsSearchSelectPro.loadingMore": "Hämtar fler...",
@@ -18315,9 +18317,6 @@ const _sfc_main$b = /* @__PURE__ */ vue.defineComponent({
18315
18317
  const showActiveDialPreview = vue.computed(
18316
18318
  () => !showHoverDialPreview.value && !!activeCountry.value && dropdownOpen.value && !isSearching.value
18317
18319
  );
18318
- const showDialPreviewPadding = vue.computed(
18319
- () => showSelectedDialPreview.value || showHoverDialPreview.value || showActiveDialPreview.value
18320
- );
18321
18320
  const dialPreviewCountry = vue.computed(() => {
18322
18321
  if (showHoverDialPreview.value && hoveredCountry.value) {
18323
18322
  return hoveredCountry.value;
@@ -18340,11 +18339,11 @@ const _sfc_main$b = /* @__PURE__ */ vue.defineComponent({
18340
18339
  showHoverDialPreview.value ? "text-gray-900/50" : "text-gray-900"
18341
18340
  ]);
18342
18341
  const inputClasses = vue.computed(() => [
18343
- "block w-full h-12 rounded-md border border-gray-500 py-2 text-base leading-6 tabular-nums",
18344
- showDialPreviewPadding.value ? "pl-10 pr-10" : "px-3 pr-10",
18342
+ "block w-full h-12 rounded-md border border-gray-500 py-2 text-base leading-6 tabular-nums px-3 pr-10",
18345
18343
  "focus:outline-2 focus:outline-blue-500 -outline-offset-2 focus:border-transparent",
18346
18344
  props.disabled ? "text-gray-800 outline-dashed outline-2 outline-gray-400 cursor-not-allowed border-transparent bg-gray-50" : "cursor-text bg-white text-gray-900",
18347
- isInvalid.value && "outline-2 -outline-offset-2 outline-red-600"
18345
+ isInvalid.value && "outline-2 -outline-offset-2 outline-red-600",
18346
+ hasNoCountryResults.value && "outline-red-600!"
18348
18347
  ]);
18349
18348
  const arrowButtonClasses = vue.computed(() => [
18350
18349
  "absolute right-0 top-0 z-10 flex h-12 w-10 items-center justify-center border-0 bg-transparent p-0",
@@ -18541,13 +18540,13 @@ const _sfc_main$b = /* @__PURE__ */ vue.defineComponent({
18541
18540
  class: vue.normalizeClass(["relative w-32", props.class])
18542
18541
  }, [
18543
18542
  vue.createElementVNode("div", _hoisted_1$5, [
18544
- dialPreviewCountry.value ? (vue.openBlock(), vue.createElementBlock("div", {
18543
+ !dropdownOpen.value ? (vue.openBlock(), vue.createElementBlock("div", {
18545
18544
  key: 0,
18546
18545
  class: vue.normalizeClass(dialPreviewClasses.value),
18547
18546
  "aria-hidden": "true"
18548
18547
  }, [
18549
- vue.createElementVNode("span", _hoisted_2$4, vue.toDisplayString(vue.unref(countryCodeToFlag)(dialPreviewCountry.value.value)), 1),
18550
- vue.createTextVNode(" " + vue.toDisplayString(vue.unref(t)("common.plus")) + vue.toDisplayString(dialPreviewCountry.value.countryCode), 1)
18548
+ vue.createElementVNode("span", _hoisted_2$4, vue.toDisplayString(vue.unref(countryCodeToFlag)(dialPreviewCountry.value?.value ?? "")), 1),
18549
+ vue.createTextVNode(" " + vue.toDisplayString(vue.unref(t)("common.plus")) + vue.toDisplayString(dialPreviewCountry.value?.countryCode ?? ""), 1)
18551
18550
  ], 2)) : vue.createCommentVNode("", true),
18552
18551
  vue.createElementVNode("input", vue.mergeProps({
18553
18552
  ref_key: "inputRef",
@@ -18743,7 +18742,22 @@ const _sfc_main$a = /* @__PURE__ */ vue.defineComponent({
18743
18742
  disabled: { type: Boolean, default: false },
18744
18743
  dataTestid: { default: void 0 },
18745
18744
  selectClass: { default: void 0 },
18746
- inputClass: { default: void 0 }
18745
+ inputClass: { default: void 0 },
18746
+ onValid: {},
18747
+ onNoCountryResults: {},
18748
+ onBlur: {},
18749
+ "onUpdate:e164": {},
18750
+ "onUpdate:country": {},
18751
+ id: { default: void 0 },
18752
+ autocomplete: { default: "tel" },
18753
+ required: { type: Boolean, default: false },
18754
+ placeholder: { default: void 0 },
18755
+ maxlength: { default: void 0 },
18756
+ minlength: { default: void 0 },
18757
+ name: { default: void 0 },
18758
+ autofocus: { type: Boolean, default: false },
18759
+ readonly: { type: Boolean, default: false },
18760
+ pattern: { default: void 0 }
18747
18761
  }, {
18748
18762
  "modelValue": { default: "" },
18749
18763
  "modelModifiers": {},
@@ -18752,12 +18766,33 @@ const _sfc_main$a = /* @__PURE__ */ vue.defineComponent({
18752
18766
  }),
18753
18767
  emits: /* @__PURE__ */ vue.mergeModels(["update:country", "update:e164", "valid", "noCountryResults", "blur"], ["update:modelValue", "update:country"]),
18754
18768
  setup(__props, { emit: __emit }) {
18755
- const nationalNumber = vue.useModel(__props, "modelValue");
18769
+ const [nationalNumber, modelModifiers] = vue.useModel(__props, "modelValue");
18756
18770
  const country = vue.useModel(__props, "country");
18771
+ const attrs = vue.useAttrs();
18757
18772
  const props = __props;
18758
18773
  const emit = __emit;
18759
18774
  const { t, locale: fdsLocale } = useFdsI18n();
18760
18775
  const resolvedLocale = vue.computed(() => props.locale ?? fdsLocale.value);
18776
+ const inputAttrs = vue.computed(() => {
18777
+ const { class: _class, style, ...rest } = attrs;
18778
+ return {
18779
+ ...rest,
18780
+ ...style == null ? {} : { style }
18781
+ };
18782
+ });
18783
+ const forwardedInputProps = vue.computed(() => ({
18784
+ id: props.id,
18785
+ autocomplete: props.autocomplete,
18786
+ required: props.required,
18787
+ placeholder: props.placeholder,
18788
+ maxlength: props.maxlength,
18789
+ minlength: props.minlength,
18790
+ name: props.name,
18791
+ autofocus: props.autofocus,
18792
+ readonly: props.readonly,
18793
+ pattern: props.pattern,
18794
+ ...inputAttrs.value
18795
+ }));
18761
18796
  const countryItems = vue.computed(() => {
18762
18797
  const options = props.countries?.length ? props.countries : buildCountryOptions(resolvedLocale.value, props.defaultCountry);
18763
18798
  return sortCountryOptionsByName(
@@ -18768,6 +18803,10 @@ const _sfc_main$a = /* @__PURE__ */ vue.defineComponent({
18768
18803
  });
18769
18804
  const phoneValidationOptions = vue.computed(() => ({ numberType: props.numberType }));
18770
18805
  const committedValid = vue.ref(null);
18806
+ const resolvedLabel = vue.computed(() => props.label === void 0 ? t("FdsPhonenumber.phoneNumber") : props.label);
18807
+ const resolvedInvalidMessage = vue.computed(
18808
+ () => props.invalidMessage === void 0 ? t("FdsPhonenumber.invalidPhone") : props.invalidMessage
18809
+ );
18771
18810
  const displayValid = vue.computed(() => {
18772
18811
  if (props.valid === false) return false;
18773
18812
  if (props.valid === true) return true;
@@ -18776,7 +18815,7 @@ const _sfc_main$a = /* @__PURE__ */ vue.defineComponent({
18776
18815
  return props.valid;
18777
18816
  });
18778
18817
  const showInvalidMessage = vue.computed(
18779
- () => displayValid.value === false && !props.optional && props.invalidMessage && !props.disabled
18818
+ () => displayValid.value === false && !props.optional && !!resolvedInvalidMessage.value && !props.disabled
18780
18819
  );
18781
18820
  const noCountryResults = vue.ref(false);
18782
18821
  function runValidation() {
@@ -18806,10 +18845,10 @@ const _sfc_main$a = /* @__PURE__ */ vue.defineComponent({
18806
18845
  }
18807
18846
  return (_ctx, _cache) => {
18808
18847
  return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$4, [
18809
- __props.label ? (vue.openBlock(), vue.createElementBlock("label", {
18848
+ resolvedLabel.value ? (vue.openBlock(), vue.createElementBlock("label", {
18810
18849
  key: 0,
18811
18850
  class: vue.normalizeClass(["block font-bold text-gray-900 cursor-pointer", { "mb-0": __props.meta, "mb-1": !__props.meta }])
18812
- }, vue.toDisplayString(__props.label), 3)) : vue.createCommentVNode("", true),
18851
+ }, vue.toDisplayString(resolvedLabel.value), 3)) : vue.createCommentVNode("", true),
18813
18852
  __props.meta ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_2$3, vue.toDisplayString(__props.meta), 1)) : vue.createCommentVNode("", true),
18814
18853
  vue.createElementVNode("div", _hoisted_3$3, [
18815
18854
  vue.createVNode(_sfc_main$b, {
@@ -18823,21 +18862,21 @@ const _sfc_main$a = /* @__PURE__ */ vue.defineComponent({
18823
18862
  class: vue.normalizeClass(["mb-0! shrink-0", __props.selectClass ?? ""]),
18824
18863
  onNoCountryResults
18825
18864
  }, null, 8, ["modelValue", "items", "valid", "disabled", "ariaLabel", "data-testid", "class"]),
18826
- vue.createVNode(_sfc_main$u, {
18827
- modelValue: nationalNumber.value,
18828
- "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => nationalNumber.value = $event),
18865
+ vue.createVNode(_sfc_main$u, vue.mergeProps({
18866
+ modelValue: vue.unref(nationalNumber),
18867
+ "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => vue.isRef(nationalNumber) ? nationalNumber.value = $event : null),
18868
+ modelModifiers: vue.unref(modelModifiers),
18829
18869
  type: "tel",
18830
18870
  valid: displayValid.value,
18831
18871
  disabled: __props.disabled,
18832
18872
  optional: __props.optional,
18833
18873
  ariaLabel: vue.unref(t)("FdsPhonenumber.phoneNumber"),
18834
18874
  "data-testid": __props.dataTestid ? `${__props.dataTestid}-number` : void 0,
18835
- class: vue.normalizeClass(["mb-0! min-w-0 flex-1", __props.inputClass ?? ""]),
18836
- onBlur: handleBlur
18837
- }, null, 8, ["modelValue", "valid", "disabled", "optional", "ariaLabel", "data-testid", "class"])
18875
+ class: ["mb-0! min-w-0 flex-1", __props.inputClass ?? ""]
18876
+ }, forwardedInputProps.value, { onBlur: handleBlur }), null, 16, ["modelValue", "modelModifiers", "valid", "disabled", "optional", "ariaLabel", "data-testid", "class"])
18838
18877
  ]),
18839
18878
  noCountryResults.value ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_4$3, vue.toDisplayString(vue.unref(t)("FdsPhonenumber.noCountryResults")), 1)) : vue.createCommentVNode("", true),
18840
- showInvalidMessage.value ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_5$3, vue.toDisplayString(__props.invalidMessage), 1)) : vue.createCommentVNode("", true)
18879
+ showInvalidMessage.value ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_5$3, vue.toDisplayString(resolvedInvalidMessage.value), 1)) : vue.createCommentVNode("", true)
18841
18880
  ]);
18842
18881
  };
18843
18882
  }