@weaverse/react 0.6.23 → 0.6.27
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.js +78 -42
- package/package.json +2 -2
- package/dist/index.d.ts +0 -92
- package/dist/index.mjs +0 -779
package/dist/index.js
CHANGED
|
@@ -224,7 +224,7 @@ Countdown.defaultProps = {
|
|
|
224
224
|
width: 48,
|
|
225
225
|
textAlign: "center"
|
|
226
226
|
},
|
|
227
|
-
"
|
|
227
|
+
".wv-countdown-label": {
|
|
228
228
|
fontSize: 10
|
|
229
229
|
},
|
|
230
230
|
"& > span": {
|
|
@@ -241,23 +241,58 @@ var countdown_default = Countdown;
|
|
|
241
241
|
// src/elements/image.tsx
|
|
242
242
|
var import_react4 = __toESM(require("react"));
|
|
243
243
|
var Image = import_react4.default.forwardRef((props, ref) => {
|
|
244
|
-
let
|
|
245
|
-
|
|
244
|
+
let { isDesignMode } = (0, import_react4.useContext)(WeaverseContext);
|
|
245
|
+
let _a = props, {
|
|
246
|
+
src,
|
|
247
|
+
alt,
|
|
248
|
+
objectFit,
|
|
249
|
+
objectPosition,
|
|
250
|
+
onClickAction,
|
|
251
|
+
openLinkInNewTab
|
|
252
|
+
} = _a, rest = __objRest(_a, [
|
|
253
|
+
"src",
|
|
254
|
+
"alt",
|
|
255
|
+
"objectFit",
|
|
256
|
+
"objectPosition",
|
|
257
|
+
"onClickAction",
|
|
258
|
+
"openLinkInNewTab"
|
|
259
|
+
]);
|
|
260
|
+
let style = {
|
|
261
|
+
"--wv-img-object-fit": objectFit,
|
|
262
|
+
"--wv-img-object-position": objectPosition
|
|
263
|
+
};
|
|
264
|
+
let handleClick = () => {
|
|
265
|
+
if (isDesignMode) {
|
|
266
|
+
return console.log("Click action:", onClickAction);
|
|
267
|
+
}
|
|
268
|
+
if (onClickAction) {
|
|
269
|
+
console.log("TODO: click action:", onClickAction);
|
|
270
|
+
}
|
|
271
|
+
};
|
|
272
|
+
return /* @__PURE__ */ import_react4.default.createElement("div", __spreadProps(__spreadValues({
|
|
246
273
|
ref
|
|
247
|
-
}, rest),
|
|
274
|
+
}, rest), {
|
|
275
|
+
style,
|
|
276
|
+
onClick: handleClick
|
|
277
|
+
}), /* @__PURE__ */ import_react4.default.createElement("img", {
|
|
248
278
|
alt,
|
|
249
279
|
src
|
|
250
280
|
}));
|
|
251
281
|
});
|
|
252
282
|
Image.defaultProps = {
|
|
253
283
|
src: "https://ucarecdn.com/1cdc9d39-ca62-492e-8ec7-f1a86b241a90/",
|
|
254
|
-
alt: "
|
|
284
|
+
alt: "Image alt text",
|
|
285
|
+
objectFit: "cover",
|
|
286
|
+
objectPosition: "center",
|
|
287
|
+
onClickAction: "open-lightbox",
|
|
288
|
+
openLinkInNewTab: false,
|
|
255
289
|
css: {
|
|
256
290
|
"@desktop": {
|
|
257
291
|
img: {
|
|
258
292
|
width: "100%",
|
|
259
293
|
height: "100%",
|
|
260
|
-
objectFit: "cover"
|
|
294
|
+
objectFit: "var(--wv-img-object-fit, cover)",
|
|
295
|
+
objectPosition: "var(--wv-img-object-position, center)"
|
|
261
296
|
}
|
|
262
297
|
}
|
|
263
298
|
}
|
|
@@ -434,10 +469,9 @@ var Placeholder_default = Placeholder;
|
|
|
434
469
|
// src/elements/instagram.tsx
|
|
435
470
|
var INSTAGRAM_API = "https://graph.instagram.com";
|
|
436
471
|
var Instagram = (0, import_react9.forwardRef)((props, ref) => {
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
let { isDesignMode } = (0, import_react9.useContext)(WeaverseContext);
|
|
472
|
+
let _a = props, { token, username, numberOfImages, imagesPerRow, gap } = _a, rest = __objRest(_a, ["token", "username", "numberOfImages", "imagesPerRow", "gap"]);
|
|
473
|
+
let [media, setMedia] = (0, import_react9.useState)([]);
|
|
474
|
+
let [error, setError] = (0, import_react9.useState)(null);
|
|
441
475
|
(0, import_react9.useEffect)(() => {
|
|
442
476
|
if (token) {
|
|
443
477
|
let params = new URLSearchParams({
|
|
@@ -463,7 +497,7 @@ var Instagram = (0, import_react9.forwardRef)((props, ref) => {
|
|
|
463
497
|
}
|
|
464
498
|
let style = {
|
|
465
499
|
"--wv-ig-images-per-row": imagesPerRow,
|
|
466
|
-
"--wv-ig-images-gap": gap
|
|
500
|
+
"--wv-ig-images-gap": gap + "px"
|
|
467
501
|
};
|
|
468
502
|
return /* @__PURE__ */ import_react9.default.createElement("div", __spreadProps(__spreadValues({
|
|
469
503
|
ref
|
|
@@ -472,15 +506,15 @@ var Instagram = (0, import_react9.forwardRef)((props, ref) => {
|
|
|
472
506
|
}), /* @__PURE__ */ import_react9.default.createElement("div", {
|
|
473
507
|
className: "wv-ig-media-container"
|
|
474
508
|
}, media.slice(0, numberOfImages).map((item) => {
|
|
475
|
-
let
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
},
|
|
482
|
-
alt:
|
|
483
|
-
src:
|
|
509
|
+
let { id, permalink, caption, media_url } = item;
|
|
510
|
+
return /* @__PURE__ */ import_react9.default.createElement("a", {
|
|
511
|
+
key: id,
|
|
512
|
+
href: permalink,
|
|
513
|
+
target: "_blank",
|
|
514
|
+
rel: "noreferrer"
|
|
515
|
+
}, /* @__PURE__ */ import_react9.default.createElement("img", {
|
|
516
|
+
alt: caption,
|
|
517
|
+
src: media_url
|
|
484
518
|
}));
|
|
485
519
|
})));
|
|
486
520
|
});
|
|
@@ -554,14 +588,14 @@ Accordion.defaultProps = {
|
|
|
554
588
|
gap: 4,
|
|
555
589
|
".wv-accordion-header": {
|
|
556
590
|
borderRadius: 4,
|
|
557
|
-
padding:
|
|
591
|
+
padding: 12,
|
|
558
592
|
marginBottom: 4,
|
|
559
|
-
|
|
593
|
+
border: "1px solid #76A9FA",
|
|
560
594
|
"&.active": {
|
|
561
595
|
color: "blue"
|
|
562
596
|
},
|
|
563
597
|
'&.active + [data-wv-type="accordion.content"]': {
|
|
564
|
-
|
|
598
|
+
maxHeight: "var(--max-height, inherit)"
|
|
565
599
|
}
|
|
566
600
|
}
|
|
567
601
|
}
|
|
@@ -572,18 +606,17 @@ var accordion_default = Accordion;
|
|
|
572
606
|
// src/elements/accordion/AccordionWrapper.tsx
|
|
573
607
|
var import_react11 = __toESM(require("react"));
|
|
574
608
|
var AccordionWrapper = (0, import_react11.forwardRef)((props, ref) => {
|
|
575
|
-
const _a = props, {
|
|
609
|
+
const _a = props, { ["data-wv-id"]: wvId, headerText, children } = _a, rest = __objRest(_a, ["data-wv-id", "headerText", "children"]);
|
|
576
610
|
const { active, setActive } = (0, import_react11.useContext)(AccordionContext);
|
|
577
611
|
return /* @__PURE__ */ import_react11.default.createElement("div", __spreadValues({
|
|
578
612
|
ref
|
|
579
613
|
}, rest), /* @__PURE__ */ import_react11.default.createElement("div", {
|
|
580
|
-
onClick: () => setActive(
|
|
581
|
-
className: `wv-accordion-header ${active ===
|
|
582
|
-
}, headerText
|
|
614
|
+
onClick: () => setActive(wvId),
|
|
615
|
+
className: `wv-accordion-header ${active === wvId ? "active" : ""}`
|
|
616
|
+
}, headerText), children);
|
|
583
617
|
});
|
|
584
618
|
AccordionWrapper.defaultProps = {
|
|
585
|
-
|
|
586
|
-
headerText: "Header 1",
|
|
619
|
+
headerText: "Header text",
|
|
587
620
|
css: {
|
|
588
621
|
"@desktop": {
|
|
589
622
|
maxHeight: "100%"
|
|
@@ -600,7 +633,9 @@ var AccordionContent = (0, import_react12.forwardRef)((props, ref) => {
|
|
|
600
633
|
"--rows": rows,
|
|
601
634
|
"--columns": columns,
|
|
602
635
|
"--gap": gap + "px",
|
|
603
|
-
"--row-size": rowSize + "px"
|
|
636
|
+
"--row-size": rowSize + "px",
|
|
637
|
+
"--col-size": "calc((var(--grid-size) - calc(var(--columns) - 1) * var(--gap)) / var(--columns))",
|
|
638
|
+
"--max-height": rows * rowSize + gap * (rowSize - 1) + "px"
|
|
604
639
|
};
|
|
605
640
|
return /* @__PURE__ */ import_react12.default.createElement("div", __spreadProps(__spreadValues({
|
|
606
641
|
ref
|
|
@@ -618,10 +653,14 @@ AccordionContent.defaultProps = {
|
|
|
618
653
|
css: {
|
|
619
654
|
"@desktop": {
|
|
620
655
|
width: "100%",
|
|
621
|
-
|
|
622
|
-
display: "
|
|
623
|
-
|
|
624
|
-
|
|
656
|
+
maxWidth: "var(--grid-size)",
|
|
657
|
+
display: "grid",
|
|
658
|
+
gridTemplateRows: "repeat(var(--rows), var(--row-size))",
|
|
659
|
+
gridTemplateColumns: "repeat(var(--columns), minmax(0, var(--col-size)))",
|
|
660
|
+
gap: "var(--gap)",
|
|
661
|
+
overflow: "hidden",
|
|
662
|
+
maxHeight: 0,
|
|
663
|
+
transition: "all 0.3s ease-in-out",
|
|
625
664
|
borderRadius: 4
|
|
626
665
|
}
|
|
627
666
|
}
|
|
@@ -722,15 +761,12 @@ function generateItemClass(instance, stitchesInstance) {
|
|
|
722
761
|
|
|
723
762
|
// src/renderer.tsx
|
|
724
763
|
var WeaverseRoot = ({ context }) => {
|
|
725
|
-
var _a;
|
|
764
|
+
var _a, _b;
|
|
726
765
|
let [, setData] = (0, import_react14.useState)(context.projectData);
|
|
727
766
|
let rootRef = (0, import_react14.useRef)();
|
|
767
|
+
let update = () => setData({});
|
|
728
768
|
(0, import_react14.useEffect)(() => {
|
|
729
|
-
let update = () => setData({});
|
|
730
769
|
context.subscribe(update);
|
|
731
|
-
if (context.projectData) {
|
|
732
|
-
setTimeout(update, 110);
|
|
733
|
-
}
|
|
734
770
|
context.contentRootElement = rootRef.current;
|
|
735
771
|
return () => {
|
|
736
772
|
context.unsubscribe(update);
|
|
@@ -738,15 +774,15 @@ var WeaverseRoot = ({ context }) => {
|
|
|
738
774
|
}, []);
|
|
739
775
|
let eventHandlers = ((_a = context == null ? void 0 : context.studioBridge) == null ? void 0 : _a.eventHandlers) || {};
|
|
740
776
|
let themeClass = context.stitchesInstance.theme.className;
|
|
741
|
-
return /* @__PURE__ */ import_react14.default.createElement("div", __spreadProps(__spreadValues({
|
|
777
|
+
return ((_b = context.projectData) == null ? void 0 : _b.rootId) ? /* @__PURE__ */ import_react14.default.createElement("div", __spreadProps(__spreadValues({
|
|
742
778
|
className: `weaverse-content-root ${themeClass}`
|
|
743
779
|
}, eventHandlers), {
|
|
744
780
|
ref: rootRef
|
|
745
781
|
}), /* @__PURE__ */ import_react14.default.createElement(WeaverseContextProvider, {
|
|
746
782
|
value: context
|
|
747
783
|
}, /* @__PURE__ */ import_react14.default.createElement(ItemInstance, {
|
|
748
|
-
id: context.projectData.rootId
|
|
749
|
-
})));
|
|
784
|
+
id: context.projectData.rootId
|
|
785
|
+
}))) : null;
|
|
750
786
|
};
|
|
751
787
|
var ItemComponent = ({ instance }) => {
|
|
752
788
|
let { stitchesInstance, elementInstances } = (0, import_react14.useContext)(WeaverseContext);
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.6.
|
|
2
|
+
"version": "0.6.27",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"typings": "dist/index.d.ts",
|
|
@@ -31,6 +31,6 @@
|
|
|
31
31
|
"name": "@weaverse/react",
|
|
32
32
|
"author": "Weaverse Team",
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@weaverse/core": "0.6.
|
|
34
|
+
"@weaverse/core": "0.6.27"
|
|
35
35
|
}
|
|
36
36
|
}
|
package/dist/index.d.ts
DELETED
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import * as react from 'react';
|
|
2
|
-
import { ReactElement, ReactNode } from 'react';
|
|
3
|
-
import { WeaverseType, Weaverse, ElementCSS, WeaverseItemStore } from '@weaverse/core';
|
|
4
|
-
export * from '@weaverse/core';
|
|
5
|
-
|
|
6
|
-
declare let createRootContext: (configs: WeaverseType) => Weaverse;
|
|
7
|
-
declare let WeaverseContext: react.Context<Weaverse>;
|
|
8
|
-
declare let WeaverseContextProvider: react.Provider<Weaverse>;
|
|
9
|
-
declare let WeaverseContextConsumer: react.Consumer<Weaverse>;
|
|
10
|
-
|
|
11
|
-
interface WeaverseElementProps extends ReactElement {
|
|
12
|
-
css?: ElementCSS;
|
|
13
|
-
children?: ReactElement | ReactElement[] | ReactNode | ReactNode[];
|
|
14
|
-
}
|
|
15
|
-
declare type WeaverseRootPropsType = {
|
|
16
|
-
context: Weaverse;
|
|
17
|
-
};
|
|
18
|
-
declare type ItemComponentProps = {
|
|
19
|
-
instance: InstanceType<typeof WeaverseItemStore>;
|
|
20
|
-
};
|
|
21
|
-
interface PlaceholderProps extends WeaverseElementProps {
|
|
22
|
-
element: string;
|
|
23
|
-
}
|
|
24
|
-
interface ButtonElementProps extends WeaverseElementProps {
|
|
25
|
-
value: string;
|
|
26
|
-
openInNewTab: boolean;
|
|
27
|
-
target: string;
|
|
28
|
-
type: 'button' | 'submit' | 'reset';
|
|
29
|
-
}
|
|
30
|
-
interface ContainerElementProps extends WeaverseElementProps {
|
|
31
|
-
[key: string]: any;
|
|
32
|
-
}
|
|
33
|
-
interface ImageElementProps extends WeaverseElementProps {
|
|
34
|
-
src: string;
|
|
35
|
-
alt: string;
|
|
36
|
-
}
|
|
37
|
-
interface LayoutElementProps extends WeaverseElementProps {
|
|
38
|
-
gridSize: number;
|
|
39
|
-
rows: number;
|
|
40
|
-
columns: number;
|
|
41
|
-
gap: number;
|
|
42
|
-
rowSize: number;
|
|
43
|
-
}
|
|
44
|
-
interface MapElementProps extends WeaverseElementProps {
|
|
45
|
-
place: string;
|
|
46
|
-
zoom: number;
|
|
47
|
-
}
|
|
48
|
-
interface TextElementProps extends WeaverseElementProps {
|
|
49
|
-
value: string;
|
|
50
|
-
}
|
|
51
|
-
interface VideoElementProps extends WeaverseElementProps {
|
|
52
|
-
src: string;
|
|
53
|
-
poster: string;
|
|
54
|
-
loop: boolean;
|
|
55
|
-
type: string;
|
|
56
|
-
controls: boolean;
|
|
57
|
-
autoPlay: boolean;
|
|
58
|
-
muted: boolean;
|
|
59
|
-
}
|
|
60
|
-
declare type CountdownTimeKey = 'days' | 'hours' | 'minutes' | 'seconds';
|
|
61
|
-
interface CountdownElementProps extends WeaverseElementProps {
|
|
62
|
-
timerType: 'fixed-time' | 'evergreen';
|
|
63
|
-
startTime: number;
|
|
64
|
-
endTime: number;
|
|
65
|
-
periods: number;
|
|
66
|
-
redirectUrl: string;
|
|
67
|
-
openInNewTab: boolean;
|
|
68
|
-
showLabel: boolean;
|
|
69
|
-
showColon: boolean;
|
|
70
|
-
}
|
|
71
|
-
declare type TimerBlockProps = {
|
|
72
|
-
label: string;
|
|
73
|
-
value: number;
|
|
74
|
-
};
|
|
75
|
-
interface InstagramElementProps extends WeaverseElementProps {
|
|
76
|
-
token: string;
|
|
77
|
-
username: string;
|
|
78
|
-
numberOfImages: number;
|
|
79
|
-
imagesPerRow: number;
|
|
80
|
-
gap: number;
|
|
81
|
-
}
|
|
82
|
-
declare type InstagramMedia = {
|
|
83
|
-
id: string;
|
|
84
|
-
media_type: 'IMAGE' | 'CAROUSEL_ALBUM';
|
|
85
|
-
media_url: string;
|
|
86
|
-
permalink: string;
|
|
87
|
-
caption: string;
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
declare let WeaverseRoot: ({ context }: WeaverseRootPropsType) => JSX.Element;
|
|
91
|
-
|
|
92
|
-
export { ButtonElementProps, ContainerElementProps, CountdownElementProps, CountdownTimeKey, ImageElementProps, InstagramElementProps, InstagramMedia, ItemComponentProps, LayoutElementProps, MapElementProps, PlaceholderProps, TextElementProps, TimerBlockProps, VideoElementProps, WeaverseContext, WeaverseContextConsumer, WeaverseContextProvider, WeaverseElementProps, WeaverseRoot, WeaverseRootPropsType, createRootContext };
|
package/dist/index.mjs
DELETED
|
@@ -1,779 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __defProps = Object.defineProperties;
|
|
3
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
-
var __spreadValues = (a, b) => {
|
|
9
|
-
for (var prop in b || (b = {}))
|
|
10
|
-
if (__hasOwnProp.call(b, prop))
|
|
11
|
-
__defNormalProp(a, prop, b[prop]);
|
|
12
|
-
if (__getOwnPropSymbols)
|
|
13
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
-
if (__propIsEnum.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
}
|
|
17
|
-
return a;
|
|
18
|
-
};
|
|
19
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
-
var __objRest = (source, exclude) => {
|
|
21
|
-
var target = {};
|
|
22
|
-
for (var prop in source)
|
|
23
|
-
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
24
|
-
target[prop] = source[prop];
|
|
25
|
-
if (source != null && __getOwnPropSymbols)
|
|
26
|
-
for (var prop of __getOwnPropSymbols(source)) {
|
|
27
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
28
|
-
target[prop] = source[prop];
|
|
29
|
-
}
|
|
30
|
-
return target;
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
// src/context.ts
|
|
34
|
-
import { Weaverse } from "@weaverse/core";
|
|
35
|
-
import { createContext as createContext2 } from "react";
|
|
36
|
-
|
|
37
|
-
// src/elements/button.tsx
|
|
38
|
-
import * as React from "react";
|
|
39
|
-
var Button = React.forwardRef((props, ref) => {
|
|
40
|
-
let _a = props, { openInNewTab, target, value } = _a, rest = __objRest(_a, ["openInNewTab", "target", "value"]);
|
|
41
|
-
if (target) {
|
|
42
|
-
return /* @__PURE__ */ React.createElement("a", __spreadProps(__spreadValues({
|
|
43
|
-
href: target,
|
|
44
|
-
target: openInNewTab ? "_blank" : "_self",
|
|
45
|
-
rel: "noreferrer"
|
|
46
|
-
}, rest), {
|
|
47
|
-
ref
|
|
48
|
-
}), value);
|
|
49
|
-
}
|
|
50
|
-
return /* @__PURE__ */ React.createElement("button", __spreadValues({
|
|
51
|
-
ref
|
|
52
|
-
}, rest), value);
|
|
53
|
-
});
|
|
54
|
-
Button.defaultProps = {
|
|
55
|
-
value: "Shop now",
|
|
56
|
-
openInNewTab: false,
|
|
57
|
-
target: "",
|
|
58
|
-
type: "button",
|
|
59
|
-
css: {
|
|
60
|
-
"@desktop": {
|
|
61
|
-
borderRadius: "72px",
|
|
62
|
-
border: "none",
|
|
63
|
-
backgroundColor: "#0F71FF",
|
|
64
|
-
color: "#fff",
|
|
65
|
-
fontSize: "13px",
|
|
66
|
-
padding: "10px 20px"
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
var button_default = Button;
|
|
71
|
-
|
|
72
|
-
// src/elements/container.tsx
|
|
73
|
-
import React2, { forwardRef as forwardRef2 } from "react";
|
|
74
|
-
var Container = forwardRef2((props, ref) => {
|
|
75
|
-
let _a = props, { children } = _a, rest = __objRest(_a, ["children"]);
|
|
76
|
-
return /* @__PURE__ */ React2.createElement("div", __spreadValues({
|
|
77
|
-
ref
|
|
78
|
-
}, rest), children);
|
|
79
|
-
});
|
|
80
|
-
Container.defaultProps = {
|
|
81
|
-
css: {
|
|
82
|
-
"@desktop": {
|
|
83
|
-
alignItems: "flex-start",
|
|
84
|
-
backgroundColor: "rgba(248,203,203,0.38)",
|
|
85
|
-
display: "flex",
|
|
86
|
-
flexDirection: "column",
|
|
87
|
-
gridArea: "1 / 1 / 3 / 6",
|
|
88
|
-
height: "fit-content",
|
|
89
|
-
justifyContent: "flex-start",
|
|
90
|
-
overflow: "hidden",
|
|
91
|
-
textAlign: "left",
|
|
92
|
-
width: "100%"
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
};
|
|
96
|
-
var container_default = Container;
|
|
97
|
-
|
|
98
|
-
// src/elements/countdown/index.tsx
|
|
99
|
-
import React4, { forwardRef as forwardRef3, useContext, useEffect } from "react";
|
|
100
|
-
|
|
101
|
-
// src/elements/countdown/timer-block.tsx
|
|
102
|
-
import React3 from "react";
|
|
103
|
-
function TimerBlock({ value, label }) {
|
|
104
|
-
return /* @__PURE__ */ React3.createElement("div", null, /* @__PURE__ */ React3.createElement("div", {
|
|
105
|
-
className: "wv-countdown-number"
|
|
106
|
-
}, value.toString().padStart(2, "0")), label && /* @__PURE__ */ React3.createElement("div", {
|
|
107
|
-
className: "wv-countdown-label"
|
|
108
|
-
}, label));
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
// src/elements/countdown/utils.ts
|
|
112
|
-
var times = ["days", "hours", "minutes", "seconds"];
|
|
113
|
-
function getTime(_seconds) {
|
|
114
|
-
const ONE_MINUTE = 60 * 1e3;
|
|
115
|
-
const ONE_HOUR = 60 * ONE_MINUTE;
|
|
116
|
-
const ONE_DAY = 24 * ONE_HOUR;
|
|
117
|
-
const days = Math.floor(_seconds / ONE_DAY);
|
|
118
|
-
const hours = Math.floor((_seconds - days * ONE_DAY) / ONE_HOUR);
|
|
119
|
-
const minutes = Math.floor((_seconds - days * ONE_DAY - hours * ONE_HOUR) / ONE_MINUTE);
|
|
120
|
-
const seconds = Math.floor((_seconds - days * ONE_DAY - hours * ONE_HOUR - minutes * ONE_MINUTE) / 1e3);
|
|
121
|
-
return { days, hours, minutes, seconds };
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
// src/elements/countdown/index.tsx
|
|
125
|
-
var Countdown = forwardRef3((props, ref) => {
|
|
126
|
-
const { isDesignMode } = useContext(WeaverseContext);
|
|
127
|
-
let _a = props, {
|
|
128
|
-
timerType,
|
|
129
|
-
startTime,
|
|
130
|
-
endTime,
|
|
131
|
-
periods,
|
|
132
|
-
redirectUrl,
|
|
133
|
-
openInNewTab,
|
|
134
|
-
showColon,
|
|
135
|
-
showLabel
|
|
136
|
-
} = _a, rest = __objRest(_a, [
|
|
137
|
-
"timerType",
|
|
138
|
-
"startTime",
|
|
139
|
-
"endTime",
|
|
140
|
-
"periods",
|
|
141
|
-
"redirectUrl",
|
|
142
|
-
"openInNewTab",
|
|
143
|
-
"showColon",
|
|
144
|
-
"showLabel"
|
|
145
|
-
]);
|
|
146
|
-
const [remaining, setRemaining] = React4.useState(0);
|
|
147
|
-
if (typeof endTime !== "number") {
|
|
148
|
-
endTime = Number.parseInt(endTime);
|
|
149
|
-
}
|
|
150
|
-
useEffect(() => {
|
|
151
|
-
const flag = setInterval(() => {
|
|
152
|
-
const remainingTime = Math.max((timerType === "fixed-time" ? new Date(endTime).getTime() : new Date(startTime).getTime() + periods * 60 * 1e3) - Date.now(), 0);
|
|
153
|
-
if (!isDesignMode && redirectUrl && remainingTime > 0 && remainingTime < 1e3) {
|
|
154
|
-
window.open(redirectUrl, openInNewTab ? "_blank" : "_self");
|
|
155
|
-
}
|
|
156
|
-
setRemaining(remainingTime);
|
|
157
|
-
}, 1e3);
|
|
158
|
-
return () => {
|
|
159
|
-
clearInterval(flag);
|
|
160
|
-
};
|
|
161
|
-
}, [startTime, endTime, periods, timerType]);
|
|
162
|
-
const timer = getTime(remaining);
|
|
163
|
-
return /* @__PURE__ */ React4.createElement("div", __spreadValues({
|
|
164
|
-
ref
|
|
165
|
-
}, rest), times.map((time) => {
|
|
166
|
-
return /* @__PURE__ */ React4.createElement(React4.Fragment, {
|
|
167
|
-
key: time
|
|
168
|
-
}, /* @__PURE__ */ React4.createElement(TimerBlock, {
|
|
169
|
-
label: showLabel ? time : "",
|
|
170
|
-
value: timer[time]
|
|
171
|
-
}), time !== "seconds" && /* @__PURE__ */ React4.createElement("span", {
|
|
172
|
-
className: `wv-countdown-number ${showColon ? "" : "hidden"}`
|
|
173
|
-
}, ":"));
|
|
174
|
-
}));
|
|
175
|
-
});
|
|
176
|
-
Countdown.defaultProps = {
|
|
177
|
-
timerType: "fixed-time",
|
|
178
|
-
startTime: Date.now(),
|
|
179
|
-
endTime: 1661140528e3,
|
|
180
|
-
periods: 90,
|
|
181
|
-
redirectUrl: "https://myshop.com",
|
|
182
|
-
openInNewTab: false,
|
|
183
|
-
showLabel: true,
|
|
184
|
-
showColon: true,
|
|
185
|
-
css: {
|
|
186
|
-
"@desktop": {
|
|
187
|
-
fontFamily: "Inter",
|
|
188
|
-
fontSize: 36,
|
|
189
|
-
fontWeight: 500,
|
|
190
|
-
display: "grid",
|
|
191
|
-
gridAutoFlow: "column",
|
|
192
|
-
gap: 10,
|
|
193
|
-
"& > div": {
|
|
194
|
-
width: 48,
|
|
195
|
-
textAlign: "center"
|
|
196
|
-
},
|
|
197
|
-
"& .wv-countdown-label": {
|
|
198
|
-
fontSize: 10
|
|
199
|
-
},
|
|
200
|
-
"& > span": {
|
|
201
|
-
lineHeight: "100%"
|
|
202
|
-
},
|
|
203
|
-
"& .hidden": {
|
|
204
|
-
visibility: "hidden"
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
};
|
|
209
|
-
var countdown_default = Countdown;
|
|
210
|
-
|
|
211
|
-
// src/elements/image.tsx
|
|
212
|
-
import React5 from "react";
|
|
213
|
-
var Image = React5.forwardRef((props, ref) => {
|
|
214
|
-
let _a = props, { src, alt } = _a, rest = __objRest(_a, ["src", "alt"]);
|
|
215
|
-
return /* @__PURE__ */ React5.createElement("div", __spreadValues({
|
|
216
|
-
ref
|
|
217
|
-
}, rest), /* @__PURE__ */ React5.createElement("img", {
|
|
218
|
-
alt,
|
|
219
|
-
src
|
|
220
|
-
}));
|
|
221
|
-
});
|
|
222
|
-
Image.defaultProps = {
|
|
223
|
-
src: "https://ucarecdn.com/1cdc9d39-ca62-492e-8ec7-f1a86b241a90/",
|
|
224
|
-
alt: "weaverse image element",
|
|
225
|
-
css: {
|
|
226
|
-
"@desktop": {
|
|
227
|
-
img: {
|
|
228
|
-
width: "100%",
|
|
229
|
-
height: "100%",
|
|
230
|
-
objectFit: "cover"
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
};
|
|
235
|
-
var image_default = Image;
|
|
236
|
-
|
|
237
|
-
// src/elements/layout.tsx
|
|
238
|
-
import React6, { forwardRef as forwardRef4 } from "react";
|
|
239
|
-
var Layout = forwardRef4((props, ref) => {
|
|
240
|
-
let _a = props, { children, rows, gap, rowSize, columns, gridSize } = _a, rest = __objRest(_a, ["children", "rows", "gap", "rowSize", "columns", "gridSize"]);
|
|
241
|
-
let style = {
|
|
242
|
-
"--grid-size": gridSize + "px",
|
|
243
|
-
"--rows": rows,
|
|
244
|
-
"--columns": columns,
|
|
245
|
-
"--gap": gap + "px",
|
|
246
|
-
"--row-size": rowSize + "px",
|
|
247
|
-
"--col-size": "calc((var(--grid-size) - calc(var(--columns) - 1) * var(--gap)) / var(--columns))"
|
|
248
|
-
};
|
|
249
|
-
return /* @__PURE__ */ React6.createElement("section", __spreadProps(__spreadValues({
|
|
250
|
-
ref
|
|
251
|
-
}, rest), {
|
|
252
|
-
style
|
|
253
|
-
}), /* @__PURE__ */ React6.createElement("div", {
|
|
254
|
-
"data-layout-content": true
|
|
255
|
-
}, children));
|
|
256
|
-
});
|
|
257
|
-
Layout.defaultProps = {
|
|
258
|
-
gridSize: 1224,
|
|
259
|
-
rows: 12,
|
|
260
|
-
columns: 12,
|
|
261
|
-
gap: 16,
|
|
262
|
-
rowSize: 48,
|
|
263
|
-
css: {
|
|
264
|
-
"@desktop": {
|
|
265
|
-
paddingTop: "16px",
|
|
266
|
-
paddingBottom: "16px",
|
|
267
|
-
paddingLeft: "var(--gap)",
|
|
268
|
-
paddingRight: "var(--gap)",
|
|
269
|
-
"> [data-layout-content]": {
|
|
270
|
-
margin: "0 auto",
|
|
271
|
-
display: "grid !important",
|
|
272
|
-
gridTemplateRows: "repeat(var(--rows), var(--row-size))",
|
|
273
|
-
gridTemplateColumns: "repeat(var(--columns), minmax(0, var(--col-size)))",
|
|
274
|
-
gap: "var(--gap)",
|
|
275
|
-
maxWidth: "var(--grid-size)"
|
|
276
|
-
}
|
|
277
|
-
},
|
|
278
|
-
"@mobile": {
|
|
279
|
-
padding: "0 16px",
|
|
280
|
-
"> [data-layout-content]": {
|
|
281
|
-
display: "flex !important",
|
|
282
|
-
flexDirection: "column"
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
};
|
|
287
|
-
var layout_default = Layout;
|
|
288
|
-
|
|
289
|
-
// src/elements/map.tsx
|
|
290
|
-
import React7, { forwardRef as forwardRef5 } from "react";
|
|
291
|
-
var Map = forwardRef5((props, ref) => {
|
|
292
|
-
let _a = props, { place, zoom } = _a, rest = __objRest(_a, ["place", "zoom"]);
|
|
293
|
-
return /* @__PURE__ */ React7.createElement("div", __spreadValues({
|
|
294
|
-
ref
|
|
295
|
-
}, rest), /* @__PURE__ */ React7.createElement("iframe", {
|
|
296
|
-
loading: "lazy",
|
|
297
|
-
scrolling: "no",
|
|
298
|
-
width: "100%",
|
|
299
|
-
height: "100%",
|
|
300
|
-
title: "map",
|
|
301
|
-
src: `https://maps.google.com/maps?z=${zoom}&t=m&q=${place}&ie=UTF8&&output=embed`,
|
|
302
|
-
style: { pointerEvents: "none" }
|
|
303
|
-
}));
|
|
304
|
-
});
|
|
305
|
-
Map.defaultProps = {
|
|
306
|
-
place: "Hanoi",
|
|
307
|
-
zoom: 14
|
|
308
|
-
};
|
|
309
|
-
var map_default = Map;
|
|
310
|
-
|
|
311
|
-
// src/elements/text.tsx
|
|
312
|
-
import * as React8 from "react";
|
|
313
|
-
var Text = React8.forwardRef((props, ref) => {
|
|
314
|
-
let _a = props, { children, value } = _a, rest = __objRest(_a, ["children", "value"]);
|
|
315
|
-
return /* @__PURE__ */ React8.createElement("div", __spreadProps(__spreadValues({
|
|
316
|
-
ref
|
|
317
|
-
}, rest), {
|
|
318
|
-
dangerouslySetInnerHTML: { __html: value }
|
|
319
|
-
}));
|
|
320
|
-
});
|
|
321
|
-
Text.defaultProps = {
|
|
322
|
-
value: "The quick brown fox jumps over the lazy dog",
|
|
323
|
-
css: {
|
|
324
|
-
"@desktop": {
|
|
325
|
-
width: "100%",
|
|
326
|
-
height: "fit-content",
|
|
327
|
-
padding: "20px",
|
|
328
|
-
outline: "none",
|
|
329
|
-
wordBreak: "break-word",
|
|
330
|
-
overflowWrap: "break-word",
|
|
331
|
-
whiteSpace: "break-spaces"
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
};
|
|
335
|
-
var text_default = Text;
|
|
336
|
-
|
|
337
|
-
// src/elements/video.tsx
|
|
338
|
-
import React9, { forwardRef as forwardRef7, useContext as useContext2 } from "react";
|
|
339
|
-
var Video = forwardRef7((props, ref) => {
|
|
340
|
-
let { isDesignMode } = useContext2(WeaverseContext);
|
|
341
|
-
let _a = props, { src, type, controls, poster, autoPlay, loop, muted } = _a, rest = __objRest(_a, ["src", "type", "controls", "poster", "autoPlay", "loop", "muted"]);
|
|
342
|
-
return /* @__PURE__ */ React9.createElement("div", __spreadValues({
|
|
343
|
-
ref
|
|
344
|
-
}, rest), /* @__PURE__ */ React9.createElement("video", {
|
|
345
|
-
controls: isDesignMode ? false : controls,
|
|
346
|
-
autoPlay: isDesignMode ? false : autoPlay,
|
|
347
|
-
loop,
|
|
348
|
-
muted: true,
|
|
349
|
-
controlsList: "nodownload",
|
|
350
|
-
disablePictureInPicture: true
|
|
351
|
-
}, /* @__PURE__ */ React9.createElement("source", {
|
|
352
|
-
src,
|
|
353
|
-
type: type || "video/mp4"
|
|
354
|
-
}), "Your browser does not support the video tag."));
|
|
355
|
-
});
|
|
356
|
-
Video.defaultProps = {
|
|
357
|
-
src: "https://youtu.be/wM-NT6hcw48",
|
|
358
|
-
poster: "https://ucarecdn.com/48d73272-3fe3-43f6-8b5b-22b68fc5a8c8/section.png",
|
|
359
|
-
loop: false,
|
|
360
|
-
type: "video/mp4",
|
|
361
|
-
controls: false,
|
|
362
|
-
autoPlay: true,
|
|
363
|
-
muted: true,
|
|
364
|
-
css: {
|
|
365
|
-
"@desktop": {
|
|
366
|
-
video: {
|
|
367
|
-
height: "100%",
|
|
368
|
-
width: "100%",
|
|
369
|
-
aspectRatio: "16 / 9"
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
|
-
};
|
|
374
|
-
var video_default = Video;
|
|
375
|
-
|
|
376
|
-
// src/elements/instagram.tsx
|
|
377
|
-
import React11, { forwardRef as forwardRef9, useContext as useContext3, useEffect as useEffect2, useState } from "react";
|
|
378
|
-
|
|
379
|
-
// src/elements/shared/Placeholder.tsx
|
|
380
|
-
import React10, { forwardRef as forwardRef8 } from "react";
|
|
381
|
-
var Placeholder = forwardRef8((props, ref) => {
|
|
382
|
-
let _a = props, { element, children } = _a, rest = __objRest(_a, ["element", "children"]);
|
|
383
|
-
let style = {
|
|
384
|
-
position: "absolute",
|
|
385
|
-
height: "100%",
|
|
386
|
-
width: "100%",
|
|
387
|
-
display: "flex",
|
|
388
|
-
flexDirection: "column",
|
|
389
|
-
alignItems: "center",
|
|
390
|
-
justifyContent: "center",
|
|
391
|
-
color: "#374151",
|
|
392
|
-
pointerEvents: "none",
|
|
393
|
-
zIndex: 1
|
|
394
|
-
};
|
|
395
|
-
return /* @__PURE__ */ React10.createElement("div", __spreadValues({
|
|
396
|
-
style,
|
|
397
|
-
ref
|
|
398
|
-
}, rest), /* @__PURE__ */ React10.createElement("div", {
|
|
399
|
-
style: { fontWeight: 600, marginBottom: "10px" }
|
|
400
|
-
}, element), /* @__PURE__ */ React10.createElement("div", null, children));
|
|
401
|
-
});
|
|
402
|
-
var Placeholder_default = Placeholder;
|
|
403
|
-
|
|
404
|
-
// src/elements/instagram.tsx
|
|
405
|
-
var INSTAGRAM_API = "https://graph.instagram.com";
|
|
406
|
-
var Instagram = forwardRef9((props, ref) => {
|
|
407
|
-
const _a = props, { token, username, numberOfImages, imagesPerRow, gap } = _a, rest = __objRest(_a, ["token", "username", "numberOfImages", "imagesPerRow", "gap"]);
|
|
408
|
-
const [media, setMedia] = useState([]);
|
|
409
|
-
const [error, setError] = useState(null);
|
|
410
|
-
let { isDesignMode } = useContext3(WeaverseContext);
|
|
411
|
-
useEffect2(() => {
|
|
412
|
-
if (token) {
|
|
413
|
-
let params = new URLSearchParams({
|
|
414
|
-
access_token: token,
|
|
415
|
-
fields: "id,media_type,caption,media_url,permalink"
|
|
416
|
-
});
|
|
417
|
-
fetch(`${INSTAGRAM_API}/me/media?${params.toString()}`).then((res) => res.json()).then((res) => {
|
|
418
|
-
if (res.error) {
|
|
419
|
-
setError(res);
|
|
420
|
-
} else {
|
|
421
|
-
setError(null);
|
|
422
|
-
setMedia([...res.data]);
|
|
423
|
-
}
|
|
424
|
-
}).catch(setError);
|
|
425
|
-
}
|
|
426
|
-
}, [token]);
|
|
427
|
-
if (!token || error) {
|
|
428
|
-
return /* @__PURE__ */ React11.createElement("div", __spreadValues({
|
|
429
|
-
ref
|
|
430
|
-
}, rest), /* @__PURE__ */ React11.createElement(Placeholder_default, {
|
|
431
|
-
element: "Instagram"
|
|
432
|
-
}, !token ? "Connect your Instagram account to display photos on your site." : "Invalid or expired token!"));
|
|
433
|
-
}
|
|
434
|
-
let style = {
|
|
435
|
-
"--wv-ig-images-per-row": imagesPerRow,
|
|
436
|
-
"--wv-ig-images-gap": gap
|
|
437
|
-
};
|
|
438
|
-
return /* @__PURE__ */ React11.createElement("div", __spreadProps(__spreadValues({
|
|
439
|
-
ref
|
|
440
|
-
}, rest), {
|
|
441
|
-
style
|
|
442
|
-
}), /* @__PURE__ */ React11.createElement("div", {
|
|
443
|
-
className: "wv-ig-media-container"
|
|
444
|
-
}, media.slice(0, numberOfImages).map((item) => {
|
|
445
|
-
let linkProps;
|
|
446
|
-
if (!isDesignMode) {
|
|
447
|
-
linkProps = { href: item.permalink, target: "_blank" };
|
|
448
|
-
}
|
|
449
|
-
return /* @__PURE__ */ React11.createElement("a", __spreadValues({
|
|
450
|
-
key: item.id
|
|
451
|
-
}, linkProps), /* @__PURE__ */ React11.createElement("img", {
|
|
452
|
-
alt: item.caption,
|
|
453
|
-
src: item.media_url
|
|
454
|
-
}));
|
|
455
|
-
})));
|
|
456
|
-
});
|
|
457
|
-
Instagram.defaultProps = {
|
|
458
|
-
token: "",
|
|
459
|
-
username: "",
|
|
460
|
-
numberOfImages: 8,
|
|
461
|
-
imagesPerRow: 4,
|
|
462
|
-
gap: 0,
|
|
463
|
-
css: {
|
|
464
|
-
"@desktop": {
|
|
465
|
-
".wv-ig-media-container": {
|
|
466
|
-
overflow: "hidden",
|
|
467
|
-
maxWidth: "100%",
|
|
468
|
-
maxHeight: "100%",
|
|
469
|
-
display: "grid",
|
|
470
|
-
gridTemplateColumns: "repeat(var(--wv-ig-images-per-row, 4), 1fr)",
|
|
471
|
-
gap: "var(--wv-ig-images-gap, 0px)",
|
|
472
|
-
img: {
|
|
473
|
-
aspectRatio: "1 / 1",
|
|
474
|
-
width: "100%",
|
|
475
|
-
height: "100%",
|
|
476
|
-
objectFit: "cover"
|
|
477
|
-
}
|
|
478
|
-
}
|
|
479
|
-
}
|
|
480
|
-
}
|
|
481
|
-
};
|
|
482
|
-
var instagram_default = Instagram;
|
|
483
|
-
|
|
484
|
-
// src/elements/accordion/index.tsx
|
|
485
|
-
import React12, { createContext, forwardRef as forwardRef10, useState as useState2 } from "react";
|
|
486
|
-
var AccordionContext = createContext({
|
|
487
|
-
active: null,
|
|
488
|
-
setActive: () => {
|
|
489
|
-
}
|
|
490
|
-
});
|
|
491
|
-
var Accordion = forwardRef10((props, ref) => {
|
|
492
|
-
const _a = props, { items, children } = _a, rest = __objRest(_a, ["items", "children"]);
|
|
493
|
-
const [active, setActive] = useState2(null);
|
|
494
|
-
const setOpenAccordion = (id) => {
|
|
495
|
-
if (id === active) {
|
|
496
|
-
setActive(null);
|
|
497
|
-
} else {
|
|
498
|
-
setActive(id);
|
|
499
|
-
}
|
|
500
|
-
};
|
|
501
|
-
console.info("9779 active", active);
|
|
502
|
-
return /* @__PURE__ */ React12.createElement("div", __spreadValues({
|
|
503
|
-
ref
|
|
504
|
-
}, rest), /* @__PURE__ */ React12.createElement(AccordionContext.Provider, {
|
|
505
|
-
value: { active, setActive: setOpenAccordion }
|
|
506
|
-
}, children));
|
|
507
|
-
});
|
|
508
|
-
Accordion.defaultProps = {
|
|
509
|
-
items: [
|
|
510
|
-
{
|
|
511
|
-
id: 1,
|
|
512
|
-
headerText: "Header 1",
|
|
513
|
-
childrenId: true
|
|
514
|
-
},
|
|
515
|
-
{
|
|
516
|
-
id: 2,
|
|
517
|
-
headerText: "Header 2"
|
|
518
|
-
}
|
|
519
|
-
],
|
|
520
|
-
css: {
|
|
521
|
-
"@desktop": {
|
|
522
|
-
display: "flex",
|
|
523
|
-
flexDirection: "column",
|
|
524
|
-
gap: 4,
|
|
525
|
-
".wv-accordion-header": {
|
|
526
|
-
borderRadius: 4,
|
|
527
|
-
padding: 4,
|
|
528
|
-
marginBottom: 4,
|
|
529
|
-
backgroundColor: "#aaa",
|
|
530
|
-
"&.active": {
|
|
531
|
-
color: "blue"
|
|
532
|
-
},
|
|
533
|
-
'&.active + [data-wv-type="accordion.content"]': {
|
|
534
|
-
display: "grid"
|
|
535
|
-
}
|
|
536
|
-
}
|
|
537
|
-
}
|
|
538
|
-
}
|
|
539
|
-
};
|
|
540
|
-
var accordion_default = Accordion;
|
|
541
|
-
|
|
542
|
-
// src/elements/accordion/AccordionWrapper.tsx
|
|
543
|
-
import React13, { forwardRef as forwardRef11, useContext as useContext4 } from "react";
|
|
544
|
-
var AccordionWrapper = forwardRef11((props, ref) => {
|
|
545
|
-
const _a = props, { wrapperId, headerText, children } = _a, rest = __objRest(_a, ["wrapperId", "headerText", "children"]);
|
|
546
|
-
const { active, setActive } = useContext4(AccordionContext);
|
|
547
|
-
return /* @__PURE__ */ React13.createElement("div", __spreadValues({
|
|
548
|
-
ref
|
|
549
|
-
}, rest), /* @__PURE__ */ React13.createElement("div", {
|
|
550
|
-
onClick: () => setActive(wrapperId),
|
|
551
|
-
className: `wv-accordion-header ${active === wrapperId ? "active" : ""}`
|
|
552
|
-
}, headerText, " #", wrapperId), children);
|
|
553
|
-
});
|
|
554
|
-
AccordionWrapper.defaultProps = {
|
|
555
|
-
wrapperId: 1,
|
|
556
|
-
headerText: "Header 1",
|
|
557
|
-
css: {
|
|
558
|
-
"@desktop": {
|
|
559
|
-
maxHeight: "100%"
|
|
560
|
-
}
|
|
561
|
-
}
|
|
562
|
-
};
|
|
563
|
-
var AccordionWrapper_default = AccordionWrapper;
|
|
564
|
-
|
|
565
|
-
// src/elements/accordion/AccordionContent.tsx
|
|
566
|
-
import React14, { forwardRef as forwardRef12 } from "react";
|
|
567
|
-
var AccordionContent = forwardRef12((props, ref) => {
|
|
568
|
-
const _a = props, { rows, columns, gap, rowSize, children } = _a, rest = __objRest(_a, ["rows", "columns", "gap", "rowSize", "children"]);
|
|
569
|
-
let style = {
|
|
570
|
-
"--rows": rows,
|
|
571
|
-
"--columns": columns,
|
|
572
|
-
"--gap": gap + "px",
|
|
573
|
-
"--row-size": rowSize + "px"
|
|
574
|
-
};
|
|
575
|
-
return /* @__PURE__ */ React14.createElement("div", __spreadProps(__spreadValues({
|
|
576
|
-
ref
|
|
577
|
-
}, rest), {
|
|
578
|
-
style
|
|
579
|
-
}), React14.Children.count(children) > 0 ? children : /* @__PURE__ */ React14.createElement(Placeholder_default, {
|
|
580
|
-
element: "Accordion"
|
|
581
|
-
}, "Item Content"));
|
|
582
|
-
});
|
|
583
|
-
AccordionContent.defaultProps = {
|
|
584
|
-
rows: 2,
|
|
585
|
-
columns: 12,
|
|
586
|
-
gap: 4,
|
|
587
|
-
rowSize: 48,
|
|
588
|
-
css: {
|
|
589
|
-
"@desktop": {
|
|
590
|
-
width: "100%",
|
|
591
|
-
backgroundColor: "#DDD",
|
|
592
|
-
display: "none",
|
|
593
|
-
gridTemplate: "repeat(var(--rows),var(--row-size))/repeat(var(--columns),1fr)",
|
|
594
|
-
gridGap: "var(--gap)",
|
|
595
|
-
borderRadius: 4
|
|
596
|
-
}
|
|
597
|
-
}
|
|
598
|
-
};
|
|
599
|
-
var AccordionContent_default = AccordionContent;
|
|
600
|
-
|
|
601
|
-
// src/elements/index.ts
|
|
602
|
-
var elements = {
|
|
603
|
-
Countdown: {
|
|
604
|
-
Component: countdown_default,
|
|
605
|
-
type: "countdown"
|
|
606
|
-
},
|
|
607
|
-
Button: {
|
|
608
|
-
Component: button_default,
|
|
609
|
-
type: "button"
|
|
610
|
-
},
|
|
611
|
-
Container: {
|
|
612
|
-
Component: container_default,
|
|
613
|
-
type: "container"
|
|
614
|
-
},
|
|
615
|
-
Image: {
|
|
616
|
-
Component: image_default,
|
|
617
|
-
type: "image"
|
|
618
|
-
},
|
|
619
|
-
Instagram: {
|
|
620
|
-
Component: instagram_default,
|
|
621
|
-
type: "instagram"
|
|
622
|
-
},
|
|
623
|
-
Layout: {
|
|
624
|
-
Component: layout_default,
|
|
625
|
-
type: "layout"
|
|
626
|
-
},
|
|
627
|
-
Map: {
|
|
628
|
-
Component: map_default,
|
|
629
|
-
type: "map"
|
|
630
|
-
},
|
|
631
|
-
Text: {
|
|
632
|
-
Component: text_default,
|
|
633
|
-
type: "text"
|
|
634
|
-
},
|
|
635
|
-
Video: {
|
|
636
|
-
Component: video_default,
|
|
637
|
-
type: "video"
|
|
638
|
-
},
|
|
639
|
-
Accordion: {
|
|
640
|
-
Component: accordion_default,
|
|
641
|
-
type: "accordion"
|
|
642
|
-
},
|
|
643
|
-
AccordionWrapper: {
|
|
644
|
-
Component: AccordionWrapper_default,
|
|
645
|
-
type: "accordion.wrapper"
|
|
646
|
-
},
|
|
647
|
-
AccordionContent: {
|
|
648
|
-
Component: AccordionContent_default,
|
|
649
|
-
type: "accordion.content"
|
|
650
|
-
}
|
|
651
|
-
};
|
|
652
|
-
var elements_default = elements;
|
|
653
|
-
|
|
654
|
-
// src/context.ts
|
|
655
|
-
var createRootContext = (configs) => {
|
|
656
|
-
let rootContext = new Weaverse(configs);
|
|
657
|
-
Object.keys(elements_default).forEach((key) => {
|
|
658
|
-
rootContext.registerElement(elements_default[key]);
|
|
659
|
-
});
|
|
660
|
-
return rootContext;
|
|
661
|
-
};
|
|
662
|
-
var WeaverseContext = createContext2({});
|
|
663
|
-
var WeaverseContextProvider = WeaverseContext.Provider;
|
|
664
|
-
var WeaverseContextConsumer = WeaverseContext.Consumer;
|
|
665
|
-
|
|
666
|
-
// src/renderer.tsx
|
|
667
|
-
import { isBrowser } from "@weaverse/core";
|
|
668
|
-
import React15, { useContext as useContext5, useEffect as useEffect3, useRef, useState as useState3 } from "react";
|
|
669
|
-
|
|
670
|
-
// src/utils/index.ts
|
|
671
|
-
var shortCssObject = (css) => {
|
|
672
|
-
return {
|
|
673
|
-
"@desktop": css["@desktop"],
|
|
674
|
-
"@mobile": css["@mobile"]
|
|
675
|
-
};
|
|
676
|
-
};
|
|
677
|
-
function generateItemClass(instance, stitchesInstance) {
|
|
678
|
-
var _a, _b, _c, _d;
|
|
679
|
-
let { css, className: cls = "" } = instance.data;
|
|
680
|
-
let defaultCss = ((_c = (_b = (_a = instance.Element) == null ? void 0 : _a.Component) == null ? void 0 : _b.defaultProps) == null ? void 0 : _c.css) || {};
|
|
681
|
-
let className = "";
|
|
682
|
-
if (css || defaultCss) {
|
|
683
|
-
let formattedCss = shortCssObject(css || defaultCss);
|
|
684
|
-
let { className: newClass = "" } = stitchesInstance.css(formattedCss)();
|
|
685
|
-
let { stitchesClass } = instance;
|
|
686
|
-
let otherClass = (((_d = instance.ref.current) == null ? void 0 : _d.className) || "").replace(stitchesClass, "").replace(cls, "").trim();
|
|
687
|
-
className = `${cls} ${newClass} ${otherClass}`.trim();
|
|
688
|
-
instance.stitchesClass = newClass;
|
|
689
|
-
}
|
|
690
|
-
return className;
|
|
691
|
-
}
|
|
692
|
-
|
|
693
|
-
// src/renderer.tsx
|
|
694
|
-
var WeaverseRoot = ({ context }) => {
|
|
695
|
-
var _a;
|
|
696
|
-
let [, setData] = useState3(context.projectData);
|
|
697
|
-
let rootRef = useRef();
|
|
698
|
-
useEffect3(() => {
|
|
699
|
-
let update = () => setData({});
|
|
700
|
-
context.subscribe(update);
|
|
701
|
-
if (context.projectData) {
|
|
702
|
-
setTimeout(update, 110);
|
|
703
|
-
}
|
|
704
|
-
context.contentRootElement = rootRef.current;
|
|
705
|
-
return () => {
|
|
706
|
-
context.unsubscribe(update);
|
|
707
|
-
};
|
|
708
|
-
}, []);
|
|
709
|
-
let eventHandlers = ((_a = context == null ? void 0 : context.studioBridge) == null ? void 0 : _a.eventHandlers) || {};
|
|
710
|
-
let themeClass = context.stitchesInstance.theme.className;
|
|
711
|
-
return /* @__PURE__ */ React15.createElement("div", __spreadProps(__spreadValues({
|
|
712
|
-
className: `weaverse-content-root ${themeClass}`
|
|
713
|
-
}, eventHandlers), {
|
|
714
|
-
ref: rootRef
|
|
715
|
-
}), /* @__PURE__ */ React15.createElement(WeaverseContextProvider, {
|
|
716
|
-
value: context
|
|
717
|
-
}, /* @__PURE__ */ React15.createElement(ItemInstance, {
|
|
718
|
-
id: context.projectData.rootId || 0
|
|
719
|
-
})));
|
|
720
|
-
};
|
|
721
|
-
var ItemComponent = ({ instance }) => {
|
|
722
|
-
let { stitchesInstance, elementInstances } = useContext5(WeaverseContext);
|
|
723
|
-
let [data, setData] = useState3(instance.data);
|
|
724
|
-
let _a = data, { id, type, childIds = [], css, className } = _a, rest = __objRest(_a, ["id", "type", "childIds", "css", "className"]);
|
|
725
|
-
useEffect3(() => {
|
|
726
|
-
var _a2;
|
|
727
|
-
let update = (data2) => setData(__spreadValues({}, data2));
|
|
728
|
-
instance.subscribe(update);
|
|
729
|
-
if (isBrowser && !instance.ref.current) {
|
|
730
|
-
Object.assign(instance.ref, {
|
|
731
|
-
current: document.querySelector(`[data-wv-id="${id}"]`)
|
|
732
|
-
});
|
|
733
|
-
}
|
|
734
|
-
(_a2 = instance.ref.current) == null ? void 0 : _a2.removeAttribute("css");
|
|
735
|
-
return () => {
|
|
736
|
-
instance.unsubscribe(update);
|
|
737
|
-
};
|
|
738
|
-
}, []);
|
|
739
|
-
let Element = elementInstances.get(type);
|
|
740
|
-
if (Element == null ? void 0 : Element.Component) {
|
|
741
|
-
let Component = Element.Component;
|
|
742
|
-
if (Component.$$typeof === Symbol.for("react.forward_ref")) {
|
|
743
|
-
rest.ref = instance.ref;
|
|
744
|
-
}
|
|
745
|
-
return /* @__PURE__ */ React15.createElement(Component, __spreadValues({
|
|
746
|
-
key: id,
|
|
747
|
-
"data-wv-type": type,
|
|
748
|
-
"data-wv-id": id,
|
|
749
|
-
className: generateItemClass(instance, stitchesInstance)
|
|
750
|
-
}, rest), childIds.map((id2) => /* @__PURE__ */ React15.createElement(ItemInstance, {
|
|
751
|
-
key: id2,
|
|
752
|
-
id: id2
|
|
753
|
-
})));
|
|
754
|
-
}
|
|
755
|
-
return null;
|
|
756
|
-
};
|
|
757
|
-
var ItemInstance = ({ id }) => {
|
|
758
|
-
let context = useContext5(WeaverseContext);
|
|
759
|
-
let { itemInstances } = context;
|
|
760
|
-
let instance = itemInstances.get(id);
|
|
761
|
-
if (!instance) {
|
|
762
|
-
return /* @__PURE__ */ React15.createElement("div", {
|
|
763
|
-
style: { display: "none" }
|
|
764
|
-
}, "Item instance ", id, " not found");
|
|
765
|
-
}
|
|
766
|
-
return /* @__PURE__ */ React15.createElement(ItemComponent, {
|
|
767
|
-
instance
|
|
768
|
-
});
|
|
769
|
-
};
|
|
770
|
-
|
|
771
|
-
// src/index.ts
|
|
772
|
-
export * from "@weaverse/core";
|
|
773
|
-
export {
|
|
774
|
-
WeaverseContext,
|
|
775
|
-
WeaverseContextConsumer,
|
|
776
|
-
WeaverseContextProvider,
|
|
777
|
-
WeaverseRoot,
|
|
778
|
-
createRootContext
|
|
779
|
-
};
|