@weaverse/react 0.7.27 → 0.7.28
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 +41 -11
- package/dist/index.js +333 -225
- package/dist/index.mjs +284 -160
- package/package.json +4 -2
package/dist/index.mjs
CHANGED
|
@@ -1,22 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __export = (target, all) => {
|
|
3
|
+
for (var name in all)
|
|
4
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
// src/index.ts
|
|
8
|
+
export * from "@weaverse/core";
|
|
4
9
|
|
|
5
10
|
// src/context.ts
|
|
6
11
|
import { Weaverse } from "@weaverse/core";
|
|
7
12
|
import { createContext } from "react";
|
|
8
|
-
var createRootContext = (configs) => {
|
|
9
|
-
let rootContext = new Weaverse(configs);
|
|
10
|
-
Object.keys(Elements).forEach((key) => {
|
|
11
|
-
rootContext.registerElement(Elements[key]);
|
|
12
|
-
});
|
|
13
|
-
return rootContext;
|
|
14
|
-
};
|
|
15
|
-
var WeaverseContext = createContext({});
|
|
16
|
-
var WeaverseContextProvider = WeaverseContext.Provider;
|
|
17
|
-
var WeaverseContextConsumer = WeaverseContext.Consumer;
|
|
18
13
|
|
|
19
|
-
// src/elements/
|
|
14
|
+
// src/elements/Button.tsx
|
|
15
|
+
import * as React from "react";
|
|
16
|
+
import { useContext } from "react";
|
|
20
17
|
var Button = React.forwardRef((props, ref) => {
|
|
21
18
|
let { isDesignMode } = useContext(WeaverseContext);
|
|
22
19
|
let { text, clickAction, linkTo, openInNewTab, ...rest } = props;
|
|
@@ -52,9 +49,9 @@ var css = {
|
|
|
52
49
|
textDecoration: "none"
|
|
53
50
|
}
|
|
54
51
|
};
|
|
55
|
-
var
|
|
52
|
+
var Button_default = Button;
|
|
56
53
|
|
|
57
|
-
// src/elements/
|
|
54
|
+
// src/elements/Container.tsx
|
|
58
55
|
import React2, { forwardRef as forwardRef2 } from "react";
|
|
59
56
|
var Container = forwardRef2(
|
|
60
57
|
(props, ref) => {
|
|
@@ -80,12 +77,77 @@ var css2 = {
|
|
|
80
77
|
}
|
|
81
78
|
};
|
|
82
79
|
Container.defaultProps = {};
|
|
83
|
-
var
|
|
80
|
+
var Container_default = Container;
|
|
84
81
|
|
|
85
|
-
// src/elements/
|
|
82
|
+
// src/elements/Countdown/index.tsx
|
|
86
83
|
import React4, { forwardRef as forwardRef3, useContext as useContext2, useEffect } from "react";
|
|
87
84
|
|
|
88
|
-
// src/
|
|
85
|
+
// src/constant/index.ts
|
|
86
|
+
var TIMES = ["days", "hours", "minutes", "seconds"];
|
|
87
|
+
var COUNTDOWN_KEY = "wv-cd-evergreen-start";
|
|
88
|
+
var INSTAGRAM_API = "https://graph.instagram.com";
|
|
89
|
+
|
|
90
|
+
// src/utils/css.ts
|
|
91
|
+
function shortCssObject(css10) {
|
|
92
|
+
return {
|
|
93
|
+
"@desktop": css10["@desktop"],
|
|
94
|
+
"@mobile": css10["@mobile"]
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
var permanentClasses = {};
|
|
98
|
+
function generateItemClass(instance, stitchesInstance) {
|
|
99
|
+
let { css: css10, type, className: cls = "" } = instance.data;
|
|
100
|
+
let className = "";
|
|
101
|
+
let permanentClass = "";
|
|
102
|
+
let perCss = instance.Element?.permanentCss;
|
|
103
|
+
if (perCss) {
|
|
104
|
+
if (type in permanentClasses) {
|
|
105
|
+
permanentClass = permanentClasses[type];
|
|
106
|
+
} else {
|
|
107
|
+
let { className: perCls } = stitchesInstance.css(perCss)();
|
|
108
|
+
Object.assign(permanentClasses, { [type]: perCls });
|
|
109
|
+
permanentClass = perCls;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
className = permanentClass;
|
|
113
|
+
if (css10) {
|
|
114
|
+
let formattedCss = shortCssObject(css10);
|
|
115
|
+
let { className: newClass = "" } = stitchesInstance.css(formattedCss)();
|
|
116
|
+
let { stitchesClass } = instance;
|
|
117
|
+
let otherClass = (instance.ref.current?.className || "").replace(stitchesClass, "").replace(cls, "").replace(permanentClass, "").trim();
|
|
118
|
+
className = `${permanentClass} ${cls} ${newClass} ${otherClass}`.trim();
|
|
119
|
+
instance.stitchesClass = newClass;
|
|
120
|
+
}
|
|
121
|
+
return className;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// src/utils/index.ts
|
|
125
|
+
function getTime(_seconds) {
|
|
126
|
+
let ONE_MINUTE = 60 * 1e3;
|
|
127
|
+
let ONE_HOUR = 60 * ONE_MINUTE;
|
|
128
|
+
let ONE_DAY = 24 * ONE_HOUR;
|
|
129
|
+
let days = Math.floor(_seconds / ONE_DAY);
|
|
130
|
+
let hours = Math.floor((_seconds - days * ONE_DAY) / ONE_HOUR);
|
|
131
|
+
let minutes = Math.floor(
|
|
132
|
+
(_seconds - days * ONE_DAY - hours * ONE_HOUR) / ONE_MINUTE
|
|
133
|
+
);
|
|
134
|
+
let seconds = Math.floor(
|
|
135
|
+
(_seconds - days * ONE_DAY - hours * ONE_HOUR - minutes * ONE_MINUTE) / 1e3
|
|
136
|
+
);
|
|
137
|
+
return { days, hours, minutes, seconds };
|
|
138
|
+
}
|
|
139
|
+
function getYoutubeEmbedId(url) {
|
|
140
|
+
const match = url.match(
|
|
141
|
+
/(?:https?:\/\/)?(?:www\.)?(?:youtube\.com|youtu\.be)\/(?:watch\?v=)?(.+)/
|
|
142
|
+
);
|
|
143
|
+
return match ? match[1] : null;
|
|
144
|
+
}
|
|
145
|
+
function getVimeoId(url) {
|
|
146
|
+
const match = url.match(/(?:https?:\/\/)?(?:www\.)?vimeo\.com\/(.+)/);
|
|
147
|
+
return match ? match[1] : null;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// src/elements/Countdown/TimerBlock.tsx
|
|
89
151
|
import React3 from "react";
|
|
90
152
|
function TimerBlock({ value, label }) {
|
|
91
153
|
return /* @__PURE__ */ React3.createElement("div", {
|
|
@@ -97,25 +159,7 @@ function TimerBlock({ value, label }) {
|
|
|
97
159
|
}, label));
|
|
98
160
|
}
|
|
99
161
|
|
|
100
|
-
// src/elements/
|
|
101
|
-
var times = ["days", "hours", "minutes", "seconds"];
|
|
102
|
-
function getTime(_seconds) {
|
|
103
|
-
const ONE_MINUTE = 60 * 1e3;
|
|
104
|
-
const ONE_HOUR = 60 * ONE_MINUTE;
|
|
105
|
-
const ONE_DAY = 24 * ONE_HOUR;
|
|
106
|
-
const days = Math.floor(_seconds / ONE_DAY);
|
|
107
|
-
const hours = Math.floor((_seconds - days * ONE_DAY) / ONE_HOUR);
|
|
108
|
-
const minutes = Math.floor(
|
|
109
|
-
(_seconds - days * ONE_DAY - hours * ONE_HOUR) / ONE_MINUTE
|
|
110
|
-
);
|
|
111
|
-
const seconds = Math.floor(
|
|
112
|
-
(_seconds - days * ONE_DAY - hours * ONE_HOUR - minutes * ONE_MINUTE) / 1e3
|
|
113
|
-
);
|
|
114
|
-
return { days, hours, minutes, seconds };
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
// src/elements/countdown/index.tsx
|
|
118
|
-
var countdownKey = "wv-cd-evergreen-start";
|
|
162
|
+
// src/elements/Countdown/index.tsx
|
|
119
163
|
var Countdown = forwardRef3(
|
|
120
164
|
(props, ref) => {
|
|
121
165
|
const { isDesignMode } = useContext2(WeaverseContext);
|
|
@@ -139,16 +183,16 @@ var Countdown = forwardRef3(
|
|
|
139
183
|
const getStartTime = () => {
|
|
140
184
|
let startTime = startTimeProp;
|
|
141
185
|
if (timerType === "evergreen") {
|
|
142
|
-
const start = localStorage.getItem(
|
|
186
|
+
const start = localStorage.getItem(COUNTDOWN_KEY);
|
|
143
187
|
if (start) {
|
|
144
188
|
startTime = Number.parseInt(start);
|
|
145
189
|
if (startTime + periods < Date.now()) {
|
|
146
190
|
startTime = Date.now();
|
|
147
|
-
localStorage.setItem(
|
|
191
|
+
localStorage.setItem(COUNTDOWN_KEY, startTime.toString());
|
|
148
192
|
}
|
|
149
193
|
} else {
|
|
150
194
|
startTime = Date.now();
|
|
151
|
-
localStorage.setItem(
|
|
195
|
+
localStorage.setItem(COUNTDOWN_KEY, startTime.toString());
|
|
152
196
|
}
|
|
153
197
|
}
|
|
154
198
|
return startTime;
|
|
@@ -177,7 +221,7 @@ var Countdown = forwardRef3(
|
|
|
177
221
|
return /* @__PURE__ */ React4.createElement("div", {
|
|
178
222
|
ref,
|
|
179
223
|
...rest
|
|
180
|
-
},
|
|
224
|
+
}, TIMES.map((time) => {
|
|
181
225
|
return /* @__PURE__ */ React4.createElement(React4.Fragment, {
|
|
182
226
|
key: time
|
|
183
227
|
}, /* @__PURE__ */ React4.createElement(TimerBlock, {
|
|
@@ -225,9 +269,9 @@ Countdown.defaultProps = {
|
|
|
225
269
|
showLabel: true,
|
|
226
270
|
showColon: true
|
|
227
271
|
};
|
|
228
|
-
var
|
|
272
|
+
var Countdown_default = Countdown;
|
|
229
273
|
|
|
230
|
-
// src/elements/
|
|
274
|
+
// src/elements/Image.tsx
|
|
231
275
|
import React5 from "react";
|
|
232
276
|
var Image = React5.forwardRef(
|
|
233
277
|
(props, ref) => {
|
|
@@ -285,9 +329,9 @@ Image.defaultProps = {
|
|
|
285
329
|
openLinkInNewTab: false,
|
|
286
330
|
linkTo: ""
|
|
287
331
|
};
|
|
288
|
-
var
|
|
332
|
+
var Image_default = Image;
|
|
289
333
|
|
|
290
|
-
// src/elements/
|
|
334
|
+
// src/elements/Layout.tsx
|
|
291
335
|
import React6, { forwardRef as forwardRef4 } from "react";
|
|
292
336
|
var Layout = forwardRef4((props, ref) => {
|
|
293
337
|
let {
|
|
@@ -380,9 +424,9 @@ Layout.defaultProps = {
|
|
|
380
424
|
gap: 16,
|
|
381
425
|
rowSize: 48
|
|
382
426
|
};
|
|
383
|
-
var
|
|
427
|
+
var Layout_default = Layout;
|
|
384
428
|
|
|
385
|
-
// src/elements/
|
|
429
|
+
// src/elements/Map.tsx
|
|
386
430
|
import React7, { forwardRef as forwardRef5 } from "react";
|
|
387
431
|
var Map = forwardRef5((props, ref) => {
|
|
388
432
|
let { place, zoom, ...rest } = props;
|
|
@@ -404,9 +448,9 @@ Map.defaultProps = {
|
|
|
404
448
|
place: "Hanoi",
|
|
405
449
|
zoom: 14
|
|
406
450
|
};
|
|
407
|
-
var
|
|
451
|
+
var Map_default = Map;
|
|
408
452
|
|
|
409
|
-
// src/elements/
|
|
453
|
+
// src/elements/Text.tsx
|
|
410
454
|
import * as React8 from "react";
|
|
411
455
|
var Text = React8.forwardRef(
|
|
412
456
|
(props, ref) => {
|
|
@@ -429,40 +473,32 @@ var css7 = {
|
|
|
429
473
|
Text.defaultProps = {
|
|
430
474
|
value: "The quick brown fox jumps over the lazy dog"
|
|
431
475
|
};
|
|
432
|
-
var
|
|
476
|
+
var Text_default = Text;
|
|
433
477
|
|
|
434
|
-
// src/elements/
|
|
478
|
+
// src/elements/Video/index.tsx
|
|
435
479
|
import React12, { forwardRef as forwardRef7, useContext as useContext3 } from "react";
|
|
436
480
|
|
|
437
|
-
// src/elements/
|
|
438
|
-
function getYoutubeEmbedId(url) {
|
|
439
|
-
const match = url.match(
|
|
440
|
-
/(?:https?:\/\/)?(?:www\.)?(?:youtube\.com|youtu\.be)\/(?:watch\?v=)?(.+)/
|
|
441
|
-
);
|
|
442
|
-
return match ? match[1] : null;
|
|
443
|
-
}
|
|
444
|
-
function getVimeoId(url) {
|
|
445
|
-
const match = url.match(/(?:https?:\/\/)?(?:www\.)?vimeo\.com\/(.+)/);
|
|
446
|
-
return match ? match[1] : null;
|
|
447
|
-
}
|
|
448
|
-
|
|
449
|
-
// src/elements/video/Youtube.tsx
|
|
481
|
+
// src/elements/Video/HTMLVideo.tsx
|
|
450
482
|
import React9 from "react";
|
|
451
|
-
function
|
|
452
|
-
let {
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
483
|
+
function HTMLVideo(props) {
|
|
484
|
+
let { src, type, controls, autoPlay, loop, muted } = props;
|
|
485
|
+
return /* @__PURE__ */ React9.createElement("video", {
|
|
486
|
+
controls,
|
|
487
|
+
autoPlay,
|
|
488
|
+
loop,
|
|
489
|
+
muted,
|
|
490
|
+
controlsList: "nodownload",
|
|
491
|
+
disablePictureInPicture: true
|
|
492
|
+
}, /* @__PURE__ */ React9.createElement("source", {
|
|
493
|
+
src,
|
|
494
|
+
type: type || "video/mp4"
|
|
495
|
+
}), /* @__PURE__ */ React9.createElement("source", {
|
|
496
|
+
src,
|
|
497
|
+
type: "video/ogg"
|
|
498
|
+
}), "Your browser does not support the video tag.");
|
|
463
499
|
}
|
|
464
500
|
|
|
465
|
-
// src/elements/
|
|
501
|
+
// src/elements/Video/Vimeo.tsx
|
|
466
502
|
import React10 from "react";
|
|
467
503
|
function Vimeo(props) {
|
|
468
504
|
let { vimeoId, controls, autoPlay, loop, muted } = props;
|
|
@@ -476,27 +512,28 @@ function Vimeo(props) {
|
|
|
476
512
|
});
|
|
477
513
|
}
|
|
478
514
|
|
|
479
|
-
// src/elements/
|
|
515
|
+
// src/elements/Video/Youtube.tsx
|
|
480
516
|
import React11 from "react";
|
|
481
|
-
function
|
|
482
|
-
let {
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
loop,
|
|
487
|
-
muted
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
517
|
+
function Youtube(props) {
|
|
518
|
+
let { youtubeId, controls, autoPlay, loop, muted } = props;
|
|
519
|
+
let params = new URLSearchParams({
|
|
520
|
+
autoplay: autoPlay ? "1" : "0",
|
|
521
|
+
controls: controls ? "1" : "0",
|
|
522
|
+
loop: loop ? "1" : "0",
|
|
523
|
+
mute: muted ? "1" : "0"
|
|
524
|
+
});
|
|
525
|
+
let youtubeSrc = `https://www.youtube.com/embed/${youtubeId}?${params.toString()}`;
|
|
526
|
+
let allow = `accelerometer;${autoPlay ? "autoplay;" : ""} clipboard-write; encrypted-media; gyroscope; picture-in-picture`;
|
|
527
|
+
return /* @__PURE__ */ React11.createElement("iframe", {
|
|
528
|
+
src: youtubeSrc,
|
|
529
|
+
width: "100%",
|
|
530
|
+
height: "100%",
|
|
531
|
+
allowFullScreen: true,
|
|
532
|
+
allow
|
|
533
|
+
});
|
|
497
534
|
}
|
|
498
535
|
|
|
499
|
-
// src/elements/
|
|
536
|
+
// src/elements/Video/index.tsx
|
|
500
537
|
var Video = forwardRef7((props, ref) => {
|
|
501
538
|
let { isDesignMode } = useContext3(WeaverseContext);
|
|
502
539
|
let {
|
|
@@ -524,7 +561,7 @@ var Video = forwardRef7((props, ref) => {
|
|
|
524
561
|
vimeoId
|
|
525
562
|
});
|
|
526
563
|
} else {
|
|
527
|
-
content = /* @__PURE__ */ React12.createElement(
|
|
564
|
+
content = /* @__PURE__ */ React12.createElement(HTMLVideo, {
|
|
528
565
|
...videoProps
|
|
529
566
|
});
|
|
530
567
|
}
|
|
@@ -550,12 +587,12 @@ Video.defaultProps = {
|
|
|
550
587
|
autoPlay: true,
|
|
551
588
|
muted: true
|
|
552
589
|
};
|
|
553
|
-
var
|
|
590
|
+
var Video_default = Video;
|
|
554
591
|
|
|
555
|
-
// src/elements/
|
|
592
|
+
// src/elements/Instagram.tsx
|
|
556
593
|
import React14, { forwardRef as forwardRef9, useEffect as useEffect2, useState } from "react";
|
|
557
594
|
|
|
558
|
-
// src/
|
|
595
|
+
// src/components/Placeholder.tsx
|
|
559
596
|
import React13, { forwardRef as forwardRef8 } from "react";
|
|
560
597
|
var Placeholder = forwardRef8(
|
|
561
598
|
(props, ref) => {
|
|
@@ -571,8 +608,7 @@ var Placeholder = forwardRef8(
|
|
|
571
608
|
);
|
|
572
609
|
var Placeholder_default = Placeholder;
|
|
573
610
|
|
|
574
|
-
// src/elements/
|
|
575
|
-
var INSTAGRAM_API = "https://graph.instagram.com";
|
|
611
|
+
// src/elements/Instagram.tsx
|
|
576
612
|
var Instagram = forwardRef9(
|
|
577
613
|
(props, ref) => {
|
|
578
614
|
let { token, username, numberOfImages, imagesPerRow, gap, ...rest } = props;
|
|
@@ -642,6 +678,19 @@ var permanentCss2 = {
|
|
|
642
678
|
objectFit: "cover"
|
|
643
679
|
}
|
|
644
680
|
}
|
|
681
|
+
},
|
|
682
|
+
"@mobile": {
|
|
683
|
+
".wv-ig-media-container": {
|
|
684
|
+
overflowX: "auto",
|
|
685
|
+
display: "flex",
|
|
686
|
+
scrollSnapType: "x mandatory"
|
|
687
|
+
},
|
|
688
|
+
".wv-ig-media-container a": {
|
|
689
|
+
scrollSnapAlign: "start",
|
|
690
|
+
flexGrow: 0,
|
|
691
|
+
flexShrink: 0,
|
|
692
|
+
flexBasis: "100%"
|
|
693
|
+
}
|
|
645
694
|
}
|
|
646
695
|
};
|
|
647
696
|
Instagram.defaultProps = {
|
|
@@ -651,101 +700,179 @@ Instagram.defaultProps = {
|
|
|
651
700
|
imagesPerRow: 4,
|
|
652
701
|
gap: 0
|
|
653
702
|
};
|
|
654
|
-
var
|
|
703
|
+
var Instagram_default = Instagram;
|
|
655
704
|
|
|
656
705
|
// src/elements/index.ts
|
|
657
|
-
var SharedComponents = {
|
|
658
|
-
Placeholder: Placeholder_default
|
|
659
|
-
};
|
|
660
706
|
var Elements = {
|
|
661
707
|
Countdown: {
|
|
662
|
-
Component:
|
|
708
|
+
Component: Countdown_default,
|
|
663
709
|
type: "countdown",
|
|
664
710
|
defaultCss: css3
|
|
665
711
|
},
|
|
666
712
|
Button: {
|
|
667
|
-
Component:
|
|
713
|
+
Component: Button_default,
|
|
668
714
|
type: "button",
|
|
669
715
|
defaultCss: css
|
|
670
716
|
},
|
|
671
717
|
Container: {
|
|
672
|
-
Component:
|
|
718
|
+
Component: Container_default,
|
|
673
719
|
type: "container",
|
|
674
720
|
defaultCss: css2
|
|
675
721
|
},
|
|
676
722
|
Image: {
|
|
677
|
-
Component:
|
|
723
|
+
Component: Image_default,
|
|
678
724
|
type: "image",
|
|
679
725
|
defaultCss: css4
|
|
680
726
|
},
|
|
681
727
|
Instagram: {
|
|
682
|
-
Component:
|
|
728
|
+
Component: Instagram_default,
|
|
683
729
|
type: "instagram",
|
|
684
730
|
defaultCss: css9,
|
|
685
731
|
permanentCss: permanentCss2
|
|
686
732
|
},
|
|
687
733
|
Layout: {
|
|
688
|
-
Component:
|
|
734
|
+
Component: Layout_default,
|
|
689
735
|
type: "layout",
|
|
690
736
|
defaultCss: css5,
|
|
691
737
|
permanentCss
|
|
692
738
|
},
|
|
693
739
|
Map: {
|
|
694
|
-
Component:
|
|
740
|
+
Component: Map_default,
|
|
695
741
|
type: "map",
|
|
696
742
|
defaultCss: css6
|
|
697
743
|
},
|
|
698
744
|
Text: {
|
|
699
|
-
Component:
|
|
745
|
+
Component: Text_default,
|
|
700
746
|
type: "text",
|
|
701
747
|
defaultCss: css7
|
|
702
748
|
},
|
|
703
749
|
Video: {
|
|
704
|
-
Component:
|
|
750
|
+
Component: Video_default,
|
|
705
751
|
type: "video",
|
|
706
752
|
defaultCss: css8
|
|
707
753
|
}
|
|
708
754
|
};
|
|
709
755
|
|
|
710
|
-
// src/
|
|
711
|
-
|
|
712
|
-
|
|
756
|
+
// src/context.ts
|
|
757
|
+
var createRootContext = (configs) => {
|
|
758
|
+
let rootContext = new Weaverse(configs);
|
|
759
|
+
Object.keys(Elements).forEach((key) => {
|
|
760
|
+
rootContext.registerElement(Elements[key]);
|
|
761
|
+
});
|
|
762
|
+
return rootContext;
|
|
763
|
+
};
|
|
764
|
+
var WeaverseContext = createContext({});
|
|
765
|
+
var WeaverseContextProvider = WeaverseContext.Provider;
|
|
766
|
+
var WeaverseContextConsumer = WeaverseContext.Consumer;
|
|
713
767
|
|
|
714
|
-
// src/
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
768
|
+
// src/components/Modal.tsx
|
|
769
|
+
var Modal_exports = {};
|
|
770
|
+
__export(Modal_exports, {
|
|
771
|
+
Modal: () => Modal,
|
|
772
|
+
ModalClose: () => ModalClose,
|
|
773
|
+
ModalContent: () => ModalContent,
|
|
774
|
+
ModalHeader: () => ModalHeader,
|
|
775
|
+
ModalTrigger: () => ModalTrigger
|
|
776
|
+
});
|
|
777
|
+
import React15, { forwardRef as forwardRef10 } from "react";
|
|
778
|
+
import {
|
|
779
|
+
Close,
|
|
780
|
+
Content,
|
|
781
|
+
Overlay,
|
|
782
|
+
Portal,
|
|
783
|
+
Root,
|
|
784
|
+
Title,
|
|
785
|
+
Trigger
|
|
786
|
+
} from "@radix-ui/react-dialog";
|
|
787
|
+
import { styled, keyframes } from "@stitches/react";
|
|
788
|
+
var Modal = Root;
|
|
789
|
+
var ModalTrigger = Trigger;
|
|
790
|
+
var ModalHeader = styled(Title, {
|
|
791
|
+
margin: 0,
|
|
792
|
+
fontWeight: 500,
|
|
793
|
+
color: "#ededef",
|
|
794
|
+
fontSize: 17
|
|
795
|
+
});
|
|
796
|
+
var ModalContent = forwardRef10(
|
|
797
|
+
(props, ref) => {
|
|
798
|
+
let { children, ...rest } = props;
|
|
799
|
+
return /* @__PURE__ */ React15.createElement(Portal, null, /* @__PURE__ */ React15.createElement(StyledOverlay, null), /* @__PURE__ */ React15.createElement(StyledContent, {
|
|
800
|
+
...rest,
|
|
801
|
+
onCloseAutoFocus: (e) => e.preventDefault(),
|
|
802
|
+
ref
|
|
803
|
+
}, /* @__PURE__ */ React15.createElement("div", null, /* @__PURE__ */ React15.createElement(ModalClose, null), /* @__PURE__ */ React15.createElement("div", null, children))));
|
|
744
804
|
}
|
|
745
|
-
|
|
805
|
+
);
|
|
806
|
+
var ModalClose = Close;
|
|
807
|
+
ModalClose.defaultProps = {
|
|
808
|
+
asChild: true
|
|
809
|
+
};
|
|
810
|
+
var overlayShow = keyframes({
|
|
811
|
+
"0%": { opacity: 0 },
|
|
812
|
+
"100%": { opacity: 1 }
|
|
813
|
+
});
|
|
814
|
+
var contentShow = keyframes({
|
|
815
|
+
"0%": { opacity: 0, transform: "translate(-50%, -48%) scale(.96)" },
|
|
816
|
+
"100%": { opacity: 1, transform: "translate(-50%, -50%) scale(1)" }
|
|
817
|
+
});
|
|
818
|
+
var StyledOverlay = styled(Overlay, {
|
|
819
|
+
backgroundColor: "#707070",
|
|
820
|
+
position: "fixed",
|
|
821
|
+
zIndex: 9999,
|
|
822
|
+
inset: 0,
|
|
823
|
+
animation: `${overlayShow} 150ms cubic-bezier(0.16, 1, 0.3, 1)`
|
|
824
|
+
});
|
|
825
|
+
var StyledContent = styled(Content, {
|
|
826
|
+
backgroundColor: "white",
|
|
827
|
+
borderRadius: 6,
|
|
828
|
+
boxShadow: "hsl(206 22% 7% / 35%) 0px 10px 38px -10px, hsl(206 22% 7% / 20%) 0px 10px 20px -15px",
|
|
829
|
+
position: "fixed",
|
|
830
|
+
top: "50%",
|
|
831
|
+
left: "50%",
|
|
832
|
+
transform: "translate(-50%, -50%)",
|
|
833
|
+
width: "90vw",
|
|
834
|
+
maxWidth: "450px",
|
|
835
|
+
maxHeight: "85vh",
|
|
836
|
+
padding: 25,
|
|
837
|
+
animation: `${contentShow} 150ms cubic-bezier(0.16, 1, 0.3, 1)`,
|
|
838
|
+
"&:focus": { outline: "none" },
|
|
839
|
+
zIndex: 9999
|
|
840
|
+
});
|
|
841
|
+
|
|
842
|
+
// src/components/Spinner.tsx
|
|
843
|
+
import React16 from "react";
|
|
844
|
+
function Spinner() {
|
|
845
|
+
return /* @__PURE__ */ React16.createElement("span", {
|
|
846
|
+
className: "wv-spinner-wrapper"
|
|
847
|
+
}, /* @__PURE__ */ React16.createElement("svg", {
|
|
848
|
+
className: "wv-spinner",
|
|
849
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
850
|
+
fill: "none",
|
|
851
|
+
viewBox: "0 0 24 24"
|
|
852
|
+
}, /* @__PURE__ */ React16.createElement("circle", {
|
|
853
|
+
style: { opacity: ".25" },
|
|
854
|
+
cx: "12",
|
|
855
|
+
cy: "12",
|
|
856
|
+
r: "10",
|
|
857
|
+
stroke: "currentColor",
|
|
858
|
+
strokeWidth: "4"
|
|
859
|
+
}), /* @__PURE__ */ React16.createElement("path", {
|
|
860
|
+
style: { opacity: ".75" },
|
|
861
|
+
fill: "currentColor",
|
|
862
|
+
d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"
|
|
863
|
+
})));
|
|
746
864
|
}
|
|
747
865
|
|
|
866
|
+
// src/components/index.ts
|
|
867
|
+
var Components = {
|
|
868
|
+
Placeholder: Placeholder_default,
|
|
869
|
+
Spinner,
|
|
870
|
+
ModalComponents: Modal_exports
|
|
871
|
+
};
|
|
872
|
+
|
|
748
873
|
// src/renderer.tsx
|
|
874
|
+
import { isBrowser } from "@weaverse/core";
|
|
875
|
+
import React17, { useContext as useContext4, useEffect as useEffect3, useRef, useState as useState2 } from "react";
|
|
749
876
|
var WeaverseRoot = ({ context }) => {
|
|
750
877
|
let [, setData] = useState2(context.projectData);
|
|
751
878
|
let rootRef = useRef();
|
|
@@ -760,13 +887,13 @@ var WeaverseRoot = ({ context }) => {
|
|
|
760
887
|
let eventHandlers = context?.studioBridge?.eventHandlers || {};
|
|
761
888
|
let themeClass = context.stitchesInstance.theme.className;
|
|
762
889
|
if (context.projectData?.rootId) {
|
|
763
|
-
return /* @__PURE__ */
|
|
890
|
+
return /* @__PURE__ */ React17.createElement("div", {
|
|
764
891
|
className: `weaverse-content-root ${themeClass}`,
|
|
765
892
|
...eventHandlers,
|
|
766
893
|
ref: rootRef
|
|
767
|
-
}, /* @__PURE__ */
|
|
894
|
+
}, /* @__PURE__ */ React17.createElement(WeaverseContextProvider, {
|
|
768
895
|
value: context
|
|
769
|
-
}, /* @__PURE__ */
|
|
896
|
+
}, /* @__PURE__ */ React17.createElement(ItemInstance, {
|
|
770
897
|
id: context.projectData.rootId
|
|
771
898
|
})));
|
|
772
899
|
}
|
|
@@ -792,13 +919,13 @@ var ItemComponent = ({ instance }) => {
|
|
|
792
919
|
if (Component.$$typeof === Symbol.for("react.forward_ref")) {
|
|
793
920
|
rest.ref = instance.ref;
|
|
794
921
|
}
|
|
795
|
-
return /* @__PURE__ */
|
|
922
|
+
return /* @__PURE__ */ React17.createElement(Component, {
|
|
796
923
|
key: id,
|
|
797
924
|
"data-wv-type": type,
|
|
798
925
|
"data-wv-id": id,
|
|
799
926
|
className: generateItemClass(instance, stitchesInstance),
|
|
800
927
|
...rest
|
|
801
|
-
}, childIds.map((id2) => /* @__PURE__ */
|
|
928
|
+
}, childIds.map((id2) => /* @__PURE__ */ React17.createElement(ItemInstance, {
|
|
802
929
|
key: id2,
|
|
803
930
|
id: id2
|
|
804
931
|
})));
|
|
@@ -812,21 +939,18 @@ var ItemInstance = ({ id }) => {
|
|
|
812
939
|
let { itemInstances } = context;
|
|
813
940
|
let instance = itemInstances.get(id);
|
|
814
941
|
if (!instance) {
|
|
815
|
-
return /* @__PURE__ */
|
|
942
|
+
return /* @__PURE__ */ React17.createElement("div", {
|
|
816
943
|
style: { display: "none" }
|
|
817
944
|
}, "Item instance ", id, " not found");
|
|
818
945
|
}
|
|
819
|
-
return /* @__PURE__ */
|
|
946
|
+
return /* @__PURE__ */ React17.createElement(ItemComponent, {
|
|
820
947
|
key: id,
|
|
821
948
|
instance
|
|
822
949
|
});
|
|
823
950
|
};
|
|
824
|
-
|
|
825
|
-
// src/index.ts
|
|
826
|
-
export * from "@weaverse/core";
|
|
827
951
|
export {
|
|
952
|
+
Components,
|
|
828
953
|
Elements,
|
|
829
|
-
SharedComponents,
|
|
830
954
|
WeaverseContext,
|
|
831
955
|
WeaverseContextConsumer,
|
|
832
956
|
WeaverseContextProvider,
|