react-native-paper-dates 0.11.15 → 0.14.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 (108) hide show
  1. package/lib/commonjs/Date/CalendarEdit.js +8 -4
  2. package/lib/commonjs/Date/CalendarEdit.js.map +1 -1
  3. package/lib/commonjs/Date/DatePickerInput.js +4 -2
  4. package/lib/commonjs/Date/DatePickerInput.js.map +1 -1
  5. package/lib/commonjs/Date/DatePickerInput.shared.js.map +1 -1
  6. package/lib/commonjs/Date/DatePickerInputWithoutModal.js +14 -1
  7. package/lib/commonjs/Date/DatePickerInputWithoutModal.js.map +1 -1
  8. package/lib/commonjs/Date/DatePickerModal.js +2 -0
  9. package/lib/commonjs/Date/DatePickerModal.js.map +1 -1
  10. package/lib/commonjs/Date/DatePickerModalContent.js +4 -2
  11. package/lib/commonjs/Date/DatePickerModalContent.js.map +1 -1
  12. package/lib/commonjs/Date/DatePickerModalContentHeader.js +6 -4
  13. package/lib/commonjs/Date/DatePickerModalContentHeader.js.map +1 -1
  14. package/lib/commonjs/Date/Swiper.js +6 -4
  15. package/lib/commonjs/Date/Swiper.js.map +1 -1
  16. package/lib/commonjs/Date/Swiper.native.js +2 -1
  17. package/lib/commonjs/Date/Swiper.native.js.map +1 -1
  18. package/lib/commonjs/Date/YearPicker.js +3 -0
  19. package/lib/commonjs/Date/YearPicker.js.map +1 -1
  20. package/lib/commonjs/TextInputMask.js +2 -0
  21. package/lib/commonjs/TextInputMask.js.map +1 -1
  22. package/lib/commonjs/Time/AnalogClock.js +7 -3
  23. package/lib/commonjs/Time/AnalogClock.js.map +1 -1
  24. package/lib/commonjs/Time/AnalogClockHours.js +4 -9
  25. package/lib/commonjs/Time/AnalogClockHours.js.map +1 -1
  26. package/lib/commonjs/Time/TimeInput.js +2 -1
  27. package/lib/commonjs/Time/TimeInput.js.map +1 -1
  28. package/lib/commonjs/Time/TimeInputs.js +4 -1
  29. package/lib/commonjs/Time/TimeInputs.js.map +1 -1
  30. package/lib/commonjs/Time/TimePicker.js +9 -2
  31. package/lib/commonjs/Time/TimePicker.js.map +1 -1
  32. package/lib/commonjs/Time/TimePickerModal.js +5 -1
  33. package/lib/commonjs/Time/TimePickerModal.js.map +1 -1
  34. package/lib/commonjs/index.js +9 -0
  35. package/lib/commonjs/index.js.map +1 -1
  36. package/lib/commonjs/translations/he.js +25 -0
  37. package/lib/commonjs/translations/he.js.map +1 -0
  38. package/lib/module/Date/CalendarEdit.js +8 -4
  39. package/lib/module/Date/CalendarEdit.js.map +1 -1
  40. package/lib/module/Date/DatePickerInput.js +4 -2
  41. package/lib/module/Date/DatePickerInput.js.map +1 -1
  42. package/lib/module/Date/DatePickerInput.shared.js.map +1 -1
  43. package/lib/module/Date/DatePickerInputWithoutModal.js +14 -1
  44. package/lib/module/Date/DatePickerInputWithoutModal.js.map +1 -1
  45. package/lib/module/Date/DatePickerModal.js +2 -0
  46. package/lib/module/Date/DatePickerModal.js.map +1 -1
  47. package/lib/module/Date/DatePickerModalContent.js +4 -2
  48. package/lib/module/Date/DatePickerModalContent.js.map +1 -1
  49. package/lib/module/Date/DatePickerModalContentHeader.js +6 -4
  50. package/lib/module/Date/DatePickerModalContentHeader.js.map +1 -1
  51. package/lib/module/Date/Swiper.js +6 -4
  52. package/lib/module/Date/Swiper.js.map +1 -1
  53. package/lib/module/Date/Swiper.native.js +2 -1
  54. package/lib/module/Date/Swiper.native.js.map +1 -1
  55. package/lib/module/Date/YearPicker.js +4 -1
  56. package/lib/module/Date/YearPicker.js.map +1 -1
  57. package/lib/module/TextInputMask.js +2 -0
  58. package/lib/module/TextInputMask.js.map +1 -1
  59. package/lib/module/Time/AnalogClock.js +7 -3
  60. package/lib/module/Time/AnalogClock.js.map +1 -1
  61. package/lib/module/Time/AnalogClockHours.js +4 -8
  62. package/lib/module/Time/AnalogClockHours.js.map +1 -1
  63. package/lib/module/Time/TimeInput.js +2 -1
  64. package/lib/module/Time/TimeInput.js.map +1 -1
  65. package/lib/module/Time/TimeInputs.js +4 -1
  66. package/lib/module/Time/TimeInputs.js.map +1 -1
  67. package/lib/module/Time/TimePicker.js +9 -2
  68. package/lib/module/Time/TimePicker.js.map +1 -1
  69. package/lib/module/Time/TimePickerModal.js +5 -1
  70. package/lib/module/Time/TimePickerModal.js.map +1 -1
  71. package/lib/module/index.js +1 -0
  72. package/lib/module/index.js.map +1 -1
  73. package/lib/module/translations/he.js +18 -0
  74. package/lib/module/translations/he.js.map +1 -0
  75. package/lib/typescript/Date/CalendarEdit.d.ts +2 -1
  76. package/lib/typescript/Date/DatePickerInput.d.ts +1 -1
  77. package/lib/typescript/Date/DatePickerInput.shared.d.ts +2 -1
  78. package/lib/typescript/Date/DatePickerInputWithoutModal.d.ts +8 -7
  79. package/lib/typescript/Date/DatePickerModal.d.ts +1 -0
  80. package/lib/typescript/Date/DatePickerModalContent.d.ts +1 -0
  81. package/lib/typescript/Date/DatePickerModalContentHeader.d.ts +2 -0
  82. package/lib/typescript/TextInputMask.d.ts +5 -6
  83. package/lib/typescript/Time/TimeInput.d.ts +1 -0
  84. package/lib/typescript/Time/TimeInputs.d.ts +2 -1
  85. package/lib/typescript/Time/TimePicker.d.ts +3 -1
  86. package/lib/typescript/Time/TimePickerModal.d.ts +3 -1
  87. package/lib/typescript/index.d.ts +1 -0
  88. package/lib/typescript/translations/he.d.ts +3 -0
  89. package/package.json +26 -25
  90. package/src/Date/CalendarEdit.tsx +5 -0
  91. package/src/Date/DatePickerInput.shared.tsx +2 -1
  92. package/src/Date/DatePickerInput.tsx +2 -0
  93. package/src/Date/DatePickerInputWithoutModal.tsx +14 -0
  94. package/src/Date/DatePickerModal.tsx +3 -0
  95. package/src/Date/DatePickerModalContent.tsx +3 -0
  96. package/src/Date/DatePickerModalContentHeader.tsx +9 -3
  97. package/src/Date/Swiper.native.tsx +1 -0
  98. package/src/Date/Swiper.tsx +3 -1
  99. package/src/Date/YearPicker.tsx +4 -1
  100. package/src/TextInputMask.tsx +2 -0
  101. package/src/Time/AnalogClock.tsx +7 -6
  102. package/src/Time/AnalogClockHours.tsx +10 -6
  103. package/src/Time/TimeInput.tsx +3 -1
  104. package/src/Time/TimeInputs.tsx +4 -0
  105. package/src/Time/TimePicker.tsx +9 -1
  106. package/src/Time/TimePickerModal.tsx +6 -0
  107. package/src/index.tsx +1 -0
  108. package/src/translations/he.ts +21 -0
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- export declare function TimePickerModal({ visible, onDismiss, onConfirm, hours, minutes, label, uppercase, cancelLabel, confirmLabel, animationType, locale, keyboardIcon, clockIcon, }: {
2
+ export declare function TimePickerModal({ visible, onDismiss, onConfirm, hours, minutes, label, uppercase, cancelLabel, confirmLabel, animationType, locale, keyboardIcon, clockIcon, use24HourClock, inputFontSize, }: {
3
3
  locale?: undefined | string;
4
4
  label?: string;
5
5
  uppercase?: boolean;
@@ -16,6 +16,8 @@ export declare function TimePickerModal({ visible, onDismiss, onConfirm, hours,
16
16
  animationType?: 'slide' | 'fade' | 'none';
17
17
  keyboardIcon?: string;
18
18
  clockIcon?: string;
19
+ use24HourClock?: boolean;
20
+ inputFontSize?: number;
19
21
  }): JSX.Element;
20
22
  declare const _default: React.MemoExoticComponent<typeof TimePickerModal>;
21
23
  export default _default;
@@ -13,6 +13,7 @@ export { default as en } from './translations/en';
13
13
  export { default as enGB } from './translations/enGB';
14
14
  export { default as es } from './translations/es';
15
15
  export { default as fr } from './translations/fr';
16
+ export { default as he } from './translations/he';
16
17
  export { default as it } from './translations/it';
17
18
  export { default as ko } from './translations/ko';
18
19
  export { default as nl } from './translations/nl';
@@ -0,0 +1,3 @@
1
+ import type { TranslationsType } from './utils';
2
+ declare const he: TranslationsType;
3
+ export default he;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-paper-dates",
3
- "version": "0.11.15",
3
+ "version": "0.14.0",
4
4
  "description": "Performant Date Picker for React Native Paper",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
@@ -50,37 +50,37 @@
50
50
  "registry": "https://registry.npmjs.org/"
51
51
  },
52
52
  "devDependencies": {
53
- "@commitlint/config-conventional": "^17.0.3",
54
- "@react-native-community/eslint-config": "^3.1.0",
55
- "@release-it/conventional-changelog": "^5.1.0",
56
- "@testing-library/jest-native": "^5.3.3",
57
- "@testing-library/react-native": "^11.5.0",
53
+ "@commitlint/config-conventional": "^17.4.4",
54
+ "@react-native-community/eslint-config": "^3.2.0",
55
+ "@release-it/conventional-changelog": "^5.1.1",
56
+ "@testing-library/jest-native": "^5.4.2",
57
+ "@testing-library/react-native": "^11.5.2",
58
58
  "@types/color": "^3.0.3",
59
- "@types/jest": "^29.2.4",
60
- "@types/react": "^18.0.26",
61
- "@types/react-native": "^0.70.8",
62
- "@types/react-native-vector-icons": "^6.4.12",
63
- "babel-loader": "^8.2.5",
64
- "commitlint": "^17.0.3",
65
- "eslint": "^8.22.0",
66
- "eslint-config-prettier": "^8.5.0",
59
+ "@types/jest": "^29.4.0",
60
+ "@types/react": "^18.0.28",
61
+ "@types/react-native": "^0.70.11",
62
+ "@types/react-native-vector-icons": "^6.4.13",
63
+ "babel-loader": "^8.3.0",
64
+ "commitlint": "^17.4.4",
65
+ "eslint": "^8.35.0",
66
+ "eslint-config-prettier": "^8.6.0",
67
67
  "eslint-plugin-prettier": "^4.2.1",
68
- "expo-cli": "^6.0.8",
69
- "husky": "^8.0.1",
70
- "jest": "^29.0.0",
68
+ "expo-cli": "^6.3.2",
69
+ "husky": "^8.0.3",
70
+ "jest": "^29.4.3",
71
71
  "pod-install": "^0.1.38",
72
- "prettier": "^2.7.1",
72
+ "prettier": "^2.8.4",
73
73
  "react": "^18.2.0",
74
- "react-native": "^0.70.6",
74
+ "react-native": "^0.70.7",
75
75
  "react-native-builder-bob": "^0.18.3",
76
- "react-native-paper": "^5.0.2",
77
- "react-native-safe-area-context": "^4.4.1",
76
+ "react-native-paper": "^5.2.0",
77
+ "react-native-safe-area-context": "^4.5.0",
78
78
  "react-native-vector-icons": "^9.2.0",
79
- "release-it": "^15.4.0",
80
- "typescript": "^4.9.4",
79
+ "release-it": "^15.7.0",
80
+ "typescript": "^4.9.5",
81
81
  "react-test-renderer": "^18.2.0",
82
82
  "@types/react-test-renderer": "^18.0.0",
83
- "caniuse-lite": "^1.0.30001383"
83
+ "caniuse-lite": "^1.0.30001458"
84
84
  },
85
85
  "peerDependencies": {
86
86
  "react": "*",
@@ -141,7 +141,8 @@
141
141
  "lib/",
142
142
  "example/node_modules",
143
143
  "example/web-build",
144
- "docusaurus"
144
+ "docusaurus",
145
+ "coverage"
145
146
  ],
146
147
  "prettier": {
147
148
  "quoteProps": "consistent",
@@ -21,6 +21,7 @@ function CalendarEdit({
21
21
  onChange,
22
22
  validRange,
23
23
  locale,
24
+ inputEnabled,
24
25
  }: {
25
26
  mode: ModeType
26
27
  label?: string
@@ -31,6 +32,7 @@ function CalendarEdit({
31
32
  onChange: (s: LocalState) => any
32
33
  validRange: ValidRangeType | undefined
33
34
  locale: string
35
+ inputEnabled?: boolean
34
36
  }) {
35
37
  const dateInput = React.useRef<TextInputNative | null>(null)
36
38
  const startInput = React.useRef<TextInputNative | null>(null)
@@ -88,6 +90,7 @@ function CalendarEdit({
88
90
  locale={locale}
89
91
  withModal={false}
90
92
  autoComplete={'off'}
93
+ inputEnabled={inputEnabled}
91
94
  />
92
95
  ) : null}
93
96
  {mode === 'range' ? (
@@ -104,6 +107,7 @@ function CalendarEdit({
104
107
  locale={locale}
105
108
  withModal={false}
106
109
  autoComplete={'off'}
110
+ inputEnabled={inputEnabled}
107
111
  />
108
112
  <View style={styles.separator} />
109
113
  <DatePickerInputWithoutModal
@@ -117,6 +121,7 @@ function CalendarEdit({
117
121
  locale={locale}
118
122
  withModal={false}
119
123
  autoComplete="off"
124
+ inputEnabled={inputEnabled}
120
125
  />
121
126
  </View>
122
127
  ) : null}
@@ -20,7 +20,8 @@ export type DatePickerInputProps = {
20
20
  startYear?: number
21
21
  endYear?: number
22
22
  onChangeText?: (text: string | undefined) => void
23
+ inputEnabled?: boolean
23
24
  } & Omit<
24
25
  React.ComponentProps<typeof TextInput>,
25
- 'value' | 'onChange' | 'onChangeText'
26
+ 'value' | 'onChange' | 'onChangeText' | 'inputMode'
26
27
  >
@@ -54,6 +54,7 @@ function DatePickerInput(
54
54
  uppercase,
55
55
  startYear,
56
56
  endYear,
57
+ inputEnabled,
57
58
  }) =>
58
59
  withModal ? (
59
60
  <DatePickerModal
@@ -70,6 +71,7 @@ function DatePickerInput(
70
71
  uppercase={uppercase ?? true}
71
72
  startYear={startYear ?? 1800}
72
73
  endYear={endYear ?? 2200}
74
+ inputEnabled={inputEnabled}
73
75
  />
74
76
  ) : null
75
77
  }
@@ -27,6 +27,7 @@ function DatePickerInputWithoutModal(
27
27
  startYear,
28
28
  endYear,
29
29
  onChangeText,
30
+ inputEnabled,
30
31
  ...rest
31
32
  }: DatePickerInputProps & {
32
33
  modal?: (params: {
@@ -39,6 +40,7 @@ function DatePickerInputWithoutModal(
39
40
  uppercase: DatePickerInputProps['uppercase']
40
41
  startYear: DatePickerInputProps['startYear']
41
42
  endYear: DatePickerInputProps['endYear']
43
+ inputEnabled: DatePickerInputProps['inputEnabled']
42
44
  }) => any
43
45
  inputButtons?: any
44
46
  },
@@ -59,6 +61,16 @@ function DatePickerInputWithoutModal(
59
61
  onValidationError,
60
62
  })
61
63
 
64
+ let disabled
65
+
66
+ if (inputEnabled !== undefined) {
67
+ disabled = !inputEnabled
68
+ }
69
+
70
+ if (rest.disabled) {
71
+ disabled = rest.disabled
72
+ }
73
+
62
74
  return (
63
75
  <>
64
76
  <View style={styles.root}>
@@ -75,6 +87,7 @@ function DatePickerInputWithoutModal(
75
87
  value={formattedValue}
76
88
  keyboardType={rest.keyboardType ?? 'number-pad'}
77
89
  mask={inputFormat}
90
+ disabled={disabled}
78
91
  onChangeText={onDateInputChangeText}
79
92
  onChange={(e) => onChangeText && onChangeText(e.nativeEvent.text)}
80
93
  keyboardAppearance={theme.dark ? 'dark' : 'default'}
@@ -99,6 +112,7 @@ function DatePickerInputWithoutModal(
99
112
  uppercase,
100
113
  startYear,
101
114
  endYear,
115
+ inputEnabled,
102
116
  })}
103
117
  </>
104
118
  )
@@ -22,6 +22,7 @@ interface DatePickerModalProps {
22
22
  animationType?: 'slide' | 'fade' | 'none'
23
23
  disableStatusBar?: boolean
24
24
  disableStatusBarPadding?: boolean
25
+ inputEnabled?: boolean
25
26
  }
26
27
 
27
28
  export interface DatePickerModalSingleProps
@@ -49,6 +50,7 @@ export function DatePickerModal(
49
50
  animationType,
50
51
  disableStatusBar,
51
52
  disableStatusBarPadding,
53
+ inputEnabled,
52
54
  ...rest
53
55
  } = props
54
56
  const animationTypeCalculated =
@@ -112,6 +114,7 @@ export function DatePickerModal(
112
114
  )}
113
115
  <DatePickerModalContent
114
116
  {...rest}
117
+ inputEnabled={inputEnabled}
115
118
  disableSafeTop={disableStatusBar}
116
119
  />
117
120
  </View>
@@ -32,6 +32,7 @@ interface DatePickerModalContentBaseProps {
32
32
  disableSafeTop?: boolean
33
33
  saveLabelDisabled?: boolean
34
34
  uppercase?: boolean
35
+ inputEnabled?: boolean
35
36
  }
36
37
 
37
38
  export interface DatePickerModalContentRangeProps
@@ -164,6 +165,7 @@ export function DatePickerModalContent(
164
165
  locale={locale}
165
166
  editIcon={props?.editIcon}
166
167
  calendarIcon={props.calendarIcon}
168
+ allowEditing={props.allowEditing || true}
167
169
  />
168
170
  </DatePickerModalHeaderBackground>
169
171
  <AnimatedCrossView
@@ -195,6 +197,7 @@ export function DatePickerModalContent(
195
197
  onChange={onInnerChange}
196
198
  validRange={validRange}
197
199
  locale={locale}
200
+ inputEnabled={props.inputEnabled}
198
201
  />
199
202
  }
200
203
  />
@@ -19,6 +19,7 @@ export interface HeaderPickProps {
19
19
  editIcon?: string
20
20
  calendarIcon?: string
21
21
  closeIcon?: string
22
+ allowEditing?: boolean
22
23
  }
23
24
 
24
25
  export interface HeaderContentProps extends HeaderPickProps {
@@ -27,6 +28,7 @@ export interface HeaderContentProps extends HeaderPickProps {
27
28
  collapsed: boolean
28
29
  onToggle: () => any
29
30
  locale: string | undefined
31
+ inputDate?: boolean
30
32
  }
31
33
 
32
34
  function getLabel(
@@ -60,15 +62,19 @@ export default function DatePickerModalContentHeader(
60
62
  uppercase,
61
63
  editIcon,
62
64
  calendarIcon,
65
+ inputDate,
66
+ allowEditing,
63
67
  } = props
64
68
  const theme = useTheme()
65
69
  const label = getLabel(props.locale, props.mode, props.label)
66
70
 
67
71
  const color = useHeaderTextColor()
72
+
73
+ const isAllowEditing = allowEditing && mode !== 'multiple' && inputDate !== undefined
74
+
68
75
  const supportingTextColor = theme.isV3 ? theme.colors.onSurfaceVariant : color
69
- const allowEditing = mode !== 'multiple'
70
76
 
71
- let textFont = theme?.isV3
77
+ const textFont = theme?.isV3
72
78
  ? theme.fonts.labelMedium
73
79
  : (theme as any as MD2Theme).fonts.medium
74
80
 
@@ -97,7 +103,7 @@ export default function DatePickerModalContentHeader(
97
103
  </View>
98
104
  </View>
99
105
  <View style={styles.fill} />
100
- {allowEditing ? (
106
+ {isAllowEditing ? (
101
107
  <IconButton
102
108
  icon={
103
109
  collapsed
@@ -175,6 +175,7 @@ function SwiperInner({
175
175
  ? new Array(visibleIndexes.length).fill(undefined).map((_, vi) => (
176
176
  <View
177
177
  key={vi}
178
+ // eslint-disable-next-line react-native/no-inline-styles
178
179
  style={{
179
180
  top: isHorizontal
180
181
  ? 0
@@ -94,7 +94,6 @@ function VerticalScroller({
94
94
  const [visibleIndexes, setVisibleIndexes] = React.useState<number[]>(
95
95
  visibleArray(initialIndex)
96
96
  )
97
- // eslint-disable-next-line no-undef
98
97
  const parentRef = React.useRef<HTMLDivElement | null>(null)
99
98
 
100
99
  useIsomorphicLayoutEffect(() => {
@@ -132,6 +131,7 @@ function VerticalScroller({
132
131
  return (
133
132
  <div
134
133
  ref={parentRef}
134
+ // eslint-disable-next-line react-native/no-inline-styles
135
135
  style={{
136
136
  height,
137
137
  width,
@@ -140,6 +140,7 @@ function VerticalScroller({
140
140
  onScroll={onScroll}
141
141
  >
142
142
  <div
143
+ // eslint-disable-next-line react-native/no-inline-styles
143
144
  style={{
144
145
  height: estimatedHeight * totalMonths,
145
146
  position: 'relative',
@@ -148,6 +149,7 @@ function VerticalScroller({
148
149
  {[0, 1, 2, 3, 4].map((vi) => (
149
150
  <div
150
151
  key={vi}
152
+ // eslint-disable-next-line react-native/no-inline-styles
151
153
  style={{
152
154
  willChange: 'transform',
153
155
  transform: `translateY(${getVerticalMonthsOffset(
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react'
2
- import { FlatList, StyleSheet, View } from 'react-native'
2
+ import { FlatList, StyleSheet, View, ScrollView } from 'react-native'
3
3
  import { MD2Theme, Text, TouchableRipple, useTheme } from 'react-native-paper'
4
4
  import { range } from '../utils'
5
5
 
@@ -50,6 +50,9 @@ export default function YearPicker({
50
50
  ref={flatList}
51
51
  style={styles.list}
52
52
  data={years}
53
+ renderScrollComponent={(sProps) => {
54
+ return <ScrollView {...sProps} />
55
+ }}
53
56
  renderItem={({ item }) => (
54
57
  <Year
55
58
  year={item}
@@ -72,6 +72,7 @@ function TextInputWithMask(
72
72
  onChange,
73
73
  value,
74
74
  mask,
75
+ disabled,
75
76
  ...rest
76
77
  }: React.ComponentProps<typeof TextInput> & { mask: string; value: string },
77
78
  ref: any
@@ -100,6 +101,7 @@ function TextInputWithMask(
100
101
  <TextInput
101
102
  ref={ref}
102
103
  {...rest}
104
+ disabled={disabled}
103
105
  value={controlledValue}
104
106
  onChangeText={onInnerChange}
105
107
  onChange={(e) => {
@@ -43,7 +43,7 @@ function AnalogClock({
43
43
  const theme = useTheme()
44
44
  const { mode } = React.useContext(DisplayModeContext)
45
45
  // used to make pointer shorter if hours are selected and above 12
46
- const shortPointer = (hours === 0 || hours > 12) && is24Hour
46
+ const shortPointer = hours >= 12 && is24Hour
47
47
  const clockRef = React.useRef<View | null>(null)
48
48
  // Hooks are nice, sometimes... :-)..
49
49
  // We need the latest values, since the onPointerMove uses a closure to the function
@@ -74,17 +74,18 @@ function AnalogClock({
74
74
  if (hours12AndPm || hours24AndPM) {
75
75
  pickedHours += 12
76
76
  }
77
- if (modeRef.current === 'AM' && pickedHours === 12) {
77
+ if ((modeRef.current === 'AM' || hours24) && pickedHours === 12) {
78
78
  pickedHours = 0
79
79
  }
80
80
 
81
- if (
82
- (!hours24 && modeRef.current === 'AM' && pickedHours === 12) ||
83
- pickedHours === 24
84
- ) {
81
+ if (!hours24 && modeRef.current === 'AM' && pickedHours === 12) {
85
82
  pickedHours = 0
86
83
  }
87
84
 
85
+ if (pickedHours === 24) {
86
+ pickedHours = 12
87
+ }
88
+
88
89
  if (hoursRef.current !== pickedHours || final) {
89
90
  onChangeRef.current({
90
91
  hours: pickedHours,
@@ -3,7 +3,6 @@ import { View, StyleSheet } from 'react-native'
3
3
  import { Text } from 'react-native-paper'
4
4
  import { circleSize } from './timeUtils'
5
5
  import { useTextColorOnPrimary } from '../utils'
6
- import { DisplayModeContext } from './TimePicker'
7
6
 
8
7
  function AnalogClockHours({
9
8
  is24Hour,
@@ -12,7 +11,6 @@ function AnalogClockHours({
12
11
  is24Hour: boolean
13
12
  hours: number
14
13
  }) {
15
- const { mode } = React.useContext(DisplayModeContext)
16
14
  const outerRange = getHourNumbers(false, circleSize, 12, 12)
17
15
  const innerRange = getHourNumbers(true, circleSize, 12, 12)
18
16
  const color = useTextColorOnPrimary()
@@ -34,11 +32,17 @@ function AnalogClockHours({
34
32
  <View style={styles.outerHourInner}>
35
33
  {/* Display 00 instead of 12 for AM hours */}
36
34
  <Text
37
- style={hours === i + 1 ? { color } : null}
35
+ style={
36
+ (!is24Hour && i + 1 === hours) ||
37
+ (hours === i + 1 && hours !== 12) ||
38
+ (i + 1 === 12 && hours === 0)
39
+ ? { color }
40
+ : null
41
+ }
38
42
  variant="bodyLarge"
39
43
  selectable={false}
40
44
  >
41
- {mode === 'AM' && is24Hour && i + 1 === 12 ? '00' : i + 1}
45
+ {is24Hour && i + 1 === 12 ? '00' : i + 1}
42
46
  </Text>
43
47
  </View>
44
48
  </View>
@@ -60,13 +64,13 @@ function AnalogClockHours({
60
64
  <Text
61
65
  selectable={false}
62
66
  style={[
63
- i + 13 === hours || (i + 13 === 24 && hours === 0)
67
+ i + 13 === hours || (i + 13 === 24 && hours === 12)
64
68
  ? { color }
65
69
  : null,
66
70
  ]}
67
71
  variant="bodyLarge"
68
72
  >
69
- {i + 13 === 24 ? '00' : i + 13}
73
+ {i + 13 === 24 ? '12' : i + 13}
70
74
  </Text>
71
75
  </View>
72
76
  </View>
@@ -24,6 +24,7 @@ interface TimeInputProps
24
24
  pressed: boolean
25
25
  onChanged: (n: number) => any
26
26
  inputType: PossibleInputTypes
27
+ inputFontSize?: number
27
28
  }
28
29
 
29
30
  function TimeInput(
@@ -34,6 +35,7 @@ function TimeInput(
34
35
  onPress,
35
36
  onChanged,
36
37
  inputType,
38
+ inputFontSize = 57,
37
39
  ...rest
38
40
  }: TimeInputProps,
39
41
  ref: any
@@ -77,6 +79,7 @@ function TimeInput(
77
79
  // eslint-disable-next-line react-native/no-inline-styles
78
80
  {
79
81
  color,
82
+ fontSize: inputFontSize,
80
83
  backgroundColor,
81
84
  borderRadius: theme.roundness * 2,
82
85
  borderColor:
@@ -123,7 +126,6 @@ function TimeInput(
123
126
  const styles = StyleSheet.create({
124
127
  root: { position: 'relative', height: 80, width: 96 },
125
128
  input: {
126
- fontSize: 57,
127
129
  textAlign: 'center',
128
130
  textAlignVertical: 'center',
129
131
  width: 96,
@@ -27,6 +27,7 @@ function TimeInputs({
27
27
  inputType,
28
28
  onChange,
29
29
  is24Hour,
30
+ inputFontSize,
30
31
  }: {
31
32
  inputType: PossibleInputTypes
32
33
  focused: PossibleClockTypes
@@ -39,6 +40,7 @@ function TimeInputs({
39
40
  focused?: undefined | PossibleClockTypes
40
41
  }) => any
41
42
  is24Hour: boolean
43
+ inputFontSize?: number
42
44
  }) {
43
45
  const startInput = React.useRef<TextInputNative | null>(null)
44
46
  const endInput = React.useRef<TextInputNative | null>(null)
@@ -78,6 +80,7 @@ function TimeInputs({
78
80
  <View style={styles.column}>
79
81
  <TimeInput
80
82
  ref={startInput}
83
+ inputFontSize={inputFontSize}
81
84
  placeholder={'00'}
82
85
  value={toHourInputFormat(hours, is24Hour)}
83
86
  clockType={clockTypes.hours}
@@ -145,6 +148,7 @@ function TimeInputs({
145
148
  <View style={styles.column}>
146
149
  <TimeInput
147
150
  ref={endInput}
151
+ inputFontSize={inputFontSize}
148
152
  placeholder={'00'}
149
153
  value={minutes}
150
154
  clockType={clockTypes.minutes}
@@ -36,6 +36,8 @@ function TimePicker({
36
36
  inputType,
37
37
  onChange,
38
38
  locale,
39
+ use24HourClock,
40
+ inputFontSize,
39
41
  }: {
40
42
  locale?: undefined | string
41
43
  inputType: PossibleInputTypes
@@ -44,6 +46,8 @@ function TimePicker({
44
46
  minutes: number
45
47
  onFocusInput: (type: PossibleClockTypes) => any
46
48
  onChange: onChangeFunc
49
+ use24HourClock?: boolean
50
+ inputFontSize?: number
47
51
  }) {
48
52
  const [displayMode, setDisplayMode] = React.useState<'AM' | 'PM' | undefined>(
49
53
  undefined
@@ -53,6 +57,9 @@ function TimePicker({
53
57
 
54
58
  // method to check whether we have 24 hours in clock or 12
55
59
  const is24Hour = React.useMemo(() => {
60
+ if (use24HourClock !== undefined) {
61
+ return use24HourClock
62
+ }
56
63
  const formatter = new Intl.DateTimeFormat(locale, {
57
64
  hour: '2-digit',
58
65
  minute: '2-digit',
@@ -60,7 +67,7 @@ function TimePicker({
60
67
  })
61
68
  const formatted = formatter.format(new Date(Date.UTC(2020, 1, 1, 23)))
62
69
  return formatted.includes('23')
63
- }, [locale])
70
+ }, [locale, use24HourClock])
64
71
 
65
72
  // Initialize display Mode according the hours value
66
73
  React.useEffect(() => {
@@ -104,6 +111,7 @@ function TimePicker({
104
111
  >
105
112
  <TimeInputs
106
113
  inputType={inputType}
114
+ inputFontSize={inputFontSize}
107
115
  hours={hours}
108
116
  minutes={minutes}
109
117
  is24Hour={is24Hour}
@@ -55,6 +55,8 @@ export function TimePickerModal({
55
55
  locale,
56
56
  keyboardIcon = 'keyboard-outline',
57
57
  clockIcon = 'clock-outline',
58
+ use24HourClock,
59
+ inputFontSize,
58
60
  }: {
59
61
  locale?: undefined | string
60
62
  label?: string
@@ -69,6 +71,8 @@ export function TimePickerModal({
69
71
  animationType?: 'slide' | 'fade' | 'none'
70
72
  keyboardIcon?: string
71
73
  clockIcon?: string
74
+ use24HourClock?: boolean
75
+ inputFontSize?: number
72
76
  }) {
73
77
  const theme = useTheme()
74
78
 
@@ -188,6 +192,8 @@ export function TimePickerModal({
188
192
  <TimePicker
189
193
  locale={locale}
190
194
  inputType={inputType}
195
+ use24HourClock={use24HourClock}
196
+ inputFontSize={inputFontSize}
191
197
  focused={focused}
192
198
  hours={localHours}
193
199
  minutes={localMinutes}
package/src/index.tsx CHANGED
@@ -14,6 +14,7 @@ export { default as en } from './translations/en'
14
14
  export { default as enGB } from './translations/enGB'
15
15
  export { default as es } from './translations/es'
16
16
  export { default as fr } from './translations/fr'
17
+ export { default as he } from './translations/he'
17
18
  export { default as it } from './translations/it'
18
19
  export { default as ko } from './translations/ko'
19
20
  export { default as nl } from './translations/nl'
@@ -0,0 +1,21 @@
1
+ import type { TranslationsType } from './utils'
2
+
3
+ const he: TranslationsType = {
4
+ save: 'שמור',
5
+ selectSingle: 'בחר תאריך',
6
+ selectMultiple: 'בחר תאריכים',
7
+ selectRange: 'בחר טווח',
8
+ notAccordingToDateFormat: (inputFormat) =>
9
+ `פורמט של תאריך צריך להיות ${inputFormat}`,
10
+ mustBeHigherThan: (date) => `חייב להיות אחרי ${date}`,
11
+ mustBeLowerThan: (date) => `חייב להיות לפני ${date}`,
12
+ mustBeBetween: (startDate, endDate) =>
13
+ `חייב להיות בין ${startDate} - ${endDate}`,
14
+ dateIsDisabled: 'יום לא מורשה',
15
+ previous: 'הקודם',
16
+ next: 'הבא',
17
+ typeInDate: 'הקש תאריך',
18
+ pickDateFromCalendar: 'בחר תאריך מהלוח שנה',
19
+ close: 'סגור',
20
+ }
21
+ export default he