@weaverse/react 0.7.26 → 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 +50 -13
- package/dist/index.js +378 -191
- package/dist/index.mjs +347 -144
- 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,21 +473,20 @@ 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/
|
|
435
|
-
import
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
autoPlay: isDesignMode ? false : autoPlay,
|
|
478
|
+
// src/elements/Video/index.tsx
|
|
479
|
+
import React12, { forwardRef as forwardRef7, useContext as useContext3 } from "react";
|
|
480
|
+
|
|
481
|
+
// src/elements/Video/HTMLVideo.tsx
|
|
482
|
+
import React9 from "react";
|
|
483
|
+
function HTMLVideo(props) {
|
|
484
|
+
let { src, type, controls, autoPlay, loop, muted } = props;
|
|
485
|
+
return /* @__PURE__ */ React9.createElement("video", {
|
|
486
|
+
controls,
|
|
487
|
+
autoPlay,
|
|
445
488
|
loop,
|
|
446
|
-
muted
|
|
489
|
+
muted,
|
|
447
490
|
controlsList: "nodownload",
|
|
448
491
|
disablePictureInPicture: true
|
|
449
492
|
}, /* @__PURE__ */ React9.createElement("source", {
|
|
@@ -452,7 +495,80 @@ var Video = forwardRef7((props, ref) => {
|
|
|
452
495
|
}), /* @__PURE__ */ React9.createElement("source", {
|
|
453
496
|
src,
|
|
454
497
|
type: "video/ogg"
|
|
455
|
-
}), "Your browser does not support the video tag.")
|
|
498
|
+
}), "Your browser does not support the video tag.");
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
// src/elements/Video/Vimeo.tsx
|
|
502
|
+
import React10 from "react";
|
|
503
|
+
function Vimeo(props) {
|
|
504
|
+
let { vimeoId, controls, autoPlay, loop, muted } = props;
|
|
505
|
+
let params = `autoplay=${autoPlay}&loop=${loop}&controls=${controls}&muted=${muted}`;
|
|
506
|
+
let vimeoSrc = `https://player.vimeo.com/video/${vimeoId}?${params}`;
|
|
507
|
+
return /* @__PURE__ */ React10.createElement("iframe", {
|
|
508
|
+
src: vimeoSrc,
|
|
509
|
+
width: "100%",
|
|
510
|
+
height: "100%",
|
|
511
|
+
allowFullScreen: true
|
|
512
|
+
});
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
// src/elements/Video/Youtube.tsx
|
|
516
|
+
import React11 from "react";
|
|
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
|
+
});
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
// src/elements/Video/index.tsx
|
|
537
|
+
var Video = forwardRef7((props, ref) => {
|
|
538
|
+
let { isDesignMode } = useContext3(WeaverseContext);
|
|
539
|
+
let {
|
|
540
|
+
src,
|
|
541
|
+
controls,
|
|
542
|
+
poster,
|
|
543
|
+
autoPlay: originAutoPlay,
|
|
544
|
+
loop,
|
|
545
|
+
muted,
|
|
546
|
+
...rest
|
|
547
|
+
} = props;
|
|
548
|
+
let autoPlay = !isDesignMode && originAutoPlay;
|
|
549
|
+
let videoProps = { src, controls, poster, autoPlay, loop, muted };
|
|
550
|
+
let content;
|
|
551
|
+
let youtubeId = getYoutubeEmbedId(src);
|
|
552
|
+
let vimeoId = getVimeoId(src);
|
|
553
|
+
if (youtubeId) {
|
|
554
|
+
content = /* @__PURE__ */ React12.createElement(Youtube, {
|
|
555
|
+
...videoProps,
|
|
556
|
+
youtubeId
|
|
557
|
+
});
|
|
558
|
+
} else if (vimeoId) {
|
|
559
|
+
content = /* @__PURE__ */ React12.createElement(Vimeo, {
|
|
560
|
+
...videoProps,
|
|
561
|
+
vimeoId
|
|
562
|
+
});
|
|
563
|
+
} else {
|
|
564
|
+
content = /* @__PURE__ */ React12.createElement(HTMLVideo, {
|
|
565
|
+
...videoProps
|
|
566
|
+
});
|
|
567
|
+
}
|
|
568
|
+
return /* @__PURE__ */ React12.createElement("div", {
|
|
569
|
+
ref,
|
|
570
|
+
...rest
|
|
571
|
+
}, content);
|
|
456
572
|
});
|
|
457
573
|
var css8 = {
|
|
458
574
|
"@desktop": {
|
|
@@ -467,34 +583,32 @@ Video.defaultProps = {
|
|
|
467
583
|
src: "https://youtu.be/wM-NT6hcw48",
|
|
468
584
|
poster: "https://ucarecdn.com/c413b8fe-ceec-4948-9c42-a0434c4ca920/-/preview/-/quality/smart/-/format/auto/",
|
|
469
585
|
loop: false,
|
|
470
|
-
type: "video/mp4",
|
|
471
586
|
controls: false,
|
|
472
587
|
autoPlay: true,
|
|
473
588
|
muted: true
|
|
474
589
|
};
|
|
475
|
-
var
|
|
590
|
+
var Video_default = Video;
|
|
476
591
|
|
|
477
|
-
// src/elements/
|
|
478
|
-
import
|
|
592
|
+
// src/elements/Instagram.tsx
|
|
593
|
+
import React14, { forwardRef as forwardRef9, useEffect as useEffect2, useState } from "react";
|
|
479
594
|
|
|
480
|
-
// src/
|
|
481
|
-
import
|
|
595
|
+
// src/components/Placeholder.tsx
|
|
596
|
+
import React13, { forwardRef as forwardRef8 } from "react";
|
|
482
597
|
var Placeholder = forwardRef8(
|
|
483
598
|
(props, ref) => {
|
|
484
599
|
let { element, children, ...rest } = props;
|
|
485
|
-
return /* @__PURE__ */
|
|
600
|
+
return /* @__PURE__ */ React13.createElement("div", {
|
|
486
601
|
"data-wv-placeholder": true,
|
|
487
602
|
ref,
|
|
488
603
|
...rest
|
|
489
|
-
}, /* @__PURE__ */
|
|
604
|
+
}, /* @__PURE__ */ React13.createElement("div", {
|
|
490
605
|
style: { fontWeight: 600, marginBottom: "10px" }
|
|
491
|
-
}, element), /* @__PURE__ */
|
|
606
|
+
}, element), /* @__PURE__ */ React13.createElement("div", null, children));
|
|
492
607
|
}
|
|
493
608
|
);
|
|
494
609
|
var Placeholder_default = Placeholder;
|
|
495
610
|
|
|
496
|
-
// src/elements/
|
|
497
|
-
var INSTAGRAM_API = "https://graph.instagram.com";
|
|
611
|
+
// src/elements/Instagram.tsx
|
|
498
612
|
var Instagram = forwardRef9(
|
|
499
613
|
(props, ref) => {
|
|
500
614
|
let { token, username, numberOfImages, imagesPerRow, gap, ...rest } = props;
|
|
@@ -517,10 +631,10 @@ var Instagram = forwardRef9(
|
|
|
517
631
|
}
|
|
518
632
|
}, [token]);
|
|
519
633
|
if (!token || error) {
|
|
520
|
-
return /* @__PURE__ */
|
|
634
|
+
return /* @__PURE__ */ React14.createElement("div", {
|
|
521
635
|
ref,
|
|
522
636
|
...rest
|
|
523
|
-
}, /* @__PURE__ */
|
|
637
|
+
}, /* @__PURE__ */ React14.createElement(Placeholder_default, {
|
|
524
638
|
element: "Instagram"
|
|
525
639
|
}, !token ? "Connect to Instagram to display photos on your site." : "Invalid or expired token!"));
|
|
526
640
|
}
|
|
@@ -528,27 +642,28 @@ var Instagram = forwardRef9(
|
|
|
528
642
|
"--wv-ig-images-per-row": imagesPerRow,
|
|
529
643
|
"--wv-ig-images-gap": gap + "px"
|
|
530
644
|
};
|
|
531
|
-
return /* @__PURE__ */
|
|
645
|
+
return /* @__PURE__ */ React14.createElement("div", {
|
|
532
646
|
ref,
|
|
533
647
|
...rest,
|
|
534
648
|
style
|
|
535
|
-
}, /* @__PURE__ */
|
|
649
|
+
}, /* @__PURE__ */ React14.createElement("div", {
|
|
536
650
|
className: "wv-ig-media-container"
|
|
537
651
|
}, media.slice(0, numberOfImages).map((item) => {
|
|
538
652
|
let { id, permalink, caption, media_url } = item;
|
|
539
|
-
return /* @__PURE__ */
|
|
653
|
+
return /* @__PURE__ */ React14.createElement("a", {
|
|
540
654
|
key: id,
|
|
541
655
|
href: permalink,
|
|
542
656
|
target: "_blank",
|
|
543
657
|
rel: "noreferrer"
|
|
544
|
-
}, /* @__PURE__ */
|
|
658
|
+
}, /* @__PURE__ */ React14.createElement("img", {
|
|
545
659
|
alt: caption,
|
|
546
660
|
src: media_url
|
|
547
661
|
}));
|
|
548
662
|
})));
|
|
549
663
|
}
|
|
550
664
|
);
|
|
551
|
-
var css9 = {
|
|
665
|
+
var css9 = {};
|
|
666
|
+
var permanentCss2 = {
|
|
552
667
|
"@desktop": {
|
|
553
668
|
".wv-ig-media-container": {
|
|
554
669
|
overflow: "hidden",
|
|
@@ -558,12 +673,24 @@ var css9 = {
|
|
|
558
673
|
gridTemplateColumns: "repeat(var(--wv-ig-images-per-row, 4), 1fr)",
|
|
559
674
|
gap: "var(--wv-ig-images-gap, 0px)",
|
|
560
675
|
img: {
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
height: "100%",
|
|
676
|
+
maxWidth: "100%",
|
|
677
|
+
maxHeight: "100%",
|
|
564
678
|
objectFit: "cover"
|
|
565
679
|
}
|
|
566
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
|
+
}
|
|
567
694
|
}
|
|
568
695
|
};
|
|
569
696
|
Instagram.defaultProps = {
|
|
@@ -573,100 +700,179 @@ Instagram.defaultProps = {
|
|
|
573
700
|
imagesPerRow: 4,
|
|
574
701
|
gap: 0
|
|
575
702
|
};
|
|
576
|
-
var
|
|
703
|
+
var Instagram_default = Instagram;
|
|
577
704
|
|
|
578
705
|
// src/elements/index.ts
|
|
579
|
-
var SharedComponents = {
|
|
580
|
-
Placeholder: Placeholder_default
|
|
581
|
-
};
|
|
582
706
|
var Elements = {
|
|
583
707
|
Countdown: {
|
|
584
|
-
Component:
|
|
708
|
+
Component: Countdown_default,
|
|
585
709
|
type: "countdown",
|
|
586
710
|
defaultCss: css3
|
|
587
711
|
},
|
|
588
712
|
Button: {
|
|
589
|
-
Component:
|
|
713
|
+
Component: Button_default,
|
|
590
714
|
type: "button",
|
|
591
715
|
defaultCss: css
|
|
592
716
|
},
|
|
593
717
|
Container: {
|
|
594
|
-
Component:
|
|
718
|
+
Component: Container_default,
|
|
595
719
|
type: "container",
|
|
596
720
|
defaultCss: css2
|
|
597
721
|
},
|
|
598
722
|
Image: {
|
|
599
|
-
Component:
|
|
723
|
+
Component: Image_default,
|
|
600
724
|
type: "image",
|
|
601
725
|
defaultCss: css4
|
|
602
726
|
},
|
|
603
727
|
Instagram: {
|
|
604
|
-
Component:
|
|
728
|
+
Component: Instagram_default,
|
|
605
729
|
type: "instagram",
|
|
606
|
-
defaultCss: css9
|
|
730
|
+
defaultCss: css9,
|
|
731
|
+
permanentCss: permanentCss2
|
|
607
732
|
},
|
|
608
733
|
Layout: {
|
|
609
|
-
Component:
|
|
734
|
+
Component: Layout_default,
|
|
610
735
|
type: "layout",
|
|
611
736
|
defaultCss: css5,
|
|
612
737
|
permanentCss
|
|
613
738
|
},
|
|
614
739
|
Map: {
|
|
615
|
-
Component:
|
|
740
|
+
Component: Map_default,
|
|
616
741
|
type: "map",
|
|
617
742
|
defaultCss: css6
|
|
618
743
|
},
|
|
619
744
|
Text: {
|
|
620
|
-
Component:
|
|
745
|
+
Component: Text_default,
|
|
621
746
|
type: "text",
|
|
622
747
|
defaultCss: css7
|
|
623
748
|
},
|
|
624
749
|
Video: {
|
|
625
|
-
Component:
|
|
750
|
+
Component: Video_default,
|
|
626
751
|
type: "video",
|
|
627
752
|
defaultCss: css8
|
|
628
753
|
}
|
|
629
754
|
};
|
|
630
755
|
|
|
631
|
-
// src/
|
|
632
|
-
|
|
633
|
-
|
|
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;
|
|
634
767
|
|
|
635
|
-
// src/
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
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))));
|
|
665
804
|
}
|
|
666
|
-
|
|
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
|
+
})));
|
|
667
864
|
}
|
|
668
865
|
|
|
866
|
+
// src/components/index.ts
|
|
867
|
+
var Components = {
|
|
868
|
+
Placeholder: Placeholder_default,
|
|
869
|
+
Spinner,
|
|
870
|
+
ModalComponents: Modal_exports
|
|
871
|
+
};
|
|
872
|
+
|
|
669
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";
|
|
670
876
|
var WeaverseRoot = ({ context }) => {
|
|
671
877
|
let [, setData] = useState2(context.projectData);
|
|
672
878
|
let rootRef = useRef();
|
|
@@ -681,13 +887,13 @@ var WeaverseRoot = ({ context }) => {
|
|
|
681
887
|
let eventHandlers = context?.studioBridge?.eventHandlers || {};
|
|
682
888
|
let themeClass = context.stitchesInstance.theme.className;
|
|
683
889
|
if (context.projectData?.rootId) {
|
|
684
|
-
return /* @__PURE__ */
|
|
890
|
+
return /* @__PURE__ */ React17.createElement("div", {
|
|
685
891
|
className: `weaverse-content-root ${themeClass}`,
|
|
686
892
|
...eventHandlers,
|
|
687
893
|
ref: rootRef
|
|
688
|
-
}, /* @__PURE__ */
|
|
894
|
+
}, /* @__PURE__ */ React17.createElement(WeaverseContextProvider, {
|
|
689
895
|
value: context
|
|
690
|
-
}, /* @__PURE__ */
|
|
896
|
+
}, /* @__PURE__ */ React17.createElement(ItemInstance, {
|
|
691
897
|
id: context.projectData.rootId
|
|
692
898
|
})));
|
|
693
899
|
}
|
|
@@ -713,13 +919,13 @@ var ItemComponent = ({ instance }) => {
|
|
|
713
919
|
if (Component.$$typeof === Symbol.for("react.forward_ref")) {
|
|
714
920
|
rest.ref = instance.ref;
|
|
715
921
|
}
|
|
716
|
-
return /* @__PURE__ */
|
|
922
|
+
return /* @__PURE__ */ React17.createElement(Component, {
|
|
717
923
|
key: id,
|
|
718
924
|
"data-wv-type": type,
|
|
719
925
|
"data-wv-id": id,
|
|
720
926
|
className: generateItemClass(instance, stitchesInstance),
|
|
721
927
|
...rest
|
|
722
|
-
}, childIds.map((id2) => /* @__PURE__ */
|
|
928
|
+
}, childIds.map((id2) => /* @__PURE__ */ React17.createElement(ItemInstance, {
|
|
723
929
|
key: id2,
|
|
724
930
|
id: id2
|
|
725
931
|
})));
|
|
@@ -733,21 +939,18 @@ var ItemInstance = ({ id }) => {
|
|
|
733
939
|
let { itemInstances } = context;
|
|
734
940
|
let instance = itemInstances.get(id);
|
|
735
941
|
if (!instance) {
|
|
736
|
-
return /* @__PURE__ */
|
|
942
|
+
return /* @__PURE__ */ React17.createElement("div", {
|
|
737
943
|
style: { display: "none" }
|
|
738
944
|
}, "Item instance ", id, " not found");
|
|
739
945
|
}
|
|
740
|
-
return /* @__PURE__ */
|
|
946
|
+
return /* @__PURE__ */ React17.createElement(ItemComponent, {
|
|
741
947
|
key: id,
|
|
742
948
|
instance
|
|
743
949
|
});
|
|
744
950
|
};
|
|
745
|
-
|
|
746
|
-
// src/index.ts
|
|
747
|
-
export * from "@weaverse/core";
|
|
748
951
|
export {
|
|
952
|
+
Components,
|
|
749
953
|
Elements,
|
|
750
|
-
SharedComponents,
|
|
751
954
|
WeaverseContext,
|
|
752
955
|
WeaverseContextConsumer,
|
|
753
956
|
WeaverseContextProvider,
|