react-native-hilal 0.1.0 → 0.3.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.
Files changed (62) hide show
  1. package/README.md +165 -49
  2. package/lib/module/calendar/Appear.js +75 -0
  3. package/lib/module/calendar/Appear.js.map +1 -0
  4. package/lib/module/calendar/DayCell.js +32 -5
  5. package/lib/module/calendar/DayCell.js.map +1 -1
  6. package/lib/module/calendar/HilalCalendar.js +434 -76
  7. package/lib/module/calendar/HilalCalendar.js.map +1 -1
  8. package/lib/module/calendar/PickerGrid.js +66 -0
  9. package/lib/module/calendar/PickerGrid.js.map +1 -0
  10. package/lib/module/calendar/month.js +135 -22
  11. package/lib/module/calendar/month.js.map +1 -1
  12. package/lib/module/calendar/range.js +103 -0
  13. package/lib/module/calendar/range.js.map +1 -0
  14. package/lib/module/calendar/styles.js +233 -7
  15. package/lib/module/calendar/styles.js.map +1 -1
  16. package/lib/module/calendar/theme.js +3 -3
  17. package/lib/module/calendar/theme.js.map +1 -1
  18. package/lib/module/core/convert.js +52 -21
  19. package/lib/module/core/convert.js.map +1 -1
  20. package/lib/module/core/index.js.map +1 -1
  21. package/lib/module/core/locale.js +5 -2
  22. package/lib/module/core/locale.js.map +1 -1
  23. package/lib/typescript/src/calendar/Appear.d.ts +22 -0
  24. package/lib/typescript/src/calendar/Appear.d.ts.map +1 -0
  25. package/lib/typescript/src/calendar/DayCell.d.ts +8 -1
  26. package/lib/typescript/src/calendar/DayCell.d.ts.map +1 -1
  27. package/lib/typescript/src/calendar/HilalCalendar.d.ts +1 -1
  28. package/lib/typescript/src/calendar/HilalCalendar.d.ts.map +1 -1
  29. package/lib/typescript/src/calendar/PickerGrid.d.ts +28 -0
  30. package/lib/typescript/src/calendar/PickerGrid.d.ts.map +1 -0
  31. package/lib/typescript/src/calendar/index.d.ts +1 -1
  32. package/lib/typescript/src/calendar/index.d.ts.map +1 -1
  33. package/lib/typescript/src/calendar/month.d.ts +30 -7
  34. package/lib/typescript/src/calendar/month.d.ts.map +1 -1
  35. package/lib/typescript/src/calendar/range.d.ts +39 -0
  36. package/lib/typescript/src/calendar/range.d.ts.map +1 -0
  37. package/lib/typescript/src/calendar/styles.d.ts +207 -113
  38. package/lib/typescript/src/calendar/styles.d.ts.map +1 -1
  39. package/lib/typescript/src/calendar/theme.d.ts +21 -1
  40. package/lib/typescript/src/calendar/theme.d.ts.map +1 -1
  41. package/lib/typescript/src/calendar/types.d.ts +153 -2
  42. package/lib/typescript/src/calendar/types.d.ts.map +1 -1
  43. package/lib/typescript/src/core/convert.d.ts +38 -15
  44. package/lib/typescript/src/core/convert.d.ts.map +1 -1
  45. package/lib/typescript/src/core/index.d.ts +1 -1
  46. package/lib/typescript/src/core/index.d.ts.map +1 -1
  47. package/lib/typescript/src/core/locale.d.ts +1 -1
  48. package/lib/typescript/src/core/locale.d.ts.map +1 -1
  49. package/package.json +1 -1
  50. package/src/calendar/Appear.tsx +94 -0
  51. package/src/calendar/DayCell.tsx +41 -1
  52. package/src/calendar/HilalCalendar.tsx +541 -85
  53. package/src/calendar/PickerGrid.tsx +99 -0
  54. package/src/calendar/index.ts +8 -1
  55. package/src/calendar/month.ts +174 -23
  56. package/src/calendar/range.ts +114 -0
  57. package/src/calendar/styles.ts +249 -6
  58. package/src/calendar/theme.ts +23 -3
  59. package/src/calendar/types.ts +156 -2
  60. package/src/core/convert.ts +87 -23
  61. package/src/core/index.ts +1 -0
  62. package/src/core/locale.ts +4 -1
