@stackshift-ui/avatar 6.0.5 → 6.0.6-beta.1

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/avatar.js CHANGED
@@ -1,103 +1 @@
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/avatar.tsx
31
- var avatar_exports = {};
32
- __export(avatar_exports, {
33
- Avatar: () => Avatar
34
- });
35
- module.exports = __toCommonJS(avatar_exports);
36
- var import_flex = require("@stackshift-ui/flex");
37
- var import_image = require("@stackshift-ui/image");
38
- var import_system = require("@stackshift-ui/system");
39
- var import_classnames = __toESM(require("classnames"));
40
- var import_react = require("react");
41
- var import_jsx_runtime = require("react/jsx-runtime");
42
- var displayName = "Avatar";
43
- var Avatar = ({
44
- src,
45
- alt = "image",
46
- size = "sm",
47
- text,
48
- children,
49
- className,
50
- as,
51
- ...props
52
- }) => {
53
- var _a;
54
- const components = (0, import_system.useStackShiftUIComponents)();
55
- const { [displayName]: Component = import_system.DefaultComponent } = components;
56
- const [loaded, setLoaded] = (0, import_react.useState)(false);
57
- const sizeMap = {
58
- sm: 40,
59
- md: 80,
60
- lg: 120,
61
- xl: 160
62
- };
63
- const avatarSize = typeof size === "number" ? `${size}px` : `${sizeMap[size]}px`;
64
- const initials = text ? (_a = text == null ? void 0 : text.split(" ")) == null ? void 0 : _a.reduce((acc, curr) => acc + curr[0], "") : "AB";
65
- const baseClass = `relative flex rounded-full aspect-square overflow-hidden border-2 border-solid border-primary`;
66
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
67
- Component,
68
- {
69
- as,
70
- className: (0, import_classnames.default)(baseClass, className),
71
- style: { maxWidth: avatarSize },
72
- ...props,
73
- "data-testid": displayName,
74
- children: [
75
- (!loaded || !src) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_flex.Flex, { align: "center", justify: "center", className: "w-full h-full bg-primary", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
76
- "p",
77
- {
78
- style: {
79
- fontSize: `calc(${avatarSize}/2)`
80
- },
81
- className: "text-white",
82
- children: initials
83
- }
84
- ) }),
85
- src && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
86
- import_image.Image,
87
- {
88
- className: "object-cover object-center w-[100%] h-[100%]",
89
- src,
90
- alt,
91
- width: 100,
92
- height: 100,
93
- onLoad: () => setLoaded(true)
94
- }
95
- )
96
- ]
97
- }
98
- );
99
- };
100
- // Annotate the CommonJS export names for ESM import in node:
101
- 0 && (module.exports = {
102
- Avatar
103
- });
1
+ "use strict";var A=Object.create;var n=Object.defineProperty;var L=Object.getOwnPropertyDescriptor;var M=Object.getOwnPropertyNames;var T=Object.getPrototypeOf,I=Object.prototype.hasOwnProperty;var P=(e,t)=>{for(var a in t)n(e,a,{get:t[a],enumerable:!0})},c=(e,t,a,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of M(t))!I.call(e,o)&&o!==a&&n(e,o,{get:()=>t[o],enumerable:!(s=L(t,o))||s.enumerable});return e};var E=(e,t,a)=>(a=e!=null?A(T(e)):{},c(t||!e||!e.__esModule?n(a,"default",{value:e,enumerable:!0}):a,e)),F=e=>c(n({},"__esModule",{value:!0}),e);var R={};P(R,{Avatar:()=>H});module.exports=F(R);var d=require("@stackshift-ui/flex"),f=require("@stackshift-ui/image"),l=require("@stackshift-ui/system"),g=E(require("classnames")),u=require("react"),r=require("react/jsx-runtime"),p="Avatar",H=({src:e,alt:t="image",size:a="sm",text:s,children:o,className:h,as:y,...b})=>{var i;let v=(0,l.useStackShiftUIComponents)(),{[p]:N=l.DefaultComponent}=v,[x,C]=(0,u.useState)(!1),m=typeof a=="number"?`${a}px`:`${{sm:40,md:80,lg:120,xl:160}[a]}px`,S=s?(i=s==null?void 0:s.split(" "))==null?void 0:i.reduce((z,w)=>z+w[0],""):"AB";return(0,r.jsxs)(N,{as:y,className:(0,g.default)("relative flex rounded-full aspect-square overflow-hidden border-2 border-solid border-primary",h),style:{maxWidth:m},...b,"data-testid":p,children:[(!x||!e)&&(0,r.jsx)(d.Flex,{align:"center",justify:"center",className:"w-full h-full bg-primary",children:(0,r.jsx)("p",{style:{fontSize:`calc(${m}/2)`},className:"text-white",children:S})}),e&&(0,r.jsx)(f.Image,{className:"object-cover object-center w-[100%] h-[100%]",src:e,alt:t,width:100,height:100,onLoad:()=>C(!0)})]})};0&&(module.exports={Avatar});
package/dist/avatar.mjs CHANGED
@@ -1,6 +1 @@
1
- import {
2
- Avatar
3
- } from "./chunk-CDOBXEGP.mjs";
4
- export {
5
- Avatar
6
- };
1
+ import{a}from"./chunk-ED3O2KBX.mjs";export{a as Avatar};
package/dist/index.js CHANGED
@@ -1,106 +1,2 @@
1
- "use strict";
2
1
  "use client";
