@csg-org/block-container 0.0.3-alpha.3 → 0.0.9
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 +77 -0
- package/dist/index.d.ts +77 -0
- package/dist/index.js +78 -0
- package/dist/index.mjs +42 -0
- package/package.json +1 -1
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
|
|
4
|
+
declare const ContainerPropsSchema: z.ZodObject<{
|
|
5
|
+
style: z.ZodNullable<z.ZodOptional<z.ZodObject<{
|
|
6
|
+
backgroundColor: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
7
|
+
borderColor: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
8
|
+
borderRadius: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
|
|
9
|
+
padding: z.ZodNullable<z.ZodOptional<z.ZodObject<{
|
|
10
|
+
top: z.ZodNumber;
|
|
11
|
+
bottom: z.ZodNumber;
|
|
12
|
+
right: z.ZodNumber;
|
|
13
|
+
left: z.ZodNumber;
|
|
14
|
+
}, "strip", z.ZodTypeAny, {
|
|
15
|
+
top: number;
|
|
16
|
+
bottom: number;
|
|
17
|
+
right: number;
|
|
18
|
+
left: number;
|
|
19
|
+
}, {
|
|
20
|
+
top: number;
|
|
21
|
+
bottom: number;
|
|
22
|
+
right: number;
|
|
23
|
+
left: number;
|
|
24
|
+
}>>>;
|
|
25
|
+
}, "strip", z.ZodTypeAny, {
|
|
26
|
+
backgroundColor?: string | null | undefined;
|
|
27
|
+
borderColor?: string | null | undefined;
|
|
28
|
+
borderRadius?: number | null | undefined;
|
|
29
|
+
padding?: {
|
|
30
|
+
top: number;
|
|
31
|
+
bottom: number;
|
|
32
|
+
right: number;
|
|
33
|
+
left: number;
|
|
34
|
+
} | null | undefined;
|
|
35
|
+
}, {
|
|
36
|
+
backgroundColor?: string | null | undefined;
|
|
37
|
+
borderColor?: string | null | undefined;
|
|
38
|
+
borderRadius?: number | null | undefined;
|
|
39
|
+
padding?: {
|
|
40
|
+
top: number;
|
|
41
|
+
bottom: number;
|
|
42
|
+
right: number;
|
|
43
|
+
left: number;
|
|
44
|
+
} | null | undefined;
|
|
45
|
+
}>>>;
|
|
46
|
+
}, "strip", z.ZodTypeAny, {
|
|
47
|
+
style?: {
|
|
48
|
+
backgroundColor?: string | null | undefined;
|
|
49
|
+
borderColor?: string | null | undefined;
|
|
50
|
+
borderRadius?: number | null | undefined;
|
|
51
|
+
padding?: {
|
|
52
|
+
top: number;
|
|
53
|
+
bottom: number;
|
|
54
|
+
right: number;
|
|
55
|
+
left: number;
|
|
56
|
+
} | null | undefined;
|
|
57
|
+
} | null | undefined;
|
|
58
|
+
}, {
|
|
59
|
+
style?: {
|
|
60
|
+
backgroundColor?: string | null | undefined;
|
|
61
|
+
borderColor?: string | null | undefined;
|
|
62
|
+
borderRadius?: number | null | undefined;
|
|
63
|
+
padding?: {
|
|
64
|
+
top: number;
|
|
65
|
+
bottom: number;
|
|
66
|
+
right: number;
|
|
67
|
+
left: number;
|
|
68
|
+
} | null | undefined;
|
|
69
|
+
} | null | undefined;
|
|
70
|
+
}>;
|
|
71
|
+
type ContainerProps = {
|
|
72
|
+
style?: z.infer<typeof ContainerPropsSchema>['style'];
|
|
73
|
+
children?: JSX.Element | JSX.Element[] | null;
|
|
74
|
+
};
|
|
75
|
+
declare function Container({ style, children }: ContainerProps): React.JSX.Element;
|
|
76
|
+
|
|
77
|
+
export { Container, type ContainerProps, ContainerPropsSchema };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
|
|
4
|
+
declare const ContainerPropsSchema: z.ZodObject<{
|
|
5
|
+
style: z.ZodNullable<z.ZodOptional<z.ZodObject<{
|
|
6
|
+
backgroundColor: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
7
|
+
borderColor: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
8
|
+
borderRadius: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
|
|
9
|
+
padding: z.ZodNullable<z.ZodOptional<z.ZodObject<{
|
|
10
|
+
top: z.ZodNumber;
|
|
11
|
+
bottom: z.ZodNumber;
|
|
12
|
+
right: z.ZodNumber;
|
|
13
|
+
left: z.ZodNumber;
|
|
14
|
+
}, "strip", z.ZodTypeAny, {
|
|
15
|
+
top: number;
|
|
16
|
+
bottom: number;
|
|
17
|
+
right: number;
|
|
18
|
+
left: number;
|
|
19
|
+
}, {
|
|
20
|
+
top: number;
|
|
21
|
+
bottom: number;
|
|
22
|
+
right: number;
|
|
23
|
+
left: number;
|
|
24
|
+
}>>>;
|
|
25
|
+
}, "strip", z.ZodTypeAny, {
|
|
26
|
+
backgroundColor?: string | null | undefined;
|
|
27
|
+
borderColor?: string | null | undefined;
|
|
28
|
+
borderRadius?: number | null | undefined;
|
|
29
|
+
padding?: {
|
|
30
|
+
top: number;
|
|
31
|
+
bottom: number;
|
|
32
|
+
right: number;
|
|
33
|
+
left: number;
|
|
34
|
+
} | null | undefined;
|
|
35
|
+
}, {
|
|
36
|
+
backgroundColor?: string | null | undefined;
|
|
37
|
+
borderColor?: string | null | undefined;
|
|
38
|
+
borderRadius?: number | null | undefined;
|
|
39
|
+
padding?: {
|
|
40
|
+
top: number;
|
|
41
|
+
bottom: number;
|
|
42
|
+
right: number;
|
|
43
|
+
left: number;
|
|
44
|
+
} | null | undefined;
|
|
45
|
+
}>>>;
|
|
46
|
+
}, "strip", z.ZodTypeAny, {
|
|
47
|
+
style?: {
|
|
48
|
+
backgroundColor?: string | null | undefined;
|
|
49
|
+
borderColor?: string | null | undefined;
|
|
50
|
+
borderRadius?: number | null | undefined;
|
|
51
|
+
padding?: {
|
|
52
|
+
top: number;
|
|
53
|
+
bottom: number;
|
|
54
|
+
right: number;
|
|
55
|
+
left: number;
|
|
56
|
+
} | null | undefined;
|
|
57
|
+
} | null | undefined;
|
|
58
|
+
}, {
|
|
59
|
+
style?: {
|
|
60
|
+
backgroundColor?: string | null | undefined;
|
|
61
|
+
borderColor?: string | null | undefined;
|
|
62
|
+
borderRadius?: number | null | undefined;
|
|
63
|
+
padding?: {
|
|
64
|
+
top: number;
|
|
65
|
+
bottom: number;
|
|
66
|
+
right: number;
|
|
67
|
+
left: number;
|
|
68
|
+
} | null | undefined;
|
|
69
|
+
} | null | undefined;
|
|
70
|
+
}>;
|
|
71
|
+
type ContainerProps = {
|
|
72
|
+
style?: z.infer<typeof ContainerPropsSchema>['style'];
|
|
73
|
+
children?: JSX.Element | JSX.Element[] | null;
|
|
74
|
+
};
|
|
75
|
+
declare function Container({ style, children }: ContainerProps): React.JSX.Element;
|
|
76
|
+
|
|
77
|
+
export { Container, type ContainerProps, ContainerPropsSchema };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
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
|
+
Container: () => Container,
|
|
34
|
+
ContainerPropsSchema: () => ContainerPropsSchema
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(index_exports);
|
|
37
|
+
var import_react = __toESM(require("react"));
|
|
38
|
+
var import_zod = require("zod");
|
|
39
|
+
var COLOR_SCHEMA = import_zod.z.string().regex(/^#[0-9a-fA-F]{6}$/).nullable().optional();
|
|
40
|
+
var PADDING_SCHEMA = import_zod.z.object({
|
|
41
|
+
top: import_zod.z.number(),
|
|
42
|
+
bottom: import_zod.z.number(),
|
|
43
|
+
right: import_zod.z.number(),
|
|
44
|
+
left: import_zod.z.number()
|
|
45
|
+
}).optional().nullable();
|
|
46
|
+
var getPadding = (padding) => padding ? `${padding.top}px ${padding.right}px ${padding.bottom}px ${padding.left}px` : void 0;
|
|
47
|
+
var ContainerPropsSchema = import_zod.z.object({
|
|
48
|
+
style: import_zod.z.object({
|
|
49
|
+
backgroundColor: COLOR_SCHEMA,
|
|
50
|
+
borderColor: COLOR_SCHEMA,
|
|
51
|
+
borderRadius: import_zod.z.number().optional().nullable(),
|
|
52
|
+
padding: PADDING_SCHEMA
|
|
53
|
+
}).optional().nullable()
|
|
54
|
+
});
|
|
55
|
+
function getBorder(style) {
|
|
56
|
+
if (!style || !style.borderColor) {
|
|
57
|
+
return void 0;
|
|
58
|
+
}
|
|
59
|
+
return `1px solid ${style.borderColor}`;
|
|
60
|
+
}
|
|
61
|
+
function Container({ style, children }) {
|
|
62
|
+
var _a, _b;
|
|
63
|
+
const wStyle = {
|
|
64
|
+
backgroundColor: (_a = style == null ? void 0 : style.backgroundColor) != null ? _a : void 0,
|
|
65
|
+
border: getBorder(style),
|
|
66
|
+
borderRadius: (_b = style == null ? void 0 : style.borderRadius) != null ? _b : void 0,
|
|
67
|
+
padding: getPadding(style == null ? void 0 : style.padding)
|
|
68
|
+
};
|
|
69
|
+
if (!children) {
|
|
70
|
+
return /* @__PURE__ */ import_react.default.createElement("div", { style: wStyle });
|
|
71
|
+
}
|
|
72
|
+
return /* @__PURE__ */ import_react.default.createElement("div", { style: wStyle }, children);
|
|
73
|
+
}
|
|
74
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
75
|
+
0 && (module.exports = {
|
|
76
|
+
Container,
|
|
77
|
+
ContainerPropsSchema
|
|
78
|
+
});
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
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 ContainerPropsSchema = z.object({
|
|
13
|
+
style: z.object({
|
|
14
|
+
backgroundColor: COLOR_SCHEMA,
|
|
15
|
+
borderColor: COLOR_SCHEMA,
|
|
16
|
+
borderRadius: z.number().optional().nullable(),
|
|
17
|
+
padding: PADDING_SCHEMA
|
|
18
|
+
}).optional().nullable()
|
|
19
|
+
});
|
|
20
|
+
function getBorder(style) {
|
|
21
|
+
if (!style || !style.borderColor) {
|
|
22
|
+
return void 0;
|
|
23
|
+
}
|
|
24
|
+
return `1px solid ${style.borderColor}`;
|
|
25
|
+
}
|
|
26
|
+
function Container({ style, children }) {
|
|
27
|
+
var _a, _b;
|
|
28
|
+
const wStyle = {
|
|
29
|
+
backgroundColor: (_a = style == null ? void 0 : style.backgroundColor) != null ? _a : void 0,
|
|
30
|
+
border: getBorder(style),
|
|
31
|
+
borderRadius: (_b = style == null ? void 0 : style.borderRadius) != null ? _b : void 0,
|
|
32
|
+
padding: getPadding(style == null ? void 0 : style.padding)
|
|
33
|
+
};
|
|
34
|
+
if (!children) {
|
|
35
|
+
return /* @__PURE__ */ React.createElement("div", { style: wStyle });
|
|
36
|
+
}
|
|
37
|
+
return /* @__PURE__ */ React.createElement("div", { style: wStyle }, children);
|
|
38
|
+
}
|
|
39
|
+
export {
|
|
40
|
+
Container,
|
|
41
|
+
ContainerPropsSchema
|
|
42
|
+
};
|