fds-vue-core 7.1.9 β†’ 7.2.2

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.
Files changed (30) hide show
  1. package/components.d.ts +2 -0
  2. package/dist/components/Form/FdsPhonenumber/FdsPhonenumber.stories.d.ts +10 -0
  3. package/dist/components/Form/FdsPhonenumber/FdsPhonenumber.vue.d.ts +36 -0
  4. package/dist/components/Form/FdsPhonenumber/FdsPhonenumberCountryPicker.vue.d.ts +30 -0
  5. package/dist/components/Form/FdsPhonenumber/countries.d.ts +14 -0
  6. package/dist/components/Form/FdsPhonenumber/types.d.ts +36 -0
  7. package/dist/components/Form/FdsPhonenumber/validatePhone.d.ts +16 -0
  8. package/dist/composables/useIsPid.d.ts +11 -0
  9. package/dist/fds-vue-core.cjs.js +3396 -613
  10. package/dist/fds-vue-core.cjs.js.map +1 -1
  11. package/dist/fds-vue-core.css +1 -1
  12. package/dist/fds-vue-core.es.js +3397 -614
  13. package/dist/fds-vue-core.es.js.map +1 -1
  14. package/dist/index.d.ts +8 -3
  15. package/dist/tsconfig.build.tsbuildinfo +1 -1
  16. package/package.json +19 -18
  17. package/src/components/FdsSearchSelect/FdsSearchSelect.vue +18 -31
  18. package/src/components/FdsSearchSelectPro/FdsSearchSelectPro.vue +14 -30
  19. package/src/components/FdsSearchSelectPro/useSearchSelectProItems.ts +10 -4
  20. package/src/components/FdsWizard/FdsWizard.vue +1 -1
  21. package/src/components/Form/FdsPhonenumber/FdsPhonenumber.stories.ts +156 -0
  22. package/src/components/Form/FdsPhonenumber/FdsPhonenumber.vue +138 -0
  23. package/src/components/Form/FdsPhonenumber/FdsPhonenumberCountryPicker.vue +426 -0
  24. package/src/components/Form/FdsPhonenumber/countries.ts +111 -0
  25. package/src/components/Form/FdsPhonenumber/types.ts +39 -0
  26. package/src/components/Form/FdsPhonenumber/validatePhone.ts +107 -0
  27. package/src/composables/useIsPid.ts +49 -11
  28. package/src/index.ts +36 -1
  29. package/src/lang/en.json +4 -0
  30. package/src/lang/sv.json +4 -0
package/components.d.ts CHANGED
@@ -31,6 +31,7 @@ import type { FdsCheckboxProps } from './src/components/Form/FdsCheckbox/types'
31
31
  import type { FdsInputProps } from './src/components/Form/FdsInput/types'
32
32
  import type { FdsRadioProps } from './src/components/Form/FdsRadio/types'
33
33
  import type { FdsSelectProps } from './src/components/Form/FdsSelect/types'
34
+ import type { FdsPhonenumberEmits, FdsPhonenumberProps } from './src/components/Form/FdsPhonenumber/types'
34
35
  import type { FdsTextareaEmits, FdsTextareaProps } from './src/components/Form/FdsTextarea/types'
35
36
  import type { FdsTableProps } from './src/components/Table/FdsTable/types'
36
37
  import type { FdsTableHeadProps } from './src/components/Table/FdsTableHead/types'
