@weaverse/react 0.7.53 → 0.7.55
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 +14 -1
- package/dist/index.js +201 -53
- package/dist/index.mjs +195 -47
- package/package.json +4 -3
package/dist/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import * as React$1 from 'react';
|
|
|
4
4
|
import React__default, { HTMLAttributes, ReactElement, ReactNode, CSSProperties } from 'react';
|
|
5
5
|
import * as _radix_ui_react_dialog from '@radix-ui/react-dialog';
|
|
6
6
|
import { DialogContentProps, DialogProps, DialogTitleProps, DialogCloseProps } from '@radix-ui/react-dialog';
|
|
7
|
+
import { KeenSliderInstance } from 'keen-slider';
|
|
7
8
|
|
|
8
9
|
declare let createRootContext: (configs: WeaverseType) => Weaverse;
|
|
9
10
|
declare let WeaverseContext: React$1.Context<Weaverse>;
|
|
@@ -54,6 +55,15 @@ interface WeaverseIconProps extends HTMLAttributes<SVGElement> {
|
|
|
54
55
|
interface TooltipProps {
|
|
55
56
|
children: React.ReactNode;
|
|
56
57
|
}
|
|
58
|
+
interface SliderProps {
|
|
59
|
+
children: React.ReactNode;
|
|
60
|
+
className?: string;
|
|
61
|
+
}
|
|
62
|
+
interface SliderArrowsProps {
|
|
63
|
+
currentSlide: number;
|
|
64
|
+
instanceRef: React.MutableRefObject<KeenSliderInstance | null>;
|
|
65
|
+
className?: string;
|
|
66
|
+
}
|
|
57
67
|
|
|
58
68
|
interface WeaverseElementProps extends Partial<ReactElement> {
|
|
59
69
|
css?: ElementCSS;
|
|
@@ -201,11 +211,14 @@ declare function Icon({ name, className, ...props }: WeaverseIconProps): JSX.Ele
|
|
|
201
211
|
|
|
202
212
|
declare function Tooltip({ children }: TooltipProps): JSX.Element;
|
|
203
213
|
|
|
214
|
+
declare function Slider({ children, className }: SliderProps): JSX.Element;
|
|
215
|
+
|
|
204
216
|
declare let Components: {
|
|
205
217
|
Placeholder: React$1.ForwardRefExoticComponent<PlaceholderProps & React$1.RefAttributes<HTMLDivElement>>;
|
|
206
218
|
Spinner: typeof Spinner;
|
|
207
219
|
ModalComponents: typeof ModalComponents;
|
|
208
220
|
Icon: typeof Icon;
|
|
221
|
+
Slider: typeof Slider;
|
|
209
222
|
Tooltip: typeof Tooltip;
|
|
210
223
|
};
|
|
211
224
|
|
|
@@ -213,4 +226,4 @@ declare const Elements: Record<string, WeaverseElement>;
|
|
|
213
226
|
|
|
214
227
|
declare let WeaverseRoot: ({ context }: WeaverseRootPropsType) => JSX.Element | null;
|
|
215
228
|
|
|
216
|
-
export { ButtonElementProps, Components, ContainerElementProps, CountdownElementProps, CountdownTimeKey, CountdownTimerType, Elements, GridContentElementProps, ImageElementProps, InstagramElementProps, InstagramMedia, ItemComponentProps, LayoutBackgroundProps, LayoutElementProps, MapElementProps, ModalContentProps, PlaceholderProps, TextElementProps, TimerBlockProps, TooltipProps, VideoCommonProps, VideoElementProps, VimeoElementProps, WeaverseContext, WeaverseContextConsumer, WeaverseContextProvider, WeaverseElementProps, WeaverseIcon, WeaverseIconProps, WeaverseRoot, WeaverseRootPropsType, YoutubeElementProps, createRootContext };
|
|
229
|
+
export { ButtonElementProps, Components, ContainerElementProps, CountdownElementProps, CountdownTimeKey, CountdownTimerType, Elements, GridContentElementProps, ImageElementProps, InstagramElementProps, InstagramMedia, ItemComponentProps, LayoutBackgroundProps, LayoutElementProps, MapElementProps, ModalContentProps, PlaceholderProps, SliderArrowsProps, SliderProps, TextElementProps, TimerBlockProps, TooltipProps, VideoCommonProps, VideoElementProps, VimeoElementProps, WeaverseContext, WeaverseContextConsumer, WeaverseContextProvider, WeaverseElementProps, WeaverseIcon, WeaverseIconProps, WeaverseRoot, WeaverseRootPropsType, YoutubeElementProps, createRootContext };
|
package/dist/index.js
CHANGED
|
@@ -40,7 +40,7 @@ __reExport(src_exports, require("@weaverse/core"), module.exports);
|
|
|
40
40
|
|
|
41
41
|
// src/context.ts
|
|
42
42
|
var import_core = require("@weaverse/core");
|
|
43
|
-
var
|
|
43
|
+
var import_react26 = require("react");
|
|
44
44
|
|
|
45
45
|
// src/elements/Button.tsx
|
|
46
46
|
var React = __toESM(require("react"));
|
|
@@ -122,15 +122,15 @@ var INSTAGRAM_API = "https://graph.instagram.com";
|
|
|
122
122
|
|
|
123
123
|
// src/utils/css.ts
|
|
124
124
|
var import_clsx = __toESM(require("clsx"));
|
|
125
|
-
function formatCSS(
|
|
125
|
+
function formatCSS(css10) {
|
|
126
126
|
return {
|
|
127
|
-
"@desktop":
|
|
128
|
-
"@mobile":
|
|
127
|
+
"@desktop": css10["@desktop"],
|
|
128
|
+
"@mobile": css10["@mobile"]
|
|
129
129
|
};
|
|
130
130
|
}
|
|
131
131
|
var permanentClasses = {};
|
|
132
132
|
function generateItemClassName(instance, stitchesInstance) {
|
|
133
|
-
let { css:
|
|
133
|
+
let { css: css10, type, className: cls = "" } = instance.data;
|
|
134
134
|
let className = "";
|
|
135
135
|
let permanentClass = "";
|
|
136
136
|
let perCss = instance.Element?.permanentCss;
|
|
@@ -144,8 +144,8 @@ function generateItemClassName(instance, stitchesInstance) {
|
|
|
144
144
|
}
|
|
145
145
|
}
|
|
146
146
|
className = permanentClass;
|
|
147
|
-
if (
|
|
148
|
-
let formattedCss = formatCSS(
|
|
147
|
+
if (css10) {
|
|
148
|
+
let formattedCss = formatCSS(css10);
|
|
149
149
|
let newStitchesClass = stitchesInstance.css(formattedCss)().className || "";
|
|
150
150
|
let { stitchesClass } = instance;
|
|
151
151
|
let otherClass = (instance.ref.current?.className || "").replace(stitchesClass, "").replace(cls, "").replace(permanentClass, "").trim();
|
|
@@ -690,7 +690,7 @@ Video.defaultProps = {
|
|
|
690
690
|
var Video_default = Video;
|
|
691
691
|
|
|
692
692
|
// src/elements/Instagram.tsx
|
|
693
|
-
var
|
|
693
|
+
var import_react25 = __toESM(require("react"));
|
|
694
694
|
|
|
695
695
|
// src/components/Placeholder.tsx
|
|
696
696
|
var import_react14 = __toESM(require("react"));
|
|
@@ -992,7 +992,7 @@ var StyledOverlay = (0, import_react17.styled)(import_react_dialog.Overlay, {
|
|
|
992
992
|
display: "block !important",
|
|
993
993
|
backgroundColor: "rgba(0, 0, 0, .3)",
|
|
994
994
|
position: "fixed",
|
|
995
|
-
zIndex:
|
|
995
|
+
zIndex: 99999,
|
|
996
996
|
inset: 0,
|
|
997
997
|
animation: `${overlayShow} 300ms cubic-bezier(0.16, 1, 0.3, 1)`
|
|
998
998
|
});
|
|
@@ -1015,7 +1015,7 @@ var StyledContent = (0, import_react17.styled)(import_react_dialog.Content, {
|
|
|
1015
1015
|
transform: "translate(-50%, -50%)",
|
|
1016
1016
|
padding: 24,
|
|
1017
1017
|
animation: `${contentShow} 300ms cubic-bezier(0.16, 1, 0.3, 1)`,
|
|
1018
|
-
zIndex:
|
|
1018
|
+
zIndex: 99999,
|
|
1019
1019
|
maxWidth: "90vw",
|
|
1020
1020
|
width: "auto",
|
|
1021
1021
|
"*": {
|
|
@@ -1041,8 +1041,8 @@ var StyledCloseIcon = (0, import_react17.styled)("button", {
|
|
|
1041
1041
|
cursor: "pointer",
|
|
1042
1042
|
fontFamily: "inherit",
|
|
1043
1043
|
borderRadius: "100%",
|
|
1044
|
-
height:
|
|
1045
|
-
width:
|
|
1044
|
+
height: 32,
|
|
1045
|
+
width: 32,
|
|
1046
1046
|
padding: 4,
|
|
1047
1047
|
display: "inline-flex",
|
|
1048
1048
|
alignItems: "center",
|
|
@@ -1055,8 +1055,8 @@ var StyledCloseIcon = (0, import_react17.styled)("button", {
|
|
|
1055
1055
|
backgroundColor: "rgba(112, 112, 112, .1)"
|
|
1056
1056
|
},
|
|
1057
1057
|
svg: {
|
|
1058
|
-
width:
|
|
1059
|
-
height:
|
|
1058
|
+
width: 24,
|
|
1059
|
+
height: 24
|
|
1060
1060
|
}
|
|
1061
1061
|
});
|
|
1062
1062
|
|
|
@@ -1064,20 +1064,23 @@ var StyledCloseIcon = (0, import_react17.styled)("button", {
|
|
|
1064
1064
|
var import_react18 = require("react");
|
|
1065
1065
|
function useOpenChangeEffect(props) {
|
|
1066
1066
|
let { open, defaultOpen, onOpenChange } = props;
|
|
1067
|
+
let rootCtx = (0, import_react18.useContext)(WeaverseContext);
|
|
1068
|
+
let toggleRootzIndex = (open2) => {
|
|
1069
|
+
let { contentRootElement } = rootCtx;
|
|
1070
|
+
if (contentRootElement) {
|
|
1071
|
+
if (open2) {
|
|
1072
|
+
contentRootElement.classList.add("modal-open");
|
|
1073
|
+
} else {
|
|
1074
|
+
contentRootElement.classList.remove("modal-open");
|
|
1075
|
+
}
|
|
1076
|
+
}
|
|
1077
|
+
};
|
|
1067
1078
|
(0, import_react18.useEffect)(() => {
|
|
1068
1079
|
let isOpen = open || defaultOpen;
|
|
1069
|
-
|
|
1070
|
-
document.body.classList.add("wv-modal-open");
|
|
1071
|
-
} else {
|
|
1072
|
-
document.body.classList.remove("wv-modal-open");
|
|
1073
|
-
}
|
|
1080
|
+
toggleRootzIndex(isOpen);
|
|
1074
1081
|
}, [open, defaultOpen]);
|
|
1075
1082
|
let handleOpenChange = (open2) => {
|
|
1076
|
-
|
|
1077
|
-
document.body.classList.add("wv-modal-open");
|
|
1078
|
-
} else {
|
|
1079
|
-
document.body.classList.remove("wv-modal-open");
|
|
1080
|
-
}
|
|
1083
|
+
toggleRootzIndex(open2);
|
|
1081
1084
|
onOpenChange?.(open2);
|
|
1082
1085
|
};
|
|
1083
1086
|
return handleOpenChange;
|
|
@@ -1160,22 +1163,167 @@ function Tooltip({ children }) {
|
|
|
1160
1163
|
}, children);
|
|
1161
1164
|
}
|
|
1162
1165
|
|
|
1166
|
+
// src/components/Slider/index.tsx
|
|
1167
|
+
var import_clsx4 = __toESM(require("clsx"));
|
|
1168
|
+
var import_react23 = require("keen-slider/react");
|
|
1169
|
+
var import_react24 = __toESM(require("react"));
|
|
1170
|
+
|
|
1171
|
+
// src/components/Slider/Arrows.tsx
|
|
1172
|
+
var import_clsx3 = __toESM(require("clsx"));
|
|
1173
|
+
var import_react22 = __toESM(require("react"));
|
|
1174
|
+
function Arrows(props) {
|
|
1175
|
+
let { currentSlide, instanceRef, className } = props;
|
|
1176
|
+
let { stitchesInstance } = (0, import_react22.useContext)(WeaverseContext);
|
|
1177
|
+
let { className: cssClass } = stitchesInstance.css(css9)();
|
|
1178
|
+
let isFirstSlide = currentSlide === 0;
|
|
1179
|
+
let isLastSlide = false;
|
|
1180
|
+
if (instanceRef.current) {
|
|
1181
|
+
isLastSlide = currentSlide === instanceRef?.current?.track?.details?.maxIdx;
|
|
1182
|
+
}
|
|
1183
|
+
let _className = (0, import_clsx3.default)(className, cssClass);
|
|
1184
|
+
let arrowLeftClass = (0, import_clsx3.default)(
|
|
1185
|
+
"wv-slider-arrow arrow--left",
|
|
1186
|
+
isFirstSlide && "arrow--disabled"
|
|
1187
|
+
);
|
|
1188
|
+
let arrowRightClass = (0, import_clsx3.default)(
|
|
1189
|
+
"wv-slider-arrow arrow--right",
|
|
1190
|
+
isLastSlide && "arrow--disabled"
|
|
1191
|
+
);
|
|
1192
|
+
return /* @__PURE__ */ import_react22.default.createElement("div", {
|
|
1193
|
+
className: _className
|
|
1194
|
+
}, /* @__PURE__ */ import_react22.default.createElement("button", {
|
|
1195
|
+
type: "button",
|
|
1196
|
+
className: arrowLeftClass,
|
|
1197
|
+
onClick: (e) => {
|
|
1198
|
+
e.stopPropagation();
|
|
1199
|
+
instanceRef?.current?.prev();
|
|
1200
|
+
}
|
|
1201
|
+
}, /* @__PURE__ */ import_react22.default.createElement(Icon, {
|
|
1202
|
+
name: "ArrowLeft"
|
|
1203
|
+
})), /* @__PURE__ */ import_react22.default.createElement("button", {
|
|
1204
|
+
type: "button",
|
|
1205
|
+
className: arrowRightClass,
|
|
1206
|
+
onClick: (e) => {
|
|
1207
|
+
e.stopPropagation();
|
|
1208
|
+
instanceRef?.current?.next();
|
|
1209
|
+
}
|
|
1210
|
+
}, /* @__PURE__ */ import_react22.default.createElement(Icon, {
|
|
1211
|
+
name: "ArrowRight"
|
|
1212
|
+
})));
|
|
1213
|
+
}
|
|
1214
|
+
var css9 = {
|
|
1215
|
+
"@desktop": {
|
|
1216
|
+
".wv-slider-arrow": {
|
|
1217
|
+
position: "absolute",
|
|
1218
|
+
top: "50%",
|
|
1219
|
+
transform: "translateY(-50%)",
|
|
1220
|
+
width: "44px",
|
|
1221
|
+
height: "44px",
|
|
1222
|
+
padding: "8px",
|
|
1223
|
+
color: "#191919",
|
|
1224
|
+
backgroundColor: "#f2f2f2",
|
|
1225
|
+
textAlign: "center",
|
|
1226
|
+
transition: "all 0.2s ease-in-out",
|
|
1227
|
+
borderRadius: "4px",
|
|
1228
|
+
border: "none",
|
|
1229
|
+
cursor: "pointer",
|
|
1230
|
+
"&:hover": {
|
|
1231
|
+
backgroundColor: "#191919",
|
|
1232
|
+
color: "#f2f2f2"
|
|
1233
|
+
},
|
|
1234
|
+
svg: {
|
|
1235
|
+
verticalAlign: "middle",
|
|
1236
|
+
width: "22px",
|
|
1237
|
+
height: "22px"
|
|
1238
|
+
},
|
|
1239
|
+
"&.arrow--left": {
|
|
1240
|
+
left: "-80px"
|
|
1241
|
+
},
|
|
1242
|
+
"&.arrow--right": {
|
|
1243
|
+
right: "-80px"
|
|
1244
|
+
},
|
|
1245
|
+
"&.arrow--disabled": {
|
|
1246
|
+
opacity: 0.5
|
|
1247
|
+
}
|
|
1248
|
+
}
|
|
1249
|
+
},
|
|
1250
|
+
"@mobile": {
|
|
1251
|
+
".wv-slider-arrow": {
|
|
1252
|
+
display: "none"
|
|
1253
|
+
}
|
|
1254
|
+
}
|
|
1255
|
+
};
|
|
1256
|
+
|
|
1257
|
+
// src/components/Slider/ResizePlugin.ts
|
|
1258
|
+
var ResizePlugin = (slider) => {
|
|
1259
|
+
let observer = new ResizeObserver(() => slider.update());
|
|
1260
|
+
slider.on("created", () => {
|
|
1261
|
+
observer.observe(slider.container);
|
|
1262
|
+
});
|
|
1263
|
+
slider.on("destroyed", () => {
|
|
1264
|
+
observer.unobserve(slider.container);
|
|
1265
|
+
});
|
|
1266
|
+
};
|
|
1267
|
+
|
|
1268
|
+
// src/components/Slider/index.tsx
|
|
1269
|
+
function Slider({ children, className }) {
|
|
1270
|
+
let [currentSlide, setCurrentSlide] = (0, import_react24.useState)(0);
|
|
1271
|
+
let [created, setCreated] = (0, import_react24.useState)(false);
|
|
1272
|
+
let [ref, instanceRef] = (0, import_react23.useKeenSlider)(
|
|
1273
|
+
{
|
|
1274
|
+
slides: { perView: 4, spacing: 16 },
|
|
1275
|
+
breakpoints: {
|
|
1276
|
+
"(max-width: 1024px)": {
|
|
1277
|
+
slides: { perView: 3, spacing: 16 }
|
|
1278
|
+
},
|
|
1279
|
+
"(max-width: 768px)": {
|
|
1280
|
+
slides: {
|
|
1281
|
+
perView: 1,
|
|
1282
|
+
spacing: 32
|
|
1283
|
+
}
|
|
1284
|
+
}
|
|
1285
|
+
},
|
|
1286
|
+
created: () => {
|
|
1287
|
+
setCreated(true);
|
|
1288
|
+
},
|
|
1289
|
+
slideChanged: (slider) => {
|
|
1290
|
+
setCurrentSlide(slider.track.details.rel);
|
|
1291
|
+
}
|
|
1292
|
+
},
|
|
1293
|
+
[ResizePlugin]
|
|
1294
|
+
);
|
|
1295
|
+
let _className = (0, import_clsx4.default)("keen-slider", className);
|
|
1296
|
+
let arrowsClass = (0, import_clsx4.default)(className && `${className}-arrows`);
|
|
1297
|
+
return /* @__PURE__ */ import_react24.default.createElement(import_react24.default.Fragment, null, /* @__PURE__ */ import_react24.default.createElement("div", {
|
|
1298
|
+
ref,
|
|
1299
|
+
className: _className
|
|
1300
|
+
}, /* @__PURE__ */ import_react24.default.createElement("link", {
|
|
1301
|
+
rel: "stylesheet",
|
|
1302
|
+
href: "https://cdn.jsdelivr.net/npm/keen-slider@latest/keen-slider.min.css"
|
|
1303
|
+
}), children), created && instanceRef?.current && /* @__PURE__ */ import_react24.default.createElement(Arrows, {
|
|
1304
|
+
currentSlide,
|
|
1305
|
+
instanceRef,
|
|
1306
|
+
className: arrowsClass
|
|
1307
|
+
}));
|
|
1308
|
+
}
|
|
1309
|
+
|
|
1163
1310
|
// src/components/index.ts
|
|
1164
1311
|
var Components = {
|
|
1165
1312
|
Placeholder: Placeholder_default,
|
|
1166
1313
|
Spinner,
|
|
1167
1314
|
ModalComponents: Modal_exports,
|
|
1168
1315
|
Icon,
|
|
1316
|
+
Slider,
|
|
1169
1317
|
Tooltip
|
|
1170
1318
|
};
|
|
1171
1319
|
|
|
1172
1320
|
// src/elements/Instagram.tsx
|
|
1173
|
-
var Instagram = (0,
|
|
1321
|
+
var Instagram = (0, import_react25.forwardRef)(
|
|
1174
1322
|
(props, ref) => {
|
|
1175
1323
|
let { token, username, numberOfImages, imagesPerRow, gap, ...rest } = props;
|
|
1176
|
-
let [media, setMedia] = (0,
|
|
1177
|
-
let [error, setError] = (0,
|
|
1178
|
-
(0,
|
|
1324
|
+
let [media, setMedia] = (0, import_react25.useState)([]);
|
|
1325
|
+
let [error, setError] = (0, import_react25.useState)(null);
|
|
1326
|
+
(0, import_react25.useEffect)(() => {
|
|
1179
1327
|
if (token) {
|
|
1180
1328
|
let params = new URLSearchParams({
|
|
1181
1329
|
access_token: token,
|
|
@@ -1192,10 +1340,10 @@ var Instagram = (0, import_react22.forwardRef)(
|
|
|
1192
1340
|
}
|
|
1193
1341
|
}, [token]);
|
|
1194
1342
|
if (!token || error) {
|
|
1195
|
-
return /* @__PURE__ */
|
|
1343
|
+
return /* @__PURE__ */ import_react25.default.createElement("div", {
|
|
1196
1344
|
ref,
|
|
1197
1345
|
...rest
|
|
1198
|
-
}, /* @__PURE__ */
|
|
1346
|
+
}, /* @__PURE__ */ import_react25.default.createElement(Components.Placeholder, {
|
|
1199
1347
|
element: "Instagram"
|
|
1200
1348
|
}, !token ? "Connect to Instagram to display photos on your site." : "Invalid or expired token!"));
|
|
1201
1349
|
}
|
|
@@ -1203,11 +1351,11 @@ var Instagram = (0, import_react22.forwardRef)(
|
|
|
1203
1351
|
"--wv-ig-images-per-row": imagesPerRow,
|
|
1204
1352
|
"--wv-ig-images-gap": gap + "px"
|
|
1205
1353
|
};
|
|
1206
|
-
return /* @__PURE__ */
|
|
1354
|
+
return /* @__PURE__ */ import_react25.default.createElement("div", {
|
|
1207
1355
|
ref,
|
|
1208
1356
|
...rest,
|
|
1209
1357
|
style
|
|
1210
|
-
}, /* @__PURE__ */
|
|
1358
|
+
}, /* @__PURE__ */ import_react25.default.createElement("div", {
|
|
1211
1359
|
className: "wv-ig-media-container"
|
|
1212
1360
|
}, media.slice(0, numberOfImages).map((item) => {
|
|
1213
1361
|
let {
|
|
@@ -1219,21 +1367,21 @@ var Instagram = (0, import_react22.forwardRef)(
|
|
|
1219
1367
|
thumbnail_url
|
|
1220
1368
|
} = item;
|
|
1221
1369
|
if (media_type === "VIDEO") {
|
|
1222
|
-
return /* @__PURE__ */
|
|
1370
|
+
return /* @__PURE__ */ import_react25.default.createElement("video", {
|
|
1223
1371
|
key: id,
|
|
1224
1372
|
controls: true,
|
|
1225
1373
|
poster: thumbnail_url
|
|
1226
|
-
}, /* @__PURE__ */
|
|
1374
|
+
}, /* @__PURE__ */ import_react25.default.createElement("source", {
|
|
1227
1375
|
src: media_url,
|
|
1228
1376
|
type: "video/mp4"
|
|
1229
1377
|
}));
|
|
1230
1378
|
}
|
|
1231
|
-
return /* @__PURE__ */
|
|
1379
|
+
return /* @__PURE__ */ import_react25.default.createElement("a", {
|
|
1232
1380
|
key: id,
|
|
1233
1381
|
href: permalink,
|
|
1234
1382
|
target: "_blank",
|
|
1235
1383
|
rel: "noreferrer"
|
|
1236
|
-
}, /* @__PURE__ */
|
|
1384
|
+
}, /* @__PURE__ */ import_react25.default.createElement("img", {
|
|
1237
1385
|
alt: caption,
|
|
1238
1386
|
src: media_url
|
|
1239
1387
|
}));
|
|
@@ -1300,18 +1448,18 @@ var createRootContext = (configs) => {
|
|
|
1300
1448
|
});
|
|
1301
1449
|
return rootContext;
|
|
1302
1450
|
};
|
|
1303
|
-
var WeaverseContext = (0,
|
|
1451
|
+
var WeaverseContext = (0, import_react26.createContext)({});
|
|
1304
1452
|
var WeaverseContextProvider = WeaverseContext.Provider;
|
|
1305
1453
|
var WeaverseContextConsumer = WeaverseContext.Consumer;
|
|
1306
1454
|
|
|
1307
1455
|
// src/renderer.tsx
|
|
1308
1456
|
var import_core2 = require("@weaverse/core");
|
|
1309
|
-
var
|
|
1457
|
+
var import_react27 = __toESM(require("react"));
|
|
1310
1458
|
var WeaverseRoot = ({ context }) => {
|
|
1311
|
-
let [, setData] = (0,
|
|
1312
|
-
let rootRef = (0,
|
|
1459
|
+
let [, setData] = (0, import_react27.useState)(context.projectData);
|
|
1460
|
+
let rootRef = (0, import_react27.useRef)();
|
|
1313
1461
|
let renderRoot = () => setData({});
|
|
1314
|
-
(0,
|
|
1462
|
+
(0, import_react27.useEffect)(() => {
|
|
1315
1463
|
context.subscribe(renderRoot);
|
|
1316
1464
|
context.contentRootElement = rootRef.current;
|
|
1317
1465
|
return () => {
|
|
@@ -1321,23 +1469,23 @@ var WeaverseRoot = ({ context }) => {
|
|
|
1321
1469
|
let eventHandlers = context?.studioBridge?.eventHandlers || {};
|
|
1322
1470
|
let themeClass = context.stitchesInstance.theme.className;
|
|
1323
1471
|
if (context.projectData?.rootId) {
|
|
1324
|
-
return /* @__PURE__ */
|
|
1472
|
+
return /* @__PURE__ */ import_react27.default.createElement("div", {
|
|
1325
1473
|
className: `weaverse-content-root ${themeClass}`,
|
|
1326
1474
|
...eventHandlers,
|
|
1327
1475
|
ref: rootRef
|
|
1328
|
-
}, /* @__PURE__ */
|
|
1476
|
+
}, /* @__PURE__ */ import_react27.default.createElement(WeaverseContextProvider, {
|
|
1329
1477
|
value: context
|
|
1330
|
-
}, /* @__PURE__ */
|
|
1478
|
+
}, /* @__PURE__ */ import_react27.default.createElement(ItemInstance, {
|
|
1331
1479
|
id: context.projectData.rootId
|
|
1332
1480
|
})));
|
|
1333
1481
|
}
|
|
1334
1482
|
return null;
|
|
1335
1483
|
};
|
|
1336
1484
|
var ItemComponent = ({ instance }) => {
|
|
1337
|
-
let { stitchesInstance, elementInstances } = (0,
|
|
1338
|
-
let [data, setData] = (0,
|
|
1339
|
-
let { id, type, childIds = [], css:
|
|
1340
|
-
(0,
|
|
1485
|
+
let { stitchesInstance, elementInstances } = (0, import_react27.useContext)(WeaverseContext);
|
|
1486
|
+
let [data, setData] = (0, import_react27.useState)(instance.data);
|
|
1487
|
+
let { id, type, childIds = [], css: css10, className, ...rest } = data;
|
|
1488
|
+
(0, import_react27.useEffect)(() => {
|
|
1341
1489
|
let render = (data2) => setData({ ...data2 });
|
|
1342
1490
|
instance.subscribe(render);
|
|
1343
1491
|
if (import_core2.isBrowser && !instance.ref.current) {
|
|
@@ -1353,13 +1501,13 @@ var ItemComponent = ({ instance }) => {
|
|
|
1353
1501
|
if (Component.$$typeof === Symbol.for("react.forward_ref")) {
|
|
1354
1502
|
rest.ref = instance.ref;
|
|
1355
1503
|
}
|
|
1356
|
-
return /* @__PURE__ */
|
|
1504
|
+
return /* @__PURE__ */ import_react27.default.createElement(Component, {
|
|
1357
1505
|
key: id,
|
|
1358
1506
|
"data-wv-type": type,
|
|
1359
1507
|
"data-wv-id": id,
|
|
1360
1508
|
className: generateItemClassName(instance, stitchesInstance),
|
|
1361
1509
|
...rest
|
|
1362
|
-
}, childIds.map((id2) => /* @__PURE__ */
|
|
1510
|
+
}, childIds.map((id2) => /* @__PURE__ */ import_react27.default.createElement(ItemInstance, {
|
|
1363
1511
|
key: id2,
|
|
1364
1512
|
id: id2
|
|
1365
1513
|
})));
|
|
@@ -1369,15 +1517,15 @@ var ItemComponent = ({ instance }) => {
|
|
|
1369
1517
|
}
|
|
1370
1518
|
};
|
|
1371
1519
|
var ItemInstance = ({ id }) => {
|
|
1372
|
-
let context = (0,
|
|
1520
|
+
let context = (0, import_react27.useContext)(WeaverseContext);
|
|
1373
1521
|
let { itemInstances } = context;
|
|
1374
1522
|
let instance = itemInstances.get(id);
|
|
1375
1523
|
if (!instance) {
|
|
1376
|
-
return /* @__PURE__ */
|
|
1524
|
+
return /* @__PURE__ */ import_react27.default.createElement("div", {
|
|
1377
1525
|
style: { display: "none" }
|
|
1378
1526
|
}, "Item instance ", id, " not found");
|
|
1379
1527
|
}
|
|
1380
|
-
return /* @__PURE__ */
|
|
1528
|
+
return /* @__PURE__ */ import_react27.default.createElement(ItemComponent, {
|
|
1381
1529
|
key: id,
|
|
1382
1530
|
instance
|
|
1383
1531
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -91,15 +91,15 @@ var INSTAGRAM_API = "https://graph.instagram.com";
|
|
|
91
91
|
|
|
92
92
|
// src/utils/css.ts
|
|
93
93
|
import clsx from "clsx";
|
|
94
|
-
function formatCSS(
|
|
94
|
+
function formatCSS(css10) {
|
|
95
95
|
return {
|
|
96
|
-
"@desktop":
|
|
97
|
-
"@mobile":
|
|
96
|
+
"@desktop": css10["@desktop"],
|
|
97
|
+
"@mobile": css10["@mobile"]
|
|
98
98
|
};
|
|
99
99
|
}
|
|
100
100
|
var permanentClasses = {};
|
|
101
101
|
function generateItemClassName(instance, stitchesInstance) {
|
|
102
|
-
let { css:
|
|
102
|
+
let { css: css10, type, className: cls = "" } = instance.data;
|
|
103
103
|
let className = "";
|
|
104
104
|
let permanentClass = "";
|
|
105
105
|
let perCss = instance.Element?.permanentCss;
|
|
@@ -113,8 +113,8 @@ function generateItemClassName(instance, stitchesInstance) {
|
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
115
|
className = permanentClass;
|
|
116
|
-
if (
|
|
117
|
-
let formattedCss = formatCSS(
|
|
116
|
+
if (css10) {
|
|
117
|
+
let formattedCss = formatCSS(css10);
|
|
118
118
|
let newStitchesClass = stitchesInstance.css(formattedCss)().className || "";
|
|
119
119
|
let { stitchesClass } = instance;
|
|
120
120
|
let otherClass = (instance.ref.current?.className || "").replace(stitchesClass, "").replace(cls, "").replace(permanentClass, "").trim();
|
|
@@ -659,7 +659,7 @@ Video.defaultProps = {
|
|
|
659
659
|
var Video_default = Video;
|
|
660
660
|
|
|
661
661
|
// src/elements/Instagram.tsx
|
|
662
|
-
import
|
|
662
|
+
import React23, { forwardRef as forwardRef10, useEffect as useEffect4, useState as useState2 } from "react";
|
|
663
663
|
|
|
664
664
|
// src/components/Placeholder.tsx
|
|
665
665
|
import React15, { forwardRef as forwardRef8 } from "react";
|
|
@@ -961,7 +961,7 @@ var StyledOverlay = styled(Overlay2, {
|
|
|
961
961
|
display: "block !important",
|
|
962
962
|
backgroundColor: "rgba(0, 0, 0, .3)",
|
|
963
963
|
position: "fixed",
|
|
964
|
-
zIndex:
|
|
964
|
+
zIndex: 99999,
|
|
965
965
|
inset: 0,
|
|
966
966
|
animation: `${overlayShow} 300ms cubic-bezier(0.16, 1, 0.3, 1)`
|
|
967
967
|
});
|
|
@@ -984,7 +984,7 @@ var StyledContent = styled(Content, {
|
|
|
984
984
|
transform: "translate(-50%, -50%)",
|
|
985
985
|
padding: 24,
|
|
986
986
|
animation: `${contentShow} 300ms cubic-bezier(0.16, 1, 0.3, 1)`,
|
|
987
|
-
zIndex:
|
|
987
|
+
zIndex: 99999,
|
|
988
988
|
maxWidth: "90vw",
|
|
989
989
|
width: "auto",
|
|
990
990
|
"*": {
|
|
@@ -1010,8 +1010,8 @@ var StyledCloseIcon = styled("button", {
|
|
|
1010
1010
|
cursor: "pointer",
|
|
1011
1011
|
fontFamily: "inherit",
|
|
1012
1012
|
borderRadius: "100%",
|
|
1013
|
-
height:
|
|
1014
|
-
width:
|
|
1013
|
+
height: 32,
|
|
1014
|
+
width: 32,
|
|
1015
1015
|
padding: 4,
|
|
1016
1016
|
display: "inline-flex",
|
|
1017
1017
|
alignItems: "center",
|
|
@@ -1024,29 +1024,32 @@ var StyledCloseIcon = styled("button", {
|
|
|
1024
1024
|
backgroundColor: "rgba(112, 112, 112, .1)"
|
|
1025
1025
|
},
|
|
1026
1026
|
svg: {
|
|
1027
|
-
width:
|
|
1028
|
-
height:
|
|
1027
|
+
width: 24,
|
|
1028
|
+
height: 24
|
|
1029
1029
|
}
|
|
1030
1030
|
});
|
|
1031
1031
|
|
|
1032
1032
|
// src/components/Modal/useOpenChangeEffect.ts
|
|
1033
|
-
import { useEffect as useEffect2 } from "react";
|
|
1033
|
+
import { useContext as useContext4, useEffect as useEffect2 } from "react";
|
|
1034
1034
|
function useOpenChangeEffect(props) {
|
|
1035
1035
|
let { open, defaultOpen, onOpenChange } = props;
|
|
1036
|
+
let rootCtx = useContext4(WeaverseContext);
|
|
1037
|
+
let toggleRootzIndex = (open2) => {
|
|
1038
|
+
let { contentRootElement } = rootCtx;
|
|
1039
|
+
if (contentRootElement) {
|
|
1040
|
+
if (open2) {
|
|
1041
|
+
contentRootElement.classList.add("modal-open");
|
|
1042
|
+
} else {
|
|
1043
|
+
contentRootElement.classList.remove("modal-open");
|
|
1044
|
+
}
|
|
1045
|
+
}
|
|
1046
|
+
};
|
|
1036
1047
|
useEffect2(() => {
|
|
1037
1048
|
let isOpen = open || defaultOpen;
|
|
1038
|
-
|
|
1039
|
-
document.body.classList.add("wv-modal-open");
|
|
1040
|
-
} else {
|
|
1041
|
-
document.body.classList.remove("wv-modal-open");
|
|
1042
|
-
}
|
|
1049
|
+
toggleRootzIndex(isOpen);
|
|
1043
1050
|
}, [open, defaultOpen]);
|
|
1044
1051
|
let handleOpenChange = (open2) => {
|
|
1045
|
-
|
|
1046
|
-
document.body.classList.add("wv-modal-open");
|
|
1047
|
-
} else {
|
|
1048
|
-
document.body.classList.remove("wv-modal-open");
|
|
1049
|
-
}
|
|
1052
|
+
toggleRootzIndex(open2);
|
|
1050
1053
|
onOpenChange?.(open2);
|
|
1051
1054
|
};
|
|
1052
1055
|
return handleOpenChange;
|
|
@@ -1129,12 +1132,157 @@ function Tooltip({ children }) {
|
|
|
1129
1132
|
}, children);
|
|
1130
1133
|
}
|
|
1131
1134
|
|
|
1135
|
+
// src/components/Slider/index.tsx
|
|
1136
|
+
import clsx4 from "clsx";
|
|
1137
|
+
import { useKeenSlider } from "keen-slider/react";
|
|
1138
|
+
import React22, { useState } from "react";
|
|
1139
|
+
|
|
1140
|
+
// src/components/Slider/Arrows.tsx
|
|
1141
|
+
import clsx3 from "clsx";
|
|
1142
|
+
import React21, { useContext as useContext5 } from "react";
|
|
1143
|
+
function Arrows(props) {
|
|
1144
|
+
let { currentSlide, instanceRef, className } = props;
|
|
1145
|
+
let { stitchesInstance } = useContext5(WeaverseContext);
|
|
1146
|
+
let { className: cssClass } = stitchesInstance.css(css9)();
|
|
1147
|
+
let isFirstSlide = currentSlide === 0;
|
|
1148
|
+
let isLastSlide = false;
|
|
1149
|
+
if (instanceRef.current) {
|
|
1150
|
+
isLastSlide = currentSlide === instanceRef?.current?.track?.details?.maxIdx;
|
|
1151
|
+
}
|
|
1152
|
+
let _className = clsx3(className, cssClass);
|
|
1153
|
+
let arrowLeftClass = clsx3(
|
|
1154
|
+
"wv-slider-arrow arrow--left",
|
|
1155
|
+
isFirstSlide && "arrow--disabled"
|
|
1156
|
+
);
|
|
1157
|
+
let arrowRightClass = clsx3(
|
|
1158
|
+
"wv-slider-arrow arrow--right",
|
|
1159
|
+
isLastSlide && "arrow--disabled"
|
|
1160
|
+
);
|
|
1161
|
+
return /* @__PURE__ */ React21.createElement("div", {
|
|
1162
|
+
className: _className
|
|
1163
|
+
}, /* @__PURE__ */ React21.createElement("button", {
|
|
1164
|
+
type: "button",
|
|
1165
|
+
className: arrowLeftClass,
|
|
1166
|
+
onClick: (e) => {
|
|
1167
|
+
e.stopPropagation();
|
|
1168
|
+
instanceRef?.current?.prev();
|
|
1169
|
+
}
|
|
1170
|
+
}, /* @__PURE__ */ React21.createElement(Icon, {
|
|
1171
|
+
name: "ArrowLeft"
|
|
1172
|
+
})), /* @__PURE__ */ React21.createElement("button", {
|
|
1173
|
+
type: "button",
|
|
1174
|
+
className: arrowRightClass,
|
|
1175
|
+
onClick: (e) => {
|
|
1176
|
+
e.stopPropagation();
|
|
1177
|
+
instanceRef?.current?.next();
|
|
1178
|
+
}
|
|
1179
|
+
}, /* @__PURE__ */ React21.createElement(Icon, {
|
|
1180
|
+
name: "ArrowRight"
|
|
1181
|
+
})));
|
|
1182
|
+
}
|
|
1183
|
+
var css9 = {
|
|
1184
|
+
"@desktop": {
|
|
1185
|
+
".wv-slider-arrow": {
|
|
1186
|
+
position: "absolute",
|
|
1187
|
+
top: "50%",
|
|
1188
|
+
transform: "translateY(-50%)",
|
|
1189
|
+
width: "44px",
|
|
1190
|
+
height: "44px",
|
|
1191
|
+
padding: "8px",
|
|
1192
|
+
color: "#191919",
|
|
1193
|
+
backgroundColor: "#f2f2f2",
|
|
1194
|
+
textAlign: "center",
|
|
1195
|
+
transition: "all 0.2s ease-in-out",
|
|
1196
|
+
borderRadius: "4px",
|
|
1197
|
+
border: "none",
|
|
1198
|
+
cursor: "pointer",
|
|
1199
|
+
"&:hover": {
|
|
1200
|
+
backgroundColor: "#191919",
|
|
1201
|
+
color: "#f2f2f2"
|
|
1202
|
+
},
|
|
1203
|
+
svg: {
|
|
1204
|
+
verticalAlign: "middle",
|
|
1205
|
+
width: "22px",
|
|
1206
|
+
height: "22px"
|
|
1207
|
+
},
|
|
1208
|
+
"&.arrow--left": {
|
|
1209
|
+
left: "-80px"
|
|
1210
|
+
},
|
|
1211
|
+
"&.arrow--right": {
|
|
1212
|
+
right: "-80px"
|
|
1213
|
+
},
|
|
1214
|
+
"&.arrow--disabled": {
|
|
1215
|
+
opacity: 0.5
|
|
1216
|
+
}
|
|
1217
|
+
}
|
|
1218
|
+
},
|
|
1219
|
+
"@mobile": {
|
|
1220
|
+
".wv-slider-arrow": {
|
|
1221
|
+
display: "none"
|
|
1222
|
+
}
|
|
1223
|
+
}
|
|
1224
|
+
};
|
|
1225
|
+
|
|
1226
|
+
// src/components/Slider/ResizePlugin.ts
|
|
1227
|
+
var ResizePlugin = (slider) => {
|
|
1228
|
+
let observer = new ResizeObserver(() => slider.update());
|
|
1229
|
+
slider.on("created", () => {
|
|
1230
|
+
observer.observe(slider.container);
|
|
1231
|
+
});
|
|
1232
|
+
slider.on("destroyed", () => {
|
|
1233
|
+
observer.unobserve(slider.container);
|
|
1234
|
+
});
|
|
1235
|
+
};
|
|
1236
|
+
|
|
1237
|
+
// src/components/Slider/index.tsx
|
|
1238
|
+
function Slider({ children, className }) {
|
|
1239
|
+
let [currentSlide, setCurrentSlide] = useState(0);
|
|
1240
|
+
let [created, setCreated] = useState(false);
|
|
1241
|
+
let [ref, instanceRef] = useKeenSlider(
|
|
1242
|
+
{
|
|
1243
|
+
slides: { perView: 4, spacing: 16 },
|
|
1244
|
+
breakpoints: {
|
|
1245
|
+
"(max-width: 1024px)": {
|
|
1246
|
+
slides: { perView: 3, spacing: 16 }
|
|
1247
|
+
},
|
|
1248
|
+
"(max-width: 768px)": {
|
|
1249
|
+
slides: {
|
|
1250
|
+
perView: 1,
|
|
1251
|
+
spacing: 32
|
|
1252
|
+
}
|
|
1253
|
+
}
|
|
1254
|
+
},
|
|
1255
|
+
created: () => {
|
|
1256
|
+
setCreated(true);
|
|
1257
|
+
},
|
|
1258
|
+
slideChanged: (slider) => {
|
|
1259
|
+
setCurrentSlide(slider.track.details.rel);
|
|
1260
|
+
}
|
|
1261
|
+
},
|
|
1262
|
+
[ResizePlugin]
|
|
1263
|
+
);
|
|
1264
|
+
let _className = clsx4("keen-slider", className);
|
|
1265
|
+
let arrowsClass = clsx4(className && `${className}-arrows`);
|
|
1266
|
+
return /* @__PURE__ */ React22.createElement(React22.Fragment, null, /* @__PURE__ */ React22.createElement("div", {
|
|
1267
|
+
ref,
|
|
1268
|
+
className: _className
|
|
1269
|
+
}, /* @__PURE__ */ React22.createElement("link", {
|
|
1270
|
+
rel: "stylesheet",
|
|
1271
|
+
href: "https://cdn.jsdelivr.net/npm/keen-slider@latest/keen-slider.min.css"
|
|
1272
|
+
}), children), created && instanceRef?.current && /* @__PURE__ */ React22.createElement(Arrows, {
|
|
1273
|
+
currentSlide,
|
|
1274
|
+
instanceRef,
|
|
1275
|
+
className: arrowsClass
|
|
1276
|
+
}));
|
|
1277
|
+
}
|
|
1278
|
+
|
|
1132
1279
|
// src/components/index.ts
|
|
1133
1280
|
var Components = {
|
|
1134
1281
|
Placeholder: Placeholder_default,
|
|
1135
1282
|
Spinner,
|
|
1136
1283
|
ModalComponents: Modal_exports,
|
|
1137
1284
|
Icon,
|
|
1285
|
+
Slider,
|
|
1138
1286
|
Tooltip
|
|
1139
1287
|
};
|
|
1140
1288
|
|
|
@@ -1142,8 +1290,8 @@ var Components = {
|
|
|
1142
1290
|
var Instagram = forwardRef10(
|
|
1143
1291
|
(props, ref) => {
|
|
1144
1292
|
let { token, username, numberOfImages, imagesPerRow, gap, ...rest } = props;
|
|
1145
|
-
let [media, setMedia] =
|
|
1146
|
-
let [error, setError] =
|
|
1293
|
+
let [media, setMedia] = useState2([]);
|
|
1294
|
+
let [error, setError] = useState2(null);
|
|
1147
1295
|
useEffect4(() => {
|
|
1148
1296
|
if (token) {
|
|
1149
1297
|
let params = new URLSearchParams({
|
|
@@ -1161,10 +1309,10 @@ var Instagram = forwardRef10(
|
|
|
1161
1309
|
}
|
|
1162
1310
|
}, [token]);
|
|
1163
1311
|
if (!token || error) {
|
|
1164
|
-
return /* @__PURE__ */
|
|
1312
|
+
return /* @__PURE__ */ React23.createElement("div", {
|
|
1165
1313
|
ref,
|
|
1166
1314
|
...rest
|
|
1167
|
-
}, /* @__PURE__ */
|
|
1315
|
+
}, /* @__PURE__ */ React23.createElement(Components.Placeholder, {
|
|
1168
1316
|
element: "Instagram"
|
|
1169
1317
|
}, !token ? "Connect to Instagram to display photos on your site." : "Invalid or expired token!"));
|
|
1170
1318
|
}
|
|
@@ -1172,11 +1320,11 @@ var Instagram = forwardRef10(
|
|
|
1172
1320
|
"--wv-ig-images-per-row": imagesPerRow,
|
|
1173
1321
|
"--wv-ig-images-gap": gap + "px"
|
|
1174
1322
|
};
|
|
1175
|
-
return /* @__PURE__ */
|
|
1323
|
+
return /* @__PURE__ */ React23.createElement("div", {
|
|
1176
1324
|
ref,
|
|
1177
1325
|
...rest,
|
|
1178
1326
|
style
|
|
1179
|
-
}, /* @__PURE__ */
|
|
1327
|
+
}, /* @__PURE__ */ React23.createElement("div", {
|
|
1180
1328
|
className: "wv-ig-media-container"
|
|
1181
1329
|
}, media.slice(0, numberOfImages).map((item) => {
|
|
1182
1330
|
let {
|
|
@@ -1188,21 +1336,21 @@ var Instagram = forwardRef10(
|
|
|
1188
1336
|
thumbnail_url
|
|
1189
1337
|
} = item;
|
|
1190
1338
|
if (media_type === "VIDEO") {
|
|
1191
|
-
return /* @__PURE__ */
|
|
1339
|
+
return /* @__PURE__ */ React23.createElement("video", {
|
|
1192
1340
|
key: id,
|
|
1193
1341
|
controls: true,
|
|
1194
1342
|
poster: thumbnail_url
|
|
1195
|
-
}, /* @__PURE__ */
|
|
1343
|
+
}, /* @__PURE__ */ React23.createElement("source", {
|
|
1196
1344
|
src: media_url,
|
|
1197
1345
|
type: "video/mp4"
|
|
1198
1346
|
}));
|
|
1199
1347
|
}
|
|
1200
|
-
return /* @__PURE__ */
|
|
1348
|
+
return /* @__PURE__ */ React23.createElement("a", {
|
|
1201
1349
|
key: id,
|
|
1202
1350
|
href: permalink,
|
|
1203
1351
|
target: "_blank",
|
|
1204
1352
|
rel: "noreferrer"
|
|
1205
|
-
}, /* @__PURE__ */
|
|
1353
|
+
}, /* @__PURE__ */ React23.createElement("img", {
|
|
1206
1354
|
alt: caption,
|
|
1207
1355
|
src: media_url
|
|
1208
1356
|
}));
|
|
@@ -1275,9 +1423,9 @@ var WeaverseContextConsumer = WeaverseContext.Consumer;
|
|
|
1275
1423
|
|
|
1276
1424
|
// src/renderer.tsx
|
|
1277
1425
|
import { isBrowser } from "@weaverse/core";
|
|
1278
|
-
import
|
|
1426
|
+
import React24, { useContext as useContext6, useEffect as useEffect5, useRef, useState as useState3 } from "react";
|
|
1279
1427
|
var WeaverseRoot = ({ context }) => {
|
|
1280
|
-
let [, setData] =
|
|
1428
|
+
let [, setData] = useState3(context.projectData);
|
|
1281
1429
|
let rootRef = useRef();
|
|
1282
1430
|
let renderRoot = () => setData({});
|
|
1283
1431
|
useEffect5(() => {
|
|
@@ -1290,22 +1438,22 @@ var WeaverseRoot = ({ context }) => {
|
|
|
1290
1438
|
let eventHandlers = context?.studioBridge?.eventHandlers || {};
|
|
1291
1439
|
let themeClass = context.stitchesInstance.theme.className;
|
|
1292
1440
|
if (context.projectData?.rootId) {
|
|
1293
|
-
return /* @__PURE__ */
|
|
1441
|
+
return /* @__PURE__ */ React24.createElement("div", {
|
|
1294
1442
|
className: `weaverse-content-root ${themeClass}`,
|
|
1295
1443
|
...eventHandlers,
|
|
1296
1444
|
ref: rootRef
|
|
1297
|
-
}, /* @__PURE__ */
|
|
1445
|
+
}, /* @__PURE__ */ React24.createElement(WeaverseContextProvider, {
|
|
1298
1446
|
value: context
|
|
1299
|
-
}, /* @__PURE__ */
|
|
1447
|
+
}, /* @__PURE__ */ React24.createElement(ItemInstance, {
|
|
1300
1448
|
id: context.projectData.rootId
|
|
1301
1449
|
})));
|
|
1302
1450
|
}
|
|
1303
1451
|
return null;
|
|
1304
1452
|
};
|
|
1305
1453
|
var ItemComponent = ({ instance }) => {
|
|
1306
|
-
let { stitchesInstance, elementInstances } =
|
|
1307
|
-
let [data, setData] =
|
|
1308
|
-
let { id, type, childIds = [], css:
|
|
1454
|
+
let { stitchesInstance, elementInstances } = useContext6(WeaverseContext);
|
|
1455
|
+
let [data, setData] = useState3(instance.data);
|
|
1456
|
+
let { id, type, childIds = [], css: css10, className, ...rest } = data;
|
|
1309
1457
|
useEffect5(() => {
|
|
1310
1458
|
let render = (data2) => setData({ ...data2 });
|
|
1311
1459
|
instance.subscribe(render);
|
|
@@ -1322,13 +1470,13 @@ var ItemComponent = ({ instance }) => {
|
|
|
1322
1470
|
if (Component.$$typeof === Symbol.for("react.forward_ref")) {
|
|
1323
1471
|
rest.ref = instance.ref;
|
|
1324
1472
|
}
|
|
1325
|
-
return /* @__PURE__ */
|
|
1473
|
+
return /* @__PURE__ */ React24.createElement(Component, {
|
|
1326
1474
|
key: id,
|
|
1327
1475
|
"data-wv-type": type,
|
|
1328
1476
|
"data-wv-id": id,
|
|
1329
1477
|
className: generateItemClassName(instance, stitchesInstance),
|
|
1330
1478
|
...rest
|
|
1331
|
-
}, childIds.map((id2) => /* @__PURE__ */
|
|
1479
|
+
}, childIds.map((id2) => /* @__PURE__ */ React24.createElement(ItemInstance, {
|
|
1332
1480
|
key: id2,
|
|
1333
1481
|
id: id2
|
|
1334
1482
|
})));
|
|
@@ -1338,15 +1486,15 @@ var ItemComponent = ({ instance }) => {
|
|
|
1338
1486
|
}
|
|
1339
1487
|
};
|
|
1340
1488
|
var ItemInstance = ({ id }) => {
|
|
1341
|
-
let context =
|
|
1489
|
+
let context = useContext6(WeaverseContext);
|
|
1342
1490
|
let { itemInstances } = context;
|
|
1343
1491
|
let instance = itemInstances.get(id);
|
|
1344
1492
|
if (!instance) {
|
|
1345
|
-
return /* @__PURE__ */
|
|
1493
|
+
return /* @__PURE__ */ React24.createElement("div", {
|
|
1346
1494
|
style: { display: "none" }
|
|
1347
1495
|
}, "Item instance ", id, " not found");
|
|
1348
1496
|
}
|
|
1349
|
-
return /* @__PURE__ */
|
|
1497
|
+
return /* @__PURE__ */ React24.createElement(ItemComponent, {
|
|
1350
1498
|
key: id,
|
|
1351
1499
|
instance
|
|
1352
1500
|
});
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.7.
|
|
2
|
+
"version": "0.7.55",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"typings": "dist/index.d.ts",
|
|
@@ -34,7 +34,8 @@
|
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@radix-ui/react-dialog": "^1.0.2",
|
|
36
36
|
"@stitches/react": "^1.2.8",
|
|
37
|
-
"@weaverse/core": "0.7.
|
|
38
|
-
"clsx": "^1.2.1"
|
|
37
|
+
"@weaverse/core": "0.7.55",
|
|
38
|
+
"clsx": "^1.2.1",
|
|
39
|
+
"keen-slider": "^6.8.5"
|
|
39
40
|
}
|
|
40
41
|
}
|