@graphiql/plugin-history 1.0.0-beta.1 → 1.0.0-beta.3

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