@box/unified-share-modal 2.8.18 → 2.9.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.
|
@@ -1,60 +1,60 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { useState as
|
|
3
|
-
import { createPortal as
|
|
4
|
-
import { useIntl as
|
|
5
|
-
import { useBlueprintModernization as
|
|
1
|
+
import fe from "clsx";
|
|
2
|
+
import { useState as be, useRef as ge, useEffect as R, useCallback as C } from "react";
|
|
3
|
+
import { createPortal as Ce } from "react-dom";
|
|
4
|
+
import { useIntl as ve } from "react-intl";
|
|
5
|
+
import { useBlueprintModernization as Se, useNotification as Ue, useUniqueId as _e, useLabelable as Fe, Tooltip as xe, Focusable as Ee, Text as Le, Modal as v } from "@box/blueprint-web";
|
|
6
6
|
import { Globe as ye } from "@box/blueprint-web-assets/icons/Medium";
|
|
7
|
-
import { bpSize040 as
|
|
8
|
-
import { UserSelectorContainer as
|
|
9
|
-
import { CollaborationRole as
|
|
10
|
-
import { SharedWithAvatars as
|
|
11
|
-
import { ShieldRestrictionNotice as
|
|
12
|
-
import { TextAreaContainer as
|
|
13
|
-
import
|
|
14
|
-
import { jsxs as l, jsx as t, Fragment as
|
|
15
|
-
import { useFormValidation as
|
|
16
|
-
import { useCollaborationForm as
|
|
17
|
-
import { useUnifiedShareFormContext as
|
|
18
|
-
import { useUnifiedShareModalContext as
|
|
19
|
-
import { parseEmails as
|
|
20
|
-
import { getNotificationArgs as
|
|
21
|
-
import '../../../../../styles/collaboration-section.css';const
|
|
22
|
-
container:
|
|
23
|
-
label:
|
|
24
|
-
modernized:
|
|
25
|
-
security:
|
|
26
|
-
icon:
|
|
27
|
-
access:
|
|
7
|
+
import { bpSize040 as k } from "@box/blueprint-web-assets/tokens/tokens";
|
|
8
|
+
import { UserSelectorContainer as Ne } from "@box/user-selector";
|
|
9
|
+
import { CollaborationRole as Ae } from "./collaboration-role.js";
|
|
10
|
+
import { SharedWithAvatars as Pe } from "./shared-with-avatars.js";
|
|
11
|
+
import { ShieldRestrictionNotice as Re } from "./shield-restriction-notice.js";
|
|
12
|
+
import { TextAreaContainer as ke } from "./text-area-container.js";
|
|
13
|
+
import i from "./messages.js";
|
|
14
|
+
import { jsxs as l, jsx as t, Fragment as Be } from "react/jsx-runtime";
|
|
15
|
+
import { useFormValidation as Me } from "../../../hooks/use-form-validation.js";
|
|
16
|
+
import { useCollaborationForm as Ve } from "../../../hooks/use-collaboration-form.js";
|
|
17
|
+
import { useUnifiedShareFormContext as De } from "../../../contexts/unified-share-form-context.js";
|
|
18
|
+
import { useUnifiedShareModalContext as Te } from "../../../contexts/unified-share-modal-context.js";
|
|
19
|
+
import { parseEmails as Ie } from "../../../utils/email.js";
|
|
20
|
+
import { getNotificationArgs as ze } from "../../../utils/notification.js";
|
|
21
|
+
import '../../../../../styles/collaboration-section.css';const Oe = "_container_1e2gg_2", we = "_label_1e2gg_8", We = "_modernized_1e2gg_15", je = "_security_1e2gg_33", Ge = "_icon_1e2gg_37", qe = "_access_1e2gg_43", c = {
|
|
22
|
+
container: Oe,
|
|
23
|
+
label: we,
|
|
24
|
+
modernized: We,
|
|
25
|
+
security: je,
|
|
26
|
+
icon: Ge,
|
|
27
|
+
access: qe
|
|
28
28
|
};
|
|
29
|
-
function
|
|
29
|
+
function ut() {
|
|
30
30
|
const {
|
|
31
31
|
formatMessage: o
|
|
32
|
-
} =
|
|
33
|
-
enableModernizedComponents:
|
|
34
|
-
} =
|
|
35
|
-
addNotification:
|
|
36
|
-
} =
|
|
37
|
-
validateShieldRestriction:
|
|
38
|
-
} =
|
|
39
|
-
contactValue:
|
|
32
|
+
} = ve(), [S, L] = be(), {
|
|
33
|
+
enableModernizedComponents: B
|
|
34
|
+
} = Se(), {
|
|
35
|
+
addNotification: M
|
|
36
|
+
} = Ue(), {
|
|
37
|
+
validateShieldRestriction: V
|
|
38
|
+
} = Me(), {
|
|
39
|
+
contactValue: D,
|
|
40
40
|
containerRef: U,
|
|
41
|
-
form:
|
|
41
|
+
form: r,
|
|
42
42
|
setForm: d,
|
|
43
|
-
setUserContacts:
|
|
44
|
-
shieldRestriction:
|
|
45
|
-
userContacts:
|
|
46
|
-
} =
|
|
47
|
-
collaborationAccess:
|
|
43
|
+
setUserContacts: T,
|
|
44
|
+
shieldRestriction: I,
|
|
45
|
+
userContacts: a
|
|
46
|
+
} = De(), {
|
|
47
|
+
collaborationAccess: z,
|
|
48
48
|
collaborationNotices: O,
|
|
49
|
-
config:
|
|
49
|
+
config: m,
|
|
50
50
|
contactService: w,
|
|
51
51
|
isFetching: W,
|
|
52
|
-
isSubmitting:
|
|
52
|
+
isSubmitting: u,
|
|
53
53
|
item: j,
|
|
54
54
|
onOpenChange: G,
|
|
55
55
|
sharingService: q,
|
|
56
56
|
variant: K
|
|
57
|
-
} =
|
|
57
|
+
} = Te(), {
|
|
58
58
|
permissions: $ = {},
|
|
59
59
|
type: H
|
|
60
60
|
} = j, {
|
|
@@ -63,139 +63,139 @@ function dt() {
|
|
|
63
63
|
} = w, {
|
|
64
64
|
sendInvitations: J,
|
|
65
65
|
sendSharedLink: Q
|
|
66
|
-
} = q;
|
|
67
|
-
let x,
|
|
68
|
-
|
|
66
|
+
} = q, X = K === "desktop", h = r === "default" || r === "invite", n = r === "invite" || r === "email", Y = r === "invite" && m.collaborationMessage, Z = r === "email" && m.sharedLinkEmailMessage, ee = a.some((e) => e.isExternalUser);
|
|
67
|
+
let x, E;
|
|
68
|
+
r === "invite" && (x = J, E = "invite-collaborators"), r === "email" && (x = Q, E = "email-shared-link");
|
|
69
69
|
const {
|
|
70
|
-
errors:
|
|
71
|
-
handleFormReset:
|
|
72
|
-
handleFormSubmit:
|
|
73
|
-
handleSelectedUsersChange:
|
|
74
|
-
handleUserSelectorBlur:
|
|
75
|
-
updateContactValue:
|
|
76
|
-
} =
|
|
70
|
+
errors: te,
|
|
71
|
+
handleFormReset: y,
|
|
72
|
+
handleFormSubmit: oe,
|
|
73
|
+
handleSelectedUsersChange: p,
|
|
74
|
+
handleUserSelectorBlur: re,
|
|
75
|
+
updateContactValue: ie
|
|
76
|
+
} = Ve(x, E), N = ge(r === "email" ? "email" : "invite");
|
|
77
77
|
R(() => {
|
|
78
|
-
N.current =
|
|
79
|
-
}, [
|
|
80
|
-
(!
|
|
81
|
-
}, [
|
|
82
|
-
const
|
|
83
|
-
|
|
84
|
-
},
|
|
78
|
+
N.current = r === "email" ? "email" : "invite";
|
|
79
|
+
}, [r]), R(() => {
|
|
80
|
+
(!a.length || !a.some((e) => e.chipVariant === "error")) && L(null);
|
|
81
|
+
}, [a]);
|
|
82
|
+
const ae = C((e) => (e.stopPropagation(), !0), []), ne = C((e) => _ ? _(e, N.current) : Promise.resolve([]), [_]), se = C((e) => F ? F(e) : Promise.resolve({}), [F]), le = (e) => {
|
|
83
|
+
n || d("invite"), ie(e);
|
|
84
|
+
}, ce = C((e) => {
|
|
85
85
|
const s = e.clipboardData.getData("text");
|
|
86
|
-
|
|
86
|
+
Ie(s).length !== 0 && (e.preventDefault(), n || d("invite"), p([...a, {
|
|
87
87
|
value: s
|
|
88
88
|
}]));
|
|
89
|
-
}, [
|
|
90
|
-
|
|
91
|
-
},
|
|
89
|
+
}, [p, n, d, a]), de = () => {
|
|
90
|
+
y(), d("default");
|
|
91
|
+
}, me = async () => {
|
|
92
92
|
try {
|
|
93
93
|
if (S) {
|
|
94
|
-
const e =
|
|
94
|
+
const e = V(a, I);
|
|
95
95
|
if (e) {
|
|
96
|
-
|
|
97
|
-
...
|
|
96
|
+
M({
|
|
97
|
+
...ze(o, "error"),
|
|
98
98
|
styledText: e
|
|
99
99
|
});
|
|
100
100
|
return;
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
|
-
if (await
|
|
103
|
+
if (await oe())
|
|
104
104
|
return;
|
|
105
|
-
|
|
105
|
+
y(), G(!1), d("default");
|
|
106
106
|
} catch (e) {
|
|
107
107
|
if (!e.shieldRestriction)
|
|
108
108
|
return;
|
|
109
109
|
const {
|
|
110
110
|
shieldRestriction: s
|
|
111
|
-
} = e, P = [...s.restrictedEmails ?? [], ...s.restrictedGroups ?? []],
|
|
111
|
+
} = e, P = [...s.restrictedEmails ?? [], ...s.restrictedGroups ?? []], pe = a.map((g) => P.includes(g.email) || P.includes(`${g.id}`) ? {
|
|
112
112
|
...g,
|
|
113
113
|
chipVariant: "error"
|
|
114
114
|
} : g);
|
|
115
|
-
|
|
115
|
+
L(s), T(pe);
|
|
116
116
|
}
|
|
117
117
|
};
|
|
118
|
-
let
|
|
119
|
-
|
|
120
|
-
const A =
|
|
118
|
+
let f, b = !1;
|
|
119
|
+
h && !$.canInviteCollaborator && (f = o(i.inviteDisabledTooltip), b = !0), h && H === "web_link" && (f = o(i.inviteWebLinkDisabledTooltip), b = !0);
|
|
120
|
+
const A = _e("user-contacts-"), ue = o(h ? i.invitePeopleLabel : i.emailSharedLinkLabel), he = Fe(ue, A);
|
|
121
121
|
return /* @__PURE__ */ l("form", {
|
|
122
122
|
className: c.container,
|
|
123
123
|
onSubmit: (e) => e.preventDefault(),
|
|
124
|
-
children: [S && /* @__PURE__ */ t(
|
|
124
|
+
children: [S && /* @__PURE__ */ t(Re, {
|
|
125
125
|
error: S,
|
|
126
|
-
isLoading:
|
|
127
|
-
onSelectedUsersChange:
|
|
126
|
+
isLoading: u,
|
|
127
|
+
onSelectedUsersChange: p
|
|
128
128
|
}), O, /* @__PURE__ */ l("div", {
|
|
129
|
-
children: [
|
|
130
|
-
className:
|
|
131
|
-
}), /* @__PURE__ */ t(
|
|
132
|
-
content:
|
|
129
|
+
children: [h && m.collaborators && /* @__PURE__ */ t(Pe, {}), /* @__PURE__ */ t(he, {
|
|
130
|
+
className: fe(c.label, B && c.modernized)
|
|
131
|
+
}), /* @__PURE__ */ t(xe, {
|
|
132
|
+
content: f,
|
|
133
133
|
"data-testid": "user-contacts-tooltip",
|
|
134
|
-
open:
|
|
134
|
+
open: f ? void 0 : !1,
|
|
135
135
|
side: "bottom",
|
|
136
|
-
children: /* @__PURE__ */ t(
|
|
136
|
+
children: /* @__PURE__ */ t(Ee, {
|
|
137
137
|
focusable: b,
|
|
138
|
-
children: /* @__PURE__ */ t(
|
|
138
|
+
children: /* @__PURE__ */ t(Ne, {
|
|
139
139
|
className: "collaboration-user-selector",
|
|
140
|
-
clearButtonAriaLabel: o(
|
|
140
|
+
clearButtonAriaLabel: o(i.clearButton),
|
|
141
141
|
clearOnBlur: !1,
|
|
142
142
|
"data-target-id": "PillSelectorDropdown-AddNamesOrEmailAddresses",
|
|
143
|
-
disabled: b ||
|
|
143
|
+
disabled: b || u,
|
|
144
144
|
displayChipVariant: (e) => e.chipVariant,
|
|
145
|
-
error:
|
|
146
|
-
fetchAvatarUrls:
|
|
147
|
-
fetchUsers:
|
|
148
|
-
hideOnEscape:
|
|
145
|
+
error: te["user-contact"],
|
|
146
|
+
fetchAvatarUrls: se,
|
|
147
|
+
fetchUsers: ne,
|
|
148
|
+
hideOnEscape: ae,
|
|
149
149
|
idForLabel: A,
|
|
150
|
-
inputValue:
|
|
150
|
+
inputValue: D,
|
|
151
151
|
label: null,
|
|
152
|
-
onBlur:
|
|
153
|
-
onInputValueChange:
|
|
154
|
-
onPaste:
|
|
155
|
-
onSelectedUsersChange:
|
|
156
|
-
placeholder:
|
|
152
|
+
onBlur: re,
|
|
153
|
+
onInputValueChange: le,
|
|
154
|
+
onPaste: ce,
|
|
155
|
+
onSelectedUsersChange: p,
|
|
156
|
+
placeholder: a.length ? "" : o(i.invitePeoplePlaceholder),
|
|
157
157
|
portalElement: U,
|
|
158
|
-
selectedUsers:
|
|
158
|
+
selectedUsers: a,
|
|
159
159
|
selectOnEnterOrTab: !0,
|
|
160
|
-
variant:
|
|
160
|
+
variant: n ? "textarea" : "input"
|
|
161
161
|
})
|
|
162
162
|
})
|
|
163
|
-
}),
|
|
163
|
+
}), h && /* @__PURE__ */ l("div", {
|
|
164
164
|
className: c.access,
|
|
165
|
-
children: [
|
|
165
|
+
children: [m.collaborationRole && /* @__PURE__ */ t(Ae, {}), z]
|
|
166
166
|
})]
|
|
167
|
-
}),
|
|
168
|
-
maxCount:
|
|
169
|
-
}),
|
|
167
|
+
}), (Y || Z) && /* @__PURE__ */ t(ke, {
|
|
168
|
+
maxCount: m.collaborationMessageLimit
|
|
169
|
+
}), n && ee && /* @__PURE__ */ l("div", {
|
|
170
170
|
className: c.security,
|
|
171
171
|
children: [/* @__PURE__ */ t(ye, {
|
|
172
172
|
className: c.icon,
|
|
173
|
-
height:
|
|
174
|
-
width:
|
|
175
|
-
}), /* @__PURE__ */ t(
|
|
173
|
+
height: k,
|
|
174
|
+
width: k
|
|
175
|
+
}), /* @__PURE__ */ t(Le, {
|
|
176
176
|
as: "span",
|
|
177
177
|
color: "textOnLightSecondary",
|
|
178
|
-
children: o(
|
|
178
|
+
children: o(i.contentSharedWithExternalCollaborators)
|
|
179
179
|
})]
|
|
180
|
-
}),
|
|
180
|
+
}), n && U && /* @__PURE__ */ Ce(/* @__PURE__ */ l(Be, {
|
|
181
181
|
children: [!W && /* @__PURE__ */ l(v.Footer, {
|
|
182
182
|
children: [/* @__PURE__ */ t(v.Footer.SecondaryButton, {
|
|
183
|
-
disabled:
|
|
184
|
-
onClick:
|
|
185
|
-
children: o(
|
|
183
|
+
disabled: u,
|
|
184
|
+
onClick: de,
|
|
185
|
+
children: o(i.cancelButton)
|
|
186
186
|
}), /* @__PURE__ */ t(v.Footer.PrimaryButton, {
|
|
187
|
-
loading:
|
|
188
|
-
loadingAriaLabel: o(
|
|
189
|
-
onClick:
|
|
190
|
-
children: o(
|
|
187
|
+
loading: u,
|
|
188
|
+
loadingAriaLabel: o(i.loadingLabel),
|
|
189
|
+
onClick: me,
|
|
190
|
+
children: o(i.sendButton)
|
|
191
191
|
})]
|
|
192
|
-
}), !
|
|
193
|
-
"aria-label": o(
|
|
194
|
-
disabled:
|
|
192
|
+
}), !X && /* @__PURE__ */ t(v.Close, {
|
|
193
|
+
"aria-label": o(i.closeButton),
|
|
194
|
+
disabled: u
|
|
195
195
|
})]
|
|
196
196
|
}), U)]
|
|
197
197
|
});
|
|
198
198
|
}
|
|
199
199
|
export {
|
|
200
|
-
|
|
200
|
+
ut as CollaborationSection
|
|
201
201
|
};
|
|
@@ -13,6 +13,7 @@ const e = ["invite-collaborators", "remove-collaborator", "create-shared-link",
|
|
|
13
13
|
sharedLinkAutoCopy: !1,
|
|
14
14
|
sharedLinkAutoCreate: !1,
|
|
15
15
|
sharedLinkEmail: !0,
|
|
16
|
+
sharedLinkEmailMessage: !0,
|
|
16
17
|
sharedLinkPermission: !0,
|
|
17
18
|
sharedLinkSettings: !0
|
|
18
19
|
}, o = ["co_owner", "editor", "previewer", "previewer_uploader", "uploader", "viewer", "viewer_uploader"], a = ["owner", ...o], t = ["open", "company", "collaborators"], i = ["can_edit", "can_download", "can_preview"], n = "boxnote";
|
|
@@ -714,6 +714,12 @@ export interface Configuration {
|
|
|
714
714
|
* @default true
|
|
715
715
|
*/
|
|
716
716
|
sharedLinkEmail?: boolean;
|
|
717
|
+
/**
|
|
718
|
+
* Controls whether the email message text field is visible to the user.
|
|
719
|
+
*
|
|
720
|
+
* @default true
|
|
721
|
+
*/
|
|
722
|
+
sharedLinkEmailMessage?: boolean;
|
|
717
723
|
/**
|
|
718
724
|
* Controls whether the shared link permission level is visible to the user.
|
|
719
725
|
*
|