@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.
package/dist/esm/lib/components/unified-share-form-modal/collaboration-section/collaboration-role.js
CHANGED
|
@@ -1,111 +1,116 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { useState as
|
|
3
|
-
import { useIntl as
|
|
4
|
-
import { Tooltip as
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import { jsx as e, jsxs as
|
|
8
|
-
import { isInvitationRoleSupported as
|
|
9
|
-
import { useUnifiedShareFormContext as
|
|
10
|
-
import { useUnifiedShareModalContext as
|
|
11
|
-
import '../../../../../styles/collaboration-role.css';const
|
|
12
|
-
container:
|
|
13
|
-
focusable:
|
|
14
|
-
content:
|
|
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
|
|
16
|
+
function oe() {
|
|
17
17
|
const {
|
|
18
18
|
formatMessage: t
|
|
19
|
-
} =
|
|
20
|
-
collaborationRole:
|
|
21
|
-
setCollaborationRole:
|
|
22
|
-
} =
|
|
23
|
-
collaborationRoles:
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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:
|
|
34
|
+
description: c,
|
|
32
35
|
id: o,
|
|
33
|
-
label:
|
|
34
|
-
} = i,
|
|
35
|
-
let
|
|
36
|
-
o === "editor" &&
|
|
37
|
-
let
|
|
38
|
-
return
|
|
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:
|
|
41
|
-
label:
|
|
43
|
+
description: c ?? x,
|
|
44
|
+
label: n ?? v
|
|
42
45
|
};
|
|
43
|
-
}), [
|
|
44
|
-
if (
|
|
45
|
-
|
|
46
|
-
}, [r,
|
|
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:
|
|
50
|
-
label:
|
|
51
|
-
} =
|
|
52
|
-
let
|
|
53
|
-
return
|
|
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:
|
|
58
|
+
content: s,
|
|
56
59
|
"data-testid": "collaboration-role-tooltip",
|
|
57
60
|
side: "bottom",
|
|
58
|
-
children: /* @__PURE__ */ e(
|
|
59
|
-
className:
|
|
60
|
-
children: /* @__PURE__ */ e(
|
|
61
|
+
children: /* @__PURE__ */ e(j, {
|
|
62
|
+
className: m.focusable,
|
|
63
|
+
children: /* @__PURE__ */ e(_, {
|
|
61
64
|
caretDirection: "down",
|
|
62
|
-
className:
|
|
65
|
+
className: m.container,
|
|
63
66
|
disabled: !0,
|
|
64
|
-
label: t(
|
|
65
|
-
role:
|
|
67
|
+
label: t(a.inviteAsRoleLabel, {
|
|
68
|
+
role: R
|
|
66
69
|
}),
|
|
67
70
|
size: "extraSmall",
|
|
68
71
|
variant: "tertiary"
|
|
69
72
|
})
|
|
70
73
|
})
|
|
71
|
-
}) : /* @__PURE__ */
|
|
72
|
-
onOpenChange:
|
|
73
|
-
open:
|
|
74
|
-
children: [/* @__PURE__ */ e(
|
|
75
|
-
children: /* @__PURE__ */ e(
|
|
76
|
-
caretDirection:
|
|
77
|
-
className:
|
|
78
|
-
disabled:
|
|
79
|
-
label: t(
|
|
80
|
-
role:
|
|
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(
|
|
88
|
+
}), /* @__PURE__ */ e(l.Content, {
|
|
86
89
|
align: "start",
|
|
87
|
-
className:
|
|
90
|
+
className: m.content,
|
|
88
91
|
children: r.map((i) => {
|
|
89
92
|
const {
|
|
90
|
-
description:
|
|
93
|
+
description: c,
|
|
91
94
|
isDisabled: o,
|
|
92
|
-
id:
|
|
93
|
-
label:
|
|
94
|
-
} = i
|
|
95
|
-
|
|
96
|
-
|
|
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:
|
|
99
|
-
children: /* @__PURE__ */ e(
|
|
100
|
-
caption:
|
|
101
|
-
label:
|
|
102
|
-
title:
|
|
103
|
+
onSelect: d,
|
|
104
|
+
children: /* @__PURE__ */ e(l.Item.MainContent, {
|
|
105
|
+
caption: c,
|
|
106
|
+
label: f,
|
|
107
|
+
title: c
|
|
103
108
|
})
|
|
104
|
-
},
|
|
109
|
+
}, n);
|
|
105
110
|
})
|
|
106
111
|
})]
|
|
107
112
|
});
|
|
108
113
|
}
|
|
109
114
|
export {
|
|
110
|
-
|
|
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
|
*
|