@graphiql/plugin-collections 1.0.0 → 1.0.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 (37) hide show
  1. package/dist/components/collection-item-row.js +7 -8
  2. package/dist/components/collection-item-row.js.map +1 -1
  3. package/dist/components/collection-row.js +20 -18
  4. package/dist/components/collection-row.js.map +1 -1
  5. package/dist/components/collections-panel.js +8 -7
  6. package/dist/components/collections-panel.js.map +1 -1
  7. package/dist/components/conflict-dialog.js +2 -3
  8. package/dist/components/conflict-dialog.js.map +1 -1
  9. package/dist/components/export-dialog.js +4 -5
  10. package/dist/components/export-dialog.js.map +1 -1
  11. package/dist/components/import-dialog.js +5 -6
  12. package/dist/components/import-dialog.js.map +1 -1
  13. package/dist/components/save-dialog.js +82 -93
  14. package/dist/components/save-dialog.js.map +1 -1
  15. package/dist/components/session-actions.d.ts +1 -1
  16. package/dist/components/session-actions.js +4 -5
  17. package/dist/components/session-actions.js.map +1 -1
  18. package/dist/icons/check.js +1 -2
  19. package/dist/icons/check.js.map +1 -1
  20. package/dist/icons/collections.js +1 -2
  21. package/dist/icons/collections.js.map +1 -1
  22. package/dist/icons/download.js +1 -2
  23. package/dist/icons/download.js.map +1 -1
  24. package/dist/icons/upload.js +1 -2
  25. package/dist/icons/upload.js.map +1 -1
  26. package/dist/index.js +4 -5
  27. package/dist/index.js.map +1 -1
  28. package/dist/operation-method.js +1 -2
  29. package/dist/storage/local-storage.js +1 -2
  30. package/dist/storage/tab-links.js +1 -2
  31. package/dist/store.d.ts +3 -1
  32. package/dist/store.js +9 -8
  33. package/dist/store.js.map +1 -1
  34. package/dist/style.css +11 -49
  35. package/dist/types.js +1 -2
  36. package/dist/utility/uuid.js +1 -2
  37. package/package.json +12 -12
@@ -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.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
+ {"version":3,"file":"import-dialog.js","names":["_jsxs","_jsx"],"sources":["../../src/components/import-dialog.tsx"],"sourcesContent":["import { FC, useRef, useState } from 'react';\nimport { Button, Dialog, Textarea } 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 monospace\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,OACEA,qBAAC,QAAD;EAAc;EAAM,eAAc,MAAK,CAAC,KAAK,QAAQ;EAArD,UAAA;GACEC,oBAAC,OAAO,QAAR,EAAA,UAAe,qBAAiC,CAAA;GAChDA,oBAAC,OAAO,aAAR;IAAoB,WAAU;IAAmB,UAAA;GAE7B,CAAA;GACpBA,oBAAC,OAAO,MAAR,EAAA,UACED,qBAAC,OAAD;IAAK,WAAU;IAAf,UAAA;KACEC,oBAAC,UAAD;MACE,WAAA;MACA,MAAM;MACN,cAAW;MACX,aAAY;MACZ,OAAO;MACP,WAAU,MAAK;OACb,cAAc,EAAE,OAAO,KAAK;OAC5B,eAAe,IAAI;MACrB;KACD,CAAA;KACDA,oBAAC,SAAD;MACE,KAAK;MACL,MAAK;MACL,QAAO;MACP,gBAAgB,eAAe,IAAI;KACpC,CAAA;KACDD,qBAAC,YAAD;MAAU,WAAU;MAApB,UAAA;OACEC,oBAAC,UAAD,EAAA,UAAQ,cAAmB,CAAA;OAC3BD,qBAAC,SAAD,EAAA,UAAA,CACEC,oBAAC,SAAD;QACE,MAAK;QACL,MAAK;QACL,OAAM;QACN,SAAS,CAAC,gBAAgB,eAAe;QACzC,gBAAgB,cAAc,OAAO;OACtC,CAAA,GAAC,0CAEG,EAAA,CAAA;OACN,gBACCD,qBAAC,SAAD,EAAA,UAAA,CACEC,oBAAC,SAAD;QACE,MAAK;QACL,MAAK;QACL,OAAM;QACN,SAAS,eAAe;QACxB,gBAAgB,cAAc,SAAS;OACxC,CAAA,GAAC,2CAEG,EAAA,CAAA;MAED;;KACT,eACCA,oBAAC,KAAD;MAAG,WAAU;MAAgC,UAAA;KAAe,CAAA;KAE9DA,oBAAC,QAAD;MAAQ,MAAK;MAAS,SAAQ;MAAU,SAAS;MAAc,UAAA;KAEvD,CAAA;IACL;GACM,CAAA,EAAA,CAAA;EACP;;AAEZ"}
@@ -1,8 +1,8 @@
1
+ import { useState } from "react";
2
+ import { Button, Dialog, Input, Select } from "@graphiql/react";
1
3
  import { collectionsStore, useCollectionsStore } from "../store.js";
2
- import { useEffect, useState } from "react";
3
- import { Button, Dialog } from "@graphiql/react";
4
- import { jsx, jsxs } from "react/jsx-runtime";
5
- //#region src/components/save-dialog.tsx
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 actions = useCollectionsStore((s) => s.actions);
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,83 +39,74 @@ var SaveDialog = () => {
41
39
  setSaving(false);
42
40
  }
43
41
  };