@@ -62,6 +63,7 @@ declare module 'vue' {
62
63
  FdsInput: DefineComponent<FdsInputProps>
63
64
  FdsCheckbox: DefineComponent<FdsCheckboxProps>
64
65
  FdsTextarea: DefineComponent<FdsTextareaProps, {}, {}, {}, {}, {}, {}, FdsTextareaEmits>
66
+ FdsPhonenumber: DefineComponent<FdsPhonenumberProps, {}, {}, {}, {}, {}, {}, FdsPhonenumberEmits>
65
67
  FdsSelect: DefineComponent<FdsSelectProps>
66
68
  FdsTable: DefineComponent<FdsTableProps>
67
69
  FdsTableHead: DefineComponent<FdsTableHeadProps>
@@ -0,0 +1,10 @@
1
+ import { Meta, StoryObj } from '@storybook/vue3';
2
+ import { default as FdsPhonenumber } from './FdsPhonenumber.vue';
3
+ declare const meta: Meta<typeof FdsPhonenumber>;
4
+ export default meta;
5
+ type Story = StoryObj<typeof meta>;
6
+ export declare const Default: Story;
7
+ export declare const InvalidNumber: Story;
8
+ export declare const AllowAnyNumberType: Story;
9
+ export declare const EnglishLocale: Story;
10
+ export declare const ValidSwedishNumber: Story;
@@ -0,0 +1,36 @@
1
+ import { FdsPhonenumberProps } from './types';
2
+ type __VLS_Props = FdsPhonenumberProps;
3
+ type __VLS_PublicProps = {
4
+ modelValue?: string;
5
+ 'country'?: string;
6
+ } & __VLS_Props;
7
+ declare const _default: import('vue').DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
8
+ blur: (ev: FocusEvent) => any;
9
+ valid: (value: boolean | null) => any;
10
+ "update:modelValue": (value: string) => any;
11
+ noCountryResults: (value: boolean) => any;
12
+ "update:country": (...args: unknown[]) => any;
13
+ "update:e164": (phoneNumber: string) => any;
14
+ }, string, import('vue').PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
15
+ onBlur?: ((ev: FocusEvent) => any) | undefined;
16
+ onValid?: ((value: boolean | null) => any) | undefined;
17
+ "onUpdate:modelValue"?: ((value: string) => any) | undefined;
18
+ onNoCountryResults?: ((value: boolean) => any) | undefined;
19
+ "onUpdate:country"?: ((...args: unknown[]) => any) | undefined;
20
+ "onUpdate:e164"?: ((phoneNumber: string) => any) | undefined;
21
+ }>, {
22
+ disabled: boolean;
23
+ dataTestid: string;
24
+ label: string;
25
+ meta: string;
26
+ valid: boolean | null;
27
+ optional: boolean;
28
+ invalidMessage: string;
29
+ inputClass: string;
30
+ locale: string;
31
+ defaultCountry: string;
32
+ countries: import('./countries').CountryPhoneOption[];
33
+ numberType: import('./types').FdsPhonenumberNumberType;
34
+ selectClass: string;
35
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
36
+ export default _default;
@@ -0,0 +1,30 @@
1
+ import { HTMLAttributes } from 'vue';
2
+ import { CountryPhoneOption } from './countries';
3
+ type __VLS_Props = {
4
+ items: CountryPhoneOption[];
5
+ valid?: boolean | null;
6
+ disabled?: boolean;
7
+ ariaLabel?: string;
8
+ dataTestid?: string;
9
+ class?: HTMLAttributes['class'];
10
+ };
11
+ type __VLS_PublicProps = {
12
+ modelValue: string;
13
+ } & __VLS_Props;
14
+ declare const _default: import('vue').DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
15
+ "update:modelValue": (value: string) => any;
16
+ noCountryResults: (value: boolean) => any;
17
+ }, string, import('vue').PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
18
+ "onUpdate:modelValue"?: ((value: string) => any) | undefined;
19
+ onNoCountryResults?: ((value: boolean) => any) | undefined;
20
+ }>, {
21
+ disabled: boolean;
22
+ dataTestid: string;
23
+ class: string | false | Record<string, any> | import('vue').ClassValue[] | null;
24
+ valid: boolean | null;
25
+ ariaLabel: string;
26
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
27
+ rootRef: HTMLDivElement;
28
+ inputRef: HTMLInputElement;
29
+ }, HTMLDivElement>;
30
+ export default _default;
@@ -0,0 +1,14 @@
1
+ export interface CountryPhoneOption {
2
+ value: string;
3
+ label: string;
4
+ countryCode: string;
5
+ countryName: string;
6
+ }
7
+ export declare const PRIORITIZED_COUNTRIES: readonly ["SE", "NO", "DK", "FI"];
8
+ export declare function isPrioritizedCountry(iso2: string): boolean;
9
+ export declare function sortCountryOptionsByName(options: CountryPhoneOption[], locale?: string, _preferredCountry?: string): CountryPhoneOption[];
10
+ /** Country options for phone fields; SE/NO/DK/FI first, then alphabetical by name. */
11
+ export declare function buildCountryOptions(locale?: string, preferredCountry?: string): CountryPhoneOption[];
12
+ /** ISO 3166-1 alpha-2 to regional indicator flag emoji, e.g. `SE` β†’ πŸ‡ΈπŸ‡ͺ */
13
+ export declare function countryCodeToFlag(iso2: string): string;
14
+ export declare function filterCountryOptions(options: CountryPhoneOption[], query: string): CountryPhoneOption[];
@@ -0,0 +1,36 @@
1
+ import { CountryPhoneOption } from './countries';
2
+ /**
3
+ * `mobile` – mobile numbers only (Google libphonenumber metadata).
4
+ * `any` – mobile and fixed-line numbers.
5
+ */
6
+ export type FdsPhonenumberNumberType = 'mobile' | 'any';
7
+ export interface FdsPhonenumberProps {
8
+ label?: string;
9
+ meta?: string;
10
+ optional?: boolean;
11
+ valid?: boolean | null;
12
+ invalidMessage?: string;
13
+ /** National number (without country calling code). */
14
+ modelValue?: string;
15
+ /** ISO 3166-1 alpha-2 country code, e.g. `SE`. */
16
+ country?: string;
17
+ /** ISO2 code shown first in the country select. */
18
+ defaultCountry?: string;
19
+ /** Override built-in country list (default from libphonenumber-js). */
20
+ countries?: CountryPhoneOption[];
21
+ /** BCP 47 locale for country names in the list, e.g. `sv-SE` or `en`. Falls back to FDS i18n locale. */
22
+ locale?: string;
23
+ /** Which number types are accepted when validating with libphonenumber-js. */
24
+ numberType?: FdsPhonenumberNumberType;
25
+ disabled?: boolean;
26
+ dataTestid?: string;
27
+ selectClass?: string;
28
+ inputClass?: string;
29
+ }
30
+ export interface FdsPhonenumberEmits {
31
+ 'update:country': [country: string];
32
+ 'update:e164': [phoneNumber: string];
33
+ valid: [value: boolean | null];
34
+ noCountryResults: [value: boolean];
35
+ blur: [ev: FocusEvent];
36
+ }
@@ -0,0 +1,16 @@
1
+ import { FdsPhonenumberNumberType } from './types';
2
+ interface ValidatePhoneOptions {
3
+ numberType?: FdsPhonenumberNumberType;
4
+ }
5
+ /** Result shape kept stable for consumers (same fields as previous `phone` package integration). */
6
+ export interface PhoneValidationResult {
7
+ isValid: boolean;
8
+ phoneNumber: string | null;
9
+ countryIso2: string | null;
10
+ countryIso3: string | null;
11
+ countryCode: string | null;
12
+ }
13
+ export declare function validatePhoneNumber(nationalNumber: string, countryIso2: string, options?: ValidatePhoneOptions): PhoneValidationResult;
14
+ /** `null` when empty, otherwise whether the number is valid for the selected country. */
15
+ export declare function getPhoneValidationState(nationalNumber: string, countryIso2: string, options?: ValidatePhoneOptions): boolean | null;
16
+ export {};
@@ -1,10 +1,21 @@
1
1
  import { Ref } from 'vue';
2
+ /** Strip separators; keep digits and letters (suffix may contain letters). */
3
+ export declare function normalizePidSearchValue(value: string): string;
2
4
  /**
3
5
  * Check if a string looks like a personnummer (Swedish personal identity number)
4
6
  * @param value - String value to check
5
7
  * @returns Boolean indicating if the value looks like a personnummer
6
8
  */
7
9
  export declare function isPidString(value: string): boolean;
10
+ /** Format as yyyymmdd-nnnn; last four may be alphanumeric (e.g. coordination numbers). */
11
+ export declare function formatPidWithDash(value: string): string;
12
+ export declare const PID_MASK = "00000000-XXXX";
13
+ export declare const PID_MASK_OPTIONS: {
14
+ readonly lazy: true;
15
+ readonly definitions: {
16
+ readonly X: RegExp;
17
+ };
18
+ };
8
19
  /**
9
20
  * Composable for detecting if a string looks like a personnummer (Swedish personal identity number)
10
21
  * @param value - Reactive string value to check (Ref<string>)