worked on GarageApp stuff
This commit is contained in:
parent
60aaf17af3
commit
eb606572b0
51919 changed files with 2168177 additions and 18 deletions
298
node_modules/@mui/material/Slider/Slider.d.ts
generated
vendored
Normal file
298
node_modules/@mui/material/Slider/Slider.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,298 @@
|
|||
import * as React from 'react';
|
||||
import { SxProps } from '@mui/system';
|
||||
import { OverridableStringUnion } from '@mui/types';
|
||||
import { Mark } from "./useSlider.types.js";
|
||||
import { SlotComponentProps } from "../utils/types.js";
|
||||
import { Theme } from "../styles/index.js";
|
||||
import { OverrideProps, OverridableComponent } from "../OverridableComponent/index.js";
|
||||
import SliderValueLabelComponent from "./SliderValueLabel.js";
|
||||
import { SliderClasses } from "./sliderClasses.js";
|
||||
export interface SliderPropsColorOverrides {}
|
||||
export interface SliderPropsSizeOverrides {}
|
||||
export interface SliderComponentsPropsOverrides {}
|
||||
export interface SliderOwnerState extends SliderProps {
|
||||
dragging: boolean;
|
||||
marked: boolean;
|
||||
focusedThumbIndex: number;
|
||||
}
|
||||
export interface SliderOwnProps<Value extends number | number[]> {
|
||||
/**
|
||||
* The label of the slider.
|
||||
*/
|
||||
'aria-label'?: string;
|
||||
/**
|
||||
* The id of the element containing a label for the slider.
|
||||
*/
|
||||
'aria-labelledby'?: string;
|
||||
/**
|
||||
* A string value that provides a user-friendly name for the current value of the slider.
|
||||
*/
|
||||
'aria-valuetext'?: string;
|
||||
/**
|
||||
* The color of the component.
|
||||
* It supports both default and custom theme colors, which can be added as shown in the
|
||||
* [palette customization guide](https://mui.com/material-ui/customization/palette/#custom-colors).
|
||||
* @default 'primary'
|
||||
*/
|
||||
color?: OverridableStringUnion<'primary' | 'secondary' | 'error' | 'info' | 'success' | 'warning', SliderPropsColorOverrides>;
|
||||
/**
|
||||
* The components used for each slot inside.
|
||||
*
|
||||
* @deprecated use the `slots` prop instead. This prop will be removed in a future major release. See [Migrating from deprecated APIs](https://mui.com/material-ui/migration/migrating-from-deprecated-apis/) for more details.
|
||||
*
|
||||
* @default {}
|
||||
*/
|
||||
components?: {
|
||||
Root?: React.ElementType;
|
||||
Track?: React.ElementType;
|
||||
Rail?: React.ElementType;
|
||||
Thumb?: React.ElementType;
|
||||
Mark?: React.ElementType;
|
||||
MarkLabel?: React.ElementType;
|
||||
ValueLabel?: React.ElementType;
|
||||
Input?: React.ElementType;
|
||||
};
|
||||
/**
|
||||
* The extra props for the slot components.
|
||||
* You can override the existing props or add new ones.
|
||||
*
|
||||
* @deprecated use the `slotProps` prop instead. This prop will be removed in a future major release. See [Migrating from deprecated APIs](https://mui.com/material-ui/migration/migrating-from-deprecated-apis/) for more details.
|
||||
*
|
||||
* @default {}
|
||||
*/
|
||||
componentsProps?: {
|
||||
root?: SlotComponentProps<'span', SliderComponentsPropsOverrides, SliderOwnerState>;
|
||||
track?: SlotComponentProps<'span', SliderComponentsPropsOverrides, SliderOwnerState>;
|
||||
rail?: SlotComponentProps<'span', SliderComponentsPropsOverrides, SliderOwnerState>;
|
||||
thumb?: SlotComponentProps<'span', SliderComponentsPropsOverrides, SliderOwnerState>;
|
||||
mark?: SlotComponentProps<'span', SliderComponentsPropsOverrides, SliderOwnerState>;
|
||||
markLabel?: SlotComponentProps<'span', SliderComponentsPropsOverrides, SliderOwnerState>;
|
||||
valueLabel?: SlotComponentProps<typeof SliderValueLabelComponent, SliderComponentsPropsOverrides, SliderOwnerState>;
|
||||
input?: SlotComponentProps<'input', SliderComponentsPropsOverrides, SliderOwnerState>;
|
||||
};
|
||||
/**
|
||||
* Override or extend the styles applied to the component.
|
||||
*/
|
||||
classes?: Partial<SliderClasses>;
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
className?: string;
|
||||
/**
|
||||
* The default value. Use when the component is not controlled.
|
||||
*/
|
||||
defaultValue?: Value;
|
||||
/**
|
||||
* If `true`, the component is disabled.
|
||||
* @default false
|
||||
*/
|
||||
disabled?: boolean;
|
||||
/**
|
||||
* If `true`, the active thumb doesn't swap when moving pointer over a thumb while dragging another thumb.
|
||||
* @default false
|
||||
*/
|
||||
disableSwap?: boolean;
|
||||
/**
|
||||
* Accepts a function which returns a string value that provides a user-friendly name for the thumb labels of the slider.
|
||||
* This is important for screen reader users.
|
||||
* @param {number} index The thumb label's index to format.
|
||||
* @returns {string}
|
||||
*/
|
||||
getAriaLabel?: (index: number) => string;
|
||||
/**
|
||||
* Accepts a function which returns a string value that provides a user-friendly name for the current value of the slider.
|
||||
* This is important for screen reader users.
|
||||
* @param {number} value The thumb label's value to format.
|
||||
* @param {number} index The thumb label's index to format.
|
||||
* @returns {string}
|
||||
*/
|
||||
getAriaValueText?: (value: number, index: number) => string;
|
||||
/**
|
||||
* Marks indicate predetermined values to which the user can move the slider.
|
||||
* If `true` the marks are spaced according the value of the `step` prop.
|
||||
* If an array, it should contain objects with `value` and an optional `label` keys.
|
||||
* @default false
|
||||
*/
|
||||
marks?: boolean | Mark[];
|
||||
/**
|
||||
* The maximum allowed value of the slider.
|
||||
* Should not be equal to min.
|
||||
* @default 100
|
||||
*/
|
||||
max?: number;
|
||||
/**
|
||||
* The minimum allowed value of the slider.
|
||||
* Should not be equal to max.
|
||||
* @default 0
|
||||
*/
|
||||
min?: number;
|
||||
/**
|
||||
* Name attribute of the hidden `input` element.
|
||||
*/
|
||||
name?: string;
|
||||
/**
|
||||
* Callback function that is fired when the slider's value changed.
|
||||
*
|
||||
* @param {Event} event The event source of the callback.
|
||||
* You can pull out the new value by accessing `event.target.value` (any).
|
||||
* **Warning**: This is a generic event not a change event.
|
||||
* @param {Value} value The new value.
|
||||
* @param {number} activeThumb Index of the currently moved thumb.
|
||||
*/
|
||||
onChange?: (event: Event, value: Value, activeThumb: number) => void;
|
||||
/**
|
||||
* Callback function that is fired when the `mouseup` is triggered.
|
||||
*
|
||||
* @param {React.SyntheticEvent | Event} event The event source of the callback. **Warning**: This is a generic event not a change event.
|
||||
* @param {Value} value The new value.
|
||||
*/
|
||||
onChangeCommitted?: (event: React.SyntheticEvent | Event, value: Value) => void;
|
||||
/**
|
||||
* The component orientation.
|
||||
* @default 'horizontal'
|
||||
*/
|
||||
orientation?: 'horizontal' | 'vertical';
|
||||
/**
|
||||
* A transformation function, to change the scale of the slider.
|
||||
* @param {any} x
|
||||
* @returns {any}
|
||||
* @default function Identity(x) {
|
||||
* return x;
|
||||
* }
|
||||
*/
|
||||
scale?: (value: number) => number;
|
||||
/**
|
||||
* The granularity with which the slider can step through values when using Page Up/Page Down or Shift + Arrow Up/Arrow Down.
|
||||
* @default 10
|
||||
*/
|
||||
shiftStep?: number;
|
||||
/**
|
||||
* The size of the slider.
|
||||
* @default 'medium'
|
||||
*/
|
||||
size?: OverridableStringUnion<'small' | 'medium', SliderPropsSizeOverrides>;
|
||||
/**
|
||||
* The props used for each slot inside the Slider.
|
||||
* @default {}
|
||||
*/
|
||||
slotProps?: {
|
||||
root?: SlotComponentProps<'span', SliderComponentsPropsOverrides, SliderOwnerState>;
|
||||
track?: SlotComponentProps<'span', SliderComponentsPropsOverrides, SliderOwnerState>;
|
||||
rail?: SlotComponentProps<'span', SliderComponentsPropsOverrides, SliderOwnerState>;
|
||||
thumb?: SlotComponentProps<'span', SliderComponentsPropsOverrides, SliderOwnerState>;
|
||||
mark?: SlotComponentProps<'span', SliderComponentsPropsOverrides, SliderOwnerState>;
|
||||
markLabel?: SlotComponentProps<'span', SliderComponentsPropsOverrides, SliderOwnerState>;
|
||||
valueLabel?: SlotComponentProps<typeof SliderValueLabelComponent, SliderComponentsPropsOverrides, SliderOwnerState>;
|
||||
input?: SlotComponentProps<'input', SliderComponentsPropsOverrides, SliderOwnerState>;
|
||||
};
|
||||
/**
|
||||
* The components used for each slot inside the Slider.
|
||||
* Either a string to use a HTML element or a component.
|
||||
* @default {}
|
||||
*/
|
||||
slots?: {
|
||||
root?: React.ElementType;
|
||||
track?: React.ElementType;
|
||||
rail?: React.ElementType;
|
||||
thumb?: React.ElementType;
|
||||
mark?: React.ElementType;
|
||||
markLabel?: React.ElementType;
|
||||
valueLabel?: React.ElementType;
|
||||
input?: React.ElementType;
|
||||
};
|
||||
/**
|
||||
* The granularity with which the slider can step through values. (A "discrete" slider.)
|
||||
* The `min` prop serves as the origin for the valid values.
|
||||
* We recommend (max - min) to be evenly divisible by the step.
|
||||
*
|
||||
* When step is `null`, the thumb can only be slid onto marks provided with the `marks` prop.
|
||||
* @default 1
|
||||
*/
|
||||
step?: number | null;
|
||||
/**
|
||||
* The system prop that allows defining system overrides as well as additional CSS styles.
|
||||
*/
|
||||
sx?: SxProps<Theme>;
|
||||
/**
|
||||
* Tab index attribute of the hidden `input` element.
|
||||
*/
|
||||
tabIndex?: number;
|
||||
/**
|
||||
* The track presentation:
|
||||
*
|
||||
* - `normal` the track will render a bar representing the slider value.
|
||||
* - `inverted` the track will render a bar representing the remaining slider value.
|
||||
* - `false` the track will render without a bar.
|
||||
* @default 'normal'
|
||||
*/
|
||||
track?: 'normal' | false | 'inverted';
|
||||
/**
|
||||
* The value of the slider.
|
||||
* For ranged sliders, provide an array with two values.
|
||||
*/
|
||||
value?: Value;
|
||||
/**
|
||||
* Controls when the value label is displayed:
|
||||
*
|
||||
* - `auto` the value label will display when the thumb is hovered or focused.
|
||||
* - `on` will display persistently.
|
||||
* - `off` will never display.
|
||||
* @default 'off'
|
||||
*/
|
||||
valueLabelDisplay?: 'on' | 'auto' | 'off';
|
||||
/**
|
||||
* The format function the value label's value.
|
||||
*
|
||||
* When a function is provided, it should have the following signature:
|
||||
*
|
||||
* - {number} value The value label's value to format
|
||||
* - {number} index The value label's index to format
|
||||
* @param {any} x
|
||||
* @returns {any}
|
||||
* @default function Identity(x) {
|
||||
* return x;
|
||||
* }
|
||||
*/
|
||||
valueLabelFormat?: string | ((value: number, index: number) => React.ReactNode);
|
||||
}
|
||||
export interface SliderTypeMap<RootComponent extends React.ElementType = 'span', AdditionalProps = {}, Value extends number | number[] = number | number[]> {
|
||||
props: AdditionalProps & SliderOwnProps<Value>;
|
||||
defaultComponent: RootComponent;
|
||||
}
|
||||
export type SliderComponent<Value extends number | number[]> = OverridableComponent<SliderTypeMap<'span', {}, Value>>;
|
||||
export type SliderType = SliderComponent<number> & SliderComponent<number[]> & SliderComponent<number | number[]>;
|
||||
export interface SliderValueLabelProps extends React.HTMLAttributes<HTMLSpanElement> {
|
||||
children: React.ReactElement<unknown>;
|
||||
index: number;
|
||||
open: boolean;
|
||||
value: React.ReactNode;
|
||||
}
|
||||
type SliderRootProps = NonNullable<SliderTypeMap['props']['componentsProps']>['root'];
|
||||
type SliderMarkProps = NonNullable<SliderTypeMap['props']['componentsProps']>['mark'];
|
||||
type SliderMarkLabelProps = NonNullable<SliderTypeMap['props']['componentsProps']>['markLabel'];
|
||||
type SliderRailProps = NonNullable<SliderTypeMap['props']['componentsProps']>['rail'];
|
||||
type SliderTrackProps = NonNullable<SliderTypeMap['props']['componentsProps']>['track'];
|
||||
type SliderThumbProps = NonNullable<SliderTypeMap['props']['componentsProps']>['thumb'];
|
||||
export declare const SliderRoot: React.FC<SliderRootProps>;
|
||||
export declare const SliderMark: React.FC<SliderMarkProps>;
|
||||
export declare const SliderMarkLabel: React.FC<SliderMarkLabelProps>;
|
||||
export declare const SliderRail: React.FC<SliderRailProps>;
|
||||
export declare const SliderTrack: React.FC<SliderTrackProps>;
|
||||
export declare const SliderThumb: React.FC<SliderThumbProps>;
|
||||
export declare const SliderValueLabel: React.FC<SliderValueLabelProps>;
|
||||
|
||||
/**
|
||||
*
|
||||
* Demos:
|
||||
*
|
||||
* - [Slider](https://mui.com/material-ui/react-slider/)
|
||||
*
|
||||
* API:
|
||||
*
|
||||
* - [Slider API](https://mui.com/material-ui/api/slider/)
|
||||
*/
|
||||
declare const Slider: SliderType;
|
||||
export type SliderProps<RootComponent extends React.ElementType = SliderTypeMap['defaultComponent'], AdditionalProps = {}> = OverrideProps<SliderTypeMap<RootComponent, AdditionalProps>, RootComponent> & {
|
||||
component?: React.ElementType;
|
||||
};
|
||||
export default Slider;
|
||||
1088
node_modules/@mui/material/Slider/Slider.js
generated
vendored
Normal file
1088
node_modules/@mui/material/Slider/Slider.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
13
node_modules/@mui/material/Slider/SliderValueLabel.d.ts
generated
vendored
Normal file
13
node_modules/@mui/material/Slider/SliderValueLabel.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
import * as React from 'react';
|
||||
import { SliderValueLabelProps } from "./SliderValueLabel.types.js";
|
||||
/**
|
||||
* @ignore - internal component.
|
||||
*/
|
||||
declare function SliderValueLabel(props: SliderValueLabelProps): React.ReactElement<{
|
||||
className?: string;
|
||||
children?: React.ReactNode;
|
||||
}, string | React.JSXElementConstructor<any>> | null;
|
||||
declare namespace SliderValueLabel {
|
||||
var propTypes: any;
|
||||
}
|
||||
export default SliderValueLabel;
|
||||
60
node_modules/@mui/material/Slider/SliderValueLabel.js
generated
vendored
Normal file
60
node_modules/@mui/material/Slider/SliderValueLabel.js
generated
vendored
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
"use strict";
|
||||
'use client';
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
||||
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = SliderValueLabel;
|
||||
var React = _interopRequireWildcard(require("react"));
|
||||
var _propTypes = _interopRequireDefault(require("prop-types"));
|
||||
var _clsx = _interopRequireDefault(require("clsx"));
|
||||
var _sliderClasses = _interopRequireDefault(require("./sliderClasses"));
|
||||
var _jsxRuntime = require("react/jsx-runtime");
|
||||
const useValueLabelClasses = props => {
|
||||
const {
|
||||
open
|
||||
} = props;
|
||||
const utilityClasses = {
|
||||
offset: (0, _clsx.default)(open && _sliderClasses.default.valueLabelOpen),
|
||||
circle: _sliderClasses.default.valueLabelCircle,
|
||||
label: _sliderClasses.default.valueLabelLabel
|
||||
};
|
||||
return utilityClasses;
|
||||
};
|
||||
|
||||
/**
|
||||
* @ignore - internal component.
|
||||
*/
|
||||
function SliderValueLabel(props) {
|
||||
const {
|
||||
children,
|
||||
className,
|
||||
value
|
||||
} = props;
|
||||
const classes = useValueLabelClasses(props);
|
||||
if (!children) {
|
||||
return null;
|
||||
}
|
||||
return /*#__PURE__*/React.cloneElement(children, {
|
||||
className: children.props.className
|
||||
}, /*#__PURE__*/(0, _jsxRuntime.jsxs)(React.Fragment, {
|
||||
children: [children.props.children, /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
||||
className: (0, _clsx.default)(classes.offset, className),
|
||||
"aria-hidden": true,
|
||||
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
||||
className: classes.circle,
|
||||
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
||||
className: classes.label,
|
||||
children: value
|
||||
})
|
||||
})
|
||||
})]
|
||||
}));
|
||||
}
|
||||
process.env.NODE_ENV !== "production" ? SliderValueLabel.propTypes = {
|
||||
children: _propTypes.default.element.isRequired,
|
||||
className: _propTypes.default.string,
|
||||
value: _propTypes.default.node
|
||||
} : void 0;
|
||||
25
node_modules/@mui/material/Slider/SliderValueLabel.types.d.ts
generated
vendored
Normal file
25
node_modules/@mui/material/Slider/SliderValueLabel.types.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
export interface SliderValueLabelProps {
|
||||
children?: React.ReactElement<{
|
||||
className?: string;
|
||||
children?: React.ReactNode;
|
||||
}>;
|
||||
className?: string;
|
||||
style?: React.CSSProperties;
|
||||
/**
|
||||
* If `true`, the value label is visible.
|
||||
*/
|
||||
open: boolean;
|
||||
/**
|
||||
* The value of the slider.
|
||||
*/
|
||||
value: React.ReactNode;
|
||||
/**
|
||||
* Controls when the value label is displayed:
|
||||
*
|
||||
* - `auto` the value label will display when the thumb is hovered or focused.
|
||||
* - `on` will display persistently.
|
||||
* - `off` will never display.
|
||||
* @default 'off'
|
||||
*/
|
||||
valueLabelDisplay?: 'on' | 'auto' | 'off';
|
||||
}
|
||||
5
node_modules/@mui/material/Slider/SliderValueLabel.types.js
generated
vendored
Normal file
5
node_modules/@mui/material/Slider/SliderValueLabel.types.js
generated
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
4
node_modules/@mui/material/Slider/index.d.ts
generated
vendored
Normal file
4
node_modules/@mui/material/Slider/index.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
export { default } from "./Slider.js";
|
||||
export * from "./Slider.js";
|
||||
export { default as sliderClasses } from "./sliderClasses.js";
|
||||
export * from "./sliderClasses.js";
|
||||
45
node_modules/@mui/material/Slider/index.js
generated
vendored
Normal file
45
node_modules/@mui/material/Slider/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
"use strict";
|
||||
|
||||
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
var _exportNames = {
|
||||
sliderClasses: true
|
||||
};
|
||||
Object.defineProperty(exports, "default", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _Slider.default;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "sliderClasses", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _sliderClasses.default;
|
||||
}
|
||||
});
|
||||
var _Slider = _interopRequireWildcard(require("./Slider"));
|
||||
Object.keys(_Slider).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
||||
if (key in exports && exports[key] === _Slider[key]) return;
|
||||
Object.defineProperty(exports, key, {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _Slider[key];
|
||||
}
|
||||
});
|
||||
});
|
||||
var _sliderClasses = _interopRequireWildcard(require("./sliderClasses"));
|
||||
Object.keys(_sliderClasses).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
||||
if (key in exports && exports[key] === _sliderClasses[key]) return;
|
||||
Object.defineProperty(exports, key, {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _sliderClasses[key];
|
||||
}
|
||||
});
|
||||
});
|
||||
88
node_modules/@mui/material/Slider/sliderClasses.d.ts
generated
vendored
Normal file
88
node_modules/@mui/material/Slider/sliderClasses.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
export interface SliderClasses {
|
||||
/** Styles applied to the root element. */
|
||||
root: string;
|
||||
/** Styles applied to the root element if `color="primary"`. */
|
||||
colorPrimary: string;
|
||||
/** Styles applied to the root element if `color="secondary"`. */
|
||||
colorSecondary: string;
|
||||
/** Styles applied to the root element if `color="error"`. */
|
||||
colorError: string;
|
||||
/** Styles applied to the root element if `color="info"`. */
|
||||
colorInfo: string;
|
||||
/** Styles applied to the root element if `color="success"`. */
|
||||
colorSuccess: string;
|
||||
/** Styles applied to the root element if `color="warning"`. */
|
||||
colorWarning: string;
|
||||
/** Styles applied to the root element if `marks` is provided with at least one label. */
|
||||
marked: string;
|
||||
/** Styles applied to the root element if `orientation="vertical"`. */
|
||||
vertical: string;
|
||||
/** State class applied to the root and thumb element if `disabled={true}`. */
|
||||
disabled: string;
|
||||
/** State class applied to the root if a thumb is being dragged. */
|
||||
dragging: string;
|
||||
/** Styles applied to the rail element. */
|
||||
rail: string;
|
||||
/** Styles applied to the track element. */
|
||||
track: string;
|
||||
/** Styles applied to the root element if `track={false}`. */
|
||||
trackFalse: string;
|
||||
/** Styles applied to the root element if `track="inverted"`. */
|
||||
trackInverted: string;
|
||||
/** Styles applied to the thumb element. */
|
||||
thumb: string;
|
||||
/** State class applied to the thumb element if it's active. */
|
||||
active: string;
|
||||
/** State class applied to the thumb element if keyboard focused. */
|
||||
focusVisible: string;
|
||||
/** Styles applied to the mark element. */
|
||||
mark: string;
|
||||
/** Styles applied to the mark element if active (depending on the value). */
|
||||
markActive: string;
|
||||
/** Styles applied to the mark label element. */
|
||||
markLabel: string;
|
||||
/** Styles applied to the mark label element if active (depending on the value). */
|
||||
markLabelActive: string;
|
||||
/** Styles applied to the root element if `size="small"`. */
|
||||
sizeSmall: string;
|
||||
/** Styles applied to the thumb element if `color="primary"`.
|
||||
* @deprecated Combine the [.MuiSlider-thumb](/material-ui/api/slider/#slider-classes-thumb) and [.MuiSlider-colorPrimary](/material-ui/api/slider/#slider-classes-colorPrimary) classes instead. See [Migrating from deprecated APIs](/material-ui/migration/migrating-from-deprecated-apis/) for more details.
|
||||
*/
|
||||
thumbColorPrimary: string;
|
||||
/** Styles applied to the thumb element if `color="secondary"`.
|
||||
* @deprecated Combine the [.MuiSlider-thumb](/material-ui/api/slider/#slider-classes-thumb) and [.MuiSlider-colorSecondary](/material-ui/api/slider/#slider-classes-colorSecondary) classes instead. See [Migrating from deprecated APIs](/material-ui/migration/migrating-from-deprecated-apis/) for more details.
|
||||
*/
|
||||
thumbColorSecondary: string;
|
||||
/** Styles applied to the thumb element if `color="error"`.
|
||||
* @deprecated Combine the [.MuiSlider-thumb](/material-ui/api/slider/#slider-classes-thumb) and [.MuiSlider-colorError](/material-ui/api/slider/#slider-classes-colorError) classes instead. See [Migrating from deprecated APIs](/material-ui/migration/migrating-from-deprecated-apis/) for more details.
|
||||
*/
|
||||
thumbColorError: string;
|
||||
/** Styles applied to the thumb element if `color="info"`.
|
||||
* @deprecated Combine the [.MuiSlider-thumb](/material-ui/api/slider/#slider-classes-thumb) and [.MuiSlider-colorInfo](/material-ui/api/slider/#slider-classes-colorInfo) classes instead. See [Migrating from deprecated APIs](/material-ui/migration/migrating-from-deprecated-apis/) for more details.
|
||||
*/
|
||||
thumbColorInfo: string;
|
||||
/** Styles applied to the thumb element if `color="success"`.
|
||||
* @deprecated Combine the [.MuiSlider-thumb](/material-ui/api/slider/#slider-classes-thumb) and [.MuiSlider-colorSuccess](/material-ui/api/slider/#slider-classes-colorSuccess) classes instead. See [Migrating from deprecated APIs](/material-ui/migration/migrating-from-deprecated-apis/) for more details.
|
||||
*/
|
||||
thumbColorSuccess: string;
|
||||
/** Styles applied to the thumb element if `color="warning"`.
|
||||
* @deprecated Combine the [.MuiSlider-thumb](/material-ui/api/slider/#slider-classes-thumb) and [.MuiSlider-colorWarning](/material-ui/api/slider/#slider-classes-colorWarning) classes instead. See [Migrating from deprecated APIs](/material-ui/migration/migrating-from-deprecated-apis/) for more details.
|
||||
*/
|
||||
thumbColorWarning: string;
|
||||
/** Styles applied to the thumb element if `size="small"`.
|
||||
* @deprecated Combine the [.MuiSlider-thumb](/material-ui/api/slider/#slider-classes-thumb) and [.MuiSlider-sizeSmall](/material-ui/api/slider/#slider-classes-sizeSmall) classes instead. See [Migrating from deprecated APIs](/material-ui/migration/migrating-from-deprecated-apis/) for more details.
|
||||
*/
|
||||
thumbSizeSmall: string;
|
||||
/** Styles applied to the thumb label element. */
|
||||
valueLabel: string;
|
||||
/** Styles applied to the thumb label element if it's open. */
|
||||
valueLabelOpen: string;
|
||||
/** Styles applied to the thumb label's circle element. */
|
||||
valueLabelCircle: string;
|
||||
/** Styles applied to the thumb label's label element. */
|
||||
valueLabelLabel: string;
|
||||
}
|
||||
export type SliderClassKey = keyof SliderClasses;
|
||||
export declare function getSliderUtilityClass(slot: string): string;
|
||||
declare const sliderClasses: SliderClasses;
|
||||
export default sliderClasses;
|
||||
15
node_modules/@mui/material/Slider/sliderClasses.js
generated
vendored
Normal file
15
node_modules/@mui/material/Slider/sliderClasses.js
generated
vendored
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
exports.getSliderUtilityClass = getSliderUtilityClass;
|
||||
var _generateUtilityClasses = _interopRequireDefault(require("@mui/utils/generateUtilityClasses"));
|
||||
var _generateUtilityClass = _interopRequireDefault(require("@mui/utils/generateUtilityClass"));
|
||||
function getSliderUtilityClass(slot) {
|
||||
return (0, _generateUtilityClass.default)('MuiSlider', slot);
|
||||
}
|
||||
const sliderClasses = (0, _generateUtilityClasses.default)('MuiSlider', ['root', 'active', 'colorPrimary', 'colorSecondary', 'colorError', 'colorInfo', 'colorSuccess', 'colorWarning', 'disabled', 'dragging', 'focusVisible', 'mark', 'markActive', 'marked', 'markLabel', 'markLabelActive', 'rail', 'sizeSmall', 'thumb', 'thumbColorPrimary', 'thumbColorSecondary', 'thumbColorError', 'thumbColorSuccess', 'thumbColorInfo', 'thumbColorWarning', 'track', 'trackInverted', 'trackFalse', 'thumbSizeSmall', 'valueLabel', 'valueLabelOpen', 'valueLabelCircle', 'valueLabelLabel', 'vertical']);
|
||||
var _default = exports.default = sliderClasses;
|
||||
4
node_modules/@mui/material/Slider/useSlider.d.ts
generated
vendored
Normal file
4
node_modules/@mui/material/Slider/useSlider.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
import { UseSliderParameters, UseSliderReturnValue } from "./useSlider.types.js";
|
||||
export declare function valueToPercent(value: number, min: number, max: number): number;
|
||||
export declare const Identity: (x: any) => any;
|
||||
export declare function useSlider(parameters: UseSliderParameters): UseSliderReturnValue;
|
||||
711
node_modules/@mui/material/Slider/useSlider.js
generated
vendored
Normal file
711
node_modules/@mui/material/Slider/useSlider.js
generated
vendored
Normal file
|
|
@ -0,0 +1,711 @@
|
|||
"use strict";
|
||||
'use client';
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
||||
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.Identity = void 0;
|
||||
exports.useSlider = useSlider;
|
||||
exports.valueToPercent = valueToPercent;
|
||||
var React = _interopRequireWildcard(require("react"));
|
||||
var _ownerDocument = _interopRequireDefault(require("@mui/utils/ownerDocument"));
|
||||
var _useControlled = _interopRequireDefault(require("@mui/utils/useControlled"));
|
||||
var _useEnhancedEffect = _interopRequireDefault(require("@mui/utils/useEnhancedEffect"));
|
||||
var _useEventCallback = _interopRequireDefault(require("@mui/utils/useEventCallback"));
|
||||
var _useForkRef = _interopRequireDefault(require("@mui/utils/useForkRef"));
|
||||
var _isFocusVisible = _interopRequireDefault(require("@mui/utils/isFocusVisible"));
|
||||
var _visuallyHidden = _interopRequireDefault(require("@mui/utils/visuallyHidden"));
|
||||
var _clamp = _interopRequireDefault(require("@mui/utils/clamp"));
|
||||
var _extractEventHandlers = _interopRequireDefault(require("@mui/utils/extractEventHandlers"));
|
||||
var _areArraysEqual = _interopRequireDefault(require("../utils/areArraysEqual"));
|
||||
const INTENTIONAL_DRAG_COUNT_THRESHOLD = 2;
|
||||
function getNewValue(currentValue, step, direction, min, max) {
|
||||
return direction === 1 ? Math.min(currentValue + step, max) : Math.max(currentValue - step, min);
|
||||
}
|
||||
function asc(a, b) {
|
||||
return a - b;
|
||||
}
|
||||
function findClosest(values, currentValue) {
|
||||
const {
|
||||
index: closestIndex
|
||||
} = values.reduce((acc, value, index) => {
|
||||
const distance = Math.abs(currentValue - value);
|
||||
if (acc === null || distance < acc.distance || distance === acc.distance) {
|
||||
return {
|
||||
distance,
|
||||
index
|
||||
};
|
||||
}
|
||||
return acc;
|
||||
}, null) ?? {};
|
||||
return closestIndex;
|
||||
}
|
||||
function trackFinger(event, touchId) {
|
||||
// The event is TouchEvent
|
||||
if (touchId.current !== undefined && event.changedTouches) {
|
||||
const touchEvent = event;
|
||||
for (let i = 0; i < touchEvent.changedTouches.length; i += 1) {
|
||||
const touch = touchEvent.changedTouches[i];
|
||||
if (touch.identifier === touchId.current) {
|
||||
return {
|
||||
x: touch.clientX,
|
||||
y: touch.clientY
|
||||
};
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// The event is MouseEvent
|
||||
return {
|
||||
x: event.clientX,
|
||||
y: event.clientY
|
||||
};
|
||||
}
|
||||
function valueToPercent(value, min, max) {
|
||||
return (value - min) * 100 / (max - min);
|
||||
}
|
||||
function percentToValue(percent, min, max) {
|
||||
return (max - min) * percent + min;
|
||||
}
|
||||
function getDecimalPrecision(num) {
|
||||
// This handles the case when num is very small (0.00000001), js will turn this into 1e-8.
|
||||
// When num is bigger than 1 or less than -1 it won't get converted to this notation so it's fine.
|
||||
if (Math.abs(num) < 1) {
|
||||
const parts = num.toExponential().split('e-');
|
||||
const matissaDecimalPart = parts[0].split('.')[1];
|
||||
return (matissaDecimalPart ? matissaDecimalPart.length : 0) + parseInt(parts[1], 10);
|
||||
}
|
||||
const decimalPart = num.toString().split('.')[1];
|
||||
return decimalPart ? decimalPart.length : 0;
|
||||
}
|
||||
function roundValueToStep(value, step, min) {
|
||||
const nearest = Math.round((value - min) / step) * step + min;
|
||||
return Number(nearest.toFixed(getDecimalPrecision(step)));
|
||||
}
|
||||
function setValueIndex({
|
||||
values,
|
||||
newValue,
|
||||
index
|
||||
}) {
|
||||
const output = values.slice();
|
||||
output[index] = newValue;
|
||||
return output.sort(asc);
|
||||
}
|
||||
function focusThumb({
|
||||
sliderRef,
|
||||
activeIndex,
|
||||
setActive
|
||||
}) {
|
||||
const doc = (0, _ownerDocument.default)(sliderRef.current);
|
||||
if (!sliderRef.current?.contains(doc.activeElement) || Number(doc?.activeElement?.getAttribute('data-index')) !== activeIndex) {
|
||||
sliderRef.current?.querySelector(`[type="range"][data-index="${activeIndex}"]`).focus();
|
||||
}
|
||||
if (setActive) {
|
||||
setActive(activeIndex);
|
||||
}
|
||||
}
|
||||
function areValuesEqual(newValue, oldValue) {
|
||||
if (typeof newValue === 'number' && typeof oldValue === 'number') {
|
||||
return newValue === oldValue;
|
||||
}
|
||||
if (typeof newValue === 'object' && typeof oldValue === 'object') {
|
||||
return (0, _areArraysEqual.default)(newValue, oldValue);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
const axisProps = {
|
||||
horizontal: {
|
||||
offset: percent => ({
|
||||
left: `${percent}%`
|
||||
}),
|
||||
leap: percent => ({
|
||||
width: `${percent}%`
|
||||
})
|
||||
},
|
||||
'horizontal-reverse': {
|
||||
offset: percent => ({
|
||||
right: `${percent}%`
|
||||
}),
|
||||
leap: percent => ({
|
||||
width: `${percent}%`
|
||||
})
|
||||
},
|
||||
vertical: {
|
||||
offset: percent => ({
|
||||
bottom: `${percent}%`
|
||||
}),
|
||||
leap: percent => ({
|
||||
height: `${percent}%`
|
||||
})
|
||||
}
|
||||
};
|
||||
const Identity = x => x;
|
||||
|
||||
// TODO: remove support for Safari < 13.
|
||||
// https://caniuse.com/#search=touch-action
|
||||
//
|
||||
// Safari, on iOS, supports touch action since v13.
|
||||
// Over 80% of the iOS phones are compatible
|
||||
// in August 2020.
|
||||
// Utilizing the CSS.supports method to check if touch-action is supported.
|
||||
// Since CSS.supports is supported on all but Edge@12 and IE and touch-action
|
||||
// is supported on both Edge@12 and IE if CSS.supports is not available that means that
|
||||
// touch-action will be supported
|
||||
exports.Identity = Identity;
|
||||
let cachedSupportsTouchActionNone;
|
||||
function doesSupportTouchActionNone() {
|
||||
if (cachedSupportsTouchActionNone === undefined) {
|
||||
if (typeof CSS !== 'undefined' && typeof CSS.supports === 'function') {
|
||||
cachedSupportsTouchActionNone = CSS.supports('touch-action', 'none');
|
||||
} else {
|
||||
cachedSupportsTouchActionNone = true;
|
||||
}
|
||||
}
|
||||
return cachedSupportsTouchActionNone;
|
||||
}
|
||||
function useSlider(parameters) {
|
||||
const {
|
||||
'aria-labelledby': ariaLabelledby,
|
||||
defaultValue,
|
||||
disabled = false,
|
||||
disableSwap = false,
|
||||
isRtl = false,
|
||||
marks: marksProp = false,
|
||||
max = 100,
|
||||
min = 0,
|
||||
name,
|
||||
onChange,
|
||||
onChangeCommitted,
|
||||
orientation = 'horizontal',
|
||||
rootRef: ref,
|
||||
scale = Identity,
|
||||
step = 1,
|
||||
shiftStep = 10,
|
||||
tabIndex,
|
||||
value: valueProp
|
||||
} = parameters;
|
||||
const touchId = React.useRef(undefined);
|
||||
// We can't use the :active browser pseudo-classes.
|
||||
// - The active state isn't triggered when clicking on the rail.
|
||||
// - The active state isn't transferred when inversing a range slider.
|
||||
const [active, setActive] = React.useState(-1);
|
||||
const [open, setOpen] = React.useState(-1);
|
||||
const [dragging, setDragging] = React.useState(false);
|
||||
const moveCount = React.useRef(0);
|
||||
// lastChangedValue is updated whenever onChange is triggered.
|
||||
const lastChangedValue = React.useRef(null);
|
||||
const [valueDerived, setValueState] = (0, _useControlled.default)({
|
||||
controlled: valueProp,
|
||||
default: defaultValue ?? min,
|
||||
name: 'Slider'
|
||||
});
|
||||
const handleChange = onChange && ((event, value, thumbIndex) => {
|
||||
// Redefine target to allow name and value to be read.
|
||||
// This allows seamless integration with the most popular form libraries.
|
||||
// https://github.com/mui/material-ui/issues/13485#issuecomment-676048492
|
||||
// Clone the event to not override `target` of the original event.
|
||||
const nativeEvent = event.nativeEvent || event;
|
||||
// @ts-ignore The nativeEvent is function, not object
|
||||
const clonedEvent = new nativeEvent.constructor(nativeEvent.type, nativeEvent);
|
||||
Object.defineProperty(clonedEvent, 'target', {
|
||||
writable: true,
|
||||
value: {
|
||||
value,
|
||||
name
|
||||
}
|
||||
});
|
||||
lastChangedValue.current = value;
|
||||
onChange(clonedEvent, value, thumbIndex);
|
||||
});
|
||||
const range = Array.isArray(valueDerived);
|
||||
let values = range ? valueDerived.slice().sort(asc) : [valueDerived];
|
||||
values = values.map(value => value == null ? min : (0, _clamp.default)(value, min, max));
|
||||
const marks = marksProp === true && step !== null ? [...Array(Math.floor((max - min) / step) + 1)].map((_, index) => ({
|
||||
value: min + step * index
|
||||
})) : marksProp || [];
|
||||
const marksValues = marks.map(mark => mark.value);
|
||||
const [focusedThumbIndex, setFocusedThumbIndex] = React.useState(-1);
|
||||
const sliderRef = React.useRef(null);
|
||||
const handleRef = (0, _useForkRef.default)(ref, sliderRef);
|
||||
const createHandleHiddenInputFocus = otherHandlers => event => {
|
||||
const index = Number(event.currentTarget.getAttribute('data-index'));
|
||||
if ((0, _isFocusVisible.default)(event.target)) {
|
||||
setFocusedThumbIndex(index);
|
||||
}
|
||||
setOpen(index);
|
||||
otherHandlers?.onFocus?.(event);
|
||||
};
|
||||
const createHandleHiddenInputBlur = otherHandlers => event => {
|
||||
if (!(0, _isFocusVisible.default)(event.target)) {
|
||||
setFocusedThumbIndex(-1);
|
||||
}
|
||||
setOpen(-1);
|
||||
otherHandlers?.onBlur?.(event);
|
||||
};
|
||||
const changeValue = (event, valueInput) => {
|
||||
const index = Number(event.currentTarget.getAttribute('data-index'));
|
||||
const value = values[index];
|
||||
const marksIndex = marksValues.indexOf(value);
|
||||
let newValue = valueInput;
|
||||
if (marks && step == null) {
|
||||
const maxMarksValue = marksValues[marksValues.length - 1];
|
||||
if (newValue >= maxMarksValue) {
|
||||
newValue = maxMarksValue;
|
||||
} else if (newValue <= marksValues[0]) {
|
||||
newValue = marksValues[0];
|
||||
} else {
|
||||
newValue = newValue < value ? marksValues[marksIndex - 1] : marksValues[marksIndex + 1];
|
||||
}
|
||||
}
|
||||
newValue = (0, _clamp.default)(newValue, min, max);
|
||||
if (range) {
|
||||
// Bound the new value to the thumb's neighbours.
|
||||
if (disableSwap) {
|
||||
newValue = (0, _clamp.default)(newValue, values[index - 1] || -Infinity, values[index + 1] || Infinity);
|
||||
}
|
||||
const previousValue = newValue;
|
||||
newValue = setValueIndex({
|
||||
values,
|
||||
newValue,
|
||||
index
|
||||
});
|
||||
let activeIndex = index;
|
||||
|
||||
// Potentially swap the index if needed.
|
||||
if (!disableSwap) {
|
||||
activeIndex = newValue.indexOf(previousValue);
|
||||
}
|
||||
focusThumb({
|
||||
sliderRef,
|
||||
activeIndex
|
||||
});
|
||||
}
|
||||
setValueState(newValue);
|
||||
setFocusedThumbIndex(index);
|
||||
if (handleChange && !areValuesEqual(newValue, valueDerived)) {
|
||||
handleChange(event, newValue, index);
|
||||
}
|
||||
if (onChangeCommitted) {
|
||||
onChangeCommitted(event, lastChangedValue.current ?? newValue);
|
||||
}
|
||||
};
|
||||
const createHandleHiddenInputKeyDown = otherHandlers => event => {
|
||||
if (['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight', 'PageUp', 'PageDown', 'Home', 'End'].includes(event.key)) {
|
||||
event.preventDefault();
|
||||
const index = Number(event.currentTarget.getAttribute('data-index'));
|
||||
const value = values[index];
|
||||
let newValue = null;
|
||||
// Keys actions that change the value by more than the most granular `step`
|
||||
// value are only applied if the step not `null`.
|
||||
// When step is `null`, the `marks` prop is used instead to define valid values.
|
||||
if (step != null) {
|
||||
const stepSize = event.shiftKey ? shiftStep : step;
|
||||
switch (event.key) {
|
||||
case 'ArrowUp':
|
||||
newValue = getNewValue(value, stepSize, 1, min, max);
|
||||
break;
|
||||
case 'ArrowRight':
|
||||
newValue = getNewValue(value, stepSize, isRtl ? -1 : 1, min, max);
|
||||
break;
|
||||
case 'ArrowDown':
|
||||
newValue = getNewValue(value, stepSize, -1, min, max);
|
||||
break;
|
||||
case 'ArrowLeft':
|
||||
newValue = getNewValue(value, stepSize, isRtl ? 1 : -1, min, max);
|
||||
break;
|
||||
case 'PageUp':
|
||||
newValue = getNewValue(value, shiftStep, 1, min, max);
|
||||
break;
|
||||
case 'PageDown':
|
||||
newValue = getNewValue(value, shiftStep, -1, min, max);
|
||||
break;
|
||||
case 'Home':
|
||||
newValue = min;
|
||||
break;
|
||||
case 'End':
|
||||
newValue = max;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} else if (marks) {
|
||||
const maxMarksValue = marksValues[marksValues.length - 1];
|
||||
const currentMarkIndex = marksValues.indexOf(value);
|
||||
const decrementKeys = [isRtl ? 'ArrowRight' : 'ArrowLeft', 'ArrowDown', 'PageDown', 'Home'];
|
||||
const incrementKeys = [isRtl ? 'ArrowLeft' : 'ArrowRight', 'ArrowUp', 'PageUp', 'End'];
|
||||
if (decrementKeys.includes(event.key)) {
|
||||
if (currentMarkIndex === 0) {
|
||||
newValue = marksValues[0];
|
||||
} else {
|
||||
newValue = marksValues[currentMarkIndex - 1];
|
||||
}
|
||||
} else if (incrementKeys.includes(event.key)) {
|
||||
if (currentMarkIndex === marksValues.length - 1) {
|
||||
newValue = maxMarksValue;
|
||||
} else {
|
||||
newValue = marksValues[currentMarkIndex + 1];
|
||||
}
|
||||
}
|
||||
}
|
||||
if (newValue != null) {
|
||||
changeValue(event, newValue);
|
||||
}
|
||||
}
|
||||
otherHandlers?.onKeyDown?.(event);
|
||||
};
|
||||
(0, _useEnhancedEffect.default)(() => {
|
||||
if (disabled && sliderRef.current.contains(document.activeElement)) {
|
||||
// This is necessary because Firefox and Safari will keep focus
|
||||
// on a disabled element:
|
||||
// https://codesandbox.io/p/sandbox/mui-pr-22247-forked-h151h?file=/src/App.js
|
||||
// @ts-ignore
|
||||
document.activeElement?.blur();
|
||||
}
|
||||
}, [disabled]);
|
||||
if (disabled && active !== -1) {
|
||||
setActive(-1);
|
||||
}
|
||||
if (disabled && focusedThumbIndex !== -1) {
|
||||
setFocusedThumbIndex(-1);
|
||||
}
|
||||
const createHandleHiddenInputChange = otherHandlers => event => {
|
||||
otherHandlers.onChange?.(event);
|
||||
// this handles value change by Pointer or Touch events
|
||||
// @ts-ignore
|
||||
changeValue(event, event.target.valueAsNumber);
|
||||
};
|
||||
const previousIndex = React.useRef(undefined);
|
||||
let axis = orientation;
|
||||
if (isRtl && orientation === 'horizontal') {
|
||||
axis += '-reverse';
|
||||
}
|
||||
const getFingerNewValue = ({
|
||||
finger,
|
||||
move = false
|
||||
}) => {
|
||||
const {
|
||||
current: slider
|
||||
} = sliderRef;
|
||||
const {
|
||||
width,
|
||||
height,
|
||||
bottom,
|
||||
left
|
||||
} = slider.getBoundingClientRect();
|
||||
let percent;
|
||||
if (axis.startsWith('vertical')) {
|
||||
percent = (bottom - finger.y) / height;
|
||||
} else {
|
||||
percent = (finger.x - left) / width;
|
||||
}
|
||||
if (axis.includes('-reverse')) {
|
||||
percent = 1 - percent;
|
||||
}
|
||||
let newValue;
|
||||
newValue = percentToValue(percent, min, max);
|
||||
if (step) {
|
||||
newValue = roundValueToStep(newValue, step, min);
|
||||
} else {
|
||||
const closestIndex = findClosest(marksValues, newValue);
|
||||
newValue = marksValues[closestIndex];
|
||||
}
|
||||
newValue = (0, _clamp.default)(newValue, min, max);
|
||||
let activeIndex = 0;
|
||||
if (range) {
|
||||
if (!move) {
|
||||
activeIndex = findClosest(values, newValue);
|
||||
} else {
|
||||
activeIndex = previousIndex.current;
|
||||
}
|
||||
|
||||
// Bound the new value to the thumb's neighbours.
|
||||
if (disableSwap) {
|
||||
newValue = (0, _clamp.default)(newValue, values[activeIndex - 1] || -Infinity, values[activeIndex + 1] || Infinity);
|
||||
}
|
||||
const previousValue = newValue;
|
||||
newValue = setValueIndex({
|
||||
values,
|
||||
newValue,
|
||||
index: activeIndex
|
||||
});
|
||||
|
||||
// Potentially swap the index if needed.
|
||||
if (!(disableSwap && move)) {
|
||||
activeIndex = newValue.indexOf(previousValue);
|
||||
previousIndex.current = activeIndex;
|
||||
}
|
||||
}
|
||||
return {
|
||||
newValue,
|
||||
activeIndex
|
||||
};
|
||||
};
|
||||
const handleTouchMove = (0, _useEventCallback.default)(nativeEvent => {
|
||||
const finger = trackFinger(nativeEvent, touchId);
|
||||
if (!finger) {
|
||||
return;
|
||||
}
|
||||
moveCount.current += 1;
|
||||
|
||||
// Cancel move in case some other element consumed a mouseup event and it was not fired.
|
||||
// @ts-ignore buttons doesn't not exists on touch event
|
||||
if (nativeEvent.type === 'mousemove' && nativeEvent.buttons === 0) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
||||
handleTouchEnd(nativeEvent);
|
||||
return;
|
||||
}
|
||||
const {
|
||||
newValue,
|
||||
activeIndex
|
||||
} = getFingerNewValue({
|
||||
finger,
|
||||
move: true
|
||||
});
|
||||
focusThumb({
|
||||
sliderRef,
|
||||
activeIndex,
|
||||
setActive
|
||||
});
|
||||
setValueState(newValue);
|
||||
if (!dragging && moveCount.current > INTENTIONAL_DRAG_COUNT_THRESHOLD) {
|
||||
setDragging(true);
|
||||
}
|
||||
if (handleChange && !areValuesEqual(newValue, valueDerived)) {
|
||||
handleChange(nativeEvent, newValue, activeIndex);
|
||||
}
|
||||
});
|
||||
const handleTouchEnd = (0, _useEventCallback.default)(nativeEvent => {
|
||||
const finger = trackFinger(nativeEvent, touchId);
|
||||
setDragging(false);
|
||||
if (!finger) {
|
||||
return;
|
||||
}
|
||||
const {
|
||||
newValue
|
||||
} = getFingerNewValue({
|
||||
finger,
|
||||
move: true
|
||||
});
|
||||
setActive(-1);
|
||||
if (nativeEvent.type === 'touchend') {
|
||||
setOpen(-1);
|
||||
}
|
||||
if (onChangeCommitted) {
|
||||
onChangeCommitted(nativeEvent, lastChangedValue.current ?? newValue);
|
||||
}
|
||||
touchId.current = undefined;
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
||||
stopListening();
|
||||
});
|
||||
const handleTouchStart = (0, _useEventCallback.default)(nativeEvent => {
|
||||
if (disabled) {
|
||||
return;
|
||||
}
|
||||
// If touch-action: none; is not supported we need to prevent the scroll manually.
|
||||
if (!doesSupportTouchActionNone()) {
|
||||
nativeEvent.preventDefault();
|
||||
}
|
||||
const touch = nativeEvent.changedTouches[0];
|
||||
if (touch != null) {
|
||||
// A number that uniquely identifies the current finger in the touch session.
|
||||
touchId.current = touch.identifier;
|
||||
}
|
||||
const finger = trackFinger(nativeEvent, touchId);
|
||||
if (finger !== false) {
|
||||
const {
|
||||
newValue,
|
||||
activeIndex
|
||||
} = getFingerNewValue({
|
||||
finger
|
||||
});
|
||||
focusThumb({
|
||||
sliderRef,
|
||||
activeIndex,
|
||||
setActive
|
||||
});
|
||||
setValueState(newValue);
|
||||
if (handleChange && !areValuesEqual(newValue, valueDerived)) {
|
||||
handleChange(nativeEvent, newValue, activeIndex);
|
||||
}
|
||||
}
|
||||
moveCount.current = 0;
|
||||
const doc = (0, _ownerDocument.default)(sliderRef.current);
|
||||
doc.addEventListener('touchmove', handleTouchMove, {
|
||||
passive: true
|
||||
});
|
||||
doc.addEventListener('touchend', handleTouchEnd, {
|
||||
passive: true
|
||||
});
|
||||
});
|
||||
const stopListening = React.useCallback(() => {
|
||||
const doc = (0, _ownerDocument.default)(sliderRef.current);
|
||||
doc.removeEventListener('mousemove', handleTouchMove);
|
||||
doc.removeEventListener('mouseup', handleTouchEnd);
|
||||
doc.removeEventListener('touchmove', handleTouchMove);
|
||||
doc.removeEventListener('touchend', handleTouchEnd);
|
||||
}, [handleTouchEnd, handleTouchMove]);
|
||||
React.useEffect(() => {
|
||||
const {
|
||||
current: slider
|
||||
} = sliderRef;
|
||||
slider.addEventListener('touchstart', handleTouchStart, {
|
||||
passive: doesSupportTouchActionNone()
|
||||
});
|
||||
return () => {
|
||||
slider.removeEventListener('touchstart', handleTouchStart);
|
||||
stopListening();
|
||||
};
|
||||
}, [stopListening, handleTouchStart]);
|
||||
React.useEffect(() => {
|
||||
if (disabled) {
|
||||
stopListening();
|
||||
}
|
||||
}, [disabled, stopListening]);
|
||||
const createHandleMouseDown = otherHandlers => event => {
|
||||
otherHandlers.onMouseDown?.(event);
|
||||
if (disabled) {
|
||||
return;
|
||||
}
|
||||
if (event.defaultPrevented) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Only handle left clicks
|
||||
if (event.button !== 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Avoid text selection
|
||||
event.preventDefault();
|
||||
const finger = trackFinger(event, touchId);
|
||||
if (finger !== false) {
|
||||
const {
|
||||
newValue,
|
||||
activeIndex
|
||||
} = getFingerNewValue({
|
||||
finger
|
||||
});
|
||||
focusThumb({
|
||||
sliderRef,
|
||||
activeIndex,
|
||||
setActive
|
||||
});
|
||||
setValueState(newValue);
|
||||
if (handleChange && !areValuesEqual(newValue, valueDerived)) {
|
||||
handleChange(event, newValue, activeIndex);
|
||||
}
|
||||
}
|
||||
moveCount.current = 0;
|
||||
const doc = (0, _ownerDocument.default)(sliderRef.current);
|
||||
doc.addEventListener('mousemove', handleTouchMove, {
|
||||
passive: true
|
||||
});
|
||||
doc.addEventListener('mouseup', handleTouchEnd);
|
||||
};
|
||||
const trackOffset = valueToPercent(range ? values[0] : min, min, max);
|
||||
const trackLeap = valueToPercent(values[values.length - 1], min, max) - trackOffset;
|
||||
const getRootProps = (externalProps = {}) => {
|
||||
const externalHandlers = (0, _extractEventHandlers.default)(externalProps);
|
||||
const ownEventHandlers = {
|
||||
onMouseDown: createHandleMouseDown(externalHandlers || {})
|
||||
};
|
||||
const mergedEventHandlers = {
|
||||
...externalHandlers,
|
||||
...ownEventHandlers
|
||||
};
|
||||
return {
|
||||
...externalProps,
|
||||
ref: handleRef,
|
||||
...mergedEventHandlers
|
||||
};
|
||||
};
|
||||
const createHandleMouseOver = otherHandlers => event => {
|
||||
otherHandlers.onMouseOver?.(event);
|
||||
const index = Number(event.currentTarget.getAttribute('data-index'));
|
||||
setOpen(index);
|
||||
};
|
||||
const createHandleMouseLeave = otherHandlers => event => {
|
||||
otherHandlers.onMouseLeave?.(event);
|
||||
setOpen(-1);
|
||||
};
|
||||
const getThumbProps = (externalProps = {}) => {
|
||||
const externalHandlers = (0, _extractEventHandlers.default)(externalProps);
|
||||
const ownEventHandlers = {
|
||||
onMouseOver: createHandleMouseOver(externalHandlers || {}),
|
||||
onMouseLeave: createHandleMouseLeave(externalHandlers || {})
|
||||
};
|
||||
return {
|
||||
...externalProps,
|
||||
...externalHandlers,
|
||||
...ownEventHandlers
|
||||
};
|
||||
};
|
||||
const getThumbStyle = index => {
|
||||
return {
|
||||
// So the non active thumb doesn't show its label on hover.
|
||||
pointerEvents: active !== -1 && active !== index ? 'none' : undefined
|
||||
};
|
||||
};
|
||||
let cssWritingMode;
|
||||
if (orientation === 'vertical') {
|
||||
cssWritingMode = isRtl ? 'vertical-rl' : 'vertical-lr';
|
||||
}
|
||||
const getHiddenInputProps = (externalProps = {}) => {
|
||||
const externalHandlers = (0, _extractEventHandlers.default)(externalProps);
|
||||
const ownEventHandlers = {
|
||||
onChange: createHandleHiddenInputChange(externalHandlers || {}),
|
||||
onFocus: createHandleHiddenInputFocus(externalHandlers || {}),
|
||||
onBlur: createHandleHiddenInputBlur(externalHandlers || {}),
|
||||
onKeyDown: createHandleHiddenInputKeyDown(externalHandlers || {})
|
||||
};
|
||||
const mergedEventHandlers = {
|
||||
...externalHandlers,
|
||||
...ownEventHandlers
|
||||
};
|
||||
return {
|
||||
tabIndex,
|
||||
'aria-labelledby': ariaLabelledby,
|
||||
'aria-orientation': orientation,
|
||||
'aria-valuemax': scale(max),
|
||||
'aria-valuemin': scale(min),
|
||||
name,
|
||||
type: 'range',
|
||||
min: parameters.min,
|
||||
max: parameters.max,
|
||||
step: parameters.step === null && parameters.marks ? 'any' : parameters.step ?? undefined,
|
||||
disabled,
|
||||
...externalProps,
|
||||
...mergedEventHandlers,
|
||||
style: {
|
||||
..._visuallyHidden.default,
|
||||
direction: isRtl ? 'rtl' : 'ltr',
|
||||
// So that VoiceOver's focus indicator matches the thumb's dimensions
|
||||
width: '100%',
|
||||
height: '100%',
|
||||
writingMode: cssWritingMode
|
||||
}
|
||||
};
|
||||
};
|
||||
return {
|
||||
active,
|
||||
axis: axis,
|
||||
axisProps,
|
||||
dragging,
|
||||
focusedThumbIndex,
|
||||
getHiddenInputProps,
|
||||
getRootProps,
|
||||
getThumbProps,
|
||||
marks: marks,
|
||||
open,
|
||||
range,
|
||||
rootRef: handleRef,
|
||||
trackLeap,
|
||||
trackOffset,
|
||||
values,
|
||||
getThumbStyle
|
||||
};
|
||||
}
|
||||
226
node_modules/@mui/material/Slider/useSlider.types.d.ts
generated
vendored
Normal file
226
node_modules/@mui/material/Slider/useSlider.types.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,226 @@
|
|||
import * as React from 'react';
|
||||
export interface UseSliderParameters {
|
||||
/**
|
||||
* The id of the element containing a label for the slider.
|
||||
*/
|
||||
'aria-labelledby'?: string;
|
||||
/**
|
||||
* The default value. Use when the component is not controlled.
|
||||
*/
|
||||
defaultValue?: number | ReadonlyArray<number>;
|
||||
/**
|
||||
* If `true`, the component is disabled.
|
||||
* @default false
|
||||
*/
|
||||
disabled?: boolean;
|
||||
/**
|
||||
* If `true`, the active thumb doesn't swap when moving pointer over a thumb while dragging another thumb.
|
||||
* @default false
|
||||
*/
|
||||
disableSwap?: boolean;
|
||||
/**
|
||||
* If `true` the Slider will be rendered right-to-left (with the lowest value on the right-hand side).
|
||||
* @default false
|
||||
*/
|
||||
isRtl?: boolean;
|
||||
/**
|
||||
* Marks indicate predetermined values to which the user can move the slider.
|
||||
* If `true` the marks are spaced according the value of the `step` prop.
|
||||
* If an array, it should contain objects with `value` and an optional `label` keys.
|
||||
* @default false
|
||||
*/
|
||||
marks?: boolean | ReadonlyArray<Mark>;
|
||||
/**
|
||||
* The maximum allowed value of the slider.
|
||||
* Should not be equal to min.
|
||||
* @default 100
|
||||
*/
|
||||
max?: number;
|
||||
/**
|
||||
* The minimum allowed value of the slider.
|
||||
* Should not be equal to max.
|
||||
* @default 0
|
||||
*/
|
||||
min?: number;
|
||||
/**
|
||||
* Name attribute of the hidden `input` element.
|
||||
*/
|
||||
name?: string;
|
||||
/**
|
||||
* Callback function that is fired when the slider's value changed.
|
||||
*
|
||||
* @param {Event} event The event source of the callback.
|
||||
* You can pull out the new value by accessing `event.target.value` (any).
|
||||
* **Warning**: This is a generic event not a change event.
|
||||
* @param {number | number[]} value The new value.
|
||||
* @param {number} activeThumb Index of the currently moved thumb.
|
||||
*/
|
||||
onChange?: (event: Event, value: number | number[], activeThumb: number) => void;
|
||||
/**
|
||||
* Callback function that is fired when the `mouseup` is triggered.
|
||||
*
|
||||
* @param {React.SyntheticEvent | Event} event The event source of the callback. **Warning**: This is a generic event not a change event.
|
||||
* @param {number | number[]} value The new value.
|
||||
*/
|
||||
onChangeCommitted?: (event: React.SyntheticEvent | Event, value: number | number[]) => void;
|
||||
/**
|
||||
* The component orientation.
|
||||
* @default 'horizontal'
|
||||
*/
|
||||
orientation?: 'horizontal' | 'vertical';
|
||||
/**
|
||||
* The ref attached to the root of the Slider.
|
||||
*/
|
||||
rootRef?: React.Ref<Element>;
|
||||
/**
|
||||
* A transformation function, to change the scale of the slider.
|
||||
* @param {any} x
|
||||
* @returns {any}
|
||||
* @default function Identity(x) {
|
||||
* return x;
|
||||
* }
|
||||
*/
|
||||
scale?: (value: number) => number;
|
||||
/**
|
||||
* The granularity with which the slider can step through values when using Page Up/Page Down or Shift + Arrow Up/Arrow Down.
|
||||
* @default 10
|
||||
*/
|
||||
shiftStep?: number;
|
||||
/**
|
||||
* The granularity with which the slider can step through values. (A "discrete" slider.)
|
||||
* The `min` prop serves as the origin for the valid values.
|
||||
* We recommend (max - min) to be evenly divisible by the step.
|
||||
*
|
||||
* When step is `null`, the thumb can only be slid onto marks provided with the `marks` prop.
|
||||
* @default 1
|
||||
*/
|
||||
step?: number | null;
|
||||
/**
|
||||
* Tab index attribute of the hidden `input` element.
|
||||
*/
|
||||
tabIndex?: number;
|
||||
/**
|
||||
* The value of the slider.
|
||||
* For ranged sliders, provide an array with two values.
|
||||
*/
|
||||
value?: number | ReadonlyArray<number>;
|
||||
}
|
||||
export interface Mark {
|
||||
value: number;
|
||||
label?: React.ReactNode;
|
||||
}
|
||||
export type UseSliderRootSlotOwnProps = {
|
||||
onMouseDown: React.MouseEventHandler;
|
||||
ref: React.RefCallback<Element> | null;
|
||||
};
|
||||
export type UseSliderRootSlotProps<ExternalProps = {}> = Omit<ExternalProps, keyof UseSliderRootSlotOwnProps> & UseSliderRootSlotOwnProps;
|
||||
export type UseSliderThumbSlotOwnProps = {
|
||||
onMouseLeave: React.MouseEventHandler;
|
||||
onMouseOver: React.MouseEventHandler;
|
||||
};
|
||||
export type UseSliderThumbSlotProps<ExternalProps = {}> = Omit<ExternalProps, keyof UseSliderThumbSlotOwnProps> & UseSliderThumbSlotOwnProps;
|
||||
export type UseSliderHiddenInputOwnProps = {
|
||||
'aria-labelledby'?: string;
|
||||
'aria-orientation'?: React.AriaAttributes['aria-orientation'];
|
||||
'aria-valuemax'?: React.AriaAttributes['aria-valuemax'];
|
||||
'aria-valuemin'?: React.AriaAttributes['aria-valuemin'];
|
||||
disabled: boolean;
|
||||
name?: string;
|
||||
onBlur: React.FocusEventHandler;
|
||||
onChange: React.ChangeEventHandler;
|
||||
onFocus: React.FocusEventHandler;
|
||||
step?: number | 'any';
|
||||
style: React.CSSProperties;
|
||||
tabIndex?: number;
|
||||
type?: React.InputHTMLAttributes<HTMLInputElement>['type'];
|
||||
};
|
||||
export type UseSliderHiddenInputProps<ExternalProps = {}> = Omit<ExternalProps, keyof UseSliderHiddenInputOwnProps> & UseSliderHiddenInputOwnProps;
|
||||
export type Axis = 'horizontal' | 'vertical' | 'horizontal-reverse';
|
||||
export interface AxisProps<T extends Axis> {
|
||||
offset: (percent: number) => T extends 'horizontal' ? {
|
||||
left: string;
|
||||
} : T extends 'vertical' ? {
|
||||
bottom: string;
|
||||
} : T extends 'horizontal-reverse' ? {
|
||||
right: string;
|
||||
} : never;
|
||||
leap: (percent: number) => T extends 'horizontal' | 'horizontal-reverse' ? {
|
||||
width: string;
|
||||
} : T extends 'vertical' ? {
|
||||
height: string;
|
||||
} : never;
|
||||
}
|
||||
export interface UseSliderReturnValue {
|
||||
/**
|
||||
* The active index of the slider.
|
||||
*/
|
||||
active: number;
|
||||
/**
|
||||
* The orientation of the slider.
|
||||
*/
|
||||
axis: Axis;
|
||||
/**
|
||||
* Returns the `offset` and `leap` methods to calculate the positioning styles based on the slider axis.
|
||||
*/
|
||||
axisProps: { [key in Axis]: AxisProps<key> };
|
||||
/**
|
||||
* If `true`, the slider is being dragged.
|
||||
*/
|
||||
dragging: boolean;
|
||||
/**
|
||||
* The index of the thumb which is focused on the slider.
|
||||
*/
|
||||
focusedThumbIndex: number;
|
||||
/**
|
||||
* Resolver for the hidden input slot's props.
|
||||
* @param externalProps props for the hidden input slot
|
||||
* @returns props that should be spread on the hidden input slot
|
||||
*/
|
||||
getHiddenInputProps: <ExternalProps extends Record<string, unknown> = {}>(externalProps?: ExternalProps) => UseSliderHiddenInputProps<ExternalProps>;
|
||||
/**
|
||||
* Resolver for the root slot's props.
|
||||
* @param externalProps props for the root slot
|
||||
* @returns props that should be spread on the root slot
|
||||
*/
|
||||
getRootProps: <ExternalProps extends Record<string, unknown> = {}>(externalProps?: ExternalProps) => UseSliderRootSlotProps<ExternalProps>;
|
||||
/**
|
||||
* Resolver for the thumb slot's props.
|
||||
* @param externalProps props for the thumb slot
|
||||
* @returns props that should be spread on the thumb slot
|
||||
*/
|
||||
getThumbProps: <ExternalProps extends Record<string, unknown> = {}>(externalProps?: ExternalProps) => UseSliderThumbSlotProps<ExternalProps>;
|
||||
/**
|
||||
* Resolver for the thumb slot's style prop.
|
||||
* @param index of the currently moved thumb
|
||||
* @returns props that should be spread on the style prop of thumb slot
|
||||
*/
|
||||
getThumbStyle: (index: number) => object;
|
||||
/**
|
||||
* The marks of the slider. Marks indicate predetermined values to which the user can move the slider.
|
||||
*/
|
||||
marks: Mark[];
|
||||
/**
|
||||
* The thumb index for the current value when in hover state.
|
||||
*/
|
||||
open: number;
|
||||
/**
|
||||
* If `true`, the slider is a range slider when the `value` prop passed is an array.
|
||||
*/
|
||||
range: boolean;
|
||||
/**
|
||||
* Ref to the root slot's DOM node.
|
||||
*/
|
||||
rootRef: React.RefCallback<Element> | null;
|
||||
/**
|
||||
* The track leap for the current value of the slider.
|
||||
*/
|
||||
trackLeap: number;
|
||||
/**
|
||||
* The track offset for the current value of the slider.
|
||||
*/
|
||||
trackOffset: number;
|
||||
/**
|
||||
* The possible values of the slider.
|
||||
*/
|
||||
values: number[];
|
||||
}
|
||||
5
node_modules/@mui/material/Slider/useSlider.types.js
generated
vendored
Normal file
5
node_modules/@mui/material/Slider/useSlider.types.js
generated
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue