react-native-hilal 0.1.0 → 0.2.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 (57) hide show
  1. package/README.md +119 -40
  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 +4 -1
  5. package/lib/module/calendar/DayCell.js.map +1 -1
  6. package/lib/module/calendar/HilalCalendar.js +341 -64
  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/styles.js +219 -6
  13. package/lib/module/calendar/styles.js.map +1 -1
  14. package/lib/module/calendar/theme.js +3 -3
  15. package/lib/module/calendar/theme.js.map +1 -1
  16. package/lib/module/core/convert.js +52 -21
  17. package/lib/module/core/convert.js.map +1 -1
  18. package/lib/module/core/index.js.map +1 -1
  19. package/lib/module/core/locale.js +5 -2
  20. package/lib/module/core/locale.js.map +1 -1
  21. package/lib/typescript/src/calendar/Appear.d.ts +22 -0
  22. package/lib/typescript/src/calendar/Appear.d.ts.map +1 -0
  23. package/lib/typescript/src/calendar/DayCell.d.ts +3 -1
  24. package/lib/typescript/src/calendar/DayCell.d.ts.map +1 -1
  25. package/lib/typescript/src/calendar/HilalCalendar.d.ts +1 -1
  26. package/lib/typescript/src/calendar/HilalCalendar.d.ts.map +1 -1
  27. package/lib/typescript/src/calendar/PickerGrid.d.ts +28 -0
  28. package/lib/typescript/src/calendar/PickerGrid.d.ts.map +1 -0
  29. package/lib/typescript/src/calendar/index.d.ts +1 -1
  30. package/lib/typescript/src/calendar/index.d.ts.map +1 -1
  31. package/lib/typescript/src/calendar/month.d.ts +30 -7
  32. package/lib/typescript/src/calendar/month.d.ts.map +1 -1
  33. package/lib/typescript/src/calendar/styles.d.ts +200 -113
  34. package/lib/typescript/src/calendar/styles.d.ts.map +1 -1
  35. package/lib/typescript/src/calendar/theme.d.ts +21 -1
  36. package/lib/typescript/src/calendar/theme.d.ts.map +1 -1
  37. package/lib/typescript/src/calendar/types.d.ts +106 -2
  38. package/lib/typescript/src/calendar/types.d.ts.map +1 -1
  39. package/lib/typescript/src/core/convert.d.ts +38 -15
  40. package/lib/typescript/src/core/convert.d.ts.map +1 -1
  41. package/lib/typescript/src/core/index.d.ts +1 -1
  42. package/lib/typescript/src/core/index.d.ts.map +1 -1
  43. package/lib/typescript/src/core/locale.d.ts +1 -1
  44. package/lib/typescript/src/core/locale.d.ts.map +1 -1
  45. package/package.json +1 -1
  46. package/src/calendar/Appear.tsx +94 -0
  47. package/src/calendar/DayCell.tsx +6 -0
  48. package/src/calendar/HilalCalendar.tsx +406 -77
  49. package/src/calendar/PickerGrid.tsx +99 -0
  50. package/src/calendar/index.ts +6 -1
  51. package/src/calendar/month.ts +174 -23
  52. package/src/calendar/styles.ts +235 -5
  53. package/src/calendar/theme.ts +23 -3
  54. package/src/calendar/types.ts +109 -2
  55. package/src/core/convert.ts +87 -23
  56. package/src/core/index.ts +1 -0
  57. package/src/core/locale.ts +4 -1
package/README.md CHANGED
@@ -22,11 +22,11 @@ iOS, Android, web and Expo Go. Zero dependencies. Arabic-first.
22
22
 
23
23
  - **Umm al-Qura**, the official calendar of Saudi Arabia, tested against ICU on every day from 1937 to 2077.
24
24
  - **Hijri and Gregorian together**: switch the grid between them, and every day also shows its date in the other calendar.
25
- - **Arabic-first**: Arabic month and day names, Arabic-Indic digits (١٢٣), proper right-to-left layout. English with Latin digits is one prop away.
25
+ - **Arabic-first**: Arabic month and day names, Arabic-Indic digits (`١٢٣`), proper right-to-left layout. English with Latin digits is one prop away.
26
26
  - **Cross-platform**: pure TypeScript and React Native core components. The same code runs on iOS, Android, the web and in Expo Go, with no native modules.
