@almadar/ui 5.14.1 → 5.16.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.
@@ -10086,13 +10086,13 @@ var init_MapView = __esm({
10086
10086
  shadowSize: [41, 41]
10087
10087
  });
10088
10088
  L.Marker.prototype.options.icon = defaultIcon;
10089
- const { useEffect: useEffect70, useRef: useRef65, useCallback: useCallback114, useState: useState103 } = React85__default;
10089
+ const { useEffect: useEffect71, useRef: useRef66, useCallback: useCallback114, useState: useState103 } = React85__default;
10090
10090
  const { Typography: Typography2 } = await Promise.resolve().then(() => (init_Typography(), Typography_exports));
10091
10091
  const { useEventBus: useEventBus2 } = await Promise.resolve().then(() => (init_useEventBus(), useEventBus_exports));
10092
10092
  function MapUpdater({ centerLat, centerLng, zoom }) {
10093
10093
  const map = useMap();
10094
- const prevRef = useRef65({ centerLat, centerLng, zoom });
10095
- useEffect70(() => {
10094
+ const prevRef = useRef66({ centerLat, centerLng, zoom });
10095
+ useEffect71(() => {
10096
10096
  const prev = prevRef.current;
10097
10097
  if (prev.centerLat !== centerLat || prev.centerLng !== centerLng || prev.zoom !== zoom) {
10098
10098
  map.setView([centerLat, centerLng], zoom);
@@ -10103,7 +10103,7 @@ var init_MapView = __esm({
10103
10103
  }
10104
10104
  function MapClickHandler({ onMapClick }) {
10105
10105
  const map = useMap();
10106
- useEffect70(() => {
10106
+ useEffect71(() => {
10107
10107
  if (!onMapClick) return;
10108
10108
  const handler = (e) => {
10109
10109
  onMapClick(e.latlng.lat, e.latlng.lng);
@@ -22286,6 +22286,21 @@ var init_DashboardLayout = __esm({
22286
22286
  };
22287
22287
  const [sidebarOpen, setSidebarOpen] = useState(false);
22288
22288
  const [userMenuOpen, setUserMenuOpen] = useState(false);
22289
+ const layoutRef = useRef(null);
22290
+ const [isMobile, setIsMobile] = useState(false);
22291
+ useEffect(() => {
22292
+ const el = layoutRef.current;
22293
+ if (!el || typeof ResizeObserver === "undefined") return;
22294
+ const ro = new ResizeObserver((entries) => {
22295
+ const w = entries[0]?.contentRect.width ?? el.clientWidth;
22296
+ setIsMobile(w < 1024);
22297
+ });
22298
+ ro.observe(el);
22299
+ return () => ro.disconnect();
22300
+ }, []);
22301
+ useEffect(() => {
22302
+ if (!isMobile && sidebarOpen) setSidebarOpen(false);
22303
+ }, [isMobile, sidebarOpen]);
22289
22304
  const location = useLocation();
22290
22305
  const ctxPagePath = useCurrentPagePath();
22291
22306
  const activePath = currentPath ?? ctxPagePath ?? location.pathname;
@@ -22298,15 +22313,15 @@ var init_DashboardLayout = __esm({
22298
22313
  const showBottomNav = layoutMode === "bottomnav";
22299
22314
  const isTopNav = layoutMode === "topnav";
22300
22315
  return /* @__PURE__ */ jsxs(
22301
- HStack,
22316
+ Box,
22302
22317
  {
22303
- gap: "none",
22304
- className: "@container/dashboard min-h-screen w-full bg-background dark:bg-background items-stretch",
22318
+ ref: layoutRef,
22319
+ className: "@container/dashboard min-h-screen w-full bg-background dark:bg-background flex flex-row items-stretch",
22305
22320
  children: [
22306
- showSidebar && sidebarOpen && /* @__PURE__ */ jsx(
22321
+ showSidebar && isMobile && sidebarOpen && /* @__PURE__ */ jsx(
22307
22322
  Box,
22308
22323
  {
22309
- className: "fixed inset-0 bg-foreground/50 dark:bg-foreground/70 z-20 @lg/dashboard:hidden",
22324
+ className: "fixed inset-0 bg-foreground/50 dark:bg-foreground/70 z-20",
22310
22325
  onClick: () => setSidebarOpen(false)
22311
22326
  }
22312
22327
  ),
@@ -22316,11 +22331,16 @@ var init_DashboardLayout = __esm({
22316
22331
  as: "aside",
22317
22332
  className: cn(
22318
22333
  "z-30 w-64 flex-shrink-0 bg-card dark:bg-card border-r border-border dark:border-border",
22319
- "fixed inset-y-0 left-0 @lg/dashboard:static @lg/dashboard:translate-x-0 @lg/dashboard:h-auto",
22320
- "transform transition-transform duration-200 ease-in-out",
22321
- "flex flex-col",
22322
- sidebarOpen ? "translate-x-0" : "-translate-x-full"
22334
+ "flex flex-col"
22323
22335
  ),
22336
+ style: isMobile ? {
22337
+ position: "fixed",
22338
+ top: 0,
22339
+ bottom: 0,
22340
+ left: 0,
22341
+ transform: sidebarOpen ? "translateX(0)" : "translateX(-100%)",
22342
+ transition: "transform 200ms ease-in-out"
22343
+ } : { position: "static", transform: "none" },
22324
22344
  children: [
22325
22345
  /* @__PURE__ */ jsxs(
22326
22346
  HStack,
@@ -22349,11 +22369,11 @@ var init_DashboardLayout = __esm({
22349
22369
  }
22350
22370
  )
22351
22371
  ] }),
22352
- /* @__PURE__ */ jsx(
22372
+ isMobile && /* @__PURE__ */ jsx(
22353
22373
  Button,
22354
22374
  {
22355
22375
  variant: "ghost",
22356
- className: "@lg/dashboard:hidden p-2 rounded-md hover:bg-muted dark:hover:bg-muted text-muted-foreground dark:text-muted-foreground",
22376
+ className: "p-2 rounded-md hover:bg-muted dark:hover:bg-muted text-muted-foreground dark:text-muted-foreground",
22357
22377
  onClick: () => setSidebarOpen(false),
22358
22378
  children: /* @__PURE__ */ jsx(Icon, { name: "x", className: "h-5 w-5" })
22359
22379
  }
@@ -22394,11 +22414,11 @@ var init_DashboardLayout = __esm({
22394
22414
  justify: "between",
22395
22415
  className: "h-full px-3 @sm/dashboard:px-4 gap-2 @sm/dashboard:gap-4",
22396
22416
  children: [
22397
- showSidebar && /* @__PURE__ */ jsx(
22417
+ showSidebar && isMobile && /* @__PURE__ */ jsx(
22398
22418
  Button,
22399
22419
  {
22400
22420
  variant: "ghost",
22401
- className: "@lg/dashboard:hidden p-2 rounded-md hover:bg-muted dark:hover:bg-muted text-muted-foreground dark:text-muted-foreground touch-manipulation min-h-[44px] min-w-[44px] flex items-center justify-center",
22421
+ className: "p-2 rounded-md hover:bg-muted dark:hover:bg-muted text-muted-foreground dark:text-muted-foreground touch-manipulation min-h-[44px] min-w-[44px] flex items-center justify-center",
22402
22422
  onClick: () => setSidebarOpen(true),
22403
22423
  "aria-label": "Open sidebar",
22404
22424
  children: /* @__PURE__ */ jsx(Icon, { name: "menu", className: "h-5 w-5" })
@@ -47203,7 +47223,7 @@ function getToastPosition(position) {
47203
47223
  return "top-4 right-4";
47204
47224
  }
47205
47225
  }
47206
- function renderPatternChildren(children, onDismiss, parentId = "root", parentPath = "root", sourceTrait) {
47226
+ function renderPatternChildren(children, onDismiss, parentId = "root", parentPath = "root", sourceTrait, orbCtx) {
47207
47227
  if (children === void 0 || children === null) return null;
47208
47228
  const childrenArray = Array.isArray(children) ? children : typeof children === "string" || typeof children === "object" && "type" in children ? [children] : [];
47209
47229
  if (childrenArray.length === 0) return null;
@@ -47234,8 +47254,11 @@ function renderPatternChildren(children, onDismiss, parentId = "root", parentPat
47234
47254
  nodeId: child._id,
47235
47255
  // Inherit sourceTrait from the parent slot so nested patterns
47236
47256
  // (e.g. form-section inside a stack) can resolve entityDef via
47237
- // the trait's linkedEntity for form-field enrichment.
47238
- ...sourceTrait !== void 0 && { sourceTrait }
47257
+ // the trait's linkedEntity for form-field enrichment. The orbCtx
47258
+ // (slot/transition/state/entity) propagates the same way so every
47259
+ // nested node carries a complete contextual-edit address.
47260
+ ...sourceTrait !== void 0 && { sourceTrait },
47261
+ ...orbCtx ?? {}
47239
47262
  };
47240
47263
  return /* @__PURE__ */ jsx(
47241
47264
  SlotContentRenderer,
@@ -47351,7 +47374,12 @@ function SlotContentRenderer({
47351
47374
  const isSingleChild = typeof childrenConfig === "string" || typeof childrenConfig === "object" && childrenConfig !== null && !Array.isArray(childrenConfig) && "type" in childrenConfig;
47352
47375
  const hasChildren = PATTERNS_WITH_CHILDREN.has(content.pattern) || Array.isArray(childrenConfig) && childrenConfig.length > 0 || isSingleChild;
47353
47376
  const myPath = patternPath ?? "root";
47354
- const renderedChildren = hasChildren ? renderPatternChildren(childrenConfig, onDismiss, content.id, myPath, content.sourceTrait) : void 0;
47377
+ const renderedChildren = hasChildren ? renderPatternChildren(childrenConfig, onDismiss, content.id, myPath, content.sourceTrait, {
47378
+ slot: content.slot,
47379
+ transitionEvent: content.transitionEvent,
47380
+ fromState: content.fromState,
47381
+ entity: content.entity
47382
+ }) : void 0;
47355
47383
  const incomingChildren = content.props.children;
47356
47384
  const childrenIsRenderFn = typeof incomingChildren === "function";
47357
47385
  const { children: _childrenConfig, ...restPropsNoChildren } = content.props;
@@ -47398,6 +47426,13 @@ function SlotContentRenderer({
47398
47426
  "data-pattern-path": myPath,
47399
47427
  "data-pattern-type": content.pattern,
47400
47428
  "data-accepts-children": acceptsChildren ? "true" : void 0,
47429
+ "data-orb-trait": content.sourceTrait,
47430
+ "data-orb-slot": content.slot,
47431
+ "data-orb-transition": content.transitionEvent,
47432
+ "data-orb-state": content.fromState,
47433
+ "data-orb-entity": content.entity,
47434
+ "data-orb-path": myPath,
47435
+ "data-orb-pattern": content.pattern,
47401
47436
  children: renderedChildren !== void 0 ? /* @__PURE__ */ jsx(PatternComponent, { ...finalProps, children: renderedChildren }) : /* @__PURE__ */ jsx(PatternComponent, { ...finalProps })
47402
47437
  }
47403
47438
  );
@@ -47410,6 +47445,13 @@ function SlotContentRenderer({
47410
47445
  "data-id": content.id,
47411
47446
  "data-node-id": content.nodeId,
47412
47447
  "data-source-trait": content.sourceTrait,
47448
+ "data-orb-trait": content.sourceTrait,
47449
+ "data-orb-slot": content.slot,
47450
+ "data-orb-transition": content.transitionEvent,
47451
+ "data-orb-state": content.fromState,
47452
+ "data-orb-entity": content.entity,
47453
+ "data-orb-path": patternPath ?? "root",
47454
+ "data-orb-pattern": content.pattern,
47413
47455
  children: content.props.children ?? /* @__PURE__ */ jsxs(Box, { className: "p-4 text-sm text-muted-foreground border border-dashed border-border rounded", children: [
47414
47456
  "Unknown pattern: ",
47415
47457
  content.pattern,
@@ -47763,7 +47805,7 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
47763
47805
  embeddedTraitsRef.current = options?.embeddedTraits;
47764
47806
  }, [options?.embeddedTraits]);
47765
47807
  const flushSlot = useCallback(
47766
- (traitName, slot, patterns) => {
47808
+ (traitName, slot, patterns, source) => {
47767
47809
  const slots = uiSlotsRef.current;
47768
47810
  const embedded = embeddedTraitsRef.current;
47769
47811
  if (patterns.length === 0) {
@@ -47792,7 +47834,10 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
47792
47834
  pattern: patternType,
47793
47835
  props,
47794
47836
  priority: 0,
47795
- animation: "fade"
47837
+ animation: "fade",
47838
+ transitionEvent: source?.event,
47839
+ fromState: source?.state,
47840
+ entity: source?.entity
47796
47841
  });
47797
47842
  return;
47798
47843
  }
@@ -47806,7 +47851,10 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
47806
47851
  target: slot,
47807
47852
  pattern: patternType,
47808
47853
  props,
47809
- sourceTrait: traitName
47854
+ sourceTrait: traitName,
47855
+ transitionEvent: source?.event,
47856
+ fromState: source?.state,
47857
+ entity: source?.entity
47810
47858
  });
47811
47859
  },
47812
47860
  []
@@ -47939,7 +47987,11 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
47939
47987
  }
47940
47988
  }
47941
47989
  for (const [slot, patterns] of pendingSlots) {
47942
- flushSlot(binding.trait.name, slot, patterns);
47990
+ flushSlot(binding.trait.name, slot, patterns, {
47991
+ event: `tick:${tick.name}`,
47992
+ state: currentState,
47993
+ entity: binding.linkedEntity
47994
+ });
47943
47995
  }
47944
47996
  }, [flushSlot]);
47945
47997
  useEffect(() => {
@@ -48191,7 +48243,11 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
48191
48243
  transition: `${result.previousState}->${result.newState}`,
48192
48244
  cleared: patterns.length === 0
48193
48245
  });
48194
- flushSlot(traitName, slot, patterns);
48246
+ flushSlot(traitName, slot, patterns, {
48247
+ event: eventKey,
48248
+ state: result.previousState,
48249
+ entity: binding.linkedEntity
48250
+ });
48195
48251
  }
48196
48252
  } catch (error) {
48197
48253
  stateLog.error("transition:effect-error", {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@almadar/ui",
3
- "version": "5.14.1",
3
+ "version": "5.16.1",
4
4
  "description": "React UI components, hooks, and providers for Almadar",
5
5
  "type": "module",
6
6
  "sideEffects": [
@@ -129,7 +129,7 @@
129
129
  "typecheck": "tsc --noEmit"
130
130
  },
131
131
  "dependencies": {
132
- "@almadar/core": ">=9.8.0",
132
+ "@almadar/core": ">=9.10.0",
133
133
  "@almadar/evaluator": ">=2.9.2",
134
134
  "@almadar/logger": "^1.3.0",
135
135
  "@almadar/patterns": ">=2.35.0",