1 | import { Simplify } from '@mui/types';
|
2 | import * as React from 'react';
|
3 | import { PolymorphicProps, SlotComponentProps, SlotComponentPropsWithSlotState } from '../utils';
|
4 | import { UseSliderHiddenInputProps, UseSliderParameters, UseSliderRootSlotProps, UseSliderThumbSlotProps } from '../useSlider';
|
5 | export type SliderOwnerState = Simplify<SliderOwnProps & {
|
6 | disabled: boolean;
|
7 | focusedThumbIndex: number;
|
8 | activeThumbIndex: number;
|
9 | isRtl: boolean;
|
10 | max: number;
|
11 | min: number;
|
12 | dragging: boolean;
|
13 | marked: boolean;
|
14 | orientation: 'horizontal' | 'vertical';
|
15 | scale: (value: number) => number;
|
16 | step: number | null;
|
17 | track: 'normal' | false | 'inverted';
|
18 | valueLabelFormat: string | ((value: number, index: number) => React.ReactNode);
|
19 | }>;
|
20 | export interface SliderRootSlotPropsOverrides {
|
21 | }
|
22 | export interface SliderTrackSlotPropsOverrides {
|
23 | }
|
24 | export interface SliderRailSlotPropsOverrides {
|
25 | }
|
26 | export interface SliderThumbSlotPropsOverrides {
|
27 | }
|
28 | export interface SliderMarkSlotPropsOverrides {
|
29 | }
|
30 | export interface SliderMarkLabelSlotPropsOverrides {
|
31 | }
|
32 | export interface SliderValueLabelSlotPropsOverrides {
|
33 | }
|
34 | export interface SliderInputSlotPropsOverrides {
|
35 | }
|
36 | export interface SliderThumbSlotState {
|
37 | focused: boolean;
|
38 | active: boolean;
|
39 | index: number;
|
40 | }
|
41 | export interface SliderOwnProps extends Omit<UseSliderParameters, 'ref'> {
|
42 | /**
|
43 | * The label of the slider.
|
44 | */
|
45 | 'aria-label'?: string;
|
46 | /**
|
47 | * A string value that provides a user-friendly name for the current value of the slider.
|
48 | */
|
49 | 'aria-valuetext'?: string;
|
50 | /**
|
51 | * Accepts a function which returns a string value that provides a user-friendly name for the thumb labels of the slider.
|
52 | * This is important for screen reader users.
|
53 | * @param {number} index The thumb label's index to format.
|
54 | * @returns {string}
|
55 | */
|
56 | getAriaLabel?: (index: number) => string;
|
57 | |
58 |
|
59 |
|
60 |
|
61 |
|
62 |
|
63 |
|
64 | getAriaValueText?: (value: number, index: number) => string;
|
65 | |
66 |
|
67 |
|
68 |
|
69 | slotProps?: {
|
70 | root?: SlotComponentProps<'span', SliderRootSlotPropsOverrides, SliderOwnerState>;
|
71 | track?: SlotComponentProps<'span', SliderTrackSlotPropsOverrides, SliderOwnerState>;
|
72 | rail?: SlotComponentProps<'span', SliderRailSlotPropsOverrides, SliderOwnerState>;
|
73 | thumb?: SlotComponentPropsWithSlotState<'span', SliderThumbSlotPropsOverrides, SliderOwnerState, SliderThumbSlotState>;
|
74 | mark?: SlotComponentProps<'span', SliderMarkSlotPropsOverrides, SliderOwnerState>;
|
75 | markLabel?: SlotComponentProps<'span', SliderMarkLabelSlotPropsOverrides, SliderOwnerState>;
|
76 | valueLabel?: SlotComponentProps<React.ElementType, SliderValueLabelSlotPropsOverrides, SliderOwnerState>;
|
77 | input?: SlotComponentProps<'input', SliderInputSlotPropsOverrides, SliderOwnerState>;
|
78 | };
|
79 | |
80 |
|
81 |
|
82 |
|
83 |
|
84 | slots?: SliderSlots;
|
85 | |
86 |
|
87 |
|
88 |
|
89 |
|
90 |
|
91 |
|
92 |
|
93 | track?: 'normal' | false | 'inverted';
|
94 | |
95 |
|
96 |
|
97 |
|
98 |
|
99 |
|
100 |
|
101 |
|
102 |
|
103 |
|
104 |
|
105 |
|
106 |
|
107 | valueLabelFormat?: string | ((value: number, index: number) => React.ReactNode);
|
108 | }
|
109 | export interface SliderSlots {
|
110 | /**
|
111 | * The component that renders the root.
|
112 | * @default 'span'
|
113 | */
|
114 | root?: React.ElementType;
|
115 | /**
|
116 | * The component that renders the track.
|
117 | * @default 'span'
|
118 | */
|
119 | track?: React.ElementType;
|
120 | /**
|
121 | * The component that renders the rail.
|
122 | * @default 'span'
|
123 | */
|
124 | rail?: React.ElementType;
|
125 | /**
|
126 | * The component that renders the thumb.
|
127 | * @default 'span'
|
128 | */
|
129 | thumb?: React.ElementType;
|
130 | /**
|
131 | * The component that renders the mark.
|
132 | * @default 'span'
|
133 | */
|
134 | mark?: React.ElementType;
|
135 | /**
|
136 | * The component that renders the mark label.
|
137 | * @default 'span'
|
138 | */
|
139 | markLabel?: React.ElementType;
|
140 | /**
|
141 | * The component that renders the value label.
|
142 | */
|
143 | valueLabel?: React.ElementType;
|
144 | /**
|
145 | * The component that renders the input.
|
146 | * @default 'input'
|
147 | */
|
148 | input?: React.ElementType;
|
149 | }
|
150 | export interface SliderTypeMap<AdditionalProps = {}, RootComponentType extends React.ElementType = 'span'> {
|
151 | props: SliderOwnProps & AdditionalProps;
|
152 | defaultComponent: RootComponentType;
|
153 | }
|
154 | export type SliderProps<RootComponentType extends React.ElementType = SliderTypeMap['defaultComponent']> = PolymorphicProps<SliderTypeMap<{}, RootComponentType>, RootComponentType>;
|
155 | export type SliderRootSlotProps = UseSliderRootSlotProps & {
|
156 | children: React.ReactNode;
|
157 | className: string;
|
158 | ownerState: SliderOwnerState;
|
159 | };
|
160 | export type SliderTrackSlotProps = {
|
161 | className?: string;
|
162 | ownerState: SliderOwnerState;
|
163 | style: React.CSSProperties;
|
164 | };
|
165 | export type SliderRailSlotProps = {
|
166 | className?: string;
|
167 | ownerState: SliderOwnerState;
|
168 | };
|
169 | export type SliderThumbSlotProps = UseSliderThumbSlotProps & {
|
170 | 'data-index': number;
|
171 | children: React.ReactNode;
|
172 | className?: string;
|
173 | ownerState: SliderOwnerState;
|
174 | style: React.CSSProperties;
|
175 | };
|
176 | export type SliderMarkSlotProps = {
|
177 | 'data-index': number;
|
178 | className?: string;
|
179 | markActive?: boolean;
|
180 | ownerState: SliderOwnerState;
|
181 | style: React.CSSProperties;
|
182 | };
|
183 | export type SliderMarkLabelSlotProps = {
|
184 | 'aria-hidden': boolean;
|
185 | 'data-index': number;
|
186 | className?: string;
|
187 | markLabelActive?: boolean;
|
188 | ownerState: SliderOwnerState;
|
189 | style: React.CSSProperties;
|
190 | };
|
191 | export type SliderValueLabelSlotProps = {
|
192 | children: React.ReactNode;
|
193 | className?: string;
|
194 | disabled?: boolean;
|
195 | index?: number;
|
196 | open?: boolean;
|
197 | ownerState: SliderOwnerState;
|
198 | valueLabel?: string | React.ReactNode;
|
199 | valueLabelFormat?: string | ((value: number, index: number) => React.ReactNode);
|
200 | };
|
201 | export type SliderInputSlotProps = UseSliderHiddenInputProps & {
|
202 | 'aria-label': React.AriaAttributes['aria-label'];
|
203 | 'aria-valuenow': React.AriaAttributes['aria-valuenow'];
|
204 | 'aria-valuetext': React.AriaAttributes['aria-valuetext'];
|
205 | 'data-index': number;
|
206 | ownerState: SliderOwnerState;
|
207 | style: React.CSSProperties;
|
208 | value: number;
|
209 | };
|
210 |
|
\ | No newline at end of file |