@utilitywarehouse/hearth-react-native 0.30.4-testid-fix-2 → 0.31.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.
Files changed (93) hide show
  1. package/.turbo/turbo-build.log +4 -5
  2. package/.turbo/turbo-lint.log +62 -70
  3. package/CHANGELOG.md +155 -0
  4. package/build/components/Badge/Badge.js +2 -2
  5. package/build/components/Badge/Badge.props.d.ts +1 -0
  6. package/build/components/Badge/BadgeText.d.ts +1 -1
  7. package/build/components/Badge/BadgeText.js +2 -2
  8. package/build/components/Container/Container.props.d.ts +2 -2
  9. package/build/components/ExpandableCard/ExpandableCard.d.ts +1 -1
  10. package/build/components/ExpandableCard/ExpandableCard.js +13 -2
  11. package/build/components/ExpandableCard/ExpandableCard.props.d.ts +43 -23
  12. package/build/components/ExpandableCard/ExpandableCardText.js +1 -1
  13. package/build/components/ExpandableCard/ExpandableCardTrigger.d.ts +3 -3
  14. package/build/components/ExpandableCard/ExpandableCardTrigger.props.d.ts +31 -6
  15. package/build/components/ExpandableCard/ExpandableCardTriggerRoot.d.ts +1 -1
  16. package/build/components/ExpandableCard/ExpandableCardTriggerRoot.js +13 -2
  17. package/build/components/Flex/Flex.props.d.ts +2 -2
  18. package/build/components/FormField/FormField.d.ts +5 -5
  19. package/build/components/FormField/FormField.js +3 -2
  20. package/build/components/Modal/Modal.d.ts +1 -1
  21. package/build/components/Modal/Modal.js +33 -39
  22. package/build/components/Modal/Modal.props.d.ts +8 -3
  23. package/build/components/Modal/Modal.shared.types.d.ts +19 -4
  24. package/build/components/Modal/Modal.web.d.ts +1 -1
  25. package/build/components/Modal/Modal.web.js +6 -3
  26. package/build/components/NavModal/NavModal.d.ts +1 -1
  27. package/build/components/NavModal/NavModal.js +10 -7
  28. package/build/components/NavModal/NavModal.props.d.ts +4 -3
  29. package/build/components/Textarea/Textarea.d.ts +1 -1
  30. package/build/components/Textarea/Textarea.js +64 -5
  31. package/build/components/Textarea/Textarea.props.d.ts +10 -0
  32. package/build/components/Textarea/TextareaRoot.js +4 -1
  33. package/docs/changelog.mdx +21 -0
  34. package/package.json +4 -4
  35. package/src/components/Badge/Badge.props.ts +1 -0
  36. package/src/components/Badge/Badge.tsx +6 -1
  37. package/src/components/Badge/BadgeText.tsx +8 -2
  38. package/src/components/Container/Container.props.ts +10 -1
  39. package/src/components/ExpandableCard/ExpandableCard.docs.mdx +89 -37
  40. package/src/components/ExpandableCard/ExpandableCard.props.ts +51 -27
  41. package/src/components/ExpandableCard/ExpandableCard.stories.tsx +67 -17
  42. package/src/components/ExpandableCard/ExpandableCard.tsx +15 -7
  43. package/src/components/ExpandableCard/ExpandableCardText.tsx +1 -1
  44. package/src/components/ExpandableCard/ExpandableCardTrigger.props.ts +37 -7
  45. package/src/components/ExpandableCard/ExpandableCardTriggerRoot.tsx +36 -2
  46. package/src/components/Flex/Flex.props.ts +16 -2
  47. package/src/components/FormField/FormField.tsx +2 -1
  48. package/src/components/List/List.stories.tsx +35 -0
  49. package/src/components/Modal/Modal.docs.mdx +52 -1
  50. package/src/components/Modal/Modal.props.ts +21 -6
  51. package/src/components/Modal/Modal.shared.types.ts +23 -4
  52. package/src/components/Modal/Modal.stories.tsx +165 -1
  53. package/src/components/Modal/Modal.tsx +101 -81
  54. package/src/components/Modal/Modal.web.tsx +29 -23
  55. package/src/components/NavModal/NavModal.docs.mdx +29 -0
  56. package/src/components/NavModal/NavModal.props.ts +11 -3
  57. package/src/components/NavModal/NavModal.stories.tsx +29 -0
  58. package/src/components/NavModal/NavModal.tsx +39 -33
  59. package/src/components/Textarea/Textarea.docs.mdx +33 -1
  60. package/src/components/Textarea/Textarea.props.ts +11 -2
  61. package/src/components/Textarea/Textarea.stories.tsx +21 -1
  62. package/src/components/Textarea/Textarea.tsx +107 -3
  63. package/src/components/Textarea/TextareaRoot.tsx +6 -2
  64. package/build/components/DatePicker/TimePicker.d.ts +0 -3
  65. package/build/components/DatePicker/TimePicker.js +0 -84
  66. package/build/components/DatePicker/time-picker/animated-math.d.ts +0 -4
  67. package/build/components/DatePicker/time-picker/animated-math.js +0 -19
  68. package/build/components/DatePicker/time-picker/period-native.d.ts +0 -6
  69. package/build/components/DatePicker/time-picker/period-native.js +0 -17
  70. package/build/components/DatePicker/time-picker/period-picker.d.ts +0 -6
  71. package/build/components/DatePicker/time-picker/period-picker.js +0 -10
  72. package/build/components/DatePicker/time-picker/period-web.d.ts +0 -6
  73. package/build/components/DatePicker/time-picker/period-web.js +0 -21
  74. package/build/components/DatePicker/time-picker/wheel-native.d.ts +0 -8
  75. package/build/components/DatePicker/time-picker/wheel-native.js +0 -19
  76. package/build/components/DatePicker/time-picker/wheel-picker/index.d.ts +0 -2
  77. package/build/components/DatePicker/time-picker/wheel-picker/index.js +0 -2
  78. package/build/components/DatePicker/time-picker/wheel-picker/wheel-picker-item.d.ts +0 -16
  79. package/build/components/DatePicker/time-picker/wheel-picker/wheel-picker-item.js +0 -97
  80. package/build/components/DatePicker/time-picker/wheel-picker/wheel-picker.d.ts +0 -21
  81. package/build/components/DatePicker/time-picker/wheel-picker/wheel-picker.js +0 -88
  82. package/build/components/DatePicker/time-picker/wheel-picker/wheel-picker.style.d.ts +0 -23
  83. package/build/components/DatePicker/time-picker/wheel-picker/wheel-picker.style.js +0 -21
  84. package/build/components/DatePicker/time-picker/wheel-web.d.ts +0 -8
  85. package/build/components/DatePicker/time-picker/wheel-web.js +0 -146
  86. package/build/components/DatePicker/time-picker/wheel.d.ts +0 -8
  87. package/build/components/DatePicker/time-picker/wheel.js +0 -10
  88. package/build/components/SafeAreaView/SafeAreaView.d.ts +0 -5
  89. package/build/components/SafeAreaView/SafeAreaView.js +0 -117
  90. package/build/components/SafeAreaView/SafeAreaView.props.d.ts +0 -17
  91. package/build/components/SafeAreaView/SafeAreaView.props.js +0 -1
  92. package/build/components/SafeAreaView/index.d.ts +0 -2
  93. package/build/components/SafeAreaView/index.js +0 -1
