@metamask/design-system-react-native 0.34.0 → 0.36.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 (124) hide show
  1. package/CHANGELOG.md +37 -1
  2. package/dist/components/ActionListItem/ActionListItem.cjs +1 -1
  3. package/dist/components/ActionListItem/ActionListItem.cjs.map +1 -1
  4. package/dist/components/ActionListItem/ActionListItem.mjs +1 -1
  5. package/dist/components/ActionListItem/ActionListItem.mjs.map +1 -1
  6. package/dist/components/BannerBase/BannerBase.cjs +8 -6
  7. package/dist/components/BannerBase/BannerBase.cjs.map +1 -1
  8. package/dist/components/BannerBase/BannerBase.d.cts.map +1 -1
  9. package/dist/components/BannerBase/BannerBase.d.mts.map +1 -1
  10. package/dist/components/BannerBase/BannerBase.mjs +9 -7
  11. package/dist/components/BannerBase/BannerBase.mjs.map +1 -1
  12. package/dist/components/BannerBase/index.cjs +3 -1
  13. package/dist/components/BannerBase/index.cjs.map +1 -1
  14. package/dist/components/BannerBase/index.d.cts +1 -0
  15. package/dist/components/BannerBase/index.d.cts.map +1 -1
  16. package/dist/components/BannerBase/index.d.mts +1 -0
  17. package/dist/components/BannerBase/index.d.mts.map +1 -1
  18. package/dist/components/BannerBase/index.mjs +1 -0
  19. package/dist/components/BannerBase/index.mjs.map +1 -1
  20. package/dist/components/ButtonBase/ButtonBase.cjs +1 -1
  21. package/dist/components/ButtonBase/ButtonBase.cjs.map +1 -1
  22. package/dist/components/ButtonBase/ButtonBase.d.cts.map +1 -1
  23. package/dist/components/ButtonBase/ButtonBase.d.mts.map +1 -1
  24. package/dist/components/ButtonBase/ButtonBase.mjs +1 -1
  25. package/dist/components/ButtonBase/ButtonBase.mjs.map +1 -1
  26. package/dist/components/Content/Content.cjs +27 -13
  27. package/dist/components/Content/Content.cjs.map +1 -1
  28. package/dist/components/Content/Content.d.cts.map +1 -1
  29. package/dist/components/Content/Content.d.mts.map +1 -1
  30. package/dist/components/Content/Content.mjs +28 -14
  31. package/dist/components/Content/Content.mjs.map +1 -1
  32. package/dist/components/Content/index.cjs +3 -3
  33. package/dist/components/Content/index.cjs.map +1 -1
  34. package/dist/components/Content/index.d.cts +1 -1
  35. package/dist/components/Content/index.d.cts.map +1 -1
  36. package/dist/components/Content/index.d.mts +1 -1
  37. package/dist/components/Content/index.d.mts.map +1 -1
  38. package/dist/components/Content/index.mjs +1 -1
  39. package/dist/components/Content/index.mjs.map +1 -1
  40. package/dist/components/FilterButton/FilterButton.cjs +24 -36
  41. package/dist/components/FilterButton/FilterButton.cjs.map +1 -1
  42. package/dist/components/FilterButton/FilterButton.d.cts.map +1 -1
  43. package/dist/components/FilterButton/FilterButton.d.mts.map +1 -1
  44. package/dist/components/FilterButton/FilterButton.mjs +25 -37
  45. package/dist/components/FilterButton/FilterButton.mjs.map +1 -1
  46. package/dist/components/ListItem/ListItem.cjs +19 -8
  47. package/dist/components/ListItem/ListItem.cjs.map +1 -1
  48. package/dist/components/ListItem/ListItem.d.cts.map +1 -1
  49. package/dist/components/ListItem/ListItem.d.mts.map +1 -1
  50. package/dist/components/ListItem/ListItem.mjs +20 -9
  51. package/dist/components/ListItem/ListItem.mjs.map +1 -1
  52. package/dist/components/ListItem/index.cjs +3 -3
  53. package/dist/components/ListItem/index.cjs.map +1 -1
  54. package/dist/components/ListItem/index.d.cts +1 -1
  55. package/dist/components/ListItem/index.d.cts.map +1 -1
  56. package/dist/components/ListItem/index.d.mts +1 -1
  57. package/dist/components/ListItem/index.d.mts.map +1 -1
  58. package/dist/components/ListItem/index.mjs +1 -1
  59. package/dist/components/ListItem/index.mjs.map +1 -1
  60. package/dist/components/Slider/Slider.cjs +152 -0
  61. package/dist/components/Slider/Slider.cjs.map +1 -0
  62. package/dist/components/Slider/Slider.constants.cjs +41 -0
  63. package/dist/components/Slider/Slider.constants.cjs.map +1 -0
  64. package/dist/components/Slider/Slider.constants.d.cts +33 -0
  65. package/dist/components/Slider/Slider.constants.d.cts.map +1 -0
  66. package/dist/components/Slider/Slider.constants.d.mts +33 -0
  67. package/dist/components/Slider/Slider.constants.d.mts.map +1 -0
  68. package/dist/components/Slider/Slider.constants.mjs +38 -0
  69. package/dist/components/Slider/Slider.constants.mjs.map +1 -0
  70. package/dist/components/Slider/Slider.d.cts +7 -0
  71. package/dist/components/Slider/Slider.d.cts.map +1 -0
  72. package/dist/components/Slider/Slider.d.mts +7 -0
  73. package/dist/components/Slider/Slider.d.mts.map +1 -0
  74. package/dist/components/Slider/Slider.mjs +129 -0
  75. package/dist/components/Slider/Slider.mjs.map +1 -0
  76. package/dist/components/Slider/Slider.types.cjs +3 -0
  77. package/dist/components/Slider/Slider.types.cjs.map +1 -0
  78. package/dist/components/Slider/Slider.types.d.cts +133 -0
  79. package/dist/components/Slider/Slider.types.d.cts.map +1 -0
  80. package/dist/components/Slider/Slider.types.d.mts +133 -0
  81. package/dist/components/Slider/Slider.types.d.mts.map +1 -0
  82. package/dist/components/Slider/Slider.types.mjs +2 -0
  83. package/dist/components/Slider/Slider.types.mjs.map +1 -0
  84. package/dist/components/Slider/Slider.utilities.cjs +287 -0
  85. package/dist/components/Slider/Slider.utilities.cjs.map +1 -0
  86. package/dist/components/Slider/Slider.utilities.d.cts +157 -0
  87. package/dist/components/Slider/Slider.utilities.d.cts.map +1 -0
  88. package/dist/components/Slider/Slider.utilities.d.mts +157 -0
  89. package/dist/components/Slider/Slider.utilities.d.mts.map +1 -0
  90. package/dist/components/Slider/Slider.utilities.mjs +266 -0
  91. package/dist/components/Slider/Slider.utilities.mjs.map +1 -0
  92. package/dist/components/Slider/index.cjs +10 -0
  93. package/dist/components/Slider/index.cjs.map +1 -0
  94. package/dist/components/Slider/index.d.cts +6 -0
  95. package/dist/components/Slider/index.d.cts.map +1 -0
  96. package/dist/components/Slider/index.d.mts +6 -0
  97. package/dist/components/Slider/index.d.mts.map +1 -0
  98. package/dist/components/Slider/index.mjs +4 -0
  99. package/dist/components/Slider/index.mjs.map +1 -0
  100. package/dist/components/Slider/useSliderGesture.cjs +252 -0
  101. package/dist/components/Slider/useSliderGesture.cjs.map +1 -0
  102. package/dist/components/Slider/useSliderGesture.d.cts +17 -0
  103. package/dist/components/Slider/useSliderGesture.d.cts.map +1 -0
  104. package/dist/components/Slider/useSliderGesture.d.mts +17 -0
  105. package/dist/components/Slider/useSliderGesture.d.mts.map +1 -0
  106. package/dist/components/Slider/useSliderGesture.mjs +248 -0
  107. package/dist/components/Slider/useSliderGesture.mjs.map +1 -0
  108. package/dist/components/index.cjs +10 -5
  109. package/dist/components/index.cjs.map +1 -1
  110. package/dist/components/index.d.cts +5 -3
  111. package/dist/components/index.d.cts.map +1 -1
  112. package/dist/components/index.d.mts +5 -3
  113. package/dist/components/index.d.mts.map +1 -1
  114. package/dist/components/index.mjs +4 -3
  115. package/dist/components/index.mjs.map +1 -1
  116. package/package.json +4 -4
  117. package/dist/components/Content/Content.constants.cjs +0 -9
  118. package/dist/components/Content/Content.constants.cjs.map +0 -1
  119. package/dist/components/Content/Content.constants.d.cts +0 -3
  120. package/dist/components/Content/Content.constants.d.cts.map +0 -1
  121. package/dist/components/Content/Content.constants.d.mts +0 -3
  122. package/dist/components/Content/Content.constants.d.mts.map +0 -1
  123. package/dist/components/Content/Content.constants.mjs +0 -6
  124. package/dist/components/Content/Content.constants.mjs.map +0 -1
