@appcorp/fusion-storybook 0.5.40 → 0.6.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.
Files changed (37) hide show
  1. package/attendance-register/documents/download.d.ts +2 -0
  2. package/attendance-register/documents/download.js +13 -0
  3. package/attendance-register/documents/image-text.d.ts +37 -0
  4. package/attendance-register/documents/image-text.js +103 -0
  5. package/attendance-register/documents/pdf.d.ts +40 -0
  6. package/attendance-register/documents/pdf.js +425 -0
  7. package/attendance-register/documents/zip-files.d.ts +2 -0
  8. package/attendance-register/documents/zip-files.js +5 -0
  9. package/attendance-register/documents/zip.d.ts +13 -0
  10. package/attendance-register/documents/zip.js +29 -0
  11. package/attendance-register/domain/calendar.d.ts +28 -0
  12. package/attendance-register/domain/calendar.js +150 -0
  13. package/attendance-register/domain/locale.d.ts +26 -0
  14. package/attendance-register/domain/locale.js +87 -0
  15. package/attendance-register/domain/register.d.ts +50 -0
  16. package/attendance-register/domain/register.js +116 -0
  17. package/attendance-register/domain/student-import.d.ts +51 -0
  18. package/attendance-register/domain/student-import.js +231 -0
  19. package/attendance-register/domain/week.d.ts +40 -0
  20. package/attendance-register/domain/week.js +90 -0
  21. package/attendance-register/index.d.ts +21 -0
  22. package/attendance-register/index.js +19 -0
  23. package/attendance-register/react/register-preview.d.ts +34 -0
  24. package/attendance-register/react/register-preview.js +88 -0
  25. package/attendance-register/react/use-attendance-register.d.ts +33 -0
  26. package/attendance-register/react/use-attendance-register.js +106 -0
  27. package/attendance-register/types.d.ts +90 -0
  28. package/attendance-register/types.js +22 -0
  29. package/base-modules/attendance/page.d.ts +2 -0
  30. package/base-modules/attendance/page.js +21 -1
  31. package/constants.d.ts +2 -3
  32. package/constants.js +2 -3
  33. package/package.json +3 -1
  34. package/tsconfig.build.tsbuildinfo +1 -1
  35. package/types/communication.d.ts +3 -59
  36. package/types/communication.js +2 -2
  37. package/types/user-management.d.ts +0 -6
