@weaverse/react 0.6.15 → 0.6.18
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/index.d.ts +13 -2
- package/dist/index.js +405 -453
- package/dist/index.mjs +408 -456
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -34,232 +34,184 @@ var __objRest = (source, exclude) => {
|
|
|
34
34
|
import { Weaverse } from "@weaverse/core";
|
|
35
35
|
import { createContext } from "react";
|
|
36
36
|
|
|
37
|
-
// src/elements/base.tsx
|
|
38
|
-
import React from "react";
|
|
39
|
-
var BaseElement = React.forwardRef((_a, ref) => {
|
|
40
|
-
var _b = _a, { tag, children } = _b, props = __objRest(_b, ["tag", "children"]);
|
|
41
|
-
return React.createElement(tag, __spreadValues({
|
|
42
|
-
ref
|
|
43
|
-
}, props), children);
|
|
44
|
-
});
|
|
45
|
-
BaseElement.defaultProps = {
|
|
46
|
-
tag: "div",
|
|
47
|
-
style: {}
|
|
48
|
-
};
|
|
49
|
-
var schema = {
|
|
50
|
-
type: "base",
|
|
51
|
-
parentType: "container",
|
|
52
|
-
title: "Base",
|
|
53
|
-
settings: []
|
|
54
|
-
};
|
|
55
|
-
var base_default = BaseElement;
|
|
56
|
-
|
|
57
37
|
// src/elements/button.tsx
|
|
58
|
-
import * as
|
|
59
|
-
var Button =
|
|
60
|
-
const _a = props, {
|
|
38
|
+
import * as React from "react";
|
|
39
|
+
var Button = React.forwardRef((props, ref) => {
|
|
40
|
+
const _a = props, { openInNewTab, target, value } = _a, rest = __objRest(_a, ["openInNewTab", "target", "value"]);
|
|
61
41
|
if (target) {
|
|
62
|
-
return /* @__PURE__ */
|
|
42
|
+
return /* @__PURE__ */ React.createElement("a", __spreadProps(__spreadValues({
|
|
63
43
|
href: target,
|
|
64
|
-
target: openInNewTab ? "_blank" : "_self"
|
|
65
|
-
|
|
44
|
+
target: openInNewTab ? "_blank" : "_self",
|
|
45
|
+
rel: "noreferrer"
|
|
46
|
+
}, rest), {
|
|
66
47
|
ref
|
|
67
|
-
}
|
|
48
|
+
}), value);
|
|
68
49
|
}
|
|
69
|
-
return /* @__PURE__ */
|
|
50
|
+
return /* @__PURE__ */ React.createElement("button", __spreadValues({
|
|
70
51
|
ref
|
|
71
|
-
}, rest),
|
|
52
|
+
}, rest), value);
|
|
72
53
|
});
|
|
73
54
|
Button.defaultProps = {
|
|
74
|
-
value: "Shop now"
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
title: "Button",
|
|
55
|
+
value: "Shop now",
|
|
56
|
+
openInNewTab: false,
|
|
57
|
+
target: "",
|
|
78
58
|
type: "button",
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
{
|
|
88
|
-
type: "border"
|
|
89
|
-
},
|
|
90
|
-
{
|
|
91
|
-
type: "background"
|
|
92
|
-
},
|
|
93
|
-
{
|
|
94
|
-
type: "spacing"
|
|
95
|
-
}
|
|
96
|
-
],
|
|
97
|
-
settings: [],
|
|
98
|
-
toolbar: [
|
|
99
|
-
{
|
|
100
|
-
type: "delete"
|
|
101
|
-
},
|
|
102
|
-
{
|
|
103
|
-
type: "duplicate"
|
|
104
|
-
},
|
|
105
|
-
{
|
|
106
|
-
type: "link"
|
|
107
|
-
},
|
|
108
|
-
{
|
|
109
|
-
type: "color"
|
|
59
|
+
css: {
|
|
60
|
+
"@desktop": {
|
|
61
|
+
borderRadius: "72px",
|
|
62
|
+
border: "none",
|
|
63
|
+
backgroundColor: "#0F71FF",
|
|
64
|
+
color: "#fff",
|
|
65
|
+
fontSize: "13px",
|
|
66
|
+
padding: "10px 20px"
|
|
110
67
|
}
|
|
111
|
-
],
|
|
112
|
-
data: {
|
|
113
|
-
css: {
|
|
114
|
-
"@desktop": {
|
|
115
|
-
borderRadius: "72px",
|
|
116
|
-
border: "none",
|
|
117
|
-
backgroundColor: "#0F71FF",
|
|
118
|
-
color: "#fff",
|
|
119
|
-
fontSize: "13px",
|
|
120
|
-
padding: "10px 20px"
|
|
121
|
-
}
|
|
122
|
-
},
|
|
123
|
-
target: "",
|
|
124
|
-
openInNewTab: false
|
|
125
|
-
},
|
|
126
|
-
flags: {
|
|
127
|
-
draggable: true
|
|
128
68
|
}
|
|
129
69
|
};
|
|
130
70
|
var button_default = Button;
|
|
131
71
|
|
|
132
72
|
// src/elements/container.tsx
|
|
133
|
-
import
|
|
73
|
+
import React2, { forwardRef as forwardRef2 } from "react";
|
|
134
74
|
var Container = forwardRef2((props, ref) => {
|
|
135
|
-
return /* @__PURE__ */
|
|
75
|
+
return /* @__PURE__ */ React2.createElement("div", __spreadValues({
|
|
136
76
|
ref
|
|
137
77
|
}, props));
|
|
138
78
|
});
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
"
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
gridArea: "1 / 1 / 3 / 6",
|
|
153
|
-
width: "100%",
|
|
154
|
-
height: "fit-content"
|
|
155
|
-
}
|
|
79
|
+
Container.defaultProps = {
|
|
80
|
+
css: {
|
|
81
|
+
"@desktop": {
|
|
82
|
+
alignItems: "flex-start",
|
|
83
|
+
backgroundColor: "rgba(248,203,203,0.38)",
|
|
84
|
+
display: "flex",
|
|
85
|
+
flexDirection: "column",
|
|
86
|
+
gridArea: "1 / 1 / 3 / 6",
|
|
87
|
+
height: "fit-content",
|
|
88
|
+
justifyContent: "flex-start",
|
|
89
|
+
overflow: "hidden",
|
|
90
|
+
textAlign: "left",
|
|
91
|
+
width: "100%"
|
|
156
92
|
}
|
|
157
|
-
},
|
|
158
|
-
settings: [],
|
|
159
|
-
flags: {
|
|
160
|
-
draggable: true,
|
|
161
|
-
resizable: true,
|
|
162
|
-
sortable: true
|
|
163
93
|
}
|
|
164
94
|
};
|
|
165
95
|
var container_default = Container;
|
|
166
96
|
|
|
167
|
-
// src/elements/
|
|
168
|
-
import React4, { forwardRef as forwardRef3 } from "react";
|
|
169
|
-
var Layout = forwardRef3((props, ref) => {
|
|
170
|
-
const _a = props, { css, children, rows, gap, rowSize, columns, gridSize } = _a, rest = __objRest(_a, ["css", "children", "rows", "gap", "rowSize", "columns", "gridSize"]);
|
|
171
|
-
return /* @__PURE__ */ React4.createElement("section", __spreadValues({
|
|
172
|
-
ref,
|
|
173
|
-
style: {
|
|
174
|
-
"--grid-size": gridSize + "px",
|
|
175
|
-
"--rows": rows,
|
|
176
|
-
"--columns": columns,
|
|
177
|
-
"--gap": gap + "px",
|
|
178
|
-
"--row-size": rowSize + "px",
|
|
179
|
-
"--col-size": "calc((var(--grid-size) - calc(var(--columns) - 1) * var(--gap)) / var(--columns))"
|
|
180
|
-
}
|
|
181
|
-
}, rest), /* @__PURE__ */ React4.createElement("div", {
|
|
182
|
-
"data-layout-content": true
|
|
183
|
-
}, children));
|
|
184
|
-
});
|
|
185
|
-
var schema4 = {
|
|
186
|
-
title: "Layout",
|
|
187
|
-
type: "layout",
|
|
188
|
-
parentType: "root",
|
|
189
|
-
data: {
|
|
190
|
-
css: {
|
|
191
|
-
"@desktop": {
|
|
192
|
-
paddingTop: "16px",
|
|
193
|
-
paddingBottom: "16px",
|
|
194
|
-
paddingLeft: "var(--gap)",
|
|
195
|
-
paddingRight: "var(--gap)",
|
|
196
|
-
"> [data-layout-content]": {
|
|
197
|
-
margin: "0 auto",
|
|
198
|
-
display: "grid !important",
|
|
199
|
-
gridTemplateRows: "repeat(var(--rows), var(--row-size))",
|
|
200
|
-
gridTemplateColumns: "repeat(var(--columns), minmax(0, var(--col-size)))",
|
|
201
|
-
gap: "var(--gap)",
|
|
202
|
-
maxWidth: "var(--grid-size)"
|
|
203
|
-
}
|
|
204
|
-
},
|
|
205
|
-
"@mobile": {
|
|
206
|
-
padding: "0 16px",
|
|
207
|
-
"> [data-layout-content]": {
|
|
208
|
-
display: "flex !important",
|
|
209
|
-
flexDirection: "column"
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
},
|
|
213
|
-
gridSize: 1224,
|
|
214
|
-
rows: 12,
|
|
215
|
-
columns: 12,
|
|
216
|
-
gap: 16,
|
|
217
|
-
rowSize: 48
|
|
218
|
-
},
|
|
219
|
-
settings: []
|
|
220
|
-
};
|
|
221
|
-
var layout_default = Layout;
|
|
97
|
+
// src/elements/countdown/index.tsx
|
|
98
|
+
import React4, { forwardRef as forwardRef3, useContext, useEffect } from "react";
|
|
222
99
|
|
|
223
|
-
// src/elements/
|
|
224
|
-
import
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
100
|
+
// src/elements/countdown/timer-block.tsx
|
|
101
|
+
import React3 from "react";
|
|
102
|
+
function TimerBlock({ value, label }) {
|
|
103
|
+
return /* @__PURE__ */ React3.createElement("div", null, /* @__PURE__ */ React3.createElement("div", {
|
|
104
|
+
className: "wv-countdown-number"
|
|
105
|
+
}, value.toString().padStart(2, "0")), label && /* @__PURE__ */ React3.createElement("div", {
|
|
106
|
+
className: "wv-countdown-label"
|
|
107
|
+
}, label));
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// src/elements/countdown/utils.ts
|
|
111
|
+
var times = ["days", "hours", "minutes", "seconds"];
|
|
112
|
+
function getTime(_seconds) {
|
|
113
|
+
const ONE_MINUTE = 60 * 1e3;
|
|
114
|
+
const ONE_HOUR = 60 * ONE_MINUTE;
|
|
115
|
+
const ONE_DAY = 24 * ONE_HOUR;
|
|
116
|
+
const days = Math.floor(_seconds / ONE_DAY);
|
|
117
|
+
const hours = Math.floor((_seconds - days * ONE_DAY) / ONE_HOUR);
|
|
118
|
+
const minutes = Math.floor((_seconds - days * ONE_DAY - hours * ONE_HOUR) / ONE_MINUTE);
|
|
119
|
+
const seconds = Math.floor((_seconds - days * ONE_DAY - hours * ONE_HOUR - minutes * ONE_MINUTE) / 1e3);
|
|
120
|
+
return { days, hours, minutes, seconds };
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// src/elements/countdown/index.tsx
|
|
124
|
+
var Countdown = forwardRef3((props, ref) => {
|
|
125
|
+
const { isDesignMode } = useContext(WeaverseContext);
|
|
126
|
+
let _a = props, {
|
|
127
|
+
timerType,
|
|
128
|
+
startTime,
|
|
129
|
+
endTime,
|
|
130
|
+
periods,
|
|
131
|
+
redirectUrl,
|
|
132
|
+
openInNewTab,
|
|
133
|
+
showColon,
|
|
134
|
+
showLabel
|
|
135
|
+
} = _a, rest = __objRest(_a, [
|
|
136
|
+
"timerType",
|
|
137
|
+
"startTime",
|
|
138
|
+
"endTime",
|
|
139
|
+
"periods",
|
|
140
|
+
"redirectUrl",
|
|
141
|
+
"openInNewTab",
|
|
142
|
+
"showColon",
|
|
143
|
+
"showLabel"
|
|
144
|
+
]);
|
|
145
|
+
const [remaining, setRemaining] = React4.useState(0);
|
|
146
|
+
if (typeof endTime !== "number") {
|
|
147
|
+
endTime = Number.parseInt(endTime);
|
|
148
|
+
}
|
|
149
|
+
useEffect(() => {
|
|
150
|
+
const flag = setInterval(() => {
|
|
151
|
+
const remainingTime = Math.max((timerType === "specific" ? new Date(endTime).getTime() : new Date(startTime).getTime() + periods * 60 * 1e3) - Date.now(), 0);
|
|
152
|
+
if (!isDesignMode && redirectUrl && remainingTime > 0 && remainingTime < 1e3) {
|
|
153
|
+
window.open(redirectUrl, openInNewTab ? "_blank" : "_self");
|
|
154
|
+
}
|
|
155
|
+
setRemaining(remainingTime);
|
|
156
|
+
}, 1e3);
|
|
157
|
+
return () => {
|
|
158
|
+
clearInterval(flag);
|
|
159
|
+
};
|
|
160
|
+
}, [startTime, endTime, periods, timerType]);
|
|
161
|
+
const timer = getTime(remaining);
|
|
162
|
+
return /* @__PURE__ */ React4.createElement("div", __spreadValues({
|
|
228
163
|
ref
|
|
229
|
-
}, rest), {
|
|
230
|
-
|
|
164
|
+
}, rest), times.map((time) => {
|
|
165
|
+
return /* @__PURE__ */ React4.createElement(React4.Fragment, {
|
|
166
|
+
key: time
|
|
167
|
+
}, /* @__PURE__ */ React4.createElement(TimerBlock, {
|
|
168
|
+
label: showLabel ? time : "",
|
|
169
|
+
value: timer[time]
|
|
170
|
+
}), time !== "seconds" && /* @__PURE__ */ React4.createElement("span", {
|
|
171
|
+
className: `wv-countdown-number ${showColon ? "" : "hidden"}`
|
|
172
|
+
}, ":"));
|
|
231
173
|
}));
|
|
232
174
|
});
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
175
|
+
Countdown.defaultProps = {
|
|
176
|
+
timerType: "specific",
|
|
177
|
+
startTime: Date.now(),
|
|
178
|
+
endTime: 1661140528e3,
|
|
179
|
+
periods: 90,
|
|
180
|
+
redirectUrl: "https://myshop.com",
|
|
181
|
+
openInNewTab: false,
|
|
182
|
+
showLabel: true,
|
|
183
|
+
showColon: true,
|
|
184
|
+
css: {
|
|
185
|
+
"@desktop": {
|
|
186
|
+
fontFamily: "Inter",
|
|
187
|
+
fontSize: 36,
|
|
188
|
+
fontWeight: 500,
|
|
189
|
+
display: "grid",
|
|
190
|
+
gridAutoFlow: "column",
|
|
191
|
+
gap: 10,
|
|
192
|
+
"& > div": {
|
|
193
|
+
width: 48,
|
|
194
|
+
textAlign: "center"
|
|
195
|
+
},
|
|
196
|
+
"& .wv-countdown-label": {
|
|
197
|
+
fontSize: 10
|
|
198
|
+
},
|
|
199
|
+
"& > span": {
|
|
200
|
+
lineHeight: "100%"
|
|
201
|
+
},
|
|
202
|
+
"& .hidden": {
|
|
203
|
+
visibility: "hidden"
|
|
252
204
|
}
|
|
253
205
|
}
|
|
254
206
|
}
|
|
255
207
|
};
|
|
256
|
-
var
|
|
208
|
+
var countdown_default = Countdown;
|
|
257
209
|
|
|
258
210
|
// src/elements/image.tsx
|
|
259
|
-
import
|
|
260
|
-
var Image =
|
|
211
|
+
import React5 from "react";
|
|
212
|
+
var Image = React5.forwardRef((props, ref) => {
|
|
261
213
|
let _a = props, { src, alt, children } = _a, rest = __objRest(_a, ["src", "alt", "children"]);
|
|
262
|
-
return /* @__PURE__ */
|
|
214
|
+
return /* @__PURE__ */ React5.createElement("img", __spreadProps(__spreadValues({
|
|
263
215
|
ref
|
|
264
216
|
}, rest), {
|
|
265
217
|
alt,
|
|
@@ -268,101 +220,77 @@ var Image = React6.forwardRef(function Image2(props, ref) {
|
|
|
268
220
|
});
|
|
269
221
|
Image.defaultProps = {
|
|
270
222
|
src: "https://ucarecdn.com/1cdc9d39-ca62-492e-8ec7-f1a86b241a90/",
|
|
271
|
-
alt: "weaverse image element"
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
"@desktop": {
|
|
281
|
-
width: "100%",
|
|
282
|
-
height: "100%",
|
|
283
|
-
objectFit: "cover"
|
|
284
|
-
},
|
|
285
|
-
"@mobile": {
|
|
286
|
-
display: "block"
|
|
287
|
-
}
|
|
223
|
+
alt: "weaverse image element",
|
|
224
|
+
css: {
|
|
225
|
+
"@desktop": {
|
|
226
|
+
width: "100%",
|
|
227
|
+
height: "100%",
|
|
228
|
+
objectFit: "cover"
|
|
229
|
+
},
|
|
230
|
+
"@mobile": {
|
|
231
|
+
display: "block"
|
|
288
232
|
}
|
|
289
|
-
},
|
|
290
|
-
flags: {
|
|
291
|
-
resizable: true,
|
|
292
|
-
draggable: true,
|
|
293
|
-
sortable: true
|
|
294
233
|
}
|
|
295
234
|
};
|
|
296
235
|
var image_default = Image;
|
|
297
236
|
|
|
298
|
-
// src/elements/
|
|
299
|
-
import
|
|
300
|
-
var
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
if (isDesignMode) {
|
|
304
|
-
controls = false;
|
|
305
|
-
autoPlay = false;
|
|
306
|
-
}
|
|
307
|
-
console.info("9779 props", props, isDesignMode);
|
|
308
|
-
return /* @__PURE__ */ React7.createElement("video", __spreadValues({
|
|
237
|
+
// src/elements/layout.tsx
|
|
238
|
+
import React6, { forwardRef as forwardRef4 } from "react";
|
|
239
|
+
var Layout = forwardRef4((props, ref) => {
|
|
240
|
+
let _a = props, { children, rows, gap, rowSize, columns, gridSize } = _a, rest = __objRest(_a, ["children", "rows", "gap", "rowSize", "columns", "gridSize"]);
|
|
241
|
+
return /* @__PURE__ */ React6.createElement("section", __spreadValues({
|
|
309
242
|
ref,
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
243
|
+
style: {
|
|
244
|
+
"--grid-size": gridSize + "px",
|
|
245
|
+
"--rows": rows,
|
|
246
|
+
"--columns": columns,
|
|
247
|
+
"--gap": gap + "px",
|
|
248
|
+
"--row-size": rowSize + "px",
|
|
249
|
+
"--col-size": "calc((var(--grid-size) - calc(var(--columns) - 1) * var(--gap)) / var(--columns))"
|
|
250
|
+
}
|
|
251
|
+
}, rest), /* @__PURE__ */ React6.createElement("div", {
|
|
252
|
+
"data-layout-content": true
|
|
253
|
+
}, children));
|
|
320
254
|
});
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
var
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
type: "duplicate"
|
|
342
|
-
},
|
|
343
|
-
{
|
|
344
|
-
type: "link"
|
|
255
|
+
Layout.defaultProps = {
|
|
256
|
+
gridSize: 1224,
|
|
257
|
+
rows: 12,
|
|
258
|
+
columns: 12,
|
|
259
|
+
gap: 16,
|
|
260
|
+
rowSize: 48,
|
|
261
|
+
css: {
|
|
262
|
+
"@desktop": {
|
|
263
|
+
paddingTop: "16px",
|
|
264
|
+
paddingBottom: "16px",
|
|
265
|
+
paddingLeft: "var(--gap)",
|
|
266
|
+
paddingRight: "var(--gap)",
|
|
267
|
+
"> [data-layout-content]": {
|
|
268
|
+
margin: "0 auto",
|
|
269
|
+
display: "grid !important",
|
|
270
|
+
gridTemplateRows: "repeat(var(--rows), var(--row-size))",
|
|
271
|
+
gridTemplateColumns: "repeat(var(--columns), minmax(0, var(--col-size)))",
|
|
272
|
+
gap: "var(--gap)",
|
|
273
|
+
maxWidth: "var(--grid-size)"
|
|
274
|
+
}
|
|
345
275
|
},
|
|
346
|
-
{
|
|
347
|
-
|
|
276
|
+
"@mobile": {
|
|
277
|
+
padding: "0 16px",
|
|
278
|
+
"> [data-layout-content]": {
|
|
279
|
+
display: "flex !important",
|
|
280
|
+
flexDirection: "column"
|
|
281
|
+
}
|
|
348
282
|
}
|
|
349
|
-
],
|
|
350
|
-
flags: {
|
|
351
|
-
resizable: true,
|
|
352
|
-
draggable: true,
|
|
353
|
-
sortable: true
|
|
354
283
|
}
|
|
355
284
|
};
|
|
356
|
-
var
|
|
285
|
+
var layout_default = Layout;
|
|
357
286
|
|
|
358
287
|
// src/elements/map.tsx
|
|
359
|
-
import
|
|
360
|
-
var Map =
|
|
361
|
-
const { place, zoom } =
|
|
362
|
-
|
|
363
|
-
return /* @__PURE__ */ React8.createElement("div", __spreadValues({
|
|
288
|
+
import React7, { forwardRef as forwardRef5 } from "react";
|
|
289
|
+
var Map = forwardRef5((props, ref) => {
|
|
290
|
+
const _a = props, { place, zoom } = _a, rest = __objRest(_a, ["place", "zoom"]);
|
|
291
|
+
return /* @__PURE__ */ React7.createElement("div", __spreadValues({
|
|
364
292
|
ref
|
|
365
|
-
},
|
|
293
|
+
}, rest), /* @__PURE__ */ React7.createElement("iframe", {
|
|
366
294
|
loading: "lazy",
|
|
367
295
|
scrolling: "no",
|
|
368
296
|
width: "100%",
|
|
@@ -376,203 +304,224 @@ var Map = forwardRef6((props, ref) => {
|
|
|
376
304
|
});
|
|
377
305
|
Map.defaultProps = {
|
|
378
306
|
place: "Hanoi",
|
|
379
|
-
zoom: 14
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
type: "map",
|
|
384
|
-
parentType: "layout",
|
|
385
|
-
toolbar: [
|
|
386
|
-
{
|
|
387
|
-
type: "delete"
|
|
388
|
-
},
|
|
389
|
-
{
|
|
390
|
-
type: "duplicate"
|
|
391
|
-
},
|
|
392
|
-
{
|
|
393
|
-
type: "link"
|
|
394
|
-
},
|
|
395
|
-
{
|
|
396
|
-
type: "color"
|
|
307
|
+
zoom: 14,
|
|
308
|
+
css: {
|
|
309
|
+
"@desktop": {
|
|
310
|
+
gridArea: "1 / 1 / 11 / 13"
|
|
397
311
|
}
|
|
398
|
-
],
|
|
399
|
-
data: {
|
|
400
|
-
css: {
|
|
401
|
-
"@desktop": {
|
|
402
|
-
gridArea: "1 / 1 / 11 / 13"
|
|
403
|
-
}
|
|
404
|
-
}
|
|
405
|
-
},
|
|
406
|
-
flags: {
|
|
407
|
-
resizable: true,
|
|
408
|
-
draggable: true,
|
|
409
|
-
sortable: true
|
|
410
312
|
}
|
|
411
313
|
};
|
|
412
314
|
var map_default = Map;
|
|
413
315
|
|
|
414
|
-
// src/elements/
|
|
415
|
-
import
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
316
|
+
// src/elements/text.tsx
|
|
317
|
+
import * as React8 from "react";
|
|
318
|
+
var Text = React8.forwardRef((props, ref) => {
|
|
319
|
+
let _a = props, { children, value } = _a, rest = __objRest(_a, ["children", "value"]);
|
|
320
|
+
return /* @__PURE__ */ React8.createElement("div", __spreadProps(__spreadValues({
|
|
321
|
+
ref
|
|
322
|
+
}, rest), {
|
|
323
|
+
dangerouslySetInnerHTML: { __html: value }
|
|
324
|
+
}));
|
|
325
|
+
});
|
|
326
|
+
Text.defaultProps = {
|
|
327
|
+
value: "The quick brown fox jumps over the lazy dog",
|
|
328
|
+
css: {
|
|
329
|
+
"@desktop": {
|
|
330
|
+
width: "100%",
|
|
331
|
+
height: "fit-content",
|
|
332
|
+
padding: 0,
|
|
333
|
+
margin: 0,
|
|
334
|
+
outline: "none",
|
|
335
|
+
wordBreak: "break-word",
|
|
336
|
+
overflowWrap: "break-word",
|
|
337
|
+
whiteSpace: "break-spaces"
|
|
338
|
+
}
|
|
339
|
+
}
|
|
435
340
|
};
|
|
436
|
-
var
|
|
341
|
+
var text_default = Text;
|
|
437
342
|
|
|
438
|
-
// src/elements/
|
|
439
|
-
|
|
343
|
+
// src/elements/video.tsx
|
|
344
|
+
import React9, { forwardRef as forwardRef7, useContext as useContext2 } from "react";
|
|
345
|
+
var Video = forwardRef7((props, ref) => {
|
|
440
346
|
const { isDesignMode } = useContext2(WeaverseContext);
|
|
441
|
-
let
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
347
|
+
let _a = props, { src, type, controls, poster, autoPlay, loop, muted } = _a, rest = __objRest(_a, ["src", "type", "controls", "poster", "autoPlay", "loop", "muted"]);
|
|
348
|
+
return /* @__PURE__ */ React9.createElement("video", __spreadValues({
|
|
349
|
+
ref,
|
|
350
|
+
controls: isDesignMode ? false : controls,
|
|
351
|
+
autoPlay: isDesignMode ? false : autoPlay,
|
|
352
|
+
loop,
|
|
353
|
+
muted: true,
|
|
354
|
+
controlsList: "nodownload",
|
|
355
|
+
disablePictureInPicture: true
|
|
356
|
+
}, rest), /* @__PURE__ */ React9.createElement("source", {
|
|
357
|
+
src,
|
|
358
|
+
type: type || "video/mp4"
|
|
359
|
+
}));
|
|
360
|
+
});
|
|
361
|
+
Video.defaultProps = {
|
|
362
|
+
src: "https://ucarecdn.com/7cae0dab-8966-4484-9998-602728c360ca/IMG_0048.MOV",
|
|
363
|
+
poster: "https://ucarecdn.com/48d73272-3fe3-43f6-8b5b-22b68fc5a8c8/section.png",
|
|
364
|
+
loop: false,
|
|
365
|
+
type: "video/mp4",
|
|
366
|
+
controls: false,
|
|
367
|
+
autoPlay: true,
|
|
368
|
+
muted: true,
|
|
369
|
+
css: {
|
|
370
|
+
"@desktop": {
|
|
371
|
+
height: "fit-content",
|
|
372
|
+
margin: 0,
|
|
373
|
+
outline: "none",
|
|
374
|
+
overflowWrap: "break-word",
|
|
375
|
+
padding: 0,
|
|
376
|
+
whitespace: "break-spaces",
|
|
377
|
+
width: "100%",
|
|
378
|
+
wordBreak: "break-word"
|
|
379
|
+
}
|
|
445
380
|
}
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
381
|
+
};
|
|
382
|
+
var video_default = Video;
|
|
383
|
+
|
|
384
|
+
// src/elements/instagram.tsx
|
|
385
|
+
import React11, { forwardRef as forwardRef9, useContext as useContext3, useEffect as useEffect2, useState } from "react";
|
|
386
|
+
|
|
387
|
+
// src/elements/shared/Placeholder.tsx
|
|
388
|
+
import React10, { forwardRef as forwardRef8 } from "react";
|
|
389
|
+
var Placeholder = forwardRef8((props, ref) => {
|
|
390
|
+
let _a = props, { element, children } = _a, rest = __objRest(_a, ["element", "children"]);
|
|
391
|
+
let style = {
|
|
392
|
+
height: "100%",
|
|
393
|
+
display: "flex",
|
|
394
|
+
flexDirection: "column",
|
|
395
|
+
alignItems: "center",
|
|
396
|
+
justifyContent: "center",
|
|
397
|
+
color: "#374151"
|
|
398
|
+
};
|
|
459
399
|
return /* @__PURE__ */ React10.createElement("div", __spreadValues({
|
|
400
|
+
style,
|
|
460
401
|
ref
|
|
461
|
-
},
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
}), /* @__PURE__ */ React10.createElement("span", {
|
|
465
|
-
className: !showColon && "hidden"
|
|
466
|
-
}, ":"), /* @__PURE__ */ React10.createElement(timer_block_default, {
|
|
467
|
-
value: timer.hours,
|
|
468
|
-
label: showLabel && "hours"
|
|
469
|
-
}), /* @__PURE__ */ React10.createElement("span", {
|
|
470
|
-
className: !showColon && "hidden"
|
|
471
|
-
}, ":"), /* @__PURE__ */ React10.createElement(timer_block_default, {
|
|
472
|
-
value: timer.mins,
|
|
473
|
-
label: showLabel && "minutes"
|
|
474
|
-
}), /* @__PURE__ */ React10.createElement("span", {
|
|
475
|
-
className: !showColon && "hidden"
|
|
476
|
-
}, ":"), /* @__PURE__ */ React10.createElement(timer_block_default, {
|
|
477
|
-
value: timer.secs,
|
|
478
|
-
label: showLabel && "seconds"
|
|
479
|
-
}));
|
|
402
|
+
}, rest), /* @__PURE__ */ React10.createElement("div", {
|
|
403
|
+
style: { fontWeight: 600, marginBottom: "10px" }
|
|
404
|
+
}, element), /* @__PURE__ */ React10.createElement("div", null, children));
|
|
480
405
|
});
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
};
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
{
|
|
505
|
-
type: "color"
|
|
406
|
+
var Placeholder_default = Placeholder;
|
|
407
|
+
|
|
408
|
+
// src/elements/instagram.tsx
|
|
409
|
+
var INSTAGRAM_API = "https://graph.instagram.com";
|
|
410
|
+
var Instagram = forwardRef9((props, ref) => {
|
|
411
|
+
const _a = props, { token, username, numberOfImages, imagesPerRow, gap } = _a, rest = __objRest(_a, ["token", "username", "numberOfImages", "imagesPerRow", "gap"]);
|
|
412
|
+
const [media, setMedia] = useState([]);
|
|
413
|
+
const [error, setError] = useState(null);
|
|
414
|
+
let { isDesignMode } = useContext3(WeaverseContext);
|
|
415
|
+
useEffect2(() => {
|
|
416
|
+
if (token) {
|
|
417
|
+
let params = new URLSearchParams({
|
|
418
|
+
access_token: token,
|
|
419
|
+
fields: "id,media_type,caption,media_url,permalink"
|
|
420
|
+
});
|
|
421
|
+
fetch(`${INSTAGRAM_API}/me/media?${params.toString()}`).then((res) => res.json()).then((res) => {
|
|
422
|
+
if (res.error) {
|
|
423
|
+
setError(res);
|
|
424
|
+
} else {
|
|
425
|
+
setError(null);
|
|
426
|
+
setMedia([...res.data]);
|
|
427
|
+
}
|
|
428
|
+
}).catch(console.error);
|
|
506
429
|
}
|
|
507
|
-
]
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
430
|
+
}, [token]);
|
|
431
|
+
if (!token || error) {
|
|
432
|
+
return /* @__PURE__ */ React11.createElement("div", __spreadValues({
|
|
433
|
+
ref
|
|
434
|
+
}, rest), /* @__PURE__ */ React11.createElement(Placeholder_default, {
|
|
435
|
+
element: "Instagram"
|
|
436
|
+
}, !token ? "Connect your Instagram account to display photos on your site." : "Invalid or expired token!"));
|
|
437
|
+
}
|
|
438
|
+
let style = {
|
|
439
|
+
"--wv-ig-images-per-row": imagesPerRow,
|
|
440
|
+
"--wv-ig-images-gap": gap
|
|
441
|
+
};
|
|
442
|
+
return /* @__PURE__ */ React11.createElement("div", __spreadProps(__spreadValues({
|
|
443
|
+
ref
|
|
444
|
+
}, rest), {
|
|
445
|
+
style
|
|
446
|
+
}), /* @__PURE__ */ React11.createElement("div", {
|
|
447
|
+
className: "wv-ig-media-wrapper"
|
|
448
|
+
}, media.slice(0, numberOfImages).map((item) => {
|
|
449
|
+
let linkProps;
|
|
450
|
+
if (!isDesignMode) {
|
|
451
|
+
linkProps = { href: item.permalink, target: "_blank" };
|
|
452
|
+
}
|
|
453
|
+
return /* @__PURE__ */ React11.createElement("a", __spreadValues({
|
|
454
|
+
key: item.id
|
|
455
|
+
}, linkProps), /* @__PURE__ */ React11.createElement("img", {
|
|
456
|
+
alt: item.caption,
|
|
457
|
+
src: item.media_url
|
|
458
|
+
}));
|
|
459
|
+
})));
|
|
460
|
+
});
|
|
461
|
+
Instagram.defaultProps = {
|
|
462
|
+
token: "",
|
|
463
|
+
username: "",
|
|
464
|
+
numberOfImages: 8,
|
|
465
|
+
imagesPerRow: 4,
|
|
466
|
+
gap: 0,
|
|
467
|
+
css: {
|
|
468
|
+
"@desktop": {
|
|
469
|
+
".wv-ig-media-wrapper": {
|
|
470
|
+
overflow: "hidden",
|
|
471
|
+
maxWidth: "100%",
|
|
472
|
+
maxHeight: "100%",
|
|
514
473
|
display: "grid",
|
|
515
|
-
|
|
516
|
-
gap:
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
fontSize: 10
|
|
523
|
-
},
|
|
524
|
-
"& > span": {
|
|
525
|
-
lineHeight: "100%"
|
|
526
|
-
},
|
|
527
|
-
"& .hidden": {
|
|
528
|
-
visibility: "hidden"
|
|
474
|
+
gridTemplateColumns: "repeat(var(--wv-ig-images-per-row, 4), 1fr)",
|
|
475
|
+
gap: "var(--wv-ig-images-gap, 0px)",
|
|
476
|
+
img: {
|
|
477
|
+
aspectRatio: "1 / 1",
|
|
478
|
+
width: "100%",
|
|
479
|
+
height: "100%",
|
|
480
|
+
objectFit: "cover"
|
|
529
481
|
}
|
|
530
482
|
}
|
|
531
483
|
}
|
|
532
|
-
},
|
|
533
|
-
flags: {
|
|
534
|
-
draggable: true
|
|
535
484
|
}
|
|
536
485
|
};
|
|
537
|
-
var
|
|
486
|
+
var instagram_default = Instagram;
|
|
538
487
|
|
|
539
488
|
// src/elements/index.ts
|
|
540
489
|
var elements = {
|
|
490
|
+
Countdown: {
|
|
491
|
+
Component: countdown_default,
|
|
492
|
+
type: "countdown"
|
|
493
|
+
},
|
|
541
494
|
Button: {
|
|
542
495
|
Component: button_default,
|
|
543
|
-
|
|
544
|
-
},
|
|
545
|
-
BaseElement: {
|
|
546
|
-
Component: base_default,
|
|
547
|
-
schema
|
|
548
|
-
},
|
|
549
|
-
Text: {
|
|
550
|
-
Component: text_default,
|
|
551
|
-
schema: schema5
|
|
552
|
-
},
|
|
553
|
-
Layout: {
|
|
554
|
-
Component: layout_default,
|
|
555
|
-
schema: schema4
|
|
496
|
+
type: "button"
|
|
556
497
|
},
|
|
557
498
|
Container: {
|
|
558
499
|
Component: container_default,
|
|
559
|
-
|
|
500
|
+
type: "container"
|
|
560
501
|
},
|
|
561
502
|
Image: {
|
|
562
503
|
Component: image_default,
|
|
563
|
-
|
|
504
|
+
type: "image"
|
|
564
505
|
},
|
|
565
|
-
|
|
566
|
-
Component:
|
|
567
|
-
|
|
506
|
+
Instagram: {
|
|
507
|
+
Component: instagram_default,
|
|
508
|
+
type: "instagram"
|
|
509
|
+
},
|
|
510
|
+
Layout: {
|
|
511
|
+
Component: layout_default,
|
|
512
|
+
type: "layout"
|
|
568
513
|
},
|
|
569
514
|
Map: {
|
|
570
515
|
Component: map_default,
|
|
571
|
-
|
|
516
|
+
type: "map"
|
|
572
517
|
},
|
|
573
|
-
|
|
574
|
-
Component:
|
|
575
|
-
|
|
518
|
+
Text: {
|
|
519
|
+
Component: text_default,
|
|
520
|
+
type: "text"
|
|
521
|
+
},
|
|
522
|
+
Video: {
|
|
523
|
+
Component: video_default,
|
|
524
|
+
type: "video"
|
|
576
525
|
}
|
|
577
526
|
};
|
|
578
527
|
var elements_default = elements;
|
|
@@ -591,24 +540,25 @@ var WeaverseContextConsumer = WeaverseContext.Consumer;
|
|
|
591
540
|
|
|
592
541
|
// src/renderer.tsx
|
|
593
542
|
import { isBrowser } from "@weaverse/core";
|
|
594
|
-
import
|
|
543
|
+
import React12, { useContext as useContext4, useEffect as useEffect3, useRef, useState as useState2 } from "react";
|
|
595
544
|
|
|
596
545
|
// src/utils/index.ts
|
|
597
546
|
var shortCssObject = (css) => {
|
|
598
547
|
return {
|
|
599
|
-
"@desktop": css[
|
|
600
|
-
"@mobile": css[
|
|
548
|
+
"@desktop": css["@desktop"],
|
|
549
|
+
"@mobile": css["@mobile"]
|
|
601
550
|
};
|
|
602
551
|
};
|
|
603
552
|
function generateItemClass(instance, stitchesInstance) {
|
|
604
|
-
var _a;
|
|
553
|
+
var _a, _b, _c, _d;
|
|
605
554
|
let { css, className: cls = "" } = instance.data;
|
|
555
|
+
let defaultCss = ((_c = (_b = (_a = instance.Element) == null ? void 0 : _a.Component) == null ? void 0 : _b.defaultProps) == null ? void 0 : _c.css) || {};
|
|
606
556
|
let className = "";
|
|
607
|
-
if (css) {
|
|
608
|
-
let formattedCss = shortCssObject(css);
|
|
557
|
+
if (css || defaultCss) {
|
|
558
|
+
let formattedCss = shortCssObject(css || defaultCss);
|
|
609
559
|
let { className: newClass = "" } = stitchesInstance.css(formattedCss)();
|
|
610
560
|
let { stitchesClass } = instance;
|
|
611
|
-
let otherClass = (((
|
|
561
|
+
let otherClass = (((_d = instance.ref.current) == null ? void 0 : _d.className) || "").replace(stitchesClass, "").replace(cls, "").trim();
|
|
612
562
|
className = `${cls} ${newClass} ${otherClass}`.trim();
|
|
613
563
|
instance.stitchesClass = newClass;
|
|
614
564
|
}
|
|
@@ -618,9 +568,9 @@ function generateItemClass(instance, stitchesInstance) {
|
|
|
618
568
|
// src/renderer.tsx
|
|
619
569
|
var WeaverseRoot = ({ context }) => {
|
|
620
570
|
var _a;
|
|
621
|
-
let [, setData] =
|
|
571
|
+
let [, setData] = useState2(context.projectData);
|
|
622
572
|
let rootRef = useRef();
|
|
623
|
-
|
|
573
|
+
useEffect3(() => {
|
|
624
574
|
let update = () => setData({});
|
|
625
575
|
context.subscribe(update);
|
|
626
576
|
if (context.projectData) {
|
|
@@ -633,21 +583,22 @@ var WeaverseRoot = ({ context }) => {
|
|
|
633
583
|
}, []);
|
|
634
584
|
let eventHandlers = ((_a = context == null ? void 0 : context.studioBridge) == null ? void 0 : _a.eventHandlers) || {};
|
|
635
585
|
let themeClass = context.stitchesInstance.theme.className;
|
|
636
|
-
return /* @__PURE__ */
|
|
586
|
+
return /* @__PURE__ */ React12.createElement("div", __spreadProps(__spreadValues({
|
|
637
587
|
className: `weaverse-content-root ${themeClass}`
|
|
638
588
|
}, eventHandlers), {
|
|
639
589
|
ref: rootRef
|
|
640
|
-
}), /* @__PURE__ */
|
|
590
|
+
}), /* @__PURE__ */ React12.createElement(WeaverseContextProvider, {
|
|
641
591
|
value: context
|
|
642
|
-
}, /* @__PURE__ */
|
|
592
|
+
}, /* @__PURE__ */ React12.createElement(ItemInstance, {
|
|
643
593
|
id: context.projectData.rootId || 0
|
|
644
594
|
})));
|
|
645
595
|
};
|
|
646
596
|
var ItemComponent = ({ instance }) => {
|
|
647
|
-
let { stitchesInstance, elementInstances } =
|
|
648
|
-
let [data, setData] =
|
|
649
|
-
let _a = data, { id, type, childIds = [], css, className
|
|
650
|
-
|
|
597
|
+
let { stitchesInstance, elementInstances } = useContext4(WeaverseContext);
|
|
598
|
+
let [data, setData] = useState2(instance.data);
|
|
599
|
+
let _a = data, { id, type, childIds = [], css, className } = _a, rest = __objRest(_a, ["id", "type", "childIds", "css", "className"]);
|
|
600
|
+
useEffect3(() => {
|
|
601
|
+
var _a2;
|
|
651
602
|
let update = (data2) => setData(__spreadValues({}, data2));
|
|
652
603
|
instance.subscribe(update);
|
|
653
604
|
if (isBrowser && !instance.ref.current) {
|
|
@@ -655,22 +606,23 @@ var ItemComponent = ({ instance }) => {
|
|
|
655
606
|
current: document.querySelector(`[data-wv-id="${id}"]`)
|
|
656
607
|
});
|
|
657
608
|
}
|
|
609
|
+
(_a2 = instance.ref.current) == null ? void 0 : _a2.removeAttribute("css");
|
|
658
610
|
return () => {
|
|
659
611
|
instance.unsubscribe(update);
|
|
660
612
|
};
|
|
661
613
|
}, []);
|
|
662
|
-
let Element = elementInstances.get(type
|
|
614
|
+
let Element = elementInstances.get(type);
|
|
663
615
|
if (Element == null ? void 0 : Element.Component) {
|
|
664
616
|
let Component = Element.Component;
|
|
665
617
|
if (Component.$$typeof === Symbol.for("react.forward_ref")) {
|
|
666
618
|
rest.ref = instance.ref;
|
|
667
619
|
}
|
|
668
|
-
return /* @__PURE__ */
|
|
620
|
+
return /* @__PURE__ */ React12.createElement(Component, __spreadValues({
|
|
669
621
|
key: id,
|
|
670
622
|
"data-wv-type": type,
|
|
671
623
|
"data-wv-id": id,
|
|
672
624
|
className: generateItemClass(instance, stitchesInstance)
|
|
673
|
-
}, rest), childIds.map((id2) => /* @__PURE__ */
|
|
625
|
+
}, rest), childIds.map((id2) => /* @__PURE__ */ React12.createElement(ItemInstance, {
|
|
674
626
|
key: id2,
|
|
675
627
|
id: id2
|
|
676
628
|
})));
|
|
@@ -678,15 +630,15 @@ var ItemComponent = ({ instance }) => {
|
|
|
678
630
|
return null;
|
|
679
631
|
};
|
|
680
632
|
var ItemInstance = ({ id }) => {
|
|
681
|
-
let context =
|
|
633
|
+
let context = useContext4(WeaverseContext);
|
|
682
634
|
let { itemInstances } = context;
|
|
683
635
|
let instance = itemInstances.get(id);
|
|
684
636
|
if (!instance) {
|
|
685
|
-
return /* @__PURE__ */
|
|
637
|
+
return /* @__PURE__ */ React12.createElement("div", {
|
|
686
638
|
style: { display: "none" }
|
|
687
639
|
}, "Item instance ", id, " not found");
|
|
688
640
|
}
|
|
689
|
-
return /* @__PURE__ */
|
|
641
|
+
return /* @__PURE__ */ React12.createElement(ItemComponent, {
|
|
690
642
|
instance
|
|
691
643
|
});
|
|
692
644
|
};
|