framepexls-ui-lib 0.2.0 → 0.2.2

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.
@@ -1,7 +1,9 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
 
3
3
  type Props = {
4
- sources: Array<string | null | undefined>;
4
+ sources?: Array<string | null | undefined>;
5
+ images?: Array<string | null | undefined>;
6
+ labels?: Array<string | null | undefined>;
5
7
  max?: number;
6
8
  size?: number;
7
9
  overlap?: boolean;
@@ -9,6 +11,6 @@ type Props = {
9
11
  className?: string;
10
12
  showCounter?: boolean;
11
13
  };
12
- declare function AvatarGroup({ sources, max, size, overlap, radiusClass, className, showCounter, }: Props): react_jsx_runtime.JSX.Element;
14
+ declare function AvatarGroup({ sources, images, labels, max, size, overlap, radiusClass, className, showCounter, }: Props): react_jsx_runtime.JSX.Element;
13
15
 
14
16
  export { AvatarGroup as default };
@@ -1,7 +1,9 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
 
3
3
  type Props = {
4
- sources: Array<string | null | undefined>;
4
+ sources?: Array<string | null | undefined>;
5
+ images?: Array<string | null | undefined>;
6
+ labels?: Array<string | null | undefined>;
5
7
  max?: number;
6
8
  size?: number;
7
9
  overlap?: boolean;
@@ -9,6 +11,6 @@ type Props = {
9
11
  className?: string;
10
12
  showCounter?: boolean;
11
13
  };
12
- declare function AvatarGroup({ sources, max, size, overlap, radiusClass, className, showCounter, }: Props): react_jsx_runtime.JSX.Element;
14
+ declare function AvatarGroup({ sources, images, labels, max, size, overlap, radiusClass, className, showCounter, }: Props): react_jsx_runtime.JSX.Element;
13
15
 
14
16
  export { AvatarGroup as default };
@@ -36,6 +36,8 @@ var import_jsx_runtime = require("react/jsx-runtime");
36
36
  var import_AvatarSquare = __toESM(require("./AvatarSquare"));
37
37
  function AvatarGroup({
38
38
  sources,
39
+ images,
40
+ labels,
39
41
  max = 3,
40
42
  size = 28,
41
43
  overlap = true,
@@ -43,16 +45,20 @@ function AvatarGroup({
43
45
  className = "",
44
46
  showCounter = true
45
47
  }) {
46
- const imgs = (sources || []).filter(Boolean);
47
- const visible = imgs.slice(0, Math.max(0, max));
48
- const rest = Math.max(0, imgs.length - visible.length);
48
+ var _a;
49
+ const list = (_a = sources != null ? sources : images) != null ? _a : [];
50
+ const visible = list.slice(0, Math.max(0, max));
51
+ const rest = Math.max(0, list.length - visible.length);
49
52
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
50
53
  "div",
51
54
  {
52
55
  className: ["flex items-center", className].join(" "),
53
56
  "aria-label": "Grupo de avatares",
54
57
  children: [
55
- visible.map((src, i) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: i > 0 && overlap ? "-ml-2" : void 0, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_AvatarSquare.default, { src, size, radiusClass }) }, `${src}-${i}`)),
58
+ visible.map((src, i) => {
59
+ var _a2;
60
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: i > 0 && overlap ? "-ml-2" : void 0, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_AvatarSquare.default, { src: src != null ? src : void 0, size, radiusClass, alt: (_a2 = labels == null ? void 0 : labels[i]) != null ? _a2 : "", initials: computeInitials(labels == null ? void 0 : labels[i]) }) }, `${src}-${i}`);
61
+ }),
56
62
  showCounter && rest > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
57
63
  "div",
58
64
  {
@@ -75,3 +81,10 @@ function AvatarGroup({
75
81
  }
76
82
  );
77
83
  }
84
+ function computeInitials(label) {
85
+ const s = (label != null ? label : "").trim();
86
+ if (!s) return "";
87
+ const parts = s.split(/\s+/).filter(Boolean);
88
+ if (parts.length === 1) return parts[0].slice(0, 2).toUpperCase();
89
+ return (parts[0][0] + parts[parts.length - 1][0]).toUpperCase();
90
+ }
@@ -3,6 +3,8 @@ import { jsx, jsxs } from "react/jsx-runtime";
3
3
  import AvatarSquare from "./AvatarSquare";
4
4
  function AvatarGroup({
5
5
  sources,
6
+ images,
7
+ labels,
6
8
  max = 3,
7
9
  size = 28,
8
10
  overlap = true,
@@ -10,16 +12,20 @@ function AvatarGroup({
10
12
  className = "",
11
13
  showCounter = true
12
14
  }) {
13
- const imgs = (sources || []).filter(Boolean);
14
- const visible = imgs.slice(0, Math.max(0, max));
15
- const rest = Math.max(0, imgs.length - visible.length);
15
+ var _a;
16
+ const list = (_a = sources != null ? sources : images) != null ? _a : [];
17
+ const visible = list.slice(0, Math.max(0, max));
18
+ const rest = Math.max(0, list.length - visible.length);
16
19
  return /* @__PURE__ */ jsxs(
17
20
  "div",
18
21
  {
19
22
  className: ["flex items-center", className].join(" "),
20
23
  "aria-label": "Grupo de avatares",
21
24
  children: [
22
- visible.map((src, i) => /* @__PURE__ */ jsx("div", { className: i > 0 && overlap ? "-ml-2" : void 0, children: /* @__PURE__ */ jsx(AvatarSquare, { src, size, radiusClass }) }, `${src}-${i}`)),
25
+ visible.map((src, i) => {
26
+ var _a2;
27
+ return /* @__PURE__ */ jsx("div", { className: i > 0 && overlap ? "-ml-2" : void 0, children: /* @__PURE__ */ jsx(AvatarSquare, { src: src != null ? src : void 0, size, radiusClass, alt: (_a2 = labels == null ? void 0 : labels[i]) != null ? _a2 : "", initials: computeInitials(labels == null ? void 0 : labels[i]) }) }, `${src}-${i}`);
28
+ }),
23
29
  showCounter && rest > 0 && /* @__PURE__ */ jsxs(
24
30
  "div",
25
31
  {
@@ -42,6 +48,13 @@ function AvatarGroup({
42
48
  }
43
49
  );
44
50
  }
51
+ function computeInitials(label) {
52
+ const s = (label != null ? label : "").trim();
53
+ if (!s) return "";
54
+ const parts = s.split(/\s+/).filter(Boolean);
55
+ if (parts.length === 1) return parts[0].slice(0, 2).toUpperCase();
56
+ return (parts[0][0] + parts[parts.length - 1][0]).toUpperCase();
57
+ }
45
58
  export {
46
59
  AvatarGroup as default
47
60
  };
@@ -4,10 +4,11 @@ type Props = {
4
4
  size?: number;
5
5
  src?: string | null;
6
6
  alt?: string;
7
+ initials?: string | null;
7
8
  className?: string;
8
9
  radiusClass?: string;
9
10
  color?: "slate" | "gray" | "zinc" | "neutral" | "stone" | "red" | "orange" | "amber" | "yellow" | "lime" | "green" | "emerald" | "teal" | "cyan" | "sky" | "blue" | "indigo" | "violet" | "purple" | "fuchsia" | "pink" | "rose";
10
11
  };
11
- declare function AvatarSquare({ size, src, alt, className, radiusClass, color, }: Props): react_jsx_runtime.JSX.Element;
12
+ declare function AvatarSquare({ size, src, alt, initials, className, radiusClass, color, }: Props): react_jsx_runtime.JSX.Element;
12
13
 
13
14
  export { AvatarSquare as default };
@@ -4,10 +4,11 @@ type Props = {
4
4
  size?: number;
5
5
  src?: string | null;
6
6
  alt?: string;
7
+ initials?: string | null;
7
8
  className?: string;
8
9
  radiusClass?: string;
9
10
  color?: "slate" | "gray" | "zinc" | "neutral" | "stone" | "red" | "orange" | "amber" | "yellow" | "lime" | "green" | "emerald" | "teal" | "cyan" | "sky" | "blue" | "indigo" | "violet" | "purple" | "fuchsia" | "pink" | "rose";
10
11
  };
11
- declare function AvatarSquare({ size, src, alt, className, radiusClass, color, }: Props): react_jsx_runtime.JSX.Element;
12
+ declare function AvatarSquare({ size, src, alt, initials, className, radiusClass, color, }: Props): react_jsx_runtime.JSX.Element;
12
13
 
13
14
  export { AvatarSquare as default };
@@ -39,6 +39,7 @@ function AvatarSquare({
39
39
  size = 32,
40
40
  src,
41
41
  alt = "",
42
+ initials = null,
42
43
  className = "",
43
44
  radiusClass = "rounded-xl",
44
45
  color = "blue"
@@ -120,10 +121,13 @@ function AvatarSquare({
120
121
  "div",
121
122
  {
122
123
  className: [
123
- "h-full w-full",
124
+ "grid place-items-center h-full w-full text-[11px] font-semibold uppercase tracking-wide text-slate-700 dark:text-slate-200",
124
125
  radiusClass,
125
126
  GRADIENT[color]
126
- ].join(" ")
127
+ ].join(" "),
128
+ "aria-label": alt || initials || "avatar",
129
+ title: alt || initials || void 0,
130
+ children: typeof initials === "string" && initials.trim() ? initials.trim() : alt ? alt.split(/\s+/).slice(0, 2).map((s) => s[0]).join("") : ""
127
131
  }
128
132
  )
129
133
  }
@@ -6,6 +6,7 @@ function AvatarSquare({
6
6
  size = 32,
7
7
  src,
8
8
  alt = "",
9
+ initials = null,
9
10
  className = "",
10
11
  radiusClass = "rounded-xl",
11
12
  color = "blue"
@@ -87,10 +88,13 @@ function AvatarSquare({
87
88
  "div",
88
89
  {
89
90
  className: [
90
- "h-full w-full",
91
+ "grid place-items-center h-full w-full text-[11px] font-semibold uppercase tracking-wide text-slate-700 dark:text-slate-200",
91
92
  radiusClass,
92
93
  GRADIENT[color]
93
- ].join(" ")
94
+ ].join(" "),
95
+ "aria-label": alt || initials || "avatar",
96
+ title: alt || initials || void 0,
97
+ children: typeof initials === "string" && initials.trim() ? initials.trim() : alt ? alt.split(/\s+/).slice(0, 2).map((s) => s[0]).join("") : ""
94
98
  }
95
99
  )
96
100
  }
package/dist/Dialog.d.mts CHANGED
@@ -25,9 +25,11 @@ declare function DialogHeader({ title, description, onClose, showClose, actions,
25
25
  compact?: boolean;
26
26
  className?: string;
27
27
  }): react_jsx_runtime.JSX.Element;
28
- declare function DialogBody({ children, padded }: {
28
+ declare function DialogBody({ children, padded, className, noScroll }: {
29
29
  children: React__default.ReactNode;
30
30
  padded?: boolean;
31
+ className?: string;
32
+ noScroll?: boolean;
31
33
  }): react_jsx_runtime.JSX.Element;
32
34
  declare function DialogFooter({ children, align, }: {
33
35
  children: React__default.ReactNode;
package/dist/Dialog.d.ts CHANGED
@@ -25,9 +25,11 @@ declare function DialogHeader({ title, description, onClose, showClose, actions,
25
25
  compact?: boolean;
26
26
  className?: string;
27
27
  }): react_jsx_runtime.JSX.Element;
28
- declare function DialogBody({ children, padded }: {
28
+ declare function DialogBody({ children, padded, className, noScroll }: {
29
29
  children: React__default.ReactNode;
30
30
  padded?: boolean;
31
+ className?: string;
32
+ noScroll?: boolean;
31
33
  }): react_jsx_runtime.JSX.Element;
32
34
  declare function DialogFooter({ children, align, }: {
33
35
  children: React__default.ReactNode;
package/dist/Dialog.js CHANGED
@@ -215,8 +215,8 @@ function DialogHeader({
215
215
  ] })
216
216
  ] }) });
217
217
  }
218
- function DialogBody({ children, padded = true }) {
219
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: cx("min-h-[60px] flex-1 overflow-auto", padded && "px-6 pb-6 pt-2"), children });
218
+ function DialogBody({ children, padded = true, className, noScroll = false }) {
219
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: cx("min-h-[60px] flex-1", noScroll ? "overflow-hidden" : "overflow-auto", padded && "px-6 pb-6 pt-2", className), children });
220
220
  }
221
221
  function DialogFooter({
222
222
  children,
package/dist/Dialog.mjs CHANGED
@@ -175,8 +175,8 @@ function DialogHeader({
175
175
  ] })
176
176
  ] }) });
177
177
  }
178
- function DialogBody({ children, padded = true }) {
179
- return /* @__PURE__ */ jsx("div", { className: cx("min-h-[60px] flex-1 overflow-auto", padded && "px-6 pb-6 pt-2"), children });
178
+ function DialogBody({ children, padded = true, className, noScroll = false }) {
179
+ return /* @__PURE__ */ jsx("div", { className: cx("min-h-[60px] flex-1", noScroll ? "overflow-hidden" : "overflow-auto", padded && "px-6 pb-6 pt-2", className), children });
180
180
  }
181
181
  function DialogFooter({
182
182
  children,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "framepexls-ui-lib",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "description": "Componentes UI de Framepexls para React/Next.",