@makeswift/runtime 0.4.1 → 0.5.0
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 +5 -3
- package/dist/Box.cjs.js.map +1 -1
- package/dist/Box.es.js +5 -3
- package/dist/Box.es.js.map +1 -1
- package/dist/Button.cjs.js +3 -3
- package/dist/Button.es.js +3 -3
- package/dist/Carousel.cjs.js +5 -3
- package/dist/Carousel.cjs.js.map +1 -1
- package/dist/Carousel.es.js +5 -3
- package/dist/Carousel.es.js.map +1 -1
- package/dist/Countdown.cjs.js +3 -3
- package/dist/Countdown.es.js +3 -3
- package/dist/Divider.cjs.js +3 -3
- package/dist/Divider.es.js +3 -3
- package/dist/Embed.cjs.js +3 -3
- package/dist/Embed.es.js +3 -3
- package/dist/Form.cjs.js +3 -3
- package/dist/Form.es.js +3 -3
- package/dist/Image.cjs.js +20 -12
- package/dist/Image.cjs.js.map +1 -1
- package/dist/Image.es.js +20 -12
- package/dist/Image.es.js.map +1 -1
- package/dist/LiveProvider.cjs.js +62 -0
- package/dist/LiveProvider.cjs.js.map +1 -0
- package/dist/LiveProvider.es.js +60 -0
- package/dist/LiveProvider.es.js.map +1 -0
- package/dist/Navigation.cjs.js +5 -3
- package/dist/Navigation.cjs.js.map +1 -1
- package/dist/Navigation.es.js +5 -3
- package/dist/Navigation.es.js.map +1 -1
- package/dist/{react-builder-preview.cjs.js → PreviewProvider.cjs.js} +43 -16
- package/dist/PreviewProvider.cjs.js.map +1 -0
- package/dist/{react-builder-preview.es.js → PreviewProvider.es.js} +47 -15
- package/dist/PreviewProvider.es.js.map +1 -0
- package/dist/Root.cjs.js +5 -3
- package/dist/Root.cjs.js.map +1 -1
- package/dist/Root.es.js +5 -3
- package/dist/Root.es.js.map +1 -1
- package/dist/SocialLinks.cjs.js +3 -3
- package/dist/SocialLinks.es.js +3 -3
- package/dist/Text.cjs.js +3 -3
- package/dist/Text.cjs.js.map +1 -1
- package/dist/Text.es.js +3 -3
- package/dist/Text.es.js.map +1 -1
- package/dist/Video.cjs.js +3 -3
- package/dist/Video.es.js +3 -3
- package/dist/actions.es.js +1 -1
- package/dist/components.cjs.js +5 -3
- package/dist/components.cjs.js.map +1 -1
- package/dist/components.es.js +5 -3
- package/dist/components.es.js.map +1 -1
- package/dist/grid-item.cjs.js +12 -1
- package/dist/grid-item.cjs.js.map +1 -1
- package/dist/grid-item.es.js +12 -1
- package/dist/grid-item.es.js.map +1 -1
- package/dist/index.cjs.js +56 -81
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.cjs2.js +6 -7
- package/dist/index.cjs2.js.map +1 -1
- package/dist/index.es.js +51 -81
- package/dist/index.es.js.map +1 -1
- package/dist/index.es2.js +6 -7
- package/dist/index.es2.js.map +1 -1
- package/dist/next-version.cjs.js +10 -0
- package/dist/next-version.cjs.js.map +1 -0
- package/dist/next-version.es.js +5 -0
- package/dist/next-version.es.js.map +1 -0
- package/dist/next.cjs.js +3 -3
- package/dist/next.es.js +4 -4
- package/dist/react-page.es.js +1 -1
- package/dist/react.cjs.js +4 -4
- package/dist/react.es.js +4 -4
- package/dist/types/src/components/builtin/Form/components/Field/components/Checkbox/index.d.ts +1 -1
- package/dist/types/src/components/builtin/Image/Image.d.ts.map +1 -1
- package/dist/types/src/components/shared/BackgroundsContainer/components/Backgrounds/index.d.ts.map +1 -1
- package/dist/types/src/components/shared/Link/index.d.ts.map +1 -1
- package/dist/types/src/next/client.d.ts +1 -0
- package/dist/types/src/next/client.d.ts.map +1 -1
- package/dist/types/src/next/index.d.ts.map +1 -1
- package/dist/types/src/next/next-version.d.ts +3 -0
- package/dist/types/src/next/next-version.d.ts.map +1 -0
- package/dist/types/src/runtimes/react/components/LiveProvider.d.ts +11 -0
- package/dist/types/src/runtimes/react/components/LiveProvider.d.ts.map +1 -0
- package/dist/types/src/runtimes/react/components/PreviewProvider.d.ts +11 -0
- package/dist/types/src/runtimes/react/components/PreviewProvider.d.ts.map +1 -0
- package/dist/types/src/runtimes/react/index.d.ts +3 -1
- package/dist/types/src/runtimes/react/index.d.ts.map +1 -1
- package/dist/types/src/state/react-builder-preview.d.ts +3 -1
- package/dist/types/src/state/react-builder-preview.d.ts.map +1 -1
- package/package.json +4 -4
- package/dist/react-builder-preview.cjs.js.map +0 -1
- package/dist/react-builder-preview.es.js.map +0 -1
package/dist/index.cjs2.js
CHANGED
|
@@ -127,14 +127,13 @@ const Link = React.forwardRef(function Link2(_a, ref) {
|
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
129
|
if (useNextLink && href != null) {
|
|
130
|
-
return /* @__PURE__ */ jsxRuntime.jsx(NextLink__default["default"], {
|
|
130
|
+
return /* @__PURE__ */ jsxRuntime.jsx(NextLink__default["default"], __spreadProps(__spreadValues({}, restOfProps), {
|
|
131
|
+
ref,
|
|
132
|
+
target,
|
|
133
|
+
onClick: handleClick,
|
|
131
134
|
href,
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
target,
|
|
135
|
-
onClick: handleClick
|
|
136
|
-
}))
|
|
137
|
-
});
|
|
135
|
+
legacyBehavior: false
|
|
136
|
+
}));
|
|
138
137
|
}
|
|
139
138
|
return /* @__PURE__ */ jsxRuntime.jsx("a", __spreadProps(__spreadValues({}, restOfProps), {
|
|
140
139
|
ref,
|
package/dist/index.cjs2.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs2.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 { useElementId } from '../../../runtimes/react'\nimport { usePagePathnameSlice } from '../../../runtimes/react/hooks/makeswift-api'\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 pageId = link && link.type === 'OPEN_PAGE' ? link.payload.pageId : null\n const page = usePagePathnameSlice(pageId ?? null)\n const elementKey =\n link?.type === 'SCROLL_TO_ELEMENT' ? link.payload.elementIdConfig?.elementKey : null\n const elementId = useElementId(elementKey)\n\n // We don't want to use `next/link` with relative paths because Next.js will attempt to normalize\n // it and mess up the path.\n let useNextLink: boolean | undefined\n let href: string | undefined\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) {\n useNextLink = true\n\n href = `/${page.pathname}`\n }\n\n target = link.payload.openInNewTab ? '_blank' : '_self'\n\n break\n }\n\n case 'OPEN_URL': {\n useNextLink = true\n\n href = link.payload.url\n\n target = link.payload.openInNewTab ? '_blank' : '_self'\n\n break\n }\n\n case 'SEND_EMAIL': {\n useNextLink = false\n\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 useNextLink = false\n\n href = `tel:${link.payload.phoneNumber}`\n\n break\n }\n\n case 'SCROLL_TO_ELEMENT': {\n useNextLink = false\n\n href = `#${elementId ?? ''}`\n\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 if (href != null) 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 && hash != 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 if (useNextLink && href != null) {\n return (\n <NextLink
|
|
1
|
+
{"version":3,"file":"index.cjs2.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 { useElementId } from '../../../runtimes/react'\nimport { usePagePathnameSlice } from '../../../runtimes/react/hooks/makeswift-api'\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 pageId = link && link.type === 'OPEN_PAGE' ? link.payload.pageId : null\n const page = usePagePathnameSlice(pageId ?? null)\n const elementKey =\n link?.type === 'SCROLL_TO_ELEMENT' ? link.payload.elementIdConfig?.elementKey : null\n const elementId = useElementId(elementKey)\n\n // We don't want to use `next/link` with relative paths because Next.js will attempt to normalize\n // it and mess up the path.\n let useNextLink: boolean | undefined\n let href: string | undefined\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) {\n useNextLink = true\n\n href = `/${page.pathname}`\n }\n\n target = link.payload.openInNewTab ? '_blank' : '_self'\n\n break\n }\n\n case 'OPEN_URL': {\n useNextLink = true\n\n href = link.payload.url\n\n target = link.payload.openInNewTab ? '_blank' : '_self'\n\n break\n }\n\n case 'SEND_EMAIL': {\n useNextLink = false\n\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 useNextLink = false\n\n href = `tel:${link.payload.phoneNumber}`\n\n break\n }\n\n case 'SCROLL_TO_ELEMENT': {\n useNextLink = false\n\n href = `#${elementId ?? ''}`\n\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 if (href != null) 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 && hash != 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 if (useNextLink && href != null) {\n return (\n <NextLink\n {...restOfProps}\n ref={ref}\n target={target}\n onClick={handleClick}\n href={href}\n // Next.js v12 has legacyBehavior set to true by default\n legacyBehavior={false}\n />\n )\n }\n\n // eslint-disable-next-line\n return <a {...restOfProps} ref={ref} href={href} target={target} onClick={handleClick} />\n})\n"],"names":["Link","forwardRef","ref","link","onClick","restOfProps","pageId","type","payload","page","usePagePathnameSlice","elementKey","elementIdConfig","elementId","useElementId","useNextLink","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;;AAGR,QAAME,SAASH,QAAQA,KAAKI,SAAS,cAAcJ,KAAKK,QAAQF,SAAS;AACnEG,QAAAA,OAAOC,KAAAA,qBAAqBJ,0BAAU,IAAX;AACjC,QAAMK,aACJR,8BAAMI,UAAS,sBAAsBJ,YAAKK,QAAQI,oBAAbT,oBAA8BQ,aAAa;AAC5EE,QAAAA,YAAYC,kBAAaH,UAAD;AAI1BI,MAAAA;AACAC,MAAAA;AACAC,MAAAA;AACAC,MAAAA;AAEJ,MAAIf,MAAM;AACAA,YAAAA,KAAKI;AAAAA,WACN,aAAa;AAChB,YAAIE,MAAM;AACM,wBAAA;AAEdO,iBAAQ,IAAGP,KAAKU;AAAAA,QACjB;AAEQhB,iBAAAA,KAAKK,QAAQY,eAAe,WAAW;AAEhD;AAAA,MACD;AAAA,WAEI,YAAY;AACD,sBAAA;AAEdJ,eAAOb,KAAKK,QAAQa;AAEXlB,iBAAAA,KAAKK,QAAQY,eAAe,WAAW;AAEhD;AAAA,MACD;AAAA,WAEI,cAAc;AACH,sBAAA;AAER,cAAA;AAAA,UAAEE;AAAAA,UAAIC,UAAU;AAAA,UAAIC,OAAO;AAAA,YAAOrB,KAAKK;AAE7C,YAAIc,MAAM;AAAc,iBAAA,UAASA,cAAcC,gBAAgBC;AAE/D;AAAA,MACD;AAAA,WAEI,cAAc;AACH,sBAAA;AAEN,eAAA,OAAMrB,KAAKK,QAAQiB;AAE3B;AAAA,MACD;AAAA,WAEI,qBAAqB;AACV,sBAAA;AAEdT,eAAQ,IAAGH,gCAAa;AAExBK,gBAAQf,KAAKK,QAAQU;AAErB;AAAA,MACD;AAAA;AAGO,cAAA,IAAIQ,WAAY,sBAAsBvB,KAAaI,QAAnD;AAAA;AAAA,EAEX;AAEQoB,uBAAYC,OAAsC;AACzDxB,YAAQwB,KAAD;AAEHA,QAAAA,MAAMC;AAAkB;AAOxBD,QAAAA,MAAME,cAAcC;AAAmB,aAAOH,MAAMI;AAEpD7B,QAAAA,QAAQA,KAAKI,SAAS,qBAAqB;AACzC0B,UAAAA;AAEA,UAAA;AACF,YAAIjB,QAAQ;AAAMiB,iBAAO,IAAIC,IAAK,0BAAyBlB,MAAlC,EAA0CiB;AAAAA,eAC5DE;AACCA,gBAAAA,MAAO,+BAA8BnB,QAAQmB,KAArD;AAAA,MACD;AAEGnB,UAAAA,QAAQ,QAAQiB,QAAQ,QAAQjB,SAASiB,MAAM;AACjDL,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;AAEGlB,MAAAA,eAAeC,QAAQ,MAAM;AAE7B,0CAAC4B,kBAAAA,YAAD,iCACMvC,cADN;AAAA,MAEE;AAAA,MACA;AAAA,MACA,SAASsB;AAAAA,MACT;AAAA,MAEA,gBAAgB;AAAA,IAAA,EARpB;AAAA,EAWD;AAGD,8EAActB;IAAa;AAAA,IAAU;AAAA,IAAY;AAAA,IAAgB,SAASsB;AAAAA,EAAAA,EAA1E;AACD,CA7H6B;;"}
|
package/dist/index.es.js
CHANGED
|
@@ -38,20 +38,20 @@ var _c;
|
|
|
38
38
|
import * as React from "react";
|
|
39
39
|
import { useEffect, createContext, useContext, useState, useMemo, useRef, Children, createElement, forwardRef, memo, useLayoutEffect, useCallback, Component, useImperativeHandle, Suspense } from "react";
|
|
40
40
|
import { useSyncExternalStoreWithSelector } from "use-sync-external-store/shim/with-selector";
|
|
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 getBorderSwatchIds, l as isNonNullable, m as getBoxShadowsSwatchIds, n as getResponsiveColorSwatchIds, o as getComponentPropControllerDescriptors, p as getPropControllers, q as configureStore$1, r as getDocument, s as getElementId, t as getIsInBuilder, u as copyElementTree, c as createDocument, v as getReactComponent } from "./react-page.es.js";
|
|
42
|
-
import { A as ActionTypes, f as introspectedResourcesFulfilled, g as apiResourceFulfilled, t as typographiesFulfilled, h as restoreAPIResourcesCache, j as registerDocumentEffect, k as registerComponentHandleEffect, l as mountComponentEffect, n as registerComponentEffect, o as registerReactComponentEffect } from "./actions.es.js";
|
|
43
41
|
import dynamic from "next/dynamic";
|
|
44
|
-
import {
|
|
42
|
+
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 getBorderSwatchIds, l as isNonNullable, m as getBoxShadowsSwatchIds, n as getResponsiveColorSwatchIds, o as getComponentPropControllerDescriptors, p as getPropControllers, q as configureStore$1, r as getDocument, s as getElementId, t as getIsInBuilder, u as copyElementTree, v as getReactComponent } from "./react-page.es.js";
|
|
43
|
+
import { A as ActionTypes, f as introspectedResourcesFulfilled, g as apiResourceFulfilled, t as typographiesFulfilled, h as restoreAPIResourcesCache, j as registerComponentHandleEffect, k as mountComponentEffect, l as registerComponentEffect, n as registerReactComponentEffect } from "./actions.es.js";
|
|
44
|
+
import { cache, cx } from "@emotion/css";
|
|
45
|
+
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
45
46
|
import { T as Types, E as ElementID, B as Backgrounds, W as Width, h as ResponsiveIconRadioGroup, M as Margin, P as Padding, i as Border, j as BorderRadius, k as Shadows, G as GapY, l as GapX, m as ResponsiveSelect, n as ResponsiveNumber, o as Checkbox, p as Grid, q as TextInput, L as Link, r as ResponsiveColor, s as TextStyle, t as Images, N as Number$1, D as Date$1, F as Font, u as ResponsiveLength, v as TextArea, w as Table, x as TableFormFields, y as Image, z as ResponsiveOpacity, A as NavigationLinks, H as SocialLinks, J as RichText, V as Video, K as StyleControlProperty, O as ImageControlValueFormat, I as ImageControlType, C as ColorControlType, Q as BorderPropControllerFormat, U as ShadowsPropControllerFormat, X as BorderRadiusPropControllerFormat, Y as MarginPropControllerFormat, Z as PaddingPropControllerFormat, _ as WidthPropControllerFormat, S as SlotControlType, a as StyleControlType } from "./slot.es.js";
|
|
47
|
+
import { S as SelectControlType, T as TextAreaControlType, a as TextInputControlType, N as NumberControlType, C as CheckboxControlType } from "./text-input.es.js";
|
|
48
|
+
import { C as ComboboxControlType } from "./combobox.es.js";
|
|
46
49
|
import { S as ShapeControlType, L as ListControlType, b as LinkControlType } from "./control.es.js";
|
|
50
|
+
import { useSyncExternalStore } from "use-sync-external-store/shim";
|
|
51
|
+
import { KeyUtils } from "slate";
|
|
47
52
|
import { createStore, applyMiddleware } from "redux";
|
|
48
53
|
import thunk from "redux-thunk";
|
|
49
54
|
import { A as APIResourceType } from "./types.es.js";
|
|
50
|
-
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
51
|
-
import { cache, cx } from "@emotion/css";
|
|
52
|
-
import { S as SelectControlType, T as TextAreaControlType, a as TextInputControlType, N as NumberControlType, C as CheckboxControlType } from "./text-input.es.js";
|
|
53
|
-
import { C as ComboboxControlType } from "./combobox.es.js";
|
|
54
|
-
import { useSyncExternalStore } from "use-sync-external-store/shim";
|
|
55
55
|
import ColorHelper from "color";
|
|
56
56
|
import scrollIntoView from "scroll-into-view-if-needed";
|
|
57
57
|
import { g as getBox } from "./box-models.es.js";
|
|
@@ -647,17 +647,17 @@ class MakeswiftClient {
|
|
|
647
647
|
return getAPIResource(this.makeswiftApiClient.getState(), APIResourceType.Snippet, snippetId);
|
|
648
648
|
}
|
|
649
649
|
}
|
|
650
|
-
const Context$
|
|
650
|
+
const Context$1 = createContext(new MakeswiftClient({
|
|
651
651
|
uri: "https://api.makeswift.com/graphql"
|
|
652
652
|
}));
|
|
653
653
|
function useMakeswiftClient() {
|
|
654
|
-
return useContext(Context$
|
|
654
|
+
return useContext(Context$1);
|
|
655
655
|
}
|
|
656
656
|
function MakeswiftProvider({
|
|
657
657
|
client,
|
|
658
658
|
children
|
|
659
659
|
}) {
|
|
660
|
-
return /* @__PURE__ */ jsx(Context$
|
|
660
|
+
return /* @__PURE__ */ jsx(Context$1.Provider, {
|
|
661
661
|
value: client,
|
|
662
662
|
children
|
|
663
663
|
});
|
|
@@ -929,10 +929,10 @@ Received "${apiKey}" instead.`);
|
|
|
929
929
|
const json = await response.json();
|
|
930
930
|
return json;
|
|
931
931
|
}
|
|
932
|
-
async createSnapshot(document2) {
|
|
932
|
+
async createSnapshot(document2, preview) {
|
|
933
933
|
const client = new MakeswiftClient({ uri: new URL("graphql", this.apiOrigin).href });
|
|
934
934
|
const cacheData = await client.prefetch(document2.data);
|
|
935
|
-
return { document: document2, apiOrigin: this.apiOrigin.href, cacheData };
|
|
935
|
+
return { document: document2, apiOrigin: this.apiOrigin.href, cacheData, preview };
|
|
936
936
|
}
|
|
937
937
|
async getPageSnapshotByPageId(pageId, { preview = false } = {}) {
|
|
938
938
|
const searchParams = new URLSearchParams({ preview: String(preview) });
|
|
@@ -943,7 +943,7 @@ Received "${apiKey}" instead.`);
|
|
|
943
943
|
throw new Error(`Failed to get snapshot with error: "${response.statusText}"`);
|
|
944
944
|
}
|
|
945
945
|
const document2 = await response.json();
|
|
946
|
-
return await this.createSnapshot(document2);
|
|
946
|
+
return await this.createSnapshot(document2, preview);
|
|
947
947
|
}
|
|
948
948
|
async getPageSnapshot(path, { preview } = {}) {
|
|
949
949
|
const [page] = await this.getPages({ path });
|
|
@@ -1050,7 +1050,7 @@ class Document$1 extends NextDocument {
|
|
|
1050
1050
|
});
|
|
1051
1051
|
}
|
|
1052
1052
|
}
|
|
1053
|
-
const version = "0.
|
|
1053
|
+
const version = "0.5.0";
|
|
1054
1054
|
function isErrorWithMessage(error) {
|
|
1055
1055
|
return typeof error === "object" && error !== null && "message" in error && typeof error.message === "string";
|
|
1056
1056
|
}
|
|
@@ -1068,7 +1068,7 @@ function MakeswiftApiHandler(apiKey, { appOrigin = "https://app.makeswift.com",
|
|
|
1068
1068
|
Received "${apiKey}" instead.`);
|
|
1069
1069
|
}
|
|
1070
1070
|
return async function makeswiftApiHandler(req, res) {
|
|
1071
|
-
var _a
|
|
1071
|
+
var _a;
|
|
1072
1072
|
await new Promise((resolve2, reject) => {
|
|
1073
1073
|
cors(req, res, (err) => {
|
|
1074
1074
|
if (err instanceof Error)
|
|
@@ -1100,7 +1100,7 @@ Read more about dynamic catch-all routes here: https://nextjs.org/docs/routing/d
|
|
|
1100
1100
|
if (typeof req.query.path !== "string") {
|
|
1101
1101
|
return res.status(400).json({ message: "Bad Request" });
|
|
1102
1102
|
}
|
|
1103
|
-
const revalidate =
|
|
1103
|
+
const revalidate = res.revalidate;
|
|
1104
1104
|
if (typeof revalidate !== "function") {
|
|
1105
1105
|
const message = `Cannot revalidate path "${req.query.path}" because \`revalidate\` function does not exist in API handler response. Please update to Next.js v12.2.0 or higher for support for on-demand revalidation.
|
|
1106
1106
|
Read more here: https://nextjs.org/blog/next-12-2#on-demand-incremental-static-regeneration-stable`;
|
|
@@ -1147,7 +1147,7 @@ Read more here: https://nextjs.org/blog/next-12-2#on-demand-incremental-static-r
|
|
|
1147
1147
|
}));
|
|
1148
1148
|
}
|
|
1149
1149
|
case "fonts": {
|
|
1150
|
-
const fonts = (
|
|
1150
|
+
const fonts = (_a = await (getFonts == null ? void 0 : getFonts())) != null ? _a : [];
|
|
1151
1151
|
return res.json(fonts);
|
|
1152
1152
|
}
|
|
1153
1153
|
case "element-tree": {
|
|
@@ -1294,6 +1294,7 @@ const Page = memo(({
|
|
|
1294
1294
|
return /* @__PURE__ */ jsx(RuntimeProvider, {
|
|
1295
1295
|
client,
|
|
1296
1296
|
rootElements: /* @__PURE__ */ new Map([[snapshot.document.id, snapshot.document.data]]),
|
|
1297
|
+
preview: snapshot.preview,
|
|
1297
1298
|
children: /* @__PURE__ */ jsx(Page$1, {
|
|
1298
1299
|
document: snapshot.document
|
|
1299
1300
|
})
|
|
@@ -1838,11 +1839,11 @@ const Contrasts = Object.freeze({
|
|
|
1838
1839
|
LIGHT: "light",
|
|
1839
1840
|
DARK: "dark"
|
|
1840
1841
|
});
|
|
1841
|
-
const Context
|
|
1842
|
+
const Context = createContext({});
|
|
1842
1843
|
function useFormContext() {
|
|
1843
|
-
return useContext(Context
|
|
1844
|
+
return useContext(Context);
|
|
1844
1845
|
}
|
|
1845
|
-
const { Provider } = Context
|
|
1846
|
+
const { Provider } = Context;
|
|
1846
1847
|
function registerComponent$6(runtime) {
|
|
1847
1848
|
return runtime.registerComponent(forwardNextDynamicRef((patch) => dynamic(() => patch(import("./Form.es.js")))), {
|
|
1848
1849
|
type: MakeswiftComponentType.Form,
|
|
@@ -2847,13 +2848,13 @@ function paddingPropertyDataToStyle(data, defaultValue = {}) {
|
|
|
2847
2848
|
const paddingBottom = (_c2 = data.paddingBottom) != null ? _c2 : defaultValue.paddingBottom;
|
|
2848
2849
|
const paddingLeft = (_d = data.paddingLeft) != null ? _d : defaultValue.paddingLeft;
|
|
2849
2850
|
const style = {};
|
|
2850
|
-
if (paddingTop)
|
|
2851
|
+
if (paddingTop != null)
|
|
2851
2852
|
style.paddingTop = lengthDataToString(paddingTop);
|
|
2852
|
-
if (paddingRight)
|
|
2853
|
+
if (paddingRight != null)
|
|
2853
2854
|
style.paddingRight = lengthDataToString(paddingRight);
|
|
2854
|
-
if (paddingBottom)
|
|
2855
|
+
if (paddingBottom != null)
|
|
2855
2856
|
style.paddingBottom = lengthDataToString(paddingBottom);
|
|
2856
|
-
if (paddingLeft)
|
|
2857
|
+
if (paddingLeft != null)
|
|
2857
2858
|
style.paddingLeft = lengthDataToString(paddingLeft);
|
|
2858
2859
|
return style;
|
|
2859
2860
|
}
|
|
@@ -2864,13 +2865,13 @@ function marginPropertyDataToStyle(data, defaultValue = {}) {
|
|
|
2864
2865
|
const marginBottom = (_c2 = data.marginBottom) != null ? _c2 : defaultValue.marginBottom;
|
|
2865
2866
|
const marginLeft = (_d = data.marginLeft) != null ? _d : defaultValue.marginLeft;
|
|
2866
2867
|
const style = {};
|
|
2867
|
-
if (marginTop)
|
|
2868
|
+
if (marginTop != null)
|
|
2868
2869
|
style.marginTop = lengthDataToString(marginTop);
|
|
2869
|
-
if (marginRight)
|
|
2870
|
+
if (marginRight != null)
|
|
2870
2871
|
style.marginRight = lengthDataToString(marginRight);
|
|
2871
|
-
if (marginBottom)
|
|
2872
|
+
if (marginBottom != null)
|
|
2872
2873
|
style.marginBottom = lengthDataToString(marginBottom);
|
|
2873
|
-
if (marginLeft)
|
|
2874
|
+
if (marginLeft != null)
|
|
2874
2875
|
style.marginLeft = lengthDataToString(marginLeft);
|
|
2875
2876
|
return style;
|
|
2876
2877
|
}
|
|
@@ -2888,16 +2889,16 @@ function borderRadiusPropertyDataToStyle(data, defaultValue = {}) {
|
|
|
2888
2889
|
const borderBottomRightRadius = (_c2 = data.borderBottomRightRadius) != null ? _c2 : defaultValue.borderBottomRightRadius;
|
|
2889
2890
|
const borderBottomLeftRadius = (_d = data.borderBottomLeftRadius) != null ? _d : defaultValue.borderBottomLeftRadius;
|
|
2890
2891
|
const style = {};
|
|
2891
|
-
if (borderTopLeftRadius) {
|
|
2892
|
+
if (borderTopLeftRadius != null) {
|
|
2892
2893
|
style.borderTopLeftRadius = lengthPercentageDataToString(borderTopLeftRadius);
|
|
2893
2894
|
}
|
|
2894
|
-
if (borderTopRightRadius) {
|
|
2895
|
+
if (borderTopRightRadius != null) {
|
|
2895
2896
|
style.borderTopRightRadius = lengthPercentageDataToString(borderTopRightRadius);
|
|
2896
2897
|
}
|
|
2897
|
-
if (borderBottomRightRadius) {
|
|
2898
|
+
if (borderBottomRightRadius != null) {
|
|
2898
2899
|
style.borderBottomRightRadius = lengthPercentageDataToString(borderBottomRightRadius);
|
|
2899
2900
|
}
|
|
2900
|
-
if (borderBottomLeftRadius) {
|
|
2901
|
+
if (borderBottomLeftRadius != null) {
|
|
2901
2902
|
style.borderBottomLeftRadius = lengthPercentageDataToString(borderBottomLeftRadius);
|
|
2902
2903
|
}
|
|
2903
2904
|
return style;
|
|
@@ -2912,13 +2913,13 @@ function borderPropertyDataToStyle(data, defaultValue = {}) {
|
|
|
2912
2913
|
const borderBottom = (_c2 = data.borderBottom) != null ? _c2 : defaultValue.borderBottom;
|
|
2913
2914
|
const borderLeft = (_d = data.borderLeft) != null ? _d : defaultValue.borderLeft;
|
|
2914
2915
|
const style = {};
|
|
2915
|
-
if (borderTop)
|
|
2916
|
+
if (borderTop != null)
|
|
2916
2917
|
style.borderTop = borderSideToString(borderTop);
|
|
2917
|
-
if (borderRight)
|
|
2918
|
+
if (borderRight != null)
|
|
2918
2919
|
style.borderRight = borderSideToString(borderRight);
|
|
2919
|
-
if (borderBottom)
|
|
2920
|
+
if (borderBottom != null)
|
|
2920
2921
|
style.borderBottom = borderSideToString(borderBottom);
|
|
2921
|
-
if (borderLeft)
|
|
2922
|
+
if (borderLeft != null)
|
|
2922
2923
|
style.borderLeft = borderSideToString(borderLeft);
|
|
2923
2924
|
return style;
|
|
2924
2925
|
}
|
|
@@ -3726,47 +3727,16 @@ function createReactRuntime(store) {
|
|
|
3726
3727
|
}
|
|
3727
3728
|
const ReactRuntime = createReactRuntime(storeContextDefaultValue);
|
|
3728
3729
|
registerBuiltinComponents(ReactRuntime);
|
|
3729
|
-
const
|
|
3730
|
-
|
|
3731
|
-
|
|
3732
|
-
|
|
3733
|
-
|
|
3734
|
-
|
|
3735
|
-
|
|
3736
|
-
|
|
3737
|
-
|
|
3738
|
-
|
|
3739
|
-
});
|
|
3740
|
-
return store2;
|
|
3741
|
-
});
|
|
3742
|
-
useEffect(() => {
|
|
3743
|
-
var _a;
|
|
3744
|
-
const unregisterDocuments = Array.from((_a = rootElements == null ? void 0 : rootElements.entries()) != null ? _a : []).map(([documentKey, rootElement]) => store.dispatch(registerDocumentEffect(createDocument(documentKey, rootElement))));
|
|
3745
|
-
return () => {
|
|
3746
|
-
unregisterDocuments.forEach((unregisterDocument) => {
|
|
3747
|
-
unregisterDocument();
|
|
3748
|
-
});
|
|
3749
|
-
};
|
|
3750
|
-
}, [store, rootElements]);
|
|
3751
|
-
useEffect(() => {
|
|
3752
|
-
const isInBuilder = window.parent !== window;
|
|
3753
|
-
if (isInBuilder)
|
|
3754
|
-
setReactBuilderPreviewStore();
|
|
3755
|
-
async function setReactBuilderPreviewStore() {
|
|
3756
|
-
const ReactBuilderPreview = await import("./react-builder-preview.es.js");
|
|
3757
|
-
setStore((store2) => ReactBuilderPreview.configureStore({
|
|
3758
|
-
preloadedState: store2.getState(),
|
|
3759
|
-
client
|
|
3760
|
-
}));
|
|
3761
|
-
}
|
|
3762
|
-
}, [client]);
|
|
3763
|
-
return /* @__PURE__ */ jsx(Context.Provider, {
|
|
3764
|
-
value: store,
|
|
3765
|
-
children: /* @__PURE__ */ jsx(MakeswiftProvider, {
|
|
3766
|
-
client,
|
|
3767
|
-
children
|
|
3768
|
-
})
|
|
3769
|
-
});
|
|
3730
|
+
const StoreContext = createContext(storeContextDefaultValue);
|
|
3731
|
+
const PreviewProvider = dynamic(() => import("./PreviewProvider.es.js"));
|
|
3732
|
+
const LiveProvider = dynamic(() => import("./LiveProvider.es.js"));
|
|
3733
|
+
function RuntimeProvider(_j) {
|
|
3734
|
+
var _k = _j, {
|
|
3735
|
+
preview
|
|
3736
|
+
} = _k, props = __objRest(_k, [
|
|
3737
|
+
"preview"
|
|
3738
|
+
]);
|
|
3739
|
+
return preview ? /* @__PURE__ */ jsx(PreviewProvider, __spreadValues({}, props)) : /* @__PURE__ */ jsx(LiveProvider, __spreadValues({}, props));
|
|
3770
3740
|
}
|
|
3771
3741
|
const PageContext = createContext(null);
|
|
3772
3742
|
function usePageIdOrNull() {
|
|
@@ -3792,7 +3762,7 @@ function useDocumentKey() {
|
|
|
3792
3762
|
return useContext(DocumentContext);
|
|
3793
3763
|
}
|
|
3794
3764
|
function useStore() {
|
|
3795
|
-
return useContext(
|
|
3765
|
+
return useContext(StoreContext);
|
|
3796
3766
|
}
|
|
3797
3767
|
function useSelector(selector) {
|
|
3798
3768
|
const store = useStore();
|
|
@@ -3812,7 +3782,7 @@ function useIsInBuilder() {
|
|
|
3812
3782
|
return useSelector((state) => getIsInBuilder(state));
|
|
3813
3783
|
}
|
|
3814
3784
|
function useDispatch() {
|
|
3815
|
-
const store = useContext(
|
|
3785
|
+
const store = useContext(StoreContext);
|
|
3816
3786
|
return store.dispatch;
|
|
3817
3787
|
}
|
|
3818
3788
|
const originalError = console.error;
|
|
@@ -3932,5 +3902,5 @@ const DocumentReference = memo(forwardRef(function DocumentReference2({
|
|
|
3932
3902
|
document: document2
|
|
3933
3903
|
});
|
|
3934
3904
|
}));
|
|
3935
|
-
export {
|
|
3905
|
+
export { getServerSideProps as $, Alignments as A, useFile as B, Contrasts as C, DocumentReference as D, Element as E, DEVICES as F, findDeviceOverride as G, serializeStyles as H, insertStyles as I, useTypography as J, useSwatches as K, shallowMergeFallbacks as L, MakeswiftComponentType as M, useFiles as N, getDeviceMediaQuery as O, PageProvider as P, usePagePathnameSlice as Q, RuntimeProvider as R, Shapes as S, useElementId as T, deepEqual as U, storeContextDefaultValue as V, StoreContext as W, MakeswiftProvider as X, MakeswiftClient as Y, getStaticPaths as Z, getStaticProps as _, ReactRuntime as a, Page as a0, Makeswift as a1, PreviewModeScript as a2, Document$1 as a3, MakeswiftApiHandler as a4, forwardNextDynamicRef as a5, 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, useBoxShadow as k, useResponsiveColor as l, Page$1 as m, useStyle as n, responsiveWidth as o, responsiveTextStyle as p, colorToString as q, responsiveStyle as r, useIsomorphicLayoutEffect as s, Sizes as t, useIsInBuilder as u, useFormContext as v, responsiveGridItem as w, useTable as x, useMakeswiftClient as y, Provider as z };
|
|
3936
3906
|
//# sourceMappingURL=index.es.js.map
|