@graphiql/plugin-collections 1.0.0-rc.1 → 1.0.1
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/collection-item-row.js +3 -4
- package/dist/components/collection-item-row.js.map +1 -1
- package/dist/components/collection-row.js +3 -4
- package/dist/components/collection-row.js.map +1 -1
- package/dist/components/collections-panel.js +4 -5
- package/dist/components/collections-panel.js.map +1 -1
- package/dist/components/conflict-dialog.js +2 -3
- package/dist/components/conflict-dialog.js.map +1 -1
- package/dist/components/export-dialog.js +28 -22
- package/dist/components/export-dialog.js.map +1 -1
- package/dist/components/import-dialog.js +60 -54
- package/dist/components/import-dialog.js.map +1 -1
- package/dist/components/save-dialog.js +24 -24
- package/dist/components/save-dialog.js.map +1 -1
- package/dist/components/session-actions.d.ts +1 -1
- package/dist/components/session-actions.js +2 -3
- package/dist/icons/check.svg_react.js +23 -0
- package/dist/icons/check.svg_react.js.map +1 -0
- package/dist/icons/collections.svg_react.js +21 -0
- package/dist/icons/collections.svg_react.js.map +1 -0
- package/dist/icons/download.svg_react.js +21 -0
- package/dist/icons/download.svg_react.js.map +1 -0
- package/dist/icons/upload.svg_react.js +21 -0
- package/dist/icons/upload.svg_react.js.map +1 -0
- package/dist/index.js +5 -6
- package/dist/index.js.map +1 -1
- package/dist/operation-method.js +1 -2
- package/dist/storage/local-storage.js +1 -2
- package/dist/storage/tab-links.js +1 -2
- package/dist/store.d.ts +3 -1
- package/dist/store.js +6 -5
- package/dist/store.js.map +1 -1
- package/dist/types.js +1 -2
- package/dist/utility/uuid.js +1 -2
- package/package.json +12 -11
- package/dist/icons/check.js +0 -19
- package/dist/icons/check.js.map +0 -1
- package/dist/icons/collections.js +0 -17
- package/dist/icons/collections.js.map +0 -1
- package/dist/icons/download.js +0 -17
- package/dist/icons/download.js.map +0 -1
- package/dist/icons/upload.js +0 -17
- package/dist/icons/upload.js.map +0 -1
|
@@ -2,7 +2,7 @@ import { collectionsStore } from "../store.js";
|
|
|
2
2
|
import { useRef, useState } from "react";
|
|
3
3
|
import { Button, Dialog } from "@graphiql/react";
|
|
4
4
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
-
|
|
5
|
+
// src/components/import-dialog.tsx
|
|
6
6
|
var ImportDialog = ({ open, onClose, onImport, allowReplace = true }) => {
|
|
7
7
|
const [importMode, setImportMode] = useState("merge");
|
|
8
8
|
const [importError, setImportError] = useState(null);
|
|
@@ -42,61 +42,67 @@ var ImportDialog = ({ open, onClose, onImport, allowReplace = true }) => {
|
|
|
42
42
|
return /* @__PURE__ */ jsxs(Dialog, {
|
|
43
43
|
open,
|
|
44
44
|
onOpenChange: (o) => !o && onClose(),
|
|
45
|
-
children: [
|
|
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
|
-
|
|
45
|
+
children: [
|
|
46
|
+
/* @__PURE__ */ jsx(Dialog.Header, { children: "Import collections" }),
|
|
47
|
+
/* @__PURE__ */ jsx(Dialog.Description, {
|
|
48
|
+
className: "graphiql-sr-only",
|
|
49
|
+
children: "Import collections from a JSON export."
|
|
50
|
+
}),
|
|
51
|
+
/* @__PURE__ */ jsx(Dialog.Body, { children: /* @__PURE__ */ jsxs("div", {
|
|
52
|
+
className: "graphiql-import-export-section",
|
|
53
|
+
children: [
|
|
54
|
+
/* @__PURE__ */ jsx("textarea", {
|
|
55
|
+
className: "graphiql-import-export-textarea",
|
|
56
|
+
rows: 6,
|
|
57
|
+
"aria-label": "Paste collections export JSON",
|
|
58
|
+
placeholder: "Paste a collections export (JSON)…",
|
|
59
|
+
value: pastedText,
|
|
60
|
+
onChange: (e) => {
|
|
61
|
+
setPastedText(e.target.value);
|
|
62
|
+
setImportError(null);
|
|
63
|
+
}
|
|
64
|
+
}),
|
|
65
|
+
/* @__PURE__ */ jsx("input", {
|
|
66
|
+
ref: fileInputRef,
|
|
67
|
+
type: "file",
|
|
68
|
+
accept: ".json,application/json",
|
|
69
|
+
onChange: () => setImportError(null)
|
|
70
|
+
}),
|
|
71
|
+
/* @__PURE__ */ jsxs("fieldset", {
|
|
72
|
+
className: "graphiql-import-export-mode",
|
|
73
|
+
children: [
|
|
74
|
+
/* @__PURE__ */ jsx("legend", { children: "Import mode" }),
|
|
75
|
+
/* @__PURE__ */ jsxs("label", { children: [/* @__PURE__ */ jsx("input", {
|
|
76
|
+
type: "radio",
|
|
77
|
+
name: "import-mode",
|
|
78
|
+
value: "merge",
|
|
79
|
+
checked: !allowReplace || importMode === "merge",
|
|
80
|
+
onChange: () => setImportMode("merge")
|
|
81
|
+
}), "Merge (add new, update changed in place)"] }),
|
|
82
|
+
allowReplace && /* @__PURE__ */ jsxs("label", { children: [/* @__PURE__ */ jsx("input", {
|
|
83
|
+
type: "radio",
|
|
84
|
+
name: "import-mode",
|
|
85
|
+
value: "replace",
|
|
86
|
+
checked: importMode === "replace",
|
|
87
|
+
onChange: () => setImportMode("replace")
|
|
88
|
+
}), "Replace (remove all existing collections)"] })
|
|
89
|
+
]
|
|
90
|
+
}),
|
|
91
|
+
importError && /* @__PURE__ */ jsx("p", {
|
|
92
|
+
className: "graphiql-import-export-error",
|
|
93
|
+
children: importError
|
|
94
|
+
}),
|
|
95
|
+
/* @__PURE__ */ jsx(Button, {
|
|
96
|
+
type: "button",
|
|
97
|
+
variant: "primary",
|
|
98
|
+
onClick: handleImport,
|
|
99
|
+
children: "Import"
|
|
100
|
+
})
|
|
101
|
+
]
|
|
102
|
+
}) })
|
|
103
|
+
]
|
|
97
104
|
});
|
|
98
105
|
};
|
|
99
|
-
//#endregion
|
|
100
106
|
export { ImportDialog };
|
|
101
107
|
|
|
102
108
|
//# sourceMappingURL=import-dialog.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"import-dialog.js","names":[],"sources":["../../src/components/import-dialog.tsx"],"sourcesContent":["import { FC, useRef, useState } from 'react';\nimport { Button, Dialog } from '@graphiql/react';\nimport { collectionsStore } from '../store';\n\ntype ImportDialogProps = {\n open: boolean;\n onClose(): void;\n onImport(text: string, mode: 'merge' | 'replace'): void;\n /** Hide the \"Replace\" import option (force merge) when false. */\n allowReplace?: boolean;\n};\n\nexport const ImportDialog: FC<ImportDialogProps> = ({\n open,\n onClose,\n onImport,\n allowReplace = true,\n}) => {\n const [importMode, setImportMode] = useState<'merge' | 'replace'>('merge');\n const [importError, setImportError] = useState<string | null>(null);\n const [pastedText, setPastedText] = useState('');\n const fileInputRef = useRef<HTMLInputElement>(null);\n\n const validateAndImport = (text: string) => {\n try {\n JSON.parse(text);\n } catch {\n setImportError(\n 'Invalid JSON. Please paste or select a valid collections export.',\n );\n return;\n }\n const analysis = collectionsStore.getState().actions.analyzeImport(text);\n if (!analysis.ok) {\n setImportError('This isn’t a valid collections export.');\n return;\n }\n onImport(text, allowReplace ? importMode : 'merge');\n onClose();\n };\n\n const handleImport = () => {\n const pasted = pastedText.trim();\n if (pasted) {\n validateAndImport(pasted);\n return;\n }\n const file = fileInputRef.current?.files?.[0];\n if (!file) {\n setImportError('Paste a collections export or choose a file.');\n return;\n }\n const reader = new FileReader();\n reader.onload = e => {\n validateAndImport(e.target?.result as string);\n };\n reader.readAsText(file);\n };\n\n return (\n <Dialog open={open} onOpenChange={o => !o && onClose()}>\n <Dialog.Header>Import collections</Dialog.Header>\n <Dialog.Body>\n <div className=\"graphiql-import-export-section\">\n <textarea\n className=\"graphiql-import-export-textarea\"\n rows={6}\n aria-label=\"Paste collections export JSON\"\n placeholder=\"Paste a collections export (JSON)…\"\n value={pastedText}\n onChange={e => {\n setPastedText(e.target.value);\n setImportError(null);\n }}\n />\n <input\n ref={fileInputRef}\n type=\"file\"\n accept=\".json,application/json\"\n onChange={() => setImportError(null)}\n />\n <fieldset className=\"graphiql-import-export-mode\">\n <legend>Import mode</legend>\n <label>\n <input\n type=\"radio\"\n name=\"import-mode\"\n value=\"merge\"\n checked={!allowReplace || importMode === 'merge'}\n onChange={() => setImportMode('merge')}\n />\n Merge (add new, update changed in place)\n </label>\n {allowReplace && (\n <label>\n <input\n type=\"radio\"\n name=\"import-mode\"\n value=\"replace\"\n checked={importMode === 'replace'}\n onChange={() => setImportMode('replace')}\n />\n Replace (remove all existing collections)\n </label>\n )}\n </fieldset>\n {importError && (\n <p className=\"graphiql-import-export-error\">{importError}</p>\n )}\n <Button type=\"button\" variant=\"primary\" onClick={handleImport}>\n Import\n </Button>\n </div>\n </Dialog.Body>\n </Dialog>\n );\n};\n"],"mappings":";;;;;AAYA,IAAa,gBAAuC,EAClD,MACA,SACA,UACA,eAAe,WACX;CACJ,MAAM,CAAC,YAAY,iBAAiB,SAA8B,OAAO;CACzE,MAAM,CAAC,aAAa,kBAAkB,SAAwB,IAAI;CAClE,MAAM,CAAC,YAAY,iBAAiB,SAAS,EAAE;CAC/C,MAAM,eAAe,OAAyB,IAAI;CAElD,MAAM,qBAAqB,SAAiB;EAC1C,IAAI;GACF,KAAK,MAAM,IAAI;EACjB,QAAQ;GACN,eACE,kEACF;GACA;EACF;EAEA,IAAI,CADa,iBAAiB,SAAS,CAAC,CAAC,QAAQ,cAAc,IAC9D,CAAA,CAAS,IAAI;GAChB,eAAe,wCAAwC;GACvD;EACF;EACA,SAAS,MAAM,eAAe,aAAa,OAAO;EAClD,QAAQ;CACV;CAEA,MAAM,qBAAqB;EACzB,MAAM,SAAS,WAAW,KAAK;EAC/B,IAAI,QAAQ;GACV,kBAAkB,MAAM;GACxB;EACF;EACA,MAAM,OAAO,aAAa,SAAS,QAAQ;EAC3C,IAAI,CAAC,MAAM;GACT,eAAe,8CAA8C;GAC7D;EACF;EACA,MAAM,SAAS,IAAI,WAAW;EAC9B,OAAO,UAAS,MAAK;GACnB,kBAAkB,EAAE,QAAQ,MAAgB;EAC9C;EACA,OAAO,WAAW,IAAI;CACxB;CAEA,OACE,qBAAC,QAAD;EAAc;EAAM,eAAc,MAAK,CAAC,KAAK,QAAQ;EAArD,UAAA,
|
|
1
|
+
{"version":3,"file":"import-dialog.js","names":[],"sources":["../../src/components/import-dialog.tsx"],"sourcesContent":["import { FC, useRef, useState } from 'react';\nimport { Button, Dialog } from '@graphiql/react';\nimport { collectionsStore } from '../store';\n\ntype ImportDialogProps = {\n open: boolean;\n onClose(): void;\n onImport(text: string, mode: 'merge' | 'replace'): void;\n /** Hide the \"Replace\" import option (force merge) when false. */\n allowReplace?: boolean;\n};\n\nexport const ImportDialog: FC<ImportDialogProps> = ({\n open,\n onClose,\n onImport,\n allowReplace = true,\n}) => {\n const [importMode, setImportMode] = useState<'merge' | 'replace'>('merge');\n const [importError, setImportError] = useState<string | null>(null);\n const [pastedText, setPastedText] = useState('');\n const fileInputRef = useRef<HTMLInputElement>(null);\n\n const validateAndImport = (text: string) => {\n try {\n JSON.parse(text);\n } catch {\n setImportError(\n 'Invalid JSON. Please paste or select a valid collections export.',\n );\n return;\n }\n const analysis = collectionsStore.getState().actions.analyzeImport(text);\n if (!analysis.ok) {\n setImportError('This isn’t a valid collections export.');\n return;\n }\n onImport(text, allowReplace ? importMode : 'merge');\n onClose();\n };\n\n const handleImport = () => {\n const pasted = pastedText.trim();\n if (pasted) {\n validateAndImport(pasted);\n return;\n }\n const file = fileInputRef.current?.files?.[0];\n if (!file) {\n setImportError('Paste a collections export or choose a file.');\n return;\n }\n const reader = new FileReader();\n reader.onload = e => {\n validateAndImport(e.target?.result as string);\n };\n reader.readAsText(file);\n };\n\n return (\n <Dialog open={open} onOpenChange={o => !o && onClose()}>\n <Dialog.Header>Import collections</Dialog.Header>\n <Dialog.Description className=\"graphiql-sr-only\">\n Import collections from a JSON export.\n </Dialog.Description>\n <Dialog.Body>\n <div className=\"graphiql-import-export-section\">\n <textarea\n className=\"graphiql-import-export-textarea\"\n rows={6}\n aria-label=\"Paste collections export JSON\"\n placeholder=\"Paste a collections export (JSON)…\"\n value={pastedText}\n onChange={e => {\n setPastedText(e.target.value);\n setImportError(null);\n }}\n />\n <input\n ref={fileInputRef}\n type=\"file\"\n accept=\".json,application/json\"\n onChange={() => setImportError(null)}\n />\n <fieldset className=\"graphiql-import-export-mode\">\n <legend>Import mode</legend>\n <label>\n <input\n type=\"radio\"\n name=\"import-mode\"\n value=\"merge\"\n checked={!allowReplace || importMode === 'merge'}\n onChange={() => setImportMode('merge')}\n />\n Merge (add new, update changed in place)\n </label>\n {allowReplace && (\n <label>\n <input\n type=\"radio\"\n name=\"import-mode\"\n value=\"replace\"\n checked={importMode === 'replace'}\n onChange={() => setImportMode('replace')}\n />\n Replace (remove all existing collections)\n </label>\n )}\n </fieldset>\n {importError && (\n <p className=\"graphiql-import-export-error\">{importError}</p>\n )}\n <Button type=\"button\" variant=\"primary\" onClick={handleImport}>\n Import\n </Button>\n </div>\n </Dialog.Body>\n </Dialog>\n );\n};\n"],"mappings":";;;;;AAYA,IAAa,gBAAuC,EAClD,MACA,SACA,UACA,eAAe,WACX;CACJ,MAAM,CAAC,YAAY,iBAAiB,SAA8B,OAAO;CACzE,MAAM,CAAC,aAAa,kBAAkB,SAAwB,IAAI;CAClE,MAAM,CAAC,YAAY,iBAAiB,SAAS,EAAE;CAC/C,MAAM,eAAe,OAAyB,IAAI;CAElD,MAAM,qBAAqB,SAAiB;EAC1C,IAAI;GACF,KAAK,MAAM,IAAI;EACjB,QAAQ;GACN,eACE,kEACF;GACA;EACF;EAEA,IAAI,CADa,iBAAiB,SAAS,CAAC,CAAC,QAAQ,cAAc,IAC9D,CAAA,CAAS,IAAI;GAChB,eAAe,wCAAwC;GACvD;EACF;EACA,SAAS,MAAM,eAAe,aAAa,OAAO;EAClD,QAAQ;CACV;CAEA,MAAM,qBAAqB;EACzB,MAAM,SAAS,WAAW,KAAK;EAC/B,IAAI,QAAQ;GACV,kBAAkB,MAAM;GACxB;EACF;EACA,MAAM,OAAO,aAAa,SAAS,QAAQ;EAC3C,IAAI,CAAC,MAAM;GACT,eAAe,8CAA8C;GAC7D;EACF;EACA,MAAM,SAAS,IAAI,WAAW;EAC9B,OAAO,UAAS,MAAK;GACnB,kBAAkB,EAAE,QAAQ,MAAgB;EAC9C;EACA,OAAO,WAAW,IAAI;CACxB;CAEA,OACE,qBAAC,QAAD;EAAc;EAAM,eAAc,MAAK,CAAC,KAAK,QAAQ;EAArD,UAAA;GACE,oBAAC,OAAO,QAAR,EAAA,UAAe,qBAAiC,CAAA;GAChD,oBAAC,OAAO,aAAR;IAAoB,WAAU;IAAmB,UAAA;GAE7B,CAAA;GACpB,oBAAC,OAAO,MAAR,EAAA,UACE,qBAAC,OAAD;IAAK,WAAU;IAAf,UAAA;KACE,oBAAC,YAAD;MACE,WAAU;MACV,MAAM;MACN,cAAW;MACX,aAAY;MACZ,OAAO;MACP,WAAU,MAAK;OACb,cAAc,EAAE,OAAO,KAAK;OAC5B,eAAe,IAAI;MACrB;KACD,CAAA;KACD,oBAAC,SAAD;MACE,KAAK;MACL,MAAK;MACL,QAAO;MACP,gBAAgB,eAAe,IAAI;KACpC,CAAA;KACD,qBAAC,YAAD;MAAU,WAAU;MAApB,UAAA;OACE,oBAAC,UAAD,EAAA,UAAQ,cAAmB,CAAA;OAC3B,qBAAC,SAAD,EAAA,UAAA,CACE,oBAAC,SAAD;QACE,MAAK;QACL,MAAK;QACL,OAAM;QACN,SAAS,CAAC,gBAAgB,eAAe;QACzC,gBAAgB,cAAc,OAAO;OACtC,CAAA,GAAC,0CAEG,EAAA,CAAA;OACN,gBACC,qBAAC,SAAD,EAAA,UAAA,CACE,oBAAC,SAAD;QACE,MAAK;QACL,MAAK;QACL,OAAM;QACN,SAAS,eAAe;QACxB,gBAAgB,cAAc,SAAS;OACxC,CAAA,GAAC,2CAEG,EAAA,CAAA;MAED;;KACT,eACC,oBAAC,KAAD;MAAG,WAAU;MAAgC,UAAA;KAAe,CAAA;KAE9D,oBAAC,QAAD;MAAQ,MAAK;MAAS,SAAQ;MAAU,SAAS;MAAc,UAAA;KAEvD,CAAA;IACL;GACM,CAAA,EAAA,CAAA;EACP;;AAEZ"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { collectionsStore, useCollectionsStore } from "../store.js";
|
|
2
|
-
import {
|
|
2
|
+
import { useState } from "react";
|
|
3
3
|
import { Button, Dialog } from "@graphiql/react";
|
|
4
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
-
|
|
4
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
// src/components/save-dialog.tsx
|
|
6
6
|
var NEW_COLLECTION = "__new__";
|
|
7
7
|
/**
|
|
8
8
|
* The single "Save to collection" dialog. Its open state and the operation
|
|
@@ -10,24 +10,22 @@ var NEW_COLLECTION = "__new__";
|
|
|
10
10
|
* it imperatively via `requestSave`.
|
|
11
11
|
*/
|
|
12
12
|
var SaveDialog = () => {
|
|
13
|
+
const { open, name, requestId } = useCollectionsStore((s) => s.saveDialog);
|
|
14
|
+
const closeSaveDialog = useCollectionsStore((s) => s.actions.closeSaveDialog);
|
|
15
|
+
return /* @__PURE__ */ jsx(Dialog, {
|
|
16
|
+
open,
|
|
17
|
+
onOpenChange: (o) => !o && closeSaveDialog(),
|
|
18
|
+
children: open && /* @__PURE__ */ jsx(SaveDialogForm, { initialName: name }, requestId)
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
var SaveDialogForm = ({ initialName }) => {
|
|
13
22
|
const collections = useCollectionsStore((s) => s.collections);
|
|
14
|
-
const
|
|
15
|
-
const { open, name: initialName } = useCollectionsStore((s) => s.saveDialog);
|
|
23
|
+
const closeSaveDialog = useCollectionsStore((s) => s.actions.closeSaveDialog);
|
|
16
24
|
const [saving, setSaving] = useState(false);
|
|
17
25
|
const [name, setName] = useState(initialName);
|
|
18
26
|
const [description, setDescription] = useState("");
|
|
19
|
-
const [selectedCollectionId, setSelectedCollectionId] = useState(NEW_COLLECTION);
|
|
27
|
+
const [selectedCollectionId, setSelectedCollectionId] = useState(() => collections[0]?.id ?? NEW_COLLECTION);
|
|
20
28
|
const [newCollectionName, setNewCollectionName] = useState("New Collection");
|
|
21
|
-
useEffect(() => {
|
|
22
|
-
if (open) {
|
|
23
|
-
const { collections: current } = collectionsStore.getState();
|
|
24
|
-
setName(initialName);
|
|
25
|
-
setDescription("");
|
|
26
|
-
setSelectedCollectionId(current[0]?.id ?? NEW_COLLECTION);
|
|
27
|
-
setNewCollectionName("New Collection");
|
|
28
|
-
setSaving(false);
|
|
29
|
-
}
|
|
30
|
-
}, [open, initialName]);
|
|
31
29
|
const handleSave = async () => {
|
|
32
30
|
setSaving(true);
|
|
33
31
|
try {
|
|
@@ -41,10 +39,13 @@ var SaveDialog = () => {
|
|
|
41
39
|
setSaving(false);
|
|
42
40
|
}
|
|
43
41
|
};
|
|
44
|
-
return /* @__PURE__ */ jsxs(
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
42
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
43
|
+
/* @__PURE__ */ jsx(Dialog.Header, { children: "Save to collection" }),
|
|
44
|
+
/* @__PURE__ */ jsx(Dialog.Description, {
|
|
45
|
+
className: "graphiql-sr-only",
|
|
46
|
+
children: "Save the current operation to a collection."
|
|
47
|
+
}),
|
|
48
|
+
/* @__PURE__ */ jsxs("form", {
|
|
48
49
|
onSubmit: (e) => {
|
|
49
50
|
e.preventDefault();
|
|
50
51
|
handleSave();
|
|
@@ -99,7 +100,7 @@ var SaveDialog = () => {
|
|
|
99
100
|
] }), /* @__PURE__ */ jsxs(Dialog.Footer, { children: [/* @__PURE__ */ jsx(Button, {
|
|
100
101
|
type: "button",
|
|
101
102
|
disabled: saving,
|
|
102
|
-
onClick:
|
|
103
|
+
onClick: closeSaveDialog,
|
|
103
104
|
children: "Cancel"
|
|
104
105
|
}), /* @__PURE__ */ jsx(Button, {
|
|
105
106
|
type: "submit",
|
|
@@ -107,10 +108,9 @@ var SaveDialog = () => {
|
|
|
107
108
|
disabled: saving,
|
|
108
109
|
children: saving ? "Saving…" : "Save"
|
|
109
110
|
})] })]
|
|
110
|
-
})
|
|
111
|
-
});
|
|
111
|
+
})
|
|
112
|
+
] });
|
|
112
113
|
};
|
|
113
|
-
//#endregion
|
|
114
114
|
export { SaveDialog };
|
|
115
115
|
|
|
116
116
|
//# sourceMappingURL=save-dialog.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"save-dialog.js","names":[],"sources":["../../src/components/save-dialog.tsx"],"sourcesContent":["import { FC,
|
|
1
|
+
{"version":3,"file":"save-dialog.js","names":["_Fragment"],"sources":["../../src/components/save-dialog.tsx"],"sourcesContent":["import { FC, useState } from 'react';\nimport { Button, Dialog } from '@graphiql/react';\nimport { useCollectionsStore, collectionsStore } from '../store';\n\nconst NEW_COLLECTION = '__new__';\n\n/**\n * The single \"Save to collection\" dialog. Its open state and the operation\n * being saved live in the collections store, so ⌘S and the save button can open\n * it imperatively via `requestSave`.\n */\nexport const SaveDialog: FC = () => {\n const { open, name, requestId } = useCollectionsStore(s => s.saveDialog);\n const closeSaveDialog = useCollectionsStore(s => s.actions.closeSaveDialog);\n\n return (\n <Dialog open={open} onOpenChange={o => !o && closeSaveDialog()}>\n {open && <SaveDialogForm key={requestId} initialName={name} />}\n </Dialog>\n );\n};\n\nconst SaveDialogForm: FC<{ initialName: string }> = ({ initialName }) => {\n const collections = useCollectionsStore(s => s.collections);\n const closeSaveDialog = useCollectionsStore(s => s.actions.closeSaveDialog);\n const [saving, setSaving] = useState(false);\n const [name, setName] = useState(initialName);\n const [description, setDescription] = useState('');\n const [selectedCollectionId, setSelectedCollectionId] = useState(\n () => collections[0]?.id ?? NEW_COLLECTION,\n );\n const [newCollectionName, setNewCollectionName] = useState('New Collection');\n\n const handleSave = async () => {\n setSaving(true);\n try {\n await collectionsStore.getState().actions.commitSaveDialog({\n name: name || 'Unnamed operation',\n description: description || undefined,\n collectionId:\n selectedCollectionId === NEW_COLLECTION\n ? undefined\n : selectedCollectionId,\n newCollectionName,\n });\n } catch {\n // The editor displays the rejected save; it retains the dirty state.\n } finally {\n setSaving(false);\n }\n };\n\n return (\n <>\n <Dialog.Header>Save to collection</Dialog.Header>\n <Dialog.Description className=\"graphiql-sr-only\">\n Save the current operation to a collection.\n </Dialog.Description>\n <form\n onSubmit={e => {\n e.preventDefault();\n void handleSave();\n }}\n >\n <Dialog.Body>\n <label className=\"graphiql-save-dialog-field\">\n <span>Operation name</span>\n <input\n type=\"text\"\n value={name}\n onChange={e => setName(e.target.value)}\n placeholder=\"Unnamed operation\"\n className=\"graphiql-save-dialog-input\"\n autoFocus\n />\n </label>\n <label className=\"graphiql-save-dialog-field\">\n <span>Description</span>\n <input\n type=\"text\"\n value={description}\n onChange={e => setDescription(e.target.value)}\n placeholder=\"Description (optional)\"\n className=\"graphiql-save-dialog-input\"\n />\n </label>\n <label className=\"graphiql-save-dialog-field\">\n <span>Collection</span>\n <select\n value={selectedCollectionId}\n onChange={e => setSelectedCollectionId(e.target.value)}\n className=\"graphiql-save-dialog-select\"\n >\n <option value={NEW_COLLECTION}>+ New collection</option>\n {collections.map(c => (\n <option key={c.id} value={c.id}>\n {c.name}\n </option>\n ))}\n </select>\n </label>\n {selectedCollectionId === NEW_COLLECTION && (\n <label className=\"graphiql-save-dialog-field\">\n <span>Collection name</span>\n <input\n type=\"text\"\n value={newCollectionName}\n onChange={e => setNewCollectionName(e.target.value)}\n placeholder=\"Collection name\"\n className=\"graphiql-save-dialog-input\"\n />\n </label>\n )}\n </Dialog.Body>\n <Dialog.Footer>\n <Button type=\"button\" disabled={saving} onClick={closeSaveDialog}>\n Cancel\n </Button>\n <Button type=\"submit\" variant=\"primary\" disabled={saving}>\n {saving ? 'Saving…' : 'Save'}\n </Button>\n </Dialog.Footer>\n </form>\n </>\n );\n};\n"],"mappings":"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"}
|
|
@@ -5,5 +5,5 @@ type CollectionsSessionActionsProps = {
|
|
|
5
5
|
allowImportExport?: boolean;
|
|
6
6
|
allowReplace?: boolean;
|
|
7
7
|
};
|
|
8
|
-
export declare const CollectionsSessionActions: ({ storage, readOnly, allowImportExport, allowReplace, }: CollectionsSessionActionsProps) => import(
|
|
8
|
+
export declare const CollectionsSessionActions: ({ storage, readOnly, allowImportExport, allowReplace, }: CollectionsSessionActionsProps) => import('react').JSX.Element;
|
|
9
9
|
export {};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { localStorageAdapter } from "../storage/local-storage.js";
|
|
2
1
|
import { collectionsStore } from "../store.js";
|
|
2
|
+
import { localStorageAdapter } from "../storage/local-storage.js";
|
|
3
3
|
import { SaveDialog } from "./save-dialog.js";
|
|
4
4
|
import { useEffect } from "react";
|
|
5
5
|
import { useGraphiQLActions } from "@graphiql/react";
|
|
6
6
|
import { jsx } from "react/jsx-runtime";
|
|
7
|
-
|
|
7
|
+
// src/components/session-actions.tsx
|
|
8
8
|
var CollectionsSessionActions = ({ storage, readOnly = false, allowImportExport = true, allowReplace = true }) => {
|
|
9
9
|
useEffect(() => {
|
|
10
10
|
collectionsStore.getState().actions.init(storage ?? localStorageAdapter, {
|
|
@@ -20,7 +20,6 @@ var CollectionsSessionActions = ({ storage, readOnly = false, allowImportExport
|
|
|
20
20
|
}, [readOnly, registerSaveHandler]);
|
|
21
21
|
return /* @__PURE__ */ jsx(SaveDialog, {});
|
|
22
22
|
};
|
|
23
|
-
//#endregion
|
|
24
23
|
export { CollectionsSessionActions };
|
|
25
24
|
|
|
26
25
|
//# sourceMappingURL=session-actions.js.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import "react";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
// src/icons/check.svg?react
|
|
4
|
+
var SvgCheck = ({ title, titleId, ...props }) => /* @__PURE__ */ jsxs("svg", {
|
|
5
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
6
|
+
fill: "none",
|
|
7
|
+
viewBox: "0 0 16 16",
|
|
8
|
+
"aria-labelledby": titleId,
|
|
9
|
+
...props,
|
|
10
|
+
children: [title ? /* @__PURE__ */ jsx("title", {
|
|
11
|
+
id: titleId,
|
|
12
|
+
children: title
|
|
13
|
+
}) : null, /* @__PURE__ */ jsx("path", {
|
|
14
|
+
stroke: "currentColor",
|
|
15
|
+
strokeLinecap: "round",
|
|
16
|
+
strokeLinejoin: "round",
|
|
17
|
+
strokeWidth: 1.75,
|
|
18
|
+
d: "m3.5 8.5 3 3 6-7"
|
|
19
|
+
})]
|
|
20
|
+
});
|
|
21
|
+
export { SvgCheck as default };
|
|
22
|
+
|
|
23
|
+
//# sourceMappingURL=check.svg_react.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check.svg_react.js","names":[],"sources":["../../src/icons/check.svg?react"],"sourcesContent":["import * as React from \"react\";\nimport { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nconst SvgCheck = ({ title, titleId, ...props }) => /* @__PURE__ */ _jsxs(\"svg\", {\n\txmlns: \"http://www.w3.org/2000/svg\",\n\tfill: \"none\",\n\tviewBox: \"0 0 16 16\",\n\t\"aria-labelledby\": titleId,\n\t...props,\n\tchildren: [title ? /* @__PURE__ */ _jsx(\"title\", {\n\t\tid: titleId,\n\t\tchildren: title\n\t}) : null, /* @__PURE__ */ _jsx(\"path\", {\n\t\tstroke: \"currentColor\",\n\t\tstrokeLinecap: \"round\",\n\t\tstrokeLinejoin: \"round\",\n\t\tstrokeWidth: 1.75,\n\t\td: \"m3.5 8.5 3 3 6-7\"\n\t})]\n});\nexport default SvgCheck;\n"],"mappings":";;;AAEA,IAAM,YAAY,EAAE,OAAO,SAAS,GAAG,YAA4B,qBAAM,OAAO;CAC/E,OAAO;CACP,MAAM;CACN,SAAS;CACT,mBAAmB;CACnB,GAAG;CACH,UAAU,CAAC,QAAwB,oBAAK,SAAS;EAChD,IAAI;EACJ,UAAU;CACX,CAAC,IAAI,MAAsB,oBAAK,QAAQ;EACvC,QAAQ;EACR,eAAe;EACf,gBAAgB;EAChB,aAAa;EACb,GAAG;CACJ,CAAC,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import "react";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
// src/icons/collections.svg?react
|
|
4
|
+
var SvgCollections = ({ title, titleId, ...props }) => /* @__PURE__ */ jsxs("svg", {
|
|
5
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
6
|
+
fill: "none",
|
|
7
|
+
stroke: "currentColor",
|
|
8
|
+
strokeLinecap: "round",
|
|
9
|
+
strokeLinejoin: "round",
|
|
10
|
+
strokeWidth: 2,
|
|
11
|
+
viewBox: "0 0 24 24",
|
|
12
|
+
"aria-labelledby": titleId,
|
|
13
|
+
...props,
|
|
14
|
+
children: [title ? /* @__PURE__ */ jsx("title", {
|
|
15
|
+
id: titleId,
|
|
16
|
+
children: title
|
|
17
|
+
}) : null, /* @__PURE__ */ jsx("path", { d: "M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z" })]
|
|
18
|
+
});
|
|
19
|
+
export { SvgCollections as default };
|
|
20
|
+
|
|
21
|
+
//# sourceMappingURL=collections.svg_react.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collections.svg_react.js","names":[],"sources":["../../src/icons/collections.svg?react"],"sourcesContent":["import * as React from \"react\";\nimport { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nconst SvgCollections = ({ title, titleId, ...props }) => /* @__PURE__ */ _jsxs(\"svg\", {\n\txmlns: \"http://www.w3.org/2000/svg\",\n\tfill: \"none\",\n\tstroke: \"currentColor\",\n\tstrokeLinecap: \"round\",\n\tstrokeLinejoin: \"round\",\n\tstrokeWidth: 2,\n\tviewBox: \"0 0 24 24\",\n\t\"aria-labelledby\": titleId,\n\t...props,\n\tchildren: [title ? /* @__PURE__ */ _jsx(\"title\", {\n\t\tid: titleId,\n\t\tchildren: title\n\t}) : null, /* @__PURE__ */ _jsx(\"path\", { d: \"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z\" })]\n});\nexport default SvgCollections;\n"],"mappings":";;;AAEA,IAAM,kBAAkB,EAAE,OAAO,SAAS,GAAG,YAA4B,qBAAM,OAAO;CACrF,OAAO;CACP,MAAM;CACN,QAAQ;CACR,eAAe;CACf,gBAAgB;CAChB,aAAa;CACb,SAAS;CACT,mBAAmB;CACnB,GAAG;CACH,UAAU,CAAC,QAAwB,oBAAK,SAAS;EAChD,IAAI;EACJ,UAAU;CACX,CAAC,IAAI,MAAsB,oBAAK,QAAQ,EAAE,GAAG,8EAA8E,CAAC,CAAC;AAC9H,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import "react";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
// src/icons/download.svg?react
|
|
4
|
+
var SvgDownload = ({ title, titleId, ...props }) => /* @__PURE__ */ jsxs("svg", {
|
|
5
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
6
|
+
fill: "none",
|
|
7
|
+
stroke: "currentColor",
|
|
8
|
+
strokeLinecap: "round",
|
|
9
|
+
strokeLinejoin: "round",
|
|
10
|
+
strokeWidth: 2,
|
|
11
|
+
viewBox: "0 0 24 24",
|
|
12
|
+
"aria-labelledby": titleId,
|
|
13
|
+
...props,
|
|
14
|
+
children: [title ? /* @__PURE__ */ jsx("title", {
|
|
15
|
+
id: titleId,
|
|
16
|
+
children: title
|
|
17
|
+
}) : null, /* @__PURE__ */ jsx("path", { d: "M12 3v11m-5-4 5 4 5-4M4 20h16" })]
|
|
18
|
+
});
|
|
19
|
+
export { SvgDownload as default };
|
|
20
|
+
|
|
21
|
+
//# sourceMappingURL=download.svg_react.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"download.svg_react.js","names":[],"sources":["../../src/icons/download.svg?react"],"sourcesContent":["import * as React from \"react\";\nimport { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nconst SvgDownload = ({ title, titleId, ...props }) => /* @__PURE__ */ _jsxs(\"svg\", {\n\txmlns: \"http://www.w3.org/2000/svg\",\n\tfill: \"none\",\n\tstroke: \"currentColor\",\n\tstrokeLinecap: \"round\",\n\tstrokeLinejoin: \"round\",\n\tstrokeWidth: 2,\n\tviewBox: \"0 0 24 24\",\n\t\"aria-labelledby\": titleId,\n\t...props,\n\tchildren: [title ? /* @__PURE__ */ _jsx(\"title\", {\n\t\tid: titleId,\n\t\tchildren: title\n\t}) : null, /* @__PURE__ */ _jsx(\"path\", { d: \"M12 3v11m-5-4 5 4 5-4M4 20h16\" })]\n});\nexport default SvgDownload;\n"],"mappings":";;;AAEA,IAAM,eAAe,EAAE,OAAO,SAAS,GAAG,YAA4B,qBAAM,OAAO;CAClF,OAAO;CACP,MAAM;CACN,QAAQ;CACR,eAAe;CACf,gBAAgB;CAChB,aAAa;CACb,SAAS;CACT,mBAAmB;CACnB,GAAG;CACH,UAAU,CAAC,QAAwB,oBAAK,SAAS;EAChD,IAAI;EACJ,UAAU;CACX,CAAC,IAAI,MAAsB,oBAAK,QAAQ,EAAE,GAAG,gCAAgC,CAAC,CAAC;AAChF,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import "react";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
// src/icons/upload.svg?react
|
|
4
|
+
var SvgUpload = ({ title, titleId, ...props }) => /* @__PURE__ */ jsxs("svg", {
|
|
5
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
6
|
+
fill: "none",
|
|
7
|
+
stroke: "currentColor",
|
|
8
|
+
strokeLinecap: "round",
|
|
9
|
+
strokeLinejoin: "round",
|
|
10
|
+
strokeWidth: 2,
|
|
11
|
+
viewBox: "0 0 24 24",
|
|
12
|
+
"aria-labelledby": titleId,
|
|
13
|
+
...props,
|
|
14
|
+
children: [title ? /* @__PURE__ */ jsx("title", {
|
|
15
|
+
id: titleId,
|
|
16
|
+
children: title
|
|
17
|
+
}) : null, /* @__PURE__ */ jsx("path", { d: "M12 21V10m-5 4 5-4 5 4M4 4h16" })]
|
|
18
|
+
});
|
|
19
|
+
export { SvgUpload as default };
|
|
20
|
+
|
|
21
|
+
//# sourceMappingURL=upload.svg_react.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upload.svg_react.js","names":[],"sources":["../../src/icons/upload.svg?react"],"sourcesContent":["import * as React from \"react\";\nimport { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nconst SvgUpload = ({ title, titleId, ...props }) => /* @__PURE__ */ _jsxs(\"svg\", {\n\txmlns: \"http://www.w3.org/2000/svg\",\n\tfill: \"none\",\n\tstroke: \"currentColor\",\n\tstrokeLinecap: \"round\",\n\tstrokeLinejoin: \"round\",\n\tstrokeWidth: 2,\n\tviewBox: \"0 0 24 24\",\n\t\"aria-labelledby\": titleId,\n\t...props,\n\tchildren: [title ? /* @__PURE__ */ _jsx(\"title\", {\n\t\tid: titleId,\n\t\tchildren: title\n\t}) : null, /* @__PURE__ */ _jsx(\"path\", { d: \"M12 21V10m-5 4 5-4 5 4M4 4h16\" })]\n});\nexport default SvgUpload;\n"],"mappings":";;;AAEA,IAAM,aAAa,EAAE,OAAO,SAAS,GAAG,YAA4B,qBAAM,OAAO;CAChF,OAAO;CACP,MAAM;CACN,QAAQ;CACR,eAAe;CACf,gBAAgB;CAChB,aAAa;CACb,SAAS;CACT,mBAAmB;CACnB,GAAG;CACH,UAAU,CAAC,QAAwB,oBAAK,SAAS;EAChD,IAAI;EACJ,UAAU;CACX,CAAC,IAAI,MAAsB,oBAAK,QAAQ,EAAE,GAAG,gCAAgC,CAAC,CAAC;AAChF,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { createLocalStorageAdapter, localStorageAdapter } from "./storage/local-storage.js";
|
|
2
|
-
import { collectionsStore, useCollectionsStore } from "./store.js";
|
|
3
1
|
import { CollectionsPanel } from "./components/collections-panel.js";
|
|
4
|
-
import { SaveDialog } from "./components/save-dialog.js";
|
|
5
2
|
import { CollectionsSessionActions } from "./components/session-actions.js";
|
|
6
|
-
import SvgCollections from "./icons/collections.js";
|
|
3
|
+
import SvgCollections from "./icons/collections.svg_react.js";
|
|
7
4
|
/* empty css */
|
|
5
|
+
import { collectionsStore, useCollectionsStore } from "./store.js";
|
|
6
|
+
import { createLocalStorageAdapter, localStorageAdapter } from "./storage/local-storage.js";
|
|
7
|
+
import { SaveDialog } from "./components/save-dialog.js";
|
|
8
8
|
import { jsx } from "react/jsx-runtime";
|
|
9
|
-
|
|
9
|
+
// src/index.tsx
|
|
10
10
|
var collectionsPlugin = (options) => {
|
|
11
11
|
function CollectionsPanelWithOptions() {
|
|
12
12
|
return /* @__PURE__ */ jsx(CollectionsPanel, {
|
|
@@ -31,7 +31,6 @@ var collectionsPlugin = (options) => {
|
|
|
31
31
|
};
|
|
32
32
|
};
|
|
33
33
|
var COLLECTIONS_PLUGIN = collectionsPlugin();
|
|
34
|
-
//#endregion
|
|
35
34
|
export { COLLECTIONS_PLUGIN, SaveDialog as CollectionsSaveDialog, collectionsPlugin, collectionsStore, createLocalStorageAdapter, localStorageAdapter, useCollectionsStore };
|
|
36
35
|
|
|
37
36
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/index.tsx"],"sourcesContent":["import type { GraphiQLPlugin } from '@graphiql/react';\nimport { CollectionsPanel } from './components/collections-panel';\nimport { CollectionsSessionActions } from './components/session-actions';\nimport CollectionsIcon from './icons/collections.svg?react';\nimport type { CollectionsStorage } from './types';\nimport './index.css';\n\nexport type {\n CollectionsStorage,\n CollectionsConfig,\n Collection,\n CollectionItem,\n} from './types';\nexport {\n collectionsStore,\n useCollectionsStore,\n type ActiveOperation,\n} from './store';\nexport {\n createLocalStorageAdapter,\n localStorageAdapter,\n} from './storage/local-storage';\nexport { SaveDialog as CollectionsSaveDialog } from './components/save-dialog';\n\nexport type CollectionsPluginOptions = {\n /** Custom storage adapter. Defaults to localStorage with key 'graphiql:collections'. */\n storage?: CollectionsStorage;\n /** Disable all write operations (export & copy still allowed). Default false. */\n readOnly?: boolean;\n /** Master switch for the import/export feature. Default true. */\n allowImportExport?: boolean;\n /** Allow the destructive \"Replace\" import option. Default true. */\n allowReplace?: boolean;\n};\n\nexport const collectionsPlugin = (\n options?: CollectionsPluginOptions,\n): GraphiQLPlugin => {\n function CollectionsPanelWithOptions() {\n return (\n <CollectionsPanel\n readOnly={options?.readOnly}\n allowImportExport={options?.allowImportExport}\n allowReplace={options?.allowReplace}\n />\n );\n }\n function CollectionsSessionActionsWithOptions() {\n return (\n <CollectionsSessionActions\n storage={options?.storage}\n readOnly={options?.readOnly}\n allowImportExport={options?.allowImportExport}\n allowReplace={options?.allowReplace}\n />\n );\n }\n return {\n title: 'Collections',\n icon: CollectionsIcon,\n content: CollectionsPanelWithOptions,\n sessionActions: CollectionsSessionActionsWithOptions,\n };\n};\n\nexport const COLLECTIONS_PLUGIN = collectionsPlugin();\n"],"mappings":";;;;;;;;;AAmCA,IAAa,qBACX,YACmB;CACnB,SAAS,8BAA8B;EACrC,OACE,oBAAC,kBAAD;GACE,UAAU,SAAS;GACnB,mBAAmB,SAAS;GAC5B,cAAc,SAAS;EACxB,CAAA;CAEL;CACA,SAAS,uCAAuC;EAC9C,OACE,oBAAC,2BAAD;GACE,SAAS,SAAS;GAClB,UAAU,SAAS;GACnB,mBAAmB,SAAS;GAC5B,cAAc,SAAS;EACxB,CAAA;CAEL;CACA,OAAO;EACL,OAAO;EACP,
|
|
1
|
+
{"version":3,"file":"index.js","names":["CollectionsIcon"],"sources":["../src/index.tsx"],"sourcesContent":["import type { GraphiQLPlugin } from '@graphiql/react';\nimport { CollectionsPanel } from './components/collections-panel';\nimport { CollectionsSessionActions } from './components/session-actions';\nimport CollectionsIcon from './icons/collections.svg?react';\nimport type { CollectionsStorage } from './types';\nimport './index.css';\n\nexport type {\n CollectionsStorage,\n CollectionsConfig,\n Collection,\n CollectionItem,\n} from './types';\nexport {\n collectionsStore,\n useCollectionsStore,\n type ActiveOperation,\n} from './store';\nexport {\n createLocalStorageAdapter,\n localStorageAdapter,\n} from './storage/local-storage';\nexport { SaveDialog as CollectionsSaveDialog } from './components/save-dialog';\n\nexport type CollectionsPluginOptions = {\n /** Custom storage adapter. Defaults to localStorage with key 'graphiql:collections'. */\n storage?: CollectionsStorage;\n /** Disable all write operations (export & copy still allowed). Default false. */\n readOnly?: boolean;\n /** Master switch for the import/export feature. Default true. */\n allowImportExport?: boolean;\n /** Allow the destructive \"Replace\" import option. Default true. */\n allowReplace?: boolean;\n};\n\nexport const collectionsPlugin = (\n options?: CollectionsPluginOptions,\n): GraphiQLPlugin => {\n function CollectionsPanelWithOptions() {\n return (\n <CollectionsPanel\n readOnly={options?.readOnly}\n allowImportExport={options?.allowImportExport}\n allowReplace={options?.allowReplace}\n />\n );\n }\n function CollectionsSessionActionsWithOptions() {\n return (\n <CollectionsSessionActions\n storage={options?.storage}\n readOnly={options?.readOnly}\n allowImportExport={options?.allowImportExport}\n allowReplace={options?.allowReplace}\n />\n );\n }\n return {\n title: 'Collections',\n icon: CollectionsIcon,\n content: CollectionsPanelWithOptions,\n sessionActions: CollectionsSessionActionsWithOptions,\n };\n};\n\nexport const COLLECTIONS_PLUGIN = collectionsPlugin();\n"],"mappings":";;;;;;;;;AAmCA,IAAa,qBACX,YACmB;CACnB,SAAS,8BAA8B;EACrC,OACE,oBAAC,kBAAD;GACE,UAAU,SAAS;GACnB,mBAAmB,SAAS;GAC5B,cAAc,SAAS;EACxB,CAAA;CAEL;CACA,SAAS,uCAAuC;EAC9C,OACE,oBAAC,2BAAD;GACE,SAAS,SAAS;GAClB,UAAU,SAAS;GACnB,mBAAmB,SAAS;GAC5B,cAAc,SAAS;EACxB,CAAA;CAEL;CACA,OAAO;EACL,OAAO;EACP,MAAMA;EACN,SAAS;EACT,gBAAgB;CAClB;AACF;AAEA,IAAa,qBAAqB,kBAAkB"}
|
package/dist/operation-method.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Kind, parse } from "graphql";
|
|
2
|
-
|
|
2
|
+
// src/operation-method.ts
|
|
3
3
|
/** Cheap regex fallback for when a document can't be parsed. */
|
|
4
4
|
function inferOperationType(query) {
|
|
5
5
|
const keyword = /^\s*(query|mutation|subscription)/i.exec(query)?.[1]?.toLowerCase();
|
|
@@ -22,7 +22,6 @@ function getDocumentMethod(query) {
|
|
|
22
22
|
return inferOperationType(query);
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
|
-
//#endregion
|
|
26
25
|
export { getDocumentMethod };
|
|
27
26
|
|
|
28
27
|
//# sourceMappingURL=operation-method.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/storage/local-storage.ts
|
|
2
2
|
var DEFAULT_KEY = "graphiql:collections";
|
|
3
3
|
var VERSION = 1;
|
|
4
4
|
function createLocalStorageAdapter(storageKey = DEFAULT_KEY) {
|
|
@@ -28,7 +28,6 @@ function createLocalStorageAdapter(storageKey = DEFAULT_KEY) {
|
|
|
28
28
|
};
|
|
29
29
|
}
|
|
30
30
|
var localStorageAdapter = createLocalStorageAdapter();
|
|
31
|
-
//#endregion
|
|
32
31
|
export { createLocalStorageAdapter, localStorageAdapter };
|
|
33
32
|
|
|
34
33
|
//# sourceMappingURL=local-storage.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/storage/tab-links.ts
|
|
2
2
|
/**
|
|
3
3
|
* Tab↔item links are browser-local: they key off GraphiQL's own tab ids, which
|
|
4
4
|
* live in localStorage and are stable across reloads. They are deliberately
|
|
@@ -27,7 +27,6 @@ function saveTabLinks(links) {
|
|
|
27
27
|
localStorage.setItem(LINKS_KEY, JSON.stringify(links));
|
|
28
28
|
} catch {}
|
|
29
29
|
}
|
|
30
|
-
//#endregion
|
|
31
30
|
export { loadTabLinks, saveTabLinks };
|
|
32
31
|
|
|
33
32
|
//# sourceMappingURL=tab-links.js.map
|
package/dist/store.d.ts
CHANGED
|
@@ -3,6 +3,8 @@ import { TabLink } from './storage/tab-links';
|
|
|
3
3
|
/** The active operation being saved, as seen by the save dialog. */
|
|
4
4
|
export type SaveDialogState = {
|
|
5
5
|
open: boolean;
|
|
6
|
+
/** Identifies a fresh request, including operations with the same name. */
|
|
7
|
+
requestId?: number;
|
|
6
8
|
/** The tab this save originated from, linked to the item once saved. */
|
|
7
9
|
tabId?: string;
|
|
8
10
|
query: string;
|
|
@@ -68,7 +70,7 @@ type CollectionsActions = {
|
|
|
68
70
|
collectionId?: string;
|
|
69
71
|
newCollectionName?: string;
|
|
70
72
|
}): Promise<void>;
|
|
71
|
-
openSaveDialog(input: Omit<SaveDialogState, 'open'>): void;
|
|
73
|
+
openSaveDialog(input: Omit<SaveDialogState, 'open' | 'requestId'>): void;
|
|
72
74
|
closeSaveDialog(): void;
|
|
73
75
|
};
|
|
74
76
|
export declare function deriveOperationName(query: string, fallback?: string | null): string;
|
package/dist/store.js
CHANGED
|
@@ -5,9 +5,10 @@ import { loadTabLinks, saveTabLinks } from "./storage/tab-links.js";
|
|
|
5
5
|
import { createBoundedUseStore } from "@graphiql/react";
|
|
6
6
|
import { createStore } from "zustand";
|
|
7
7
|
import { z } from "zod";
|
|
8
|
-
|
|
8
|
+
// src/store.ts
|
|
9
9
|
var INITIAL_SAVE_DIALOG = {
|
|
10
10
|
open: false,
|
|
11
|
+
requestId: 0,
|
|
11
12
|
query: "",
|
|
12
13
|
variables: "",
|
|
13
14
|
headers: "",
|
|
@@ -445,10 +446,11 @@ var collectionsStore = createStore((set, get) => {
|
|
|
445
446
|
}
|
|
446
447
|
},
|
|
447
448
|
openSaveDialog(input) {
|
|
448
|
-
set({ saveDialog: {
|
|
449
|
+
set((s) => ({ saveDialog: {
|
|
449
450
|
...input,
|
|
450
|
-
open: true
|
|
451
|
-
|
|
451
|
+
open: true,
|
|
452
|
+
requestId: (s.saveDialog.requestId ?? 0) + 1
|
|
453
|
+
} }));
|
|
452
454
|
},
|
|
453
455
|
closeSaveDialog() {
|
|
454
456
|
if (committingDialog) return;
|
|
@@ -463,7 +465,6 @@ var collectionsStore = createStore((set, get) => {
|
|
|
463
465
|
};
|
|
464
466
|
});
|
|
465
467
|
var useCollectionsStore = createBoundedUseStore(collectionsStore);
|
|
466
|
-
//#endregion
|
|
467
468
|
export { collectionsStore, deriveOperationName, useCollectionsStore };
|
|
468
469
|
|
|
469
470
|
//# sourceMappingURL=store.js.map
|