@weaverse/react 0.6.16 → 0.6.17
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 +6 -2
- package/dist/index.js +336 -445
- package/dist/index.mjs +350 -459
- 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,212 +304,172 @@ 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
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
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
|
+
}
|
|
454
380
|
}
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
}
|
|
466
|
-
|
|
467
|
-
|
|
381
|
+
};
|
|
382
|
+
var video_default = Video;
|
|
383
|
+
|
|
384
|
+
// src/elements/instagram.tsx
|
|
385
|
+
import React10, { forwardRef as forwardRef8, useContext as useContext3, useEffect as useEffect2, useState } from "react";
|
|
386
|
+
var Instagram = forwardRef8((props, ref) => {
|
|
387
|
+
const { stitchesInstance } = useContext3(WeaverseContext);
|
|
388
|
+
const _a = props, { token, numberOfImages, imagesPerRow, className } = _a, rest = __objRest(_a, ["token", "numberOfImages", "imagesPerRow", "className"]);
|
|
389
|
+
const [media, setMedia] = useState([]);
|
|
390
|
+
useEffect2(() => {
|
|
391
|
+
const url = `https://graph.instagram.com/me/media?fields=id,media_type,caption,media_url&access_token=${token}`;
|
|
392
|
+
fetch(url).then((res) => res.json()).then((res) => {
|
|
393
|
+
setMedia(res.data);
|
|
394
|
+
});
|
|
395
|
+
}, [token]);
|
|
396
|
+
const css = {
|
|
397
|
+
gridTemplateColumns: `repeat(${imagesPerRow[0] || 1}, 1fr)`
|
|
398
|
+
};
|
|
399
|
+
const { className: instagramClass = "" } = stitchesInstance.css(css)();
|
|
468
400
|
return /* @__PURE__ */ React10.createElement("div", __spreadValues({
|
|
401
|
+
className: `${className} ${instagramClass}`,
|
|
469
402
|
ref
|
|
470
|
-
},
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
}, ":"), /* @__PURE__ */ React10.createElement(timer_block_default, {
|
|
481
|
-
value: timer.mins,
|
|
482
|
-
label: showLabel && "minutes"
|
|
483
|
-
}), /* @__PURE__ */ React10.createElement("span", {
|
|
484
|
-
className: !showColon && "hidden"
|
|
485
|
-
}, ":"), /* @__PURE__ */ React10.createElement(timer_block_default, {
|
|
486
|
-
value: timer.secs,
|
|
487
|
-
label: showLabel && "seconds"
|
|
403
|
+
}, rest), !token ? "Token is empty" : media.map((item, key) => {
|
|
404
|
+
return /* @__PURE__ */ React10.createElement("div", {
|
|
405
|
+
key,
|
|
406
|
+
className: "wv-instagram-item"
|
|
407
|
+
}, /* @__PURE__ */ React10.createElement("img", {
|
|
408
|
+
width: "100%",
|
|
409
|
+
height: "100%",
|
|
410
|
+
alt: item.caption,
|
|
411
|
+
src: item.media_url
|
|
412
|
+
}));
|
|
488
413
|
}));
|
|
489
414
|
});
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
{
|
|
505
|
-
type: "delete"
|
|
506
|
-
},
|
|
507
|
-
{
|
|
508
|
-
type: "duplicate"
|
|
509
|
-
},
|
|
510
|
-
{
|
|
511
|
-
type: "link"
|
|
512
|
-
},
|
|
513
|
-
{
|
|
514
|
-
type: "color"
|
|
515
|
-
}
|
|
516
|
-
],
|
|
517
|
-
data: {
|
|
518
|
-
css: {
|
|
519
|
-
"@desktop": {
|
|
520
|
-
fontFamily: "Inter",
|
|
521
|
-
fontSize: 36,
|
|
522
|
-
fontWeight: 500,
|
|
523
|
-
display: "grid",
|
|
524
|
-
gridAutoFlow: "column",
|
|
525
|
-
gap: 10,
|
|
526
|
-
"& > div": {
|
|
527
|
-
width: 48,
|
|
528
|
-
textAlign: "center"
|
|
529
|
-
},
|
|
530
|
-
"& .wv-countdown-label": {
|
|
531
|
-
fontSize: 10
|
|
532
|
-
},
|
|
533
|
-
"& > span": {
|
|
534
|
-
lineHeight: "100%"
|
|
535
|
-
},
|
|
536
|
-
"& .hidden": {
|
|
537
|
-
visibility: "hidden"
|
|
415
|
+
Instagram.defaultProps = {
|
|
416
|
+
token: "",
|
|
417
|
+
numberOfImages: [12],
|
|
418
|
+
imagesPerRow: [4],
|
|
419
|
+
css: {
|
|
420
|
+
"@desktop": {
|
|
421
|
+
display: "grid",
|
|
422
|
+
gridTemplateColumns: "repeat(4, 1fr)",
|
|
423
|
+
"& .wv-instagram-item": {
|
|
424
|
+
width: "100%",
|
|
425
|
+
height: "100%",
|
|
426
|
+
backgroundColor: "red",
|
|
427
|
+
"& img": {
|
|
428
|
+
objectFit: "contain"
|
|
538
429
|
}
|
|
539
430
|
}
|
|
540
431
|
}
|
|
541
|
-
},
|
|
542
|
-
flags: {
|
|
543
|
-
draggable: true
|
|
544
432
|
}
|
|
545
433
|
};
|
|
546
|
-
var
|
|
434
|
+
var instagram_default = Instagram;
|
|
547
435
|
|
|
548
436
|
// src/elements/index.ts
|
|
549
437
|
var elements = {
|
|
438
|
+
Countdown: {
|
|
439
|
+
Component: countdown_default,
|
|
440
|
+
type: "countdown"
|
|
441
|
+
},
|
|
550
442
|
Button: {
|
|
551
443
|
Component: button_default,
|
|
552
|
-
|
|
553
|
-
},
|
|
554
|
-
BaseElement: {
|
|
555
|
-
Component: base_default,
|
|
556
|
-
schema
|
|
557
|
-
},
|
|
558
|
-
Text: {
|
|
559
|
-
Component: text_default,
|
|
560
|
-
schema: schema5
|
|
561
|
-
},
|
|
562
|
-
Layout: {
|
|
563
|
-
Component: layout_default,
|
|
564
|
-
schema: schema4
|
|
444
|
+
type: "button"
|
|
565
445
|
},
|
|
566
446
|
Container: {
|
|
567
447
|
Component: container_default,
|
|
568
|
-
|
|
448
|
+
type: "container"
|
|
569
449
|
},
|
|
570
450
|
Image: {
|
|
571
451
|
Component: image_default,
|
|
572
|
-
|
|
452
|
+
type: "image"
|
|
573
453
|
},
|
|
574
|
-
|
|
575
|
-
Component:
|
|
576
|
-
|
|
454
|
+
Instagram: {
|
|
455
|
+
Component: instagram_default,
|
|
456
|
+
type: "instagram"
|
|
457
|
+
},
|
|
458
|
+
Layout: {
|
|
459
|
+
Component: layout_default,
|
|
460
|
+
type: "layout"
|
|
577
461
|
},
|
|
578
462
|
Map: {
|
|
579
463
|
Component: map_default,
|
|
580
|
-
|
|
464
|
+
type: "map"
|
|
581
465
|
},
|
|
582
|
-
|
|
583
|
-
Component:
|
|
584
|
-
|
|
466
|
+
Text: {
|
|
467
|
+
Component: text_default,
|
|
468
|
+
type: "text"
|
|
469
|
+
},
|
|
470
|
+
Video: {
|
|
471
|
+
Component: video_default,
|
|
472
|
+
type: "video"
|
|
585
473
|
}
|
|
586
474
|
};
|
|
587
475
|
var elements_default = elements;
|
|
@@ -600,24 +488,25 @@ var WeaverseContextConsumer = WeaverseContext.Consumer;
|
|
|
600
488
|
|
|
601
489
|
// src/renderer.tsx
|
|
602
490
|
import { isBrowser } from "@weaverse/core";
|
|
603
|
-
import React11, { useContext as
|
|
491
|
+
import React11, { useContext as useContext4, useEffect as useEffect3, useRef, useState as useState2 } from "react";
|
|
604
492
|
|
|
605
493
|
// src/utils/index.ts
|
|
606
494
|
var shortCssObject = (css) => {
|
|
607
495
|
return {
|
|
608
|
-
"@desktop": css[
|
|
609
|
-
"@mobile": css[
|
|
496
|
+
"@desktop": css["@desktop"],
|
|
497
|
+
"@mobile": css["@mobile"]
|
|
610
498
|
};
|
|
611
499
|
};
|
|
612
500
|
function generateItemClass(instance, stitchesInstance) {
|
|
613
|
-
var _a;
|
|
501
|
+
var _a, _b, _c, _d;
|
|
614
502
|
let { css, className: cls = "" } = instance.data;
|
|
503
|
+
let defaultCss = ((_c = (_b = (_a = instance.Element) == null ? void 0 : _a.Component) == null ? void 0 : _b.defaultProps) == null ? void 0 : _c.css) || {};
|
|
615
504
|
let className = "";
|
|
616
|
-
if (css) {
|
|
617
|
-
let formattedCss = shortCssObject(css);
|
|
505
|
+
if (css || defaultCss) {
|
|
506
|
+
let formattedCss = shortCssObject(css || defaultCss);
|
|
618
507
|
let { className: newClass = "" } = stitchesInstance.css(formattedCss)();
|
|
619
508
|
let { stitchesClass } = instance;
|
|
620
|
-
let otherClass = (((
|
|
509
|
+
let otherClass = (((_d = instance.ref.current) == null ? void 0 : _d.className) || "").replace(stitchesClass, "").replace(cls, "").trim();
|
|
621
510
|
className = `${cls} ${newClass} ${otherClass}`.trim();
|
|
622
511
|
instance.stitchesClass = newClass;
|
|
623
512
|
}
|
|
@@ -627,9 +516,9 @@ function generateItemClass(instance, stitchesInstance) {
|
|
|
627
516
|
// src/renderer.tsx
|
|
628
517
|
var WeaverseRoot = ({ context }) => {
|
|
629
518
|
var _a;
|
|
630
|
-
let [, setData] =
|
|
519
|
+
let [, setData] = useState2(context.projectData);
|
|
631
520
|
let rootRef = useRef();
|
|
632
|
-
|
|
521
|
+
useEffect3(() => {
|
|
633
522
|
let update = () => setData({});
|
|
634
523
|
context.subscribe(update);
|
|
635
524
|
if (context.projectData) {
|
|
@@ -653,10 +542,11 @@ var WeaverseRoot = ({ context }) => {
|
|
|
653
542
|
})));
|
|
654
543
|
};
|
|
655
544
|
var ItemComponent = ({ instance }) => {
|
|
656
|
-
let { stitchesInstance, elementInstances } =
|
|
657
|
-
let [data, setData] =
|
|
658
|
-
let _a = data, { id, type, childIds = [], css, className
|
|
659
|
-
|
|
545
|
+
let { stitchesInstance, elementInstances } = useContext4(WeaverseContext);
|
|
546
|
+
let [data, setData] = useState2(instance.data);
|
|
547
|
+
let _a = data, { id, type, childIds = [], css, className } = _a, rest = __objRest(_a, ["id", "type", "childIds", "css", "className"]);
|
|
548
|
+
useEffect3(() => {
|
|
549
|
+
var _a2;
|
|
660
550
|
let update = (data2) => setData(__spreadValues({}, data2));
|
|
661
551
|
instance.subscribe(update);
|
|
662
552
|
if (isBrowser && !instance.ref.current) {
|
|
@@ -664,11 +554,12 @@ var ItemComponent = ({ instance }) => {
|
|
|
664
554
|
current: document.querySelector(`[data-wv-id="${id}"]`)
|
|
665
555
|
});
|
|
666
556
|
}
|
|
557
|
+
(_a2 = instance.ref.current) == null ? void 0 : _a2.removeAttribute("css");
|
|
667
558
|
return () => {
|
|
668
559
|
instance.unsubscribe(update);
|
|
669
560
|
};
|
|
670
561
|
}, []);
|
|
671
|
-
let Element = elementInstances.get(type
|
|
562
|
+
let Element = elementInstances.get(type);
|
|
672
563
|
if (Element == null ? void 0 : Element.Component) {
|
|
673
564
|
let Component = Element.Component;
|
|
674
565
|
if (Component.$$typeof === Symbol.for("react.forward_ref")) {
|
|
@@ -687,7 +578,7 @@ var ItemComponent = ({ instance }) => {
|
|
|
687
578
|
return null;
|
|
688
579
|
};
|
|
689
580
|
var ItemInstance = ({ id }) => {
|
|
690
|
-
let context =
|
|
581
|
+
let context = useContext4(WeaverseContext);
|
|
691
582
|
let { itemInstances } = context;
|
|
692
583
|
let instance = itemInstances.get(id);
|
|
693
584
|
if (!instance) {
|