panelui-native 0.81.0 → 0.82.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/lib/module/components/bottom-sheet/index.js +90 -17
- package/lib/module/components/bottom-sheet/index.js.map +1 -1
- package/lib/module/components/button/index.js +13 -0
- package/lib/module/components/button/index.js.map +1 -1
- package/lib/module/components/button-group/index.js +3 -0
- package/lib/module/components/button-group/index.js.map +1 -1
- package/lib/module/components/image-generation/dot-field.js +210 -0
- package/lib/module/components/image-generation/dot-field.js.map +1 -0
- package/lib/module/components/image-generation/index.js +417 -0
- package/lib/module/components/image-generation/index.js.map +1 -0
- package/lib/module/components/kpi/index.js +2 -4
- package/lib/module/components/kpi/index.js.map +1 -1
- package/lib/module/components/menu/index.js +8 -16
- package/lib/module/components/menu/index.js.map +1 -1
- package/lib/module/components/panelside/index.js +340 -33
- package/lib/module/components/panelside/index.js.map +1 -1
- package/lib/module/components/select/index.js +127 -23
- package/lib/module/components/select/index.js.map +1 -1
- package/lib/module/components/slide-button/index.js +610 -0
- package/lib/module/components/slide-button/index.js.map +1 -0
- package/lib/module/components/slide-button/slide-button-track.js +98 -0
- package/lib/module/components/slide-button/slide-button-track.js.map +1 -0
- package/lib/module/icons/index.js +553 -1934
- package/lib/module/icons/index.js.map +1 -1
- package/lib/module/index.js +3 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/primitives/portal.js +15 -1
- package/lib/module/primitives/portal.js.map +1 -1
- package/lib/typescript/src/components/bottom-sheet/index.d.ts.map +1 -1
- package/lib/typescript/src/components/button/index.d.ts +12 -0
- package/lib/typescript/src/components/button/index.d.ts.map +1 -1
- package/lib/typescript/src/components/button-group/index.d.ts +9 -0
- package/lib/typescript/src/components/button-group/index.d.ts.map +1 -1
- package/lib/typescript/src/components/image-generation/dot-field.d.ts +61 -0
- package/lib/typescript/src/components/image-generation/dot-field.d.ts.map +1 -0
- package/lib/typescript/src/components/image-generation/index.d.ts +126 -0
- package/lib/typescript/src/components/image-generation/index.d.ts.map +1 -0
- package/lib/typescript/src/components/kpi/index.d.ts.map +1 -1
- package/lib/typescript/src/components/menu/index.d.ts.map +1 -1
- package/lib/typescript/src/components/panelside/index.d.ts +194 -10
- package/lib/typescript/src/components/panelside/index.d.ts.map +1 -1
- package/lib/typescript/src/components/select/index.d.ts +75 -2
- package/lib/typescript/src/components/select/index.d.ts.map +1 -1
- package/lib/typescript/src/components/slide-button/index.d.ts +317 -0
- package/lib/typescript/src/components/slide-button/index.d.ts.map +1 -0
- package/lib/typescript/src/components/slide-button/slide-button-track.d.ts +70 -0
- package/lib/typescript/src/components/slide-button/slide-button-track.d.ts.map +1 -0
- package/lib/typescript/src/icons/index.d.ts +136 -189
- package/lib/typescript/src/icons/index.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +4 -2
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/primitives/portal.d.ts.map +1 -1
- package/package.json +3 -2
- package/src/components/bottom-sheet/index.tsx +97 -17
- package/src/components/button/index.tsx +10 -2
- package/src/components/button-group/index.tsx +1 -0
- package/src/components/image-generation/dot-field.ts +226 -0
- package/src/components/image-generation/index.tsx +488 -0
- package/src/components/kpi/index.tsx +2 -4
- package/src/components/menu/index.tsx +10 -15
- package/src/components/panelside/index.tsx +498 -33
- package/src/components/select/index.tsx +158 -31
- package/src/components/slide-button/index.tsx +681 -0
- package/src/components/slide-button/slide-button-track.ts +100 -0
- package/src/icons/index.tsx +338 -1327
- package/src/index.ts +28 -0
- package/src/primitives/portal.tsx +15 -1
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SlideButton — drag across to confirm, with the distance drawn on the button.
|
|
3
|
+
*
|
|
4
|
+
* ```tsx
|
|
5
|
+
* <SlideButton onComplete={ship}>
|
|
6
|
+
* <SlideButton.Label>Slide to ship</SlideButton.Label>
|
|
7
|
+
* </SlideButton>
|
|
8
|
+
* ```
|
|
9
|
+
*
|
|
10
|
+
* For an action worth a moment's deliberation, where a hold is the wrong
|
|
11
|
+
* shape. A hold asks for time and shows a clock; a slide asks for a movement
|
|
12
|
+
* and shows a distance — so the reader can go as fast as they like, and still
|
|
13
|
+
* cannot arrive by tapping. Pair it with [ProgressButton](../progress-button)
|
|
14
|
+
* rather than choosing between them: the hold suits an action that should feel
|
|
15
|
+
* expensive, the slide one that should feel deliberate.
|
|
16
|
+
*
|
|
17
|
+
* ## The far end is the promise
|
|
18
|
+
*
|
|
19
|
+
* Nothing fires until the thumb clears `threshold`, which defaults to nine
|
|
20
|
+
* tenths of the rail. Released short, it springs home and the fill goes with
|
|
21
|
+
* it. Released short but travelling, it is honoured — a flick that had
|
|
22
|
+
* plainly committed is not worth refusing on a technicality, and the velocity
|
|
23
|
+
* is projected forward to decide.
|
|
24
|
+
*
|
|
25
|
+
* ## How it is drawn
|
|
26
|
+
*
|
|
27
|
+
* A track, a fill that follows the thumb, and a label that fades as the thumb
|
|
28
|
+
* reaches it. The label fades rather than sliding out of the way because the
|
|
29
|
+
* thumb is about to be where the label is, and two things moving toward each
|
|
30
|
+
* other at different speeds reads as a collision.
|
|
31
|
+
*
|
|
32
|
+
* The thumb is translated and the fill's width animated, both on the UI thread
|
|
33
|
+
* off one shared value, so a drag never re-renders React.
|
|
34
|
+
*
|
|
35
|
+
* ## Sliding without a finger
|
|
36
|
+
*
|
|
37
|
+
* A drag is not available to a screen reader, so the rail is also a button:
|
|
38
|
+
* it takes an `activate` accessibility action and completes on it. This is not
|
|
39
|
+
* a lesser path bolted on — a confirmation control that can only be reached by
|
|
40
|
+
* dragging is a confirmation control some people cannot use.
|
|
41
|
+
*/
|
|
42
|
+
import { type ReactNode } from 'react';
|
|
43
|
+
import { View, type ViewProps } from 'react-native';
|
|
44
|
+
import { type SharedValue } from 'react-native-reanimated';
|
|
45
|
+
import { type VariantProps } from 'tailwind-variants';
|
|
46
|
+
declare const slideButtonVariants: import("tailwind-variants").TVReturnType<{
|
|
47
|
+
variant: {
|
|
48
|
+
secondary: {
|
|
49
|
+
label: string;
|
|
50
|
+
fill: string;
|
|
51
|
+
};
|
|
52
|
+
destructive: {
|
|
53
|
+
label: string;
|
|
54
|
+
fill: string;
|
|
55
|
+
};
|
|
56
|
+
success: {
|
|
57
|
+
label: string;
|
|
58
|
+
fill: string;
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
size: {
|
|
62
|
+
sm: {
|
|
63
|
+
root: string;
|
|
64
|
+
label: string;
|
|
65
|
+
};
|
|
66
|
+
md: {
|
|
67
|
+
root: string;
|
|
68
|
+
label: string;
|
|
69
|
+
};
|
|
70
|
+
lg: {
|
|
71
|
+
root: string;
|
|
72
|
+
label: string;
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
fullWidth: {
|
|
76
|
+
true: {
|
|
77
|
+
root: string;
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
disabled: {
|
|
81
|
+
true: {
|
|
82
|
+
root: string;
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
}, {
|
|
86
|
+
root: string;
|
|
87
|
+
/**
|
|
88
|
+
* The ground the handle has covered.
|
|
89
|
+
*
|
|
90
|
+
* Inset on every side by the same padding the handle sits in, so at rest
|
|
91
|
+
* it is exactly zero wide and there is nothing to see — a trail with a
|
|
92
|
+
* sliver of colour in it before anything has been dragged is a control
|
|
93
|
+
* that looks part-finished.
|
|
94
|
+
*/
|
|
95
|
+
fill: string;
|
|
96
|
+
/** The label, centred in the rail rather than in the space beside it. */
|
|
97
|
+
label: string;
|
|
98
|
+
/**
|
|
99
|
+
* The draggable handle. Wider than it is tall, so it reads as something to
|
|
100
|
+
* push rather than as a dot that happens to be on a track — and the extra
|
|
101
|
+
* width is what gives the chevron room to sit in without crowding the
|
|
102
|
+
* curve at either end.
|
|
103
|
+
*/
|
|
104
|
+
thumb: string;
|
|
105
|
+
/** What the thumb holds — a chevron at rest, a tick once it has arrived. */
|
|
106
|
+
thumbContent: string;
|
|
107
|
+
}, undefined, {
|
|
108
|
+
variant: {
|
|
109
|
+
secondary: {
|
|
110
|
+
label: string;
|
|
111
|
+
fill: string;
|
|
112
|
+
};
|
|
113
|
+
destructive: {
|
|
114
|
+
label: string;
|
|
115
|
+
fill: string;
|
|
116
|
+
};
|
|
117
|
+
success: {
|
|
118
|
+
label: string;
|
|
119
|
+
fill: string;
|
|
120
|
+
};
|
|
121
|
+
};
|
|
122
|
+
size: {
|
|
123
|
+
sm: {
|
|
124
|
+
root: string;
|
|
125
|
+
label: string;
|
|
126
|
+
};
|
|
127
|
+
md: {
|
|
128
|
+
root: string;
|
|
129
|
+
label: string;
|
|
130
|
+
};
|
|
131
|
+
lg: {
|
|
132
|
+
root: string;
|
|
133
|
+
label: string;
|
|
134
|
+
};
|
|
135
|
+
};
|
|
136
|
+
fullWidth: {
|
|
137
|
+
true: {
|
|
138
|
+
root: string;
|
|
139
|
+
};
|
|
140
|
+
};
|
|
141
|
+
disabled: {
|
|
142
|
+
true: {
|
|
143
|
+
root: string;
|
|
144
|
+
};
|
|
145
|
+
};
|
|
146
|
+
}, {
|
|
147
|
+
root: string;
|
|
148
|
+
/**
|
|
149
|
+
* The ground the handle has covered.
|
|
150
|
+
*
|
|
151
|
+
* Inset on every side by the same padding the handle sits in, so at rest
|
|
152
|
+
* it is exactly zero wide and there is nothing to see — a trail with a
|
|
153
|
+
* sliver of colour in it before anything has been dragged is a control
|
|
154
|
+
* that looks part-finished.
|
|
155
|
+
*/
|
|
156
|
+
fill: string;
|
|
157
|
+
/** The label, centred in the rail rather than in the space beside it. */
|
|
158
|
+
label: string;
|
|
159
|
+
/**
|
|
160
|
+
* The draggable handle. Wider than it is tall, so it reads as something to
|
|
161
|
+
* push rather than as a dot that happens to be on a track — and the extra
|
|
162
|
+
* width is what gives the chevron room to sit in without crowding the
|
|
163
|
+
* curve at either end.
|
|
164
|
+
*/
|
|
165
|
+
thumb: string;
|
|
166
|
+
/** What the thumb holds — a chevron at rest, a tick once it has arrived. */
|
|
167
|
+
thumbContent: string;
|
|
168
|
+
}, import("tailwind-variants").TVReturnType<{
|
|
169
|
+
variant: {
|
|
170
|
+
secondary: {
|
|
171
|
+
label: string;
|
|
172
|
+
fill: string;
|
|
173
|
+
};
|
|
174
|
+
destructive: {
|
|
175
|
+
label: string;
|
|
176
|
+
fill: string;
|
|
177
|
+
};
|
|
178
|
+
success: {
|
|
179
|
+
label: string;
|
|
180
|
+
fill: string;
|
|
181
|
+
};
|
|
182
|
+
};
|
|
183
|
+
size: {
|
|
184
|
+
sm: {
|
|
185
|
+
root: string;
|
|
186
|
+
label: string;
|
|
187
|
+
};
|
|
188
|
+
md: {
|
|
189
|
+
root: string;
|
|
190
|
+
label: string;
|
|
191
|
+
};
|
|
192
|
+
lg: {
|
|
193
|
+
root: string;
|
|
194
|
+
label: string;
|
|
195
|
+
};
|
|
196
|
+
};
|
|
197
|
+
fullWidth: {
|
|
198
|
+
true: {
|
|
199
|
+
root: string;
|
|
200
|
+
};
|
|
201
|
+
};
|
|
202
|
+
disabled: {
|
|
203
|
+
true: {
|
|
204
|
+
root: string;
|
|
205
|
+
};
|
|
206
|
+
};
|
|
207
|
+
}, {
|
|
208
|
+
root: string;
|
|
209
|
+
/**
|
|
210
|
+
* The ground the handle has covered.
|
|
211
|
+
*
|
|
212
|
+
* Inset on every side by the same padding the handle sits in, so at rest
|
|
213
|
+
* it is exactly zero wide and there is nothing to see — a trail with a
|
|
214
|
+
* sliver of colour in it before anything has been dragged is a control
|
|
215
|
+
* that looks part-finished.
|
|
216
|
+
*/
|
|
217
|
+
fill: string;
|
|
218
|
+
/** The label, centred in the rail rather than in the space beside it. */
|
|
219
|
+
label: string;
|
|
220
|
+
/**
|
|
221
|
+
* The draggable handle. Wider than it is tall, so it reads as something to
|
|
222
|
+
* push rather than as a dot that happens to be on a track — and the extra
|
|
223
|
+
* width is what gives the chevron room to sit in without crowding the
|
|
224
|
+
* curve at either end.
|
|
225
|
+
*/
|
|
226
|
+
thumb: string;
|
|
227
|
+
/** What the thumb holds — a chevron at rest, a tick once it has arrived. */
|
|
228
|
+
thumbContent: string;
|
|
229
|
+
}, undefined, unknown, unknown, undefined>>;
|
|
230
|
+
type SlideButtonVariantProps = VariantProps<typeof slideButtonVariants>;
|
|
231
|
+
/** How a slide button looks. */
|
|
232
|
+
export type SlideButtonVariant = NonNullable<SlideButtonVariantProps['variant']>;
|
|
233
|
+
/** How big a slide button is. */
|
|
234
|
+
export type SlideButtonSize = NonNullable<SlideButtonVariantProps['size']>;
|
|
235
|
+
/** The slide's progress and whether it has completed, for a custom part. */
|
|
236
|
+
export declare function useSlideButton(): {
|
|
237
|
+
progress: SharedValue<number>;
|
|
238
|
+
completed: boolean;
|
|
239
|
+
};
|
|
240
|
+
export interface SlideButtonProps extends Omit<ViewProps, 'children'>, Omit<SlideButtonVariantProps, 'disabled'> {
|
|
241
|
+
/** Extra classes for the rail — the box the button occupies in your layout. */
|
|
242
|
+
className?: string;
|
|
243
|
+
/**
|
|
244
|
+
* The fraction of the rail the thumb has to cover for the slide to count.
|
|
245
|
+
* Defaults to `0.9`, clamped to between `0.1` and `1`.
|
|
246
|
+
*/
|
|
247
|
+
threshold?: number;
|
|
248
|
+
/** Fires once the thumb has been taken past the threshold and released. */
|
|
249
|
+
onComplete?: () => void;
|
|
250
|
+
/** Fires whenever the completed state changes, including on a reset. */
|
|
251
|
+
onCompletedChange?: (completed: boolean) => void;
|
|
252
|
+
/** Controlled completion. Leave unset to let the button own it. */
|
|
253
|
+
completed?: boolean;
|
|
254
|
+
/** Return to the unslid state after `autoResetDelay`. */
|
|
255
|
+
autoReset?: boolean;
|
|
256
|
+
/** Milliseconds to stay completed before resetting. Defaults to `1000`. */
|
|
257
|
+
autoResetDelay?: number;
|
|
258
|
+
/** Dim the button and refuse the drag outright. */
|
|
259
|
+
disabled?: boolean;
|
|
260
|
+
/**
|
|
261
|
+
* A tick as the thumb arms and a knock when it commits. Off by default,
|
|
262
|
+
* because a control used several times in a row is one a reader may not want
|
|
263
|
+
* buzzing every time.
|
|
264
|
+
*/
|
|
265
|
+
haptics?: boolean;
|
|
266
|
+
/**
|
|
267
|
+
* What a screen reader is told the button does, in the imperative — it is
|
|
268
|
+
* announced as the action of a button rather than as an instruction to drag,
|
|
269
|
+
* since dragging is not available there. Defaults to `'Confirm'`.
|
|
270
|
+
*/
|
|
271
|
+
accessibilityActionLabel?: string;
|
|
272
|
+
children?: ReactNode;
|
|
273
|
+
}
|
|
274
|
+
export interface SlideButtonLabelProps extends ViewProps {
|
|
275
|
+
/** Extra classes for the label's text. */
|
|
276
|
+
className?: string;
|
|
277
|
+
children?: ReactNode;
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* What the button says.
|
|
281
|
+
*
|
|
282
|
+
* Centred in the whole rail rather than in the space beside the thumb, and it
|
|
283
|
+
* does not move or fade — the thumb simply passes over it, and the rail's own
|
|
284
|
+
* clip takes the rest.
|
|
285
|
+
*
|
|
286
|
+
* Fading it out was worse in a way that only shows on a device: the label
|
|
287
|
+
* disappears while there is still most of a rail left to cross, so the button
|
|
288
|
+
* spends the second half of the gesture saying nothing at all. Covered
|
|
289
|
+
* instead, the text is legible right up to the moment the handle reaches it,
|
|
290
|
+
* which is also the moment the reader no longer needs it.
|
|
291
|
+
*/
|
|
292
|
+
declare function SlideButtonLabel({ className, style, children, ...props }: SlideButtonLabelProps): import("react").JSX.Element;
|
|
293
|
+
declare namespace SlideButtonLabel {
|
|
294
|
+
var displayName: string;
|
|
295
|
+
}
|
|
296
|
+
export interface SlideButtonThumbProps extends ViewProps {
|
|
297
|
+
/** Extra classes for the thumb — its fill and shape. Its size comes from `size`. */
|
|
298
|
+
className?: string;
|
|
299
|
+
/** Replaces the chevron. The tick that lands on completion is unaffected. */
|
|
300
|
+
children?: ReactNode;
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* The disc the finger moves.
|
|
304
|
+
*
|
|
305
|
+
* Translated rather than laid out at a position, so a drag costs no layout
|
|
306
|
+
* pass. It sits absolutely at the rail's leading inset and travels from there.
|
|
307
|
+
*/
|
|
308
|
+
declare function SlideButtonThumb({ className, style, children, ...props }: SlideButtonThumbProps): import("react").JSX.Element;
|
|
309
|
+
declare namespace SlideButtonThumb {
|
|
310
|
+
var displayName: string;
|
|
311
|
+
}
|
|
312
|
+
export declare const SlideButton: import("react").ForwardRefExoticComponent<SlideButtonProps & import("react").RefAttributes<View>> & {
|
|
313
|
+
Label: typeof SlideButtonLabel;
|
|
314
|
+
Thumb: typeof SlideButtonThumb;
|
|
315
|
+
};
|
|
316
|
+
export {};
|
|
317
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/slide-button/index.tsx"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The arithmetic behind a slide, kept out of the component so it can be tested
|
|
3
|
+
* without a renderer — the same split `progress-button-hold` uses.
|
|
4
|
+
*
|
|
5
|
+
* The gesture's worklets carry their own copies of these three lines rather
|
|
6
|
+
* than calling in here. A pan handler is the one place in the library that
|
|
7
|
+
* cannot afford a surprise: a worklet reaching across a module boundary for a
|
|
8
|
+
* helper that reaches across again for another is a chain with more ways to go
|
|
9
|
+
* wrong than the arithmetic is long. What lives here is the definition, and
|
|
10
|
+
* the tests hold the component to it.
|
|
11
|
+
*/
|
|
12
|
+
/** The fraction of the rail that has to be covered for the slide to count. */
|
|
13
|
+
export declare const DEFAULT_THRESHOLD = 0.9;
|
|
14
|
+
/** Milliseconds before an `autoReset` button offers itself again. */
|
|
15
|
+
export declare const DEFAULT_AUTO_RESET_DELAY = 1000;
|
|
16
|
+
/**
|
|
17
|
+
* Seconds of fling counted as distance already travelled.
|
|
18
|
+
*
|
|
19
|
+
* A slide released at speed near the end was going to arrive, and stopping it
|
|
20
|
+
* dead a few points short is the control arguing with a gesture that had
|
|
21
|
+
* plainly committed. Small, because the reverse mistake — a flick from
|
|
22
|
+
* halfway completing an action the reader was only playing with — is the
|
|
23
|
+
* worse one.
|
|
24
|
+
*/
|
|
25
|
+
export declare const VELOCITY_LOOKAHEAD = 0.12;
|
|
26
|
+
/**
|
|
27
|
+
* How far past the end the thumb can be pushed, as a divisor on the overshoot.
|
|
28
|
+
*
|
|
29
|
+
* The rail has an end and the finger does not, so the distance past it is
|
|
30
|
+
* given back at an eighth. Without this the thumb parks under the finger with
|
|
31
|
+
* a gap opening behind it, which reads as the control having come loose.
|
|
32
|
+
*/
|
|
33
|
+
export declare const OVERSHOOT_FRICTION = 8;
|
|
34
|
+
/**
|
|
35
|
+
* A threshold that cannot produce a button which fires on contact.
|
|
36
|
+
*
|
|
37
|
+
* Zero would complete the moment the thumb moved, which is a button with a
|
|
38
|
+
* gesture in front of it rather than a slide. One is allowed: it means the
|
|
39
|
+
* thumb has to reach the far end exactly, which is a legitimate ask for
|
|
40
|
+
* something destructive.
|
|
41
|
+
*/
|
|
42
|
+
export declare function resolveThreshold(threshold: number | undefined): number;
|
|
43
|
+
/**
|
|
44
|
+
* How far along the rail the thumb has been dragged, as `0` to `1`.
|
|
45
|
+
*
|
|
46
|
+
* `travel` is the rail minus the thumb — the distance the thumb's own leading
|
|
47
|
+
* edge can actually cover. Measuring against the full rail width instead would
|
|
48
|
+
* make the last thumb-width of the track unreachable, so a slide could never
|
|
49
|
+
* finish.
|
|
50
|
+
*/
|
|
51
|
+
export declare function progressFor(translation: number, travel: number): number;
|
|
52
|
+
/**
|
|
53
|
+
* The thumb's offset in points, rubber-banded once it passes the end.
|
|
54
|
+
*
|
|
55
|
+
* Before the end it follows the finger exactly. There is no easing on the way
|
|
56
|
+
* out, because a thumb that lags its own finger reads as a slow app rather
|
|
57
|
+
* than as a heavy control.
|
|
58
|
+
*/
|
|
59
|
+
export declare function offsetFor(translation: number, travel: number): number;
|
|
60
|
+
/**
|
|
61
|
+
* Whether a released slide should be honoured.
|
|
62
|
+
*
|
|
63
|
+
* Where it got to, plus where its speed was about to carry it. A slide let go
|
|
64
|
+
* short and still is refused; a slide let go short and travelling is not,
|
|
65
|
+
* because the reader has already made the movement that finishes it.
|
|
66
|
+
*/
|
|
67
|
+
export declare function isCommitted(progress: number, velocity: number, travel: number, threshold: number): boolean;
|
|
68
|
+
/** Keeps a number inside a range. Exported because the tests read it. */
|
|
69
|
+
export declare function clamp(value: number, low: number, high: number): number;
|
|
70
|
+
//# sourceMappingURL=slide-button-track.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slide-button-track.d.ts","sourceRoot":"","sources":["../../../../../src/components/slide-button/slide-button-track.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,8EAA8E;AAC9E,eAAO,MAAM,iBAAiB,MAAM,CAAC;AAErC,qEAAqE;AACrE,eAAO,MAAM,wBAAwB,OAAO,CAAC;AAE7C;;;;;;;;GAQG;AACH,eAAO,MAAM,kBAAkB,OAAO,CAAC;AAEvC;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,IAAI,CAAC;AAEpC;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAGtE;AAED;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAGvE;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAKrE;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CACzB,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,GAChB,OAAO,CAIT;AAED,yEAAyE;AACzE,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAEtE"}
|