@xyo-network/react-schema 7.5.8 → 7.5.11

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 (32) hide show
  1. package/dist/browser/contexts/Schema/Provider/Memory.d.ts.map +1 -1
  2. package/dist/browser/hooks/useGetSchema.d.ts +8 -6
  3. package/dist/browser/hooks/useGetSchema.d.ts.map +1 -1
  4. package/dist/browser/hooks/useSchemaDefinitions.d.ts +2 -2
  5. package/dist/browser/hooks/useSchemaDefinitions.d.ts.map +1 -1
  6. package/dist/browser/hooks/useSchemaStats.d.ts.map +1 -1
  7. package/dist/browser/index.mjs +308 -297
  8. package/dist/browser/index.mjs.map +1 -1
  9. package/package.json +160 -57
  10. package/src/components/Property/SchemaProperty.stories.tsx +0 -41
  11. package/src/components/Property/SchemaProperty.tsx +0 -154
  12. package/src/components/Property/index.ts +0 -1
  13. package/src/components/SelectEx/SchemaSelectEx.tsx +0 -45
  14. package/src/components/SelectEx/index.ts +0 -1
  15. package/src/components/index.ts +0 -2
  16. package/src/contexts/Schema/Context.ts +0 -5
  17. package/src/contexts/Schema/Provider/Memory.tsx +0 -31
  18. package/src/contexts/Schema/Provider/Props.ts +0 -4
  19. package/src/contexts/Schema/Provider/Route.tsx +0 -73
  20. package/src/contexts/Schema/Provider/index.ts +0 -3
  21. package/src/contexts/Schema/State.ts +0 -13
  22. package/src/contexts/Schema/index.ts +0 -4
  23. package/src/contexts/Schema/use.ts +0 -8
  24. package/src/contexts/index.ts +0 -1
  25. package/src/hooks/index.ts +0 -4
  26. package/src/hooks/stories/TestSchemaHooks.stories.tsx +0 -102
  27. package/src/hooks/useGetSchema.stories.tsx +0 -65
  28. package/src/hooks/useGetSchema.tsx +0 -57
  29. package/src/hooks/useSchemaDefinitions.tsx +0 -26
  30. package/src/hooks/useSchemaList.tsx +0 -35
  31. package/src/hooks/useSchemaStats.tsx +0 -62
  32. package/src/index.ts +0 -3
@@ -1,8 +1,9 @@
1
- var __defProp = Object.defineProperty;
2
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
-
4
1
  // src/components/Property/SchemaProperty.tsx
5
- import { NewReleases as NewReleasesIcon, OpenInNew as OpenInNewIcon, Verified as VerifiedIcon } from "@mui/icons-material";
2
+ import {
3
+ NewReleases as NewReleasesIcon,
4
+ OpenInNew as OpenInNewIcon,
5
+ Verified as VerifiedIcon
6
+ } from "@mui/icons-material";
6
7
  import { IconButton } from "@mui/material";
7
8
  import { useAsyncEffect } from "@xylabs/react-async-effect";
8
9
  import { FlexGrowRow } from "@xylabs/react-flexbox";
@@ -10,115 +11,128 @@ import { LinkEx } from "@xylabs/react-link";
10
11
  import { useEvent } from "@xyo-network/react-event";
11
12
  import { Property, PropertyValue } from "@xyo-network/react-property";
12
13
  import { SchemaCache } from "@xyo-network/schema-cache";
