@makeswift/runtime 0.9.3 → 0.9.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 +4 -4
- package/dist/Box.es.js +5 -5
- package/dist/Button.cjs.js +4 -4
- package/dist/Button.es.js +5 -5
- package/dist/Carousel.cjs.js +4 -4
- package/dist/Carousel.es.js +5 -5
- package/dist/Countdown.cjs.js +2 -2
- package/dist/Countdown.es.js +3 -3
- package/dist/Divider.cjs.js +4 -4
- package/dist/Divider.es.js +5 -5
- 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 +2 -2
- package/dist/Form.es.js +3 -3
- package/dist/Image.cjs.js +2 -2
- package/dist/Image.es.js +3 -3
- package/dist/LiveProvider.cjs.js +5 -5
- package/dist/LiveProvider.es.js +5 -5
- package/dist/Navigation.cjs.js +3 -3
- package/dist/Navigation.es.js +4 -4
- package/dist/PreviewProvider.cjs.js +9 -8
- package/dist/PreviewProvider.cjs.js.map +1 -1
- package/dist/PreviewProvider.es.js +11 -10
- package/dist/PreviewProvider.es.js.map +1 -1
- package/dist/ReadOnlyText.cjs.js +4 -5
- package/dist/ReadOnlyText.cjs.js.map +1 -1
- package/dist/ReadOnlyText.es.js +4 -5
- package/dist/ReadOnlyText.es.js.map +1 -1
- package/dist/ReadOnlyTextV2.cjs.js +17 -19
- package/dist/ReadOnlyTextV2.cjs.js.map +1 -1
- package/dist/ReadOnlyTextV2.es.js +16 -18
- package/dist/ReadOnlyTextV2.es.js.map +1 -1
- package/dist/Root.cjs.js +2 -2
- package/dist/Root.es.js +3 -3
- package/dist/SocialLinks.cjs.js +4 -4
- package/dist/SocialLinks.es.js +5 -5
- package/dist/Text.cjs.js +2 -2
- 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 +2 -1
- package/dist/Video.es.js.map +1 -1
- package/dist/actions.cjs.js +467 -3
- package/dist/actions.cjs.js.map +1 -1
- package/dist/actions.es.js +467 -4
- package/dist/actions.es.js.map +1 -1
- package/dist/box-model.cjs.js +1 -0
- package/dist/box-model.cjs.js.map +1 -1
- package/dist/box-model.es.js +1 -0
- package/dist/box-model.es.js.map +1 -1
- package/dist/builder.cjs.js +1 -0
- package/dist/builder.cjs.js.map +1 -1
- package/dist/builder.es.js +1 -0
- package/dist/builder.es.js.map +1 -1
- package/dist/components.cjs.js +2 -2
- package/dist/components.es.js +2 -2
- package/dist/control-serialization.cjs.js +1 -0
- package/dist/control-serialization.cjs.js.map +1 -1
- package/dist/control-serialization.es.js +2 -1
- package/dist/control-serialization.es.js.map +1 -1
- package/dist/controls.cjs.js +19 -14
- package/dist/controls.cjs.js.map +1 -1
- package/dist/controls.es.js +3 -2
- package/dist/controls.es.js.map +1 -1
- package/dist/index.cjs.js +182 -60
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.cjs10.js +25 -13
- package/dist/index.cjs10.js.map +1 -1
- package/dist/index.cjs2.js +1 -0
- package/dist/index.cjs2.js.map +1 -1
- package/dist/index.cjs5.js +96 -5
- package/dist/index.cjs5.js.map +1 -1
- package/dist/index.cjs8.js +2 -2
- package/dist/index.cjs9.js +5 -5
- package/dist/index.es.js +170 -49
- package/dist/index.es.js.map +1 -1
- package/dist/index.es10.js +26 -14
- package/dist/index.es10.js.map +1 -1
- package/dist/index.es2.js +2 -1
- package/dist/index.es2.js.map +1 -1
- package/dist/index.es4.js +1 -1
- package/dist/index.es5.js +88 -2
- package/dist/index.es5.js.map +1 -1
- package/dist/index.es6.js +1 -1
- package/dist/index.es8.js +2 -2
- package/dist/index.es9.js +6 -6
- package/dist/main.cjs.js +1 -0
- package/dist/main.cjs.js.map +1 -1
- package/dist/main.es.js +1 -0
- package/dist/main.es.js.map +1 -1
- package/dist/next.cjs.js +2 -2
- package/dist/next.es.js +3 -3
- package/dist/prop-controllers.cjs.js +1 -0
- package/dist/prop-controllers.cjs.js.map +1 -1
- package/dist/prop-controllers.es.js +1 -0
- package/dist/prop-controllers.es.js.map +1 -1
- package/dist/react-page.cjs.js +114 -31
- package/dist/react-page.cjs.js.map +1 -1
- package/dist/react-page.es.js +111 -12
- package/dist/react-page.es.js.map +1 -1
- package/dist/react.cjs.js +2 -2
- package/dist/react.es.js +2 -2
- package/dist/slate.cjs.js +22 -75
- package/dist/slate.cjs.js.map +1 -1
- package/dist/slate.es.js +25 -79
- package/dist/slate.es.js.map +1 -1
- package/dist/state/breakpoints.cjs.js +1 -0
- package/dist/state/breakpoints.cjs.js.map +1 -1
- package/dist/state/breakpoints.es.js +1 -0
- package/dist/state/breakpoints.es.js.map +1 -1
- package/dist/types/src/components/builtin/Button/Button.d.ts +1 -1
- package/dist/types/src/components/builtin/Form/components/Field/components/Checkbox/index.d.ts +1 -1
- package/dist/types/src/components/builtin/Text/ReadOnlyText.d.ts.map +1 -1
- package/dist/types/src/components/builtin/Text/components/Leaf/leaf.d.ts +0 -17
- package/dist/types/src/components/builtin/Text/components/Leaf/leaf.d.ts.map +1 -1
- package/dist/types/src/components/page/Page.d.ts.map +1 -1
- package/dist/types/src/controls/control.d.ts +3 -2
- package/dist/types/src/controls/control.d.ts.map +1 -1
- package/dist/types/src/controls/index.d.ts +1 -0
- package/dist/types/src/controls/index.d.ts.map +1 -1
- package/dist/types/src/controls/list.d.ts +2 -0
- package/dist/types/src/controls/list.d.ts.map +1 -1
- package/dist/types/src/controls/shape.d.ts +2 -0
- package/dist/types/src/controls/shape.d.ts.map +1 -1
- package/dist/types/src/controls/typography.d.ts +31 -0
- package/dist/types/src/controls/typography.d.ts.map +1 -0
- package/dist/types/src/next/client.d.ts +9 -1
- 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/prop-controllers/descriptors.d.ts +6 -3
- package/dist/types/src/prop-controllers/descriptors.d.ts.map +1 -1
- package/dist/types/src/prop-controllers/introspection.d.ts +1 -1
- package/dist/types/src/prop-controllers/introspection.d.ts.map +1 -1
- package/dist/types/src/runtimes/react/controls/control.d.ts +3 -2
- package/dist/types/src/runtimes/react/controls/control.d.ts.map +1 -1
- package/dist/types/src/runtimes/react/controls/rich-text-v2/ReadOnlyTextV2.d.ts.map +1 -1
- package/dist/types/src/runtimes/react/controls/typography.d.ts +21 -0
- package/dist/types/src/runtimes/react/controls/typography.d.ts.map +1 -0
- package/dist/types/src/runtimes/react/controls.d.ts.map +1 -1
- package/dist/types/src/runtimes/react/index.d.ts.map +1 -1
- package/dist/types/src/slate/TypographyPlugin/index.d.ts +9 -0
- package/dist/types/src/slate/TypographyPlugin/index.d.ts.map +1 -1
- package/dist/types/src/state/actions.d.ts +7 -7
- package/dist/types/src/state/actions.d.ts.map +1 -1
- package/dist/types/src/state/modules/locales.d.ts +6 -7
- package/dist/types/src/state/modules/locales.d.ts.map +1 -1
- package/dist/types/src/state/react-builder-preview.d.ts.map +1 -1
- package/dist/types/src/state/react-page.d.ts +3 -1
- package/dist/types/src/state/react-page.d.ts.map +1 -1
- package/dist/types/types/locale.d.ts +9 -0
- package/dist/types/types/locale.d.ts.map +1 -0
- package/dist/types.cjs2.js +13 -16
- package/dist/types.cjs2.js.map +1 -1
- package/dist/types.es2.js +10 -13
- package/dist/types.es2.js.map +1 -1
- package/dist/{text-input.cjs.js → typography.cjs.js} +9 -1
- package/dist/typography.cjs.js.map +1 -0
- package/dist/{text-input.es.js → typography.es.js} +8 -2
- package/dist/typography.es.js.map +1 -0
- package/package.json +1 -1
- package/dist/leaf.cjs.js +0 -182
- package/dist/leaf.cjs.js.map +0 -1
- package/dist/leaf.es.js +0 -179
- package/dist/leaf.es.js.map +0 -1
- package/dist/text-input.cjs.js.map +0 -1
- package/dist/text-input.es.js.map +0 -1
package/dist/index.cjs.js
CHANGED
|
@@ -41,7 +41,7 @@ var dynamic = require("next/dynamic");
|
|
|
41
41
|
var reactPage = require("./react-page.cjs.js");
|
|
42
42
|
var actions = require("./actions.cjs.js");
|
|
43
43
|
var jsxRuntime = require("react/jsx-runtime");
|
|
44
|
-
var
|
|
44
|
+
var typography = require("./typography.cjs.js");
|
|
45
45
|
var combobox = require("./combobox.cjs.js");
|
|
46
46
|
require("slate");
|
|
47
47
|
var shim = require("use-sync-external-store/shim");
|
|
@@ -51,10 +51,8 @@ var types = require("./types.cjs.js");
|
|
|
51
51
|
var state_breakpoints = require("./state/breakpoints.cjs.js");
|
|
52
52
|
var boxModels = require("./box-models.cjs.js");
|
|
53
53
|
var ColorHelper = require("color");
|
|
54
|
-
var css = require("@emotion/css");
|
|
55
|
-
require("@emotion/serialize");
|
|
56
|
-
require("@emotion/utils");
|
|
57
54
|
var scrollIntoView = require("scroll-into-view-if-needed");
|
|
55
|
+
var css = require("@emotion/css");
|
|
58
56
|
var reactDom = require("react-dom");
|
|
59
57
|
var parse = require("html-react-parser");
|
|
60
58
|
var Head = require("next/head");
|
|
@@ -599,7 +597,7 @@ const filterUsedSnippetProperties = ({
|
|
|
599
597
|
function Page$1({
|
|
600
598
|
document: page
|
|
601
599
|
}) {
|
|
602
|
-
var _a;
|
|
600
|
+
var _a, _b;
|
|
603
601
|
const isInBuilder = useIsInBuilder();
|
|
604
602
|
const [snippets, setSnippets] = React.useState(page.snippets);
|
|
605
603
|
const cachedPage = useCachedPage(isInBuilder ? page.id : null);
|
|
@@ -661,6 +659,10 @@ function Page$1({
|
|
|
661
659
|
});
|
|
662
660
|
previousHeadSnippets.current = headSnippets;
|
|
663
661
|
}, [headSnippets]);
|
|
662
|
+
const baseLocalizedPage = page.localizedPages.find(({
|
|
663
|
+
parentId
|
|
664
|
+
}) => parentId == null);
|
|
665
|
+
const documentId = (_b = baseLocalizedPage == null ? void 0 : baseLocalizedPage.elementTreeId) != null ? _b : page.id;
|
|
664
666
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
665
667
|
children: [/* @__PURE__ */ jsxRuntime.jsxs(Head__default["default"], {
|
|
666
668
|
children: [/* @__PURE__ */ jsxRuntime.jsx("style", {
|
|
@@ -742,7 +744,7 @@ function Page$1({
|
|
|
742
744
|
return null;
|
|
743
745
|
}))]
|
|
744
746
|
}), /* @__PURE__ */ jsxRuntime.jsx(DocumentReference, {
|
|
745
|
-
documentReference: reactPage.createDocumentReference(
|
|
747
|
+
documentReference: reactPage.createDocumentReference(documentId)
|
|
746
748
|
}), filteredSnippets.filter((snippet) => snippet.location === SnippetLocation.Body).map((snippet) => /* @__PURE__ */ jsxRuntime.jsx(BodySnippet, {
|
|
747
749
|
code: snippet.code,
|
|
748
750
|
cleanup: snippet.cleanup
|
|
@@ -959,7 +961,7 @@ Received "${apiKey}" instead.`);
|
|
|
959
961
|
while (current = remaining.pop()) {
|
|
960
962
|
let getResourcesFromElementDescriptors = function(elementDescriptors2, props) {
|
|
961
963
|
Object.entries(elementDescriptors2).forEach(([propName, descriptor]) => {
|
|
962
|
-
reactPage.
|
|
964
|
+
reactPage.getSwatchIds(descriptor, props[propName]).forEach((swatchId) => {
|
|
963
965
|
swatchIds.add(swatchId);
|
|
964
966
|
});
|
|
965
967
|
reactPage.getFileIds(descriptor, props[propName]).forEach((fileId) => fileIds.add(fileId));
|
|
@@ -972,34 +974,6 @@ Received "${apiKey}" instead.`);
|
|
|
972
974
|
remaining.push(child);
|
|
973
975
|
}
|
|
974
976
|
});
|
|
975
|
-
if (descriptor.type === reactPage.ShapeControlType) {
|
|
976
|
-
const prop = props[propName];
|
|
977
|
-
if (prop == null)
|
|
978
|
-
return;
|
|
979
|
-
getResourcesFromElementDescriptors(descriptor.config.type, prop);
|
|
980
|
-
}
|
|
981
|
-
if (descriptor.type === reactPage.ListControlType) {
|
|
982
|
-
const prop = props[propName];
|
|
983
|
-
if (prop == null)
|
|
984
|
-
return;
|
|
985
|
-
prop.forEach((item) => {
|
|
986
|
-
getResourcesFromElementDescriptors({ propName: descriptor.config.type }, { propName: item.value });
|
|
987
|
-
});
|
|
988
|
-
}
|
|
989
|
-
if (descriptor.type === reactPage.Types.Shape) {
|
|
990
|
-
const prop = props[propName];
|
|
991
|
-
if (prop == null)
|
|
992
|
-
return;
|
|
993
|
-
getResourcesFromElementDescriptors(descriptor.options.type, prop);
|
|
994
|
-
}
|
|
995
|
-
if (descriptor.type === reactPage.Types.List) {
|
|
996
|
-
const prop = props[propName];
|
|
997
|
-
if (prop == null)
|
|
998
|
-
return;
|
|
999
|
-
prop.forEach((item) => {
|
|
1000
|
-
getResourcesFromElementDescriptors({ propName: descriptor.options.type }, { propName: item.value });
|
|
1001
|
-
});
|
|
1002
|
-
}
|
|
1003
977
|
});
|
|
1004
978
|
};
|
|
1005
979
|
let element2;
|
|
@@ -1019,8 +993,8 @@ Received "${apiKey}" instead.`);
|
|
|
1019
993
|
getResourcesFromElementDescriptors(elementDescriptors, element2.props);
|
|
1020
994
|
}
|
|
1021
995
|
const typographies = await this.getTypographies([...typographyIds]);
|
|
1022
|
-
typographies.forEach((
|
|
1023
|
-
|
|
996
|
+
typographies.forEach((typography2) => {
|
|
997
|
+
typography2 == null ? void 0 : typography2.style.forEach((style) => {
|
|
1024
998
|
var _a;
|
|
1025
999
|
const swatchId = (_a = style.value.color) == null ? void 0 : _a.swatchId;
|
|
1026
1000
|
if (swatchId != null)
|
|
@@ -1055,7 +1029,7 @@ Received "${apiKey}" instead.`);
|
|
|
1055
1029
|
var _a;
|
|
1056
1030
|
return {
|
|
1057
1031
|
id,
|
|
1058
|
-
value: (_a = typographies.find((
|
|
1032
|
+
value: (_a = typographies.find((typography2) => (typography2 == null ? void 0 : typography2.id) === id)) != null ? _a : null
|
|
1059
1033
|
};
|
|
1060
1034
|
}),
|
|
1061
1035
|
[types.APIResourceType.Table]: [...tableIds].map((id) => {
|
|
@@ -1078,10 +1052,16 @@ Received "${apiKey}" instead.`);
|
|
|
1078
1052
|
}))
|
|
1079
1053
|
};
|
|
1080
1054
|
}
|
|
1081
|
-
async getPageSnapshot(pathname, {
|
|
1055
|
+
async getPageSnapshot(pathname, {
|
|
1056
|
+
preview: previewOverride = false,
|
|
1057
|
+
unstable_locale
|
|
1058
|
+
} = {}) {
|
|
1082
1059
|
var _a;
|
|
1083
1060
|
const siteVersion = (_a = this.siteVersion) != null ? _a : previewOverride ? MakeswiftSiteVersion.Working : MakeswiftSiteVersion.Live;
|
|
1084
|
-
const
|
|
1061
|
+
const searchParams = new URLSearchParams();
|
|
1062
|
+
if (unstable_locale)
|
|
1063
|
+
searchParams.set("locale", unstable_locale);
|
|
1064
|
+
const response = await this.fetch(`/v2/pages/${encodeURIComponent(pathname)}/document?${searchParams.toString()}`, {
|
|
1085
1065
|
headers: { "Makeswift-Site-Version": siteVersion }
|
|
1086
1066
|
});
|
|
1087
1067
|
if (!response.ok) {
|
|
@@ -1182,7 +1162,7 @@ async function fonts(_req, res, { getFonts } = {}) {
|
|
|
1182
1162
|
const fonts2 = (_a = await (getFonts == null ? void 0 : getFonts())) != null ? _a : [];
|
|
1183
1163
|
return res.json(fonts2);
|
|
1184
1164
|
}
|
|
1185
|
-
const version = "0.9.
|
|
1165
|
+
const version = "0.9.5";
|
|
1186
1166
|
async function handler(req, res, { apiKey, unstable_siteVersions }) {
|
|
1187
1167
|
if (req.query.secret !== apiKey) {
|
|
1188
1168
|
return res.status(401).json({ message: "Unauthorized" });
|
|
@@ -1453,9 +1433,13 @@ const Page = React.memo(({
|
|
|
1453
1433
|
uri: new URL("graphql", snapshot.apiOrigin).href,
|
|
1454
1434
|
cacheData: snapshot.cacheData
|
|
1455
1435
|
}), [snapshot]);
|
|
1436
|
+
const rootElements = /* @__PURE__ */ new Map([[snapshot.document.id, snapshot.document.data]]);
|
|
1437
|
+
snapshot.document.localizedPages.forEach((localizedPage) => {
|
|
1438
|
+
rootElements.set(localizedPage.elementTreeId, localizedPage.data);
|
|
1439
|
+
});
|
|
1456
1440
|
return /* @__PURE__ */ jsxRuntime.jsx(RuntimeProvider, {
|
|
1457
1441
|
client,
|
|
1458
|
-
rootElements
|
|
1442
|
+
rootElements,
|
|
1459
1443
|
preview: snapshot.preview,
|
|
1460
1444
|
runtime,
|
|
1461
1445
|
children: /* @__PURE__ */ jsxRuntime.jsx(Page$1, {
|
|
@@ -2586,12 +2570,12 @@ function useFiles(fileIds) {
|
|
|
2586
2570
|
function useTypography(typographyId) {
|
|
2587
2571
|
const client = useMakeswiftClient();
|
|
2588
2572
|
const readTypography = () => typographyId == null ? null : client.readTypography(typographyId);
|
|
2589
|
-
const
|
|
2573
|
+
const typography2 = shim.useSyncExternalStore(client.subscribe, readTypography, readTypography);
|
|
2590
2574
|
React.useEffect(() => {
|
|
2591
2575
|
if (typographyId != null)
|
|
2592
2576
|
client.fetchTypography(typographyId).catch(console.error);
|
|
2593
2577
|
}, [client, typographyId]);
|
|
2594
|
-
return
|
|
2578
|
+
return typography2;
|
|
2595
2579
|
}
|
|
2596
2580
|
function useGlobalElement(globalElementId) {
|
|
2597
2581
|
const client = useMakeswiftClient();
|
|
@@ -3412,6 +3396,138 @@ function useTextAreaValue(data, definition) {
|
|
|
3412
3396
|
function useTextInputValue(data, definition) {
|
|
3413
3397
|
return data != null ? data : definition.config.defaultValue;
|
|
3414
3398
|
}
|
|
3399
|
+
function isNonNullable(value) {
|
|
3400
|
+
return value != null;
|
|
3401
|
+
}
|
|
3402
|
+
function typographyFragementToTypographyControlData(typography2) {
|
|
3403
|
+
if (typography2 == null)
|
|
3404
|
+
return void 0;
|
|
3405
|
+
return {
|
|
3406
|
+
id: typography2.id,
|
|
3407
|
+
style: typography2.style.map(({ deviceId, value }) => {
|
|
3408
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
3409
|
+
return {
|
|
3410
|
+
deviceId,
|
|
3411
|
+
value: {
|
|
3412
|
+
fontFamily: (_a = value.fontFamily) != null ? _a : void 0,
|
|
3413
|
+
lineHeight: (_b = value.lineHeight) != null ? _b : void 0,
|
|
3414
|
+
letterSpacing: (_c = value.letterSpacing) != null ? _c : void 0,
|
|
3415
|
+
fontWeight: (_d = value.fontWeight) != null ? _d : void 0,
|
|
3416
|
+
textAlign: (_e = value.textAlign) != null ? _e : void 0,
|
|
3417
|
+
uppercase: (_f = value.uppercase) != null ? _f : void 0,
|
|
3418
|
+
underline: (_g = value.underline) != null ? _g : void 0,
|
|
3419
|
+
strikethrough: (_h = value.strikethrough) != null ? _h : void 0,
|
|
3420
|
+
italic: (_i = value.italic) != null ? _i : void 0,
|
|
3421
|
+
fontSize: (_j = value.fontSize) != null ? _j : void 0,
|
|
3422
|
+
color: (_k = value.color) != null ? _k : void 0
|
|
3423
|
+
}
|
|
3424
|
+
};
|
|
3425
|
+
})
|
|
3426
|
+
};
|
|
3427
|
+
}
|
|
3428
|
+
function getTypographyStyleSwatchIds(style) {
|
|
3429
|
+
var _a;
|
|
3430
|
+
return (_a = style == null ? void 0 : style.map((override) => override.value).flatMap((typographyStyle) => {
|
|
3431
|
+
var _a2;
|
|
3432
|
+
return (_a2 = typographyStyle.color) == null ? void 0 : _a2.swatchId;
|
|
3433
|
+
}).filter(isNonNullable)) != null ? _a : [];
|
|
3434
|
+
}
|
|
3435
|
+
const withColor = (swatches) => (deviceRawTypographyValue) => {
|
|
3436
|
+
var _b, _c;
|
|
3437
|
+
const { value, deviceId } = deviceRawTypographyValue;
|
|
3438
|
+
if (value.color == null) {
|
|
3439
|
+
const _a = value, { color } = _a, nextValue = __objRest(_a, ["color"]);
|
|
3440
|
+
return {
|
|
3441
|
+
deviceId,
|
|
3442
|
+
value: nextValue
|
|
3443
|
+
};
|
|
3444
|
+
}
|
|
3445
|
+
return {
|
|
3446
|
+
deviceId,
|
|
3447
|
+
value: __spreadProps(__spreadValues({}, value), {
|
|
3448
|
+
color: {
|
|
3449
|
+
swatch: swatches.find((s) => {
|
|
3450
|
+
var _a2;
|
|
3451
|
+
return s && s.id === ((_a2 = value.color) == null ? void 0 : _a2.swatchId);
|
|
3452
|
+
}),
|
|
3453
|
+
alpha: (_c = (_b = value.color) == null ? void 0 : _b.alpha) != null ? _c : void 0
|
|
3454
|
+
}
|
|
3455
|
+
})
|
|
3456
|
+
};
|
|
3457
|
+
};
|
|
3458
|
+
const getDeviceId = ({ deviceId }) => deviceId;
|
|
3459
|
+
function useEnhancedTypography(value) {
|
|
3460
|
+
var _a, _b, _c;
|
|
3461
|
+
const typography2 = typographyFragementToTypographyControlData(useTypography((_a = value == null ? void 0 : value.id) != null ? _a : null));
|
|
3462
|
+
const source = (_b = typography2 == null ? void 0 : typography2.style) != null ? _b : [];
|
|
3463
|
+
const override = (_c = value == null ? void 0 : value.style) != null ? _c : [];
|
|
3464
|
+
const breakpoints = useBreakpoints();
|
|
3465
|
+
const swatchIds = [
|
|
3466
|
+
...getTypographyStyleSwatchIds(value == null ? void 0 : value.style),
|
|
3467
|
+
...getTypographyStyleSwatchIds(typography2 == null ? void 0 : typography2.style)
|
|
3468
|
+
];
|
|
3469
|
+
const swatches = useSwatches(swatchIds).filter(isNonNullable);
|
|
3470
|
+
const enhancedSource = source.map(withColor(swatches));
|
|
3471
|
+
const enhancedOverride = override.map(withColor(swatches));
|
|
3472
|
+
const devices = [
|
|
3473
|
+
...new Set(enhancedSource.map(getDeviceId).concat(enhancedOverride.map(getDeviceId)))
|
|
3474
|
+
];
|
|
3475
|
+
return devices.map((deviceId) => {
|
|
3476
|
+
var _a2, _b2;
|
|
3477
|
+
const deviceSource = (_a2 = state_breakpoints.findBreakpointOverride(breakpoints, enhancedSource, deviceId)) == null ? void 0 : _a2.value;
|
|
3478
|
+
const deviceOverride = (_b2 = state_breakpoints.findBreakpointOverride(breakpoints, enhancedOverride, deviceId, (v) => v)) == null ? void 0 : _b2.value;
|
|
3479
|
+
if (deviceSource && deviceOverride) {
|
|
3480
|
+
return {
|
|
3481
|
+
deviceId,
|
|
3482
|
+
value: __spreadValues(__spreadValues({}, deviceSource), deviceOverride)
|
|
3483
|
+
};
|
|
3484
|
+
} else if (deviceOverride) {
|
|
3485
|
+
return {
|
|
3486
|
+
deviceId,
|
|
3487
|
+
value: deviceOverride
|
|
3488
|
+
};
|
|
3489
|
+
} else if (deviceSource) {
|
|
3490
|
+
return {
|
|
3491
|
+
deviceId,
|
|
3492
|
+
value: deviceSource
|
|
3493
|
+
};
|
|
3494
|
+
}
|
|
3495
|
+
return null;
|
|
3496
|
+
}).filter(isNonNullable);
|
|
3497
|
+
}
|
|
3498
|
+
function useTypographyClassName(value) {
|
|
3499
|
+
return reactPage.useStyle(useResponsiveStyle([value], ([value2]) => {
|
|
3500
|
+
if (value2 === void 0)
|
|
3501
|
+
return {};
|
|
3502
|
+
let styles = {};
|
|
3503
|
+
if (value2.color != null)
|
|
3504
|
+
styles.color = colorToString(value2.color);
|
|
3505
|
+
if (value2.fontFamily != null)
|
|
3506
|
+
styles.fontFamily = value2.fontFamily;
|
|
3507
|
+
if (value2.fontSize != null && value2.fontSize.value != null && value2.fontSize.unit != null)
|
|
3508
|
+
styles.fontSize = `${value2.fontSize.value}${value2.fontSize.unit}`;
|
|
3509
|
+
if (value2.fontWeight != null)
|
|
3510
|
+
styles.fontWeight = value2.fontWeight;
|
|
3511
|
+
if (value2.lineHeight != null)
|
|
3512
|
+
styles.lineHeight = value2.lineHeight;
|
|
3513
|
+
if (value2.letterSpacing != null)
|
|
3514
|
+
styles.letterSpacing = `${value2.letterSpacing / 10}em`;
|
|
3515
|
+
if (value2.uppercase != null)
|
|
3516
|
+
styles.textTransform = value2.uppercase === true ? "uppercase" : "initial";
|
|
3517
|
+
if (value2.underline != null || value2.strikethrough != null)
|
|
3518
|
+
styles.textDecoration = [
|
|
3519
|
+
Boolean(value2.underline) && "underline",
|
|
3520
|
+
Boolean(value2.strikethrough) && "line-through"
|
|
3521
|
+
].filter(Boolean).join(" ");
|
|
3522
|
+
if (value2.italic != null)
|
|
3523
|
+
styles.fontStyle = value2.italic === true ? "italic" : "initial";
|
|
3524
|
+
return styles;
|
|
3525
|
+
}, state_breakpoints.shallowMergeFallbacks));
|
|
3526
|
+
}
|
|
3527
|
+
function useTypographyValue(data) {
|
|
3528
|
+
const enhancedTypography = useEnhancedTypography(data);
|
|
3529
|
+
return useTypographyClassName(enhancedTypography);
|
|
3530
|
+
}
|
|
3415
3531
|
function ControlValue({
|
|
3416
3532
|
data,
|
|
3417
3533
|
definition,
|
|
@@ -3419,31 +3535,31 @@ function ControlValue({
|
|
|
3419
3535
|
control
|
|
3420
3536
|
}) {
|
|
3421
3537
|
switch (definition.type) {
|
|
3422
|
-
case
|
|
3538
|
+
case typography.CheckboxControlType:
|
|
3423
3539
|
return /* @__PURE__ */ jsxRuntime.jsx(RenderHook, {
|
|
3424
3540
|
hook: useCheckboxControlValue,
|
|
3425
3541
|
parameters: [data, definition],
|
|
3426
3542
|
children: (value) => children(value)
|
|
3427
3543
|
}, definition.type);
|
|
3428
|
-
case
|
|
3544
|
+
case typography.NumberControlType:
|
|
3429
3545
|
return /* @__PURE__ */ jsxRuntime.jsx(RenderHook, {
|
|
3430
3546
|
hook: useNumber,
|
|
3431
3547
|
parameters: [data, definition],
|
|
3432
3548
|
children: (value) => children(value)
|
|
3433
3549
|
}, definition.type);
|
|
3434
|
-
case
|
|
3550
|
+
case typography.TextInputControlType:
|
|
3435
3551
|
return /* @__PURE__ */ jsxRuntime.jsx(RenderHook, {
|
|
3436
3552
|
hook: useTextInputValue,
|
|
3437
3553
|
parameters: [data, definition],
|
|
3438
3554
|
children: (value) => children(value)
|
|
3439
3555
|
}, definition.type);
|
|
3440
|
-
case
|
|
3556
|
+
case typography.TextAreaControlType:
|
|
3441
3557
|
return /* @__PURE__ */ jsxRuntime.jsx(RenderHook, {
|
|
3442
3558
|
hook: useTextAreaValue,
|
|
3443
3559
|
parameters: [data, definition],
|
|
3444
3560
|
children: (value) => children(value)
|
|
3445
3561
|
}, definition.type);
|
|
3446
|
-
case
|
|
3562
|
+
case typography.SelectControlType:
|
|
3447
3563
|
return /* @__PURE__ */ jsxRuntime.jsx(RenderHook, {
|
|
3448
3564
|
hook: useSelectControlValue,
|
|
3449
3565
|
parameters: [data, definition],
|
|
@@ -3455,7 +3571,7 @@ function ControlValue({
|
|
|
3455
3571
|
parameters: [data, definition],
|
|
3456
3572
|
children: (value) => children(value)
|
|
3457
3573
|
}, definition.type);
|
|
3458
|
-
case
|
|
3574
|
+
case typography.IconRadioGroupControlType:
|
|
3459
3575
|
return /* @__PURE__ */ jsxRuntime.jsx(RenderHook, {
|
|
3460
3576
|
hook: useIconRadioGroupValue,
|
|
3461
3577
|
parameters: [data, definition],
|
|
@@ -3524,6 +3640,12 @@ function ControlValue({
|
|
|
3524
3640
|
parameters: [data, definition, control],
|
|
3525
3641
|
children: (value) => children(value)
|
|
3526
3642
|
}, definition.type);
|
|
3643
|
+
case typography.TypographyControlType:
|
|
3644
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RenderHook, {
|
|
3645
|
+
hook: useTypographyValue,
|
|
3646
|
+
parameters: [data],
|
|
3647
|
+
children: (value) => children(value)
|
|
3648
|
+
}, definition.type);
|
|
3527
3649
|
default:
|
|
3528
3650
|
return children(data);
|
|
3529
3651
|
}
|
|
@@ -3565,19 +3687,20 @@ function PropsValue({
|
|
|
3565
3687
|
return Object.entries(propControllerDescriptorsRef.current).reduceRight((renderFn, [propName, descriptor]) => (propsValue) => {
|
|
3566
3688
|
var _a2, _b, _c, _d;
|
|
3567
3689
|
switch (descriptor.type) {
|
|
3568
|
-
case
|
|
3569
|
-
case
|
|
3570
|
-
case
|
|
3571
|
-
case
|
|
3572
|
-
case
|
|
3690
|
+
case typography.CheckboxControlType:
|
|
3691
|
+
case typography.NumberControlType:
|
|
3692
|
+
case typography.TextInputControlType:
|
|
3693
|
+
case typography.TextAreaControlType:
|
|
3694
|
+
case typography.SelectControlType:
|
|
3573
3695
|
case reactPage.ColorControlType:
|
|
3574
|
-
case
|
|
3696
|
+
case typography.IconRadioGroupControlType:
|
|
3575
3697
|
case reactPage.ImageControlType:
|
|
3576
3698
|
case combobox.ComboboxControlType:
|
|
3577
3699
|
case reactPage.ShapeControlType:
|
|
3578
3700
|
case reactPage.ListControlType:
|
|
3579
3701
|
case reactPage.LinkControlType:
|
|
3580
3702
|
case reactPage.StyleV2ControlType:
|
|
3703
|
+
case typography.TypographyControlType:
|
|
3581
3704
|
return /* @__PURE__ */ jsxRuntime.jsx(ControlValue, {
|
|
3582
3705
|
definition: descriptor,
|
|
3583
3706
|
data: props[propName],
|
|
@@ -3807,9 +3930,7 @@ class ReactRuntime {
|
|
|
3807
3930
|
__publicField(this, "store");
|
|
3808
3931
|
this.store = reactPage.configureStore({
|
|
3809
3932
|
breakpoints: breakpoints ? state_breakpoints.parseBreakpointsInput(breakpoints) : void 0,
|
|
3810
|
-
locales: unstable_i18n ?
|
|
3811
|
-
locale: null
|
|
3812
|
-
}) : void 0
|
|
3933
|
+
locales: unstable_i18n ? reactPage.parseLocalesInput(unstable_i18n) : void 0
|
|
3813
3934
|
});
|
|
3814
3935
|
registerBuiltinComponents(this);
|
|
3815
3936
|
}
|
|
@@ -4114,6 +4235,7 @@ exports.useBoxShadow = useBoxShadow;
|
|
|
4114
4235
|
exports.useBreakpoints = useBreakpoints;
|
|
4115
4236
|
exports.useBuilderEditMode = useBuilderEditMode;
|
|
4116
4237
|
exports.useElementId = useElementId;
|
|
4238
|
+
exports.useEnhancedTypography = useEnhancedTypography;
|
|
4117
4239
|
exports.useFile = useFile;
|
|
4118
4240
|
exports.useFiles = useFiles;
|
|
4119
4241
|
exports.useFormContext = useFormContext;
|
|
@@ -4129,5 +4251,5 @@ exports.useResponsiveTextStyle = useResponsiveTextStyle;
|
|
|
4129
4251
|
exports.useResponsiveWidth = useResponsiveWidth;
|
|
4130
4252
|
exports.useSwatches = useSwatches;
|
|
4131
4253
|
exports.useTable = useTable;
|
|
4132
|
-
exports.
|
|
4254
|
+
exports.useTypographyClassName = useTypographyClassName;
|
|
4133
4255
|
//# sourceMappingURL=index.cjs.js.map
|