@weaverse/react 0.6.11 → 0.6.14
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.js +282 -25
- package/dist/index.mjs +277 -20
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -62,7 +62,7 @@ module.exports = __toCommonJS(src_exports);
|
|
|
62
62
|
|
|
63
63
|
// src/context.ts
|
|
64
64
|
var import_core = require("@weaverse/core");
|
|
65
|
-
var
|
|
65
|
+
var import_react9 = require("react");
|
|
66
66
|
|
|
67
67
|
// src/elements/base.tsx
|
|
68
68
|
var import_react = __toESM(require("react"));
|
|
@@ -101,7 +101,7 @@ var Button = React2.forwardRef((props, ref) => {
|
|
|
101
101
|
}, rest), props.value);
|
|
102
102
|
});
|
|
103
103
|
Button.defaultProps = {
|
|
104
|
-
value: "
|
|
104
|
+
value: "Shop now"
|
|
105
105
|
};
|
|
106
106
|
var schema2 = {
|
|
107
107
|
title: "Button",
|
|
@@ -142,13 +142,19 @@ var schema2 = {
|
|
|
142
142
|
data: {
|
|
143
143
|
css: {
|
|
144
144
|
"@desktop": {
|
|
145
|
-
borderRadius: "
|
|
145
|
+
borderRadius: "72px",
|
|
146
|
+
border: "none",
|
|
147
|
+
backgroundColor: "#0F71FF",
|
|
148
|
+
color: "#fff",
|
|
146
149
|
fontSize: "13px",
|
|
147
|
-
padding: "10px
|
|
150
|
+
padding: "10px 20px"
|
|
148
151
|
}
|
|
149
152
|
},
|
|
150
153
|
target: "",
|
|
151
154
|
openInNewTab: false
|
|
155
|
+
},
|
|
156
|
+
flags: {
|
|
157
|
+
draggable: true
|
|
152
158
|
}
|
|
153
159
|
};
|
|
154
160
|
var button_default = Button;
|
|
@@ -174,7 +180,6 @@ var schema3 = {
|
|
|
174
180
|
justifyContent: "flex-start",
|
|
175
181
|
textAlign: "left",
|
|
176
182
|
gridArea: "1 / 1 / 3 / 6",
|
|
177
|
-
overflow: "hidden",
|
|
178
183
|
width: "100%",
|
|
179
184
|
height: "fit-content"
|
|
180
185
|
}
|
|
@@ -184,8 +189,7 @@ var schema3 = {
|
|
|
184
189
|
flags: {
|
|
185
190
|
draggable: true,
|
|
186
191
|
resizable: true,
|
|
187
|
-
sortable: true
|
|
188
|
-
hasSelection: false
|
|
192
|
+
sortable: true
|
|
189
193
|
}
|
|
190
194
|
};
|
|
191
195
|
var container_default = Container;
|
|
@@ -229,7 +233,7 @@ var schema4 = {
|
|
|
229
233
|
}
|
|
230
234
|
},
|
|
231
235
|
"@mobile": {
|
|
232
|
-
padding: "0",
|
|
236
|
+
padding: "0 16px",
|
|
233
237
|
"> [data-layout-content]": {
|
|
234
238
|
display: "flex !important",
|
|
235
239
|
flexDirection: "column"
|
|
@@ -293,7 +297,7 @@ var Image = import_react4.default.forwardRef(function Image2(props, ref) {
|
|
|
293
297
|
}));
|
|
294
298
|
});
|
|
295
299
|
Image.defaultProps = {
|
|
296
|
-
src: "https://ucarecdn.com/
|
|
300
|
+
src: "https://ucarecdn.com/1cdc9d39-ca62-492e-8ec7-f1a86b241a90/",
|
|
297
301
|
alt: "weaverse image element"
|
|
298
302
|
};
|
|
299
303
|
var schema6 = {
|
|
@@ -321,6 +325,247 @@ var schema6 = {
|
|
|
321
325
|
};
|
|
322
326
|
var image_default = Image;
|
|
323
327
|
|
|
328
|
+
// src/elements/video.tsx
|
|
329
|
+
var import_react5 = __toESM(require("react"));
|
|
330
|
+
var Video = (0, import_react5.forwardRef)((props, ref) => {
|
|
331
|
+
const { isDesignMode } = (0, import_react5.useContext)(WeaverseContext);
|
|
332
|
+
let _a = props, { src, type, controls, autoPlay, loop, muted } = _a, rest = __objRest(_a, ["src", "type", "controls", "autoPlay", "loop", "muted"]);
|
|
333
|
+
if (isDesignMode) {
|
|
334
|
+
controls = false;
|
|
335
|
+
autoPlay = false;
|
|
336
|
+
}
|
|
337
|
+
console.info("9779 props", props, isDesignMode);
|
|
338
|
+
return /* @__PURE__ */ import_react5.default.createElement("video", __spreadValues({
|
|
339
|
+
ref,
|
|
340
|
+
controls,
|
|
341
|
+
autoPlay,
|
|
342
|
+
loop,
|
|
343
|
+
muted: true
|
|
344
|
+
}, rest), /* @__PURE__ */ import_react5.default.createElement("source", {
|
|
345
|
+
src,
|
|
346
|
+
type: type || "video/mp4",
|
|
347
|
+
controlsList: "nodownload",
|
|
348
|
+
disablePictureInPicture: true
|
|
349
|
+
}));
|
|
350
|
+
});
|
|
351
|
+
Video.defaultProps = {
|
|
352
|
+
src: "https://ucarecdn.com/7cae0dab-8966-4484-9998-602728c360ca/IMG_0048.MOV",
|
|
353
|
+
poster: "https://ucarecdn.com/48d73272-3fe3-43f6-8b5b-22b68fc5a8c8/section.png",
|
|
354
|
+
loop: false,
|
|
355
|
+
type: "video/mp4",
|
|
356
|
+
controls: false,
|
|
357
|
+
autoPlay: true,
|
|
358
|
+
muted: true,
|
|
359
|
+
width: "100%",
|
|
360
|
+
height: "auto"
|
|
361
|
+
};
|
|
362
|
+
var schema7 = {
|
|
363
|
+
title: "Video",
|
|
364
|
+
type: "video",
|
|
365
|
+
parentType: "layout",
|
|
366
|
+
toolbar: [
|
|
367
|
+
{
|
|
368
|
+
type: "delete"
|
|
369
|
+
},
|
|
370
|
+
{
|
|
371
|
+
type: "duplicate"
|
|
372
|
+
},
|
|
373
|
+
{
|
|
374
|
+
type: "link"
|
|
375
|
+
},
|
|
376
|
+
{
|
|
377
|
+
type: "color"
|
|
378
|
+
}
|
|
379
|
+
],
|
|
380
|
+
flags: {
|
|
381
|
+
resizable: true,
|
|
382
|
+
draggable: true,
|
|
383
|
+
sortable: true
|
|
384
|
+
}
|
|
385
|
+
};
|
|
386
|
+
var video_default = Video;
|
|
387
|
+
|
|
388
|
+
// src/elements/map.tsx
|
|
389
|
+
var import_react6 = __toESM(require("react"));
|
|
390
|
+
var Map = (0, import_react6.forwardRef)((props, ref) => {
|
|
391
|
+
const { place, zoom } = props;
|
|
392
|
+
console.info("9779 props", props);
|
|
393
|
+
return /* @__PURE__ */ import_react6.default.createElement("div", __spreadValues({
|
|
394
|
+
ref
|
|
395
|
+
}, props), /* @__PURE__ */ import_react6.default.createElement("iframe", {
|
|
396
|
+
loading: "lazy",
|
|
397
|
+
scrolling: "no",
|
|
398
|
+
width: "100%",
|
|
399
|
+
height: "100%",
|
|
400
|
+
title: "map",
|
|
401
|
+
src: `https://maps.google.com/maps?z=${zoom}&t=m&q=${place}&ie=UTF8&&output=embed`,
|
|
402
|
+
style: {
|
|
403
|
+
pointerEvents: "none"
|
|
404
|
+
}
|
|
405
|
+
}));
|
|
406
|
+
});
|
|
407
|
+
Map.defaultProps = {
|
|
408
|
+
place: "Hanoi",
|
|
409
|
+
zoom: 14
|
|
410
|
+
};
|
|
411
|
+
var schema8 = {
|
|
412
|
+
title: "Map",
|
|
413
|
+
type: "map",
|
|
414
|
+
parentType: "layout",
|
|
415
|
+
toolbar: [
|
|
416
|
+
{
|
|
417
|
+
type: "delete"
|
|
418
|
+
},
|
|
419
|
+
{
|
|
420
|
+
type: "duplicate"
|
|
421
|
+
},
|
|
422
|
+
{
|
|
423
|
+
type: "link"
|
|
424
|
+
},
|
|
425
|
+
{
|
|
426
|
+
type: "color"
|
|
427
|
+
}
|
|
428
|
+
],
|
|
429
|
+
data: {
|
|
430
|
+
css: {
|
|
431
|
+
"@desktop": {
|
|
432
|
+
gridArea: "1 / 1 / 11 / 13"
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
},
|
|
436
|
+
flags: {
|
|
437
|
+
resizable: true,
|
|
438
|
+
draggable: true,
|
|
439
|
+
sortable: true
|
|
440
|
+
}
|
|
441
|
+
};
|
|
442
|
+
var map_default = Map;
|
|
443
|
+
|
|
444
|
+
// src/elements/countdown/index.tsx
|
|
445
|
+
var import_react8 = __toESM(require("react"));
|
|
446
|
+
|
|
447
|
+
// src/elements/countdown/utils.ts
|
|
448
|
+
function getTime(seconds) {
|
|
449
|
+
const ONE_MINUTE = 60 * 1e3;
|
|
450
|
+
const ONE_HOUR = 60 * ONE_MINUTE;
|
|
451
|
+
const ONE_DAY = 24 * ONE_HOUR;
|
|
452
|
+
const days = Math.floor(seconds / ONE_DAY);
|
|
453
|
+
const hours = Math.floor((seconds - days * ONE_DAY) / ONE_HOUR);
|
|
454
|
+
const mins = Math.floor((seconds - days * ONE_DAY - hours * ONE_HOUR) / ONE_MINUTE);
|
|
455
|
+
const secs = Math.floor((seconds - days * ONE_DAY - hours * ONE_HOUR - mins * ONE_MINUTE) / 1e3);
|
|
456
|
+
return { days, hours, mins, secs };
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
// src/elements/countdown/timer-block.tsx
|
|
460
|
+
var import_react7 = __toESM(require("react"));
|
|
461
|
+
var TimerBlock = (props) => {
|
|
462
|
+
return /* @__PURE__ */ import_react7.default.createElement("div", null, /* @__PURE__ */ import_react7.default.createElement("div", null, props.value.toString().padStart(2, "0")), props.label && /* @__PURE__ */ import_react7.default.createElement("div", {
|
|
463
|
+
className: "wv-countdown-label"
|
|
464
|
+
}, props.label));
|
|
465
|
+
};
|
|
466
|
+
var timer_block_default = TimerBlock;
|
|
467
|
+
|
|
468
|
+
// src/elements/countdown/index.tsx
|
|
469
|
+
var Countdown = (0, import_react8.forwardRef)((props, ref) => {
|
|
470
|
+
const { isDesignMode } = (0, import_react8.useContext)(WeaverseContext);
|
|
471
|
+
let { type, startTime, endTime, periods, redirectUrl, openInNewTab, showColon, showLabel } = props;
|
|
472
|
+
const [remaining, setRemaining] = import_react8.default.useState(0);
|
|
473
|
+
if (typeof endTime !== "number") {
|
|
474
|
+
endTime = Number.parseInt(endTime);
|
|
475
|
+
}
|
|
476
|
+
(0, import_react8.useEffect)(() => {
|
|
477
|
+
const flag = setInterval(() => {
|
|
478
|
+
const remainingTime = Math.max((type === "specific" ? new Date(endTime).getTime() : new Date(startTime) + periods * 60 * 1e3) - Date.now(), 0);
|
|
479
|
+
if (!isDesignMode && redirectUrl && remainingTime > 0 && remainingTime < 1e3) {
|
|
480
|
+
window.open(redirectUrl, openInNewTab ? "_blank" : "_self");
|
|
481
|
+
}
|
|
482
|
+
setRemaining(remainingTime);
|
|
483
|
+
}, 1e3);
|
|
484
|
+
return () => {
|
|
485
|
+
clearInterval(flag);
|
|
486
|
+
};
|
|
487
|
+
}, [startTime, endTime, periods, type]);
|
|
488
|
+
const timer = getTime(remaining);
|
|
489
|
+
return /* @__PURE__ */ import_react8.default.createElement("div", __spreadValues({
|
|
490
|
+
ref
|
|
491
|
+
}, props), /* @__PURE__ */ import_react8.default.createElement(timer_block_default, {
|
|
492
|
+
value: timer.days,
|
|
493
|
+
label: showLabel && "days"
|
|
494
|
+
}), /* @__PURE__ */ import_react8.default.createElement("span", {
|
|
495
|
+
className: !showColon && "hidden"
|
|
496
|
+
}, ":"), /* @__PURE__ */ import_react8.default.createElement(timer_block_default, {
|
|
497
|
+
value: timer.hours,
|
|
498
|
+
label: showLabel && "hours"
|
|
499
|
+
}), /* @__PURE__ */ import_react8.default.createElement("span", {
|
|
500
|
+
className: !showColon && "hidden"
|
|
501
|
+
}, ":"), /* @__PURE__ */ import_react8.default.createElement(timer_block_default, {
|
|
502
|
+
value: timer.mins,
|
|
503
|
+
label: showLabel && "minutes"
|
|
504
|
+
}), /* @__PURE__ */ import_react8.default.createElement("span", {
|
|
505
|
+
className: !showColon && "hidden"
|
|
506
|
+
}, ":"), /* @__PURE__ */ import_react8.default.createElement(timer_block_default, {
|
|
507
|
+
value: timer.secs,
|
|
508
|
+
label: showLabel && "seconds"
|
|
509
|
+
}));
|
|
510
|
+
});
|
|
511
|
+
Countdown.defaultProps = {
|
|
512
|
+
type: "specific",
|
|
513
|
+
startTime: Date.now(),
|
|
514
|
+
endTime: 1661140528e3,
|
|
515
|
+
redirectUrl: "",
|
|
516
|
+
openInNewTab: false,
|
|
517
|
+
showLabel: true,
|
|
518
|
+
showColon: true
|
|
519
|
+
};
|
|
520
|
+
var schema9 = {
|
|
521
|
+
title: "Countdown",
|
|
522
|
+
type: "countdown",
|
|
523
|
+
parentType: "container",
|
|
524
|
+
toolbar: [
|
|
525
|
+
{
|
|
526
|
+
type: "delete"
|
|
527
|
+
},
|
|
528
|
+
{
|
|
529
|
+
type: "duplicate"
|
|
530
|
+
},
|
|
531
|
+
{
|
|
532
|
+
type: "link"
|
|
533
|
+
},
|
|
534
|
+
{
|
|
535
|
+
type: "color"
|
|
536
|
+
}
|
|
537
|
+
],
|
|
538
|
+
data: {
|
|
539
|
+
css: {
|
|
540
|
+
"@desktop": {
|
|
541
|
+
fontFamily: "Inter",
|
|
542
|
+
fontSize: 36,
|
|
543
|
+
fontWeight: 500,
|
|
544
|
+
display: "grid",
|
|
545
|
+
gridAutoFlow: "column",
|
|
546
|
+
gap: 10,
|
|
547
|
+
"& > div": {
|
|
548
|
+
width: 48,
|
|
549
|
+
textAlign: "center"
|
|
550
|
+
},
|
|
551
|
+
"& .wv-countdown-label": {
|
|
552
|
+
fontSize: 10
|
|
553
|
+
},
|
|
554
|
+
"& > span": {
|
|
555
|
+
lineHeight: "100%"
|
|
556
|
+
},
|
|
557
|
+
"& .hidden": {
|
|
558
|
+
visibility: "hidden"
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
},
|
|
563
|
+
flags: {
|
|
564
|
+
draggable: true
|
|
565
|
+
}
|
|
566
|
+
};
|
|
567
|
+
var countdown_default = Countdown;
|
|
568
|
+
|
|
324
569
|
// src/elements/index.ts
|
|
325
570
|
var elements = {
|
|
326
571
|
Button: {
|
|
@@ -346,6 +591,18 @@ var elements = {
|
|
|
346
591
|
Image: {
|
|
347
592
|
Component: image_default,
|
|
348
593
|
schema: schema6
|
|
594
|
+
},
|
|
595
|
+
Video: {
|
|
596
|
+
Component: video_default,
|
|
597
|
+
schema: schema7
|
|
598
|
+
},
|
|
599
|
+
Map: {
|
|
600
|
+
Component: map_default,
|
|
601
|
+
schema: schema8
|
|
602
|
+
},
|
|
603
|
+
Countdown: {
|
|
604
|
+
Component: countdown_default,
|
|
605
|
+
schema: schema9
|
|
349
606
|
}
|
|
350
607
|
};
|
|
351
608
|
var elements_default = elements;
|
|
@@ -358,13 +615,13 @@ var createRootContext = (configs) => {
|
|
|
358
615
|
});
|
|
359
616
|
return rootContext;
|
|
360
617
|
};
|
|
361
|
-
var WeaverseContext = (0,
|
|
618
|
+
var WeaverseContext = (0, import_react9.createContext)({});
|
|
362
619
|
var WeaverseContextProvider = WeaverseContext.Provider;
|
|
363
620
|
var WeaverseContextConsumer = WeaverseContext.Consumer;
|
|
364
621
|
|
|
365
622
|
// src/renderer.tsx
|
|
366
623
|
var import_core2 = require("@weaverse/core");
|
|
367
|
-
var
|
|
624
|
+
var import_react10 = __toESM(require("react"));
|
|
368
625
|
|
|
369
626
|
// src/utils/index.ts
|
|
370
627
|
var shortCssObject = (css) => {
|
|
@@ -391,9 +648,9 @@ function generateItemClass(instance, stitchesInstance) {
|
|
|
391
648
|
// src/renderer.tsx
|
|
392
649
|
var WeaverseRoot = ({ context }) => {
|
|
393
650
|
var _a;
|
|
394
|
-
let [, setData] = (0,
|
|
395
|
-
let rootRef = (0,
|
|
396
|
-
(0,
|
|
651
|
+
let [, setData] = (0, import_react10.useState)(context.projectData);
|
|
652
|
+
let rootRef = (0, import_react10.useRef)();
|
|
653
|
+
(0, import_react10.useEffect)(() => {
|
|
397
654
|
let update = () => setData({});
|
|
398
655
|
context.subscribe(update);
|
|
399
656
|
if (context.projectData) {
|
|
@@ -406,21 +663,21 @@ var WeaverseRoot = ({ context }) => {
|
|
|
406
663
|
}, []);
|
|
407
664
|
let eventHandlers = ((_a = context == null ? void 0 : context.studioBridge) == null ? void 0 : _a.eventHandlers) || {};
|
|
408
665
|
let themeClass = context.stitchesInstance.theme.className;
|
|
409
|
-
return /* @__PURE__ */
|
|
666
|
+
return /* @__PURE__ */ import_react10.default.createElement("div", __spreadProps(__spreadValues({
|
|
410
667
|
className: `weaverse-content-root ${themeClass}`
|
|
411
668
|
}, eventHandlers), {
|
|
412
669
|
ref: rootRef
|
|
413
|
-
}), /* @__PURE__ */
|
|
670
|
+
}), /* @__PURE__ */ import_react10.default.createElement(WeaverseContextProvider, {
|
|
414
671
|
value: context
|
|
415
|
-
}, /* @__PURE__ */
|
|
672
|
+
}, /* @__PURE__ */ import_react10.default.createElement(ItemInstance, {
|
|
416
673
|
id: context.projectData.rootId || 0
|
|
417
674
|
})));
|
|
418
675
|
};
|
|
419
676
|
var ItemComponent = ({ instance }) => {
|
|
420
|
-
let { stitchesInstance, elementInstances } = (0,
|
|
421
|
-
let [data, setData] = (0,
|
|
677
|
+
let { stitchesInstance, elementInstances } = (0, import_react10.useContext)(WeaverseContext);
|
|
678
|
+
let [data, setData] = (0, import_react10.useState)(instance.data);
|
|
422
679
|
let _a = data, { id, type, childIds = [], css, className: cls = "" } = _a, rest = __objRest(_a, ["id", "type", "childIds", "css", "className"]);
|
|
423
|
-
(0,
|
|
680
|
+
(0, import_react10.useEffect)(() => {
|
|
424
681
|
let update = (data2) => setData(__spreadValues({}, data2));
|
|
425
682
|
instance.subscribe(update);
|
|
426
683
|
if (import_core2.isBrowser && !instance.ref.current) {
|
|
@@ -438,12 +695,12 @@ var ItemComponent = ({ instance }) => {
|
|
|
438
695
|
if (Component.$$typeof === Symbol.for("react.forward_ref")) {
|
|
439
696
|
rest.ref = instance.ref;
|
|
440
697
|
}
|
|
441
|
-
return /* @__PURE__ */
|
|
698
|
+
return /* @__PURE__ */ import_react10.default.createElement(Component, __spreadValues({
|
|
442
699
|
key: id,
|
|
443
700
|
"data-wv-type": type,
|
|
444
701
|
"data-wv-id": id,
|
|
445
702
|
className: generateItemClass(instance, stitchesInstance)
|
|
446
|
-
}, rest), childIds.map((id2) => /* @__PURE__ */
|
|
703
|
+
}, rest), childIds.map((id2) => /* @__PURE__ */ import_react10.default.createElement(ItemInstance, {
|
|
447
704
|
key: id2,
|
|
448
705
|
id: id2
|
|
449
706
|
})));
|
|
@@ -451,15 +708,15 @@ var ItemComponent = ({ instance }) => {
|
|
|
451
708
|
return null;
|
|
452
709
|
};
|
|
453
710
|
var ItemInstance = ({ id }) => {
|
|
454
|
-
let context = (0,
|
|
711
|
+
let context = (0, import_react10.useContext)(WeaverseContext);
|
|
455
712
|
let { itemInstances } = context;
|
|
456
713
|
let instance = itemInstances.get(id);
|
|
457
714
|
if (!instance) {
|
|
458
|
-
return /* @__PURE__ */
|
|
715
|
+
return /* @__PURE__ */ import_react10.default.createElement("div", {
|
|
459
716
|
style: { display: "none" }
|
|
460
717
|
}, "Item instance ", id, " not found");
|
|
461
718
|
}
|
|
462
|
-
return /* @__PURE__ */
|
|
719
|
+
return /* @__PURE__ */ import_react10.default.createElement(ItemComponent, {
|
|
463
720
|
instance
|
|
464
721
|
});
|
|
465
722
|
};
|
package/dist/index.mjs
CHANGED
|
@@ -71,7 +71,7 @@ var Button = React2.forwardRef((props, ref) => {
|
|
|
71
71
|
}, rest), props.value);
|
|
72
72
|
});
|
|
73
73
|
Button.defaultProps = {
|
|
74
|
-
value: "
|
|
74
|
+
value: "Shop now"
|
|
75
75
|
};
|
|
76
76
|
var schema2 = {
|
|
77
77
|
title: "Button",
|
|
@@ -112,13 +112,19 @@ var schema2 = {
|
|
|
112
112
|
data: {
|
|
113
113
|
css: {
|
|
114
114
|
"@desktop": {
|
|
115
|
-
borderRadius: "
|
|
115
|
+
borderRadius: "72px",
|
|
116
|
+
border: "none",
|
|
117
|
+
backgroundColor: "#0F71FF",
|
|
118
|
+
color: "#fff",
|
|
116
119
|
fontSize: "13px",
|
|
117
|
-
padding: "10px
|
|
120
|
+
padding: "10px 20px"
|
|
118
121
|
}
|
|
119
122
|
},
|
|
120
123
|
target: "",
|
|
121
124
|
openInNewTab: false
|
|
125
|
+
},
|
|
126
|
+
flags: {
|
|
127
|
+
draggable: true
|
|
122
128
|
}
|
|
123
129
|
};
|
|
124
130
|
var button_default = Button;
|
|
@@ -144,7 +150,6 @@ var schema3 = {
|
|
|
144
150
|
justifyContent: "flex-start",
|
|
145
151
|
textAlign: "left",
|
|
146
152
|
gridArea: "1 / 1 / 3 / 6",
|
|
147
|
-
overflow: "hidden",
|
|
148
153
|
width: "100%",
|
|
149
154
|
height: "fit-content"
|
|
150
155
|
}
|
|
@@ -154,8 +159,7 @@ var schema3 = {
|
|
|
154
159
|
flags: {
|
|
155
160
|
draggable: true,
|
|
156
161
|
resizable: true,
|
|
157
|
-
sortable: true
|
|
158
|
-
hasSelection: false
|
|
162
|
+
sortable: true
|
|
159
163
|
}
|
|
160
164
|
};
|
|
161
165
|
var container_default = Container;
|
|
@@ -199,7 +203,7 @@ var schema4 = {
|
|
|
199
203
|
}
|
|
200
204
|
},
|
|
201
205
|
"@mobile": {
|
|
202
|
-
padding: "0",
|
|
206
|
+
padding: "0 16px",
|
|
203
207
|
"> [data-layout-content]": {
|
|
204
208
|
display: "flex !important",
|
|
205
209
|
flexDirection: "column"
|
|
@@ -263,7 +267,7 @@ var Image = React6.forwardRef(function Image2(props, ref) {
|
|
|
263
267
|
}));
|
|
264
268
|
});
|
|
265
269
|
Image.defaultProps = {
|
|
266
|
-
src: "https://ucarecdn.com/
|
|
270
|
+
src: "https://ucarecdn.com/1cdc9d39-ca62-492e-8ec7-f1a86b241a90/",
|
|
267
271
|
alt: "weaverse image element"
|
|
268
272
|
};
|
|
269
273
|
var schema6 = {
|
|
@@ -291,6 +295,247 @@ var schema6 = {
|
|
|
291
295
|
};
|
|
292
296
|
var image_default = Image;
|
|
293
297
|
|
|
298
|
+
// src/elements/video.tsx
|
|
299
|
+
import React7, { forwardRef as forwardRef5, useContext } from "react";
|
|
300
|
+
var Video = forwardRef5((props, ref) => {
|
|
301
|
+
const { isDesignMode } = useContext(WeaverseContext);
|
|
302
|
+
let _a = props, { src, type, controls, autoPlay, loop, muted } = _a, rest = __objRest(_a, ["src", "type", "controls", "autoPlay", "loop", "muted"]);
|
|
303
|
+
if (isDesignMode) {
|
|
304
|
+
controls = false;
|
|
305
|
+
autoPlay = false;
|
|
306
|
+
}
|
|
307
|
+
console.info("9779 props", props, isDesignMode);
|
|
308
|
+
return /* @__PURE__ */ React7.createElement("video", __spreadValues({
|
|
309
|
+
ref,
|
|
310
|
+
controls,
|
|
311
|
+
autoPlay,
|
|
312
|
+
loop,
|
|
313
|
+
muted: true
|
|
314
|
+
}, rest), /* @__PURE__ */ React7.createElement("source", {
|
|
315
|
+
src,
|
|
316
|
+
type: type || "video/mp4",
|
|
317
|
+
controlsList: "nodownload",
|
|
318
|
+
disablePictureInPicture: true
|
|
319
|
+
}));
|
|
320
|
+
});
|
|
321
|
+
Video.defaultProps = {
|
|
322
|
+
src: "https://ucarecdn.com/7cae0dab-8966-4484-9998-602728c360ca/IMG_0048.MOV",
|
|
323
|
+
poster: "https://ucarecdn.com/48d73272-3fe3-43f6-8b5b-22b68fc5a8c8/section.png",
|
|
324
|
+
loop: false,
|
|
325
|
+
type: "video/mp4",
|
|
326
|
+
controls: false,
|
|
327
|
+
autoPlay: true,
|
|
328
|
+
muted: true,
|
|
329
|
+
width: "100%",
|
|
330
|
+
height: "auto"
|
|
331
|
+
};
|
|
332
|
+
var schema7 = {
|
|
333
|
+
title: "Video",
|
|
334
|
+
type: "video",
|
|
335
|
+
parentType: "layout",
|
|
336
|
+
toolbar: [
|
|
337
|
+
{
|
|
338
|
+
type: "delete"
|
|
339
|
+
},
|
|
340
|
+
{
|
|
341
|
+
type: "duplicate"
|
|
342
|
+
},
|
|
343
|
+
{
|
|
344
|
+
type: "link"
|
|
345
|
+
},
|
|
346
|
+
{
|
|
347
|
+
type: "color"
|
|
348
|
+
}
|
|
349
|
+
],
|
|
350
|
+
flags: {
|
|
351
|
+
resizable: true,
|
|
352
|
+
draggable: true,
|
|
353
|
+
sortable: true
|
|
354
|
+
}
|
|
355
|
+
};
|
|
356
|
+
var video_default = Video;
|
|
357
|
+
|
|
358
|
+
// src/elements/map.tsx
|
|
359
|
+
import React8, { forwardRef as forwardRef6 } from "react";
|
|
360
|
+
var Map = forwardRef6((props, ref) => {
|
|
361
|
+
const { place, zoom } = props;
|
|
362
|
+
console.info("9779 props", props);
|
|
363
|
+
return /* @__PURE__ */ React8.createElement("div", __spreadValues({
|
|
364
|
+
ref
|
|
365
|
+
}, props), /* @__PURE__ */ React8.createElement("iframe", {
|
|
366
|
+
loading: "lazy",
|
|
367
|
+
scrolling: "no",
|
|
368
|
+
width: "100%",
|
|
369
|
+
height: "100%",
|
|
370
|
+
title: "map",
|
|
371
|
+
src: `https://maps.google.com/maps?z=${zoom}&t=m&q=${place}&ie=UTF8&&output=embed`,
|
|
372
|
+
style: {
|
|
373
|
+
pointerEvents: "none"
|
|
374
|
+
}
|
|
375
|
+
}));
|
|
376
|
+
});
|
|
377
|
+
Map.defaultProps = {
|
|
378
|
+
place: "Hanoi",
|
|
379
|
+
zoom: 14
|
|
380
|
+
};
|
|
381
|
+
var schema8 = {
|
|
382
|
+
title: "Map",
|
|
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
|
+
}
|
|
404
|
+
}
|
|
405
|
+
},
|
|
406
|
+
flags: {
|
|
407
|
+
resizable: true,
|
|
408
|
+
draggable: true,
|
|
409
|
+
sortable: true
|
|
410
|
+
}
|
|
411
|
+
};
|
|
412
|
+
var map_default = Map;
|
|
413
|
+
|
|
414
|
+
// src/elements/countdown/index.tsx
|
|
415
|
+
import React10, { forwardRef as forwardRef7, useContext as useContext2, useEffect } from "react";
|
|
416
|
+
|
|
417
|
+
// src/elements/countdown/utils.ts
|
|
418
|
+
function getTime(seconds) {
|
|
419
|
+
const ONE_MINUTE = 60 * 1e3;
|
|
420
|
+
const ONE_HOUR = 60 * ONE_MINUTE;
|
|
421
|
+
const ONE_DAY = 24 * ONE_HOUR;
|
|
422
|
+
const days = Math.floor(seconds / ONE_DAY);
|
|
423
|
+
const hours = Math.floor((seconds - days * ONE_DAY) / ONE_HOUR);
|
|
424
|
+
const mins = Math.floor((seconds - days * ONE_DAY - hours * ONE_HOUR) / ONE_MINUTE);
|
|
425
|
+
const secs = Math.floor((seconds - days * ONE_DAY - hours * ONE_HOUR - mins * ONE_MINUTE) / 1e3);
|
|
426
|
+
return { days, hours, mins, secs };
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
// src/elements/countdown/timer-block.tsx
|
|
430
|
+
import React9 from "react";
|
|
431
|
+
var TimerBlock = (props) => {
|
|
432
|
+
return /* @__PURE__ */ React9.createElement("div", null, /* @__PURE__ */ React9.createElement("div", null, props.value.toString().padStart(2, "0")), props.label && /* @__PURE__ */ React9.createElement("div", {
|
|
433
|
+
className: "wv-countdown-label"
|
|
434
|
+
}, props.label));
|
|
435
|
+
};
|
|
436
|
+
var timer_block_default = TimerBlock;
|
|
437
|
+
|
|
438
|
+
// src/elements/countdown/index.tsx
|
|
439
|
+
var Countdown = forwardRef7((props, ref) => {
|
|
440
|
+
const { isDesignMode } = useContext2(WeaverseContext);
|
|
441
|
+
let { type, startTime, endTime, periods, redirectUrl, openInNewTab, showColon, showLabel } = props;
|
|
442
|
+
const [remaining, setRemaining] = React10.useState(0);
|
|
443
|
+
if (typeof endTime !== "number") {
|
|
444
|
+
endTime = Number.parseInt(endTime);
|
|
445
|
+
}
|
|
446
|
+
useEffect(() => {
|
|
447
|
+
const flag = setInterval(() => {
|
|
448
|
+
const remainingTime = Math.max((type === "specific" ? new Date(endTime).getTime() : new Date(startTime) + periods * 60 * 1e3) - Date.now(), 0);
|
|
449
|
+
if (!isDesignMode && redirectUrl && remainingTime > 0 && remainingTime < 1e3) {
|
|
450
|
+
window.open(redirectUrl, openInNewTab ? "_blank" : "_self");
|
|
451
|
+
}
|
|
452
|
+
setRemaining(remainingTime);
|
|
453
|
+
}, 1e3);
|
|
454
|
+
return () => {
|
|
455
|
+
clearInterval(flag);
|
|
456
|
+
};
|
|
457
|
+
}, [startTime, endTime, periods, type]);
|
|
458
|
+
const timer = getTime(remaining);
|
|
459
|
+
return /* @__PURE__ */ React10.createElement("div", __spreadValues({
|
|
460
|
+
ref
|
|
461
|
+
}, props), /* @__PURE__ */ React10.createElement(timer_block_default, {
|
|
462
|
+
value: timer.days,
|
|
463
|
+
label: showLabel && "days"
|
|
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
|
+
}));
|
|
480
|
+
});
|
|
481
|
+
Countdown.defaultProps = {
|
|
482
|
+
type: "specific",
|
|
483
|
+
startTime: Date.now(),
|
|
484
|
+
endTime: 1661140528e3,
|
|
485
|
+
redirectUrl: "",
|
|
486
|
+
openInNewTab: false,
|
|
487
|
+
showLabel: true,
|
|
488
|
+
showColon: true
|
|
489
|
+
};
|
|
490
|
+
var schema9 = {
|
|
491
|
+
title: "Countdown",
|
|
492
|
+
type: "countdown",
|
|
493
|
+
parentType: "container",
|
|
494
|
+
toolbar: [
|
|
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"
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
},
|
|
533
|
+
flags: {
|
|
534
|
+
draggable: true
|
|
535
|
+
}
|
|
536
|
+
};
|
|
537
|
+
var countdown_default = Countdown;
|
|
538
|
+
|
|
294
539
|
// src/elements/index.ts
|
|
295
540
|
var elements = {
|
|
296
541
|
Button: {
|
|
@@ -316,6 +561,18 @@ var elements = {
|
|
|
316
561
|
Image: {
|
|
317
562
|
Component: image_default,
|
|
318
563
|
schema: schema6
|
|
564
|
+
},
|
|
565
|
+
Video: {
|
|
566
|
+
Component: video_default,
|
|
567
|
+
schema: schema7
|
|
568
|
+
},
|
|
569
|
+
Map: {
|
|
570
|
+
Component: map_default,
|
|
571
|
+
schema: schema8
|
|
572
|
+
},
|
|
573
|
+
Countdown: {
|
|
574
|
+
Component: countdown_default,
|
|
575
|
+
schema: schema9
|
|
319
576
|
}
|
|
320
577
|
};
|
|
321
578
|
var elements_default = elements;
|
|
@@ -334,7 +591,7 @@ var WeaverseContextConsumer = WeaverseContext.Consumer;
|
|
|
334
591
|
|
|
335
592
|
// src/renderer.tsx
|
|
336
593
|
import { isBrowser } from "@weaverse/core";
|
|
337
|
-
import
|
|
594
|
+
import React11, { useContext as useContext3, useEffect as useEffect2, useRef, useState } from "react";
|
|
338
595
|
|
|
339
596
|
// src/utils/index.ts
|
|
340
597
|
var shortCssObject = (css) => {
|
|
@@ -363,7 +620,7 @@ var WeaverseRoot = ({ context }) => {
|
|
|
363
620
|
var _a;
|
|
364
621
|
let [, setData] = useState(context.projectData);
|
|
365
622
|
let rootRef = useRef();
|
|
366
|
-
|
|
623
|
+
useEffect2(() => {
|
|
367
624
|
let update = () => setData({});
|
|
368
625
|
context.subscribe(update);
|
|
369
626
|
if (context.projectData) {
|
|
@@ -376,21 +633,21 @@ var WeaverseRoot = ({ context }) => {
|
|
|
376
633
|
}, []);
|
|
377
634
|
let eventHandlers = ((_a = context == null ? void 0 : context.studioBridge) == null ? void 0 : _a.eventHandlers) || {};
|
|
378
635
|
let themeClass = context.stitchesInstance.theme.className;
|
|
379
|
-
return /* @__PURE__ */
|
|
636
|
+
return /* @__PURE__ */ React11.createElement("div", __spreadProps(__spreadValues({
|
|
380
637
|
className: `weaverse-content-root ${themeClass}`
|
|
381
638
|
}, eventHandlers), {
|
|
382
639
|
ref: rootRef
|
|
383
|
-
}), /* @__PURE__ */
|
|
640
|
+
}), /* @__PURE__ */ React11.createElement(WeaverseContextProvider, {
|
|
384
641
|
value: context
|
|
385
|
-
}, /* @__PURE__ */
|
|
642
|
+
}, /* @__PURE__ */ React11.createElement(ItemInstance, {
|
|
386
643
|
id: context.projectData.rootId || 0
|
|
387
644
|
})));
|
|
388
645
|
};
|
|
389
646
|
var ItemComponent = ({ instance }) => {
|
|
390
|
-
let { stitchesInstance, elementInstances } =
|
|
647
|
+
let { stitchesInstance, elementInstances } = useContext3(WeaverseContext);
|
|
391
648
|
let [data, setData] = useState(instance.data);
|
|
392
649
|
let _a = data, { id, type, childIds = [], css, className: cls = "" } = _a, rest = __objRest(_a, ["id", "type", "childIds", "css", "className"]);
|
|
393
|
-
|
|
650
|
+
useEffect2(() => {
|
|
394
651
|
let update = (data2) => setData(__spreadValues({}, data2));
|
|
395
652
|
instance.subscribe(update);
|
|
396
653
|
if (isBrowser && !instance.ref.current) {
|
|
@@ -408,12 +665,12 @@ var ItemComponent = ({ instance }) => {
|
|
|
408
665
|
if (Component.$$typeof === Symbol.for("react.forward_ref")) {
|
|
409
666
|
rest.ref = instance.ref;
|
|
410
667
|
}
|
|
411
|
-
return /* @__PURE__ */
|
|
668
|
+
return /* @__PURE__ */ React11.createElement(Component, __spreadValues({
|
|
412
669
|
key: id,
|
|
413
670
|
"data-wv-type": type,
|
|
414
671
|
"data-wv-id": id,
|
|
415
672
|
className: generateItemClass(instance, stitchesInstance)
|
|
416
|
-
}, rest), childIds.map((id2) => /* @__PURE__ */
|
|
673
|
+
}, rest), childIds.map((id2) => /* @__PURE__ */ React11.createElement(ItemInstance, {
|
|
417
674
|
key: id2,
|
|
418
675
|
id: id2
|
|
419
676
|
})));
|
|
@@ -421,15 +678,15 @@ var ItemComponent = ({ instance }) => {
|
|
|
421
678
|
return null;
|
|
422
679
|
};
|
|
423
680
|
var ItemInstance = ({ id }) => {
|
|
424
|
-
let context =
|
|
681
|
+
let context = useContext3(WeaverseContext);
|
|
425
682
|
let { itemInstances } = context;
|
|
426
683
|
let instance = itemInstances.get(id);
|
|
427
684
|
if (!instance) {
|
|
428
|
-
return /* @__PURE__ */
|
|
685
|
+
return /* @__PURE__ */ React11.createElement("div", {
|
|
429
686
|
style: { display: "none" }
|
|
430
687
|
}, "Item instance ", id, " not found");
|
|
431
688
|
}
|
|
432
|
-
return /* @__PURE__ */
|
|
689
|
+
return /* @__PURE__ */ React11.createElement(ItemComponent, {
|
|
433
690
|
instance
|
|
434
691
|
});
|
|
435
692
|
};
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.6.
|
|
2
|
+
"version": "0.6.14",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"typings": "dist/index.d.ts",
|
|
@@ -31,6 +31,6 @@
|
|
|
31
31
|
"name": "@weaverse/react",
|
|
32
32
|
"author": "Weaverse Team",
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@weaverse/core": "0.6.
|
|
34
|
+
"@weaverse/core": "0.6.14"
|
|
35
35
|
}
|
|
36
36
|
}
|