@box/unified-share-modal 2.12.14 → 2.12.16

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 (95) hide show
  1. package/dist/chunks/classification-status.js +62 -0
  2. package/dist/chunks/collaboration-role.js +89 -0
  3. package/dist/chunks/collaboration-section.js +156 -0
  4. package/dist/chunks/collaborator-list-item.js +61 -0
  5. package/dist/chunks/collaborator-list.js +74 -0
  6. package/dist/chunks/remove-collaborator-modal.js +61 -0
  7. package/dist/chunks/remove-shared-link-modal.js +56 -0
  8. package/dist/chunks/shared-link-access.js +65 -0
  9. package/dist/chunks/shared-link-permission.js +67 -0
  10. package/dist/chunks/shared-link-section.js +176 -0
  11. package/dist/chunks/shared-link-settings-modal.js +86 -0
  12. package/dist/chunks/shared-with-avatars.js +48 -0
  13. package/dist/chunks/shield-restriction-notice.js +97 -0
  14. package/dist/chunks/text-area-container.js +36 -0
  15. package/dist/chunks/unified-share-form-modal.js +66 -0
  16. package/dist/chunks/unified-share-form.js +23 -0
  17. package/dist/esm/index.js +2 -4
  18. package/dist/esm/lib/components/classification-status/classification-status.js +2 -80
  19. package/dist/esm/lib/components/classification-status/index.js +2 -4
  20. package/dist/esm/lib/components/classification-status/messages.js +10 -12
  21. package/dist/esm/lib/components/index.js +5 -10
  22. package/dist/esm/lib/components/remove-collaborator-modal/index.js +2 -4
  23. package/dist/esm/lib/components/remove-collaborator-modal/messages.js +26 -28
  24. package/dist/esm/lib/components/remove-collaborator-modal/remove-collaborator-modal.js +2 -84
  25. package/dist/esm/lib/components/remove-shared-link-modal/index.js +2 -4
  26. package/dist/esm/lib/components/remove-shared-link-modal/messages.js +26 -28
  27. package/dist/esm/lib/components/remove-shared-link-modal/remove-shared-link-modal.js +2 -72
  28. package/dist/esm/lib/components/shared-link-settings-modal/download-section.js +35 -61
  29. package/dist/esm/lib/components/shared-link-settings-modal/expiration-section.js +33 -50
  30. package/dist/esm/lib/components/shared-link-settings-modal/index.js +2 -4
  31. package/dist/esm/lib/components/shared-link-settings-modal/messages.js +138 -144
  32. package/dist/esm/lib/components/shared-link-settings-modal/password-section.js +32 -52
  33. package/dist/esm/lib/components/shared-link-settings-modal/shared-link-settings-modal.js +2 -98
  34. package/dist/esm/lib/components/shared-link-settings-modal/shared-link-settings.js +97 -126
  35. package/dist/esm/lib/components/shared-link-settings-modal/vanity-section.js +33 -47
  36. package/dist/esm/lib/components/unified-share-form-modal/collaboration-section/collaboration-role.js +2 -128
  37. package/dist/esm/lib/components/unified-share-form-modal/collaboration-section/collaboration-section.js +2 -202
  38. package/dist/esm/lib/components/unified-share-form-modal/collaboration-section/index.js +2 -4
  39. package/dist/esm/lib/components/unified-share-form-modal/collaboration-section/messages.js +134 -136
  40. package/dist/esm/lib/components/unified-share-form-modal/collaboration-section/shared-with-avatars.js +2 -67
  41. package/dist/esm/lib/components/unified-share-form-modal/collaboration-section/shield-restriction-notice.js +2 -134
  42. package/dist/esm/lib/components/unified-share-form-modal/collaboration-section/text-area-container.js +2 -53
  43. package/dist/esm/lib/components/unified-share-form-modal/collaborator-list/collaborator-avatar.js +48 -60
  44. package/dist/esm/lib/components/unified-share-form-modal/collaborator-list/collaborator-list-item.js +2 -86
  45. package/dist/esm/lib/components/unified-share-form-modal/collaborator-list/collaborator-list.js +2 -101
  46. package/dist/esm/lib/components/unified-share-form-modal/collaborator-list/index.js +2 -4
  47. package/dist/esm/lib/components/unified-share-form-modal/collaborator-list/messages.js +38 -40
  48. package/dist/esm/lib/components/unified-share-form-modal/index.js +2 -4
  49. package/dist/esm/lib/components/unified-share-form-modal/messages.js +46 -48
  50. package/dist/esm/lib/components/unified-share-form-modal/shared-link-section/index.js +2 -4
  51. package/dist/esm/lib/components/unified-share-form-modal/shared-link-section/messages.js +142 -144
  52. package/dist/esm/lib/components/unified-share-form-modal/shared-link-section/shared-link-access.js +2 -102
  53. package/dist/esm/lib/components/unified-share-form-modal/shared-link-section/shared-link-permission.js +2 -105
  54. package/dist/esm/lib/components/unified-share-form-modal/shared-link-section/shared-link-section.js +2 -191
  55. package/dist/esm/lib/components/unified-share-form-modal/unified-share-form-modal.js +2 -85
  56. package/dist/esm/lib/components/unified-share-form-modal/unified-share-form.js +2 -29
  57. package/dist/esm/lib/constants.js +44 -28
  58. package/dist/esm/lib/contexts/index.js +4 -14
  59. package/dist/esm/lib/contexts/shared-link-settings-context.js +50 -59
  60. package/dist/esm/lib/contexts/unified-share-form-context.js +60 -57
  61. package/dist/esm/lib/contexts/unified-share-modal-context.js +65 -68
  62. package/dist/esm/lib/hooks/index.js +7 -14
  63. package/dist/esm/lib/hooks/use-access-levels.js +69 -93
  64. package/dist/esm/lib/hooks/use-collaboration-form.js +75 -95
  65. package/dist/esm/lib/hooks/use-form-validation.js +32 -43
  66. package/dist/esm/lib/hooks/use-link-settings-form.js +49 -64
  67. package/dist/esm/lib/hooks/use-permission-levels.js +33 -50
  68. package/dist/esm/lib/hooks/use-sharing-action.js +44 -59
  69. package/dist/esm/lib/messages.js +106 -108
  70. package/dist/esm/lib/unified-share-base.js +30 -40
  71. package/dist/esm/lib/unified-share-modal.js +41 -59
  72. package/dist/esm/lib/utils/collaborator.js +12 -27
  73. package/dist/esm/lib/utils/date.js +10 -14
  74. package/dist/esm/lib/utils/email.js +5 -7
  75. package/dist/esm/lib/utils/event.js +6 -13
  76. package/dist/esm/lib/utils/form.js +4 -14
  77. package/dist/esm/lib/utils/index.js +9 -34
  78. package/dist/esm/lib/utils/notification.js +19 -28
  79. package/dist/esm/lib/utils/permission.js +15 -22
  80. package/dist/esm/lib/utils/validation.js +2 -11
  81. package/dist/styles/classification-status.css +1 -1
  82. package/dist/styles/collaboration-role.css +1 -1
  83. package/dist/styles/collaboration-section.css +1 -1
  84. package/dist/styles/collaborator-list-item.css +1 -1
  85. package/dist/styles/collaborator-list.css +1 -1
  86. package/dist/styles/remove-collaborator-modal.css +1 -1
  87. package/dist/styles/shared-link-access.css +1 -1
  88. package/dist/styles/shared-link-section.css +1 -1
  89. package/dist/styles/shared-link-settings-modal.css +1 -1
  90. package/dist/styles/shared-with-avatars.css +1 -1
  91. package/dist/styles/shield-restriction-notice.css +1 -1
  92. package/dist/styles/text-area-container.css +1 -1
  93. package/dist/styles/unified-share-form-modal.css +1 -1
  94. package/dist/styles/unified-share-form.css +1 -1
  95. package/package.json +10 -10
@@ -1,69 +1,66 @@
1
- import { createContext as V, useState as t, useEffect as b, useMemo as j, useContext as A } from "react";
2
- import { DEFAULT_CONFIGURATION as D } from "../constants.js";
3
- import { jsx as F } from "react/jsx-runtime";
4
- const L = /* @__PURE__ */ V(null), _ = () => {
5
- const e = A(L);
6
- if (!e)
7
- throw new Error("useUnifiedShareModalContext must be used with UnifiedShareModalContext.Provider");
8
- return e;
9
- }, g = ({
10
- children: e,
11
- collaborationAccess: r,
12
- collaborationNotices: n,
13
- collaborationRoles: s,
14
- collaborators: d,
15
- config: f,
16
- contactService: i,
17
- currentUser: a,
18
- eventService: u,
19
- initialContacts: l,
20
- isFetching: x,
21
- isOpen: o,
22
- isSubmitting: m,
23
- item: c,
24
- onOpenChange: h,
25
- sharedLink: C,
26
- sharingService: U,
27
- variant: M
28
- }) => {
29
- const [S, P] = t(null), [w, v] = t(!1), [E, I] = t("unified-share-form");
30
- b(() => {
31
- o || (v(!1), I("unified-share-form"));
32
- }, [o]);
33
- const T = j(() => ({
34
- collaborationAccess: r,
35
- collaborationNotices: n,
36
- collaborationRoles: s ?? [],
37
- collaborator: S,
38
- collaborators: d ?? [],
39
- config: {
40
- ...D,
41
- ...f
42
- },
43
- contactService: i ?? {},
44
- currentUser: a ?? {},
45
- eventService: u ?? {},
46
- initialContacts: l ?? [],
47
- isFetching: x,
48
- isOpen: o,
49
- isSubmitting: m ?? w,
50
- item: c,
51
- onOpenChange: h,
52
- setCollaborator: P,
53
- setIsLoading: v,
54
- setView: I,
55
- sharedLink: C ?? {},
56
- sharingService: U ?? {},
57
- variant: M,
58
- view: E
59
- }), [r, n, s, S, d, f, i, a, u, l, x, w, o, m, c, h, C, U, M, E]);
60
- return /* @__PURE__ */ F(L.Provider, {
61
- value: T,
62
- children: e
63
- });
64
- };
65
- export {
66
- L as UnifiedShareModalContext,
67
- g as UnifiedShareModalProvider,
68
- _ as useUnifiedShareModalContext
1
+ import { DEFAULT_CONFIGURATION as e } from "../constants.js";
2
+ import { createContext as t, useContext as n, useEffect as r, useMemo as i, useState as a } from "react";
3
+ import { jsx as o } from "react/jsx-runtime";
4
+ var s = /* @__PURE__ */ t(null), c = () => {
5
+ let e = n(s);
6
+ if (!e) throw Error("useUnifiedShareModalContext must be used with UnifiedShareModalContext.Provider");
7
+ return e;
8
+ }, l = ({ children: t, collaborationAccess: n, collaborationNotices: c, collaborationRoles: l, collaborators: u, config: d, contactService: f, currentUser: p, eventService: m, initialContacts: h, isFetching: g, isOpen: _, isSubmitting: v, item: y, onOpenChange: b, sharedLink: x, sharingService: S, variant: C }) => {
9
+ let [w, T] = a(null), [E, D] = a(!1), [O, k] = a("unified-share-form");
10
+ r(() => {
11
+ _ || (D(!1), k("unified-share-form"));
12
+ }, [_]);
13
+ let A = i(() => ({
14
+ collaborationAccess: n,
15
+ collaborationNotices: c,
16
+ collaborationRoles: l ?? [],
17
+ collaborator: w,
18
+ collaborators: u ?? [],
19
+ config: {
20
+ ...e,
21
+ ...d
22
+ },
23
+ contactService: f ?? {},
24
+ currentUser: p ?? {},
25
+ eventService: m ?? {},
26
+ initialContacts: h ?? [],
27
+ isFetching: g,
28
+ isOpen: _,
29
+ isSubmitting: v ?? E,
30
+ item: y,
31
+ onOpenChange: b,
32
+ setCollaborator: T,
33
+ setIsLoading: D,
34
+ setView: k,
35
+ sharedLink: x ?? {},
36
+ sharingService: S ?? {},
37
+ variant: C,
38
+ view: O
39
+ }), [
40
+ n,
41
+ c,
42
+ l,
43
+ w,
44
+ u,
45
+ d,
46
+ f,
47
+ p,
48
+ m,
49
+ h,
50
+ g,
51
+ E,
52
+ _,
53
+ v,
54
+ y,
55
+ b,
56
+ x,
57
+ S,
58
+ C,
59
+ O
60
+ ]);
61
+ return /* @__PURE__ */ o(s.Provider, {
62
+ value: A,
63
+ children: t
64
+ });
69
65
  };
66
+ export { s as UnifiedShareModalContext, l as UnifiedShareModalProvider, c as useUnifiedShareModalContext };
@@ -1,14 +1,7 @@
1
- import { useAccessLevels as r } from "./use-access-levels.js";
2
- import { useCollaborationForm as t } from "./use-collaboration-form.js";
3
- import { useFormValidation as i } from "./use-form-validation.js";
4
- import { useLinkSettingsForm as f } from "./use-link-settings-form.js";
5
- import { usePermissionLevels as u } from "./use-permission-levels.js";
6
- import { useSharingAction as a } from "./use-sharing-action.js";
7
- export {
8
- r as useAccessLevels,
9
- t as useCollaborationForm,
10
- i as useFormValidation,
11
- f as useLinkSettingsForm,
12
- u as usePermissionLevels,
13
- a as useSharingAction
14
- };
1
+ import { useAccessLevels as e } from "./use-access-levels.js";
2
+ import { useFormValidation as t } from "./use-form-validation.js";
3
+ import { useSharingAction as n } from "./use-sharing-action.js";
4
+ import { useCollaborationForm as r } from "./use-collaboration-form.js";
5
+ import { useLinkSettingsForm as i } from "./use-link-settings-form.js";
6
+ import { usePermissionLevels as a } from "./use-permission-levels.js";
7
+ export { e as useAccessLevels, r as useCollaborationForm, t as useFormValidation, i as useLinkSettingsForm, a as usePermissionLevels, n as useSharingAction };
@@ -1,94 +1,70 @@
1
- import { useMemo as p } from "react";
2
- import { useIntl as A } from "react-intl";
3
- import { useUnifiedShareModalContext as v } from "../contexts/unified-share-modal-context.js";
4
- import e from "../components/unified-share-form-modal/shared-link-section/messages.js";
5
- import { getAllowedAccessLevels as k } from "../utils/permission.js";
6
- const d = (o, a, t) => {
7
- const {
8
- id: l,
9
- label: n
10
- } = a;
11
- let s;
12
- switch (l) {
13
- case "collaborators":
14
- s = e.collaboratorsAccessLevelLabel;
15
- break;
16
- case "company":
17
- s = t ? e.enterpriseAccessLevelLabel : e.companyAccessLevelLabel;
18
- break;
19
- case "open":
20
- s = e.openAccessLevelLabel;
21
- break;
22
- }
23
- return n ?? (s ? o(s, {
24
- enterprise: t
25
- }) : "");
26
- }, f = (o, a, t, l) => {
27
- const {
28
- description: n,
29
- id: s
30
- } = a;
31
- let r, c;
32
- switch (s) {
33
- case "collaborators":
34
- r = e.collaboratorsAccessLevelDescription;
35
- break;
36
- case "company":
37
- r = t ? e.enterpriseAccessLevelDescription : e.companyAccessLevelDescription;
38
- break;
39
- case "open":
40
- r = e.openAccessLevelDescription;
41
- break;
42
- }
43
- switch (l) {
44
- case "file":
45
- c = e.fileAccessLevelItem;
46
- break;
47
- case "folder":
48
- c = e.folderAccessLevelItem;
49
- break;
50
- case "hubs":
51
- c = e.hubsAccessLevelItem;
52
- break;
53
- case "web_link":
54
- c = e.webLinkAccessLevelItem;
55
- break;
56
- case "workflow":
57
- c = e.workflowAccessLevelItem;
58
- break;
59
- }
60
- return n ?? (r ? o(r, {
61
- enterprise: t,
62
- item: o(c)
63
- }) : "");
64
- }, I = () => {
65
- const {
66
- formatMessage: o
67
- } = A(), {
68
- currentUser: a,
69
- item: t,
70
- sharedLink: l
71
- } = v(), {
72
- enterprise: n = {}
73
- } = a, {
74
- name: s
75
- } = n, {
76
- type: r
77
- } = t, {
78
- access: c,
79
- accessLevels: b
80
- } = l, m = p(() => k(b).map((i) => ({
81
- ...i,
82
- description: f(o, i, s, r),
83
- label: d(o, i, s)
84
- })), [b, s, o, r]), L = p(() => m.find(({
85
- id: i
86
- }) => c === i), [c, m]);
87
- return {
88
- allowedLevels: m,
89
- selectedAccess: L
90
- };
91
- };
92
- export {
93
- I as useAccessLevels
1
+ import { useUnifiedShareModalContext as e } from "../contexts/unified-share-modal-context.js";
2
+ import { getAllowedAccessLevels as t } from "../utils/permission.js";
3
+ import n from "../components/unified-share-form-modal/shared-link-section/messages.js";
4
+ import { useMemo as r } from "react";
5
+ import { useIntl as i } from "react-intl";
6
+ var a = (e, t, r) => {
7
+ let { id: i, label: a } = t, o;
8
+ switch (i) {
9
+ case "collaborators":
10
+ o = n.collaboratorsAccessLevelLabel;
11
+ break;
12
+ case "company":
13
+ o = r ? n.enterpriseAccessLevelLabel : n.companyAccessLevelLabel;
14
+ break;
15
+ case "open":
16
+ o = n.openAccessLevelLabel;
17
+ break;
18
+ }
19
+ return a ?? (o ? e(o, { enterprise: r }) : "");
20
+ }, o = (e, t, r, i) => {
21
+ let { description: a, id: o } = t, s, c;
22
+ switch (o) {
23
+ case "collaborators":
24
+ s = n.collaboratorsAccessLevelDescription;
25
+ break;
26
+ case "company":
27
+ s = r ? n.enterpriseAccessLevelDescription : n.companyAccessLevelDescription;
28
+ break;
29
+ case "open":
30
+ s = n.openAccessLevelDescription;
31
+ break;
32
+ }
33
+ switch (i) {
34
+ case "file":
35
+ c = n.fileAccessLevelItem;
36
+ break;
37
+ case "folder":
38
+ c = n.folderAccessLevelItem;
39
+ break;
40
+ case "hubs":
41
+ c = n.hubsAccessLevelItem;
42
+ break;
43
+ case "web_link":
44
+ c = n.webLinkAccessLevelItem;
45
+ break;
46
+ case "workflow":
47
+ c = n.workflowAccessLevelItem;
48
+ break;
49
+ }
50
+ return a ?? (s ? e(s, {
51
+ enterprise: r,
52
+ item: e(c)
53
+ }) : "");
54
+ }, s = () => {
55
+ let { formatMessage: n } = i(), { currentUser: s, item: c, sharedLink: l } = e(), { enterprise: u = {} } = s, { name: d } = u, { type: f } = c, { access: p, accessLevels: m } = l, h = r(() => t(m).map((e) => ({
56
+ ...e,
57
+ description: o(n, e, d, f),
58
+ label: a(n, e, d)
59
+ })), [
60
+ m,
61
+ d,
62
+ n,
63
+ f
64
+ ]);
65
+ return {
66
+ allowedLevels: h,
67
+ selectedAccess: r(() => h.find(({ id: e }) => p === e), [p, h])
68
+ };
94
69
  };
70
+ export { s as useAccessLevels };
@@ -1,96 +1,76 @@
1
- import A from "lodash/differenceBy";
2
- import M from "lodash/uniqBy";
3
- import { useCallback as l } from "react";
4
- import { useUnifiedShareFormContext as T } from "../contexts/unified-share-form-context.js";
5
- import { useUnifiedShareModalContext as D } from "../contexts/unified-share-modal-context.js";
6
- import { useFormValidation as J } from "./use-form-validation.js";
7
- import { useSharingAction as O } from "./use-sharing-action.js";
8
- import { parseEmails as P } from "../utils/email.js";
9
- const Z = (S, v) => {
10
- const {
11
- errors: h,
12
- setFieldError: r,
13
- validateCollaborationLimit: c,
14
- validateUserContact: g,
15
- validateUserSelector: u
16
- } = J(), {
17
- config: F,
18
- contactService: w
19
- } = D(), {
20
- collaborationLimit: i
21
- } = F, {
22
- collaborationRole: E,
23
- form: L,
24
- messageValue: x,
25
- setContactValue: m,
26
- setMessageValue: R,
27
- setUserContacts: f,
28
- shieldRestriction: d,
29
- userContacts: n
30
- } = T(), {
31
- onAction: V
32
- } = O(S, v), {
33
- getContactsByEmail: C
34
- } = w, U = () => {
35
- f([]), m(""), R(""), r("userContacts", "");
36
- }, B = l((t) => {
37
- c(n, i) || r("userContacts", ""), m(t);
38
- }, [i, m, r, n, c]), b = l(async (t) => {
39
- const s = {};
40
- if (C && t.length > 0) {
41
- const e = await C(t);
42
- for (const o of Object.keys(e))
43
- s[o.toLowerCase()] = e[o];
44
- }
45
- return t.map((e) => {
46
- const o = s[e.toLowerCase()];
47
- return o || {
48
- email: e,
49
- id: 0,
50
- isExternalUser: !0,
51
- name: e,
52
- value: e,
53
- type: "user"
54
- };
55
- });
56
- }, [C]), p = l(async (t) => {
57
- r("userContacts", ""), u(t);
58
- let s;
59
- if (t.length <= n.length || t[t.length - 1].id !== void 0)
60
- s = t;
61
- else {
62
- const e = t.slice(0, -1), o = t[t.length - 1].value, y = P(o);
63
- y.length === 0 && g(o);
64
- const j = e.filter((a) => a.email).map((a) => a.email), k = M(A(y, j, (a) => a.toLowerCase()), (a) => a.toLowerCase()), q = await b(k);
65
- s = [...e, ...q];
66
- }
67
- i && c(s, i), f(s);
68
- }, [i, b, r, f, n, c, g, u]), I = l((t) => {
69
- const s = t.relatedTarget?.closest(".usm-UserContacts-input"), e = document.querySelector('[aria-labelledby^="usm-UserContacts-"]')?.contains(t.relatedTarget);
70
- if (s || e)
71
- return;
72
- const o = t.target.value.trim();
73
- o && p([...n, {
74
- value: o
75
- }]);
76
- }, [p, n]);
77
- return {
78
- errors: h,
79
- handleFormReset: U,
80
- handleFormSubmit: async () => {
81
- if (h.userContacts || u(n))
82
- return !0;
83
- const t = {
84
- contacts: n,
85
- message: x
86
- };
87
- return L === "invite" && (t.role = E.id), d.isJustificationAllowed && (t.justificationReason = d.justificationReason, t.classificationId = d.classificationId), await V(t), U(), !1;
88
- },
89
- handleSelectedUsersChange: p,
90
- handleUserSelectorBlur: I,
91
- updateContactValue: B
92
- };
93
- };
94
- export {
95
- Z as useCollaborationForm
1
+ import { useUnifiedShareModalContext as e } from "../contexts/unified-share-modal-context.js";
2
+ import { parseEmails as t } from "../utils/email.js";
3
+ import { useUnifiedShareFormContext as n } from "../contexts/unified-share-form-context.js";
4
+ import { useFormValidation as r } from "./use-form-validation.js";
5
+ import { useSharingAction as i } from "./use-sharing-action.js";
6
+ import { useCallback as a } from "react";
7
+ import o from "lodash/differenceBy";
8
+ import s from "lodash/uniqBy";
9
+ var c = (c, l) => {
10
+ let { errors: u, setFieldError: d, validateCollaborationLimit: f, validateUserContact: p, validateUserSelector: m } = r(), { config: h, contactService: g } = e(), { collaborationLimit: _ } = h, { collaborationRole: v, form: y, messageValue: b, setContactValue: x, setMessageValue: S, setUserContacts: C, shieldRestriction: w, userContacts: T } = n(), { onAction: E } = i(c, l), { getContactsByEmail: D } = g, O = () => {
11
+ C([]), x(""), S(""), d("userContacts", "");
12
+ }, k = a((e) => {
13
+ f(T, _) || d("userContacts", ""), x(e);
14
+ }, [
15
+ _,
16
+ x,
17
+ d,
18
+ T,
19
+ f
20
+ ]), A = a(async (e) => {
21
+ let t = {};
22
+ if (D && e.length > 0) {
23
+ let n = await D(e);
24
+ for (let e of Object.keys(n)) t[e.toLowerCase()] = n[e];
25
+ }
26
+ return e.map((e) => t[e.toLowerCase()] || {
27
+ email: e,
28
+ id: 0,
29
+ isExternalUser: !0,
30
+ name: e,
31
+ value: e,
32
+ type: "user"
33
+ });
34
+ }, [D]), j = a(async (e) => {
35
+ d("userContacts", ""), m(e);
36
+ let n;
37
+ if (e.length <= T.length || e[e.length - 1].id !== void 0) n = e;
38
+ else {
39
+ let r = e.slice(0, -1), i = e[e.length - 1].value, a = t(i);
40
+ a.length === 0 && p(i);
41
+ let c = await A(s(o(a, r.filter((e) => e.email).map((e) => e.email), (e) => e.toLowerCase()), (e) => e.toLowerCase()));
42
+ n = [...r, ...c];
43
+ }
44
+ _ && f(n, _), C(n);
45
+ }, [
46
+ _,
47
+ A,
48
+ d,
49
+ C,
50
+ T,
51
+ f,
52
+ p,
53
+ m
54
+ ]);
55
+ return {
56
+ errors: u,
57
+ handleFormReset: O,
58
+ handleFormSubmit: async () => {
59
+ if (u.userContacts || m(T)) return !0;
60
+ let e = {
61
+ contacts: T,
62
+ message: b
63
+ };
64
+ return y === "invite" && (e.role = v.id), w.isJustificationAllowed && (e.justificationReason = w.justificationReason, e.classificationId = w.classificationId), await E(e), O(), !1;
65
+ },
66
+ handleSelectedUsersChange: j,
67
+ handleUserSelectorBlur: a((e) => {
68
+ let t = e.relatedTarget?.closest(".usm-UserContacts-input"), n = document.querySelector("[aria-labelledby^=\"usm-UserContacts-\"]")?.contains(e.relatedTarget);
69
+ if (t || n) return;
70
+ let r = e.target.value.trim();
71
+ r && j([...T, { value: r }]);
72
+ }, [j, T]),
73
+ updateContactValue: k
74
+ };
96
75
  };
76
+ export { c as useCollaborationForm };
@@ -1,44 +1,33 @@
1
- import { useState as h, useCallback as i } from "react";
2
- import { useIntl as w } from "react-intl";
3
- import a from "../messages.js";
4
- import { formatTomorrowDateToCalendarDate as N } from "../utils/date.js";
5
- import { isVanityNameValid as y, isEmailValid as P, doesPasswordContainMinCharacters as b, doesPasswordContainInvalidCharacter as V, doesPasswordContainMixedCase as x, doesPasswordContainLetter as l, doesPasswordContainNumber as c, doesPasswordContainSymbol as d } from "../utils/validation.js";
6
- const U = () => {
7
- const {
8
- formatMessage: e
9
- } = w(), [f, u] = h({}), t = i((r, o) => {
10
- u((s) => ({
11
- ...s,
12
- [r]: o
13
- }));
14
- }, []), m = i((r) => {
15
- if (!r)
16
- return t("expiration", e(a.expirationRequiredErrorMessage)), !0;
17
- const o = N();
18
- return r.compare(o) < 0 ? (t("expiration", e(a.expirationFutureDateErrorMessage)), !0) : !1;
19
- }, [e, t]), C = i((r) => r ? y(r) ? !1 : (t("vanityName", e(a.vanityNameInvalidErrorMessage)), !0) : (t("vanityName", e(a.vanityNameRequiredErrorMessage)), !0), [e, t]), g = i((r, o) => {
20
- const s = r.filter((n) => n.chipVariant === "error");
21
- return o.isJustificationAllowed && !o.justificationReason ? e(a.justificationRequiredErrorNotice, {
22
- count: s.length
23
- }) : s.length && !o.isJustificationAllowed ? e(a.restrictedContactsErrorNotice, {
24
- count: s.length
25
- }) : "";
26
- }, [e]), v = i((r) => r.length ? !1 : (t("userContacts", e(a.emailRequiredErrorMessage)), !0), [e, t]), E = i((r, o) => r.filter((n) => n.value !== "").length <= o ? !1 : (t("userContacts", e(a.contactsLimitErrorMessage, {
27
- maxContacts: o
28
- })), !0), [e, t]), M = i((r) => r === "" ? !0 : P(r) ? !1 : (t("userContacts", e(a.invalidEmailErrorMessage)), !0), [e, t]), p = i((r) => b(r) ? V(r) ? (t("password", e(a.passwordContainInvalidCharacterErrorMessage)), !0) : !x(r) && !(l(r) && c(r)) && !(l(r) && d(r)) && !(c(r) && d(r)) ? (t("password", e(a.passwordContainLetterNumberOrSymbolErrorMessage)), !0) : !1 : (t("password", e(a.passwordContainMinCharactersErrorMessage)), !0), [e, t]);
29
- return {
30
- errors: f,
31
- validateCollaborationLimit: E,
32
- validateExpiration: m,
33
- validatePassword: p,
34
- validateShieldRestriction: g,
35
- validateVanityName: C,
36
- validateUserContact: M,
37
- validateUserSelector: v,
38
- setErrors: u,
39
- setFieldError: t
40
- };
41
- };
42
- export {
43
- U as useFormValidation
1
+ import { formatTomorrowDateToCalendarDate as e } from "../utils/date.js";
2
+ import { doesPasswordContainInvalidCharacter as t, doesPasswordContainLetter as n, doesPasswordContainMinCharacters as r, doesPasswordContainMixedCase as i, doesPasswordContainNumber as a, doesPasswordContainSymbol as o, isEmailValid as s, isVanityNameValid as c } from "../utils/validation.js";
3
+ import l from "../messages.js";
4
+ import { useCallback as u, useState as d } from "react";
5
+ import { useIntl as f } from "react-intl";
6
+ var p = () => {
7
+ let { formatMessage: p } = f(), [m, h] = d({}), g = u((e, t) => {
8
+ h((n) => ({
9
+ ...n,
10
+ [e]: t
11
+ }));
12
+ }, []), _ = u((t) => {
13
+ if (!t) return g("expiration", p(l.expirationRequiredErrorMessage)), !0;
14
+ let n = e();
15
+ return t.compare(n) < 0 ? (g("expiration", p(l.expirationFutureDateErrorMessage)), !0) : !1;
16
+ }, [p, g]), v = u((e) => e ? c(e) ? !1 : (g("vanityName", p(l.vanityNameInvalidErrorMessage)), !0) : (g("vanityName", p(l.vanityNameRequiredErrorMessage)), !0), [p, g]), y = u((e, t) => {
17
+ let n = e.filter((e) => e.chipVariant === "error");
18
+ return t.isJustificationAllowed && !t.justificationReason ? p(l.justificationRequiredErrorNotice, { count: n.length }) : n.length && !t.isJustificationAllowed ? p(l.restrictedContactsErrorNotice, { count: n.length }) : "";
19
+ }, [p]), b = u((e) => e.length ? !1 : (g("userContacts", p(l.emailRequiredErrorMessage)), !0), [p, g]), x = u((e, t) => e.filter((e) => e.value !== "").length <= t ? !1 : (g("userContacts", p(l.contactsLimitErrorMessage, { maxContacts: t })), !0), [p, g]), S = u((e) => e === "" ? !0 : s(e) ? !1 : (g("userContacts", p(l.invalidEmailErrorMessage)), !0), [p, g]);
20
+ return {
21
+ errors: m,
22
+ validateCollaborationLimit: x,
23
+ validateExpiration: _,
24
+ validatePassword: u((e) => r(e) ? t(e) ? (g("password", p(l.passwordContainInvalidCharacterErrorMessage)), !0) : !i(e) && !(n(e) && a(e)) && !(n(e) && o(e)) && !(a(e) && o(e)) ? (g("password", p(l.passwordContainLetterNumberOrSymbolErrorMessage)), !0) : !1 : (g("password", p(l.passwordContainMinCharactersErrorMessage)), !0), [p, g]),
25
+ validateShieldRestriction: y,
26
+ validateVanityName: v,
27
+ validateUserContact: S,
28
+ validateUserSelector: b,
29
+ setErrors: h,
30
+ setFieldError: g
31
+ };
44
32
  };
33
+ export { p as useFormValidation };