@almadar/ui 5.95.0 → 5.97.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.
@@ -1,4 +1,5 @@
1
- import React11, { createContext, useCallback, useState, useRef, useEffect, useContext, useMemo, useSyncExternalStore, useId } from 'react';
1
+ import * as React12 from 'react';
2
+ import React12__default, { createContext, useCallback, useState, useRef, useEffect, useContext, useMemo, useSyncExternalStore, useId } from 'react';
2
3
  import { createLogger } from '@almadar/logger';
3
4
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
4
5
  import * as LucideIcons2 from 'lucide-react';
@@ -2748,7 +2749,7 @@ var positionStyles = {
2748
2749
  fixed: "fixed",
2749
2750
  sticky: "sticky"
2750
2751
  };
2751
- var Box = React11.forwardRef(
2752
+ var Box = React12__default.forwardRef(
2752
2753
  ({
2753
2754
  padding,
2754
2755
  paddingX,
@@ -2813,7 +2814,7 @@ var Box = React11.forwardRef(
2813
2814
  onPointerDown?.(e);
2814
2815
  }, [hoverEvent, tapReveal, triggerProps, onPointerDown]);
2815
2816
  const isClickable = action || onClick;
2816
- return React11.createElement(
2817
+ return React12__default.createElement(
2817
2818
  Component,
2818
2819
  {
2819
2820
  ref,
@@ -2901,7 +2902,7 @@ var Stack = ({
2901
2902
  };
2902
2903
  const isHorizontal = direction === "horizontal";
2903
2904
  const directionClass = responsive && isHorizontal ? reverse ? "flex-col-reverse md:flex-row-reverse" : "flex-col md:flex-row" : isHorizontal ? reverse ? "flex-row-reverse" : "flex-row" : reverse ? "flex-col-reverse" : "flex-col";
2904
- return React11.createElement(
2905
+ return React12__default.createElement(
2905
2906
  Component,
2906
2907
  {
2907
2908
  className: cn(
@@ -3011,7 +3012,7 @@ var Typography = ({
3011
3012
  }) => {
3012
3013
  const variant = variantProp ?? (level ? `h${level}` : "body1");
3013
3014
  const Component = as || defaultElements[variant];
3014
- return React11.createElement(
3015
+ return React12__default.createElement(
3015
3016
  Component,
3016
3017
  {
3017
3018
  id,
@@ -3103,7 +3104,7 @@ function loadLib(key, importer) {
3103
3104
  return p;
3104
3105
  }
3105
3106
  function lazyFamilyIcon(libKey, importer, pick, fallbackName, family) {
3106
- const Lazy = React11.lazy(async () => {
3107
+ const Lazy = React12__default.lazy(async () => {
3107
3108
  const lib = await loadLib(libKey, importer);
3108
3109
  const Comp = pick(lib);
3109
3110
  if (!Comp) {
@@ -3113,7 +3114,7 @@ function lazyFamilyIcon(libKey, importer, pick, fallbackName, family) {
3113
3114
  return { default: Comp };
3114
3115
  });
3115
3116
  const Wrapped = (props) => /* @__PURE__ */ jsx(
3116
- React11.Suspense,
3117
+ React12__default.Suspense,
3117
3118
  {
3118
3119
  fallback: /* @__PURE__ */ jsx(
3119
3120
  "span",
@@ -3819,7 +3820,7 @@ var Icon = ({
3819
3820
  const directIcon = typeof icon === "string" ? void 0 : icon;
3820
3821
  const effectiveName = typeof icon === "string" ? icon : name;
3821
3822
  const family = useIconFamily();
3822
- const RenderedComponent = React11.useMemo(() => {
3823
+ const RenderedComponent = React12__default.useMemo(() => {
3823
3824
  if (directIcon) return null;
3824
3825
  return effectiveName ? resolveIconForFamily(effectiveName, family) : null;
3825
3826
  }, [directIcon, effectiveName, family]);
@@ -3867,6 +3868,143 @@ var Icon = ({
3867
3868
  );
3868
3869
  };
3869
3870
  Icon.displayName = "Icon";
3871
+
3872
+ // lib/atlasSlice.ts
3873
+ var atlasCache = /* @__PURE__ */ new Map();
3874
+ function isTilesheet(a) {
3875
+ return typeof a.tileWidth === "number";
3876
+ }
3877
+ function getAtlas(url, onReady) {
3878
+ if (atlasCache.has(url)) return atlasCache.get(url) ?? void 0;
3879
+ atlasCache.set(url, void 0);
3880
+ fetch(url).then((r2) => r2.json()).then((json) => {
3881
+ atlasCache.set(url, json);
3882
+ onReady();
3883
+ }).catch(() => {
3884
+ atlasCache.set(url, null);
3885
+ });
3886
+ return void 0;
3887
+ }
3888
+ function subRectFor(atlas, sprite) {
3889
+ if (isTilesheet(atlas)) {
3890
+ let col;
3891
+ let row;
3892
+ if (sprite.includes(",")) {
3893
+ const [c, r2] = sprite.split(",").map((n) => Number(n.trim()));
3894
+ col = c;
3895
+ row = r2;
3896
+ } else {
3897
+ const i = Number(sprite);
3898
+ if (!Number.isFinite(i)) return null;
3899
+ col = i % atlas.columns;
3900
+ row = Math.floor(i / atlas.columns);
3901
+ }
3902
+ if (!Number.isFinite(col) || !Number.isFinite(row) || col < 0 || row < 0 || col >= atlas.columns || row >= atlas.rows) return null;
3903
+ const margin = atlas.margin ?? 0;
3904
+ const spacing = atlas.spacing ?? 0;
3905
+ return {
3906
+ sx: margin + col * (atlas.tileWidth + spacing),
3907
+ sy: margin + row * (atlas.tileHeight + spacing),
3908
+ sw: atlas.tileWidth,
3909
+ sh: atlas.tileHeight
3910
+ };
3911
+ }
3912
+ const st = atlas.subTextures[sprite];
3913
+ if (!st) return null;
3914
+ return { sx: st.x, sy: st.y, sw: st.width, sh: st.height };
3915
+ }
3916
+ function isAtlasAsset(asset) {
3917
+ return !!asset && typeof asset.atlas === "string" && typeof asset.sprite === "string";
3918
+ }
3919
+ var imageCache = /* @__PURE__ */ new Map();
3920
+ var imageWaiters = /* @__PURE__ */ new Map();
3921
+ function getSheetImage(url, onReady) {
3922
+ const cached = imageCache.get(url);
3923
+ if (cached) return cached;
3924
+ (imageWaiters.get(url) ?? imageWaiters.set(url, /* @__PURE__ */ new Set()).get(url)).add(onReady);
3925
+ if (!imageCache.has(url)) {
3926
+ imageCache.set(url, null);
3927
+ const img = new Image();
3928
+ img.crossOrigin = "anonymous";
3929
+ img.onload = () => {
3930
+ imageCache.set(url, img);
3931
+ imageWaiters.get(url)?.forEach((fn) => fn());
3932
+ imageWaiters.delete(url);
3933
+ };
3934
+ img.src = url;
3935
+ }
3936
+ return null;
3937
+ }
3938
+ function AtlasImage({
3939
+ asset,
3940
+ size,
3941
+ width,
3942
+ height,
3943
+ fill = false,
3944
+ fit = "contain",
3945
+ alt,
3946
+ className,
3947
+ style,
3948
+ "aria-hidden": ariaHidden
3949
+ }) {
3950
+ const [, bump] = React12.useReducer((x) => x + 1, 0);
3951
+ const canvasRef = React12.useRef(null);
3952
+ const sliced = isAtlasAsset(asset);
3953
+ const atlas = sliced ? getAtlas(asset.atlas, bump) : void 0;
3954
+ const img = sliced && asset?.url ? getSheetImage(asset.url, bump) : null;
3955
+ const rect = sliced && atlas ? subRectFor(atlas, asset.sprite) : null;
3956
+ React12.useEffect(() => {
3957
+ const canvas = canvasRef.current;
3958
+ if (!canvas || !img || !rect) return;
3959
+ canvas.width = rect.sw;
3960
+ canvas.height = rect.sh;
3961
+ const ctx = canvas.getContext("2d");
3962
+ if (!ctx) return;
3963
+ ctx.imageSmoothingEnabled = false;
3964
+ ctx.clearRect(0, 0, rect.sw, rect.sh);
3965
+ ctx.drawImage(img, rect.sx, rect.sy, rect.sw, rect.sh, 0, 0, rect.sw, rect.sh);
3966
+ }, [img, rect?.sx, rect?.sy, rect?.sw, rect?.sh]);
3967
+ const w = fill ? "100%" : width ?? size;
3968
+ const h = fill ? "100%" : height ?? size;
3969
+ const boxStyle = {
3970
+ ...fill ? { position: "absolute", inset: 0 } : {},
3971
+ width: w,
3972
+ height: h,
3973
+ objectFit: fit,
3974
+ imageRendering: "pixelated",
3975
+ ...style
3976
+ };
3977
+ if (!asset?.url) return null;
3978
+ if (sliced) {
3979
+ if (!rect || !img) {
3980
+ return /* @__PURE__ */ jsx("span", { "aria-hidden": true, className: cn("inline-block flex-shrink-0", className), style: { ...boxStyle, objectFit: void 0 } });
3981
+ }
3982
+ return /* @__PURE__ */ jsx(
3983
+ "canvas",
3984
+ {
3985
+ ref: canvasRef,
3986
+ role: ariaHidden ? void 0 : "img",
3987
+ "aria-hidden": ariaHidden,
3988
+ "aria-label": ariaHidden ? void 0 : alt ?? asset.name ?? asset.category ?? "",
3989
+ className: cn("flex-shrink-0", className),
3990
+ style: boxStyle
3991
+ }
3992
+ );
3993
+ }
3994
+ return /* @__PURE__ */ jsx(
3995
+ "img",
3996
+ {
3997
+ src: asset.url,
3998
+ alt: alt ?? asset.name ?? asset.category ?? "",
3999
+ "aria-hidden": ariaHidden,
4000
+ ...typeof w === "number" ? { width: w } : {},
4001
+ ...typeof h === "number" ? { height: h } : {},
4002
+ className: cn("flex-shrink-0", className),
4003
+ style: boxStyle
4004
+ }
4005
+ );
4006
+ }
4007
+ AtlasImage.displayName = "AtlasImage";
3870
4008
  var variantStyles2 = {
3871
4009
  primary: [
3872
4010
  "bg-primary text-primary-foreground",
@@ -3939,7 +4077,7 @@ function resolveIconProp(value, sizeClass) {
3939
4077
  const IconComp = value;
3940
4078
  return /* @__PURE__ */ jsx(IconComp, { className: sizeClass });
3941
4079
  }
3942
- if (React11.isValidElement(value)) {
4080
+ if (React12__default.isValidElement(value)) {
3943
4081
  return value;
3944
4082
  }
3945
4083
  if (typeof value === "object" && value !== null && isIconLike(value)) {
@@ -3948,7 +4086,7 @@ function resolveIconProp(value, sizeClass) {
3948
4086
  }
3949
4087
  return value;
3950
4088
  }
3951
- var Button = React11.forwardRef(
4089
+ var Button = React12__default.forwardRef(
3952
4090
  ({
3953
4091
  className,
3954
4092
  variant = "primary",
@@ -3972,7 +4110,7 @@ var Button = React11.forwardRef(
3972
4110
  const leftIconValue = leftIcon || iconProp;
3973
4111
  const rightIconValue = rightIcon || iconRightProp;
3974
4112
  const px = size === "sm" ? 16 : size === "lg" ? 20 : 16;
3975
- const resolvedLeftIcon = iconAsset?.url ? /* @__PURE__ */ jsx("img", { src: iconAsset.url, alt: iconAsset.name ?? iconAsset.category ?? "", width: px, height: px, style: { imageRendering: "pixelated", objectFit: "contain", width: px, height: px }, className: "flex-shrink-0" }) : resolveIconProp(leftIconValue, iconSizeStyles[size]);
4113
+ const resolvedLeftIcon = iconAsset?.url ? /* @__PURE__ */ jsx(AtlasImage, { asset: iconAsset, size: px, alt: iconAsset.name ?? iconAsset.category ?? "", className: "flex-shrink-0" }) : resolveIconProp(leftIconValue, iconSizeStyles[size]);
3976
4114
  const resolvedRightIcon = resolveIconProp(rightIconValue, iconSizeStyles[size]);
3977
4115
  const handleClick = (e) => {
3978
4116
  if (action) {
@@ -4047,7 +4185,7 @@ var sizeStyles2 = {
4047
4185
  md: "px-2.5 py-1 text-sm",
4048
4186
  lg: "px-3 py-1.5 text-base"
4049
4187
  };
4050
- var Badge = React11.forwardRef(
4188
+ var Badge = React12__default.forwardRef(
4051
4189
  ({ className, variant = "default", size = "sm", amount, label, icon, iconAsset, children, onRemove, removeLabel, ...props }, ref) => {
4052
4190
  const iconSizes = {
4053
4191
  sm: "h-icon-default w-icon-default",
@@ -4055,7 +4193,7 @@ var Badge = React11.forwardRef(
4055
4193
  lg: "h-icon-default w-icon-default"
4056
4194
  };
4057
4195
  const iconPx = size === "lg" ? 20 : 16;
4058
- const resolvedIcon = iconAsset?.url ? /* @__PURE__ */ jsx("img", { src: iconAsset.url, alt: iconAsset.name ?? iconAsset.category ?? "", width: iconPx, height: iconPx, style: { imageRendering: "pixelated", objectFit: "contain", width: iconPx, height: iconPx }, className: "flex-shrink-0" }) : typeof icon === "string" ? /* @__PURE__ */ jsx(Icon, { name: icon, className: iconSizes[size] }) : icon ? /* @__PURE__ */ jsx(Icon, { icon, className: iconSizes[size] }) : null;
4196
+ const resolvedIcon = iconAsset?.url ? /* @__PURE__ */ jsx(AtlasImage, { asset: iconAsset, size: iconPx, alt: iconAsset.name ?? iconAsset.category ?? "", className: "flex-shrink-0" }) : typeof icon === "string" ? /* @__PURE__ */ jsx(Icon, { name: icon, className: iconSizes[size] }) : icon ? /* @__PURE__ */ jsx(Icon, { icon, className: iconSizes[size] }) : null;
4059
4197
  return /* @__PURE__ */ jsxs(
4060
4198
  "span",
4061
4199
  {
@@ -4101,7 +4239,7 @@ var sizeStyles3 = {
4101
4239
  md: "h-6 w-6",
4102
4240
  lg: "h-8 w-8"
4103
4241
  };
4104
- var Spinner = React11.forwardRef(
4242
+ var Spinner = React12__default.forwardRef(
4105
4243
  ({ className, size = "md", overlay, ...props }, ref) => {
4106
4244
  if (overlay) {
4107
4245
  return /* @__PURE__ */ jsx(
@@ -4183,7 +4321,7 @@ var lookStyles = {
4183
4321
  chip: "shadow-none rounded-pill border-[length:var(--border-width)] border-border",
4184
4322
  "tile-image-first": "p-0 overflow-hidden"
4185
4323
  };
4186
- var Card = React11.forwardRef(
4324
+ var Card = React12__default.forwardRef(
4187
4325
  ({
4188
4326
  className,
4189
4327
  variant = "bordered",
@@ -4231,9 +4369,9 @@ var Card = React11.forwardRef(
4231
4369
  }
4232
4370
  );
4233
4371
  Card.displayName = "Card";
4234
- var CardHeader = React11.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("div", { ref, className: cn("mb-4", className), ...props }));
4372
+ var CardHeader = React12__default.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("div", { ref, className: cn("mb-4", className), ...props }));
4235
4373
  CardHeader.displayName = "CardHeader";
4236
- var CardTitle = React11.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
4374
+ var CardTitle = React12__default.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
4237
4375
  "h3",
4238
4376
  {
4239
4377
  ref,
@@ -4246,11 +4384,11 @@ var CardTitle = React11.forwardRef(({ className, ...props }, ref) => /* @__PURE_
4246
4384
  }
4247
4385
  ));
4248
4386
  CardTitle.displayName = "CardTitle";
4249
- var CardContent = React11.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("div", { ref, className: cn("", className), ...props }));
4387
+ var CardContent = React12__default.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("div", { ref, className: cn("", className), ...props }));
4250
4388
  CardContent.displayName = "CardContent";
4251
4389
  var CardBody = CardContent;
4252
4390
  CardBody.displayName = "CardBody";
4253
- var CardFooter = React11.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
4391
+ var CardFooter = React12__default.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
4254
4392
  "div",
4255
4393
  {
4256
4394
  ref,
@@ -4342,7 +4480,7 @@ var Center = ({
4342
4480
  as: Component = "div"
4343
4481
  }) => {
4344
4482
  const mergedStyle = minHeight ? { minHeight, ...style } : style;
4345
- return React11.createElement(Component, {
4483
+ return React12__default.createElement(Component, {
4346
4484
  className: cn(
4347
4485
  inline ? "inline-flex" : "flex",
4348
4486
  horizontal && "justify-center",
@@ -4403,7 +4541,7 @@ var paddingClasses = {
4403
4541
  md: "py-16",
4404
4542
  lg: "py-24"
4405
4543
  };
4406
- var ContentSection = React11.forwardRef(
4544
+ var ContentSection = React12__default.forwardRef(
4407
4545
  ({ children, background = "default", padding = "lg", id, className }, ref) => {
4408
4546
  return /* @__PURE__ */ jsx(
4409
4547
  Box,
@@ -5005,7 +5143,7 @@ var StepFlow = ({
5005
5143
  className
5006
5144
  }) => {
5007
5145
  if (orientation === "vertical") {
5008
- return /* @__PURE__ */ jsx(VStack, { gap: "none", className: cn("w-full", className), children: steps.map((step, index) => /* @__PURE__ */ jsx(React11.Fragment, { children: /* @__PURE__ */ jsxs(HStack, { gap: "md", align: "start", className: "w-full", children: [
5146
+ return /* @__PURE__ */ jsx(VStack, { gap: "none", className: cn("w-full", className), children: steps.map((step, index) => /* @__PURE__ */ jsx(React12__default.Fragment, { children: /* @__PURE__ */ jsxs(HStack, { gap: "md", align: "start", className: "w-full", children: [
5009
5147
  /* @__PURE__ */ jsxs(VStack, { gap: "none", align: "center", children: [
5010
5148
  /* @__PURE__ */ jsx(StepCircle, { step, index }),
5011
5149
  showConnectors && index < steps.length - 1 && /* @__PURE__ */ jsx(Box, { className: "w-px h-8 bg-border" })
@@ -5016,7 +5154,7 @@ var StepFlow = ({
5016
5154
  ] })
5017
5155
  ] }) }, index)) });
5018
5156
  }
5019
- return /* @__PURE__ */ jsx(Box, { className: cn("w-full flex flex-col md:flex-row items-start gap-0", className), children: steps.map((step, index) => /* @__PURE__ */ jsxs(React11.Fragment, { children: [
5157
+ return /* @__PURE__ */ jsx(Box, { className: cn("w-full flex flex-col md:flex-row items-start gap-0", className), children: steps.map((step, index) => /* @__PURE__ */ jsxs(React12__default.Fragment, { children: [
5020
5158
  /* @__PURE__ */ jsxs(VStack, { gap: "sm", align: "center", className: "flex-1 w-full md:w-auto", children: [
5021
5159
  /* @__PURE__ */ jsx(StepCircle, { step, index }),
5022
5160
  /* @__PURE__ */ jsx(Typography, { variant: "h4", className: "text-center", children: step.title }),
@@ -5224,8 +5362,8 @@ var Avatar = ({
5224
5362
  actionPayload
5225
5363
  }) => {
5226
5364
  const eventBus = useEventBus();
5227
- const [imgFailed, setImgFailed] = React11.useState(false);
5228
- React11.useEffect(() => {
5365
+ const [imgFailed, setImgFailed] = React12__default.useState(false);
5366
+ React12__default.useEffect(() => {
5229
5367
  setImgFailed(false);
5230
5368
  }, [src]);
5231
5369
  const initials = providedInitials ?? (name ? generateInitials(name) : void 0);
@@ -5616,7 +5754,7 @@ var animatedStyles = {
5616
5754
  "scale-up": { opacity: 1, transform: "scale(1) translateY(0)" },
5617
5755
  "none": {}
5618
5756
  };
5619
- var AnimatedReveal = React11.forwardRef(
5757
+ var AnimatedReveal = React12__default.forwardRef(
5620
5758
  ({
5621
5759
  trigger = "scroll",
5622
5760
  animation = "fade-up",
@@ -5769,7 +5907,7 @@ function applyMorphAnimation(container, animate, duration, delay, easing) {
5769
5907
  el.style.opacity = animate ? "1" : "0";
5770
5908
  });
5771
5909
  }
5772
- var AnimatedGraphic = React11.forwardRef(
5910
+ var AnimatedGraphic = React12__default.forwardRef(
5773
5911
  ({
5774
5912
  src,
5775
5913
  svgContent,
@@ -5792,7 +5930,7 @@ var AnimatedGraphic = React11.forwardRef(
5792
5930
  const fetchedSvg = useFetchedSvg(svgContent ? void 0 : src);
5793
5931
  const resolvedSvg = svgContent ?? fetchedSvg;
5794
5932
  const prevAnimateRef = useRef(animate);
5795
- const setRef = React11.useCallback(
5933
+ const setRef = React12__default.useCallback(
5796
5934
  (node) => {
5797
5935
  containerRef.current = node;
5798
5936
  if (typeof ref === "function") ref(node);