@@ -3,5 +3,5 @@ import type { HilalCalendarProps } from './types.js';
3
3
  * A month-grid date picker for the Umm al-Qura Hijri and the Gregorian
4
4
  * calendar.
5
5
  */
6
- export declare function HilalCalendar({ value, defaultValue, onChange, calendar: calendarProp, onCalendarChange, showCalendarToggle, showSecondaryDate, locale, digits: digitsProp, direction, firstDayOfWeek, minDate, maxDate, isDateDisabled, theme: themeProp, style, dayStyle, }: HilalCalendarProps): import("react").JSX.Element;
6
+ export declare function HilalCalendar({ value, defaultValue, onChange, selectionMode, rangeValue, defaultRangeValue, onRangeChange, minRangeDays, maxRangeDays, calendar: calendarProp, onCalendarChange, showCalendarToggle, showSecondaryDate, locale, digits: digitsProp, direction, firstDayOfWeek, minDate, maxDate, isDateDisabled, hijriAdjustment, showMonthYearPicker, weekdayFormat, theme: themeProp, styles: stylesProp, labels: labelsProp, style, dayStyle, maxFontSizeMultiplier, }: HilalCalendarProps): import("react").JSX.Element;
7
7
  //# sourceMappingURL=HilalCalendar.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"HilalCalendar.d.ts","sourceRoot":"","sources":["../../../../src/calendar/HilalCalendar.tsx"],"names":[],"mappings":"AA0CA,OAAO,KAAK,EAAE,kBAAkB,EAAgB,MAAM,YAAS,CAAC;AAyEhE;;;GAGG;AACH,wBAAgB,aAAa,CAAC,EAC5B,KAAK,EACL,YAAY,EACZ,QAAQ,EACR,QAAQ,EAAE,YAAsB,EAChC,gBAAgB,EAChB,kBAAyB,EACzB,iBAAwB,EACxB,MAAa,EACb,MAAM,EAAE,UAAU,EAClB,SAAkB,EAClB,cAAkB,EAClB,OAAO,EACP,OAAO,EACP,cAAc,EACd,KAAK,EAAE,SAAkB,EACzB,KAAK,EACL,QAAQ,GACT,EAAE,kBAAkB,+BAqQpB"}