3
- var __create = Object.create;
4
- var __defProp = Object.defineProperty;
5
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
- var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __getProtoOf = Object.getPrototypeOf;
8
- var __hasOwnProp = Object.prototype.hasOwnProperty;
9
- var __export = (target, all) => {
10
- for (var name in all)
11
- __defProp(target, name, { get: all[name], enumerable: true });
12
- };
13
- var __copyProps = (to, from, except, desc) => {
14
- if (from && typeof from === "object" || typeof from === "function") {
15
- for (let key of __getOwnPropNames(from))
16
- if (!__hasOwnProp.call(to, key) && key !== except)
17
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
- }
19
- return to;
20
- };
21
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
- // If the importer is in node compatibility mode or this is not an ESM
23
- // file that has been converted to a CommonJS file using a Babel-
24
- // compatible transform (i.e. "__esModule" has not been set), then set
25
- // "default" to the CommonJS "module.exports" for node compatibility.
26
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
- mod
28
- ));
29
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
-
31
- // src/index.ts
32
- var src_exports = {};
33
- __export(src_exports, {
34
- Avatar: () => Avatar
35
- });
36
- module.exports = __toCommonJS(src_exports);
37
-
38
- // src/avatar.tsx
39
- var import_flex = require("@stackshift-ui/flex");
40
- var import_image = require("@stackshift-ui/image");
41
- var import_system = require("@stackshift-ui/system");
42
- var import_classnames = __toESM(require("classnames"));
43
- var import_react = require("react");
44
- var import_jsx_runtime = require("react/jsx-runtime");
45
- var displayName = "Avatar";
46
- var Avatar = ({
47
- src,
48
- alt = "image",
49
- size = "sm",
50
- text,
51
- children,
52
- className,
53
- as,
54
- ...props
55
- }) => {
56
- var _a;
57
- const components = (0, import_system.useStackShiftUIComponents)();
58
- const { [displayName]: Component = import_system.DefaultComponent } = components;
59
- const [loaded, setLoaded] = (0, import_react.useState)(false);
60
- const sizeMap = {
61
- sm: 40,
62
- md: 80,
63
- lg: 120,
64
- xl: 160
65
- };
66
- const avatarSize = typeof size === "number" ? `${size}px` : `${sizeMap[size]}px`;
67
- const initials = text ? (_a = text == null ? void 0 : text.split(" ")) == null ? void 0 : _a.reduce((acc, curr) => acc + curr[0], "") : "AB";
68
- const baseClass = `relative flex rounded-full aspect-square overflow-hidden border-2 border-solid border-primary`;
69
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
70
- Component,
71
- {
72
- as,
73
- className: (0, import_classnames.default)(baseClass, className),
74
- style: { maxWidth: avatarSize },
75
- ...props,
76
- "data-testid": displayName,
77
- children: [
78
- (!loaded || !src) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_flex.Flex, { align: "center", justify: "center", className: "w-full h-full bg-primary", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
79
- "p",
80
- {
81
- style: {
82
- fontSize: `calc(${avatarSize}/2)`
83
- },
84
- className: "text-white",
85
- children: initials
86
- }
87
- ) }),
88
- src && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
89
- import_image.Image,
90
- {
91
- className: "object-cover object-center w-[100%] h-[100%]",
92
- src,
93
- alt,
94
- width: 100,
95
- height: 100,
96
- onLoad: () => setLoaded(true)
97
- }
98
- )
99
- ]
100
- }
101
- );
102
- };
103
- // Annotate the CommonJS export names for ESM import in node:
104
- 0 && (module.exports = {
105
- Avatar
106
- });
2
+ "use strict";var A=Object.create;var n=Object.defineProperty;var L=Object.getOwnPropertyDescriptor;var M=Object.getOwnPropertyNames;var T=Object.getPrototypeOf,I=Object.prototype.hasOwnProperty;var P=(e,t)=>{for(var a in t)n(e,a,{get:t[a],enumerable:!0})},c=(e,t,a,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of M(t))!I.call(e,o)&&o!==a&&n(e,o,{get:()=>t[o],enumerable:!(s=L(t,o))||s.enumerable});return e};var E=(e,t,a)=>(a=e!=null?A(T(e)):{},c(t||!e||!e.__esModule?n(a,"default",{value:e,enumerable:!0}):a,e)),F=e=>c(n({},"__esModule",{value:!0}),e);var R={};P(R,{Avatar:()=>H});module.exports=F(R);var d=require("@stackshift-ui/flex"),f=require("@stackshift-ui/image"),l=require("@stackshift-ui/system"),u=E(require("classnames")),g=require("react"),r=require("react/jsx-runtime"),p="Avatar",H=({src:e,alt:t="image",size:a="sm",text:s,children:o,className:h,as:y,...b})=>{var i;let v=(0,l.useStackShiftUIComponents)(),{[p]:x=l.DefaultComponent}=v,[N,C]=(0,g.useState)(!1),m=typeof a=="number"?`${a}px`:`${{sm:40,md:80,lg:120,xl:160}[a]}px`,S=s?(i=s==null?void 0:s.split(" "))==null?void 0:i.reduce((z,w)=>z+w[0],""):"AB";return(0,r.jsxs)(x,{as:y,className:(0,u.default)("relative flex rounded-full aspect-square overflow-hidden border-2 border-solid border-primary",h),style:{maxWidth:m},...b,"data-testid":p,children:[(!N||!e)&&(0,r.jsx)(d.Flex,{align:"center",justify:"center",className:"w-full h-full bg-primary",children:(0,r.jsx)("p",{style:{fontSize:`calc(${m}/2)`},className:"text-white",children:S})}),e&&(0,r.jsx)(f.Image,{className:"object-cover object-center w-[100%] h-[100%]",src:e,alt:t,width:100,height:100,onLoad:()=>C(!0)})]})};0&&(module.exports={Avatar});
package/dist/index.mjs CHANGED
@@ -1,8 +1,2 @@
1
1
  "use client";
