@makeswift/runtime 0.1.1 → 0.1.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/dist/Box.cjs.js +1 -0
- package/dist/Box.cjs.js.map +1 -1
- package/dist/Box.es.js +1 -0
- package/dist/Box.es.js.map +1 -1
- package/dist/Button.cjs.js +1 -1
- package/dist/Button.es.js +2 -2
- package/dist/Carousel.cjs.js +1 -1
- package/dist/Carousel.es.js +2 -2
- package/dist/Countdown.cjs.js +1 -0
- package/dist/Countdown.cjs.js.map +1 -1
- package/dist/Countdown.es.js +2 -1
- package/dist/Countdown.es.js.map +1 -1
- package/dist/Divider.cjs.js +1 -0
- package/dist/Divider.cjs.js.map +1 -1
- package/dist/Divider.es.js +2 -1
- package/dist/Divider.es.js.map +1 -1
- package/dist/Embed.cjs.js +1 -0
- package/dist/Embed.cjs.js.map +1 -1
- package/dist/Embed.es.js +2 -1
- package/dist/Embed.es.js.map +1 -1
- package/dist/Form.cjs.js +1 -1
- package/dist/Form.es.js +2 -2
- package/dist/Image.cjs2.js +1 -1
- package/dist/Image.es2.js +2 -2
- package/dist/Navigation.cjs.js +1 -1
- package/dist/Navigation.es.js +2 -2
- package/dist/Root.cjs.js +1 -0
- package/dist/Root.cjs.js.map +1 -1
- package/dist/Root.es.js +1 -0
- package/dist/Root.es.js.map +1 -1
- package/dist/SocialLinks.es.js +1 -1
- package/dist/Text.cjs.js +1 -1
- package/dist/Text.es.js +2 -2
- package/dist/Video.cjs.js +1 -0
- package/dist/Video.cjs.js.map +1 -1
- package/dist/Video.es.js +1 -0
- package/dist/Video.es.js.map +1 -1
- package/dist/components.cjs.js +4 -4
- package/dist/components.es.js +4 -4
- package/dist/controls.cjs.js +2 -0
- package/dist/controls.cjs.js.map +1 -1
- package/dist/controls.es.js +1 -1
- package/dist/cssMediaRules.es.js +1 -1
- package/dist/descriptors.cjs.js.map +1 -1
- package/dist/descriptors.es.js.map +1 -1
- package/dist/index.cjs.js +144 -21
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.cjs3.js +2 -13
- package/dist/index.cjs3.js.map +1 -1
- package/dist/index.es.js +145 -23
- package/dist/index.es.js.map +1 -1
- package/dist/index.es2.js +1 -1
- package/dist/index.es3.js +3 -13
- package/dist/index.es3.js.map +1 -1
- package/dist/next.cjs.js +1 -0
- package/dist/next.cjs.js.map +1 -1
- package/dist/next.es.js +1 -0
- package/dist/next.es.js.map +1 -1
- package/dist/react-builder-preview.cjs.js +1 -0
- package/dist/react-builder-preview.cjs.js.map +1 -1
- package/dist/react-builder-preview.es.js +1 -0
- package/dist/react-builder-preview.es.js.map +1 -1
- package/dist/react.cjs.js +1 -0
- package/dist/react.cjs.js.map +1 -1
- package/dist/react.es.js +1 -0
- package/dist/react.es.js.map +1 -1
- package/dist/style.cjs.js +5 -2
- package/dist/style.cjs.js.map +1 -1
- package/dist/style.es.js +5 -2
- package/dist/style.es.js.map +1 -1
- package/dist/text-input.cjs.js +6 -0
- package/dist/text-input.cjs.js.map +1 -1
- package/dist/text-input.es.js +5 -1
- package/dist/text-input.es.js.map +1 -1
- package/dist/types/controls/control.d.ts +3 -2
- package/dist/types/controls/control.d.ts.map +1 -1
- package/dist/types/controls/index.d.ts +1 -0
- package/dist/types/controls/index.d.ts.map +1 -1
- package/dist/types/controls/link.d.ts +50 -0
- package/dist/types/controls/link.d.ts.map +1 -0
- package/dist/types/controls/style.d.ts +65 -0
- package/dist/types/controls/style.d.ts.map +1 -1
- package/dist/types/next.d.ts.map +1 -1
- package/dist/types/prop-controllers/descriptors.d.ts +4 -3
- package/dist/types/prop-controllers/descriptors.d.ts.map +1 -1
- package/dist/types/runtimes/react/controls/control.d.ts +3 -2
- package/dist/types/runtimes/react/controls/control.d.ts.map +1 -1
- package/dist/types/runtimes/react/controls/link.d.ts +11 -0
- package/dist/types/runtimes/react/controls/link.d.ts.map +1 -0
- package/dist/types/runtimes/react/controls/style.d.ts.map +1 -1
- package/dist/types/runtimes/react/controls.d.ts.map +1 -1
- package/dist/types/runtimes/react/index.d.ts.map +1 -1
- package/dist/useBoxShadow.es.js +1 -1
- package/dist/useMediaQuery.es.js +1 -1
- package/package.json +1 -1
package/dist/index.cjs3.js
CHANGED
|
@@ -40,16 +40,6 @@ function _interopDefaultLegacy(e) {
|
|
|
40
40
|
}
|
|
41
41
|
var scrollIntoView__default = /* @__PURE__ */ _interopDefaultLegacy(scrollIntoView);
|
|
42
42
|
var NextLink__default = /* @__PURE__ */ _interopDefaultLegacy(NextLink);
|
|
43
|
-
function usePage(pageId) {
|
|
44
|
-
const { error, data = {} } = next.useQuery(next.PAGE_PATHNAMES_BY_ID, {
|
|
45
|
-
skip: pageId == null,
|
|
46
|
-
variables: { ids: [pageId] }
|
|
47
|
-
});
|
|
48
|
-
if (pageId == null || error != null)
|
|
49
|
-
return null;
|
|
50
|
-
const { pagePathnamesById: [page] = [] } = data;
|
|
51
|
-
return page;
|
|
52
|
-
}
|
|
53
43
|
const Link = React.forwardRef(function Link2(_a, ref) {
|
|
54
44
|
var _b = _a, {
|
|
55
45
|
link,
|
|
@@ -60,10 +50,10 @@ const Link = React.forwardRef(function Link2(_a, ref) {
|
|
|
60
50
|
"onClick"
|
|
61
51
|
]);
|
|
62
52
|
var _a2;
|
|
63
|
-
const page = usePage(link && link.type === "OPEN_PAGE" ? link.payload.pageId : null);
|
|
53
|
+
const page = next.usePage(link && link.type === "OPEN_PAGE" ? link.payload.pageId : null);
|
|
64
54
|
const elementKey = (link == null ? void 0 : link.type) === "SCROLL_TO_ELEMENT" ? (_a2 = link.payload.elementIdConfig) == null ? void 0 : _a2.elementKey : null;
|
|
65
55
|
const elementId = next.useElementId(elementKey);
|
|
66
|
-
let href = "";
|
|
56
|
+
let href = "#";
|
|
67
57
|
let target;
|
|
68
58
|
let block;
|
|
69
59
|
if (link) {
|
|
@@ -137,5 +127,4 @@ const Link = React.forwardRef(function Link2(_a, ref) {
|
|
|
137
127
|
});
|
|
138
128
|
});
|
|
139
129
|
exports.Link = Link;
|
|
140
|
-
exports.usePage = usePage;
|
|
141
130
|
//# sourceMappingURL=index.cjs3.js.map
|
package/dist/index.cjs3.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs3.js","sources":["../src/components/
|
|
1
|
+
{"version":3,"file":"index.cjs3.js","sources":["../src/components/shared/Link/index.tsx"],"sourcesContent":["import { ComponentPropsWithoutRef, forwardRef, MouseEvent } from 'react'\nimport scrollIntoView from 'scroll-into-view-if-needed'\nimport NextLink from 'next/link'\n\nimport { LinkValue as LinkPropControllerValue } from '../../../prop-controllers/descriptors'\nimport { usePage } from '../../hooks'\nimport { useElementId } from '../../../runtimes/react'\n\ntype BaseProps = {\n link?: LinkPropControllerValue\n onClick?: (event: MouseEvent<HTMLAnchorElement>) => unknown\n}\n\ntype Props = BaseProps & Omit<ComponentPropsWithoutRef<'a'>, keyof BaseProps>\n\nexport const Link = forwardRef<HTMLAnchorElement, Props>(function Link(\n { link, onClick = () => {}, ...restOfProps }: Props,\n ref,\n) {\n const page = usePage(link && link.type === 'OPEN_PAGE' ? link.payload.pageId : null)\n const elementKey =\n link?.type === 'SCROLL_TO_ELEMENT' ? link.payload.elementIdConfig?.elementKey : null\n const elementId = useElementId(elementKey)\n\n let href = '#'\n let target: '_blank' | '_self' | undefined\n let block: 'start' | 'center' | 'end' | undefined\n\n if (link) {\n switch (link.type) {\n case 'OPEN_PAGE': {\n if (page) href = `/${page.pathname}`\n\n target = link.payload.openInNewTab ? '_blank' : '_self'\n\n break\n }\n\n case 'OPEN_URL': {\n href = link.payload.url\n\n target = link.payload.openInNewTab ? '_blank' : '_self'\n\n break\n }\n\n case 'SEND_EMAIL': {\n const { to, subject = '', body = '' } = link.payload\n\n if (to != null) href = `mailto:${to}?subject=${subject}&body=${body}`\n\n break\n }\n\n case 'CALL_PHONE': {\n href = `tel:${link.payload.phoneNumber}`\n\n break\n }\n\n case 'SCROLL_TO_ELEMENT': {\n href = `#${elementId ?? ''}`\n block = link.payload.block\n\n break\n }\n\n default:\n throw new RangeError(`Invalid link type \"${(link as any).type}.\"`)\n }\n }\n\n function handleClick(event: MouseEvent<HTMLAnchorElement>) {\n onClick(event)\n\n if (event.defaultPrevented) return\n\n /**\n * When we introduced `next/link` instead of just `a` element slate no longer prevented link from navigating within\n * content mode. This is a hack to compensate for what would be expected as slate's default behavior.\n * On upgrade of slate this can be reevaluated.\n */\n if (event.currentTarget.isContentEditable) return event.preventDefault()\n\n if (link && link.type === 'SCROLL_TO_ELEMENT') {\n let hash: string | undefined\n\n try {\n hash = new URL(`http://www.example.com/${href}`).hash\n } catch (error) {\n console.error(`Link received invalid href: ${href}`, error)\n }\n\n if (href != null && href === hash) {\n event.preventDefault()\n const view = event.view as unknown as Window\n\n scrollIntoView(view.document.querySelector(hash)!, {\n behavior: 'smooth',\n block,\n })\n\n if (view.location.hash !== hash) view.history.pushState({}, '', hash)\n }\n }\n }\n\n return (\n <NextLink href={href}>\n {/* eslint-disable-next-line */}\n <a {...restOfProps} ref={ref} target={target} onClick={handleClick} />\n </NextLink>\n )\n})\n"],"names":["Link","forwardRef","ref","link","onClick","restOfProps","page","usePage","type","payload","pageId","elementKey","elementIdConfig","elementId","useElementId","href","target","block","pathname","openInNewTab","url","to","subject","body","phoneNumber","RangeError","handleClick","event","defaultPrevented","currentTarget","isContentEditable","preventDefault","hash","URL","error","view","scrollIntoView","document","querySelector","behavior","location","history","pushState","NextLink"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAeaA,MAAAA,OAAOC,MAAAA,WAAqC,eACvD,IACAC,KACA;AAFA,eAAEC;AAAAA;AAAAA,IAAMC,UAAU,MAAM;AAAA,IAAE;AAAA,MAA1B,IAA+BC,wBAA/B,IAA+BA;AAAAA,IAA7BF;AAAAA,IAAMC;AAAAA;;AAGFE,QAAAA,OAAOC,KAAAA,QAAQJ,QAAQA,KAAKK,SAAS,cAAcL,KAAKM,QAAQC,SAAS,IAA3D;AACpB,QAAMC,aACJR,8BAAMK,UAAS,sBAAsBL,YAAKM,QAAQG,oBAAbT,oBAA8BQ,aAAa;AAC5EE,QAAAA,YAAYC,kBAAaH,UAAD;AAE1BI,MAAAA,OAAO;AACPC,MAAAA;AACAC,MAAAA;AAEJ,MAAId,MAAM;AACAA,YAAAA,KAAKK;AAAAA,WACN,aAAa;AACZF,YAAAA;AAAMS,iBAAQ,IAAGT,KAAKY;AAEjBf,iBAAAA,KAAKM,QAAQU,eAAe,WAAW;AAEhD;AAAA,MACD;AAAA,WAEI,YAAY;AACfJ,eAAOZ,KAAKM,QAAQW;AAEXjB,iBAAAA,KAAKM,QAAQU,eAAe,WAAW;AAEhD;AAAA,MACD;AAAA,WAEI,cAAc;AACX,cAAA;AAAA,UAAEE;AAAAA,UAAIC,UAAU;AAAA,UAAIC,OAAO;AAAA,YAAOpB,KAAKM;AAE7C,YAAIY,MAAM;AAAc,iBAAA,UAASA,cAAcC,gBAAgBC;AAE/D;AAAA,MACD;AAAA,WAEI,cAAc;AACT,eAAA,OAAMpB,KAAKM,QAAQe;AAE3B;AAAA,MACD;AAAA,WAEI,qBAAqB;AACxBT,eAAQ,IAAGF,gCAAa;AACxBI,gBAAQd,KAAKM,QAAQQ;AAErB;AAAA,MACD;AAAA;AAGO,cAAA,IAAIQ,WAAY,sBAAsBtB,KAAaK,QAAnD;AAAA;AAAA,EAEX;AAEQkB,uBAAYC,OAAsC;AACzDvB,YAAQuB,KAAD;AAEHA,QAAAA,MAAMC;AAAkB;AAOxBD,QAAAA,MAAME,cAAcC;AAAmB,aAAOH,MAAMI;AAEpD5B,QAAAA,QAAQA,KAAKK,SAAS,qBAAqB;AACzCwB,UAAAA;AAEA,UAAA;AACFA,eAAO,IAAIC,IAAK,0BAAyBlB,MAAlC,EAA0CiB;AAAAA,eAC1CE;AACCA,gBAAAA,MAAO,+BAA8BnB,QAAQmB,KAArD;AAAA,MACD;AAEGnB,UAAAA,QAAQ,QAAQA,SAASiB,MAAM;AACjCL,cAAMI,eAAN;AACMI,cAAAA,OAAOR,MAAMQ;AAEnBC,gCAAAA,WAAeD,KAAKE,SAASC,cAAcN,IAA5B,GAAoC;AAAA,UACjDO,UAAU;AAAA,UACVtB;AAAAA,QAAAA,CAFY;AAKVkB,YAAAA,KAAKK,SAASR,SAASA;AAAMG,eAAKM,QAAQC,UAAU,IAAI,IAAIV,IAA/B;AAAA,MAClC;AAAA,IACF;AAAA,EACF;AAED,wCACGW,kBAAAA,YAAD;AAAA,IAAU;AAAA,IAAV,+EAEStC;MAAa;AAAA,MAAU;AAAA,MAAgB,SAASqB;AAAAA,IAAAA,EAAvD;AAAA,EAAA,CAHJ;AAMD,CAlG6B;;"}
|
package/dist/index.es.js
CHANGED
|
@@ -36,7 +36,7 @@ var __publicField = (obj, key, value) => {
|
|
|
36
36
|
};
|
|
37
37
|
var _e;
|
|
38
38
|
import * as React from "react";
|
|
39
|
-
import { createContext, useContext, useEffect, useState, useMemo, useRef, Children, createElement, forwardRef, useLayoutEffect, Component, memo, useImperativeHandle } from "react";
|
|
39
|
+
import { createContext, useContext, useEffect, useState, useMemo, useRef, Children, createElement, forwardRef, useLayoutEffect, useCallback, Component, memo, useImperativeHandle } from "react";
|
|
40
40
|
import { useSyncExternalStoreWithSelector } from "use-sync-external-store/shim/with-selector";
|
|
41
41
|
import { g as getPropControllerDescriptors, i as isElementReference, a as getElementSwatchIds, b as getFileIds, d as getTypographyIds, e as getTableIds, f as getPageIds, h as getElementChildren, j as createDocumentReference, k as getComponentPropControllerDescriptors, l as configureStore, m as getDocument, n as getElementId, o as getIsInBuilder, p as getReactComponent, c as createDocument } from "./react-page.es.js";
|
|
42
42
|
import { f as registerComponentHandleEffect, g as mountComponentEffect, h as registerComponentEffect, j as registerReactComponentEffect, k as registerDocumentEffect } from "./actions.es.js";
|
|
@@ -51,12 +51,13 @@ import { BatchHttpLink } from "@apollo/client/link/batch-http";
|
|
|
51
51
|
import { P as PagePathnameSliceFragmentDoc } from "./graphql.es.js";
|
|
52
52
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
53
53
|
import { T as Types, E as ElementID, B as Backgrounds, W as Width, R as ResponsiveIconRadioGroup, M as Margin, P as Padding, a as Border, b as BorderRadius, S as Shadows, G as GapY, c as GapX, e as ResponsiveSelect, f as ResponsiveNumber, C as Checkbox, g as Grid, h as TextInput, L as Link, i as ResponsiveColor, j as TextStyle, I as Images, N as Number, D as Date$1, F as Font, k as ResponsiveLength, l as TextArea, m as Table, n as TableFormFields, o as Image, p as ResponsiveOpacity, q as NavigationLinks, r as SocialLinks, s as RichText, V as Video, t as WidthControlValueFormats } from "./descriptors.es.js";
|
|
54
|
-
import { S as SelectControlType, T as TextAreaControlType, a as TextInputControlType, N as NumberControlType, C as CheckboxControlType } from "./text-input.es.js";
|
|
54
|
+
import { L as LinkControlType, S as SelectControlType, T as TextAreaControlType, a as TextInputControlType, N as NumberControlType, C as CheckboxControlType } from "./text-input.es.js";
|
|
55
55
|
import { C as ColorControlType } from "./color.es.js";
|
|
56
56
|
import { S as ShapeControlType, L as ListControlType, C as ComboboxControlType } from "./shape.es.js";
|
|
57
57
|
import { a as ImageControlValueFormat, I as ImageControlType } from "./image.es.js";
|
|
58
58
|
import { a as StyleControlProperty, S as StyleControlType } from "./style.es.js";
|
|
59
59
|
import ColorHelper from "color";
|
|
60
|
+
import scrollIntoView from "scroll-into-view-if-needed";
|
|
60
61
|
import { findDOMNode } from "react-dom";
|
|
61
62
|
import parse from "html-react-parser";
|
|
62
63
|
import Head from "next/head";
|
|
@@ -836,29 +837,57 @@ class Document$1 extends NextDocument {
|
|
|
836
837
|
}
|
|
837
838
|
}
|
|
838
839
|
const REVALIDATE_SECONDS = 1;
|
|
840
|
+
function getApiOrigin() {
|
|
841
|
+
var _a;
|
|
842
|
+
const apiOriginString = (_a = process["env"].MAKESWIFT_API_HOST) != null ? _a : "https://api.makeswift.com";
|
|
843
|
+
try {
|
|
844
|
+
const url = new URL(apiOriginString);
|
|
845
|
+
return url.origin;
|
|
846
|
+
} catch (error) {
|
|
847
|
+
const errorMessage = `"MAKESWIFT_API_HOST" environment variable must be a valid URL. Expected something like "https://api.makeswift.com" but instead received "${apiOriginString}".`;
|
|
848
|
+
throw new Error(errorMessage);
|
|
849
|
+
}
|
|
850
|
+
}
|
|
851
|
+
const uuidRegExp = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/;
|
|
852
|
+
function getApiKey() {
|
|
853
|
+
const apiKey = process["env"].MAKESWIFT_SITE_API_KEY;
|
|
854
|
+
if (apiKey == null) {
|
|
855
|
+
const errorMessage = '"MAKESWIFT_SITE_API_KEY" environment variable must be set. Please add your site API key to your `.env.local` file. More info: https://www.makeswift.com/docs/guides/manual-setup#add-environment-variables';
|
|
856
|
+
throw new Error(errorMessage);
|
|
857
|
+
}
|
|
858
|
+
if (!uuidRegExp.test(apiKey)) {
|
|
859
|
+
const errorMEssage = `Invalid Makeswift site API key "${apiKey}". Please check your \`.env.local\` file for the "MAKESWIFT_SITE_API_KEY" environment variable. More info: https://www.makeswift.com/docs/guides/manual-setup#add-environment-variables`;
|
|
860
|
+
throw new Error(errorMEssage);
|
|
861
|
+
}
|
|
862
|
+
return apiKey;
|
|
863
|
+
}
|
|
839
864
|
async function getServerSideProps({
|
|
840
865
|
query: {
|
|
841
866
|
pageId
|
|
842
867
|
}
|
|
843
868
|
}) {
|
|
844
|
-
const url = `${
|
|
869
|
+
const url = `${getApiOrigin()}/v0/preview-page-data?id=${pageId}`;
|
|
845
870
|
const res = await fetch(url, {
|
|
846
871
|
headers: {
|
|
847
|
-
"x-api-key":
|
|
872
|
+
"x-api-key": getApiKey()
|
|
848
873
|
}
|
|
849
874
|
});
|
|
850
|
-
if (res.status
|
|
875
|
+
if (res.status === 404) {
|
|
851
876
|
console.error(await res.json());
|
|
852
877
|
return {
|
|
853
878
|
notFound: true
|
|
854
879
|
};
|
|
855
880
|
}
|
|
881
|
+
if (!res.ok) {
|
|
882
|
+
const json = await res.json();
|
|
883
|
+
throw new Error(json.message);
|
|
884
|
+
}
|
|
856
885
|
const page = await res.json();
|
|
857
886
|
if (page == null)
|
|
858
887
|
return {
|
|
859
888
|
notFound: true
|
|
860
889
|
};
|
|
861
|
-
const makeswiftApiEndpoint = `${
|
|
890
|
+
const makeswiftApiEndpoint = `${getApiOrigin()}/graphql`;
|
|
862
891
|
const client = new MakeswiftClient({
|
|
863
892
|
uri: makeswiftApiEndpoint
|
|
864
893
|
});
|
|
@@ -884,26 +913,30 @@ async function getStaticProps({
|
|
|
884
913
|
const {
|
|
885
914
|
path = []
|
|
886
915
|
} = params;
|
|
887
|
-
const url = `${
|
|
916
|
+
const url = `${getApiOrigin()}/v0/live-page-data?path=${path.join("/")}`;
|
|
888
917
|
const res = await fetch(url, {
|
|
889
918
|
headers: {
|
|
890
|
-
"x-api-key":
|
|
919
|
+
"x-api-key": getApiKey()
|
|
891
920
|
}
|
|
892
921
|
});
|
|
893
|
-
if (res.status
|
|
922
|
+
if (res.status === 404) {
|
|
894
923
|
console.error(await res.json());
|
|
895
924
|
return {
|
|
896
925
|
notFound: true,
|
|
897
926
|
revalidate: REVALIDATE_SECONDS
|
|
898
927
|
};
|
|
899
928
|
}
|
|
929
|
+
if (!res.ok) {
|
|
930
|
+
const json = await res.json();
|
|
931
|
+
throw new Error(json.message);
|
|
932
|
+
}
|
|
900
933
|
const page = await res.json();
|
|
901
934
|
if (page == null)
|
|
902
935
|
return {
|
|
903
936
|
notFound: true,
|
|
904
937
|
revalidate: REVALIDATE_SECONDS
|
|
905
938
|
};
|
|
906
|
-
const makeswiftApiEndpoint = `${
|
|
939
|
+
const makeswiftApiEndpoint = `${getApiOrigin()}/graphql`;
|
|
907
940
|
const client = new MakeswiftClient({
|
|
908
941
|
uri: makeswiftApiEndpoint
|
|
909
942
|
});
|
|
@@ -2099,6 +2132,16 @@ function useFile(fileId) {
|
|
|
2099
2132
|
}
|
|
2100
2133
|
const isSSR = typeof window === "undefined" || /ServerSideRendering/.test(window.navigator && window.navigator.userAgent);
|
|
2101
2134
|
const useIsomorphicLayoutEffect = isSSR ? useEffect : useLayoutEffect;
|
|
2135
|
+
function usePage(pageId) {
|
|
2136
|
+
const { error, data = {} } = useQuery(PAGE_PATHNAMES_BY_ID, {
|
|
2137
|
+
skip: pageId == null,
|
|
2138
|
+
variables: { ids: [pageId] }
|
|
2139
|
+
});
|
|
2140
|
+
if (pageId == null || error != null)
|
|
2141
|
+
return null;
|
|
2142
|
+
const { pagePathnamesById: [page] = [] } = data;
|
|
2143
|
+
return page;
|
|
2144
|
+
}
|
|
2102
2145
|
function responsiveStyle(responsiveValues, join$1, strategy) {
|
|
2103
2146
|
return join(responsiveValues, join$1, strategy).reduce((acc, { deviceId, value }) => {
|
|
2104
2147
|
const device = getDevice(deviceId);
|
|
@@ -2385,10 +2428,11 @@ function useStyleControlCssObject(style, controlDefinition) {
|
|
|
2385
2428
|
style == null ? void 0 : style.margin,
|
|
2386
2429
|
style == null ? void 0 : style.padding,
|
|
2387
2430
|
useBorder(style == null ? void 0 : style.border),
|
|
2388
|
-
style == null ? void 0 : style.borderRadius
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2431
|
+
style == null ? void 0 : style.borderRadius,
|
|
2432
|
+
style == null ? void 0 : style.textStyle
|
|
2433
|
+
], ([width, margin, padding, border, borderRadius, textStyle]) => {
|
|
2434
|
+
var _a, _b, _c, _d, _e2, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s;
|
|
2435
|
+
return __spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({}, properties.includes(StyleControlProperty.Width) && {
|
|
2392
2436
|
width: (_a = widthToString(width)) != null ? _a : "100%"
|
|
2393
2437
|
}), properties.includes(StyleControlProperty.Margin) && {
|
|
2394
2438
|
marginTop: (_b = marginToString(margin == null ? void 0 : margin.marginTop)) != null ? _b : 0,
|
|
@@ -2410,7 +2454,10 @@ function useStyleControlCssObject(style, controlDefinition) {
|
|
|
2410
2454
|
borderTopRightRadius: (_o = borderRadiusToString(borderRadius == null ? void 0 : borderRadius.borderTopRightRadius)) != null ? _o : 0,
|
|
2411
2455
|
borderBottomRightRadius: (_p = borderRadiusToString(borderRadius == null ? void 0 : borderRadius.borderBottomRightRadius)) != null ? _p : 0,
|
|
2412
2456
|
borderBottomLeftRadius: (_q = borderRadiusToString(borderRadius == null ? void 0 : borderRadius.borderBottomLeftRadius)) != null ? _q : 0
|
|
2413
|
-
})
|
|
2457
|
+
}), properties.includes(StyleControlProperty.TextStyle) && __spreadProps(__spreadValues(__spreadValues(__spreadValues(__spreadValues({}, (textStyle == null ? void 0 : textStyle.fontFamily) && { fontFamily: textStyle.fontFamily }), (textStyle == null ? void 0 : textStyle.letterSpacing) && { letterSpacing: textStyle.letterSpacing }), (textStyle == null ? void 0 : textStyle.fontSize) && { fontSize: fontSizeToString(textStyle.fontSize) }), (textStyle == null ? void 0 : textStyle.fontWeight) && { fontWeight: textStyle.fontWeight }), {
|
|
2458
|
+
textTransform: (_r = textStyle == null ? void 0 : textStyle.textTransform) != null ? _r : [],
|
|
2459
|
+
fontStyle: (_s = textStyle == null ? void 0 : textStyle.fontStyle) != null ? _s : []
|
|
2460
|
+
}));
|
|
2414
2461
|
}));
|
|
2415
2462
|
function widthToString(widthProperty) {
|
|
2416
2463
|
if (widthProperty == null)
|
|
@@ -2440,6 +2487,9 @@ function useStyleControlCssObject(style, controlDefinition) {
|
|
|
2440
2487
|
return null;
|
|
2441
2488
|
return `${borderRadius.value}${borderRadius.unit}`;
|
|
2442
2489
|
}
|
|
2490
|
+
function fontSizeToString(fontSize) {
|
|
2491
|
+
return `${fontSize.value}${fontSize.unit}`;
|
|
2492
|
+
}
|
|
2443
2493
|
}
|
|
2444
2494
|
const useInsertionEffectSpecifier = "useInsertionEffect";
|
|
2445
2495
|
const useInsertionEffect = (_e = React[useInsertionEffectSpecifier]) != null ? _e : React.useLayoutEffect;
|
|
@@ -2502,6 +2552,71 @@ function useImageControlValue(data, definition) {
|
|
|
2502
2552
|
dimensions: { width: file.dimensions.width, height: file.dimensions.height }
|
|
2503
2553
|
};
|
|
2504
2554
|
}
|
|
2555
|
+
function useLinkControlValue(link, _definition) {
|
|
2556
|
+
var _a;
|
|
2557
|
+
const page = usePage(link && link.type === "OPEN_PAGE" ? link.payload.pageId : null);
|
|
2558
|
+
const elementKey = (link == null ? void 0 : link.type) === "SCROLL_TO_ELEMENT" ? (_a = link.payload.elementIdConfig) == null ? void 0 : _a.elementKey : null;
|
|
2559
|
+
const elementId = useElementId(elementKey);
|
|
2560
|
+
let href = "#";
|
|
2561
|
+
let target;
|
|
2562
|
+
let block;
|
|
2563
|
+
if (link) {
|
|
2564
|
+
switch (link.type) {
|
|
2565
|
+
case "OPEN_PAGE": {
|
|
2566
|
+
if (page)
|
|
2567
|
+
href = `/${page.pathname}`;
|
|
2568
|
+
target = link.payload.openInNewTab ? "_blank" : "_self";
|
|
2569
|
+
break;
|
|
2570
|
+
}
|
|
2571
|
+
case "OPEN_URL": {
|
|
2572
|
+
href = link.payload.url;
|
|
2573
|
+
target = link.payload.openInNewTab ? "_blank" : "_self";
|
|
2574
|
+
break;
|
|
2575
|
+
}
|
|
2576
|
+
case "SEND_EMAIL": {
|
|
2577
|
+
const { to, subject = "", body = "" } = link.payload;
|
|
2578
|
+
if (to != null)
|
|
2579
|
+
href = `mailto:${to}?subject=${subject}&body=${body}`;
|
|
2580
|
+
break;
|
|
2581
|
+
}
|
|
2582
|
+
case "CALL_PHONE": {
|
|
2583
|
+
href = `tel:${link.payload.phoneNumber}`;
|
|
2584
|
+
break;
|
|
2585
|
+
}
|
|
2586
|
+
case "SCROLL_TO_ELEMENT": {
|
|
2587
|
+
href = `#${elementId != null ? elementId : ""}`;
|
|
2588
|
+
block = link.payload.block;
|
|
2589
|
+
break;
|
|
2590
|
+
}
|
|
2591
|
+
default:
|
|
2592
|
+
throw new RangeError(`Invalid link type "${link.type}."`);
|
|
2593
|
+
}
|
|
2594
|
+
}
|
|
2595
|
+
const handleClick = useCallback((event) => {
|
|
2596
|
+
if (event.defaultPrevented)
|
|
2597
|
+
return;
|
|
2598
|
+
if (link && link.type === "SCROLL_TO_ELEMENT") {
|
|
2599
|
+
let hash;
|
|
2600
|
+
try {
|
|
2601
|
+
hash = new URL(`http://www.example.com/${href}`).hash;
|
|
2602
|
+
} catch (error) {
|
|
2603
|
+
console.error(`Link received invalid href: ${href}`, error);
|
|
2604
|
+
}
|
|
2605
|
+
if (href != null && href === hash) {
|
|
2606
|
+
event.preventDefault();
|
|
2607
|
+
const view = event.view;
|
|
2608
|
+
scrollIntoView(view.document.querySelector(hash), {
|
|
2609
|
+
behavior: "smooth",
|
|
2610
|
+
block
|
|
2611
|
+
});
|
|
2612
|
+
if (view.location.hash !== hash)
|
|
2613
|
+
view.history.pushState({}, "", hash);
|
|
2614
|
+
}
|
|
2615
|
+
}
|
|
2616
|
+
}, [link, href, block]);
|
|
2617
|
+
const res = useMemo(() => ({ href, target, onClick: handleClick }), [href, target, handleClick]);
|
|
2618
|
+
return res;
|
|
2619
|
+
}
|
|
2505
2620
|
function ListControlValue({
|
|
2506
2621
|
definition,
|
|
2507
2622
|
data,
|
|
@@ -2586,6 +2701,12 @@ function ControlValue({
|
|
|
2586
2701
|
parameters: [data, definition],
|
|
2587
2702
|
children: (value) => children(value)
|
|
2588
2703
|
}, definition.type);
|
|
2704
|
+
case LinkControlType:
|
|
2705
|
+
return /* @__PURE__ */ jsx(RenderHook, {
|
|
2706
|
+
hook: useLinkControlValue,
|
|
2707
|
+
parameters: [data, definition],
|
|
2708
|
+
children: (value) => children(value)
|
|
2709
|
+
}, definition.type);
|
|
2589
2710
|
case ComboboxControlType:
|
|
2590
2711
|
return /* @__PURE__ */ jsx(RenderHook, {
|
|
2591
2712
|
hook: useComboboxControlValue,
|
|
@@ -2636,6 +2757,7 @@ function PropsValue({
|
|
|
2636
2757
|
case ComboboxControlType:
|
|
2637
2758
|
case ShapeControlType:
|
|
2638
2759
|
case ListControlType:
|
|
2760
|
+
case LinkControlType:
|
|
2639
2761
|
return /* @__PURE__ */ jsx(ControlValue, {
|
|
2640
2762
|
definition: descriptor,
|
|
2641
2763
|
data: props[propName],
|
|
@@ -2828,17 +2950,17 @@ function useDispatch() {
|
|
|
2828
2950
|
const store = useContext(Context);
|
|
2829
2951
|
return store.dispatch;
|
|
2830
2952
|
}
|
|
2831
|
-
|
|
2832
|
-
|
|
2833
|
-
|
|
2834
|
-
if (
|
|
2953
|
+
const originalError = console.error;
|
|
2954
|
+
let patched = false;
|
|
2955
|
+
function suppressRefWarning(ownerName) {
|
|
2956
|
+
if (patched === false) {
|
|
2835
2957
|
console.error = (...args) => {
|
|
2836
2958
|
if (typeof args[0] === "string" && args[0].includes("Function components cannot be given refs.") && args[0].includes(`Check the render method of \`${ownerName}\`.`)) {
|
|
2837
2959
|
return;
|
|
2838
2960
|
}
|
|
2839
|
-
return
|
|
2961
|
+
return originalError(...args);
|
|
2840
2962
|
};
|
|
2841
|
-
|
|
2963
|
+
patched = true;
|
|
2842
2964
|
}
|
|
2843
2965
|
}
|
|
2844
2966
|
const ElementData = memo(forwardRef(function ElementData2({
|
|
@@ -2848,7 +2970,7 @@ const ElementData = memo(forwardRef(function ElementData2({
|
|
|
2848
2970
|
const [handle, setHandle] = useState(null);
|
|
2849
2971
|
const [foundDomNode, setFoundDomNode] = useState(null);
|
|
2850
2972
|
useImperativeHandle(ref, () => handle != null ? handle : foundDomNode, [handle, foundDomNode]);
|
|
2851
|
-
|
|
2973
|
+
suppressRefWarning(`\`ForwardRef(${ElementData2.name})\``);
|
|
2852
2974
|
if (Component2 == null) {
|
|
2853
2975
|
return /* @__PURE__ */ jsx(FallbackComponent, {
|
|
2854
2976
|
ref,
|
|
@@ -2957,5 +3079,5 @@ const DocumentReference = memo(forwardRef(function DocumentReference2({
|
|
|
2957
3079
|
document: document2
|
|
2958
3080
|
});
|
|
2959
3081
|
}));
|
|
2960
|
-
export { Alignments as A,
|
|
3082
|
+
export { Alignments as A, findDeviceOverride as B, Contrasts as C, DocumentReference as D, Element as E, TYPOGRAPHIES_BY_ID as F, SWATCHES_BY_ID as G, shallowMergeFallbacks as H, join as I, getDevice as J, getDeviceMediaQuery as K, isNonNullable as L, FILES_BY_ID as M, useElementId as N, deepEqual as O, PageProvider as P, MakeswiftClient as Q, RuntimeProvider as R, SITE_FONTS_QUERY as S, TABLE_BY_ID as T, Document$1 as U, getServerSideProps as V, getStaticProps as W, getStaticPaths as X, Page as Y, forwardNextDynamicRef as Z, ReactRuntime as a, usePageId as b, DEFAULT_BOX_ANIMATE_TYPE as c, DEFAULT_BOX_ANIMATE_DELAY as d, DEFAULT_BOX_ANIMATE_DURATION as e, DEFAULT_ITEM_ANIMATE_TYPE as f, DEFAULT_ITEM_ANIMATE_DELAY as g, DEFAULT_ITEM_ANIMATE_DURATION as h, DEFAULT_ITEM_STAGGER_DURATION as i, useBorder as j, useResponsiveColor as k, useFile as l, usePage as m, PAGE_SNIPPETS_QUERY as n, Page$1 as o, colorToString as p, useIsomorphicLayoutEffect as q, responsiveWidth as r, Shapes as s, Sizes as t, useIsInBuilder as u, useFormContext as v, useQuery as w, useMutation as x, Provider as y, DEVICES as z };
|
|
2961
3083
|
//# sourceMappingURL=index.es.js.map
|