@graphiql/plugin-history 1.0.0-beta.0 → 1.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/components.js +375 -358
- package/dist/components.js.map +1 -1
- package/dist/context.js +108 -126
- package/dist/context.js.map +1 -1
- package/dist/index.js +11 -14
- package/dist/index.js.map +1 -1
- package/dist/style.css +3 -1
- package/package.json +23 -15
package/dist/components.js
CHANGED
|
@@ -1,376 +1,393 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useHistory, useHistoryActions } from "./context.js";
|
|
2
|
+
import { Button, CloseIcon, MethodPill, PanelHeader, PenIcon, StarFilledIcon, StarIcon, Tooltip, TrashIcon, UnStyledButton, pick, useGraphiQL } from "@graphiql/react";
|
|
2
3
|
import { c } from "react-compiler-runtime";
|
|
3
|
-
import { useRef, useState
|
|
4
|
+
import { useEffect, useRef, useState } from "react";
|
|
4
5
|
import { clsx } from "clsx";
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
6
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
//#region src/components.tsx
|
|
8
|
+
var History = () => {
|
|
9
|
+
const $ = c(29);
|
|
10
|
+
const all = useHistory();
|
|
11
|
+
const { deleteFromHistory } = useHistoryActions();
|
|
12
|
+
let hasFavorites;
|
|
13
|
+
let hasItems;
|
|
14
|
+
let items;
|
|
15
|
+
let t0;
|
|
16
|
+
let t1;
|
|
17
|
+
let t2;
|
|
18
|
+
let t3;
|
|
19
|
+
let t4;
|
|
20
|
+
if ($[0] !== all || $[1] !== deleteFromHistory) {
|
|
21
|
+
items = all.slice().map(_temp).reverse();
|
|
22
|
+
const favorites = items.filter(_temp2);
|
|
23
|
+
if (favorites.length) items = items.filter(_temp3);
|
|
24
|
+
const handleClear = () => {
|
|
25
|
+
for (const item_2 of items) deleteFromHistory(item_2, true);
|
|
26
|
+
};
|
|
27
|
+
hasFavorites = Boolean(favorites.length);
|
|
28
|
+
hasItems = Boolean(items.length);
|
|
29
|
+
const clearButton = hasItems ? /* @__PURE__ */ jsx(Button, {
|
|
30
|
+
type: "button",
|
|
31
|
+
onClick: handleClear,
|
|
32
|
+
children: "Clear"
|
|
33
|
+
}) : void 0;
|
|
34
|
+
t0 = "History";
|
|
35
|
+
t1 = "graphiql-history";
|
|
36
|
+
if ($[10] !== clearButton) {
|
|
37
|
+
t2 = /* @__PURE__ */ jsx(PanelHeader, {
|
|
38
|
+
title: "History",
|
|
39
|
+
subtitle: "Last 20 runs.",
|
|
40
|
+
actions: clearButton
|
|
41
|
+
});
|
|
42
|
+
$[10] = clearButton;
|
|
43
|
+
$[11] = t2;
|
|
44
|
+
} else t2 = $[11];
|
|
45
|
+
if ($[12] !== hasFavorites || $[13] !== hasItems) {
|
|
46
|
+
t3 = !hasFavorites && !hasItems && /* @__PURE__ */ jsx("div", {
|
|
47
|
+
className: "graphiql-history-empty",
|
|
48
|
+
children: "No queries run yet."
|
|
49
|
+
});
|
|
50
|
+
$[12] = hasFavorites;
|
|
51
|
+
$[13] = hasItems;
|
|
52
|
+
$[14] = t3;
|
|
53
|
+
} else t3 = $[14];
|
|
54
|
+
t4 = hasFavorites && /* @__PURE__ */ jsx("ul", {
|
|
55
|
+
className: "graphiql-history-items",
|
|
56
|
+
children: favorites.map(_temp4)
|
|
57
|
+
});
|
|
58
|
+
$[0] = all;
|
|
59
|
+
$[1] = deleteFromHistory;
|
|
60
|
+
$[2] = hasFavorites;
|
|
61
|
+
$[3] = hasItems;
|
|
62
|
+
$[4] = items;
|
|
63
|
+
$[5] = t0;
|
|
64
|
+
$[6] = t1;
|
|
65
|
+
$[7] = t2;
|
|
66
|
+
$[8] = t3;
|
|
67
|
+
$[9] = t4;
|
|
68
|
+
} else {
|
|
69
|
+
hasFavorites = $[2];
|
|
70
|
+
hasItems = $[3];
|
|
71
|
+
items = $[4];
|
|
72
|
+
t0 = $[5];
|
|
73
|
+
t1 = $[6];
|
|
74
|
+
t2 = $[7];
|
|
75
|
+
t3 = $[8];
|
|
76
|
+
t4 = $[9];
|
|
77
|
+
}
|
|
78
|
+
let t5;
|
|
79
|
+
if ($[15] !== hasFavorites || $[16] !== hasItems) {
|
|
80
|
+
t5 = hasFavorites && hasItems && /* @__PURE__ */ jsx("div", { className: "graphiql-history-item-spacer" });
|
|
81
|
+
$[15] = hasFavorites;
|
|
82
|
+
$[16] = hasItems;
|
|
83
|
+
$[17] = t5;
|
|
84
|
+
} else t5 = $[17];
|
|
85
|
+
let t6;
|
|
86
|
+
if ($[18] !== hasItems || $[19] !== items) {
|
|
87
|
+
t6 = hasItems && /* @__PURE__ */ jsx("ul", {
|
|
88
|
+
className: "graphiql-history-items",
|
|
89
|
+
children: items.map(_temp5)
|
|
90
|
+
});
|
|
91
|
+
$[18] = hasItems;
|
|
92
|
+
$[19] = items;
|
|
93
|
+
$[20] = t6;
|
|
94
|
+
} else t6 = $[20];
|
|
95
|
+
let t7;
|
|
96
|
+
if ($[21] !== t0 || $[22] !== t1 || $[23] !== t2 || $[24] !== t3 || $[25] !== t4 || $[26] !== t5 || $[27] !== t6) {
|
|
97
|
+
t7 = /* @__PURE__ */ jsxs("section", {
|
|
98
|
+
"aria-label": t0,
|
|
99
|
+
className: t1,
|
|
100
|
+
children: [
|
|
101
|
+
t2,
|
|
102
|
+
t3,
|
|
103
|
+
t4,
|
|
104
|
+
t5,
|
|
105
|
+
t6
|
|
106
|
+
]
|
|
107
|
+
});
|
|
108
|
+
$[21] = t0;
|
|
109
|
+
$[22] = t1;
|
|
110
|
+
$[23] = t2;
|
|
111
|
+
$[24] = t3;
|
|
112
|
+
$[25] = t4;
|
|
113
|
+
$[26] = t5;
|
|
114
|
+
$[27] = t6;
|
|
115
|
+
$[28] = t7;
|
|
116
|
+
} else t7 = $[28];
|
|
117
|
+
return t7;
|
|
112
118
|
};
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
119
|
+
var HistoryItem = (props) => {
|
|
120
|
+
const $ = c(42);
|
|
121
|
+
const { editLabel, toggleFavorite, deleteFromHistory, setActive } = useHistoryActions();
|
|
122
|
+
let t0;
|
|
123
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
124
|
+
t0 = pick("headerEditor", "queryEditor", "variableEditor");
|
|
125
|
+
$[0] = t0;
|
|
126
|
+
} else t0 = $[0];
|
|
127
|
+
const { headerEditor, queryEditor, variableEditor } = useGraphiQL(t0);
|
|
128
|
+
const inputRef = useRef(null);
|
|
129
|
+
const buttonRef = useRef(null);
|
|
130
|
+
const editButtonRef = useRef(null);
|
|
131
|
+
const [isEditable, setIsEditable] = useState(false);
|
|
132
|
+
const wasEditable = useRef(false);
|
|
133
|
+
let t1;
|
|
134
|
+
let t2;
|
|
135
|
+
if ($[1] !== isEditable) {
|
|
136
|
+
t1 = () => {
|
|
137
|
+
if (isEditable) inputRef.current?.focus();
|
|
138
|
+
else if (wasEditable.current) editButtonRef.current?.focus();
|
|
139
|
+
wasEditable.current = isEditable;
|
|
140
|
+
};
|
|
141
|
+
t2 = [isEditable];
|
|
142
|
+
$[1] = isEditable;
|
|
143
|
+
$[2] = t1;
|
|
144
|
+
$[3] = t2;
|
|
145
|
+
} else {
|
|
146
|
+
t1 = $[2];
|
|
147
|
+
t2 = $[3];
|
|
148
|
+
}
|
|
149
|
+
useEffect(t1, t2);
|
|
150
|
+
let t3;
|
|
151
|
+
if ($[4] !== props.item.label || $[5] !== props.item.operationName || $[6] !== props.item.query) {
|
|
152
|
+
t3 = props.item.label || props.item.operationName || formatQuery(props.item.query);
|
|
153
|
+
$[4] = props.item.label;
|
|
154
|
+
$[5] = props.item.operationName;
|
|
155
|
+
$[6] = props.item.query;
|
|
156
|
+
$[7] = t3;
|
|
157
|
+
} else t3 = $[7];
|
|
158
|
+
const displayName = t3;
|
|
159
|
+
let t4;
|
|
160
|
+
if ($[8] !== editLabel || $[9] !== props.item) {
|
|
161
|
+
t4 = () => {
|
|
162
|
+
setIsEditable(false);
|
|
163
|
+
const { index, ...item } = props.item;
|
|
164
|
+
editLabel({
|
|
165
|
+
...item,
|
|
166
|
+
label: inputRef.current?.value
|
|
167
|
+
}, index);
|
|
168
|
+
};
|
|
169
|
+
$[8] = editLabel;
|
|
170
|
+
$[9] = props.item;
|
|
171
|
+
$[10] = t4;
|
|
172
|
+
} else t4 = $[10];
|
|
173
|
+
const handleSave = t4;
|
|
174
|
+
let t5;
|
|
175
|
+
if ($[11] === Symbol.for("react.memo_cache_sentinel")) {
|
|
176
|
+
t5 = () => {
|
|
177
|
+
setIsEditable(false);
|
|
178
|
+
};
|
|
179
|
+
$[11] = t5;
|
|
180
|
+
} else t5 = $[11];
|
|
181
|
+
const handleClose = t5;
|
|
182
|
+
let t6;
|
|
183
|
+
if ($[12] === Symbol.for("react.memo_cache_sentinel")) {
|
|
184
|
+
t6 = (e) => {
|
|
185
|
+
e.stopPropagation();
|
|
186
|
+
setIsEditable(true);
|
|
187
|
+
};
|
|
188
|
+
$[12] = t6;
|
|
189
|
+
} else t6 = $[12];
|
|
190
|
+
const handleEditLabel = t6;
|
|
191
|
+
let t7;
|
|
192
|
+
if ($[13] !== headerEditor || $[14] !== props.item || $[15] !== queryEditor || $[16] !== setActive || $[17] !== variableEditor) {
|
|
193
|
+
t7 = () => {
|
|
194
|
+
const { query, variables, headers } = props.item;
|
|
195
|
+
queryEditor?.setValue(query ?? "");
|
|
196
|
+
variableEditor?.setValue(variables ?? "");
|
|
197
|
+
headerEditor?.setValue(headers ?? "");
|
|
198
|
+
setActive(props.item);
|
|
199
|
+
};
|
|
200
|
+
$[13] = headerEditor;
|
|
201
|
+
$[14] = props.item;
|
|
202
|
+
$[15] = queryEditor;
|
|
203
|
+
$[16] = setActive;
|
|
204
|
+
$[17] = variableEditor;
|
|
205
|
+
$[18] = t7;
|
|
206
|
+
} else t7 = $[18];
|
|
207
|
+
const handleHistoryItemClick = t7;
|
|
208
|
+
let t8;
|
|
209
|
+
if ($[19] !== deleteFromHistory || $[20] !== props.item) {
|
|
210
|
+
t8 = (e_0) => {
|
|
211
|
+
e_0.stopPropagation();
|
|
212
|
+
deleteFromHistory(props.item);
|
|
213
|
+
};
|
|
214
|
+
$[19] = deleteFromHistory;
|
|
215
|
+
$[20] = props.item;
|
|
216
|
+
$[21] = t8;
|
|
217
|
+
} else t8 = $[21];
|
|
218
|
+
const handleDeleteItemFromHistory = t8;
|
|
219
|
+
let t9;
|
|
220
|
+
if ($[22] !== props.item || $[23] !== toggleFavorite) {
|
|
221
|
+
t9 = (e_1) => {
|
|
222
|
+
e_1.stopPropagation();
|
|
223
|
+
toggleFavorite(props.item);
|
|
224
|
+
};
|
|
225
|
+
$[22] = props.item;
|
|
226
|
+
$[23] = toggleFavorite;
|
|
227
|
+
$[24] = t9;
|
|
228
|
+
} else t9 = $[24];
|
|
229
|
+
const handleToggleFavorite = t9;
|
|
230
|
+
let t10;
|
|
231
|
+
if ($[25] !== props.item.variables) {
|
|
232
|
+
t10 = props.item.variables ? formatVariables(props.item.variables) : null;
|
|
233
|
+
$[25] = props.item.variables;
|
|
234
|
+
$[26] = t10;
|
|
235
|
+
} else t10 = $[26];
|
|
236
|
+
const variablesSnippet = t10;
|
|
237
|
+
const t11 = isEditable && "editable";
|
|
238
|
+
let t12;
|
|
239
|
+
if ($[27] !== t11) {
|
|
240
|
+
t12 = clsx("graphiql-history-item", t11);
|
|
241
|
+
$[27] = t11;
|
|
242
|
+
$[28] = t12;
|
|
243
|
+
} else t12 = $[28];
|
|
244
|
+
let t13;
|
|
245
|
+
if ($[29] !== displayName || $[30] !== editLabel || $[31] !== handleDeleteItemFromHistory || $[32] !== handleHistoryItemClick || $[33] !== handleSave || $[34] !== handleToggleFavorite || $[35] !== isEditable || $[36] !== props.item || $[37] !== variablesSnippet) {
|
|
246
|
+
t13 = isEditable ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
247
|
+
/* @__PURE__ */ jsx("input", {
|
|
248
|
+
type: "text",
|
|
249
|
+
defaultValue: props.item.label,
|
|
250
|
+
ref: inputRef,
|
|
251
|
+
onKeyDown: (e_2) => {
|
|
252
|
+
if (e_2.key === "Escape") setIsEditable(false);
|
|
253
|
+
else if (e_2.key === "Enter") {
|
|
254
|
+
setIsEditable(false);
|
|
255
|
+
editLabel({
|
|
256
|
+
...props.item,
|
|
257
|
+
label: e_2.currentTarget.value
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
},
|
|
261
|
+
placeholder: "Type a label"
|
|
262
|
+
}),
|
|
263
|
+
/* @__PURE__ */ jsx(UnStyledButton, {
|
|
264
|
+
type: "button",
|
|
265
|
+
ref: buttonRef,
|
|
266
|
+
onClick: handleSave,
|
|
267
|
+
children: "Save"
|
|
268
|
+
}),
|
|
269
|
+
/* @__PURE__ */ jsx(UnStyledButton, {
|
|
270
|
+
type: "button",
|
|
271
|
+
ref: buttonRef,
|
|
272
|
+
onClick: handleClose,
|
|
273
|
+
"aria-label": "Cancel",
|
|
274
|
+
children: /* @__PURE__ */ jsx(CloseIcon, { "aria-hidden": "true" })
|
|
275
|
+
})
|
|
276
|
+
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("div", {
|
|
277
|
+
className: "graphiql-history-item-inner",
|
|
278
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
279
|
+
className: "graphiql-history-item-row",
|
|
280
|
+
children: [props.item.operation && /* @__PURE__ */ jsx(MethodPill, {
|
|
281
|
+
operation: props.item.operation,
|
|
282
|
+
"aria-hidden": true
|
|
283
|
+
}), /* @__PURE__ */ jsx(Tooltip, {
|
|
284
|
+
label: "Set active",
|
|
285
|
+
children: /* @__PURE__ */ jsx(UnStyledButton, {
|
|
286
|
+
type: "button",
|
|
287
|
+
className: "graphiql-history-item-label",
|
|
288
|
+
onClick: handleHistoryItemClick,
|
|
289
|
+
"aria-label": "Set active",
|
|
290
|
+
children: displayName
|
|
291
|
+
})
|
|
292
|
+
})]
|
|
293
|
+
}), variablesSnippet && /* @__PURE__ */ jsx("div", {
|
|
294
|
+
className: "graphiql-history-item-meta",
|
|
295
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
296
|
+
className: "graphiql-history-item-variables",
|
|
297
|
+
children: variablesSnippet
|
|
298
|
+
})
|
|
299
|
+
})]
|
|
300
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
301
|
+
className: "graphiql-history-item-actions",
|
|
302
|
+
children: [
|
|
303
|
+
/* @__PURE__ */ jsx(Tooltip, {
|
|
304
|
+
label: "Edit label",
|
|
305
|
+
children: /* @__PURE__ */ jsx(UnStyledButton, {
|
|
306
|
+
ref: editButtonRef,
|
|
307
|
+
type: "button",
|
|
308
|
+
className: "graphiql-history-item-action",
|
|
309
|
+
onClick: handleEditLabel,
|
|
310
|
+
"aria-label": "Edit label",
|
|
311
|
+
children: /* @__PURE__ */ jsx(PenIcon, { "aria-hidden": "true" })
|
|
312
|
+
})
|
|
313
|
+
}),
|
|
314
|
+
/* @__PURE__ */ jsx(Tooltip, {
|
|
315
|
+
label: props.item.favorite ? "Remove favorite" : "Add favorite",
|
|
316
|
+
children: /* @__PURE__ */ jsx(UnStyledButton, {
|
|
317
|
+
type: "button",
|
|
318
|
+
className: "graphiql-history-item-action",
|
|
319
|
+
onClick: handleToggleFavorite,
|
|
320
|
+
"aria-label": props.item.favorite ? "Remove favorite" : "Add favorite",
|
|
321
|
+
children: props.item.favorite ? /* @__PURE__ */ jsx(StarFilledIcon, { "aria-hidden": "true" }) : /* @__PURE__ */ jsx(StarIcon, { "aria-hidden": "true" })
|
|
322
|
+
})
|
|
323
|
+
}),
|
|
324
|
+
/* @__PURE__ */ jsx(Tooltip, {
|
|
325
|
+
label: "Delete from history",
|
|
326
|
+
children: /* @__PURE__ */ jsx(UnStyledButton, {
|
|
327
|
+
type: "button",
|
|
328
|
+
className: "graphiql-history-item-action",
|
|
329
|
+
onClick: handleDeleteItemFromHistory,
|
|
330
|
+
"aria-label": "Delete from history",
|
|
331
|
+
children: /* @__PURE__ */ jsx(TrashIcon, { "aria-hidden": "true" })
|
|
332
|
+
})
|
|
333
|
+
})
|
|
334
|
+
]
|
|
335
|
+
})] });
|
|
336
|
+
$[29] = displayName;
|
|
337
|
+
$[30] = editLabel;
|
|
338
|
+
$[31] = handleDeleteItemFromHistory;
|
|
339
|
+
$[32] = handleHistoryItemClick;
|
|
340
|
+
$[33] = handleSave;
|
|
341
|
+
$[34] = handleToggleFavorite;
|
|
342
|
+
$[35] = isEditable;
|
|
343
|
+
$[36] = props.item;
|
|
344
|
+
$[37] = variablesSnippet;
|
|
345
|
+
$[38] = t13;
|
|
346
|
+
} else t13 = $[38];
|
|
347
|
+
let t14;
|
|
348
|
+
if ($[39] !== t12 || $[40] !== t13) {
|
|
349
|
+
t14 = /* @__PURE__ */ jsx("li", {
|
|
350
|
+
className: t12,
|
|
351
|
+
children: t13
|
|
352
|
+
});
|
|
353
|
+
$[39] = t12;
|
|
354
|
+
$[40] = t13;
|
|
355
|
+
$[41] = t14;
|
|
356
|
+
} else t14 = $[41];
|
|
357
|
+
return t14;
|
|
336
358
|
};
|
|
337
359
|
function formatQuery(query) {
|
|
338
|
-
|
|
360
|
+
return query?.split("\n").map((line) => line.replace(/#(.*)/, "")).join(" ").replaceAll("{", " { ").replaceAll("}", " } ").replaceAll(/[\s]{2,}/g, " ");
|
|
339
361
|
}
|
|
340
362
|
function formatVariables(variables) {
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
return variables.slice(0, 60);
|
|
350
|
-
}
|
|
363
|
+
try {
|
|
364
|
+
const parsed = JSON.parse(variables);
|
|
365
|
+
const entries = Object.entries(parsed);
|
|
366
|
+
if (!entries.length) return null;
|
|
367
|
+
return entries.slice(0, 3).map(([k, v]) => `${k}: ${JSON.stringify(v)}`).join(", ");
|
|
368
|
+
} catch {
|
|
369
|
+
return variables.slice(0, 60);
|
|
370
|
+
}
|
|
351
371
|
}
|
|
352
372
|
function _temp(item, i) {
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
373
|
+
return {
|
|
374
|
+
...item,
|
|
375
|
+
index: i
|
|
376
|
+
};
|
|
357
377
|
}
|
|
358
378
|
function _temp2(item_0) {
|
|
359
|
-
|
|
379
|
+
return item_0.favorite;
|
|
360
380
|
}
|
|
361
381
|
function _temp3(item_1) {
|
|
362
|
-
|
|
382
|
+
return !item_1.favorite;
|
|
363
383
|
}
|
|
364
384
|
function _temp4(item_3) {
|
|
365
|
-
|
|
385
|
+
return /* @__PURE__ */ jsx(HistoryItem, { item: item_3 }, item_3.index);
|
|
366
386
|
}
|
|
367
387
|
function _temp5(item_4) {
|
|
368
|
-
|
|
388
|
+
return /* @__PURE__ */ jsx(HistoryItem, { item: item_4 }, item_4.index);
|
|
369
389
|
}
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
formatVariables
|
|
375
|
-
};
|
|
376
|
-
//# sourceMappingURL=components.js.map
|
|
390
|
+
//#endregion
|
|
391
|
+
export { History, HistoryItem, formatQuery, formatVariables };
|
|
392
|
+
|
|
393
|
+
//# sourceMappingURL=components.js.map
|