2
- "use strict";
3
- import {
4
- Avatar
5
- } from "./chunk-CDOBXEGP.mjs";
6
- export {
7
- Avatar
8
- };
2
+ "use strict";import{a as e}from"./chunk-ED3O2KBX.mjs";export{e as Avatar};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stackshift-ui/avatar",
3
3
  "description": "",
4
- "version": "6.0.5",
4
+ "version": "6.0.6-beta.1",
5
5
  "private": false,
6
6
  "sideEffects": false,
7
7
  "main": "./dist/index.js",
@@ -29,22 +29,22 @@
29
29
  "typescript": "^5.6.2",
30
30
  "vite-tsconfig-paths": "^5.0.1",
31
31
  "vitest": "^2.1.1",
32
- "@stackshift-ui/eslint-config": "6.0.2",
33
- "@stackshift-ui/typescript-config": "6.0.2"
32
+ "@stackshift-ui/eslint-config": "6.0.3-beta.1",
33
+ "@stackshift-ui/typescript-config": "6.0.3-beta.1"
34
34
  },
35
35
  "dependencies": {
36
36
  "classnames": "^2.5.1",
37
- "@stackshift-ui/scripts": "6.0.2",
38
- "@stackshift-ui/flex": "6.0.3",
39
- "@stackshift-ui/system": "6.0.3",
40
- "@stackshift-ui/image": "6.0.3"
37
+ "@stackshift-ui/scripts": "6.0.3-beta.1",
38
+ "@stackshift-ui/system": "6.0.4-beta.1",
39
+ "@stackshift-ui/flex": "6.0.4-beta.1",
40
+ "@stackshift-ui/image": "6.0.4-beta.1"
41
41
  },
