react-native-paper-dates 0.10.1 → 0.11.1

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 (48) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +8 -441
  3. package/lib/commonjs/Date/DatePickerModalContent.js +3 -3
  4. package/lib/commonjs/Date/DatePickerModalContent.js.map +1 -1
  5. package/lib/commonjs/Date/DatePickerModalHeader.js +2 -2
  6. package/lib/commonjs/Date/DatePickerModalHeader.js.map +1 -1
  7. package/lib/commonjs/Date/inputUtils.js +4 -4
  8. package/lib/commonjs/Date/inputUtils.js.map +1 -1
  9. package/lib/commonjs/translations/ar.js.map +1 -1
  10. package/lib/commonjs/translations/de.js.map +1 -1
  11. package/lib/commonjs/translations/es.js +25 -0
  12. package/lib/commonjs/translations/es.js.map +1 -0
  13. package/lib/commonjs/translations/fr.js +1 -1
  14. package/lib/commonjs/translations/fr.js.map +1 -1
  15. package/lib/commonjs/translations/it.js +25 -0
  16. package/lib/commonjs/translations/it.js.map +1 -0
  17. package/lib/module/Date/DatePickerModalContent.js +3 -3
  18. package/lib/module/Date/DatePickerModalContent.js.map +1 -1
  19. package/lib/module/Date/DatePickerModalHeader.js +2 -2
  20. package/lib/module/Date/DatePickerModalHeader.js.map +1 -1
  21. package/lib/module/Date/inputUtils.js +1 -1
  22. package/lib/module/Date/inputUtils.js.map +1 -1
  23. package/lib/module/translations/ar.js.map +1 -1
  24. package/lib/module/translations/de.js.map +1 -1
  25. package/lib/module/translations/es.js +18 -0
  26. package/lib/module/translations/es.js.map +1 -0
  27. package/lib/module/translations/fr.js +1 -1
  28. package/lib/module/translations/fr.js.map +1 -1
  29. package/lib/module/translations/it.js +18 -0
  30. package/lib/module/translations/it.js.map +1 -0
  31. package/lib/typescript/Date/DatePickerModalContent.d.ts +1 -0
  32. package/lib/typescript/translations/es.d.ts +3 -0
  33. package/lib/typescript/translations/it.d.ts +3 -0
  34. package/package.json +17 -8
  35. package/src/Date/DatePickerModalContent.tsx +4 -3
  36. package/src/Date/DatePickerModalHeader.tsx +2 -2
  37. package/src/Date/inputUtils.ts +2 -2
  38. package/src/translations/ar.ts +1 -1
  39. package/src/translations/de.ts +1 -0
  40. package/src/translations/es.ts +21 -0
  41. package/src/translations/fr.ts +16 -18
  42. package/src/translations/it.ts +21 -0
  43. package/lib/commonjs/Date/dateUtils.test.js +0 -9
  44. package/lib/commonjs/Date/dateUtils.test.js.map +0 -1
  45. package/lib/module/Date/dateUtils.test.js +0 -6
  46. package/lib/module/Date/dateUtils.test.js.map +0 -1
  47. package/lib/typescript/Date/dateUtils.test.d.ts +0 -1
  48. package/src/Date/dateUtils.test.ts +0 -9
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2020 Webridge Design
3
+ Copyright (c) 2022 webRidge
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
 
2
2
  <img align="left" width="56" height="56" src="https://user-images.githubusercontent.com/6492229/98982291-70b42480-251f-11eb-8d67-4b0b1b6e917b.png"> react-native-paper-dates
3
3
  ---
4
+
4
5
  <br>
5
6
 
6
7
  <p float="left">
@@ -24,456 +25,22 @@
24
25
 
