@weaverse/react 0.6.14 → 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 -436
- package/dist/index.mjs +350 -450
- 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,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"
|
|
397
|
-
}
|
|
398
|
-
],
|
|
399
|
-
data: {
|
|
400
|
-
css: {
|
|
401
|
-
"@desktop": {
|
|
402
|
-
gridArea: "1 / 1 / 11 / 13"
|
|
403
|
-
}
|
|
307
|
+
zoom: 14,
|
|
308
|
+
css: {
|
|
309
|
+
"@desktop": {
|
|
310
|
+
gridArea: "1 / 1 / 11 / 13"
|
|
404
311
|
}
|
|
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 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)();
|
|
459
400
|
return /* @__PURE__ */ React10.createElement("div", __spreadValues({
|
|
401
|
+
className: `${className} ${instagramClass}`,
|
|
460
402
|
ref
|
|
461
|
-
},
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
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"
|
|
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
|
+
}));
|
|
479
413
|
}));
|
|
480
414
|
});
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
{
|
|
496
|
-
type: "delete"
|
|
497
|
-
},
|
|
498
|
-
{
|
|
499
|
-
type: "duplicate"
|
|
500
|
-
},
|
|
501
|
-
{
|
|
502
|
-
type: "link"
|
|
503
|
-
},
|
|
504
|
-
{
|
|
505
|
-
type: "color"
|
|
506
|
-
}
|
|
507
|
-
],
|
|
508
|
-
data: {
|
|
509
|
-
css: {
|
|
510
|
-
"@desktop": {
|
|
511
|
-
fontFamily: "Inter",
|
|
512
|
-
fontSize: 36,
|
|
513
|
-
fontWeight: 500,
|
|
514
|
-
display: "grid",
|
|
515
|
-
gridAutoFlow: "column",
|
|
516
|
-
gap: 10,
|
|
517
|
-
"& > div": {
|
|
518
|
-
width: 48,
|
|
519
|
-
textAlign: "center"
|
|
520
|
-
},
|
|
521
|
-
"& .wv-countdown-label": {
|
|
522
|
-
fontSize: 10
|
|
523
|
-
},
|
|
524
|
-
"& > span": {
|
|
525
|
-
lineHeight: "100%"
|
|
526
|
-
},
|
|
527
|
-
"& .hidden": {
|
|
528
|
-
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"
|
|
529
429
|
}
|
|
530
430
|
}
|
|
531
431
|
}
|
|
532
|
-
},
|
|
533
|
-
flags: {
|
|
534
|
-
draggable: true
|
|
535
432
|
}
|
|
536
433
|
};
|
|
537
|
-
var
|
|
434
|
+
var instagram_default = Instagram;
|
|
538
435
|
|
|
539
436
|
// src/elements/index.ts
|
|
540
437
|
var elements = {
|
|
438
|
+
Countdown: {
|
|
439
|
+
Component: countdown_default,
|
|
440
|
+
type: "countdown"
|
|
441
|
+
},
|
|
541
442
|
Button: {
|
|
542
443
|
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
|
|
444
|
+
type: "button"
|
|
556
445
|
},
|
|
557
446
|
Container: {
|
|
558
447
|
Component: container_default,
|
|
559
|
-
|
|
448
|
+
type: "container"
|
|
560
449
|
},
|
|
561
450
|
Image: {
|
|
562
451
|
Component: image_default,
|
|
563
|
-
|
|
452
|
+
type: "image"
|
|
564
453
|
},
|
|
565
|
-
|
|
566
|
-
Component:
|
|
567
|
-
|
|
454
|
+
Instagram: {
|
|
455
|
+
Component: instagram_default,
|
|
456
|
+
type: "instagram"
|
|
457
|
+
},
|
|
458
|
+
Layout: {
|
|
459
|
+
Component: layout_default,
|
|
460
|
+
type: "layout"
|
|
568
461
|
},
|
|
569
462
|
Map: {
|
|
570
463
|
Component: map_default,
|
|
571
|
-
|
|
464
|
+
type: "map"
|
|
572
465
|
},
|
|
573
|
-
|
|
574
|
-
Component:
|
|
575
|
-
|
|
466
|
+
Text: {
|
|
467
|
+
Component: text_default,
|
|
468
|
+
type: "text"
|
|
469
|
+
},
|
|
470
|
+
Video: {
|
|
471
|
+
Component: video_default,
|
|
472
|
+
type: "video"
|
|
576
473
|
}
|
|
577
474
|
};
|
|
578
475
|
var elements_default = elements;
|
|
@@ -591,24 +488,25 @@ var WeaverseContextConsumer = WeaverseContext.Consumer;
|
|
|
591
488
|
|
|
592
489
|
// src/renderer.tsx
|
|
593
490
|
import { isBrowser } from "@weaverse/core";
|
|
594
|
-
import React11, { useContext as
|
|
491
|
+
import React11, { useContext as useContext4, useEffect as useEffect3, useRef, useState as useState2 } from "react";
|
|
595
492
|
|
|
596
493
|
// src/utils/index.ts
|
|
597
494
|
var shortCssObject = (css) => {
|
|
598
495
|
return {
|
|
599
|
-
"@desktop": css[
|
|
600
|
-
"@mobile": css[
|
|
496
|
+
"@desktop": css["@desktop"],
|
|
497
|
+
"@mobile": css["@mobile"]
|
|
601
498
|
};
|
|
602
499
|
};
|
|
603
500
|
function generateItemClass(instance, stitchesInstance) {
|
|
604
|
-
var _a;
|
|
501
|
+
var _a, _b, _c, _d;
|
|
605
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) || {};
|
|
606
504
|
let className = "";
|
|
607
|
-
if (css) {
|
|
608
|
-
let formattedCss = shortCssObject(css);
|
|
505
|
+
if (css || defaultCss) {
|
|
506
|
+
let formattedCss = shortCssObject(css || defaultCss);
|
|
609
507
|
let { className: newClass = "" } = stitchesInstance.css(formattedCss)();
|
|
610
508
|
let { stitchesClass } = instance;
|
|
611
|
-
let otherClass = (((
|
|
509
|
+
let otherClass = (((_d = instance.ref.current) == null ? void 0 : _d.className) || "").replace(stitchesClass, "").replace(cls, "").trim();
|
|
612
510
|
className = `${cls} ${newClass} ${otherClass}`.trim();
|
|
613
511
|
instance.stitchesClass = newClass;
|
|
614
512
|
}
|
|
@@ -618,9 +516,9 @@ function generateItemClass(instance, stitchesInstance) {
|
|
|
618
516
|
// src/renderer.tsx
|
|
619
517
|
var WeaverseRoot = ({ context }) => {
|
|
620
518
|
var _a;
|
|
621
|
-
let [, setData] =
|
|
519
|
+
let [, setData] = useState2(context.projectData);
|
|
622
520
|
let rootRef = useRef();
|
|
623
|
-
|
|
521
|
+
useEffect3(() => {
|
|
624
522
|
let update = () => setData({});
|
|
625
523
|
context.subscribe(update);
|
|
626
524
|
if (context.projectData) {
|
|
@@ -644,10 +542,11 @@ var WeaverseRoot = ({ context }) => {
|
|
|
644
542
|
})));
|
|
645
543
|
};
|
|
646
544
|
var ItemComponent = ({ instance }) => {
|
|
647
|
-
let { stitchesInstance, elementInstances } =
|
|
648
|
-
let [data, setData] =
|
|
649
|
-
let _a = data, { id, type, childIds = [], css, className
|
|
650
|
-
|
|
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;
|
|
651
550
|
let update = (data2) => setData(__spreadValues({}, data2));
|
|
652
551
|
instance.subscribe(update);
|
|
653
552
|
if (isBrowser && !instance.ref.current) {
|
|
@@ -655,11 +554,12 @@ var ItemComponent = ({ instance }) => {
|
|
|
655
554
|
current: document.querySelector(`[data-wv-id="${id}"]`)
|
|
656
555
|
});
|
|
657
556
|
}
|
|
557
|
+
(_a2 = instance.ref.current) == null ? void 0 : _a2.removeAttribute("css");
|
|
658
558
|
return () => {
|
|
659
559
|
instance.unsubscribe(update);
|
|
660
560
|
};
|
|
661
561
|
}, []);
|
|
662
|
-
let Element = elementInstances.get(type
|
|
562
|
+
let Element = elementInstances.get(type);
|
|
663
563
|
if (Element == null ? void 0 : Element.Component) {
|
|
664
564
|
let Component = Element.Component;
|
|
665
565
|
if (Component.$$typeof === Symbol.for("react.forward_ref")) {
|
|
@@ -678,7 +578,7 @@ var ItemComponent = ({ instance }) => {
|
|
|
678
578
|
return null;
|
|
679
579
|
};
|
|
680
580
|
var ItemInstance = ({ id }) => {
|
|
681
|
-
let context =
|
|
581
|
+
let context = useContext4(WeaverseContext);
|
|
682
582
|
let { itemInstances } = context;
|
|
683
583
|
let instance = itemInstances.get(id);
|
|
684
584
|
if (!instance) {
|