@harya72/react-native-ruler 1.0.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/LICENSE +21 -0
- package/README.md +212 -0
- package/dist/Ruler.d.ts +21 -0
- package/dist/Ruler.d.ts.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.esm.js +268 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/index.js +273 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +155 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +75 -0
- package/src/Ruler.tsx +457 -0
- package/src/index.ts +8 -0
- package/src/types.ts +182 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var reactNative = require('react-native');
|
|
6
|
+
var React = require('react');
|
|
7
|
+
var Animated = require('react-native-reanimated');
|
|
8
|
+
|
|
9
|
+
let LinearGradient = null;
|
|
10
|
+
try {
|
|
11
|
+
// @ts-ignore
|
|
12
|
+
LinearGradient = require('expo-linear-gradient').LinearGradient;
|
|
13
|
+
}
|
|
14
|
+
catch (e) {
|
|
15
|
+
// expo-linear-gradient not installed, fade gradients will be disabled
|
|
16
|
+
}
|
|
17
|
+
const { width: SCREEN_WIDTH } = reactNative.Dimensions.get('window');
|
|
18
|
+
const { width: screenWidth } = reactNative.Dimensions.get('screen');
|
|
19
|
+
const FADE_CONFIG = {
|
|
20
|
+
fadeWidth: 0.25,
|
|
21
|
+
fadeOpacity: 0.1,
|
|
22
|
+
};
|
|
23
|
+
const STEP = 1;
|
|
24
|
+
const LONG_BAR_WIDTH = 6;
|
|
25
|
+
const LONG_BAR_HEIGHT = 50;
|
|
26
|
+
const SHORT_BAR_WIDTH = 3;
|
|
27
|
+
const SHORT_BAR_HEIGHT = 30;
|
|
28
|
+
const LONG_BAR_COLOR = 'white';
|
|
29
|
+
const SHORT_BAR_COLOR = '#B5B5B5';
|
|
30
|
+
const GAP = 10;
|
|
31
|
+
const BORDER_RADIUS = 50;
|
|
32
|
+
const Bar = React.memo(({ index, longBarHeight, longBarWidth, shortBarHeight, shortBarWidth, longBarColor, shortBarColor, borderRadius, }) => {
|
|
33
|
+
const isLong = index % 10 === 0;
|
|
34
|
+
const barWidth = isLong ? longBarWidth : shortBarWidth;
|
|
35
|
+
const barHeight = isLong ? longBarHeight : shortBarHeight;
|
|
36
|
+
const margin = (longBarWidth - barWidth) / 2;
|
|
37
|
+
return (React.createElement(reactNative.View, { style: {
|
|
38
|
+
height: barHeight,
|
|
39
|
+
backgroundColor: isLong ? longBarColor : shortBarColor,
|
|
40
|
+
width: barWidth,
|
|
41
|
+
borderRadius: borderRadius,
|
|
42
|
+
marginHorizontal: margin,
|
|
43
|
+
} }));
|
|
44
|
+
});
|
|
45
|
+
Bar.displayName = 'Bar';
|
|
46
|
+
const AnimatedTextInput = Animated.createAnimatedComponent(reactNative.TextInput);
|
|
47
|
+
const AnimatedText = React.memo(({ text, fontSize = 96, style, }) => {
|
|
48
|
+
const animatedProps = Animated.useAnimatedProps(() => {
|
|
49
|
+
return {
|
|
50
|
+
text: text.value,
|
|
51
|
+
defaultValue: text.value,
|
|
52
|
+
};
|
|
53
|
+
});
|
|
54
|
+
const textStyle = [
|
|
55
|
+
style,
|
|
56
|
+
{
|
|
57
|
+
fontSize: fontSize,
|
|
58
|
+
padding: 0,
|
|
59
|
+
margin: 0,
|
|
60
|
+
textAlign: 'center',
|
|
61
|
+
textAlignVertical: 'center',
|
|
62
|
+
},
|
|
63
|
+
];
|
|
64
|
+
return (React.createElement(AnimatedTextInput, { animatedProps: animatedProps, editable: false, underlineColorAndroid: "transparent", style: [textStyle, { opacity: 1 }], multiline: false }));
|
|
65
|
+
});
|
|
66
|
+
AnimatedText.displayName = 'AnimatedText';
|
|
67
|
+
/**
|
|
68
|
+
* A highly customizable, performant ruler component for React Native
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```tsx
|
|
72
|
+
* <Ruler
|
|
73
|
+
* min={0}
|
|
74
|
+
* max={200}
|
|
75
|
+
* step={1}
|
|
76
|
+
* height={100}
|
|
77
|
+
* initialValue={50}
|
|
78
|
+
* onChange={(value) => console.log('Selected:', value)}
|
|
79
|
+
* supportLinearGradient={true}
|
|
80
|
+
* />
|
|
81
|
+
* ```
|
|
82
|
+
*/
|
|
83
|
+
const Ruler = ({ onChange, max, min, fadeWidth = FADE_CONFIG.fadeWidth, fadeOpacity = FADE_CONFIG.fadeOpacity, decelerationRate = 'normal', ...rest }) => {
|
|
84
|
+
// Prop validation
|
|
85
|
+
if (__DEV__) {
|
|
86
|
+
if (min >= max) {
|
|
87
|
+
console.error('Ruler: min must be less than max');
|
|
88
|
+
}
|
|
89
|
+
if (rest?.step !== undefined && rest.step <= 0) {
|
|
90
|
+
console.error('Ruler: step must be greater than 0');
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
const MAX = max;
|
|
94
|
+
const MIN = min;
|
|
95
|
+
const step = rest?.step ?? STEP;
|
|
96
|
+
const longBarWidth = rest?.longBarWidth ?? LONG_BAR_WIDTH;
|
|
97
|
+
const shortBarWidth = rest?.shortBarWidth ?? SHORT_BAR_WIDTH;
|
|
98
|
+
const longBarHeight = rest?.longBarHeight ?? LONG_BAR_HEIGHT;
|
|
99
|
+
const shortBarHeight = rest?.shortBarHeight ?? SHORT_BAR_HEIGHT;
|
|
100
|
+
const longBarColor = rest?.longBarColor ?? LONG_BAR_COLOR;
|
|
101
|
+
const shortBarColor = rest?.shortBarColor ?? SHORT_BAR_COLOR;
|
|
102
|
+
const gap = rest?.gapBetweenSteps ?? GAP;
|
|
103
|
+
const borderRadius = rest?.borderRadius ?? BORDER_RADIUS;
|
|
104
|
+
// Calculate fraction digits based on step precision
|
|
105
|
+
const fractionDigits = React.useMemo(() => {
|
|
106
|
+
if (step >= 1)
|
|
107
|
+
return 0;
|
|
108
|
+
const decimals = step.toString().split('.')[1]?.length || 0;
|
|
109
|
+
return Math.min(decimals, 10);
|
|
110
|
+
}, [step]);
|
|
111
|
+
const formatValue = React.useCallback((value) => value.toFixed(fractionDigits), [fractionDigits]);
|
|
112
|
+
const getInitialValue = React.useCallback(() => {
|
|
113
|
+
const initialVal = rest?.initialValue !== undefined ? rest.initialValue : MIN;
|
|
114
|
+
return Math.max(MIN, Math.min(initialVal, MAX));
|
|
115
|
+
}, [rest?.initialValue, MIN, MAX]);
|
|
116
|
+
const prevInitialValue = React.useRef(getInitialValue());
|
|
117
|
+
const prevMomentumValue = Animated.useSharedValue(formatValue(getInitialValue()));
|
|
118
|
+
const isUserInteractingRef = React.useRef(false);
|
|
119
|
+
const isUserInteracting = Animated.useSharedValue(false);
|
|
120
|
+
const setIsUserInteracting = React.useCallback((value) => {
|
|
121
|
+
isUserInteractingRef.current = value;
|
|
122
|
+
}, []);
|
|
123
|
+
const currentValue = Animated.useSharedValue(formatValue(getInitialValue()));
|
|
124
|
+
const listRef = React.useRef(null);
|
|
125
|
+
const isInitialMount = React.useRef(true);
|
|
126
|
+
const data = React.useMemo(() => {
|
|
127
|
+
// Prevent division by zero
|
|
128
|
+
if (step <= 0)
|
|
129
|
+
return [];
|
|
130
|
+
const itemAmount = (MAX - MIN) / step;
|
|
131
|
+
// Warn about large ranges
|
|
132
|
+
if (__DEV__ && itemAmount > 1000) {
|
|
133
|
+
console.warn(`Ruler: Large range (${Math.round(itemAmount)} items). Consider increasing step size for better performance.`);
|
|
134
|
+
}
|
|
135
|
+
return Array.from({ length: itemAmount + 1 }, (_, i) => MIN + i * step);
|
|
136
|
+
}, [MIN, MAX, step]);
|
|
137
|
+
const snapOffsets = React.useMemo(() => {
|
|
138
|
+
return data.map((_, index) => index * (longBarWidth + gap));
|
|
139
|
+
}, [data, longBarWidth, gap]);
|
|
140
|
+
React.useEffect(() => {
|
|
141
|
+
let isMounted = true;
|
|
142
|
+
if (isInitialMount.current || isUserInteractingRef.current) {
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
const clampedValue = getInitialValue();
|
|
146
|
+
const prevValue = prevInitialValue.current;
|
|
147
|
+
if (Math.abs(clampedValue - prevValue) <= step) {
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
prevInitialValue.current = clampedValue;
|
|
151
|
+
currentValue.value = formatValue(clampedValue);
|
|
152
|
+
const index = Math.round((clampedValue - MIN) / step);
|
|
153
|
+
if (isMounted) {
|
|
154
|
+
listRef.current?.scrollToOffset({
|
|
155
|
+
offset: index * (longBarWidth + gap),
|
|
156
|
+
animated: true,
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
return () => {
|
|
160
|
+
isMounted = false;
|
|
161
|
+
};
|
|
162
|
+
}, [rest?.initialValue, MIN, MAX, step, longBarWidth, gap, formatValue, getInitialValue]);
|
|
163
|
+
const scrollHandler = Animated.useAnimatedScrollHandler({
|
|
164
|
+
onBeginDrag: () => {
|
|
165
|
+
'worklet';
|
|
166
|
+
isUserInteracting.value = true;
|
|
167
|
+
Animated.runOnJS(setIsUserInteracting)(true);
|
|
168
|
+
},
|
|
169
|
+
onScroll: (event) => {
|
|
170
|
+
if (!isUserInteracting.value)
|
|
171
|
+
return;
|
|
172
|
+
const scrollX = event.contentOffset.x;
|
|
173
|
+
const index = Math.round(scrollX / (longBarWidth + gap));
|
|
174
|
+
const value = MIN + index * step;
|
|
175
|
+
if (value >= MIN && value <= MAX) {
|
|
176
|
+
currentValue.value = value.toFixed(fractionDigits);
|
|
177
|
+
}
|
|
178
|
+
},
|
|
179
|
+
onMomentumEnd: (event) => {
|
|
180
|
+
const scrollX = event.contentOffset.x;
|
|
181
|
+
const index = Math.round(scrollX / (longBarWidth + gap));
|
|
182
|
+
const value = MIN + index * step;
|
|
183
|
+
const formattedValue = value.toFixed(fractionDigits);
|
|
184
|
+
if (value >= MIN && value <= MAX) {
|
|
185
|
+
if (prevMomentumValue.value !== formattedValue) {
|
|
186
|
+
if (isUserInteracting.value) {
|
|
187
|
+
Animated.runOnJS(onChange)(parseFloat(formattedValue));
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
prevMomentumValue.value = formattedValue;
|
|
192
|
+
isUserInteracting.value = false;
|
|
193
|
+
Animated.runOnJS(setIsUserInteracting)(false);
|
|
194
|
+
},
|
|
195
|
+
});
|
|
196
|
+
const Spacer = React.useCallback(() => React.createElement(reactNative.View, { style: { width: SCREEN_WIDTH / 2 - longBarWidth / 2 } }), [longBarWidth]);
|
|
197
|
+
const onContentSizeChange = React.useCallback(() => {
|
|
198
|
+
if (isInitialMount.current) {
|
|
199
|
+
isInitialMount.current = false;
|
|
200
|
+
const initialIndex = Math.round((getInitialValue() - MIN) / step);
|
|
201
|
+
listRef.current?.scrollToOffset({
|
|
202
|
+
offset: initialIndex * (longBarWidth + gap),
|
|
203
|
+
animated: false,
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
}, [getInitialValue, MIN, step, longBarWidth, gap]);
|
|
207
|
+
const renderItem = React.useCallback(({ index }) => (React.createElement(Bar, { index: index, longBarColor: longBarColor, longBarHeight: longBarHeight, longBarWidth: longBarWidth, shortBarColor: shortBarColor, shortBarHeight: shortBarHeight, shortBarWidth: shortBarWidth, borderRadius: borderRadius })), [
|
|
208
|
+
longBarColor,
|
|
209
|
+
longBarHeight,
|
|
210
|
+
longBarWidth,
|
|
211
|
+
shortBarColor,
|
|
212
|
+
shortBarHeight,
|
|
213
|
+
shortBarWidth,
|
|
214
|
+
borderRadius,
|
|
215
|
+
]);
|
|
216
|
+
const renderSeparator = React.useCallback(() => React.createElement(reactNative.View, { style: { width: gap } }), [gap]);
|
|
217
|
+
const getItemLayout = React.useCallback((_data, index) => ({
|
|
218
|
+
length: longBarWidth + gap,
|
|
219
|
+
offset: (longBarWidth + gap) * index,
|
|
220
|
+
index,
|
|
221
|
+
}), [longBarWidth, gap]);
|
|
222
|
+
// Check if linear gradient is supported
|
|
223
|
+
const shouldShowGradient = rest?.supportLinearGradient && LinearGradient;
|
|
224
|
+
return (React.createElement(reactNative.View, { style: { width: screenWidth } },
|
|
225
|
+
!rest?.textComponent ? (React.createElement(AnimatedText, { text: currentValue, style: [styles.valueText, rest?.textStyle] })) : (rest.textComponent(currentValue)),
|
|
226
|
+
React.createElement(reactNative.View, { style: { justifyContent: 'center', maxHeight: rest?.height } },
|
|
227
|
+
React.createElement(Animated.FlatList, { ref: listRef, data: data, renderItem: renderItem, keyExtractor: (_, i) => i.toString(), horizontal: true, showsHorizontalScrollIndicator: false, ListHeaderComponent: Spacer, ListFooterComponent: Spacer, ItemSeparatorComponent: renderSeparator, contentContainerStyle: {
|
|
228
|
+
alignItems: 'center',
|
|
229
|
+
}, scrollEventThrottle: 16, onScroll: scrollHandler, overScrollMode: "never", snapToOffsets: snapOffsets, snapToAlignment: "start", onContentSizeChange: onContentSizeChange, decelerationRate: decelerationRate, maxToRenderPerBatch: 10, initialNumToRender: 20, windowSize: 21, getItemLayout: getItemLayout, removeClippedSubviews: reactNative.Platform.OS === 'android' }),
|
|
230
|
+
shouldShowGradient && (React.createElement(LinearGradient, { colors: ['rgba(0,0,0,0.9)', `rgba(0,0,0,${fadeOpacity})`], start: { x: 0, y: 0 }, end: { x: 1, y: 0 }, style: [
|
|
231
|
+
styles.fadeOverlay,
|
|
232
|
+
{
|
|
233
|
+
left: 0,
|
|
234
|
+
width: SCREEN_WIDTH * fadeWidth,
|
|
235
|
+
},
|
|
236
|
+
], pointerEvents: "none" })),
|
|
237
|
+
shouldShowGradient && (React.createElement(LinearGradient, { colors: [`rgba(0,0,0,${fadeOpacity})`, 'rgba(0,0,0,0.9)'], start: { x: 0, y: 0 }, end: { x: 1, y: 0 }, style: [
|
|
238
|
+
styles.fadeOverlay,
|
|
239
|
+
{
|
|
240
|
+
right: 0,
|
|
241
|
+
width: SCREEN_WIDTH * fadeWidth,
|
|
242
|
+
},
|
|
243
|
+
], pointerEvents: "none" })),
|
|
244
|
+
React.createElement(reactNative.View, { style: {
|
|
245
|
+
position: 'absolute',
|
|
246
|
+
alignSelf: 'center',
|
|
247
|
+
zIndex: 1,
|
|
248
|
+
}, pointerEvents: "none" }, rest?.barComponent ?? (React.createElement(reactNative.View, { style: {
|
|
249
|
+
height: rest?.indicatorHeight ?? 100,
|
|
250
|
+
width: rest?.indicatorWidth ?? 10,
|
|
251
|
+
backgroundColor: rest?.indicatorColor ?? 'white',
|
|
252
|
+
borderRadius: rest?.borderRadius ?? BORDER_RADIUS,
|
|
253
|
+
} }))))));
|
|
254
|
+
};
|
|
255
|
+
const styles = reactNative.StyleSheet.create({
|
|
256
|
+
container: { justifyContent: 'center', alignItems: 'center' },
|
|
257
|
+
valueText: {
|
|
258
|
+
fontSize: 28,
|
|
259
|
+
color: 'white',
|
|
260
|
+
marginBottom: 16,
|
|
261
|
+
textAlign: 'center',
|
|
262
|
+
},
|
|
263
|
+
fadeOverlay: {
|
|
264
|
+
position: 'absolute',
|
|
265
|
+
top: 0,
|
|
266
|
+
bottom: 0,
|
|
267
|
+
zIndex: 2,
|
|
268
|
+
},
|
|
269
|
+
});
|
|
270
|
+
|
|
271
|
+
exports.Ruler = Ruler;
|
|
272
|
+
exports.default = Ruler;
|
|
273
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/Ruler.tsx"],"sourcesContent":[null],"names":["Dimensions","memo","View","TextInput","useAnimatedProps","useMemo","useCallback","useRef","useSharedValue","useEffect","useAnimatedScrollHandler","runOnJS","Platform","StyleSheet"],"mappings":";;;;;;;;AA2BA,IAAI,cAAc,GAAQ,IAAI;AAC9B,IAAI;;AAEF,IAAA,cAAc,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC,cAAc;AACjE;AAAE,OAAO,CAAC,EAAE;;AAEZ;AAEA,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,GAAGA,sBAAU,CA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AAG,EAAE,CAAC;AACN,QAAA,MAAM,EAAE,CAAC;AACT,QAAA,MAAM,EAAE,CAAC;AACV,KAAA;AACF,CAAA,CAAC;;;;;"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { StyleProp, ViewStyle, TextStyle, TextInputProps } from 'react-native';
|
|
3
|
+
import { SharedValue } from 'react-native-reanimated';
|
|
4
|
+
/**
|
|
5
|
+
* Props for the Ruler component
|
|
6
|
+
*/
|
|
7
|
+
export interface RulerProps {
|
|
8
|
+
/**
|
|
9
|
+
* Callback function called when the ruler value changes
|
|
10
|
+
* @param value - The current selected value
|
|
11
|
+
*/
|
|
12
|
+
onChange: (value: number) => void;
|
|
13
|
+
/**
|
|
14
|
+
* Maximum value on the ruler
|
|
15
|
+
*/
|
|
16
|
+
max: number;
|
|
17
|
+
/**
|
|
18
|
+
* Minimum value on the ruler
|
|
19
|
+
*/
|
|
20
|
+
min: number;
|
|
21
|
+
/**
|
|
22
|
+
* Step increment between values
|
|
23
|
+
* @default 1
|
|
24
|
+
*/
|
|
25
|
+
step?: number;
|
|
26
|
+
/**
|
|
27
|
+
* Width of the fade gradient as a percentage of screen width (0-1)
|
|
28
|
+
* @default 0.25
|
|
29
|
+
*/
|
|
30
|
+
fadeWidth?: number;
|
|
31
|
+
/**
|
|
32
|
+
* Opacity of the fade gradient (0-1)
|
|
33
|
+
* @default 0.1
|
|
34
|
+
*/
|
|
35
|
+
fadeOpacity?: number;
|
|
36
|
+
/**
|
|
37
|
+
* Style for the ruler container
|
|
38
|
+
*/
|
|
39
|
+
style?: StyleProp<ViewStyle>;
|
|
40
|
+
/**
|
|
41
|
+
* Style for the value text
|
|
42
|
+
*/
|
|
43
|
+
textStyle?: StyleProp<TextStyle>;
|
|
44
|
+
/**
|
|
45
|
+
* Color of the center indicator
|
|
46
|
+
* @default "white"
|
|
47
|
+
*/
|
|
48
|
+
indicatorColor?: string;
|
|
49
|
+
/**
|
|
50
|
+
* Height of the center indicator
|
|
51
|
+
* @default 100
|
|
52
|
+
*/
|
|
53
|
+
indicatorHeight?: number;
|
|
54
|
+
/**
|
|
55
|
+
* Width of the center indicator
|
|
56
|
+
* @default 10
|
|
57
|
+
*/
|
|
58
|
+
indicatorWidth?: number;
|
|
59
|
+
/**
|
|
60
|
+
* Height of long bars (every 10th step)
|
|
61
|
+
* @default 50
|
|
62
|
+
*/
|
|
63
|
+
longBarHeight?: number;
|
|
64
|
+
/**
|
|
65
|
+
* Height of short bars
|
|
66
|
+
* @default 30
|
|
67
|
+
*/
|
|
68
|
+
shortBarHeight?: number;
|
|
69
|
+
/**
|
|
70
|
+
* Width of long bars
|
|
71
|
+
* @default 6
|
|
72
|
+
*/
|
|
73
|
+
longBarWidth?: number;
|
|
74
|
+
/**
|
|
75
|
+
* Width of short bars
|
|
76
|
+
* @default 3
|
|
77
|
+
*/
|
|
78
|
+
shortBarWidth?: number;
|
|
79
|
+
/**
|
|
80
|
+
* Color of long bars
|
|
81
|
+
* @default "white"
|
|
82
|
+
*/
|
|
83
|
+
longBarColor?: string;
|
|
84
|
+
/**
|
|
85
|
+
* Color of short bars
|
|
86
|
+
* @default "#B5B5B5"
|
|
87
|
+
*/
|
|
88
|
+
shortBarColor?: string;
|
|
89
|
+
/**
|
|
90
|
+
* Gap between ruler steps
|
|
91
|
+
* @default 10
|
|
92
|
+
*/
|
|
93
|
+
gapBetweenSteps?: number;
|
|
94
|
+
/**
|
|
95
|
+
* Border radius for bars and indicator
|
|
96
|
+
* @default 50
|
|
97
|
+
*/
|
|
98
|
+
borderRadius?: number;
|
|
99
|
+
/**
|
|
100
|
+
* Custom component to render as the center indicator bar
|
|
101
|
+
*/
|
|
102
|
+
barComponent?: ReactNode;
|
|
103
|
+
/**
|
|
104
|
+
* Enable linear gradient fade on edges (requires expo-linear-gradient)
|
|
105
|
+
* @default false
|
|
106
|
+
*/
|
|
107
|
+
supportLinearGradient?: boolean;
|
|
108
|
+
/**
|
|
109
|
+
* Initial value to display
|
|
110
|
+
* @default min
|
|
111
|
+
*/
|
|
112
|
+
initialValue?: number;
|
|
113
|
+
/**
|
|
114
|
+
* Scroll deceleration rate
|
|
115
|
+
* @default "normal"
|
|
116
|
+
*/
|
|
117
|
+
decelerationRate?: 'fast' | 'normal';
|
|
118
|
+
/**
|
|
119
|
+
* Height of the ruler component
|
|
120
|
+
*/
|
|
121
|
+
height: number;
|
|
122
|
+
/**
|
|
123
|
+
* Custom text component to display the current value
|
|
124
|
+
* @param currentValue - Shared value containing the current ruler value as a string
|
|
125
|
+
*/
|
|
126
|
+
textComponent?: (currentValue: SharedValue<string>) => ReactNode;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Internal props for AnimatedTextInput
|
|
130
|
+
*/
|
|
131
|
+
export interface AnimatedTextInputProps extends TextInputProps {
|
|
132
|
+
text?: string;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Props for the AnimatedText component
|
|
136
|
+
*/
|
|
137
|
+
export interface AnimatedGradientTextProps {
|
|
138
|
+
text: SharedValue<string>;
|
|
139
|
+
fontSize?: number;
|
|
140
|
+
style?: any;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Props for the Bar component
|
|
144
|
+
*/
|
|
145
|
+
export interface BarProps {
|
|
146
|
+
index: number;
|
|
147
|
+
longBarHeight: number;
|
|
148
|
+
longBarWidth: number;
|
|
149
|
+
shortBarHeight: number;
|
|
150
|
+
shortBarWidth: number;
|
|
151
|
+
longBarColor: string;
|
|
152
|
+
shortBarColor: string;
|
|
153
|
+
borderRadius?: number;
|
|
154
|
+
}
|
|
155
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,SAAS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AAE,OAAO,CAAC;IAEhC;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,MAAM,GAAG,QAAQ,CAAC;IAErC;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;;OAGG;IACH,aAAa,CAAC,EAAE,CAAC,YAAY,EAAE,WAAW,CAAC,MAAM,CAAC,KAAK,SAAS,CAAC;CAClE;AAED;;GAEG;AACH,MAAM,WAAW,sBAAuB,SAAQ,cAAc;IAC5D,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC,IAAI,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,GAAG,CAAC;CACb;AAED;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB"}
|
package/package.json
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@harya72/react-native-ruler",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "A highly customizable, performant ruler component for React Native with smooth animations",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/index.esm.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"type": "module",
|
|
9
|
+
"files": [
|
|
10
|
+
"dist",
|
|
11
|
+
"src",
|
|
12
|
+
"README.md",
|
|
13
|
+
"LICENSE"
|
|
14
|
+
],
|
|
15
|
+
"sideEffects": false,
|
|
16
|
+
"engines": {
|
|
17
|
+
"node": ">=16.0.0"
|
|
18
|
+
},
|
|
19
|
+
"publishConfig": {
|
|
20
|
+
"access": "public",
|
|
21
|
+
"registry": "https://registry.npmjs.org/"
|
|
22
|
+
},
|
|
23
|
+
"scripts": {
|
|
24
|
+
"build": "rollup -c",
|
|
25
|
+
"prepare": "npm run build",
|
|
26
|
+
"typecheck": "tsc --noEmit",
|
|
27
|
+
"prepublishOnly": "npm run build"
|
|
28
|
+
},
|
|
29
|
+
"keywords": [
|
|
30
|
+
"react-native",
|
|
31
|
+
"ruler",
|
|
32
|
+
"picker",
|
|
33
|
+
"slider",
|
|
34
|
+
"animated",
|
|
35
|
+
"reanimated",
|
|
36
|
+
"measurement",
|
|
37
|
+
"selector",
|
|
38
|
+
"ui",
|
|
39
|
+
"component"
|
|
40
|
+
],
|
|
41
|
+
"author": "harya72",
|
|
42
|
+
"license": "MIT",
|
|
43
|
+
"repository": {
|
|
44
|
+
"type": "git",
|
|
45
|
+
"url": "https://github.com/harya72/react-native-ruler.git"
|
|
46
|
+
},
|
|
47
|
+
"bugs": {
|
|
48
|
+
"url": "https://github.com/harya72/react-native-ruler/issues"
|
|
49
|
+
},
|
|
50
|
+
"homepage": "https://github.com/harya72/react-native-ruler#readme",
|
|
51
|
+
"peerDependencies": {
|
|
52
|
+
"react": ">=16.8.0",
|
|
53
|
+
"react-native": ">=0.60.0",
|
|
54
|
+
"react-native-reanimated": ">=2.0.0"
|
|
55
|
+
},
|
|
56
|
+
"peerDependenciesMeta": {
|
|
57
|
+
"expo-linear-gradient": {
|
|
58
|
+
"optional": true
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
"devDependencies": {
|
|
62
|
+
"@rollup/plugin-commonjs": "^25.0.7",
|
|
63
|
+
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
64
|
+
"@rollup/plugin-typescript": "^11.1.5",
|
|
65
|
+
"@types/react": "^18.2.0",
|
|
66
|
+
"@types/react-native": "^0.72.0",
|
|
67
|
+
"react": "^18.2.0",
|
|
68
|
+
"react-native": "^0.72.0",
|
|
69
|
+
"react-native-reanimated": "^3.0.0",
|
|
70
|
+
"rollup": "^4.9.0",
|
|
71
|
+
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
72
|
+
"tslib": "^2.6.2",
|
|
73
|
+
"typescript": "^5.3.0"
|
|
74
|
+
}
|
|
75
|
+
}
|