44
- return /* @__PURE__ */ jsxs(Dialog, {
45
- open,
46
- onOpenChange: (o) => !o && actions.closeSaveDialog(),
47
- children: [
48
- /* @__PURE__ */ jsx(Dialog.Header, { children: "Save to collection" }),
49
- /* @__PURE__ */ jsx(Dialog.Description, {
50
- className: "graphiql-sr-only",
51
- children: "Save the current operation to a collection."
52
- }),
53
- /* @__PURE__ */ jsxs("form", {
54
- onSubmit: (e) => {
55
- e.preventDefault();
56
- handleSave();
57
- },
58
- children: [/* @__PURE__ */ jsxs(Dialog.Body, { children: [
59
- /* @__PURE__ */ jsxs("label", {
60
- className: "graphiql-save-dialog-field",
61
- children: [/* @__PURE__ */ jsx("span", { children: "Operation name" }), /* @__PURE__ */ jsx("input", {
62
- type: "text",
63
- value: name,
64
- onChange: (e) => setName(e.target.value),
65
- placeholder: "Unnamed operation",
66
- className: "graphiql-save-dialog-input",
67
- autoFocus: true
68
- })]
69
- }),
70
- /* @__PURE__ */ jsxs("label", {
71
- className: "graphiql-save-dialog-field",
72
- children: [/* @__PURE__ */ jsx("span", { children: "Description" }), /* @__PURE__ */ jsx("input", {
73
- type: "text",
74
- value: description,
75
- onChange: (e) => setDescription(e.target.value),
76
- placeholder: "Description (optional)",
77
- className: "graphiql-save-dialog-input"
78
- })]
79
- }),
80
- /* @__PURE__ */ jsxs("label", {
81
- className: "graphiql-save-dialog-field",
82
- children: [/* @__PURE__ */ jsx("span", { children: "Collection" }), /* @__PURE__ */ jsxs("select", {
83
- value: selectedCollectionId,
84
- onChange: (e) => setSelectedCollectionId(e.target.value),
85
- className: "graphiql-save-dialog-select",
86
- children: [/* @__PURE__ */ jsx("option", {
87
- value: NEW_COLLECTION,
88
- children: "+ New collection"
89
- }), collections.map((c) => /* @__PURE__ */ jsx("option", {
90
- value: c.id,
91
- children: c.name
92
- }, c.id))]
93
- })]
94
- }),
95
- selectedCollectionId === NEW_COLLECTION && /* @__PURE__ */ jsxs("label", {
96
- className: "graphiql-save-dialog-field",
97
- children: [/* @__PURE__ */ jsx("span", { children: "Collection name" }), /* @__PURE__ */ jsx("input", {
98
- type: "text",
99
- value: newCollectionName,
100
- onChange: (e) => setNewCollectionName(e.target.value),
101
- placeholder: "Collection name",
102
- className: "graphiql-save-dialog-input"
103
- })]
104
- })
105
- ] }), /* @__PURE__ */ jsxs(Dialog.Footer, { children: [/* @__PURE__ */ jsx(Button, {
106
- type: "button",
107
- disabled: saving,
108
- onClick: () => actions.closeSaveDialog(),
109
- children: "Cancel"
110
- }), /* @__PURE__ */ jsx(Button, {
111
- type: "submit",
112
- variant: "primary",
113
- disabled: saving,
114
- children: saving ? "Saving…" : "Save"
115
- })] })]
116
- })
117
- ]
118
- });
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", {
49
+ onSubmit: (e) => {
50
+ e.preventDefault();
51
+ handleSave();
52
+ },
53
+ children: [/* @__PURE__ */ jsxs(Dialog.Body, { children: [
54
+ /* @__PURE__ */ jsxs("label", {
55
+ className: "graphiql-save-dialog-field",
56
+ children: [/* @__PURE__ */ jsx("span", { children: "Operation name" }), /* @__PURE__ */ jsx(Input, {
57
+ type: "text",
58
+ value: name,
59
+ onChange: (e) => setName(e.target.value),
60
+ placeholder: "Unnamed operation",
61
+ autoFocus: true
62
+ })]
63
+ }),
64
+ /* @__PURE__ */ jsxs("label", {
65
+ className: "graphiql-save-dialog-field",
66
+ children: [/* @__PURE__ */ jsx("span", { children: "Description" }), /* @__PURE__ */ jsx(Input, {
67
+ type: "text",
68
+ value: description,
69
+ onChange: (e) => setDescription(e.target.value),
70
+ placeholder: "Description (optional)"
71
+ })]
72
+ }),
73
+ /* @__PURE__ */ jsxs("label", {
74
+ className: "graphiql-save-dialog-field",
75
+ children: [/* @__PURE__ */ jsx("span", { children: "Collection" }), /* @__PURE__ */ jsxs(Select, {
76
+ value: selectedCollectionId,
77
+ onChange: (e) => setSelectedCollectionId(e.target.value),
78
+ children: [/* @__PURE__ */ jsx("option", {
79
+ value: NEW_COLLECTION,
80
+ children: "+ New collection"
81
+ }), collections.map((c) => /* @__PURE__ */ jsx("option", {
82
+ value: c.id,
83
+ children: c.name
84
+ }, c.id))]
85
+ })]
86
+ }),
87
+ selectedCollectionId === NEW_COLLECTION && /* @__PURE__ */ jsxs("label", {
88
+ className: "graphiql-save-dialog-field",
89
+ children: [/* @__PURE__ */ jsx("span", { children: "Collection name" }), /* @__PURE__ */ jsx(Input, {
90
+ type: "text",
91
+ value: newCollectionName,
92
+ onChange: (e) => setNewCollectionName(e.target.value),
93
+ placeholder: "Collection name"
94
+ })]
95
+ })
96
+ ] }), /* @__PURE__ */ jsxs(Dialog.Footer, { children: [/* @__PURE__ */ jsx(Button, {
97
+ type: "button",
98
+ disabled: saving,
99
+ onClick: closeSaveDialog,
100
+ children: "Cancel"
101
+ }), /* @__PURE__ */ jsx(Button, {
102
+ type: "submit",
103
+ variant: "primary",
104
+ disabled: saving,
105
+ children: saving ? "Saving…" : "Save"
106
+ })] })]
107
+ })
108
+ ] });
119
109
  };
