@bloomreach/react-banana-ui 1.36.0 → 1.38.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 (45) hide show
  1. package/dist/bloomreach-react-banana-ui.es.js +11282 -9409
  2. package/dist/bloomreach-react-banana-ui.es.js.map +1 -1
  3. package/dist/bloomreach-react-banana-ui.umd.js +19 -19
  4. package/dist/bloomreach-react-banana-ui.umd.js.map +1 -1
  5. package/dist/components/inputs/autocomplete/autocomplete.stories.d.ts +10 -0
  6. package/dist/components/inputs/autocomplete/autocomplete.types.d.ts +36 -0
  7. package/dist/components/inputs/field-label/field-label.types.d.ts +2 -2
  8. package/dist/components/inputs/index.d.ts +1 -0
  9. package/dist/components/inputs/internal.d.ts +1 -0
  10. package/dist/components/inputs/slider/index.d.ts +4 -0
  11. package/dist/components/inputs/slider/internal/components/index.d.ts +4 -0
  12. package/dist/components/inputs/slider/internal/components/slider-mark-list.d.ts +20 -0
  13. package/dist/components/inputs/slider/internal/components/slider-number-input.d.ts +32 -0
  14. package/dist/components/inputs/slider/internal/components/slider-thumb.d.ts +31 -0
  15. package/dist/components/inputs/slider/internal/components/slider-tickmarks.d.ts +13 -0
  16. package/dist/components/inputs/slider/internal/hooks/index.d.ts +5 -0
  17. package/dist/components/inputs/slider/internal/hooks/use-slider-base.d.ts +18 -0
  18. package/dist/components/inputs/slider/internal/hooks/use-slider-hidden-input-props.d.ts +47 -0
  19. package/dist/components/inputs/slider/internal/hooks/use-slider-marks.d.ts +14 -0
  20. package/dist/components/inputs/slider/internal/hooks/use-slider-pointer-interaction.d.ts +47 -0
  21. package/dist/components/inputs/slider/internal/hooks/use-slider.d.ts +17 -0
  22. package/dist/components/inputs/slider/internal/index.d.ts +4 -0
  23. package/dist/components/inputs/slider/internal/types/index.d.ts +2 -0
  24. package/dist/components/inputs/slider/internal/types/slider.internal-types.d.ts +97 -0
  25. package/dist/components/inputs/slider/internal/utils/index.d.ts +2 -0
  26. package/dist/components/inputs/slider/internal/utils/slider.helpers.d.ts +227 -0
  27. package/dist/components/inputs/slider/internal/utils/slider.utils.d.ts +190 -0
  28. package/dist/components/inputs/slider/slider/index.d.ts +2 -0
  29. package/dist/components/inputs/slider/slider/slider.d.ts +17 -0
  30. package/dist/components/inputs/slider/slider/slider.qa.stories.d.ts +27 -0
  31. package/dist/components/inputs/slider/slider/slider.stories.d.ts +33 -0
  32. package/dist/components/inputs/slider/slider/slider.types.d.ts +229 -0
  33. package/dist/components/inputs/slider/slider-field/index.d.ts +2 -0
  34. package/dist/components/inputs/slider/slider-field/slider-field.d.ts +27 -0
  35. package/dist/components/inputs/slider/slider-field/slider-field.qa.stories.d.ts +18 -0
  36. package/dist/components/inputs/slider/slider-field/slider-field.stories.d.ts +15 -0
  37. package/dist/components/inputs/slider/slider-field/slider-field.types.d.ts +24 -0
  38. package/dist/react-banana-ui.css +1 -1
  39. package/dist/utils/dom.d.ts +7 -0
  40. package/dist/utils/hooks/index.d.ts +2 -0
  41. package/dist/utils/hooks/use-event-callback.d.ts +6 -0
  42. package/dist/utils/hooks/use-fork-refs.d.ts +7 -0
  43. package/dist/utils/index.d.ts +1 -0
  44. package/dist/utils/types/styles.types.d.ts +1 -1
  45. package/package.json +44 -43
