@antelopejs/dms 0.21.4-next.998.gc2b0d73 → 0.22.0

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 (90) hide show
  1. package/CHANGELOG.md +114 -0
  2. package/README.md +2 -2
  3. package/dist/e2e/mongo.d.mts +5 -5
  4. package/dist/e2e/processes.d.mts +18 -4
  5. package/dist/implementations/dms/page/preview-models.d.ts +0 -2
  6. package/dist/implementations/dms-base/phone-number.d.ts +1 -0
  7. package/dist/implementations/dms-base/phone-number.js +17 -0
  8. package/dist/implementations/dms-base/phone-number.js.map +1 -0
  9. package/dist/implementations/dms-notifications/index.d.ts +5 -1
  10. package/dist/implementations/dms-notifications/index.js +39 -11
  11. package/dist/implementations/dms-notifications/index.js.map +1 -1
  12. package/dist/index.js +2 -0
  13. package/dist/index.js.map +1 -1
  14. package/dist/mcp/page-verify/accounts.d.ts +2 -2
  15. package/dist/mcp/page-verify/accounts.js +21 -13
  16. package/dist/mcp/page-verify/accounts.js.map +1 -1
  17. package/dist/pages/settings/users/invite-resend.d.ts +4 -0
  18. package/dist/pages/settings/users/invite-resend.js +27 -19
  19. package/dist/pages/settings/users/invite-resend.js.map +1 -1
  20. package/dist/pages/settings/users/invites.d.ts +2 -4
  21. package/dist/pages/settings/users/invites.js +4 -17
  22. package/dist/pages/settings/users/invites.js.map +1 -1
  23. package/dist/pages/settings/users/notifications.d.ts +4 -1
  24. package/dist/pages/settings/users/notifications.js +12 -4
  25. package/dist/pages/settings/users/notifications.js.map +1 -1
  26. package/dist/store/internal/frontend/dev-reload.d.ts +7 -4
  27. package/dist/store/internal/frontend/dev-reload.js +16 -17
  28. package/dist/store/internal/frontend/dev-reload.js.map +1 -1
  29. package/dist/utils/notification-email.d.ts +13 -0
  30. package/dist/utils/notification-email.js +37 -0
  31. package/dist/utils/notification-email.js.map +1 -0
  32. package/dist/utils/notification-registry/index.d.ts +1 -0
  33. package/dist/utils/notification-registry/index.js +1 -0
  34. package/dist/utils/notification-registry/index.js.map +1 -1
  35. package/e2e/database.mjs +9 -3
  36. package/e2e/mongo.mjs +5 -5
  37. package/e2e/processes.mjs +32 -9
  38. package/e2e/run-state.mjs +40 -2
  39. package/frontend-vue/eslint-globals.generated.mjs +17 -17
  40. package/frontend-vue/layers/dms-core/app/composables/page/useSiteLayout.ts +20 -14
  41. package/frontend-vue/layers/dms-core/app/types/page.ts +1 -0
  42. package/frontend-vue/layers/dms-core/app/types/row-action.ts +2 -0
  43. package/frontend-vue/layers/dms-core/i18n/locales/core-en-GB.json +1 -0
  44. package/frontend-vue/layers/dms-core/i18n/locales/core-fr-FR.json +1 -0
  45. package/frontend-vue/layers/dms-layout/app/build/components/layout/DashboardSidebar.vue +30 -29
  46. package/frontend-vue/layers/dms-layout/app/build/components/layout/PageHeaderActionBar.vue +4 -8
  47. package/frontend-vue/layers/dms-layout/app/build/components/notification/NotificationPopover.vue +10 -2
  48. package/frontend-vue/layers/dms-layout/app/build/components/pages/settings/notification/NotificationInboxItem.vue +8 -2
  49. package/frontend-vue/layers/dms-layout/app/build/components/pages/settings/notification/NotificationMatrixSubject.vue +32 -1
  50. package/frontend-vue/layers/dms-layout/app/build/components/pages/settings/notification/NotificationPreferencesForm.vue +11 -1
  51. package/frontend-vue/layers/dms-layout/app/build/components/pages/settings/notification/notificationDisplay.ts +13 -0
  52. package/frontend-vue/layers/dms-layout/app/build/composables/notification/useNotificationCatalog.ts +16 -0
  53. package/frontend-vue/layers/dms-layout/app/build/composables/notification/useNotificationPreferences.ts +38 -3
  54. package/frontend-vue/layers/dms-layout/app/components/layout/DashboardSearch.vue +10 -0
  55. package/frontend-vue/layers/dms-layout/i18n/locales/layout-en-GB.json +4 -1
  56. package/frontend-vue/layers/dms-layout/i18n/locales/layout-fr-FR.json +4 -1
  57. package/frontend-vue/layers/dms-ui/app/build/components/button/DisabledReason.vue +27 -0
  58. package/frontend-vue/layers/dms-ui/app/build/components/containers/TargetComponentTree.vue +2 -0
  59. package/frontend-vue/layers/dms-ui/app/build/components/period/PeriodRangeCalendar.vue +1 -0
  60. package/frontend-vue/layers/dms-ui/app/build/components/stat/StatCell.vue +2 -11
  61. package/frontend-vue/layers/dms-ui/app/build/components/table/TableActions.vue +17 -17
  62. package/frontend-vue/layers/dms-ui/app/build/components/table/TablePagination.vue +1 -0
  63. package/frontend-vue/layers/dms-ui/app/build/composables/actions/actionTargetHandlers.ts +1 -1
  64. package/frontend-vue/layers/dms-ui/app/build/composables/actions/actionTargetRows.ts +5 -1
  65. package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/useMockupViewerShortcuts.ts +19 -9
  66. package/frontend-vue/layers/dms-ui/app/build/composables/confirm/fetchedConfirmDialog.ts +1 -1
  67. package/frontend-vue/layers/dms-ui/app/build/composables/data-types/defaultPrimitiveTypes.ts +12 -3
  68. package/frontend-vue/layers/dms-ui/app/build/composables/global/shortcuts.ts +14 -0
  69. package/frontend-vue/layers/dms-ui/app/build/composables/page/pageUrlValues.ts +1 -1
  70. package/frontend-vue/layers/dms-ui/app/build/composables/table/tableColumnActionDescriptors.ts +47 -31
  71. package/frontend-vue/layers/dms-ui/app/build/composables/table/tableColumnActionRendering.ts +19 -3
  72. package/frontend-vue/layers/dms-ui/app/build/composables/table/tableColumnActionSizing.ts +2 -1
  73. package/frontend-vue/layers/dms-ui/app/build/composables/table/tableColumnTypes.ts +2 -0
  74. package/frontend-vue/layers/dms-ui/app/build/types/tree.ts +8 -3
  75. package/frontend-vue/layers/dms-ui/app/build/utils/phoneNumber.ts +143 -0
  76. package/frontend-vue/layers/dms-ui/app/components/form/components/DatePicker.vue +1 -0
  77. package/frontend-vue/layers/dms-ui/app/components/form/components/InputCalendar.vue +1 -0
  78. package/frontend-vue/layers/dms-ui/app/components/form/components/InputPhone.vue +165 -13
  79. package/frontend-vue/layers/dms-ui/app/components/form/components/InputRelation.vue +3 -2
  80. package/frontend-vue/layers/dms-ui/app/components/form/components/InputRepeater.vue +32 -1
  81. package/frontend-vue/layers/dms-ui/app/components/kpi/KpiCard.vue +1 -6
  82. package/frontend-vue/layers/dms-ui/app/entries/components/button/DisabledReason.ts +1 -0
  83. package/frontend-vue/layers/dms-ui/app/entries/components/stat/StatCell.ts +2 -0
  84. package/frontend-vue/layers/dms-ui/app/entries/composables/global/shortcuts.ts +1 -0
  85. package/frontend-vue/layers/dms-ui/app/entries/utils/phoneNumber.ts +1 -0
  86. package/frontend-vue/layers/dms-ui/app/types/row-action.ts +2 -0
  87. package/frontend-vue/layers/dms-ui/i18n/locales/ui-en-GB.json +10 -1
  88. package/frontend-vue/layers/dms-ui/i18n/locales/ui-fr-FR.json +10 -1
  89. package/frontend-vue/package.json +1 -0
  90. package/package.json +6 -5
