react-native-mantine 0.12.0 → 0.14.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 (63) hide show
  1. package/lib/commonjs/components/LinearGradient/PlatformLinearGradient.js +9 -9
  2. package/lib/commonjs/components/LinearGradient/PlatformLinearGradient.js.map +1 -1
  3. package/lib/commonjs/components/index.js +35 -46
  4. package/lib/commonjs/components/index.js.map +1 -1
  5. package/lib/commonjs/theme/functions/fns/gradient/gradient.js +3 -3
  6. package/lib/commonjs/theme/functions/fns/gradient/gradient.js.map +1 -1
  7. package/lib/commonjs/theme/functions/fns/theme-color/theme-color.js +1 -1
  8. package/lib/module/components/LinearGradient/PlatformLinearGradient.js +9 -9
  9. package/lib/module/components/LinearGradient/PlatformLinearGradient.js.map +1 -1
  10. package/lib/module/components/index.js +0 -1
  11. package/lib/module/components/index.js.map +1 -1
  12. package/lib/module/theme/functions/fns/gradient/gradient.js +2 -2
  13. package/lib/module/theme/functions/fns/gradient/gradient.js.map +1 -1
  14. package/lib/module/theme/functions/fns/theme-color/theme-color.js +1 -1
  15. package/lib/typescript/commonjs/src/components/Button/index.d.ts +1 -1
  16. package/lib/typescript/commonjs/src/components/Button/index.d.ts.map +1 -1
  17. package/lib/typescript/commonjs/src/components/ColorSwatch/index.d.ts +1 -1
  18. package/lib/typescript/commonjs/src/components/ColorSwatch/index.d.ts.map +1 -1
  19. package/lib/typescript/commonjs/src/components/LinearGradient/PlatformLinearGradient.d.ts +1 -1
  20. package/lib/typescript/commonjs/src/components/Mark/index.d.ts +1 -1
  21. package/lib/typescript/commonjs/src/components/Mark/index.d.ts.map +1 -1
  22. package/lib/typescript/commonjs/src/components/Space/index.d.ts +2 -2
  23. package/lib/typescript/commonjs/src/components/Space/index.d.ts.map +1 -1
  24. package/lib/typescript/commonjs/src/components/index.d.ts +0 -1
  25. package/lib/typescript/commonjs/src/components/index.d.ts.map +1 -1
  26. package/lib/typescript/commonjs/src/theme/functions/fns/gradient/gradient.d.ts +2 -2
  27. package/lib/typescript/commonjs/src/theme/functions/fns/gradient/gradient.d.ts.map +1 -1
  28. package/lib/typescript/commonjs/src/theme/types/DefaultProps.d.ts +2 -2
  29. package/lib/typescript/commonjs/src/theme/types/DefaultProps.d.ts.map +1 -1
  30. package/lib/typescript/module/src/components/Button/index.d.ts +1 -1
  31. package/lib/typescript/module/src/components/Button/index.d.ts.map +1 -1
  32. package/lib/typescript/module/src/components/ColorSwatch/index.d.ts +1 -1
  33. package/lib/typescript/module/src/components/ColorSwatch/index.d.ts.map +1 -1
  34. package/lib/typescript/module/src/components/LinearGradient/PlatformLinearGradient.d.ts +1 -1
  35. package/lib/typescript/module/src/components/Mark/index.d.ts +1 -1
  36. package/lib/typescript/module/src/components/Mark/index.d.ts.map +1 -1
  37. package/lib/typescript/module/src/components/Space/index.d.ts +2 -2
  38. package/lib/typescript/module/src/components/Space/index.d.ts.map +1 -1
  39. package/lib/typescript/module/src/components/index.d.ts +0 -1
  40. package/lib/typescript/module/src/components/index.d.ts.map +1 -1
  41. package/lib/typescript/module/src/theme/functions/fns/gradient/gradient.d.ts +2 -2
  42. package/lib/typescript/module/src/theme/functions/fns/gradient/gradient.d.ts.map +1 -1
  43. package/lib/typescript/module/src/theme/types/DefaultProps.d.ts +2 -2
  44. package/lib/typescript/module/src/theme/types/DefaultProps.d.ts.map +1 -1
  45. package/package.json +2 -4
  46. package/src/components/Button/index.tsx +1 -1
  47. package/src/components/ColorSwatch/index.tsx +1 -1
  48. package/src/components/LinearGradient/PlatformLinearGradient.tsx +9 -9
  49. package/src/components/Mark/index.tsx +1 -1
  50. package/src/components/Space/index.tsx +2 -2
  51. package/src/components/index.tsx +0 -1
  52. package/src/theme/functions/fns/gradient/gradient.ts +2 -2
  53. package/src/theme/functions/fns/theme-color/theme-color.ts +1 -1
  54. package/src/theme/types/DefaultProps.ts +3 -3
  55. package/lib/commonjs/components/Slider/index.js +0 -300
  56. package/lib/commonjs/components/Slider/index.js.map +0 -1
  57. package/lib/module/components/Slider/index.js +0 -295
  58. package/lib/module/components/Slider/index.js.map +0 -1
  59. package/lib/typescript/commonjs/src/components/Slider/index.d.ts +0 -43
  60. package/lib/typescript/commonjs/src/components/Slider/index.d.ts.map +0 -1
  61. package/lib/typescript/module/src/components/Slider/index.d.ts +0 -43
  62. package/lib/typescript/module/src/components/Slider/index.d.ts.map +0 -1
  63. package/src/components/Slider/index.tsx +0 -349
