@almadar/ui 5.126.0 → 5.128.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.
@@ -5307,8 +5307,34 @@ interface CalendarGridProps {
5307
5307
  * layouts or screenshot tests).
5308
5308
  */
5309
5309
  dayWindow?: CalendarDayWindow | 'auto';
5310
+ /**
5311
+ * Row field holding the chip label. Defaults to `title`. Lets a host bound
5312
+ * to its own entity name the column instead of being forced to rename its
5313
+ * fields to this grid's contract (same accessor idiom as `DataList`'s
5314
+ * `senderField` / `DataGrid`'s `imageField`).
5315
+ */
5316
+ titleField?: string;
5317
+ /** Row field holding the start timestamp (ISO or epoch). Defaults to `startTime`. */
5318
+ startField?: string;
5319
+ /** Row field holding the chip's Tailwind colour class. Defaults to `color`. */
5320
+ colorField?: string;
5321
+ /**
5322
+ * Render function for one event chip's content. Receives the row and its
5323
+ * index in the materialised events array. The grid keeps ownership of
5324
+ * placement, colour and the click target; this replaces only what is drawn
5325
+ * INSIDE the chip, so a host can show a time + instructor + badge stack
5326
+ * instead of the default single label.
5327
+ */
5328
+ children?: (item: EntityRow, index: number) => React__default.ReactNode;
5329
+ /**
5330
+ * Per-event render function (schema-level alias for the children render
5331
+ * prop). In `.orb`: `["fn", "item", { pattern tree with @item.field bindings }]`.
5332
+ * In `.lolo`: `renderItem: (fn item <Component …={@item.field}/>)` — the same
5333
+ * contract `data-list` / `data-grid` / `carousel` already use.
5334
+ */
5335
+ renderItem?: (item: EntityRow, index: number) => React__default.ReactNode;
5310
5336
  }
5311
- declare function CalendarGrid({ weekStart, timeSlots, events, onSlotClick, onDayClick, onEventClick, className, longPressEvent, longPressPayload, swipeLeftEvent, swipeRightEvent, dayWindow, }: CalendarGridProps): React__default.JSX.Element;
5337
+ declare function CalendarGrid({ weekStart, timeSlots, events, onSlotClick, onDayClick, onEventClick, className, longPressEvent, longPressPayload, swipeLeftEvent, swipeRightEvent, dayWindow, titleField, startField, colorField, children, renderItem, }: CalendarGridProps): React__default.JSX.Element;
5312
5338
  declare namespace CalendarGrid {
5313
5339
  var displayName: string;
5314
5340
  }
@@ -5307,8 +5307,34 @@ interface CalendarGridProps {
5307
5307
  * layouts or screenshot tests).
5308
5308
  */
5309
5309
  dayWindow?: CalendarDayWindow | 'auto';
5310
+ /**
5311
+ * Row field holding the chip label. Defaults to `title`. Lets a host bound
5312
+ * to its own entity name the column instead of being forced to rename its
5313
+ * fields to this grid's contract (same accessor idiom as `DataList`'s
5314
+ * `senderField` / `DataGrid`'s `imageField`).
5315
+ */
5316
+ titleField?: string;
5317
+ /** Row field holding the start timestamp (ISO or epoch). Defaults to `startTime`. */
5318
+ startField?: string;
5319
+ /** Row field holding the chip's Tailwind colour class. Defaults to `color`. */
5320
+ colorField?: string;
5321
+ /**
5322
+ * Render function for one event chip's content. Receives the row and its
5323
+ * index in the materialised events array. The grid keeps ownership of
5324
+ * placement, colour and the click target; this replaces only what is drawn
5325
+ * INSIDE the chip, so a host can show a time + instructor + badge stack
5326
+ * instead of the default single label.
5327
+ */
5328
+ children?: (item: EntityRow, index: number) => React__default.ReactNode;
5329
+ /**
5330
+ * Per-event render function (schema-level alias for the children render
5331
+ * prop). In `.orb`: `["fn", "item", { pattern tree with @item.field bindings }]`.
5332
+ * In `.lolo`: `renderItem: (fn item <Component …={@item.field}/>)` — the same
5333
+ * contract `data-list` / `data-grid` / `carousel` already use.
5334
+ */
5335
+ renderItem?: (item: EntityRow, index: number) => React__default.ReactNode;
5310
5336
  }
