@utilitywarehouse/hearth-react-native 0.3.1 → 0.4.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.
- package/.storybook/preview.tsx +3 -0
- package/.turbo/turbo-build.log +1 -1
- package/.turbo/turbo-lint.log +1 -1
- package/CHANGELOG.md +10 -0
- package/build/components/CurrencyInput/CurrencyInput.js +1 -1
- package/build/components/DatePicker/DatePicker.context.d.ts +19 -0
- package/build/components/DatePicker/DatePicker.context.js +3 -0
- package/build/components/DatePicker/DatePicker.d.ts +19 -0
- package/build/components/DatePicker/DatePicker.js +479 -0
- package/build/components/DatePicker/DatePicker.props.d.ts +125 -0
- package/build/components/DatePicker/DatePicker.props.js +1 -0
- package/build/components/DatePicker/DatePickerCalendar.d.ts +2 -0
- package/build/components/DatePicker/DatePickerCalendar.js +28 -0
- package/build/components/DatePicker/DatePickerDay.d.ts +11 -0
- package/build/components/DatePicker/DatePickerDay.js +242 -0
- package/build/components/DatePicker/DatePickerDays.d.ts +2 -0
- package/build/components/DatePicker/DatePickerDays.js +157 -0
- package/build/components/DatePicker/DatePickerFooter.d.ts +2 -0
- package/build/components/DatePicker/DatePickerFooter.js +23 -0
- package/build/components/DatePicker/DatePickerHeader/DatePickerHeader.props.d.ts +8 -0
- package/build/components/DatePicker/DatePickerHeader/DatePickerHeader.props.js +1 -0
- package/build/components/DatePicker/DatePickerHeader/DatePickerMonthButton.d.ts +2 -0
- package/build/components/DatePicker/DatePickerHeader/DatePickerMonthButton.js +14 -0
- package/build/components/DatePicker/DatePickerHeader/DatePickerNextButton.d.ts +2 -0
- package/build/components/DatePicker/DatePickerHeader/DatePickerNextButton.js +32 -0
- package/build/components/DatePicker/DatePickerHeader/DatePickerPrevButton.d.ts +2 -0
- package/build/components/DatePicker/DatePickerHeader/DatePickerPrevButton.js +32 -0
- package/build/components/DatePicker/DatePickerHeader/DatePickerSelectors.d.ts +6 -0
- package/build/components/DatePicker/DatePickerHeader/DatePickerSelectors.js +64 -0
- package/build/components/DatePicker/DatePickerHeader/DatePickerTimeButton.d.ts +1 -0
- package/build/components/DatePicker/DatePickerHeader/DatePickerTimeButton.js +22 -0
- package/build/components/DatePicker/DatePickerHeader/DatePickerYearButton.d.ts +2 -0
- package/build/components/DatePicker/DatePickerHeader/DatePickerYearButton.js +25 -0
- package/build/components/DatePicker/DatePickerHeader/index.d.ts +3 -0
- package/build/components/DatePicker/DatePickerHeader/index.js +30 -0
- package/build/components/DatePicker/DatePickerMonths.d.ts +2 -0
- package/build/components/DatePicker/DatePickerMonths.js +69 -0
- package/build/components/DatePicker/DatePickerWeekdays.d.ts +8 -0
- package/build/components/DatePicker/DatePickerWeekdays.js +26 -0
- package/build/components/DatePicker/DatePickerYears.d.ts +2 -0
- package/build/components/DatePicker/DatePickerYears.js +83 -0
- package/build/components/DatePicker/TimePicker.d.ts +3 -0
- package/build/components/DatePicker/TimePicker.js +84 -0
- package/build/components/DatePicker/enums.d.ts +12 -0
- package/build/components/DatePicker/enums.js +12 -0
- package/build/components/DatePicker/index.d.ts +4 -0
- package/build/components/DatePicker/index.js +3 -0
- package/build/components/DatePicker/polyfill.d.ts +0 -0
- package/build/components/DatePicker/polyfill.js +22 -0
- package/build/components/DatePicker/time-picker/animated-math.d.ts +4 -0
- package/build/components/DatePicker/time-picker/animated-math.js +19 -0
- package/build/components/DatePicker/time-picker/period-native.d.ts +6 -0
- package/build/components/DatePicker/time-picker/period-native.js +17 -0
- package/build/components/DatePicker/time-picker/period-picker.d.ts +6 -0
- package/build/components/DatePicker/time-picker/period-picker.js +10 -0
- package/build/components/DatePicker/time-picker/period-web.d.ts +6 -0
- package/build/components/DatePicker/time-picker/period-web.js +21 -0
- package/build/components/DatePicker/time-picker/wheel-native.d.ts +8 -0
- package/build/components/DatePicker/time-picker/wheel-native.js +19 -0
- package/build/components/DatePicker/time-picker/wheel-picker/index.d.ts +2 -0
- package/build/components/DatePicker/time-picker/wheel-picker/index.js +2 -0
- package/build/components/DatePicker/time-picker/wheel-picker/wheel-picker-item.d.ts +16 -0
- package/build/components/DatePicker/time-picker/wheel-picker/wheel-picker-item.js +97 -0
- package/build/components/DatePicker/time-picker/wheel-picker/wheel-picker.d.ts +21 -0
- package/build/components/DatePicker/time-picker/wheel-picker/wheel-picker.js +88 -0
- package/build/components/DatePicker/time-picker/wheel-picker/wheel-picker.style.d.ts +23 -0
- package/build/components/DatePicker/time-picker/wheel-picker/wheel-picker.style.js +21 -0
- package/build/components/DatePicker/time-picker/wheel-web.d.ts +8 -0
- package/build/components/DatePicker/time-picker/wheel-web.js +148 -0
- package/build/components/DatePicker/time-picker/wheel.d.ts +8 -0
- package/build/components/DatePicker/time-picker/wheel.js +10 -0
- package/build/components/DatePicker/utils.d.ts +212 -0
- package/build/components/DatePicker/utils.js +391 -0
- package/build/components/DatePickerInput/DatePickerInput.d.ts +6 -0
- package/build/components/DatePickerInput/DatePickerInput.js +126 -0
- package/build/components/DatePickerInput/DatePickerInput.props.d.ts +47 -0
- package/build/components/DatePickerInput/DatePickerInput.props.js +1 -0
- package/build/components/DatePickerInput/DatePickerInputDoneButton.d.ts +8 -0
- package/build/components/DatePickerInput/DatePickerInputDoneButton.js +19 -0
- package/build/components/DatePickerInput/DatePickerInputDoneButton.web.d.ts +5 -0
- package/build/components/DatePickerInput/DatePickerInputDoneButton.web.js +5 -0
- package/build/components/DatePickerInput/index.d.ts +2 -0
- package/build/components/DatePickerInput/index.js +1 -0
- package/build/components/Input/InputField.d.ts +1 -1
- package/build/components/Input/InputField.js +1 -1
- package/build/components/Input/InputSlot.d.ts +1 -1
- package/build/components/Input/InputSlot.js +3 -3
- package/build/components/UnstyledIconButton/UnstyledIconButton.js +2 -2
- package/build/components/UnstyledIconButton/UnstyledIconButtonRoot.js +1 -1
- package/build/components/index.d.ts +2 -0
- package/build/components/index.js +2 -0
- package/build/hooks/index.d.ts +4 -3
- package/build/hooks/index.js +4 -3
- package/build/hooks/usePrevious.d.ts +1 -0
- package/build/hooks/usePrevious.js +8 -0
- package/build/hooks/useTheme.d.ts +2 -1
- package/build/hooks/useTheme.js +2 -2
- package/build/tokens/components/dark/date-picker.d.ts +1 -0
- package/build/tokens/components/dark/date-picker.js +1 -0
- package/build/tokens/components/dark/illustrations.d.ts +7 -0
- package/build/tokens/components/dark/illustrations.js +6 -0
- package/build/tokens/components/dark/index.d.ts +1 -0
- package/build/tokens/components/dark/index.js +1 -0
- package/build/tokens/components/dark/segmented-control.d.ts +2 -2
- package/build/tokens/components/dark/segmented-control.js +2 -2
- package/build/tokens/components/dark/table.d.ts +3 -0
- package/build/tokens/components/dark/table.js +3 -0
- package/build/tokens/components/light/date-picker.d.ts +1 -0
- package/build/tokens/components/light/date-picker.js +1 -0
- package/build/tokens/components/light/illustrations.d.ts +7 -0
- package/build/tokens/components/light/illustrations.js +6 -0
- package/build/tokens/components/light/index.d.ts +1 -0
- package/build/tokens/components/light/index.js +1 -0
- package/build/tokens/components/light/segmented-control.d.ts +2 -2
- package/build/tokens/components/light/segmented-control.js +2 -2
- package/build/tokens/components/light/table.d.ts +3 -0
- package/build/tokens/components/light/table.js +3 -0
- package/build/utils/index.d.ts +1 -0
- package/build/utils/index.js +1 -0
- package/build/utils/isEqual.d.ts +2 -0
- package/build/utils/isEqual.js +29 -0
- package/chromatic.config.json +6 -0
- package/docs/components/AllComponents.web.tsx +43 -1
- package/docs/components/ViewWrap.tsx +32 -0
- package/docs/components/index.ts +1 -0
- package/docs/getting-started.mdx +6 -6
- package/package.json +10 -7
- package/src/components/CurrencyInput/CurrencyInput.tsx +2 -1
- package/src/components/DatePicker/DatePicker.context.ts +23 -0
- package/src/components/DatePicker/DatePicker.docs.mdx +239 -0
- package/src/components/DatePicker/DatePicker.props.ts +139 -0
- package/src/components/DatePicker/DatePicker.stories.tsx +98 -0
- package/src/components/DatePicker/DatePicker.tsx +669 -0
- package/src/components/DatePicker/DatePickerCalendar.tsx +41 -0
- package/src/components/DatePicker/DatePickerDay.tsx +302 -0
- package/src/components/DatePicker/DatePickerDays.tsx +241 -0
- package/src/components/DatePicker/DatePickerFooter.tsx +35 -0
- package/src/components/DatePicker/DatePickerHeader/DatePickerHeader.props.ts +10 -0
- package/src/components/DatePicker/DatePickerHeader/DatePickerMonthButton.tsx +29 -0
- package/src/components/DatePicker/DatePickerHeader/DatePickerNextButton.tsx +46 -0
- package/src/components/DatePicker/DatePickerHeader/DatePickerPrevButton.tsx +46 -0
- package/src/components/DatePicker/DatePickerHeader/DatePickerSelectors.tsx +96 -0
- package/src/components/DatePicker/DatePickerHeader/DatePickerTimeButton.tsx +48 -0
- package/src/components/DatePicker/DatePickerHeader/DatePickerYearButton.tsx +50 -0
- package/src/components/DatePicker/DatePickerHeader/index.tsx +64 -0
- package/src/components/DatePicker/DatePickerMonths.tsx +101 -0
- package/src/components/DatePicker/DatePickerWeekdays.tsx +49 -0
- package/src/components/DatePicker/DatePickerYears.tsx +119 -0
- package/src/components/DatePicker/TimePicker.tsx +141 -0
- package/src/components/DatePicker/enums.ts +14 -0
- package/src/components/DatePicker/index.ts +13 -0
- package/src/components/DatePicker/polyfill.ts +21 -0
- package/src/components/DatePicker/time-picker/animated-math.ts +33 -0
- package/src/components/DatePicker/time-picker/period-native.tsx +34 -0
- package/src/components/DatePicker/time-picker/period-picker.tsx +16 -0
- package/src/components/DatePicker/time-picker/period-web.tsx +36 -0
- package/src/components/DatePicker/time-picker/wheel-native.tsx +37 -0
- package/src/components/DatePicker/time-picker/wheel-picker/index.ts +3 -0
- package/src/components/DatePicker/time-picker/wheel-picker/wheel-picker-item.tsx +132 -0
- package/src/components/DatePicker/time-picker/wheel-picker/wheel-picker.style.ts +22 -0
- package/src/components/DatePicker/time-picker/wheel-picker/wheel-picker.tsx +200 -0
- package/src/components/DatePicker/time-picker/wheel-web.tsx +181 -0
- package/src/components/DatePicker/time-picker/wheel.tsx +18 -0
- package/src/components/DatePicker/utils.ts +549 -0
- package/src/components/DatePickerInput/DatePickerInput.docs.mdx +237 -0
- package/src/components/DatePickerInput/DatePickerInput.props.ts +50 -0
- package/src/components/DatePickerInput/DatePickerInput.stories.tsx +178 -0
- package/src/components/DatePickerInput/DatePickerInput.tsx +265 -0
- package/src/components/DatePickerInput/DatePickerInputDoneButton.tsx +42 -0
- package/src/components/DatePickerInput/DatePickerInputDoneButton.web.tsx +7 -0
- package/src/components/DatePickerInput/index.ts +2 -0
- package/src/components/Icon/Icon.stories.tsx +4 -3
- package/src/components/Input/InputField.tsx +0 -2
- package/src/components/Input/InputSlot.tsx +14 -3
- package/src/components/Modal/Modal.stories.tsx +2 -30
- package/src/components/UnstyledIconButton/UnstyledIconButton.tsx +14 -2
- package/src/components/UnstyledIconButton/UnstyledIconButtonRoot.tsx +7 -3
- package/src/components/index.ts +2 -0
- package/src/hooks/index.ts +4 -3
- package/src/hooks/usePrevious.ts +9 -0
- package/src/hooks/useTheme.ts +4 -3
- package/src/tokens/components/dark/date-picker.ts +1 -0
- package/src/tokens/components/dark/illustrations.ts +7 -0
- package/src/tokens/components/dark/index.ts +1 -0
- package/src/tokens/components/dark/segmented-control.ts +2 -2
- package/src/tokens/components/dark/table.ts +3 -0
- package/src/tokens/components/light/date-picker.ts +1 -0
- package/src/tokens/components/light/illustrations.ts +7 -0
- package/src/tokens/components/light/index.ts +1 -0
- package/src/tokens/components/light/segmented-control.ts +2 -2
- package/src/tokens/components/light/table.ts +3 -0
- package/src/utils/index.ts +1 -0
- package/src/utils/isEqual.ts +30 -0
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { CalendarSmallIcon, CloseSmallIcon } from '@utilitywarehouse/hearth-react-native-icons';
|
|
3
|
+
import dayjs from 'dayjs';
|
|
4
|
+
import customParseFormat from 'dayjs/plugin/customParseFormat';
|
|
5
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
6
|
+
import { Keyboard, Platform } from 'react-native';
|
|
7
|
+
import { StyleSheet } from 'react-native-unistyles';
|
|
8
|
+
import { DatePicker } from '../DatePicker';
|
|
9
|
+
import { useFormFieldContext } from '../FormField';
|
|
10
|
+
import { Input, InputField, InputSlot } from '../Input';
|
|
11
|
+
import { UnstyledIconButton } from '../UnstyledIconButton';
|
|
12
|
+
import DatePickerInputDoneButton from './DatePickerInputDoneButton';
|
|
13
|
+
dayjs.extend(customParseFormat);
|
|
14
|
+
const DEFAULT_FORMAT = 'DD/MM/YYYY';
|
|
15
|
+
const maskDefaultFormat = (value) => {
|
|
16
|
+
const digitsOnly = value.replace(/\D/g, '').slice(0, 8);
|
|
17
|
+
const day = digitsOnly.slice(0, 2);
|
|
18
|
+
const month = digitsOnly.slice(2, 4);
|
|
19
|
+
const year = digitsOnly.slice(4, 8);
|
|
20
|
+
return [day, month, year].filter(Boolean).join('/');
|
|
21
|
+
};
|
|
22
|
+
const DatePickerInput = ({ validationStatus = 'initial', disabled, focused, readonly, placeholder, inBottomSheet = false, format = DEFAULT_FORMAT, openButtonLabel = 'Open date picker', autoCloseOnSelect = true, onChange, onChangeText, onBlur, onFocus, value, datePickerProps, onClear, ...rest }) => {
|
|
23
|
+
const formFieldContext = useFormFieldContext();
|
|
24
|
+
const validationStatusFromContext = formFieldContext?.validationStatus ?? validationStatus;
|
|
25
|
+
const isDisabled = formFieldContext?.disabled ?? disabled;
|
|
26
|
+
const isReadonly = formFieldContext?.readonly ?? readonly;
|
|
27
|
+
const pickerRef = useRef(null);
|
|
28
|
+
const accessoryViewID = useMemo(() => {
|
|
29
|
+
if (Platform.OS !== 'ios')
|
|
30
|
+
return undefined;
|
|
31
|
+
return `datepicker-input-${Math.random().toString(36).slice(2)}`;
|
|
32
|
+
}, []);
|
|
33
|
+
const formatDate = useCallback((dateValue) => {
|
|
34
|
+
if (!dateValue)
|
|
35
|
+
return '';
|
|
36
|
+
const parsed = dayjs(dateValue);
|
|
37
|
+
return parsed.isValid() ? parsed.format(format) : '';
|
|
38
|
+
}, [format]);
|
|
39
|
+
const isDefaultFormat = format === DEFAULT_FORMAT;
|
|
40
|
+
const [inputValue, setInputValue] = useState(() => formatDate(value));
|
|
41
|
+
useEffect(() => {
|
|
42
|
+
setInputValue(formatDate(value));
|
|
43
|
+
}, [value, formatDate]);
|
|
44
|
+
const handleTextChange = useCallback((text) => {
|
|
45
|
+
const nextValue = isDefaultFormat ? maskDefaultFormat(text) : text;
|
|
46
|
+
setInputValue(nextValue);
|
|
47
|
+
onChangeText?.(nextValue);
|
|
48
|
+
if (!nextValue) {
|
|
49
|
+
onChange?.({ date: undefined });
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
const parsed = dayjs(nextValue, format, true);
|
|
53
|
+
if (parsed.isValid()) {
|
|
54
|
+
onChange?.({ date: parsed.toDate() });
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
onChange?.({ date: undefined });
|
|
58
|
+
}
|
|
59
|
+
}, [format, isDefaultFormat, onChange, onChangeText]);
|
|
60
|
+
const handleClear = useCallback(() => {
|
|
61
|
+
setInputValue('');
|
|
62
|
+
onChange?.({ date: undefined });
|
|
63
|
+
onClear?.();
|
|
64
|
+
}, [onChange, onClear]);
|
|
65
|
+
const closeKeyboard = useCallback(() => {
|
|
66
|
+
Keyboard.dismiss();
|
|
67
|
+
}, []);
|
|
68
|
+
const openPicker = useCallback(() => {
|
|
69
|
+
if (isDisabled || isReadonly)
|
|
70
|
+
return;
|
|
71
|
+
closeKeyboard();
|
|
72
|
+
pickerRef.current?.present();
|
|
73
|
+
}, [closeKeyboard, isDisabled, isReadonly]);
|
|
74
|
+
const selectedDate = useMemo(() => {
|
|
75
|
+
if (value) {
|
|
76
|
+
return value;
|
|
77
|
+
}
|
|
78
|
+
const parsed = dayjs(inputValue, format, true);
|
|
79
|
+
return parsed.isValid() ? parsed.toDate() : undefined;
|
|
80
|
+
}, [value, inputValue, format]);
|
|
81
|
+
const handlePickerChange = useCallback(({ date }) => {
|
|
82
|
+
if (!date) {
|
|
83
|
+
handleClear();
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
const formatted = formatDate(date);
|
|
87
|
+
setInputValue(formatted);
|
|
88
|
+
onChange?.({ date });
|
|
89
|
+
if (autoCloseOnSelect) {
|
|
90
|
+
pickerRef.current?.close?.();
|
|
91
|
+
}
|
|
92
|
+
}, [autoCloseOnSelect, formatDate, handleClear, onChange]);
|
|
93
|
+
const handleBlur = useCallback((event) => {
|
|
94
|
+
onBlur?.(event);
|
|
95
|
+
}, [onBlur]);
|
|
96
|
+
const handleFocus = useCallback((event) => {
|
|
97
|
+
onFocus?.(event);
|
|
98
|
+
}, [onFocus]);
|
|
99
|
+
const { onCancel: pickerOnCancel, ...restDatePickerProps } = datePickerProps ?? {};
|
|
100
|
+
const { style: inputStyle, keyboardType: keyboardTypeProp, inputMode: inputModeProp, accessibilityHint: accessibilityHintProp, accessibilityLabel: accessibilityLabelProp, accessible: accessibleProp, accessibilityRole: accessibilityRoleProp, importantForAccessibility: importantForAccessibilityProp, ...textInputProps } = rest;
|
|
101
|
+
const resolvedKeyboardType = keyboardTypeProp ?? (isDefaultFormat ? 'number-pad' : undefined);
|
|
102
|
+
const resolvedInputMode = inputModeProp ?? (isDefaultFormat ? 'numeric' : undefined);
|
|
103
|
+
const resolvedAccessibilityHint = accessibilityHintProp ?? `Enter the date in ${format} format`;
|
|
104
|
+
const resolvedAccessibilityLabel = accessibilityLabelProp ?? 'Date input';
|
|
105
|
+
const resolvedAccessible = accessibleProp ?? true;
|
|
106
|
+
const resolvedImportantForAccessibility = importantForAccessibilityProp ?? 'yes';
|
|
107
|
+
const handleCancel = useCallback(() => {
|
|
108
|
+
pickerOnCancel?.();
|
|
109
|
+
pickerRef.current?.close?.();
|
|
110
|
+
}, [pickerOnCancel]);
|
|
111
|
+
const placeholderValue = placeholder ?? format;
|
|
112
|
+
return (_jsxs(_Fragment, { children: [_jsxs(Input, { validationStatus: validationStatusFromContext, disabled: isDisabled, readonly: isReadonly, focused: focused, style: styles.wrap, accessible: false, children: [_jsx(InputField, { editable: !isReadonly && !isDisabled, value: inputValue, placeholder: placeholderValue, onChangeText: handleTextChange, onBlur: handleBlur, onFocus: handleFocus, inBottomSheet: inBottomSheet, keyboardType: resolvedKeyboardType, inputMode: resolvedInputMode, accessibilityHint: resolvedAccessibilityHint, "aria-label": "Date input", accessibilityLabel: resolvedAccessibilityLabel, accessible: resolvedAccessible, accessibilityState: {
|
|
113
|
+
disabled: isDisabled || isReadonly,
|
|
114
|
+
}, importantForAccessibility: resolvedImportantForAccessibility, inputAccessoryViewID: Platform.OS === 'ios' ? accessoryViewID : undefined, ...textInputProps, style: [styles.input, inputStyle] }), !!inputValue && onClear && !isReadonly && !isDisabled && (_jsx(InputSlot, { accessibilityElementsHidden: false, children: _jsx(UnstyledIconButton, { accessibilityLabel: "Clear date", accessibilityHint: "Removes the current date", icon: CloseSmallIcon, onPress: handleClear }) })), _jsx(InputSlot, { accessibilityElementsHidden: false, children: _jsx(UnstyledIconButton, { accessibilityLabel: openButtonLabel, accessibilityHint: "Opens the date picker calendar", icon: CalendarSmallIcon, onPress: openPicker, disabled: isDisabled || isReadonly }) })] }), _jsx(DatePicker, { ref: pickerRef, mode: "single", date: selectedDate, onChange: handlePickerChange, onCancel: handleCancel, ...restDatePickerProps }), Platform.OS === 'ios' && accessoryViewID && (_jsx(DatePickerInputDoneButton, { accessoryViewID: accessoryViewID, closeKeyboard: closeKeyboard }))] }));
|
|
115
|
+
};
|
|
116
|
+
DatePickerInput.displayName = 'DatePickerInput';
|
|
117
|
+
const styles = StyleSheet.create(theme => ({
|
|
118
|
+
wrap: {
|
|
119
|
+
gap: theme.components.input.date.gap,
|
|
120
|
+
},
|
|
121
|
+
input: {
|
|
122
|
+
paddingLeft: 0,
|
|
123
|
+
paddingRight: 0,
|
|
124
|
+
},
|
|
125
|
+
}));
|
|
126
|
+
export default DatePickerInput;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { TextInputProps, ViewProps } from 'react-native';
|
|
2
|
+
import type { DatePickerSingleProps } from '../DatePicker/DatePicker';
|
|
3
|
+
import type { DateType } from '../DatePicker/DatePicker.props';
|
|
4
|
+
export interface DatePickerInputBaseProps {
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
validationStatus?: 'initial' | 'valid' | 'invalid';
|
|
7
|
+
readonly?: boolean;
|
|
8
|
+
focused?: boolean;
|
|
9
|
+
placeholder?: string;
|
|
10
|
+
inBottomSheet?: boolean;
|
|
11
|
+
required?: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Controls how the selected date is formatted when displayed inside the input.
|
|
14
|
+
* Accepts any Day.js format string. When left as the default `DD/MM/YYYY`,
|
|
15
|
+
* the input automatically inserts separators as people type.
|
|
16
|
+
*/
|
|
17
|
+
format?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Accessible label announced when activating the calendar trigger button.
|
|
20
|
+
*/
|
|
21
|
+
openButtonLabel?: string;
|
|
22
|
+
/**
|
|
23
|
+
* When true (default), the calendar sheet is dismissed as soon as a date is picked.
|
|
24
|
+
*/
|
|
25
|
+
autoCloseOnSelect?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Additional props forwarded to the underlying DatePicker instance.
|
|
28
|
+
*/
|
|
29
|
+
datePickerProps?: Omit<DatePickerSingleProps, 'mode' | 'date' | 'onChange' | 'ref'>;
|
|
30
|
+
/**
|
|
31
|
+
* Handles cleared input values.
|
|
32
|
+
*/
|
|
33
|
+
onClear?: () => void;
|
|
34
|
+
}
|
|
35
|
+
export type DatePickerInputProps = DatePickerInputBaseProps & Omit<TextInputProps, 'value' | 'onChange' | 'children'> & ViewProps & {
|
|
36
|
+
/**
|
|
37
|
+
* Controlled date value. Accepts Date, string, number or Day.js instances.
|
|
38
|
+
*/
|
|
39
|
+
value?: DateType;
|
|
40
|
+
/**
|
|
41
|
+
* Fired after a valid date is parsed either from typing or the picker selection.
|
|
42
|
+
*/
|
|
43
|
+
onChange?: (params: {
|
|
44
|
+
date: DateType;
|
|
45
|
+
}) => void;
|
|
46
|
+
};
|
|
47
|
+
export default DatePickerInputProps;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { InputAccessoryView, View } from 'react-native';
|
|
3
|
+
import { StyleSheet } from 'react-native-unistyles';
|
|
4
|
+
import { Button } from '../Button';
|
|
5
|
+
const DatePickerInputDoneButton = ({ accessoryViewID, closeKeyboard, }) => {
|
|
6
|
+
return (_jsx(InputAccessoryView, { nativeID: accessoryViewID, children: _jsx(View, { style: styles.accessory, children: _jsx(Button, { accessibilityRole: "button", accessibilityLabel: "Done", onPress: closeKeyboard, variant: "ghost", colorScheme: "functional", children: "Done" }) }) }));
|
|
7
|
+
};
|
|
8
|
+
const styles = StyleSheet.create(theme => ({
|
|
9
|
+
accessory: {
|
|
10
|
+
paddingHorizontal: 16,
|
|
11
|
+
paddingVertical: 2,
|
|
12
|
+
alignItems: 'flex-end',
|
|
13
|
+
backgroundColor: theme.color.surface.neutral.strong,
|
|
14
|
+
borderTopWidth: theme.borderWidth[1],
|
|
15
|
+
borderTopColor: theme.color.border.subtle,
|
|
16
|
+
},
|
|
17
|
+
}));
|
|
18
|
+
DatePickerInputDoneButton.DisplayName = 'DatePickerInputDoneButton';
|
|
19
|
+
export default DatePickerInputDoneButton;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as DatePickerInput } from './DatePickerInput';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TextInputProps } from 'react-native';
|
|
2
2
|
declare const InputField: {
|
|
3
|
-
({ style,
|
|
3
|
+
({ style, inBottomSheet, ...props }: TextInputProps & {
|
|
4
4
|
inBottomSheet?: boolean;
|
|
5
5
|
}): import("react/jsx-runtime").JSX.Element;
|
|
6
6
|
displayName: string;
|
|
@@ -4,7 +4,7 @@ import { TextInput as RNTextInput } from 'react-native';
|
|
|
4
4
|
import { StyleSheet } from 'react-native-unistyles';
|
|
5
5
|
import { useTheme } from '../../hooks';
|
|
6
6
|
import { useInputContext } from './Input.context';
|
|
7
|
-
const InputField = ({ style,
|
|
7
|
+
const InputField = ({ style, inBottomSheet = false, ...props }) => {
|
|
8
8
|
const { disabled, focused = false, type } = useInputContext();
|
|
9
9
|
styles.useVariants({ focused, type });
|
|
10
10
|
const { color } = useTheme();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ViewProps } from 'react-native';
|
|
2
2
|
declare const InputSlot: {
|
|
3
|
-
({ children, style, ...props }: ViewProps): import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
({ children, style, accessible, importantForAccessibility, ...props }: ViewProps): import("react/jsx-runtime").JSX.Element;
|
|
4
4
|
displayName: string;
|
|
5
5
|
};
|
|
6
6
|
export default InputSlot;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { StyleSheet } from 'react-native-unistyles';
|
|
3
2
|
import { View } from 'react-native';
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
import { StyleSheet } from 'react-native-unistyles';
|
|
4
|
+
const InputSlot = ({ children, style, accessible, importantForAccessibility, ...props }) => {
|
|
5
|
+
return (_jsx(View, { ...props, accessible: accessible ?? false, importantForAccessibility: importantForAccessibility ?? 'auto', style: [styles.container, style], children: children }));
|
|
6
6
|
};
|
|
7
7
|
InputSlot.displayName = 'InputSlot';
|
|
8
8
|
const styles = StyleSheet.create({
|
|
@@ -17,10 +17,10 @@ UnstyledIconButtonSpinner.displayName = 'UnstyledIconButtonSpinner';
|
|
|
17
17
|
UnstyledIconButtonIcon.displayName = 'UnstyledIconButtonIcon';
|
|
18
18
|
const UnstyledIconButton = ({ icon, disabled = false, pressed, size = 'md', inverted = false, iconStyle, ...props }) => {
|
|
19
19
|
const { disabled: groupDisabled, loading: groupLoading } = useButtonGroupContext();
|
|
20
|
-
const { loading } = props;
|
|
20
|
+
const { loading, accessibilityRole = 'button', accessible = true, focusable = true, importantForAccessibility = 'yes', ...restProps } = props;
|
|
21
21
|
const isLoading = loading ?? groupLoading;
|
|
22
22
|
const buttonDisabled = isLoading || (disabled ?? groupDisabled);
|
|
23
|
-
return (_jsx(UnstyledIconButtonComponent, { ...
|
|
23
|
+
return (_jsx(UnstyledIconButtonComponent, { ...restProps, size: size, inverted: inverted, isDisabled: buttonDisabled, isPressed: pressed, accessibilityRole: accessibilityRole, accessible: accessible, focusable: focusable, importantForAccessibility: importantForAccessibility, icon: icon, children: loading ? (_jsx(UnstyledIconButtonSpinner, {})) : (_jsx(UnstyledIconButtonIcon, { as: icon, style: iconStyle })) }));
|
|
24
24
|
};
|
|
25
25
|
UnstyledIconButton.displayName = 'UnstyledIconButton';
|
|
26
26
|
export default UnstyledIconButton;
|
|
@@ -7,7 +7,7 @@ const UnstyledIconButtonRoot = ({ size, inverted, states, ...props }) => {
|
|
|
7
7
|
const { active, disabled } = states || {};
|
|
8
8
|
styles.useVariants({ disabled, size });
|
|
9
9
|
const value = useMemo(() => ({ disabled, active, inverted, size }), [disabled, active, inverted, size]);
|
|
10
|
-
return (_jsx(UnstyledIconButtonContext.Provider, { value: value, children: _jsx(Pressable, { ...props, style: [styles.container, props.style] }) }));
|
|
10
|
+
return (_jsx(UnstyledIconButtonContext.Provider, { value: value, children: _jsx(Pressable, { ...props, accessibilityState: { disabled: !!disabled, ...props.accessibilityState }, style: [styles.container, props.style] }) }));
|
|
11
11
|
};
|
|
12
12
|
UnstyledIconButtonRoot.displayName = 'UnstyledIconButtonRoot';
|
|
13
13
|
const styles = StyleSheet.create(theme => ({
|
|
@@ -9,6 +9,8 @@ export * from './Card';
|
|
|
9
9
|
export * from './Center';
|
|
10
10
|
export * from './Checkbox';
|
|
11
11
|
export * from './CurrencyInput';
|
|
12
|
+
export * from './DatePicker';
|
|
13
|
+
export * from './DatePickerInput';
|
|
12
14
|
export * from './DescriptionList';
|
|
13
15
|
export * from './DetailText';
|
|
14
16
|
export * from './Divider';
|
|
@@ -10,6 +10,8 @@ export * from './Card';
|
|
|
10
10
|
export * from './Center';
|
|
11
11
|
export * from './Checkbox';
|
|
12
12
|
export * from './CurrencyInput';
|
|
13
|
+
export * from './DatePicker';
|
|
14
|
+
export * from './DatePickerInput';
|
|
13
15
|
export * from './DescriptionList';
|
|
14
16
|
export * from './DetailText';
|
|
15
17
|
export * from './Divider';
|
package/build/hooks/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
export { default as useColorMode } from './useColorMode';
|
|
2
1
|
export { default as useBreakpointValue } from './useBreakpointValue';
|
|
3
|
-
export { default as
|
|
2
|
+
export { default as useColorMode } from './useColorMode';
|
|
4
3
|
export { default as useMedia } from './useMedia';
|
|
5
|
-
export {
|
|
4
|
+
export { usePrevious } from './usePrevious';
|
|
6
5
|
export { useStyleProps } from './useStyleProps';
|
|
6
|
+
export { default as useTheme } from './useTheme';
|
|
7
|
+
export { default as useToken } from './useToken';
|
package/build/hooks/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
export { default as useColorMode } from './useColorMode';
|
|
2
1
|
export { default as useBreakpointValue } from './useBreakpointValue';
|
|
3
|
-
export { default as
|
|
2
|
+
export { default as useColorMode } from './useColorMode';
|
|
4
3
|
export { default as useMedia } from './useMedia';
|
|
5
|
-
export {
|
|
4
|
+
export { usePrevious } from './usePrevious';
|
|
6
5
|
export { useStyleProps } from './useStyleProps';
|
|
6
|
+
export { default as useTheme } from './useTheme';
|
|
7
|
+
export { default as useToken } from './useToken';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const usePrevious: (value: any) => null;
|
package/build/hooks/useTheme.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useUnistyles } from 'react-native-unistyles';
|
|
2
2
|
const useTheme = () => {
|
|
3
|
-
const theme =
|
|
3
|
+
const { theme } = useUnistyles();
|
|
4
4
|
return theme;
|
|
5
5
|
};
|
|
6
6
|
export default useTheme;
|
|
@@ -21,6 +21,7 @@ export { default as expandableCard } from './expandable-card';
|
|
|
21
21
|
export { default as formField } from './form-field';
|
|
22
22
|
export { default as iconButton } from './icon-button';
|
|
23
23
|
export { default as iconContainer } from './icon-container';
|
|
24
|
+
export { default as illustrations } from './illustrations';
|
|
24
25
|
export { default as indicatorIconButton } from './indicator-icon-button';
|
|
25
26
|
export { default as inlineLink } from './inline-link';
|
|
26
27
|
export { default as input } from './input';
|
|
@@ -21,6 +21,7 @@ export { default as expandableCard } from './expandable-card';
|
|
|
21
21
|
export { default as formField } from './form-field';
|
|
22
22
|
export { default as iconButton } from './icon-button';
|
|
23
23
|
export { default as iconContainer } from './icon-container';
|
|
24
|
+
export { default as illustrations } from './illustrations';
|
|
24
25
|
export { default as indicatorIconButton } from './indicator-icon-button';
|
|
25
26
|
export { default as inlineLink } from './inline-link';
|
|
26
27
|
export { default as input } from './input';
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
* Do not edit directly, this file was auto-generated.
|
|
3
3
|
*/
|
|
4
4
|
declare const _default: {
|
|
5
|
-
readonly borderRadius:
|
|
5
|
+
readonly borderRadius: 9999;
|
|
6
6
|
readonly gap: 6;
|
|
7
7
|
readonly group: {
|
|
8
|
-
readonly borderRadius:
|
|
8
|
+
readonly borderRadius: 9999;
|
|
9
9
|
readonly borderWidth: 1;
|
|
10
10
|
readonly gap: 4;
|
|
11
11
|
readonly height: 48;
|
|
@@ -21,6 +21,7 @@ export { default as expandableCard } from './expandable-card';
|
|
|
21
21
|
export { default as formField } from './form-field';
|
|
22
22
|
export { default as iconButton } from './icon-button';
|
|
23
23
|
export { default as iconContainer } from './icon-container';
|
|
24
|
+
export { default as illustrations } from './illustrations';
|
|
24
25
|
export { default as indicatorIconButton } from './indicator-icon-button';
|
|
25
26
|
export { default as inlineLink } from './inline-link';
|
|
26
27
|
export { default as input } from './input';
|
|
@@ -21,6 +21,7 @@ export { default as expandableCard } from './expandable-card';
|
|
|
21
21
|
export { default as formField } from './form-field';
|
|
22
22
|
export { default as iconButton } from './icon-button';
|
|
23
23
|
export { default as iconContainer } from './icon-container';
|
|
24
|
+
export { default as illustrations } from './illustrations';
|
|
24
25
|
export { default as indicatorIconButton } from './indicator-icon-button';
|
|
25
26
|
export { default as inlineLink } from './inline-link';
|
|
26
27
|
export { default as input } from './input';
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
* Do not edit directly, this file was auto-generated.
|
|
3
3
|
*/
|
|
4
4
|
declare const _default: {
|
|
5
|
-
readonly borderRadius:
|
|
5
|
+
readonly borderRadius: 9999;
|
|
6
6
|
readonly gap: 6;
|
|
7
7
|
readonly group: {
|
|
8
|
-
readonly borderRadius:
|
|
8
|
+
readonly borderRadius: 9999;
|
|
9
9
|
readonly borderWidth: 1;
|
|
10
10
|
readonly gap: 4;
|
|
11
11
|
readonly height: 48;
|
package/build/utils/index.d.ts
CHANGED
|
@@ -3,4 +3,5 @@ export { default as formatThousands } from './formatThousands';
|
|
|
3
3
|
export { default as getFlattenedColorValue } from './getFlattenedColorValue';
|
|
4
4
|
export { default as getStyleValue } from './getStyleValue';
|
|
5
5
|
export { default as hexWithOpacity } from './hexWithOpacity';
|
|
6
|
+
export { default as isEqual } from './isEqual';
|
|
6
7
|
export * from './styleUtils';
|
package/build/utils/index.js
CHANGED
|
@@ -3,4 +3,5 @@ export { default as formatThousands } from './formatThousands';
|
|
|
3
3
|
export { default as getFlattenedColorValue } from './getFlattenedColorValue';
|
|
4
4
|
export { default as getStyleValue } from './getStyleValue';
|
|
5
5
|
export { default as hexWithOpacity } from './hexWithOpacity';
|
|
6
|
+
export { default as isEqual } from './isEqual';
|
|
6
7
|
export * from './styleUtils';
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
const isEqual = (a, b) => {
|
|
2
|
+
if (a === b)
|
|
3
|
+
return true;
|
|
4
|
+
if (typeof a !== typeof b)
|
|
5
|
+
return false;
|
|
6
|
+
if (typeof a !== 'object' || a === null || b === null)
|
|
7
|
+
return false;
|
|
8
|
+
if (Array.isArray(a) !== Array.isArray(b))
|
|
9
|
+
return false;
|
|
10
|
+
if (Array.isArray(a)) {
|
|
11
|
+
if (a.length !== b.length)
|
|
12
|
+
return false;
|
|
13
|
+
for (let i = 0; i < a.length; i++) {
|
|
14
|
+
if (!isEqual(a[i], b[i]))
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
const keysA = Object.keys(a);
|
|
20
|
+
const keysB = Object.keys(b);
|
|
21
|
+
if (keysA.length !== keysB.length)
|
|
22
|
+
return false;
|
|
23
|
+
for (const key of keysA) {
|
|
24
|
+
if (!keysB.includes(key) || !isEqual(a[key], b[key]))
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
return true;
|
|
28
|
+
};
|
|
29
|
+
export default isEqual;
|