@almadar/ui 2.11.3 → 2.11.5

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.
@@ -2826,17 +2826,19 @@ function ScoreDisplay({
2826
2826
  size = "md",
2827
2827
  className,
2828
2828
  animated = true,
2829
- locale = "en-US"
2829
+ locale = "en-US",
2830
+ ...rest
2830
2831
  }) {
2831
- const [displayValue, setDisplayValue] = React80.useState(value);
2832
+ const resolvedValue = typeof value === "number" && !Number.isNaN(value) ? value : typeof rest.score === "number" && !Number.isNaN(rest.score) ? rest.score : 0;
2833
+ const [displayValue, setDisplayValue] = React80.useState(resolvedValue);
2832
2834
  const [isAnimating, setIsAnimating] = React80.useState(false);
2833
2835
  React80.useEffect(() => {
2834
- if (!animated || displayValue === value) {
2835
- setDisplayValue(value);
2836
+ if (!animated || displayValue === resolvedValue) {
2837
+ setDisplayValue(resolvedValue);
2836
2838
  return;
2837
2839
  }
2838
2840
  setIsAnimating(true);
2839
- const diff = value - displayValue;
2841
+ const diff = resolvedValue - displayValue;
2840
2842
  const steps = Math.min(Math.abs(diff), 20);
2841
2843
  const increment = diff / steps;
2842
2844
  let current = displayValue;
@@ -2847,12 +2849,12 @@ function ScoreDisplay({
2847
2849
  setDisplayValue(Math.round(current));
2848
2850
  if (step >= steps) {
2849
2851
  clearInterval(timer);
2850
- setDisplayValue(value);
2852
+ setDisplayValue(resolvedValue);
2851
2853
  setIsAnimating(false);
2852
2854
  }
2853
2855
  }, 50);
2854
2856
  return () => clearInterval(timer);
2855
- }, [value, animated]);
2857
+ }, [resolvedValue, animated]);
2856
2858
  const formattedValue = new Intl.NumberFormat(locale).format(displayValue);
2857
2859
  return /* @__PURE__ */ jsxs(
2858
2860
  "div",
@@ -10416,7 +10418,7 @@ function IsometricCanvas({
10416
10418
  if (url) urls.push(url);
10417
10419
  }
10418
10420
  }
10419
- urls.push(...effectSpriteUrls);
10421
+ if (effectSpriteUrls) urls.push(...effectSpriteUrls);
10420
10422
  if (backgroundImage) urls.push(backgroundImage);
10421
10423
  return [...new Set(urls.filter(Boolean))];
10422
10424
  }, [sortedTiles, features, units, getTerrainSprite, getFeatureSprite, getUnitSprite, effectSpriteUrls, backgroundImage, assetManifest, resolveManifestUrl]);
@@ -11901,7 +11903,7 @@ function useSafeEventBus7() {
11901
11903
  }
11902
11904
  }
