@mission-studio/puck 1.0.19 → 1.0.20

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,78 @@
1
+ import {
2
+ getHeadingStyle
3
+ } from "./chunk-X6VGLL5Y.mjs";
4
+ import {
5
+ useEntries,
6
+ useTheme
7
+ } from "./chunk-PJXZC564.mjs";
8
+ import {
9
+ hexToRgba
10
+ } from "./chunk-C6V3YUPF.mjs";
11
+
12
+ // components/page/next/Heading.tsx
13
+ import { jsx } from "react/jsx-runtime";
14
+ function isThemeableValue(value) {
15
+ return typeof value === "object" && value !== null && "useTheme" in value;
16
+ }
17
+ function isEntryBoundValue(value) {
18
+ return typeof value === "object" && value !== null && "useEntry" in value;
19
+ }
20
+ function Heading({
21
+ text,
22
+ level = "h2",
23
+ size = "2xl",
24
+ weight = "bold",
25
+ color,
26
+ align = "left",
27
+ letterSpacing = "normal",
28
+ lineHeight = "tight",
29
+ id
30
+ }) {
31
+ const { resolveColor } = useTheme();
32
+ const { getEntryValue } = useEntries();
33
+ const resolvedText = (() => {
34
+ if (!text) return "";
35
+ if (typeof text === "string") return text;
36
+ if (isEntryBoundValue(text)) {
37
+ if (text.useEntry) {
38
+ return String(getEntryValue(text.entryName, text.fieldKey) ?? "");
39
+ }
40
+ return text.value;
41
+ }
42
+ return "";
43
+ })();
44
+ const resolvedColor = (() => {
45
+ if (!color)
46
+ return hexToRgba(
47
+ resolveColor("foreground").color,
48
+ resolveColor("foreground").opacity
49
+ );
50
+ if (typeof color === "string") return color;
51
+ if (isThemeableValue(color)) {
52
+ return color.useTheme ? hexToRgba(
53
+ resolveColor(color.themeKey).color,
54
+ resolveColor(color.themeKey).opacity
55
+ ) : hexToRgba(color.value.color, color.value.opacity);
56
+ }
57
+ if ("color" in color) return hexToRgba(color.color, color.opacity);
58
+ return hexToRgba(
59
+ resolveColor("foreground").color,
60
+ resolveColor("foreground").opacity
61
+ );
62
+ })();
63
+ const Tag = level;
64
+ const style = getHeadingStyle({
65
+ size,
66
+ weight,
67
+ color: resolvedColor,
68
+ align,
69
+ letterSpacing,
70
+ lineHeight
71
+ });
72
+ if (!resolvedText) return null;
73
+ return /* @__PURE__ */ jsx(Tag, { id, style, children: resolvedText });
74
+ }
75
+
76
+ export {
77
+ Heading
78
+ };