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