27
27
  - **Zero runtime dependencies**: no moment, no dayjs, no `Intl` calendars at runtime.
28
- - **Themeable**: light, dark, follow the system, or your own colors.
29
- - **Accessible**: every day is a button with a full spoken date and its selected and disabled state.
28
+ - **Customizable**: light, dark, follow the system, or your own colors and fonts; styles for every part and your own button texts.
29
+ - **Accessible**: every day is a button with a full spoken date, its selected and disabled state, and "today". Text follows the phone's text size within limits that keep the layout intact, and animations respect reduce motion.
30
30
  - **The engine is public**: convert and format Hijri dates without using the UI.
31
31
 
32
32
  ## Installation
@@ -41,6 +41,8 @@ npx expo install react-native-hilal
41
41
 
42
42
  `react` and `react-native` are the only peer dependencies. There is nothing to link and no native build step.
43
43
 
44
+ Hilal is designed for phones first. On the web (React Native Web) it works the same, but text is drawn with the browser's fonts, so it can look slightly different.
45
+
44
46
  ## Quick start
45
47
 
46
48
  ```tsx
@@ -74,7 +76,7 @@ export default function Screen() {
74
76
  }
75
77
  ```
76
78
 
77
- With the default `locale="ar"`, `formatted.hijri` is ١ رمضان ١٤٤٦ هـ and `formatted.gregorian` is ١ مارس ٢٠٢٥ in Arabic-Indic digits.
79
+ With the default `locale="ar"`, `formatted.hijri` is `'١ رمضان ١٤٤٦ هـ'` and `formatted.gregorian` is `'١ مارس ٢٠٢٥'`, in Arabic-Indic digits.
78
80
 
79
81
  ## Examples
80
82
 
