@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 pe from "clsx";
2
- import { useState as fe, useRef as he, useEffect as R, useCallback as C } from "react";
3
- import { createPortal as be } from "react-dom";
4
- import { useIntl as ge } from "react-intl";
5
- import { useBlueprintModernization as Ce, useNotification as ve, useUniqueId as Se, useLabelable as Ue, Tooltip as _e, Focusable as Fe, Text as xe, Modal as v } from "@box/blueprint-web";
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 B } from "@box/blueprint-web-assets/tokens/tokens";
8
- import { UserSelectorContainer as Ee } from "@box/user-selector";
9
- import { CollaborationRole as Le } from "./collaboration-role.js";
10
- import { SharedWithAvatars as Ne } from "./shared-with-avatars.js";
11
- import { ShieldRestrictionNotice as Ae } from "./shield-restriction-notice.js";
12
- import { TextAreaContainer as Pe } from "./text-area-container.js";
13
- import r from "./messages.js";
14
- import { jsxs as l, jsx as t, Fragment as Re } from "react/jsx-runtime";
15
- import { useFormValidation as Be } from "../../../hooks/use-form-validation.js";
16
- import { useCollaborationForm as ke } from "../../../hooks/use-collaboration-form.js";
17
- import { useUnifiedShareFormContext as Ve } from "../../../contexts/unified-share-form-context.js";
18
- import { useUnifiedShareModalContext as De } from "../../../contexts/unified-share-modal-context.js";
19
- import { parseEmails as Te } from "../../../utils/email.js";
20
- import { getNotificationArgs as Me } from "../../../utils/notification.js";
21
- import '../../../../../styles/collaboration-section.css';const ze = "_container_1e2gg_2", Ie = "_label_1e2gg_8", Oe = "_modernized_1e2gg_15", we = "_security_1e2gg_33", We = "_icon_1e2gg_37", je = "_access_1e2gg_43", c = {
22
- container: ze,
23
- label: Ie,
24
- modernized: Oe,
25
- security: we,
26
- icon: We,
27
- access: je
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 dt() {
29
+ function ut() {
30
30
  const {
31
31
  formatMessage: o
32
- } = ge(), [S, E] = fe(), {
33
- enableModernizedComponents: k
34
- } = Ce(), {
35
- addNotification: V
36
- } = ve(), {
37
- validateShieldRestriction: D
38
- } = Be(), {
39
- contactValue: T,
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: n,
41
+ form: r,
42
42
  setForm: d,
43
- setUserContacts: M,
44
- shieldRestriction: z,
45
- userContacts: i
46
- } = Ve(), {
47
- collaborationAccess: I,
43
+ setUserContacts: T,
44
+ shieldRestriction: I,
45
+ userContacts: a
46
+ } = De(), {
47
+ collaborationAccess: z,
48
48
  collaborationNotices: O,
49
- config: p,
49
+ config: m,
50
50
  contactService: w,
51
51
  isFetching: W,
52
- isSubmitting: m,
52
+ isSubmitting: u,
53
53
  item: j,
54
54
  onOpenChange: G,
55
55
  sharingService: q,
56
56
  variant: K
57
- } = De(), {
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, y;
68
- n === "invite" && (x = J, y = "invite-collaborators"), n === "email" && (x = Q, y = "email-shared-link");
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: X,
71
- handleFormReset: L,
72
- handleFormSubmit: Y,
73
- handleSelectedUsersChange: f,
74
- handleUserSelectorBlur: Z,
75
- updateContactValue: ee
76
- } = ke(x, y), te = K === "desktop", u = n === "default" || n === "invite", a = n === "invite" || n === "email", oe = i.some((e) => e.isExternalUser), N = he(n === "email" ? "email" : "invite");
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 = n === "email" ? "email" : "invite";
79
- }, [n]), R(() => {
80
- (!i.length || !i.some((e) => e.chipVariant === "error")) && E(null);
81
- }, [i]);
82
- const re = C((e) => (e.stopPropagation(), !0), []), ie = C((e) => _ ? _(e, N.current) : Promise.resolve([]), [_]), ne = C((e) => F ? F(e) : Promise.resolve({}), [F]), ae = (e) => {
83
- a || d("invite"), ee(e);
84
- }, se = C((e) => {
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
- Te(s).length !== 0 && (e.preventDefault(), a || d("invite"), f([...i, {
86
+ Ie(s).length !== 0 && (e.preventDefault(), n || d("invite"), p([...a, {
87
87
  value: s
88
88
  }]));
89
- }, [f, a, d, i]), le = () => {
90
- L(), d("default");
91
- }, ce = async () => {
89
+ }, [p, n, d, a]), de = () => {
90
+ y(), d("default");
91
+ }, me = async () => {
92
92
  try {
93
93
  if (S) {
94
- const e = D(i, z);
94
+ const e = V(a, I);
95
95
  if (e) {
96
- V({
97
- ...Me(o, "error"),
96
+ M({
97
+ ...ze(o, "error"),
98
98
  styledText: e
99
99
  });
100
100
  return;
101
101
  }
102
102
  }
103
- if (await Y())
103
+ if (await oe())
104
104
  return;
105
- L(), G(!1), d("default");
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 ?? []], ue = i.map((g) => P.includes(g.email) || P.includes(`${g.id}`) ? {
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
- E(s), M(ue);
115
+ L(s), T(pe);
116
116
  }
117
117
  };
118
- let h, b = !1;
119
- u && !$.canInviteCollaborator && (h = o(r.inviteDisabledTooltip), b = !0), u && H === "web_link" && (h = o(r.inviteWebLinkDisabledTooltip), b = !0);
120
- const A = Se("user-contacts-"), de = o(u ? r.invitePeopleLabel : r.emailSharedLinkLabel), me = Ue(de, 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(Ae, {
124
+ children: [S && /* @__PURE__ */ t(Re, {
125
125
  error: S,
126
- isLoading: m,
127
- onSelectedUsersChange: f
126
+ isLoading: u,
127
+ onSelectedUsersChange: p
128
128
  }), O, /* @__PURE__ */ l("div", {
129
- children: [u && p.collaborators && /* @__PURE__ */ t(Ne, {}), /* @__PURE__ */ t(me, {
130
- className: pe(c.label, k && c.modernized)
131
- }), /* @__PURE__ */ t(_e, {
132
- content: h,
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: h ? void 0 : !1,
134
+ open: f ? void 0 : !1,
135
135
  side: "bottom",
136
- children: /* @__PURE__ */ t(Fe, {
136
+ children: /* @__PURE__ */ t(Ee, {
137
137
  focusable: b,
138
- children: /* @__PURE__ */ t(Ee, {
138
+ children: /* @__PURE__ */ t(Ne, {
139
139
  className: "collaboration-user-selector",
140
- clearButtonAriaLabel: o(r.clearButton),
140
+ clearButtonAriaLabel: o(i.clearButton),
141
141
  clearOnBlur: !1,
142
142
  "data-target-id": "PillSelectorDropdown-AddNamesOrEmailAddresses",
143
- disabled: b || m,
143
+ disabled: b || u,
144
144
  displayChipVariant: (e) => e.chipVariant,
145
- error: X["user-contact"],
146
- fetchAvatarUrls: ne,
147
- fetchUsers: ie,
148
- hideOnEscape: re,
145
+ error: te["user-contact"],
146
+ fetchAvatarUrls: se,
147
+ fetchUsers: ne,
148
+ hideOnEscape: ae,
149
149
  idForLabel: A,
150
- inputValue: T,
150
+ inputValue: D,
151
151
  label: null,
152
- onBlur: Z,
153
- onInputValueChange: ae,
154
- onPaste: se,
155
- onSelectedUsersChange: f,
156
- placeholder: i.length ? "" : o(r.invitePeoplePlaceholder),
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: i,
158
+ selectedUsers: a,
159
159
  selectOnEnterOrTab: !0,
160
- variant: a ? "textarea" : "input"
160
+ variant: n ? "textarea" : "input"
161
161
  })
162
162
  })
163
- }), u && /* @__PURE__ */ l("div", {
163
+ }), h && /* @__PURE__ */ l("div", {
164
164
  className: c.access,
165
- children: [p.collaborationRole && /* @__PURE__ */ t(Le, {}), I]
165
+ children: [m.collaborationRole && /* @__PURE__ */ t(Ae, {}), z]
166
166
  })]
167
- }), a && p.collaborationMessage && /* @__PURE__ */ t(Pe, {
168
- maxCount: p.collaborationMessageLimit
169
- }), a && oe && /* @__PURE__ */ l("div", {
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: B,
174
- width: B
175
- }), /* @__PURE__ */ t(xe, {
173
+ height: k,
174
+ width: k
175
+ }), /* @__PURE__ */ t(Le, {
176
176
  as: "span",
177
177
  color: "textOnLightSecondary",
178
- children: o(r.contentSharedWithExternalCollaborators)
178
+ children: o(i.contentSharedWithExternalCollaborators)
179
179
  })]
180
- }), a && U && /* @__PURE__ */ be(/* @__PURE__ */ l(Re, {
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: m,
184
- onClick: le,
185
- children: o(r.cancelButton)
183
+ disabled: u,
184
+ onClick: de,
185
+ children: o(i.cancelButton)
186
186
  }), /* @__PURE__ */ t(v.Footer.PrimaryButton, {
187
- loading: m,
188
- loadingAriaLabel: o(r.loadingLabel),
189
- onClick: ce,
190
- children: o(r.sendButton)
187
+ loading: u,
188
+ loadingAriaLabel: o(i.loadingLabel),
189
+ onClick: me,
190
+ children: o(i.sendButton)
191
191
  })]
192
- }), !te && /* @__PURE__ */ t(v.Close, {
193
- "aria-label": o(r.closeButton),
194
- disabled: m
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
- dt as CollaborationSection
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
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@box/unified-share-modal",
3
- "version": "2.8.18",
3
+ "version": "2.9.0",
4
4
  "license": "SEE LICENSE IN LICENSE",
5
5
  "peerDependencies": {
6
6
  "@box/blueprint-web": "^13.9.4",