@storyblok/react 4.2.1 → 4.3.1
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/README.md +108 -1
- package/dist/client.js +1 -1
- package/dist/common/index.d.ts +2 -2
- package/dist/common/index.d.ts.map +1 -1
- package/dist/common/storyblok-component.d.ts +2 -2
- package/dist/common/storyblok-component.d.ts.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.mjs +39 -29
- package/dist/index2.js +1 -1
- package/dist/index2.mjs +22 -18
- package/dist/live-editing.js +1 -1
- package/dist/richtext.d.ts +7 -0
- package/dist/richtext.d.ts.map +1 -0
- package/dist/richtext.js +1 -0
- package/dist/richtext.mjs +26 -0
- package/dist/rsc/index.d.ts +3 -0
- package/dist/rsc/index.d.ts.map +1 -1
- package/dist/rsc/server-component.d.ts +2 -2
- package/dist/rsc/server-component.d.ts.map +1 -1
- package/dist/rsc/story.d.ts +2 -2
- package/dist/rsc/story.d.ts.map +1 -1
- package/dist/rsc.js +1 -1
- package/dist/rsc.mjs +29 -21
- package/dist/server-component.js +1 -1
- package/dist/server-component.mjs +2 -0
- package/dist/storyblok-js.js +2 -2
- package/dist/storyblok-js.mjs +541 -339
- package/dist/storyblok-rich-text.d.ts +5 -0
- package/dist/storyblok-rich-text.d.ts.map +1 -0
- package/dist/storyblok-rich-text.js +1 -0
- package/dist/storyblok-rich-text.mjs +15 -0
- package/dist/types.d.ts +5 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/utils.d.ts +9 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +1 -0
- package/dist/utils.mjs +33 -0
- package/package.json +9 -2
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { StoryblokRichTextProps } from './types';
|
|
3
|
+
declare const StoryblokRichText: React.ForwardRefExoticComponent<StoryblokRichTextProps & React.RefAttributes<HTMLDivElement>>;
|
|
4
|
+
export default StoryblokRichText;
|
|
5
|
+
//# sourceMappingURL=storyblok-rich-text.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storyblok-rich-text.d.ts","sourceRoot":"","sources":["../src/storyblok-rich-text.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAI1C,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAEtD,QAAA,MAAM,iBAAiB,+FAetB,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const n=require("react/jsx-runtime"),i=require("react"),u=require("./utils.js"),l=require("./richtext.js"),x=i.forwardRef(({doc:t,resolvers:e},r)=>{const{render:o}=l.useStoryblokRichTextResolver({resolvers:e}),s=o(t),c=u.convertAttributesInElement(s);return n.jsx("div",{ref:r,children:c})});module.exports=x;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { jsx as i } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as s } from "react";
|
|
3
|
+
import { convertAttributesInElement as c } from "./utils.mjs";
|
|
4
|
+
import { useStoryblokRichTextResolver as f } from "./richtext.mjs";
|
|
5
|
+
const h = s(
|
|
6
|
+
({ doc: t, resolvers: r }, o) => {
|
|
7
|
+
const { render: e } = f({
|
|
8
|
+
resolvers: r
|
|
9
|
+
}), m = e(t), n = c(m);
|
|
10
|
+
return /* @__PURE__ */ i("div", { ref: o, children: n });
|
|
11
|
+
}
|
|
12
|
+
);
|
|
13
|
+
export {
|
|
14
|
+
h as default
|
|
15
|
+
};
|
package/dist/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type React from 'react';
|
|
2
|
-
import type { ISbStoryData, SbSDKOptions, StoryblokBridgeConfigV2 } from '@storyblok/js';
|
|
2
|
+
import type { ISbStoryData, SbSDKOptions, StoryblokBridgeConfigV2, StoryblokRichTextNode, StoryblokRichTextResolvers } from '@storyblok/js';
|
|
3
3
|
export interface SbReactComponentsMap {
|
|
4
4
|
[key: string]: React.ElementType;
|
|
5
5
|
}
|
|
@@ -9,5 +9,9 @@ export interface SbReactSDKOptions extends SbSDKOptions {
|
|
|
9
9
|
customFallbackComponent?: React.ElementType;
|
|
10
10
|
}
|
|
11
11
|
export type TUseStoryblokState = <T = void>(initialStory: ISbStoryData<T> | null, bridgeOptions?: StoryblokBridgeConfigV2) => ISbStoryData<T> | null;
|
|
12
|
+
export interface StoryblokRichTextProps {
|
|
13
|
+
doc: StoryblokRichTextNode<React.ReactElement>;
|
|
14
|
+
resolvers?: StoryblokRichTextResolvers<React.ReactElement>;
|
|
15
|
+
}
|
|
12
16
|
export type { ArrayFn, AsyncFn, ISbAlternateObject, ISbCache, ISbConfig, ISbContentMangmntAPI, ISbDimensions, ISbError, ISbManagmentApiResult, ISbNode, ISbResponse, ISbResult, ISbRichtext, ISbSchema, ISbStories, ISbStoriesParams, ISbStory, ISbStoryData, ISbStoryParams, ISbThrottle, SbBlokData, SbBlokKeyDataTypes, SbRichTextOptions, SbSDKOptions, StoryblokBridgeConfigV2, StoryblokBridgeV2, StoryblokClient, StoryblokComponentType, useStoryblokBridge, } from '@storyblok/js';
|
|
13
17
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,uBAAuB,EAAE,qBAAqB,EAAE,0BAA0B,EAAE,MAAM,eAAe,CAAC;AAE5I,MAAM,WAAW,oBAAoB;IACnC,CAAC,GAAG,EAAE,MAAM,GAAG,KAAK,CAAC,WAAW,CAAC;CAClC;AAED,MAAM,WAAW,iBAAkB,SAAQ,YAAY;IACrD,UAAU,CAAC,EAAE,oBAAoB,CAAC;IAClC,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,uBAAuB,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC;CAC7C;AAED,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,GAAG,IAAI,EACxC,YAAY,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,IAAI,EACpC,aAAa,CAAC,EAAE,uBAAuB,KACpC,YAAY,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;AAE5B,MAAM,WAAW,sBAAsB;IACrC,GAAG,EAAE,qBAAqB,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;IAC/C,SAAS,CAAC,EAAE,0BAA0B,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;CAC5D;AAED,YAAY,EACV,OAAO,EACP,OAAO,EACP,kBAAkB,EAClB,QAAQ,EACR,SAAS,EACT,oBAAoB,EACpB,aAAa,EACb,QAAQ,EACR,qBAAqB,EACrB,OAAO,EACP,WAAW,EACX,SAAS,EACT,WAAW,EACX,SAAS,EACT,UAAU,EACV,gBAAgB,EAChB,QAAQ,EACR,YAAY,EACZ,cAAc,EACd,WAAW,EACX,UAAU,EACV,kBAAkB,EAClB,iBAAiB,EACjB,YAAY,EACZ,uBAAuB,EACvB,iBAAiB,EACjB,eAAe,EACf,sBAAsB,EACtB,kBAAkB,GACnB,MAAM,eAAe,CAAC"}
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Recursively converts HTML attributes in a React element tree to their JSX property names.
|
|
4
|
+
*
|
|
5
|
+
* @param {React.ReactElement} element The React element to process.
|
|
6
|
+
* @return {React.ReactElement} A new React element with converted attributes.
|
|
7
|
+
*/
|
|
8
|
+
export declare function convertAttributesInElement(element: React.ReactElement | React.ReactElement[]): React.ReactElement | React.ReactElement[];
|
|
9
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAkB1B;;;;;GAKG;AACH,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,KAAK,CAAC,YAAY,GAAG,KAAK,CAAC,YAAY,EAAE,GAAG,KAAK,CAAC,YAAY,GAAG,KAAK,CAAC,YAAY,EAAE,CAqCxI"}
|
package/dist/utils.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react");function l(t){return t.replace(/-([a-z])/g,n=>n[1].toUpperCase())}function f(t){return t.split(";").reduce((n,s)=>{let[r,e]=s.split(":");return r=r==null?void 0:r.trim(),e=e==null?void 0:e.trim(),r&&e&&(n[l(r)]=e),n},{})}function p(t){if(Array.isArray(t))return t.map(i=>p(i));if(!a.isValidElement(t))return t;const n={class:"className",for:"htmlFor",targetAttr:"targetattr"},s=Object.keys(t.props).reduce((i,o)=>{let c=t.props[o];o==="style"&&typeof c=="string"&&(c=f(c));const u=n[o]||o;return i[u]=c,i},{});s.key=t.key;const r=a.Children.map(t.props.children,i=>p(i));return a.createElement(t.type,s,r)}exports.convertAttributesInElement=p;
|
package/dist/utils.mjs
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import a from "react";
|
|
2
|
+
function l(r) {
|
|
3
|
+
return r.replace(/-([a-z])/g, (n) => n[1].toUpperCase());
|
|
4
|
+
}
|
|
5
|
+
function f(r) {
|
|
6
|
+
return r.split(";").reduce((n, o) => {
|
|
7
|
+
let [t, e] = o.split(":");
|
|
8
|
+
return t = t == null ? void 0 : t.trim(), e = e == null ? void 0 : e.trim(), t && e && (n[l(t)] = e), n;
|
|
9
|
+
}, {});
|
|
10
|
+
}
|
|
11
|
+
function c(r) {
|
|
12
|
+
if (Array.isArray(r))
|
|
13
|
+
return r.map((i) => c(i));
|
|
14
|
+
if (!a.isValidElement(r))
|
|
15
|
+
return r;
|
|
16
|
+
const n = {
|
|
17
|
+
class: "className",
|
|
18
|
+
for: "htmlFor",
|
|
19
|
+
targetAttr: "targetattr"
|
|
20
|
+
// Add more attribute conversions here as needed
|
|
21
|
+
}, o = Object.keys(r.props).reduce((i, s) => {
|
|
22
|
+
let p = r.props[s];
|
|
23
|
+
s === "style" && typeof p == "string" && (p = f(p));
|
|
24
|
+
const u = n[s] || s;
|
|
25
|
+
return i[u] = p, i;
|
|
26
|
+
}, {});
|
|
27
|
+
o.key = r.key;
|
|
28
|
+
const t = a.Children.map(r.props.children, (i) => c(i));
|
|
29
|
+
return a.createElement(r.type, o, t);
|
|
30
|
+
}
|
|
31
|
+
export {
|
|
32
|
+
c as convertAttributesInElement
|
|
33
|
+
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storyblok/react",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "4.
|
|
4
|
+
"version": "4.3.1",
|
|
5
5
|
"private": false,
|
|
6
6
|
"packageManager": "pnpm@9.13.2",
|
|
7
7
|
"description": "SDK to integrate Storyblok into your project using React.",
|
|
@@ -101,7 +101,14 @@
|
|
|
101
101
|
"commitlint": {
|
|
102
102
|
"extends": [
|
|
103
103
|
"@commitlint/config-conventional"
|
|
104
|
-
]
|
|
104
|
+
],
|
|
105
|
+
"rules": {
|
|
106
|
+
"body-max-line-length": [
|
|
107
|
+
2,
|
|
108
|
+
"always",
|
|
109
|
+
200
|
|
110
|
+
]
|
|
111
|
+
}
|
|
105
112
|
},
|
|
106
113
|
"release": {
|
|
107
114
|
"branches": [
|