@graphiql/plugin-collections 1.0.0-beta.0 → 1.0.0-beta.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.
Files changed (41) hide show
  1. package/LICENSE +21 -0
  2. package/dist/components/collection-item-row.js +212 -282
  3. package/dist/components/collection-item-row.js.map +1 -1
  4. package/dist/components/collection-row.js +139 -159
  5. package/dist/components/collection-row.js.map +1 -1
  6. package/dist/components/collections-panel.js +408 -496
  7. package/dist/components/collections-panel.js.map +1 -1
  8. package/dist/components/conflict-dialog.js +148 -164
  9. package/dist/components/conflict-dialog.js.map +1 -1
  10. package/dist/components/export-dialog.js +52 -52
  11. package/dist/components/export-dialog.js.map +1 -1
  12. package/dist/components/import-dialog.js +100 -112
  13. package/dist/components/import-dialog.js.map +1 -1
  14. package/dist/components/save-dialog.js +116 -124
  15. package/dist/components/save-dialog.js.map +1 -1
  16. package/dist/components/session-actions.js +23 -31
  17. package/dist/components/session-actions.js.map +1 -1
  18. package/dist/icons/check.js +18 -9
  19. package/dist/icons/check.js.map +1 -1
  20. package/dist/icons/collections.js +16 -9
  21. package/dist/icons/collections.js.map +1 -1
  22. package/dist/icons/download.js +16 -9
  23. package/dist/icons/download.js.map +1 -1
  24. package/dist/icons/upload.js +16 -9
  25. package/dist/icons/upload.js.map +1 -1
  26. package/dist/index.js +31 -41
  27. package/dist/index.js.map +1 -1
  28. package/dist/operation-method.js +24 -24
  29. package/dist/operation-method.js.map +1 -1
  30. package/dist/storage/local-storage.js +32 -37
  31. package/dist/storage/local-storage.js.map +1 -1
  32. package/dist/storage/tab-links.js +27 -30
  33. package/dist/storage/tab-links.js.map +1 -1
  34. package/dist/store.js +365 -402
  35. package/dist/store.js.map +1 -1
  36. package/dist/style.css +6 -27
  37. package/dist/types.js +9 -8
  38. package/dist/types.js.map +1 -1
  39. package/dist/utility/uuid.js +11 -9
  40. package/dist/utility/uuid.js.map +1 -1
  41. 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.
