@box/unified-share-modal 1.33.0 → 1.35.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,155 +1,168 @@
1
- import { useMemo as U } from "react";
2
- import { useIntl as z } from "react-intl";
3
- import { Modal as i, Text as H, Link as R } from "@box/blueprint-web";
4
- import { DownloadSection as q } from "./download-section.js";
5
- import { ExpirationSection as G } from "./expiration-section.js";
6
- import { PasswordSection as J } from "./password-section.js";
7
- import { VanitySection as K } from "./vanity-section.js";
8
- import d from "./messages.js";
9
- import { jsx as a, jsxs as p } from "react/jsx-runtime";
10
- import { useAccessLevels as Q } from "../../hooks/use-access-levels.js";
11
- import { formatDateFromTimestampToCalendarDate as W } from "../../utils/date.js";
12
- import { useLinkSettingsForm as X } from "../../hooks/use-link-settings-form.js";
13
- import { useUnifiedShareModalContext as Y } from "../../contexts/unified-share-modal-context.js";
14
- import '../../../../styles/shared-link-settings-modal.css';const Z = "_content_1wiic_1", $ = "_body_1wiic_5", v = {
15
- content: Z,
16
- body: $
1
+ import { useState as q, useMemo as G, useEffect as J } from "react";
2
+ import { useIntl as K } from "react-intl";
3
+ import { Modal as t, LoadingIndicator as Q, Text as W, Link as X } from "@box/blueprint-web";
4
+ import { DownloadSection as Y } from "./download-section.js";
5
+ import { ExpirationSection as Z } from "./expiration-section.js";
6
+ import { PasswordSection as $ } from "./password-section.js";
7
+ import { VanitySection as O } from "./vanity-section.js";
8
+ import s from "./messages.js";
9
+ import { jsx as a, jsxs as w } from "react/jsx-runtime";
10
+ import { useAccessLevels as ee } from "../../hooks/use-access-levels.js";
11
+ import { formatDateFromTimestampToCalendarDate as ae } from "../../utils/date.js";
12
+ import { useLinkSettingsForm as ne } from "../../hooks/use-link-settings-form.js";
13
+ import { useUnifiedShareModalContext as oe } from "../../contexts/unified-share-modal-context.js";
14
+ import '../../../../styles/shared-link-settings-modal.css';const ie = "_content_1r0kk_1", te = "_body_1r0kk_5", se = "_loading_1r0kk_17", f = {
15
+ content: ie,
16
+ body: te,
17
+ loading: se
17
18
  };
18
- function he({
19
- isOpen: y,
20
- onOpenChange: b
19
+ function ye({
20
+ isOpen: c,
21
+ onOpenChange: v
21
22
  }) {
22
23
  const {
23
- formatMessage: s
24
- } = z(), {
25
- eventService: C,
26
- isSubmitting: f,
27
- sharedLink: S
28
- } = Y(), {
29
- expiresAt: c = 0,
24
+ formatMessage: i
25
+ } = K(), [g, C] = q(!1), {
26
+ eventService: k,
27
+ isSubmitting: E,
28
+ sharedLink: x
29
+ } = oe(), {
30
+ expiresAt: m = 0,
30
31
  settings: n = {},
31
- vanityDomain: E = "",
32
- vanityName: m = ""
33
- } = S, {
34
- onSharedLinkSettingsClose: u
35
- } = C, {
36
- selectedAccess: x
37
- } = Q(), g = U(() => ({
38
- expiration: c ? W(c) : null,
32
+ vanityDomain: L = "",
33
+ vanityName: h = ""
34
+ } = x, {
35
+ onSharedLinkSettingsClose: y,
36
+ onSharedLinkSettingsLoad: p
37
+ } = k, {
38
+ selectedAccess: D
39
+ } = ee(), b = G(() => ({
40
+ expiration: m ? ae(m) : null,
39
41
  isDownloadEnabled: !!n.isDownloadEnabled,
40
- isExpirationEnabled: !!c,
42
+ isExpirationEnabled: !!m,
41
43
  isPasswordEnabled: !!n.isPasswordEnabled,
42
- isVanityNameEnabled: !!m,
44
+ isVanityNameEnabled: !!h,
43
45
  password: "",
44
- vanityName: m
45
- }), [c, n, m]), {
46
- errors: h,
46
+ vanityName: h
47
+ }), [m, n, h]), {
48
+ errors: u,
47
49
  formData: o,
48
- handleFormReset: k,
49
- handleFormSubmit: D,
50
- isUpdating: L,
51
- setErrors: N,
52
- setFieldError: t,
53
- setFieldValue: r,
54
- validatePassword: P
55
- } = X(g), w = () => {
56
- k(), u && u(), b(!1);
57
- }, F = async () => {
58
- await D() || (N({}), b(!1));
59
- }, T = (e) => {
60
- t("expiration", void 0), r("isExpirationEnabled", e);
61
- }, B = (e) => {
62
- t("expiration", void 0), r("expiration", e);
63
- }, A = (e) => {
64
- t("vanityName", void 0), r("isVanityNameEnabled", e);
50
+ handleFormReset: N,
51
+ handleFormSubmit: F,
52
+ isUpdating: P,
53
+ setErrors: T,
54
+ setFieldError: r,
55
+ setFieldValue: d,
56
+ validatePassword: B
57
+ } = ne(b);
58
+ J(() => {
59
+ (async () => p && (c && await p(), C(!c)))();
60
+ }, [c, p]);
61
+ const S = () => {
62
+ N(), y && y(), v(!1);
63
+ }, A = async () => {
64
+ await F() || (T({}), v(!1));
65
+ }, _ = (e) => {
66
+ r("expiration", void 0), d("isExpirationEnabled", e);
65
67
  }, V = (e) => {
66
- t("vanityName", void 0), r("vanityName", e.target.value);
68
+ r("expiration", void 0), d("expiration", e);
67
69
  }, M = (e) => {
68
- t("password", void 0), r("isPasswordEnabled", e);
69
- }, _ = (e) => {
70
- t("password", void 0), r("password", e.target.value);
70
+ r("vanityName", void 0), d("isVanityNameEnabled", e);
71
71
  }, I = (e) => {
72
- r("isDownloadEnabled", e);
72
+ r("vanityName", void 0), d("vanityName", e.target.value);
73
73
  }, j = (e) => {
74
- const O = document.getElementById("usm-SharedLinkSettingsModal-primaryButton")?.contains(e.relatedTarget);
75
- g.isPasswordEnabled && !o.password || O || P(o.password);
76
- }, l = f || L;
77
- return /* @__PURE__ */ a(i, {
78
- onOpenChange: w,
79
- open: y,
80
- children: /* @__PURE__ */ p(i.Content, {
81
- className: v.content,
74
+ r("password", void 0), d("isPasswordEnabled", e);
75
+ }, z = (e) => {
76
+ r("password", void 0), d("password", e.target.value);
77
+ }, U = (e) => {
78
+ d("isDownloadEnabled", e);
79
+ }, H = (e) => {
80
+ const R = document.getElementById("usm-SharedLinkSettingsModal-primaryButton")?.contains(e.relatedTarget);
81
+ b.isPasswordEnabled && !o.password || R || B(o.password);
82
+ }, l = E || P;
83
+ return /* @__PURE__ */ a(t, {
84
+ onOpenChange: S,
85
+ open: c,
86
+ children: /* @__PURE__ */ w(t.Content, {
87
+ className: f.content,
82
88
  size: "medium",
83
- children: [/* @__PURE__ */ a(i.Header, {
84
- children: s(d.title)
85
- }), /* @__PURE__ */ p(i.Body, {
86
- className: v.body,
87
- children: [/* @__PURE__ */ a(H, {
89
+ children: [/* @__PURE__ */ a(t.Header, {
90
+ children: i(s.title)
91
+ }), /* @__PURE__ */ w(t.Body, {
92
+ className: f.body,
93
+ inert: g ? "" : null,
94
+ children: [g && /* @__PURE__ */ a("div", {
95
+ className: f.loading,
96
+ children: /* @__PURE__ */ a(Q, {
97
+ "aria-label": i(s.loadingLabel),
98
+ size: "large"
99
+ })
100
+ }), /* @__PURE__ */ a(W, {
88
101
  as: "p",
89
102
  color: "textOnLightSecondary",
90
- children: s(d.subtitle, {
91
- learnSharedLinkSettingsLink: /* @__PURE__ */ a(R, {
103
+ children: i(s.subtitle, {
104
+ learnSharedLinkSettingsLink: /* @__PURE__ */ a(X, {
92
105
  href: "https://support.box.com/hc/en-us/articles/360043697554-Configuring-Individual-Shared-Link-Settings",
93
106
  rel: "noreferrer",
94
107
  target: "_blank",
95
- children: s(d.learnSharedLinkSettingsLink)
108
+ children: i(s.learnSharedLinkSettingsLink)
96
109
  })
97
110
  })
98
- }), /* @__PURE__ */ a(G, {
111
+ }), /* @__PURE__ */ a(Z, {
99
112
  canChange: !!n.canChangeExpiration,
100
- error: h.expiration,
113
+ error: u.expiration,
101
114
  expiration: o.expiration,
102
115
  isChecked: o.isExpirationEnabled,
103
116
  isDisabled: l,
104
- onChange: B,
105
- onToggle: T
106
- }), /* @__PURE__ */ a(J, {
117
+ onChange: V,
118
+ onToggle: _
119
+ }), /* @__PURE__ */ a($, {
107
120
  canChange: !!n.canChangePassword,
108
- error: h.password,
109
- isAvailable: n.isPasswordAvailable && x?.id === "open",
121
+ error: u.password,
122
+ isAvailable: n.isPasswordAvailable && D?.id === "open",
110
123
  isChecked: o.isPasswordEnabled,
111
- isDefaultChecked: g.isPasswordEnabled,
124
+ isDefaultChecked: b.isPasswordEnabled,
112
125
  isDisabled: l,
113
- onBlur: j,
114
- onChange: _,
115
- onFocus: () => t("password", void 0),
116
- onToggle: M,
126
+ onBlur: H,
127
+ onChange: z,
128
+ onFocus: () => r("password", void 0),
129
+ onToggle: j,
117
130
  password: o.password
118
- }), /* @__PURE__ */ a(K, {
131
+ }), /* @__PURE__ */ a(O, {
119
132
  canChange: !!n.canChangeVanityName,
120
- error: h.vanityName,
133
+ error: u.vanityName,
121
134
  isAvailable: !!n.isVanityNameAvailable,
122
135
  isChecked: o.isVanityNameEnabled,
123
136
  isDisabled: l,
124
- onChange: V,
125
- onToggle: A,
126
- vanityDomain: E,
137
+ onChange: I,
138
+ onToggle: M,
139
+ vanityDomain: L,
127
140
  vanityName: o.vanityName
128
- }), /* @__PURE__ */ a(q, {
141
+ }), /* @__PURE__ */ a(Y, {
129
142
  canChange: !!n.canChangeDownload,
130
143
  isAvailable: !!n.isDownloadAvailable,
131
144
  isChecked: o.isDownloadEnabled,
132
145
  isDisabled: l,
133
- onToggle: I
146
+ onToggle: U
134
147
  })]
135
- }), /* @__PURE__ */ p(i.Footer, {
136
- children: [/* @__PURE__ */ a(i.Footer.SecondaryButton, {
148
+ }), !g && /* @__PURE__ */ w(t.Footer, {
149
+ children: [/* @__PURE__ */ a(t.Footer.SecondaryButton, {
137
150
  disabled: l,
138
- onClick: w,
139
- children: s(d.cancelButton)
140
- }), /* @__PURE__ */ a(i.Footer.PrimaryButton, {
151
+ onClick: S,
152
+ children: i(s.cancelButton)
153
+ }), /* @__PURE__ */ a(t.Footer.PrimaryButton, {
141
154
  id: "usm-SharedLinkSettingsModal-primaryButton",
142
155
  loading: l,
143
- loadingAriaLabel: s(d.loadingLabel),
144
- onClick: F,
145
- children: s(d.saveButton)
156
+ loadingAriaLabel: i(s.loadingLabel),
157
+ onClick: A,
158
+ children: i(s.saveButton)
146
159
  })]
147
- }), /* @__PURE__ */ a(i.Close, {
148
- "aria-label": s(d.closeButton)
160
+ }), /* @__PURE__ */ a(t.Close, {
161
+ "aria-label": i(s.closeButton)
149
162
  })]
150
163
  })
151
164
  });
152
165
  }
153
166
  export {
154
- he as SharedLinkSettingsModal
167
+ ye as SharedLinkSettingsModal
155
168
  };
@@ -1,66 +1,66 @@
1
1
  import _ from "clsx";
2
- import y from "lodash/camelCase";
3
- import { useState as L, useMemo as k, useEffect as F } from "react";
4
- import { useIntl as N } from "react-intl";
5
- import { Tooltip as O, Focusable as $, TriggerButton as D, DropdownMenu as r } from "@box/blueprint-web";
6
- import j from "../messages.js";
2
+ import L from "lodash/camelCase";
3
+ import { useState as k, useMemo as w, useEffect as q } from "react";
4
+ import { useIntl as F } from "react-intl";
5
+ import { Tooltip as N, Focusable as O, TriggerButton as D, DropdownMenu as r } from "@box/blueprint-web";
6
+ import $ from "../messages.js";
7
7
  import n from "./messages.js";
8
- import { jsx as e, jsxs as z } from "react/jsx-runtime";
9
- import { isInvitationRoleSupported as A, getDefaultCollaborationRole as P } from "../../../utils/collaborator.js";
10
- import { useUnifiedShareFormContext as U } from "../../../contexts/unified-share-form-context.js";
11
- import { useUnifiedShareModalContext as B } from "../../../contexts/unified-share-modal-context.js";
12
- import '../../../../../styles/collaboration-role.css';const E = "_container_xvspw_1", W = "_overrides_xvspw_5", q = "_focusable_xvspw_10", s = {
13
- container: E,
14
- overrides: W,
15
- focusable: q
8
+ import { jsx as e, jsxs as j } from "react/jsx-runtime";
9
+ import { isInvitationRoleSupported as z, getDefaultCollaborationRole as A } from "../../../utils/collaborator.js";
10
+ import { useUnifiedShareFormContext as P } from "../../../contexts/unified-share-form-context.js";
11
+ import { useUnifiedShareModalContext as U } from "../../../contexts/unified-share-modal-context.js";
12
+ import '../../../../../styles/collaboration-role.css';const B = "_container_1fonq_1", E = "_overrides_1fonq_4", W = "_focusable_1fonq_9", l = {
13
+ container: B,
14
+ overrides: E,
15
+ focusable: W
16
16
  };
17
17
  function te() {
18
18
  const {
19
19
  formatMessage: o
20
- } = N(), [f, M] = L(!1), {
20
+ } = F(), [b, M] = k(!1), {
21
21
  collaborationRole: u,
22
22
  setCollaborationRole: d
23
- } = U(), {
23
+ } = P(), {
24
24
  collaborationRoles: g,
25
25
  isSubmitting: S,
26
- item: w
27
- } = B(), {
28
- permissions: I = {},
26
+ item: I
27
+ } = U(), {
28
+ permissions: T = {},
29
29
  type: m
30
- } = w, l = k(() => g.map((i) => {
30
+ } = I, s = w(() => g.map((i) => {
31
31
  const {
32
32
  description: p,
33
33
  id: t,
34
34
  label: c
35
- } = i, b = A(t), x = y(t);
36
- let h = x;
37
- t === "editor" && m === "folder" && (h += "Folder");
35
+ } = i, f = z(t), h = L(t);
36
+ let x = h;
37
+ t === "editor" && m === "folder" && (x += "Folder");
38
38
  let C = t, R = "";
39
- return b && (C = o(j[`${x}Role`]), R = o(n[`${h}Description`])), {
39
+ return f && (C = o($[`${h}Role`]), R = o(n[`${x}Description`])), {
40
40
  ...i,
41
41
  description: p ?? R,
42
42
  label: c ?? C
43
43
  };
44
44
  }), [g, o, m]);
45
- if (F(() => {
46
- d(P(l));
47
- }, [l, d]), !l.length || !u)
45
+ if (q(() => {
46
+ d(A(s));
47
+ }, [s, d]), !s.length || !u)
48
48
  return null;
49
49
  const {
50
- id: T,
50
+ id: y,
51
51
  label: v
52
52
  } = u;
53
53
  let a;
54
- return I.canInviteCollaborator || (a = o(n.inviteDisabledTooltip)), m === "web_link" && (a = o(n.inviteWebLinkDisabledTooltip)), a ? /* @__PURE__ */ e(O, {
54
+ return T.canInviteCollaborator || (a = o(n.inviteDisabledTooltip)), m === "web_link" && (a = o(n.inviteWebLinkDisabledTooltip)), a ? /* @__PURE__ */ e(N, {
55
55
  align: "start",
56
56
  content: a,
57
57
  "data-testid": "collaboration-role-tooltip",
58
58
  side: "bottom",
59
- children: /* @__PURE__ */ e($, {
60
- className: s.focusable,
59
+ children: /* @__PURE__ */ e(O, {
60
+ className: l.focusable,
61
61
  children: /* @__PURE__ */ e(D, {
62
62
  caretDirection: "down",
63
- className: _(s.container, s.overrides),
63
+ className: _(l.container, l.overrides),
64
64
  disabled: !0,
65
65
  label: o(n.inviteAsRoleLabel, {
66
66
  role: v
@@ -69,13 +69,13 @@ function te() {
69
69
  variant: "tertiary"
70
70
  })
71
71
  })
72
- }) : /* @__PURE__ */ z(r.Root, {
72
+ }) : /* @__PURE__ */ j(r.Root, {
73
73
  onOpenChange: M,
74
- open: f,
74
+ open: b,
75
75
  children: [/* @__PURE__ */ e(r.Trigger, {
76
76
  children: /* @__PURE__ */ e(D, {
77
- caretDirection: f ? "up" : "down",
78
- className: _(s.container, s.overrides),
77
+ caretDirection: b ? "up" : "down",
78
+ className: _(l.container, l.overrides),
79
79
  disabled: S,
80
80
  label: o(n.inviteAsRoleLabel, {
81
81
  role: v
@@ -85,20 +85,20 @@ function te() {
85
85
  })
86
86
  }), /* @__PURE__ */ e(r.Content, {
87
87
  align: "start",
88
- children: l.map((i) => {
88
+ children: s.map((i) => {
89
89
  const {
90
90
  description: p,
91
91
  isDisabled: t,
92
92
  id: c,
93
- label: b
93
+ label: f
94
94
  } = i;
95
95
  return /* @__PURE__ */ e(r.CheckboxItem, {
96
- checked: T === c,
96
+ checked: y === c,
97
97
  disabled: t,
98
98
  onSelect: () => d(i),
99
99
  children: /* @__PURE__ */ e(r.Item.MainContent, {
100
100
  caption: p,
101
- label: b
101
+ label: f
102
102
  })
103
103
  }, c);
104
104
  })