@@ -0,0 +1,106 @@
1
+ "use client";
2
+ import { useCallback, useEffect, useMemo, useRef, useState } from "react";
3
+ import { MONTHS, } from "../types";
4
+ import { getDaysInMonth, getNextMonth, getWeekGroups, getWorkingDays, parseNoSchoolDays, } from "../domain/calendar";
5
+ import { DEFAULT_REGISTER_LOCALE } from "../domain/locale";
6
+ import { getDefaultWeekendDays } from "../domain/week";
7
+ import { formatClassLabel, getRegisterSummary } from "../domain/register";
8
+ function currentMonth() {
9
+ return MONTHS[new Date().getMonth()];
10
+ }
11
+ /**
12
+ * Headless register state shared by both apps. It owns only register concerns;
13
+ * contact details, analytics and API fetching stay in the consuming repo.
14
+ */
15
+ export function useAttendanceRegister({ initialState, onChange, }) {
16
+ const [state, setState] = useState(initialState);
17
+ const onChangeRef = useRef(onChange);
18
+ useEffect(() => {
19
+ onChangeRef.current = onChange;
20
+ }, [onChange]);
21
+ useEffect(() => {
22
+ var _a;
23
+ (_a = onChangeRef.current) === null || _a === void 0 ? void 0 : _a.call(onChangeRef, state);
24
+ }, [state]);
25
+ const updateField = useCallback((key, value) => {
26
+ setState((previous) => (Object.assign(Object.assign({}, previous), { [key]: value })));
27
+ }, []);
28
+ const setStudents = useCallback((students) => {
29
+ setState((previous) => (Object.assign(Object.assign({}, previous), { students })));
30
+ }, []);
31
+ const removeStudent = useCallback((id) => {
32
+ setState((previous) => (Object.assign(Object.assign({}, previous), { students: previous.students.filter((student) => student.id !== id) })));
33
+ }, []);
34
+ const updateStudent = useCallback((id, patch) => {
35
+ setState((previous) => (Object.assign(Object.assign({}, previous), { students: previous.students.map((student) => student.id === id ? Object.assign(Object.assign({}, student), patch) : student) })));
36
+ }, []);
37
+ const clearStudents = useCallback(() => {
38
+ setState((previous) => (Object.assign(Object.assign({}, previous), { students: [] })));
39
+ }, []);
40
+ const resetRegister = useCallback(() => {
41
+ setState((previous) => (Object.assign(Object.assign({}, previous), { className: "", section: "", grade: "", month: currentMonth(), year: new Date().getFullYear(), format: "a4", layout: "monthly", density: "standard", weekStartsOn: "monday", weekendDays: getDefaultWeekendDays(previous.country), noSchoolDaysInput: "", students: [], locale: DEFAULT_REGISTER_LOCALE })));
42
+ }, []);
43
+ const advanceMonth = useCallback(() => {
44
+ const next = getNextMonth(state.month, state.year);
45
+ setState((previous) => (Object.assign(Object.assign({}, previous), { month: next.month, year: next.year, noSchoolDaysInput: "" })));
46
+ return next;
47
+ }, [state.month, state.year]);
48
+ const days = useMemo(() => getDaysInMonth(state.month, state.year, state.weekendDays, state.locale), [state.month, state.year, state.weekendDays, state.locale]);
49
+ const weeks = useMemo(() => getWeekGroups(state.month, state.year, state.weekStartsOn, state.weekendDays, state.locale), [state.month, state.year, state.weekStartsOn, state.weekendDays, state.locale]);
50
+ const parsedNoSchool = useMemo(() => parseNoSchoolDays(state.noSchoolDaysInput, days.length, {
51
+ monthIndex: MONTHS.indexOf(state.month),
52
+ year: state.year,
53
+ }), [state.noSchoolDaysInput, days.length, state.month, state.year]);
54
+ const workingDays = useMemo(() => getWorkingDays(days, parsedNoSchool.days), [days, parsedNoSchool.days]);
55
+ const config = useMemo(() => ({
56
+ className: state.className.trim(),
57
+ section: state.section.trim(),
58
+ grade: state.grade.trim(),
59
+ month: state.month,
60
+ year: state.year,
61
+ format: state.format,
62
+ layout: state.layout,
63
+ density: state.density,
64
+ weekStartsOn: state.weekStartsOn,
65
+ weekendDays: state.weekendDays,
66
+ noSchoolDays: parsedNoSchool.days,
67
+ students: state.students,
68
+ schoolName: state.schoolName.trim(),
69
+ locale: state.locale,
70
+ }), [state, parsedNoSchool.days]);
71
+ const summary = useMemo(() => getRegisterSummary(config), [config]);
72
+ const classLabel = state.className.trim() ? formatClassLabel(config) : "Add a class name";
73
+ const canExportLocal = state.schoolName.trim().length >= 2 &&
74
+ state.className.trim().length > 0 &&
75
+ state.students.length > 0 &&
76
+ parsedNoSchool.invalid.length === 0;
77
+ const localError = state.schoolName.trim().length < 2
78
+ ? "Enter a school name (at least 2 characters)."
79
+ : !state.className.trim()
80
+ ? "Enter a class name."
81
+ : state.students.length === 0
82
+ ? "Add at least one student."
83
+ : parsedNoSchool.invalid.length > 0
84
+ ? "Fix the no-school day numbers first."
85
+ : "";
86
+ return {
87
+ state,
88
+ setState,
89
+ updateField,
90
+ setStudents,
91
+ removeStudent,
92
+ updateStudent,
93
+ clearStudents,
94
+ resetRegister,
95
+ advanceMonth,
96
+ days,
97
+ weeks,
98
+ parsedNoSchool,
99
+ workingDays,
100
+ config,
101
+ summary,
102
+ classLabel,
103
+ canExportLocal,
104
+ localError,
105
+ };
106
+ }
@@ -0,0 +1,90 @@
1
+ /**
2
+ * Shared attendance-register domain types.
3
+ *
4
+ * These types are intentionally free of React, Next.js, next-intl and auth
5
+ * concerns so the public schoolkit tool and the fusion SaaS can both use them.
6
+ */
7
+ export interface Student {
8
+ id: string;
9
+ name: string;
10
+ rollNumber: string;
11
+ /** Optional school-issued identifier. Names are not unique; this is. */
12
+ admissionNumber?: string;
13
+ }
14
+ export type PaperFormat = "a4" | "a3" | "letter" | "legal";
15
+ export type RegisterLayout = "monthly" | "weekly";
16
+ export type WeekStart = "monday" | "sunday";
17
+ export type RegisterDensity = "standard" | "compact";
18
+ /** Short marks printed in the register when recorded attendance is included. */
19
+ export type AttendanceMark = "P" | "A" | "L" | "E" | "H";
20
+ /** JavaScript weekday indices: 0 = Sunday … 6 = Saturday. */
21
+ export declare const DEFAULT_WEEKEND_DAYS: readonly number[];
22
+ export interface RegisterConfig {
23
+ className: string;
24
+ section: string;
25
+ grade: string;
26
+ month: string;
27
+ year: number;
28
+ format: PaperFormat;
29
+ layout: RegisterLayout;
30
+ /** Compact rows fit more students per page; standard rows leave more room to write. */
31
+ density: RegisterDensity;
32
+ weekStartsOn: WeekStart;
33
+ /** Weekday indices treated as closed, e.g. [0, 6] or [5, 6]. */
34
+ weekendDays: number[];
35
+ noSchoolDays: number[];
36
+ students: Student[];
37
+ schoolName: string;
38
+ /** Locale used for month and weekday labels, e.g. "es". */
39
+ locale: string;
40
+ /** Optional marks keyed by student id and day number. */
41
+ attendance?: Record<string, Record<number, AttendanceMark>>;
42
+ }
43
+ /**
44
+ * A reusable roster plus its print settings. This is the neutral shape both
45
+ * schoolkit's saved classes and fusion's class-section groups map into.
46
+ */
47
+ export interface RegisterRoster {
48
+ id?: string;
49
+ className: string;
50
+ section: string;
51
+ grade: string;
52
+ students: Student[];
53
+ weekendDays: number[];
54
+ locale: string;
55
+ format: PaperFormat;
56
+ layout: RegisterLayout;
57
+ density: RegisterDensity;
58
+ weekStartsOn: WeekStart;
59
+ }
60
+ /** Month-specific state shared by both register builders. */
61
+ export interface RegisterFormState {
62
+ schoolName: string;
63
+ country: string;
64
+ locale: string;
65
+ className: string;
66
+ section: string;
67
+ grade: string;
68
+ month: string;
69
+ year: number;
70
+ format: PaperFormat;
71
+ layout: RegisterLayout;
72
+ density: RegisterDensity;
73
+ weekStartsOn: WeekStart;
74
+ weekendDays: number[];
75
+ noSchoolDaysInput: string;
76
+ students: Student[];
77
+ }
78
+ export interface AttendanceDay {
79
+ day: number;
80
+ weekday: string;
81
+ isWeekend: boolean;
82
+ }
83
+ export interface WeekGroup {
84
+ weekNumber: number;
85
+ startDay: number;
86
+ endDay: number;
87
+ /** Seven slots, Monday-first or Sunday-first. Null means outside the month. */
88
+ slots: (AttendanceDay | null)[];
89
+ }
90
+ export declare const MONTHS: string[];
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Shared attendance-register domain types.
3
+ *
4
+ * These types are intentionally free of React, Next.js, next-intl and auth
5
+ * concerns so the public schoolkit tool and the fusion SaaS can both use them.
6
+ */
7
+ /** JavaScript weekday indices: 0 = Sunday … 6 = Saturday. */
8
+ export const DEFAULT_WEEKEND_DAYS = [0, 6];
9
+ export const MONTHS = [
10
+ "January",
11
+ "February",
12
+ "March",
13
+ "April",
14
+ "May",
15
+ "June",
16
+ "July",
17
+ "August",
18
+ "September",
19
+ "October",
20
+ "November",
21
+ "December",
22
+ ];
@@ -30,6 +30,8 @@ interface Props {
30
30
  labelRemarks: string;
31
31
  labelStatus: string;
32
32
  labelStudent: string;
33
+ registerHref?: string;
34
+ labelRegister?: string;
33
35
  saveLabel: string;
34
36
  searchPlaceholder: string;
35
37
  tableDescription: string;
@@ -78,6 +78,26 @@ const GenericAttendancePage = createGenericModulePage();
78
78
  const AttendancePageInner = (props) => {
79
79
  const context = useAttendanceModule();
80
80
  const t = useTranslations("attendance");
81
+ const pageContext = useMemo(() => {
82
+ var _a;
83
+ if (!props.registerHref)
84
+ return context;
85
+ return Object.assign(Object.assign({}, context), { headerActions: [
86
+ ...context.headerActions,
87
+ {
88
+ enabled: true,
89
+ handleOnClick: () => {
90
+ window.location.assign(props.registerHref);
91
+ },
92
+ label: (_a = props.labelRegister) !== null && _a !== void 0 ? _a : "Attendance Register",
93
+ order: context.headerActions.length,
94
+ },
95
+ ] });
96
+ }, [
97
+ context,
98
+ props.labelRegister,
99
+ props.registerHref,
100
+ ]);
81
101
  const statusLabels = useMemo(() => ({
82
102
  PRESENT: t("formOptionPresent"),
83
103
  ABSENT: t("formOptionAbsent"),
@@ -175,6 +195,6 @@ const AttendancePageInner = (props) => {
175
195
  if (!hasPermission) {
176
196
  return _jsx(RbacNoAccess, { moduleName: "Attendance" });
177
197
  }
178
- return (_jsx("div", { className: "p-4", children: _jsx(GenericAttendancePage, { overrideConfig: attendanceConfig, context: context, tableBodyCols: tableBodyCols }) }));
198
+ return (_jsx("div", { className: "p-4", children: _jsx(GenericAttendancePage, { overrideConfig: attendanceConfig, context: pageContext, tableBodyCols: tableBodyCols }) }));
179
199
  };
180
200
  export const AttendancePage = (props) => (_jsx(AttendanceProvider, { children: _jsx(AttendancePageInner, Object.assign({}, props)) }));
package/constants.d.ts CHANGED
@@ -12,6 +12,7 @@ export declare const ATTENDANCE_API_ROUTES: {
12
12
  readonly UNIT: "/api/v1/attendance";
13
13
  readonly AUTO_POST: "/api/v1/attendance/auto-post";
14
14
  readonly AUTO_POST_STATUS: (jobId: string) => string;
15
+ readonly REGISTER: "/api/v1/attendance/register";
15
16
  };
16
17
  export declare const BULK_OPERATIONS_API_ROUTES: {
17
18
  readonly LIST: "/api/v1/bulk-operations";
@@ -116,6 +117,7 @@ export declare const DASHBOARD_ROUTES: {
116
117
  AI_ASSISTANT: string;
117
118
  AI_ATTENDANCE: string;
118
119
  ATTENDANCE: string;
120
+ ATTENDANCE_REGISTER: string;
119
121
  BULK_OPERATIONS: string;
120
122
  CLASS: string;
121
123
  COMMUNICATION: string;
@@ -185,9 +187,6 @@ export declare const CSVS: {
185
187
  Admission: string;
186
188
  AdmissionAI: string;
187
189
  Attendance: string;
188
- BlogComment: string;
189
- BlogCommentClap: string;
190
- BlogPost: string;
191
190
  Campaign: string;
192
191
  Campus: string;
193
192
  Class: string;
package/constants.js CHANGED
@@ -15,6 +15,7 @@ export const ATTENDANCE_API_ROUTES = {
15
15
  UNIT: "/api/v1/attendance",
16
16
  AUTO_POST: "/api/v1/attendance/auto-post",
17
17
  AUTO_POST_STATUS: (jobId) => `/api/v1/attendance/auto-post/${jobId}`,
18
+ REGISTER: "/api/v1/attendance/register",
18
19
  };
19
20
  export const BULK_OPERATIONS_API_ROUTES = {
20
21
  LIST: "/api/v1/bulk-operations",
@@ -129,6 +130,7 @@ export const DASHBOARD_ROUTES = {
129
130
  AI_ASSISTANT: "/tools/ai-assistant",
130
131
  AI_ATTENDANCE: "/tools/ai-attendance",
131
132
  ATTENDANCE: "/operational-tracking/attendance",
133
+ ATTENDANCE_REGISTER: "/tools/attendance-register",
132
134
  BULK_OPERATIONS: "/apps/bulk-operations",
133
135
  CLASS: "/academic-structure/class",
134
136
  COMMUNICATION: "/communication",
@@ -198,9 +200,6 @@ export const CSVS = {
198
200
  Admission: "https://storage.edupilotpro.com/fusion-public/data-tables/Admission.csv",
199
201
  AdmissionAI: "https://storage.edupilotpro.com/fusion-public/data-tables/AdmissionAI.csv",
200
202
  Attendance: "https://storage.edupilotpro.com/fusion-public/data-tables/Attendance.csv",
201
- BlogComment: "https://storage.edupilotpro.com/fusion-public/data-tables/BlogComment.csv",
202
- BlogCommentClap: "https://storage.edupilotpro.com/fusion-public/data-tables/BlogCommentClap.csv",
203
- BlogPost: "https://storage.edupilotpro.com/fusion-public/data-tables/BlogPost.csv",
204
203
  Campaign: "https://storage.edupilotpro.com/fusion-public/data-tables/Campaign.csv",
205
204
  Campus: "https://storage.edupilotpro.com/fusion-public/data-tables/Campus.csv",
206
205
  Class: "https://storage.edupilotpro.com/fusion-public/data-tables/Class.csv",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appcorp/fusion-storybook",
3
- "version": "0.5.40",
3
+ "version": "0.6.2",
4
4
  "scripts": {
5
5
  "build-storybook": "storybook build",
6
6
  "build:next": "next build",
@@ -86,10 +86,12 @@
86
86
  "eslint-config-next": "16",
87
87
  "eslint-config-prettier": "^10.1.8",
88
88
  "eslint-plugin-prettier": "^5.5.5",
89
+ "fflate": "^0.8.3",
89
90
  "husky": "^9.1.7",
90
91
  "jest": "^30.3.0",
91
92
  "jest-environment-jsdom": "^30.3.0",
92
93
  "json-2-csv": "^5.5.10",
94
+ "jspdf": "^4.2.1",
93
95
  "libphonenumber-js": "^1.13.3",
94
96
  "lint-staged": "^16.4.0",
95
97
  "lucide-react": "^1.8.0",