@csg-org/block-image 0.0.6-alpha.3 → 0.0.6-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.
@@ -0,0 +1,107 @@
1
+ import React from 'react';
2
+ import { z } from 'zod';
3
+
4
+ declare const ImagePropsSchema: z.ZodObject<{
5
+ style: z.ZodNullable<z.ZodOptional<z.ZodObject<{
6
+ padding: z.ZodNullable<z.ZodOptional<z.ZodObject<{
7
+ top: z.ZodNumber;
8
+ bottom: z.ZodNumber;
9
+ right: z.ZodNumber;
10
+ left: z.ZodNumber;
11
+ }, "strip", z.ZodTypeAny, {
12
+ top: number;
13
+ bottom: number;
14
+ right: number;
15
+ left: number;
16
+ }, {
17
+ top: number;
18
+ bottom: number;
19
+ right: number;
20
+ left: number;
21
+ }>>>;
22
+ backgroundColor: z.ZodNullable<z.ZodOptional<z.ZodString>>;
23
+ textAlign: z.ZodNullable<z.ZodOptional<z.ZodEnum<["center", "left", "right"]>>>;
24
+ }, "strip", z.ZodTypeAny, {
25
+ padding?: {
26
+ top: number;
27
+ bottom: number;
28
+ right: number;
29
+ left: number;
30
+ } | null | undefined;
31
+ backgroundColor?: string | null | undefined;
32
+ textAlign?: "right" | "left" | "center" | null | undefined;
33
+ }, {
34
+ padding?: {
35
+ top: number;
36
+ bottom: number;
37
+ right: number;
38
+ left: number;
39
+ } | null | undefined;
40
+ backgroundColor?: string | null | undefined;
41
+ textAlign?: "right" | "left" | "center" | null | undefined;
42
+ }>>>;
43
+ props: z.ZodNullable<z.ZodOptional<z.ZodObject<{
44
+ width: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
45
+ height: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
46
+ url: z.ZodNullable<z.ZodOptional<z.ZodString>>;
47
+ alt: z.ZodNullable<z.ZodOptional<z.ZodString>>;
48
+ linkHref: z.ZodNullable<z.ZodOptional<z.ZodString>>;
49
+ contentAlignment: z.ZodNullable<z.ZodOptional<z.ZodEnum<["top", "middle", "bottom"]>>>;
50
+ }, "strip", z.ZodTypeAny, {
51
+ width?: number | null | undefined;
52
+ height?: number | null | undefined;
53
+ url?: string | null | undefined;
54
+ alt?: string | null | undefined;
55
+ linkHref?: string | null | undefined;
56
+ contentAlignment?: "top" | "bottom" | "middle" | null | undefined;
57
+ }, {
58
+ width?: number | null | undefined;
59
+ height?: number | null | undefined;
60
+ url?: string | null | undefined;
61
+ alt?: string | null | undefined;
62
+ linkHref?: string | null | undefined;
63
+ contentAlignment?: "top" | "bottom" | "middle" | null | undefined;
64
+ }>>>;
65
+ }, "strip", z.ZodTypeAny, {
66
+ style?: {
67
+ padding?: {
68
+ top: number;
69
+ bottom: number;
70
+ right: number;
71
+ left: number;
72
+ } | null | undefined;
73
+ backgroundColor?: string | null | undefined;
74
+ textAlign?: "right" | "left" | "center" | null | undefined;
75
+ } | null | undefined;
76
+ props?: {
77
+ width?: number | null | undefined;
78
+ height?: number | null | undefined;
79
+ url?: string | null | undefined;
80
+ alt?: string | null | undefined;
81
+ linkHref?: string | null | undefined;
82
+ contentAlignment?: "top" | "bottom" | "middle" | null | undefined;
83
+ } | null | undefined;
84
+ }, {
85
+ style?: {
86
+ padding?: {
87
+ top: number;
88
+ bottom: number;
89
+ right: number;
90
+ left: number;
91
+ } | null | undefined;
92
+ backgroundColor?: string | null | undefined;
93
+ textAlign?: "right" | "left" | "center" | null | undefined;
94
+ } | null | undefined;
95
+ props?: {
96
+ width?: number | null | undefined;
97
+ height?: number | null | undefined;
98
+ url?: string | null | undefined;
99
+ alt?: string | null | undefined;
100
+ linkHref?: string | null | undefined;
101
+ contentAlignment?: "top" | "bottom" | "middle" | null | undefined;
102
+ } | null | undefined;
103
+ }>;
104
+ type ImageProps = z.infer<typeof ImagePropsSchema>;
105
+ declare function Image({ style, props }: ImageProps): React.JSX.Element;
106
+
107
+ export { Image, type ImageProps, ImagePropsSchema };
@@ -0,0 +1,107 @@
1
+ import React from 'react';
2
+ import { z } from 'zod';
3
+
4
+ declare const ImagePropsSchema: z.ZodObject<{
5
+ style: z.ZodNullable<z.ZodOptional<z.ZodObject<{
6
+ padding: z.ZodNullable<z.ZodOptional<z.ZodObject<{
7
+ top: z.ZodNumber;
8
+ bottom: z.ZodNumber;
9
+ right: z.ZodNumber;
10
+ left: z.ZodNumber;
11
+ }, "strip", z.ZodTypeAny, {
12
+ top: number;
13
+ bottom: number;
14
+ right: number;
15
+ left: number;
16
+ }, {
17
+ top: number;
18
+ bottom: number;
19
+ right: number;
20
+ left: number;
21
+ }>>>;
22
+ backgroundColor: z.ZodNullable<z.ZodOptional<z.ZodString>>;
23
+ textAlign: z.ZodNullable<z.ZodOptional<z.ZodEnum<["center", "left", "right"]>>>;
24
+ }, "strip", z.ZodTypeAny, {
25
+ padding?: {
26
+ top: number;
27
+ bottom: number;
28
+ right: number;
29
+ left: number;
30
+ } | null | undefined;
31
+ backgroundColor?: string | null | undefined;
32
+ textAlign?: "right" | "left" | "center" | null | undefined;
33
+ }, {
34
+ padding?: {
35
+ top: number;
36
+ bottom: number;
37
+ right: number;
38
+ left: number;
39
+ } | null | undefined;
40
+ backgroundColor?: string | null | undefined;
41
+ textAlign?: "right" | "left" | "center" | null | undefined;
42
+ }>>>;
43
+ props: z.ZodNullable<z.ZodOptional<z.ZodObject<{
44
+ width: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
45
+ height: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
46
+ url: z.ZodNullable<z.ZodOptional<z.ZodString>>;
47
+ alt: z.ZodNullable<z.ZodOptional<z.ZodString>>;
48
+ linkHref: z.ZodNullable<z.ZodOptional<z.ZodString>>;
49
+ contentAlignment: z.ZodNullable<z.ZodOptional<z.ZodEnum<["top", "middle", "bottom"]>>>;
50
+ }, "strip", z.ZodTypeAny, {
51
+ width?: number | null | undefined;
52
+ height?: number | null | undefined;
53
+ url?: string | null | undefined;
54
+ alt?: string | null | undefined;
55
+ linkHref?: string | null | undefined;
56
+ contentAlignment?: "top" | "bottom" | "middle" | null | undefined;
57
+ }, {
58
+ width?: number | null | undefined;
59
+ height?: number | null | undefined;
60
+ url?: string | null | undefined;
61
+ alt?: string | null | undefined;
62
+ linkHref?: string | null | undefined;
63
+ contentAlignment?: "top" | "bottom" | "middle" | null | undefined;
64
+ }>>>;
65
+ }, "strip", z.ZodTypeAny, {
66
+ style?: {
67
+ padding?: {
68
+ top: number;
69
+ bottom: number;
70
+ right: number;
71
+ left: number;
72
+ } | null | undefined;
73
+ backgroundColor?: string | null | undefined;
74
+ textAlign?: "right" | "left" | "center" | null | undefined;
75
+ } | null | undefined;
76
+ props?: {
77
+ width?: number | null | undefined;
78
+ height?: number | null | undefined;
79
+ url?: string | null | undefined;
80
+ alt?: string | null | undefined;
81
+ linkHref?: string | null | undefined;
82
+ contentAlignment?: "top" | "bottom" | "middle" | null | undefined;
83
+ } | null | undefined;
84
+ }, {
85
+ style?: {
86
+ padding?: {
87
+ top: number;
88
+ bottom: number;
89
+ right: number;
90
+ left: number;
91
+ } | null | undefined;
92
+ backgroundColor?: string | null | undefined;
93
+ textAlign?: "right" | "left" | "center" | null | undefined;
94
+ } | null | undefined;
95
+ props?: {
96
+ width?: number | null | undefined;
97
+ height?: number | null | undefined;
98
+ url?: string | null | undefined;
99
+ alt?: string | null | undefined;
100
+ linkHref?: string | null | undefined;
101
+ contentAlignment?: "top" | "bottom" | "middle" | null | undefined;
102
+ } | null | undefined;
103
+ }>;
104
+ type ImageProps = z.infer<typeof ImagePropsSchema>;
105
+ declare function Image({ style, props }: ImageProps): React.JSX.Element;
106
+
107
+ export { Image, type ImageProps, ImagePropsSchema };
package/dist/index.js ADDED
@@ -0,0 +1,99 @@
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
+ Image: () => Image,
34
+ ImagePropsSchema: () => ImagePropsSchema
35
+ });
36
+ module.exports = __toCommonJS(index_exports);
37
+ var import_react = __toESM(require("react"));
38
+ var import_zod = require("zod");
39
+ var PADDING_SCHEMA = import_zod.z.object({
40
+ top: import_zod.z.number(),
41
+ bottom: import_zod.z.number(),
42
+ right: import_zod.z.number(),
43
+ left: import_zod.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 ImagePropsSchema = import_zod.z.object({
47
+ style: import_zod.z.object({
48
+ padding: PADDING_SCHEMA,
49
+ backgroundColor: import_zod.z.string().regex(/^#[0-9a-fA-F]{6}$/).optional().nullable(),
50
+ textAlign: import_zod.z.enum(["center", "left", "right"]).optional().nullable()
51
+ }).optional().nullable(),
52
+ props: import_zod.z.object({
53
+ width: import_zod.z.number().optional().nullable(),
54
+ height: import_zod.z.number().optional().nullable(),
55
+ url: import_zod.z.string().optional().nullable(),
56
+ alt: import_zod.z.string().optional().nullable(),
57
+ linkHref: import_zod.z.string().optional().nullable(),
58
+ contentAlignment: import_zod.z.enum(["top", "middle", "bottom"]).optional().nullable()
59
+ }).optional().nullable()
60
+ });
61
+ function Image({ style, props }) {
62
+ var _a, _b, _c, _d, _e, _f, _g, _h;
63
+ const sectionStyle = {
64
+ padding: getPadding(style == null ? void 0 : style.padding),
65
+ backgroundColor: (_a = style == null ? void 0 : style.backgroundColor) != null ? _a : void 0,
66
+ textAlign: (_b = style == null ? void 0 : style.textAlign) != null ? _b : void 0
67
+ };
68
+ const linkHref = (_c = props == null ? void 0 : props.linkHref) != null ? _c : null;
69
+ const width = (_d = props == null ? void 0 : props.width) != null ? _d : void 0;
70
+ const height = (_e = props == null ? void 0 : props.height) != null ? _e : void 0;
71
+ const imageElement = /* @__PURE__ */ import_react.default.createElement(
72
+ "img",
73
+ {
74
+ alt: (_f = props == null ? void 0 : props.alt) != null ? _f : "",
75
+ src: (_g = props == null ? void 0 : props.url) != null ? _g : "",
76
+ width,
77
+ height,
78
+ style: {
79
+ width,
80
+ height,
81
+ outline: "none",
82
+ border: "none",
83
+ textDecoration: "none",
84
+ verticalAlign: (_h = props == null ? void 0 : props.contentAlignment) != null ? _h : "middle",
85
+ display: "inline-block",
86
+ maxWidth: "100%"
87
+ }
88
+ }
89
+ );
90
+ if (!linkHref) {
91
+ return /* @__PURE__ */ import_react.default.createElement("div", { style: sectionStyle }, imageElement);
92
+ }
93
+ return /* @__PURE__ */ import_react.default.createElement("div", { style: sectionStyle }, /* @__PURE__ */ import_react.default.createElement("a", { href: linkHref, style: { textDecoration: "none" }, target: "_blank" }, imageElement));
94
+ }
95
+ // Annotate the CommonJS export names for ESM import in node:
96
+ 0 && (module.exports = {
97
+ Image,
98
+ ImagePropsSchema
99
+ });
package/dist/index.mjs ADDED
@@ -0,0 +1,63 @@
1
+ // src/index.tsx
2
+ import React from "react";
3
+ import { z } from "zod";
4
+ var PADDING_SCHEMA = z.object({
5
+ top: z.number(),
6
+ bottom: z.number(),
7
+ right: z.number(),
8
+ left: z.number()
9
+ }).optional().nullable();
10
+ var getPadding = (padding) => padding ? `${padding.top}px ${padding.right}px ${padding.bottom}px ${padding.left}px` : void 0;
11
+ var ImagePropsSchema = z.object({
12
+ style: z.object({
13
+ padding: PADDING_SCHEMA,
14
+ backgroundColor: z.string().regex(/^#[0-9a-fA-F]{6}$/).optional().nullable(),
15
+ textAlign: z.enum(["center", "left", "right"]).optional().nullable()
16
+ }).optional().nullable(),
17
+ props: z.object({
18
+ width: z.number().optional().nullable(),
19
+ height: z.number().optional().nullable(),
20
+ url: z.string().optional().nullable(),
21
+ alt: z.string().optional().nullable(),
22
+ linkHref: z.string().optional().nullable(),
23
+ contentAlignment: z.enum(["top", "middle", "bottom"]).optional().nullable()
24
+ }).optional().nullable()
25
+ });
26
+ function Image({ style, props }) {
27
+ var _a, _b, _c, _d, _e, _f, _g, _h;
28
+ const sectionStyle = {
29
+ padding: getPadding(style == null ? void 0 : style.padding),
30
+ backgroundColor: (_a = style == null ? void 0 : style.backgroundColor) != null ? _a : void 0,
31
+ textAlign: (_b = style == null ? void 0 : style.textAlign) != null ? _b : void 0
32
+ };
33
+ const linkHref = (_c = props == null ? void 0 : props.linkHref) != null ? _c : null;
34
+ const width = (_d = props == null ? void 0 : props.width) != null ? _d : void 0;
35
+ const height = (_e = props == null ? void 0 : props.height) != null ? _e : void 0;
36
+ const imageElement = /* @__PURE__ */ React.createElement(
37
+ "img",
38
+ {
39
+ alt: (_f = props == null ? void 0 : props.alt) != null ? _f : "",
40
+ src: (_g = props == null ? void 0 : props.url) != null ? _g : "",
41
+ width,
42
+ height,
43
+ style: {
44
+ width,
45
+ height,
46
+ outline: "none",
47
+ border: "none",
48
+ textDecoration: "none",
49
+ verticalAlign: (_h = props == null ? void 0 : props.contentAlignment) != null ? _h : "middle",
50
+ display: "inline-block",
51
+ maxWidth: "100%"
52
+ }
53
+ }
54
+ );
55
+ if (!linkHref) {
56
+ return /* @__PURE__ */ React.createElement("div", { style: sectionStyle }, imageElement);
57
+ }
58
+ return /* @__PURE__ */ React.createElement("div", { style: sectionStyle }, /* @__PURE__ */ React.createElement("a", { href: linkHref, style: { textDecoration: "none" }, target: "_blank" }, imageElement));
59
+ }
60
+ export {
61
+ Image,
62
+ ImagePropsSchema
63
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@csg-org/block-image",
3
- "version": "0.0.6-alpha.3",
3
+ "version": "0.0.6-alpha.4",
4
4
  "description": "@csg-org/document compatible Image component",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",