@@ -101,34 +103,42 @@ The [example app](example) shows every feature side by side. Run it with `yarn e
101
103
 
102
104
  ## `<HilalCalendar />` props
103
105
 
104
- | Prop | Type | Default | Description |
105
- | -------------------- | ---------------------------------------------------- | ----------------------------------- | ---------------------------------------------------------------------------------------- |
106
- | `value` | `Date` | | Selected day (controlled). Only the local calendar day is used. |
107
- | `defaultValue` | `Date` | | Initially selected day (uncontrolled). |
108
- | `onChange` | `(date: SelectedDate) => void` | | Called when the user picks a day. |
109
- | `calendar` | `'hijri' \| 'gregorian'` | `'hijri'` | Calendar of the month grid. The grid follows this prop when it changes. |
110
- | `onCalendarChange` | `(calendar) => void` | | Called when the user switches calendars with the toggle. |
111
- | `showCalendarToggle` | `boolean` | `true` | Show the Hijri / Gregorian toggle. |
112
- | `showSecondaryDate` | `boolean` | `true` | Show the other calendar's day under each day. |
113
- | `locale` | `'ar' \| 'en'` | `'ar'` | Language of month names, weekdays and labels. |
114
- | `digits` | `'arabic' \| 'latin'` | `'arabic'` for `ar`, else `'latin'` | Arabic-Indic (١٢٣) or Latin (123) digits. |
115
- | `direction` | `'rtl' \| 'ltr' \| 'auto'` | `'auto'` | `auto` is right-to-left when the app is RTL (`I18nManager.isRTL`) or the locale is `ar`. |
116
- | `firstDayOfWeek` | `0 \| 1 \| 6` | `0` | `0` Sunday, `1` Monday, `6` Saturday. |
117
- | `minDate` | `Date` | | Earliest selectable day. Navigation stops at its month. |
118
- | `maxDate` | `Date` | | Latest selectable day. Navigation stops at its month. |
119
- | `isDateDisabled` | `(date: SelectedDate) => boolean` | | Return `true` to disable a day. |
120
- | `theme` | `'light' \| 'dark' \| 'auto' \| Partial<HilalTheme>` | `'auto'` | `auto` follows `useColorScheme()`. A partial theme is merged over the `auto` theme. |
121
- | `style` | `StyleProp<ViewStyle>` | | Style of the outer container. |
122
- | `dayStyle` | `StyleProp<ViewStyle>` | | Style of every day cell. |
106
+ | Prop | Type | Default | Description |
107
+ | ----------------------- | ---------------------------------------------------- | ----------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
108
+ | `value` | `Date` | | Selected day (controlled). Only the local calendar day is used. |
109
+ | `defaultValue` | `Date` | | Initially selected day (uncontrolled). |
110
+ | `onChange` | `(date: SelectedDate) => void` | | Called when the user picks a day. |
111
+ | `calendar` | `'hijri' \| 'gregorian'` | `'hijri'` | Calendar of the month grid. The grid follows this prop when it changes. |
112
+ | `onCalendarChange` | `(calendar) => void` | | Called when the user switches calendars with the toggle. |
113
+ | `showCalendarToggle` | `boolean` | `true` | Show the Hijri / Gregorian toggle. |
114
+ | `showSecondaryDate` | `boolean` | `true` | Show the other calendar's day under each day. |
115
+ | `locale` | `'ar' \| 'en'` | `'ar'` | Language of month names, weekdays and labels. |
116
+ | `digits` | `'arabic' \| 'latin'` | `'arabic'` for `ar`, else `'latin'` | Arabic-Indic (`١٢٣`) or Latin (`123`) digits. |
117
+ | `direction` | `'rtl' \| 'ltr' \| 'auto'` | `'auto'` | `auto` is right-to-left when the app is RTL (`I18nManager.isRTL`) or the locale is `ar`. |
118
+ | `firstDayOfWeek` | `0 \| 1 \| 6` | `0` | `0` Sunday, `1` Monday, `6` Saturday. |
119
+ | `weekdayFormat` | `'short' \| 'narrow'` | `'short'` | Weekday names above the days: `'أحد'` / `'Sun'`, or `'ح'` / `'S'`. |
120
+ | `minDate` | `Date` | | Earliest selectable day. Navigation stops at its month. |
121
+ | `maxDate` | `Date` | | Latest selectable day. Navigation stops at its month. |
122
+ | `isDateDisabled` | `(date: SelectedDate) => boolean` | | Return `true` to disable a day. |
123
+ | `hijriAdjustment` | `number` | `0` | Shift Hijri dates by whole days, from `-2` to `2`. `1` makes every Hijri date one day later. See [Adjusting to local moon sighting](#adjusting-to-local-moon-sighting). |
124
+ | `showMonthYearPicker` | `boolean` | `true` | Pressing the month title opens a grid of months, and from there a grid of years. |
125
+ | `theme` | `'light' \| 'dark' \| 'auto' \| Partial<HilalTheme>` | `'auto'` | `auto` follows `useColorScheme()`. A partial theme is merged over the `auto` theme. |
126
+ | `styles` | `HilalStyles` | | Styles for parts of the calendar. See [Customization](#customization). |
127
+ | `labels` | `HilalLabels` | | Texts of the toggle and buttons. See [Customization](#customization). |
128
+ | `style` | `StyleProp<ViewStyle>` | | Style of the outer container. |
129
+ | `dayStyle` | `StyleProp<ViewStyle>` | | Style of every day cell. Unlike `styles.day`, it also wins over the selected and today styles. |
130
+ | `maxFontSizeMultiplier` | `number` | `1.3` in cells, `2` in the header | How far the phone's text size setting may grow the text. `1` turns it off, `0` removes the limit. |
123
131
 
124
132
  Navigation never goes past `minDate`/`maxDate` or the edges of the supported range (1356–1500 AH), so the calendar can't show a broken month.
125
133
 
134
+ To jump far, for example to a date of birth, press the month title: it opens the 12 months of that year, the arrows change the year, and pressing the year opens a page of 12 years. Months and years with no selectable day are disabled. The grids fade in, keeping the calendar the same height, and switch without animation when the system asks to reduce motion. Turn the picker off with `showMonthYearPicker={false}`.
135
+
126
136
  ### Theme
127
137
 
128
138
  ```ts
