@graphiql/plugin-doc-explorer 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -151,7 +151,7 @@ var DocExplorer = () => {
151
151
  let t5;
152
152
  if ($[33] !== t2 || $[34] !== t3 || $[35] !== t4) {
153
153
  t5 = /* @__PURE__ */ jsxs("section", {
154
- className: "graphiql-doc-explorer",
154
+ className: "graphiql-doc-explorer graphiql-side-panel-content",
155
155
  "aria-label": "Documentation Explorer",
156
156
  children: [
157
157
  t1,
@@ -1 +1 @@
1
- {"version":3,"file":"doc-explorer.js","names":["isEnumType","isInputObjectType","isInterfaceType","isObjectType","isType","isUnionType","useGraphiQL","pick","useDocExplorer","useDocExplorerActions","DocExplorer","$","_c","t0","Symbol","for","fetchError","isIntrospecting","schema","validationErrors","explorerNavStack","pop","content","navItem","navigateToIndex","at","t1","length","index","stepsBack","i","t2","message","def","isTypeOrFieldView","t3","name","t4","t5","TypeView","type","hasNewFieldsList","needsTypeDocs","t6","_jsx","_jsxs","_Fragment"],"sources":["../../src/components/doc-explorer.tsx"],"sourcesContent":["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"],"mappings":";;;;;;;;;;;;;;AAqBA,IAAaU,oBAAkB;CAAA,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CAAA,IAAA2B;CAAA,IAAA3B,EAAA,OAAA+B,iBAAA/B,EAAA,QAAA6B,MAAA;EAC9CF,KAAAI,iBACCE,oBAAA,OAAA;GAAe,WAAA;GACb,UAAAA,oBAAC,mBAAD;IAAyBJ;IAAM,YAAA;GAAW,CAAA;EACvC,CAAA;EACN7B,EAAA,KAAA+B;EAAA/B,EAAA,MAAA6B;EAAA7B,EAAA,MAAA2B;CAAA,OAAAA,KAAA3B,EAAA;CAAA,IAAAgC;CAAA,IAAAhC,EAAA,QAAAwB,MAAAxB,EAAA,QAAA0B,MAAA1B,EAAA,QAAA2B,IAAA;EAPHK,KAAAE,qBAAAC,UAAA,EAAA,UAAA;GACEX;GACCE;GACAC;EAIA,EAAA,CAAA;EACA3B,EAAA,MAAAwB;EAAAxB,EAAA,MAAA0B;EAAA1B,EAAA,MAAA2B;EAAA3B,EAAA,MAAAgC;CAAA,OAAAA,KAAAhC,EAAA;CAAA,OARHgC;AAQG"}
1
+ {"version":3,"file":"doc-explorer.js","names":["isEnumType","isInputObjectType","isInterfaceType","isObjectType","isType","isUnionType","useGraphiQL","pick","useDocExplorer","useDocExplorerActions","DocExplorer","$","_c","t0","Symbol","for","fetchError","isIntrospecting","schema","validationErrors","explorerNavStack","pop","content","navItem","navigateToIndex","at","t1","length","index","stepsBack","i","t2","message","def","isTypeOrFieldView","t3","name","t4","t5","TypeView","type","hasNewFieldsList","needsTypeDocs","t6","_jsx","_jsxs","_Fragment"],"sources":["../../src/components/doc-explorer.tsx"],"sourcesContent":["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 graphiql-side-panel-content\"\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"],"mappings":";;;;;;;;;;;;;;AAqBA,IAAaU,oBAAkB;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAAA,IAAAC;CAAA,IAAAF,EAAA,OAAAG,OAAAC,IAAA,2BAAA,GAAA;EAE3BF,KAAAN,KAAK,cAAc,mBAAmB,UAAU,kBAAkB;EAACI,EAAA,KAAAE;CAAA,OAAAA,KAAAF,EAAA;CADrE,MAAA,EAAAK,YAAAC,iBAAAC,QAAAC,qBAAkEb,YAChEO,EACF;CACA,MAAAO,mBAAyBZ,eAAe;CACxC,MAAA,EAAAa,QAAgBZ,sBAAsB;CAAE,IAAAa;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAb,EAAA,OAAAS,oBAAAT,EAAA,OAAAK,cAAAL,EAAA,OAAAM,mBAAAN,EAAA,OAAAU,OAAAV,EAAA,OAAAO,UAAAP,EAAA,OAAAQ,kBAAA;EACxCI,UAAgBH,iBAAgBK,GAAI,EAAE;EAAG,IAAAC;EAAA,IAAAf,EAAA,QAAAS,iBAAAO,UAAAhB,EAAA,QAAAU,KAAA;GAEjBK,MAAAE,UAAA;IACtB,MAAAC,YAAkBT,iBAAgBO,SAAU,IAAIC;IAChD,KAAA,IAAAE,IAAa,GAAGA,IAAID,WAAWC,KAC7BT,IAAI;GACL;GACFV,EAAA,MAAAS,iBAAAO;GAAAhB,EAAA,MAAAU;GAAAV,EAAA,MAAAe;EAAA,OAAAA,KAAAf,EAAA;EALDa,kBAAwBE;EAOxBJ,UAAyB;EACzB,IAAIN,YAAU;GAAA,IAAAe;GAAA,IAAApB,EAAA,QAAAG,OAAAC,IAAA,2BAAA,GAAA;IAEVgB,KAAAa,oBAAA,OAAA;K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A,KAAAxB,EAAA;CAAA,IAAA0B;CAAA,IAAA1B,EAAA,OAAA8B,oBAAA9B,EAAA,OAAA6B,MAAA;EACvBH,KAAAI,oBAAoBG,oBAAC,YAAD,EAAkBJ,KAAM,CAAA;EAAE7B,EAAA,KAAA8B;EAAA9B,EAAA,KAAA6B;EAAA7B,EAAA,KAAA0B;CAAA,OAAAA,KAAA1B,EAAA;CAAA,IAAA2B;CAAA,IAAA3B,EAAA,OAAA+B,iBAAA/B,EAAA,QAAA6B,MAAA;EAC9CF,KAAAI,iBACCE,oBAAA,OAAA;GAAe,WAAA;GACb,UAAAA,oBAAC,mBAAD;IAAyBJ;IAAM,YAAA;GAAW,CAAA;EACvC,CAAA;EACN7B,EAAA,KAAA+B;EAAA/B,EAAA,MAAA6B;EAAA7B,EAAA,MAAA2B;CAAA,OAAAA,KAAA3B,EAAA;CAAA,IAAAgC;CAAA,IAAAhC,EAAA,QAAAwB,MAAAxB,EAAA,QAAA0B,MAAA1B,EAAA,QAAA2B,IAAA;EAPHK,KAAAE,qBAAAC,UAAA,EAAA,UAAA;GACEX;GACCE;GACAC;EAIA,EAAA,CAAA;EACA3B,EAAA,MAAAwB;EAAAxB,EAAA,MAAA0B;EAAA1B,EAAA,MAAA2B;EAAA3B,EAAA,MAAAgC;CAAA,OAAAA,KAAAhC,EAAA;CAAA,OARHgC;AAQG"}
@@ -2,7 +2,7 @@ import { c } from "react-compiler-runtime";
2
2
  import { useEffect, useRef, useState } from "react";
3
3
  import { isInputObjectType, isInterfaceType, isObjectType } from "graphql";
4
4
  import { Combobox, ComboboxInput, ComboboxOption, ComboboxOptions } from "@headlessui/react";
5
- import { KEY_MAP, KeycapHint, MagnifyingGlassIcon, debounce, formatShortcutForOS, typeCategory } from "@graphiql/react";
5
+ import { KEY_MAP, KeycapHint, SearchInput, debounce, formatShortcutForOS, typeCategory } from "@graphiql/react";
6
6
  import { useDocExplorer, useDocExplorerActions } from "../context.js";
7
7
  import { useSearchResults } from "./search.js";
8
8
  import { renderType } from "./utils.js";
@@ -10,7 +10,7 @@ import { renderType } from "./utils.js";
10
10
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
11
11
  // src/components/search-row.tsx
12
12
  var SearchRow = () => {
13
- const $ = c(39);
13
+ const $ = c(36);
14
14
  const explorerNavStack = useDocExplorer();
15
15
  const { push } = useDocExplorerActions();
16
16
  const inputRef = useRef(null);
@@ -90,79 +90,68 @@ var SearchRow = () => {
90
90
  $[16] = t5;
91
91
  } else t5 = $[16];
92
92
  const shortcutKeys = t5;
93
- const t6 = `Search ${navItem.name}...`;
94
- let t7;
95
- let t8;
93
+ let t6;
96
94
  if ($[17] === Symbol.for("react.memo_cache_sentinel")) {
97
- t7 = () => {
98
- inputRef.current.focus();
95
+ t6 = (event) => {
96
+ if (event.target === event.currentTarget) inputRef.current.focus();
99
97
  };
100
- t8 = /* @__PURE__ */ jsx(MagnifyingGlassIcon, { "aria-hidden": "true" });
101
- $[17] = t7;
102
- $[18] = t8;
103
- } else {
104
- t7 = $[17];
105
- t8 = $[18];
106
- }
98
+ $[17] = t6;
99
+ } else t6 = $[17];
100
+ const t7 = `Search ${navItem.name}...`;
107
101
  let t10;
108
- let t11;
102
+ let t8;
109
103
  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;
104
+ if ($[18] === Symbol.for("react.memo_cache_sentinel")) {
105
+ t8 = (event_0) => setSearchValue(event_0.target.value);
106
+ t9 = () => setIsFocused(true);
107
+ t10 = () => setIsFocused(false);
108
+ $[18] = t10;
109
+ $[19] = t8;
110
+ $[20] = t9;
117
111
  } else {
118
- t10 = $[19];
119
- t11 = $[20];
120
- t9 = $[21];
112
+ t10 = $[18];
113
+ t8 = $[19];
114
+ t9 = $[20];
121
115
  }
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, {
116
+ let t11;
117
+ if ($[21] !== isFocused || $[22] !== searchValue || $[23] !== shortcutKeys) {
118
+ t11 = !isFocused && !searchValue && /* @__PURE__ */ jsx(KeycapHint, {
140
119
  keys: shortcutKeys,
141
120
  ariaLabel: "Search docs shortcut"
142
121
  });
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", {
122
+ $[21] = isFocused;
123
+ $[22] = searchValue;
124
+ $[23] = shortcutKeys;
125
+ $[24] = t11;
126
+ } else t11 = $[24];
127
+ let t12;
128
+ if ($[25] !== searchValue || $[26] !== t11 || $[27] !== t7) {
129
+ t12 = /* @__PURE__ */ jsx("div", {
151
130
  className: "graphiql-doc-explorer-search-row-input",
152
- onClick: t7,
153
- children: [
154
- t8,
155
- t12,
156
- t13
157
- ]
131
+ onClick: t6,
132
+ children: /* @__PURE__ */ jsx(ComboboxInput, {
133
+ as: SearchInput,
134
+ monospace: true,
135
+ "aria-label": t7,
136
+ autoComplete: "off",
137
+ onChange: t8,
138
+ onFocus: t9,
139
+ onBlur: t10,
140
+ placeholder: "Search schema",
141
+ ref: inputRef,
142
+ value: searchValue,
143
+ "data-cy": "doc-explorer-input",
144
+ hint: t11
145
+ })
158
146
  });
147
+ $[25] = searchValue;
148
+ $[26] = t11;
149
+ $[27] = t7;
159
150
  $[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, {
151
+ } else t12 = $[28];
152
+ let t13;
153
+ if ($[29] !== isFocused || $[30] !== results) {
154
+ t13 = isFocused && /* @__PURE__ */ jsxs(ComboboxOptions, {
166
155
  className: "graphiql-doc-explorer-search-row-listbox",
167
156
  "data-cy": "doc-explorer-list",
168
157
  children: [
@@ -178,29 +167,27 @@ var SearchRow = () => {
178
167
  results.fields.map(_temp3)
179
168
  ]
180
169
  });
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", {
170
+ $[29] = isFocused;
171
+ $[30] = results;
172
+ $[31] = t13;
173
+ } else t13 = $[31];
174
+ let t14;
175
+ if ($[32] !== onSelect || $[33] !== t12 || $[34] !== t13) {
176
+ t14 = /* @__PURE__ */ jsx("div", {
188
177
  className: "graphiql-doc-explorer-search-row-wrapper",
189
178
  children: /* @__PURE__ */ jsxs(Combobox, {
190
179
  as: "div",
191
180
  className: "graphiql-doc-explorer-search-row",
192
181
  onChange: onSelect,
193
- "aria-label": t6,
194
- children: [t14, t15]
182
+ children: [t12, t13]
195
183
  })
196
184
  });
197
- $[34] = onSelect;
185
+ $[32] = onSelect;
186
+ $[33] = t12;
187
+ $[34] = t13;
198
188
  $[35] = t14;
199
- $[36] = t15;
200
- $[37] = t6;
201
- $[38] = t16;
202
- } else t16 = $[38];
203
- return t16;
189
+ } else t14 = $[35];
190
+ return t14;
204
191
  };
205
192
  var SearchType = (t0) => {
206
193
  const $ = c(5);
@@ -1 +1 @@
1
- {"version":3,"file":"search-row.js","names":["useEffect","useRef","useState","isInputObjectType","isInterfaceType","isObjectType","formatShortcutForOS","debounce","KEY_MAP","typeCategory","useDocExplorer","useDocExplorerActions","useSearchResults","renderType","type","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","SearchField","_temp4","result","i","result_0","i_0","result_1","i_1","namedType","_jsx","_jsxs","_Fragment"],"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,IAAaiB,kBAAgB;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAC3B,MAAAC,mBAAyBV,eAAe;CACxC,MAAA,EAAAW,SAAiBV,sBAAsB;CAEvC,MAAAW,WAAiBrB,OAAyB,IAAK;CAC/C,MAAAsB,mBAAyBX,iBAAiB;CAC1C,MAAA,CAAAY,aAAAC,kBAAsCvB,SAAS,EAAE;CAAE,IAAAwB;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,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AD;EAESR,OAAAA;EACC,WAAA;EAHV,UAAA;GAKEO,oBAAC,YAAD,EAAkB,MAAAP,SAAMhE,KAAO,CAAA;GAAE;GACjCuE,oBAAC,aAAD;IAAoB,OAAAP,SAAM/D;IAAkB,UAAA+D,SAAM9D;GAAW,CAAA;EAC/C;CANT,GAAA,SAAS+D,KAMA;AAAC;AAuBW,SAAAF,OAAAO,WAAA;CAAA,OAY9BC,oBAAC,YAAD,EAAkBD,MAAAA,UAAW,CAAA;AAAE"}
1
+ {"version":3,"file":"search-row.js","names":["useEffect","useRef","useState","isInputObjectType","isInterfaceType","isObjectType","formatShortcutForOS","SearchInput","debounce","KEY_MAP","typeCategory","useDocExplorer","useDocExplorerActions","useSearchResults","renderType","type","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","event","target","currentTarget","current","focus","t7","t10","t8","t9","event_0","value","t11","t12","t13","within","types","fields","map","_temp","_temp2","_temp3","t14","SearchType","SearchField","_temp4","result","i","result_0","i_0","result_1","i_1","namedType","_jsx","_jsxs","_Fragment"],"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 KeycapHint,\n SearchInput,\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 >\n {/* The Docs keyboard shortcut clicks this container after mount. */}\n <div\n className=\"graphiql-doc-explorer-search-row-input\"\n onClick={event => {\n if (event.target === event.currentTarget) {\n inputRef.current.focus();\n }\n }}\n >\n <ComboboxInput\n as={SearchInput}\n monospace\n aria-label={`Search ${navItem.name}...`}\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 hint={\n !isFocused &&\n !searchValue && (\n <KeycapHint\n keys={shortcutKeys}\n ariaLabel=\"Search docs shortcut\"\n />\n )\n }\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,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AzGJ,SAAAP,OAAAQ,UAAAC,KAAA;CAAA,OAmHfI,oBAAC,gBAAD;EAESP,OAAAA;EACC,WAAA;EAER,UAAAO,oBAAC,YAAD,EAAkB,MAAAP,SAAMhE,KAAO,CAAA;CACjB,GALT,QAAQiE,KAKC;AAAC;AAzHF,SAAAN,OAAAS,UAAAC,KAAA;CAAA,OA4HfG,qBAAC,gBAAD;EAESR,OAAAA;EACC,WAAA;EAHV,UAAA;GAKEO,oBAAC,YAAD,EAAkB,MAAAP,SAAMhE,KAAO,CAAA;GAAE;GACjCuE,oBAAC,aAAD;IAAoB,OAAAP,SAAM/D;IAAkB,UAAA+D,SAAM9D;GAAW,CAAA;EAC/C;CANT,GAAA,SAAS+D,KAMA;AAAC;AAuBW,SAAAF,OAAAO,WAAA;CAAA,OAY9BC,oBAAC,YAAD,EAAkBD,MAAAA,UAAW,CAAA;AAAE"}
@@ -1,18 +1,17 @@
1
1
  import { c } from "react-compiler-runtime";
2
- import { isInputObjectType, isInterfaceType, isObjectType } from "graphql";
3
- import { useEffect, useRef, useState } from "react";
2
+ import { isInputObjectType, isInterfaceType, isNamedType, isObjectType } from "graphql";
3
+ import { useEffect, useState } from "react";
4
4
  import { Combobox, ComboboxInput, ComboboxOption, ComboboxOptions } from "@headlessui/react";
5
- import { KEY_MAP, KeycapHint, MagnifyingGlassIcon, debounce, formatShortcutForOS, useGraphiQL } from "@graphiql/react";
5
+ import { KEY_MAP, KeycapHint, SearchInput, debounce, formatShortcutForOS, useGraphiQL } from "@graphiql/react";
6
6
  import { useDocExplorer, useDocExplorerActions } from "../context.js";
7
7
  import { renderType } from "./utils.js";
8
8
  /* empty css */
9
9
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
10
10
  // src/components/search.tsx
11
11
  var Search = () => {
12
- const $ = c(39);
12
+ const $ = c(35);
13
13
  const explorerNavStack = useDocExplorer();
14
14
  const { push } = useDocExplorerActions();
15
- const inputRef = useRef(null);
16
15
  const getSearchResults = useSearchResults();
17
16
  const [searchValue, setSearchValue] = useState("");
18
17
  let t0;
@@ -91,78 +90,54 @@ var Search = () => {
91
90
  t4 = $[14];
92
91
  }
93
92
  if (!t4) return null;
94
- const t5 = isFocused ? void 0 : "idle";
95
- const t6 = `Search ${navItem.name}...`;
93
+ const t5 = `Search ${navItem.name}...`;
94
+ let t6;
96
95
  let t7;
97
96
  let t8;
98
97
  if ($[18] === Symbol.for("react.memo_cache_sentinel")) {
99
- t7 = () => {
100
- inputRef.current.focus();
101
- };
102
- t8 = /* @__PURE__ */ jsx(MagnifyingGlassIcon, { "aria-hidden": "true" });
103
- $[18] = t7;
104
- $[19] = t8;
98
+ t6 = (event) => setSearchValue(event.target.value);
99
+ t7 = () => setIsFocused(true);
100
+ t8 = () => setIsFocused(false);
101
+ $[18] = t6;
102
+ $[19] = t7;
103
+ $[20] = t8;
105
104
  } else {
106
- t7 = $[18];
107
- t8 = $[19];
105
+ t6 = $[18];
106
+ t7 = $[19];
107
+ t8 = $[20];
108
108
  }
109
- let t10;
110
- let t11;
111
109
  let t9;
112
- if ($[20] === Symbol.for("react.memo_cache_sentinel")) {
113
- t9 = (event) => setSearchValue(event.target.value);
114
- t10 = () => setIsFocused(true);
115
- t11 = () => setIsFocused(false);
116
- $[20] = t10;
117
- $[21] = t11;
118
- $[22] = t9;
119
- } else {
120
- t10 = $[20];
121
- t11 = $[21];
122
- t9 = $[22];
123
- }
124
- let t12;
125
- if ($[23] !== searchValue) {
126
- t12 = /* @__PURE__ */ jsx(ComboboxInput, {
127
- autoComplete: "off",
128
- onChange: t9,
129
- onFocus: t10,
130
- onBlur: t11,
131
- placeholder: "Search Docs",
132
- ref: inputRef,
133
- value: searchValue,
134
- "data-cy": "doc-explorer-input"
135
- });
136
- $[23] = searchValue;
137
- $[24] = t12;
138
- } else t12 = $[24];
139
- let t13;
140
- if ($[25] !== shortcutKeys) {
141
- t13 = /* @__PURE__ */ jsx(KeycapHint, {
110
+ if ($[21] !== isFocused || $[22] !== shortcutKeys) {
111
+ t9 = !isFocused && /* @__PURE__ */ jsx(KeycapHint, {
142
112
  keys: shortcutKeys,
143
113
  ariaLabel: "Search docs shortcut"
144
114
  });
145
- $[25] = shortcutKeys;
146
- $[26] = t13;
147
- } else t13 = $[26];
148
- let t14;
149
- if ($[27] !== t12 || $[28] !== t13) {
150
- t14 = /* @__PURE__ */ jsxs("div", {
151
- className: "graphiql-doc-explorer-search-input",
152
- onClick: t7,
153
- children: [
154
- t8,
155
- t12,
156
- t13
157
- ]
115
+ $[21] = isFocused;
116
+ $[22] = shortcutKeys;
117
+ $[23] = t9;
118
+ } else t9 = $[23];
119
+ let t10;
120
+ if ($[24] !== searchValue || $[25] !== t5 || $[26] !== t9) {
121
+ t10 = /* @__PURE__ */ jsx(ComboboxInput, {
122
+ as: SearchInput,
123
+ "aria-label": t5,
124
+ autoComplete: "off",
125
+ onChange: t6,
126
+ onFocus: t7,
127
+ onBlur: t8,
128
+ placeholder: "Search Docs",
129
+ value: searchValue,
130
+ "data-cy": "doc-explorer-input",
131
+ hint: t9
158
132
  });
159
- $[27] = t12;
160
- $[28] = t13;
161
- $[29] = t14;
162
- } else t14 = $[29];
163
- let t15;
164
- if ($[30] !== isFocused || $[31] !== results) {
165
- t15 = isFocused && /* @__PURE__ */ jsxs(ComboboxOptions, {
133
+ $[24] = searchValue;
134
+ $[25] = t5;
135
+ $[26] = t9;
136
+ $[27] = t10;
137
+ } else t10 = $[27];
138
+ let t11;
139
+ if ($[28] !== isFocused || $[29] !== results) {
140
+ t11 = isFocused && /* @__PURE__ */ jsxs(ComboboxOptions, {
166
141
  "data-cy": "doc-explorer-list",
167
142
  children: [
168
143
  results.within.length + results.types.length + results.fields.length === 0 ? /* @__PURE__ */ jsx("div", {
@@ -177,28 +152,24 @@ var Search = () => {
177
152
  results.fields.map(_temp3)
178
153
  ]
179
154
  });
180
- $[30] = isFocused;
181
- $[31] = results;
182
- $[32] = t15;
183
- } else t15 = $[32];
184
- let t16;
185
- if ($[33] !== onSelect || $[34] !== t14 || $[35] !== t15 || $[36] !== t5 || $[37] !== t6) {
186
- t16 = /* @__PURE__ */ jsxs(Combobox, {
155
+ $[28] = isFocused;
156
+ $[29] = results;
157
+ $[30] = t11;
158
+ } else t11 = $[30];
159
+ let t12;
160
+ if ($[31] !== onSelect || $[32] !== t10 || $[33] !== t11) {
161
+ t12 = /* @__PURE__ */ jsxs(Combobox, {
187
162
  as: "div",
188
163
  className: "graphiql-doc-explorer-search",
189
164
  onChange: onSelect,
190
- "data-state": t5,
191
- "aria-label": t6,
192
- children: [t14, t15]
165
+ children: [t10, t11]
193
166
  });
194
- $[33] = onSelect;
195
- $[34] = t14;
196
- $[35] = t15;
197
- $[36] = t5;
198
- $[37] = t6;
199
- $[38] = t16;
200
- } else t16 = $[38];
201
- return t16;
167
+ $[31] = onSelect;
168
+ $[32] = t10;
169
+ $[33] = t11;
170
+ $[34] = t12;
171
+ } else t12 = $[34];
172
+ return t12;
202
173
  };
203
174
  function useSearchResults() {
204
175
  const $ = c(5);
@@ -221,37 +192,59 @@ function useSearchResults() {
221
192
  };
222
193
  if (!schema) return matches;
223
194
  const withinType = navItem.def;
224
- const typeMap = schema.getTypeMap();
225
- let typeNames = Object.keys(typeMap);
226
- if (withinType) {
227
- typeNames = typeNames.filter((n) => n !== withinType.name);
228
- typeNames.unshift(withinType.name);
229
- }
230
- for (const typeName of typeNames) {
231
- if (matches.within.length + matches.types.length + matches.fields.length >= 100) break;
232
- const type = typeMap[typeName];
233
- if (withinType !== type && isMatch(typeName, searchValue)) matches.types.push({ type });
234
- if (!isObjectType(type) && !isInterfaceType(type) && !isInputObjectType(type)) continue;
235
- const fields = type.getFields();
236
- for (const fieldName in fields) {
237
- const field = fields[fieldName];
238
- let matchingArgs;
239
- if (!isMatch(fieldName, searchValue)) {
240
- if ("args" in field) {
241
- matchingArgs = field.args.filter((arg) => isMatch(arg.name, searchValue));
242
- if (matchingArgs.length === 0) continue;
243
- } else continue;
195
+ const query = searchValue.toLowerCase();
196
+ const exact = [];
197
+ const prefix = [];
198
+ const substring = [];
199
+ const byRank = [
200
+ exact,
201
+ prefix,
202
+ substring
203
+ ];
204
+ const matchRank = function matchRank(name) {
205
+ const lower = name.toLowerCase();
206
+ if (!query || lower === query) return 0;
207
+ if (lower.startsWith(query)) return 1;
208
+ return lower.includes(query) ? 2 : 1e400;
209
+ };
210
+ const searchFields = function searchFields(type) {
211
+ if (!isObjectType(type) && !isInterfaceType(type) && !isInputObjectType(type)) return;
212
+ for (const field of Object.values(type.getFields())) {
213
+ if (exact.length === 100) break;
214
+ const fieldRank = matchRank(field.name);
215
+ let showField = true;
216
+ if (fieldRank > 0 && "args" in field) for (const argument of field.args) {
217
+ const rank = matchRank(argument.name);
218
+ if (rank < fieldRank) {
219
+ showField = false;
220
+ const bucket = byRank[rank];
221
+ if (bucket.length < 100) bucket.push({
222
+ type,
223
+ field,
224
+ argument
225
+ });
226
+ }
244
227
  }
245
- matches[withinType === type ? "within" : "fields"].push(...matchingArgs ? matchingArgs.map((argument) => ({
246
- type,
247
- field,
248
- argument
249
- })) : [{
228
+ const bucket_0 = byRank[fieldRank];
229
+ if (showField && bucket_0 && bucket_0.length < 100) bucket_0.push({
250
230
  type,
251
231
  field
252
- }]);
232
+ });
253
233
  }
234
+ };
235
+ if (isNamedType(withinType)) searchFields(withinType);
236
+ const types = Object.values(schema.getTypeMap());
237
+ for (const type_0 of types) {
238
+ if (exact.length === 100) break;
239
+ const bucket_1 = byRank[matchRank(type_0.name)];
240
+ if (type_0 !== withinType && bucket_1 && bucket_1.length < 100) bucket_1.push({ type: type_0 });
254
241
  }
242
+ for (const type_1 of types) {
243
+ if (exact.length === 100) break;
244
+ if (type_1 !== withinType) searchFields(type_1);
245
+ }
246
+ for (const match of exact.concat(prefix, substring).slice(0, 100)) if ("field" in match) matches[match.type === withinType ? "within" : "fields"].push(match);
247
+ else matches.types.push(match);
255
248
  return matches;
256
249
  };
257
250
  $[2] = navItem;
@@ -263,14 +256,6 @@ function useSearchResults() {
263
256
  function _temp4(state) {
264
257
  return state.schema;
265
258
  }
266
- function isMatch(sourceText, searchValue) {
267
- try {
268
- const escaped = searchValue.replaceAll(/[^_0-9A-Za-z]/g, (ch) => "\\" + ch);
269
- return new RegExp(escaped, "i").test(sourceText);
270
- } catch {
271
- return sourceText.toLowerCase().includes(searchValue.toLowerCase());
272
- }
273
- }
274
259
  var Type = (t0) => {
275
260
  const $ = c(2);
276
261
  const { type } = t0;
@@ -1 +1 @@
1
- {"version":3,"file":"search.js","names":["isInputObjectType","isInterfaceType","isObjectType","useEffect","useRef","useState","formatShortcutForOS","useGraphiQL","debounce","KEY_MAP","useDocExplorer","useDocExplorerActions","renderType","Search","$","_c","explorerNavStack","push","inputRef","getSearchResults","useSearchResults","searchValue","setSearchValue","t0","results","setResults","isFocused","setIsFocused","t1","search","debouncedGetSearchResults","t2","t3","navItem","onSelect","shortcutKeys","t4","at","t5","def","name","field","type","t6","Symbol","for","searchInDocs","key","split","length","shouldSearchBoxAppear","undefined","t7","t8","current","focus","t10","t11","t9","event","target","value","t12","t13","t14","t15","within","types","fields","map","_temp","_temp2","_temp3","t16","argument","schema","_temp4","matches","withinType","typeMap","getTypeMap","typeNames","Object","keys","filter","n","unshift","typeName","isMatch","getFields","fieldName","matchingArgs","args","arg","state","sourceText","escaped","replaceAll","ch","RegExp","test","toLowerCase","includes","Type","Field","_temp5","result","i","result_0","i_0","result_1","i_1","namedType","_jsx","_jsxs","_Fragment"],"sources":["../../src/components/search.tsx"],"sourcesContent":["import {\n GraphQLArgument,\n GraphQLField,\n GraphQLInputField,\n GraphQLNamedType,\n isInputObjectType,\n isInterfaceType,\n isObjectType,\n} from 'graphql';\nimport { FC, useEffect, useRef, useState } from 'react';\nimport {\n Combobox,\n ComboboxInput,\n ComboboxOptions,\n ComboboxOption,\n} from '@headlessui/react';\nimport {\n formatShortcutForOS,\n useGraphiQL,\n KeycapHint,\n MagnifyingGlassIcon,\n debounce,\n KEY_MAP,\n} from '@graphiql/react';\nimport { useDocExplorer, useDocExplorerActions } from '../context';\nimport { renderType } from './utils';\nimport './search.css';\n\nexport const Search: 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 [isFocused, setIsFocused] = useState(false);\n const debouncedGetSearchResults = debounce(200, (search: string) => {\n setResults(getSearchResults(search));\n });\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 // `null` when we remove search value\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 const shortcutKeys = formatShortcutForOS(KEY_MAP.searchInDocs.key).split('-');\n\n const shouldSearchBoxAppear =\n explorerNavStack.length === 1 ||\n isObjectType(navItem.def) ||\n isInterfaceType(navItem.def) ||\n isInputObjectType(navItem.def);\n if (!shouldSearchBoxAppear) {\n return null;\n }\n\n return (\n <Combobox\n as=\"div\"\n className=\"graphiql-doc-explorer-search\"\n onChange={onSelect}\n data-state={isFocused ? undefined : 'idle'}\n aria-label={`Search ${navItem.name}...`}\n >\n <div\n className=\"graphiql-doc-explorer-search-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 Docs\"\n ref={inputRef}\n value={searchValue}\n data-cy=\"doc-explorer-input\"\n />\n <KeycapHint keys={shortcutKeys} ariaLabel=\"Search docs shortcut\" />\n </div>\n {isFocused && (\n <ComboboxOptions data-cy=\"doc-explorer-list\">\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 <Field field={result.field} argument={result.argument} />\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 <Type 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 <Type type={result.type} />.\n <Field field={result.field} argument={result.argument} />\n </ComboboxOption>\n ))}\n </ComboboxOptions>\n )}\n </Combobox>\n );\n};\n\ntype TypeMatch = { type: GraphQLNamedType };\n\ntype FieldMatch = {\n type: GraphQLNamedType;\n field: GraphQLField<unknown, unknown> | GraphQLInputField;\n argument?: GraphQLArgument;\n};\n\nexport function useSearchResults() {\n const explorerNavStack = useDocExplorer();\n const schema = useGraphiQL(state => state.schema);\n\n const navItem = explorerNavStack.at(-1)!;\n\n return (searchValue: string) => {\n const matches: {\n within: FieldMatch[];\n types: TypeMatch[];\n fields: FieldMatch[];\n } = {\n within: [],\n types: [],\n fields: [],\n };\n\n if (!schema) {\n return matches;\n }\n\n const withinType = navItem.def;\n\n const typeMap = schema.getTypeMap();\n let typeNames = Object.keys(typeMap);\n\n // Move the within type name to be the first searched.\n if (withinType) {\n typeNames = typeNames.filter(n => n !== withinType.name);\n typeNames.unshift(withinType.name);\n }\n for (const typeName of typeNames) {\n if (\n matches.within.length + matches.types.length + matches.fields.length >=\n 100\n ) {\n break;\n }\n\n const type = typeMap[typeName]!;\n if (withinType !== type && isMatch(typeName, searchValue)) {\n matches.types.push({ type });\n }\n\n if (\n !isObjectType(type) &&\n !isInterfaceType(type) &&\n !isInputObjectType(type)\n ) {\n continue;\n }\n\n const fields = type.getFields();\n for (const fieldName in fields) {\n const field = fields[fieldName]!;\n let matchingArgs: GraphQLArgument[] | undefined;\n\n if (!isMatch(fieldName, searchValue)) {\n if ('args' in field) {\n matchingArgs = field.args.filter(arg =>\n isMatch(arg.name, searchValue),\n );\n if (matchingArgs.length === 0) {\n continue;\n }\n } else {\n continue;\n }\n }\n\n matches[withinType === type ? 'within' : 'fields'].push(\n ...(matchingArgs\n ? matchingArgs.map(argument => ({ type, field, argument }))\n : [{ type, field }]),\n );\n }\n }\n\n return matches;\n };\n}\n\nfunction isMatch(sourceText: string, searchValue: string): boolean {\n try {\n const escaped = searchValue.replaceAll(/[^_0-9A-Za-z]/g, ch => '\\\\' + ch);\n return new RegExp(escaped, 'i').test(sourceText);\n } catch {\n return sourceText.toLowerCase().includes(searchValue.toLowerCase());\n }\n}\n\nconst Type: FC<{ type: GraphQLNamedType }> = ({ type }) => {\n return <span className=\"graphiql-doc-explorer-search-type\">{type.name}</span>;\n};\n\ntype FieldProps = {\n field: GraphQLField<unknown, unknown> | GraphQLInputField;\n argument?: GraphQLArgument;\n};\n\nconst Field: FC<FieldProps> = ({ 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 <Type type={namedType} />\n ))}\n )\n </>\n ) : null}\n </>\n );\n};\n"],"mappings":";;;;;;;;;;AA4BA,IAAaa,eAAa;CAAA,MAAAC,IAAAC,EAAA,EAAA;CACxB,MAAAC,mBAAyBN,eAAe;CACxC,MAAA,EAAAO,SAAiBN,sBAAsB;CAEvC,MAAAO,WAAiBd,OAAyB,IAAK;CAC/C,MAAAe,mBAAyBC,iBAAiB;CAC1C,MAAA,CAAAC,aAAAC,kBAAsCjB,SAAS,EAAE;CA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MAE1B;GAAE;EAEL,EAAA,CAAA,IAXD;EAYO3F,EAAA,KAAA4D;EAAA5D,EAAA,KAAAiB;CAAA,OAAAA,KAAAjB,EAAA;CAAA,IAAAkB;CAAA,IAAAlB,EAAA,OAAAc,MAAAd,EAAA,OAAAiB,IAAA;EAdVC,KAAAkF,qBAAAC,UAAA,EAAA,UAAA,CACEvF,IACCG,EAYO,EAAA,CAAA;EACPjB,EAAA,KAAAc;EAAAd,EAAA,KAAAiB;EAAAjB,EAAA,KAAAkB;CAAA,OAAAA,KAAAlB,EAAA;CAAA,OAfHkB;AAeG;AApPmB,SAAAsC,MAAAoC,QAAAC,GAAA;CAAA,OA+EZM,oBAAC,gBAAD;EAESP,OAAAA;EACC,WAAA;EAER,UAAAO,oBAAC,OAAD;GAAc,OAAAP,OAAMjE;GAAkB,UAAAiE,OAAMhC;EAAW,CAAA;CACzC,GALT,UAAUiC,GAKD;AAAC;AArFL,SAAApC,OAAAqC,UAAAC,KAAA;CAAA,OA+FdI,oBAAC,gBAAD;EAESP,OAAAA;EACC,WAAA;EAER,UAAAO,oBAAC,MAAD,EAAY,MAAAP,SAAMhE,KAAO,CAAA;CACX,GALT,QAAQiE,KAKC;AAAC;AArGH,SAAAnC,OAAAsC,UAAAC,KAAA;CAAA,OAwGdG,qBAAC,gBAAD;EAESR,OAAAA;EACC,WAAA;EAHV,UAAA;GAKEO,oBAAC,MAAD,EAAY,MAAAP,SAAMhE,KAAO,CAAA;GAAE;GAC3BuE,oBAAC,OAAD;IAAc,OAAAP,SAAMjE;IAAkB,UAAAiE,SAAMhC;GAAW,CAAA;EACzC;CANT,GAAA,SAASiC,KAMA;AAAC;AAoHC,SAAAF,OAAAO,WAAA;CAAA,OAYlBC,oBAAC,MAAD,EAAYD,MAAAA,UAAW,CAAA;AAAE"}
1
+ {"version":3,"file":"search.js","names":["isInputObjectType","isInterfaceType","isNamedType","isObjectType","useEffect","useState","formatShortcutForOS","useGraphiQL","SearchInput","debounce","KEY_MAP","useDocExplorer","useDocExplorerActions","renderType","Search","$","_c","explorerNavStack","push","getSearchResults","useSearchResults","searchValue","setSearchValue","t0","results","setResults","isFocused","setIsFocused","t1","search","debouncedGetSearchResults","t2","t3","navItem","onSelect","shortcutKeys","t4","at","t5","def","name","field","type","t6","Symbol","for","searchInDocs","key","split","length","shouldSearchBoxAppear","t7","t8","event","target","value","t9","t10","t11","within","types","fields","map","_temp","_temp2","_temp3","t12","argument","schema","_temp4","matches","withinType","query","toLowerCase","exact","prefix","substring","byRank","matchRank","lower","startsWith","includes","Infinity","searchFields","Object","values","getFields","fieldRank","showField","args","rank","bucket","bucket_0","getTypeMap","type_0","bucket_1","type_1","match","concat","slice","state","Type","Field","_temp5","result","i","result_0","i_0","result_1","i_1","namedType","_jsx","_jsxs","_Fragment"],"sources":["../../src/components/search.tsx"],"sourcesContent":["import {\n GraphQLArgument,\n GraphQLField,\n GraphQLInputField,\n GraphQLNamedType,\n isInputObjectType,\n isInterfaceType,\n isNamedType,\n isObjectType,\n} from 'graphql';\nimport { FC, useEffect, useState } from 'react';\nimport {\n Combobox,\n ComboboxInput,\n ComboboxOptions,\n ComboboxOption,\n} from '@headlessui/react';\nimport {\n formatShortcutForOS,\n useGraphiQL,\n KeycapHint,\n SearchInput,\n debounce,\n KEY_MAP,\n} from '@graphiql/react';\nimport { useDocExplorer, useDocExplorerActions } from '../context';\nimport { renderType } from './utils';\nimport './search.css';\n\nexport const Search: FC = () => {\n const explorerNavStack = useDocExplorer();\n const { push } = useDocExplorerActions();\n\n const getSearchResults = useSearchResults();\n const [searchValue, setSearchValue] = useState('');\n const [results, setResults] = useState(() => getSearchResults(searchValue));\n const [isFocused, setIsFocused] = useState(false);\n const debouncedGetSearchResults = debounce(200, (search: string) => {\n setResults(getSearchResults(search));\n });\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 // `null` when we remove search value\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 const shortcutKeys = formatShortcutForOS(KEY_MAP.searchInDocs.key).split('-');\n\n const shouldSearchBoxAppear =\n explorerNavStack.length === 1 ||\n isObjectType(navItem.def) ||\n isInterfaceType(navItem.def) ||\n isInputObjectType(navItem.def);\n if (!shouldSearchBoxAppear) {\n return null;\n }\n\n return (\n <Combobox\n as=\"div\"\n className=\"graphiql-doc-explorer-search\"\n onChange={onSelect}\n >\n <ComboboxInput\n as={SearchInput}\n aria-label={`Search ${navItem.name}...`}\n autoComplete=\"off\"\n onChange={event => setSearchValue(event.target.value)}\n onFocus={() => setIsFocused(true)}\n onBlur={() => setIsFocused(false)}\n placeholder=\"Search Docs\"\n value={searchValue}\n data-cy=\"doc-explorer-input\"\n hint={\n !isFocused && (\n <KeycapHint keys={shortcutKeys} ariaLabel=\"Search docs shortcut\" />\n )\n }\n />\n {isFocused && (\n <ComboboxOptions data-cy=\"doc-explorer-list\">\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 <Field field={result.field} argument={result.argument} />\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 <Type 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 <Type type={result.type} />.\n <Field field={result.field} argument={result.argument} />\n </ComboboxOption>\n ))}\n </ComboboxOptions>\n )}\n </Combobox>\n );\n};\n\ntype TypeMatch = { type: GraphQLNamedType };\n\ntype FieldMatch = {\n type: GraphQLNamedType;\n field: GraphQLField<unknown, unknown> | GraphQLInputField;\n argument?: GraphQLArgument;\n};\n\nexport function useSearchResults() {\n const explorerNavStack = useDocExplorer();\n const schema = useGraphiQL(state => state.schema);\n\n const navItem = explorerNavStack.at(-1)!;\n\n return (searchValue: string) => {\n const matches: {\n within: FieldMatch[];\n types: TypeMatch[];\n fields: FieldMatch[];\n } = {\n within: [],\n types: [],\n fields: [],\n };\n\n if (!schema) {\n return matches;\n }\n\n const withinType = navItem.def;\n const query = searchValue.toLowerCase();\n const limit = 100;\n const exact: Array<TypeMatch | FieldMatch> = [];\n const prefix: Array<TypeMatch | FieldMatch> = [];\n const substring: Array<TypeMatch | FieldMatch> = [];\n\n const byRank = [exact, prefix, substring];\n\n function matchRank(name: string): number {\n const lower = name.toLowerCase();\n if (!query || lower === query) {\n return 0;\n }\n if (lower.startsWith(query)) {\n return 1;\n }\n return lower.includes(query) ? 2 : Infinity;\n }\n\n function searchFields(type: GraphQLNamedType) {\n if (\n !isObjectType(type) &&\n !isInterfaceType(type) &&\n !isInputObjectType(type)\n ) {\n return;\n }\n for (const field of Object.values(type.getFields())) {\n if (exact.length === limit) {\n break;\n }\n const fieldRank = matchRank(field.name);\n let showField = true;\n if (fieldRank > 0 && 'args' in field) {\n for (const argument of field.args) {\n const rank = matchRank(argument.name);\n if (rank < fieldRank) {\n showField = false;\n const bucket = byRank[rank]!;\n if (bucket.length < limit) {\n bucket.push({ type, field, argument });\n }\n }\n }\n }\n const bucket = byRank[fieldRank];\n if (showField && bucket && bucket.length < limit) {\n bucket.push({ type, field });\n }\n }\n }\n\n // Break ties in the same order the explorer displays the groups.\n if (isNamedType(withinType)) {\n searchFields(withinType);\n }\n const types = Object.values(schema.getTypeMap());\n for (const type of types) {\n if (exact.length === limit) {\n break;\n }\n const bucket = byRank[matchRank(type.name)];\n if (type !== withinType && bucket && bucket.length < limit) {\n bucket.push({ type });\n }\n }\n for (const type of types) {\n if (exact.length === limit) {\n break;\n }\n if (type !== withinType) {\n searchFields(type);\n }\n }\n\n for (const match of exact.concat(prefix, substring).slice(0, limit)) {\n if ('field' in match) {\n matches[match.type === withinType ? 'within' : 'fields'].push(match);\n } else {\n matches.types.push(match);\n }\n }\n return matches;\n };\n}\n\nconst Type: FC<{ type: GraphQLNamedType }> = ({ type }) => {\n return <span className=\"graphiql-doc-explorer-search-type\">{type.name}</span>;\n};\n\ntype FieldProps = {\n field: GraphQLField<unknown, unknown> | GraphQLInputField;\n argument?: GraphQLArgument;\n};\n\nconst Field: FC<FieldProps> = ({ 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 <Type type={namedType} />\n ))}\n )\n </>\n ) : null}\n </>\n );\n};\n"],"mappings":";;;;;;;;;;AA6BA,IAAac,eAAa;CAAA,MAAAC,IAAAC,EAAA,EAAA;CACxB,MAAAC,mBAAyBN,eAAe;CACxC,MAAA,EAAAO,SAAiBN,sBAAsB;CAEvC,MAAAO,mBAAyBC,iBAAiB;CAC1C,MAAA,CAAAC,aAAAC,kBAAsCjB,SAAS,EAAE;CAAE,IAAAkB;CAAA,IAAAR,EAAA,OAAAI,oBAAAJ,EAAA,OAAAM,aAAA;EACZE,WAAMJ,iBAAiBE,WAAW;EAACN,EAAA,KAAAI;EAAAJ,EAAA,KAAAM;EAAAN,EAAA,KAAAQ;CAAA,OAAAA,KAAAR,EAAA;CAA1E,MAAA,CAAAS,SAAAC,cAA8BpB,SAASkB,EAAmC;CAC1E,MAAA,CAAAG,WAAAC,gBAAkCtB,SAAS,KAAK;CAAE,IAAAuB;CAAA,IAAAb,EAAA,OAAAI,kBAAA;EAChBS,KAAAnB,SAAS,MAAKoB,WAAA;GAC9CJ,WAA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AESP,OAAAA;EACC,WAAA;EAER,UAAAO,oBAAC,OAAD;GAAc,OAAAP,OAAM/D;GAAkB,UAAA+D,OAAMrC;EAAW,CAAA;CACzC,GALT,UAAUsC,GAKD;AAAC;AA/EL,SAAAzC,OAAA0C,UAAAC,KAAA;CAAA,OAyFdI,oBAAC,gBAAD;EAESP,OAAAA;EACC,WAAA;EAER,UAAAO,oBAAC,MAAD,EAAY,MAAAP,SAAM9D,KAAO,CAAA;CACX,GALT,QAAQ+D,KAKC;AAAC;AA/FH,SAAAxC,OAAA2C,UAAAC,KAAA;CAAA,OAkGdG,qBAAC,gBAAD;EAESR,OAAAA;EACC,WAAA;EAHV,UAAA;GAKEO,oBAAC,MAAD,EAAY,MAAAP,SAAM9D,KAAO,CAAA;GAAE;GAC3BqE,oBAAC,OAAD;IAAc,OAAAP,SAAM/D;IAAkB,UAAA+D,SAAMrC;GAAW,CAAA;EACzC;CANT,GAAA,SAASsC,KAMA;AAAC;AAqIC,SAAAF,OAAAO,WAAA;CAAA,OAYlBC,oBAAC,MAAD,EAAYD,MAAAA,UAAW,CAAA;AAAE"}
package/dist/context.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { GraphQLArgument, GraphQLField, GraphQLInputField, GraphQLNamedType, GraphQLSchema } from 'graphql';
2
- import { FC, ReactNode } from 'react';
2
+ import { FC, ReactNode, RefObject } from 'react';
3
3
  import { SchemaReference, GraphiQLPlugin } from '@graphiql/react';
4
4
  export declare const DOC_EXPLORER_PLUGIN: GraphiQLPlugin;
5
5
  export type DocExplorerFieldDef = GraphQLField<unknown, unknown> | GraphQLInputField | GraphQLArgument;
@@ -49,6 +49,8 @@ export type DocExplorerStoreType = {
49
49
  export declare const docExplorerStore: import('zustand').StoreApi<DocExplorerStoreType>;
50
50
  export declare const DocExplorerStore: FC<{
51
51
  children: ReactNode;
52
+ /** The container in which Cmd/Ctrl+K opens documentation search. */
53
+ shortcutTarget?: RefObject<HTMLElement | null>;
52
54
  }>;
53
55
  export declare const useDocExplorer: () => DocExplorerNavStack;
54
56
  /**
package/dist/context.js CHANGED
@@ -117,17 +117,17 @@ var docExplorerStore = createStore((set) => ({
117
117
  }
118
118
  }
119
119
  }));
120
- function focusSearchInputWhenMounted(framesLeft) {
120
+ function focusSearchInputWhenMounted(container, framesLeft) {
121
121
  if (framesLeft <= 0) return;
122
122
  requestAnimationFrame(() => {
123
- const el = document.querySelector(".graphiql-doc-explorer-search-row-input");
123
+ const el = container.querySelector(".graphiql-doc-explorer-search-row-input");
124
124
  if (el) el.click();
125
- else focusSearchInputWhenMounted(framesLeft - 1);
125
+ else focusSearchInputWhenMounted(container, framesLeft - 1);
126
126
  });
127
127
  }
128
128
  var DocExplorerStore = (t0) => {
129
- const $ = c(11);
130
- const { children } = t0;
129
+ const $ = c(12);
130
+ const { children, shortcutTarget } = t0;
131
131
  let t1;
132
132
  if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
133
133
  t1 = pick("schema", "validationErrors", "schemaReference");
@@ -171,27 +171,31 @@ var DocExplorerStore = (t0) => {
171
171
  useEffect(t4, t5);
172
172
  let t6;
173
173
  let t7;
174
- if ($[8] !== setVisiblePlugin) {
174
+ if ($[8] !== setVisiblePlugin || $[9] !== shortcutTarget) {
175
175
  t6 = () => {
176
+ const target = shortcutTarget?.current ?? document.documentElement;
176
177
  const handleKeyDown = function handleKeyDown(event) {
177
178
  if (!(event[isMacOs ? "metaKey" : "ctrlKey"] && event.code === "KeyK")) return;
179
+ const container = event.target instanceof Element ? event.target.closest(".graphiql-container") : null;
180
+ if (!container || shortcutTarget && container !== shortcutTarget.current) return;
178
181
  event.preventDefault();
179
182
  event.stopPropagation();
180
183
  setVisiblePlugin(DOC_EXPLORER_PLUGIN);
181
- focusSearchInputWhenMounted(10);
184
+ focusSearchInputWhenMounted(container, 10);
182
185
  };
183
- window.addEventListener("keydown", handleKeyDown, true);
186
+ target.addEventListener("keydown", handleKeyDown, true);
184
187
  return () => {
185
- window.removeEventListener("keydown", handleKeyDown, true);
188
+ target.removeEventListener("keydown", handleKeyDown, true);
186
189
  };
187
190
  };
188
- t7 = [setVisiblePlugin];
191
+ t7 = [setVisiblePlugin, shortcutTarget];
189
192
  $[8] = setVisiblePlugin;
190
- $[9] = t6;
191
- $[10] = t7;
193
+ $[9] = shortcutTarget;
194
+ $[10] = t6;
195
+ $[11] = t7;
192
196
  } else {
193
- t6 = $[9];
194
- t7 = $[10];
197
+ t6 = $[10];
198
+ t7 = $[11];
195
199
  }
196
200
  useEffect(t6, t7);
197
201
  return children;
@@ -1 +1 @@
1
- {"version":3,"file":"context.js","names":["isEnumType","isInputObjectType","isInterfaceType","isNamedType","isObjectType","isScalarType","isUnionType","useEffect","useGraphiQL","useGraphiQLActions","pick","createBoundedUseStore","isMacOs","createStore","getSchemaReference","DocExplorer","DOC_EXPLORER_PLUGIN","title","icon","Icon","visiblePlugin","state","content","name","def","explorerNavStack","actions","push","item","pop","reset","resolveSchemaReferenceToNavItem","schemaReference","rebuildNavStackWithSchema","schema","INITIAL_NAV_STACK","docExplorerStore","set","curr","lastItem","at","length","slice","kind","typeInfo","ref","items","type","field","oldNavStack","newNavStack","lastEntity","newType","getType","getFields","args","some","a","focusSearchInputWhenMounted","framesLeft","requestAnimationFrame","el","document","querySelector","click","DocExplorerStore","children","t0","$","_c","t1","Symbol","for","validationErrors","setVisiblePlugin","t2","t3","getState","t4","t5","t6","t7","handleKeyDown","event","code","preventDefault","stopPropagation","window","addEventListener","removeEventListener","useDocExplorerStore","useDocExplorer","_temp","useDocExplorerActions","_temp2","_jsx"],"sources":["../src/context.tsx"],"sourcesContent":["import type {\n GraphQLArgument,\n GraphQLField,\n GraphQLInputField,\n GraphQLNamedType,\n GraphQLSchema,\n} from 'graphql';\nimport {\n isEnumType,\n isInputObjectType,\n isInterfaceType,\n isNamedType,\n isObjectType,\n isScalarType,\n isUnionType,\n} from 'graphql';\nimport { FC, ReactElement, ReactNode, useEffect } from 'react';\nimport {\n SchemaReference,\n useGraphiQL,\n useGraphiQLActions,\n pick,\n createBoundedUseStore,\n GraphiQLPlugin,\n DocsFilledIcon,\n DocsIcon,\n isMacOs,\n} from '@graphiql/react';\nimport { createStore } from 'zustand';\nimport { getSchemaReference } from './schema-reference';\nimport { DocExplorer } from './components';\n\nexport const DOC_EXPLORER_PLUGIN: GraphiQLPlugin = {\n title: 'Documentation Explorer',\n icon: function Icon() {\n const visiblePlugin = useGraphiQL(state => state.visiblePlugin);\n return visiblePlugin === DOC_EXPLORER_PLUGIN ? (\n <DocsFilledIcon />\n ) : (\n <DocsIcon />\n );\n },\n content: DocExplorer,\n};\n\nexport type DocExplorerFieldDef =\n | GraphQLField<unknown, unknown>\n | GraphQLInputField\n | GraphQLArgument;\n\nexport type DocExplorerNavStackItem = {\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 | DocExplorerFieldDef;\n};\n\n// There's always at least one item in the nav stack\nexport type DocExplorerNavStack = [\n DocExplorerNavStackItem,\n ...DocExplorerNavStackItem[],\n];\n\nexport type DocExplorerStoreType = {\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: DocExplorerNavStack;\n actions: {\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: DocExplorerNavStackItem): 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 resolveSchemaReferenceToNavItem(\n schemaReference: SchemaReference | null,\n ): void;\n /**\n * Replace the nav stack with an updated version using the new schema.\n */\n rebuildNavStackWithSchema(schema: GraphQLSchema): void;\n };\n};\n\nconst INITIAL_NAV_STACK: DocExplorerNavStack = [{ name: 'Root' }];\n\nexport const docExplorerStore = createStore<DocExplorerStoreType>(set => ({\n explorerNavStack: INITIAL_NAV_STACK,\n actions: {\n push(item) {\n set(state => {\n const curr = state.explorerNavStack;\n const lastItem = curr.at(-1)!;\n const explorerNavStack: DocExplorerNavStack =\n // Avoid pushing duplicate items\n lastItem.def === item.def ? curr : [...curr, item];\n\n return { explorerNavStack };\n });\n },\n pop() {\n set(state => {\n const curr = state.explorerNavStack;\n\n const explorerNavStack =\n curr.length > 1 ? (curr.slice(0, -1) as DocExplorerNavStack) : curr;\n\n return { explorerNavStack };\n });\n },\n reset() {\n set(state => {\n const curr = state.explorerNavStack;\n const explorerNavStack = curr.length === 1 ? curr : INITIAL_NAV_STACK;\n return { explorerNavStack };\n });\n },\n resolveSchemaReferenceToNavItem(schemaReference) {\n if (!schemaReference) {\n return;\n }\n const { kind, typeInfo } = schemaReference;\n const ref = getSchemaReference(kind, typeInfo);\n if (!ref) {\n return;\n }\n\n // Replace the current path with the path to the referenced item,\n // rather than appending to it; repeatedly clicking the same reference\n // must not grow the stack.\n const items: DocExplorerNavStackItem[] = [];\n switch (ref.kind) {\n case 'Type': {\n items.push({\n name: ref.type.name,\n def: ref.type,\n });\n break;\n }\n case 'Field': {\n // Show a field type on stack\n if (ref.type) {\n items.push({\n name: ref.type.name,\n def: ref.type,\n });\n }\n items.push({\n name: ref.field.name,\n def: ref.field,\n });\n break;\n }\n case 'Argument': {\n if (ref.field) {\n items.push({\n name: ref.field.name,\n def: ref.field,\n });\n }\n break;\n }\n case 'EnumValue': {\n if (ref.type) {\n items.push({\n name: ref.type.name,\n def: ref.type,\n });\n }\n break;\n }\n }\n if (items.length > 0) {\n set({ explorerNavStack: [INITIAL_NAV_STACK[0], ...items] });\n }\n },\n rebuildNavStackWithSchema(schema: GraphQLSchema) {\n set(state => {\n const oldNavStack = state.explorerNavStack;\n if (oldNavStack.length === 1) {\n return state;\n }\n // Spread is needed\n const newNavStack: DocExplorerNavStack = [...INITIAL_NAV_STACK];\n let lastEntity:\n | GraphQLNamedType\n | GraphQLField<unknown, unknown>\n | null = null;\n for (const item of oldNavStack) {\n if (item === INITIAL_NAV_STACK[0]) {\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 { explorerNavStack: newNavStack };\n });\n },\n },\n}));\n\n// The doc-explorer panel (and its search input) mounts asynchronously after\n// `setVisiblePlugin` commits, which isn't guaranteed to land within a single\n// animation frame, so poll across a few frames rather than assuming one is\n// enough.\nfunction focusSearchInputWhenMounted(framesLeft: number) {\n if (framesLeft <= 0) {\n return;\n }\n requestAnimationFrame(() => {\n const el = document.querySelector<HTMLDivElement>(\n '.graphiql-doc-explorer-search-row-input',\n );\n if (el) {\n el.click();\n } else {\n focusSearchInputWhenMounted(framesLeft - 1);\n }\n });\n}\n\nexport const DocExplorerStore: FC<{\n children: ReactNode;\n}> = ({ children }) => {\n const { schema, validationErrors, schemaReference } = useGraphiQL(\n pick('schema', 'validationErrors', 'schemaReference'),\n );\n const { setVisiblePlugin } = useGraphiQLActions();\n\n useEffect(() => {\n const { resolveSchemaReferenceToNavItem } =\n docExplorerStore.getState().actions;\n resolveSchemaReferenceToNavItem(schemaReference);\n }, [schemaReference]);\n\n useEffect(() => {\n const { reset, rebuildNavStackWithSchema } =\n docExplorerStore.getState().actions;\n\n // Whenever the schema changes, we must revalidate/replace the nav stack.\n if (schema == null || validationErrors.length > 0) {\n reset();\n } else {\n rebuildNavStackWithSchema(schema);\n }\n }, [schema, validationErrors]);\n\n useEffect(() => {\n function handleKeyDown(event: KeyboardEvent) {\n const shouldOpenSearch =\n event[isMacOs ? 'metaKey' : 'ctrlKey'] &&\n // Using `event.code` because `event.key` will trigger different character\n // in English `˚` and in French `È`\n event.code === 'KeyK';\n if (!shouldOpenSearch) {\n return;\n }\n // Take priority over monaco-editor's built-in `Cmd/Ctrl+K` binding even\n // when an editor pane has focus.\n event.preventDefault();\n event.stopPropagation();\n\n setVisiblePlugin(DOC_EXPLORER_PLUGIN);\n // The panel (and its search input) mounts after this state update\n // commits, which isn't guaranteed to land within a single animation\n // frame, so poll across a few frames rather than assuming one is enough.\n focusSearchInputWhenMounted(10);\n }\n\n window.addEventListener('keydown', handleKeyDown, true);\n return () => {\n window.removeEventListener('keydown', handleKeyDown, true);\n };\n }, [setVisiblePlugin]);\n\n return children as ReactElement;\n};\n\nconst useDocExplorerStore = createBoundedUseStore(docExplorerStore);\n\nexport const useDocExplorer = () =>\n useDocExplorerStore(state => state.explorerNavStack);\n\n/**\n * Actions are functions used to update values in your store. They are static and never change.\n * @see https://tkdodo.eu/blog/working-with-zustand#separate-actions-from-state\n */\nexport const useDocExplorerActions = () =>\n useDocExplorerStore(state => state.actions);\n"],"mappings":";;;;;;;;;AAgCA,IAAagB,sBAAsC;CACjDC,OAAO;CACPC,MAAM,SAASC,OAAO;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sB;AAAC;AARf,SAAAF,MAAAvE,OAAA;CAAA,OACCA,MAAKI;AAAiB;AAMhB,SAAAqE,OAAAzE,OAAA;CAAA,OACNA,MAAKK;AAAQ"}
1
+ {"version":3,"file":"context.js","names":["isEnumType","isInputObjectType","isInterfaceType","isNamedType","isObjectType","isScalarType","isUnionType","useEffect","useGraphiQL","useGraphiQLActions","pick","createBoundedUseStore","isMacOs","createStore","getSchemaReference","DocExplorer","DOC_EXPLORER_PLUGIN","title","icon","Icon","visiblePlugin","state","content","name","def","explorerNavStack","actions","push","item","pop","reset","resolveSchemaReferenceToNavItem","schemaReference","rebuildNavStackWithSchema","schema","INITIAL_NAV_STACK","docExplorerStore","set","curr","lastItem","at","length","slice","kind","typeInfo","ref","items","type","field","oldNavStack","newNavStack","lastEntity","newType","getType","getFields","args","some","a","focusSearchInputWhenMounted","container","Element","framesLeft","requestAnimationFrame","el","querySelector","click","DocExplorerStore","children","shortcutTarget","t0","$","_c","t1","Symbol","for","validationErrors","setVisiblePlugin","t2","t3","getState","t4","t5","t6","t7","target","current","document","documentElement","handleKeyDown","event","code","closest","preventDefault","stopPropagation","addEventListener","removeEventListener","useDocExplorerStore","useDocExplorer","_temp","useDocExplorerActions","_temp2","_jsx"],"sources":["../src/context.tsx"],"sourcesContent":["import type {\n GraphQLArgument,\n GraphQLField,\n GraphQLInputField,\n GraphQLNamedType,\n GraphQLSchema,\n} from 'graphql';\nimport {\n isEnumType,\n isInputObjectType,\n isInterfaceType,\n isNamedType,\n isObjectType,\n isScalarType,\n isUnionType,\n} from 'graphql';\nimport { FC, ReactElement, ReactNode, RefObject, useEffect } from 'react';\nimport {\n SchemaReference,\n useGraphiQL,\n useGraphiQLActions,\n pick,\n createBoundedUseStore,\n GraphiQLPlugin,\n DocsFilledIcon,\n DocsIcon,\n isMacOs,\n} from '@graphiql/react';\nimport { createStore } from 'zustand';\nimport { getSchemaReference } from './schema-reference';\nimport { DocExplorer } from './components';\n\nexport const DOC_EXPLORER_PLUGIN: GraphiQLPlugin = {\n title: 'Documentation Explorer',\n icon: function Icon() {\n const visiblePlugin = useGraphiQL(state => state.visiblePlugin);\n return visiblePlugin === DOC_EXPLORER_PLUGIN ? (\n <DocsFilledIcon />\n ) : (\n <DocsIcon />\n );\n },\n content: DocExplorer,\n};\n\nexport type DocExplorerFieldDef =\n | GraphQLField<unknown, unknown>\n | GraphQLInputField\n | GraphQLArgument;\n\nexport type DocExplorerNavStackItem = {\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 | DocExplorerFieldDef;\n};\n\n// There's always at least one item in the nav stack\nexport type DocExplorerNavStack = [\n DocExplorerNavStackItem,\n ...DocExplorerNavStackItem[],\n];\n\nexport type DocExplorerStoreType = {\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: DocExplorerNavStack;\n actions: {\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: DocExplorerNavStackItem): 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 resolveSchemaReferenceToNavItem(\n schemaReference: SchemaReference | null,\n ): void;\n /**\n * Replace the nav stack with an updated version using the new schema.\n */\n rebuildNavStackWithSchema(schema: GraphQLSchema): void;\n };\n};\n\nconst INITIAL_NAV_STACK: DocExplorerNavStack = [{ name: 'Root' }];\n\nexport const docExplorerStore = createStore<DocExplorerStoreType>(set => ({\n explorerNavStack: INITIAL_NAV_STACK,\n actions: {\n push(item) {\n set(state => {\n const curr = state.explorerNavStack;\n const lastItem = curr.at(-1)!;\n const explorerNavStack: DocExplorerNavStack =\n // Avoid pushing duplicate items\n lastItem.def === item.def ? curr : [...curr, item];\n\n return { explorerNavStack };\n });\n },\n pop() {\n set(state => {\n const curr = state.explorerNavStack;\n\n const explorerNavStack =\n curr.length > 1 ? (curr.slice(0, -1) as DocExplorerNavStack) : curr;\n\n return { explorerNavStack };\n });\n },\n reset() {\n set(state => {\n const curr = state.explorerNavStack;\n const explorerNavStack = curr.length === 1 ? curr : INITIAL_NAV_STACK;\n return { explorerNavStack };\n });\n },\n resolveSchemaReferenceToNavItem(schemaReference) {\n if (!schemaReference) {\n return;\n }\n const { kind, typeInfo } = schemaReference;\n const ref = getSchemaReference(kind, typeInfo);\n if (!ref) {\n return;\n }\n\n // Replace the current path with the path to the referenced item,\n // rather than appending to it; repeatedly clicking the same reference\n // must not grow the stack.\n const items: DocExplorerNavStackItem[] = [];\n switch (ref.kind) {\n case 'Type': {\n items.push({\n name: ref.type.name,\n def: ref.type,\n });\n break;\n }\n case 'Field': {\n // Show a field type on stack\n if (ref.type) {\n items.push({\n name: ref.type.name,\n def: ref.type,\n });\n }\n items.push({\n name: ref.field.name,\n def: ref.field,\n });\n break;\n }\n case 'Argument': {\n if (ref.field) {\n items.push({\n name: ref.field.name,\n def: ref.field,\n });\n }\n break;\n }\n case 'EnumValue': {\n if (ref.type) {\n items.push({\n name: ref.type.name,\n def: ref.type,\n });\n }\n break;\n }\n }\n if (items.length > 0) {\n set({ explorerNavStack: [INITIAL_NAV_STACK[0], ...items] });\n }\n },\n rebuildNavStackWithSchema(schema: GraphQLSchema) {\n set(state => {\n const oldNavStack = state.explorerNavStack;\n if (oldNavStack.length === 1) {\n return state;\n }\n // Spread is needed\n const newNavStack: DocExplorerNavStack = [...INITIAL_NAV_STACK];\n let lastEntity:\n | GraphQLNamedType\n | GraphQLField<unknown, unknown>\n | null = null;\n for (const item of oldNavStack) {\n if (item === INITIAL_NAV_STACK[0]) {\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 { explorerNavStack: newNavStack };\n });\n },\n },\n}));\n\n// The doc-explorer panel (and its search input) mounts asynchronously after\n// `setVisiblePlugin` commits, which isn't guaranteed to land within a single\n// animation frame, so poll across a few frames rather than assuming one is\n// enough.\nfunction focusSearchInputWhenMounted(container: Element, framesLeft: number) {\n if (framesLeft <= 0) {\n return;\n }\n requestAnimationFrame(() => {\n const el = container.querySelector<HTMLDivElement>(\n '.graphiql-doc-explorer-search-row-input',\n );\n if (el) {\n el.click();\n } else {\n focusSearchInputWhenMounted(container, framesLeft - 1);\n }\n });\n}\n\nexport const DocExplorerStore: FC<{\n children: ReactNode;\n /** The container in which Cmd/Ctrl+K opens documentation search. */\n shortcutTarget?: RefObject<HTMLElement | null>;\n}> = ({ children, shortcutTarget }) => {\n const { schema, validationErrors, schemaReference } = useGraphiQL(\n pick('schema', 'validationErrors', 'schemaReference'),\n );\n const { setVisiblePlugin } = useGraphiQLActions();\n\n useEffect(() => {\n const { resolveSchemaReferenceToNavItem } =\n docExplorerStore.getState().actions;\n resolveSchemaReferenceToNavItem(schemaReference);\n }, [schemaReference]);\n\n useEffect(() => {\n const { reset, rebuildNavStackWithSchema } =\n docExplorerStore.getState().actions;\n\n // Whenever the schema changes, we must revalidate/replace the nav stack.\n if (schema == null || validationErrors.length > 0) {\n reset();\n } else {\n rebuildNavStackWithSchema(schema);\n }\n }, [schema, validationErrors]);\n\n useEffect(() => {\n const target = shortcutTarget?.current ?? document.documentElement;\n function handleKeyDown(event: KeyboardEvent) {\n const shouldOpenSearch =\n event[isMacOs ? 'metaKey' : 'ctrlKey'] &&\n // Using `event.code` because `event.key` will trigger different character\n // in English `˚` and in French `È`\n event.code === 'KeyK';\n if (!shouldOpenSearch) {\n return;\n }\n const container =\n event.target instanceof Element\n ? event.target.closest('.graphiql-container')\n : null;\n if (\n !container ||\n (shortcutTarget && container !== shortcutTarget.current)\n ) {\n return;\n }\n // Take priority over monaco-editor's built-in `Cmd/Ctrl+K` binding even\n // when an editor pane has focus.\n event.preventDefault();\n event.stopPropagation();\n\n setVisiblePlugin(DOC_EXPLORER_PLUGIN);\n // The panel (and its search input) mounts after this state update\n // commits, which isn't guaranteed to land within a single animation\n // frame, so poll across a few frames rather than assuming one is enough.\n focusSearchInputWhenMounted(container, 10);\n }\n\n target.addEventListener('keydown', handleKeyDown, true);\n return () => {\n target.removeEventListener('keydown', handleKeyDown, true);\n };\n }, [setVisiblePlugin, shortcutTarget]);\n\n return children as ReactElement;\n};\n\nconst useDocExplorerStore = createBoundedUseStore(docExplorerStore);\n\nexport const useDocExplorer = () =>\n useDocExplorerStore(state => state.explorerNavStack);\n\n/**\n * Actions are functions used to update values in your store. They are static and never change.\n * @see https://tkdodo.eu/blog/working-with-zustand#separate-actions-from-state\n */\nexport const useDocExplorerActions = () =>\n useDocExplorerStore(state => state.actions);\n"],"mappings":";;;;;;;;;AAgCA,IAAagB,sBA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AAE,EAAA,MAAAY;EAAAZ,EAAA,MAAAa;CAAA,OAAA;EAAAD,KAAAZ,EAAA;EAAAa,KAAAb,EAAA;CAAA;CArCrC/D,UAAU2E,IAqCPC,EAAkC;CAAC,OAE/BhB;AAAwB;AAGjC,IAAM6B,sBAAsBrF,sBAAsByB,gBAAgB;AAElE,IAAa6D,uBAAiB;CAAA,OAC5BD,oBAAoBE,KAA+B;AAAC;;;;;AAMtD,IAAaC,8BAAwB;CAAA,OACnCH,oBAAoBI,MAAsB;AAAC;AARf,SAAAF,MAAA7E,OAAA;CAAA,OACCA,MAAKI;AAAiB;AAMhB,SAAA2E,OAAA/E,OAAA;CAAA,OACNA,MAAKK;AAAQ"}
package/dist/style.css CHANGED
@@ -2,7 +2,7 @@
2
2
  color: oklch(var(--accent-green));
3
3
  }
4
4
  .graphiql-doc-explorer-breadcrumb {
5
- padding: var(--px-6) var(--px-16) 0;
5
+ padding: var(--px-6) var(--graphiql-doc-explorer-item-inset, var(--px-16)) 0;
6
6
  font-family: var(--font-family-mono);
7
7
  flex-wrap: wrap;
8
8
  align-items: center;
@@ -91,7 +91,8 @@ a.graphiql-doc-explorer-type-name[data-type-kind="input"] {
91
91
  .graphiql-doc-explorer-arguments-list-header {
92
92
  align-items: center;
93
93
  gap: var(--px-6);
94
- padding: var(--px-6) var(--px-16) var(--px-4);
94
+ padding: var(--px-6) var(--graphiql-doc-explorer-item-inset, var(--px-16))
95
+ var(--px-4);
95
96
  cursor: pointer;
96
97
  color: oklch(var(--fg-subtle));
97
98
  text-transform: uppercase;
@@ -132,7 +133,9 @@ a.graphiql-doc-explorer-type-name[data-type-kind="input"] {
132
133
 
133
134
  .graphiql-doc-explorer-argument {
134
135
  gap: var(--px-4);
135
- padding: 5px var(--px-16) 5px var(--px-24);
136
+ padding-block: 5px;
137
+ padding-inline: calc(var(--graphiql-doc-explorer-item-inset, var(--px-16)) + var(--px-8))
138
+ var(--graphiql-doc-explorer-item-inset, var(--px-16));
136
139
  flex-direction: column;
137
140
  display: flex;
138
141
  }
@@ -173,7 +176,7 @@ a.graphiql-doc-explorer-type-name[data-type-kind="input"] {
173
176
  }
174
177
 
175
178
  .graphiql-doc-explorer-arguments-list-show-deprecated {
176
- margin: var(--px-8) var(--px-16);
179
+ margin: var(--px-8) var(--graphiql-doc-explorer-item-inset, var(--px-16));
177
180
  }
178
181
 
179
182
  .graphiql-doc-explorer-directives-list {
@@ -183,7 +186,8 @@ a.graphiql-doc-explorer-type-name[data-type-kind="input"] {
183
186
  }
184
187
 
185
188
  .graphiql-doc-explorer-directives-list-header {
186
- padding: var(--px-6) var(--px-16) var(--px-4);
189
+ padding: var(--px-6) var(--graphiql-doc-explorer-item-inset, var(--px-16))
190
+ var(--px-4);
187
191
  color: oklch(var(--fg-subtle));
188
192
  text-transform: uppercase;
189
193
  letter-spacing: .08em;
@@ -202,7 +206,9 @@ a.graphiql-doc-explorer-type-name[data-type-kind="input"] {
202
206
  }
203
207
 
204
208
  .graphiql-doc-explorer-directive-row {
205
- padding: 5px var(--px-16) 5px var(--px-24);
209
+ padding-block: 5px;
210
+ padding-inline: calc(var(--graphiql-doc-explorer-item-inset, var(--px-16)) + var(--px-8))
211
+ var(--graphiql-doc-explorer-item-inset, var(--px-16));
206
212
  font-family: var(--font-family-mono);
207
213
  font-size: 12px;
208
214
  }
@@ -261,7 +267,8 @@ a.graphiql-doc-explorer-type-name[data-type-kind="input"] {
261
267
  .graphiql-doc-explorer-fields-list-header {
262
268
  align-items: center;
263
269
  gap: var(--px-6);
264
- padding: var(--px-6) var(--px-16) var(--px-4);
270
+ padding: var(--px-6) var(--graphiql-doc-explorer-item-inset, var(--px-16))
271
+ var(--px-4);
265
272
  cursor: pointer;
266
273
  color: oklch(var(--fg-subtle));
267
274
  font-size: var(--font-size-eyebrow);
@@ -302,7 +309,9 @@ a.graphiql-doc-explorer-type-name[data-type-kind="input"] {
302
309
 
303
310
  .graphiql-doc-explorer-field-row {
304
311
  gap: var(--px-4);
305
- padding: 5px var(--px-12) 5px var(--px-24);
312
+ padding-block: 5px;
313
+ padding-inline: calc(var(--graphiql-doc-explorer-item-inset, var(--px-16)) + var(--px-8))
314
+ var(--graphiql-doc-explorer-item-inset, var(--px-12));
306
315
  cursor: pointer;
307
316
  text-align: left;
308
317
  width: 100%;
@@ -364,7 +373,7 @@ a.graphiql-doc-explorer-type-name[data-type-kind="input"] {
364
373
  }
365
374
 
366
375
  .graphiql-doc-explorer-fields-list-show-deprecated {
367
- margin: var(--px-8) var(--px-16);
376
+ margin: var(--px-8) var(--graphiql-doc-explorer-item-inset, var(--px-16));
368
377
  }
369
378
  .graphiql-doc-explorer-schema-overview {
370
379
  padding: var(--px-8) 0;
@@ -373,7 +382,8 @@ a.graphiql-doc-explorer-type-name[data-type-kind="input"] {
373
382
  }
374
383
 
375
384
  .graphiql-doc-explorer-schema-section-header {
376
- padding: var(--px-6) var(--px-16) var(--px-4);
385
+ padding: var(--px-6) var(--graphiql-doc-explorer-item-inset, var(--px-16))
386
+ var(--px-4);
377
387
  text-transform: uppercase;
378
388
  letter-spacing: .08em;
379
389
  color: oklch(var(--fg-subtle));
@@ -393,7 +403,7 @@ a.graphiql-doc-explorer-type-name[data-type-kind="input"] {
393
403
  .graphiql-doc-explorer-schema-root-row {
394
404
  align-items: center;
395
405
  gap: var(--px-6);
396
- padding: 5px var(--px-16);
406
+ padding: 5px var(--graphiql-doc-explorer-item-inset, var(--px-16));
397
407
  cursor: pointer;
398
408
  text-align: left;
399
409
  width: 100%;
@@ -429,7 +439,7 @@ a.graphiql-doc-explorer-type-name[data-type-kind="input"] {
429
439
  .graphiql-doc-explorer-schema-type-row {
430
440
  align-items: center;
431
441
  gap: var(--px-8);
432
- padding: 4px var(--px-16);
442
+ padding: 4px var(--graphiql-doc-explorer-item-inset, var(--px-16));
433
443
  cursor: pointer;
434
444
  text-align: left;
435
445
  width: 100%;
@@ -453,53 +463,6 @@ a.graphiql-doc-explorer-type-name[data-type-kind="input"] {
453
463
  color: oklch(var(--fg-default));
454
464
  font-size: 12px;
455
465
  }
456
- .graphiql-doc-explorer-search {
457
- color: oklch(var(--fg-muted));
458
- }
459
-
460
- .graphiql-doc-explorer-search:not([data-state="idle"]) {
461
- color: oklch(var(--fg-default));
462
- }
463
-
464
- .graphiql-doc-explorer-search:not([data-state="idle"]) .graphiql-doc-explorer-search-input {
465
- background: oklch(var(--bg-canvas));
466
- border: 1px solid oklch(var(--border-default));
467
- box-shadow: var(--shadow-popover);
468
- }
469
-
470
- .graphiql-doc-explorer-search-input {
471
- background-color: oklch(var(--fg-default) / .08);
472
- border-radius: var(--border-radius-4);
473
- flex: 1;
474
- align-items: center;
475
- display: flex;
476
- }
477
-
478
- .graphiql-doc-explorer-search-input:focus-within {
479
- outline: 2px solid oklch(var(--accent-blue));
480
- outline-offset: 2px;
481
- }
482
-
483
- .graphiql-doc-explorer-search-input {
484
- gap: var(--px-8);
485
- padding: var(--px-4) var(--px-8);
486
- }
487
-
488
- .graphiql-doc-explorer-search [role="combobox"] {
489
- background-color: #0000;
490
- border: none;
491
- flex: 1;
492
- min-width: 0;
493
- }
494
-
495
- .graphiql-doc-explorer-search [role="combobox"]:focus {
496
- outline: none;
497
- }
498
-
499
- .graphiql-doc-explorer-search:focus-within .graphiql-keycap-hint {
500
- display: none;
501
- }
502
-
503
466
  .graphiql-doc-explorer-search [role="listbox"] {
504
467
  background-color: oklch(var(--bg-canvas));
505
468
  border: 1px solid oklch(var(--border-default));
@@ -573,7 +536,7 @@ a.graphiql-doc-explorer-type-name[data-type-kind="input"] {
573
536
  padding: var(--px-8) var(--px-12);
574
537
  }
575
538
  .graphiql-doc-explorer-search-row-wrapper {
576
- padding: var(--px-8) var(--px-16);
539
+ padding: var(--px-8) var(--graphiql-doc-explorer-item-inset, var(--px-16));
577
540
  position: relative;
578
541
  }
579
542
 
@@ -581,42 +544,6 @@ a.graphiql-doc-explorer-type-name[data-type-kind="input"] {
581
544
  position: relative;
582
545
  }
583
546
 
584
- .graphiql-doc-explorer-search-row-input {
585
- align-items: center;
586
- gap: var(--px-6);
587
- background: oklch(var(--bg-subtle));
588
- border: 1px solid oklch(var(--border-muted));
589
- border-radius: var(--radius-sm);
590
- padding: var(--px-4) var(--px-8);
591
- cursor: text;
592
- display: flex;
593
- }
594
-
595
- .graphiql-doc-explorer-search-row-input svg {
596
- width: 11px;
597
- height: 11px;
598
- color: oklch(var(--fg-disabled));
599
- flex-shrink: 0;
600
- }
601
-
602
- .graphiql-doc-explorer-search-row-input [role="combobox"] {
603
- min-width: 0;
604
- font-family: var(--font-family-mono);
605
- color: oklch(var(--fg-default));
606
- background: none;
607
- border: none;
608
- flex: 1;
609
- font-size: 11.5px;
610
- }
611
-
612
- .graphiql-doc-explorer-search-row-input [role="combobox"]::placeholder {
613
- color: oklch(var(--fg-disabled));
614
- }
615
-
616
- .graphiql-doc-explorer-search-row-input [role="combobox"]:focus {
617
- outline: none;
618
- }
619
-
620
547
  .graphiql-doc-explorer-search-row-listbox {
621
548
  top: calc(100% + var(--px-4));
622
549
  z-index: 5;
@@ -791,6 +718,10 @@ a.graphiql-doc-explorer-field-name:focus {
791
718
  .graphiql-doc-explorer-enum-value {
792
719
  color: oklch(var(--accent-green-light));
793
720
  }
721
+ .graphiql-doc-explorer {
722
+ --graphiql-doc-explorer-item-inset: 0px;
723
+ }
724
+
794
725
  .graphiql-panel-header-title {
795
726
  text-transform: uppercase;
796
727
  letter-spacing: .08em;
@@ -804,26 +735,18 @@ a.graphiql-doc-explorer-field-name:focus {
804
735
 
805
736
  .graphiql-doc-explorer-content > * {
806
737
  color: oklch(var(--fg-muted));
807
- padding: 0 var(--px-16) var(--px-16);
738
+ padding-block: 0 var(--px-16);
808
739
  margin-top: var(--px-16);
809
740
  }
810
741
 
811
742
  .graphiql-doc-explorer-content .graphiql-doc-explorer-type-card, .graphiql-doc-explorer-content .graphiql-doc-explorer-field-card {
812
- padding: var(--px-10) var(--px-16);
743
+ padding-block: var(--px-10);
813
744
  margin-top: 0;
814
745
  }
815
746
 
816
747
  .graphiql-doc-explorer-content .graphiql-doc-explorer-fields-list, .graphiql-doc-explorer-content .graphiql-doc-explorer-arguments-list {
817
748
  margin-top: 0;
818
749
  padding-top: 0;
819
- padding-left: 0;
820
- padding-right: 0;
821
- }
822
-
823
- .graphiql-doc-explorer-type-extra {
824
- padding: 0 var(--px-16) var(--px-16);
825
- margin-top: var(--px-16);
826
- color: oklch(var(--fg-muted));
827
750
  }
828
751
 
829
752
  .graphiql-doc-explorer-error {
@@ -832,7 +755,7 @@ a.graphiql-doc-explorer-field-name:focus {
832
755
  border-radius: var(--radius-sm);
833
756
  color: oklch(var(--accent-red));
834
757
  padding: var(--px-8) var(--px-12);
835
- margin: var(--px-16);
758
+ margin-block: var(--px-16);
836
759
  }
837
760
 
838
761
  a.graphiql-doc-explorer-back, .graphiql-doc-explorer-title {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphiql/plugin-doc-explorer",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "sideEffects": [
5
5
  "*.css"
6
6
  ],
@@ -32,7 +32,7 @@
32
32
  "dist"
33
33
  ],
34
34
  "peerDependencies": {
35
- "@graphiql/react": "^1.0.0",
35
+ "@graphiql/react": "^1.1.0",
36
36
  "graphql": "^16.11.0 || ^17.0.0",
37
37
  "react": "^18 || ^19",
38
38
  "react-dom": "^18 || ^19"
@@ -44,7 +44,7 @@
44
44
  },
45
45
  "devDependencies": {
46
46
  "@babel/core": "^7.29.6",
47
- "@graphiql/react": "^1.0.0",
47
+ "@graphiql/react": "^1.1.0",
48
48
  "@storybook/addon-a11y": "^10.6.9",
49
49
  "@storybook/addon-vitest": "^10.6.9",
50
50
  "@storybook/react-vite": "^10.6.9",