25
26
  [![Demo of react-native-paper-dates](https://user-images.githubusercontent.com/6492229/98866767-bd3f2780-246d-11eb-890e-3491b47c95c5.gif)](https://www.youtube.com/watch?v=SHhQU2doTug)
26
27
 
27
- View video in better frame [on YouTube](https://www.youtube.com/watch?v=SHhQU2doTug)
28
+ ## Documentation
29
+
30
+ Check out the official docs: [web-ridge.github.io/react-native-paper-dates](https://web-ridge.github.io/react-native-paper-dates/)
31
+
32
+ ## Demo
28
33
 
29
- Web demo: [reactnativepaperdates.com](http://reactnativepaperdates.com/)
34
+ [reactnativepaperdates.com](https://www.reactnativepaperdates.com/)
30
35
 
31
36
  ## About us
37
+
32
38
  We want developers to be able to build software faster using modern tools like GraphQL, Golang and React Native.
33
39
 
34
40
  Give us a follow on Twitter:
35
41
  [RichardLindhout](https://twitter.com/RichardLindhout),
36
42
  [web_ridge](https://twitter.com/web_ridge)
37
43
 
38
- ## Donate
39
- Please contribute or donate so we can spend more time on this library
40
-
41
- [Donate with PayPal](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=7B9KKQLXTEW9Q&source=url)
42
-
43
-
44
- ## Getting started
45
- First install and follow the guides at [react-native-paper](https://callstack.github.io/react-native-paper/)
46
-
47
- Yarn
48
- ```
49
- yarn add react-native-paper-dates
50
- ```
51
-
52
- npm
53
- ```
54
- npm install react-native-paper-dates --save
55
- ```
56
-
57
-
58
- ## Import some localized strings
59
- Ideally you do this somewhere in your `index.js` before `react-native-paper-dates` is used.
60
- Currently we have en/nl/de/pl/pt/ar/ko/fr translations but it's really easy to add one extra since it are only some labels and error messages.
61
-
62
- ```tsx
63
- // e.g in your index.js
64
- import {
65
- // en,
66
- // fr,
67
- // nl,
68
- // de,
69
- // pl,
70
- // pt,
71
- // ar,
72
- // ko
73
- // fr
74
- enGB,
75
- registerTranslation,
76
- } from 'react-native-paper-dates'
77
- // registerTranslation('en', en)
78
- // registerTranslation('fr', fr)
79
- // registerTranslation('nl', nl)
80
- // registerTranslation('pl', pl)
81
- // registerTranslation('pt', pt)
82
- // registerTranslation('de', de)
83
- // registerTranslation('ar', ar)
84
- // registerTranslation('ko', ko)
85
- // registerTranslation('fr', fr)
86
- registerTranslation('en-GB', enGB)
87
- ```
88
-
89
- ### or register your own
90
- Please send a PR with your language to make sure all locales are there next time
91
- ```tsx
92
- import {
93
- registerTranslation,
94
- } from 'react-native-paper-dates'
95
- registerTranslation("pl", {
96
- save: 'Save',
97
- selectSingle: 'Select date',
98
- selectMultiple: 'Select dates',
99
- selectRange: 'Select period',
100
- notAccordingToDateFormat: (inputFormat) =>
101
- `Date format must be ${inputFormat}`,
102
- mustBeHigherThan: (date) => `Must be later then ${date}`,
103
- mustBeLowerThan: (date) => `Must be earlier then ${date}`,
104
- mustBeBetween: (startDate, endDate) =>
105
- `Must be between ${startDate} - ${endDate}`,
106
- dateIsDisabled: 'Day is not allowed',
107
- previous: 'Previous',
108
- next: 'Next',
109
- typeInDate: 'Type in date',
110
- pickDateFromCalendar: 'Pick date from calendar',
111
- close: 'Close',
112
- })
113
- ```
114
-
115
- ## Usage
116
-
117
- ### Single date Picker (modal)
118
-
119
- ```tsx
120
- import * as React from 'react';
121
- import { Button } from 'react-native-paper';
122
- import { DatePickerModal } from 'react-native-paper-dates';
123
-
124
- export default function ReadMeExampleSingle() {
125
- const [date, setDate] = React.useState<Date | undefined>(undefined);
126
- const [open, setOpen] = React.useState(false);
127
-
128
- const onDismissSingle = React.useCallback(() => {
129
- setOpen(false);
130
- }, [setOpen]);
131
-
132
- const onConfirmSingle = React.useCallback(
133
- (params) => {
134
- setOpen(false);
135
- setDate(params.date);
136
- },
137
- [setOpen, setDate]
138
- );
139
-
140
- return (
141
- <>
142
- <Button onPress={() => setOpen(true)} uppercase={false} mode="outlined">
143
- Pick single date
144
- </Button>
145
- <DatePickerModal
146
- locale="en"
147
- mode="single"
148
- visible={open}
149
- onDismiss={onDismissSingle}
150
- date={date}
151
- onConfirm={onConfirmSingle}
152
- // validRange={{
153
- // startDate: new Date(2021, 1, 2), // optional
154
- // endDate: new Date(), // optional
155
- // disabledDates: [new Date()] // optional
156
- // }}
157
- // onChange={} // same props as onConfirm but triggered without confirmed by user
158
- // saveLabel="Save" // optional
159
- // saveLabelDisabled={true} // optional, default is false
160
- // uppercase={false} // optional, default is true
161
- // label="Select date" // optional
162
- // animationType="slide" // optional, default is 'slide' on ios/android and 'none' on web
163
- // startYear={2000} // optional, default is 1800
164
- // endYear={2100} // optional, default is 2200
165
- // closeIcon="close" // optional, default is "close"
166
- // editIcon="pencil" // optional, default is "pencil"
167
- // calendarIcon="calendar" // optional, default is "calendar"
168
- />
169
- </>
170
- );
171
- }
172
- ```
173
-
174
- ### Range picker (modal)
175
- ```tsx
176
- import * as React from 'react';
177
- import { Button } from 'react-native-paper';
178
-
179
- import { DatePickerModal } from 'react-native-paper-dates';
180
-
181
- export default function ReadMeExampleRange() {
182
- const [range, setRange] = React.useState<{
183
- startDate: Date | undefined;
184
- endDate: Date | undefined;
185
- }>({ startDate: undefined, endDate: undefined });
186
-
187
- const [open, setOpen] = React.useState(false);
188
-
189
- const onDismiss = React.useCallback(() => {
190
- setOpen(false);
191
- }, [setOpen]);
192
-
193
- const onConfirm = React.useCallback(
194
- ({ startDate, endDate }) => {
195
- setOpen(false);
196
- setRange({ startDate, endDate });
197
- },
198
- [setOpen, setRange]
199
- );
200
-
201
- return (
202
- <>
203
- <Button onPress={() => setOpen(true)} uppercase={false} mode="outlined">
204
- Pick range
205
- </Button>
206
- <DatePickerModal
207
- locale="en"
208
- mode="range"
209
- visible={open}
210
- onDismiss={onDismiss}
211
- startDate={range.startDate}
212
- endDate={range.endDate}
213
- onConfirm={onConfirm}
214
- // validRange={{
215
- // startDate: new Date(2021, 1, 2), // optional
216
- // endDate: new Date(), // optional
217
- // disabledDates: [new Date()] // optional
218
- // }}
219
- // onChange={} // same props as onConfirm but triggered without confirmed by user
220
- // saveLabel="Save" // optional
221
- // saveLabelDisabled={true} // optional, default is false
222
- // uppercase={false} // optional, default is true
223
- // label="Select period" // optional
224
- // startLabel="From" // optional
225
- // endLabel="To" // optional
226
- // animationType="slide" // optional, default is slide on ios/android and none on web
227
- // startYear={2000} // optional, default is 1800
228
- // endYear={2100} // optional, default is 2200
229
- // closeIcon="close" // optional, default is "close"
230
- // editIcon="pencil" // optional, default is "pencil"
231
- // calendarIcon="calendar" // optional, default is "calendar"
232
- />
233
- </>
234
- );
235
- }
236
-
237
- ```
238
-
239
-
240
- ### Multiple dates picker
241
- ```tsx
242
- import * as React from 'react';
243
- import { Button } from 'react-native-paper';
244
-
245
- import { DatePickerModal } from 'react-native-paper-dates';
246
-
247
- export default function ReadMeExampleMultiple() {
248
- const [dates, setDates] = React.useState<Date[] | undefined>();
249
- const [open, setOpen] = React.useState(false);
250
-
251
- const onDismiss = React.useCallback(() => {
252
- setOpen(false);
253
- }, [setOpen]);
254
-
255
- const onConfirm = React.useCallback((params) => {
256
- setOpen(false);
257
- setDates(params.dates);
258
- console.log('[on-change-multi]', params);
259
- }, []);
260
-
261
- return (
262
- <>
263
- <Button onPress={() => setOpen(true)} uppercase={false} mode="outlined">
264
- Pick multiple dates
265
- </Button>
266
-
267
- <DatePickerModal
268
- locale="en"
269
- mode="multiple"
270
- visible={open}
271
- onDismiss={onDismiss}
272
- dates={dates}
273
- onConfirm={onConfirm}
274
- // moreLabel="More"
275
- // validRange={{
276
- // startDate: new Date(2021, 1, 2), // optional
277
- // endDate: new Date(), // optional
278
- // disabledDates: [new Date()] // optional
279
- // }}
280
- // saveLabel="Save" // optional
281
- // uppercase={false} // optional, default is true
282
- // label="Select period" // optional
283
- // startLabel="From" // optional
284
- // saveLabelDisabled={true} // optional, default is false
285
- // endLabel="To" // optional
286
- // animationType="slide" // optional, default is slide on ios/android and none on web
287
- // startYear={2000} // optional, default is 1800
288
- // endYear={2100} // optional, default is 2200
289
- // closeIcon="close" // optional, default is "close"
290
- />
291
- </>
292
- );
293
- }
294
- ```
295
-
296
- ### Input date with modal button
297
- ```tsx
298
- export default function ReadMeExampleDatePickerInput() {
299
- const [inputDate, setInputDate] = React.useState<Date | undefined>(undefined)
300
-
301
- return (
302
- <>
303
- <DatePickerInput
304
- locale="en"
305
- label="Birthdate"
306
- value={inputDate}
307
- onChange={(d) => setInputDate(d)}
308
- inputMode="start"
309
- // mode="outlined" (see react-native-paper docs)
310
- // calendarIcon="calendar" // optional, default is "calendar"
311
- // other react native TextInput props
312
- />
313
- </>
314
- )
315
- }
316
-
317
- ```
318
-
319
- ### Time picker
320
- ```tsx
321
- import * as React from 'react'
322
- import { Button } from 'react-native-paper'
323
- import { TimePickerModal } from 'react-native-paper-dates'
324
-
325
- export default function TimePickerPage() {
326
- const [visible, setVisible] = React.useState(false)
327
- const onDismiss = React.useCallback(() => {
328
- setVisible(false)
329
- }, [setVisible])
330
-
331
- const onConfirm = React.useCallback(
332
- ({ hours, minutes }) => {
333
- setVisible(false);
334
- console.log({ hours, minutes });
335
- },
336
- [setVisible]
337
- );
338
-
339
-
340
- return (
341
- <>
342
- <TimePickerModal
343
- visible={visible}
344
- onDismiss={onDismiss}
345
- onConfirm={onConfirm}
346
- hours={12} // default: current hours
347
- minutes={14} // default: current minutes
348
- label="Select time" // optional, default 'Select time'
349
- uppercase={false} // optional, default is true
350
- cancelLabel="Cancel" // optional, default: 'Cancel'
351
- confirmLabel="Ok" // optional, default: 'Ok'
352
- animationType="fade" // optional, default is 'none'
353
- locale="en" // optional, default is automically detected by your system
354
- // keyboardIcon="keyboard-outline" // optional, default is "keyboard-outline"
355
- // clockIcon="clock-outline" // optional, default is "clock-outline"
356
- />
357
- <Button onPress={()=> setVisible(true)}>
358
- Pick time
359
- </Button>
360
- </>
361
- )
362
- }
363
- ```
364
-
365
-
366
-
367
-
368
-
369
-
370
- ## Roadmap
371
- Things on our roadmap have labels with `enhancement`.
372
- https://github.com/web-ridge/react-native-paper-dates/issues
373
-
374
- ## Tips & Tricks
375
- - Use 0.14+ version of React-Native-Web (Modal and better number input)
376
- - Try to avoid putting the Picker Modals inside of a scrollView
377
- If that is **not possible** use the following props on the surrounding ScrollViews/Flatlists
378
-
379
- ```javascript
380
- keyboardDismissMode="on-drag"
381
- keyboardShouldPersistTaps="handled"
382
- contentInsetAdjustmentBehavior="always"
383
- ```
384
- This is to prevent the need to press 2 times before save or close button in modal works (1 press for closing keyboard, 1 press for confirm/close)
385
- [React Native Issue: #10138](https://github.com/facebook/react-native/issues/10138)
386
-
387
-
388
-
389
- ## Android Caveats
390
- We recommend Hermes with React Native >= 0.66 **you won't need these polyfills at all!**
391
-
392
- ### Below React Native 0.66
393
- You will need to add a polyfill for the Intl API on Android if:
394
-
395
- - You have [Hermes](https://github.com/facebook/hermes/issues/23) enabled and are below React Native 0.66
396
- - You have [Hermes](https://github.com/facebook/hermes/issues/23) disabled and you want to support locales outside of en-US and you don't have the org.webkit:android-jsc-intl:+ variant enabled in your app/build.gradle
397
-
398
-
399
- Install polyfills with Yarn
400
-
401
- ```
402
- yarn add react-native-localize @formatjs/intl-pluralrules @formatjs/intl-getcanonicallocales @formatjs/intl-listformat @formatjs/intl-displaynames @formatjs/intl-locale @formatjs/intl-datetimeformat @formatjs/intl-numberformat @formatjs/intl-relativetimeformat
403
- ```
404
-
405
- or npm
406
-
407
- ```
408
- npm install react-native-localize @formatjs/intl-pluralrules @formatjs/intl-getcanonicallocales @formatjs/intl-listformat @formatjs/intl-displaynames @formatjs/intl-locale @formatjs/intl-datetimeformat @formatjs/intl-numberformat @formatjs/intl-relativetimeformat --save
409
- ```
410
-
411
- If using Expo, omit `react-native-localize` and use `expo install expo-localization` instead. Read more [here](https://docs.expo.dev/versions/latest/sdk/localization/#installation).
412
-
413
- In your app starting entrypoint e.g. `./index.js` or even better use a `index.android.js` to prevent importing on iOS/web put the following code. (don't forget to import the languages you want to support, in the example only english language is supported)
414
-
415
- ```javascript
416
- // on top of your index.android.js file
417
- const isAndroid = require('react-native').Platform.OS === 'android'; // this line is only needed if you don't use an .android.js file
418
- const isHermesEnabled = !!global.HermesInternal; // this line is only needed if you don't use an .android.js file
419
-
420
- // in your index.js file
421
- if (isHermesEnabled || isAndroid) { // this line is only needed if you don't use an .android.js file
422
-
423
- require('@formatjs/intl-getcanonicallocales/polyfill');
424
- require('@formatjs/intl-locale/polyfill');
425
-
426
-
427
- require('@formatjs/intl-pluralrules/polyfill');
428
- require('@formatjs/intl-pluralrules/locale-data/en.js'); // USE YOUR OWN LANGUAGE OR MULTIPLE IMPORTS YOU WANT TO SUPPORT
429
-
430
- require('@formatjs/intl-displaynames/polyfill');
431
- require('@formatjs/intl-displaynames/locale-data/en.js'); // USE YOUR OWN LANGUAGE OR MULTIPLE IMPORTS YOU WANT TO SUPPORT
432
-
433
- require('@formatjs/intl-listformat/polyfill');
434
- require('@formatjs/intl-listformat/locale-data/en.js'); // USE YOUR OWN LANGUAGE OR MULTIPLE IMPORTS YOU WANT TO SUPPORT
435
-
436
- require('@formatjs/intl-numberformat/polyfill');
437
- require('@formatjs/intl-numberformat/locale-data/en.js'); // USE YOUR OWN LANGUAGE OR MULTIPLE IMPORTS YOU WANT TO SUPPORT
438
-
439
- require('@formatjs/intl-relativetimeformat/polyfill');
440
- require('@formatjs/intl-relativetimeformat/locale-data/en.js'); // USE YOUR OWN LANGUAGE OR MULTIPLE IMPORTS YOU WANT TO SUPPORT
441
-
442
- require('@formatjs/intl-datetimeformat/polyfill');
443
- require('@formatjs/intl-datetimeformat/locale-data/en.js'); // USE YOUR OWN LANGUAGE OR MULTIPLE IMPORTS YOU WANT TO SUPPORT
444
-
445
- require('@formatjs/intl-datetimeformat/add-golden-tz.js');
446
-
447
-
448
-
449
- // https://formatjs.io/docs/polyfills/intl-datetimeformat/#default-timezone
450
-
451
- if ('__setDefaultTimeZone' in Intl.DateTimeFormat) {
452
-
453
- // If you are using react-native-cli
454
- let RNLocalize = require('react-native-localize');
455
- Intl.DateTimeFormat.__setDefaultTimeZone(RNLocalize.getTimeZone());
456
-
457
- // Are you using Expo, use this instead of previous 2 lines
458
- // Intl.DateTimeFormat.__setDefaultTimeZone(
459
- // require("expo-localization").timezone
460
- // );
461
- }
462
- } // this line is only needed if you don't use an .android.js file
463
- ```
464
-
465
- ## Contributing
466
-
467
- See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.
468
-
469
44
  ## License
470
45
 
471
46
  MIT
472
-
473
-
474
- ### Checkout our other libraries
475
- - Simple form library for React Native with great UX for developer and end-user [react-native-use-form](https://github.com/web-ridge/react-native-use-form)
476
- - Smooth and fast cross platform Material Design Tabs for React Native Paper: [react-native-paper-tabs](https://github.com/web-ridge/react-native-paper-tabs)
477
- - Simple translations in React (Native): [react-ridge-translations](https://github.com/web-ridge/react-ridge-translations)
478
- - Simple global state management in React (Native): [react-ridge-state](https://github.com/web-ridge/react-ridge-state)
479
- - 1 command utility for React Native (Web) project: [create-react-native-web-application](https://github.com/web-ridge/create-react-native-web-application)
@@ -91,8 +91,8 @@ function DatePickerModalContent(props) {
91
91
  onSave: onInnerConfirm,
92
92
  onDismiss: onDismiss,
93
93
  saveLabel: props.saveLabel,
94
- saveLabelDisabled: props.saveLabelDisabled || false,
95
- uppercase: props.uppercase || true,
94
+ saveLabelDisabled: props.saveLabelDisabled ?? false,
95
+ uppercase: props.uppercase ?? true,
96
96
  disableSafeTop: disableSafeTop,
97
97
  closeIcon: props.closeIcon
98
98
  }), /*#__PURE__*/React.createElement(_DatePickerModalContentHeader.default, {
@@ -106,7 +106,7 @@ function DatePickerModalContent(props) {
106
106
  moreLabel: props.moreLabel,
107
107
  startLabel: props.startLabel,
108
108
  endLabel: props.endLabel,
109
- uppercase: props.uppercase || true,
109
+ uppercase: props.uppercase ?? true,
110
110
  locale: locale,
111
111
  editIcon: props.editIcon,
112
112
  calendarIcon: props.calendarIcon
@@ -1 +1 @@
1
- {"version":3,"names":["DatePickerModalContent","props","mode","onChange","onConfirm","onDismiss","disableSafeTop","disableWeekDays","locale","validRange","dateMode","startYear","endYear","anyProps","state","setState","React","useState","date","startDate","endDate","dates","useEffect","collapsed","setCollapsed","onInnerChange","useCallback","params","prev","onInnerConfirm","onToggleCollapse","saveLabel","saveLabelDisabled","uppercase","closeIcon","headerSeparator","emptyLabel","label","moreLabel","startLabel","endLabel","editIcon","calendarIcon","memo"],"sources":["DatePickerModalContent.tsx"],"sourcesContent":["import * as React from 'react'\n\nimport Calendar, {\n BaseCalendarProps,\n CalendarDate,\n CalendarDates,\n MultiChange,\n MultiConfirm,\n RangeChange,\n SingleChange,\n} from './Calendar'\n\nimport AnimatedCrossView from './AnimatedCrossView'\n\nimport DatePickerModalHeader from './DatePickerModalHeader'\nimport DatePickerModalContentHeader, {\n HeaderPickProps,\n} from './DatePickerModalContentHeader'\nimport CalendarEdit from './CalendarEdit'\nimport DatePickerModalHeaderBackground from './DatePickerModalHeaderBackground'\n\nexport type LocalState = {\n startDate: CalendarDate\n endDate: CalendarDate\n date: CalendarDate\n dates: CalendarDates\n}\n\ninterface DatePickerModalContentBaseProps {\n inputFormat?: string\n locale: string\n onDismiss: () => any\n disableSafeTop?: boolean\n saveLabelDisabled?: boolean\n}\n\nexport interface DatePickerModalContentRangeProps\n extends HeaderPickProps,\n BaseCalendarProps,\n DatePickerModalContentBaseProps {\n mode: 'range'\n startDate: CalendarDate\n endDate: CalendarDate\n onChange?: RangeChange\n onConfirm: RangeChange\n}\n\nexport interface DatePickerModalContentSingleProps\n extends HeaderPickProps,\n BaseCalendarProps,\n DatePickerModalContentBaseProps {\n mode: 'single'\n date?: CalendarDate\n onChange?: SingleChange\n onConfirm: SingleChange\n dateMode?: 'start' | 'end'\n}\n\nexport interface DatePickerModalContentMultiProps\n extends HeaderPickProps,\n BaseCalendarProps,\n DatePickerModalContentBaseProps {\n mode: 'multiple'\n dates?: CalendarDates\n onChange?: MultiChange\n onConfirm: MultiConfirm\n}\n\nexport function DatePickerModalContent(\n props:\n | DatePickerModalContentRangeProps\n | DatePickerModalContentSingleProps\n | DatePickerModalContentMultiProps\n) {\n const {\n mode,\n onChange,\n onConfirm,\n onDismiss,\n disableSafeTop,\n disableWeekDays,\n locale,\n validRange,\n dateMode,\n startYear,\n endYear,\n } = props\n\n const anyProps = props as any\n\n // use local state to add only onConfirm state changes\n const [state, setState] = React.useState<LocalState>({\n date: anyProps.date,\n startDate: anyProps.startDate,\n endDate: anyProps.endDate,\n dates: anyProps.dates,\n })\n\n // update local state if changed from outside or if modal is opened\n React.useEffect(() => {\n setState({\n date: anyProps.date,\n startDate: anyProps.startDate,\n endDate: anyProps.endDate,\n dates: anyProps.dates,\n })\n }, [anyProps.date, anyProps.startDate, anyProps.endDate, anyProps.dates])\n\n const [collapsed, setCollapsed] = React.useState<boolean>(true)\n\n const onInnerChange = React.useCallback(\n (params: any) => {\n onChange && onChange(params)\n setState((prev) => ({ ...prev, ...params }))\n },\n [onChange, setState]\n )\n\n const onInnerConfirm = React.useCallback(() => {\n if (mode === 'single') {\n ;(onConfirm as DatePickerModalContentSingleProps['onConfirm'])({\n date: state.date,\n })\n } else if (mode === 'range') {\n ;(onConfirm as DatePickerModalContentRangeProps['onConfirm'])({\n startDate: state.startDate,\n endDate: state.endDate,\n })\n } else if (mode === 'multiple') {\n ;(onConfirm as DatePickerModalContentMultiProps['onConfirm'])({\n dates: state.dates || [],\n })\n }\n }, [state, mode, onConfirm])\n\n const onToggleCollapse = React.useCallback(() => {\n setCollapsed((prev) => !prev)\n }, [setCollapsed])\n\n return (\n <>\n <DatePickerModalHeaderBackground>\n <DatePickerModalHeader\n locale={locale}\n onSave={onInnerConfirm}\n onDismiss={onDismiss}\n saveLabel={props.saveLabel}\n saveLabelDisabled={props.saveLabelDisabled || false}\n uppercase={props.uppercase || true}\n disableSafeTop={disableSafeTop}\n closeIcon={props.closeIcon}\n />\n <DatePickerModalContentHeader\n state={state}\n mode={mode}\n collapsed={collapsed}\n onToggle={onToggleCollapse}\n headerSeparator={props.headerSeparator}\n emptyLabel={props.emptyLabel}\n label={props.label}\n moreLabel={props.moreLabel}\n startLabel={props.startLabel}\n endLabel={props.endLabel}\n uppercase={props.uppercase || true}\n locale={locale}\n editIcon={props.editIcon}\n calendarIcon={props.calendarIcon}\n />\n </DatePickerModalHeaderBackground>\n\n <AnimatedCrossView\n collapsed={collapsed}\n calendar={\n <Calendar\n locale={locale}\n mode={mode}\n startDate={state.startDate}\n endDate={state.endDate}\n date={state.date}\n onChange={onInnerChange}\n disableWeekDays={disableWeekDays}\n dates={state.dates}\n validRange={validRange}\n dateMode={dateMode}\n startYear={startYear}\n endYear={endYear}\n />\n }\n calendarEdit={\n <CalendarEdit\n mode={mode}\n state={state}\n label={props.label}\n startLabel={props.startLabel}\n endLabel={props.endLabel}\n collapsed={collapsed}\n onChange={onInnerChange}\n valid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MAAM,EAAED;IATV;EAnBJ,EA9BF,CADF;AAiED;;4BAEcQ,KAAK,CAAC2B,IAAN,CAAW3C,sBAAX,C"}
1
+ {"version":3,"names":["DatePickerModalContent","props","mode","onChange","onConfirm","onDismiss","disableSafeTop","disableWeekDays","locale","validRange","dateMode","startYear","endYear","anyProps","state","setState","React","useState","date","startDate","endDate","dates","useEffect","collapsed","setCollapsed","onInnerChange","useCallback","params","prev","onInnerConfirm","onToggleCollapse","saveLabel","saveLabelDisabled","uppercase","closeIcon","headerSeparator","emptyLabel","label","moreLabel","startLabel","endLabel","editIcon","calendarIcon","memo"],"sources":["DatePickerModalContent.tsx"],"sourcesContent":["import * as React from 'react'\n\nimport Calendar, {\n BaseCalendarProps,\n CalendarDate,\n CalendarDates,\n MultiChange,\n MultiConfirm,\n RangeChange,\n SingleChange,\n} from './Calendar'\n\nimport AnimatedCrossView from './AnimatedCrossView'\n\nimport DatePickerModalHeader from './DatePickerModalHeader'\nimport DatePickerModalContentHeader, {\n HeaderPickProps,\n} from './DatePickerModalContentHeader'\nimport CalendarEdit from './CalendarEdit'\nimport DatePickerModalHeaderBackground from './DatePickerModalHeaderBackground'\n\nexport type LocalState = {\n startDate: CalendarDate\n endDate: CalendarDate\n date: CalendarDate\n dates: CalendarDates\n}\n\ninterface DatePickerModalContentBaseProps {\n inputFormat?: string\n locale: string\n onDismiss: () => any\n disableSafeTop?: boolean\n saveLabelDisabled?: boolean\n uppercase?: boolean\n}\n\nexport interface DatePickerModalContentRangeProps\n extends HeaderPickProps,\n BaseCalendarProps,\n DatePickerModalContentBaseProps {\n mode: 'range'\n startDate: CalendarDate\n endDate: CalendarDate\n onChange?: RangeChange\n onConfirm: RangeChange\n}\n\nexport interface DatePickerModalContentSingleProps\n extends HeaderPickProps,\n BaseCalendarProps,\n DatePickerModalContentBaseProps {\n mode: 'single'\n date?: CalendarDate\n onChange?: SingleChange\n onConfirm: SingleChange\n dateMode?: 'start' | 'end'\n}\n\nexport interface DatePickerModalContentMultiProps\n extends HeaderPickProps,\n BaseCalendarProps,\n DatePickerModalContentBaseProps {\n mode: 'multiple'\n dates?: CalendarDates\n onChange?: MultiChange\n onConfirm: MultiConfirm\n}\n\nexport function DatePickerModalContent(\n props:\n | DatePickerModalContentRangeProps\n | DatePickerModalContentSingleProps\n | DatePickerModalContentMultiProps\n) {\n const {\n mode,\n onChange,\n onConfirm,\n onDismiss,\n disableSafeTop,\n disableWeekDays,\n locale,\n validRange,\n dateMode,\n startYear,\n endYear,\n } = props\n\n const anyProps = props as any\n\n // use local state to add only onConfirm state changes\n const [state, setState] = React.useState<LocalState>({\n date: anyProps.date,\n startDate: anyProps.startDate,\n endDate: anyProps.endDate,\n dates: anyProps.dates,\n })\n\n // update local state if changed from outside or if modal is opened\n React.useEffect(() => {\n setState({\n date: anyProps.date,\n startDate: anyProps.startDate,\n endDate: anyProps.endDate,\n dates: anyProps.dates,\n })\n }, [anyProps.date, anyProps.startDate, anyProps.endDate, anyProps.dates])\n\n const [collapsed, setCollapsed] = React.useState<boolean>(true)\n\n const onInnerChange = React.useCallback(\n (params: any) => {\n onChange && onChange(params)\n setState((prev) => ({ ...prev, ...params }))\n },\n [onChange, setState]\n )\n\n const onInnerConfirm = React.useCallback(() => {\n if (mode === 'single') {\n ;(onConfirm as DatePickerModalContentSingleProps['onConfirm'])({\n date: state.date,\n })\n } else if (mode === 'range') {\n ;(onConfirm as DatePickerModalContentRangeProps['onConfirm'])({\n startDate: state.startDate,\n endDate: state.endDate,\n })\n } else if (mode === 'multiple') {\n ;(onConfirm as DatePickerModalContentMultiProps['onConfirm'])({\n dates: state.dates || [],\n })\n }\n }, [state, mode, onConfirm])\n\n const onToggleCollapse = React.useCallback(() => {\n setCollapsed((prev) => !prev)\n }, [setCollapsed])\n\n return (\n <>\n <DatePickerModalHeaderBackground>\n <DatePickerModalHeader\n locale={locale}\n onSave={onInnerConfirm}\n onDismiss={onDismiss}\n saveLabel={props.saveLabel}\n saveLabelDisabled={props.saveLabelDisabled ?? false}\n uppercase={props.uppercase ?? true}\n disableSafeTop={disableSafeTop}\n closeIcon={props.closeIcon}\n />\n <DatePickerModalContentHeader\n state={state}\n mode={mode}\n collapsed={collapsed}\n onToggle={onToggleCollapse}\n headerSeparator={props.headerSeparator}\n emptyLabel={props.emptyLabel}\n label={props.label}\n moreLabel={props.moreLabel}\n startLabel={props.startLabel}\n endLabel={props.endLabel}\n uppercase={props.uppercase ?? true}\n locale={locale}\n editIcon={props.editIcon}\n calendarIcon={props.calendarIcon}\n />\n </DatePickerModalHeaderBackground>\n\n <AnimatedCrossView\n collapsed={collapsed}\n calendar={\n <Calendar\n locale={locale}\n mode={mode}\n startDate={state.startDate}\n endDate={state.endDate}\n date={state.date}\n onChange={onInnerChange}\n disableWeekDays={disableWeekDays}\n dates={state.dates}\n validRange={validRange}\n dateMode={dateMode}\n startYear={startYear}\n endYear={endYear}\n />\n }\n calendarEdit={\n <CalendarEdit\n mode={mode}\n state={state}\n label={props.label}\n startLabel={props.startLabel}\n endLabel={props.endLabel}\n collapsed={collapsed}\n onChange={onInnerChange}\n validRange={validRange}\n locale={locale}\n />\n }\n />\n </>\n )\n}\n\nexport default React.memo(DatePickerModalContent)\n"],"mappings":";;;;;;;;AAAA;;AAEA;;AAUA;;AAEA;;AACA;;AAGA;;AACA;;;;;;;;AAkDO,SAASA,sBAAT,CACLC,KADK,EAKL;EACA,MAAM;IACJC,IADI;IAEJC,QAFI;IAGJC,SAHI;IAIJC,SAJI;IAKJC,cALI;IAMJC,eANI;IAOJC,MAPI;IAQJC,UARI;IASJC,QATI;IAUJC,SAVI;IAWJC;EAXI,IAYFX,KAZJ;EAcA,MAAMY,QAAQ,GAAGZ,KAAjB,CAfA,CAiBA;;EACA,MAAM,CAACa,KAAD,EAAQC,QAAR,IAAoBC,KAAK,CAACC,QAAN,CAA2B;IACnDC,IAAI,EAAEL,QAAQ,CAACK,IADoC;IAEnDC,SAAS,EAAEN,QAAQ,CAACM,SAF+B;IAGnDC,OAAO,EAA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,QAAQ,eACN,oBAAC,iBAAD;MACE,MAAM,EAAEf,MADV;MAEE,IAAI,EAAEN,IAFR;MAGE,SAAS,EAAEY,KAAK,CAACK,SAHnB;MAIE,OAAO,EAAEL,KAAK,CAACM,OAJjB;MAKE,IAAI,EAAEN,KAAK,CAACI,IALd;MAME,QAAQ,EAAEO,aANZ;MAOE,eAAe,EAAElB,eAPnB;MAQE,KAAK,EAAEO,KAAK,CAACO,KARf;MASE,UAAU,EAAEZ,UATd;MAUE,QAAQ,EAAEC,QAVZ;MAWE,SAAS,EAAEC,SAXb;MAYE,OAAO,EAAEC;IAZX,EAHJ;IAkBE,YAAY,eACV,oBAAC,qBAAD;MACE,IAAI,EAAEV,IADR;MAEE,KAAK,EAAEY,KAFT;MAGE,KAAK,EAAEb,KAAK,CAACoC,KAHf;MAIE,UAAU,EAAEpC,KAAK,CAACsC,UAJpB;MAKE,QAAQ,EAAEtC,KAAK,CAACuC,QALlB;MAME,SAAS,EAAEjB,SANb;MAOE,QAAQ,EAAEE,aAPZ;MAQE,UAAU,EAAEhB,UARd;MASE,MAAM,EAAED;IATV;EAnBJ,EA9BF,CADF;AAiED;;4BAEcQ,KAAK,CAAC2B,IAAN,CAAW3C,sBAAX,C"}
@@ -50,8 +50,8 @@ function DatePickerModalHeader(props) {
50
50
  color: color,
51
51
  textColor: color,
52
52
  onPress: props.onSave,
53
- disabled: props.saveLabelDisabled || false,
54
- uppercase: props.uppercase || true,
53
+ disabled: props.saveLabelDisabled ?? false,
54
+ uppercase: props.uppercase ?? true,
55
55
  testID: "react-native-paper-dates-save"
56
56
  }, saveLabel)));
57
57
  }
@@ -1 +1 @@
1
- {"version":3,"names":["DatePickerModalHeader","props","disableSafeTop","locale","closeIcon","saveLabel","getTranslation","color","useHeaderTextColor","insets","useSafeAreaInsets","styles","animated","paddingTop","top","paddingLeft","left","paddingRight","right","appbarHeader","onDismiss","onSave","saveLabelDisabled","uppercase","StyleSheet","create","fill","flex","elevation","header","height","alignItems","flexDirection","headerContentContainer","marginTop","label","letterSpacing","fontSize","singleHeaderText","rangeHeaderText","headerTextFilled","headerTextEmpty","headerSeparator","backgroundColor"],"sources":["DatePickerModalHeader.tsx"],"sourcesContent":["import * as React from 'react'\nimport { Animated, StyleSheet } from 'react-native'\nimport { Appbar, Button } from 'react-native-paper'\n\nimport { useHeaderTextColor } from '../utils'\nimport { getTranslation } from '../translations/utils'\nimport { useSafeAreaInsets } from 'react-native-safe-area-context'\n\nexport interface DatePickerModalHeaderProps {\n disableSafeTop?: boolean\n saveLabel?: string\n saveLabelDisabled?: boolean\n uppercase?: boolean\n onDismiss: () => void\n onSave: () => void\n locale: string | undefined\n closeIcon?: string\n}\n\nexport default function DatePickerModalHeader(\n props: DatePickerModalHeaderProps\n) {\n const { disableSafeTop, locale, closeIcon = 'close' } = props\n const saveLabel = props.saveLabel || getTranslation(locale, 'save')\n const color = useHeaderTextColor()\n const insets = useSafeAreaInsets()\n\n return (\n <Animated.View\n style={[\n styles.animated,\n {\n paddingTop: disableSafeTop ? 0 : insets.top,\n paddingLeft: insets.left,\n paddingRight: insets.right,\n },\n ]}\n >\n <Appbar style={styles.appbarHeader}>\n <Appbar.Action\n icon={closeIcon}\n accessibilityLabel={getTranslation(locale, 'close')}\n onPress={props.onDismiss}\n color={color}\n testID=\"react-native-paper-dates-close\"\n />\n <Appbar.Content title={''} />\n <Button\n color={color}\n textColor={color}\n onPress={props.onSave}\n disabled={props.saveLabelDisabled || false}\n uppercase={props.uppercase || true}\n testID=\"react-native-paper-dates-save\"\n >\n {saveLabel}\n </Button>\n </Appbar>\n </Animated.View>\n )\n}\n\nconst styles = StyleSheet.create({\n fill: {\n flex: 1,\n },\n animated: {\n elevation: 4,\n },\n\n header: {\n height: 75,\n alignItems: 'center',\n flexDirection: 'row',\n paddingLeft: 24,\n paddingRight: 12,\n },\n headerContentContainer: { marginTop: 5, flexDirection: 'row' },\n label: { color: '#fff', letterSpacing: 1, fontSize: 13 },\n singleHeaderText: { color: '#fff', fontSize: 25 },\n rangeHeaderText: { color: '#fff', fontSize: 25 },\n headerTextFilled: { color: 'rgba(255,255,255,1)' },\n headerTextEmpty: { color: 'rgba(255,255,255,0.5)' },\n headerSeparator: {\n color: 'rgba(255,255,255,1)',\n fontSize: 25,\n paddingLeft: 6,\n paddingRight: 6,\n },\n appbarHeader: {\n elevation: 0,\n backgroundColor: 'transparent',\n // alignItems:'center'\n },\n})\n"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AAEA;;AACA;;AACA;;;;;;AAae,SAASA,qBAAT,CACbC,KADa,EAEb;EACA,MAAM;IAAEC,cAAF;IAAkBC,MAAlB;IAA0BC,SAAS,GAAG;EAAtC,IAAkDH,KAAxD;EACA,MAAMI,SAAS,GAAGJ,KAAK,CAACI,SAAN,IAAmB,IAAAC,sBAAA,EAAeH,MAAf,EAAuB,MAAvB,CAArC;EACA,MAAMI,KAAK,GAAG,IAAAC,yBAAA,GAAd;EACA,MAAMC,MAAM,GAAG,IAAAC,6CAAA,GAAf;EAEA,oBACE,oBAAC,qBAAD,CAAU,IAAV;IACE,KAAK,EAAE,CACLC,MAAM,CAACC,QADF,EAEL;MACEC,UAAU,EAAEX,cAAc,GAAG,CAAH,GAAOO,MAAM,CAACK,GAD1C;MAEEC,WAAW,EAAEN,MAAM,CAACO,IAFtB;MAGEC,YAAY,EAAER,MAAM,CAACS;IAHvB,CAFK;EADT,gBAUE,oBAAC,wBAAD;IAAQ,KAAK,EAAEP,MAAM,CAACQ;EAAtB,gBACE,oBAAC,wBAAD,CAAQ,MAAR;IACE,IAAI,EAAEf,SADR;IAEE,kBAAkB,EAAE,IAAAE,sBAAA,EAAeH,MAAf,EAAuB,OAAvB,CAFtB;IAGE,OAAO,EAAEF,KAAK,CAACmB,SAHjB;IAIE,KAAK,EAAEb,KAJT;IAKE,MAAM,EAAC;EALT,EADF,eAQE,oBAAC,wBAAD,CAAQ,OAAR;IAAgB,KAAK,EAAE;EAAvB,EARF,eASE,oBAAC,wBAAD;IACE,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AE,aAFL,CAGZ;;EAHY;AA3BiB,CAAlB,CAAf"}
1
+ {"version":3,"names":["DatePickerModalHeader","props","disableSafeTop","locale","closeIcon","saveLabel","getTranslation","color","useHeaderTextColor","insets","useSafeAreaInsets","styles","animated","paddingTop","top","paddingLeft","left","paddingRight","right","appbarHeader","onDismiss","onSave","saveLabelDisabled","uppercase","StyleSheet","create","fill","flex","elevation","header","height","alignItems","flexDirection","headerContentContainer","marginTop","label","letterSpacing","fontSize","singleHeaderText","rangeHeaderText","headerTextFilled","headerTextEmpty","headerSeparator","backgroundColor"],"sources":["DatePickerModalHeader.tsx"],"sourcesContent":["import * as React from 'react'\nimport { Animated, StyleSheet } from 'react-native'\nimport { Appbar, Button } from 'react-native-paper'\n\nimport { useHeaderTextColor } from '../utils'\nimport { getTranslation } from '../translations/utils'\nimport { useSafeAreaInsets } from 'react-native-safe-area-context'\n\nexport interface DatePickerModalHeaderProps {\n disableSafeTop?: boolean\n saveLabel?: string\n saveLabelDisabled?: boolean\n uppercase?: boolean\n onDismiss: () => void\n onSave: () => void\n locale: string | undefined\n closeIcon?: string\n}\n\nexport default function DatePickerModalHeader(\n props: DatePickerModalHeaderProps\n) {\n const { disableSafeTop, locale, closeIcon = 'close' } = props\n const saveLabel = props.saveLabel || getTranslation(locale, 'save')\n const color = useHeaderTextColor()\n const insets = useSafeAreaInsets()\n\n return (\n <Animated.View\n style={[\n styles.animated,\n {\n paddingTop: disableSafeTop ? 0 : insets.top,\n paddingLeft: insets.left,\n paddingRight: insets.right,\n },\n ]}\n >\n <Appbar style={styles.appbarHeader}>\n <Appbar.Action\n icon={closeIcon}\n accessibilityLabel={getTranslation(locale, 'close')}\n onPress={props.onDismiss}\n color={color}\n testID=\"react-native-paper-dates-close\"\n />\n <Appbar.Content title={''} />\n <Button\n color={color}\n textColor={color}\n onPress={props.onSave}\n disabled={props.saveLabelDisabled ?? false}\n uppercase={props.uppercase ?? true}\n testID=\"react-native-paper-dates-save\"\n >\n {saveLabel}\n </Button>\n </Appbar>\n </Animated.View>\n )\n}\n\nconst styles = StyleSheet.create({\n fill: {\n flex: 1,\n },\n animated: {\n elevation: 4,\n },\n\n header: {\n height: 75,\n alignItems: 'center',\n flexDirection: 'row',\n paddingLeft: 24,\n paddingRight: 12,\n },\n headerContentContainer: { marginTop: 5, flexDirection: 'row' },\n label: { color: '#fff', letterSpacing: 1, fontSize: 13 },\n singleHeaderText: { color: '#fff', fontSize: 25 },\n rangeHeaderText: { color: '#fff', fontSize: 25 },\n headerTextFilled: { color: 'rgba(255,255,255,1)' },\n headerTextEmpty: { color: 'rgba(255,255,255,0.5)' },\n headerSeparator: {\n color: 'rgba(255,255,255,1)',\n fontSize: 25,\n paddingLeft: 6,\n paddingRight: 6,\n },\n appbarHeader: {\n elevation: 0,\n backgroundColor: 'transparent',\n // alignItems:'center'\n },\n})\n"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AAEA;;AACA;;AACA;;;;;;AAae,SAASA,qBAAT,CACbC,KADa,EAEb;EACA,MAAM;IAAEC,cAAF;IAAkBC,MAAlB;IAA0BC,SAAS,GAAG;EAAtC,IAAkDH,KAAxD;EACA,MAAMI,SAAS,GAAGJ,KAAK,CAACI,SAAN,IAAmB,IAAAC,sBAAA,EAAeH,MAAf,EAAuB,MAAvB,CAArC;EACA,MAAMI,KAAK,GAAG,IAAAC,yBAAA,GAAd;EACA,MAAMC,MAAM,GAAG,IAAAC,6CAAA,GAAf;EAEA,oBACE,oBAAC,qBAAD,CAAU,IAAV;IACE,KAAK,EAAE,CACLC,MAAM,CAACC,QADF,EAEL;MACEC,UAAU,EAAEX,cAAc,GAAG,CAAH,GAAOO,MAAM,CAACK,GAD1C;MAEEC,WAAW,EAAEN,MAAM,CAACO,IAFtB;MAGEC,YAAY,EAAER,MAAM,CAACS;IAHvB,CAFK;EADT,gBAUE,oBAAC,wBAAD;IAAQ,KAAK,EAAEP,MAAM,CAACQ;EAAtB,gBACE,oBAAC,wBAAD,CAAQ,MAAR;IACE,IA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EAAE;EAAT,CAnBa;EAoB/BkC,eAAe,EAAE;IAAElC,KAAK,EAAE;EAAT,CApBc;EAqB/BmC,eAAe,EAAE;IACfnC,KAAK,EAAE,qBADQ;IAEf8B,QAAQ,EAAE,EAFK;IAGftB,WAAW,EAAE,CAHE;IAIfE,YAAY,EAAE;EAJC,CArBc;EA2B/BE,YAAY,EAAE;IACZS,SAAS,EAAE,CADC;IAEZe,eAAe,EAAE,aAFL,CAGZ;;EAHY;AA3BiB,CAAlB,CAAf"}
@@ -9,7 +9,7 @@ var _dateUtils = require("./dateUtils");
9
9
 
10
10
  var React = _interopRequireWildcard(require("react"));
11
11
 
12
- var _reactNativePaperDates = require("react-native-paper-dates");
12
+ var _utils = require("../translations/utils");
13
13
 
14
14
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
15
15
 
@@ -48,19 +48,19 @@ function useDateInput(_ref) {
48
48
  const month = Number(date.slice(monthIndex, monthIndex + 2));
49
49
 
50
50
  if (Number.isNaN(day) || Number.isNaN(year) || Number.isNaN(month)) {
51
- setError((0, _reactNativePaperDates.getTranslation)(locale, 'notAccordingToDateFormat', () => 'notAccordingToDateFormat')(inputFormat));
51
+ setError((0, _utils.getTranslation)(locale, 'notAccordingToDateFormat', () => 'notAccordingToDateFormat')(inputFormat));
52
52
  return;
53
53
  }
54
54
 
55
55
  const finalDate = inputMode === 'end' ? new Date(year, month - 1, day, 23, 59, 59) : new Date(year, month - 1, day);
56
56
 
57
57
  if (isDisabled(finalDate)) {
58
- setError((0, _reactNativePaperDates.getTranslation)(locale, 'dateIsDisabled'));
58
+ setError((0, _utils.getTranslation)(locale, 'dateIsDisabled'));
59
59
  return;
60
60
  }
61
61
 
62
62
  if (!isWithinValidRange(finalDate)) {
63
- let errors = validStart && validEnd ? [`${(0, _reactNativePaperDates.getTranslation)(locale, 'mustBeBetween', () => 'mustBeBetween')(formatter.format(validStart), formatter.format(validEnd))}`] : [validStart ? (0, _reactNativePaperDates.getTranslation)(locale, 'mustBeHigherThan', () => 'mustBeHigherThan')(formatter.format(validStart)) : '', validEnd ? (0, _reactNativePaperDates.getTranslation)(locale, 'mustBeLowerThan', () => 'mustBeLowerThan')(formatter.format(validEnd)) : ''];
63
+ let errors = validStart && validEnd ? [`${(0, _utils.getTranslation)(locale, 'mustBeBetween', () => 'mustBeBetween')(formatter.format(validStart), formatter.format(validEnd))}`] : [validStart ? (0, _utils.getTranslation)(locale, 'mustBeHigherThan', () => 'mustBeHigherThan')(formatter.format(validStart)) : '', validEnd ? (0, _utils.getTranslation)(locale, 'mustBeLowerThan', () => 'mustBeLowerThan')(formatter.format(validEnd)) : ''];
64
64
  setError(errors.filter(n => n).join(' '));
65
65
  return;
66
66
  }
@@ -1 +1 @@
1
- {"version":3,"names":["useDateInput","locale","value","validRange","inputMode","onChange","isDisabled","isWithinValidRange","validStart","validEnd","useRangeChecker","error","setError","React","useState","formatter","useInputFormatter","inputFormat","useInputFormat","formattedValue","format","onChangeText","date","dayIndex","indexOf","monthIndex","yearIndex","day","Number","slice","year","month","isNaN","getTranslation","finalDate","Date","errors","filter","n","join"],"sources":["inputUtils.ts"],"sourcesContent":["import { useInputFormat, useInputFormatter, useRangeChecker } from './dateUtils'\nimport * as React from 'react'\nimport type { ValidRangeType } from './Calendar'\nimport { getTranslation } from 'react-native-paper-dates'\n\nexport default function useDateInput({\n locale,\n value,\n validRange,\n inputMode,\n onChange,\n}: {\n onChange: (d: Date) => void\n locale: undefined | string\n value: Date | undefined\n validRange: ValidRangeType | undefined\n inputMode: 'start' | 'end'\n}) {\n const { isDisabled, isWithinValidRange, validStart, validEnd } =\n useRangeChecker(validRange)\n const [error, setError] = React.useState<null | string>(null)\n const formatter = useInputFormatter({ locale })\n const inputFormat = useInputFormat({ formatter, locale })\n const formattedValue = value !== null ? formatter.format(value) : '';\n const onChangeText = (date: string) => {\n const dayIndex = inputFormat.indexOf('DD')\n const monthIndex = inputFormat.indexOf('MM')\n const yearIndex =\n locale === 'pt'\n ? inputFormat.indexOf('AAAA')\n : inputFormat.indexOf('YYYY')\n\n const day = Number(date.slice(dayIndex, dayIndex + 2))\n const year = Number(date.slice(yearIndex, yearIndex + 4))\n const month = Number(date.slice(monthIndex, monthIndex + 2))\n\n if (Number.isNaN(day) || Number.isNaN(year) || Number.isNaN(month)) {\n setError(\n getTranslation(\n locale,\n 'notAccordingToDateFormat',\n () => 'notAccordingToDateFormat'\n )(inputFormat)\n )\n return\n }\n\n const finalDate =\n inputMode === 'end'\n ? new Date(year, month - 1, day, 23, 59, 59)\n : new Date(year, month - 1, day)\n\n if (isDisabled(finalDate)) {\n setError(getTranslation(locale, 'dateIsDisabled'))\n return\n }\n if (!isWithinValidRange(finalDate)) {\n let errors =\n validStart && validEnd\n ? [\n `${getTranslation(\n locale,\n 'mustBeBetween',\n () => 'mustBeBetween'\n )(formatter.format(validStart), formatter.format(validEnd))}`,\n ]\n : [\n validStart\n ? getTranslation(\n locale,\n 'mustBeHigherThan',\n () => 'mustBeHigherThan'\n )(formatter.format(validStart))\n : '',\n validEnd\n ? getTranslation(\n locale,\n 'mustBeLowerThan',\n () => 'mustBeLowerThan'\n )(formatter.format(validEnd))\n : '',\n ]\n setError(errors.filter((n) => n).join(' '))\n return\n }\n\n setError(null)\n if (inputMode === 'end') {\n onChange(finalDate)\n } else {\n onChange(finalDate)\n }\n }\n return {\n onChange,\n error,\n formattedValue,\n onChangeText,\n inputFormat,\n }\n}\n"],"mappings":";;;;;;;AAAA;;AACA;;AAEA;;;;;;AAEe,SAASA,YAAT,OAYZ;EAAA,IAZkC;IACnCC,MADmC;IAEnCC,KAFmC;IAGnCC,UAHmC;IAInCC,SAJmC;IAKnCC;EALmC,CAYlC;EACD,MAAM;IAAEC,UAAF;IAAcC,kBAAd;IAAkCC,UAAlC;IAA8CC;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B,EAAyB;MACvBC,QAAQ,CAAC6B,SAAD,CAAR;IACD,CAFD,MAEO;MACL7B,QAAQ,CAAC6B,SAAD,CAAR;IACD;EACF,CApED;;EAqEA,OAAO;IACL7B,QADK;IAELM,KAFK;IAGLQ,cAHK;IAILE,YAJK;IAKLJ;EALK,CAAP;AAOD"}
1
+ {"version":3,"names":["useDateInput","locale","value","validRange","inputMode","onChange","isDisabled","isWithinValidRange","validStart","validEnd","useRangeChecker","error","setError","React","useState","formatter","useInputFormatter","inputFormat","useInputFormat","formattedValue","format","onChangeText","date","dayIndex","indexOf","monthIndex","yearIndex","day","Number","slice","year","month","isNaN","getTranslation","finalDate","Date","errors","filter","n","join"],"sources":["inputUtils.ts"],"sourcesContent":["import { useInputFormat, useInputFormatter, useRangeChecker } from './dateUtils'\nimport * as React from 'react'\nimport type { ValidRangeType } from './Calendar'\nimport { getTranslation } from '../translations/utils'\n\nexport default function useDateInput({\n locale,\n value,\n validRange,\n inputMode,\n onChange,\n}: {\n onChange: (d: Date) => void\n locale: undefined | string\n value: Date | undefined\n validRange: ValidRangeType | undefined\n inputMode: 'start' | 'end'\n}) {\n const { isDisabled, isWithinValidRange, validStart, validEnd } =\n useRangeChecker(validRange)\n const [error, setError] = React.useState<null | string>(null)\n const formatter = useInputFormatter({ locale })\n const inputFormat = useInputFormat({ formatter, locale })\n const formattedValue = value !== null ? formatter.format(value) : ''\n const onChangeText = (date: string) => {\n const dayIndex = inputFormat.indexOf('DD')\n const monthIndex = inputFormat.indexOf('MM')\n const yearIndex =\n locale === 'pt'\n ? inputFormat.indexOf('AAAA')\n : inputFormat.indexOf('YYYY')\n\n const day = Number(date.slice(dayIndex, dayIndex + 2))\n const year = Number(date.slice(yearIndex, yearIndex + 4))\n const month = Number(date.slice(monthIndex, monthIndex + 2))\n\n if (Number.isNaN(day) || Number.isNaN(year) || Number.isNaN(month)) {\n setError(\n getTranslation(\n locale,\n 'notAccordingToDateFormat',\n () => 'notAccordingToDateFormat'\n )(inputFormat)\n )\n return\n }\n\n const finalDate =\n inputMode === 'end'\n ? new Date(year, month - 1, day, 23, 59, 59)\n : new Date(year, month - 1, day)\n\n if (isDisabled(finalDate)) {\n setError(getTranslation(locale, 'dateIsDisabled'))\n return\n }\n if (!isWithinValidRange(finalDate)) {\n let errors =\n validStart && validEnd\n ? [\n `${getTranslation(\n locale,\n 'mustBeBetween',\n () => 'mustBeBetween'\n )(formatter.format(validStart), formatter.format(validEnd))}`,\n ]\n : [\n validStart\n ? getTranslation(\n locale,\n 'mustBeHigherThan',\n () => 'mustBeHigherThan'\n )(formatter.format(validStart))\n : '',\n validEnd\n ? getTranslation(\n locale,\n 'mustBeLowerThan',\n () => 'mustBeLowerThan'\n )(formatter.format(validEnd))\n : '',\n ]\n setError(errors.filter((n) => n).join(' '))\n return\n }\n\n setError(null)\n if (inputMode === 'end') {\n onChange(finalDate)\n } else {\n onChange(finalDate)\n }\n }\n return {\n onChange,\n error,\n formattedValue,\n onChangeText,\n inputFormat,\n }\n}\n"],"mappings":";;;;;;;AAAA;;AACA;;AAEA;;;;;;AAEe,SAASA,YAAT,OAYZ;EAAA,IAZkC;IACnCC,MADmC;IAEnCC,KAFmC;IAGnCC,UAHmC;IAInCC,SAJmC;IAKnCC;EALmC,CAYlC;EACD,MAAM;IAAEC,UAAF;IAAcC,kBAAd;IAAkCC,UAAlC;IAA8CC;EAA9C,IACJ,IAAAC,0BAAA,EAAgBP,UAAhB,CADF;EAEA,MAAM,CAACQ,KAAD,EAAQC,QAAR,IAAoBC,KAAK,CAACC,QAAN,CAA8B,IAA9B,CAA1B;EACA,MAAMC,SAAS,GAAG,IAAAC,4BAAA,EAAkB;IAAEf;EAAF,CAAlB,CAAlB;EACA,MAAMgB,WAAW,GAAG,IAAAC,yBAAA,EAAe;IAAEH,SAAF;IAAad;EAAb,CAAf,CAApB;EACA,MAAMkB,cAAc,GAAGjB,KAAK,KAAK,IAAV,GAAiBa,SAAS,CAACK,MAAV,CAAiBlB,KAAjB,CAAjB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