120
- //#endregion
121
110
  export { SaveDialog };
122
111
 
123
112
  //# sourceMappingURL=save-dialog.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"save-dialog.js","names":[],"sources":["../../src/components/save-dialog.tsx"],"sourcesContent":["import { FC, useEffect, 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 collections = useCollectionsStore(s => s.collections);\n const actions = useCollectionsStore(s => s.actions);\n const { open, name: initialName } = useCollectionsStore(s => s.saveDialog);\n const [saving, setSaving] = useState(false);\n\n const [name, setName] = useState(initialName);\n const [description, setDescription] = useState('');\n const [selectedCollectionId, setSelectedCollectionId] =\n useState<string>(NEW_COLLECTION);\n const [newCollectionName, setNewCollectionName] = useState('New Collection');\n\n // Reset the form each time the dialog opens with a fresh operation.\n useEffect(() => {\n if (open) {\n const { collections: current } = collectionsStore.getState();\n setName(initialName);\n setDescription('');\n setSelectedCollectionId(current[0]?.id ?? NEW_COLLECTION);\n setNewCollectionName('New Collection');\n setSaving(false);\n }\n }, [open, initialName]);\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 <Dialog open={open} onOpenChange={o => !o && actions.closeSaveDialog()}>\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\n type=\"button\"\n disabled={saving}\n onClick={() => actions.closeSaveDialog()}\n >\n Cancel\n </Button>\n <Button type=\"submit\" variant=\"primary\" disabled={saving}>\n {saving ? 'Saving…' : 'Save'}\n </Button>\n </Dialog.Footer>\n </form>\n </Dialog>\n );\n};\n"],"mappings":"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"}
