@almadar/ui 5.125.0 → 5.127.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.
@@ -14413,6 +14413,32 @@ var init_ButtonGroup = __esm({
14413
14413
  ButtonGroup.displayName = "ButtonGroup";
14414
14414
  }
14415
14415
  });
14416
+
14417
+ // lib/getNestedValue.ts
14418
+ function getNestedValue(obj, path) {
14419
+ if (obj === null || obj === void 0 || !path) {
14420
+ return void 0;
14421
+ }
14422
+ if (!path.includes(".")) {
14423
+ return obj[path];
14424
+ }
14425
+ const parts = path.split(".");
14426
+ let value = obj;
14427
+ for (const part of parts) {
14428
+ if (value === null || value === void 0) {
14429
+ return void 0;
14430
+ }
14431
+ if (typeof value !== "object" || Array.isArray(value)) {
14432
+ return void 0;
14433
+ }
14434
+ value = value[part];
14435
+ }
14436
+ return value;
14437
+ }
14438
+ var init_getNestedValue = __esm({
14439
+ "lib/getNestedValue.ts"() {
14440
+ }
14441
+ });
14416
14442
  function useSwipeGesture(callbacks, options = {}) {
14417
14443
  const { threshold = 50, velocityThreshold = 0.3, preventDefault = false } = options;
14418
14444
  const startX = useRef(0);
@@ -14526,17 +14552,31 @@ function getWeekDays(start) {
14526
14552
  }
14527
14553
  return days;
14528
14554
  }
