@box/unified-share-modal 2.13.12 → 2.14.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.
@@ -9,16 +9,16 @@ import { t as a } from "./collaboration-role.js";
9
9
  import { t as ne } from "./shared-with-avatars.js";
10
10
  import { t as re } from "./shield-restriction-notice.js";
11
11
  import { t as ie } from "./text-area-container.js";
12
- import { useCallback as o, useEffect as s, useRef as ae, useState as c } from "react";
13
- import l from "clsx";
14
- import { useIntl as u } from "react-intl";
15
- import { Focusable as d, Modal as f, Text as p, Tooltip as m, useBlueprintModernization as oe, useLabelable as se, useNotification as ce, useUniqueId as le } from "@box/blueprint-web";
16
- import { Fragment as ue, jsx as h, jsxs as g } from "react/jsx-runtime";
17
- import { createPortal as de } from "react-dom";
18
- import { Globe as fe } from "@box/blueprint-web-assets/icons/Medium";
19
- import { bpSize040 as _ } from "@box/blueprint-web-assets/tokens/tokens";
20
- import { UserSelectorContainer as pe } from "@box/user-selector";
21
- import '../styles/collaboration-section.css';var v = {
12
+ import { useCallback as o, useEffect as s, useRef as ae, useState as oe } from "react";
13
+ import c from "clsx";
14
+ import { useIntl as l } from "react-intl";
15
+ import { Focusable as u, Modal as d, Text as f, Tooltip as p, useBlueprintModernization as se, useLabelable as ce, useNotification as le, useUniqueId as ue } from "@box/blueprint-web";
16
+ import { Fragment as de, jsx as m, jsxs as h } from "react/jsx-runtime";
17
+ import { createPortal as fe } from "react-dom";
18
+ import { Globe as pe } from "@box/blueprint-web-assets/icons/Medium";
19
+ import { bpSize040 as g } from "@box/blueprint-web-assets/tokens/tokens";
20
+ import { UserSelectorContainer as me } from "@box/user-selector";
21
+ import '../styles/collaboration-section.css';var _ = {
22
22
  container: "_container_1e2gg_2",
23
23
  label: "_label_1e2gg_8",
24
24
  modernized: "_modernized_1e2gg_15",
@@ -26,131 +26,132 @@ import '../styles/collaboration-section.css';var v = {
26
26
  icon: "_icon_1e2gg_37",
27
27
  access: "_access_1e2gg_43"
28
28
  };
29
- function y() {
30
- let { formatMessage: y } = u(), [b, x] = c(), { enableModernizedComponents: S } = oe(), { addNotification: C } = ce(), { validateShieldRestriction: w } = ee(), { contactValue: T, containerRef: E, form: D, setForm: O, setUserContacts: k, shieldRestriction: A, userContacts: j } = r(), { collaborationAccess: M, collaborationNotices: N, config: P, contactService: F, isFetching: I, isSubmitting: L, item: R, onOpenChange: z, sharingService: B, variant: me } = e(), { permissions: he = {}, type: ge } = R, { getContacts: V, getContactsAvatarUrls: H } = F, { sendInvitations: _e, sendSharedLink: ve } = B, ye = me === "desktop", U = D === "default" || D === "invite", W = D === "invite" || D === "email", be = D === "invite" && P.collaborationMessage, xe = D === "email" && P.sharedLinkEmailMessage, Se = j.some((e) => e.isExternalUser), G, K;
31
- D === "invite" && (G = _e, K = "invite-collaborators"), D === "email" && (G = ve, K = "email-shared-link");
32
- let { errors: Ce, handleFormReset: q, handleFormSubmit: we, handleSelectedUsersChange: J, handleUserSelectorBlur: Te, updateContactValue: Ee } = te(G, K), Y = ae(D === "email" ? "email" : "invite");
29
+ function v() {
30
+ let { formatMessage: v } = l(), [y, b] = oe(), { enableModernizedComponents: x } = se(), { addNotification: S } = le(), { validateShieldRestriction: C } = ee(), { contactValue: w, containerRef: T, form: E, setForm: D, setUserContacts: O, shieldRestriction: k, userContacts: A } = r(), { collaborationAccess: j, collaborationNotices: M, config: N, contactService: P, isFetching: F, isSubmitting: I, item: L, onOpenChange: R, sharingService: z, variant: he } = e(), { permissions: B = {}, type: ge } = L, { getContacts: V, getContactsAvatarUrls: H } = P, { sendInvitations: _e, sendSharedLink: ve } = z, ye = he === "desktop", U = E === "default" || E === "invite", W = E === "invite" || E === "email", be = E === "invite" && N.collaborationMessage, xe = E === "email" && N.sharedLinkEmailMessage, Se = A.some((e) => e.isExternalUser), G, K;
31
+ E === "invite" && (G = _e, K = "invite-collaborators"), E === "email" && (G = ve, K = "email-shared-link");
32
+ let { errors: Ce, handleFormReset: q, handleFormSubmit: we, handleSelectedUsersChange: J, handleUserSelectorBlur: Te, updateContactValue: Ee } = te(G, K), Y = ae(E === "email" ? "email" : "invite");
33
33
  s(() => {
34
- Y.current = D === "email" ? "email" : "invite";
35
- }, [D]), s(() => {
36
- (!j.length || !j.some((e) => e.chipVariant === "error")) && x(null);
37
- }, [j]);
34
+ Y.current = E === "email" ? "email" : "invite";
35
+ }, [E]), s(() => {
36
+ (!A.length || !A.some((e) => e.chipVariant === "error")) && b(null);
37
+ }, [A]);
38
38
  let De = o((e) => (e.stopPropagation(), !0), []), Oe = o((e) => V ? V(e, Y.current) : Promise.resolve([]), [V]), ke = o((e) => H ? H(e) : Promise.resolve({}), [H]), Ae = (e) => {
39
- W || O("invite"), Ee(e);
39
+ W || D("invite"), Ee(e);
40
40
  }, X = o((e) => {
41
41
  let n = e.clipboardData.getData("text");
42
- t(n).length !== 0 && (e.preventDefault(), W || O("invite"), J([...j, { value: n }]));
42
+ t(n).length !== 0 && (e.preventDefault(), W || D("invite"), J([...A, { value: n }]));
43
43
  }, [
44
44
  J,
45
45
  W,
46
- O,
47
- j
46
+ D,
47
+ A
48
48
  ]), je = () => {
49
- q(), O("default");
49
+ q(), D("default");
50
50
  }, Me = async () => {
51
51
  try {
52
- if (b) {
53
- let e = w(j, A);
52
+ if (y) {
53
+ let e = C(A, k);
54
54
  if (e) {
55
- C({
56
- ...n(y, "error"),
55
+ S({
56
+ ...n(v, "error"),
57
57
  styledText: e
58
58
  });
59
59
  return;
60
60
  }
61
61
  }
62
62
  if (await we()) return;
63
- q(), z(!1), O("default");
63
+ q(), R(!1), D("default");
64
64
  } catch (e) {
65
65
  if (!e.shieldRestriction) return;
66
- let { shieldRestriction: t } = e, n = [...t.restrictedEmails ?? [], ...t.restrictedGroups ?? []], r = j.map((e) => n.includes(e.email) || n.includes(`${e.id}`) ? {
66
+ let { shieldRestriction: t } = e, n = [...t.restrictedEmails ?? [], ...t.restrictedGroups ?? []], r = A.map((e) => n.includes(e.email) || n.includes(`${e.id}`) ? {
67
67
  ...e,
68
68
  chipVariant: "error"
69
69
  } : e);
70
- x(t), k(r);
70
+ b(t), O(r);
71
71
  }
72
72
  }, Z, Q = !1;
73
- U && !he.canInviteCollaborator && (Z = y(i.inviteDisabledTooltip), Q = !0), U && ge === "web_link" && (Z = y(i.inviteWebLinkDisabledTooltip), Q = !0);
74
- let $ = le("usm-UserContacts-"), Ne = se(y(U ? i.invitePeopleLabel : i.emailSharedLinkLabel), $);
75
- return /* @__PURE__ */ g("form", {
76
- className: v.container,
73
+ U && !B.canInviteCollaborator && (Z = v(i.inviteDisabledTooltip), Q = !0), U && ge === "web_link" && (Z = v(i.inviteWebLinkDisabledTooltip), Q = !0);
74
+ let $ = ue("usm-UserContacts-"), Ne = ce(v(U ? i.invitePeopleLabel : i.emailSharedLinkLabel), $);
75
+ return /* @__PURE__ */ h("form", {
76
+ className: _.container,
77
77
  onSubmit: (e) => e.preventDefault(),
78
78
  children: [
79
- b && /* @__PURE__ */ h(re, {
80
- error: b,
81
- isLoading: L,
79
+ y && /* @__PURE__ */ m(re, {
80
+ error: y,
81
+ isLoading: I,
82
82
  onSelectedUsersChange: J
83
83
  }),
84
- N,
85
- /* @__PURE__ */ g("div", { children: [
86
- U && P.collaborators && /* @__PURE__ */ h(ne, {}),
87
- /* @__PURE__ */ h(Ne, { className: l(v.label, S && v.modernized) }),
88
- /* @__PURE__ */ h(m, {
84
+ M,
85
+ /* @__PURE__ */ h("div", { children: [
86
+ U && N.collaborators && /* @__PURE__ */ m(ne, {}),
87
+ /* @__PURE__ */ m(Ne, { className: c(_.label, x && _.modernized) }),
88
+ /* @__PURE__ */ m(p, {
89
89
  content: Z,
90
90
  "data-testid": "usm-UserContacts-tooltip",
91
91
  open: Z ? void 0 : !1,
92
92
  side: "bottom",
93
- children: /* @__PURE__ */ h(d, {
93
+ children: /* @__PURE__ */ m(u, {
94
94
  focusable: Q,
95
- children: /* @__PURE__ */ h(pe, {
95
+ children: /* @__PURE__ */ m(me, {
96
+ autoFocus: B.canInviteCollaborator,
96
97
  className: "usm-UserContacts-input",
97
- clearButtonAriaLabel: y(i.clearButton),
98
+ clearButtonAriaLabel: v(i.clearButton),
98
99
  clearOnBlur: !1,
99
100
  "data-target-id": "PillSelectorDropdown-AddNamesOrEmailAddresses",
100
- disabled: Q || L,
101
+ disabled: Q || I,
101
102
  displayChipVariant: (e) => e.chipVariant,
102
103
  error: Ce.userContacts,
103
104
  fetchAvatarUrls: ke,
104
105
  fetchUsers: Oe,
105
106
  hideOnEscape: De,
106
107
  idForLabel: $,
107
- inputValue: T,
108
+ inputValue: w,
108
109
  label: null,
109
110
  onBlur: Te,
110
111
  onInputValueChange: Ae,
111
112
  onPaste: X,
112
113
  onSelectedUsersChange: J,
113
- placeholder: j.length ? "" : y(i.invitePeoplePlaceholder),
114
- portalElement: E,
115
- selectedUsers: j,
114
+ placeholder: A.length ? "" : v(i.invitePeoplePlaceholder),
115
+ portalElement: T,
116
+ selectedUsers: A,
116
117
  selectOnEnterOrTab: !0,
117
118
  variant: W ? "textarea" : "input"
118
119
  })
119
120
  })
120
121
  }),
121
- U && /* @__PURE__ */ g("div", {
122
- className: v.access,
123
- children: [P.collaborationRole && /* @__PURE__ */ h(a, {}), M]
122
+ U && /* @__PURE__ */ h("div", {
123
+ className: _.access,
124
+ children: [N.collaborationRole && /* @__PURE__ */ m(a, {}), j]
124
125
  })
125
126
  ] }),
126
- (be || xe) && /* @__PURE__ */ h(ie, { maxCount: P.collaborationMessageLimit }),
127
- W && Se && /* @__PURE__ */ g("div", {
128
- className: v.security,
129
- children: [/* @__PURE__ */ h(fe, {
130
- className: v.icon,
131
- height: _,
132
- width: _
133
- }), /* @__PURE__ */ h(p, {
127
+ (be || xe) && /* @__PURE__ */ m(ie, { maxCount: N.collaborationMessageLimit }),
128
+ W && Se && /* @__PURE__ */ h("div", {
129
+ className: _.security,
130
+ children: [/* @__PURE__ */ m(pe, {
131
+ className: _.icon,
132
+ height: g,
133
+ width: g
134
+ }), /* @__PURE__ */ m(f, {
134
135
  as: "span",
135
136
  color: "textOnLightSecondary",
136
- children: y(i.contentSharedWithExternalCollaborators)
137
+ children: v(i.contentSharedWithExternalCollaborators)
137
138
  })]
138
139
  }),
139
- W && E && /* @__PURE__ */ de(/* @__PURE__ */ g(ue, { children: [!I && /* @__PURE__ */ g(f.Footer, { children: [/* @__PURE__ */ h(f.Footer.SecondaryButton, {
140
- disabled: L,
140
+ W && T && /* @__PURE__ */ fe(/* @__PURE__ */ h(de, { children: [!F && /* @__PURE__ */ h(d.Footer, { children: [/* @__PURE__ */ m(d.Footer.SecondaryButton, {
141
+ disabled: I,
141
142
  onClick: je,
142
- children: y(i.cancelButton)
143
- }), /* @__PURE__ */ h(f.Footer.PrimaryButton, {
143
+ children: v(i.cancelButton)
144
+ }), /* @__PURE__ */ m(d.Footer.PrimaryButton, {
144
145
  "data-target-id": "Modal.Footer.PrimaryButton-USMSendInvite",
145
- loading: L,
146
- loadingAriaLabel: y(i.loadingLabel),
146
+ loading: I,
147
+ loadingAriaLabel: v(i.loadingLabel),
147
148
  onClick: Me,
148
- children: y(i.sendButton)
149
- })] }), !ye && /* @__PURE__ */ h(f.Close, {
150
- "aria-label": y(i.closeButton),
151
- disabled: L
152
- })] }), E)
149
+ children: v(i.sendButton)
150
+ })] }), !ye && /* @__PURE__ */ m(d.Close, {
151
+ "aria-label": v(i.closeButton),
152
+ disabled: I
153
+ })] }), T)
153
154
  ]
154
155
  });
155
156
  }
156
- export { y as t };
157
+ export { v as t };
@@ -90,6 +90,7 @@ function T() {
90
90
  children: /* @__PURE__ */ _(te, {
91
91
  focusable: $,
92
92
  children: /* @__PURE__ */ _(re.Item, {
93
+ autoFocus: !B.canInviteCollaborator,
93
94
  checked: q,
94
95
  "data-target-id": "Toggle-CreateSharedLink",
95
96
  disabled: $ || F,