@weaverse/react 0.7.5 → 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 +198 -120
- package/dist/index.mjs +197 -123
- package/package.json +2 -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%",
|
|
@@ -801,35 +785,70 @@ var TabContent_default = TabContent;
|
|
|
801
785
|
|
|
802
786
|
// src/elements/slider/index.tsx
|
|
803
787
|
var import_react16 = __toESM(require("react"));
|
|
804
|
-
var
|
|
805
|
-
var
|
|
806
|
-
active: null,
|
|
807
|
-
setActive: () => {
|
|
808
|
-
}
|
|
809
|
-
});
|
|
788
|
+
var import_nuka_carousel = __toESM(require("nuka-carousel"));
|
|
789
|
+
var Carousel = import_nuka_carousel.default.default;
|
|
810
790
|
var Slider = (0, import_react16.forwardRef)((props, ref) => {
|
|
811
|
-
|
|
812
|
-
const { children, ...rest } = props;
|
|
813
|
-
const defaultActive = (_c = (_b = (_a = import_react16.default.Children.toArray(children)) == null ? void 0 : _a[0]) == null ? void 0 : _b.props) == null ? void 0 : _c.id;
|
|
814
|
-
const [active, setActive] = (0, import_react16.useState)(defaultActive);
|
|
791
|
+
const { isDesignMode } = (0, import_react16.useContext)(WeaverseContext);
|
|
792
|
+
const { autoplay, delay, children, ...rest } = props;
|
|
815
793
|
return /* @__PURE__ */ import_react16.default.createElement("div", {
|
|
816
794
|
...rest,
|
|
817
795
|
ref
|
|
818
|
-
}, /* @__PURE__ */ import_react16.default.createElement(
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
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));
|
|
829
816
|
});
|
|
830
817
|
Slider.defaultProps = {
|
|
818
|
+
fullWidth: true,
|
|
819
|
+
autoplay: true,
|
|
820
|
+
delay: 3,
|
|
831
821
|
css: {
|
|
832
|
-
"@desktop": {
|
|
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
|
+
}
|
|
833
852
|
}
|
|
834
853
|
};
|
|
835
854
|
var slider_default = Slider;
|
|
@@ -838,9 +857,18 @@ var slider_default = Slider;
|
|
|
838
857
|
var import_react17 = __toESM(require("react"));
|
|
839
858
|
var SliderContent = (0, import_react17.forwardRef)(
|
|
840
859
|
(props, ref) => {
|
|
841
|
-
const {
|
|
842
|
-
const
|
|
843
|
-
|
|
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;
|
|
844
872
|
let style = {
|
|
845
873
|
"--rows": rows,
|
|
846
874
|
"--columns": columns,
|
|
@@ -848,19 +876,28 @@ var SliderContent = (0, import_react17.forwardRef)(
|
|
|
848
876
|
"--row-size": rowSize + "px",
|
|
849
877
|
"--col-size": "calc((var(--grid-size) - calc(var(--columns) - 1) * var(--gap)) / var(--columns))",
|
|
850
878
|
"--max-height": rows * rowSize + gap * (rowSize - 1) + "px",
|
|
851
|
-
"--
|
|
879
|
+
"--background-url": `url(${mediaUrl}`
|
|
880
|
+
};
|
|
881
|
+
const handleClick = () => {
|
|
882
|
+
if (!isDesignMode && targetLink) {
|
|
883
|
+
window.open(targetLink, openInNewTab ? "_blank" : "_self");
|
|
884
|
+
}
|
|
852
885
|
};
|
|
853
886
|
return /* @__PURE__ */ import_react17.default.createElement("div", {
|
|
854
|
-
ref,
|
|
855
887
|
...rest,
|
|
856
|
-
style
|
|
888
|
+
style,
|
|
889
|
+
onClick: handleClick
|
|
857
890
|
}, import_react17.default.Children.count(children) > 0 ? children : /* @__PURE__ */ import_react17.default.createElement(Placeholder_default, {
|
|
858
|
-
element: "Slider"
|
|
859
|
-
}, "
|
|
891
|
+
element: "Slider Content"
|
|
892
|
+
}, "Please drag and drop an element here"));
|
|
860
893
|
}
|
|
861
894
|
);
|
|
862
895
|
SliderContent.defaultProps = {
|
|
863
|
-
|
|
896
|
+
name: "Slider",
|
|
897
|
+
mediaUrl: "",
|
|
898
|
+
openInNewTab: false,
|
|
899
|
+
targetLink: "https://myshop.com",
|
|
900
|
+
rows: 4,
|
|
864
901
|
columns: 12,
|
|
865
902
|
gap: 4,
|
|
866
903
|
rowSize: 48,
|
|
@@ -868,18 +905,56 @@ SliderContent.defaultProps = {
|
|
|
868
905
|
"@desktop": {
|
|
869
906
|
width: "100%",
|
|
870
907
|
maxWidth: "var(--grid-size)",
|
|
871
|
-
display: "
|
|
908
|
+
display: "grid",
|
|
872
909
|
gridTemplateRows: "repeat(var(--rows), var(--row-size))",
|
|
873
910
|
gridTemplateColumns: "repeat(var(--columns), minmax(0, var(--col-size)))",
|
|
874
911
|
gap: "var(--gap)",
|
|
875
|
-
borderRadius: 4
|
|
912
|
+
borderRadius: 4,
|
|
913
|
+
backgroundImage: "var(--background-url, none)"
|
|
876
914
|
}
|
|
877
915
|
}
|
|
878
916
|
};
|
|
879
917
|
var SliderContent_default = SliderContent;
|
|
880
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
|
+
|
|
881
956
|
// src/elements/index.ts
|
|
882
|
-
var
|
|
957
|
+
var Elements = {
|
|
883
958
|
Countdown: {
|
|
884
959
|
Component: countdown_default,
|
|
885
960
|
type: "countdown"
|
|
@@ -943,33 +1018,36 @@ var elements = {
|
|
|
943
1018
|
SliderContent: {
|
|
944
1019
|
Component: SliderContent_default,
|
|
945
1020
|
type: "slider.content"
|
|
1021
|
+
},
|
|
1022
|
+
CustomHTML: {
|
|
1023
|
+
Component: custom_html_default,
|
|
1024
|
+
type: "custom.html"
|
|
946
1025
|
}
|
|
947
1026
|
};
|
|
948
|
-
var elements_default = elements;
|
|
949
1027
|
|
|
950
1028
|
// src/context.ts
|
|
951
1029
|
var createRootContext = (configs) => {
|
|
952
1030
|
let rootContext = new import_core.Weaverse(configs);
|
|
953
|
-
Object.keys(
|
|
954
|
-
rootContext.registerElement(
|
|
1031
|
+
Object.keys(Elements).forEach((key) => {
|
|
1032
|
+
rootContext.registerElement(Elements[key]);
|
|
955
1033
|
});
|
|
956
1034
|
return rootContext;
|
|
957
1035
|
};
|
|
958
|
-
var WeaverseContext = (0,
|
|
1036
|
+
var WeaverseContext = (0, import_react19.createContext)({});
|
|
959
1037
|
var WeaverseContextProvider = WeaverseContext.Provider;
|
|
960
1038
|
var WeaverseContextConsumer = WeaverseContext.Consumer;
|
|
961
1039
|
|
|
962
1040
|
// src/renderer.tsx
|
|
963
1041
|
var import_core2 = require("@weaverse/core");
|
|
964
|
-
var
|
|
1042
|
+
var import_react20 = __toESM(require("react"));
|
|
965
1043
|
|
|
966
1044
|
// src/utils/index.ts
|
|
967
|
-
|
|
1045
|
+
function shortCssObject(css) {
|
|
968
1046
|
return {
|
|
969
1047
|
"@desktop": css["@desktop"],
|
|
970
1048
|
"@mobile": css["@mobile"]
|
|
971
1049
|
};
|
|
972
|
-
}
|
|
1050
|
+
}
|
|
973
1051
|
function generateItemClass(instance, stitchesInstance) {
|
|
974
1052
|
var _a, _b, _c, _d;
|
|
975
1053
|
let { css, className: cls = "" } = instance.data;
|
|
@@ -989,10 +1067,10 @@ function generateItemClass(instance, stitchesInstance) {
|
|
|
989
1067
|
// src/renderer.tsx
|
|
990
1068
|
var WeaverseRoot = ({ context }) => {
|
|
991
1069
|
var _a, _b;
|
|
992
|
-
let [, setData] = (0,
|
|
993
|
-
let rootRef = (0,
|
|
1070
|
+
let [, setData] = (0, import_react20.useState)(context.projectData);
|
|
1071
|
+
let rootRef = (0, import_react20.useRef)();
|
|
994
1072
|
let update = () => setData({});
|
|
995
|
-
(0,
|
|
1073
|
+
(0, import_react20.useEffect)(() => {
|
|
996
1074
|
context.subscribe(update);
|
|
997
1075
|
context.contentRootElement = rootRef.current;
|
|
998
1076
|
return () => {
|
|
@@ -1001,21 +1079,21 @@ var WeaverseRoot = ({ context }) => {
|
|
|
1001
1079
|
}, []);
|
|
1002
1080
|
let eventHandlers = ((_a = context == null ? void 0 : context.studioBridge) == null ? void 0 : _a.eventHandlers) || {};
|
|
1003
1081
|
let themeClass = context.stitchesInstance.theme.className;
|
|
1004
|
-
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", {
|
|
1005
1083
|
className: `weaverse-content-root ${themeClass}`,
|
|
1006
1084
|
...eventHandlers,
|
|
1007
1085
|
ref: rootRef
|
|
1008
|
-
}, /* @__PURE__ */
|
|
1086
|
+
}, /* @__PURE__ */ import_react20.default.createElement(WeaverseContextProvider, {
|
|
1009
1087
|
value: context
|
|
1010
|
-
}, /* @__PURE__ */
|
|
1088
|
+
}, /* @__PURE__ */ import_react20.default.createElement(ItemInstance, {
|
|
1011
1089
|
id: context.projectData.rootId
|
|
1012
1090
|
}))) : null;
|
|
1013
1091
|
};
|
|
1014
1092
|
var ItemComponent = ({ instance }) => {
|
|
1015
|
-
let { stitchesInstance, elementInstances } = (0,
|
|
1016
|
-
let [data, setData] = (0,
|
|
1093
|
+
let { stitchesInstance, elementInstances } = (0, import_react20.useContext)(WeaverseContext);
|
|
1094
|
+
let [data, setData] = (0, import_react20.useState)(instance.data);
|
|
1017
1095
|
let { id, type, childIds = [], css, className, ...rest } = data;
|
|
1018
|
-
(0,
|
|
1096
|
+
(0, import_react20.useEffect)(() => {
|
|
1019
1097
|
var _a;
|
|
1020
1098
|
let update = (data2) => setData({ ...data2 });
|
|
1021
1099
|
instance.subscribe(update);
|
|
@@ -1035,13 +1113,13 @@ var ItemComponent = ({ instance }) => {
|
|
|
1035
1113
|
if (Component.$$typeof === Symbol.for("react.forward_ref")) {
|
|
1036
1114
|
rest.ref = instance.ref;
|
|
1037
1115
|
}
|
|
1038
|
-
return /* @__PURE__ */
|
|
1116
|
+
return /* @__PURE__ */ import_react20.default.createElement(Component, {
|
|
1039
1117
|
key: id,
|
|
1040
1118
|
"data-wv-type": type,
|
|
1041
1119
|
"data-wv-id": id,
|
|
1042
1120
|
className: generateItemClass(instance, stitchesInstance),
|
|
1043
1121
|
...rest
|
|
1044
|
-
}, childIds.map((id2) => /* @__PURE__ */
|
|
1122
|
+
}, childIds.map((id2) => /* @__PURE__ */ import_react20.default.createElement(ItemInstance, {
|
|
1045
1123
|
key: id2,
|
|
1046
1124
|
id: id2
|
|
1047
1125
|
})));
|
|
@@ -1049,15 +1127,15 @@ var ItemComponent = ({ instance }) => {
|
|
|
1049
1127
|
return null;
|
|
1050
1128
|
};
|
|
1051
1129
|
var ItemInstance = ({ id }) => {
|
|
1052
|
-
let context = (0,
|
|
1130
|
+
let context = (0, import_react20.useContext)(WeaverseContext);
|
|
1053
1131
|
let { itemInstances } = context;
|
|
1054
1132
|
let instance = itemInstances.get(id);
|
|
1055
1133
|
if (!instance) {
|
|
1056
|
-
return /* @__PURE__ */
|
|
1134
|
+
return /* @__PURE__ */ import_react20.default.createElement("div", {
|
|
1057
1135
|
style: { display: "none" }
|
|
1058
1136
|
}, "Item instance ", id, " not found");
|
|
1059
1137
|
}
|
|
1060
|
-
return /* @__PURE__ */
|
|
1138
|
+
return /* @__PURE__ */ import_react20.default.createElement(ItemComponent, {
|
|
1061
1139
|
instance
|
|
1062
1140
|
});
|
|
1063
1141
|
};
|
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",
|
|
@@ -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%",
|
|
@@ -763,51 +747,91 @@ TabContent.defaultProps = {
|
|
|
763
747
|
var TabContent_default = TabContent;
|
|
764
748
|
|
|
765
749
|
// src/elements/slider/index.tsx
|
|
766
|
-
import React18, {
|
|
767
|
-
|
|
768
|
-
|
|
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
|
-
});
|
|
750
|
+
import React18, { forwardRef as forwardRef15, useContext as useContext7 } from "react";
|
|
751
|
+
import C from "nuka-carousel";
|
|
752
|
+
var Carousel = C.default;
|
|
777
753
|
var Slider = forwardRef15((props, ref) => {
|
|
778
|
-
|
|
779
|
-
const { children, ...rest } = props;
|
|
780
|
-
const defaultActive = (_c = (_b = (_a = React18.Children.toArray(children)) == null ? void 0 : _a[0]) == null ? void 0 : _b.props) == null ? void 0 : _c.id;
|
|
781
|
-
const [active, setActive] = useState5(defaultActive);
|
|
754
|
+
const { isDesignMode } = useContext7(WeaverseContext);
|
|
755
|
+
const { autoplay, delay, children, ...rest } = props;
|
|
782
756
|
return /* @__PURE__ */ React18.createElement("div", {
|
|
783
757
|
...rest,
|
|
784
758
|
ref
|
|
785
|
-
}, /* @__PURE__ */ React18.createElement(
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
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));
|
|
796
779
|
});
|
|
797
780
|
Slider.defaultProps = {
|
|
781
|
+
fullWidth: true,
|
|
782
|
+
autoplay: true,
|
|
783
|
+
delay: 3,
|
|
798
784
|
css: {
|
|
799
|
-
"@desktop": {
|
|
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
|
+
}
|
|
800
815
|
}
|
|
801
816
|
};
|
|
802
817
|
var slider_default = Slider;
|
|
803
818
|
|
|
804
819
|
// src/elements/slider/SliderContent.tsx
|
|
805
|
-
import React19, { forwardRef as forwardRef16, useContext as
|
|
820
|
+
import React19, { forwardRef as forwardRef16, useContext as useContext8 } from "react";
|
|
806
821
|
var SliderContent = forwardRef16(
|
|
807
822
|
(props, ref) => {
|
|
808
|
-
const {
|
|
809
|
-
const
|
|
810
|
-
|
|
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;
|
|
811
835
|
let style = {
|
|
812
836
|
"--rows": rows,
|
|
813
837
|
"--columns": columns,
|
|
@@ -815,19 +839,28 @@ var SliderContent = forwardRef16(
|
|
|
815
839
|
"--row-size": rowSize + "px",
|
|
816
840
|
"--col-size": "calc((var(--grid-size) - calc(var(--columns) - 1) * var(--gap)) / var(--columns))",
|
|
817
841
|
"--max-height": rows * rowSize + gap * (rowSize - 1) + "px",
|
|
818
|
-
"--
|
|
842
|
+
"--background-url": `url(${mediaUrl}`
|
|
843
|
+
};
|
|
844
|
+
const handleClick = () => {
|
|
845
|
+
if (!isDesignMode && targetLink) {
|
|
846
|
+
window.open(targetLink, openInNewTab ? "_blank" : "_self");
|
|
847
|
+
}
|
|
819
848
|
};
|
|
820
849
|
return /* @__PURE__ */ React19.createElement("div", {
|
|
821
|
-
ref,
|
|
822
850
|
...rest,
|
|
823
|
-
style
|
|
851
|
+
style,
|
|
852
|
+
onClick: handleClick
|
|
824
853
|
}, React19.Children.count(children) > 0 ? children : /* @__PURE__ */ React19.createElement(Placeholder_default, {
|
|
825
|
-
element: "Slider"
|
|
826
|
-
}, "
|
|
854
|
+
element: "Slider Content"
|
|
855
|
+
}, "Please drag and drop an element here"));
|
|
827
856
|
}
|
|
828
857
|
);
|
|
829
858
|
SliderContent.defaultProps = {
|
|
830
|
-
|
|
859
|
+
name: "Slider",
|
|
860
|
+
mediaUrl: "",
|
|
861
|
+
openInNewTab: false,
|
|
862
|
+
targetLink: "https://myshop.com",
|
|
863
|
+
rows: 4,
|
|
831
864
|
columns: 12,
|
|
832
865
|
gap: 4,
|
|
833
866
|
rowSize: 48,
|
|
@@ -835,18 +868,56 @@ SliderContent.defaultProps = {
|
|
|
835
868
|
"@desktop": {
|
|
836
869
|
width: "100%",
|
|
837
870
|
maxWidth: "var(--grid-size)",
|
|
838
|
-
display: "
|
|
871
|
+
display: "grid",
|
|
839
872
|
gridTemplateRows: "repeat(var(--rows), var(--row-size))",
|
|
840
873
|
gridTemplateColumns: "repeat(var(--columns), minmax(0, var(--col-size)))",
|
|
841
874
|
gap: "var(--gap)",
|
|
842
|
-
borderRadius: 4
|
|
875
|
+
borderRadius: 4,
|
|
876
|
+
backgroundImage: "var(--background-url, none)"
|
|
843
877
|
}
|
|
844
878
|
}
|
|
845
879
|
};
|
|
846
880
|
var SliderContent_default = SliderContent;
|
|
847
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
|
+
|
|
848
919
|
// src/elements/index.ts
|
|
849
|
-
var
|
|
920
|
+
var Elements = {
|
|
850
921
|
Countdown: {
|
|
851
922
|
Component: countdown_default,
|
|
852
923
|
type: "countdown"
|
|
@@ -910,33 +981,36 @@ var elements = {
|
|
|
910
981
|
SliderContent: {
|
|
911
982
|
Component: SliderContent_default,
|
|
912
983
|
type: "slider.content"
|
|
984
|
+
},
|
|
985
|
+
CustomHTML: {
|
|
986
|
+
Component: custom_html_default,
|
|
987
|
+
type: "custom.html"
|
|
913
988
|
}
|
|
914
989
|
};
|
|
915
|
-
var elements_default = elements;
|
|
916
990
|
|
|
917
991
|
// src/context.ts
|
|
918
992
|
var createRootContext = (configs) => {
|
|
919
993
|
let rootContext = new Weaverse(configs);
|
|
920
|
-
Object.keys(
|
|
921
|
-
rootContext.registerElement(
|
|
994
|
+
Object.keys(Elements).forEach((key) => {
|
|
995
|
+
rootContext.registerElement(Elements[key]);
|
|
922
996
|
});
|
|
923
997
|
return rootContext;
|
|
924
998
|
};
|
|
925
|
-
var WeaverseContext =
|
|
999
|
+
var WeaverseContext = createContext3({});
|
|
926
1000
|
var WeaverseContextProvider = WeaverseContext.Provider;
|
|
927
1001
|
var WeaverseContextConsumer = WeaverseContext.Consumer;
|
|
928
1002
|
|
|
929
1003
|
// src/renderer.tsx
|
|
930
1004
|
import { isBrowser } from "@weaverse/core";
|
|
931
|
-
import
|
|
1005
|
+
import React21, { useContext as useContext10, useEffect as useEffect4, useRef, useState as useState5 } from "react";
|
|
932
1006
|
|
|
933
1007
|
// src/utils/index.ts
|
|
934
|
-
|
|
1008
|
+
function shortCssObject(css) {
|
|
935
1009
|
return {
|
|
936
1010
|
"@desktop": css["@desktop"],
|
|
937
1011
|
"@mobile": css["@mobile"]
|
|
938
1012
|
};
|
|
939
|
-
}
|
|
1013
|
+
}
|
|
940
1014
|
function generateItemClass(instance, stitchesInstance) {
|
|
941
1015
|
var _a, _b, _c, _d;
|
|
942
1016
|
let { css, className: cls = "" } = instance.data;
|
|
@@ -956,7 +1030,7 @@ function generateItemClass(instance, stitchesInstance) {
|
|
|
956
1030
|
// src/renderer.tsx
|
|
957
1031
|
var WeaverseRoot = ({ context }) => {
|
|
958
1032
|
var _a, _b;
|
|
959
|
-
let [, setData] =
|
|
1033
|
+
let [, setData] = useState5(context.projectData);
|
|
960
1034
|
let rootRef = useRef();
|
|
961
1035
|
let update = () => setData({});
|
|
962
1036
|
useEffect4(() => {
|
|
@@ -968,19 +1042,19 @@ var WeaverseRoot = ({ context }) => {
|
|
|
968
1042
|
}, []);
|
|
969
1043
|
let eventHandlers = ((_a = context == null ? void 0 : context.studioBridge) == null ? void 0 : _a.eventHandlers) || {};
|
|
970
1044
|
let themeClass = context.stitchesInstance.theme.className;
|
|
971
|
-
return ((_b = context.projectData) == null ? void 0 : _b.rootId) ? /* @__PURE__ */
|
|
1045
|
+
return ((_b = context.projectData) == null ? void 0 : _b.rootId) ? /* @__PURE__ */ React21.createElement("div", {
|
|
972
1046
|
className: `weaverse-content-root ${themeClass}`,
|
|
973
1047
|
...eventHandlers,
|
|
974
1048
|
ref: rootRef
|
|
975
|
-
}, /* @__PURE__ */
|
|
1049
|
+
}, /* @__PURE__ */ React21.createElement(WeaverseContextProvider, {
|
|
976
1050
|
value: context
|
|
977
|
-
}, /* @__PURE__ */
|
|
1051
|
+
}, /* @__PURE__ */ React21.createElement(ItemInstance, {
|
|
978
1052
|
id: context.projectData.rootId
|
|
979
1053
|
}))) : null;
|
|
980
1054
|
};
|
|
981
1055
|
var ItemComponent = ({ instance }) => {
|
|
982
|
-
let { stitchesInstance, elementInstances } =
|
|
983
|
-
let [data, setData] =
|
|
1056
|
+
let { stitchesInstance, elementInstances } = useContext10(WeaverseContext);
|
|
1057
|
+
let [data, setData] = useState5(instance.data);
|
|
984
1058
|
let { id, type, childIds = [], css, className, ...rest } = data;
|
|
985
1059
|
useEffect4(() => {
|
|
986
1060
|
var _a;
|
|
@@ -1002,13 +1076,13 @@ var ItemComponent = ({ instance }) => {
|
|
|
1002
1076
|
if (Component.$$typeof === Symbol.for("react.forward_ref")) {
|
|
1003
1077
|
rest.ref = instance.ref;
|
|
1004
1078
|
}
|
|
1005
|
-
return /* @__PURE__ */
|
|
1079
|
+
return /* @__PURE__ */ React21.createElement(Component, {
|
|
1006
1080
|
key: id,
|
|
1007
1081
|
"data-wv-type": type,
|
|
1008
1082
|
"data-wv-id": id,
|
|
1009
1083
|
className: generateItemClass(instance, stitchesInstance),
|
|
1010
1084
|
...rest
|
|
1011
|
-
}, childIds.map((id2) => /* @__PURE__ */
|
|
1085
|
+
}, childIds.map((id2) => /* @__PURE__ */ React21.createElement(ItemInstance, {
|
|
1012
1086
|
key: id2,
|
|
1013
1087
|
id: id2
|
|
1014
1088
|
})));
|
|
@@ -1016,15 +1090,15 @@ var ItemComponent = ({ instance }) => {
|
|
|
1016
1090
|
return null;
|
|
1017
1091
|
};
|
|
1018
1092
|
var ItemInstance = ({ id }) => {
|
|
1019
|
-
let context =
|
|
1093
|
+
let context = useContext10(WeaverseContext);
|
|
1020
1094
|
let { itemInstances } = context;
|
|
1021
1095
|
let instance = itemInstances.get(id);
|
|
1022
1096
|
if (!instance) {
|
|
1023
|
-
return /* @__PURE__ */
|
|
1097
|
+
return /* @__PURE__ */ React21.createElement("div", {
|
|
1024
1098
|
style: { display: "none" }
|
|
1025
1099
|
}, "Item instance ", id, " not found");
|
|
1026
1100
|
}
|
|
1027
|
-
return /* @__PURE__ */
|
|
1101
|
+
return /* @__PURE__ */ React21.createElement(ItemComponent, {
|
|
1028
1102
|
instance
|
|
1029
1103
|
});
|
|
1030
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,7 +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
35
|
"nuka-carousel": "^5.2.0"
|
|
36
36
|
}
|
|
37
37
|
}
|