14529
- function generateDefaultTimeSlots() {
14555
+ function eventStartDate(event, startField) {
14556
+ const raw = getNestedValue(event, startField);
14557
+ return new Date(raw ?? "");
14558
+ }
14559
+ function generateDefaultTimeSlots(events2, startField) {
14560
+ let first = DEFAULT_FIRST_HOUR;
14561
+ let last = DEFAULT_LAST_HOUR;
14562
+ for (const ev of events2) {
14563
+ const start = eventStartDate(ev, startField);
14564
+ if (Number.isNaN(start.getTime())) continue;
14565
+ const hour = start.getHours();
14566
+ if (hour < first) first = hour;
14567
+ if (hour > last) last = hour;
14568
+ }
14530
14569
  const slots = [];
14531
- for (let hour = 9; hour <= 17; hour++) {
14532
- slots.push(`${hour.toString().padStart(2, "0")}:00`);
14570
+ for (let hour = first; hour <= last; hour++) {
14571
+ slots.push(slotLabel(hour));
14533
14572
  }
14534
14573
  return slots;
14535
14574
  }
14536
- function eventInSlot(event, day, slotTime) {
14537
- const eventStart = new Date(event.startTime);
14538
- const [slotHour, slotMinute] = slotTime.split(":").map(Number);
14539
- return eventStart.toDateString() === day.toDateString() && eventStart.getHours() === slotHour && eventStart.getMinutes() === slotMinute;
14575
+ function eventInSlot(event, day, slotTime, startField) {
14576
+ const eventStart = eventStartDate(event, startField);
14577
+ if (Number.isNaN(eventStart.getTime())) return false;
14578
+ const [slotHour] = slotTime.split(":").map(Number);
14579
+ return eventStart.toDateString() === day.toDateString() && eventStart.getHours() === slotHour;
14540
14580
  }
14541
14581
  function CalendarGrid({
14542
14582
  weekStart,
@@ -14550,7 +14590,12 @@ function CalendarGrid({
14550
14590
  longPressPayload,
14551
14591
  swipeLeftEvent,
14552
14592
  swipeRightEvent,
14553
- dayWindow = "auto"
14593
+ dayWindow = "auto",
14594
+ titleField = "title",
14595
+ startField = "startTime",
14596
+ colorField = "color",
14597
+ children,
14598
+ renderItem
14554
14599
  }) {
14555
14600
  const evs = Array.isArray(events2) ? events2 : events2 ? [events2] : [];
14556
14601
  const eventBus = useEventBus();
@@ -14565,8 +14610,8 @@ function CalendarGrid({
14565
14610
  [resolvedWeekStart]
14566
14611
  );
14567
14612
  const resolvedTimeSlots = useMemo(
14568
- () => timeSlots ?? generateDefaultTimeSlots(),
14569
- [timeSlots]
14613
+ () => timeSlots ?? generateDefaultTimeSlots(evs, startField),
14614
+ [timeSlots, evs, startField]
14570
14615
  );
14571
14616
  const visibleCount = useDayWindow(dayWindow);
14572
14617
  const [dayOffset, setDayOffset] = useState(0);
@@ -14603,9 +14648,9 @@ function CalendarGrid({
14603
14648
  );
14604
14649
  const eventsForDayCount = useCallback(
14605
14650
  (day) => evs.filter(
14606
- (ev) => new Date(ev.startTime).toDateString() === day.toDateString()
14651
+ (ev) => eventStartDate(ev, startField).toDateString() === day.toDateString()
14607
14652
  ).length,
14608
- [events2]
14653
+ [events2, startField]
14609
14654
  );
14610
14655
  const swipeCallbacks = useMemo(() => ({
14611
14656
  onSwipeLeft: swipeLeftEvent ? () => eventBus.emit(`UI:${swipeLeftEvent}`, {}) : void 0,
@@ -14624,8 +14669,11 @@ function CalendarGrid({
14624
14669
  eventBus.emit(`UI:${longPressEvent}`, { date: day.toISOString(), time, ...longPressPayload });
14625
14670
  }, 500);
14626
14671
  }, [longPressEvent, longPressPayload, eventBus]);
14672
+ const renderChip = children ?? renderItem;
14627
14673
  const renderEvent = (event) => {
14628
- const color = event.color;
14674
+ const color = getNestedValue(event, colorField);
14675
+ const label = String(getNestedValue(event, titleField) ?? "");
14676
+ const eventIndex = evs.indexOf(event);
14629
14677
  return /* @__PURE__ */ jsx(
14630
14678
  Box,
14631
14679
  {
@@ -14637,7 +14685,7 @@ function CalendarGrid({
14637
14685
  color ? color : "bg-primary/10 border-primary/30 text-primary"
14638
14686
  ),
14639
14687
  onClick: (e) => handleEventClick(event, e),
14640
- children: /* @__PURE__ */ jsx(Typography, { variant: "small", className: "truncate font-medium", children: event.title })
14688
+ children: renderChip ? renderChip(event, eventIndex) : /* @__PURE__ */ jsx(Typography, { variant: "small", className: "truncate font-medium", children: label })
14641
14689
  },
14642
14690
  event.id
14643
14691
  );
@@ -14721,7 +14769,7 @@ function CalendarGrid({
14721
14769
  ) }),
14722
14770
  visibleDays.map((day) => {
14723
14771
  const slotEvents = evs.filter(
14724
- (ev) => eventInSlot(ev, day, time)
14772
+ (ev) => eventInSlot(ev, day, time, startField)
14725
14773
  );
14726
14774
  const isToday = day.toDateString() === (/* @__PURE__ */ new Date()).toDateString();
14727
14775
  return /* @__PURE__ */ jsx(
@@ -14753,11 +14801,12 @@ function CalendarGrid({
14753
14801
  }
14754
14802
  );
14755
14803
  }
14756
- var SHORT_DATE;
14804
+ var SHORT_DATE, DEFAULT_FIRST_HOUR, DEFAULT_LAST_HOUR, slotLabel;
14757
14805
  var init_CalendarGrid = __esm({
14758
14806
  "components/core/molecules/CalendarGrid.tsx"() {
14759
14807
  "use client";
14760
14808
  init_cn();
14809
+ init_getNestedValue();
14761
14810
  init_Box();
14762
14811
  init_Button();
14763
14812
  init_Stack();
@@ -14768,6 +14817,9 @@ var init_CalendarGrid = __esm({
14768
14817
  init_useEventBus();
14769
14818
  init_useSwipeGesture();
14770
14819
  SHORT_DATE = { month: "short", day: "numeric" };
14820
+ DEFAULT_FIRST_HOUR = 9;
14821
+ DEFAULT_LAST_HOUR = 17;
14822
+ slotLabel = (hour) => `${hour.toString().padStart(2, "0")}:00`;
14771
14823
  CalendarGrid.displayName = "CalendarGrid";
14772
14824
  }
14773
14825
  });
@@ -16366,32 +16418,6 @@ var init_Canvas = __esm({
16366
16418
  Canvas.displayName = "Canvas";
16367
16419
  }
16368
16420
  });
16369
-
16370
- // lib/getNestedValue.ts
16371
- function getNestedValue(obj, path) {
16372
- if (obj === null || obj === void 0 || !path) {
16373
- return void 0;
16374
- }
16375
- if (!path.includes(".")) {
16376
- return obj[path];
16377
- }
16378
- const parts = path.split(".");
16379
- let value = obj;
16380
- for (const part of parts) {
16381
- if (value === null || value === void 0) {
16382
- return void 0;
16383
- }
16384
- if (typeof value !== "object" || Array.isArray(value)) {
16385
- return void 0;
16386
- }
16387
- value = value[part];
16388
- }
16389
- return value;
16390
- }
16391
- var init_getNestedValue = __esm({
16392
- "lib/getNestedValue.ts"() {
16393
- }
16394
- });
16395
16421
  var Pagination;
16396
16422
  var init_Pagination = __esm({
16397
16423
  "components/core/molecules/Pagination.tsx"() {
@@ -45334,6 +45360,13 @@ function MaybeTraitScope({
45334
45360
  if (wrap) {
45335
45361
  return /* @__PURE__ */ jsx(TraitScopeProvider, { orbital, trait: sourceTrait, children });
45336
45362
  }
45363
+ if (sourceTrait !== void 0 && schemaCtx !== null) {
45364
+ scopeWrapLog.warn("decline", {
45365
+ sourceTrait,
45366
+ orbitalsByTraitSize: schemaCtx.orbitalsByTrait.size,
45367
+ reason: "sourceTrait not in orbitalsByTrait \u2014 children render unscoped"
45368
+ });
45369
+ }
45337
45370
  return /* @__PURE__ */ jsx(Fragment, { children });
45338
45371
  }
45339
45372
  function UISlotComponent({
@@ -45631,7 +45664,7 @@ function renderPatternChildren(children, onDismiss, parentId = "root", parentPat
45631
45664
  const childId = `${parentId}-${index}`;
45632
45665
  const childPath = parentPath === "root" ? `root.children.${index}` : `${parentPath}.children.${index}`;
45633
45666
  const childAsRecord = child;
45634
- const { type: _childType, props: nestedProps, _id: _childNodeId, children: _childChildren, ...flatProps } = childAsRecord;
45667
+ const { type: _childType, props: nestedProps, _id: _childNodeId, _sourceTrait: childSourceTrait, children: _childChildren, ...flatProps } = childAsRecord;
45635
45668
  const resolvedProps = nestedProps !== void 0 ? nestedProps : flatProps;
45636
45669
  if (_childChildren !== void 0 && nestedProps === void 0) {
45637
45670
  resolvedProps.children = _childChildren;
@@ -45646,11 +45679,14 @@ function renderPatternChildren(children, onDismiss, parentId = "root", parentPat
45646
45679
  // (e.g. form-section inside a stack) can resolve entityDef via
45647
45680
  // the trait's linkedEntity for form-field enrichment. The orbCtx
45648
45681
  // (slot/transition/state/entity) propagates the same way so every
45649
- // nested node carries a complete contextual-edit address.
45650
- ...sourceTrait !== void 0 && { sourceTrait },
45682
+ // nested node carries a complete contextual-edit address. A child
45683
+ // carrying its own `_sourceTrait` (multi-source slot stack) owns it
45684
+ // outright — inheriting the synthetic wrapper's sentinel instead
45685
+ // would erase the real owner.
45686
+ ...childSourceTrait !== void 0 ? { sourceTrait: childSourceTrait } : sourceTrait !== void 0 && { sourceTrait },
45651
45687
  ...orbCtx ?? {}
45652
45688
  };
45653
- return /* @__PURE__ */ jsx(
45689
+ const renderedChild = /* @__PURE__ */ jsx(
45654
45690
  SlotContentRenderer,
45655
45691
  {
45656
45692
  content: childContent,
@@ -45659,6 +45695,7 @@ function renderPatternChildren(children, onDismiss, parentId = "root", parentPat
45659
45695
  },
45660
45696
  childId
45661
45697
  );
45698
+ return childSourceTrait !== void 0 ? /* @__PURE__ */ jsx(MaybeTraitScope, { sourceTrait: childSourceTrait, children: renderedChild }, childId) : renderedChild;
45662
45699
  });
45663
45700
  }
45664
45701
  function toDrawableNodes(children) {
@@ -47207,9 +47244,10 @@ function aggregateSlot(sources) {
47207
47244
  const entries = Object.entries(sources);
47208
47245
  if (entries.length === 0) return null;
47209
47246
  if (entries.length === 1) return entries[0][1];
47210
- const children = entries.map(([, entry]) => ({
47247
+ const children = entries.map(([sourceKey, entry]) => ({
47211
47248
  type: entry.pattern,
47212
- ...entry.props
47249
+ ...entry.props,
47250
+ ...sourceKey !== DEFAULT_SOURCE_KEY && { _sourceTrait: sourceKey }
47213
47251
  }));
47214
47252
  const stackId = `slot-content-stack-${entries.map(([k]) => k).join("-")}`;
47215
47253
  return {
@@ -40,9 +40,10 @@ function aggregateSlot(sources) {
40
40
  const entries = Object.entries(sources);
41
41
  if (entries.length === 0) return null;
42
42
  if (entries.length === 1) return entries[0][1];
43
- const children = entries.map(([, entry]) => ({
43
+ const children = entries.map(([sourceKey, entry]) => ({
44
44
  type: entry.pattern,
45
- ...entry.props
45
+ ...entry.props,
46
+ ...sourceKey !== DEFAULT_SOURCE_KEY && { _sourceTrait: sourceKey }
46
47
  }));
47
48
  const stackId = `slot-content-stack-${entries.map(([k]) => k).join("-")}`;
48
49
  return {
@@ -38,9 +38,10 @@ function aggregateSlot(sources) {
38
38
  const entries = Object.entries(sources);
39
39
  if (entries.length === 0) return null;
40
40
  if (entries.length === 1) return entries[0][1];
41
- const children = entries.map(([, entry]) => ({
41
+ const children = entries.map(([sourceKey, entry]) => ({
42
42
  type: entry.pattern,
43
- ...entry.props
43
+ ...entry.props,
44
+ ...sourceKey !== DEFAULT_SOURCE_KEY && { _sourceTrait: sourceKey }
44
45
  }));
45
46
  const stackId = `slot-content-stack-${entries.map(([k]) => k).join("-")}`;
46
47
  return {
@@ -1053,9 +1053,10 @@ function aggregateSlot(sources) {
1053
1053
  const entries = Object.entries(sources);
1054
1054
  if (entries.length === 0) return null;
1055
1055
  if (entries.length === 1) return entries[0][1];
1056
- const children = entries.map(([, entry]) => ({
1056
+ const children = entries.map(([sourceKey, entry]) => ({
1057
1057
  type: entry.pattern,
1058
- ...entry.props
1058
+ ...entry.props,
1059
+ ...sourceKey !== DEFAULT_SOURCE_KEY && { _sourceTrait: sourceKey }
1059
1060
  }));
1060
1061
  const stackId = `slot-content-stack-${entries.map(([k]) => k).join("-")}`;
1061
1062
  return {
@@ -1051,9 +1051,10 @@ function aggregateSlot(sources) {
1051
1051
  const entries = Object.entries(sources);
1052
1052
  if (entries.length === 0) return null;
1053
1053
  if (entries.length === 1) return entries[0][1];
1054
- const children = entries.map(([, entry]) => ({
1054
+ const children = entries.map(([sourceKey, entry]) => ({
1055
1055
  type: entry.pattern,
1056
- ...entry.props
1056
+ ...entry.props,
1057
+ ...sourceKey !== DEFAULT_SOURCE_KEY && { _sourceTrait: sourceKey }
1057
1058
  }));
1058
1059
  const stackId = `slot-content-stack-${entries.map(([k]) => k).join("-")}`;
1059
1060
  return {