13
- import React, { useState } from "react";
14
- var useResolveSchema = /* @__PURE__ */ __name((schema) => {
14
+ import { useState } from "react";
15
+ import { jsx, jsxs } from "react/jsx-runtime";
16
+ var useResolveSchema = (schema) => {
15
17
  const [entry, setEntry] = useState();
16
- useAsyncEffect(async (mounted) => {
17
- if (schema) {
18
- const entry2 = await SchemaCache.instance.get(schema);
19
- if (mounted()) {
20
- setEntry(entry2);
18
+ useAsyncEffect(
19
+ async (mounted) => {
20
+ if (schema) {
21
+ const entry2 = await SchemaCache.instance.get(schema);
22
+ if (mounted()) {
23
+ setEntry(entry2);
24
+ }
21
25
  }
22
- }
23
- }, [
24
- schema
25
- ]);
26
+ },
27
+ [schema]
28
+ );
26
29
  return entry;
27
- }, "useResolveSchema");
28
- var SchemaProperty = /* @__PURE__ */ __name(({ showLinkNames = true, showOpenNewWindowLink = true, showStatusIcon = true, titleProps, value, ...props }) => {
30
+ };
31
+ var SchemaProperty = ({
32
+ showLinkNames = true,
33
+ showOpenNewWindowLink = true,
34
+ showStatusIcon = true,
35
+ titleProps,
36
+ value,
37
+ ...props
38
+ }) => {
29
39
  const resolvedSchema = useResolveSchema(value);
30
40
  const [buttonRef, buttonDispatch] = useEvent();
31
41
  const [divRef, divDispatch] = useEvent();
32
- const onClick = /* @__PURE__ */ __name((dispatch, openNewWindow = false) => {
33
- dispatch?.("schema", "click", JSON.stringify({
34
- openNewWindow,
35
- schema: value
36
- }));
37
- }, "onClick");
38
- return /* @__PURE__ */ React.createElement(Property, {
39
- title: "Schema",
40
- value,
41
- tip: "Schema sent with the payload",
42
- titleProps,
43
- ...props
44
- }, value && showStatusIcon ? resolvedSchema === null ? /* @__PURE__ */ React.createElement(IconButton, {
45
- ref: buttonRef,
46
- size: "small",
47
- onClick: /* @__PURE__ */ __name(() => {
48
- if (!buttonRef.current) {
49
- console.warn("buttonRef.current is null");
50
- }
51
- onClick(buttonDispatch);
52
- }, "onClick")
53
- }, /* @__PURE__ */ React.createElement(NewReleasesIcon, {
54
- color: "warning",
55
- fontSize: "inherit"
56
- })) : resolvedSchema === void 0 ? /* @__PURE__ */ React.createElement(IconButton, {
57
- ref: buttonRef,
58
- size: "small",
59
- onClick: /* @__PURE__ */ __name(() => {
60
- if (!buttonRef.current) {
61
- console.warn("buttonRef.current is null");
62
- }
63
- onClick(buttonDispatch);
64
- }, "onClick")
65
- }, /* @__PURE__ */ React.createElement(NewReleasesIcon, {
66
- color: "disabled",
67
- fontSize: "inherit"
68
- })) : /* @__PURE__ */ React.createElement(IconButton, {
69
- rel: "noopener noreferrer",
70
- size: "small",
71
- target: "_blank",
72
- href: resolvedSchema?.huri?.href ?? ""
73
- }, /* @__PURE__ */ React.createElement(VerifiedIcon, {
74
- color: "success",
75
- fontSize: "inherit"
76
- })) : null, value ? /* @__PURE__ */ React.createElement(FlexGrowRow, {
77
- ref: divRef,
78
- justifyContent: "space-between"
79
- }, showLinkNames ? /* @__PURE__ */ React.createElement(LinkEx, {
80
- display: "block",
81
- width: "100%",
82
- sx: {
83
- cursor: "pointer"
84
- }
85
- }, /* @__PURE__ */ React.createElement(PropertyValue, {
86
- value,
87
- title: "view schema",
88
- onClick: /* @__PURE__ */ __name(() => {
89
- if (!divRef.current) {
90
- console.warn("divRef.current is null");
91
- }
92
- onClick(divDispatch);
93
- }, "onClick")
94
- })) : /* @__PURE__ */ React.createElement(PropertyValue, {
95
- value,
96
- title: "view schema",
97
- onClick: /* @__PURE__ */ __name(() => {
98
- if (!divRef.current) {
99
- console.warn("divRef.current is null");
42
+ const onClick = (dispatch, openNewWindow = false) => {
43
+ dispatch?.(
44
+ "schema",
45
+ "click",
46
+ JSON.stringify({
47
+ openNewWindow,
48
+ schema: value
49
+ })
50
+ );
51
+ };
52
+ return /* @__PURE__ */ jsxs(Property, { title: "Schema", value, tip: "Schema sent with the payload", titleProps, ...props, children: [
53
+ value && showStatusIcon ? resolvedSchema === null ? /* @__PURE__ */ jsx(
54
+ IconButton,
55
+ {
56
+ ref: buttonRef,
57
+ size: "small",
58
+ onClick: () => {
59
+ if (!buttonRef.current) {
60
+ console.warn("buttonRef.current is null");
61
+ }
62
+ onClick(buttonDispatch);
63
+ },
64
+ children: /* @__PURE__ */ jsx(NewReleasesIcon, { color: "warning", fontSize: "inherit" })
100
65
  }
101
- onClick(divDispatch);
102
- }, "onClick")
103
- }), showOpenNewWindowLink ? /* @__PURE__ */ React.createElement(IconButton, {
104
- ref: buttonRef,
105
- size: "small",
106
- onClick: /* @__PURE__ */ __name(() => {
107
- if (!buttonRef.current) {
108
- console.warn("buttonRef.current is null");
66
+ ) : resolvedSchema === void 0 ? /* @__PURE__ */ jsx(
67
+ IconButton,
68
+ {
69
+ ref: buttonRef,
70
+ size: "small",
71
+ onClick: () => {
72
+ if (!buttonRef.current) {
73
+ console.warn("buttonRef.current is null");
74
+ }
75
+ onClick(buttonDispatch);
76
+ },
77
+ children: /* @__PURE__ */ jsx(NewReleasesIcon, { color: "disabled", fontSize: "inherit" })
109
78
  }
110
- onClick(buttonDispatch, true);
111
- }, "onClick")
112
- }, /* @__PURE__ */ React.createElement(OpenInNewIcon, {
113
- fontSize: "inherit"
114
- })) : null) : null);
115
- }, "SchemaProperty");
79
+ ) : /* @__PURE__ */ jsx(IconButton, { rel: "noopener noreferrer", size: "small", target: "_blank", href: resolvedSchema?.huri?.href ?? "", children: /* @__PURE__ */ jsx(VerifiedIcon, { color: "success", fontSize: "inherit" }) }) : null,
80
+ value ? /* @__PURE__ */ jsxs(FlexGrowRow, { ref: divRef, justifyContent: "space-between", children: [
81
+ showLinkNames ? /* @__PURE__ */ jsx(
82
+ LinkEx,
83
+ {
84
+ display: "block",
85
+ width: "100%",
86
+ sx: { cursor: "pointer" },
87
+ children: /* @__PURE__ */ jsx(
88
+ PropertyValue,
89
+ {
90
+ value,
91
+ title: "view schema",
92
+ onClick: () => {
93
+ if (!divRef.current) {
94
+ console.warn("divRef.current is null");
95
+ }
96
+ onClick(divDispatch);
97
+ }
98
+ }
99
+ )
100
+ }
101
+ ) : /* @__PURE__ */ jsx(
102
+ PropertyValue,
103
+ {
104
+ value,
105
+ title: "view schema",
106
+ onClick: () => {
107
+ if (!divRef.current) {
108
+ console.warn("divRef.current is null");
109
+ }
110
+ onClick(divDispatch);
111
+ }
112
+ }
113
+ ),
114
+ showOpenNewWindowLink ? /* @__PURE__ */ jsx(
115
+ IconButton,
116
+ {
117
+ ref: buttonRef,
118
+ size: "small",
119
+ onClick: () => {
120
+ if (!buttonRef.current) {
121
+ console.warn("buttonRef.current is null");
122
+ }
123
+ onClick(buttonDispatch, true);
124
+ },
125
+ children: /* @__PURE__ */ jsx(OpenInNewIcon, { fontSize: "inherit" })
126
+ }
127
+ ) : null
128
+ ] }) : null
129
+ ] });
130
+ };
116
131
  SchemaProperty.displayName = "SchemaProperty";
117
132
 
118
133
  // src/components/SelectEx/SchemaSelectEx.tsx
119
134
  import { MenuItem, Typography } from "@mui/material";
120
135
  import { SelectEx } from "@xylabs/react-select";
121
- import React4 from "react";
122
136
 
123
137
  // src/contexts/Schema/Context.ts
124
138
  import { createContextEx } from "@xylabs/react-shared";
@@ -126,7 +140,11 @@ var SchemaContext = createContextEx();
126
140
 
127
141
  // src/contexts/Schema/Provider/Memory.tsx
128
142
  import { exists } from "@xylabs/sdk-js";
129
- import React2, { useEffect, useMemo as useMemo2, useState as useState5 } from "react";
143
+ import {
144
+ useEffect,
145
+ useMemo as useMemo2,
146
+ useState as useState5
147
+ } from "react";
130
148
 
131
149
  // src/hooks/useGetSchema.tsx
132
150
  import { useAsyncEffect as useAsyncEffect2 } from "@xylabs/react-async-effect";
@@ -134,223 +152,217 @@ import { PayloadBuilder } from "@xyo-network/payload-builder";
134
152
  import { ModuleErrorSchema } from "@xyo-network/payload-model";
135
153
  import { SchemaCache as SchemaCache2 } from "@xyo-network/schema-cache";
136
154
  import { useState as useState2 } from "react";
137
- var useGetSchemaPayload = /* @__PURE__ */ __name((schema) => {
155
+ var useGetSchemaPayload = (schema) => {
138
156
  const [notFound, setNotFound] = useState2(false);
139
157
  const [xyoError, setXyoError] = useState2();
140
158
  const [schemaCacheEntry, setSchemaCacheEntry] = useState2();
141
159
  const [schemaLocal, setSchemaLocal] = useState2();
142
- useAsyncEffect2(async (mounted) => {
143
- const firstRequest = !notFound && !schemaCacheEntry && !xyoError;
144
- const schemaChanged = schema !== schemaLocal;
145
- if (schema && firstRequest || schema && schemaChanged) {
146
- try {
147
- const schemaCacheEntry2 = await SchemaCache2.instance.get(schema);
148
- if (mounted()) {
149
- setSchemaCacheEntry(schemaCacheEntry2);
150
- setNotFound(schemaCacheEntry2 === null || schemaCacheEntry2 === void 0);
151
- }
152
- } catch (e) {
153
- const error = e;
154
- console.error(e);
155
- if (mounted()) {
156
- setXyoError({
157
- message: error.message,
158
- schema: ModuleErrorSchema,
159
- $sources: []
160
- });
160
+ useAsyncEffect2(
161
+ async (mounted) => {
162
+ const firstRequest = !notFound && !schemaCacheEntry && !xyoError;
163
+ const schemaChanged = schema !== schemaLocal;
164
+ if (schema && firstRequest || schema && schemaChanged) {
165
+ try {
166
+ const schemaCacheEntry2 = await SchemaCache2.instance.get(schema);
167
+ if (mounted()) {
168
+ setSchemaCacheEntry(schemaCacheEntry2);
169
+ setNotFound(schemaCacheEntry2 === null || schemaCacheEntry2 === void 0);
170
+ }
171
+ } catch (e) {
172
+ const error = e;
173
+ console.error(e);
174
+ if (mounted()) {
175
+ setXyoError({
176
+ message: error.message,
177
+ schema: ModuleErrorSchema,
178
+ $sources: []
179
+ });
180
+ }
161
181
  }
162
182
  }
163
- }
164
- if (schemaChanged) {
165
- setSchemaLocal(schema);
166
- }
167
- }, [
168
- xyoError,
169
- notFound,
170
- schema,
171
- schemaLocal,
172
- schemaCacheEntry
173
- ]);
183
+ if (schemaChanged) {
184
+ setSchemaLocal(schema);
185
+ }
186
+ },
187
+ [xyoError, notFound, schema, schemaLocal, schemaCacheEntry]
188
+ );
174
189
  return {
175
190
  notFound,
176
191
  schemaHuri: schemaCacheEntry?.huri,
177
192
  schemaPayload: schemaCacheEntry ? new PayloadBuilder(schemaCacheEntry?.payload).fields(schemaCacheEntry.payload).build() : schemaCacheEntry,
178
193
  xyoError
179
194
  };
180
- }, "useGetSchemaPayload");
195
+ };
181
196
 
182
197
  // src/hooks/useSchemaDefinitions.tsx
183
198
  import { useAsyncEffect as useAsyncEffect3 } from "@xylabs/react-async-effect";
184
199
  import { SchemaCache as SchemaCache3 } from "@xyo-network/schema-cache";
185
200
  import { useState as useState3 } from "react";
186
- var useSchemaDefinitions = /* @__PURE__ */ __name((schemaList) => {
201
+ var useSchemaDefinitions = (schemaList) => {
187
202
  const [schemaPayloads, setSchemaPayloads] = useState3();
188
- useAsyncEffect3(async (mounted) => {
189
- if (schemaList) {
190
- const promiseResults = await Promise.allSettled(schemaList?.map(({ name }) => SchemaCache3.instance.get(name)));
191
- if (mounted()) {
192
- setSchemaPayloads(promiseResults.map((result) => result.status === "fulfilled" ? result.value?.payload : void 0).filter((item) => item !== void 0 && item !== null));
203
+ useAsyncEffect3(
204
+ async (mounted) => {
205
+ if (schemaList) {
206
+ const promiseResults = await Promise.allSettled(schemaList?.map(({ name }) => SchemaCache3.instance.get(name)));
207
+ if (mounted()) {
208
+ setSchemaPayloads(
209
+ promiseResults.map((result) => result.status === "fulfilled" ? result.value?.payload : void 0).filter((item) => item !== void 0 && item !== null)
210
+ );
211
+ }
193
212
  }
194
- }
195
- }, [
196
- schemaList
197
- ]);
213
+ },
214
+ [schemaList]
215
+ );
198
216
  return schemaPayloads;
199
- }, "useSchemaDefinitions");
217
+ };
200
218
 
201
219
  // src/hooks/useSchemaList.tsx
202
220
  import { usePromise } from "@xylabs/react-promise";
203
221
  import { SchemaListQuerySchema } from "@xyo-network/diviner-schema-list-model";
204
222
  import { useWeakDivinerFromNode } from "@xyo-network/react-diviner";
205
223
  import { useMemo } from "react";
206
- var useSchemaList = /* @__PURE__ */ __name((address, nameOrAddress = "SchemaListDiviner") => {
224
+ var useSchemaList = (address, nameOrAddress = "SchemaListDiviner") => {
207
225
  const [diviner, divinerError] = useWeakDivinerFromNode(nameOrAddress);
208
- const query = useMemo(() => address ? [
209
- {
210
- address,
211
- schema: SchemaListQuerySchema
212
- }
213
- ] : void 0, [
214
- address
215
- ]);
216
- const [schemaList, error] = usePromise(async () => {
217
- const divinerInstance = diviner?.deref();
218
- if (divinerInstance) {
219
- const response = await divinerInstance.divine(query);
220
- return response.at(0);
221
- }
222
- }, [
223
- diviner,
224
- divinerError,
225
- query
226
- ]);
227
- return [
228
- schemaList,
229
- error
230
- ];
231
- }, "useSchemaList");
226
+ const query = useMemo(
227
+ () => address ? [
228
+ {
229
+ address,
230
+ schema: SchemaListQuerySchema
231
+ }
232
+ ] : void 0,
233
+ [address]
234
+ );
235
+ const [schemaList, error] = usePromise(
236
+ async () => {
237
+ const divinerInstance = diviner?.deref();
238
+ if (divinerInstance) {
239
+ const response = await divinerInstance.divine(query);
240
+ return response.at(0);
241
+ }
242
+ },
243
+ [diviner, divinerError, query]
244
+ );
245
+ return [schemaList, error];
246
+ };
232
247
 
233
248
  // src/hooks/useSchemaStats.tsx
234
249
  import { useAsyncEffect as useAsyncEffect4 } from "@xylabs/react-async-effect";
235
250
  import { isDefined } from "@xylabs/sdk-js";
236
- import { SchemaStatsDivinerSchema, SchemaStatsQuerySchema } from "@xyo-network/diviner-schema-stats-model";
251
+ import {
252
+ SchemaStatsDivinerSchema,
253
+ SchemaStatsQuerySchema
254
+ } from "@xyo-network/diviner-schema-stats-model";
237
255
  import { TYPES } from "@xyo-network/node-core-types";
238
256
  import { isPayloadOfSchemaType } from "@xyo-network/payload-model";
239
257
  import { useWeakDivinerFromNode as useWeakDivinerFromNode2 } from "@xyo-network/react-diviner";
240
258
  import { useState as useState4 } from "react";
241
- var useSchemaStats = /* @__PURE__ */ __name((statsAddress, nameOrAddress = TYPES.SchemaStatsDiviner) => {
259
+ var useSchemaStats = (statsAddress, nameOrAddress = TYPES.SchemaStatsDiviner) => {
242
260
  const [refresh, setRefresh] = useState4(1);
243
261
  const [diviner, divinerError] = useWeakDivinerFromNode2(nameOrAddress);
244
262
  const [error, setError] = useState4();
245
- const refreshHistory = /* @__PURE__ */ __name(() => setRefresh((previous) => previous + 1), "refreshHistory");
263
+ const refreshHistory = () => setRefresh((previous) => previous + 1);
246
264
  const [schemaList, setSchemaList] = useState4();
247
- useAsyncEffect4(async (mounted) => {
248
- const instance = diviner?.deref();
249
- if (isDefined(instance) && isDefined(statsAddress)) {
250
- if (divinerError) {
251
- if (mounted()) {
252
- setError(divinerError);
253
- setSchemaList(void 0);
254
- }
255
- } else {
256
- try {
257
- const query = {
258
- address: statsAddress,
259
- schema: SchemaStatsQuerySchema
260
- };
261
- const schemas = (await instance.divine([
262
- query
263
- ])).filter(isPayloadOfSchemaType(SchemaStatsDivinerSchema));
265
+ useAsyncEffect4(
266
+ async (mounted) => {
267
+ const instance = diviner?.deref();
268
+ if (isDefined(instance) && isDefined(statsAddress)) {
269
+ if (divinerError) {
264
270
  if (mounted()) {
265
- setSchemaList(schemas);
266
- setError(void 0);
271
+ setError(divinerError);
272
+ setSchemaList(void 0);
273
+ }
274
+ } else {
275
+ try {
276
+ const query = {
277
+ address: statsAddress,
278
+ schema: SchemaStatsQuerySchema
279
+ };
280
+ const schemas = (await instance.divine([query])).filter(isPayloadOfSchemaType(SchemaStatsDivinerSchema));
281
+ if (mounted()) {
282
+ setSchemaList(schemas);
283
+ setError(void 0);
284
+ }
285
+ } catch (ex) {
286
+ setError(ex);
287
+ setSchemaList(void 0);
267
288
  }
268
- } catch (ex) {
269
- setError(ex);
270
- setSchemaList(void 0);
271
289
  }
272
290
  }
273
- }
274
- }, [
275
- diviner,
276
- refresh,
277
- divinerError,
278
- statsAddress
279
- ]);
280
- return [
281
- schemaList,
282
- error,
283
- refreshHistory
284
- ];
285
- }, "useSchemaStats");
291
+ },
292
+ [diviner, refresh, divinerError, statsAddress]
293
+ );
294
+ return [schemaList, error, refreshHistory];
295
+ };
286
296
 
287
297
  // src/contexts/Schema/Provider/Memory.tsx
288
- var SchemaMemoryProvider = /* @__PURE__ */ __name(({ defaultSchema, knownSchemaList, ...props }) => {
298
+ import { jsx as jsx2 } from "react/jsx-runtime";
299
+ var SchemaMemoryProvider = ({
300
+ defaultSchema,
301
+ knownSchemaList,
302
+ ...props
303
+ }) => {
289
304
  const [schema, setSchema] = useState5(defaultSchema);
290
305
  const [schemaList, setSchemaList] = useState5(knownSchemaList);
291
306
  const [fetchedSchemaStats] = useSchemaStats();
292
307
  useEffect(() => {
293
308
  if (fetchedSchemaStats) {
294
- const schemaList2 = fetchedSchemaStats.map(({ name }) => name).filter(exists);
295
- setSchemaList(schemaList2);
309
+ const newSchemaList = fetchedSchemaStats.map(({ name }) => name).filter(exists);
310
+ setSchemaList(newSchemaList);
296
311
  }
297
- }, [
298
- fetchedSchemaStats
299
- ]);
312
+ }, [fetchedSchemaStats]);
300
313
  const value = useMemo2(() => ({
301
314
  provided: true,
302
315
  schema,
303
316
  schemaList: knownSchemaList ?? schemaList,
304
317
  setSchema,
305
318
  setSchemaList
306
- }), [
307
- schema,
308
- schemaList,
309
- knownSchemaList
310
- ]);
311
- return /* @__PURE__ */ React2.createElement(SchemaContext, {
312
- value,
313
- ...props
314
- });
315
- }, "SchemaMemoryProvider");
319
+ }), [schema, schemaList, knownSchemaList]);
320
+ return /* @__PURE__ */ jsx2(SchemaContext, { value, ...props });
321
+ };
316
322
 
317
323
  // src/contexts/Schema/Provider/Route.tsx
318
- import React3, { useCallback, useEffect as useEffect2, useMemo as useMemo3 } from "react";
324
+ import {
325
+ useCallback,
326
+ useEffect as useEffect2,
327
+ useMemo as useMemo3
328
+ } from "react";
319
329
  import { useSearchParams } from "react-router-dom";
320
330
 
321
331
  // src/contexts/Schema/use.ts
322
332
  import { useContextEx } from "@xylabs/react-shared";
323
- var useSchema = /* @__PURE__ */ __name((required = false) => {
333
+ var useSchema = (required = false) => {
324
334
  return useContextEx(SchemaContext, "Schema", required);
325
- }, "useSchema");
335
+ };
326
336
 
327
337
  // src/contexts/Schema/Provider/Route.tsx
328
- var SchemaRouteProviderInner = /* @__PURE__ */ __name(({ children }) => {
329
- const { schema, setSchema, schemaList } = useSchema();
338
+ import { jsx as jsx3 } from "react/jsx-runtime";
339
+ var SchemaRouteProviderInner = ({ children }) => {
340
+ const {
341
+ schema,
342
+ setSchema,
343
+ schemaList
344
+ } = useSchema();
330
345
  const [params, setParams] = useSearchParams();
331
346
  const routeSchema = params.get("schema");
332
- const setSchemaParam = useCallback((schema2) => {
333
- if (schema2) {
334
- params.set("schema", schema2);
335
- setParams(params, {
336
- replace: true
337
- });
347
+ const setSchemaParam = useCallback(
348
+ (schema2) => {
349
+ if (schema2) {
350
+ params.set("schema", schema2);
351
+ setParams(params, { replace: true });
352
+ setSchema?.(schema2);
353
+ } else {
354
+ params.delete("network");
355
+ }
356
+ },
357
+ [params, setParams, setSchema]
358
+ );
359
+ const setSchemaLocal = useCallback(
360
+ (schema2) => {
361
+ setSchemaParam(schema2);
338
362
  setSchema?.(schema2);
339
- } else {
340
- params.delete("network");
341
- }
342
- }, [
343
- params,
344
- setParams,
345
- setSchema
346
- ]);
347
- const setSchemaLocal = useCallback((schema2) => {
348
- setSchemaParam(schema2);
349
- setSchema?.(schema2);
350
- }, [
351
- setSchemaParam,
352
- setSchema
353
- ]);
363
+ },
364
+ [setSchemaParam, setSchema]
365
+ );
354
366
  useEffect2(() => {
355
367
  if (routeSchema !== schema) {
356
368
  if (routeSchema === void 0 && schema !== void 0) {
@@ -359,61 +371,60 @@ var SchemaRouteProviderInner = /* @__PURE__ */ __name(({ children }) => {
359
371
  setSchema?.(routeSchema);
360
372
  }
361
373
  }
362
- }, [
363
- routeSchema,
364
- schema,
365
- setSchemaParam,
366
- setSchema,
367
- setSchemaLocal
368
- ]);
374
+ }, [routeSchema, schema, setSchemaParam, setSchema, setSchemaLocal]);
369
375
  const value = useMemo3(() => ({
370
376
  provided: true,
371
377
  schema,
372
378
  schemaList,
373
379
  setSchema: setSchemaLocal
374
- }), [
375
- schema,
376
- schemaList,
377
- setSchemaLocal
378
- ]);
379
- return /* @__PURE__ */ React3.createElement(SchemaContext, {
380
- value
381
- }, children);
382
- }, "SchemaRouteProviderInner");
383
- var SchemaRouteProvider = /* @__PURE__ */ __name(({ knownSchemaList, defaultSchema, ...props }) => {
384
- return /* @__PURE__ */ React3.createElement(SchemaMemoryProvider, {
385
- knownSchemaList,
386
- defaultSchema
387
- }, /* @__PURE__ */ React3.createElement(SchemaRouteProviderInner, props));
388
- }, "SchemaRouteProvider");
380
+ }), [schema, schemaList, setSchemaLocal]);
381
+ return /* @__PURE__ */ jsx3(SchemaContext, { value, children });
382
+ };
383
+ var SchemaRouteProvider = ({
384
+ knownSchemaList,
385
+ defaultSchema,
386
+ ...props
387
+ }) => {
388
+ return /* @__PURE__ */ jsx3(SchemaMemoryProvider, { knownSchemaList, defaultSchema, children: /* @__PURE__ */ jsx3(SchemaRouteProviderInner, { ...props }) });
389
+ };
389
390
 
