@uipath/apollo-wind 2.86.1 → 2.88.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/components/ui/connection-picker/components/connection-actions-menu.cjs +129 -0
- package/dist/components/ui/connection-picker/components/connection-actions-menu.d.ts +21 -0
- package/dist/components/ui/connection-picker/components/connection-actions-menu.js +95 -0
- package/dist/components/ui/connection-picker/components/connection-status.cjs +81 -0
- package/dist/components/ui/connection-picker/components/connection-status.d.ts +22 -0
- package/dist/components/ui/connection-picker/components/connection-status.js +41 -0
- package/dist/components/ui/connection-picker/connection-picker.cjs +411 -0
- package/dist/components/ui/connection-picker/connection-picker.d.ts +12 -0
- package/dist/components/ui/connection-picker/connection-picker.js +374 -0
- package/dist/components/ui/connection-picker/index.cjs +39 -0
- package/dist/components/ui/connection-picker/index.d.ts +2 -0
- package/dist/components/ui/connection-picker/index.js +2 -0
- package/dist/components/ui/connection-picker/types.cjs +18 -0
- package/dist/components/ui/connection-picker/types.d.ts +124 -0
- package/dist/components/ui/connection-picker/types.js +0 -0
- package/dist/components/ui/field-addons/field-menu.cjs +41 -23
- package/dist/components/ui/field-addons/field-menu.d.ts +2 -0
- package/dist/components/ui/field-addons/field-menu.js +42 -24
- package/dist/components/ui/folder-picker/folder-picker.cjs +4 -3
- package/dist/components/ui/folder-picker/folder-picker.js +4 -3
- package/dist/components/ui/index.cjs +267 -241
- package/dist/components/ui/index.d.ts +2 -0
- package/dist/components/ui/index.js +2 -0
- package/dist/components/ui/{folder-picker/components/folder-picker-empty-state.cjs → picker-empty-state.cjs} +11 -11
- package/dist/components/ui/picker-empty-state.d.ts +33 -0
- package/dist/components/ui/{folder-picker/components/folder-picker-empty-state.js → picker-empty-state.js} +9 -9
- package/dist/components/ui/resource-picker/command-value.cjs +48 -0
- package/dist/components/ui/resource-picker/command-value.d.ts +11 -0
- package/dist/components/ui/resource-picker/command-value.js +11 -0
- package/dist/components/ui/resource-picker/components/resource-group-header.cjs +102 -0
- package/dist/components/ui/resource-picker/components/resource-group-header.d.ts +44 -0
- package/dist/components/ui/resource-picker/components/resource-group-header.js +65 -0
- package/dist/components/ui/resource-picker/components/resource-picker-footer.cjs +55 -0
- package/dist/components/ui/resource-picker/components/resource-picker-footer.d.ts +14 -0
- package/dist/components/ui/resource-picker/components/resource-picker-footer.js +21 -0
- package/dist/components/ui/resource-picker/components/resource-row-actions-menu.cjs +136 -0
- package/dist/components/ui/resource-picker/components/resource-row-actions-menu.d.ts +30 -0
- package/dist/components/ui/resource-picker/components/resource-row-actions-menu.js +102 -0
- package/dist/components/ui/resource-picker/components/resource-row.cjs +115 -0
- package/dist/components/ui/resource-picker/components/resource-row.d.ts +16 -0
- package/dist/components/ui/resource-picker/components/resource-row.js +81 -0
- package/dist/components/ui/resource-picker/focus.cjs +66 -0
- package/dist/components/ui/resource-picker/focus.d.ts +1 -0
- package/dist/components/ui/resource-picker/focus.js +32 -0
- package/dist/components/ui/resource-picker/index.cjs +42 -0
- package/dist/components/ui/resource-picker/index.d.ts +2 -0
- package/dist/components/ui/resource-picker/index.js +2 -0
- package/dist/components/ui/resource-picker/resource-picker.cjs +606 -0
- package/dist/components/ui/resource-picker/resource-picker.d.ts +40 -0
- package/dist/components/ui/resource-picker/resource-picker.js +566 -0
- package/dist/components/ui/resource-picker/types.cjs +50 -0
- package/dist/components/ui/resource-picker/types.d.ts +209 -0
- package/dist/components/ui/resource-picker/types.js +16 -0
- package/dist/index.cjs +24 -7
- package/dist/index.d.ts +4 -0
- package/dist/index.js +3 -1
- package/dist/styles.css +75 -29
- package/package.json +1 -1
- package/dist/components/ui/folder-picker/components/folder-picker-empty-state.d.ts +0 -26
|
@@ -0,0 +1,374 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Pencil, Plus } from "lucide-react";
|
|
4
|
+
import { forwardRef, useCallback, useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
5
|
+
import { Button } from "../button.js";
|
|
6
|
+
import { FormFieldError } from "../form-field.js";
|
|
7
|
+
import { InputGroup, InputGroupAddon, InputGroupTrigger } from "../input-group.js";
|
|
8
|
+
import { InputGroupContext, NO_GROUP, NO_GROUP_DISABLED, useInputGroup } from "../input-group-context.js";
|
|
9
|
+
import { cn } from "../../../lib/index.js";
|
|
10
|
+
import { ResourcePicker } from "../resource-picker/resource-picker.js";
|
|
11
|
+
import { ConnectionActionsMenu } from "./components/connection-actions-menu.js";
|
|
12
|
+
import { ConnectionStatusDot, ConnectionStatusLine, STATUS_LABELS } from "./components/connection-status.js";
|
|
13
|
+
const DEFAULT_CONNECTION_PICKER_STRINGS = {
|
|
14
|
+
statusLabels: STATUS_LABELS,
|
|
15
|
+
defaultReasons: {
|
|
16
|
+
broken: 'Connection broken. Reconnect to restore access.',
|
|
17
|
+
warning: 'Connection needs attention.'
|
|
18
|
+
},
|
|
19
|
+
fix: 'Fix',
|
|
20
|
+
fixLabel: (name)=>`Fix ${name}`,
|
|
21
|
+
edit: 'Edit',
|
|
22
|
+
editLabel: (name)=>`Edit ${name}`,
|
|
23
|
+
addNewConnection: 'Add new connection',
|
|
24
|
+
listLabel: 'Connections',
|
|
25
|
+
optionsLabel: 'Connection options',
|
|
26
|
+
editConnection: 'Edit connection',
|
|
27
|
+
refreshSchema: 'Refresh schema',
|
|
28
|
+
refreshingSchema: 'Refreshing schema...',
|
|
29
|
+
schemaRefreshed: 'Schema refreshed',
|
|
30
|
+
noMatchText: (query)=>`No results match “${query}”.`,
|
|
31
|
+
collapsedGroupLabel: (label)=>`${label}, collapsed`,
|
|
32
|
+
expandedGroupLabel: (label)=>`${label}, expanded`,
|
|
33
|
+
actionsMenuLabel: (label)=>`Actions for ${label}`
|
|
34
|
+
};
|
|
35
|
+
const statusOf = (connection)=>connection.status ?? 'connected';
|
|
36
|
+
const headlineOf = (reason)=>reason.split(/(?<=\.)\s+/)[0]?.replace(/\.$/, '') ?? '';
|
|
37
|
+
const statusLabelOf = (connection, labels)=>{
|
|
38
|
+
const status = statusOf(connection);
|
|
39
|
+
return 'warning' === status && connection.statusReason ? headlineOf(connection.statusReason) : labels[status];
|
|
40
|
+
};
|
|
41
|
+
const displayName = (connection)=>connection.account || connection.name;
|
|
42
|
+
const distinguishingName = (connection, collisions)=>connection.account && connection.account !== connection.name && collisions.has(displayName(connection)) ? connection.name : void 0;
|
|
43
|
+
const byHealth = (a, b)=>('broken' === statusOf(a) ? 1 : 0) - ('broken' === statusOf(b) ? 1 : 0);
|
|
44
|
+
function ConnectionPickerField({ connections, value = '', onSelect, onClear, onFix, onEdit, onAddConnection, onRefreshSchema, error, errorId, defaultFolder = 'My Workspace', addConnectionLabel = 'Add connection', placeholder = 'Select connection...', searchPlaceholder = 'Search connections...', emptyText = 'No connections yet.', strings, disabled: disabledProp = false, open: controlledOpen, onOpenChange, className, id, 'aria-labelledby': ariaLabelledBy, 'aria-describedby': ariaDescribedBy, 'aria-invalid': ariaInvalid, 'aria-errormessage': ariaErrorMessage, ...pickerProps }, forwardedRef) {
|
|
45
|
+
const enclosing = useInputGroup();
|
|
46
|
+
const disabled = disabledProp || Boolean(enclosing.disabled);
|
|
47
|
+
const groupContext = disabled ? NO_GROUP_DISABLED : NO_GROUP;
|
|
48
|
+
const messageId = useId();
|
|
49
|
+
const healthId = useId();
|
|
50
|
+
const addTextId = useId();
|
|
51
|
+
const loadErrorId = useId();
|
|
52
|
+
const text = useMemo(()=>({
|
|
53
|
+
...DEFAULT_CONNECTION_PICKER_STRINGS,
|
|
54
|
+
...strings
|
|
55
|
+
}), [
|
|
56
|
+
strings
|
|
57
|
+
]);
|
|
58
|
+
const [uncontrolledOpen, setUncontrolledOpen] = useState(false);
|
|
59
|
+
const open = controlledOpen ?? uncontrolledOpen;
|
|
60
|
+
const setOpen = (nextOpen)=>{
|
|
61
|
+
if (void 0 === controlledOpen) setUncontrolledOpen(nextOpen);
|
|
62
|
+
onOpenChange?.(nextOpen);
|
|
63
|
+
};
|
|
64
|
+
const addOnly = 0 === connections.length && Boolean(onAddConnection) && !value && !pickerProps.loading && !pickerProps.loadError;
|
|
65
|
+
const closedByAddOnly = addOnly && open;
|
|
66
|
+
useEffect(()=>{
|
|
67
|
+
if (closedByAddOnly) setOpen(false);
|
|
68
|
+
}, [
|
|
69
|
+
closedByAddOnly
|
|
70
|
+
]);
|
|
71
|
+
const focusWithin = useRef(false);
|
|
72
|
+
const trackFocus = {
|
|
73
|
+
onFocus: ()=>{
|
|
74
|
+
focusWithin.current = true;
|
|
75
|
+
},
|
|
76
|
+
onBlur: ()=>{
|
|
77
|
+
focusWithin.current = false;
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
const fieldRef = useRef(null);
|
|
81
|
+
const fieldControl = ()=>fieldRef.current?.querySelector('[data-slot="input-group-control"]');
|
|
82
|
+
useLayoutEffect(()=>{
|
|
83
|
+
if (!focusWithin.current) return;
|
|
84
|
+
const focusControl = ()=>{
|
|
85
|
+
const control = fieldControl();
|
|
86
|
+
if (!control) return;
|
|
87
|
+
const active = control.getRootNode().activeElement;
|
|
88
|
+
if (!active || active === control.ownerDocument.body) control.focus();
|
|
89
|
+
};
|
|
90
|
+
focusControl();
|
|
91
|
+
const settle = window.setTimeout(focusControl, 0);
|
|
92
|
+
return ()=>window.clearTimeout(settle);
|
|
93
|
+
}, [
|
|
94
|
+
addOnly
|
|
95
|
+
]);
|
|
96
|
+
const byId = useMemo(()=>new Map(connections.map((connection)=>[
|
|
97
|
+
connection.id,
|
|
98
|
+
connection
|
|
99
|
+
])), [
|
|
100
|
+
connections
|
|
101
|
+
]);
|
|
102
|
+
const collisions = useMemo(()=>{
|
|
103
|
+
const seen = new Set();
|
|
104
|
+
const shared = new Set();
|
|
105
|
+
for (const connection of connections){
|
|
106
|
+
const name = displayName(connection);
|
|
107
|
+
if (seen.has(name)) shared.add(name);
|
|
108
|
+
else seen.add(name);
|
|
109
|
+
}
|
|
110
|
+
return shared;
|
|
111
|
+
}, [
|
|
112
|
+
connections
|
|
113
|
+
]);
|
|
114
|
+
const fullName = useCallback((connection)=>{
|
|
115
|
+
const secondary = distinguishingName(connection, collisions);
|
|
116
|
+
return secondary ? `${displayName(connection)} (${secondary})` : displayName(connection);
|
|
117
|
+
}, [
|
|
118
|
+
collisions
|
|
119
|
+
]);
|
|
120
|
+
const groups = useMemo(()=>{
|
|
121
|
+
const folders = new Map();
|
|
122
|
+
for (const connection of connections){
|
|
123
|
+
const folder = connection.folder || defaultFolder;
|
|
124
|
+
const members = folders.get(folder);
|
|
125
|
+
if (members) members.push(connection);
|
|
126
|
+
else folders.set(folder, [
|
|
127
|
+
connection
|
|
128
|
+
]);
|
|
129
|
+
}
|
|
130
|
+
return [
|
|
131
|
+
...folders
|
|
132
|
+
].map(([folder, members])=>({
|
|
133
|
+
id: folder,
|
|
134
|
+
label: folder,
|
|
135
|
+
items: [
|
|
136
|
+
...members
|
|
137
|
+
].sort(byHealth).map((connection)=>({
|
|
138
|
+
id: connection.id,
|
|
139
|
+
label: displayName(connection),
|
|
140
|
+
description: distinguishingName(connection, collisions),
|
|
141
|
+
fieldLabel: fullName(connection),
|
|
142
|
+
icon: connection.logo ? /*#__PURE__*/ jsx("img", {
|
|
143
|
+
src: connection.logo,
|
|
144
|
+
alt: "",
|
|
145
|
+
className: "size-4 object-contain"
|
|
146
|
+
}) : connection.icon,
|
|
147
|
+
subtitle: /*#__PURE__*/ jsx(ConnectionStatusLine, {
|
|
148
|
+
status: statusOf(connection),
|
|
149
|
+
label: statusLabelOf(connection, text.statusLabels)
|
|
150
|
+
}),
|
|
151
|
+
subtitleText: statusLabelOf(connection, text.statusLabels),
|
|
152
|
+
keywords: [
|
|
153
|
+
connection.name,
|
|
154
|
+
...connection.keywords ?? []
|
|
155
|
+
],
|
|
156
|
+
disabled: connection.disabled
|
|
157
|
+
}))
|
|
158
|
+
}));
|
|
159
|
+
}, [
|
|
160
|
+
connections,
|
|
161
|
+
defaultFolder,
|
|
162
|
+
text.statusLabels,
|
|
163
|
+
collisions,
|
|
164
|
+
fullName
|
|
165
|
+
]);
|
|
166
|
+
const selected = value ? byId.get(value) : void 0;
|
|
167
|
+
const selectedStatus = selected ? statusOf(selected) : void 0;
|
|
168
|
+
const unhealthy = 'broken' === selectedStatus || 'warning' === selectedStatus;
|
|
169
|
+
const handOff = (action, connection)=>{
|
|
170
|
+
setOpen(false);
|
|
171
|
+
action(connection);
|
|
172
|
+
};
|
|
173
|
+
const itemActions = onFix || onEdit ? (item)=>{
|
|
174
|
+
const connection = byId.get(item.id);
|
|
175
|
+
if (!connection) return [];
|
|
176
|
+
const name = fullName(connection);
|
|
177
|
+
const actions = [];
|
|
178
|
+
if (onFix && 'broken' === statusOf(connection)) actions.push({
|
|
179
|
+
id: 'fix',
|
|
180
|
+
label: text.fixLabel(name),
|
|
181
|
+
text: text.fix,
|
|
182
|
+
tone: 'danger',
|
|
183
|
+
onSelect: ()=>handOff(onFix, connection)
|
|
184
|
+
});
|
|
185
|
+
if (onEdit) actions.push({
|
|
186
|
+
id: 'edit',
|
|
187
|
+
label: text.editLabel(name),
|
|
188
|
+
text: text.edit,
|
|
189
|
+
icon: /*#__PURE__*/ jsx(Pencil, {
|
|
190
|
+
className: "size-3.5"
|
|
191
|
+
}),
|
|
192
|
+
onSelect: ()=>handOff(onEdit, connection)
|
|
193
|
+
});
|
|
194
|
+
return actions;
|
|
195
|
+
} : void 0;
|
|
196
|
+
const reason = selected && unhealthy ? selected.statusReason || text.defaultReasons[selectedStatus] : '';
|
|
197
|
+
const summary = headlineOf(reason);
|
|
198
|
+
const { loadError, onRetry, retryLabel = 'Retry' } = pickerProps;
|
|
199
|
+
const showLoadError = !error && Boolean(loadError);
|
|
200
|
+
const showHealth = !error && !showLoadError && Boolean(summary);
|
|
201
|
+
const broken = 'broken' === selectedStatus;
|
|
202
|
+
const describedBy = [
|
|
203
|
+
ariaDescribedBy,
|
|
204
|
+
selectedStatus ? healthId : void 0,
|
|
205
|
+
showHealth ? messageId : void 0,
|
|
206
|
+
showLoadError ? loadErrorId : void 0
|
|
207
|
+
].filter(Boolean).join(' ') || void 0;
|
|
208
|
+
const fieldProps = {
|
|
209
|
+
id,
|
|
210
|
+
'aria-labelledby': ariaLabelledBy,
|
|
211
|
+
'aria-describedby': describedBy
|
|
212
|
+
};
|
|
213
|
+
if (addOnly) return /*#__PURE__*/ jsx(InputGroupContext.Provider, {
|
|
214
|
+
value: groupContext,
|
|
215
|
+
children: /*#__PURE__*/ jsx("div", {
|
|
216
|
+
ref: fieldRef,
|
|
217
|
+
className: cn('min-w-0', className),
|
|
218
|
+
...trackFocus,
|
|
219
|
+
children: /*#__PURE__*/ jsxs(InputGroup, {
|
|
220
|
+
error: error,
|
|
221
|
+
errorId: errorId ?? messageId,
|
|
222
|
+
children: [
|
|
223
|
+
/*#__PURE__*/ jsx(InputGroupAddon, {
|
|
224
|
+
align: "inline-start",
|
|
225
|
+
children: /*#__PURE__*/ jsx(Plus, {
|
|
226
|
+
"aria-hidden": true,
|
|
227
|
+
className: "text-foreground-muted"
|
|
228
|
+
})
|
|
229
|
+
}),
|
|
230
|
+
/*#__PURE__*/ jsx(InputGroupTrigger, {
|
|
231
|
+
ref: forwardedRef,
|
|
232
|
+
...fieldProps,
|
|
233
|
+
"aria-labelledby": ariaLabelledBy ? `${ariaLabelledBy} ${addTextId}` : id ? `${id} ${addTextId}` : void 0,
|
|
234
|
+
"aria-invalid": ariaInvalid,
|
|
235
|
+
"aria-errormessage": ariaErrorMessage,
|
|
236
|
+
disabled: disabled,
|
|
237
|
+
onClick: onAddConnection,
|
|
238
|
+
children: /*#__PURE__*/ jsx("span", {
|
|
239
|
+
id: addTextId,
|
|
240
|
+
className: "min-w-0 flex-1 truncate text-foreground-subtle",
|
|
241
|
+
children: addConnectionLabel
|
|
242
|
+
})
|
|
243
|
+
})
|
|
244
|
+
]
|
|
245
|
+
})
|
|
246
|
+
})
|
|
247
|
+
});
|
|
248
|
+
return /*#__PURE__*/ jsx(InputGroupContext.Provider, {
|
|
249
|
+
value: groupContext,
|
|
250
|
+
children: /*#__PURE__*/ jsxs("div", {
|
|
251
|
+
ref: fieldRef,
|
|
252
|
+
className: cn('min-w-0', className),
|
|
253
|
+
...trackFocus,
|
|
254
|
+
children: [
|
|
255
|
+
/*#__PURE__*/ jsx(ResourcePicker, {
|
|
256
|
+
ref: forwardedRef,
|
|
257
|
+
...pickerProps,
|
|
258
|
+
...fieldProps,
|
|
259
|
+
"aria-invalid": broken && !error ? true : ariaInvalid,
|
|
260
|
+
"aria-errormessage": broken && showHealth ? messageId : ariaErrorMessage,
|
|
261
|
+
error: error,
|
|
262
|
+
errorId: errorId,
|
|
263
|
+
warning: 'warning' === selectedStatus,
|
|
264
|
+
groups: groups,
|
|
265
|
+
value: value,
|
|
266
|
+
onSelect: (item)=>{
|
|
267
|
+
const connection = byId.get(item.id);
|
|
268
|
+
if (connection) onSelect(connection);
|
|
269
|
+
},
|
|
270
|
+
onClear: onClear,
|
|
271
|
+
placeholder: value && !selected ? value : placeholder,
|
|
272
|
+
searchPlaceholder: searchPlaceholder,
|
|
273
|
+
emptyText: emptyText,
|
|
274
|
+
listLabel: text.listLabel,
|
|
275
|
+
noMatchText: text.noMatchText,
|
|
276
|
+
collapsedGroupLabel: text.collapsedGroupLabel,
|
|
277
|
+
expandedGroupLabel: text.expandedGroupLabel,
|
|
278
|
+
actionsMenuLabel: text.actionsMenuLabel,
|
|
279
|
+
disabled: disabled,
|
|
280
|
+
open: open,
|
|
281
|
+
onOpenChange: setOpen,
|
|
282
|
+
icon: selectedStatus ? /*#__PURE__*/ jsx(ConnectionStatusDot, {
|
|
283
|
+
status: selectedStatus,
|
|
284
|
+
label: text.statusLabels[selectedStatus]
|
|
285
|
+
}) : void 0,
|
|
286
|
+
itemActions: itemActions,
|
|
287
|
+
trailingAdornment: selected && (onRefreshSchema || onEdit) && !disabled ? /*#__PURE__*/ jsx(ConnectionActionsMenu, {
|
|
288
|
+
onRefreshSchema: onRefreshSchema ? ()=>onRefreshSchema(selected) : void 0,
|
|
289
|
+
onEdit: onEdit ? ()=>onEdit(selected) : void 0,
|
|
290
|
+
strings: text
|
|
291
|
+
}, selected.id) : void 0,
|
|
292
|
+
footerLeading: onAddConnection ? /*#__PURE__*/ jsxs(Button, {
|
|
293
|
+
variant: "ghost",
|
|
294
|
+
size: "2xs",
|
|
295
|
+
className: "-ml-2 gap-1 font-semibold text-brand hover:text-brand future:text-brand future:hover:text-brand",
|
|
296
|
+
onClick: ()=>{
|
|
297
|
+
if (disabled || !open) return;
|
|
298
|
+
setOpen(false);
|
|
299
|
+
onAddConnection();
|
|
300
|
+
},
|
|
301
|
+
children: [
|
|
302
|
+
/*#__PURE__*/ jsx(Plus, {
|
|
303
|
+
className: "size-3.5"
|
|
304
|
+
}),
|
|
305
|
+
text.addNewConnection
|
|
306
|
+
]
|
|
307
|
+
}) : void 0
|
|
308
|
+
}),
|
|
309
|
+
selectedStatus && /*#__PURE__*/ jsx("span", {
|
|
310
|
+
id: healthId,
|
|
311
|
+
hidden: true,
|
|
312
|
+
children: text.statusLabels[selectedStatus]
|
|
313
|
+
}),
|
|
314
|
+
showLoadError && /*#__PURE__*/ jsxs("div", {
|
|
315
|
+
className: "mt-1.5 flex min-w-0 items-baseline gap-1.5",
|
|
316
|
+
children: [
|
|
317
|
+
/*#__PURE__*/ jsx(FormFieldError, {
|
|
318
|
+
id: loadErrorId,
|
|
319
|
+
title: loadError ?? void 0,
|
|
320
|
+
className: "mt-0 min-w-0 truncate",
|
|
321
|
+
children: loadError
|
|
322
|
+
}),
|
|
323
|
+
!disabled && onRetry && /*#__PURE__*/ jsx(Button, {
|
|
324
|
+
variant: "text",
|
|
325
|
+
size: "4xs",
|
|
326
|
+
className: "shrink-0 px-0 text-xs",
|
|
327
|
+
onClick: ()=>{
|
|
328
|
+
fieldControl()?.focus();
|
|
329
|
+
onRetry();
|
|
330
|
+
},
|
|
331
|
+
children: retryLabel
|
|
332
|
+
})
|
|
333
|
+
]
|
|
334
|
+
}),
|
|
335
|
+
showHealth && selectedStatus && /*#__PURE__*/ jsxs("div", {
|
|
336
|
+
className: "mt-1.5 flex min-w-0 items-baseline gap-1.5",
|
|
337
|
+
children: [
|
|
338
|
+
/*#__PURE__*/ jsx(FormFieldError, {
|
|
339
|
+
id: messageId,
|
|
340
|
+
severity: broken ? 'error' : 'warning',
|
|
341
|
+
title: reason,
|
|
342
|
+
className: "mt-0 min-w-0 truncate",
|
|
343
|
+
children: summary === reason ? summary : /*#__PURE__*/ jsxs(Fragment, {
|
|
344
|
+
children: [
|
|
345
|
+
/*#__PURE__*/ jsx("span", {
|
|
346
|
+
"aria-hidden": true,
|
|
347
|
+
children: summary
|
|
348
|
+
}),
|
|
349
|
+
/*#__PURE__*/ jsx("span", {
|
|
350
|
+
className: "sr-only",
|
|
351
|
+
children: reason
|
|
352
|
+
})
|
|
353
|
+
]
|
|
354
|
+
})
|
|
355
|
+
}),
|
|
356
|
+
!disabled && selected && onFix && /*#__PURE__*/ jsx(Button, {
|
|
357
|
+
variant: "text",
|
|
358
|
+
size: "4xs",
|
|
359
|
+
className: "shrink-0 px-0 text-xs",
|
|
360
|
+
onClick: ()=>{
|
|
361
|
+
fieldControl()?.focus();
|
|
362
|
+
onFix(selected);
|
|
363
|
+
},
|
|
364
|
+
children: text.fix
|
|
365
|
+
})
|
|
366
|
+
]
|
|
367
|
+
})
|
|
368
|
+
]
|
|
369
|
+
})
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
const ConnectionPicker = /*#__PURE__*/ forwardRef(ConnectionPickerField);
|
|
373
|
+
ConnectionPicker.displayName = 'ConnectionPicker';
|
|
374
|
+
export { ConnectionPicker, DEFAULT_CONNECTION_PICKER_STRINGS };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
DEFAULT_CONNECTION_PICKER_STRINGS: ()=>external_connection_picker_cjs_namespaceObject.DEFAULT_CONNECTION_PICKER_STRINGS,
|
|
28
|
+
ConnectionPicker: ()=>external_connection_picker_cjs_namespaceObject.ConnectionPicker
|
|
29
|
+
});
|
|
30
|
+
const external_connection_picker_cjs_namespaceObject = require("./connection-picker.cjs");
|
|
31
|
+
exports.ConnectionPicker = __webpack_exports__.ConnectionPicker;
|
|
32
|
+
exports.DEFAULT_CONNECTION_PICKER_STRINGS = __webpack_exports__.DEFAULT_CONNECTION_PICKER_STRINGS;
|
|
33
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
34
|
+
"ConnectionPicker",
|
|
35
|
+
"DEFAULT_CONNECTION_PICKER_STRINGS"
|
|
36
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
37
|
+
Object.defineProperty(exports, '__esModule', {
|
|
38
|
+
value: true
|
|
39
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.r = (exports1)=>{
|
|
5
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
6
|
+
value: 'Module'
|
|
7
|
+
});
|
|
8
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
9
|
+
value: true
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
})();
|
|
13
|
+
var __webpack_exports__ = {};
|
|
14
|
+
__webpack_require__.r(__webpack_exports__);
|
|
15
|
+
for(var __rspack_i in __webpack_exports__)exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
16
|
+
Object.defineProperty(exports, '__esModule', {
|
|
17
|
+
value: true
|
|
18
|
+
});
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { ResourcePickerProps } from '../resource-picker/types';
|
|
3
|
+
/**
|
|
4
|
+
* A connection's health. `warning` is usable but degraded, such as missing
|
|
5
|
+
* scopes or a rate limit, and is named by its `statusReason` headline when it
|
|
6
|
+
* has one; `broken` needs repair before it will work.
|
|
7
|
+
*/
|
|
8
|
+
export type ConnectionStatus = 'connected' | 'warning' | 'broken';
|
|
9
|
+
export interface Connection {
|
|
10
|
+
id: string;
|
|
11
|
+
/** The connection's own name, such as "Outlook Work". */
|
|
12
|
+
name: string;
|
|
13
|
+
/**
|
|
14
|
+
* The account behind it. When present it is what the row and field show:
|
|
15
|
+
* a node bound to the wrong account is the mistake worth catching, and the
|
|
16
|
+
* connection name says which connector, not which account.
|
|
17
|
+
*/
|
|
18
|
+
account?: string;
|
|
19
|
+
/** Defaults to `connected`. */
|
|
20
|
+
status?: ConnectionStatus;
|
|
21
|
+
/**
|
|
22
|
+
* Why the connection is not healthy, authored as "Headline. Detail.". The
|
|
23
|
+
* headline is shown under the field and the whole reason on hover. For a
|
|
24
|
+
* `warning` the headline also names the state on its row.
|
|
25
|
+
*/
|
|
26
|
+
statusReason?: string;
|
|
27
|
+
/** The folder the connection lives in. Connections without one share `defaultFolder`. */
|
|
28
|
+
folder?: string;
|
|
29
|
+
/** The connector's logo, as an image URL. Takes precedence over `icon`. */
|
|
30
|
+
logo?: string;
|
|
31
|
+
/** Leading glyph for the row, for a connector without a logo image. */
|
|
32
|
+
icon?: ReactNode;
|
|
33
|
+
/** Extra terms the search matches, such as the connector name or a resource id. */
|
|
34
|
+
keywords?: string[];
|
|
35
|
+
disabled?: boolean;
|
|
36
|
+
metadata?: unknown;
|
|
37
|
+
}
|
|
38
|
+
export interface ConnectionPickerProps extends Pick<ResourcePickerProps, 'placeholder' | 'disabled' | 'clearable' | 'clearAriaLabel' | 'align' | 'open' | 'onOpenChange' | 'searchPlaceholder' | 'emptyText' | 'loading' | 'loadingText' | 'loadError' | 'onRetry' | 'retryLabel' | 'error' | 'errorId' | 'footerTrailing' | 'showCounts' | 'locale' | 'formatCount' | 'contentClassName' | 'className' | 'id' | 'aria-labelledby' | 'aria-describedby' | 'aria-invalid' | 'aria-errormessage'> {
|
|
39
|
+
connections: Connection[];
|
|
40
|
+
/** Id of the chosen connection. */
|
|
41
|
+
value?: string;
|
|
42
|
+
onSelect: (connection: Connection) => void;
|
|
43
|
+
/** Clears the field. Without it the clear control is not offered. */
|
|
44
|
+
onClear?: () => void;
|
|
45
|
+
/**
|
|
46
|
+
* Repairs an unhealthy connection. Under the field it is offered for a
|
|
47
|
+
* chosen connection that is `broken` or `warning`, such as one missing
|
|
48
|
+
* scopes, so it must handle both; the row shortcut is offered on `broken`
|
|
49
|
+
* rows only.
|
|
50
|
+
*/
|
|
51
|
+
onFix?: (connection: Connection) => void;
|
|
52
|
+
/**
|
|
53
|
+
* Offered on every row, revealed under the cursor, and in the field's menu
|
|
54
|
+
* for the chosen connection, which is the route that reaches it from the
|
|
55
|
+
* keyboard.
|
|
56
|
+
*/
|
|
57
|
+
onEdit?: (connection: Connection) => void;
|
|
58
|
+
/**
|
|
59
|
+
* Starts a new connection. Adds a footer link, and with no connections at
|
|
60
|
+
* all the field itself becomes the way in, since a list with nothing to
|
|
61
|
+
* pick has nothing to open.
|
|
62
|
+
*/
|
|
63
|
+
onAddConnection?: () => void;
|
|
64
|
+
/**
|
|
65
|
+
* Re-reads the chosen connection's schema. Adds a field menu while a
|
|
66
|
+
* connection is chosen. Return a promise to show progress until it settles.
|
|
67
|
+
*/
|
|
68
|
+
onRefreshSchema?: (connection: Connection) => void | Promise<void>;
|
|
69
|
+
/** Folder for connections that do not name one. */
|
|
70
|
+
defaultFolder?: string;
|
|
71
|
+
addConnectionLabel?: string;
|
|
72
|
+
/**
|
|
73
|
+
* Overrides for the text the picker renders that has no prop of its own,
|
|
74
|
+
* for localisation. Anything omitted falls back to
|
|
75
|
+
* `DEFAULT_CONNECTION_PICKER_STRINGS`.
|
|
76
|
+
*/
|
|
77
|
+
strings?: Partial<ConnectionPickerStrings>;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Every user-facing string ConnectionPicker renders beyond its own props
|
|
81
|
+
* (`placeholder`, `searchPlaceholder`, `emptyText`, `addConnectionLabel`,
|
|
82
|
+
* `defaultFolder`, `clearAriaLabel`), including those of the ResourcePicker it
|
|
83
|
+
* is built on.
|
|
84
|
+
*/
|
|
85
|
+
export interface ConnectionPickerStrings {
|
|
86
|
+
/** Health names, on the rows, the field's description and its dot. */
|
|
87
|
+
statusLabels: Record<ConnectionStatus, string>;
|
|
88
|
+
/**
|
|
89
|
+
* Reasons shown under the field for an unhealthy choice without a
|
|
90
|
+
* `statusReason`, as "Headline. Detail.".
|
|
91
|
+
*/
|
|
92
|
+
defaultReasons: Record<Exclude<ConnectionStatus, 'connected'>, string>;
|
|
93
|
+
/** Visible text of the Fix action, on the rows and under the field. */
|
|
94
|
+
fix: string;
|
|
95
|
+
/** Accessible name of a row's Fix action, given the connection's name. */
|
|
96
|
+
fixLabel: (name: string) => string;
|
|
97
|
+
/** Visible text of the Edit action in a row's actions menu. */
|
|
98
|
+
edit: string;
|
|
99
|
+
/** Accessible name of a row's Edit action, given the connection's name. */
|
|
100
|
+
editLabel: (name: string) => string;
|
|
101
|
+
/** The footer link that starts a new connection. */
|
|
102
|
+
addNewConnection: string;
|
|
103
|
+
/** Accessible name of the list of connections. */
|
|
104
|
+
listLabel: string;
|
|
105
|
+
/** Accessible name of the field's menu button. */
|
|
106
|
+
optionsLabel: string;
|
|
107
|
+
/** The field menu's Edit item. */
|
|
108
|
+
editConnection: string;
|
|
109
|
+
/** The field menu's refresh item, at rest, while it runs, and once done. */
|
|
110
|
+
refreshSchema: string;
|
|
111
|
+
refreshingSchema: string;
|
|
112
|
+
schemaRefreshed: string;
|
|
113
|
+
/** ResourcePicker's `noMatchText`: shown when the search matches nothing. */
|
|
114
|
+
noMatchText: (query: string) => string;
|
|
115
|
+
/** ResourcePicker's `collapsedGroupLabel`: a collapsed folder's spoken name. */
|
|
116
|
+
collapsedGroupLabel: (label: string) => string;
|
|
117
|
+
/**
|
|
118
|
+
* ResourcePicker's `expandedGroupLabel`: an open folder's spoken name when
|
|
119
|
+
* every connection in it is disabled.
|
|
120
|
+
*/
|
|
121
|
+
expandedGroupLabel: (label: string) => string;
|
|
122
|
+
/** ResourcePicker's `actionsMenuLabel`: a row's actions menu name. */
|
|
123
|
+
actionsMenuLabel: (label: string) => string;
|
|
124
|
+
}
|
|
File without changes
|
|
@@ -39,24 +39,16 @@ const DEFAULT_MODES = [
|
|
|
39
39
|
'literal',
|
|
40
40
|
'expression'
|
|
41
41
|
];
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
"aria-checked": active,
|
|
46
|
-
className: "flex-col items-start gap-0.5 py-2",
|
|
47
|
-
"data-active": active || void 0,
|
|
48
|
-
disabled: disabled,
|
|
49
|
-
onClick: onClick,
|
|
42
|
+
const DESCRIBED_ITEM_CLASS = 'flex-col items-start gap-0.5 py-2';
|
|
43
|
+
function DescribedItemContent({ icon, label, labelClassName, description }) {
|
|
44
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
|
|
50
45
|
children: [
|
|
51
46
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
52
47
|
className: "flex items-center gap-2",
|
|
53
48
|
children: [
|
|
54
|
-
|
|
55
|
-
size: 13,
|
|
56
|
-
className: active ? 'text-brand' : 'text-foreground-muted'
|
|
57
|
-
}),
|
|
49
|
+
icon,
|
|
58
50
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
|
|
59
|
-
className: (0, index_cjs_namespaceObject.cn)('text-xs font-medium',
|
|
51
|
+
className: (0, index_cjs_namespaceObject.cn)('text-xs font-medium', labelClassName),
|
|
60
52
|
children: label
|
|
61
53
|
})
|
|
62
54
|
]
|
|
@@ -68,6 +60,25 @@ function ValueModeMenuItem({ icon: Icon, label, description, active, disabled, o
|
|
|
68
60
|
]
|
|
69
61
|
});
|
|
70
62
|
}
|
|
63
|
+
function ValueModeMenuItem({ icon: Icon, label, description, active, disabled, onClick }) {
|
|
64
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_dropdown_menu_cjs_namespaceObject.DropdownMenuItem, {
|
|
65
|
+
role: "menuitemradio",
|
|
66
|
+
"aria-checked": active,
|
|
67
|
+
className: DESCRIBED_ITEM_CLASS,
|
|
68
|
+
"data-active": active || void 0,
|
|
69
|
+
disabled: disabled,
|
|
70
|
+
onClick: onClick,
|
|
71
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(DescribedItemContent, {
|
|
72
|
+
icon: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(Icon, {
|
|
73
|
+
size: 13,
|
|
74
|
+
className: active ? 'text-brand' : 'text-foreground-muted'
|
|
75
|
+
}),
|
|
76
|
+
label: label,
|
|
77
|
+
labelClassName: active ? 'text-brand' : 'text-foreground',
|
|
78
|
+
description: description
|
|
79
|
+
})
|
|
80
|
+
});
|
|
81
|
+
}
|
|
71
82
|
function FieldMenu({ mode, onSelect, modes, extraModes, actions, checked, modesDisabled, disabled, expectedType, literalDescription, triggerLabel: triggerLabelOverride, strings, onCloseAutoFocus }) {
|
|
72
83
|
const text = {
|
|
73
84
|
...external_value_mode_strings_cjs_namespaceObject.DEFAULT_VALUE_MODE_STRINGS,
|
|
@@ -115,18 +126,25 @@ function FieldMenu({ mode, onSelect, modes, extraModes, actions, checked, modesD
|
|
|
115
126
|
!modesDisabled && !!actions?.length && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_dropdown_menu_cjs_namespaceObject.DropdownMenuSeparator, {}),
|
|
116
127
|
actions?.map((action)=>{
|
|
117
128
|
const ActionIcon = action.icon;
|
|
118
|
-
|
|
129
|
+
const icon = ActionIcon ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(ActionIcon, {}) : action.iconDataUri && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("img", {
|
|
130
|
+
src: action.iconDataUri,
|
|
131
|
+
alt: "",
|
|
132
|
+
className: "size-4 shrink-0"
|
|
133
|
+
});
|
|
134
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_dropdown_menu_cjs_namespaceObject.DropdownMenuItem, {
|
|
119
135
|
disabled: action.disabled,
|
|
120
136
|
onClick: action.onSelect,
|
|
121
|
-
className: (0, index_cjs_namespaceObject.cn)(action.destructive && 'text-error focus:text-error'),
|
|
122
|
-
children:
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
137
|
+
className: (0, index_cjs_namespaceObject.cn)(action.description && DESCRIBED_ITEM_CLASS, action.destructive && 'text-error focus:text-error'),
|
|
138
|
+
children: action.description ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(DescribedItemContent, {
|
|
139
|
+
icon: icon,
|
|
140
|
+
label: action.label,
|
|
141
|
+
description: action.description
|
|
142
|
+
}) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
|
|
143
|
+
children: [
|
|
144
|
+
icon,
|
|
145
|
+
action.label
|
|
146
|
+
]
|
|
147
|
+
})
|
|
130
148
|
}, action.id);
|
|
131
149
|
})
|
|
132
150
|
]
|
|
@@ -8,6 +8,8 @@ export interface FieldMenuItem {
|
|
|
8
8
|
icon?: LucideIcon;
|
|
9
9
|
/** Icon as a data URI, used when `icon` is absent. */
|
|
10
10
|
iconDataUri?: string;
|
|
11
|
+
/** A line under the label. With it the row takes a mode row's two-line layout. */
|
|
12
|
+
description?: string;
|
|
11
13
|
disabled?: boolean;
|
|
12
14
|
/** Styles the row as one that removes or discards something. */
|
|
13
15
|
destructive?: boolean;
|