panelui-native 0.7.0 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -3
- package/lib/module/components/attachment/index.js +219 -0
- package/lib/module/components/attachment/index.js.map +1 -0
- package/lib/module/components/bottom-sheet/index.js +53 -3
- package/lib/module/components/bottom-sheet/index.js.map +1 -1
- package/lib/module/components/button/index.js +19 -1
- package/lib/module/components/button/index.js.map +1 -1
- package/lib/module/components/dialog/index.js +6 -2
- package/lib/module/components/dialog/index.js.map +1 -1
- package/lib/module/components/empty-state/index.js +94 -17
- package/lib/module/components/empty-state/index.js.map +1 -1
- package/lib/module/components/frame/index.js +128 -15
- package/lib/module/components/frame/index.js.map +1 -1
- package/lib/module/components/input/index.js +107 -15
- package/lib/module/components/input/index.js.map +1 -1
- package/lib/module/components/line-chart/index.js +1024 -0
- package/lib/module/components/line-chart/index.js.map +1 -0
- package/lib/module/components/marker/index.js +190 -0
- package/lib/module/components/marker/index.js.map +1 -0
- package/lib/module/components/message/index.js +24 -8
- package/lib/module/components/message/index.js.map +1 -1
- package/lib/module/components/message-scroller/index.js +451 -0
- package/lib/module/components/message-scroller/index.js.map +1 -0
- package/lib/module/components/popover/index.js +511 -0
- package/lib/module/components/popover/index.js.map +1 -0
- package/lib/module/components/progress/index.js +52 -2
- package/lib/module/components/progress/index.js.map +1 -1
- package/lib/module/components/radio-group/index.js +132 -17
- package/lib/module/components/radio-group/index.js.map +1 -1
- package/lib/module/components/section-rail/index.js +355 -0
- package/lib/module/components/section-rail/index.js.map +1 -0
- package/lib/module/components/select/index.js +245 -56
- package/lib/module/components/select/index.js.map +1 -1
- package/lib/module/components/separator/index.js +91 -0
- package/lib/module/components/separator/index.js.map +1 -0
- package/lib/module/components/slider/index.js +355 -0
- package/lib/module/components/slider/index.js.map +1 -0
- package/lib/module/components/surface/index.js +21 -2
- package/lib/module/components/surface/index.js.map +1 -1
- package/lib/module/components/switch/index.js +10 -1
- package/lib/module/components/switch/index.js.map +1 -1
- package/lib/module/components/tabs/index.js +186 -16
- package/lib/module/components/tabs/index.js.map +1 -1
- package/lib/module/components/toggle-button/index.js +297 -0
- package/lib/module/components/toggle-button/index.js.map +1 -0
- package/lib/module/hooks/index.js +1 -0
- package/lib/module/hooks/index.js.map +1 -1
- package/lib/module/hooks/use-keyboard-avoidance.js +57 -8
- package/lib/module/hooks/use-keyboard-avoidance.js.map +1 -1
- package/lib/module/hooks/use-scroll-sections.js +89 -0
- package/lib/module/hooks/use-scroll-sections.js.map +1 -0
- package/lib/module/icons/index.js +69 -0
- package/lib/module/icons/index.js.map +1 -1
- package/lib/module/index.js +11 -2
- package/lib/module/index.js.map +1 -1
- package/lib/module/native/index.js.map +1 -1
- package/lib/module/primitives/keyboard-avoider.js +2 -0
- package/lib/module/primitives/keyboard-avoider.js.map +1 -1
- package/lib/module/primitives/scrim.js +72 -0
- package/lib/module/primitives/scrim.js.map +1 -0
- package/lib/module/utils/haptics.js +57 -0
- package/lib/module/utils/haptics.js.map +1 -0
- package/lib/typescript/src/components/attachment/index.d.ts +93 -0
- package/lib/typescript/src/components/attachment/index.d.ts.map +1 -0
- package/lib/typescript/src/components/bottom-sheet/index.d.ts +6 -1
- package/lib/typescript/src/components/bottom-sheet/index.d.ts.map +1 -1
- package/lib/typescript/src/components/button/index.d.ts +9 -4
- package/lib/typescript/src/components/button/index.d.ts.map +1 -1
- package/lib/typescript/src/components/dialog/index.d.ts +7 -1
- package/lib/typescript/src/components/dialog/index.d.ts.map +1 -1
- package/lib/typescript/src/components/empty-state/index.d.ts +152 -2
- package/lib/typescript/src/components/empty-state/index.d.ts.map +1 -1
- package/lib/typescript/src/components/frame/index.d.ts +47 -7
- package/lib/typescript/src/components/frame/index.d.ts.map +1 -1
- package/lib/typescript/src/components/input/index.d.ts +113 -2
- package/lib/typescript/src/components/input/index.d.ts.map +1 -1
- package/lib/typescript/src/components/line-chart/index.d.ts +247 -0
- package/lib/typescript/src/components/line-chart/index.d.ts.map +1 -0
- package/lib/typescript/src/components/marker/index.d.ts +137 -0
- package/lib/typescript/src/components/marker/index.d.ts.map +1 -0
- package/lib/typescript/src/components/message/index.d.ts +8 -1
- package/lib/typescript/src/components/message/index.d.ts.map +1 -1
- package/lib/typescript/src/components/message-scroller/index.d.ts +150 -0
- package/lib/typescript/src/components/message-scroller/index.d.ts.map +1 -0
- package/lib/typescript/src/components/popover/index.d.ts +136 -0
- package/lib/typescript/src/components/popover/index.d.ts.map +1 -0
- package/lib/typescript/src/components/progress/index.d.ts +33 -0
- package/lib/typescript/src/components/progress/index.d.ts.map +1 -1
- package/lib/typescript/src/components/radio-group/index.d.ts +39 -0
- package/lib/typescript/src/components/radio-group/index.d.ts.map +1 -1
- package/lib/typescript/src/components/section-rail/index.d.ts +115 -0
- package/lib/typescript/src/components/section-rail/index.d.ts.map +1 -0
- package/lib/typescript/src/components/select/index.d.ts +46 -7
- package/lib/typescript/src/components/select/index.d.ts.map +1 -1
- package/lib/typescript/src/components/separator/index.d.ts +47 -0
- package/lib/typescript/src/components/separator/index.d.ts.map +1 -0
- package/lib/typescript/src/components/slider/index.d.ts +203 -0
- package/lib/typescript/src/components/slider/index.d.ts.map +1 -0
- package/lib/typescript/src/components/surface/index.d.ts +51 -2
- package/lib/typescript/src/components/surface/index.d.ts.map +1 -1
- package/lib/typescript/src/components/switch/index.d.ts.map +1 -1
- package/lib/typescript/src/components/tabs/index.d.ts +46 -4
- package/lib/typescript/src/components/tabs/index.d.ts.map +1 -1
- package/lib/typescript/src/components/toggle-button/index.d.ts +244 -0
- package/lib/typescript/src/components/toggle-button/index.d.ts.map +1 -0
- package/lib/typescript/src/hooks/index.d.ts +1 -0
- package/lib/typescript/src/hooks/index.d.ts.map +1 -1
- package/lib/typescript/src/hooks/use-keyboard-avoidance.d.ts +10 -1
- package/lib/typescript/src/hooks/use-keyboard-avoidance.d.ts.map +1 -1
- package/lib/typescript/src/hooks/use-scroll-sections.d.ts +31 -0
- package/lib/typescript/src/hooks/use-scroll-sections.d.ts.map +1 -0
- package/lib/typescript/src/icons/index.d.ts +6 -0
- package/lib/typescript/src/icons/index.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +13 -4
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/native/index.d.ts +16 -1
- package/lib/typescript/src/native/index.d.ts.map +1 -1
- package/lib/typescript/src/primitives/keyboard-avoider.d.ts +8 -1
- package/lib/typescript/src/primitives/keyboard-avoider.d.ts.map +1 -1
- package/lib/typescript/src/primitives/scrim.d.ts +21 -0
- package/lib/typescript/src/primitives/scrim.d.ts.map +1 -0
- package/lib/typescript/src/utils/haptics.d.ts +12 -0
- package/lib/typescript/src/utils/haptics.d.ts.map +1 -0
- package/package.json +9 -1
- package/src/components/attachment/index.tsx +279 -0
- package/src/components/bottom-sheet/index.tsx +58 -2
- package/src/components/button/index.tsx +26 -5
- package/src/components/dialog/index.tsx +10 -1
- package/src/components/empty-state/index.tsx +60 -14
- package/src/components/frame/index.tsx +175 -29
- package/src/components/input/index.tsx +122 -16
- package/src/components/line-chart/index.tsx +1224 -0
- package/src/components/marker/index.tsx +194 -0
- package/src/components/message/index.tsx +29 -5
- package/src/components/message-scroller/index.tsx +574 -0
- package/src/components/popover/index.tsx +624 -0
- package/src/components/progress/index.tsx +81 -1
- package/src/components/radio-group/index.tsx +156 -18
- package/src/components/section-rail/index.tsx +459 -0
- package/src/components/select/index.tsx +265 -52
- package/src/components/separator/index.tsx +97 -0
- package/src/components/slider/index.tsx +371 -0
- package/src/components/surface/index.tsx +29 -3
- package/src/components/switch/index.tsx +8 -1
- package/src/components/tabs/index.tsx +208 -28
- package/src/components/toggle-button/index.tsx +374 -0
- package/src/hooks/index.ts +5 -0
- package/src/hooks/use-keyboard-avoidance.ts +73 -7
- package/src/hooks/use-scroll-sections.ts +127 -0
- package/src/icons/index.tsx +48 -0
- package/src/index.ts +97 -6
- package/src/native/index.ts +13 -1
- package/src/primitives/keyboard-avoider.tsx +9 -1
- package/src/primitives/scrim.tsx +95 -0
- package/src/utils/haptics.ts +63 -0
- package/theme.css +64 -2
- package/lib/module/components/inline-select/index.js +0 -284
- package/lib/module/components/inline-select/index.js.map +0 -1
- package/lib/typescript/src/components/inline-select/index.d.ts +0 -48
- package/lib/typescript/src/components/inline-select/index.d.ts.map +0 -1
- package/src/components/inline-select/index.tsx +0 -332
|
@@ -0,0 +1,355 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Slider — a value picker driven by a single thumb.
|
|
5
|
+
*
|
|
6
|
+
* The thumb is a pill exactly as tall as the track rather than a disc floating
|
|
7
|
+
* over it. That is a deliberate shape choice and it is also the robust one: a
|
|
8
|
+
* knob taller than its track has to escape the track's own bounds to be drawn
|
|
9
|
+
* whole, which puts the visual design at the mercy of a clipping rule. Here the
|
|
10
|
+
* two are the same height, so there is nothing to clip and nothing to escape.
|
|
11
|
+
*
|
|
12
|
+
* Inside the pill sits a smaller knob that shrinks while dragging — the press
|
|
13
|
+
* feedback lives on the part you are looking at, not on the whole control.
|
|
14
|
+
*
|
|
15
|
+
* Position and fill width are animated on the UI thread; dragging never
|
|
16
|
+
* round-trips through React, and the picked value bridges back to JS on change
|
|
17
|
+
* and on release.
|
|
18
|
+
*
|
|
19
|
+
* ```tsx
|
|
20
|
+
* <Slider label="Volume" showValue defaultValue={30} />
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* Works controlled (`value` + `onValueChange`) or uncontrolled (`defaultValue`).
|
|
24
|
+
*/
|
|
25
|
+
import { forwardRef, useCallback, useEffect, useRef, useState } from 'react';
|
|
26
|
+
import { View } from 'react-native';
|
|
27
|
+
import { Gesture, GestureDetector } from 'react-native-gesture-handler';
|
|
28
|
+
import Animated, { runOnJS, useAnimatedStyle, useSharedValue, withSpring } from 'react-native-reanimated';
|
|
29
|
+
import { tv } from 'tailwind-variants';
|
|
30
|
+
import { getNativeUI } from "../../native/index.js";
|
|
31
|
+
import { Text } from "../../primitives/text.js";
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Springs the thumb onto its resting step after a drag or a track tap. Drags
|
|
35
|
+
* themselves are followed 1:1 with no spring, so the knob stays under the
|
|
36
|
+
* finger; the spring only settles the final snap.
|
|
37
|
+
*/
|
|
38
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
39
|
+
const SPRING = {
|
|
40
|
+
damping: 18,
|
|
41
|
+
stiffness: 220,
|
|
42
|
+
mass: 0.6
|
|
43
|
+
};
|
|
44
|
+
/** Settles the knob between its idle and dragging sizes. */
|
|
45
|
+
const KNOB_SPRING = {
|
|
46
|
+
damping: 15,
|
|
47
|
+
stiffness: 200,
|
|
48
|
+
mass: 0.5
|
|
49
|
+
};
|
|
50
|
+
/** How far the knob shrinks while the thumb is held. */
|
|
51
|
+
const KNOB_PRESSED_SCALE = 0.86;
|
|
52
|
+
/** Grab radius around the thumb — the pill is small, the target should not be. */
|
|
53
|
+
const HIT_SLOP = 16;
|
|
54
|
+
const sliderVariants = tv({
|
|
55
|
+
slots: {
|
|
56
|
+
root: 'w-full gap-2',
|
|
57
|
+
header: 'w-full flex-row items-center justify-between gap-3',
|
|
58
|
+
label: 'text-sm font-medium text-foreground',
|
|
59
|
+
value: 'text-sm text-muted-foreground',
|
|
60
|
+
// The track is the full height of the control, so the thumb has somewhere
|
|
61
|
+
// to sit rather than somewhere to stick out of.
|
|
62
|
+
track: 'w-full justify-center rounded-full bg-muted',
|
|
63
|
+
fill: 'absolute bottom-0 left-0 top-0 rounded-full',
|
|
64
|
+
thumb: 'absolute left-0 rounded-full p-0.5',
|
|
65
|
+
// `background`, not a per-colour on-token: the status foregrounds are the
|
|
66
|
+
// darker text hues meant for soft fills, so a green-700 knob on a green-500
|
|
67
|
+
// pill would barely show. The page background reads against every fill in
|
|
68
|
+
// both themes.
|
|
69
|
+
knob: 'flex-1 rounded-full bg-background shadow-sm'
|
|
70
|
+
},
|
|
71
|
+
variants: {
|
|
72
|
+
color: {
|
|
73
|
+
primary: {
|
|
74
|
+
fill: 'bg-primary',
|
|
75
|
+
thumb: 'bg-primary'
|
|
76
|
+
},
|
|
77
|
+
success: {
|
|
78
|
+
fill: 'bg-success',
|
|
79
|
+
thumb: 'bg-success'
|
|
80
|
+
},
|
|
81
|
+
warning: {
|
|
82
|
+
fill: 'bg-warning',
|
|
83
|
+
thumb: 'bg-warning'
|
|
84
|
+
},
|
|
85
|
+
destructive: {
|
|
86
|
+
fill: 'bg-destructive',
|
|
87
|
+
thumb: 'bg-destructive'
|
|
88
|
+
},
|
|
89
|
+
info: {
|
|
90
|
+
fill: 'bg-info',
|
|
91
|
+
thumb: 'bg-info'
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
size: {
|
|
95
|
+
sm: {
|
|
96
|
+
track: 'h-4',
|
|
97
|
+
thumb: 'h-4'
|
|
98
|
+
},
|
|
99
|
+
md: {
|
|
100
|
+
track: 'h-5',
|
|
101
|
+
thumb: 'h-5'
|
|
102
|
+
},
|
|
103
|
+
lg: {
|
|
104
|
+
track: 'h-6',
|
|
105
|
+
thumb: 'h-6'
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
disabled: {
|
|
109
|
+
true: {
|
|
110
|
+
root: 'opacity-50'
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
defaultVariants: {
|
|
115
|
+
color: 'primary',
|
|
116
|
+
size: 'md'
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
/** Thumb width per size. Wider than it is tall, so the pill reads as a grip. */
|
|
121
|
+
const THUMB_WIDTH = {
|
|
122
|
+
sm: 24,
|
|
123
|
+
md: 28,
|
|
124
|
+
lg: 32
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
/** Row height reserved for the platform's own slider. */
|
|
128
|
+
const NATIVE_HEIGHT = 32;
|
|
129
|
+
function clampJS(value, min, max) {
|
|
130
|
+
return Math.min(Math.max(value, min), max);
|
|
131
|
+
}
|
|
132
|
+
function snap(value, min, max, step) {
|
|
133
|
+
if (step <= 0) return clampJS(value, min, max);
|
|
134
|
+
const stepped = Math.round((value - min) / step) * step + min;
|
|
135
|
+
return clampJS(stepped, min, max);
|
|
136
|
+
}
|
|
137
|
+
export const Slider = /*#__PURE__*/forwardRef(({
|
|
138
|
+
className,
|
|
139
|
+
headerClassName,
|
|
140
|
+
trackClassName,
|
|
141
|
+
fillClassName,
|
|
142
|
+
thumbClassName,
|
|
143
|
+
knobClassName,
|
|
144
|
+
value: valueProp,
|
|
145
|
+
defaultValue = 0,
|
|
146
|
+
min = 0,
|
|
147
|
+
max = 100,
|
|
148
|
+
step = 1,
|
|
149
|
+
onValueChange,
|
|
150
|
+
onValueCommit,
|
|
151
|
+
disabled = false,
|
|
152
|
+
native,
|
|
153
|
+
label,
|
|
154
|
+
showValue = false,
|
|
155
|
+
formatValue,
|
|
156
|
+
color = 'primary',
|
|
157
|
+
size = 'md'
|
|
158
|
+
}, ref) => {
|
|
159
|
+
const isControlled = valueProp !== undefined;
|
|
160
|
+
const [internal, setInternal] = useState(defaultValue);
|
|
161
|
+
const value = clampJS(isControlled ? valueProp : internal, min, max);
|
|
162
|
+
const slots = sliderVariants({
|
|
163
|
+
color,
|
|
164
|
+
size,
|
|
165
|
+
disabled
|
|
166
|
+
});
|
|
167
|
+
const thumbWidth = THUMB_WIDTH[size ?? 'md'];
|
|
168
|
+
const nativeUI = native ? getNativeUI() : null;
|
|
169
|
+
|
|
170
|
+
// Measured on layout; the thumb travels across (trackWidth - thumbWidth) so
|
|
171
|
+
// it stays inside the track at both ends.
|
|
172
|
+
const trackWidth = useSharedValue(0);
|
|
173
|
+
// Fraction 0..1 that drives the fill and the thumb, animated on the UI thread.
|
|
174
|
+
const progress = useSharedValue(max > min ? (value - min) / (max - min) : 0);
|
|
175
|
+
const startProgress = useSharedValue(0);
|
|
176
|
+
const pressed = useSharedValue(0);
|
|
177
|
+
|
|
178
|
+
// The change handler runs on JS; keep the latest props reachable from the
|
|
179
|
+
// worklet callback without re-creating the gesture on every render.
|
|
180
|
+
const changeRef = useRef(onValueChange);
|
|
181
|
+
changeRef.current = onValueChange;
|
|
182
|
+
const commitRef = useRef(onValueCommit);
|
|
183
|
+
commitRef.current = onValueCommit;
|
|
184
|
+
const emitChange = useCallback(next => {
|
|
185
|
+
if (!isControlled) setInternal(next);
|
|
186
|
+
changeRef.current?.(next);
|
|
187
|
+
}, [isControlled]);
|
|
188
|
+
const emitCommit = useCallback(next => {
|
|
189
|
+
commitRef.current?.(next);
|
|
190
|
+
}, []);
|
|
191
|
+
|
|
192
|
+
// Keep the animation in step with a controlled value that changes elsewhere.
|
|
193
|
+
useEffect(() => {
|
|
194
|
+
const next = max > min ? (value - min) / (max - min) : 0;
|
|
195
|
+
progress.value = withSpring(next, SPRING);
|
|
196
|
+
}, [value, min, max, progress]);
|
|
197
|
+
const onLayout = event => {
|
|
198
|
+
trackWidth.value = event.nativeEvent.layout.width;
|
|
199
|
+
};
|
|
200
|
+
const commitFromProgress = useCallback((p, commit) => {
|
|
201
|
+
const raw = min + p * (max - min);
|
|
202
|
+
const snapped = snap(raw, min, max, step);
|
|
203
|
+
emitChange(snapped);
|
|
204
|
+
if (commit) emitCommit(snapped);
|
|
205
|
+
}, [min, max, step, emitChange, emitCommit]);
|
|
206
|
+
const pan = Gesture.Pan().enabled(!disabled).hitSlop(HIT_SLOP).onBegin(() => {
|
|
207
|
+
startProgress.value = progress.value;
|
|
208
|
+
pressed.value = withSpring(1, KNOB_SPRING);
|
|
209
|
+
}).onUpdate(event => {
|
|
210
|
+
const travel = Math.max(trackWidth.value - thumbWidth, 1);
|
|
211
|
+
const delta = event.translationX / travel;
|
|
212
|
+
const next = Math.min(Math.max(startProgress.value + delta, 0), 1);
|
|
213
|
+
progress.value = next;
|
|
214
|
+
runOnJS(commitFromProgress)(next, false);
|
|
215
|
+
}).onFinalize(() => {
|
|
216
|
+
pressed.value = withSpring(0, KNOB_SPRING);
|
|
217
|
+
runOnJS(commitFromProgress)(progress.value, true);
|
|
218
|
+
});
|
|
219
|
+
const tap = Gesture.Tap().enabled(!disabled).maxDuration(250).onEnd(event => {
|
|
220
|
+
const travel = Math.max(trackWidth.value - thumbWidth, 1);
|
|
221
|
+
const next = Math.min(Math.max((event.x - thumbWidth / 2) / travel, 0), 1);
|
|
222
|
+
progress.value = withSpring(next, SPRING);
|
|
223
|
+
runOnJS(commitFromProgress)(next, true);
|
|
224
|
+
});
|
|
225
|
+
const gesture = Gesture.Race(pan, tap);
|
|
226
|
+
|
|
227
|
+
// The fill runs under the thumb rather than up to it, so the two never show
|
|
228
|
+
// a seam between them as the thumb moves.
|
|
229
|
+
const fillStyle = useAnimatedStyle(() => {
|
|
230
|
+
const travel = Math.max(trackWidth.value - thumbWidth, 0);
|
|
231
|
+
return {
|
|
232
|
+
width: progress.value * travel + thumbWidth
|
|
233
|
+
};
|
|
234
|
+
});
|
|
235
|
+
const thumbStyle = useAnimatedStyle(() => {
|
|
236
|
+
const travel = Math.max(trackWidth.value - thumbWidth, 0);
|
|
237
|
+
return {
|
|
238
|
+
transform: [{
|
|
239
|
+
translateX: progress.value * travel
|
|
240
|
+
}]
|
|
241
|
+
};
|
|
242
|
+
});
|
|
243
|
+
const knobStyle = useAnimatedStyle(() => ({
|
|
244
|
+
transform: [{
|
|
245
|
+
scale: 1 - pressed.value * (1 - KNOB_PRESSED_SCALE)
|
|
246
|
+
}]
|
|
247
|
+
}));
|
|
248
|
+
|
|
249
|
+
// VoiceOver / TalkBack increment and decrement move by a single step.
|
|
250
|
+
const nudge = dir => {
|
|
251
|
+
const next = snap(value + dir * (step || 1), min, max, step);
|
|
252
|
+
if (next === value) return;
|
|
253
|
+
progress.value = withSpring(max > min ? (next - min) / (max - min) : 0, SPRING);
|
|
254
|
+
emitChange(next);
|
|
255
|
+
emitCommit(next);
|
|
256
|
+
};
|
|
257
|
+
const onAccessibilityAction = event => {
|
|
258
|
+
if (event.nativeEvent.actionName === 'increment') nudge(1);else if (event.nativeEvent.actionName === 'decrement') nudge(-1);
|
|
259
|
+
};
|
|
260
|
+
const shownValue = formatValue ? formatValue(value) : String(Math.round(value));
|
|
261
|
+
const header = label || showValue ? /*#__PURE__*/_jsxs(View, {
|
|
262
|
+
className: slots.header({
|
|
263
|
+
className: headerClassName
|
|
264
|
+
}),
|
|
265
|
+
children: [label ? /*#__PURE__*/_jsx(Text, {
|
|
266
|
+
className: slots.label(),
|
|
267
|
+
children: label
|
|
268
|
+
}) : /*#__PURE__*/_jsx(View, {}), showValue ? /*#__PURE__*/_jsx(Text, {
|
|
269
|
+
className: slots.value(),
|
|
270
|
+
children: shownValue
|
|
271
|
+
}) : null]
|
|
272
|
+
}) : null;
|
|
273
|
+
if (nativeUI) {
|
|
274
|
+
const {
|
|
275
|
+
Host,
|
|
276
|
+
Slider: NativeSlider
|
|
277
|
+
} = nativeUI;
|
|
278
|
+
return /*#__PURE__*/_jsxs(View, {
|
|
279
|
+
ref: ref,
|
|
280
|
+
className: slots.root({
|
|
281
|
+
className
|
|
282
|
+
}),
|
|
283
|
+
children: [header, /*#__PURE__*/_jsx(Host, {
|
|
284
|
+
style: {
|
|
285
|
+
height: NATIVE_HEIGHT
|
|
286
|
+
},
|
|
287
|
+
children: /*#__PURE__*/_jsx(NativeSlider, {
|
|
288
|
+
value: value,
|
|
289
|
+
onValueChange: next => {
|
|
290
|
+
emitChange(snap(next, min, max, step));
|
|
291
|
+
},
|
|
292
|
+
min: min,
|
|
293
|
+
max: max,
|
|
294
|
+
step: step,
|
|
295
|
+
disabled: disabled
|
|
296
|
+
})
|
|
297
|
+
})]
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
return /*#__PURE__*/_jsxs(View, {
|
|
301
|
+
ref: ref,
|
|
302
|
+
className: slots.root({
|
|
303
|
+
className
|
|
304
|
+
}),
|
|
305
|
+
collapsable: false,
|
|
306
|
+
children: [header, /*#__PURE__*/_jsx(GestureDetector, {
|
|
307
|
+
gesture: gesture,
|
|
308
|
+
children: /*#__PURE__*/_jsxs(View, {
|
|
309
|
+
className: slots.track({
|
|
310
|
+
className: trackClassName
|
|
311
|
+
}),
|
|
312
|
+
onLayout: onLayout,
|
|
313
|
+
children: [/*#__PURE__*/_jsx(Animated.View, {
|
|
314
|
+
style: fillStyle,
|
|
315
|
+
className: slots.fill({
|
|
316
|
+
className: fillClassName
|
|
317
|
+
})
|
|
318
|
+
}), /*#__PURE__*/_jsx(Animated.View, {
|
|
319
|
+
style: [thumbStyle, {
|
|
320
|
+
width: thumbWidth
|
|
321
|
+
}],
|
|
322
|
+
className: slots.thumb({
|
|
323
|
+
className: thumbClassName
|
|
324
|
+
}),
|
|
325
|
+
accessible: true,
|
|
326
|
+
accessibilityRole: "adjustable",
|
|
327
|
+
accessibilityLabel: label,
|
|
328
|
+
accessibilityState: {
|
|
329
|
+
disabled
|
|
330
|
+
},
|
|
331
|
+
accessibilityValue: {
|
|
332
|
+
min,
|
|
333
|
+
max,
|
|
334
|
+
now: Math.round(value),
|
|
335
|
+
text: shownValue
|
|
336
|
+
},
|
|
337
|
+
accessibilityActions: [{
|
|
338
|
+
name: 'increment'
|
|
339
|
+
}, {
|
|
340
|
+
name: 'decrement'
|
|
341
|
+
}],
|
|
342
|
+
onAccessibilityAction: onAccessibilityAction,
|
|
343
|
+
children: /*#__PURE__*/_jsx(Animated.View, {
|
|
344
|
+
style: knobStyle,
|
|
345
|
+
className: slots.knob({
|
|
346
|
+
className: knobClassName
|
|
347
|
+
})
|
|
348
|
+
})
|
|
349
|
+
})]
|
|
350
|
+
})
|
|
351
|
+
})]
|
|
352
|
+
});
|
|
353
|
+
});
|
|
354
|
+
Slider.displayName = 'Slider';
|
|
355
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["forwardRef","useCallback","useEffect","useRef","useState","View","Gesture","GestureDetector","Animated","runOnJS","useAnimatedStyle","useSharedValue","withSpring","tv","getNativeUI","Text","jsx","_jsx","jsxs","_jsxs","SPRING","damping","stiffness","mass","KNOB_SPRING","KNOB_PRESSED_SCALE","HIT_SLOP","sliderVariants","slots","root","header","label","value","track","fill","thumb","knob","variants","color","primary","success","warning","destructive","info","size","sm","md","lg","disabled","true","defaultVariants","THUMB_WIDTH","NATIVE_HEIGHT","clampJS","min","max","Math","snap","step","stepped","round","Slider","className","headerClassName","trackClassName","fillClassName","thumbClassName","knobClassName","valueProp","defaultValue","onValueChange","onValueCommit","native","showValue","formatValue","ref","isControlled","undefined","internal","setInternal","thumbWidth","nativeUI","trackWidth","progress","startProgress","pressed","changeRef","current","commitRef","emitChange","next","emitCommit","onLayout","event","nativeEvent","layout","width","commitFromProgress","p","commit","raw","snapped","pan","Pan","enabled","hitSlop","onBegin","onUpdate","travel","delta","translationX","onFinalize","tap","Tap","maxDuration","onEnd","x","gesture","Race","fillStyle","thumbStyle","transform","translateX","knobStyle","scale","nudge","dir","onAccessibilityAction","actionName","shownValue","String","children","Host","NativeSlider","style","height","collapsable","accessible","accessibilityRole","accessibilityLabel","accessibilityState","accessibilityValue","now","text","accessibilityActions","name","displayName"],"sourceRoot":"../../../../src","sources":["components/slider/index.tsx"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,UAAU,EAAEC,WAAW,EAAEC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AAC5E,SACEC,IAAI,QAGC,cAAc;AACrB,SAASC,OAAO,EAAEC,eAAe,QAAQ,8BAA8B;AACvE,OAAOC,QAAQ,IACbC,OAAO,EACPC,gBAAgB,EAChBC,cAAc,EACdC,UAAU,QACL,yBAAyB;AAChC,SAASC,EAAE,QAA2B,mBAAmB;AACzD,SAASC,WAAW,QAAQ,uBAAc;AAC1C,SAASC,IAAI,QAAQ,0BAAuB;;AAE5C;AACA;AACA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AAU;UACjBzD,SAAS,EAAElC,KAAK,CAACM,IAAI,CAAC;YAAE4B,SAAS,EAAEG;UAAc,CAAC;QAAE,CACrD,CAAC,eACFhD,IAAA,CAACT,QAAQ,CAACH,IAAI;UACZiI,KAAK,EAAE,CAACd,UAAU,EAAE;YAAExB,KAAK,EAAEhB;UAAW,CAAC,CAAE;UAC3ClB,SAAS,EAAElC,KAAK,CAACO,KAAK,CAAC;YAAE2B,SAAS,EAAEI;UAAe,CAAC,CAAE;UACtDuE,UAAU;UACVC,iBAAiB,EAAC,YAAY;UAC9BC,kBAAkB,EAAE5G,KAAM;UAC1B6G,kBAAkB,EAAE;YAAE5F;UAAS,CAAE;UACjC6F,kBAAkB,EAAE;YAClBvF,GAAG;YACHC,GAAG;YACHuF,GAAG,EAAEtF,IAAI,CAACI,KAAK,CAAC5B,KAAK,CAAC;YACtB+G,IAAI,EAAEd;UACR,CAAE;UACFe,oBAAoB,EAAE,CAAC;YAAEC,IAAI,EAAE;UAAY,CAAC,EAAE;YAAEA,IAAI,EAAE;UAAY,CAAC,CAAE;UACrElB,qBAAqB,EAAEA,qBAAsB;UAAAI,QAAA,eAE7ClH,IAAA,CAACT,QAAQ,CAACH,IAAI;YACZiI,KAAK,EAAEX,SAAU;YACjB7D,SAAS,EAAElC,KAAK,CAACQ,IAAI,CAAC;cAAE0B,SAAS,EAAEK;YAAc,CAAC;UAAE,CACrD;QAAC,CACW,CAAC;MAAA,CACZ;IAAC,CACQ,CAAC;EAAA,CACd,CAAC;AAEX,CACF,CAAC;AAEDN,MAAM,CAACqF,WAAW,GAAG,QAAQ","ignoreList":[]}
|
|
@@ -25,22 +25,38 @@ import { StyleSheet, View } from 'react-native';
|
|
|
25
25
|
import { tv } from 'tailwind-variants';
|
|
26
26
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
27
27
|
const surfaceVariants = tv({
|
|
28
|
-
base: 'overflow-hidden rounded-3xl
|
|
28
|
+
base: 'overflow-hidden rounded-3xl',
|
|
29
29
|
variants: {
|
|
30
30
|
variant: {
|
|
31
31
|
default: 'bg-surface',
|
|
32
32
|
secondary: 'bg-surface-secondary',
|
|
33
33
|
tertiary: 'bg-surface-tertiary',
|
|
34
34
|
transparent: 'bg-transparent'
|
|
35
|
+
},
|
|
36
|
+
padding: {
|
|
37
|
+
none: '',
|
|
38
|
+
sm: 'p-2.5',
|
|
39
|
+
default: 'p-4',
|
|
40
|
+
lg: 'p-6'
|
|
41
|
+
},
|
|
42
|
+
bordered: {
|
|
43
|
+
true: 'border border-border'
|
|
44
|
+
},
|
|
45
|
+
elevated: {
|
|
46
|
+
true: 'shadow-sm'
|
|
35
47
|
}
|
|
36
48
|
},
|
|
37
49
|
defaultVariants: {
|
|
38
|
-
variant: 'default'
|
|
50
|
+
variant: 'default',
|
|
51
|
+
padding: 'default'
|
|
39
52
|
}
|
|
40
53
|
});
|
|
41
54
|
export const Surface = /*#__PURE__*/forwardRef(({
|
|
42
55
|
className,
|
|
43
56
|
variant,
|
|
57
|
+
padding,
|
|
58
|
+
bordered,
|
|
59
|
+
elevated,
|
|
44
60
|
style,
|
|
45
61
|
...props
|
|
46
62
|
}, ref) => /*#__PURE__*/_jsx(View, {
|
|
@@ -52,6 +68,9 @@ export const Surface = /*#__PURE__*/forwardRef(({
|
|
|
52
68
|
style: [styles.root, style],
|
|
53
69
|
className: surfaceVariants({
|
|
54
70
|
variant,
|
|
71
|
+
padding,
|
|
72
|
+
bordered,
|
|
73
|
+
elevated,
|
|
55
74
|
className
|
|
56
75
|
}),
|
|
57
76
|
...props
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["forwardRef","StyleSheet","View","tv","jsx","_jsx","surfaceVariants","base","variants","variant","default","secondary","tertiary","transparent","defaultVariants","Surface","className","style","props","ref","styles","root","displayName","create","borderCurve"],"sourceRoot":"../../../../src","sources":["components/surface/index.tsx"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,UAAU,QAAQ,OAAO;AAClC,SAASC,UAAU,EAAEC,IAAI,QAAwB,cAAc;AAC/D,SAASC,EAAE,QAA2B,mBAAmB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAE1D,MAAMC,eAAe,GAAGH,EAAE,CAAC;EACzBI,IAAI,EAAE,
|
|
1
|
+
{"version":3,"names":["forwardRef","StyleSheet","View","tv","jsx","_jsx","surfaceVariants","base","variants","variant","default","secondary","tertiary","transparent","padding","none","sm","lg","bordered","true","elevated","defaultVariants","Surface","className","style","props","ref","styles","root","displayName","create","borderCurve"],"sourceRoot":"../../../../src","sources":["components/surface/index.tsx"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,UAAU,QAAQ,OAAO;AAClC,SAASC,UAAU,EAAEC,IAAI,QAAwB,cAAc;AAC/D,SAASC,EAAE,QAA2B,mBAAmB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAE1D,MAAMC,eAAe,GAAGH,EAAE,CAAC;EACzBI,IAAI,EAAE,6BAA6B;EACnCC,QAAQ,EAAE;IACRC,OAAO,EAAE;MACPC,OAAO,EAAE,YAAY;MACrBC,SAAS,EAAE,sBAAsB;MACjCC,QAAQ,EAAE,qBAAqB;MAC/BC,WAAW,EAAE;IACf,CAAC;IACDC,OAAO,EAAE;MACPC,IAAI,EAAE,EAAE;MACRC,EAAE,EAAE,OAAO;MACXN,OAAO,EAAE,KAAK;MACdO,EAAE,EAAE;IACN,CAAC;IACDC,QAAQ,EAAE;MACRC,IAAI,EAAE;IACR,CAAC;IACDC,QAAQ,EAAE;MACRD,IAAI,EAAE;IACR;EACF,CAAC;EACDE,eAAe,EAAE;IACfZ,OAAO,EAAE,SAAS;IAClBK,OAAO,EAAE;EACX;AACF,CAAC,CAAC;AAqBF,OAAO,MAAMQ,OAAO,gBAAGtB,UAAU,CAC/B,CAAC;EAAEuB,SAAS;EAAEd,OAAO;EAAEK,OAAO;EAAEI,QAAQ;EAAEE,QAAQ;EAAEI,KAAK;EAAE,GAAGC;AAAM,CAAC,EAAEC,GAAG,kBACxErB,IAAA,CAACH,IAAI;EACHwB,GAAG,EAAEA;EACL;EACA;EACA;EAAA;EACAF,KAAK,EAAE,CAACG,MAAM,CAACC,IAAI,EAAEJ,KAAK,CAAE;EAC5BD,SAAS,EAAEjB,eAAe,CAAC;IAAEG,OAAO;IAAEK,OAAO;IAAEI,QAAQ;IAAEE,QAAQ;IAAEG;EAAU,CAAC,CAAE;EAAA,GAC5EE;AAAK,CACV,CAEL,CAAC;AAEDH,OAAO,CAACO,WAAW,GAAG,SAAS;AAE/B,MAAMF,MAAM,GAAG1B,UAAU,CAAC6B,MAAM,CAAC;EAC/BF,IAAI,EAAE;IAAEG,WAAW,EAAE;EAAa;AACpC,CAAC,CAAC","ignoreList":[]}
|
|
@@ -42,6 +42,13 @@ const TRAVEL = {
|
|
|
42
42
|
sm: 16,
|
|
43
43
|
md: 20
|
|
44
44
|
};
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Row height given to the native host. It is told its size rather than asked
|
|
48
|
+
* to measure the platform's own content, which arrives a frame late and leaves
|
|
49
|
+
* the control collapsed until something forces a second pass.
|
|
50
|
+
*/
|
|
51
|
+
const NATIVE_HEIGHT = 32;
|
|
45
52
|
/**
|
|
46
53
|
* Animated switch. Thumb position and active-track opacity are driven on the
|
|
47
54
|
* UI thread; toggling never re-renders beyond the value change itself.
|
|
@@ -78,7 +85,9 @@ export const Switch = /*#__PURE__*/forwardRef(({
|
|
|
78
85
|
Switch: NativeSwitch
|
|
79
86
|
} = nativeUI;
|
|
80
87
|
return /*#__PURE__*/_jsx(Host, {
|
|
81
|
-
|
|
88
|
+
style: {
|
|
89
|
+
height: NATIVE_HEIGHT
|
|
90
|
+
},
|
|
82
91
|
children: /*#__PURE__*/_jsx(NativeSwitch, {
|
|
83
92
|
value: value,
|
|
84
93
|
onValueChange: next => onValueChange?.(next),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["forwardRef","useEffect","Pressable","View","Animated","interpolate","useAnimatedStyle","useSharedValue","withSpring","tv","getNativeUI","jsx","_jsx","jsxs","_jsxs","SPRING","damping","stiffness","mass","switchVariants","slots","track","activeTrack","thumb","variants","size","sm","md","disabled","true","defaultVariants","TRAVEL","Switch","className","value","onValueChange","native","label","ref","progress","nativeUI","thumbStyle","transform","translateX","activeTrackStyle","opacity","Host","NativeSwitch","
|
|
1
|
+
{"version":3,"names":["forwardRef","useEffect","Pressable","View","Animated","interpolate","useAnimatedStyle","useSharedValue","withSpring","tv","getNativeUI","jsx","_jsx","jsxs","_jsxs","SPRING","damping","stiffness","mass","switchVariants","slots","track","activeTrack","thumb","variants","size","sm","md","disabled","true","defaultVariants","TRAVEL","NATIVE_HEIGHT","Switch","className","value","onValueChange","native","label","ref","progress","nativeUI","thumbStyle","transform","translateX","activeTrackStyle","opacity","Host","NativeSwitch","style","height","children","next","accessibilityRole","accessibilityState","checked","onPress","hitSlop","displayName"],"sourceRoot":"../../../../src","sources":["components/switch/index.tsx"],"mappings":";;AAAA,SAASA,UAAU,EAAEC,SAAS,QAAQ,OAAO;AAC7C,SAASC,SAAS,EAAEC,IAAI,QAAQ,cAAc;AAC9C,OAAOC,QAAQ,IACbC,WAAW,EACXC,gBAAgB,EAChBC,cAAc,EACdC,UAAU,QACL,yBAAyB;AAChC,SAASC,EAAE,QAA2B,mBAAmB;AACzD,SAASC,WAAW,QAAQ,uBAAc;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAE3C,MAAMC,MAAM,GAAG;EAAEC,OAAO,EAAE,EAAE;EAAEC,SAAS,EAAE,GAAG;EAAEC,IAAI,EAAE;AAAI,CAAU;AAElE,MAAMC,cAAc,GAAGV,EAAE,CAAC;EACxBW,KAAK,EAAE;IACLC,KA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