1
+ {"version":3,"file":"save-dialog.js","names":["_jsx","_jsxs","_Fragment"],"sources":["../../src/components/save-dialog.tsx"],"sourcesContent":["import { FC, useState } from 'react';\nimport { Button, Dialog, Input, Select } 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 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 />\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 >\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 />\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":";;;;;AAIA,IAAM,iBAAiB;;;;;;AAOvB,IAAa,mBAAuB;CAClC,MAAM,EAAE,MAAM,MAAM,cAAc,qBAAoB,MAAK,EAAE,UAAU;CACvE,MAAM,kBAAkB,qBAAoB,MAAK,EAAE,QAAQ,eAAe;CAE1E,OACEA,oBAAC,QAAD;EAAc;EAAM,eAAc,MAAK,CAAC,KAAK,gBAAgB;EAC1D,UAAA,QAAQA,oBAAC,gBAAD,EAAgC,aAAa,KAAO,GAA/B,SAA+B;CACvD,CAAA;AAEZ;AAEA,IAAM,kBAA+C,EAAE,kBAAkB;CACvE,MAAM,cAAc,qBAAoB,MAAK,EAAE,WAAW;CAC1D,MAAM,kBAAkB,qBAAoB,MAAK,EAAE,QAAQ,eAAe;CAC1E,MAAM,CAAC,QAAQ,aAAa,SAAS,KAAK;CAC1C,MAAM,CAAC,MAAM,WAAW,SAAS,WAAW;CAC5C,MAAM,CAAC,aAAa,kBAAkB,SAAS,EAAE;CACjD,MAAM,CAAC,sBAAsB,2BAA2B,eAChD,YAAY,EAAE,EAAE,MAAM,cAC9B;CACA,MAAM,CAAC,mBAAmB,wBAAwB,SAAS,gBAAgB;CAE3E,MAAM,aAAa,YAAY;EAC7B,UAAU,IAAI;EACd,IAAI;GACF,MAAM,iBAAiB,SAAS,CAAC,CAAC,QAAQ,iBAAiB;IACzD,MAAM,QAAQ;IACd,aAAa,eAAe,KAAA;IAC5B,cACE,yBAAyB,iBACrB,KAAA,IACA;IACN;GACF,CAAC;EACH,QAAQ,CAER,UAAU;GACR,UAAU,KAAK;EACjB;CACF;CAEA,OACEC,qBAAAC,UAAA,EAAA,UAAA;EACEF,oBAAC,OAAO,QAAR,EAAA,UAAe,qBAAiC,CAAA;EAChDA,oBAAC,OAAO,aAAR;GAAoB,WAAU;GAAmB,UAAA;EAE7B,CAAA;EACpBC,qBAAC,QAAD;GACE,WAAU,MAAK;IACb,EAAE,eAAe;IACZ,WAAW;GAClB;GAJF,UAAA,CAMEA,qBAAC,OAAO,MAAR,EAAA,UAAA;IACEA,qBAAC,SAAD;KAAO,WAAU;KAAjB,UAAA,CACED,oBAAC,QAAD,EAAA,UAAM,iBAAoB,CAAA,GAC1BA,oBAAC,OAAD;MACE,MAAK;MACL,OAAO;MACP,WAAU,MAAK,QAAQ,EAAE,OAAO,KAAK;MACrC,aAAY;MACZ,WAAA;KACD,CAAA,CACI;;IACPC,qBAAC,SAAD;KAAO,WAAU;KAAjB,UAAA,CACED,oBAAC,QAAD,EAAA,UAAM,cAAiB,CAAA,GACvBA,oBAAC,OAAD;MACE,MAAK;MACL,OAAO;MACP,WAAU,MAAK,eAAe,EAAE,OAAO,KAAK;MAC5C,aAAY;KACb,CAAA,CACI;;IACPC,qBAAC,SAAD;KAAO,WAAU;KAAjB,UAAA,CACED,oBAAC,QAAD,EAAA,UAAM,aAAgB,CAAA,GACtBC,qBAAC,QAAD;MACE,OAAO;MACP,WAAU,MAAK,wBAAwB,EAAE,OAAO,KAAK;MAFvD,UAAA,CAIED,oBAAC,UAAD;OAAQ,OAAO;OAAgB,UAAA;MAAwB,CAAA,GACtD,YAAY,KAAI,MACfA,oBAAC,UAAD;OAAmB,OAAO,EAAE;OACzB,UAAA,EAAE;MACG,GAFK,EAAE,EAEP,CACT,CACK;KACH,CAAA,CAAA;;IACN,yBAAyB,kBACxBC,qBAAC,SAAD;KAAO,WAAU;KAAjB,UAAA,CACED,oBAAC,QAAD,EAAA,UAAM,kBAAqB,CAAA,GAC3BA,oBAAC,OAAD;MACE,MAAK;MACL,OAAO;MACP,WAAU,MAAK,qBAAqB,EAAE,OAAO,KAAK;MAClD,aAAY;KACb,CAAA,CACI;;GAEE,EAAA,CAAA,GACbC,qBAAC,OAAO,QAAR,EAAA,UAAA,CACED,oBAAC,QAAD;IAAQ,MAAK;IAAS,UAAU;IAAQ,SAAS;IAAiB,UAAA;GAE1D,CAAA,GACRA,oBAAC,QAAD;IAAQ,MAAK;IAAS,SAAQ;IAAU,UAAU;IAC/C,UAAA,SAAS,YAAY;GAChB,CAAA,CACK,EAAA,CAAA,CACX;;CACN,EAAA,CAAA;AAEN"}
@@ -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("react/jsx-runtime").JSX.Element;
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
- import { collectionsStore } from "../store.js";
3
- import { SaveDialog } from "./save-dialog.js";
4
1
  import { useEffect } from "react";
5
2
  import { useGraphiQLActions } from "@graphiql/react";
3
+ import { collectionsStore } from "../store.js";
4
+ import { localStorageAdapter } from "../storage/local-storage.js";
5
+ import { SaveDialog } from "./save-dialog.js";
6
6
  import { jsx } from "react/jsx-runtime";
7
- //#region src/components/session-actions.tsx
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
@@ -1 +1 @@
1
- {"version":3,"file":"session-actions.js","names":[],"sources":["../../src/components/session-actions.tsx"],"sourcesContent":["import { useEffect } from 'react';\nimport { useGraphiQLActions } from '@graphiql/react';\nimport { collectionsStore } from '../store';\nimport { localStorageAdapter } from '../storage/local-storage';\nimport { SaveDialog } from './save-dialog';\nimport type { CollectionsStorage } from '../types';\n\ntype CollectionsSessionActionsProps = {\n storage?: CollectionsStorage;\n readOnly?: boolean;\n allowImportExport?: boolean;\n allowReplace?: boolean;\n};\n\nexport const CollectionsSessionActions = ({\n storage,\n readOnly = false,\n allowImportExport = true,\n allowReplace = true,\n}: CollectionsSessionActionsProps) => {\n useEffect(() => {\n void collectionsStore\n .getState()\n .actions.init(storage ?? localStorageAdapter, {\n readOnly,\n allowImportExport,\n allowReplace,\n });\n // storage/config are intentionally only read on mount\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n const { registerSaveHandler } = useGraphiQLActions();\n\n useEffect(() => {\n if (readOnly) {\n return;\n }\n return registerSaveHandler(tab =>\n collectionsStore.getState().actions.requestSave(tab),\n );\n }, [readOnly, registerSaveHandler]);\n\n return <SaveDialog />;\n};\n"],"mappings":";;;;;;;AAcA,IAAa,6BAA6B,EACxC,SACA,WAAW,OACX,oBAAoB,MACpB,eAAe,WACqB;CACpC,gBAAgB;EACd,iBACG,SAAS,CAAC,CACV,QAAQ,KAAK,WAAW,qBAAqB;GAC5C;GACA;GACA;EACF,CAAC;CAGL,GAAG,CAAC,CAAC;CAEL,MAAM,EAAE,wBAAwB,mBAAmB;CAEnD,gBAAgB;EACd,IAAI,UACF;EAEF,OAAO,qBAAoB,QACzB,iBAAiB,SAAS,CAAC,CAAC,QAAQ,YAAY,GAAG,CACrD;CACF,GAAG,CAAC,UAAU,mBAAmB,CAAC;CAElC,OAAO,oBAAC,YAAD,CAAa,CAAA;AACtB"}
1
+ {"version":3,"file":"session-actions.js","names":["_jsx"],"sources":["../../src/components/session-actions.tsx"],"sourcesContent":["import { useEffect } from 'react';\nimport { useGraphiQLActions } from '@graphiql/react';\nimport { collectionsStore } from '../store';\nimport { localStorageAdapter } from '../storage/local-storage';\nimport { SaveDialog } from './save-dialog';\nimport type { CollectionsStorage } from '../types';\n\ntype CollectionsSessionActionsProps = {\n storage?: CollectionsStorage;\n readOnly?: boolean;\n allowImportExport?: boolean;\n allowReplace?: boolean;\n};\n\nexport const CollectionsSessionActions = ({\n storage,\n readOnly = false,\n allowImportExport = true,\n allowReplace = true,\n}: CollectionsSessionActionsProps) => {\n useEffect(() => {\n void collectionsStore\n .getState()\n .actions.init(storage ?? localStorageAdapter, {\n readOnly,\n allowImportExport,\n allowReplace,\n });\n // storage/config are intentionally only read on mount\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n const { registerSaveHandler } = useGraphiQLActions();\n\n useEffect(() => {\n if (readOnly) {\n return;\n }\n return registerSaveHandler(tab =>\n collectionsStore.getState().actions.requestSave(tab),\n );\n }, [readOnly, registerSaveHandler]);\n\n return <SaveDialog />;\n};\n"],"mappings":";;;;;;;AAcA,IAAa,6BAA6B,EACxC,SACA,WAAW,OACX,oBAAoB,MACpB,eAAe,WACqB;CACpC,gBAAgB;EACT,iBACF,SAAS,CAAC,CACV,QAAQ,KAAK,WAAW,qBAAqB;GAC5C;GACA;GACA;EACF,CAAC;CAGL,GAAG,CAAC,CAAC;CAEL,MAAM,EAAE,wBAAwB,mBAAmB;CAEnD,gBAAgB;EACd,IAAI,UACF;EAEF,OAAO,qBAAoB,QACzB,iBAAiB,SAAS,CAAC,CAAC,QAAQ,YAAY,GAAG,CACrD;CACF,GAAG,CAAC,UAAU,mBAAmB,CAAC;CAElC,OAAOA,oBAAC,YAAD,CAAa,CAAA;AACtB"}
@@ -1,6 +1,6 @@
1
1
  import "react";
2
2
  import { jsx, jsxs } from "react/jsx-runtime";
3
- //#region src/icons/check.svg?react
3
+ // src/icons/check.svg?react
4
4
  var SvgCheck = ({ title, titleId, ...props }) => /* @__PURE__ */ jsxs("svg", {
5
5
  xmlns: "http://www.w3.org/2000/svg",
6
6
  fill: "none",
@@ -18,7 +18,6 @@ var SvgCheck = ({ title, titleId, ...props }) => /* @__PURE__ */ jsxs("svg", {
18
18
  d: "m3.5 8.5 3 3 6-7"
19
19
  })]
20
20
  });
