mirror of https://git.lenooby09.tech/LeNooby09/social-app.git
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

at rn-stack-repro 64 lines 1.5 kB view raw
1import React from 'react' 2import {TextInput, TextInputProps, StyleSheet} from 'react-native' 3// @ts-ignore 4import {unstable_createElement} from 'react-native-web' 5 6import * as TextField from '#/components/forms/TextField' 7import {toSimpleDateString} from '#/components/forms/DateField/utils' 8import {DateFieldProps} from '#/components/forms/DateField/types' 9 10export * as utils from '#/components/forms/DateField/utils' 11export const Label = TextField.Label 12 13const InputBase = React.forwardRef<HTMLInputElement, TextInputProps>( 14 ({style, ...props}, ref) => { 15 return unstable_createElement('input', { 16 ...props, 17 ref, 18 type: 'date', 19 style: [ 20 StyleSheet.flatten(style), 21 { 22 background: 'transparent', 23 border: 0, 24 }, 25 ], 26 }) 27 }, 28) 29 30InputBase.displayName = 'InputBase' 31 32const Input = TextField.createInput(InputBase as unknown as typeof TextInput) 33 34export function DateField({ 35 value, 36 onChangeDate, 37 label, 38 isInvalid, 39 testID, 40}: DateFieldProps) { 41 const handleOnChange = React.useCallback( 42 (e: any) => { 43 const date = e.target.valueAsDate || e.target.value 44 45 if (date) { 46 const formatted = toSimpleDateString(date) 47 onChangeDate(formatted) 48 } 49 }, 50 [onChangeDate], 51 ) 52 53 return ( 54 <TextField.Root isInvalid={isInvalid}> 55 <Input 56 value={value} 57 label={label} 58 onChange={handleOnChange} 59 onChangeText={() => {}} 60 testID={testID} 61 /> 62 </TextField.Root> 63 ) 64}