fds-vue-core 7.2.3 → 7.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Form/FdsPhonenumber/FdsPhonenumber.vue.d.ts +12 -2
- package/dist/components/Form/FdsPhonenumber/types.d.ts +12 -2
- package/dist/fds-vue-core.cjs.js +57 -15
- package/dist/fds-vue-core.cjs.js.map +1 -1
- package/dist/fds-vue-core.es.js +58 -16
- package/dist/fds-vue-core.es.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/components/Form/FdsPhonenumber/FdsPhonenumber.vue +49 -6
- package/src/components/Form/FdsPhonenumber/FdsPhonenumberCountryPicker.vue +1 -2
- package/src/components/Form/FdsPhonenumber/types.ts +25 -2
- package/src/lang/en.json +1 -0
- package/src/lang/sv.json +1 -0
|
@@ -7,25 +7,35 @@ type __VLS_PublicProps = {
|
|
|
7
7
|
declare const _default: import('vue').DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
8
8
|
blur: (ev: FocusEvent) => any;
|
|
9
9
|
valid: (value: boolean | null) => any;
|
|
10
|
-
"update:modelValue": (
|
|
10
|
+
"update:modelValue": (...args: unknown[]) => any;
|
|
11
11
|
noCountryResults: (value: boolean) => any;
|
|
12
12
|
"update:country": (...args: unknown[]) => any;
|
|
13
13
|
"update:e164": (phoneNumber: string) => any;
|
|
14
14
|
}, string, import('vue').PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
15
15
|
onBlur?: ((ev: FocusEvent) => any) | undefined;
|
|
16
16
|
onValid?: ((value: boolean | null) => any) | undefined;
|
|
17
|
-
"onUpdate:modelValue"?: ((
|
|
17
|
+
"onUpdate:modelValue"?: ((...args: unknown[]) => any) | undefined;
|
|
18
18
|
onNoCountryResults?: ((value: boolean) => any) | undefined;
|
|
19
19
|
"onUpdate:country"?: ((...args: unknown[]) => any) | undefined;
|
|
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
|
-
|
|
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,11 +28,19 @@ 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:modelValue'?: ((value: string) => void) | Array<(value: string) => void>;
|
|
35
|
+
'onUpdate:e164'?: ((value: string) => void) | Array<(value: string) => void>;
|
|
36
|
+
'onUpdate:country'?: ((value: string) => void) | Array<(value: string) => void>;
|
|
29
37
|
}
|
|
30
38
|
export interface FdsPhonenumberEmits {
|
|
39
|
+
'update:modelValue': [value: string];
|
|
31
40
|
'update:country': [country: string];
|
|
32
41
|
'update:e164': [phoneNumber: string];
|
|
33
42
|
valid: [value: boolean | null];
|
|
34
43
|
noCountryResults: [value: boolean];
|
|
35
44
|
blur: [ev: FocusEvent];
|
|
36
45
|
}
|
|
46
|
+
export {};
|
package/dist/fds-vue-core.cjs.js
CHANGED
|
@@ -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...",
|
|
@@ -18351,8 +18353,7 @@ const _sfc_main$b = /* @__PURE__ */ vue.defineComponent({
|
|
|
18351
18353
|
"pointer-events-none transition-transform duration-200 ease-in-out",
|
|
18352
18354
|
{
|
|
18353
18355
|
"fill-gray-500": props.disabled,
|
|
18354
|
-
"fill-
|
|
18355
|
-
"fill-blue-500": !props.disabled && !isInvalid.value,
|
|
18356
|
+
"fill-blue-500": !props.disabled && !isInvalid.value || isInvalid.value,
|
|
18356
18357
|
"rotate-180": dropdownOpen.value && !props.disabled
|
|
18357
18358
|
}
|
|
18358
18359
|
]);
|
|
@@ -18740,21 +18741,58 @@ const _sfc_main$a = /* @__PURE__ */ vue.defineComponent({
|
|
|
18740
18741
|
disabled: { type: Boolean, default: false },
|
|
18741
18742
|
dataTestid: { default: void 0 },
|
|
18742
18743
|
selectClass: { default: void 0 },
|
|
18743
|
-
inputClass: { default: void 0 }
|
|
18744
|
+
inputClass: { default: void 0 },
|
|
18745
|
+
onValid: {},
|
|
18746
|
+
onNoCountryResults: {},
|
|
18747
|
+
onBlur: {},
|
|
18748
|
+
"onUpdate:modelValue": {},
|
|
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": {},
|
|
18747
18764
|
"country": { default: "SE" },
|
|
18748
18765
|
"countryModifiers": {}
|
|
18749
18766
|
}),
|
|
18750
|
-
emits: /* @__PURE__ */ vue.mergeModels(["update:country", "update:e164", "valid", "noCountryResults", "blur"], ["update:modelValue", "update:country"]),
|
|
18767
|
+
emits: /* @__PURE__ */ vue.mergeModels(["update:modelValue", "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 &&
|
|
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
|
-
|
|
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(
|
|
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
|
|
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:
|
|
18833
|
-
|
|
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(
|
|
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
|
}
|