@xaui/native 0.2.8 → 0.9.1-alpha.1

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 (234) hide show
  1. package/dist/chunk-KFCORXWW.cjs +150 -0
  2. package/dist/chunk-M7P46XKI.cjs +100 -0
  3. package/dist/chunk-N357EQCZ.js +150 -0
  4. package/dist/chunk-NHPQQQ7P.cjs +734 -0
  5. package/dist/chunk-PBVPOX7D.js +734 -0
  6. package/dist/chunk-RBNCR5KB.js +100 -0
  7. package/dist/index.cjs +40 -1
  8. package/dist/index.d.cts +5 -2
  9. package/dist/index.d.ts +5 -2
  10. package/dist/index.js +40 -0
  11. package/dist/system/index.cjs +7 -0
  12. package/dist/system/index.d.cts +83 -0
  13. package/dist/system/index.d.ts +83 -0
  14. package/dist/system/index.js +7 -0
  15. package/dist/theme/index.cjs +36 -0
  16. package/dist/theme/index.d.cts +539 -0
  17. package/dist/theme/index.d.ts +539 -0
  18. package/dist/theme/index.js +36 -0
  19. package/dist/theme.type-B3ODSLbB.d.cts +153 -0
  20. package/dist/theme.type-B3ODSLbB.d.ts +153 -0
  21. package/package.json +30 -248
  22. package/README.md +0 -178
  23. package/dist/alert/index.cjs +0 -340
  24. package/dist/alert/index.d.cts +0 -46
  25. package/dist/alert/index.d.ts +0 -46
  26. package/dist/alert/index.js +0 -340
  27. package/dist/app-bar/index.cjs +0 -148
  28. package/dist/app-bar/index.d.cts +0 -59
  29. package/dist/app-bar/index.d.ts +0 -59
  30. package/dist/app-bar/index.js +0 -148
  31. package/dist/autocomplete/index.cjs +0 -1122
  32. package/dist/autocomplete/index.d.cts +0 -88
  33. package/dist/autocomplete/index.d.ts +0 -88
  34. package/dist/autocomplete/index.js +0 -1122
  35. package/dist/avatar/index.cjs +0 -281
  36. package/dist/avatar/index.d.cts +0 -123
  37. package/dist/avatar/index.d.ts +0 -123
  38. package/dist/avatar/index.js +0 -281
  39. package/dist/badge/index.cjs +0 -197
  40. package/dist/badge/index.d.cts +0 -94
  41. package/dist/badge/index.d.ts +0 -94
  42. package/dist/badge/index.js +0 -197
  43. package/dist/bottom-sheet/index.cjs +0 -9
  44. package/dist/bottom-sheet/index.d.cts +0 -84
  45. package/dist/bottom-sheet/index.d.ts +0 -84
  46. package/dist/bottom-sheet/index.js +0 -9
  47. package/dist/bottom-tab-bar/index.cjs +0 -497
  48. package/dist/bottom-tab-bar/index.d.cts +0 -211
  49. package/dist/bottom-tab-bar/index.d.ts +0 -211
  50. package/dist/bottom-tab-bar/index.js +0 -497
  51. package/dist/button/index.cjs +0 -392
  52. package/dist/button/index.d.cts +0 -174
  53. package/dist/button/index.d.ts +0 -174
  54. package/dist/button/index.js +0 -392
  55. package/dist/button.type-j1ZdkkSl.d.cts +0 -4
  56. package/dist/button.type-j1ZdkkSl.d.ts +0 -4
  57. package/dist/card/index.cjs +0 -338
  58. package/dist/card/index.d.cts +0 -191
  59. package/dist/card/index.d.ts +0 -191
  60. package/dist/card/index.js +0 -338
  61. package/dist/carousel/index.cjs +0 -381
  62. package/dist/carousel/index.d.cts +0 -147
  63. package/dist/carousel/index.d.ts +0 -147
  64. package/dist/carousel/index.js +0 -381
  65. package/dist/chart/index.cjs +0 -1026
  66. package/dist/chart/index.d.cts +0 -218
  67. package/dist/chart/index.d.ts +0 -218
  68. package/dist/chart/index.js +0 -1026
  69. package/dist/checkbox/index.cjs +0 -443
  70. package/dist/checkbox/index.d.cts +0 -73
  71. package/dist/checkbox/index.d.ts +0 -73
  72. package/dist/checkbox/index.js +0 -443
  73. package/dist/chip/index.cjs +0 -503
  74. package/dist/chip/index.d.cts +0 -195
  75. package/dist/chip/index.d.ts +0 -195
  76. package/dist/chip/index.js +0 -503
  77. package/dist/chunk-4JFWQ5XT.js +0 -368
  78. package/dist/chunk-56RPWZD2.cjs +0 -9
  79. package/dist/chunk-7UFBLUMV.cjs +0 -136
  80. package/dist/chunk-A45TVXU5.js +0 -337
  81. package/dist/chunk-BYWUAPC4.cjs +0 -368
  82. package/dist/chunk-DECMUMCI.js +0 -0
  83. package/dist/chunk-DHSTKO3K.cjs +0 -19
  84. package/dist/chunk-DJ4Q37UT.cjs +0 -75
  85. package/dist/chunk-EUQDGTST.cjs +0 -1
  86. package/dist/chunk-GBHQCAKW.js +0 -19
  87. package/dist/chunk-RBSA4NH4.js +0 -136
  88. package/dist/chunk-SHBDANQN.js +0 -9
  89. package/dist/chunk-UGEINZM7.cjs +0 -290
  90. package/dist/chunk-UU4HHBDN.js +0 -290
  91. package/dist/chunk-VSZEXOUN.js +0 -384
  92. package/dist/chunk-YIEUN3G5.cjs +0 -384
  93. package/dist/chunk-ZH6ZSV2Q.cjs +0 -337
  94. package/dist/chunk-ZY7IUTAT.js +0 -75
  95. package/dist/color-picker/index.cjs +0 -457
  96. package/dist/color-picker/index.d.cts +0 -124
  97. package/dist/color-picker/index.d.ts +0 -124
  98. package/dist/color-picker/index.js +0 -457
  99. package/dist/core/index.cjs +0 -24
  100. package/dist/core/index.d.cts +0 -28
  101. package/dist/core/index.d.ts +0 -28
  102. package/dist/core/index.js +0 -24
  103. package/dist/datepicker/index.cjs +0 -1625
  104. package/dist/datepicker/index.d.cts +0 -45
  105. package/dist/datepicker/index.d.ts +0 -45
  106. package/dist/datepicker/index.js +0 -1625
  107. package/dist/dialog/index.cjs +0 -372
  108. package/dist/dialog/index.d.cts +0 -151
  109. package/dist/dialog/index.d.ts +0 -151
  110. package/dist/dialog/index.js +0 -372
  111. package/dist/divider/index.cjs +0 -8
  112. package/dist/divider/index.d.cts +0 -30
  113. package/dist/divider/index.d.ts +0 -30
  114. package/dist/divider/index.js +0 -8
  115. package/dist/drawer/index.cjs +0 -237
  116. package/dist/drawer/index.d.cts +0 -58
  117. package/dist/drawer/index.d.ts +0 -58
  118. package/dist/drawer/index.js +0 -237
  119. package/dist/expansion-panel/index.cjs +0 -441
  120. package/dist/expansion-panel/index.d.cts +0 -153
  121. package/dist/expansion-panel/index.d.ts +0 -153
  122. package/dist/expansion-panel/index.js +0 -441
  123. package/dist/fab/index.cjs +0 -9
  124. package/dist/fab/index.d.cts +0 -10
  125. package/dist/fab/index.d.ts +0 -10
  126. package/dist/fab/index.js +0 -9
  127. package/dist/fab-menu/index.cjs +0 -330
  128. package/dist/fab-menu/index.d.cts +0 -125
  129. package/dist/fab-menu/index.d.ts +0 -125
  130. package/dist/fab-menu/index.js +0 -330
  131. package/dist/fab.type-CkUHmXU_.d.ts +0 -86
  132. package/dist/fab.type-DN0vtAh6.d.cts +0 -86
  133. package/dist/feature-discovery/index.cjs +0 -464
  134. package/dist/feature-discovery/index.d.cts +0 -82
  135. package/dist/feature-discovery/index.d.ts +0 -82
  136. package/dist/feature-discovery/index.js +0 -464
  137. package/dist/indicator/index.cjs +0 -8
  138. package/dist/indicator/index.d.cts +0 -47
  139. package/dist/indicator/index.d.ts +0 -47
  140. package/dist/indicator/index.js +0 -8
  141. package/dist/input/index.cjs +0 -1462
  142. package/dist/input/index.d.cts +0 -522
  143. package/dist/input/index.d.ts +0 -522
  144. package/dist/input/index.js +0 -1462
  145. package/dist/input-trigger/index.cjs +0 -197
  146. package/dist/input-trigger/index.d.cts +0 -11
  147. package/dist/input-trigger/index.d.ts +0 -11
  148. package/dist/input-trigger/index.js +0 -197
  149. package/dist/input-trigger.type-Ba4bM3Qp.d.cts +0 -180
  150. package/dist/input-trigger.type-Ba4bM3Qp.d.ts +0 -180
  151. package/dist/list/index.cjs +0 -395
  152. package/dist/list/index.d.cts +0 -188
  153. package/dist/list/index.d.ts +0 -188
  154. package/dist/list/index.js +0 -395
  155. package/dist/menu/index.cjs +0 -316
  156. package/dist/menu/index.d.cts +0 -115
  157. package/dist/menu/index.d.ts +0 -115
  158. package/dist/menu/index.js +0 -316
  159. package/dist/menubox/index.cjs +0 -297
  160. package/dist/menubox/index.d.cts +0 -98
  161. package/dist/menubox/index.d.ts +0 -98
  162. package/dist/menubox/index.js +0 -297
  163. package/dist/pager/index.cjs +0 -205
  164. package/dist/pager/index.d.cts +0 -93
  165. package/dist/pager/index.d.ts +0 -93
  166. package/dist/pager/index.js +0 -205
  167. package/dist/picker/index.cjs +0 -244
  168. package/dist/picker/index.d.cts +0 -121
  169. package/dist/picker/index.d.ts +0 -121
  170. package/dist/picker/index.js +0 -244
  171. package/dist/progress/index.cjs +0 -219
  172. package/dist/progress/index.d.cts +0 -47
  173. package/dist/progress/index.d.ts +0 -47
  174. package/dist/progress/index.js +0 -219
  175. package/dist/radio/index.cjs +0 -465
  176. package/dist/radio/index.d.cts +0 -145
  177. package/dist/radio/index.d.ts +0 -145
  178. package/dist/radio/index.js +0 -465
  179. package/dist/refresh-control/index.cjs +0 -45
  180. package/dist/refresh-control/index.d.cts +0 -55
  181. package/dist/refresh-control/index.d.ts +0 -55
  182. package/dist/refresh-control/index.js +0 -45
  183. package/dist/segment-button/index.cjs +0 -405
  184. package/dist/segment-button/index.d.cts +0 -141
  185. package/dist/segment-button/index.d.ts +0 -141
  186. package/dist/segment-button/index.js +0 -405
  187. package/dist/select/index.cjs +0 -878
  188. package/dist/select/index.d.cts +0 -192
  189. package/dist/select/index.d.ts +0 -192
  190. package/dist/select/index.js +0 -878
  191. package/dist/skeleton/index.cjs +0 -89
  192. package/dist/skeleton/index.d.cts +0 -45
  193. package/dist/skeleton/index.d.ts +0 -45
  194. package/dist/skeleton/index.js +0 -89
  195. package/dist/slider/index.cjs +0 -576
  196. package/dist/slider/index.d.cts +0 -171
  197. package/dist/slider/index.d.ts +0 -171
  198. package/dist/slider/index.js +0 -576
  199. package/dist/snackbar/index.cjs +0 -436
  200. package/dist/snackbar/index.d.cts +0 -174
  201. package/dist/snackbar/index.d.ts +0 -174
  202. package/dist/snackbar/index.js +0 -436
  203. package/dist/snippet/index.cjs +0 -314
  204. package/dist/snippet/index.d.cts +0 -95
  205. package/dist/snippet/index.d.ts +0 -95
  206. package/dist/snippet/index.js +0 -314
  207. package/dist/stepper/index.cjs +0 -550
  208. package/dist/stepper/index.d.cts +0 -137
  209. package/dist/stepper/index.d.ts +0 -137
  210. package/dist/stepper/index.js +0 -550
  211. package/dist/switch/index.cjs +0 -358
  212. package/dist/switch/index.d.cts +0 -28
  213. package/dist/switch/index.d.ts +0 -28
  214. package/dist/switch/index.js +0 -358
  215. package/dist/tabs/index.cjs +0 -440
  216. package/dist/tabs/index.d.cts +0 -180
  217. package/dist/tabs/index.d.ts +0 -180
  218. package/dist/tabs/index.js +0 -440
  219. package/dist/timepicker/index.cjs +0 -823
  220. package/dist/timepicker/index.d.cts +0 -215
  221. package/dist/timepicker/index.d.ts +0 -215
  222. package/dist/timepicker/index.js +0 -823
  223. package/dist/toolbar/index.cjs +0 -333
  224. package/dist/toolbar/index.d.cts +0 -100
  225. package/dist/toolbar/index.d.ts +0 -100
  226. package/dist/toolbar/index.js +0 -333
  227. package/dist/typography/index.cjs +0 -238
  228. package/dist/typography/index.d.cts +0 -113
  229. package/dist/typography/index.d.ts +0 -113
  230. package/dist/typography/index.js +0 -238
  231. package/dist/view/index.cjs +0 -1361
  232. package/dist/view/index.d.cts +0 -833
  233. package/dist/view/index.d.ts +0 -833
  234. package/dist/view/index.js +0 -1361
@@ -1,576 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }require('../chunk-56RPWZD2.cjs');
2
-
3
-
4
-
5
- var _chunk7UFBLUMVcjs = require('../chunk-7UFBLUMV.cjs');
6
-
7
- // src/components/slider/slider.tsx
8
- var _react = require('react'); var _react2 = _interopRequireDefault(_react);
9
-
10
-
11
-
12
-
13
-
14
- var _reactnative = require('react-native');
15
-
16
- // src/components/slider/slider.animation.ts
17
-
18
- var runSliderThumbPressInAnimation = (scale) => {
19
- _reactnative.Animated.spring(scale, {
20
- toValue: 1.08,
21
- friction: 6,
22
- tension: 120,
23
- useNativeDriver: false
24
- }).start();
25
- };
26
- var runSliderThumbPressOutAnimation = (scale) => {
27
- _reactnative.Animated.spring(scale, {
28
- toValue: 1,
29
- friction: 6,
30
- tension: 120,
31
- useNativeDriver: false
32
- }).start();
33
- };
34
-
35
- // src/components/slider/slider.hook.ts
36
-
37
- var _core = require('@xaui/core');
38
- function useSliderSizeStyles(size) {
39
- const theme = _chunk7UFBLUMVcjs.useXUITheme.call(void 0, );
40
- return _react.useMemo.call(void 0, () => {
41
- const sizes = {
42
- xs: {
43
- trackThickness: 4,
44
- thumbSize: 14,
45
- stepDotSize: 4,
46
- markOffset: 12,
47
- fontSize: theme.fontSizes.xs
48
- },
49
- sm: {
50
- trackThickness: 6,
51
- thumbSize: 16,
52
- stepDotSize: 5,
53
- markOffset: 14,
54
- fontSize: theme.fontSizes.sm
55
- },
56
- md: {
57
- trackThickness: 8,
58
- thumbSize: 20,
59
- stepDotSize: 6,
60
- markOffset: 16,
61
- fontSize: theme.fontSizes.md
62
- },
63
- lg: {
64
- trackThickness: 10,
65
- thumbSize: 24,
66
- stepDotSize: 7,
67
- markOffset: 18,
68
- fontSize: theme.fontSizes.lg
69
- }
70
- };
71
- return sizes[size];
72
- }, [size, theme]);
73
- }
74
- function useSliderColorStyles(color, isDisabled) {
75
- const theme = _chunk7UFBLUMVcjs.useXUITheme.call(void 0, );
76
- const safeColor = _core.getSafeThemeColor.call(void 0, color);
77
- const palette = theme.colors[safeColor];
78
- const fillColor = _core.withPaletteNumber.call(void 0, palette.main, 400);
79
- return _react.useMemo.call(void 0, () => {
80
- if (isDisabled) {
81
- return {
82
- trackColor: `${theme.colors.default.main}30`,
83
- fillColor: `${theme.colors.default.main}55`,
84
- thumbColor: `${theme.colors.default.main}85`,
85
- valueColor: `${theme.colors.foreground}85`,
86
- labelColor: `${theme.colors.foreground}85`,
87
- stepColor: `${theme.colors.default.main}50`,
88
- activeStepColor: `${theme.colors.default.main}75`,
89
- markColor: `${theme.colors.foreground}80`
90
- };
91
- }
92
- return {
93
- trackColor: `${palette.main}28`,
94
- fillColor,
95
- thumbColor: fillColor,
96
- valueColor: theme.colors.foreground,
97
- labelColor: theme.colors.foreground,
98
- stepColor: `${palette.main}40`,
99
- activeStepColor: fillColor,
100
- markColor: `${theme.colors.foreground}90`
101
- };
102
- }, [fillColor, isDisabled, palette.main, theme.colors]);
103
- }
104
-
105
- // src/components/slider/slider.style.ts
106
-
107
- var styles = _reactnative.StyleSheet.create({
108
- container: {
109
- width: "100%"
110
- },
111
- header: {
112
- flexDirection: "row",
113
- alignItems: "center",
114
- justifyContent: "space-between",
115
- marginBottom: 10
116
- },
117
- row: {
118
- flexDirection: "row",
119
- alignItems: "center",
120
- gap: 10,
121
- width: "100%"
122
- },
123
- verticalRow: {
124
- flexDirection: "column",
125
- alignItems: "center",
126
- justifyContent: "center",
127
- gap: 10
128
- },
129
- trackContainer: {
130
- flex: 1,
131
- justifyContent: "center",
132
- position: "relative"
133
- },
134
- verticalTrackContainer: {
135
- height: 220,
136
- justifyContent: "center",
137
- alignItems: "center"
138
- },
139
- track: {
140
- width: "100%",
141
- overflow: "hidden"
142
- },
143
- verticalTrack: {
144
- width: 8,
145
- height: "100%"
146
- },
147
- fill: {
148
- position: "absolute",
149
- left: 0,
150
- top: 0
151
- },
152
- verticalFill: {
153
- left: 0,
154
- bottom: 0,
155
- top: void 0
156
- },
157
- thumb: {
158
- position: "absolute",
159
- justifyContent: "center",
160
- alignItems: "center"
161
- },
162
- mark: {
163
- position: "absolute",
164
- alignItems: "center"
165
- },
166
- stepDot: {
167
- position: "absolute",
168
- borderRadius: 999
169
- },
170
- disabled: {
171
- opacity: 0.55
172
- },
173
- label: {
174
- fontWeight: "600"
175
- },
176
- value: {
177
- fontWeight: "500"
178
- },
179
- markLabel: {
180
- marginTop: 6,
181
- fontSize: 12
182
- }
183
- });
184
-
185
- // src/components/slider/slider.tsx
186
- var clamp = (value, min, max) => Math.min(Math.max(value, min), max);
187
- var roundToStep = (value, min, step) => {
188
- const safeStep = step <= 0 ? 1 : step;
189
- return Math.round((value - min) / safeStep) * safeStep + min;
190
- };
191
- var valueToPercent = (value, min, max) => {
192
- const range = max - min;
193
- if (range <= 0) return 0;
194
- return (value - min) / range * 100;
195
- };
196
- var percentToValue = (percent, min, max, step) => {
197
- const raw = min + (max - min) * percent / 100;
198
- return clamp(roundToStep(raw, min, step), min, max);
199
- };
200
- var getInitialValue = ({
201
- value,
202
- defaultValue,
203
- minValue,
204
- maxValue
205
- }) => {
206
- if (value !== void 0) return clamp(value, minValue, maxValue);
207
- if (defaultValue !== void 0) return clamp(defaultValue, minValue, maxValue);
208
- return minValue;
209
- };
210
- var getRelativePosition = (location, trackLength, orientation) => {
211
- if (trackLength <= 0) return 0;
212
- const ratio = clamp(location / trackLength, 0, 1);
213
- return orientation === "vertical" ? (1 - ratio) * 100 : ratio * 100;
214
- };
215
- var renderMarkLabel = (mark) => {
216
- if (mark.label === void 0) return null;
217
- return mark.label;
218
- };
219
- var getPixelPosition = (percent, length) => {
220
- if (length <= 0) return 0;
221
- return clamp(percent, 0, 100) / 100 * length;
222
- };
223
- var Slider = ({
224
- value: controlledValue,
225
- defaultValue,
226
- minValue = 0,
227
- maxValue = 100,
228
- step = 1,
229
- label,
230
- showValueLabel = false,
231
- formatOptions,
232
- marks,
233
- showSteps = false,
234
- orientation = "horizontal",
235
- size = "md",
236
- color = "primary",
237
- radius = "full",
238
- startContent,
239
- endContent,
240
- isDisabled = false,
241
- isReadOnly = false,
242
- trackLength,
243
- onChange,
244
- onChangeEnd,
245
- customAppearance
246
- }) => {
247
- const isControlled = controlledValue !== void 0;
248
- const [internalValue, setInternalValue] = _react.useState.call(void 0,
249
- getInitialValue({
250
- value: controlledValue,
251
- defaultValue,
252
- minValue,
253
- maxValue
254
- })
255
- );
256
- const [measuredTrackLength, setMeasuredTrackLength] = _react.useState.call(void 0,
257
- trackLength && trackLength > 0 ? trackLength : 0
258
- );
259
- const currentValue = isControlled ? clamp(controlledValue, minValue, maxValue) : internalValue;
260
- const sizeStyles = useSliderSizeStyles(size);
261
- const colorStyles = useSliderColorStyles(color, isDisabled);
262
- const radiusStyles = _chunk7UFBLUMVcjs.useBorderRadiusStyles.call(void 0, radius);
263
- const theme = _chunk7UFBLUMVcjs.useXUITheme.call(void 0, );
264
- const thumbScale = _react.useRef.call(void 0, new _reactnative.Animated.Value(1)).current;
265
- const initialTouchTrackPosition = _react.useRef.call(void 0, 0);
266
- const animatedTrackPosition = _react.useRef.call(void 0, new _reactnative.Animated.Value(0)).current;
267
- const isDragging = _react.useRef.call(void 0, false);
268
- const currentValueRef = _react.useRef.call(void 0, currentValue);
269
- currentValueRef.current = currentValue;
270
- const onChangeEndRef = _react.useRef.call(void 0, onChangeEnd);
271
- onChangeEndRef.current = onChangeEnd;
272
- const thumbOverlapInset = Math.max(
273
- 0,
274
- (sizeStyles.thumbSize - sizeStyles.trackThickness) / 2
275
- );
276
- const formattedValue = _react.useMemo.call(void 0, () => {
277
- try {
278
- return new Intl.NumberFormat(void 0, formatOptions).format(currentValue);
279
- } catch (e) {
280
- return String(currentValue);
281
- }
282
- }, [currentValue, formatOptions]);
283
- const activePercent = valueToPercent(currentValue, minValue, maxValue);
284
- const effectiveTrackLength = trackLength && trackLength > 0 ? trackLength : measuredTrackLength;
285
- const thumbCenterPosition = getPixelPosition(activePercent, effectiveTrackLength);
286
- const trackContainerLengthStyle = orientation === "vertical" ? {
287
- height: (trackLength && trackLength > 0 ? trackLength : 220) + thumbOverlapInset * 2
288
- } : trackLength && trackLength > 0 ? { width: trackLength + thumbOverlapInset * 2 } : null;
289
- _react.useEffect.call(void 0, () => {
290
- if (!isDragging.current && effectiveTrackLength > 0) {
291
- animatedTrackPosition.setValue(
292
- clamp(thumbCenterPosition, 0, effectiveTrackLength)
293
- );
294
- }
295
- }, [thumbCenterPosition, effectiveTrackLength, animatedTrackPosition]);
296
- const animatedFillSize = _react.useMemo.call(void 0, () => {
297
- const safeLength = Math.max(effectiveTrackLength, 1);
298
- return animatedTrackPosition.interpolate({
299
- inputRange: [0, safeLength],
300
- outputRange: [0, safeLength],
301
- extrapolate: "clamp"
302
- });
303
- }, [animatedTrackPosition, effectiveTrackLength]);
304
- const animatedThumbOffset = _react.useMemo.call(void 0, () => {
305
- const base = thumbOverlapInset - sizeStyles.thumbSize / 2;
306
- const safeLength = Math.max(effectiveTrackLength, 1);
307
- return animatedTrackPosition.interpolate({
308
- inputRange: [0, safeLength],
309
- outputRange: [base, safeLength + base],
310
- extrapolate: "clamp"
311
- });
312
- }, [
313
- animatedTrackPosition,
314
- effectiveTrackLength,
315
- thumbOverlapInset,
316
- sizeStyles.thumbSize
317
- ]);
318
- const setValue = _react.useCallback.call(void 0,
319
- (nextValue) => {
320
- if (!isControlled) {
321
- setInternalValue(nextValue);
322
- }
323
- _optionalChain([onChange, 'optionalCall', _2 => _2(nextValue)]);
324
- },
325
- [isControlled, onChange]
326
- );
327
- const setValueFromPosition = _react.useCallback.call(void 0,
328
- (position) => {
329
- const nextPercent = getRelativePosition(
330
- position,
331
- effectiveTrackLength,
332
- orientation
333
- );
334
- const nextValue = percentToValue(nextPercent, minValue, maxValue, step);
335
- setValue(nextValue);
336
- return nextValue;
337
- },
338
- [effectiveTrackLength, maxValue, minValue, orientation, setValue, step]
339
- );
340
- const isInteractive = !isDisabled && !isReadOnly;
341
- const panResponder = _react.useMemo.call(void 0,
342
- () => _reactnative.PanResponder.create({
343
- onStartShouldSetPanResponder: () => isInteractive,
344
- onMoveShouldSetPanResponder: (_evt, gs) => {
345
- if (!isInteractive) return false;
346
- return orientation === "horizontal" ? Math.abs(gs.dx) >= Math.abs(gs.dy) : Math.abs(gs.dy) >= Math.abs(gs.dx);
347
- },
348
- onPanResponderTerminationRequest: () => !isDragging.current,
349
- onPanResponderGrant: (event) => {
350
- if (!isInteractive) return;
351
- isDragging.current = true;
352
- runSliderThumbPressInAnimation(thumbScale);
353
- const point = orientation === "vertical" ? event.nativeEvent.locationY : event.nativeEvent.locationX;
354
- const rawPosition = point - thumbOverlapInset;
355
- initialTouchTrackPosition.current = rawPosition;
356
- const clamped = clamp(rawPosition, 0, effectiveTrackLength);
357
- animatedTrackPosition.setValue(
358
- orientation === "vertical" ? effectiveTrackLength - clamped : clamped
359
- );
360
- setValueFromPosition(rawPosition);
361
- },
362
- onPanResponderMove: (_event, gestureState) => {
363
- if (!isInteractive) return;
364
- const delta = orientation === "vertical" ? gestureState.dy : gestureState.dx;
365
- const rawPosition = initialTouchTrackPosition.current + delta;
366
- const clamped = clamp(rawPosition, 0, effectiveTrackLength);
367
- animatedTrackPosition.setValue(
368
- orientation === "vertical" ? effectiveTrackLength - clamped : clamped
369
- );
370
- setValueFromPosition(rawPosition);
371
- },
372
- onPanResponderRelease: (_event, gestureState) => {
373
- isDragging.current = false;
374
- runSliderThumbPressOutAnimation(thumbScale);
375
- if (!isInteractive) return;
376
- const delta = orientation === "vertical" ? gestureState.dy : gestureState.dx;
377
- const nextValue = setValueFromPosition(
378
- initialTouchTrackPosition.current + delta
379
- );
380
- const snappedPercent = valueToPercent(nextValue, minValue, maxValue);
381
- animatedTrackPosition.setValue(
382
- getPixelPosition(snappedPercent, effectiveTrackLength)
383
- );
384
- _optionalChain([onChangeEndRef, 'access', _3 => _3.current, 'optionalCall', _4 => _4(nextValue)]);
385
- },
386
- onPanResponderTerminate: () => {
387
- isDragging.current = false;
388
- runSliderThumbPressOutAnimation(thumbScale);
389
- const val = currentValueRef.current;
390
- const pct = valueToPercent(val, minValue, maxValue);
391
- animatedTrackPosition.setValue(getPixelPosition(pct, effectiveTrackLength));
392
- _optionalChain([onChangeEndRef, 'access', _5 => _5.current, 'optionalCall', _6 => _6(val)]);
393
- }
394
- }),
395
- [
396
- animatedTrackPosition,
397
- effectiveTrackLength,
398
- isInteractive,
399
- minValue,
400
- maxValue,
401
- orientation,
402
- setValueFromPosition,
403
- thumbScale,
404
- thumbOverlapInset
405
- ]
406
- );
407
- const handleTrackLayout = _react.useCallback.call(void 0,
408
- (event) => {
409
- if (trackLength && trackLength > 0) return;
410
- const nextLength = orientation === "vertical" ? event.nativeEvent.layout.height : event.nativeEvent.layout.width;
411
- setMeasuredTrackLength(nextLength);
412
- },
413
- [orientation, trackLength]
414
- );
415
- const steps = _react.useMemo.call(void 0, () => {
416
- if (!showSteps || step <= 0 || maxValue <= minValue) return [];
417
- const count = Math.floor((maxValue - minValue) / step);
418
- if (count > 200) return [];
419
- return Array.from({ length: count + 1 }, (_, index) => minValue + index * step);
420
- }, [maxValue, minValue, showSteps, step]);
421
- return /* @__PURE__ */ _react2.default.createElement(_reactnative.View, { style: [styles.container, _optionalChain([customAppearance, 'optionalAccess', _7 => _7.container])] }, (label !== void 0 || showValueLabel) && /* @__PURE__ */ _react2.default.createElement(_reactnative.View, { style: [styles.header, _optionalChain([customAppearance, 'optionalAccess', _8 => _8.header])] }, label !== void 0 ? /* @__PURE__ */ _react2.default.createElement(
422
- _reactnative.Text,
423
- {
424
- style: [
425
- styles.label,
426
- { color: colorStyles.labelColor, fontSize: sizeStyles.fontSize },
427
- _optionalChain([customAppearance, 'optionalAccess', _9 => _9.label])
428
- ]
429
- },
430
- label
431
- ) : /* @__PURE__ */ _react2.default.createElement(_reactnative.View, null), showValueLabel && /* @__PURE__ */ _react2.default.createElement(
432
- _reactnative.Text,
433
- {
434
- style: [
435
- styles.value,
436
- { color: colorStyles.valueColor, fontSize: sizeStyles.fontSize },
437
- _optionalChain([customAppearance, 'optionalAccess', _10 => _10.value])
438
- ]
439
- },
440
- formattedValue
441
- )), /* @__PURE__ */ _react2.default.createElement(
442
- _reactnative.View,
443
- {
444
- style: [
445
- orientation === "vertical" ? styles.verticalRow : styles.row,
446
- (isDisabled || isReadOnly) && styles.disabled
447
- ]
448
- },
449
- startContent,
450
- /* @__PURE__ */ _react2.default.createElement(
451
- _reactnative.View,
452
- {
453
- ...panResponder.panHandlers,
454
- style: [
455
- styles.trackContainer,
456
- orientation === "vertical" && styles.verticalTrackContainer,
457
- {
458
- padding: thumbOverlapInset
459
- },
460
- trackContainerLengthStyle,
461
- _optionalChain([customAppearance, 'optionalAccess', _11 => _11.trackContainer])
462
- ]
463
- },
464
- /* @__PURE__ */ _react2.default.createElement(
465
- _reactnative.View,
466
- {
467
- onLayout: handleTrackLayout,
468
- style: [
469
- styles.track,
470
- orientation === "vertical" && styles.verticalTrack,
471
- {
472
- borderRadius: radiusStyles.borderRadius,
473
- backgroundColor: colorStyles.trackColor,
474
- height: orientation === "vertical" ? "100%" : sizeStyles.trackThickness,
475
- width: orientation === "vertical" ? sizeStyles.trackThickness : "100%"
476
- },
477
- _optionalChain([customAppearance, 'optionalAccess', _12 => _12.track])
478
- ]
479
- },
480
- /* @__PURE__ */ _react2.default.createElement(
481
- _reactnative.Animated.View,
482
- {
483
- style: [
484
- styles.fill,
485
- orientation === "vertical" && styles.verticalFill,
486
- {
487
- backgroundColor: colorStyles.fillColor,
488
- height: orientation === "vertical" ? effectiveTrackLength > 0 ? animatedFillSize : `${activePercent}%` : sizeStyles.trackThickness,
489
- width: orientation === "vertical" ? sizeStyles.trackThickness : effectiveTrackLength > 0 ? animatedFillSize : `${activePercent}%`
490
- },
491
- _optionalChain([customAppearance, 'optionalAccess', _13 => _13.fill])
492
- ]
493
- }
494
- ),
495
- showSteps && steps.map((stepValue) => {
496
- const percent = valueToPercent(stepValue, minValue, maxValue);
497
- const isActive = stepValue <= currentValue;
498
- return /* @__PURE__ */ _react2.default.createElement(
499
- _reactnative.View,
500
- {
501
- key: `step-${stepValue}`,
502
- style: [
503
- styles.stepDot,
504
- {
505
- width: sizeStyles.stepDotSize,
506
- height: sizeStyles.stepDotSize,
507
- backgroundColor: isActive ? colorStyles.activeStepColor : colorStyles.stepColor,
508
- left: orientation === "vertical" ? (sizeStyles.trackThickness - sizeStyles.stepDotSize) / 2 : getPixelPosition(percent, effectiveTrackLength) - sizeStyles.stepDotSize / 2,
509
- bottom: orientation === "vertical" ? getPixelPosition(percent, effectiveTrackLength) - sizeStyles.stepDotSize / 2 : (sizeStyles.trackThickness - sizeStyles.stepDotSize) / 2
510
- },
511
- _optionalChain([customAppearance, 'optionalAccess', _14 => _14.step]),
512
- isActive && _optionalChain([customAppearance, 'optionalAccess', _15 => _15.activeStep])
513
- ]
514
- }
515
- );
516
- })
517
- ),
518
- /* @__PURE__ */ _react2.default.createElement(
519
- _reactnative.Animated.View,
520
- {
521
- pointerEvents: "none",
522
- style: [
523
- styles.thumb,
524
- {
525
- width: sizeStyles.thumbSize,
526
- height: sizeStyles.thumbSize,
527
- borderRadius: sizeStyles.thumbSize / 2,
528
- left: orientation === "vertical" ? 0 : animatedThumbOffset,
529
- top: orientation === "vertical" ? void 0 : 0,
530
- bottom: orientation === "vertical" ? animatedThumbOffset : void 0,
531
- backgroundColor: theme.colors.background,
532
- borderWidth: 2,
533
- borderColor: colorStyles.fillColor,
534
- ...theme.shadows.md,
535
- transform: [{ scale: thumbScale }]
536
- },
537
- _optionalChain([customAppearance, 'optionalAccess', _16 => _16.thumb])
538
- ]
539
- }
540
- ),
541
- _optionalChain([marks, 'optionalAccess', _17 => _17.map, 'call', _18 => _18((mark) => {
542
- const percent = valueToPercent(mark.value, minValue, maxValue);
543
- return /* @__PURE__ */ _react2.default.createElement(
544
- _reactnative.View,
545
- {
546
- key: `mark-${mark.value}`,
547
- style: [
548
- styles.mark,
549
- {
550
- left: orientation === "vertical" ? thumbOverlapInset + sizeStyles.trackThickness + 8 : thumbOverlapInset + getPixelPosition(percent, effectiveTrackLength) - 10,
551
- top: orientation === "vertical" ? void 0 : thumbOverlapInset + sizeStyles.trackThickness,
552
- bottom: orientation === "vertical" ? thumbOverlapInset + getPixelPosition(percent, effectiveTrackLength) - 8 : void 0
553
- },
554
- _optionalChain([customAppearance, 'optionalAccess', _19 => _19.mark])
555
- ]
556
- },
557
- /* @__PURE__ */ _react2.default.createElement(
558
- _reactnative.Text,
559
- {
560
- style: [
561
- styles.markLabel,
562
- { color: colorStyles.markColor },
563
- _optionalChain([customAppearance, 'optionalAccess', _20 => _20.markLabel])
564
- ]
565
- },
566
- renderMarkLabel(mark)
567
- )
568
- );
569
- })])
570
- ),
571
- endContent
572
- ));
573
- };
574
-
575
-
576
- exports.Slider = Slider;