@graphiql/plugin-query-builder 1.0.0-beta.1 → 1.0.0-beta.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.
Files changed (53) hide show
  1. package/LICENSE +21 -0
  2. package/dist/components/arg-input/arg-input-by-type.js +441 -444
  3. package/dist/components/arg-input/arg-input-by-type.js.map +1 -1
  4. package/dist/components/arg-input/enum-arg-control.js +49 -52
  5. package/dist/components/arg-input/enum-arg-control.js.map +1 -1
  6. package/dist/components/arg-input/index.js +44 -36
  7. package/dist/components/arg-input/index.js.map +1 -1
  8. package/dist/components/arg-input/scalar-arg-control.js +58 -63
  9. package/dist/components/arg-input/scalar-arg-control.js.map +1 -1
  10. package/dist/components/field-row.js +212 -197
  11. package/dist/components/field-row.js.map +1 -1
  12. package/dist/components/field-tree-context.js +23 -27
  13. package/dist/components/field-tree-context.js.map +1 -1
  14. package/dist/components/field-tree-node.js +128 -105
  15. package/dist/components/field-tree-node.js.map +1 -1
  16. package/dist/components/field-tree.js +178 -199
  17. package/dist/components/field-tree.js.map +1 -1
  18. package/dist/components/fragment-editor.js +157 -151
  19. package/dist/components/fragment-editor.js.map +1 -1
  20. package/dist/components/fragment-section.js +215 -203
  21. package/dist/components/fragment-section.js.map +1 -1
  22. package/dist/components/query-builder.js +205 -181
  23. package/dist/components/query-builder.js.map +1 -1
  24. package/dist/components/type-condition-selector.js +417 -462
  25. package/dist/components/type-condition-selector.js.map +1 -1
  26. package/dist/components/use-cursor-path.js +69 -70
  27. package/dist/components/use-cursor-path.js.map +1 -1
  28. package/dist/components/use-cursor-reveal.js +83 -89
  29. package/dist/components/use-cursor-reveal.js.map +1 -1
  30. package/dist/components/use-working-document.js +432 -527
  31. package/dist/components/use-working-document.js.map +1 -1
  32. package/dist/index.js +11 -11
  33. package/dist/index.js.map +1 -1
  34. package/dist/lib/arg-value.js +132 -139
  35. package/dist/lib/arg-value.js.map +1 -1
  36. package/dist/lib/arguments.js +54 -55
  37. package/dist/lib/arguments.js.map +1 -1
  38. package/dist/lib/ast-path.js +266 -291
  39. package/dist/lib/ast-path.js.map +1 -1
  40. package/dist/lib/field-list-view.js +33 -43
  41. package/dist/lib/field-list-view.js.map +1 -1
  42. package/dist/lib/field-selection.js +63 -67
  43. package/dist/lib/field-selection.js.map +1 -1
  44. package/dist/lib/fragments.js +166 -152
  45. package/dist/lib/fragments.js.map +1 -1
  46. package/dist/lib/inline-fragments.js +64 -62
  47. package/dist/lib/inline-fragments.js.map +1 -1
  48. package/dist/lib/schema-walk.js +141 -158
  49. package/dist/lib/schema-walk.js.map +1 -1
  50. package/dist/lib/variables.js +96 -90
  51. package/dist/lib/variables.js.map +1 -1
  52. package/dist/style.css +4 -22
  53. package/package.json +21 -18
@@ -1,472 +1,427 @@
1
- import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
- import { c } from "react-compiler-runtime";
3
- import { ChevronDownIcon } from "@graphiql/react";
4
- import { isUnionType, isInterfaceType } from "graphql";
5
- import { useState, useEffect } from "react";
1
+ import { inlineFragmentSegment, segmentsEqual } from "../lib/ast-path.js";
2
+ import { isInlineFragmentPresent } from "../lib/inline-fragments.js";
6
3
  import { useFieldTreeContext } from "./field-tree-context.js";
7
- import { FieldTreeList } from "./field-tree.js";
8
4
  import { useCursorReveal } from "./use-cursor-reveal.js";
