@box/unified-share-modal 1.40.6 → 1.41.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,111 +1,116 @@
1
- import T from "lodash/camelCase";
2
- import { useState as y, useMemo as L, useEffect as k } from "react";
3
- import { useIntl as N } from "react-intl";
4
- import { Tooltip as F, Focusable as O, TriggerButton as D, DropdownMenu as n } from "@box/blueprint-web";
5
- import $ from "../messages.js";
6
- import l from "./messages.js";
7
- import { jsx as e, jsxs as j } from "react/jsx-runtime";
8
- import { isInvitationRoleSupported as z, getDefaultCollaborationRole as A } from "../../../utils/collaborator.js";
9
- import { useUnifiedShareFormContext as P } from "../../../contexts/unified-share-form-context.js";
10
- import { useUnifiedShareModalContext as U } from "../../../contexts/unified-share-modal-context.js";
11
- import '../../../../../styles/collaboration-role.css';const B = "_container_15wt1_1", E = "_focusable_15wt1_10", W = "_content_15wt1_14", d = {
12
- container: B,
13
- focusable: E,
14
- content: W
1
+ import L from "lodash/camelCase";
2
+ import { useState as k, useMemo as N, useEffect as F } from "react";
3
+ import { useIntl as O } from "react-intl";
4
+ import { Tooltip as $, Focusable as j, TriggerButton as _, DropdownMenu as l } from "@box/blueprint-web";
5
+ import z from "../messages.js";
6
+ import a from "./messages.js";
7
+ import { jsx as e, jsxs as A } from "react/jsx-runtime";
8
+ import { isInvitationRoleSupported as P, getDefaultCollaborationRole as U } from "../../../utils/collaborator.js";
9
+ import { useUnifiedShareFormContext as B } from "../../../contexts/unified-share-form-context.js";
10
+ import { useUnifiedShareModalContext as E } from "../../../contexts/unified-share-modal-context.js";
11
+ import '../../../../../styles/collaboration-role.css';const W = "_container_15wt1_1", q = "_focusable_15wt1_10", G = "_content_15wt1_14", m = {
12
+ container: W,
13
+ focusable: q,
14
+ content: G
15
15
  };
16
- function ee() {
16
+ function oe() {
17
17
  const {
18
18
  formatMessage: t
19
- } = N(), [f, M] = y(!1), {
20
- collaborationRole: u,
21
- setCollaborationRole: m
22
- } = P(), {
23
- collaborationRoles: g,
24
- isSubmitting: S,
25
- item: v
26
- } = U(), {
27
- permissions: w = {},
28
- type: p
29
- } = v, r = L(() => g.map((i) => {
19
+ } = O(), [u, D] = k(!1), {
20
+ collaborationRole: g,
21
+ setCollaborationRole: p
22
+ } = B(), {
23
+ collaborationRoles: h,
24
+ eventService: M,
25
+ isSubmitting: w,
26
+ item: I
27
+ } = E(), {
28
+ permissions: T = {},
29
+ type: b
30
+ } = I, {
31
+ onCollaborationRoleChange: C
32
+ } = M, r = N(() => h.map((i) => {
30
33
  const {
31
- description: s,
34
+ description: c,
32
35
  id: o,
33
- label: c
34
- } = i, b = z(o), C = T(o);
35
- let R = C;
36
- o === "editor" && p === "folder" && (R += "Folder");
37
- let x = o, _ = "";
38
- return b && (x = t($[`${C}Role`]), _ = t(l[`${R}Description`])), {
36
+ label: n
37
+ } = i, f = P(o), d = L(o);
38
+ let S = d;
39
+ o === "editor" && b === "folder" && (S += "Folder");
40
+ let v = o, x = "";
41
+ return f && (v = t(z[`${d}Role`]), x = t(a[`${S}Description`])), {
39
42
  ...i,
40
- description: s ?? _,
41
- label: c ?? x
43
+ description: c ?? x,
44
+ label: n ?? v
42
45
  };
43
- }), [g, t, p]);
44
- if (k(() => {
45
- m(A(r));
46
- }, [r, m]), !r.length || !u)
46
+ }), [h, t, b]);
47
+ if (F(() => {
48
+ p(U(r));
49
+ }, [r, p]), !r.length || !g)
47
50
  return null;
48
51
  const {
49
- id: I,
50
- label: h
51
- } = u;
52
- let a;
53
- return w.canInviteCollaborator || (a = t(l.inviteDisabledTooltip)), p === "web_link" && (a = t(l.inviteWebLinkDisabledTooltip)), a ? /* @__PURE__ */ e(F, {
52
+ id: y,
53
+ label: R
54
+ } = g;
55
+ let s;
56
+ return T.canInviteCollaborator || (s = t(a.inviteDisabledTooltip)), b === "web_link" && (s = t(a.inviteWebLinkDisabledTooltip)), s ? /* @__PURE__ */ e($, {
54
57
  align: "start",
55
- content: a,
58
+ content: s,
56
59
  "data-testid": "collaboration-role-tooltip",
57
60
  side: "bottom",
58
- children: /* @__PURE__ */ e(O, {
59
- className: d.focusable,
60
- children: /* @__PURE__ */ e(D, {
61
+ children: /* @__PURE__ */ e(j, {
62
+ className: m.focusable,
63
+ children: /* @__PURE__ */ e(_, {
61
64
  caretDirection: "down",
62
- className: d.container,
65
+ className: m.container,
63
66
  disabled: !0,
64
- label: t(l.inviteAsRoleLabel, {
65
- role: h
67
+ label: t(a.inviteAsRoleLabel, {
68
+ role: R
66
69
  }),
67
70
  size: "extraSmall",
68
71
  variant: "tertiary"
69
72
  })
70
73
  })
71
- }) : /* @__PURE__ */ j(n.Root, {
72
- onOpenChange: M,
73
- open: f,
74
- children: [/* @__PURE__ */ e(n.Trigger, {
75
- children: /* @__PURE__ */ e(D, {
76
- caretDirection: f ? "up" : "down",
77
- className: d.container,
78
- disabled: S,
79
- label: t(l.inviteAsRoleLabel, {
80
- role: h
74
+ }) : /* @__PURE__ */ A(l.Root, {
75
+ onOpenChange: D,
76
+ open: u,
77
+ children: [/* @__PURE__ */ e(l.Trigger, {
78
+ children: /* @__PURE__ */ e(_, {
79
+ caretDirection: u ? "up" : "down",
80
+ className: m.container,
81
+ disabled: w,
82
+ label: t(a.inviteAsRoleLabel, {
83
+ role: R
81
84
  }),
82
85
  size: "extraSmall",
83
86
  variant: "tertiary"
84
87
  })
85
- }), /* @__PURE__ */ e(n.Content, {
88
+ }), /* @__PURE__ */ e(l.Content, {
86
89
  align: "start",
87
- className: d.content,
90
+ className: m.content,
88
91
  children: r.map((i) => {
89
92
  const {
90
- description: s,
93
+ description: c,
91
94
  isDisabled: o,
92
- id: c,
93
- label: b
94
- } = i;
95
- return /* @__PURE__ */ e(n.CheckboxItem, {
96
- checked: I === c,
95
+ id: n,
96
+ label: f
97
+ } = i, d = () => {
98
+ p(i), C && C(n);
99
+ };
100
+ return /* @__PURE__ */ e(l.CheckboxItem, {
101
+ checked: y === n,
97
102
  disabled: o,
98
- onSelect: () => m(i),
99
- children: /* @__PURE__ */ e(n.Item.MainContent, {
100
- caption: s,
101
- label: b,
102
- title: s
103
+ onSelect: d,
104
+ children: /* @__PURE__ */ e(l.Item.MainContent, {
105
+ caption: c,
106
+ label: f,
107
+ title: c
103
108
  })
104
- }, c);
109
+ }, n);
105
110
  })
106
111
  })]
107
112
  });
108
113
  }
109
114
  export {
110
- ee as CollaborationRole
115
+ oe as CollaborationRole
111
116
  };
@@ -334,6 +334,10 @@ export interface CollaborationRole {
334
334
  label?: string;
335
335
  }
336
336
  export interface EventService {
337
+ /**
338
+ * Function to observe when the user changes the collaboration role.
339
+ */
340
+ onCollaborationRoleChange?: (role: InvitationRole | string) => void;
337
341
  /**
338
342
  * Function to customize the click behavior of the "Shared with ..." list of avatars.
339
343
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@box/unified-share-modal",
3
- "version": "1.40.6",
3
+ "version": "1.41.0",
4
4
  "license": "SEE LICENSE IN LICENSE",
5
5
  "peerDependencies": {
6
6
  "@box/blueprint-web": "^12.130.0",