@graphiql/plugin-doc-explorer 0.0.1-canary-aa7ad225.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/README.md +1 -0
  2. package/dist/components/argument.d.ts +21 -0
  3. package/dist/components/argument.js +96 -0
  4. package/dist/components/argument.js.map +1 -0
  5. package/dist/components/default-value.d.ts +9 -0
  6. package/dist/components/default-value.js +78 -0
  7. package/dist/components/default-value.js.map +1 -0
  8. package/dist/components/deprecation-reason.d.ts +9 -0
  9. package/dist/components/deprecation-reason.js +24 -0
  10. package/dist/components/deprecation-reason.js.map +1 -0
  11. package/dist/components/directive.d.ts +9 -0
  12. package/dist/components/directive.js +25 -0
  13. package/dist/components/directive.js.map +1 -0
  14. package/dist/components/doc-explorer.d.ts +1 -0
  15. package/dist/components/doc-explorer.js +234 -0
  16. package/dist/components/doc-explorer.js.map +1 -0
  17. package/dist/components/field-documentation.d.ts +9 -0
  18. package/dist/components/field-documentation.js +182 -0
  19. package/dist/components/field-documentation.js.map +1 -0
  20. package/dist/components/field-link.d.ts +9 -0
  21. package/dist/components/field-link.js +48 -0
  22. package/dist/components/field-link.js.map +1 -0
  23. package/dist/components/index.d.ts +12 -0
  24. package/dist/components/schema-documentation.d.ts +9 -0
  25. package/dist/components/schema-documentation.js +168 -0
  26. package/dist/components/schema-documentation.js.map +1 -0
  27. package/dist/components/search.d.ts +17 -0
  28. package/dist/components/search.js +379 -0
  29. package/dist/components/search.js.map +1 -0
  30. package/dist/components/section.d.ts +11 -0
  31. package/dist/components/section.js +68 -0
  32. package/dist/components/section.js.map +1 -0
  33. package/dist/components/type-documentation.d.ts +9 -0
  34. package/dist/components/type-documentation.js +394 -0
  35. package/dist/components/type-documentation.js.map +1 -0
  36. package/dist/components/type-link.d.ts +9 -0
  37. package/dist/components/type-link.js +52 -0
  38. package/dist/components/type-link.js.map +1 -0
  39. package/dist/components/utils.d.ts +3 -0
  40. package/dist/components/utils.js +22 -0
  41. package/dist/components/utils.js.map +1 -0
  42. package/dist/context.d.ts +56 -0
  43. package/dist/context.js +234 -0
  44. package/dist/context.js.map +1 -0
  45. package/dist/index.d.ts +5 -0
  46. package/dist/index.js +42 -0
  47. package/dist/index.js.map +1 -0
  48. package/dist/style.css +285 -0
  49. package/package.json +60 -0