9
- import { segmentsEqual, inlineFragmentSegment } from "../lib/ast-path.js";
10
- import { isInlineFragmentPresent } from "../lib/inline-fragments.js";
5
+ import { FieldTreeList } from "./field-tree.js";
6
+ import { ChevronDownIcon } from "@graphiql/react";
7
+ import { c } from "react-compiler-runtime";
8
+ import { isInterfaceType, isUnionType } from "graphql";
9
+ import { useEffect, useState } from "react";
10
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
11
+ //#region src/components/type-condition-selector.tsx
12
+ /**
13
+ * The type conditions worth offering for an abstract field: every concrete
14
+ * object type, plus (for interface fields) the other interfaces that share an
15
+ * implementor, so you can narrow to a sibling/sub-interface (`... on Node`).
16
+ * The field's own interface and the interfaces it already implements are
17
+ * skipped, since those fields are selectable directly. A union contributes just
18
+ * its member object types.
19
+ */
11
20
  function applicableTypeConditions(abstractType, schema) {
12
- const objects = schema.getPossibleTypes(abstractType);
13
- if (!isInterfaceType(abstractType)) {
14
- return [...objects];
15
- }
16
- const skip = /* @__PURE__ */ new Set([abstractType.name, ...abstractType.getInterfaces().map((i) => i.name)]);
17
- const interfaces = /* @__PURE__ */ new Map();
18
- for (const object of objects) {
19
- for (const iface of object.getInterfaces()) {
20
- if (!skip.has(iface.name)) {
21
- interfaces.set(iface.name, iface);
22
- }
23
- }
24
- }
25
- return [...objects, ...interfaces.values()];
21
+ const objects = schema.getPossibleTypes(abstractType);
22
+ if (!isInterfaceType(abstractType)) return [...objects];
23
+ const skip = /* @__PURE__ */ new Set([abstractType.name, ...abstractType.getInterfaces().map((i) => i.name)]);
24
+ const interfaces = /* @__PURE__ */ new Map();
25
+ for (const object of objects) for (const iface of object.getInterfaces()) if (!skip.has(iface.name)) interfaces.set(iface.name, iface);
26
+ return [...objects, ...interfaces.values()];
26
27
  }
