@weaverse/react 0.7.5 → 0.7.8
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 +9 -5
- package/dist/index.js +343 -186
- package/dist/index.mjs +331 -178
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// src/context.ts
|
|
2
2
|
import { Weaverse } from "@weaverse/core";
|
|
3
|
-
import { createContext as
|
|
3
|
+
import { createContext as createContext3 } from "react";
|
|
4
4
|
|
|
5
5
|
// src/elements/button.tsx
|
|
6
6
|
import * as React from "react";
|
|
@@ -220,7 +220,7 @@ var Image = React5.forwardRef(
|
|
|
220
220
|
}
|
|
221
221
|
);
|
|
222
222
|
Image.defaultProps = {
|
|
223
|
-
src: "https://ucarecdn.com/
|
|
223
|
+
src: "https://ucarecdn.com/c413b8fe-ceec-4948-9c42-a0434c4ca920/",
|
|
224
224
|
alt: "Image alt text",
|
|
225
225
|
objectFit: "cover",
|
|
226
226
|
objectPosition: "center",
|
|
@@ -390,20 +390,9 @@ import React10, { forwardRef as forwardRef8 } from "react";
|
|
|
390
390
|
var Placeholder = forwardRef8(
|
|
391
391
|
(props, ref) => {
|
|
392
392
|
let { element, children, ...rest } = props;
|
|
393
|
-
let style = {
|
|
394
|
-
position: "absolute",
|
|
395
|
-
height: "100%",
|
|
396
|
-
width: "100%",
|
|
397
|
-
display: "flex",
|
|
398
|
-
flexDirection: "column",
|
|
399
|
-
alignItems: "center",
|
|
400
|
-
justifyContent: "center",
|
|
401
|
-
color: "#374151",
|
|
402
|
-
pointerEvents: "none",
|
|
403
|
-
zIndex: 1
|
|
404
|
-
};
|
|
405
393
|
return /* @__PURE__ */ React10.createElement("div", {
|
|
406
|
-
|
|
394
|
+
"data-wv-type": "placeholder",
|
|
395
|
+
style: { display: "none" },
|
|
407
396
|
ref,
|
|
408
397
|
...rest
|
|
409
398
|
}, /* @__PURE__ */ React10.createElement("div", {
|
|
@@ -498,108 +487,190 @@ var instagram_default = Instagram;
|
|
|
498
487
|
// src/elements/accordion/index.tsx
|
|
499
488
|
import React12, { createContext, forwardRef as forwardRef10, useState as useState2 } from "react";
|
|
500
489
|
var AccordionContext = createContext({
|
|
501
|
-
|
|
490
|
+
iconName: "arrow",
|
|
491
|
+
active: [],
|
|
502
492
|
setActive: () => {
|
|
503
493
|
}
|
|
504
494
|
});
|
|
505
495
|
var Accordion = forwardRef10(
|
|
506
496
|
(props, ref) => {
|
|
507
|
-
const {
|
|
508
|
-
const [active, setActive] = useState2(
|
|
497
|
+
const { iconName, children, ...rest } = props;
|
|
498
|
+
const [active, setActive] = useState2([]);
|
|
509
499
|
const setOpenAccordion = (id) => {
|
|
510
|
-
if (id
|
|
511
|
-
setActive(
|
|
500
|
+
if (active.includes(id)) {
|
|
501
|
+
setActive(active.filter((_id) => _id !== id));
|
|
512
502
|
} else {
|
|
513
|
-
setActive(id);
|
|
503
|
+
setActive([...active, id]);
|
|
514
504
|
}
|
|
515
505
|
};
|
|
516
506
|
return /* @__PURE__ */ React12.createElement("div", {
|
|
517
507
|
ref,
|
|
518
508
|
...rest
|
|
519
509
|
}, /* @__PURE__ */ React12.createElement(AccordionContext.Provider, {
|
|
520
|
-
value: { active, setActive: setOpenAccordion }
|
|
510
|
+
value: { active, setActive: setOpenAccordion, iconName }
|
|
521
511
|
}, children));
|
|
522
512
|
}
|
|
523
513
|
);
|
|
524
514
|
Accordion.defaultProps = {
|
|
525
|
-
|
|
526
|
-
{
|
|
527
|
-
id: 1,
|
|
528
|
-
headerText: "Header 1",
|
|
529
|
-
childrenId: true
|
|
530
|
-
},
|
|
531
|
-
{
|
|
532
|
-
id: 2,
|
|
533
|
-
headerText: "Header 2"
|
|
534
|
-
}
|
|
535
|
-
],
|
|
515
|
+
iconName: "arrow",
|
|
536
516
|
css: {
|
|
537
517
|
"@desktop": {
|
|
538
518
|
display: "flex",
|
|
539
519
|
flexDirection: "column",
|
|
540
|
-
gap: 4
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
520
|
+
gap: 4
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
};
|
|
524
|
+
var accordion_default = Accordion;
|
|
525
|
+
|
|
526
|
+
// src/elements/accordion/AccordionWrapper.tsx
|
|
527
|
+
import React14, { forwardRef as forwardRef11, useContext as useContext5 } from "react";
|
|
528
|
+
|
|
529
|
+
// src/elements/accordion/Icon.tsx
|
|
530
|
+
import React13, { useContext as useContext4 } from "react";
|
|
531
|
+
var ICONS = {
|
|
532
|
+
caret: {
|
|
533
|
+
animationType: "rotate90",
|
|
534
|
+
css: {
|
|
535
|
+
position: "absolute!important",
|
|
536
|
+
left: 5,
|
|
537
|
+
top: 2,
|
|
538
|
+
width: 0,
|
|
539
|
+
height: 0,
|
|
540
|
+
borderTop: "6px solid transparent",
|
|
541
|
+
borderBottom: "6px solid transparent",
|
|
542
|
+
borderLeft: "6px solid #1F2A37"
|
|
543
|
+
}
|
|
544
|
+
},
|
|
545
|
+
arrow: {
|
|
546
|
+
animationType: "rotate90",
|
|
547
|
+
css: {
|
|
548
|
+
border: "solid #1F2A37",
|
|
549
|
+
borderWidth: "0 1px 1px 0",
|
|
550
|
+
display: "inline-block",
|
|
551
|
+
transform: "rotate(-45deg) translate(15%, -15%)",
|
|
552
|
+
padding: 4
|
|
553
|
+
}
|
|
554
|
+
},
|
|
555
|
+
plus: {
|
|
556
|
+
animationType: "custom",
|
|
557
|
+
css: {
|
|
558
|
+
display: "inline-block",
|
|
559
|
+
top: -6,
|
|
560
|
+
width: 15,
|
|
561
|
+
height: 1,
|
|
562
|
+
backgroundColor: "#1F2A37",
|
|
563
|
+
"&:after": {
|
|
564
|
+
position: "absolute",
|
|
565
|
+
content: "",
|
|
566
|
+
top: -7,
|
|
567
|
+
left: 7,
|
|
568
|
+
width: 1,
|
|
569
|
+
height: 15,
|
|
570
|
+
backgroundColor: "#1F2A37",
|
|
571
|
+
transition: "all 0.3s ease-in-out 0s"
|
|
572
|
+
},
|
|
573
|
+
"&.active": {
|
|
574
|
+
"&:after": {
|
|
575
|
+
transform: "rotate(90deg)"
|
|
551
576
|
}
|
|
552
577
|
}
|
|
553
578
|
}
|
|
554
579
|
}
|
|
555
580
|
};
|
|
556
|
-
var
|
|
581
|
+
var rotateAnimation = {
|
|
582
|
+
transition: "all 0.3s ease-in-out 0s",
|
|
583
|
+
transform: "rotate(90deg)"
|
|
584
|
+
};
|
|
585
|
+
function Icon(props) {
|
|
586
|
+
let { name, active = false, style, ...rest } = props;
|
|
587
|
+
let { stitchesInstance } = useContext4(WeaverseContext);
|
|
588
|
+
const { animationType, css } = ICONS[name];
|
|
589
|
+
if (active && animationType === "rotate90") {
|
|
590
|
+
style = { ...rotateAnimation, ...style };
|
|
591
|
+
}
|
|
592
|
+
let { className } = stitchesInstance.css(css)();
|
|
593
|
+
if (active)
|
|
594
|
+
className += " active";
|
|
595
|
+
return /* @__PURE__ */ React13.createElement("span", {
|
|
596
|
+
style,
|
|
597
|
+
...rest
|
|
598
|
+
}, /* @__PURE__ */ React13.createElement("i", {
|
|
599
|
+
className
|
|
600
|
+
}));
|
|
601
|
+
}
|
|
602
|
+
var Icon_default = Icon;
|
|
557
603
|
|
|
558
604
|
// src/elements/accordion/AccordionWrapper.tsx
|
|
559
|
-
import React13, { forwardRef as forwardRef11, useContext as useContext4 } from "react";
|
|
560
605
|
var AccordionWrapper = forwardRef11((props, ref) => {
|
|
561
|
-
const { ["data-wv-id"]: wvId,
|
|
562
|
-
const { active, setActive } =
|
|
563
|
-
|
|
606
|
+
const { ["data-wv-id"]: wvId, name, children, ...rest } = props;
|
|
607
|
+
const { iconName, active, setActive } = useContext5(AccordionContext);
|
|
608
|
+
const isActive = active.includes(wvId);
|
|
609
|
+
return /* @__PURE__ */ React14.createElement("div", {
|
|
564
610
|
ref,
|
|
565
611
|
...rest
|
|
566
|
-
}, /* @__PURE__ */
|
|
612
|
+
}, /* @__PURE__ */ React14.createElement("div", {
|
|
567
613
|
onClick: () => setActive(wvId),
|
|
568
|
-
className: `wv-
|
|
569
|
-
},
|
|
614
|
+
className: `wv-acc-header ${isActive ? "active" : ""}`
|
|
615
|
+
}, /* @__PURE__ */ React14.createElement("span", null, name), /* @__PURE__ */ React14.createElement(Icon_default, {
|
|
616
|
+
className: "wv-acc-icon",
|
|
617
|
+
active: isActive,
|
|
618
|
+
name: iconName
|
|
619
|
+
})), children);
|
|
570
620
|
});
|
|
571
621
|
AccordionWrapper.defaultProps = {
|
|
572
|
-
|
|
622
|
+
name: "Accordion item",
|
|
573
623
|
css: {
|
|
574
624
|
"@desktop": {
|
|
575
|
-
maxHeight: "100%"
|
|
625
|
+
maxHeight: "100%",
|
|
626
|
+
".wv-acc-icon": {
|
|
627
|
+
position: "absolute",
|
|
628
|
+
right: 16,
|
|
629
|
+
width: 16,
|
|
630
|
+
height: 16,
|
|
631
|
+
transition: "all 0.3s ease-in-out 0s"
|
|
632
|
+
},
|
|
633
|
+
".wv-acc-header": {
|
|
634
|
+
display: "flex",
|
|
635
|
+
alignItems: "center",
|
|
636
|
+
borderRadius: 4,
|
|
637
|
+
padding: 12,
|
|
638
|
+
marginBottom: 4,
|
|
639
|
+
border: "1px solid #76A9FA",
|
|
640
|
+
cursor: "pointer",
|
|
641
|
+
'&.active + [data-wv-type="accordion.content"]': {
|
|
642
|
+
maxHeight: "var(--max-height, inherit)"
|
|
643
|
+
}
|
|
644
|
+
}
|
|
576
645
|
}
|
|
577
646
|
}
|
|
578
647
|
};
|
|
579
648
|
var AccordionWrapper_default = AccordionWrapper;
|
|
580
649
|
|
|
581
650
|
// src/elements/accordion/AccordionContent.tsx
|
|
582
|
-
import
|
|
583
|
-
var AccordionContent = forwardRef12(
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
});
|
|
651
|
+
import React15, { forwardRef as forwardRef12 } from "react";
|
|
652
|
+
var AccordionContent = forwardRef12(
|
|
653
|
+
(props, ref) => {
|
|
654
|
+
const { rows, columns, gap, rowSize, children, ...rest } = props;
|
|
655
|
+
let style = {
|
|
656
|
+
"--rows": rows,
|
|
657
|
+
"--columns": columns,
|
|
658
|
+
"--gap": gap + "px",
|
|
659
|
+
"--row-size": rowSize + "px",
|
|
660
|
+
"--col-size": "calc((var(--grid-size) - calc(var(--columns) - 1) * var(--gap)) / var(--columns))",
|
|
661
|
+
"--max-height": rows * rowSize + gap * (rowSize - 1) + "px"
|
|
662
|
+
};
|
|
663
|
+
return /* @__PURE__ */ React15.createElement("div", {
|
|
664
|
+
ref,
|
|
665
|
+
...rest,
|
|
666
|
+
style
|
|
667
|
+
}, React15.Children.count(children) > 0 ? children : /* @__PURE__ */ React15.createElement(Placeholder_default, {
|
|
668
|
+
element: "Accordion Content"
|
|
669
|
+
}, "Please drag and drop an element here"));
|
|
670
|
+
}
|
|
671
|
+
);
|
|
601
672
|
AccordionContent.defaultProps = {
|
|
602
|
-
rows:
|
|
673
|
+
rows: 3,
|
|
603
674
|
columns: 12,
|
|
604
675
|
gap: 4,
|
|
605
676
|
rowSize: 48,
|
|
@@ -621,34 +692,33 @@ AccordionContent.defaultProps = {
|
|
|
621
692
|
var AccordionContent_default = AccordionContent;
|
|
622
693
|
|
|
623
694
|
// src/elements/tab/index.tsx
|
|
624
|
-
import
|
|
695
|
+
import React17, { createContext as createContext2, forwardRef as forwardRef13, useState as useState4 } from "react";
|
|
625
696
|
|
|
626
697
|
// src/elements/tab/TabHeaderWrapper.tsx
|
|
627
|
-
import
|
|
698
|
+
import React16, { useContext as useContext6, useEffect as useEffect3, useState as useState3 } from "react";
|
|
628
699
|
function TabHeader(props) {
|
|
629
700
|
const { wvId } = props;
|
|
630
|
-
const { active, setActive } =
|
|
631
|
-
const { itemInstances } =
|
|
701
|
+
const { active, setActive } = useContext6(TabContext);
|
|
702
|
+
const { itemInstances } = useContext6(WeaverseContext);
|
|
632
703
|
const instance = itemInstances.get(wvId);
|
|
633
704
|
let [data, setData] = useState3(instance.data);
|
|
634
705
|
useEffect3(() => {
|
|
635
706
|
let update = (data2) => setData({ ...data2 });
|
|
636
707
|
instance.subscribe(update);
|
|
637
708
|
}, []);
|
|
638
|
-
|
|
639
|
-
return /* @__PURE__ */ React15.createElement("div", {
|
|
709
|
+
return /* @__PURE__ */ React16.createElement("div", {
|
|
640
710
|
onClick: () => setActive(wvId),
|
|
641
711
|
className: `wv-tab-header${active === wvId ? " active" : ""}`
|
|
642
|
-
},
|
|
712
|
+
}, data.name);
|
|
643
713
|
}
|
|
644
714
|
function TabHeaderWrapper(props) {
|
|
645
|
-
const { itemInstances } =
|
|
715
|
+
const { itemInstances } = useContext6(WeaverseContext);
|
|
646
716
|
const instance = itemInstances.get(props.wvId);
|
|
647
717
|
const data = instance.data;
|
|
648
718
|
const childIds = data.childIds;
|
|
649
|
-
return /* @__PURE__ */
|
|
650
|
-
className: "wv-tab-
|
|
651
|
-
}, childIds.map((id) => /* @__PURE__ */
|
|
719
|
+
return /* @__PURE__ */ React16.createElement("div", {
|
|
720
|
+
className: "wv-tab-header-wrapper"
|
|
721
|
+
}, childIds.map((id) => /* @__PURE__ */ React16.createElement(TabHeader, {
|
|
652
722
|
key: id,
|
|
653
723
|
wvId: id
|
|
654
724
|
})));
|
|
@@ -663,54 +733,47 @@ var TabContext = createContext2({
|
|
|
663
733
|
var Tab = forwardRef13((props, ref) => {
|
|
664
734
|
var _a, _b, _c;
|
|
665
735
|
const wvId = props["data-wv-id"];
|
|
666
|
-
const {
|
|
667
|
-
const defaultActive = (_c = (_b = (_a =
|
|
736
|
+
const { fullWidthTabHeader, children, ...rest } = props;
|
|
737
|
+
const defaultActive = (_c = (_b = (_a = React17.Children.toArray(children)) == null ? void 0 : _a[0]) == null ? void 0 : _b.props) == null ? void 0 : _c.id;
|
|
668
738
|
const [active, setActive] = useState4(defaultActive);
|
|
669
739
|
const setOpenTab = (id) => {
|
|
670
|
-
if (id
|
|
671
|
-
setActive(null);
|
|
672
|
-
} else {
|
|
740
|
+
if (id !== active) {
|
|
673
741
|
setActive(id);
|
|
674
742
|
}
|
|
675
743
|
};
|
|
676
|
-
return /* @__PURE__ */
|
|
744
|
+
return /* @__PURE__ */ React17.createElement("div", {
|
|
677
745
|
ref,
|
|
678
|
-
...rest
|
|
679
|
-
|
|
746
|
+
...rest,
|
|
747
|
+
style: {
|
|
748
|
+
"--tab-width": fullWidthTabHeader ? "100%" : "auto"
|
|
749
|
+
}
|
|
750
|
+
}, /* @__PURE__ */ React17.createElement(TabContext.Provider, {
|
|
680
751
|
value: { active, setActive: setOpenTab }
|
|
681
|
-
}, /* @__PURE__ */
|
|
752
|
+
}, /* @__PURE__ */ React17.createElement(TabHeaderWrapper, {
|
|
682
753
|
wvId
|
|
683
754
|
}), children));
|
|
684
755
|
});
|
|
685
756
|
Tab.defaultProps = {
|
|
686
|
-
|
|
687
|
-
{
|
|
688
|
-
headerText: "Header 1"
|
|
689
|
-
},
|
|
690
|
-
{
|
|
691
|
-
headerText: "Header 2"
|
|
692
|
-
},
|
|
693
|
-
{
|
|
694
|
-
headerText: "Header 2"
|
|
695
|
-
}
|
|
696
|
-
],
|
|
757
|
+
fullWidthTabHeader: false,
|
|
697
758
|
css: {
|
|
698
759
|
"@desktop": {
|
|
699
760
|
display: "flex",
|
|
700
761
|
flexDirection: "column",
|
|
701
762
|
gap: 4,
|
|
702
|
-
"& .wv-tab-
|
|
763
|
+
"& .wv-tab-header-wrapper": {
|
|
703
764
|
width: "100%",
|
|
704
765
|
display: "flex",
|
|
705
766
|
marginBottom: 10
|
|
706
767
|
},
|
|
707
768
|
"& .wv-tab-header": {
|
|
708
|
-
backgroundColor: "#
|
|
709
|
-
padding: "
|
|
769
|
+
backgroundColor: "#fff",
|
|
770
|
+
padding: "15px 24px",
|
|
771
|
+
border: "1px solid #E4E7EB",
|
|
710
772
|
cursor: "pointer",
|
|
773
|
+
textAlign: "center",
|
|
774
|
+
width: "var(--tab-width, auto)",
|
|
711
775
|
"&.active": {
|
|
712
|
-
backgroundColor: "#
|
|
713
|
-
color: "#fff"
|
|
776
|
+
backgroundColor: "#E4E7EB"
|
|
714
777
|
}
|
|
715
778
|
}
|
|
716
779
|
}
|
|
@@ -719,10 +782,10 @@ Tab.defaultProps = {
|
|
|
719
782
|
var tab_default = Tab;
|
|
720
783
|
|
|
721
784
|
// src/elements/tab/TabContent.tsx
|
|
722
|
-
import
|
|
785
|
+
import React18, { forwardRef as forwardRef14, useContext as useContext7 } from "react";
|
|
723
786
|
var TabContent = forwardRef14(
|
|
724
787
|
(props, ref) => {
|
|
725
|
-
const { active } =
|
|
788
|
+
const { active } = useContext7(TabContext);
|
|
726
789
|
const wvId = props["data-wv-id"];
|
|
727
790
|
const { rows, columns, gap, rowSize, children, ...rest } = props;
|
|
728
791
|
let style = {
|
|
@@ -734,20 +797,21 @@ var TabContent = forwardRef14(
|
|
|
734
797
|
"--max-height": rows * rowSize + gap * (rowSize - 1) + "px",
|
|
735
798
|
"--content-active": active === wvId ? "grid" : "none"
|
|
736
799
|
};
|
|
737
|
-
return /* @__PURE__ */
|
|
800
|
+
return /* @__PURE__ */ React18.createElement("div", {
|
|
738
801
|
ref,
|
|
739
802
|
...rest,
|
|
740
803
|
style
|
|
741
|
-
},
|
|
742
|
-
element: "Tab"
|
|
743
|
-
}, "
|
|
804
|
+
}, React18.Children.count(children) > 0 ? children : /* @__PURE__ */ React18.createElement(Placeholder_default, {
|
|
805
|
+
element: "Tab Content"
|
|
806
|
+
}, "Please drag and drop an element here"));
|
|
744
807
|
}
|
|
745
808
|
);
|
|
746
809
|
TabContent.defaultProps = {
|
|
747
|
-
rows:
|
|
810
|
+
rows: 3,
|
|
748
811
|
columns: 12,
|
|
749
812
|
gap: 4,
|
|
750
813
|
rowSize: 48,
|
|
814
|
+
name: "Tab header",
|
|
751
815
|
css: {
|
|
752
816
|
"@desktop": {
|
|
753
817
|
width: "100%",
|
|
@@ -763,51 +827,90 @@ TabContent.defaultProps = {
|
|
|
763
827
|
var TabContent_default = TabContent;
|
|
764
828
|
|
|
765
829
|
// src/elements/slider/index.tsx
|
|
766
|
-
import
|
|
767
|
-
|
|
768
|
-
forwardRef as forwardRef15,
|
|
769
|
-
useState as useState5
|
|
770
|
-
} from "react";
|
|
771
|
-
import * as Carousel from "nuka-carousel";
|
|
772
|
-
var SliderContext = createContext3({
|
|
773
|
-
active: null,
|
|
774
|
-
setActive: () => {
|
|
775
|
-
}
|
|
776
|
-
});
|
|
830
|
+
import React19, { forwardRef as forwardRef15, useContext as useContext8 } from "react";
|
|
831
|
+
import { Carousel } from "nuka-carousel/lib/carousel";
|
|
777
832
|
var Slider = forwardRef15((props, ref) => {
|
|
778
|
-
|
|
779
|
-
const { children, ...rest } = props;
|
|
780
|
-
|
|
781
|
-
const [active, setActive] = useState5(defaultActive);
|
|
782
|
-
return /* @__PURE__ */ React18.createElement("div", {
|
|
833
|
+
const { isDesignMode } = useContext8(WeaverseContext);
|
|
834
|
+
const { autoplay, delay, children, ...rest } = props;
|
|
835
|
+
return /* @__PURE__ */ React19.createElement("div", {
|
|
783
836
|
...rest,
|
|
784
837
|
ref
|
|
785
|
-
}, /* @__PURE__ */
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
838
|
+
}, /* @__PURE__ */ React19.createElement(Carousel, {
|
|
839
|
+
dragging: false,
|
|
840
|
+
renderCenterLeftControls: (props2) => /* @__PURE__ */ React19.createElement("button", {
|
|
841
|
+
className: "wv-slider-btn",
|
|
842
|
+
onClick: props2.previousSlide,
|
|
843
|
+
disabled: (isDesignMode || !autoplay) && props2.currentSlide === 0
|
|
844
|
+
}, /* @__PURE__ */ React19.createElement("i", {
|
|
845
|
+
className: "wv-slider-arrow wv-slider-arrow-left"
|
|
846
|
+
})),
|
|
847
|
+
renderCenterRightControls: (props2) => /* @__PURE__ */ React19.createElement("button", {
|
|
848
|
+
className: "wv-slider-btn",
|
|
849
|
+
onClick: props2.nextSlide,
|
|
850
|
+
disabled: (isDesignMode || !autoplay) && props2.slideCount === props2.currentSlide
|
|
851
|
+
}, /* @__PURE__ */ React19.createElement("i", {
|
|
852
|
+
className: "wv-slider-arrow wv-slider-arrow-right"
|
|
853
|
+
})),
|
|
854
|
+
wrapAround: !isDesignMode,
|
|
855
|
+
autoplay: !isDesignMode && autoplay,
|
|
856
|
+
autoplayInterval: delay * 1e3
|
|
857
|
+
}, children));
|
|
796
858
|
});
|
|
797
859
|
Slider.defaultProps = {
|
|
860
|
+
fullWidth: true,
|
|
861
|
+
autoplay: true,
|
|
862
|
+
delay: 3,
|
|
798
863
|
css: {
|
|
799
|
-
"@desktop": {
|
|
864
|
+
"@desktop": {
|
|
865
|
+
"& .wv-slider-btn": {
|
|
866
|
+
borderRadius: "100%",
|
|
867
|
+
width: 40,
|
|
868
|
+
height: 40,
|
|
869
|
+
background: "#fff",
|
|
870
|
+
border: "none",
|
|
871
|
+
cursor: "pointer",
|
|
872
|
+
"&[disabled]": {
|
|
873
|
+
cursor: "not-allowed"
|
|
874
|
+
},
|
|
875
|
+
"&:hover .wv-slider-arrow": {
|
|
876
|
+
borderColor: "#999"
|
|
877
|
+
},
|
|
878
|
+
"& .wv-slider-arrow": {
|
|
879
|
+
border: "solid black",
|
|
880
|
+
borderWidth: "0 1px 1px 0",
|
|
881
|
+
display: "inline-block",
|
|
882
|
+
padding: 5
|
|
883
|
+
},
|
|
884
|
+
"& .wv-slider-arrow-right": {
|
|
885
|
+
transform: "rotate(-45deg)",
|
|
886
|
+
marginRight: 5
|
|
887
|
+
},
|
|
888
|
+
"& .wv-slider-arrow-left": {
|
|
889
|
+
transform: "rotate(135deg)",
|
|
890
|
+
marginLeft: 5
|
|
891
|
+
}
|
|
892
|
+
}
|
|
893
|
+
}
|
|
800
894
|
}
|
|
801
895
|
};
|
|
802
896
|
var slider_default = Slider;
|
|
803
897
|
|
|
804
898
|
// src/elements/slider/SliderContent.tsx
|
|
805
|
-
import
|
|
899
|
+
import React20, { forwardRef as forwardRef16, useContext as useContext9 } from "react";
|
|
806
900
|
var SliderContent = forwardRef16(
|
|
807
901
|
(props, ref) => {
|
|
808
|
-
const {
|
|
809
|
-
const
|
|
810
|
-
|
|
902
|
+
const { isDesignMode } = useContext9(WeaverseContext);
|
|
903
|
+
const {
|
|
904
|
+
mediaUrl,
|
|
905
|
+
targetLink,
|
|
906
|
+
openInNewTab,
|
|
907
|
+
rows,
|
|
908
|
+
columns,
|
|
909
|
+
gap,
|
|
910
|
+
rowSize,
|
|
911
|
+
children,
|
|
912
|
+
...rest
|
|
913
|
+
} = props;
|
|
811
914
|
let style = {
|
|
812
915
|
"--rows": rows,
|
|
813
916
|
"--columns": columns,
|
|
@@ -815,19 +918,28 @@ var SliderContent = forwardRef16(
|
|
|
815
918
|
"--row-size": rowSize + "px",
|
|
816
919
|
"--col-size": "calc((var(--grid-size) - calc(var(--columns) - 1) * var(--gap)) / var(--columns))",
|
|
817
920
|
"--max-height": rows * rowSize + gap * (rowSize - 1) + "px",
|
|
818
|
-
"--
|
|
921
|
+
"--background-url": `url(${mediaUrl}`
|
|
819
922
|
};
|
|
820
|
-
|
|
821
|
-
|
|
923
|
+
const handleClick = () => {
|
|
924
|
+
if (!isDesignMode && targetLink) {
|
|
925
|
+
window.open(targetLink, openInNewTab ? "_blank" : "_self");
|
|
926
|
+
}
|
|
927
|
+
};
|
|
928
|
+
return /* @__PURE__ */ React20.createElement("div", {
|
|
822
929
|
...rest,
|
|
823
|
-
style
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
930
|
+
style,
|
|
931
|
+
onClick: handleClick
|
|
932
|
+
}, React20.Children.count(children) > 0 ? children : /* @__PURE__ */ React20.createElement(Placeholder_default, {
|
|
933
|
+
element: "Slider Content"
|
|
934
|
+
}, "Please drag and drop an element here"));
|
|
827
935
|
}
|
|
828
936
|
);
|
|
829
937
|
SliderContent.defaultProps = {
|
|
830
|
-
|
|
938
|
+
name: "Slider",
|
|
939
|
+
mediaUrl: "",
|
|
940
|
+
openInNewTab: false,
|
|
941
|
+
targetLink: "https://myshop.com",
|
|
942
|
+
rows: 4,
|
|
831
943
|
columns: 12,
|
|
832
944
|
gap: 4,
|
|
833
945
|
rowSize: 48,
|
|
@@ -835,18 +947,56 @@ SliderContent.defaultProps = {
|
|
|
835
947
|
"@desktop": {
|
|
836
948
|
width: "100%",
|
|
837
949
|
maxWidth: "var(--grid-size)",
|
|
838
|
-
display: "
|
|
950
|
+
display: "grid",
|
|
839
951
|
gridTemplateRows: "repeat(var(--rows), var(--row-size))",
|
|
840
952
|
gridTemplateColumns: "repeat(var(--columns), minmax(0, var(--col-size)))",
|
|
841
953
|
gap: "var(--gap)",
|
|
842
|
-
borderRadius: 4
|
|
954
|
+
borderRadius: 4,
|
|
955
|
+
backgroundImage: "var(--background-url, none)"
|
|
843
956
|
}
|
|
844
957
|
}
|
|
845
958
|
};
|
|
846
959
|
var SliderContent_default = SliderContent;
|
|
847
960
|
|
|
961
|
+
// src/elements/custom-html.tsx
|
|
962
|
+
import React21, { forwardRef as forwardRef17, useContext as useContext10 } from "react";
|
|
963
|
+
var CustomHTML = forwardRef17(
|
|
964
|
+
(props, ref) => {
|
|
965
|
+
const { content, children, ...rest } = props;
|
|
966
|
+
const { isDesignMode } = useContext10(WeaverseContext);
|
|
967
|
+
const style = {
|
|
968
|
+
"--pointer-events": isDesignMode ? "none" : "auto"
|
|
969
|
+
};
|
|
970
|
+
if (!content)
|
|
971
|
+
return /* @__PURE__ */ React21.createElement("div", {
|
|
972
|
+
ref,
|
|
973
|
+
...rest
|
|
974
|
+
}, /* @__PURE__ */ React21.createElement(Placeholder_default, {
|
|
975
|
+
element: "Custom HTML"
|
|
976
|
+
}, "Please add your custom HTML codes."));
|
|
977
|
+
return /* @__PURE__ */ React21.createElement("div", {
|
|
978
|
+
ref,
|
|
979
|
+
...rest,
|
|
980
|
+
style,
|
|
981
|
+
dangerouslySetInnerHTML: { __html: content }
|
|
982
|
+
});
|
|
983
|
+
}
|
|
984
|
+
);
|
|
985
|
+
CustomHTML.defaultProps = {
|
|
986
|
+
content: "",
|
|
987
|
+
type: "custom.html",
|
|
988
|
+
css: {
|
|
989
|
+
"@desktop": {
|
|
990
|
+
"& > *": {
|
|
991
|
+
pointerEvents: "var(--pointer-events, unset)"
|
|
992
|
+
}
|
|
993
|
+
}
|
|
994
|
+
}
|
|
995
|
+
};
|
|
996
|
+
var custom_html_default = CustomHTML;
|
|
997
|
+
|
|
848
998
|
// src/elements/index.ts
|
|
849
|
-
var
|
|
999
|
+
var Elements = {
|
|
850
1000
|
Countdown: {
|
|
851
1001
|
Component: countdown_default,
|
|
852
1002
|
type: "countdown"
|
|
@@ -910,33 +1060,36 @@ var elements = {
|
|
|
910
1060
|
SliderContent: {
|
|
911
1061
|
Component: SliderContent_default,
|
|
912
1062
|
type: "slider.content"
|
|
1063
|
+
},
|
|
1064
|
+
CustomHTML: {
|
|
1065
|
+
Component: custom_html_default,
|
|
1066
|
+
type: "custom.html"
|
|
913
1067
|
}
|
|
914
1068
|
};
|
|
915
|
-
var elements_default = elements;
|
|
916
1069
|
|
|
917
1070
|
// src/context.ts
|
|
918
1071
|
var createRootContext = (configs) => {
|
|
919
1072
|
let rootContext = new Weaverse(configs);
|
|
920
|
-
Object.keys(
|
|
921
|
-
rootContext.registerElement(
|
|
1073
|
+
Object.keys(Elements).forEach((key) => {
|
|
1074
|
+
rootContext.registerElement(Elements[key]);
|
|
922
1075
|
});
|
|
923
1076
|
return rootContext;
|
|
924
1077
|
};
|
|
925
|
-
var WeaverseContext =
|
|
1078
|
+
var WeaverseContext = createContext3({});
|
|
926
1079
|
var WeaverseContextProvider = WeaverseContext.Provider;
|
|
927
1080
|
var WeaverseContextConsumer = WeaverseContext.Consumer;
|
|
928
1081
|
|
|
929
1082
|
// src/renderer.tsx
|
|
930
1083
|
import { isBrowser } from "@weaverse/core";
|
|
931
|
-
import
|
|
1084
|
+
import React22, { useContext as useContext11, useEffect as useEffect4, useRef, useState as useState5 } from "react";
|
|
932
1085
|
|
|
933
1086
|
// src/utils/index.ts
|
|
934
|
-
|
|
1087
|
+
function shortCssObject(css) {
|
|
935
1088
|
return {
|
|
936
1089
|
"@desktop": css["@desktop"],
|
|
937
1090
|
"@mobile": css["@mobile"]
|
|
938
1091
|
};
|
|
939
|
-
}
|
|
1092
|
+
}
|
|
940
1093
|
function generateItemClass(instance, stitchesInstance) {
|
|
941
1094
|
var _a, _b, _c, _d;
|
|
942
1095
|
let { css, className: cls = "" } = instance.data;
|
|
@@ -956,7 +1109,7 @@ function generateItemClass(instance, stitchesInstance) {
|
|
|
956
1109
|
// src/renderer.tsx
|
|
957
1110
|
var WeaverseRoot = ({ context }) => {
|
|
958
1111
|
var _a, _b;
|
|
959
|
-
let [, setData] =
|
|
1112
|
+
let [, setData] = useState5(context.projectData);
|
|
960
1113
|
let rootRef = useRef();
|
|
961
1114
|
let update = () => setData({});
|
|
962
1115
|
useEffect4(() => {
|
|
@@ -968,19 +1121,19 @@ var WeaverseRoot = ({ context }) => {
|
|
|
968
1121
|
}, []);
|
|
969
1122
|
let eventHandlers = ((_a = context == null ? void 0 : context.studioBridge) == null ? void 0 : _a.eventHandlers) || {};
|
|
970
1123
|
let themeClass = context.stitchesInstance.theme.className;
|
|
971
|
-
return ((_b = context.projectData) == null ? void 0 : _b.rootId) ? /* @__PURE__ */
|
|
1124
|
+
return ((_b = context.projectData) == null ? void 0 : _b.rootId) ? /* @__PURE__ */ React22.createElement("div", {
|
|
972
1125
|
className: `weaverse-content-root ${themeClass}`,
|
|
973
1126
|
...eventHandlers,
|
|
974
1127
|
ref: rootRef
|
|
975
|
-
}, /* @__PURE__ */
|
|
1128
|
+
}, /* @__PURE__ */ React22.createElement(WeaverseContextProvider, {
|
|
976
1129
|
value: context
|
|
977
|
-
}, /* @__PURE__ */
|
|
1130
|
+
}, /* @__PURE__ */ React22.createElement(ItemInstance, {
|
|
978
1131
|
id: context.projectData.rootId
|
|
979
1132
|
}))) : null;
|
|
980
1133
|
};
|
|
981
1134
|
var ItemComponent = ({ instance }) => {
|
|
982
|
-
let { stitchesInstance, elementInstances } =
|
|
983
|
-
let [data, setData] =
|
|
1135
|
+
let { stitchesInstance, elementInstances } = useContext11(WeaverseContext);
|
|
1136
|
+
let [data, setData] = useState5(instance.data);
|
|
984
1137
|
let { id, type, childIds = [], css, className, ...rest } = data;
|
|
985
1138
|
useEffect4(() => {
|
|
986
1139
|
var _a;
|
|
@@ -1002,13 +1155,13 @@ var ItemComponent = ({ instance }) => {
|
|
|
1002
1155
|
if (Component.$$typeof === Symbol.for("react.forward_ref")) {
|
|
1003
1156
|
rest.ref = instance.ref;
|
|
1004
1157
|
}
|
|
1005
|
-
return /* @__PURE__ */
|
|
1158
|
+
return /* @__PURE__ */ React22.createElement(Component, {
|
|
1006
1159
|
key: id,
|
|
1007
1160
|
"data-wv-type": type,
|
|
1008
1161
|
"data-wv-id": id,
|
|
1009
1162
|
className: generateItemClass(instance, stitchesInstance),
|
|
1010
1163
|
...rest
|
|
1011
|
-
}, childIds.map((id2) => /* @__PURE__ */
|
|
1164
|
+
}, childIds.map((id2) => /* @__PURE__ */ React22.createElement(ItemInstance, {
|
|
1012
1165
|
key: id2,
|
|
1013
1166
|
id: id2
|
|
1014
1167
|
})));
|
|
@@ -1016,15 +1169,15 @@ var ItemComponent = ({ instance }) => {
|
|
|
1016
1169
|
return null;
|
|
1017
1170
|
};
|
|
1018
1171
|
var ItemInstance = ({ id }) => {
|
|
1019
|
-
let context =
|
|
1172
|
+
let context = useContext11(WeaverseContext);
|
|
1020
1173
|
let { itemInstances } = context;
|
|
1021
1174
|
let instance = itemInstances.get(id);
|
|
1022
1175
|
if (!instance) {
|
|
1023
|
-
return /* @__PURE__ */
|
|
1176
|
+
return /* @__PURE__ */ React22.createElement("div", {
|
|
1024
1177
|
style: { display: "none" }
|
|
1025
1178
|
}, "Item instance ", id, " not found");
|
|
1026
1179
|
}
|
|
1027
|
-
return /* @__PURE__ */
|
|
1180
|
+
return /* @__PURE__ */ React22.createElement(ItemComponent, {
|
|
1028
1181
|
instance
|
|
1029
1182
|
});
|
|
1030
1183
|
};
|