react-bricks 4.6.1 → 4.7.0-alpha.0

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.
Files changed (66) hide show
  1. package/astro/DynamicComponent.astro +174 -0
  2. package/astro/PageViewer.astro +56 -0
  3. package/astro/Slot.astro +40 -0
  4. package/astro/SlotViewer.astro +38 -0
  5. package/astro/TemplateViewer.astro +24 -0
  6. package/astro/index.js +2 -0
  7. package/astro/package.json +20 -0
  8. package/astro/react-bricks-astro.d.ts +1236 -0
  9. package/astro/react-bricks-astro.esm.js +2 -0
  10. package/astro/server/index.js +2 -0
  11. package/astro/server/package.json +14 -0
  12. package/astro/server/react-bricks-astro-server.d.ts +1027 -0
  13. package/astro/server/react-bricks-astro-server.esm.js +2 -0
  14. package/frontend/index.js +2 -1
  15. package/frontend/package.json +2 -2
  16. package/frontend/react-bricks-frontend.esm.js +2 -1
  17. package/index.js +2 -1
  18. package/package.json +39 -23
  19. package/react-bricks-1YD00zjF.js +2 -0
  20. package/react-bricks-BI0q6_FW.esm.js +2 -0
  21. package/react-bricks-BSHEhoDG.esm.js +2 -0
  22. package/react-bricks-BUGrDTgq.esm.js +2 -0
  23. package/react-bricks-BgfLLAM0.js +2 -0
  24. package/react-bricks-BklAG3OE.esm.js +2 -0
  25. package/react-bricks-BnMY1ZEO.js +2 -0
  26. package/react-bricks-BnRsW22a.js +2 -0
  27. package/react-bricks-Bv9phTdZ.js +2 -0
  28. package/react-bricks-C-nvbiap.js +2 -0
  29. package/react-bricks-CErfpf4g.esm.js +2 -0
  30. package/react-bricks-CI44eOAm.js +2 -0
  31. package/react-bricks-CW55gEAH.esm.js +2 -0
  32. package/react-bricks-CXY4gR9A.js +2 -0
  33. package/{react-bricks-amKwgsHP.esm.js → react-bricks-ChFEEzaf.esm.js} +2 -1
  34. package/react-bricks-ChQsE0YU.esm.js +2 -0
  35. package/react-bricks-DQcHsMAz.esm.js +2 -0
  36. package/react-bricks-DRIKzHUS.js +2 -0
  37. package/react-bricks-DS4kraXp.js +2 -0
  38. package/{react-bricks-C4Xaxf69.js → react-bricks-DamkhdwS.js} +2 -1
  39. package/react-bricks-DouXS5I0.js +2 -0
  40. package/react-bricks-DzZdqeB7.esm.js +2 -0
  41. package/react-bricks-IZZ19Kbs.esm.js +2 -0
  42. package/react-bricks-OncRrHCV.esm.js +2 -0
  43. package/react-bricks-SXPPhoTe.esm.js +2 -0
  44. package/react-bricks-Wx-oWYfO.js +2 -0
  45. package/react-bricks.d.ts +66 -43
  46. package/react-bricks.esm.js +2 -1
  47. package/rsc/client/index.js +2 -1
  48. package/rsc/client/package.json +2 -2
  49. package/rsc/client/react-bricks-rsc-client.d.ts +36 -13
  50. package/rsc/client/react-bricks-rsc-client.esm.js +2 -1
  51. package/rsc/index.js +2 -1
  52. package/rsc/package.json +2 -2
  53. package/rsc/react-bricks-rsc.d.ts +60 -37
  54. package/rsc/react-bricks-rsc.esm.js +2 -1
  55. package/react-bricks-8DGKndRH.esm.js +0 -1
  56. package/react-bricks-BI0lOdOd.js +0 -1
  57. package/react-bricks-BKgyRVXN.js +0 -1
  58. package/react-bricks-BQVp1I6D.js +0 -1
  59. package/react-bricks-C8TC7BiB.esm.js +0 -1
  60. package/react-bricks-CaxnQSIm.js +0 -1
  61. package/react-bricks-Cb_1qAfs.js +0 -1
  62. package/react-bricks-CjeZxHOb.esm.js +0 -1
  63. package/react-bricks-Cogx-YCi.esm.js +0 -1
  64. package/react-bricks-D3cMjNMP.esm.js +0 -1
  65. package/react-bricks-D8vmjvBM.js +0 -1
  66. package/react-bricks-ufYPAS2z.esm.js +0 -1
