@builder.io/sdk-react 0.0.2 → 0.0.4
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/package.json +6 -1
- package/packages/_rsc/src/blocks/BaseText.js +27 -0
- package/packages/_rsc/src/blocks/button/button.js +35 -0
- package/packages/_rsc/src/blocks/button/component-info.js +41 -0
- package/packages/_rsc/src/blocks/columns/columns.js +96 -0
- package/packages/_rsc/src/blocks/columns/component-info.js +242 -0
- package/packages/_rsc/src/blocks/custom-code/component-info.js +31 -0
- package/packages/_rsc/src/blocks/custom-code/custom-code.js +63 -0
- package/packages/_rsc/src/blocks/embed/component-info.js +44 -0
- package/packages/_rsc/src/blocks/embed/embed.js +55 -0
- package/packages/_rsc/src/blocks/embed/helpers.js +9 -0
- package/packages/_rsc/src/blocks/form/component-info.js +262 -0
- package/packages/_rsc/src/blocks/form/form.js +222 -0
- package/packages/_rsc/src/blocks/fragment/component-info.js +11 -0
- package/packages/_rsc/src/blocks/fragment/fragment.js +24 -0
- package/packages/_rsc/src/blocks/image/component-info.js +151 -0
- package/packages/_rsc/src/blocks/image/image.helpers.js +48 -0
- package/packages/_rsc/src/blocks/image/image.js +101 -0
- package/packages/_rsc/src/blocks/img/component-info.js +20 -0
- package/packages/_rsc/src/blocks/img/img.js +33 -0
- package/packages/_rsc/src/blocks/input/component-info.js +74 -0
- package/packages/_rsc/src/blocks/input/input.js +36 -0
- package/packages/_rsc/src/blocks/raw-text/component-info.js +16 -0
- package/packages/_rsc/src/blocks/raw-text/raw-text.js +28 -0
- package/packages/_rsc/src/blocks/section/component-info.js +49 -0
- package/packages/_rsc/src/blocks/section/section.js +31 -0
- package/packages/_rsc/src/blocks/select/component-info.js +59 -0
- package/packages/_rsc/src/blocks/select/select.js +36 -0
- package/packages/_rsc/src/blocks/submit-button/component-info.js +28 -0
- package/packages/_rsc/src/blocks/submit-button/submit-button.js +26 -0
- package/packages/_rsc/src/blocks/symbol/component-info.js +43 -0
- package/packages/_rsc/src/blocks/symbol/symbol.js +51 -0
- package/packages/_rsc/src/blocks/text/component-info.js +24 -0
- package/packages/_rsc/src/blocks/text/text.js +27 -0
- package/packages/_rsc/src/blocks/textarea/component-info.js +47 -0
- package/packages/_rsc/src/blocks/textarea/textarea.js +32 -0
- package/packages/_rsc/src/blocks/util.js +8 -0
- package/packages/_rsc/src/blocks/video/component-info.js +106 -0
- package/packages/_rsc/src/blocks/video/video.js +57 -0
- package/packages/_rsc/src/components/render-block/block-styles.js +70 -0
- package/packages/_rsc/src/components/render-block/render-block.helpers.js +23 -0
- package/packages/_rsc/src/components/render-block/render-block.js +206 -0
- package/packages/_rsc/src/components/render-block/render-component-with-context.js +51 -0
- package/packages/_rsc/src/components/render-block/render-component.js +43 -0
- package/packages/_rsc/src/components/render-block/render-repeated-block.js +49 -0
- package/packages/_rsc/src/components/render-block/types.js +0 -0
- package/packages/_rsc/src/components/render-blocks.js +80 -0
- package/packages/_rsc/src/components/render-content/builder-editing.js +35 -0
- package/packages/_rsc/src/components/render-content/components/render-styles.js +78 -0
- package/packages/_rsc/src/components/render-content/index.js +4 -0
- package/packages/_rsc/src/components/render-content/render-content.js +200 -0
- package/packages/_rsc/src/components/render-inlined-styles.js +36 -0
- package/packages/_rsc/src/constants/builder-registered-components.js +54 -0
- package/packages/_rsc/src/constants/device-sizes.js +48 -0
- package/packages/_rsc/src/constants/target.js +4 -0
- package/packages/_rsc/src/context/builder.context.js +11 -0
- package/packages/_rsc/src/context/types.js +0 -0
- package/packages/_rsc/src/functions/camel-to-kebab-case.js +4 -0
- package/packages/_rsc/src/functions/evaluate.js +6 -0
- package/packages/_rsc/src/functions/event-handler-name.js +7 -0
- package/packages/_rsc/src/functions/extract-text-styles.js +22 -0
- package/packages/_rsc/src/functions/fast-clone.js +4 -0
- package/packages/_rsc/src/functions/get-block-actions-handler.js +11 -0
- package/packages/_rsc/src/functions/get-block-actions.js +18 -0
- package/packages/_rsc/src/functions/get-block-component-options.js +28 -0
- package/packages/_rsc/src/functions/get-block-properties.js +29 -0
- package/packages/_rsc/src/functions/get-block-tag.js +6 -0
- package/packages/_rsc/src/functions/get-builder-search-params/fn.test.js +13 -0
- package/packages/_rsc/src/functions/get-builder-search-params/index.js +38 -0
- package/packages/_rsc/src/functions/get-content/ab-testing.js +99 -0
- package/packages/_rsc/src/functions/get-content/fn.test.js +31 -0
- package/packages/_rsc/src/functions/get-content/index.js +101 -0
- package/packages/_rsc/src/functions/get-content/types.js +0 -0
- package/packages/_rsc/src/functions/get-fetch.js +34 -0
- package/packages/_rsc/src/functions/get-global-this.js +18 -0
- package/packages/_rsc/src/functions/get-processed-block.js +59 -0
- package/packages/_rsc/src/functions/get-processed-block.test.js +32 -0
- package/packages/_rsc/src/functions/get-react-native-block-styles.js +32 -0
- package/packages/_rsc/src/functions/if-target.js +15 -0
- package/packages/_rsc/src/functions/is-browser.js +6 -0
- package/packages/_rsc/src/functions/is-editing.js +7 -0
- package/packages/_rsc/src/functions/is-iframe.js +7 -0
- package/packages/_rsc/src/functions/is-previewing.js +14 -0
- package/packages/_rsc/src/functions/on-change.js +27 -0
- package/packages/_rsc/src/functions/on-change.test.js +19 -0
- package/packages/_rsc/src/functions/register-component.js +68 -0
- package/packages/_rsc/src/functions/register.js +29 -0
- package/packages/_rsc/src/functions/sanitize-react-native-block-styles.js +66 -0
- package/packages/_rsc/src/functions/set-editor-settings.js +15 -0
- package/packages/_rsc/src/functions/set.js +11 -0
- package/packages/_rsc/src/functions/set.test.js +16 -0
- package/packages/_rsc/src/functions/track.js +124 -0
- package/packages/_rsc/src/functions/transform-block.js +6 -0
- package/packages/_rsc/src/helpers/ab-tests.js +16 -0
- package/packages/_rsc/src/helpers/cookie.js +79 -0
- package/packages/_rsc/src/helpers/css.js +28 -0
- package/packages/_rsc/src/helpers/flatten.js +34 -0
- package/packages/_rsc/src/helpers/localStorage.js +34 -0
- package/packages/_rsc/src/helpers/nullable.js +4 -0
- package/packages/_rsc/src/helpers/sessionId.js +49 -0
- package/packages/_rsc/src/helpers/time.js +5 -0
- package/packages/_rsc/src/helpers/url.js +10 -0
- package/packages/_rsc/src/helpers/url.test.js +15 -0
- package/packages/_rsc/src/helpers/uuid.js +13 -0
- package/packages/_rsc/src/helpers/visitorId.js +33 -0
- package/packages/_rsc/src/index-helpers/blocks-exports.js +22 -0
- package/packages/_rsc/src/index-helpers/top-of-file.js +2 -0
- package/packages/_rsc/src/index.js +14 -0
- package/packages/_rsc/src/scripts/init-editing.js +93 -0
- package/packages/_rsc/src/types/builder-block.js +0 -0
- package/packages/_rsc/src/types/builder-content.js +0 -0
- package/packages/_rsc/src/types/can-track.js +0 -0
- package/packages/_rsc/src/types/components.js +0 -0
- package/packages/_rsc/src/types/deep-partial.js +0 -0
- package/packages/_rsc/src/types/element.js +0 -0
- package/packages/_rsc/src/types/targets.js +0 -0
- package/packages/_rsc/src/types/typescript.js +0 -0
- package/src/blocks/button/button.jsx +6 -5
- package/src/blocks/columns/columns.jsx +9 -10
- package/src/blocks/columns/component-info.js +2 -2
- package/src/blocks/embed/component-info.js +2 -2
- package/src/blocks/form/form.jsx +4 -7
- package/src/blocks/image/component-info.js +2 -2
- package/src/blocks/image/image.jsx +36 -14
- package/src/blocks/img/img.jsx +2 -5
- package/src/blocks/submit-button/submit-button.jsx +2 -5
- package/src/blocks/symbol/symbol.jsx +3 -4
- package/src/blocks/util.js +6 -5
- package/src/components/render-block/block-styles.jsx +9 -3
- package/src/components/render-block/render-block.jsx +14 -11
- package/src/components/render-block/render-component.jsx +1 -2
- package/src/components/render-content/builder-editing.jsx +7 -0
- package/src/components/render-content/render-content.jsx +14 -6
- package/src/components/render-inlined-styles.jsx +4 -4
- package/src/constants/device-sizes.js +29 -2
- package/src/constants/target.js +1 -1
- package/src/functions/evaluate.js +4 -3
- package/src/functions/get-block-actions-handler.js +8 -9
- package/src/functions/get-block-actions.js +2 -2
- package/src/functions/get-builder-search-params/index.js +2 -1
- package/src/functions/get-content/index.js +8 -3
- package/src/functions/register-component.js +1 -5
- package/src/functions/track.js +4 -0
- package/src/index.js +1 -1
- package/src/scripts/init-editing.js +17 -5
- package/src/functions/mark-mutable.js +0 -10
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
+
var __spreadValues = (a, b) => {
|
|
7
|
+
for (var prop in b || (b = {}))
|
|
8
|
+
if (__hasOwnProp.call(b, prop))
|
|
9
|
+
__defNormalProp(a, prop, b[prop]);
|
|
10
|
+
if (__getOwnPropSymbols)
|
|
11
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
12
|
+
if (__propIsEnum.call(b, prop))
|
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
|
+
}
|
|
15
|
+
return a;
|
|
16
|
+
};
|
|
17
|
+
import * as React from "react";
|
|
18
|
+
import RenderComponent from "./render-component.js";
|
|
19
|
+
function RenderComponentWithContext(props) {
|
|
20
|
+
const _context = __spreadValues({}, props["_context"]);
|
|
21
|
+
_context.BuilderContext = {
|
|
22
|
+
get content() {
|
|
23
|
+
return props.context.content;
|
|
24
|
+
},
|
|
25
|
+
get state() {
|
|
26
|
+
return props.context.state;
|
|
27
|
+
},
|
|
28
|
+
get context() {
|
|
29
|
+
return props.context.context;
|
|
30
|
+
},
|
|
31
|
+
get apiKey() {
|
|
32
|
+
return props.context.apiKey;
|
|
33
|
+
},
|
|
34
|
+
get registeredComponents() {
|
|
35
|
+
return props.context.registeredComponents;
|
|
36
|
+
},
|
|
37
|
+
get inheritedStyles() {
|
|
38
|
+
return props.context.inheritedStyles;
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
return /* @__PURE__ */ React.createElement(RenderComponent, {
|
|
42
|
+
componentRef: props.componentRef,
|
|
43
|
+
componentOptions: props.componentOptions,
|
|
44
|
+
blockChildren: props.blockChildren,
|
|
45
|
+
context: props.context,
|
|
46
|
+
_context
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
export {
|
|
50
|
+
RenderComponentWithContext as default
|
|
51
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
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
|
+
import * as React from "react";
|
|
21
|
+
import BlockStyles from "./block-styles.js";
|
|
22
|
+
import RenderBlock from "./render-block.js";
|
|
23
|
+
function RenderComponent(props) {
|
|
24
|
+
var _a, _b;
|
|
25
|
+
const _context = __spreadValues({}, props["_context"]);
|
|
26
|
+
const ComponentRefRef = props.componentRef;
|
|
27
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, props.componentRef ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(ComponentRefRef, __spreadProps(__spreadValues({}, props.componentOptions), {
|
|
28
|
+
_context
|
|
29
|
+
}), (_a = props.blockChildren) == null ? void 0 : _a.map((child) => /* @__PURE__ */ React.createElement(RenderBlock, {
|
|
30
|
+
key: "render-block-" + child.id,
|
|
31
|
+
block: child,
|
|
32
|
+
context: props.context,
|
|
33
|
+
_context
|
|
34
|
+
})), (_b = props.blockChildren) == null ? void 0 : _b.map((child) => /* @__PURE__ */ React.createElement(BlockStyles, {
|
|
35
|
+
key: "block-style-" + child.id,
|
|
36
|
+
block: child,
|
|
37
|
+
context: props.context,
|
|
38
|
+
_context
|
|
39
|
+
})))) : null);
|
|
40
|
+
}
|
|
41
|
+
export {
|
|
42
|
+
RenderComponent as default
|
|
43
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
+
var __spreadValues = (a, b) => {
|
|
7
|
+
for (var prop in b || (b = {}))
|
|
8
|
+
if (__hasOwnProp.call(b, prop))
|
|
9
|
+
__defNormalProp(a, prop, b[prop]);
|
|
10
|
+
if (__getOwnPropSymbols)
|
|
11
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
12
|
+
if (__propIsEnum.call(b, prop))
|
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
|
+
}
|
|
15
|
+
return a;
|
|
16
|
+
};
|
|
17
|
+
import * as React from "react";
|
|
18
|
+
import RenderBlock from "./render-block.js";
|
|
19
|
+
function RenderRepeatedBlock(props) {
|
|
20
|
+
const _context = __spreadValues({}, props["_context"]);
|
|
21
|
+
_context.BuilderContext = {
|
|
22
|
+
get content() {
|
|
23
|
+
return props.repeatContext.content;
|
|
24
|
+
},
|
|
25
|
+
get state() {
|
|
26
|
+
return props.repeatContext.state;
|
|
27
|
+
},
|
|
28
|
+
get context() {
|
|
29
|
+
return props.repeatContext.context;
|
|
30
|
+
},
|
|
31
|
+
get apiKey() {
|
|
32
|
+
return props.repeatContext.apiKey;
|
|
33
|
+
},
|
|
34
|
+
get registeredComponents() {
|
|
35
|
+
return props.repeatContext.registeredComponents;
|
|
36
|
+
},
|
|
37
|
+
get inheritedStyles() {
|
|
38
|
+
return props.repeatContext.inheritedStyles;
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
return /* @__PURE__ */ React.createElement(RenderBlock, {
|
|
42
|
+
block: props.block,
|
|
43
|
+
context: props.repeatContext,
|
|
44
|
+
_context
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
export {
|
|
48
|
+
RenderRepeatedBlock as default
|
|
49
|
+
};
|
|
File without changes
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
+
var __spreadValues = (a, b) => {
|
|
7
|
+
for (var prop in b || (b = {}))
|
|
8
|
+
if (__hasOwnProp.call(b, prop))
|
|
9
|
+
__defNormalProp(a, prop, b[prop]);
|
|
10
|
+
if (__getOwnPropSymbols)
|
|
11
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
12
|
+
if (__propIsEnum.call(b, prop))
|
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
|
+
}
|
|
15
|
+
return a;
|
|
16
|
+
};
|
|
17
|
+
import * as React from "react";
|
|
18
|
+
import { isEditing } from "../functions/is-editing.js";
|
|
19
|
+
import BlockStyles from "./render-block/block-styles.js";
|
|
20
|
+
import RenderBlock from "./render-block/render-block.js";
|
|
21
|
+
function RenderBlocks(props) {
|
|
22
|
+
var _a, _b;
|
|
23
|
+
const _context = __spreadValues({}, props["_context"]);
|
|
24
|
+
const state = {
|
|
25
|
+
get className() {
|
|
26
|
+
var _a2;
|
|
27
|
+
return "builder-blocks" + (!((_a2 = props.blocks) == null ? void 0 : _a2.length) ? " no-blocks" : "");
|
|
28
|
+
},
|
|
29
|
+
onClick() {
|
|
30
|
+
var _a2, _b2;
|
|
31
|
+
if (isEditing() && !((_a2 = props.blocks) == null ? void 0 : _a2.length)) {
|
|
32
|
+
(_b2 = window.parent) == null ? void 0 : _b2.postMessage({
|
|
33
|
+
type: "builder.clickEmptyBlocks",
|
|
34
|
+
data: {
|
|
35
|
+
parentElementId: props.parent,
|
|
36
|
+
dataPath: props.path
|
|
37
|
+
}
|
|
38
|
+
}, "*");
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
onMouseEnter() {
|
|
42
|
+
var _a2, _b2;
|
|
43
|
+
if (isEditing() && !((_a2 = props.blocks) == null ? void 0 : _a2.length)) {
|
|
44
|
+
(_b2 = window.parent) == null ? void 0 : _b2.postMessage({
|
|
45
|
+
type: "builder.hoverEmptyBlocks",
|
|
46
|
+
data: {
|
|
47
|
+
parentElementId: props.parent,
|
|
48
|
+
dataPath: props.path
|
|
49
|
+
}
|
|
50
|
+
}, "*");
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
const builderContext = _context["BuilderContext"];
|
|
55
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", {
|
|
56
|
+
className: state.className + " div-4f307ff9",
|
|
57
|
+
"builder-path": props.path,
|
|
58
|
+
"builder-parent-id": props.parent,
|
|
59
|
+
dataSet: {
|
|
60
|
+
class: state.className
|
|
61
|
+
},
|
|
62
|
+
style: props.styleProp
|
|
63
|
+
}, props.blocks ? /* @__PURE__ */ React.createElement(React.Fragment, null, (_a = props.blocks) == null ? void 0 : _a.map((block) => /* @__PURE__ */ React.createElement(RenderBlock, {
|
|
64
|
+
key: "render-block-" + block.id,
|
|
65
|
+
block,
|
|
66
|
+
context: builderContext,
|
|
67
|
+
_context
|
|
68
|
+
}))) : null, props.blocks ? /* @__PURE__ */ React.createElement(React.Fragment, null, (_b = props.blocks) == null ? void 0 : _b.map((block) => /* @__PURE__ */ React.createElement(BlockStyles, {
|
|
69
|
+
key: "block-style-" + block.id,
|
|
70
|
+
block,
|
|
71
|
+
context: builderContext,
|
|
72
|
+
_context
|
|
73
|
+
}))) : null), /* @__PURE__ */ React.createElement("style", null, `.div-4f307ff9 {
|
|
74
|
+
display: flex;
|
|
75
|
+
flex-direction: column;
|
|
76
|
+
align-items: stretch; }`));
|
|
77
|
+
}
|
|
78
|
+
export {
|
|
79
|
+
RenderBlocks as default
|
|
80
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React, { useEffect } from "react";
|
|
2
|
+
import { setupBrowserForEditing } from "../../scripts/init-editing.js";
|
|
3
|
+
function BuilderEditingWrapper(props) {
|
|
4
|
+
useEffect(() => {
|
|
5
|
+
setupBrowserForEditing();
|
|
6
|
+
if (props.components) {
|
|
7
|
+
for (const component of props.components) {
|
|
8
|
+
window.parent.postMessage({
|
|
9
|
+
type: "builder.registerComponent",
|
|
10
|
+
data: component
|
|
11
|
+
}, "*");
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
function onMessage(e) {
|
|
15
|
+
var _a, _b;
|
|
16
|
+
switch ((_a = e.data) == null ? void 0 : _a.type) {
|
|
17
|
+
case "builder.contentUpdate": {
|
|
18
|
+
(_b = props.onUpdate) == null ? void 0 : _b.call(props, e.data.data);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
addEventListener("message", onMessage);
|
|
23
|
+
return () => window.removeEventListener("message", onMessage);
|
|
24
|
+
}, [props.model]);
|
|
25
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
26
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
27
|
+
onClickCapture: (e) => {
|
|
28
|
+
e.stopPropagation();
|
|
29
|
+
e.preventDefault();
|
|
30
|
+
}
|
|
31
|
+
}, props.children);
|
|
32
|
+
}
|
|
33
|
+
export {
|
|
34
|
+
BuilderEditingWrapper
|
|
35
|
+
};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
+
var __spreadValues = (a, b) => {
|
|
7
|
+
for (var prop in b || (b = {}))
|
|
8
|
+
if (__hasOwnProp.call(b, prop))
|
|
9
|
+
__defNormalProp(a, prop, b[prop]);
|
|
10
|
+
if (__getOwnPropSymbols)
|
|
11
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
12
|
+
if (__propIsEnum.call(b, prop))
|
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
|
+
}
|
|
15
|
+
return a;
|
|
16
|
+
};
|
|
17
|
+
import * as React from "react";
|
|
18
|
+
import RenderInlinedStyles from "../../render-inlined-styles.js";
|
|
19
|
+
function RenderContentStyles(props) {
|
|
20
|
+
const _context = __spreadValues({}, props["_context"]);
|
|
21
|
+
const state = {
|
|
22
|
+
getCssFromFont(font) {
|
|
23
|
+
var _a, _b;
|
|
24
|
+
const family = font.family + (font.kind && !font.kind.includes("#") ? ", " + font.kind : "");
|
|
25
|
+
const name = family.split(",")[0];
|
|
26
|
+
const url = (_b = font.fileUrl) != null ? _b : (_a = font == null ? void 0 : font.files) == null ? void 0 : _a.regular;
|
|
27
|
+
let str = "";
|
|
28
|
+
if (url && family && name) {
|
|
29
|
+
str += `
|
|
30
|
+
@font-face {
|
|
31
|
+
font-family: "${family}";
|
|
32
|
+
src: local("${name}"), url('${url}') format('woff2');
|
|
33
|
+
font-display: fallback;
|
|
34
|
+
font-weight: 400;
|
|
35
|
+
}
|
|
36
|
+
`.trim();
|
|
37
|
+
}
|
|
38
|
+
if (font.files) {
|
|
39
|
+
for (const weight in font.files) {
|
|
40
|
+
const isNumber = String(Number(weight)) === weight;
|
|
41
|
+
if (!isNumber) {
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
const weightUrl = font.files[weight];
|
|
45
|
+
if (weightUrl && weightUrl !== url) {
|
|
46
|
+
str += `
|
|
47
|
+
@font-face {
|
|
48
|
+
font-family: "${family}";
|
|
49
|
+
src: url('${weightUrl}') format('woff2');
|
|
50
|
+
font-display: fallback;
|
|
51
|
+
font-weight: ${weight};
|
|
52
|
+
}
|
|
53
|
+
`.trim();
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return str;
|
|
58
|
+
},
|
|
59
|
+
getFontCss({ customFonts }) {
|
|
60
|
+
var _a;
|
|
61
|
+
return ((_a = customFonts == null ? void 0 : customFonts.map((font) => this.getCssFromFont(font))) == null ? void 0 : _a.join(" ")) || "";
|
|
62
|
+
},
|
|
63
|
+
get injectedStyles() {
|
|
64
|
+
return `
|
|
65
|
+
${props.cssCode || ""}
|
|
66
|
+
${state.getFontCss({
|
|
67
|
+
customFonts: props.customFonts
|
|
68
|
+
})}`;
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
return /* @__PURE__ */ React.createElement(RenderInlinedStyles, {
|
|
72
|
+
styles: state.injectedStyles,
|
|
73
|
+
_context
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
export {
|
|
77
|
+
RenderContentStyles as default
|
|
78
|
+
};
|
|
@@ -0,0 +1,200 @@
|
|
|
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
|
+
import * as React from "react";
|
|
21
|
+
import { getDefaultRegisteredComponents } from "../../constants/builder-registered-components.js";
|
|
22
|
+
import { TARGET } from "../../constants/target.js";
|
|
23
|
+
import { evaluate } from "../../functions/evaluate.js";
|
|
24
|
+
import { getFetch } from "../../functions/get-fetch.js";
|
|
25
|
+
import { isEditing } from "../../functions/is-editing.js";
|
|
26
|
+
import {
|
|
27
|
+
components
|
|
28
|
+
} from "../../functions/register-component.js";
|
|
29
|
+
import { _track } from "../../functions/track.js";
|
|
30
|
+
import RenderBlocks from "../render-blocks.js";
|
|
31
|
+
import RenderContentStyles from "./components/render-styles.js";
|
|
32
|
+
function RenderContent(props) {
|
|
33
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
34
|
+
const _context = __spreadValues({}, props["_context"]);
|
|
35
|
+
const state = {
|
|
36
|
+
forceReRenderCount: 0,
|
|
37
|
+
get useContent() {
|
|
38
|
+
var _a2, _b2;
|
|
39
|
+
if (!props.content && !state.overrideContent) {
|
|
40
|
+
return void 0;
|
|
41
|
+
}
|
|
42
|
+
const mergedContent = __spreadProps(__spreadValues(__spreadValues({}, props.content), state.overrideContent), {
|
|
43
|
+
data: __spreadValues(__spreadValues(__spreadValues({}, (_a2 = props.content) == null ? void 0 : _a2.data), props.data), (_b2 = state.overrideContent) == null ? void 0 : _b2.data)
|
|
44
|
+
});
|
|
45
|
+
return mergedContent;
|
|
46
|
+
},
|
|
47
|
+
overrideContent: null,
|
|
48
|
+
update: 0,
|
|
49
|
+
get canTrackToUse() {
|
|
50
|
+
return props.canTrack || true;
|
|
51
|
+
},
|
|
52
|
+
overrideState: {},
|
|
53
|
+
get contentState() {
|
|
54
|
+
var _a2, _b2;
|
|
55
|
+
return __spreadValues(__spreadValues(__spreadValues(__spreadValues({}, (_b2 = (_a2 = props.content) == null ? void 0 : _a2.data) == null ? void 0 : _b2.state), props.data), props.locale ? {
|
|
56
|
+
locale: props.locale
|
|
57
|
+
} : {}), state.overrideState);
|
|
58
|
+
},
|
|
59
|
+
get contextContext() {
|
|
60
|
+
return props.context || {};
|
|
61
|
+
},
|
|
62
|
+
get allRegisteredComponents() {
|
|
63
|
+
const allComponentsArray = [
|
|
64
|
+
...getDefaultRegisteredComponents(),
|
|
65
|
+
...components,
|
|
66
|
+
...props.customComponents || []
|
|
67
|
+
];
|
|
68
|
+
const allComponents = allComponentsArray.reduce((acc, curr) => __spreadProps(__spreadValues({}, acc), {
|
|
69
|
+
[curr.name]: curr
|
|
70
|
+
}), {});
|
|
71
|
+
return allComponents;
|
|
72
|
+
},
|
|
73
|
+
processMessage(event) {
|
|
74
|
+
const { data } = event;
|
|
75
|
+
if (data) {
|
|
76
|
+
switch (data.type) {
|
|
77
|
+
case "builder.contentUpdate": {
|
|
78
|
+
const messageContent = data.data;
|
|
79
|
+
const key = messageContent.key || messageContent.alias || messageContent.entry || messageContent.modelName;
|
|
80
|
+
const contentData = messageContent.data;
|
|
81
|
+
if (key === props.model) {
|
|
82
|
+
state.overrideContent = contentData;
|
|
83
|
+
state.forceReRenderCount = state.forceReRenderCount + 1;
|
|
84
|
+
}
|
|
85
|
+
break;
|
|
86
|
+
}
|
|
87
|
+
case "builder.patchUpdates": {
|
|
88
|
+
break;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
evaluateJsCode() {
|
|
94
|
+
var _a2, _b2;
|
|
95
|
+
const jsCode = (_b2 = (_a2 = state.useContent) == null ? void 0 : _a2.data) == null ? void 0 : _b2.jsCode;
|
|
96
|
+
if (jsCode) {
|
|
97
|
+
evaluate({
|
|
98
|
+
code: jsCode,
|
|
99
|
+
context: state.contextContext,
|
|
100
|
+
state: state.contentState
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
get httpReqsData() {
|
|
105
|
+
return {};
|
|
106
|
+
},
|
|
107
|
+
onClick(_event) {
|
|
108
|
+
var _a2, _b2;
|
|
109
|
+
if (state.useContent) {
|
|
110
|
+
const variationId = (_a2 = state.useContent) == null ? void 0 : _a2.testVariationId;
|
|
111
|
+
const contentId = (_b2 = state.useContent) == null ? void 0 : _b2.id;
|
|
112
|
+
_track({
|
|
113
|
+
type: "click",
|
|
114
|
+
canTrack: state.canTrackToUse,
|
|
115
|
+
contentId,
|
|
116
|
+
apiKey: props.apiKey,
|
|
117
|
+
variationId: variationId !== contentId ? variationId : void 0
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
evalExpression(expression) {
|
|
122
|
+
return expression.replace(/{{([^}]+)}}/g, (_match, group) => evaluate({
|
|
123
|
+
code: group,
|
|
124
|
+
context: state.contextContext,
|
|
125
|
+
state: state.contentState
|
|
126
|
+
}));
|
|
127
|
+
},
|
|
128
|
+
handleRequest({ url, key }) {
|
|
129
|
+
getFetch().then((fetch) => fetch(url)).then((response) => response.json()).then((json) => {
|
|
130
|
+
const newOverrideState = __spreadProps(__spreadValues({}, state.overrideState), {
|
|
131
|
+
[key]: json
|
|
132
|
+
});
|
|
133
|
+
state.overrideState = newOverrideState;
|
|
134
|
+
}).catch((err) => {
|
|
135
|
+
console.log("error fetching dynamic data", url, err);
|
|
136
|
+
});
|
|
137
|
+
},
|
|
138
|
+
runHttpRequests() {
|
|
139
|
+
var _a2, _b2, _c2;
|
|
140
|
+
const requests = (_c2 = (_b2 = (_a2 = state.useContent) == null ? void 0 : _a2.data) == null ? void 0 : _b2.httpRequests) != null ? _c2 : {};
|
|
141
|
+
Object.entries(requests).forEach(([key, url]) => {
|
|
142
|
+
if (url && (!state.httpReqsData[key] || isEditing())) {
|
|
143
|
+
const evaluatedUrl = state.evalExpression(url);
|
|
144
|
+
state.handleRequest({
|
|
145
|
+
url: evaluatedUrl,
|
|
146
|
+
key
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
},
|
|
151
|
+
emitStateUpdate() {
|
|
152
|
+
if (isEditing()) {
|
|
153
|
+
window.dispatchEvent(new CustomEvent("builder:component:stateChange", {
|
|
154
|
+
detail: {
|
|
155
|
+
state: state.contentState,
|
|
156
|
+
ref: {
|
|
157
|
+
name: props.model
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}));
|
|
161
|
+
}
|
|
162
|
+
},
|
|
163
|
+
get shouldRenderContentStyles() {
|
|
164
|
+
var _a2, _b2, _c2, _d2, _e2;
|
|
165
|
+
return Boolean((((_b2 = (_a2 = state.useContent) == null ? void 0 : _a2.data) == null ? void 0 : _b2.cssCode) || ((_e2 = (_d2 = (_c2 = state.useContent) == null ? void 0 : _c2.data) == null ? void 0 : _d2.customFonts) == null ? void 0 : _e2.length)) && TARGET !== "reactNative");
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
_context.BuilderContext = {
|
|
169
|
+
get content() {
|
|
170
|
+
return state.useContent;
|
|
171
|
+
},
|
|
172
|
+
get state() {
|
|
173
|
+
return state.contentState;
|
|
174
|
+
},
|
|
175
|
+
get context() {
|
|
176
|
+
return state.contextContext;
|
|
177
|
+
},
|
|
178
|
+
get apiKey() {
|
|
179
|
+
return props.apiKey;
|
|
180
|
+
},
|
|
181
|
+
get registeredComponents() {
|
|
182
|
+
return state.allRegisteredComponents;
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, state.useContent ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", {
|
|
186
|
+
"builder-content-id": (_a = state.useContent) == null ? void 0 : _a.id,
|
|
187
|
+
"builder-model": props.model
|
|
188
|
+
}, state.shouldRenderContentStyles ? /* @__PURE__ */ React.createElement(RenderContentStyles, {
|
|
189
|
+
cssCode: (_c = (_b = state.useContent) == null ? void 0 : _b.data) == null ? void 0 : _c.cssCode,
|
|
190
|
+
customFonts: (_e = (_d = state.useContent) == null ? void 0 : _d.data) == null ? void 0 : _e.customFonts,
|
|
191
|
+
_context
|
|
192
|
+
}) : null, /* @__PURE__ */ React.createElement(RenderBlocks, {
|
|
193
|
+
blocks: (_g = (_f = state.useContent) == null ? void 0 : _f.data) == null ? void 0 : _g.blocks,
|
|
194
|
+
key: state.forceReRenderCount,
|
|
195
|
+
_context
|
|
196
|
+
}))) : null);
|
|
197
|
+
}
|
|
198
|
+
export {
|
|
199
|
+
RenderContent as default
|
|
200
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
+
var __spreadValues = (a, b) => {
|
|
7
|
+
for (var prop in b || (b = {}))
|
|
8
|
+
if (__hasOwnProp.call(b, prop))
|
|
9
|
+
__defNormalProp(a, prop, b[prop]);
|
|
10
|
+
if (__getOwnPropSymbols)
|
|
11
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
12
|
+
if (__propIsEnum.call(b, prop))
|
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
|
+
}
|
|
15
|
+
return a;
|
|
16
|
+
};
|
|
17
|
+
import * as React from "react";
|
|
18
|
+
import { TARGET } from "../constants/target.js";
|
|
19
|
+
function RenderInlinedStyles(props) {
|
|
20
|
+
const _context = __spreadValues({}, props["_context"]);
|
|
21
|
+
const state = {
|
|
22
|
+
get injectedStyleScript() {
|
|
23
|
+
return `<${state.tag}>${props.styles}</${state.tag}>`;
|
|
24
|
+
},
|
|
25
|
+
get tag() {
|
|
26
|
+
return "style";
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
const TagRef = state.tag;
|
|
30
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, TARGET === "svelte" ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", {
|
|
31
|
+
dangerouslySetInnerHTML: { __html: state.injectedStyleScript }
|
|
32
|
+
})) : /* @__PURE__ */ React.createElement(TagRef, null, props.styles));
|
|
33
|
+
}
|
|
34
|
+
export {
|
|
35
|
+
RenderInlinedStyles as default
|
|
36
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
+
var __spreadValues = (a, b) => {
|
|
7
|
+
for (var prop in b || (b = {}))
|
|
8
|
+
if (__hasOwnProp.call(b, prop))
|
|
9
|
+
__defNormalProp(a, prop, b[prop]);
|
|
10
|
+
if (__getOwnPropSymbols)
|
|
11
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
12
|
+
if (__propIsEnum.call(b, prop))
|
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
|
+
}
|
|
15
|
+
return a;
|
|
16
|
+
};
|
|
17
|
+
import { default as Button } from "../blocks/button/button.js";
|
|
18
|
+
import { componentInfo as buttonComponentInfo } from "../blocks/button/component-info.js";
|
|
19
|
+
import { default as Columns } from "../blocks/columns/columns.js";
|
|
20
|
+
import { componentInfo as columnsComponentInfo } from "../blocks/columns/component-info.js";
|
|
21
|
+
import { componentInfo as fragmentComponentInfo } from "../blocks/fragment/component-info.js";
|
|
22
|
+
import { default as Fragment } from "../blocks/fragment/fragment.js";
|
|
23
|
+
import { componentInfo as imageComponentInfo } from "../blocks/image/component-info.js";
|
|
24
|
+
import { default as Image } from "../blocks/image/image.js";
|
|
25
|
+
import { componentInfo as sectionComponentInfo } from "../blocks/section/component-info.js";
|
|
26
|
+
import { default as Section } from "../blocks/section/section.js";
|
|
27
|
+
import { componentInfo as symbolComponentInfo } from "../blocks/symbol/component-info.js";
|
|
28
|
+
import { default as Symbol } from "../blocks/symbol/symbol.js";
|
|
29
|
+
import { componentInfo as textComponentInfo } from "../blocks/text/component-info.js";
|
|
30
|
+
import { default as Text } from "../blocks/text/text.js";
|
|
31
|
+
import { componentInfo as videoComponentInfo } from "../blocks/video/component-info.js";
|
|
32
|
+
import { default as Video } from "../blocks/video/video.js";
|
|
33
|
+
import { componentInfo as embedComponentInfo } from "../blocks/embed/component-info.js";
|
|
34
|
+
import { default as embed } from "../blocks/embed/embed.js";
|
|
35
|
+
import { default as Img } from "../blocks/img/img.js";
|
|
36
|
+
import { componentInfo as imgComponentInfo } from "../blocks/img/component-info.js";
|
|
37
|
+
import { default as customCode } from "../blocks/custom-code/custom-code.js";
|
|
38
|
+
import { componentInfo as customCodeInfo } from "../blocks/custom-code/component-info.js";
|
|
39
|
+
const getDefaultRegisteredComponents = () => [
|
|
40
|
+
__spreadValues({ component: Columns }, columnsComponentInfo),
|
|
41
|
+
__spreadValues({ component: Image }, imageComponentInfo),
|
|
42
|
+
__spreadValues({ component: Img }, imgComponentInfo),
|
|
43
|
+
__spreadValues({ component: Text }, textComponentInfo),
|
|
44
|
+
__spreadValues({ component: Video }, videoComponentInfo),
|
|
45
|
+
__spreadValues({ component: Symbol }, symbolComponentInfo),
|
|
46
|
+
__spreadValues({ component: Button }, buttonComponentInfo),
|
|
47
|
+
__spreadValues({ component: Section }, sectionComponentInfo),
|
|
48
|
+
__spreadValues({ component: Fragment }, fragmentComponentInfo),
|
|
49
|
+
__spreadValues({ component: embed }, embedComponentInfo),
|
|
50
|
+
__spreadValues({ component: customCode }, customCodeInfo)
|
|
51
|
+
];
|
|
52
|
+
export {
|
|
53
|
+
getDefaultRegisteredComponents
|
|
54
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { fastClone } from "../functions/fast-clone";
|
|
2
|
+
const SIZES = {
|
|
3
|
+
small: {
|
|
4
|
+
min: 320,
|
|
5
|
+
default: 321,
|
|
6
|
+
max: 640
|
|
7
|
+
},
|
|
8
|
+
medium: {
|
|
9
|
+
min: 641,
|
|
10
|
+
default: 642,
|
|
11
|
+
max: 991
|
|
12
|
+
},
|
|
13
|
+
large: {
|
|
14
|
+
min: 990,
|
|
15
|
+
default: 991,
|
|
16
|
+
max: 1200
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
const getMaxWidthQueryForSize = (size, sizeValues = SIZES) => `@media (max-width: ${sizeValues[size].max}px)`;
|
|
20
|
+
const getSizesForBreakpoints = ({ small, medium }) => {
|
|
21
|
+
const newSizes = fastClone(SIZES);
|
|
22
|
+
if (!small || !medium) {
|
|
23
|
+
return newSizes;
|
|
24
|
+
}
|
|
25
|
+
const smallMin = Math.floor(small / 2);
|
|
26
|
+
newSizes.small = {
|
|
27
|
+
max: small,
|
|
28
|
+
min: smallMin,
|
|
29
|
+
default: smallMin + 1
|
|
30
|
+
};
|
|
31
|
+
const mediumMin = newSizes.small.max + 1;
|
|
32
|
+
newSizes.medium = {
|
|
33
|
+
max: medium,
|
|
34
|
+
min: mediumMin,
|
|
35
|
+
default: mediumMin + 1
|
|
36
|
+
};
|
|
37
|
+
const largeMin = newSizes.medium.max + 1;
|
|
38
|
+
newSizes.large = {
|
|
39
|
+
max: 2e3,
|
|
40
|
+
min: largeMin,
|
|
41
|
+
default: largeMin + 1
|
|
42
|
+
};
|
|
43
|
+
return newSizes;
|
|
44
|
+
};
|
|
45
|
+
export {
|
|
46
|
+
getMaxWidthQueryForSize,
|
|
47
|
+
getSizesForBreakpoints
|
|
48
|
+
};
|