@@ -1,5 +1,6 @@
1
1
  import type { Data } from "../../components/table/TableRoot.vue";
2
2
  import Button from "@nuxt/ui/components/Button.vue";
3
+ import DisabledReason from "../../components/button/DisabledReason.vue";
3
4
  import DropdownMenu, {
4
5
  type DropdownMenuItem,
5
6
  } from "@nuxt/ui/components/DropdownMenu.vue";
@@ -15,11 +16,22 @@ import {
15
16
  menuLabel,
16
17
  buildRowActionDescriptors,
17
18
  isDestructive,
19
+ isOffered,
18
20
  descriptorToMenuItem,
19
21
  } from "./tableColumnActionDescriptors";
20
22
 
23
+ const withDisabledReason = (
24
+ descriptor: RowActionDescriptor,
25
+ button: ReturnType<typeof h>,
26
+ ) =>
27
+ h(
28
+ DisabledReason,
29
+ { reason: descriptor.disabledReason },
30
+ { default: () => button },
31
+ );
32
+
21
33
  const renderActionButton = (descriptor: RowActionDescriptor, rowId: string) => {
22
- return h(Button, {
34
+ const button = h(Button, {
23
35
  id: `row-action-${rowId}-${descriptor.icon || descriptor.label}`,
24
36
  "aria-label": descriptor.label,
25
37
  title: descriptor.showLabel ? undefined : descriptor.label,
@@ -28,11 +40,13 @@ const renderActionButton = (descriptor: RowActionDescriptor, rowId: string) => {
28
40
  color: descriptor.color || Color.neutral,
29
41
  variant: descriptor.variant ?? ButtonVariant.ghost,
30
42
  size: Size.tiny,
43
+ disabled: descriptor.disabled,
31
44
  onClick: (event: Event) => {
32
45
  event.stopPropagation();
33
46
  descriptor.onSelect();
34
47
  },
35
48
  });
49
+ return withDisabledReason(descriptor, button);
36
50
  };
37
51
 
38
52
  const renderActionsDropdown = <T extends Data>(
@@ -67,18 +81,20 @@ const renderRestoreButton = (
67
81
  descriptor: RowActionDescriptor,
68
82
  rowId: string,
69
83
  ) => {
70
- return h(Button, {
84
+ const button = h(Button, {
71
85
  id: `row-action-${rowId}-restore`,
72
86
  label: descriptor.label,
73
87
  icon: descriptor.icon,
74
88
  color: Color.neutral,
75
89
  variant: ButtonVariant.ghost,
76
90
  size: Size.tiny,
91
+ disabled: descriptor.disabled,
77
92
  onClick: (event: Event) => {
78
93
  event.stopPropagation();
79
94
  descriptor.onSelect();
80
95
  },
81
96
  });
97
+ return withDisabledReason(descriptor, button);
82
98
  };
83
99
 
84
100
  export const renderActionsCell = <T extends Data>(
@@ -88,7 +104,7 @@ export const renderActionsCell = <T extends Data>(
88
104
  const { config } = context;
89
105
 
90
106
  const descriptors = buildRowActionDescriptors(context, row.original).filter(
91
- (d) => !d.disabled && !isOffMode(context, d),
107
+ (d) => isOffered(d) && !isOffMode(context, d),
92
108
  );
93
109
  const restoreDescriptor = isShowingArchived(context)
94
110
  ? descriptors.find((d) => d.key === "restore")
@@ -9,6 +9,7 @@ import type {
9
9
  import {
10
10
  isCustomActionInline,
11
11
  isOffMode,
12
+ isOffered,
12
13
  buildRowActionDescriptors,
13
14
  BUILTIN_ROW_ACTION_KEYS,
14
15
  } from "./tableColumnActionDescriptors";
@@ -81,7 +82,7 @@ const shownActionsWidth = <T extends Data>(
81
82
  ): number => {
82
83
  return actionsCellWidth(
83
84
  buildRowActionDescriptors(context, row).filter(
84
- (d) => !d.disabled && !isOffMode(context, d),
85
+ (d) => isOffered(d) && !isOffMode(context, d),
85
86
  ),
86
87
  );
87
88
  };
@@ -21,6 +21,8 @@ export interface RowActionDescriptor {
21
21
  icon: string;
22
22
  onSelect: () => void;
23
23
  disabled: boolean;
24
+ /** Why a disabled action stays on the row, filled from it. */
25
+ disabledReason?: string;
24
26
  color?: CustomRowAction["color"];
25
27
  visible: boolean;
26
28
  /** Inline button variant (custom actions); ghost otherwise. */
@@ -8,14 +8,16 @@ export interface TreeItem extends LinkProps {
8
8
  children?: TreeItem[];
9
9
  }
10
10
 
11
+ /** The menu groups of the first-level entries declared with `placement`, unset for the scrolling menu. */
11
12
  export function convertSiteLayoutTreeToTreeItems(
12
13
  siteLayoutTree: SiteLayoutTree | null | undefined,
14
+ placement?: SiteLayoutTree["placement"],
13
15
  ): NavigationMenuItem[][] {
14
16
  if (!siteLayoutTree) {
15
17
  return [];
16
18
  }
17
19
 
18
- return convertToTreeItems(siteLayoutTree);
20
+ return convertToTreeItems(siteLayoutTree, placement);
19
21
  }
20
22
 
21
23
  const EXCLUDED_TOP_LEVEL_IDS = new Set(["settings", "modules"]);
@@ -70,12 +72,15 @@ function buildLabelGroup(
70
72
  ];
71
73
  }
72
74
 
73
- function convertToTreeItems(node: SiteLayoutTree): NavigationMenuItem[][] {
75
+ function convertToTreeItems(
76
+ node: SiteLayoutTree,
77
+ placement: SiteLayoutTree["placement"],
78
+ ): NavigationMenuItem[][] {
74
79
  const groups: NavigationMenuItem[][] = [];
75
80
 
76
81
  for (const nodeId of node.childrenOrders) {
77
82
  const item = node.children[nodeId]!;
78
- if (isExcludedFromRoot(item)) {
83
+ if (isExcludedFromRoot(item) || item.placement !== placement) {
79
84
  continue;
80
85
  }
81
86
 
@@ -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
+ }
@@ -329,6 +329,7 @@ const label = computed(() => {
329
329
  <template #content>
330
330
  <UCalendar
331
331
  v-bind="forwarded"
332
+ :calendar-label="t('dms.form.select_date')"
332
333
  :min-value="minValue"
333
334
  :max-value="maxValue"
334
335
  :week-starts-on="props.weekStartsOn ?? weekStartsOn"
@@ -200,6 +200,7 @@ const forwarded = useForwardPropsEmits(convertedProps, wrappedEmits);
200
200
  <template>
201
201
  <UCalendar
202
202
  v-bind="{ ...forwarded, ...ariaAttrs }"
203
+ :calendar-label="$t('dms.form.select_date')"
203
204
  :week-starts-on="props.weekStartsOn ?? weekStartsOn"
204
205
  :min-value="minValue"
205
206
  :max-value="maxValue"
@@ -1,18 +1,170 @@
1
1
  <script setup lang="ts">
2
- import type {
3
- InputProps,
4
- InputEmits,
5
- InputSlots,
6
- } from "@nuxt/ui/components/Input.vue";
7
- import { useForwardPropsEmits } from "reka-ui";
8
-
9
- const props = defineProps<InputProps>();
10
- const emits = defineEmits<InputEmits>();
11
- defineSlots<InputSlots>();
12
-
13
- const forwarded = useForwardPropsEmits(props, emits);
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
- <UInput v-bind="forwarded" type="tel" leading leading-icon="i-ph-phone" />
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>
@@ -168,8 +168,9 @@ const canAdd = computed(
168
168
  () =>
169
169
  !!props.addForm &&
170
170
  !!props.addForm.options?.submitUrl &&
171
- (!props.addPermissionIds?.length ||
172
- props.addPermissionIds.some((id) => hasPermission(id))),
171
+ (props.addPermissionIds?.length
172
+ ? props.addPermissionIds.some((id) => hasPermission(id))
173
+ : hasPermission("*")),
173
174
  );
174
175
 
175
176
  interface RelationResponse {
@@ -11,6 +11,9 @@ import { fieldErrorPattern } from "../../../build/composables/form/formEntryCont
11
11
  import { resolveDmsComponent } from "../../../composables/resolveDmsComponent";
12
12
  import DmsRepeaterTable from "./RepeaterTable.vue";
13
13
  import type { DataTypeFormatter } from "#dms-core/app/composables/data-types/useDataType";
14
+ import type { FormFieldValue } from "../../../composables/form/types/value";
15
+ import { FORM_FIELD_SAVED_KEY } from "../../../composables/form/types/field-saved";
16
+ import { cloneFormValue } from "../../../build/composables/form/useFormModel";
14
17
 
15
18
  /** A field of the rows: one column. */
16
19
  interface RepeaterColumn {
@@ -19,6 +22,8 @@ interface RepeaterColumn {
19
22
  type?: string;
20
23
  component: ComponentInfo;
21
24
  required?: boolean;
25
+ /** The cell's value in a row added or created to reach `min`. */
26
+ defaultValue?: FormFieldValue;
22
27
  }
23
28
 
24
29
  type RepeaterRow = NonNullable<Parameters<DataTypeFormatter>[3]>;
@@ -44,6 +49,7 @@ const { name: fieldName, emitFormChange } = useFormField();
44
49
  const formBus = inject(formBusInjectionKey, null);
45
50
  const formErrors = inject(formErrorsInjectionKey, null);
46
51
  const formInputs = inject(formInputsInjectionKey, null);
52
+ const markFieldSaved = inject(FORM_FIELD_SAVED_KEY, null);
47
53
 
48
54
  const rows = computed<RepeaterRow[]>(() =>
49
55
  Array.isArray(model.value) ? model.value : [],
@@ -123,11 +129,36 @@ function setCell(
123
129
  if (fieldName.value) formBus?.emit({ type: "change", name: rowName(index) });
124
130
  }
125
131
 
132
+ /** A row as the user adds it: a copy of each column's `defaultValue`. */
133
+ function newRow(): RepeaterRow {
134
+ const row: RepeaterRow = {};
135
+ for (const column of props.columns)
136
+ if (column.defaultValue !== undefined)
137
+ row[column.id] = cloneFormValue(column.defaultValue);
138
+ return row;
139
+ }
140
+
126
141
  function addRow(): void {
127
142
  rowKeys.value.push(nextKey++);
128
- emitRows([...rows.value, {}], false);
143
+ emitRows([...rows.value, newRow()], false);
129
144
  }
130
145
 
146
+ /**
147
+ * Below `min`, the field gets the missing rows as the value it opens with:
148
+ * the form does not read them as a change to save.
149
+ */
150
+ watch(
151
+ () => rows.value.length,
152
+ (length) => {
153
+ const missing = (props.min ?? 0) - length;
154
+ if (props.disabled || missing <= 0) return;
155
+ const next = [...rows.value, ...Array.from({ length: missing }, newRow)];
156
+ emitRows(next, false);
157
+ if (props.id) markFieldSaved?.(props.id, next);
158
+ },
159
+ { immediate: true },
160
+ );
161
+
131
162
  function removeRow(index: number): void {
132
163
  rowKeys.value.splice(index, 1);
133
164
  emitRows(rows.value.filter((_, at) => at !== index));
@@ -272,12 +272,7 @@ const isStat = computed(() => props.variant === "stat");
272
272
  class="text-dimmed size-[15px] shrink-0"
273
273
  :aria-hidden="true"
274
274
  />
275
- <DmsEyebrowLabel
276
- tone="muted"
277
- truncate
278
- class="max-sm:whitespace-normal"
279
- :label="processI18n(title)"
280
- />
275
+ <DmsEyebrowLabel tone="muted" :label="processI18n(title)" />
281
276
  </div>
282
277
  <!-- The value's placeholder takes its 33px line. -->
283
278
  <USkeleton
@@ -0,0 +1 @@
1
+ export { default } from "../../../build/components/button/DisabledReason.vue";
@@ -0,0 +1,2 @@
1
+ export { default } from "../../../build/components/stat/StatCell.vue";
2
+ export * from "../../../build/components/stat/StatCell.vue";
@@ -0,0 +1 @@
1
+ export * from "../../../build/composables/global/shortcuts";
@@ -0,0 +1 @@
1
+ export * from "../../build/utils/phoneNumber";
@@ -22,6 +22,8 @@ export interface CustomRowAction {
22
22
  /** Asked before the target runs: a fixed dialog, or `{ from }`. */
23
23
  confirm?: ActionConfirm;
24
24
  rule?: RowActionRule;
25
+ /** Shown on a row `rule` keeps the action off, which then stays disabled (`$`: i18n key). */
26
+ disabledReason?: string;
25
27
  /** Inline button instead of a menu entry (the backend serializes `isVisible`). */
26
28
  isVisible?: boolean;
27
29
  /**
@@ -215,7 +215,7 @@
215
215
  },
216
216
  "pagination": {
217
217
  "label": "Navigation",
218
- "count": "{count} items",
218
+ "count": "{count} item | {count} items",
219
219
  "size": "Displayed per {pageSize}",
220
220
  "current_page": "Page {currentPage} of {totalPages}",
221
221
  "first_page": "First page",
@@ -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",
@@ -521,6 +526,10 @@
521
526
  "description": "Focus the page's own search",
522
527
  "condition": "Settings pages with a search of their own, such as this one"
523
528
  },
529
+ "question_mark": {
530
+ "description": "Open the keyboard shortcuts page",
531
+ "condition": "Outside a text field"
532
+ },
524
533
  "escape": {
525
534
  "description": "Close dialogs, menus and the palette"
526
535
  }
@@ -215,7 +215,7 @@
215
215
  },
216
216
  "pagination": {
217
217
  "label": "Navigation",
218
- "count": "{count} éléments",
218
+ "count": "{count} élément | {count} éléments",
219
219
  "size": "Affiché par {pageSize}",
220
220
  "current_page": "Page {currentPage} sur {totalPages}",
221
221
  "first_page": "Première page",
@@ -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",
@@ -521,6 +526,10 @@
521
526
  "description": "Aller à la recherche propre à la page",
522
527
  "condition": "Pages de paramètres qui ont leur propre recherche, comme celle-ci"
523
528
  },
529
+ "question_mark": {
530
+ "description": "Ouvrir la page des raccourcis clavier",
531
+ "condition": "En dehors d'un champ de texte"
532
+ },
524
533
  "escape": {
525
534
  "description": "Fermer les dialogues, les menus et la palette"
526
535
  }
@@ -67,6 +67,7 @@
67
67
  "isomorphic-dompurify": "^3.11.0",
68
68
  "json-schema-to-zod": "^2.6.0",
69
69
  "jsonwebtoken": "^9.0.3",
70
+ "libphonenumber-js": "^1.13.16",
70
71
  "reka-ui": "^2.6.0",
71
72
  "scule": "^1.3.0",
72
73
  "sortablejs": "^1.14.0",