129
139
  type HilalTheme = {
130
140
  background: string; // calendar background
131
- text: string; // day numbers, month title, arrows
141
+ text: string; // day numbers, month title
132
142
  textSecondary: string; // secondary dates, weekday names
133
143
  primary: string; // selected day, active toggle
134
144
  onPrimary: string; // text on primary
@@ -136,11 +146,62 @@ type HilalTheme = {
136
146
  disabled: string; // disabled days and arrows
137
147
  border: string; // toggle outline
138
148
  radius: number; // corner radius of a day cell
149
+ arrow?: string; // month arrows, default: text
150
+ fontFamily?: string; // all text, default: the system font
151
+ fontFamilyBold?: string; // bold text: title, selected day, today, weekdays, toggle, picker
152
+ fontScale?: number; // multiplies every font size, default 1
139
153
  };
140
154
  ```
141
155
 
142
156
  `lightTheme` and `darkTheme` are exported if you want to build a full theme from one of them.
143
157
 
158
+ ### Customization
159
+
160
+ Fonts go in the theme. Load them first (for example with `expo-font`) and pass their names. With `fontFamilyBold`, the bold text uses that font as it is, without a bold weight on top. `fontScale` makes all text larger or smaller, and day cells grow with larger text. Weekday names and the month and year names in the picker never grow, so they still fit their columns on small phones.
161
+
162
+ ```tsx
163
+ <HilalCalendar
164
+ theme={{
165
+ fontFamily: 'Cairo-Regular',
166
+ fontFamilyBold: 'Cairo-Bold',
167
+ fontScale: 1.1,
168
+ arrow: '#0F766E',
169
+ }}
170
+ />
171
+ ```
172
+
173
+ For anything else, `styles` takes a style for each part, merged over the theme's styles:
174
+
175
+ ```tsx
176
+ <HilalCalendar
177
+ styles={{
178
+ title: { fontSize: 20 },
179
+ selectedDay: { borderRadius: 8 },
180
+ weekdayText: { color: '#6B7280' },
181
+ }}
182
+ />
183
+ ```
184
+
185
+ | Part | Slots |
186
+ | ------------------------ | ---------------------------------------------------------------------------- |
187
+ | Container | `container` |
188
+ | Hijri / Gregorian toggle | `toggle`, `toggleOption`, `toggleText` |
189
+ | Header | `header`, `title`, `subtitle`, `arrow` |
190
+ | Weekday names | `weekdayText` |
191
+ | Days | `day`, `dayText`, `secondaryDayText` |
192
+ | Day states | `selectedDay`, `selectedDayText`, `today`, `todayDayText`, `disabledDayText` |
193
+ | Month and year picker | `pickerItem`, `pickerText` |
194
+
195
+ The day states apply to day cells only, not to the month and year picker.
196
+
197
+ `labels` replaces the texts of the toggle, and the names screen readers give the buttons. Labels you don't pass keep the locale's text:
198
+
199
+ ```tsx
200
+ <HilalCalendar labels={{ hijri: 'هـ', gregorian: 'م' }} />
201
+ ```
202
+
203
+ The keys are `hijri`, `gregorian`, `today`, `thisMonth`, `thisYear`, `previousMonth`, `nextMonth`, `previousYear`, `nextYear`, `previousYears`, `nextYears`, `chooseMonth` and `chooseYear`.
204
+
144
205
  ## Core API
145
206
 
146
207
  The conversion engine is exported on its own: pure functions, no React.
@@ -159,22 +220,24 @@ formatHijri({ year: 1446, month: 9, day: 1 }, { locale: 'en' }); // '1 Ramadan 1
159
220
  getHijriMonthLength(1446, 9); // 29
160
221
  ```
161
222
 
162
- Without options, `formatHijri` returns ١ رمضان ١٤٤٦ هـ (Arabic, Arabic-Indic digits).
223
+ Without options, `formatHijri` returns `'١ رمضان ١٤٤٦ هـ'` (Arabic, Arabic-Indic digits).
163
224
 
164
- | Function | Description |
165
- | --------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- |
166
- | `toHijri(date: Date): HijriDate` | Hijri date of the local calendar day of `date`. The time of day is ignored. |
167
- | `toGregorian(hijri: HijriDate): Date` | A `Date` at local midnight of the matching Gregorian day. |
168
- | `getHijriMonthLength(year, month): 29 \| 30` | Days in a Hijri month (`month` is 1–12). |
169
- | `isValidHijri(hijri: HijriDate): boolean` | Whether the date exists and is in the supported range. |
170
- | `getSupportedRange(): { min: HijriDate; max: HijriDate }` | `1 Muharram 1356` to `30 Dhu al-Hijjah 1500`. |
171
- | `formatHijri(hijri, { locale?, digits? }): string` | Arabic by default (١ رمضان ١٤٤٦ هـ), or `'1 Ramadan 1446 AH'` with `locale: 'en'`. |
172
- | `getMonthNames(calendar, locale): string[]` | 12 month names. Arabic Gregorian names use the Gulf style (يناير، فبراير، مارس), not the Levantine one. |
173
- | `getWeekdayNames(locale, format?): string[]` | 7 weekday names, Sunday first (matches `Date#getDay()`), `'long'` or `'short'`. |
174
- | `toArabicDigits(input: string \| number): string` | `'1446'` → `'١٤٤٦'`. |
225
+ | Function | Description |
226
+ | --------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------- |
227
+ | `toHijri(date: Date, { adjustment? }): HijriDate` | Hijri date of the local calendar day of `date`. The time of day is ignored. |
228
+ | `toGregorian(hijri: HijriDate, { adjustment? }): Date` | A `Date` at local midnight of the matching Gregorian day. |
229
+ | `getHijriMonthLength(year, month): 29 \| 30` | Days in a Hijri month (`month` is 1–12). |
230
+ | `isValidHijri(hijri: HijriDate): boolean` | Whether the date exists and is in the supported range. |
231
+ | `getSupportedRange(): { min: HijriDate; max: HijriDate }` | `1 Muharram 1356` to `30 Dhu al-Hijjah 1500`. |
232
+ | `formatHijri(hijri, { locale?, digits? }): string` | Arabic by default (`'١ رمضان ١٤٤٦ هـ'`), or `'1 Ramadan 1446 AH'` with `locale: 'en'`. |
233
+ | `getMonthNames(calendar, locale): string[]` | 12 month names. Arabic Gregorian names use the Gulf style (`'يناير'`, `'فبراير'`, `'مارس'`), not the Levantine one. |
234
+ | `getWeekdayNames(locale, format?): string[]` | 7 weekday names, Sunday first (matches `Date#getDay()`), `'long'`, `'short'` or `'narrow'`. |
235
+ | `toArabicDigits(input: string \| number): string` | `'1446'` → `'١٤٤٦'`. |
175
236
 
176
237
  `HijriDate` is `{ year: number; month: number; day: number }` with `month` from 1 to 12. Dates outside the supported range (1937-03-14 to 2077-11-16) throw a `RangeError`.
177
238
 
239
+ All types are exported too: `HilalCalendarProps`, `SelectedDate`, `HilalTheme`, `ThemeProp`, `HilalStyles`, `HilalLabels`, `HijriDate`, `HijriConversionOptions`, `FormatHijriOptions`, `CalendarType`, `Locale`, `Digits` and `WeekdayFormat`.
240
+
178
241
  Dates are always handled as **local calendar days**. A day is never derived from a UTC timestamp, so the result doesn't depend on the time of day or the time zone offset.
179
242
 
180
243
  ## Why Hilal?
@@ -196,26 +259,42 @@ Hilal uses the **Umm al-Qura** calendar, the official calendar of Saudi Arabia.
196
259
 
197
260
  Religious occasions such as the start of Ramadan or Eid are announced from the actual sighting of the crescent moon (_hilal_), and can differ from the Umm al-Qura date by a day. Use Hilal for scheduling and display, and rely on the official announcement for religious observances.
198
261
 
262
+ ### Adjusting to local moon sighting
263
+
264
+ Where months start a day before or after Umm al-Qura, shift the Hijri calendar by whole days, from `-2` to `2`:
265
+
266
+ ```tsx
267
+ // The month started a day earlier here: Umm al-Qura's 29 Sha'ban 1445
268
+ // (10 March 2024) shows as 1 Ramadan 1445.
269
+ <HilalCalendar hijriAdjustment={1} />
270
+ ```
271
+
272
+ ```ts
273
+ toHijri(new Date(2024, 2, 10), { adjustment: 1 }); // { year: 1445, month: 9, day: 1 }
274
+ toGregorian({ year: 1445, month: 9, day: 1 }, { adjustment: 1 }); // Sun Mar 10 2024
275
+ ```
276
+
277
+ Gregorian dates never change. The shift moves the whole calendar, so months keep their Umm al-Qura lengths: a month of 29 days stays 29 days. This is the common approach in Islamic apps, and it matches a local calendar that runs a fixed number of days ahead of or behind Umm al-Qura.
278
+
199
279
  ### How the Umm al-Qura table is made and verified
200
280
 
201
281
  - **Generated, not copied.** [`scripts/generate-umalqura-table.ts`](scripts/generate-umalqura-table.ts) reads the `islamic-umalqura` calendar from Node's built-in ICU and writes [`src/core/umalqura-data.ts`](src/core/umalqura-data.ts). Run `yarn generate:umalqura` to rebuild it.
202
282
  - **Compact.** The table is one 12-bit number per Hijri year (bit set means a 30-day month), plus the start day of 1 Muharram 1356: 145 numbers, about 1.5 KB.
203
283
  - **No `Intl` at runtime.** Support for the `islamic-umalqura` calendar differs between Hermes versions and platforms, so the library only reads the table.
204
- - **Tested day by day.** The test suite compares `toHijri` with ICU for all 51,383 days in the range, at 00:00 and 23:59, and checks every month length and the round trip `toGregorian(toHijri(d)) === d`. The suite runs in a UTC+14 time zone, so any code that takes the day from a UTC timestamp fails.
284
+ - **Tested day by day.** The test suite compares `toHijri` with ICU for all 51,383 days in the range, at 00:00 and 23:59, and checks every month length and the round trip `toGregorian(toHijri(d)) === d`, also for every Hijri adjustment. The suite runs in a UTC+14 time zone, so any code that takes the day from a UTC timestamp fails.
205
285
 
206
286
  ## Roadmap
207
287
 
208
- Ideas for v2:
288
+ Planned next:
209
289
 
210
290
  - Range selection
211
- - Quick year and month picker
212
291
  - Event dots on days
213
292
  - Swipe between months
214
293
  - Ready-made bottom sheet and modal variants
215
294
 
216
295
  ## Contributing
217
296
 
218
- See [CONTRIBUTING.md](CONTRIBUTING.md) for the development workflow, commit conventions and how to send a pull request.
297
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for the development workflow, commit conventions and how to send a pull request. To report a security issue, see [SECURITY.md](SECURITY.md).
219
298
 
220
299
  ## License
221
300
 
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+
3
+ import { useEffect, useState } from 'react';
4
+ import { AccessibilityInfo, Animated, Easing, Platform, View } from 'react-native';
5
+ import { jsx as _jsx } from "react/jsx-runtime";
6
+ const DURATION = 220;
7
+ /** Scale the content starts from, just under its full size. */
8
+ const FROM_SCALE = 0.96;
9
+ /**
10
+ * Fades its content in with a slight zoom when it mounts, so switching
11
+ * between the days and the month or year picker is not an abrupt jump.
12
+ * Give it a new `key` to play it again.
13
+ */
14
+ export function Appear({
15
+ animate,
16
+ style,
17
+ onLayout,
18
+ children
19
+ }) {
20
+ const [animated] = useState(animate);
21
+ const [progress] = useState(() => new Animated.Value(animated ? 0 : 1));
22
+ useEffect(() => {
23
+ if (!animated) {
24
+ return;
25
+ }
26
+ const animation = Animated.timing(progress, {
27
+ toValue: 1,
28
+ duration: DURATION,
29
+ easing: Easing.out(Easing.cubic),
30
+ // React Native Web has no native animation driver.
31
+ useNativeDriver: Platform.OS !== 'web'
32
+ });
33
+ animation.start();
34
+ return () => animation.stop();
35
+ // Plays once, on mount.
36
+ // eslint-disable-next-line react-hooks/exhaustive-deps
37
+ }, []);
38
+ if (!animated) {
39
+ return /*#__PURE__*/_jsx(View, {
40
+ style: style,
41
+ onLayout: onLayout,
42
+ children: children
43
+ });
44
+ }
45
+ const scale = progress.interpolate({
46
+ inputRange: [0, 1],
47
+ outputRange: [FROM_SCALE, 1]
48
+ });
49
+ return /*#__PURE__*/_jsx(Animated.View, {
50
+ style: [style, {
51
+ opacity: progress,
52
+ transform: [{
53
+ scale
54
+ }]
55
+ }],
56
+ onLayout: onLayout,
57
+ children: children
58
+ });
59
+ }
60
+
61
+ /** Whether the user asked the system to reduce motion. */
62
+ export function useReduceMotion() {
63
+ const [reduceMotion, setReduceMotion] = useState(false);
64
+ useEffect(() => {
65
+ let mounted = true;
66
+ AccessibilityInfo.isReduceMotionEnabled().then(enabled => mounted && setReduceMotion(enabled), () => {});
67
+ const subscription = AccessibilityInfo.addEventListener('reduceMotionChanged', setReduceMotion);
68
+ return () => {
69
+ mounted = false;
70
+ subscription.remove();
71
+ };
72
+ }, []);
73
+ return reduceMotion;
74
+ }
75
+ //# sourceMappingURL=Appear.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useEffect","useState","AccessibilityInfo","Animated","Easing","Platform","View","jsx","_jsx","DURATION","FROM_SCALE","Appear","animate","style","onLayout","children","animated","progress","Value","animation","timing","toValue","duration","easing","out","cubic","useNativeDriver","OS","start","stop","scale","interpolate","inputRange","outputRange","opacity","transform","useReduceMotion","reduceMotion","setReduceMotion","mounted","isReduceMotionEnabled","then","enabled","subscription","addEventListener","remove"],"sourceRoot":"../../../src","sources":["calendar/Appear.tsx"],"mappings":";;AAAA,SAASA,SAAS,EAAEC,QAAQ,QAAwB,OAAO;AAC3D,SACEC,iBAAiB,EACjBC,QAAQ,EACRC,MAAM,EACN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AAC;EACF,oBACEF,IAAA,CAACL,QAAQ,CAACG,IAAI;IACZO,KAAK,EAAE,CAACA,KAAK,EAAE;MAAEqB,OAAO,EAAEjB,QAAQ;MAAEkB,SAAS,EAAE,CAAC;QAAEL;MAAM,CAAC;IAAE,CAAC,CAAE;IAC9DhB,QAAQ,EAAEA,QAAS;IAAAC,QAAA,EAElBA;EAAQ,CACI,CAAC;AAEpB;;AAEA;AACA,OAAO,SAASqB,eAAeA,CAAA,EAAG;EAChC,MAAM,CAACC,YAAY,EAAEC,eAAe,CAAC,GAAGrC,QAAQ,CAAC,KAAK,CAAC;EACvDD,SAAS,CAAC,MAAM;IACd,IAAIuC,OAAO,GAAG,IAAI;IAClBrC,iBAAiB,CAACsC,qBAAqB,CAAC,CAAC,CAACC,IAAI,CAC3CC,OAAO,IAAKH,OAAO,IAAID,eAAe,CAACI,OAAO,CAAC,EAChD,MAAM,CAAC,CACT,CAAC;IACD,MAAMC,YAAY,GAAGzC,iBAAiB,CAAC0C,gBAAgB,CACrD,qBAAqB,EACrBN,eACF,CAAC;IACD,OAAO,MAAM;MACXC,OAAO,GAAG,KAAK;MACfI,YAAY,CAACE,MAAM,CAAC,CAAC;IACvB,CAAC;EACH,CAAC,EAAE,EAAE,CAAC;EACN,OAAOR,YAAY;AACrB","ignoreList":[]}
@@ -18,6 +18,7 @@ export function DayCellView({
18
18
  disabled,
19
19
  styles,
20
20
  dayStyle,
21
+ maxFontScale,
21
22
  onSelect
22
23
  }) {
23
24
  return /*#__PURE__*/_jsx(View, {
@@ -35,9 +36,11 @@ export function DayCellView({
35
36
  pressed
36
37
  }) => [styles.day, today && styles.today, selected && styles.selected, pressed && !selected && styles.pressed, dayStyle],
37
38
  children: [/*#__PURE__*/_jsx(Text, {
38
- style: [styles.dayText, disabled && styles.disabledText, selected && styles.selectedText],
39
+ maxFontSizeMultiplier: maxFontScale,
40
+ style: [styles.dayText, disabled && styles.disabledText, today && styles.todayText, selected && styles.selectedText],
39
41
  children: label
40
42
  }), secondaryLabel !== null && /*#__PURE__*/_jsx(Text, {
43
+ maxFontSizeMultiplier: maxFontScale,
41
44
  style: [styles.secondaryText, disabled && styles.disabledText, selected && styles.selectedSecondaryText],
42
45
  children: secondaryLabel
43
46
  })]
@@ -1 +1 @@
1
- {"version":3,"names":["memo","Pressable","Text","View","jsx","_jsx","jsxs","_jsxs","DayCellView","epochDay","label","secondaryLabel","accessibilityLabel","selected","today","disabled","styles","dayStyle","onSelect","style","slot","children","accessibilityRole","accessibilityState","onPress","pressed","day","dayText","disabledText","selectedText","secondaryText","selectedSecondaryText","DayCell"],"sourceRoot":"../../../src","sources":["calendar/DayCell.tsx"],"mappings":";;AAAA,SAASA,IAAI,QAAQ,OAAO;AAC5B,SACEC,SAAS,EACTC,IAAI,EACJC,IAAI,QAGC,cAAc;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAiBtB;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,WAAWA,CAAC;EAC1BC,QAAQ;EACRC,KAAK;EACLC,cAAc;EACdC,kBAAkB;EAClBC,QAAQ;EACRC,KAAK;EACLC,QAAQ;EACRC,MAAM;EACNC,QAAQ;EACRC;AACY,CAAC,EAAE;EACf,oBACEb,IAAA,CAACF,IAAI;IAACgB,KAAK,EAAEH,MAAM,CAACI,IAAK;IAAAC,QAAA,eACvBd,KAAA,CAACN,SAAS;MACRqB,iBAAiB,EAAC,QAAQ;MAC1BV,kBAAkB,EAAEA,kBAAmB;MACvCW,kBAAkB,EAAE;QAAEV,QAAQ;QAAEE;MAAS,CAAE;MAC3CA,QAAQ,EAAEA,QAAS;MACnBS,OAAO,EAAEA,CAAA,KAAMN,QAAQ,CAACT,QAAQ,CAAE;MAClCU,KAAK,EAAEA,CAAC;QAAEM;MAAQ,CAAC,KAAK,CACtBT,MAAM,CAACU,GAAG,EACVZ,KAAK,IAAIE,MAAM,CAACF,KAAK,EACrBD,QAAQ,IAAIG,MAAM,CAACH,QAAQ,EAC3BY,OAAO,IAAI,CAACZ,QAAQ,IAAIG,MAAM,CAACS,OAAO,EACtCR,QAAQ,CACR;MAAAI,QAAA,gBAEFhB,IAAA,CAACH,IAAI;QACHiB,KAAK,EAAE,CACLH,MAAM,CAACW,OAAO,EACdZ,QAAQ,IAAIC,MAAM,CAACY,YAAY,EAC/Bf,QAAQ,IAAIG,MAAM,CAACa,YAAY,CAC/B;QAAAR,QAAA,EAEDX;MAAK,CACF,CAAC,EACNC,cAAc,KAAK,IAAI,iBACtBN,IAAA,CAACH,IAAI;QACHiB,KAAK,EAAE,CACLH,MAAM,CAACc,aAAa,EACpBf,QAAQ,IAAIC,MAAM,CAACY,YAAY,EAC/Bf,QAAQ,IAAIG,MAAM,CAACe,qBAAqB,CACxC;QAAAV,QAAA,EAEDV;MAAc,CACX,CACP;IAAA,CACQ;EAAC,CACR,CAAC;AAEX;AAEA,OAAO,MAAMqB,OAAO,gBAAGhC,IAAI,CAACQ,WAAW,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["memo","Pressable","Text","View","jsx","_jsx","jsxs","_jsxs","DayCellView","epochDay","label","secondaryLabel","accessibilityLabel","selected","today","disabled","styles","dayStyle","maxFontScale","onSelect","style","slot","children","accessibilityRole","accessibilityState","onPress","pressed","day","maxFontSizeMultiplier","dayText","disabledText","todayText","selectedText","secondaryText","selectedSecondaryText","DayCell"],"sourceRoot":"../../../src","sources":["calendar/DayCell.tsx"],"mappings":";;AAAA,SAASA,IAAI,QAAQ,OAAO;AAC5B,SACEC,SAAS,EACTC,IAAI,EACJC,IAAI,QAGC,cAAc;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAmBtB;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,WAAWA,CAAC;EAC1BC,QAAQ;EACRC,KAAK;EACLC,cAAc;EACdC,kBAAkB;EAClBC,QAAQ;EACRC,KAAK;EACLC,QAAQ;EACRC,MAAM;EACNC,QAAQ;EACRC,YAAY;E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