react-bricks 4.6.1 → 4.7.0-beta.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/astro/DynamicComponent.astro +170 -0
- package/astro/PageViewer.astro +47 -0
- package/astro/index.js +1 -0
- package/astro/package.json +17 -0
- package/astro/react-bricks-astro.d.ts +1216 -0
- package/astro/react-bricks-astro.esm.js +1 -0
- package/astro/server/index.js +1 -0
- package/astro/server/package.json +14 -0
- package/astro/server/react-bricks-astro-server.d.ts +1023 -0
- package/astro/server/react-bricks-astro-server.esm.js +1 -0
- package/frontend/index.js +1 -1
- package/frontend/package.json +1 -1
- package/frontend/react-bricks-frontend.esm.js +1 -1
- package/index.js +1 -1
- package/package.json +30 -16
- package/react-bricks-1Be065Jm.js +1 -0
- package/react-bricks-B5lVuSry.esm.js +1 -0
- package/react-bricks-BFoJ4_oR.js +1 -0
- package/react-bricks-BNV57e5L.js +1 -0
- package/react-bricks-BNm3bMhQ.js +1 -0
- package/react-bricks-BO8V0Yxk.esm.js +1 -0
- package/react-bricks-BX28H7sD.js +1 -0
- package/react-bricks-Btf-citH.js +1 -0
- package/react-bricks-Bxd2YQWA.esm.js +1 -0
- package/react-bricks-C6NB1NCl.js +1 -0
- package/react-bricks-C8uZEwAc.esm.js +1 -0
- package/react-bricks-CI44eOAm.js +1 -0
- package/{react-bricks-amKwgsHP.esm.js → react-bricks-CSYRGq7N.esm.js} +1 -1
- package/react-bricks-CehpE_Dj.esm.js +1 -0
- package/react-bricks-DBsyFafC.js +1 -0
- package/react-bricks-DJfUVCN6.esm.js +1 -0
- package/react-bricks-DPkjyT2r.esm.js +1 -0
- package/react-bricks-DVKooNi6.esm.js +1 -0
- package/react-bricks-DzZdqeB7.esm.js +1 -0
- package/react-bricks-EDdZkV0N.js +1 -0
- package/react-bricks-HPMmwU16.esm.js +1 -0
- package/{react-bricks-C4Xaxf69.js → react-bricks-NL2q_6Ub.js} +1 -1
- package/react-bricks-rwnTYUVT.js +1 -0
- package/react-bricks-vrNJ5_JL.esm.js +1 -0
- package/react-bricks.d.ts +51 -32
- package/react-bricks.esm.js +1 -1
- package/rsc/client/index.js +1 -1
- package/rsc/client/package.json +1 -1
- package/rsc/client/react-bricks-rsc-client.d.ts +27 -8
- package/rsc/client/react-bricks-rsc-client.esm.js +1 -1
- package/rsc/index.js +1 -1
- package/rsc/package.json +1 -1
- package/rsc/react-bricks-rsc.d.ts +51 -32
- package/rsc/react-bricks-rsc.esm.js +1 -1
- package/react-bricks-8DGKndRH.esm.js +0 -1
- package/react-bricks-BI0lOdOd.js +0 -1
- package/react-bricks-BKgyRVXN.js +0 -1
- package/react-bricks-BQVp1I6D.js +0 -1
- package/react-bricks-C8TC7BiB.esm.js +0 -1
- package/react-bricks-CaxnQSIm.js +0 -1
- package/react-bricks-Cb_1qAfs.js +0 -1
- package/react-bricks-CjeZxHOb.esm.js +0 -1
- package/react-bricks-Cogx-YCi.esm.js +0 -1
- package/react-bricks-D3cMjNMP.esm.js +0 -1
- package/react-bricks-D8vmjvBM.js +0 -1
- package/react-bricks-ufYPAS2z.esm.js +0 -1
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
---
|
|
2
|
+
import type { types } from 'react-bricks/astro'
|
|
3
|
+
import { reactBricksAstroStore, AstroBrick } from 'react-bricks/astro'
|
|
4
|
+
import PageViewer from 'react-bricks/astro/PageViewer.astro'
|
|
5
|
+
|
|
6
|
+
// import type { types } from '@/shared/types'
|
|
7
|
+
// import reactBricksAstroStore from '../../ReactBricks/reactBricksAstroStore'
|
|
8
|
+
// import AstroBrick from '../AstroBrick'
|
|
9
|
+
// import PageViewer from './PageViewer.astro'
|
|
10
|
+
|
|
11
|
+
interface Props {
|
|
12
|
+
block: types.IContentBlock
|
|
13
|
+
index?: number
|
|
14
|
+
itemsCount?: number
|
|
15
|
+
page?: types.Page
|
|
16
|
+
[x: string]: unknown
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
let error = false
|
|
20
|
+
const { block, index, itemsCount, page, ...props } = Astro.props as Props
|
|
21
|
+
const config = reactBricksAstroStore.getConfig()
|
|
22
|
+
if (!config) {
|
|
23
|
+
console.warn('React Bricks Store is not initialized')
|
|
24
|
+
error = true
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
reactBricksAstroStore.setBlock(block)
|
|
28
|
+
|
|
29
|
+
// console.log('DynamicComponent', import.meta.env.SSR, !!config)
|
|
30
|
+
const Brick = reactBricksAstroStore.getBrick(block)
|
|
31
|
+
|
|
32
|
+
let blockProps = { ...block.props, ...props }
|
|
33
|
+
|
|
34
|
+
if (!Brick) {
|
|
35
|
+
if (process.env.NODE_ENV === 'development') {
|
|
36
|
+
console.warn(`Missing component for block type "${block.type}"`)
|
|
37
|
+
}
|
|
38
|
+
error = true
|
|
39
|
+
} else {
|
|
40
|
+
// Apply mapExternalDataToProps if it is defined
|
|
41
|
+
// and externalData is supplied
|
|
42
|
+
if (
|
|
43
|
+
Brick.schema.mapExternalDataToProps &&
|
|
44
|
+
typeof Brick.schema.mapExternalDataToProps === 'function' &&
|
|
45
|
+
page?.externalData &&
|
|
46
|
+
typeof page.externalData === 'object'
|
|
47
|
+
) {
|
|
48
|
+
blockProps = {
|
|
49
|
+
...blockProps,
|
|
50
|
+
...Brick.schema.mapExternalDataToProps(page.externalData, block.props),
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function trimEndChar(str: string, charToRemove: string) {
|
|
56
|
+
return str.endsWith(charToRemove) ? str.slice(0, -1) : str
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const pathname =
|
|
60
|
+
Astro.url.pathname === '/'
|
|
61
|
+
? Astro.url.pathname
|
|
62
|
+
: trimEndChar(Astro.url.pathname || '', '/')
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
{
|
|
66
|
+
error || !Brick ? (
|
|
67
|
+
''
|
|
68
|
+
) : blockProps['RB_PAGE_EMBED'] &&
|
|
69
|
+
blockProps['RB_PAGE_EMBED_CONTENT'] &&
|
|
70
|
+
blockProps['RB_PAGE_EMBED_CONTENT'].statusCode !== 404 &&
|
|
71
|
+
blockProps['RB_PAGE_EMBED_CONTENT'].error !== 'Not found' ? (
|
|
72
|
+
<PageViewer page={blockProps['RB_PAGE_EMBED_CONTENT']} main={false} />
|
|
73
|
+
) : !Brick.schema.astroInteractivity ? (
|
|
74
|
+
<AstroBrick
|
|
75
|
+
blockProps={blockProps}
|
|
76
|
+
index={index}
|
|
77
|
+
itemsCount={itemsCount}
|
|
78
|
+
page={page}
|
|
79
|
+
block={block}
|
|
80
|
+
pathname={pathname}
|
|
81
|
+
/>
|
|
82
|
+
) : Brick.schema.astroInteractivity === 'load' ||
|
|
83
|
+
(Brick.schema.astroInteractivity as any).load === true ? (
|
|
84
|
+
<AstroBrick
|
|
85
|
+
client:load
|
|
86
|
+
blockProps={blockProps}
|
|
87
|
+
index={index}
|
|
88
|
+
itemsCount={itemsCount}
|
|
89
|
+
page={page}
|
|
90
|
+
block={block}
|
|
91
|
+
pathname={pathname}
|
|
92
|
+
/>
|
|
93
|
+
) : Brick.schema.astroInteractivity === 'idle' ||
|
|
94
|
+
(Brick.schema.astroInteractivity as any).idle === true ? (
|
|
95
|
+
<AstroBrick
|
|
96
|
+
client:idle
|
|
97
|
+
blockProps={blockProps}
|
|
98
|
+
index={index}
|
|
99
|
+
itemsCount={itemsCount}
|
|
100
|
+
page={page}
|
|
101
|
+
block={block}
|
|
102
|
+
pathname={pathname}
|
|
103
|
+
/>
|
|
104
|
+
) : !!(Brick.schema.astroInteractivity as any).idle?.timeout ? (
|
|
105
|
+
<AstroBrick
|
|
106
|
+
client:idle={{
|
|
107
|
+
timeout: (Brick.schema.astroInteractivity as any).idle?.timeout,
|
|
108
|
+
}}
|
|
109
|
+
blockProps={blockProps}
|
|
110
|
+
index={index}
|
|
111
|
+
itemsCount={itemsCount}
|
|
112
|
+
page={page}
|
|
113
|
+
block={block}
|
|
114
|
+
pathname={pathname}
|
|
115
|
+
/>
|
|
116
|
+
) : Brick.schema.astroInteractivity === 'visible' ||
|
|
117
|
+
(Brick.schema.astroInteractivity as any).visible === true ? (
|
|
118
|
+
<AstroBrick
|
|
119
|
+
client:visible
|
|
120
|
+
blockProps={blockProps}
|
|
121
|
+
index={index}
|
|
122
|
+
itemsCount={itemsCount}
|
|
123
|
+
page={page}
|
|
124
|
+
block={block}
|
|
125
|
+
pathname={pathname}
|
|
126
|
+
/>
|
|
127
|
+
) : !!(Brick.schema.astroInteractivity as any).visible?.rootMargin ? (
|
|
128
|
+
<AstroBrick
|
|
129
|
+
client:visible={{
|
|
130
|
+
rootMargin: (Brick.schema.astroInteractivity as any).visible
|
|
131
|
+
?.rootMargin,
|
|
132
|
+
}}
|
|
133
|
+
blockProps={blockProps}
|
|
134
|
+
index={index}
|
|
135
|
+
itemsCount={itemsCount}
|
|
136
|
+
page={page}
|
|
137
|
+
block={block}
|
|
138
|
+
pathname={pathname}
|
|
139
|
+
/>
|
|
140
|
+
) : !!(Brick.schema.astroInteractivity as any).media ? (
|
|
141
|
+
<AstroBrick
|
|
142
|
+
client:media={(Brick.schema.astroInteractivity as any).media}
|
|
143
|
+
blockProps={blockProps}
|
|
144
|
+
index={index}
|
|
145
|
+
itemsCount={itemsCount}
|
|
146
|
+
page={page}
|
|
147
|
+
block={block}
|
|
148
|
+
pathname={pathname}
|
|
149
|
+
/>
|
|
150
|
+
) : !!(Brick.schema.astroInteractivity as any).only ? (
|
|
151
|
+
<AstroBrick
|
|
152
|
+
client:only={(Brick.schema.astroInteractivity as any).only}
|
|
153
|
+
blockProps={blockProps}
|
|
154
|
+
index={index}
|
|
155
|
+
itemsCount={itemsCount}
|
|
156
|
+
page={page}
|
|
157
|
+
block={block}
|
|
158
|
+
pathname={pathname}
|
|
159
|
+
/>
|
|
160
|
+
) : (
|
|
161
|
+
<AstroBrick
|
|
162
|
+
blockProps={blockProps}
|
|
163
|
+
index={index}
|
|
164
|
+
itemsCount={itemsCount}
|
|
165
|
+
page={page}
|
|
166
|
+
block={block}
|
|
167
|
+
pathname={pathname}
|
|
168
|
+
/>
|
|
169
|
+
)
|
|
170
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
---
|
|
2
|
+
import type { types } from 'react-bricks/astro'
|
|
3
|
+
import { reactBricksAstroStore, ClickToEdit } from 'react-bricks/astro'
|
|
4
|
+
import DynamicComponent from 'react-bricks/astro/DynamicComponent.astro'
|
|
5
|
+
|
|
6
|
+
// import type { types } from '@/shared/types'
|
|
7
|
+
// import reactBricksAstroStore from '../../ReactBricks/reactBricksAstroStore'
|
|
8
|
+
// import ClickToEdit from '../ClickToEdit'
|
|
9
|
+
// import DynamicComponent from './DynamicComponent.astro'
|
|
10
|
+
|
|
11
|
+
interface Props {
|
|
12
|
+
page: types.Page
|
|
13
|
+
main?: boolean
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
let error = false
|
|
17
|
+
const { page, main } = Astro.props as Props
|
|
18
|
+
|
|
19
|
+
if (!page) {
|
|
20
|
+
console.error(`Page not found.`)
|
|
21
|
+
error = true
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
reactBricksAstroStore.setPage(page)
|
|
25
|
+
|
|
26
|
+
const pageType = reactBricksAstroStore.getPageType(page)
|
|
27
|
+
|
|
28
|
+
if (!pageType) {
|
|
29
|
+
console.error(`Unknown pageType ${page.type}.`)
|
|
30
|
+
error = true
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// console.log('is main?', !!main, page.name)
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
{
|
|
37
|
+
error
|
|
38
|
+
? ''
|
|
39
|
+
: (page?.content?.map((block, index) => (
|
|
40
|
+
<DynamicComponent
|
|
41
|
+
page={page}
|
|
42
|
+
key={`${block.id}-${index}`}
|
|
43
|
+
{...{ block }}
|
|
44
|
+
/>
|
|
45
|
+
)) ?? null)
|
|
46
|
+
}
|
|
47
|
+
{!!main ? <ClickToEdit client:idle page={page} /> : ''}
|
package/astro/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";require("intersection-observer");var e=require("../react-bricks-DBsyFafC.js"),t=require("../react-bricks-1Be065Jm.js"),r=require("react"),n=require("react-icons/fi"),o=require("../react-bricks-BFoJ4_oR.js");require("../react-bricks-Btf-citH.js"),require("classnames"),require("../react-bricks-BNm3bMhQ.js"),require("ts-md5");var i,s="c"+(i=5,e.__spreadArray([],e.__read(Array(i)),!1).map((function(){return(~~(36*Math.random())).toString(36)})).join("")),a=function(){return r.createElement(r.Fragment,null,r.createElement("style",null,"\n.".concat(s," {\n display:block;\n position: fixed;\n box-sizing: border-box;\n z-index: 999;\n bottom: 20px;\n left: 20px;\n padding: 5px 12px;\n background-color: #ffffffdd;\n display: flex;\n justify-content: center;\n align-items: center;\n color: #1e293b;\n font-size: 11px;\n font-weight: 600;\n border: 1px solid #e2e8f0cc;\n border-radius: 20px;\n text-transform: uppercase;\n box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);\n filter: none;\n transition: all 300ms ease;\n}\n.").concat(s,":hover {\n background-color: #ffffff;\n filter: drop-shadow(0 20px 13px rgb(0 0 0 / 0.03)) drop-shadow(0 8px 5px rgb(0 0 0 / 0.08));\n}\n.").concat(s," .l {\n transition: color 300ms ease;\n}\n.").concat(s,":hover .l {\n color: #f65a8e;\n}\n ")),r.createElement("a",{href:"https://reactbricks.com?utm_campaign=site-badge",target:"_blank",className:s},r.createElement("img",{src:"https://reactbricks.com/_next/static/media/reactbricks_icon.c57a7be4.svg",style:{width:18,height:18,marginRight:6}}),r.createElement("span",null,"Made in ",r.createElement("span",{className:"l"},"React Bricks"))))},c=t.reactBricksAstroStore.getBricks,l=t.reactBricksAstroStore.getPageValues,p=t.reactBricksAstroStore.getBlockValue,d=t.reactBricksAstroStore.isAdmin;t.reactBricksAstroStore.register,Object.defineProperty(exports,"types",{enumerable:!0,get:function(){return e.types}}),exports.File=t.File,exports.Image=t.Image,exports.Link=t.Link,exports.Repeater=t.Repeater,exports.RichText=t.CompatibleRichText,exports.RichTextExt=t.RichText,exports.Text=t.Text,exports.reactBricksAstroStore=t.reactBricksAstroStore,exports.useAdminContext=t.useAdminContext,exports.usePageValues=t.usePageValues,exports.useReactBricksContext=t.useReactBricksContext,exports.useVisualEdit=t.useVisualEdit,exports.Plain=o.Plain,exports.AstroBrick=function(n){var o=n.index,i=n.itemsCount,s=n.blockProps,a=n.page,c=n.block,l=n.pathname,p=void 0===l?"":l,d=t.reactBricksAstroStore.getBrick(c);return d?(t.reactBricksAstroStore.setPathname(p),r.createElement(d,e.__assign({},s,{key:s.key,index:o,itemsCount:i,__page:a,__block:c}))):("development"===process.env.NODE_ENV&&console.warn('Missing component for block type "'.concat(c.type,'"')),null)},exports.ClickToEdit=function(i){var s,c,l=i.page,p=e.__read(r.useState(!1),2),d=p[0],u=p[1],x=t.useReactBricksContext();if(r.useEffect((function(){u(!0)}),[]),!d)return null;if(!x)return null;var m,f=(null===(s=null==l?void 0:l.customValues)||void 0===s?void 0:s.___t)&&!o.isPaidPlan(null===(c=l.customValues)||void 0===c?void 0:c.___t),g=localStorage.getItem(e.AUTH_TOKEN_LS_KEY);if(g&&g.length>10&&g.startsWith("ey")){if((null==x?void 0:x.clickToEditSide)===e.types.ClickToEditSide.None)return null;var k=x||{navigate:function(){}},b=k.navigate,h=k.editorPath,E=k.clickToEditSide,y={};return E===e.types.ClickToEditSide.BottomRight&&(y.bottom=50,y.right=0,y.borderTopLeftRadius=999,y.borderBottomLeftRadius=999,y.transform="translate(8px,0)"),E===e.types.ClickToEditSide.BottomLeft&&(y.bottom=50,y.left=0,y.borderTopRightRadius=999,y.borderBottomRightRadius=999,y.transform="translate(-8px,0)"),E===e.types.ClickToEditSide.TopRight&&(y.top=50,y.right=0,y.borderTopLeftRadius=999,y.borderBottomLeftRadius=999,y.transform="translate(8px,0)"),E===e.types.ClickToEditSide.TopLeft&&(y.top=50,y.left=0,y.borderTopRightRadius=999,y.borderBottomRightRadius=999,y.transform="translate(-8px,0)"),r.createElement(r.Fragment,null,r.createElement("style",null,"\n.rb-click-to-edit {\n position: fixed;\n z-index: 10;\n width: 61px;\n height: 38px;\n background-color: #f65a8e;\n display: flex;\n justify-content: center;\n align-items: center;\n color: #fff;\n font-size: 20px;\n cursor: pointer;\n box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);\n transition: all 150ms ease;\n border: 2px solid #fff;\n}\n.rb-click-to-edit-left:hover {\n transform: translate(-2px,0)!important;\n}\n.rb-click-to-edit-right:hover {\n transform: translate(2px,0)!important;\n}\n "),r.createElement("div",{className:"rb-click-to-edit ".concat((m=E,m===e.types.ClickToEditSide.TopLeft||m===e.types.ClickToEditSide.BottomLeft?"rb-click-to-edit-left":"rb-click-to-edit-right")),style:y,onClick:function(){return b("".concat(h,"?p=").concat(encodeURIComponent(l.id),"&l=").concat(l.language))}},r.createElement(n.FiEdit,null)),f&&r.createElement(a,null))}return f&&r.createElement(a,null)},exports.getBlockValue=p,exports.getBricks=c,exports.getPageValues=l,exports.isAdmin=d;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "react-bricks-astro",
|
|
3
|
+
"version": "4.7.0-beta.1",
|
|
4
|
+
"main": "index.js",
|
|
5
|
+
"module": "react-bricks-astro.esm.js",
|
|
6
|
+
"types": "./react-bricks-astro.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"require": "./index.js",
|
|
10
|
+
"import": "./react-bricks-astro.esm.js",
|
|
11
|
+
"default": "./react-bricks-astro.esm.js",
|
|
12
|
+
"types": "./react-bricks-astro.d.ts"
|
|
13
|
+
},
|
|
14
|
+
"./DynamicComponent.astro": "./DynamicComponent.astro",
|
|
15
|
+
"./PageViewer.astro": "./PageViewer.astro"
|
|
16
|
+
}
|
|
17
|
+
}
|