390
391
  // src/components/SelectEx/SchemaSelectEx.tsx
391
- var SchemaSelectEx = /* @__PURE__ */ __name(({ onChange, variant = "outlined", ...props }) => {
392
- const { schema, setSchema, schemaList } = useSchema(false);
393
- return /* @__PURE__ */ React4.createElement(SelectEx, {
394
- variant,
395
- size: "small",
396
- value: schema ?? "none",
397
- onChange: /* @__PURE__ */ __name((event, child) => {
398
- if (event.target.value !== schema) {
399
- onChange?.(event, child);
400
- setSchema?.(event.target.value);
401
- }
402
- }, "onChange"),
403
- renderValue: /* @__PURE__ */ __name((value) => {
404
- return /* @__PURE__ */ React4.createElement(Typography, null, value === "none" ? "- None -" : value);
405
- }, "renderValue"),
406
- ...props
407
- }, schemaList?.map((schema2) => {
408
- return /* @__PURE__ */ React4.createElement(MenuItem, {
409
- key: schemaList.indexOf(schema2),
410
- value: schema2
411
- }, schema2);
412
- }), /* @__PURE__ */ React4.createElement(MenuItem, {
413
- key: "none",
414
- value: "none"
415
- }, "- None -"));
416
- }, "SchemaSelectEx");
392
+ import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
393
+ var SchemaSelectEx = ({
394
+ onChange,
395
+ variant = "outlined",
396
+ ...props
397
+ }) => {
398
+ const {
399
+ schema,
400
+ setSchema,
401
+ schemaList
402
+ } = useSchema(false);
403
+ return /* @__PURE__ */ jsxs2(
404
+ SelectEx,
405
+ {
406
+ variant,
407
+ size: "small",
408
+ value: schema ?? "none",
409
+ onChange: (event, child) => {
410
+ if (event.target.value !== schema) {
411
+ onChange?.(event, child);
412
+ setSchema?.(event.target.value);
413
+ }
414
+ },
415
+ renderValue: (value) => {
416
+ return /* @__PURE__ */ jsx4(Typography, { children: value === "none" ? "- None -" : value });
417
+ },
418
+ ...props,
419
+ children: [
420
+ schemaList?.map((schema2) => {
421
+ return /* @__PURE__ */ jsx4(MenuItem, { value: schema2, children: schema2 }, schemaList.indexOf(schema2));
422
+ }),
423
+ /* @__PURE__ */ jsx4(MenuItem, { value: "none", children: "- None -" }, "none")
424
+ ]
425
+ }
426
+ );
427
+ };
417
428
  export {
418
429
  SchemaContext,
419
430
  SchemaMemoryProvider,