UNPKG

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