@antelopejs/dms 0.21.4-next.1005.ga44543e → 0.21.4-next.1007.gae3a8da
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/implementations/dms-base/phone-number.d.ts +1 -0
- package/dist/implementations/dms-base/phone-number.js +17 -0
- package/dist/implementations/dms-base/phone-number.js.map +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/frontend-vue/layers/dms-core/i18n/locales/core-en-GB.json +1 -0
- package/frontend-vue/layers/dms-core/i18n/locales/core-fr-FR.json +1 -0
- package/frontend-vue/layers/dms-layout/app/build/components/notification/NotificationPopover.vue +10 -2
- package/frontend-vue/layers/dms-layout/app/build/components/pages/settings/notification/NotificationInboxItem.vue +8 -2
- package/frontend-vue/layers/dms-layout/app/build/components/pages/settings/notification/notificationDisplay.ts +13 -0
- package/frontend-vue/layers/dms-ui/app/build/composables/confirm/fetchedConfirmDialog.ts +1 -1
- package/frontend-vue/layers/dms-ui/app/build/composables/data-types/defaultPrimitiveTypes.ts +11 -1
- package/frontend-vue/layers/dms-ui/app/build/utils/phoneNumber.ts +143 -0
- package/frontend-vue/layers/dms-ui/app/components/form/components/InputPhone.vue +165 -13
- package/frontend-vue/layers/dms-ui/app/entries/utils/phoneNumber.ts +1 -0
- package/frontend-vue/layers/dms-ui/i18n/locales/ui-en-GB.json +5 -0
- package/frontend-vue/layers/dms-ui/i18n/locales/ui-fr-FR.json +5 -0
- package/frontend-vue/package.json +1 -0
- package/package.json +4 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function ToE164(text: string, defaultCountry?: string): string | undefined;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ToE164 = ToE164;
|
|
4
|
+
const min_1 = require("libphonenumber-js/min");
|
|
5
|
+
const PHONE_CHARACTERS = /^[+\d\s().\-/]+$/;
|
|
6
|
+
const INTERNATIONAL_CALL_PREFIX = /^00/;
|
|
7
|
+
function ToE164(text, defaultCountry) {
|
|
8
|
+
const trimmed = text.trim();
|
|
9
|
+
if (!PHONE_CHARACTERS.test(trimmed))
|
|
10
|
+
return undefined;
|
|
11
|
+
const country = defaultCountry?.trim().toUpperCase();
|
|
12
|
+
const parsed = (0, min_1.parsePhoneNumberFromString)(trimmed.replace(INTERNATIONAL_CALL_PREFIX, "+"), country && (0, min_1.isSupportedCountry)(country)
|
|
13
|
+
? { defaultCountry: country }
|
|
14
|
+
: undefined);
|
|
15
|
+
return parsed?.isPossible() ? parsed.number : undefined;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=phone-number.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"phone-number.js","sourceRoot":"","sources":["../../../src/implementations/dms-base/phone-number.ts"],"names":[],"mappings":";;;AAAA,+CAG+B;AAE/B,MAAM,gBAAgB,GAAG,kBAAkB,CAAC;AAE5C,MAAM,yBAAyB,GAAG,KAAK,CAAC;AAExC,gBACE,IAAY,EACZ,cAAuB;IAEvB,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;IAC5B,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,OAAO,CAAC;QAAE,OAAO,SAAS,CAAC;IACtD,MAAM,OAAO,GAAG,cAAc,EAAE,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IACrD,MAAM,MAAM,GAAG,IAAA,gCAA0B,EACvC,OAAO,CAAC,OAAO,CAAC,yBAAyB,EAAE,GAAG,CAAC,EAC/C,OAAO,IAAI,IAAA,wBAAkB,EAAC,OAAO,CAAC;QACpC,CAAC,CAAC,EAAE,cAAc,EAAE,OAAO,EAAE;QAC7B,CAAC,CAAC,SAAS,CACd,CAAC;IACF,OAAO,MAAM,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC;AAC1D,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -130,6 +130,7 @@ async function implementInterfaces() {
|
|
|
130
130
|
void (0, interface_core_1.ImplementInterface)(await Promise.resolve().then(() => __importStar(require("@antelopejs/interface-dms/guards"))), await Promise.resolve().then(() => __importStar(require("./implementations/dms/guards"))));
|
|
131
131
|
void (0, interface_core_1.ImplementInterface)(await Promise.resolve().then(() => __importStar(require("@antelopejs/interface-dms/base/table-view"))), await Promise.resolve().then(() => __importStar(require("./implementations/dms-base/table-view"))));
|
|
132
132
|
void (0, interface_core_1.ImplementInterface)(await Promise.resolve().then(() => __importStar(require("@antelopejs/interface-dms/base/table-view/internal/distinct-values"))), await Promise.resolve().then(() => __importStar(require("./implementations/dms-base/distinct-values"))));
|
|
133
|
+
void (0, interface_core_1.ImplementInterface)(await Promise.resolve().then(() => __importStar(require("@antelopejs/interface-dms/base/data-types/internal/phone-number"))), await Promise.resolve().then(() => __importStar(require("./implementations/dms-base/phone-number"))));
|
|
133
134
|
void (0, interface_core_1.ImplementInterface)(await Promise.resolve().then(() => __importStar(require("@antelopejs/interface-dms/base/export-jobs"))), await Promise.resolve().then(() => __importStar(require("./implementations/dms-base/export-jobs"))));
|
|
134
135
|
void (0, interface_core_1.ImplementInterface)(await Promise.resolve().then(() => __importStar(require("@antelopejs/interface-dms/base/tenant-export-archive"))), await Promise.resolve().then(() => __importStar(require("./implementations/dms-base/tenant-export-archive"))));
|
|
135
136
|
void (0, interface_core_1.ImplementInterface)(await Promise.resolve().then(() => __importStar(require("@antelopejs/interface-dms/client-base-url"))), await Promise.resolve().then(() => __importStar(require("./implementations/dms/client-base-url"))));
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+DAAgE;AAChE,gEAA6D;AAC7D,gEAA4D;AAC5D,gE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V,gBAAM,CAAC,cAAc,CAAC,UAAU,CAAC,gBAAgB,CAAC,CAAC;IACnD,gBAAgB,CAAC,KAAK,EAAE,CAAC;IACzB,MAAM,yBAAyB,CAAC;IAChC,MAAM,iBAAiB,CAAC;IACxB,IAAA,oBAAY,EAAC,YAAI,CAAC,oBAAoB,CAAC,CAAC;IACxC,IAAA,4CAA0B,GAAE,CAAC;IAC7B,MAAM,IAAA,6BAAuB,GAAE,CAAC;IAChC,MAAM,IAAA,sCAAyB,GAAE,CAAC;IAClC,IAAI,CAAC;QACH,MAAM,SAAS,GAAG,MAAM,OAAO,CAAC,UAAU,CACxC,SAAS,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAC9C,CAAC;QACF,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;YACjC,IAAI,QAAQ,CAAC,MAAM,KAAK,UAAU,EAAE,CAAC;gBACnC,iBAAO,CAAC,KAAK,CAAC,4BAA4B,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;YAC/D,CAAC;QACH,CAAC;IACH,CAAC;YAAS,CAAC;QACT,SAAS,GAAG,EAAE,CAAC;QACf,MAAM,IAAA,uBAAY,GAAE,CAAC;QACrB,2BAA2B,EAAE,CAAC;QAC9B,IAAA,gCAAqB,GAAE,CAAC;QACxB,IAAA,yBAAgB,GAAE,CAAC;IACrB,CAAC;AACH,CAAC"}
|
|
@@ -411,6 +411,7 @@
|
|
|
411
411
|
"required": "This field is required.",
|
|
412
412
|
"invalid": "This value isn’t valid.",
|
|
413
413
|
"invalid_email": "Enter a valid email address.",
|
|
414
|
+
"invalid_phone": "Enter a valid phone number, with its country.",
|
|
414
415
|
"too_long": "This value is too long.",
|
|
415
416
|
"too_short": "This value is too short.",
|
|
416
417
|
"too_small": "This value is too small.",
|
|
@@ -411,6 +411,7 @@
|
|
|
411
411
|
"required": "Ce champ est obligatoire.",
|
|
412
412
|
"invalid": "Cette valeur n’est pas valide.",
|
|
413
413
|
"invalid_email": "Saisissez une adresse e-mail valide.",
|
|
414
|
+
"invalid_phone": "Saisissez un numéro de téléphone valide, avec son pays.",
|
|
414
415
|
"too_long": "Cette valeur est trop longue.",
|
|
415
416
|
"too_short": "Cette valeur est trop courte.",
|
|
416
417
|
"too_small": "Cette valeur est trop petite.",
|
package/frontend-vue/layers/dms-layout/app/build/components/notification/NotificationPopover.vue
CHANGED
|
@@ -8,7 +8,10 @@ import {
|
|
|
8
8
|
settledRenderedBellCounts,
|
|
9
9
|
type UserNotification,
|
|
10
10
|
} from "../../../composables/notification/useNotifications";
|
|
11
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
formatNotificationFullTime,
|
|
13
|
+
resolveNotificationTone,
|
|
14
|
+
} from "../pages/settings/notification/notificationDisplay";
|
|
12
15
|
import { DMS_TONE_SOLID, iconWellToneOf } from "#dms-ui/app/entries/utils/tone";
|
|
13
16
|
import DmsRowSkeleton from "#dms-ui/app/entries/components/skeleton/RowSkeleton";
|
|
14
17
|
|
|
@@ -227,7 +230,12 @@ const goToNotifications = () => {
|
|
|
227
230
|
}}
|
|
228
231
|
</div>
|
|
229
232
|
<div class="text-muted mt-1 text-[10px]">
|
|
230
|
-
|
|
233
|
+
<time
|
|
234
|
+
:datetime="notification.createdAt"
|
|
235
|
+
:title="formatNotificationFullTime(notification.createdAt, locale)"
|
|
236
|
+
>
|
|
237
|
+
{{ formatRelativeTime(notification.createdAt, t, locale) }}
|
|
238
|
+
</time>
|
|
231
239
|
</div>
|
|
232
240
|
</template>
|
|
233
241
|
|
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
MODULE_TAG_CLASS,
|
|
5
5
|
type NotificationSourceTag,
|
|
6
6
|
SOURCE_TAG_CLASS,
|
|
7
|
+
formatNotificationFullTime,
|
|
7
8
|
resolveNotificationTone,
|
|
8
9
|
} from "./notificationDisplay";
|
|
9
10
|
|
|
@@ -19,7 +20,7 @@ const emit = defineEmits<{
|
|
|
19
20
|
toggleRead: [];
|
|
20
21
|
delete: [];
|
|
21
22
|
}>();
|
|
22
|
-
const { t } = useI18n();
|
|
23
|
+
const { t, locale } = useI18n();
|
|
23
24
|
const { processI18n } = useTranslation();
|
|
24
25
|
|
|
25
26
|
const isUnread = computed(() => !props.notification.isRead);
|
|
@@ -27,6 +28,9 @@ const iconWellTone = computed(() => {
|
|
|
27
28
|
const tone = resolveNotificationTone(props.notification);
|
|
28
29
|
return tone === "neutral" ? "muted" : tone;
|
|
29
30
|
});
|
|
31
|
+
const fullTime = computed(() =>
|
|
32
|
+
formatNotificationFullTime(props.notification.createdAt, locale.value),
|
|
33
|
+
);
|
|
30
34
|
const readToggleLabel = computed(() =>
|
|
31
35
|
isUnread.value
|
|
32
36
|
? t("page.settings.notifications.mark_read")
|
|
@@ -71,7 +75,9 @@ const actionLabelUi = {
|
|
|
71
75
|
}}
|
|
72
76
|
</template>
|
|
73
77
|
<template #meta>
|
|
74
|
-
<time :datetime="props.notification.createdAt">{{
|
|
78
|
+
<time :datetime="props.notification.createdAt" :title="fullTime">{{
|
|
79
|
+
props.time
|
|
80
|
+
}}</time>
|
|
75
81
|
<span
|
|
76
82
|
v-if="props.source"
|
|
77
83
|
:class="[SOURCE_TAG_CLASS, props.source.isModule && MODULE_TAG_CLASS]"
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { formatDate } from "#dms-core/app/utils/formatter";
|
|
1
2
|
import { MONO_TAG_CLASS } from "#dms-ui/app/entries/utils/monoChip";
|
|
2
3
|
import {
|
|
3
4
|
formatShortDate,
|
|
@@ -82,6 +83,18 @@ export const formatNotificationTime = (
|
|
|
82
83
|
return formatShortDate(date, now, locale);
|
|
83
84
|
};
|
|
84
85
|
|
|
86
|
+
const FULL_TIME_FORMAT: Intl.DateTimeFormatOptions = {
|
|
87
|
+
dateStyle: "medium",
|
|
88
|
+
timeStyle: "short",
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
/** The exact date and time, in the user's language, for a time's hover title. */
|
|
92
|
+
export const formatNotificationFullTime = (
|
|
93
|
+
createdAt: string,
|
|
94
|
+
locale: string,
|
|
95
|
+
): string | undefined =>
|
|
96
|
+
formatDate(createdAt, locale, FULL_TIME_FORMAT) ?? undefined;
|
|
97
|
+
|
|
85
98
|
/**
|
|
86
99
|
* The matrix lays out from its own width (`@container/matrix` on the table),
|
|
87
100
|
* not the viewport's: the settings column at 1024px is narrower than a phone
|
|
@@ -44,7 +44,7 @@ const REQUEST_FREE_INPUTS: ReadonlyMap<string, ReadonlySet<string>> = new Map(
|
|
|
44
44
|
"dms-input-email": ["placeholder"],
|
|
45
45
|
"dms-input-number": NUMBER_KEYS,
|
|
46
46
|
"dms-input-percentage": NUMBER_KEYS,
|
|
47
|
-
"dms-input-phone": ["placeholder", "requiredPrefix"],
|
|
47
|
+
"dms-input-phone": ["placeholder", "requiredPrefix", "defaultCountry"],
|
|
48
48
|
"dms-input-password": [
|
|
49
49
|
"placeholder",
|
|
50
50
|
"minLength",
|
package/frontend-vue/layers/dms-ui/app/build/composables/data-types/defaultPrimitiveTypes.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type {
|
|
|
2
2
|
DataType,
|
|
3
3
|
DataTypeFormatter,
|
|
4
4
|
} from "#dms-core/app/composables/data-types/useDataType";
|
|
5
|
-
import { isObject } from "#dms-core/app/utils/type-check";
|
|
5
|
+
import { isObject, isString } from "#dms-core/app/utils/type-check";
|
|
6
6
|
import UIcon from "@nuxt/ui/runtime/vue/components/Icon.vue";
|
|
7
7
|
import { childOf, readRowTone, type Row } from "./cellHelpers";
|
|
8
8
|
import {
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
} from "../table/utils/filterEditorValue";
|
|
12
12
|
import { formatDuration } from "#dms-core/app/utils/formatter";
|
|
13
13
|
import { withNumberSuffix } from "./numberSuffix";
|
|
14
|
+
import { formatPhone } from "../../utils/phoneNumber";
|
|
14
15
|
import { DMS_TONE_TEXT } from "../../utils/tone";
|
|
15
16
|
import { getAppTranslation } from "../../../../../dms-core/app/composables/translation/useTranslation";
|
|
16
17
|
|
|
@@ -111,6 +112,15 @@ export const registerPrimitiveTypes = (
|
|
|
111
112
|
id: "string",
|
|
112
113
|
formatter: { default: renderText },
|
|
113
114
|
});
|
|
115
|
+
registerDataType({
|
|
116
|
+
id: "phone",
|
|
117
|
+
formatter: {
|
|
118
|
+
default: (value) => {
|
|
119
|
+
if (value === "") return null;
|
|
120
|
+
return isString(value) ? formatPhone(value) : value;
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
});
|
|
114
124
|
registerDataType({
|
|
115
125
|
id: "price",
|
|
116
126
|
formatter: { default: withNumberSuffix(formatPrice) },
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AsYouType,
|
|
3
|
+
type CountryCode,
|
|
4
|
+
getCountries,
|
|
5
|
+
getCountryCallingCode,
|
|
6
|
+
isSupportedCountry,
|
|
7
|
+
parsePhoneNumberFromString,
|
|
8
|
+
} from "libphonenumber-js/min";
|
|
9
|
+
|
|
10
|
+
const PHONE_CHARACTERS = /^[+\d\s().\-/]+$/;
|
|
11
|
+
|
|
12
|
+
const INTERNATIONAL_PREFIX = /^(\+|00)/;
|
|
13
|
+
|
|
14
|
+
const E164 = /^\+[1-9]\d{1,14}$/;
|
|
15
|
+
|
|
16
|
+
/** A country the phone input offers: its ISO code and calling code. */
|
|
17
|
+
export interface PhoneCountry {
|
|
18
|
+
code: CountryCode;
|
|
19
|
+
/** Without its "+": "32". */
|
|
20
|
+
callingCode: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** What the user typed into a phone input, read in its selected country. */
|
|
24
|
+
export interface TypedPhone {
|
|
25
|
+
/** The text formatted as it is typed ("+32 494 66", "0494 66 94"). */
|
|
26
|
+
text: string;
|
|
27
|
+
/** The country a "+" or "00" prefix names, else the selected one. */
|
|
28
|
+
country?: CountryCode;
|
|
29
|
+
/** The value to store: E.164 when it is a possible number, else the text. */
|
|
30
|
+
value: string;
|
|
31
|
+
/** Whether `value` is a possible number, in E.164. */
|
|
32
|
+
isNumber: boolean;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** The supported country an ISO 3166-1 alpha-2 code ("be", "BE") names. */
|
|
36
|
+
export function phoneCountry(
|
|
37
|
+
code: string | null | undefined,
|
|
38
|
+
): CountryCode | undefined {
|
|
39
|
+
const upper = code?.trim().toUpperCase();
|
|
40
|
+
return upper && isSupportedCountry(upper) ? upper : undefined;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function phoneCountries(): PhoneCountry[] {
|
|
44
|
+
return getCountries().map((code) => ({
|
|
45
|
+
code,
|
|
46
|
+
callingCode: getCountryCallingCode(code),
|
|
47
|
+
}));
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function isInternational(text: string): boolean {
|
|
51
|
+
return INTERNATIONAL_PREFIX.test(text.trim());
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function withPlus(text: string): string {
|
|
55
|
+
return text.trim().replace(INTERNATIONAL_PREFIX, "+");
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function parse(text: string, country: CountryCode | undefined) {
|
|
59
|
+
if (!PHONE_CHARACTERS.test(text.trim())) return undefined;
|
|
60
|
+
return parsePhoneNumberFromString(
|
|
61
|
+
withPlus(text),
|
|
62
|
+
country ? { defaultCountry: country } : undefined,
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* The E.164 form ("+32494669443") of a phone number typed in any common way:
|
|
68
|
+
* a number without a "+" or "00" prefix reads in `country`. `undefined` when
|
|
69
|
+
* the text is not a possible number of its country.
|
|
70
|
+
*/
|
|
71
|
+
export function toE164(
|
|
72
|
+
text: string,
|
|
73
|
+
country?: CountryCode,
|
|
74
|
+
): string | undefined {
|
|
75
|
+
const parsed = parse(text, country);
|
|
76
|
+
return parsed?.isPossible() ? parsed.number : undefined;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* How a stored phone number reads: an E.164 value in international format
|
|
81
|
+
* ("+32 494 66 94 43"), anything else as stored.
|
|
82
|
+
*/
|
|
83
|
+
export function formatPhone(value: string): string {
|
|
84
|
+
if (!E164.test(value)) return value;
|
|
85
|
+
return parsePhoneNumberFromString(value)?.formatInternational() ?? value;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** The country a stored E.164 value belongs to. */
|
|
89
|
+
export function storedPhoneCountry(value: string): CountryCode | undefined {
|
|
90
|
+
if (!E164.test(value)) return undefined;
|
|
91
|
+
return parsePhoneNumberFromString(value)?.country;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export function readTypedPhone(
|
|
95
|
+
text: string,
|
|
96
|
+
country: CountryCode | undefined,
|
|
97
|
+
): TypedPhone {
|
|
98
|
+
const value = toE164(text, country);
|
|
99
|
+
const isNumber = value !== undefined;
|
|
100
|
+
if (!PHONE_CHARACTERS.test(text.trim())) {
|
|
101
|
+
return { text, country, value: text, isNumber };
|
|
102
|
+
}
|
|
103
|
+
if (!isInternational(text)) {
|
|
104
|
+
const formatter = new AsYouType(country);
|
|
105
|
+
return {
|
|
106
|
+
text: formatter.input(text),
|
|
107
|
+
country,
|
|
108
|
+
value: value ?? text,
|
|
109
|
+
isNumber,
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
const formatter = new AsYouType();
|
|
113
|
+
const formatted = formatter.input(withPlus(text));
|
|
114
|
+
const callingCode = formatter.getCallingCode();
|
|
115
|
+
const keepsCountry =
|
|
116
|
+
country !== undefined &&
|
|
117
|
+
callingCode !== undefined &&
|
|
118
|
+
getCountryCallingCode(country) === callingCode;
|
|
119
|
+
return {
|
|
120
|
+
text: formatted,
|
|
121
|
+
country: formatter.getCountry() ?? (keepsCountry ? country : undefined),
|
|
122
|
+
value: value ?? text,
|
|
123
|
+
isNumber,
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* The number typed, moved to another country: an international number keeps
|
|
129
|
+
* its national part under the new calling code. A national number, or text
|
|
130
|
+
* that is no number, stays as typed, to be read in the new country.
|
|
131
|
+
*/
|
|
132
|
+
export function moveToCountry(
|
|
133
|
+
text: string,
|
|
134
|
+
from: CountryCode | undefined,
|
|
135
|
+
to: CountryCode,
|
|
136
|
+
): string {
|
|
137
|
+
if (!isInternational(text)) return text;
|
|
138
|
+
const parsed = parse(text, from);
|
|
139
|
+
if (!parsed) return text;
|
|
140
|
+
return new AsYouType().input(
|
|
141
|
+
`+${getCountryCallingCode(to)}${parsed.nationalNumber}`,
|
|
142
|
+
);
|
|
143
|
+
}
|
|
@@ -1,18 +1,170 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
2
|
+
import { useFormField } from "@nuxt/ui/composables/useFormField";
|
|
3
|
+
import type { CountryCode } from "libphonenumber-js/min";
|
|
4
|
+
import { useControlError } from "../../../composables/form/useControlError";
|
|
5
|
+
import {
|
|
6
|
+
formatPhone,
|
|
7
|
+
moveToCountry,
|
|
8
|
+
phoneCountries,
|
|
9
|
+
phoneCountry,
|
|
10
|
+
readTypedPhone,
|
|
11
|
+
storedPhoneCountry,
|
|
12
|
+
} from "../../../build/utils/phoneNumber";
|
|
13
|
+
|
|
14
|
+
const ITEM_HEIGHT = 32;
|
|
15
|
+
|
|
16
|
+
interface InputPhoneProps {
|
|
17
|
+
id?: string;
|
|
18
|
+
placeholder?: string;
|
|
19
|
+
disabled?: boolean;
|
|
20
|
+
/** Refuses a number typed without its country. */
|
|
21
|
+
requiredPrefix?: boolean;
|
|
22
|
+
/** ISO 3166-1 alpha-2 code the country selector starts on ("BE"). */
|
|
23
|
+
defaultCountry?: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const props = defineProps<InputPhoneProps>();
|
|
27
|
+
const model = defineModel<string | null | undefined>();
|
|
28
|
+
const { t, te, locale } = useI18n();
|
|
29
|
+
const { report } = useControlError();
|
|
30
|
+
const {
|
|
31
|
+
id,
|
|
32
|
+
size,
|
|
33
|
+
color,
|
|
34
|
+
highlight,
|
|
35
|
+
disabled,
|
|
36
|
+
ariaAttrs,
|
|
37
|
+
emitFormBlur,
|
|
38
|
+
emitFormInput,
|
|
39
|
+
} = useFormField(props);
|
|
40
|
+
|
|
41
|
+
const isStrict = computed(
|
|
42
|
+
() => !!props.requiredPrefix || !!props.defaultCountry,
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
const text = ref("");
|
|
46
|
+
const country = ref<CountryCode>();
|
|
47
|
+
let emitted: string | null | undefined;
|
|
48
|
+
|
|
49
|
+
function show(value: string | null | undefined): void {
|
|
50
|
+
emitted = value;
|
|
51
|
+
const stored = value ?? "";
|
|
52
|
+
text.value = formatPhone(stored);
|
|
53
|
+
country.value =
|
|
54
|
+
storedPhoneCountry(stored) ??
|
|
55
|
+
(stored ? country.value : undefined) ??
|
|
56
|
+
phoneCountry(props.defaultCountry);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
show(model.value);
|
|
60
|
+
|
|
61
|
+
watch(model, (value) => {
|
|
62
|
+
if (value !== emitted) show(value);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
function store(value: string): void {
|
|
66
|
+
emitted = value;
|
|
67
|
+
model.value = value;
|
|
68
|
+
emitFormInput();
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function read(next: string, { isDeleting = false } = {}): void {
|
|
72
|
+
const typed = readTypedPhone(next, country.value);
|
|
73
|
+
text.value = isDeleting ? next : typed.text;
|
|
74
|
+
country.value = typed.country;
|
|
75
|
+
store(typed.value);
|
|
76
|
+
if (typed.isNumber || !next.trim()) report(undefined);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function onInput(next: string | number | null | undefined): void {
|
|
80
|
+
const value = String(next ?? "");
|
|
81
|
+
read(value, { isDeleting: value.length < text.value.length });
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function onBlur(): void {
|
|
85
|
+
const typed = readTypedPhone(text.value, country.value);
|
|
86
|
+
if (typed.isNumber) text.value = formatPhone(typed.value);
|
|
87
|
+
report(
|
|
88
|
+
isStrict.value && text.value.trim() && !typed.isNumber
|
|
89
|
+
? t("dms.field_errors.invalid_phone")
|
|
90
|
+
: undefined,
|
|
91
|
+
);
|
|
92
|
+
emitFormBlur();
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function onCountry(next: CountryCode | undefined): void {
|
|
96
|
+
if (!next) return;
|
|
97
|
+
const moved = moveToCountry(text.value, country.value, next);
|
|
98
|
+
country.value = next;
|
|
99
|
+
read(moved);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const countryItems = computed(() =>
|
|
103
|
+
phoneCountries()
|
|
104
|
+
.filter((entry) => te(`country.${entry.code}`))
|
|
105
|
+
.map((entry) => ({
|
|
106
|
+
value: entry.code,
|
|
107
|
+
label: t(`country.${entry.code}`),
|
|
108
|
+
code: `+${entry.callingCode}`,
|
|
109
|
+
}))
|
|
110
|
+
.sort((a, b) => a.label.localeCompare(b.label, locale.value)),
|
|
111
|
+
);
|
|
112
|
+
|
|
113
|
+
const selected = computed(() =>
|
|
114
|
+
countryItems.value.find((item) => item.value === country.value),
|
|
115
|
+
);
|
|
14
116
|
</script>
|
|
15
117
|
|
|
16
118
|
<template>
|
|
17
|
-
<
|
|
119
|
+
<div class="flex w-full">
|
|
120
|
+
<USelectMenu
|
|
121
|
+
:model-value="country"
|
|
122
|
+
:items="countryItems"
|
|
123
|
+
value-key="value"
|
|
124
|
+
label-key="label"
|
|
125
|
+
:filter-fields="['label', 'value', 'code']"
|
|
126
|
+
:search-input="{ placeholder: t('dms.form.phone.country_search') }"
|
|
127
|
+
:virtualize="{ estimateSize: ITEM_HEIGHT }"
|
|
128
|
+
:size="size"
|
|
129
|
+
:color="color"
|
|
130
|
+
:highlight="highlight"
|
|
131
|
+
:disabled="disabled"
|
|
132
|
+
:aria-label="t('dms.form.phone.country')"
|
|
133
|
+
trailing-icon="i-ph-caret-down"
|
|
134
|
+
class="shrink-0 rounded-e-none"
|
|
135
|
+
:ui="{ content: 'min-w-72' }"
|
|
136
|
+
data-phone-country
|
|
137
|
+
@update:model-value="onCountry"
|
|
138
|
+
>
|
|
139
|
+
<span v-if="selected" class="tabular-nums">
|
|
140
|
+
{{ selected.value }} {{ selected.code }}
|
|
141
|
+
</span>
|
|
142
|
+
<UIcon v-else name="i-ph-globe" class="size-4" />
|
|
143
|
+
<template #empty="{ searchTerm }">
|
|
144
|
+
{{ t("dms.form.phone.country_none", { search: searchTerm }) }}
|
|
145
|
+
</template>
|
|
146
|
+
<template #item-trailing="{ item }">
|
|
147
|
+
<span class="text-dimmed text-[11px] tabular-nums">
|
|
148
|
+
{{ item.code }}
|
|
149
|
+
</span>
|
|
150
|
+
</template>
|
|
151
|
+
</USelectMenu>
|
|
152
|
+
<UInput
|
|
153
|
+
v-bind="ariaAttrs"
|
|
154
|
+
:id="id"
|
|
155
|
+
:model-value="text"
|
|
156
|
+
type="tel"
|
|
157
|
+
inputmode="tel"
|
|
158
|
+
autocomplete="tel"
|
|
159
|
+
:placeholder="props.placeholder"
|
|
160
|
+
:size="size"
|
|
161
|
+
:color="color"
|
|
162
|
+
:highlight="highlight"
|
|
163
|
+
:disabled="disabled"
|
|
164
|
+
class="min-w-0 flex-1"
|
|
165
|
+
:ui="{ base: 'rounded-s-none' }"
|
|
166
|
+
@update:model-value="onInput"
|
|
167
|
+
@blur="onBlur"
|
|
168
|
+
/>
|
|
169
|
+
</div>
|
|
18
170
|
</template>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "../../build/utils/phoneNumber";
|
|
@@ -444,6 +444,11 @@
|
|
|
444
444
|
"invalid_email": "{value} isn’t a valid email address. | {value} aren’t valid email addresses.",
|
|
445
445
|
"remove": "Remove {value}"
|
|
446
446
|
},
|
|
447
|
+
"phone": {
|
|
448
|
+
"country": "Country",
|
|
449
|
+
"country_search": "Search a country or a code",
|
|
450
|
+
"country_none": "No country matches “{search}”."
|
|
451
|
+
},
|
|
447
452
|
"code": {
|
|
448
453
|
"completion_footer": "↵ insert · Esc close",
|
|
449
454
|
"complete": "complete",
|
|
@@ -444,6 +444,11 @@
|
|
|
444
444
|
"invalid_email": "{value} n’est pas une adresse e-mail valide. | {value} ne sont pas des adresses e-mail valides.",
|
|
445
445
|
"remove": "Retirer {value}"
|
|
446
446
|
},
|
|
447
|
+
"phone": {
|
|
448
|
+
"country": "Pays",
|
|
449
|
+
"country_search": "Rechercher un pays ou un indicatif",
|
|
450
|
+
"country_none": "Aucun pays ne correspond à « {search} »."
|
|
451
|
+
},
|
|
447
452
|
"code": {
|
|
448
453
|
"completion_footer": "↵ insérer · Échap fermer",
|
|
449
454
|
"complete": "compléter",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antelopejs/dms",
|
|
3
|
-
"version": "0.21.4-next.
|
|
3
|
+
"version": "0.21.4-next.1007.gae3a8da",
|
|
4
4
|
"description": "AntelopeJS DMS. Plug in your PostgreSQL, MySQL, MariaDB, MongoDB or RethinkDB database and your coding agent builds a back office and analytics dashboard as typed TypeScript. Real-time updates on the data the DMS manages.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"antelopejs",
|
|
@@ -89,7 +89,7 @@
|
|
|
89
89
|
"@antelopejs/interface-data-api": ">=0.8.0 <0.9.0",
|
|
90
90
|
"@antelopejs/interface-database": ">=0.4.0 <0.5.0",
|
|
91
91
|
"@antelopejs/interface-database-decorators": ">=0.5.2 <0.6.0",
|
|
92
|
-
"@antelopejs/interface-dms": "0.14.7-next.
|
|
92
|
+
"@antelopejs/interface-dms": "0.14.7-next.1006.g63d3e11",
|
|
93
93
|
"@antelopejs/interface-dms-builder": "0.6.2-next.987.gb437fd0",
|
|
94
94
|
"@antelopejs/interface-email": ">=0.2.1 <0.3.0",
|
|
95
95
|
"@antelopejs/interface-file-storage": ">=0.1.4 <0.2.0",
|
|
@@ -102,6 +102,7 @@
|
|
|
102
102
|
"dompurify": "^3.4.17",
|
|
103
103
|
"jsdom": "^29.1.1",
|
|
104
104
|
"jsonwebtoken": "^9.0.3",
|
|
105
|
+
"libphonenumber-js": "^1.13.16",
|
|
105
106
|
"mmdb-lib": "^3.0.3",
|
|
106
107
|
"node-cron": "^4.2.1",
|
|
107
108
|
"parse5": "^7.3.0",
|
|
@@ -212,7 +213,7 @@
|
|
|
212
213
|
"optional": true
|
|
213
214
|
}
|
|
214
215
|
},
|
|
215
|
-
"gitHead": "
|
|
216
|
+
"gitHead": "ae3a8daf5284e30df23c1b58d30e0bdb2952a4e7",
|
|
216
217
|
"scripts": {
|
|
217
218
|
"build": "pnpm --filter @antelopejs/interface-dms --filter @antelopejs/interface-dms-builder build && rimraf dist && antelopejs-tsc && tsc-alias && tsc -p e2e/tsconfig.types.json",
|
|
218
219
|
"dev": "ajs project run --inspect -w -p playground",
|