1
+ {"version":3,"file":"HilalCalendar.d.ts","sourceRoot":"","sources":["../../../../src/calendar/HilalCalendar.tsx"],"names":[],"mappings":"AAmEA,OAAO,KAAK,EAEV,kBAAkB,EAGnB,MAAM,YAAS,CAAC;AAmIjB;;;GAGG;AACH,wBAAgB,aAAa,CAAC,EAC5B,KAAK,EACL,YAAY,EACZ,QAAQ,EACR,aAAwB,EACxB,UAAU,EACV,iBAAiB,EACjB,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,QAAQ,EAAE,YAAsB,EAChC,gBAAgB,EAChB,kBAAyB,EACzB,iBAAwB,EACxB,MAAa,EACb,MAAM,EAAE,UAAU,EAClB,SAAkB,EAClB,cAAkB,EAClB,OAAO,EACP,OAAO,EACP,cAAc,EACd,eAAmB,EACnB,mBAA0B,EAC1B,aAAuB,EACvB,KAAK,EAAE,SAAkB,EACzB,MAAM,EAAE,UAAU,EAClB,MAAM,EAAE,UAAU,EAClB,KAAK,EACL,QAAQ,EACR,qBAAqB,GACtB,EAAE,kBAAkB,+BA4lBpB"}
@@ -0,0 +1,28 @@
1
+ import type { CalendarStyles } from './styles.js';
2
+ export type PickerGridItem = {
3
+ key: number;
4
+ label: string;
5
+ accessibilityLabel: string;
6
+ selected: boolean;
7
+ /** The current month or year (today's), drawn with a ring. */
8
+ current: boolean;
9
+ disabled: boolean;
10
+ };
11
+ type PickerGridProps = {
12
+ items: PickerGridItem[];
13
+ styles: CalendarStyles;
14
+ /** 'row' or 'row-reverse', the same as the day grid. */
15
+ row: 'row' | 'row-reverse';
16
+ /** Grow the rows to fill the parent's height. */
17
+ fill: boolean;
18
+ /** maxFontSizeMultiplier of the texts. */
19
+ maxFontScale: number;
20
+ onSelect: (key: number) => void;
21
+ };
22
+ /**
23
+ * The month or year picker: items in rows of three, each a button. Only
24
+ * rendered while the picker is open.
25
+ */
26
+ export declare function PickerGrid({ items, styles, row, fill, maxFontScale, onSelect, }: PickerGridProps): import("react").JSX.Element;
27
+ export {};
28
+ //# sourceMappingURL=PickerGrid.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PickerGrid.d.ts","sourceRoot":"","sources":["../../../../src/calendar/PickerGrid.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAU,CAAC;AAE/C,MAAM,MAAM,cAAc,GAAG;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,kBAAkB,EAAE,MAAM,CAAC;IAC3B,QAAQ,EAAE,OAAO,CAAC;IAClB,8DAA8D;IAC9D,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF,KAAK,eAAe,GAAG;IACrB,KAAK,EAAE,cAAc,EAAE,CAAC;IACxB,MAAM,EAAE,cAAc,CAAC;IACvB,wDAAwD;IACxD,GAAG,EAAE,KAAK,GAAG,aAAa,CAAC;IAC3B,iDAAiD;IACjD,IAAI,EAAE,OAAO,CAAC;IACd,0CAA0C;IAC1C,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;CACjC,CAAC;AAYF;;;GAGG;AACH,wBAAgB,UAAU,CAAC,EACzB,KAAK,EACL,MAAM,EACN,GAAG,EACH,IAAI,EACJ,YAAY,EACZ,QAAQ,GACT,EAAE,eAAe,+BAmDjB"}
@@ -1,4 +1,4 @@
1
1
  export { HilalCalendar } from './HilalCalendar.js';
2
2
  export { darkTheme, lightTheme, type HilalTheme, type ThemeProp, } from './theme.js';
