@weaverse/react 0.6.11 → 0.6.16
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 +291 -25
- package/dist/index.mjs +286 -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,256 @@ 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 {
|
|
472
|
+
type,
|
|
473
|
+
startTime,
|
|
474
|
+
endTime,
|
|
475
|
+
periods,
|
|
476
|
+
redirectUrl,
|
|
477
|
+
openInNewTab,
|
|
478
|
+
showColon,
|
|
479
|
+
showLabel
|
|
480
|
+
} = props;
|
|
481
|
+
const [remaining, setRemaining] = import_react8.default.useState(0);
|
|
482
|
+
if (typeof endTime !== "number") {
|
|
483
|
+
endTime = Number.parseInt(endTime);
|
|
484
|
+
}
|
|
485
|
+
(0, import_react8.useEffect)(() => {
|
|
486
|
+
const flag = setInterval(() => {
|
|
487
|
+
const remainingTime = Math.max((type === "specific" ? new Date(endTime).getTime() : new Date(startTime) + periods * 60 * 1e3) - Date.now(), 0);
|
|
488
|
+
if (!isDesignMode && redirectUrl && remainingTime > 0 && remainingTime < 1e3) {
|
|
489
|
+
window.open(redirectUrl, openInNewTab ? "_blank" : "_self");
|
|
490
|
+
}
|
|
491
|
+
setRemaining(remainingTime);
|
|
492
|
+
}, 1e3);
|
|
493
|
+
return () => {
|
|
494
|
+
clearInterval(flag);
|
|
495
|
+
};
|
|
496
|
+
}, [startTime, endTime, periods, type]);
|
|
497
|
+
const timer = getTime(remaining);
|
|
498
|
+
return /* @__PURE__ */ import_react8.default.createElement("div", __spreadValues({
|
|
499
|
+
ref
|
|
500
|
+
}, props), /* @__PURE__ */ import_react8.default.createElement(timer_block_default, {
|
|
501
|
+
value: timer.days,
|
|
502
|
+
label: showLabel && "days"
|
|
503
|
+
}), /* @__PURE__ */ import_react8.default.createElement("span", {
|
|
504
|
+
className: !showColon && "hidden"
|
|
505
|
+
}, ":"), /* @__PURE__ */ import_react8.default.createElement(timer_block_default, {
|
|
506
|
+
value: timer.hours,
|
|
507
|
+
label: showLabel && "hours"
|
|
508
|
+
}), /* @__PURE__ */ import_react8.default.createElement("span", {
|
|
509
|
+
className: !showColon && "hidden"
|
|
510
|
+
}, ":"), /* @__PURE__ */ import_react8.default.createElement(timer_block_default, {
|
|
511
|
+
value: timer.mins,
|
|
512
|
+
label: showLabel && "minutes"
|
|
513
|
+
}), /* @__PURE__ */ import_react8.default.createElement("span", {
|
|
514
|
+
className: !showColon && "hidden"
|
|
515
|
+
}, ":"), /* @__PURE__ */ import_react8.default.createElement(timer_block_default, {
|
|
516
|
+
value: timer.secs,
|
|
517
|
+
label: showLabel && "seconds"
|
|
518
|
+
}));
|
|
519
|
+
});
|
|
520
|
+
Countdown.defaultProps = {
|
|
521
|
+
type: "specific",
|
|
522
|
+
startTime: Date.now(),
|
|
523
|
+
endTime: 1661140528e3,
|
|
524
|
+
redirectUrl: "",
|
|
525
|
+
openInNewTab: false,
|
|
526
|
+
showLabel: true,
|
|
527
|
+
showColon: true
|
|
528
|
+
};
|
|
529
|
+
var schema9 = {
|
|
530
|
+
title: "Countdown",
|
|
531
|
+
type: "countdown",
|
|
532
|
+
parentType: "container",
|
|
533
|
+
toolbar: [
|
|
534
|
+
{
|
|
535
|
+
type: "delete"
|
|
536
|
+
},
|
|
537
|
+
{
|
|
538
|
+
type: "duplicate"
|
|
539
|
+
},
|
|
540
|
+
{
|
|
541
|
+
type: "link"
|
|
542
|
+
},
|
|
543
|
+
{
|
|
544
|
+
type: "color"
|
|
545
|
+
}
|
|
546
|
+
],
|
|
547
|
+
data: {
|
|
548
|
+
css: {
|
|
549
|
+
"@desktop": {
|
|
550
|
+
fontFamily: "Inter",
|
|
551
|
+
fontSize: 36,
|
|
552
|
+
fontWeight: 500,
|
|
553
|
+
display: "grid",
|
|
554
|
+
gridAutoFlow: "column",
|
|
555
|
+
gap: 10,
|
|
556
|
+
"& > div": {
|
|
557
|
+
width: 48,
|
|
558
|
+
textAlign: "center"
|
|
559
|
+
},
|
|
560
|
+
"& .wv-countdown-label": {
|
|
561
|
+
fontSize: 10
|
|
562
|
+
},
|
|
563
|
+
"& > span": {
|
|
564
|
+
lineHeight: "100%"
|
|
565
|
+
},
|
|
566
|
+
"& .hidden": {
|
|
567
|
+
visibility: "hidden"
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
},
|
|
572
|
+
flags: {
|
|
573
|
+
draggable: true
|
|
574
|
+
}
|
|
575
|
+
};
|
|
576
|
+
var countdown_default = Countdown;
|
|
577
|
+
|
|
324
578
|
// src/elements/index.ts
|
|
325
579
|
var elements = {
|
|
326
580
|
Button: {
|
|
@@ -346,6 +600,18 @@ var elements = {
|
|
|
346
600
|
Image: {
|
|
347
601
|
Component: image_default,
|
|
348
602
|
schema: schema6
|
|
603
|
+
},
|
|
604
|
+
Video: {
|
|
605
|
+
Component: video_default,
|
|
606
|
+
schema: schema7
|
|
607
|
+
},
|
|
608
|
+
Map: {
|
|
609
|
+
Component: map_default,
|
|
610
|
+
schema: schema8
|
|
611
|
+
},
|
|
612
|
+
Countdown: {
|
|
613
|
+
Component: countdown_default,
|
|
614
|
+
schema: schema9
|
|
349
615
|
}
|
|
350
616
|
};
|
|
351
617
|
var elements_default = elements;
|
|
@@ -358,13 +624,13 @@ var createRootContext = (configs) => {
|
|
|
358
624
|
});
|
|
359
625
|
return rootContext;
|
|
360
626
|
};
|
|
361
|
-
var WeaverseContext = (0,
|
|
627
|
+
var WeaverseContext = (0, import_react9.createContext)({});
|
|
362
628
|
var WeaverseContextProvider = WeaverseContext.Provider;
|
|
363
629
|
var WeaverseContextConsumer = WeaverseContext.Consumer;
|
|
364
630
|
|
|
365
631
|
// src/renderer.tsx
|
|
366
632
|
var import_core2 = require("@weaverse/core");
|
|
367
|
-
var
|
|
633
|
+
var import_react10 = __toESM(require("react"));
|
|
368
634
|
|
|
369
635
|
// src/utils/index.ts
|
|
370
636
|
var shortCssObject = (css) => {
|
|
@@ -391,9 +657,9 @@ function generateItemClass(instance, stitchesInstance) {
|
|
|
391
657
|
// src/renderer.tsx
|
|
392
658
|
var WeaverseRoot = ({ context }) => {
|
|
393
659
|
var _a;
|
|
394
|
-
let [, setData] = (0,
|
|
395
|
-
let rootRef = (0,
|
|
396
|
-
(0,
|
|
660
|
+
let [, setData] = (0, import_react10.useState)(context.projectData);
|
|
661
|
+
let rootRef = (0, import_react10.useRef)();
|
|
662
|
+
(0, import_react10.useEffect)(() => {
|
|
397
663
|
let update = () => setData({});
|
|
398
664
|
context.subscribe(update);
|
|
399
665
|
if (context.projectData) {
|
|
@@ -406,21 +672,21 @@ var WeaverseRoot = ({ context }) => {
|
|
|
406
672
|
}, []);
|
|
407
673
|
let eventHandlers = ((_a = context == null ? void 0 : context.studioBridge) == null ? void 0 : _a.eventHandlers) || {};
|
|
408
674
|
let themeClass = context.stitchesInstance.theme.className;
|
|
409
|
-
return /* @__PURE__ */
|
|
675
|
+
return /* @__PURE__ */ import_react10.default.createElement("div", __spreadProps(__spreadValues({
|
|
410
676
|
className: `weaverse-content-root ${themeClass}`
|
|
411
677
|
}, eventHandlers), {
|
|
412
678
|
ref: rootRef
|
|
413
|
-
}), /* @__PURE__ */
|
|
679
|
+
}), /* @__PURE__ */ import_react10.default.createElement(WeaverseContextProvider, {
|
|
414
680
|
value: context
|
|
415
|
-
}, /* @__PURE__ */
|
|
681
|
+
}, /* @__PURE__ */ import_react10.default.createElement(ItemInstance, {
|
|
416
682
|
id: context.projectData.rootId || 0
|
|
417
683
|
})));
|
|
418
684
|
};
|
|
419
685
|
var ItemComponent = ({ instance }) => {
|
|
420
|
-
let { stitchesInstance, elementInstances } = (0,
|
|
421
|
-
let [data, setData] = (0,
|
|
686
|
+
let { stitchesInstance, elementInstances } = (0, import_react10.useContext)(WeaverseContext);
|
|
687
|
+
let [data, setData] = (0, import_react10.useState)(instance.data);
|
|
422
688
|
let _a = data, { id, type, childIds = [], css, className: cls = "" } = _a, rest = __objRest(_a, ["id", "type", "childIds", "css", "className"]);
|
|
423
|
-
(0,
|
|
689
|
+
(0, import_react10.useEffect)(() => {
|
|
424
690
|
let update = (data2) => setData(__spreadValues({}, data2));
|
|
425
691
|
instance.subscribe(update);
|
|
426
692
|
if (import_core2.isBrowser && !instance.ref.current) {
|
|
@@ -438,12 +704,12 @@ var ItemComponent = ({ instance }) => {
|
|
|
438
704
|
if (Component.$$typeof === Symbol.for("react.forward_ref")) {
|
|
439
705
|
rest.ref = instance.ref;
|
|
440
706
|
}
|
|
441
|
-
return /* @__PURE__ */
|
|
707
|
+
return /* @__PURE__ */ import_react10.default.createElement(Component, __spreadValues({
|
|
442
708
|
key: id,
|
|
443
709
|
"data-wv-type": type,
|
|
444
710
|
"data-wv-id": id,
|
|
445
711
|
className: generateItemClass(instance, stitchesInstance)
|
|
446
|
-
}, rest), childIds.map((id2) => /* @__PURE__ */
|
|
712
|
+
}, rest), childIds.map((id2) => /* @__PURE__ */ import_react10.default.createElement(ItemInstance, {
|
|
447
713
|
key: id2,
|
|
448
714
|
id: id2
|
|
449
715
|
})));
|
|
@@ -451,15 +717,15 @@ var ItemComponent = ({ instance }) => {
|
|
|
451
717
|
return null;
|
|
452
718
|
};
|
|
453
719
|
var ItemInstance = ({ id }) => {
|
|
454
|
-
let context = (0,
|
|
720
|
+
let context = (0, import_react10.useContext)(WeaverseContext);
|
|
455
721
|
let { itemInstances } = context;
|
|
456
722
|
let instance = itemInstances.get(id);
|
|
457
723
|
if (!instance) {
|
|
458
|
-
return /* @__PURE__ */
|
|
724
|
+
return /* @__PURE__ */ import_react10.default.createElement("div", {
|
|
459
725
|
style: { display: "none" }
|
|
460
726
|
}, "Item instance ", id, " not found");
|
|
461
727
|
}
|
|
462
|
-
return /* @__PURE__ */
|
|
728
|
+
return /* @__PURE__ */ import_react10.default.createElement(ItemComponent, {
|
|
463
729
|
instance
|
|
464
730
|
});
|
|
465
731
|
};
|
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,256 @@ 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 {
|
|
442
|
+
type,
|
|
443
|
+
startTime,
|
|
444
|
+
endTime,
|
|
445
|
+
periods,
|
|
446
|
+
redirectUrl,
|
|
447
|
+
openInNewTab,
|
|
448
|
+
showColon,
|
|
449
|
+
showLabel
|
|
450
|
+
} = props;
|
|
451
|
+
const [remaining, setRemaining] = React10.useState(0);
|
|
452
|
+
if (typeof endTime !== "number") {
|
|
453
|
+
endTime = Number.parseInt(endTime);
|
|
454
|
+
}
|
|
455
|
+
useEffect(() => {
|
|
456
|
+
const flag = setInterval(() => {
|
|
457
|
+
const remainingTime = Math.max((type === "specific" ? new Date(endTime).getTime() : new Date(startTime) + periods * 60 * 1e3) - Date.now(), 0);
|
|
458
|
+
if (!isDesignMode && redirectUrl && remainingTime > 0 && remainingTime < 1e3) {
|
|
459
|
+
window.open(redirectUrl, openInNewTab ? "_blank" : "_self");
|
|
460
|
+
}
|
|
461
|
+
setRemaining(remainingTime);
|
|
462
|
+
}, 1e3);
|
|
463
|
+
return () => {
|
|
464
|
+
clearInterval(flag);
|
|
465
|
+
};
|
|
466
|
+
}, [startTime, endTime, periods, type]);
|
|
467
|
+
const timer = getTime(remaining);
|
|
468
|
+
return /* @__PURE__ */ React10.createElement("div", __spreadValues({
|
|
469
|
+
ref
|
|
470
|
+
}, props), /* @__PURE__ */ React10.createElement(timer_block_default, {
|
|
471
|
+
value: timer.days,
|
|
472
|
+
label: showLabel && "days"
|
|
473
|
+
}), /* @__PURE__ */ React10.createElement("span", {
|
|
474
|
+
className: !showColon && "hidden"
|
|
475
|
+
}, ":"), /* @__PURE__ */ React10.createElement(timer_block_default, {
|
|
476
|
+
value: timer.hours,
|
|
477
|
+
label: showLabel && "hours"
|
|
478
|
+
}), /* @__PURE__ */ React10.createElement("span", {
|
|
479
|
+
className: !showColon && "hidden"
|
|
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"
|
|
488
|
+
}));
|
|
489
|
+
});
|
|
490
|
+
Countdown.defaultProps = {
|
|
491
|
+
type: "specific",
|
|
492
|
+
startTime: Date.now(),
|
|
493
|
+
endTime: 1661140528e3,
|
|
494
|
+
redirectUrl: "",
|
|
495
|
+
openInNewTab: false,
|
|
496
|
+
showLabel: true,
|
|
497
|
+
showColon: true
|
|
498
|
+
};
|
|
499
|
+
var schema9 = {
|
|
500
|
+
title: "Countdown",
|
|
501
|
+
type: "countdown",
|
|
502
|
+
parentType: "container",
|
|
503
|
+
toolbar: [
|
|
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"
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
},
|
|
542
|
+
flags: {
|
|
543
|
+
draggable: true
|
|
544
|
+
}
|
|
545
|
+
};
|
|
546
|
+
var countdown_default = Countdown;
|
|
547
|
+
|
|
294
548
|
// src/elements/index.ts
|
|
295
549
|
var elements = {
|
|
296
550
|
Button: {
|
|
@@ -316,6 +570,18 @@ var elements = {
|
|
|
316
570
|
Image: {
|
|
317
571
|
Component: image_default,
|
|
318
572
|
schema: schema6
|
|
573
|
+
},
|
|
574
|
+
Video: {
|
|
575
|
+
Component: video_default,
|
|
576
|
+
schema: schema7
|
|
577
|
+
},
|
|
578
|
+
Map: {
|
|
579
|
+
Component: map_default,
|
|
580
|
+
schema: schema8
|
|
581
|
+
},
|
|
582
|
+
Countdown: {
|
|
583
|
+
Component: countdown_default,
|
|
584
|
+
schema: schema9
|
|
319
585
|
}
|
|
320
586
|
};
|
|
321
587
|
var elements_default = elements;
|
|
@@ -334,7 +600,7 @@ var WeaverseContextConsumer = WeaverseContext.Consumer;
|
|
|
334
600
|
|
|
335
601
|
// src/renderer.tsx
|
|
336
602
|
import { isBrowser } from "@weaverse/core";
|
|
337
|
-
import
|
|
603
|
+
import React11, { useContext as useContext3, useEffect as useEffect2, useRef, useState } from "react";
|
|
338
604
|
|
|
339
605
|
// src/utils/index.ts
|
|
340
606
|
var shortCssObject = (css) => {
|
|
@@ -363,7 +629,7 @@ var WeaverseRoot = ({ context }) => {
|
|
|
363
629
|
var _a;
|
|
364
630
|
let [, setData] = useState(context.projectData);
|
|
365
631
|
let rootRef = useRef();
|
|
366
|
-
|
|
632
|
+
useEffect2(() => {
|
|
367
633
|
let update = () => setData({});
|
|
368
634
|
context.subscribe(update);
|
|
369
635
|
if (context.projectData) {
|
|
@@ -376,21 +642,21 @@ var WeaverseRoot = ({ context }) => {
|
|
|
376
642
|
}, []);
|
|
377
643
|
let eventHandlers = ((_a = context == null ? void 0 : context.studioBridge) == null ? void 0 : _a.eventHandlers) || {};
|
|
378
644
|
let themeClass = context.stitchesInstance.theme.className;
|
|
379
|
-
return /* @__PURE__ */
|
|
645
|
+
return /* @__PURE__ */ React11.createElement("div", __spreadProps(__spreadValues({
|
|
380
646
|
className: `weaverse-content-root ${themeClass}`
|
|
381
647
|
}, eventHandlers), {
|
|
382
648
|
ref: rootRef
|
|
383
|
-
}), /* @__PURE__ */
|
|
649
|
+
}), /* @__PURE__ */ React11.createElement(WeaverseContextProvider, {
|
|
384
650
|
value: context
|
|
385
|
-
}, /* @__PURE__ */
|
|
651
|
+
}, /* @__PURE__ */ React11.createElement(ItemInstance, {
|
|
386
652
|
id: context.projectData.rootId || 0
|
|
387
653
|
})));
|
|
388
654
|
};
|
|
389
655
|
var ItemComponent = ({ instance }) => {
|
|
390
|
-
let { stitchesInstance, elementInstances } =
|
|
656
|
+
let { stitchesInstance, elementInstances } = useContext3(WeaverseContext);
|
|
391
657
|
let [data, setData] = useState(instance.data);
|
|
392
658
|
let _a = data, { id, type, childIds = [], css, className: cls = "" } = _a, rest = __objRest(_a, ["id", "type", "childIds", "css", "className"]);
|
|
393
|
-
|
|
659
|
+
useEffect2(() => {
|
|
394
660
|
let update = (data2) => setData(__spreadValues({}, data2));
|
|
395
661
|
instance.subscribe(update);
|
|
396
662
|
if (isBrowser && !instance.ref.current) {
|
|
@@ -408,12 +674,12 @@ var ItemComponent = ({ instance }) => {
|
|
|
408
674
|
if (Component.$$typeof === Symbol.for("react.forward_ref")) {
|
|
409
675
|
rest.ref = instance.ref;
|
|
410
676
|
}
|
|
411
|
-
return /* @__PURE__ */
|
|
677
|
+
return /* @__PURE__ */ React11.createElement(Component, __spreadValues({
|
|
412
678
|
key: id,
|
|
413
679
|
"data-wv-type": type,
|
|
414
680
|
"data-wv-id": id,
|
|
415
681
|
className: generateItemClass(instance, stitchesInstance)
|
|
416
|
-
}, rest), childIds.map((id2) => /* @__PURE__ */
|
|
682
|
+
}, rest), childIds.map((id2) => /* @__PURE__ */ React11.createElement(ItemInstance, {
|
|
417
683
|
key: id2,
|
|
418
684
|
id: id2
|
|
419
685
|
})));
|
|
@@ -421,15 +687,15 @@ var ItemComponent = ({ instance }) => {
|
|
|
421
687
|
return null;
|
|
422
688
|
};
|
|
423
689
|
var ItemInstance = ({ id }) => {
|
|
424
|
-
let context =
|
|
690
|
+
let context = useContext3(WeaverseContext);
|
|
425
691
|
let { itemInstances } = context;
|
|
426
692
|
let instance = itemInstances.get(id);
|
|
427
693
|
if (!instance) {
|
|
428
|
-
return /* @__PURE__ */
|
|
694
|
+
return /* @__PURE__ */ React11.createElement("div", {
|
|
429
695
|
style: { display: "none" }
|
|
430
696
|
}, "Item instance ", id, " not found");
|
|
431
697
|
}
|
|
432
|
-
return /* @__PURE__ */
|
|
698
|
+
return /* @__PURE__ */ React11.createElement(ItemComponent, {
|
|
433
699
|
instance
|
|
434
700
|
});
|
|
435
701
|
};
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.6.
|
|
2
|
+
"version": "0.6.16",
|
|
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.16"
|
|
35
35
|
}
|
|
36
36
|
}
|