@weaverse/react 0.7.14 → 0.7.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 +88 -585
- package/dist/index.mjs +90 -587
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -21,16 +21,17 @@ Button.defaultProps = {
|
|
|
21
21
|
text: "Shop now",
|
|
22
22
|
clickAction: "none",
|
|
23
23
|
linkTo: "",
|
|
24
|
-
openInNewTab: false
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
24
|
+
openInNewTab: false
|
|
25
|
+
};
|
|
26
|
+
var css = {
|
|
27
|
+
"@desktop": {
|
|
28
|
+
borderRadius: "72px",
|
|
29
|
+
border: "none",
|
|
30
|
+
backgroundColor: "#0F71FF",
|
|
31
|
+
color: "#fff",
|
|
32
|
+
fontSize: "13px",
|
|
33
|
+
padding: "10px 20px",
|
|
34
|
+
textDecoration: "none"
|
|
34
35
|
}
|
|
35
36
|
};
|
|
36
37
|
var button_default = Button;
|
|
@@ -46,7 +47,7 @@ var Container = forwardRef2(
|
|
|
46
47
|
}, children);
|
|
47
48
|
}
|
|
48
49
|
);
|
|
49
|
-
var
|
|
50
|
+
var css2 = {
|
|
50
51
|
"@desktop": {
|
|
51
52
|
alignItems: "flex-start",
|
|
52
53
|
backgroundColor: "rgba(248,203,203,0.38)",
|
|
@@ -83,10 +84,12 @@ var WeaverseContextConsumer = WeaverseContext.Consumer;
|
|
|
83
84
|
// src/elements/countdown/timer-block.tsx
|
|
84
85
|
import React3 from "react";
|
|
85
86
|
function TimerBlock({ value, label }) {
|
|
86
|
-
return /* @__PURE__ */ React3.createElement("div",
|
|
87
|
-
className: "wv-
|
|
87
|
+
return /* @__PURE__ */ React3.createElement("div", {
|
|
88
|
+
className: "wv-cd-block"
|
|
89
|
+
}, /* @__PURE__ */ React3.createElement("div", {
|
|
90
|
+
className: "wv-cd-number"
|
|
88
91
|
}, value.toString().padStart(2, "0")), label && /* @__PURE__ */ React3.createElement("div", {
|
|
89
|
-
className: "wv-
|
|
92
|
+
className: "wv-cd-label"
|
|
90
93
|
}, label));
|
|
91
94
|
}
|
|
92
95
|
|
|
@@ -134,6 +137,7 @@ var Countdown = forwardRef3(
|
|
|
134
137
|
);
|
|
135
138
|
if (!isDesignMode && redirectUrl && remainingTime > 0 && remainingTime < 1e3) {
|
|
136
139
|
window.open(redirectUrl, openInNewTab ? "_blank" : "_self");
|
|
140
|
+
clearInterval(flag);
|
|
137
141
|
}
|
|
138
142
|
setRemaining(remainingTime);
|
|
139
143
|
}, 1e3);
|
|
@@ -151,13 +155,13 @@ var Countdown = forwardRef3(
|
|
|
151
155
|
}, /* @__PURE__ */ React4.createElement(TimerBlock, {
|
|
152
156
|
label: showLabel ? time : "",
|
|
153
157
|
value: timer[time]
|
|
154
|
-
}), time !== "seconds" && /* @__PURE__ */ React4.createElement("span", {
|
|
155
|
-
className: `wv-
|
|
156
|
-
}, ":"));
|
|
158
|
+
}), time !== "seconds" && /* @__PURE__ */ React4.createElement("div", null, /* @__PURE__ */ React4.createElement("span", {
|
|
159
|
+
className: `wv-cd-number ${showColon ? "" : "hidden"}`
|
|
160
|
+
}, ":")));
|
|
157
161
|
}));
|
|
158
162
|
}
|
|
159
163
|
);
|
|
160
|
-
var
|
|
164
|
+
var css3 = {
|
|
161
165
|
"@desktop": {
|
|
162
166
|
fontFamily: "Inter",
|
|
163
167
|
fontSize: 36,
|
|
@@ -165,11 +169,12 @@ var css2 = {
|
|
|
165
169
|
display: "grid",
|
|
166
170
|
gridAutoFlow: "column",
|
|
167
171
|
gap: 10,
|
|
168
|
-
|
|
172
|
+
lineHeight: "initial",
|
|
173
|
+
".wv-cd-block": {
|
|
169
174
|
width: 48,
|
|
170
175
|
textAlign: "center"
|
|
171
176
|
},
|
|
172
|
-
".wv-
|
|
177
|
+
".wv-cd-label": {
|
|
173
178
|
fontSize: 10
|
|
174
179
|
},
|
|
175
180
|
"& > span": {
|
|
@@ -183,7 +188,7 @@ var css2 = {
|
|
|
183
188
|
Countdown.defaultProps = {
|
|
184
189
|
timerType: "fixed-time",
|
|
185
190
|
startTime: Date.now(),
|
|
186
|
-
endTime:
|
|
191
|
+
endTime: 1666756528e3,
|
|
187
192
|
periods: 90,
|
|
188
193
|
redirectUrl: "https://myshop.com",
|
|
189
194
|
openInNewTab: false,
|
|
@@ -193,10 +198,9 @@ Countdown.defaultProps = {
|
|
|
193
198
|
var countdown_default = Countdown;
|
|
194
199
|
|
|
195
200
|
// src/elements/image.tsx
|
|
196
|
-
import React5
|
|
201
|
+
import React5 from "react";
|
|
197
202
|
var Image = React5.forwardRef(
|
|
198
203
|
(props, ref) => {
|
|
199
|
-
let { isDesignMode } = useContext2(WeaverseContext);
|
|
200
204
|
let {
|
|
201
205
|
src,
|
|
202
206
|
alt,
|
|
@@ -204,38 +208,41 @@ var Image = React5.forwardRef(
|
|
|
204
208
|
objectPosition,
|
|
205
209
|
onClickAction,
|
|
206
210
|
openLinkInNewTab,
|
|
211
|
+
linkTo,
|
|
207
212
|
...rest
|
|
208
213
|
} = props;
|
|
209
214
|
let style = {
|
|
210
215
|
"--wv-img-object-fit": objectFit,
|
|
211
216
|
"--wv-img-object-position": objectPosition
|
|
212
217
|
};
|
|
213
|
-
let
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
218
|
+
let content = /* @__PURE__ */ React5.createElement("img", {
|
|
219
|
+
alt,
|
|
220
|
+
"data-blink-src": src
|
|
221
|
+
});
|
|
222
|
+
if (onClickAction === "open-link" && linkTo) {
|
|
223
|
+
let target = openLinkInNewTab ? "_blank" : "_self";
|
|
224
|
+
content = /* @__PURE__ */ React5.createElement("a", {
|
|
225
|
+
href: linkTo,
|
|
226
|
+
target
|
|
227
|
+
}, content);
|
|
228
|
+
}
|
|
221
229
|
return /* @__PURE__ */ React5.createElement("div", {
|
|
222
230
|
ref,
|
|
223
231
|
...rest,
|
|
224
|
-
style
|
|
225
|
-
|
|
226
|
-
}, /* @__PURE__ */ React5.createElement("img", {
|
|
227
|
-
alt,
|
|
228
|
-
src
|
|
229
|
-
}));
|
|
232
|
+
style
|
|
233
|
+
}, content);
|
|
230
234
|
}
|
|
231
235
|
);
|
|
232
|
-
var
|
|
236
|
+
var css4 = {
|
|
233
237
|
"@desktop": {
|
|
234
238
|
img: {
|
|
235
239
|
width: "100%",
|
|
236
240
|
height: "100%",
|
|
237
241
|
objectFit: "var(--wv-img-object-fit, cover)",
|
|
238
242
|
objectPosition: "var(--wv-img-object-position, center)"
|
|
243
|
+
},
|
|
244
|
+
"& [data-blink-src]": {
|
|
245
|
+
visibility: "hidden"
|
|
239
246
|
}
|
|
240
247
|
}
|
|
241
248
|
};
|
|
@@ -244,8 +251,9 @@ Image.defaultProps = {
|
|
|
244
251
|
alt: "Image alt text",
|
|
245
252
|
objectFit: "cover",
|
|
246
253
|
objectPosition: "center",
|
|
247
|
-
onClickAction: "open-
|
|
248
|
-
openLinkInNewTab: false
|
|
254
|
+
onClickAction: "open-link",
|
|
255
|
+
openLinkInNewTab: false,
|
|
256
|
+
linkTo: ""
|
|
249
257
|
};
|
|
250
258
|
var image_default = Image;
|
|
251
259
|
|
|
@@ -269,7 +277,7 @@ var Layout = forwardRef4((props, ref) => {
|
|
|
269
277
|
"data-layout-content": true
|
|
270
278
|
}, children));
|
|
271
279
|
});
|
|
272
|
-
var
|
|
280
|
+
var css5 = {
|
|
273
281
|
"@desktop": {
|
|
274
282
|
paddingTop: "16px",
|
|
275
283
|
paddingBottom: "16px",
|
|
@@ -318,7 +326,7 @@ var Map = forwardRef5((props, ref) => {
|
|
|
318
326
|
style: { pointerEvents: "none" }
|
|
319
327
|
}));
|
|
320
328
|
});
|
|
321
|
-
var
|
|
329
|
+
var css6 = {};
|
|
322
330
|
Map.defaultProps = {
|
|
323
331
|
place: "Hanoi",
|
|
324
332
|
zoom: 14
|
|
@@ -337,7 +345,7 @@ var Text = React8.forwardRef(
|
|
|
337
345
|
});
|
|
338
346
|
}
|
|
339
347
|
);
|
|
340
|
-
var
|
|
348
|
+
var css7 = {
|
|
341
349
|
"@desktop": {
|
|
342
350
|
padding: "10px",
|
|
343
351
|
wordBreak: "break-word",
|
|
@@ -351,9 +359,9 @@ Text.defaultProps = {
|
|
|
351
359
|
var text_default = Text;
|
|
352
360
|
|
|
353
361
|
// src/elements/video.tsx
|
|
354
|
-
import React9, { forwardRef as forwardRef7, useContext as
|
|
362
|
+
import React9, { forwardRef as forwardRef7, useContext as useContext2 } from "react";
|
|
355
363
|
var Video = forwardRef7((props, ref) => {
|
|
356
|
-
let { isDesignMode } =
|
|
364
|
+
let { isDesignMode } = useContext2(WeaverseContext);
|
|
357
365
|
let { src, type, controls, poster, autoPlay, loop, muted, ...rest } = props;
|
|
358
366
|
return /* @__PURE__ */ React9.createElement("div", {
|
|
359
367
|
ref,
|
|
@@ -368,9 +376,12 @@ var Video = forwardRef7((props, ref) => {
|
|
|
368
376
|
}, /* @__PURE__ */ React9.createElement("source", {
|
|
369
377
|
src,
|
|
370
378
|
type: type || "video/mp4"
|
|
379
|
+
}), /* @__PURE__ */ React9.createElement("source", {
|
|
380
|
+
src,
|
|
381
|
+
type: "video/ogg"
|
|
371
382
|
}), "Your browser does not support the video tag."));
|
|
372
383
|
});
|
|
373
|
-
var
|
|
384
|
+
var css8 = {
|
|
374
385
|
"@desktop": {
|
|
375
386
|
video: {
|
|
376
387
|
height: "100%",
|
|
@@ -381,7 +392,7 @@ var css7 = {
|
|
|
381
392
|
};
|
|
382
393
|
Video.defaultProps = {
|
|
383
394
|
src: "https://youtu.be/wM-NT6hcw48",
|
|
384
|
-
poster: "https://ucarecdn.com/
|
|
395
|
+
poster: "https://ucarecdn.com/c413b8fe-ceec-4948-9c42-a0434c4ca920/-/preview/-/quality/smart/-/format/auto/",
|
|
385
396
|
loop: false,
|
|
386
397
|
type: "video/mp4",
|
|
387
398
|
controls: false,
|
|
@@ -465,7 +476,7 @@ var Instagram = forwardRef9(
|
|
|
465
476
|
})));
|
|
466
477
|
}
|
|
467
478
|
);
|
|
468
|
-
var
|
|
479
|
+
var css9 = {
|
|
469
480
|
"@desktop": {
|
|
470
481
|
".wv-ig-media-container": {
|
|
471
482
|
overflow: "hidden",
|
|
@@ -492,480 +503,6 @@ Instagram.defaultProps = {
|
|
|
492
503
|
};
|
|
493
504
|
var instagram_default = Instagram;
|
|
494
505
|
|
|
495
|
-
// src/elements/accordion/index.tsx
|
|
496
|
-
import React12, { createContext as createContext2, forwardRef as forwardRef10, useState as useState2 } from "react";
|
|
497
|
-
var AccordionContext = createContext2({
|
|
498
|
-
iconName: "arrow",
|
|
499
|
-
active: [],
|
|
500
|
-
setActive: () => {
|
|
501
|
-
}
|
|
502
|
-
});
|
|
503
|
-
var Accordion = forwardRef10(
|
|
504
|
-
(props, ref) => {
|
|
505
|
-
const { iconName, children, ...rest } = props;
|
|
506
|
-
const [active, setActive] = useState2([]);
|
|
507
|
-
const setOpenAccordion = (id) => {
|
|
508
|
-
if (active.includes(id)) {
|
|
509
|
-
setActive(active.filter((_id) => _id !== id));
|
|
510
|
-
} else {
|
|
511
|
-
setActive([...active, id]);
|
|
512
|
-
}
|
|
513
|
-
};
|
|
514
|
-
return /* @__PURE__ */ React12.createElement("div", {
|
|
515
|
-
ref,
|
|
516
|
-
...rest
|
|
517
|
-
}, /* @__PURE__ */ React12.createElement(AccordionContext.Provider, {
|
|
518
|
-
value: { active, setActive: setOpenAccordion, iconName }
|
|
519
|
-
}, children));
|
|
520
|
-
}
|
|
521
|
-
);
|
|
522
|
-
var css9 = {
|
|
523
|
-
"@desktop": {
|
|
524
|
-
display: "flex",
|
|
525
|
-
flexDirection: "column",
|
|
526
|
-
gap: 4
|
|
527
|
-
}
|
|
528
|
-
};
|
|
529
|
-
Accordion.defaultProps = {
|
|
530
|
-
iconName: "arrow"
|
|
531
|
-
};
|
|
532
|
-
var accordion_default = Accordion;
|
|
533
|
-
|
|
534
|
-
// src/elements/accordion/AccordionWrapper.tsx
|
|
535
|
-
import React14, { forwardRef as forwardRef11, useContext as useContext5 } from "react";
|
|
536
|
-
|
|
537
|
-
// src/elements/accordion/Icon.tsx
|
|
538
|
-
import React13, { useContext as useContext4 } from "react";
|
|
539
|
-
var ICONS = {
|
|
540
|
-
caret: {
|
|
541
|
-
animationType: "rotate90",
|
|
542
|
-
css: {
|
|
543
|
-
position: "absolute!important",
|
|
544
|
-
left: 5,
|
|
545
|
-
top: 2,
|
|
546
|
-
width: 0,
|
|
547
|
-
height: 0,
|
|
548
|
-
borderTop: "6px solid transparent",
|
|
549
|
-
borderBottom: "6px solid transparent",
|
|
550
|
-
borderLeft: "6px solid #1F2A37"
|
|
551
|
-
}
|
|
552
|
-
},
|
|
553
|
-
arrow: {
|
|
554
|
-
animationType: "rotate90",
|
|
555
|
-
css: {
|
|
556
|
-
border: "solid #1F2A37",
|
|
557
|
-
borderWidth: "0 1px 1px 0",
|
|
558
|
-
display: "inline-block",
|
|
559
|
-
transform: "rotate(-45deg) translate(15%, -15%)",
|
|
560
|
-
padding: 4
|
|
561
|
-
}
|
|
562
|
-
},
|
|
563
|
-
plus: {
|
|
564
|
-
animationType: "custom",
|
|
565
|
-
css: {
|
|
566
|
-
display: "inline-block",
|
|
567
|
-
top: -6,
|
|
568
|
-
width: 15,
|
|
569
|
-
height: 1,
|
|
570
|
-
backgroundColor: "#1F2A37",
|
|
571
|
-
"&:after": {
|
|
572
|
-
position: "absolute",
|
|
573
|
-
content: "",
|
|
574
|
-
top: -7,
|
|
575
|
-
left: 7,
|
|
576
|
-
width: 1,
|
|
577
|
-
height: 15,
|
|
578
|
-
backgroundColor: "#1F2A37",
|
|
579
|
-
transition: "all 0.3s ease-in-out 0s"
|
|
580
|
-
},
|
|
581
|
-
"&.active": {
|
|
582
|
-
"&:after": {
|
|
583
|
-
transform: "rotate(90deg)"
|
|
584
|
-
}
|
|
585
|
-
}
|
|
586
|
-
}
|
|
587
|
-
}
|
|
588
|
-
};
|
|
589
|
-
var rotateAnimation = {
|
|
590
|
-
transition: "all 0.3s ease-in-out 0s",
|
|
591
|
-
transform: "rotate(90deg)"
|
|
592
|
-
};
|
|
593
|
-
function Icon(props) {
|
|
594
|
-
let { name, active = false, style, ...rest } = props;
|
|
595
|
-
let { stitchesInstance } = useContext4(WeaverseContext);
|
|
596
|
-
const { animationType, css: css16 } = ICONS[name];
|
|
597
|
-
if (active && animationType === "rotate90") {
|
|
598
|
-
style = { ...rotateAnimation, ...style };
|
|
599
|
-
}
|
|
600
|
-
let { className } = stitchesInstance.css(css16)();
|
|
601
|
-
if (active)
|
|
602
|
-
className += " active";
|
|
603
|
-
return /* @__PURE__ */ React13.createElement("span", {
|
|
604
|
-
style,
|
|
605
|
-
...rest
|
|
606
|
-
}, /* @__PURE__ */ React13.createElement("i", {
|
|
607
|
-
className
|
|
608
|
-
}));
|
|
609
|
-
}
|
|
610
|
-
var Icon_default = Icon;
|
|
611
|
-
|
|
612
|
-
// src/elements/accordion/AccordionWrapper.tsx
|
|
613
|
-
var AccordionWrapper = forwardRef11((props, ref) => {
|
|
614
|
-
const { ["data-wv-id"]: wvId, name, children, ...rest } = props;
|
|
615
|
-
const { iconName, active, setActive } = useContext5(AccordionContext);
|
|
616
|
-
const isActive = active.includes(wvId);
|
|
617
|
-
return /* @__PURE__ */ React14.createElement("div", {
|
|
618
|
-
ref,
|
|
619
|
-
...rest
|
|
620
|
-
}, /* @__PURE__ */ React14.createElement("div", {
|
|
621
|
-
onClick: () => setActive(wvId),
|
|
622
|
-
className: `wv-acc-header ${isActive ? "active" : ""}`
|
|
623
|
-
}, /* @__PURE__ */ React14.createElement("span", null, name), /* @__PURE__ */ React14.createElement(Icon_default, {
|
|
624
|
-
className: "wv-acc-icon",
|
|
625
|
-
active: isActive,
|
|
626
|
-
name: iconName
|
|
627
|
-
})), children);
|
|
628
|
-
});
|
|
629
|
-
var css10 = {
|
|
630
|
-
"@desktop": {
|
|
631
|
-
maxHeight: "100%",
|
|
632
|
-
".wv-acc-icon": {
|
|
633
|
-
position: "absolute",
|
|
634
|
-
right: 16,
|
|
635
|
-
width: 16,
|
|
636
|
-
height: 16,
|
|
637
|
-
transition: "all 0.3s ease-in-out 0s"
|
|
638
|
-
},
|
|
639
|
-
".wv-acc-header": {
|
|
640
|
-
display: "flex",
|
|
641
|
-
alignItems: "center",
|
|
642
|
-
borderRadius: 4,
|
|
643
|
-
padding: 12,
|
|
644
|
-
marginBottom: 4,
|
|
645
|
-
border: "1px solid #76A9FA",
|
|
646
|
-
cursor: "pointer",
|
|
647
|
-
'&.active + [data-wv-type="accordion.content"]': {
|
|
648
|
-
maxHeight: "var(--max-height, inherit)"
|
|
649
|
-
}
|
|
650
|
-
}
|
|
651
|
-
}
|
|
652
|
-
};
|
|
653
|
-
AccordionWrapper.defaultProps = {
|
|
654
|
-
name: "Accordion item"
|
|
655
|
-
};
|
|
656
|
-
var AccordionWrapper_default = AccordionWrapper;
|
|
657
|
-
|
|
658
|
-
// src/elements/accordion/AccordionContent.tsx
|
|
659
|
-
import React15, { forwardRef as forwardRef12 } from "react";
|
|
660
|
-
var AccordionContent = forwardRef12(
|
|
661
|
-
(props, ref) => {
|
|
662
|
-
const { rows, columns, gap, rowSize, children, ...rest } = props;
|
|
663
|
-
let style = {
|
|
664
|
-
"--rows": rows,
|
|
665
|
-
"--columns": columns,
|
|
666
|
-
"--gap": gap + "px",
|
|
667
|
-
"--row-size": rowSize + "px",
|
|
668
|
-
"--col-size": "calc((var(--grid-size) - calc(var(--columns) - 1) * var(--gap)) / var(--columns))",
|
|
669
|
-
"--max-height": rows * rowSize + gap * (rowSize - 1) + "px"
|
|
670
|
-
};
|
|
671
|
-
return /* @__PURE__ */ React15.createElement("div", {
|
|
672
|
-
ref,
|
|
673
|
-
...rest,
|
|
674
|
-
style
|
|
675
|
-
}, React15.Children.count(children) > 0 ? children : /* @__PURE__ */ React15.createElement(Placeholder_default, {
|
|
676
|
-
element: "Accordion Content"
|
|
677
|
-
}, "Drag and drop an element here."));
|
|
678
|
-
}
|
|
679
|
-
);
|
|
680
|
-
var css11 = {
|
|
681
|
-
"@desktop": {
|
|
682
|
-
width: "100%",
|
|
683
|
-
maxWidth: "var(--grid-size)",
|
|
684
|
-
display: "grid",
|
|
685
|
-
gridTemplateRows: "repeat(var(--rows), var(--row-size))",
|
|
686
|
-
gridTemplateColumns: "repeat(var(--columns), minmax(0, var(--col-size)))",
|
|
687
|
-
gap: "var(--gap)",
|
|
688
|
-
overflow: "hidden",
|
|
689
|
-
maxHeight: 0,
|
|
690
|
-
transition: "all var(--transition-duration, 0.3s) ease-in-out",
|
|
691
|
-
borderRadius: 4
|
|
692
|
-
}
|
|
693
|
-
};
|
|
694
|
-
AccordionContent.defaultProps = {
|
|
695
|
-
rows: 3,
|
|
696
|
-
columns: 12,
|
|
697
|
-
gap: 4,
|
|
698
|
-
rowSize: 48
|
|
699
|
-
};
|
|
700
|
-
var AccordionContent_default = AccordionContent;
|
|
701
|
-
|
|
702
|
-
// src/elements/tab/index.tsx
|
|
703
|
-
import React17, { createContext as createContext3, forwardRef as forwardRef13, useState as useState4 } from "react";
|
|
704
|
-
|
|
705
|
-
// src/elements/tab/TabHeaderWrapper.tsx
|
|
706
|
-
import React16, { useContext as useContext6, useEffect as useEffect3, useState as useState3 } from "react";
|
|
707
|
-
function TabHeader(props) {
|
|
708
|
-
const { wvId } = props;
|
|
709
|
-
const { active, setActive } = useContext6(TabContext);
|
|
710
|
-
const { itemInstances } = useContext6(WeaverseContext);
|
|
711
|
-
const instance = itemInstances.get(wvId);
|
|
712
|
-
let [data, setData] = useState3(instance.data);
|
|
713
|
-
useEffect3(() => {
|
|
714
|
-
let update = (data2) => setData({ ...data2 });
|
|
715
|
-
instance.subscribe(update);
|
|
716
|
-
}, []);
|
|
717
|
-
return /* @__PURE__ */ React16.createElement("div", {
|
|
718
|
-
onClick: () => setActive(wvId),
|
|
719
|
-
className: `wv-tab-header${active === wvId ? " active" : ""}`
|
|
720
|
-
}, data.name);
|
|
721
|
-
}
|
|
722
|
-
function TabHeaderWrapper(props) {
|
|
723
|
-
const { itemInstances } = useContext6(WeaverseContext);
|
|
724
|
-
const instance = itemInstances.get(props.wvId);
|
|
725
|
-
const data = instance.data;
|
|
726
|
-
const childIds = data.childIds;
|
|
727
|
-
return /* @__PURE__ */ React16.createElement("div", {
|
|
728
|
-
className: "wv-tab-header-wrapper"
|
|
729
|
-
}, childIds.map((id) => /* @__PURE__ */ React16.createElement(TabHeader, {
|
|
730
|
-
key: id,
|
|
731
|
-
wvId: id
|
|
732
|
-
})));
|
|
733
|
-
}
|
|
734
|
-
|
|
735
|
-
// src/elements/tab/index.tsx
|
|
736
|
-
var TabContext = createContext3({
|
|
737
|
-
active: null,
|
|
738
|
-
setActive: () => {
|
|
739
|
-
}
|
|
740
|
-
});
|
|
741
|
-
var Tab = forwardRef13((props, ref) => {
|
|
742
|
-
var _a, _b, _c;
|
|
743
|
-
const wvId = props["data-wv-id"];
|
|
744
|
-
const { fullWidthTabHeader, children, ...rest } = props;
|
|
745
|
-
const defaultActive = (_c = (_b = (_a = React17.Children.toArray(children)) == null ? void 0 : _a[0]) == null ? void 0 : _b.props) == null ? void 0 : _c.id;
|
|
746
|
-
const [active, setActive] = useState4(defaultActive);
|
|
747
|
-
const setOpenTab = (id) => {
|
|
748
|
-
if (id !== active) {
|
|
749
|
-
setActive(id);
|
|
750
|
-
}
|
|
751
|
-
};
|
|
752
|
-
return /* @__PURE__ */ React17.createElement("div", {
|
|
753
|
-
ref,
|
|
754
|
-
...rest,
|
|
755
|
-
style: {
|
|
756
|
-
"--tab-width": fullWidthTabHeader ? "100%" : "auto"
|
|
757
|
-
}
|
|
758
|
-
}, /* @__PURE__ */ React17.createElement(TabContext.Provider, {
|
|
759
|
-
value: { active, setActive: setOpenTab }
|
|
760
|
-
}, /* @__PURE__ */ React17.createElement(TabHeaderWrapper, {
|
|
761
|
-
wvId
|
|
762
|
-
}), children));
|
|
763
|
-
});
|
|
764
|
-
var css12 = {
|
|
765
|
-
"@desktop": {
|
|
766
|
-
display: "flex",
|
|
767
|
-
flexDirection: "column",
|
|
768
|
-
gap: 4,
|
|
769
|
-
"& .wv-tab-header-wrapper": {
|
|
770
|
-
width: "100%",
|
|
771
|
-
display: "flex",
|
|
772
|
-
marginBottom: 10
|
|
773
|
-
},
|
|
774
|
-
"& .wv-tab-header": {
|
|
775
|
-
backgroundColor: "#fff",
|
|
776
|
-
padding: "15px 24px",
|
|
777
|
-
border: "1px solid #E4E7EB",
|
|
778
|
-
cursor: "pointer",
|
|
779
|
-
textAlign: "center",
|
|
780
|
-
width: "var(--tab-width, auto)",
|
|
781
|
-
"&.active": {
|
|
782
|
-
backgroundColor: "#E4E7EB"
|
|
783
|
-
}
|
|
784
|
-
}
|
|
785
|
-
}
|
|
786
|
-
};
|
|
787
|
-
Tab.defaultProps = {
|
|
788
|
-
fullWidthTabHeader: false
|
|
789
|
-
};
|
|
790
|
-
var tab_default = Tab;
|
|
791
|
-
|
|
792
|
-
// src/elements/tab/TabContent.tsx
|
|
793
|
-
import React18, { forwardRef as forwardRef14, useContext as useContext7 } from "react";
|
|
794
|
-
var TabContent = forwardRef14(
|
|
795
|
-
(props, ref) => {
|
|
796
|
-
const { active } = useContext7(TabContext);
|
|
797
|
-
const wvId = props["data-wv-id"];
|
|
798
|
-
const { rows, columns, gap, rowSize, children, ...rest } = props;
|
|
799
|
-
let style = {
|
|
800
|
-
"--rows": rows,
|
|
801
|
-
"--columns": columns,
|
|
802
|
-
"--gap": gap + "px",
|
|
803
|
-
"--row-size": rowSize + "px",
|
|
804
|
-
"--col-size": "calc((var(--grid-size) - calc(var(--columns) - 1) * var(--gap)) / var(--columns))",
|
|
805
|
-
"--max-height": rows * rowSize + gap * (rowSize - 1) + "px",
|
|
806
|
-
"--content-active": active === wvId ? "grid" : "none"
|
|
807
|
-
};
|
|
808
|
-
return /* @__PURE__ */ React18.createElement("div", {
|
|
809
|
-
ref,
|
|
810
|
-
...rest,
|
|
811
|
-
style
|
|
812
|
-
}, React18.Children.count(children) > 0 ? children : /* @__PURE__ */ React18.createElement(Placeholder_default, {
|
|
813
|
-
element: "Tab Content"
|
|
814
|
-
}, "Drag and drop an element here."));
|
|
815
|
-
}
|
|
816
|
-
);
|
|
817
|
-
var css13 = {
|
|
818
|
-
"@desktop": {
|
|
819
|
-
width: "100%",
|
|
820
|
-
maxWidth: "var(--grid-size)",
|
|
821
|
-
display: "var(--content-active, none)",
|
|
822
|
-
gridTemplateRows: "repeat(var(--rows), var(--row-size))",
|
|
823
|
-
gridTemplateColumns: "repeat(var(--columns), minmax(0, var(--col-size)))",
|
|
824
|
-
gap: "var(--gap)",
|
|
825
|
-
borderRadius: 4
|
|
826
|
-
}
|
|
827
|
-
};
|
|
828
|
-
TabContent.defaultProps = {
|
|
829
|
-
rows: 3,
|
|
830
|
-
columns: 12,
|
|
831
|
-
gap: 4,
|
|
832
|
-
rowSize: 48,
|
|
833
|
-
name: "Tab header"
|
|
834
|
-
};
|
|
835
|
-
var TabContent_default = TabContent;
|
|
836
|
-
|
|
837
|
-
// src/elements/slider/index.tsx
|
|
838
|
-
import React19, { forwardRef as forwardRef15, useContext as useContext8 } from "react";
|
|
839
|
-
import { Carousel } from "nuka-carousel/lib/carousel";
|
|
840
|
-
var Slider = forwardRef15((props, ref) => {
|
|
841
|
-
const { isDesignMode } = useContext8(WeaverseContext);
|
|
842
|
-
const { autoplay, delay, children, ...rest } = props;
|
|
843
|
-
return /* @__PURE__ */ React19.createElement("div", {
|
|
844
|
-
...rest,
|
|
845
|
-
ref
|
|
846
|
-
}, /* @__PURE__ */ React19.createElement(Carousel, {
|
|
847
|
-
dragging: false,
|
|
848
|
-
renderCenterLeftControls: (props2) => /* @__PURE__ */ React19.createElement("button", {
|
|
849
|
-
className: "wv-slider-btn",
|
|
850
|
-
onClick: props2.previousSlide,
|
|
851
|
-
disabled: (isDesignMode || !autoplay) && props2.currentSlide === 0
|
|
852
|
-
}, /* @__PURE__ */ React19.createElement("i", {
|
|
853
|
-
className: "wv-slider-arrow wv-slider-arrow-left"
|
|
854
|
-
})),
|
|
855
|
-
renderCenterRightControls: (props2) => /* @__PURE__ */ React19.createElement("button", {
|
|
856
|
-
className: "wv-slider-btn",
|
|
857
|
-
onClick: props2.nextSlide,
|
|
858
|
-
disabled: (isDesignMode || !autoplay) && props2.slideCount === props2.currentSlide
|
|
859
|
-
}, /* @__PURE__ */ React19.createElement("i", {
|
|
860
|
-
className: "wv-slider-arrow wv-slider-arrow-right"
|
|
861
|
-
})),
|
|
862
|
-
wrapAround: !isDesignMode,
|
|
863
|
-
autoplay: !isDesignMode && autoplay,
|
|
864
|
-
autoplayInterval: delay * 1e3
|
|
865
|
-
}, children));
|
|
866
|
-
});
|
|
867
|
-
var css14 = {
|
|
868
|
-
"@desktop": {
|
|
869
|
-
"& .wv-slider-btn": {
|
|
870
|
-
borderRadius: "100%",
|
|
871
|
-
width: 40,
|
|
872
|
-
height: 40,
|
|
873
|
-
background: "#fff",
|
|
874
|
-
border: "none",
|
|
875
|
-
cursor: "pointer",
|
|
876
|
-
"&[disabled]": {
|
|
877
|
-
cursor: "not-allowed"
|
|
878
|
-
},
|
|
879
|
-
"&:hover .wv-slider-arrow": {
|
|
880
|
-
borderColor: "#999"
|
|
881
|
-
},
|
|
882
|
-
"& .wv-slider-arrow": {
|
|
883
|
-
border: "solid black",
|
|
884
|
-
borderWidth: "0 1px 1px 0",
|
|
885
|
-
display: "inline-block",
|
|
886
|
-
padding: 5
|
|
887
|
-
},
|
|
888
|
-
"& .wv-slider-arrow-right": {
|
|
889
|
-
transform: "rotate(-45deg)",
|
|
890
|
-
marginRight: 5
|
|
891
|
-
},
|
|
892
|
-
"& .wv-slider-arrow-left": {
|
|
893
|
-
transform: "rotate(135deg)",
|
|
894
|
-
marginLeft: 5
|
|
895
|
-
}
|
|
896
|
-
}
|
|
897
|
-
}
|
|
898
|
-
};
|
|
899
|
-
Slider.defaultProps = {
|
|
900
|
-
fullWidth: true,
|
|
901
|
-
autoplay: true,
|
|
902
|
-
delay: 3
|
|
903
|
-
};
|
|
904
|
-
var slider_default = Slider;
|
|
905
|
-
|
|
906
|
-
// src/elements/slider/SliderContent.tsx
|
|
907
|
-
import React20, { forwardRef as forwardRef16, useContext as useContext9 } from "react";
|
|
908
|
-
var SliderContent = forwardRef16(
|
|
909
|
-
(props, ref) => {
|
|
910
|
-
const { isDesignMode } = useContext9(WeaverseContext);
|
|
911
|
-
const {
|
|
912
|
-
mediaUrl,
|
|
913
|
-
targetLink,
|
|
914
|
-
openInNewTab,
|
|
915
|
-
rows,
|
|
916
|
-
columns,
|
|
917
|
-
gap,
|
|
918
|
-
rowSize,
|
|
919
|
-
children,
|
|
920
|
-
...rest
|
|
921
|
-
} = props;
|
|
922
|
-
let style = {
|
|
923
|
-
"--rows": rows,
|
|
924
|
-
"--columns": columns,
|
|
925
|
-
"--gap": gap + "px",
|
|
926
|
-
"--row-size": rowSize + "px",
|
|
927
|
-
"--col-size": "calc((var(--grid-size) - calc(var(--columns) - 1) * var(--gap)) / var(--columns))",
|
|
928
|
-
"--max-height": rows * rowSize + gap * (rowSize - 1) + "px",
|
|
929
|
-
"--background-url": `url(${mediaUrl}`
|
|
930
|
-
};
|
|
931
|
-
const handleClick = () => {
|
|
932
|
-
if (!isDesignMode && targetLink) {
|
|
933
|
-
window.open(targetLink, openInNewTab ? "_blank" : "_self");
|
|
934
|
-
}
|
|
935
|
-
};
|
|
936
|
-
return /* @__PURE__ */ React20.createElement("div", {
|
|
937
|
-
...rest,
|
|
938
|
-
style,
|
|
939
|
-
onClick: handleClick
|
|
940
|
-
}, React20.Children.count(children) > 0 ? children : /* @__PURE__ */ React20.createElement(Placeholder_default, {
|
|
941
|
-
element: "Slider Content"
|
|
942
|
-
}, "Drag and drop an element here."));
|
|
943
|
-
}
|
|
944
|
-
);
|
|
945
|
-
var css15 = {
|
|
946
|
-
"@desktop": {
|
|
947
|
-
width: "100%",
|
|
948
|
-
maxWidth: "var(--grid-size)",
|
|
949
|
-
display: "grid",
|
|
950
|
-
gridTemplateRows: "repeat(var(--rows), var(--row-size))",
|
|
951
|
-
gridTemplateColumns: "repeat(var(--columns), minmax(0, var(--col-size)))",
|
|
952
|
-
gap: "var(--gap)",
|
|
953
|
-
borderRadius: 4,
|
|
954
|
-
backgroundImage: "var(--background-url, none)"
|
|
955
|
-
}
|
|
956
|
-
};
|
|
957
|
-
SliderContent.defaultProps = {
|
|
958
|
-
name: "Slider",
|
|
959
|
-
mediaUrl: "",
|
|
960
|
-
openInNewTab: false,
|
|
961
|
-
targetLink: "https://myshop.com",
|
|
962
|
-
rows: 4,
|
|
963
|
-
columns: 12,
|
|
964
|
-
gap: 4,
|
|
965
|
-
rowSize: 48
|
|
966
|
-
};
|
|
967
|
-
var SliderContent_default = SliderContent;
|
|
968
|
-
|
|
969
506
|
// src/elements/index.ts
|
|
970
507
|
var SharedComponents = {
|
|
971
508
|
Placeholder: Placeholder_default
|
|
@@ -974,99 +511,65 @@ var Elements = {
|
|
|
974
511
|
Countdown: {
|
|
975
512
|
Component: countdown_default,
|
|
976
513
|
type: "countdown",
|
|
977
|
-
defaultCss:
|
|
514
|
+
defaultCss: css3
|
|
978
515
|
},
|
|
979
516
|
Button: {
|
|
980
517
|
Component: button_default,
|
|
981
|
-
type: "button"
|
|
518
|
+
type: "button",
|
|
519
|
+
defaultCss: css
|
|
982
520
|
},
|
|
983
521
|
Container: {
|
|
984
522
|
Component: container_default,
|
|
985
523
|
type: "container",
|
|
986
|
-
defaultCss:
|
|
524
|
+
defaultCss: css2
|
|
987
525
|
},
|
|
988
526
|
Image: {
|
|
989
527
|
Component: image_default,
|
|
990
528
|
type: "image",
|
|
991
|
-
defaultCss:
|
|
529
|
+
defaultCss: css4
|
|
992
530
|
},
|
|
993
531
|
Instagram: {
|
|
994
532
|
Component: instagram_default,
|
|
995
533
|
type: "instagram",
|
|
996
|
-
defaultCss:
|
|
534
|
+
defaultCss: css9
|
|
997
535
|
},
|
|
998
536
|
Layout: {
|
|
999
537
|
Component: layout_default,
|
|
1000
538
|
type: "layout",
|
|
1001
|
-
defaultCss:
|
|
539
|
+
defaultCss: css5
|
|
1002
540
|
},
|
|
1003
541
|
Map: {
|
|
1004
542
|
Component: map_default,
|
|
1005
543
|
type: "map",
|
|
1006
|
-
defaultCss:
|
|
544
|
+
defaultCss: css6
|
|
1007
545
|
},
|
|
1008
546
|
Text: {
|
|
1009
547
|
Component: text_default,
|
|
1010
548
|
type: "text",
|
|
1011
|
-
defaultCss:
|
|
549
|
+
defaultCss: css7
|
|
1012
550
|
},
|
|
1013
551
|
Video: {
|
|
1014
552
|
Component: video_default,
|
|
1015
553
|
type: "video",
|
|
1016
|
-
defaultCss:
|
|
1017
|
-
},
|
|
1018
|
-
Accordion: {
|
|
1019
|
-
Component: accordion_default,
|
|
1020
|
-
type: "accordion",
|
|
1021
|
-
defaultCss: css9
|
|
1022
|
-
},
|
|
1023
|
-
AccordionWrapper: {
|
|
1024
|
-
Component: AccordionWrapper_default,
|
|
1025
|
-
type: "accordion.wrapper",
|
|
1026
|
-
defaultCss: css10
|
|
1027
|
-
},
|
|
1028
|
-
AccordionContent: {
|
|
1029
|
-
Component: AccordionContent_default,
|
|
1030
|
-
type: "accordion.content",
|
|
1031
|
-
defaultCss: css11
|
|
1032
|
-
},
|
|
1033
|
-
Tab: {
|
|
1034
|
-
Component: tab_default,
|
|
1035
|
-
type: "tab",
|
|
1036
|
-
defaultCss: css12
|
|
1037
|
-
},
|
|
1038
|
-
TabContent: {
|
|
1039
|
-
Component: TabContent_default,
|
|
1040
|
-
type: "tab.content",
|
|
1041
|
-
defaultCss: css13
|
|
1042
|
-
},
|
|
1043
|
-
Slider: {
|
|
1044
|
-
Component: slider_default,
|
|
1045
|
-
type: "slider",
|
|
1046
|
-
defaultCss: css14
|
|
1047
|
-
},
|
|
1048
|
-
SliderContent: {
|
|
1049
|
-
Component: SliderContent_default,
|
|
1050
|
-
type: "slider.content",
|
|
1051
|
-
defaultCss: css15
|
|
554
|
+
defaultCss: css8
|
|
1052
555
|
}
|
|
1053
556
|
};
|
|
1054
557
|
|
|
1055
558
|
// src/renderer.tsx
|
|
1056
559
|
import { isBrowser } from "@weaverse/core";
|
|
1057
|
-
import
|
|
560
|
+
import React12, { useContext as useContext3, useEffect as useEffect3, useRef, useState as useState2 } from "react";
|
|
1058
561
|
|
|
1059
562
|
// src/utils/index.ts
|
|
1060
|
-
function shortCssObject(
|
|
563
|
+
function shortCssObject(css10) {
|
|
1061
564
|
return {
|
|
1062
|
-
"@desktop":
|
|
1063
|
-
"@mobile":
|
|
565
|
+
"@desktop": css10["@desktop"],
|
|
566
|
+
"@mobile": css10["@mobile"]
|
|
1064
567
|
};
|
|
1065
568
|
}
|
|
1066
569
|
var permanentClasses = {};
|
|
1067
570
|
function generateItemClass(instance, stitchesInstance) {
|
|
1068
571
|
var _a, _b;
|
|
1069
|
-
let { css:
|
|
572
|
+
let { css: css10, type, className: cls = "" } = instance.data;
|
|
1070
573
|
let className = "";
|
|
1071
574
|
let permanentClass = "";
|
|
1072
575
|
let perCss = (_a = instance.Element) == null ? void 0 : _a.permanentCss;
|
|
@@ -1080,8 +583,8 @@ function generateItemClass(instance, stitchesInstance) {
|
|
|
1080
583
|
}
|
|
1081
584
|
}
|
|
1082
585
|
className = permanentClass;
|
|
1083
|
-
if (
|
|
1084
|
-
let formattedCss = shortCssObject(
|
|
586
|
+
if (css10) {
|
|
587
|
+
let formattedCss = shortCssObject(css10);
|
|
1085
588
|
let { className: newClass = "" } = stitchesInstance.css(formattedCss)();
|
|
1086
589
|
let { stitchesClass } = instance;
|
|
1087
590
|
let otherClass = (((_b = instance.ref.current) == null ? void 0 : _b.className) || "").replace(stitchesClass, "").replace(cls, "").replace(permanentClass, "").trim();
|
|
@@ -1094,10 +597,10 @@ function generateItemClass(instance, stitchesInstance) {
|
|
|
1094
597
|
// src/renderer.tsx
|
|
1095
598
|
var WeaverseRoot = ({ context }) => {
|
|
1096
599
|
var _a, _b;
|
|
1097
|
-
let [, setData] =
|
|
600
|
+
let [, setData] = useState2(context.projectData);
|
|
1098
601
|
let rootRef = useRef();
|
|
1099
602
|
let update = () => setData({});
|
|
1100
|
-
|
|
603
|
+
useEffect3(() => {
|
|
1101
604
|
context.subscribe(update);
|
|
1102
605
|
context.contentRootElement = rootRef.current;
|
|
1103
606
|
return () => {
|
|
@@ -1106,21 +609,21 @@ var WeaverseRoot = ({ context }) => {
|
|
|
1106
609
|
}, []);
|
|
1107
610
|
let eventHandlers = ((_a = context == null ? void 0 : context.studioBridge) == null ? void 0 : _a.eventHandlers) || {};
|
|
1108
611
|
let themeClass = context.stitchesInstance.theme.className;
|
|
1109
|
-
return ((_b = context.projectData) == null ? void 0 : _b.rootId) ? /* @__PURE__ */
|
|
612
|
+
return ((_b = context.projectData) == null ? void 0 : _b.rootId) ? /* @__PURE__ */ React12.createElement("div", {
|
|
1110
613
|
className: `weaverse-content-root ${themeClass}`,
|
|
1111
614
|
...eventHandlers,
|
|
1112
615
|
ref: rootRef
|
|
1113
|
-
}, /* @__PURE__ */
|
|
616
|
+
}, /* @__PURE__ */ React12.createElement(WeaverseContextProvider, {
|
|
1114
617
|
value: context
|
|
1115
|
-
}, /* @__PURE__ */
|
|
618
|
+
}, /* @__PURE__ */ React12.createElement(ItemInstance, {
|
|
1116
619
|
id: context.projectData.rootId
|
|
1117
620
|
}))) : null;
|
|
1118
621
|
};
|
|
1119
622
|
var ItemComponent = ({ instance }) => {
|
|
1120
|
-
let { stitchesInstance, elementInstances } =
|
|
1121
|
-
let [data, setData] =
|
|
1122
|
-
let { id, type, childIds = [], css:
|
|
1123
|
-
|
|
623
|
+
let { stitchesInstance, elementInstances } = useContext3(WeaverseContext);
|
|
624
|
+
let [data, setData] = useState2(instance.data);
|
|
625
|
+
let { id, type, childIds = [], css: css10, className, ...rest } = data;
|
|
626
|
+
useEffect3(() => {
|
|
1124
627
|
let update = (data2) => setData({ ...data2 });
|
|
1125
628
|
instance.subscribe(update);
|
|
1126
629
|
if (isBrowser && !instance.ref.current) {
|
|
@@ -1136,13 +639,13 @@ var ItemComponent = ({ instance }) => {
|
|
|
1136
639
|
if (Component.$$typeof === Symbol.for("react.forward_ref")) {
|
|
1137
640
|
rest.ref = instance.ref;
|
|
1138
641
|
}
|
|
1139
|
-
return /* @__PURE__ */
|
|
642
|
+
return /* @__PURE__ */ React12.createElement(Component, {
|
|
1140
643
|
key: id,
|
|
1141
644
|
"data-wv-type": type,
|
|
1142
645
|
"data-wv-id": id,
|
|
1143
646
|
className: generateItemClass(instance, stitchesInstance),
|
|
1144
647
|
...rest
|
|
1145
|
-
}, childIds.map((id2) => /* @__PURE__ */
|
|
648
|
+
}, childIds.map((id2) => /* @__PURE__ */ React12.createElement(ItemInstance, {
|
|
1146
649
|
key: id2,
|
|
1147
650
|
id: id2
|
|
1148
651
|
})));
|
|
@@ -1150,15 +653,15 @@ var ItemComponent = ({ instance }) => {
|
|
|
1150
653
|
return null;
|
|
1151
654
|
};
|
|
1152
655
|
var ItemInstance = ({ id }) => {
|
|
1153
|
-
let context =
|
|
656
|
+
let context = useContext3(WeaverseContext);
|
|
1154
657
|
let { itemInstances } = context;
|
|
1155
658
|
let instance = itemInstances.get(id);
|
|
1156
659
|
if (!instance) {
|
|
1157
|
-
return /* @__PURE__ */
|
|
660
|
+
return /* @__PURE__ */ React12.createElement("div", {
|
|
1158
661
|
style: { display: "none" }
|
|
1159
662
|
}, "Item instance ", id, " not found");
|
|
1160
663
|
}
|
|
1161
|
-
return /* @__PURE__ */
|
|
664
|
+
return /* @__PURE__ */ React12.createElement(ItemComponent, {
|
|
1162
665
|
instance
|
|
1163
666
|
});
|
|
1164
667
|
};
|