UNPKG

33.6 kBJavaScriptView Raw
1'use client';
2
3import * as React from 'react';
4import PropTypes from 'prop-types';
5import clsx from 'clsx';
6import chainPropTypes from '@mui/utils/chainPropTypes';
7import composeClasses from '@mui/utils/composeClasses';
8import { alpha, lighten, darken } from '@mui/system/colorManipulator';
9import { useRtl } from '@mui/system/RtlProvider';
10import useSlotProps from '@mui/utils/useSlotProps';
11import { useSlider, valueToPercent } from "./useSlider.js";
12import isHostComponent from "../utils/isHostComponent.js";
13import { styled } from "../zero-styled/index.js";
14import memoTheme from "../utils/memoTheme.js";
15import { useDefaultProps } from "../DefaultPropsProvider/index.js";
16import slotShouldForwardProp from "../styles/slotShouldForwardProp.js";
17import shouldSpreadAdditionalProps from "../utils/shouldSpreadAdditionalProps.js";
18import capitalize from "../utils/capitalize.js";
19import createSimplePaletteValueFilter from "../utils/createSimplePaletteValueFilter.js";
20import BaseSliderValueLabel from "./SliderValueLabel.js";
21import sliderClasses, { getSliderUtilityClass } from "./sliderClasses.js";
22import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
23function Identity(x) {
24 return x;
25}
26export const SliderRoot = styled('span', {
27 name: 'MuiSlider',
28 slot: 'Root',
29 overridesResolver: (props, styles) => {
30 const {
31 ownerState
32 } = props;
33 return [styles.root, styles[`color${capitalize(ownerState.color)}`], ownerState.size !== 'medium' && styles[`size${capitalize(ownerState.size)}`], ownerState.marked && styles.marked, ownerState.orientation === 'vertical' && styles.vertical, ownerState.track === 'inverted' && styles.trackInverted, ownerState.track === false && styles.trackFalse];
34 }
35})(memoTheme(({
36 theme
37}) => ({
38 borderRadius: 12,
39 boxSizing: 'content-box',
40 display: 'inline-block',
41 position: 'relative',
42 cursor: 'pointer',
43 touchAction: 'none',
44 WebkitTapHighlightColor: 'transparent',
45 '@media print': {
46 colorAdjust: 'exact'
47 },
48 [`&.${sliderClasses.disabled}`]: {
49 pointerEvents: 'none',
50 cursor: 'default',
51 color: (theme.vars || theme).palette.grey[400]
52 },
53 [`&.${sliderClasses.dragging}`]: {
54 [`& .${sliderClasses.thumb}, & .${sliderClasses.track}`]: {
55 transition: 'none'
56 }
57 },
58 variants: [...Object.entries(theme.palette).filter(createSimplePaletteValueFilter()).map(([color]) => ({
59 props: {
60 color
61 },
62 style: {
63 color: (theme.vars || theme).palette[color].main
64 }
65 })), {
66 props: {
67 orientation: 'horizontal'
68 },
69 style: {
70 height: 4,
71 width: '100%',
72 padding: '13px 0',
73 // The primary input mechanism of the device includes a pointing device of limited accuracy.
74 '@media (pointer: coarse)': {
75 // Reach 42px touch target, about ~8mm on screen.
76 padding: '20px 0'
77 }
78 }
79 }, {
80 props: {
81 orientation: 'horizontal',
82 size: 'small'
83 },
84 style: {
85 height: 2
86 }
87 }, {
88 props: {
89 orientation: 'horizontal',
90 marked: true
91 },
92 style: {
93 marginBottom: 20
94 }
95 }, {
96 props: {
97 orientation: 'vertical'
98 },
99 style: {
100 height: '100%',
101 width: 4,
102 padding: '0 13px',
103 // The primary input mechanism of the device includes a pointing device of limited accuracy.
104 '@media (pointer: coarse)': {
105 // Reach 42px touch target, about ~8mm on screen.
106 padding: '0 20px'
107 }
108 }
109 }, {
110 props: {
111 orientation: 'vertical',
112 size: 'small'
113 },
114 style: {
115 width: 2
116 }
117 }, {
118 props: {
119 orientation: 'vertical',
120 marked: true
121 },
122 style: {
123 marginRight: 44
124 }
125 }]
126})));
127export const SliderRail = styled('span', {
128 name: 'MuiSlider',
129 slot: 'Rail',
130 overridesResolver: (props, styles) => styles.rail
131})({
132 display: 'block',
133 position: 'absolute',
134 borderRadius: 'inherit',
135 backgroundColor: 'currentColor',
136 opacity: 0.38,
137 variants: [{
138 props: {
139 orientation: 'horizontal'
140 },
141 style: {
142 width: '100%',
143 height: 'inherit',
144 top: '50%',
145 transform: 'translateY(-50%)'
146 }
147 }, {
148 props: {
149 orientation: 'vertical'
150 },
151 style: {
152 height: '100%',
153 width: 'inherit',
154 left: '50%',
155 transform: 'translateX(-50%)'
156 }
157 }, {
158 props: {
159 track: 'inverted'
160 },
161 style: {
162 opacity: 1
163 }
164 }]
165});
166export const SliderTrack = styled('span', {
167 name: 'MuiSlider',
168 slot: 'Track',
169 overridesResolver: (props, styles) => styles.track
170})(memoTheme(({
171 theme
172}) => {
173 return {
174 display: 'block',
175 position: 'absolute',
176 borderRadius: 'inherit',
177 border: '1px solid currentColor',
178 backgroundColor: 'currentColor',
179 transition: theme.transitions.create(['left', 'width', 'bottom', 'height'], {
180 duration: theme.transitions.duration.shortest
181 }),
182 variants: [{
183 props: {
184 size: 'small'
185 },
186 style: {
187 border: 'none'
188 }
189 }, {
190 props: {
191 orientation: 'horizontal'
192 },
193 style: {
194 height: 'inherit',
195 top: '50%',
196 transform: 'translateY(-50%)'
197 }
198 }, {
199 props: {
200 orientation: 'vertical'
201 },
202 style: {
203 width: 'inherit',
204 left: '50%',
205 transform: 'translateX(-50%)'
206 }
207 }, {
208 props: {
209 track: false
210 },
211 style: {
212 display: 'none'
213 }
214 }, ...Object.entries(theme.palette).filter(createSimplePaletteValueFilter()).map(([color]) => ({
215 props: {
216 color,
217 track: 'inverted'
218 },
219 style: {
220 ...(theme.vars ? {
221 backgroundColor: theme.vars.palette.Slider[`${color}Track`],
222 borderColor: theme.vars.palette.Slider[`${color}Track`]
223 } : {
224 backgroundColor: lighten(theme.palette[color].main, 0.62),
225 borderColor: lighten(theme.palette[color].main, 0.62),
226 ...theme.applyStyles('dark', {
227 backgroundColor: darken(theme.palette[color].main, 0.5)
228 }),
229 ...theme.applyStyles('dark', {
230 borderColor: darken(theme.palette[color].main, 0.5)
231 })
232 })
233 }
234 }))]
235 };
236}));
237export const SliderThumb = styled('span', {
238 name: 'MuiSlider',
239 slot: 'Thumb',
240 overridesResolver: (props, styles) => {
241 const {
242 ownerState
243 } = props;
244 return [styles.thumb, styles[`thumbColor${capitalize(ownerState.color)}`], ownerState.size !== 'medium' && styles[`thumbSize${capitalize(ownerState.size)}`]];
245 }
246})(memoTheme(({
247 theme
248}) => ({
249 position: 'absolute',
250 width: 20,
251 height: 20,
252 boxSizing: 'border-box',
253 borderRadius: '50%',
254 outline: 0,
255 backgroundColor: 'currentColor',
256 display: 'flex',
257 alignItems: 'center',
258 justifyContent: 'center',
259 transition: theme.transitions.create(['box-shadow', 'left', 'bottom'], {
260 duration: theme.transitions.duration.shortest
261 }),
262 '&::before': {
263 position: 'absolute',
264 content: '""',
265 borderRadius: 'inherit',
266 width: '100%',
267 height: '100%',
268 boxShadow: (theme.vars || theme).shadows[2]
269 },
270 '&::after': {
271 position: 'absolute',
272 content: '""',
273 borderRadius: '50%',
274 // 42px is the hit target
275 width: 42,
276 height: 42,
277 top: '50%',
278 left: '50%',
279 transform: 'translate(-50%, -50%)'
280 },
281 [`&.${sliderClasses.disabled}`]: {
282 '&:hover': {
283 boxShadow: 'none'
284 }
285 },
286 variants: [{
287 props: {
288 size: 'small'
289 },
290 style: {
291 width: 12,
292 height: 12,
293 '&::before': {
294 boxShadow: 'none'
295 }
296 }
297 }, {
298 props: {
299 orientation: 'horizontal'
300 },
301 style: {
302 top: '50%',
303 transform: 'translate(-50%, -50%)'
304 }
305 }, {
306 props: {
307 orientation: 'vertical'
308 },
309 style: {
310 left: '50%',
311 transform: 'translate(-50%, 50%)'
312 }
313 }, ...Object.entries(theme.palette).filter(createSimplePaletteValueFilter()).map(([color]) => ({
314 props: {
315 color
316 },
317 style: {
318 [`&:hover, &.${sliderClasses.focusVisible}`]: {
319 ...(theme.vars ? {
320 boxShadow: `0px 0px 0px 8px rgba(${theme.vars.palette[color].mainChannel} / 0.16)`
321 } : {
322 boxShadow: `0px 0px 0px 8px ${alpha(theme.palette[color].main, 0.16)}`
323 }),
324 '@media (hover: none)': {
325 boxShadow: 'none'
326 }
327 },
328 [`&.${sliderClasses.active}`]: {
329 ...(theme.vars ? {
330 boxShadow: `0px 0px 0px 14px rgba(${theme.vars.palette[color].mainChannel} / 0.16)`
331 } : {
332 boxShadow: `0px 0px 0px 14px ${alpha(theme.palette[color].main, 0.16)}`
333 })
334 }
335 }
336 }))]
337})));
338const SliderValueLabel = styled(BaseSliderValueLabel, {
339 name: 'MuiSlider',
340 slot: 'ValueLabel',
341 overridesResolver: (props, styles) => styles.valueLabel
342})(memoTheme(({
343 theme
344}) => ({
345 zIndex: 1,
346 whiteSpace: 'nowrap',
347 ...theme.typography.body2,
348 fontWeight: 500,
349 transition: theme.transitions.create(['transform'], {
350 duration: theme.transitions.duration.shortest
351 }),
352 position: 'absolute',
353 backgroundColor: (theme.vars || theme).palette.grey[600],
354 borderRadius: 2,
355 color: (theme.vars || theme).palette.common.white,
356 display: 'flex',
357 alignItems: 'center',
358 justifyContent: 'center',
359 padding: '0.25rem 0.75rem',
360 variants: [{
361 props: {
362 orientation: 'horizontal'
363 },
364 style: {
365 transform: 'translateY(-100%) scale(0)',
366 top: '-10px',
367 transformOrigin: 'bottom center',
368 '&::before': {
369 position: 'absolute',
370 content: '""',
371 width: 8,
372 height: 8,
373 transform: 'translate(-50%, 50%) rotate(45deg)',
374 backgroundColor: 'inherit',
375 bottom: 0,
376 left: '50%'
377 },
378 [`&.${sliderClasses.valueLabelOpen}`]: {
379 transform: 'translateY(-100%) scale(1)'
380 }
381 }
382 }, {
383 props: {
384 orientation: 'vertical'
385 },
386 style: {
387 transform: 'translateY(-50%) scale(0)',
388 right: '30px',
389 top: '50%',
390 transformOrigin: 'right center',
391 '&::before': {
392 position: 'absolute',
393 content: '""',
394 width: 8,
395 height: 8,
396 transform: 'translate(-50%, -50%) rotate(45deg)',
397 backgroundColor: 'inherit',
398 right: -8,
399 top: '50%'
400 },
401 [`&.${sliderClasses.valueLabelOpen}`]: {
402 transform: 'translateY(-50%) scale(1)'
403 }
404 }
405 }, {
406 props: {
407 size: 'small'
408 },
409 style: {
410 fontSize: theme.typography.pxToRem(12),
411 padding: '0.25rem 0.5rem'
412 }
413 }, {
414 props: {
415 orientation: 'vertical',
416 size: 'small'
417 },
418 style: {
419 right: '20px'
420 }
421 }]
422})));
423process.env.NODE_ENV !== "production" ? SliderValueLabel.propTypes /* remove-proptypes */ = {
424 // ┌────────────────────────────── Warning ──────────────────────────────┐
425 // │ These PropTypes are generated from the TypeScript type definitions. │
426 // │ To update them, edit the d.ts file and run `pnpm proptypes`. │
427 // └─────────────────────────────────────────────────────────────────────┘
428 /**
429 * @ignore
430 */
431 children: PropTypes.element.isRequired,
432 /**
433 * @ignore
434 */
435 index: PropTypes.number.isRequired,
436 /**
437 * @ignore
438 */
439 open: PropTypes.bool.isRequired,
440 /**
441 * @ignore
442 */
443 value: PropTypes.node
444} : void 0;
445export { SliderValueLabel };
446export const SliderMark = styled('span', {
447 name: 'MuiSlider',
448 slot: 'Mark',
449 shouldForwardProp: prop => slotShouldForwardProp(prop) && prop !== 'markActive',
450 overridesResolver: (props, styles) => {
451 const {
452 markActive
453 } = props;
454 return [styles.mark, markActive && styles.markActive];
455 }
456})(memoTheme(({
457 theme
458}) => ({
459 position: 'absolute',
460 width: 2,
461 height: 2,
462 borderRadius: 1,
463 backgroundColor: 'currentColor',
464 variants: [{
465 props: {
466 orientation: 'horizontal'
467 },
468 style: {
469 top: '50%',
470 transform: 'translate(-1px, -50%)'
471 }
472 }, {
473 props: {
474 orientation: 'vertical'
475 },
476 style: {
477 left: '50%',
478 transform: 'translate(-50%, 1px)'
479 }
480 }, {
481 props: {
482 markActive: true
483 },
484 style: {
485 backgroundColor: (theme.vars || theme).palette.background.paper,
486 opacity: 0.8
487 }
488 }]
489})));
490export const SliderMarkLabel = styled('span', {
491 name: 'MuiSlider',
492 slot: 'MarkLabel',
493 shouldForwardProp: prop => slotShouldForwardProp(prop) && prop !== 'markLabelActive',
494 overridesResolver: (props, styles) => styles.markLabel
495})(memoTheme(({
496 theme
497}) => ({
498 ...theme.typography.body2,
499 color: (theme.vars || theme).palette.text.secondary,
500 position: 'absolute',
501 whiteSpace: 'nowrap',
502 variants: [{
503 props: {
504 orientation: 'horizontal'
505 },
506 style: {
507 top: 30,
508 transform: 'translateX(-50%)',
509 '@media (pointer: coarse)': {
510 top: 40
511 }
512 }
513 }, {
514 props: {
515 orientation: 'vertical'
516 },
517 style: {
518 left: 36,
519 transform: 'translateY(50%)',
520 '@media (pointer: coarse)': {
521 left: 44
522 }
523 }
524 }, {
525 props: {
526 markLabelActive: true
527 },
528 style: {
529 color: (theme.vars || theme).palette.text.primary
530 }
531 }]
532})));
533const useUtilityClasses = ownerState => {
534 const {
535 disabled,
536 dragging,
537 marked,
538 orientation,
539 track,
540 classes,
541 color,
542 size
543 } = ownerState;
544 const slots = {
545 root: ['root', disabled && 'disabled', dragging && 'dragging', marked && 'marked', orientation === 'vertical' && 'vertical', track === 'inverted' && 'trackInverted', track === false && 'trackFalse', color && `color${capitalize(color)}`, size && `size${capitalize(size)}`],
546 rail: ['rail'],
547 track: ['track'],
548 mark: ['mark'],
549 markActive: ['markActive'],
550 markLabel: ['markLabel'],
551 markLabelActive: ['markLabelActive'],
552 valueLabel: ['valueLabel'],
553 thumb: ['thumb', disabled && 'disabled', size && `thumbSize${capitalize(size)}`, color && `thumbColor${capitalize(color)}`],
554 active: ['active'],
555 disabled: ['disabled'],
556 focusVisible: ['focusVisible']
557 };
558 return composeClasses(slots, getSliderUtilityClass, classes);
559};
560const Forward = ({
561 children
562}) => children;
563const Slider = /*#__PURE__*/React.forwardRef(function Slider(inputProps, ref) {
564 const props = useDefaultProps({
565 props: inputProps,
566 name: 'MuiSlider'
567 });
568 const isRtl = useRtl();
569 const {
570 'aria-label': ariaLabel,
571 'aria-valuetext': ariaValuetext,
572 'aria-labelledby': ariaLabelledby,
573 // eslint-disable-next-line react/prop-types
574 component = 'span',
575 components = {},
576 componentsProps = {},
577 color = 'primary',
578 classes: classesProp,
579 className,
580 disableSwap = false,
581 disabled = false,
582 getAriaLabel,
583 getAriaValueText,
584 marks: marksProp = false,
585 max = 100,
586 min = 0,
587 name,
588 onChange,
589 onChangeCommitted,
590 orientation = 'horizontal',
591 shiftStep = 10,
592 size = 'medium',
593 step = 1,
594 scale = Identity,
595 slotProps,
596 slots,
597 tabIndex,
598 track = 'normal',
599 value: valueProp,
600 valueLabelDisplay = 'off',
601 valueLabelFormat = Identity,
602 ...other
603 } = props;
604 const ownerState = {
605 ...props,
606 isRtl,
607 max,
608 min,
609 classes: classesProp,
610 disabled,
611 disableSwap,
612 orientation,
613 marks: marksProp,
614 color,
615 size,
616 step,
617 shiftStep,
618 scale,
619 track,
620 valueLabelDisplay,
621 valueLabelFormat
622 };
623 const {
624 axisProps,
625 getRootProps,
626 getHiddenInputProps,
627 getThumbProps,
628 open,
629 active,
630 axis,
631 focusedThumbIndex,
632 range,
633 dragging,
634 marks,
635 values,
636 trackOffset,
637 trackLeap,
638 getThumbStyle
639 } = useSlider({
640 ...ownerState,
641 rootRef: ref
642 });
643 ownerState.marked = marks.length > 0 && marks.some(mark => mark.label);
644 ownerState.dragging = dragging;
645 ownerState.focusedThumbIndex = focusedThumbIndex;
646 const classes = useUtilityClasses(ownerState);
647
648 // support both `slots` and `components` for backward compatibility
649 const RootSlot = slots?.root ?? components.Root ?? SliderRoot;
650 const RailSlot = slots?.rail ?? components.Rail ?? SliderRail;
651 const TrackSlot = slots?.track ?? components.Track ?? SliderTrack;
652 const ThumbSlot = slots?.thumb ?? components.Thumb ?? SliderThumb;
653 const ValueLabelSlot = slots?.valueLabel ?? components.ValueLabel ?? SliderValueLabel;
654 const MarkSlot = slots?.mark ?? components.Mark ?? SliderMark;
655 const MarkLabelSlot = slots?.markLabel ?? components.MarkLabel ?? SliderMarkLabel;
656 const InputSlot = slots?.input ?? components.Input ?? 'input';
657 const rootSlotProps = slotProps?.root ?? componentsProps.root;
658 const railSlotProps = slotProps?.rail ?? componentsProps.rail;
659 const trackSlotProps = slotProps?.track ?? componentsProps.track;
660 const thumbSlotProps = slotProps?.thumb ?? componentsProps.thumb;
661 const valueLabelSlotProps = slotProps?.valueLabel ?? componentsProps.valueLabel;
662 const markSlotProps = slotProps?.mark ?? componentsProps.mark;
663 const markLabelSlotProps = slotProps?.markLabel ?? componentsProps.markLabel;
664 const inputSlotProps = slotProps?.input ?? componentsProps.input;
665 const rootProps = useSlotProps({
666 elementType: RootSlot,
667 getSlotProps: getRootProps,
668 externalSlotProps: rootSlotProps,
669 externalForwardedProps: other,
670 additionalProps: {
671 ...(shouldSpreadAdditionalProps(RootSlot) && {
672 as: component
673 })
674 },
675 ownerState: {
676 ...ownerState,
677 ...rootSlotProps?.ownerState
678 },
679 className: [classes.root, className]
680 });
681 const railProps = useSlotProps({
682 elementType: RailSlot,
683 externalSlotProps: railSlotProps,
684 ownerState,
685 className: classes.rail
686 });
687 const trackProps = useSlotProps({
688 elementType: TrackSlot,
689 externalSlotProps: trackSlotProps,
690 additionalProps: {
691 style: {
692 ...axisProps[axis].offset(trackOffset),
693 ...axisProps[axis].leap(trackLeap)
694 }
695 },
696 ownerState: {
697 ...ownerState,
698 ...trackSlotProps?.ownerState
699 },
700 className: classes.track
701 });
702 const thumbProps = useSlotProps({
703 elementType: ThumbSlot,
704 getSlotProps: getThumbProps,
705 externalSlotProps: thumbSlotProps,
706 ownerState: {
707 ...ownerState,
708 ...thumbSlotProps?.ownerState
709 },
710 className: classes.thumb
711 });
712 const valueLabelProps = useSlotProps({
713 elementType: ValueLabelSlot,
714 externalSlotProps: valueLabelSlotProps,
715 ownerState: {
716 ...ownerState,
717 ...valueLabelSlotProps?.ownerState
718 },
719 className: classes.valueLabel
720 });
721 const markProps = useSlotProps({
722 elementType: MarkSlot,
723 externalSlotProps: markSlotProps,
724 ownerState,
725 className: classes.mark
726 });
727 const markLabelProps = useSlotProps({
728 elementType: MarkLabelSlot,
729 externalSlotProps: markLabelSlotProps,
730 ownerState,
731 className: classes.markLabel
732 });
733 const inputSliderProps = useSlotProps({
734 elementType: InputSlot,
735 getSlotProps: getHiddenInputProps,
736 externalSlotProps: inputSlotProps,
737 ownerState
738 });
739 return /*#__PURE__*/_jsxs(RootSlot, {
740 ...rootProps,
741 children: [/*#__PURE__*/_jsx(RailSlot, {
742 ...railProps
743 }), /*#__PURE__*/_jsx(TrackSlot, {
744 ...trackProps
745 }), marks.filter(mark => mark.value >= min && mark.value <= max).map((mark, index) => {
746 const percent = valueToPercent(mark.value, min, max);
747 const style = axisProps[axis].offset(percent);
748 let markActive;
749 if (track === false) {
750 markActive = values.includes(mark.value);
751 } else {
752 markActive = track === 'normal' && (range ? mark.value >= values[0] && mark.value <= values[values.length - 1] : mark.value <= values[0]) || track === 'inverted' && (range ? mark.value <= values[0] || mark.value >= values[values.length - 1] : mark.value >= values[0]);
753 }
754 return /*#__PURE__*/_jsxs(React.Fragment, {
755 children: [/*#__PURE__*/_jsx(MarkSlot, {
756 "data-index": index,
757 ...markProps,
758 ...(!isHostComponent(MarkSlot) && {
759 markActive
760 }),
761 style: {
762 ...style,
763 ...markProps.style
764 },
765 className: clsx(markProps.className, markActive && classes.markActive)
766 }), mark.label != null ? /*#__PURE__*/_jsx(MarkLabelSlot, {
767 "aria-hidden": true,
768 "data-index": index,
769 ...markLabelProps,
770 ...(!isHostComponent(MarkLabelSlot) && {
771 markLabelActive: markActive
772 }),
773 style: {
774 ...style,
775 ...markLabelProps.style
776 },
777 className: clsx(classes.markLabel, markLabelProps.className, markActive && classes.markLabelActive),
778 children: mark.label
779 }) : null]
780 }, index);
781 }), values.map((value, index) => {
782 const percent = valueToPercent(value, min, max);
783 const style = axisProps[axis].offset(percent);
784 const ValueLabelComponent = valueLabelDisplay === 'off' ? Forward : ValueLabelSlot;
785 return /*#__PURE__*/ /* TODO v6: Change component structure. It will help in avoiding the complicated React.cloneElement API added in SliderValueLabel component. Should be: Thumb -> Input, ValueLabel. Follow Joy UI's Slider structure. */_jsx(ValueLabelComponent, {
786 ...(!isHostComponent(ValueLabelComponent) && {
787 valueLabelFormat,
788 valueLabelDisplay,
789 value: typeof valueLabelFormat === 'function' ? valueLabelFormat(scale(value), index) : valueLabelFormat,
790 index,
791 open: open === index || active === index || valueLabelDisplay === 'on',
792 disabled
793 }),
794 ...valueLabelProps,
795 children: /*#__PURE__*/_jsx(ThumbSlot, {
796 "data-index": index,
797 ...thumbProps,
798 className: clsx(classes.thumb, thumbProps.className, active === index && classes.active, focusedThumbIndex === index && classes.focusVisible),
799 style: {
800 ...style,
801 ...getThumbStyle(index),
802 ...thumbProps.style
803 },
804 children: /*#__PURE__*/_jsx(InputSlot, {
805 "data-index": index,
806 "aria-label": getAriaLabel ? getAriaLabel(index) : ariaLabel,
807 "aria-valuenow": scale(value),
808 "aria-labelledby": ariaLabelledby,
809 "aria-valuetext": getAriaValueText ? getAriaValueText(scale(value), index) : ariaValuetext,
810 value: values[index],
811 ...inputSliderProps
812 })
813 })
814 }, index);
815 })]
816 });
817});
818process.env.NODE_ENV !== "production" ? Slider.propTypes /* remove-proptypes */ = {
819 // ┌────────────────────────────── Warning ──────────────────────────────┐
820 // │ These PropTypes are generated from the TypeScript type definitions. │
821 // │ To update them, edit the d.ts file and run `pnpm proptypes`. │
822 // └─────────────────────────────────────────────────────────────────────┘
823 /**
824 * The label of the slider.
825 */
826 'aria-label': chainPropTypes(PropTypes.string, props => {
827 const range = Array.isArray(props.value || props.defaultValue);
828 if (range && props['aria-label'] != null) {
829 return new Error('MUI: You need to use the `getAriaLabel` prop instead of `aria-label` when using a range slider.');
830 }
831 return null;
832 }),
833 /**
834 * The id of the element containing a label for the slider.
835 */
836 'aria-labelledby': PropTypes.string,
837 /**
838 * A string value that provides a user-friendly name for the current value of the slider.
839 */
840 'aria-valuetext': chainPropTypes(PropTypes.string, props => {
841 const range = Array.isArray(props.value || props.defaultValue);
842 if (range && props['aria-valuetext'] != null) {
843 return new Error('MUI: You need to use the `getAriaValueText` prop instead of `aria-valuetext` when using a range slider.');
844 }
845 return null;
846 }),
847 /**
848 * @ignore
849 */
850 children: PropTypes.node,
851 /**
852 * Override or extend the styles applied to the component.
853 */
854 classes: PropTypes.object,
855 /**
856 * @ignore
857 */
858 className: PropTypes.string,
859 /**
860 * The color of the component.
861 * It supports both default and custom theme colors, which can be added as shown in the
862 * [palette customization guide](https://mui.com/material-ui/customization/palette/#custom-colors).
863 * @default 'primary'
864 */
865 color: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.oneOf(['primary', 'secondary', 'error', 'info', 'success', 'warning']), PropTypes.string]),
866 /**
867 * The components used for each slot inside.
868 *
869 * @deprecated use the `slots` prop instead. This prop will be removed in v7. See [Migrating from deprecated APIs](https://mui.com/material-ui/migration/migrating-from-deprecated-apis/) for more details.
870 *
871 * @default {}
872 */
873 components: PropTypes.shape({
874 Input: PropTypes.elementType,
875 Mark: PropTypes.elementType,
876 MarkLabel: PropTypes.elementType,
877 Rail: PropTypes.elementType,
878 Root: PropTypes.elementType,
879 Thumb: PropTypes.elementType,
880 Track: PropTypes.elementType,
881 ValueLabel: PropTypes.elementType
882 }),
883 /**
884 * The extra props for the slot components.
885 * You can override the existing props or add new ones.
886 *
887 * @deprecated use the `slotProps` prop instead. This prop will be removed in v7. See [Migrating from deprecated APIs](https://mui.com/material-ui/migration/migrating-from-deprecated-apis/) for more details.
888 *
889 * @default {}
890 */
891 componentsProps: PropTypes.shape({
892 input: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
893 mark: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
894 markLabel: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
895 rail: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
896 root: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
897 thumb: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
898 track: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
899 valueLabel: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
900 children: PropTypes.element,
901 className: PropTypes.string,
902 open: PropTypes.bool,
903 style: PropTypes.object,
904 value: PropTypes.node,
905 valueLabelDisplay: PropTypes.oneOf(['auto', 'off', 'on'])
906 })])
907 }),
908 /**
909 * The default value. Use when the component is not controlled.
910 */
911 defaultValue: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.number), PropTypes.number]),
912 /**
913 * If `true`, the component is disabled.
914 * @default false
915 */
916 disabled: PropTypes.bool,
917 /**
918 * If `true`, the active thumb doesn't swap when moving pointer over a thumb while dragging another thumb.
919 * @default false
920 */
921 disableSwap: PropTypes.bool,
922 /**
923 * Accepts a function which returns a string value that provides a user-friendly name for the thumb labels of the slider.
924 * This is important for screen reader users.
925 * @param {number} index The thumb label's index to format.
926 * @returns {string}
927 */
928 getAriaLabel: PropTypes.func,
929 /**
930 * Accepts a function which returns a string value that provides a user-friendly name for the current value of the slider.
931 * This is important for screen reader users.
932 * @param {number} value The thumb label's value to format.
933 * @param {number} index The thumb label's index to format.
934 * @returns {string}
935 */
936 getAriaValueText: PropTypes.func,
937 /**
938 * Marks indicate predetermined values to which the user can move the slider.
939 * If `true` the marks are spaced according the value of the `step` prop.
940 * If an array, it should contain objects with `value` and an optional `label` keys.
941 * @default false
942 */
943 marks: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.shape({
944 label: PropTypes.node,
945 value: PropTypes.number.isRequired
946 })), PropTypes.bool]),
947 /**
948 * The maximum allowed value of the slider.
949 * Should not be equal to min.
950 * @default 100
951 */
952 max: PropTypes.number,
953 /**
954 * The minimum allowed value of the slider.
955 * Should not be equal to max.
956 * @default 0
957 */
958 min: PropTypes.number,
959 /**
960 * Name attribute of the hidden `input` element.
961 */
962 name: PropTypes.string,
963 /**
964 * Callback function that is fired when the slider's value changed.
965 *
966 * @param {Event} event The event source of the callback.
967 * You can pull out the new value by accessing `event.target.value` (any).
968 * **Warning**: This is a generic event not a change event.
969 * @param {number | number[]} value The new value.
970 * @param {number} activeThumb Index of the currently moved thumb.
971 */
972 onChange: PropTypes.func,
973 /**
974 * Callback function that is fired when the `mouseup` is triggered.
975 *
976 * @param {React.SyntheticEvent | Event} event The event source of the callback. **Warning**: This is a generic event not a change event.
977 * @param {number | number[]} value The new value.
978 */
979 onChangeCommitted: PropTypes.func,
980 /**
981 * The component orientation.
982 * @default 'horizontal'
983 */
984 orientation: PropTypes.oneOf(['horizontal', 'vertical']),
985 /**
986 * A transformation function, to change the scale of the slider.
987 * @param {any} x
988 * @returns {any}
989 * @default function Identity(x) {
990 * return x;
991 * }
992 */
993 scale: PropTypes.func,
994 /**
995 * The granularity with which the slider can step through values when using Page Up/Page Down or Shift + Arrow Up/Arrow Down.
996 * @default 10
997 */
998 shiftStep: PropTypes.number,
999 /**
1000 * The size of the slider.
1001 * @default 'medium'
1002 */
1003 size: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.oneOf(['small', 'medium']), PropTypes.string]),
1004 /**
1005 * The props used for each slot inside the Slider.
1006 * @default {}
1007 */
1008 slotProps: PropTypes.shape({
1009 input: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
1010 mark: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
1011 markLabel: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
1012 rail: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
1013 root: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
1014 thumb: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
1015 track: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
1016 valueLabel: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
1017 children: PropTypes.element,
1018 className: PropTypes.string,
1019 open: PropTypes.bool,
1020 style: PropTypes.object,
1021 value: PropTypes.node,
1022 valueLabelDisplay: PropTypes.oneOf(['auto', 'off', 'on'])
1023 })])
1024 }),
1025 /**
1026 * The components used for each slot inside the Slider.
1027 * Either a string to use a HTML element or a component.
1028 * @default {}
1029 */
1030 slots: PropTypes.shape({
1031 input: PropTypes.elementType,
1032 mark: PropTypes.elementType,
1033 markLabel: PropTypes.elementType,
1034 rail: PropTypes.elementType,
1035 root: PropTypes.elementType,
1036 thumb: PropTypes.elementType,
1037 track: PropTypes.elementType,
1038 valueLabel: PropTypes.elementType
1039 }),
1040 /**
1041 * The granularity with which the slider can step through values. (A "discrete" slider.)
1042 * The `min` prop serves as the origin for the valid values.
1043 * We recommend (max - min) to be evenly divisible by the step.
1044 *
1045 * When step is `null`, the thumb can only be slid onto marks provided with the `marks` prop.
1046 * @default 1
1047 */
1048 step: PropTypes.number,
1049 /**
1050 * The system prop that allows defining system overrides as well as additional CSS styles.
1051 */
1052 sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
1053 /**
1054 * Tab index attribute of the hidden `input` element.
1055 */
1056 tabIndex: PropTypes.number,
1057 /**
1058 * The track presentation:
1059 *
1060 * - `normal` the track will render a bar representing the slider value.
1061 * - `inverted` the track will render a bar representing the remaining slider value.
1062 * - `false` the track will render without a bar.
1063 * @default 'normal'
1064 */
1065 track: PropTypes.oneOf(['inverted', 'normal', false]),
1066 /**
1067 * The value of the slider.
1068 * For ranged sliders, provide an array with two values.
1069 */
1070 value: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.number), PropTypes.number]),
1071 /**
1072 * Controls when the value label is displayed:
1073 *
1074 * - `auto` the value label will display when the thumb is hovered or focused.
1075 * - `on` will display persistently.
1076 * - `off` will never display.
1077 * @default 'off'
1078 */
1079 valueLabelDisplay: PropTypes.oneOf(['auto', 'off', 'on']),
1080 /**
1081 * The format function the value label's value.
1082 *
1083 * When a function is provided, it should have the following signature:
1084 *
1085 * - {number} value The value label's value to format
1086 * - {number} index The value label's index to format
1087 * @param {any} x
1088 * @returns {any}
1089 * @default function Identity(x) {
1090 * return x;
1091 * }
1092 */
1093 valueLabelFormat: PropTypes.oneOfType([PropTypes.func, PropTypes.string])
1094} : void 0;
1095export default Slider;
\No newline at end of file