27
- const TypeConditionSelector = (t0) => {
28
- var _a;
29
- const $ = c(58);
30
- const {
31
- fieldPath,
32
- abstractType
33
- } = t0;
34
- const {
35
- doc,
36
- schema,
37
- target,
38
- cursorPath
39
- } = useFieldTreeContext();
40
- let t1;
41
- if ($[0] !== abstractType || $[1] !== doc || $[2] !== fieldPath || $[3] !== schema || $[4] !== target) {
42
- let t24;
43
- if ($[6] !== doc || $[7] !== fieldPath || $[8] !== target) {
44
- t24 = (t) => isInlineFragmentPresent(doc, fieldPath, t.name, target);
45
- $[6] = doc;
46
- $[7] = fieldPath;
47
- $[8] = target;
48
- $[9] = t24;
49
- } else {
50
- t24 = $[9];
51
- }
52
- t1 = (schema ? applicableTypeConditions(abstractType, schema) : []).some(t24);
53
- $[0] = abstractType;
54
- $[1] = doc;
55
- $[2] = fieldPath;
56
- $[3] = schema;
57
- $[4] = target;
58
- $[5] = t1;
59
- } else {
60
- t1 = $[5];
61
- }
62
- const hasSelectedCondition = t1;
63
- const [expanded, setExpanded] = useState(hasSelectedCondition);
64
- let t2;
65
- let t3;
66
- if ($[10] !== hasSelectedCondition) {
67
- t2 = () => {
68
- if (hasSelectedCondition) {
69
- setExpanded(true);
70
- }
71
- };
72
- t3 = [hasSelectedCondition];
73
- $[10] = hasSelectedCondition;
74
- $[11] = t2;
75
- $[12] = t3;
76
- } else {
77
- t2 = $[11];
78
- t3 = $[12];
79
- }
80
- useEffect(t2, t3);
81
- let t4;
82
- if ($[13] !== cursorPath || $[14] !== fieldPath) {
83
- t4 = cursorPath !== void 0 && cursorPath.length > fieldPath.length && fieldPath.every((seg, i) => segmentsEqual(cursorPath[i], seg)) && ((_a = cursorPath[fieldPath.length]) == null ? void 0 : _a.kind) === "inlineFragment";
84
- $[13] = cursorPath;
85
- $[14] = fieldPath;
86
- $[15] = t4;
87
- } else {
88
- t4 = $[15];
89
- }
90
- const cursorInCondition = t4;
91
- let t5;
92
- if ($[16] !== cursorInCondition) {
93
- t5 = () => {
94
- if (cursorInCondition) {
95
- setExpanded(true);
96
- }
97
- };
98
- $[16] = cursorInCondition;
99
- $[17] = t5;
100
- } else {
101
- t5 = $[17];
102
- }
103
- let t6;
104
- if ($[18] !== cursorInCondition || $[19] !== cursorPath) {
105
- t6 = [cursorPath, cursorInCondition];
106
- $[18] = cursorInCondition;
107
- $[19] = cursorPath;
108
- $[20] = t6;
109
- } else {
110
- t6 = $[20];
111
- }
112
- useEffect(t5, t6);
113
- if (!schema) {
114
- return null;
115
- }
116
- let t10;
117
- let t11;
118
- let t7;
119
- let t8;
120
- let t9;
121
- let typeConditions;
122
- if ($[21] !== abstractType || $[22] !== doc || $[23] !== fieldPath || $[24] !== schema || $[25] !== target) {
123
- t11 = Symbol.for("react.early_return_sentinel");
124
- bb0: {
125
- typeConditions = applicableTypeConditions(abstractType, schema);
126
- if (typeConditions.length === 0) {
127
- t11 = null;
128
- break bb0;
129
- }
130
- t7 = "graphiql-qb-type-condition";
131
- t8 = "group";
132
- t9 = `Possible types for ${abstractType.name}`;
133
- let t122;
134
- if ($[32] !== doc || $[33] !== fieldPath || $[34] !== target) {
135
- t122 = (conditionType) => {
136
- const isSelected = isInlineFragmentPresent(doc, fieldPath, conditionType.name, target);
137
- return /* @__PURE__ */ jsx(TypeConditionEntry, { fieldPath, typeName: conditionType.name, concreteType: conditionType, isInterface: isInterfaceType(conditionType), isSelected }, conditionType.name);
138
- };
139
- $[32] = doc;
140
- $[33] = fieldPath;
141
- $[34] = target;
142
- $[35] = t122;
143
- } else {
144
- t122 = $[35];
145
- }
146
- t10 = typeConditions.map(t122);
147
- }
148
- $[21] = abstractType;
149
- $[22] = doc;
150
- $[23] = fieldPath;
151
- $[24] = schema;
152
- $[25] = target;
153
- $[26] = t10;
154
- $[27] = t11;
155
- $[28] = t7;
156
- $[29] = t8;
157
- $[30] = t9;
158
- $[31] = typeConditions;
159
- } else {
160
- t10 = $[26];
161
- t11 = $[27];
162
- t7 = $[28];
163
- t8 = $[29];
164
- t9 = $[30];
165
- typeConditions = $[31];
166
- }
167
- if (t11 !== Symbol.for("react.early_return_sentinel")) {
168
- return t11;
169
- }
170
- let t12;
171
- if ($[36] !== t10 || $[37] !== t7 || $[38] !== t8 || $[39] !== t9) {
172
- t12 = /* @__PURE__ */ jsx("div", { className: t7, role: t8, "aria-label": t9, children: t10 });
173
- $[36] = t10;
174
- $[37] = t7;
175
- $[38] = t8;
176
- $[39] = t9;
177
- $[40] = t12;
178
- } else {
179
- t12 = $[40];
180
- }
181
- const entries = t12;
182
- if (isUnionType(abstractType)) {
183
- return entries;
184
- }
185
- const t13 = `calc(${fieldPath.length * 12}px + var(--px-8))`;
186
- let t14;
187
- if ($[41] !== t13) {
188
- t14 = {
189
- paddingLeft: t13
190
- };
191
- $[41] = t13;
192
- $[42] = t14;
193
- } else {
194
- t14 = $[42];
195
- }
196
- let t15;
197
- if ($[43] === Symbol.for("react.memo_cache_sentinel")) {
198
- t15 = () => setExpanded(_temp);
199
- $[43] = t15;
200
- } else {
201
- t15 = $[43];
202
- }
203
- const t16 = expanded ? "graphiql-qb-chevron-expanded" : "graphiql-qb-chevron-collapsed";
204
- let t17;
205
- if ($[44] === Symbol.for("react.memo_cache_sentinel")) {
206
- t17 = /* @__PURE__ */ jsx(ChevronDownIcon, {});
207
- $[44] = t17;
208
- } else {
209
- t17 = $[44];
210
- }
211
- let t18;
212
- if ($[45] !== t16) {
213
- t18 = /* @__PURE__ */ jsx("span", { className: t16, children: t17 });
214
- $[45] = t16;
215
- $[46] = t18;
216
- } else {
217
- t18 = $[46];
218
- }
219
- let t19;
220
- if ($[47] === Symbol.for("react.memo_cache_sentinel")) {
221
- t19 = /* @__PURE__ */ jsx("span", { className: "graphiql-qb-possible-types-label", children: "Possible types" });
222
- $[47] = t19;
223
- } else {
224
- t19 = $[47];
225
- }
226
- let t20;
227
- if ($[48] !== typeConditions.length) {
228
- t20 = /* @__PURE__ */ jsx("span", { className: "graphiql-qb-possible-types-count", children: typeConditions.length });
229
- $[48] = typeConditions.length;
230
- $[49] = t20;
231
- } else {
232
- t20 = $[49];
233
- }
234
- let t21;
235
- if ($[50] !== expanded || $[51] !== t14 || $[52] !== t18 || $[53] !== t20) {
236
- t21 = /* @__PURE__ */ jsxs("button", { type: "button", className: "graphiql-qb-field-toggle graphiql-qb-possible-types-header", style: t14, onClick: t15, "aria-expanded": expanded, children: [
237
- t18,
238
- t19,
239
- t20
240
- ] });
241
- $[50] = expanded;
242
- $[51] = t14;
243
- $[52] = t18;
244
- $[53] = t20;
245
- $[54] = t21;
246
- } else {
247
- t21 = $[54];
248
- }
249
- const t22 = expanded && entries;
250
- let t23;
251
- if ($[55] !== t21 || $[56] !== t22) {
252
- t23 = /* @__PURE__ */ jsxs("div", { className: "graphiql-qb-possible-types", children: [
253
- t21,
254
- t22
255
- ] });
256
- $[55] = t21;
257
- $[56] = t22;
258
- $[57] = t23;
259
- } else {
260
- t23 = $[57];
261
- }
262
- return t23;
28
+ var TypeConditionSelector = (t0) => {
29
+ const $ = c(58);
30
+ const { fieldPath, abstractType } = t0;
31
+ const { doc, schema, target, cursorPath } = useFieldTreeContext();
32
+ let t1;
33
+ if ($[0] !== abstractType || $[1] !== doc || $[2] !== fieldPath || $[3] !== schema || $[4] !== target) {
34
+ let t2;
35
+ if ($[6] !== doc || $[7] !== fieldPath || $[8] !== target) {
36
+ t2 = (t) => isInlineFragmentPresent(doc, fieldPath, t.name, target);
37
+ $[6] = doc;
38
+ $[7] = fieldPath;
39
+ $[8] = target;
40
+ $[9] = t2;
41
+ } else t2 = $[9];
42
+ t1 = (schema ? applicableTypeConditions(abstractType, schema) : []).some(t2);
43
+ $[0] = abstractType;
44
+ $[1] = doc;
45
+ $[2] = fieldPath;
46
+ $[3] = schema;
47
+ $[4] = target;
48
+ $[5] = t1;
49
+ } else t1 = $[5];
50
+ const hasSelectedCondition = t1;
51
+ const [expanded, setExpanded] = useState(hasSelectedCondition);
52
+ let t2;
53
+ let t3;
54
+ if ($[10] !== hasSelectedCondition) {
55
+ t2 = () => {
56
+ if (hasSelectedCondition) setExpanded(true);
57
+ };
58
+ t3 = [hasSelectedCondition];
59
+ $[10] = hasSelectedCondition;
60
+ $[11] = t2;
61
+ $[12] = t3;
62
+ } else {
63
+ t2 = $[11];
64
+ t3 = $[12];
65
+ }
66
+ useEffect(t2, t3);
67
+ let t4;
68
+ if ($[13] !== cursorPath || $[14] !== fieldPath) {
69
+ t4 = cursorPath !== void 0 && cursorPath.length > fieldPath.length && fieldPath.every((seg, i) => segmentsEqual(cursorPath[i], seg)) && cursorPath[fieldPath.length]?.kind === "inlineFragment";
70
+ $[13] = cursorPath;
71
+ $[14] = fieldPath;
72
+ $[15] = t4;
73
+ } else t4 = $[15];
74
+ const cursorInCondition = t4;
75
+ let t5;
76
+ if ($[16] !== cursorInCondition) {
77
+ t5 = () => {
78
+ if (cursorInCondition) setExpanded(true);
79
+ };
80
+ $[16] = cursorInCondition;
81
+ $[17] = t5;
82
+ } else t5 = $[17];
83
+ let t6;
84
+ if ($[18] !== cursorInCondition || $[19] !== cursorPath) {
85
+ t6 = [cursorPath, cursorInCondition];
86
+ $[18] = cursorInCondition;
87
+ $[19] = cursorPath;
88
+ $[20] = t6;
89
+ } else t6 = $[20];
90
+ useEffect(t5, t6);
91
+ if (!schema) return null;
92
+ let t10;
93
+ let t11;
94
+ let t7;
95
+ let t8;
96
+ let t9;
97
+ let typeConditions;
98
+ if ($[21] !== abstractType || $[22] !== doc || $[23] !== fieldPath || $[24] !== schema || $[25] !== target) {
99
+ t11 = Symbol.for("react.early_return_sentinel");
100
+ bb0: {
101
+ typeConditions = applicableTypeConditions(abstractType, schema);
102
+ if (typeConditions.length === 0) {
103
+ t11 = null;
104
+ break bb0;
105
+ }
106
+ t7 = "graphiql-qb-type-condition";
107
+ t8 = "group";
108
+ t9 = `Possible types for ${abstractType.name}`;
109
+ let t12;
110
+ if ($[32] !== doc || $[33] !== fieldPath || $[34] !== target) {
111
+ t12 = (conditionType) => {
112
+ const isSelected = isInlineFragmentPresent(doc, fieldPath, conditionType.name, target);
113
+ return /* @__PURE__ */ jsx(TypeConditionEntry, {
114
+ fieldPath,
115
+ typeName: conditionType.name,
116
+ concreteType: conditionType,
117
+ isInterface: isInterfaceType(conditionType),
118
+ isSelected
119
+ }, conditionType.name);
120
+ };
121
+ $[32] = doc;
122
+ $[33] = fieldPath;
123
+ $[34] = target;
124
+ $[35] = t12;
125
+ } else t12 = $[35];
126
+ t10 = typeConditions.map(t12);
127
+ }
128
+ $[21] = abstractType;
129
+ $[22] = doc;
130
+ $[23] = fieldPath;
131
+ $[24] = schema;
132
+ $[25] = target;
133
+ $[26] = t10;
134
+ $[27] = t11;
135
+ $[28] = t7;
136
+ $[29] = t8;
137
+ $[30] = t9;
138
+ $[31] = typeConditions;
139
+ } else {
140
+ t10 = $[26];
141
+ t11 = $[27];
142
+ t7 = $[28];
143
+ t8 = $[29];
144
+ t9 = $[30];
145
+ typeConditions = $[31];
146
+ }
147
+ if (t11 !== Symbol.for("react.early_return_sentinel")) return t11;
148
+ let t12;
149
+ if ($[36] !== t10 || $[37] !== t7 || $[38] !== t8 || $[39] !== t9) {
150
+ t12 = /* @__PURE__ */ jsx("div", {
151
+ className: t7,
152
+ role: t8,
153
+ "aria-label": t9,
154
+ children: t10
155
+ });
156
+ $[36] = t10;
157
+ $[37] = t7;
158
+ $[38] = t8;
159
+ $[39] = t9;
160
+ $[40] = t12;
161
+ } else t12 = $[40];
162
+ const entries = t12;
163
+ if (isUnionType(abstractType)) return entries;
164
+ const t13 = `calc(${fieldPath.length * 12}px + var(--px-8))`;
165
+ let t14;
166
+ if ($[41] !== t13) {
167
+ t14 = { paddingLeft: t13 };
168
+ $[41] = t13;
169
+ $[42] = t14;
170
+ } else t14 = $[42];
171
+ let t15;
172
+ if ($[43] === Symbol.for("react.memo_cache_sentinel")) {
173
+ t15 = () => setExpanded(_temp);
174
+ $[43] = t15;
175
+ } else t15 = $[43];
176
+ const t16 = expanded ? "graphiql-qb-chevron-expanded" : "graphiql-qb-chevron-collapsed";
177
+ let t17;
178
+ if ($[44] === Symbol.for("react.memo_cache_sentinel")) {
179
+ t17 = /* @__PURE__ */ jsx(ChevronDownIcon, {});
180
+ $[44] = t17;
181
+ } else t17 = $[44];
182
+ let t18;
183
+ if ($[45] !== t16) {
184
+ t18 = /* @__PURE__ */ jsx("span", {
185
+ className: t16,
186
+ children: t17
187
+ });
188
+ $[45] = t16;
189
+ $[46] = t18;
190
+ } else t18 = $[46];
191
+ let t19;
192
+ if ($[47] === Symbol.for("react.memo_cache_sentinel")) {
193
+ t19 = /* @__PURE__ */ jsx("span", {
194
+ className: "graphiql-qb-possible-types-label",
195
+ children: "Possible types"
196
+ });
197
+ $[47] = t19;
198
+ } else t19 = $[47];
199
+ let t20;
200
+ if ($[48] !== typeConditions.length) {
201
+ t20 = /* @__PURE__ */ jsx("span", {
202
+ className: "graphiql-qb-possible-types-count",
203
+ children: typeConditions.length
204
+ });
205
+ $[48] = typeConditions.length;
206
+ $[49] = t20;
207
+ } else t20 = $[49];
208
+ let t21;
209
+ if ($[50] !== expanded || $[51] !== t14 || $[52] !== t18 || $[53] !== t20) {
210
+ t21 = /* @__PURE__ */ jsxs("button", {
211
+ type: "button",
212
+ className: "graphiql-qb-field-toggle graphiql-qb-possible-types-header",
213
+ style: t14,
214
+ onClick: t15,
215
+ "aria-expanded": expanded,
216
+ children: [
217
+ t18,
218
+ t19,
219
+ t20
220
+ ]
221
+ });
222
+ $[50] = expanded;
223
+ $[51] = t14;
224
+ $[52] = t18;
225
+ $[53] = t20;
226
+ $[54] = t21;
227
+ } else t21 = $[54];
228
+ const t22 = expanded && entries;
229
+ let t23;
230
+ if ($[55] !== t21 || $[56] !== t22) {
231
+ t23 = /* @__PURE__ */ jsxs("div", {
232
+ className: "graphiql-qb-possible-types",
233
+ children: [t21, t22]
234
+ });
235
+ $[55] = t21;
236
+ $[56] = t22;
237
+ $[57] = t23;
238
+ } else t23 = $[57];
239
+ return t23;
263
240
  };
264
- const TypeConditionEntry = (t0) => {
265
- const $ = c(48);
266
- const {
267
- fieldPath,
268
- typeName,
269
- concreteType,
270
- isInterface,
271
- isSelected
272
- } = t0;
273
- const {
274
- cursorPath,
275
- onAddInlineFragment,
276
- onRemoveInlineFragment
277
- } = useFieldTreeContext();
278
- const [expanded, setExpanded] = useState(false);
279
- let t1;
280
- if ($[0] !== typeName) {
281
- t1 = inlineFragmentSegment(typeName);
282
- $[0] = typeName;
283
- $[1] = t1;
284
- } else {
285
- t1 = $[1];
286
- }
287
- let t2;
288
- if ($[2] !== fieldPath || $[3] !== t1) {
289
- t2 = [...fieldPath, t1];
290
- $[2] = fieldPath;
291
- $[3] = t1;
292
- $[4] = t2;
293
- } else {
294
- t2 = $[4];
295
- }
296
- const fragmentPath = t2;
297
- const {
298
- flash,
299
- current,
300
- nodeRef
301
- } = useCursorReveal(fragmentPath, cursorPath, setExpanded);
302
- let t3;
303
- if ($[5] !== fieldPath || $[6] !== isSelected || $[7] !== onAddInlineFragment || $[8] !== onRemoveInlineFragment || $[9] !== typeName) {
304
- t3 = function handleToggle2() {
305
- if (isSelected) {
306
- onRemoveInlineFragment == null ? void 0 : onRemoveInlineFragment(fieldPath, typeName);
307
- } else {
308
- onAddInlineFragment == null ? void 0 : onAddInlineFragment(fieldPath, typeName);
309
- }
310
- };
311
- $[5] = fieldPath;
312
- $[6] = isSelected;
313
- $[7] = onAddInlineFragment;
314
- $[8] = onRemoveInlineFragment;
315
- $[9] = typeName;
316
- $[10] = t3;
317
- } else {
318
- t3 = $[10];
319
- }
320
- const handleToggle = t3;
321
- const t4 = `graphiql-qb-inline-fragment${flash ? " graphiql-qb-flash" : ""}${current ? " graphiql-qb-current" : ""}`;
322
- const t5 = `calc(${fieldPath.length * 12}px + var(--px-8))`;
323
- let t6;
324
- if ($[11] !== t5) {
325
- t6 = {
326
- paddingLeft: t5
327
- };
328
- $[11] = t5;
329
- $[12] = t6;
330
- } else {
331
- t6 = $[12];
332
- }
333
- const t7 = `Toggle ... on ${typeName}`;
334
- let t8;
335
- if ($[13] !== handleToggle || $[14] !== isSelected || $[15] !== t7) {
336
- t8 = /* @__PURE__ */ jsx("input", { type: "checkbox", checked: isSelected, onChange: handleToggle, "aria-label": t7, className: "graphiql-qb-field-checkbox" });
337
- $[13] = handleToggle;
338
- $[14] = isSelected;
339
- $[15] = t7;
340
- $[16] = t8;
341
- } else {
342
- t8 = $[16];
343
- }
344
- let t9;
345
- if ($[17] === Symbol.for("react.memo_cache_sentinel")) {
346
- t9 = () => setExpanded(_temp2);
347
- $[17] = t9;
348
- } else {
349
- t9 = $[17];
350
- }
351
- const t10 = `${expanded ? "Collapse" : "Expand"} ... on ${typeName}`;
352
- const t11 = expanded ? "graphiql-qb-chevron-expanded" : "graphiql-qb-chevron-collapsed";
353
- let t12;
354
- if ($[18] === Symbol.for("react.memo_cache_sentinel")) {
355
- t12 = /* @__PURE__ */ jsx(ChevronDownIcon, {});
356
- $[18] = t12;
357
- } else {
358
- t12 = $[18];
359
- }
360
- let t13;
361
- if ($[19] !== t11) {
362
- t13 = /* @__PURE__ */ jsx("span", { className: t11, children: t12 });
363
- $[19] = t11;
364
- $[20] = t13;
365
- } else {
366
- t13 = $[20];
367
- }
368
- let t14;
369
- if ($[21] === Symbol.for("react.memo_cache_sentinel")) {
370
- t14 = /* @__PURE__ */ jsx("span", { className: "graphiql-qb-spread", children: "..." });
371
- $[21] = t14;
372
- } else {
373
- t14 = $[21];
374
- }
375
- let t15;
376
- if ($[22] !== typeName) {
377
- t15 = /* @__PURE__ */ jsx("span", { className: "graphiql-qb-type-name", children: typeName });
378
- $[22] = typeName;
379
- $[23] = t15;
380
- } else {
381
- t15 = $[23];
382
- }
383
- let t16;
384
- if ($[24] !== isInterface) {
385
- t16 = isInterface && /* @__PURE__ */ jsx("span", { className: "graphiql-qb-type-kind-tag", children: "interface" });
386
- $[24] = isInterface;
387
- $[25] = t16;
388
- } else {
389
- t16 = $[25];
390
- }
391
- let t17;
392
- if ($[26] !== t15 || $[27] !== t16) {
393
- t17 = /* @__PURE__ */ jsxs("span", { className: "graphiql-qb-inline-fragment-label", children: [
394
- t14,
395
- " on ",
396
- t15,
397
- t16
398
- ] });
399
- $[26] = t15;
400
- $[27] = t16;
401
- $[28] = t17;
402
- } else {
403
- t17 = $[28];
404
- }
405
- let t18;
406
- if ($[29] !== expanded || $[30] !== t10 || $[31] !== t13 || $[32] !== t17) {
407
- t18 = /* @__PURE__ */ jsxs("button", { type: "button", className: "graphiql-qb-field-toggle", onClick: t9, "aria-expanded": expanded, "aria-label": t10, children: [
408
- t13,
409
- t17
410
- ] });
411
- $[29] = expanded;
412
- $[30] = t10;
413
- $[31] = t13;
414
- $[32] = t17;
415
- $[33] = t18;
416
- } else {
417
- t18 = $[33];
418
- }
419
- let t19;
420
- if ($[34] !== t18 || $[35] !== t6 || $[36] !== t8) {
421
- t19 = /* @__PURE__ */ jsxs("div", { className: "graphiql-qb-inline-fragment-header", style: t6, children: [
422
- t8,
423
- t18
424
- ] });
425
- $[34] = t18;
426
- $[35] = t6;
427
- $[36] = t8;
428
- $[37] = t19;
429
- } else {
430
- t19 = $[37];
431
- }
432
- let t20;
433
- if ($[38] !== concreteType || $[39] !== expanded || $[40] !== fragmentPath || $[41] !== isInterface) {
434
- t20 = expanded && /* @__PURE__ */ jsxs(Fragment, { children: [
435
- /* @__PURE__ */ jsx(FieldTreeList, { type: concreteType, path: fragmentPath }),
436
- isInterface && /* @__PURE__ */ jsx(TypeConditionSelector, { fieldPath: fragmentPath, abstractType: concreteType })
437
- ] });
438
- $[38] = concreteType;
439
- $[39] = expanded;
440
- $[40] = fragmentPath;
441
- $[41] = isInterface;
442
- $[42] = t20;
443
- } else {
444
- t20 = $[42];
445
- }
446
- let t21;
447
- if ($[43] !== nodeRef || $[44] !== t19 || $[45] !== t20 || $[46] !== t4) {
448
- t21 = /* @__PURE__ */ jsxs("div", { className: t4, ref: nodeRef, children: [
449
- t19,
450
- t20
451
- ] });
452
- $[43] = nodeRef;
453
- $[44] = t19;
454
- $[45] = t20;
455
- $[46] = t4;
456
- $[47] = t21;
457
- } else {
458
- t21 = $[47];
459
- }
460
- return t21;
241
+ var TypeConditionEntry = (t0) => {
242
+ const $ = c(48);
243
+ const { fieldPath, typeName, concreteType, isInterface, isSelected } = t0;
244
+ const { cursorPath, onAddInlineFragment, onRemoveInlineFragment } = useFieldTreeContext();
245
+ const [expanded, setExpanded] = useState(false);
246
+ let t1;
247
+ if ($[0] !== typeName) {
248
+ t1 = inlineFragmentSegment(typeName);
249
+ $[0] = typeName;
250
+ $[1] = t1;
251
+ } else t1 = $[1];
252
+ let t2;
253
+ if ($[2] !== fieldPath || $[3] !== t1) {
254
+ t2 = [...fieldPath, t1];
255
+ $[2] = fieldPath;
256
+ $[3] = t1;
257
+ $[4] = t2;
258
+ } else t2 = $[4];
259
+ const fragmentPath = t2;
260
+ const { flash, current, nodeRef } = useCursorReveal(fragmentPath, cursorPath, setExpanded);
261
+ let t3;
262
+ if ($[5] !== fieldPath || $[6] !== isSelected || $[7] !== onAddInlineFragment || $[8] !== onRemoveInlineFragment || $[9] !== typeName) {
263
+ t3 = function handleToggle() {
264
+ if (isSelected) onRemoveInlineFragment?.(fieldPath, typeName);
265
+ else onAddInlineFragment?.(fieldPath, typeName);
266
+ };
267
+ $[5] = fieldPath;
268
+ $[6] = isSelected;
269
+ $[7] = onAddInlineFragment;
270
+ $[8] = onRemoveInlineFragment;
271
+ $[9] = typeName;
272
+ $[10] = t3;
273
+ } else t3 = $[10];
274
+ const handleToggle = t3;
275
+ const t4 = `graphiql-qb-inline-fragment${flash ? " graphiql-qb-flash" : ""}${current ? " graphiql-qb-current" : ""}`;
276
+ const t5 = `calc(${fieldPath.length * 12}px + var(--px-8))`;
277
+ let t6;
278
+ if ($[11] !== t5) {
279
+ t6 = { paddingLeft: t5 };
280
+ $[11] = t5;
281
+ $[12] = t6;
282
+ } else t6 = $[12];
283
+ const t7 = `Toggle ... on ${typeName}`;
284
+ let t8;
285
+ if ($[13] !== handleToggle || $[14] !== isSelected || $[15] !== t7) {
286
+ t8 = /* @__PURE__ */ jsx("input", {
287
+ type: "checkbox",
288
+ checked: isSelected,
289
+ onChange: handleToggle,
290
+ "aria-label": t7,
291
+ className: "graphiql-qb-field-checkbox"
292
+ });
293
+ $[13] = handleToggle;
294
+ $[14] = isSelected;
295
+ $[15] = t7;
296
+ $[16] = t8;
297
+ } else t8 = $[16];
298
+ let t9;
299
+ if ($[17] === Symbol.for("react.memo_cache_sentinel")) {
300
+ t9 = () => setExpanded(_temp2);
301
+ $[17] = t9;
302
+ } else t9 = $[17];
303
+ const t10 = `${expanded ? "Collapse" : "Expand"} ... on ${typeName}`;
304
+ const t11 = expanded ? "graphiql-qb-chevron-expanded" : "graphiql-qb-chevron-collapsed";
305
+ let t12;
306
+ if ($[18] === Symbol.for("react.memo_cache_sentinel")) {
307
+ t12 = /* @__PURE__ */ jsx(ChevronDownIcon, {});
308
+ $[18] = t12;
309
+ } else t12 = $[18];
310
+ let t13;
311
+ if ($[19] !== t11) {
312
+ t13 = /* @__PURE__ */ jsx("span", {
313
+ className: t11,
314
+ children: t12
315
+ });
316
+ $[19] = t11;
317
+ $[20] = t13;
318
+ } else t13 = $[20];
319
+ let t14;
320
+ if ($[21] === Symbol.for("react.memo_cache_sentinel")) {
321
+ t14 = /* @__PURE__ */ jsx("span", {
322
+ className: "graphiql-qb-spread",
323
+ children: "..."
324
+ });
325
+ $[21] = t14;
326
+ } else t14 = $[21];
327
+ let t15;
328
+ if ($[22] !== typeName) {
329
+ t15 = /* @__PURE__ */ jsx("span", {
330
+ className: "graphiql-qb-type-name",
331
+ children: typeName
332
+ });
333
+ $[22] = typeName;
334
+ $[23] = t15;
335
+ } else t15 = $[23];
336
+ let t16;
337
+ if ($[24] !== isInterface) {
338
+ t16 = isInterface && /* @__PURE__ */ jsx("span", {
339
+ className: "graphiql-qb-type-kind-tag",
340
+ children: "interface"
341
+ });
342
+ $[24] = isInterface;
343
+ $[25] = t16;
344
+ } else t16 = $[25];
345
+ let t17;
346
+ if ($[26] !== t15 || $[27] !== t16) {
347
+ t17 = /* @__PURE__ */ jsxs("span", {
348
+ className: "graphiql-qb-inline-fragment-label",
349
+ children: [
350
+ t14,
351
+ " on ",
352
+ t15,
353
+ t16
354
+ ]
355
+ });
356
+ $[26] = t15;
357
+ $[27] = t16;
358
+ $[28] = t17;
359
+ } else t17 = $[28];
360
+ let t18;
361
+ if ($[29] !== expanded || $[30] !== t10 || $[31] !== t13 || $[32] !== t17) {
362
+ t18 = /* @__PURE__ */ jsxs("button", {
363
+ type: "button",
364
+ className: "graphiql-qb-field-toggle",
365
+ onClick: t9,
366
+ "aria-expanded": expanded,
367
+ "aria-label": t10,
368
+ children: [t13, t17]
369
+ });
370
+ $[29] = expanded;
371
+ $[30] = t10;
372
+ $[31] = t13;
373
+ $[32] = t17;
374
+ $[33] = t18;
375
+ } else t18 = $[33];
376
+ let t19;
377
+ if ($[34] !== t18 || $[35] !== t6 || $[36] !== t8) {
378
+ t19 = /* @__PURE__ */ jsxs("div", {
379
+ className: "graphiql-qb-inline-fragment-header",
380
+ style: t6,
381
+ children: [t8, t18]
382
+ });
383
+ $[34] = t18;
384
+ $[35] = t6;
385
+ $[36] = t8;
386
+ $[37] = t19;
387
+ } else t19 = $[37];
388
+ let t20;
389
+ if ($[38] !== concreteType || $[39] !== expanded || $[40] !== fragmentPath || $[41] !== isInterface) {
390
+ t20 = expanded && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(FieldTreeList, {
391
+ type: concreteType,
392
+ path: fragmentPath
393
+ }), isInterface && /* @__PURE__ */ jsx(TypeConditionSelector, {
394
+ fieldPath: fragmentPath,
395
+ abstractType: concreteType
396
+ })] });
397
+ $[38] = concreteType;
398
+ $[39] = expanded;
399
+ $[40] = fragmentPath;
400
+ $[41] = isInterface;
401
+ $[42] = t20;
402
+ } else t20 = $[42];
403
+ let t21;
404
+ if ($[43] !== nodeRef || $[44] !== t19 || $[45] !== t20 || $[46] !== t4) {
405
+ t21 = /* @__PURE__ */ jsxs("div", {
406
+ className: t4,
407
+ ref: nodeRef,
408
+ children: [t19, t20]
409
+ });
410
+ $[43] = nodeRef;
411
+ $[44] = t19;
412
+ $[45] = t20;
413
+ $[46] = t4;
414
+ $[47] = t21;
415
+ } else t21 = $[47];
416
+ return t21;
461
417
  };
462
418
  function _temp(prev) {
463
- return !prev;
419
+ return !prev;
464
420
  }
465
421
  function _temp2(prev) {
466
- return !prev;
422
+ return !prev;
467
423
  }
468
- export {
469
- TypeConditionSelector,
470
- applicableTypeConditions
471
- };
472
- //# sourceMappingURL=type-condition-selector.js.map
424
+ //#endregion
425
+ export { TypeConditionSelector, applicableTypeConditions };
426
+
427
+ //# sourceMappingURL=type-condition-selector.js.map