@box/unified-share-modal 0.47.0 → 0.47.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.
@@ -23,22 +23,22 @@ function ua({
23
23
  sharedLink: f
24
24
  } = ia(), {
25
25
  expiresAt: v,
26
- permissions: i = {},
26
+ settings: i = {},
27
27
  vanityDomain: A,
28
- vanityName: m
28
+ vanityName: g
29
29
  } = f, {
30
30
  onSharedLinkSettingsClose: w
31
31
  } = N, {
32
- selectedAccess: g
32
+ selectedAccess: m
33
33
  } = Z(), b = v ? aa(v) : void 0, p = G(() => ({
34
34
  expiration: b,
35
35
  isDownloadEnabled: !!i.isDownloadEnabled,
36
36
  isExpirationEnabled: !!b,
37
37
  isPasswordEnabled: !!i.isPasswordEnabled,
38
- isVanityEnabled: !!m,
38
+ isVanityEnabled: !!g,
39
39
  password: "",
40
- vanityName: m || ""
41
- }), [b, i, m]), {
40
+ vanityName: g || ""
41
+ }), [b, i, g]), {
42
42
  errors: u,
43
43
  formData: t,
44
44
  handleFormReset: y,
@@ -114,7 +114,7 @@ function ua({
114
114
  previousMonthAriaLabel: a(e.linkExpirationPreviousMonthAriaLabel),
115
115
  value: t.expiration
116
116
  })
117
- }), i.isPasswordAvailable && (g == null ? void 0 : g.id) === "open" && /* @__PURE__ */ n(c.Item, {
117
+ }), i.isPasswordAvailable && (m == null ? void 0 : m.id) === "open" && /* @__PURE__ */ n(c.Item, {
118
118
  checked: t.isPasswordEnabled,
119
119
  disabled: !i.canChangePassword,
120
120
  label: a(e.passwordToggleText),
@@ -1,70 +1,69 @@
1
- import { useCallback as i } from "react";
2
- import { useFormValidation as w } from "./use-form-validation.js";
3
- import { useSharingAction as B } from "./use-sharing-action.js";
4
- import { useUnifiedShareFormContext as E } from "../contexts/unified-share-form-context.js";
5
- import { useUnifiedShareModalContext as A } from "../contexts/unified-share-modal-context.js";
6
- const N = (g, h) => {
1
+ import { useCallback as s } from "react";
2
+ import { useFormValidation as V } from "./use-form-validation.js";
3
+ import { useSharingAction as w } from "./use-sharing-action.js";
4
+ import { useUnifiedShareFormContext as B } from "../contexts/unified-share-form-context.js";
5
+ import { useUnifiedShareModalContext as E } from "../contexts/unified-share-modal-context.js";
6
+ const q = (v, F) => {
7
7
  const {
8
- errors: p,
8
+ errors: f,
9
9
  setFieldError: o,
10
- validateUserContact: n,
11
- validateUserSelector: u
12
- } = w(), {
13
- contactService: v
14
- } = A(), {
15
- setContactValue: m,
16
- setMessageValue: F,
17
- setUserContacts: r,
18
- userContacts: a
10
+ validateUserContact: C,
11
+ validateUserSelector: i
12
+ } = V(), {
13
+ contactService: g
19
14
  } = E(), {
15
+ setContactValue: l,
16
+ setMessageValue: h,
17
+ setUserContacts: a,
18
+ userContacts: n
19
+ } = B(), {
20
20
  isLoading: b,
21
21
  onAction: U
22
- } = B(g, h), {
23
- getContactByEmail: d
24
- } = v, f = () => {
25
- r([]), m(""), F(""), o("user-contact", "");
26
- }, x = i((t) => {
27
- o("user-contact", ""), m(t);
28
- }, [m, o]), y = i((t) => {
29
- var l, S;
30
- const e = (l = document.querySelector('div[role="listbox"][aria-labelledby^="user-contacts"]')) == null ? void 0 : l.contains(t.relatedTarget), c = (S = t.relatedTarget) == null ? void 0 : S.closest(".collaboration-user-selector");
31
- if (e || c)
32
- return;
33
- const s = t.target.value;
34
- n(s);
35
- }, [n]), C = i(async (t) => {
22
+ } = w(v, F), {
23
+ getContactByEmail: u
24
+ } = g, S = () => {
25
+ a([]), l(""), h(""), o("user-contact", "");
26
+ }, x = s((t) => {
27
+ o("user-contact", ""), l(t);
28
+ }, [l, o]), p = s(async (t) => {
36
29
  if (t.id)
37
30
  return t;
38
- if (d) {
39
- const e = await d(t.value);
31
+ if (u) {
32
+ const e = await u(t.value);
40
33
  if (e && e.id)
41
34
  return e;
42
35
  }
43
- return n(t.value) ? null : {
36
+ return C(t.value) ? null : {
44
37
  email: t.value,
45
38
  id: 0,
46
39
  isExternalUser: !0,
47
40
  name: t.value,
48
41
  value: t.value
49
42
  };
50
- }, [d, n]), V = i(async (t) => {
51
- if (o("user-contact", ""), u(t), a.length >= t.length) {
52
- r(t);
43
+ }, [u, C]), m = s(async (t) => {
44
+ if (o("user-contact", ""), i(t), n.length >= t.length) {
45
+ a(t);
53
46
  return;
54
47
  }
55
- const [e, ...c] = [...t].reverse(), s = await C(e), l = s ? [...c, s] : c;
56
- r(l.filter(Boolean));
57
- }, [C, o, r, u, a]);
48
+ const [e, ...d] = [...t].reverse(), r = await p(e), c = r ? [...d, r] : d;
49
+ a(c.filter(Boolean));
50
+ }, [p, o, a, i, n]), y = s((t) => {
51
+ var r, c;
52
+ const e = (r = t.relatedTarget) == null ? void 0 : r.closest(".collaboration-user-selector");
53
+ (c = document.querySelector('div[role="listbox"][aria-labelledby^="user-contacts"]')) != null && c.contains(t.relatedTarget) || e || m([...n, {
54
+ value: t.target.value
55
+ }]);
56
+ }, [m, n]);
58
57
  return {
59
- errors: p,
60
- handleFormReset: f,
61
- handleFormSubmit: async () => u(a) || n(a[a.length - 1].value) ? !0 : (await U({}), f(), !1),
62
- handleSelectedUsersChange: V,
58
+ errors: f,
59
+ handleFormReset: S,
60
+ handleFormSubmit: async () => f["user-contact"] || i(n) ? !0 : (await U({}), S(), !1),
61
+ handleSelectedUsersChange: m,
63
62
  handleUserSelectorBlur: y,
64
63
  isFormSubmitting: b,
65
64
  updateContactValue: x
66
65
  };
67
66
  };
68
67
  export {
69
- N as useCollaborationForm
68
+ q as useCollaborationForm
70
69
  };
@@ -2,12 +2,12 @@ import { useState as g, useCallback as o } from "react";
2
2
  import { useIntl as v } from "react-intl";
3
3
  import a from "../messages.js";
4
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";
5
+ import { isVanityNameValid as w, isEmailValid as y, doesPasswordContainMinCharacters as N, doesPasswordContainInvalidCharacter as P, doesPasswordContainMixedCase as x, doesPasswordContainLetter as i, doesPasswordContainNumber as u, doesPasswordContainSymbol as d } from "../utils/validation.js";
6
6
  const R = () => {
7
7
  const {
8
8
  formatMessage: t
9
- } = v(), [l, i] = g({}), e = o((r, s) => {
10
- i((M) => ({
9
+ } = v(), [l, n] = g({}), e = o((r, s) => {
10
+ n((M) => ({
11
11
  ...M,
12
12
  [r]: s
13
13
  }));
@@ -16,7 +16,7 @@ const R = () => {
16
16
  return e("expiration", t(a.expirationRequiredErrorMessage)), !0;
17
17
  const s = p();
18
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]);
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) && !(i(r) && u(r)) && !(i(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
21
  errors: l,
22
22
  validateExpiration: m,
@@ -24,7 +24,7 @@ const R = () => {
24
24
  validateVanityName: c,
25
25
  validateUserContact: C,
26
26
  validateUserSelector: f,
27
- setErrors: i,
27
+ setErrors: n,
28
28
  setFieldError: e
29
29
  };
30
30
  };
@@ -1,58 +1,58 @@
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), {
1
+ import { useState as N, useCallback as d } from "react";
2
+ import { useFormValidation as b } from "./use-form-validation.js";
3
+ import { useSharingAction as P } from "./use-sharing-action.js";
4
+ import { getSharedLinkFormValidation as U } from "../utils/validation.js";
5
+ import { useUnifiedShareModalContext as A } from "../contexts/unified-share-modal-context.js";
6
+ const q = (t) => {
7
+ const [o, a] = N(t), {
8
8
  errors: l,
9
9
  setErrors: c,
10
10
  setFieldError: s,
11
11
  validateExpiration: u,
12
12
  validatePassword: n,
13
13
  validateVanityName: m
14
- } = N(), {
15
- sharedLink: {
16
- permissions: p
17
- },
18
- sharingService: f
19
- } = U(), {
20
- updateSharedLink: E
14
+ } = b(), {
15
+ sharedLink: f,
16
+ sharingService: E
17
+ } = A(), {
18
+ settings: p
21
19
  } = f, {
22
- isLoading: S,
20
+ updateSharedLink: S
21
+ } = E, {
22
+ isLoading: g,
23
23
  onAction: h
24
- } = b(E, "update-shared-link"), V = d((r, e) => {
24
+ } = P(S, "update-shared-link"), V = d((r, e) => {
25
25
  a((i) => ({
26
26
  ...i,
27
27
  [r]: e
28
28
  }));
29
- }, []), g = d(() => {
29
+ }, []), k = d(() => {
30
30
  a(t), c({});
31
- }, [t, c, a]), k = d(async () => {
31
+ }, [t, c, a]), x = d(async () => {
32
32
  const {
33
33
  updatedFormData: r,
34
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)
35
+ } = U(p, o, t), i = e.expiration && u(r.updatedExpiration), y = e.password && n(r.updatedPassword), v = e.vanityName && m(r.updatedVanityName);
36
+ if (i || y || v)
37
37
  return !0;
38
38
  try {
39
39
  await h(r);
40
- } catch (v) {
41
- return Object.entries(v).forEach(([w, F]) => s(w, F)), !0;
40
+ } catch (w) {
41
+ return Object.entries(w).forEach(([F, L]) => s(F, L)), !0;
42
42
  }
43
43
  return !1;
44
- }, [o, t, p, h, s, u, n, m]);
44
+ }, [o, t, h, s, p, u, n, m]);
45
45
  return {
46
46
  errors: l,
47
47
  formData: o,
48
- handleFormReset: g,
49
- handleFormSubmit: k,
50
- isUpdating: S,
48
+ handleFormReset: k,
49
+ handleFormSubmit: x,
50
+ isUpdating: g,
51
51
  setFieldError: s,
52
52
  setFieldValue: V,
53
53
  validatePassword: n
54
54
  };
55
55
  };
56
56
  export {
57
- R as useLinkSettingsForm
57
+ q as useLinkSettingsForm
58
58
  };
@@ -1,26 +1,26 @@
1
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";
2
+ import { formatDateFromTimestampToCalendarDate as d, formatDateFromTimestampToDateString as l, formatTomorrowDateToCalendarDate as m } from "./date.js";
3
3
  import { callOnKeyboardEvent as p } from "./event.js";
4
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";
5
+ import { doesPasswordContainInvalidCharacter as D, doesPasswordContainLetter as x, doesPasswordContainMinCharacters as P, doesPasswordContainMixedCase as S, doesPasswordContainNumber as T, doesPasswordContainSymbol as b, getSharedLinkFormValidation as c, isEmailValid as v, isVanityNameValid as u } from "./validation.js";
6
6
  export {
7
7
  p as callOnKeyboardEvent,
8
8
  D as doesPasswordContainInvalidCharacter,
9
9
  x as doesPasswordContainLetter,
10
10
  P as doesPasswordContainMinCharacters,
11
- S as doesPasswordContainNumber,
12
- T as doesPasswordContainSymbol,
13
- n as formatDateFromTimestampToCalendarDate,
11
+ S as doesPasswordContainMixedCase,
12
+ T as doesPasswordContainNumber,
13
+ b as doesPasswordContainSymbol,
14
+ d as formatDateFromTimestampToCalendarDate,
14
15
  l as formatDateFromTimestampToDateString,
15
16
  m as formatTomorrowDateToCalendarDate,
16
17
  w as getAllowedAccessLevels,
17
18
  e as getAvatarBadgeSize,
18
19
  t as getDefaultCollaborationRole,
19
20
  r as getFirstInitial,
20
- b as getSharedLinkFormValidation,
21
+ c as getSharedLinkFormValidation,
21
22
  i as isCollaboratorRoleSupported,
22
- c as isEmailValid,
23
+ v as isEmailValid,
23
24
  s as isInvitationRoleSupported,
24
- v as isPasswordMixedCase,
25
25
  u as isVanityNameValid
26
26
  };
@@ -1,4 +1,4 @@
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) => {
1
+ const m = /^[a-zA-Z0-9-]{12,30}$/, A = /^[A-Z0-9._'%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i, P = (a) => m.test(a), f = (a) => a.length === 0 ? !0 : A.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
2
  const {
3
3
  expiration: l,
4
4
  isDownloadEnabled: u,
@@ -11,10 +11,10 @@ const A = /^[a-zA-Z0-9-]{12,30}$/, C = /^[A-Z0-9._'%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$
11
11
  canChangeDownload: p,
12
12
  canChangeExpiration: w,
13
13
  canChangeVanityName: E,
14
- canChangePassword: b,
15
- isDownloadAvailable: g,
16
- isPasswordAvailable: h,
17
- isVanityNameAvailable: m
14
+ canChangePassword: C,
15
+ isDownloadAvailable: b,
16
+ isPasswordAvailable: g,
17
+ isVanityNameAvailable: h
18
18
  } = a, e = {
19
19
  updatedExpiration: n ? l : 0,
20
20
  updatedPassword: s ? i : "",
@@ -25,7 +25,7 @@ const A = /^[a-zA-Z0-9-]{12,30}$/, C = /^[A-Z0-9._'%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$
25
25
  password: !1,
26
26
  vanityName: !1
27
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), {
28
+ return w ? n && (t.expiration = !0) : e.updatedExpiration = void 0, !g || !C || r.isPasswordEnabled && !i ? e.updatedPassword = void 0 : s && (t.password = !0), !h || !E ? e.updatedVanityName = void 0 : o && (t.vanityName = !0), (!b || !p) && (e.updatedIsDownloadEnabled = void 0), {
29
29
  updatedFormData: e,
30
30
  shouldValidate: t
31
31
  };
@@ -34,10 +34,10 @@ export {
34
34
  D as doesPasswordContainInvalidCharacter,
35
35
  y as doesPasswordContainLetter,
36
36
  v as doesPasswordContainMinCharacters,
37
+ x as doesPasswordContainMixedCase,
37
38
  N as doesPasswordContainNumber,
38
39
  V as doesPasswordContainSymbol,
39
40
  Z as getSharedLinkFormValidation,
40
41
  f as isEmailValid,
41
- x as isPasswordMixedCase,
42
42
  P as isVanityNameValid
43
43
  };
@@ -1,7 +1,7 @@
1
1
  import { UserContactType } from '@box/user-selector';
2
2
  import { UnifiedShareModalContextValue } from '../contexts';
3
3
  import { UnifiedShareModalProps } from '../unified-share-modal';
4
- import { CollaborationRole, Collaborator, Configuration, Item, SharedLink, SharedLinkPermissions } from '../types';
4
+ import { CollaborationRole, Collaborator, Configuration, Item, SharedLink, SharedLinkSettings } from '../types';
5
5
  export declare const mockCollaborationRoles: CollaborationRole[];
6
6
  export declare const mockCollaborators: Collaborator[];
7
7
  export declare const mockCollaboratorsExtended: Collaborator[];
@@ -13,7 +13,7 @@ export declare const mockContactService: {
13
13
  };
14
14
  export declare const mockBoxFile: Item;
15
15
  export declare const mockBoxFolder: Item;
16
- export declare const mockSharedLinkPermissions: SharedLinkPermissions;
16
+ export declare const mockSharedLinkSettings: SharedLinkSettings;
17
17
  export declare const mockSharedLink: SharedLink;
18
18
  export declare const useMockSharedLink: (sharedLinkArg: any) => {
19
19
  sharedLink: SharedLink;
@@ -95,7 +95,7 @@ export interface Enterprise {
95
95
  */
96
96
  name?: string;
97
97
  }
98
- export interface SharedLinkPermissions {
98
+ export interface SharedLinkSettings {
99
99
  canChangeDownload?: boolean;
100
100
  canChangeExpiration?: boolean;
101
101
  canChangePassword?: boolean;
@@ -110,7 +110,7 @@ export interface SharedLink {
110
110
  access?: AccessLevelType;
111
111
  accessLevels?: (AccessLevel | AccessLevelType)[];
112
112
  expiresAt?: number;
113
- permissions?: SharedLinkPermissions;
113
+ settings?: SharedLinkSettings;
114
114
  url: string;
115
115
  vanityDomain?: string;
116
116
  vanityName?: string;
@@ -4,9 +4,9 @@ export declare const doesPasswordContainMinCharacters: (password: string) => boo
4
4
  export declare const doesPasswordContainNumber: (password: string) => boolean;
5
5
  export declare const doesPasswordContainSymbol: (password: string) => boolean;
6
6
  export declare const doesPasswordContainLetter: (password: string) => boolean;
7
- export declare const isPasswordMixedCase: (password: string) => boolean;
7
+ export declare const doesPasswordContainMixedCase: (password: string) => boolean;
8
8
  export declare const doesPasswordContainInvalidCharacter: (password: string) => boolean;
9
- export declare const getSharedLinkFormValidation: (permissions: any, formData: any, initialFormData: any) => {
9
+ export declare const getSharedLinkFormValidation: (settings: any, formData: any, initialFormData: any) => {
10
10
  updatedFormData: {
11
11
  updatedExpiration: any;
12
12
  updatedPassword: any;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@box/unified-share-modal",
3
- "version": "0.47.0",
3
+ "version": "0.47.2",
4
4
  "license": "SEE LICENSE IN LICENSE",
5
5
  "peerDependencies": {
6
6
  "@box/blueprint-web": "^9.18.13",
@@ -13,9 +13,9 @@
13
13
  "react-intl": "^6.4.2"
14
14
  },
15
15
  "devDependencies": {
16
- "@box/blueprint-web": "^12.69.2",
16
+ "@box/blueprint-web": "^12.71.0",
17
17
  "@box/blueprint-web-assets": "^4.67.0",
18
- "@box/copy-input": "^0.22.0",
18
+ "@box/copy-input": "^0.22.2",
19
19
  "@box/storybook-utils": "0.14.3",
20
20
  "@box/eslint-plugin-blueprint": "1.0.4",
21
21
  "react-intl": "^6.4.2"