@satoshibits/react-json-schema-builder 1.1.3 → 1.1.5
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/index.cjs.js +1 -1
- package/dist/index.cjs10.js +1 -1
- package/dist/index.cjs10.js.map +1 -1
- package/dist/index.cjs11.js +1 -1
- package/dist/index.cjs11.js.map +1 -1
- package/dist/index.cjs12.js +1 -1
- package/dist/index.cjs12.js.map +1 -1
- package/dist/index.cjs13.js +1 -1
- package/dist/index.cjs13.js.map +1 -1
- package/dist/index.cjs14.js +1 -1
- package/dist/index.cjs14.js.map +1 -1
- package/dist/index.cjs15.js +6 -1
- package/dist/index.cjs15.js.map +1 -1
- package/dist/index.cjs16.js +1 -1
- package/dist/index.cjs16.js.map +1 -1
- package/dist/index.cjs17.js +1 -1
- package/dist/index.cjs17.js.map +1 -1
- package/dist/index.cjs18.js +1 -1
- package/dist/index.cjs18.js.map +1 -1
- package/dist/index.cjs19.js +1 -1
- package/dist/index.cjs19.js.map +1 -1
- package/dist/index.cjs2.js +1 -1
- package/dist/index.cjs2.js.map +1 -1
- package/dist/index.cjs20.js +1 -1
- package/dist/index.cjs20.js.map +1 -1
- package/dist/index.cjs21.js +1 -1
- package/dist/index.cjs21.js.map +1 -1
- package/dist/index.cjs22.js +1 -1
- package/dist/index.cjs22.js.map +1 -1
- package/dist/index.cjs23.js +1 -6
- package/dist/index.cjs23.js.map +1 -1
- package/dist/index.cjs24.js +1 -6
- package/dist/index.cjs24.js.map +1 -1
- package/dist/index.cjs25.js +1 -6
- package/dist/index.cjs25.js.map +1 -1
- package/dist/index.cjs26.js +1 -1
- package/dist/index.cjs26.js.map +1 -1
- package/dist/index.cjs27.js +1 -1
- package/dist/index.cjs27.js.map +1 -1
- package/dist/index.cjs28.js +6 -1
- package/dist/index.cjs28.js.map +1 -1
- package/dist/index.cjs29.js +6 -1
- package/dist/index.cjs29.js.map +1 -1
- package/dist/index.cjs3.js +1 -1
- package/dist/index.cjs3.js.map +1 -1
- package/dist/index.cjs30.js +1 -1
- package/dist/index.cjs30.js.map +1 -1
- package/dist/index.cjs31.js +1 -1
- package/dist/index.cjs34.js +1 -1
- package/dist/index.cjs36.js +1 -1
- package/dist/index.cjs37.js +1 -1
- package/dist/index.cjs38.js +1 -1
- package/dist/index.cjs39.js +1 -1
- package/dist/index.cjs4.js +1 -1
- package/dist/index.cjs4.js.map +1 -1
- package/dist/index.cjs41.js +1 -1
- package/dist/index.cjs42.js +1 -1
- package/dist/index.cjs42.js.map +1 -1
- package/dist/index.cjs43.js +1 -1
- package/dist/index.cjs47.js +1 -1
- package/dist/index.cjs5.js +1 -1
- package/dist/index.cjs5.js.map +1 -1
- package/dist/index.cjs55.js +1 -5
- package/dist/index.cjs55.js.map +1 -1
- package/dist/index.cjs56.js +1 -1
- package/dist/index.cjs56.js.map +1 -1
- package/dist/index.cjs57.js +1 -1
- package/dist/index.cjs57.js.map +1 -1
- package/dist/index.cjs58.js +1 -1
- package/dist/index.cjs58.js.map +1 -1
- package/dist/index.cjs59.js +1 -1
- package/dist/index.cjs59.js.map +1 -1
- package/dist/index.cjs6.js +1 -1
- package/dist/index.cjs6.js.map +1 -1
- package/dist/index.cjs60.js +1 -1
- package/dist/index.cjs60.js.map +1 -1
- package/dist/index.cjs61.js +1 -1
- package/dist/index.cjs61.js.map +1 -1
- package/dist/index.cjs62.js +5 -1
- package/dist/index.cjs62.js.map +1 -1
- package/dist/index.cjs63.js +1 -1
- package/dist/index.cjs63.js.map +1 -1
- package/dist/index.cjs65.js +1 -1
- package/dist/index.cjs67.js +1 -1
- package/dist/index.cjs69.js +1 -1
- package/dist/index.cjs7.js +1 -1
- package/dist/index.cjs7.js.map +1 -1
- package/dist/index.cjs71.js +1 -1
- package/dist/index.cjs72.js +1 -1
- package/dist/index.cjs75.js +1 -1
- package/dist/index.cjs78.js +1 -1
- package/dist/index.cjs8.js +1 -1
- package/dist/index.cjs8.js.map +1 -1
- package/dist/index.cjs81.js +1 -1
- package/dist/index.cjs9.js +1 -1
- package/dist/index.cjs9.js.map +1 -1
- package/dist/index.d.mts +5 -4
- package/dist/index.d.mts.map +1 -1
- package/dist/index.es.js +18 -28
- package/dist/index.es10.js +22 -22
- package/dist/index.es10.js.map +1 -1
- package/dist/index.es11.js +14 -42
- package/dist/index.es11.js.map +1 -1
- package/dist/index.es12.js +5 -65
- package/dist/index.es12.js.map +1 -1
- package/dist/index.es13.js +43 -24
- package/dist/index.es13.js.map +1 -1
- package/dist/index.es14.js +21 -126
- package/dist/index.es14.js.map +1 -1
- package/dist/index.es15.js +13 -20
- package/dist/index.es15.js.map +1 -1
- package/dist/index.es16.js +129 -130
- package/dist/index.es16.js.map +1 -1
- package/dist/index.es17.js +3 -137
- package/dist/index.es17.js.map +1 -1
- package/dist/index.es18.js +20 -61
- package/dist/index.es18.js.map +1 -1
- package/dist/index.es19.js +65 -10
- package/dist/index.es19.js.map +1 -1
- package/dist/index.es2.js +156 -113
- package/dist/index.es2.js.map +1 -1
- package/dist/index.es20.js +134 -22
- package/dist/index.es20.js.map +1 -1
- package/dist/index.es21.js +131 -421
- package/dist/index.es21.js.map +1 -1
- package/dist/index.es22.js +63 -5
- package/dist/index.es22.js.map +1 -1
- package/dist/index.es23.js +11 -13
- package/dist/index.es23.js.map +1 -1
- package/dist/index.es24.js +23 -16
- package/dist/index.es24.js.map +1 -1
- package/dist/index.es25.js +428 -13
- package/dist/index.es25.js.map +1 -1
- package/dist/index.es26.js +7 -13
- package/dist/index.es26.js.map +1 -1
- package/dist/index.es27.js +9 -3
- package/dist/index.es27.js.map +1 -1
- package/dist/index.es28.js +13 -19
- package/dist/index.es28.js.map +1 -1
- package/dist/index.es29.js +19 -23
- package/dist/index.es29.js.map +1 -1
- package/dist/index.es3.js +129 -340
- package/dist/index.es3.js.map +1 -1
- package/dist/index.es30.js +4 -7
- package/dist/index.es30.js.map +1 -1
- package/dist/index.es31.js +1 -1
- package/dist/index.es34.js +1 -1
- package/dist/index.es36.js +7 -7
- package/dist/index.es37.js +3 -3
- package/dist/index.es38.js +3 -3
- package/dist/index.es39.js +2 -2
- package/dist/index.es4.js +92 -70
- package/dist/index.es4.js.map +1 -1
- package/dist/index.es41.js +2 -2
- package/dist/index.es42.js +4 -4
- package/dist/index.es43.js +6 -6
- package/dist/index.es47.js +4 -4
- package/dist/index.es5.js +225 -79
- package/dist/index.es5.js.map +1 -1
- package/dist/index.es55.js +30 -252
- package/dist/index.es55.js.map +1 -1
- package/dist/index.es56.js +26 -21
- package/dist/index.es56.js.map +1 -1
- package/dist/index.es57.js +6 -32
- package/dist/index.es57.js.map +1 -1
- package/dist/index.es58.js +62 -23
- package/dist/index.es58.js.map +1 -1
- package/dist/index.es59.js +29 -6
- package/dist/index.es59.js.map +1 -1
- package/dist/index.es6.js +117 -57
- package/dist/index.es6.js.map +1 -1
- package/dist/index.es60.js +4 -64
- package/dist/index.es60.js.map +1 -1
- package/dist/index.es61.js +24 -29
- package/dist/index.es61.js.map +1 -1
- package/dist/index.es62.js +254 -5
- package/dist/index.es62.js.map +1 -1
- package/dist/index.es63.js +21 -24
- package/dist/index.es63.js.map +1 -1
- package/dist/index.es65.js +2 -2
- package/dist/index.es67.js +3 -3
- package/dist/index.es69.js +2 -2
- package/dist/index.es7.js +345 -48
- package/dist/index.es7.js.map +1 -1
- package/dist/index.es71.js +4 -4
- package/dist/index.es72.js +1 -1
- package/dist/index.es75.js +1 -1
- package/dist/index.es78.js +1 -1
- package/dist/index.es8.js +73 -163
- package/dist/index.es8.js.map +1 -1
- package/dist/index.es81.js +1 -1
- package/dist/index.es9.js +18 -3
- package/dist/index.es9.js.map +1 -1
- package/dist/packages/builder/add-dialog.d.ts +5 -5
- package/dist/packages/builder/context.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.es59.js
CHANGED
|
@@ -1,10 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import * as l from "react";
|
|
2
|
+
import { useCallbackRef as f } from "./index.es73.js";
|
|
3
|
+
function R({
|
|
4
|
+
prop: t,
|
|
5
|
+
defaultProp: r,
|
|
6
|
+
onChange: s = () => {
|
|
7
|
+
}
|
|
8
|
+
}) {
|
|
9
|
+
const [e, n] = v({ defaultProp: r, onChange: s }), o = t !== void 0, i = o ? t : e, u = f(s), d = l.useCallback(
|
|
10
|
+
(c) => {
|
|
11
|
+
if (o) {
|
|
12
|
+
const a = typeof c == "function" ? c(t) : c;
|
|
13
|
+
a !== t && u(a);
|
|
14
|
+
} else
|
|
15
|
+
n(c);
|
|
16
|
+
},
|
|
17
|
+
[o, t, n, u]
|
|
18
|
+
);
|
|
19
|
+
return [i, d];
|
|
20
|
+
}
|
|
21
|
+
function v({
|
|
22
|
+
defaultProp: t,
|
|
23
|
+
onChange: r
|
|
24
|
+
}) {
|
|
25
|
+
const s = l.useState(t), [e] = s, n = l.useRef(e), o = f(r);
|
|
26
|
+
return l.useEffect(() => {
|
|
27
|
+
n.current !== e && (o(e), n.current = e);
|
|
28
|
+
}, [e, n, o]), s;
|
|
6
29
|
}
|
|
7
30
|
export {
|
|
8
|
-
|
|
31
|
+
R as useControllableState
|
|
9
32
|
};
|
|
10
33
|
//# sourceMappingURL=index.es59.js.map
|
package/dist/index.es59.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.es59.js","sources":["../../../node_modules/.pnpm/@radix-ui+
|
|
1
|
+
{"version":3,"file":"index.es59.js","sources":["../../../node_modules/.pnpm/@radix-ui+react-use-controllable-state@1.1.0_@types+react@18.3.18_react@18.3.1/node_modules/@radix-ui/react-use-controllable-state/dist/index.mjs"],"sourcesContent":["// packages/react/use-controllable-state/src/useControllableState.tsx\nimport * as React from \"react\";\nimport { useCallbackRef } from \"@radix-ui/react-use-callback-ref\";\nfunction useControllableState({\n prop,\n defaultProp,\n onChange = () => {\n }\n}) {\n const [uncontrolledProp, setUncontrolledProp] = useUncontrolledState({ defaultProp, onChange });\n const isControlled = prop !== void 0;\n const value = isControlled ? prop : uncontrolledProp;\n const handleChange = useCallbackRef(onChange);\n const setValue = React.useCallback(\n (nextValue) => {\n if (isControlled) {\n const setter = nextValue;\n const value2 = typeof nextValue === \"function\" ? setter(prop) : nextValue;\n if (value2 !== prop) handleChange(value2);\n } else {\n setUncontrolledProp(nextValue);\n }\n },\n [isControlled, prop, setUncontrolledProp, handleChange]\n );\n return [value, setValue];\n}\nfunction useUncontrolledState({\n defaultProp,\n onChange\n}) {\n const uncontrolledState = React.useState(defaultProp);\n const [value] = uncontrolledState;\n const prevValueRef = React.useRef(value);\n const handleChange = useCallbackRef(onChange);\n React.useEffect(() => {\n if (prevValueRef.current !== value) {\n handleChange(value);\n prevValueRef.current = value;\n }\n }, [value, prevValueRef, handleChange]);\n return uncontrolledState;\n}\nexport {\n useControllableState\n};\n//# sourceMappingURL=index.mjs.map\n"],"names":["useControllableState","prop","defaultProp","onChange","uncontrolledProp","setUncontrolledProp","useUncontrolledState","isControlled","value","handleChange","useCallbackRef","setValue","React","nextValue","value2","uncontrolledState","prevValueRef"],"mappings":";;AAGA,SAASA,EAAqB;AAAA,EAC5B,MAAAC;AAAA,EACA,aAAAC;AAAA,EACA,UAAAC,IAAW,MAAM;AAAA,EACnB;AACA,GAAG;AACD,QAAM,CAACC,GAAkBC,CAAmB,IAAIC,EAAqB,EAAE,aAAAJ,GAAa,UAAAC,GAAU,GACxFI,IAAeN,MAAS,QACxBO,IAAQD,IAAeN,IAAOG,GAC9BK,IAAeC,EAAeP,CAAQ,GACtCQ,IAAWC,EAAM;AAAA,IACrB,CAACC,MAAc;AACb,UAAIN,GAAc;AAEhB,cAAMO,IAAS,OAAOD,KAAc,aADrBA,EACyCZ,CAAI,IAAIY;AAChE,QAAIC,MAAWb,KAAMQ,EAAaK,CAAM;AAAA,MAChD;AACQ,QAAAT,EAAoBQ,CAAS;AAAA,IAEhC;AAAA,IACD,CAACN,GAAcN,GAAMI,GAAqBI,CAAY;AAAA,EACvD;AACD,SAAO,CAACD,GAAOG,CAAQ;AACzB;AACA,SAASL,EAAqB;AAAA,EAC5B,aAAAJ;AAAA,EACA,UAAAC;AACF,GAAG;AACD,QAAMY,IAAoBH,EAAM,SAASV,CAAW,GAC9C,CAACM,CAAK,IAAIO,GACVC,IAAeJ,EAAM,OAAOJ,CAAK,GACjCC,IAAeC,EAAeP,CAAQ;AAC5C,SAAAS,EAAM,UAAU,MAAM;AACpB,IAAII,EAAa,YAAYR,MAC3BC,EAAaD,CAAK,GAClBQ,EAAa,UAAUR;AAAA,EAE1B,GAAE,CAACA,GAAOQ,GAAcP,CAAY,CAAC,GAC/BM;AACT;","x_google_ignoreList":[0]}
|
package/dist/index.es6.js
CHANGED
|
@@ -1,61 +1,121 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
})
|
|
17
|
-
const
|
|
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
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
1
|
+
import { jsx as v } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as x, useState as y, useContext as C } from "react";
|
|
3
|
+
import { a as O } from "./index.es17.js";
|
|
4
|
+
import { a as m } from "./index.es18.js";
|
|
5
|
+
const q = x(void 0), R = {
|
|
6
|
+
$schema: "http://json-schema.org/draft-07/schema#",
|
|
7
|
+
type: "object",
|
|
8
|
+
title: "title",
|
|
9
|
+
description: "",
|
|
10
|
+
properties: {},
|
|
11
|
+
required: []
|
|
12
|
+
};
|
|
13
|
+
function A({
|
|
14
|
+
children: c,
|
|
15
|
+
initialSchema: f
|
|
16
|
+
}) {
|
|
17
|
+
const [p, n] = y(
|
|
18
|
+
f ?? R
|
|
19
|
+
), [u, l] = y([]);
|
|
20
|
+
return /* @__PURE__ */ v(q.Provider, { value: { schema: p, setSchema: n, path: u, setPath: l }, children: c });
|
|
21
|
+
}
|
|
22
|
+
function K({
|
|
23
|
+
onSchemaChange: c
|
|
24
|
+
} = {}) {
|
|
25
|
+
const f = C(q);
|
|
26
|
+
if (f === void 0)
|
|
27
|
+
throw new Error("useSchema must be used within a SchemaProvider");
|
|
28
|
+
const { path: p, schema: n, setSchema: u } = f, l = (t, e) => {
|
|
29
|
+
let r = t, i = null, o = null;
|
|
30
|
+
for (const s of e)
|
|
31
|
+
r.type === "array" && r.items && !Array.isArray(r.items) && typeof r.items == "object" && r.items.type === "object" && typeof r.items.properties?.[s] == "object" ? (o = r.items, i = r.items.properties[s], r = r.items) : r.type === "object" && r.properties && !Array.isArray(r.properties) && typeof r.properties[s] == "object" && (o = r, i = r.properties[s], r = r.properties[s]);
|
|
32
|
+
return { propertySchema: i, parentSchema: o };
|
|
33
|
+
}, a = (t) => {
|
|
34
|
+
const { propertySchema: e } = l(
|
|
35
|
+
t ?? n,
|
|
36
|
+
p
|
|
37
|
+
);
|
|
38
|
+
return e ? e.type === "array" ? e.items : e : t ?? n;
|
|
39
|
+
}, b = () => {
|
|
40
|
+
const { propertySchema: t } = l(n, p);
|
|
41
|
+
return t;
|
|
42
|
+
}, j = (t, e) => {
|
|
43
|
+
const r = m(n), i = a(r);
|
|
44
|
+
if (i.properties?.[t]) {
|
|
45
|
+
const o = Object.entries(i.properties).map(
|
|
46
|
+
([s, g]) => [s === t ? e : s, g]
|
|
47
|
+
);
|
|
48
|
+
i.properties = Object.fromEntries(
|
|
49
|
+
o
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
i.required?.includes(t) && (i.required = i.required.map(
|
|
53
|
+
(o) => o === t ? e : o
|
|
54
|
+
)), u(r), c?.(r);
|
|
55
|
+
}, P = (t, e) => {
|
|
56
|
+
const r = m(n), i = a(r);
|
|
57
|
+
typeof e == "object" && "isRequired" in e && (i.type === "object" && (i.required || (i.required = []), e.isRequired ? i.required.includes(t) || i.required.push(t) : i.required = i.required.filter((s) => s !== t)), delete e.isRequired);
|
|
58
|
+
let o = !1;
|
|
59
|
+
if (i.type === "object" && i.properties) {
|
|
60
|
+
const s = i.properties[t];
|
|
61
|
+
typeof s != "boolean" && s && typeof e != "boolean" && (e.type && e.type !== s.type ? e = {
|
|
62
|
+
title: s.title,
|
|
63
|
+
description: s.description,
|
|
64
|
+
default: s.default,
|
|
65
|
+
...e
|
|
66
|
+
} : e.enum ? (delete e.type, delete e.items, delete e.properties, e = {
|
|
67
|
+
title: s.title,
|
|
68
|
+
description: s.description,
|
|
69
|
+
...e
|
|
70
|
+
}) : e = { ...s, ...e }, i.properties[t] = e), o = !0;
|
|
71
|
+
}
|
|
72
|
+
if (u(r), c?.(r), o)
|
|
73
|
+
return { status: "success", property: i.properties[t] };
|
|
74
|
+
}, d = (t, e, r) => {
|
|
75
|
+
const i = m(n), o = a(i);
|
|
76
|
+
return o.type !== "object" && (o.type = "object"), o.properties || (o.properties = {}), o.properties[t] ? {
|
|
77
|
+
status: "error",
|
|
78
|
+
code: "key-exists",
|
|
79
|
+
message: `Property with key ${t} already exists`
|
|
80
|
+
} : (e.enum && (delete e.type, delete e.items, delete e.properties), e = Object.fromEntries(
|
|
81
|
+
Object.entries(e).filter(([, s]) => s !== void 0)
|
|
82
|
+
), o.properties[t] = e, r && (o.required || (o.required = []), o.required.includes(t) || o.required.push(t)), u(i), c?.(i), {
|
|
83
|
+
status: "success",
|
|
84
|
+
property: o.properties[t]
|
|
85
|
+
});
|
|
86
|
+
}, S = (t) => {
|
|
87
|
+
const e = m(n), r = a(e);
|
|
88
|
+
r.type === "object" && r.required && (r.required = r.required.filter((i) => i !== t)), r.type === "object" && r.properties && delete r.properties[t], u(e), c?.(e);
|
|
89
|
+
}, w = (t) => {
|
|
90
|
+
const e = a().properties;
|
|
91
|
+
if (!e || O(e) || typeof e[t] == "boolean")
|
|
92
|
+
return;
|
|
93
|
+
const r = e[t], i = `${t}_copy`, o = m(r);
|
|
94
|
+
return d(i, o, h(t));
|
|
95
|
+
}, h = (t) => {
|
|
96
|
+
if (p.length) {
|
|
97
|
+
const { propertySchema: e } = l(n, p);
|
|
98
|
+
return e?.type === "array" && e.items && typeof e.items != "boolean" && !Array.isArray(e.items) && e.items?.type === "object" ? !!e.items?.required?.includes(t) : !!e?.required?.includes(t);
|
|
51
99
|
}
|
|
52
|
-
|
|
53
|
-
}
|
|
100
|
+
return !!n?.required?.includes(t);
|
|
101
|
+
};
|
|
102
|
+
return {
|
|
103
|
+
...f,
|
|
104
|
+
getCurrentSchema: a,
|
|
105
|
+
getCurrentProperty: b,
|
|
106
|
+
handlePropertyChange: P,
|
|
107
|
+
handleAddProperty: d,
|
|
108
|
+
handleKeyChange: j,
|
|
109
|
+
navigateToCorrectNesting: l,
|
|
110
|
+
handleDeleteProperty: S,
|
|
111
|
+
isPropertyRequired: h,
|
|
112
|
+
getValue: () => n,
|
|
113
|
+
handleDuplicateProperty: w
|
|
114
|
+
};
|
|
115
|
+
}
|
|
54
116
|
export {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
j as NumberMinimumRenderer,
|
|
59
|
-
w as NumberMultipleOfRenderer
|
|
117
|
+
q as SchemaContext,
|
|
118
|
+
A as SchemaProvider,
|
|
119
|
+
K as useSchema
|
|
60
120
|
};
|
|
61
121
|
//# sourceMappingURL=index.es6.js.map
|
package/dist/index.es6.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.es6.js","sources":["../src/packages/plugins/number.tsx"],"sourcesContent":["import { Input } from \"@/components/ui/input\";\nimport { InputErrorWrapper } from \"@/components/input-error\";\nimport { Label } from \"@/components/ui/label\";\nimport { cn } from \"@/lib/utils\";\nimport {\n BaseJSONSchemaPlugin,\n ConstraintRendererProps,\n useConstraints,\n} from \"@/packages/constraints/context\";\nimport { Button } from \"@/components/ui/button\";\nimport { X } from \"lucide-react\";\n\n// A generic number constraint renderer component to reduce code duplication\nconst NumberConstraintRenderer = ({\n constraintName,\n value,\n onConstraintChange,\n disabled,\n error,\n onRemoveConstraint,\n}: ConstraintRendererProps<number> & { disabled?: boolean }) => {\n const { getConstraintDefinition } = useConstraints();\n const constraintDef = getConstraintDefinition(constraintName);\n\n if (!constraintDef) {\n return null;\n }\n\n return (\n <InputErrorWrapper\n errorCode={error?.code}\n errorDescription={error?.message}\n showError={!!error}\n >\n <div>\n <Label className=\"mb-2\" htmlFor={constraintDef.name}>\n {constraintDef.name}\n </Label>\n <div className=\"flex items-center gap-2\">\n <Input\n id={constraintDef.name}\n type=\"number\"\n value={value}\n onChange={(e) => onConstraintChange(Number(e.target.value))}\n disabled={disabled}\n className={cn({ \"border-destructive\": error })}\n />\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"icon\"\n onClick={() => onRemoveConstraint()}\n >\n <X className=\"size-4\" />\n </Button>\n </div>\n {constraintDef.description && (\n <div className=\"mt-2 text-sm text-gray-500\">\n {constraintDef.description}\n </div>\n )}\n </div>\n </InputErrorWrapper>\n );\n};\n\n// Reuse the generic renderer for all number constraints\nexport const NumberMinimumRenderer = NumberConstraintRenderer;\nexport const NumberMaximumRenderer = NumberConstraintRenderer;\nexport const NumberExclusiveMinimumRenderer = NumberConstraintRenderer;\nexport const NumberExclusiveMaximumRenderer = NumberConstraintRenderer;\nexport const NumberMultipleOfRenderer = NumberConstraintRenderer;\n\nconst plugin: BaseJSONSchemaPlugin = {\n id: \"number-constraints\",\n hooks: {\n registerConstraints() {\n return [\n {\n name: \"minimum\",\n label: \"Minimum\",\n appliesTo: [\"number\", \"integer\"],\n schema: {\n type: \"number\",\n title: \"Minimum Constraint\",\n description: \"The minimum value for this constraint\",\n examples: [0, 1, 10],\n },\n description: \"Constrains a number or integer to a minimum value\",\n defaultValue: 0,\n },\n {\n name: \"maximum\",\n label: \"Maximum\",\n appliesTo: [\"number\", \"integer\"],\n schema: {\n type: \"number\",\n title: \"Maximum Constraint\",\n description: \"The maximum value for this constraint\",\n examples: [10, 100, 1000],\n },\n description: \"Constrains a number or integer to a maximum value\",\n defaultValue: 100,\n },\n {\n name: \"exclusiveMinimum\",\n label: \"Exclusive Minimum\",\n appliesTo: [\"number\", \"integer\"],\n schema: {\n type: \"number\",\n title: \"Exclusive Minimum Constraint\",\n description: \"The value must be strictly greater than this\",\n examples: [0, 1, 10],\n },\n description:\n \"Value must be strictly greater than (not equal to) this value\",\n defaultValue: 0,\n },\n {\n name: \"exclusiveMaximum\",\n label: \"Exclusive Maximum\",\n appliesTo: [\"number\", \"integer\"],\n schema: {\n type: \"number\",\n title: \"Exclusive Maximum Constraint\",\n description: \"The value must be strictly less than this\",\n examples: [10, 100, 1000],\n },\n description:\n \"Value must be strictly less than (not equal to) this value\",\n defaultValue: 100,\n },\n {\n name: \"multipleOf\",\n label: \"Multiple Of\",\n appliesTo: [\"number\", \"integer\"],\n schema: {\n type: \"number\",\n title: \"Multiple Of Constraint\",\n description: \"Value must be a multiple of this number\",\n examples: [2, 5, 10],\n exclusiveMinimum: 0,\n },\n description:\n \"Value must be divisible by this number (e.g., 5 for multiples of 5)\",\n defaultValue: 1,\n },\n ];\n },\n registerRenderers() {\n return {\n minimum: NumberMinimumRenderer,\n maximum: NumberMaximumRenderer,\n exclusiveMinimum: NumberExclusiveMinimumRenderer,\n exclusiveMaximum: NumberExclusiveMaximumRenderer,\n multipleOf: NumberMultipleOfRenderer,\n };\n },\n },\n};\n\nexport default plugin;\n"],"names":["NumberConstraintRenderer","constraintName","value","onConstraintChange","disabled","error","onRemoveConstraint","getConstraintDefinition","useConstraints","constraintDef","jsx","InputErrorWrapper","Label","jsxs","Input","e","cn","Button","X","NumberMinimumRenderer","NumberMaximumRenderer","NumberExclusiveMinimumRenderer","NumberExclusiveMaximumRenderer","NumberMultipleOfRenderer"],"mappings":";;;;;;;;AAaA,MAAMA,IAA2B,CAAC;AAAA,EAChC,gBAAAC;AAAA,EACA,OAAAC;AAAA,EACA,oBAAAC;AAAA,EACA,UAAAC;AAAA,EACA,OAAAC;AAAA,EACA,oBAAAC;AACF,MAAgE;AACxD,QAAA,EAAE,yBAAAC,EAAwB,IAAIC,EAAe,GAC7CC,IAAgBF,EAAwBN,CAAc;AAE5D,SAAKQ,IAKH,gBAAAC;AAAA,IAACC;AAAA,IAAA;AAAA,MACC,WAAWN,GAAO;AAAA,MAClB,kBAAkBA,GAAO;AAAA,MACzB,WAAW,CAAC,CAACA;AAAA,MAEb,4BAAC,OACC,EAAA,UAAA;AAAA,QAAA,gBAAAK,EAACE,KAAM,WAAU,QAAO,SAASH,EAAc,MAC5C,YAAc,KACjB,CAAA;AAAA,QACA,gBAAAI,EAAC,OAAI,EAAA,WAAU,2BACb,UAAA;AAAA,UAAA,gBAAAH;AAAA,YAACI;AAAA,YAAA;AAAA,cACC,IAAIL,EAAc;AAAA,cAClB,MAAK;AAAA,cACL,OAAAP;AAAA,cACA,UAAU,CAACa,MAAMZ,EAAmB,OAAOY,EAAE,OAAO,KAAK,CAAC;AAAA,cAC1D,UAAAX;AAAA,cACA,WAAWY,EAAG,EAAE,sBAAsBX,EAAO,CAAA;AAAA,YAAA;AAAA,UAC/C;AAAA,UACA,gBAAAK;AAAA,YAACO;AAAA,YAAA;AAAA,cACC,MAAK;AAAA,cACL,SAAQ;AAAA,cACR,MAAK;AAAA,cACL,SAAS,MAAMX,EAAmB;AAAA,cAElC,UAAA,gBAAAI,EAACQ,GAAE,EAAA,WAAU,SAAS,CAAA;AAAA,YAAA;AAAA,UAAA;AAAA,QACxB,GACF;AAAA,QACCT,EAAc,eACb,gBAAAC,EAAC,SAAI,WAAU,8BACZ,YAAc,YACjB,CAAA;AAAA,MAAA,EAEJ,CAAA;AAAA,IAAA;AAAA,EACF,IArCO;AAuCX,GAGaS,IAAwBnB,GACxBoB,IAAwBpB,GACxBqB,IAAiCrB,GACjCsB,IAAiCtB,GACjCuB,IAA2BvB;"}
|
|
1
|
+
{"version":3,"file":"index.es6.js","sources":["../src/packages/builder/context.tsx"],"sourcesContent":["import { createContext, useContext, useState } from \"react\";\n\nimport type { PropsWithChildren, SetStateAction } from \"react\";\nimport type { JSONSchema7, JSONSchema7Definition } from \"json-schema\";\nimport { clone, isEmpty } from \"remeda\";\nimport type { OperationError } from \"./shared-types\";\n\ninterface ContextState<T extends JSONSchema7> {\n schema: T;\n setSchema: React.Dispatch<T>;\n path: string[];\n setPath: React.Dispatch<SetStateAction<string[]>>;\n}\n\nexport const SchemaContext = createContext<\n ContextState<JSONSchema7> | undefined\n>(undefined);\n\nconst defaultSchema: JSONSchema7 = {\n $schema: \"http://json-schema.org/draft-07/schema#\",\n type: \"object\",\n title: \"title\",\n description: \"\",\n properties: {},\n required: [],\n};\n\nfunction SchemaProvider({\n children,\n initialSchema,\n}: PropsWithChildren<{ initialSchema?: JSONSchema7 }>) {\n const [schema, setSchema] = useState<JSONSchema7>(\n initialSchema ?? defaultSchema,\n );\n\n /**\n * Path represents the path to a nested property in the schema.\n * It should only contain property keys.\n * An empty path means the current schema is the root schema since\n * the path only represents nested properties.\n */\n const [path, setPath] = useState<string[]>([]);\n\n // NOTE: you *might* need to memoize your values\n // Learn more in http://kcd.im/optimize-context\n\n return (\n <SchemaContext.Provider value={{ schema, setSchema, path, setPath }}>\n {children}\n </SchemaContext.Provider>\n );\n}\n\nexport type PropertyAddError = OperationError & {\n status: \"error\";\n};\n\nexport interface PropertyAddSuccess {\n status: \"success\";\n property: JSONSchema7;\n}\n\nexport interface PropertyChangeSuccess {\n status: \"success\";\n property: JSONSchema7Definition;\n}\n\nfunction useSchema({\n onSchemaChange,\n}: {\n onSchemaChange?: (schema: JSONSchema7) => void;\n} = {}) {\n const context = useContext(SchemaContext);\n\n if (context === undefined) {\n throw new Error(\"useSchema must be used within a SchemaProvider\");\n }\n\n const { path, schema, setSchema } = context;\n\n /**\n * Navigates to the correct property schema of the latest key in the provided path.\n *\n * It will traverse both \"properties\" and \"items\" to find the correct property schema.\n *\n * It will only return a property schema if the provided path is valid i.e. it\n * correctly follows the schema's nesting structure.\n *\n * It will only return a parent schema if the provided path is valid i.e. it\n * correctly follows the schema's nesting structure.\n */\n const navigateToCorrectNesting = (\n providedSchema: JSONSchema7,\n providedPath: string[],\n ) => {\n let current = providedSchema;\n let propertySchema: JSONSchema7 | null = null;\n // Should be the schema of type \"object\" containing the property in its properties key\n let parentSchema: JSONSchema7 | null = null;\n\n for (const p of providedPath) {\n if (\n current.type === \"array\" &&\n current.items &&\n !Array.isArray(current.items) &&\n typeof current.items === \"object\" &&\n current.items.type === \"object\" &&\n typeof current.items.properties?.[p] === \"object\"\n ) {\n parentSchema = current.items;\n propertySchema = current.items.properties[p];\n current = current.items;\n } else if (\n current.type === \"object\" &&\n current.properties &&\n !Array.isArray(current.properties) &&\n typeof current.properties[p] === \"object\"\n ) {\n parentSchema = current;\n propertySchema = current.properties[p];\n current = current.properties[p];\n }\n }\n\n return { propertySchema, parentSchema };\n };\n\n /**\n * Gets the current schema of the latest key in the path.\n * If path is empty, it will return the root schema.\n *\n * It should always return the \"object\" schema of the current path.\n */\n const getCurrentSchema = (initialSchema?: JSONSchema7) => {\n // Gets the correct object schema if under nesting\n // Otherwise, return the root schema\n const { propertySchema } = navigateToCorrectNesting(\n initialSchema ?? schema,\n path,\n );\n\n if (propertySchema) {\n if (propertySchema.type === \"array\") {\n return propertySchema.items as JSONSchema7;\n }\n\n return propertySchema;\n }\n\n return initialSchema ?? schema;\n };\n\n /**\n * Gets the correct property schema of the latest key in the path.\n * If no path is provided, it will return null.\n */\n const getCurrentProperty = () => {\n const { propertySchema } = navigateToCorrectNesting(schema, path);\n\n return propertySchema;\n };\n\n /**\n * Change the key of a property in the schema. It expects\n * the find the key at the current path.\n */\n const handleKeyChange = (key: string, newKey: string) => {\n const newSchema = clone(schema);\n\n // The current schema containing the property to change\n const current: JSONSchema7 = getCurrentSchema(newSchema);\n\n if (current.properties?.[key]) {\n //Important: maintain order as to not confuse users\n const newProperties = Object.entries(current.properties).map(\n ([k, val]) => {\n return [k === key ? newKey : k, val];\n },\n );\n\n current.properties = Object.fromEntries(\n newProperties,\n ) as JSONSchema7[\"properties\"];\n }\n\n if (current.required?.includes(key)) {\n current.required = current.required.map((item) =>\n item === key ? newKey : item,\n );\n }\n\n setSchema(newSchema);\n onSchemaChange?.(newSchema);\n };\n\n const handlePropertyChange = (\n key: string,\n updates: Partial<JSONSchema7Definition> & { isRequired?: boolean },\n ): PropertyChangeSuccess | undefined => {\n const newSchema = clone(schema);\n\n // The current schema containing the property to change\n const current: JSONSchema7 = getCurrentSchema(newSchema);\n\n // Handle required field updates\n if (typeof updates === \"object\" && \"isRequired\" in updates) {\n if (current.type === \"object\") {\n if (!current.required) {\n current.required = [];\n }\n if (updates.isRequired) {\n if (!current.required.includes(key)) {\n current.required.push(key);\n }\n } else {\n current.required = current.required.filter((item) => item !== key);\n }\n }\n delete updates.isRequired;\n }\n\n let isUpdated = false;\n\n // Update the property\n if (current.type === \"object\" && current.properties) {\n const originalProperty = current.properties[key];\n // Ensure the property exists and is not a boolean\n if (typeof originalProperty !== \"boolean\" && originalProperty) {\n if (typeof updates !== \"boolean\") {\n //if updates changes the type of the property,\n //only the title, description, and default properties should remain\n //from the original property\n if (updates.type && updates.type !== originalProperty.type) {\n updates = {\n title: originalProperty.title,\n description: originalProperty.description,\n default: originalProperty.default,\n ...updates,\n };\n } else if (updates.enum) {\n //if the property is an enum, only the title and description should remain\n //from the original property\n delete updates.type;\n delete updates.items;\n delete updates.properties;\n updates = {\n title: originalProperty.title,\n description: originalProperty.description,\n ...updates,\n };\n } else {\n updates = { ...originalProperty, ...updates };\n }\n\n current.properties[key] = updates;\n }\n }\n isUpdated = true;\n }\n\n setSchema(newSchema);\n onSchemaChange?.(newSchema);\n\n if (isUpdated) {\n return { status: \"success\", property: current.properties![key]! };\n }\n };\n\n /**\n * Adds a sibling property to the current schema.\n */\n const handleAddProperty = (\n key: string,\n propertyToAdd: JSONSchema7,\n isRequired: boolean,\n ) => {\n const newSchema = clone(schema);\n\n // The current schema containing the property to add\n const current: JSONSchema7 = getCurrentSchema(newSchema);\n\n // Ensure the current schema has a properties object\n if (current.type !== \"object\") {\n current.type = \"object\";\n }\n if (!current.properties) {\n current.properties = {};\n }\n\n //Ensure there's no existing property with the same key\n if (current.properties[key]) {\n return {\n status: \"error\",\n code: \"key-exists\" as const,\n message: `Property with key ${key} already exists`,\n } satisfies PropertyAddError;\n }\n\n if (propertyToAdd.enum) {\n //ensure that only the enum property is present\n delete propertyToAdd.type;\n delete propertyToAdd.items;\n delete propertyToAdd.properties;\n }\n\n // Clean the propertyToAdd object ensuring it doesn't contain\n //keys with undefined values\n propertyToAdd = Object.fromEntries(\n Object.entries(propertyToAdd).filter(([, value]) => value !== undefined),\n );\n\n // Add the new property\n current.properties[key] = propertyToAdd;\n\n // Handle required field\n if (isRequired) {\n if (!current.required) {\n current.required = [];\n }\n if (!current.required.includes(key)) {\n current.required.push(key);\n }\n }\n\n setSchema(newSchema);\n onSchemaChange?.(newSchema);\n\n return {\n status: \"success\" as const,\n property: current.properties[key],\n } satisfies PropertyAddSuccess;\n };\n\n const handleDeleteProperty = (key: string) => {\n const newSchema = clone(schema);\n\n // The current schema containing the property to delete\n const current: JSONSchema7 = getCurrentSchema(newSchema);\n\n // Handle required field updates\n if (current.type === \"object\") {\n if (current.required) {\n current.required = current.required.filter((item) => item !== key);\n }\n }\n\n // Delete the property\n if (current.type === \"object\" && current.properties) {\n delete current.properties[key];\n }\n\n setSchema(newSchema);\n onSchemaChange?.(newSchema);\n };\n\n const handleDuplicateProperty = (key: string) => {\n const currentProperties = getCurrentSchema().properties;\n if (\n !currentProperties ||\n isEmpty(currentProperties) ||\n typeof currentProperties[key] === \"boolean\"\n ) {\n return;\n }\n\n const propertyToDuplicate = currentProperties[key]!;\n const newKey = `${key}_copy`;\n const newProperty = clone(propertyToDuplicate);\n\n // Add the duplicated property\n return handleAddProperty(newKey, newProperty, isPropertyRequired(key));\n };\n\n const isPropertyRequired = (key: string) => {\n if (path.length) {\n const { propertySchema } = navigateToCorrectNesting(schema, path);\n\n if (\n propertySchema?.type === \"array\" &&\n propertySchema.items &&\n typeof propertySchema.items !== \"boolean\" &&\n !Array.isArray(propertySchema.items) &&\n propertySchema.items?.type === \"object\"\n ) {\n return Boolean(propertySchema.items?.required?.includes(key));\n } else {\n return Boolean(propertySchema?.required?.includes(key));\n }\n }\n\n return Boolean(schema?.required?.includes(key));\n };\n\n /**\n * Programatically get the current schema value\n */\n const getValue = () => {\n return schema;\n };\n\n return {\n ...context,\n getCurrentSchema,\n getCurrentProperty,\n handlePropertyChange,\n handleAddProperty,\n handleKeyChange,\n navigateToCorrectNesting,\n handleDeleteProperty,\n isPropertyRequired,\n getValue,\n handleDuplicateProperty,\n };\n}\n\nexport { SchemaProvider, useSchema };\n"],"names":["SchemaContext","createContext","defaultSchema","SchemaProvider","children","initialSchema","schema","setSchema","useState","path","setPath","jsx","useSchema","onSchemaChange","context","useContext","navigateToCorrectNesting","providedSchema","providedPath","current","propertySchema","parentSchema","p","getCurrentSchema","getCurrentProperty","handleKeyChange","key","newKey","newSchema","clone","newProperties","k","val","item","handlePropertyChange","updates","isUpdated","originalProperty","handleAddProperty","propertyToAdd","isRequired","value","handleDeleteProperty","handleDuplicateProperty","currentProperties","isEmpty","propertyToDuplicate","newProperty","isPropertyRequired"],"mappings":";;;;AAca,MAAAA,IAAgBC,EAE3B,MAAS,GAELC,IAA6B;AAAA,EACjC,SAAS;AA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A,EAAe,OAAO,UAAU,SAASM,CAAG,IAEpD,EAAQN,GAAgB,UAAU,SAASM,CAAG;AAAA,IACvD;AAGF,WAAO,EAAQpB,GAAQ,UAAU,SAASoB,CAAG;AAAA,EAC/C;AASO,SAAA;AAAA,IACL,GAAGZ;AAAA,IACH,kBAAAS;AAAA,IACA,oBAAAC;AAAA,IACA,sBAAAU;AAAA,IACA,mBAAAI;AAAA,IACA,iBAAAb;AAAA,IACA,0BAAAT;AAAA,IACA,sBAAA0B;AAAA,IACA,oBAAAM;AAAA,IACA,UAde,MACR1C;AAAA,IAcP,yBAAAqC;AAAA,EACF;AACF;"}
|
package/dist/index.es60.js
CHANGED
|
@@ -1,69 +1,9 @@
|
|
|
1
1
|
import * as u from "react";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const { children: e, ...o } = r, s = u.useMemo(() => o, Object.values(o));
|
|
6
|
-
return /* @__PURE__ */ f(n.Provider, { value: s, children: e });
|
|
7
|
-
};
|
|
8
|
-
p.displayName = t + "Provider";
|
|
9
|
-
function i(r) {
|
|
10
|
-
const e = u.useContext(n);
|
|
11
|
-
if (e) return e;
|
|
12
|
-
if (c !== void 0) return c;
|
|
13
|
-
throw new Error(`\`${r}\` must be used within \`${t}\``);
|
|
14
|
-
}
|
|
15
|
-
return [p, i];
|
|
16
|
-
}
|
|
17
|
-
function w(t, c = []) {
|
|
18
|
-
let n = [];
|
|
19
|
-
function p(r, e) {
|
|
20
|
-
const o = u.createContext(e), s = n.length;
|
|
21
|
-
n = [...n, e];
|
|
22
|
-
const d = (x) => {
|
|
23
|
-
const { scope: m, children: v, ...a } = x, S = m?.[t]?.[s] || o, h = u.useMemo(() => a, Object.values(a));
|
|
24
|
-
return /* @__PURE__ */ f(S.Provider, { value: h, children: v });
|
|
25
|
-
};
|
|
26
|
-
d.displayName = r + "Provider";
|
|
27
|
-
function C(x, m) {
|
|
28
|
-
const v = m?.[t]?.[s] || o, a = u.useContext(v);
|
|
29
|
-
if (a) return a;
|
|
30
|
-
if (e !== void 0) return e;
|
|
31
|
-
throw new Error(`\`${x}\` must be used within \`${r}\``);
|
|
32
|
-
}
|
|
33
|
-
return [d, C];
|
|
34
|
-
}
|
|
35
|
-
const i = () => {
|
|
36
|
-
const r = n.map((e) => u.createContext(e));
|
|
37
|
-
return function(o) {
|
|
38
|
-
const s = o?.[t] || r;
|
|
39
|
-
return u.useMemo(
|
|
40
|
-
() => ({ [`__scope${t}`]: { ...o, [t]: s } }),
|
|
41
|
-
[o, s]
|
|
42
|
-
);
|
|
43
|
-
};
|
|
44
|
-
};
|
|
45
|
-
return i.scopeName = t, [p, P(i, ...c)];
|
|
46
|
-
}
|
|
47
|
-
function P(...t) {
|
|
48
|
-
const c = t[0];
|
|
49
|
-
if (t.length === 1) return c;
|
|
50
|
-
const n = () => {
|
|
51
|
-
const p = t.map((i) => ({
|
|
52
|
-
useScope: i(),
|
|
53
|
-
scopeName: i.scopeName
|
|
54
|
-
}));
|
|
55
|
-
return function(r) {
|
|
56
|
-
const e = p.reduce((o, { useScope: s, scopeName: d }) => {
|
|
57
|
-
const x = s(r)[`__scope${d}`];
|
|
58
|
-
return { ...o, ...x };
|
|
59
|
-
}, {});
|
|
60
|
-
return u.useMemo(() => ({ [`__scope${c.scopeName}`]: e }), [e]);
|
|
61
|
-
};
|
|
62
|
-
};
|
|
63
|
-
return n.scopeName = c.scopeName, n;
|
|
2
|
+
function t(r) {
|
|
3
|
+
const e = u.useRef({ value: r, previous: r });
|
|
4
|
+
return u.useMemo(() => (e.current.value !== r && (e.current.previous = e.current.value, e.current.value = r), e.current.previous), [r]);
|
|
64
5
|
}
|
|
65
6
|
export {
|
|
66
|
-
|
|
67
|
-
w as createContextScope
|
|
7
|
+
t as usePrevious
|
|
68
8
|
};
|
|
69
9
|
//# sourceMappingURL=index.es60.js.map
|
package/dist/index.es60.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.es60.js","sources":["../../../node_modules/.pnpm/@radix-ui+react-
|
|
1
|
+
{"version":3,"file":"index.es60.js","sources":["../../../node_modules/.pnpm/@radix-ui+react-use-previous@1.1.0_@types+react@18.3.18_react@18.3.1/node_modules/@radix-ui/react-use-previous/dist/index.mjs"],"sourcesContent":["// packages/react/use-previous/src/usePrevious.tsx\nimport * as React from \"react\";\nfunction usePrevious(value) {\n const ref = React.useRef({ value, previous: value });\n return React.useMemo(() => {\n if (ref.current.value !== value) {\n ref.current.previous = ref.current.value;\n ref.current.value = value;\n }\n return ref.current.previous;\n }, [value]);\n}\nexport {\n usePrevious\n};\n//# sourceMappingURL=index.mjs.map\n"],"names":["usePrevious","value","ref","React"],"mappings":";AAEA,SAASA,EAAYC,GAAO;AAC1B,QAAMC,IAAMC,EAAM,OAAO,EAAE,OAAAF,GAAO,UAAUA,GAAO;AACnD,SAAOE,EAAM,QAAQ,OACfD,EAAI,QAAQ,UAAUD,MACxBC,EAAI,QAAQ,WAAWA,EAAI,QAAQ,OACnCA,EAAI,QAAQ,QAAQD,IAEfC,EAAI,QAAQ,WAClB,CAACD,CAAK,CAAC;AACZ;","x_google_ignoreList":[0]}
|
package/dist/index.es61.js
CHANGED
|
@@ -1,33 +1,28 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import {
|
|
3
|
-
function
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}) {
|
|
25
|
-
const s = l.useState(t), [e] = s, n = l.useRef(e), o = f(r);
|
|
26
|
-
return l.useEffect(() => {
|
|
27
|
-
n.current !== e && (o(e), n.current = e);
|
|
28
|
-
}, [e, n, o]), s;
|
|
1
|
+
import * as h from "react";
|
|
2
|
+
import { useLayoutEffect as z } from "./index.es74.js";
|
|
3
|
+
function c(r) {
|
|
4
|
+
const [d, e] = h.useState(void 0);
|
|
5
|
+
return z(() => {
|
|
6
|
+
if (r) {
|
|
7
|
+
e({ width: r.offsetWidth, height: r.offsetHeight });
|
|
8
|
+
const f = new ResizeObserver((i) => {
|
|
9
|
+
if (!Array.isArray(i) || !i.length)
|
|
10
|
+
return;
|
|
11
|
+
const b = i[0];
|
|
12
|
+
let o, t;
|
|
13
|
+
if ("borderBoxSize" in b) {
|
|
14
|
+
const s = b.borderBoxSize, u = Array.isArray(s) ? s[0] : s;
|
|
15
|
+
o = u.inlineSize, t = u.blockSize;
|
|
16
|
+
} else
|
|
17
|
+
o = r.offsetWidth, t = r.offsetHeight;
|
|
18
|
+
e({ width: o, height: t });
|
|
19
|
+
});
|
|
20
|
+
return f.observe(r, { box: "border-box" }), () => f.unobserve(r);
|
|
21
|
+
} else
|
|
22
|
+
e(void 0);
|
|
23
|
+
}, [r]), d;
|
|
29
24
|
}
|
|
30
25
|
export {
|
|
31
|
-
|
|
26
|
+
c as useSize
|
|
32
27
|
};
|
|
33
28
|
//# sourceMappingURL=index.es61.js.map
|
package/dist/index.es61.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.es61.js","sources":["../../../node_modules/.pnpm/@radix-ui+react-use-
|
|
1
|
+
{"version":3,"file":"index.es61.js","sources":["../../../node_modules/.pnpm/@radix-ui+react-use-size@1.1.0_@types+react@18.3.18_react@18.3.1/node_modules/@radix-ui/react-use-size/dist/index.mjs"],"sourcesContent":["// packages/react/use-size/src/useSize.tsx\nimport * as React from \"react\";\nimport { useLayoutEffect } from \"@radix-ui/react-use-layout-effect\";\nfunction useSize(element) {\n const [size, setSize] = React.useState(void 0);\n useLayoutEffect(() => {\n if (element) {\n setSize({ width: element.offsetWidth, height: element.offsetHeight });\n const resizeObserver = new ResizeObserver((entries) => {\n if (!Array.isArray(entries)) {\n return;\n }\n if (!entries.length) {\n return;\n }\n const entry = entries[0];\n let width;\n let height;\n if (\"borderBoxSize\" in entry) {\n const borderSizeEntry = entry[\"borderBoxSize\"];\n const borderSize = Array.isArray(borderSizeEntry) ? borderSizeEntry[0] : borderSizeEntry;\n width = borderSize[\"inlineSize\"];\n height = borderSize[\"blockSize\"];\n } else {\n width = element.offsetWidth;\n height = element.offsetHeight;\n }\n setSize({ width, height });\n });\n resizeObserver.observe(element, { box: \"border-box\" });\n return () => resizeObserver.unobserve(element);\n } else {\n setSize(void 0);\n }\n }, [element]);\n return size;\n}\nexport {\n useSize\n};\n//# sourceMappingURL=index.mjs.map\n"],"names":["useSize","element","size","setSize","React","useLayoutEffect","resizeObserver","entries","entry","width","height","borderSizeEntry","borderSize"],"mappings":";;AAGA,SAASA,EAAQC,GAAS;AACxB,QAAM,CAACC,GAAMC,CAAO,IAAIC,EAAM,SAAS,MAAM;AAC7CC,SAAAA,EAAgB,MAAM;AACpB,QAAIJ,GAAS;AACX,MAAAE,EAAQ,EAAE,OAAOF,EAAQ,aAAa,QAAQA,EAAQ,cAAc;AACpE,YAAMK,IAAiB,IAAI,eAAe,CAACC,MAAY;AAIrD,YAHI,CAAC,MAAM,QAAQA,CAAO,KAGtB,CAACA,EAAQ;AACX;AAEF,cAAMC,IAAQD,EAAQ,CAAC;AACvB,YAAIE,GACAC;AACJ,YAAI,mBAAmBF,GAAO;AAC5B,gBAAMG,IAAkBH,EAAM,eACxBI,IAAa,MAAM,QAAQD,CAAe,IAAIA,EAAgB,CAAC,IAAIA;AACzE,UAAAF,IAAQG,EAAW,YACnBF,IAASE,EAAW;AAAA,QAC9B;AACU,UAAAH,IAAQR,EAAQ,aAChBS,IAAST,EAAQ;AAEnB,QAAAE,EAAQ,EAAE,OAAAM,GAAO,QAAAC,GAAQ;AAAA,MACjC,CAAO;AACD,aAAAJ,EAAe,QAAQL,GAAS,EAAE,KAAK,aAAY,CAAE,GAC9C,MAAMK,EAAe,UAAUL,CAAO;AAAA,IACnD;AACM,MAAAE,EAAQ,MAAM;AAAA,EAEpB,GAAK,CAACF,CAAO,CAAC,GACLC;AACT;","x_google_ignoreList":[0]}
|