@weaverse/react 0.7.2 → 0.7.6
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 +252 -87
- package/dist/index.mjs +245 -80
- package/package.json +3 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import { ReactElement, ReactNode } from 'react';
|
|
2
|
+
import { ReactElement, ReactNode, CSSProperties } from 'react';
|
|
3
3
|
import { WeaverseType, Weaverse, ElementCSS, WeaverseItemStore } from '@weaverse/core';
|
|
4
4
|
export * from '@weaverse/core';
|
|
5
5
|
|
|
@@ -23,6 +23,7 @@ declare type ItemComponentProps = {
|
|
|
23
23
|
interface PlaceholderProps {
|
|
24
24
|
element: string;
|
|
25
25
|
children: ReactElement | ReactElement[] | ReactNode | ReactNode[];
|
|
26
|
+
style?: CSSProperties;
|
|
26
27
|
}
|
|
27
28
|
interface ButtonElementProps extends WeaverseElementProps {
|
|
28
29
|
value: string;
|
|
@@ -42,13 +43,15 @@ interface ImageElementProps extends WeaverseElementProps {
|
|
|
42
43
|
linkTo?: string;
|
|
43
44
|
openLinkInNewTab?: boolean;
|
|
44
45
|
}
|
|
45
|
-
interface
|
|
46
|
-
gridSize: number;
|
|
46
|
+
interface GridContentElementProps extends WeaverseElementProps {
|
|
47
47
|
rows: number;
|
|
48
48
|
columns: number;
|
|
49
49
|
gap: number;
|
|
50
50
|
rowSize: number;
|
|
51
51
|
}
|
|
52
|
+
interface LayoutElementProps extends GridContentElementProps {
|
|
53
|
+
gridSize: number;
|
|
54
|
+
}
|
|
52
55
|
interface MapElementProps extends WeaverseElementProps {
|
|
53
56
|
place: string;
|
|
54
57
|
zoom: number;
|
|
@@ -66,8 +69,9 @@ interface VideoElementProps extends WeaverseElementProps {
|
|
|
66
69
|
muted: boolean;
|
|
67
70
|
}
|
|
68
71
|
declare type CountdownTimeKey = 'days' | 'hours' | 'minutes' | 'seconds';
|
|
72
|
+
declare type CountdownTimerType = 'fixed-time' | 'evergreen';
|
|
69
73
|
interface CountdownElementProps extends WeaverseElementProps {
|
|
70
|
-
timerType:
|
|
74
|
+
timerType: CountdownTimerType;
|
|
71
75
|
startTime: number;
|
|
72
76
|
endTime: number;
|
|
73
77
|
periods: number;
|
|
@@ -97,4 +101,4 @@ declare type InstagramMedia = {
|
|
|
97
101
|
|
|
98
102
|
declare let WeaverseRoot: ({ context }: WeaverseRootPropsType) => JSX.Element | null;
|
|
99
103
|
|
|
100
|
-
export { ButtonElementProps, ContainerElementProps, CountdownElementProps, CountdownTimeKey, ImageElementProps, InstagramElementProps, InstagramMedia, ItemComponentProps, LayoutElementProps, MapElementProps, PlaceholderProps, TextElementProps, TimerBlockProps, VideoElementProps, WeaverseContext, WeaverseContextConsumer, WeaverseContextProvider, WeaverseElementProps, WeaverseRoot, WeaverseRootPropsType, createRootContext };
|
|
104
|
+
export { ButtonElementProps, ContainerElementProps, CountdownElementProps, CountdownTimeKey, CountdownTimerType, GridContentElementProps, ImageElementProps, InstagramElementProps, InstagramMedia, ItemComponentProps, LayoutElementProps, MapElementProps, PlaceholderProps, TextElementProps, TimerBlockProps, VideoElementProps, WeaverseContext, WeaverseContextConsumer, WeaverseContextProvider, WeaverseElementProps, WeaverseRoot, WeaverseRootPropsType, createRootContext };
|
package/dist/index.js
CHANGED
|
@@ -37,7 +37,7 @@ module.exports = __toCommonJS(src_exports);
|
|
|
37
37
|
|
|
38
38
|
// src/context.ts
|
|
39
39
|
var import_core = require("@weaverse/core");
|
|
40
|
-
var
|
|
40
|
+
var import_react19 = require("react");
|
|
41
41
|
|
|
42
42
|
// src/elements/button.tsx
|
|
43
43
|
var React = __toESM(require("react"));
|
|
@@ -257,7 +257,7 @@ var Image = import_react4.default.forwardRef(
|
|
|
257
257
|
}
|
|
258
258
|
);
|
|
259
259
|
Image.defaultProps = {
|
|
260
|
-
src: "https://ucarecdn.com/
|
|
260
|
+
src: "https://ucarecdn.com/c413b8fe-ceec-4948-9c42-a0434c4ca920/",
|
|
261
261
|
alt: "Image alt text",
|
|
262
262
|
objectFit: "cover",
|
|
263
263
|
objectPosition: "center",
|
|
@@ -426,20 +426,26 @@ var import_react9 = __toESM(require("react"));
|
|
|
426
426
|
var import_react8 = __toESM(require("react"));
|
|
427
427
|
var Placeholder = (0, import_react8.forwardRef)(
|
|
428
428
|
(props, ref) => {
|
|
429
|
-
let { element, children, ...rest } = props;
|
|
430
|
-
let
|
|
429
|
+
let { element, children, style: newStyle, ...rest } = props;
|
|
430
|
+
let defaultStyle = {
|
|
431
431
|
position: "absolute",
|
|
432
|
-
height: "100%",
|
|
433
|
-
width: "100%",
|
|
432
|
+
height: "calc(100% - 20px)",
|
|
433
|
+
width: "calc(100% - 20px)",
|
|
434
434
|
display: "flex",
|
|
435
435
|
flexDirection: "column",
|
|
436
436
|
alignItems: "center",
|
|
437
437
|
justifyContent: "center",
|
|
438
|
-
color: "#374151",
|
|
439
438
|
pointerEvents: "none",
|
|
440
|
-
zIndex: 1
|
|
439
|
+
zIndex: 1,
|
|
440
|
+
color: "#374151",
|
|
441
|
+
backgroundColor: "#F9FAFB",
|
|
442
|
+
border: "1px dashed #0F71FF",
|
|
443
|
+
borderRadius: 4,
|
|
444
|
+
margin: 10
|
|
441
445
|
};
|
|
446
|
+
const style = { ...defaultStyle, ...newStyle };
|
|
442
447
|
return /* @__PURE__ */ import_react8.default.createElement("div", {
|
|
448
|
+
"data-wv-type": "placeholder",
|
|
443
449
|
style,
|
|
444
450
|
ref,
|
|
445
451
|
...rest
|
|
@@ -559,17 +565,6 @@ var Accordion = (0, import_react10.forwardRef)(
|
|
|
559
565
|
}
|
|
560
566
|
);
|
|
561
567
|
Accordion.defaultProps = {
|
|
562
|
-
items: [
|
|
563
|
-
{
|
|
564
|
-
id: 1,
|
|
565
|
-
headerText: "Header 1",
|
|
566
|
-
childrenId: true
|
|
567
|
-
},
|
|
568
|
-
{
|
|
569
|
-
id: 2,
|
|
570
|
-
headerText: "Header 2"
|
|
571
|
-
}
|
|
572
|
-
],
|
|
573
568
|
css: {
|
|
574
569
|
"@desktop": {
|
|
575
570
|
display: "flex",
|
|
@@ -595,7 +590,7 @@ var accordion_default = Accordion;
|
|
|
595
590
|
// src/elements/accordion/AccordionWrapper.tsx
|
|
596
591
|
var import_react11 = __toESM(require("react"));
|
|
597
592
|
var AccordionWrapper = (0, import_react11.forwardRef)((props, ref) => {
|
|
598
|
-
const { ["data-wv-id"]: wvId,
|
|
593
|
+
const { ["data-wv-id"]: wvId, name, children, ...rest } = props;
|
|
599
594
|
const { active, setActive } = (0, import_react11.useContext)(AccordionContext);
|
|
600
595
|
return /* @__PURE__ */ import_react11.default.createElement("div", {
|
|
601
596
|
ref,
|
|
@@ -603,10 +598,10 @@ var AccordionWrapper = (0, import_react11.forwardRef)((props, ref) => {
|
|
|
603
598
|
}, /* @__PURE__ */ import_react11.default.createElement("div", {
|
|
604
599
|
onClick: () => setActive(wvId),
|
|
605
600
|
className: `wv-accordion-header ${active === wvId ? "active" : ""}`
|
|
606
|
-
},
|
|
601
|
+
}, name), children);
|
|
607
602
|
});
|
|
608
603
|
AccordionWrapper.defaultProps = {
|
|
609
|
-
|
|
604
|
+
name: "Accordion item",
|
|
610
605
|
css: {
|
|
611
606
|
"@desktop": {
|
|
612
607
|
maxHeight: "100%"
|
|
@@ -617,24 +612,26 @@ var AccordionWrapper_default = AccordionWrapper;
|
|
|
617
612
|
|
|
618
613
|
// src/elements/accordion/AccordionContent.tsx
|
|
619
614
|
var import_react12 = __toESM(require("react"));
|
|
620
|
-
var AccordionContent = (0, import_react12.forwardRef)(
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
});
|
|
615
|
+
var AccordionContent = (0, import_react12.forwardRef)(
|
|
616
|
+
(props, ref) => {
|
|
617
|
+
const { rows, columns, gap, rowSize, children, ...rest } = props;
|
|
618
|
+
let style = {
|
|
619
|
+
"--rows": rows,
|
|
620
|
+
"--columns": columns,
|
|
621
|
+
"--gap": gap + "px",
|
|
622
|
+
"--row-size": rowSize + "px",
|
|
623
|
+
"--col-size": "calc((var(--grid-size) - calc(var(--columns) - 1) * var(--gap)) / var(--columns))",
|
|
624
|
+
"--max-height": rows * rowSize + gap * (rowSize - 1) + "px"
|
|
625
|
+
};
|
|
626
|
+
return /* @__PURE__ */ import_react12.default.createElement("div", {
|
|
627
|
+
ref,
|
|
628
|
+
...rest,
|
|
629
|
+
style
|
|
630
|
+
}, import_react12.default.Children.count(children) > 0 ? children : /* @__PURE__ */ import_react12.default.createElement(Placeholder_default, {
|
|
631
|
+
element: "Accordion Content"
|
|
632
|
+
}, "Please drag and drop an element here"));
|
|
633
|
+
}
|
|
634
|
+
);
|
|
638
635
|
AccordionContent.defaultProps = {
|
|
639
636
|
rows: 2,
|
|
640
637
|
columns: 12,
|
|
@@ -672,11 +669,10 @@ function TabHeader(props) {
|
|
|
672
669
|
let update = (data2) => setData({ ...data2 });
|
|
673
670
|
instance.subscribe(update);
|
|
674
671
|
}, []);
|
|
675
|
-
const text = data.headerText;
|
|
676
672
|
return /* @__PURE__ */ import_react13.default.createElement("div", {
|
|
677
673
|
onClick: () => setActive(wvId),
|
|
678
674
|
className: `wv-tab-header${active === wvId ? " active" : ""}`
|
|
679
|
-
},
|
|
675
|
+
}, data.name);
|
|
680
676
|
}
|
|
681
677
|
function TabHeaderWrapper(props) {
|
|
682
678
|
const { itemInstances } = (0, import_react13.useContext)(WeaverseContext);
|
|
@@ -684,7 +680,7 @@ function TabHeaderWrapper(props) {
|
|
|
684
680
|
const data = instance.data;
|
|
685
681
|
const childIds = data.childIds;
|
|
686
682
|
return /* @__PURE__ */ import_react13.default.createElement("div", {
|
|
687
|
-
className: "wv-tab-
|
|
683
|
+
className: "wv-tab-header-wrapper"
|
|
688
684
|
}, childIds.map((id) => /* @__PURE__ */ import_react13.default.createElement(TabHeader, {
|
|
689
685
|
key: id,
|
|
690
686
|
wvId: id
|
|
@@ -700,13 +696,11 @@ var TabContext = (0, import_react14.createContext)({
|
|
|
700
696
|
var Tab = (0, import_react14.forwardRef)((props, ref) => {
|
|
701
697
|
var _a, _b, _c;
|
|
702
698
|
const wvId = props["data-wv-id"];
|
|
703
|
-
const {
|
|
699
|
+
const { children, ...rest } = props;
|
|
704
700
|
const defaultActive = (_c = (_b = (_a = import_react14.default.Children.toArray(children)) == null ? void 0 : _a[0]) == null ? void 0 : _b.props) == null ? void 0 : _c.id;
|
|
705
701
|
const [active, setActive] = (0, import_react14.useState)(defaultActive);
|
|
706
702
|
const setOpenTab = (id) => {
|
|
707
|
-
if (id
|
|
708
|
-
setActive(null);
|
|
709
|
-
} else {
|
|
703
|
+
if (id !== active) {
|
|
710
704
|
setActive(id);
|
|
711
705
|
}
|
|
712
706
|
};
|
|
@@ -720,34 +714,23 @@ var Tab = (0, import_react14.forwardRef)((props, ref) => {
|
|
|
720
714
|
}), children));
|
|
721
715
|
});
|
|
722
716
|
Tab.defaultProps = {
|
|
723
|
-
items: [
|
|
724
|
-
{
|
|
725
|
-
headerText: "Header 1"
|
|
726
|
-
},
|
|
727
|
-
{
|
|
728
|
-
headerText: "Header 2"
|
|
729
|
-
},
|
|
730
|
-
{
|
|
731
|
-
headerText: "Header 2"
|
|
732
|
-
}
|
|
733
|
-
],
|
|
734
717
|
css: {
|
|
735
718
|
"@desktop": {
|
|
736
719
|
display: "flex",
|
|
737
720
|
flexDirection: "column",
|
|
738
721
|
gap: 4,
|
|
739
|
-
"& .wv-tab-
|
|
722
|
+
"& .wv-tab-header-wrapper": {
|
|
740
723
|
width: "100%",
|
|
741
724
|
display: "flex",
|
|
742
725
|
marginBottom: 10
|
|
743
726
|
},
|
|
744
727
|
"& .wv-tab-header": {
|
|
745
|
-
backgroundColor: "#
|
|
746
|
-
padding: "
|
|
728
|
+
backgroundColor: "#fff",
|
|
729
|
+
padding: "15px 24px",
|
|
730
|
+
border: "1px solid #E4E7EB",
|
|
747
731
|
cursor: "pointer",
|
|
748
732
|
"&.active": {
|
|
749
|
-
backgroundColor: "#
|
|
750
|
-
color: "#fff"
|
|
733
|
+
backgroundColor: "#E4E7EB"
|
|
751
734
|
}
|
|
752
735
|
}
|
|
753
736
|
}
|
|
@@ -776,8 +759,8 @@ var TabContent = (0, import_react15.forwardRef)(
|
|
|
776
759
|
...rest,
|
|
777
760
|
style
|
|
778
761
|
}, import_react15.default.Children.count(children) > 0 ? children : /* @__PURE__ */ import_react15.default.createElement(Placeholder_default, {
|
|
779
|
-
element: "Tab"
|
|
780
|
-
}, "
|
|
762
|
+
element: "Tab Content"
|
|
763
|
+
}, "Please drag and drop an element here"));
|
|
781
764
|
}
|
|
782
765
|
);
|
|
783
766
|
TabContent.defaultProps = {
|
|
@@ -785,6 +768,7 @@ TabContent.defaultProps = {
|
|
|
785
768
|
columns: 12,
|
|
786
769
|
gap: 4,
|
|
787
770
|
rowSize: 48,
|
|
771
|
+
name: "Tab header",
|
|
788
772
|
css: {
|
|
789
773
|
"@desktop": {
|
|
790
774
|
width: "100%",
|
|
@@ -799,8 +783,178 @@ TabContent.defaultProps = {
|
|
|
799
783
|
};
|
|
800
784
|
var TabContent_default = TabContent;
|
|
801
785
|
|
|
786
|
+
// src/elements/slider/index.tsx
|
|
787
|
+
var import_react16 = __toESM(require("react"));
|
|
788
|
+
var import_nuka_carousel = __toESM(require("nuka-carousel"));
|
|
789
|
+
var Carousel = import_nuka_carousel.default.default;
|
|
790
|
+
var Slider = (0, import_react16.forwardRef)((props, ref) => {
|
|
791
|
+
const { isDesignMode } = (0, import_react16.useContext)(WeaverseContext);
|
|
792
|
+
const { autoplay, delay, children, ...rest } = props;
|
|
793
|
+
return /* @__PURE__ */ import_react16.default.createElement("div", {
|
|
794
|
+
...rest,
|
|
795
|
+
ref
|
|
796
|
+
}, /* @__PURE__ */ import_react16.default.createElement(Carousel, {
|
|
797
|
+
dragging: false,
|
|
798
|
+
renderCenterLeftControls: (props2) => /* @__PURE__ */ import_react16.default.createElement("button", {
|
|
799
|
+
className: "wv-slider-btn",
|
|
800
|
+
onClick: props2.previousSlide,
|
|
801
|
+
disabled: (isDesignMode || !autoplay) && props2.currentSlide === 0
|
|
802
|
+
}, /* @__PURE__ */ import_react16.default.createElement("i", {
|
|
803
|
+
className: "wv-slider-arrow wv-slider-arrow-left"
|
|
804
|
+
})),
|
|
805
|
+
renderCenterRightControls: (props2) => /* @__PURE__ */ import_react16.default.createElement("button", {
|
|
806
|
+
className: "wv-slider-btn",
|
|
807
|
+
onClick: props2.nextSlide,
|
|
808
|
+
disabled: (isDesignMode || !autoplay) && props2.slideCount === props2.currentSlide
|
|
809
|
+
}, /* @__PURE__ */ import_react16.default.createElement("i", {
|
|
810
|
+
className: "wv-slider-arrow wv-slider-arrow-right"
|
|
811
|
+
})),
|
|
812
|
+
wrapAround: !isDesignMode,
|
|
813
|
+
autoplay: !isDesignMode && autoplay,
|
|
814
|
+
autoplayInterval: delay * 1e3
|
|
815
|
+
}, children));
|
|
816
|
+
});
|
|
817
|
+
Slider.defaultProps = {
|
|
818
|
+
fullWidth: true,
|
|
819
|
+
autoplay: true,
|
|
820
|
+
delay: 3,
|
|
821
|
+
css: {
|
|
822
|
+
"@desktop": {
|
|
823
|
+
"& .wv-slider-btn": {
|
|
824
|
+
borderRadius: "100%",
|
|
825
|
+
width: 40,
|
|
826
|
+
height: 40,
|
|
827
|
+
background: "#fff",
|
|
828
|
+
border: "none",
|
|
829
|
+
cursor: "pointer",
|
|
830
|
+
"&[disabled]": {
|
|
831
|
+
cursor: "not-allowed"
|
|
832
|
+
},
|
|
833
|
+
"&:hover .wv-slider-arrow": {
|
|
834
|
+
borderColor: "#999"
|
|
835
|
+
},
|
|
836
|
+
"& .wv-slider-arrow": {
|
|
837
|
+
border: "solid black",
|
|
838
|
+
borderWidth: "0 1px 1px 0",
|
|
839
|
+
display: "inline-block",
|
|
840
|
+
padding: 5
|
|
841
|
+
},
|
|
842
|
+
"& .wv-slider-arrow-right": {
|
|
843
|
+
transform: "rotate(-45deg)",
|
|
844
|
+
marginRight: 5
|
|
845
|
+
},
|
|
846
|
+
"& .wv-slider-arrow-left": {
|
|
847
|
+
transform: "rotate(135deg)",
|
|
848
|
+
marginLeft: 5
|
|
849
|
+
}
|
|
850
|
+
}
|
|
851
|
+
}
|
|
852
|
+
}
|
|
853
|
+
};
|
|
854
|
+
var slider_default = Slider;
|
|
855
|
+
|
|
856
|
+
// src/elements/slider/SliderContent.tsx
|
|
857
|
+
var import_react17 = __toESM(require("react"));
|
|
858
|
+
var SliderContent = (0, import_react17.forwardRef)(
|
|
859
|
+
(props, ref) => {
|
|
860
|
+
const { isDesignMode } = (0, import_react17.useContext)(WeaverseContext);
|
|
861
|
+
const {
|
|
862
|
+
mediaUrl,
|
|
863
|
+
targetLink,
|
|
864
|
+
openInNewTab,
|
|
865
|
+
rows,
|
|
866
|
+
columns,
|
|
867
|
+
gap,
|
|
868
|
+
rowSize,
|
|
869
|
+
children,
|
|
870
|
+
...rest
|
|
871
|
+
} = props;
|
|
872
|
+
let style = {
|
|
873
|
+
"--rows": rows,
|
|
874
|
+
"--columns": columns,
|
|
875
|
+
"--gap": gap + "px",
|
|
876
|
+
"--row-size": rowSize + "px",
|
|
877
|
+
"--col-size": "calc((var(--grid-size) - calc(var(--columns) - 1) * var(--gap)) / var(--columns))",
|
|
878
|
+
"--max-height": rows * rowSize + gap * (rowSize - 1) + "px",
|
|
879
|
+
"--background-url": `url(${mediaUrl}`
|
|
880
|
+
};
|
|
881
|
+
const handleClick = () => {
|
|
882
|
+
if (!isDesignMode && targetLink) {
|
|
883
|
+
window.open(targetLink, openInNewTab ? "_blank" : "_self");
|
|
884
|
+
}
|
|
885
|
+
};
|
|
886
|
+
return /* @__PURE__ */ import_react17.default.createElement("div", {
|
|
887
|
+
...rest,
|
|
888
|
+
style,
|
|
889
|
+
onClick: handleClick
|
|
890
|
+
}, import_react17.default.Children.count(children) > 0 ? children : /* @__PURE__ */ import_react17.default.createElement(Placeholder_default, {
|
|
891
|
+
element: "Slider Content"
|
|
892
|
+
}, "Please drag and drop an element here"));
|
|
893
|
+
}
|
|
894
|
+
);
|
|
895
|
+
SliderContent.defaultProps = {
|
|
896
|
+
name: "Slider",
|
|
897
|
+
mediaUrl: "",
|
|
898
|
+
openInNewTab: false,
|
|
899
|
+
targetLink: "https://myshop.com",
|
|
900
|
+
rows: 4,
|
|
901
|
+
columns: 12,
|
|
902
|
+
gap: 4,
|
|
903
|
+
rowSize: 48,
|
|
904
|
+
css: {
|
|
905
|
+
"@desktop": {
|
|
906
|
+
width: "100%",
|
|
907
|
+
maxWidth: "var(--grid-size)",
|
|
908
|
+
display: "grid",
|
|
909
|
+
gridTemplateRows: "repeat(var(--rows), var(--row-size))",
|
|
910
|
+
gridTemplateColumns: "repeat(var(--columns), minmax(0, var(--col-size)))",
|
|
911
|
+
gap: "var(--gap)",
|
|
912
|
+
borderRadius: 4,
|
|
913
|
+
backgroundImage: "var(--background-url, none)"
|
|
914
|
+
}
|
|
915
|
+
}
|
|
916
|
+
};
|
|
917
|
+
var SliderContent_default = SliderContent;
|
|
918
|
+
|
|
919
|
+
// src/elements/custom-html.tsx
|
|
920
|
+
var import_react18 = __toESM(require("react"));
|
|
921
|
+
var CustomHTML = (0, import_react18.forwardRef)(
|
|
922
|
+
(props, ref) => {
|
|
923
|
+
const { content, children, ...rest } = props;
|
|
924
|
+
const { isDesignMode } = (0, import_react18.useContext)(WeaverseContext);
|
|
925
|
+
const style = {
|
|
926
|
+
"--pointer-events": isDesignMode ? "none" : "auto"
|
|
927
|
+
};
|
|
928
|
+
if (!content)
|
|
929
|
+
return /* @__PURE__ */ import_react18.default.createElement("div", {
|
|
930
|
+
ref,
|
|
931
|
+
...rest
|
|
932
|
+
}, /* @__PURE__ */ import_react18.default.createElement(Placeholder_default, {
|
|
933
|
+
element: "Custom HTML"
|
|
934
|
+
}, "Please add your custom HTML codes."));
|
|
935
|
+
return /* @__PURE__ */ import_react18.default.createElement("div", {
|
|
936
|
+
ref,
|
|
937
|
+
...rest,
|
|
938
|
+
style,
|
|
939
|
+
dangerouslySetInnerHTML: { __html: content }
|
|
940
|
+
});
|
|
941
|
+
}
|
|
942
|
+
);
|
|
943
|
+
CustomHTML.defaultProps = {
|
|
944
|
+
content: "",
|
|
945
|
+
type: "custom.html",
|
|
946
|
+
css: {
|
|
947
|
+
"@desktop": {
|
|
948
|
+
"& > *": {
|
|
949
|
+
pointerEvents: "var(--pointer-events, unset)"
|
|
950
|
+
}
|
|
951
|
+
}
|
|
952
|
+
}
|
|
953
|
+
};
|
|
954
|
+
var custom_html_default = CustomHTML;
|
|
955
|
+
|
|
802
956
|
// src/elements/index.ts
|
|
803
|
-
var
|
|
957
|
+
var Elements = {
|
|
804
958
|
Countdown: {
|
|
805
959
|
Component: countdown_default,
|
|
806
960
|
type: "countdown"
|
|
@@ -856,33 +1010,44 @@ var elements = {
|
|
|
856
1010
|
TabContent: {
|
|
857
1011
|
Component: TabContent_default,
|
|
858
1012
|
type: "tab.content"
|
|
1013
|
+
},
|
|
1014
|
+
Slider: {
|
|
1015
|
+
Component: slider_default,
|
|
1016
|
+
type: "slider"
|
|
1017
|
+
},
|
|
1018
|
+
SliderContent: {
|
|
1019
|
+
Component: SliderContent_default,
|
|
1020
|
+
type: "slider.content"
|
|
1021
|
+
},
|
|
1022
|
+
CustomHTML: {
|
|
1023
|
+
Component: custom_html_default,
|
|
1024
|
+
type: "custom.html"
|
|
859
1025
|
}
|
|
860
1026
|
};
|
|
861
|
-
var elements_default = elements;
|
|
862
1027
|
|
|
863
1028
|
// src/context.ts
|
|
864
1029
|
var createRootContext = (configs) => {
|
|
865
1030
|
let rootContext = new import_core.Weaverse(configs);
|
|
866
|
-
Object.keys(
|
|
867
|
-
rootContext.registerElement(
|
|
1031
|
+
Object.keys(Elements).forEach((key) => {
|
|
1032
|
+
rootContext.registerElement(Elements[key]);
|
|
868
1033
|
});
|
|
869
1034
|
return rootContext;
|
|
870
1035
|
};
|
|
871
|
-
var WeaverseContext = (0,
|
|
1036
|
+
var WeaverseContext = (0, import_react19.createContext)({});
|
|
872
1037
|
var WeaverseContextProvider = WeaverseContext.Provider;
|
|
873
1038
|
var WeaverseContextConsumer = WeaverseContext.Consumer;
|
|
874
1039
|
|
|
875
1040
|
// src/renderer.tsx
|
|
876
1041
|
var import_core2 = require("@weaverse/core");
|
|
877
|
-
var
|
|
1042
|
+
var import_react20 = __toESM(require("react"));
|
|
878
1043
|
|
|
879
1044
|
// src/utils/index.ts
|
|
880
|
-
|
|
1045
|
+
function shortCssObject(css) {
|
|
881
1046
|
return {
|
|
882
1047
|
"@desktop": css["@desktop"],
|
|
883
1048
|
"@mobile": css["@mobile"]
|
|
884
1049
|
};
|
|
885
|
-
}
|
|
1050
|
+
}
|
|
886
1051
|
function generateItemClass(instance, stitchesInstance) {
|
|
887
1052
|
var _a, _b, _c, _d;
|
|
888
1053
|
let { css, className: cls = "" } = instance.data;
|
|
@@ -902,10 +1067,10 @@ function generateItemClass(instance, stitchesInstance) {
|
|
|
902
1067
|
// src/renderer.tsx
|
|
903
1068
|
var WeaverseRoot = ({ context }) => {
|
|
904
1069
|
var _a, _b;
|
|
905
|
-
let [, setData] = (0,
|
|
906
|
-
let rootRef = (0,
|
|
1070
|
+
let [, setData] = (0, import_react20.useState)(context.projectData);
|
|
1071
|
+
let rootRef = (0, import_react20.useRef)();
|
|
907
1072
|
let update = () => setData({});
|
|
908
|
-
(0,
|
|
1073
|
+
(0, import_react20.useEffect)(() => {
|
|
909
1074
|
context.subscribe(update);
|
|
910
1075
|
context.contentRootElement = rootRef.current;
|
|
911
1076
|
return () => {
|
|
@@ -914,21 +1079,21 @@ var WeaverseRoot = ({ context }) => {
|
|
|
914
1079
|
}, []);
|
|
915
1080
|
let eventHandlers = ((_a = context == null ? void 0 : context.studioBridge) == null ? void 0 : _a.eventHandlers) || {};
|
|
916
1081
|
let themeClass = context.stitchesInstance.theme.className;
|
|
917
|
-
return ((_b = context.projectData) == null ? void 0 : _b.rootId) ? /* @__PURE__ */
|
|
1082
|
+
return ((_b = context.projectData) == null ? void 0 : _b.rootId) ? /* @__PURE__ */ import_react20.default.createElement("div", {
|
|
918
1083
|
className: `weaverse-content-root ${themeClass}`,
|
|
919
1084
|
...eventHandlers,
|
|
920
1085
|
ref: rootRef
|
|
921
|
-
}, /* @__PURE__ */
|
|
1086
|
+
}, /* @__PURE__ */ import_react20.default.createElement(WeaverseContextProvider, {
|
|
922
1087
|
value: context
|
|
923
|
-
}, /* @__PURE__ */
|
|
1088
|
+
}, /* @__PURE__ */ import_react20.default.createElement(ItemInstance, {
|
|
924
1089
|
id: context.projectData.rootId
|
|
925
1090
|
}))) : null;
|
|
926
1091
|
};
|
|
927
1092
|
var ItemComponent = ({ instance }) => {
|
|
928
|
-
let { stitchesInstance, elementInstances } = (0,
|
|
929
|
-
let [data, setData] = (0,
|
|
1093
|
+
let { stitchesInstance, elementInstances } = (0, import_react20.useContext)(WeaverseContext);
|
|
1094
|
+
let [data, setData] = (0, import_react20.useState)(instance.data);
|
|
930
1095
|
let { id, type, childIds = [], css, className, ...rest } = data;
|
|
931
|
-
(0,
|
|
1096
|
+
(0, import_react20.useEffect)(() => {
|
|
932
1097
|
var _a;
|
|
933
1098
|
let update = (data2) => setData({ ...data2 });
|
|
934
1099
|
instance.subscribe(update);
|
|
@@ -948,13 +1113,13 @@ var ItemComponent = ({ instance }) => {
|
|
|
948
1113
|
if (Component.$$typeof === Symbol.for("react.forward_ref")) {
|
|
949
1114
|
rest.ref = instance.ref;
|
|
950
1115
|
}
|
|
951
|
-
return /* @__PURE__ */
|
|
1116
|
+
return /* @__PURE__ */ import_react20.default.createElement(Component, {
|
|
952
1117
|
key: id,
|
|
953
1118
|
"data-wv-type": type,
|
|
954
1119
|
"data-wv-id": id,
|
|
955
1120
|
className: generateItemClass(instance, stitchesInstance),
|
|
956
1121
|
...rest
|
|
957
|
-
}, childIds.map((id2) => /* @__PURE__ */
|
|
1122
|
+
}, childIds.map((id2) => /* @__PURE__ */ import_react20.default.createElement(ItemInstance, {
|
|
958
1123
|
key: id2,
|
|
959
1124
|
id: id2
|
|
960
1125
|
})));
|
|
@@ -962,15 +1127,15 @@ var ItemComponent = ({ instance }) => {
|
|
|
962
1127
|
return null;
|
|
963
1128
|
};
|
|
964
1129
|
var ItemInstance = ({ id }) => {
|
|
965
|
-
let context = (0,
|
|
1130
|
+
let context = (0, import_react20.useContext)(WeaverseContext);
|
|
966
1131
|
let { itemInstances } = context;
|
|
967
1132
|
let instance = itemInstances.get(id);
|
|
968
1133
|
if (!instance) {
|
|
969
|
-
return /* @__PURE__ */
|
|
1134
|
+
return /* @__PURE__ */ import_react20.default.createElement("div", {
|
|
970
1135
|
style: { display: "none" }
|
|
971
1136
|
}, "Item instance ", id, " not found");
|
|
972
1137
|
}
|
|
973
|
-
return /* @__PURE__ */
|
|
1138
|
+
return /* @__PURE__ */ import_react20.default.createElement(ItemComponent, {
|
|
974
1139
|
instance
|
|
975
1140
|
});
|
|
976
1141
|
};
|
package/dist/index.mjs
CHANGED
|
@@ -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",
|
|
@@ -389,20 +389,26 @@ import React11, { forwardRef as forwardRef9, useEffect as useEffect2, useState }
|
|
|
389
389
|
import React10, { forwardRef as forwardRef8 } from "react";
|
|
390
390
|
var Placeholder = forwardRef8(
|
|
391
391
|
(props, ref) => {
|
|
392
|
-
let { element, children, ...rest } = props;
|
|
393
|
-
let
|
|
392
|
+
let { element, children, style: newStyle, ...rest } = props;
|
|
393
|
+
let defaultStyle = {
|
|
394
394
|
position: "absolute",
|
|
395
|
-
height: "100%",
|
|
396
|
-
width: "100%",
|
|
395
|
+
height: "calc(100% - 20px)",
|
|
396
|
+
width: "calc(100% - 20px)",
|
|
397
397
|
display: "flex",
|
|
398
398
|
flexDirection: "column",
|
|
399
399
|
alignItems: "center",
|
|
400
400
|
justifyContent: "center",
|
|
401
|
-
color: "#374151",
|
|
402
401
|
pointerEvents: "none",
|
|
403
|
-
zIndex: 1
|
|
402
|
+
zIndex: 1,
|
|
403
|
+
color: "#374151",
|
|
404
|
+
backgroundColor: "#F9FAFB",
|
|
405
|
+
border: "1px dashed #0F71FF",
|
|
406
|
+
borderRadius: 4,
|
|
407
|
+
margin: 10
|
|
404
408
|
};
|
|
409
|
+
const style = { ...defaultStyle, ...newStyle };
|
|
405
410
|
return /* @__PURE__ */ React10.createElement("div", {
|
|
411
|
+
"data-wv-type": "placeholder",
|
|
406
412
|
style,
|
|
407
413
|
ref,
|
|
408
414
|
...rest
|
|
@@ -522,17 +528,6 @@ var Accordion = forwardRef10(
|
|
|
522
528
|
}
|
|
523
529
|
);
|
|
524
530
|
Accordion.defaultProps = {
|
|
525
|
-
items: [
|
|
526
|
-
{
|
|
527
|
-
id: 1,
|
|
528
|
-
headerText: "Header 1",
|
|
529
|
-
childrenId: true
|
|
530
|
-
},
|
|
531
|
-
{
|
|
532
|
-
id: 2,
|
|
533
|
-
headerText: "Header 2"
|
|
534
|
-
}
|
|
535
|
-
],
|
|
536
531
|
css: {
|
|
537
532
|
"@desktop": {
|
|
538
533
|
display: "flex",
|
|
@@ -558,7 +553,7 @@ var accordion_default = Accordion;
|
|
|
558
553
|
// src/elements/accordion/AccordionWrapper.tsx
|
|
559
554
|
import React13, { forwardRef as forwardRef11, useContext as useContext4 } from "react";
|
|
560
555
|
var AccordionWrapper = forwardRef11((props, ref) => {
|
|
561
|
-
const { ["data-wv-id"]: wvId,
|
|
556
|
+
const { ["data-wv-id"]: wvId, name, children, ...rest } = props;
|
|
562
557
|
const { active, setActive } = useContext4(AccordionContext);
|
|
563
558
|
return /* @__PURE__ */ React13.createElement("div", {
|
|
564
559
|
ref,
|
|
@@ -566,10 +561,10 @@ var AccordionWrapper = forwardRef11((props, ref) => {
|
|
|
566
561
|
}, /* @__PURE__ */ React13.createElement("div", {
|
|
567
562
|
onClick: () => setActive(wvId),
|
|
568
563
|
className: `wv-accordion-header ${active === wvId ? "active" : ""}`
|
|
569
|
-
},
|
|
564
|
+
}, name), children);
|
|
570
565
|
});
|
|
571
566
|
AccordionWrapper.defaultProps = {
|
|
572
|
-
|
|
567
|
+
name: "Accordion item",
|
|
573
568
|
css: {
|
|
574
569
|
"@desktop": {
|
|
575
570
|
maxHeight: "100%"
|
|
@@ -580,24 +575,26 @@ var AccordionWrapper_default = AccordionWrapper;
|
|
|
580
575
|
|
|
581
576
|
// src/elements/accordion/AccordionContent.tsx
|
|
582
577
|
import React14, { forwardRef as forwardRef12 } from "react";
|
|
583
|
-
var AccordionContent = forwardRef12(
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
});
|
|
578
|
+
var AccordionContent = forwardRef12(
|
|
579
|
+
(props, ref) => {
|
|
580
|
+
const { rows, columns, gap, rowSize, children, ...rest } = props;
|
|
581
|
+
let style = {
|
|
582
|
+
"--rows": rows,
|
|
583
|
+
"--columns": columns,
|
|
584
|
+
"--gap": gap + "px",
|
|
585
|
+
"--row-size": rowSize + "px",
|
|
586
|
+
"--col-size": "calc((var(--grid-size) - calc(var(--columns) - 1) * var(--gap)) / var(--columns))",
|
|
587
|
+
"--max-height": rows * rowSize + gap * (rowSize - 1) + "px"
|
|
588
|
+
};
|
|
589
|
+
return /* @__PURE__ */ React14.createElement("div", {
|
|
590
|
+
ref,
|
|
591
|
+
...rest,
|
|
592
|
+
style
|
|
593
|
+
}, React14.Children.count(children) > 0 ? children : /* @__PURE__ */ React14.createElement(Placeholder_default, {
|
|
594
|
+
element: "Accordion Content"
|
|
595
|
+
}, "Please drag and drop an element here"));
|
|
596
|
+
}
|
|
597
|
+
);
|
|
601
598
|
AccordionContent.defaultProps = {
|
|
602
599
|
rows: 2,
|
|
603
600
|
columns: 12,
|
|
@@ -635,11 +632,10 @@ function TabHeader(props) {
|
|
|
635
632
|
let update = (data2) => setData({ ...data2 });
|
|
636
633
|
instance.subscribe(update);
|
|
637
634
|
}, []);
|
|
638
|
-
const text = data.headerText;
|
|
639
635
|
return /* @__PURE__ */ React15.createElement("div", {
|
|
640
636
|
onClick: () => setActive(wvId),
|
|
641
637
|
className: `wv-tab-header${active === wvId ? " active" : ""}`
|
|
642
|
-
},
|
|
638
|
+
}, data.name);
|
|
643
639
|
}
|
|
644
640
|
function TabHeaderWrapper(props) {
|
|
645
641
|
const { itemInstances } = useContext5(WeaverseContext);
|
|
@@ -647,7 +643,7 @@ function TabHeaderWrapper(props) {
|
|
|
647
643
|
const data = instance.data;
|
|
648
644
|
const childIds = data.childIds;
|
|
649
645
|
return /* @__PURE__ */ React15.createElement("div", {
|
|
650
|
-
className: "wv-tab-
|
|
646
|
+
className: "wv-tab-header-wrapper"
|
|
651
647
|
}, childIds.map((id) => /* @__PURE__ */ React15.createElement(TabHeader, {
|
|
652
648
|
key: id,
|
|
653
649
|
wvId: id
|
|
@@ -663,13 +659,11 @@ var TabContext = createContext2({
|
|
|
663
659
|
var Tab = forwardRef13((props, ref) => {
|
|
664
660
|
var _a, _b, _c;
|
|
665
661
|
const wvId = props["data-wv-id"];
|
|
666
|
-
const {
|
|
662
|
+
const { children, ...rest } = props;
|
|
667
663
|
const defaultActive = (_c = (_b = (_a = React16.Children.toArray(children)) == null ? void 0 : _a[0]) == null ? void 0 : _b.props) == null ? void 0 : _c.id;
|
|
668
664
|
const [active, setActive] = useState4(defaultActive);
|
|
669
665
|
const setOpenTab = (id) => {
|
|
670
|
-
if (id
|
|
671
|
-
setActive(null);
|
|
672
|
-
} else {
|
|
666
|
+
if (id !== active) {
|
|
673
667
|
setActive(id);
|
|
674
668
|
}
|
|
675
669
|
};
|
|
@@ -683,34 +677,23 @@ var Tab = forwardRef13((props, ref) => {
|
|
|
683
677
|
}), children));
|
|
684
678
|
});
|
|
685
679
|
Tab.defaultProps = {
|
|
686
|
-
items: [
|
|
687
|
-
{
|
|
688
|
-
headerText: "Header 1"
|
|
689
|
-
},
|
|
690
|
-
{
|
|
691
|
-
headerText: "Header 2"
|
|
692
|
-
},
|
|
693
|
-
{
|
|
694
|
-
headerText: "Header 2"
|
|
695
|
-
}
|
|
696
|
-
],
|
|
697
680
|
css: {
|
|
698
681
|
"@desktop": {
|
|
699
682
|
display: "flex",
|
|
700
683
|
flexDirection: "column",
|
|
701
684
|
gap: 4,
|
|
702
|
-
"& .wv-tab-
|
|
685
|
+
"& .wv-tab-header-wrapper": {
|
|
703
686
|
width: "100%",
|
|
704
687
|
display: "flex",
|
|
705
688
|
marginBottom: 10
|
|
706
689
|
},
|
|
707
690
|
"& .wv-tab-header": {
|
|
708
|
-
backgroundColor: "#
|
|
709
|
-
padding: "
|
|
691
|
+
backgroundColor: "#fff",
|
|
692
|
+
padding: "15px 24px",
|
|
693
|
+
border: "1px solid #E4E7EB",
|
|
710
694
|
cursor: "pointer",
|
|
711
695
|
"&.active": {
|
|
712
|
-
backgroundColor: "#
|
|
713
|
-
color: "#fff"
|
|
696
|
+
backgroundColor: "#E4E7EB"
|
|
714
697
|
}
|
|
715
698
|
}
|
|
716
699
|
}
|
|
@@ -739,8 +722,8 @@ var TabContent = forwardRef14(
|
|
|
739
722
|
...rest,
|
|
740
723
|
style
|
|
741
724
|
}, React17.Children.count(children) > 0 ? children : /* @__PURE__ */ React17.createElement(Placeholder_default, {
|
|
742
|
-
element: "Tab"
|
|
743
|
-
}, "
|
|
725
|
+
element: "Tab Content"
|
|
726
|
+
}, "Please drag and drop an element here"));
|
|
744
727
|
}
|
|
745
728
|
);
|
|
746
729
|
TabContent.defaultProps = {
|
|
@@ -748,6 +731,7 @@ TabContent.defaultProps = {
|
|
|
748
731
|
columns: 12,
|
|
749
732
|
gap: 4,
|
|
750
733
|
rowSize: 48,
|
|
734
|
+
name: "Tab header",
|
|
751
735
|
css: {
|
|
752
736
|
"@desktop": {
|
|
753
737
|
width: "100%",
|
|
@@ -762,8 +746,178 @@ TabContent.defaultProps = {
|
|
|
762
746
|
};
|
|
763
747
|
var TabContent_default = TabContent;
|
|
764
748
|
|
|
749
|
+
// src/elements/slider/index.tsx
|
|
750
|
+
import React18, { forwardRef as forwardRef15, useContext as useContext7 } from "react";
|
|
751
|
+
import C from "nuka-carousel";
|
|
752
|
+
var Carousel = C.default;
|
|
753
|
+
var Slider = forwardRef15((props, ref) => {
|
|
754
|
+
const { isDesignMode } = useContext7(WeaverseContext);
|
|
755
|
+
const { autoplay, delay, children, ...rest } = props;
|
|
756
|
+
return /* @__PURE__ */ React18.createElement("div", {
|
|
757
|
+
...rest,
|
|
758
|
+
ref
|
|
759
|
+
}, /* @__PURE__ */ React18.createElement(Carousel, {
|
|
760
|
+
dragging: false,
|
|
761
|
+
renderCenterLeftControls: (props2) => /* @__PURE__ */ React18.createElement("button", {
|
|
762
|
+
className: "wv-slider-btn",
|
|
763
|
+
onClick: props2.previousSlide,
|
|
764
|
+
disabled: (isDesignMode || !autoplay) && props2.currentSlide === 0
|
|
765
|
+
}, /* @__PURE__ */ React18.createElement("i", {
|
|
766
|
+
className: "wv-slider-arrow wv-slider-arrow-left"
|
|
767
|
+
})),
|
|
768
|
+
renderCenterRightControls: (props2) => /* @__PURE__ */ React18.createElement("button", {
|
|
769
|
+
className: "wv-slider-btn",
|
|
770
|
+
onClick: props2.nextSlide,
|
|
771
|
+
disabled: (isDesignMode || !autoplay) && props2.slideCount === props2.currentSlide
|
|
772
|
+
}, /* @__PURE__ */ React18.createElement("i", {
|
|
773
|
+
className: "wv-slider-arrow wv-slider-arrow-right"
|
|
774
|
+
})),
|
|
775
|
+
wrapAround: !isDesignMode,
|
|
776
|
+
autoplay: !isDesignMode && autoplay,
|
|
777
|
+
autoplayInterval: delay * 1e3
|
|
778
|
+
}, children));
|
|
779
|
+
});
|
|
780
|
+
Slider.defaultProps = {
|
|
781
|
+
fullWidth: true,
|
|
782
|
+
autoplay: true,
|
|
783
|
+
delay: 3,
|
|
784
|
+
css: {
|
|
785
|
+
"@desktop": {
|
|
786
|
+
"& .wv-slider-btn": {
|
|
787
|
+
borderRadius: "100%",
|
|
788
|
+
width: 40,
|
|
789
|
+
height: 40,
|
|
790
|
+
background: "#fff",
|
|
791
|
+
border: "none",
|
|
792
|
+
cursor: "pointer",
|
|
793
|
+
"&[disabled]": {
|
|
794
|
+
cursor: "not-allowed"
|
|
795
|
+
},
|
|
796
|
+
"&:hover .wv-slider-arrow": {
|
|
797
|
+
borderColor: "#999"
|
|
798
|
+
},
|
|
799
|
+
"& .wv-slider-arrow": {
|
|
800
|
+
border: "solid black",
|
|
801
|
+
borderWidth: "0 1px 1px 0",
|
|
802
|
+
display: "inline-block",
|
|
803
|
+
padding: 5
|
|
804
|
+
},
|
|
805
|
+
"& .wv-slider-arrow-right": {
|
|
806
|
+
transform: "rotate(-45deg)",
|
|
807
|
+
marginRight: 5
|
|
808
|
+
},
|
|
809
|
+
"& .wv-slider-arrow-left": {
|
|
810
|
+
transform: "rotate(135deg)",
|
|
811
|
+
marginLeft: 5
|
|
812
|
+
}
|
|
813
|
+
}
|
|
814
|
+
}
|
|
815
|
+
}
|
|
816
|
+
};
|
|
817
|
+
var slider_default = Slider;
|
|
818
|
+
|
|
819
|
+
// src/elements/slider/SliderContent.tsx
|
|
820
|
+
import React19, { forwardRef as forwardRef16, useContext as useContext8 } from "react";
|
|
821
|
+
var SliderContent = forwardRef16(
|
|
822
|
+
(props, ref) => {
|
|
823
|
+
const { isDesignMode } = useContext8(WeaverseContext);
|
|
824
|
+
const {
|
|
825
|
+
mediaUrl,
|
|
826
|
+
targetLink,
|
|
827
|
+
openInNewTab,
|
|
828
|
+
rows,
|
|
829
|
+
columns,
|
|
830
|
+
gap,
|
|
831
|
+
rowSize,
|
|
832
|
+
children,
|
|
833
|
+
...rest
|
|
834
|
+
} = props;
|
|
835
|
+
let style = {
|
|
836
|
+
"--rows": rows,
|
|
837
|
+
"--columns": columns,
|
|
838
|
+
"--gap": gap + "px",
|
|
839
|
+
"--row-size": rowSize + "px",
|
|
840
|
+
"--col-size": "calc((var(--grid-size) - calc(var(--columns) - 1) * var(--gap)) / var(--columns))",
|
|
841
|
+
"--max-height": rows * rowSize + gap * (rowSize - 1) + "px",
|
|
842
|
+
"--background-url": `url(${mediaUrl}`
|
|
843
|
+
};
|
|
844
|
+
const handleClick = () => {
|
|
845
|
+
if (!isDesignMode && targetLink) {
|
|
846
|
+
window.open(targetLink, openInNewTab ? "_blank" : "_self");
|
|
847
|
+
}
|
|
848
|
+
};
|
|
849
|
+
return /* @__PURE__ */ React19.createElement("div", {
|
|
850
|
+
...rest,
|
|
851
|
+
style,
|
|
852
|
+
onClick: handleClick
|
|
853
|
+
}, React19.Children.count(children) > 0 ? children : /* @__PURE__ */ React19.createElement(Placeholder_default, {
|
|
854
|
+
element: "Slider Content"
|
|
855
|
+
}, "Please drag and drop an element here"));
|
|
856
|
+
}
|
|
857
|
+
);
|
|
858
|
+
SliderContent.defaultProps = {
|
|
859
|
+
name: "Slider",
|
|
860
|
+
mediaUrl: "",
|
|
861
|
+
openInNewTab: false,
|
|
862
|
+
targetLink: "https://myshop.com",
|
|
863
|
+
rows: 4,
|
|
864
|
+
columns: 12,
|
|
865
|
+
gap: 4,
|
|
866
|
+
rowSize: 48,
|
|
867
|
+
css: {
|
|
868
|
+
"@desktop": {
|
|
869
|
+
width: "100%",
|
|
870
|
+
maxWidth: "var(--grid-size)",
|
|
871
|
+
display: "grid",
|
|
872
|
+
gridTemplateRows: "repeat(var(--rows), var(--row-size))",
|
|
873
|
+
gridTemplateColumns: "repeat(var(--columns), minmax(0, var(--col-size)))",
|
|
874
|
+
gap: "var(--gap)",
|
|
875
|
+
borderRadius: 4,
|
|
876
|
+
backgroundImage: "var(--background-url, none)"
|
|
877
|
+
}
|
|
878
|
+
}
|
|
879
|
+
};
|
|
880
|
+
var SliderContent_default = SliderContent;
|
|
881
|
+
|
|
882
|
+
// src/elements/custom-html.tsx
|
|
883
|
+
import React20, { forwardRef as forwardRef17, useContext as useContext9 } from "react";
|
|
884
|
+
var CustomHTML = forwardRef17(
|
|
885
|
+
(props, ref) => {
|
|
886
|
+
const { content, children, ...rest } = props;
|
|
887
|
+
const { isDesignMode } = useContext9(WeaverseContext);
|
|
888
|
+
const style = {
|
|
889
|
+
"--pointer-events": isDesignMode ? "none" : "auto"
|
|
890
|
+
};
|
|
891
|
+
if (!content)
|
|
892
|
+
return /* @__PURE__ */ React20.createElement("div", {
|
|
893
|
+
ref,
|
|
894
|
+
...rest
|
|
895
|
+
}, /* @__PURE__ */ React20.createElement(Placeholder_default, {
|
|
896
|
+
element: "Custom HTML"
|
|
897
|
+
}, "Please add your custom HTML codes."));
|
|
898
|
+
return /* @__PURE__ */ React20.createElement("div", {
|
|
899
|
+
ref,
|
|
900
|
+
...rest,
|
|
901
|
+
style,
|
|
902
|
+
dangerouslySetInnerHTML: { __html: content }
|
|
903
|
+
});
|
|
904
|
+
}
|
|
905
|
+
);
|
|
906
|
+
CustomHTML.defaultProps = {
|
|
907
|
+
content: "",
|
|
908
|
+
type: "custom.html",
|
|
909
|
+
css: {
|
|
910
|
+
"@desktop": {
|
|
911
|
+
"& > *": {
|
|
912
|
+
pointerEvents: "var(--pointer-events, unset)"
|
|
913
|
+
}
|
|
914
|
+
}
|
|
915
|
+
}
|
|
916
|
+
};
|
|
917
|
+
var custom_html_default = CustomHTML;
|
|
918
|
+
|
|
765
919
|
// src/elements/index.ts
|
|
766
|
-
var
|
|
920
|
+
var Elements = {
|
|
767
921
|
Countdown: {
|
|
768
922
|
Component: countdown_default,
|
|
769
923
|
type: "countdown"
|
|
@@ -819,15 +973,26 @@ var elements = {
|
|
|
819
973
|
TabContent: {
|
|
820
974
|
Component: TabContent_default,
|
|
821
975
|
type: "tab.content"
|
|
976
|
+
},
|
|
977
|
+
Slider: {
|
|
978
|
+
Component: slider_default,
|
|
979
|
+
type: "slider"
|
|
980
|
+
},
|
|
981
|
+
SliderContent: {
|
|
982
|
+
Component: SliderContent_default,
|
|
983
|
+
type: "slider.content"
|
|
984
|
+
},
|
|
985
|
+
CustomHTML: {
|
|
986
|
+
Component: custom_html_default,
|
|
987
|
+
type: "custom.html"
|
|
822
988
|
}
|
|
823
989
|
};
|
|
824
|
-
var elements_default = elements;
|
|
825
990
|
|
|
826
991
|
// src/context.ts
|
|
827
992
|
var createRootContext = (configs) => {
|
|
828
993
|
let rootContext = new Weaverse(configs);
|
|
829
|
-
Object.keys(
|
|
830
|
-
rootContext.registerElement(
|
|
994
|
+
Object.keys(Elements).forEach((key) => {
|
|
995
|
+
rootContext.registerElement(Elements[key]);
|
|
831
996
|
});
|
|
832
997
|
return rootContext;
|
|
833
998
|
};
|
|
@@ -837,15 +1002,15 @@ var WeaverseContextConsumer = WeaverseContext.Consumer;
|
|
|
837
1002
|
|
|
838
1003
|
// src/renderer.tsx
|
|
839
1004
|
import { isBrowser } from "@weaverse/core";
|
|
840
|
-
import
|
|
1005
|
+
import React21, { useContext as useContext10, useEffect as useEffect4, useRef, useState as useState5 } from "react";
|
|
841
1006
|
|
|
842
1007
|
// src/utils/index.ts
|
|
843
|
-
|
|
1008
|
+
function shortCssObject(css) {
|
|
844
1009
|
return {
|
|
845
1010
|
"@desktop": css["@desktop"],
|
|
846
1011
|
"@mobile": css["@mobile"]
|
|
847
1012
|
};
|
|
848
|
-
}
|
|
1013
|
+
}
|
|
849
1014
|
function generateItemClass(instance, stitchesInstance) {
|
|
850
1015
|
var _a, _b, _c, _d;
|
|
851
1016
|
let { css, className: cls = "" } = instance.data;
|
|
@@ -877,18 +1042,18 @@ var WeaverseRoot = ({ context }) => {
|
|
|
877
1042
|
}, []);
|
|
878
1043
|
let eventHandlers = ((_a = context == null ? void 0 : context.studioBridge) == null ? void 0 : _a.eventHandlers) || {};
|
|
879
1044
|
let themeClass = context.stitchesInstance.theme.className;
|
|
880
|
-
return ((_b = context.projectData) == null ? void 0 : _b.rootId) ? /* @__PURE__ */
|
|
1045
|
+
return ((_b = context.projectData) == null ? void 0 : _b.rootId) ? /* @__PURE__ */ React21.createElement("div", {
|
|
881
1046
|
className: `weaverse-content-root ${themeClass}`,
|
|
882
1047
|
...eventHandlers,
|
|
883
1048
|
ref: rootRef
|
|
884
|
-
}, /* @__PURE__ */
|
|
1049
|
+
}, /* @__PURE__ */ React21.createElement(WeaverseContextProvider, {
|
|
885
1050
|
value: context
|
|
886
|
-
}, /* @__PURE__ */
|
|
1051
|
+
}, /* @__PURE__ */ React21.createElement(ItemInstance, {
|
|
887
1052
|
id: context.projectData.rootId
|
|
888
1053
|
}))) : null;
|
|
889
1054
|
};
|
|
890
1055
|
var ItemComponent = ({ instance }) => {
|
|
891
|
-
let { stitchesInstance, elementInstances } =
|
|
1056
|
+
let { stitchesInstance, elementInstances } = useContext10(WeaverseContext);
|
|
892
1057
|
let [data, setData] = useState5(instance.data);
|
|
893
1058
|
let { id, type, childIds = [], css, className, ...rest } = data;
|
|
894
1059
|
useEffect4(() => {
|
|
@@ -911,13 +1076,13 @@ var ItemComponent = ({ instance }) => {
|
|
|
911
1076
|
if (Component.$$typeof === Symbol.for("react.forward_ref")) {
|
|
912
1077
|
rest.ref = instance.ref;
|
|
913
1078
|
}
|
|
914
|
-
return /* @__PURE__ */
|
|
1079
|
+
return /* @__PURE__ */ React21.createElement(Component, {
|
|
915
1080
|
key: id,
|
|
916
1081
|
"data-wv-type": type,
|
|
917
1082
|
"data-wv-id": id,
|
|
918
1083
|
className: generateItemClass(instance, stitchesInstance),
|
|
919
1084
|
...rest
|
|
920
|
-
}, childIds.map((id2) => /* @__PURE__ */
|
|
1085
|
+
}, childIds.map((id2) => /* @__PURE__ */ React21.createElement(ItemInstance, {
|
|
921
1086
|
key: id2,
|
|
922
1087
|
id: id2
|
|
923
1088
|
})));
|
|
@@ -925,15 +1090,15 @@ var ItemComponent = ({ instance }) => {
|
|
|
925
1090
|
return null;
|
|
926
1091
|
};
|
|
927
1092
|
var ItemInstance = ({ id }) => {
|
|
928
|
-
let context =
|
|
1093
|
+
let context = useContext10(WeaverseContext);
|
|
929
1094
|
let { itemInstances } = context;
|
|
930
1095
|
let instance = itemInstances.get(id);
|
|
931
1096
|
if (!instance) {
|
|
932
|
-
return /* @__PURE__ */
|
|
1097
|
+
return /* @__PURE__ */ React21.createElement("div", {
|
|
933
1098
|
style: { display: "none" }
|
|
934
1099
|
}, "Item instance ", id, " not found");
|
|
935
1100
|
}
|
|
936
|
-
return /* @__PURE__ */
|
|
1101
|
+
return /* @__PURE__ */ React21.createElement(ItemComponent, {
|
|
937
1102
|
instance
|
|
938
1103
|
});
|
|
939
1104
|
};
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.7.
|
|
2
|
+
"version": "0.7.6",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"typings": "dist/index.d.ts",
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
"name": "@weaverse/react",
|
|
32
32
|
"author": "Weaverse Team",
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@weaverse/core": "0.7.
|
|
34
|
+
"@weaverse/core": "0.7.6",
|
|
35
|
+
"nuka-carousel": "^5.2.0"
|
|
35
36
|
}
|
|
36
37
|
}
|