@graphiql/plugin-history 0.0.2 → 0.0.3-canary-ee3ef668.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components.js +134 -153
- package/dist/components.js.map +1 -1
- package/dist/context.d.ts +18 -33
- package/dist/context.js +106 -88
- package/dist/context.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
package/dist/components.js
CHANGED
|
@@ -2,27 +2,18 @@ import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
|
2
2
|
import { c } from "react-compiler-runtime";
|
|
3
3
|
import { useState, useEffect, useRef } from "react";
|
|
4
4
|
import { Button, useEditorContext, cn, UnStyledButton, CloseIcon, Tooltip, PenIcon, StarFilledIcon, StarIcon, TrashIcon } from "@graphiql/react";
|
|
5
|
-
import {
|
|
5
|
+
import { useHistory, useHistoryActions } from "./context.js";
|
|
6
6
|
function handleDelete(items, deleteFromHistory) {
|
|
7
7
|
for (const item of items) {
|
|
8
8
|
deleteFromHistory(item, true);
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
11
|
function History() {
|
|
12
|
-
const $ = c(
|
|
13
|
-
|
|
14
|
-
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
15
|
-
t0 = {
|
|
16
|
-
nonNull: true
|
|
17
|
-
};
|
|
18
|
-
$[0] = t0;
|
|
19
|
-
} else {
|
|
20
|
-
t0 = $[0];
|
|
21
|
-
}
|
|
12
|
+
const $ = c(13);
|
|
13
|
+
const all = useHistory();
|
|
22
14
|
const {
|
|
23
|
-
items: all,
|
|
24
15
|
deleteFromHistory
|
|
25
|
-
} =
|
|
16
|
+
} = useHistoryActions();
|
|
26
17
|
let items;
|
|
27
18
|
items = all.slice().map(_temp).reverse();
|
|
28
19
|
const favorites = items.filter(_temp2);
|
|
@@ -30,25 +21,25 @@ function History() {
|
|
|
30
21
|
items = items.filter(_temp3);
|
|
31
22
|
}
|
|
32
23
|
const [clearStatus, setClearStatus] = useState(null);
|
|
24
|
+
let t0;
|
|
33
25
|
let t1;
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
t1 = () => {
|
|
26
|
+
if ($[0] !== clearStatus) {
|
|
27
|
+
t0 = () => {
|
|
37
28
|
if (clearStatus) {
|
|
38
29
|
setTimeout(() => {
|
|
39
30
|
setClearStatus(null);
|
|
40
31
|
}, 2e3);
|
|
41
32
|
}
|
|
42
33
|
};
|
|
43
|
-
|
|
44
|
-
$[
|
|
34
|
+
t1 = [clearStatus];
|
|
35
|
+
$[0] = clearStatus;
|
|
36
|
+
$[1] = t0;
|
|
45
37
|
$[2] = t1;
|
|
46
|
-
$[3] = t2;
|
|
47
38
|
} else {
|
|
39
|
+
t0 = $[1];
|
|
48
40
|
t1 = $[2];
|
|
49
|
-
t2 = $[3];
|
|
50
41
|
}
|
|
51
|
-
useEffect(
|
|
42
|
+
useEffect(t0, t1);
|
|
52
43
|
const handleClearStatus = () => {
|
|
53
44
|
try {
|
|
54
45
|
handleDelete(items, deleteFromHistory);
|
|
@@ -59,51 +50,51 @@ function History() {
|
|
|
59
50
|
};
|
|
60
51
|
const hasFavorites = Boolean(favorites.length);
|
|
61
52
|
const hasItems = Boolean(items.length);
|
|
62
|
-
const
|
|
63
|
-
const
|
|
64
|
-
const
|
|
53
|
+
const t2 = "History";
|
|
54
|
+
const t3 = "graphiql-history";
|
|
55
|
+
const t4 = (clearStatus || hasItems) && /* @__PURE__ */ jsx(Button, { type: "button", state: clearStatus || void 0, disabled: !items.length, onClick: handleClearStatus, children: {
|
|
65
56
|
success: "Cleared",
|
|
66
57
|
error: "Failed to Clear"
|
|
67
58
|
}[clearStatus] || "Clear" });
|
|
68
|
-
let
|
|
69
|
-
if ($[
|
|
70
|
-
|
|
59
|
+
let t5;
|
|
60
|
+
if ($[3] !== t4) {
|
|
61
|
+
t5 = /* @__PURE__ */ jsxs("div", { className: "graphiql-history-header", children: [
|
|
71
62
|
"History",
|
|
72
|
-
|
|
63
|
+
t4
|
|
73
64
|
] });
|
|
65
|
+
$[3] = t4;
|
|
74
66
|
$[4] = t5;
|
|
75
|
-
$[5] = t6;
|
|
76
67
|
} else {
|
|
77
|
-
|
|
68
|
+
t5 = $[4];
|
|
78
69
|
}
|
|
79
|
-
const
|
|
80
|
-
let
|
|
81
|
-
if ($[
|
|
82
|
-
|
|
83
|
-
$[
|
|
84
|
-
$[
|
|
85
|
-
$[
|
|
70
|
+
const t6 = hasFavorites && /* @__PURE__ */ jsx("ul", { className: "graphiql-history-items", children: favorites.map(_temp4) });
|
|
71
|
+
let t7;
|
|
72
|
+
if ($[5] !== hasFavorites || $[6] !== hasItems) {
|
|
73
|
+
t7 = hasFavorites && hasItems && /* @__PURE__ */ jsx("div", { className: "graphiql-history-item-spacer" });
|
|
74
|
+
$[5] = hasFavorites;
|
|
75
|
+
$[6] = hasItems;
|
|
76
|
+
$[7] = t7;
|
|
86
77
|
} else {
|
|
87
|
-
|
|
78
|
+
t7 = $[7];
|
|
88
79
|
}
|
|
89
|
-
const
|
|
90
|
-
let
|
|
91
|
-
if ($[
|
|
92
|
-
|
|
80
|
+
const t8 = hasItems && /* @__PURE__ */ jsx("ul", { className: "graphiql-history-items", children: items.map(_temp5) });
|
|
81
|
+
let t9;
|
|
82
|
+
if ($[8] !== t5 || $[9] !== t6 || $[10] !== t7 || $[11] !== t8) {
|
|
83
|
+
t9 = /* @__PURE__ */ jsxs("section", { "aria-label": t2, className: t3, children: [
|
|
84
|
+
t5,
|
|
93
85
|
t6,
|
|
94
86
|
t7,
|
|
95
|
-
t8
|
|
96
|
-
t9
|
|
87
|
+
t8
|
|
97
88
|
] });
|
|
89
|
+
$[8] = t5;
|
|
98
90
|
$[9] = t6;
|
|
99
91
|
$[10] = t7;
|
|
100
92
|
$[11] = t8;
|
|
101
93
|
$[12] = t9;
|
|
102
|
-
$[13] = t10;
|
|
103
94
|
} else {
|
|
104
|
-
|
|
95
|
+
t9 = $[12];
|
|
105
96
|
}
|
|
106
|
-
return
|
|
97
|
+
return t9;
|
|
107
98
|
}
|
|
108
99
|
function _temp5(item_3) {
|
|
109
100
|
return /* @__PURE__ */ jsx(HistoryItem, { item: item_3 }, item_3.index);
|
|
@@ -124,73 +115,63 @@ function _temp(item, i) {
|
|
|
124
115
|
};
|
|
125
116
|
}
|
|
126
117
|
function HistoryItem(props) {
|
|
127
|
-
const $ = c(
|
|
128
|
-
let t0;
|
|
129
|
-
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
130
|
-
t0 = {
|
|
131
|
-
nonNull: true,
|
|
132
|
-
caller: HistoryItem
|
|
133
|
-
};
|
|
134
|
-
$[0] = t0;
|
|
135
|
-
} else {
|
|
136
|
-
t0 = $[0];
|
|
137
|
-
}
|
|
118
|
+
const $ = c(39);
|
|
138
119
|
const {
|
|
139
120
|
editLabel,
|
|
140
121
|
toggleFavorite,
|
|
141
122
|
deleteFromHistory,
|
|
142
123
|
setActive
|
|
143
|
-
} =
|
|
144
|
-
let
|
|
145
|
-
if ($[
|
|
146
|
-
|
|
124
|
+
} = useHistoryActions();
|
|
125
|
+
let t0;
|
|
126
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
127
|
+
t0 = {
|
|
147
128
|
nonNull: true,
|
|
148
129
|
caller: HistoryItem
|
|
149
130
|
};
|
|
150
|
-
$[
|
|
131
|
+
$[0] = t0;
|
|
151
132
|
} else {
|
|
152
|
-
|
|
133
|
+
t0 = $[0];
|
|
153
134
|
}
|
|
154
135
|
const {
|
|
155
136
|
headerEditor,
|
|
156
137
|
queryEditor,
|
|
157
138
|
variableEditor
|
|
158
|
-
} = useEditorContext(
|
|
139
|
+
} = useEditorContext(t0);
|
|
159
140
|
const inputRef = useRef(null);
|
|
160
141
|
const buttonRef = useRef(null);
|
|
161
142
|
const [isEditable, setIsEditable] = useState(false);
|
|
143
|
+
let t1;
|
|
162
144
|
let t2;
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
t2 = () => {
|
|
145
|
+
if ($[1] !== isEditable) {
|
|
146
|
+
t1 = () => {
|
|
166
147
|
var _a;
|
|
167
148
|
if (isEditable) {
|
|
168
149
|
(_a = inputRef.current) == null ? void 0 : _a.focus();
|
|
169
150
|
}
|
|
170
151
|
};
|
|
171
|
-
|
|
172
|
-
$[
|
|
152
|
+
t2 = [isEditable];
|
|
153
|
+
$[1] = isEditable;
|
|
154
|
+
$[2] = t1;
|
|
173
155
|
$[3] = t2;
|
|
174
|
-
$[4] = t3;
|
|
175
156
|
} else {
|
|
157
|
+
t1 = $[2];
|
|
176
158
|
t2 = $[3];
|
|
177
|
-
t3 = $[4];
|
|
178
159
|
}
|
|
179
|
-
useEffect(
|
|
180
|
-
let
|
|
181
|
-
if ($[
|
|
182
|
-
|
|
183
|
-
$[
|
|
184
|
-
$[
|
|
185
|
-
$[
|
|
186
|
-
$[
|
|
160
|
+
useEffect(t1, t2);
|
|
161
|
+
let t3;
|
|
162
|
+
if ($[4] !== props.item.label || $[5] !== props.item.operationName || $[6] !== props.item.query) {
|
|
163
|
+
t3 = props.item.label || props.item.operationName || formatQuery(props.item.query);
|
|
164
|
+
$[4] = props.item.label;
|
|
165
|
+
$[5] = props.item.operationName;
|
|
166
|
+
$[6] = props.item.query;
|
|
167
|
+
$[7] = t3;
|
|
187
168
|
} else {
|
|
188
|
-
|
|
169
|
+
t3 = $[7];
|
|
189
170
|
}
|
|
190
|
-
const displayName =
|
|
191
|
-
let
|
|
192
|
-
if ($[
|
|
193
|
-
|
|
171
|
+
const displayName = t3;
|
|
172
|
+
let t4;
|
|
173
|
+
if ($[8] !== editLabel || $[9] !== props.item) {
|
|
174
|
+
t4 = () => {
|
|
194
175
|
var _a;
|
|
195
176
|
setIsEditable(false);
|
|
196
177
|
const {
|
|
@@ -202,37 +183,37 @@ function HistoryItem(props) {
|
|
|
202
183
|
label: (_a = inputRef.current) == null ? void 0 : _a.value
|
|
203
184
|
}, index);
|
|
204
185
|
};
|
|
205
|
-
$[
|
|
206
|
-
$[
|
|
186
|
+
$[8] = editLabel;
|
|
187
|
+
$[9] = props.item;
|
|
188
|
+
$[10] = t4;
|
|
189
|
+
} else {
|
|
190
|
+
t4 = $[10];
|
|
191
|
+
}
|
|
192
|
+
const handleSave = t4;
|
|
193
|
+
let t5;
|
|
194
|
+
if ($[11] === Symbol.for("react.memo_cache_sentinel")) {
|
|
195
|
+
t5 = () => {
|
|
196
|
+
setIsEditable(false);
|
|
197
|
+
};
|
|
207
198
|
$[11] = t5;
|
|
208
199
|
} else {
|
|
209
200
|
t5 = $[11];
|
|
210
201
|
}
|
|
211
|
-
const
|
|
202
|
+
const handleClose = t5;
|
|
212
203
|
let t6;
|
|
213
204
|
if ($[12] === Symbol.for("react.memo_cache_sentinel")) {
|
|
214
|
-
t6 = () => {
|
|
215
|
-
|
|
205
|
+
t6 = (e) => {
|
|
206
|
+
e.stopPropagation();
|
|
207
|
+
setIsEditable(true);
|
|
216
208
|
};
|
|
217
209
|
$[12] = t6;
|
|
218
210
|
} else {
|
|
219
211
|
t6 = $[12];
|
|
220
212
|
}
|
|
221
|
-
const
|
|
213
|
+
const handleEditLabel = t6;
|
|
222
214
|
let t7;
|
|
223
|
-
if ($[13]
|
|
224
|
-
t7 = (
|
|
225
|
-
e.stopPropagation();
|
|
226
|
-
setIsEditable(true);
|
|
227
|
-
};
|
|
228
|
-
$[13] = t7;
|
|
229
|
-
} else {
|
|
230
|
-
t7 = $[13];
|
|
231
|
-
}
|
|
232
|
-
const handleEditLabel = t7;
|
|
233
|
-
let t8;
|
|
234
|
-
if ($[14] !== headerEditor || $[15] !== props.item || $[16] !== queryEditor || $[17] !== setActive || $[18] !== variableEditor) {
|
|
235
|
-
t8 = () => {
|
|
215
|
+
if ($[13] !== headerEditor || $[14] !== props.item || $[15] !== queryEditor || $[16] !== setActive || $[17] !== variableEditor) {
|
|
216
|
+
t7 = () => {
|
|
236
217
|
const {
|
|
237
218
|
query,
|
|
238
219
|
variables,
|
|
@@ -243,54 +224,54 @@ function HistoryItem(props) {
|
|
|
243
224
|
headerEditor == null ? void 0 : headerEditor.setValue(headers ?? "");
|
|
244
225
|
setActive(props.item);
|
|
245
226
|
};
|
|
246
|
-
$[
|
|
247
|
-
$[
|
|
248
|
-
$[
|
|
249
|
-
$[
|
|
250
|
-
$[
|
|
251
|
-
$[
|
|
227
|
+
$[13] = headerEditor;
|
|
228
|
+
$[14] = props.item;
|
|
229
|
+
$[15] = queryEditor;
|
|
230
|
+
$[16] = setActive;
|
|
231
|
+
$[17] = variableEditor;
|
|
232
|
+
$[18] = t7;
|
|
252
233
|
} else {
|
|
253
|
-
|
|
234
|
+
t7 = $[18];
|
|
254
235
|
}
|
|
255
|
-
const handleHistoryItemClick =
|
|
256
|
-
let
|
|
257
|
-
if ($[
|
|
258
|
-
|
|
236
|
+
const handleHistoryItemClick = t7;
|
|
237
|
+
let t8;
|
|
238
|
+
if ($[19] !== deleteFromHistory || $[20] !== props.item) {
|
|
239
|
+
t8 = (e_0) => {
|
|
259
240
|
e_0.stopPropagation();
|
|
260
241
|
deleteFromHistory(props.item);
|
|
261
242
|
};
|
|
262
|
-
$[
|
|
263
|
-
$[
|
|
264
|
-
$[
|
|
243
|
+
$[19] = deleteFromHistory;
|
|
244
|
+
$[20] = props.item;
|
|
245
|
+
$[21] = t8;
|
|
265
246
|
} else {
|
|
266
|
-
|
|
247
|
+
t8 = $[21];
|
|
267
248
|
}
|
|
268
|
-
const handleDeleteItemFromHistory =
|
|
269
|
-
let
|
|
270
|
-
if ($[
|
|
271
|
-
|
|
249
|
+
const handleDeleteItemFromHistory = t8;
|
|
250
|
+
let t9;
|
|
251
|
+
if ($[22] !== props.item || $[23] !== toggleFavorite) {
|
|
252
|
+
t9 = (e_1) => {
|
|
272
253
|
e_1.stopPropagation();
|
|
273
254
|
toggleFavorite(props.item);
|
|
274
255
|
};
|
|
275
|
-
$[
|
|
276
|
-
$[
|
|
277
|
-
$[
|
|
256
|
+
$[22] = props.item;
|
|
257
|
+
$[23] = toggleFavorite;
|
|
258
|
+
$[24] = t9;
|
|
278
259
|
} else {
|
|
279
|
-
|
|
260
|
+
t9 = $[24];
|
|
280
261
|
}
|
|
281
|
-
const handleToggleFavorite =
|
|
282
|
-
const
|
|
283
|
-
let
|
|
284
|
-
if ($[
|
|
285
|
-
|
|
262
|
+
const handleToggleFavorite = t9;
|
|
263
|
+
const t10 = isEditable && "editable";
|
|
264
|
+
let t11;
|
|
265
|
+
if ($[25] !== t10) {
|
|
266
|
+
t11 = cn("graphiql-history-item", t10);
|
|
267
|
+
$[25] = t10;
|
|
286
268
|
$[26] = t11;
|
|
287
|
-
$[27] = t12;
|
|
288
269
|
} else {
|
|
289
|
-
|
|
270
|
+
t11 = $[26];
|
|
290
271
|
}
|
|
291
|
-
let
|
|
292
|
-
if ($[
|
|
293
|
-
|
|
272
|
+
let t12;
|
|
273
|
+
if ($[27] !== displayName || $[28] !== editLabel || $[29] !== handleDeleteItemFromHistory || $[30] !== handleHistoryItemClick || $[31] !== handleSave || $[32] !== handleToggleFavorite || $[33] !== isEditable || $[34] !== props.item) {
|
|
274
|
+
t12 = isEditable ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
294
275
|
/* @__PURE__ */ jsx("input", { type: "text", defaultValue: props.item.label, ref: inputRef, onKeyDown: (e_2) => {
|
|
295
276
|
if (e_2.key === "Esc") {
|
|
296
277
|
setIsEditable(false);
|
|
@@ -312,28 +293,28 @@ function HistoryItem(props) {
|
|
|
312
293
|
/* @__PURE__ */ jsx(Tooltip, { label: props.item.favorite ? "Remove favorite" : "Add favorite", children: /* @__PURE__ */ jsx(UnStyledButton, { type: "button", className: "graphiql-history-item-action", onClick: handleToggleFavorite, "aria-label": props.item.favorite ? "Remove favorite" : "Add favorite", children: props.item.favorite ? /* @__PURE__ */ jsx(StarFilledIcon, { "aria-hidden": "true" }) : /* @__PURE__ */ jsx(StarIcon, { "aria-hidden": "true" }) }) }),
|
|
313
294
|
/* @__PURE__ */ jsx(Tooltip, { label: "Delete from history", children: /* @__PURE__ */ jsx(UnStyledButton, { type: "button", className: "graphiql-history-item-action", onClick: handleDeleteItemFromHistory, "aria-label": "Delete from history", children: /* @__PURE__ */ jsx(TrashIcon, { "aria-hidden": "true" }) }) })
|
|
314
295
|
] });
|
|
315
|
-
$[
|
|
316
|
-
$[
|
|
317
|
-
$[
|
|
318
|
-
$[
|
|
319
|
-
$[
|
|
320
|
-
$[
|
|
321
|
-
$[
|
|
322
|
-
$[
|
|
323
|
-
$[
|
|
296
|
+
$[27] = displayName;
|
|
297
|
+
$[28] = editLabel;
|
|
298
|
+
$[29] = handleDeleteItemFromHistory;
|
|
299
|
+
$[30] = handleHistoryItemClick;
|
|
300
|
+
$[31] = handleSave;
|
|
301
|
+
$[32] = handleToggleFavorite;
|
|
302
|
+
$[33] = isEditable;
|
|
303
|
+
$[34] = props.item;
|
|
304
|
+
$[35] = t12;
|
|
324
305
|
} else {
|
|
325
|
-
|
|
306
|
+
t12 = $[35];
|
|
326
307
|
}
|
|
327
|
-
let
|
|
328
|
-
if ($[
|
|
329
|
-
|
|
308
|
+
let t13;
|
|
309
|
+
if ($[36] !== t11 || $[37] !== t12) {
|
|
310
|
+
t13 = /* @__PURE__ */ jsx("li", { className: t11, children: t12 });
|
|
311
|
+
$[36] = t11;
|
|
330
312
|
$[37] = t12;
|
|
331
313
|
$[38] = t13;
|
|
332
|
-
$[39] = t14;
|
|
333
314
|
} else {
|
|
334
|
-
|
|
315
|
+
t13 = $[38];
|
|
335
316
|
}
|
|
336
|
-
return
|
|
317
|
+
return t13;
|
|
337
318
|
}
|
|
338
319
|
function formatQuery(query) {
|
|
339
320
|
return query == null ? void 0 : query.split("\n").map((line) => line.replace(/#(.*)/, "")).join(" ").replaceAll("{", " { ").replaceAll("}", " } ").replaceAll(/[\s]{2,}/g, " ");
|
package/dist/components.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"components.js","sources":["../src/components.tsx"],"sourcesContent":["import type { QueryStoreItem } from '@graphiql/toolkit';\nimport { MouseEventHandler, useEffect, useRef, useState } from 'react';\nimport {\n cn,\n CloseIcon,\n PenIcon,\n StarFilledIcon,\n StarIcon,\n TrashIcon,\n useEditorContext,\n Button,\n Tooltip,\n UnStyledButton,\n} from '@graphiql/react';\nimport { HistoryContextType, useHistoryContext } from './context';\n\n// Fix error from react-compiler\n// Support value blocks (conditional, logical, optional chaining, etc) within a try/catch statement\nfunction handleDelete(\n items: QueryStoreItem[],\n deleteFromHistory: HistoryContextType['deleteFromHistory'],\n) {\n for (const item of items) {\n deleteFromHistory(item, true);\n }\n}\n\nexport function History() {\n const { items: all, deleteFromHistory } = useHistoryContext({\n nonNull: true,\n });\n\n // Reverse items since we push them in so want the latest one at the top, and pass the\n // original index in case multiple items share the same label so we can edit correct item\n let items = all\n .slice()\n .map((item, i) => ({ ...item, index: i }))\n .reverse();\n const favorites = items.filter(item => item.favorite);\n if (favorites.length) {\n items = items.filter(item => !item.favorite);\n }\n\n const [clearStatus, setClearStatus] = useState<'success' | 'error' | null>(\n null,\n );\n useEffect(() => {\n if (clearStatus) {\n // reset the button after a couple seconds\n setTimeout(() => {\n setClearStatus(null);\n }, 2000);\n }\n }, [clearStatus]);\n\n const handleClearStatus = () => {\n try {\n handleDelete(items, deleteFromHistory);\n setClearStatus('success');\n } catch {\n setClearStatus('error');\n }\n };\n const hasFavorites = Boolean(favorites.length);\n const hasItems = Boolean(items.length);\n\n return (\n <section aria-label=\"History\" className=\"graphiql-history\">\n <div className=\"graphiql-history-header\">\n History\n {(clearStatus || hasItems) && (\n <Button\n type=\"button\"\n state={clearStatus || undefined}\n disabled={!items.length}\n onClick={handleClearStatus}\n >\n {{\n success: 'Cleared',\n error: 'Failed to Clear',\n }[clearStatus!] || 'Clear'}\n </Button>\n )}\n </div>\n\n {hasFavorites && (\n <ul className=\"graphiql-history-items\">\n {favorites.map(item => (\n <HistoryItem item={item} key={item.index} />\n ))}\n </ul>\n )}\n\n {hasFavorites && hasItems && (\n <div className=\"graphiql-history-item-spacer\" />\n )}\n\n {hasItems && (\n <ul className=\"graphiql-history-items\">\n {items.map(item => (\n <HistoryItem item={item} key={item.index} />\n ))}\n </ul>\n )}\n </section>\n );\n}\n\ntype QueryHistoryItemProps = {\n item: QueryStoreItem & { index?: number };\n};\n\nexport function HistoryItem(props: QueryHistoryItemProps) {\n const { editLabel, toggleFavorite, deleteFromHistory, setActive } =\n useHistoryContext({\n nonNull: true,\n caller: HistoryItem,\n });\n const { headerEditor, queryEditor, variableEditor } = useEditorContext({\n nonNull: true,\n caller: HistoryItem,\n });\n const inputRef = useRef<HTMLInputElement>(null);\n const buttonRef = useRef<HTMLButtonElement>(null);\n const [isEditable, setIsEditable] = useState(false);\n\n useEffect(() => {\n if (isEditable) {\n inputRef.current?.focus();\n }\n }, [isEditable]);\n\n const displayName =\n props.item.label ||\n props.item.operationName ||\n formatQuery(props.item.query);\n\n const handleSave = () => {\n setIsEditable(false);\n const { index, ...item } = props.item;\n editLabel({ ...item, label: inputRef.current?.value }, index);\n };\n\n const handleClose = () => {\n setIsEditable(false);\n };\n\n const handleEditLabel: MouseEventHandler<HTMLButtonElement> = e => {\n e.stopPropagation();\n setIsEditable(true);\n };\n\n const handleHistoryItemClick: MouseEventHandler<HTMLButtonElement> = () => {\n const { query, variables, headers } = props.item;\n queryEditor?.setValue(query ?? '');\n variableEditor?.setValue(variables ?? '');\n headerEditor?.setValue(headers ?? '');\n setActive(props.item);\n };\n\n const handleDeleteItemFromHistory: MouseEventHandler<\n HTMLButtonElement\n > = e => {\n e.stopPropagation();\n deleteFromHistory(props.item);\n };\n\n const handleToggleFavorite: MouseEventHandler<HTMLButtonElement> = e => {\n e.stopPropagation();\n toggleFavorite(props.item);\n };\n\n return (\n <li className={cn('graphiql-history-item', isEditable && 'editable')}>\n {isEditable ? (\n <>\n <input\n type=\"text\"\n defaultValue={props.item.label}\n ref={inputRef}\n onKeyDown={e => {\n if (e.key === 'Esc') {\n setIsEditable(false);\n } else if (e.key === 'Enter') {\n setIsEditable(false);\n editLabel({ ...props.item, label: e.currentTarget.value });\n }\n }}\n placeholder=\"Type a label\"\n />\n <UnStyledButton type=\"button\" ref={buttonRef} onClick={handleSave}>\n Save\n </UnStyledButton>\n <UnStyledButton type=\"button\" ref={buttonRef} onClick={handleClose}>\n <CloseIcon />\n </UnStyledButton>\n </>\n ) : (\n <>\n <Tooltip label=\"Set active\">\n <UnStyledButton\n type=\"button\"\n className=\"graphiql-history-item-label\"\n onClick={handleHistoryItemClick}\n aria-label=\"Set active\"\n >\n {displayName}\n </UnStyledButton>\n </Tooltip>\n <Tooltip label=\"Edit label\">\n <UnStyledButton\n type=\"button\"\n className=\"graphiql-history-item-action\"\n onClick={handleEditLabel}\n aria-label=\"Edit label\"\n >\n <PenIcon aria-hidden=\"true\" />\n </UnStyledButton>\n </Tooltip>\n <Tooltip\n label={props.item.favorite ? 'Remove favorite' : 'Add favorite'}\n >\n <UnStyledButton\n type=\"button\"\n className=\"graphiql-history-item-action\"\n onClick={handleToggleFavorite}\n aria-label={\n props.item.favorite ? 'Remove favorite' : 'Add favorite'\n }\n >\n {props.item.favorite ? (\n <StarFilledIcon aria-hidden=\"true\" />\n ) : (\n <StarIcon aria-hidden=\"true\" />\n )}\n </UnStyledButton>\n </Tooltip>\n <Tooltip label=\"Delete from history\">\n <UnStyledButton\n type=\"button\"\n className=\"graphiql-history-item-action\"\n onClick={handleDeleteItemFromHistory}\n aria-label=\"Delete from history\"\n >\n <TrashIcon aria-hidden=\"true\" />\n </UnStyledButton>\n </Tooltip>\n </>\n )}\n </li>\n );\n}\n\nexport function formatQuery(query?: string) {\n return query\n ?.split('\\n')\n .map(line => line.replace(/#(.*)/, ''))\n .join(' ')\n .replaceAll('{', ' { ')\n .replaceAll('}', ' } ')\n .replaceAll(/[\\s]{2,}/g, ' ');\n}\n"],"names":["handleDelete","items","deleteFromHistory","item","History","$","_c","t0","Symbol","for","nonNull","all","useHistoryContext","slice","map","_temp","reverse","favorites","filter","_temp2","length","_temp3","clearStatus","setClearStatus","useState","t1","t2","setTimeout","useEffect","handleClearStatus","hasFavorites","Boolean","hasItems","t3","t4","t5","undefined","success","error","t6","t7","_temp4","t8","t9","_temp5","t10","item_3","index","item_2","item_1","favorite","item_0","i","HistoryItem","props","caller","editLabel","toggleFavorite","setActive","headerEditor","queryEditor","variableEditor","useEditorContext","inputRef","useRef","buttonRef","isEditable","setIsEditable","current","focus","label","operationName","query","formatQuery","displayName","value","handleSave","handleClose","e","stopPropagation","handleEditLabel","variables","headers","setValue","handleHistoryItemClick","e_0","handleDeleteItemFromHistory","e_1","handleToggleFavorite","t11","t12","cn","t13","e_2","key","currentTarget","t14","split","line","replace","join","replaceAll"],"mappings":";;;;;AAkBA,SAASA,aACPC,OACAC,mBACA;AACA,aAAWC,QAAQF,OAAO;AACxBC,sBAAkBC,MAAM,IAAI;AAAA,EAAA;AAEhC;AAEO,SAAAC,UAAA;AAAAC,QAAAA,IAAAC,EAAA,EAAA;AAAAC,MAAAA;AAAA,MAAAF,EAAA,CAAA,MAAAG,OAAAC,IAAA,2BAAA,GAAA;AACuD,SAAA;AAAA,MAAAC,SAAA;AAAA,IAAA;AAE3DL,WAAAE;AAAAA,EAAAA,OAAA;AAAAA,SAAAF,EAAA,CAAA;AAAA,EAAA;AAFD,QAAA;AAAA,IAAAJ,OAAAU;AAAAA,IAAAT;AAAAA,EAAAA,IAA0CU,kBAAkBL,EAE3D;AAIDN,MAAAA;AAAAA,UAAYU,IAAGE,MACN,EAACC,IAAAC,KACiC,EAACC,QACjC;AACXC,QAAAA,YAAkBhB,MAAKiB,OAAAC,MAA6B;AAAE,MAClDF,UAASG,QAAA;AACHnB,YAAAA,MAAKiB,OAAAG,MAA8B;AAAA,EAAA;AAG7C,QAAA,CAAAC,aAAAC,cAAA,IAAsCC,aAEtC;AAAEC,MAAAA;AAAAC,MAAAA;AAAArB,MAAAA,SAAAiB,aAAA;AACQG,SAAAA,MAAA;AAA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ASvB,YAAYD,OAAgB;AACnCA,SAAAA,+BACHyB,MAAM,MACPnF,IAAIoF,UAAQA,KAAKC,QAAQ,SAAS,EAAE,GACpCC,KAAK,KACLC,WAAW,KAAK,OAChBA,WAAW,KAAK,OAChBA,WAAW,aAAa;AAC7B;"}
|
|
1
|
+
{"version":3,"file":"components.js","sources":["../src/components.tsx"],"sourcesContent":["import type { QueryStoreItem } from '@graphiql/toolkit';\nimport { MouseEventHandler, useEffect, useRef, useState } from 'react';\nimport {\n cn,\n CloseIcon,\n PenIcon,\n StarFilledIcon,\n StarIcon,\n TrashIcon,\n useEditorContext,\n Button,\n Tooltip,\n UnStyledButton,\n} from '@graphiql/react';\nimport { useHistory, useHistoryActions } from './context';\n\n// Fix error from react-compiler\n// Support value blocks (conditional, logical, optional chaining, etc.) within a try/catch statement\nfunction handleDelete(\n items: QueryStoreItem[],\n deleteFromHistory: ReturnType<typeof useHistoryActions>['deleteFromHistory'],\n) {\n for (const item of items) {\n deleteFromHistory(item, true);\n }\n}\n\nexport function History() {\n const all = useHistory();\n const { deleteFromHistory } = useHistoryActions();\n\n // Reverse items since we push them in so want the latest one at the top, and pass the\n // original index in case multiple items share the same label so we can edit the correct item\n let items = all\n .slice()\n .map((item, i) => ({ ...item, index: i }))\n .reverse();\n const favorites = items.filter(item => item.favorite);\n if (favorites.length) {\n items = items.filter(item => !item.favorite);\n }\n\n const [clearStatus, setClearStatus] = useState<'success' | 'error' | null>(\n null,\n );\n useEffect(() => {\n if (clearStatus) {\n // reset the button after a couple seconds\n setTimeout(() => {\n setClearStatus(null);\n }, 2000);\n }\n }, [clearStatus]);\n\n const handleClearStatus = () => {\n try {\n handleDelete(items, deleteFromHistory);\n setClearStatus('success');\n } catch {\n setClearStatus('error');\n }\n };\n const hasFavorites = Boolean(favorites.length);\n const hasItems = Boolean(items.length);\n\n return (\n <section aria-label=\"History\" className=\"graphiql-history\">\n <div className=\"graphiql-history-header\">\n History\n {(clearStatus || hasItems) && (\n <Button\n type=\"button\"\n state={clearStatus || undefined}\n disabled={!items.length}\n onClick={handleClearStatus}\n >\n {{\n success: 'Cleared',\n error: 'Failed to Clear',\n }[clearStatus!] || 'Clear'}\n </Button>\n )}\n </div>\n\n {hasFavorites && (\n <ul className=\"graphiql-history-items\">\n {favorites.map(item => (\n <HistoryItem item={item} key={item.index} />\n ))}\n </ul>\n )}\n\n {hasFavorites && hasItems && (\n <div className=\"graphiql-history-item-spacer\" />\n )}\n\n {hasItems && (\n <ul className=\"graphiql-history-items\">\n {items.map(item => (\n <HistoryItem item={item} key={item.index} />\n ))}\n </ul>\n )}\n </section>\n );\n}\n\ntype QueryHistoryItemProps = {\n item: QueryStoreItem & { index?: number };\n};\n\nexport function HistoryItem(props: QueryHistoryItemProps) {\n const { editLabel, toggleFavorite, deleteFromHistory, setActive } =\n useHistoryActions();\n const { headerEditor, queryEditor, variableEditor } = useEditorContext({\n nonNull: true,\n caller: HistoryItem,\n });\n const inputRef = useRef<HTMLInputElement>(null);\n const buttonRef = useRef<HTMLButtonElement>(null);\n const [isEditable, setIsEditable] = useState(false);\n\n useEffect(() => {\n if (isEditable) {\n inputRef.current?.focus();\n }\n }, [isEditable]);\n\n const displayName =\n props.item.label ||\n props.item.operationName ||\n formatQuery(props.item.query);\n\n const handleSave = () => {\n setIsEditable(false);\n const { index, ...item } = props.item;\n editLabel({ ...item, label: inputRef.current?.value }, index);\n };\n\n const handleClose = () => {\n setIsEditable(false);\n };\n\n const handleEditLabel: MouseEventHandler<HTMLButtonElement> = e => {\n e.stopPropagation();\n setIsEditable(true);\n };\n\n const handleHistoryItemClick: MouseEventHandler<HTMLButtonElement> = () => {\n const { query, variables, headers } = props.item;\n queryEditor?.setValue(query ?? '');\n variableEditor?.setValue(variables ?? '');\n headerEditor?.setValue(headers ?? '');\n setActive(props.item);\n };\n\n const handleDeleteItemFromHistory: MouseEventHandler<\n HTMLButtonElement\n > = e => {\n e.stopPropagation();\n deleteFromHistory(props.item);\n };\n\n const handleToggleFavorite: MouseEventHandler<HTMLButtonElement> = e => {\n e.stopPropagation();\n toggleFavorite(props.item);\n };\n\n return (\n <li className={cn('graphiql-history-item', isEditable && 'editable')}>\n {isEditable ? (\n <>\n <input\n type=\"text\"\n defaultValue={props.item.label}\n ref={inputRef}\n onKeyDown={e => {\n if (e.key === 'Esc') {\n setIsEditable(false);\n } else if (e.key === 'Enter') {\n setIsEditable(false);\n editLabel({ ...props.item, label: e.currentTarget.value });\n }\n }}\n placeholder=\"Type a label\"\n />\n <UnStyledButton type=\"button\" ref={buttonRef} onClick={handleSave}>\n Save\n </UnStyledButton>\n <UnStyledButton type=\"button\" ref={buttonRef} onClick={handleClose}>\n <CloseIcon />\n </UnStyledButton>\n </>\n ) : (\n <>\n <Tooltip label=\"Set active\">\n <UnStyledButton\n type=\"button\"\n className=\"graphiql-history-item-label\"\n onClick={handleHistoryItemClick}\n aria-label=\"Set active\"\n >\n {displayName}\n </UnStyledButton>\n </Tooltip>\n <Tooltip label=\"Edit label\">\n <UnStyledButton\n type=\"button\"\n className=\"graphiql-history-item-action\"\n onClick={handleEditLabel}\n aria-label=\"Edit label\"\n >\n <PenIcon aria-hidden=\"true\" />\n </UnStyledButton>\n </Tooltip>\n <Tooltip\n label={props.item.favorite ? 'Remove favorite' : 'Add favorite'}\n >\n <UnStyledButton\n type=\"button\"\n className=\"graphiql-history-item-action\"\n onClick={handleToggleFavorite}\n aria-label={\n props.item.favorite ? 'Remove favorite' : 'Add favorite'\n }\n >\n {props.item.favorite ? (\n <StarFilledIcon aria-hidden=\"true\" />\n ) : (\n <StarIcon aria-hidden=\"true\" />\n )}\n </UnStyledButton>\n </Tooltip>\n <Tooltip label=\"Delete from history\">\n <UnStyledButton\n type=\"button\"\n className=\"graphiql-history-item-action\"\n onClick={handleDeleteItemFromHistory}\n aria-label=\"Delete from history\"\n >\n <TrashIcon aria-hidden=\"true\" />\n </UnStyledButton>\n </Tooltip>\n </>\n )}\n </li>\n );\n}\n\nexport function formatQuery(query?: string) {\n return query\n ?.split('\\n')\n .map(line => line.replace(/#(.*)/, ''))\n .join(' ')\n .replaceAll('{', ' { ')\n .replaceAll('}', ' } ')\n .replaceAll(/[\\s]{2,}/g, ' ');\n}\n"],"names":["handleDelete","items","deleteFromHistory","item","History","$","_c","all","useHistory","useHistoryActions","slice","map","_temp","reverse","favorites","filter","_temp2","length","_temp3","clearStatus","setClearStatus","useState","t0","t1","setTimeout","useEffect","handleClearStatus","hasFavorites","Boolean","hasItems","t2","t3","t4","undefined","success","error","t5","t6","_temp4","t7","t8","_temp5","t9","item_3","index","item_2","item_1","favorite","item_0","i","HistoryItem","props","editLabel","toggleFavorite","setActive","Symbol","for","nonNull","caller","headerEditor","queryEditor","variableEditor","useEditorContext","inputRef","useRef","buttonRef","isEditable","setIsEditable","current","focus","label","operationName","query","formatQuery","displayName","value","handleSave","handleClose","e","stopPropagation","handleEditLabel","variables","headers","setValue","handleHistoryItemClick","e_0","handleDeleteItemFromHistory","e_1","handleToggleFavorite","t10","t11","cn","t12","e_2","key","currentTarget","t13","split","line","replace","join","replaceAll"],"mappings":";;;;;AAkBA,SAASA,aACPC,OACAC,mBACA;AACA,aAAWC,QAAQF,OAAO;AACxBC,sBAAkBC,MAAM,IAAI;AAAA,EAAA;AAEhC;AAEO,SAAAC,UAAA;AAAAC,QAAAA,IAAAC,EAAA,EAAA;AACL,QAAAC,MAAYC,WAAW;AACvB,QAAA;AAAA,IAAAN;AAAAA,MAA8BO,kBAAkB;AAIhDR,MAAAA;AAAAA,UAAYM,IAAGG,MACN,EAACC,IAAAC,KACiC,EAACC,QACjC;AACXC,QAAAA,YAAkBb,MAAKc,OAAAC,MAA6B;AAAE,MAClDF,UAASG,QAAA;AACHhB,YAAAA,MAAKc,OAAAG,MAA8B;AAAA,EAAA;AAG7C,QAAA,CAAAC,aAAAC,cAAA,IAAsCC,aAEtC;AAAEC,MAAAA;AAAAC,MAAAA;AAAAlB,MAAAA,SAAAc,aAAA;AACQG,SAAAA,MAAA;AAAA,UACJH,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|
1
|
-
import { QueryStoreItem } from '@graphiql/toolkit';
|
|
2
1
|
import { ReactNode } from 'react';
|
|
3
|
-
|
|
2
|
+
import { QueryStoreItem } from '@graphiql/toolkit';
|
|
3
|
+
declare type HistoryContextProviderProps = {
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
/**
|
|
6
|
+
* The maximum number of executed operations to store.
|
|
7
|
+
* @default 20
|
|
8
|
+
*/
|
|
9
|
+
maxHistoryLength?: number;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* The functions send the entire operation so users can customize their own application with
|
|
13
|
+
* <HistoryContext.Provider value={customizedFunctions} /> and get access to the operation plus
|
|
14
|
+
* any additional props they added for their needs (i.e., build their own functions that may save
|
|
15
|
+
* to a backend instead of localStorage and might need an id property added to the QueryStoreItem)
|
|
16
|
+
*/
|
|
17
|
+
export declare function HistoryContextProvider({ maxHistoryLength, children, }: HistoryContextProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
18
|
+
export declare const useHistory: () => readonly QueryStoreItem[];
|
|
19
|
+
export declare const useHistoryActions: () => {
|
|
4
20
|
/**
|
|
5
21
|
* Add an operation to the history.
|
|
6
22
|
* @param operation The operation that was executed, consisting of the query,
|
|
@@ -29,10 +45,6 @@ export declare type HistoryContextType = {
|
|
|
29
45
|
label?: string;
|
|
30
46
|
favorite?: boolean;
|
|
31
47
|
}, index?: number): void;
|
|
32
|
-
/**
|
|
33
|
-
* The list of history items.
|
|
34
|
-
*/
|
|
35
|
-
items: readonly QueryStoreItem[];
|
|
36
48
|
/**
|
|
37
49
|
* Toggle the favorite state of an item from the history.
|
|
38
50
|
* @param args An object containing the favorite state (`undefined` if it
|
|
@@ -61,31 +73,4 @@ export declare type HistoryContextType = {
|
|
|
61
73
|
*/
|
|
62
74
|
setActive(args: QueryStoreItem): void;
|
|
63
75
|
};
|
|
64
|
-
export declare const HistoryContext: import('react').Context<HistoryContextType | null>;
|
|
65
|
-
declare type HistoryContextProviderProps = {
|
|
66
|
-
children: ReactNode;
|
|
67
|
-
/**
|
|
68
|
-
* The maximum number of executed operations to store.
|
|
69
|
-
* @default 20
|
|
70
|
-
*/
|
|
71
|
-
maxHistoryLength?: number;
|
|
72
|
-
};
|
|
73
|
-
/**
|
|
74
|
-
* The functions send the entire operation so users can customize their own application with
|
|
75
|
-
* <HistoryContext.Provider value={customizedFunctions} /> and get access to the operation plus
|
|
76
|
-
* any additional props they added for their needs (i.e., build their own functions that may save
|
|
77
|
-
* to a backend instead of localStorage and might need an id property added to the QueryStoreItem)
|
|
78
|
-
*/
|
|
79
|
-
export declare function HistoryContextProvider({ maxHistoryLength, children, }: HistoryContextProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
80
|
-
export declare const useHistoryContext: {
|
|
81
|
-
(options: {
|
|
82
|
-
nonNull: true;
|
|
83
|
-
caller?: Function | undefined;
|
|
84
|
-
}): HistoryContextType;
|
|
85
|
-
(options: {
|
|
86
|
-
nonNull?: boolean | undefined;
|
|
87
|
-
caller?: Function | undefined;
|
|
88
|
-
}): HistoryContextType | null;
|
|
89
|
-
(): HistoryContextType | null;
|
|
90
|
-
};
|
|
91
76
|
export {};
|
package/dist/context.js
CHANGED
|
@@ -1,16 +1,57 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { c } from "react-compiler-runtime";
|
|
3
|
+
import { useRef, useEffect, createContext, useContext } from "react";
|
|
4
|
+
import { createStore, useStore } from "zustand";
|
|
3
5
|
import { HistoryStore, StorageAPI } from "@graphiql/toolkit";
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
const
|
|
6
|
+
import { useStorageContext, useExecutionContext, useEditorContext } from "@graphiql/react";
|
|
7
|
+
function createHistoryStore(storage, maxHistoryLength) {
|
|
8
|
+
const historyStore = (
|
|
9
|
+
// Fall back to a noop storage when the StorageContext is empty
|
|
10
|
+
new HistoryStore(storage || new StorageAPI(null), maxHistoryLength)
|
|
11
|
+
);
|
|
12
|
+
return createStore((set) => ({
|
|
13
|
+
items: historyStore.queries,
|
|
14
|
+
actions: {
|
|
15
|
+
addToHistory(operation) {
|
|
16
|
+
historyStore.updateHistory(operation);
|
|
17
|
+
const items = historyStore.queries;
|
|
18
|
+
set({
|
|
19
|
+
items
|
|
20
|
+
});
|
|
21
|
+
},
|
|
22
|
+
editLabel(operation, index) {
|
|
23
|
+
historyStore.editLabel(operation, index);
|
|
24
|
+
const items = historyStore.queries;
|
|
25
|
+
set({
|
|
26
|
+
items
|
|
27
|
+
});
|
|
28
|
+
},
|
|
29
|
+
toggleFavorite(operation) {
|
|
30
|
+
historyStore.toggleFavorite(operation);
|
|
31
|
+
const items = historyStore.queries;
|
|
32
|
+
set({
|
|
33
|
+
items
|
|
34
|
+
});
|
|
35
|
+
},
|
|
36
|
+
setActive: (item) => item,
|
|
37
|
+
deleteFromHistory(item, clearFavorites) {
|
|
38
|
+
historyStore.deleteHistory(item, clearFavorites);
|
|
39
|
+
const items = historyStore.queries;
|
|
40
|
+
set({
|
|
41
|
+
items
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}));
|
|
46
|
+
}
|
|
47
|
+
const HistoryContext = createContext(null);
|
|
7
48
|
function HistoryContextProvider(t0) {
|
|
8
|
-
const $ = c(
|
|
49
|
+
const $ = c(11);
|
|
9
50
|
const {
|
|
10
51
|
maxHistoryLength: t1,
|
|
11
52
|
children
|
|
12
53
|
} = t0;
|
|
13
|
-
const maxHistoryLength = t1 === void 0 ?
|
|
54
|
+
const maxHistoryLength = t1 === void 0 ? 20 : t1;
|
|
14
55
|
const storage = useStorageContext();
|
|
15
56
|
let t2;
|
|
16
57
|
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
@@ -25,77 +66,42 @@ function HistoryContextProvider(t0) {
|
|
|
25
66
|
isFetching
|
|
26
67
|
} = useExecutionContext(t2);
|
|
27
68
|
let t3;
|
|
28
|
-
if ($[1]
|
|
29
|
-
t3 =
|
|
30
|
-
$[1] = maxHistoryLength;
|
|
31
|
-
$[2] = storage;
|
|
32
|
-
$[3] = t3;
|
|
33
|
-
} else {
|
|
34
|
-
t3 = $[3];
|
|
35
|
-
}
|
|
36
|
-
const [historyStore] = useState(t3);
|
|
37
|
-
let t4;
|
|
38
|
-
if ($[4] !== historyStore.queries) {
|
|
39
|
-
t4 = () => historyStore.queries || [];
|
|
40
|
-
$[4] = historyStore.queries;
|
|
41
|
-
$[5] = t4;
|
|
42
|
-
} else {
|
|
43
|
-
t4 = $[5];
|
|
44
|
-
}
|
|
45
|
-
const [items, setItems] = useState(t4);
|
|
46
|
-
let t5;
|
|
47
|
-
if ($[6] !== historyStore || $[7] !== items) {
|
|
48
|
-
t5 = {
|
|
49
|
-
addToHistory(operation) {
|
|
50
|
-
historyStore.updateHistory(operation);
|
|
51
|
-
setItems(historyStore.queries);
|
|
52
|
-
},
|
|
53
|
-
editLabel(operation_0, index) {
|
|
54
|
-
historyStore.editLabel(operation_0, index);
|
|
55
|
-
setItems(historyStore.queries);
|
|
56
|
-
},
|
|
57
|
-
items,
|
|
58
|
-
toggleFavorite(operation_1) {
|
|
59
|
-
historyStore.toggleFavorite(operation_1);
|
|
60
|
-
setItems(historyStore.queries);
|
|
61
|
-
},
|
|
62
|
-
setActive: _temp,
|
|
63
|
-
deleteFromHistory(item_0, clearFavorites) {
|
|
64
|
-
historyStore.deleteHistory(item_0, clearFavorites);
|
|
65
|
-
setItems(historyStore.queries);
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
$[6] = historyStore;
|
|
69
|
-
$[7] = items;
|
|
70
|
-
$[8] = t5;
|
|
71
|
-
} else {
|
|
72
|
-
t5 = $[8];
|
|
73
|
-
}
|
|
74
|
-
const value = t5;
|
|
75
|
-
let t6;
|
|
76
|
-
if ($[9] === Symbol.for("react.memo_cache_sentinel")) {
|
|
77
|
-
t6 = {
|
|
69
|
+
if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
|
|
70
|
+
t3 = {
|
|
78
71
|
nonNull: true
|
|
79
72
|
};
|
|
80
|
-
$[
|
|
73
|
+
$[1] = t3;
|
|
81
74
|
} else {
|
|
82
|
-
|
|
75
|
+
t3 = $[1];
|
|
83
76
|
}
|
|
84
77
|
const {
|
|
85
78
|
tabs,
|
|
86
79
|
activeTabIndex
|
|
87
|
-
} = useEditorContext(
|
|
80
|
+
} = useEditorContext(t3);
|
|
88
81
|
const activeTab = tabs[activeTabIndex];
|
|
89
|
-
const
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
82
|
+
const storeRef = useRef(null);
|
|
83
|
+
if (storeRef.current === null) {
|
|
84
|
+
let t42;
|
|
85
|
+
if ($[2] !== maxHistoryLength || $[3] !== storage) {
|
|
86
|
+
t42 = createHistoryStore(storage, maxHistoryLength);
|
|
87
|
+
$[2] = maxHistoryLength;
|
|
88
|
+
$[3] = storage;
|
|
89
|
+
$[4] = t42;
|
|
90
|
+
} else {
|
|
91
|
+
t42 = $[4];
|
|
92
|
+
}
|
|
93
|
+
storeRef.current = t42;
|
|
94
|
+
}
|
|
95
|
+
let t4;
|
|
96
|
+
let t5;
|
|
97
|
+
if ($[5] !== activeTab || $[6] !== isFetching) {
|
|
98
|
+
t4 = () => {
|
|
96
99
|
if (!isFetching) {
|
|
97
100
|
return;
|
|
98
101
|
}
|
|
102
|
+
const {
|
|
103
|
+
addToHistory
|
|
104
|
+
} = storeRef.current.getState().actions;
|
|
99
105
|
addToHistory({
|
|
100
106
|
query: activeTab.query ?? void 0,
|
|
101
107
|
variables: activeTab.variables ?? void 0,
|
|
@@ -103,36 +109,48 @@ function HistoryContextProvider(t0) {
|
|
|
103
109
|
operationName: activeTab.operationName ?? void 0
|
|
104
110
|
});
|
|
105
111
|
};
|
|
106
|
-
|
|
107
|
-
$[
|
|
108
|
-
$[
|
|
109
|
-
$[
|
|
110
|
-
$[
|
|
111
|
-
$[14] = t8;
|
|
112
|
+
t5 = [isFetching, activeTab];
|
|
113
|
+
$[5] = activeTab;
|
|
114
|
+
$[6] = isFetching;
|
|
115
|
+
$[7] = t4;
|
|
116
|
+
$[8] = t5;
|
|
112
117
|
} else {
|
|
113
|
-
|
|
114
|
-
|
|
118
|
+
t4 = $[7];
|
|
119
|
+
t5 = $[8];
|
|
115
120
|
}
|
|
116
|
-
useEffect(
|
|
117
|
-
let
|
|
118
|
-
if ($[
|
|
119
|
-
|
|
120
|
-
$[
|
|
121
|
-
$[
|
|
122
|
-
$[17] = t9;
|
|
121
|
+
useEffect(t4, t5);
|
|
122
|
+
let t6;
|
|
123
|
+
if ($[9] !== children) {
|
|
124
|
+
t6 = /* @__PURE__ */ jsx(HistoryContext.Provider, { value: storeRef, children });
|
|
125
|
+
$[9] = children;
|
|
126
|
+
$[10] = t6;
|
|
123
127
|
} else {
|
|
124
|
-
|
|
128
|
+
t6 = $[10];
|
|
125
129
|
}
|
|
126
|
-
return
|
|
130
|
+
return t6;
|
|
131
|
+
}
|
|
132
|
+
function useHistoryStore(selector) {
|
|
133
|
+
const store = useContext(HistoryContext);
|
|
134
|
+
if (!store) {
|
|
135
|
+
throw new Error("Missing `HistoryContextProvider` in the tree");
|
|
136
|
+
}
|
|
137
|
+
return useStore(store.current, selector);
|
|
138
|
+
}
|
|
139
|
+
const useHistory = () => {
|
|
140
|
+
return useHistoryStore(_temp);
|
|
141
|
+
};
|
|
142
|
+
const useHistoryActions = () => {
|
|
143
|
+
return useHistoryStore(_temp2);
|
|
144
|
+
};
|
|
145
|
+
function _temp(state) {
|
|
146
|
+
return state.items;
|
|
127
147
|
}
|
|
128
|
-
function
|
|
129
|
-
return
|
|
148
|
+
function _temp2(state) {
|
|
149
|
+
return state.actions;
|
|
130
150
|
}
|
|
131
|
-
const useHistoryContext = createContextHook(HistoryContext);
|
|
132
|
-
const DEFAULT_HISTORY_LENGTH = 20;
|
|
133
151
|
export {
|
|
134
|
-
HistoryContext,
|
|
135
152
|
HistoryContextProvider,
|
|
136
|
-
|
|
153
|
+
useHistory,
|
|
154
|
+
useHistoryActions
|
|
137
155
|
};
|
|
138
156
|
//# sourceMappingURL=context.js.map
|
package/dist/context.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","sources":["../src/context.tsx"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"context.js","sources":["../src/context.tsx"],"sourcesContent":["import {\n createContext,\n ReactNode,\n RefObject,\n useContext,\n useEffect,\n useRef,\n} from 'react';\nimport { createStore, StoreApi, useStore } from 'zustand';\nimport { HistoryStore, QueryStoreItem, StorageAPI } from '@graphiql/toolkit';\nimport {\n useStorageContext,\n useExecutionContext,\n useEditorContext,\n} from '@graphiql/react';\n\nfunction createHistoryStore(\n storage: StorageAPI | null,\n maxHistoryLength: number,\n) {\n const historyStore =\n // Fall back to a noop storage when the StorageContext is empty\n new HistoryStore(storage || new StorageAPI(null), maxHistoryLength);\n\n return createStore<HistoryContextType>(set => ({\n items: historyStore.queries,\n actions: {\n addToHistory(operation) {\n historyStore.updateHistory(operation);\n const items = historyStore.queries;\n set({ items });\n },\n editLabel(operation, index) {\n historyStore.editLabel(operation, index);\n const items = historyStore.queries;\n set({ items });\n },\n toggleFavorite(operation) {\n historyStore.toggleFavorite(operation);\n const items = historyStore.queries;\n set({ items });\n },\n setActive: item => item,\n deleteFromHistory(item, clearFavorites) {\n historyStore.deleteHistory(item, clearFavorites);\n const items = historyStore.queries;\n set({ items });\n },\n },\n }));\n}\n\ntype HistoryContextType = {\n /**\n * The list of history items.\n */\n items: readonly QueryStoreItem[];\n actions: {\n /**\n * Add an operation to the history.\n * @param operation The operation that was executed, consisting of the query,\n * variables, headers, and operation name.\n */\n addToHistory(operation: {\n query?: string;\n variables?: string;\n headers?: string;\n operationName?: string;\n }): void;\n /**\n * Change the custom label of an item from the history.\n * @param args An object containing the label (`undefined` if it should be\n * unset) and properties that identify the history item that the label should\n * be applied to. (This can result in the label being applied to multiple\n * history items.)\n * @param index Index to edit. Without it, will look for the first index matching the\n * operation, which may lead to misleading results if multiple items have the same label\n */\n editLabel(\n args: {\n query?: string;\n variables?: string;\n headers?: string;\n operationName?: string;\n label?: string;\n favorite?: boolean;\n },\n index?: number,\n ): void;\n /**\n * Toggle the favorite state of an item from the history.\n * @param args An object containing the favorite state (`undefined` if it\n * should be unset) and properties that identify the history item that the\n * label should be applied to. (This can result in the label being applied\n * to multiple history items.)\n */\n toggleFavorite(args: {\n query?: string;\n variables?: string;\n headers?: string;\n operationName?: string;\n label?: string;\n favorite?: boolean;\n }): void;\n /**\n * Delete an operation from the history.\n * @param args The operation that was executed, consisting of the query,\n * variables, headers, and operation name.\n * @param clearFavorites This is only if you press the 'clear' button\n */\n deleteFromHistory(args: QueryStoreItem, clearFavorites?: boolean): void;\n /**\n * If you need to know when an item in history is set as active to customize\n * your application.\n */\n setActive(args: QueryStoreItem): void;\n };\n};\n\nconst HistoryContext = createContext<RefObject<\n StoreApi<HistoryContextType>\n> | null>(null);\n\ntype HistoryContextProviderProps = {\n children: ReactNode;\n /**\n * The maximum number of executed operations to store.\n * @default 20\n */\n maxHistoryLength?: number;\n};\n\n/**\n * The functions send the entire operation so users can customize their own application with\n * <HistoryContext.Provider value={customizedFunctions} /> and get access to the operation plus\n * any additional props they added for their needs (i.e., build their own functions that may save\n * to a backend instead of localStorage and might need an id property added to the QueryStoreItem)\n */\nexport function HistoryContextProvider({\n maxHistoryLength = 20,\n children,\n}: HistoryContextProviderProps) {\n const storage = useStorageContext();\n const { isFetching } = useExecutionContext({ nonNull: true });\n const { tabs, activeTabIndex } = useEditorContext({ nonNull: true });\n const activeTab = tabs[activeTabIndex];\n const storeRef = useRef<StoreApi<HistoryContextType>>(null!);\n\n if (storeRef.current === null) {\n storeRef.current = createHistoryStore(storage, maxHistoryLength);\n }\n\n useEffect(() => {\n if (!isFetching) {\n return;\n }\n const { addToHistory } = storeRef.current.getState().actions;\n addToHistory({\n query: activeTab.query ?? undefined,\n variables: activeTab.variables ?? undefined,\n headers: activeTab.headers ?? undefined,\n operationName: activeTab.operationName ?? undefined,\n });\n }, [isFetching, activeTab]);\n\n return (\n <HistoryContext.Provider value={storeRef}>\n {children}\n </HistoryContext.Provider>\n );\n}\n\nfunction useHistoryStore<T>(selector: (state: HistoryContextType) => T): T {\n const store = useContext(HistoryContext);\n if (!store) {\n throw new Error('Missing `HistoryContextProvider` in the tree');\n }\n return useStore(store.current, selector);\n}\n\nexport const useHistory = () => useHistoryStore(state => state.items);\nexport const useHistoryActions = () => useHistoryStore(state => state.actions);\n"],"names":["createHistoryStore","storage","maxHistoryLength","historyStore","HistoryStore","StorageAPI","createStore","set","items","queries","actions","addToHistory","operation","updateHistory","editLabel","index","toggleFavorite","setActive","item","deleteFromHistory","clearFavorites","deleteHistory","HistoryContext","createContext","HistoryContextProvider","t0","$","_c","t1","children","undefined","useStorageContext","t2","Symbol","for","nonNull","isFetching","useExecutionContext","t3","tabs","activeTabIndex","useEditorContext","activeTab","storeRef","useRef","current","t4","t5","getState","query","variables","headers","operationName","useEffect","t6","useHistoryStore","selector","store","useContext","Error","useStore","useHistory","_temp","useHistoryActions","_temp2","state"],"mappings":";;;;;;AAgBA,SAASA,mBACPC,SACAC,kBACA;AACMC,QAAAA;AAAAA;AAAAA,IAEJ,IAAIC,aAAaH,WAAW,IAAII,WAAW,IAAI,GAAGH,gBAAgB;AAAA;AAEpE,SAAOI,YAAgCC,CAAQ,SAAA;AAAA,IAC7CC,OAAOL,aAAaM;AAAAA,IACpBC,SAAS;AAAA,MACPC,aAAaC,WAAW;AACtBT,qBAAaU,cAAcD,SAAS;AACpC,cAAMJ,QAAQL,aAAaM;AACvB,YAAA;AAAA,UAAED;AAAAA,QAAAA,CAAO;AAAA,MACf;AAAA,MACAM,UAAUF,WAAWG,OAAO;AACbD,qBAAAA,UAAUF,WAAWG,KAAK;AACvC,cAAMP,QAAQL,aAAaM;AACvB,YAAA;AAAA,UAAED;AAAAA,QAAAA,CAAO;AAAA,MACf;AAAA,MACAQ,eAAeJ,WAAW;A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8C;AAAA,EAAA;AAEzDC,SAAAA,SAASH,MAAKZ,SAAUW,QAAQ;AAAC;AAGnC,MAAMK,aAAaA,MAAA;AAAA,SAAMN,gBAAAO,KAAoC;AAAC;AAC9D,MAAMC,oBAAoBA,MAAA;AAAA,SAAMR,gBAAAS,MAAsC;AAAC;AADpD,SAAAF,MAAAG,OAAA;AAAA,SAA+BA,MAAKzD;AAAA;AAC7B,SAAAwD,OAAAC,OAAA;AAAA,SAA+BA,MAAKvD;AAAA;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -2,4 +2,4 @@ import { GraphiQLPlugin } from '@graphiql/react';
|
|
|
2
2
|
import { History } from './components';
|
|
3
3
|
export declare const HISTORY_PLUGIN: GraphiQLPlugin;
|
|
4
4
|
export { History };
|
|
5
|
-
export {
|
|
5
|
+
export { HistoryContextProvider, useHistory, useHistoryActions, } from './context';
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { HistoryIcon } from "@graphiql/react";
|
|
2
2
|
/* empty css */
|
|
3
3
|
import { History } from "./components.js";
|
|
4
|
-
import {
|
|
4
|
+
import { HistoryContextProvider, useHistory, useHistoryActions } from "./context.js";
|
|
5
5
|
const HISTORY_PLUGIN = {
|
|
6
6
|
title: "History",
|
|
7
7
|
icon: HistoryIcon,
|
|
@@ -10,8 +10,8 @@ const HISTORY_PLUGIN = {
|
|
|
10
10
|
export {
|
|
11
11
|
HISTORY_PLUGIN,
|
|
12
12
|
History,
|
|
13
|
-
HistoryContext,
|
|
14
13
|
HistoryContextProvider,
|
|
15
|
-
|
|
14
|
+
useHistory,
|
|
15
|
+
useHistoryActions
|
|
16
16
|
};
|
|
17
17
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import { GraphiQLPlugin, HistoryIcon } from '@graphiql/react';\nimport './style.css';\n\nimport { History } from './components';\n\nexport const HISTORY_PLUGIN: GraphiQLPlugin = {\n title: 'History',\n icon: HistoryIcon,\n content: History,\n};\n\nexport { History };\n\nexport {\n
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import { GraphiQLPlugin, HistoryIcon } from '@graphiql/react';\nimport './style.css';\n\nimport { History } from './components';\n\nexport const HISTORY_PLUGIN: GraphiQLPlugin = {\n title: 'History',\n icon: HistoryIcon,\n content: History,\n};\n\nexport { History };\n\nexport {\n HistoryContextProvider,\n useHistory,\n useHistoryActions,\n} from './context';\n"],"names":["HISTORY_PLUGIN","title","icon","HistoryIcon","content","History"],"mappings":";;;;AAKO,MAAMA,iBAAiC;AAAA,EAC5CC,OAAO;AAAA,EACPC,MAAMC;AAAAA,EACNC,SAASC;AACX;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphiql/plugin-history",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3-canary-ee3ef668.0",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -41,7 +41,8 @@
|
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"react-compiler-runtime": "19.1.0-rc.1",
|
|
43
43
|
"@graphiql/toolkit": "^0.11.2",
|
|
44
|
-
"@graphiql/react": "^0.32.0"
|
|
44
|
+
"@graphiql/react": "^0.32.2-canary-ee3ef668.0",
|
|
45
|
+
"zustand": "^5"
|
|
45
46
|
},
|
|
46
47
|
"devDependencies": {
|
|
47
48
|
"@testing-library/react": "^16.1.0",
|