@box/unified-share-modal 0.45.2 → 0.46.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.
- package/dist/esm/lib/components/shared-link-settings-modal/shared-link-settings-modal.js +109 -100
- package/dist/esm/lib/hooks/use-form-validation.js +24 -22
- package/dist/esm/lib/hooks/use-link-settings-form.js +46 -48
- package/dist/esm/lib/hooks/use-sharing-action.js +12 -12
- package/dist/esm/lib/messages.js +16 -0
- package/dist/esm/lib/utils/index.js +23 -16
- package/dist/esm/lib/utils/validation.js +41 -3
- package/dist/i18n/bn-IN.js +4 -0
- package/dist/i18n/da-DK.js +4 -0
- package/dist/i18n/de-DE.js +4 -0
- package/dist/i18n/en-AU.js +4 -0
- package/dist/i18n/en-CA.js +4 -0
- package/dist/i18n/en-GB.js +4 -0
- package/dist/i18n/en-US.js +4 -0
- package/dist/i18n/en-US.properties +8 -0
- package/dist/i18n/en-x-pseudo.js +4 -0
- package/dist/i18n/es-419.js +4 -0
- package/dist/i18n/es-ES.js +4 -0
- package/dist/i18n/fi-FI.js +4 -0
- package/dist/i18n/fr-CA.js +4 -0
- package/dist/i18n/fr-FR.js +4 -0
- package/dist/i18n/hi-IN.js +4 -0
- package/dist/i18n/it-IT.js +4 -0
- package/dist/i18n/ja-JP.js +4 -0
- package/dist/i18n/json/src/lib/messages.json +1 -1
- package/dist/i18n/ko-KR.js +4 -0
- package/dist/i18n/nb-NO.js +4 -0
- package/dist/i18n/nl-NL.js +4 -0
- package/dist/i18n/pl-PL.js +4 -0
- package/dist/i18n/pt-BR.js +4 -0
- package/dist/i18n/ru-RU.js +4 -0
- package/dist/i18n/sv-SE.js +4 -0
- package/dist/i18n/tr-TR.js +4 -0
- package/dist/i18n/zh-CN.js +4 -0
- package/dist/i18n/zh-TW.js +4 -0
- package/dist/types/lib/components/remove-shared-link-modal/stories/shared.d.ts +0 -1
- package/dist/types/lib/components/shared-link-settings-modal/stories/shared.d.ts +0 -34
- package/dist/types/lib/components/unified-share-form-modal/stories/shared.d.ts +1 -14
- package/dist/types/lib/hooks/use-form-validation.d.ts +2 -0
- package/dist/types/lib/hooks/use-link-settings-form.d.ts +1 -0
- package/dist/types/lib/messages.d.ts +20 -0
- package/dist/types/lib/stories/shared.d.ts +13 -6
- package/dist/types/lib/types.d.ts +2 -2
- package/dist/types/lib/utils/validation.d.ts +19 -0
- package/package.json +5 -8
- package/dist/esm/lib/store.js +0 -30
- package/dist/types/lib/store.d.ts +0 -21
|
@@ -1,173 +1,182 @@
|
|
|
1
|
-
import { useMemo as
|
|
2
|
-
import { useIntl as
|
|
3
|
-
import { Modal as r, Text as C, Link as
|
|
1
|
+
import { useMemo as G } from "react";
|
|
2
|
+
import { useIntl as J } from "react-intl";
|
|
3
|
+
import { Modal as r, Text as C, Link as K, Switch as c, DateI18nProvider as Q, DatePicker as X, InlineNotice as k, TextInput as L } from "@box/blueprint-web";
|
|
4
4
|
import e from "./messages.js";
|
|
5
|
-
import { jsx as n, jsxs as
|
|
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
|
|
15
|
-
isOpen:
|
|
16
|
-
onOpenChange:
|
|
5
|
+
import { jsx as n, jsxs as d, Fragment as S } from "react/jsx-runtime";
|
|
6
|
+
import { useAccessLevels as Z } from "../../hooks/use-access-levels.js";
|
|
7
|
+
import { formatDateFromTimestampToCalendarDate as aa, formatTomorrowDateToCalendarDate as ea } from "../../utils/date.js";
|
|
8
|
+
import { useLinkSettingsForm as na } from "../../hooks/use-link-settings-form.js";
|
|
9
|
+
import { useUnifiedShareModalContext as ia } from "../../contexts/unified-share-modal-context.js";
|
|
10
|
+
import '../../../../styles/shared-link-settings-modal.css';const oa = "_content_1wiic_1", ta = "_body_1wiic_5", P = {
|
|
11
|
+
content: oa,
|
|
12
|
+
body: ta
|
|
13
|
+
}, ra = "••••••••";
|
|
14
|
+
function ua({
|
|
15
|
+
isOpen: D,
|
|
16
|
+
onOpenChange: h
|
|
17
17
|
}) {
|
|
18
18
|
const {
|
|
19
19
|
formatMessage: a
|
|
20
|
-
} =
|
|
21
|
-
eventService:
|
|
22
|
-
isSubmitting:
|
|
23
|
-
sharedLink:
|
|
24
|
-
} =
|
|
25
|
-
expiresAt:
|
|
20
|
+
} = J(), {
|
|
21
|
+
eventService: N,
|
|
22
|
+
isSubmitting: T,
|
|
23
|
+
sharedLink: f
|
|
24
|
+
} = ia(), {
|
|
25
|
+
expiresAt: v,
|
|
26
26
|
permissions: i = {},
|
|
27
|
-
vanityDomain:
|
|
28
|
-
vanityName:
|
|
29
|
-
} = S, {
|
|
30
|
-
onSharedLinkSettingsClose: v
|
|
27
|
+
vanityDomain: A,
|
|
28
|
+
vanityName: m
|
|
31
29
|
} = f, {
|
|
30
|
+
onSharedLinkSettingsClose: w
|
|
31
|
+
} = N, {
|
|
32
32
|
selectedAccess: g
|
|
33
|
-
} =
|
|
33
|
+
} = Z(), b = v ? aa(v) : void 0, p = G(() => ({
|
|
34
34
|
expiration: b,
|
|
35
|
-
isDownloadEnabled: i.isDownloadEnabled
|
|
35
|
+
isDownloadEnabled: !!i.isDownloadEnabled,
|
|
36
36
|
isExpirationEnabled: !!b,
|
|
37
|
-
isPasswordEnabled: i.isPasswordEnabled
|
|
38
|
-
isVanityEnabled: !!
|
|
37
|
+
isPasswordEnabled: !!i.isPasswordEnabled,
|
|
38
|
+
isVanityEnabled: !!m,
|
|
39
39
|
password: "",
|
|
40
|
-
vanityName:
|
|
41
|
-
}), [b, i,
|
|
40
|
+
vanityName: m || ""
|
|
41
|
+
}), [b, i, m]), {
|
|
42
42
|
errors: u,
|
|
43
|
-
formData:
|
|
44
|
-
handleFormReset:
|
|
45
|
-
handleFormSubmit:
|
|
46
|
-
isUpdating:
|
|
47
|
-
setFieldError:
|
|
48
|
-
setFieldValue:
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
43
|
+
formData: t,
|
|
44
|
+
handleFormReset: y,
|
|
45
|
+
handleFormSubmit: I,
|
|
46
|
+
isUpdating: F,
|
|
47
|
+
setFieldError: l,
|
|
48
|
+
setFieldValue: s,
|
|
49
|
+
validatePassword: V
|
|
50
|
+
} = na(p), B = () => {
|
|
51
|
+
y(), w && w(), h(!1);
|
|
52
|
+
}, M = async () => {
|
|
53
|
+
await I() || (y(), h(!1));
|
|
54
|
+
}, _ = (o) => {
|
|
55
|
+
l("expiration", void 0), s("isExpirationEnabled", o);
|
|
56
|
+
}, U = (o) => {
|
|
57
|
+
l("expiration", void 0), s("expiration", o);
|
|
58
|
+
}, R = (o) => {
|
|
59
|
+
l("vanityName", void 0), s("isVanityEnabled", o);
|
|
60
|
+
}, W = (o) => {
|
|
61
|
+
l("vanityName", void 0), s("vanityName", o.target.value);
|
|
62
|
+
}, j = (o) => {
|
|
63
|
+
l("password", void 0), s("isPasswordEnabled", o);
|
|
64
|
+
}, O = (o) => {
|
|
65
|
+
l("password", void 0), s("password", o.target.value);
|
|
66
|
+
}, $ = (o) => {
|
|
67
|
+
s("isDownloadEnabled", o);
|
|
68
|
+
}, z = (o) => {
|
|
69
|
+
var E;
|
|
70
|
+
const q = (E = document.getElementById("usm-SharedLinkSettingsModal-primaryButton")) == null ? void 0 : E.contains(o.relatedTarget);
|
|
71
|
+
p.isPasswordEnabled && !t.password || q || V(t.password);
|
|
72
|
+
}, H = i.canChangeVanityName && !!t.vanityName, Y = `${A || ""}${t.vanityName}`, x = T || F;
|
|
68
73
|
return /* @__PURE__ */ n(r, {
|
|
69
|
-
onOpenChange:
|
|
70
|
-
open:
|
|
71
|
-
children: /* @__PURE__ */
|
|
72
|
-
className:
|
|
74
|
+
onOpenChange: h,
|
|
75
|
+
open: D,
|
|
76
|
+
children: /* @__PURE__ */ d(r.Content, {
|
|
77
|
+
className: P.content,
|
|
73
78
|
size: "medium",
|
|
74
79
|
children: [/* @__PURE__ */ n(r.Header, {
|
|
75
80
|
children: a(e.title)
|
|
76
|
-
}), /* @__PURE__ */
|
|
77
|
-
className:
|
|
81
|
+
}), /* @__PURE__ */ d(r.Body, {
|
|
82
|
+
className: P.body,
|
|
78
83
|
children: [/* @__PURE__ */ n(C, {
|
|
79
84
|
as: "p",
|
|
80
85
|
color: "textOnLightSecondary",
|
|
81
86
|
children: a(e.subtitle, {
|
|
82
|
-
learnSharedLinkSettingsLink: /* @__PURE__ */ n(
|
|
87
|
+
learnSharedLinkSettingsLink: /* @__PURE__ */ n(K, {
|
|
83
88
|
href: "https://support.box.com/hc/en-us/articles/360043697554-Configuring-Individual-Shared-Link-Settings",
|
|
84
89
|
rel: "noreferrer",
|
|
85
90
|
target: "_blank",
|
|
86
91
|
children: a(e.learnSharedLinkSettingsLink)
|
|
87
92
|
})
|
|
88
93
|
})
|
|
89
|
-
}), /* @__PURE__ */ n(
|
|
90
|
-
checked:
|
|
94
|
+
}), /* @__PURE__ */ n(c.Item, {
|
|
95
|
+
checked: t.isExpirationEnabled,
|
|
91
96
|
disabled: !i.canChangeExpiration,
|
|
92
97
|
label: a(e.linkExpirationToggleText),
|
|
93
|
-
onCheckedChange:
|
|
98
|
+
onCheckedChange: _,
|
|
94
99
|
value: "link-expiration-settings"
|
|
95
|
-
}),
|
|
96
|
-
/* @__PURE__ */ n(
|
|
100
|
+
}), t.isExpirationEnabled && // Get the locale from the user's operating system settings
|
|
101
|
+
/* @__PURE__ */ n(Q, {
|
|
97
102
|
locale: navigator.language || "en-US",
|
|
98
|
-
children: /* @__PURE__ */ n(
|
|
103
|
+
children: /* @__PURE__ */ n(X, {
|
|
99
104
|
calendarAriaLabel: a(e.linkExpirationCalendarAriaLabel),
|
|
100
105
|
clearDatePickerAriaLabel: a(e.linkExpirationClearDatePickerAriaLabel),
|
|
101
106
|
error: u.expiration,
|
|
102
107
|
hideLabel: !0,
|
|
103
108
|
isDisabled: !i.canChangeExpiration,
|
|
104
109
|
label: a(e.linkExpirationDatePickerLabel),
|
|
105
|
-
minValue:
|
|
110
|
+
minValue: ea(),
|
|
106
111
|
nextMonthAriaLabel: a(e.linkExpirationNextMonthAriaLabel),
|
|
107
|
-
onChange:
|
|
112
|
+
onChange: U,
|
|
108
113
|
openCalendarDropdownAriaLabel: a(e.linkExpirationOpenCalendarDropdownAriaLabel),
|
|
109
114
|
previousMonthAriaLabel: a(e.linkExpirationPreviousMonthAriaLabel),
|
|
110
|
-
value:
|
|
115
|
+
value: t.expiration
|
|
111
116
|
})
|
|
112
|
-
}), i.isPasswordAvailable && (g == null ? void 0 : g.id) === "open" && /* @__PURE__ */ n(
|
|
113
|
-
checked:
|
|
117
|
+
}), i.isPasswordAvailable && (g == null ? void 0 : g.id) === "open" && /* @__PURE__ */ n(c.Item, {
|
|
118
|
+
checked: t.isPasswordEnabled,
|
|
114
119
|
disabled: !i.canChangePassword,
|
|
115
120
|
label: a(e.passwordToggleText),
|
|
116
|
-
onCheckedChange:
|
|
121
|
+
onCheckedChange: j,
|
|
117
122
|
value: "password-settings"
|
|
118
|
-
}),
|
|
119
|
-
children: [i.canChangePassword && /* @__PURE__ */ n(
|
|
123
|
+
}), t.isPasswordEnabled && /* @__PURE__ */ d(S, {
|
|
124
|
+
children: [i.canChangePassword && /* @__PURE__ */ n(k, {
|
|
120
125
|
variant: "warning",
|
|
121
126
|
variantIconAriaLabel: a(e.warningNoticeIconAriaLabel),
|
|
122
127
|
children: a(e.passwordWarningText)
|
|
123
|
-
}), /* @__PURE__ */ n(
|
|
128
|
+
}), /* @__PURE__ */ n(L, {
|
|
124
129
|
disabled: !i.canChangePassword,
|
|
130
|
+
error: u.password,
|
|
125
131
|
hideLabel: !0,
|
|
126
132
|
label: a(e.passwordToggleText),
|
|
127
|
-
|
|
128
|
-
|
|
133
|
+
onBlur: z,
|
|
134
|
+
onChange: O,
|
|
135
|
+
onFocus: () => l("password", void 0),
|
|
136
|
+
placeholder: p.isPasswordEnabled ? ra : a(e.passwordInputPlaceholder),
|
|
129
137
|
type: "password",
|
|
130
|
-
value:
|
|
138
|
+
value: t.password
|
|
131
139
|
})]
|
|
132
|
-
}), i.isVanityNameAvailable && /* @__PURE__ */ n(
|
|
133
|
-
checked:
|
|
140
|
+
}), i.isVanityNameAvailable && /* @__PURE__ */ n(c.Item, {
|
|
141
|
+
checked: t.isVanityEnabled,
|
|
134
142
|
disabled: !i.canChangeVanityName,
|
|
135
143
|
label: a(e.vanityNameToggleText),
|
|
136
|
-
onCheckedChange:
|
|
144
|
+
onCheckedChange: R,
|
|
137
145
|
value: "vanity-domain-settings"
|
|
138
|
-
}),
|
|
139
|
-
children: [i.canChangeVanityName && /* @__PURE__ */ n(
|
|
146
|
+
}), t.isVanityEnabled && /* @__PURE__ */ d(S, {
|
|
147
|
+
children: [i.canChangeVanityName && /* @__PURE__ */ n(k, {
|
|
140
148
|
variant: "warning",
|
|
141
149
|
variantIconAriaLabel: a(e.warningNoticeIconAriaLabel),
|
|
142
150
|
children: a(e.vanityDomainSettingsWarningText)
|
|
143
|
-
}), /* @__PURE__ */ n(
|
|
151
|
+
}), /* @__PURE__ */ n(L, {
|
|
144
152
|
disabled: !i.canChangeVanityName,
|
|
145
153
|
error: u.vanityName,
|
|
146
154
|
hideLabel: !0,
|
|
147
155
|
label: a(e.vanityNameInputLabel),
|
|
148
|
-
onChange:
|
|
156
|
+
onChange: W,
|
|
149
157
|
placeholder: a(e.vanityNameInputPlaceholder),
|
|
150
|
-
value:
|
|
151
|
-
}),
|
|
158
|
+
value: t.vanityName
|
|
159
|
+
}), H && /* @__PURE__ */ n(C, {
|
|
152
160
|
as: "p",
|
|
153
|
-
children:
|
|
161
|
+
children: Y
|
|
154
162
|
})]
|
|
155
|
-
}), i.isDownloadAvailable && /* @__PURE__ */ n(
|
|
156
|
-
checked:
|
|
163
|
+
}), i.isDownloadAvailable && /* @__PURE__ */ n(c.Item, {
|
|
164
|
+
checked: t.isDownloadEnabled,
|
|
157
165
|
disabled: !i.canChangeDownload,
|
|
158
166
|
label: a(e.downloadSettingsToggleText),
|
|
159
|
-
onCheckedChange:
|
|
167
|
+
onCheckedChange: $,
|
|
160
168
|
value: "download-link-settings"
|
|
161
169
|
})]
|
|
162
|
-
}), /* @__PURE__ */
|
|
170
|
+
}), /* @__PURE__ */ d(r.Footer, {
|
|
163
171
|
children: [/* @__PURE__ */ n(r.Footer.SecondaryButton, {
|
|
164
|
-
disabled:
|
|
165
|
-
onClick:
|
|
172
|
+
disabled: x,
|
|
173
|
+
onClick: B,
|
|
166
174
|
children: a(e.cancelButton)
|
|
167
175
|
}), /* @__PURE__ */ n(r.Footer.PrimaryButton, {
|
|
168
|
-
|
|
176
|
+
id: "usm-SharedLinkSettingsModal-primaryButton",
|
|
177
|
+
loading: x,
|
|
169
178
|
loadingAriaLabel: a(e.loadingLabel),
|
|
170
|
-
onClick:
|
|
179
|
+
onClick: M,
|
|
171
180
|
children: a(e.saveButton)
|
|
172
181
|
})]
|
|
173
182
|
}), /* @__PURE__ */ n(r.Close, {
|
|
@@ -177,5 +186,5 @@ function ga({
|
|
|
177
186
|
});
|
|
178
187
|
}
|
|
179
188
|
export {
|
|
180
|
-
|
|
189
|
+
ua as SharedLinkSettingsModal
|
|
181
190
|
};
|
|
@@ -1,31 +1,33 @@
|
|
|
1
|
-
import { useState as
|
|
2
|
-
import { useIntl as
|
|
1
|
+
import { useState as g, useCallback as o } from "react";
|
|
2
|
+
import { useIntl as v } from "react-intl";
|
|
3
3
|
import a from "../messages.js";
|
|
4
|
-
import { formatTomorrowDateToCalendarDate as
|
|
5
|
-
import { isVanityNameValid as
|
|
6
|
-
const
|
|
4
|
+
import { formatTomorrowDateToCalendarDate as p } from "../utils/date.js";
|
|
5
|
+
import { isVanityNameValid as w, isEmailValid as y, doesPasswordContainMinCharacters as N, doesPasswordContainInvalidCharacter as P, isPasswordMixedCase as x, doesPasswordContainLetter as n, doesPasswordContainNumber as u, doesPasswordContainSymbol as d } from "../utils/validation.js";
|
|
6
|
+
const R = () => {
|
|
7
7
|
const {
|
|
8
8
|
formatMessage: t
|
|
9
|
-
} =
|
|
10
|
-
|
|
11
|
-
...
|
|
12
|
-
[
|
|
9
|
+
} = v(), [l, i] = g({}), e = o((r, s) => {
|
|
10
|
+
i((M) => ({
|
|
11
|
+
...M,
|
|
12
|
+
[r]: s
|
|
13
13
|
}));
|
|
14
|
-
}, []),
|
|
15
|
-
if (!
|
|
16
|
-
return
|
|
17
|
-
const
|
|
18
|
-
return
|
|
19
|
-
}, [t,
|
|
14
|
+
}, []), m = o((r) => {
|
|
15
|
+
if (!r)
|
|
16
|
+
return e("expiration", t(a.expirationRequiredErrorMessage)), !0;
|
|
17
|
+
const s = p();
|
|
18
|
+
return r.compare(s) < 0 ? (e("expiration", t(a.expirationFutureDateRequiredErrorMessage)), !0) : !1;
|
|
19
|
+
}, [t, e]), c = o((r) => r ? w(r) ? !1 : (e("vanityName", t(a.vanityNameInvalidErrorMessage)), !0) : (e("vanityName", t(a.vanityNameRequiredErrorMessage)), !0), [t, e]), f = o((r) => r.length ? !1 : (e("user-contact", t(a.emailRequiredErrorMessage)), !0), [t, e]), C = o((r) => y(r) ? !1 : (e("user-contact", t(a.invalidEmailErrorMessage)), !0), [t, e]), E = o((r) => N(r) ? P(r) ? (e("password", t(a.passwordContainInvalidCharacterErrorMessage)), !0) : !x(r) && !(n(r) && u(r)) && !(n(r) && d(r)) && !(u(r) && d(r)) ? (e("password", t(a.passwordContainLetterNumberOrSymbolErrorMessage)), !0) : !1 : (e("password", t(a.passwordContainMinCharactersErrorMessage)), !0), [t, e]);
|
|
20
20
|
return {
|
|
21
|
-
errors:
|
|
22
|
-
validateExpiration:
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
21
|
+
errors: l,
|
|
22
|
+
validateExpiration: m,
|
|
23
|
+
validatePassword: E,
|
|
24
|
+
validateVanityName: c,
|
|
25
|
+
validateUserContact: C,
|
|
26
|
+
validateUserSelector: f,
|
|
27
|
+
setErrors: i,
|
|
28
|
+
setFieldError: e
|
|
27
29
|
};
|
|
28
30
|
};
|
|
29
31
|
export {
|
|
30
|
-
|
|
32
|
+
R as useFormValidation
|
|
31
33
|
};
|
|
@@ -1,60 +1,58 @@
|
|
|
1
|
-
import { useState as
|
|
2
|
-
import { useFormValidation as
|
|
3
|
-
import { useSharingAction as
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
import { useState as L, useCallback as d } from "react";
|
|
2
|
+
import { useFormValidation as N } from "./use-form-validation.js";
|
|
3
|
+
import { useSharingAction as b } from "./use-sharing-action.js";
|
|
4
|
+
import { getSharedLinkFormValidation as P } from "../utils/validation.js";
|
|
5
|
+
import { useUnifiedShareModalContext as U } from "../contexts/unified-share-modal-context.js";
|
|
6
|
+
const R = (t) => {
|
|
7
|
+
const [o, a] = L(t), {
|
|
8
|
+
errors: l,
|
|
9
|
+
setErrors: c,
|
|
10
|
+
setFieldError: s,
|
|
11
|
+
validateExpiration: u,
|
|
12
|
+
validatePassword: n,
|
|
13
|
+
validateVanityName: m
|
|
14
|
+
} = N(), {
|
|
15
|
+
sharedLink: {
|
|
16
|
+
permissions: p
|
|
17
|
+
},
|
|
12
18
|
sharingService: f
|
|
13
|
-
} =
|
|
14
|
-
updateSharedLink:
|
|
19
|
+
} = U(), {
|
|
20
|
+
updateSharedLink: E
|
|
15
21
|
} = f, {
|
|
16
|
-
isLoading:
|
|
17
|
-
onAction:
|
|
18
|
-
} =
|
|
19
|
-
|
|
20
|
-
...
|
|
21
|
-
[
|
|
22
|
+
isLoading: S,
|
|
23
|
+
onAction: h
|
|
24
|
+
} = b(E, "update-shared-link"), V = d((r, e) => {
|
|
25
|
+
a((i) => ({
|
|
26
|
+
...i,
|
|
27
|
+
[r]: e
|
|
22
28
|
}));
|
|
23
|
-
}, []),
|
|
24
|
-
|
|
25
|
-
}, [
|
|
29
|
+
}, []), g = d(() => {
|
|
30
|
+
a(t), c({});
|
|
31
|
+
}, [t, c, a]), k = d(async () => {
|
|
26
32
|
const {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
} = a;
|
|
33
|
-
let e = !1;
|
|
34
|
-
if (s && c(t) && (e = !0), g && u(m) && (e = !0), e)
|
|
35
|
-
return e;
|
|
36
|
-
const x = {
|
|
37
|
-
expiration: t,
|
|
38
|
-
isDownloadEnabled: i,
|
|
39
|
-
vanityName: m
|
|
40
|
-
};
|
|
33
|
+
updatedFormData: r,
|
|
34
|
+
shouldValidate: e
|
|
35
|
+
} = P(p, o, t), i = e.expiration && u(r.updatedExpiration), x = e.password && n(r.updatedPassword), y = e.vanityName && m(r.updatedVanityName);
|
|
36
|
+
if (i || x || y)
|
|
37
|
+
return !0;
|
|
41
38
|
try {
|
|
42
|
-
await
|
|
43
|
-
} catch (
|
|
44
|
-
return Object.entries(
|
|
39
|
+
await h(r);
|
|
40
|
+
} catch (v) {
|
|
41
|
+
return Object.entries(v).forEach(([w, F]) => s(w, F)), !0;
|
|
45
42
|
}
|
|
46
43
|
return !1;
|
|
47
|
-
}, [
|
|
44
|
+
}, [o, t, p, h, s, u, n, m]);
|
|
48
45
|
return {
|
|
49
|
-
errors:
|
|
50
|
-
formData:
|
|
51
|
-
handleFormReset:
|
|
52
|
-
handleFormSubmit:
|
|
53
|
-
isUpdating:
|
|
54
|
-
setFieldError:
|
|
55
|
-
setFieldValue:
|
|
46
|
+
errors: l,
|
|
47
|
+
formData: o,
|
|
48
|
+
handleFormReset: g,
|
|
49
|
+
handleFormSubmit: k,
|
|
50
|
+
isUpdating: S,
|
|
51
|
+
setFieldError: s,
|
|
52
|
+
setFieldValue: V,
|
|
53
|
+
validatePassword: n
|
|
56
54
|
};
|
|
57
55
|
};
|
|
58
56
|
export {
|
|
59
|
-
|
|
57
|
+
R as useLinkSettingsForm
|
|
60
58
|
};
|
|
@@ -9,16 +9,16 @@ const f = (s, e) => ({
|
|
|
9
9
|
sensitivity: "foreground",
|
|
10
10
|
typeIconAriaLabel: s(e === "success" ? i.successNoticeIcon : i.errorNoticeIcon),
|
|
11
11
|
variant: e
|
|
12
|
-
}), N = (s, e, t,
|
|
12
|
+
}), N = (s, e, t, c) => {
|
|
13
13
|
if (!t)
|
|
14
14
|
return "";
|
|
15
15
|
const l = b(t), n = i[`${l}${e === "success" ? "Success" : "Error"}NoticeText`];
|
|
16
|
-
return n ? s(n,
|
|
16
|
+
return n ? s(n, c) : e === "error" ? s(i.defaultErrorNoticeText) : "";
|
|
17
17
|
}, O = (s, e) => {
|
|
18
18
|
const {
|
|
19
19
|
formatMessage: t
|
|
20
20
|
} = E(), {
|
|
21
|
-
addNotification:
|
|
21
|
+
addNotification: c
|
|
22
22
|
} = S(), [l, u] = C(!1), {
|
|
23
23
|
config: n,
|
|
24
24
|
item: h
|
|
@@ -32,13 +32,13 @@ const f = (s, e) => ({
|
|
|
32
32
|
u(!0);
|
|
33
33
|
try {
|
|
34
34
|
if (s) {
|
|
35
|
-
const o = await s(...p),
|
|
36
|
-
|
|
35
|
+
const o = await s(...p), r = a && !!o && !!o.messages, y = a && !r;
|
|
36
|
+
r && o.messages.forEach(({
|
|
37
37
|
text: x,
|
|
38
38
|
type: A,
|
|
39
39
|
...T
|
|
40
40
|
}) => {
|
|
41
|
-
|
|
41
|
+
c({
|
|
42
42
|
...f(t, A),
|
|
43
43
|
styledText: x,
|
|
44
44
|
...T
|
|
@@ -47,22 +47,22 @@ const f = (s, e) => ({
|
|
|
47
47
|
const g = N(t, "success", e, {
|
|
48
48
|
itemName: d
|
|
49
49
|
});
|
|
50
|
-
y && g &&
|
|
50
|
+
y && g && c({
|
|
51
51
|
...f(t, "success"),
|
|
52
52
|
styledText: g
|
|
53
53
|
});
|
|
54
54
|
}
|
|
55
55
|
} catch (o) {
|
|
56
|
-
const
|
|
57
|
-
if (a &&
|
|
56
|
+
const r = N(t, "error", e);
|
|
57
|
+
if (a && r && c({
|
|
58
58
|
...f(t, "error"),
|
|
59
|
-
styledText:
|
|
60
|
-
}), o.fields && Object.values(o.fields).length)
|
|
59
|
+
styledText: r
|
|
60
|
+
}), o != null && o.fields && Object.values(o.fields).length)
|
|
61
61
|
throw o.fields;
|
|
62
62
|
} finally {
|
|
63
63
|
u(!1);
|
|
64
64
|
}
|
|
65
|
-
}, [s,
|
|
65
|
+
}, [s, c, t, a, d, e]),
|
|
66
66
|
isLoading: l
|
|
67
67
|
};
|
|
68
68
|
};
|
package/dist/esm/lib/messages.js
CHANGED
|
@@ -63,6 +63,22 @@ const a = e({
|
|
|
63
63
|
emailRequiredErrorMessage: {
|
|
64
64
|
id: "groupSharedFeatures.usm.emailRequiredErrorMessage",
|
|
65
65
|
defaultMessage: "Enter at least one valid email"
|
|
66
|
+
},
|
|
67
|
+
passwordRequiredErrorMessage: {
|
|
68
|
+
id: "groupSharedFeatures.usm.passwordRequiredErrorMessage",
|
|
69
|
+
defaultMessage: "Please enter a password"
|
|
70
|
+
},
|
|
71
|
+
passwordContainMinCharactersErrorMessage: {
|
|
72
|
+
id: "groupSharedFeatures.usm.passwordContainMinCharactersErrorMessage",
|
|
73
|
+
defaultMessage: "Password should contain at least 8 characters"
|
|
74
|
+
},
|
|
75
|
+
passwordContainInvalidCharacterErrorMessage: {
|
|
76
|
+
id: "groupSharedFeatures.usm.passwordContainInvalidCharacterErrorMessage",
|
|
77
|
+
defaultMessage: 'Your password cannot contain a space, "<" or ">"'
|
|
78
|
+
},
|
|
79
|
+
passwordContainLetterNumberOrSymbolErrorMessage: {
|
|
80
|
+
id: "groupSharedFeatures.usm.passwordContainLetterNumberOrSymbolErrorMessage",
|
|
81
|
+
defaultMessage: "Your password should contain at least one upper case letter, number, or special character."
|
|
66
82
|
}
|
|
67
83
|
});
|
|
68
84
|
export {
|
|
@@ -1,19 +1,26 @@
|
|
|
1
|
-
import { getAvatarBadgeSize as
|
|
2
|
-
import { formatDateFromTimestampToCalendarDate as
|
|
3
|
-
import { callOnKeyboardEvent as
|
|
4
|
-
import { getAllowedAccessLevels as
|
|
5
|
-
import {
|
|
1
|
+
import { getAvatarBadgeSize as e, getDefaultCollaborationRole as t, getFirstInitial as r, isCollaboratorRoleSupported as i, isInvitationRoleSupported as s } from "./collaborator.js";
|
|
2
|
+
import { formatDateFromTimestampToCalendarDate as n, formatDateFromTimestampToDateString as l, formatTomorrowDateToCalendarDate as m } from "./date.js";
|
|
3
|
+
import { callOnKeyboardEvent as p } from "./event.js";
|
|
4
|
+
import { getAllowedAccessLevels as w } from "./permission.js";
|
|
5
|
+
import { doesPasswordContainInvalidCharacter as D, doesPasswordContainLetter as x, doesPasswordContainMinCharacters as P, doesPasswordContainNumber as S, doesPasswordContainSymbol as T, getSharedLinkFormValidation as b, isEmailValid as c, isPasswordMixedCase as v, isVanityNameValid as u } from "./validation.js";
|
|
6
6
|
export {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
p as callOnKeyboardEvent,
|
|
8
|
+
D as doesPasswordContainInvalidCharacter,
|
|
9
|
+
x as doesPasswordContainLetter,
|
|
10
|
+
P as doesPasswordContainMinCharacters,
|
|
11
|
+
S as doesPasswordContainNumber,
|
|
12
|
+
T as doesPasswordContainSymbol,
|
|
13
|
+
n as formatDateFromTimestampToCalendarDate,
|
|
14
|
+
l as formatDateFromTimestampToDateString,
|
|
15
|
+
m as formatTomorrowDateToCalendarDate,
|
|
16
|
+
w as getAllowedAccessLevels,
|
|
17
|
+
e as getAvatarBadgeSize,
|
|
18
|
+
t as getDefaultCollaborationRole,
|
|
14
19
|
r as getFirstInitial,
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
20
|
+
b as getSharedLinkFormValidation,
|
|
21
|
+
i as isCollaboratorRoleSupported,
|
|
22
|
+
c as isEmailValid,
|
|
23
|
+
s as isInvitationRoleSupported,
|
|
24
|
+
v as isPasswordMixedCase,
|
|
25
|
+
u as isVanityNameValid
|
|
19
26
|
};
|
|
@@ -1,5 +1,43 @@
|
|
|
1
|
-
const
|
|
1
|
+
const A = /^[a-zA-Z0-9-]{12,30}$/, C = /^[A-Z0-9._'%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i, P = (a) => A.test(a), f = (a) => a.length === 0 ? !0 : C.test(a), v = (a) => a.length >= 8, N = (a) => a.replace(/\D/g, "").length >= 1, V = (a) => a.replace(/\s/g, "").replace(/\w/g, "").length >= 1, y = (a) => /[a-zA-Z]/.test(a), x = (a) => /[a-z]/.test(a) && /[A-Z]/.test(a), D = (a) => /[\s<>]/.test(a), Z = (a, d, r) => {
|
|
2
|
+
const {
|
|
3
|
+
expiration: l,
|
|
4
|
+
isDownloadEnabled: u,
|
|
5
|
+
isExpirationEnabled: n,
|
|
6
|
+
isPasswordEnabled: s,
|
|
7
|
+
isVanityEnabled: o,
|
|
8
|
+
password: i,
|
|
9
|
+
vanityName: c
|
|
10
|
+
} = d, {
|
|
11
|
+
canChangeDownload: p,
|
|
12
|
+
canChangeExpiration: w,
|
|
13
|
+
canChangeVanityName: E,
|
|
14
|
+
canChangePassword: b,
|
|
15
|
+
isDownloadAvailable: g,
|
|
16
|
+
isPasswordAvailable: h,
|
|
17
|
+
isVanityNameAvailable: m
|
|
18
|
+
} = a, e = {
|
|
19
|
+
updatedExpiration: n ? l : 0,
|
|
20
|
+
updatedPassword: s ? i : "",
|
|
21
|
+
updatedVanityName: o ? c : "",
|
|
22
|
+
updatedIsDownloadEnabled: u
|
|
23
|
+
}, t = {
|
|
24
|
+
expiration: !1,
|
|
25
|
+
password: !1,
|
|
26
|
+
vanityName: !1
|
|
27
|
+
};
|
|
28
|
+
return w ? n && (t.expiration = !0) : e.updatedExpiration = void 0, !h || !b || r.isPasswordEnabled && !i ? e.updatedPassword = void 0 : s && (t.password = !0), !m || !E ? e.updatedVanityName = void 0 : o && (t.vanityName = !0), (!g || !p) && (e.updatedIsDownloadEnabled = void 0), {
|
|
29
|
+
updatedFormData: e,
|
|
30
|
+
shouldValidate: t
|
|
31
|
+
};
|
|
32
|
+
};
|
|
2
33
|
export {
|
|
3
|
-
|
|
4
|
-
|
|
34
|
+
D as doesPasswordContainInvalidCharacter,
|
|
35
|
+
y as doesPasswordContainLetter,
|
|
36
|
+
v as doesPasswordContainMinCharacters,
|
|
37
|
+
N as doesPasswordContainNumber,
|
|
38
|
+
V as doesPasswordContainSymbol,
|
|
39
|
+
Z as getSharedLinkFormValidation,
|
|
40
|
+
f as isEmailValid,
|
|
41
|
+
x as isPasswordMixedCase,
|
|
42
|
+
P as isVanityNameValid
|
|
5
43
|
};
|