@utilitywarehouse/hearth-react-native 0.3.0 → 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 +3 -1
- package/CHANGELOG.md +22 -0
- package/build/components/Alert/AlertCloseButton.js +25 -3
- package/build/components/Alert/AlertIcon.js +17 -1
- package/build/components/Alert/AlertIconButton.js +27 -1
- package/build/components/Alert/AlertLink.js +47 -1
- package/build/components/Alert/AlertText.d.ts +1 -1
- package/build/components/Alert/AlertText.js +26 -2
- package/build/components/Alert/AlertTitle.d.ts +1 -1
- package/build/components/Alert/AlertTitle.js +26 -2
- package/build/components/Badge/BadgeIcon.js +72 -0
- package/build/components/Badge/BadgeText.js +72 -0
- package/build/components/Button/ButtonRoot.js +1 -0
- package/build/components/Checkbox/Checkbox.d.ts +2 -2
- package/build/components/Checkbox/Checkbox.js +11 -10
- package/build/components/Checkbox/Checkbox.props.d.ts +3 -1
- package/build/components/Checkbox/CheckboxIcon.js +1 -1
- package/build/components/Checkbox/CheckboxImage.d.ts +6 -0
- package/build/components/Checkbox/CheckboxImage.js +5 -0
- package/build/components/Checkbox/CheckboxTileRoot.js +1 -1
- package/build/components/Checkbox/index.d.ts +3 -2
- package/build/components/Checkbox/index.js +2 -1
- 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/Link/Link.d.ts +1 -1
- package/build/components/Link/Link.js +4 -4
- package/build/components/Link/Link.props.d.ts +3 -0
- package/build/components/Radio/Radio.d.ts +2 -2
- package/build/components/Radio/Radio.js +9 -8
- package/build/components/Radio/Radio.props.d.ts +3 -1
- package/build/components/Radio/RadioImage.d.ts +6 -0
- package/build/components/Radio/RadioImage.js +5 -0
- package/build/components/Radio/RadioTileRoot.js +1 -1
- package/build/components/Radio/index.d.ts +3 -2
- package/build/components/Radio/index.js +2 -1
- package/build/components/Select/SelectOption.js +1 -7
- package/build/components/UnstyledIconButton/UnstyledIconButton.d.ts +1 -1
- package/build/components/UnstyledIconButton/UnstyledIconButton.js +5 -5
- package/build/components/UnstyledIconButton/UnstyledIconButton.props.d.ts +2 -1
- 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/core/themes.d.ts +12 -12
- 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/color.d.ts +12 -12
- package/build/tokens/color.js +6 -6
- package/build/tokens/components/dark/alert.d.ts +13 -0
- package/build/tokens/components/dark/alert.js +13 -0
- package/build/tokens/components/dark/checkbox.d.ts +3 -0
- package/build/tokens/components/dark/checkbox.js +3 -0
- 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/icon-button.d.ts +7 -0
- package/build/tokens/components/dark/icon-button.js +7 -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 +2 -0
- package/build/tokens/components/dark/index.js +2 -0
- package/build/tokens/components/dark/link.d.ts +5 -0
- package/build/tokens/components/dark/link.js +5 -0
- package/build/tokens/components/dark/progress-bar.d.ts +41 -0
- package/build/tokens/components/dark/progress-bar.js +40 -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/alert.d.ts +13 -0
- package/build/tokens/components/light/alert.js +13 -0
- package/build/tokens/components/light/checkbox.d.ts +3 -0
- package/build/tokens/components/light/checkbox.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/icon-button.d.ts +7 -0
- package/build/tokens/components/light/icon-button.js +7 -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 +2 -0
- package/build/tokens/components/light/index.js +2 -0
- package/build/tokens/components/light/link.d.ts +5 -0
- package/build/tokens/components/light/link.js +5 -0
- package/build/tokens/components/light/progress-bar.d.ts +41 -0
- package/build/tokens/components/light/progress-bar.js +40 -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/tokens/index.d.ts +1 -0
- package/build/tokens/index.js +1 -0
- package/build/tokens/motion.d.ts +23 -0
- package/build/tokens/motion.js +22 -0
- package/build/tokens/primitive.d.ts +19 -0
- package/build/tokens/primitive.js +19 -0
- package/build/tokens/semantic-dark.d.ts +5 -5
- package/build/tokens/semantic-dark.js +5 -5
- package/build/tokens/semantic-light.d.ts +1 -1
- package/build/tokens/semantic-light.js +1 -1
- 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/assets/bank-logo.png +0 -0
- package/docs/assets/bank-logo1.png +0 -0
- package/docs/components/AllComponents.web.tsx +43 -1
- package/docs/components/ViewWrap.tsx +32 -0
- package/docs/components/index.ts +7 -7
- package/docs/getting-started.mdx +6 -6
- package/docs/introduction.mdx +3 -3
- package/package.json +16 -12
- package/src/components/Alert/AlertCloseButton.tsx +33 -5
- package/src/components/Alert/AlertIcon.tsx +17 -1
- package/src/components/Alert/AlertIconButton.tsx +37 -4
- package/src/components/Alert/AlertLink.tsx +52 -1
- package/src/components/Alert/AlertText.tsx +28 -3
- package/src/components/Alert/AlertTitle.tsx +28 -3
- package/src/components/Badge/BadgeIcon.tsx +72 -0
- package/src/components/Badge/BadgeText.tsx +72 -0
- package/src/components/Button/ButtonRoot.tsx +1 -0
- package/src/components/Checkbox/Checkbox.docs.mdx +45 -7
- package/src/components/Checkbox/Checkbox.props.ts +3 -1
- package/src/components/Checkbox/Checkbox.stories.tsx +37 -1
- package/src/components/Checkbox/Checkbox.tsx +12 -9
- package/src/components/Checkbox/CheckboxIcon.tsx +1 -1
- package/src/components/Checkbox/CheckboxImage.tsx +9 -0
- package/src/components/Checkbox/CheckboxTileRoot.tsx +1 -1
- package/src/components/Checkbox/index.ts +3 -2
- 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/IconContainer/IconContainer.docs.mdx +4 -4
- package/src/components/Input/InputField.tsx +0 -2
- package/src/components/Input/InputSlot.tsx +14 -3
- package/src/components/Link/Link.props.ts +3 -0
- package/src/components/Link/Link.tsx +12 -6
- package/src/components/List/List.docs.mdx +24 -23
- package/src/components/Modal/Modal.stories.tsx +2 -30
- package/src/components/Radio/Radio.docs.mdx +96 -124
- package/src/components/Radio/Radio.props.ts +3 -1
- package/src/components/Radio/Radio.stories.tsx +47 -0
- package/src/components/Radio/Radio.tsx +10 -7
- package/src/components/Radio/RadioImage.tsx +9 -0
- package/src/components/Radio/RadioTileRoot.tsx +1 -1
- package/src/components/Radio/index.ts +3 -2
- package/src/components/Select/Select.docs.mdx +6 -6
- package/src/components/Select/Select.stories.tsx +7 -7
- package/src/components/Select/SelectOption.tsx +4 -10
- package/src/components/UnstyledIconButton/UnstyledIconButton.props.ts +2 -1
- package/src/components/UnstyledIconButton/UnstyledIconButton.tsx +23 -5
- 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/color.ts +6 -6
- package/src/tokens/components/dark/alert.ts +13 -0
- package/src/tokens/components/dark/checkbox.ts +3 -0
- package/src/tokens/components/dark/date-picker.ts +1 -0
- package/src/tokens/components/dark/icon-button.ts +7 -0
- package/src/tokens/components/dark/illustrations.ts +7 -0
- package/src/tokens/components/dark/index.ts +2 -0
- package/src/tokens/components/dark/link.ts +5 -0
- package/src/tokens/components/dark/progress-bar.ts +41 -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/alert.ts +13 -0
- package/src/tokens/components/light/checkbox.ts +3 -0
- package/src/tokens/components/light/date-picker.ts +1 -0
- package/src/tokens/components/light/icon-button.ts +7 -0
- package/src/tokens/components/light/illustrations.ts +7 -0
- package/src/tokens/components/light/index.ts +2 -0
- package/src/tokens/components/light/link.ts +5 -0
- package/src/tokens/components/light/progress-bar.ts +41 -0
- package/src/tokens/components/light/segmented-control.ts +2 -2
- package/src/tokens/components/light/table.ts +3 -0
- package/src/tokens/index.ts +1 -0
- package/src/tokens/motion.ts +23 -0
- package/src/tokens/primitive.ts +19 -0
- package/src/tokens/semantic-dark.ts +5 -5
- package/src/tokens/semantic-light.ts +1 -1
- package/src/utils/index.ts +1 -0
- package/src/utils/isEqual.ts +30 -0
- package/docs/assets/react-native-pig.png +0 -0
- package/docs/components/AdvancedRadioExample.tsx +0 -126
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { memo } from 'react';
|
|
3
|
+
import { View } from 'react-native';
|
|
4
|
+
import { StyleSheet } from 'react-native-unistyles';
|
|
5
|
+
import NextButton from './DatePickerNextButton';
|
|
6
|
+
import PrevButton from './DatePickerPrevButton';
|
|
7
|
+
import Selectors from './DatePickerSelectors';
|
|
8
|
+
const NavigationButtons = ({}) => (_jsxs(View, { style: styles.navigation, children: [_jsx(PrevButton, {}), _jsx(NextButton, {})] }));
|
|
9
|
+
const Header = ({ navigationPosition = 'around' }) => (_jsx(View, { style: [styles.headerContainer], children: _jsx(View, { style: styles.container, children: navigationPosition === 'left' ? (_jsxs(_Fragment, { children: [_jsx(NavigationButtons, {}), _jsx(Selectors, { position: "left" })] })) : navigationPosition === 'right' ? (_jsxs(_Fragment, { children: [_jsx(Selectors, { position: "right" }), _jsx(NavigationButtons, {})] })) : (_jsxs(_Fragment, { children: [_jsx(PrevButton, {}), _jsx(Selectors, { position: "around" }), _jsx(NextButton, {})] })) }) }));
|
|
10
|
+
const styles = StyleSheet.create(theme => ({
|
|
11
|
+
headerContainer: {
|
|
12
|
+
paddingVertical: 3,
|
|
13
|
+
},
|
|
14
|
+
container: {
|
|
15
|
+
flexDirection: 'row',
|
|
16
|
+
alignItems: 'center',
|
|
17
|
+
justifyContent: 'space-between',
|
|
18
|
+
},
|
|
19
|
+
navigation: {
|
|
20
|
+
flexDirection: 'row',
|
|
21
|
+
gap: theme.components.datePicker.header.controlGap,
|
|
22
|
+
},
|
|
23
|
+
}));
|
|
24
|
+
const customComparator = (prev, next) => {
|
|
25
|
+
const areEqual = prev.PrevIcon === next.PrevIcon &&
|
|
26
|
+
prev.NextIcon === next.NextIcon &&
|
|
27
|
+
prev.navigationPosition === next.navigationPosition;
|
|
28
|
+
return areEqual;
|
|
29
|
+
};
|
|
30
|
+
export default memo(Header, customComparator);
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Pressable, View } from 'react-native';
|
|
3
|
+
import { StyleSheet } from 'react-native-unistyles';
|
|
4
|
+
import { BodyText } from '../BodyText';
|
|
5
|
+
import { useDatePickerContext } from './DatePicker.context';
|
|
6
|
+
import { CONTAINER_HEIGHT } from './enums';
|
|
7
|
+
import { getMonthsArray, getParsedDate, isMonthDisabled } from './utils';
|
|
8
|
+
const Months = () => {
|
|
9
|
+
const { currentDate, onSelectMonth, containerHeight = CONTAINER_HEIGHT, monthsFormat = 'short', minDate, maxDate, } = useDatePickerContext();
|
|
10
|
+
const { month } = getParsedDate(currentDate);
|
|
11
|
+
return (_jsx(View, { style: styles.container, testID: "month-selector", children: _jsx(View, { style: styles.months, children: getMonthsArray().map((item, index) => {
|
|
12
|
+
const isSelected = index === month;
|
|
13
|
+
const isDisabled = isMonthDisabled(index, currentDate, {
|
|
14
|
+
minDate,
|
|
15
|
+
maxDate,
|
|
16
|
+
});
|
|
17
|
+
styles.useVariants({ isSelected, isDisabled });
|
|
18
|
+
return (_jsx(View, { style: styles.monthCell(containerHeight), children: _jsx(Pressable, { disabled: isDisabled, onPress: () => onSelectMonth(index), accessibilityRole: "button", accessibilityLabel: item.name.full, style: styles.item, children: _jsx(BodyText, { style: styles.label, children: item.name[monthsFormat] }, index) }) }, index));
|
|
19
|
+
}) }) }));
|
|
20
|
+
};
|
|
21
|
+
const styles = StyleSheet.create(theme => ({
|
|
22
|
+
container: {
|
|
23
|
+
flex: 1,
|
|
24
|
+
alignItems: 'center',
|
|
25
|
+
},
|
|
26
|
+
months: {
|
|
27
|
+
flexDirection: 'row',
|
|
28
|
+
flexWrap: 'wrap',
|
|
29
|
+
},
|
|
30
|
+
month: {
|
|
31
|
+
flex: 1,
|
|
32
|
+
alignItems: 'center',
|
|
33
|
+
justifyContent: 'center',
|
|
34
|
+
},
|
|
35
|
+
monthCell: (containerHeight) => ({
|
|
36
|
+
width: `${99.9 / 3}%`,
|
|
37
|
+
height: containerHeight / 6,
|
|
38
|
+
padding: 2,
|
|
39
|
+
}),
|
|
40
|
+
label: {
|
|
41
|
+
variants: {
|
|
42
|
+
isSelected: {
|
|
43
|
+
true: {
|
|
44
|
+
color: theme.color.text.inverted,
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
item: {
|
|
50
|
+
flex: 1,
|
|
51
|
+
alignItems: 'center',
|
|
52
|
+
justifyContent: 'center',
|
|
53
|
+
padding: 8,
|
|
54
|
+
borderRadius: theme.borderRadius.md,
|
|
55
|
+
variants: {
|
|
56
|
+
isSelected: {
|
|
57
|
+
true: {
|
|
58
|
+
backgroundColor: theme.color.surface.brand.default,
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
isDisabled: {
|
|
62
|
+
true: {
|
|
63
|
+
opacity: theme.opacity.disabled,
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
}));
|
|
69
|
+
export default Months;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { WeekdayFormat } from './DatePicker.props';
|
|
2
|
+
type WeekdaysProps = {
|
|
3
|
+
firstDayOfWeek: number;
|
|
4
|
+
weekdaysFormat?: WeekdayFormat;
|
|
5
|
+
weekdaysHeight?: number;
|
|
6
|
+
};
|
|
7
|
+
declare const _default: import("react").MemoExoticComponent<({ firstDayOfWeek, weekdaysFormat, weekdaysHeight, }: WeekdaysProps) => import("react/jsx-runtime").JSX.Element>;
|
|
8
|
+
export default _default;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { memo } from 'react';
|
|
3
|
+
import { View } from 'react-native';
|
|
4
|
+
import { StyleSheet } from 'react-native-unistyles';
|
|
5
|
+
import { BodyText } from '../BodyText';
|
|
6
|
+
import { WEEKDAYS_HEIGHT } from './enums';
|
|
7
|
+
import { getWeekdays } from './utils';
|
|
8
|
+
const Weekdays = ({ firstDayOfWeek, weekdaysFormat = 'min', weekdaysHeight = WEEKDAYS_HEIGHT, }) => {
|
|
9
|
+
return (_jsx(View, { style: [styles.container(weekdaysHeight)], testID: "weekdays", children: getWeekdays(firstDayOfWeek)?.map((weekday, index) => (_jsx(View, { style: [styles.weekday], children: _jsx(BodyText, { style: styles.text, accessible: false, children: weekday.name[weekdaysFormat] }) }, index))) }));
|
|
10
|
+
};
|
|
11
|
+
const styles = StyleSheet.create(theme => ({
|
|
12
|
+
container: (weekdaysHeight) => ({
|
|
13
|
+
height: weekdaysHeight,
|
|
14
|
+
flexDirection: 'row',
|
|
15
|
+
alignItems: 'center',
|
|
16
|
+
}),
|
|
17
|
+
text: {
|
|
18
|
+
color: theme.color.text.secondary,
|
|
19
|
+
},
|
|
20
|
+
weekday: {
|
|
21
|
+
width: `${99.9 / 7}%`,
|
|
22
|
+
alignItems: 'center',
|
|
23
|
+
justifyContent: 'center',
|
|
24
|
+
},
|
|
25
|
+
}));
|
|
26
|
+
export default memo(Weekdays);
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback } from 'react';
|
|
3
|
+
import { Pressable, View } from 'react-native';
|
|
4
|
+
import { StyleSheet } from 'react-native-unistyles';
|
|
5
|
+
import { BodyText } from '../BodyText';
|
|
6
|
+
import { useDatePickerContext } from './DatePicker.context';
|
|
7
|
+
import { CONTAINER_HEIGHT } from './enums';
|
|
8
|
+
import { formatNumber, getDateYear, getYearRange, isYearDisabled } from './utils';
|
|
9
|
+
const Years = () => {
|
|
10
|
+
const { mode, numerals = 'latn', currentDate, currentYear, date, onSelectYear, containerHeight = CONTAINER_HEIGHT, minDate, maxDate, } = useDatePickerContext();
|
|
11
|
+
const selectedYear = getDateYear(date);
|
|
12
|
+
const generateCells = useCallback(() => {
|
|
13
|
+
const years = getYearRange(currentYear);
|
|
14
|
+
const activeYear = getDateYear(currentDate);
|
|
15
|
+
const column = years.map(year => {
|
|
16
|
+
const isSelected = year === selectedYear;
|
|
17
|
+
const isActivated = year === activeYear;
|
|
18
|
+
const isDisabled = isYearDisabled(year, { minDate, maxDate });
|
|
19
|
+
styles.useVariants({ isSelected, isDisabled, isActivated });
|
|
20
|
+
return (_jsx(View, { style: styles.yearCell(containerHeight), children: _jsx(Pressable, { disabled: isDisabled, onPress: () => onSelectYear(year), accessibilityRole: "button", accessibilityLabel: year.toString(), style: styles.year, children: _jsx(BodyText, { style: styles.label, children: formatNumber(year, numerals) }, year) }) }, year));
|
|
21
|
+
});
|
|
22
|
+
return column;
|
|
23
|
+
}, [
|
|
24
|
+
onSelectYear,
|
|
25
|
+
selectedYear,
|
|
26
|
+
currentYear,
|
|
27
|
+
currentDate,
|
|
28
|
+
styles,
|
|
29
|
+
mode,
|
|
30
|
+
minDate,
|
|
31
|
+
maxDate,
|
|
32
|
+
numerals,
|
|
33
|
+
]);
|
|
34
|
+
return (_jsx(View, { style: [styles.container, styles.years], testID: "year-selector", children: _jsx(View, { style: styles.years, children: generateCells() }) }));
|
|
35
|
+
};
|
|
36
|
+
const styles = StyleSheet.create(theme => ({
|
|
37
|
+
container: {
|
|
38
|
+
flex: 1,
|
|
39
|
+
alignItems: 'center',
|
|
40
|
+
justifyContent: 'center',
|
|
41
|
+
},
|
|
42
|
+
years: {
|
|
43
|
+
flexDirection: 'row',
|
|
44
|
+
flexWrap: 'wrap',
|
|
45
|
+
},
|
|
46
|
+
year: {
|
|
47
|
+
flex: 1,
|
|
48
|
+
alignItems: 'center',
|
|
49
|
+
justifyContent: 'center',
|
|
50
|
+
padding: 8,
|
|
51
|
+
borderRadius: theme.borderRadius.md,
|
|
52
|
+
variants: {
|
|
53
|
+
isActivated: {
|
|
54
|
+
true: {
|
|
55
|
+
backgroundColor: theme.color.surface.brand.default,
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
isDisabled: {
|
|
59
|
+
true: {
|
|
60
|
+
opacity: theme.opacity.disabled,
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
isSelected: {
|
|
64
|
+
true: {},
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
yearCell: (containerHeight) => ({
|
|
69
|
+
width: `${99.9 / 3}%`,
|
|
70
|
+
height: containerHeight / 6,
|
|
71
|
+
padding: 2,
|
|
72
|
+
}),
|
|
73
|
+
label: {
|
|
74
|
+
variants: {
|
|
75
|
+
isActivated: {
|
|
76
|
+
true: {
|
|
77
|
+
color: theme.color.text.inverted,
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
}));
|
|
83
|
+
export default Years;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import dayjs from 'dayjs';
|
|
3
|
+
import { useCallback, useMemo } from 'react';
|
|
4
|
+
import { ScrollView, View } from 'react-native';
|
|
5
|
+
import { StyleSheet } from 'react-native-unistyles';
|
|
6
|
+
import { BodyText } from '../BodyText';
|
|
7
|
+
import { useDatePickerContext } from './DatePicker.context';
|
|
8
|
+
import { CONTAINER_HEIGHT } from './enums';
|
|
9
|
+
import PeriodPicker from './time-picker/period-picker';
|
|
10
|
+
import Wheel from './time-picker/wheel';
|
|
11
|
+
import { formatNumber, getParsedDate } from './utils';
|
|
12
|
+
const createNumberList = (num, numerals, startFrom = 0) => {
|
|
13
|
+
return Array.from({ length: num }, (_, i) => ({
|
|
14
|
+
value: i + startFrom,
|
|
15
|
+
text: i + startFrom < 10
|
|
16
|
+
? `${formatNumber(0, numerals)}${formatNumber(i + startFrom, numerals)}`
|
|
17
|
+
: `${formatNumber(i + startFrom, numerals)}`,
|
|
18
|
+
}));
|
|
19
|
+
};
|
|
20
|
+
const TimePicker = () => {
|
|
21
|
+
const { currentDate, date, onSelectDate, timeZone, numerals = 'latn', use12Hours, } = useDatePickerContext();
|
|
22
|
+
const hours = useMemo(() => createNumberList(use12Hours ? 12 : 24, numerals, use12Hours ? 1 : 0), [numerals, use12Hours]);
|
|
23
|
+
const minutes = useMemo(() => createNumberList(60, numerals), [numerals]);
|
|
24
|
+
const { hour, hour12, minute, period } = getParsedDate(date || currentDate);
|
|
25
|
+
const handleChangeHour = useCallback((value) => {
|
|
26
|
+
let hour24 = value;
|
|
27
|
+
if (use12Hours) {
|
|
28
|
+
if (period === 'AM' && value === 12) {
|
|
29
|
+
hour24 = 0;
|
|
30
|
+
}
|
|
31
|
+
else if (period === 'PM' && value < 12) {
|
|
32
|
+
hour24 = value + 12;
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
hour24 = value;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
const newDate = dayjs.tz(date, timeZone).hour(hour24).minute(minute);
|
|
39
|
+
onSelectDate(newDate);
|
|
40
|
+
}, [date, onSelectDate, timeZone, use12Hours, period, minute]);
|
|
41
|
+
const handleChangeMinute = useCallback((value) => {
|
|
42
|
+
const newDate = dayjs.tz(date, timeZone).minute(value);
|
|
43
|
+
onSelectDate(newDate);
|
|
44
|
+
}, [date, onSelectDate, timeZone]);
|
|
45
|
+
const handlePeriodChange = useCallback((newPeriod) => {
|
|
46
|
+
let newHour = hour12;
|
|
47
|
+
if (newPeriod === 'PM' && hour12 < 12) {
|
|
48
|
+
newHour = hour12 + 12;
|
|
49
|
+
}
|
|
50
|
+
else if (newPeriod === 'AM' && hour12 === 12) {
|
|
51
|
+
newHour = 0;
|
|
52
|
+
}
|
|
53
|
+
else if (newPeriod === 'AM' && hour >= 12) {
|
|
54
|
+
newHour = hour12;
|
|
55
|
+
}
|
|
56
|
+
const newDate = dayjs.tz(date || currentDate, timeZone).hour(newHour);
|
|
57
|
+
onSelectDate(newDate);
|
|
58
|
+
}, [date, currentDate, onSelectDate, timeZone, hour, hour12]);
|
|
59
|
+
return (_jsxs(ScrollView, { horizontal: true, scrollEnabled: false, contentContainerStyle: styles.container, testID: "time-selector", children: [_jsxs(View, { style: styles.timePickerContainer, children: [_jsx(View, { style: styles.wheelContainer, children: _jsx(Wheel, { value: use12Hours ? hour12 : hour, items: hours, setValue: handleChangeHour }) }), _jsx(BodyText, { style: styles.timeSeparator, children: ":" }), _jsx(View, { style: styles.wheelContainer, children: _jsx(Wheel, { value: minute, items: minutes, setValue: handleChangeMinute }) })] }), use12Hours && period ? (_jsx(View, { style: styles.periodContainer, children: _jsx(PeriodPicker, { value: period, setValue: handlePeriodChange }) })) : null] }));
|
|
60
|
+
};
|
|
61
|
+
const styles = StyleSheet.create({
|
|
62
|
+
container: {
|
|
63
|
+
flex: 1,
|
|
64
|
+
alignItems: 'center',
|
|
65
|
+
justifyContent: 'center',
|
|
66
|
+
},
|
|
67
|
+
wheelContainer: {
|
|
68
|
+
flex: 1,
|
|
69
|
+
},
|
|
70
|
+
timePickerContainer: {
|
|
71
|
+
alignItems: 'center',
|
|
72
|
+
justifyContent: 'center',
|
|
73
|
+
width: CONTAINER_HEIGHT / 2,
|
|
74
|
+
height: CONTAINER_HEIGHT / 2,
|
|
75
|
+
flexDirection: 'row',
|
|
76
|
+
},
|
|
77
|
+
timeSeparator: {
|
|
78
|
+
marginHorizontal: 5,
|
|
79
|
+
},
|
|
80
|
+
periodContainer: {
|
|
81
|
+
marginLeft: 10,
|
|
82
|
+
},
|
|
83
|
+
});
|
|
84
|
+
export default TimePicker;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type CalendarViews = 'day' | 'month' | 'year' | 'time';
|
|
2
|
+
export declare enum CalendarActionKind {
|
|
3
|
+
SET_CALENDAR_VIEW = "SET_CALENDAR_VIEW",
|
|
4
|
+
CHANGE_CURRENT_DATE = "CHANGE_CURRENT_DATE",
|
|
5
|
+
CHANGE_CURRENT_YEAR = "CHANGE_CURRENT_YEAR",
|
|
6
|
+
CHANGE_SELECTED_DATE = "CHANGE_SELECTED_DATE",
|
|
7
|
+
CHANGE_SELECTED_RANGE = "CHANGE_SELECTED_RANGE",
|
|
8
|
+
CHANGE_SELECTED_MULTIPLE = "CHANGE_SELECTED_MULTIPLE",
|
|
9
|
+
RESET_STATE = "RESET_STATE"
|
|
10
|
+
}
|
|
11
|
+
export declare const CONTAINER_HEIGHT = 300;
|
|
12
|
+
export declare const WEEKDAYS_HEIGHT = 25;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export var CalendarActionKind;
|
|
2
|
+
(function (CalendarActionKind) {
|
|
3
|
+
CalendarActionKind["SET_CALENDAR_VIEW"] = "SET_CALENDAR_VIEW";
|
|
4
|
+
CalendarActionKind["CHANGE_CURRENT_DATE"] = "CHANGE_CURRENT_DATE";
|
|
5
|
+
CalendarActionKind["CHANGE_CURRENT_YEAR"] = "CHANGE_CURRENT_YEAR";
|
|
6
|
+
CalendarActionKind["CHANGE_SELECTED_DATE"] = "CHANGE_SELECTED_DATE";
|
|
7
|
+
CalendarActionKind["CHANGE_SELECTED_RANGE"] = "CHANGE_SELECTED_RANGE";
|
|
8
|
+
CalendarActionKind["CHANGE_SELECTED_MULTIPLE"] = "CHANGE_SELECTED_MULTIPLE";
|
|
9
|
+
CalendarActionKind["RESET_STATE"] = "RESET_STATE";
|
|
10
|
+
})(CalendarActionKind || (CalendarActionKind = {}));
|
|
11
|
+
export const CONTAINER_HEIGHT = 300;
|
|
12
|
+
export const WEEKDAYS_HEIGHT = 25;
|
|
File without changes
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// @ts-ignore
|
|
3
|
+
Date.prototype._toLocaleString = Date.prototype.toLocaleString;
|
|
4
|
+
// @ts-ignore
|
|
5
|
+
Date.prototype.toLocaleString = function (a, b) {
|
|
6
|
+
if (b && Object.keys(b).length === 1 && 'timeZone' in b && a === 'en-US') {
|
|
7
|
+
return Intl.DateTimeFormat('en-us', {
|
|
8
|
+
year: 'numeric',
|
|
9
|
+
month: '2-digit',
|
|
10
|
+
day: '2-digit',
|
|
11
|
+
hour: '2-digit',
|
|
12
|
+
minute: '2-digit',
|
|
13
|
+
second: '2-digit',
|
|
14
|
+
hour12: false,
|
|
15
|
+
timeZone: b.timeZone,
|
|
16
|
+
})
|
|
17
|
+
.format(this)
|
|
18
|
+
.replace(/(\d{2})\/(\d{2})\/(\d{4}),/g, '$3-$1-$2');
|
|
19
|
+
}
|
|
20
|
+
// @ts-ignore
|
|
21
|
+
return this._toLocaleString(a, b);
|
|
22
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Animated } from 'react-native';
|
|
2
|
+
const FACTORIAL_3 = 3 * 2;
|
|
3
|
+
const FACTORIAL_5 = 5 * 4 * FACTORIAL_3;
|
|
4
|
+
const FACTORIAL_7 = 7 * 6 * FACTORIAL_5;
|
|
5
|
+
function sin(animated) {
|
|
6
|
+
const normalized = normalize(animated);
|
|
7
|
+
const square = Animated.multiply(normalized, normalized);
|
|
8
|
+
const pow3 = Animated.multiply(normalized, square);
|
|
9
|
+
const pow5 = Animated.multiply(pow3, square);
|
|
10
|
+
const pow7 = Animated.multiply(pow5, square);
|
|
11
|
+
return Animated.add(Animated.add(normalized, Animated.multiply(pow3, -1 / FACTORIAL_3)), Animated.add(Animated.multiply(pow5, 1 / FACTORIAL_5), Animated.multiply(pow7, -1 / FACTORIAL_7)));
|
|
12
|
+
}
|
|
13
|
+
function normalize(animated) {
|
|
14
|
+
return Animated.add(Animated.modulo(Animated.add(animated, Math.PI), Math.PI * 2), -Math.PI).interpolate({
|
|
15
|
+
inputRange: [-Math.PI, -Math.PI / 2, Math.PI / 2, Math.PI],
|
|
16
|
+
outputRange: [0, -Math.PI / 2, Math.PI / 2, 0],
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
export { sin, normalize };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { memo } from 'react';
|
|
3
|
+
import WheelPicker from './wheel-picker';
|
|
4
|
+
const options = [
|
|
5
|
+
{ value: 'AM', text: 'AM' },
|
|
6
|
+
{ value: 'PM', text: 'PM' },
|
|
7
|
+
];
|
|
8
|
+
const PeriodNative = ({ value, setValue = () => { } }) => {
|
|
9
|
+
return (_jsx(WheelPicker, { value: value, options: options, onChange: setValue,
|
|
10
|
+
//containerStyle={defaultStyles.container}
|
|
11
|
+
itemHeight: 44, decelerationRate: "fast" }));
|
|
12
|
+
};
|
|
13
|
+
const customComparator = (prev, next) => {
|
|
14
|
+
const areEqual = prev.value === next.value && prev.setValue === next.setValue;
|
|
15
|
+
return areEqual;
|
|
16
|
+
};
|
|
17
|
+
export default memo(PeriodNative, customComparator);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { memo } from 'react';
|
|
3
|
+
import { Platform } from 'react-native';
|
|
4
|
+
import PeriodNative from './period-native';
|
|
5
|
+
import PeriodWeb from './period-web';
|
|
6
|
+
const PeriodPicker = (props) => {
|
|
7
|
+
const Component = Platform.OS === 'web' ? PeriodWeb : PeriodNative;
|
|
8
|
+
return _jsx(Component, { ...props });
|
|
9
|
+
};
|
|
10
|
+
export default memo(PeriodPicker);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { memo } from 'react';
|
|
3
|
+
import { Pressable, View } from 'react-native';
|
|
4
|
+
import { StyleSheet } from 'react-native-unistyles';
|
|
5
|
+
import { BodyText } from '../../BodyText';
|
|
6
|
+
const PeriodWeb = ({ value, setValue = () => { } }) => {
|
|
7
|
+
return (_jsx(Pressable, { onPress: () => setValue(value == 'AM' ? 'PM' : 'AM'), children: _jsx(View, { style: [styles.period], children: _jsx(BodyText, { children: value }) }) }));
|
|
8
|
+
};
|
|
9
|
+
const styles = StyleSheet.create({
|
|
10
|
+
period: {
|
|
11
|
+
width: 65,
|
|
12
|
+
height: 44,
|
|
13
|
+
alignItems: 'center',
|
|
14
|
+
justifyContent: 'center',
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
const customComparator = (prev, next) => {
|
|
18
|
+
const areEqual = prev.value === next.value && prev.setValue === next.setValue;
|
|
19
|
+
return areEqual;
|
|
20
|
+
};
|
|
21
|
+
export default memo(PeriodWeb, customComparator);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { PickerOption } from '../DatePicker.props';
|
|
2
|
+
interface WheelProps {
|
|
3
|
+
value: number | string;
|
|
4
|
+
setValue?: (value: any) => void;
|
|
5
|
+
items: PickerOption[];
|
|
6
|
+
}
|
|
7
|
+
declare const _default: import("react").MemoExoticComponent<({ value, setValue, items }: WheelProps) => import("react/jsx-runtime").JSX.Element>;
|
|
8
|
+
export default _default;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { memo } from 'react';
|
|
3
|
+
import { Platform } from 'react-native';
|
|
4
|
+
import { StyleSheet } from 'react-native-unistyles';
|
|
5
|
+
import WheelPicker from './wheel-picker';
|
|
6
|
+
const WheelNative = ({ value, setValue = () => { }, items }) => {
|
|
7
|
+
return (_jsx(WheelPicker, { value: value, options: items, onChange: setValue, containerStyle: styles.container, itemHeight: 44, decelerationRate: "fast" }));
|
|
8
|
+
};
|
|
9
|
+
const styles = StyleSheet.create({
|
|
10
|
+
container: {
|
|
11
|
+
display: 'flex',
|
|
12
|
+
...Platform.select({
|
|
13
|
+
web: {
|
|
14
|
+
userSelect: 'none',
|
|
15
|
+
},
|
|
16
|
+
}),
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
export default memo(WheelNative);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Animated, StyleProp, ViewStyle } from 'react-native';
|
|
3
|
+
import { PickerOption } from '../../DatePicker.props';
|
|
4
|
+
interface ItemProps {
|
|
5
|
+
style: StyleProp<ViewStyle>;
|
|
6
|
+
option: PickerOption | null;
|
|
7
|
+
height: number;
|
|
8
|
+
index: number;
|
|
9
|
+
currentScrollIndex: Animated.AnimatedAddition<number>;
|
|
10
|
+
visibleRest: number;
|
|
11
|
+
rotationFunction: (x: number) => number;
|
|
12
|
+
opacityFunction: (x: number) => number;
|
|
13
|
+
scaleFunction: (x: number) => number;
|
|
14
|
+
}
|
|
15
|
+
declare const _default: React.NamedExoticComponent<ItemProps>;
|
|
16
|
+
export default _default;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { Animated } from 'react-native';
|
|
4
|
+
import { BodyText } from '../../../BodyText';
|
|
5
|
+
import styles from './wheel-picker.style';
|
|
6
|
+
const WheelPickerItem = ({ style, height, option, index, visibleRest, currentScrollIndex, opacityFunction, rotationFunction, scaleFunction, }) => {
|
|
7
|
+
const relativeScrollIndex = Animated.subtract(index, currentScrollIndex);
|
|
8
|
+
const translateY = relativeScrollIndex.interpolate({
|
|
9
|
+
inputRange: (() => {
|
|
10
|
+
const range = [0];
|
|
11
|
+
for (let i = 1; i <= visibleRest + 1; i++) {
|
|
12
|
+
range.unshift(-i);
|
|
13
|
+
range.push(i);
|
|
14
|
+
}
|
|
15
|
+
return range;
|
|
16
|
+
})(),
|
|
17
|
+
outputRange: (() => {
|
|
18
|
+
const range = [0];
|
|
19
|
+
for (let i = 1; i <= visibleRest + 1; i++) {
|
|
20
|
+
let y = (height / 2) * (1 - Math.sin(Math.PI / 2 - rotationFunction(i)));
|
|
21
|
+
for (let j = 1; j < i; j++) {
|
|
22
|
+
y += height * (1 - Math.sin(Math.PI / 2 - rotationFunction(j)));
|
|
23
|
+
}
|
|
24
|
+
range.unshift(y);
|
|
25
|
+
range.push(-y);
|
|
26
|
+
}
|
|
27
|
+
return range;
|
|
28
|
+
})(),
|
|
29
|
+
});
|
|
30
|
+
const opacity = relativeScrollIndex.interpolate({
|
|
31
|
+
inputRange: (() => {
|
|
32
|
+
const range = [0];
|
|
33
|
+
for (let i = 1; i <= visibleRest + 1; i++) {
|
|
34
|
+
range.unshift(-i);
|
|
35
|
+
range.push(i);
|
|
36
|
+
}
|
|
37
|
+
return range;
|
|
38
|
+
})(),
|
|
39
|
+
outputRange: (() => {
|
|
40
|
+
const range = [1];
|
|
41
|
+
for (let x = 1; x <= visibleRest + 1; x++) {
|
|
42
|
+
const y = opacityFunction(x);
|
|
43
|
+
range.unshift(y);
|
|
44
|
+
range.push(y);
|
|
45
|
+
}
|
|
46
|
+
return range;
|
|
47
|
+
})(),
|
|
48
|
+
});
|
|
49
|
+
const scale = relativeScrollIndex.interpolate({
|
|
50
|
+
inputRange: (() => {
|
|
51
|
+
const range = [0];
|
|
52
|
+
for (let i = 1; i <= visibleRest + 1; i++) {
|
|
53
|
+
range.unshift(-i);
|
|
54
|
+
range.push(i);
|
|
55
|
+
}
|
|
56
|
+
return range;
|
|
57
|
+
})(),
|
|
58
|
+
outputRange: (() => {
|
|
59
|
+
const range = [1.0];
|
|
60
|
+
for (let x = 1; x <= visibleRest + 1; x++) {
|
|
61
|
+
const y = scaleFunction(x);
|
|
62
|
+
range.unshift(y);
|
|
63
|
+
range.push(y);
|
|
64
|
+
}
|
|
65
|
+
return range;
|
|
66
|
+
})(),
|
|
67
|
+
});
|
|
68
|
+
const rotateX = relativeScrollIndex.interpolate({
|
|
69
|
+
inputRange: (() => {
|
|
70
|
+
const range = [0];
|
|
71
|
+
for (let i = 1; i <= visibleRest + 1; i++) {
|
|
72
|
+
range.unshift(-i);
|
|
73
|
+
range.push(i);
|
|
74
|
+
}
|
|
75
|
+
return range;
|
|
76
|
+
})(),
|
|
77
|
+
outputRange: (() => {
|
|
78
|
+
const range = ['0deg'];
|
|
79
|
+
for (let x = 1; x <= visibleRest + 1; x++) {
|
|
80
|
+
const y = rotationFunction(x);
|
|
81
|
+
range.unshift(`${y}deg`);
|
|
82
|
+
range.push(`${y}deg`);
|
|
83
|
+
}
|
|
84
|
+
return range;
|
|
85
|
+
})(),
|
|
86
|
+
});
|
|
87
|
+
return (_jsx(Animated.View, { style: [
|
|
88
|
+
styles.option,
|
|
89
|
+
style,
|
|
90
|
+
{
|
|
91
|
+
height,
|
|
92
|
+
opacity,
|
|
93
|
+
transform: [{ translateY }, { rotateX }, { scale }],
|
|
94
|
+
},
|
|
95
|
+
], children: _jsx(BodyText, { children: option?.text }) }));
|
|
96
|
+
};
|
|
97
|
+
export default React.memo(WheelPickerItem);
|