@langchain/macaw-components 1.7.5 → 1.7.6

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.
@@ -28,7 +28,7 @@ var Avatar = forwardRef(({ size = "md", shape = "square", badge, tooltip, classN
28
28
  const rounding = shape === "circle" ? "rounded-full" : "rounded-sm";
29
29
  const inner = /* @__PURE__ */ jsxs("div", {
30
30
  ref,
31
- className: cn("relative inline-flex shrink-0 cursor-default items-center justify-center text-center font-medium uppercase text-white/90 transition-all", rounding, BOX_SIZE[size], TEXT_SIZE[size], active && "bg-brand", className),
31
+ className: cn("relative inline-flex shrink-0 items-center justify-center text-center font-medium uppercase text-white/90 transition-all", rounding, BOX_SIZE[size], TEXT_SIZE[size], active && "bg-brand", className),
32
32
  style: active ? void 0 : { backgroundImage: `linear-gradient(to bottom right, ${startColor}, #aaaaaa)` },
33
33
  children: [imageUrl ? /* @__PURE__ */ jsx("div", {
34
34
  className: cn("absolute inset-0 size-full bg-cover bg-center", rounding),
@@ -1 +1 @@
1
- {"version":3,"file":"Avatar.js","names":[],"sources":["../../../src/components/Avatar/Avatar.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\nimport { forwardRef } from 'react';\n\nimport { cn } from '../../utils/cn';\nimport {\n VISUAL_ELEMENT_SIZES,\n type VisualElementSize,\n} from '../../utils/componentSizes';\nimport { getColorByString } from '../../utils/get-color-by-string';\nimport { sanitizeImageSrc } from '../../utils/sanitizeImageSrc';\nimport { Tooltip } from '../Tooltip';\n\ntype AvatarSize = VisualElementSize | 'lg' | 'xl';\ntype AvatarShape = 'circle' | 'square';\n\ninterface AvatarProps {\n /** Outer box size: xxs=12px, xs=16px, sm=20px, md=24px, lg=36px, xl=48px. */\n size?: AvatarSize;\n shape?: AvatarShape;\n /** Show a small notification dot in the top-right corner. */\n badge?: boolean;\n /** Wrap the avatar in a tooltip with this title. */\n tooltip?: string;\n /** Extra classes on the avatar box. Can override size/text/color via `twMerge`. */\n className?: string;\n /** Text used for the initial and, unless `color` is set, the color hash. */\n label: string;\n /** Renders an image instead of the initial when present. */\n imageUrl?: string;\n /** Overrides the color-from-string hash with an explicit gradient start color. */\n color?: string;\n /** Rendered instead of the initial when `label` is empty. */\n fallbackIcon?: ReactNode;\n /** Highlighted brand-fill state (e.g. the current user's own entry). */\n active?: boolean;\n}\n\n// The shared tiers use the visual-element scale. Identity-specific lg/xl tiers\n// remain larger so existing Avatar presentations retain their geometry.\nconst BOX_SIZE: Record<AvatarSize, string> = {\n xxs: VISUAL_ELEMENT_SIZES.xxs.className,\n xs: VISUAL_ELEMENT_SIZES.xs.className,\n sm: VISUAL_ELEMENT_SIZES.sm.className,\n md: VISUAL_ELEMENT_SIZES.md.className,\n lg: 'size-9',\n xl: 'size-12',\n};\n\nconst TEXT_SIZE: Record<AvatarSize, string> = {\n xxs: 'text-[0.625rem] leading-none',\n xs: 'text-xxs',\n sm: 'text-xs',\n md: 'text-sm',\n lg: 'text-lg',\n xl: 'text-xl',\n};\n\n// Keeps the URL inside a quoted CSS `url(\"\")` string.\nconst escapeCssString = (value: string) =>\n value.replace(/[\"\\\\\\n\\r\\f]/g, (c) => `\\\\${c.charCodeAt(0).toString(16)} `);\n\nconst Avatar = forwardRef<HTMLDivElement, AvatarProps>(\n (\n {\n size = 'md',\n shape = 'square',\n badge,\n tooltip,\n className,\n label,\n imageUrl,\n color,\n fallbackIcon,\n active,\n },\n ref\n ) => {\n const startColor = color ?? getColorByString(label);\n const rounding = shape === 'circle' ? 'rounded-full' : 'rounded-sm';\n\n const inner = (\n // The box is intentionally not `overflow-hidden` so the badge dot can\n // overflow the top-right corner. The image child clips itself instead.\n <div\n ref={ref}\n className={cn(\n 'relative inline-flex shrink-0 cursor-default items-center justify-center text-center font-medium uppercase text-white/90 transition-all',\n rounding,\n BOX_SIZE[size],\n TEXT_SIZE[size],\n active && 'bg-brand',\n className\n )}\n style={\n active\n ? undefined\n : {\n backgroundImage: `linear-gradient(to bottom right, ${startColor}, #aaaaaa)`,\n }\n }\n >\n {imageUrl ? (\n <div\n className={cn(\n 'absolute inset-0 size-full bg-cover bg-center',\n rounding\n )}\n style={{\n backgroundImage: `url(\"${escapeCssString(sanitizeImageSrc(imageUrl))}\")`,\n }}\n />\n ) : label ? (\n <span>{label.charAt(0)}</span>\n ) : (\n (fallbackIcon ?? null)\n )}\n\n {badge && (\n <div\n className={cn(\n 'absolute rounded-full border-current bg-error-strong outline-transparent',\n size === 'xxs'\n ? '-right-0.5 -top-0.5 size-1.5 border'\n : '-right-1 -top-1 size-3 border-2'\n )}\n />\n )}\n </div>\n );\n\n if (tooltip) {\n return <Tooltip title={tooltip}>{inner}</Tooltip>;\n }\n\n return inner;\n }\n);\n\nAvatar.displayName = 'Avatar';\n\nexport { Avatar };\nexport type { AvatarProps, AvatarSize };\n"],"mappings":";;;;;;;;AAuCA,IAAM,WAAuC;CAC3C,KAAK,qBAAqB,IAAI;CAC9B,IAAI,qBAAqB,GAAG;CAC5B,IAAI,qBAAqB,GAAG;CAC5B,IAAI,qBAAqB,GAAG;CAC5B,IAAI;CACJ,IAAI;AACN;AAEA,IAAM,YAAwC;CAC5C,KAAK;CACL,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;AACN;AAGA,IAAM,mBAAmB,UACvB,MAAM,QAAQ,iBAAiB,MAAM,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,SAAS,EAAE,EAAE,EAAE;AAE3E,IAAM,SAAS,YAEX,EACE,OAAO,MACP,QAAQ,UACR,OACA,SACA,WACA,OACA,UACA,OACA,cACA,UAEF,QACG;CACH,MAAM,aAAa,SAAS,iBAAiB,KAAK;CAClD,MAAM,WAAW,UAAU,WAAW,iBAAiB;CAEvD,MAAM,QAGJ,qBAAC,OAAD;EACO;EACL,WAAW,GACT,2IACA,UACA,SAAS,OACT,UAAU,OACV,UAAU,YACV,SACF;EACA,OACE,SACI,KAAA,IACA,EACE,iBAAiB,oCAAoC,WAAW,YAClE;EAfR,UAAA,CAkBG,WACC,oBAAC,OAAD;GACE,WAAW,GACT,iDACA,QACF;GACA,OAAO,EACL,iBAAiB,QAAQ,gBAAgB,iBAAiB,QAAQ,CAAC,EAAE,IACvE;EACD,CAAA,IACC,QACF,oBAAC,QAAD,EAAA,UAAO,MAAM,OAAO,CAAC,EAAQ,CAAA,IAE5B,gBAAgB,MAGlB,SACC,oBAAC,OAAD,EACE,WAAW,GACT,4EACA,SAAS,QACL,wCACA,iCACN,EACD,CAAA,CAEA;;CAGP,IAAI,SACF,OAAO,oBAAC,SAAD;EAAS,OAAO;EAAU,UAAA;CAAe,CAAA;CAGlD,OAAO;AACT,CACF;AAEA,OAAO,cAAc"}
1
+ {"version":3,"file":"Avatar.js","names":[],"sources":["../../../src/components/Avatar/Avatar.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\nimport { forwardRef } from 'react';\n\nimport { cn } from '../../utils/cn';\nimport {\n VISUAL_ELEMENT_SIZES,\n type VisualElementSize,\n} from '../../utils/componentSizes';\nimport { getColorByString } from '../../utils/get-color-by-string';\nimport { sanitizeImageSrc } from '../../utils/sanitizeImageSrc';\nimport { Tooltip } from '../Tooltip';\n\ntype AvatarSize = VisualElementSize | 'lg' | 'xl';\ntype AvatarShape = 'circle' | 'square';\n\ninterface AvatarProps {\n /** Outer box size: xxs=12px, xs=16px, sm=20px, md=24px, lg=36px, xl=48px. */\n size?: AvatarSize;\n shape?: AvatarShape;\n /** Show a small notification dot in the top-right corner. */\n badge?: boolean;\n /** Wrap the avatar in a tooltip with this title. */\n tooltip?: string;\n /** Extra classes on the avatar box. Can override size/text/color via `twMerge`. */\n className?: string;\n /** Text used for the initial and, unless `color` is set, the color hash. */\n label: string;\n /** Renders an image instead of the initial when present. */\n imageUrl?: string;\n /** Overrides the color-from-string hash with an explicit gradient start color. */\n color?: string;\n /** Rendered instead of the initial when `label` is empty. */\n fallbackIcon?: ReactNode;\n /** Highlighted brand-fill state (e.g. the current user's own entry). */\n active?: boolean;\n}\n\n// The shared tiers use the visual-element scale. Identity-specific lg/xl tiers\n// remain larger so existing Avatar presentations retain their geometry.\nconst BOX_SIZE: Record<AvatarSize, string> = {\n xxs: VISUAL_ELEMENT_SIZES.xxs.className,\n xs: VISUAL_ELEMENT_SIZES.xs.className,\n sm: VISUAL_ELEMENT_SIZES.sm.className,\n md: VISUAL_ELEMENT_SIZES.md.className,\n lg: 'size-9',\n xl: 'size-12',\n};\n\nconst TEXT_SIZE: Record<AvatarSize, string> = {\n xxs: 'text-[0.625rem] leading-none',\n xs: 'text-xxs',\n sm: 'text-xs',\n md: 'text-sm',\n lg: 'text-lg',\n xl: 'text-xl',\n};\n\n// Keeps the URL inside a quoted CSS `url(\"\")` string.\nconst escapeCssString = (value: string) =>\n value.replace(/[\"\\\\\\n\\r\\f]/g, (c) => `\\\\${c.charCodeAt(0).toString(16)} `);\n\nconst Avatar = forwardRef<HTMLDivElement, AvatarProps>(\n (\n {\n size = 'md',\n shape = 'square',\n badge,\n tooltip,\n className,\n label,\n imageUrl,\n color,\n fallbackIcon,\n active,\n },\n ref\n ) => {\n const startColor = color ?? getColorByString(label);\n const rounding = shape === 'circle' ? 'rounded-full' : 'rounded-sm';\n\n const inner = (\n // The box is intentionally not `overflow-hidden` so the badge dot can\n // overflow the top-right corner. The image child clips itself instead.\n <div\n ref={ref}\n className={cn(\n 'relative inline-flex shrink-0 items-center justify-center text-center font-medium uppercase text-white/90 transition-all',\n rounding,\n BOX_SIZE[size],\n TEXT_SIZE[size],\n active && 'bg-brand',\n className\n )}\n style={\n active\n ? undefined\n : {\n backgroundImage: `linear-gradient(to bottom right, ${startColor}, #aaaaaa)`,\n }\n }\n >\n {imageUrl ? (\n <div\n className={cn(\n 'absolute inset-0 size-full bg-cover bg-center',\n rounding\n )}\n style={{\n backgroundImage: `url(\"${escapeCssString(sanitizeImageSrc(imageUrl))}\")`,\n }}\n />\n ) : label ? (\n <span>{label.charAt(0)}</span>\n ) : (\n (fallbackIcon ?? null)\n )}\n\n {badge && (\n <div\n className={cn(\n 'absolute rounded-full border-current bg-error-strong outline-transparent',\n size === 'xxs'\n ? '-right-0.5 -top-0.5 size-1.5 border'\n : '-right-1 -top-1 size-3 border-2'\n )}\n />\n )}\n </div>\n );\n\n if (tooltip) {\n return <Tooltip title={tooltip}>{inner}</Tooltip>;\n }\n\n return inner;\n }\n);\n\nAvatar.displayName = 'Avatar';\n\nexport { Avatar };\nexport type { AvatarProps, AvatarSize };\n"],"mappings":";;;;;;;;AAuCA,IAAM,WAAuC;CAC3C,KAAK,qBAAqB,IAAI;CAC9B,IAAI,qBAAqB,GAAG;CAC5B,IAAI,qBAAqB,GAAG;CAC5B,IAAI,qBAAqB,GAAG;CAC5B,IAAI;CACJ,IAAI;AACN;AAEA,IAAM,YAAwC;CAC5C,KAAK;CACL,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;AACN;AAGA,IAAM,mBAAmB,UACvB,MAAM,QAAQ,iBAAiB,MAAM,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,SAAS,EAAE,EAAE,EAAE;AAE3E,IAAM,SAAS,YAEX,EACE,OAAO,MACP,QAAQ,UACR,OACA,SACA,WACA,OACA,UACA,OACA,cACA,UAEF,QACG;CACH,MAAM,aAAa,SAAS,iBAAiB,KAAK;CAClD,MAAM,WAAW,UAAU,WAAW,iBAAiB;CAEvD,MAAM,QAGJ,qBAAC,OAAD;EACO;EACL,WAAW,GACT,4HACA,UACA,SAAS,OACT,UAAU,OACV,UAAU,YACV,SACF;EACA,OACE,SACI,KAAA,IACA,EACE,iBAAiB,oCAAoC,WAAW,YAClE;EAfR,UAAA,CAkBG,WACC,oBAAC,OAAD;GACE,WAAW,GACT,iDACA,QACF;GACA,OAAO,EACL,iBAAiB,QAAQ,gBAAgB,iBAAiB,QAAQ,CAAC,EAAE,IACvE;EACD,CAAA,IACC,QACF,oBAAC,QAAD,EAAA,UAAO,MAAM,OAAO,CAAC,EAAQ,CAAA,IAE5B,gBAAgB,MAGlB,SACC,oBAAC,OAAD,EACE,WAAW,GACT,4EACA,SAAS,QACL,wCACA,iCACN,EACD,CAAA,CAEA;;CAGP,IAAI,SACF,OAAO,oBAAC,SAAD;EAAS,OAAO;EAAU,UAAA;CAAe,CAAA;CAGlD,OAAO;AACT,CACF;AAEA,OAAO,cAAc"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@langchain/macaw-components",
3
- "version": "1.7.5",
3
+ "version": "1.7.6",
4
4
  "description": "React components and usage guidance for the Macaw Design System.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -653,7 +653,7 @@
653
653
  "@fontsource/fira-code": "^5.2.7",
654
654
  "@fontsource/inter": "^5.2.8",
655
655
  "@headlessui/react": "^2.2.10",
656
- "@langchain/macaw-tokens": "1.7.5",
656
+ "@langchain/macaw-tokens": "1.7.6",
657
657
  "@lezer/common": "^1.2.1",
658
658
  "@lezer/highlight": "^1.2.0",
659
659
  "@lezer/yaml": "^1.0.4",