5311
- declare function CalendarGrid({ weekStart, timeSlots, events, onSlotClick, onDayClick, onEventClick, className, longPressEvent, longPressPayload, swipeLeftEvent, swipeRightEvent, dayWindow, }: CalendarGridProps): React__default.JSX.Element;
5337
+ declare function CalendarGrid({ weekStart, timeSlots, events, onSlotClick, onDayClick, onEventClick, className, longPressEvent, longPressPayload, swipeLeftEvent, swipeRightEvent, dayWindow, titleField, startField, colorField, children, renderItem, }: CalendarGridProps): React__default.JSX.Element;
5312
5338
  declare namespace CalendarGrid {
5313
5339
  var displayName: string;
5314
5340
  }
@@ -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,11 +14552,15 @@ function getWeekDays(start) {
14526
14552
  }
14527
14553
  return days;
14528
14554
  }
14529
- function generateDefaultTimeSlots(events2) {
14555
+ function eventStartDate(event, startField) {
14556
+ const raw = getNestedValue(event, startField);
14557
+ return new Date(raw ?? "");
14558
+ }
14559
+ function generateDefaultTimeSlots(events2, startField) {
14530
14560
  let first = DEFAULT_FIRST_HOUR;
14531
14561
  let last = DEFAULT_LAST_HOUR;
14532
14562
  for (const ev of events2) {
14533
- const start = new Date(ev.startTime);
14563
+ const start = eventStartDate(ev, startField);
14534
14564
  if (Number.isNaN(start.getTime())) continue;
14535
14565
  const hour = start.getHours();
14536
14566
  if (hour < first) first = hour;
@@ -14542,8 +14572,8 @@ function generateDefaultTimeSlots(events2) {
14542
14572
  }
14543
14573
  return slots;
14544
14574
  }
14545
- function eventInSlot(event, day, slotTime) {
14546
- const eventStart = new Date(event.startTime);
14575
+ function eventInSlot(event, day, slotTime, startField) {
14576
+ const eventStart = eventStartDate(event, startField);
14547
14577
  if (Number.isNaN(eventStart.getTime())) return false;
14548
14578
  const [slotHour] = slotTime.split(":").map(Number);
14549
14579
  return eventStart.toDateString() === day.toDateString() && eventStart.getHours() === slotHour;
@@ -14560,7 +14590,12 @@ function CalendarGrid({
14560
14590
  longPressPayload,
14561
14591
  swipeLeftEvent,
14562
14592
  swipeRightEvent,
14563
- dayWindow = "auto"
14593
+ dayWindow = "auto",
14594
+ titleField = "title",
14595
+ startField = "startTime",
14596
+ colorField = "color",
14597
+ children,
14598
+ renderItem
14564
14599
  }) {
14565
14600
  const evs = Array.isArray(events2) ? events2 : events2 ? [events2] : [];
14566
14601
  const eventBus = useEventBus();
@@ -14575,8 +14610,8 @@ function CalendarGrid({
14575
14610
  [resolvedWeekStart]
14576
14611
  );
14577
14612
  const resolvedTimeSlots = useMemo(
14578
- () => timeSlots ?? generateDefaultTimeSlots(evs),
14579
- [timeSlots, evs]
14613
+ () => timeSlots ?? generateDefaultTimeSlots(evs, startField),
14614
+ [timeSlots, evs, startField]
14580
14615
  );
14581
14616
  const visibleCount = useDayWindow(dayWindow);
14582
14617
  const [dayOffset, setDayOffset] = useState(0);
@@ -14613,9 +14648,9 @@ function CalendarGrid({
14613
14648
  );
14614
14649
  const eventsForDayCount = useCallback(
14615
14650
  (day) => evs.filter(
14616
- (ev) => new Date(ev.startTime).toDateString() === day.toDateString()
14651
+ (ev) => eventStartDate(ev, startField).toDateString() === day.toDateString()
14617
14652
  ).length,
14618
- [events2]
14653
+ [events2, startField]
14619
14654
  );
14620
14655
  const swipeCallbacks = useMemo(() => ({
14621
14656
  onSwipeLeft: swipeLeftEvent ? () => eventBus.emit(`UI:${swipeLeftEvent}`, {}) : void 0,
@@ -14634,8 +14669,11 @@ function CalendarGrid({
14634
14669
  eventBus.emit(`UI:${longPressEvent}`, { date: day.toISOString(), time, ...longPressPayload });
14635
14670
  }, 500);
14636
14671
  }, [longPressEvent, longPressPayload, eventBus]);
14672
+ const renderChip = children ?? renderItem;
14637
14673
  const renderEvent = (event) => {
14638
- const color = event.color;
14674
+ const color = getNestedValue(event, colorField);
14675
+ const label = String(getNestedValue(event, titleField) ?? "");
14676
+ const eventIndex = evs.indexOf(event);
14639
14677
  return /* @__PURE__ */ jsx(
14640
14678
  Box,
14641
14679
  {
@@ -14647,7 +14685,7 @@ function CalendarGrid({
14647
14685
  color ? color : "bg-primary/10 border-primary/30 text-primary"
14648
14686
  ),
14649
14687
  onClick: (e) => handleEventClick(event, e),
14650
- 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 })
14651
14689
  },
14652
14690
  event.id
14653
14691
  );
@@ -14731,7 +14769,7 @@ function CalendarGrid({
14731
14769
  ) }),
14732
14770
  visibleDays.map((day) => {
14733
14771
  const slotEvents = evs.filter(
14734
- (ev) => eventInSlot(ev, day, time)
14772
+ (ev) => eventInSlot(ev, day, time, startField)
14735
14773
  );
14736
14774
  const isToday = day.toDateString() === (/* @__PURE__ */ new Date()).toDateString();
14737
14775
  return /* @__PURE__ */ jsx(
@@ -14768,6 +14806,7 @@ var init_CalendarGrid = __esm({
14768
14806
  "components/core/molecules/CalendarGrid.tsx"() {
14769
14807
  "use client";
14770
14808
  init_cn();
14809
+ init_getNestedValue();
14771
14810
  init_Box();
14772
14811
  init_Button();
14773
14812
  init_Stack();
@@ -16379,32 +16418,6 @@ var init_Canvas = __esm({
16379
16418
  Canvas.displayName = "Canvas";
16380
16419
  }
16381
16420
  });
16382
-
16383
- // lib/getNestedValue.ts
16384
- function getNestedValue(obj, path) {
16385
- if (obj === null || obj === void 0 || !path) {
16386
- return void 0;
16387
- }
16388
- if (!path.includes(".")) {
16389
- return obj[path];
16390
- }
16391
- const parts = path.split(".");
16392
- let value = obj;
16393
- for (const part of parts) {
16394
- if (value === null || value === void 0) {
16395
- return void 0;
16396
- }
16397
- if (typeof value !== "object" || Array.isArray(value)) {
16398
- return void 0;
16399
- }
16400
- value = value[part];
16401
- }
16402
- return value;
16403
- }
16404
- var init_getNestedValue = __esm({
16405
- "lib/getNestedValue.ts"() {
16406
- }
16407
- });
16408
16421
  var Pagination;
16409
16422
  var init_Pagination = __esm({
16410
16423
  "components/core/molecules/Pagination.tsx"() {
@@ -19560,7 +19573,7 @@ var init_DashboardLayout = __esm({
19560
19573
  ]
19561
19574
  }
19562
19575
  ),
19563
- user && /* @__PURE__ */ jsxs(Box, { className: "relative", children: [
19576
+ user?.name && /* @__PURE__ */ jsxs(Box, { className: "relative", children: [
19564
19577
  /* @__PURE__ */ jsxs(
19565
19578
  Button,
19566
19579
  {
@@ -1,7 +1,7 @@
1
1
  export { U as UISlotContext, a as UISlotProvider, u as useSlotContent, b as useSlotHasContent, c as useUISlots } from '../UISlotContext-D8_SoDsD.cjs';
2
- export { A as ANONYMOUS_USER, B as BUILT_IN_THEMES, C as ColorMode, a as CurrentPagePathContext, b as CurrentPagePathProvider, c as CurrentPagePathProviderProps, D as DesignTheme, d as DesignThemeProvider, O as OrbitalThemeProvider, e as OrbitalThemeProviderProps, R as ResolvedMode, T as ThemeContext, f as ThemeProvider, g as ThemeProviderProps, U as UIThemeDefinition, h as UserContext, i as UserContextValue, j as UserData, k as UserProvider, l as UserProviderProps, u as useCurrentPagePath, m as useDesignTheme, n as useHasPermission, o as useHasRole, p as useTheme, q as useUser, r as useUserForEvaluation } from '../UserContext-BKckAUv7.cjs';
2
+ export { B as BUILT_IN_THEMES, C as ColorMode, a as CurrentPagePathContext, b as CurrentPagePathProvider, c as CurrentPagePathProviderProps, D as DesignTheme, d as DesignThemeProvider, O as OrbitalThemeProvider, e as OrbitalThemeProviderProps, R as ResolvedMode, T as ThemeContext, f as ThemeProvider, g as ThemeProviderProps, U as UIThemeDefinition, h as UserContext, i as UserContextValue, j as UserData, k as UserProvider, l as UserProviderProps, u as useCurrentPagePath, m as useDesignTheme, n as useHasPermission, o as useHasRole, p as useTheme, q as useUser, r as useUserForEvaluation } from '../UserContext-g_LcDiGN.cjs';
3
3
  import { ThemeRef, ThemeDefinition, ThemeTokens, ThemeVariant } from '@almadar/core';
4
- export { UISlot } from '@almadar/core';
4
+ export { ANONYMOUS_USER, UISlot } from '@almadar/core';
5
5
  export { S as SlotAnimation, a as SlotChangeCallback, b as SlotContent, c as SlotRenderConfig, U as UISlotManager } from '../useUISlots-BesZYMks.cjs';
6
6
  import 'react';
7
7
 
@@ -1,7 +1,7 @@
1
1
  export { U as UISlotContext, a as UISlotProvider, u as useSlotContent, b as useSlotHasContent, c as useUISlots } from '../UISlotContext-C1FsU9GB.js';
2
- export { A as ANONYMOUS_USER, B as BUILT_IN_THEMES, C as ColorMode, a as CurrentPagePathContext, b as CurrentPagePathProvider, c as CurrentPagePathProviderProps, D as DesignTheme, d as DesignThemeProvider, O as OrbitalThemeProvider, e as OrbitalThemeProviderProps, R as ResolvedMode, T as ThemeContext, f as ThemeProvider, g as ThemeProviderProps, U as UIThemeDefinition, h as UserContext, i as UserContextValue, j as UserData, k as UserProvider, l as UserProviderProps, u as useCurrentPagePath, m as useDesignTheme, n as useHasPermission, o as useHasRole, p as useTheme, q as useUser, r as useUserForEvaluation } from '../UserContext-BKckAUv7.js';
2
+ export { B as BUILT_IN_THEMES, C as ColorMode, a as CurrentPagePathContext, b as CurrentPagePathProvider, c as CurrentPagePathProviderProps, D as DesignTheme, d as DesignThemeProvider, O as OrbitalThemeProvider, e as OrbitalThemeProviderProps, R as ResolvedMode, T as ThemeContext, f as ThemeProvider, g as ThemeProviderProps, U as UIThemeDefinition, h as UserContext, i as UserContextValue, j as UserData, k as UserProvider, l as UserProviderProps, u as useCurrentPagePath, m as useDesignTheme, n as useHasPermission, o as useHasRole, p as useTheme, q as useUser, r as useUserForEvaluation } from '../UserContext-g_LcDiGN.js';
3
3
  import { ThemeRef, ThemeDefinition, ThemeTokens, ThemeVariant } from '@almadar/core';
4
- export { UISlot } from '@almadar/core';
4
+ export { ANONYMOUS_USER, UISlot } from '@almadar/core';
5
5
  export { S as SlotAnimation, a as SlotChangeCallback, b as SlotContent, c as SlotRenderConfig, U as UISlotManager } from '../useUISlots-BesZYMks.js';
6
6
  import 'react';
7
7
 
@@ -18876,6 +18876,32 @@ var init_ButtonGroup = __esm({
18876
18876
  ButtonGroup.displayName = "ButtonGroup";
18877
18877
  }
18878
18878
  });
18879
+
18880
+ // lib/getNestedValue.ts
18881
+ function getNestedValue(obj, path) {
18882
+ if (obj === null || obj === void 0 || !path) {
18883
+ return void 0;
18884
+ }
18885
+ if (!path.includes(".")) {
18886
+ return obj[path];
18887
+ }
18888
+ const parts = path.split(".");
18889
+ let value = obj;
18890
+ for (const part of parts) {
18891
+ if (value === null || value === void 0) {
18892
+ return void 0;
18893
+ }
18894
+ if (typeof value !== "object" || Array.isArray(value)) {
18895
+ return void 0;
18896
+ }
18897
+ value = value[part];
18898
+ }
18899
+ return value;
18900
+ }
18901
+ var init_getNestedValue = __esm({
18902
+ "lib/getNestedValue.ts"() {
18903
+ }
18904
+ });
18879
18905
  function useSwipeGesture(callbacks, options = {}) {
18880
18906
  const { threshold = 50, velocityThreshold = 0.3, preventDefault = false } = options;
18881
18907
  const startX = React84.useRef(0);
@@ -18989,11 +19015,15 @@ function getWeekDays(start) {
18989
19015
  }
18990
19016
  return days;
18991
19017
  }
18992
- function generateDefaultTimeSlots(events2) {
19018
+ function eventStartDate(event, startField) {
19019
+ const raw = getNestedValue(event, startField);
19020
+ return new Date(raw ?? "");
19021
+ }
19022
+ function generateDefaultTimeSlots(events2, startField) {
18993
19023
  let first = DEFAULT_FIRST_HOUR;
18994
19024
  let last = DEFAULT_LAST_HOUR;
18995
19025
  for (const ev of events2) {
18996
- const start = new Date(ev.startTime);
19026
+ const start = eventStartDate(ev, startField);
18997
19027
  if (Number.isNaN(start.getTime())) continue;
18998
19028
  const hour = start.getHours();
18999
19029
  if (hour < first) first = hour;
@@ -19005,8 +19035,8 @@ function generateDefaultTimeSlots(events2) {
19005
19035
  }
19006
19036
  return slots;
19007
19037
  }
19008
- function eventInSlot(event, day, slotTime) {
19009
- const eventStart = new Date(event.startTime);
19038
+ function eventInSlot(event, day, slotTime, startField) {
19039
+ const eventStart = eventStartDate(event, startField);
19010
19040
  if (Number.isNaN(eventStart.getTime())) return false;
19011
19041
  const [slotHour] = slotTime.split(":").map(Number);
19012
19042
  return eventStart.toDateString() === day.toDateString() && eventStart.getHours() === slotHour;
@@ -19023,7 +19053,12 @@ function CalendarGrid({
19023
19053
  longPressPayload,
19024
19054
  swipeLeftEvent,
19025
19055
  swipeRightEvent,
19026
- dayWindow = "auto"
19056
+ dayWindow = "auto",
19057
+ titleField = "title",
19058
+ startField = "startTime",
19059
+ colorField = "color",
19060
+ children,
19061
+ renderItem
19027
19062
  }) {
19028
19063
  const evs = Array.isArray(events2) ? events2 : events2 ? [events2] : [];
19029
19064
  const eventBus = useEventBus();
@@ -19038,8 +19073,8 @@ function CalendarGrid({
19038
19073
  [resolvedWeekStart]
19039
19074
  );
19040
19075
  const resolvedTimeSlots = React84.useMemo(
19041
- () => timeSlots ?? generateDefaultTimeSlots(evs),
19042
- [timeSlots, evs]
19076
+ () => timeSlots ?? generateDefaultTimeSlots(evs, startField),
19077
+ [timeSlots, evs, startField]
19043
19078
  );
19044
19079
  const visibleCount = useDayWindow(dayWindow);
19045
19080
  const [dayOffset, setDayOffset] = React84.useState(0);
@@ -19076,9 +19111,9 @@ function CalendarGrid({
19076
19111
  );
19077
19112
  const eventsForDayCount = React84.useCallback(
19078
19113
  (day) => evs.filter(
19079
- (ev) => new Date(ev.startTime).toDateString() === day.toDateString()
19114
+ (ev) => eventStartDate(ev, startField).toDateString() === day.toDateString()
19080
19115
  ).length,
19081
- [events2]
19116
+ [events2, startField]
19082
19117
  );
19083
19118
  const swipeCallbacks = React84.useMemo(() => ({
19084
19119
  onSwipeLeft: swipeLeftEvent ? () => eventBus.emit(`UI:${swipeLeftEvent}`, {}) : void 0,
@@ -19097,8 +19132,11 @@ function CalendarGrid({
19097
19132
  eventBus.emit(`UI:${longPressEvent}`, { date: day.toISOString(), time, ...longPressPayload });
19098
19133
  }, 500);
19099
19134
  }, [longPressEvent, longPressPayload, eventBus]);
19135
+ const renderChip = children ?? renderItem;
19100
19136
  const renderEvent = (event) => {
19101
- const color = event.color;
19137
+ const color = getNestedValue(event, colorField);
19138
+ const label = String(getNestedValue(event, titleField) ?? "");
19139
+ const eventIndex = evs.indexOf(event);
19102
19140
  return /* @__PURE__ */ jsxRuntime.jsx(
19103
19141
  Box,
19104
19142
  {
@@ -19110,7 +19148,7 @@ function CalendarGrid({
19110
19148
  color ? color : "bg-primary/10 border-primary/30 text-primary"
19111
19149
  ),
19112
19150
  onClick: (e) => handleEventClick(event, e),
19113
- children: /* @__PURE__ */ jsxRuntime.jsx(Typography, { variant: "small", className: "truncate font-medium", children: event.title })
19151
+ children: renderChip ? renderChip(event, eventIndex) : /* @__PURE__ */ jsxRuntime.jsx(Typography, { variant: "small", className: "truncate font-medium", children: label })
19114
19152
  },
19115
19153
  event.id
19116
19154
  );
@@ -19194,7 +19232,7 @@ function CalendarGrid({
19194
19232
  ) }),
19195
19233
  visibleDays.map((day) => {
19196
19234
  const slotEvents = evs.filter(
19197
- (ev) => eventInSlot(ev, day, time)
19235
+ (ev) => eventInSlot(ev, day, time, startField)
19198
19236
  );
19199
19237
  const isToday = day.toDateString() === (/* @__PURE__ */ new Date()).toDateString();
19200
19238
  return /* @__PURE__ */ jsxRuntime.jsx(
@@ -19231,6 +19269,7 @@ var init_CalendarGrid = __esm({
19231
19269
  "components/core/molecules/CalendarGrid.tsx"() {
19232
19270
  "use client";
19233
19271
  init_cn();
19272
+ init_getNestedValue();
19234
19273
  init_Box();
19235
19274
  init_Button();
19236
19275
  init_Stack();
@@ -19247,32 +19286,6 @@ var init_CalendarGrid = __esm({
19247
19286
  CalendarGrid.displayName = "CalendarGrid";
19248
19287
  }
19249
19288
  });
19250
-
19251
- // lib/getNestedValue.ts
19252
- function getNestedValue(obj, path) {
19253
- if (obj === null || obj === void 0 || !path) {
19254
- return void 0;
19255
- }
19256
- if (!path.includes(".")) {
19257
- return obj[path];
19258
- }
19259
- const parts = path.split(".");
19260
- let value = obj;
19261
- for (const part of parts) {
19262
- if (value === null || value === void 0) {
19263
- return void 0;
19264
- }
19265
- if (typeof value !== "object" || Array.isArray(value)) {
19266
- return void 0;
19267
- }
19268
- value = value[part];
19269
- }
19270
- return value;
19271
- }
19272
- var init_getNestedValue = __esm({
19273
- "lib/getNestedValue.ts"() {
19274
- }
19275
- });
19276
19289
  var Pagination;
19277
19290
  var init_Pagination = __esm({
19278
19291
  "components/core/molecules/Pagination.tsx"() {
@@ -22055,7 +22068,7 @@ var init_DashboardLayout = __esm({
22055
22068
  ]
22056
22069
  }
22057
22070
  ),
22058
- user && /* @__PURE__ */ jsxRuntime.jsxs(Box, { className: "relative", children: [
22071
+ user?.name && /* @__PURE__ */ jsxRuntime.jsxs(Box, { className: "relative", children: [
22059
22072
  /* @__PURE__ */ jsxRuntime.jsxs(
22060
22073
  Button,
22061
22074
  {
@@ -45141,6 +45154,96 @@ function VerificationProvider({
45141
45154
  return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children });
45142
45155
  }
45143
45156
  VerificationProvider.displayName = "VerificationProvider";
45157
+ var UserContext = React84.createContext(null);
45158
+ function UserProvider({
45159
+ user = null,
45160
+ children
45161
+ }) {
45162
+ const hasRole = React84.useCallback(
45163
+ (role) => {
45164
+ if (!user) return role === "anonymous";
45165
+ return user.role === role;
45166
+ },
45167
+ [user]
45168
+ );
45169
+ const hasPermission = React84.useCallback(
45170
+ (permission) => {
45171
+ if (!user) return false;
45172
+ return user.permissions?.includes(permission) ?? false;
45173
+ },
45174
+ [user]
45175
+ );
45176
+ const hasAnyRole = React84.useCallback(
45177
+ (roles) => {
45178
+ if (!user) return roles.includes("anonymous");
45179
+ return user.role ? roles.includes(user.role) : false;
45180
+ },
45181
+ [user]
45182
+ );
45183
+ const hasAllPermissions = React84.useCallback(
45184
+ (permissions) => {
45185
+ if (!user || !user.permissions) return false;
45186
+ return permissions.every((p) => user.permissions?.includes(p));
45187
+ },
45188
+ [user]
45189
+ );
45190
+ const getUserField = React84.useCallback(
45191
+ (path) => {
45192
+ const viewer = user ?? core.ANONYMOUS_USER;
45193
+ const [first, ...rest] = path.split(".");
45194
+ if (!first) return void 0;
45195
+ let value = viewer[first];
45196
+ for (const segment of rest) {
45197
+ if (value === null || typeof value !== "object" || Array.isArray(value) || value instanceof Date) {
45198
+ return void 0;
45199
+ }
45200
+ value = value[segment];
45201
+ }
45202
+ return value;
45203
+ },
45204
+ [user]
45205
+ );
45206
+ const contextValue = React84.useMemo(
45207
+ () => ({
45208
+ user,
45209
+ isLoggedIn: user !== null,
45210
+ hasRole,
45211
+ hasPermission,
45212
+ hasAnyRole,
45213
+ hasAllPermissions,
45214
+ getUserField
45215
+ }),
45216
+ [user, hasRole, hasPermission, hasAnyRole, hasAllPermissions, getUserField]
45217
+ );
45218
+ return /* @__PURE__ */ jsxRuntime.jsx(UserContext.Provider, { value: contextValue, children });
45219
+ }
45220
+ function useUser() {
45221
+ const context = React84.useContext(UserContext);
45222
+ if (!context) {
45223
+ return {
45224
+ user: null,
45225
+ isLoggedIn: false,
45226
+ hasRole: (role) => role === "anonymous",
45227
+ hasPermission: () => false,
45228
+ hasAnyRole: (roles) => roles.includes("anonymous"),
45229
+ hasAllPermissions: () => false,
45230
+ getUserField: () => void 0
45231
+ };
45232
+ }
45233
+ return context;
45234
+ }
45235
+ function useHasRole(role) {
45236
+ const { hasRole } = useUser();
45237
+ return hasRole(role);
45238
+ }
45239
+ function useHasPermission(permission) {
45240
+ const { hasPermission } = useUser();
45241
+ return hasPermission(permission);
45242
+ }
45243
+ function useUserForEvaluation() {
45244
+ const { user, isLoggedIn } = useUser();
45245
+ return isLoggedIn && user ? user : void 0;
45246
+ }
45144
45247
  function OrbitalProvider({
45145
45248
  children,
45146
45249
  themes,
@@ -45152,13 +45255,14 @@ function OrbitalProvider({
45152
45255
  initialData,
45153
45256
  suspense = false,
45154
45257
  verification,
45155
- isolated = false
45258
+ isolated = false,
45259
+ user = null
45156
45260
  }) {
45157
45261
  const suspenseConfig = React84.useMemo(
45158
45262
  () => ({ enabled: suspense }),
45159
45263
  [suspense]
45160
45264
  );
45161
- const inner = /* @__PURE__ */ jsxRuntime.jsx(EventBusProvider, { debug: debug2, isolated, children: /* @__PURE__ */ jsxRuntime.jsx(VerificationProvider, { enabled: verification, children: /* @__PURE__ */ jsxRuntime.jsx(SelectionProvider, { debug: debug2, children: /* @__PURE__ */ jsxRuntime.jsx(SuspenseConfigProvider, { config: suspenseConfig, children }) }) }) });
45265
+ const inner = /* @__PURE__ */ jsxRuntime.jsx(EventBusProvider, { debug: debug2, isolated, children: /* @__PURE__ */ jsxRuntime.jsx(VerificationProvider, { enabled: verification, children: /* @__PURE__ */ jsxRuntime.jsx(UserProvider, { user, children: /* @__PURE__ */ jsxRuntime.jsx(SelectionProvider, { debug: debug2, children: /* @__PURE__ */ jsxRuntime.jsx(SuspenseConfigProvider, { config: suspenseConfig, children }) }) }) }) });
45162
45266
  if (skipTheme) {
45163
45267
  return inner;
45164
45268
  }
@@ -45414,104 +45518,6 @@ var CurrentPagePathProvider = ({
45414
45518
  }) => /* @__PURE__ */ jsxRuntime.jsx(CurrentPagePathContext.Provider, { value, children });
45415
45519
  CurrentPagePathProvider.displayName = "CurrentPagePathProvider";
45416
45520
  var useCurrentPagePath2 = () => React84.useContext(CurrentPagePathContext);
45417
- var ANONYMOUS_USER = {
45418
- id: "anonymous",
45419
- role: "anonymous",
45420
- permissions: []
45421
- };
45422
- var UserContext = React84.createContext(null);
45423
- function UserProvider({
45424
- user = null,
45425
- children
45426
- }) {
45427
- const hasRole = React84.useCallback(
45428
- (role) => {
45429
- if (!user) return role === "anonymous";
45430
- return user.role === role;
45431
- },
45432
- [user]
45433
- );
45434
- const hasPermission = React84.useCallback(
45435
- (permission) => {
45436
- if (!user) return false;
45437
- return user.permissions?.includes(permission) ?? false;
45438
- },
45439
- [user]
45440
- );
45441
- const hasAnyRole = React84.useCallback(
45442
- (roles) => {
45443
- if (!user) return roles.includes("anonymous");
45444
- return user.role ? roles.includes(user.role) : false;
45445
- },
45446
- [user]
45447
- );
45448
- const hasAllPermissions = React84.useCallback(
45449
- (permissions) => {
45450
- if (!user || !user.permissions) return false;
45451
- return permissions.every((p) => user.permissions?.includes(p));
45452
- },
45453
- [user]
45454
- );
45455
- const getUserField = React84.useCallback(
45456
- (path) => {
45457
- const userData = user ?? ANONYMOUS_USER;
45458
- const parts = path.split(".");
45459
- let value = userData;
45460
- for (const segment of parts) {
45461
- if (value === null || value === void 0) {
45462
- return void 0;
45463
- }
45464
- if (typeof value === "object") {
45465
- value = value[segment];
45466
- } else {
45467
- return void 0;
45468
- }
45469
- }
45470
- return value;
45471
- },
45472
- [user]
45473
- );
45474
- const contextValue = React84.useMemo(
45475
- () => ({
45476
- user,
45477
- isLoggedIn: user !== null,
45478
- hasRole,
45479
- hasPermission,
45480
- hasAnyRole,
45481
- hasAllPermissions,
45482
- getUserField
45483
- }),
45484
- [user, hasRole, hasPermission, hasAnyRole, hasAllPermissions, getUserField]
45485
- );
45486
- return /* @__PURE__ */ jsxRuntime.jsx(UserContext.Provider, { value: contextValue, children });
45487
- }
45488
- function useUser() {
45489
- const context = React84.useContext(UserContext);
45490
- if (!context) {
45491
- return {
45492
- user: null,
45493
- isLoggedIn: false,
45494
- hasRole: (role) => role === "anonymous",
45495
- hasPermission: () => false,
45496
- hasAnyRole: (roles) => roles.includes("anonymous"),
45497
- hasAllPermissions: () => false,
45498
- getUserField: () => void 0
45499
- };
45500
- }
45501
- return context;
45502
- }
45503
- function useHasRole(role) {
45504
- const { hasRole } = useUser();
45505
- return hasRole(role);
45506
- }
45507
- function useHasPermission(permission) {
45508
- const { hasPermission } = useUser();
45509
- return hasPermission(permission);
45510
- }
45511
- function useUserForEvaluation() {
45512
- const { user, isLoggedIn } = useUser();
45513
- return isLoggedIn && user ? user : void 0;
45514
- }
45515
45521
  var EntitySchemaContext = React84.createContext(null);
45516
45522
  function EntitySchemaProvider({
45517
45523
  entities,
@@ -46235,7 +46241,10 @@ Object.defineProperty(exports, "useDesignTheme", {
46235
46241
  enumerable: true,
46236
46242
  get: function () { return context.useDesignTheme; }
46237
46243
  });
46238
- exports.ANONYMOUS_USER = ANONYMOUS_USER;
46244
+ Object.defineProperty(exports, "ANONYMOUS_USER", {
46245
+ enumerable: true,
46246
+ get: function () { return core.ANONYMOUS_USER; }
46247
+ });
46239
46248
  exports.CurrentPagePathContext = CurrentPagePathContext;
46240
46249
  exports.CurrentPagePathProvider = CurrentPagePathProvider;
46241
46250
  exports.EntitySchemaProvider = EntitySchemaProvider;