@@ -0,0 +1,234 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { c } from "react-compiler-runtime";
3
+ import { isNamedType, isObjectType, isInputObjectType, isScalarType, isEnumType, isInterfaceType, isUnionType } from "graphql";
4
+ import { useState, useEffect } from "react";
5
+ import { createNullableContext, createContextHook, useSchemaContext } from "@graphiql/react";
6
+ const initialNavStackItem = {
7
+ name: "Docs"
8
+ };
9
+ const ExplorerContext = createNullableContext("ExplorerContext");
10
+ function ExplorerContextProvider(props) {
11
+ const $ = c(17);
12
+ let t0;
13
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
14
+ t0 = {
15
+ nonNull: true,
16
+ caller: ExplorerContextProvider
17
+ };
18
+ $[0] = t0;
19
+ } else {
20
+ t0 = $[0];
21
+ }
22
+ const {
23
+ schema,
24
+ validationErrors,
25
+ schemaReference
26
+ } = useSchemaContext(t0);
27
+ let t1;
28
+ if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
29
+ t1 = [initialNavStackItem];
30
+ $[1] = t1;
31
+ } else {
32
+ t1 = $[1];
33
+ }
34
+ const [navStack, setNavStack] = useState(t1);
35
+ let t2;
36
+ if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
37
+ t2 = (item) => {
38
+ setNavStack((currentState) => {
39
+ const lastItem = currentState.at(-1);
40
+ return lastItem.def === item.def ? currentState : [...currentState, item];
41
+ });
42
+ };
43
+ $[2] = t2;
44
+ } else {
45
+ t2 = $[2];
46
+ }
47
+ const push = t2;
48
+ let t3;
49
+ if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
50
+ t3 = () => {
51
+ setNavStack(_temp);
52
+ };
53
+ $[3] = t3;
54
+ } else {
55
+ t3 = $[3];
56
+ }
57
+ const pop = t3;
58
+ let t4;
59
+ if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
60
+ t4 = () => {
61
+ setNavStack(_temp2);
62
+ };
63
+ $[4] = t4;
64
+ } else {
65
+ t4 = $[4];
66
+ }
67
+ const reset = t4;
68
+ let t5;
69
+ let t6;
70
+ if ($[5] !== schemaReference) {
71
+ t5 = () => {
72
+ if (!schemaReference) {
73
+ return;
74
+ }
75
+ bb26: switch (schemaReference.kind) {
76
+ case "Type": {
77
+ push({
78
+ name: schemaReference.type.name,
79
+ def: schemaReference.type
80
+ });
81
+ break bb26;
82
+ }
83
+ case "Field": {
84
+ push({
85
+ name: schemaReference.field.name,
86
+ def: schemaReference.field
87
+ });
88
+ break bb26;
89
+ }
90
+ case "Argument": {
91
+ if (schemaReference.field) {
92
+ push({
93
+ name: schemaReference.field.name,
94
+ def: schemaReference.field
95
+ });
96
+ }
97
+ break bb26;
98
+ }
99
+ case "EnumValue": {
100
+ if (schemaReference.type) {
101
+ push({
102
+ name: schemaReference.type.name,
103
+ def: schemaReference.type
104
+ });
105
+ }
106
+ }
107
+ }
108
+ };
109
+ t6 = [schemaReference, push];
110
+ $[5] = schemaReference;
111
+ $[6] = t5;
112
+ $[7] = t6;
113
+ } else {
114
+ t5 = $[6];
115
+ t6 = $[7];
116
+ }
117
+ useEffect(t5, t6);
118
+ let t7;
119
+ let t8;
120
+ if ($[8] !== schema || $[9] !== validationErrors) {
121
+ t7 = () => {
122
+ if (schema == null || validationErrors.length > 0) {
123
+ reset();
124
+ } else {
125
+ setNavStack((oldNavStack) => {
126
+ if (oldNavStack.length === 1) {
127
+ return oldNavStack;
128
+ }
129
+ const newNavStack = [initialNavStackItem];
130
+ let lastEntity = null;
131
+ for (const item_0 of oldNavStack) {
132
+ if (item_0 === initialNavStackItem) {
133
+ continue;
134
+ }
135
+ if (item_0.def) {
136
+ if (isNamedType(item_0.def)) {
137
+ const newType = schema.getType(item_0.def.name);
138
+ if (newType) {
139
+ newNavStack.push({
140
+ name: item_0.name,
141
+ def: newType
142
+ });
143
+ lastEntity = newType;
144
+ } else {
145
+ break;
146
+ }
147
+ } else {
148
+ if (lastEntity === null) {
149
+ break;
150
+ } else {
151
+ if (isObjectType(lastEntity) || isInputObjectType(lastEntity)) {
152
+ const field = lastEntity.getFields()[item_0.name];
153
+ if (field) {
154
+ newNavStack.push({
155
+ name: item_0.name,
156
+ def: field
157
+ });
158
+ } else {
159
+ break;
160
+ }
161
+ } else {
162
+ if (isScalarType(lastEntity) || isEnumType(lastEntity) || isInterfaceType(lastEntity) || isUnionType(lastEntity)) {
163
+ break;
164
+ } else {
165
+ const field_0 = lastEntity;
166
+ if (field_0.args.some((a) => a.name === item_0.name)) {
167
+ newNavStack.push({
168
+ name: item_0.name,
169
+ def: field_0
170
+ });
171
+ } else {
172
+ break;
173
+ }
174
+ }
175
+ }
176
+ }
177
+ }
178
+ } else {
179
+ lastEntity = null;
180
+ newNavStack.push(item_0);
181
+ }
182
+ }
183
+ return newNavStack;
184
+ });
185
+ }
186
+ };
187
+ t8 = [schema, validationErrors];
188
+ $[8] = schema;
189
+ $[9] = validationErrors;
190
+ $[10] = t7;
191
+ $[11] = t8;
192
+ } else {
193
+ t7 = $[10];
194
+ t8 = $[11];
195
+ }
196
+ useEffect(t7, t8);
197
+ let t9;
198
+ if ($[12] !== navStack) {
199
+ t9 = {
200
+ explorerNavStack: navStack,
201
+ push,
202
+ pop,
203
+ reset
204
+ };
205
+ $[12] = navStack;
206
+ $[13] = t9;
207
+ } else {
208
+ t9 = $[13];
209
+ }
210
+ const value = t9;
211
+ let t10;
212
+ if ($[14] !== props.children || $[15] !== value) {
213
+ t10 = /* @__PURE__ */ jsx(ExplorerContext.Provider, { value, children: props.children });
214
+ $[14] = props.children;
215
+ $[15] = value;
216
+ $[16] = t10;
217
+ } else {
218
+ t10 = $[16];
219
+ }
220
+ return t10;
221
+ }
222
+ function _temp2(currentState_1) {
223
+ return currentState_1.length === 1 ? currentState_1 : [initialNavStackItem];
224
+ }
225
+ function _temp(currentState_0) {
226
+ return currentState_0.length > 1 ? currentState_0.slice(0, -1) : currentState_0;
227
+ }
228
+ const useExplorerContext = createContextHook(ExplorerContext);
229
+ export {
230
+ ExplorerContext,
231
+ ExplorerContextProvider,
232
+ useExplorerContext
233
+ };
234
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.js","sources":["../src/context.tsx"],"sourcesContent":["import type {\n GraphQLArgument,\n GraphQLField,\n GraphQLInputField,\n GraphQLNamedType,\n} from 'graphql';\nimport {\n isEnumType,\n isInputObjectType,\n isInterfaceType,\n isNamedType,\n isObjectType,\n isScalarType,\n isUnionType,\n} from 'graphql';\nimport { ReactNode, useEffect, useState } from 'react';\nimport {\n useSchemaContext,\n createContextHook,\n createNullableContext,\n} from '@graphiql/react';\n\nexport type ExplorerFieldDef =\n | GraphQLField<unknown, unknown>\n | GraphQLInputField\n | GraphQLArgument;\n\nexport type ExplorerNavStackItem = {\n /**\n * The name of the item.\n */\n name: string;\n /**\n * The definition object of the item, this can be a named type, a field, an\n * input field or an argument.\n */\n def?: GraphQLNamedType | ExplorerFieldDef;\n};\n\n// There's always at least one item in the nav stack\nexport type ExplorerNavStack = [\n ExplorerNavStackItem,\n ...ExplorerNavStackItem[],\n];\n\nconst initialNavStackItem: ExplorerNavStackItem = { name: 'Docs' };\n\nexport type ExplorerContextType = {\n /**\n * A stack of navigation items. The last item in the list is the current one.\n * This list always contains at least one item.\n */\n explorerNavStack: ExplorerNavStack;\n /**\n * Push an item to the navigation stack.\n * @param item The item that should be pushed to the stack.\n */\n push(item: ExplorerNavStackItem): void;\n /**\n * Pop the last item from the navigation stack.\n */\n pop(): void;\n /**\n * Reset the navigation stack to its initial state, this will remove all but\n * the initial stack item.\n */\n reset(): void;\n};\n\nexport const ExplorerContext =\n createNullableContext<ExplorerContextType>('ExplorerContext');\n\ntype ExplorerContextProviderProps = {\n children: ReactNode;\n};\n\nexport function ExplorerContextProvider(props: ExplorerContextProviderProps) {\n const { schema, validationErrors, schemaReference } = useSchemaContext({\n nonNull: true,\n caller: ExplorerContextProvider,\n });\n\n const [navStack, setNavStack] = useState<ExplorerNavStack>([\n initialNavStackItem,\n ]);\n\n const push = // eslint-disable-line react-hooks/exhaustive-deps -- false positive, variable is optimized by react-compiler, no need to wrap with useCallback\n (item: ExplorerNavStackItem) => {\n setNavStack(currentState => {\n const lastItem = currentState.at(-1)!;\n return lastItem.def === item.def\n ? // Avoid pushing duplicate items\n currentState\n : [...currentState, item];\n });\n };\n\n const pop = () => {\n setNavStack(currentState =>\n currentState.length > 1\n ? (currentState.slice(0, -1) as ExplorerNavStack)\n : currentState,\n );\n };\n\n const reset = () => {\n setNavStack(currentState =>\n currentState.length === 1 ? currentState : [initialNavStackItem],\n );\n };\n\n useEffect(() => {\n if (!schemaReference) {\n return;\n }\n switch (schemaReference.kind) {\n case 'Type': {\n push({ name: schemaReference.type.name, def: schemaReference.type });\n break;\n }\n case 'Field': {\n push({ name: schemaReference.field.name, def: schemaReference.field });\n break;\n }\n case 'Argument': {\n if (schemaReference.field) {\n push({\n name: schemaReference.field.name,\n def: schemaReference.field,\n });\n }\n break;\n }\n case 'EnumValue': {\n if (schemaReference.type) {\n push({ name: schemaReference.type.name, def: schemaReference.type });\n }\n break;\n }\n }\n }, [schemaReference, push]);\n\n useEffect(() => {\n // Whenever the schema changes, we must revalidate/replace the nav stack.\n if (schema == null || validationErrors.length > 0) {\n reset();\n } else {\n // Replace the nav stack with an updated version using the new schema\n setNavStack(oldNavStack => {\n if (oldNavStack.length === 1) {\n return oldNavStack;\n }\n const newNavStack: ExplorerNavStack = [initialNavStackItem];\n let lastEntity:\n | GraphQLNamedType\n | GraphQLField<unknown, unknown>\n | null = null;\n for (const item of oldNavStack) {\n if (item === initialNavStackItem) {\n // No need to copy the initial item\n continue;\n }\n if (item.def) {\n // If item.def isn't a named type, it must be a field, inputField, or argument\n if (isNamedType(item.def)) {\n // The type needs to be replaced with the new schema type of the same name\n const newType = schema.getType(item.def.name);\n if (newType) {\n newNavStack.push({\n name: item.name,\n def: newType,\n });\n lastEntity = newType;\n } else {\n // This type no longer exists; the stack cannot be built beyond here\n break;\n }\n } else if (lastEntity === null) {\n // We can't have a sub-entity if we have no entity; stop rebuilding the nav stack\n break;\n } else if (\n isObjectType(lastEntity) ||\n isInputObjectType(lastEntity)\n ) {\n // item.def must be a Field / input field; replace with the new field of the same name\n const field = lastEntity.getFields()[item.name];\n if (field) {\n newNavStack.push({\n name: item.name,\n def: field,\n });\n } else {\n // This field no longer exists; the stack cannot be built beyond here\n break;\n }\n } else if (\n isScalarType(lastEntity) ||\n isEnumType(lastEntity) ||\n isInterfaceType(lastEntity) ||\n isUnionType(lastEntity)\n ) {\n // These don't (currently) have non-type sub-entries; something has gone wrong.\n // Handle gracefully by discontinuing rebuilding the stack.\n break;\n } else {\n // lastEntity must be a field (because it's not a named type)\n const field: GraphQLField<unknown, unknown> = lastEntity;\n // Thus item.def must be an argument, so find the same named argument in the new schema\n if (field.args.some(a => a.name === item.name)) {\n newNavStack.push({\n name: item.name,\n def: field,\n });\n } else {\n // This argument no longer exists; the stack cannot be built beyond here\n break;\n }\n }\n } else {\n lastEntity = null;\n newNavStack.push(item);\n }\n }\n return newNavStack;\n });\n }\n }, [schema, validationErrors]);\n\n const value: ExplorerContextType = {\n explorerNavStack: navStack,\n push,\n pop,\n reset,\n };\n\n return (\n <ExplorerContext.Provider value={value}>\n {props.children}\n </ExplorerContext.Provider>\n );\n}\n\nexport const useExplorerContext = createContextHook(ExplorerContext);\n"],"names":["initialNavStackItem","name","ExplorerContext","createNullableContext","ExplorerContextProvider","props","$","_c","t0","Symbol","for","nonNull","caller","schema","validationErrors","schemaReference","useSchemaContext","t1","navStack","setNavStack","useState","t2","item","currentState","lastItem","at","def","push","t3","_temp","pop","t4","_temp2","reset","t5","t6","kind","type","bb26","field","useEffect","t7","t8","length","oldNavStack","newNavStack","lastEntity","item_0","isNamedType","newType","getType","isObjectType","isInputObjectType","getFields","isScalarType","isEnumType","isInterfaceType","isUnionType","field_0","args","some","a","t9","explorerNavStack","value","t10","children","currentState_1","currentState_0","slice","useExplorerContext","createContextHook"],"mappings":";;;;;AA6CA,MAAMA,sBAA4C;AAAA,EAAEC,MAAM;AAAO;AAwBpDC,MAAAA,kBACXC,sBAA2C,iBAAiB;AAMvD,SAAAC,wBAAAC,OAAA;AAAAC,QAAAA,IAAAC,EAAA,EAAA;AAAAC,MAAAA;AAAA,MAAAF,EAAA,CAAA,MAAAG,OAAAC,IAAA,2BAAA,GAAA;AACkE,SAAA;AAAA,MAAAC,SAAA;AAAA,MAAAC,QAAAR;AAAAA,IAAA;AAGtEE,WAAAE;AAAAA,EAAAA,OAAA;AAAAA,SAAAF,EAAA,CAAA;AAAA,EAAA;AAHD,QAAA;AAAA,IAAAO;AAAAA,IAAAC;AAAAA,IAAAC;AAAAA,EAAAA,IAAsDC,iBAAiBR,EAGtE;AAAES,MAAAA;AAAA,MAAAX,EAAA,CAAA,MAAAG,OAAAC,IAAA,2BAAA,GAAA;AAEwDO,UAAAjB,mBAAA;AAE1DM,WAAAW;AAAAA,EAAAA,OAAA;AAAAA,SAAAX,EAAA,CAAA;AAAA,EAAA;AAFD,QAAA,CAAAY,UAAAC,WAAA,IAAgCC,SAA2BH,EAE1D;AAAEI,MAAAA;AAAA,MAAAf,EAAA,CAAA,MAAAG,OAAAC,IAAA,2BAAA,GAAA;AAGDW,SAAAC,CAAA,SAAA;AACEH,kBAAWI,CAAA,iBAAA;AACTC,cAAAA,WAAiBD,aAAYE,KAAM;AAC5BD,eAAAA,SAAQE,QAASJ,KAAII,MAExBH,eAAY,CAAA,GACRA,cAAcD,IAAI;AAAA,MAAA,CAC3B;AAAA,IAAC;AACHhB,WAAAe;AAAAA,EAAAA,OAAA;AAAAA,SAAAf,EAAA,CAAA;AAAA,EAAA;AATH,QAAAqB,OACEN;AAQEO,MAAAA;AA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AAA0D,OAAA;AAGAC,8BAAA,gBAAA,UAAA,EAAiCD,OAC9B3D,gBAAK6D,UACR;AAA2B,MAAA,EAAA,IAAA7D,MAAA6D;AAAA5D,YAAA0D;AAAA1D,YAAA2D;AAAAA,EAAAA,OAAA;AAAAA,UAAA3D,EAAA,EAAA;AAAA,EAAA;AAF3B2D,SAAAA;AAE2B;AAlKxB,SAAAjC,OAAAmC,gBAAA;AAAA,SA+BD5C,eAAYoB,WAAA,IAAgBpB,iBAAY,CAAAvB,mBAAA;AAAwB;AA/B/D,SAAA6B,MAAAuC,gBAAA;AAAA,SAuBD7C,eAAYoB,SAAA,IACPpB,eAAY8C,MAAY,GAAA,EAAA,IACzB9C;AAAY;AA6IT+C,MAAAA,qBAAqBC,kBAAkBrE,eAAe;"}
@@ -0,0 +1,5 @@
1
+ import { GraphiQLPlugin } from '@graphiql/react';
2
+ export * from './components';
3
+ export { ExplorerContext, ExplorerContextProvider, useExplorerContext, } from './context';
4
+ export type { ExplorerContextType, ExplorerFieldDef, ExplorerNavStack, ExplorerNavStackItem, } from './context';
5
+ export declare const DOC_EXPLORER_PLUGIN: GraphiQLPlugin;
package/dist/index.js ADDED
@@ -0,0 +1,42 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { usePluginContext, DocsFilledIcon, DocsIcon } from "@graphiql/react";
3
+ import { ExplorerContext, ExplorerContextProvider, useExplorerContext } from "./context.js";
4
+ import { DocExplorer } from "./components/doc-explorer.js";
5
+ import { Argument } from "./components/argument.js";
6
+ import { DefaultValue } from "./components/default-value.js";
7
+ import { DeprecationReason } from "./components/deprecation-reason.js";
8
+ import { Directive } from "./components/directive.js";
9
+ import { FieldDocumentation } from "./components/field-documentation.js";
10
+ import { FieldLink } from "./components/field-link.js";
11
+ import { SchemaDocumentation } from "./components/schema-documentation.js";
12
+ import { Search } from "./components/search.js";
13
+ import { ExplorerSection } from "./components/section.js";
14
+ import { TypeDocumentation } from "./components/type-documentation.js";
15
+ import { TypeLink } from "./components/type-link.js";
16
+ const DOC_EXPLORER_PLUGIN = {
17
+ title: "Documentation Explorer",
18
+ icon: function Icon() {
19
+ const pluginContext = usePluginContext();
20
+ return (pluginContext == null ? void 0 : pluginContext.visiblePlugin) === DOC_EXPLORER_PLUGIN ? /* @__PURE__ */ jsx(DocsFilledIcon, {}) : /* @__PURE__ */ jsx(DocsIcon, {});
21
+ },
22
+ content: DocExplorer
23
+ };
24
+ export {
25
+ Argument,
26
+ DOC_EXPLORER_PLUGIN,
27
+ DefaultValue,
28
+ DeprecationReason,
29
+ Directive,
30
+ DocExplorer,
31
+ ExplorerContext,
32
+ ExplorerContextProvider,
33
+ ExplorerSection,
34
+ FieldDocumentation,
35
+ FieldLink,
36
+ SchemaDocumentation,
37
+ Search,
38
+ TypeDocumentation,
39
+ TypeLink,
40
+ useExplorerContext
41
+ };
42
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../src/index.tsx"],"sourcesContent":["import {\n DocsFilledIcon,\n DocsIcon,\n GraphiQLPlugin,\n usePluginContext,\n} from '@graphiql/react';\nimport { DocExplorer } from './components';\n\nexport * from './components';\n\nexport {\n ExplorerContext,\n ExplorerContextProvider,\n useExplorerContext,\n} from './context';\n\nexport type {\n ExplorerContextType,\n ExplorerFieldDef,\n ExplorerNavStack,\n ExplorerNavStackItem,\n} from './context';\n\nexport const DOC_EXPLORER_PLUGIN: GraphiQLPlugin = {\n title: 'Documentation Explorer',\n icon: function Icon() {\n const pluginContext = usePluginContext();\n return pluginContext?.visiblePlugin === DOC_EXPLORER_PLUGIN ? (\n <DocsFilledIcon />\n ) : (\n <DocsIcon />\n );\n },\n content: DocExplorer,\n};\n"],"names":["DOC_EXPLORER_PLUGIN","title","icon","Icon","pluginContext","usePluginContext","visiblePlugin","content","DocExplorer"],"mappings":";;;;;;;;;;;;;;;AAuBO,MAAMA,sBAAsC;AAAA,EACjDC,OAAO;AAAA,EACPC,MAAM,SAASC,OAAO;AACpB,UAAMC,gBAAgBC,iBAAiB;AACvC,YAAOD,+CAAeE,mBAAkBN,0CACrC,gBAAiB,CAAA,CAAA,wBAEjB,UACF,EAAA;AAAA,EACH;AAAA,EACAO,SAASC;AACX;"}
package/dist/style.css ADDED
@@ -0,0 +1,285 @@
1
+ .graphiql-doc-explorer-default-value {
2
+ color: hsl(var(--color-success));
3
+ }
4
+ a.graphiql-doc-explorer-type-name {
5
+ color: hsl(var(--color-warning));
6
+ text-decoration: none;
7
+ }
8
+
9
+ a.graphiql-doc-explorer-type-name:hover {
10
+ text-decoration: underline;
11
+ }
12
+
13
+ a.graphiql-doc-explorer-type-name:focus {
14
+ outline: hsl(var(--color-warning)) auto 1px;
15
+ }
16
+ .graphiql-doc-explorer-argument > * + * {
17
+ margin-top: var(--px-12);
18
+ }
19
+
20
+ .graphiql-doc-explorer-argument-name {
21
+ color: hsl(var(--color-secondary));
22
+ }
23
+
24
+ .graphiql-doc-explorer-argument-deprecation {
25
+ background-color: hsla(var(--color-warning), var(--alpha-background-light));
26
+ border: 1px solid hsl(var(--color-warning));
27
+ border-radius: var(--border-radius-4);
28
+ color: hsl(var(--color-warning));
29
+ padding: var(--px-8);
30
+ }
31
+
32
+ .graphiql-doc-explorer-argument-deprecation-label {
33
+ font-size: var(--font-size-hint);
34
+ font-weight: var(--font-weight-medium);
35
+ }
36
+ .graphiql-doc-explorer-deprecation {
37
+ background-color: hsla(var(--color-warning), var(--alpha-background-light));
38
+ border: 1px solid hsl(var(--color-warning));
39
+ border-radius: var(--px-4);
40
+ color: hsl(var(--color-warning));
41
+ padding: var(--px-8);
42
+ }
43
+
44
+ .graphiql-doc-explorer-deprecation-label {
45
+ font-size: var(--font-size-hint);
46
+ font-weight: var(--font-weight-medium);
47
+ }
48
+ .graphiql-doc-explorer-directive {
49
+ color: hsl(var(--color-secondary));
50
+ }
51
+ .graphiql-doc-explorer-section-title {
52
+ font-size: var(--font-size-hint);
53
+ font-weight: var(--font-weight-medium);
54
+ align-items: center;
55
+ line-height: 1;
56
+ display: flex;
57
+ }
58
+
59
+ .graphiql-doc-explorer-section-title > svg {
60
+ height: var(--px-16);
61
+ margin-right: var(--px-8);
62
+ width: var(--px-16);
63
+ }
64
+
65
+ .graphiql-doc-explorer-section-content {
66
+ margin-left: var(--px-8);
67
+ margin-top: var(--px-16);
68
+ }
69
+
70
+ .graphiql-doc-explorer-section-content > * + * {
71
+ margin-top: var(--px-16);
72
+ }
73
+ .graphiql-doc-explorer-root-type {
74
+ color: hsl(var(--color-info));
75
+ }
76
+ .graphiql-doc-explorer-search {
77
+ color: hsla(var(--color-neutral), var(--alpha-secondary));
78
+ }
79
+
80
+ .graphiql-doc-explorer-search:not([data-state="idle"]) {
81
+ border: var(--popover-border);
82
+ border-radius: var(--border-radius-4);
83
+ box-shadow: var(--popover-box-shadow);
84
+ color: hsl(var(--color-neutral));
85
+ }
86
+
87
+ .graphiql-doc-explorer-search:not([data-state="idle"]) .graphiql-doc-explorer-search-input {
88
+ background: hsl(var(--color-base));
89
+ }
90
+
91
+ .graphiql-doc-explorer-search-input {
92
+ background-color: hsla(var(--color-neutral), var(--alpha-background-light));
93
+ border-radius: var(--border-radius-4);
94
+ padding: var(--px-8) var(--px-12);
95
+ align-items: center;
96
+ display: flex;
97
+ }
98
+
99
+ .graphiql-doc-explorer-search [role="combobox"] {
100
+ margin-left: var(--px-4);
101
+ background-color: #0000;
102
+ border: none;
103
+ width: 100%;
104
+ }
105
+
106
+ .graphiql-doc-explorer-search [role="combobox"]:focus {
107
+ outline: none;
108
+ }
109
+
110
+ .graphiql-doc-explorer-search [role="listbox"] {
111
+ background-color: hsl(var(--color-base));
112
+ border-bottom-left-radius: var(--border-radius-4);
113
+ border-bottom-right-radius: var(--border-radius-4);
114
+ border: none;
115
+ border-top: 1px solid hsla(var(--color-neutral), var(--alpha-background-heavy));
116
+ max-height: 400px;
117
+ font-size: var(--font-size-body);
118
+ padding: var(--px-4);
119
+ margin: 0;
120
+ position: relative;
121
+ overflow-y: auto;
122
+ }
123
+
124
+ .graphiql-doc-explorer-search [role="option"] {
125
+ border-radius: var(--border-radius-4);
126
+ color: hsla(var(--color-neutral), var(--alpha-secondary));
127
+ padding: var(--px-8) var(--px-12);
128
+ text-overflow: ellipsis;
129
+ white-space: nowrap;
130
+ cursor: pointer;
131
+ overflow-x: hidden;
132
+ }
133
+
134
+ .graphiql-doc-explorer-search [role="option"][data-headlessui-state="active"] {
135
+ background-color: hsla(var(--color-neutral), var(--alpha-background-light));
136
+ }
137
+
138
+ .graphiql-doc-explorer-search [role="option"]:hover {
139
+ background-color: hsla(var(--color-neutral), var(--alpha-background-medium));
140
+ }
141
+
142
+ .graphiql-doc-explorer-search [role="option"][data-headlessui-state="active"]:hover {
143
+ background-color: hsla(var(--color-neutral), var(--alpha-background-heavy));
144
+ }
145
+
146
+ .graphiql-doc-explorer-search [role="option"] + :is(.graphiql-doc-explorer-search [role="option"]) {
147
+ margin-top: var(--px-4);
148
+ }
149
+
150
+ .graphiql-doc-explorer-search-type {
151
+ color: hsl(var(--color-info));
152
+ }
153
+
154
+ .graphiql-doc-explorer-search-field {
155
+ color: hsl(var(--color-warning));
156
+ }
157
+
158
+ .graphiql-doc-explorer-search-argument {
159
+ color: hsl(var(--color-secondary));
160
+ }
161
+
162
+ .graphiql-doc-explorer-search-divider {
163
+ color: hsla(var(--color-neutral), var(--alpha-secondary));
164
+ font-size: var(--font-size-hint);
165
+ font-weight: var(--font-weight-medium);
166
+ margin-top: var(--px-8);
167
+ padding: var(--px-8) var(--px-12);
168
+ }
169
+
170
+ .graphiql-doc-explorer-search-empty {
171
+ color: hsla(var(--color-neutral), var(--alpha-secondary));
172
+ padding: var(--px-8) var(--px-12);
173
+ }
174
+ a.graphiql-doc-explorer-field-name {
175
+ color: hsl(var(--color-info));
176
+ text-decoration: none;
177
+ }
178
+
179
+ a.graphiql-doc-explorer-field-name:hover {
180
+ text-decoration: underline;
181
+ }
182
+
183
+ a.graphiql-doc-explorer-field-name:focus {
184
+ outline: hsl(var(--color-info)) auto 1px;
185
+ }
186
+ .graphiql-doc-explorer-item > :not(:first-child) {
187
+ margin-top: var(--px-12);
188
+ }
189
+
190
+ .graphiql-doc-explorer-argument-multiple {
191
+ margin-left: var(--px-8);
192
+ }
193
+
194
+ .graphiql-doc-explorer-enum-value {
195
+ color: hsl(var(--color-info));
196
+ }
197
+ .graphiql-doc-explorer-header {
198
+ justify-content: space-between;
199
+ display: flex;
200
+ position: relative;
201
+ }
202
+
203
+ .graphiql-doc-explorer-header:focus-within .graphiql-doc-explorer-title {
204
+ visibility: hidden;
205
+ }
206
+
207
+ .graphiql-doc-explorer-header:focus-within .graphiql-doc-explorer-back:not(:focus) {
208
+ color: #0000;
209
+ }
210
+
211
+ .graphiql-doc-explorer-header-content {
212
+ flex-direction: column;
213
+ min-width: 0;
214
+ display: flex;
215
+ }
216
+
217
+ .graphiql-doc-explorer-search {
218
+ position: absolute;
219
+ top: 0;
220
+ right: 0;
221
+ }
222
+
223
+ .graphiql-doc-explorer-search:focus-within {
224
+ left: 0;
225
+ }
226
+
227
+ .graphiql-doc-explorer-search:not(:focus-within) [role="combobox"] {
228
+ width: 5ch;
229
+ height: 24px;
230
+ }
231
+
232
+ .graphiql-doc-explorer-search [role="combobox"]:focus {
233
+ width: 100%;
234
+ }
235
+
236
+ a.graphiql-doc-explorer-back {
237
+ color: hsla(var(--color-neutral), var(--alpha-secondary));
238
+ align-items: center;
239
+ text-decoration: none;
240
+ display: flex;
241
+ }
242
+
243
+ a.graphiql-doc-explorer-back:hover {
244
+ text-decoration: underline;
245
+ }
246
+
247
+ a.graphiql-doc-explorer-back:focus {
248
+ outline: hsla(var(--color-neutral), var(--alpha-secondary)) auto 1px;
249
+ }
250
+
251
+ a.graphiql-doc-explorer-back:focus + .graphiql-doc-explorer-title {
252
+ visibility: unset;
253
+ }
254
+
255
+ a.graphiql-doc-explorer-back > svg {
256
+ height: var(--px-8);
257
+ margin-right: var(--px-8);
258
+ width: var(--px-8);
259
+ }
260
+
261
+ .graphiql-doc-explorer-title {
262
+ font-weight: var(--font-weight-medium);
263
+ font-size: var(--font-size-h2);
264
+ text-overflow: ellipsis;
265
+ white-space: nowrap;
266
+ overflow-x: hidden;
267
+ }
268
+
269
+ .graphiql-doc-explorer-title:not(:first-child) {
270
+ font-size: var(--font-size-h3);
271
+ margin-top: var(--px-8);
272
+ }
273
+
274
+ .graphiql-doc-explorer-content > * {
275
+ color: hsla(var(--color-neutral), var(--alpha-secondary));
276
+ margin-top: var(--px-20);
277
+ }
278
+
279
+ .graphiql-doc-explorer-error {
280
+ background-color: hsla(var(--color-error), var(--alpha-background-heavy));
281
+ border: 1px solid hsl(var(--color-error));
282
+ border-radius: var(--border-radius-8);
283
+ color: hsl(var(--color-error));
284
+ padding: var(--px-8) var(--px-12);
285
+ }
package/package.json ADDED
@@ -0,0 +1,60 @@
1
+ {
2
+ "name": "@graphiql/plugin-doc-explorer",
3
+ "version": "0.0.1-canary-aa7ad225.0",
4
+ "sideEffects": false,
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "https://github.com/graphql/graphiql",
8
+ "directory": "packages/graphiql-plugin-doc-explorer"
9
+ },
10
+ "homepage": "https://github.com/graphql/graphiql/tree/master/packages/graphiql-plugin-doc-explorer#readme",
11
+ "bugs": {
12
+ "url": "https://github.com/graphql/graphiql/issues?q=issue+label:@graphiql/plugin-doc-explorer"
13
+ },
14
+ "license": "MIT",
15
+ "exports": {
16
+ "./package.json": "./package.json",
17
+ "./style.css": "./dist/style.css",
18
+ ".": "./dist/index.js"
19
+ },
20
+ "types": "dist/index.d.ts",
21
+ "keywords": [
22
+ "react",
23
+ "graphql",
24
+ "graphiql",
25
+ "plugin",
26
+ "documentation",
27
+ "explorer"
28
+ ],
29
+ "files": [
30
+ "dist"
31
+ ],
32
+ "scripts": {
33
+ "dev": "vite build --watch",
34
+ "build": "vite build",
35
+ "test": "vitest",
36
+ "types:check": "tsc --noEmit"
37
+ },
38
+ "peerDependencies": {
39
+ "react": "^18 || ^19",
40
+ "react-dom": "^18 || ^19",
41
+ "graphql": "^15.5.0 || ^16.0.0 || ^17.0.0"
42
+ },
43
+ "dependencies": {
44
+ "react-compiler-runtime": "19.1.0-rc.1",
45
+ "@graphiql/react": "^0.32.0-canary-aa7ad225.0",
46
+ "@headlessui/react": "^2.2"
47
+ },
48
+ "devDependencies": {
49
+ "@vitejs/plugin-react": "^4.4.1",
50
+ "vite-plugin-dts": "^4.5.3",
51
+ "babel-plugin-react-compiler": "19.1.0-rc.1",
52
+ "@testing-library/dom": "^10.4.0",
53
+ "@testing-library/jest-dom": "^6.6.3",
54
+ "@testing-library/react": "^16.3.0",
55
+ "react": "^19.1.0",
56
+ "react-dom": "^19.1.0",
57
+ "vite": "^6.3.4",
58
+ "graphql": "^16.9.0"
59
+ }
60
+ }