11903
11905
  var Lightbox = ({
11904
- images,
11906
+ images = [],
11905
11907
  currentIndex = 0,
11906
11908
  isOpen = false,
11907
11909
  showCounter = true,
@@ -11910,6 +11912,7 @@ var Lightbox = ({
11910
11912
  onIndexChange,
11911
11913
  className
11912
11914
  }) => {
11915
+ const safeImages = Array.isArray(images) ? images : [];
11913
11916
  const [index, setIndex] = useState(currentIndex);
11914
11917
  const [touchStartX, setTouchStartX] = useState(null);
11915
11918
  const eventBus = useSafeEventBus7();
@@ -11924,11 +11927,12 @@ var Lightbox = ({
11924
11927
  }, [closeAction, eventBus, onClose]);
11925
11928
  const goTo = useCallback(
11926
11929
  (newIndex) => {
11927
- const clamped = Math.max(0, Math.min(images.length - 1, newIndex));
11930
+ if (safeImages.length === 0) return;
11931
+ const clamped = Math.max(0, Math.min(safeImages.length - 1, newIndex));
11928
11932
  setIndex(clamped);
11929
11933
  onIndexChange?.(clamped);
11930
11934
  },
11931
- [images.length, onIndexChange]
11935
+ [safeImages.length, onIndexChange]
11932
11936
  );
11933
11937
  const goPrev = useCallback(() => goTo(index - 1), [goTo, index]);
11934
11938
  const goNext = useCallback(() => goTo(index + 1), [goTo, index]);
@@ -11958,10 +11962,10 @@ var Lightbox = ({
11958
11962
  };
11959
11963
  }
11960
11964
  }, [isOpen]);
11961
- if (!isOpen || images.length === 0) return null;
11962
- const currentImage = images[index];
11965
+ if (!isOpen || safeImages.length === 0) return null;
11966
+ const currentImage = safeImages[index];
11963
11967
  const hasPrev = index > 0;
11964
- const hasNext = index < images.length - 1;
11968
+ const hasNext = index < safeImages.length - 1;
11965
11969
  const handleTouchStart = (e) => {
11966
11970
  setTouchStartX(e.touches[0].clientX);
11967
11971
  };
@@ -12005,7 +12009,7 @@ var Lightbox = ({
12005
12009
  children: /* @__PURE__ */ jsx(X, { className: "w-6 h-6" })
12006
12010
  }
12007
12011
  ),
12008
- hasPrev && images.length > 1 && /* @__PURE__ */ jsx(
12012
+ hasPrev && safeImages.length > 1 && /* @__PURE__ */ jsx(
12009
12013
  "button",
12010
12014
  {
12011
12015
  type: "button",
@@ -12042,7 +12046,7 @@ var Lightbox = ({
12042
12046
  )
12043
12047
  }
12044
12048
  ),
12045
- hasNext && images.length > 1 && /* @__PURE__ */ jsx(
12049
+ hasNext && safeImages.length > 1 && /* @__PURE__ */ jsx(
12046
12050
  "button",
12047
12051
  {
12048
12052
  type: "button",
@@ -12062,10 +12066,10 @@ var Lightbox = ({
12062
12066
  }
12063
12067
  ),
12064
12068
  /* @__PURE__ */ jsxs("div", { className: "absolute bottom-4 left-0 right-0 text-center", children: [
12065
- showCounter && images.length > 1 && /* @__PURE__ */ jsxs("div", { className: "text-white text-sm mb-1", children: [
12069
+ showCounter && safeImages.length > 1 && /* @__PURE__ */ jsxs("div", { className: "text-white text-sm mb-1", children: [
12066
12070
  index + 1,
12067
12071
  " of ",
12068
- images.length
12072
+ safeImages.length
12069
12073
  ] }),
12070
12074
  currentImage?.caption && /* @__PURE__ */ jsx("div", { className: "text-white text-sm opacity-80 px-8", children: currentImage.caption })
12071
12075
  ] })
@@ -1,4 +1,4 @@
1
- import { SuspenseConfigProvider } from './chunk-D54SBLJJ.js';
1
+ import { SuspenseConfigProvider } from './chunk-4LBNLALH.js';
2
2
  import { ThemeProvider } from './chunk-DKQN5FVU.js';
3
3
  import { SelectionProvider, EntityDataProvider } from './chunk-WGJIL4YR.js';
4
4
  import { useEventBus, EventBusProvider } from './chunk-YXZM3WCF.js';
@@ -1079,7 +1079,7 @@ interface ScoreDisplayProps {
1079
1079
  /** Number formatting locale */
1080
1080
  locale?: string;
1081
1081
  }
1082
- declare function ScoreDisplay({ value, label, icon, size, className, animated, locale, }: ScoreDisplayProps): react_jsx_runtime.JSX.Element;
1082
+ declare function ScoreDisplay({ value, label, icon, size, className, animated, locale, ...rest }: ScoreDisplayProps & Record<string, unknown>): react_jsx_runtime.JSX.Element;
1083
1083
  declare namespace ScoreDisplay {
1084
1084
  var displayName: string;
1085
1085
  }
@@ -4,8 +4,8 @@ export { ENTITY_EVENTS, useAgentChat, useAuthContext, useCompile, useConnectGitH
4
4
  export { clearEntities, getAllEntities, getByType, getEntity, getSingleton, removeEntity, spawnEntity, updateEntity, updateSingleton } from '../chunk-N7MVUW4R.js';
5
5
  import { subscribeToTraitChanges, getAllTraits } from '../chunk-42YQ6JVR.js';
6
6
  import '../chunk-3HJHHULT.js';
7
- import { VStack, HStack, Typography, Button, Icon, Box, Card, Avatar, Badge, SearchInput, Checkbox, Menu as Menu$1, Pagination, LoadingState, EmptyState, Modal, ErrorState, QuizBlock, CodeBlock, ScaledDiagram, MarkdownContent, Divider, ProgressBar, isoToScreen, IsometricCanvas_default, Stack, Select, Drawer, Toast, Tabs, Input, ThemeToggle, TILE_WIDTH, EntityDisplayEvents, StateIndicator, Accordion, ButtonGroup, Container } from '../chunk-D54SBLJJ.js';
8
- export { ALL_PRESETS, Accordion, ActionButton, ActionButtons, Card2 as ActionCard, Alert, AnimatedCounter, Avatar, Badge, Box, Breadcrumb, Button, ButtonGroup, CalendarGrid, CanvasEffect, Card, CardBody, CardContent, CardFooter, CardGrid, CardHeader, CardTitle, Carousel, Center, Chart, ChartLegend, Checkbox, ChoiceButton, CodeBlock, CombatLog, ComboCounter, ConditionalWrapper, ConfettiEffect, Container, ControlButton, CraftingRecipe, DIAMOND_TOP_Y, DPad, DamageNumber, DataGrid, DataList, DataTable, DateRangeSelector, DayCell, DetailPanel, DialogueBox, DialogueBubble, Divider, Drawer, EmptyState, EnemyPlate, EntityDisplayEvents, ErrorBoundary, ErrorState, FEATURE_COLORS, FLOOR_HEIGHT, FilterGroup, Flex, FlipCard, FlipContainer, FloatingActionButton, Form, FormField, FormSectionHeader, GameCanvas2D, GameHud, GameMenu, GameOverScreen, GraphView, Grid, HStack, Heading, HealthBar, HealthPanel, Icon, InfiniteScrollSentinel, Input, InputGroup, InventoryGrid, InventoryPanel, IsometricCanvas, ItemSlot, Label, LawReferenceTooltip, Lightbox, LineChart, LoadingState, MapView, MarkdownContent, MasterDetail, Menu, Meter, MiniMap, Modal, NumberStepper, Overlay, PageHeader, Pagination, PlatformerCanvas, Popover, PowerupSlots, ProgressBar, ProgressDots, PullToRefresh, QuestTracker, QuizBlock, Radio, RangeSlider, RelationSelect, RepeatableFormSection, ResourceBar, ResourceCounter, ScaledDiagram, ScoreBoard, ScoreDisplay, SearchInput, Select, SidePanel, SimpleGrid, SimulationCanvas, SimulationControls, SimulationGraph, Skeleton, SlotContentRenderer, SortableList, Spacer, Spinner, Sprite, Stack, StarRating, StatBadge, StatCard, StatDisplay, StateIndicator, StatusDot, StatusEffect, SwipeableRow, Switch, TILE_HEIGHT, TILE_WIDTH, Tabs, Text, TextHighlight, Textarea, ThemeSelector, ThemeToggle, TimeSlotCell, TimerDisplay, Toast, Tooltip, TrendIndicator, TurnIndicator, TurnPanel, TypewriterText, Typography, UISlotComponent, UISlotRenderer, UnitCommandBar, UploadDropZone, VStack, ViolationAlert, WaypointMarker, WizardNavigation, WizardProgress, XPBar, drawSprite, isoToScreen, pendulum, projectileMotion, screenToIso, springOscillator, useCamera, useImageCache } from '../chunk-D54SBLJJ.js';
7
+ import { VStack, HStack, Typography, Button, Icon, Box, Card, Avatar, Badge, SearchInput, Checkbox, Menu as Menu$1, Pagination, LoadingState, EmptyState, Modal, ErrorState, QuizBlock, CodeBlock, ScaledDiagram, MarkdownContent, Divider, ProgressBar, isoToScreen, IsometricCanvas_default, Stack, Select, Drawer, Toast, Tabs, Input, ThemeToggle, TILE_WIDTH, EntityDisplayEvents, StateIndicator, Accordion, ButtonGroup, Container } from '../chunk-4LBNLALH.js';
8
+ export { ALL_PRESETS, Accordion, ActionButton, ActionButtons, Card2 as ActionCard, Alert, AnimatedCounter, Avatar, Badge, Box, Breadcrumb, Button, ButtonGroup, CalendarGrid, CanvasEffect, Card, CardBody, CardContent, CardFooter, CardGrid, CardHeader, CardTitle, Carousel, Center, Chart, ChartLegend, Checkbox, ChoiceButton, CodeBlock, CombatLog, ComboCounter, ConditionalWrapper, ConfettiEffect, Container, ControlButton, CraftingRecipe, DIAMOND_TOP_Y, DPad, DamageNumber, DataGrid, DataList, DataTable, DateRangeSelector, DayCell, DetailPanel, DialogueBox, DialogueBubble, Divider, Drawer, EmptyState, EnemyPlate, EntityDisplayEvents, ErrorBoundary, ErrorState, FEATURE_COLORS, FLOOR_HEIGHT, FilterGroup, Flex, FlipCard, FlipContainer, FloatingActionButton, Form, FormField, FormSectionHeader, GameCanvas2D, GameHud, GameMenu, GameOverScreen, GraphView, Grid, HStack, Heading, HealthBar, HealthPanel, Icon, InfiniteScrollSentinel, Input, InputGroup, InventoryGrid, InventoryPanel, IsometricCanvas, ItemSlot, Label, LawReferenceTooltip, Lightbox, LineChart, LoadingState, MapView, MarkdownContent, MasterDetail, Menu, Meter, MiniMap, Modal, NumberStepper, Overlay, PageHeader, Pagination, PlatformerCanvas, Popover, PowerupSlots, ProgressBar, ProgressDots, PullToRefresh, QuestTracker, QuizBlock, Radio, RangeSlider, RelationSelect, RepeatableFormSection, ResourceBar, ResourceCounter, ScaledDiagram, ScoreBoard, ScoreDisplay, SearchInput, Select, SidePanel, SimpleGrid, SimulationCanvas, SimulationControls, SimulationGraph, Skeleton, SlotContentRenderer, SortableList, Spacer, Spinner, Sprite, Stack, StarRating, StatBadge, StatCard, StatDisplay, StateIndicator, StatusDot, StatusEffect, SwipeableRow, Switch, TILE_HEIGHT, TILE_WIDTH, Tabs, Text, TextHighlight, Textarea, ThemeSelector, ThemeToggle, TimeSlotCell, TimerDisplay, Toast, Tooltip, TrendIndicator, TurnIndicator, TurnPanel, TypewriterText, Typography, UISlotComponent, UISlotRenderer, UnitCommandBar, UploadDropZone, VStack, ViolationAlert, WaypointMarker, WizardNavigation, WizardProgress, XPBar, drawSprite, isoToScreen, pendulum, projectileMotion, screenToIso, springOscillator, useCamera, useImageCache } from '../chunk-4LBNLALH.js';
9
9
  import '../chunk-DKQN5FVU.js';
10
10
  import { useTranslate } from '../chunk-WGJIL4YR.js';
11
11
  export { EntityDataProvider, I18nProvider, createTranslate, entityDataKeys, parseQueryBinding, useDragReorder, useEntity, useEntityDataAdapter, useEntityDetail, useEntityList, useEntityListSuspense, useEntitySuspense, useInfiniteScroll, useLongPress, usePullToRefresh, useQuerySingleton, useSwipeGesture, useTranslate } from '../chunk-WGJIL4YR.js';
@@ -1,5 +1,5 @@
1
- export { FetchedDataContext, FetchedDataProvider, OfflineModeProvider, OrbitalProvider, VerificationProvider, useFetchedData, useFetchedDataContext, useFetchedEntity, useOfflineMode, useOptionalOfflineMode } from '../chunk-SSJZTICC.js';
2
- import '../chunk-D54SBLJJ.js';
1
+ export { FetchedDataContext, FetchedDataProvider, OfflineModeProvider, OrbitalProvider, VerificationProvider, useFetchedData, useFetchedDataContext, useFetchedEntity, useOfflineMode, useOptionalOfflineMode } from '../chunk-A2NPH2P3.js';
2
+ import '../chunk-4LBNLALH.js';
3
3
  import '../chunk-DKQN5FVU.js';
4
4
  export { SelectionContext, SelectionProvider, useSelection, useSelectionOptional } from '../chunk-WGJIL4YR.js';
5
5
  export { EventBusContext, EventBusProvider } from '../chunk-YXZM3WCF.js';
@@ -2,8 +2,8 @@ import '../chunk-GTIAVPI5.js';
2
2
  import '../chunk-N7MVUW4R.js';
3
3
  import { registerTrait, unregisterTrait, updateTraitState } from '../chunk-42YQ6JVR.js';
4
4
  import '../chunk-3HJHHULT.js';
5
- import { useFetchedDataContext } from '../chunk-SSJZTICC.js';
6
- import '../chunk-D54SBLJJ.js';
5
+ import { useFetchedDataContext } from '../chunk-A2NPH2P3.js';
6
+ import '../chunk-4LBNLALH.js';
7
7
  import '../chunk-DKQN5FVU.js';
8
8
  import '../chunk-WGJIL4YR.js';
9
9
  import { useEventBus } from '../chunk-YXZM3WCF.js';
@@ -193,7 +193,14 @@ function useTraitStateMachine(traitBindings, slotsActions, options) {
193
193
  );
194
194
  const linkedEntity = binding.linkedEntity || "";
195
195
  const entityId = payload?.entityId;
196
- const entityData = linkedEntity && entityId && fetchedDataContext ? fetchedDataContext.getById(linkedEntity, entityId) || {} : payload || {};
196
+ const entityData = (() => {
197
+ if (!linkedEntity || !fetchedDataContext) return payload || {};
198
+ if (entityId) {
199
+ return fetchedDataContext.getById(linkedEntity, entityId) || {};
200
+ }
201
+ const records = fetchedDataContext.getData(linkedEntity);
202
+ return records[0] || payload || {};
203
+ })();
197
204
  const pendingSlots = /* @__PURE__ */ new Map();
198
205
  const slotSource = {
199
206
  trait: binding.trait.name,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@almadar/ui",
3
- "version": "2.11.3",
3
+ "version": "2.11.5",
4
4
  "description": "React UI components, hooks, and providers for Almadar",
5
5
  "type": "module",
6
6
  "main": "./dist/components/index.js",