@box/unified-share-modal 2.7.1 → 2.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.
package/dist/esm/lib/components/unified-share-form-modal/shared-link-section/shared-link-section.js
CHANGED
|
@@ -1,74 +1,75 @@
|
|
|
1
|
-
import { useRef as
|
|
2
|
-
import { useIntl as
|
|
3
|
-
import { useNotification as
|
|
4
|
-
import { ClockBadge as
|
|
5
|
-
import { Mail as
|
|
6
|
-
import { SurfaceStatusSurfaceRed as
|
|
7
|
-
import { CopyInput as
|
|
8
|
-
import { SharedLinkAccess as
|
|
9
|
-
import { SharedLinkPermission as
|
|
1
|
+
import { useRef as O, useCallback as E, useEffect as R } from "react";
|
|
2
|
+
import { useIntl as U } from "react-intl";
|
|
3
|
+
import { useNotification as z, Text as S, Tooltip as y, Focusable as K, Switch as G, Status as V, Link as q, Button as H } from "@box/blueprint-web";
|
|
4
|
+
import { ClockBadge as J } from "@box/blueprint-web-assets/icons/Line";
|
|
5
|
+
import { Mail as Q, Globe as D } from "@box/blueprint-web-assets/icons/Medium";
|
|
6
|
+
import { SurfaceStatusSurfaceRed as W, bpSize040 as g } from "@box/blueprint-web-assets/tokens/tokens";
|
|
7
|
+
import { CopyInput as X } from "@box/copy-input";
|
|
8
|
+
import { SharedLinkAccess as Y } from "./shared-link-access.js";
|
|
9
|
+
import { SharedLinkPermission as Z } from "./shared-link-permission.js";
|
|
10
10
|
import t from "./messages.js";
|
|
11
11
|
import { jsxs as d, jsx as i } from "react/jsx-runtime";
|
|
12
|
-
import { useUnifiedShareFormContext as
|
|
13
|
-
import { useUnifiedShareModalContext as
|
|
14
|
-
import { useSharingAction as
|
|
15
|
-
import { getNotificationArgs as
|
|
16
|
-
import { formatDateFromTimestampToDateString as
|
|
17
|
-
import { callOnKeyboardEvent as
|
|
18
|
-
import '../../../../../styles/shared-link-section.css';const
|
|
19
|
-
container:
|
|
20
|
-
toggle:
|
|
21
|
-
settings:
|
|
22
|
-
copy:
|
|
23
|
-
access:
|
|
24
|
-
icon:
|
|
12
|
+
import { useUnifiedShareFormContext as $ } from "../../../contexts/unified-share-form-context.js";
|
|
13
|
+
import { useUnifiedShareModalContext as ee } from "../../../contexts/unified-share-modal-context.js";
|
|
14
|
+
import { useSharingAction as te } from "../../../hooks/use-sharing-action.js";
|
|
15
|
+
import { getNotificationArgs as ie } from "../../../utils/notification.js";
|
|
16
|
+
import { formatDateFromTimestampToDateString as ae } from "../../../utils/date.js";
|
|
17
|
+
import { callOnKeyboardEvent as ne } from "../../../utils/event.js";
|
|
18
|
+
import '../../../../../styles/shared-link-section.css';const oe = "_container_j966c_1", re = "_toggle_j966c_7", se = "_settings_j966c_13", ce = "_copy_j966c_22", le = "_access_j966c_30", de = "_icon_j966c_36", c = {
|
|
19
|
+
container: oe,
|
|
20
|
+
toggle: re,
|
|
21
|
+
settings: se,
|
|
22
|
+
copy: ce,
|
|
23
|
+
access: le,
|
|
24
|
+
icon: de
|
|
25
25
|
};
|
|
26
|
-
function
|
|
26
|
+
function Ne() {
|
|
27
27
|
const {
|
|
28
28
|
formatMessage: e
|
|
29
|
-
} =
|
|
29
|
+
} = U(), {
|
|
30
30
|
addNotification: C
|
|
31
|
-
} =
|
|
31
|
+
} = z(), f = O(null), {
|
|
32
32
|
isSharedLinkAutoCopied: k,
|
|
33
33
|
isSharedLinkAutoCreated: r,
|
|
34
|
-
setForm:
|
|
35
|
-
} =
|
|
34
|
+
setForm: j
|
|
35
|
+
} = $(), {
|
|
36
36
|
config: s,
|
|
37
37
|
isFetching: v,
|
|
38
38
|
isSubmitting: n,
|
|
39
|
-
item:
|
|
39
|
+
item: w,
|
|
40
40
|
setView: L,
|
|
41
41
|
sharedLink: o,
|
|
42
|
-
sharingService:
|
|
43
|
-
} =
|
|
42
|
+
sharingService: I
|
|
43
|
+
} = ee(), {
|
|
44
44
|
permissions: x = {}
|
|
45
|
-
} = j, {
|
|
46
|
-
createSharedLink: _
|
|
47
45
|
} = w, {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
46
|
+
createSharedLink: _
|
|
47
|
+
} = I, {
|
|
48
|
+
notifications: T,
|
|
49
|
+
sharedLinkAutoCopy: P,
|
|
50
|
+
sharedLinkAutoCreate: A
|
|
51
|
+
} = s, a = !!o.url, h = P && !k.current, N = A && !r.current, B = E(async () => {
|
|
51
52
|
const l = await _();
|
|
52
53
|
return h ? {
|
|
53
54
|
messages: []
|
|
54
55
|
} : l;
|
|
55
56
|
}, [h, _]), {
|
|
56
57
|
onAction: b
|
|
57
|
-
} =
|
|
58
|
-
|
|
59
|
-
(async () => v || n || ((h ||
|
|
60
|
-
}, [a, h,
|
|
61
|
-
const
|
|
58
|
+
} = te(B, "create-shared-link");
|
|
59
|
+
R(() => {
|
|
60
|
+
(async () => v || n || ((h || N) && !a && (await b(), r.current = !0), h && a && f.current && (f.current.click(), k.current = !0)))();
|
|
61
|
+
}, [a, h, N, v, k, r, n, b]);
|
|
62
|
+
const F = E((l) => {
|
|
62
63
|
let p;
|
|
63
|
-
l
|
|
64
|
-
...
|
|
64
|
+
typeof l != "string" ? p = r.current ? e(t.autoCreateCopyErrorNoticeText) : null : p = r.current ? e(t.autoCreateCopySuccessNoticeText) : e(t.autoCopySuccessNoticeText), p && T.includes("auto-copy-shared-link") && C({
|
|
65
|
+
...ie(e, "success"),
|
|
65
66
|
styledText: p
|
|
66
67
|
});
|
|
67
|
-
}, [C, e, r]),
|
|
68
|
+
}, [C, e, r, T]), M = async (l) => {
|
|
68
69
|
l || L("remove-shared-link"), l && await b();
|
|
69
70
|
};
|
|
70
|
-
let
|
|
71
|
-
return !a && !n && (
|
|
71
|
+
let u, m = !1;
|
|
72
|
+
return !a && !n && (u = e(t.sharedLinkToggleTooltip)), !a && !x.canShare && (u = e(t.createLinkDisabledTooltip), m = !0), a && !x.canSetShareAccess && (u = e(t.removeLinkDisabledTooltip), m = !0), /* @__PURE__ */ d("div", {
|
|
72
73
|
className: c.container,
|
|
73
74
|
children: [/* @__PURE__ */ i(S, {
|
|
74
75
|
as: "label",
|
|
@@ -78,38 +79,38 @@ function Ae() {
|
|
|
78
79
|
className: c.toggle,
|
|
79
80
|
children: [/* @__PURE__ */ i(y, {
|
|
80
81
|
align: "start",
|
|
81
|
-
content:
|
|
82
|
+
content: u,
|
|
82
83
|
"data-testid": "shared-link-tooltip",
|
|
83
|
-
open:
|
|
84
|
-
children: /* @__PURE__ */ i(
|
|
85
|
-
focusable:
|
|
86
|
-
children: /* @__PURE__ */ i(
|
|
84
|
+
open: u ? void 0 : !1,
|
|
85
|
+
children: /* @__PURE__ */ i(K, {
|
|
86
|
+
focusable: m,
|
|
87
|
+
children: /* @__PURE__ */ i(G.Item, {
|
|
87
88
|
checked: a,
|
|
88
89
|
"data-target-id": "Toggle-CreateSharedLink",
|
|
89
|
-
disabled:
|
|
90
|
+
disabled: m || n,
|
|
90
91
|
label: e(t.sharedLinkToggleLabel),
|
|
91
|
-
onCheckedChange:
|
|
92
|
+
onCheckedChange: M,
|
|
92
93
|
value: "shared-link"
|
|
93
94
|
})
|
|
94
95
|
})
|
|
95
96
|
}), a && !!o.expiresAt && /* @__PURE__ */ i(y, {
|
|
96
97
|
content: e(t.expirationIconTooltip, {
|
|
97
|
-
expirationDate:
|
|
98
|
+
expirationDate: ae(o.expiresAt)
|
|
98
99
|
}),
|
|
99
100
|
"data-testid": "expiration-date-tooltip",
|
|
100
|
-
children: /* @__PURE__ */ i(
|
|
101
|
-
color:
|
|
101
|
+
children: /* @__PURE__ */ i(V, {
|
|
102
|
+
color: W,
|
|
102
103
|
hideText: !0,
|
|
103
|
-
icon:
|
|
104
|
+
icon: J,
|
|
104
105
|
text: e(t.expirationIconLabel)
|
|
105
106
|
})
|
|
106
|
-
}), a && s.sharedLinkSettings && /* @__PURE__ */ i(
|
|
107
|
+
}), a && s.sharedLinkSettings && /* @__PURE__ */ i(q, {
|
|
107
108
|
"aria-disabled": n,
|
|
108
109
|
"aria-haspopup": "dialog",
|
|
109
110
|
className: c.settings,
|
|
110
111
|
"data-target-id": "PlainButton-SharedLinkSettings",
|
|
111
112
|
onClick: () => L("shared-link-settings"),
|
|
112
|
-
onKeyDown:
|
|
113
|
+
onKeyDown: ne(() => L("shared-link-settings"), {
|
|
113
114
|
canPreventDefault: !0
|
|
114
115
|
}),
|
|
115
116
|
role: "button",
|
|
@@ -119,33 +120,33 @@ function Ae() {
|
|
|
119
120
|
})]
|
|
120
121
|
}), a && /* @__PURE__ */ d("div", {
|
|
121
122
|
className: c.copy,
|
|
122
|
-
children: [/* @__PURE__ */ i(
|
|
123
|
+
children: [/* @__PURE__ */ i(X, {
|
|
123
124
|
ref: f,
|
|
124
|
-
autoFocus:
|
|
125
|
+
autoFocus: A && r.current,
|
|
125
126
|
"data-target-id": "Button-CopySharedLink",
|
|
126
127
|
disabled: n,
|
|
127
128
|
hideLabel: !0,
|
|
128
129
|
label: e(t.sharedLinkUrlLabel),
|
|
129
|
-
onCopy:
|
|
130
|
+
onCopy: F,
|
|
130
131
|
value: o.url
|
|
131
132
|
}), s.sharedLinkEmail && /* @__PURE__ */ i(y, {
|
|
132
133
|
align: "end",
|
|
133
134
|
content: e(t.sharedLinkEmailLabel),
|
|
134
|
-
children: /* @__PURE__ */ i(
|
|
135
|
+
children: /* @__PURE__ */ i(H, {
|
|
135
136
|
"aria-label": e(t.sharedLinkEmailLabel),
|
|
136
137
|
"data-target-id": "Button-SendSharedLink",
|
|
137
138
|
disabled: n,
|
|
138
|
-
icon:
|
|
139
|
-
onClick: () =>
|
|
139
|
+
icon: Q,
|
|
140
|
+
onClick: () => j("email"),
|
|
140
141
|
size: "large",
|
|
141
142
|
variant: "secondary"
|
|
142
143
|
})
|
|
143
144
|
})]
|
|
144
145
|
}), a && (s.sharedLinkAccess || s.sharedLinkPermission) && /* @__PURE__ */ d("div", {
|
|
145
146
|
className: c.access,
|
|
146
|
-
children: [s.sharedLinkAccess && /* @__PURE__ */ i(
|
|
147
|
+
children: [s.sharedLinkAccess && /* @__PURE__ */ i(Y, {}), s.sharedLinkPermission && /* @__PURE__ */ i(Z, {})]
|
|
147
148
|
}), a && o.access === "open" && /* @__PURE__ */ d("div", {
|
|
148
|
-
children: [/* @__PURE__ */ i(
|
|
149
|
+
children: [/* @__PURE__ */ i(D, {
|
|
149
150
|
className: c.icon,
|
|
150
151
|
height: g,
|
|
151
152
|
width: g
|
|
@@ -155,7 +156,7 @@ function Ae() {
|
|
|
155
156
|
children: o.permission === "can_edit" ? e(t.sharedLinkEditablePubliclyAvailable) : e(t.sharedLinkPubliclyAvailable)
|
|
156
157
|
})]
|
|
157
158
|
}), a && o.access === "company" && o.permission === "can_edit" && /* @__PURE__ */ d("div", {
|
|
158
|
-
children: [/* @__PURE__ */ i(
|
|
159
|
+
children: [/* @__PURE__ */ i(D, {
|
|
159
160
|
className: c.icon,
|
|
160
161
|
height: g,
|
|
161
162
|
width: g
|
|
@@ -168,5 +169,5 @@ function Ae() {
|
|
|
168
169
|
});
|
|
169
170
|
}
|
|
170
171
|
export {
|
|
171
|
-
|
|
172
|
+
Ne as SharedLinkSection
|
|
172
173
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const e = ["invite-collaborators", "remove-collaborator", "create-shared-link", "delete-shared-link", "update-shared-link", "email-shared-link"], r = {
|
|
1
|
+
const e = ["invite-collaborators", "remove-collaborator", "create-shared-link", "delete-shared-link", "update-shared-link", "email-shared-link", "auto-copy-shared-link"], r = {
|
|
2
2
|
collaboration: !0,
|
|
3
3
|
collaborationLimit: 100,
|
|
4
4
|
collaborationMessage: !0,
|
|
@@ -29,7 +29,7 @@ export type FormType = 'default' | 'invite' | 'email' | 'collaborators';
|
|
|
29
29
|
/**
|
|
30
30
|
* Supported success and error notifications when the user performs sharing actions.
|
|
31
31
|
*/
|
|
32
|
-
export type NotificationType = 'invite-collaborators' | 'remove-collaborator' | 'create-shared-link' | 'delete-shared-link' | 'update-shared-link' | 'email-shared-link';
|
|
32
|
+
export type NotificationType = 'invite-collaborators' | 'remove-collaborator' | 'create-shared-link' | 'delete-shared-link' | 'update-shared-link' | 'email-shared-link' | 'auto-copy-shared-link';
|
|
33
33
|
/**
|
|
34
34
|
* Supported roles for inviting a new collaborator. The available roles are dependent on the Enterprise settings.
|
|
35
35
|
*
|
package/package.json
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@box/unified-share-modal",
|
|
3
|
-
"version": "2.7.
|
|
3
|
+
"version": "2.7.2",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE",
|
|
5
5
|
"peerDependencies": {
|
|
6
|
-
"@box/blueprint-web": "^13.5.
|
|
7
|
-
"@box/blueprint-web-assets": "^4.
|
|
8
|
-
"@box/copy-input": "^1.39.
|
|
9
|
-
"@box/user-selector": "^1.73.
|
|
6
|
+
"@box/blueprint-web": "^13.5.5",
|
|
7
|
+
"@box/blueprint-web-assets": "^4.104.0",
|
|
8
|
+
"@box/copy-input": "^1.39.10",
|
|
9
|
+
"@box/user-selector": "^1.73.11",
|
|
10
10
|
"lodash": "^4.17.15",
|
|
11
11
|
"react": "^18.0.0",
|
|
12
12
|
"react-dom": "^18.0.0",
|
|
13
13
|
"react-intl": "^6.4.2"
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
|
-
"@box/blueprint-web": "^13.5.
|
|
17
|
-
"@box/blueprint-web-assets": "^4.
|
|
18
|
-
"@box/copy-input": "^1.39.
|
|
19
|
-
"@box/storybook-utils": "0.16.
|
|
16
|
+
"@box/blueprint-web": "^13.5.5",
|
|
17
|
+
"@box/blueprint-web-assets": "^4.104.0",
|
|
18
|
+
"@box/copy-input": "^1.39.10",
|
|
19
|
+
"@box/storybook-utils": "0.16.61",
|
|
20
20
|
"@box/eslint-plugin-blueprint": "1.1.1",
|
|
21
21
|
"react-intl": "^6.4.2"
|
|
22
22
|
},
|