@mission-studio/puck 1.0.19 → 1.0.21

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.
@@ -0,0 +1,142 @@
1
+ import {
2
+ getHeadingStyle,
3
+ getParagraphStyle
4
+ } from "./chunk-MWW5LYLN.mjs";
5
+ import {
6
+ useEntries,
7
+ useTheme
8
+ } from "./chunk-PJXZC564.mjs";
9
+ import {
10
+ hexToRgba
11
+ } from "./chunk-C6V3YUPF.mjs";
12
+
13
+ // components/page/next/Heading.tsx
14
+ import { jsx } from "react/jsx-runtime";
15
+ function isThemeableValue(value) {
16
+ return typeof value === "object" && value !== null && "useTheme" in value;
17
+ }
18
+ function isEntryBoundValue(value) {
19
+ return typeof value === "object" && value !== null && "useEntry" in value;
20
+ }
21
+ function Heading({
22
+ text,
23
+ level = "h2",
24
+ size = "2xl",
25
+ weight = "bold",
26
+ color,
27
+ align = "left",
28
+ letterSpacing = "normal",
29
+ lineHeight = "tight",
30
+ id
31
+ }) {
32
+ const { resolveColor } = useTheme();
33
+ const { getEntryValue } = useEntries();
34
+ const resolvedText = (() => {
35
+ if (!text) return "";
36
+ if (typeof text === "string") return text;
37
+ if (isEntryBoundValue(text)) {
38
+ if (text.useEntry) {
39
+ return String(getEntryValue(text.entryName, text.fieldKey) ?? "");
40
+ }
41
+ return text.value;
42
+ }
43
+ return "";
44
+ })();
45
+ const resolvedColor = (() => {
46
+ if (!color)
47
+ return hexToRgba(
48
+ resolveColor("foreground").color,
49
+ resolveColor("foreground").opacity
50
+ );
51
+ if (typeof color === "string") return color;
52
+ if (isThemeableValue(color)) {
53
+ return color.useTheme ? hexToRgba(
54
+ resolveColor(color.themeKey).color,
55
+ resolveColor(color.themeKey).opacity
56
+ ) : hexToRgba(color.value.color, color.value.opacity);
57
+ }
58
+ if ("color" in color) return hexToRgba(color.color, color.opacity);
59
+ return hexToRgba(
60
+ resolveColor("foreground").color,
61
+ resolveColor("foreground").opacity
62
+ );
63
+ })();
64
+ const Tag = level;
65
+ const style = getHeadingStyle({
66
+ size,
67
+ weight,
68
+ color: resolvedColor,
69
+ align,
70
+ letterSpacing,
71
+ lineHeight
72
+ });
73
+ if (!resolvedText) return null;
74
+ return /* @__PURE__ */ jsx(Tag, { id, style, children: resolvedText });
75
+ }
76
+
77
+ // components/page/next/Paragraph.tsx
78
+ import { jsx as jsx2 } from "react/jsx-runtime";
79
+ function isThemeableValue2(value) {
80
+ return typeof value === "object" && value !== null && "useTheme" in value;
81
+ }
82
+ function isEntryBoundValue2(value) {
83
+ return typeof value === "object" && value !== null && "useEntry" in value;
84
+ }
85
+ function Paragraph({
86
+ text,
87
+ size = "base",
88
+ weight = "normal",
89
+ color,
90
+ align = "left",
91
+ lineHeight = "normal",
92
+ maxWidth,
93
+ id
94
+ }) {
95
+ const { resolveColor } = useTheme();
96
+ const { getEntryValue } = useEntries();
97
+ const resolvedText = (() => {
98
+ if (!text) return "";
99
+ if (typeof text === "string") return text;
100
+ if (isEntryBoundValue2(text)) {
101
+ if (text.useEntry) {
102
+ return String(getEntryValue(text.entryName, text.fieldKey) ?? "");
103
+ }
104
+ return text.value;
105
+ }
106
+ return "";
107
+ })();
108
+ const resolvedColor = (() => {
109
+ if (!color)
110
+ return hexToRgba(
111
+ resolveColor("foreground").color,
112
+ resolveColor("foreground").opacity
113
+ );
114
+ if (typeof color === "string") return color;
115
+ if (isThemeableValue2(color)) {
116
+ return color.useTheme ? hexToRgba(
117
+ resolveColor(color.themeKey).color,
118
+ resolveColor(color.themeKey).opacity
119
+ ) : hexToRgba(color.value.color, color.value.opacity);
120
+ }
121
+ if ("color" in color) return hexToRgba(color.color, color.opacity);
122
+ return hexToRgba(
123
+ resolveColor("foreground").color,
124
+ resolveColor("foreground").opacity
125
+ );
126
+ })();
127
+ const style = getParagraphStyle({
128
+ size,
129
+ weight,
130
+ color: resolvedColor,
131
+ align,
132
+ lineHeight,
133
+ maxWidth
134
+ });
135
+ if (!resolvedText) return null;
136
+ return /* @__PURE__ */ jsx2("p", { id, style, children: resolvedText });
137
+ }
138
+
139
+ export {
140
+ Heading,
141
+ Paragraph
142
+ };