@umituz/web-dashboard 9.0.0 → 9.0.2

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umituz/web-dashboard",
3
- "version": "9.0.0",
3
+ "version": "9.0.2",
4
4
  "description": "Installable app skeleton for the fleet — layouts, analytics (dependency-free SVG charts), calendar, onboarding flow permissions/module registry; udb-* stylesheet on design-system tokens",
5
5
  "type": "module",
6
6
  "main": "./src/index.ts",
@@ -121,11 +121,11 @@ export function aggregateByPeriod(
121
121
  let key: string;
122
122
 
123
123
  if (period === "day") {
124
- key = date.toISOString().split("T")[0];
124
+ key = date.toISOString().slice(0, 10);
125
125
  } else if (period === "week") {
126
126
  const weekStart = new Date(date);
127
127
  weekStart.setDate(date.getDate() - date.getDay());
128
- key = weekStart.toISOString().split("T")[0];
128
+ key = weekStart.toISOString().slice(0, 10);
129
129
  } else {
130
130
 
131
131
  key = `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, "0")}`;
@@ -4,20 +4,25 @@ export { mapCalendarDocument, mapPostDocument } from './contentItemMapper';
4
4
  export * from './layout';
5
5
  export type { FirestoreDocument } from './contentItemMapper';
6
6
 
7
- export function getWeekDates(date: Date, startOfWeek: number = 0): Date[] {
8
- const week: Date[] = [];
9
- const current = new Date(date);
7
+ /** Always seven consecutive days starting at the week anchor — the tuple
8
+ * type states that guarantee, so index access stays `Date` (not
9
+ * `Date | undefined`) under consumer `noUncheckedIndexedAccess`. */
10
+ export function getWeekDates(
11
+ date: Date,
12
+ startOfWeek: number = 0,
13
+ ): [Date, Date, Date, Date, Date, Date, Date] {
14
+ const anchor = new Date(date);
10
15
 
11
- const day = current.getDay();
16
+ const day = anchor.getDay();
12
17
  const diff = (day < startOfWeek ? 7 : 0) + day - startOfWeek;
13
- current.setDate(current.getDate() - diff);
14
-
15
- for (let i = 0; i < 7; i++) {
16
- week.push(new Date(current));
17
- current.setDate(current.getDate() + 1);
18
- }
19
-
20
- return week;
18
+ anchor.setDate(anchor.getDate() - diff);
19
+
20
+ const at = (offset: number): Date => {
21
+ const dayAt = new Date(anchor);
22
+ dayAt.setDate(anchor.getDate() + offset);
23
+ return dayAt;
24
+ };
25
+ return [at(0), at(1), at(2), at(3), at(4), at(5), at(6)];
21
26
  }
22
27
 
23
28
  export function getMonthDays(date: Date): Date[] {