@box/unified-share-modal 1.7.0 → 1.7.2

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,27 +1,27 @@
1
- import { useMemo as H } from "react";
2
- import { useIntl as q } from "react-intl";
3
- import { Modal as r, Text as C, Link as G, Switch as h, DateI18nProvider as J, DatePicker as K, InlineNotice as E, TextInput as k } from "@box/blueprint-web";
1
+ import { useMemo as q } from "react";
2
+ import { useIntl as G } from "react-intl";
3
+ import { Modal as r, Text as y, Link as J, Switch as h, DateI18nProvider as K, DatePicker as Q, InlineNotice as E, TextInput as k } from "@box/blueprint-web";
4
4
  import e from "./messages.js";
5
5
  import { jsx as n, jsxs as d, Fragment as L } from "react/jsx-runtime";
6
- import { useAccessLevels as Q } from "../../hooks/use-access-levels.js";
7
- import { formatDateFromTimestampToCalendarDate as X, formatTomorrowDateToCalendarDate as Y } from "../../utils/date.js";
8
- import { useLinkSettingsForm as Z } from "../../hooks/use-link-settings-form.js";
9
- import { useUnifiedShareModalContext as aa } from "../../contexts/unified-share-modal-context.js";
10
- import '../../../../styles/shared-link-settings-modal.css';const ea = "_content_1wiic_1", na = "_body_1wiic_5", S = {
11
- content: ea,
12
- body: na
13
- }, ia = "••••••••";
14
- function ga({
6
+ import { useAccessLevels as X } from "../../hooks/use-access-levels.js";
7
+ import { formatDateFromTimestampToCalendarDate as Y, formatTomorrowDateToCalendarDate as Z } from "../../utils/date.js";
8
+ import { useLinkSettingsForm as aa } from "../../hooks/use-link-settings-form.js";
9
+ import { useUnifiedShareModalContext as ea } from "../../contexts/unified-share-modal-context.js";
10
+ import '../../../../styles/shared-link-settings-modal.css';const na = "_content_1wiic_1", ia = "_body_1wiic_5", S = {
11
+ content: na,
12
+ body: ia
13
+ }, oa = "••••••••";
14
+ function ba({
15
15
  isOpen: D,
16
- onOpenChange: m
16
+ onOpenChange: u
17
17
  }) {
18
18
  const {
19
19
  formatMessage: a
20
- } = q(), {
20
+ } = G(), {
21
21
  eventService: N,
22
22
  isSubmitting: P,
23
23
  sharedLink: f
24
- } = aa(), {
24
+ } = ea(), {
25
25
  expiresAt: c = 0,
26
26
  settings: i = {},
27
27
  vanityDomain: T = "",
@@ -29,9 +29,9 @@ function ga({
29
29
  } = f, {
30
30
  onSharedLinkSettingsClose: w
31
31
  } = N, {
32
- selectedAccess: b
33
- } = Q(), p = H(() => ({
34
- expiration: c ? X(c) : null,
32
+ selectedAccess: m
33
+ } = X(), b = q(() => ({
34
+ expiration: c ? Y(c) : null,
35
35
  isDownloadEnabled: !!i.isDownloadEnabled,
36
36
  isExpirationEnabled: !!c,
37
37
  isPasswordEnabled: !!i.isPasswordEnabled,
@@ -39,39 +39,40 @@ function ga({
39
39
  password: "",
40
40
  vanityName: g
41
41
  }), [c, i, g]), {
42
- errors: u,
42
+ errors: p,
43
43
  formData: t,
44
- handleFormReset: v,
45
- handleFormSubmit: A,
46
- isUpdating: I,
44
+ handleFormReset: A,
45
+ handleFormSubmit: I,
46
+ isUpdating: F,
47
+ setErrors: V,
47
48
  setFieldError: l,
48
49
  setFieldValue: s,
49
- validatePassword: F
50
- } = Z(p), V = () => {
51
- v(), w && w(), m(!1);
52
- }, B = async () => {
53
- await A() || (v(), m(!1));
54
- }, M = (o) => {
55
- l("expiration", void 0), s("isExpirationEnabled", o);
50
+ validatePassword: B
51
+ } = aa(b), v = () => {
52
+ A(), w && w(), u(!1);
53
+ }, M = async () => {
54
+ await I() || (V({}), u(!1));
56
55
  }, _ = (o) => {
56
+ l("expiration", void 0), s("isExpirationEnabled", o);
57
+ }, O = (o) => {
57
58
  l("expiration", void 0), s("expiration", o);
58
59
  }, U = (o) => {
59
60
  l("vanityName", void 0), s("isVanityNameEnabled", o);
60
- }, O = (o) => {
61
- l("vanityName", void 0), s("vanityName", o.target.value);
62
61
  }, R = (o) => {
63
- l("password", void 0), s("isPasswordEnabled", o);
62
+ l("vanityName", void 0), s("vanityName", o.target.value);
64
63
  }, W = (o) => {
65
- l("password", void 0), s("password", o.target.value);
64
+ l("password", void 0), s("isPasswordEnabled", o);
66
65
  }, j = (o) => {
67
- s("isDownloadEnabled", o);
66
+ l("password", void 0), s("password", o.target.value);
68
67
  }, $ = (o) => {
69
- var y;
70
- const z = (y = document.getElementById("usm-SharedLinkSettingsModal-primaryButton")) == null ? void 0 : y.contains(o.relatedTarget);
71
- p.isPasswordEnabled && !t.password || z || F(t.password);
72
- }, x = P || I;
68
+ s("isDownloadEnabled", o);
69
+ }, z = (o) => {
70
+ var C;
71
+ const H = (C = document.getElementById("usm-SharedLinkSettingsModal-primaryButton")) == null ? void 0 : C.contains(o.relatedTarget);
72
+ b.isPasswordEnabled && !t.password || H || B(t.password);
73
+ }, x = P || F;
73
74
  return /* @__PURE__ */ n(r, {
74
- onOpenChange: m,
75
+ onOpenChange: v,
75
76
  open: D,
76
77
  children: /* @__PURE__ */ d(r.Content, {
77
78
  className: S.content,
@@ -80,11 +81,11 @@ function ga({
80
81
  children: a(e.title)
81
82
  }), /* @__PURE__ */ d(r.Body, {
82
83
  className: S.body,
83
- children: [/* @__PURE__ */ n(C, {
84
+ children: [/* @__PURE__ */ n(y, {
84
85
  as: "p",
85
86
  color: "textOnLightSecondary",
86
87
  children: a(e.subtitle, {
87
- learnSharedLinkSettingsLink: /* @__PURE__ */ n(G, {
88
+ learnSharedLinkSettingsLink: /* @__PURE__ */ n(J, {
88
89
  href: "https://support.box.com/hc/en-us/articles/360043697554-Configuring-Individual-Shared-Link-Settings",
89
90
  rel: "noreferrer",
90
91
  target: "_blank",
@@ -95,30 +96,30 @@ function ga({
95
96
  checked: t.isExpirationEnabled,
96
97
  disabled: !i.canChangeExpiration,
97
98
  label: a(e.linkExpirationToggleText),
98
- onCheckedChange: M,
99
+ onCheckedChange: _,
99
100
  value: "link-expiration-settings"
100
101
  }), t.isExpirationEnabled && // Get the locale from the user's operating system settings
101
- /* @__PURE__ */ n(J, {
102
+ /* @__PURE__ */ n(K, {
102
103
  locale: navigator.language || "en-US",
103
- children: /* @__PURE__ */ n(K, {
104
+ children: /* @__PURE__ */ n(Q, {
104
105
  calendarAriaLabel: a(e.linkExpirationCalendarAriaLabel),
105
106
  clearDatePickerAriaLabel: a(e.linkExpirationClearDatePickerAriaLabel),
106
- error: u.expiration,
107
+ error: p.expiration,
107
108
  hideLabel: !0,
108
109
  isDisabled: !i.canChangeExpiration,
109
110
  label: a(e.linkExpirationDatePickerLabel),
110
- minValue: Y(),
111
+ minValue: Z(),
111
112
  nextMonthAriaLabel: a(e.linkExpirationNextMonthAriaLabel),
112
- onChange: _,
113
+ onChange: O,
113
114
  openCalendarDropdownAriaLabel: a(e.linkExpirationOpenCalendarDropdownAriaLabel),
114
115
  previousMonthAriaLabel: a(e.linkExpirationPreviousMonthAriaLabel),
115
116
  value: t.expiration
116
117
  })
117
- }), i.isPasswordAvailable && (b == null ? void 0 : b.id) === "open" && /* @__PURE__ */ n(h.Item, {
118
+ }), i.isPasswordAvailable && (m == null ? void 0 : m.id) === "open" && /* @__PURE__ */ n(h.Item, {
118
119
  checked: t.isPasswordEnabled,
119
120
  disabled: !i.canChangePassword,
120
121
  label: a(e.passwordToggleText),
121
- onCheckedChange: R,
122
+ onCheckedChange: W,
122
123
  value: "password-settings"
123
124
  }), t.isPasswordEnabled && /* @__PURE__ */ d(L, {
124
125
  children: [i.canChangePassword && /* @__PURE__ */ n(E, {
@@ -127,13 +128,13 @@ function ga({
127
128
  children: a(e.passwordWarningText)
128
129
  }), /* @__PURE__ */ n(k, {
129
130
  disabled: !i.canChangePassword,
130
- error: u.password,
131
+ error: p.password,
131
132
  hideLabel: !0,
132
133
  label: a(e.passwordToggleText),
133
- onBlur: $,
134
- onChange: W,
134
+ onBlur: z,
135
+ onChange: j,
135
136
  onFocus: () => l("password", void 0),
136
- placeholder: p.isPasswordEnabled ? ia : a(e.passwordInputPlaceholder),
137
+ placeholder: b.isPasswordEnabled ? oa : a(e.passwordInputPlaceholder),
137
138
  type: "password",
138
139
  value: t.password
139
140
  })]
@@ -150,13 +151,13 @@ function ga({
150
151
  children: a(e.vanityDomainSettingsWarningText)
151
152
  }), /* @__PURE__ */ n(k, {
152
153
  disabled: !i.canChangeVanityName,
153
- error: u.vanityName,
154
+ error: p.vanityName,
154
155
  hideLabel: !0,
155
156
  label: a(e.vanityNameInputLabel),
156
- onChange: O,
157
+ onChange: R,
157
158
  placeholder: a(e.vanityNameInputPlaceholder),
158
159
  value: t.vanityName
159
- }), i.canChangeVanityName && /* @__PURE__ */ n(C, {
160
+ }), i.canChangeVanityName && /* @__PURE__ */ n(y, {
160
161
  as: "p",
161
162
  children: `${T}${t.vanityName}`
162
163
  })]
@@ -164,19 +165,19 @@ function ga({
164
165
  checked: t.isDownloadEnabled,
165
166
  disabled: !i.canChangeDownload,
166
167
  label: a(e.downloadSettingsToggleText),
167
- onCheckedChange: j,
168
+ onCheckedChange: $,
168
169
  value: "download-link-settings"
169
170
  })]
170
171
  }), /* @__PURE__ */ d(r.Footer, {
171
172
  children: [/* @__PURE__ */ n(r.Footer.SecondaryButton, {
172
173
  disabled: x,
173
- onClick: V,
174
+ onClick: v,
174
175
  children: a(e.cancelButton)
175
176
  }), /* @__PURE__ */ n(r.Footer.PrimaryButton, {
176
177
  id: "usm-SharedLinkSettingsModal-primaryButton",
177
178
  loading: x,
178
179
  loadingAriaLabel: a(e.loadingLabel),
179
- onClick: B,
180
+ onClick: M,
180
181
  children: a(e.saveButton)
181
182
  })]
182
183
  }), /* @__PURE__ */ n(r.Close, {
@@ -186,5 +187,5 @@ function ga({
186
187
  });
187
188
  }
188
189
  export {
189
- ga as SharedLinkSettingsModal
190
+ ba as SharedLinkSettingsModal
190
191
  };
@@ -1,66 +1,68 @@
1
- import { useState as A, useEffect as C, useCallback as c } from "react";
2
- import { useFormValidation as F } from "./use-form-validation.js";
3
- import { useSharingAction as j } from "./use-sharing-action.js";
4
- import { getUpdatedLinkSettingsFormData as M } from "../utils/form.js";
5
- import { useUnifiedShareModalContext as O } from "../contexts/unified-share-modal-context.js";
6
- const H = (r) => {
7
- const [s, o] = A(r), {
8
- errors: E,
9
- setErrors: e,
1
+ import A from "lodash/isEqual";
2
+ import { useState as C, useRef as j, useEffect as q, useCallback as i } from "react";
3
+ import { useFormValidation as I } from "./use-form-validation.js";
4
+ import { useSharingAction as M } from "./use-sharing-action.js";
5
+ import { getUpdatedLinkSettingsFormData as O } from "../utils/form.js";
6
+ import { useUnifiedShareModalContext as z } from "../contexts/unified-share-modal-context.js";
7
+ const Q = (e) => {
8
+ const [s, o] = C(e), u = j(e), {
9
+ errors: h,
10
+ setErrors: r,
10
11
  setFieldError: n,
11
- validateExpiration: u,
12
+ validateExpiration: p,
12
13
  validatePassword: a,
13
- validateVanityName: p
14
- } = F(), {
15
- sharingService: f
16
- } = O(), {
17
- updateSharedLink: h
18
- } = f, {
14
+ validateVanityName: f
15
+ } = I(), {
16
+ sharingService: E
17
+ } = z(), {
18
+ updateSharedLink: g
19
+ } = E, {
19
20
  isLoading: l,
20
21
  onAction: m
21
- } = j(h, "update-shared-link");
22
- C(() => {
23
- o(r), e({});
24
- }, [r, e]);
25
- const S = c((t, d) => {
26
- o((i) => ({
27
- ...i,
28
- [t]: d
22
+ } = M(g, "update-shared-link");
23
+ q(() => {
24
+ !A(u.current, e) && (o(e), r({}), u.current = e);
25
+ }, [e, r]);
26
+ const S = i((t, c) => {
27
+ o((d) => ({
28
+ ...d,
29
+ [t]: c
29
30
  }));
30
- }, []), g = c(() => {
31
- o(r), e({});
32
- }, [r, e]), b = c(async () => {
33
- const t = M(s, r), {
34
- expiration: d,
35
- isExpirationEnabled: i,
31
+ }, []), b = i(() => {
32
+ o(e), r({});
33
+ }, [e, r]), v = i(async () => {
34
+ const t = O(s, e), {
35
+ expiration: c,
36
+ isExpirationEnabled: d,
36
37
  isPasswordEnabled: x,
37
38
  isVanityNameEnabled: y,
38
39
  password: k,
39
- vanityName: v
40
- } = t, w = i && u(d), V = x && a(k), L = y && p(v);
41
- if (w || V || L)
40
+ vanityName: w
41
+ } = t, V = d && p(c), L = x && a(k), N = y && f(w);
42
+ if (V || L || N)
42
43
  return !0;
43
44
  try {
44
45
  await m({
45
- ...r,
46
+ ...e,
46
47
  ...t
47
48
  });
48
- } catch (N) {
49
- return Object.entries(N).forEach(([U, P]) => n(U, P)), !0;
49
+ } catch (U) {
50
+ return Object.entries(U).forEach(([P, R]) => n(P, R)), !0;
50
51
  }
51
52
  return !1;
52
- }, [s, r, m, n, u, a, p]);
53
+ }, [s, e, m, n, p, a, f]);
53
54
  return {
54
- errors: E,
55
+ errors: h,
55
56
  formData: s,
56
- handleFormReset: g,
57
- handleFormSubmit: b,
57
+ handleFormReset: b,
58
+ handleFormSubmit: v,
58
59
  isUpdating: l,
60
+ setErrors: r,
59
61
  setFieldError: n,
60
62
  setFieldValue: S,
61
63
  validatePassword: a
62
64
  };
63
65
  };
64
66
  export {
65
- H as useLinkSettingsForm
67
+ Q as useLinkSettingsForm
66
68
  };
@@ -5,6 +5,7 @@ export declare const useLinkSettingsForm: (initialFormData: LinkSettingsFormData
5
5
  handleFormReset: () => void;
6
6
  handleFormSubmit: () => Promise<boolean>;
7
7
  isUpdating: boolean;
8
+ setErrors: import('react').Dispatch<import('react').SetStateAction<import('./use-form-validation').FormErrors>>;
8
9
  setFieldError: (field: any, error: any) => void;
9
10
  setFieldValue: (field: any, value: any) => void;
10
11
  validatePassword: (password: string) => boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@box/unified-share-modal",
3
- "version": "1.7.0",
3
+ "version": "1.7.2",
4
4
  "license": "SEE LICENSE IN LICENSE",
5
5
  "peerDependencies": {
6
6
  "@box/blueprint-web": "^9.18.13",
@@ -13,10 +13,10 @@
13
13
  "react-intl": "^6.4.2"
14
14
  },
15
15
  "devDependencies": {
16
- "@box/blueprint-web": "^12.93.0",
17
- "@box/blueprint-web-assets": "^4.77.0",
18
- "@box/copy-input": "^1.6.0",
19
- "@box/storybook-utils": "0.14.14",
16
+ "@box/blueprint-web": "^12.93.1",
17
+ "@box/blueprint-web-assets": "^4.78.0",
18
+ "@box/copy-input": "^1.6.1",
19
+ "@box/storybook-utils": "0.14.15",
20
20
  "@box/eslint-plugin-blueprint": "1.0.5",
21
21
  "react-intl": "^6.4.2"
22
22
  },