@graphiql/plugin-collections 1.0.0-beta.1 → 1.0.0-beta.3
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/LICENSE +21 -0
- package/README.md +5 -6
- package/dist/components/collection-item-row.js +212 -282
- package/dist/components/collection-item-row.js.map +1 -1
- package/dist/components/collection-row.js +139 -159
- package/dist/components/collection-row.js.map +1 -1
- package/dist/components/collections-panel.js +408 -496
- package/dist/components/collections-panel.js.map +1 -1
- package/dist/components/conflict-dialog.js +148 -164
- package/dist/components/conflict-dialog.js.map +1 -1
- package/dist/components/export-dialog.js +52 -52
- package/dist/components/export-dialog.js.map +1 -1
- package/dist/components/import-dialog.js +100 -112
- package/dist/components/import-dialog.js.map +1 -1
- package/dist/components/save-dialog.js +116 -124
- package/dist/components/save-dialog.js.map +1 -1
- package/dist/components/session-actions.js +23 -31
- package/dist/components/session-actions.js.map +1 -1
- package/dist/icons/check.js +18 -9
- package/dist/icons/check.js.map +1 -1
- package/dist/icons/collections.js +16 -9
- package/dist/icons/collections.js.map +1 -1
- package/dist/icons/download.js +16 -9
- package/dist/icons/download.js.map +1 -1
- package/dist/icons/upload.js +16 -9
- package/dist/icons/upload.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +32 -41
- package/dist/index.js.map +1 -1
- package/dist/operation-method.js +24 -24
- package/dist/operation-method.js.map +1 -1
- package/dist/storage/local-storage.js +32 -37
- package/dist/storage/local-storage.js.map +1 -1
- package/dist/storage/tab-links.js +27 -30
- package/dist/storage/tab-links.js.map +1 -1
- package/dist/store.js +365 -402
- package/dist/store.js.map +1 -1
- package/dist/style.css +6 -27
- package/dist/types.js +9 -8
- package/dist/types.js.map +1 -1
- package/dist/utility/uuid.js +11 -9
- package/dist/utility/uuid.js.map +1 -1
- package/package.json +19 -15
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) GraphQL Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -16,14 +16,14 @@ npm install react react-dom graphql @graphiql/react
|
|
|
16
16
|
|
|
17
17
|
## Usage
|
|
18
18
|
|
|
19
|
-
The collections plugin is installed by default in GraphiQL, so an unmodified `<GraphiQL>` already shows a Collections rail icon.
|
|
19
|
+
The collections plugin is installed by default in GraphiQL, so an unmodified `<GraphiQL>` already shows a Collections rail icon. Use `COLLECTIONS_PLUGIN` when you pass a custom `plugins` array and want to keep the default collections configuration. Use `collectionsPlugin(options)` to supply a custom storage backend or restrict what users can do.
|
|
20
20
|
|
|
21
21
|
> **Note:** passing the `plugins` prop replaces the default plugin set, so include the others you want alongside it.
|
|
22
22
|
|
|
23
23
|
```jsx
|
|
24
24
|
import { GraphiQL } from 'graphiql';
|
|
25
25
|
import { createTransport } from '@graphiql/toolkit';
|
|
26
|
-
import {
|
|
26
|
+
import { COLLECTIONS_PLUGIN } from '@graphiql/plugin-collections';
|
|
27
27
|
import 'graphiql/style.css';
|
|
28
28
|
import '@graphiql/plugin-collections/style.css';
|
|
29
29
|
|
|
@@ -31,10 +31,8 @@ const transport = createTransport({
|
|
|
31
31
|
url: 'https://swapi-graphql.netlify.app/.netlify/functions/index',
|
|
32
32
|
});
|
|
33
33
|
|
|
34
|
-
const collections = collectionsPlugin();
|
|
35
|
-
|
|
36
34
|
function GraphiQLWithCollections() {
|
|
37
|
-
return <GraphiQL transport={transport} plugins={[
|
|
35
|
+
return <GraphiQL transport={transport} plugins={[COLLECTIONS_PLUGIN]} />;
|
|
38
36
|
}
|
|
39
37
|
```
|
|
40
38
|
|
|
@@ -155,7 +153,8 @@ await actions.reload();
|
|
|
155
153
|
|
|
156
154
|
## Exports
|
|
157
155
|
|
|
158
|
-
- `
|
|
156
|
+
- `COLLECTIONS_PLUGIN` — the default plugin configuration
|
|
157
|
+
- `collectionsPlugin(options?)` — the plugin factory for custom configuration
|
|
159
158
|
- `collectionsStore`, `useCollectionsStore` — the store and its React hook
|
|
160
159
|
- `createLocalStorageAdapter(key)`, `localStorageAdapter` — built-in storage
|
|
161
160
|
- `CollectionsSaveDialog` — the save dialog component
|
|
@@ -1,286 +1,216 @@
|
|
|
1
|
-
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useState, useRef, useEffect } from "react";
|
|
3
|
-
import { MethodPill, PenIcon, CopyIcon, TrashIcon } from "@graphiql/react";
|
|
4
1
|
import { getDocumentMethod } from "../operation-method.js";
|
|
5
2
|
import SvgUpload from "../icons/upload.js";
|
|
6
3
|
import SvgCheck from "../icons/check.js";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
!isEditing && /* @__PURE__ */ jsxs("div", { className: "graphiql-collection-item-actions", children: [
|
|
216
|
-
!readOnly && /* @__PURE__ */ jsx(
|
|
217
|
-
"button",
|
|
218
|
-
{
|
|
219
|
-
type: "button",
|
|
220
|
-
className: "graphiql-collection-item-action",
|
|
221
|
-
"aria-label": `Rename ${item.name}`,
|
|
222
|
-
title: "Rename",
|
|
223
|
-
onClick: startEdit,
|
|
224
|
-
children: /* @__PURE__ */ jsx(PenIcon, { "aria-hidden": "true" })
|
|
225
|
-
}
|
|
226
|
-
),
|
|
227
|
-
/* @__PURE__ */ jsx(
|
|
228
|
-
"button",
|
|
229
|
-
{
|
|
230
|
-
type: "button",
|
|
231
|
-
className: "graphiql-collection-item-action",
|
|
232
|
-
"aria-label": `Copy operation ${item.name}`,
|
|
233
|
-
title: "Copy operation",
|
|
234
|
-
"data-confirmed": confirmed === "copy" || void 0,
|
|
235
|
-
onClick: (e) => {
|
|
236
|
-
e.stopPropagation();
|
|
237
|
-
void runAction(
|
|
238
|
-
"copy",
|
|
239
|
-
() => navigator.clipboard.writeText(item.query),
|
|
240
|
-
"Copied query to clipboard.",
|
|
241
|
-
"Could not copy to clipboard."
|
|
242
|
-
);
|
|
243
|
-
},
|
|
244
|
-
children: confirmed === "copy" ? /* @__PURE__ */ jsx(SvgCheck, { "aria-hidden": "true" }) : /* @__PURE__ */ jsx(CopyIcon, { "aria-hidden": "true" })
|
|
245
|
-
}
|
|
246
|
-
),
|
|
247
|
-
/* @__PURE__ */ jsx(
|
|
248
|
-
"button",
|
|
249
|
-
{
|
|
250
|
-
type: "button",
|
|
251
|
-
className: "graphiql-collection-item-action",
|
|
252
|
-
"aria-label": `Share ${item.name} as collection`,
|
|
253
|
-
title: "Share as collection",
|
|
254
|
-
"data-confirmed": confirmed === "share" || void 0,
|
|
255
|
-
onClick: (e) => {
|
|
256
|
-
e.stopPropagation();
|
|
257
|
-
void runAction(
|
|
258
|
-
"share",
|
|
259
|
-
() => onShare(item.id),
|
|
260
|
-
"Shared operation to clipboard.",
|
|
261
|
-
"Could not share to clipboard."
|
|
262
|
-
);
|
|
263
|
-
},
|
|
264
|
-
children: confirmed === "share" ? /* @__PURE__ */ jsx(SvgCheck, { "aria-hidden": "true" }) : /* @__PURE__ */ jsx(SvgUpload, { "aria-hidden": "true" })
|
|
265
|
-
}
|
|
266
|
-
),
|
|
267
|
-
!readOnly && /* @__PURE__ */ jsx(
|
|
268
|
-
"button",
|
|
269
|
-
{
|
|
270
|
-
type: "button",
|
|
271
|
-
className: "graphiql-collection-item-action",
|
|
272
|
-
"aria-label": `Delete ${item.name}`,
|
|
273
|
-
title: "Delete",
|
|
274
|
-
onClick: handleDelete,
|
|
275
|
-
children: /* @__PURE__ */ jsx(TrashIcon, { "aria-hidden": "true" })
|
|
276
|
-
}
|
|
277
|
-
)
|
|
278
|
-
] })
|
|
279
|
-
]
|
|
280
|
-
}
|
|
281
|
-
);
|
|
4
|
+
import { useEffect, useRef, useState } from "react";
|
|
5
|
+
import { CopyIcon, MethodPill, PenIcon, TrashIcon } from "@graphiql/react";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
//#region src/components/collection-item-row.tsx
|
|
8
|
+
var CollectionItemRow = ({ item, collectionId, index, readOnly = false, isGrabbed, onGrabToggle, onGrabMove, onGrabCancel, onOpen, onShare, onAnnounce, onDelete, onMove, onRenameItem }) => {
|
|
9
|
+
const [isDragOver, setIsDragOver] = useState(false);
|
|
10
|
+
const [isEditing, setIsEditing] = useState(false);
|
|
11
|
+
const [confirmed, setConfirmed] = useState(null);
|
|
12
|
+
const [confirmToken, setConfirmToken] = useState(0);
|
|
13
|
+
const editFormRef = useRef(null);
|
|
14
|
+
const [editName, setEditName] = useState(item.name);
|
|
15
|
+
const [editDescription, setEditDescription] = useState(item.description ?? "");
|
|
16
|
+
const method = getDocumentMethod(item.query);
|
|
17
|
+
const startEdit = (e) => {
|
|
18
|
+
e.stopPropagation();
|
|
19
|
+
setEditName(item.name);
|
|
20
|
+
setEditDescription(item.description ?? "");
|
|
21
|
+
setIsEditing(true);
|
|
22
|
+
};
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
if (!confirmed) return;
|
|
25
|
+
const timer = setTimeout(() => setConfirmed(null), 1500);
|
|
26
|
+
return () => clearTimeout(timer);
|
|
27
|
+
}, [confirmed, confirmToken]);
|
|
28
|
+
const runAction = async (kind, write, message, failureMessage) => {
|
|
29
|
+
try {
|
|
30
|
+
await write();
|
|
31
|
+
onAnnounce(message);
|
|
32
|
+
setConfirmed(kind);
|
|
33
|
+
setConfirmToken((t) => t + 1);
|
|
34
|
+
} catch {
|
|
35
|
+
onAnnounce(failureMessage);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
const handleDelete = (e) => {
|
|
39
|
+
e.stopPropagation();
|
|
40
|
+
onDelete(collectionId, item.id);
|
|
41
|
+
};
|
|
42
|
+
const commitEdit = () => {
|
|
43
|
+
const name = editName.trim() || item.name;
|
|
44
|
+
onRenameItem(collectionId, item.id, {
|
|
45
|
+
name,
|
|
46
|
+
description: editDescription
|
|
47
|
+
});
|
|
48
|
+
setIsEditing(false);
|
|
49
|
+
};
|
|
50
|
+
const handleBlur = (e) => {
|
|
51
|
+
if (editFormRef.current?.contains(e.relatedTarget)) return;
|
|
52
|
+
commitEdit();
|
|
53
|
+
};
|
|
54
|
+
const cancelEdit = () => {
|
|
55
|
+
setEditName(item.name);
|
|
56
|
+
setEditDescription(item.description ?? "");
|
|
57
|
+
setIsEditing(false);
|
|
58
|
+
};
|
|
59
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
60
|
+
className: `graphiql-collection-item-row${isDragOver ? " graphiql-collection-drop-target" : ""}`,
|
|
61
|
+
"data-grabbed": isGrabbed || void 0,
|
|
62
|
+
draggable: !readOnly && !isEditing,
|
|
63
|
+
onDragStart: readOnly || isEditing ? void 0 : (e) => {
|
|
64
|
+
e.dataTransfer.setData("application/x-graphiql-item", JSON.stringify({
|
|
65
|
+
collectionId,
|
|
66
|
+
index
|
|
67
|
+
}));
|
|
68
|
+
e.dataTransfer.effectAllowed = "move";
|
|
69
|
+
},
|
|
70
|
+
onDragOver: readOnly ? void 0 : (e) => {
|
|
71
|
+
e.preventDefault();
|
|
72
|
+
e.dataTransfer.dropEffect = "move";
|
|
73
|
+
setIsDragOver(true);
|
|
74
|
+
},
|
|
75
|
+
onDragLeave: readOnly ? void 0 : () => setIsDragOver(false),
|
|
76
|
+
onDrop: readOnly ? void 0 : (e) => {
|
|
77
|
+
e.preventDefault();
|
|
78
|
+
setIsDragOver(false);
|
|
79
|
+
try {
|
|
80
|
+
const data = JSON.parse(e.dataTransfer.getData("application/x-graphiql-item"));
|
|
81
|
+
onMove(data.collectionId, data.index, collectionId, index);
|
|
82
|
+
} catch {}
|
|
83
|
+
},
|
|
84
|
+
onClick: () => {
|
|
85
|
+
if (!isEditing) onOpen(item);
|
|
86
|
+
},
|
|
87
|
+
children: [
|
|
88
|
+
/* @__PURE__ */ jsx("button", {
|
|
89
|
+
type: "button",
|
|
90
|
+
className: "graphiql-collection-drag-handle",
|
|
91
|
+
"data-collection-drag-handle": item.id,
|
|
92
|
+
"aria-label": `Reorder ${item.name}. Press space to grab, arrow keys to move, escape to cancel.`,
|
|
93
|
+
"aria-pressed": isGrabbed,
|
|
94
|
+
disabled: readOnly,
|
|
95
|
+
onClick: (e) => e.stopPropagation(),
|
|
96
|
+
onKeyDown: (e) => {
|
|
97
|
+
if (e.key === " " || e.key === "Enter") {
|
|
98
|
+
e.preventDefault();
|
|
99
|
+
e.stopPropagation();
|
|
100
|
+
onGrabToggle();
|
|
101
|
+
} else if (isGrabbed && e.key === "ArrowDown") {
|
|
102
|
+
e.preventDefault();
|
|
103
|
+
e.stopPropagation();
|
|
104
|
+
onGrabMove("down");
|
|
105
|
+
} else if (isGrabbed && e.key === "ArrowUp") {
|
|
106
|
+
e.preventDefault();
|
|
107
|
+
e.stopPropagation();
|
|
108
|
+
onGrabMove("up");
|
|
109
|
+
} else if (isGrabbed && e.key === "Escape") {
|
|
110
|
+
e.preventDefault();
|
|
111
|
+
e.stopPropagation();
|
|
112
|
+
onGrabCancel();
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
children: "⠿"
|
|
116
|
+
}),
|
|
117
|
+
method === "mix" ? /* @__PURE__ */ jsx("span", {
|
|
118
|
+
className: "graphiql-method-pill graphiql-collection-method-pill-mix",
|
|
119
|
+
"aria-hidden": true,
|
|
120
|
+
children: "MIX"
|
|
121
|
+
}) : /* @__PURE__ */ jsx(MethodPill, {
|
|
122
|
+
operation: method,
|
|
123
|
+
"aria-hidden": true
|
|
124
|
+
}),
|
|
125
|
+
isEditing ? /* @__PURE__ */ jsxs("div", {
|
|
126
|
+
ref: editFormRef,
|
|
127
|
+
className: "graphiql-collection-item-edit-form",
|
|
128
|
+
onClick: (e) => e.stopPropagation(),
|
|
129
|
+
children: [/* @__PURE__ */ jsx("input", {
|
|
130
|
+
className: "graphiql-collection-item-edit-input",
|
|
131
|
+
value: editName,
|
|
132
|
+
autoFocus: true,
|
|
133
|
+
placeholder: item.name,
|
|
134
|
+
onChange: (e) => setEditName(e.target.value),
|
|
135
|
+
onBlur: handleBlur,
|
|
136
|
+
onKeyDown: (e) => {
|
|
137
|
+
if (e.key === "Enter") commitEdit();
|
|
138
|
+
if (e.key === "Escape") cancelEdit();
|
|
139
|
+
e.stopPropagation();
|
|
140
|
+
}
|
|
141
|
+
}), /* @__PURE__ */ jsx("input", {
|
|
142
|
+
className: "graphiql-collection-item-edit-input",
|
|
143
|
+
value: editDescription,
|
|
144
|
+
placeholder: "Description (optional)",
|
|
145
|
+
onChange: (e) => setEditDescription(e.target.value),
|
|
146
|
+
onBlur: handleBlur,
|
|
147
|
+
onKeyDown: (e) => {
|
|
148
|
+
if (e.key === "Enter") commitEdit();
|
|
149
|
+
if (e.key === "Escape") cancelEdit();
|
|
150
|
+
e.stopPropagation();
|
|
151
|
+
}
|
|
152
|
+
})]
|
|
153
|
+
}) : /* @__PURE__ */ jsxs("div", {
|
|
154
|
+
className: "graphiql-collection-item-main",
|
|
155
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
156
|
+
className: "graphiql-collection-item-name",
|
|
157
|
+
title: item.name,
|
|
158
|
+
children: item.name
|
|
159
|
+
}), item.description && /* @__PURE__ */ jsx("span", {
|
|
160
|
+
className: "graphiql-collection-item-description",
|
|
161
|
+
title: item.description,
|
|
162
|
+
children: item.description
|
|
163
|
+
})]
|
|
164
|
+
}),
|
|
165
|
+
!isEditing && /* @__PURE__ */ jsxs("div", {
|
|
166
|
+
className: "graphiql-collection-item-actions",
|
|
167
|
+
children: [
|
|
168
|
+
!readOnly && /* @__PURE__ */ jsx("button", {
|
|
169
|
+
type: "button",
|
|
170
|
+
className: "graphiql-collection-item-action",
|
|
171
|
+
"aria-label": `Rename ${item.name}`,
|
|
172
|
+
title: "Rename",
|
|
173
|
+
onClick: startEdit,
|
|
174
|
+
children: /* @__PURE__ */ jsx(PenIcon, { "aria-hidden": "true" })
|
|
175
|
+
}),
|
|
176
|
+
/* @__PURE__ */ jsx("button", {
|
|
177
|
+
type: "button",
|
|
178
|
+
className: "graphiql-collection-item-action",
|
|
179
|
+
"aria-label": `Copy operation ${item.name}`,
|
|
180
|
+
title: "Copy operation",
|
|
181
|
+
"data-confirmed": confirmed === "copy" || void 0,
|
|
182
|
+
onClick: (e) => {
|
|
183
|
+
e.stopPropagation();
|
|
184
|
+
runAction("copy", () => navigator.clipboard.writeText(item.query), "Copied query to clipboard.", "Could not copy to clipboard.");
|
|
185
|
+
},
|
|
186
|
+
children: confirmed === "copy" ? /* @__PURE__ */ jsx(SvgCheck, { "aria-hidden": "true" }) : /* @__PURE__ */ jsx(CopyIcon, { "aria-hidden": "true" })
|
|
187
|
+
}),
|
|
188
|
+
/* @__PURE__ */ jsx("button", {
|
|
189
|
+
type: "button",
|
|
190
|
+
className: "graphiql-collection-item-action",
|
|
191
|
+
"aria-label": `Share ${item.name} as collection`,
|
|
192
|
+
title: "Share as collection",
|
|
193
|
+
"data-confirmed": confirmed === "share" || void 0,
|
|
194
|
+
onClick: (e) => {
|
|
195
|
+
e.stopPropagation();
|
|
196
|
+
runAction("share", () => onShare(item.id), "Shared operation to clipboard.", "Could not share to clipboard.");
|
|
197
|
+
},
|
|
198
|
+
children: confirmed === "share" ? /* @__PURE__ */ jsx(SvgCheck, { "aria-hidden": "true" }) : /* @__PURE__ */ jsx(SvgUpload, { "aria-hidden": "true" })
|
|
199
|
+
}),
|
|
200
|
+
!readOnly && /* @__PURE__ */ jsx("button", {
|
|
201
|
+
type: "button",
|
|
202
|
+
className: "graphiql-collection-item-action",
|
|
203
|
+
"aria-label": `Delete ${item.name}`,
|
|
204
|
+
title: "Delete",
|
|
205
|
+
onClick: handleDelete,
|
|
206
|
+
children: /* @__PURE__ */ jsx(TrashIcon, { "aria-hidden": "true" })
|
|
207
|
+
})
|
|
208
|
+
]
|
|
209
|
+
})
|
|
210
|
+
]
|
|
211
|
+
});
|
|
282
212
|
};
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
//# sourceMappingURL=collection-item-row.js.map
|
|
213
|
+
//#endregion
|
|
214
|
+
export { CollectionItemRow };
|
|
215
|
+
|
|
216
|
+
//# sourceMappingURL=collection-item-row.js.map
|