@graphiql/plugin-doc-explorer 0.4.3 → 1.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/dist/components/arguments-list.d.ts +12 -0
  2. package/dist/components/arguments-list.js +248 -0
  3. package/dist/components/arguments-list.js.map +1 -0
  4. package/dist/components/breadcrumb.d.ts +8 -0
  5. package/dist/components/breadcrumb.js +54 -0
  6. package/dist/components/breadcrumb.js.map +1 -0
  7. package/dist/components/doc-explorer.js +172 -123
  8. package/dist/components/doc-explorer.js.map +1 -1
  9. package/dist/components/field-card.d.ts +7 -0
  10. package/dist/components/field-card.js +102 -0
  11. package/dist/components/field-card.js.map +1 -0
  12. package/dist/components/field-documentation.js +76 -110
  13. package/dist/components/field-documentation.js.map +1 -1
  14. package/dist/components/fields-list.d.ts +8 -0
  15. package/dist/components/fields-list.js +235 -0
  16. package/dist/components/fields-list.js.map +1 -0
  17. package/dist/components/index.d.ts +6 -0
  18. package/dist/components/schema-documentation.js +170 -98
  19. package/dist/components/schema-documentation.js.map +1 -1
  20. package/dist/components/search-row.d.ts +2 -0
  21. package/dist/components/search-row.js +282 -0
  22. package/dist/components/search-row.js.map +1 -0
  23. package/dist/components/search.js +76 -52
  24. package/dist/components/search.js.map +1 -1
  25. package/dist/components/section.js +1 -1
  26. package/dist/components/section.js.map +1 -1
  27. package/dist/components/type-card.d.ts +7 -0
  28. package/dist/components/type-card.js +112 -0
  29. package/dist/components/type-card.js.map +1 -0
  30. package/dist/components/type-documentation.d.ts +6 -0
  31. package/dist/components/type-documentation.js +11 -9
  32. package/dist/components/type-documentation.js.map +1 -1
  33. package/dist/components/type-link.js +2 -1
  34. package/dist/components/type-link.js.map +1 -1
  35. package/dist/context.js +60 -40
  36. package/dist/context.js.map +1 -1
  37. package/dist/index.d.ts +0 -1
  38. package/dist/index.js +13 -3
  39. package/dist/index.js.map +1 -1
  40. package/dist/stories/doc-explorer.stories.d.ts +12 -0
  41. package/dist/style.css +691 -131
  42. package/package.json +9 -3
  43. package/dist/deprecated.d.ts +0 -11
  44. package/dist/deprecated.js +0 -24
  45. package/dist/deprecated.js.map +0 -1
@@ -1,15 +1,18 @@
1
- import { jsxs, jsx } from "react/jsx-runtime";
1
+ import { jsxs, jsx, Fragment } from "react/jsx-runtime";
2
2
  import { c } from "react-compiler-runtime";
3
- import { isType } from "graphql";
4
- import { pick, useGraphiQL, Spinner, ChevronLeftIcon } from "@graphiql/react";
3
+ import { isType, isObjectType, isInterfaceType, isInputObjectType, isEnumType, isUnionType } from "graphql";
4
+ import { pick, useGraphiQL, Spinner, PanelHeader } from "@graphiql/react";
5
5
  import { useDocExplorer, useDocExplorerActions } from "../context.js";
6
+ import { Breadcrumb } from "./breadcrumb.js";
6
7
  import { FieldDocumentation } from "./field-documentation.js";
8
+ import { FieldsList } from "./fields-list.js";
7
9
  import { SchemaDocumentation } from "./schema-documentation.js";
8
- import { Search } from "./search.js";
10
+ import { SearchRow } from "./search-row.js";
11
+ import { TypeCard } from "./type-card.js";
9
12
  import { TypeDocumentation } from "./type-documentation.js";
10
13
  /* empty css */
