@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.
Files changed (65) hide show
  1. package/README.md +43 -7
  2. package/build/angular/index.js +1 -1
  3. package/build/angular/slider/index.android.js +7 -1
  4. package/build/angular/slider/index.ios.js +8 -2
  5. package/build/angular/slider/shared.js +4 -1
  6. package/build/core/index.d.ts +2 -2
  7. package/build/core/render-slider.js +5 -1
  8. package/build/core/render-steps-indicator.js +13 -4
  9. package/build/react/index.js +1 -1
  10. package/build/react/slider/index.ios.js +1 -1
  11. package/build/react/slider/shared.js +11 -4
  12. package/build/register/index.js +5 -2
  13. package/build/solid/index.d.ts +4 -0
  14. package/build/solid/index.js +8 -0
  15. package/build/solid/slider/index.android.d.ts +2 -0
  16. package/build/solid/slider/index.android.js +10 -0
  17. package/build/solid/slider/index.d.ts +1 -0
  18. package/build/solid/slider/index.ios.d.ts +2 -0
  19. package/build/solid/slider/index.ios.js +11 -0
  20. package/build/solid/slider/index.js +4 -0
  21. package/build/solid/slider/shared.d.ts +12 -0
  22. package/build/solid/slider/shared.js +296 -0
  23. package/build/svelte/index.js +1 -1
  24. package/build/svelte/slider/index.svelte +62 -10
  25. package/build/svelte/slider/slider-platform.ios.js +1 -1
  26. package/build/vue/index.js +1 -1
  27. package/build/vue/slider/index.ios.js +1 -1
  28. package/build/vue/slider/shared.js +11 -5
  29. package/build-ngc/angular/slider/index.android.js +14 -2
  30. package/build-ngc/angular/slider/index.android.js.map +1 -1
  31. package/build-ngc/angular/slider/index.ios.js +15 -3
  32. package/build-ngc/angular/slider/index.ios.js.map +1 -1
  33. package/build-ngc/angular/slider/shared.js +4 -1
  34. package/build-ngc/angular/slider/shared.js.map +1 -1
  35. package/build-ngc/core/index.d.ts +2 -2
  36. package/build-ngc/core/index.js.map +1 -1
  37. package/build-ngc/core/render-slider.js +5 -1
  38. package/build-ngc/core/render-slider.js.map +1 -1
  39. package/build-ngc/core/render-steps-indicator.js +13 -4
  40. package/build-ngc/core/render-steps-indicator.js.map +1 -1
  41. package/build-ngc/core/slider-state.js.map +1 -1
  42. package/build-ngc/register/index.js +5 -2
  43. package/build-ngc/register/index.js.map +1 -1
  44. package/package.json +39 -15
  45. package/src/angular/slider/index.android.ts +7 -1
  46. package/src/angular/slider/index.ios.ts +11 -2
  47. package/src/angular/slider/shared.ts +31 -10
  48. package/src/core/index.ts +9 -2
  49. package/src/core/render-slider.ts +24 -6
  50. package/src/core/render-steps-indicator.ts +38 -10
  51. package/src/core/slider-props.ts +5 -1
  52. package/src/core/slider-state.ts +16 -5
  53. package/src/react/slider/index.ios.ts +4 -1
  54. package/src/react/slider/shared.ts +66 -15
  55. package/src/register/index.ts +9 -2
  56. package/src/solid/index.ts +12 -0
  57. package/src/solid/slider/index.android.ts +15 -0
  58. package/src/solid/slider/index.ios.ts +19 -0
  59. package/src/solid/slider/index.ts +5 -0
  60. package/src/solid/slider/shared.ts +468 -0
  61. package/src/svelte/slider/index.svelte +62 -10
  62. package/src/svelte/slider/slider-platform.ios.ts +4 -1
  63. package/src/svelte/slider/slider-props.ts +4 -1
  64. package/src/vue/slider/index.ios.ts +4 -1
  65. package/src/vue/slider/shared.ts +72 -19
