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