@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
|
|
2
|
-
import { useIntl as
|
|
3
|
-
import { Modal as r, Text as
|
|
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
|
|
7
|
-
import { formatDateFromTimestampToCalendarDate as
|
|
8
|
-
import { useLinkSettingsForm as
|
|
9
|
-
import { useUnifiedShareModalContext as
|
|
10
|
-
import '../../../../styles/shared-link-settings-modal.css';const
|
|
11
|
-
content:
|
|
12
|
-
body:
|
|
13
|
-
},
|
|
14
|
-
function
|
|
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:
|
|
16
|
+
onOpenChange: u
|
|
17
17
|
}) {
|
|
18
18
|
const {
|
|
19
19
|
formatMessage: a
|
|
20
|
-
} =
|
|
20
|
+
} = G(), {
|
|
21
21
|
eventService: N,
|
|
22
22
|
isSubmitting: P,
|
|
23
23
|
sharedLink: f
|
|
24
|
-
} =
|
|
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:
|
|
33
|
-
} =
|
|
34
|
-
expiration: c ?
|
|
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:
|
|
42
|
+
errors: p,
|
|
43
43
|
formData: t,
|
|
44
|
-
handleFormReset:
|
|
45
|
-
handleFormSubmit:
|
|
46
|
-
isUpdating:
|
|
44
|
+
handleFormReset: A,
|
|
45
|
+
handleFormSubmit: I,
|
|
46
|
+
isUpdating: F,
|
|
47
|
+
setErrors: V,
|
|
47
48
|
setFieldError: l,
|
|
48
49
|
setFieldValue: s,
|
|
49
|
-
validatePassword:
|
|
50
|
-
} =
|
|
51
|
-
|
|
52
|
-
},
|
|
53
|
-
await
|
|
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("
|
|
62
|
+
l("vanityName", void 0), s("vanityName", o.target.value);
|
|
64
63
|
}, W = (o) => {
|
|
65
|
-
l("password", void 0), s("
|
|
64
|
+
l("password", void 0), s("isPasswordEnabled", o);
|
|
66
65
|
}, j = (o) => {
|
|
67
|
-
s("
|
|
66
|
+
l("password", void 0), s("password", o.target.value);
|
|
68
67
|
}, $ = (o) => {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
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:
|
|
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(
|
|
84
|
+
children: [/* @__PURE__ */ n(y, {
|
|
84
85
|
as: "p",
|
|
85
86
|
color: "textOnLightSecondary",
|
|
86
87
|
children: a(e.subtitle, {
|
|
87
|
-
learnSharedLinkSettingsLink: /* @__PURE__ */ n(
|
|
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:
|
|
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(
|
|
102
|
+
/* @__PURE__ */ n(K, {
|
|
102
103
|
locale: navigator.language || "en-US",
|
|
103
|
-
children: /* @__PURE__ */ n(
|
|
104
|
+
children: /* @__PURE__ */ n(Q, {
|
|
104
105
|
calendarAriaLabel: a(e.linkExpirationCalendarAriaLabel),
|
|
105
106
|
clearDatePickerAriaLabel: a(e.linkExpirationClearDatePickerAriaLabel),
|
|
106
|
-
error:
|
|
107
|
+
error: p.expiration,
|
|
107
108
|
hideLabel: !0,
|
|
108
109
|
isDisabled: !i.canChangeExpiration,
|
|
109
110
|
label: a(e.linkExpirationDatePickerLabel),
|
|
110
|
-
minValue:
|
|
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 && (
|
|
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:
|
|
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:
|
|
131
|
+
error: p.password,
|
|
131
132
|
hideLabel: !0,
|
|
132
133
|
label: a(e.passwordToggleText),
|
|
133
|
-
onBlur:
|
|
134
|
-
onChange:
|
|
134
|
+
onBlur: z,
|
|
135
|
+
onChange: j,
|
|
135
136
|
onFocus: () => l("password", void 0),
|
|
136
|
-
placeholder:
|
|
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:
|
|
154
|
+
error: p.vanityName,
|
|
154
155
|
hideLabel: !0,
|
|
155
156
|
label: a(e.vanityNameInputLabel),
|
|
156
|
-
onChange:
|
|
157
|
+
onChange: R,
|
|
157
158
|
placeholder: a(e.vanityNameInputPlaceholder),
|
|
158
159
|
value: t.vanityName
|
|
159
|
-
}), i.canChangeVanityName && /* @__PURE__ */ n(
|
|
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:
|
|
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:
|
|
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:
|
|
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
|
-
|
|
190
|
+
ba as SharedLinkSettingsModal
|
|
190
191
|
};
|
|
@@ -1,66 +1,68 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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:
|
|
12
|
+
validateExpiration: p,
|
|
12
13
|
validatePassword: a,
|
|
13
|
-
validateVanityName:
|
|
14
|
-
} =
|
|
15
|
-
sharingService:
|
|
16
|
-
} =
|
|
17
|
-
updateSharedLink:
|
|
18
|
-
} =
|
|
14
|
+
validateVanityName: f
|
|
15
|
+
} = I(), {
|
|
16
|
+
sharingService: E
|
|
17
|
+
} = z(), {
|
|
18
|
+
updateSharedLink: g
|
|
19
|
+
} = E, {
|
|
19
20
|
isLoading: l,
|
|
20
21
|
onAction: m
|
|
21
|
-
} =
|
|
22
|
-
|
|
23
|
-
o(
|
|
24
|
-
}, [
|
|
25
|
-
const S =
|
|
26
|
-
o((
|
|
27
|
-
...
|
|
28
|
-
[t]:
|
|
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
|
-
}, []),
|
|
31
|
-
o(
|
|
32
|
-
}, [
|
|
33
|
-
const t =
|
|
34
|
-
expiration:
|
|
35
|
-
isExpirationEnabled:
|
|
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:
|
|
40
|
-
} = t,
|
|
41
|
-
if (
|
|
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
|
-
...
|
|
46
|
+
...e,
|
|
46
47
|
...t
|
|
47
48
|
});
|
|
48
|
-
} catch (
|
|
49
|
-
return Object.entries(
|
|
49
|
+
} catch (U) {
|
|
50
|
+
return Object.entries(U).forEach(([P, R]) => n(P, R)), !0;
|
|
50
51
|
}
|
|
51
52
|
return !1;
|
|
52
|
-
}, [s,
|
|
53
|
+
}, [s, e, m, n, p, a, f]);
|
|
53
54
|
return {
|
|
54
|
-
errors:
|
|
55
|
+
errors: h,
|
|
55
56
|
formData: s,
|
|
56
|
-
handleFormReset:
|
|
57
|
-
handleFormSubmit:
|
|
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
|
-
|
|
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.
|
|
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.
|
|
17
|
-
"@box/blueprint-web-assets": "^4.
|
|
18
|
-
"@box/copy-input": "^1.6.
|
|
19
|
-
"@box/storybook-utils": "0.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
|
},
|