@@ -6,12 +6,22 @@ export default meta;
6
6
  export type Story<Value extends NonNullable<unknown> = string, Multiple extends boolean = false, FreeSolo extends boolean = false> = StoryObj<typeof Autocomplete<Value, Multiple, FreeSolo>>;
7
7
  declare const fruits: string[];
8
8
  export declare const Basic: Story;
9
+ export declare const CustomWidth: Story;
9
10
  export declare const AutoSelect: Story;
10
11
  export declare const AutoSelectFreeSoloMultiple: Story<string, true, true>;
11
12
  export declare const DefaultValue: Story;
12
13
  export declare const ControlledSingleValue: Story;
13
14
  export declare const Multiple: Story<(typeof fruits)[0], true>;
15
+ export declare const SelectAll: Story<(typeof fruits)[0], true>;
16
+ export declare const SelectAllWithDisabledOptions: Story<{
17
+ id: number;
18
+ label: string;
19
+ }, true>;
14
20
  export declare const DefaultValueMultiple: Story<(typeof fruits)[0], true>;
21
+ export declare const LimitTags: Story<(typeof fruits)[0], true>;
22
+ export declare const LimitTagsCustomText: Story<(typeof fruits)[0], true>;
23
+ export declare const MaxRows: Story<(typeof fruits)[0], true>;
24
+ export declare const LimitTagsWithMaxRows: Story<(typeof fruits)[0], true>;
15
25
  export declare const ControlledMultipleValue: Story<(typeof fruits)[0], true>;
16
26
  export declare const Disabled: Story;
17
27
  export declare const DisabledMultiple: Story<(typeof fruits)[0], true>;
@@ -49,6 +49,13 @@ export interface AutocompleteProps<AutocompleteOption extends NonNullable<unknow
49
49
  * If `true`, the Autocomplete is free solo, meaning that the user input is not bound to provided options.
50
50
  */
51
51
  freeSolo?: FreeSolo;
52
+ /**
53
+ * Customize the overflow text shown when tags are truncated by `limitTags`.
54
+ * @param more The number of hidden tags
55
+ * @returns Content to render as the overflow indicator
56
+ * @default (more) => `+${more}`
57
+ */
58
+ getLimitTagsText?: (more: number) => ReactNode;
52
59
  /**
53
60
  * Used to determine if an option is disabled.
54
61
  */
@@ -81,6 +88,12 @@ export interface AutocompleteProps<AutocompleteOption extends NonNullable<unknow
81
88
  * Icon or any element displayed at the start of the input.
82
89
  */
83
90
  leftElement?: ReactNode;
91
+ /**
92
+ * The maximum number of tags visible when the popup is closed.
93
+ * Set to `-1` to show all tags. Only works when `multiple` is `true`.
94
+ * @default -1
95
+ */
96
+ limitTags?: number;
84
97
  /**
85
98
  * If `true`, the component is in a loading state.
86
99
  * @default false
@@ -91,6 +104,11 @@ export interface AutocompleteProps<AutocompleteOption extends NonNullable<unknow
91
104
  * @default "Loading..."
92
105
  */
93
106
  loadingText?: string;
107
+ /**
108
+ * The maximum number of visible tag rows before the tag area becomes scrollable while the popup is closed.
109
+ * Only works when `multiple` is `true`.
110
+ */
111
+ maxRows?: number;
94
112
  /**
95
113
  * If `true`, the component allows multiple selections.
96
114
  * @default false
@@ -179,12 +197,30 @@ export interface AutocompleteProps<AutocompleteOption extends NonNullable<unknow
179
197
  * Icon or any element displayed at the end of the input, before the clear button and chevron.
180
198
  */
181
199
  rightElement?: ReactNode;