42
42
  "peerDependencies": {
43
43
  "@types/react": "16.8 - 19",
44
44
  "next": "10 - 14",
45
45
  "react": "16.8 - 19",
46
46
  "react-dom": "16.8 - 19",
47
- "@stackshift-ui/system": ">=0.0.0"
47
+ "@stackshift-ui/system": ">=6.0.4-beta.1"
48
48
  },
49
49
  "peerDependenciesMeta": {
50
50
  "next": {
@@ -1,69 +0,0 @@
1
- // src/avatar.tsx
2
- import { Flex } from "@stackshift-ui/flex";
3
- import { Image } from "@stackshift-ui/image";
4
- import { DefaultComponent, useStackShiftUIComponents } from "@stackshift-ui/system";
5
- import cn from "classnames";
6
- import { useState } from "react";
7
- import { jsx, jsxs } from "react/jsx-runtime";
8
- var displayName = "Avatar";
9
- var Avatar = ({
10
- src,
11
- alt = "image",
12
- size = "sm",
13
- text,
14
- children,
15
- className,
16
- as,
17
- ...props
18
- }) => {
19
- var _a;
20
- const components = useStackShiftUIComponents();
21
- const { [displayName]: Component = DefaultComponent } = components;
22
- const [loaded, setLoaded] = useState(false);
23
- const sizeMap = {
24
- sm: 40,
25
- md: 80,
26
- lg: 120,
27
- xl: 160
28
- };
29
- const avatarSize = typeof size === "number" ? `${size}px` : `${sizeMap[size]}px`;
30
- const initials = text ? (_a = text == null ? void 0 : text.split(" ")) == null ? void 0 : _a.reduce((acc, curr) => acc + curr[0], "") : "AB";
31
- const baseClass = `relative flex rounded-full aspect-square overflow-hidden border-2 border-solid border-primary`;
32
- return /* @__PURE__ */ jsxs(
33
- Component,
34
- {
35
- as,
36
- className: cn(baseClass, className),
37
- style: { maxWidth: avatarSize },
38
- ...props,
39
- "data-testid": displayName,
40
- children: [
41
- (!loaded || !src) && /* @__PURE__ */ jsx(Flex, { align: "center", justify: "center", className: "w-full h-full bg-primary", children: /* @__PURE__ */ jsx(
42
- "p",
43
- {
44
- style: {
45
- fontSize: `calc(${avatarSize}/2)`
46
- },
47
- className: "text-white",
48
- children: initials
49
- }
50
- ) }),
51
- src && /* @__PURE__ */ jsx(
52
- Image,
53
- {
54
- className: "object-cover object-center w-[100%] h-[100%]",
55
- src,
56
- alt,
57
- width: 100,
58
- height: 100,
59
- onLoad: () => setLoaded(true)
60
- }
61
- )
62
- ]
63
- }
64
- );
65
- };
66
-
67
- export {
68
- Avatar
69
- };