21
- //#endregion
22
21
  export { SvgCheck as default };
23
22
 
24
23
  //# sourceMappingURL=check.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"check.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"}
1
+ {"version":3,"file":"check.js","names":["_jsxs","_jsx"],"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,YAA4BA,qBAAM,OAAO;CAC/E,OAAO;CACP,MAAM;CACN,SAAS;CACT,mBAAmB;CACnB,GAAG;CACH,UAAU,CAAC,QAAwBC,oBAAK,SAAS;EAChD,IAAI;EACJ,UAAU;CACX,CAAC,IAAI,MAAsBA,oBAAK,QAAQ;EACvC,QAAQ;EACR,eAAe;EACf,gBAAgB;EAChB,aAAa;EACb,GAAG;CACJ,CAAC,CAAC;AACH,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import "react";
2
2
  import { jsx, jsxs } from "react/jsx-runtime";
3
- //#region src/icons/collections.svg?react
3
+ // src/icons/collections.svg?react
4
4
  var SvgCollections = ({ title, titleId, ...props }) => /* @__PURE__ */ jsxs("svg", {
5
5
  xmlns: "http://www.w3.org/2000/svg",
6
6
  fill: "none",
@@ -16,7 +16,6 @@ var SvgCollections = ({ title, titleId, ...props }) => /* @__PURE__ */ jsxs("svg
16
16
  children: title
17
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
18
  });
19
- //#endregion
20
19
  export { SvgCollections as default };
21
20
 
22
21
  //# sourceMappingURL=collections.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"collections.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"}
1
+ {"version":3,"file":"collections.js","names":["_jsxs","_jsx"],"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,YAA4BA,qBAAM,OAAO;CACrF,OAAO;CACP,MAAM;CACN,QAAQ;CACR,eAAe;CACf,gBAAgB;CAChB,aAAa;CACb,SAAS;CACT,mBAAmB;CACnB,GAAG;CACH,UAAU,CAAC,QAAwBC,oBAAK,SAAS;EAChD,IAAI;EACJ,UAAU;CACX,CAAC,IAAI,MAAsBA,oBAAK,QAAQ,EAAE,GAAG,8EAA8E,CAAC,CAAC;AAC9H,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import "react";
2
2
  import { jsx, jsxs } from "react/jsx-runtime";
3
- //#region src/icons/download.svg?react
3
+ // src/icons/download.svg?react
4
4
  var SvgDownload = ({ title, titleId, ...props }) => /* @__PURE__ */ jsxs("svg", {
5
5
  xmlns: "http://www.w3.org/2000/svg",
6
6
  fill: "none",
@@ -16,7 +16,6 @@ var SvgDownload = ({ title, titleId, ...props }) => /* @__PURE__ */ jsxs("svg",
16
16
  children: title
17
17
  }) : null, /* @__PURE__ */ jsx("path", { d: "M12 3v11m-5-4 5 4 5-4M4 20h16" })]
18
18
  });
19
- //#endregion
20
19
  export { SvgDownload as default };
21
20
 
22
21
  //# sourceMappingURL=download.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"download.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"}
1
+ {"version":3,"file":"download.js","names":["_jsxs","_jsx"],"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,YAA4BA,qBAAM,OAAO;CAClF,OAAO;CACP,MAAM;CACN,QAAQ;CACR,eAAe;CACf,gBAAgB;CAChB,aAAa;CACb,SAAS;CACT,mBAAmB;CACnB,GAAG;CACH,UAAU,CAAC,QAAwBC,oBAAK,SAAS;EAChD,IAAI;EACJ,UAAU;CACX,CAAC,IAAI,MAAsBA,oBAAK,QAAQ,EAAE,GAAG,gCAAgC,CAAC,CAAC;AAChF,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import "react";
2
2
  import { jsx, jsxs } from "react/jsx-runtime";
3
- //#region src/icons/upload.svg?react
3
+ // src/icons/upload.svg?react
4
4
  var SvgUpload = ({ title, titleId, ...props }) => /* @__PURE__ */ jsxs("svg", {
5
5
  xmlns: "http://www.w3.org/2000/svg",
6
6
  fill: "none",
@@ -16,7 +16,6 @@ var SvgUpload = ({ title, titleId, ...props }) => /* @__PURE__ */ jsxs("svg", {
16
16
  children: title
17
17
  }) : null, /* @__PURE__ */ jsx("path", { d: "M12 21V10m-5 4 5-4 5 4M4 4h16" })]
18
18
  });
19
- //#endregion
20
19
  export { SvgUpload as default };
21
20
 
22
21
  //# sourceMappingURL=upload.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"upload.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"}
1
+ {"version":3,"file":"upload.js","names":["_jsxs","_jsx"],"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,YAA4BA,qBAAM,OAAO;CAChF,OAAO;CACP,MAAM;CACN,QAAQ;CACR,eAAe;CACf,gBAAgB;CAChB,aAAa;CACb,SAAS;CACT,mBAAmB;CACnB,GAAG;CACH,UAAU,CAAC,QAAwBC,oBAAK,SAAS;EAChD,IAAI;EACJ,UAAU;CACX,CAAC,IAAI,MAAsBA,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
3
  import SvgCollections from "./icons/collections.js";
7
4
  /* empty css */
8
5
  import { jsx } from "react/jsx-runtime";
9
- //#region src/index.tsx
6
+ import { collectionsStore, useCollectionsStore } from "./store.js";
7
+ import { createLocalStorageAdapter, localStorageAdapter } from "./storage/local-storage.js";
8
+ import { SaveDialog } from "./components/save-dialog.js";
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,MAAM;EACN,SAAS;EACT,gBAAgB;CAClB;AACF;AAEA,IAAa,qBAAqB,kBAAkB"}
1
+ {"version":3,"file":"index.js","names":["_jsx","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,OACEA,oBAAC,kBAAD;GACE,UAAU,SAAS;GACnB,mBAAmB,SAAS;GAC5B,cAAc,SAAS;EACxB,CAAA;CAEL;CACA,SAAS,uCAAuC;EAC9C,OACEA,oBAAC,2BAAD;GACE,SAAS,SAAS;GAClB,UAAU,SAAS;GACnB,mBAAmB,SAAS;GAC5B,cAAc,SAAS;EACxB,CAAA;CAEL;CACA,OAAO;EACL,OAAO;EACP,MAAMC;EACN,SAAS;EACT,gBAAgB;CAClB;AACF;AAEA,IAAa,qBAAqB,kBAAkB"}
@@ -1,5 +1,5 @@
1
1
  import { Kind, parse } from "graphql";
2
- //#region src/operation-method.ts
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
- //#region src/storage/local-storage.ts
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
- //#region src/storage/tab-links.ts
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
@@ -1,13 +1,14 @@
1
+ import { createStore } from "zustand";
2
+ import { createBoundedUseStore } from "@graphiql/react";
3
+ import { z } from "zod";
1
4
  import { randomId } from "./utility/uuid.js";
2
5
  import { DEFAULT_COLLECTIONS_CONFIG } from "./types.js";
3
6
  import { localStorageAdapter } from "./storage/local-storage.js";
4
7
  import { loadTabLinks, saveTabLinks } from "./storage/tab-links.js";
5
- import { createBoundedUseStore } from "@graphiql/react";
6
- import { createStore } from "zustand";
7
- import { z } from "zod";
8
- //#region src/store.ts
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