@csg-org/block-button 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 +136 -0
- package/dist/index.d.ts +136 -0
- package/dist/index.js +184 -0
- package/dist/index.mjs +147 -0
- package/package.json +1 -1
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
|
|
4
|
+
declare const ButtonPropsSchema: z.ZodObject<{
|
|
5
|
+
style: z.ZodNullable<z.ZodOptional<z.ZodObject<{
|
|
6
|
+
backgroundColor: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
7
|
+
fontSize: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
|
|
8
|
+
fontFamily: z.ZodOptional<z.ZodNullable<z.ZodEnum<["MODERN_SANS", "BOOK_SANS", "ORGANIC_SANS", "GEOMETRIC_SANS", "HEAVY_SANS", "ROUNDED_SANS", "MODERN_SERIF", "BOOK_SERIF", "MONOSPACE"]>>>;
|
|
9
|
+
fontWeight: z.ZodNullable<z.ZodOptional<z.ZodEnum<["bold", "normal"]>>>;
|
|
10
|
+
textAlign: z.ZodNullable<z.ZodOptional<z.ZodEnum<["left", "center", "right"]>>>;
|
|
11
|
+
padding: z.ZodNullable<z.ZodOptional<z.ZodObject<{
|
|
12
|
+
top: z.ZodNumber;
|
|
13
|
+
bottom: z.ZodNumber;
|
|
14
|
+
right: z.ZodNumber;
|
|
15
|
+
left: z.ZodNumber;
|
|
16
|
+
}, "strip", z.ZodTypeAny, {
|
|
17
|
+
top: number;
|
|
18
|
+
bottom: number;
|
|
19
|
+
right: number;
|
|
20
|
+
left: number;
|
|
21
|
+
}, {
|
|
22
|
+
top: number;
|
|
23
|
+
bottom: number;
|
|
24
|
+
right: number;
|
|
25
|
+
left: number;
|
|
26
|
+
}>>>;
|
|
27
|
+
}, "strip", z.ZodTypeAny, {
|
|
28
|
+
backgroundColor?: string | null | undefined;
|
|
29
|
+
fontSize?: number | null | undefined;
|
|
30
|
+
fontFamily?: "MODERN_SANS" | "BOOK_SANS" | "ORGANIC_SANS" | "GEOMETRIC_SANS" | "HEAVY_SANS" | "ROUNDED_SANS" | "MODERN_SERIF" | "BOOK_SERIF" | "MONOSPACE" | null | undefined;
|
|
31
|
+
fontWeight?: "bold" | "normal" | null | undefined;
|
|
32
|
+
textAlign?: "right" | "left" | "center" | null | undefined;
|
|
33
|
+
padding?: {
|
|
34
|
+
top: number;
|
|
35
|
+
bottom: number;
|
|
36
|
+
right: number;
|
|
37
|
+
left: number;
|
|
38
|
+
} | null | undefined;
|
|
39
|
+
}, {
|
|
40
|
+
backgroundColor?: string | null | undefined;
|
|
41
|
+
fontSize?: number | null | undefined;
|
|
42
|
+
fontFamily?: "MODERN_SANS" | "BOOK_SANS" | "ORGANIC_SANS" | "GEOMETRIC_SANS" | "HEAVY_SANS" | "ROUNDED_SANS" | "MODERN_SERIF" | "BOOK_SERIF" | "MONOSPACE" | null | undefined;
|
|
43
|
+
fontWeight?: "bold" | "normal" | null | undefined;
|
|
44
|
+
textAlign?: "right" | "left" | "center" | null | undefined;
|
|
45
|
+
padding?: {
|
|
46
|
+
top: number;
|
|
47
|
+
bottom: number;
|
|
48
|
+
right: number;
|
|
49
|
+
left: number;
|
|
50
|
+
} | null | undefined;
|
|
51
|
+
}>>>;
|
|
52
|
+
props: z.ZodNullable<z.ZodOptional<z.ZodObject<{
|
|
53
|
+
buttonBackgroundColor: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
54
|
+
buttonStyle: z.ZodNullable<z.ZodOptional<z.ZodEnum<["rectangle", "pill", "rounded"]>>>;
|
|
55
|
+
buttonTextColor: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
56
|
+
fullWidth: z.ZodNullable<z.ZodOptional<z.ZodBoolean>>;
|
|
57
|
+
size: z.ZodNullable<z.ZodOptional<z.ZodEnum<["x-small", "small", "large", "medium"]>>>;
|
|
58
|
+
text: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
59
|
+
url: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
60
|
+
}, "strip", z.ZodTypeAny, {
|
|
61
|
+
buttonBackgroundColor?: string | null | undefined;
|
|
62
|
+
buttonStyle?: "rectangle" | "pill" | "rounded" | null | undefined;
|
|
63
|
+
buttonTextColor?: string | null | undefined;
|
|
64
|
+
fullWidth?: boolean | null | undefined;
|
|
65
|
+
size?: "x-small" | "small" | "large" | "medium" | null | undefined;
|
|
66
|
+
text?: string | null | undefined;
|
|
67
|
+
url?: string | null | undefined;
|
|
68
|
+
}, {
|
|
69
|
+
buttonBackgroundColor?: string | null | undefined;
|
|
70
|
+
buttonStyle?: "rectangle" | "pill" | "rounded" | null | undefined;
|
|
71
|
+
buttonTextColor?: string | null | undefined;
|
|
72
|
+
fullWidth?: boolean | null | undefined;
|
|
73
|
+
size?: "x-small" | "small" | "large" | "medium" | null | undefined;
|
|
74
|
+
text?: string | null | undefined;
|
|
75
|
+
url?: string | null | undefined;
|
|
76
|
+
}>>>;
|
|
77
|
+
}, "strip", z.ZodTypeAny, {
|
|
78
|
+
style?: {
|
|
79
|
+
backgroundColor?: string | null | undefined;
|
|
80
|
+
fontSize?: number | null | undefined;
|
|
81
|
+
fontFamily?: "MODERN_SANS" | "BOOK_SANS" | "ORGANIC_SANS" | "GEOMETRIC_SANS" | "HEAVY_SANS" | "ROUNDED_SANS" | "MODERN_SERIF" | "BOOK_SERIF" | "MONOSPACE" | null | undefined;
|
|
82
|
+
fontWeight?: "bold" | "normal" | null | undefined;
|
|
83
|
+
textAlign?: "right" | "left" | "center" | null | undefined;
|
|
84
|
+
padding?: {
|
|
85
|
+
top: number;
|
|
86
|
+
bottom: number;
|
|
87
|
+
right: number;
|
|
88
|
+
left: number;
|
|
89
|
+
} | null | undefined;
|
|
90
|
+
} | null | undefined;
|
|
91
|
+
props?: {
|
|
92
|
+
buttonBackgroundColor?: string | null | undefined;
|
|
93
|
+
buttonStyle?: "rectangle" | "pill" | "rounded" | null | undefined;
|
|
94
|
+
buttonTextColor?: string | null | undefined;
|
|
95
|
+
fullWidth?: boolean | null | undefined;
|
|
96
|
+
size?: "x-small" | "small" | "large" | "medium" | null | undefined;
|
|
97
|
+
text?: string | null | undefined;
|
|
98
|
+
url?: string | null | undefined;
|
|
99
|
+
} | null | undefined;
|
|
100
|
+
}, {
|
|
101
|
+
style?: {
|
|
102
|
+
backgroundColor?: string | null | undefined;
|
|
103
|
+
fontSize?: number | null | undefined;
|
|
104
|
+
fontFamily?: "MODERN_SANS" | "BOOK_SANS" | "ORGANIC_SANS" | "GEOMETRIC_SANS" | "HEAVY_SANS" | "ROUNDED_SANS" | "MODERN_SERIF" | "BOOK_SERIF" | "MONOSPACE" | null | undefined;
|
|
105
|
+
fontWeight?: "bold" | "normal" | null | undefined;
|
|
106
|
+
textAlign?: "right" | "left" | "center" | null | undefined;
|
|
107
|
+
padding?: {
|
|
108
|
+
top: number;
|
|
109
|
+
bottom: number;
|
|
110
|
+
right: number;
|
|
111
|
+
left: number;
|
|
112
|
+
} | null | undefined;
|
|
113
|
+
} | null | undefined;
|
|
114
|
+
props?: {
|
|
115
|
+
buttonBackgroundColor?: string | null | undefined;
|
|
116
|
+
buttonStyle?: "rectangle" | "pill" | "rounded" | null | undefined;
|
|
117
|
+
buttonTextColor?: string | null | undefined;
|
|
118
|
+
fullWidth?: boolean | null | undefined;
|
|
119
|
+
size?: "x-small" | "small" | "large" | "medium" | null | undefined;
|
|
120
|
+
text?: string | null | undefined;
|
|
121
|
+
url?: string | null | undefined;
|
|
122
|
+
} | null | undefined;
|
|
123
|
+
}>;
|
|
124
|
+
type ButtonProps = z.infer<typeof ButtonPropsSchema>;
|
|
125
|
+
declare const ButtonPropsDefaults: {
|
|
126
|
+
readonly text: "";
|
|
127
|
+
readonly url: "";
|
|
128
|
+
readonly fullWidth: false;
|
|
129
|
+
readonly size: "medium";
|
|
130
|
+
readonly buttonStyle: "rounded";
|
|
131
|
+
readonly buttonTextColor: "#FFFFFF";
|
|
132
|
+
readonly buttonBackgroundColor: "#999999";
|
|
133
|
+
};
|
|
134
|
+
declare function Button({ style, props }: ButtonProps): React.JSX.Element;
|
|
135
|
+
|
|
136
|
+
export { Button, type ButtonProps, ButtonPropsDefaults, ButtonPropsSchema };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
|
|
4
|
+
declare const ButtonPropsSchema: z.ZodObject<{
|
|
5
|
+
style: z.ZodNullable<z.ZodOptional<z.ZodObject<{
|
|
6
|
+
backgroundColor: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
7
|
+
fontSize: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
|
|
8
|
+
fontFamily: z.ZodOptional<z.ZodNullable<z.ZodEnum<["MODERN_SANS", "BOOK_SANS", "ORGANIC_SANS", "GEOMETRIC_SANS", "HEAVY_SANS", "ROUNDED_SANS", "MODERN_SERIF", "BOOK_SERIF", "MONOSPACE"]>>>;
|
|
9
|
+
fontWeight: z.ZodNullable<z.ZodOptional<z.ZodEnum<["bold", "normal"]>>>;
|
|
10
|
+
textAlign: z.ZodNullable<z.ZodOptional<z.ZodEnum<["left", "center", "right"]>>>;
|
|
11
|
+
padding: z.ZodNullable<z.ZodOptional<z.ZodObject<{
|
|
12
|
+
top: z.ZodNumber;
|
|
13
|
+
bottom: z.ZodNumber;
|
|
14
|
+
right: z.ZodNumber;
|
|
15
|
+
left: z.ZodNumber;
|
|
16
|
+
}, "strip", z.ZodTypeAny, {
|
|
17
|
+
top: number;
|
|
18
|
+
bottom: number;
|
|
19
|
+
right: number;
|
|
20
|
+
left: number;
|
|
21
|
+
}, {
|
|
22
|
+
top: number;
|
|
23
|
+
bottom: number;
|
|
24
|
+
right: number;
|
|
25
|
+
left: number;
|
|
26
|
+
}>>>;
|
|
27
|
+
}, "strip", z.ZodTypeAny, {
|
|
28
|
+
backgroundColor?: string | null | undefined;
|
|
29
|
+
fontSize?: number | null | undefined;
|
|
30
|
+
fontFamily?: "MODERN_SANS" | "BOOK_SANS" | "ORGANIC_SANS" | "GEOMETRIC_SANS" | "HEAVY_SANS" | "ROUNDED_SANS" | "MODERN_SERIF" | "BOOK_SERIF" | "MONOSPACE" | null | undefined;
|
|
31
|
+
fontWeight?: "bold" | "normal" | null | undefined;
|
|
32
|
+
textAlign?: "right" | "left" | "center" | null | undefined;
|
|
33
|
+
padding?: {
|
|
34
|
+
top: number;
|
|
35
|
+
bottom: number;
|
|
36
|
+
right: number;
|
|
37
|
+
left: number;
|
|
38
|
+
} | null | undefined;
|
|
39
|
+
}, {
|
|
40
|
+
backgroundColor?: string | null | undefined;
|
|
41
|
+
fontSize?: number | null | undefined;
|
|
42
|
+
fontFamily?: "MODERN_SANS" | "BOOK_SANS" | "ORGANIC_SANS" | "GEOMETRIC_SANS" | "HEAVY_SANS" | "ROUNDED_SANS" | "MODERN_SERIF" | "BOOK_SERIF" | "MONOSPACE" | null | undefined;
|
|
43
|
+
fontWeight?: "bold" | "normal" | null | undefined;
|
|
44
|
+
textAlign?: "right" | "left" | "center" | null | undefined;
|
|
45
|
+
padding?: {
|
|
46
|
+
top: number;
|
|
47
|
+
bottom: number;
|
|
48
|
+
right: number;
|
|
49
|
+
left: number;
|
|
50
|
+
} | null | undefined;
|
|
51
|
+
}>>>;
|
|
52
|
+
props: z.ZodNullable<z.ZodOptional<z.ZodObject<{
|
|
53
|
+
buttonBackgroundColor: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
54
|
+
buttonStyle: z.ZodNullable<z.ZodOptional<z.ZodEnum<["rectangle", "pill", "rounded"]>>>;
|
|
55
|
+
buttonTextColor: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
56
|
+
fullWidth: z.ZodNullable<z.ZodOptional<z.ZodBoolean>>;
|
|
57
|
+
size: z.ZodNullable<z.ZodOptional<z.ZodEnum<["x-small", "small", "large", "medium"]>>>;
|
|
58
|
+
text: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
59
|
+
url: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
60
|
+
}, "strip", z.ZodTypeAny, {
|
|
61
|
+
buttonBackgroundColor?: string | null | undefined;
|
|
62
|
+
buttonStyle?: "rectangle" | "pill" | "rounded" | null | undefined;
|
|
63
|
+
buttonTextColor?: string | null | undefined;
|
|
64
|
+
fullWidth?: boolean | null | undefined;
|
|
65
|
+
size?: "x-small" | "small" | "large" | "medium" | null | undefined;
|
|
66
|
+
text?: string | null | undefined;
|
|
67
|
+
url?: string | null | undefined;
|
|
68
|
+
}, {
|
|
69
|
+
buttonBackgroundColor?: string | null | undefined;
|
|
70
|
+
buttonStyle?: "rectangle" | "pill" | "rounded" | null | undefined;
|
|
71
|
+
buttonTextColor?: string | null | undefined;
|
|
72
|
+
fullWidth?: boolean | null | undefined;
|
|
73
|
+
size?: "x-small" | "small" | "large" | "medium" | null | undefined;
|
|
74
|
+
text?: string | null | undefined;
|
|
75
|
+
url?: string | null | undefined;
|
|
76
|
+
}>>>;
|
|
77
|
+
}, "strip", z.ZodTypeAny, {
|
|
78
|
+
style?: {
|
|
79
|
+
backgroundColor?: string | null | undefined;
|
|
80
|
+
fontSize?: number | null | undefined;
|
|
81
|
+
fontFamily?: "MODERN_SANS" | "BOOK_SANS" | "ORGANIC_SANS" | "GEOMETRIC_SANS" | "HEAVY_SANS" | "ROUNDED_SANS" | "MODERN_SERIF" | "BOOK_SERIF" | "MONOSPACE" | null | undefined;
|
|
82
|
+
fontWeight?: "bold" | "normal" | null | undefined;
|
|
83
|
+
textAlign?: "right" | "left" | "center" | null | undefined;
|
|
84
|
+
padding?: {
|
|
85
|
+
top: number;
|
|
86
|
+
bottom: number;
|
|
87
|
+
right: number;
|
|
88
|
+
left: number;
|
|
89
|
+
} | null | undefined;
|
|
90
|
+
} | null | undefined;
|
|
91
|
+
props?: {
|
|
92
|
+
buttonBackgroundColor?: string | null | undefined;
|
|
93
|
+
buttonStyle?: "rectangle" | "pill" | "rounded" | null | undefined;
|
|
94
|
+
buttonTextColor?: string | null | undefined;
|
|
95
|
+
fullWidth?: boolean | null | undefined;
|
|
96
|
+
size?: "x-small" | "small" | "large" | "medium" | null | undefined;
|
|
97
|
+
text?: string | null | undefined;
|
|
98
|
+
url?: string | null | undefined;
|
|
99
|
+
} | null | undefined;
|
|
100
|
+
}, {
|
|
101
|
+
style?: {
|
|
102
|
+
backgroundColor?: string | null | undefined;
|
|
103
|
+
fontSize?: number | null | undefined;
|
|
104
|
+
fontFamily?: "MODERN_SANS" | "BOOK_SANS" | "ORGANIC_SANS" | "GEOMETRIC_SANS" | "HEAVY_SANS" | "ROUNDED_SANS" | "MODERN_SERIF" | "BOOK_SERIF" | "MONOSPACE" | null | undefined;
|
|
105
|
+
fontWeight?: "bold" | "normal" | null | undefined;
|
|
106
|
+
textAlign?: "right" | "left" | "center" | null | undefined;
|
|
107
|
+
padding?: {
|
|
108
|
+
top: number;
|
|
109
|
+
bottom: number;
|
|
110
|
+
right: number;
|
|
111
|
+
left: number;
|
|
112
|
+
} | null | undefined;
|
|
113
|
+
} | null | undefined;
|
|
114
|
+
props?: {
|
|
115
|
+
buttonBackgroundColor?: string | null | undefined;
|
|
116
|
+
buttonStyle?: "rectangle" | "pill" | "rounded" | null | undefined;
|
|
117
|
+
buttonTextColor?: string | null | undefined;
|
|
118
|
+
fullWidth?: boolean | null | undefined;
|
|
119
|
+
size?: "x-small" | "small" | "large" | "medium" | null | undefined;
|
|
120
|
+
text?: string | null | undefined;
|
|
121
|
+
url?: string | null | undefined;
|
|
122
|
+
} | null | undefined;
|
|
123
|
+
}>;
|
|
124
|
+
type ButtonProps = z.infer<typeof ButtonPropsSchema>;
|
|
125
|
+
declare const ButtonPropsDefaults: {
|
|
126
|
+
readonly text: "";
|
|
127
|
+
readonly url: "";
|
|
128
|
+
readonly fullWidth: false;
|
|
129
|
+
readonly size: "medium";
|
|
130
|
+
readonly buttonStyle: "rounded";
|
|
131
|
+
readonly buttonTextColor: "#FFFFFF";
|
|
132
|
+
readonly buttonBackgroundColor: "#999999";
|
|
133
|
+
};
|
|
134
|
+
declare function Button({ style, props }: ButtonProps): React.JSX.Element;
|
|
135
|
+
|
|
136
|
+
export { Button, type ButtonProps, ButtonPropsDefaults, ButtonPropsSchema };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,184 @@
|
|
|
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
|
+
Button: () => Button,
|
|
34
|
+
ButtonPropsDefaults: () => ButtonPropsDefaults,
|
|
35
|
+
ButtonPropsSchema: () => ButtonPropsSchema
|
|
36
|
+
});
|
|
37
|
+
module.exports = __toCommonJS(index_exports);
|
|
38
|
+
var import_react = __toESM(require("react"));
|
|
39
|
+
var import_zod = require("zod");
|
|
40
|
+
var FONT_FAMILY_SCHEMA = import_zod.z.enum([
|
|
41
|
+
"MODERN_SANS",
|
|
42
|
+
"BOOK_SANS",
|
|
43
|
+
"ORGANIC_SANS",
|
|
44
|
+
"GEOMETRIC_SANS",
|
|
45
|
+
"HEAVY_SANS",
|
|
46
|
+
"ROUNDED_SANS",
|
|
47
|
+
"MODERN_SERIF",
|
|
48
|
+
"BOOK_SERIF",
|
|
49
|
+
"MONOSPACE"
|
|
50
|
+
]).nullable().optional();
|
|
51
|
+
function getFontFamily(fontFamily) {
|
|
52
|
+
switch (fontFamily) {
|
|
53
|
+
case "MODERN_SANS":
|
|
54
|
+
return '"Helvetica Neue", "Arial Nova", "Nimbus Sans", Arial, sans-serif';
|
|
55
|
+
case "BOOK_SANS":
|
|
56
|
+
return 'Optima, Candara, "Noto Sans", source-sans-pro, sans-serif';
|
|
57
|
+
case "ORGANIC_SANS":
|
|
58
|
+
return 'Seravek, "Gill Sans Nova", Ubuntu, Calibri, "DejaVu Sans", source-sans-pro, sans-serif';
|
|
59
|
+
case "GEOMETRIC_SANS":
|
|
60
|
+
return 'Avenir, "Avenir Next LT Pro", Montserrat, Corbel, "URW Gothic", source-sans-pro, sans-serif';
|
|
61
|
+
case "HEAVY_SANS":
|
|
62
|
+
return 'Bahnschrift, "DIN Alternate", "Franklin Gothic Medium", "Nimbus Sans Narrow", sans-serif-condensed, sans-serif';
|
|
63
|
+
case "ROUNDED_SANS":
|
|
64
|
+
return 'ui-rounded, "Hiragino Maru Gothic ProN", Quicksand, Comfortaa, Manjari, "Arial Rounded MT Bold", Calibri, source-sans-pro, sans-serif';
|
|
65
|
+
case "MODERN_SERIF":
|
|
66
|
+
return 'Charter, "Bitstream Charter", "Sitka Text", Cambria, serif';
|
|
67
|
+
case "BOOK_SERIF":
|
|
68
|
+
return '"Iowan Old Style", "Palatino Linotype", "URW Palladio L", P052, serif';
|
|
69
|
+
case "MONOSPACE":
|
|
70
|
+
return '"Nimbus Mono PS", "Courier New", "Cutive Mono", monospace';
|
|
71
|
+
}
|
|
72
|
+
return void 0;
|
|
73
|
+
}
|
|
74
|
+
var COLOR_SCHEMA = import_zod.z.string().regex(/^#[0-9a-fA-F]{6}$/).nullable().optional();
|
|
75
|
+
var PADDING_SCHEMA = import_zod.z.object({
|
|
76
|
+
top: import_zod.z.number(),
|
|
77
|
+
bottom: import_zod.z.number(),
|
|
78
|
+
right: import_zod.z.number(),
|
|
79
|
+
left: import_zod.z.number()
|
|
80
|
+
}).optional().nullable();
|
|
81
|
+
var getPadding = (padding) => padding ? `${padding.top}px ${padding.right}px ${padding.bottom}px ${padding.left}px` : void 0;
|
|
82
|
+
var ButtonPropsSchema = import_zod.z.object({
|
|
83
|
+
style: import_zod.z.object({
|
|
84
|
+
backgroundColor: COLOR_SCHEMA,
|
|
85
|
+
fontSize: import_zod.z.number().min(0).optional().nullable(),
|
|
86
|
+
fontFamily: FONT_FAMILY_SCHEMA,
|
|
87
|
+
fontWeight: import_zod.z.enum(["bold", "normal"]).optional().nullable(),
|
|
88
|
+
textAlign: import_zod.z.enum(["left", "center", "right"]).optional().nullable(),
|
|
89
|
+
padding: PADDING_SCHEMA
|
|
90
|
+
}).optional().nullable(),
|
|
91
|
+
props: import_zod.z.object({
|
|
92
|
+
buttonBackgroundColor: COLOR_SCHEMA,
|
|
93
|
+
buttonStyle: import_zod.z.enum(["rectangle", "pill", "rounded"]).optional().nullable(),
|
|
94
|
+
buttonTextColor: COLOR_SCHEMA,
|
|
95
|
+
fullWidth: import_zod.z.boolean().optional().nullable(),
|
|
96
|
+
size: import_zod.z.enum(["x-small", "small", "large", "medium"]).optional().nullable(),
|
|
97
|
+
text: import_zod.z.string().optional().nullable(),
|
|
98
|
+
url: import_zod.z.string().optional().nullable()
|
|
99
|
+
}).optional().nullable()
|
|
100
|
+
});
|
|
101
|
+
function getRoundedCorners(props) {
|
|
102
|
+
var _a;
|
|
103
|
+
const buttonStyle = (_a = props == null ? void 0 : props.buttonStyle) != null ? _a : ButtonPropsDefaults.buttonStyle;
|
|
104
|
+
switch (buttonStyle) {
|
|
105
|
+
case "rectangle":
|
|
106
|
+
return void 0;
|
|
107
|
+
case "pill":
|
|
108
|
+
return 64;
|
|
109
|
+
case "rounded":
|
|
110
|
+
default:
|
|
111
|
+
return 4;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
function getButtonSizePadding(props) {
|
|
115
|
+
var _a;
|
|
116
|
+
const size = (_a = props == null ? void 0 : props.size) != null ? _a : ButtonPropsDefaults.size;
|
|
117
|
+
switch (size) {
|
|
118
|
+
case "x-small":
|
|
119
|
+
return [4, 8];
|
|
120
|
+
case "small":
|
|
121
|
+
return [8, 12];
|
|
122
|
+
case "large":
|
|
123
|
+
return [16, 32];
|
|
124
|
+
case "medium":
|
|
125
|
+
default:
|
|
126
|
+
return [12, 20];
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
var ButtonPropsDefaults = {
|
|
130
|
+
text: "",
|
|
131
|
+
url: "",
|
|
132
|
+
fullWidth: false,
|
|
133
|
+
size: "medium",
|
|
134
|
+
buttonStyle: "rounded",
|
|
135
|
+
buttonTextColor: "#FFFFFF",
|
|
136
|
+
buttonBackgroundColor: "#999999"
|
|
137
|
+
};
|
|
138
|
+
function Button({ style, props }) {
|
|
139
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
140
|
+
const text = (_a = props == null ? void 0 : props.text) != null ? _a : ButtonPropsDefaults.text;
|
|
141
|
+
const url = (_b = props == null ? void 0 : props.url) != null ? _b : ButtonPropsDefaults.url;
|
|
142
|
+
const fullWidth = (_c = props == null ? void 0 : props.fullWidth) != null ? _c : ButtonPropsDefaults.fullWidth;
|
|
143
|
+
const buttonTextColor = (_d = props == null ? void 0 : props.buttonTextColor) != null ? _d : ButtonPropsDefaults.buttonTextColor;
|
|
144
|
+
const buttonBackgroundColor = (_e = props == null ? void 0 : props.buttonBackgroundColor) != null ? _e : ButtonPropsDefaults.buttonBackgroundColor;
|
|
145
|
+
const padding = getButtonSizePadding(props);
|
|
146
|
+
const textRaise = padding[1] * 2 * 3 / 4;
|
|
147
|
+
const wrapperStyle = {
|
|
148
|
+
backgroundColor: (_f = style == null ? void 0 : style.backgroundColor) != null ? _f : void 0,
|
|
149
|
+
textAlign: (_g = style == null ? void 0 : style.textAlign) != null ? _g : void 0,
|
|
150
|
+
padding: getPadding(style == null ? void 0 : style.padding)
|
|
151
|
+
};
|
|
152
|
+
const linkStyle = {
|
|
153
|
+
color: buttonTextColor,
|
|
154
|
+
fontSize: (_h = style == null ? void 0 : style.fontSize) != null ? _h : 16,
|
|
155
|
+
fontFamily: getFontFamily(style == null ? void 0 : style.fontFamily),
|
|
156
|
+
fontWeight: (_i = style == null ? void 0 : style.fontWeight) != null ? _i : "bold",
|
|
157
|
+
backgroundColor: buttonBackgroundColor,
|
|
158
|
+
borderRadius: getRoundedCorners(props),
|
|
159
|
+
display: fullWidth ? "block" : "inline-block",
|
|
160
|
+
padding: `${padding[0]}px ${padding[1]}px`,
|
|
161
|
+
textDecoration: "none"
|
|
162
|
+
};
|
|
163
|
+
return /* @__PURE__ */ import_react.default.createElement("div", { style: wrapperStyle }, /* @__PURE__ */ import_react.default.createElement("a", { href: url, style: linkStyle, target: "_blank" }, /* @__PURE__ */ import_react.default.createElement(
|
|
164
|
+
"span",
|
|
165
|
+
{
|
|
166
|
+
dangerouslySetInnerHTML: {
|
|
167
|
+
__html: `<!--[if mso]><i style="letter-spacing: ${padding[1]}px;mso-font-width:-100%;mso-text-raise:${textRaise}" hidden> </i><![endif]-->`
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
), /* @__PURE__ */ import_react.default.createElement("span", null, text), /* @__PURE__ */ import_react.default.createElement(
|
|
171
|
+
"span",
|
|
172
|
+
{
|
|
173
|
+
dangerouslySetInnerHTML: {
|
|
174
|
+
__html: `<!--[if mso]><i style="letter-spacing: ${padding[1]}px;mso-font-width:-100%" hidden> </i><![endif]-->`
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
)));
|
|
178
|
+
}
|
|
179
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
180
|
+
0 && (module.exports = {
|
|
181
|
+
Button,
|
|
182
|
+
ButtonPropsDefaults,
|
|
183
|
+
ButtonPropsSchema
|
|
184
|
+
});
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
// src/index.tsx
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
var FONT_FAMILY_SCHEMA = z.enum([
|
|
5
|
+
"MODERN_SANS",
|
|
6
|
+
"BOOK_SANS",
|
|
7
|
+
"ORGANIC_SANS",
|
|
8
|
+
"GEOMETRIC_SANS",
|
|
9
|
+
"HEAVY_SANS",
|
|
10
|
+
"ROUNDED_SANS",
|
|
11
|
+
"MODERN_SERIF",
|
|
12
|
+
"BOOK_SERIF",
|
|
13
|
+
"MONOSPACE"
|
|
14
|
+
]).nullable().optional();
|
|
15
|
+
function getFontFamily(fontFamily) {
|
|
16
|
+
switch (fontFamily) {
|
|
17
|
+
case "MODERN_SANS":
|
|
18
|
+
return '"Helvetica Neue", "Arial Nova", "Nimbus Sans", Arial, sans-serif';
|
|
19
|
+
case "BOOK_SANS":
|
|
20
|
+
return 'Optima, Candara, "Noto Sans", source-sans-pro, sans-serif';
|
|
21
|
+
case "ORGANIC_SANS":
|
|
22
|
+
return 'Seravek, "Gill Sans Nova", Ubuntu, Calibri, "DejaVu Sans", source-sans-pro, sans-serif';
|
|
23
|
+
case "GEOMETRIC_SANS":
|
|
24
|
+
return 'Avenir, "Avenir Next LT Pro", Montserrat, Corbel, "URW Gothic", source-sans-pro, sans-serif';
|
|
25
|
+
case "HEAVY_SANS":
|
|
26
|
+
return 'Bahnschrift, "DIN Alternate", "Franklin Gothic Medium", "Nimbus Sans Narrow", sans-serif-condensed, sans-serif';
|
|
27
|
+
case "ROUNDED_SANS":
|
|
28
|
+
return 'ui-rounded, "Hiragino Maru Gothic ProN", Quicksand, Comfortaa, Manjari, "Arial Rounded MT Bold", Calibri, source-sans-pro, sans-serif';
|
|
29
|
+
case "MODERN_SERIF":
|
|
30
|
+
return 'Charter, "Bitstream Charter", "Sitka Text", Cambria, serif';
|
|
31
|
+
case "BOOK_SERIF":
|
|
32
|
+
return '"Iowan Old Style", "Palatino Linotype", "URW Palladio L", P052, serif';
|
|
33
|
+
case "MONOSPACE":
|
|
34
|
+
return '"Nimbus Mono PS", "Courier New", "Cutive Mono", monospace';
|
|
35
|
+
}
|
|
36
|
+
return void 0;
|
|
37
|
+
}
|
|
38
|
+
var COLOR_SCHEMA = z.string().regex(/^#[0-9a-fA-F]{6}$/).nullable().optional();
|
|
39
|
+
var PADDING_SCHEMA = z.object({
|
|
40
|
+
top: z.number(),
|
|
41
|
+
bottom: z.number(),
|
|
42
|
+
right: z.number(),
|
|
43
|
+
left: z.number()
|
|
44
|
+
}).optional().nullable();
|
|
45
|
+
var getPadding = (padding) => padding ? `${padding.top}px ${padding.right}px ${padding.bottom}px ${padding.left}px` : void 0;
|
|
46
|
+
var ButtonPropsSchema = z.object({
|
|
47
|
+
style: z.object({
|
|
48
|
+
backgroundColor: COLOR_SCHEMA,
|
|
49
|
+
fontSize: z.number().min(0).optional().nullable(),
|
|
50
|
+
fontFamily: FONT_FAMILY_SCHEMA,
|
|
51
|
+
fontWeight: z.enum(["bold", "normal"]).optional().nullable(),
|
|
52
|
+
textAlign: z.enum(["left", "center", "right"]).optional().nullable(),
|
|
53
|
+
padding: PADDING_SCHEMA
|
|
54
|
+
}).optional().nullable(),
|
|
55
|
+
props: z.object({
|
|
56
|
+
buttonBackgroundColor: COLOR_SCHEMA,
|
|
57
|
+
buttonStyle: z.enum(["rectangle", "pill", "rounded"]).optional().nullable(),
|
|
58
|
+
buttonTextColor: COLOR_SCHEMA,
|
|
59
|
+
fullWidth: z.boolean().optional().nullable(),
|
|
60
|
+
size: z.enum(["x-small", "small", "large", "medium"]).optional().nullable(),
|
|
61
|
+
text: z.string().optional().nullable(),
|
|
62
|
+
url: z.string().optional().nullable()
|
|
63
|
+
}).optional().nullable()
|
|
64
|
+
});
|
|
65
|
+
function getRoundedCorners(props) {
|
|
66
|
+
var _a;
|
|
67
|
+
const buttonStyle = (_a = props == null ? void 0 : props.buttonStyle) != null ? _a : ButtonPropsDefaults.buttonStyle;
|
|
68
|
+
switch (buttonStyle) {
|
|
69
|
+
case "rectangle":
|
|
70
|
+
return void 0;
|
|
71
|
+
case "pill":
|
|
72
|
+
return 64;
|
|
73
|
+
case "rounded":
|
|
74
|
+
default:
|
|
75
|
+
return 4;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
function getButtonSizePadding(props) {
|
|
79
|
+
var _a;
|
|
80
|
+
const size = (_a = props == null ? void 0 : props.size) != null ? _a : ButtonPropsDefaults.size;
|
|
81
|
+
switch (size) {
|
|
82
|
+
case "x-small":
|
|
83
|
+
return [4, 8];
|
|
84
|
+
case "small":
|
|
85
|
+
return [8, 12];
|
|
86
|
+
case "large":
|
|
87
|
+
return [16, 32];
|
|
88
|
+
case "medium":
|
|
89
|
+
default:
|
|
90
|
+
return [12, 20];
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
var ButtonPropsDefaults = {
|
|
94
|
+
text: "",
|
|
95
|
+
url: "",
|
|
96
|
+
fullWidth: false,
|
|
97
|
+
size: "medium",
|
|
98
|
+
buttonStyle: "rounded",
|
|
99
|
+
buttonTextColor: "#FFFFFF",
|
|
100
|
+
buttonBackgroundColor: "#999999"
|
|
101
|
+
};
|
|
102
|
+
function Button({ style, props }) {
|
|
103
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
104
|
+
const text = (_a = props == null ? void 0 : props.text) != null ? _a : ButtonPropsDefaults.text;
|
|
105
|
+
const url = (_b = props == null ? void 0 : props.url) != null ? _b : ButtonPropsDefaults.url;
|
|
106
|
+
const fullWidth = (_c = props == null ? void 0 : props.fullWidth) != null ? _c : ButtonPropsDefaults.fullWidth;
|
|
107
|
+
const buttonTextColor = (_d = props == null ? void 0 : props.buttonTextColor) != null ? _d : ButtonPropsDefaults.buttonTextColor;
|
|
108
|
+
const buttonBackgroundColor = (_e = props == null ? void 0 : props.buttonBackgroundColor) != null ? _e : ButtonPropsDefaults.buttonBackgroundColor;
|
|
109
|
+
const padding = getButtonSizePadding(props);
|
|
110
|
+
const textRaise = padding[1] * 2 * 3 / 4;
|
|
111
|
+
const wrapperStyle = {
|
|
112
|
+
backgroundColor: (_f = style == null ? void 0 : style.backgroundColor) != null ? _f : void 0,
|
|
113
|
+
textAlign: (_g = style == null ? void 0 : style.textAlign) != null ? _g : void 0,
|
|
114
|
+
padding: getPadding(style == null ? void 0 : style.padding)
|
|
115
|
+
};
|
|
116
|
+
const linkStyle = {
|
|
117
|
+
color: buttonTextColor,
|
|
118
|
+
fontSize: (_h = style == null ? void 0 : style.fontSize) != null ? _h : 16,
|
|
119
|
+
fontFamily: getFontFamily(style == null ? void 0 : style.fontFamily),
|
|
120
|
+
fontWeight: (_i = style == null ? void 0 : style.fontWeight) != null ? _i : "bold",
|
|
121
|
+
backgroundColor: buttonBackgroundColor,
|
|
122
|
+
borderRadius: getRoundedCorners(props),
|
|
123
|
+
display: fullWidth ? "block" : "inline-block",
|
|
124
|
+
padding: `${padding[0]}px ${padding[1]}px`,
|
|
125
|
+
textDecoration: "none"
|
|
126
|
+
};
|
|
127
|
+
return /* @__PURE__ */ React.createElement("div", { style: wrapperStyle }, /* @__PURE__ */ React.createElement("a", { href: url, style: linkStyle, target: "_blank" }, /* @__PURE__ */ React.createElement(
|
|
128
|
+
"span",
|
|
129
|
+
{
|
|
130
|
+
dangerouslySetInnerHTML: {
|
|
131
|
+
__html: `<!--[if mso]><i style="letter-spacing: ${padding[1]}px;mso-font-width:-100%;mso-text-raise:${textRaise}" hidden> </i><![endif]-->`
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
), /* @__PURE__ */ React.createElement("span", null, text), /* @__PURE__ */ React.createElement(
|
|
135
|
+
"span",
|
|
136
|
+
{
|
|
137
|
+
dangerouslySetInnerHTML: {
|
|
138
|
+
__html: `<!--[if mso]><i style="letter-spacing: ${padding[1]}px;mso-font-width:-100%" hidden> </i><![endif]-->`
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
)));
|
|
142
|
+
}
|
|
143
|
+
export {
|
|
144
|
+
Button,
|
|
145
|
+
ButtonPropsDefaults,
|
|
146
|
+
ButtonPropsSchema
|
|
147
|
+
};
|