rn-grid-date-time-picker 1.2.1 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/lib/commonjs/components/DateTimePicker.js +48 -20
  3. package/lib/commonjs/components/DateTimePicker.js.map +1 -1
  4. package/lib/commonjs/components/container/PickerContainer.js +2 -1
  5. package/lib/commonjs/components/container/PickerContainer.js.map +1 -1
  6. package/lib/commonjs/components/container/PickerLayout.js +5 -1
  7. package/lib/commonjs/components/container/PickerLayout.js.map +1 -1
  8. package/lib/commonjs/components/field/KeyboardAccessoryBar.js +38 -0
  9. package/lib/commonjs/components/field/KeyboardAccessoryBar.js.map +1 -0
  10. package/lib/commonjs/components/field/SegmentedInput.js +11 -6
  11. package/lib/commonjs/components/field/SegmentedInput.js.map +1 -1
  12. package/lib/commonjs/components/hooks/useScrollToTime.js +85 -0
  13. package/lib/commonjs/components/hooks/useScrollToTime.js.map +1 -0
  14. package/lib/commonjs/components/theme/defaultStrings.js.map +1 -1
  15. package/lib/commonjs/components/time/TypedTime.js +34 -10
  16. package/lib/commonjs/components/time/TypedTime.js.map +1 -1
  17. package/lib/commonjs/components/types.js +2 -0
  18. package/lib/commonjs/components/types.js.map +1 -1
  19. package/lib/commonjs/core/draft.js +2 -1
  20. package/lib/commonjs/core/draft.js.map +1 -1
  21. package/lib/module/components/DateTimePicker.js +48 -20
  22. package/lib/module/components/DateTimePicker.js.map +1 -1
  23. package/lib/module/components/container/PickerContainer.js +2 -1
  24. package/lib/module/components/container/PickerContainer.js.map +1 -1
  25. package/lib/module/components/container/PickerLayout.js +5 -1
  26. package/lib/module/components/container/PickerLayout.js.map +1 -1
  27. package/lib/module/components/field/KeyboardAccessoryBar.js +33 -0
  28. package/lib/module/components/field/KeyboardAccessoryBar.js.map +1 -0
  29. package/lib/module/components/field/SegmentedInput.js +11 -7
  30. package/lib/module/components/field/SegmentedInput.js.map +1 -1
  31. package/lib/module/components/hooks/useScrollToTime.js +79 -0
  32. package/lib/module/components/hooks/useScrollToTime.js.map +1 -0
  33. package/lib/module/components/theme/defaultStrings.js.map +1 -1
  34. package/lib/module/components/time/TypedTime.js +33 -11
  35. package/lib/module/components/time/TypedTime.js.map +1 -1
  36. package/lib/module/components/types.js +2 -0
  37. package/lib/module/components/types.js.map +1 -1
  38. package/lib/module/core/draft.js +2 -1
  39. package/lib/module/core/draft.js.map +1 -1
  40. package/lib/typescript/commonjs/src/components/DateTimePicker.d.ts.map +1 -1
  41. package/lib/typescript/commonjs/src/components/container/PickerContainer.d.ts.map +1 -1
  42. package/lib/typescript/commonjs/src/components/container/PickerLayout.d.ts +7 -2
  43. package/lib/typescript/commonjs/src/components/container/PickerLayout.d.ts.map +1 -1
  44. package/lib/typescript/commonjs/src/components/field/KeyboardAccessoryBar.d.ts +15 -0
  45. package/lib/typescript/commonjs/src/components/field/KeyboardAccessoryBar.d.ts.map +1 -0
  46. package/lib/typescript/commonjs/src/components/field/SegmentedInput.d.ts +2 -2
  47. package/lib/typescript/commonjs/src/components/field/SegmentedInput.d.ts.map +1 -1
  48. package/lib/typescript/commonjs/src/components/hooks/useScrollToTime.d.ts +26 -0
  49. package/lib/typescript/commonjs/src/components/hooks/useScrollToTime.d.ts.map +1 -0
  50. package/lib/typescript/commonjs/src/components/nativeTypes.d.ts +2 -1
  51. package/lib/typescript/commonjs/src/components/nativeTypes.d.ts.map +1 -1
  52. package/lib/typescript/commonjs/src/components/theme/defaultStrings.d.ts +1 -0
  53. package/lib/typescript/commonjs/src/components/theme/defaultStrings.d.ts.map +1 -1
  54. package/lib/typescript/commonjs/src/components/time/TypedTime.d.ts +1 -1
  55. package/lib/typescript/commonjs/src/components/time/TypedTime.d.ts.map +1 -1
  56. package/lib/typescript/commonjs/src/components/types.d.ts +41 -3
  57. package/lib/typescript/commonjs/src/components/types.d.ts.map +1 -1
  58. package/lib/typescript/commonjs/src/core/draft.d.ts +2 -1
  59. package/lib/typescript/commonjs/src/core/draft.d.ts.map +1 -1
  60. package/lib/typescript/commonjs/src/index.d.ts +1 -1
  61. package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
  62. package/lib/typescript/module/src/components/DateTimePicker.d.ts.map +1 -1
  63. package/lib/typescript/module/src/components/container/PickerContainer.d.ts.map +1 -1
  64. package/lib/typescript/module/src/components/container/PickerLayout.d.ts +7 -2
  65. package/lib/typescript/module/src/components/container/PickerLayout.d.ts.map +1 -1
  66. package/lib/typescript/module/src/components/field/KeyboardAccessoryBar.d.ts +15 -0
  67. package/lib/typescript/module/src/components/field/KeyboardAccessoryBar.d.ts.map +1 -0
  68. package/lib/typescript/module/src/components/field/SegmentedInput.d.ts +2 -2
  69. package/lib/typescript/module/src/components/field/SegmentedInput.d.ts.map +1 -1
  70. package/lib/typescript/module/src/components/hooks/useScrollToTime.d.ts +26 -0
  71. package/lib/typescript/module/src/components/hooks/useScrollToTime.d.ts.map +1 -0
  72. package/lib/typescript/module/src/components/nativeTypes.d.ts +2 -1
  73. package/lib/typescript/module/src/components/nativeTypes.d.ts.map +1 -1
  74. package/lib/typescript/module/src/components/theme/defaultStrings.d.ts +1 -0
  75. package/lib/typescript/module/src/components/theme/defaultStrings.d.ts.map +1 -1
  76. package/lib/typescript/module/src/components/time/TypedTime.d.ts +1 -1
  77. package/lib/typescript/module/src/components/time/TypedTime.d.ts.map +1 -1
  78. package/lib/typescript/module/src/components/types.d.ts +41 -3
  79. package/lib/typescript/module/src/components/types.d.ts.map +1 -1
  80. package/lib/typescript/module/src/core/draft.d.ts +2 -1
  81. package/lib/typescript/module/src/core/draft.d.ts.map +1 -1
  82. package/lib/typescript/module/src/index.d.ts +1 -1
  83. package/lib/typescript/module/src/index.d.ts.map +1 -1
  84. package/package.json +1 -1
  85. package/src/components/DateTimePicker.tsx +67 -20
  86. package/src/components/container/PickerContainer.tsx +1 -0
  87. package/src/components/container/PickerLayout.tsx +10 -1
  88. package/src/components/field/KeyboardAccessoryBar.tsx +38 -0
  89. package/src/components/field/SegmentedInput.tsx +12 -7
  90. package/src/components/hooks/useScrollToTime.ts +99 -0
  91. package/src/components/nativeTypes.ts +2 -1
  92. package/src/components/theme/defaultStrings.ts +1 -0
  93. package/src/components/time/TypedTime.tsx +31 -10
  94. package/src/components/types.ts +45 -3
  95. package/src/core/draft.ts +5 -2
  96. package/src/index.tsx +1 -0
