@tugkanpilka/calendar 1.0.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.
- package/LICENSE +22 -0
- package/README.md +310 -0
- package/dist/components/Calendar/Calendar.d.ts +12 -0
- package/dist/components/Calendar/Calendar.d.ts.map +1 -0
- package/dist/components/Calendar/Calendar.types.d.ts +33 -0
- package/dist/components/Calendar/Calendar.types.d.ts.map +1 -0
- package/dist/components/Day/Day.d.ts +7 -0
- package/dist/components/Day/Day.d.ts.map +1 -0
- package/dist/components/Day/Day.types.d.ts +40 -0
- package/dist/components/Day/Day.types.d.ts.map +1 -0
- package/dist/components/MonthHeader/MonthHeader.d.ts +12 -0
- package/dist/components/MonthHeader/MonthHeader.d.ts.map +1 -0
- package/dist/components/MonthHeader/MonthHeader.types.d.ts +33 -0
- package/dist/components/MonthHeader/MonthHeader.types.d.ts.map +1 -0
- package/dist/components/MonthList/MonthList.d.ts +12 -0
- package/dist/components/MonthList/MonthList.d.ts.map +1 -0
- package/dist/components/MonthList/MonthList.types.d.ts +31 -0
- package/dist/components/MonthList/MonthList.types.d.ts.map +1 -0
- package/dist/components/Week/Week.d.ts +12 -0
- package/dist/components/Week/Week.d.ts.map +1 -0
- package/dist/components/Week/Week.types.d.ts +35 -0
- package/dist/components/Week/Week.types.d.ts.map +1 -0
- package/dist/components/WeekdayHeader/WeekdayHeader.d.ts +16 -0
- package/dist/components/WeekdayHeader/WeekdayHeader.d.ts.map +1 -0
- package/dist/components/WeekdayHeader/WeekdayHeader.types.d.ts +16 -0
- package/dist/components/WeekdayHeader/WeekdayHeader.types.d.ts.map +1 -0
- package/dist/core/date/date-formatters.d.ts +65 -0
- package/dist/core/date/date-formatters.d.ts.map +1 -0
- package/dist/core/date/index.d.ts +6 -0
- package/dist/core/date/index.d.ts.map +1 -0
- package/dist/core/date/scroll-utils.d.ts +48 -0
- package/dist/core/date/scroll-utils.d.ts.map +1 -0
- package/dist/core/grid/calendar-grid.d.ts +45 -0
- package/dist/core/grid/calendar-grid.d.ts.map +1 -0
- package/dist/core/grid/index.d.ts +6 -0
- package/dist/core/grid/index.d.ts.map +1 -0
- package/dist/core/grid/virtualization.d.ts +38 -0
- package/dist/core/grid/virtualization.d.ts.map +1 -0
- package/dist/core/index.d.ts +7 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/types.d.ts +70 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/hooks/index.d.ts +10 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/useCalendarItems.d.ts +64 -0
- package/dist/hooks/useCalendarItems.d.ts.map +1 -0
- package/dist/hooks/useInfiniteScroll.d.ts +21 -0
- package/dist/hooks/useInfiniteScroll.d.ts.map +1 -0
- package/dist/hooks/useScrollToDate.d.ts +25 -0
- package/dist/hooks/useScrollToDate.d.ts.map +1 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.esm.js +667 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/index.js +701 -0
- package/dist/index.js.map +1 -0
- package/dist/types/index.d.ts +14 -0
- package/dist/types/index.d.ts.map +1 -0
- package/package.json +64 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure date formatting utilities for Calendar component
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Month name to number mapping (0-11)
|
|
6
|
+
*/
|
|
7
|
+
export declare const MONTH_NUMBERS: Record<string, number>;
|
|
8
|
+
/**
|
|
9
|
+
* Date format strings
|
|
10
|
+
*/
|
|
11
|
+
export declare const DATE_FORMATS: {
|
|
12
|
+
readonly DAY: "yyyy-MM-dd";
|
|
13
|
+
readonly WEEK: (year: number, weekNumber: number) => string;
|
|
14
|
+
readonly MONTH: (year: number, monthNumber: number) => string;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Calendar date formatter utilities
|
|
18
|
+
*/
|
|
19
|
+
export declare const formatCalendarDate: {
|
|
20
|
+
/**
|
|
21
|
+
* Formats a date as a day string (yyyy-MM-dd)
|
|
22
|
+
* @param date - Date to format
|
|
23
|
+
* @returns Formatted date string
|
|
24
|
+
*/
|
|
25
|
+
day: (date: Date) => string;
|
|
26
|
+
/**
|
|
27
|
+
* Formats a date as a week string (yyyy-Www)
|
|
28
|
+
* @param date - Date to format
|
|
29
|
+
* @param weekNumber - Week number
|
|
30
|
+
* @returns Formatted week string
|
|
31
|
+
*/
|
|
32
|
+
week: (date: Date, weekNumber: number) => string;
|
|
33
|
+
/**
|
|
34
|
+
* Formats a month as a string (yyyy-Mmm)
|
|
35
|
+
* @param year - Year
|
|
36
|
+
* @param monthName - Month name (e.g., "January")
|
|
37
|
+
* @returns Formatted month string
|
|
38
|
+
*/
|
|
39
|
+
month: (year: number, monthName: string) => string;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Parses a formatted day string back to a Date
|
|
43
|
+
* @param dateString - Date string in format yyyy-MM-dd
|
|
44
|
+
* @returns Parsed Date object
|
|
45
|
+
*/
|
|
46
|
+
export declare function parseDayString(dateString: string): Date;
|
|
47
|
+
/**
|
|
48
|
+
* Parses a formatted week string back to year and week number
|
|
49
|
+
* @param weekString - Week string in format yyyy-Www
|
|
50
|
+
* @returns Object with year and weekNumber
|
|
51
|
+
*/
|
|
52
|
+
export declare function parseWeekString(weekString: string): {
|
|
53
|
+
year: number;
|
|
54
|
+
weekNumber: number;
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Parses a formatted month string back to year and month number
|
|
58
|
+
* @param monthString - Month string in format yyyy-Mmm
|
|
59
|
+
* @returns Object with year and monthNumber (1-12)
|
|
60
|
+
*/
|
|
61
|
+
export declare function parseMonthString(monthString: string): {
|
|
62
|
+
year: number;
|
|
63
|
+
monthNumber: number;
|
|
64
|
+
};
|
|
65
|
+
//# sourceMappingURL=date-formatters.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"date-formatters.d.ts","sourceRoot":"","sources":["../../../src/core/date/date-formatters.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH;;GAEG;AACH,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAahD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,YAAY;;0BAEV,MAAM,cAAc,MAAM;2BACzB,MAAM,eAAe,MAAM;CACjC,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,kBAAkB;IAC7B;;;;OAIG;gBACS,IAAI,KAAG,MAAM;IAIzB;;;;;OAKG;iBACU,IAAI,cAAc,MAAM,KAAG,MAAM;IAI9C;;;;;OAKG;kBACW,MAAM,aAAa,MAAM,KAAG,MAAM;CAIjD,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAEvD;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG;IACnD,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;CACpB,CASA;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,MAAM,GAAG;IACrD,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;CACrB,CASA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/date/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Scroll position management utilities for Calendar component
|
|
3
|
+
*/
|
|
4
|
+
import type { ScrollPosition, ScrollIntoViewOptions } from '../types';
|
|
5
|
+
import type { DateInfo, MonthInfo } from 'date-range-utils';
|
|
6
|
+
/**
|
|
7
|
+
* Finds the DOM element for a specific date
|
|
8
|
+
* @param dateString - Formatted date string (yyyy-MM-dd)
|
|
9
|
+
* @param container - Scrollable container element
|
|
10
|
+
* @returns The DOM element for the date, or null if not found
|
|
11
|
+
*/
|
|
12
|
+
export declare function findDateElement(dateString: string, container: HTMLElement | null): HTMLElement | null;
|
|
13
|
+
/**
|
|
14
|
+
* Scrolls to a specific date in the calendar
|
|
15
|
+
* @param dateString - Formatted date string (yyyy-MM-dd)
|
|
16
|
+
* @param container - Scrollable container element
|
|
17
|
+
* @param options - Scroll options (behavior, block, inline)
|
|
18
|
+
* @returns Promise that resolves when scrolling is complete
|
|
19
|
+
*/
|
|
20
|
+
export declare function scrollToDate(dateString: string, container: HTMLElement | null, options?: ScrollIntoViewOptions): Promise<void>;
|
|
21
|
+
/**
|
|
22
|
+
* Gets the scroll position of a container
|
|
23
|
+
* @param container - Scrollable container element
|
|
24
|
+
* @returns Current scroll position
|
|
25
|
+
*/
|
|
26
|
+
export declare function getScrollPosition(container: HTMLElement | null): ScrollPosition | null;
|
|
27
|
+
/**
|
|
28
|
+
* Sets the scroll position of a container
|
|
29
|
+
* @param container - Scrollable container element
|
|
30
|
+
* @param position - Scroll position to set
|
|
31
|
+
*/
|
|
32
|
+
export declare function setScrollPosition(container: HTMLElement | null, position: ScrollPosition): void;
|
|
33
|
+
/**
|
|
34
|
+
* Finds the date info for a specific formatted date string in months
|
|
35
|
+
* @param dateString - Formatted date string (yyyy-MM-dd)
|
|
36
|
+
* @param months - Array of month info
|
|
37
|
+
* @returns The date info, or null if not found
|
|
38
|
+
*/
|
|
39
|
+
export declare function findDateInfoInMonths(dateString: string, months: MonthInfo<DateInfo>[]): DateInfo | null;
|
|
40
|
+
/**
|
|
41
|
+
* Calculates the approximate scroll position for a date
|
|
42
|
+
* @param dateString - Formatted date string (yyyy-MM-dd)
|
|
43
|
+
* @param months - Array of month info
|
|
44
|
+
* @param itemHeight - Height of a single item in pixels
|
|
45
|
+
* @returns Approximate scroll position in pixels
|
|
46
|
+
*/
|
|
47
|
+
export declare function calculateDateScrollPosition(dateString: string, months: MonthInfo<DateInfo>[], itemHeight?: number): number;
|
|
48
|
+
//# sourceMappingURL=scroll-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scroll-utils.d.ts","sourceRoot":"","sources":["../../../src/core/date/scroll-utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAEtE,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE5D;;;;;GAKG;AACH,wBAAgB,eAAe,CAC7B,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,WAAW,GAAG,IAAI,GAC5B,WAAW,GAAG,IAAI,CASpB;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAC1B,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,WAAW,GAAG,IAAI,EAC7B,OAAO,GAAE,qBAIR,GACA,OAAO,CAAC,IAAI,CAAC,CAWf;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,WAAW,GAAG,IAAI,GAC5B,cAAc,GAAG,IAAI,CAOvB;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,WAAW,GAAG,IAAI,EAC7B,QAAQ,EAAE,cAAc,GACvB,IAAI,CAKN;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,SAAS,CAAC,QAAQ,CAAC,EAAE,GAC5B,QAAQ,GAAG,IAAI,CAajB;AAED;;;;;;GAMG;AACH,wBAAgB,2BAA2B,CACzC,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,SAAS,CAAC,QAAQ,CAAC,EAAE,EAC7B,UAAU,GAAE,MAAW,GACtB,MAAM,CAeR"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core grid utilities for Calendar component
|
|
3
|
+
*/
|
|
4
|
+
import type { CalendarGridConfig } from '../types';
|
|
5
|
+
/**
|
|
6
|
+
* Default calendar grid configuration
|
|
7
|
+
*/
|
|
8
|
+
export declare const DEFAULT_GRID_CONFIG: CalendarGridConfig;
|
|
9
|
+
/**
|
|
10
|
+
* Calculates the grid index from row and column
|
|
11
|
+
* @param row - Row index (0-based)
|
|
12
|
+
* @param col - Column index (0-based)
|
|
13
|
+
* @param columns - Number of columns in the grid
|
|
14
|
+
* @returns The calculated grid index
|
|
15
|
+
*/
|
|
16
|
+
export declare function calculateGridIndex(row: number, col: number, columns?: number): number;
|
|
17
|
+
/**
|
|
18
|
+
* Checks if a grid index represents a week number cell
|
|
19
|
+
* @param index - Grid index to check
|
|
20
|
+
* @param config - Grid configuration (optional, uses defaults)
|
|
21
|
+
* @returns True if the index represents a week number cell
|
|
22
|
+
*/
|
|
23
|
+
export declare function isWeekNumberCell(index: number, config?: CalendarGridConfig): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Calculates the row index from a grid index
|
|
26
|
+
* @param index - Grid index
|
|
27
|
+
* @param columns - Number of columns in the grid
|
|
28
|
+
* @returns The row index (0-based)
|
|
29
|
+
*/
|
|
30
|
+
export declare function getRowFromIndex(index: number, columns?: number): number;
|
|
31
|
+
/**
|
|
32
|
+
* Calculates the column index from a grid index
|
|
33
|
+
* @param index - Grid index
|
|
34
|
+
* @param columns - Number of columns in the grid
|
|
35
|
+
* @returns The column index (0-based)
|
|
36
|
+
*/
|
|
37
|
+
export declare function getColumnFromIndex(index: number, columns?: number): number;
|
|
38
|
+
/**
|
|
39
|
+
* Calculates the number of rows needed for a given number of items
|
|
40
|
+
* @param itemCount - Total number of items
|
|
41
|
+
* @param columns - Number of columns in the grid
|
|
42
|
+
* @returns The number of rows needed
|
|
43
|
+
*/
|
|
44
|
+
export declare function calculateRowCount(itemCount: number, columns?: number): number;
|
|
45
|
+
//# sourceMappingURL=calendar-grid.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calendar-grid.d.ts","sourceRoot":"","sources":["../../../src/core/grid/calendar-grid.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAEnD;;GAEG;AACH,eAAO,MAAM,mBAAmB,EAAE,kBAGjC,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAChC,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,EACX,OAAO,GAAE,MAAoC,GAC5C,MAAM,CAER;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,MAAM,EACb,MAAM,GAAE,kBAAwC,GAC/C,OAAO,CAET;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAC7B,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,MAAoC,GAC5C,MAAM,CAER;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,MAAoC,GAC5C,MAAM,CAER;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,MAAM,EACjB,OAAO,GAAE,MAAoC,GAC5C,MAAM,CAER"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/grid/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Virtual scrolling utilities for infinite scrolling Calendar
|
|
3
|
+
*/
|
|
4
|
+
import type { ViewportConfig, ViewportRange } from '../types';
|
|
5
|
+
/**
|
|
6
|
+
* Default viewport configuration
|
|
7
|
+
*/
|
|
8
|
+
export declare const DEFAULT_VIEWPORT_CONFIG: ViewportConfig;
|
|
9
|
+
/**
|
|
10
|
+
* Calculates the visible range of items for virtual scrolling
|
|
11
|
+
* @param scrollTop - Current scroll position
|
|
12
|
+
* @param containerHeight - Height of the scrollable container
|
|
13
|
+
* @param config - Viewport configuration
|
|
14
|
+
* @returns The visible range of items
|
|
15
|
+
*/
|
|
16
|
+
export declare function calculateVisibleRange(scrollTop: number, containerHeight: number, config?: ViewportConfig): ViewportRange;
|
|
17
|
+
/**
|
|
18
|
+
* Calculates the total height of all items for virtual scrolling
|
|
19
|
+
* @param itemCount - Total number of items
|
|
20
|
+
* @param itemHeight - Height of a single item
|
|
21
|
+
* @returns Total height in pixels
|
|
22
|
+
*/
|
|
23
|
+
export declare function calculateTotalHeight(itemCount: number, itemHeight?: number): number;
|
|
24
|
+
/**
|
|
25
|
+
* Calculates the offset for a specific item index in virtual scrolling
|
|
26
|
+
* @param index - Item index
|
|
27
|
+
* @param itemHeight - Height of a single item
|
|
28
|
+
* @returns Offset in pixels
|
|
29
|
+
*/
|
|
30
|
+
export declare function calculateItemOffset(index: number, itemHeight?: number): number;
|
|
31
|
+
/**
|
|
32
|
+
* Checks if an item is within the visible range
|
|
33
|
+
* @param itemIndex - Index of the item to check
|
|
34
|
+
* @param range - Current viewport range
|
|
35
|
+
* @returns True if the item is visible
|
|
36
|
+
*/
|
|
37
|
+
export declare function isItemVisible(itemIndex: number, range: ViewportRange): boolean;
|
|
38
|
+
//# sourceMappingURL=virtualization.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"virtualization.d.ts","sourceRoot":"","sources":["../../../src/core/grid/virtualization.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE9D;;GAEG;AACH,eAAO,MAAM,uBAAuB,EAAE,cAIrC,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACnC,SAAS,EAAE,MAAM,EACjB,eAAe,EAAE,MAAM,EACvB,MAAM,GAAE,cAAwC,GAC/C,aAAa,CAmBf;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,SAAS,EAAE,MAAM,EACjB,UAAU,GAAE,MAA2C,GACtD,MAAM,CAER;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,MAAM,EACb,UAAU,GAAE,MAA2C,GACtD,MAAM,CAER;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAC3B,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,aAAa,GACnB,OAAO,CAET"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core domain types for Calendar component
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Calendar grid configuration
|
|
6
|
+
*/
|
|
7
|
+
export interface CalendarGridConfig {
|
|
8
|
+
/** Number of columns in the grid (default: 8 - 7 days + 1 week number) */
|
|
9
|
+
columns: number;
|
|
10
|
+
/** Index of the week number column (default: 7) */
|
|
11
|
+
weekNumberColumn: number;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Virtual scrolling viewport configuration
|
|
15
|
+
*/
|
|
16
|
+
export interface ViewportConfig {
|
|
17
|
+
/** Height of a single item in pixels */
|
|
18
|
+
itemHeight: number;
|
|
19
|
+
/** Number of items to render outside visible area (overscan) */
|
|
20
|
+
overscan: number;
|
|
21
|
+
/** Total number of items */
|
|
22
|
+
totalItems: number;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Viewport range for virtual scrolling
|
|
26
|
+
*/
|
|
27
|
+
export interface ViewportRange {
|
|
28
|
+
/** Start index of visible items */
|
|
29
|
+
startIndex: number;
|
|
30
|
+
/** End index of visible items */
|
|
31
|
+
endIndex: number;
|
|
32
|
+
/** Total number of visible items */
|
|
33
|
+
visibleCount: number;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Infinite scrolling configuration
|
|
37
|
+
*/
|
|
38
|
+
export interface InfiniteScrollConfig {
|
|
39
|
+
/** Whether there are more items to load */
|
|
40
|
+
hasMore: boolean;
|
|
41
|
+
/** Whether currently loading more items */
|
|
42
|
+
isLoading: boolean;
|
|
43
|
+
/** Callback to load more items */
|
|
44
|
+
onLoadMore: () => void | Promise<void>;
|
|
45
|
+
/** Root margin for IntersectionObserver (default: '10px') */
|
|
46
|
+
rootMargin?: string;
|
|
47
|
+
/** Threshold for IntersectionObserver (default: 0) */
|
|
48
|
+
threshold?: number;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Scroll position configuration
|
|
52
|
+
*/
|
|
53
|
+
export interface ScrollPosition {
|
|
54
|
+
/** Scroll top position */
|
|
55
|
+
scrollTop: number;
|
|
56
|
+
/** Scroll left position */
|
|
57
|
+
scrollLeft: number;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* ScrollIntoView options
|
|
61
|
+
*/
|
|
62
|
+
export interface ScrollIntoViewOptions {
|
|
63
|
+
/** Scroll behavior */
|
|
64
|
+
behavior?: 'auto' | 'smooth';
|
|
65
|
+
/** Vertical alignment */
|
|
66
|
+
block?: 'start' | 'center' | 'end' | 'nearest';
|
|
67
|
+
/** Horizontal alignment */
|
|
68
|
+
inline?: 'start' | 'center' | 'end' | 'nearest';
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,0EAA0E;IAC1E,OAAO,EAAE,MAAM,CAAC;IA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4
|
+
export { useCalendarItems } from './useCalendarItems';
|
|
5
|
+
export type { UseCalendarItemsProps, IndicatorConfig, GetIndicatorProps, } from './useCalendarItems';
|
|
6
|
+
export { useInfiniteScroll } from './useInfiniteScroll';
|
|
7
|
+
export type { UseInfiniteScrollProps } from './useInfiniteScroll';
|
|
8
|
+
export { useScrollToDate } from './useScrollToDate';
|
|
9
|
+
export type { UseScrollToDateProps } from './useScrollToDate';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,YAAY,EACV,qBAAqB,EACrB,eAAe,EACf,iBAAiB,GAClB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,YAAY,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAElE,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,YAAY,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generic hook for calendar items rendering
|
|
3
|
+
* Provides utility functions to generate props for calendar components
|
|
4
|
+
*/
|
|
5
|
+
import { type RefObject } from 'react';
|
|
6
|
+
import { DateInfo } from 'date-range-utils';
|
|
7
|
+
/**
|
|
8
|
+
* Generic indicator configuration
|
|
9
|
+
*/
|
|
10
|
+
export interface IndicatorConfig {
|
|
11
|
+
/** Whether to show indicator */
|
|
12
|
+
isDotted?: boolean;
|
|
13
|
+
/** Indicator type */
|
|
14
|
+
dotType?: 'primary' | 'secondary';
|
|
15
|
+
/** Whether the item is focused */
|
|
16
|
+
isFocused?: boolean;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Function to get indicator props for a date
|
|
20
|
+
*/
|
|
21
|
+
export type GetIndicatorProps = (formattedDate: string) => IndicatorConfig;
|
|
22
|
+
/**
|
|
23
|
+
* Props for useCalendarItems hook
|
|
24
|
+
*/
|
|
25
|
+
export interface UseCalendarItemsProps {
|
|
26
|
+
/** Currently selected date (formatted as yyyy-MM-dd) */
|
|
27
|
+
currentDate: string;
|
|
28
|
+
/** Function to set the current date */
|
|
29
|
+
setCurrentDate: (date: string) => void;
|
|
30
|
+
/** Ref for scrolling to the current day */
|
|
31
|
+
scrollRef?: RefObject<HTMLElement | null>;
|
|
32
|
+
/** Optional function to get indicator props for a date */
|
|
33
|
+
getIndicatorProps?: GetIndicatorProps;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Generic hook to generate props and utility functions for rendering calendar items
|
|
37
|
+
* Removes business-specific logic (metadata) and makes it generic
|
|
38
|
+
*
|
|
39
|
+
* @param props - Hook configuration
|
|
40
|
+
* @returns Object with memoized functions to get props for different calendar item types
|
|
41
|
+
*/
|
|
42
|
+
export declare function useCalendarItems(props: UseCalendarItemsProps): {
|
|
43
|
+
getWeekNumberProps: (dateInfo: DateInfo) => {
|
|
44
|
+
text: string;
|
|
45
|
+
key: string;
|
|
46
|
+
isMultiMonth: boolean;
|
|
47
|
+
onClick: () => void;
|
|
48
|
+
};
|
|
49
|
+
getDayProps: (dateInfo: DateInfo) => {
|
|
50
|
+
dateInfo: DateInfo;
|
|
51
|
+
ref: RefObject<HTMLElement | null> | undefined;
|
|
52
|
+
isMarked: boolean;
|
|
53
|
+
isSelected: boolean;
|
|
54
|
+
isRounded: boolean;
|
|
55
|
+
onDateClick: (info: DateInfo) => void;
|
|
56
|
+
key: string;
|
|
57
|
+
};
|
|
58
|
+
getMonthHeaderProps: (monthName: string) => {
|
|
59
|
+
text: string;
|
|
60
|
+
onClick: () => void;
|
|
61
|
+
};
|
|
62
|
+
isWeekNumber: (item: DateInfo) => boolean;
|
|
63
|
+
};
|
|
64
|
+
//# sourceMappingURL=useCalendarItems.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCalendarItems.d.ts","sourceRoot":"","sources":["../../src/hooks/useCalendarItems.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAe,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AACpD,OAAO,EAAE,QAAQ,EAA0B,MAAM,kBAAkB,CAAC;AAIpE;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,gCAAgC;IAChC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,qBAAqB;IACrB,OAAO,CAAC,EAAE,SAAS,GAAG,WAAW,CAAC;IAClC,kCAAkC;IAClC,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG,CAC9B,aAAa,EAAE,MAAM,KAClB,eAAe,CAAC;AAErB;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,wDAAwD;IACxD,WAAW,EAAE,MAAM,CAAC;IACpB,uCAAuC;IACvC,cAAc,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,2CAA2C;IAC3C,SAAS,CAAC,EAAE,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;IAC1C,0DAA0D;IAC1D,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;CACvC;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,qBAAqB;mCAY9C,QAAQ;;;;;;4BA4BR,QAAQ;;;;;;4BAMU,QAAQ;;;qCAsBzB,MAAM;;;;yBAsBX,QAAQ;EAUlB"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hook for infinite scrolling support
|
|
3
|
+
*/
|
|
4
|
+
import { type RefObject } from 'react';
|
|
5
|
+
import type { InfiniteScrollConfig } from '../core/types';
|
|
6
|
+
/**
|
|
7
|
+
* Props for useInfiniteScroll hook
|
|
8
|
+
*/
|
|
9
|
+
export interface UseInfiniteScrollProps extends InfiniteScrollConfig {
|
|
10
|
+
/** Ref to the scrollable container */
|
|
11
|
+
scrollRef?: RefObject<HTMLElement | null>;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Hook for infinite scrolling with IntersectionObserver
|
|
15
|
+
*
|
|
16
|
+
* @param props - Infinite scroll configuration
|
|
17
|
+
*/
|
|
18
|
+
export declare function useInfiniteScroll(props: UseInfiniteScrollProps): {
|
|
19
|
+
sentinelRef: RefObject<HTMLDivElement | null>;
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=useInfiniteScroll.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useInfiniteScroll.d.ts","sourceRoot":"","sources":["../../src/hooks/useInfiniteScroll.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAqB,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAC1D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAE1D;;GAEG;AACH,MAAM,WAAW,sBAAuB,SAAQ,oBAAoB;IAClE,sCAAsC;IACtC,SAAS,CAAC,EAAE,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;CAC3C;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,sBAAsB;;EAgD9D"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hook for scrolling to a specific date
|
|
3
|
+
*/
|
|
4
|
+
import { type RefObject } from 'react';
|
|
5
|
+
import type { ScrollIntoViewOptions } from '../core/types';
|
|
6
|
+
/**
|
|
7
|
+
* Props for useScrollToDate hook
|
|
8
|
+
*/
|
|
9
|
+
export interface UseScrollToDateProps {
|
|
10
|
+
/** Ref to the scrollable container */
|
|
11
|
+
scrollRef?: RefObject<HTMLElement | null>;
|
|
12
|
+
/** Scroll options */
|
|
13
|
+
scrollOptions?: ScrollIntoViewOptions;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Hook for scrolling to a specific date in the calendar
|
|
17
|
+
*
|
|
18
|
+
* @param props - Scroll configuration
|
|
19
|
+
* @returns Function to scroll to a date
|
|
20
|
+
*/
|
|
21
|
+
export declare function useScrollToDate(props?: UseScrollToDateProps): {
|
|
22
|
+
scrollTo: (dateString: string) => Promise<void>;
|
|
23
|
+
findElement: (dateString: string) => HTMLElement | null;
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=useScrollToDate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useScrollToDate.d.ts","sourceRoot":"","sources":["../../src/hooks/useScrollToDate.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAe,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAEpD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAE3D;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,sCAAsC;IACtC,SAAS,CAAC,EAAE,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;IAC1C,qBAAqB;IACrB,aAAa,CAAC,EAAE,qBAAqB,CAAC;CACvC;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,KAAK,GAAE,oBAAyB;2BAIzC,MAAM;8BAeZ,MAAM;EAUtB"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Calendar Component - Public API
|
|
3
|
+
*
|
|
4
|
+
* An infinite scrolling calendar component built with React.
|
|
5
|
+
* Supports render props for maximum customization.
|
|
6
|
+
*/
|
|
7
|
+
export { default as Calendar } from './components/Calendar/Calendar';
|
|
8
|
+
export { default as MonthList } from './components/MonthList/MonthList';
|
|
9
|
+
export { default as Day } from './components/Day/Day';
|
|
10
|
+
export { default as Week } from './components/Week/Week';
|
|
11
|
+
export { default as MonthHeader } from './components/MonthHeader/MonthHeader';
|
|
12
|
+
export { default as WeekdayHeader } from './components/WeekdayHeader/WeekdayHeader';
|
|
13
|
+
export { WEEKDAY_NAMES } from './components/WeekdayHeader/WeekdayHeader';
|
|
14
|
+
export type { CalendarProps, MonthListProps, DayProps, WeekProps, MonthHeaderProps, WeekdayHeaderProps, DayIndicatorProps, WeekIndicatorProps, MonthHeaderIndicatorProps, } from './types';
|
|
15
|
+
export { formatCalendarDate, parseDayString, parseWeekString, parseMonthString, MONTH_NUMBERS, DATE_FORMATS, } from './core/date';
|
|
16
|
+
export { calculateGridIndex, isWeekNumberCell, getRowFromIndex, getColumnFromIndex, calculateRowCount, DEFAULT_GRID_CONFIG, } from './core/grid';
|
|
17
|
+
export { calculateVisibleRange, calculateTotalHeight, calculateItemOffset, isItemVisible, DEFAULT_VIEWPORT_CONFIG, } from './core/grid/virtualization';
|
|
18
|
+
export { findDateElement, scrollToDate, getScrollPosition, setScrollPosition, findDateInfoInMonths, calculateDateScrollPosition, } from './core/date/scroll-utils';
|
|
19
|
+
export type { CalendarGridConfig, ViewportConfig, ViewportRange, InfiniteScrollConfig, ScrollPosition, ScrollIntoViewOptions, } from './core/types';
|
|
20
|
+
export { useCalendarItems, useInfiniteScroll, useScrollToDate, } from './hooks';
|
|
21
|
+
export type { UseCalendarItemsProps, IndicatorConfig, GetIndicatorProps, UseInfiniteScrollProps, UseScrollToDateProps, } from './hooks';
|
|
22
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,gCAAgC,CAAC;AACrE,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,kCAAkC,CAAC;AACxE,OAAO,EAAE,OAAO,IAAI,GAAG,EAAE,MAAM,sBAAs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