@makeswift/runtime 0.1.2 → 0.1.5
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/Box2.cjs.js +54 -0
- package/dist/Box2.cjs.js.map +1 -0
- package/dist/Box2.es.js +52 -0
- package/dist/Box2.es.js.map +1 -0
- 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/grid-item.cjs.js +594 -0
- package/dist/grid-item.cjs.js.map +1 -0
- package/dist/grid-item.es.js +585 -0
- package/dist/grid-item.es.js.map +1 -0
- package/dist/index.cjs.js +128 -10
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.cjs3.js +1 -12
- package/dist/index.cjs3.js.map +1 -1
- package/dist/index.es.js +129 -12
- package/dist/index.es.js.map +1 -1
- package/dist/index.es2.js +1 -1
- package/dist/index.es3.js +2 -12
- 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/slot.cjs.js +130 -0
- package/dist/slot.cjs.js.map +1 -0
- package/dist/slot.es.js +123 -0
- package/dist/slot.es.js.map +1 -0
- 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/api/react.d.ts.map +1 -1
- package/dist/types/components/builtin/Box/Box2.d.ts +8 -0
- package/dist/types/components/builtin/Box/Box2.d.ts.map +1 -0
- package/dist/types/components/experimental/box-placeholder.d.ts +2 -0
- package/dist/types/components/experimental/box-placeholder.d.ts.map +1 -0
- package/dist/types/components/experimental/box.d.ts +9 -0
- package/dist/types/components/experimental/box.d.ts.map +1 -0
- package/dist/types/components/experimental/index.d.ts +2 -0
- package/dist/types/components/experimental/index.d.ts.map +1 -0
- package/dist/types/components/hooks/useTable.d.ts +66 -0
- package/dist/types/components/hooks/useTable.d.ts.map +1 -0
- package/dist/types/components/shared/grid-item.d.ts +17 -0
- package/dist/types/components/shared/grid-item.d.ts.map +1 -0
- 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/slot.d.ts +42 -0
- package/dist/types/controls/slot.d.ts.map +1 -0
- package/dist/types/css/border-radius.d.ts +20 -0
- package/dist/types/css/border-radius.d.ts.map +1 -0
- package/dist/types/css/border.d.ts +31 -0
- package/dist/types/css/border.d.ts.map +1 -0
- package/dist/types/css/box-shadow.d.ts +19 -0
- package/dist/types/css/box-shadow.d.ts.map +1 -0
- package/dist/types/css/color.d.ts +5 -0
- package/dist/types/css/color.d.ts.map +1 -0
- package/dist/types/css/length-percentage.d.ts +10 -0
- package/dist/types/css/length-percentage.d.ts.map +1 -0
- package/dist/types/css/length.d.ts +14 -0
- package/dist/types/css/length.d.ts.map +1 -0
- package/dist/types/css/margin.d.ts +20 -0
- package/dist/types/css/margin.d.ts.map +1 -0
- package/dist/types/css/padding.d.ts +20 -0
- package/dist/types/css/padding.d.ts.map +1 -0
- 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/slot.d.ts +26 -0
- package/dist/types/runtimes/react/controls/slot.d.ts.map +1 -0
- package/dist/types/runtimes/react/controls.d.ts.map +1 -1
- package/dist/types/runtimes/react/use-style.d.ts +3 -0
- package/dist/types/runtimes/react/use-style.d.ts.map +1 -0
- package/dist/types/use-global-style.d.ts +3 -0
- package/dist/types/use-global-style.d.ts.map +1 -0
- package/dist/types/use-grid-item-style.d.ts +1 -0
- package/dist/types/use-grid-item-style.d.ts.map +1 -0
- package/dist/types/use-style.d.ts +3 -0
- package/dist/types/use-style.d.ts.map +1 -0
- 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,7 +50,7 @@ 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
56
|
let href = "#";
|
|
@@ -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";
|
|
@@ -447,6 +448,8 @@ class MakeswiftClient {
|
|
|
447
448
|
variables: introspectionData
|
|
448
449
|
});
|
|
449
450
|
res.data.pagePathnamesById.forEach((pagePathnameSlice) => {
|
|
451
|
+
if (pagePathnameSlice == null)
|
|
452
|
+
return;
|
|
450
453
|
const id = Buffer.from(`Page:${pagePathnameSlice.id}`).toString("base64");
|
|
451
454
|
this.apolloClient.cache.writeFragment({
|
|
452
455
|
fragment: PagePathnameSliceFragmentDoc,
|
|
@@ -836,29 +839,57 @@ class Document$1 extends NextDocument {
|
|
|
836
839
|
}
|
|
837
840
|
}
|
|
838
841
|
const REVALIDATE_SECONDS = 1;
|
|
842
|
+
function getApiOrigin() {
|
|
843
|
+
var _a;
|
|
844
|
+
const apiOriginString = (_a = process["env"].MAKESWIFT_API_HOST) != null ? _a : "https://api.makeswift.com";
|
|
845
|
+
try {
|
|
846
|
+
const url = new URL(apiOriginString);
|
|
847
|
+
return url.origin;
|
|
848
|
+
} catch (error) {
|
|
849
|
+
const errorMessage = `"MAKESWIFT_API_HOST" environment variable must be a valid URL. Expected something like "https://api.makeswift.com" but instead received "${apiOriginString}".`;
|
|
850
|
+
throw new Error(errorMessage);
|
|
851
|
+
}
|
|
852
|
+
}
|
|
853
|
+
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}$/;
|
|
854
|
+
function getApiKey() {
|
|
855
|
+
const apiKey = process["env"].MAKESWIFT_SITE_API_KEY;
|
|
856
|
+
if (apiKey == null) {
|
|
857
|
+
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';
|
|
858
|
+
throw new Error(errorMessage);
|
|
859
|
+
}
|
|
860
|
+
if (!uuidRegExp.test(apiKey)) {
|
|
861
|
+
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`;
|
|
862
|
+
throw new Error(errorMEssage);
|
|
863
|
+
}
|
|
864
|
+
return apiKey;
|
|
865
|
+
}
|
|
839
866
|
async function getServerSideProps({
|
|
840
867
|
query: {
|
|
841
868
|
pageId
|
|
842
869
|
}
|
|
843
870
|
}) {
|
|
844
|
-
const url = `${
|
|
871
|
+
const url = `${getApiOrigin()}/v0/preview-page-data?id=${pageId}`;
|
|
845
872
|
const res = await fetch(url, {
|
|
846
873
|
headers: {
|
|
847
|
-
"x-api-key":
|
|
874
|
+
"x-api-key": getApiKey()
|
|
848
875
|
}
|
|
849
876
|
});
|
|
850
|
-
if (res.status
|
|
877
|
+
if (res.status === 404) {
|
|
851
878
|
console.error(await res.json());
|
|
852
879
|
return {
|
|
853
880
|
notFound: true
|
|
854
881
|
};
|
|
855
882
|
}
|
|
883
|
+
if (!res.ok) {
|
|
884
|
+
const json = await res.json();
|
|
885
|
+
throw new Error(json.message);
|
|
886
|
+
}
|
|
856
887
|
const page = await res.json();
|
|
857
888
|
if (page == null)
|
|
858
889
|
return {
|
|
859
890
|
notFound: true
|
|
860
891
|
};
|
|
861
|
-
const makeswiftApiEndpoint = `${
|
|
892
|
+
const makeswiftApiEndpoint = `${getApiOrigin()}/graphql`;
|
|
862
893
|
const client = new MakeswiftClient({
|
|
863
894
|
uri: makeswiftApiEndpoint
|
|
864
895
|
});
|
|
@@ -884,26 +915,30 @@ async function getStaticProps({
|
|
|
884
915
|
const {
|
|
885
916
|
path = []
|
|
886
917
|
} = params;
|
|
887
|
-
const url = `${
|
|
918
|
+
const url = `${getApiOrigin()}/v0/live-page-data?path=${path.join("/")}`;
|
|
888
919
|
const res = await fetch(url, {
|
|
889
920
|
headers: {
|
|
890
|
-
"x-api-key":
|
|
921
|
+
"x-api-key": getApiKey()
|
|
891
922
|
}
|
|
892
923
|
});
|
|
893
|
-
if (res.status
|
|
924
|
+
if (res.status === 404) {
|
|
894
925
|
console.error(await res.json());
|
|
895
926
|
return {
|
|
896
927
|
notFound: true,
|
|
897
928
|
revalidate: REVALIDATE_SECONDS
|
|
898
929
|
};
|
|
899
930
|
}
|
|
931
|
+
if (!res.ok) {
|
|
932
|
+
const json = await res.json();
|
|
933
|
+
throw new Error(json.message);
|
|
934
|
+
}
|
|
900
935
|
const page = await res.json();
|
|
901
936
|
if (page == null)
|
|
902
937
|
return {
|
|
903
938
|
notFound: true,
|
|
904
939
|
revalidate: REVALIDATE_SECONDS
|
|
905
940
|
};
|
|
906
|
-
const makeswiftApiEndpoint = `${
|
|
941
|
+
const makeswiftApiEndpoint = `${getApiOrigin()}/graphql`;
|
|
907
942
|
const client = new MakeswiftClient({
|
|
908
943
|
uri: makeswiftApiEndpoint
|
|
909
944
|
});
|
|
@@ -2099,6 +2134,16 @@ function useFile(fileId) {
|
|
|
2099
2134
|
}
|
|
2100
2135
|
const isSSR = typeof window === "undefined" || /ServerSideRendering/.test(window.navigator && window.navigator.userAgent);
|
|
2101
2136
|
const useIsomorphicLayoutEffect = isSSR ? useEffect : useLayoutEffect;
|
|
2137
|
+
function usePage(pageId) {
|
|
2138
|
+
const { error, data = {} } = useQuery(PAGE_PATHNAMES_BY_ID, {
|
|
2139
|
+
skip: pageId == null,
|
|
2140
|
+
variables: { ids: [pageId] }
|
|
2141
|
+
});
|
|
2142
|
+
if (pageId == null || error != null)
|
|
2143
|
+
return null;
|
|
2144
|
+
const { pagePathnamesById: [page] = [] } = data;
|
|
2145
|
+
return page;
|
|
2146
|
+
}
|
|
2102
2147
|
function responsiveStyle(responsiveValues, join$1, strategy) {
|
|
2103
2148
|
return join(responsiveValues, join$1, strategy).reduce((acc, { deviceId, value }) => {
|
|
2104
2149
|
const device = getDevice(deviceId);
|
|
@@ -2509,6 +2554,71 @@ function useImageControlValue(data, definition) {
|
|
|
2509
2554
|
dimensions: { width: file.dimensions.width, height: file.dimensions.height }
|
|
2510
2555
|
};
|
|
2511
2556
|
}
|
|
2557
|
+
function useLinkControlValue(link, _definition) {
|
|
2558
|
+
var _a;
|
|
2559
|
+
const page = usePage(link && link.type === "OPEN_PAGE" ? link.payload.pageId : null);
|
|
2560
|
+
const elementKey = (link == null ? void 0 : link.type) === "SCROLL_TO_ELEMENT" ? (_a = link.payload.elementIdConfig) == null ? void 0 : _a.elementKey : null;
|
|
2561
|
+
const elementId = useElementId(elementKey);
|
|
2562
|
+
let href = "#";
|
|
2563
|
+
let target;
|
|
2564
|
+
let block;
|
|
2565
|
+
if (link) {
|
|
2566
|
+
switch (link.type) {
|
|
2567
|
+
case "OPEN_PAGE": {
|
|
2568
|
+
if (page)
|
|
2569
|
+
href = `/${page.pathname}`;
|
|
2570
|
+
target = link.payload.openInNewTab ? "_blank" : "_self";
|
|
2571
|
+
break;
|
|
2572
|
+
}
|
|
2573
|
+
case "OPEN_URL": {
|
|
2574
|
+
href = link.payload.url;
|
|
2575
|
+
target = link.payload.openInNewTab ? "_blank" : "_self";
|
|
2576
|
+
break;
|
|
2577
|
+
}
|
|
2578
|
+
case "SEND_EMAIL": {
|
|
2579
|
+
const { to, subject = "", body = "" } = link.payload;
|
|
2580
|
+
if (to != null)
|
|
2581
|
+
href = `mailto:${to}?subject=${subject}&body=${body}`;
|
|
2582
|
+
break;
|
|
2583
|
+
}
|
|
2584
|
+
case "CALL_PHONE": {
|
|
2585
|
+
href = `tel:${link.payload.phoneNumber}`;
|
|
2586
|
+
break;
|
|
2587
|
+
}
|
|
2588
|
+
case "SCROLL_TO_ELEMENT": {
|
|
2589
|
+
href = `#${elementId != null ? elementId : ""}`;
|
|
2590
|
+
block = link.payload.block;
|
|
2591
|
+
break;
|
|
2592
|
+
}
|
|
2593
|
+
default:
|
|
2594
|
+
throw new RangeError(`Invalid link type "${link.type}."`);
|
|
2595
|
+
}
|
|
2596
|
+
}
|
|
2597
|
+
const handleClick = useCallback((event) => {
|
|
2598
|
+
if (event.defaultPrevented)
|
|
2599
|
+
return;
|
|
2600
|
+
if (link && link.type === "SCROLL_TO_ELEMENT") {
|
|
2601
|
+
let hash;
|
|
2602
|
+
try {
|
|
2603
|
+
hash = new URL(`http://www.example.com/${href}`).hash;
|
|
2604
|
+
} catch (error) {
|
|
2605
|
+
console.error(`Link received invalid href: ${href}`, error);
|
|
2606
|
+
}
|
|
2607
|
+
if (href != null && href === hash) {
|
|
2608
|
+
event.preventDefault();
|
|
2609
|
+
const view = event.view;
|
|
2610
|
+
scrollIntoView(view.document.querySelector(hash), {
|
|
2611
|
+
behavior: "smooth",
|
|
2612
|
+
block
|
|
2613
|
+
});
|
|
2614
|
+
if (view.location.hash !== hash)
|
|
2615
|
+
view.history.pushState({}, "", hash);
|
|
2616
|
+
}
|
|
2617
|
+
}
|
|
2618
|
+
}, [link, href, block]);
|
|
2619
|
+
const res = useMemo(() => ({ href, target, onClick: handleClick }), [href, target, handleClick]);
|
|
2620
|
+
return res;
|
|
2621
|
+
}
|
|
2512
2622
|
function ListControlValue({
|
|
2513
2623
|
definition,
|
|
2514
2624
|
data,
|
|
@@ -2593,6 +2703,12 @@ function ControlValue({
|
|
|
2593
2703
|
parameters: [data, definition],
|
|
2594
2704
|
children: (value) => children(value)
|
|
2595
2705
|
}, definition.type);
|
|
2706
|
+
case LinkControlType:
|
|
2707
|
+
return /* @__PURE__ */ jsx(RenderHook, {
|
|
2708
|
+
hook: useLinkControlValue,
|
|
2709
|
+
parameters: [data, definition],
|
|
2710
|
+
children: (value) => children(value)
|
|
2711
|
+
}, definition.type);
|
|
2596
2712
|
case ComboboxControlType:
|
|
2597
2713
|
return /* @__PURE__ */ jsx(RenderHook, {
|
|
2598
2714
|
hook: useComboboxControlValue,
|
|
@@ -2643,6 +2759,7 @@ function PropsValue({
|
|
|
2643
2759
|
case ComboboxControlType:
|
|
2644
2760
|
case ShapeControlType:
|
|
2645
2761
|
case ListControlType:
|
|
2762
|
+
case LinkControlType:
|
|
2646
2763
|
return /* @__PURE__ */ jsx(ControlValue, {
|
|
2647
2764
|
definition: descriptor,
|
|
2648
2765
|
data: props[propName],
|
|
@@ -2858,7 +2975,7 @@ const ElementData = memo(forwardRef(function ElementData2({
|
|
|
2858
2975
|
suppressRefWarning(`\`ForwardRef(${ElementData2.name})\``);
|
|
2859
2976
|
if (Component2 == null) {
|
|
2860
2977
|
return /* @__PURE__ */ jsx(FallbackComponent, {
|
|
2861
|
-
ref,
|
|
2978
|
+
ref: setHandle,
|
|
2862
2979
|
text: "Component not found"
|
|
2863
2980
|
});
|
|
2864
2981
|
}
|
|
@@ -2964,5 +3081,5 @@ const DocumentReference = memo(forwardRef(function DocumentReference2({
|
|
|
2964
3081
|
document: document2
|
|
2965
3082
|
});
|
|
2966
3083
|
}));
|
|
2967
|
-
export { Alignments as A,
|
|
3084
|
+
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 };
|
|
2968
3085
|
//# sourceMappingURL=index.es.js.map
|