@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,21 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { FlatListProps, StyleProp, ViewProps, ViewStyle } from 'react-native';
|
|
3
|
+
import { PickerOption } from '../../DatePicker.props';
|
|
4
|
+
interface Props {
|
|
5
|
+
value: number | string;
|
|
6
|
+
options: PickerOption[];
|
|
7
|
+
onChange: (index: number | string) => void;
|
|
8
|
+
selectedIndicatorStyle?: StyleProp<ViewStyle>;
|
|
9
|
+
itemStyle?: ViewStyle;
|
|
10
|
+
itemHeight?: number;
|
|
11
|
+
containerStyle?: ViewStyle;
|
|
12
|
+
containerProps?: Omit<ViewProps, 'style'>;
|
|
13
|
+
scaleFunction?: (x: number) => number;
|
|
14
|
+
rotationFunction?: (x: number) => number;
|
|
15
|
+
opacityFunction?: (x: number) => number;
|
|
16
|
+
visibleRest?: number;
|
|
17
|
+
decelerationRate?: 'normal' | 'fast' | number;
|
|
18
|
+
flatListProps?: Omit<FlatListProps<PickerOption | null>, 'data' | 'renderItem'>;
|
|
19
|
+
}
|
|
20
|
+
declare const _default: React.NamedExoticComponent<Props>;
|
|
21
|
+
export default _default;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { memo, useEffect, useMemo, useRef, useState } from 'react';
|
|
3
|
+
import { Animated, Platform, View, } from 'react-native';
|
|
4
|
+
import WheelPickerItem from './wheel-picker-item';
|
|
5
|
+
import styles from './wheel-picker.style';
|
|
6
|
+
const WheelPicker = ({ value, options, onChange, selectedIndicatorStyle = {}, containerStyle = {}, itemStyle = {}, itemHeight = 40, scaleFunction = (x) => 1.0 ** x, rotationFunction = (x) => 1 - Math.pow(1 / 2, x), opacityFunction = (x) => Math.pow(1 / 3, x), visibleRest = 2, decelerationRate = 'normal', containerProps = {}, flatListProps = {}, }) => {
|
|
7
|
+
const momentumStarted = useRef(false);
|
|
8
|
+
const selectedIndex = options.findIndex(item => item.value === value);
|
|
9
|
+
const flatListRef = useRef(null);
|
|
10
|
+
const [scrollY] = useState(new Animated.Value(selectedIndex * itemHeight));
|
|
11
|
+
const containerHeight = (1 + visibleRest * 2) * itemHeight;
|
|
12
|
+
const paddedOptions = useMemo(() => {
|
|
13
|
+
const array = [...options];
|
|
14
|
+
for (let i = 0; i < visibleRest; i++) {
|
|
15
|
+
array.unshift(null);
|
|
16
|
+
array.push(null);
|
|
17
|
+
}
|
|
18
|
+
return array;
|
|
19
|
+
}, [options, visibleRest]);
|
|
20
|
+
const offsets = useMemo(() => [...Array(paddedOptions.length)].map((_, i) => i * itemHeight), [paddedOptions, itemHeight]);
|
|
21
|
+
const currentScrollIndex = useMemo(() => Animated.add(Animated.divide(scrollY, itemHeight), visibleRest), [visibleRest, scrollY, itemHeight]);
|
|
22
|
+
const handleScrollEnd = (event) => {
|
|
23
|
+
const offsetY = Math.min(itemHeight * (options.length - 1), Math.max(event.nativeEvent.contentOffset.y, 0));
|
|
24
|
+
let index = Math.floor(offsetY / itemHeight);
|
|
25
|
+
const remainder = offsetY % itemHeight;
|
|
26
|
+
if (remainder > itemHeight / 2) {
|
|
27
|
+
index++;
|
|
28
|
+
}
|
|
29
|
+
if (index !== selectedIndex) {
|
|
30
|
+
onChange(options[index]?.value || 0);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
const handleMomentumScrollBegin = () => {
|
|
34
|
+
momentumStarted.current = true;
|
|
35
|
+
};
|
|
36
|
+
const handleMomentumScrollEnd = (event) => {
|
|
37
|
+
momentumStarted.current = false;
|
|
38
|
+
handleScrollEnd(event);
|
|
39
|
+
};
|
|
40
|
+
const handleScrollEndDrag = (event) => {
|
|
41
|
+
// Capture the offset value immediately
|
|
42
|
+
const offsetY = event.nativeEvent.contentOffset?.y;
|
|
43
|
+
// We'll start a short timer to see if momentum scroll begins
|
|
44
|
+
setTimeout(() => {
|
|
45
|
+
// If momentum scroll hasn't started within the timeout,
|
|
46
|
+
// then it was a slow scroll that won't trigger momentum
|
|
47
|
+
if (!momentumStarted.current && offsetY !== undefined) {
|
|
48
|
+
// Create a synthetic event with just the data we need
|
|
49
|
+
const syntheticEvent = {
|
|
50
|
+
nativeEvent: {
|
|
51
|
+
contentOffset: { y: offsetY },
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
handleScrollEnd(syntheticEvent);
|
|
55
|
+
}
|
|
56
|
+
}, 50);
|
|
57
|
+
};
|
|
58
|
+
useEffect(() => {
|
|
59
|
+
if (selectedIndex < 0 || selectedIndex >= options.length) {
|
|
60
|
+
throw new Error(`Selected index ${selectedIndex} is out of bounds [0, ${options.length - 1}]`);
|
|
61
|
+
}
|
|
62
|
+
}, [selectedIndex, options]);
|
|
63
|
+
/**
|
|
64
|
+
* If selectedIndex is changed from outside (not via onChange) we need to scroll to the specified index.
|
|
65
|
+
* This ensures that what the user sees as selected in the picker always corresponds to the value state.
|
|
66
|
+
*/
|
|
67
|
+
useEffect(() => {
|
|
68
|
+
flatListRef.current?.scrollToIndex({
|
|
69
|
+
index: selectedIndex,
|
|
70
|
+
animated: Platform.OS === 'ios',
|
|
71
|
+
});
|
|
72
|
+
}, [selectedIndex, itemHeight]);
|
|
73
|
+
return (_jsxs(View, { style: [styles.container, { height: containerHeight }, containerStyle], ...containerProps, children: [_jsx(View, { style: [
|
|
74
|
+
styles.selectedIndicator,
|
|
75
|
+
selectedIndicatorStyle,
|
|
76
|
+
{
|
|
77
|
+
transform: [{ translateY: -itemHeight / 2 }],
|
|
78
|
+
height: itemHeight,
|
|
79
|
+
},
|
|
80
|
+
] }), _jsx(Animated.FlatList, { ...flatListProps, ref: flatListRef, nestedScrollEnabled: true, style: styles.scrollView, showsVerticalScrollIndicator: false, onScroll: Animated.event([{ nativeEvent: { contentOffset: { y: scrollY } } }], {
|
|
81
|
+
useNativeDriver: true,
|
|
82
|
+
}), onScrollEndDrag: handleScrollEndDrag, onMomentumScrollBegin: handleMomentumScrollBegin, onMomentumScrollEnd: handleMomentumScrollEnd, snapToOffsets: offsets, decelerationRate: decelerationRate, initialScrollIndex: selectedIndex, getItemLayout: (_, index) => ({
|
|
83
|
+
length: itemHeight,
|
|
84
|
+
offset: itemHeight * index,
|
|
85
|
+
index,
|
|
86
|
+
}), data: paddedOptions, keyExtractor: (item, index) => item ? `${item.value}-${item.text}-${index}` : `null-${index}`, renderItem: ({ item: option, index }) => (_jsx(WheelPickerItem, { index: index, option: option, style: itemStyle, height: itemHeight, currentScrollIndex: currentScrollIndex, scaleFunction: scaleFunction, rotationFunction: rotationFunction, opacityFunction: opacityFunction, visibleRest: visibleRest }, `option-${index}`)) })] }));
|
|
87
|
+
};
|
|
88
|
+
export default memo(WheelPicker);
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
container: {
|
|
3
|
+
position: "relative";
|
|
4
|
+
};
|
|
5
|
+
selectedIndicator: {
|
|
6
|
+
position: "absolute";
|
|
7
|
+
width: "100%";
|
|
8
|
+
top: "50%";
|
|
9
|
+
};
|
|
10
|
+
scrollView: {
|
|
11
|
+
overflow: "hidden";
|
|
12
|
+
flex: number;
|
|
13
|
+
};
|
|
14
|
+
option: {
|
|
15
|
+
alignItems: "center";
|
|
16
|
+
justifyContent: "center";
|
|
17
|
+
paddingHorizontal: number;
|
|
18
|
+
zIndex: number;
|
|
19
|
+
};
|
|
20
|
+
} & {
|
|
21
|
+
useVariants: (variants: never) => void;
|
|
22
|
+
};
|
|
23
|
+
export default _default;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { StyleSheet } from 'react-native-unistyles';
|
|
2
|
+
export default StyleSheet.create({
|
|
3
|
+
container: {
|
|
4
|
+
position: 'relative',
|
|
5
|
+
},
|
|
6
|
+
selectedIndicator: {
|
|
7
|
+
position: 'absolute',
|
|
8
|
+
width: '100%',
|
|
9
|
+
top: '50%',
|
|
10
|
+
},
|
|
11
|
+
scrollView: {
|
|
12
|
+
overflow: 'hidden',
|
|
13
|
+
flex: 1,
|
|
14
|
+
},
|
|
15
|
+
option: {
|
|
16
|
+
alignItems: 'center',
|
|
17
|
+
justifyContent: 'center',
|
|
18
|
+
paddingHorizontal: 16,
|
|
19
|
+
zIndex: 100,
|
|
20
|
+
},
|
|
21
|
+
});
|
|
@@ -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,148 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { memo, useMemo, useRef } from 'react';
|
|
3
|
+
import { Animated, PanResponder, Platform, View } from 'react-native';
|
|
4
|
+
import { StyleSheet } from 'react-native-unistyles';
|
|
5
|
+
import { isEqual } from '../../../utils';
|
|
6
|
+
import { BodyText } from '../../BodyText';
|
|
7
|
+
import { CONTAINER_HEIGHT } from '../enums';
|
|
8
|
+
import { sin } from './animated-math';
|
|
9
|
+
const ITEM_HEIGHT = 44;
|
|
10
|
+
const WheelWeb = ({ value, setValue = () => { }, items }) => {
|
|
11
|
+
const displayCount = 5;
|
|
12
|
+
const translateY = useRef(new Animated.Value(0)).current;
|
|
13
|
+
const renderCount = displayCount * 2 < items.length ? displayCount * 8 : displayCount * 2 - 1;
|
|
14
|
+
const circular = items.length >= displayCount;
|
|
15
|
+
const height = 140;
|
|
16
|
+
const radius = height / 2;
|
|
17
|
+
const valueIndex = useMemo(() => {
|
|
18
|
+
return Math.max(0, items.findIndex(item => item.value === value));
|
|
19
|
+
}, [items, value]);
|
|
20
|
+
const panResponder = useMemo(() => {
|
|
21
|
+
return PanResponder.create({
|
|
22
|
+
onMoveShouldSetPanResponder: () => true,
|
|
23
|
+
onStartShouldSetPanResponderCapture: () => true,
|
|
24
|
+
onPanResponderGrant: () => {
|
|
25
|
+
translateY.setValue(0);
|
|
26
|
+
},
|
|
27
|
+
onPanResponderMove: (evt, gestureState) => {
|
|
28
|
+
translateY.setValue(gestureState.dy);
|
|
29
|
+
evt.stopPropagation();
|
|
30
|
+
},
|
|
31
|
+
onPanResponderRelease: (_, gestureState) => {
|
|
32
|
+
translateY.extractOffset();
|
|
33
|
+
let newValueIndex = valueIndex - Math.round(gestureState.dy / ((radius * 2) / displayCount));
|
|
34
|
+
if (circular) {
|
|
35
|
+
newValueIndex = (newValueIndex + items.length) % items.length;
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
if (newValueIndex < 0) {
|
|
39
|
+
newValueIndex = 0;
|
|
40
|
+
}
|
|
41
|
+
else if (newValueIndex >= items.length) {
|
|
42
|
+
newValueIndex = items.length - 1;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
const newValue = items[newValueIndex];
|
|
46
|
+
if (newValue?.value === value) {
|
|
47
|
+
translateY.setOffset(0);
|
|
48
|
+
translateY.setValue(0);
|
|
49
|
+
}
|
|
50
|
+
else if (newValue?.value) {
|
|
51
|
+
setValue(newValue.value);
|
|
52
|
+
}
|
|
53
|
+
else if (items[0]?.value) {
|
|
54
|
+
setValue(items[0].value);
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
}, [circular, displayCount, radius, setValue, value, valueIndex, items, translateY]);
|
|
59
|
+
const displayValues = useMemo(() => {
|
|
60
|
+
const centerIndex = Math.floor(renderCount / 2);
|
|
61
|
+
return Array.from({ length: renderCount }, (_, index) => {
|
|
62
|
+
let targetIndex = valueIndex + index - centerIndex;
|
|
63
|
+
if (circular) {
|
|
64
|
+
targetIndex = ((targetIndex % items.length) + items.length) % items.length;
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
targetIndex = Math.max(0, Math.min(targetIndex, items.length - 1));
|
|
68
|
+
}
|
|
69
|
+
return items[targetIndex] || items[0];
|
|
70
|
+
});
|
|
71
|
+
}, [renderCount, valueIndex, items, circular]);
|
|
72
|
+
const animatedAngles = useMemo(() => {
|
|
73
|
+
//translateY.setValue(0);
|
|
74
|
+
translateY.setOffset(0);
|
|
75
|
+
const currentIndex = displayValues.findIndex(item => item?.value === value);
|
|
76
|
+
return displayValues && displayValues.length > 0
|
|
77
|
+
? displayValues.map((_, index) => translateY
|
|
78
|
+
.interpolate({
|
|
79
|
+
inputRange: [-radius, radius],
|
|
80
|
+
outputRange: [
|
|
81
|
+
-radius + ((radius * 2) / displayCount) * (index - currentIndex),
|
|
82
|
+
radius + ((radius * 2) / displayCount) * (index - currentIndex),
|
|
83
|
+
],
|
|
84
|
+
extrapolate: 'extend',
|
|
85
|
+
})
|
|
86
|
+
.interpolate({
|
|
87
|
+
inputRange: [-radius, radius],
|
|
88
|
+
outputRange: [-Math.PI / 2, Math.PI / 2],
|
|
89
|
+
extrapolate: 'clamp',
|
|
90
|
+
}))
|
|
91
|
+
: [];
|
|
92
|
+
}, [displayValues, radius, value, displayCount, translateY]);
|
|
93
|
+
return (_jsxs(View, { style: [styles.container], ...panResponder.panHandlers, children: [_jsx(View, { style: [
|
|
94
|
+
styles.selectedIndicator,
|
|
95
|
+
{
|
|
96
|
+
transform: [{ translateY: -ITEM_HEIGHT / 2 }],
|
|
97
|
+
height: ITEM_HEIGHT,
|
|
98
|
+
},
|
|
99
|
+
] }), displayValues?.map((displayValue, index) => {
|
|
100
|
+
const animatedAngle = animatedAngles[index];
|
|
101
|
+
return (_jsx(Animated.View, {
|
|
102
|
+
// eslint-disable-next-line react-native/no-inline-styles
|
|
103
|
+
style: {
|
|
104
|
+
position: 'absolute',
|
|
105
|
+
height: ITEM_HEIGHT - 10,
|
|
106
|
+
transform: animatedAngle
|
|
107
|
+
? [
|
|
108
|
+
{
|
|
109
|
+
translateY: Animated.multiply(radius, sin(animatedAngle)),
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
rotateX: animatedAngle.interpolate({
|
|
113
|
+
inputRange: [-Math.PI / 2, Math.PI / 2],
|
|
114
|
+
outputRange: ['-89deg', '89deg'],
|
|
115
|
+
extrapolate: 'clamp',
|
|
116
|
+
}),
|
|
117
|
+
},
|
|
118
|
+
]
|
|
119
|
+
: [],
|
|
120
|
+
opacity: displayValue?.value !== value ? 0.3 : 1,
|
|
121
|
+
}, children: _jsx(BodyText, { children: displayValue?.text }) }, `${displayValue?.text}-${index}`));
|
|
122
|
+
})] }));
|
|
123
|
+
};
|
|
124
|
+
const styles = StyleSheet.create({
|
|
125
|
+
container: {
|
|
126
|
+
minWidth: 30,
|
|
127
|
+
overflow: 'hidden',
|
|
128
|
+
alignItems: 'center',
|
|
129
|
+
justifyContent: 'center',
|
|
130
|
+
height: CONTAINER_HEIGHT / 2,
|
|
131
|
+
...Platform.select({
|
|
132
|
+
web: {
|
|
133
|
+
cursor: 'pointer',
|
|
134
|
+
userSelect: 'none',
|
|
135
|
+
},
|
|
136
|
+
}),
|
|
137
|
+
},
|
|
138
|
+
selectedIndicator: {
|
|
139
|
+
position: 'absolute',
|
|
140
|
+
width: '100%',
|
|
141
|
+
top: '50%',
|
|
142
|
+
},
|
|
143
|
+
});
|
|
144
|
+
const customComparator = (prev, next) => {
|
|
145
|
+
const areEqual = prev.value === next.value && prev.setValue === next.setValue && isEqual(prev.items, next.items);
|
|
146
|
+
return areEqual;
|
|
147
|
+
};
|
|
148
|
+
export default memo(WheelWeb, customComparator);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { PickerOption } from '../DatePicker.props';
|
|
2
|
+
type WheelProps = {
|
|
3
|
+
value: number | string;
|
|
4
|
+
setValue?: (value: any) => void;
|
|
5
|
+
items: PickerOption[];
|
|
6
|
+
};
|
|
7
|
+
declare const _default: import("react").MemoExoticComponent<(props: WheelProps) => import("react/jsx-runtime").JSX.Element>;
|
|
8
|
+
export default _default;
|
|
@@ -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 WheelNative from './wheel-native';
|
|
5
|
+
import WheelWeb from './wheel-web';
|
|
6
|
+
const Wheel = (props) => {
|
|
7
|
+
const Component = Platform.OS === 'web' ? WheelWeb : WheelNative;
|
|
8
|
+
return _jsx(Component, { ...props });
|
|
9
|
+
};
|
|
10
|
+
export default memo(Wheel);
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import dayjs from 'dayjs';
|
|
2
|
+
import type { CalendarDay, CalendarMonth, CalendarWeek, DateType, Numerals } from './DatePicker.props';
|
|
3
|
+
export declare const CALENDAR_FORMAT = "YYYY-MM-DD HH:mm";
|
|
4
|
+
export declare const DATE_FORMAT = "YYYY-MM-DD";
|
|
5
|
+
export declare const YEAR_PAGE_SIZE = 12;
|
|
6
|
+
export declare const getMonths: () => dayjs.MonthNames;
|
|
7
|
+
export declare const getMonthName: (month: number) => string;
|
|
8
|
+
/**
|
|
9
|
+
* Get months array
|
|
10
|
+
*
|
|
11
|
+
* @returns months array
|
|
12
|
+
*/
|
|
13
|
+
export declare const getMonthsArray: () => CalendarMonth[];
|
|
14
|
+
/**
|
|
15
|
+
* Get weekdays
|
|
16
|
+
*
|
|
17
|
+
* @param locale - locale
|
|
18
|
+
* @param firstDayOfWeek - first day of week
|
|
19
|
+
* @param format - format short, min or full
|
|
20
|
+
*
|
|
21
|
+
* @returns weekdays
|
|
22
|
+
*/
|
|
23
|
+
export declare const getWeekdays: (firstDayOfWeek: number) => CalendarWeek[];
|
|
24
|
+
export declare const getFormated: (date: DateType) => string;
|
|
25
|
+
export declare const getDateMonth: (date: DateType) => number;
|
|
26
|
+
export declare const getDateYear: (date: DateType) => number;
|
|
27
|
+
/**
|
|
28
|
+
* Check if two dates are on the same day
|
|
29
|
+
*
|
|
30
|
+
* @param a - date to check
|
|
31
|
+
* @param b - date to check
|
|
32
|
+
*
|
|
33
|
+
* @returns true if dates are on the same day, false otherwise
|
|
34
|
+
*/
|
|
35
|
+
export declare function areDatesOnSameDay(a: DateType, b: DateType): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Check if date is between two dates
|
|
38
|
+
*
|
|
39
|
+
* @param date - date to check
|
|
40
|
+
* @param options - options
|
|
41
|
+
*
|
|
42
|
+
* @returns true if date is between two dates, false otherwise
|
|
43
|
+
*/
|
|
44
|
+
export declare function isDateBetween(date: DateType, { startDate, endDate, }: {
|
|
45
|
+
startDate?: DateType;
|
|
46
|
+
endDate?: DateType;
|
|
47
|
+
}): boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Check if date is disabled
|
|
50
|
+
*
|
|
51
|
+
* @param date - date to check
|
|
52
|
+
* @param options - options
|
|
53
|
+
*
|
|
54
|
+
* @returns true if date is disabled, false otherwise
|
|
55
|
+
*/
|
|
56
|
+
export declare function isDateDisabled(date: dayjs.Dayjs, { minDate, maxDate, enabledDates, disabledDates, }: {
|
|
57
|
+
minDate?: DateType;
|
|
58
|
+
maxDate?: DateType;
|
|
59
|
+
enabledDates?: DateType[] | ((date: DateType) => boolean) | undefined;
|
|
60
|
+
disabledDates?: DateType[] | ((date: DateType) => boolean) | undefined;
|
|
61
|
+
}): boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Check if year is disabled
|
|
64
|
+
*
|
|
65
|
+
* @param year - year to check
|
|
66
|
+
* @param options - options
|
|
67
|
+
*
|
|
68
|
+
* @returns true if year is disabled, false otherwise
|
|
69
|
+
*/
|
|
70
|
+
export declare function isYearDisabled(year: number, { minDate, maxDate, }: {
|
|
71
|
+
minDate?: DateType;
|
|
72
|
+
maxDate?: DateType;
|
|
73
|
+
}): boolean;
|
|
74
|
+
/**
|
|
75
|
+
* Check if month is disabled
|
|
76
|
+
*
|
|
77
|
+
* @param month - month to check
|
|
78
|
+
* @param date - date to check
|
|
79
|
+
* @param options - options
|
|
80
|
+
*
|
|
81
|
+
* @returns true if month is disabled, false otherwise
|
|
82
|
+
*/
|
|
83
|
+
export declare function isMonthDisabled(month: number, date: DateType, { minDate, maxDate, }: {
|
|
84
|
+
minDate?: DateType;
|
|
85
|
+
maxDate?: DateType;
|
|
86
|
+
}): boolean;
|
|
87
|
+
/**
|
|
88
|
+
* Get formated date
|
|
89
|
+
*
|
|
90
|
+
* @param date - date to get formated date from
|
|
91
|
+
* @param format - format to get formated date from
|
|
92
|
+
*
|
|
93
|
+
* @returns formated date
|
|
94
|
+
*/
|
|
95
|
+
export declare const getFormatedDate: (date: DateType, format: string) => string;
|
|
96
|
+
/**
|
|
97
|
+
* Get date
|
|
98
|
+
*
|
|
99
|
+
* @param date - date to get
|
|
100
|
+
*
|
|
101
|
+
* @returns date
|
|
102
|
+
*/
|
|
103
|
+
export declare const getDate: (date: DateType) => dayjs.Dayjs;
|
|
104
|
+
/**
|
|
105
|
+
* Get year range
|
|
106
|
+
*
|
|
107
|
+
* @param year - year to get year range from
|
|
108
|
+
*
|
|
109
|
+
* @returns year range
|
|
110
|
+
*/
|
|
111
|
+
export declare const getYearRange: (year: number) => number[];
|
|
112
|
+
/**
|
|
113
|
+
* Get days in month
|
|
114
|
+
*
|
|
115
|
+
* @param date - date to get days in month from
|
|
116
|
+
* @param showOutsideDays - whether to show outside days
|
|
117
|
+
* @param firstDayOfWeek - first day of week, number 0-6, 0 – Sunday, 6 – Saturday
|
|
118
|
+
*
|
|
119
|
+
* @returns days in month
|
|
120
|
+
*/
|
|
121
|
+
export declare function getDaysInMonth(date: DateType, showOutsideDays: boolean | undefined, firstDayOfWeek: number): {
|
|
122
|
+
prevMonthDays: number;
|
|
123
|
+
prevMonthOffset: number;
|
|
124
|
+
daysInCurrentMonth: number;
|
|
125
|
+
daysInNextMonth: number;
|
|
126
|
+
fullDaysInMonth: number;
|
|
127
|
+
};
|
|
128
|
+
/**
|
|
129
|
+
* Get first day of month
|
|
130
|
+
*
|
|
131
|
+
* @param date - date to get first day of month from
|
|
132
|
+
* @param firstDayOfWeek - first day of week, number 0-6, 0 – Sunday, 6 – Saturday
|
|
133
|
+
*
|
|
134
|
+
* @returns first day of month
|
|
135
|
+
*/
|
|
136
|
+
export declare function getFirstDayOfMonth(date: DateType, firstDayOfWeek: number): number;
|
|
137
|
+
/**
|
|
138
|
+
* Get start of day
|
|
139
|
+
*
|
|
140
|
+
* @param date - date to get start of day from
|
|
141
|
+
*
|
|
142
|
+
* @returns start of day
|
|
143
|
+
*/
|
|
144
|
+
export declare function getStartOfDay(date: DateType): DateType;
|
|
145
|
+
/**
|
|
146
|
+
* Get end of day
|
|
147
|
+
*
|
|
148
|
+
* @param date - date to get end of day from
|
|
149
|
+
*
|
|
150
|
+
* @returns end of day
|
|
151
|
+
*/
|
|
152
|
+
export declare function getEndOfDay(date: DateType): DateType;
|
|
153
|
+
/**
|
|
154
|
+
* Convert date to unix timestamp
|
|
155
|
+
*
|
|
156
|
+
* @param date - date to convert
|
|
157
|
+
*
|
|
158
|
+
* @returns unix timestamp
|
|
159
|
+
*/
|
|
160
|
+
export declare function dateToUnix(date: DateType): number;
|
|
161
|
+
/**
|
|
162
|
+
* Remove time from date
|
|
163
|
+
*
|
|
164
|
+
* @param date - date to remove time from
|
|
165
|
+
*
|
|
166
|
+
* @returns date with time removed
|
|
167
|
+
*/
|
|
168
|
+
export declare function removeTime(date: DateType, timeZone: string | undefined): DateType;
|
|
169
|
+
/**
|
|
170
|
+
* Get detailed date object
|
|
171
|
+
*
|
|
172
|
+
* @param date Get detailed date object
|
|
173
|
+
*
|
|
174
|
+
* @returns parsed date object
|
|
175
|
+
*/
|
|
176
|
+
export declare const getParsedDate: (date: DateType) => {
|
|
177
|
+
year: number;
|
|
178
|
+
month: number;
|
|
179
|
+
hour: number;
|
|
180
|
+
hour12: number;
|
|
181
|
+
minute: number;
|
|
182
|
+
period: string;
|
|
183
|
+
};
|
|
184
|
+
/**
|
|
185
|
+
* Calculate month days array based on current date
|
|
186
|
+
*
|
|
187
|
+
* @param datetime - The current date that selected
|
|
188
|
+
* @param showOutsideDays
|
|
189
|
+
* @param minDate - min selectable date
|
|
190
|
+
* @param maxDate - max selectable date
|
|
191
|
+
* @param firstDayOfWeek - first day of week, number 0-6, 0 – Sunday, 6 – Saturday
|
|
192
|
+
* @param enabledDates - array of enabled dates, or a function that returns true for a given date (takes precedence over disabledDates)
|
|
193
|
+
* @param disabledDates - array of disabled dates, or a function that returns true for a given date
|
|
194
|
+
* @param prevMonthDays - number of days in the previous month
|
|
195
|
+
* @param prevMonthOffset - number of days to offset the previous month
|
|
196
|
+
* @param daysInCurrentMonth - number of days in the current month
|
|
197
|
+
* @param daysInNextMonth - number of days in the next month
|
|
198
|
+
*
|
|
199
|
+
* @returns days array based on current date
|
|
200
|
+
*/
|
|
201
|
+
export declare const getMonthDays: (datetime: DateType, showOutsideDays: boolean, minDate: DateType, maxDate: DateType, firstDayOfWeek: number, enabledDates: DateType[] | ((date: DateType) => boolean) | undefined, disabledDates: DateType[] | ((date: DateType) => boolean) | undefined, prevMonthDays: number, prevMonthOffset: number, daysInCurrentMonth: number, daysInNextMonth: number, numerals: Numerals) => CalendarDay[];
|
|
202
|
+
/**
|
|
203
|
+
* Deep compare memo
|
|
204
|
+
*
|
|
205
|
+
* @param value - value to compare
|
|
206
|
+
* @param deps - dependencies
|
|
207
|
+
*
|
|
208
|
+
* @returns memoized value
|
|
209
|
+
*/
|
|
210
|
+
export declare function useDeepCompareMemo<T>(value: T, deps: any[]): T;
|
|
211
|
+
export declare const numeralSystems: Record<Numerals, readonly string[]>;
|
|
212
|
+
export declare function formatNumber(value: number, numerals: Numerals): string;
|