@@ -0,0 +1,7 @@
1
+ import React from "react";
2
+ import type { SliderProps } from "./Slider.types.cjs";
3
+ export declare const Slider: {
4
+ ({ value, onValueChange, onDragEnd, minimumValue, maximumValue, step, isDisabled, testID, marks, showRangeLabels, showRangeDots, onGrip, onMark, mapValueToTrackPercent, mapTrackPercentToValue, trackInset, twClassName, style, ...props }: SliderProps): React.JSX.Element;
5
+ displayName: string;
6
+ };
7
+ //# sourceMappingURL=Slider.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Slider.d.cts","sourceRoot":"","sources":["../../../src/components/Slider/Slider.tsx"],"names":[],"mappings":"AAYA,OAAO,KAA+B,cAAc;AAmBpD,OAAO,KAAK,EAAE,WAAW,EAAE,2BAAuB;AAUlD,eAAO,MAAM,MAAM;iPAoBhB,WAAW;;CAwMb,CAAC"}
@@ -0,0 +1,7 @@
1
+ import React from "react";
2
+ import type { SliderProps } from "./Slider.types.mjs";
3
+ export declare const Slider: {
4
+ ({ value, onValueChange, onDragEnd, minimumValue, maximumValue, step, isDisabled, testID, marks, showRangeLabels, showRangeDots, onGrip, onMark, mapValueToTrackPercent, mapTrackPercentToValue, trackInset, twClassName, style, ...props }: SliderProps): React.JSX.Element;
5
+ displayName: string;
6
+ };
7
+ //# sourceMappingURL=Slider.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Slider.d.mts","sourceRoot":"","sources":["../../../src/components/Slider/Slider.tsx"],"names":[],"mappings":"AAYA,OAAO,KAA+B,cAAc;AAmBpD,OAAO,KAAK,EAAE,WAAW,EAAE,2BAAuB;AAUlD,eAAO,MAAM,MAAM;iPAoBhB,WAAW;;CAwMb,CAAC"}
@@ -0,0 +1,129 @@
1
+ function $importDefault(module) {
2
+ if (module?.__esModule) {
3
+ return module.default;
4
+ }
5
+ return module;
6
+ }
7
+ import { FontWeight, TextColor, TextVariant, SliderMarkColor } from "@metamask/design-system-shared";
8
+ import { getThemeColors, usePureBlack, useTailwind, useTheme } from "@metamask/design-system-twrnc-preset";
9
+ import $React, { useCallback, useMemo } from "react";
10
+ const React = $importDefault($React);
11
+ import { Pressable } from "react-native";
12
+ import { GestureDetector } from "react-native-gesture-handler";
13
+ import Animated from "react-native-reanimated";
14
+ import { Box } from "../Box/index.mjs";
15
+ import { Text } from "../Text/index.mjs";
16
+ import { DEFAULT_MARKS, RANGE_LABEL_TOP, SLIDER_BOTTOM_PADDING, SLIDER_TRACK_INSET, THUMB_BOTTOM_OFFSET, THUMB_LEFT_OFFSET, THUMB_SIZE, THUMB_TOP_OFFSET } from "./Slider.constants.mjs";
17
+ import { buildColorStops, clampValueToRange, getDotLeftPercent, getTrackPercentFromValue, hasThemedMarkColors } from "./Slider.utilities.mjs";
18
+ import { useSliderGesture } from "./useSliderGesture.mjs";
19
+ export const Slider = ({ value, onValueChange, onDragEnd, minimumValue = 0, maximumValue = 100, step = 1, isDisabled = false, testID, marks = DEFAULT_MARKS, showRangeLabels = false, showRangeDots = false, onGrip, onMark, mapValueToTrackPercent, mapTrackPercentToValue, trackInset = SLIDER_TRACK_INSET, twClassName, style, ...props }) => {
20
+ const tw = useTailwind();
21
+ const theme = useTheme();
22
+ const isPureBlack = usePureBlack();
23
+ const palette = useMemo(() => getThemeColors(theme, isPureBlack), [isPureBlack, theme]);
24
+ const themedColors = useMemo(() => {
25
+ const hasThemedColors = hasThemedMarkColors(marks);
26
+ return {
27
+ hasThemedColors,
28
+ fillColorStops: buildColorStops(marks, palette, SliderMarkColor.IconAlternative),
29
+ thumbColorStops: buildColorStops(marks, palette, SliderMarkColor.IconDefault),
30
+ };
31
+ }, [palette, marks]);
32
+ const labeledMarks = useMemo(() => marks.filter((mark) => mark.label !== undefined), [marks]);
33
+ const { handleLayout, progressStyle, thumbStyle, gesture, handlePressStep } = useSliderGesture({
34
+ value,
35
+ minimumValue,
36
+ maximumValue,
37
+ step,
38
+ isDisabled,
39
+ onValueChange,
40
+ onDragEnd,
41
+ onGrip,
42
+ onMark,
43
+ marks,
44
+ fillColorStops: themedColors.fillColorStops,
45
+ thumbColorStops: themedColors.thumbColorStops,
46
+ hasThemedColors: themedColors.hasThemedColors,
47
+ mapValueToTrackPercent,
48
+ mapTrackPercentToValue,
49
+ });
50
+ const getAccessibilityText = useCallback(() => {
51
+ const trackPercent = Math.round(getTrackPercentFromValue(value, minimumValue, maximumValue, mapValueToTrackPercent));
52
+ return `${trackPercent}%`;
53
+ }, [mapValueToTrackPercent, maximumValue, minimumValue, value]);
54
+ const handleAccessibilityAction = useCallback((event) => {
55
+ if (isDisabled) {
56
+ return;
57
+ }
58
+ const delta = event.nativeEvent.actionName === 'increment' ? step : -step;
59
+ const nextValue = clampValueToRange(value + delta, minimumValue, maximumValue, step);
60
+ if (nextValue !== value) {
61
+ onValueChange(nextValue);
62
+ onDragEnd?.(nextValue);
63
+ }
64
+ }, [
65
+ isDisabled,
66
+ maximumValue,
67
+ minimumValue,
68
+ onDragEnd,
69
+ onValueChange,
70
+ step,
71
+ value,
72
+ ]);
73
+ return (<Box {...props} testID={testID} accessibilityRole="adjustable" accessibilityState={{ disabled: isDisabled }} accessibilityValue={{
74
+ min: minimumValue,
75
+ max: maximumValue,
76
+ now: value,
77
+ text: getAccessibilityText(),
78
+ }} accessibilityActions={[{ name: 'increment' }, { name: 'decrement' }]} onAccessibilityAction={handleAccessibilityAction} onLayout={handleLayout} style={[
79
+ tw.style('relative self-stretch', isDisabled ? 'py-2 opacity-40' : 'py-2'),
80
+ {
81
+ marginHorizontal: trackInset,
82
+ ...(showRangeLabels && { paddingBottom: SLIDER_BOTTOM_PADDING }),
83
+ },
84
+ style,
85
+ ]} twClassName={twClassName}>
86
+ <GestureDetector gesture={gesture}>
87
+ <Animated.View style={[tw.style('relative'), { height: THUMB_BOTTOM_OFFSET }]}>
88
+ <Animated.View style={tw.style('absolute left-0 top-0 h-2 w-full rounded-full bg-border-muted')}/>
89
+ <Animated.View style={[
90
+ tw.style('absolute left-0 top-0 h-2 rounded-full', !themedColors.hasThemedColors && 'bg-icon-alternative'),
91
+ progressStyle,
92
+ ]}/>
93
+ {showRangeDots &&
94
+ marks.map((mark) => (<Box key={`dot-${mark.step}`} pointerEvents="none" twClassName="absolute top-0.5 h-1 w-1 rounded-full bg-text-muted" style={{
95
+ left: getDotLeftPercent(mark.step),
96
+ transform: [{ translateX: -2 }],
97
+ zIndex: -2,
98
+ }}/>))}
99
+ <Animated.View style={[
100
+ tw.style('absolute rounded-full', !themedColors.hasThemedColors && 'bg-icon-default'),
101
+ {
102
+ width: THUMB_SIZE,
103
+ height: THUMB_SIZE,
104
+ top: THUMB_TOP_OFFSET,
105
+ left: THUMB_LEFT_OFFSET,
106
+ elevation: 4,
107
+ },
108
+ thumbStyle,
109
+ ]} hitSlop={{ top: 25, bottom: 25, left: 25, right: 25 }}/>
110
+ </Animated.View>
111
+ </GestureDetector>
112
+
113
+ {showRangeLabels &&
114
+ labeledMarks.map((mark) => (<Pressable key={`label-${mark.step}`} style={[
115
+ tw.style('absolute items-center'),
116
+ {
117
+ top: RANGE_LABEL_TOP,
118
+ left: getDotLeftPercent(mark.step),
119
+ transform: [{ translateX: '-50%' }],
120
+ },
121
+ ]} onPress={() => handlePressStep(mark.step)} disabled={isDisabled} accessibilityRole="button">
122
+ <Text variant={TextVariant.BodyMd} fontWeight={FontWeight.Medium} color={TextColor.TextAlternative}>
123
+ {mark.label}
124
+ </Text>
125
+ </Pressable>))}
126
+ </Box>);
127
+ };
128
+ Slider.displayName = 'Slider';
129
+ //# sourceMappingURL=Slider.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Slider.mjs","sourceRoot":"","sources":["../../../src/components/Slider/Slider.tsx"],"names":[],"mappings":";;;;;;AAAA,OAAO,EACL,UAAU,EACV,SAAS,EACT,WAAW,EACX,eAAe,EAChB,uCAAuC;AACxC,OAAO,EACL,cAAc,EACd,YAAY,EACZ,WAAW,EACX,QAAQ,EACT,6CAA6C;AAC9C,OAAO,QAAO,EAAE,WAAW,EAAE,OAAO,EAAE,cAAc;;AACpD,OAAO,EAA4B,SAAS,EAAE,qBAAqB;AAEnE,OAAO,EAAE,eAAe,EAAE,qCAAqC;AAC/D,OAAO,QAAQ,gCAAgC;AAE/C,OAAO,EAAE,GAAG,EAAE,yBAAe;AAC7B,OAAO,EAAE,IAAI,EAAE,0BAAgB;AAE/B,OAAO,EACL,aAAa,EACb,eAAe,EACf,qBAAqB,EACrB,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,EACjB,UAAU,EACV,gBAAgB,EACjB,+BAA2B;AAE5B,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,iBAAiB,EACjB,wBAAwB,EACxB,mBAAmB,EACpB,+BAA2B;AAC5B,OAAO,E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Ae;wBACpB,IAAI,EAAE,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAsB;wBACvD,SAAS,EAAE,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,CAAC;qBACpC;iBACF,CAAC,CACF,OAAO,CAAC,CAAC,GAAG,EAAE,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAC1C,QAAQ,CAAC,CAAC,UAAU,CAAC,CACrB,iBAAiB,CAAC,QAAQ,CAE1B;YAAA,CAAC,IAAI,CACH,OAAO,CAAC,CAAC,WAAW,CAAC,MAAM,CAAC,CAC5B,UAAU,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,CAC9B,KAAK,CAAC,CAAC,SAAS,CAAC,eAAe,CAAC,CAEjC;cAAA,CAAC,IAAI,CAAC,KAAK,CACb;YAAA,EAAE,IAAI,CACR;UAAA,EAAE,SAAS,CAAC,CACb,CAAC,CACN;IAAA,EAAE,GAAG,CAAC,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,WAAW,GAAG,QAAQ,CAAC","sourcesContent":["import {\n FontWeight,\n TextColor,\n TextVariant,\n SliderMarkColor,\n} from '@metamask/design-system-shared';\nimport {\n getThemeColors,\n usePureBlack,\n useTailwind,\n useTheme,\n} from '@metamask/design-system-twrnc-preset';\nimport React, { useCallback, useMemo } from 'react';\nimport { AccessibilityActionEvent, Pressable } from 'react-native';\nimport type { ViewStyle } from 'react-native';\nimport { GestureDetector } from 'react-native-gesture-handler';\nimport Animated from 'react-native-reanimated';\n\nimport { Box } from '../Box';\nimport { Text } from '../Text';\n\nimport {\n DEFAULT_MARKS,\n RANGE_LABEL_TOP,\n SLIDER_BOTTOM_PADDING,\n SLIDER_TRACK_INSET,\n THUMB_BOTTOM_OFFSET,\n THUMB_LEFT_OFFSET,\n THUMB_SIZE,\n THUMB_TOP_OFFSET,\n} from './Slider.constants';\nimport type { SliderProps } from './Slider.types';\nimport {\n buildColorStops,\n clampValueToRange,\n getDotLeftPercent,\n getTrackPercentFromValue,\n hasThemedMarkColors,\n} from './Slider.utilities';\nimport { useSliderGesture } from './useSliderGesture';\n\nexport const Slider = ({\n value,\n onValueChange,\n onDragEnd,\n minimumValue = 0,\n maximumValue = 100,\n step = 1,\n isDisabled = false,\n testID,\n marks = DEFAULT_MARKS,\n showRangeLabels = false,\n showRangeDots = false,\n onGrip,\n onMark,\n mapValueToTrackPercent,\n mapTrackPercentToValue,\n trackInset = SLIDER_TRACK_INSET,\n twClassName,\n style,\n ...props\n}: SliderProps) => {\n const tw = useTailwind();\n const theme = useTheme();\n const isPureBlack = usePureBlack();\n\n const palette = useMemo(\n () => getThemeColors(theme, isPureBlack),\n [isPureBlack, theme],\n );\n\n const themedColors = useMemo(() => {\n const hasThemedColors = hasThemedMarkColors(marks);\n\n return {\n hasThemedColors,\n fillColorStops: buildColorStops(\n marks,\n palette,\n SliderMarkColor.IconAlternative,\n ),\n thumbColorStops: buildColorStops(\n marks,\n palette,\n SliderMarkColor.IconDefault,\n ),\n };\n }, [palette, marks]);\n\n const labeledMarks = useMemo(\n () => marks.filter((mark) => mark.label !== undefined),\n [marks],\n );\n\n const { handleLayout, progressStyle, thumbStyle, gesture, handlePressStep } =\n useSliderGesture({\n value,\n minimumValue,\n maximumValue,\n step,\n isDisabled,\n onValueChange,\n onDragEnd,\n onGrip,\n onMark,\n marks,\n fillColorStops: themedColors.fillColorStops,\n thumbColorStops: themedColors.thumbColorStops,\n hasThemedColors: themedColors.hasThemedColors,\n mapValueToTrackPercent,\n mapTrackPercentToValue,\n });\n\n const getAccessibilityText = useCallback(() => {\n const trackPercent = Math.round(\n getTrackPercentFromValue(\n value,\n minimumValue,\n maximumValue,\n mapValueToTrackPercent,\n ),\n );\n return `${trackPercent}%`;\n }, [mapValueToTrackPercent, maximumValue, minimumValue, value]);\n\n const handleAccessibilityAction = useCallback(\n (event: AccessibilityActionEvent) => {\n if (isDisabled) {\n return;\n }\n\n const delta = event.nativeEvent.actionName === 'increment' ? step : -step;\n const nextValue = clampValueToRange(\n value + delta,\n minimumValue,\n maximumValue,\n step,\n );\n\n if (nextValue !== value) {\n onValueChange(nextValue);\n onDragEnd?.(nextValue);\n }\n },\n [\n isDisabled,\n maximumValue,\n minimumValue,\n onDragEnd,\n onValueChange,\n step,\n value,\n ],\n );\n\n return (\n <Box\n {...props}\n testID={testID}\n accessibilityRole=\"adjustable\"\n accessibilityState={{ disabled: isDisabled }}\n accessibilityValue={{\n min: minimumValue,\n max: maximumValue,\n now: value,\n text: getAccessibilityText(),\n }}\n accessibilityActions={[{ name: 'increment' }, { name: 'decrement' }]}\n onAccessibilityAction={handleAccessibilityAction}\n onLayout={handleLayout}\n style={[\n tw.style(\n 'relative self-stretch',\n isDisabled ? 'py-2 opacity-40' : 'py-2',\n ),\n {\n marginHorizontal: trackInset,\n ...(showRangeLabels && { paddingBottom: SLIDER_BOTTOM_PADDING }),\n },\n style,\n ]}\n twClassName={twClassName}\n >\n <GestureDetector gesture={gesture}>\n <Animated.View\n style={[tw.style('relative'), { height: THUMB_BOTTOM_OFFSET }]}\n >\n <Animated.View\n style={tw.style(\n 'absolute left-0 top-0 h-2 w-full rounded-full bg-border-muted',\n )}\n />\n <Animated.View\n style={[\n tw.style(\n 'absolute left-0 top-0 h-2 rounded-full',\n !themedColors.hasThemedColors && 'bg-icon-alternative',\n ),\n progressStyle,\n ]}\n />\n {showRangeDots &&\n marks.map((mark) => (\n <Box\n key={`dot-${mark.step}`}\n pointerEvents=\"none\"\n twClassName=\"absolute top-0.5 h-1 w-1 rounded-full bg-text-muted\"\n style={{\n left: getDotLeftPercent(mark.step) as ViewStyle['left'],\n transform: [{ translateX: -2 }],\n zIndex: -2,\n }}\n />\n ))}\n <Animated.View\n style={[\n tw.style(\n 'absolute rounded-full',\n !themedColors.hasThemedColors && 'bg-icon-default',\n ),\n {\n width: THUMB_SIZE,\n height: THUMB_SIZE,\n top: THUMB_TOP_OFFSET,\n left: THUMB_LEFT_OFFSET,\n elevation: 4,\n },\n thumbStyle,\n ]}\n hitSlop={{ top: 25, bottom: 25, left: 25, right: 25 }}\n />\n </Animated.View>\n </GestureDetector>\n\n {showRangeLabels &&\n labeledMarks.map((mark) => (\n <Pressable\n key={`label-${mark.step}`}\n style={[\n tw.style('absolute items-center'),\n {\n top: RANGE_LABEL_TOP,\n left: getDotLeftPercent(mark.step) as ViewStyle['left'],\n transform: [{ translateX: '-50%' }],\n },\n ]}\n onPress={() => handlePressStep(mark.step)}\n disabled={isDisabled}\n accessibilityRole=\"button\"\n >\n <Text\n variant={TextVariant.BodyMd}\n fontWeight={FontWeight.Medium}\n color={TextColor.TextAlternative}\n >\n {mark.label}\n </Text>\n </Pressable>\n ))}\n </Box>\n );\n};\n\nSlider.displayName = 'Slider';\n"]}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=Slider.types.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Slider.types.cjs","sourceRoot":"","sources":["../../../src/components/Slider/Slider.types.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n SliderPropsShared,\n SliderMark,\n SliderMarkColor,\n} from '@metamask/design-system-shared';\nimport type { ViewProps } from 'react-native';\nimport type { Gesture } from 'react-native-gesture-handler';\nimport type { useAnimatedStyle } from 'react-native-reanimated';\n\nimport type { SliderColorStop } from './Slider.utilities';\n\nexport type { SliderMark, SliderMarkColor };\n\n/**\n * React Native Slider props.\n *\n * Extends {@link SliderPropsShared} for cross-platform API (value, range, labels,\n * custom scale hooks) and `ViewProps` for root container passthrough (e.g.\n * `testID`, `accessibilityLabel`). See README for consumer-facing prop docs.\n */\nexport type SliderProps = SliderPropsShared &\n ViewProps & {\n /**\n * Horizontal inset on the root container so the thumb can overhang the track\n * at min/max without clipping. Defaults to {@link SLIDER_TRACK_INSET} (16);\n * override when the parent already provides edge padding.\n *\n * @default 16\n */\n trackInset?: number;\n\n /**\n * Optional twrnc classes merged into the root container after component defaults.\n * Use for layout spacing the Box API does not cover (e.g. `mt-4`).\n */\n twClassName?: string;\n };\n\n/**\n * Inputs for `useSliderGesture` — gesture handling and animated thumb/fill sync.\n *\n * Only `value` and `onValueChange` are required. Remaining fields default to the\n * same values as {@link SliderPropsShared} when omitted.\n */\nexport type UseSliderGestureParams = {\n /** Controlled domain value (`minimumValue`…`maximumValue`). */\n value: number;\n\n /**\n * Lower bound of the domain range.\n *\n * @default 0\n */\n minimumValue?: number;\n\n /**\n * Upper bound of the domain range.\n *\n * @default 100\n */\n maximumValue?: number;\n\n /**\n * Step increment applied by the default `mapTrackPercentToValue` mapper.\n * Custom mappers handle stepping inside `mapTrackPercentToValue`.\n *\n * @default 1\n */\n step?: number;\n\n /**\n * When true, pan/tap gestures and range-label presses are disabled.\n *\n * @default false\n */\n isDisabled?: boolean;\n\n /**\n * Called on every value change during pan drag, track tap, or range-label press.\n * Bridged from UI-thread worklets via `runOnJS`.\n */\n onValueChange: (value: number) => void;\n\n /**\n * Called when a gesture completes (finger lift, tap, or label press).\n * Omitted when the parent does not pass `onDragEnd`.\n */\n onDragEnd?: (value: number) => void;\n\n /**\n * Fires once when pan begins and once when pan ends; not fired on tap or\n * range-label press. Use for haptic feedback (e.g. ImpactMoment.SliderGrip).\n */\n onGrip?: () => void;\n\n /**\n * Called when track percent crosses a haptic mark threshold while dragging.\n * Evaluated on each pan `onUpdate` and on range-label press.\n */\n onMark?: () => void;\n\n /** Mark entries for label press value resolution and haptic thresholds. */\n marks: readonly SliderMark[];\n\n /** Resolved fill color stops for themed interpolation. */\n fillColorStops: readonly SliderColorStop[];\n\n /** Resolved thumb color stops for themed interpolation. */\n thumbColorStops: readonly SliderColorStop[];\n\n /** When true, thumb and fill use interpolated theme colors. */\n hasThemedColors: boolean;\n\n /**\n * Maps domain value → 0–100 track position for thumb/fill sync.\n * Must be a Reanimated worklet when provided (`'worklet';` in the function body).\n */\n mapValueToTrackPercent?: (value: number) => number;\n\n /**\n * Maps 0–100 track position → domain value during gestures.\n * Apply step rounding and snapping here for non-linear scales.\n * Must be a Reanimated worklet when provided (`'worklet';` in the function body).\n */\n mapTrackPercentToValue?: (trackPercent: number) => number;\n};\n\n/**\n * Return value of `useSliderGesture`.\n *\n * Wire `handleLayout`, animated styles, and `gesture` into `Slider.tsx`;\n * `handlePressStep` is bound to range-label `Pressable` targets.\n */\nexport type UseSliderGestureResult = {\n /**\n * Root `onLayout` handler. Stores track width and re-syncs thumb position\n * from the current `value` prop.\n */\n handleLayout: (event: { nativeEvent: { layout: { width: number } } }) => void;\n\n /** Animated width for the filled portion of the track (follows thumb). */\n progressStyle: ReturnType<typeof useAnimatedStyle>;\n\n /** Animated `translateX` for the thumb relative to the track start. */\n thumbStyle: ReturnType<typeof useAnimatedStyle>;\n\n /** Combined pan + tap gesture for the track/thumb hit area. */\n gesture: ReturnType<typeof Gesture.Simultaneous>;\n\n /**\n * Sets value from a tapped mark label: mark value → callbacks → thumb sync.\n * No-op when `isDisabled` is true.\n */\n handlePressStep: (rangeStep: number) => void;\n};\n"]}
@@ -0,0 +1,133 @@
1
+ import type { SliderPropsShared, SliderMark, SliderMarkColor } from "@metamask/design-system-shared";
2
+ import type { ViewProps } from "react-native";
3
+ import type { Gesture } from "react-native-gesture-handler";
4
+ import type { useAnimatedStyle } from "react-native-reanimated";
5
+ import type { SliderColorStop } from "./Slider.utilities.cjs";
6
+ export type { SliderMark, SliderMarkColor };
7
+ /**
8
+ * React Native Slider props.
9
+ *
10
+ * Extends {@link SliderPropsShared} for cross-platform API (value, range, labels,
11
+ * custom scale hooks) and `ViewProps` for root container passthrough (e.g.
12
+ * `testID`, `accessibilityLabel`). See README for consumer-facing prop docs.
13
+ */
14
+ export type SliderProps = SliderPropsShared & ViewProps & {
15
+ /**
16
+ * Horizontal inset on the root container so the thumb can overhang the track
17
+ * at min/max without clipping. Defaults to {@link SLIDER_TRACK_INSET} (16);
18
+ * override when the parent already provides edge padding.
19
+ *
20
+ * @default 16
21
+ */
22
+ trackInset?: number;
23
+ /**
24
+ * Optional twrnc classes merged into the root container after component defaults.
25
+ * Use for layout spacing the Box API does not cover (e.g. `mt-4`).
26
+ */
27
+ twClassName?: string;
28
+ };
29
+ /**
30
+ * Inputs for `useSliderGesture` — gesture handling and animated thumb/fill sync.
31
+ *
32
+ * Only `value` and `onValueChange` are required. Remaining fields default to the
33
+ * same values as {@link SliderPropsShared} when omitted.
34
+ */
35
+ export type UseSliderGestureParams = {
36
+ /** Controlled domain value (`minimumValue`…`maximumValue`). */
37
+ value: number;
38
+ /**
39
+ * Lower bound of the domain range.
40
+ *
41
+ * @default 0
42
+ */
43
+ minimumValue?: number;
44
+ /**
45
+ * Upper bound of the domain range.
46
+ *
47
+ * @default 100
48
+ */
49
+ maximumValue?: number;
50
+ /**
51
+ * Step increment applied by the default `mapTrackPercentToValue` mapper.
52
+ * Custom mappers handle stepping inside `mapTrackPercentToValue`.
53
+ *
54
+ * @default 1
55
+ */
56
+ step?: number;
57
+ /**
58
+ * When true, pan/tap gestures and range-label presses are disabled.
59
+ *
60
+ * @default false
61
+ */
62
+ isDisabled?: boolean;
63
+ /**
64
+ * Called on every value change during pan drag, track tap, or range-label press.
65
+ * Bridged from UI-thread worklets via `runOnJS`.
66
+ */
67
+ onValueChange: (value: number) => void;
68
+ /**
69
+ * Called when a gesture completes (finger lift, tap, or label press).
70
+ * Omitted when the parent does not pass `onDragEnd`.
71
+ */
72
+ onDragEnd?: (value: number) => void;
73
+ /**
74
+ * Fires once when pan begins and once when pan ends; not fired on tap or
75
+ * range-label press. Use for haptic feedback (e.g. ImpactMoment.SliderGrip).
76
+ */
77
+ onGrip?: () => void;
78
+ /**
79
+ * Called when track percent crosses a haptic mark threshold while dragging.
80
+ * Evaluated on each pan `onUpdate` and on range-label press.
81
+ */
82
+ onMark?: () => void;
83
+ /** Mark entries for label press value resolution and haptic thresholds. */
84
+ marks: readonly SliderMark[];
85
+ /** Resolved fill color stops for themed interpolation. */
86
+ fillColorStops: readonly SliderColorStop[];
87
+ /** Resolved thumb color stops for themed interpolation. */
88
+ thumbColorStops: readonly SliderColorStop[];
89
+ /** When true, thumb and fill use interpolated theme colors. */
90
+ hasThemedColors: boolean;
91
+ /**
92
+ * Maps domain value → 0–100 track position for thumb/fill sync.
93
+ * Must be a Reanimated worklet when provided (`'worklet';` in the function body).
94
+ */
95
+ mapValueToTrackPercent?: (value: number) => number;
96
+ /**
97
+ * Maps 0–100 track position → domain value during gestures.
98
+ * Apply step rounding and snapping here for non-linear scales.
99
+ * Must be a Reanimated worklet when provided (`'worklet';` in the function body).
100
+ */
101
+ mapTrackPercentToValue?: (trackPercent: number) => number;
102
+ };
103
+ /**
104
+ * Return value of `useSliderGesture`.
105
+ *
106
+ * Wire `handleLayout`, animated styles, and `gesture` into `Slider.tsx`;
107
+ * `handlePressStep` is bound to range-label `Pressable` targets.
108
+ */
109
+ export type UseSliderGestureResult = {
110
+ /**
111
+ * Root `onLayout` handler. Stores track width and re-syncs thumb position
112
+ * from the current `value` prop.
113
+ */
114
+ handleLayout: (event: {
115
+ nativeEvent: {
116
+ layout: {
117
+ width: number;
118
+ };
119
+ };
120
+ }) => void;
121
+ /** Animated width for the filled portion of the track (follows thumb). */
122
+ progressStyle: ReturnType<typeof useAnimatedStyle>;
123
+ /** Animated `translateX` for the thumb relative to the track start. */
124
+ thumbStyle: ReturnType<typeof useAnimatedStyle>;
125
+ /** Combined pan + tap gesture for the track/thumb hit area. */
126
+ gesture: ReturnType<typeof Gesture.Simultaneous>;
127
+ /**
128
+ * Sets value from a tapped mark label: mark value → callbacks → thumb sync.
129
+ * No-op when `isDisabled` is true.
130
+ */
131
+ handlePressStep: (rangeStep: number) => void;
132
+ };
133
+ //# sourceMappingURL=Slider.types.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Slider.types.d.cts","sourceRoot":"","sources":["../../../src/components/Slider/Slider.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iBAAiB,EACjB,UAAU,EACV,eAAe,EAChB,uCAAu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IACH,sBAAsB,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;IAEnD;;;;OAIG;IACH,sBAAsB,CAAC,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,MAAM,CAAC;CAC3D,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,sBAAsB,GAAG;IACnC;;;OAGG;IACH,YAAY,EAAE,CAAC,KAAK,EAAE;QAAE,WAAW,EAAE;YAAE,MAAM,EAAE;gBAAE,KAAK,EAAE,MAAM,CAAA;aAAE,CAAA;SAAE,CAAA;KAAE,KAAK,IAAI,CAAC;IAE9E,0EAA0E;IAC1E,aAAa,EAAE,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAAC;IAEnD,uEAAuE;IACvE,UAAU,EAAE,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAAC;IAEhD,+DAA+D;IAC/D,OAAO,EAAE,UAAU,CAAC,OAAO,OAAO,CAAC,YAAY,CAAC,CAAC;IAEjD;;;OAGG;IACH,eAAe,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;CAC9C,CAAC"}
@@ -0,0 +1,133 @@
1
+ import type { SliderPropsShared, SliderMark, SliderMarkColor } from "@metamask/design-system-shared";
2
+ import type { ViewProps } from "react-native";
3
+ import type { Gesture } from "react-native-gesture-handler";
4
+ import type { useAnimatedStyle } from "react-native-reanimated";
5
+ import type { SliderColorStop } from "./Slider.utilities.mjs";
6
+ export type { SliderMark, SliderMarkColor };
7
+ /**
8
+ * React Native Slider props.
9
+ *
10
+ * Extends {@link SliderPropsShared} for cross-platform API (value, range, labels,
11
+ * custom scale hooks) and `ViewProps` for root container passthrough (e.g.
12
+ * `testID`, `accessibilityLabel`). See README for consumer-facing prop docs.
13
+ */
14
+ export type SliderProps = SliderPropsShared & ViewProps & {
15
+ /**
16
+ * Horizontal inset on the root container so the thumb can overhang the track
17
+ * at min/max without clipping. Defaults to {@link SLIDER_TRACK_INSET} (16);
18
+ * override when the parent already provides edge padding.
19
+ *
20
+ * @default 16
21
+ */
22
+ trackInset?: number;
23
+ /**
24
+ * Optional twrnc classes merged into the root container after component defaults.
25
+ * Use for layout spacing the Box API does not cover (e.g. `mt-4`).
26
+ */
27
+ twClassName?: string;
28
+ };
29
+ /**
30
+ * Inputs for `useSliderGesture` — gesture handling and animated thumb/fill sync.
31
+ *
32
+ * Only `value` and `onValueChange` are required. Remaining fields default to the
33
+ * same values as {@link SliderPropsShared} when omitted.
34
+ */
35
+ export type UseSliderGestureParams = {
36
+ /** Controlled domain value (`minimumValue`…`maximumValue`). */
37
+ value: number;
38
+ /**
39
+ * Lower bound of the domain range.
40
+ *
41
+ * @default 0
42
+ */
43
+ minimumValue?: number;
44
+ /**
45
+ * Upper bound of the domain range.
46
+ *
47
+ * @default 100
48
+ */
49
+ maximumValue?: number;
50
+ /**
51
+ * Step increment applied by the default `mapTrackPercentToValue` mapper.
52
+ * Custom mappers handle stepping inside `mapTrackPercentToValue`.
53
+ *
54
+ * @default 1
55
+ */
56
+ step?: number;
57
+ /**
58
+ * When true, pan/tap gestures and range-label presses are disabled.
59
+ *
60
+ * @default false
61
+ */
62
+ isDisabled?: boolean;
63
+ /**
64
+ * Called on every value change during pan drag, track tap, or range-label press.
65
+ * Bridged from UI-thread worklets via `runOnJS`.
66
+ */
67
+ onValueChange: (value: number) => void;
68
+ /**
69
+ * Called when a gesture completes (finger lift, tap, or label press).
70
+ * Omitted when the parent does not pass `onDragEnd`.
71
+ */
72
+ onDragEnd?: (value: number) => void;
73
+ /**
74
+ * Fires once when pan begins and once when pan ends; not fired on tap or
75
+ * range-label press. Use for haptic feedback (e.g. ImpactMoment.SliderGrip).
76
+ */
77
+ onGrip?: () => void;
78
+ /**
79
+ * Called when track percent crosses a haptic mark threshold while dragging.
80
+ * Evaluated on each pan `onUpdate` and on range-label press.
81
+ */
82
+ onMark?: () => void;
83
+ /** Mark entries for label press value resolution and haptic thresholds. */
84
+ marks: readonly SliderMark[];
85
+ /** Resolved fill color stops for themed interpolation. */
86
+ fillColorStops: readonly SliderColorStop[];
87
+ /** Resolved thumb color stops for themed interpolation. */
88
+ thumbColorStops: readonly SliderColorStop[];
89
+ /** When true, thumb and fill use interpolated theme colors. */
90
+ hasThemedColors: boolean;
91
+ /**
92
+ * Maps domain value → 0–100 track position for thumb/fill sync.
93
+ * Must be a Reanimated worklet when provided (`'worklet';` in the function body).
94
+ */
95
+ mapValueToTrackPercent?: (value: number) => number;
96
+ /**
97
+ * Maps 0–100 track position → domain value during gestures.
98
+ * Apply step rounding and snapping here for non-linear scales.
99
+ * Must be a Reanimated worklet when provided (`'worklet';` in the function body).
100
+ */
101
+ mapTrackPercentToValue?: (trackPercent: number) => number;
102
+ };
103
+ /**
104
+ * Return value of `useSliderGesture`.
105
+ *
106
+ * Wire `handleLayout`, animated styles, and `gesture` into `Slider.tsx`;
107
+ * `handlePressStep` is bound to range-label `Pressable` targets.
108
+ */
109
+ export type UseSliderGestureResult = {
110
+ /**
111
+ * Root `onLayout` handler. Stores track width and re-syncs thumb position
112
+ * from the current `value` prop.
113
+ */
114
+ handleLayout: (event: {
115
+ nativeEvent: {
116
+ layout: {
117
+ width: number;
118
+ };
119
+ };
120
+ }) => void;
121
+ /** Animated width for the filled portion of the track (follows thumb). */
122
+ progressStyle: ReturnType<typeof useAnimatedStyle>;
123
+ /** Animated `translateX` for the thumb relative to the track start. */
124
+ thumbStyle: ReturnType<typeof useAnimatedStyle>;
125
+ /** Combined pan + tap gesture for the track/thumb hit area. */
126
+ gesture: ReturnType<typeof Gesture.Simultaneous>;
127
+ /**
128
+ * Sets value from a tapped mark label: mark value → callbacks → thumb sync.
129
+ * No-op when `isDisabled` is true.
130
+ */
131
+ handlePressStep: (rangeStep: number) => void;
132
+ };
133
+ //# sourceMappingURL=Slider.types.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Slider.types.d.mts","sourceRoot":"","sources":["../../../src/components/Slider/Slider.types.ts"],"names":[],"mappings":"AAAA,OAAO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+DAA+D;IAC/D,eAAe,EAAE,OAAO,CAAC;IAEzB;;;OAGG;IACH,sBAAsB,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;IAEnD;;;;OAIG;IACH,sBAAsB,CAAC,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,MAAM,CAAC;CAC3D,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,sBAAsB,GAAG;IACnC;;;OAGG;IACH,YAAY,EAAE,CAAC,KAAK,EAAE;QAAE,WAAW,EAAE;YAAE,MAAM,EAAE;gBAAE,KAAK,EAAE,MAAM,CAAA;aAAE,CAAA;SAAE,CAAA;KAAE,KAAK,IAAI,CAAC;IAE9E,0EAA0E;IAC1E,aAAa,EAAE,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAAC;IAEnD,uEAAuE;IACvE,UAAU,EAAE,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAAC;IAEhD,+DAA+D;IAC/D,OAAO,EAAE,UAAU,CAAC,OAAO,OAAO,CAAC,YAAY,CAAC,CAAC;IAEjD;;;OAGG;IACH,eAAe,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;CAC9C,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=Slider.types.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Slider.types.mjs","sourceRoot":"","sources":["../../../src/components/Slider/Slider.types.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n SliderPropsShared,\n SliderMark,\n SliderMarkColor,\n} from '@metamask/design-system-shared';\nimport type { ViewProps } from 'react-native';\nimport type { Gesture } from 'react-native-gesture-handler';\nimport type { useAnimatedStyle } from 'react-native-reanimated';\n\nimport type { SliderColorStop } from './Slider.utilities';\n\nexport type { SliderMark, SliderMarkColor };\n\n/**\n * React Native Slider props.\n *\n * Extends {@link SliderPropsShared} for cross-platform API (value, range, labels,\n * custom scale hooks) and `ViewProps` for root container passthrough (e.g.\n * `testID`, `accessibilityLabel`). See README for consumer-facing prop docs.\n */\nexport type SliderProps = SliderPropsShared &\n ViewProps & {\n /**\n * Horizontal inset on the root container so the thumb can overhang the track\n * at min/max without clipping. Defaults to {@link SLIDER_TRACK_INSET} (16);\n * override when the parent already provides edge padding.\n *\n * @default 16\n */\n trackInset?: number;\n\n /**\n * Optional twrnc classes merged into the root container after component defaults.\n * Use for layout spacing the Box API does not cover (e.g. `mt-4`).\n */\n twClassName?: string;\n };\n\n/**\n * Inputs for `useSliderGesture` — gesture handling and animated thumb/fill sync.\n *\n * Only `value` and `onValueChange` are required. Remaining fields default to the\n * same values as {@link SliderPropsShared} when omitted.\n */\nexport type UseSliderGestureParams = {\n /** Controlled domain value (`minimumValue`…`maximumValue`). */\n value: number;\n\n /**\n * Lower bound of the domain range.\n *\n * @default 0\n */\n minimumValue?: number;\n\n /**\n * Upper bound of the domain range.\n *\n * @default 100\n */\n maximumValue?: number;\n\n /**\n * Step increment applied by the default `mapTrackPercentToValue` mapper.\n * Custom mappers handle stepping inside `mapTrackPercentToValue`.\n *\n * @default 1\n */\n step?: number;\n\n /**\n * When true, pan/tap gestures and range-label presses are disabled.\n *\n * @default false\n */\n isDisabled?: boolean;\n\n /**\n * Called on every value change during pan drag, track tap, or range-label press.\n * Bridged from UI-thread worklets via `runOnJS`.\n */\n onValueChange: (value: number) => void;\n\n /**\n * Called when a gesture completes (finger lift, tap, or label press).\n * Omitted when the parent does not pass `onDragEnd`.\n */\n onDragEnd?: (value: number) => void;\n\n /**\n * Fires once when pan begins and once when pan ends; not fired on tap or\n * range-label press. Use for haptic feedback (e.g. ImpactMoment.SliderGrip).\n */\n onGrip?: () => void;\n\n /**\n * Called when track percent crosses a haptic mark threshold while dragging.\n * Evaluated on each pan `onUpdate` and on range-label press.\n */\n onMark?: () => void;\n\n /** Mark entries for label press value resolution and haptic thresholds. */\n marks: readonly SliderMark[];\n\n /** Resolved fill color stops for themed interpolation. */\n fillColorStops: readonly SliderColorStop[];\n\n /** Resolved thumb color stops for themed interpolation. */\n thumbColorStops: readonly SliderColorStop[];\n\n /** When true, thumb and fill use interpolated theme colors. */\n hasThemedColors: boolean;\n\n /**\n * Maps domain value → 0–100 track position for thumb/fill sync.\n * Must be a Reanimated worklet when provided (`'worklet';` in the function body).\n */\n mapValueToTrackPercent?: (value: number) => number;\n\n /**\n * Maps 0–100 track position → domain value during gestures.\n * Apply step rounding and snapping here for non-linear scales.\n * Must be a Reanimated worklet when provided (`'worklet';` in the function body).\n */\n mapTrackPercentToValue?: (trackPercent: number) => number;\n};\n\n/**\n * Return value of `useSliderGesture`.\n *\n * Wire `handleLayout`, animated styles, and `gesture` into `Slider.tsx`;\n * `handlePressStep` is bound to range-label `Pressable` targets.\n */\nexport type UseSliderGestureResult = {\n /**\n * Root `onLayout` handler. Stores track width and re-syncs thumb position\n * from the current `value` prop.\n */\n handleLayout: (event: { nativeEvent: { layout: { width: number } } }) => void;\n\n /** Animated width for the filled portion of the track (follows thumb). */\n progressStyle: ReturnType<typeof useAnimatedStyle>;\n\n /** Animated `translateX` for the thumb relative to the track start. */\n thumbStyle: ReturnType<typeof useAnimatedStyle>;\n\n /** Combined pan + tap gesture for the track/thumb hit area. */\n gesture: ReturnType<typeof Gesture.Simultaneous>;\n\n /**\n * Sets value from a tapped mark label: mark value → callbacks → thumb sync.\n * No-op when `isDisabled` is true.\n */\n handlePressStep: (rangeStep: number) => void;\n};\n"]}