@@ -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
- const CollectionItemRow = ({
8
- item,
9
- collectionId,
10
- index,
11
- readOnly = false,
12
- isGrabbed,
13
- onGrabToggle,
14
- onGrabMove,
15
- onGrabCancel,
16
- onOpen,
17
- onShare,
18
- onAnnounce,
19
- onDelete,
20
- onMove,
21
- onRenameItem
22
- }) => {
23
- const [isDragOver, setIsDragOver] = useState(false);
24
- const [isEditing, setIsEditing] = useState(false);
25
- const [confirmed, setConfirmed] = useState(null);
26
- const [confirmToken, setConfirmToken] = useState(0);
27
- const editFormRef = useRef(null);
28
- const [editName, setEditName] = useState(item.name);
29
- const [editDescription, setEditDescription] = useState(
30
- item.description ?? ""
31
- );
32
- const method = getDocumentMethod(item.query);
33
- const startEdit = (e) => {
34
- e.stopPropagation();
35
- setEditName(item.name);
36
- setEditDescription(item.description ?? "");
37
- setIsEditing(true);
38
- };
39
- useEffect(() => {
40
- if (!confirmed) {
41
- return;
42
- }
43
- const timer = setTimeout(() => setConfirmed(null), 1500);
44
- return () => clearTimeout(timer);
45
- }, [confirmed, confirmToken]);
46
- const runAction = async (kind, write, message, failureMessage) => {
47
- try {
48
- await write();
49
- onAnnounce(message);
50
- setConfirmed(kind);
51
- setConfirmToken((t) => t + 1);
52
- } catch {
53
- onAnnounce(failureMessage);
54
- }
55
- };
56
- const handleDelete = (e) => {
57
- e.stopPropagation();
58
- onDelete(collectionId, item.id);
59
- };
60
- const commitEdit = () => {
61
- const name = editName.trim() || item.name;
62
- onRenameItem(collectionId, item.id, {
63
- name,
64
- description: editDescription
65
- });
66
- setIsEditing(false);
67
- };
68
- const handleBlur = (e) => {
69
- var _a;
70
- if ((_a = editFormRef.current) == null ? void 0 : _a.contains(e.relatedTarget)) {
71
- return;
72
- }
73
- commitEdit();
74
- };
75
- const cancelEdit = () => {
76
- setEditName(item.name);
77
- setEditDescription(item.description ?? "");
78
- setIsEditing(false);
79
- };
80
- return /* @__PURE__ */ jsxs(
81
- "div",
82
- {
83
- className: `graphiql-collection-item-row${isDragOver ? " graphiql-collection-drop-target" : ""}`,
84
- "data-grabbed": isGrabbed || void 0,
85
- draggable: !readOnly && !isEditing,
86
- onDragStart: readOnly || isEditing ? void 0 : (e) => {
87
- e.dataTransfer.setData(
88
- "application/x-graphiql-item",
89
- JSON.stringify({ collectionId, index })
90
- );
91
- e.dataTransfer.effectAllowed = "move";
92
- },
93
- onDragOver: readOnly ? void 0 : (e) => {
94
- e.preventDefault();
95
- e.dataTransfer.dropEffect = "move";
96
- setIsDragOver(true);
97
- },
98
- onDragLeave: readOnly ? void 0 : () => setIsDragOver(false),
99
- onDrop: readOnly ? void 0 : (e) => {
100
- e.preventDefault();
101
- setIsDragOver(false);
102
- try {
103
- const data = JSON.parse(
104
- e.dataTransfer.getData("application/x-graphiql-item")
105
- );
106
- onMove(data.collectionId, data.index, collectionId, index);
107
- } catch {
108
- }
109
- },
110
- onClick: () => {
111
- if (!isEditing) {
112
- onOpen(item);
113
- }
114
- },
115
- children: [
116
- /* @__PURE__ */ jsx(
117
- "button",
118
- {
119
- type: "button",
120
- className: "graphiql-collection-drag-handle",
121
- "data-collection-drag-handle": item.id,
122
- "aria-label": `Reorder ${item.name}. Press space to grab, arrow keys to move, escape to cancel.`,
123
- "aria-pressed": isGrabbed,
124
- disabled: readOnly,
125
- onClick: (e) => e.stopPropagation(),
126
- onKeyDown: (e) => {
127
- if (e.key === " " || e.key === "Enter") {
128
- e.preventDefault();
129
- e.stopPropagation();
130
- onGrabToggle();
131
- } else if (isGrabbed && e.key === "ArrowDown") {
132
- e.preventDefault();
133
- e.stopPropagation();
134
- onGrabMove("down");
135
- } else if (isGrabbed && e.key === "ArrowUp") {
136
- e.preventDefault();
137
- e.stopPropagation();
138
- onGrabMove("up");
139
- } else if (isGrabbed && e.key === "Escape") {
140
- e.preventDefault();
141
- e.stopPropagation();
142
- onGrabCancel();
143
- }
144
- },
145
- children: "⠿"
146
- }
147
- ),
148
- method === "mix" ? /* @__PURE__ */ jsx(
149
- "span",
150
- {
151
- className: "graphiql-method-pill graphiql-collection-method-pill-mix",
152
- "aria-hidden": true,
153
- children: "MIX"
154
- }
155
- ) : /* @__PURE__ */ jsx(MethodPill, { operation: method, "aria-hidden": true }),
156
- isEditing ? /* @__PURE__ */ jsxs(
157
- "div",
158
- {
159
- ref: editFormRef,
160
- className: "graphiql-collection-item-edit-form",
161
- onClick: (e) => e.stopPropagation(),
162
- children: [
163
- /* @__PURE__ */ jsx(
164
- "input",
165
- {
166
- className: "graphiql-collection-item-edit-input",
167
- value: editName,
168
- autoFocus: true,
169
- placeholder: item.name,
170
- onChange: (e) => setEditName(e.target.value),
171
- onBlur: handleBlur,
172
- onKeyDown: (e) => {
173
- if (e.key === "Enter") {
174
- commitEdit();
175
- }
176
- if (e.key === "Escape") {
177
- cancelEdit();
178
- }
179
- e.stopPropagation();
180
- }
181
- }
182
- ),
183
- /* @__PURE__ */ jsx(
184
- "input",
185
- {
186
- className: "graphiql-collection-item-edit-input",
187
- value: editDescription,
188
- placeholder: "Description (optional)",
189
- onChange: (e) => setEditDescription(e.target.value),
190
- onBlur: handleBlur,
191
- onKeyDown: (e) => {
192
- if (e.key === "Enter") {
193
- commitEdit();
194
- }
195
- if (e.key === "Escape") {
196
- cancelEdit();
197
- }
198
- e.stopPropagation();
199
- }
200
- }
201
- )
202
- ]
203
- }
204
- ) : /* @__PURE__ */ jsxs("div", { className: "graphiql-collection-item-main", children: [
205
- /* @__PURE__ */ jsx("span", { className: "graphiql-collection-item-name", title: item.name, children: item.name }),
206
- item.description && /* @__PURE__ */ jsx(
207
- "span",
208
- {
209
- className: "graphiql-collection-item-description",
210
- title: item.description,
211
- children: item.description
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
- export {
284
- CollectionItemRow
285
- };
286
- //# sourceMappingURL=collection-item-row.js.map
213
+ //#endregion
214
+ export { CollectionItemRow };
215
+
216
+ //# sourceMappingURL=collection-item-row.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"collection-item-row.js","sources":["../../src/components/collection-item-row.tsx"],"sourcesContent":["import { FC, useEffect, useRef, useState } from 'react';\nimport { MethodPill, PenIcon, CopyIcon, TrashIcon } from '@graphiql/react';\nimport type { CollectionItem } from '../types';\nimport { getDocumentMethod } from '../operation-method';\nimport UploadIcon from '../icons/upload.svg?react';\nimport CheckIcon from '../icons/check.svg?react';\n\ntype CollectionItemRowProps = {\n item: CollectionItem;\n collectionId: string;\n /** The item's position within its collection, used for drag reorder. */\n index: number;\n /** Hide write affordances (Move, Delete) and disable drag-reorder when true. */\n readOnly?: boolean;\n isGrabbed: boolean;\n onGrabToggle(): void;\n onGrabMove(direction: 'up' | 'down'): void;\n onGrabCancel(): void;\n onOpen(item: CollectionItem): void;\n onShare(itemId: string): Promise<void>;\n onAnnounce(message: string): void;\n onDelete(collectionId: string, itemId: string): void;\n onMove(\n fromCollectionId: string,\n fromIndex: number,\n toCollectionId: string,\n toIndex: number,\n ): void;\n onRenameItem(\n collectionId: string,\n itemId: string,\n updates: { name: string; description: string },\n ): void;\n};\n\nexport const CollectionItemRow: FC<CollectionItemRowProps> = ({\n item,\n collectionId,\n index,\n readOnly = false,\n isGrabbed,\n onGrabToggle,\n onGrabMove,\n onGrabCancel,\n onOpen,\n onShare,\n onAnnounce,\n onDelete,\n onMove,\n onRenameItem,\n}) => {\n const [isDragOver, setIsDragOver] = useState(false);\n const [isEditing, setIsEditing] = useState(false);\n const [confirmed, setConfirmed] = useState<'copy' | 'share' | null>(null);\n const [confirmToken, setConfirmToken] = useState(0);\n const editFormRef = useRef<HTMLDivElement>(null);\n const [editName, setEditName] = useState(item.name);\n const [editDescription, setEditDescription] = useState(\n item.description ?? '',\n );\n const method = getDocumentMethod(item.query);\n\n // Action buttons stop propagation so their clicks don't also trigger the\n // row's open handler.\n const startEdit = (e: React.MouseEvent) => {\n e.stopPropagation();\n setEditName(item.name);\n setEditDescription(item.description ?? '');\n setIsEditing(true);\n };\n\n useEffect(() => {\n if (!confirmed) {\n return;\n }\n const timer = setTimeout(() => setConfirmed(null), 1500);\n return () => clearTimeout(timer);\n }, [confirmed, confirmToken]);\n\n const runAction = async (\n kind: 'copy' | 'share',\n write: () => Promise<void>,\n message: string,\n failureMessage: string,\n ) => {\n try {\n await write();\n onAnnounce(message);\n setConfirmed(kind);\n setConfirmToken(t => t + 1);\n } catch {\n onAnnounce(failureMessage);\n }\n };\n\n const handleDelete = (e: React.MouseEvent) => {\n e.stopPropagation();\n onDelete(collectionId, item.id);\n };\n\n const commitEdit = () => {\n const name = editName.trim() || item.name;\n onRenameItem(collectionId, item.id, {\n name,\n description: editDescription,\n });\n setIsEditing(false);\n };\n\n // Commit only when focus leaves the whole form; moving between the name and\n // description inputs must not tear down the edit UI mid-edit.\n const handleBlur = (e: React.FocusEvent) => {\n if (editFormRef.current?.contains(e.relatedTarget as Node | null)) {\n return;\n }\n commitEdit();\n };\n\n const cancelEdit = () => {\n setEditName(item.name);\n setEditDescription(item.description ?? '');\n setIsEditing(false);\n };\n\n return (\n <div\n className={`graphiql-collection-item-row${isDragOver ? ' graphiql-collection-drop-target' : ''}`}\n data-grabbed={isGrabbed || undefined}\n draggable={!readOnly && !isEditing}\n onDragStart={\n readOnly || isEditing\n ? undefined\n : e => {\n e.dataTransfer.setData(\n 'application/x-graphiql-item',\n JSON.stringify({ collectionId, index }),\n );\n e.dataTransfer.effectAllowed = 'move';\n }\n }\n onDragOver={\n readOnly\n ? undefined\n : e => {\n e.preventDefault();\n e.dataTransfer.dropEffect = 'move';\n setIsDragOver(true);\n }\n }\n onDragLeave={readOnly ? undefined : () => setIsDragOver(false)}\n onDrop={\n readOnly\n ? undefined\n : e => {\n e.preventDefault();\n setIsDragOver(false);\n try {\n const data = JSON.parse(\n e.dataTransfer.getData('application/x-graphiql-item'),\n );\n onMove(data.collectionId, data.index, collectionId, index);\n } catch {\n // malformed drag data\n }\n }\n }\n onClick={() => {\n if (!isEditing) {\n onOpen(item);\n }\n }}\n >\n <button\n type=\"button\"\n className=\"graphiql-collection-drag-handle\"\n data-collection-drag-handle={item.id}\n aria-label={`Reorder ${item.name}. Press space to grab, arrow keys to move, escape to cancel.`}\n aria-pressed={isGrabbed}\n disabled={readOnly}\n onClick={e => e.stopPropagation()}\n onKeyDown={e => {\n if (e.key === ' ' || e.key === 'Enter') {\n e.preventDefault();\n e.stopPropagation();\n onGrabToggle();\n } else if (isGrabbed && e.key === 'ArrowDown') {\n e.preventDefault();\n e.stopPropagation();\n onGrabMove('down');\n } else if (isGrabbed && e.key === 'ArrowUp') {\n e.preventDefault();\n e.stopPropagation();\n onGrabMove('up');\n } else if (isGrabbed && e.key === 'Escape') {\n e.preventDefault();\n e.stopPropagation();\n onGrabCancel();\n }\n }}\n >\n ⠿\n </button>\n {method === 'mix' ? (\n <span\n className=\"graphiql-method-pill graphiql-collection-method-pill-mix\"\n aria-hidden\n >\n MIX\n </span>\n ) : (\n <MethodPill operation={method} aria-hidden />\n )}\n {isEditing ? (\n <div\n ref={editFormRef}\n className=\"graphiql-collection-item-edit-form\"\n onClick={e => e.stopPropagation()}\n >\n <input\n className=\"graphiql-collection-item-edit-input\"\n value={editName}\n autoFocus\n placeholder={item.name}\n onChange={e => setEditName(e.target.value)}\n onBlur={handleBlur}\n onKeyDown={e => {\n if (e.key === 'Enter') {\n commitEdit();\n }\n if (e.key === 'Escape') {\n cancelEdit();\n }\n e.stopPropagation();\n }}\n />\n <input\n className=\"graphiql-collection-item-edit-input\"\n value={editDescription}\n placeholder=\"Description (optional)\"\n onChange={e => setEditDescription(e.target.value)}\n onBlur={handleBlur}\n onKeyDown={e => {\n if (e.key === 'Enter') {\n commitEdit();\n }\n if (e.key === 'Escape') {\n cancelEdit();\n }\n e.stopPropagation();\n }}\n />\n </div>\n ) : (\n <div className=\"graphiql-collection-item-main\">\n <span className=\"graphiql-collection-item-name\" title={item.name}>\n {item.name}\n </span>\n {item.description && (\n <span\n className=\"graphiql-collection-item-description\"\n title={item.description}\n >\n {item.description}\n </span>\n )}\n </div>\n )}\n {!isEditing && (\n <div className=\"graphiql-collection-item-actions\">\n {!readOnly && (\n <button\n type=\"button\"\n className=\"graphiql-collection-item-action\"\n aria-label={`Rename ${item.name}`}\n title=\"Rename\"\n onClick={startEdit}\n >\n <PenIcon aria-hidden=\"true\" />\n </button>\n )}\n <button\n type=\"button\"\n className=\"graphiql-collection-item-action\"\n aria-label={`Copy operation ${item.name}`}\n title=\"Copy operation\"\n data-confirmed={confirmed === 'copy' || undefined}\n onClick={e => {\n e.stopPropagation();\n void runAction(\n 'copy',\n () => navigator.clipboard.writeText(item.query),\n 'Copied query to clipboard.',\n 'Could not copy to clipboard.',\n );\n }}\n >\n {confirmed === 'copy' ? (\n <CheckIcon aria-hidden=\"true\" />\n ) : (\n <CopyIcon aria-hidden=\"true\" />\n )}\n </button>\n <button\n type=\"button\"\n className=\"graphiql-collection-item-action\"\n aria-label={`Share ${item.name} as collection`}\n title=\"Share as collection\"\n data-confirmed={confirmed === 'share' || undefined}\n onClick={e => {\n e.stopPropagation();\n void runAction(\n 'share',\n () => onShare(item.id),\n 'Shared operation to clipboard.',\n 'Could not share to clipboard.',\n );\n }}\n >\n {confirmed === 'share' ? (\n <CheckIcon aria-hidden=\"true\" />\n ) : (\n <UploadIcon aria-hidden=\"true\" />\n )}\n </button>\n {!readOnly && (\n <button\n type=\"button\"\n className=\"graphiql-collection-item-action\"\n aria-label={`Delete ${item.name}`}\n title=\"Delete\"\n onClick={handleDelete}\n >\n <TrashIcon aria-hidden=\"true\" />\n </button>\n )}\n </div>\n )}\n </div>\n );\n};\n"],"names":["CheckIcon","UploadIcon"],"mappings":";;;;;;AAmCO,MAAM,oBAAgD,CAAC;AAAA,EAC5D;AAAA,EACA;AAAA,EACA;AAAA,EACA,WAAW;AAAA,EACX;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAM;AACJ,QAAM,CAAC,YAAY,aAAa,IAAI,SAAS,KAAK;AAClD,QAAM,CAAC,WAAW,YAAY,IAAI,SAAS,KAAK;AAChD,QAAM,CAAC,WAAW,YAAY,IAAI,SAAkC,IAAI;AACxE,QAAM,CAAC,cAAc,eAAe,IAAI,SAAS,CAAC;AAC5C,QAAA,cAAc,OAAuB,IAAI;AAC/C,QAAM,CAAC,UAAU,WAAW,IAAI,SAAS,KAAK,IAAI;AAC5C,QAAA,CAAC,iBAAiB,kBAAkB,IAAI;AAAA,IAC5C,KAAK,eAAe;AAAA,EACtB;AACM,QAAA,SAAS,kBAAkB,KAAK,KAAK;AAIrC,QAAA,YAAY,CAAC,MAAwB;AACzC,MAAE,gBAAgB;AAClB,gBAAY,KAAK,IAAI;AACF,uBAAA,KAAK,eAAe,EAAE;AACzC,iBAAa,IAAI;AAAA,EACnB;AAEA,YAAU,MAAM;AACd,Q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Y,QAAO,IAE9B,oBAACC,WAAW,EAAA,eAAY,OAAO,CAAA;AAAA,YAAA;AAAA,UAEnC;AAAA,UACC,CAAC,YACA;AAAA,YAAC;AAAA,YAAA;AAAA,cACC,MAAK;AAAA,cACL,WAAU;AAAA,cACV,cAAY,UAAU,KAAK,IAAI;AAAA,cAC/B,OAAM;AAAA,cACN,SAAS;AAAA,cAET,UAAA,oBAAC,WAAU,EAAA,eAAY,OAAO,CAAA;AAAA,YAAA;AAAA,UAAA;AAAA,QAChC,EAEJ,CAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAEJ;AAEJ;"}
1
+ {"version":3,"file":"collection-item-row.js","names":[],"sources":["../../src/components/collection-item-row.tsx"],"sourcesContent":["import { FC, useEffect, useRef, useState } from 'react';\nimport { MethodPill, PenIcon, CopyIcon, TrashIcon } from '@graphiql/react';\nimport type { CollectionItem } from '../types';\nimport { getDocumentMethod } from '../operation-method';\nimport UploadIcon from '../icons/upload.svg?react';\nimport CheckIcon from '../icons/check.svg?react';\n\ntype CollectionItemRowProps = {\n item: CollectionItem;\n collectionId: string;\n /** The item's position within its collection, used for drag reorder. */\n index: number;\n /** Hide write affordances (Move, Delete) and disable drag-reorder when true. */\n readOnly?: boolean;\n isGrabbed: boolean;\n onGrabToggle(): void;\n onGrabMove(direction: 'up' | 'down'): void;\n onGrabCancel(): void;\n onOpen(item: CollectionItem): void;\n onShare(itemId: string): Promise<void>;\n onAnnounce(message: string): void;\n onDelete(collectionId: string, itemId: string): void;\n onMove(\n fromCollectionId: string,\n fromIndex: number,\n toCollectionId: string,\n toIndex: number,\n ): void;\n onRenameItem(\n collectionId: string,\n itemId: string,\n updates: { name: string; description: string },\n ): void;\n};\n\nexport const CollectionItemRow: FC<CollectionItemRowProps> = ({\n item,\n collectionId,\n index,\n readOnly = false,\n isGrabbed,\n onGrabToggle,\n onGrabMove,\n onGrabCancel,\n onOpen,\n onShare,\n onAnnounce,\n onDelete,\n onMove,\n onRenameItem,\n}) => {\n const [isDragOver, setIsDragOver] = useState(false);\n const [isEditing, setIsEditing] = useState(false);\n const [confirmed, setConfirmed] = useState<'copy' | 'share' | null>(null);\n const [confirmToken, setConfirmToken] = useState(0);\n const editFormRef = useRef<HTMLDivElement>(null);\n const [editName, setEditName] = useState(item.name);\n const [editDescription, setEditDescription] = useState(\n item.description ?? '',\n );\n const method = getDocumentMethod(item.query);\n\n // Action buttons stop propagation so their clicks don't also trigger the\n // row's open handler.\n const startEdit = (e: React.MouseEvent) => {\n e.stopPropagation();\n setEditName(item.name);\n setEditDescription(item.description ?? '');\n setIsEditing(true);\n };\n\n useEffect(() => {\n if (!confirmed) {\n return;\n }\n const timer = setTimeout(() => setConfirmed(null), 1500);\n return () => clearTimeout(timer);\n }, [confirmed, confirmToken]);\n\n const runAction = async (\n kind: 'copy' | 'share',\n write: () => Promise<void>,\n message: string,\n failureMessage: string,\n ) => {\n try {\n await write();\n onAnnounce(message);\n setConfirmed(kind);\n setConfirmToken(t => t + 1);\n } catch {\n onAnnounce(failureMessage);\n }\n };\n\n const handleDelete = (e: React.MouseEvent) => {\n e.stopPropagation();\n onDelete(collectionId, item.id);\n };\n\n const commitEdit = () => {\n const name = editName.trim() || item.name;\n onRenameItem(collectionId, item.id, {\n name,\n description: editDescription,\n });\n setIsEditing(false);\n };\n\n // Commit only when focus leaves the whole form; moving between the name and\n // description inputs must not tear down the edit UI mid-edit.\n const handleBlur = (e: React.FocusEvent) => {\n if (editFormRef.current?.contains(e.relatedTarget as Node | null)) {\n return;\n }\n commitEdit();\n };\n\n const cancelEdit = () => {\n setEditName(item.name);\n setEditDescription(item.description ?? '');\n setIsEditing(false);\n };\n\n return (\n <div\n className={`graphiql-collection-item-row${isDragOver ? ' graphiql-collection-drop-target' : ''}`}\n data-grabbed={isGrabbed || undefined}\n draggable={!readOnly && !isEditing}\n onDragStart={\n readOnly || isEditing\n ? undefined\n : e => {\n e.dataTransfer.setData(\n 'application/x-graphiql-item',\n JSON.stringify({ collectionId, index }),\n );\n e.dataTransfer.effectAllowed = 'move';\n }\n }\n onDragOver={\n readOnly\n ? undefined\n : e => {\n e.preventDefault();\n e.dataTransfer.dropEffect = 'move';\n setIsDragOver(true);\n }\n }\n onDragLeave={readOnly ? undefined : () => setIsDragOver(false)}\n onDrop={\n readOnly\n ? undefined\n : e => {\n e.preventDefault();\n setIsDragOver(false);\n try {\n const data = JSON.parse(\n e.dataTransfer.getData('application/x-graphiql-item'),\n );\n onMove(data.collectionId, data.index, collectionId, index);\n } catch {\n // malformed drag data\n }\n }\n }\n onClick={() => {\n if (!isEditing) {\n onOpen(item);\n }\n }}\n >\n <button\n type=\"button\"\n className=\"graphiql-collection-drag-handle\"\n data-collection-drag-handle={item.id}\n aria-label={`Reorder ${item.name}. Press space to grab, arrow keys to move, escape to cancel.`}\n aria-pressed={isGrabbed}\n disabled={readOnly}\n onClick={e => e.stopPropagation()}\n onKeyDown={e => {\n if (e.key === ' ' || e.key === 'Enter') {\n e.preventDefault();\n e.stopPropagation();\n onGrabToggle();\n } else if (isGrabbed && e.key === 'ArrowDown') {\n e.preventDefault();\n e.stopPropagation();\n onGrabMove('down');\n } else if (isGrabbed && e.key === 'ArrowUp') {\n e.preventDefault();\n e.stopPropagation();\n onGrabMove('up');\n } else if (isGrabbed && e.key === 'Escape') {\n e.preventDefault();\n e.stopPropagation();\n onGrabCancel();\n }\n }}\n >\n ⠿\n </button>\n {method === 'mix' ? (\n <span\n className=\"graphiql-method-pill graphiql-collection-method-pill-mix\"\n aria-hidden\n >\n MIX\n </span>\n ) : (\n <MethodPill operation={method} aria-hidden />\n )}\n {isEditing ? (\n <div\n ref={editFormRef}\n className=\"graphiql-collection-item-edit-form\"\n onClick={e => e.stopPropagation()}\n >\n <input\n className=\"graphiql-collection-item-edit-input\"\n value={editName}\n autoFocus\n placeholder={item.name}\n onChange={e => setEditName(e.target.value)}\n onBlur={handleBlur}\n onKeyDown={e => {\n if (e.key === 'Enter') {\n commitEdit();\n }\n if (e.key === 'Escape') {\n cancelEdit();\n }\n e.stopPropagation();\n }}\n />\n <input\n className=\"graphiql-collection-item-edit-input\"\n value={editDescription}\n placeholder=\"Description (optional)\"\n onChange={e => setEditDescription(e.target.value)}\n onBlur={handleBlur}\n onKeyDown={e => {\n if (e.key === 'Enter') {\n commitEdit();\n }\n if (e.key === 'Escape') {\n cancelEdit();\n }\n e.stopPropagation();\n }}\n />\n </div>\n ) : (\n <div className=\"graphiql-collection-item-main\">\n <span className=\"graphiql-collection-item-name\" title={item.name}>\n {item.name}\n </span>\n {item.description && (\n <span\n className=\"graphiql-collection-item-description\"\n title={item.description}\n >\n {item.description}\n </span>\n )}\n </div>\n )}\n {!isEditing && (\n <div className=\"graphiql-collection-item-actions\">\n {!readOnly && (\n <button\n type=\"button\"\n className=\"graphiql-collection-item-action\"\n aria-label={`Rename ${item.name}`}\n title=\"Rename\"\n onClick={startEdit}\n >\n <PenIcon aria-hidden=\"true\" />\n </button>\n )}\n <button\n type=\"button\"\n className=\"graphiql-collection-item-action\"\n aria-label={`Copy operation ${item.name}`}\n title=\"Copy operation\"\n data-confirmed={confirmed === 'copy' || undefined}\n onClick={e => {\n e.stopPropagation();\n void runAction(\n 'copy',\n () => navigator.clipboard.writeText(item.query),\n 'Copied query to clipboard.',\n 'Could not copy to clipboard.',\n );\n }}\n >\n {confirmed === 'copy' ? (\n <CheckIcon aria-hidden=\"true\" />\n ) : (\n <CopyIcon aria-hidden=\"true\" />\n )}\n </button>\n <button\n type=\"button\"\n className=\"graphiql-collection-item-action\"\n aria-label={`Share ${item.name} as collection`}\n title=\"Share as collection\"\n data-confirmed={confirmed === 'share' || undefined}\n onClick={e => {\n e.stopPropagation();\n void runAction(\n 'share',\n () => onShare(item.id),\n 'Shared operation to clipboard.',\n 'Could not share to clipboard.',\n );\n }}\n >\n {confirmed === 'share' ? (\n <CheckIcon aria-hidden=\"true\" />\n ) : (\n <UploadIcon aria-hidden=\"true\" />\n )}\n </button>\n {!readOnly && (\n <button\n type=\"button\"\n className=\"graphiql-collection-item-action\"\n aria-label={`Delete ${item.name}`}\n title=\"Delete\"\n onClick={handleDelete}\n >\n <TrashIcon aria-hidden=\"true\" />\n </button>\n )}\n </div>\n )}\n </div>\n );\n};\n"],"mappings":";;;;;;;AAmCA,IAAa,qBAAiD,EAC5D,MACA,cACA,OACA,WAAW,OACX,WACA,cACA,YACA,cACA,QACA,SACA,YACA,UACA,QACA,mBACI;CACJ,MAAM,CAAC,YAAY,iBAAiB,SAAS,KAAK;CAClD,MAAM,CAAC,WAAW,gBAAgB,SAAS,KAAK;CAChD,MAAM,CAAC,WAAW,gBAAgB,SAAkC,IAAI;CACxE,MAAM,CAAC,cAAc,mBAAmB,SAAS,CAAC;CAClD,MAAM,cAAc,OAAuB,IAAI;CAC/C,MAAM,CAAC,UAAU,eAAe,SAAS,KAAK,IAAI;CAClD,MAAM,CAAC,iBAAiB,sBAAsB,SAC5C,KAAK,eAAe,EACtB;CACA,MAAM,SAAS,kBAAkB,KAAK,KAAK;CAI3C,MAAM,aAAa,MAAwB;EACzC,EAAE,gBAAgB;EAClB,YAAY,KAAK,IAAI;EACrB,mBAAmB,KAAK,eAAe,EAAE;EACzC,aAAa,IAAI;CACnB;CAEA,gBAAgB;EACd,IAAI,CAAC,WACH;EAEF,MAAM,QAAQ,iBAAiB,aAAa,IAAI,GAAG,IAAI;EACvD,aAAa,aAAa,KAAK;CACjC,GAAG,CAAC,WAAW,YAAY,CAAC;CAE5B,MAAM,YAAY,OAChB,MACA,OACA,SACA,mBACG;EACH,IAAI;GACF,MAAM,MAAM;GACZ,WAAW,OAAO;GAClB,aAAa,IAAI;GACjB,iBAAgB,MAAK,IAAI,CAAC;EAC5B,QAAQ;GACN,WAAW,cAAc;EAC3B;CACF;CAEA,MAAM,gBAAgB,MAAwB;EAC5C,EAAE,gBAAgB;EAClB,SAAS,cAAc,KAAK,EAAE;CAChC;CAEA,MAAM,mBAAmB;EACvB,MAAM,OAAO,SAAS,KAAK,KAAK,KAAK;EACrC,aAAa,cA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