@@ -1,8 +1,9 @@
1
1
  import type React from 'react';
2
- import type { StyleProp, TextStyle } from 'react-native';
2
+ import type { ScrollViewProps, StyleProp, TextStyle } from 'react-native';
3
3
  import type { CalendarSystem } from '../core/calendarSystem';
4
4
  import type { Constraints, TimeBounds } from '../core/constraints';
5
5
  import type { Numerals } from '../core/numerals';
6
+ import type { ScrollViewRef } from './nativeTypes';
6
7
  import type {
7
8
  CalendarDate,
8
9
  PickerType,
@@ -130,8 +131,29 @@ export interface SheetOptions {
130
131
  fieldPlaceholder?: string;
131
132
  /** The calendar icon at the end of that field, as on the on-screen field. Default false. */
132
133
  fieldIcon?: boolean;
134
+ /**
135
+ * Passed to the sheet body's ScrollView, over the picker's own defaults, e.g.
136
+ * `{ showsVerticalScrollIndicator: true, persistentScrollbar: true }` to keep
137
+ * the scrollbar showing on Android (iOS shows it only while scrolling).
138
+ * Applies to the built-in sheet and to `renderSheet`.
139
+ */
140
+ scrollProps?: SheetScrollProps;
141
+ /**
142
+ * Date-time sheets: once a calendar tap picks the date (a range's end, a
143
+ * multiple picker's first date), the body scrolls the time section into view
144
+ * when it doesn't show in full. true: just far enough to show it; 'end': to
145
+ * the end of the body; false: no scroll. Default true. Applies to the
146
+ * built-in sheet and to `renderSheet`.
147
+ */
148
+ scrollToTime?: boolean | 'end';
133
149
  }
134
150
 
151
+ /** ScrollView props a sheet's body takes (`sheet.scrollProps`). */
152
+ export type SheetScrollProps = Omit<
153
+ ScrollViewProps,
154
+ 'children' | 'style' | 'testID'
155
+ >;
156
+
135
157
  /**
136
158
  * The second argument of `onChange` when the picker can show a Hijri calendar:
137
159
  * the calendar the date was picked in. The value itself is always Gregorian.
@@ -243,6 +265,13 @@ export interface DateTimePickerProps {
243
265
 
244
266
  // presentation
245
267
  presentation?: 'sheet' | 'inline';
268
+ /**
269
+ * Inline date-time pickers: your ScrollView around the picker. Once a
270
+ * calendar tap picks the date, it scrolls the time section into view, as
271
+ * `sheet.scrollToTime: true` does in the sheet. Without it an inline picker
272
+ * never scrolls.
273
+ */
274
+ scrollToTimeRef?: React.RefObject<ScrollViewRef | null>;
246
275
  visible?: boolean;
247
276
  onOpen?: () => void;
248
277
  onClose?: () => void;
@@ -359,6 +388,14 @@ export interface DateTimePickerProps {
359
388
  hijriLocale?: string;
360
389
  /** The tab a dual calendar opens on, each time it opens. Default 'gregory'. */
361
390
  dualDefaultTab?: 'gregory' | 'hijri';
391
+ /**
392
+ * How the on-screen field writes the saved value. 'picked' (default): in the
393
+ * calendar it was picked in, so a Hijri pick shows Hijri text, digits and
394
+ * AM / PM. 'gregory': always in `dateFormat`, with `strings` and the
395
+ * Gregorian digits. The field inside the sheet and the time rows still
396
+ * follow the tab.
397
+ */
398
+ fieldCalendar?: 'picked' | 'gregory';
362
399
  /** Replaces the built-in calendar switch. */
363
400
  renderCalendarSwitch?: (p: CalendarSwitchRenderProps) => React.ReactNode;
364
401
  /** Any BCP-47 tag; decides names, the date order and the clock. Default: the device locale. */
@@ -380,8 +417,13 @@ export interface DateTimePickerProps {
380
417
  /** Default: from `locale`, else '12h'. */
381
418
  timeFormat?: TimeFormat;
382
419
  minuteStep?: number;
383
- /** A newly picked day always gets this time (over a time typed first and over the current time). */
384
- newDayTime?: Time;
420
+ /**
421
+ * The time a newly picked day gets (a saved time is kept). 'now' (default):
422
+ * the current time. A `Time`: always that time, over a time typed first.
423
+ * 'empty': none; the time boxes stay empty and Confirm (and 'instant'
424
+ * saving) waits until the user enters the time.
425
+ */
426
+ newDayTime?: Time | 'now' | 'empty';
385
427
  /**
386
428
  * Shows each time row's picked day under its label ('Start time',
387
429
  * 10-03-2026), as the field writes it. Nothing shows until the day is
package/src/core/draft.ts CHANGED
@@ -53,7 +53,8 @@ export interface DraftOptions {
53
53
  zone: string;
54
54
  /** Turns saved strings into values and back. */
55
55
  adapter: ValueAdapter;
56
- defaultTime?: Time;
56
+ /** Time for a newly picked day when none is given; null leaves it empty. Default DEFAULT_TIME. */
57
+ defaultTime?: Time | null;
57
58
  multiple?: {
58
59
  timeMode?: 'shared' | 'perDate';
59
60
  maxSelections?: number;
@@ -157,7 +158,9 @@ const timeForNewDay = (
157
158
  newDayTime?: Time | null
158
159
  ): Time | null => {
159
160
  if (opts.type !== 'datetime') return null;
160
- return existing ?? newDayTime ?? opts.defaultTime ?? DEFAULT_TIME;
161
+ const fallback =
162
+ opts.defaultTime === undefined ? DEFAULT_TIME : opts.defaultTime;
163
+ return existing ?? newDayTime ?? fallback;
161
164
  };
162
165
 
163
166
  const withDay = (
package/src/index.tsx CHANGED
@@ -68,6 +68,7 @@ export type {
68
68
  PickerState,
69
69
  SheetOptions,
70
70
  SheetRenderProps,
71
+ SheetScrollProps,
71
72
  SheetSize,
72
73
  Slot,
73
74
  TimeLabelRenderProps,