react-simple-initials 1.0.0

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.js ADDED
@@ -0,0 +1,75 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/index.jsx
30
+ var index_exports = {};
31
+ __export(index_exports, {
32
+ default: () => InitialsAvatar
33
+ });
34
+ module.exports = __toCommonJS(index_exports);
35
+ var import_react = __toESM(require("react"));
36
+ var FUNDOS = [
37
+ "#EF4444",
38
+ "#F97316",
39
+ "#EAB308",
40
+ "#22C55E",
41
+ "#3B82F6",
42
+ "#A855F7",
43
+ "#EC4899",
44
+ "#64748B"
45
+ ];
46
+ function InitialsAvatar({
47
+ nome = "?",
48
+ tamanho = 40,
49
+ fonte = "inherit",
50
+ corTexto = "#FFFFFF"
51
+ }) {
52
+ const tamanhoNome = nome.length;
53
+ const FundoEscolhido = FUNDOS[tamanhoNome % FUNDOS.length];
54
+ const inicial = nome.trim().charAt(0).toUpperCase();
55
+ return /* @__PURE__ */ import_react.default.createElement(
56
+ "div",
57
+ {
58
+ style: {
59
+ width: tamanho,
60
+ height: tamanho,
61
+ backgroundColor: FundoEscolhido,
62
+ color: corTexto,
63
+ fontFamily: fonte,
64
+ display: "flex",
65
+ alignItems: "center",
66
+ justifyContent: "center",
67
+ borderRadius: "50%",
68
+ fontSize: tamanho / 2.2,
69
+ fontWeight: "bold",
70
+ userSelect: "none"
71
+ }
72
+ },
73
+ inicial
74
+ );
75
+ }
package/dist/index.mjs ADDED
@@ -0,0 +1,45 @@
1
+ // src/index.jsx
2
+ import React from "react";
3
+ var FUNDOS = [
4
+ "#EF4444",
5
+ "#F97316",
6
+ "#EAB308",
7
+ "#22C55E",
8
+ "#3B82F6",
9
+ "#A855F7",
10
+ "#EC4899",
11
+ "#64748B"
12
+ ];
13
+ function InitialsAvatar({
14
+ nome = "?",
15
+ tamanho = 40,
16
+ fonte = "inherit",
17
+ corTexto = "#FFFFFF"
18
+ }) {
19
+ const tamanhoNome = nome.length;
20
+ const FundoEscolhido = FUNDOS[tamanhoNome % FUNDOS.length];
21
+ const inicial = nome.trim().charAt(0).toUpperCase();
22
+ return /* @__PURE__ */ React.createElement(
23
+ "div",
24
+ {
25
+ style: {
26
+ width: tamanho,
27
+ height: tamanho,
28
+ backgroundColor: FundoEscolhido,
29
+ color: corTexto,
30
+ fontFamily: fonte,
31
+ display: "flex",
32
+ alignItems: "center",
33
+ justifyContent: "center",
34
+ borderRadius: "50%",
35
+ fontSize: tamanho / 2.2,
36
+ fontWeight: "bold",
37
+ userSelect: "none"
38
+ }
39
+ },
40
+ inicial
41
+ );
42
+ }
43
+ export {
44
+ InitialsAvatar as default
45
+ };
package/package.json ADDED
@@ -0,0 +1,25 @@
1
+ {
2
+ "name": "react-simple-initials",
3
+ "version": "1.0.0",
4
+ "description": "Um componente React minimalista para avatares com iniciais do nome.",
5
+ "main": "dist/index.js",
6
+ "module": "dist/index.mjs",
7
+ "scripts": {
8
+ "build": "tsup src/index.jsx --format cjs,esm"
9
+ },
10
+ "keywords": [
11
+ "react",
12
+ "avatar",
13
+ "initials",
14
+ "ui"
15
+ ],
16
+ "author": "WinstonAjr",
17
+ "license": "MIT",
18
+ "peerDependencies": {
19
+ "react": ">=16.8.0"
20
+ },
21
+ "devDependencies": {
22
+ "tsup": "^8.5.1",
23
+ "typescript": "^5.9.3"
24
+ }
25
+ }
package/src/index.jsx ADDED
@@ -0,0 +1,44 @@
1
+ import React from "react";
2
+
3
+ const FUNDOS = [
4
+ "#EF4444",
5
+ "#F97316",
6
+ "#EAB308",
7
+ "#22C55E",
8
+ "#3B82F6",
9
+ "#A855F7",
10
+ "#EC4899",
11
+ "#64748B",
12
+ ];
13
+
14
+ export default function InitialsAvatar({
15
+ nome = "?",
16
+ tamanho = 40,
17
+ fonte = "inherit",
18
+ corTexto = "#FFFFFF",
19
+ }) {
20
+ const tamanhoNome = nome.length;
21
+ const FundoEscolhido = FUNDOS[tamanhoNome % FUNDOS.length];
22
+ const inicial = nome.trim().charAt(0).toUpperCase();
23
+
24
+ return (
25
+ <div
26
+ style={{
27
+ width: tamanho,
28
+ height: tamanho,
29
+ backgroundColor: FundoEscolhido,
30
+ color: corTexto,
31
+ fontFamily: fonte,
32
+ display: "flex",
33
+ alignItems: "center",
34
+ justifyContent: "center",
35
+ borderRadius: "50%",
36
+ fontSize: tamanho / 2.2,
37
+ fontWeight: "bold",
38
+ userSelect: "none",
39
+ }}
40
+ >
41
+ {inicial}
42
+ </div>
43
+ );
44
+ }