11
14
  const DocExplorer = () => {
12
- const $ = c(39);
15
+ const $ = c(37);
13
16
  let t0;
14
17
  if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
15
18
  t0 = pick("fetchError", "isIntrospecting", "schema", "validationErrors");
@@ -29,85 +32,101 @@ const DocExplorer = () => {
29
32
  } = useDocExplorerActions();
30
33
  let content;
31
34
  let navItem;
32
- if ($[1] !== explorerNavStack || $[2] !== fetchError || $[3] !== isIntrospecting || $[4] !== schema || $[5] !== validationErrors) {
35
+ let navigateToIndex;
36
+ if ($[1] !== explorerNavStack || $[2] !== fetchError || $[3] !== isIntrospecting || $[4] !== pop || $[5] !== schema || $[6] !== validationErrors) {
33
37
  navItem = explorerNavStack.at(-1);
38
+ let t12;
39
+ if ($[10] !== explorerNavStack.length || $[11] !== pop) {
40
+ t12 = (index) => {
41
+ const stepsBack = explorerNavStack.length - 1 - index;
42
+ for (let i = 0; i < stepsBack; i++) {
43
+ pop();
44
+ }
45
+ };
46
+ $[10] = explorerNavStack.length;
47
+ $[11] = pop;
48
+ $[12] = t12;
49
+ } else {
50
+ t12 = $[12];
51
+ }
52
+ navigateToIndex = t12;
34
53
  content = null;
35
54
  if (fetchError) {
36
- let t12;
37
- if ($[8] === Symbol.for("react.memo_cache_sentinel")) {
38
- t12 = /* @__PURE__ */ jsx("div", { className: "graphiql-doc-explorer-error", children: "Error fetching schema" });
39
- $[8] = t12;
55
+ let t22;
56
+ if ($[13] === Symbol.for("react.memo_cache_sentinel")) {
57
+ t22 = /* @__PURE__ */ jsx("div", { className: "graphiql-doc-explorer-error", children: "Error fetching schema" });
58
+ $[13] = t22;
40
59
  } else {
41
- t12 = $[8];
60
+ t22 = $[13];
42
61
  }
43
- content = t12;
62
+ content = t22;
44
63
  } else {
45
64
  if (validationErrors[0]) {
46
- let t12;
47
- if ($[9] !== validationErrors[0].message) {
48
- t12 = /* @__PURE__ */ jsxs("div", { className: "graphiql-doc-explorer-error", children: [
65
+ let t22;
66
+ if ($[14] !== validationErrors[0].message) {
67
+ t22 = /* @__PURE__ */ jsxs("div", { className: "graphiql-doc-explorer-error", children: [
49
68
  "Schema is invalid: ",
50
69
  validationErrors[0].message
51
70
  ] });
52
- $[9] = validationErrors[0].message;
53
- $[10] = t12;
71
+ $[14] = validationErrors[0].message;
72
+ $[15] = t22;
54
73
  } else {
55
- t12 = $[10];
74
+ t22 = $[15];
56
75
  }
57
- content = t12;
76
+ content = t22;
58
77
  } else {
59
78
  if (isIntrospecting) {
60
- let t12;
61
- if ($[11] === Symbol.for("react.memo_cache_sentinel")) {
62
- t12 = /* @__PURE__ */ jsx(Spinner, {});
63
- $[11] = t12;
79
+ let t22;
80
+ if ($[16] === Symbol.for("react.memo_cache_sentinel")) {
81
+ t22 = /* @__PURE__ */ jsx(Spinner, {});
82
+ $[16] = t22;
64
83
  } else {
65
- t12 = $[11];
84
+ t22 = $[16];
66
85
  }
67
- content = t12;
86
+ content = t22;
68
87
  } else {
69
88
  if (!schema) {
70
- let t12;
71
- if ($[12] === Symbol.for("react.memo_cache_sentinel")) {
72
- t12 = /* @__PURE__ */ jsx("div", { className: "graphiql-doc-explorer-error", children: "No GraphQL schema available" });
73
- $[12] = t12;
89
+ let t22;
90
+ if ($[17] === Symbol.for("react.memo_cache_sentinel")) {
91
+ t22 = /* @__PURE__ */ jsx("div", { className: "graphiql-doc-explorer-error", children: "No GraphQL schema available" });
92
+ $[17] = t22;
74
93
  } else {
75
- t12 = $[12];
94
+ t22 = $[17];
76
95
  }
77
- content = t12;
96
+ content = t22;
78
97
  } else {
79
98
  if (explorerNavStack.length === 1) {
80
- let t12;
81
- if ($[13] !== schema) {
82
- t12 = /* @__PURE__ */ jsx(SchemaDocumentation, { schema });
83
- $[13] = schema;
84
- $[14] = t12;
99
+ let t22;
100
+ if ($[18] !== schema) {
101
+ t22 = /* @__PURE__ */ jsx(SchemaDocumentation, { schema });
102
+ $[18] = schema;
103
+ $[19] = t22;
85
104
  } else {
86
- t12 = $[14];
105
+ t22 = $[19];
87
106
  }
88
- content = t12;
107
+ content = t22;
89
108
  } else {
90
109
  if (isType(navItem.def)) {
91
- let t12;
92
- if ($[15] !== navItem.def) {
93
- t12 = /* @__PURE__ */ jsx(TypeDocumentation, { type: navItem.def });
94
- $[15] = navItem.def;
95
- $[16] = t12;
110
+ let t22;
111
+ if ($[20] !== navItem.def) {
112
+ t22 = /* @__PURE__ */ jsx(TypeView, { type: navItem.def });
113
+ $[20] = navItem.def;
114
+ $[21] = t22;
96
115
  } else {
97
- t12 = $[16];
116
+ t22 = $[21];
98
117
  }
99
- content = t12;
118
+ content = t22;
100
119
  } else {
101
120
  if (navItem.def) {
102
- let t12;
103
- if ($[17] !== navItem.def) {
104
- t12 = /* @__PURE__ */ jsx(FieldDocumentation, { field: navItem.def });
105
- $[17] = navItem.def;
106
- $[18] = t12;
121
+ let t22;
122
+ if ($[22] !== navItem.def) {
123
+ t22 = /* @__PURE__ */ jsx(FieldDocumentation, { field: navItem.def });
124
+ $[22] = navItem.def;
125
+ $[23] = t22;
107
126
  } else {
108
- t12 = $[18];
127
+ t22 = $[23];
109
128
  }
110
- content = t12;
129
+ content = t22;
111
130
  }
112
131
  }
113
132
  }
@@ -118,102 +137,132 @@ const DocExplorer = () => {
118
137
  $[1] = explorerNavStack;
119
138
  $[2] = fetchError;
120
139
  $[3] = isIntrospecting;
121
- $[4] = schema;
122
- $[5] = validationErrors;
123
- $[6] = content;
124
- $[7] = navItem;
140
+ $[4] = pop;
141
+ $[5] = schema;
142
+ $[6] = validationErrors;
143
+ $[7] = content;
144
+ $[8] = navItem;
145
+ $[9] = navigateToIndex;
125
146
  } else {
126
- content = $[6];
127
- navItem = $[7];
128
- }
129
- let prevName;
130
- if (explorerNavStack.length > 1) {
131
- let t12;
132
- if ($[19] !== explorerNavStack) {
133
- t12 = explorerNavStack.at(-2);
134
- $[19] = explorerNavStack;
135
- $[20] = t12;
136
- } else {
137
- t12 = $[20];
138
- }
139
- prevName = t12.name;
147
+ content = $[7];
148
+ navItem = $[8];
149
+ navigateToIndex = $[9];
140
150
  }
151
+ const isTypeOrFieldView = explorerNavStack.length > 1;
141
152
  let t1;
142
- if ($[21] !== pop || $[22] !== prevName) {
143
- t1 = prevName && /* @__PURE__ */ jsxs("a", { href: "#", className: "graphiql-doc-explorer-back", onClick: (event) => {
144
- event.preventDefault();
145
- pop();
146
- }, "aria-label": `Go back to ${prevName}`, children: [
147
- /* @__PURE__ */ jsx(ChevronLeftIcon, {}),
148
- prevName
149
- ] });
150
- $[21] = pop;
151
- $[22] = prevName;
152
- $[23] = t1;
153
+ if ($[24] === Symbol.for("react.memo_cache_sentinel")) {
154
+ t1 = /* @__PURE__ */ jsx(PanelHeader, { title: "Schema Explorer" });
155
+ $[24] = t1;
153
156
  } else {
154
- t1 = $[23];
157
+ t1 = $[24];
155
158
  }
156
159
  let t2;
157
- if ($[24] !== navItem.name) {
158
- t2 = /* @__PURE__ */ jsx("div", { className: "graphiql-doc-explorer-title", children: navItem.name });
159
- $[24] = navItem.name;
160
- $[25] = t2;
160
+ if ($[25] !== explorerNavStack || $[26] !== isTypeOrFieldView || $[27] !== navigateToIndex) {
161
+ t2 = isTypeOrFieldView && /* @__PURE__ */ jsx(Breadcrumb, { navStack: explorerNavStack, onNavigateTo: navigateToIndex });
162
+ $[25] = explorerNavStack;
163
+ $[26] = isTypeOrFieldView;
164
+ $[27] = navigateToIndex;
165
+ $[28] = t2;
161
166
  } else {
162
- t2 = $[25];
167
+ t2 = $[28];
163
168
  }
164
169
  let t3;
165
- if ($[26] !== t1 || $[27] !== t2) {
166
- t3 = /* @__PURE__ */ jsxs("div", { className: "graphiql-doc-explorer-header-content", children: [
167
- t1,
168
- t2
169
- ] });
170
- $[26] = t1;
171
- $[27] = t2;
172
- $[28] = t3;
170
+ if ($[29] !== navItem.name) {
171
+ t3 = /* @__PURE__ */ jsx(SearchRow, {}, navItem.name);
172
+ $[29] = navItem.name;
173
+ $[30] = t3;
173
174
  } else {
174
- t3 = $[28];
175
+ t3 = $[30];
175
176
  }
176
177
  let t4;
177
- if ($[29] !== navItem.name) {
178
- t4 = /* @__PURE__ */ jsx(Search, {}, navItem.name);
179
- $[29] = navItem.name;
180
- $[30] = t4;
178
+ if ($[31] !== content) {
179
+ t4 = /* @__PURE__ */ jsx("div", { className: "graphiql-doc-explorer-content", children: content });
180
+ $[31] = content;
181
+ $[32] = t4;
181
182
  } else {
182
- t4 = $[30];
183
+ t4 = $[32];
183
184
  }
184
185
  let t5;
185
- if ($[31] !== t3 || $[32] !== t4) {
186
- t5 = /* @__PURE__ */ jsxs("div", { className: "graphiql-doc-explorer-header", children: [
186
+ if ($[33] !== t2 || $[34] !== t3 || $[35] !== t4) {
187
+ t5 = /* @__PURE__ */ jsxs("section", { className: "graphiql-doc-explorer", "aria-label": "Documentation Explorer", children: [
188
+ t1,
189
+ t2,
187
190
  t3,
188
191
  t4
189
192
  ] });
190
- $[31] = t3;
191
- $[32] = t4;
192
- $[33] = t5;
193
+ $[33] = t2;
194
+ $[34] = t3;
195
+ $[35] = t4;
196
+ $[36] = t5;
193
197
  } else {
194
- t5 = $[33];
198
+ t5 = $[36];
195
199
  }
196
- let t6;
197
- if ($[34] !== content) {
198
- t6 = /* @__PURE__ */ jsx("div", { className: "graphiql-doc-explorer-content", children: content });
199
- $[34] = content;
200
- $[35] = t6;
200
+ return t5;
201
+ };
202
+ const TypeView = (t0) => {
203
+ const $ = c(16);
204
+ const {
205
+ type
206
+ } = t0;
207
+ let t1;
208
+ if ($[0] !== type) {
209
+ t1 = isObjectType(type) || isInterfaceType(type) || isInputObjectType(type);
210
+ $[0] = type;
211
+ $[1] = t1;
212
+ } else {
213
+ t1 = $[1];
214
+ }
215
+ const hasNewFieldsList = t1;
216
+ let t2;
217
+ if ($[2] !== type) {
218
+ t2 = isEnumType(type) || isUnionType(type) || isInterfaceType(type);
219
+ $[2] = type;
220
+ $[3] = t2;
221
+ } else {
222
+ t2 = $[3];
223
+ }
224
+ const needsTypeDocs = t2;
225
+ let t3;
226
+ if ($[4] !== type) {
227
+ t3 = /* @__PURE__ */ jsx(TypeCard, { type });
228
+ $[4] = type;
229
+ $[5] = t3;
201
230
  } else {
202
- t6 = $[35];
231
+ t3 = $[5];
203
232
  }
204
- let t7;
205
- if ($[36] !== t5 || $[37] !== t6) {
206
- t7 = /* @__PURE__ */ jsxs("section", { className: "graphiql-doc-explorer", "aria-label": "Documentation Explorer", children: [
207
- t5,
208
- t6
233
+ let t4;
234
+ if ($[6] !== hasNewFieldsList || $[7] !== type) {
235
+ t4 = hasNewFieldsList && /* @__PURE__ */ jsx(FieldsList, { type });
236
+ $[6] = hasNewFieldsList;
237
+ $[7] = type;
238
+ $[8] = t4;
239
+ } else {
240
+ t4 = $[8];
241
+ }
242
+ let t5;
243
+ if ($[9] !== needsTypeDocs || $[10] !== type) {
244
+ t5 = needsTypeDocs && /* @__PURE__ */ jsx("div", { className: "graphiql-doc-explorer-type-extra", children: /* @__PURE__ */ jsx(TypeDocumentation, { type, hideHeader: true }) });
245
+ $[9] = needsTypeDocs;
246
+ $[10] = type;
247
+ $[11] = t5;
248
+ } else {
249
+ t5 = $[11];
250
+ }
251
+ let t6;
252
+ if ($[12] !== t3 || $[13] !== t4 || $[14] !== t5) {
253
+ t6 = /* @__PURE__ */ jsxs(Fragment, { children: [
254
+ t3,
255
+ t4,
256
+ t5
209
257
  ] });
210
- $[36] = t5;
211
- $[37] = t6;
212
- $[38] = t7;
258
+ $[12] = t3;
259
+ $[13] = t4;
260
+ $[14] = t5;
261
+ $[15] = t6;
213
262
  } else {
214
- t7 = $[38];
263
+ t6 = $[15];
215
264
  }
216
- return t7;
265
+ return t6;
217
266
  };
218
267
  export {
219
268
  DocExplorer
@@ -1 +1 @@
1
- {"version":3,"file":"doc-explorer.js","sources":["../../src/components/doc-explorer.tsx"],"sourcesContent":["import { isType } from 'graphql';\nimport type { FC, ReactNode } from 'react';\nimport { ChevronLeftIcon, Spinner, useGraphiQL, pick } from '@graphiql/react';\nimport { useDocExplorer, useDocExplorerActions } from '../context';\nimport { FieldDocumentation } from './field-documentation';\nimport { SchemaDocumentation } from './schema-documentation';\nimport { Search } from './search';\nimport { TypeDocumentation } from './type-documentation';\nimport './doc-explorer.css';\n\nexport const DocExplorer: FC = () => {\n const { fetchError, isIntrospecting, schema, validationErrors } = useGraphiQL(\n pick('fetchError', 'isIntrospecting', 'schema', 'validationErrors'),\n );\n const explorerNavStack = useDocExplorer();\n const { pop } = useDocExplorerActions();\n const navItem = explorerNavStack.at(-1)!;\n\n let content: ReactNode = null;\n if (fetchError) {\n content = (\n <div className=\"graphiql-doc-explorer-error\">Error fetching schema</div>\n );\n } else if (validationErrors[0]) {\n content = (\n <div className=\"graphiql-doc-explorer-error\">\n Schema is invalid: {validationErrors[0].message}\n </div>\n );\n } else if (isIntrospecting) {\n // Schema is undefined when it is being loaded via introspection.\n content = <Spinner />;\n } else if (!schema) {\n // Schema is null when it explicitly does not exist, typically due to\n // an error during introspection.\n content = (\n <div className=\"graphiql-doc-explorer-error\">\n No GraphQL schema available\n </div>\n );\n } else if (explorerNavStack.length === 1) {\n content = <SchemaDocumentation schema={schema} />;\n } else if (isType(navItem.def)) {\n content = <TypeDocumentation type={navItem.def} />;\n } else if (navItem.def) {\n content = <FieldDocumentation field={navItem.def} />;\n }\n\n let prevName;\n if (explorerNavStack.length > 1) {\n prevName = explorerNavStack.at(-2)!.name;\n }\n\n return (\n <section\n className=\"graphiql-doc-explorer\"\n aria-label=\"Documentation Explorer\"\n >\n <div className=\"graphiql-doc-explorer-header\">\n <div className=\"graphiql-doc-explorer-header-content\">\n {prevName && (\n <a\n href=\"#\"\n className=\"graphiql-doc-explorer-back\"\n onClick={event => {\n event.preventDefault();\n pop();\n }}\n aria-label={`Go back to ${prevName}`}\n >\n <ChevronLeftIcon />\n {prevName}\n </a>\n )}\n <div className=\"graphiql-doc-explorer-title\">{navItem.name}</div>\n </div>\n <Search key={navItem.name} />\n </div>\n <div className=\"graphiql-doc-explorer-content\">{content}</div>\n </section>\n );\n};\n"],"names":["DocExplorer","$","_c","t0","Symbol","for","pick","fetchError","isIntrospecting","schema","validationErrors","useGraphiQL","explorerNavStack","useDocExplorer","pop","useDocExplorerActions","content","navItem","at","t1","message","length","isType","def","prevName","event","preventDefault","t2","name","t3","t4","t5","t6","t7"],"mappings":";;;;;;;;;;AAUO,MAAMA,cAAkBA,MAAA;AAAAC,QAAAA,IAAAC,EAAA,EAAA;AAAAC,MAAAA;AAAA,MAAAF,EAAA,CAAA,MAAAG,OAAAC,IAAA,2BAAA,GAAA;AAE3BF,SAAAG,KAAK,cAAc,mBAAmB,UAAU,kBAAkB;AAACL,WAAAE;AAAAA,EAAAA,OAAA;AAAAA,SAAAF,EAAA,CAAA;AAAA,EAAA;AADrE,QAAA;AAAA,IAAAM;AAAAA,IAAAC;AAAAA,IAAAC;AAAAA,IAAAC;A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":["import {\n GraphQLNamedType,\n isEnumType,\n isInputObjectType,\n isInterfaceType,\n isObjectType,\n isType,\n isUnionType,\n} from 'graphql';\nimport type { FC, ReactNode } from 'react';\nimport { PanelHeader, Spinner, useGraphiQL, pick } from '@graphiql/react';\nimport { useDocExplorer, useDocExplorerActions } from '../context';\nimport { Breadcrumb } from './breadcrumb';\nimport { FieldDocumentation } from './field-documentation';\nimport { FieldsList } from './fields-list';\nimport { SchemaDocumentation } from './schema-documentation';\nimport { SearchRow } from './search-row';\nimport { TypeCard } from './type-card';\nimport { TypeDocumentation } from './type-documentation';\nimport './doc-explorer.css';\n\nexport const DocExplorer: FC = () => {\n const { fetchError, isIntrospecting, schema, validationErrors } = useGraphiQL(\n pick('fetchError', 'isIntrospecting', 'schema', 'validationErrors'),\n );\n const explorerNavStack = useDocExplorer();\n const { pop } = useDocExplorerActions();\n const navItem = explorerNavStack.at(-1)!;\n\n const navigateToIndex = (index: number) => {\n const stepsBack = explorerNavStack.length - 1 - index;\n for (let i = 0; i < stepsBack; i++) {\n pop();\n }\n };\n\n let content: ReactNode = null;\n if (fetchError) {\n content = (\n <div className=\"graphiql-doc-explorer-error\">Error fetching schema</div>\n );\n } else if (validationErrors[0]) {\n content = (\n <div className=\"graphiql-doc-explorer-error\">\n Schema is invalid: {validationErrors[0].message}\n </div>\n );\n } else if (isIntrospecting) {\n content = <Spinner />;\n } else if (!schema) {\n content = (\n <div className=\"graphiql-doc-explorer-error\">\n No GraphQL schema available\n </div>\n );\n } else if (explorerNavStack.length === 1) {\n content = <SchemaDocumentation schema={schema} />;\n } else if (isType(navItem.def)) {\n content = <TypeView type={navItem.def} />;\n } else if (navItem.def) {\n content = <FieldDocumentation field={navItem.def} />;\n }\n\n const isTypeOrFieldView = explorerNavStack.length > 1;\n\n return (\n <section\n className=\"graphiql-doc-explorer\"\n aria-label=\"Documentation Explorer\"\n >\n <PanelHeader title=\"Schema Explorer\" />\n {isTypeOrFieldView && (\n <Breadcrumb\n navStack={explorerNavStack}\n onNavigateTo={navigateToIndex}\n />\n )}\n <SearchRow key={navItem.name} />\n <div className=\"graphiql-doc-explorer-content\">{content}</div>\n </section>\n );\n};\n\nconst TypeView: FC<{ type: GraphQLNamedType }> = ({ type }) => {\n const hasNewFieldsList =\n isObjectType(type) || isInterfaceType(type) || isInputObjectType(type);\n // Enum/union/scalar still need the TypeDocumentation for enum values and\n // possible-type sections; interface needs it for Implementations.\n const needsTypeDocs =\n isEnumType(type) || isUnionType(type) || isInterfaceType(type);\n\n return (\n <>\n <TypeCard type={type} />\n {hasNewFieldsList && <FieldsList type={type} />}\n {needsTypeDocs && (\n <div className=\"graphiql-doc-explorer-type-extra\">\n <TypeDocumentation type={type} hideHeader />\n </div>\n )}\n </>\n );\n};\n"],"names":["DocExplorer","$","_c","t0","Symbol","for","pick","fetchError","isIntrospecting","schema","validationErrors","useGraphiQL","explorerNavStack","useDocExplorer","pop","useDocExplorerActions","content","navItem","navigateToIndex","at","t1","length","index","stepsBack","i","t2","message","isType","def","isTypeOrFieldView","t3","name","t4","t5","TypeView","type","isObjectType","isInterfaceType","isInputObjectType","hasNewFieldsList","isEnumType","isUnionType","needsTypeDocs","t6"],"mappings":";;;;;;;;;;;;;AAqBO,MAAMA,cAAkBA,MAAA;AAAAC,QAAAA,IAAAC,EAAA,EAAA;AAAAC,MAAAA;AAAA,MAAAF,EAAA,CAAA,MAAAG,OAAAC,IAAA,2BAAA,GAAA;AAE3BF,SAAAG,KAAK,cAAc,mBAAmB,UAAU,kBAAkB;AAACL,WAAAE;AAAAA,EAAAA,OAAA;AAAAA,SAAAF,EAAA,CAAA;AAAA,EAAA;AADrE,QAAA;AAAA,IAAAM;AAAAA,IAAAC;AAAAA,IAAAC;AAAAA,IAAAC;AAAAA,EAAAA,IAAkEC,YAChER,EACF;AACA,QAAAS,mBAAyBC,eAAe;AACxC,QAAA;AAAA,IAAAC;AAAAA,MAAgBC,sBAAsB;AAAEC,MAAAA;AAAAC,MAAAA;AAAAC,MAAAA;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AA7B,MAAAA,SAAAkC,MAAA;6BAI5D,YAAeA,KAAQ,CAAA;AAAAlC,WAAAkC;AAAAlC,WAAA6B;AAAAA,EAAAA,OAAA;AAAAA,SAAA7B,EAAA,CAAA;AAAA,EAAA;AAAA+B,MAAAA;AAAA,MAAA/B,EAAAsC,CAAAA,MAAAA,oBAAAtC,SAAAkC,MAAA;AACvBI,SAAAA,oBAAqB,oBAAA,YAAA,EAAiBJ,KAAQ,CAAA;AAAAlC,WAAAsC;AAAAtC,WAAAkC;AAAAlC,WAAA+B;AAAAA,EAAAA,OAAA;AAAAA,SAAA/B,EAAA,CAAA;AAAA,EAAA;AAAAgC,MAAAA;AAAA,MAAAhC,EAAAyC,CAAAA,MAAAA,iBAAAzC,UAAAkC,MAAA;AAC9CO,SAAAA,iBAGO,oBAAA,OAAA,EAFS,WAAA,oCACb,8BAAC,mBAAwBP,EAAAA,MAAM,kBAAU,EAC3C,CAAA;AACDlC,WAAAyC;AAAAzC,YAAAkC;AAAAlC,YAAAgC;AAAAA,EAAAA,OAAA;AAAAA,SAAAhC,EAAA,EAAA;AAAA,EAAA;AAAA0C,MAAAA;AAAA1C,MAAAA,EAAA6B,EAAAA,MAAAA,MAAA7B,UAAA+B,MAAA/B,EAAA,EAAA,MAAAgC,IAAA;AAPHU,SACEb,qBAAAA,UAAAA,EAAAA,UAAAA;AAAAA,MAAAA;AAAAA,MACCE;AAAAA,MACAC;AAAAA,IAAAA,GAIA;AACAhC,YAAA6B;AAAA7B,YAAA+B;AAAA/B,YAAAgC;AAAAhC,YAAA0C;AAAAA,EAAAA,OAAA;AAAAA,SAAA1C,EAAA,EAAA;AAAA,EAAA;AARH0C,SAAAA;AAQG;"}
@@ -0,0 +1,7 @@
1
+ import { FC } from 'react';
2
+ import { DocExplorerFieldDef } from '../context';
3
+ type FieldCardProps = {
4
+ field: DocExplorerFieldDef;
5
+ };
6
+ export declare const FieldCard: FC<FieldCardProps>;
7
+ export {};
@@ -0,0 +1,102 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { c } from "react-compiler-runtime";
3
+ import { DeprecationReason } from "./deprecation-reason.js";
4
+ import { TypeLink } from "./type-link.js";
5
+ import { renderType } from "./utils.js";
6
+ /* empty css */
7
+ const FieldCard = (t0) => {
8
+ const $ = c(19);
9
+ const {
10
+ field
11
+ } = t0;
12
+ let t1;
13
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
14
+ t1 = /* @__PURE__ */ jsx("span", { className: "graphiql-doc-explorer-type-badge", children: "FIELD" });
15
+ $[0] = t1;
16
+ } else {
17
+ t1 = $[0];
18
+ }
19
+ let t2;
20
+ if ($[1] !== field.name) {
21
+ t2 = /* @__PURE__ */ jsx("span", { className: "graphiql-doc-explorer-field-card-name", children: field.name });
22
+ $[1] = field.name;
23
+ $[2] = t2;
24
+ } else {
25
+ t2 = $[2];
26
+ }
27
+ let t3;
28
+ if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
29
+ t3 = /* @__PURE__ */ jsx("span", { className: "graphiql-doc-explorer-field-card-colon", "aria-hidden": "true", children: ":" });
30
+ $[3] = t3;
31
+ } else {
32
+ t3 = $[3];
33
+ }
34
+ let t4;
35
+ if ($[4] !== field.type) {
36
+ t4 = renderType(field.type, _temp);
37
+ $[4] = field.type;
38
+ $[5] = t4;
39
+ } else {
40
+ t4 = $[5];
41
+ }
42
+ let t5;
43
+ if ($[6] !== t4) {
44
+ t5 = /* @__PURE__ */ jsx("span", { className: "graphiql-doc-explorer-field-card-type", children: t4 });
45
+ $[6] = t4;
46
+ $[7] = t5;
47
+ } else {
48
+ t5 = $[7];
49
+ }
50
+ let t6;
51
+ if ($[8] !== t2 || $[9] !== t5) {
52
+ t6 = /* @__PURE__ */ jsxs("div", { className: "graphiql-doc-explorer-field-card-header", children: [
53
+ t1,
54
+ t2,
55
+ t3,
56
+ t5
57
+ ] });
58
+ $[8] = t2;
59
+ $[9] = t5;
60
+ $[10] = t6;
61
+ } else {
62
+ t6 = $[10];
63
+ }
64
+ let t7;
65
+ if ($[11] !== field.description) {
66
+ t7 = field.description && /* @__PURE__ */ jsx("p", { className: "graphiql-doc-explorer-field-card-description", children: field.description });
67
+ $[11] = field.description;
68
+ $[12] = t7;
69
+ } else {
70
+ t7 = $[12];
71
+ }
72
+ let t8;
73
+ if ($[13] !== field) {
74
+ t8 = "deprecationReason" in field && field.deprecationReason ? /* @__PURE__ */ jsx(DeprecationReason, { preview: false, children: field.deprecationReason }) : null;
75
+ $[13] = field;
76
+ $[14] = t8;
77
+ } else {
78
+ t8 = $[14];
79
+ }
80
+ let t9;
81
+ if ($[15] !== t6 || $[16] !== t7 || $[17] !== t8) {
82
+ t9 = /* @__PURE__ */ jsxs("div", { className: "graphiql-doc-explorer-field-card", children: [
83
+ t6,
84
+ t7,
85
+ t8
86
+ ] });
87
+ $[15] = t6;
88
+ $[16] = t7;
89
+ $[17] = t8;
90
+ $[18] = t9;
91
+ } else {
92
+ t9 = $[18];
93
+ }
94
+ return t9;
95
+ };
96
+ function _temp(namedType) {
97
+ return /* @__PURE__ */ jsx(TypeLink, { type: namedType });
98
+ }
99
+ export {
100
+ FieldCard
101
+ };
102
+ //# sourceMappingURL=field-card.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"field-card.js","sources":["../../src/components/field-card.tsx"],"sourcesContent":["import type { FC } from 'react';\nimport type { DocExplorerFieldDef } from '../context';\nimport { DeprecationReason } from './deprecation-reason';\nimport { TypeLink } from './type-link';\nimport { renderType } from './utils';\nimport './field-card.css';\n\ntype FieldCardProps = {\n field: DocExplorerFieldDef;\n};\n\nexport const FieldCard: FC<FieldCardProps> = ({ field }) => {\n return (\n <div className=\"graphiql-doc-explorer-field-card\">\n <div className=\"graphiql-doc-explorer-field-card-header\">\n <span className=\"graphiql-doc-explorer-type-badge\">FIELD</span>\n <span className=\"graphiql-doc-explorer-field-card-name\">\n {field.name}\n </span>\n <span\n className=\"graphiql-doc-explorer-field-card-colon\"\n aria-hidden=\"true\"\n >\n :\n </span>\n <span className=\"graphiql-doc-explorer-field-card-type\">\n {renderType(field.type, namedType => (\n <TypeLink type={namedType} />\n ))}\n </span>\n </div>\n {field.description && (\n <p className=\"graphiql-doc-explorer-field-card-description\">\n {field.description}\n </p>\n )}\n {'deprecationReason' in field && field.deprecationReason ? (\n <DeprecationReason preview={false}>\n {field.deprecationReason}\n </DeprecationReason>\n ) : null}\n </div>\n );\n};\n"],"names":["FieldCard","t0","$","_c","field","t1","Symbol","for","t2","name","t3","t4","type","renderType","_temp","t5","t6","t7","description","t8","deprecationReason","t9","namedType"],"mappings":";;;;;;AAWO,MAAMA,YAAgCC,CAAA,OAAA;AAAAC,QAAAA,IAAAC,EAAA,EAAA;AAAC,QAAA;AAAA,IAAAC;AAAAA,EAAAA,IAAAH;AAASI,MAAAA;AAAA,MAAAH,EAAA,CAAA,MAAAI,OAAAC,IAAA,2BAAA,GAAA;AAI/CF,SAAA,oBAAA,QAAA,EAAgB,WAAA,oCAAmC,UAAK,SAAA;AAAOH,WAAAG;AAAAA,EAAAA,OAAA;AAAAA,SAAAH,EAAA,CAAA;AAAA,EAAA;AAAAM,MAAAA;AAAA,MAAAN,EAAA,CAAA,MAAAE,MAAAK,MAAA;AAC/DD,SAEO,oBAAA,QAAA,EAFS,WAAA,yCACbJ,gBAAKK,MACR;AAAO,MAAA,CAAA,IAAAL,MAAAK;AAAAP,WAAAM;AAAAA,EAAAA,OAAA;AAAAA,SAAAN,EAAA,CAAA;AAAA,EAAA;AAAAQ,MAAAA;AAAA,MAAAR,EAAA,CAAA,MAAAI,OAAAC,IAAA,2BAAA,GAAA;AACPG,6BAKO,QAJK,EAAA,WAAA,0CACE,eAAA,QACb,UAED,KAAA;AAAOR,WAAAQ;AAAAA,EAAAA,OAAA;AAAAA,SAAAR,EAAA,CAAA;AAAA,EAAA;AAAAS,MAAAA;AAAA,MAAAT,EAAA,CAAA,MAAAE,MAAAQ,MAAA;AAEJC,SAAAA,WAAWT,MAAKQ,MAAAE,KAEhB;AAA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