Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docusaurus/docs/date-picker/input-date-picker.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,8 @@ The start year when the component is rendered. Defaults to `1800`.
`Type: number | undefined`
The end year when the component is rendered. Defaults to `2200`.

**inputEnabled**
`Type: boolean | undefined`
Flag indicating if the component should be enabled or not. Behavior similarly to `disabled`. Defaults to `true`.

* Other [react-native TextInput props](https://reactnative.dev/docs/textinput#props).*
4 changes: 4 additions & 0 deletions docusaurus/docs/date-picker/range-date-picker.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,3 +145,7 @@ The edit icon used to toggle between calendar and input. Defaults to `pencil`. Y
**calendarIcon**
`Type: string | undefined`
The edit icon used to toggle between input and calendar. Defaults to `calendar`. You can pass the name of an icon from [MaterialCommunityIcons](https://materialdesignicons.com/).

**inputEnabled**
`Type: boolean | undefined`
Flag indicating if the component should be enabled or not. Defaults to `true`.
4 changes: 4 additions & 0 deletions docusaurus/docs/date-picker/single-date-picker.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,7 @@ The edit icon used to toggle between calendar and input. Defaults to `pencil`. Y
**calendarIcon**
`Type: string | undefined`
The edit icon used to toggle between input and calendar. Defaults to `calendar`. You can pass the name of an icon from [MaterialCommunityIcons](https://materialdesignicons.com/).

**inputEnabled**
`Type: boolean | undefined`
Flag indicating if the component should be enabled or not. Defaults to `true`.
5 changes: 5 additions & 0 deletions src/Date/CalendarEdit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ function CalendarEdit({
onChange,
validRange,
locale,
inputEnabled,
}: {
mode: ModeType
label?: string
Expand All @@ -31,6 +32,7 @@ function CalendarEdit({
onChange: (s: LocalState) => any
validRange: ValidRangeType | undefined
locale: string
inputEnabled?: boolean
}) {
const dateInput = React.useRef<TextInputNative | null>(null)
const startInput = React.useRef<TextInputNative | null>(null)
Expand Down Expand Up @@ -88,6 +90,7 @@ function CalendarEdit({
locale={locale}
withModal={false}
autoComplete={'off'}
inputEnabled={inputEnabled}
/>
) : null}
{mode === 'range' ? (
Expand All @@ -104,6 +107,7 @@ function CalendarEdit({
locale={locale}
withModal={false}
autoComplete={'off'}
inputEnabled={inputEnabled}
/>
<View style={styles.separator} />
<DatePickerInputWithoutModal
Expand All @@ -117,6 +121,7 @@ function CalendarEdit({
locale={locale}
withModal={false}
autoComplete="off"
inputEnabled={inputEnabled}
/>
</View>
) : null}
Expand Down
1 change: 1 addition & 0 deletions src/Date/DatePickerInput.shared.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export type DatePickerInputProps = {
startYear?: number
endYear?: number
onChangeText?: (text: string | undefined) => void
inputEnabled?: boolean
} & Omit<
React.ComponentProps<typeof TextInput>,
'value' | 'onChange' | 'onChangeText'
Expand Down
2 changes: 2 additions & 0 deletions src/Date/DatePickerInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ function DatePickerInput(
uppercase,
startYear,
endYear,
inputEnabled,
}) =>
withModal ? (
<DatePickerModal
Expand All @@ -70,6 +71,7 @@ function DatePickerInput(
uppercase={uppercase ?? true}
startYear={startYear ?? 1800}
endYear={endYear ?? 2200}
inputEnabled={inputEnabled}
/>
) : null
}
Expand Down
14 changes: 14 additions & 0 deletions src/Date/DatePickerInputWithoutModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ function DatePickerInputWithoutModal(
startYear,
endYear,
onChangeText,
inputEnabled,
...rest
}: DatePickerInputProps & {
modal?: (params: {
Expand All @@ -39,6 +40,7 @@ function DatePickerInputWithoutModal(
uppercase: DatePickerInputProps['uppercase']
startYear: DatePickerInputProps['startYear']
endYear: DatePickerInputProps['endYear']
inputEnabled: DatePickerInputProps['inputEnabled']
}) => any
inputButtons?: any
},
Expand All @@ -59,6 +61,16 @@ function DatePickerInputWithoutModal(
onValidationError,
})

let disabled

if (inputEnabled !== undefined) {
disabled = !inputEnabled
}

if (rest.disabled) {
disabled = rest.disabled
}

return (
<>
<View style={styles.root}>
Expand All @@ -75,6 +87,7 @@ function DatePickerInputWithoutModal(
value={formattedValue}
keyboardType={rest.keyboardType ?? 'number-pad'}
mask={inputFormat}
disabled={disabled}
onChangeText={onDateInputChangeText}
onChange={(e) => onChangeText && onChangeText(e.nativeEvent.text)}
keyboardAppearance={theme.dark ? 'dark' : 'default'}
Expand All @@ -99,6 +112,7 @@ function DatePickerInputWithoutModal(
uppercase,
startYear,
endYear,
inputEnabled,
})}
</>
)
Expand Down
3 changes: 3 additions & 0 deletions src/Date/DatePickerModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ interface DatePickerModalProps {
animationType?: 'slide' | 'fade' | 'none'
disableStatusBar?: boolean
disableStatusBarPadding?: boolean
inputEnabled?: boolean
}

export interface DatePickerModalSingleProps
Expand Down Expand Up @@ -49,6 +50,7 @@ export function DatePickerModal(
animationType,
disableStatusBar,
disableStatusBarPadding,
inputEnabled,
...rest
} = props
const animationTypeCalculated =
Expand Down Expand Up @@ -112,6 +114,7 @@ export function DatePickerModal(
)}
<DatePickerModalContent
{...rest}
inputEnabled={inputEnabled}
disableSafeTop={disableStatusBar}
/>
</View>
Expand Down
2 changes: 2 additions & 0 deletions src/Date/DatePickerModalContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ interface DatePickerModalContentBaseProps {
disableSafeTop?: boolean
saveLabelDisabled?: boolean
uppercase?: boolean
inputEnabled?: boolean
}

export interface DatePickerModalContentRangeProps
Expand Down Expand Up @@ -195,6 +196,7 @@ export function DatePickerModalContent(
onChange={onInnerChange}
validRange={validRange}
locale={locale}
inputEnabled={props.inputEnabled}
/>
}
/>
Expand Down
8 changes: 7 additions & 1 deletion src/Date/DatePickerModalContentHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export interface HeaderContentProps extends HeaderPickProps {
collapsed: boolean
onToggle: () => any
locale: string | undefined
inputDate?: boolean
}

function getLabel(
Expand Down Expand Up @@ -60,13 +61,18 @@ export default function DatePickerModalContentHeader(
uppercase,
editIcon,
calendarIcon,
inputDate,
} = props
const theme = useTheme()
const label = getLabel(props.locale, props.mode, props.label)

const color = useHeaderTextColor()
const supportingTextColor = theme.isV3 ? theme.colors.onSurfaceVariant : color
const allowEditing = mode !== 'multiple'
let allowEditing = mode !== 'multiple'

if (inputDate !== undefined) {
allowEditing = inputDate
}

let textFont = theme?.isV3
? theme.fonts.labelMedium
Expand Down
2 changes: 2 additions & 0 deletions src/TextInputMask.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ function TextInputWithMask(
onChange,
value,
mask,
disabled,
...rest
}: React.ComponentProps<typeof TextInput> & { mask: string; value: string },
ref: any
Expand Down Expand Up @@ -100,6 +101,7 @@ function TextInputWithMask(
<TextInput
ref={ref}
{...rest}
disabled={disabled}
value={controlledValue}
onChangeText={onInnerChange}
onChange={(e) => {
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/Time/__snapshots__/TimeInput.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ exports[`renders TimeInput 1`] = `
style={
[
{
"fontSize": 57,
"textAlign": "center",
"textAlignVertical": "center",
"width": 96,
Expand All @@ -31,6 +30,7 @@ exports[`renders TimeInput 1`] = `
"borderRadius": 8,
"borderWidth": 2,
"color": "rgba(33, 0, 93, 1)",
"fontSize": 57,
"height": 80,
},
]
Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/Time/__snapshots__/TimeInputs.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ exports[`renders TimeInputs 1`] = `
style={
[
{
"fontSize": 57,
"textAlign": "center",
"textAlignVertical": "center",
"width": 96,
Expand All @@ -54,6 +53,7 @@ exports[`renders TimeInputs 1`] = `
"borderRadius": 8,
"borderWidth": 0,
"color": "rgba(28, 27, 31, 1)",
"fontSize": 57,
"height": 72,
},
]
Expand Down Expand Up @@ -178,7 +178,6 @@ exports[`renders TimeInputs 1`] = `
style={
[
{
"fontSize": 57,
"textAlign": "center",
"textAlignVertical": "center",
"width": 96,
Expand All @@ -189,6 +188,7 @@ exports[`renders TimeInputs 1`] = `
"borderRadius": 8,
"borderWidth": 0,
"color": "rgba(28, 27, 31, 1)",
"fontSize": 57,
"height": 72,
},
]
Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/Time/__snapshots__/TimePicker.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ exports[`renders TimePicker 1`] = `
style={
[
{
"fontSize": 57,
"textAlign": "center",
"textAlignVertical": "center",
"width": 96,
Expand All @@ -62,6 +61,7 @@ exports[`renders TimePicker 1`] = `
"borderRadius": 8,
"borderWidth": 0,
"color": "rgba(28, 27, 31, 1)",
"fontSize": 57,
"height": 72,
},
]
Expand Down Expand Up @@ -186,7 +186,6 @@ exports[`renders TimePicker 1`] = `
style={
[
{
"fontSize": 57,
"textAlign": "center",
"textAlignVertical": "center",
"width": 96,
Expand All @@ -197,6 +196,7 @@ exports[`renders TimePicker 1`] = `
"borderRadius": 8,
"borderWidth": 0,
"color": "rgba(28, 27, 31, 1)",
"fontSize": 57,
"height": 72,
},
]
Expand Down