rn-grid-date-time-picker 1.2.2 → 1.3.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.
- package/CHANGELOG.md +35 -0
- package/lib/commonjs/components/DateTimePicker.js +109 -129
- package/lib/commonjs/components/DateTimePicker.js.map +1 -1
- package/lib/commonjs/components/calendar/DayCell.js +17 -6
- package/lib/commonjs/components/calendar/DayCell.js.map +1 -1
- package/lib/commonjs/components/calendar/calendarStyles.js +11 -0
- package/lib/commonjs/components/calendar/calendarStyles.js.map +1 -1
- package/lib/commonjs/components/container/PickerContainer.js +2 -1
- package/lib/commonjs/components/container/PickerContainer.js.map +1 -1
- package/lib/commonjs/components/container/PickerLayout.js +5 -1
- package/lib/commonjs/components/container/PickerLayout.js.map +1 -1
- package/lib/commonjs/components/field/ValueField.js +19 -2
- package/lib/commonjs/components/field/ValueField.js.map +1 -1
- package/lib/commonjs/components/field/fieldText.js +44 -5
- package/lib/commonjs/components/field/fieldText.js.map +1 -1
- package/lib/commonjs/components/hooks/useScrollToTime.js +85 -0
- package/lib/commonjs/components/hooks/useScrollToTime.js.map +1 -0
- package/lib/commonjs/components/theme/styleKeys.js +3 -1
- package/lib/commonjs/components/theme/styleKeys.js.map +1 -1
- package/lib/commonjs/components/time/TypedTime.js +20 -2
- package/lib/commonjs/components/time/TypedTime.js.map +1 -1
- package/lib/commonjs/components/types.js +4 -1
- package/lib/commonjs/components/types.js.map +1 -1
- package/lib/commonjs/core/draft.js +2 -1
- package/lib/commonjs/core/draft.js.map +1 -1
- package/lib/module/components/DateTimePicker.js +110 -130
- package/lib/module/components/DateTimePicker.js.map +1 -1
- package/lib/module/components/calendar/DayCell.js +18 -7
- package/lib/module/components/calendar/DayCell.js.map +1 -1
- package/lib/module/components/calendar/calendarStyles.js +11 -0
- package/lib/module/components/calendar/calendarStyles.js.map +1 -1
- package/lib/module/components/container/PickerContainer.js +2 -1
- package/lib/module/components/container/PickerContainer.js.map +1 -1
- package/lib/module/components/container/PickerLayout.js +5 -1
- package/lib/module/components/container/PickerLayout.js.map +1 -1
- package/lib/module/components/field/ValueField.js +20 -3
- package/lib/module/components/field/ValueField.js.map +1 -1
- package/lib/module/components/field/fieldText.js +40 -4
- package/lib/module/components/field/fieldText.js.map +1 -1
- package/lib/module/components/hooks/useScrollToTime.js +79 -0
- package/lib/module/components/hooks/useScrollToTime.js.map +1 -0
- package/lib/module/components/theme/styleKeys.js +3 -1
- package/lib/module/components/theme/styleKeys.js.map +1 -1
- package/lib/module/components/time/TypedTime.js +22 -4
- package/lib/module/components/time/TypedTime.js.map +1 -1
- package/lib/module/components/types.js +4 -1
- package/lib/module/components/types.js.map +1 -1
- package/lib/module/core/draft.js +2 -1
- package/lib/module/core/draft.js.map +1 -1
- package/lib/typescript/commonjs/src/components/DateTimePicker.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/calendar/DayCell.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/calendar/calendarStyles.d.ts +9 -0
- package/lib/typescript/commonjs/src/components/calendar/calendarStyles.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/container/PickerContainer.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/container/PickerLayout.d.ts +7 -2
- package/lib/typescript/commonjs/src/components/container/PickerLayout.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/field/ValueField.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/field/fieldText.d.ts +19 -0
- package/lib/typescript/commonjs/src/components/field/fieldText.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/hooks/useScrollToTime.d.ts +26 -0
- package/lib/typescript/commonjs/src/components/hooks/useScrollToTime.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/components/nativeTypes.d.ts +2 -1
- package/lib/typescript/commonjs/src/components/nativeTypes.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/theme/styleKeys.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/time/TypedTime.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/types.d.ts +59 -8
- package/lib/typescript/commonjs/src/components/types.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/core/draft.d.ts +2 -1
- package/lib/typescript/commonjs/src/core/draft.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/index.d.ts +1 -1
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
- package/lib/typescript/module/src/components/DateTimePicker.d.ts.map +1 -1
- package/lib/typescript/module/src/components/calendar/DayCell.d.ts.map +1 -1
- package/lib/typescript/module/src/components/calendar/calendarStyles.d.ts +9 -0
- package/lib/typescript/module/src/components/calendar/calendarStyles.d.ts.map +1 -1
- package/lib/typescript/module/src/components/container/PickerContainer.d.ts.map +1 -1
- package/lib/typescript/module/src/components/container/PickerLayout.d.ts +7 -2
- package/lib/typescript/module/src/components/container/PickerLayout.d.ts.map +1 -1
- package/lib/typescript/module/src/components/field/ValueField.d.ts.map +1 -1
- package/lib/typescript/module/src/components/field/fieldText.d.ts +19 -0
- package/lib/typescript/module/src/components/field/fieldText.d.ts.map +1 -1
- package/lib/typescript/module/src/components/hooks/useScrollToTime.d.ts +26 -0
- package/lib/typescript/module/src/components/hooks/useScrollToTime.d.ts.map +1 -0
- package/lib/typescript/module/src/components/nativeTypes.d.ts +2 -1
- package/lib/typescript/module/src/components/nativeTypes.d.ts.map +1 -1
- package/lib/typescript/module/src/components/theme/styleKeys.d.ts.map +1 -1
- package/lib/typescript/module/src/components/time/TypedTime.d.ts.map +1 -1
- package/lib/typescript/module/src/components/types.d.ts +59 -8
- package/lib/typescript/module/src/components/types.d.ts.map +1 -1
- package/lib/typescript/module/src/core/draft.d.ts +2 -1
- package/lib/typescript/module/src/core/draft.d.ts.map +1 -1
- package/lib/typescript/module/src/index.d.ts +1 -1
- package/lib/typescript/module/src/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/DateTimePicker.tsx +141 -135
- package/src/components/calendar/DayCell.tsx +25 -6
- package/src/components/calendar/calendarStyles.ts +11 -0
- package/src/components/container/PickerContainer.tsx +1 -0
- package/src/components/container/PickerLayout.tsx +10 -1
- package/src/components/field/ValueField.tsx +30 -11
- package/src/components/field/fieldText.ts +48 -5
- package/src/components/hooks/useScrollToTime.ts +99 -0
- package/src/components/nativeTypes.ts +2 -1
- package/src/components/theme/styleKeys.ts +3 -1
- package/src/components/time/TypedTime.tsx +25 -6
- package/src/components/types.ts +63 -8
- package/src/core/draft.ts +5 -2
- package/src/index.tsx +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,36 @@ All notable changes to this project are documented here. The format follows [Kee
|
|
|
4
4
|
|
|
5
5
|
## [Unreleased]
|
|
6
6
|
|
|
7
|
+
## [1.3.1] - 2026-11-13
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- `sheet.showNotAllowedError` (default `true`): `false` hides "This date isn't available" above the calendar when the picked date (or a range's end) is a disabled day, such as a saved value the rules no longer allow. Confirm stays off for that day either way.
|
|
12
|
+
|
|
13
|
+
### Fixed
|
|
14
|
+
|
|
15
|
+
- A greyed (disabled) today no longer keeps the full accent ring. Its ring keeps the accent colour at 40% opacity, like the other greyed controls, and the day number stays as grey as the other greyed days. A custom `styles.today` (its border colour or width, for example) and the corner radius from `styles.day` still apply to that ring.
|
|
16
|
+
- With a `fieldDateText` style, the empty date-time field's placeholder now sets its date apart from its time, like the value does, so `{ minWidth: '50%' }` starts the placeholder's time at the middle of the field too. A `placeholder` passed in is cut at the first `strings.dateTimeSeparator` when what follows is a time (`'DD/MM/YYYY HH:MM'`); wording such as `'Pick a time'` stays whole.
|
|
17
|
+
|
|
18
|
+
### Changed
|
|
19
|
+
|
|
20
|
+
- **A dual calendar's selection shows in both tabs.** A day picked on the Gregorian tab is highlighted on the Hijri tab too, and the other way round, and a tap on either tab edits the same selection instead of starting over, so a range can start on one tab and end on the other. The selection is saved with the tab on screen: Confirm on the Hijri tab saves a Gregorian pick as Hijri (`info.calendarSystem: 'hijri'`), and the field writes it that way. With `commitMode="instant"`, a tab (or a calendar in the switch) the user picks saves the selection again with that calendar; the tab the picker opens on doesn't. The field inside the sheet now follows the tab too. A new `calendarSystem` prop no longer clears a selection in progress. Values stay Gregorian.
|
|
21
|
+
- **A dual calendar reopens on the tab its value was saved with.** A date saved from the Hijri tab opens the picker on the Hijri tab next time, while the picker stays mounted. With no value it still opens on `dualDefaultTab`, and so does a value passed in from outside: to keep the tab after a remount, store `info.calendarSystem` and pass it as `dualDefaultTab`.
|
|
22
|
+
|
|
23
|
+
## [1.3.0] - 2026-11-12
|
|
24
|
+
|
|
25
|
+
### Added
|
|
26
|
+
|
|
27
|
+
- `fieldCalendar` (`'picked'` | `'gregory'`, default `'picked'`): how the on-screen field writes the saved value. `'gregory'` keeps it in `dateFormat`, with `strings` AM / PM and Gregorian digits, even when the date was picked on the Hijri tab. The field inside the sheet and the time rows still follow the tab, and `onChange` still reports the calendar the date was picked in.
|
|
28
|
+
- `sheet.scrollProps`: props for the sheet body's ScrollView, over the picker's own defaults, in the built-in sheet and with `renderSheet`. For example `{ showsVerticalScrollIndicator: true, persistentScrollbar: true }` keeps the scrollbar showing on Android; iOS shows it only while scrolling. Its type is exported as `SheetScrollProps`.
|
|
29
|
+
- `newDayTime: 'empty'`: a newly picked day gets no time. The time boxes stay empty (both ends of a range, the shared time of multiple dates) and Confirm stays disabled, and `commitMode: 'instant'` saves nothing, until the user enters a time. An hour alone counts, as it already did (empty minutes are 00). A saved time is kept when another day is picked. `newDayTime: 'now'` is the default and keeps the current-time behaviour; a `Time` still fixes the time.
|
|
30
|
+
- `sheet.scrollToTime` (`true` | `'end'` | `false`, default `true`): in a date-time sheet whose body scrolls, a calendar tap that picks the date now scrolls the time section into view when it's below the fold, so the time boxes show before they're tapped. Single mode scrolls on every tap, range mode once the end is picked, and multiple mode for the first date only, so more dates can be picked. `true` scrolls just far enough to show the time, `'end'` to the end of the body, `false` turns it off. Nothing moves when the time already shows in full. Built-in sheet and `renderSheet`.
|
|
31
|
+
- `scrollToTimeRef`: the same scroll for an inline date-time picker. Pass the ScrollView the picker sits in, and a calendar tap that picks the date scrolls it just far enough to show the time section. Without it an inline picker doesn't scroll, as before.
|
|
32
|
+
|
|
33
|
+
### Fixed
|
|
34
|
+
|
|
35
|
+
- Android: a drag that starts on a time box now scrolls the sheet (or the screen around an inline picker). A TextInput keeps any drag that starts on it, so the body only scrolled from the calendar. The boxes ignore touches and a wrapper takes them; a tap still focuses the box, and a tap on the box being edited brings the keyboard back. Nothing about this changes when a box gains focus, because a change at that moment made Android move focus from box to box. iOS is unchanged.
|
|
36
|
+
|
|
7
37
|
## [1.2.2] - 2026-11-05
|
|
8
38
|
|
|
9
39
|
### Fixed
|
|
@@ -146,6 +176,11 @@ Initial release.
|
|
|
146
176
|
- `dateFormat` in any case (`'dd/mm/yyyy'`). A format the picker can't use warns in development and falls back to the locale order.
|
|
147
177
|
- Accessibility labels and states, reduce-motion support, a font-scale cap and RTL mirroring. On iOS every typed box gets a Done button above the number pad, and errors are announced to VoiceOver.
|
|
148
178
|
|
|
179
|
+
[Unreleased]: https://github.com/Bhairavi-ancy/rn-grid-date-time-picker/compare/v1.3.1...HEAD
|
|
180
|
+
[1.3.1]: https://github.com/Bhairavi-ancy/rn-grid-date-time-picker/compare/v1.3.0...v1.3.1
|
|
181
|
+
[1.3.0]: https://github.com/Bhairavi-ancy/rn-grid-date-time-picker/compare/v1.2.2...v1.3.0
|
|
182
|
+
[1.2.2]: https://github.com/Bhairavi-ancy/rn-grid-date-time-picker/compare/v1.2.1...v1.2.2
|
|
183
|
+
[1.2.1]: https://github.com/Bhairavi-ancy/rn-grid-date-time-picker/compare/v1.2.0...v1.2.1
|
|
149
184
|
[1.2.0]: https://github.com/Bhairavi-ancy/rn-grid-date-time-picker/compare/v1.1.0...v1.2.0
|
|
150
185
|
[1.1.0]: https://github.com/Bhairavi-ancy/rn-grid-date-time-picker/compare/v1.0.0...v1.1.0
|
|
151
186
|
[1.0.0]: https://github.com/Bhairavi-ancy/rn-grid-date-time-picker/releases/tag/v1.0.0
|
|
@@ -21,7 +21,6 @@ var _CalendarSwitch = _interopRequireDefault(require("./calendar/CalendarSwitch.
|
|
|
21
21
|
var _localeNames = require("./calendar/localeNames.js");
|
|
22
22
|
var _direction = require("./theme/direction.js");
|
|
23
23
|
var _numerals2 = require("./theme/numerals.js");
|
|
24
|
-
var _selection = require("./calendar/selection.js");
|
|
25
24
|
var _PickerContainer = _interopRequireDefault(require("./container/PickerContainer.js"));
|
|
26
25
|
var _fieldText = require("./field/fieldText.js");
|
|
27
26
|
var _FieldMessages = _interopRequireDefault(require("./field/FieldMessages.js"));
|
|
@@ -29,6 +28,7 @@ var _RangeFields = _interopRequireDefault(require("./field/RangeFields.js"));
|
|
|
29
28
|
var _ValueField = _interopRequireDefault(require("./field/ValueField.js"));
|
|
30
29
|
var _useKeyboardFold = require("./hooks/useKeyboardFold.js");
|
|
31
30
|
var _useOpenPicker = require("./hooks/useOpenPicker.js");
|
|
31
|
+
var _useScrollToTime = require("./hooks/useScrollToTime.js");
|
|
32
32
|
var _usePickerDraft = require("./hooks/usePickerDraft.js");
|
|
33
33
|
var _useTodayTick = require("./hooks/useTodayTick.js");
|
|
34
34
|
var _TimeRows = _interopRequireDefault(require("./time/TimeRows.js"));
|
|
@@ -45,19 +45,6 @@ const RTL = {
|
|
|
45
45
|
direction: 'rtl'
|
|
46
46
|
};
|
|
47
47
|
|
|
48
|
-
/** The same kind of selection with nothing in it. */
|
|
49
|
-
const emptySelection = sel => sel.kind === 'single' ? {
|
|
50
|
-
kind: 'single',
|
|
51
|
-
day: null
|
|
52
|
-
} : sel.kind === 'range' ? {
|
|
53
|
-
kind: 'range',
|
|
54
|
-
from: null,
|
|
55
|
-
to: null
|
|
56
|
-
} : {
|
|
57
|
-
...sel,
|
|
58
|
-
days: []
|
|
59
|
-
};
|
|
60
|
-
|
|
61
48
|
/** Minute steps that divide the hour. */
|
|
62
49
|
const MINUTE_STEPS = [1, 2, 3, 4, 5, 6, 10, 12, 15, 20, 30, 60];
|
|
63
50
|
|
|
@@ -94,6 +81,7 @@ const DateTimePicker = props => {
|
|
|
94
81
|
multiple,
|
|
95
82
|
range,
|
|
96
83
|
presentation = 'sheet',
|
|
84
|
+
scrollToTimeRef,
|
|
97
85
|
visible,
|
|
98
86
|
onOpen,
|
|
99
87
|
onClose,
|
|
@@ -144,6 +132,7 @@ const DateTimePicker = props => {
|
|
|
144
132
|
calendarSwitch,
|
|
145
133
|
onCalendarSystemChange,
|
|
146
134
|
dualDefaultTab = 'gregory',
|
|
135
|
+
fieldCalendar = 'picked',
|
|
147
136
|
hijriLocale = 'ar-SA',
|
|
148
137
|
renderCalendarSwitch,
|
|
149
138
|
showToday = false,
|
|
@@ -334,12 +323,13 @@ const DateTimePicker = props => {
|
|
|
334
323
|
const folded = keyboardUp && (!isInline || ownFocus);
|
|
335
324
|
const rangeLayout = range?.layout ?? 'singleField';
|
|
336
325
|
const multipleTimeMode = multiple?.timeMode ?? 'shared';
|
|
326
|
+
const startsEmpty = newDayTime === 'empty';
|
|
337
327
|
const draftOptions = (0, _react.useMemo)(() => {
|
|
338
328
|
return {
|
|
339
329
|
type,
|
|
340
330
|
zone,
|
|
341
331
|
adapter,
|
|
342
|
-
defaultTime: _draft.DEFAULT_TIME,
|
|
332
|
+
defaultTime: startsEmpty ? null : _draft.DEFAULT_TIME,
|
|
343
333
|
multiple: {
|
|
344
334
|
timeMode: multiple?.timeMode,
|
|
345
335
|
maxSelections: multiple?.maxSelections
|
|
@@ -351,7 +341,7 @@ const DateTimePicker = props => {
|
|
|
351
341
|
maxDays: range?.maxDays
|
|
352
342
|
}
|
|
353
343
|
};
|
|
354
|
-
}, [type, zone, adapter, multiple?.timeMode, multiple?.maxSelections, range?.allowSameDay, range?.reselect, range?.minDays, range?.maxDays]);
|
|
344
|
+
}, [type, zone, adapter, startsEmpty, multiple?.timeMode, multiple?.maxSelections, range?.allowSameDay, range?.reselect, range?.minDays, range?.maxDays]);
|
|
355
345
|
const draft = (0, _usePickerDraft.usePickerDraft)(mode, value, isOpen, draftOptions);
|
|
356
346
|
const today = (0, _useTodayTick.useTodayTick)(zone, now);
|
|
357
347
|
|
|
@@ -526,6 +516,15 @@ const DateTimePicker = props => {
|
|
|
526
516
|
const preview = (0, _react.useMemo)(() => Object.values(rowPending).reduce((acc, p) => p ? (0, _draft.setTime)(acc, p.time, p.target) : acc, draft.draft), [draft.draft, rowPending]);
|
|
527
517
|
const previewIssue = (0, _draft.validateDraft)(preview, draftOptions);
|
|
528
518
|
const d = draft.draft;
|
|
519
|
+
// Once a calendar tap picks the date (both ends of a range), the sheet (or
|
|
520
|
+
// the app's ScrollView around an inline picker) scrolls the time section
|
|
521
|
+
// into view.
|
|
522
|
+
const datePicked = d.mode === 'single' ? !!d.slot.value : d.mode === 'range' ? !!d.from.value && !!d.to.value : d.slots.length > 0;
|
|
523
|
+
const {
|
|
524
|
+
scrollRef,
|
|
525
|
+
timeRef,
|
|
526
|
+
request: revealTime
|
|
527
|
+
} = (0, _useScrollToTime.useScrollToTime)(type !== 'datetime' ? false : isInline ? !!scrollToTimeRef : sheetOptions?.scrollToTime ?? true, datePicked, isInline ? scrollToTimeRef : undefined);
|
|
529
528
|
/** The values a draft would save, with a shared time applied. */
|
|
530
529
|
const valuesOf = dr => {
|
|
531
530
|
if (dr.mode === 'single') return [dr.slot.value];
|
|
@@ -562,10 +561,10 @@ const DateTimePicker = props => {
|
|
|
562
561
|
};
|
|
563
562
|
const valueKey = JSON.stringify(value ?? '');
|
|
564
563
|
|
|
565
|
-
// A selection
|
|
566
|
-
//
|
|
567
|
-
// value remembers its calendar; one from outside counts as picked in
|
|
568
|
-
// calendar the picker opens on.
|
|
564
|
+
// A selection shows in both tabs (Gregorian and Hijri). It is saved with the
|
|
565
|
+
// calendar on screen, and the on-screen field writes it in that calendar. A
|
|
566
|
+
// saved value remembers its calendar; one from outside counts as picked in
|
|
567
|
+
// the calendar the picker opens on.
|
|
569
568
|
// The saved value as a draft, for the on-screen field and for comparing
|
|
570
569
|
// values by what they hold.
|
|
571
570
|
const saved = (0, _react.useMemo)(() => (0, _draft.createDraft)(mode, value, draftOptions),
|
|
@@ -576,32 +575,12 @@ const DateTimePicker = props => {
|
|
|
576
575
|
const savedContent = contentOf(saved);
|
|
577
576
|
const savedSystemRef = (0, _react.useRef)(null);
|
|
578
577
|
const savedSystem = savedSystemRef.current?.content === savedContent ? savedSystemRef.current.system : outsideSystem;
|
|
579
|
-
const
|
|
580
|
-
//
|
|
581
|
-
//
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
valueKey,
|
|
586
|
-
savedSystem
|
|
587
|
-
});
|
|
588
|
-
(0, _react.useEffect)(() => {
|
|
589
|
-
const seen = systemSeen.current;
|
|
590
|
-
systemSeen.current = {
|
|
591
|
-
isOpen,
|
|
592
|
-
valueKey,
|
|
593
|
-
savedSystem
|
|
594
|
-
};
|
|
595
|
-
setDraftSystem(savedSystem);
|
|
596
|
-
const systemOnly = seen.isOpen === isOpen && seen.valueKey === valueKey && seen.savedSystem !== savedSystem;
|
|
597
|
-
if (systemOnly && isOpen && edited.current) {
|
|
598
|
-
draft.clear();
|
|
599
|
-
resetSelectionUi();
|
|
600
|
-
}
|
|
601
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps -- the draft's actions are stable
|
|
602
|
-
}, [isOpen, valueKey, savedSystem]);
|
|
603
|
-
(0, _react.useEffect)(() => setDualTab(dualDefaultTab), [isOpen, dualDefaultTab]);
|
|
604
|
-
const selectionShown = draftSystem === shownSystem;
|
|
578
|
+
const hasSaved = valuesOf(saved).some(v => v !== null);
|
|
579
|
+
// Each open starts on the tab the saved value was saved with; with no value,
|
|
580
|
+
// on dualDefaultTab.
|
|
581
|
+
(0, _react.useEffect)(() => setDualTab(hasSaved ? savedSystem : dualDefaultTab),
|
|
582
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps -- on open and on a new dualDefaultTab, not on every save
|
|
583
|
+
[isOpen, dualDefaultTab]);
|
|
605
584
|
/** Saves a value: with the calendar it was picked in, when one can be Hijri. */
|
|
606
585
|
const emitChange = (0, _react.useCallback)((wire, picked) => {
|
|
607
586
|
savedSystemRef.current = {
|
|
@@ -625,11 +604,12 @@ const DateTimePicker = props => {
|
|
|
625
604
|
bounds: constraints.timeBounds(v.date)
|
|
626
605
|
}) === null)) && !typingBlocked && !wheelSpinning && !confirmDisabled;
|
|
627
606
|
|
|
628
|
-
// Every save: Confirm, an 'instant' edit (onConfirm is added by `confirm`)
|
|
607
|
+
// Every save: Confirm, an 'instant' edit (onConfirm is added by `confirm`),
|
|
608
|
+
// with the calendar on screen.
|
|
629
609
|
const commit = (0, _react.useCallback)(wire => {
|
|
630
|
-
emitChange(wire,
|
|
610
|
+
emitChange(wire, shownSystem);
|
|
631
611
|
onBlur?.();
|
|
632
|
-
}, [emitChange,
|
|
612
|
+
}, [emitChange, shownSystem, onBlur]);
|
|
633
613
|
const confirm = (0, _react.useCallback)(() => {
|
|
634
614
|
if (!canConfirm) return;
|
|
635
615
|
const {
|
|
@@ -661,8 +641,8 @@ const DateTimePicker = props => {
|
|
|
661
641
|
draft.clear();
|
|
662
642
|
resetSelectionUi();
|
|
663
643
|
edited.current = false;
|
|
664
|
-
emitChange('',
|
|
665
|
-
}, [draft, emitChange,
|
|
644
|
+
emitChange('', shownSystem);
|
|
645
|
+
}, [draft, emitChange, shownSystem, resetSelectionUi]);
|
|
666
646
|
const clearDraft = (0, _react.useCallback)(() => {
|
|
667
647
|
edited.current = true;
|
|
668
648
|
draft.clear();
|
|
@@ -671,7 +651,6 @@ const DateTimePicker = props => {
|
|
|
671
651
|
|
|
672
652
|
// × in the field above the calendar. 'instant' saves every edit, so it
|
|
673
653
|
// clears the saved value too (once; an empty value isn't saved again).
|
|
674
|
-
const hasSaved = valuesOf(saved).some(v => v !== null);
|
|
675
654
|
const clearInSheet = (0, _react.useCallback)(() => {
|
|
676
655
|
if (commitMode === 'instant' && hasSaved) clearValue();else clearDraft();
|
|
677
656
|
}, [commitMode, hasSaved, clearValue, clearDraft]);
|
|
@@ -683,7 +662,8 @@ const DateTimePicker = props => {
|
|
|
683
662
|
// Confirm press, but only while open (closing discards, as with Confirm),
|
|
684
663
|
// and only what the draft holds: a time still being typed isn't saved yet.
|
|
685
664
|
// An edit equal to the saved value isn't saved again; one `validate`
|
|
686
|
-
// rejected waits until the selection or the saved value changes.
|
|
665
|
+
// rejected waits until the selection or the saved value changes. A tab
|
|
666
|
+
// change the user makes saves the selection again with the new calendar.
|
|
687
667
|
const lastRejected = (0, _react.useRef)(null);
|
|
688
668
|
// The last value saved: not saved again while the parent's `value` catches
|
|
689
669
|
// up (a slow store, a server round trip) or when it never does.
|
|
@@ -701,11 +681,12 @@ const DateTimePicker = props => {
|
|
|
701
681
|
if (!typingDone || timeIssue || !canSave(draft.draft)) return;
|
|
702
682
|
const wire = draft.toWire();
|
|
703
683
|
const key = JSON.stringify(wire);
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
// dates
|
|
684
|
+
const sent = `${shownSystem} ${key}`;
|
|
685
|
+
if (key === lastRejected.current || sent === lastEmitted.current) return;
|
|
686
|
+
// The same dates in the same calendar aren't saved again; the same dates
|
|
687
|
+
// with the other tab on screen are.
|
|
707
688
|
const unchanged = key === valueKey || contentOf(draft.draft) === savedContent;
|
|
708
|
-
if (unchanged &&
|
|
689
|
+
if (unchanged && shownSystem === savedSystem) return;
|
|
709
690
|
const message = latest.current.validate?.(wire);
|
|
710
691
|
if (message) {
|
|
711
692
|
lastRejected.current = key;
|
|
@@ -716,14 +697,14 @@ const DateTimePicker = props => {
|
|
|
716
697
|
latest.current.onError?.('VALIDATION', wire);
|
|
717
698
|
return;
|
|
718
699
|
}
|
|
719
|
-
lastEmitted.current =
|
|
700
|
+
lastEmitted.current = sent;
|
|
720
701
|
commit(wire);
|
|
721
702
|
};
|
|
722
703
|
// Only typing waits for the field to be left; a tap is a finished edit.
|
|
723
704
|
const typedLast = (0, _react.useRef)(false);
|
|
724
705
|
(0, _react.useEffect)(() => saveInstant(!sheetTyping || !typedLast.current),
|
|
725
706
|
// eslint-disable-next-line react-hooks/exhaustive-deps -- when the draft or what blocks it changes, not when callbacks are re-created
|
|
726
|
-
[commitMode, isOpen, sheetTyping, draft.draft,
|
|
707
|
+
[commitMode, isOpen, sheetTyping, draft.draft, shownSystem, timeIssue, typingBlocked, wheelSpinning, confirmDisabled, constraints]);
|
|
727
708
|
// Closing while the sheet's field still has focus ends the typing: an
|
|
728
709
|
// instant picker saves what was typed before it closes.
|
|
729
710
|
const saveInstantRef = (0, _react.useRef)(saveInstant);
|
|
@@ -734,21 +715,14 @@ const DateTimePicker = props => {
|
|
|
734
715
|
}, [closePicker]);
|
|
735
716
|
|
|
736
717
|
// A typed date with no time yet gets one the way a tapped day does: the fixed
|
|
737
|
-
// newDayTime, else a time already typed in the time row, else now.
|
|
718
|
+
// newDayTime, else a time already typed in the time row, else now (or none).
|
|
738
719
|
const withFilledTime = (parsed, key) => parsed.value ?? (parsed.dateOnly ? {
|
|
739
720
|
date: parsed.dateOnly,
|
|
740
|
-
time: fixedTime ?? pending[key] ??
|
|
721
|
+
time: fixedTime ?? pending[key] ?? newTime()
|
|
741
722
|
} : null);
|
|
742
|
-
|
|
743
|
-
// Typed segments are Gregorian, so typing keeps the calendar a selection was
|
|
744
|
-
// picked in; into an empty draft, it takes the calendar on screen.
|
|
745
|
-
const adoptShownIfEmpty = () => {
|
|
746
|
-
if (valuesOf(d).every(v => v === null)) setDraftSystem(shownSystem);
|
|
747
|
-
};
|
|
748
723
|
const onSheetTyped = parsed => {
|
|
749
724
|
edited.current = true;
|
|
750
725
|
typedLast.current = true;
|
|
751
|
-
adoptShownIfEmpty();
|
|
752
726
|
const typed = withFilledTime(parsed, 'single');
|
|
753
727
|
setTypingBlock('single', !parsed.isEmpty && !typed);
|
|
754
728
|
if (typed) draft.setValue(typed, 'single');else if (parsed.isEmpty) draft.clear();
|
|
@@ -756,14 +730,13 @@ const DateTimePicker = props => {
|
|
|
756
730
|
const onRangeTyped = (end, parsed) => {
|
|
757
731
|
edited.current = true;
|
|
758
732
|
typedLast.current = true;
|
|
759
|
-
adoptShownIfEmpty();
|
|
760
733
|
const typed = withFilledTime(parsed, end);
|
|
761
734
|
setTypingBlock(end, !parsed.isEmpty && !typed);
|
|
762
735
|
if (typed || parsed.isEmpty) draft.setValue(typed, end);
|
|
763
736
|
};
|
|
764
737
|
|
|
765
738
|
// A fixed time for every newly picked day (wins over a typed time and over "now").
|
|
766
|
-
const fixedTime = newDayTime
|
|
739
|
+
const fixedTime = typeof newDayTime === 'object' ? newDayTime : null;
|
|
767
740
|
|
|
768
741
|
// A day picked on an empty date-time starts at the current time, moved up to
|
|
769
742
|
// the next allowed minute step. An existing time is kept.
|
|
@@ -777,6 +750,8 @@ const DateTimePicker = props => {
|
|
|
777
750
|
minute: capped % 60
|
|
778
751
|
};
|
|
779
752
|
}, [now, zone, minuteStep]);
|
|
753
|
+
/** A new day's time when nothing fixed or typed: now, or none with newDayTime 'empty'. */
|
|
754
|
+
const newTime = (0, _react.useCallback)(() => startsEmpty ? null : nowTime(), [startsEmpty, nowTime]);
|
|
780
755
|
|
|
781
756
|
// A range end picked on the start's day starts an hour after the start (at
|
|
782
757
|
// most the day's latest allowed time, or its last step), so the range isn't
|
|
@@ -784,8 +759,8 @@ const DateTimePicker = props => {
|
|
|
784
759
|
// A time typed for the end before its day is kept as typed.
|
|
785
760
|
const endTimeFor = (from, day, typed) => {
|
|
786
761
|
if (!fixedTime && typed) return typed;
|
|
787
|
-
const time = fixedTime ??
|
|
788
|
-
if (!from?.time || !(0, _calendarDate.isSameDay)(from.date, day)) return time;
|
|
762
|
+
const time = fixedTime ?? newTime();
|
|
763
|
+
if (!time || !from?.time || !(0, _calendarDate.isSameDay)(from.date, day)) return time;
|
|
789
764
|
const start = from.time.hour * 60 + from.time.minute;
|
|
790
765
|
if (time.hour * 60 + time.minute > start) return time;
|
|
791
766
|
// Within the day's allowed hours when it has them.
|
|
@@ -800,66 +775,57 @@ const DateTimePicker = props => {
|
|
|
800
775
|
const onSelectDay = (0, _react.useCallback)(day => {
|
|
801
776
|
edited.current = true;
|
|
802
777
|
typedLast.current = false;
|
|
803
|
-
// A
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
const cur = fresh ? (0, _draft.clearDraft)(d) : d;
|
|
807
|
-
const end0 = fresh ? 'from' : activeEnd;
|
|
808
|
-
const dayInEdit = fresh ? null : activeDay;
|
|
809
|
-
const times = fresh ? {} : pending;
|
|
810
|
-
if (fresh) {
|
|
811
|
-
draft.clear();
|
|
812
|
-
resetSelectionUi();
|
|
813
|
-
}
|
|
814
|
-
if (cur.mode === 'range') {
|
|
778
|
+
// A multiple picker scrolls for its first date only, so more can be picked.
|
|
779
|
+
if (d.mode !== 'multiple' || d.slots.length === 0) revealTime();
|
|
780
|
+
if (d.mode === 'range') {
|
|
815
781
|
if (rangeLayout === 'fromTo') {
|
|
816
782
|
setEndPicked(false);
|
|
817
783
|
// A full range: the tap starts a new one (or moves the nearest end).
|
|
818
|
-
if (!endPicked &&
|
|
784
|
+
if (!endPicked && d.from.value && d.to.value) {
|
|
819
785
|
const moveNearest = range?.reselect === 'moveNearestEnd';
|
|
820
|
-
const nearest = Math.abs((0, _calendarDate.daysBetween)(
|
|
786
|
+
const nearest = Math.abs((0, _calendarDate.daysBetween)(d.from.value.date, day)) < Math.abs((0, _calendarDate.daysBetween)(d.to.value.date, day)) ? 'from' : 'to';
|
|
821
787
|
const end = moveNearest ? nearest : 'from';
|
|
822
788
|
setTypingBlock('from', false);
|
|
823
789
|
setTypingBlock('to', false);
|
|
824
|
-
draft.selectDay(day, fixedTime ??
|
|
790
|
+
draft.selectDay(day, fixedTime ?? pending[end] ?? newTime());
|
|
825
791
|
setActiveEnd(moveNearest ? nearest : 'to');
|
|
826
792
|
return;
|
|
827
793
|
}
|
|
828
794
|
// Choosing the end after a start tap: a day before the start moves the start.
|
|
829
|
-
const end1 =
|
|
795
|
+
const end1 = activeEnd === 'to' && !endPicked && d.from.value && (0, _calendarDate.compareCalendarDates)(day, d.from.value.date) < 0 ? 'from' : activeEnd;
|
|
830
796
|
// The tapped day replaces whatever was typed in this end only.
|
|
831
797
|
setTypingBlock(end1, false);
|
|
832
|
-
draft.setRangeEnd(day, end1, end1 === 'to' ? endTimeFor(
|
|
798
|
+
draft.setRangeEnd(day, end1, end1 === 'to' ? endTimeFor(d.from.value, day, pending.to) : fixedTime ?? pending.from ?? newTime());
|
|
833
799
|
// The start tapped again where a range can't be one day deselects
|
|
834
800
|
// it, so the next tap picks the start again.
|
|
835
|
-
const deselects = end1 === 'to' && !(0, _draft.sameDayRangeOk)(draftOptions) && (0, _calendarDate.isSameDay)(
|
|
836
|
-
if (
|
|
801
|
+
const deselects = end1 === 'to' && !(0, _draft.sameDayRangeOk)(draftOptions) && (0, _calendarDate.isSameDay)(d.from.value?.date, day);
|
|
802
|
+
if (activeEnd === 'from') setActiveEnd('to');else if (deselects) setActiveEnd('from');
|
|
837
803
|
return;
|
|
838
804
|
}
|
|
839
805
|
// The single field: the first tap is the start, the next one the end.
|
|
840
|
-
const startsOver = !
|
|
806
|
+
const startsOver = !d.from.value || !!d.to.value && range?.reselect !== 'moveNearestEnd';
|
|
841
807
|
const end = startsOver ? 'from' : 'to';
|
|
842
808
|
setTypingBlock('single', false);
|
|
843
|
-
draft.selectDay(day, end === 'to' && !
|
|
809
|
+
draft.selectDay(day, end === 'to' && !d.to.value ? endTimeFor(d.from.value, day, pending.to) : fixedTime ?? pending[end] ?? newTime());
|
|
844
810
|
return;
|
|
845
811
|
}
|
|
846
|
-
if (
|
|
812
|
+
if (d.mode === 'multiple') {
|
|
847
813
|
const perDate = type === 'datetime' && multipleTimeMode === 'perDate';
|
|
848
|
-
const picked =
|
|
814
|
+
const picked = d.slots.some(slot => (0, _calendarDate.isSameDay)(slot.value?.date, day));
|
|
849
815
|
// perDate: a tap on a picked day first makes it the one the time row edits.
|
|
850
|
-
if (perDate && picked && !(0, _calendarDate.isSameDay)(
|
|
816
|
+
if (perDate && picked && !(0, _calendarDate.isSameDay)(activeDay, day)) {
|
|
851
817
|
setActiveDay(day);
|
|
852
818
|
return;
|
|
853
819
|
}
|
|
854
|
-
draft.selectDay(day, fixedTime ??
|
|
820
|
+
draft.selectDay(day, fixedTime ?? newTime());
|
|
855
821
|
if (perDate) setActiveDay(picked ? null : day);
|
|
856
822
|
return;
|
|
857
823
|
}
|
|
858
824
|
setTypingBlock('single', false);
|
|
859
|
-
draft.selectDay(day, fixedTime ??
|
|
825
|
+
draft.selectDay(day, fixedTime ?? pending.single ?? newTime());
|
|
860
826
|
},
|
|
861
827
|
// eslint-disable-next-line react-hooks/exhaustive-deps -- valuesOf reads only `d` and props listed here
|
|
862
|
-
[d, draft,
|
|
828
|
+
[d, draft, newTime, rangeLayout, activeEnd, activeDay, fixedTime, pending, range?.reselect, type, multipleTimeMode, setTypingBlock, endPicked, draftOptions, minuteStep, constraints, revealTime]);
|
|
863
829
|
|
|
864
830
|
// The calendar gets a tap handler that never changes, so its memoized day
|
|
865
831
|
// cells don't all redraw on every tap; it calls the current one.
|
|
@@ -979,12 +945,13 @@ const DateTimePicker = props => {
|
|
|
979
945
|
|
|
980
946
|
/** A value's date in the calendar it was picked in: Hijri text, or none for the dateFormat. */
|
|
981
947
|
const dateTextFor = picked => picked === 'hijri' ? v => (0, _calendarSystem.hijriDateText)(v.date, hijriLocale) ?? (0, _fieldText.formatDateText)(v, dateFormat) : undefined;
|
|
982
|
-
|
|
983
|
-
const
|
|
984
|
-
const
|
|
985
|
-
const
|
|
986
|
-
|
|
987
|
-
//
|
|
948
|
+
// The calendar the on-screen field writes the saved value in.
|
|
949
|
+
const fieldSystem = fieldCalendar === 'gregory' ? 'gregory' : savedSystem;
|
|
950
|
+
const savedDateText = dateTextFor(fieldSystem);
|
|
951
|
+
const draftDateText = dateTextFor(shownSystem);
|
|
952
|
+
const savedStrings = stringsFor(fieldSystem);
|
|
953
|
+
// The texts inside the picker, its error messages too, follow the tab on
|
|
954
|
+
// screen; the on-screen field's keep `strings`.
|
|
988
955
|
const shownStrings = stringsFor(shownSystem);
|
|
989
956
|
|
|
990
957
|
// What the on-screen field shows: the saved value, never the draft.
|
|
@@ -1015,7 +982,7 @@ const DateTimePicker = props => {
|
|
|
1015
982
|
type,
|
|
1016
983
|
mode,
|
|
1017
984
|
value,
|
|
1018
|
-
displayText: digitsFor(
|
|
985
|
+
displayText: digitsFor(fieldSystem)(savedText ?? (0, _fieldText.formatValueText)(savedSingle, type, dateFormat, timeFormat, savedDateText, savedStrings)),
|
|
1019
986
|
disabled,
|
|
1020
987
|
readOnly,
|
|
1021
988
|
isOpen,
|
|
@@ -1036,11 +1003,12 @@ const DateTimePicker = props => {
|
|
|
1036
1003
|
};
|
|
1037
1004
|
const sheetValue = draft.draft.mode === 'single' ? draft.draft.slot.value : null;
|
|
1038
1005
|
// A time outside the limits is explained under the time row, not here.
|
|
1039
|
-
const
|
|
1006
|
+
const notAllowedError = sheetOptions?.showNotAllowedError === false ? '' : shownStrings.errorNotAllowed;
|
|
1007
|
+
const sheetValueError = sheetValue && dayOff(sheetValue.date) ? notAllowedError : '';
|
|
1040
1008
|
let rangeError = '';
|
|
1041
1009
|
if (d.mode === 'range' && d.from.value && d.to.value) {
|
|
1042
1010
|
const length = (0, _calendarDate.daysBetween)(d.from.value.date, d.to.value.date) + 1;
|
|
1043
|
-
if (constraints.dayStatus(d.from.value.date).disabled || constraints.dayStatus(d.to.value.date).disabled) rangeError =
|
|
1011
|
+
if (constraints.dayStatus(d.from.value.date).disabled || constraints.dayStatus(d.to.value.date).disabled) rangeError = notAllowedError;else if (previewIssue === 'RANGE_ORDER') rangeError = shownStrings.errorRangeOrder;else if (previewIssue === 'RANGE_LENGTH') rangeError = range?.minDays !== undefined && length < range.minDays ? shownStrings.errorRangeTooShort(range.minDays) : shownStrings.errorRangeTooLong(range?.maxDays ?? length);
|
|
1044
1012
|
}
|
|
1045
1013
|
const fieldCommon = {
|
|
1046
1014
|
type,
|
|
@@ -1090,7 +1058,7 @@ const DateTimePicker = props => {
|
|
|
1090
1058
|
testID: testID ? `${testID}-value` : undefined
|
|
1091
1059
|
}) : mode === 'single' ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_ValueField.default, {
|
|
1092
1060
|
...fieldCommon,
|
|
1093
|
-
strings:
|
|
1061
|
+
strings: shownStrings,
|
|
1094
1062
|
errorStrings: shownStrings,
|
|
1095
1063
|
value: sheetValue,
|
|
1096
1064
|
displayText: precision !== 'day' ? periodText(sheetValue) : undefined,
|
|
@@ -1107,7 +1075,7 @@ const DateTimePicker = props => {
|
|
|
1107
1075
|
testID: testID ? `${testID}-value` : undefined
|
|
1108
1076
|
}) : d.mode === 'range' ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_RangeFields.default, {
|
|
1109
1077
|
...fieldCommon,
|
|
1110
|
-
strings:
|
|
1078
|
+
strings: shownStrings,
|
|
1111
1079
|
errorStrings: shownStrings,
|
|
1112
1080
|
layout: rangeLayout,
|
|
1113
1081
|
dateText: draftDateText,
|
|
@@ -1127,9 +1095,9 @@ const DateTimePicker = props => {
|
|
|
1127
1095
|
testID: testID
|
|
1128
1096
|
}) : d.mode === 'multiple' ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_ValueField.default, {
|
|
1129
1097
|
...fieldCommon,
|
|
1130
|
-
strings:
|
|
1098
|
+
strings: shownStrings,
|
|
1131
1099
|
value: null,
|
|
1132
|
-
displayText: (0, _fieldText.formatMultipleText)(draftValues, type, dateFormat, timeFormat, draftDateText,
|
|
1100
|
+
displayText: (0, _fieldText.formatMultipleText)(draftValues, type, dateFormat, timeFormat, draftDateText, shownStrings),
|
|
1133
1101
|
placeholder: sheetOptions?.fieldPlaceholder,
|
|
1134
1102
|
allowClear: allowClear,
|
|
1135
1103
|
onClear: clearInSheet,
|
|
@@ -1144,13 +1112,20 @@ const DateTimePicker = props => {
|
|
|
1144
1112
|
dual: strings.calendarDual ?? _defaultStrings.DEFAULT_STRINGS.calendarDual
|
|
1145
1113
|
};
|
|
1146
1114
|
const systemA11yLabel = strings.a11yCalendarSystem ?? _defaultStrings.DEFAULT_STRINGS.a11yCalendarSystem;
|
|
1115
|
+
// A calendar or tab the user picks is an edit: 'instant' saves the selection
|
|
1116
|
+
// again with that calendar.
|
|
1147
1117
|
const chooseSystem = next => {
|
|
1148
1118
|
if (next === system) return;
|
|
1119
|
+
edited.current = true;
|
|
1149
1120
|
setChosenSystem(next);
|
|
1150
1121
|
if (next === 'dual') setDualTab(dualDefaultTab);
|
|
1151
1122
|
echo.current = next;
|
|
1152
1123
|
onCalendarSystemChange?.(next);
|
|
1153
1124
|
};
|
|
1125
|
+
const chooseTab = next => {
|
|
1126
|
+
edited.current = true;
|
|
1127
|
+
setDualTab(next);
|
|
1128
|
+
};
|
|
1154
1129
|
const calendarSwitchNode = !switchSystems ? null : renderCalendarSwitch ? renderCalendarSwitch({
|
|
1155
1130
|
systems: switchSystems,
|
|
1156
1131
|
selected: system,
|
|
@@ -1182,7 +1157,7 @@ const DateTimePicker = props => {
|
|
|
1182
1157
|
label: systemLabels.hijri
|
|
1183
1158
|
}],
|
|
1184
1159
|
selected: dualTab,
|
|
1185
|
-
onSelect:
|
|
1160
|
+
onSelect: chooseTab,
|
|
1186
1161
|
accessibilityLabel: systemA11yLabel,
|
|
1187
1162
|
tokens: tokens,
|
|
1188
1163
|
styles: styles,
|
|
@@ -1198,16 +1173,16 @@ const DateTimePicker = props => {
|
|
|
1198
1173
|
children: node
|
|
1199
1174
|
})
|
|
1200
1175
|
});
|
|
1201
|
-
// Another calendar opens on the days the last one showed, else
|
|
1202
|
-
//
|
|
1203
|
-
const calendarAnchor = shownAnchor.current ??
|
|
1176
|
+
// Another calendar opens on the days the last one showed, else where the
|
|
1177
|
+
// picker would open.
|
|
1178
|
+
const calendarAnchor = shownAnchor.current ?? initialVisibleDate;
|
|
1204
1179
|
const calendar = /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
1205
1180
|
style: folded ? FOLDED : undefined,
|
|
1206
1181
|
children: [calendarSwitchNode, dualTabs, mirrored(/*#__PURE__*/(0, _jsxRuntime.jsx)(_Calendar.default, {
|
|
1207
|
-
constraints:
|
|
1182
|
+
constraints: calendarConstraints,
|
|
1208
1183
|
today: today,
|
|
1209
1184
|
initialVisibleDate: calendarAnchor,
|
|
1210
|
-
selection:
|
|
1185
|
+
selection: selection,
|
|
1211
1186
|
onSelectDay: onSelectDayStable,
|
|
1212
1187
|
firstDayOfWeek: firstDayOfWeek,
|
|
1213
1188
|
showOutsideDays: showOutsideDays,
|
|
@@ -1270,18 +1245,22 @@ const DateTimePicker = props => {
|
|
|
1270
1245
|
// Shown while the selection is still the one it was given for.
|
|
1271
1246
|
const validationMessage = validation && (validation.key === JSON.stringify(draft.toWire()) || validation.key === JSON.stringify((0, _draft.draftToWire)(preview, draftOptions))) ? validation.message : null;
|
|
1272
1247
|
|
|
1273
|
-
// The field
|
|
1274
|
-
// the calendar and the time rows follow the tab that shows.
|
|
1248
|
+
// The field, the calendar and the time rows follow the tab that shows.
|
|
1275
1249
|
const sheetContent = /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
1276
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.
|
|
1277
|
-
value: digitsFor(draftSystem),
|
|
1278
|
-
children: sheetField
|
|
1279
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_numerals2.NumeralsContext.Provider, {
|
|
1280
|
-
value: digitsFor(shownSystem),
|
|
1281
|
-
children: calendar
|
|
1282
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_numerals2.NumeralsContext.Provider, {
|
|
1250
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_numerals2.NumeralsContext.Provider, {
|
|
1283
1251
|
value: digitsFor(shownSystem),
|
|
1284
|
-
children:
|
|
1252
|
+
children: [sheetField, calendar]
|
|
1253
|
+
}), timeRow == null ? null :
|
|
1254
|
+
/*#__PURE__*/
|
|
1255
|
+
// Measured for the scroll to the time (sheet.scrollToTime).
|
|
1256
|
+
(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
1257
|
+
ref: timeRef,
|
|
1258
|
+
collapsable: false,
|
|
1259
|
+
testID: testID ? `${testID}-time-section` : undefined,
|
|
1260
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_numerals2.NumeralsContext.Provider, {
|
|
1261
|
+
value: digitsFor(shownSystem),
|
|
1262
|
+
children: mirrored(timeRow)
|
|
1263
|
+
})
|
|
1285
1264
|
}), validationMessage ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_FieldMessages.default, {
|
|
1286
1265
|
error: validationMessage,
|
|
1287
1266
|
tokens: tokens,
|
|
@@ -1293,13 +1272,14 @@ const DateTimePicker = props => {
|
|
|
1293
1272
|
}) : null]
|
|
1294
1273
|
});
|
|
1295
1274
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_numerals2.NumeralsContext.Provider, {
|
|
1296
|
-
value: digitsFor(
|
|
1275
|
+
value: digitsFor(fieldSystem),
|
|
1297
1276
|
children: [trigger, /*#__PURE__*/(0, _jsxRuntime.jsx)(_PickerContainer.default, {
|
|
1298
1277
|
presentation: presentation,
|
|
1299
1278
|
isOpen: isOpen,
|
|
1300
1279
|
onRequestClose: close,
|
|
1301
1280
|
renderSheet: renderSheet,
|
|
1302
1281
|
sheet: sheetOptions,
|
|
1282
|
+
scrollRef: scrollRef,
|
|
1303
1283
|
state: state,
|
|
1304
1284
|
header: header,
|
|
1305
1285
|
title: title ?? (isInline ? undefined : strings.titleDate),
|