200
+ /**
201
+ * If `true`, a "Select all" checkbox is shown at the top of the listbox
202
+ * that toggles all currently visible (filtered) enabled options.
203
+ * Only works when `multiple` is `true`.
204
+ * @default false
205
+ */
206
+ selectAll?: boolean;
207
+ /**
208
+ * The label for the select all checkbox.
209
+ * Only applicable when both `selectAll` and `multiple` are `true`.
210
+ * @default "Select all"
211
+ */
212
+ selectAllLabel?: string;
182
213
  /**
183
214
  * The selected value.
184
215
  * Set to `null` in case of single select and `[]` in case of multiple select to clear the selection.
185
216
  * If the value is an object it must have reference equality with the option in order to be selected.
186
217
  */
187
218
  value?: AutocompleteValue<AutocompleteOption, Multiple, FreeSolo>;
219
+ /**
220
+ * The width of the autocomplete input. Accepts any valid CSS width value.
221
+ * @example '100%', '400px', 'auto'
222
+ */
223
+ width?: number | string;
188
224
  }
189
225
  export interface AutocompleteRenderGroupParams extends AutocompleteGroupedOption<object> {
190
226
  children: ReactNode;
@@ -1,5 +1,5 @@
1
- import { ReactNode } from 'react';
2
- export interface FieldLabelProps {
1
+ import { HTMLAttributes, ReactNode } from 'react';
2
+ export interface FieldLabelProps extends HTMLAttributes<HTMLLabelElement> {
3
3
  /**
4
4
  * The content of the component.
5
5
  */
@@ -9,5 +9,6 @@ export * from './radio-field';
9
9
  export * from './radio-group';
10
10
  export * from './select-field';
11
11
  export * from './select-option';
12
+ export * from './slider';
12
13
  export * from './text-field';
13
14
  export * from './toggle-field';
@@ -4,4 +4,5 @@ export * from './base-input';
4
4
  export * from './checkbox';
5
5
  export * from './field-label';
6
6
  export * from './select';
7
+ export * from './slider';
7
8
  export * from './toggle';
@@ -0,0 +1,4 @@
1
+ export { default as Slider } from './slider';
2
+ export { default as SliderField } from './slider-field';
3
+ export type { SliderFieldProps } from './slider-field/slider-field.types';
4
+ export type { Mark, SliderChangeCommittedHandler, SliderChangeHandler, SliderNumberInputAttributes, SliderProps, SliderValue, } from './slider/slider.types';
@@ -0,0 +1,4 @@
1
+ export { SliderMarkList } from './slider-mark-list';
2
+ export { SliderNumberInput } from './slider-number-input';
3
+ export { SliderThumb } from './slider-thumb';
4
+ export { SliderTickmarks } from './slider-tickmarks';
@@ -0,0 +1,20 @@
1
+ import { ReactElement } from 'react';
2
+ import { Axis, AxisProps, Mark, SliderProps } from '../types';
3
+ interface SliderMarkListProps {
4
+ axis: Axis;
5
+ axisProps: AxisProps;
6
+ markLevels: number[];
7
+ markRenderKeys: string[];
8
+ marks: Mark[];
9
+ max: number;
10
+ min: number;
11
+ range: boolean;
12
+ track: SliderProps['track'];
13
+ trackLeap: number;
14
+ trackOffset: number;
15
+ }
16
+ export declare const SliderMarkList: {
17
+ ({ axis, axisProps, markLevels, markRenderKeys, marks, max, min, range, track, trackLeap, trackOffset, }: SliderMarkListProps): ReactElement;
18
+ displayName: string;
19
+ };
20
+ export {};
@@ -0,0 +1,32 @@
1
+ import { ChangeEvent, FocusEvent, KeyboardEvent, ReactElement } from 'react';
2
+ import { SliderNumberInputAttributes } from '../../slider/slider.types';
3
+ /** Props for the visible `<input type="number">` rendered when `withNumberInput` is enabled. */
4
+ export interface SliderNumberInputProps {
5
+ ariaLabel?: string;
6
+ ariaLabelledby?: string;
7
+ disabled?: boolean;
8
+ error?: boolean;
9
+ inputProps?: SliderNumberInputAttributes;
10
+ max: number;
11
+ min: number;
12
+ onBlur: (event: FocusEvent<HTMLInputElement>) => void;
13
+ onChange: (event: ChangeEvent<HTMLInputElement>) => void;
14
+ onKeyDown: (event: KeyboardEvent<HTMLInputElement>) => void;
15
+ readOnly?: boolean;
16
+ step: 'any' | number;
17
+ value: string;
18
+ }
19
+ /**
20
+ * A compact `<input type="number">` rendered alongside the slider when `withNumberInput`
21
+ * is enabled. Allows users to type an exact value instead of dragging.
22
+ *
23
+ * For range sliders, two instances are rendered (one per thumb). The input respects
24
+ * all slider constraints (min, max, step, marks, snap) via the parent's change handlers.
25
+ *
26
+ * Merges any user-provided `inputProps` (including custom `onBlur`/`onChange` handlers)
27
+ * with the slider's internal handlers.
28
+ */
29
+ export declare const SliderNumberInput: {
30
+ ({ ariaLabel, ariaLabelledby, disabled, error, inputProps, max, min, onBlur, onChange, onKeyDown, readOnly, step, value, }: SliderNumberInputProps): ReactElement;
31
+ displayName: string;
32
+ };
@@ -0,0 +1,31 @@
1
+ import { ReactElement } from 'react';
2
+ import { Axis, AxisProps, GetHiddenInputProps, GetThumbProps, SliderProps } from '../types';
3
+ import type * as React from 'react';
4
+ interface SliderThumbProps {
5
+ active: number;
6
+ ariaLabel?: string;
7
+ ariaLabelledby?: string;
8
+ ariaValuetext?: string;
9
+ axis: Axis;
10
+ axisProps: AxisProps;
11
+ focusedThumbIndex: number;
12
+ getAriaValueText?: (value: number, index: number) => string;
13
+ getHiddenInputProps: GetHiddenInputProps;
14
+ getThumbProps: GetThumbProps;
15
+ getThumbStyle: (index: number) => React.CSSProperties;
16
+ index: number;
17
+ max: number;
18
+ min: number;
19
+ open: number;
20
+ readOnly: boolean;
21
+ scale?: (value: number) => number;
22
+ value: number;
23
+ valueLabelDisplay: SliderProps['valueLabelDisplay'];
24
+ valueLabelFormat?: SliderProps['valueLabelFormat'];
25
+ values: number[];
26
+ }
27
+ export declare const SliderThumb: {
28
+ ({ active, ariaLabel, ariaLabelledby, ariaValuetext, axis, axisProps, focusedThumbIndex, getAriaValueText, getHiddenInputProps, getThumbProps, getThumbStyle, index, max, min, open, readOnly, scale, value, valueLabelDisplay, valueLabelFormat, values, }: SliderThumbProps): ReactElement;
29
+ displayName: string;
30
+ };
31
+ export {};
@@ -0,0 +1,13 @@
1
+ import { ReactElement } from 'react';
2
+ interface SliderTickmarksProps {
3
+ isActiveLayer: boolean;
4
+ tickmarkMeta: Array<{
5
+ isMajor: boolean;
6
+ percent: number;
7
+ }>;
8
+ }
9
+ export declare const SliderTickmarks: {
10
+ ({ isActiveLayer, tickmarkMeta }: SliderTickmarksProps): ReactElement;
11
+ displayName: string;
12
+ };
13
+ export {};
@@ -0,0 +1,5 @@
1
+ export { default as useSlider } from './use-slider';
2
+ export { default as useSliderBase } from './use-slider-base';
3
+ export { default as useSliderHiddenInputProps } from './use-slider-hidden-input-props';
4
+ export { useSliderMarks } from './use-slider-marks';
5
+ export { default as useSliderPointerInteraction } from './use-slider-pointer-interaction';
@@ -0,0 +1,18 @@
1
+ import { UseSliderBaseParameters, UseSliderBaseReturnValue } from '../types';
2
+ /**
3
+ * Core slider hook that manages all fundamental slider behavior:
4
+ * - **Controlled/uncontrolled state** via `useControlledValue`.
5
+ * - **Pointer interactions** (mouse/touch drag) via `useSliderPointerInteraction`.
6
+ * - **Keyboard navigation** via `useSliderHiddenInputProps`.
7
+ * - **Track position** calculation (`trackOffset` and `trackLeap`).
8
+ * - **Mark generation** from the `marks` prop.
9
+ * - **Thumb focus and hover** state tracking.
10
+ *
11
+ * This hook does NOT handle snap-to-marks, center-track, or number input logic —
12
+ * those are layered on top by `useSlider`.
13
+ *
14
+ * @param parameters - Base slider configuration.
15
+ * @returns State values, prop getter functions, and refs for building the slider UI.
16
+ */
17
+ declare const useSliderBase: (parameters: UseSliderBaseParameters) => UseSliderBaseReturnValue;
18
+ export default useSliderBase;
@@ -0,0 +1,47 @@
1
+ import { GetHiddenInputProps, Mark, SliderValue } from '../types';
2
+ import type * as React from 'react';
3
+ interface UseSliderHiddenInputPropsParameters {
4
+ ariaLabelledby?: string;
5
+ disabled: boolean;
6
+ disableSwap: boolean;
7
+ handleChange?: (event: Event | React.SyntheticEvent, value: SliderValue, activeThumb: number) => void;
8
+ isRtl: boolean;
9
+ marks: Mark[];
10
+ marksValues: number[];
11
+ max: number;
12
+ min: number;
13
+ minDistance: number;
14
+ name?: string;
15
+ onChangeCommitted?: (event: Event | React.SyntheticEvent, value: SliderValue) => void;
16
+ orientation: 'horizontal' | 'vertical';
17
+ range: boolean;
18
+ readOnly: boolean;
19
+ resolveKeyboardValue?: (currentValue: number, nextValue: number) => number;
20
+ scale: (value: number) => number;
21
+ setFocusedThumbIndex: (index: number) => void;
22
+ setOpen: (index: number) => void;
23
+ setValueState: (value: SliderValue) => void;
24
+ shiftStep: number;
25
+ sliderRef: React.RefObject<HTMLSpanElement | null>;
26
+ step: null | number;
27
+ tabIndex?: number;
28
+ valueDerived: SliderValue;
29
+ values: number[];
30
+ }
31
+ /**
32
+ * Builds the props getter for the hidden `<input type="range">` elements that
33
+ * provide native keyboard accessibility for each slider thumb.
34
+ *
35
+ * Each thumb renders a visually hidden range input. This hook handles:
36
+ * - **Arrow key navigation** with `step` and `shiftStep` increments.
37
+ * - **Page Up/Down** for large jumps.
38
+ * - **Mark-only mode** (`step === null`) — arrow keys jump between marks.
39
+ * - **RTL support** — reverses left/right arrow directions.
40
+ * - **Range constraints** — enforces `minDistance` and `disableSwap` on keyboard moves.
41
+ * - **Focus tracking** — updates `focusedThumbIndex` and `open` state for value labels.
42
+ *
43
+ * @returns A `getHiddenInputProps` function that merges external props with the
44
+ * generated accessibility and event handler props.
45
+ */
46
+ declare const useSliderHiddenInputProps: ({ ariaLabelledby, disabled, disableSwap, handleChange, isRtl, marks, marksValues, max, min, minDistance, name, onChangeCommitted, orientation, range, readOnly, resolveKeyboardValue, scale, setFocusedThumbIndex, setOpen, setValueState, shiftStep, sliderRef, step, tabIndex, valueDerived, values, }: UseSliderHiddenInputPropsParameters) => GetHiddenInputProps;
47
+ export default useSliderHiddenInputProps;
@@ -0,0 +1,14 @@
1
+ import { Mark, SliderProps } from '../types';
2
+ interface UseSliderMarksParams {
3
+ marks: Mark[];
4
+ max: number;
5
+ min: number;
6
+ orientation: SliderProps['orientation'];
7
+ }
8
+ interface UseSliderMarksResult {
9
+ hasStaggeredLabels: boolean;
10
+ markLevels: number[];
11
+ markRenderKeys: string[];
12
+ }
13
+ export declare const useSliderMarks: ({ marks, max, min, orientation }: UseSliderMarksParams) => UseSliderMarksResult;
14
+ export default useSliderMarks;
@@ -0,0 +1,47 @@
1
+ import { EventHandlers } from '../../../../../utils/dom';
2
+ import { Axis, Mark, SliderValue } from '../types';
3
+ import type * as React from 'react';
4
+ interface UseSliderPointerInteractionParameters {
5
+ axis: Axis;
6
+ disabled: boolean;
7
+ disableSwap: boolean;
8
+ handleChange?: (event: Event | React.SyntheticEvent, value: SliderValue, activeThumb: number) => void;
9
+ marks: Mark[];
10
+ marksValues: number[];
11
+ max: number;
12
+ min: number;
13
+ minDistance: number;
14
+ onChangeCommitted?: (event: Event | React.SyntheticEvent, value: SliderValue) => void;
15
+ range: boolean;
16
+ readOnly: boolean;
17
+ setActive: (index: number) => void;
18
+ setDragging: (value: boolean) => void;
19
+ setOpen: (index: number) => void;
20
+ setValueState: (value: SliderValue) => void;
21
+ sliderRef: React.RefObject<HTMLSpanElement | null>;
22
+ step: null | number;
23
+ valueDerived: SliderValue;
24
+ values: number[];
25
+ }
26
+ interface UseSliderPointerInteractionResult {
27
+ createHandleMouseDown: (otherHandlers: EventHandlers) => (event: React.MouseEvent<HTMLSpanElement>) => void;
28
+ }
29
+ /**
30
+ * Manages mouse and touch pointer interactions for the slider.
31
+ *
32
+ * Handles the full drag lifecycle:
33
+ * 1. **Pointer down** (mousedown/touchstart) — determines the clicked position,
34
+ * finds the closest thumb, jumps it to the pointer, and starts listening for moves.
35
+ * 2. **Pointer move** (mousemove/touchmove) — tracks the finger position, updates
36
+ * the thumb value in real-time, and triggers the dragging visual state after
37
+ * `INTENTIONAL_DRAG_COUNT_THRESHOLD` moves.
38
+ * 3. **Pointer up** (mouseup/touchend) — commits the final value and cleans up listeners.
39
+ *
40
+ * Touch events are attached directly to the slider DOM element (not via React)
41
+ * to control `passive` behavior for scroll prevention.
42
+ *
43
+ * @returns `createHandleMouseDown` — a factory that produces the `onMouseDown` handler
44
+ * for the slider root, composable with external event handlers.
45
+ */
46
+ declare const useSliderPointerInteraction: ({ axis, disabled, disableSwap, handleChange, marks, marksValues, max, min, minDistance, onChangeCommitted, range, readOnly, setActive, setDragging, setOpen, setValueState, sliderRef, step, valueDerived, values, }: UseSliderPointerInteractionParameters) => UseSliderPointerInteractionResult;
47
+ export default useSliderPointerInteraction;
@@ -0,0 +1,17 @@
1
+ import { UseSliderParameters, UseSliderReturnValue } from '../types';
2
+ /**
3
+ * Primary hook for the Slider component. Wraps `useSliderBase` and adds:
4
+ * - **Snap-to-marks** — magnetically snaps thumb values to nearby marks during
5
+ * pointer drag, keyboard navigation, and number input entry.
6
+ * - **Track metrics** — recomputes `trackOffset`/`trackLeap` for `center` track
7
+ * mode and snap-adjusted values.
8
+ * - **Number input handling** — keeps visible number inputs in a transient text
9
+ * state while the user types, then commits normalized values on blur or Enter.
10
+ * - **Read-only enforcement** — blocks hidden input changes in read-only mode
11
+ * by intercepting `onChangeCapture` and `onKeyDownCapture`.
12
+ *
13
+ * @param parameters - Slider configuration (extends `UseSliderBaseParameters`).
14
+ * @returns State, props getters, and handlers needed by the `Slider` component.
15
+ */
16
+ export declare const useSlider: (parameters: UseSliderParameters) => UseSliderReturnValue;
17
+ export default useSlider;
@@ -0,0 +1,4 @@
1
+ export * from './components';
2
+ export * from './hooks';
3
+ export * from './types';
4
+ export * from './utils';
@@ -0,0 +1,2 @@
1
+ export type { Mark, SliderProps, SliderValue } from '../../slider/slider.types';
2
+ export type { Axis, AxisConfig, AxisProps, EmptyProps, GetHiddenInputProps, GetRootProps, GetThumbProps, UseSliderBaseParameters, UseSliderBaseReturnValue, UseSliderHiddenInputProps, UseSliderParameters, UseSliderReturnValue, UseSliderRootSlotProps, UseSliderThumbSlotProps, } from './slider.internal-types';
@@ -0,0 +1,97 @@
1
+ import { Mark, SliderProps, SliderValue } from '../../slider/slider.types';
2
+ import type * as React from 'react';
3
+ /** The resolved axis direction for CSS positioning. RTL horizontal layout uses `horizontal-reverse`. */
4
+ export type Axis = 'horizontal' | 'horizontal-reverse' | 'vertical';
5
+ /** CSS property generators for positioning and sizing elements along a single axis. */
6
+ export interface AxisConfig {
7
+ /** Returns CSS properties for setting the track/thumb length (e.g. `{ width }` or `{ height }`). */
8
+ leap: (percent: number) => React.CSSProperties;
9
+ /** Returns CSS properties for setting the track/thumb position (e.g. `{ left }` or `{ bottom }`). */
10
+ offset: (percent: number) => React.CSSProperties;
11
+ }
12
+ /** Maps each axis direction to its CSS positioning/sizing configuration. */
13
+ export type AxisProps = Record<Axis, AxisConfig>;
14
+ /** An empty props object type, used as the default for generic prop getter type parameters. */
15
+ export type EmptyProps = Record<string, never>;
16
+ type SlotExternalProps<ExternalProps extends Record<string, unknown>> = Omit<ExternalProps, 'children' | 'key'>;
17
+ export type UseSliderRootSlotProps<ExternalProps extends Record<string, unknown> = EmptyProps> = Omit<React.HTMLAttributes<HTMLSpanElement>, 'children'> & SlotExternalProps<ExternalProps> & {
18
+ ref?: null | React.RefCallback<Element>;
19
+ };
20
+ export type UseSliderThumbSlotProps<ExternalProps extends Record<string, unknown> = EmptyProps> = Omit<React.HTMLAttributes<HTMLSpanElement>, 'children'> & SlotExternalProps<ExternalProps>;
21
+ export type UseSliderHiddenInputProps<ExternalProps extends Record<string, unknown> = EmptyProps> = ExternalProps & React.InputHTMLAttributes<HTMLInputElement>;
22
+ /** Props getter for the visually hidden `<input type="range">` per thumb. */
23
+ export type GetHiddenInputProps = <ExternalProps extends Record<string, unknown> = EmptyProps>(externalProps?: ExternalProps) => UseSliderHiddenInputProps<ExternalProps>;
24
+ /** Props getter for the slider root `<span>` element. */
25
+ export type GetRootProps = <ExternalProps extends Record<string, unknown> = EmptyProps>(externalProps?: ExternalProps) => UseSliderRootSlotProps<ExternalProps>;
26
+ /** Props getter for each thumb `<span>` wrapper element. */
27
+ export type GetThumbProps = <ExternalProps extends Record<string, unknown> = EmptyProps>(externalProps?: ExternalProps) => UseSliderThumbSlotProps<ExternalProps>;
28
+ /**
29
+ * Optional transform applied to keyboard-driven value changes before they are committed.
30
+ * Used by snap-to-marks to override the raw step-based value with a snapped value.
31
+ */
32
+ export type ResolveKeyboardValue = (currentValue: number, nextValue: number) => number;
33
+ /** Parameters for the `useSliderBase` hook — the foundation of all slider behavior. */
34
+ export interface UseSliderBaseParameters {
35
+ 'aria-labelledby'?: string;
36
+ defaultValue?: SliderValue;
37
+ disabled?: boolean;
38
+ disableSwap?: boolean;
39
+ isRtl?: boolean;
40
+ marks?: boolean | ReadonlyArray<Mark>;
41
+ max?: number;
42
+ min?: number;
43
+ minDistance?: number;
44
+ name?: string;
45
+ onChange?: (event: Event, value: SliderValue, activeThumb: number) => void;
46
+ onChangeCommitted?: (event: Event | React.SyntheticEvent, value: SliderValue) => void;
47
+ orientation?: 'horizontal' | 'vertical';
48
+ readOnly?: boolean;
49
+ resolveKeyboardValue?: ResolveKeyboardValue;
50
+ rootRef?: React.Ref<Element>;
51
+ scale?: (value: number) => number;
52
+ shiftStep?: number;
53
+ step?: null | number;
54
+ tabIndex?: number;
55
+ value?: SliderValue;
56
+ }
57
+ /** Return value from `useSliderBase` — provides all state and prop getters for the slider. */
58
+ export interface UseSliderBaseReturnValue {
59
+ active: number;
60
+ axis: Axis;
61
+ axisProps: AxisProps;
62
+ dragging: boolean;
63
+ focusedThumbIndex: number;
64
+ getHiddenInputProps: GetHiddenInputProps;
65
+ getRootProps: GetRootProps;
66
+ getThumbProps: GetThumbProps;
67
+ getThumbStyle: (index: number) => React.CSSProperties;
68
+ marks: Mark[];
69
+ open: number;
70
+ range: boolean;
71
+ rootRef: null | React.RefCallback<Element>;
72
+ setValueState: (value: SliderValue) => void;
73
+ trackLeap: number;
74
+ trackOffset: number;
75
+ values: number[];
76
+ }
77
+ /** Parameters for `useSlider` — extends base parameters with snap, track mode, and input features. */
78
+ export interface UseSliderParameters extends UseSliderBaseParameters {
79
+ snapToMarks?: SliderProps['snapToMarks'];
80
+ track?: SliderProps['track'];
81
+ withNumberInput?: boolean;
82
+ }
83
+ /** Return value from `useSlider` — extends the base return with snap, number input, and track metrics. */
84
+ export type UseSliderReturnValue = Omit<UseSliderBaseReturnValue, 'getHiddenInputProps' | 'trackLeap' | 'trackOffset'> & {
85
+ customMarks?: Mark[];
86
+ getHiddenInputProps: GetHiddenInputProps;
87
+ handleNumberInputBlur: (event: React.FocusEvent<HTMLInputElement>, thumbIndex: number) => void;
88
+ handleNumberInputChange: (event: React.ChangeEvent<HTMLInputElement>, thumbIndex: number) => void;
89
+ handleNumberInputKeyDown: (event: React.KeyboardEvent<HTMLInputElement>, thumbIndex: number) => void;
90
+ inputValues: string[];
91
+ renderValues: number[];
92
+ resolvedStep: null | number;
93
+ resolvedTrack: SliderProps['track'];
94
+ trackLeap: number;
95
+ trackOffset: number;
96
+ };
97
+ export {};
@@ -0,0 +1,2 @@
1
+ export * from './slider.helpers';
2
+ export * from './slider.utils';