@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.
- package/dist/chunks/classification-status.js +62 -0
- package/dist/chunks/collaboration-role.js +89 -0
- package/dist/chunks/collaboration-section.js +156 -0
- package/dist/chunks/collaborator-list-item.js +61 -0
- package/dist/chunks/collaborator-list.js +74 -0
- package/dist/chunks/remove-collaborator-modal.js +61 -0
- package/dist/chunks/remove-shared-link-modal.js +56 -0
- package/dist/chunks/shared-link-access.js +65 -0
- package/dist/chunks/shared-link-permission.js +67 -0
- package/dist/chunks/shared-link-section.js +176 -0
- package/dist/chunks/shared-link-settings-modal.js +86 -0
- package/dist/chunks/shared-with-avatars.js +48 -0
- package/dist/chunks/shield-restriction-notice.js +97 -0
- package/dist/chunks/text-area-container.js +36 -0
- package/dist/chunks/unified-share-form-modal.js +66 -0
- package/dist/chunks/unified-share-form.js +23 -0
- package/dist/esm/index.js +2 -4
- package/dist/esm/lib/components/classification-status/classification-status.js +2 -80
- package/dist/esm/lib/components/classification-status/index.js +2 -4
- package/dist/esm/lib/components/classification-status/messages.js +10 -12
- package/dist/esm/lib/components/index.js +5 -10
- package/dist/esm/lib/components/remove-collaborator-modal/index.js +2 -4
- package/dist/esm/lib/components/remove-collaborator-modal/messages.js +26 -28
- package/dist/esm/lib/components/remove-collaborator-modal/remove-collaborator-modal.js +2 -84
- package/dist/esm/lib/components/remove-shared-link-modal/index.js +2 -4
- package/dist/esm/lib/components/remove-shared-link-modal/messages.js +26 -28
- package/dist/esm/lib/components/remove-shared-link-modal/remove-shared-link-modal.js +2 -72
- package/dist/esm/lib/components/shared-link-settings-modal/download-section.js +35 -61
- package/dist/esm/lib/components/shared-link-settings-modal/expiration-section.js +33 -50
- package/dist/esm/lib/components/shared-link-settings-modal/index.js +2 -4
- package/dist/esm/lib/components/shared-link-settings-modal/messages.js +138 -144
- package/dist/esm/lib/components/shared-link-settings-modal/password-section.js +32 -52
- package/dist/esm/lib/components/shared-link-settings-modal/shared-link-settings-modal.js +2 -98
- package/dist/esm/lib/components/shared-link-settings-modal/shared-link-settings.js +97 -126
- package/dist/esm/lib/components/shared-link-settings-modal/vanity-section.js +33 -47
- package/dist/esm/lib/components/unified-share-form-modal/collaboration-section/collaboration-role.js +2 -128
- package/dist/esm/lib/components/unified-share-form-modal/collaboration-section/collaboration-section.js +2 -202
- package/dist/esm/lib/components/unified-share-form-modal/collaboration-section/index.js +2 -4
- package/dist/esm/lib/components/unified-share-form-modal/collaboration-section/messages.js +134 -136
- package/dist/esm/lib/components/unified-share-form-modal/collaboration-section/shared-with-avatars.js +2 -67
- package/dist/esm/lib/components/unified-share-form-modal/collaboration-section/shield-restriction-notice.js +2 -134
- package/dist/esm/lib/components/unified-share-form-modal/collaboration-section/text-area-container.js +2 -53
- package/dist/esm/lib/components/unified-share-form-modal/collaborator-list/collaborator-avatar.js +48 -60
- package/dist/esm/lib/components/unified-share-form-modal/collaborator-list/collaborator-list-item.js +2 -86
- package/dist/esm/lib/components/unified-share-form-modal/collaborator-list/collaborator-list.js +2 -101
- package/dist/esm/lib/components/unified-share-form-modal/collaborator-list/index.js +2 -4
- package/dist/esm/lib/components/unified-share-form-modal/collaborator-list/messages.js +38 -40
- package/dist/esm/lib/components/unified-share-form-modal/index.js +2 -4
- package/dist/esm/lib/components/unified-share-form-modal/messages.js +46 -48
- package/dist/esm/lib/components/unified-share-form-modal/shared-link-section/index.js +2 -4
- package/dist/esm/lib/components/unified-share-form-modal/shared-link-section/messages.js +142 -144
- package/dist/esm/lib/components/unified-share-form-modal/shared-link-section/shared-link-access.js +2 -102
- package/dist/esm/lib/components/unified-share-form-modal/shared-link-section/shared-link-permission.js +2 -105
- package/dist/esm/lib/components/unified-share-form-modal/shared-link-section/shared-link-section.js +2 -191
- package/dist/esm/lib/components/unified-share-form-modal/unified-share-form-modal.js +2 -85
- package/dist/esm/lib/components/unified-share-form-modal/unified-share-form.js +2 -29
- package/dist/esm/lib/constants.js +44 -28
- package/dist/esm/lib/contexts/index.js +4 -14
- package/dist/esm/lib/contexts/shared-link-settings-context.js +50 -59
- package/dist/esm/lib/contexts/unified-share-form-context.js +60 -57
- package/dist/esm/lib/contexts/unified-share-modal-context.js +65 -68
- package/dist/esm/lib/hooks/index.js +7 -14
- package/dist/esm/lib/hooks/use-access-levels.js +69 -93
- package/dist/esm/lib/hooks/use-collaboration-form.js +75 -95
- package/dist/esm/lib/hooks/use-form-validation.js +32 -43
- package/dist/esm/lib/hooks/use-link-settings-form.js +49 -64
- package/dist/esm/lib/hooks/use-permission-levels.js +33 -50
- package/dist/esm/lib/hooks/use-sharing-action.js +44 -59
- package/dist/esm/lib/messages.js +106 -108
- package/dist/esm/lib/unified-share-base.js +30 -40
- package/dist/esm/lib/unified-share-modal.js +41 -59
- package/dist/esm/lib/utils/collaborator.js +12 -27
- package/dist/esm/lib/utils/date.js +10 -14
- package/dist/esm/lib/utils/email.js +5 -7
- package/dist/esm/lib/utils/event.js +6 -13
- package/dist/esm/lib/utils/form.js +4 -14
- package/dist/esm/lib/utils/index.js +9 -34
- package/dist/esm/lib/utils/notification.js +19 -28
- package/dist/esm/lib/utils/permission.js +15 -22
- package/dist/esm/lib/utils/validation.js +2 -11
- package/dist/styles/classification-status.css +1 -1
- package/dist/styles/collaboration-role.css +1 -1
- package/dist/styles/collaboration-section.css +1 -1
- package/dist/styles/collaborator-list-item.css +1 -1
- package/dist/styles/collaborator-list.css +1 -1
- package/dist/styles/remove-collaborator-modal.css +1 -1
- package/dist/styles/shared-link-access.css +1 -1
- package/dist/styles/shared-link-section.css +1 -1
- package/dist/styles/shared-link-settings-modal.css +1 -1
- package/dist/styles/shared-with-avatars.css +1 -1
- package/dist/styles/shield-restriction-notice.css +1 -1
- package/dist/styles/text-area-container.css +1 -1
- package/dist/styles/unified-share-form-modal.css +1 -1
- package/dist/styles/unified-share-form.css +1 -1
- package/package.json +10 -10
|
@@ -1,69 +1,66 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { jsx as
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
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
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
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 {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
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
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
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 {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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 };
|