@csg-org/block-heading 0.0.4-alpha.3 → 0.0.4-alpha.4
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/index.d.mts +106 -0
- package/dist/index.d.ts +106 -0
- package/dist/index.js +138 -0
- package/dist/index.mjs +101 -0
- package/package.json +1 -1
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
|
|
4
|
+
declare const HeadingPropsSchema: z.ZodObject<{
|
|
5
|
+
props: z.ZodNullable<z.ZodOptional<z.ZodObject<{
|
|
6
|
+
text: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
7
|
+
level: z.ZodNullable<z.ZodOptional<z.ZodEnum<["h1", "h2", "h3"]>>>;
|
|
8
|
+
}, "strip", z.ZodTypeAny, {
|
|
9
|
+
text?: string | null | undefined;
|
|
10
|
+
level?: "h1" | "h2" | "h3" | null | undefined;
|
|
11
|
+
}, {
|
|
12
|
+
text?: string | null | undefined;
|
|
13
|
+
level?: "h1" | "h2" | "h3" | null | undefined;
|
|
14
|
+
}>>>;
|
|
15
|
+
style: z.ZodNullable<z.ZodOptional<z.ZodObject<{
|
|
16
|
+
color: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
17
|
+
backgroundColor: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
18
|
+
fontFamily: z.ZodOptional<z.ZodNullable<z.ZodEnum<["MODERN_SANS", "BOOK_SANS", "ORGANIC_SANS", "GEOMETRIC_SANS", "HEAVY_SANS", "ROUNDED_SANS", "MODERN_SERIF", "BOOK_SERIF", "MONOSPACE"]>>>;
|
|
19
|
+
fontWeight: z.ZodNullable<z.ZodOptional<z.ZodEnum<["bold", "normal"]>>>;
|
|
20
|
+
textAlign: z.ZodNullable<z.ZodOptional<z.ZodEnum<["left", "center", "right"]>>>;
|
|
21
|
+
padding: z.ZodNullable<z.ZodOptional<z.ZodObject<{
|
|
22
|
+
top: z.ZodNumber;
|
|
23
|
+
bottom: z.ZodNumber;
|
|
24
|
+
right: z.ZodNumber;
|
|
25
|
+
left: z.ZodNumber;
|
|
26
|
+
}, "strip", z.ZodTypeAny, {
|
|
27
|
+
top: number;
|
|
28
|
+
bottom: number;
|
|
29
|
+
right: number;
|
|
30
|
+
left: number;
|
|
31
|
+
}, {
|
|
32
|
+
top: number;
|
|
33
|
+
bottom: number;
|
|
34
|
+
right: number;
|
|
35
|
+
left: number;
|
|
36
|
+
}>>>;
|
|
37
|
+
}, "strip", z.ZodTypeAny, {
|
|
38
|
+
color?: string | null | undefined;
|
|
39
|
+
backgroundColor?: string | null | undefined;
|
|
40
|
+
fontFamily?: "MODERN_SANS" | "BOOK_SANS" | "ORGANIC_SANS" | "GEOMETRIC_SANS" | "HEAVY_SANS" | "ROUNDED_SANS" | "MODERN_SERIF" | "BOOK_SERIF" | "MONOSPACE" | null | undefined;
|
|
41
|
+
fontWeight?: "bold" | "normal" | null | undefined;
|
|
42
|
+
textAlign?: "right" | "left" | "center" | null | undefined;
|
|
43
|
+
padding?: {
|
|
44
|
+
top: number;
|
|
45
|
+
bottom: number;
|
|
46
|
+
right: number;
|
|
47
|
+
left: number;
|
|
48
|
+
} | null | undefined;
|
|
49
|
+
}, {
|
|
50
|
+
color?: string | null | undefined;
|
|
51
|
+
backgroundColor?: string | null | undefined;
|
|
52
|
+
fontFamily?: "MODERN_SANS" | "BOOK_SANS" | "ORGANIC_SANS" | "GEOMETRIC_SANS" | "HEAVY_SANS" | "ROUNDED_SANS" | "MODERN_SERIF" | "BOOK_SERIF" | "MONOSPACE" | null | undefined;
|
|
53
|
+
fontWeight?: "bold" | "normal" | null | undefined;
|
|
54
|
+
textAlign?: "right" | "left" | "center" | null | undefined;
|
|
55
|
+
padding?: {
|
|
56
|
+
top: number;
|
|
57
|
+
bottom: number;
|
|
58
|
+
right: number;
|
|
59
|
+
left: number;
|
|
60
|
+
} | null | undefined;
|
|
61
|
+
}>>>;
|
|
62
|
+
}, "strip", z.ZodTypeAny, {
|
|
63
|
+
props?: {
|
|
64
|
+
text?: string | null | undefined;
|
|
65
|
+
level?: "h1" | "h2" | "h3" | null | undefined;
|
|
66
|
+
} | null | undefined;
|
|
67
|
+
style?: {
|
|
68
|
+
color?: string | null | undefined;
|
|
69
|
+
backgroundColor?: string | null | undefined;
|
|
70
|
+
fontFamily?: "MODERN_SANS" | "BOOK_SANS" | "ORGANIC_SANS" | "GEOMETRIC_SANS" | "HEAVY_SANS" | "ROUNDED_SANS" | "MODERN_SERIF" | "BOOK_SERIF" | "MONOSPACE" | null | undefined;
|
|
71
|
+
fontWeight?: "bold" | "normal" | null | undefined;
|
|
72
|
+
textAlign?: "right" | "left" | "center" | null | undefined;
|
|
73
|
+
padding?: {
|
|
74
|
+
top: number;
|
|
75
|
+
bottom: number;
|
|
76
|
+
right: number;
|
|
77
|
+
left: number;
|
|
78
|
+
} | null | undefined;
|
|
79
|
+
} | null | undefined;
|
|
80
|
+
}, {
|
|
81
|
+
props?: {
|
|
82
|
+
text?: string | null | undefined;
|
|
83
|
+
level?: "h1" | "h2" | "h3" | null | undefined;
|
|
84
|
+
} | null | undefined;
|
|
85
|
+
style?: {
|
|
86
|
+
color?: string | null | undefined;
|
|
87
|
+
backgroundColor?: string | null | undefined;
|
|
88
|
+
fontFamily?: "MODERN_SANS" | "BOOK_SANS" | "ORGANIC_SANS" | "GEOMETRIC_SANS" | "HEAVY_SANS" | "ROUNDED_SANS" | "MODERN_SERIF" | "BOOK_SERIF" | "MONOSPACE" | null | undefined;
|
|
89
|
+
fontWeight?: "bold" | "normal" | null | undefined;
|
|
90
|
+
textAlign?: "right" | "left" | "center" | null | undefined;
|
|
91
|
+
padding?: {
|
|
92
|
+
top: number;
|
|
93
|
+
bottom: number;
|
|
94
|
+
right: number;
|
|
95
|
+
left: number;
|
|
96
|
+
} | null | undefined;
|
|
97
|
+
} | null | undefined;
|
|
98
|
+
}>;
|
|
99
|
+
type HeadingProps = z.infer<typeof HeadingPropsSchema>;
|
|
100
|
+
declare const HeadingPropsDefaults: {
|
|
101
|
+
readonly level: "h2";
|
|
102
|
+
readonly text: "";
|
|
103
|
+
};
|
|
104
|
+
declare function Heading({ props, style }: HeadingProps): React.JSX.Element;
|
|
105
|
+
|
|
106
|
+
export { Heading, type HeadingProps, HeadingPropsDefaults, HeadingPropsSchema };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
|
|
4
|
+
declare const HeadingPropsSchema: z.ZodObject<{
|
|
5
|
+
props: z.ZodNullable<z.ZodOptional<z.ZodObject<{
|
|
6
|
+
text: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
7
|
+
level: z.ZodNullable<z.ZodOptional<z.ZodEnum<["h1", "h2", "h3"]>>>;
|
|
8
|
+
}, "strip", z.ZodTypeAny, {
|
|
9
|
+
text?: string | null | undefined;
|
|
10
|
+
level?: "h1" | "h2" | "h3" | null | undefined;
|
|
11
|
+
}, {
|
|
12
|
+
text?: string | null | undefined;
|
|
13
|
+
level?: "h1" | "h2" | "h3" | null | undefined;
|
|
14
|
+
}>>>;
|
|
15
|
+
style: z.ZodNullable<z.ZodOptional<z.ZodObject<{
|
|
16
|
+
color: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
17
|
+
backgroundColor: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
18
|
+
fontFamily: z.ZodOptional<z.ZodNullable<z.ZodEnum<["MODERN_SANS", "BOOK_SANS", "ORGANIC_SANS", "GEOMETRIC_SANS", "HEAVY_SANS", "ROUNDED_SANS", "MODERN_SERIF", "BOOK_SERIF", "MONOSPACE"]>>>;
|
|
19
|
+
fontWeight: z.ZodNullable<z.ZodOptional<z.ZodEnum<["bold", "normal"]>>>;
|
|
20
|
+
textAlign: z.ZodNullable<z.ZodOptional<z.ZodEnum<["left", "center", "right"]>>>;
|
|
21
|
+
padding: z.ZodNullable<z.ZodOptional<z.ZodObject<{
|
|
22
|
+
top: z.ZodNumber;
|
|
23
|
+
bottom: z.ZodNumber;
|
|
24
|
+
right: z.ZodNumber;
|
|
25
|
+
left: z.ZodNumber;
|
|
26
|
+
}, "strip", z.ZodTypeAny, {
|
|
27
|
+
top: number;
|
|
28
|
+
bottom: number;
|
|
29
|
+
right: number;
|
|
30
|
+
left: number;
|
|
31
|
+
}, {
|
|
32
|
+
top: number;
|
|
33
|
+
bottom: number;
|
|
34
|
+
right: number;
|
|
35
|
+
left: number;
|
|
36
|
+
}>>>;
|
|
37
|
+
}, "strip", z.ZodTypeAny, {
|
|
38
|
+
color?: string | null | undefined;
|
|
39
|
+
backgroundColor?: string | null | undefined;
|
|
40
|
+
fontFamily?: "MODERN_SANS" | "BOOK_SANS" | "ORGANIC_SANS" | "GEOMETRIC_SANS" | "HEAVY_SANS" | "ROUNDED_SANS" | "MODERN_SERIF" | "BOOK_SERIF" | "MONOSPACE" | null | undefined;
|
|
41
|
+
fontWeight?: "bold" | "normal" | null | undefined;
|
|
42
|
+
textAlign?: "right" | "left" | "center" | null | undefined;
|
|
43
|
+
padding?: {
|
|
44
|
+
top: number;
|
|
45
|
+
bottom: number;
|
|
46
|
+
right: number;
|
|
47
|
+
left: number;
|
|
48
|
+
} | null | undefined;
|
|
49
|
+
}, {
|
|
50
|
+
color?: string | null | undefined;
|
|
51
|
+
backgroundColor?: string | null | undefined;
|
|
52
|
+
fontFamily?: "MODERN_SANS" | "BOOK_SANS" | "ORGANIC_SANS" | "GEOMETRIC_SANS" | "HEAVY_SANS" | "ROUNDED_SANS" | "MODERN_SERIF" | "BOOK_SERIF" | "MONOSPACE" | null | undefined;
|
|
53
|
+
fontWeight?: "bold" | "normal" | null | undefined;
|
|
54
|
+
textAlign?: "right" | "left" | "center" | null | undefined;
|
|
55
|
+
padding?: {
|
|
56
|
+
top: number;
|
|
57
|
+
bottom: number;
|
|
58
|
+
right: number;
|
|
59
|
+
left: number;
|
|
60
|
+
} | null | undefined;
|
|
61
|
+
}>>>;
|
|
62
|
+
}, "strip", z.ZodTypeAny, {
|
|
63
|
+
props?: {
|
|
64
|
+
text?: string | null | undefined;
|
|
65
|
+
level?: "h1" | "h2" | "h3" | null | undefined;
|
|
66
|
+
} | null | undefined;
|
|
67
|
+
style?: {
|
|
68
|
+
color?: string | null | undefined;
|
|
69
|
+
backgroundColor?: string | null | undefined;
|
|
70
|
+
fontFamily?: "MODERN_SANS" | "BOOK_SANS" | "ORGANIC_SANS" | "GEOMETRIC_SANS" | "HEAVY_SANS" | "ROUNDED_SANS" | "MODERN_SERIF" | "BOOK_SERIF" | "MONOSPACE" | null | undefined;
|
|
71
|
+
fontWeight?: "bold" | "normal" | null | undefined;
|
|
72
|
+
textAlign?: "right" | "left" | "center" | null | undefined;
|
|
73
|
+
padding?: {
|
|
74
|
+
top: number;
|
|
75
|
+
bottom: number;
|
|
76
|
+
right: number;
|
|
77
|
+
left: number;
|
|
78
|
+
} | null | undefined;
|
|
79
|
+
} | null | undefined;
|
|
80
|
+
}, {
|
|
81
|
+
props?: {
|
|
82
|
+
text?: string | null | undefined;
|
|
83
|
+
level?: "h1" | "h2" | "h3" | null | undefined;
|
|
84
|
+
} | null | undefined;
|
|
85
|
+
style?: {
|
|
86
|
+
color?: string | null | undefined;
|
|
87
|
+
backgroundColor?: string | null | undefined;
|
|
88
|
+
fontFamily?: "MODERN_SANS" | "BOOK_SANS" | "ORGANIC_SANS" | "GEOMETRIC_SANS" | "HEAVY_SANS" | "ROUNDED_SANS" | "MODERN_SERIF" | "BOOK_SERIF" | "MONOSPACE" | null | undefined;
|
|
89
|
+
fontWeight?: "bold" | "normal" | null | undefined;
|
|
90
|
+
textAlign?: "right" | "left" | "center" | null | undefined;
|
|
91
|
+
padding?: {
|
|
92
|
+
top: number;
|
|
93
|
+
bottom: number;
|
|
94
|
+
right: number;
|
|
95
|
+
left: number;
|
|
96
|
+
} | null | undefined;
|
|
97
|
+
} | null | undefined;
|
|
98
|
+
}>;
|
|
99
|
+
type HeadingProps = z.infer<typeof HeadingPropsSchema>;
|
|
100
|
+
declare const HeadingPropsDefaults: {
|
|
101
|
+
readonly level: "h2";
|
|
102
|
+
readonly text: "";
|
|
103
|
+
};
|
|
104
|
+
declare function Heading({ props, style }: HeadingProps): React.JSX.Element;
|
|
105
|
+
|
|
106
|
+
export { Heading, type HeadingProps, HeadingPropsDefaults, HeadingPropsSchema };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/index.tsx
|
|
31
|
+
var index_exports = {};
|
|
32
|
+
__export(index_exports, {
|
|
33
|
+
Heading: () => Heading,
|
|
34
|
+
HeadingPropsDefaults: () => HeadingPropsDefaults,
|
|
35
|
+
HeadingPropsSchema: () => HeadingPropsSchema
|
|
36
|
+
});
|
|
37
|
+
module.exports = __toCommonJS(index_exports);
|
|
38
|
+
var import_react = __toESM(require("react"));
|
|
39
|
+
var import_zod = require("zod");
|
|
40
|
+
var COLOR_SCHEMA = import_zod.z.string().regex(/^#[0-9a-fA-F]{6}$/).nullable().optional();
|
|
41
|
+
var PADDING_SCHEMA = import_zod.z.object({
|
|
42
|
+
top: import_zod.z.number(),
|
|
43
|
+
bottom: import_zod.z.number(),
|
|
44
|
+
right: import_zod.z.number(),
|
|
45
|
+
left: import_zod.z.number()
|
|
46
|
+
}).optional().nullable();
|
|
47
|
+
var getPadding = (padding) => padding ? `${padding.top}px ${padding.right}px ${padding.bottom}px ${padding.left}px` : void 0;
|
|
48
|
+
var FONT_FAMILY_SCHEMA = import_zod.z.enum([
|
|
49
|
+
"MODERN_SANS",
|
|
50
|
+
"BOOK_SANS",
|
|
51
|
+
"ORGANIC_SANS",
|
|
52
|
+
"GEOMETRIC_SANS",
|
|
53
|
+
"HEAVY_SANS",
|
|
54
|
+
"ROUNDED_SANS",
|
|
55
|
+
"MODERN_SERIF",
|
|
56
|
+
"BOOK_SERIF",
|
|
57
|
+
"MONOSPACE"
|
|
58
|
+
]).nullable().optional();
|
|
59
|
+
function getFontFamily(fontFamily) {
|
|
60
|
+
switch (fontFamily) {
|
|
61
|
+
case "MODERN_SANS":
|
|
62
|
+
return '"Helvetica Neue", "Arial Nova", "Nimbus Sans", Arial, sans-serif';
|
|
63
|
+
case "BOOK_SANS":
|
|
64
|
+
return 'Optima, Candara, "Noto Sans", source-sans-pro, sans-serif';
|
|
65
|
+
case "ORGANIC_SANS":
|
|
66
|
+
return 'Seravek, "Gill Sans Nova", Ubuntu, Calibri, "DejaVu Sans", source-sans-pro, sans-serif';
|
|
67
|
+
case "GEOMETRIC_SANS":
|
|
68
|
+
return 'Avenir, "Avenir Next LT Pro", Montserrat, Corbel, "URW Gothic", source-sans-pro, sans-serif';
|
|
69
|
+
case "HEAVY_SANS":
|
|
70
|
+
return 'Bahnschrift, "DIN Alternate", "Franklin Gothic Medium", "Nimbus Sans Narrow", sans-serif-condensed, sans-serif';
|
|
71
|
+
case "ROUNDED_SANS":
|
|
72
|
+
return 'ui-rounded, "Hiragino Maru Gothic ProN", Quicksand, Comfortaa, Manjari, "Arial Rounded MT Bold", Calibri, source-sans-pro, sans-serif';
|
|
73
|
+
case "MODERN_SERIF":
|
|
74
|
+
return 'Charter, "Bitstream Charter", "Sitka Text", Cambria, serif';
|
|
75
|
+
case "BOOK_SERIF":
|
|
76
|
+
return '"Iowan Old Style", "Palatino Linotype", "URW Palladio L", P052, serif';
|
|
77
|
+
case "MONOSPACE":
|
|
78
|
+
return '"Nimbus Mono PS", "Courier New", "Cutive Mono", monospace';
|
|
79
|
+
}
|
|
80
|
+
return void 0;
|
|
81
|
+
}
|
|
82
|
+
var HeadingPropsSchema = import_zod.z.object({
|
|
83
|
+
props: import_zod.z.object({
|
|
84
|
+
text: import_zod.z.string().optional().nullable(),
|
|
85
|
+
level: import_zod.z.enum(["h1", "h2", "h3"]).optional().nullable()
|
|
86
|
+
}).optional().nullable(),
|
|
87
|
+
style: import_zod.z.object({
|
|
88
|
+
color: COLOR_SCHEMA,
|
|
89
|
+
backgroundColor: COLOR_SCHEMA,
|
|
90
|
+
fontFamily: FONT_FAMILY_SCHEMA,
|
|
91
|
+
fontWeight: import_zod.z.enum(["bold", "normal"]).optional().nullable(),
|
|
92
|
+
textAlign: import_zod.z.enum(["left", "center", "right"]).optional().nullable(),
|
|
93
|
+
padding: PADDING_SCHEMA
|
|
94
|
+
}).optional().nullable()
|
|
95
|
+
});
|
|
96
|
+
var HeadingPropsDefaults = {
|
|
97
|
+
level: "h2",
|
|
98
|
+
text: ""
|
|
99
|
+
};
|
|
100
|
+
function Heading({ props, style }) {
|
|
101
|
+
var _a, _b, _c, _d, _e, _f;
|
|
102
|
+
const level = (_a = props == null ? void 0 : props.level) != null ? _a : HeadingPropsDefaults.level;
|
|
103
|
+
const text = (_b = props == null ? void 0 : props.text) != null ? _b : HeadingPropsDefaults.text;
|
|
104
|
+
const hStyle = {
|
|
105
|
+
color: (_c = style == null ? void 0 : style.color) != null ? _c : void 0,
|
|
106
|
+
backgroundColor: (_d = style == null ? void 0 : style.backgroundColor) != null ? _d : void 0,
|
|
107
|
+
fontWeight: (_e = style == null ? void 0 : style.fontWeight) != null ? _e : "bold",
|
|
108
|
+
textAlign: (_f = style == null ? void 0 : style.textAlign) != null ? _f : void 0,
|
|
109
|
+
margin: 0,
|
|
110
|
+
fontFamily: getFontFamily(style == null ? void 0 : style.fontFamily),
|
|
111
|
+
fontSize: getFontSize(level),
|
|
112
|
+
padding: getPadding(style == null ? void 0 : style.padding)
|
|
113
|
+
};
|
|
114
|
+
switch (level) {
|
|
115
|
+
case "h1":
|
|
116
|
+
return /* @__PURE__ */ import_react.default.createElement("h1", { style: hStyle }, text);
|
|
117
|
+
case "h2":
|
|
118
|
+
return /* @__PURE__ */ import_react.default.createElement("h2", { style: hStyle }, text);
|
|
119
|
+
case "h3":
|
|
120
|
+
return /* @__PURE__ */ import_react.default.createElement("h3", { style: hStyle }, text);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
function getFontSize(level) {
|
|
124
|
+
switch (level) {
|
|
125
|
+
case "h1":
|
|
126
|
+
return 32;
|
|
127
|
+
case "h2":
|
|
128
|
+
return 24;
|
|
129
|
+
case "h3":
|
|
130
|
+
return 20;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
134
|
+
0 && (module.exports = {
|
|
135
|
+
Heading,
|
|
136
|
+
HeadingPropsDefaults,
|
|
137
|
+
HeadingPropsSchema
|
|
138
|
+
});
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
// src/index.tsx
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
var COLOR_SCHEMA = z.string().regex(/^#[0-9a-fA-F]{6}$/).nullable().optional();
|
|
5
|
+
var PADDING_SCHEMA = z.object({
|
|
6
|
+
top: z.number(),
|
|
7
|
+
bottom: z.number(),
|
|
8
|
+
right: z.number(),
|
|
9
|
+
left: z.number()
|
|
10
|
+
}).optional().nullable();
|
|
11
|
+
var getPadding = (padding) => padding ? `${padding.top}px ${padding.right}px ${padding.bottom}px ${padding.left}px` : void 0;
|
|
12
|
+
var FONT_FAMILY_SCHEMA = z.enum([
|
|
13
|
+
"MODERN_SANS",
|
|
14
|
+
"BOOK_SANS",
|
|
15
|
+
"ORGANIC_SANS",
|
|
16
|
+
"GEOMETRIC_SANS",
|
|
17
|
+
"HEAVY_SANS",
|
|
18
|
+
"ROUNDED_SANS",
|
|
19
|
+
"MODERN_SERIF",
|
|
20
|
+
"BOOK_SERIF",
|
|
21
|
+
"MONOSPACE"
|
|
22
|
+
]).nullable().optional();
|
|
23
|
+
function getFontFamily(fontFamily) {
|
|
24
|
+
switch (fontFamily) {
|
|
25
|
+
case "MODERN_SANS":
|
|
26
|
+
return '"Helvetica Neue", "Arial Nova", "Nimbus Sans", Arial, sans-serif';
|
|
27
|
+
case "BOOK_SANS":
|
|
28
|
+
return 'Optima, Candara, "Noto Sans", source-sans-pro, sans-serif';
|
|
29
|
+
case "ORGANIC_SANS":
|
|
30
|
+
return 'Seravek, "Gill Sans Nova", Ubuntu, Calibri, "DejaVu Sans", source-sans-pro, sans-serif';
|
|
31
|
+
case "GEOMETRIC_SANS":
|
|
32
|
+
return 'Avenir, "Avenir Next LT Pro", Montserrat, Corbel, "URW Gothic", source-sans-pro, sans-serif';
|
|
33
|
+
case "HEAVY_SANS":
|
|
34
|
+
return 'Bahnschrift, "DIN Alternate", "Franklin Gothic Medium", "Nimbus Sans Narrow", sans-serif-condensed, sans-serif';
|
|
35
|
+
case "ROUNDED_SANS":
|
|
36
|
+
return 'ui-rounded, "Hiragino Maru Gothic ProN", Quicksand, Comfortaa, Manjari, "Arial Rounded MT Bold", Calibri, source-sans-pro, sans-serif';
|
|
37
|
+
case "MODERN_SERIF":
|
|
38
|
+
return 'Charter, "Bitstream Charter", "Sitka Text", Cambria, serif';
|
|
39
|
+
case "BOOK_SERIF":
|
|
40
|
+
return '"Iowan Old Style", "Palatino Linotype", "URW Palladio L", P052, serif';
|
|
41
|
+
case "MONOSPACE":
|
|
42
|
+
return '"Nimbus Mono PS", "Courier New", "Cutive Mono", monospace';
|
|
43
|
+
}
|
|
44
|
+
return void 0;
|
|
45
|
+
}
|
|
46
|
+
var HeadingPropsSchema = z.object({
|
|
47
|
+
props: z.object({
|
|
48
|
+
text: z.string().optional().nullable(),
|
|
49
|
+
level: z.enum(["h1", "h2", "h3"]).optional().nullable()
|
|
50
|
+
}).optional().nullable(),
|
|
51
|
+
style: z.object({
|
|
52
|
+
color: COLOR_SCHEMA,
|
|
53
|
+
backgroundColor: COLOR_SCHEMA,
|
|
54
|
+
fontFamily: FONT_FAMILY_SCHEMA,
|
|
55
|
+
fontWeight: z.enum(["bold", "normal"]).optional().nullable(),
|
|
56
|
+
textAlign: z.enum(["left", "center", "right"]).optional().nullable(),
|
|
57
|
+
padding: PADDING_SCHEMA
|
|
58
|
+
}).optional().nullable()
|
|
59
|
+
});
|
|
60
|
+
var HeadingPropsDefaults = {
|
|
61
|
+
level: "h2",
|
|
62
|
+
text: ""
|
|
63
|
+
};
|
|
64
|
+
function Heading({ props, style }) {
|
|
65
|
+
var _a, _b, _c, _d, _e, _f;
|
|
66
|
+
const level = (_a = props == null ? void 0 : props.level) != null ? _a : HeadingPropsDefaults.level;
|
|
67
|
+
const text = (_b = props == null ? void 0 : props.text) != null ? _b : HeadingPropsDefaults.text;
|
|
68
|
+
const hStyle = {
|
|
69
|
+
color: (_c = style == null ? void 0 : style.color) != null ? _c : void 0,
|
|
70
|
+
backgroundColor: (_d = style == null ? void 0 : style.backgroundColor) != null ? _d : void 0,
|
|
71
|
+
fontWeight: (_e = style == null ? void 0 : style.fontWeight) != null ? _e : "bold",
|
|
72
|
+
textAlign: (_f = style == null ? void 0 : style.textAlign) != null ? _f : void 0,
|
|
73
|
+
margin: 0,
|
|
74
|
+
fontFamily: getFontFamily(style == null ? void 0 : style.fontFamily),
|
|
75
|
+
fontSize: getFontSize(level),
|
|
76
|
+
padding: getPadding(style == null ? void 0 : style.padding)
|
|
77
|
+
};
|
|
78
|
+
switch (level) {
|
|
79
|
+
case "h1":
|
|
80
|
+
return /* @__PURE__ */ React.createElement("h1", { style: hStyle }, text);
|
|
81
|
+
case "h2":
|
|
82
|
+
return /* @__PURE__ */ React.createElement("h2", { style: hStyle }, text);
|
|
83
|
+
case "h3":
|
|
84
|
+
return /* @__PURE__ */ React.createElement("h3", { style: hStyle }, text);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
function getFontSize(level) {
|
|
88
|
+
switch (level) {
|
|
89
|
+
case "h1":
|
|
90
|
+
return 32;
|
|
91
|
+
case "h2":
|
|
92
|
+
return 24;
|
|
93
|
+
case "h3":
|
|
94
|
+
return 20;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
export {
|
|
98
|
+
Heading,
|
|
99
|
+
HeadingPropsDefaults,
|
|
100
|
+
HeadingPropsSchema
|
|
101
|
+
};
|