@@ -1,43 +0,0 @@
1
- import React from 'react';
2
- import type { DefaultProps, MantineColor, MantineNumberSize, MantineSize } from '../../theme/types';
3
- export interface SliderProps extends DefaultProps {
4
- /** Slider value (controlled) */
5
- value?: number;
6
- /** Default value (uncontrolled) */
7
- defaultValue?: number;
8
- /** Called when value changes */
9
- onChange?: (value: number) => void;
10
- /** Called when user stops dragging */
11
- onChangeEnd?: (value: number) => void;
12
- /** Minimum value */
13
- min?: number;
14
- /** Maximum value */
15
- max?: number;
16
- /** Step interval */
17
- step?: number;
18
- /** Slider size */
19
- size?: MantineSize;
20
- /** Slider color */
21
- color?: MantineColor;
22
- /** Key of theme.radius or any valid value to set border-radius */
23
- radius?: MantineNumberSize;
24
- /** Display label */
25
- label?: ((value: number) => React.ReactNode) | React.ReactNode;
26
- /** Display marks */
27
- marks?: {
28
- value: number;
29
- label?: React.ReactNode;
30
- }[];
31
- /** Disabled state */
32
- disabled?: boolean;
33
- /** Show label on hover */
34
- showLabelOnHover?: boolean;
35
- /** Thumb children, displays above thumb */
36
- thumbChildren?: React.ReactNode;
37
- /** Hides thumb */
38
- thumbWithoutBorder?: boolean;
39
- /** Additional styles */
40
- style?: any;
41
- }
42
- export declare const Slider: React.ForwardRefExoticComponent<SliderProps & React.RefAttributes<any>>;
43
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/components/Slider/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoD,MAAM,OAAO,CAAC;AAazE,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAKpG,MAAM,WAAW,WAAY,SAAQ,YAAY;IAC/C,gCAAgC;IAChC,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,mCAAmC;IACnC,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,gCAAgC;IAChC,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAEnC,sCAAsC;IACtC,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAEtC,oBAAoB;IACpB,GAAG,CAAC,EAAE,MAAM,CAAC;IAEb,oBAAoB;IACpB,GAAG,CAAC,EAAE,MAAM,CAAC;IAEb,oBAAoB;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,kBAAkB;IAClB,IAAI,CAAC,EAAE,WAAW,CAAC;IAEnB,mBAAmB;IACnB,KAAK,CAAC,EAAE,YAAY,CAAC;IAErB,kEAAkE;IAClE,MAAM,CAAC,EAAE,iBAAiB,CAAC;IAE3B,oBAAoB;IACpB,KAAK,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,MAAM,KAAK,KAAK,CAAC,SAAS,CAAC,GAAG,KAAK,CAAC,SAAS,CAAC;IAE/D,oBAAoB;IACpB,KAAK,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;KAAE,EAAE,CAAC;IAErD,qBAAqB;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,0BAA0B;IAC1B,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAE3B,2CAA2C;IAC3C,aAAa,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAEhC,kBAAkB;IAClB,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAE7B,wBAAwB;IACxB,KAAK,CAAC,EAAE,GAAG,CAAC;CACb;AAmHD,eAAO,MAAM,MAAM,yEAkKjB,CAAC"}
@@ -1,43 +0,0 @@
1
- import React from 'react';
2
- import type { DefaultProps, MantineColor, MantineNumberSize, MantineSize } from '../../theme/types';
3
- export interface SliderProps extends DefaultProps {
4
- /** Slider value (controlled) */
5
- value?: number;
6
- /** Default value (uncontrolled) */
7
- defaultValue?: number;
8
- /** Called when value changes */
9
- onChange?: (value: number) => void;
10
- /** Called when user stops dragging */
11
- onChangeEnd?: (value: number) => void;
12
- /** Minimum value */
13
- min?: number;
14
- /** Maximum value */
15
- max?: number;
16
- /** Step interval */
17
- step?: number;
18
- /** Slider size */
19
- size?: MantineSize;
20
- /** Slider color */
21
- color?: MantineColor;
22
- /** Key of theme.radius or any valid value to set border-radius */
23
- radius?: MantineNumberSize;
24
- /** Display label */
25
- label?: ((value: number) => React.ReactNode) | React.ReactNode;
26
- /** Display marks */
27
- marks?: {
28
- value: number;
29
- label?: React.ReactNode;
30
- }[];
31
- /** Disabled state */
32
- disabled?: boolean;
33
- /** Show label on hover */
34
- showLabelOnHover?: boolean;
35
- /** Thumb children, displays above thumb */
36
- thumbChildren?: React.ReactNode;
37
- /** Hides thumb */
38
- thumbWithoutBorder?: boolean;
39
- /** Additional styles */
40
- style?: any;
41
- }
42
- export declare const Slider: React.ForwardRefExoticComponent<SliderProps & React.RefAttributes<any>>;
43
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/components/Slider/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoD,MAAM,OAAO,CAAC;AAazE,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAKpG,MAAM,WAAW,WAAY,SAAQ,YAAY;IAC/C,gCAAgC;IAChC,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,mCAAmC;IACnC,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,gCAAgC;IAChC,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAEnC,sCAAsC;IACtC,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAEtC,oBAAoB;IACpB,GAAG,CAAC,EAAE,MAAM,CAAC;IAEb,oBAAoB;IACpB,GAAG,CAAC,EAAE,MAAM,CAAC;IAEb,oBAAoB;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,kBAAkB;IAClB,IAAI,CAAC,EAAE,WAAW,CAAC;IAEnB,mBAAmB;IACnB,KAAK,CAAC,EAAE,YAAY,CAAC;IAErB,kEAAkE;IAClE,MAAM,CAAC,EAAE,iBAAiB,CAAC;IAE3B,oBAAoB;IACpB,KAAK,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,MAAM,KAAK,KAAK,CAAC,SAAS,CAAC,GAAG,KAAK,CAAC,SAAS,CAAC;IAE/D,oBAAoB;IACpB,KAAK,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;KAAE,EAAE,CAAC;IAErD,qBAAqB;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,0BAA0B;IAC1B,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAE3B,2CAA2C;IAC3C,aAAa,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAEhC,kBAAkB;IAClB,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAE7B,wBAAwB;IACxB,KAAK,CAAC,EAAE,GAAG,CAAC;CACb;AAmHD,eAAO,MAAM,MAAM,yEAkKjB,CAAC"}
@@ -1,349 +0,0 @@
1
- import React, { forwardRef, useRef, useState, useCallback } from 'react';
2
- import {
3
- View,
4
- PanResponder,
5
- Animated,
6
- } from 'react-native';
7
- import type {
8
- LayoutChangeEvent,
9
- GestureResponderEvent,
10
- PanResponderGestureState,
11
- } from 'react-native';
12
- import { BoxView } from '../BoxView';
13
- import { Text } from '../Text';
14
- import type { DefaultProps, MantineColor, MantineNumberSize, MantineSize } from '../../theme/types';
15
- import { useComponentDefaultProps } from '../../theme/theme-provider';
16
- import { createStyles } from '../../theme';
17
- import { rem } from '../../theme/utils/rem';
18
-
19
- export interface SliderProps extends DefaultProps {
20
- /** Slider value (controlled) */
21
- value?: number;
22
-
23
- /** Default value (uncontrolled) */
24
- defaultValue?: number;
25
-
26
- /** Called when value changes */
27
- onChange?: (value: number) => void;
28
-
29
- /** Called when user stops dragging */
30
- onChangeEnd?: (value: number) => void;
31
-
32
- /** Minimum value */
33
- min?: number;
34
-
35
- /** Maximum value */
36
- max?: number;
37
-
38
- /** Step interval */
39
- step?: number;
40
-
41
- /** Slider size */
42
- size?: MantineSize;
43
-
44
- /** Slider color */
45
- color?: MantineColor;
46
-
47
- /** Key of theme.radius or any valid value to set border-radius */
48
- radius?: MantineNumberSize;
49
-
50
- /** Display label */
51
- label?: ((value: number) => React.ReactNode) | React.ReactNode;
52
-
53
- /** Display marks */
54
- marks?: { value: number; label?: React.ReactNode }[];
55
-
56
- /** Disabled state */
57
- disabled?: boolean;
58
-
59
- /** Show label on hover */
60
- showLabelOnHover?: boolean;
61
-
62
- /** Thumb children, displays above thumb */
63
- thumbChildren?: React.ReactNode;
64
-
65
- /** Hides thumb */
66
- thumbWithoutBorder?: boolean;
67
-
68
- /** Additional styles */
69
- style?: any;
70
- }
71
-
72
- const sizes = {
73
- xs: { height: rem(4), thumb: rem(12) },
74
- sm: { height: rem(6), thumb: rem(16) },
75
- md: { height: rem(8), thumb: rem(20) },
76
- lg: { height: rem(10), thumb: rem(24) },
77
- xl: { height: rem(12), thumb: rem(28) },
78
- };
79
-
80
- const useStyles = createStyles(
81
- (
82
- theme,
83
- {
84
- color,
85
- radius,
86
- disabled,
87
- }: {
88
- color: MantineColor;
89
- radius: MantineNumberSize;
90
- disabled: boolean;
91
- },
92
- { size }
93
- ) => {
94
- const colors = theme.colors[color] || theme.colors[theme.primaryColor];
95
- const sizeStyles = sizes[size as keyof typeof sizes] || sizes.md;
96
-
97
- return {
98
- root: {
99
- position: 'relative',
100
- width: '100%',
101
- paddingVertical: rem(10),
102
- opacity: disabled ? 0.5 : 1,
103
- },
104
- track: {
105
- position: 'relative',
106
- height: sizeStyles.height,
107
- backgroundColor:
108
- theme.colorScheme === 'dark' ? theme.colors.dark?.[4] : theme.colors.gray?.[2],
109
- borderRadius: theme.fn.radius(radius),
110
- overflow: 'hidden',
111
- },
112
- bar: {
113
- position: 'absolute',
114
- height: '100%',
115
- backgroundColor: colors?.[6] || colors?.[5] || theme.primaryBgColor,
116
- borderRadius: theme.fn.radius(radius),
117
- },
118
- thumb: {
119
- position: 'absolute',
120
- width: sizeStyles.thumb,
121
- height: sizeStyles.thumb,
122
- borderRadius: sizeStyles.thumb,
123
- backgroundColor: theme.white,
124
- borderWidth: rem(3),
125
- borderColor: colors?.[6] || colors?.[5] || theme.primaryBgColor,
126
- top: -(sizeStyles.thumb / 2 - sizeStyles.height / 2),
127
- shadowColor: '#000',
128
- shadowOffset: { width: 0, height: 2 },
129
- shadowOpacity: 0.1,
130
- shadowRadius: 4,
131
- elevation: 2,
132
- },
133
- label: {
134
- position: 'absolute',
135
- top: rem(-32),
136
- backgroundColor: colors?.[6] || colors?.[5] || theme.primaryBgColor,
137
- paddingHorizontal: theme.spacing.xs,
138
- paddingVertical: rem(4),
139
- borderRadius: theme.fn.radius('sm'),
140
- minWidth: rem(28),
141
- alignItems: 'center',
142
- justifyContent: 'center',
143
- },
144
- labelText: {
145
- color: theme.white,
146
- fontSize: theme.fontSizes.xs as number,
147
- fontWeight: '600',
148
- },
149
- marks: {
150
- position: 'absolute',
151
- width: '100%',
152
- top: sizeStyles.height,
153
- flexDirection: 'row',
154
- },
155
- mark: {
156
- position: 'absolute',
157
- width: rem(2),
158
- height: rem(6),
159
- backgroundColor: theme.colorScheme === 'dark' ? theme.colors.dark?.[4] : theme.colors.gray?.[3],
160
- borderRadius: rem(1),
161
- },
162
- markLabel: {
163
- position: 'absolute',
164
- top: rem(10),
165
- fontSize: theme.fontSizes.xs as number,
166
- color: theme.colorScheme === 'dark' ? theme.colors.dark?.[2] : theme.colors.gray?.[6],
167
- transform: [{ translateX: -10 }],
168
- },
169
- };
170
- }
171
- ) as any;
172
-
173
- const defaultProps: Partial<SliderProps> = {
174
- min: 0,
175
- max: 100,
176
- step: 1,
177
- size: 'md',
178
- color: 'blue',
179
- radius: 'xl',
180
- disabled: false,
181
- showLabelOnHover: true,
182
- thumbWithoutBorder: false,
183
- };
184
-
185
- export const Slider = forwardRef<any, SliderProps>((props, ref) => {
186
- const {
187
- value: controlledValue,
188
- defaultValue,
189
- onChange,
190
- onChangeEnd,
191
- min,
192
- max,
193
- step,
194
- size,
195
- color,
196
- radius,
197
- label,
198
- marks,
199
- disabled,
200
- showLabelOnHover,
201
- thumbChildren,
202
- thumbWithoutBorder,
203
- style,
204
- ...others
205
- } = useComponentDefaultProps('Slider', defaultProps, props);
206
-
207
- const { styles, sx } = useStyles(
208
- { color, radius, disabled },
209
- { name: 'Slider', size }
210
- ) as any;
211
-
212
- const sizeStyles = sizes[size as keyof typeof sizes] || sizes.md;
213
-
214
- const [uncontrolledValue, setUncontrolledValue] = useState(defaultValue ?? min ?? 0);
215
- const [trackWidth, setTrackWidth] = useState(0);
216
- const [showLabel, setShowLabel] = useState(false);
217
-
218
- const value = controlledValue !== undefined ? controlledValue : uncontrolledValue;
219
-
220
- const scale = useRef(new Animated.Value(1)).current;
221
-
222
- const clampValue = useCallback(
223
- (val: number) => {
224
- const clamped = Math.max(min!, Math.min(max!, val));
225
- const stepped = Math.round(clamped / step!) * step!;
226
- return stepped;
227
- },
228
- [min, max, step]
229
- );
230
-
231
- const updateValue = useCallback(
232
- (newValue: number) => {
233
- const clampedValue = clampValue(newValue);
234
- if (controlledValue === undefined) {
235
- setUncontrolledValue(clampedValue);
236
- }
237
- onChange?.(clampedValue);
238
- },
239
- [clampValue, controlledValue, onChange]
240
- );
241
-
242
- const getValueFromPosition = useCallback(
243
- (posX: number) => {
244
- const percentage = posX / trackWidth;
245
- return min! + percentage * (max! - min!);
246
- },
247
- [trackWidth, min, max]
248
- );
249
-
250
- const trackLayoutRef = useRef({ x: 0, y: 0, width: 0, height: 0 });
251
-
252
- const panResponder = useRef(
253
- PanResponder.create({
254
- onStartShouldSetPanResponder: () => !disabled!,
255
- onMoveShouldSetPanResponder: () => !disabled!,
256
- onPanResponderGrant: (evt: GestureResponderEvent) => {
257
- setShowLabel(true);
258
- Animated.spring(scale, {
259
- toValue: 1.2,
260
- useNativeDriver: true,
261
- }).start();
262
-
263
- // Handle tap to move slider
264
- const locationX = evt.nativeEvent.locationX;
265
- const newValue = getValueFromPosition(locationX);
266
- updateValue(newValue);
267
- },
268
- onPanResponderMove: (_evt: GestureResponderEvent, gestureState: PanResponderGestureState) => {
269
- // Calculate position relative to track start
270
- const relativeX = gestureState.moveX - trackLayoutRef.current.x;
271
- const newValue = getValueFromPosition(relativeX);
272
- updateValue(newValue);
273
- },
274
- onPanResponderRelease: () => {
275
- setShowLabel(false);
276
- Animated.spring(scale, {
277
- toValue: 1,
278
- useNativeDriver: true,
279
- }).start();
280
- onChangeEnd?.(value);
281
- },
282
- })
283
- ).current;
284
-
285
- const handleLayout = (event: LayoutChangeEvent) => {
286
- const { x, y, width, height } = event.nativeEvent.layout;
287
- setTrackWidth(width);
288
- trackLayoutRef.current = { x, y, width, height };
289
- };
290
-
291
- const percentage = ((value - min!) / (max! - min!)) * 100;
292
- const thumbPosition = (trackWidth * percentage) / 100;
293
-
294
- const renderLabel = () => {
295
- if (!showLabel && !showLabelOnHover) return null;
296
- if (!showLabel) return null;
297
-
298
- const labelContent = typeof label === 'function' ? label(value) : label || value;
299
-
300
- return (
301
- <BoxView style={[styles.label, { left: -(rem(28) / 2) }]}>
302
- <Text style={styles.labelText}>{labelContent}</Text>
303
- </BoxView>
304
- );
305
- };
306
-
307
- return (
308
- <BoxView ref={ref} style={sx(styles.root, style)} {...others}>
309
- <View style={styles.track} onLayout={handleLayout} {...panResponder.panHandlers}>
310
- <View style={[styles.bar, { width: `${percentage}%` }]} />
311
-
312
- {trackWidth > 0 && (
313
- <Animated.View
314
- style={[
315
- styles.thumb,
316
- {
317
- left: thumbPosition - (sizeStyles.thumb / 2),
318
- transform: [{ scale }],
319
- },
320
- ]}
321
- >
322
- {renderLabel()}
323
- {thumbChildren}
324
- </Animated.View>
325
- )}
326
- </View>
327
-
328
- {marks && marks.length > 0 && (
329
- <View style={styles.marks}>
330
- {marks.map((mark, index) => {
331
- const markPercentage = ((mark.value - min!) / (max! - min!)) * 100;
332
- const markPosition = (trackWidth * markPercentage) / 100;
333
-
334
- return (
335
- <View key={index}>
336
- <View style={[styles.mark, { left: markPosition }]} />
337
- {mark.label && (
338
- <Text style={[styles.markLabel, { left: markPosition }]}>{mark.label}</Text>
339
- )}
340
- </View>
341
- );
342
- })}
343
- </View>
344
- )}
345
- </BoxView>
346
- );
347
- });
348
-
349
- Slider.displayName = 'Slider';