@@ -1,4 +1,4 @@
1
- import { Meta, StoryObj } from '@storybook/react-vite';
1
+ import { Meta, StoryObj } from '@storybook/react-native';
2
2
  import { Textarea } from '.';
3
3
 
4
4
  const meta = {
@@ -56,6 +56,16 @@ const meta = {
56
56
  description: 'Focus the Textarea component',
57
57
  defaultValue: false,
58
58
  },
59
+ required: {
60
+ control: 'boolean',
61
+ description: 'Whether the Textarea component is required',
62
+ defaultValue: true,
63
+ },
64
+ resizable: {
65
+ control: 'boolean',
66
+ description: 'Enables a drag handle to resize the Textarea vertically',
67
+ defaultValue: false,
68
+ },
59
69
  },
60
70
  args: {
61
71
  placeholder: 'Textarea placeholder',
@@ -63,6 +73,7 @@ const meta = {
63
73
  disabled: false,
64
74
  readonly: false,
65
75
  focused: false,
76
+ resizable: false,
66
77
  },
67
78
  } satisfies Meta<typeof Textarea>;
68
79
 
@@ -70,3 +81,12 @@ export default meta;
70
81
  type Story = StoryObj<typeof meta>;
71
82
 
72
83
  export const Playground: Story = {};
