@graphiql/plugin-doc-explorer 0.0.2 → 0.0.3-canary-5d447953.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/default-value.d.ts +2 -2
- package/dist/components/default-value.js.map +1 -1
- package/dist/components/doc-explorer.js +118 -138
- package/dist/components/doc-explorer.js.map +1 -1
- package/dist/components/field-documentation.d.ts +2 -2
- package/dist/components/field-documentation.js.map +1 -1
- package/dist/components/field-link.d.ts +2 -2
- package/dist/components/field-link.js +17 -26
- package/dist/components/field-link.js.map +1 -1
- package/dist/components/search.d.ts +1 -1
- package/dist/components/search.js +115 -152
- package/dist/components/search.js.map +1 -1
- package/dist/components/type-documentation.js +17 -26
- package/dist/components/type-documentation.js.map +1 -1
- package/dist/components/type-link.js +17 -27
- package/dist/components/type-link.js.map +1 -1
- package/dist/context.d.ts +47 -26
- package/dist/context.js +194 -183
- package/dist/context.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +5 -4
- package/dist/index.js.map +1 -1
- package/package.json +4 -3
|
@@ -1,53 +1,43 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { c } from "react-compiler-runtime";
|
|
3
|
-
import {
|
|
3
|
+
import { useDocExplorerActions } from "../context.js";
|
|
4
4
|
import { renderType } from "./utils.js";
|
|
5
5
|
/* empty css */
|
|
6
6
|
const TypeLink = (t0) => {
|
|
7
|
-
const $ = c(
|
|
7
|
+
const $ = c(5);
|
|
8
8
|
const {
|
|
9
9
|
type
|
|
10
10
|
} = t0;
|
|
11
|
-
let t1;
|
|
12
|
-
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
13
|
-
t1 = {
|
|
14
|
-
nonNull: true,
|
|
15
|
-
caller: TypeLink
|
|
16
|
-
};
|
|
17
|
-
$[0] = t1;
|
|
18
|
-
} else {
|
|
19
|
-
t1 = $[0];
|
|
20
|
-
}
|
|
21
11
|
const {
|
|
22
12
|
push
|
|
23
|
-
} =
|
|
13
|
+
} = useDocExplorerActions();
|
|
24
14
|
if (!type) {
|
|
25
15
|
return null;
|
|
26
16
|
}
|
|
27
|
-
let
|
|
28
|
-
if ($[
|
|
29
|
-
|
|
17
|
+
let t1;
|
|
18
|
+
if ($[0] !== push) {
|
|
19
|
+
t1 = (namedType) => /* @__PURE__ */ jsx("a", { className: "graphiql-doc-explorer-type-name", onClick: (event) => {
|
|
30
20
|
event.preventDefault();
|
|
31
21
|
push({
|
|
32
22
|
name: namedType.name,
|
|
33
23
|
def: namedType
|
|
34
24
|
});
|
|
35
25
|
}, href: "#", children: namedType.name });
|
|
36
|
-
$[
|
|
37
|
-
$[
|
|
26
|
+
$[0] = push;
|
|
27
|
+
$[1] = t1;
|
|
38
28
|
} else {
|
|
39
|
-
|
|
29
|
+
t1 = $[1];
|
|
40
30
|
}
|
|
41
|
-
let
|
|
42
|
-
if ($[
|
|
43
|
-
|
|
44
|
-
$[
|
|
45
|
-
$[
|
|
46
|
-
$[
|
|
31
|
+
let t2;
|
|
32
|
+
if ($[2] !== t1 || $[3] !== type) {
|
|
33
|
+
t2 = renderType(type, t1);
|
|
34
|
+
$[2] = t1;
|
|
35
|
+
$[3] = type;
|
|
36
|
+
$[4] = t2;
|
|
47
37
|
} else {
|
|
48
|
-
|
|
38
|
+
t2 = $[4];
|
|
49
39
|
}
|
|
50
|
-
return
|
|
40
|
+
return t2;
|
|
51
41
|
};
|
|
52
42
|
export {
|
|
53
43
|
TypeLink
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type-link.js","sources":["../../src/components/type-link.tsx"],"sourcesContent":["import { FC } from 'react';\nimport { GraphQLType } from 'graphql';\nimport {
|
|
1
|
+
{"version":3,"file":"type-link.js","sources":["../../src/components/type-link.tsx"],"sourcesContent":["import { FC } from 'react';\nimport { GraphQLType } from 'graphql';\nimport { useDocExplorerActions } from '../context';\nimport { renderType } from './utils';\nimport './type-link.css';\n\ntype TypeLinkProps = {\n /**\n * The type that should be linked to.\n */\n type: GraphQLType;\n};\n\nexport const TypeLink: FC<TypeLinkProps> = ({ type }) => {\n const { push } = useDocExplorerActions();\n\n if (!type) {\n return null;\n }\n\n return renderType(type, namedType => (\n <a\n className=\"graphiql-doc-explorer-type-name\"\n onClick={event => {\n event.preventDefault();\n push({ name: namedType.name, def: namedType });\n }}\n href=\"#\"\n >\n {namedType.name}\n </a>\n ));\n};\n"],"names":["TypeLink","t0","$","_c","type","push","useDocExplorerActions","t1","namedType","event","preventDefault","name","def","t2","renderType"],"mappings":";;;;;AAaO,MAAMA,WAA8BC,CAAA,OAAA;AAAAC,QAAAA,IAAAC,EAAA,CAAA;AAAC,QAAA;AAAA,IAAAC;AAAAA,EAAAA,IAAAH;AAC1C,QAAA;AAAA,IAAAI;AAAAA,MAAiBC,sBAAsB;AAAE,MAAA,CAEpCF,MAAI;AAAA,WAAA;AAAA,EAAA;AAAAG,MAAAA;AAAAL,MAAAA,SAAAG,MAAA;AAIeE,SAAAC,eACtB,oBAAA,KAAA,EACY,WAAA,mCACD,SAAAC,CAAA,UAAA;AACPA,YAAKC,eAAgB;AACjB,WAAA;AAAA,QAAAC,MAASH,UAASG;AAAAA,QAAAC,KAAYJ;AAAAA,MAAAA,CAAW;AAAA,IAE1C,GAAA,MAAA,KAEJA,UAAAA,UAASG,KACZ,CAAA;AACDT,WAAAG;AAAAH,WAAAK;AAAAA,EAAAA,OAAA;AAAAA,SAAAL,EAAA,CAAA;AAAA,EAAA;AAAAW,MAAAA;AAAA,MAAAX,EAAAK,CAAAA,MAAAA,MAAAL,SAAAE,MAAA;AAXMU,SAAAA,WAAWV,MAAMG,EAWvB;AAACL,WAAAK;AAAAL,WAAAE;AAAAF,WAAAW;AAAAA,EAAAA,OAAA;AAAAA,SAAAX,EAAA,CAAA;AAAA,EAAA;AAXKW,SAAAA;AAWL;"}
|
package/dist/context.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { GraphQLArgument, GraphQLField, GraphQLInputField, GraphQLNamedType } from 'graphql';
|
|
2
|
-
import { FC, ReactNode } from 'react';
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { GraphQLArgument, GraphQLField, GraphQLInputField, GraphQLNamedType, GraphQLSchema } from 'graphql';
|
|
2
|
+
import { FC, ReactNode, RefObject } from 'react';
|
|
3
|
+
import { SchemaContextType } from '@graphiql/react';
|
|
4
|
+
import { StoreApi } from 'zustand';
|
|
5
|
+
export declare type DocExplorerFieldDef = GraphQLField<unknown, unknown> | GraphQLInputField | GraphQLArgument;
|
|
6
|
+
export declare type DocExplorerNavStackItem = {
|
|
5
7
|
/**
|
|
6
8
|
* The name of the item.
|
|
7
9
|
*/
|
|
@@ -10,23 +12,52 @@ export declare type ExplorerNavStackItem = {
|
|
|
10
12
|
* The definition object of the item, this can be a named type, a field, an
|
|
11
13
|
* input field or an argument.
|
|
12
14
|
*/
|
|
13
|
-
def?: GraphQLNamedType |
|
|
15
|
+
def?: GraphQLNamedType | DocExplorerFieldDef;
|
|
14
16
|
};
|
|
15
|
-
export declare type
|
|
16
|
-
|
|
17
|
-
...
|
|
17
|
+
export declare type DocExplorerNavStack = [
|
|
18
|
+
DocExplorerNavStackItem,
|
|
19
|
+
...DocExplorerNavStackItem[]
|
|
18
20
|
];
|
|
19
|
-
export declare type
|
|
21
|
+
export declare type DocExplorerContextType = {
|
|
20
22
|
/**
|
|
21
23
|
* A stack of navigation items. The last item in the list is the current one.
|
|
22
24
|
* This list always contains at least one item.
|
|
23
25
|
*/
|
|
24
|
-
explorerNavStack:
|
|
26
|
+
explorerNavStack: DocExplorerNavStack;
|
|
27
|
+
actions: {
|
|
28
|
+
/**
|
|
29
|
+
* Push an item to the navigation stack.
|
|
30
|
+
* @param item The item that should be pushed to the stack.
|
|
31
|
+
*/
|
|
32
|
+
push(item: DocExplorerNavStackItem): void;
|
|
33
|
+
/**
|
|
34
|
+
* Pop the last item from the navigation stack.
|
|
35
|
+
*/
|
|
36
|
+
pop(): void;
|
|
37
|
+
/**
|
|
38
|
+
* Reset the navigation stack to its initial state, this will remove all but
|
|
39
|
+
* the initial stack item.
|
|
40
|
+
*/
|
|
41
|
+
reset(): void;
|
|
42
|
+
resolveSchemaReferenceToNavItem(schemaReference: SchemaContextType['schemaReference']): void;
|
|
43
|
+
/**
|
|
44
|
+
* Replace the nav stack with an updated version using the new schema.
|
|
45
|
+
*/
|
|
46
|
+
rebuildNavStackWithSchema(schema: GraphQLSchema): void;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
export declare function createDocExplorerStore(initialNavStackItem?: DocExplorerNavStackItem): StoreApi<DocExplorerContextType>;
|
|
50
|
+
export declare const DocExplorerContext: import('react').Context<RefObject<StoreApi<DocExplorerContextType>> | null>;
|
|
51
|
+
export declare const DocExplorerContextProvider: FC<{
|
|
52
|
+
children: ReactNode;
|
|
53
|
+
}>;
|
|
54
|
+
export declare const useDocExplorer: () => DocExplorerNavStack;
|
|
55
|
+
export declare const useDocExplorerActions: () => {
|
|
25
56
|
/**
|
|
26
57
|
* Push an item to the navigation stack.
|
|
27
58
|
* @param item The item that should be pushed to the stack.
|
|
28
59
|
*/
|
|
29
|
-
push(item:
|
|
60
|
+
push(item: DocExplorerNavStackItem): void;
|
|
30
61
|
/**
|
|
31
62
|
* Pop the last item from the navigation stack.
|
|
32
63
|
*/
|
|
@@ -36,19 +67,9 @@ export declare type ExplorerContextType = {
|
|
|
36
67
|
* the initial stack item.
|
|
37
68
|
*/
|
|
38
69
|
reset(): void;
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
export declare const useExplorerContext: {
|
|
45
|
-
(options: {
|
|
46
|
-
nonNull: true;
|
|
47
|
-
caller?: Function | undefined;
|
|
48
|
-
}): ExplorerContextType;
|
|
49
|
-
(options: {
|
|
50
|
-
nonNull?: boolean | undefined;
|
|
51
|
-
caller?: Function | undefined;
|
|
52
|
-
}): ExplorerContextType | null;
|
|
53
|
-
(): ExplorerContextType | null;
|
|
70
|
+
resolveSchemaReferenceToNavItem(schemaReference: SchemaContextType['schemaReference']): void;
|
|
71
|
+
/**
|
|
72
|
+
* Replace the nav stack with an updated version using the new schema.
|
|
73
|
+
*/
|
|
74
|
+
rebuildNavStackWithSchema(schema: GraphQLSchema): void;
|
|
54
75
|
};
|
package/dist/context.js
CHANGED
|
@@ -1,234 +1,245 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { c } from "react-compiler-runtime";
|
|
3
3
|
import { isNamedType, isObjectType, isInputObjectType, isScalarType, isEnumType, isInterfaceType, isUnionType } from "graphql";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
4
|
+
import { createContext, useRef, useEffect, useContext } from "react";
|
|
5
|
+
import { useSchemaStore } from "@graphiql/react";
|
|
6
|
+
import { createStore, useStore } from "zustand";
|
|
7
|
+
function createDocExplorerStore(initialNavStackItem = {
|
|
7
8
|
name: "Docs"
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
const push = t2;
|
|
48
|
-
let t3;
|
|
49
|
-
if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
|
|
50
|
-
t3 = () => {
|
|
51
|
-
setNavStack(_temp);
|
|
52
|
-
};
|
|
53
|
-
$[3] = t3;
|
|
54
|
-
} else {
|
|
55
|
-
t3 = $[3];
|
|
56
|
-
}
|
|
57
|
-
const pop = t3;
|
|
58
|
-
let t4;
|
|
59
|
-
if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
|
|
60
|
-
t4 = () => {
|
|
61
|
-
setNavStack(_temp2);
|
|
62
|
-
};
|
|
63
|
-
$[4] = t4;
|
|
64
|
-
} else {
|
|
65
|
-
t4 = $[4];
|
|
66
|
-
}
|
|
67
|
-
const reset = t4;
|
|
68
|
-
let t5;
|
|
69
|
-
let t6;
|
|
70
|
-
if ($[5] !== schemaReference) {
|
|
71
|
-
t5 = () => {
|
|
72
|
-
if (!schemaReference) {
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
bb26: switch (schemaReference.kind) {
|
|
76
|
-
case "Type": {
|
|
77
|
-
push({
|
|
78
|
-
name: schemaReference.type.name,
|
|
79
|
-
def: schemaReference.type
|
|
80
|
-
});
|
|
81
|
-
break bb26;
|
|
82
|
-
}
|
|
83
|
-
case "Field": {
|
|
84
|
-
push({
|
|
85
|
-
name: schemaReference.field.name,
|
|
86
|
-
def: schemaReference.field
|
|
87
|
-
});
|
|
88
|
-
break bb26;
|
|
9
|
+
}) {
|
|
10
|
+
return createStore((set, get) => ({
|
|
11
|
+
explorerNavStack: [initialNavStackItem],
|
|
12
|
+
actions: {
|
|
13
|
+
push(item) {
|
|
14
|
+
set((state) => {
|
|
15
|
+
const curr = state.explorerNavStack;
|
|
16
|
+
const lastItem = curr.at(-1);
|
|
17
|
+
const explorerNavStack = (
|
|
18
|
+
// Avoid pushing duplicate items
|
|
19
|
+
lastItem.def === item.def ? curr : [...curr, item]
|
|
20
|
+
);
|
|
21
|
+
return {
|
|
22
|
+
explorerNavStack
|
|
23
|
+
};
|
|
24
|
+
});
|
|
25
|
+
},
|
|
26
|
+
pop() {
|
|
27
|
+
set((state) => {
|
|
28
|
+
const curr = state.explorerNavStack;
|
|
29
|
+
const explorerNavStack = curr.length > 1 ? curr.slice(0, -1) : curr;
|
|
30
|
+
return {
|
|
31
|
+
explorerNavStack
|
|
32
|
+
};
|
|
33
|
+
});
|
|
34
|
+
},
|
|
35
|
+
reset() {
|
|
36
|
+
set((state) => {
|
|
37
|
+
const curr = state.explorerNavStack;
|
|
38
|
+
const explorerNavStack = curr.length === 1 ? curr : [initialNavStackItem];
|
|
39
|
+
return {
|
|
40
|
+
explorerNavStack
|
|
41
|
+
};
|
|
42
|
+
});
|
|
43
|
+
},
|
|
44
|
+
resolveSchemaReferenceToNavItem(schemaReference) {
|
|
45
|
+
if (!schemaReference) {
|
|
46
|
+
return;
|
|
89
47
|
}
|
|
90
|
-
|
|
91
|
-
|
|
48
|
+
const {
|
|
49
|
+
push
|
|
50
|
+
} = get().actions;
|
|
51
|
+
switch (schemaReference.kind) {
|
|
52
|
+
case "Type": {
|
|
92
53
|
push({
|
|
93
|
-
name: schemaReference.
|
|
94
|
-
def: schemaReference.
|
|
54
|
+
name: schemaReference.type.name,
|
|
55
|
+
def: schemaReference.type
|
|
95
56
|
});
|
|
57
|
+
break;
|
|
96
58
|
}
|
|
97
|
-
|
|
98
|
-
}
|
|
99
|
-
case "EnumValue": {
|
|
100
|
-
if (schemaReference.type) {
|
|
59
|
+
case "Field": {
|
|
101
60
|
push({
|
|
102
|
-
name: schemaReference.
|
|
103
|
-
def: schemaReference.
|
|
61
|
+
name: schemaReference.field.name,
|
|
62
|
+
def: schemaReference.field
|
|
104
63
|
});
|
|
64
|
+
break;
|
|
65
|
+
}
|
|
66
|
+
case "Argument": {
|
|
67
|
+
if (schemaReference.field) {
|
|
68
|
+
push({
|
|
69
|
+
name: schemaReference.field.name,
|
|
70
|
+
def: schemaReference.field
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
case "EnumValue": {
|
|
76
|
+
if (schemaReference.type) {
|
|
77
|
+
push({
|
|
78
|
+
name: schemaReference.type.name,
|
|
79
|
+
def: schemaReference.type
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
break;
|
|
105
83
|
}
|
|
106
84
|
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
$[6] = t5;
|
|
112
|
-
$[7] = t6;
|
|
113
|
-
} else {
|
|
114
|
-
t5 = $[6];
|
|
115
|
-
t6 = $[7];
|
|
116
|
-
}
|
|
117
|
-
useEffect(t5, t6);
|
|
118
|
-
let t7;
|
|
119
|
-
let t8;
|
|
120
|
-
if ($[8] !== schema || $[9] !== validationErrors) {
|
|
121
|
-
t7 = () => {
|
|
122
|
-
if (schema == null || validationErrors.length > 0) {
|
|
123
|
-
reset();
|
|
124
|
-
} else {
|
|
125
|
-
setNavStack((oldNavStack) => {
|
|
85
|
+
},
|
|
86
|
+
rebuildNavStackWithSchema(schema) {
|
|
87
|
+
set((state) => {
|
|
88
|
+
const oldNavStack = state.explorerNavStack;
|
|
126
89
|
if (oldNavStack.length === 1) {
|
|
127
90
|
return oldNavStack;
|
|
128
91
|
}
|
|
129
92
|
const newNavStack = [initialNavStackItem];
|
|
130
93
|
let lastEntity = null;
|
|
131
|
-
for (const
|
|
132
|
-
if (
|
|
94
|
+
for (const item of oldNavStack) {
|
|
95
|
+
if (item === initialNavStackItem) {
|
|
133
96
|
continue;
|
|
134
97
|
}
|
|
135
|
-
if (
|
|
136
|
-
if (isNamedType(
|
|
137
|
-
const newType = schema.getType(
|
|
98
|
+
if (item.def) {
|
|
99
|
+
if (isNamedType(item.def)) {
|
|
100
|
+
const newType = schema.getType(item.def.name);
|
|
138
101
|
if (newType) {
|
|
139
102
|
newNavStack.push({
|
|
140
|
-
name:
|
|
103
|
+
name: item.name,
|
|
141
104
|
def: newType
|
|
142
105
|
});
|
|
143
106
|
lastEntity = newType;
|
|
144
107
|
} else {
|
|
145
108
|
break;
|
|
146
109
|
}
|
|
147
|
-
} else {
|
|
148
|
-
|
|
110
|
+
} else if (lastEntity === null) {
|
|
111
|
+
break;
|
|
112
|
+
} else if (isObjectType(lastEntity) || isInputObjectType(lastEntity)) {
|
|
113
|
+
const field = lastEntity.getFields()[item.name];
|
|
114
|
+
if (field) {
|
|
115
|
+
newNavStack.push({
|
|
116
|
+
name: item.name,
|
|
117
|
+
def: field
|
|
118
|
+
});
|
|
119
|
+
} else {
|
|
149
120
|
break;
|
|
121
|
+
}
|
|
122
|
+
} else if (isScalarType(lastEntity) || isEnumType(lastEntity) || isInterfaceType(lastEntity) || isUnionType(lastEntity)) {
|
|
123
|
+
break;
|
|
124
|
+
} else {
|
|
125
|
+
const field = lastEntity;
|
|
126
|
+
if (field.args.some((a) => a.name === item.name)) {
|
|
127
|
+
newNavStack.push({
|
|
128
|
+
name: item.name,
|
|
129
|
+
def: field
|
|
130
|
+
});
|
|
150
131
|
} else {
|
|
151
|
-
|
|
152
|
-
const field = lastEntity.getFields()[item_0.name];
|
|
153
|
-
if (field) {
|
|
154
|
-
newNavStack.push({
|
|
155
|
-
name: item_0.name,
|
|
156
|
-
def: field
|
|
157
|
-
});
|
|
158
|
-
} else {
|
|
159
|
-
break;
|
|
160
|
-
}
|
|
161
|
-
} else {
|
|
162
|
-
if (isScalarType(lastEntity) || isEnumType(lastEntity) || isInterfaceType(lastEntity) || isUnionType(lastEntity)) {
|
|
163
|
-
break;
|
|
164
|
-
} else {
|
|
165
|
-
const field_0 = lastEntity;
|
|
166
|
-
if (field_0.args.some((a) => a.name === item_0.name)) {
|
|
167
|
-
newNavStack.push({
|
|
168
|
-
name: item_0.name,
|
|
169
|
-
def: field_0
|
|
170
|
-
});
|
|
171
|
-
} else {
|
|
172
|
-
break;
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
}
|
|
132
|
+
break;
|
|
176
133
|
}
|
|
177
134
|
}
|
|
178
135
|
} else {
|
|
179
136
|
lastEntity = null;
|
|
180
|
-
newNavStack.push(
|
|
137
|
+
newNavStack.push(item);
|
|
181
138
|
}
|
|
182
139
|
}
|
|
183
|
-
return
|
|
140
|
+
return {
|
|
141
|
+
explorerNavStack: newNavStack
|
|
142
|
+
};
|
|
184
143
|
});
|
|
185
144
|
}
|
|
145
|
+
}
|
|
146
|
+
}));
|
|
147
|
+
}
|
|
148
|
+
const DocExplorerContext = createContext(null);
|
|
149
|
+
const DocExplorerContextProvider = (props) => {
|
|
150
|
+
const $ = c(10);
|
|
151
|
+
const {
|
|
152
|
+
schema,
|
|
153
|
+
validationErrors,
|
|
154
|
+
schemaReference
|
|
155
|
+
} = useSchemaStore();
|
|
156
|
+
const storeRef = useRef(null);
|
|
157
|
+
if (storeRef.current === null) {
|
|
158
|
+
let t02;
|
|
159
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
160
|
+
t02 = createDocExplorerStore();
|
|
161
|
+
$[0] = t02;
|
|
162
|
+
} else {
|
|
163
|
+
t02 = $[0];
|
|
164
|
+
}
|
|
165
|
+
storeRef.current = t02;
|
|
166
|
+
}
|
|
167
|
+
let t0;
|
|
168
|
+
let t1;
|
|
169
|
+
if ($[1] !== schemaReference) {
|
|
170
|
+
t0 = () => {
|
|
171
|
+
const {
|
|
172
|
+
resolveSchemaReferenceToNavItem
|
|
173
|
+
} = storeRef.current.getState().actions;
|
|
174
|
+
resolveSchemaReferenceToNavItem(schemaReference);
|
|
186
175
|
};
|
|
187
|
-
|
|
188
|
-
$[
|
|
189
|
-
$[
|
|
190
|
-
$[
|
|
191
|
-
$[11] = t8;
|
|
176
|
+
t1 = [schemaReference];
|
|
177
|
+
$[1] = schemaReference;
|
|
178
|
+
$[2] = t0;
|
|
179
|
+
$[3] = t1;
|
|
192
180
|
} else {
|
|
193
|
-
|
|
194
|
-
|
|
181
|
+
t0 = $[2];
|
|
182
|
+
t1 = $[3];
|
|
195
183
|
}
|
|
196
|
-
useEffect(
|
|
197
|
-
let
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
184
|
+
useEffect(t0, t1);
|
|
185
|
+
let t2;
|
|
186
|
+
let t3;
|
|
187
|
+
if ($[4] !== schema || $[5] !== validationErrors) {
|
|
188
|
+
t2 = () => {
|
|
189
|
+
const {
|
|
190
|
+
reset,
|
|
191
|
+
rebuildNavStackWithSchema
|
|
192
|
+
} = storeRef.current.getState().actions;
|
|
193
|
+
if (schema == null || validationErrors.length > 0) {
|
|
194
|
+
reset();
|
|
195
|
+
} else {
|
|
196
|
+
rebuildNavStackWithSchema(schema);
|
|
197
|
+
}
|
|
204
198
|
};
|
|
205
|
-
|
|
206
|
-
$[
|
|
199
|
+
t3 = [schema, validationErrors];
|
|
200
|
+
$[4] = schema;
|
|
201
|
+
$[5] = validationErrors;
|
|
202
|
+
$[6] = t2;
|
|
203
|
+
$[7] = t3;
|
|
207
204
|
} else {
|
|
208
|
-
|
|
205
|
+
t2 = $[6];
|
|
206
|
+
t3 = $[7];
|
|
209
207
|
}
|
|
210
|
-
|
|
211
|
-
let
|
|
212
|
-
if ($[
|
|
213
|
-
|
|
214
|
-
$[
|
|
215
|
-
$[
|
|
216
|
-
$[16] = t10;
|
|
208
|
+
useEffect(t2, t3);
|
|
209
|
+
let t4;
|
|
210
|
+
if ($[8] !== props.children) {
|
|
211
|
+
t4 = /* @__PURE__ */ jsx(DocExplorerContext.Provider, { value: storeRef, children: props.children });
|
|
212
|
+
$[8] = props.children;
|
|
213
|
+
$[9] = t4;
|
|
217
214
|
} else {
|
|
218
|
-
|
|
215
|
+
t4 = $[9];
|
|
219
216
|
}
|
|
220
|
-
return
|
|
217
|
+
return t4;
|
|
218
|
+
};
|
|
219
|
+
function useDocExplorerStore(selector) {
|
|
220
|
+
const store = useContext(DocExplorerContext);
|
|
221
|
+
if (!store) {
|
|
222
|
+
throw new Error("Missing `DocExplorerContextProvider` in the tree");
|
|
223
|
+
}
|
|
224
|
+
return useStore(store.current, selector);
|
|
225
|
+
}
|
|
226
|
+
const useDocExplorer = () => {
|
|
227
|
+
return useDocExplorerStore(_temp);
|
|
228
|
+
};
|
|
229
|
+
const useDocExplorerActions = () => {
|
|
230
|
+
return useDocExplorerStore(_temp2);
|
|
221
231
|
};
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
return currentState_0.length > 1 ? currentState_0.slice(0, -1) : currentState_0;
|
|
232
|
+
function _temp(state) {
|
|
233
|
+
return state.explorerNavStack;
|
|
225
234
|
}
|
|
226
|
-
function _temp2(
|
|
227
|
-
return
|
|
235
|
+
function _temp2(state) {
|
|
236
|
+
return state.actions;
|
|
228
237
|
}
|
|
229
238
|
export {
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
239
|
+
DocExplorerContext,
|
|
240
|
+
DocExplorerContextProvider,
|
|
241
|
+
createDocExplorerStore,
|
|
242
|
+
useDocExplorer,
|
|
243
|
+
useDocExplorerActions
|
|
233
244
|
};
|
|
234
245
|
//# sourceMappingURL=context.js.map
|