fds-vue-core 7.2.3 → 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...",
@@ -18740,7 +18742,22 @@ const _sfc_main$a = /* @__PURE__ */ vue.defineComponent({
18740
18742
  disabled: { type: Boolean, default: false },
18741
18743
  dataTestid: { default: void 0 },
18742
18744
  selectClass: { default: void 0 },
18743
- 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 }
18744
18761
  }, {
18745
18762
  "modelValue": { default: "" },
18746
18763
  "modelModifiers": {},
@@ -18749,12 +18766,33 @@ const _sfc_main$a = /* @__PURE__ */ vue.defineComponent({
18749
18766
  }),
18750
18767
  emits: /* @__PURE__ */ vue.mergeModels(["update:country", "update:e164", "valid", "noCountryResults", "blur"], ["update:modelValue", "update:country"]),
18751
18768
  setup(__props, { emit: __emit }) {
18752
- const nationalNumber = vue.useModel(__props, "modelValue");
18769
+ const [nationalNumber, modelModifiers] = vue.useModel(__props, "modelValue");
18753
18770
  const country = vue.useModel(__props, "country");
18771
+ const attrs = vue.useAttrs();
18754
18772
  const props = __props;
18755
18773
  const emit = __emit;
18756
18774
  const { t, locale: fdsLocale } = useFdsI18n();
18757
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
+ }));
18758
18796
  const countryItems = vue.computed(() => {
18759
18797
  const options = props.countries?.length ? props.countries : buildCountryOptions(resolvedLocale.value, props.defaultCountry);
18760
18798
  return sortCountryOptionsByName(
@@ -18765,6 +18803,10 @@ const _sfc_main$a = /* @__PURE__ */ vue.defineComponent({
18765
18803
  });
18766
18804
  const phoneValidationOptions = vue.computed(() => ({ numberType: props.numberType }));
18767
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
+ );
18768
18810
  const displayValid = vue.computed(() => {
18769
18811
  if (props.valid === false) return false;
18770
18812
  if (props.valid === true) return true;
@@ -18773,7 +18815,7 @@ const _sfc_main$a = /* @__PURE__ */ vue.defineComponent({
18773
18815
  return props.valid;
18774
18816
  });
18775
18817
  const showInvalidMessage = vue.computed(
18776
- () => displayValid.value === false && !props.optional && props.invalidMessage && !props.disabled
18818
+ () => displayValid.value === false && !props.optional && !!resolvedInvalidMessage.value && !props.disabled
18777
18819
  );
18778
18820
  const noCountryResults = vue.ref(false);
18779
18821
  function runValidation() {
@@ -18803,10 +18845,10 @@ const _sfc_main$a = /* @__PURE__ */ vue.defineComponent({
18803
18845
  }
18804
18846
  return (_ctx, _cache) => {
18805
18847
  return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$4, [
18806
- __props.label ? (vue.openBlock(), vue.createElementBlock("label", {
18848
+ resolvedLabel.value ? (vue.openBlock(), vue.createElementBlock("label", {
18807
18849
  key: 0,
18808
18850
  class: vue.normalizeClass(["block font-bold text-gray-900 cursor-pointer", { "mb-0": __props.meta, "mb-1": !__props.meta }])
18809
- }, vue.toDisplayString(__props.label), 3)) : vue.createCommentVNode("", true),
18851
+ }, vue.toDisplayString(resolvedLabel.value), 3)) : vue.createCommentVNode("", true),
18810
18852
  __props.meta ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_2$3, vue.toDisplayString(__props.meta), 1)) : vue.createCommentVNode("", true),
18811
18853
  vue.createElementVNode("div", _hoisted_3$3, [
18812
18854
  vue.createVNode(_sfc_main$b, {
@@ -18820,21 +18862,21 @@ const _sfc_main$a = /* @__PURE__ */ vue.defineComponent({
18820
18862
  class: vue.normalizeClass(["mb-0! shrink-0", __props.selectClass ?? ""]),
18821
18863
  onNoCountryResults
18822
18864
  }, null, 8, ["modelValue", "items", "valid", "disabled", "ariaLabel", "data-testid", "class"]),
18823
- vue.createVNode(_sfc_main$u, {
18824
- modelValue: nationalNumber.value,
18825
- "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),
18826
18869
  type: "tel",
18827
18870
  valid: displayValid.value,
18828
18871
  disabled: __props.disabled,
18829
18872
  optional: __props.optional,
18830
18873
  ariaLabel: vue.unref(t)("FdsPhonenumber.phoneNumber"),
18831
18874
  "data-testid": __props.dataTestid ? `${__props.dataTestid}-number` : void 0,
18832
- class: vue.normalizeClass(["mb-0! min-w-0 flex-1", __props.inputClass ?? ""]),
18833
- onBlur: handleBlur
18834
- }, 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"])
18835
18877
  ]),
18836
18878
  noCountryResults.value ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_4$3, vue.toDisplayString(vue.unref(t)("FdsPhonenumber.noCountryResults")), 1)) : vue.createCommentVNode("", true),
18837
- 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)
18838
18880
  ]);
18839
18881
  };
18840
18882
  }