84
+
85
+ export const Resizable: Story = {
86
+ args: {
87
+ label: 'Notes',
88
+ helperText: 'Drag the bottom-right handle to resize',
89
+ placeholder: 'Add more detail here...',
90
+ resizable: true,
91
+ },
92
+ };
@@ -1,7 +1,19 @@
1
1
  import { createTextarea } from '@gluestack-ui/textarea';
2
2
  import type TextareaProps from './Textarea.props';
3
3
 
4
- import { useEffect } from 'react';
4
+ import { useEffect, useMemo, useRef } from 'react';
5
+ import {
6
+ View,
7
+ type LayoutChangeEvent,
8
+ type StyleProp,
9
+ type TextStyle,
10
+ type ViewStyle,
11
+ } from 'react-native';
12
+ import { Gesture, GestureDetector } from 'react-native-gesture-handler';
13
+ import { useAnimatedStyle, useSharedValue } from 'react-native-reanimated';
14
+ import { Path, Svg } from 'react-native-svg';
15
+ import { StyleSheet } from 'react-native-unistyles';
16
+ import { useTheme } from '../../hooks';
5
17
  import { FormField, useFormFieldContext } from '../FormField';
6
18
  import TextareaFieldComponent from './TextareaField';
7
19
  import TextareaRoot from './TextareaRoot';
