@storyblok/react 2.1.5 → 2.1.6
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/{client-7b1fd9f5.mjs → client-1896280c.mjs} +9 -6
- package/dist/client-c97d457f.js +1 -0
- package/dist/storyblok-react.js +1 -1
- package/dist/storyblok-react.mjs +15 -17
- package/dist/storyblok-react4.js +1 -1
- package/dist/storyblok-react4.mjs +8 -6
- package/dist/types/story.d.ts +1 -1
- package/package.json +5 -5
- package/dist/client-85627252.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useState } from "react";
|
|
1
|
+
import { useState, useEffect } from "react";
|
|
2
2
|
import { u as ue } from "./storyblok-js-834d6ca5.mjs";
|
|
3
3
|
const useStoryblokState = (initialStory = null, bridgeOptions = {}) => {
|
|
4
4
|
let [story, setStory] = useState(initialStory);
|
|
@@ -6,11 +6,14 @@ const useStoryblokState = (initialStory = null, bridgeOptions = {}) => {
|
|
|
6
6
|
if (!isBridgeEnable || !initialStory) {
|
|
7
7
|
return initialStory;
|
|
8
8
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
(
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
setStory(initialStory);
|
|
11
|
+
ue(
|
|
12
|
+
story.id,
|
|
13
|
+
(newStory) => setStory(newStory),
|
|
14
|
+
bridgeOptions
|
|
15
|
+
);
|
|
16
|
+
}, [initialStory]);
|
|
14
17
|
return story;
|
|
15
18
|
};
|
|
16
19
|
export {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const e=require("react"),t=require("./storyblok-js-1cafaa66.js");exports.useStoryblokState=(r=null,o={})=>{let[s,u]=e.useState(r);return"undefined"!=typeof window&&void 0!==window.storyblokRegisterEvent&&r?(e.useEffect((()=>{u(r),t.ue(s.id,(e=>u(e)),o)}),[r]),s):r};
|
package/dist/storyblok-react.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react"),o=require("./storyblok-js-1cafaa66.js"),t=require("./index-c2e3dd49.js"),r=require("./client-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react"),o=require("./storyblok-js-1cafaa66.js"),t=require("./index-c2e3dd49.js"),r=require("./client-c97d457f.js");exports.RichTextResolver=o.y,exports.RichTextSchema=o.ie,exports.apiPlugin=o.ce,exports.loadStoryblokBridge=o.ge,exports.registerStoryblokBridge=o.ue,exports.renderRichText=o.de,exports.storyblokEditable=o.he,exports.useStoryblokBridge=o.ue,exports.StoryblokComponent=t.StoryblokComponent,exports.getComponent=t.getComponent,exports.getStoryblokApi=t.useStoryblokApi,exports.storyblokInit=t.storyblokInit,exports.useStoryblokApi=t.useStoryblokApi,exports.useStoryblokState=r.useStoryblokState,exports.useStoryblok=(r,s={},i={})=>{const n=t.useStoryblokApi();if(!n)return console.error("You can't use useStoryblok if you're not loading apiPlugin."),null;let[l,u]=e.useState({});const p="undefined"!=typeof window&&void 0!==window.storyblokRegisterEvent;return e.useEffect((()=>{!async function(){const{data:e}=await n.get(`cdn/stories/${r}`,s);u(e.story),p&&e.story.id&&o.ue(e.story.id,(e=>u(e)),i)}()}),[r,JSON.stringify(s)]),l};
|
package/dist/storyblok-react.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import { u as ue } from "./storyblok-js-834d6ca5.mjs";
|
|
|
3
3
|
import { y, i, c, g, d, h } from "./storyblok-js-834d6ca5.mjs";
|
|
4
4
|
import { u as useStoryblokApi } from "./index-a23f03ba.mjs";
|
|
5
5
|
import { S, g as g2, s } from "./index-a23f03ba.mjs";
|
|
6
|
-
import { u } from "./client-
|
|
6
|
+
import { u } from "./client-1896280c.mjs";
|
|
7
7
|
const useStoryblok = (slug, apiOptions = {}, bridgeOptions = {}) => {
|
|
8
8
|
const storyblokApiInstance = useStoryblokApi();
|
|
9
9
|
if (!storyblokApiInstance) {
|
|
@@ -14,25 +14,23 @@ const useStoryblok = (slug, apiOptions = {}, bridgeOptions = {}) => {
|
|
|
14
14
|
}
|
|
15
15
|
let [story, setStory] = useState({});
|
|
16
16
|
const isBridgeEnable = typeof window !== "undefined" && typeof window.storyblokRegisterEvent !== "undefined";
|
|
17
|
-
const initStory = async () => {
|
|
18
|
-
const { data } = await storyblokApiInstance.get(
|
|
19
|
-
`cdn/stories/${slug}`,
|
|
20
|
-
apiOptions
|
|
21
|
-
);
|
|
22
|
-
setStory(data.story);
|
|
23
|
-
};
|
|
24
|
-
useEffect(() => {
|
|
25
|
-
initStory();
|
|
26
|
-
}, [slug, apiOptions]);
|
|
27
17
|
useEffect(() => {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
bridgeOptions
|
|
18
|
+
async function initStory() {
|
|
19
|
+
const { data } = await storyblokApiInstance.get(
|
|
20
|
+
`cdn/stories/${slug}`,
|
|
21
|
+
apiOptions
|
|
33
22
|
);
|
|
23
|
+
setStory(data.story);
|
|
24
|
+
if (isBridgeEnable && data.story.id) {
|
|
25
|
+
ue(
|
|
26
|
+
data.story.id,
|
|
27
|
+
(story2) => setStory(story2),
|
|
28
|
+
bridgeOptions
|
|
29
|
+
);
|
|
30
|
+
}
|
|
34
31
|
}
|
|
35
|
-
|
|
32
|
+
initStory();
|
|
33
|
+
}, [slug, JSON.stringify(apiOptions)]);
|
|
36
34
|
return story;
|
|
37
35
|
};
|
|
38
36
|
export {
|
package/dist/storyblok-react4.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";"use client";const e=require("react"),
|
|
1
|
+
"use strict";"use client";const e=require("react"),r=require("./client-c97d457f.js"),t=require("./index-c2e3dd49.js");require("./storyblok-js-1cafaa66.js");const o=e.forwardRef((({story:o,...s},n)=>(o=r.useStoryblokState(o),e.createElement(t.StoryblokComponent,{ref:n,blok:o.content,...s}))));module.exports=o;
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import React from "react";
|
|
3
|
-
import { u as useStoryblokState } from "./client-
|
|
2
|
+
import React, { forwardRef } from "react";
|
|
3
|
+
import { u as useStoryblokState } from "./client-1896280c.mjs";
|
|
4
4
|
import { S as StoryblokComponent } from "./index-a23f03ba.mjs";
|
|
5
5
|
import "./storyblok-js-834d6ca5.mjs";
|
|
6
|
-
const StoryblokStory = (
|
|
7
|
-
story
|
|
8
|
-
|
|
9
|
-
};
|
|
6
|
+
const StoryblokStory = forwardRef(
|
|
7
|
+
({ story, ...restProps }, ref) => {
|
|
8
|
+
story = useStoryblokState(story);
|
|
9
|
+
return /* @__PURE__ */ React.createElement(StoryblokComponent, { ref, blok: story.content, ...restProps });
|
|
10
|
+
}
|
|
11
|
+
);
|
|
10
12
|
export {
|
|
11
13
|
StoryblokStory as default
|
|
12
14
|
};
|
package/dist/types/story.d.ts
CHANGED
|
@@ -4,5 +4,5 @@ interface StoryblokStoryProps {
|
|
|
4
4
|
story: ISbStoryData;
|
|
5
5
|
[key: string]: unknown;
|
|
6
6
|
}
|
|
7
|
-
declare const StoryblokStory:
|
|
7
|
+
declare const StoryblokStory: React.ForwardRefExoticComponent<Omit<StoryblokStoryProps, "ref"> & React.RefAttributes<HTMLElement>>;
|
|
8
8
|
export default StoryblokStory;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storyblok/react",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.6",
|
|
4
4
|
"description": "SDK to integrate Storyblok into your project using React.",
|
|
5
5
|
"main": "./dist/storyblok-react.js",
|
|
6
6
|
"module": "./dist/storyblok-react.mjs",
|
|
@@ -52,17 +52,17 @@
|
|
|
52
52
|
"@cypress/react": "^5.12.5",
|
|
53
53
|
"@cypress/vite-dev-server": "^2.2.3",
|
|
54
54
|
"@tsconfig/recommended": "^1.0.2",
|
|
55
|
-
"@types/react": "18.2.
|
|
56
|
-
"@vitejs/plugin-react": "^4.0.
|
|
55
|
+
"@types/react": "18.2.13",
|
|
56
|
+
"@vitejs/plugin-react": "^4.0.1",
|
|
57
57
|
"babel-jest": "^29.5.0",
|
|
58
58
|
"cypress": "^9.7.0",
|
|
59
59
|
"eslint-plugin-cypress": "^2.13.3",
|
|
60
|
-
"eslint-plugin-jest": "^27.2.
|
|
60
|
+
"eslint-plugin-jest": "^27.2.2",
|
|
61
61
|
"jest": "^29.5.0",
|
|
62
62
|
"react": "^18.2.0",
|
|
63
63
|
"react-dom": "^18.2.0",
|
|
64
64
|
"start-server-and-test": "^2.0.0",
|
|
65
|
-
"terser": "^5.18.
|
|
65
|
+
"terser": "^5.18.1",
|
|
66
66
|
"vite": "^4.1.4"
|
|
67
67
|
},
|
|
68
68
|
"peerDependencies": {
|
package/dist/client-85627252.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const e=require("react"),t=require("./storyblok-js-1cafaa66.js");exports.useStoryblokState=(r=null,o={})=>{let[s,i]=e.useState(r);return"undefined"!=typeof window&&void 0!==window.storyblokRegisterEvent&&r?(t.ue(s.id,(e=>i(e)),o),s):r};
|