@symbiote-native/slider 5.1.0 → 6.0.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 +43 -7
- package/build/angular/index.js +1 -1
- package/build/angular/slider/index.android.js +7 -1
- package/build/angular/slider/index.ios.js +8 -2
- package/build/angular/slider/shared.js +4 -1
- package/build/core/index.d.ts +2 -2
- package/build/core/render-slider.js +5 -1
- package/build/core/render-steps-indicator.js +13 -4
- package/build/react/index.js +1 -1
- package/build/react/slider/index.ios.js +1 -1
- package/build/react/slider/shared.js +11 -4
- package/build/register/index.js +5 -2
- package/build/solid/index.d.ts +4 -0
- package/build/solid/index.js +8 -0
- package/build/solid/slider/index.android.d.ts +2 -0
- package/build/solid/slider/index.android.js +10 -0
- package/build/solid/slider/index.d.ts +1 -0
- package/build/solid/slider/index.ios.d.ts +2 -0
- package/build/solid/slider/index.ios.js +11 -0
- package/build/solid/slider/index.js +4 -0
- package/build/solid/slider/shared.d.ts +12 -0
- package/build/solid/slider/shared.js +296 -0
- package/build/svelte/index.js +1 -1
- package/build/svelte/slider/index.svelte +62 -10
- package/build/svelte/slider/slider-platform.ios.js +1 -1
- package/build/vue/index.js +1 -1
- package/build/vue/slider/index.ios.js +1 -1
- package/build/vue/slider/shared.js +11 -5
- package/build-ngc/angular/slider/index.android.js +14 -2
- package/build-ngc/angular/slider/index.android.js.map +1 -1
- package/build-ngc/angular/slider/index.ios.js +15 -3
- package/build-ngc/angular/slider/index.ios.js.map +1 -1
- package/build-ngc/angular/slider/shared.js +4 -1
- package/build-ngc/angular/slider/shared.js.map +1 -1
- package/build-ngc/core/index.d.ts +2 -2
- package/build-ngc/core/index.js.map +1 -1
- package/build-ngc/core/render-slider.js +5 -1
- package/build-ngc/core/render-slider.js.map +1 -1
- package/build-ngc/core/render-steps-indicator.js +13 -4
- package/build-ngc/core/render-steps-indicator.js.map +1 -1
- package/build-ngc/core/slider-state.js.map +1 -1
- package/build-ngc/register/index.js +5 -2
- package/build-ngc/register/index.js.map +1 -1
- package/package.json +39 -15
- package/src/angular/slider/index.android.ts +7 -1
- package/src/angular/slider/index.ios.ts +11 -2
- package/src/angular/slider/shared.ts +31 -10
- package/src/core/index.ts +9 -2
- package/src/core/render-slider.ts +24 -6
- package/src/core/render-steps-indicator.ts +38 -10
- package/src/core/slider-props.ts +5 -1
- package/src/core/slider-state.ts +16 -5
- package/src/react/slider/index.ios.ts +4 -1
- package/src/react/slider/shared.ts +66 -15
- package/src/register/index.ts +9 -2
- package/src/solid/index.ts +12 -0
- package/src/solid/slider/index.android.ts +15 -0
- package/src/solid/slider/index.ios.ts +19 -0
- package/src/solid/slider/index.ts +5 -0
- package/src/solid/slider/shared.ts +468 -0
- package/src/svelte/slider/index.svelte +62 -10
- package/src/svelte/slider/slider-platform.ios.ts +4 -1
- package/src/svelte/slider/slider-props.ts +4 -1
- package/src/vue/slider/index.ios.ts +4 -1
- package/src/vue/slider/shared.ts +72 -19
package/src/vue/slider/shared.ts
CHANGED
|
@@ -7,7 +7,13 @@
|
|
|
7
7
|
// the side-effect import in ../register (pulled in by the package barrel, NOT here, so this module
|
|
8
8
|
// and its tests stay free of the third-party spec).
|
|
9
9
|
|
|
10
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
defineComponent,
|
|
12
|
+
h,
|
|
13
|
+
ref,
|
|
14
|
+
type SetupContext,
|
|
15
|
+
type VNode,
|
|
16
|
+
} from '@vue/runtime-core';
|
|
11
17
|
import {
|
|
12
18
|
descriptorToVue,
|
|
13
19
|
normalizeVueAttrs,
|
|
@@ -16,7 +22,11 @@ import {
|
|
|
16
22
|
Image,
|
|
17
23
|
type IImageSourceProp,
|
|
18
24
|
} from '@symbiote-native/vue';
|
|
19
|
-
import {
|
|
25
|
+
import {
|
|
26
|
+
dlog,
|
|
27
|
+
type IClassNameValue,
|
|
28
|
+
type ISymbioteEvent,
|
|
29
|
+
} from '@symbiote-native/engine';
|
|
20
30
|
import {
|
|
21
31
|
sanitizeSliderValue,
|
|
22
32
|
resolveSliderDisabled,
|
|
@@ -60,7 +70,10 @@ import {
|
|
|
60
70
|
// the class-routing note on HANDLED_ATTRS below.
|
|
61
71
|
export type ISliderProps = Omit<
|
|
62
72
|
ISliderBaseProps,
|
|
63
|
-
|
|
73
|
+
| 'onValueChange'
|
|
74
|
+
| 'onSlidingStart'
|
|
75
|
+
| 'onSlidingComplete'
|
|
76
|
+
| 'onAccessibilityAction'
|
|
64
77
|
> & {
|
|
65
78
|
modelValue?: number;
|
|
66
79
|
class?: IClassNameValue;
|
|
@@ -92,14 +105,21 @@ function asBoolean(value: unknown): boolean | undefined {
|
|
|
92
105
|
}
|
|
93
106
|
|
|
94
107
|
function isImageSourceProp(value: unknown): value is IImageSourceProp {
|
|
95
|
-
return
|
|
108
|
+
return (
|
|
109
|
+
typeof value === 'number' || (typeof value === 'object' && value !== null)
|
|
110
|
+
);
|
|
96
111
|
}
|
|
97
112
|
|
|
98
113
|
// accessibilityState arrives untyped; narrow its disabled flag for the fold while preserving the
|
|
99
114
|
// other entries at runtime (the resolve spread carries them onto the native node).
|
|
100
|
-
function asAccessibilityState(
|
|
115
|
+
function asAccessibilityState(
|
|
116
|
+
value: unknown,
|
|
117
|
+
): ISliderAccessibilityState | undefined {
|
|
101
118
|
if (!isRecord(value)) return undefined;
|
|
102
|
-
return {
|
|
119
|
+
return {
|
|
120
|
+
...value,
|
|
121
|
+
disabled: typeof value.disabled === 'boolean' ? value.disabled : undefined,
|
|
122
|
+
};
|
|
103
123
|
}
|
|
104
124
|
|
|
105
125
|
// The props/handlers the lifecycle consumes itself; everything else (the track tints + images,
|
|
@@ -180,14 +200,17 @@ export function createSlider(platform: ISliderPlatform) {
|
|
|
180
200
|
};
|
|
181
201
|
const handleLayout = (event: ISymbioteEvent): void => {
|
|
182
202
|
const layout = event.nativeEvent.layout;
|
|
183
|
-
if (isRecord(layout) && typeof layout.width === 'number')
|
|
203
|
+
if (isRecord(layout) && typeof layout.width === 'number')
|
|
204
|
+
width.value = layout.width;
|
|
184
205
|
};
|
|
185
206
|
|
|
186
207
|
return () => {
|
|
187
208
|
const attrs = normalizeVueAttrs(rawAttrs);
|
|
188
209
|
|
|
189
|
-
const minimumValue =
|
|
190
|
-
|
|
210
|
+
const minimumValue =
|
|
211
|
+
asNumber(attrs.minimumValue) ?? SLIDER_DEFAULT_MINIMUM_VALUE;
|
|
212
|
+
const maximumValue =
|
|
213
|
+
asNumber(attrs.maximumValue) ?? SLIDER_DEFAULT_MAXIMUM_VALUE;
|
|
191
214
|
const step = asNumber(attrs.step) ?? SLIDER_DEFAULT_STEP;
|
|
192
215
|
const lowerLimit = resolveSliderLowerLimit(asNumber(attrs.lowerLimit));
|
|
193
216
|
const upperLimit = resolveSliderUpperLimit(asNumber(attrs.upperLimit));
|
|
@@ -195,19 +218,27 @@ export function createSlider(platform: ISliderPlatform) {
|
|
|
195
218
|
dlog('Slider: lowerLimit must be smaller than upperLimit');
|
|
196
219
|
}
|
|
197
220
|
const disabledAttr = asBoolean(attrs.disabled);
|
|
198
|
-
const accessibilityState = asAccessibilityState(
|
|
221
|
+
const accessibilityState = asAccessibilityState(
|
|
222
|
+
attrs.accessibilityState,
|
|
223
|
+
);
|
|
199
224
|
const inverted = asBoolean(attrs.inverted) ?? false;
|
|
200
225
|
|
|
201
226
|
const hasStepMarker = slots.stepMarker !== undefined;
|
|
202
227
|
const renderStepNumber = asBoolean(attrs.renderStepNumber);
|
|
203
228
|
const hasThumbImage = attrs.thumbImage !== undefined;
|
|
204
|
-
const showSteps = shouldRenderStepsIndicator(
|
|
229
|
+
const showSteps = shouldRenderStepsIndicator(
|
|
230
|
+
hasStepMarker,
|
|
231
|
+
renderStepNumber,
|
|
232
|
+
);
|
|
205
233
|
|
|
206
234
|
// The native view gets a thumbImage only when there is one AND no custom marker (which
|
|
207
235
|
// draws its own thumb), matching the library. We pass the source raw — the engine runs the
|
|
208
236
|
// image processor derived from RNCSlider's ViewConfig (same path as the color tints), so
|
|
209
237
|
// unlike the plain-RN library wrapper we do NOT pre-call Image.resolveAssetSource here.
|
|
210
|
-
const nativeThumbImage = shouldPassNativeThumbImage(
|
|
238
|
+
const nativeThumbImage = shouldPassNativeThumbImage(
|
|
239
|
+
hasStepMarker,
|
|
240
|
+
hasThumbImage,
|
|
241
|
+
)
|
|
211
242
|
? attrs.thumbImage
|
|
212
243
|
: undefined;
|
|
213
244
|
|
|
@@ -220,9 +251,16 @@ export function createSlider(platform: ISliderPlatform) {
|
|
|
220
251
|
upperLimit,
|
|
221
252
|
disabled: resolveSliderDisabled(disabledAttr, accessibilityState),
|
|
222
253
|
inverted,
|
|
223
|
-
thumbTintColor: resolveThumbTintColor(
|
|
254
|
+
thumbTintColor: resolveThumbTintColor(
|
|
255
|
+
attrs.thumbTintColor,
|
|
256
|
+
hasStepMarker,
|
|
257
|
+
hasThumbImage,
|
|
258
|
+
),
|
|
224
259
|
thumbImage: nativeThumbImage,
|
|
225
|
-
accessibilityState: resolveSliderAccessibilityState(
|
|
260
|
+
accessibilityState: resolveSliderAccessibilityState(
|
|
261
|
+
disabledAttr,
|
|
262
|
+
accessibilityState,
|
|
263
|
+
),
|
|
226
264
|
width: width.value,
|
|
227
265
|
style: attrs.style,
|
|
228
266
|
passthrough: {
|
|
@@ -314,7 +352,10 @@ export function createSlider(platform: ISliderPlatform) {
|
|
|
314
352
|
|
|
315
353
|
// The wrapper style for the steps path mirrors renderSlider's wrapper (kept here because the
|
|
316
354
|
// custom-marker path builds the wrapper itself rather than going through renderSlider).
|
|
317
|
-
function resolveStepsWrapperStyle(
|
|
355
|
+
function resolveStepsWrapperStyle(
|
|
356
|
+
style: unknown,
|
|
357
|
+
platform: ISliderPlatform,
|
|
358
|
+
): unknown {
|
|
318
359
|
return [platform.defaultStyle, style, { justifyContent: 'center' }];
|
|
319
360
|
}
|
|
320
361
|
|
|
@@ -348,12 +389,16 @@ function renderCustomStepsOverlay(params: ICustomStepsParams): VNode {
|
|
|
348
389
|
min,
|
|
349
390
|
max,
|
|
350
391
|
});
|
|
351
|
-
if (marker !== undefined)
|
|
392
|
+
if (marker !== undefined)
|
|
393
|
+
trackChildren.push(h('symbiote-view', {}, marker));
|
|
352
394
|
if (isImageSourceProp(params.thumbImage) && value === params.currentValue) {
|
|
353
395
|
trackChildren.push(
|
|
354
396
|
h(
|
|
355
397
|
'symbiote-view',
|
|
356
|
-
{
|
|
398
|
+
{
|
|
399
|
+
style: THUMB_IMAGE_CONTAINER_STYLE,
|
|
400
|
+
testID: 'sliderTrackMark-thumbImage',
|
|
401
|
+
},
|
|
357
402
|
[h(Image, { source: params.thumbImage, style: THUMB_IMAGE_STYLE })],
|
|
358
403
|
),
|
|
359
404
|
);
|
|
@@ -364,11 +409,19 @@ function renderCustomStepsOverlay(params: ICustomStepsParams): VNode {
|
|
|
364
409
|
if (params.renderStepNumber) {
|
|
365
410
|
cellChildren.push(
|
|
366
411
|
h('symbiote-view', { style: STEP_NUMBER_CONTAINER_STYLE }, [
|
|
367
|
-
h(
|
|
412
|
+
h(
|
|
413
|
+
'symbiote-text',
|
|
414
|
+
{ testID: `${index}th-step`, style: { fontSize } },
|
|
415
|
+
String(value),
|
|
416
|
+
),
|
|
368
417
|
]),
|
|
369
418
|
);
|
|
370
419
|
}
|
|
371
|
-
return h(
|
|
420
|
+
return h(
|
|
421
|
+
'symbiote-view',
|
|
422
|
+
{ style: STEP_INDICATOR_ELEMENT_STYLE },
|
|
423
|
+
cellChildren,
|
|
424
|
+
);
|
|
372
425
|
});
|
|
373
426
|
return h(
|
|
374
427
|
'symbiote-view',
|