@@ -18,7 +18,9 @@ export type ISliderAccessibilityState = {
18
18
  // Mirror the library's `passedValue`: NaN or a falsy value (incl. 0) becomes undefined, so the
19
19
  // native view falls back to its own default initial value rather than receiving NaN/0 as a
20
20
  // write. Entered once it still acts as the initial value (the slider is uncontrolled after).
21
- export function sanitizeSliderValue(value: number | undefined): number | undefined {
21
+ export function sanitizeSliderValue(
22
+ value: number | undefined,
23
+ ): number | undefined {
22
24
  if (value === undefined) return undefined;
23
25
  return Number.isNaN(value) || !value ? undefined : value;
24
26
  }
@@ -44,17 +46,23 @@ export function resolveSliderAccessibilityState(
44
46
  }
45
47
 
46
48
  // Default the slide limits to the unbounded sentinels when unset (the native, non-web case).
47
- export function resolveSliderLowerLimit(lowerLimit: number | undefined): number {
49
+ export function resolveSliderLowerLimit(
50
+ lowerLimit: number | undefined,
51
+ ): number {
48
52
  return lowerLimit ?? SLIDER_LIMIT_MIN_VALUE;
49
53
  }
50
54
 
51
- export function resolveSliderUpperLimit(upperLimit: number | undefined): number {
55
+ export function resolveSliderUpperLimit(
56
+ upperLimit: number | undefined,
57
+ ): number {
52
58
  return upperLimit ?? SLIDER_LIMIT_MAX_VALUE;
53
59
  }
54
60
 
55
61
  // The value the native value/sliding events carry as nativeEvent.value. nativeEvent is an
56
62
  // untyped Record, so narrow; a non-number payload yields undefined (no callback fired upstream).
57
- export function valueFromSliderEvent(event: ISymbioteEvent): number | undefined {
63
+ export function valueFromSliderEvent(
64
+ event: ISymbioteEvent,
65
+ ): number | undefined {
58
66
  const value = event.nativeEvent.value;
59
67
  return typeof value === 'number' ? value : undefined;
60
68
  }
@@ -91,7 +99,10 @@ export function shouldPassNativeThumbImage(
91
99
  }
92
100
 
93
101
  // The library warns when the limits cross; surfaced as a pure predicate so the adapter logs it.
94
- export function isInvalidLimitConfig(lowerLimit: number, upperLimit: number): boolean {
102
+ export function isInvalidLimitConfig(
103
+ lowerLimit: number,
104
+ upperLimit: number,
105
+ ): boolean {
95
106
  return lowerLimit >= upperLimit;
96
107
  }
97
108
 
@@ -3,7 +3,10 @@
3
3
  // Also the base (./index re-exports it) for headless. Mirrors the library's iOS branches.
4
4
 
5
5
  import { createSlider } from './shared';
6
- import { SLIDER_IOS_DEFAULT_HEIGHT, SLIDER_STEP_RESOLUTION_IOS } from '../../core';
6
+ import {
7
+ SLIDER_IOS_DEFAULT_HEIGHT,
8
+ SLIDER_STEP_RESOLUTION_IOS,
9
+ } from '../../core';
7
10
 
8
11
  const IOS_STEPS_CONTAINER_TOP = 10;
9
12
 
@@ -9,7 +9,13 @@
9
9
  // library's React Slider component — that component internally calls React hooks off the React
10
10
  // dispatcher, so a non-React adapter rendering it directly would crash on a null dispatcher.
11
11
 
12
- import { createElement, forwardRef, useCallback, useEffect, useState } from 'react';
12
+ import {
13
+ createElement,
14
+ forwardRef,
15
+ useCallback,
16
+ useEffect,
17
+ useState,
18
+ } from 'react';
13
19
  import type {
14
20
  FC,
15
21
  ForwardRefExoticComponent,
@@ -19,8 +25,16 @@ import type {
19
25
  } from 'react';
20
26
  import { descriptorToReact, Image } from '@symbiote-native/react';
21
27
  import { resolveAccessibilityProps } from '@symbiote-native/components';
22
- import type { IDescriptor, IDescriptorChild, IImageSourceProp } from '@symbiote-native/components';
23
- import { dlog, type ISymbioteEvent, type ISymbioteNode } from '@symbiote-native/engine';
28
+ import type {
29
+ IDescriptor,
30
+ IDescriptorChild,
31
+ IImageSourceProp,
32
+ } from '@symbiote-native/components';
33
+ import {
34
+ dlog,
35
+ type ISymbioteEvent,
36
+ type ISymbioteNode,
37
+ } from '@symbiote-native/engine';
24
38
  import {
25
39
  sanitizeSliderValue,
26
40
  resolveSliderDisabled,
@@ -86,7 +100,10 @@ function toChild(child: IDescriptorChild): ReactElement | string {
86
100
  // renderSlider's Descriptor IS the outer wrapper (symbiote-view hosting the native leaf +
87
101
  // optional steps overlay); className is reapplied on it here, exactly like ImageBackground's
88
102
  // wrapper.
89
- function withClassName(descriptor: IDescriptor, className: string | undefined): ReactElement {
103
+ function withClassName(
104
+ descriptor: IDescriptor,
105
+ className: string | undefined,
106
+ ): ReactElement {
90
107
  return createElement(
91
108
  descriptor.type,
92
109
  { key: descriptor.key, ...descriptor.props, className },
@@ -123,7 +140,9 @@ export function createSlider(platform: ISliderPlatform): ISliderComponent {
123
140
  ...passthrough
124
141
  } = props;
125
142
 
126
- const [reportedValue, setReportedValue] = useState<number | undefined>(undefined);
143
+ const [reportedValue, setReportedValue] = useState<number | undefined>(
144
+ undefined,
145
+ );
127
146
  const [width, setWidth] = useState(0);
128
147
 
129
148
  const handleValueChange = useCallback(
@@ -157,7 +176,8 @@ export function createSlider(platform: ISliderPlatform): ISliderComponent {
157
176
  );
158
177
  const handleLayout = useCallback((event: ISymbioteEvent): void => {
159
178
  const layout = event.nativeEvent.layout;
160
- if (isRecord(layout) && typeof layout.width === 'number') setWidth(layout.width);
179
+ if (isRecord(layout) && typeof layout.width === 'number')
180
+ setWidth(layout.width);
161
181
  }, []);
162
182
 
163
183
  const minimum = minimumValue ?? SLIDER_DEFAULT_MINIMUM_VALUE;
@@ -173,10 +193,16 @@ export function createSlider(platform: ISliderPlatform): ISliderComponent {
173
193
 
174
194
  const hasStepMarker = StepMarker !== undefined;
175
195
  const hasThumbImage = thumbImage !== undefined;
176
- const showSteps = shouldRenderStepsIndicator(hasStepMarker, renderStepNumber);
196
+ const showSteps = shouldRenderStepsIndicator(
197
+ hasStepMarker,
198
+ renderStepNumber,
199
+ );
177
200
  // Passed to the native view raw — the engine runs the image processor derived from RNCSlider's
178
201
  // ViewConfig — and only when no custom marker draws its own thumb (matches the library).
179
- const nativeThumbImage = shouldPassNativeThumbImage(hasStepMarker, hasThumbImage)
202
+ const nativeThumbImage = shouldPassNativeThumbImage(
203
+ hasStepMarker,
204
+ hasThumbImage,
205
+ )
180
206
  ? thumbImage
181
207
  : undefined;
182
208
 
@@ -189,9 +215,16 @@ export function createSlider(platform: ISliderPlatform): ISliderComponent {
189
215
  upperLimit: upper,
190
216
  disabled: resolveSliderDisabled(disabled, accessibilityState),
191
217
  inverted: inverted ?? false,
192
- thumbTintColor: resolveThumbTintColor(thumbTintColor, hasStepMarker, hasThumbImage),
218
+ thumbTintColor: resolveThumbTintColor(
219
+ thumbTintColor,
220
+ hasStepMarker,
221
+ hasThumbImage,
222
+ ),
193
223
  thumbImage: nativeThumbImage,
194
- accessibilityState: resolveSliderAccessibilityState(disabled, accessibilityState),
224
+ accessibilityState: resolveSliderAccessibilityState(
225
+ disabled,
226
+ accessibilityState,
227
+ ),
195
228
  width,
196
229
  style,
197
230
  passthrough: {
@@ -206,10 +239,18 @@ export function createSlider(platform: ISliderPlatform): ISliderComponent {
206
239
  };
207
240
 
208
241
  if (!showSteps) {
209
- return withClassName(renderSlider(view, platform, { onLayout: handleLayout }), className);
242
+ return withClassName(
243
+ renderSlider(view, platform, { onLayout: handleLayout }),
244
+ className,
245
+ );
210
246
  }
211
247
 
212
- const options = computeStepOptions(minimum, maximum, stepValue, platform.stepResolution);
248
+ const options = computeStepOptions(
249
+ minimum,
250
+ maximum,
251
+ stepValue,
252
+ platform.stepResolution,
253
+ );
213
254
  const currentValue = reportedValue ?? view.value ?? minimum;
214
255
 
215
256
  if (StepMarker !== undefined) {
@@ -225,7 +266,11 @@ export function createSlider(platform: ISliderPlatform): ISliderComponent {
225
266
  });
226
267
  return createElement(
227
268
  'symbiote-view',
228
- { style: resolveStepsWrapperStyle(style, platform), onLayout: handleLayout, className },
269
+ {
270
+ style: resolveStepsWrapperStyle(style, platform),
271
+ onLayout: handleLayout,
272
+ className,
273
+ },
229
274
  overlay,
230
275
  descriptorToReact(renderSliderNative(view, platform)),
231
276
  );
@@ -248,7 +293,10 @@ export function createSlider(platform: ISliderPlatform): ISliderComponent {
248
293
  }
249
294
 
250
295
  // The wrapper style for the custom-marker steps path mirrors renderSlider's wrapper.
251
- function resolveStepsWrapperStyle(style: unknown, platform: ISliderPlatform): unknown {
296
+ function resolveStepsWrapperStyle(
297
+ style: unknown,
298
+ platform: ISliderPlatform,
299
+ ): unknown {
252
300
  return [platform.defaultStyle, style, { justifyContent: 'center' }];
253
301
  }
254
302
 
@@ -291,7 +339,10 @@ function renderCustomStepsOverlay(params: ICustomStepsParams): ReactElement {
291
339
  style: THUMB_IMAGE_CONTAINER_STYLE,
292
340
  testID: 'sliderTrackMark-thumbImage',
293
341
  },
294
- createElement(Image, { source: params.thumbImage, style: THUMB_IMAGE_STYLE }),
342
+ createElement(Image, {
343
+ source: params.thumbImage,
344
+ style: THUMB_IMAGE_STYLE,
345
+ }),
295
346
  ),
296
347
  );
297
348
  }
@@ -7,7 +7,11 @@
7
7
  // barrel imports it; the component modules and their headless tests stay free of the spec.
8
8
 
9
9
  import '@react-native-community/slider/dist/RNCSliderNativeComponent';
10
- import { processColor, registerComponent, type IColorValue } from '@symbiote-native/engine';
10
+ import {
11
+ processColor,
12
+ registerComponent,
13
+ type IColorValue,
14
+ } from '@symbiote-native/engine';
11
15
  import {
12
16
  RNC_SLIDER_VIEW_NAME,
13
17
  SLIDER_ON_CHANGE,
@@ -33,7 +37,10 @@ function processSliderColor(value: unknown): unknown {
33
37
  registerComponent(RNC_SLIDER_VIEW_NAME, {
34
38
  events: [
35
39
  { raw: 'topChange', listener: listenerName(SLIDER_ON_CHANGE) },
36
- { raw: 'topRNCSliderValueChange', listener: listenerName(SLIDER_ON_VALUE_CHANGE) },
40
+ {
41
+ raw: 'topRNCSliderValueChange',
42
+ listener: listenerName(SLIDER_ON_VALUE_CHANGE),
43
+ },
37
44
  {
38
45
  raw: 'topRNCSliderSlidingStart',
39
46
  listener: listenerName(SLIDER_ON_SLIDING_START),
@@ -0,0 +1,12 @@
1
+ // @symbiote-native/slider/solid: the Solid wrapper over the @react-native-community/slider native
2
+ // view. The bare import below is FIRST and is a side effect, not a re-export: it registers the
3
+ // native view's ViewConfig (the codegen spec, never the library's React component) before any
4
+ // Slider can mount. Metro's production-only `inlineRequires` moves a require down to the first
5
+ // place its binding is USED and compiles a barrel's re-export into a lazy getter, so a registration
6
+ // reached through one silently never runs in RELEASE builds only. Do not restructure it.
7
+
8
+ import '../register';
9
+
10
+ export { Slider } from './slider';
11
+ export type { ISliderProps, ISliderStepMarker } from './slider';
12
+ export type { IStepMarkerProps } from '../core';
@@ -0,0 +1,15 @@
1
+ // Slider on Android: the native view sizes itself (no default height), lays out implicit steps at
2
+ // 128-point resolution, and keeps the step row at the top. Mirrors the library's Android branches.
3
+
4
+ import { createSlider } from './shared';
5
+ import { SLIDER_STEP_RESOLUTION_ANDROID } from '../../core';
6
+
7
+ export type { ISliderProps, ISliderStepMarker } from './shared';
8
+
9
+ const ANDROID_STEPS_CONTAINER_TOP = 0;
10
+
11
+ export const Slider = createSlider({
12
+ defaultStyle: {},
13
+ stepResolution: SLIDER_STEP_RESOLUTION_ANDROID,
14
+ stepsContainerTop: ANDROID_STEPS_CONTAINER_TOP,
15
+ });
@@ -0,0 +1,19 @@
1
+ // Slider on iOS: the native view has an intrinsic 40pt height (the wrapper applies it as the
2
+ // default), lays out implicit steps at 1000-point resolution, and nudges the step row down 10pt.
3
+ // Also the base (./index re-exports it) for headless. Mirrors the library's iOS branches.
4
+
5
+ import { createSlider } from './shared';
6
+ import {
7
+ SLIDER_IOS_DEFAULT_HEIGHT,
8
+ SLIDER_STEP_RESOLUTION_IOS,
9
+ } from '../../core';
10
+
11
+ export type { ISliderProps, ISliderStepMarker } from './shared';
12
+
13
+ const IOS_STEPS_CONTAINER_TOP = 10;
14
+
15
+ export const Slider = createSlider({
16
+ defaultStyle: { height: SLIDER_IOS_DEFAULT_HEIGHT },
17
+ stepResolution: SLIDER_STEP_RESOLUTION_IOS,
18
+ stepsContainerTop: IOS_STEPS_CONTAINER_TOP,
19
+ });
@@ -0,0 +1,5 @@
1
+ // Base / default Slider: re-exports the iOS build. Metro overrides this with index.ios.ts /
2
+ // index.android.ts on a real host; under vitest / tsc the resolution lands here. Filename is the
3
+ // selector, no Platform.OS read — the same convention adapters/solid's own Switch follows.
4
+
5
+ export * from './index.ios';