@graphiql/plugin-doc-explorer 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.
- package/LICENSE +21 -0
- package/dist/components/argument.js +88 -92
- package/dist/components/argument.js.map +1 -1
- package/dist/components/arguments-list.js +226 -237
- package/dist/components/arguments-list.js.map +1 -1
- package/dist/components/breadcrumb.js +59 -52
- package/dist/components/breadcrumb.js.map +1 -1
- package/dist/components/default-value.js +63 -74
- package/dist/components/default-value.js.map +1 -1
- package/dist/components/deprecation-reason.js +27 -21
- package/dist/components/deprecation-reason.js.map +1 -1
- package/dist/components/directive.js +20 -23
- package/dist/components/directive.js.map +1 -1
- package/dist/components/doc-explorer.js +219 -259
- package/dist/components/doc-explorer.js.map +1 -1
- package/dist/components/field-card.js +103 -97
- package/dist/components/field-card.js.map +1 -1
- package/dist/components/field-documentation.js +118 -135
- package/dist/components/field-documentation.js.map +1 -1
- package/dist/components/field-link.js +37 -39
- package/dist/components/field-link.js.map +1 -1
- package/dist/components/fields-list.js +216 -226
- package/dist/components/fields-list.js.map +1 -1
- package/dist/components/schema-documentation.js +263 -224
- package/dist/components/schema-documentation.js.map +1 -1
- package/dist/components/search-row.js +287 -268
- package/dist/components/search-row.js.map +1 -1
- package/dist/components/search.js +342 -345
- package/dist/components/search.js.map +1 -1
- package/dist/components/section.js +59 -69
- package/dist/components/section.js.map +1 -1
- package/dist/components/type-card.js +104 -107
- package/dist/components/type-card.js.map +1 -1
- package/dist/components/type-documentation.js +340 -363
- package/dist/components/type-documentation.js.map +1 -1
- package/dist/components/type-link.js +38 -39
- package/dist/components/type-link.js.map +1 -1
- package/dist/components/utils.js +15 -20
- package/dist/components/utils.js.map +1 -1
- package/dist/context.js +205 -285
- package/dist/context.js.map +1 -1
- package/dist/index.js +7 -31
- package/dist/schema-reference.js +48 -54
- package/dist/schema-reference.js.map +1 -1
- package/dist/style.css +24 -28
- package/package.json +25 -19
- package/dist/index.js.map +0 -1
|
@@ -1,282 +1,301 @@
|
|
|
1
|
-
import { jsxs, jsx, Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { c } from "react-compiler-runtime";
|
|
3
|
-
import { useRef, useState, useEffect } from "react";
|
|
4
|
-
import { isObjectType, isInterfaceType, isInputObjectType } from "graphql";
|
|
5
|
-
import { ComboboxOptions, ComboboxOption, ComboboxInput, Combobox } from "@headlessui/react";
|
|
6
|
-
import { debounce, formatShortcutForOS, KEY_MAP, typeCategory, MagnifyingGlassIcon, KeycapHint } from "@graphiql/react";
|
|
7
1
|
import { useDocExplorer, useDocExplorerActions } from "../context.js";
|
|
8
|
-
import { useSearchResults } from "./search.js";
|
|
9
2
|
import { renderType } from "./utils.js";
|
|
3
|
+
import { useSearchResults } from "./search.js";
|
|
10
4
|
/* empty css */
|
|
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
|
-
|
|
112
|
-
|
|
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
|
-
|
|
5
|
+
import { c } from "react-compiler-runtime";
|
|
6
|
+
import { KEY_MAP, KeycapHint, MagnifyingGlassIcon, debounce, formatShortcutForOS, typeCategory } from "@graphiql/react";
|
|
7
|
+
import { isInputObjectType, isInterfaceType, isObjectType } from "graphql";
|
|
8
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
import { useEffect, useRef, useState } from "react";
|
|
10
|
+
import { Combobox, ComboboxInput, ComboboxOption, ComboboxOptions } from "@headlessui/react";
|
|
11
|
+
//#region src/components/search-row.tsx
|
|
12
|
+
var SearchRow = () => {
|
|
13
|
+
const $ = c(39);
|
|
14
|
+
const explorerNavStack = useDocExplorer();
|
|
15
|
+
const { push } = useDocExplorerActions();
|
|
16
|
+
const inputRef = useRef(null);
|
|
17
|
+
const getSearchResults = useSearchResults();
|
|
18
|
+
const [searchValue, setSearchValue] = useState("");
|
|
19
|
+
let t0;
|
|
20
|
+
if ($[0] !== getSearchResults || $[1] !== searchValue) {
|
|
21
|
+
t0 = () => getSearchResults(searchValue);
|
|
22
|
+
$[0] = getSearchResults;
|
|
23
|
+
$[1] = searchValue;
|
|
24
|
+
$[2] = t0;
|
|
25
|
+
} else t0 = $[2];
|
|
26
|
+
const [results, setResults] = useState(t0);
|
|
27
|
+
let t1;
|
|
28
|
+
if ($[3] !== getSearchResults) {
|
|
29
|
+
t1 = debounce(200, (search) => {
|
|
30
|
+
setResults(getSearchResults(search));
|
|
31
|
+
});
|
|
32
|
+
$[3] = getSearchResults;
|
|
33
|
+
$[4] = t1;
|
|
34
|
+
} else t1 = $[4];
|
|
35
|
+
const debouncedGetSearchResults = t1;
|
|
36
|
+
const [isFocused, setIsFocused] = useState(false);
|
|
37
|
+
let t2;
|
|
38
|
+
let t3;
|
|
39
|
+
if ($[5] !== debouncedGetSearchResults || $[6] !== searchValue) {
|
|
40
|
+
t2 = () => {
|
|
41
|
+
debouncedGetSearchResults(searchValue);
|
|
42
|
+
return debouncedGetSearchResults.cancel;
|
|
43
|
+
};
|
|
44
|
+
t3 = [debouncedGetSearchResults, searchValue];
|
|
45
|
+
$[5] = debouncedGetSearchResults;
|
|
46
|
+
$[6] = searchValue;
|
|
47
|
+
$[7] = t2;
|
|
48
|
+
$[8] = t3;
|
|
49
|
+
} else {
|
|
50
|
+
t2 = $[7];
|
|
51
|
+
t3 = $[8];
|
|
52
|
+
}
|
|
53
|
+
useEffect(t2, t3);
|
|
54
|
+
let navItem;
|
|
55
|
+
let onSelect;
|
|
56
|
+
let t4;
|
|
57
|
+
if ($[9] !== explorerNavStack || $[10] !== push) {
|
|
58
|
+
navItem = explorerNavStack.at(-1);
|
|
59
|
+
let t5;
|
|
60
|
+
if ($[14] !== push) {
|
|
61
|
+
t5 = (def) => {
|
|
62
|
+
if (!def) return;
|
|
63
|
+
push("field" in def ? {
|
|
64
|
+
name: def.field.name,
|
|
65
|
+
def: def.field
|
|
66
|
+
} : {
|
|
67
|
+
name: def.type.name,
|
|
68
|
+
def: def.type
|
|
69
|
+
});
|
|
70
|
+
};
|
|
71
|
+
$[14] = push;
|
|
72
|
+
$[15] = t5;
|
|
73
|
+
} else t5 = $[15];
|
|
74
|
+
onSelect = t5;
|
|
75
|
+
t4 = explorerNavStack.length === 1 || isObjectType(navItem.def) || isInterfaceType(navItem.def) || isInputObjectType(navItem.def);
|
|
76
|
+
$[9] = explorerNavStack;
|
|
77
|
+
$[10] = push;
|
|
78
|
+
$[11] = navItem;
|
|
79
|
+
$[12] = onSelect;
|
|
80
|
+
$[13] = t4;
|
|
81
|
+
} else {
|
|
82
|
+
navItem = $[11];
|
|
83
|
+
onSelect = $[12];
|
|
84
|
+
t4 = $[13];
|
|
85
|
+
}
|
|
86
|
+
if (!t4) return null;
|
|
87
|
+
let t5;
|
|
88
|
+
if ($[16] === Symbol.for("react.memo_cache_sentinel")) {
|
|
89
|
+
t5 = formatShortcutForOS(KEY_MAP.searchInDocs.key).split("-");
|
|
90
|
+
$[16] = t5;
|
|
91
|
+
} else t5 = $[16];
|
|
92
|
+
const shortcutKeys = t5;
|
|
93
|
+
const t6 = `Search ${navItem.name}...`;
|
|
94
|
+
let t7;
|
|
95
|
+
let t8;
|
|
96
|
+
if ($[17] === Symbol.for("react.memo_cache_sentinel")) {
|
|
97
|
+
t7 = () => {
|
|
98
|
+
inputRef.current.focus();
|
|
99
|
+
};
|
|
100
|
+
t8 = /* @__PURE__ */ jsx(MagnifyingGlassIcon, { "aria-hidden": "true" });
|
|
101
|
+
$[17] = t7;
|
|
102
|
+
$[18] = t8;
|
|
103
|
+
} else {
|
|
104
|
+
t7 = $[17];
|
|
105
|
+
t8 = $[18];
|
|
106
|
+
}
|
|
107
|
+
let t10;
|
|
108
|
+
let t11;
|
|
109
|
+
let t9;
|
|
110
|
+
if ($[19] === Symbol.for("react.memo_cache_sentinel")) {
|
|
111
|
+
t9 = (event) => setSearchValue(event.target.value);
|
|
112
|
+
t10 = () => setIsFocused(true);
|
|
113
|
+
t11 = () => setIsFocused(false);
|
|
114
|
+
$[19] = t10;
|
|
115
|
+
$[20] = t11;
|
|
116
|
+
$[21] = t9;
|
|
117
|
+
} else {
|
|
118
|
+
t10 = $[19];
|
|
119
|
+
t11 = $[20];
|
|
120
|
+
t9 = $[21];
|
|
121
|
+
}
|
|
122
|
+
let t12;
|
|
123
|
+
if ($[22] !== searchValue) {
|
|
124
|
+
t12 = /* @__PURE__ */ jsx(ComboboxInput, {
|
|
125
|
+
autoComplete: "off",
|
|
126
|
+
onChange: t9,
|
|
127
|
+
onFocus: t10,
|
|
128
|
+
onBlur: t11,
|
|
129
|
+
placeholder: "Search schema",
|
|
130
|
+
ref: inputRef,
|
|
131
|
+
value: searchValue,
|
|
132
|
+
"data-cy": "doc-explorer-input"
|
|
133
|
+
});
|
|
134
|
+
$[22] = searchValue;
|
|
135
|
+
$[23] = t12;
|
|
136
|
+
} else t12 = $[23];
|
|
137
|
+
let t13;
|
|
138
|
+
if ($[24] !== isFocused || $[25] !== searchValue || $[26] !== shortcutKeys) {
|
|
139
|
+
t13 = !isFocused && !searchValue && /* @__PURE__ */ jsx(KeycapHint, {
|
|
140
|
+
keys: shortcutKeys,
|
|
141
|
+
ariaLabel: "Search docs shortcut"
|
|
142
|
+
});
|
|
143
|
+
$[24] = isFocused;
|
|
144
|
+
$[25] = searchValue;
|
|
145
|
+
$[26] = shortcutKeys;
|
|
146
|
+
$[27] = t13;
|
|
147
|
+
} else t13 = $[27];
|
|
148
|
+
let t14;
|
|
149
|
+
if ($[28] !== t12 || $[29] !== t13) {
|
|
150
|
+
t14 = /* @__PURE__ */ jsxs("div", {
|
|
151
|
+
className: "graphiql-doc-explorer-search-row-input",
|
|
152
|
+
onClick: t7,
|
|
153
|
+
children: [
|
|
154
|
+
t8,
|
|
155
|
+
t12,
|
|
156
|
+
t13
|
|
157
|
+
]
|
|
158
|
+
});
|
|
159
|
+
$[28] = t12;
|
|
160
|
+
$[29] = t13;
|
|
161
|
+
$[30] = t14;
|
|
162
|
+
} else t14 = $[30];
|
|
163
|
+
let t15;
|
|
164
|
+
if ($[31] !== isFocused || $[32] !== results) {
|
|
165
|
+
t15 = isFocused && /* @__PURE__ */ jsxs(ComboboxOptions, {
|
|
166
|
+
className: "graphiql-doc-explorer-search-row-listbox",
|
|
167
|
+
"data-cy": "doc-explorer-list",
|
|
168
|
+
children: [
|
|
169
|
+
results.within.length + results.types.length + results.fields.length === 0 ? /* @__PURE__ */ jsx("div", {
|
|
170
|
+
className: "graphiql-doc-explorer-search-empty",
|
|
171
|
+
children: "No results found"
|
|
172
|
+
}) : results.within.map(_temp),
|
|
173
|
+
results.within.length > 0 && results.types.length + results.fields.length > 0 ? /* @__PURE__ */ jsx("div", {
|
|
174
|
+
className: "graphiql-doc-explorer-search-divider",
|
|
175
|
+
children: "Other results"
|
|
176
|
+
}) : null,
|
|
177
|
+
results.types.map(_temp2),
|
|
178
|
+
results.fields.map(_temp3)
|
|
179
|
+
]
|
|
180
|
+
});
|
|
181
|
+
$[31] = isFocused;
|
|
182
|
+
$[32] = results;
|
|
183
|
+
$[33] = t15;
|
|
184
|
+
} else t15 = $[33];
|
|
185
|
+
let t16;
|
|
186
|
+
if ($[34] !== onSelect || $[35] !== t14 || $[36] !== t15 || $[37] !== t6) {
|
|
187
|
+
t16 = /* @__PURE__ */ jsx("div", {
|
|
188
|
+
className: "graphiql-doc-explorer-search-row-wrapper",
|
|
189
|
+
children: /* @__PURE__ */ jsxs(Combobox, {
|
|
190
|
+
as: "div",
|
|
191
|
+
className: "graphiql-doc-explorer-search-row",
|
|
192
|
+
onChange: onSelect,
|
|
193
|
+
"aria-label": t6,
|
|
194
|
+
children: [t14, t15]
|
|
195
|
+
})
|
|
196
|
+
});
|
|
197
|
+
$[34] = onSelect;
|
|
198
|
+
$[35] = t14;
|
|
199
|
+
$[36] = t15;
|
|
200
|
+
$[37] = t6;
|
|
201
|
+
$[38] = t16;
|
|
202
|
+
} else t16 = $[38];
|
|
203
|
+
return t16;
|
|
195
204
|
};
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
}
|
|
218
|
-
return t2;
|
|
205
|
+
var SearchType = (t0) => {
|
|
206
|
+
const $ = c(5);
|
|
207
|
+
const { type } = t0;
|
|
208
|
+
let t1;
|
|
209
|
+
if ($[0] !== type) {
|
|
210
|
+
t1 = typeCategory(type);
|
|
211
|
+
$[0] = type;
|
|
212
|
+
$[1] = t1;
|
|
213
|
+
} else t1 = $[1];
|
|
214
|
+
let t2;
|
|
215
|
+
if ($[2] !== t1 || $[3] !== type.name) {
|
|
216
|
+
t2 = /* @__PURE__ */ jsx("span", {
|
|
217
|
+
className: "graphiql-doc-explorer-search-type",
|
|
218
|
+
"data-type-kind": t1,
|
|
219
|
+
children: type.name
|
|
220
|
+
});
|
|
221
|
+
$[2] = t1;
|
|
222
|
+
$[3] = type.name;
|
|
223
|
+
$[4] = t2;
|
|
224
|
+
} else t2 = $[4];
|
|
225
|
+
return t2;
|
|
219
226
|
};
|
|
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
|
-
$[5] = t2;
|
|
257
|
-
$[6] = t3;
|
|
258
|
-
} else {
|
|
259
|
-
t3 = $[6];
|
|
260
|
-
}
|
|
261
|
-
return t3;
|
|
227
|
+
var SearchField = (t0) => {
|
|
228
|
+
const $ = c(7);
|
|
229
|
+
const { field, argument } = t0;
|
|
230
|
+
let t1;
|
|
231
|
+
if ($[0] !== field.name) {
|
|
232
|
+
t1 = /* @__PURE__ */ jsx("span", {
|
|
233
|
+
className: "graphiql-doc-explorer-search-field",
|
|
234
|
+
children: field.name
|
|
235
|
+
});
|
|
236
|
+
$[0] = field.name;
|
|
237
|
+
$[1] = t1;
|
|
238
|
+
} else t1 = $[1];
|
|
239
|
+
let t2;
|
|
240
|
+
if ($[2] !== argument) {
|
|
241
|
+
t2 = argument ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
242
|
+
"(",
|
|
243
|
+
/* @__PURE__ */ jsx("span", {
|
|
244
|
+
className: "graphiql-doc-explorer-search-argument",
|
|
245
|
+
children: argument.name
|
|
246
|
+
}),
|
|
247
|
+
":",
|
|
248
|
+
" ",
|
|
249
|
+
renderType(argument.type, _temp4),
|
|
250
|
+
")"
|
|
251
|
+
] }) : null;
|
|
252
|
+
$[2] = argument;
|
|
253
|
+
$[3] = t2;
|
|
254
|
+
} else t2 = $[3];
|
|
255
|
+
let t3;
|
|
256
|
+
if ($[4] !== t1 || $[5] !== t2) {
|
|
257
|
+
t3 = /* @__PURE__ */ jsxs(Fragment, { children: [t1, t2] });
|
|
258
|
+
$[4] = t1;
|
|
259
|
+
$[5] = t2;
|
|
260
|
+
$[6] = t3;
|
|
261
|
+
} else t3 = $[6];
|
|
262
|
+
return t3;
|
|
262
263
|
};
|
|
263
264
|
function _temp(result, i) {
|
|
264
|
-
|
|
265
|
+
return /* @__PURE__ */ jsx(ComboboxOption, {
|
|
266
|
+
value: result,
|
|
267
|
+
"data-cy": "doc-explorer-option",
|
|
268
|
+
children: /* @__PURE__ */ jsx(SearchField, {
|
|
269
|
+
field: result.field,
|
|
270
|
+
argument: result.argument
|
|
271
|
+
})
|
|
272
|
+
}, `within-${i}`);
|
|
265
273
|
}
|
|
266
274
|
function _temp2(result_0, i_0) {
|
|
267
|
-
|
|
275
|
+
return /* @__PURE__ */ jsx(ComboboxOption, {
|
|
276
|
+
value: result_0,
|
|
277
|
+
"data-cy": "doc-explorer-option",
|
|
278
|
+
children: /* @__PURE__ */ jsx(SearchType, { type: result_0.type })
|
|
279
|
+
}, `type-${i_0}`);
|
|
268
280
|
}
|
|
269
281
|
function _temp3(result_1, i_1) {
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
282
|
+
return /* @__PURE__ */ jsxs(ComboboxOption, {
|
|
283
|
+
value: result_1,
|
|
284
|
+
"data-cy": "doc-explorer-option",
|
|
285
|
+
children: [
|
|
286
|
+
/* @__PURE__ */ jsx(SearchType, { type: result_1.type }),
|
|
287
|
+
".",
|
|
288
|
+
/* @__PURE__ */ jsx(SearchField, {
|
|
289
|
+
field: result_1.field,
|
|
290
|
+
argument: result_1.argument
|
|
291
|
+
})
|
|
292
|
+
]
|
|
293
|
+
}, `field-${i_1}`);
|
|
275
294
|
}
|
|
276
295
|
function _temp4(namedType) {
|
|
277
|
-
|
|
296
|
+
return /* @__PURE__ */ jsx(SearchType, { type: namedType });
|
|
278
297
|
}
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
//# sourceMappingURL=search-row.js.map
|
|
298
|
+
//#endregion
|
|
299
|
+
export { SearchRow };
|
|
300
|
+
|
|
301
|
+
//# sourceMappingURL=search-row.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search-row.js","sources":["../../src/components/search-row.tsx"],"sourcesContent":["import { FC, useEffect, useRef, useState } from 'react';\nimport {\n GraphQLArgument,\n GraphQLField,\n GraphQLInputField,\n GraphQLNamedType,\n isInputObjectType,\n isInterfaceType,\n isObjectType,\n} from 'graphql';\nimport {\n Combobox,\n ComboboxInput,\n ComboboxOptions,\n ComboboxOption,\n} from '@headlessui/react';\nimport {\n formatShortcutForOS,\n MagnifyingGlassIcon,\n KeycapHint,\n debounce,\n KEY_MAP,\n typeCategory,\n} from '@graphiql/react';\nimport { useDocExplorer, useDocExplorerActions } from '../context';\nimport { useSearchResults } from './search';\nimport { renderType } from './utils';\nimport './search-row.css';\n\ntype TypeMatch = { type: GraphQLNamedType };\ntype FieldMatch = {\n type: GraphQLNamedType;\n field: GraphQLField<unknown, unknown> | GraphQLInputField;\n argument?: GraphQLArgument;\n};\n\nexport const SearchRow: FC = () => {\n const explorerNavStack = useDocExplorer();\n const { push } = useDocExplorerActions();\n\n const inputRef = useRef<HTMLInputElement>(null!);\n const getSearchResults = useSearchResults();\n const [searchValue, setSearchValue] = useState('');\n const [results, setResults] = useState(() => getSearchResults(searchValue));\n const debouncedGetSearchResults = debounce(200, (search: string) => {\n setResults(getSearchResults(search));\n });\n const [isFocused, setIsFocused] = useState(false);\n\n useEffect(() => {\n debouncedGetSearchResults(searchValue);\n }, [debouncedGetSearchResults, searchValue]);\n\n const navItem = explorerNavStack.at(-1)!;\n\n const onSelect = (def: TypeMatch | FieldMatch | null) => {\n if (!def) {\n return;\n }\n push(\n 'field' in def\n ? { name: def.field.name, def: def.field }\n : { name: def.type.name, def: def.type },\n );\n };\n\n const shouldShow =\n explorerNavStack.length === 1 ||\n isObjectType(navItem.def) ||\n isInterfaceType(navItem.def) ||\n isInputObjectType(navItem.def);\n\n if (!shouldShow) {\n return null;\n }\n\n const shortcutKeys = formatShortcutForOS(KEY_MAP.searchInDocs.key).split('-');\n\n return (\n <div className=\"graphiql-doc-explorer-search-row-wrapper\">\n <Combobox\n as=\"div\"\n className=\"graphiql-doc-explorer-search-row\"\n onChange={onSelect}\n aria-label={`Search ${navItem.name}...`}\n >\n <div\n className=\"graphiql-doc-explorer-search-row-input\"\n onClick={() => {\n inputRef.current.focus();\n }}\n >\n <MagnifyingGlassIcon aria-hidden=\"true\" />\n <ComboboxInput\n autoComplete=\"off\"\n onChange={event => setSearchValue(event.target.value)}\n onFocus={() => setIsFocused(true)}\n onBlur={() => setIsFocused(false)}\n placeholder=\"Search schema\"\n ref={inputRef}\n value={searchValue}\n data-cy=\"doc-explorer-input\"\n />\n {!isFocused && !searchValue && (\n <KeycapHint keys={shortcutKeys} ariaLabel=\"Search docs shortcut\" />\n )}\n </div>\n {isFocused && (\n <ComboboxOptions\n className=\"graphiql-doc-explorer-search-row-listbox\"\n data-cy=\"doc-explorer-list\"\n >\n {results.within.length +\n results.types.length +\n results.fields.length ===\n 0 ? (\n <div className=\"graphiql-doc-explorer-search-empty\">\n No results found\n </div>\n ) : (\n results.within.map((result, i) => (\n <ComboboxOption\n key={`within-${i}`}\n value={result}\n data-cy=\"doc-explorer-option\"\n >\n <SearchField\n field={result.field}\n argument={result.argument}\n />\n </ComboboxOption>\n ))\n )}\n {results.within.length > 0 &&\n results.types.length + results.fields.length > 0 ? (\n <div className=\"graphiql-doc-explorer-search-divider\">\n Other results\n </div>\n ) : null}\n {results.types.map((result, i) => (\n <ComboboxOption\n key={`type-${i}`}\n value={result}\n data-cy=\"doc-explorer-option\"\n >\n <SearchType type={result.type} />\n </ComboboxOption>\n ))}\n {results.fields.map((result, i) => (\n <ComboboxOption\n key={`field-${i}`}\n value={result}\n data-cy=\"doc-explorer-option\"\n >\n <SearchType type={result.type} />.\n <SearchField field={result.field} argument={result.argument} />\n </ComboboxOption>\n ))}\n </ComboboxOptions>\n )}\n </Combobox>\n </div>\n );\n};\n\nconst SearchType: FC<{ type: GraphQLNamedType }> = ({ type }) => (\n <span\n className=\"graphiql-doc-explorer-search-type\"\n data-type-kind={typeCategory(type)}\n >\n {type.name}\n </span>\n);\n\ntype SearchFieldProps = {\n field: GraphQLField<unknown, unknown> | GraphQLInputField;\n argument?: GraphQLArgument;\n};\n\nconst SearchField: FC<SearchFieldProps> = ({ field, argument }) => {\n return (\n <>\n <span className=\"graphiql-doc-explorer-search-field\">{field.name}</span>\n {argument ? (\n <>\n (\n <span className=\"graphiql-doc-explorer-search-argument\">\n {argument.name}\n </span>\n :{' '}\n {renderType(argument.type, namedType => (\n <SearchType type={namedType} />\n ))}\n )\n </>\n ) : null}\n </>\n );\n};\n"],"names":["SearchRow","$","_c","explorerNavStack","useDocExplorer","push","useDocExplorerActions","inputRef","useRef","getSearchResults","useSearchResults","searchValue","setSearchValue","useState","t0","results","setResults","t1","debounce","search","debouncedGetSearchResults","isFocused","setIsFocused","t2","t3","useEffect","navItem","onSelect","t4","at","t5","def","name","field","type","length","isObjectType","isInterfaceType","isInputObjectType","shouldShow","Symbol","for","formatShortcutForOS","KEY_MAP","searchInDocs","key","split","shortcutKeys","t6","t7","t8","current","focus","t10","t11","t9","event","target","value","t12","t13","t14","t15","within","types","fields","map","_temp","_temp2","_temp3","t16","SearchType","typeCategory","SearchField","argument","renderType","_temp4","result","i","result_0","i_0","result_1","i_1","namedType"],"mappings":";;;;;;;;;;AAoCO,MAAMA,YAAgBA,MAAA;AAAAC,QAAAA,IAAAC,EAAA,EAAA;AAC3B,QAAAC,mBAAyBC,eAAe;AACxC,QAAA;AAAA,IAAAC;AAAAA,MAAiBC,sBAAsB;AAEvCC,QAAAA,WAAiBC,OAAA,IAA8B;AAC/C,QAAAC,mBAAyBC,iBAAiB;AAC1C,QAAA,CAAAC,aAAAC,cAAA,IAAsCC,SAAS,EAAE;AAAEC,MAAAA;AAAA,MAAAb,EAAAQ,CAAAA,MAAAA,oBAAAR,SAAAU,aAAA;AACZG,SAAAA,MAAML,iBAAiBE,WAAW;AAACV,WAAAQ;AAAAR,WAAAU;AAAAV,WAAAa;AAAAA,EAAAA,OAAA;AAAAA,SAAAb,EAAA,CAAA;AAAA,EAAA;AAA1E,QAAA,CAAAc,SAAAC,UAAA,IAA8BH,SAASC,EAAmC;AAAEG,MAAAA;AAAAhB,MAAAA,SAAAQ,kBAAA;AAC1CS,SAAAA,SAAA,KAAAC,CAAA,WAAA;AACrBV,iBAAAA,iBAAiBU,MAAM,CAAC;AAAA,IAAA,CACpC;AAAClB,WAAAQ;AAAAR,WAAAgB;AAAAA,EAAAA,OAAA;AAAAA,SAAAhB,EAAA,CAAA;AAAA,EAAA;AAFF,QAAAmB,4BAAkCH;AAGlC,QAAA,CAAAI,WAAAC,YAAA,IAAkCT,cAAc;AAAEU,MAAAA;AAAAC,MAAAA;AAAA,MAAAvB,EAAAmB,CAAAA,MAAAA,6BAAAnB,SAAAU,aAAA;AAExCY,SAAAA,MAAA;AACRH,gCAA0BT,WAAW;A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EAAA,MAAAA,SAAM3C,KAC1B,CAAA,EALe4C,GAAAA,QAAAA,GAAC,EAKhB;AAAiB;AA9GF,SAAAT,OAAAY,UAAAC,KAAA;AAAA,SAiHd,qBAAA,gBAAA,EAEQL,iBACC,WAAA,uBAER,UAAA;AAAA,IAAC,oBAAA,YAAA,EAAiB,MAAAA,SAAM3C,KAAS,CAAA;AAAA,IAAA;AAAA,wBAChC,aAAmB,EAAA,OAAA2C,SAAM5C,OAAkB,UAAA4C,SAAMH,SAAS,CAAA;AAAA,gBAL7CI,GAAC,EAMjB;AAAiB;AAuBW,SAAAF,OAAAO,WAAA;AAY9B,SAAA,oBAAC,YAAiBA,EAAAA,MAAAA,UAAa,CAAA;AAAA;"}
|
|
1
|
+
{"version":3,"file":"search-row.js","names":["FC","useEffect","useRef","useState","GraphQLArgument","GraphQLField","GraphQLInputField","GraphQLNamedType","isInputObjectType","isInterfaceType","isObjectType","Combobox","ComboboxInput","ComboboxOptions","ComboboxOption","formatShortcutForOS","MagnifyingGlassIcon","KeycapHint","debounce","KEY_MAP","typeCategory","useDocExplorer","useDocExplorerActions","useSearchResults","renderType","TypeMatch","type","FieldMatch","field","argument","SearchRow","$","_c","explorerNavStack","push","inputRef","getSearchResults","searchValue","setSearchValue","t0","results","setResults","t1","search","debouncedGetSearchResults","isFocused","setIsFocused","t2","t3","cancel","navItem","onSelect","t4","at","t5","def","name","length","shouldShow","Symbol","for","searchInDocs","key","split","shortcutKeys","t6","t7","t8","current","focus","t10","t11","t9","event","target","value","t12","t13","t14","t15","within","types","fields","map","_temp","_temp2","_temp3","t16","SearchType","SearchFieldProps","SearchField","_temp4","result","i","result_0","i_0","result_1","i_1","namedType"],"sources":["../../src/components/search-row.tsx"],"sourcesContent":["import { FC, useEffect, useRef, useState } from 'react';\nimport {\n GraphQLArgument,\n GraphQLField,\n GraphQLInputField,\n GraphQLNamedType,\n isInputObjectType,\n isInterfaceType,\n isObjectType,\n} from 'graphql';\nimport {\n Combobox,\n ComboboxInput,\n ComboboxOptions,\n ComboboxOption,\n} from '@headlessui/react';\nimport {\n formatShortcutForOS,\n MagnifyingGlassIcon,\n KeycapHint,\n debounce,\n KEY_MAP,\n typeCategory,\n} from '@graphiql/react';\nimport { useDocExplorer, useDocExplorerActions } from '../context';\nimport { useSearchResults } from './search';\nimport { renderType } from './utils';\nimport './search-row.css';\n\ntype TypeMatch = { type: GraphQLNamedType };\ntype FieldMatch = {\n type: GraphQLNamedType;\n field: GraphQLField<unknown, unknown> | GraphQLInputField;\n argument?: GraphQLArgument;\n};\n\nexport const SearchRow: FC = () => {\n const explorerNavStack = useDocExplorer();\n const { push } = useDocExplorerActions();\n\n const inputRef = useRef<HTMLInputElement>(null!);\n const getSearchResults = useSearchResults();\n const [searchValue, setSearchValue] = useState('');\n const [results, setResults] = useState(() => getSearchResults(searchValue));\n const debouncedGetSearchResults = debounce(200, (search: string) => {\n setResults(getSearchResults(search));\n });\n const [isFocused, setIsFocused] = useState(false);\n\n useEffect(() => {\n debouncedGetSearchResults(searchValue);\n return debouncedGetSearchResults.cancel;\n }, [debouncedGetSearchResults, searchValue]);\n\n const navItem = explorerNavStack.at(-1)!;\n\n const onSelect = (def: TypeMatch | FieldMatch | null) => {\n if (!def) {\n return;\n }\n push(\n 'field' in def\n ? { name: def.field.name, def: def.field }\n : { name: def.type.name, def: def.type },\n );\n };\n\n const shouldShow =\n explorerNavStack.length === 1 ||\n isObjectType(navItem.def) ||\n isInterfaceType(navItem.def) ||\n isInputObjectType(navItem.def);\n\n if (!shouldShow) {\n return null;\n }\n\n const shortcutKeys = formatShortcutForOS(KEY_MAP.searchInDocs.key).split('-');\n\n return (\n <div className=\"graphiql-doc-explorer-search-row-wrapper\">\n <Combobox\n as=\"div\"\n className=\"graphiql-doc-explorer-search-row\"\n onChange={onSelect}\n aria-label={`Search ${navItem.name}...`}\n >\n <div\n className=\"graphiql-doc-explorer-search-row-input\"\n onClick={() => {\n inputRef.current.focus();\n }}\n >\n <MagnifyingGlassIcon aria-hidden=\"true\" />\n <ComboboxInput\n autoComplete=\"off\"\n onChange={event => setSearchValue(event.target.value)}\n onFocus={() => setIsFocused(true)}\n onBlur={() => setIsFocused(false)}\n placeholder=\"Search schema\"\n ref={inputRef}\n value={searchValue}\n data-cy=\"doc-explorer-input\"\n />\n {!isFocused && !searchValue && (\n <KeycapHint keys={shortcutKeys} ariaLabel=\"Search docs shortcut\" />\n )}\n </div>\n {isFocused && (\n <ComboboxOptions\n className=\"graphiql-doc-explorer-search-row-listbox\"\n data-cy=\"doc-explorer-list\"\n >\n {results.within.length +\n results.types.length +\n results.fields.length ===\n 0 ? (\n <div className=\"graphiql-doc-explorer-search-empty\">\n No results found\n </div>\n ) : (\n results.within.map((result, i) => (\n <ComboboxOption\n key={`within-${i}`}\n value={result}\n data-cy=\"doc-explorer-option\"\n >\n <SearchField\n field={result.field}\n argument={result.argument}\n />\n </ComboboxOption>\n ))\n )}\n {results.within.length > 0 &&\n results.types.length + results.fields.length > 0 ? (\n <div className=\"graphiql-doc-explorer-search-divider\">\n Other results\n </div>\n ) : null}\n {results.types.map((result, i) => (\n <ComboboxOption\n key={`type-${i}`}\n value={result}\n data-cy=\"doc-explorer-option\"\n >\n <SearchType type={result.type} />\n </ComboboxOption>\n ))}\n {results.fields.map((result, i) => (\n <ComboboxOption\n key={`field-${i}`}\n value={result}\n data-cy=\"doc-explorer-option\"\n >\n <SearchType type={result.type} />.\n <SearchField field={result.field} argument={result.argument} />\n </ComboboxOption>\n ))}\n </ComboboxOptions>\n )}\n </Combobox>\n </div>\n );\n};\n\nconst SearchType: FC<{ type: GraphQLNamedType }> = ({ type }) => (\n <span\n className=\"graphiql-doc-explorer-search-type\"\n data-type-kind={typeCategory(type)}\n >\n {type.name}\n </span>\n);\n\ntype SearchFieldProps = {\n field: GraphQLField<unknown, unknown> | GraphQLInputField;\n argument?: GraphQLArgument;\n};\n\nconst SearchField: FC<SearchFieldProps> = ({ field, argument }) => {\n return (\n <>\n <span className=\"graphiql-doc-explorer-search-field\">{field.name}</span>\n {argument ? (\n <>\n (\n <span className=\"graphiql-doc-explorer-search-argument\">\n {argument.name}\n </span>\n :{' '}\n {renderType(argument.type, namedType => (\n <SearchType type={namedType} />\n ))}\n )\n </>\n ) : null}\n </>\n );\n};\n"],"mappings":";;;;;;;;;;;AAoCA,IAAa8B,kBAAgB;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAC3B,MAAAC,mBAAyBZ,eAAe;CACxC,MAAA,EAAAa,SAAiBZ,sBAAsB;CAEvC,MAAAa,WAAiBjC,OAAA,IAA8B;CAC/C,MAAAkC,mBAAyBb,iBAAiB;CAC1C,MAAA,CAAAc,aAAAC,kBAAsCnC,SAAS,EAAE;CAAE,IAAAoC;CAAA,IAAAR,EAAA,OAAAK,oBAAAL,EAAA,OAAAM,aAAA;EACZE,WAAMH,iBAAiBC,WAAW;EAACN,EAAA,KAAAK;EAAAL,EAAA,KAAAM;EAAAN,EAAA,KAAAQ;CAAA,OAAAA,KAAAR,EAAA;CAA1E,MAAA,CAAAS,SAAAC,cAA8BtC,SAASoC,EAAmC;CAAE,IAAAG;CAAA,IAAAX,EAAA,OAAAK,kBAAA;EAC1CM,KAAAxB,SAAA,MAAAyB,WAAA;GAChCF,WAAWL,iBAAiBO,MAAM,CAAC;EAAC,CACrC;EAACZ,EAAA,KAAAK;EAAAL,EAAA,KAAAW;CAAA,OAAAA,KAAAX,EAAA;CAFF,MAAAa,4BAAkCF;CAGlC,MAAA,CAAAG,WAAAC,gBAAkC3C,SAAA,KAAc;CAAE,IAAA4C;CAAA,IAAAC;CAAA,IAAAjB,EAAA,OAAAa,6BAAAb,EAAA,OAAAM,aAAA;EAExCU,WAAA;GACRH,0BAA0BP,WAAW;GAAC,OAC/BO,0BAAyBK;EAAA;EAC/BD,KAAA,CAACJ,2BAA2BP,WAAW;EAACN,EAAA,KAAAa;EAAAb,EAAA,KAAAM;EAAAN,EAAA,KAAAgB;EAAAhB,EAAA,KAAAiB;CAAA,OAAA;EAAAD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