@weaverse/react 0.7.15 → 0.7.17
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 +8 -3
- package/dist/index.js +91 -579
- package/dist/index.mjs +90 -578
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -199,34 +199,6 @@ var countdown_default = Countdown;
|
|
|
199
199
|
|
|
200
200
|
// src/elements/image.tsx
|
|
201
201
|
import React5 from "react";
|
|
202
|
-
import { isBrowser } from "@weaverse/core";
|
|
203
|
-
var loadUploadCareAdaptiveDelivery = () => {
|
|
204
|
-
if (!window.Blinkloader) {
|
|
205
|
-
console.log("loadUploadCareAdaptiveDelivery");
|
|
206
|
-
(function(src, cb) {
|
|
207
|
-
let s = document.createElement("script");
|
|
208
|
-
s.setAttribute("src", src);
|
|
209
|
-
s.onload = cb;
|
|
210
|
-
(document.head || document.body).appendChild(s);
|
|
211
|
-
})(
|
|
212
|
-
"https://ucarecdn.com/libs/blinkloader/3.x/blinkloader.min.js",
|
|
213
|
-
function() {
|
|
214
|
-
window.Blinkloader.optimize({
|
|
215
|
-
pubkey: "1a22133d1a1bdc089d4c",
|
|
216
|
-
fadeIn: true,
|
|
217
|
-
lazyload: true,
|
|
218
|
-
smartCompression: true,
|
|
219
|
-
responsive: true,
|
|
220
|
-
retina: true,
|
|
221
|
-
webp: true
|
|
222
|
-
});
|
|
223
|
-
}
|
|
224
|
-
);
|
|
225
|
-
}
|
|
226
|
-
};
|
|
227
|
-
if (isBrowser) {
|
|
228
|
-
loadUploadCareAdaptiveDelivery();
|
|
229
|
-
}
|
|
230
202
|
var Image = React5.forwardRef(
|
|
231
203
|
(props, ref) => {
|
|
232
204
|
let {
|
|
@@ -269,7 +241,7 @@ var css4 = {
|
|
|
269
241
|
objectFit: "var(--wv-img-object-fit, cover)",
|
|
270
242
|
objectPosition: "var(--wv-img-object-position, center)"
|
|
271
243
|
},
|
|
272
|
-
"
|
|
244
|
+
"& [data-blink-src]": {
|
|
273
245
|
visibility: "hidden"
|
|
274
246
|
}
|
|
275
247
|
}
|
|
@@ -288,7 +260,18 @@ var image_default = Image;
|
|
|
288
260
|
// src/elements/layout.tsx
|
|
289
261
|
import React6, { forwardRef as forwardRef4 } from "react";
|
|
290
262
|
var Layout = forwardRef4((props, ref) => {
|
|
291
|
-
let {
|
|
263
|
+
let {
|
|
264
|
+
children,
|
|
265
|
+
rows,
|
|
266
|
+
gap,
|
|
267
|
+
rowSize,
|
|
268
|
+
columns,
|
|
269
|
+
gridSize,
|
|
270
|
+
backgroundColor,
|
|
271
|
+
backgroundImage,
|
|
272
|
+
objectFit,
|
|
273
|
+
...rest
|
|
274
|
+
} = props;
|
|
292
275
|
let style = {
|
|
293
276
|
"--grid-size": gridSize + "px",
|
|
294
277
|
"--rows": rows,
|
|
@@ -301,10 +284,30 @@ var Layout = forwardRef4((props, ref) => {
|
|
|
301
284
|
ref,
|
|
302
285
|
...rest,
|
|
303
286
|
style
|
|
304
|
-
}, /* @__PURE__ */ React6.createElement(
|
|
287
|
+
}, /* @__PURE__ */ React6.createElement(LayoutBackground, {
|
|
288
|
+
imgUrl: backgroundImage,
|
|
289
|
+
bgColor: backgroundColor,
|
|
290
|
+
objectFit
|
|
291
|
+
}), /* @__PURE__ */ React6.createElement("div", {
|
|
305
292
|
"data-layout-content": true
|
|
306
293
|
}, children));
|
|
307
294
|
});
|
|
295
|
+
var LayoutBackground = (props) => {
|
|
296
|
+
let { bgColor, imgUrl, objectFit } = props;
|
|
297
|
+
let style = {
|
|
298
|
+
["--bg-color"]: bgColor,
|
|
299
|
+
["--object-fit"]: objectFit
|
|
300
|
+
};
|
|
301
|
+
return imgUrl || bgColor ? /* @__PURE__ */ React6.createElement("div", {
|
|
302
|
+
"data-wv-bg": true,
|
|
303
|
+
style
|
|
304
|
+
}, imgUrl && /* @__PURE__ */ React6.createElement("img", {
|
|
305
|
+
width: "100%",
|
|
306
|
+
height: "100%",
|
|
307
|
+
"data-blink-src": imgUrl,
|
|
308
|
+
alt: "wv-layout-background"
|
|
309
|
+
})) : null;
|
|
310
|
+
};
|
|
308
311
|
var css5 = {
|
|
309
312
|
"@desktop": {
|
|
310
313
|
paddingTop: "16px",
|
|
@@ -328,6 +331,18 @@ var css5 = {
|
|
|
328
331
|
}
|
|
329
332
|
}
|
|
330
333
|
};
|
|
334
|
+
var permanentCss = {
|
|
335
|
+
"@desktop": {
|
|
336
|
+
"[data-wv-bg]": {
|
|
337
|
+
position: "absolute",
|
|
338
|
+
inset: 0,
|
|
339
|
+
backgroundColor: "var(--bg-color)"
|
|
340
|
+
},
|
|
341
|
+
img: {
|
|
342
|
+
objectFit: "var(--object-fit, cover)"
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
};
|
|
331
346
|
Layout.defaultProps = {
|
|
332
347
|
gridSize: 1224,
|
|
333
348
|
rows: 12,
|
|
@@ -438,7 +453,7 @@ var Placeholder = forwardRef8(
|
|
|
438
453
|
(props, ref) => {
|
|
439
454
|
let { element, children, ...rest } = props;
|
|
440
455
|
return /* @__PURE__ */ React10.createElement("div", {
|
|
441
|
-
"data-wv-
|
|
456
|
+
"data-wv-placeholder": true,
|
|
442
457
|
style: { display: "none" },
|
|
443
458
|
ref,
|
|
444
459
|
...rest
|
|
@@ -531,480 +546,6 @@ Instagram.defaultProps = {
|
|
|
531
546
|
};
|
|
532
547
|
var instagram_default = Instagram;
|
|
533
548
|
|
|
534
|
-
// src/elements/accordion/index.tsx
|
|
535
|
-
import React12, { createContext as createContext2, forwardRef as forwardRef10, useState as useState2 } from "react";
|
|
536
|
-
var AccordionContext = createContext2({
|
|
537
|
-
iconName: "arrow",
|
|
538
|
-
active: [],
|
|
539
|
-
setActive: () => {
|
|
540
|
-
}
|
|
541
|
-
});
|
|
542
|
-
var Accordion = forwardRef10(
|
|
543
|
-
(props, ref) => {
|
|
544
|
-
const { iconName, children, ...rest } = props;
|
|
545
|
-
const [active, setActive] = useState2([]);
|
|
546
|
-
const setOpenAccordion = (id) => {
|
|
547
|
-
if (active.includes(id)) {
|
|
548
|
-
setActive(active.filter((_id) => _id !== id));
|
|
549
|
-
} else {
|
|
550
|
-
setActive([...active, id]);
|
|
551
|
-
}
|
|
552
|
-
};
|
|
553
|
-
return /* @__PURE__ */ React12.createElement("div", {
|
|
554
|
-
ref,
|
|
555
|
-
...rest
|
|
556
|
-
}, /* @__PURE__ */ React12.createElement(AccordionContext.Provider, {
|
|
557
|
-
value: { active, setActive: setOpenAccordion, iconName }
|
|
558
|
-
}, children));
|
|
559
|
-
}
|
|
560
|
-
);
|
|
561
|
-
var css10 = {
|
|
562
|
-
"@desktop": {
|
|
563
|
-
display: "flex",
|
|
564
|
-
flexDirection: "column",
|
|
565
|
-
gap: 4
|
|
566
|
-
}
|
|
567
|
-
};
|
|
568
|
-
Accordion.defaultProps = {
|
|
569
|
-
iconName: "arrow"
|
|
570
|
-
};
|
|
571
|
-
var accordion_default = Accordion;
|
|
572
|
-
|
|
573
|
-
// src/elements/accordion/AccordionWrapper.tsx
|
|
574
|
-
import React14, { forwardRef as forwardRef11, useContext as useContext4 } from "react";
|
|
575
|
-
|
|
576
|
-
// src/elements/accordion/Icon.tsx
|
|
577
|
-
import React13, { useContext as useContext3 } from "react";
|
|
578
|
-
var ICONS = {
|
|
579
|
-
caret: {
|
|
580
|
-
animationType: "rotate90",
|
|
581
|
-
css: {
|
|
582
|
-
position: "absolute!important",
|
|
583
|
-
left: 5,
|
|
584
|
-
top: 2,
|
|
585
|
-
width: 0,
|
|
586
|
-
height: 0,
|
|
587
|
-
borderTop: "6px solid transparent",
|
|
588
|
-
borderBottom: "6px solid transparent",
|
|
589
|
-
borderLeft: "6px solid #1F2A37"
|
|
590
|
-
}
|
|
591
|
-
},
|
|
592
|
-
arrow: {
|
|
593
|
-
animationType: "rotate90",
|
|
594
|
-
css: {
|
|
595
|
-
border: "solid #1F2A37",
|
|
596
|
-
borderWidth: "0 1px 1px 0",
|
|
597
|
-
display: "inline-block",
|
|
598
|
-
transform: "rotate(-45deg) translate(15%, -15%)",
|
|
599
|
-
padding: 4
|
|
600
|
-
}
|
|
601
|
-
},
|
|
602
|
-
plus: {
|
|
603
|
-
animationType: "custom",
|
|
604
|
-
css: {
|
|
605
|
-
display: "inline-block",
|
|
606
|
-
top: -6,
|
|
607
|
-
width: 15,
|
|
608
|
-
height: 1,
|
|
609
|
-
backgroundColor: "#1F2A37",
|
|
610
|
-
"&:after": {
|
|
611
|
-
position: "absolute",
|
|
612
|
-
content: "",
|
|
613
|
-
top: -7,
|
|
614
|
-
left: 7,
|
|
615
|
-
width: 1,
|
|
616
|
-
height: 15,
|
|
617
|
-
backgroundColor: "#1F2A37",
|
|
618
|
-
transition: "all 0.3s ease-in-out 0s"
|
|
619
|
-
},
|
|
620
|
-
"&.active": {
|
|
621
|
-
"&:after": {
|
|
622
|
-
transform: "rotate(90deg)"
|
|
623
|
-
}
|
|
624
|
-
}
|
|
625
|
-
}
|
|
626
|
-
}
|
|
627
|
-
};
|
|
628
|
-
var rotateAnimation = {
|
|
629
|
-
transition: "all 0.3s ease-in-out 0s",
|
|
630
|
-
transform: "rotate(90deg)"
|
|
631
|
-
};
|
|
632
|
-
function Icon(props) {
|
|
633
|
-
let { name, active = false, style, ...rest } = props;
|
|
634
|
-
let { stitchesInstance } = useContext3(WeaverseContext);
|
|
635
|
-
const { animationType, css: css17 } = ICONS[name];
|
|
636
|
-
if (active && animationType === "rotate90") {
|
|
637
|
-
style = { ...rotateAnimation, ...style };
|
|
638
|
-
}
|
|
639
|
-
let { className } = stitchesInstance.css(css17)();
|
|
640
|
-
if (active)
|
|
641
|
-
className += " active";
|
|
642
|
-
return /* @__PURE__ */ React13.createElement("span", {
|
|
643
|
-
style,
|
|
644
|
-
...rest
|
|
645
|
-
}, /* @__PURE__ */ React13.createElement("i", {
|
|
646
|
-
className
|
|
647
|
-
}));
|
|
648
|
-
}
|
|
649
|
-
var Icon_default = Icon;
|
|
650
|
-
|
|
651
|
-
// src/elements/accordion/AccordionWrapper.tsx
|
|
652
|
-
var AccordionWrapper = forwardRef11((props, ref) => {
|
|
653
|
-
const { ["data-wv-id"]: wvId, name, children, ...rest } = props;
|
|
654
|
-
const { iconName, active, setActive } = useContext4(AccordionContext);
|
|
655
|
-
const isActive = active.includes(wvId);
|
|
656
|
-
return /* @__PURE__ */ React14.createElement("div", {
|
|
657
|
-
ref,
|
|
658
|
-
...rest
|
|
659
|
-
}, /* @__PURE__ */ React14.createElement("div", {
|
|
660
|
-
onClick: () => setActive(wvId),
|
|
661
|
-
className: `wv-acc-header ${isActive ? "active" : ""}`
|
|
662
|
-
}, /* @__PURE__ */ React14.createElement("span", null, name), /* @__PURE__ */ React14.createElement(Icon_default, {
|
|
663
|
-
className: "wv-acc-icon",
|
|
664
|
-
active: isActive,
|
|
665
|
-
name: iconName
|
|
666
|
-
})), children);
|
|
667
|
-
});
|
|
668
|
-
var css11 = {
|
|
669
|
-
"@desktop": {
|
|
670
|
-
maxHeight: "100%",
|
|
671
|
-
".wv-acc-icon": {
|
|
672
|
-
position: "absolute",
|
|
673
|
-
right: 16,
|
|
674
|
-
width: 16,
|
|
675
|
-
height: 16,
|
|
676
|
-
transition: "all 0.3s ease-in-out 0s"
|
|
677
|
-
},
|
|
678
|
-
".wv-acc-header": {
|
|
679
|
-
display: "flex",
|
|
680
|
-
alignItems: "center",
|
|
681
|
-
borderRadius: 4,
|
|
682
|
-
padding: 12,
|
|
683
|
-
marginBottom: 4,
|
|
684
|
-
border: "1px solid #76A9FA",
|
|
685
|
-
cursor: "pointer",
|
|
686
|
-
'&.active + [data-wv-type="accordion.content"]': {
|
|
687
|
-
maxHeight: "var(--max-height, inherit)"
|
|
688
|
-
}
|
|
689
|
-
}
|
|
690
|
-
}
|
|
691
|
-
};
|
|
692
|
-
AccordionWrapper.defaultProps = {
|
|
693
|
-
name: "Accordion item"
|
|
694
|
-
};
|
|
695
|
-
var AccordionWrapper_default = AccordionWrapper;
|
|
696
|
-
|
|
697
|
-
// src/elements/accordion/AccordionContent.tsx
|
|
698
|
-
import React15, { forwardRef as forwardRef12 } from "react";
|
|
699
|
-
var AccordionContent = forwardRef12(
|
|
700
|
-
(props, ref) => {
|
|
701
|
-
const { rows, columns, gap, rowSize, children, ...rest } = props;
|
|
702
|
-
let style = {
|
|
703
|
-
"--rows": rows,
|
|
704
|
-
"--columns": columns,
|
|
705
|
-
"--gap": gap + "px",
|
|
706
|
-
"--row-size": rowSize + "px",
|
|
707
|
-
"--col-size": "calc((var(--grid-size) - calc(var(--columns) - 1) * var(--gap)) / var(--columns))",
|
|
708
|
-
"--max-height": rows * rowSize + gap * (rowSize - 1) + "px"
|
|
709
|
-
};
|
|
710
|
-
return /* @__PURE__ */ React15.createElement("div", {
|
|
711
|
-
ref,
|
|
712
|
-
...rest,
|
|
713
|
-
style
|
|
714
|
-
}, React15.Children.count(children) > 0 ? children : /* @__PURE__ */ React15.createElement(Placeholder_default, {
|
|
715
|
-
element: "Accordion Content"
|
|
716
|
-
}, "Drag and drop an element here."));
|
|
717
|
-
}
|
|
718
|
-
);
|
|
719
|
-
var css12 = {
|
|
720
|
-
"@desktop": {
|
|
721
|
-
width: "100%",
|
|
722
|
-
maxWidth: "var(--grid-size)",
|
|
723
|
-
display: "grid",
|
|
724
|
-
gridTemplateRows: "repeat(var(--rows), var(--row-size))",
|
|
725
|
-
gridTemplateColumns: "repeat(var(--columns), minmax(0, var(--col-size)))",
|
|
726
|
-
gap: "var(--gap)",
|
|
727
|
-
overflow: "hidden",
|
|
728
|
-
maxHeight: 0,
|
|
729
|
-
transition: "all var(--transition-duration, 0.3s) ease-in-out",
|
|
730
|
-
borderRadius: 4
|
|
731
|
-
}
|
|
732
|
-
};
|
|
733
|
-
AccordionContent.defaultProps = {
|
|
734
|
-
rows: 3,
|
|
735
|
-
columns: 12,
|
|
736
|
-
gap: 4,
|
|
737
|
-
rowSize: 48
|
|
738
|
-
};
|
|
739
|
-
var AccordionContent_default = AccordionContent;
|
|
740
|
-
|
|
741
|
-
// src/elements/tab/index.tsx
|
|
742
|
-
import React17, { createContext as createContext3, forwardRef as forwardRef13, useState as useState4 } from "react";
|
|
743
|
-
|
|
744
|
-
// src/elements/tab/TabHeaderWrapper.tsx
|
|
745
|
-
import React16, { useContext as useContext5, useEffect as useEffect3, useState as useState3 } from "react";
|
|
746
|
-
function TabHeader(props) {
|
|
747
|
-
const { wvId } = props;
|
|
748
|
-
const { active, setActive } = useContext5(TabContext);
|
|
749
|
-
const { itemInstances } = useContext5(WeaverseContext);
|
|
750
|
-
const instance = itemInstances.get(wvId);
|
|
751
|
-
let [data, setData] = useState3(instance.data);
|
|
752
|
-
useEffect3(() => {
|
|
753
|
-
let update = (data2) => setData({ ...data2 });
|
|
754
|
-
instance.subscribe(update);
|
|
755
|
-
}, []);
|
|
756
|
-
return /* @__PURE__ */ React16.createElement("div", {
|
|
757
|
-
onClick: () => setActive(wvId),
|
|
758
|
-
className: `wv-tab-header${active === wvId ? " active" : ""}`
|
|
759
|
-
}, data.name);
|
|
760
|
-
}
|
|
761
|
-
function TabHeaderWrapper(props) {
|
|
762
|
-
const { itemInstances } = useContext5(WeaverseContext);
|
|
763
|
-
const instance = itemInstances.get(props.wvId);
|
|
764
|
-
const data = instance.data;
|
|
765
|
-
const childIds = data.childIds;
|
|
766
|
-
return /* @__PURE__ */ React16.createElement("div", {
|
|
767
|
-
className: "wv-tab-header-wrapper"
|
|
768
|
-
}, childIds.map((id) => /* @__PURE__ */ React16.createElement(TabHeader, {
|
|
769
|
-
key: id,
|
|
770
|
-
wvId: id
|
|
771
|
-
})));
|
|
772
|
-
}
|
|
773
|
-
|
|
774
|
-
// src/elements/tab/index.tsx
|
|
775
|
-
var TabContext = createContext3({
|
|
776
|
-
active: null,
|
|
777
|
-
setActive: () => {
|
|
778
|
-
}
|
|
779
|
-
});
|
|
780
|
-
var Tab = forwardRef13((props, ref) => {
|
|
781
|
-
var _a, _b, _c;
|
|
782
|
-
const wvId = props["data-wv-id"];
|
|
783
|
-
const { fullWidthTabHeader, children, ...rest } = props;
|
|
784
|
-
const defaultActive = (_c = (_b = (_a = React17.Children.toArray(children)) == null ? void 0 : _a[0]) == null ? void 0 : _b.props) == null ? void 0 : _c.id;
|
|
785
|
-
const [active, setActive] = useState4(defaultActive);
|
|
786
|
-
const setOpenTab = (id) => {
|
|
787
|
-
if (id !== active) {
|
|
788
|
-
setActive(id);
|
|
789
|
-
}
|
|
790
|
-
};
|
|
791
|
-
return /* @__PURE__ */ React17.createElement("div", {
|
|
792
|
-
ref,
|
|
793
|
-
...rest,
|
|
794
|
-
style: {
|
|
795
|
-
"--tab-width": fullWidthTabHeader ? "100%" : "auto"
|
|
796
|
-
}
|
|
797
|
-
}, /* @__PURE__ */ React17.createElement(TabContext.Provider, {
|
|
798
|
-
value: { active, setActive: setOpenTab }
|
|
799
|
-
}, /* @__PURE__ */ React17.createElement(TabHeaderWrapper, {
|
|
800
|
-
wvId
|
|
801
|
-
}), children));
|
|
802
|
-
});
|
|
803
|
-
var css13 = {
|
|
804
|
-
"@desktop": {
|
|
805
|
-
display: "flex",
|
|
806
|
-
flexDirection: "column",
|
|
807
|
-
gap: 4,
|
|
808
|
-
"& .wv-tab-header-wrapper": {
|
|
809
|
-
width: "100%",
|
|
810
|
-
display: "flex",
|
|
811
|
-
marginBottom: 10
|
|
812
|
-
},
|
|
813
|
-
"& .wv-tab-header": {
|
|
814
|
-
backgroundColor: "#fff",
|
|
815
|
-
padding: "15px 24px",
|
|
816
|
-
border: "1px solid #E4E7EB",
|
|
817
|
-
cursor: "pointer",
|
|
818
|
-
textAlign: "center",
|
|
819
|
-
width: "var(--tab-width, auto)",
|
|
820
|
-
"&.active": {
|
|
821
|
-
backgroundColor: "#E4E7EB"
|
|
822
|
-
}
|
|
823
|
-
}
|
|
824
|
-
}
|
|
825
|
-
};
|
|
826
|
-
Tab.defaultProps = {
|
|
827
|
-
fullWidthTabHeader: false
|
|
828
|
-
};
|
|
829
|
-
var tab_default = Tab;
|
|
830
|
-
|
|
831
|
-
// src/elements/tab/TabContent.tsx
|
|
832
|
-
import React18, { forwardRef as forwardRef14, useContext as useContext6 } from "react";
|
|
833
|
-
var TabContent = forwardRef14(
|
|
834
|
-
(props, ref) => {
|
|
835
|
-
const { active } = useContext6(TabContext);
|
|
836
|
-
const wvId = props["data-wv-id"];
|
|
837
|
-
const { rows, columns, gap, rowSize, children, ...rest } = props;
|
|
838
|
-
let style = {
|
|
839
|
-
"--rows": rows,
|
|
840
|
-
"--columns": columns,
|
|
841
|
-
"--gap": gap + "px",
|
|
842
|
-
"--row-size": rowSize + "px",
|
|
843
|
-
"--col-size": "calc((var(--grid-size) - calc(var(--columns) - 1) * var(--gap)) / var(--columns))",
|
|
844
|
-
"--max-height": rows * rowSize + gap * (rowSize - 1) + "px",
|
|
845
|
-
"--content-active": active === wvId ? "grid" : "none"
|
|
846
|
-
};
|
|
847
|
-
return /* @__PURE__ */ React18.createElement("div", {
|
|
848
|
-
ref,
|
|
849
|
-
...rest,
|
|
850
|
-
style
|
|
851
|
-
}, React18.Children.count(children) > 0 ? children : /* @__PURE__ */ React18.createElement(Placeholder_default, {
|
|
852
|
-
element: "Tab Content"
|
|
853
|
-
}, "Drag and drop an element here."));
|
|
854
|
-
}
|
|
855
|
-
);
|
|
856
|
-
var css14 = {
|
|
857
|
-
"@desktop": {
|
|
858
|
-
width: "100%",
|
|
859
|
-
maxWidth: "var(--grid-size)",
|
|
860
|
-
display: "var(--content-active, none)",
|
|
861
|
-
gridTemplateRows: "repeat(var(--rows), var(--row-size))",
|
|
862
|
-
gridTemplateColumns: "repeat(var(--columns), minmax(0, var(--col-size)))",
|
|
863
|
-
gap: "var(--gap)",
|
|
864
|
-
borderRadius: 4
|
|
865
|
-
}
|
|
866
|
-
};
|
|
867
|
-
TabContent.defaultProps = {
|
|
868
|
-
rows: 3,
|
|
869
|
-
columns: 12,
|
|
870
|
-
gap: 4,
|
|
871
|
-
rowSize: 48,
|
|
872
|
-
name: "Tab header"
|
|
873
|
-
};
|
|
874
|
-
var TabContent_default = TabContent;
|
|
875
|
-
|
|
876
|
-
// src/elements/slider/index.tsx
|
|
877
|
-
import React19, { forwardRef as forwardRef15, useContext as useContext7 } from "react";
|
|
878
|
-
import { Carousel } from "nuka-carousel/lib/carousel";
|
|
879
|
-
var Slider = forwardRef15((props, ref) => {
|
|
880
|
-
const { isDesignMode } = useContext7(WeaverseContext);
|
|
881
|
-
const { autoplay, delay, children, ...rest } = props;
|
|
882
|
-
return /* @__PURE__ */ React19.createElement("div", {
|
|
883
|
-
...rest,
|
|
884
|
-
ref
|
|
885
|
-
}, /* @__PURE__ */ React19.createElement(Carousel, {
|
|
886
|
-
dragging: false,
|
|
887
|
-
renderCenterLeftControls: (props2) => /* @__PURE__ */ React19.createElement("button", {
|
|
888
|
-
className: "wv-slider-btn",
|
|
889
|
-
onClick: props2.previousSlide,
|
|
890
|
-
disabled: (isDesignMode || !autoplay) && props2.currentSlide === 0
|
|
891
|
-
}, /* @__PURE__ */ React19.createElement("i", {
|
|
892
|
-
className: "wv-slider-arrow wv-slider-arrow-left"
|
|
893
|
-
})),
|
|
894
|
-
renderCenterRightControls: (props2) => /* @__PURE__ */ React19.createElement("button", {
|
|
895
|
-
className: "wv-slider-btn",
|
|
896
|
-
onClick: props2.nextSlide,
|
|
897
|
-
disabled: (isDesignMode || !autoplay) && props2.slideCount === props2.currentSlide
|
|
898
|
-
}, /* @__PURE__ */ React19.createElement("i", {
|
|
899
|
-
className: "wv-slider-arrow wv-slider-arrow-right"
|
|
900
|
-
})),
|
|
901
|
-
wrapAround: !isDesignMode,
|
|
902
|
-
autoplay: !isDesignMode && autoplay,
|
|
903
|
-
autoplayInterval: delay * 1e3
|
|
904
|
-
}, children));
|
|
905
|
-
});
|
|
906
|
-
var css15 = {
|
|
907
|
-
"@desktop": {
|
|
908
|
-
"& .wv-slider-btn": {
|
|
909
|
-
borderRadius: "100%",
|
|
910
|
-
width: 40,
|
|
911
|
-
height: 40,
|
|
912
|
-
background: "#fff",
|
|
913
|
-
border: "none",
|
|
914
|
-
cursor: "pointer",
|
|
915
|
-
"&[disabled]": {
|
|
916
|
-
cursor: "not-allowed"
|
|
917
|
-
},
|
|
918
|
-
"&:hover .wv-slider-arrow": {
|
|
919
|
-
borderColor: "#999"
|
|
920
|
-
},
|
|
921
|
-
"& .wv-slider-arrow": {
|
|
922
|
-
border: "solid black",
|
|
923
|
-
borderWidth: "0 1px 1px 0",
|
|
924
|
-
display: "inline-block",
|
|
925
|
-
padding: 5
|
|
926
|
-
},
|
|
927
|
-
"& .wv-slider-arrow-right": {
|
|
928
|
-
transform: "rotate(-45deg)",
|
|
929
|
-
marginRight: 5
|
|
930
|
-
},
|
|
931
|
-
"& .wv-slider-arrow-left": {
|
|
932
|
-
transform: "rotate(135deg)",
|
|
933
|
-
marginLeft: 5
|
|
934
|
-
}
|
|
935
|
-
}
|
|
936
|
-
}
|
|
937
|
-
};
|
|
938
|
-
Slider.defaultProps = {
|
|
939
|
-
fullWidth: true,
|
|
940
|
-
autoplay: true,
|
|
941
|
-
delay: 3
|
|
942
|
-
};
|
|
943
|
-
var slider_default = Slider;
|
|
944
|
-
|
|
945
|
-
// src/elements/slider/SliderContent.tsx
|
|
946
|
-
import React20, { forwardRef as forwardRef16, useContext as useContext8 } from "react";
|
|
947
|
-
var SliderContent = forwardRef16(
|
|
948
|
-
(props, ref) => {
|
|
949
|
-
const { isDesignMode } = useContext8(WeaverseContext);
|
|
950
|
-
const {
|
|
951
|
-
mediaUrl,
|
|
952
|
-
targetLink,
|
|
953
|
-
openInNewTab,
|
|
954
|
-
rows,
|
|
955
|
-
columns,
|
|
956
|
-
gap,
|
|
957
|
-
rowSize,
|
|
958
|
-
children,
|
|
959
|
-
...rest
|
|
960
|
-
} = props;
|
|
961
|
-
let style = {
|
|
962
|
-
"--rows": rows,
|
|
963
|
-
"--columns": columns,
|
|
964
|
-
"--gap": gap + "px",
|
|
965
|
-
"--row-size": rowSize + "px",
|
|
966
|
-
"--col-size": "calc((var(--grid-size) - calc(var(--columns) - 1) * var(--gap)) / var(--columns))",
|
|
967
|
-
"--max-height": rows * rowSize + gap * (rowSize - 1) + "px",
|
|
968
|
-
"--background-url": `url(${mediaUrl}`
|
|
969
|
-
};
|
|
970
|
-
const handleClick = () => {
|
|
971
|
-
if (!isDesignMode && targetLink) {
|
|
972
|
-
window.open(targetLink, openInNewTab ? "_blank" : "_self");
|
|
973
|
-
}
|
|
974
|
-
};
|
|
975
|
-
return /* @__PURE__ */ React20.createElement("div", {
|
|
976
|
-
...rest,
|
|
977
|
-
style,
|
|
978
|
-
onClick: handleClick
|
|
979
|
-
}, React20.Children.count(children) > 0 ? children : /* @__PURE__ */ React20.createElement(Placeholder_default, {
|
|
980
|
-
element: "Slider Content"
|
|
981
|
-
}, "Drag and drop an element here."));
|
|
982
|
-
}
|
|
983
|
-
);
|
|
984
|
-
var css16 = {
|
|
985
|
-
"@desktop": {
|
|
986
|
-
width: "100%",
|
|
987
|
-
maxWidth: "var(--grid-size)",
|
|
988
|
-
display: "grid",
|
|
989
|
-
gridTemplateRows: "repeat(var(--rows), var(--row-size))",
|
|
990
|
-
gridTemplateColumns: "repeat(var(--columns), minmax(0, var(--col-size)))",
|
|
991
|
-
gap: "var(--gap)",
|
|
992
|
-
borderRadius: 4,
|
|
993
|
-
backgroundImage: "var(--background-url, none)"
|
|
994
|
-
}
|
|
995
|
-
};
|
|
996
|
-
SliderContent.defaultProps = {
|
|
997
|
-
name: "Slider",
|
|
998
|
-
mediaUrl: "",
|
|
999
|
-
openInNewTab: false,
|
|
1000
|
-
targetLink: "https://myshop.com",
|
|
1001
|
-
rows: 4,
|
|
1002
|
-
columns: 12,
|
|
1003
|
-
gap: 4,
|
|
1004
|
-
rowSize: 48
|
|
1005
|
-
};
|
|
1006
|
-
var SliderContent_default = SliderContent;
|
|
1007
|
-
|
|
1008
549
|
// src/elements/index.ts
|
|
1009
550
|
var SharedComponents = {
|
|
1010
551
|
Placeholder: Placeholder_default
|
|
@@ -1038,7 +579,8 @@ var Elements = {
|
|
|
1038
579
|
Layout: {
|
|
1039
580
|
Component: layout_default,
|
|
1040
581
|
type: "layout",
|
|
1041
|
-
defaultCss: css5
|
|
582
|
+
defaultCss: css5,
|
|
583
|
+
permanentCss
|
|
1042
584
|
},
|
|
1043
585
|
Map: {
|
|
1044
586
|
Component: map_default,
|
|
@@ -1054,59 +596,24 @@ var Elements = {
|
|
|
1054
596
|
Component: video_default,
|
|
1055
597
|
type: "video",
|
|
1056
598
|
defaultCss: css8
|
|
1057
|
-
},
|
|
1058
|
-
Accordion: {
|
|
1059
|
-
Component: accordion_default,
|
|
1060
|
-
type: "accordion",
|
|
1061
|
-
defaultCss: css10
|
|
1062
|
-
},
|
|
1063
|
-
AccordionWrapper: {
|
|
1064
|
-
Component: AccordionWrapper_default,
|
|
1065
|
-
type: "accordion.wrapper",
|
|
1066
|
-
defaultCss: css11
|
|
1067
|
-
},
|
|
1068
|
-
AccordionContent: {
|
|
1069
|
-
Component: AccordionContent_default,
|
|
1070
|
-
type: "accordion.content",
|
|
1071
|
-
defaultCss: css12
|
|
1072
|
-
},
|
|
1073
|
-
Tab: {
|
|
1074
|
-
Component: tab_default,
|
|
1075
|
-
type: "tab",
|
|
1076
|
-
defaultCss: css13
|
|
1077
|
-
},
|
|
1078
|
-
TabContent: {
|
|
1079
|
-
Component: TabContent_default,
|
|
1080
|
-
type: "tab.content",
|
|
1081
|
-
defaultCss: css14
|
|
1082
|
-
},
|
|
1083
|
-
Slider: {
|
|
1084
|
-
Component: slider_default,
|
|
1085
|
-
type: "slider",
|
|
1086
|
-
defaultCss: css15
|
|
1087
|
-
},
|
|
1088
|
-
SliderContent: {
|
|
1089
|
-
Component: SliderContent_default,
|
|
1090
|
-
type: "slider.content",
|
|
1091
|
-
defaultCss: css16
|
|
1092
599
|
}
|
|
1093
600
|
};
|
|
1094
601
|
|
|
1095
602
|
// src/renderer.tsx
|
|
1096
|
-
import { isBrowser
|
|
1097
|
-
import
|
|
603
|
+
import { isBrowser } from "@weaverse/core";
|
|
604
|
+
import React12, { useContext as useContext3, useEffect as useEffect3, useRef, useState as useState2 } from "react";
|
|
1098
605
|
|
|
1099
606
|
// src/utils/index.ts
|
|
1100
|
-
function shortCssObject(
|
|
607
|
+
function shortCssObject(css10) {
|
|
1101
608
|
return {
|
|
1102
|
-
"@desktop":
|
|
1103
|
-
"@mobile":
|
|
609
|
+
"@desktop": css10["@desktop"],
|
|
610
|
+
"@mobile": css10["@mobile"]
|
|
1104
611
|
};
|
|
1105
612
|
}
|
|
1106
613
|
var permanentClasses = {};
|
|
1107
614
|
function generateItemClass(instance, stitchesInstance) {
|
|
1108
615
|
var _a, _b;
|
|
1109
|
-
let { css:
|
|
616
|
+
let { css: css10, type, className: cls = "" } = instance.data;
|
|
1110
617
|
let className = "";
|
|
1111
618
|
let permanentClass = "";
|
|
1112
619
|
let perCss = (_a = instance.Element) == null ? void 0 : _a.permanentCss;
|
|
@@ -1120,8 +627,8 @@ function generateItemClass(instance, stitchesInstance) {
|
|
|
1120
627
|
}
|
|
1121
628
|
}
|
|
1122
629
|
className = permanentClass;
|
|
1123
|
-
if (
|
|
1124
|
-
let formattedCss = shortCssObject(
|
|
630
|
+
if (css10) {
|
|
631
|
+
let formattedCss = shortCssObject(css10);
|
|
1125
632
|
let { className: newClass = "" } = stitchesInstance.css(formattedCss)();
|
|
1126
633
|
let { stitchesClass } = instance;
|
|
1127
634
|
let otherClass = (((_b = instance.ref.current) == null ? void 0 : _b.className) || "").replace(stitchesClass, "").replace(cls, "").replace(permanentClass, "").trim();
|
|
@@ -1134,41 +641,44 @@ function generateItemClass(instance, stitchesInstance) {
|
|
|
1134
641
|
// src/renderer.tsx
|
|
1135
642
|
var WeaverseRoot = ({ context }) => {
|
|
1136
643
|
var _a, _b;
|
|
1137
|
-
let [, setData] =
|
|
644
|
+
let [, setData] = useState2(context.projectData);
|
|
1138
645
|
let rootRef = useRef();
|
|
1139
|
-
let
|
|
1140
|
-
|
|
1141
|
-
context.subscribe(
|
|
646
|
+
let renderRoot = () => setData({});
|
|
647
|
+
useEffect3(() => {
|
|
648
|
+
context.subscribe(renderRoot);
|
|
1142
649
|
context.contentRootElement = rootRef.current;
|
|
1143
650
|
return () => {
|
|
1144
|
-
context.unsubscribe(
|
|
651
|
+
context.unsubscribe(renderRoot);
|
|
1145
652
|
};
|
|
1146
653
|
}, []);
|
|
1147
654
|
let eventHandlers = ((_a = context == null ? void 0 : context.studioBridge) == null ? void 0 : _a.eventHandlers) || {};
|
|
1148
655
|
let themeClass = context.stitchesInstance.theme.className;
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
656
|
+
if ((_b = context.projectData) == null ? void 0 : _b.rootId) {
|
|
657
|
+
return /* @__PURE__ */ React12.createElement("div", {
|
|
658
|
+
className: `weaverse-content-root ${themeClass}`,
|
|
659
|
+
...eventHandlers,
|
|
660
|
+
ref: rootRef
|
|
661
|
+
}, /* @__PURE__ */ React12.createElement(WeaverseContextProvider, {
|
|
662
|
+
value: context
|
|
663
|
+
}, /* @__PURE__ */ React12.createElement(ItemInstance, {
|
|
664
|
+
id: context.projectData.rootId
|
|
665
|
+
})));
|
|
666
|
+
}
|
|
667
|
+
return null;
|
|
1158
668
|
};
|
|
1159
669
|
var ItemComponent = ({ instance }) => {
|
|
1160
|
-
let { stitchesInstance, elementInstances } =
|
|
1161
|
-
let [data, setData] =
|
|
1162
|
-
let { id, type, childIds = [], css:
|
|
1163
|
-
|
|
1164
|
-
let
|
|
1165
|
-
instance.subscribe(
|
|
1166
|
-
if (
|
|
670
|
+
let { stitchesInstance, elementInstances } = useContext3(WeaverseContext);
|
|
671
|
+
let [data, setData] = useState2(instance.data);
|
|
672
|
+
let { id, type, childIds = [], css: css10, className, ...rest } = data;
|
|
673
|
+
useEffect3(() => {
|
|
674
|
+
let render = (data2) => setData({ ...data2 });
|
|
675
|
+
instance.subscribe(render);
|
|
676
|
+
if (isBrowser && !instance.ref.current) {
|
|
1167
677
|
Object.assign(instance.ref, {
|
|
1168
678
|
current: document.querySelector(`[data-wv-id="${id}"]`)
|
|
1169
679
|
});
|
|
1170
680
|
}
|
|
1171
|
-
return () => instance.unsubscribe(
|
|
681
|
+
return () => instance.unsubscribe(render);
|
|
1172
682
|
}, []);
|
|
1173
683
|
let Element = elementInstances.get(type);
|
|
1174
684
|
if (Element == null ? void 0 : Element.Component) {
|
|
@@ -1176,29 +686,31 @@ var ItemComponent = ({ instance }) => {
|
|
|
1176
686
|
if (Component.$$typeof === Symbol.for("react.forward_ref")) {
|
|
1177
687
|
rest.ref = instance.ref;
|
|
1178
688
|
}
|
|
1179
|
-
return /* @__PURE__ */
|
|
689
|
+
return /* @__PURE__ */ React12.createElement(Component, {
|
|
1180
690
|
key: id,
|
|
1181
691
|
"data-wv-type": type,
|
|
1182
692
|
"data-wv-id": id,
|
|
1183
693
|
className: generateItemClass(instance, stitchesInstance),
|
|
1184
694
|
...rest
|
|
1185
|
-
}, childIds.map((id2) => /* @__PURE__ */
|
|
695
|
+
}, childIds.map((id2) => /* @__PURE__ */ React12.createElement(ItemInstance, {
|
|
1186
696
|
key: id2,
|
|
1187
697
|
id: id2
|
|
1188
698
|
})));
|
|
699
|
+
} else {
|
|
700
|
+
console.log(`Unknown element: ${type}`);
|
|
701
|
+
return null;
|
|
1189
702
|
}
|
|
1190
|
-
return null;
|
|
1191
703
|
};
|
|
1192
704
|
var ItemInstance = ({ id }) => {
|
|
1193
|
-
let context =
|
|
705
|
+
let context = useContext3(WeaverseContext);
|
|
1194
706
|
let { itemInstances } = context;
|
|
1195
707
|
let instance = itemInstances.get(id);
|
|
1196
708
|
if (!instance) {
|
|
1197
|
-
return /* @__PURE__ */
|
|
709
|
+
return /* @__PURE__ */ React12.createElement("div", {
|
|
1198
710
|
style: { display: "none" }
|
|
1199
711
|
}, "Item instance ", id, " not found");
|
|
1200
712
|
}
|
|
1201
|
-
return /* @__PURE__ */
|
|
713
|
+
return /* @__PURE__ */ React12.createElement(ItemComponent, {
|
|
1202
714
|
instance
|
|
1203
715
|
});
|
|
1204
716
|
};
|