@@ -0,0 +1,174 @@
1
+ ---
2
+ import type { types } from 'react-bricks/astro'
3
+ import { reactBricksAstroStore, AstroBrick } from 'react-bricks/astro'
4
+ import PageViewer from './PageViewer.astro'
5
+
6
+ interface Props {
7
+ block: types.IContentBlock
8
+ index?: number
9
+ itemsCount?: number
10
+ page?: types.Page
11
+ [x: string]: unknown
12
+ }
13
+
14
+ let error = false
15
+ const { block, index, itemsCount, page, ...props } = Astro.props as Props
16
+ const config = reactBricksAstroStore.getConfig()
17
+
18
+ if (!config) {
19
+ console.warn('React Bricks Store is not initialized')
20
+ error = true
21
+ }
22
+
23
+ reactBricksAstroStore.setBlock(block)
24
+
25
+ const Brick = reactBricksAstroStore.getBrick(block)
26
+
27
+ let blockProps = { ...block.props, ...props }
28
+
29
+ if (!Brick) {
30
+ if (process.env.NODE_ENV === 'development') {
31
+ console.warn(`Missing component for block type "${block.type}"`)
32
+ }
33
+ error = true
34
+ } else {
35
+ if (
36
+ Brick.schema.mapExternalDataToProps &&
37
+ typeof Brick.schema.mapExternalDataToProps === 'function' &&
38
+ page?.externalData &&
39
+ typeof page.externalData === 'object'
40
+ ) {
41
+ blockProps = {
42
+ ...blockProps,
43
+ ...Brick.schema.mapExternalDataToProps(page.externalData, block.props),
44
+ }
45
+ }
46
+ }
47
+
48
+ function trimEndChar(str: string, charToRemove: string) {
49
+ return str.endsWith(charToRemove) ? str.slice(0, -1) : str
50
+ }
51
+
52
+ const pathname =
53
+ Astro.url.pathname === '/'
54
+ ? Astro.url.pathname
55
+ : trimEndChar(Astro.url.pathname || '', '/')
56
+
57
+ const isDev = import.meta.env.DEV
58
+ ---
59
+
60
+ {
61
+ error || !Brick ? (
62
+ ''
63
+ ) : blockProps['RB_PAGE_EMBED'] &&
64
+ blockProps['RB_PAGE_EMBED_CONTENT'] &&
65
+ blockProps['RB_PAGE_EMBED_CONTENT'].statusCode !== 404 &&
66
+ blockProps['RB_PAGE_EMBED_CONTENT'].error !== 'Not found' ? (
67
+ <PageViewer page={blockProps['RB_PAGE_EMBED_CONTENT']} main={false} />
68
+ ) : !Brick.schema.astroInteractivity ? (
69
+ <AstroBrick
70
+ blockProps={blockProps}
71
+ index={index}
72
+ itemsCount={itemsCount}
73
+ page={page}
74
+ block={block}
75
+ pathname={pathname}
76
+ />
77
+ ) : Brick.schema.astroInteractivity && isDev ? (
78
+ <AstroBrick
79
+ client:only
80
+ blockProps={blockProps}
81
+ index={index}
82
+ itemsCount={itemsCount}
83
+ page={page}
84
+ block={block}
85
+ pathname={pathname}
86
+ />
87
+ ) : Brick.schema.astroInteractivity === 'load' ||
88
+ Brick.schema.astroInteractivity.load === true ? (
89
+ <AstroBrick
90
+ client:load
91
+ blockProps={blockProps}
92
+ index={index}
93
+ itemsCount={itemsCount}
94
+ page={page}
95
+ block={block}
96
+ pathname={pathname}
97
+ />
98
+ ) : Brick.schema.astroInteractivity === 'idle' ||
99
+ Brick.schema.astroInteractivity.idle === true ? (
100
+ <AstroBrick
101
+ client:idle
102
+ blockProps={blockProps}
103
+ index={index}
104
+ itemsCount={itemsCount}
105
+ page={page}
106
+ block={block}
107
+ pathname={pathname}
108
+ />
109
+ ) : !!Brick.schema.astroInteractivity.idle?.timeout ? (
110
+ <AstroBrick
111
+ client:idle={{
112
+ timeout: Brick.schema.astroInteractivity.idle?.timeout,
113
+ }}
114
+ blockProps={blockProps}
115
+ index={index}
116
+ itemsCount={itemsCount}
117
+ page={page}
118
+ block={block}
119
+ pathname={pathname}
120
+ />
121
+ ) : Brick.schema.astroInteractivity === 'visible' ||
122
+ Brick.schema.astroInteractivity.visible === true ? (
123
+ <AstroBrick
124
+ client:visible
125
+ blockProps={blockProps}
126
+ index={index}
127
+ itemsCount={itemsCount}
128
+ page={page}
129
+ block={block}
130
+ pathname={pathname}
131
+ />
132
+ ) : !!Brick.schema.astroInteractivity.visible?.rootMargin ? (
133
+ <AstroBrick
134
+ client:visible={{
135
+ rootMargin: Brick.schema.astroInteractivity.visible?.rootMargin,
136
+ }}
137
+ blockProps={blockProps}
138
+ index={index}
139
+ itemsCount={itemsCount}
140
+ page={page}
141
+ block={block}
142
+ pathname={pathname}
143
+ />
144
+ ) : !!Brick.schema.astroInteractivity.media ? (
145
+ <AstroBrick
146
+ client:media={Brick.schema.astroInteractivity.media}
147
+ blockProps={blockProps}
148
+ index={index}
149
+ itemsCount={itemsCount}
150
+ page={page}
151
+ block={block}
152
+ pathname={pathname}
153
+ />
154
+ ) : !!Brick.schema.astroInteractivity.only ? (
155
+ <AstroBrick
156
+ client:only={Brick.schema.astroInteractivity.only}
157
+ blockProps={blockProps}
158
+ index={index}
159
+ itemsCount={itemsCount}
160
+ page={page}
161
+ block={block}
162
+ pathname={pathname}
163
+ />
164
+ ) : (
165
+ <AstroBrick
166
+ blockProps={blockProps}
167
+ index={index}
168
+ itemsCount={itemsCount}
169
+ page={page}
170
+ block={block}
171
+ pathname={pathname}
172
+ />
173
+ )
174
+ }
@@ -0,0 +1,56 @@
1
+ ---
2
+ import type { types } from 'react-bricks/astro'
3
+ import { ClickToEdit, reactBricksAstroStore } from 'react-bricks/astro'
4
+ import DynamicComponent from './DynamicComponent.astro'
5
+ import TemplateViewer from './TemplateViewer.astro'
6
+
7
+ interface Props {
8
+ page: types.Page
9
+ main?: boolean
10
+ }
11
+
12
+ let error = false
13
+ const { page, main } = Astro.props as Props
14
+
15
+ if (!page) {
16
+ console.error(`Page not found.`)
17
+ error = true
18
+ }
19
+
20
+ reactBricksAstroStore.setPage(page)
21
+
22
+ const pageType = reactBricksAstroStore.getPageType(page)
23
+
24
+ if (!pageType) {
25
+ console.error(`Unknown pageType ${page.type}.`)
26
+ error = true
27
+ }
28
+ ---
29
+
30
+ {
31
+ error ? (
32
+ ''
33
+ ) : pageType.template ? (
34
+ <TemplateViewer page={page} pageType={pageType} />
35
+ ) : (
36
+ (page?.content?.map((block: any, index: any) => (
37
+ <DynamicComponent
38
+ page={page}
39
+ key={`${block.id}-${index}`}
40
+ {...{ block }}
41
+ />
42
+ )) ?? null)
43
+ )
44
+ }
45
+ {
46
+ !!main && !!page ? (
47
+ <ClickToEdit
48
+ client:idle
49
+ customValues={page.customValues}
50
+ id={page.id}
51
+ language={page.language}
52
+ />
53
+ ) : (
54
+ ''
55
+ )
56
+ }
@@ -0,0 +1,40 @@
1
+ ---
2
+ import type { types } from 'react-bricks/astro'
3
+ import reactBricksAstroStore from '../../ReactBricks/reactBricksAstroStore'
4
+ import SlotViewer from './SlotViewer.astro'
5
+
6
+ interface Props {
7
+ page: types.Page
8
+ name: string
9
+ }
10
+
11
+ let error = false
12
+ const { page, name } = Astro.props as Props
13
+
14
+ reactBricksAstroStore.setPage(page)
15
+
16
+ if (!page) {
17
+ error = true
18
+ }
19
+
20
+ const pageType = reactBricksAstroStore.getPageType(page)
21
+
22
+ if (!pageType) {
23
+ console.error(`Unknown pageType ${page.type}.`)
24
+ error = true
25
+ }
26
+
27
+ if (!pageType?.template) {
28
+ console.error(`Page ${page.name} has no Template defined.`)
29
+ error = true
30
+ }
31
+
32
+ const slot = pageType?.template?.find((slot) => slot.slotName === name)
33
+
34
+ if (!slot) {
35
+ console.error(`Slot ${name} not found in ${pageType} page type.`)
36
+ error = true
37
+ }
38
+ ---
39
+
40
+ {error ? '' : <SlotViewer page={page} slotName={name} />}
@@ -0,0 +1,38 @@
1
+ ---
2
+ import type { types } from 'react-bricks/astro'
3
+ import DynamicComponent from './DynamicComponent.astro'
4
+
5
+ interface Props {
6
+ page: types.Page
7
+ slotName: string
8
+ }
9
+
10
+ let error = false
11
+ const { page, slotName } = Astro.props as Props
12
+
13
+ const slotBlock = page.content.find(
14
+ (block) =>
15
+ block.type === '__RB_TEMPLATE_SLOT' && block.props['slotName'] === slotName
16
+ )
17
+ if (!slotBlock) {
18
+ console.error(`Slot ${slotName} not found.`)
19
+ error = true
20
+ }
21
+ if (!slotBlock?.props['slotItems'] || !slotBlock?.props['slotItems'].length) {
22
+ error = true
23
+ }
24
+ ---
25
+
26
+ {
27
+ error
28
+ ? ''
29
+ : ((slotBlock?.props['slotItems'] as types.IContentBlock[]).map(
30
+ (block, index) => (
31
+ <DynamicComponent
32
+ page={page}
33
+ key={`${block.id}-${index}`}
34
+ {...{ block }}
35
+ />
36
+ )
37
+ ) ?? null)
38
+ }
@@ -0,0 +1,24 @@
1
+ ---
2
+ import type { types } from 'react-bricks/astro'
3
+ import SlotViewer from './SlotViewer.astro'
4
+
5
+ interface Props {
6
+ page: types.Page
7
+ pageType: types.IPageType
8
+ }
9
+ let error = false
10
+ const { page, pageType } = Astro.props as Props
11
+
12
+ if (!pageType.template || !pageType.template.length) {
13
+ console.error(`Template not found.`)
14
+ error = true
15
+ }
16
+ ---
17
+
18
+ {
19
+ error
20
+ ? ''
21
+ : pageType?.template?.map((slot) => (
22
+ <SlotViewer page={page} slotName={slot.slotName} />
23
+ ))
24
+ }
package/astro/index.js ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";require("intersection-observer");var e=require("../react-bricks-CXY4gR9A.js"),t=require("react"),r=require("../react-bricks-BgfLLAM0.js"),n=require("react-icons/fi"),o=require("../react-bricks-Bv9phTdZ.js");require("../react-bricks-DRIKzHUS.js"),require("classnames"),require("../react-bricks-1YD00zjF.js"),require("../react-bricks-DouXS5I0.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 t.createElement(t.Fragment,null,t.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 ")),t.createElement("a",{href:"https://reactbricks.com?utm_campaign=site-badge",target:"_blank",className:s},t.createElement("img",{src:"https://reactbricks.com/_next/static/media/reactbricks_icon.c57a7be4.svg",style:{width:18,height:18,marginRight:6}}),t.createElement("span",null,"Made in ",t.createElement("span",{className:"l"},"React Bricks"))))},c=r.reactBricksAstroStore.getBricks,l=r.reactBricksAstroStore.getPageValues,d=r.reactBricksAstroStore.getBlockValue,p=r.reactBricksAstroStore.isAdmin;r.reactBricksAstroStore.register,Object.defineProperty(exports,"types",{enumerable:!0,get:function(){return e.types}}),exports.File=r.File,exports.Image=r.Image,exports.Link=r.Link,exports.List=r.ListAstro,exports.Repeater=r.Repeater,exports.RichText=r.CompatibleRichText,exports.RichTextExt=r.RichText,exports.Text=r.Text,exports.reactBricksAstroStore=r.reactBricksAstroStore,exports.useAdminContext=r.useAdminContext,exports.usePageValues=r.usePageValues,exports.useReactBricksContext=r.useReactBricksContext,exports.useVisualEdit=r.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,d=void 0===l?"":l,p=e.__read(t.useState(r.reactBricksAstroStore.isRegistered()),2),u=p[0],f=p[1];if(t.useEffect((function(){return r.reactBricksAstroStore.__subscribeConfig((function(){f(!0)}))}),[]),"undefined"!=typeof window&&!u)return null;a&&r.reactBricksAstroStore.setPage(a);var x=r.reactBricksAstroStore.getBrick(c);return x?(r.reactBricksAstroStore.setPathname(d),t.createElement(x,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=i.customValues,c=i.id,l=i.language,d=e.__read(t.useState(!1),2),p=d[0],u=d[1],f=r.useReactBricksContext();if(t.useEffect((function(){u(!0)}),[]),!p)return null;var x=(null==s?void 0:s.___t)&&!o.isPaidPlan(null==s?void 0:s.___t)?t.createElement(a,null):null;if(!f)return x;var m,g=localStorage.getItem(e.AUTH_TOKEN_LS_KEY);if(g&&g.length>10&&g.startsWith("ey")){if((null==f?void 0:f.clickToEditSide)===e.types.ClickToEditSide.None)return x;var k=f||{navigate:function(){}},b=k.navigate,h=k.editorPath,E=k.clickToEditSide,_={};return E===e.types.ClickToEditSide.BottomRight&&(_.bottom=50,_.right=0,_.borderTopLeftRadius=999,_.borderBottomLeftRadius=999,_.transform="translate(8px,0)"),E===e.types.ClickToEditSide.BottomLeft&&(_.bottom=50,_.left=0,_.borderTopRightRadius=999,_.borderBottomRightRadius=999,_.transform="translate(-8px,0)"),E===e.types.ClickToEditSide.TopRight&&(_.top=50,_.right=0,_.borderTopLeftRadius=999,_.borderBottomLeftRadius=999,_.transform="translate(8px,0)"),E===e.types.ClickToEditSide.TopLeft&&(_.top=50,_.left=0,_.borderTopRightRadius=999,_.borderBottomRightRadius=999,_.transform="translate(-8px,0)"),t.createElement(t.Fragment,null,t.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 "),t.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:_,onClick:function(){return b("".concat(h,"?p=").concat(encodeURIComponent(c),"&l=").concat(l))}},t.createElement(n.FiEdit,null)),x)}return x},exports.getBlockValue=d,exports.getBricks=c,exports.getPageValues=l,exports.isAdmin=p;
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "react-bricks-astro",
3
+ "version": "4.7.0-alpha.0",
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
+ "./Slot.astro": "./Slot.astro",
17
+ "./SlotViewer.astro": "./SlotViewer.astro",
18
+ "./TemplateViewer.astro": "./TemplateViewer.astro"
19
+ }
20
+ }