@storyblok/react 5.4.5 → 5.4.9
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react"),l=require("@storyblok/js");function u(c,{isServerContext:t=!1}={}){return function(e){var o,n;const r=(o=e==null?void 0:e.attrs)==null?void 0:o.body;if(!Array.isArray(r)||r.length===0)return[];const a=((n=e.attrs)==null?void 0:n.id)||(t?`fallback-key-${JSON.stringify(e.attrs)}`:void 0);return r.map((i,m)=>s.createElement(c,{blok:i,key:`${a}-${m}`}))}}function R(c,{isServerContext:t=!1}={}){return function(e){const r=u(c,{isServerContext:t}),{resolvers:a,...o}=e,n={...t?e:{},renderFn:s.createElement,textFn:i=>s.createElement(s.Fragment,{key:Math.random().toString(36).substring(2,15)},i),resolvers:{[l.BlockTypes.COMPONENT]:r,...a},keyedResolvers:!0,...t?{}:o};return l.richTextResolver(n)}}exports.createComponentResolver=u;exports.createRichTextHook=R;
|
|
@@ -1,38 +1,43 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { BlockTypes as
|
|
3
|
-
function
|
|
1
|
+
import s from "react";
|
|
2
|
+
import { BlockTypes as u, richTextResolver as f } from "@storyblok/js";
|
|
3
|
+
function y(c, {
|
|
4
4
|
isServerContext: t = !1
|
|
5
5
|
} = {}) {
|
|
6
6
|
return function(e) {
|
|
7
|
-
var
|
|
8
|
-
const r = (
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
var o, n;
|
|
8
|
+
const r = (o = e == null ? void 0 : e.attrs) == null ? void 0 : o.body;
|
|
9
|
+
if (!Array.isArray(r) || r.length === 0)
|
|
10
|
+
return [];
|
|
11
|
+
const a = ((n = e.attrs) == null ? void 0 : n.id) || (t ? `fallback-key-${JSON.stringify(e.attrs)}` : void 0);
|
|
12
|
+
return r.map(
|
|
13
|
+
(i, m) => s.createElement(c, {
|
|
14
|
+
blok: i,
|
|
15
|
+
key: `${a}-${m}`
|
|
16
|
+
})
|
|
17
|
+
);
|
|
13
18
|
};
|
|
14
19
|
}
|
|
15
|
-
function
|
|
20
|
+
function k(c, {
|
|
16
21
|
isServerContext: t = !1
|
|
17
22
|
} = {}) {
|
|
18
23
|
return function(e) {
|
|
19
|
-
const r =
|
|
24
|
+
const r = y(c, { isServerContext: t }), { resolvers: a, ...o } = e, n = {
|
|
20
25
|
...t ? e : {},
|
|
21
|
-
renderFn:
|
|
22
|
-
textFn: (
|
|
26
|
+
renderFn: s.createElement,
|
|
27
|
+
textFn: (i) => s.createElement(s.Fragment, {
|
|
23
28
|
key: Math.random().toString(36).substring(2, 15)
|
|
24
|
-
},
|
|
29
|
+
}, i),
|
|
25
30
|
resolvers: {
|
|
26
|
-
[
|
|
27
|
-
...
|
|
31
|
+
[u.COMPONENT]: r,
|
|
32
|
+
...a
|
|
28
33
|
},
|
|
29
34
|
keyedResolvers: !0,
|
|
30
|
-
...t ? {} :
|
|
35
|
+
...t ? {} : o
|
|
31
36
|
};
|
|
32
|
-
return
|
|
37
|
+
return f(n);
|
|
33
38
|
};
|
|
34
39
|
}
|
|
35
40
|
export {
|
|
36
|
-
|
|
37
|
-
|
|
41
|
+
y as createComponentResolver,
|
|
42
|
+
k as createRichTextHook
|
|
38
43
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
2
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react"),d=require("@storyblok/js"),l=(t=null,o={})=>{const[r,u]=n.useState(null),e=(t==null?void 0:t.id)??null;return n.useEffect(()=>{u(null)},[e]),n.useEffect(()=>{!(typeof window<"u"&&typeof window.storyblokRegisterEvent<"u")||!e||d.registerStoryblokBridge(e,i=>u(i),o)},[e,o]),r&&r.id===e?r:t};exports.useStoryblokState=l;
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { useState as
|
|
3
|
-
import { registerStoryblokBridge as
|
|
4
|
-
const g = (
|
|
5
|
-
const [r, o] =
|
|
6
|
-
return
|
|
7
|
-
o(
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
2
|
+
import { useState as l, useEffect as i } from "react";
|
|
3
|
+
import { registerStoryblokBridge as u } from "@storyblok/js";
|
|
4
|
+
const g = (t = null, n = {}) => {
|
|
5
|
+
const [r, o] = l(null), e = (t == null ? void 0 : t.id) ?? null;
|
|
6
|
+
return i(() => {
|
|
7
|
+
o(null);
|
|
8
|
+
}, [e]), i(() => {
|
|
9
|
+
!(typeof window < "u" && typeof window.storyblokRegisterEvent < "u") || !e || u(
|
|
10
|
+
e,
|
|
11
|
+
(d) => o(d),
|
|
12
|
+
n
|
|
11
13
|
);
|
|
12
|
-
}, [e]), r;
|
|
14
|
+
}, [e, n]), r && r.id === e ? r : t;
|
|
13
15
|
};
|
|
14
16
|
export {
|
|
15
17
|
g as useStoryblokState
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storyblok/react",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "5.4.
|
|
4
|
+
"version": "5.4.9",
|
|
5
5
|
"private": false,
|
|
6
6
|
"description": "SDK to integrate Storyblok into your project using React.",
|
|
7
7
|
"author": "Storyblok",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
}
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@storyblok/js": "4.2.
|
|
52
|
+
"@storyblok/js": "4.2.7"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@babel/core": "^7.27.1",
|