3
- export type { HilalCalendarProps, SelectedDate } from './types.js';
3
+ export type { DateRange, HilalCalendarProps, HilalLabels, HilalStyles, SelectedDate, SelectedRange, } from './types.js';
4
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/calendar/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAiB,CAAC;AAChD,OAAO,EACL,SAAS,EACT,UAAU,EACV,KAAK,UAAU,EACf,KAAK,SAAS,GACf,MAAM,YAAS,CAAC;AACjB,YAAY,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,YAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/calendar/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAiB,CAAC;AAChD,OAAO,EACL,SAAS,EACT,UAAU,EACV,KAAK,UAAU,EACf,KAAK,SAAS,GACf,MAAM,YAAS,CAAC;AACjB,YAAY,EACV,SAAS,EACT,kBAAkB,EAClB,WAAW,EACX,WAAW,EACX,YAAY,EACZ,aAAa,GACd,MAAM,YAAS,CAAC"}
@@ -27,30 +27,30 @@ export type DayRange = {
27
27
  export declare const SUPPORTED_DAYS: DayRange;
28
28
  export declare function otherCalendar(calendar: CalendarType): CalendarType;
29
29
  /** Epoch day of the first day of a month. */
30
- export declare function monthStart({ calendar, year, month }: CalendarMonth): number;
30
+ export declare function monthStart({ calendar, year, month }: CalendarMonth, adjustment?: number): number;
31
31
  /** Number of days in a month. */
32
32
  export declare function monthLength(m: CalendarMonth): number;
33
33
  /** Year, month and day of an epoch day in either calendar. */
34
- export declare function dateInCalendar(epochDay: number, calendar: CalendarType): import("../core/days.js").CivilDate;
34
+ export declare function dateInCalendar(epochDay: number, calendar: CalendarType, adjustment?: number): import("../core/days.js").CivilDate;
35
35
  /**
36
36
  * The month of `calendar` that contains `epochDay`. Days outside the
37
37
  * supported range are clamped to it first.
38
38
  */
39
- export declare function monthContaining(epochDay: number, calendar: CalendarType): CalendarMonth;
39
+ export declare function monthContaining(epochDay: number, calendar: CalendarType, adjustment?: number): CalendarMonth;
40
40
  export declare function addMonths(m: CalendarMonth, delta: number): CalendarMonth;
41
41
  export declare function clampDay(epochDay: number, range: DayRange): number;
42
42
  /**
43
43
  * The days that may be selected: `minDay`/`maxDay` (when given)
44
44
  * intersected with the supported range.
45
45
  */
46
- export declare function selectableRange(minDay: number | undefined, maxDay: number | undefined): DayRange;
46
+ export declare function selectableRange(minDay: number | undefined, maxDay: number | undefined, adjustment?: number): DayRange;
47
47
  /** Whether any day of month `m` falls inside `range`. */
48
- export declare function monthOverlaps(m: CalendarMonth, range: DayRange): boolean;
48
+ export declare function monthOverlaps(m: CalendarMonth, range: DayRange, adjustment?: number): boolean;
49
49
  /**
50
50
  * Lays out month `m` in weeks starting on `firstDayOfWeek` (0 = Sunday,
51
51
  * 1 = Monday, 6 = Saturday).
52
52
  */
53
- export declare function buildMonthGrid(m: CalendarMonth, firstDayOfWeek: number): MonthGrid;
53
+ export declare function buildMonthGrid(m: CalendarMonth, firstDayOfWeek: number, adjustment?: number): MonthGrid;
54
54
  /** "رمضان ١٤٤٦" / "Ramadan 1446" / "March 2025". */
55
55
  export declare function monthTitle(m: CalendarMonth, locale: Locale, digits: Digits): string;
56
56
  /**
@@ -59,5 +59,28 @@ export declare function monthTitle(m: CalendarMonth, locale: Locale, digits: Dig
59
59
  * a year boundary, or a single month. Only days in the supported range
60
60
  * count.
61
61
  */
62
- export declare function secondaryTitle(m: CalendarMonth, locale: Locale, digits: Digits): string;
62
+ export declare function secondaryTitle(m: CalendarMonth, locale: Locale, digits: Digits, adjustment?: number): string;
63
+ /** Years shown on one page of the year picker. */
64
+ export declare const YEARS_PER_PAGE = 12;
65
+ /** A month (1-12) or a year in the picker, and whether it can be picked. */
66
+ export type PickerItem = {
67
+ value: number;
68
+ disabled: boolean;
69
+ };
70
+ /** Whether any day of `year` falls inside `range`. */
71
+ export declare function yearOverlaps(calendar: CalendarType, year: number, range: DayRange, adjustment?: number): boolean;
72
+ /** The 12 months of `year`, disabled when none of their days is in `range`. */
73
+ export declare function monthsOfYear(calendar: CalendarType, year: number, range: DayRange, adjustment?: number): PickerItem[];
74
+ /** First year of the year-picker page that contains `year`. */
75
+ export declare function yearPageStart(year: number): number;
76
+ /** The years of the page starting at `pageStart`. */
77
+ export declare function yearsOnPage(calendar: CalendarType, pageStart: number, range: DayRange, adjustment?: number): PickerItem[];
78
+ /** Whether the page starting at `pageStart` has any year that can be picked. */
79
+ export declare function pageOverlaps(calendar: CalendarType, pageStart: number, range: DayRange, adjustment?: number): boolean;
80
+ /**
81
+ * The years of the other calendar that years `fromYear` to `toYear`
82
+ * overlap, for example "٢٠٢٣ – ٢٠٢٤" for 1445 AH, or a single year. Only
83
+ * days in the supported range count.
84
+ */
85
+ export declare function yearsSecondaryTitle(calendar: CalendarType, fromYear: number, toYear: number, digits: Digits, adjustment?: number): string;
63
86
  //# sourceMappingURL=month.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"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which days a range covers and how pressing a day
3
+ * changes it. Pure functions on epoch days, no React.
4
+ */
5
+ /** A picked range of days. `end` is undefined while only the start is picked. */
6
+ export type DayRangeSelection = {
7
+ start: number;
8
+ end?: number;
9
+ };
10
+ /** The fewest and most days a range may have, both ends included. */
11
+ export type RangeLimits = {
12
+ min: number;
13
+ max: number;
14
+ };
15
+ export declare const NO_RANGE_LIMITS: RangeLimits;
16
+ /**
17
+ * Checks minRangeDays and maxRangeDays: whole numbers of at least 1, the
18
+ * minimum no larger than the maximum. Throws a RangeError otherwise.
19
+ */
20
+ export declare function checkRangeLimits(min: number | undefined, max: number | undefined): RangeLimits;
21
+ /**
22
+ * Whether `day` can't end the range started at `range.start` because the
23
+ * range would be shorter or longer than `limits`. Only days after the
24
+ * start of a range without an end; any other day can be pressed.
25
+ */
26
+ export declare function outsideRangeLimits(range: DayRangeSelection | undefined, day: number, limits: RangeLimits): boolean;
27
+ /**
28
+ * The range after pressing `day`. The first press picks the start, the
29
+ * second the end. A press before the start, a press after a complete
30
+ * range, a press across a blocked day, or a press that would make the
31
+ * range shorter or longer than `limits` starts a new range instead.
32
+ */
33
+ export declare function nextRange(current: DayRangeSelection | undefined, day: number, isBlocked?: (day: number) => boolean, limits?: RangeLimits): DayRangeSelection;
34
+ /** Where a day sits in a range: its ends, inside it, or alone in it. */
35
+ export type RangePosition = 'start' | 'middle' | 'end' | 'single';
36
+ export declare function rangePosition(range: DayRangeSelection | undefined, day: number): RangePosition | null;
37
+ /** Days in a complete range, both ends included. */
38
+ export declare function rangeLength(range: DayRangeSelection): number | null;
39
+ //# sourceMappingURL=range.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"range.d.ts","sourceRoot":"","sources":["../../../../src/calendar/range.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,iFAAiF;AACjF,MAAM,MAAM,iBAAiB,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAEhE,qEAAqE;AACrE,MAAM,MAAM,WAAW,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC;AAEvD,eAAO,MAAM,eAAe,EAAE,WAAuC,CAAC;AAEtE;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,MAAM,GAAG,SAAS,EACvB,GAAG,EAAE,MAAM,GAAG,SAAS,GACtB,WAAW,CAkBb;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,iBAAiB,GAAG,SAAS,EACpC,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,WAAW,WAOpB;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CACvB,OAAO,EAAE,iBAAiB,GAAG,SAAS,EACtC,GAAG,EAAE,MAAM,EACX,SAAS,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,EACpC,MAAM,GAAE,WAA6B,GACpC,iBAAiB,CAoBnB;AAED,wEAAwE;AACxE,MAAM,MAAM,aAAa,GAAG,OAAO,GAAG,QAAQ,GAAG,KAAK,GAAG,QAAQ,CAAC;AAElE,wBAAgB,aAAa,CAC3B,KAAK,EAAE,iBAAiB,GAAG,SAAS,EACpC,GAAG,EAAE,MAAM,GACV,aAAa,GAAG,IAAI,CAYtB;AAED,oDAAoD;AACpD,wBAAgB,WAAW,CAAC,KAAK,EAAE,iBAAiB,iBAEnD"}
@@ -1,119 +1,213 @@
1
1
  import type { HilalTheme } from './theme.js';
2
+ import type { HilalStyles } from './types.js';
2
3
  export type CalendarStyles = ReturnType<typeof createStyles>;
4
+ /**
5
+ * How far the phone's text size setting may grow the text of day cells,
6
+ * weekday names and picker buttons, which have a fixed size: up to 1.3 a
7
+ * day number and the date under it still fit a 48 pt cell.
8
+ */
9
+ export declare const MAX_CELL_FONT_SCALE = 1.3;
10
+ /** The same for the header and the toggle, which have room to grow. */
11
+ export declare const MAX_HEADER_FONT_SCALE = 2;
3
12
  export declare function createStyles(theme: HilalTheme): Readonly<{
4
- container: {
5
- backgroundColor: string;
6
- borderRadius: number;
7
- padding: number;
8
- };
9
- toggle: {
10
- alignSelf: "center";
11
- borderColor: string;
12
- borderRadius: number;
13
- borderWidth: number;
14
- marginBottom: number;
15
- padding: number;
16
- };
17
- toggleOption: {
18
- borderRadius: number;
19
- paddingHorizontal: number;
20
- paddingVertical: number;
21
- };
22
- toggleOptionActive: {
23
- backgroundColor: string;
24
- };
25
- toggleText: {
26
- color: string;
27
- fontSize: number;
28
- fontWeight: "600";
29
- };
30
- toggleTextActive: {
31
- color: string;
32
- };
33
- header: {
34
- alignItems: "center";
35
- marginBottom: number;
36
- };
37
- titles: {
38
- alignItems: "center";
39
- flex: number;
40
- };
41
- title: {
42
- color: string;
43
- fontSize: number;
44
- fontWeight: "700";
45
- };
46
- subtitle: {
47
- color: string;
48
- fontSize: number;
49
- marginTop: number;
50
- };
51
- arrow: {
52
- alignItems: "center";
53
- borderRadius: number;
54
- height: number;
55
- justifyContent: "center";
56
- width: number;
57
- };
58
- arrowPressed: {
59
- backgroundColor: string;
60
- };
61
- weekdays: {
62
- marginBottom: number;
63
- };
64
- weekday: {
65
- color: string;
66
- flex: number;
67
- fontSize: number;
68
- fontWeight: "600";
69
- textAlign: "center";
70
- };
71
- week: {};
72
- slot: {
73
- alignItems: "center";
74
- flex: number;
75
- paddingHorizontal: number;
76
- paddingVertical: number;
77
- };
78
- day: {
79
- alignItems: "center";
80
- borderColor: string;
81
- borderRadius: number;
82
- borderWidth: number;
83
- height: number;
84
- justifyContent: "center";
85
- maxWidth: number;
86
- width: string;
87
- };
88
- today: {
89
- borderColor: string;
90
- };
91
- selected: {
92
- backgroundColor: string;
93
- borderColor: string;
94
- };
95
- pressed: {
96
- backgroundColor: string;
97
- };
98
- dayText: {
99
- color: string;
100
- fontSize: number;
101
- fontWeight: "600";
102
- };
103
- secondaryText: {
104
- color: string;
105
- fontSize: number;
106
- marginTop: number;
107
- };
108
- selectedText: {
109
- color: string;
110
- };
111
- selectedSecondaryText: {
112
- color: string;
113
- opacity: number;
114
- };
115
- disabledText: {
116
- color: string;
13
+ readonly container: {
14
+ readonly backgroundColor: string;
15
+ readonly borderRadius: 20;
16
+ readonly padding: 12;
17
+ };
18
+ readonly toggle: {
19
+ readonly alignSelf: "center";
20
+ readonly borderColor: string;
21
+ readonly borderRadius: 999;
22
+ readonly borderWidth: 1;
23
+ readonly marginBottom: 12;
24
+ readonly padding: 3;
25
+ };
26
+ readonly toggleOption: {
27
+ readonly borderRadius: 999;
28
+ readonly paddingHorizontal: 16;
29
+ readonly paddingVertical: 6;
30
+ };
31
+ readonly toggleOptionActive: {
32
+ readonly backgroundColor: string;
33
+ };
34
+ readonly toggleText: {
35
+ readonly color: string;
36
+ readonly fontSize: 14;
37
+ readonly fontWeight: "600";
38
+ };
39
+ readonly toggleTextActive: {
40
+ readonly color: string;
41
+ };
42
+ readonly header: {
43
+ readonly alignItems: "center";
44
+ readonly marginBottom: 8;
45
+ };
46
+ readonly titles: {
47
+ readonly alignItems: "center";
48
+ readonly flex: 1;
49
+ };
50
+ readonly title: {
51
+ readonly color: string;
52
+ readonly fontSize: 18;
53
+ readonly fontWeight: "700";
54
+ };
55
+ readonly subtitle: {
56
+ readonly color: string;
57
+ readonly fontSize: 13;
58
+ readonly marginTop: 2;
59
+ };
60
+ readonly arrow: {
61
+ readonly alignItems: "center";
62
+ readonly borderRadius: 999;
63
+ readonly height: 40;
64
+ readonly justifyContent: "center";
65
+ readonly width: 40;
66
+ };
67
+ readonly arrowPressed: {
68
+ readonly backgroundColor: string;
69
+ };
70
+ readonly weekdays: {
71
+ readonly marginBottom: 8;
72
+ };
73
+ readonly weekday: {
74
+ readonly color: string;
75
+ readonly flex: 1;
76
+ readonly fontSize: 12;
77
+ readonly fontWeight: "600";
78
+ readonly textAlign: "center";
79
+ };
80
+ readonly week: {};
81
+ readonly slot: {
82
+ readonly alignItems: "center";
83
+ readonly flex: 1;
84
+ readonly paddingHorizontal: 3;
85
+ readonly paddingVertical: 2;
86
+ };
87
+ readonly rangeBand: {
88
+ readonly backgroundColor: string;
89
+ readonly bottom: 2;
90
+ readonly opacity: 0.15;
91
+ readonly position: "absolute";
92
+ readonly top: 2;
93
+ };
94
+ readonly day: {
95
+ readonly alignItems: "center";
96
+ readonly borderColor: "transparent";
97
+ readonly borderRadius: number;
98
+ readonly borderWidth: 1.5;
99
+ readonly height: 48;
100
+ readonly justifyContent: "center";
101
+ readonly maxWidth: 48;
102
+ readonly width: "100%";
103
+ };
104
+ readonly today: {
105
+ readonly borderColor: string;
106
+ };
107
+ readonly selected: {
108
+ readonly backgroundColor: string;
109
+ readonly borderColor: string;
110
+ };
111
+ readonly pressed: {
112
+ readonly backgroundColor: string;
113
+ };
114
+ readonly dayText: {
115
+ readonly color: string;
116
+ readonly fontSize: 16;
117
+ readonly fontWeight: "500";
118
+ readonly lineHeight: 20;
119
+ };
120
+ readonly secondaryText: {
121
+ readonly color: string;
122
+ readonly fontSize: 11;
123
+ readonly lineHeight: 14;
124
+ readonly marginTop: 1;
125
+ };
126
+ readonly selectedText: {
127
+ readonly color: string;
128
+ readonly fontWeight: "700";
129
+ };
130
+ readonly todayText: {
131
+ readonly fontWeight: "700";
132
+ };
133
+ readonly selectedSecondaryText: {
134
+ readonly color: string;
135
+ readonly opacity: 0.8;
136
+ };
137
+ readonly disabledText: {
138
+ readonly color: string;
139
+ };
140
+ readonly titleButton: {
141
+ readonly alignItems: "center";
142
+ readonly borderRadius: 10;
143
+ readonly overflow: "hidden";
144
+ readonly paddingHorizontal: 10;
145
+ readonly paddingVertical: 2;
146
+ };
147
+ readonly titleInButton: {
148
+ readonly flexShrink: 1;
149
+ readonly textAlign: "center";
150
+ };
151
+ readonly titleStatic: {
152
+ readonly paddingVertical: 2;
153
+ };
154
+ readonly titleButtonPressed: {
155
+ readonly backgroundColor: string;
156
+ };
157
+ readonly titleTint: {
158
+ readonly backgroundColor: string;
159
+ readonly opacity: 0.1;
160
+ readonly bottom: 0;
161
+ readonly left: 0;
162
+ readonly position: "absolute";
163
+ readonly right: 0;
164
+ readonly top: 0;
165
+ };
166
+ readonly picker: {
167
+ readonly marginTop: 4;
168
+ };
169
+ readonly pickerSlot: {
170
+ readonly flex: 1;
171
+ readonly padding: 3;
172
+ };
173
+ readonly pickerItem: {
174
+ readonly alignItems: "center";
175
+ readonly borderColor: "transparent";
176
+ readonly borderRadius: number;
177
+ readonly borderWidth: 1.5;
178
+ readonly justifyContent: "center";
179
+ readonly minHeight: 52;
180
+ readonly overflow: "hidden";
181
+ readonly paddingHorizontal: 4;
182
+ readonly paddingVertical: 6;
183
+ };
184
+ readonly grow: {
185
+ readonly flexGrow: 1;
186
+ };
187
+ readonly pickerItemTint: {
188
+ readonly backgroundColor: string;
189
+ readonly opacity: 0.05;
190
+ readonly bottom: 0;
191
+ readonly left: 0;
192
+ readonly position: "absolute";
193
+ readonly right: 0;
194
+ readonly top: 0;
195
+ };
196
+ readonly pickerText: {
197
+ readonly color: string;
198
+ readonly fontSize: 14;
199
+ readonly fontWeight: "600";
200
+ readonly lineHeight: 18;
201
+ readonly textAlign: "center";
117
202
  };
118
203
  }>;
204
+ /**
205
+ * Merges the `styles` prop over the calendar styles: `styles` for the
206
+ * calendar and the picker, `dayStyles` for the day cells. Slots that are
207
+ * not set leave the calendar styles as they are.
208
+ */
209
+ export declare function withSlots(styles: CalendarStyles, slots: HilalStyles | undefined): {
210
+ styles: CalendarStyles;
211
+ dayStyles: CalendarStyles;
212
+ };
119
213
  //# sourceMappingURL=styles.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../../src/calendar/styles.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAS,CAAC;AAE1C,MAAM,MAAM,cAAc,GAAG,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC;AAE7D,wBAAgB,YAAY,CAAC,KAAK,EAAE,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwH7C"}
1
+ {"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../../src/calendar/styles.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAS,CAAC;AAC1C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAS,CAAC;AAW3C,MAAM,MAAM,cAAc,GAAG,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC;AAK7D;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,MAAM,CAAC;AACvC,uEAAuE;AACvE,eAAO,MAAM,qBAAqB,IAAI,CAAC;AA0BvC,wBAAgB,YAAY,CAAC,KAAK,EAAE,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAE7C;AAuFD;;;;GAIG;AACH,wBAAgB,SAAS,CACvB,MAAM,EAAE,cAAc,EACtB,KAAK,EAAE,WAAW,GAAG,SAAS,GAC7B;IAAE,MAAM,EAAE,cAAc,CAAC;IAAC,SAAS,EAAE,cAAc,CAAA;CAAE,CAmBvD"}
@@ -1,4 +1,4 @@
1
- /** Colors and shape of the calendar. */
1
+ /** Colors, fonts and shape of the calendar. */
2
2
  export type HilalTheme = {
3
3
  /** Calendar background. */
4
4
  background: string;
@@ -18,6 +18,26 @@ export type HilalTheme = {
18
18
  border: string;
19
19
  /** Corner radius of a day cell. */
20
20
  radius: number;
21
+ /** Month arrows. Default: `text`. */
22
+ arrow?: string;
23
+ /**
24
+ * Font of all text, for example 'Cairo-Regular'. Default: the system
25
+ * font.
26
+ */
27
+ fontFamily?: string;
28
+ /**
29
+ * Font of the bold text (month title, selected day and today, toggle,
30
+ * weekdays, picker), for example 'Cairo-Bold'. When set, it is used as is,
31
+ * without a fontWeight on top. Default: `fontFamily` with a bold weight.
32
+ */
33
+ fontFamilyBold?: string;
34
+ /**
35
+ * Multiplies every font size, for example 1.15 for larger text. Day
36
+ * cells grow with it. Weekday names and the picker's month and year
37
+ * names shrink with it but never grow, so they still fit their columns
38
+ * on small phones. Default 1.
39
+ */
40
+ fontScale?: number;
21
41
  };
22
42
  export type ThemeProp = 'light' | 'dark' | 'auto' | Partial<HilalTheme>;
23
43
  export declare const lightTheme: HilalTheme;
@@ -1 +1 @@
1
- {"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../../../src/calendar/theme.ts"],"names":[],"mappings":"AAAA,wCAAwC;AACxC,MAAM,MAAM,UAAU,GAAG;IACvB,2BAA2B;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,wCAAwC;IACxC,IAAI,EAAE,MAAM,CAAC;IACb,kDAAkD;IAClD,aAAa,EAAE,MAAM,CAAC;IACtB,+CAA+C;IAC/C,OAAO,EAAE,MAAM,CAAC;IAChB,yBAAyB;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,gCAAgC;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,wDAAwD;IACxD,QAAQ,EAAE,MAAM,CAAC;IACjB,sBAAsB;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,mCAAmC;IACnC,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AAExE,eAAO,MAAM,UAAU,EAAE,UAUxB,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,UAUvB,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,YAAY,CAC1B,KAAK,EAAE,S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