@@ -13,9 +25,14 @@ export const TextareaComponent = createTextarea({
13
25
 
14
26
  export const TextareaField = TextareaComponent.Input;
15
27
 
28
+ const DEFAULT_TEXTAREA_HEIGHT = 96;
29
+ const RESIZE_HANDLE_TOUCH_SIZE = 28;
30
+ const RESIZE_HANDLE_ICON_SIZE = 9;
31
+
16
32
  const Textarea = ({
17
33
  validationStatus = 'initial',
18
34
  children,
35
+ resizable = false,
19
36
  disabled,
20
37
  focused,
21
38
  readonly,
@@ -26,9 +43,11 @@ const Textarea = ({
26
43
  invalidText,
27
44
  required,
28
45
  helperIcon,
46
+ onLayout,
29
47
  ...props
30
48
  }: TextareaProps) => {
31
49
  const formFieldContext = useFormFieldContext();
50
+ const hasMeasuredHeight = useRef(false);
32
51
  const textareaLabel = label ?? formFieldContext?.label;
33
52
  const textareaHelperText = helperText ?? formFieldContext?.helperText;
34
53
  const textareaValidText = validText ?? formFieldContext?.validText;
@@ -37,12 +56,15 @@ const Textarea = ({
37
56
  const textareaDisabled = disabled ?? formFieldContext?.disabled;
38
57
  const textareaReadonly = readonly ?? formFieldContext?.readonly;
39
58
  const textareaValidationStatus = formFieldContext?.validationStatus ?? validationStatus;
59
+ const textareaHeight = useSharedValue(DEFAULT_TEXTAREA_HEIGHT);
60
+ const resizeStartHeight = useSharedValue(DEFAULT_TEXTAREA_HEIGHT);
61
+ const theme = useTheme();
40
62
 
41
63
  useEffect(() => {
42
64
  if (formFieldContext?.setShouldHandleAccessibility) {
43
65
  formFieldContext.setShouldHandleAccessibility(true);
44
66
  }
45
- }, []);
67
+ }, [formFieldContext]);
46
68
 
47
69
  const getAccessibilityLabel = () => {
48
70
  let accessibilityLabel = '';
@@ -75,6 +97,47 @@ const Textarea = ({
75
97
  return accessibilityHint || props.accessibilityHint;
76
98
  };
77
99
 
100
+ const handleTextareaLayout = (event: LayoutChangeEvent) => {
101
+ if (!hasMeasuredHeight.current) {
102
+ textareaHeight.value = event.nativeEvent.layout.height;
103
+ resizeStartHeight.value = event.nativeEvent.layout.height;
104
+ hasMeasuredHeight.current = true;
105
+ }
106
+
107
+ if (children) {
108
+ onLayout?.(event);
109
+ }
110
+ };
111
+
112
+ const resizeGesture = useMemo(
113
+ () =>
114
+ Gesture.Pan()
115
+ .enabled(resizable && !textareaDisabled)
116
+ .onBegin(() => {
117
+ resizeStartHeight.value = textareaHeight.value;
118
+ })
119
+ .onUpdate(event => {
120
+ const nextHeight =
121
+ resizeStartHeight.value + event.translationY + event.translationX * 0.35;
122
+
123
+ textareaHeight.value = Math.max(DEFAULT_TEXTAREA_HEIGHT, nextHeight);
124
+ }),
125
+ [resizable, resizeStartHeight, textareaDisabled, textareaHeight]
126
+ );
127
+
128
+ const animatedHeightStyle = useAnimatedStyle(
129
+ () => ({
130
+ height: textareaHeight.value,
131
+ }),
132
+ [textareaHeight]
133
+ );
134
+
135
+ const rootStyle = (children ? props.style : undefined) as StyleProp<ViewStyle>;
136
+ const inputStyle = (!children ? props.style : undefined) as StyleProp<TextStyle>;
137
+ const textareaStyle = (
138
+ resizable ? [rootStyle, animatedHeightStyle] : rootStyle
139
+ ) as StyleProp<ViewStyle>;
140
+
78
141
  return (
79
142
  <FormField
80
143
  label={label}
@@ -91,6 +154,8 @@ const Textarea = ({
91
154
  >
92
155
  <TextareaComponent
93
156
  {...(children ? props : {})}
157
+ onLayout={handleTextareaLayout}
158
+ style={textareaStyle}
94
159
  validationStatus={textareaValidationStatus}
95
160
  isInvalid={textareaValidationStatus === 'invalid'}
96
161
  isReadOnly={textareaReadonly}
@@ -104,12 +169,51 @@ const Textarea = ({
104
169
  <>{children}</>
105
170
  ) : (
106
171
  <>
107
- <TextareaField {...props} />
172
+ <TextareaField {...props} onLayout={onLayout} style={[styles.textarea, inputStyle]} />
108
173
  </>
109
174
  )}
175
+ {resizable && !textareaDisabled ? (
176
+ <GestureDetector gesture={resizeGesture}>
177
+ <View style={styles.resizeHandle}>
178
+ <Svg
179
+ width={RESIZE_HANDLE_ICON_SIZE}
180
+ height={RESIZE_HANDLE_ICON_SIZE}
181
+ viewBox="0 0 9 9"
182
+ fill="none"
183
+ >
184
+ <Path
185
+ d="M0.353516 8.35355L8.35352 0.353546M4.35352 8.35355L8.35352 4.35355"
186
+ stroke={theme.color.icon.primary}
187
+ />
188
+ </Svg>
189
+ </View>
190
+ </GestureDetector>
191
+ ) : null}
110
192
  </TextareaComponent>
111
193
  </FormField>
112
194
  );
113
195
  };
114
196
 
197
+ const styles = StyleSheet.create({
198
+ textarea: {
199
+ padding: 0,
200
+ _web: {
201
+ outlineStyle: 'none',
202
+ _focusVisible: {
203
+ outlineStyle: 'none',
204
+ },
205
+ },
206
+ },
207
+ resizeHandle: {
208
+ position: 'absolute',
209
+ right: 0,
210
+ bottom: 0,
211
+ width: RESIZE_HANDLE_TOUCH_SIZE,
212
+ height: RESIZE_HANDLE_TOUCH_SIZE,
213
+ alignItems: 'center',
214
+ justifyContent: 'center',
215
+ zIndex: 1,
216
+ },
217
+ });
218
+
115
219
  export default Textarea;
@@ -1,9 +1,12 @@
1
1
  import { useMemo } from 'react';
2
2
  import { View } from 'react-native';
3
+ import Animated from 'react-native-reanimated';
3
4
  import { StyleSheet } from 'react-native-unistyles';
4
5
  import { TextareaContext } from './Textarea.context';
5
6
  import InputProps from './Textarea.props';
6
7
 
8
+ const AnimatedView = Animated.createAnimatedComponent(View);
9
+
7
10
  const TextareaRoot = ({
8
11
  children,
9
12
  style,
@@ -21,9 +24,9 @@ const TextareaRoot = ({
21
24
 
22
25
  return (
23
26
  <TextareaContext.Provider value={value}>
24
- <View {...props} style={[styles.container, style]}>
27
+ <AnimatedView {...props} style={[styles.container, style]}>
25
28
  {children}
26
- </View>
29
+ </AnimatedView>
27
30
  </TextareaContext.Provider>
28
31
  );
29
32
  };
@@ -35,6 +38,7 @@ const styles = StyleSheet.create(theme => ({
35
38
  borderColor: theme.color.border.strong,
36
39
  height: theme.components.input.textArea.height,
37
40
  borderRadius: theme.components.input.borderRadius,
41
+ position: 'relative',
38
42
  flexDirection: 'row',
39
43
  overflow: 'hidden',
40
44
  alignContent: 'center',
@@ -1,3 +0,0 @@
1
- export type Period = 'AM' | 'PM';
2
- declare const TimePicker: () => import("react/jsx-runtime").JSX.Element;
3
- export default TimePicker;
@@ -1,84 +0,0 @@
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;
@@ -1,4 +0,0 @@
1
- import { Animated } from 'react-native';
2
- declare function sin(animated: Animated.Animated): Animated.AnimatedAddition<string | number>;
3
- declare function normalize(animated: Animated.Animated): Animated.Animated;
4
- export { sin, normalize };
@@ -1,19 +0,0 @@
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 };
@@ -1,6 +0,0 @@
1
- interface PeriodProps {
2
- value: string;
3
- setValue?: (value: any) => void;
4
- }
5
- declare const _default: import("react").MemoExoticComponent<({ value, setValue }: PeriodProps) => import("react/jsx-runtime").JSX.Element>;
6
- export default _default;
@@ -1,17 +0,0 @@
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);
@@ -1,6 +0,0 @@
1
- type PeriodProps = {
2
- value: string;
3
- setValue?: (value: any) => void;
4
- };
5
- declare const _default: import("react").MemoExoticComponent<(props: PeriodProps) => import("react/jsx-runtime").JSX.Element>;
6
- export default _default;
@@ -1,10 +0,0 @@
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);
@@ -1,6 +0,0 @@
1
- interface PeriodProps {
2
- value: string;
3
- setValue?: (value: any) => void;
4
- }
5
- declare const _default: import("react").MemoExoticComponent<({ value, setValue }: PeriodProps) => import("react/jsx-runtime").JSX.Element>;
6
- export default _default;
@@ -1,21 +0,0 @@
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);
@@ -1,8 +0,0 @@
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;
@@ -1,19 +0,0 @@
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);
@@ -1,2 +0,0 @@
1
- import WheelPicker from './wheel-picker';
2
- export default WheelPicker;
@@ -1,2 +0,0 @@
1
- import WheelPicker from './wheel-picker';
2
- export default WheelPicker;
@@ -1,16 +0,0 @@
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;
@@ -1,97 +0,0 @@
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);
@@ -1,21 +0,0 @@
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;