Added Statistics calculation
Statistics now show calculated values
This commit is contained in:
parent
fe87374e47
commit
fc0f69dacb
2147 changed files with 141321 additions and 39 deletions
143
node_modules/@mui/x-date-pickers/internals/components/PickerFieldUI.d.ts
generated
vendored
Normal file
143
node_modules/@mui/x-date-pickers/internals/components/PickerFieldUI.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,143 @@
|
|||
import * as React from 'react';
|
||||
import { TextFieldProps } from '@mui/material/TextField';
|
||||
import { IconButtonProps } from '@mui/material/IconButton';
|
||||
import { InputAdornmentProps } from '@mui/material/InputAdornment';
|
||||
import { SvgIconProps } from '@mui/material/SvgIcon';
|
||||
import { MakeOptional, SlotComponentPropsFromProps } from '@mui/x-internals/types';
|
||||
import { FieldOwnerState } from "../../models/index.js";
|
||||
import { UseFieldOwnerStateParameters } from "../hooks/useFieldOwnerState.js";
|
||||
import type { UseFieldReturnValue, UseFieldProps } from "../hooks/useField/index.js";
|
||||
import { PickersTextFieldProps } from "../../PickersTextField/index.js";
|
||||
export declare const cleanFieldResponse: <TFieldResponse extends MakeOptional<UseFieldReturnValue<any, ExportedPickerFieldUIProps & {
|
||||
[key: string]: any;
|
||||
}>, "onClear" | "clearable">>({
|
||||
enableAccessibleFieldDOMStructure,
|
||||
...fieldResponse
|
||||
}: TFieldResponse) => ExportedPickerFieldUIProps & {
|
||||
openPickerAriaLabel: string;
|
||||
textFieldProps: TextFieldProps | PickersTextFieldProps;
|
||||
};
|
||||
export declare const PickerFieldUIContext: React.Context<PickerFieldUIContextValue>;
|
||||
/**
|
||||
* Adds the button to open the Picker and the button to clear the value of the field.
|
||||
* @ignore - internal component.
|
||||
*/
|
||||
export declare function PickerFieldUI<TEnableAccessibleFieldDOMStructure extends boolean, TProps extends UseFieldProps<TEnableAccessibleFieldDOMStructure>>(props: PickerFieldUIProps<TEnableAccessibleFieldDOMStructure, TProps>): React.JSX.Element;
|
||||
export interface ExportedPickerFieldUIProps {
|
||||
/**
|
||||
* If `true`, a clear button will be shown in the field allowing value clearing.
|
||||
* @default false
|
||||
*/
|
||||
clearable?: boolean;
|
||||
/**
|
||||
* Callback fired when the clear button is clicked.
|
||||
*/
|
||||
onClear?: React.MouseEventHandler;
|
||||
/**
|
||||
* The position at which the clear button is placed.
|
||||
* If the field is not clearable, the button is not rendered.
|
||||
* @default 'end'
|
||||
*/
|
||||
clearButtonPosition?: 'start' | 'end';
|
||||
/**
|
||||
* The position at which the opening button is placed.
|
||||
* If there is no Picker to open, the button is not rendered
|
||||
* @default 'end'
|
||||
*/
|
||||
openPickerButtonPosition?: 'start' | 'end';
|
||||
}
|
||||
export interface PickerFieldUIProps<TEnableAccessibleFieldDOMStructure extends boolean, TProps extends UseFieldProps<TEnableAccessibleFieldDOMStructure>> {
|
||||
/**
|
||||
* Overridable component slots.
|
||||
* @default {}
|
||||
*/
|
||||
slots?: PickerFieldUISlots;
|
||||
/**
|
||||
* The props used for each component slot.
|
||||
* @default {}
|
||||
*/
|
||||
slotProps?: PickerFieldUISlotProps;
|
||||
/**
|
||||
* Object returned by the `useField` hook or one of its wrapper (for example `useDateField`).
|
||||
*/
|
||||
fieldResponse: UseFieldReturnValue<TEnableAccessibleFieldDOMStructure, TProps>;
|
||||
/**
|
||||
* The component to use to render the Picker opening icon if none is provided in the Picker's slots.
|
||||
*/
|
||||
defaultOpenPickerIcon: React.ElementType;
|
||||
}
|
||||
export interface PickerFieldUISlots {
|
||||
/**
|
||||
* Form control with an input to render the value.
|
||||
* @default <PickersTextField />, or <TextField /> from '@mui/material' if `enableAccessibleFieldDOMStructure` is `false`.
|
||||
*/
|
||||
textField?: React.ElementType;
|
||||
/**
|
||||
* Component displayed on the start or end input adornment used to open the Picker.
|
||||
* @default InputAdornment
|
||||
*/
|
||||
inputAdornment?: React.ElementType<InputAdornmentProps>;
|
||||
/**
|
||||
* Button to clear the value.
|
||||
* @default IconButton
|
||||
*/
|
||||
clearButton?: React.ElementType;
|
||||
/**
|
||||
* Icon to display in the button used to clean the value.
|
||||
* @default ClearIcon
|
||||
*/
|
||||
clearIcon?: React.ElementType;
|
||||
}
|
||||
export interface PickerFieldUISlotsFromContext extends PickerFieldUISlots {
|
||||
/**
|
||||
* Button to open the Picker.
|
||||
* @default IconButton
|
||||
*/
|
||||
openPickerButton?: React.ElementType<IconButtonProps>;
|
||||
/**
|
||||
* Icon to display in the button used to open the Picker.
|
||||
*/
|
||||
openPickerIcon?: React.ElementType;
|
||||
}
|
||||
export interface PickerFieldUISlotProps {
|
||||
textField?: SlotComponentPropsFromProps<Omit<TextFieldProps, 'onKeyDown'> | PickersTextFieldProps, {}, FieldOwnerState>;
|
||||
inputAdornment?: SlotComponentPropsFromProps<InputAdornmentProps, {}, FieldInputAdornmentOwnerState>;
|
||||
clearIcon?: SlotComponentPropsFromProps<SvgIconProps, {}, FieldOwnerState>;
|
||||
clearButton?: SlotComponentPropsFromProps<IconButtonProps, {}, FieldOwnerState>;
|
||||
}
|
||||
export interface PickerFieldUISlotPropsFromContext extends PickerFieldUISlotProps {
|
||||
openPickerButton?: SlotComponentPropsFromProps<IconButtonProps, {}, FieldOwnerState>;
|
||||
openPickerIcon?: SlotComponentPropsFromProps<SvgIconProps, {}, FieldOwnerState>;
|
||||
}
|
||||
interface FieldInputAdornmentOwnerState extends FieldOwnerState {
|
||||
position: 'start' | 'end';
|
||||
}
|
||||
interface PickerFieldUIContextValue {
|
||||
inputRef: React.Ref<HTMLInputElement> | undefined;
|
||||
slots: PickerFieldUISlotsFromContext;
|
||||
slotProps: PickerFieldUISlotPropsFromContext;
|
||||
}
|
||||
export declare function mergeSlotProps<TProps extends {}, TOwnerState extends FieldOwnerState>(slotPropsA: SlotComponentPropsFromProps<TProps, {}, TOwnerState> | undefined, slotPropsB: SlotComponentPropsFromProps<TProps, {}, TOwnerState> | undefined): Partial<TProps> | ((ownerState: TOwnerState) => {}) | undefined;
|
||||
/**
|
||||
* The `textField` slot props cannot be handled inside `PickerFieldUI` because it would be a breaking change to not pass the enriched props to `useField`.
|
||||
* Once the non-accessible DOM structure will be removed, we will be able to remove the `textField` slot and clean this logic.
|
||||
*/
|
||||
export declare function useFieldTextFieldProps<TProps extends UseFieldOwnerStateParameters & {
|
||||
inputProps?: {};
|
||||
InputProps?: {};
|
||||
}>(parameters: UseFieldTextFieldPropsParameters): TProps;
|
||||
interface UseFieldTextFieldPropsParameters {
|
||||
slotProps: {
|
||||
textField?: SlotComponentPropsFromProps<Omit<TextFieldProps, 'onKeyDown'> | PickersTextFieldProps, {}, FieldOwnerState>;
|
||||
} | undefined;
|
||||
ref: React.Ref<HTMLDivElement>;
|
||||
externalForwardedProps: any;
|
||||
}
|
||||
export declare function PickerFieldUIContextProvider(props: PickerFieldUIContextProviderProps): React.JSX.Element;
|
||||
interface PickerFieldUIContextProviderProps {
|
||||
children: React.ReactNode;
|
||||
inputRef: React.Ref<HTMLInputElement> | undefined;
|
||||
slots: PickerFieldUISlotsFromContext | undefined;
|
||||
slotProps: PickerFieldUISlotPropsFromContext | undefined;
|
||||
}
|
||||
export {};
|
||||
337
node_modules/@mui/x-date-pickers/internals/components/PickerFieldUI.js
generated
vendored
Normal file
337
node_modules/@mui/x-date-pickers/internals/components/PickerFieldUI.js
generated
vendored
Normal file
|
|
@ -0,0 +1,337 @@
|
|||
"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.PickerFieldUI = PickerFieldUI;
|
||||
exports.PickerFieldUIContext = void 0;
|
||||
exports.PickerFieldUIContextProvider = PickerFieldUIContextProvider;
|
||||
exports.cleanFieldResponse = void 0;
|
||||
exports.mergeSlotProps = mergeSlotProps;
|
||||
exports.useFieldTextFieldProps = useFieldTextFieldProps;
|
||||
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
||||
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
||||
var React = _interopRequireWildcard(require("react"));
|
||||
var _useEventCallback = _interopRequireDefault(require("@mui/utils/useEventCallback"));
|
||||
var _useForkRef = _interopRequireDefault(require("@mui/utils/useForkRef"));
|
||||
var _resolveComponentProps = _interopRequireDefault(require("@mui/utils/resolveComponentProps"));
|
||||
var _TextField = _interopRequireDefault(require("@mui/material/TextField"));
|
||||
var _IconButton = _interopRequireDefault(require("@mui/material/IconButton"));
|
||||
var _InputAdornment = _interopRequireDefault(require("@mui/material/InputAdornment"));
|
||||
var _useSlotProps5 = _interopRequireDefault(require("@mui/utils/useSlotProps"));
|
||||
var _useFieldOwnerState = require("../hooks/useFieldOwnerState");
|
||||
var _hooks = require("../../hooks");
|
||||
var _icons = require("../../icons");
|
||||
var _useNullablePickerContext = require("../hooks/useNullablePickerContext");
|
||||
var _PickersTextField = require("../../PickersTextField");
|
||||
var _jsxRuntime = require("react/jsx-runtime");
|
||||
const _excluded = ["enableAccessibleFieldDOMStructure"],
|
||||
_excluded2 = ["InputProps", "readOnly", "onClear", "clearable", "clearButtonPosition", "openPickerButtonPosition", "openPickerAriaLabel"],
|
||||
_excluded3 = ["onPaste", "onKeyDown", "inputMode", "readOnly", "InputProps", "inputProps", "inputRef", "onClear", "clearable", "clearButtonPosition", "openPickerButtonPosition", "openPickerAriaLabel"],
|
||||
_excluded4 = ["ownerState"],
|
||||
_excluded5 = ["ownerState"],
|
||||
_excluded6 = ["ownerState"],
|
||||
_excluded7 = ["ownerState"],
|
||||
_excluded8 = ["InputProps", "inputProps"];
|
||||
const cleanFieldResponse = _ref => {
|
||||
let {
|
||||
enableAccessibleFieldDOMStructure
|
||||
} = _ref,
|
||||
fieldResponse = (0, _objectWithoutPropertiesLoose2.default)(_ref, _excluded);
|
||||
if (enableAccessibleFieldDOMStructure) {
|
||||
const {
|
||||
InputProps,
|
||||
readOnly,
|
||||
onClear,
|
||||
clearable,
|
||||
clearButtonPosition,
|
||||
openPickerButtonPosition,
|
||||
openPickerAriaLabel
|
||||
} = fieldResponse,
|
||||
other = (0, _objectWithoutPropertiesLoose2.default)(fieldResponse, _excluded2);
|
||||
return {
|
||||
clearable,
|
||||
onClear,
|
||||
clearButtonPosition,
|
||||
openPickerButtonPosition,
|
||||
openPickerAriaLabel,
|
||||
textFieldProps: (0, _extends2.default)({}, other, {
|
||||
InputProps: (0, _extends2.default)({}, InputProps ?? {}, {
|
||||
readOnly
|
||||
})
|
||||
})
|
||||
};
|
||||
}
|
||||
const {
|
||||
onPaste,
|
||||
onKeyDown,
|
||||
inputMode,
|
||||
readOnly,
|
||||
InputProps,
|
||||
inputProps,
|
||||
inputRef,
|
||||
onClear,
|
||||
clearable,
|
||||
clearButtonPosition,
|
||||
openPickerButtonPosition,
|
||||
openPickerAriaLabel
|
||||
} = fieldResponse,
|
||||
other = (0, _objectWithoutPropertiesLoose2.default)(fieldResponse, _excluded3);
|
||||
return {
|
||||
clearable,
|
||||
onClear,
|
||||
clearButtonPosition,
|
||||
openPickerButtonPosition,
|
||||
openPickerAriaLabel,
|
||||
textFieldProps: (0, _extends2.default)({}, other, {
|
||||
InputProps: (0, _extends2.default)({}, InputProps ?? {}, {
|
||||
readOnly
|
||||
}),
|
||||
inputProps: (0, _extends2.default)({}, inputProps ?? {}, {
|
||||
inputMode,
|
||||
onPaste,
|
||||
onKeyDown,
|
||||
ref: inputRef
|
||||
})
|
||||
})
|
||||
};
|
||||
};
|
||||
exports.cleanFieldResponse = cleanFieldResponse;
|
||||
const PickerFieldUIContext = exports.PickerFieldUIContext = /*#__PURE__*/React.createContext({
|
||||
slots: {},
|
||||
slotProps: {},
|
||||
inputRef: undefined
|
||||
});
|
||||
|
||||
/**
|
||||
* Adds the button to open the Picker and the button to clear the value of the field.
|
||||
* @ignore - internal component.
|
||||
*/
|
||||
if (process.env.NODE_ENV !== "production") PickerFieldUIContext.displayName = "PickerFieldUIContext";
|
||||
function PickerFieldUI(props) {
|
||||
const {
|
||||
slots,
|
||||
slotProps,
|
||||
fieldResponse,
|
||||
defaultOpenPickerIcon
|
||||
} = props;
|
||||
const translations = (0, _hooks.usePickerTranslations)();
|
||||
const pickerContext = (0, _useNullablePickerContext.useNullablePickerContext)();
|
||||
const pickerFieldUIContext = React.useContext(PickerFieldUIContext);
|
||||
const {
|
||||
textFieldProps,
|
||||
onClear,
|
||||
clearable,
|
||||
openPickerAriaLabel,
|
||||
clearButtonPosition: clearButtonPositionProp = 'end',
|
||||
openPickerButtonPosition: openPickerButtonPositionProp = 'end'
|
||||
} = cleanFieldResponse(fieldResponse);
|
||||
const ownerState = (0, _useFieldOwnerState.useFieldOwnerState)(textFieldProps);
|
||||
const handleClickOpeningButton = (0, _useEventCallback.default)(event => {
|
||||
event.preventDefault();
|
||||
pickerContext?.setOpen(prev => !prev);
|
||||
});
|
||||
const triggerStatus = pickerContext ? pickerContext.triggerStatus : 'hidden';
|
||||
const clearButtonPosition = clearable ? clearButtonPositionProp : null;
|
||||
const openPickerButtonPosition = triggerStatus !== 'hidden' ? openPickerButtonPositionProp : null;
|
||||
const TextField = slots?.textField ?? pickerFieldUIContext.slots.textField ?? (fieldResponse.enableAccessibleFieldDOMStructure === false ? _TextField.default : _PickersTextField.PickersTextField);
|
||||
const InputAdornment = slots?.inputAdornment ?? pickerFieldUIContext.slots.inputAdornment ?? _InputAdornment.default;
|
||||
const _useSlotProps = (0, _useSlotProps5.default)({
|
||||
elementType: InputAdornment,
|
||||
externalSlotProps: mergeSlotProps(pickerFieldUIContext.slotProps.inputAdornment, slotProps?.inputAdornment),
|
||||
additionalProps: {
|
||||
position: 'start'
|
||||
},
|
||||
ownerState: (0, _extends2.default)({}, ownerState, {
|
||||
position: 'start'
|
||||
})
|
||||
}),
|
||||
startInputAdornmentProps = (0, _objectWithoutPropertiesLoose2.default)(_useSlotProps, _excluded4);
|
||||
const _useSlotProps2 = (0, _useSlotProps5.default)({
|
||||
elementType: InputAdornment,
|
||||
externalSlotProps: slotProps?.inputAdornment,
|
||||
additionalProps: {
|
||||
position: 'end'
|
||||
},
|
||||
ownerState: (0, _extends2.default)({}, ownerState, {
|
||||
position: 'end'
|
||||
})
|
||||
}),
|
||||
endInputAdornmentProps = (0, _objectWithoutPropertiesLoose2.default)(_useSlotProps2, _excluded5);
|
||||
const OpenPickerButton = pickerFieldUIContext.slots.openPickerButton ?? _IconButton.default;
|
||||
// We don't want to forward the `ownerState` to the `<IconButton />` component, see mui/material-ui#34056
|
||||
const _useSlotProps3 = (0, _useSlotProps5.default)({
|
||||
elementType: OpenPickerButton,
|
||||
externalSlotProps: pickerFieldUIContext.slotProps.openPickerButton,
|
||||
additionalProps: {
|
||||
disabled: triggerStatus === 'disabled',
|
||||
onClick: handleClickOpeningButton,
|
||||
'aria-label': openPickerAriaLabel,
|
||||
edge:
|
||||
// open button is always rendered at the edge
|
||||
textFieldProps.variant !== 'standard' ? openPickerButtonPosition : false
|
||||
},
|
||||
ownerState
|
||||
}),
|
||||
openPickerButtonProps = (0, _objectWithoutPropertiesLoose2.default)(_useSlotProps3, _excluded6);
|
||||
const OpenPickerIcon = pickerFieldUIContext.slots.openPickerIcon ?? defaultOpenPickerIcon;
|
||||
const openPickerIconProps = (0, _useSlotProps5.default)({
|
||||
elementType: OpenPickerIcon,
|
||||
externalSlotProps: pickerFieldUIContext.slotProps.openPickerIcon,
|
||||
ownerState
|
||||
});
|
||||
const ClearButton = slots?.clearButton ?? pickerFieldUIContext.slots.clearButton ?? _IconButton.default;
|
||||
// We don't want to forward the `ownerState` to the `<IconButton />` component, see mui/material-ui#34056
|
||||
const _useSlotProps4 = (0, _useSlotProps5.default)({
|
||||
elementType: ClearButton,
|
||||
externalSlotProps: mergeSlotProps(pickerFieldUIContext.slotProps.clearButton, slotProps?.clearButton),
|
||||
className: 'clearButton',
|
||||
additionalProps: {
|
||||
title: translations.fieldClearLabel,
|
||||
tabIndex: -1,
|
||||
onClick: onClear,
|
||||
disabled: fieldResponse.disabled || fieldResponse.readOnly,
|
||||
edge:
|
||||
// clear button can only be at the edge if it's position differs from the open button
|
||||
textFieldProps.variant !== 'standard' && clearButtonPosition !== openPickerButtonPosition ? clearButtonPosition : false
|
||||
},
|
||||
ownerState
|
||||
}),
|
||||
clearButtonProps = (0, _objectWithoutPropertiesLoose2.default)(_useSlotProps4, _excluded7);
|
||||
const ClearIcon = slots?.clearIcon ?? pickerFieldUIContext.slots.clearIcon ?? _icons.ClearIcon;
|
||||
const clearIconProps = (0, _useSlotProps5.default)({
|
||||
elementType: ClearIcon,
|
||||
externalSlotProps: mergeSlotProps(pickerFieldUIContext.slotProps.clearIcon, slotProps?.clearIcon),
|
||||
additionalProps: {
|
||||
fontSize: 'small'
|
||||
},
|
||||
ownerState
|
||||
});
|
||||
textFieldProps.ref = (0, _useForkRef.default)(textFieldProps.ref, pickerContext?.rootRef);
|
||||
if (!textFieldProps.InputProps) {
|
||||
textFieldProps.InputProps = {};
|
||||
}
|
||||
if (pickerContext) {
|
||||
textFieldProps.InputProps.ref = pickerContext.triggerRef;
|
||||
}
|
||||
if (!textFieldProps.InputProps?.startAdornment && (clearButtonPosition === 'start' || openPickerButtonPosition === 'start')) {
|
||||
textFieldProps.InputProps.startAdornment = /*#__PURE__*/(0, _jsxRuntime.jsxs)(InputAdornment, (0, _extends2.default)({}, startInputAdornmentProps, {
|
||||
children: [openPickerButtonPosition === 'start' && /*#__PURE__*/(0, _jsxRuntime.jsx)(OpenPickerButton, (0, _extends2.default)({}, openPickerButtonProps, {
|
||||
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(OpenPickerIcon, (0, _extends2.default)({}, openPickerIconProps))
|
||||
})), clearButtonPosition === 'start' && /*#__PURE__*/(0, _jsxRuntime.jsx)(ClearButton, (0, _extends2.default)({}, clearButtonProps, {
|
||||
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(ClearIcon, (0, _extends2.default)({}, clearIconProps))
|
||||
}))]
|
||||
}));
|
||||
}
|
||||
if (!textFieldProps.InputProps?.endAdornment && (clearButtonPosition === 'end' || openPickerButtonPosition === 'end')) {
|
||||
textFieldProps.InputProps.endAdornment = /*#__PURE__*/(0, _jsxRuntime.jsxs)(InputAdornment, (0, _extends2.default)({}, endInputAdornmentProps, {
|
||||
children: [clearButtonPosition === 'end' && /*#__PURE__*/(0, _jsxRuntime.jsx)(ClearButton, (0, _extends2.default)({}, clearButtonProps, {
|
||||
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(ClearIcon, (0, _extends2.default)({}, clearIconProps))
|
||||
})), openPickerButtonPosition === 'end' && /*#__PURE__*/(0, _jsxRuntime.jsx)(OpenPickerButton, (0, _extends2.default)({}, openPickerButtonProps, {
|
||||
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(OpenPickerIcon, (0, _extends2.default)({}, openPickerIconProps))
|
||||
}))]
|
||||
}));
|
||||
}
|
||||
if (clearButtonPosition != null) {
|
||||
textFieldProps.sx = [{
|
||||
'& .clearButton': {
|
||||
opacity: 1
|
||||
},
|
||||
'@media (pointer: fine)': {
|
||||
'& .clearButton': {
|
||||
opacity: 0
|
||||
},
|
||||
'&:hover, &:focus-within': {
|
||||
'.clearButton': {
|
||||
opacity: 1
|
||||
}
|
||||
}
|
||||
}
|
||||
}, ...(Array.isArray(textFieldProps.sx) ? textFieldProps.sx : [textFieldProps.sx])];
|
||||
}
|
||||
return /*#__PURE__*/(0, _jsxRuntime.jsx)(TextField, (0, _extends2.default)({}, textFieldProps));
|
||||
}
|
||||
function mergeSlotProps(slotPropsA, slotPropsB) {
|
||||
if (!slotPropsA) {
|
||||
return slotPropsB;
|
||||
}
|
||||
if (!slotPropsB) {
|
||||
return slotPropsA;
|
||||
}
|
||||
return ownerState => {
|
||||
return (0, _extends2.default)({}, (0, _resolveComponentProps.default)(slotPropsB, ownerState), (0, _resolveComponentProps.default)(slotPropsA, ownerState));
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* The `textField` slot props cannot be handled inside `PickerFieldUI` because it would be a breaking change to not pass the enriched props to `useField`.
|
||||
* Once the non-accessible DOM structure will be removed, we will be able to remove the `textField` slot and clean this logic.
|
||||
*/
|
||||
function useFieldTextFieldProps(parameters) {
|
||||
const {
|
||||
ref,
|
||||
externalForwardedProps,
|
||||
slotProps
|
||||
} = parameters;
|
||||
const pickerFieldUIContext = React.useContext(PickerFieldUIContext);
|
||||
const pickerContext = (0, _useNullablePickerContext.useNullablePickerContext)();
|
||||
const ownerState = (0, _useFieldOwnerState.useFieldOwnerState)(externalForwardedProps);
|
||||
const {
|
||||
InputProps,
|
||||
inputProps
|
||||
} = externalForwardedProps,
|
||||
otherExternalForwardedProps = (0, _objectWithoutPropertiesLoose2.default)(externalForwardedProps, _excluded8);
|
||||
const textFieldProps = (0, _useSlotProps5.default)({
|
||||
elementType: _PickersTextField.PickersTextField,
|
||||
externalSlotProps: mergeSlotProps(pickerFieldUIContext.slotProps.textField, slotProps?.textField),
|
||||
externalForwardedProps: otherExternalForwardedProps,
|
||||
additionalProps: {
|
||||
ref,
|
||||
sx: pickerContext?.rootSx,
|
||||
label: pickerContext?.label,
|
||||
name: pickerContext?.name,
|
||||
className: pickerContext?.rootClassName,
|
||||
inputRef: pickerFieldUIContext.inputRef
|
||||
},
|
||||
ownerState
|
||||
});
|
||||
|
||||
// TODO: Remove when mui/material-ui#35088 will be merged
|
||||
textFieldProps.inputProps = (0, _extends2.default)({}, inputProps, textFieldProps.inputProps);
|
||||
textFieldProps.InputProps = (0, _extends2.default)({}, InputProps, textFieldProps.InputProps);
|
||||
return textFieldProps;
|
||||
}
|
||||
function PickerFieldUIContextProvider(props) {
|
||||
const {
|
||||
slots = {},
|
||||
slotProps = {},
|
||||
inputRef,
|
||||
children
|
||||
} = props;
|
||||
const contextValue = React.useMemo(() => ({
|
||||
inputRef,
|
||||
slots: {
|
||||
openPickerButton: slots.openPickerButton,
|
||||
openPickerIcon: slots.openPickerIcon,
|
||||
textField: slots.textField,
|
||||
inputAdornment: slots.inputAdornment,
|
||||
clearIcon: slots.clearIcon,
|
||||
clearButton: slots.clearButton
|
||||
},
|
||||
slotProps: {
|
||||
openPickerButton: slotProps.openPickerButton,
|
||||
openPickerIcon: slotProps.openPickerIcon,
|
||||
textField: slotProps.textField,
|
||||
inputAdornment: slotProps.inputAdornment,
|
||||
clearIcon: slotProps.clearIcon,
|
||||
clearButton: slotProps.clearButton
|
||||
}
|
||||
}), [inputRef, slots.openPickerButton, slots.openPickerIcon, slots.textField, slots.inputAdornment, slots.clearIcon, slots.clearButton, slotProps.openPickerButton, slotProps.openPickerIcon, slotProps.textField, slotProps.inputAdornment, slotProps.clearIcon, slotProps.clearButton]);
|
||||
return /*#__PURE__*/(0, _jsxRuntime.jsx)(PickerFieldUIContext.Provider, {
|
||||
value: contextValue,
|
||||
children: children
|
||||
});
|
||||
}
|
||||
67
node_modules/@mui/x-date-pickers/internals/components/PickerPopper/PickerPopper.d.ts
generated
vendored
Normal file
67
node_modules/@mui/x-date-pickers/internals/components/PickerPopper/PickerPopper.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
import * as React from 'react';
|
||||
import { PaperProps as MuiPaperProps, PaperProps } from '@mui/material/Paper';
|
||||
import { PopperProps as MuiPopperProps, PopperPlacementType, PopperProps } from '@mui/material/Popper';
|
||||
import { TrapFocusProps as MuiTrapFocusProps } from '@mui/material/Unstable_TrapFocus';
|
||||
import { TransitionProps as MuiTransitionProps } from '@mui/material/transitions';
|
||||
import { SlotComponentPropsFromProps } from '@mui/x-internals/types';
|
||||
import { PickerPopperClasses } from "./pickerPopperClasses.js";
|
||||
import { PickerOwnerState } from "../../../models/index.js";
|
||||
export interface PickerPopperOwnerState extends PickerOwnerState {
|
||||
popperPlacement: PopperPlacementType;
|
||||
}
|
||||
export interface PickerPopperSlots {
|
||||
/**
|
||||
* Custom component for the paper rendered inside the desktop picker's Popper.
|
||||
* @default PickerPopperPaper
|
||||
*/
|
||||
desktopPaper?: React.JSXElementConstructor<MuiPaperProps>;
|
||||
/**
|
||||
* Custom component for the desktop popper [Transition](https://mui.com/material-ui/transitions/).
|
||||
* @default Grow or Fade from '@mui/material' when `reduceAnimations` is `true`.
|
||||
*/
|
||||
desktopTransition?: React.JSXElementConstructor<MuiTransitionProps>;
|
||||
/**
|
||||
* Custom component for trapping the focus inside the views on desktop.
|
||||
* @default TrapFocus from '@mui/material'.
|
||||
*/
|
||||
desktopTrapFocus?: React.JSXElementConstructor<MuiTrapFocusProps>;
|
||||
/**
|
||||
* Custom component for the popper inside which the views are rendered on desktop.
|
||||
* @default Popper from '@mui/material'.
|
||||
*/
|
||||
popper?: React.ElementType<MuiPopperProps>;
|
||||
}
|
||||
export interface PickerPopperSlotProps {
|
||||
/**
|
||||
* Props passed down to the desktop [Paper](https://mui.com/material-ui/api/paper/) component.
|
||||
*/
|
||||
desktopPaper?: SlotComponentPropsFromProps<PaperProps, {}, PickerPopperOwnerState>;
|
||||
/**
|
||||
* Props passed down to the desktop [Transition](https://mui.com/material-ui/transitions/) component.
|
||||
*/
|
||||
desktopTransition?: Partial<MuiTransitionProps>;
|
||||
/**
|
||||
* Props passed down to the [FocusTrap](https://mui.com/base-ui/react-focus-trap/) component on desktop.
|
||||
*/
|
||||
desktopTrapFocus?: Partial<MuiTrapFocusProps>;
|
||||
/**
|
||||
* Props passed down to [Popper](https://mui.com/material-ui/api/popper/) component.
|
||||
*/
|
||||
popper?: SlotComponentPropsFromProps<PopperProps, {}, PickerOwnerState>;
|
||||
}
|
||||
export interface ExportedPickerPopperProps {
|
||||
/**
|
||||
* Override or extend the styles applied to the component.
|
||||
*/
|
||||
classes?: Partial<PickerPopperClasses>;
|
||||
/**
|
||||
* @default "bottom-start"
|
||||
*/
|
||||
placement?: MuiPopperProps['placement'];
|
||||
}
|
||||
export interface PickerPopperProps extends ExportedPickerPopperProps {
|
||||
children?: React.ReactNode;
|
||||
slots?: PickerPopperSlots;
|
||||
slotProps?: PickerPopperSlotProps;
|
||||
}
|
||||
export declare function PickerPopper(inProps: PickerPopperProps): React.JSX.Element;
|
||||
350
node_modules/@mui/x-date-pickers/internals/components/PickerPopper/PickerPopper.js
generated
vendored
Normal file
350
node_modules/@mui/x-date-pickers/internals/components/PickerPopper/PickerPopper.js
generated
vendored
Normal file
|
|
@ -0,0 +1,350 @@
|
|||
"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.PickerPopper = PickerPopper;
|
||||
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
||||
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
||||
var React = _interopRequireWildcard(require("react"));
|
||||
var _useSlotProps = _interopRequireDefault(require("@mui/utils/useSlotProps"));
|
||||
var _Grow = _interopRequireDefault(require("@mui/material/Grow"));
|
||||
var _Fade = _interopRequireDefault(require("@mui/material/Fade"));
|
||||
var _Paper = _interopRequireDefault(require("@mui/material/Paper"));
|
||||
var _Popper = _interopRequireDefault(require("@mui/material/Popper"));
|
||||
var _Unstable_TrapFocus = _interopRequireDefault(require("@mui/material/Unstable_TrapFocus"));
|
||||
var _useForkRef = _interopRequireDefault(require("@mui/utils/useForkRef"));
|
||||
var _useEventCallback = _interopRequireDefault(require("@mui/utils/useEventCallback"));
|
||||
var _ownerDocument = _interopRequireDefault(require("@mui/utils/ownerDocument"));
|
||||
var _composeClasses = _interopRequireDefault(require("@mui/utils/composeClasses"));
|
||||
var _styles = require("@mui/material/styles");
|
||||
var _pickerPopperClasses = require("./pickerPopperClasses");
|
||||
var _utils = require("../../utils/utils");
|
||||
var _usePickerPrivateContext = require("../../hooks/usePickerPrivateContext");
|
||||
var _hooks = require("../../../hooks");
|
||||
var _jsxRuntime = require("react/jsx-runtime");
|
||||
const _excluded = ["PaperComponent", "ownerState", "children", "paperSlotProps", "paperClasses", "onPaperClick", "onPaperTouchStart"];
|
||||
const useUtilityClasses = classes => {
|
||||
const slots = {
|
||||
root: ['root'],
|
||||
paper: ['paper']
|
||||
};
|
||||
return (0, _composeClasses.default)(slots, _pickerPopperClasses.getPickerPopperUtilityClass, classes);
|
||||
};
|
||||
const PickerPopperRoot = (0, _styles.styled)(_Popper.default, {
|
||||
name: 'MuiPickerPopper',
|
||||
slot: 'Root'
|
||||
})(({
|
||||
theme
|
||||
}) => ({
|
||||
zIndex: theme.zIndex.modal
|
||||
}));
|
||||
const PickerPopperPaper = (0, _styles.styled)(_Paper.default, {
|
||||
name: 'MuiPickerPopper',
|
||||
slot: 'Paper'
|
||||
})({
|
||||
outline: 0,
|
||||
transformOrigin: 'top center',
|
||||
variants: [{
|
||||
props: ({
|
||||
popperPlacement
|
||||
}) => new Set(['top', 'top-start', 'top-end']).has(popperPlacement),
|
||||
style: {
|
||||
transformOrigin: 'bottom center'
|
||||
}
|
||||
}]
|
||||
});
|
||||
function clickedRootScrollbar(event, doc) {
|
||||
return doc.documentElement.clientWidth < event.clientX || doc.documentElement.clientHeight < event.clientY;
|
||||
}
|
||||
/**
|
||||
* Based on @mui/material/ClickAwayListener without the customization.
|
||||
* We can probably strip away even more since children won't be portaled.
|
||||
* @param {boolean} active Only listen to clicks when the popper is opened.
|
||||
* @param {(event: MouseEvent | TouchEvent) => void} onClickAway The callback to call when clicking outside the popper.
|
||||
* @returns {Array} The ref and event handler to listen to the outside clicks.
|
||||
*/
|
||||
function useClickAwayListener(active, onClickAway) {
|
||||
const movedRef = React.useRef(false);
|
||||
const syntheticEventRef = React.useRef(false);
|
||||
const nodeRef = React.useRef(null);
|
||||
const activatedRef = React.useRef(false);
|
||||
React.useEffect(() => {
|
||||
if (!active) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
// Ensure that this hook is not "activated" synchronously.
|
||||
// https://github.com/facebook/react/issues/20074
|
||||
function armClickAwayListener() {
|
||||
activatedRef.current = true;
|
||||
}
|
||||
document.addEventListener('mousedown', armClickAwayListener, true);
|
||||
document.addEventListener('touchstart', armClickAwayListener, true);
|
||||
return () => {
|
||||
document.removeEventListener('mousedown', armClickAwayListener, true);
|
||||
document.removeEventListener('touchstart', armClickAwayListener, true);
|
||||
activatedRef.current = false;
|
||||
};
|
||||
}, [active]);
|
||||
|
||||
// The handler doesn't take event.defaultPrevented into account:
|
||||
//
|
||||
// event.preventDefault() is meant to stop default behaviors like
|
||||
// clicking a checkbox to check it, hitting a button to submit a form,
|
||||
// and hitting left arrow to move the cursor in a text input etc.
|
||||
// Only special HTML elements have these default behaviors.
|
||||
const handleClickAway = (0, _useEventCallback.default)(event => {
|
||||
if (!activatedRef.current) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Given developers can stop the propagation of the synthetic event,
|
||||
// we can only be confident with a positive value.
|
||||
const insideReactTree = syntheticEventRef.current;
|
||||
syntheticEventRef.current = false;
|
||||
const doc = (0, _ownerDocument.default)(nodeRef.current);
|
||||
|
||||
// 1. IE11 support, which trigger the handleClickAway even after the unbind
|
||||
// 2. The child might render null.
|
||||
// 3. Behave like a blur listener.
|
||||
if (!nodeRef.current ||
|
||||
// is a TouchEvent?
|
||||
'clientX' in event && clickedRootScrollbar(event, doc)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Do not act if user performed touchmove
|
||||
if (movedRef.current) {
|
||||
movedRef.current = false;
|
||||
return;
|
||||
}
|
||||
let insideDOM;
|
||||
|
||||
// If not enough, can use https://github.com/DieterHolvoet/event-propagation-path/blob/master/propagationPath.js
|
||||
if (event.composedPath) {
|
||||
insideDOM = event.composedPath().indexOf(nodeRef.current) > -1;
|
||||
} else {
|
||||
insideDOM = !doc.documentElement.contains(event.target) || nodeRef.current.contains(event.target);
|
||||
}
|
||||
if (!insideDOM && !insideReactTree) {
|
||||
onClickAway(event);
|
||||
}
|
||||
});
|
||||
|
||||
// Keep track of mouse/touch events that bubbled up through the portal.
|
||||
const handleSynthetic = event => {
|
||||
// Ignore events handled by our internal components
|
||||
if (!event.defaultMuiPrevented) {
|
||||
syntheticEventRef.current = true;
|
||||
}
|
||||
};
|
||||
React.useEffect(() => {
|
||||
if (active) {
|
||||
const doc = (0, _ownerDocument.default)(nodeRef.current);
|
||||
const handleTouchMove = () => {
|
||||
movedRef.current = true;
|
||||
};
|
||||
doc.addEventListener('touchstart', handleClickAway);
|
||||
doc.addEventListener('touchmove', handleTouchMove);
|
||||
return () => {
|
||||
doc.removeEventListener('touchstart', handleClickAway);
|
||||
doc.removeEventListener('touchmove', handleTouchMove);
|
||||
};
|
||||
}
|
||||
return undefined;
|
||||
}, [active, handleClickAway]);
|
||||
React.useEffect(() => {
|
||||
// TODO This behavior is not tested automatically
|
||||
// It's unclear whether this is due to different update semantics in test (batched in act() vs discrete on click).
|
||||
// Or if this is a timing related issues due to different Transition components
|
||||
// Once we get rid of all the manual scheduling (for example setTimeout(update, 0)) we can revisit this code+test.
|
||||
if (active) {
|
||||
const doc = (0, _ownerDocument.default)(nodeRef.current);
|
||||
doc.addEventListener('click', handleClickAway);
|
||||
return () => {
|
||||
doc.removeEventListener('click', handleClickAway);
|
||||
// cleanup `handleClickAway`
|
||||
syntheticEventRef.current = false;
|
||||
};
|
||||
}
|
||||
return undefined;
|
||||
}, [active, handleClickAway]);
|
||||
return [nodeRef, handleSynthetic, handleSynthetic];
|
||||
}
|
||||
const PickerPopperPaperWrapper = /*#__PURE__*/React.forwardRef((props, ref) => {
|
||||
const {
|
||||
PaperComponent,
|
||||
ownerState,
|
||||
children,
|
||||
paperSlotProps,
|
||||
paperClasses,
|
||||
onPaperClick,
|
||||
onPaperTouchStart
|
||||
// picks up the style props provided by `Transition`
|
||||
// https://mui.com/material-ui/transitions/#child-requirement
|
||||
} = props,
|
||||
other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
|
||||
const paperProps = (0, _useSlotProps.default)({
|
||||
elementType: PaperComponent,
|
||||
externalSlotProps: paperSlotProps,
|
||||
additionalProps: {
|
||||
tabIndex: -1,
|
||||
elevation: 8,
|
||||
ref
|
||||
},
|
||||
className: paperClasses,
|
||||
ownerState
|
||||
});
|
||||
return /*#__PURE__*/(0, _jsxRuntime.jsx)(PaperComponent, (0, _extends2.default)({}, other, paperProps, {
|
||||
onClick: event => {
|
||||
onPaperClick(event);
|
||||
paperProps.onClick?.(event);
|
||||
},
|
||||
onTouchStart: event => {
|
||||
onPaperTouchStart(event);
|
||||
paperProps.onTouchStart?.(event);
|
||||
},
|
||||
ownerState: ownerState,
|
||||
children: children
|
||||
}));
|
||||
});
|
||||
if (process.env.NODE_ENV !== "production") PickerPopperPaperWrapper.displayName = "PickerPopperPaperWrapper";
|
||||
function PickerPopper(inProps) {
|
||||
const props = (0, _styles.useThemeProps)({
|
||||
props: inProps,
|
||||
name: 'MuiPickerPopper'
|
||||
});
|
||||
const {
|
||||
children,
|
||||
placement = 'bottom-start',
|
||||
slots,
|
||||
slotProps,
|
||||
classes: classesProp
|
||||
} = props;
|
||||
const {
|
||||
open,
|
||||
popupRef,
|
||||
reduceAnimations
|
||||
} = (0, _hooks.usePickerContext)();
|
||||
const {
|
||||
ownerState: pickerOwnerState,
|
||||
rootRefObject
|
||||
} = (0, _usePickerPrivateContext.usePickerPrivateContext)();
|
||||
const {
|
||||
dismissViews,
|
||||
getCurrentViewMode,
|
||||
onPopperExited,
|
||||
triggerElement,
|
||||
viewContainerRole
|
||||
} = (0, _usePickerPrivateContext.usePickerPrivateContext)();
|
||||
React.useEffect(() => {
|
||||
function handleKeyDown(nativeEvent) {
|
||||
if (open && nativeEvent.key === 'Escape') {
|
||||
dismissViews();
|
||||
}
|
||||
}
|
||||
document.addEventListener('keydown', handleKeyDown);
|
||||
return () => {
|
||||
document.removeEventListener('keydown', handleKeyDown);
|
||||
};
|
||||
}, [dismissViews, open]);
|
||||
const lastFocusedElementRef = React.useRef(null);
|
||||
React.useEffect(() => {
|
||||
if (viewContainerRole === 'tooltip' || getCurrentViewMode() === 'field') {
|
||||
return;
|
||||
}
|
||||
if (open) {
|
||||
lastFocusedElementRef.current = (0, _utils.getActiveElement)(rootRefObject.current);
|
||||
} else if (lastFocusedElementRef.current && lastFocusedElementRef.current instanceof HTMLElement) {
|
||||
// make sure the button is flushed with updated label, before returning focus to it
|
||||
// avoids issue, where screen reader could fail to announce selected date after selection
|
||||
setTimeout(() => {
|
||||
if (lastFocusedElementRef.current instanceof HTMLElement) {
|
||||
lastFocusedElementRef.current.focus();
|
||||
}
|
||||
});
|
||||
}
|
||||
}, [open, viewContainerRole, getCurrentViewMode, rootRefObject]);
|
||||
const classes = useUtilityClasses(classesProp);
|
||||
const handleClickAway = (0, _useEventCallback.default)(() => {
|
||||
if (viewContainerRole === 'tooltip') {
|
||||
(0, _utils.executeInTheNextEventLoopTick)(() => {
|
||||
if (rootRefObject.current?.contains((0, _utils.getActiveElement)(rootRefObject.current)) || popupRef.current?.contains((0, _utils.getActiveElement)(popupRef.current))) {
|
||||
return;
|
||||
}
|
||||
dismissViews();
|
||||
});
|
||||
} else {
|
||||
dismissViews();
|
||||
}
|
||||
});
|
||||
const [clickAwayRef, onPaperClick, onPaperTouchStart] = useClickAwayListener(open, handleClickAway);
|
||||
const paperRef = React.useRef(null);
|
||||
const handleRef = (0, _useForkRef.default)(paperRef, popupRef);
|
||||
const handlePaperRef = (0, _useForkRef.default)(handleRef, clickAwayRef);
|
||||
const handleKeyDown = event => {
|
||||
if (event.key === 'Escape') {
|
||||
// stop the propagation to avoid closing parent modal
|
||||
event.stopPropagation();
|
||||
dismissViews();
|
||||
}
|
||||
};
|
||||
const Transition = slots?.desktopTransition ?? reduceAnimations ? _Fade.default : _Grow.default;
|
||||
const FocusTrap = slots?.desktopTrapFocus ?? _Unstable_TrapFocus.default;
|
||||
const Paper = slots?.desktopPaper ?? PickerPopperPaper;
|
||||
const Popper = slots?.popper ?? PickerPopperRoot;
|
||||
const popperProps = (0, _useSlotProps.default)({
|
||||
elementType: Popper,
|
||||
externalSlotProps: slotProps?.popper,
|
||||
additionalProps: {
|
||||
transition: true,
|
||||
role: viewContainerRole == null ? undefined : viewContainerRole,
|
||||
open,
|
||||
placement,
|
||||
anchorEl: triggerElement,
|
||||
onKeyDown: handleKeyDown
|
||||
},
|
||||
className: classes.root,
|
||||
ownerState: pickerOwnerState
|
||||
});
|
||||
const ownerState = React.useMemo(() => (0, _extends2.default)({}, pickerOwnerState, {
|
||||
popperPlacement: popperProps.placement
|
||||
}), [pickerOwnerState, popperProps.placement]);
|
||||
return /*#__PURE__*/(0, _jsxRuntime.jsx)(Popper, (0, _extends2.default)({}, popperProps, {
|
||||
children: ({
|
||||
TransitionProps
|
||||
}) => /*#__PURE__*/(0, _jsxRuntime.jsx)(FocusTrap, (0, _extends2.default)({
|
||||
open: open,
|
||||
disableAutoFocus: true
|
||||
// pickers are managing focus position manually
|
||||
// without this prop the focus is returned to the button before `aria-label` is updated
|
||||
// which would force screen readers to read too old label
|
||||
,
|
||||
disableRestoreFocus: true,
|
||||
disableEnforceFocus: viewContainerRole === 'tooltip',
|
||||
isEnabled: () => true
|
||||
}, slotProps?.desktopTrapFocus, {
|
||||
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(Transition, (0, _extends2.default)({}, TransitionProps, slotProps?.desktopTransition, {
|
||||
onExited: event => {
|
||||
onPopperExited?.();
|
||||
slotProps?.desktopTransition?.onExited?.(event);
|
||||
TransitionProps?.onExited?.();
|
||||
},
|
||||
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(PickerPopperPaperWrapper, {
|
||||
PaperComponent: Paper,
|
||||
ownerState: ownerState,
|
||||
ref: handlePaperRef,
|
||||
onPaperClick: onPaperClick,
|
||||
onPaperTouchStart: onPaperTouchStart,
|
||||
paperClasses: classes.paper,
|
||||
paperSlotProps: slotProps?.desktopPaper,
|
||||
children: children
|
||||
})
|
||||
}))
|
||||
}))
|
||||
}));
|
||||
}
|
||||
4
node_modules/@mui/x-date-pickers/internals/components/PickerPopper/index.d.ts
generated
vendored
Normal file
4
node_modules/@mui/x-date-pickers/internals/components/PickerPopper/index.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
export { PickerPopper } from "./PickerPopper.js";
|
||||
export type { ExportedPickerPopperProps } from "./PickerPopper.js";
|
||||
export { pickerPopperClasses, getPickerPopperUtilityClass } from "./pickerPopperClasses.js";
|
||||
export type { PickerPopperClassKey, PickerPopperClasses } from "./pickerPopperClasses.js";
|
||||
25
node_modules/@mui/x-date-pickers/internals/components/PickerPopper/index.js
generated
vendored
Normal file
25
node_modules/@mui/x-date-pickers/internals/components/PickerPopper/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "PickerPopper", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _PickerPopper.PickerPopper;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "getPickerPopperUtilityClass", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _pickerPopperClasses.getPickerPopperUtilityClass;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "pickerPopperClasses", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _pickerPopperClasses.pickerPopperClasses;
|
||||
}
|
||||
});
|
||||
var _PickerPopper = require("./PickerPopper");
|
||||
var _pickerPopperClasses = require("./pickerPopperClasses");
|
||||
9
node_modules/@mui/x-date-pickers/internals/components/PickerPopper/pickerPopperClasses.d.ts
generated
vendored
Normal file
9
node_modules/@mui/x-date-pickers/internals/components/PickerPopper/pickerPopperClasses.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
export interface PickerPopperClasses {
|
||||
/** Styles applied to the root element. */
|
||||
root: string;
|
||||
/** Styles applied to the paper element. */
|
||||
paper: string;
|
||||
}
|
||||
export type PickerPopperClassKey = keyof PickerPopperClasses;
|
||||
export declare function getPickerPopperUtilityClass(slot: string): string;
|
||||
export declare const pickerPopperClasses: Record<"root" | "paper", string>;
|
||||
14
node_modules/@mui/x-date-pickers/internals/components/PickerPopper/pickerPopperClasses.js
generated
vendored
Normal file
14
node_modules/@mui/x-date-pickers/internals/components/PickerPopper/pickerPopperClasses.js
generated
vendored
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.getPickerPopperUtilityClass = getPickerPopperUtilityClass;
|
||||
exports.pickerPopperClasses = void 0;
|
||||
var _generateUtilityClass = _interopRequireDefault(require("@mui/utils/generateUtilityClass"));
|
||||
var _generateUtilityClasses = _interopRequireDefault(require("@mui/utils/generateUtilityClasses"));
|
||||
function getPickerPopperUtilityClass(slot) {
|
||||
return (0, _generateUtilityClass.default)('MuiPickerPopper', slot);
|
||||
}
|
||||
const pickerPopperClasses = exports.pickerPopperClasses = (0, _generateUtilityClasses.default)('MuiPickerPopper', ['root', 'paper']);
|
||||
293
node_modules/@mui/x-date-pickers/internals/components/PickerProvider.d.ts
generated
vendored
Normal file
293
node_modules/@mui/x-date-pickers/internals/components/PickerProvider.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,293 @@
|
|||
import * as React from 'react';
|
||||
import { SxProps } from '@mui/system';
|
||||
import { Theme } from '@mui/material/styles';
|
||||
import { PickerChangeImportance, PickerOwnerState, PickersTimezone } from "../../models/index.js";
|
||||
import { PickersInputLocaleText } from "../../locales/index.js";
|
||||
import { DateOrTimeViewWithMeridiem, PickerOrientation, PickerValidValue, PickerVariant } from "../models/index.js";
|
||||
import { PickerFieldPrivateContextValue } from "../hooks/useNullableFieldPrivateContext.js";
|
||||
import type { PickersShortcutsItemContext } from "../../PickersShortcuts/index.js";
|
||||
import type { PickersActionBarAction } from "../../PickersActionBar/index.js";
|
||||
export declare const PickerActionsContext: React.Context<PickerActionsContextValue<any, any, any> | null>;
|
||||
export declare const PickerPrivateContext: React.Context<PickerPrivateContextValue>;
|
||||
/**
|
||||
* Provides the context for the various parts of a Picker component:
|
||||
* - contextValue: the context for the Picker sub-components.
|
||||
* - localizationProvider: the translations passed through the props and through a parent LocalizationProvider.
|
||||
*
|
||||
* @ignore - do not document.
|
||||
*/
|
||||
export declare function PickerProvider<TValue extends PickerValidValue>(props: PickerProviderProps<TValue>): React.JSX.Element;
|
||||
export interface PickerProviderProps<TValue extends PickerValidValue> {
|
||||
contextValue: PickerContextValue<any, any, any>;
|
||||
actionsContextValue: PickerActionsContextValue<any, any, any>;
|
||||
privateContextValue: PickerPrivateContextValue;
|
||||
fieldPrivateContextValue: PickerFieldPrivateContextValue;
|
||||
isValidContextValue: (value: TValue) => boolean;
|
||||
localeText: PickersInputLocaleText | undefined;
|
||||
children: React.ReactNode;
|
||||
}
|
||||
export interface PickerContextValue<TValue extends PickerValidValue, TView extends DateOrTimeViewWithMeridiem, TError> extends PickerActionsContextValue<TValue, TView, TError> {
|
||||
/**
|
||||
* The current value of the Picker.
|
||||
*/
|
||||
value: TValue;
|
||||
/**
|
||||
* The timezone to use when rendering the dates.
|
||||
* If a `timezone` prop is provided, it will be used.
|
||||
* If the `value` prop contains a valid date, its timezone will be used.
|
||||
* If no `value` prop is provided, but the `defaultValue` contains a valid date, its timezone will be used.
|
||||
* If no `value` or `defaultValue` is provided, but the `referenceDate` is provided, its timezone will be used.
|
||||
* Otherwise, the timezone will be the default one of your date library.
|
||||
*/
|
||||
timezone: PickersTimezone;
|
||||
/**
|
||||
* Whether the Picker is open.
|
||||
*/
|
||||
open: boolean;
|
||||
/**
|
||||
* Whether the Picker is disabled.
|
||||
*/
|
||||
disabled: boolean;
|
||||
/**
|
||||
* Whether the Picker is read-only.
|
||||
*/
|
||||
readOnly: boolean;
|
||||
/**
|
||||
* Whether the Picker should be focused on mount.
|
||||
* If the Picker has a field and is not open, the field should be focused.
|
||||
* If the Picker does not have a field (static variant) or is not open, the view should be focused.
|
||||
*/
|
||||
autoFocus: boolean;
|
||||
/**
|
||||
* The views that the Picker has to render.
|
||||
* It is equal to the Picker `views` prop—if defined.
|
||||
* Otherwise, a default set of views is provided based on the component you are using:
|
||||
* - Date Picker: ['year', 'day']
|
||||
* - Time Picker: ['hours', 'minutes']
|
||||
* - Date Time Picker: ['year', 'day', 'hours', 'minutes']
|
||||
* - Date Range Picker: ['day']
|
||||
* - Date Time Range Picker: ['day', 'hours', 'minutes']
|
||||
*/
|
||||
views: readonly TView[];
|
||||
/**
|
||||
* The currently rendered view.
|
||||
*/
|
||||
view: TView | null;
|
||||
/**
|
||||
* The first view shown when opening the Picker for the first time.
|
||||
*/
|
||||
initialView: TView | null;
|
||||
/**
|
||||
* The responsive variant of the Picker.
|
||||
* It is equal to "desktop" when using a desktop Picker (like <DesktopDatePicker />).
|
||||
* It is equal to "mobile" when using a mobile Picker (like <MobileDatePicker />).
|
||||
* It is equal to "mobile" or "desktop" when using a responsive Picker (like <DatePicker />) depending on the `desktopModeMediaQuery` prop.
|
||||
* It is equal to "mobile" or "desktop" when using a static Picker (like <StaticDatePicker />) depending on the `displayStaticWrapperAs` prop.
|
||||
* It is always equal to "desktop" if the component you are accessing the context from is not wrapped with a Picker.
|
||||
*/
|
||||
variant: PickerVariant;
|
||||
/**
|
||||
* The orientation of the Picker.
|
||||
* On Time Pickers and Date Time Pickers, it is always equal to "portrait".
|
||||
* On Date Pickers, it is equal to the Picker `orientation` prop if defined, otherwise it is based on the current orientation of the user's screen.
|
||||
* It is always equal to "portrait" if the component you are accessing the context from is not wrapped with a Picker.
|
||||
*/
|
||||
orientation: PickerOrientation;
|
||||
/**
|
||||
* Whether the heavy animations should be disabled.
|
||||
* @default `@media(prefers-reduced-motion: reduce)` || `navigator.userAgent` matches Android <10 or iOS <13
|
||||
*/
|
||||
reduceAnimations?: boolean;
|
||||
/**
|
||||
* The ref to attach to the element that triggers the Picker opening.
|
||||
* When using a built-in field component, this property is automatically attached to the right element.
|
||||
*/
|
||||
triggerRef: React.Dispatch<React.SetStateAction<HTMLElement | null>>;
|
||||
/**
|
||||
* The status of the element that triggers the Picker opening.
|
||||
* If it is "hidden", the field should not render the UI to open the Picker.
|
||||
* If it is "disabled", the field should render a disabled UI to open the Picker.
|
||||
* If it is "enabled", the field should render an interactive UI to open the Picker.
|
||||
*/
|
||||
triggerStatus: 'hidden' | 'disabled' | 'enabled';
|
||||
/**
|
||||
* Whether the Picker has any value picking steps left.
|
||||
*/
|
||||
hasNextStep: boolean;
|
||||
/**
|
||||
* The ref to attach to the popup's outermost element that contains the view, if any.
|
||||
* When using a built-in popup component, this property is automatically attached to the appropriate element.
|
||||
*/
|
||||
popupRef: React.RefObject<any>;
|
||||
/**
|
||||
* The format to use when rendering the value in the field.
|
||||
* It is equal to the Picker `format` prop if defined.
|
||||
* It is generated based on the available views if not defined.
|
||||
* It is always equal to an empty string if the Picker does not have a field (static variant).
|
||||
* It is always equal to an empty string if the component you are accessing the context from is not wrapped with a Picker.
|
||||
*/
|
||||
fieldFormat: string;
|
||||
/**
|
||||
* The name to apply to the <input /> element if the Picker contains one.
|
||||
* If the Picker has a field, it should probably be applied to its input element.
|
||||
* It is equal to the Picker `name` prop if defined (the prop does not exist on the static variant).
|
||||
* It is always equal to undefined if the component you are accessing the context from is not wrapped with a Picker.
|
||||
*/
|
||||
name: string | undefined;
|
||||
/**
|
||||
* The label to render by the field if the Picker contains one.
|
||||
* It is equal to the Picker `label` prop if defined (the prop does not exist on the static variant).
|
||||
* It is always equal to undefined if the component you are accessing the context from is not wrapped with a Picker.
|
||||
*/
|
||||
label: React.ReactNode | undefined;
|
||||
/**
|
||||
* The class name to apply to the root element.
|
||||
* If the Picker has a field, it should be applied to field root element, otherwise to the layout root element.
|
||||
* It is equal to the Picker `className` prop if defined.
|
||||
* It is always equal to undefined if the component you are accessing the context from is not wrapped with a Picker.
|
||||
*/
|
||||
rootClassName: string | undefined;
|
||||
/**
|
||||
* The MUI style prop to apply to the root element.
|
||||
* If the Picker has a field, it should be applied to field root element, otherwise to the layout root element.
|
||||
* It is equal to the Picker `sx` prop if defined.
|
||||
* It is always equal to undefined if the component you are accessing the context from is not wrapped with a Picker.
|
||||
*/
|
||||
rootSx: SxProps<Theme> | undefined;
|
||||
/**
|
||||
* The ref to attach to the root element.
|
||||
* If the Picker has a field, it should be attached to field root element, otherwise to the layout root element.
|
||||
* It is equal to the ref passed to the Picker component if defined.
|
||||
* It is always equal to undefined if the component you are accessing the context from is not wrapped with a Picker.
|
||||
*/
|
||||
rootRef: React.ForwardedRef<HTMLDivElement> | undefined;
|
||||
}
|
||||
export interface PickerActionsContextValue<TValue extends PickerValidValue, TView extends DateOrTimeViewWithMeridiem, TError = string | null> {
|
||||
/**
|
||||
* Set the current value of the Picker.
|
||||
* @param {TValue} value The new value of the Picker.
|
||||
* @param {SetValueActionOptions<TError>} options The options to customize the behavior of this update.
|
||||
*/
|
||||
setValue: (value: TValue, options?: SetValueActionOptions<TError>) => void;
|
||||
/**
|
||||
* Set the current open state of the Picker.
|
||||
* It can be a function that will receive the current open state as parameter.
|
||||
* ```ts
|
||||
* setOpen(true); // Opens the Picker.
|
||||
* setOpen(false); // Closes the Picker.
|
||||
* setOpen((prevOpen) => !prevOpen); // Toggles the open state.
|
||||
* ```
|
||||
* @param {React.SetStateAction<boolean>} action The new open state of the Picker.
|
||||
*/
|
||||
setOpen: React.Dispatch<React.SetStateAction<boolean>>;
|
||||
/**
|
||||
* Set the current view of the Picker.
|
||||
* @template TView
|
||||
* @param {TView} view The new view of the Picker
|
||||
*/
|
||||
setView: (view: TView) => void;
|
||||
/**
|
||||
* Set the current value of the Picker to be empty.
|
||||
* The value will be `null` on a single Picker and `[null, null]` on a range Picker.
|
||||
*/
|
||||
clearValue: () => void;
|
||||
/**
|
||||
* Set the current value of the Picker to be the current date.
|
||||
* The value will be `today` on a non-range Picker and `[today, today]` on a range Picker.
|
||||
* With `today` being the current date, with its time set to `00:00:00` on Date Pickers and its time set to the current time on Time and Date and Time Pickers.
|
||||
*/
|
||||
setValueToToday: () => void;
|
||||
/**
|
||||
* Accept the current value of the Picker.
|
||||
* Will call `onAccept` if defined.
|
||||
* If the Picker is re-opened, this value will be the one used to initialize the views.
|
||||
*/
|
||||
acceptValueChanges: () => void;
|
||||
/**
|
||||
* Cancel the changes made to the current value of the Picker.
|
||||
* The value will be reset to the last accepted value.
|
||||
*/
|
||||
cancelValueChanges: () => void;
|
||||
/**
|
||||
* Go to the next step in the value picking process.
|
||||
* For example, on the Mobile Date Time Picker, if the user is editing the date, it will switch to editing the time.
|
||||
*/
|
||||
goToNextStep: () => void;
|
||||
}
|
||||
export interface SetValueActionOptions<TError = string | null> {
|
||||
/**
|
||||
* The importance of the change when picking a value:
|
||||
* - "accept": fires `onChange`, fires `onAccept` and closes the Picker.
|
||||
* - "set": fires `onChange` but do not fire `onAccept` and does not close the Picker.
|
||||
* @default "accept"
|
||||
*/
|
||||
changeImportance?: PickerChangeImportance;
|
||||
/**
|
||||
* The validation error associated with the current value.
|
||||
* If not defined, the validation will be computed by the Picker.
|
||||
*/
|
||||
validationError?: TError;
|
||||
/**
|
||||
* The shortcut that triggered this change.
|
||||
* It should not be defined if the change does not come from a shortcut.
|
||||
*/
|
||||
shortcut?: PickersShortcutsItemContext;
|
||||
/**
|
||||
* Whether the value should call `onChange` and `onAccept` when the value is not controlled and has never been modified.
|
||||
* If `true`, the `onChange` and `onAccept` callback will only be fired if the value has been modified (and is not equal to the last published value).
|
||||
* If `false`, the `onChange` and `onAccept` callback will be fired when the value has never been modified (`onAccept` only if `changeImportance` is set to "accept").
|
||||
* @default false
|
||||
*/
|
||||
skipPublicationIfPristine?: boolean;
|
||||
/**
|
||||
* Whether the Picker should close.
|
||||
* @default changeImportance === "accept"
|
||||
*/
|
||||
shouldClose?: boolean;
|
||||
}
|
||||
export interface PickerPrivateContextValue {
|
||||
dismissViews: () => void;
|
||||
/**
|
||||
* The ownerState of the picker.
|
||||
*/
|
||||
ownerState: PickerOwnerState;
|
||||
/**
|
||||
* Whether at least one view has an UI (it has a view renderer associated).
|
||||
*/
|
||||
hasUIView: boolean;
|
||||
/**
|
||||
* Return the mode of the current view.
|
||||
* @returns {boolean} The mode of the current view.
|
||||
*/
|
||||
getCurrentViewMode: () => 'UI' | 'field';
|
||||
/**
|
||||
* The ref of the root element.
|
||||
* This is the object counterpart of the `usePickerContext().rootRef` property which can be a function.
|
||||
*/
|
||||
rootRefObject: React.RefObject<HTMLDivElement | null>;
|
||||
/**
|
||||
* The id of the label element.
|
||||
*/
|
||||
labelId: string | undefined;
|
||||
/**
|
||||
* The element used as the anchor for the Picker Popper.
|
||||
*/
|
||||
triggerElement: HTMLElement | null;
|
||||
/**
|
||||
* The aria role associated with the view container.
|
||||
* It is equal to "dialog" when the view is rendered inside a `@mui/material/Dialog`.
|
||||
* It is equal to "dialog" when the view is rendered inside a `@mui/material/Popper` and the focus is trapped inside the view.
|
||||
* It is equal to "tooltip" when the view is rendered inside a `@mui/material/Popper` and the focus remains inside the field.
|
||||
* It is always equal to null if the Picker does not have a field (static variant).
|
||||
* It is always equal to null if the component you are accessing the context from is not wrapped with a Picker.
|
||||
*/
|
||||
viewContainerRole: 'dialog' | 'tooltip' | null;
|
||||
/**
|
||||
* The actions to render in the action bar if the user doesn't provide any.
|
||||
*/
|
||||
defaultActionBarActions: PickersActionBarAction[];
|
||||
/**
|
||||
* The function to call when the Popper is closing animation is finished.
|
||||
*/
|
||||
onPopperExited: (() => void) | undefined;
|
||||
}
|
||||
77
node_modules/@mui/x-date-pickers/internals/components/PickerProvider.js
generated
vendored
Normal file
77
node_modules/@mui/x-date-pickers/internals/components/PickerProvider.js
generated
vendored
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
"use strict";
|
||||
'use client';
|
||||
|
||||
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.PickerPrivateContext = exports.PickerActionsContext = void 0;
|
||||
exports.PickerProvider = PickerProvider;
|
||||
var React = _interopRequireWildcard(require("react"));
|
||||
var _LocalizationProvider = require("../../LocalizationProvider");
|
||||
var _useIsValidValue = require("../../hooks/useIsValidValue");
|
||||
var _useNullableFieldPrivateContext = require("../hooks/useNullableFieldPrivateContext");
|
||||
var _usePickerContext = require("../../hooks/usePickerContext");
|
||||
var _jsxRuntime = require("react/jsx-runtime");
|
||||
const PickerActionsContext = exports.PickerActionsContext = /*#__PURE__*/React.createContext(null);
|
||||
if (process.env.NODE_ENV !== "production") PickerActionsContext.displayName = "PickerActionsContext";
|
||||
const PickerPrivateContext = exports.PickerPrivateContext = /*#__PURE__*/React.createContext({
|
||||
ownerState: {
|
||||
isPickerDisabled: false,
|
||||
isPickerReadOnly: false,
|
||||
isPickerValueEmpty: false,
|
||||
isPickerOpen: false,
|
||||
pickerVariant: 'desktop',
|
||||
pickerOrientation: 'portrait'
|
||||
},
|
||||
rootRefObject: {
|
||||
current: null
|
||||
},
|
||||
labelId: undefined,
|
||||
dismissViews: () => {},
|
||||
hasUIView: true,
|
||||
getCurrentViewMode: () => 'UI',
|
||||
triggerElement: null,
|
||||
viewContainerRole: null,
|
||||
defaultActionBarActions: [],
|
||||
onPopperExited: undefined
|
||||
});
|
||||
|
||||
/**
|
||||
* Provides the context for the various parts of a Picker component:
|
||||
* - contextValue: the context for the Picker sub-components.
|
||||
* - localizationProvider: the translations passed through the props and through a parent LocalizationProvider.
|
||||
*
|
||||
* @ignore - do not document.
|
||||
*/
|
||||
if (process.env.NODE_ENV !== "production") PickerPrivateContext.displayName = "PickerPrivateContext";
|
||||
function PickerProvider(props) {
|
||||
const {
|
||||
contextValue,
|
||||
actionsContextValue,
|
||||
privateContextValue,
|
||||
fieldPrivateContextValue,
|
||||
isValidContextValue,
|
||||
localeText,
|
||||
children
|
||||
} = props;
|
||||
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_usePickerContext.PickerContext.Provider, {
|
||||
value: contextValue,
|
||||
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(PickerActionsContext.Provider, {
|
||||
value: actionsContextValue,
|
||||
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(PickerPrivateContext.Provider, {
|
||||
value: privateContextValue,
|
||||
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_useNullableFieldPrivateContext.PickerFieldPrivateContext.Provider, {
|
||||
value: fieldPrivateContextValue,
|
||||
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_useIsValidValue.IsValidValueContext.Provider, {
|
||||
value: isValidContextValue,
|
||||
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_LocalizationProvider.LocalizationProvider, {
|
||||
localeText: localeText,
|
||||
children: children
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
});
|
||||
}
|
||||
1
node_modules/@mui/x-date-pickers/internals/components/PickerViewRoot/PickerViewRoot.d.ts
generated
vendored
Normal file
1
node_modules/@mui/x-date-pickers/internals/components/PickerViewRoot/PickerViewRoot.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
export declare const PickerViewRoot: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
||||
16
node_modules/@mui/x-date-pickers/internals/components/PickerViewRoot/PickerViewRoot.js
generated
vendored
Normal file
16
node_modules/@mui/x-date-pickers/internals/components/PickerViewRoot/PickerViewRoot.js
generated
vendored
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.PickerViewRoot = void 0;
|
||||
var _styles = require("@mui/material/styles");
|
||||
var _dimensions = require("../../constants/dimensions");
|
||||
const PickerViewRoot = exports.PickerViewRoot = (0, _styles.styled)('div')({
|
||||
overflow: 'hidden',
|
||||
width: _dimensions.DIALOG_WIDTH,
|
||||
maxHeight: _dimensions.VIEW_HEIGHT,
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
margin: '0 auto'
|
||||
});
|
||||
1
node_modules/@mui/x-date-pickers/internals/components/PickerViewRoot/index.d.ts
generated
vendored
Normal file
1
node_modules/@mui/x-date-pickers/internals/components/PickerViewRoot/index.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
export { PickerViewRoot } from "./PickerViewRoot.js";
|
||||
12
node_modules/@mui/x-date-pickers/internals/components/PickerViewRoot/index.js
generated
vendored
Normal file
12
node_modules/@mui/x-date-pickers/internals/components/PickerViewRoot/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "PickerViewRoot", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _PickerViewRoot.PickerViewRoot;
|
||||
}
|
||||
});
|
||||
var _PickerViewRoot = require("./PickerViewRoot");
|
||||
3
node_modules/@mui/x-date-pickers/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.d.ts
generated
vendored
Normal file
3
node_modules/@mui/x-date-pickers/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
import * as React from 'react';
|
||||
import { PickersArrowSwitcherProps } from "./PickersArrowSwitcher.types.js";
|
||||
export declare const PickersArrowSwitcher: React.ForwardRefExoticComponent<PickersArrowSwitcherProps & React.RefAttributes<HTMLDivElement>>;
|
||||
182
node_modules/@mui/x-date-pickers/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js
generated
vendored
Normal file
182
node_modules/@mui/x-date-pickers/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js
generated
vendored
Normal file
|
|
@ -0,0 +1,182 @@
|
|||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
||||
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.PickersArrowSwitcher = void 0;
|
||||
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
||||
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
||||
var React = _interopRequireWildcard(require("react"));
|
||||
var _clsx = _interopRequireDefault(require("clsx"));
|
||||
var _Typography = _interopRequireDefault(require("@mui/material/Typography"));
|
||||
var _RtlProvider = require("@mui/system/RtlProvider");
|
||||
var _styles = require("@mui/material/styles");
|
||||
var _composeClasses = _interopRequireDefault(require("@mui/utils/composeClasses"));
|
||||
var _useSlotProps3 = _interopRequireDefault(require("@mui/utils/useSlotProps"));
|
||||
var _IconButton = _interopRequireDefault(require("@mui/material/IconButton"));
|
||||
var _icons = require("../../../icons");
|
||||
var _pickersArrowSwitcherClasses = require("./pickersArrowSwitcherClasses");
|
||||
var _usePickerPrivateContext = require("../../hooks/usePickerPrivateContext");
|
||||
var _jsxRuntime = require("react/jsx-runtime");
|
||||
const _excluded = ["children", "className", "slots", "slotProps", "isNextDisabled", "isNextHidden", "onGoToNext", "nextLabel", "isPreviousDisabled", "isPreviousHidden", "onGoToPrevious", "previousLabel", "labelId", "classes"],
|
||||
_excluded2 = ["ownerState"],
|
||||
_excluded3 = ["ownerState"];
|
||||
const PickersArrowSwitcherRoot = (0, _styles.styled)('div', {
|
||||
name: 'MuiPickersArrowSwitcher',
|
||||
slot: 'Root'
|
||||
})({
|
||||
display: 'flex'
|
||||
});
|
||||
const PickersArrowSwitcherSpacer = (0, _styles.styled)('div', {
|
||||
name: 'MuiPickersArrowSwitcher',
|
||||
slot: 'Spacer'
|
||||
})(({
|
||||
theme
|
||||
}) => ({
|
||||
width: theme.spacing(3)
|
||||
}));
|
||||
const PickersArrowSwitcherButton = (0, _styles.styled)(_IconButton.default, {
|
||||
name: 'MuiPickersArrowSwitcher',
|
||||
slot: 'Button'
|
||||
})({
|
||||
variants: [{
|
||||
props: {
|
||||
isButtonHidden: true
|
||||
},
|
||||
style: {
|
||||
visibility: 'hidden'
|
||||
}
|
||||
}]
|
||||
});
|
||||
const useUtilityClasses = classes => {
|
||||
const slots = {
|
||||
root: ['root'],
|
||||
spacer: ['spacer'],
|
||||
button: ['button'],
|
||||
previousIconButton: ['previousIconButton'],
|
||||
nextIconButton: ['nextIconButton'],
|
||||
leftArrowIcon: ['leftArrowIcon'],
|
||||
rightArrowIcon: ['rightArrowIcon']
|
||||
};
|
||||
return (0, _composeClasses.default)(slots, _pickersArrowSwitcherClasses.getPickersArrowSwitcherUtilityClass, classes);
|
||||
};
|
||||
const PickersArrowSwitcher = exports.PickersArrowSwitcher = /*#__PURE__*/React.forwardRef(function PickersArrowSwitcher(inProps, ref) {
|
||||
const isRtl = (0, _RtlProvider.useRtl)();
|
||||
const props = (0, _styles.useThemeProps)({
|
||||
props: inProps,
|
||||
name: 'MuiPickersArrowSwitcher'
|
||||
});
|
||||
const {
|
||||
children,
|
||||
className,
|
||||
slots,
|
||||
slotProps,
|
||||
isNextDisabled,
|
||||
isNextHidden,
|
||||
onGoToNext,
|
||||
nextLabel,
|
||||
isPreviousDisabled,
|
||||
isPreviousHidden,
|
||||
onGoToPrevious,
|
||||
previousLabel,
|
||||
labelId,
|
||||
classes: classesProp
|
||||
} = props,
|
||||
other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
|
||||
const {
|
||||
ownerState
|
||||
} = (0, _usePickerPrivateContext.usePickerPrivateContext)();
|
||||
const classes = useUtilityClasses(classesProp);
|
||||
const nextProps = {
|
||||
isDisabled: isNextDisabled,
|
||||
isHidden: isNextHidden,
|
||||
goTo: onGoToNext,
|
||||
label: nextLabel
|
||||
};
|
||||
const previousProps = {
|
||||
isDisabled: isPreviousDisabled,
|
||||
isHidden: isPreviousHidden,
|
||||
goTo: onGoToPrevious,
|
||||
label: previousLabel
|
||||
};
|
||||
const PreviousIconButton = slots?.previousIconButton ?? PickersArrowSwitcherButton;
|
||||
const previousIconButtonProps = (0, _useSlotProps3.default)({
|
||||
elementType: PreviousIconButton,
|
||||
externalSlotProps: slotProps?.previousIconButton,
|
||||
additionalProps: {
|
||||
size: 'medium',
|
||||
title: previousProps.label,
|
||||
'aria-label': previousProps.label,
|
||||
disabled: previousProps.isDisabled,
|
||||
edge: 'end',
|
||||
onClick: previousProps.goTo
|
||||
},
|
||||
ownerState: (0, _extends2.default)({}, ownerState, {
|
||||
isButtonHidden: previousProps.isHidden ?? false
|
||||
}),
|
||||
className: (0, _clsx.default)(classes.button, classes.previousIconButton)
|
||||
});
|
||||
const NextIconButton = slots?.nextIconButton ?? PickersArrowSwitcherButton;
|
||||
const nextIconButtonProps = (0, _useSlotProps3.default)({
|
||||
elementType: NextIconButton,
|
||||
externalSlotProps: slotProps?.nextIconButton,
|
||||
additionalProps: {
|
||||
size: 'medium',
|
||||
title: nextProps.label,
|
||||
'aria-label': nextProps.label,
|
||||
disabled: nextProps.isDisabled,
|
||||
edge: 'start',
|
||||
onClick: nextProps.goTo
|
||||
},
|
||||
ownerState: (0, _extends2.default)({}, ownerState, {
|
||||
isButtonHidden: nextProps.isHidden ?? false
|
||||
}),
|
||||
className: (0, _clsx.default)(classes.button, classes.nextIconButton)
|
||||
});
|
||||
const LeftArrowIcon = slots?.leftArrowIcon ?? _icons.ArrowLeftIcon;
|
||||
// The spread is here to avoid this bug mui/material-ui#34056
|
||||
const _useSlotProps = (0, _useSlotProps3.default)({
|
||||
elementType: LeftArrowIcon,
|
||||
externalSlotProps: slotProps?.leftArrowIcon,
|
||||
additionalProps: {
|
||||
fontSize: 'inherit'
|
||||
},
|
||||
ownerState,
|
||||
className: classes.leftArrowIcon
|
||||
}),
|
||||
leftArrowIconProps = (0, _objectWithoutPropertiesLoose2.default)(_useSlotProps, _excluded2);
|
||||
const RightArrowIcon = slots?.rightArrowIcon ?? _icons.ArrowRightIcon;
|
||||
// The spread is here to avoid this bug mui/material-ui#34056
|
||||
const _useSlotProps2 = (0, _useSlotProps3.default)({
|
||||
elementType: RightArrowIcon,
|
||||
externalSlotProps: slotProps?.rightArrowIcon,
|
||||
additionalProps: {
|
||||
fontSize: 'inherit'
|
||||
},
|
||||
ownerState,
|
||||
className: classes.rightArrowIcon
|
||||
}),
|
||||
rightArrowIconProps = (0, _objectWithoutPropertiesLoose2.default)(_useSlotProps2, _excluded3);
|
||||
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(PickersArrowSwitcherRoot, (0, _extends2.default)({
|
||||
ref: ref,
|
||||
className: (0, _clsx.default)(classes.root, className),
|
||||
ownerState: ownerState
|
||||
}, other, {
|
||||
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(PreviousIconButton, (0, _extends2.default)({}, previousIconButtonProps, {
|
||||
children: isRtl ? /*#__PURE__*/(0, _jsxRuntime.jsx)(RightArrowIcon, (0, _extends2.default)({}, rightArrowIconProps)) : /*#__PURE__*/(0, _jsxRuntime.jsx)(LeftArrowIcon, (0, _extends2.default)({}, leftArrowIconProps))
|
||||
})), children ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
|
||||
variant: "subtitle1",
|
||||
component: "span",
|
||||
id: labelId,
|
||||
children: children
|
||||
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(PickersArrowSwitcherSpacer, {
|
||||
className: classes.spacer,
|
||||
ownerState: ownerState
|
||||
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(NextIconButton, (0, _extends2.default)({}, nextIconButtonProps, {
|
||||
children: isRtl ? /*#__PURE__*/(0, _jsxRuntime.jsx)(LeftArrowIcon, (0, _extends2.default)({}, leftArrowIconProps)) : /*#__PURE__*/(0, _jsxRuntime.jsx)(RightArrowIcon, (0, _extends2.default)({}, rightArrowIconProps))
|
||||
}))]
|
||||
}));
|
||||
});
|
||||
if (process.env.NODE_ENV !== "production") PickersArrowSwitcher.displayName = "PickersArrowSwitcher";
|
||||
74
node_modules/@mui/x-date-pickers/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.types.d.ts
generated
vendored
Normal file
74
node_modules/@mui/x-date-pickers/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.types.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
import * as React from 'react';
|
||||
import { SlotComponentProps } from '@mui/utils/types';
|
||||
import IconButton from '@mui/material/IconButton';
|
||||
import SvgIcon from '@mui/material/SvgIcon';
|
||||
import { PickersArrowSwitcherClasses } from "./pickersArrowSwitcherClasses.js";
|
||||
import { PickerOwnerState } from "../../../models/index.js";
|
||||
export interface ExportedPickersArrowSwitcherProps {
|
||||
/**
|
||||
* Overridable component slots.
|
||||
* @default {}
|
||||
*/
|
||||
slots?: PickersArrowSwitcherSlots;
|
||||
/**
|
||||
* The props used for each component slot.
|
||||
* @default {}
|
||||
*/
|
||||
slotProps?: PickersArrowSwitcherSlotProps;
|
||||
/**
|
||||
* Override or extend the styles applied to the component.
|
||||
*/
|
||||
classes?: Partial<PickersArrowSwitcherClasses>;
|
||||
/**
|
||||
* Format used to display the date.
|
||||
* @default `${adapter.formats.month} ${adapter.formats.year}`
|
||||
*/
|
||||
format?: string;
|
||||
}
|
||||
export interface PickersArrowSwitcherProps extends ExportedPickersArrowSwitcherProps, Omit<React.HTMLProps<HTMLDivElement>, 'ref' | 'as'> {
|
||||
children?: React.ReactNode;
|
||||
isPreviousDisabled: boolean;
|
||||
isPreviousHidden?: boolean;
|
||||
onGoToPrevious: () => void;
|
||||
previousLabel: string;
|
||||
isNextDisabled: boolean;
|
||||
isNextHidden?: boolean;
|
||||
onGoToNext: () => void;
|
||||
nextLabel: string;
|
||||
labelId?: string;
|
||||
}
|
||||
export interface PickersArrowSwitcherOwnerState extends PickerOwnerState {
|
||||
/**
|
||||
* If `true`, this button should be hidden.
|
||||
*/
|
||||
isButtonHidden: boolean;
|
||||
}
|
||||
export interface PickersArrowSwitcherSlotPropsOverrides {}
|
||||
export interface PickersArrowSwitcherSlots {
|
||||
/**
|
||||
* Button allowing to switch to the left view.
|
||||
* @default IconButton
|
||||
*/
|
||||
previousIconButton?: React.ElementType;
|
||||
/**
|
||||
* Button allowing to switch to the right view.
|
||||
* @default IconButton
|
||||
*/
|
||||
nextIconButton?: React.ElementType;
|
||||
/**
|
||||
* Icon displayed in the left view switch button.
|
||||
* @default ArrowLeft
|
||||
*/
|
||||
leftArrowIcon?: React.ElementType;
|
||||
/**
|
||||
* Icon displayed in the right view switch button.
|
||||
* @default ArrowRight
|
||||
*/
|
||||
rightArrowIcon?: React.ElementType;
|
||||
}
|
||||
export interface PickersArrowSwitcherSlotProps {
|
||||
previousIconButton?: SlotComponentProps<typeof IconButton, PickersArrowSwitcherSlotPropsOverrides, PickersArrowSwitcherOwnerState>;
|
||||
nextIconButton?: SlotComponentProps<typeof IconButton, PickersArrowSwitcherSlotPropsOverrides, PickersArrowSwitcherOwnerState>;
|
||||
leftArrowIcon?: SlotComponentProps<typeof SvgIcon, PickersArrowSwitcherSlotPropsOverrides, PickerOwnerState>;
|
||||
rightArrowIcon?: SlotComponentProps<typeof SvgIcon, PickersArrowSwitcherSlotPropsOverrides, PickerOwnerState>;
|
||||
}
|
||||
5
node_modules/@mui/x-date-pickers/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.types.js
generated
vendored
Normal file
5
node_modules/@mui/x-date-pickers/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.types.js
generated
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
4
node_modules/@mui/x-date-pickers/internals/components/PickersArrowSwitcher/index.d.ts
generated
vendored
Normal file
4
node_modules/@mui/x-date-pickers/internals/components/PickersArrowSwitcher/index.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
export { PickersArrowSwitcher } from "./PickersArrowSwitcher.js";
|
||||
export type { PickersArrowSwitcherSlots, PickersArrowSwitcherSlotProps, ExportedPickersArrowSwitcherProps } from "./PickersArrowSwitcher.types.js";
|
||||
export { pickersArrowSwitcherClasses, getPickersArrowSwitcherUtilityClass } from "./pickersArrowSwitcherClasses.js";
|
||||
export type { PickersArrowSwitcherClassKey, PickersArrowSwitcherClasses } from "./pickersArrowSwitcherClasses.js";
|
||||
25
node_modules/@mui/x-date-pickers/internals/components/PickersArrowSwitcher/index.js
generated
vendored
Normal file
25
node_modules/@mui/x-date-pickers/internals/components/PickersArrowSwitcher/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "PickersArrowSwitcher", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _PickersArrowSwitcher.PickersArrowSwitcher;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "getPickersArrowSwitcherUtilityClass", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _pickersArrowSwitcherClasses.getPickersArrowSwitcherUtilityClass;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "pickersArrowSwitcherClasses", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _pickersArrowSwitcherClasses.pickersArrowSwitcherClasses;
|
||||
}
|
||||
});
|
||||
var _PickersArrowSwitcher = require("./PickersArrowSwitcher");
|
||||
var _pickersArrowSwitcherClasses = require("./pickersArrowSwitcherClasses");
|
||||
19
node_modules/@mui/x-date-pickers/internals/components/PickersArrowSwitcher/pickersArrowSwitcherClasses.d.ts
generated
vendored
Normal file
19
node_modules/@mui/x-date-pickers/internals/components/PickersArrowSwitcher/pickersArrowSwitcherClasses.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
export interface PickersArrowSwitcherClasses {
|
||||
/** Styles applied to the root element. */
|
||||
root: string;
|
||||
/** Styles applied to the spacer element. */
|
||||
spacer: string;
|
||||
/** Styles applied to the button element. */
|
||||
button: string;
|
||||
/** Styles applied to the previous icon button element. */
|
||||
previousIconButton: string;
|
||||
/** Styles applied to the next icon button element. */
|
||||
nextIconButton: string;
|
||||
/** Styles applied to the left icon element. */
|
||||
leftArrowIcon: string;
|
||||
/** Styles applied to the right icon element. */
|
||||
rightArrowIcon: string;
|
||||
}
|
||||
export type PickersArrowSwitcherClassKey = keyof PickersArrowSwitcherClasses;
|
||||
export declare function getPickersArrowSwitcherUtilityClass(slot: string): string;
|
||||
export declare const pickersArrowSwitcherClasses: Record<"root" | "button" | "spacer" | "previousIconButton" | "nextIconButton" | "leftArrowIcon" | "rightArrowIcon", string>;
|
||||
14
node_modules/@mui/x-date-pickers/internals/components/PickersArrowSwitcher/pickersArrowSwitcherClasses.js
generated
vendored
Normal file
14
node_modules/@mui/x-date-pickers/internals/components/PickersArrowSwitcher/pickersArrowSwitcherClasses.js
generated
vendored
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.getPickersArrowSwitcherUtilityClass = getPickersArrowSwitcherUtilityClass;
|
||||
exports.pickersArrowSwitcherClasses = void 0;
|
||||
var _generateUtilityClass = _interopRequireDefault(require("@mui/utils/generateUtilityClass"));
|
||||
var _generateUtilityClasses = _interopRequireDefault(require("@mui/utils/generateUtilityClasses"));
|
||||
function getPickersArrowSwitcherUtilityClass(slot) {
|
||||
return (0, _generateUtilityClass.default)('MuiPickersArrowSwitcher', slot);
|
||||
}
|
||||
const pickersArrowSwitcherClasses = exports.pickersArrowSwitcherClasses = (0, _generateUtilityClasses.default)('MuiPickersArrowSwitcher', ['root', 'spacer', 'button', 'previousIconButton', 'nextIconButton', 'leftArrowIcon', 'rightArrowIcon']);
|
||||
48
node_modules/@mui/x-date-pickers/internals/components/PickersModalDialog.d.ts
generated
vendored
Normal file
48
node_modules/@mui/x-date-pickers/internals/components/PickersModalDialog.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
import * as React from 'react';
|
||||
import { DialogProps as MuiDialogProps } from '@mui/material/Dialog';
|
||||
import { PaperProps as MuiPaperProps } from '@mui/material/Paper';
|
||||
import { TransitionProps as MuiTransitionProps } from '@mui/material/transitions';
|
||||
export interface PickersModalDialogSlots {
|
||||
/**
|
||||
* Custom component for the dialog inside which the views are rendered on mobile.
|
||||
* @default PickersModalDialogRoot
|
||||
*/
|
||||
dialog?: React.ElementType<MuiDialogProps>;
|
||||
/**
|
||||
* Custom component for the paper rendered inside the mobile picker's Dialog.
|
||||
* @default Paper from '@mui/material'.
|
||||
*/
|
||||
mobilePaper?: React.JSXElementConstructor<MuiPaperProps>;
|
||||
/**
|
||||
* Custom component for the mobile dialog [Transition](https://mui.com/material-ui/transitions/).
|
||||
* @default Fade from '@mui/material'.
|
||||
*/
|
||||
mobileTransition?: React.JSXElementConstructor<MuiTransitionProps>;
|
||||
}
|
||||
export interface PickersModalDialogSlotProps {
|
||||
/**
|
||||
* Props passed down to the [`Dialog`](https://mui.com/material-ui/api/dialog/) component.
|
||||
*/
|
||||
dialog?: Partial<MuiDialogProps>;
|
||||
/**
|
||||
* Props passed down to the mobile [Paper](https://mui.com/material-ui/api/paper/) component.
|
||||
*/
|
||||
mobilePaper?: Partial<MuiPaperProps>;
|
||||
/**
|
||||
* Props passed down to the mobile [Transition](https://mui.com/material-ui/transitions/) component.
|
||||
*/
|
||||
mobileTransition?: Partial<MuiTransitionProps>;
|
||||
}
|
||||
export interface PickersModalDialogProps {
|
||||
/**
|
||||
* Overridable component slots.
|
||||
* @default {}
|
||||
*/
|
||||
slots?: PickersModalDialogSlots;
|
||||
/**
|
||||
* The props used for each component slot.
|
||||
* @default {}
|
||||
*/
|
||||
slotProps?: PickersModalDialogSlotProps;
|
||||
}
|
||||
export declare function PickersModalDialog(props: React.PropsWithChildren<PickersModalDialogProps>): React.JSX.Element;
|
||||
63
node_modules/@mui/x-date-pickers/internals/components/PickersModalDialog.js
generated
vendored
Normal file
63
node_modules/@mui/x-date-pickers/internals/components/PickersModalDialog.js
generated
vendored
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
"use strict";
|
||||
|
||||
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.PickersModalDialog = PickersModalDialog;
|
||||
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
||||
var React = _interopRequireWildcard(require("react"));
|
||||
var _DialogContent = _interopRequireDefault(require("@mui/material/DialogContent"));
|
||||
var _Fade = _interopRequireDefault(require("@mui/material/Fade"));
|
||||
var _Dialog = _interopRequireWildcard(require("@mui/material/Dialog"));
|
||||
var _styles = require("@mui/material/styles");
|
||||
var _dimensions = require("../constants/dimensions");
|
||||
var _hooks = require("../../hooks");
|
||||
var _usePickerPrivateContext = require("../hooks/usePickerPrivateContext");
|
||||
var _jsxRuntime = require("react/jsx-runtime");
|
||||
const PickersModalDialogRoot = (0, _styles.styled)(_Dialog.default)({
|
||||
[`& .${_Dialog.dialogClasses.container}`]: {
|
||||
outline: 0
|
||||
},
|
||||
[`& .${_Dialog.dialogClasses.paper}`]: {
|
||||
outline: 0,
|
||||
minWidth: _dimensions.DIALOG_WIDTH
|
||||
}
|
||||
});
|
||||
const PickersModalDialogContent = (0, _styles.styled)(_DialogContent.default)({
|
||||
'&:first-of-type': {
|
||||
padding: 0
|
||||
}
|
||||
});
|
||||
function PickersModalDialog(props) {
|
||||
const {
|
||||
children,
|
||||
slots,
|
||||
slotProps
|
||||
} = props;
|
||||
const {
|
||||
open
|
||||
} = (0, _hooks.usePickerContext)();
|
||||
const {
|
||||
dismissViews,
|
||||
onPopperExited
|
||||
} = (0, _usePickerPrivateContext.usePickerPrivateContext)();
|
||||
const Dialog = slots?.dialog ?? PickersModalDialogRoot;
|
||||
const Transition = slots?.mobileTransition ?? _Fade.default;
|
||||
return /*#__PURE__*/(0, _jsxRuntime.jsx)(Dialog, (0, _extends2.default)({
|
||||
open: open,
|
||||
onClose: () => {
|
||||
dismissViews();
|
||||
onPopperExited?.();
|
||||
}
|
||||
}, slotProps?.dialog, {
|
||||
TransitionComponent: Transition,
|
||||
TransitionProps: slotProps?.mobileTransition,
|
||||
PaperComponent: slots?.mobilePaper,
|
||||
PaperProps: slotProps?.mobilePaper,
|
||||
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(PickersModalDialogContent, {
|
||||
children: children
|
||||
})
|
||||
}));
|
||||
}
|
||||
14
node_modules/@mui/x-date-pickers/internals/components/PickersToolbar.d.ts
generated
vendored
Normal file
14
node_modules/@mui/x-date-pickers/internals/components/PickersToolbar.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
import * as React from 'react';
|
||||
import { BaseToolbarProps } from "../models/props/toolbar.js";
|
||||
import { PickersToolbarClasses } from "./pickersToolbarClasses.js";
|
||||
export interface PickersToolbarProps extends Pick<BaseToolbarProps, 'hidden' | 'titleId'> {
|
||||
className?: string;
|
||||
landscapeDirection?: 'row' | 'column';
|
||||
toolbarTitle: React.ReactNode;
|
||||
classes?: Partial<PickersToolbarClasses>;
|
||||
}
|
||||
type PickersToolbarComponent = ((props: React.PropsWithChildren<PickersToolbarProps> & React.RefAttributes<HTMLDivElement>) => React.JSX.Element) & {
|
||||
propTypes?: any;
|
||||
};
|
||||
export declare const PickersToolbar: PickersToolbarComponent;
|
||||
export {};
|
||||
123
node_modules/@mui/x-date-pickers/internals/components/PickersToolbar.js
generated
vendored
Normal file
123
node_modules/@mui/x-date-pickers/internals/components/PickersToolbar.js
generated
vendored
Normal file
|
|
@ -0,0 +1,123 @@
|
|||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
||||
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.PickersToolbar = void 0;
|
||||
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
||||
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
||||
var React = _interopRequireWildcard(require("react"));
|
||||
var _clsx = _interopRequireDefault(require("clsx"));
|
||||
var _Typography = _interopRequireDefault(require("@mui/material/Typography"));
|
||||
var _styles = require("@mui/material/styles");
|
||||
var _composeClasses = _interopRequireDefault(require("@mui/utils/composeClasses"));
|
||||
var _createStyled = require("@mui/system/createStyled");
|
||||
var _pickersToolbarClasses = require("./pickersToolbarClasses");
|
||||
var _useToolbarOwnerState = require("../hooks/useToolbarOwnerState");
|
||||
var _jsxRuntime = require("react/jsx-runtime");
|
||||
const _excluded = ["children", "className", "classes", "toolbarTitle", "hidden", "titleId", "classes", "landscapeDirection"];
|
||||
const useUtilityClasses = classes => {
|
||||
const slots = {
|
||||
root: ['root'],
|
||||
title: ['title'],
|
||||
content: ['content']
|
||||
};
|
||||
return (0, _composeClasses.default)(slots, _pickersToolbarClasses.getPickersToolbarUtilityClass, classes);
|
||||
};
|
||||
const PickersToolbarRoot = (0, _styles.styled)('div', {
|
||||
name: 'MuiPickersToolbar',
|
||||
slot: 'Root'
|
||||
})(({
|
||||
theme
|
||||
}) => ({
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
alignItems: 'flex-start',
|
||||
justifyContent: 'space-between',
|
||||
padding: theme.spacing(2, 3),
|
||||
variants: [{
|
||||
props: {
|
||||
pickerOrientation: 'landscape'
|
||||
},
|
||||
style: {
|
||||
height: 'auto',
|
||||
maxWidth: 160,
|
||||
padding: 16,
|
||||
justifyContent: 'flex-start',
|
||||
flexWrap: 'wrap'
|
||||
}
|
||||
}]
|
||||
}));
|
||||
const PickersToolbarContent = (0, _styles.styled)('div', {
|
||||
name: 'MuiPickersToolbar',
|
||||
slot: 'Content',
|
||||
shouldForwardProp: prop => (0, _createStyled.shouldForwardProp)(prop) && prop !== 'landscapeDirection'
|
||||
})({
|
||||
display: 'flex',
|
||||
flexWrap: 'wrap',
|
||||
width: '100%',
|
||||
flex: 1,
|
||||
justifyContent: 'space-between',
|
||||
alignItems: 'center',
|
||||
flexDirection: 'row',
|
||||
variants: [{
|
||||
props: {
|
||||
pickerOrientation: 'landscape'
|
||||
},
|
||||
style: {
|
||||
justifyContent: 'flex-start',
|
||||
alignItems: 'flex-start',
|
||||
flexDirection: 'column'
|
||||
}
|
||||
}, {
|
||||
props: {
|
||||
pickerOrientation: 'landscape',
|
||||
landscapeDirection: 'row'
|
||||
},
|
||||
style: {
|
||||
flexDirection: 'row'
|
||||
}
|
||||
}]
|
||||
});
|
||||
const PickersToolbar = exports.PickersToolbar = /*#__PURE__*/React.forwardRef(function PickersToolbar(inProps, ref) {
|
||||
const props = (0, _styles.useThemeProps)({
|
||||
props: inProps,
|
||||
name: 'MuiPickersToolbar'
|
||||
});
|
||||
const {
|
||||
children,
|
||||
className,
|
||||
classes: classesProp,
|
||||
toolbarTitle,
|
||||
hidden,
|
||||
titleId,
|
||||
landscapeDirection
|
||||
} = props,
|
||||
other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
|
||||
const ownerState = (0, _useToolbarOwnerState.useToolbarOwnerState)();
|
||||
const classes = useUtilityClasses(classesProp);
|
||||
if (hidden) {
|
||||
return null;
|
||||
}
|
||||
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(PickersToolbarRoot, (0, _extends2.default)({
|
||||
ref: ref,
|
||||
className: (0, _clsx.default)(classes.root, className),
|
||||
ownerState: ownerState
|
||||
}, other, {
|
||||
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
|
||||
color: "text.secondary",
|
||||
variant: "overline",
|
||||
id: titleId,
|
||||
className: classes.title,
|
||||
children: toolbarTitle
|
||||
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(PickersToolbarContent, {
|
||||
className: classes.content,
|
||||
ownerState: ownerState,
|
||||
landscapeDirection: landscapeDirection,
|
||||
children: children
|
||||
})]
|
||||
}));
|
||||
});
|
||||
if (process.env.NODE_ENV !== "production") PickersToolbar.displayName = "PickersToolbar";
|
||||
15
node_modules/@mui/x-date-pickers/internals/components/PickersToolbarButton.d.ts
generated
vendored
Normal file
15
node_modules/@mui/x-date-pickers/internals/components/PickersToolbarButton.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
import * as React from 'react';
|
||||
import { ButtonProps } from '@mui/material/Button';
|
||||
import { TypographyProps } from '@mui/material/Typography';
|
||||
import { ExtendMui } from "../models/helpers.js";
|
||||
import { PickersToolbarButtonClasses } from "./pickersToolbarButtonClasses.js";
|
||||
export interface PickersToolbarButtonProps extends ExtendMui<ButtonProps, 'value' | 'variant'> {
|
||||
align?: TypographyProps['align'];
|
||||
selected: boolean;
|
||||
typographyClassName?: string;
|
||||
value: React.ReactNode;
|
||||
variant: TypographyProps['variant'];
|
||||
classes?: Partial<PickersToolbarButtonClasses>;
|
||||
width?: number | string;
|
||||
}
|
||||
export declare const PickersToolbarButton: React.ForwardRefExoticComponent<Omit<PickersToolbarButtonProps, "ref"> & React.RefAttributes<HTMLButtonElement>>;
|
||||
70
node_modules/@mui/x-date-pickers/internals/components/PickersToolbarButton.js
generated
vendored
Normal file
70
node_modules/@mui/x-date-pickers/internals/components/PickersToolbarButton.js
generated
vendored
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
||||
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.PickersToolbarButton = void 0;
|
||||
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
||||
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
||||
var React = _interopRequireWildcard(require("react"));
|
||||
var _clsx = _interopRequireDefault(require("clsx"));
|
||||
var _Button = _interopRequireDefault(require("@mui/material/Button"));
|
||||
var _styles = require("@mui/material/styles");
|
||||
var _composeClasses = _interopRequireDefault(require("@mui/utils/composeClasses"));
|
||||
var _PickersToolbarText = require("./PickersToolbarText");
|
||||
var _pickersToolbarClasses = require("./pickersToolbarClasses");
|
||||
var _jsxRuntime = require("react/jsx-runtime");
|
||||
const _excluded = ["align", "className", "classes", "selected", "typographyClassName", "value", "variant", "width"];
|
||||
const useUtilityClasses = classes => {
|
||||
const slots = {
|
||||
root: ['root']
|
||||
};
|
||||
return (0, _composeClasses.default)(slots, _pickersToolbarClasses.getPickersToolbarUtilityClass, classes);
|
||||
};
|
||||
const PickersToolbarButtonRoot = (0, _styles.styled)(_Button.default, {
|
||||
name: 'MuiPickersToolbarButton',
|
||||
slot: 'Root'
|
||||
})({
|
||||
padding: 0,
|
||||
minWidth: 16,
|
||||
textTransform: 'none'
|
||||
});
|
||||
const PickersToolbarButton = exports.PickersToolbarButton = /*#__PURE__*/React.forwardRef(function PickersToolbarButton(inProps, ref) {
|
||||
const props = (0, _styles.useThemeProps)({
|
||||
props: inProps,
|
||||
name: 'MuiPickersToolbarButton'
|
||||
});
|
||||
const {
|
||||
align,
|
||||
className,
|
||||
classes: classesProp,
|
||||
selected,
|
||||
typographyClassName,
|
||||
value,
|
||||
variant,
|
||||
width
|
||||
} = props,
|
||||
other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
|
||||
const classes = useUtilityClasses(classesProp);
|
||||
return /*#__PURE__*/(0, _jsxRuntime.jsx)(PickersToolbarButtonRoot, (0, _extends2.default)({
|
||||
variant: "text",
|
||||
ref: ref,
|
||||
className: (0, _clsx.default)(classes.root, className),
|
||||
ownerState: props
|
||||
}, width ? {
|
||||
sx: {
|
||||
width
|
||||
}
|
||||
} : {}, other, {
|
||||
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_PickersToolbarText.PickersToolbarText, {
|
||||
align: align,
|
||||
className: typographyClassName,
|
||||
variant: variant,
|
||||
value: value,
|
||||
selected: selected
|
||||
})
|
||||
}));
|
||||
});
|
||||
if (process.env.NODE_ENV !== "production") PickersToolbarButton.displayName = "PickersToolbarButton";
|
||||
11
node_modules/@mui/x-date-pickers/internals/components/PickersToolbarText.d.ts
generated
vendored
Normal file
11
node_modules/@mui/x-date-pickers/internals/components/PickersToolbarText.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
import * as React from 'react';
|
||||
import { TypographyProps } from '@mui/material/Typography';
|
||||
import { PickersToolbarTextClasses } from "./pickersToolbarTextClasses.js";
|
||||
export interface ExportedPickersToolbarTextProps extends Omit<TypographyProps, 'classes' | 'variant' | 'align'> {
|
||||
classes?: Partial<PickersToolbarTextClasses>;
|
||||
}
|
||||
export interface PickersToolbarTextProps extends Omit<TypographyProps, 'classes'>, Pick<ExportedPickersToolbarTextProps, 'classes'> {
|
||||
selected?: boolean;
|
||||
value: React.ReactNode;
|
||||
}
|
||||
export declare const PickersToolbarText: React.ForwardRefExoticComponent<Omit<PickersToolbarTextProps, "ref"> & React.RefAttributes<HTMLSpanElement>>;
|
||||
61
node_modules/@mui/x-date-pickers/internals/components/PickersToolbarText.js
generated
vendored
Normal file
61
node_modules/@mui/x-date-pickers/internals/components/PickersToolbarText.js
generated
vendored
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
||||
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.PickersToolbarText = void 0;
|
||||
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
||||
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
||||
var React = _interopRequireWildcard(require("react"));
|
||||
var _clsx = _interopRequireDefault(require("clsx"));
|
||||
var _Typography = _interopRequireDefault(require("@mui/material/Typography"));
|
||||
var _styles = require("@mui/material/styles");
|
||||
var _composeClasses = _interopRequireDefault(require("@mui/utils/composeClasses"));
|
||||
var _pickersToolbarTextClasses = require("./pickersToolbarTextClasses");
|
||||
var _jsxRuntime = require("react/jsx-runtime");
|
||||
const _excluded = ["className", "classes", "selected", "value"];
|
||||
const useUtilityClasses = classes => {
|
||||
const slots = {
|
||||
root: ['root']
|
||||
};
|
||||
return (0, _composeClasses.default)(slots, _pickersToolbarTextClasses.getPickersToolbarTextUtilityClass, classes);
|
||||
};
|
||||
const PickersToolbarTextRoot = (0, _styles.styled)(_Typography.default, {
|
||||
name: 'MuiPickersToolbarText',
|
||||
slot: 'Root'
|
||||
})(({
|
||||
theme
|
||||
}) => ({
|
||||
transition: theme.transitions.create('color'),
|
||||
color: (theme.vars || theme).palette.text.secondary,
|
||||
[`&[data-selected]`]: {
|
||||
color: (theme.vars || theme).palette.text.primary
|
||||
}
|
||||
}));
|
||||
const PickersToolbarText = exports.PickersToolbarText = /*#__PURE__*/React.forwardRef(function PickersToolbarText(inProps, ref) {
|
||||
const props = (0, _styles.useThemeProps)({
|
||||
props: inProps,
|
||||
name: 'MuiPickersToolbarText'
|
||||
});
|
||||
const {
|
||||
className,
|
||||
classes: classesProp,
|
||||
selected,
|
||||
value
|
||||
} = props,
|
||||
other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
|
||||
const classes = useUtilityClasses(classesProp);
|
||||
return /*#__PURE__*/(0, _jsxRuntime.jsx)(PickersToolbarTextRoot, (0, _extends2.default)({
|
||||
ref: ref,
|
||||
className: (0, _clsx.default)(classes.root, className),
|
||||
component: "span",
|
||||
ownerState: props
|
||||
}, selected && {
|
||||
'data-selected': true
|
||||
}, other, {
|
||||
children: value
|
||||
}));
|
||||
});
|
||||
if (process.env.NODE_ENV !== "production") PickersToolbarText.displayName = "PickersToolbarText";
|
||||
7
node_modules/@mui/x-date-pickers/internals/components/pickersToolbarButtonClasses.d.ts
generated
vendored
Normal file
7
node_modules/@mui/x-date-pickers/internals/components/pickersToolbarButtonClasses.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
export interface PickersToolbarButtonClasses {
|
||||
/** Styles applied to the root element. */
|
||||
root: string;
|
||||
}
|
||||
export type PickersToolbarButtonClassKey = keyof PickersToolbarButtonClasses;
|
||||
export declare function getPickersToolbarButtonUtilityClass(slot: string): string;
|
||||
export declare const pickersToolbarButtonClasses: Record<"root", string>;
|
||||
14
node_modules/@mui/x-date-pickers/internals/components/pickersToolbarButtonClasses.js
generated
vendored
Normal file
14
node_modules/@mui/x-date-pickers/internals/components/pickersToolbarButtonClasses.js
generated
vendored
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.getPickersToolbarButtonUtilityClass = getPickersToolbarButtonUtilityClass;
|
||||
exports.pickersToolbarButtonClasses = void 0;
|
||||
var _generateUtilityClass = _interopRequireDefault(require("@mui/utils/generateUtilityClass"));
|
||||
var _generateUtilityClasses = _interopRequireDefault(require("@mui/utils/generateUtilityClasses"));
|
||||
function getPickersToolbarButtonUtilityClass(slot) {
|
||||
return (0, _generateUtilityClass.default)('MuiPickersToolbarButton', slot);
|
||||
}
|
||||
const pickersToolbarButtonClasses = exports.pickersToolbarButtonClasses = (0, _generateUtilityClasses.default)('MuiPickersToolbarButton', ['root']);
|
||||
11
node_modules/@mui/x-date-pickers/internals/components/pickersToolbarClasses.d.ts
generated
vendored
Normal file
11
node_modules/@mui/x-date-pickers/internals/components/pickersToolbarClasses.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
export interface PickersToolbarClasses {
|
||||
/** Styles applied to the root element. */
|
||||
root: string;
|
||||
/** Styles applied to the title element. */
|
||||
title: string;
|
||||
/** Styles applied to the content element. */
|
||||
content: string;
|
||||
}
|
||||
export type PickersToolbarClassKey = keyof PickersToolbarClasses;
|
||||
export declare function getPickersToolbarUtilityClass(slot: string): string;
|
||||
export declare const pickersToolbarClasses: Record<"root" | "title" | "content", string>;
|
||||
14
node_modules/@mui/x-date-pickers/internals/components/pickersToolbarClasses.js
generated
vendored
Normal file
14
node_modules/@mui/x-date-pickers/internals/components/pickersToolbarClasses.js
generated
vendored
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.getPickersToolbarUtilityClass = getPickersToolbarUtilityClass;
|
||||
exports.pickersToolbarClasses = void 0;
|
||||
var _generateUtilityClass = _interopRequireDefault(require("@mui/utils/generateUtilityClass"));
|
||||
var _generateUtilityClasses = _interopRequireDefault(require("@mui/utils/generateUtilityClasses"));
|
||||
function getPickersToolbarUtilityClass(slot) {
|
||||
return (0, _generateUtilityClass.default)('MuiPickersToolbar', slot);
|
||||
}
|
||||
const pickersToolbarClasses = exports.pickersToolbarClasses = (0, _generateUtilityClasses.default)('MuiPickersToolbar', ['root', 'title', 'content']);
|
||||
7
node_modules/@mui/x-date-pickers/internals/components/pickersToolbarTextClasses.d.ts
generated
vendored
Normal file
7
node_modules/@mui/x-date-pickers/internals/components/pickersToolbarTextClasses.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
export interface PickersToolbarTextClasses {
|
||||
/** Styles applied to the root element. */
|
||||
root: string;
|
||||
}
|
||||
export type PickersToolbarTextClassKey = keyof PickersToolbarTextClasses;
|
||||
export declare function getPickersToolbarTextUtilityClass(slot: string): string;
|
||||
export declare const pickersToolbarTextClasses: Record<"root", string>;
|
||||
14
node_modules/@mui/x-date-pickers/internals/components/pickersToolbarTextClasses.js
generated
vendored
Normal file
14
node_modules/@mui/x-date-pickers/internals/components/pickersToolbarTextClasses.js
generated
vendored
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.getPickersToolbarTextUtilityClass = getPickersToolbarTextUtilityClass;
|
||||
exports.pickersToolbarTextClasses = void 0;
|
||||
var _generateUtilityClass = _interopRequireDefault(require("@mui/utils/generateUtilityClass"));
|
||||
var _generateUtilityClasses = _interopRequireDefault(require("@mui/utils/generateUtilityClasses"));
|
||||
function getPickersToolbarTextUtilityClass(slot) {
|
||||
return (0, _generateUtilityClass.default)('MuiPickersToolbarText', slot);
|
||||
}
|
||||
const pickersToolbarTextClasses = exports.pickersToolbarTextClasses = (0, _generateUtilityClasses.default)('MuiPickersToolbarText', ['root']);
|
||||
7
node_modules/@mui/x-date-pickers/internals/constants/dimensions.d.ts
generated
vendored
Normal file
7
node_modules/@mui/x-date-pickers/internals/constants/dimensions.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
export declare const DAY_SIZE = 36;
|
||||
export declare const DAY_MARGIN = 2;
|
||||
export declare const DIALOG_WIDTH = 320;
|
||||
export declare const MAX_CALENDAR_HEIGHT = 280;
|
||||
export declare const VIEW_HEIGHT = 336;
|
||||
export declare const DIGITAL_CLOCK_VIEW_HEIGHT = 232;
|
||||
export declare const MULTI_SECTION_CLOCK_SECTION_WIDTH = 48;
|
||||
13
node_modules/@mui/x-date-pickers/internals/constants/dimensions.js
generated
vendored
Normal file
13
node_modules/@mui/x-date-pickers/internals/constants/dimensions.js
generated
vendored
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.VIEW_HEIGHT = exports.MULTI_SECTION_CLOCK_SECTION_WIDTH = exports.MAX_CALENDAR_HEIGHT = exports.DIGITAL_CLOCK_VIEW_HEIGHT = exports.DIALOG_WIDTH = exports.DAY_SIZE = exports.DAY_MARGIN = void 0;
|
||||
const DAY_SIZE = exports.DAY_SIZE = 36;
|
||||
const DAY_MARGIN = exports.DAY_MARGIN = 2;
|
||||
const DIALOG_WIDTH = exports.DIALOG_WIDTH = 320;
|
||||
const MAX_CALENDAR_HEIGHT = exports.MAX_CALENDAR_HEIGHT = 280;
|
||||
const VIEW_HEIGHT = exports.VIEW_HEIGHT = 336;
|
||||
const DIGITAL_CLOCK_VIEW_HEIGHT = exports.DIGITAL_CLOCK_VIEW_HEIGHT = 232;
|
||||
const MULTI_SECTION_CLOCK_SECTION_WIDTH = exports.MULTI_SECTION_CLOCK_SECTION_WIDTH = 48;
|
||||
26
node_modules/@mui/x-date-pickers/internals/demo/DemoContainer.d.ts
generated
vendored
Normal file
26
node_modules/@mui/x-date-pickers/internals/demo/DemoContainer.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
import * as React from 'react';
|
||||
import { StackProps } from '@mui/material/Stack';
|
||||
import { SxProps, Theme } from '@mui/material/styles';
|
||||
interface DemoGridProps {
|
||||
children: React.ReactNode;
|
||||
components: string[];
|
||||
sx?: SxProps<Theme>;
|
||||
}
|
||||
interface DemoItemProps extends Omit<StackProps, 'component'> {
|
||||
label?: React.ReactNode;
|
||||
component?: string;
|
||||
}
|
||||
/**
|
||||
* WARNING: This is an internal component used in documentation to achieve a desired layout.
|
||||
* Please do not use it in your application.
|
||||
*/
|
||||
export declare function DemoItem(props: DemoItemProps): React.JSX.Element;
|
||||
export declare namespace DemoItem {
|
||||
var displayName: string;
|
||||
}
|
||||
/**
|
||||
* WARNING: This is an internal component used in documentation to achieve a desired layout.
|
||||
* Please do not use it in your application.
|
||||
*/
|
||||
export declare function DemoContainer(props: DemoGridProps): React.JSX.Element;
|
||||
export {};
|
||||
188
node_modules/@mui/x-date-pickers/internals/demo/DemoContainer.js
generated
vendored
Normal file
188
node_modules/@mui/x-date-pickers/internals/demo/DemoContainer.js
generated
vendored
Normal file
|
|
@ -0,0 +1,188 @@
|
|||
"use strict";
|
||||
|
||||
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.DemoContainer = DemoContainer;
|
||||
exports.DemoItem = DemoItem;
|
||||
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
||||
var React = _interopRequireWildcard(require("react"));
|
||||
var _Stack = _interopRequireWildcard(require("@mui/material/Stack"));
|
||||
var _Typography = _interopRequireDefault(require("@mui/material/Typography"));
|
||||
var _TextField = require("@mui/material/TextField");
|
||||
var _PickersTextField = require("../../PickersTextField");
|
||||
var _jsxRuntime = require("react/jsx-runtime");
|
||||
const getChildTypeFromChildName = childName => {
|
||||
if (childName.match(/^([A-Za-z]+)Range(Calendar|Clock)$/)) {
|
||||
return 'multi-panel-UI-view';
|
||||
}
|
||||
if (childName.match(/^([A-Za-z]*)(DigitalClock)$/)) {
|
||||
return 'Tall-UI-view';
|
||||
}
|
||||
if (childName.match(/^Static([A-Za-z]+)/) || childName.match(/^([A-Za-z]+)(Calendar|Clock)$/)) {
|
||||
return 'UI-view';
|
||||
}
|
||||
if (childName.match(/^MultiInput([A-Za-z]+)RangeField$/)) {
|
||||
return 'multi-input-range-field';
|
||||
}
|
||||
if (childName.match(/^SingleInput([A-Za-z]+)RangeField$/) || childName.match(/^([A-Za-z]+)RangePicker$/)) {
|
||||
return 'single-input-range-field';
|
||||
}
|
||||
return 'single-input-field';
|
||||
};
|
||||
const getSupportedSectionFromChildName = childName => {
|
||||
if (childName.includes('DateTime')) {
|
||||
return 'date-time';
|
||||
}
|
||||
if (childName.includes('Date')) {
|
||||
return 'date';
|
||||
}
|
||||
return 'time';
|
||||
};
|
||||
/**
|
||||
* WARNING: This is an internal component used in documentation to achieve a desired layout.
|
||||
* Please do not use it in your application.
|
||||
*/
|
||||
function DemoItem(props) {
|
||||
const {
|
||||
label,
|
||||
children,
|
||||
component,
|
||||
sx: sxProp,
|
||||
alignItems = 'stretch'
|
||||
} = props;
|
||||
let spacing;
|
||||
let sx = sxProp;
|
||||
if (component && getChildTypeFromChildName(component) === 'multi-input-range-field') {
|
||||
spacing = 1.5;
|
||||
sx = (0, _extends2.default)({}, sx, {
|
||||
[`& .${_TextField.textFieldClasses.root}`]: {
|
||||
flexGrow: 1
|
||||
}
|
||||
});
|
||||
} else {
|
||||
spacing = 1;
|
||||
}
|
||||
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Stack.default, {
|
||||
direction: "column",
|
||||
alignItems: alignItems,
|
||||
spacing: spacing,
|
||||
sx: sx,
|
||||
children: [label && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
|
||||
variant: "body2",
|
||||
children: label
|
||||
}), children]
|
||||
});
|
||||
}
|
||||
DemoItem.displayName = 'DemoItem';
|
||||
const isDemoItem = child => {
|
||||
if (/*#__PURE__*/React.isValidElement(child) && typeof child.type !== 'string') {
|
||||
// @ts-ignore
|
||||
return child.type.displayName === 'DemoItem';
|
||||
}
|
||||
return false;
|
||||
};
|
||||
/**
|
||||
* WARNING: This is an internal component used in documentation to achieve a desired layout.
|
||||
* Please do not use it in your application.
|
||||
*/
|
||||
function DemoContainer(props) {
|
||||
const {
|
||||
children,
|
||||
components,
|
||||
sx: sxProp
|
||||
} = props;
|
||||
const childrenTypes = new Set();
|
||||
const childrenSupportedSections = new Set();
|
||||
components.forEach(childName => {
|
||||
childrenTypes.add(getChildTypeFromChildName(childName));
|
||||
childrenSupportedSections.add(getSupportedSectionFromChildName(childName));
|
||||
});
|
||||
const getSpacing = direction => {
|
||||
if (direction === 'row') {
|
||||
return childrenTypes.has('UI-view') || childrenTypes.has('Tall-UI-view') ? 3 : 2;
|
||||
}
|
||||
return childrenTypes.has('UI-view') ? 4 : 3;
|
||||
};
|
||||
let direction;
|
||||
let spacing;
|
||||
let extraSx = {};
|
||||
let demoItemSx = {};
|
||||
const sx = (0, _extends2.default)({
|
||||
overflow: 'auto',
|
||||
// Add padding as overflow can hide the outline text field label.
|
||||
pt: 1
|
||||
}, sxProp);
|
||||
if (components.length > 2 || childrenTypes.has('multi-input-range-field') || childrenTypes.has('single-input-range-field') || childrenTypes.has('multi-panel-UI-view') || childrenTypes.has('UI-view') || childrenSupportedSections.has('date-time')) {
|
||||
direction = 'column';
|
||||
spacing = getSpacing('column');
|
||||
} else {
|
||||
direction = {
|
||||
xs: 'column',
|
||||
lg: 'row'
|
||||
};
|
||||
spacing = {
|
||||
xs: getSpacing('column'),
|
||||
lg: getSpacing('row')
|
||||
};
|
||||
}
|
||||
if (childrenTypes.has('UI-view')) {
|
||||
// noop
|
||||
} else if (childrenTypes.has('single-input-range-field')) {
|
||||
if (!childrenSupportedSections.has('date-time')) {
|
||||
extraSx = {
|
||||
[`& > .${_TextField.textFieldClasses.root}, & > .${_PickersTextField.pickersTextFieldClasses.root}`]: {
|
||||
minWidth: 300
|
||||
}
|
||||
};
|
||||
} else {
|
||||
extraSx = {
|
||||
[`& > .${_TextField.textFieldClasses.root}, & > .${_PickersTextField.pickersTextFieldClasses.root}`]: {
|
||||
minWidth: {
|
||||
xs: 300,
|
||||
// If demo also contains MultiInputDateTimeRangeField, increase width to avoid cutting off the value.
|
||||
md: childrenTypes.has('multi-input-range-field') ? 460 : 440
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
} else if (childrenSupportedSections.has('date-time')) {
|
||||
extraSx = {
|
||||
[`& > .${_TextField.textFieldClasses.root}, & > .${_PickersTextField.pickersTextFieldClasses.root}`]: {
|
||||
minWidth: 270
|
||||
}
|
||||
};
|
||||
if (childrenTypes.has('multi-input-range-field')) {
|
||||
// increase width for the multi input date time range fields
|
||||
demoItemSx = {
|
||||
[`& > .${_Stack.stackClasses.root} > .${_TextField.textFieldClasses.root}, & > .${_Stack.stackClasses.root} > .${_PickersTextField.pickersTextFieldClasses.root}`]: {
|
||||
minWidth: 210
|
||||
}
|
||||
};
|
||||
}
|
||||
} else {
|
||||
extraSx = {
|
||||
[`& > .${_TextField.textFieldClasses.root}, & > .${_PickersTextField.pickersTextFieldClasses.root}`]: {
|
||||
minWidth: 200
|
||||
}
|
||||
};
|
||||
}
|
||||
const finalSx = (0, _extends2.default)({}, sx, extraSx);
|
||||
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Stack.default, {
|
||||
direction: direction,
|
||||
spacing: spacing,
|
||||
sx: finalSx,
|
||||
children: React.Children.map(children, child => {
|
||||
if (/*#__PURE__*/React.isValidElement(child) && isDemoItem(child)) {
|
||||
// Inject sx styles to the `DemoItem` if it is a direct child of `DemoContainer`.
|
||||
// @ts-ignore
|
||||
return /*#__PURE__*/React.cloneElement(child, {
|
||||
sx: (0, _extends2.default)({}, extraSx, demoItemSx)
|
||||
});
|
||||
}
|
||||
return child;
|
||||
})
|
||||
});
|
||||
}
|
||||
1
node_modules/@mui/x-date-pickers/internals/demo/index.d.ts
generated
vendored
Normal file
1
node_modules/@mui/x-date-pickers/internals/demo/index.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
export { DemoContainer, DemoItem } from "./DemoContainer.js";
|
||||
18
node_modules/@mui/x-date-pickers/internals/demo/index.js
generated
vendored
Normal file
18
node_modules/@mui/x-date-pickers/internals/demo/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "DemoContainer", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _DemoContainer.DemoContainer;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "DemoItem", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _DemoContainer.DemoItem;
|
||||
}
|
||||
});
|
||||
var _DemoContainer = require("./DemoContainer");
|
||||
24
node_modules/@mui/x-date-pickers/internals/hooks/date-helpers-hooks.d.ts
generated
vendored
Normal file
24
node_modules/@mui/x-date-pickers/internals/hooks/date-helpers-hooks.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
import { PickerOnChangeFn } from "./useViews.js";
|
||||
import { PickerSelectionState } from "./usePicker/index.js";
|
||||
import { PickersTimezone, PickerValidDate } from "../../models/index.js";
|
||||
export interface MonthValidationOptions {
|
||||
disablePast?: boolean;
|
||||
disableFuture?: boolean;
|
||||
minDate: PickerValidDate;
|
||||
maxDate: PickerValidDate;
|
||||
timezone: PickersTimezone;
|
||||
}
|
||||
export declare function useNextMonthDisabled(month: PickerValidDate, {
|
||||
disableFuture,
|
||||
maxDate,
|
||||
timezone
|
||||
}: Pick<MonthValidationOptions, 'disableFuture' | 'maxDate' | 'timezone'>): boolean;
|
||||
export declare function usePreviousMonthDisabled(month: PickerValidDate, {
|
||||
disablePast,
|
||||
minDate,
|
||||
timezone
|
||||
}: Pick<MonthValidationOptions, 'disablePast' | 'minDate' | 'timezone'>): boolean;
|
||||
export declare function useMeridiemMode(date: PickerValidDate | null, ampm: boolean | undefined, onChange: PickerOnChangeFn, selectionState?: PickerSelectionState): {
|
||||
meridiemMode: import("../utils/time-utils.js").Meridiem | null;
|
||||
handleMeridiemChange: (mode: "am" | "pm") => void;
|
||||
};
|
||||
49
node_modules/@mui/x-date-pickers/internals/hooks/date-helpers-hooks.js
generated
vendored
Normal file
49
node_modules/@mui/x-date-pickers/internals/hooks/date-helpers-hooks.js
generated
vendored
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
"use strict";
|
||||
|
||||
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.useMeridiemMode = useMeridiemMode;
|
||||
exports.useNextMonthDisabled = useNextMonthDisabled;
|
||||
exports.usePreviousMonthDisabled = usePreviousMonthDisabled;
|
||||
var React = _interopRequireWildcard(require("react"));
|
||||
var _timeUtils = require("../utils/time-utils");
|
||||
var _usePickerAdapter = require("../../hooks/usePickerAdapter");
|
||||
function useNextMonthDisabled(month, {
|
||||
disableFuture,
|
||||
maxDate,
|
||||
timezone
|
||||
}) {
|
||||
const adapter = (0, _usePickerAdapter.usePickerAdapter)();
|
||||
return React.useMemo(() => {
|
||||
const now = adapter.date(undefined, timezone);
|
||||
const lastEnabledMonth = adapter.startOfMonth(disableFuture && adapter.isBefore(now, maxDate) ? now : maxDate);
|
||||
return !adapter.isAfter(lastEnabledMonth, month);
|
||||
}, [disableFuture, maxDate, month, adapter, timezone]);
|
||||
}
|
||||
function usePreviousMonthDisabled(month, {
|
||||
disablePast,
|
||||
minDate,
|
||||
timezone
|
||||
}) {
|
||||
const adapter = (0, _usePickerAdapter.usePickerAdapter)();
|
||||
return React.useMemo(() => {
|
||||
const now = adapter.date(undefined, timezone);
|
||||
const firstEnabledMonth = adapter.startOfMonth(disablePast && adapter.isAfter(now, minDate) ? now : minDate);
|
||||
return !adapter.isBefore(firstEnabledMonth, month);
|
||||
}, [disablePast, minDate, month, adapter, timezone]);
|
||||
}
|
||||
function useMeridiemMode(date, ampm, onChange, selectionState) {
|
||||
const adapter = (0, _usePickerAdapter.usePickerAdapter)();
|
||||
const cleanDate = React.useMemo(() => !adapter.isValid(date) ? null : date, [adapter, date]);
|
||||
const meridiemMode = (0, _timeUtils.getMeridiem)(cleanDate, adapter);
|
||||
const handleMeridiemChange = React.useCallback(mode => {
|
||||
const timeWithMeridiem = cleanDate == null ? null : (0, _timeUtils.convertToMeridiem)(cleanDate, mode, Boolean(ampm), adapter);
|
||||
onChange(timeWithMeridiem, selectionState ?? 'partial');
|
||||
}, [ampm, cleanDate, onChange, selectionState, adapter]);
|
||||
return {
|
||||
meridiemMode,
|
||||
handleMeridiemChange
|
||||
};
|
||||
}
|
||||
15
node_modules/@mui/x-date-pickers/internals/hooks/useClockReferenceDate.d.ts
generated
vendored
Normal file
15
node_modules/@mui/x-date-pickers/internals/hooks/useClockReferenceDate.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
import { MuiPickersAdapter, PickersTimezone, PickerValidDate } from "../../models/index.js";
|
||||
import { PickerValue } from "../models/index.js";
|
||||
export declare const useClockReferenceDate: <TProps extends {}>({
|
||||
value,
|
||||
referenceDate: referenceDateProp,
|
||||
adapter,
|
||||
props,
|
||||
timezone
|
||||
}: {
|
||||
value: PickerValue;
|
||||
referenceDate: PickerValidDate | undefined;
|
||||
adapter: MuiPickersAdapter;
|
||||
props: TProps;
|
||||
timezone: PickersTimezone;
|
||||
}) => PickerValidDate;
|
||||
33
node_modules/@mui/x-date-pickers/internals/hooks/useClockReferenceDate.js
generated
vendored
Normal file
33
node_modules/@mui/x-date-pickers/internals/hooks/useClockReferenceDate.js
generated
vendored
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
"use strict";
|
||||
|
||||
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.useClockReferenceDate = void 0;
|
||||
var React = _interopRequireWildcard(require("react"));
|
||||
var _valueManagers = require("../utils/valueManagers");
|
||||
var _dateUtils = require("../utils/date-utils");
|
||||
var _getDefaultReferenceDate = require("../utils/getDefaultReferenceDate");
|
||||
const useClockReferenceDate = ({
|
||||
value,
|
||||
referenceDate: referenceDateProp,
|
||||
adapter,
|
||||
props,
|
||||
timezone
|
||||
}) => {
|
||||
const referenceDate = React.useMemo(() => _valueManagers.singleItemValueManager.getInitialReferenceValue({
|
||||
value,
|
||||
adapter,
|
||||
props,
|
||||
referenceDate: referenceDateProp,
|
||||
granularity: _getDefaultReferenceDate.SECTION_TYPE_GRANULARITY.day,
|
||||
timezone,
|
||||
getTodayDate: () => (0, _dateUtils.getTodayDate)(adapter, timezone, 'date')
|
||||
}),
|
||||
// We want the `referenceDate` to update on prop and `timezone` change (https://github.com/mui/mui-x/issues/10804)
|
||||
[referenceDateProp, timezone] // eslint-disable-line react-hooks/exhaustive-deps
|
||||
);
|
||||
return value ?? referenceDate;
|
||||
};
|
||||
exports.useClockReferenceDate = useClockReferenceDate;
|
||||
38
node_modules/@mui/x-date-pickers/internals/hooks/useControlledValue.d.ts
generated
vendored
Normal file
38
node_modules/@mui/x-date-pickers/internals/hooks/useControlledValue.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
import type { PickerRangeValue, PickerValueManager } from "../models/index.js";
|
||||
import { PickersTimezone, PickerValidDate } from "../../models/index.js";
|
||||
import { PickerValidValue } from "../models/index.js";
|
||||
/**
|
||||
* Hooks controlling the value while making sure that:
|
||||
* - The value returned by `onChange` always have the timezone of `props.value` or `props.defaultValue` if defined
|
||||
* - The value rendered is always the one from `props.timezone` if defined
|
||||
*/
|
||||
export declare const useControlledValue: <TValue extends PickerValidValue, TChange extends (...params: any[]) => void>({
|
||||
name,
|
||||
timezone: timezoneProp,
|
||||
value: valueProp,
|
||||
defaultValue,
|
||||
referenceDate,
|
||||
onChange: onChangeProp,
|
||||
valueManager
|
||||
}: UseControlledValueWithTimezoneParameters<TValue, TChange>) => {
|
||||
value: TValue;
|
||||
handleValueChange: TChange;
|
||||
timezone: string;
|
||||
};
|
||||
interface UseValueWithTimezoneParameters<TValue extends PickerValidValue, TChange extends (...params: any[]) => void> {
|
||||
timezone: PickersTimezone | undefined;
|
||||
value: TValue | undefined;
|
||||
defaultValue: TValue | undefined;
|
||||
/**
|
||||
* The reference date as passed to `props.referenceDate`.
|
||||
* It does not need to have its default value.
|
||||
* This is only used to determine the timezone to use when `props.value` and `props.defaultValue` are not defined.
|
||||
*/
|
||||
referenceDate?: TValue extends PickerRangeValue ? TValue | PickerValidDate : PickerValidDate;
|
||||
onChange: TChange | undefined;
|
||||
valueManager: PickerValueManager<TValue, any>;
|
||||
}
|
||||
interface UseControlledValueWithTimezoneParameters<TValue extends PickerValidValue, TChange extends (...params: any[]) => void> extends UseValueWithTimezoneParameters<TValue, TChange> {
|
||||
name: string;
|
||||
}
|
||||
export {};
|
||||
65
node_modules/@mui/x-date-pickers/internals/hooks/useControlledValue.js
generated
vendored
Normal file
65
node_modules/@mui/x-date-pickers/internals/hooks/useControlledValue.js
generated
vendored
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
||||
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.useControlledValue = void 0;
|
||||
var React = _interopRequireWildcard(require("react"));
|
||||
var _useEventCallback = _interopRequireDefault(require("@mui/utils/useEventCallback"));
|
||||
var _useControlled = _interopRequireDefault(require("@mui/utils/useControlled"));
|
||||
var _usePickerAdapter = require("../../hooks/usePickerAdapter");
|
||||
/**
|
||||
* Hooks controlling the value while making sure that:
|
||||
* - The value returned by `onChange` always have the timezone of `props.value` or `props.defaultValue` if defined
|
||||
* - The value rendered is always the one from `props.timezone` if defined
|
||||
*/
|
||||
const useControlledValue = ({
|
||||
name,
|
||||
timezone: timezoneProp,
|
||||
value: valueProp,
|
||||
defaultValue,
|
||||
referenceDate,
|
||||
onChange: onChangeProp,
|
||||
valueManager
|
||||
}) => {
|
||||
const adapter = (0, _usePickerAdapter.usePickerAdapter)();
|
||||
const [valueWithInputTimezone, setValue] = (0, _useControlled.default)({
|
||||
name,
|
||||
state: 'value',
|
||||
controlled: valueProp,
|
||||
default: defaultValue ?? valueManager.emptyValue
|
||||
});
|
||||
const inputTimezone = React.useMemo(() => valueManager.getTimezone(adapter, valueWithInputTimezone), [adapter, valueManager, valueWithInputTimezone]);
|
||||
const setInputTimezone = (0, _useEventCallback.default)(newValue => {
|
||||
if (inputTimezone == null) {
|
||||
return newValue;
|
||||
}
|
||||
return valueManager.setTimezone(adapter, inputTimezone, newValue);
|
||||
});
|
||||
const timezoneToRender = React.useMemo(() => {
|
||||
if (timezoneProp) {
|
||||
return timezoneProp;
|
||||
}
|
||||
if (inputTimezone) {
|
||||
return inputTimezone;
|
||||
}
|
||||
if (referenceDate) {
|
||||
return adapter.getTimezone(Array.isArray(referenceDate) ? referenceDate[0] : referenceDate);
|
||||
}
|
||||
return 'default';
|
||||
}, [timezoneProp, inputTimezone, referenceDate, adapter]);
|
||||
const valueWithTimezoneToRender = React.useMemo(() => valueManager.setTimezone(adapter, timezoneToRender, valueWithInputTimezone), [valueManager, adapter, timezoneToRender, valueWithInputTimezone]);
|
||||
const handleValueChange = (0, _useEventCallback.default)((newValue, ...otherParams) => {
|
||||
const newValueWithInputTimezone = setInputTimezone(newValue);
|
||||
setValue(newValueWithInputTimezone);
|
||||
onChangeProp?.(newValueWithInputTimezone, ...otherParams);
|
||||
});
|
||||
return {
|
||||
value: valueWithTimezoneToRender,
|
||||
handleValueChange,
|
||||
timezone: timezoneToRender
|
||||
};
|
||||
};
|
||||
exports.useControlledValue = useControlledValue;
|
||||
2
node_modules/@mui/x-date-pickers/internals/hooks/useDesktopPicker/index.d.ts
generated
vendored
Normal file
2
node_modules/@mui/x-date-pickers/internals/hooks/useDesktopPicker/index.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
export { useDesktopPicker } from "./useDesktopPicker.js";
|
||||
export type { UseDesktopPickerSlots, UseDesktopPickerSlotProps, ExportedUseDesktopPickerSlotProps, DesktopOnlyPickerProps, UseDesktopPickerProps } from "./useDesktopPicker.types.js";
|
||||
12
node_modules/@mui/x-date-pickers/internals/hooks/useDesktopPicker/index.js
generated
vendored
Normal file
12
node_modules/@mui/x-date-pickers/internals/hooks/useDesktopPicker/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "useDesktopPicker", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _useDesktopPicker.useDesktopPicker;
|
||||
}
|
||||
});
|
||||
var _useDesktopPicker = require("./useDesktopPicker");
|
||||
16
node_modules/@mui/x-date-pickers/internals/hooks/useDesktopPicker/useDesktopPicker.d.ts
generated
vendored
Normal file
16
node_modules/@mui/x-date-pickers/internals/hooks/useDesktopPicker/useDesktopPicker.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
import * as React from 'react';
|
||||
import { UseDesktopPickerParams, UseDesktopPickerProps } from "./useDesktopPicker.types.js";
|
||||
import { DateOrTimeViewWithMeridiem } from "../../models/index.js";
|
||||
/**
|
||||
* Hook managing all the single-date desktop pickers:
|
||||
* - DesktopDatePicker
|
||||
* - DesktopDateTimePicker
|
||||
* - DesktopTimePicker
|
||||
*/
|
||||
export declare const useDesktopPicker: <TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean, TExternalProps extends UseDesktopPickerProps<TView, TEnableAccessibleFieldDOMStructure, any, TExternalProps>>({
|
||||
props,
|
||||
steps,
|
||||
...pickerParams
|
||||
}: UseDesktopPickerParams<TView, TEnableAccessibleFieldDOMStructure, TExternalProps>) => {
|
||||
renderPicker: () => React.JSX.Element;
|
||||
};
|
||||
106
node_modules/@mui/x-date-pickers/internals/hooks/useDesktopPicker/useDesktopPicker.js
generated
vendored
Normal file
106
node_modules/@mui/x-date-pickers/internals/hooks/useDesktopPicker/useDesktopPicker.js
generated
vendored
Normal file
|
|
@ -0,0 +1,106 @@
|
|||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
||||
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.useDesktopPicker = void 0;
|
||||
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
||||
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
||||
var React = _interopRequireWildcard(require("react"));
|
||||
var _useSlotProps2 = _interopRequireDefault(require("@mui/utils/useSlotProps"));
|
||||
var _PickerPopper = require("../../components/PickerPopper/PickerPopper");
|
||||
var _usePicker = require("../usePicker");
|
||||
var _PickersLayout = require("../../../PickersLayout");
|
||||
var _PickerProvider = require("../../components/PickerProvider");
|
||||
var _PickerFieldUI = require("../../components/PickerFieldUI");
|
||||
var _createNonRangePickerStepNavigation = require("../../utils/createNonRangePickerStepNavigation");
|
||||
var _jsxRuntime = require("react/jsx-runtime");
|
||||
const _excluded = ["props", "steps"],
|
||||
_excluded2 = ["ownerState"];
|
||||
/**
|
||||
* Hook managing all the single-date desktop pickers:
|
||||
* - DesktopDatePicker
|
||||
* - DesktopDateTimePicker
|
||||
* - DesktopTimePicker
|
||||
*/
|
||||
const useDesktopPicker = _ref => {
|
||||
let {
|
||||
props,
|
||||
steps
|
||||
} = _ref,
|
||||
pickerParams = (0, _objectWithoutPropertiesLoose2.default)(_ref, _excluded);
|
||||
const {
|
||||
slots,
|
||||
slotProps: innerSlotProps,
|
||||
label,
|
||||
inputRef,
|
||||
localeText
|
||||
} = props;
|
||||
const getStepNavigation = (0, _createNonRangePickerStepNavigation.createNonRangePickerStepNavigation)({
|
||||
steps
|
||||
});
|
||||
const {
|
||||
providerProps,
|
||||
renderCurrentView,
|
||||
ownerState
|
||||
} = (0, _usePicker.usePicker)((0, _extends2.default)({}, pickerParams, {
|
||||
props,
|
||||
localeText,
|
||||
autoFocusView: true,
|
||||
viewContainerRole: 'dialog',
|
||||
variant: 'desktop',
|
||||
getStepNavigation
|
||||
}));
|
||||
const labelId = providerProps.privateContextValue.labelId;
|
||||
const isToolbarHidden = innerSlotProps?.toolbar?.hidden ?? false;
|
||||
const Field = slots.field;
|
||||
const _useSlotProps = (0, _useSlotProps2.default)({
|
||||
elementType: Field,
|
||||
externalSlotProps: innerSlotProps?.field,
|
||||
additionalProps: (0, _extends2.default)({}, isToolbarHidden && {
|
||||
id: labelId
|
||||
}),
|
||||
ownerState
|
||||
}),
|
||||
fieldProps = (0, _objectWithoutPropertiesLoose2.default)(_useSlotProps, _excluded2);
|
||||
const Layout = slots.layout ?? _PickersLayout.PickersLayout;
|
||||
let labelledById = labelId;
|
||||
if (isToolbarHidden) {
|
||||
if (label) {
|
||||
labelledById = `${labelId}-label`;
|
||||
} else {
|
||||
labelledById = undefined;
|
||||
}
|
||||
}
|
||||
const slotProps = (0, _extends2.default)({}, innerSlotProps, {
|
||||
toolbar: (0, _extends2.default)({}, innerSlotProps?.toolbar, {
|
||||
titleId: labelId
|
||||
}),
|
||||
popper: (0, _extends2.default)({
|
||||
'aria-labelledby': labelledById
|
||||
}, innerSlotProps?.popper)
|
||||
});
|
||||
const renderPicker = () => /*#__PURE__*/(0, _jsxRuntime.jsx)(_PickerProvider.PickerProvider, (0, _extends2.default)({}, providerProps, {
|
||||
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_PickerFieldUI.PickerFieldUIContextProvider, {
|
||||
slots: slots,
|
||||
slotProps: slotProps,
|
||||
inputRef: inputRef,
|
||||
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(Field, (0, _extends2.default)({}, fieldProps)), /*#__PURE__*/(0, _jsxRuntime.jsx)(_PickerPopper.PickerPopper, {
|
||||
slots: slots,
|
||||
slotProps: slotProps,
|
||||
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(Layout, (0, _extends2.default)({}, slotProps?.layout, {
|
||||
slots: slots,
|
||||
slotProps: slotProps,
|
||||
children: renderCurrentView()
|
||||
}))
|
||||
})]
|
||||
})
|
||||
}));
|
||||
if (process.env.NODE_ENV !== "production") renderPicker.displayName = "renderPicker";
|
||||
return {
|
||||
renderPicker
|
||||
};
|
||||
};
|
||||
exports.useDesktopPicker = useDesktopPicker;
|
||||
48
node_modules/@mui/x-date-pickers/internals/hooks/useDesktopPicker/useDesktopPicker.types.d.ts
generated
vendored
Normal file
48
node_modules/@mui/x-date-pickers/internals/hooks/useDesktopPicker/useDesktopPicker.types.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
import * as React from 'react';
|
||||
import { MakeRequired, SlotComponentPropsFromProps } from '@mui/x-internals/types';
|
||||
import { BasePickerProps } from "../../models/props/basePickerProps.js";
|
||||
import { PickerPopperSlots, PickerPopperSlotProps } from "../../components/PickerPopper/PickerPopper.js";
|
||||
import { UsePickerParameters, UsePickerNonStaticProps, UsePickerProps } from "../usePicker/index.js";
|
||||
import { PickerFieldSlotProps, PickerOwnerState } from "../../../models/index.js";
|
||||
import { ExportedPickersLayoutSlots, ExportedPickersLayoutSlotProps, PickersLayoutSlotProps } from "../../../PickersLayout/PickersLayout.types.js";
|
||||
import { DateOrTimeViewWithMeridiem, PickerValue } from "../../models/index.js";
|
||||
import { PickerFieldUISlotsFromContext, PickerFieldUISlotPropsFromContext } from "../../components/PickerFieldUI.js";
|
||||
import { PickerStep } from "../../utils/createNonRangePickerStepNavigation.js";
|
||||
export interface UseDesktopPickerSlots extends Pick<PickerPopperSlots, 'desktopPaper' | 'desktopTransition' | 'desktopTrapFocus' | 'popper'>, ExportedPickersLayoutSlots<PickerValue>, PickerFieldUISlotsFromContext {
|
||||
/**
|
||||
* Component used to enter the date with the keyboard.
|
||||
*/
|
||||
field: React.ElementType;
|
||||
}
|
||||
export interface ExportedUseDesktopPickerSlotProps<TEnableAccessibleFieldDOMStructure extends boolean> extends PickerPopperSlotProps, ExportedPickersLayoutSlotProps<PickerValue>, PickerFieldUISlotPropsFromContext {
|
||||
field?: SlotComponentPropsFromProps<PickerFieldSlotProps<PickerValue, TEnableAccessibleFieldDOMStructure>, {}, PickerOwnerState>;
|
||||
}
|
||||
export interface UseDesktopPickerSlotProps<TEnableAccessibleFieldDOMStructure extends boolean> extends ExportedUseDesktopPickerSlotProps<TEnableAccessibleFieldDOMStructure>, Pick<PickersLayoutSlotProps<PickerValue>, 'toolbar'> {}
|
||||
export interface DesktopOnlyPickerProps extends UsePickerNonStaticProps {
|
||||
/**
|
||||
* If `true`, the `input` element is focused during the first mount.
|
||||
* @default false
|
||||
*/
|
||||
autoFocus?: boolean;
|
||||
}
|
||||
export interface UseDesktopPickerProps<TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean, TError, TExternalProps extends UsePickerProps<PickerValue, TView, TError, any>> extends BasePickerProps<PickerValue, any, TError, TExternalProps>, MakeRequired<DesktopOnlyPickerProps, 'format'> {
|
||||
/**
|
||||
* Overridable component slots.
|
||||
* @default {}
|
||||
*/
|
||||
slots: UseDesktopPickerSlots;
|
||||
/**
|
||||
* The props used for each component slot.
|
||||
* @default {}
|
||||
*/
|
||||
slotProps?: UseDesktopPickerSlotProps<TEnableAccessibleFieldDOMStructure>;
|
||||
}
|
||||
export interface UseDesktopPickerParams<TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean, TExternalProps extends UseDesktopPickerProps<TView, TEnableAccessibleFieldDOMStructure, any, TExternalProps>> extends Pick<UsePickerParameters<PickerValue, TView, TExternalProps>, 'valueManager' | 'valueType' | 'validator' | 'rendererInterceptor' | 'ref'> {
|
||||
props: TExternalProps;
|
||||
/**
|
||||
* Steps available for the picker.
|
||||
* This will be used to define the behavior of navigation actions.
|
||||
* If null, the picker will not have any step navigation.
|
||||
*/
|
||||
steps: PickerStep[] | null;
|
||||
}
|
||||
5
node_modules/@mui/x-date-pickers/internals/hooks/useDesktopPicker/useDesktopPicker.types.js
generated
vendored
Normal file
5
node_modules/@mui/x-date-pickers/internals/hooks/useDesktopPicker/useDesktopPicker.types.js
generated
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
15
node_modules/@mui/x-date-pickers/internals/hooks/useField/buildSectionsFromFormat.d.ts
generated
vendored
Normal file
15
node_modules/@mui/x-date-pickers/internals/hooks/useField/buildSectionsFromFormat.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
import { FieldSection, MuiPickersAdapter, PickerValidDate } from "../../../models/index.js";
|
||||
import { PickersLocaleText } from "../../../locales/index.js";
|
||||
interface BuildSectionsFromFormatParameters {
|
||||
adapter: MuiPickersAdapter;
|
||||
format: string;
|
||||
formatDensity: 'dense' | 'spacious';
|
||||
isRtl: boolean;
|
||||
shouldRespectLeadingZeros: boolean;
|
||||
localeText: PickersLocaleText;
|
||||
localizedDigits: string[];
|
||||
date: PickerValidDate | null;
|
||||
enableAccessibleFieldDOMStructure: boolean;
|
||||
}
|
||||
export declare const buildSectionsFromFormat: (parameters: BuildSectionsFromFormatParameters) => FieldSection[];
|
||||
export {};
|
||||
263
node_modules/@mui/x-date-pickers/internals/hooks/useField/buildSectionsFromFormat.js
generated
vendored
Normal file
263
node_modules/@mui/x-date-pickers/internals/hooks/useField/buildSectionsFromFormat.js
generated
vendored
Normal file
|
|
@ -0,0 +1,263 @@
|
|||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.buildSectionsFromFormat = void 0;
|
||||
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
||||
var _useField = require("./useField.utils");
|
||||
const expandFormat = ({
|
||||
adapter,
|
||||
format
|
||||
}) => {
|
||||
// Expand the provided format
|
||||
let formatExpansionOverflow = 10;
|
||||
let prevFormat = format;
|
||||
let nextFormat = adapter.expandFormat(format);
|
||||
while (nextFormat !== prevFormat) {
|
||||
prevFormat = nextFormat;
|
||||
nextFormat = adapter.expandFormat(prevFormat);
|
||||
formatExpansionOverflow -= 1;
|
||||
if (formatExpansionOverflow < 0) {
|
||||
throw new Error('MUI X: The format expansion seems to be in an infinite loop. Please open an issue with the format passed to the component.');
|
||||
}
|
||||
}
|
||||
return nextFormat;
|
||||
};
|
||||
const getEscapedPartsFromFormat = ({
|
||||
adapter,
|
||||
expandedFormat
|
||||
}) => {
|
||||
const escapedParts = [];
|
||||
const {
|
||||
start: startChar,
|
||||
end: endChar
|
||||
} = adapter.escapedCharacters;
|
||||
const regExp = new RegExp(`(\\${startChar}[^\\${endChar}]*\\${endChar})+`, 'g');
|
||||
let match = null;
|
||||
// eslint-disable-next-line no-cond-assign
|
||||
while (match = regExp.exec(expandedFormat)) {
|
||||
escapedParts.push({
|
||||
start: match.index,
|
||||
end: regExp.lastIndex - 1
|
||||
});
|
||||
}
|
||||
return escapedParts;
|
||||
};
|
||||
const getSectionPlaceholder = (adapter, localeText, sectionConfig, sectionFormat) => {
|
||||
switch (sectionConfig.type) {
|
||||
case 'year':
|
||||
{
|
||||
return localeText.fieldYearPlaceholder({
|
||||
digitAmount: adapter.formatByString(adapter.date(undefined, 'default'), sectionFormat).length,
|
||||
format: sectionFormat
|
||||
});
|
||||
}
|
||||
case 'month':
|
||||
{
|
||||
return localeText.fieldMonthPlaceholder({
|
||||
contentType: sectionConfig.contentType,
|
||||
format: sectionFormat
|
||||
});
|
||||
}
|
||||
case 'day':
|
||||
{
|
||||
return localeText.fieldDayPlaceholder({
|
||||
format: sectionFormat
|
||||
});
|
||||
}
|
||||
case 'weekDay':
|
||||
{
|
||||
return localeText.fieldWeekDayPlaceholder({
|
||||
contentType: sectionConfig.contentType,
|
||||
format: sectionFormat
|
||||
});
|
||||
}
|
||||
case 'hours':
|
||||
{
|
||||
return localeText.fieldHoursPlaceholder({
|
||||
format: sectionFormat
|
||||
});
|
||||
}
|
||||
case 'minutes':
|
||||
{
|
||||
return localeText.fieldMinutesPlaceholder({
|
||||
format: sectionFormat
|
||||
});
|
||||
}
|
||||
case 'seconds':
|
||||
{
|
||||
return localeText.fieldSecondsPlaceholder({
|
||||
format: sectionFormat
|
||||
});
|
||||
}
|
||||
case 'meridiem':
|
||||
{
|
||||
return localeText.fieldMeridiemPlaceholder({
|
||||
format: sectionFormat
|
||||
});
|
||||
}
|
||||
default:
|
||||
{
|
||||
return sectionFormat;
|
||||
}
|
||||
}
|
||||
};
|
||||
const createSection = ({
|
||||
adapter,
|
||||
date,
|
||||
shouldRespectLeadingZeros,
|
||||
localeText,
|
||||
localizedDigits,
|
||||
now,
|
||||
token,
|
||||
startSeparator
|
||||
}) => {
|
||||
if (token === '') {
|
||||
throw new Error('MUI X: Should not call `commitToken` with an empty token');
|
||||
}
|
||||
const sectionConfig = (0, _useField.getDateSectionConfigFromFormatToken)(adapter, token);
|
||||
const hasLeadingZerosInFormat = (0, _useField.doesSectionFormatHaveLeadingZeros)(adapter, sectionConfig.contentType, sectionConfig.type, token);
|
||||
const hasLeadingZerosInInput = shouldRespectLeadingZeros ? hasLeadingZerosInFormat : sectionConfig.contentType === 'digit';
|
||||
const isValidDate = adapter.isValid(date);
|
||||
let sectionValue = isValidDate ? adapter.formatByString(date, token) : '';
|
||||
let maxLength = null;
|
||||
if (hasLeadingZerosInInput) {
|
||||
if (hasLeadingZerosInFormat) {
|
||||
maxLength = sectionValue === '' ? adapter.formatByString(now, token).length : sectionValue.length;
|
||||
} else {
|
||||
if (sectionConfig.maxLength == null) {
|
||||
throw new Error(`MUI X: The token ${token} should have a 'maxLength' property on it's adapter`);
|
||||
}
|
||||
maxLength = sectionConfig.maxLength;
|
||||
if (isValidDate) {
|
||||
sectionValue = (0, _useField.applyLocalizedDigits)((0, _useField.cleanLeadingZeros)((0, _useField.removeLocalizedDigits)(sectionValue, localizedDigits), maxLength), localizedDigits);
|
||||
}
|
||||
}
|
||||
}
|
||||
return (0, _extends2.default)({}, sectionConfig, {
|
||||
format: token,
|
||||
maxLength,
|
||||
value: sectionValue,
|
||||
placeholder: getSectionPlaceholder(adapter, localeText, sectionConfig, token),
|
||||
hasLeadingZerosInFormat,
|
||||
hasLeadingZerosInInput,
|
||||
startSeparator,
|
||||
endSeparator: '',
|
||||
modified: false
|
||||
});
|
||||
};
|
||||
const buildSections = parameters => {
|
||||
const {
|
||||
adapter,
|
||||
expandedFormat,
|
||||
escapedParts
|
||||
} = parameters;
|
||||
const now = adapter.date(undefined);
|
||||
const sections = [];
|
||||
let startSeparator = '';
|
||||
|
||||
// This RegExp tests if the beginning of a string corresponds to a supported token
|
||||
const validTokens = Object.keys(adapter.formatTokenMap).sort((a, b) => b.length - a.length); // Sort to put longest word first
|
||||
|
||||
const regExpFirstWordInFormat = /^([a-zA-Z]+)/;
|
||||
const regExpWordOnlyComposedOfTokens = new RegExp(`^(${validTokens.join('|')})*$`);
|
||||
const regExpFirstTokenInWord = new RegExp(`^(${validTokens.join('|')})`);
|
||||
const getEscapedPartOfCurrentChar = i => escapedParts.find(escapeIndex => escapeIndex.start <= i && escapeIndex.end >= i);
|
||||
let i = 0;
|
||||
while (i < expandedFormat.length) {
|
||||
const escapedPartOfCurrentChar = getEscapedPartOfCurrentChar(i);
|
||||
const isEscapedChar = escapedPartOfCurrentChar != null;
|
||||
const firstWordInFormat = regExpFirstWordInFormat.exec(expandedFormat.slice(i))?.[1];
|
||||
|
||||
// The first word in the format is only composed of tokens.
|
||||
// We extract those tokens to create a new sections.
|
||||
if (!isEscapedChar && firstWordInFormat != null && regExpWordOnlyComposedOfTokens.test(firstWordInFormat)) {
|
||||
let word = firstWordInFormat;
|
||||
while (word.length > 0) {
|
||||
const firstWord = regExpFirstTokenInWord.exec(word)[1];
|
||||
word = word.slice(firstWord.length);
|
||||
sections.push(createSection((0, _extends2.default)({}, parameters, {
|
||||
now,
|
||||
token: firstWord,
|
||||
startSeparator
|
||||
})));
|
||||
startSeparator = '';
|
||||
}
|
||||
i += firstWordInFormat.length;
|
||||
}
|
||||
// The remaining format does not start with a token,
|
||||
// We take the first character and add it to the current section's end separator.
|
||||
else {
|
||||
const char = expandedFormat[i];
|
||||
|
||||
// If we are on the opening or closing character of an escaped part of the format,
|
||||
// Then we ignore this character.
|
||||
const isEscapeBoundary = isEscapedChar && escapedPartOfCurrentChar?.start === i || escapedPartOfCurrentChar?.end === i;
|
||||
if (!isEscapeBoundary) {
|
||||
if (sections.length === 0) {
|
||||
startSeparator += char;
|
||||
} else {
|
||||
sections[sections.length - 1].endSeparator += char;
|
||||
sections[sections.length - 1].isEndFormatSeparator = true;
|
||||
}
|
||||
}
|
||||
i += 1;
|
||||
}
|
||||
}
|
||||
if (sections.length === 0 && startSeparator.length > 0) {
|
||||
sections.push({
|
||||
type: 'empty',
|
||||
contentType: 'letter',
|
||||
maxLength: null,
|
||||
format: '',
|
||||
value: '',
|
||||
placeholder: '',
|
||||
hasLeadingZerosInFormat: false,
|
||||
hasLeadingZerosInInput: false,
|
||||
startSeparator,
|
||||
endSeparator: '',
|
||||
modified: false
|
||||
});
|
||||
}
|
||||
return sections;
|
||||
};
|
||||
const postProcessSections = ({
|
||||
isRtl,
|
||||
formatDensity,
|
||||
sections
|
||||
}) => {
|
||||
return sections.map(section => {
|
||||
const cleanSeparator = separator => {
|
||||
let cleanedSeparator = separator;
|
||||
if (isRtl && cleanedSeparator !== null && cleanedSeparator.includes(' ')) {
|
||||
cleanedSeparator = `\u2069${cleanedSeparator}\u2066`;
|
||||
}
|
||||
if (formatDensity === 'spacious' && ['/', '.', '-'].includes(cleanedSeparator)) {
|
||||
cleanedSeparator = ` ${cleanedSeparator} `;
|
||||
}
|
||||
return cleanedSeparator;
|
||||
};
|
||||
section.startSeparator = cleanSeparator(section.startSeparator);
|
||||
section.endSeparator = cleanSeparator(section.endSeparator);
|
||||
return section;
|
||||
});
|
||||
};
|
||||
const buildSectionsFromFormat = parameters => {
|
||||
let expandedFormat = expandFormat(parameters);
|
||||
if (parameters.isRtl && parameters.enableAccessibleFieldDOMStructure) {
|
||||
expandedFormat = expandedFormat.split(' ').reverse().join(' ');
|
||||
}
|
||||
const escapedParts = getEscapedPartsFromFormat((0, _extends2.default)({}, parameters, {
|
||||
expandedFormat
|
||||
}));
|
||||
const sections = buildSections((0, _extends2.default)({}, parameters, {
|
||||
expandedFormat,
|
||||
escapedParts
|
||||
}));
|
||||
return postProcessSections((0, _extends2.default)({}, parameters, {
|
||||
sections
|
||||
}));
|
||||
};
|
||||
exports.buildSectionsFromFormat = buildSectionsFromFormat;
|
||||
4
node_modules/@mui/x-date-pickers/internals/hooks/useField/index.d.ts
generated
vendored
Normal file
4
node_modules/@mui/x-date-pickers/internals/hooks/useField/index.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
export { useField } from "./useField.js";
|
||||
export type { UseFieldInternalProps, UseFieldParameters, UseFieldReturnValue, UseFieldProps, FieldValueManager, FieldChangeHandler, FieldChangeHandlerContext } from "./useField.types.js";
|
||||
export { createDateStrForV7HiddenInputFromSections, createDateStrForV6InputFromSections } from "./useField.utils.js";
|
||||
export { useFieldInternalPropsWithDefaults } from "./useFieldInternalPropsWithDefaults.js";
|
||||
32
node_modules/@mui/x-date-pickers/internals/hooks/useField/index.js
generated
vendored
Normal file
32
node_modules/@mui/x-date-pickers/internals/hooks/useField/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "createDateStrForV6InputFromSections", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _useField2.createDateStrForV6InputFromSections;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "createDateStrForV7HiddenInputFromSections", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _useField2.createDateStrForV7HiddenInputFromSections;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "useField", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _useField.useField;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "useFieldInternalPropsWithDefaults", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _useFieldInternalPropsWithDefaults.useFieldInternalPropsWithDefaults;
|
||||
}
|
||||
});
|
||||
var _useField = require("./useField");
|
||||
var _useField2 = require("./useField.utils");
|
||||
var _useFieldInternalPropsWithDefaults = require("./useFieldInternalPropsWithDefaults");
|
||||
9
node_modules/@mui/x-date-pickers/internals/hooks/useField/syncSelectionToDOM.d.ts
generated
vendored
Normal file
9
node_modules/@mui/x-date-pickers/internals/hooks/useField/syncSelectionToDOM.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
import { PickerValidValue } from "../../models/index.js";
|
||||
import { UseFieldDOMGetters } from "./useField.types.js";
|
||||
import { UseFieldStateReturnValue } from "./useFieldState.js";
|
||||
export declare function syncSelectionToDOM<TValue extends PickerValidValue>(parameters: SyncSelectionToDOMParameters<TValue>): void;
|
||||
export interface SyncSelectionToDOMParameters<TValue extends PickerValidValue> {
|
||||
domGetters: UseFieldDOMGetters;
|
||||
stateResponse: UseFieldStateReturnValue<TValue>;
|
||||
focused: boolean;
|
||||
}
|
||||
60
node_modules/@mui/x-date-pickers/internals/hooks/useField/syncSelectionToDOM.js
generated
vendored
Normal file
60
node_modules/@mui/x-date-pickers/internals/hooks/useField/syncSelectionToDOM.js
generated
vendored
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.syncSelectionToDOM = syncSelectionToDOM;
|
||||
var _ownerDocument = _interopRequireDefault(require("@mui/utils/ownerDocument"));
|
||||
var _utils = require("../../utils/utils");
|
||||
function syncSelectionToDOM(parameters) {
|
||||
const {
|
||||
focused,
|
||||
domGetters,
|
||||
stateResponse: {
|
||||
// States and derived states
|
||||
parsedSelectedSections,
|
||||
state
|
||||
}
|
||||
} = parameters;
|
||||
if (!domGetters.isReady()) {
|
||||
return;
|
||||
}
|
||||
const selection = (0, _ownerDocument.default)(domGetters.getRoot()).getSelection();
|
||||
if (!selection) {
|
||||
return;
|
||||
}
|
||||
if (parsedSelectedSections == null) {
|
||||
// If the selection contains an element inside the field, we reset it.
|
||||
if (selection.rangeCount > 0 &&
|
||||
// Firefox can return a Restricted object here
|
||||
selection.getRangeAt(0).startContainer instanceof Node && domGetters.getRoot().contains(selection.getRangeAt(0).startContainer)) {
|
||||
selection.removeAllRanges();
|
||||
}
|
||||
if (focused) {
|
||||
domGetters.getRoot().blur();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// On multi input range pickers we want to update selection range only for the active input
|
||||
if (!domGetters.getRoot().contains((0, _utils.getActiveElement)(domGetters.getRoot()))) {
|
||||
return;
|
||||
}
|
||||
const range = new window.Range();
|
||||
let target;
|
||||
if (parsedSelectedSections === 'all') {
|
||||
target = domGetters.getRoot();
|
||||
} else {
|
||||
const section = state.sections[parsedSelectedSections];
|
||||
if (section.type === 'empty') {
|
||||
target = domGetters.getSectionContainer(parsedSelectedSections);
|
||||
} else {
|
||||
target = domGetters.getSectionContent(parsedSelectedSections);
|
||||
}
|
||||
}
|
||||
range.selectNodeContents(target);
|
||||
target.focus();
|
||||
selection.removeAllRanges();
|
||||
selection.addRange(range);
|
||||
}
|
||||
3
node_modules/@mui/x-date-pickers/internals/hooks/useField/useField.d.ts
generated
vendored
Normal file
3
node_modules/@mui/x-date-pickers/internals/hooks/useField/useField.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
import { UseFieldParameters, UseFieldReturnValue, UseFieldProps } from "./useField.types.js";
|
||||
import { PickerValidValue } from "../../models/index.js";
|
||||
export declare const useField: <TValue extends PickerValidValue, TEnableAccessibleFieldDOMStructure extends boolean, TError, TValidationProps extends {}, TProps extends UseFieldProps<TEnableAccessibleFieldDOMStructure>>(parameters: UseFieldParameters<TValue, TEnableAccessibleFieldDOMStructure, TError, TValidationProps, TProps>) => UseFieldReturnValue<TEnableAccessibleFieldDOMStructure, TProps>;
|
||||
16
node_modules/@mui/x-date-pickers/internals/hooks/useField/useField.js
generated
vendored
Normal file
16
node_modules/@mui/x-date-pickers/internals/hooks/useField/useField.js
generated
vendored
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.useField = void 0;
|
||||
var _useFieldV7TextField = require("./useFieldV7TextField");
|
||||
var _useFieldV6TextField = require("./useFieldV6TextField");
|
||||
var _useNullableFieldPrivateContext = require("../useNullableFieldPrivateContext");
|
||||
const useField = parameters => {
|
||||
const fieldPrivateContext = (0, _useNullableFieldPrivateContext.useNullableFieldPrivateContext)();
|
||||
const enableAccessibleFieldDOMStructure = parameters.props.enableAccessibleFieldDOMStructure ?? fieldPrivateContext?.enableAccessibleFieldDOMStructure ?? true;
|
||||
const useFieldTextField = enableAccessibleFieldDOMStructure ? _useFieldV7TextField.useFieldV7TextField : _useFieldV6TextField.useFieldV6TextField;
|
||||
return useFieldTextField(parameters);
|
||||
};
|
||||
exports.useField = useField;
|
||||
329
node_modules/@mui/x-date-pickers/internals/hooks/useField/useField.types.d.ts
generated
vendored
Normal file
329
node_modules/@mui/x-date-pickers/internals/hooks/useField/useField.types.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,329 @@
|
|||
import * as React from 'react';
|
||||
import { FieldSectionType, FieldSection, FieldSelectedSections, MuiPickersAdapter, TimezoneProps, FieldSectionContentType, PickerValidDate, FieldRef, OnErrorProps, InferFieldSection, PickerManager, PickerValueType } from "../../../models/index.js";
|
||||
import { InternalPropNames } from "../../../hooks/useSplitFieldProps.js";
|
||||
import type { PickersSectionElement, PickersSectionListRef } from "../../../PickersSectionList/index.js";
|
||||
import { FormProps, InferNonNullablePickerValue, PickerRangeValue, PickerValidValue } from "../../models/index.js";
|
||||
export interface UseFieldParameters<TValue extends PickerValidValue, TEnableAccessibleFieldDOMStructure extends boolean, TError, TValidationProps extends {}, TProps extends UseFieldProps<TEnableAccessibleFieldDOMStructure>> {
|
||||
manager: PickerManager<TValue, TEnableAccessibleFieldDOMStructure, TError, TValidationProps, any>;
|
||||
props: TProps;
|
||||
skipContextFieldRefAssignment?: boolean;
|
||||
}
|
||||
export interface UseFieldInternalProps<TValue extends PickerValidValue, TEnableAccessibleFieldDOMStructure extends boolean, TError> extends TimezoneProps, FormProps, OnErrorProps<TValue, TError> {
|
||||
/**
|
||||
* The selected value.
|
||||
* Used when the component is controlled.
|
||||
*/
|
||||
value?: TValue;
|
||||
/**
|
||||
* The default value. Use when the component is not controlled.
|
||||
*/
|
||||
defaultValue?: TValue;
|
||||
/**
|
||||
* The date used to generate a part of the new value that is not present in the format when both `value` and `defaultValue` are empty.
|
||||
* For example, on time fields it will be used to determine the date to set.
|
||||
* @default The closest valid date using the validation props, except callbacks such as `shouldDisableDate`. Value is rounded to the most granular section used.
|
||||
*/
|
||||
referenceDate?: TValue extends PickerRangeValue ? TValue | PickerValidDate : PickerValidDate;
|
||||
/**
|
||||
* Callback fired when the value changes.
|
||||
* @template TValue The value type. It will be the same type as `value` or `null`. It can be in `[start, end]` format in case of range value.
|
||||
* @template TError The validation error type. It will be either `string` or a `null`. It can be in `[start, end]` format in case of range value.
|
||||
* @param {TValue} value The new value.
|
||||
* @param {FieldChangeHandlerContext<TError>} context The context containing the validation result of the current value.
|
||||
*/
|
||||
onChange?: FieldChangeHandler<TValue, TError>;
|
||||
/**
|
||||
* Format of the date when rendered in the input(s).
|
||||
*/
|
||||
format: string;
|
||||
/**
|
||||
* Density of the format when rendered in the input.
|
||||
* Setting `formatDensity` to `"spacious"` will add a space before and after each `/`, `-` and `.` character.
|
||||
* @default "dense"
|
||||
*/
|
||||
formatDensity?: 'dense' | 'spacious';
|
||||
/**
|
||||
* If `true`, the format will respect the leading zeroes (for example on dayjs, the format `M/D/YYYY` will render `8/16/2018`)
|
||||
* If `false`, the format will always add leading zeroes (for example on dayjs, the format `M/D/YYYY` will render `08/16/2018`)
|
||||
*
|
||||
* Warning n°1: Luxon is not able to respect the leading zeroes when using macro tokens (for example "DD"), so `shouldRespectLeadingZeros={true}` might lead to inconsistencies when using `AdapterLuxon`.
|
||||
*
|
||||
* Warning n°2: When `shouldRespectLeadingZeros={true}`, the field will add an invisible character on the sections containing a single digit to make sure `onChange` is fired.
|
||||
* If you need to get the clean value from the input, you can remove this character using `input.value.replace(/\u200e/g, '')`.
|
||||
*
|
||||
* Warning n°3: When used in strict mode, dayjs and moment require to respect the leading zeros.
|
||||
* This mean that when using `shouldRespectLeadingZeros={false}`, if you retrieve the value directly from the input (not listening to `onChange`) and your format contains tokens without leading zeros, the value will not be parsed by your library.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
shouldRespectLeadingZeros?: boolean;
|
||||
/**
|
||||
* The currently selected sections.
|
||||
* This prop accepts four formats:
|
||||
* 1. If a number is provided, the section at this index will be selected.
|
||||
* 2. If a string of type `FieldSectionType` is provided, the first section with that name will be selected.
|
||||
* 3. If `"all"` is provided, all the sections will be selected.
|
||||
* 4. If `null` is provided, no section will be selected.
|
||||
* If not provided, the selected sections will be handled internally.
|
||||
*/
|
||||
selectedSections?: FieldSelectedSections;
|
||||
/**
|
||||
* Callback fired when the selected sections change.
|
||||
* @param {FieldSelectedSections} newValue The new selected sections.
|
||||
*/
|
||||
onSelectedSectionsChange?: (newValue: FieldSelectedSections) => void;
|
||||
/**
|
||||
* The ref object used to imperatively interact with the field.
|
||||
*/
|
||||
unstableFieldRef?: React.Ref<FieldRef<TValue>>;
|
||||
/**
|
||||
* @default true
|
||||
*/
|
||||
enableAccessibleFieldDOMStructure?: TEnableAccessibleFieldDOMStructure;
|
||||
/**
|
||||
* If `true`, the `input` element is focused during the first mount.
|
||||
* @default false
|
||||
*/
|
||||
autoFocus?: boolean;
|
||||
/**
|
||||
* If `true`, the component is displayed in focused state.
|
||||
*/
|
||||
focused?: boolean;
|
||||
}
|
||||
export type UseFieldForwardedProps<TEnableAccessibleFieldDOMStructure extends boolean> = TEnableAccessibleFieldDOMStructure extends false ? {
|
||||
clearable?: boolean;
|
||||
error?: boolean;
|
||||
placeholder?: string;
|
||||
inputRef?: React.Ref<HTMLInputElement>;
|
||||
onClick?: React.MouseEventHandler;
|
||||
onFocus?: React.FocusEventHandler;
|
||||
onKeyDown?: React.KeyboardEventHandler;
|
||||
onBlur?: React.FocusEventHandler;
|
||||
onPaste?: React.ClipboardEventHandler<HTMLDivElement>;
|
||||
onClear?: React.MouseEventHandler;
|
||||
} : {
|
||||
clearable?: boolean;
|
||||
error?: boolean;
|
||||
focused?: boolean;
|
||||
sectionListRef?: React.Ref<PickersSectionListRef>;
|
||||
onClick?: React.MouseEventHandler;
|
||||
onKeyDown?: React.KeyboardEventHandler;
|
||||
onFocus?: React.FocusEventHandler;
|
||||
onBlur?: React.FocusEventHandler;
|
||||
onInput?: React.FormEventHandler<HTMLDivElement>;
|
||||
onPaste?: React.ClipboardEventHandler<HTMLDivElement>;
|
||||
onClear?: React.MouseEventHandler;
|
||||
};
|
||||
type UseFieldAdditionalProps<TEnableAccessibleFieldDOMStructure extends boolean> = TEnableAccessibleFieldDOMStructure extends false ? {
|
||||
/**
|
||||
* The aria label to set on the button that opens the Picker.
|
||||
*/
|
||||
openPickerAriaLabel: string;
|
||||
enableAccessibleFieldDOMStructure: false;
|
||||
focused: boolean | undefined;
|
||||
inputMode: 'text' | 'numeric';
|
||||
placeholder: string;
|
||||
value: string;
|
||||
onChange: React.ChangeEventHandler<HTMLInputElement>;
|
||||
autoComplete: 'off';
|
||||
} : {
|
||||
/**
|
||||
* The aria label to set on the button that opens the Picker.
|
||||
*/
|
||||
openPickerAriaLabel: string;
|
||||
enableAccessibleFieldDOMStructure: true;
|
||||
elements: PickersSectionElement[];
|
||||
tabIndex: number | undefined;
|
||||
contentEditable: boolean;
|
||||
value: string;
|
||||
onChange: React.ChangeEventHandler<HTMLInputElement>;
|
||||
areAllSectionsEmpty: boolean;
|
||||
focused: boolean;
|
||||
};
|
||||
export type UseFieldReturnValue<TEnableAccessibleFieldDOMStructure extends boolean, TProps extends UseFieldProps<TEnableAccessibleFieldDOMStructure>> = Required<Pick<UseFieldInternalProps<any, any, any>, 'disabled' | 'readOnly' | 'autoFocus'>> & Required<UseFieldForwardedProps<TEnableAccessibleFieldDOMStructure>> & UseFieldAdditionalProps<TEnableAccessibleFieldDOMStructure> & Omit<TProps, InternalPropNames<PickerValueType>>;
|
||||
export type FieldSectionValueBoundaries<SectionType extends FieldSectionType> = {
|
||||
minimum: number;
|
||||
maximum: number;
|
||||
} & (SectionType extends 'day' ? {
|
||||
longestMonth: PickerValidDate;
|
||||
} : {});
|
||||
export type FieldSectionsValueBoundaries = { [SectionType in FieldSectionType]: (params: {
|
||||
currentDate: PickerValidDate | null;
|
||||
format: string;
|
||||
contentType: FieldSectionContentType;
|
||||
}) => FieldSectionValueBoundaries<SectionType> };
|
||||
export type FieldSectionsBoundaries = { [SectionType in FieldSectionType]: {
|
||||
minimum: number;
|
||||
maximum: number;
|
||||
} };
|
||||
export type FieldChangeHandler<TValue extends PickerValidValue, TError> = (value: TValue, context: FieldChangeHandlerContext<TError>) => void;
|
||||
export interface FieldChangeHandlerContext<TError> {
|
||||
validationError: TError;
|
||||
}
|
||||
export type FieldParsedSelectedSections = number | 'all' | null;
|
||||
export interface FieldValueManager<TValue extends PickerValidValue> {
|
||||
/**
|
||||
* Creates the section list from the current value.
|
||||
* The `prevSections` are used on the range fields to avoid losing the sections of a partially filled date when editing the other date.
|
||||
* @template TValue The value type. It will be the same type as `value` or `null`. It can be in `[start, end]` format in case of range value.
|
||||
* @param {TValue} value The current value to generate sections from.
|
||||
* @param {(date: PickerValidDate | null) => FieldSection[]} getSectionsFromDate Returns the sections of the given date.
|
||||
* @returns {InferFieldSection<TValue>[]} The new section list.
|
||||
*/
|
||||
getSectionsFromValue: (value: TValue, getSectionsFromDate: (date: PickerValidDate | null) => FieldSection[]) => InferFieldSection<TValue>[];
|
||||
/**
|
||||
* Creates the string value to render in the input based on the current section list.
|
||||
* @template TValue The value type. It will be the same type as `value` or `null`. It can be in `[start, end]` format in case of range value.
|
||||
* @param {InferFieldSection<TValue>[]} sections The current section list.
|
||||
* @param {string} localizedDigits The conversion table from localized to 0-9 digits.
|
||||
* @param {boolean} isRtl `true` if the current orientation is "right to left"
|
||||
* @returns {string} The string value to render in the input.
|
||||
*/
|
||||
getV6InputValueFromSections: (sections: InferFieldSection<TValue>[], localizedDigits: string[], isRtl: boolean) => string;
|
||||
/**
|
||||
* Creates the string value to render in the input based on the current section list.
|
||||
* @template TValue The value type. It will be the same type as `value` or `null`. It can be in `[start, end]` format in case of range value.
|
||||
* @param {InferFieldSection<TValue>[]} sections The current section list.
|
||||
* @returns {string} The string value to render in the input.
|
||||
*/
|
||||
getV7HiddenInputValueFromSections: (sections: InferFieldSection<TValue>[]) => string;
|
||||
/**
|
||||
* Parses a string version (most of the time coming from the input).
|
||||
* This method should only be used when the change does not come from a single section.
|
||||
* @template TValue The value type. It will be the same type as `value` or `null`. It can be in `[start, end]` format in case of range value.
|
||||
* @param {string} valueStr The string value to parse.
|
||||
* @param {TValue} referenceValue The reference value currently stored in state.
|
||||
* @param {(dateStr: string, referenceDate: PickerValidDate) => PickerValidDate | null} parseDate A method to convert a string date into a parsed one.
|
||||
* @returns {TValue} The new parsed value.
|
||||
*/
|
||||
parseValueStr: (valueStr: string, referenceValue: InferNonNullablePickerValue<TValue>, parseDate: (dateStr: string, referenceDate: PickerValidDate) => PickerValidDate | null) => TValue;
|
||||
/**
|
||||
* Update the reference value with the new value.
|
||||
* This method must make sure that no date inside the returned `referenceValue` is invalid.
|
||||
* @template TValue The value type. It will be the same type as `value` or `null`. It can be in `[start, end]` format in case of range value.
|
||||
* @param {MuiPickersAdapter} adapter The adapter to manipulate the date.
|
||||
* @param {TValue} value The new value from which we want to take all valid dates in the `referenceValue` state.
|
||||
* @param {TValue} prevReferenceValue The previous reference value. It is used as a fallback for invalid dates in the new value.
|
||||
* @returns {TValue} The new reference value with no invalid date.
|
||||
*/
|
||||
updateReferenceValue: (adapter: MuiPickersAdapter, value: TValue, prevReferenceValue: InferNonNullablePickerValue<TValue>) => InferNonNullablePickerValue<TValue>;
|
||||
/**
|
||||
* Extract from the given value the date that contains the given section.
|
||||
* @param {TValue} value The value to extract the date from.
|
||||
* @param {InferFieldSection<TValue>} section The section to get the date from.
|
||||
* @returns {PickerValidDate | null} The date that contains the section.
|
||||
*/
|
||||
getDateFromSection: (value: TValue, section: InferFieldSection<TValue>) => PickerValidDate | null;
|
||||
/**
|
||||
* Get the sections of the date that contains the given section.
|
||||
* @template TValue The value type. It will be the same type as `value` or `null`. It can be in `[start, end]` format in case of range value.
|
||||
* @param {InferFieldSection<TValue>[]} sections The sections of the full value.
|
||||
* @param {InferFieldSection<TValue>} section A section of the date from which we want to get all the sections.
|
||||
* @returns {InferFieldSection<TValue>[]} The sections of the date that contains the section.
|
||||
*/
|
||||
getDateSectionsFromValue: (sections: InferFieldSection<TValue>[], section: InferFieldSection<TValue>) => InferFieldSection<TValue>[];
|
||||
/**
|
||||
* Creates a new value based on the provided date and the current value.
|
||||
* @template TValue The value type. It will be the same type as `value` or `null`. It can be in `[start, end]` format in case of range value.
|
||||
* @param {TValue} value The value to update the date in.
|
||||
* @param {InferFieldSection<TValue>} section A section of the date we want to update in the value.
|
||||
* @param {PickerValidDate | null} date The date that contains the section.
|
||||
* @returns {TValue} The updated value.
|
||||
*/
|
||||
updateDateInValue: (value: TValue, section: InferFieldSection<TValue>, date: PickerValidDate | null) => TValue;
|
||||
/**
|
||||
* @template TValue The value type. It will be the same type as `value` or `null`. It can be in `[start, end]` format in case of range value.
|
||||
* @param {InferFieldSection<TValue>[]} sections The sections of the full value.
|
||||
* @param {InferFieldSection<TValue>} section A section of the date from which we want to clear all the sections.
|
||||
* @returns {InferFieldSection<TValue>[]} The sections of the full value with all the sections of the target date cleared.
|
||||
*/
|
||||
clearDateSections: (sections: InferFieldSection<TValue>[], section: InferFieldSection<TValue>) => InferFieldSection<TValue>[];
|
||||
}
|
||||
export interface UseFieldState<TValue extends PickerValidValue> {
|
||||
/**
|
||||
* Last value returned by `useControlledValue`.
|
||||
*/
|
||||
lastExternalValue: TValue;
|
||||
/**
|
||||
* Last set of parameters used to generate the sections.
|
||||
*/
|
||||
lastSectionsDependencies: {
|
||||
format: string;
|
||||
isRtl: boolean;
|
||||
locale: any;
|
||||
};
|
||||
/**
|
||||
* Non-nullable value used to keep trace of the timezone and the date parts not present in the format.
|
||||
* It is updated whenever we have a valid date (for the Range Pickers we update only the portion of the range that is valid).
|
||||
*/
|
||||
referenceValue: InferNonNullablePickerValue<TValue>;
|
||||
/**
|
||||
* Sections currently displayed in the field.
|
||||
*/
|
||||
sections: InferFieldSection<TValue>[];
|
||||
/**
|
||||
* Android `onChange` behavior when the input selection is not empty is quite different from a desktop behavior.
|
||||
* There are two `onChange` calls:
|
||||
* 1. A call with the selected content removed.
|
||||
* 2. A call with the key pressed added to the value.
|
||||
**
|
||||
* For instance, if the input value equals `month / day / year` and `day` is selected.
|
||||
* The pressing `1` will have the following behavior:
|
||||
* 1. A call with `month / / year`.
|
||||
* 2. A call with `month / 1 / year`.
|
||||
*
|
||||
* But if you don't update the input with the value passed on the first `onChange`.
|
||||
* Then the second `onChange` will add the key press at the beginning of the selected value.
|
||||
* 1. A call with `month / / year` that we don't set into state.
|
||||
* 2. A call with `month / 1day / year`.
|
||||
*
|
||||
* The property below allows us to set the first `onChange` value into state waiting for the second one.
|
||||
*/
|
||||
tempValueStrAndroid: string | null;
|
||||
/**
|
||||
* The current query when editing the field using letters or digits.
|
||||
*/
|
||||
characterQuery: CharacterEditingQuery | null;
|
||||
}
|
||||
export type SectionNeighbors = {
|
||||
[sectionIndex: number]: {
|
||||
/**
|
||||
* Index of the next section displayed on the left. `null` if it's the leftmost section.
|
||||
*/
|
||||
leftIndex: number | null;
|
||||
/**
|
||||
* Index of the next section displayed on the right. `null` if it's the rightmost section.
|
||||
*/
|
||||
rightIndex: number | null;
|
||||
};
|
||||
};
|
||||
export type SectionOrdering = {
|
||||
/**
|
||||
* For each section index provide the index of the section displayed on the left and on the right.
|
||||
*/
|
||||
neighbors: SectionNeighbors;
|
||||
/**
|
||||
* Index of the section displayed on the far left
|
||||
*/
|
||||
startIndex: number;
|
||||
/**
|
||||
* Index of the section displayed on the far right
|
||||
*/
|
||||
endIndex: number;
|
||||
};
|
||||
export interface CharacterEditingQuery {
|
||||
value: string;
|
||||
sectionIndex: number;
|
||||
sectionType: FieldSectionType;
|
||||
}
|
||||
export type UseFieldProps<TEnableAccessibleFieldDOMStructure extends boolean> = UseFieldForwardedProps<TEnableAccessibleFieldDOMStructure> & {
|
||||
enableAccessibleFieldDOMStructure?: boolean;
|
||||
};
|
||||
export interface UseFieldDOMGetters {
|
||||
isReady: () => boolean;
|
||||
getRoot: () => HTMLElement;
|
||||
getSectionContainer: (sectionIndex: number) => HTMLElement;
|
||||
getSectionContent: (sectionIndex: number) => HTMLElement;
|
||||
getSectionIndexFromDOMElement: (element: Element | null | undefined) => number | null;
|
||||
}
|
||||
export {};
|
||||
5
node_modules/@mui/x-date-pickers/internals/hooks/useField/useField.types.js
generated
vendored
Normal file
5
node_modules/@mui/x-date-pickers/internals/hooks/useField/useField.types.js
generated
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
36
node_modules/@mui/x-date-pickers/internals/hooks/useField/useField.utils.d.ts
generated
vendored
Normal file
36
node_modules/@mui/x-date-pickers/internals/hooks/useField/useField.utils.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
import { FieldSectionsValueBoundaries, SectionOrdering, FieldSectionValueBoundaries, FieldParsedSelectedSections } from "./useField.types.js";
|
||||
import { FieldSectionType, FieldSection, MuiPickersAdapter, FieldSectionContentType, PickersTimezone, PickerValidDate, FieldSelectedSections, PickerValueType, InferFieldSection } from "../../../models/index.js";
|
||||
import { PickerValidValue } from "../../models/index.js";
|
||||
export declare const getDateSectionConfigFromFormatToken: (adapter: MuiPickersAdapter, formatToken: string) => Pick<FieldSection, "type" | "contentType"> & {
|
||||
maxLength: number | undefined;
|
||||
};
|
||||
export declare const getDaysInWeekStr: (adapter: MuiPickersAdapter, format: string) => string[];
|
||||
export declare const getLetterEditingOptions: (adapter: MuiPickersAdapter, timezone: PickersTimezone, sectionType: FieldSectionType, format: string) => string[];
|
||||
export declare const FORMAT_SECONDS_NO_LEADING_ZEROS = "s";
|
||||
export declare const getLocalizedDigits: (adapter: MuiPickersAdapter) => string[];
|
||||
export declare const removeLocalizedDigits: (valueStr: string, localizedDigits: string[]) => string;
|
||||
export declare const applyLocalizedDigits: (valueStr: string, localizedDigits: string[]) => string;
|
||||
export declare const isStringNumber: (valueStr: string, localizedDigits: string[]) => boolean;
|
||||
/**
|
||||
* Make sure the value of a digit section have the right amount of leading zeros.
|
||||
* E.g.: `03` => `3`
|
||||
* Warning: Should only be called with non-localized digits. Call `removeLocalizedDigits` with your value if needed.
|
||||
*/
|
||||
export declare const cleanLeadingZeros: (valueStr: string, size: number) => string;
|
||||
export declare const cleanDigitSectionValue: (adapter: MuiPickersAdapter, value: number, sectionBoundaries: FieldSectionValueBoundaries<any>, localizedDigits: string[], section: Pick<FieldSection, "format" | "type" | "contentType" | "hasLeadingZerosInFormat" | "hasLeadingZerosInInput" | "maxLength">) => string;
|
||||
export declare const getSectionVisibleValue: (section: FieldSection, target: "input-rtl" | "input-ltr" | "non-input", localizedDigits: string[]) => string;
|
||||
export declare const changeSectionValueFormat: (adapter: MuiPickersAdapter, valueStr: string, currentFormat: string, newFormat: string) => string;
|
||||
export declare const doesSectionFormatHaveLeadingZeros: (adapter: MuiPickersAdapter, contentType: FieldSectionContentType, sectionType: FieldSectionType, format: string) => boolean;
|
||||
/**
|
||||
* Some date libraries like `dayjs` don't support parsing from date with escaped characters.
|
||||
* To make sure that the parsing works, we are building a format and a date without any separator.
|
||||
*/
|
||||
export declare const getDateFromDateSections: (adapter: MuiPickersAdapter, sections: FieldSection[], localizedDigits: string[]) => PickerValidDate;
|
||||
export declare const createDateStrForV7HiddenInputFromSections: (sections: FieldSection[]) => string;
|
||||
export declare const createDateStrForV6InputFromSections: (sections: FieldSection[], localizedDigits: string[], isRtl: boolean) => string;
|
||||
export declare const getSectionsBoundaries: (adapter: MuiPickersAdapter, localizedDigits: string[], timezone: PickersTimezone) => FieldSectionsValueBoundaries;
|
||||
export declare const validateSections: <TValue extends PickerValidValue>(sections: InferFieldSection<TValue>[], valueType: PickerValueType) => void;
|
||||
export declare const mergeDateIntoReferenceDate: (adapter: MuiPickersAdapter, dateToTransferFrom: PickerValidDate, sections: FieldSection[], referenceDate: PickerValidDate, shouldLimitToEditedSections: boolean) => PickerValidDate;
|
||||
export declare const isAndroid: () => boolean;
|
||||
export declare const getSectionOrder: (sections: FieldSection[], shouldApplyRTL: boolean) => SectionOrdering;
|
||||
export declare const parseSelectedSections: (selectedSections: FieldSelectedSections, sections: FieldSection[]) => FieldParsedSelectedSections;
|
||||
523
node_modules/@mui/x-date-pickers/internals/hooks/useField/useField.utils.js
generated
vendored
Normal file
523
node_modules/@mui/x-date-pickers/internals/hooks/useField/useField.utils.js
generated
vendored
Normal file
|
|
@ -0,0 +1,523 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.validateSections = exports.removeLocalizedDigits = exports.parseSelectedSections = exports.mergeDateIntoReferenceDate = exports.isStringNumber = exports.isAndroid = exports.getSectionsBoundaries = exports.getSectionVisibleValue = exports.getSectionOrder = exports.getLocalizedDigits = exports.getLetterEditingOptions = exports.getDaysInWeekStr = exports.getDateSectionConfigFromFormatToken = exports.getDateFromDateSections = exports.doesSectionFormatHaveLeadingZeros = exports.createDateStrForV7HiddenInputFromSections = exports.createDateStrForV6InputFromSections = exports.cleanLeadingZeros = exports.cleanDigitSectionValue = exports.changeSectionValueFormat = exports.applyLocalizedDigits = exports.FORMAT_SECONDS_NO_LEADING_ZEROS = void 0;
|
||||
var _dateUtils = require("../../utils/date-utils");
|
||||
const getDateSectionConfigFromFormatToken = (adapter, formatToken) => {
|
||||
const config = adapter.formatTokenMap[formatToken];
|
||||
if (config == null) {
|
||||
throw new Error([`MUI X: The token "${formatToken}" is not supported by the Date and Time Pickers.`, 'Please try using another token or open an issue on https://github.com/mui/mui-x/issues/new/choose if you think it should be supported.'].join('\n'));
|
||||
}
|
||||
if (typeof config === 'string') {
|
||||
return {
|
||||
type: config,
|
||||
contentType: config === 'meridiem' ? 'letter' : 'digit',
|
||||
maxLength: undefined
|
||||
};
|
||||
}
|
||||
return {
|
||||
type: config.sectionType,
|
||||
contentType: config.contentType,
|
||||
maxLength: config.maxLength
|
||||
};
|
||||
};
|
||||
exports.getDateSectionConfigFromFormatToken = getDateSectionConfigFromFormatToken;
|
||||
const getDaysInWeekStr = (adapter, format) => {
|
||||
const elements = [];
|
||||
const now = adapter.date(undefined, 'default');
|
||||
const startDate = adapter.startOfWeek(now);
|
||||
const endDate = adapter.endOfWeek(now);
|
||||
let current = startDate;
|
||||
while (adapter.isBefore(current, endDate)) {
|
||||
elements.push(current);
|
||||
current = adapter.addDays(current, 1);
|
||||
}
|
||||
return elements.map(weekDay => adapter.formatByString(weekDay, format));
|
||||
};
|
||||
exports.getDaysInWeekStr = getDaysInWeekStr;
|
||||
const getLetterEditingOptions = (adapter, timezone, sectionType, format) => {
|
||||
switch (sectionType) {
|
||||
case 'month':
|
||||
{
|
||||
return (0, _dateUtils.getMonthsInYear)(adapter, adapter.date(undefined, timezone)).map(month => adapter.formatByString(month, format));
|
||||
}
|
||||
case 'weekDay':
|
||||
{
|
||||
return getDaysInWeekStr(adapter, format);
|
||||
}
|
||||
case 'meridiem':
|
||||
{
|
||||
const now = adapter.date(undefined, timezone);
|
||||
return [adapter.startOfDay(now), adapter.endOfDay(now)].map(date => adapter.formatByString(date, format));
|
||||
}
|
||||
default:
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// This format should be the same on all the adapters
|
||||
// If some adapter does not respect this convention, then we will need to hardcode the format on each adapter.
|
||||
exports.getLetterEditingOptions = getLetterEditingOptions;
|
||||
const FORMAT_SECONDS_NO_LEADING_ZEROS = exports.FORMAT_SECONDS_NO_LEADING_ZEROS = 's';
|
||||
const NON_LOCALIZED_DIGITS = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'];
|
||||
const getLocalizedDigits = adapter => {
|
||||
const today = adapter.date(undefined);
|
||||
const formattedZero = adapter.formatByString(adapter.setSeconds(today, 0), FORMAT_SECONDS_NO_LEADING_ZEROS);
|
||||
if (formattedZero === '0') {
|
||||
return NON_LOCALIZED_DIGITS;
|
||||
}
|
||||
return Array.from({
|
||||
length: 10
|
||||
}).map((_, index) => adapter.formatByString(adapter.setSeconds(today, index), FORMAT_SECONDS_NO_LEADING_ZEROS));
|
||||
};
|
||||
exports.getLocalizedDigits = getLocalizedDigits;
|
||||
const removeLocalizedDigits = (valueStr, localizedDigits) => {
|
||||
if (localizedDigits[0] === '0') {
|
||||
return valueStr;
|
||||
}
|
||||
const digits = [];
|
||||
let currentFormattedDigit = '';
|
||||
for (let i = 0; i < valueStr.length; i += 1) {
|
||||
currentFormattedDigit += valueStr[i];
|
||||
const matchingDigitIndex = localizedDigits.indexOf(currentFormattedDigit);
|
||||
if (matchingDigitIndex > -1) {
|
||||
digits.push(matchingDigitIndex.toString());
|
||||
currentFormattedDigit = '';
|
||||
}
|
||||
}
|
||||
return digits.join('');
|
||||
};
|
||||
exports.removeLocalizedDigits = removeLocalizedDigits;
|
||||
const applyLocalizedDigits = (valueStr, localizedDigits) => {
|
||||
if (localizedDigits[0] === '0') {
|
||||
return valueStr;
|
||||
}
|
||||
return valueStr.split('').map(char => localizedDigits[Number(char)]).join('');
|
||||
};
|
||||
exports.applyLocalizedDigits = applyLocalizedDigits;
|
||||
const isStringNumber = (valueStr, localizedDigits) => {
|
||||
const nonLocalizedValueStr = removeLocalizedDigits(valueStr, localizedDigits);
|
||||
// `Number(' ')` returns `0` even if ' ' is not a valid number.
|
||||
return nonLocalizedValueStr !== ' ' && !Number.isNaN(Number(nonLocalizedValueStr));
|
||||
};
|
||||
|
||||
/**
|
||||
* Make sure the value of a digit section have the right amount of leading zeros.
|
||||
* E.g.: `03` => `3`
|
||||
* Warning: Should only be called with non-localized digits. Call `removeLocalizedDigits` with your value if needed.
|
||||
*/
|
||||
exports.isStringNumber = isStringNumber;
|
||||
const cleanLeadingZeros = (valueStr, size) => {
|
||||
// Remove the leading zeros and then add back as many as needed.
|
||||
return Number(valueStr).toString().padStart(size, '0');
|
||||
};
|
||||
exports.cleanLeadingZeros = cleanLeadingZeros;
|
||||
const cleanDigitSectionValue = (adapter, value, sectionBoundaries, localizedDigits, section) => {
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
if (section.type !== 'day' && section.contentType === 'digit-with-letter') {
|
||||
throw new Error([`MUI X: The token "${section.format}" is a digit format with letter in it.'
|
||||
This type of format is only supported for 'day' sections`].join('\n'));
|
||||
}
|
||||
}
|
||||
if (section.type === 'day' && section.contentType === 'digit-with-letter') {
|
||||
const date = adapter.setDate(sectionBoundaries.longestMonth, value);
|
||||
return adapter.formatByString(date, section.format);
|
||||
}
|
||||
|
||||
// queryValue without leading `0` (`01` => `1`)
|
||||
let valueStr = value.toString();
|
||||
if (section.hasLeadingZerosInInput) {
|
||||
valueStr = cleanLeadingZeros(valueStr, section.maxLength);
|
||||
}
|
||||
return applyLocalizedDigits(valueStr, localizedDigits);
|
||||
};
|
||||
exports.cleanDigitSectionValue = cleanDigitSectionValue;
|
||||
const getSectionVisibleValue = (section, target, localizedDigits) => {
|
||||
let value = section.value || section.placeholder;
|
||||
const hasLeadingZeros = target === 'non-input' ? section.hasLeadingZerosInFormat : section.hasLeadingZerosInInput;
|
||||
if (target === 'non-input' && section.hasLeadingZerosInInput && !section.hasLeadingZerosInFormat) {
|
||||
value = Number(removeLocalizedDigits(value, localizedDigits)).toString();
|
||||
}
|
||||
|
||||
// In the input, we add an empty character at the end of each section without leading zeros.
|
||||
// This makes sure that `onChange` will always be fired.
|
||||
// Otherwise, when your input value equals `1/dd/yyyy` (format `M/DD/YYYY` on DayJs),
|
||||
// If you press `1`, on the first section, the new value is also `1/dd/yyyy`,
|
||||
// So the browser will not fire the input `onChange`.
|
||||
const shouldAddInvisibleSpace = ['input-rtl', 'input-ltr'].includes(target) && section.contentType === 'digit' && !hasLeadingZeros && value.length === 1;
|
||||
if (shouldAddInvisibleSpace) {
|
||||
value = `${value}\u200e`;
|
||||
}
|
||||
if (target === 'input-rtl') {
|
||||
value = `\u2068${value}\u2069`;
|
||||
}
|
||||
return value;
|
||||
};
|
||||
exports.getSectionVisibleValue = getSectionVisibleValue;
|
||||
const changeSectionValueFormat = (adapter, valueStr, currentFormat, newFormat) => {
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
if (getDateSectionConfigFromFormatToken(adapter, currentFormat).type === 'weekDay') {
|
||||
throw new Error("changeSectionValueFormat doesn't support week day formats");
|
||||
}
|
||||
}
|
||||
return adapter.formatByString(adapter.parse(valueStr, currentFormat), newFormat);
|
||||
};
|
||||
exports.changeSectionValueFormat = changeSectionValueFormat;
|
||||
const isFourDigitYearFormat = (adapter, format) => adapter.formatByString(adapter.date(undefined, 'system'), format).length === 4;
|
||||
const doesSectionFormatHaveLeadingZeros = (adapter, contentType, sectionType, format) => {
|
||||
if (contentType !== 'digit') {
|
||||
return false;
|
||||
}
|
||||
const now = adapter.date(undefined, 'default');
|
||||
switch (sectionType) {
|
||||
// We can't use `changeSectionValueFormat`, because `adapter.parse('1', 'YYYY')` returns `1971` instead of `1`.
|
||||
case 'year':
|
||||
{
|
||||
// Remove once https://github.com/iamkun/dayjs/pull/2847 is merged and bump dayjs version
|
||||
if (adapter.lib === 'dayjs' && format === 'YY') {
|
||||
return true;
|
||||
}
|
||||
return adapter.formatByString(adapter.setYear(now, 1), format).startsWith('0');
|
||||
}
|
||||
case 'month':
|
||||
{
|
||||
return adapter.formatByString(adapter.startOfYear(now), format).length > 1;
|
||||
}
|
||||
case 'day':
|
||||
{
|
||||
return adapter.formatByString(adapter.startOfMonth(now), format).length > 1;
|
||||
}
|
||||
case 'weekDay':
|
||||
{
|
||||
return adapter.formatByString(adapter.startOfWeek(now), format).length > 1;
|
||||
}
|
||||
case 'hours':
|
||||
{
|
||||
return adapter.formatByString(adapter.setHours(now, 1), format).length > 1;
|
||||
}
|
||||
case 'minutes':
|
||||
{
|
||||
return adapter.formatByString(adapter.setMinutes(now, 1), format).length > 1;
|
||||
}
|
||||
case 'seconds':
|
||||
{
|
||||
return adapter.formatByString(adapter.setSeconds(now, 1), format).length > 1;
|
||||
}
|
||||
default:
|
||||
{
|
||||
throw new Error('Invalid section type');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Some date libraries like `dayjs` don't support parsing from date with escaped characters.
|
||||
* To make sure that the parsing works, we are building a format and a date without any separator.
|
||||
*/
|
||||
exports.doesSectionFormatHaveLeadingZeros = doesSectionFormatHaveLeadingZeros;
|
||||
const getDateFromDateSections = (adapter, sections, localizedDigits) => {
|
||||
// If we have both a day and a weekDay section,
|
||||
// Then we skip the weekDay in the parsing because libraries like dayjs can't parse complicated formats containing a weekDay.
|
||||
// dayjs(dayjs().format('dddd MMMM D YYYY'), 'dddd MMMM D YYYY')) // returns `Invalid Date` even if the format is valid.
|
||||
const shouldSkipWeekDays = sections.some(section => section.type === 'day');
|
||||
const sectionFormats = [];
|
||||
const sectionValues = [];
|
||||
for (let i = 0; i < sections.length; i += 1) {
|
||||
const section = sections[i];
|
||||
const shouldSkip = shouldSkipWeekDays && section.type === 'weekDay';
|
||||
if (!shouldSkip) {
|
||||
sectionFormats.push(section.format);
|
||||
sectionValues.push(getSectionVisibleValue(section, 'non-input', localizedDigits));
|
||||
}
|
||||
}
|
||||
const formatWithoutSeparator = sectionFormats.join(' ');
|
||||
const dateWithoutSeparatorStr = sectionValues.join(' ');
|
||||
return adapter.parse(dateWithoutSeparatorStr, formatWithoutSeparator);
|
||||
};
|
||||
exports.getDateFromDateSections = getDateFromDateSections;
|
||||
const createDateStrForV7HiddenInputFromSections = sections => sections.map(section => {
|
||||
return `${section.startSeparator}${section.value || section.placeholder}${section.endSeparator}`;
|
||||
}).join('');
|
||||
exports.createDateStrForV7HiddenInputFromSections = createDateStrForV7HiddenInputFromSections;
|
||||
const createDateStrForV6InputFromSections = (sections, localizedDigits, isRtl) => {
|
||||
const formattedSections = sections.map(section => {
|
||||
const dateValue = getSectionVisibleValue(section, isRtl ? 'input-rtl' : 'input-ltr', localizedDigits);
|
||||
return `${section.startSeparator}${dateValue}${section.endSeparator}`;
|
||||
});
|
||||
const dateStr = formattedSections.join('');
|
||||
if (!isRtl) {
|
||||
return dateStr;
|
||||
}
|
||||
|
||||
// \u2066: start left-to-right isolation
|
||||
// \u2067: start right-to-left isolation
|
||||
// \u2068: start first strong character isolation
|
||||
// \u2069: pop isolation
|
||||
// wrap into an isolated group such that separators can split the string in smaller ones by adding \u2069\u2068
|
||||
return `\u2066${dateStr}\u2069`;
|
||||
};
|
||||
exports.createDateStrForV6InputFromSections = createDateStrForV6InputFromSections;
|
||||
const getSectionsBoundaries = (adapter, localizedDigits, timezone) => {
|
||||
const today = adapter.date(undefined, timezone);
|
||||
const endOfYear = adapter.endOfYear(today);
|
||||
const endOfDay = adapter.endOfDay(today);
|
||||
const {
|
||||
maxDaysInMonth,
|
||||
longestMonth
|
||||
} = (0, _dateUtils.getMonthsInYear)(adapter, today).reduce((acc, month) => {
|
||||
const daysInMonth = adapter.getDaysInMonth(month);
|
||||
if (daysInMonth > acc.maxDaysInMonth) {
|
||||
return {
|
||||
maxDaysInMonth: daysInMonth,
|
||||
longestMonth: month
|
||||
};
|
||||
}
|
||||
return acc;
|
||||
}, {
|
||||
maxDaysInMonth: 0,
|
||||
longestMonth: null
|
||||
});
|
||||
return {
|
||||
year: ({
|
||||
format
|
||||
}) => ({
|
||||
minimum: 0,
|
||||
maximum: isFourDigitYearFormat(adapter, format) ? 9999 : 99
|
||||
}),
|
||||
month: () => ({
|
||||
minimum: 1,
|
||||
// Assumption: All years have the same amount of months
|
||||
maximum: adapter.getMonth(endOfYear) + 1
|
||||
}),
|
||||
day: ({
|
||||
currentDate
|
||||
}) => ({
|
||||
minimum: 1,
|
||||
maximum: adapter.isValid(currentDate) ? adapter.getDaysInMonth(currentDate) : maxDaysInMonth,
|
||||
longestMonth: longestMonth
|
||||
}),
|
||||
weekDay: ({
|
||||
format,
|
||||
contentType
|
||||
}) => {
|
||||
if (contentType === 'digit') {
|
||||
const daysInWeek = getDaysInWeekStr(adapter, format).map(Number);
|
||||
return {
|
||||
minimum: Math.min(...daysInWeek),
|
||||
maximum: Math.max(...daysInWeek)
|
||||
};
|
||||
}
|
||||
return {
|
||||
minimum: 1,
|
||||
maximum: 7
|
||||
};
|
||||
},
|
||||
hours: ({
|
||||
format
|
||||
}) => {
|
||||
const lastHourInDay = adapter.getHours(endOfDay);
|
||||
const hasMeridiem = removeLocalizedDigits(adapter.formatByString(adapter.endOfDay(today), format), localizedDigits) !== lastHourInDay.toString();
|
||||
if (hasMeridiem) {
|
||||
return {
|
||||
minimum: 1,
|
||||
maximum: Number(removeLocalizedDigits(adapter.formatByString(adapter.startOfDay(today), format), localizedDigits))
|
||||
};
|
||||
}
|
||||
return {
|
||||
minimum: 0,
|
||||
maximum: lastHourInDay
|
||||
};
|
||||
},
|
||||
minutes: () => ({
|
||||
minimum: 0,
|
||||
// Assumption: All years have the same amount of minutes
|
||||
maximum: adapter.getMinutes(endOfDay)
|
||||
}),
|
||||
seconds: () => ({
|
||||
minimum: 0,
|
||||
// Assumption: All years have the same amount of seconds
|
||||
maximum: adapter.getSeconds(endOfDay)
|
||||
}),
|
||||
meridiem: () => ({
|
||||
minimum: 0,
|
||||
maximum: 1
|
||||
}),
|
||||
empty: () => ({
|
||||
minimum: 0,
|
||||
maximum: 0
|
||||
})
|
||||
};
|
||||
};
|
||||
exports.getSectionsBoundaries = getSectionsBoundaries;
|
||||
let warnedOnceInvalidSection = false;
|
||||
const validateSections = (sections, valueType) => {
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
if (!warnedOnceInvalidSection) {
|
||||
const supportedSections = ['empty'];
|
||||
if (['date', 'date-time'].includes(valueType)) {
|
||||
supportedSections.push('weekDay', 'day', 'month', 'year');
|
||||
}
|
||||
if (['time', 'date-time'].includes(valueType)) {
|
||||
supportedSections.push('hours', 'minutes', 'seconds', 'meridiem');
|
||||
}
|
||||
const invalidSection = sections.find(section => !supportedSections.includes(section.type));
|
||||
if (invalidSection) {
|
||||
console.warn(`MUI X: The field component you are using is not compatible with the "${invalidSection.type}" date section.`, `The supported date sections are ["${supportedSections.join('", "')}"]\`.`);
|
||||
warnedOnceInvalidSection = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
exports.validateSections = validateSections;
|
||||
const transferDateSectionValue = (adapter, section, dateToTransferFrom, dateToTransferTo) => {
|
||||
switch (section.type) {
|
||||
case 'year':
|
||||
{
|
||||
return adapter.setYear(dateToTransferTo, adapter.getYear(dateToTransferFrom));
|
||||
}
|
||||
case 'month':
|
||||
{
|
||||
return adapter.setMonth(dateToTransferTo, adapter.getMonth(dateToTransferFrom));
|
||||
}
|
||||
case 'weekDay':
|
||||
{
|
||||
let dayInWeekStrOfActiveDate = adapter.formatByString(dateToTransferFrom, section.format);
|
||||
if (section.hasLeadingZerosInInput) {
|
||||
dayInWeekStrOfActiveDate = cleanLeadingZeros(dayInWeekStrOfActiveDate, section.maxLength);
|
||||
}
|
||||
const formattedDaysInWeek = getDaysInWeekStr(adapter, section.format);
|
||||
const dayInWeekOfActiveDate = formattedDaysInWeek.indexOf(dayInWeekStrOfActiveDate);
|
||||
const dayInWeekOfNewSectionValue = formattedDaysInWeek.indexOf(section.value);
|
||||
const diff = dayInWeekOfNewSectionValue - dayInWeekOfActiveDate;
|
||||
return adapter.addDays(dateToTransferFrom, diff);
|
||||
}
|
||||
case 'day':
|
||||
{
|
||||
return adapter.setDate(dateToTransferTo, adapter.getDate(dateToTransferFrom));
|
||||
}
|
||||
case 'meridiem':
|
||||
{
|
||||
const isAM = adapter.getHours(dateToTransferFrom) < 12;
|
||||
const mergedDateHours = adapter.getHours(dateToTransferTo);
|
||||
if (isAM && mergedDateHours >= 12) {
|
||||
return adapter.addHours(dateToTransferTo, -12);
|
||||
}
|
||||
if (!isAM && mergedDateHours < 12) {
|
||||
return adapter.addHours(dateToTransferTo, 12);
|
||||
}
|
||||
return dateToTransferTo;
|
||||
}
|
||||
case 'hours':
|
||||
{
|
||||
return adapter.setHours(dateToTransferTo, adapter.getHours(dateToTransferFrom));
|
||||
}
|
||||
case 'minutes':
|
||||
{
|
||||
return adapter.setMinutes(dateToTransferTo, adapter.getMinutes(dateToTransferFrom));
|
||||
}
|
||||
case 'seconds':
|
||||
{
|
||||
return adapter.setSeconds(dateToTransferTo, adapter.getSeconds(dateToTransferFrom));
|
||||
}
|
||||
default:
|
||||
{
|
||||
return dateToTransferTo;
|
||||
}
|
||||
}
|
||||
};
|
||||
const reliableSectionModificationOrder = {
|
||||
year: 1,
|
||||
month: 2,
|
||||
day: 3,
|
||||
weekDay: 4,
|
||||
hours: 5,
|
||||
minutes: 6,
|
||||
seconds: 7,
|
||||
meridiem: 8,
|
||||
empty: 9
|
||||
};
|
||||
const mergeDateIntoReferenceDate = (adapter, dateToTransferFrom, sections, referenceDate, shouldLimitToEditedSections) =>
|
||||
// cloning sections before sort to avoid mutating it
|
||||
[...sections].sort((a, b) => reliableSectionModificationOrder[a.type] - reliableSectionModificationOrder[b.type]).reduce((mergedDate, section) => {
|
||||
if (!shouldLimitToEditedSections || section.modified) {
|
||||
return transferDateSectionValue(adapter, section, dateToTransferFrom, mergedDate);
|
||||
}
|
||||
return mergedDate;
|
||||
}, referenceDate);
|
||||
exports.mergeDateIntoReferenceDate = mergeDateIntoReferenceDate;
|
||||
const isAndroid = () => navigator.userAgent.toLowerCase().includes('android');
|
||||
|
||||
// TODO v9: Remove
|
||||
exports.isAndroid = isAndroid;
|
||||
const getSectionOrder = (sections, shouldApplyRTL) => {
|
||||
const neighbors = {};
|
||||
if (!shouldApplyRTL) {
|
||||
sections.forEach((_, index) => {
|
||||
const leftIndex = index === 0 ? null : index - 1;
|
||||
const rightIndex = index === sections.length - 1 ? null : index + 1;
|
||||
neighbors[index] = {
|
||||
leftIndex,
|
||||
rightIndex
|
||||
};
|
||||
});
|
||||
return {
|
||||
neighbors,
|
||||
startIndex: 0,
|
||||
endIndex: sections.length - 1
|
||||
};
|
||||
}
|
||||
const rtl2ltr = {};
|
||||
const ltr2rtl = {};
|
||||
let groupedSectionsStart = 0;
|
||||
let groupedSectionsEnd = 0;
|
||||
let RTLIndex = sections.length - 1;
|
||||
while (RTLIndex >= 0) {
|
||||
groupedSectionsEnd = sections.findIndex(
|
||||
// eslint-disable-next-line @typescript-eslint/no-loop-func
|
||||
(section, index) => index >= groupedSectionsStart && section.endSeparator?.includes(' ') &&
|
||||
// Special case where the spaces were not there in the initial input
|
||||
section.endSeparator !== ' / ');
|
||||
if (groupedSectionsEnd === -1) {
|
||||
groupedSectionsEnd = sections.length - 1;
|
||||
}
|
||||
for (let i = groupedSectionsEnd; i >= groupedSectionsStart; i -= 1) {
|
||||
ltr2rtl[i] = RTLIndex;
|
||||
rtl2ltr[RTLIndex] = i;
|
||||
RTLIndex -= 1;
|
||||
}
|
||||
groupedSectionsStart = groupedSectionsEnd + 1;
|
||||
}
|
||||
sections.forEach((_, index) => {
|
||||
const rtlIndex = ltr2rtl[index];
|
||||
const leftIndex = rtlIndex === 0 ? null : rtl2ltr[rtlIndex - 1];
|
||||
const rightIndex = rtlIndex === sections.length - 1 ? null : rtl2ltr[rtlIndex + 1];
|
||||
neighbors[index] = {
|
||||
leftIndex,
|
||||
rightIndex
|
||||
};
|
||||
});
|
||||
return {
|
||||
neighbors,
|
||||
startIndex: rtl2ltr[0],
|
||||
endIndex: rtl2ltr[sections.length - 1]
|
||||
};
|
||||
};
|
||||
exports.getSectionOrder = getSectionOrder;
|
||||
const parseSelectedSections = (selectedSections, sections) => {
|
||||
if (selectedSections == null) {
|
||||
return null;
|
||||
}
|
||||
if (selectedSections === 'all') {
|
||||
return 'all';
|
||||
}
|
||||
if (typeof selectedSections === 'string') {
|
||||
const index = sections.findIndex(section => section.type === selectedSections);
|
||||
return index === -1 ? null : index;
|
||||
}
|
||||
return selectedSections;
|
||||
};
|
||||
exports.parseSelectedSections = parseSelectedSections;
|
||||
29
node_modules/@mui/x-date-pickers/internals/hooks/useField/useFieldCharacterEditing.d.ts
generated
vendored
Normal file
29
node_modules/@mui/x-date-pickers/internals/hooks/useField/useFieldCharacterEditing.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
import { UseFieldStateReturnValue } from "./useFieldState.js";
|
||||
import { PickerValidValue } from "../../models/index.js";
|
||||
/**
|
||||
* Update the active section value when the user pressed a key that is not a navigation key (arrow key for example).
|
||||
* This hook has two main editing behaviors
|
||||
*
|
||||
* 1. The numeric editing when the user presses a digit
|
||||
* 2. The letter editing when the user presses another key
|
||||
*/
|
||||
export declare const useFieldCharacterEditing: <TValue extends PickerValidValue>({
|
||||
stateResponse: {
|
||||
localizedDigits,
|
||||
sectionsValueBoundaries,
|
||||
state,
|
||||
timezone,
|
||||
setCharacterQuery,
|
||||
setTempAndroidValueStr,
|
||||
updateSectionValue
|
||||
}
|
||||
}: UseFieldCharacterEditingParameters<TValue>) => UseFieldCharacterEditingReturnValue;
|
||||
export interface ApplyCharacterEditingParameters {
|
||||
keyPressed: string;
|
||||
sectionIndex: number;
|
||||
}
|
||||
interface UseFieldCharacterEditingParameters<TValue extends PickerValidValue> {
|
||||
stateResponse: UseFieldStateReturnValue<TValue>;
|
||||
}
|
||||
export type UseFieldCharacterEditingReturnValue = (params: ApplyCharacterEditingParameters) => void;
|
||||
export {};
|
||||
264
node_modules/@mui/x-date-pickers/internals/hooks/useField/useFieldCharacterEditing.js
generated
vendored
Normal file
264
node_modules/@mui/x-date-pickers/internals/hooks/useField/useFieldCharacterEditing.js
generated
vendored
Normal file
|
|
@ -0,0 +1,264 @@
|
|||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.useFieldCharacterEditing = void 0;
|
||||
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
||||
var _useEventCallback = _interopRequireDefault(require("@mui/utils/useEventCallback"));
|
||||
var _useField = require("./useField.utils");
|
||||
var _usePickerAdapter = require("../../../hooks/usePickerAdapter");
|
||||
const isQueryResponseWithoutValue = response => response.saveQuery != null;
|
||||
|
||||
/**
|
||||
* Update the active section value when the user pressed a key that is not a navigation key (arrow key for example).
|
||||
* This hook has two main editing behaviors
|
||||
*
|
||||
* 1. The numeric editing when the user presses a digit
|
||||
* 2. The letter editing when the user presses another key
|
||||
*/
|
||||
const useFieldCharacterEditing = ({
|
||||
stateResponse: {
|
||||
// States and derived states
|
||||
localizedDigits,
|
||||
sectionsValueBoundaries,
|
||||
state,
|
||||
timezone,
|
||||
// Methods to update the states
|
||||
setCharacterQuery,
|
||||
setTempAndroidValueStr,
|
||||
updateSectionValue
|
||||
}
|
||||
}) => {
|
||||
const adapter = (0, _usePickerAdapter.usePickerAdapter)();
|
||||
const applyQuery = ({
|
||||
keyPressed,
|
||||
sectionIndex
|
||||
}, getFirstSectionValueMatchingWithQuery, isValidQueryValue) => {
|
||||
const cleanKeyPressed = keyPressed.toLowerCase();
|
||||
const activeSection = state.sections[sectionIndex];
|
||||
|
||||
// The current query targets the section being editing
|
||||
// We can try to concatenate the value
|
||||
if (state.characterQuery != null && (!isValidQueryValue || isValidQueryValue(state.characterQuery.value)) && state.characterQuery.sectionIndex === sectionIndex) {
|
||||
const concatenatedQueryValue = `${state.characterQuery.value}${cleanKeyPressed}`;
|
||||
const queryResponse = getFirstSectionValueMatchingWithQuery(concatenatedQueryValue, activeSection);
|
||||
if (!isQueryResponseWithoutValue(queryResponse)) {
|
||||
setCharacterQuery({
|
||||
sectionIndex,
|
||||
value: concatenatedQueryValue,
|
||||
sectionType: activeSection.type
|
||||
});
|
||||
return queryResponse;
|
||||
}
|
||||
}
|
||||
const queryResponse = getFirstSectionValueMatchingWithQuery(cleanKeyPressed, activeSection);
|
||||
if (isQueryResponseWithoutValue(queryResponse) && !queryResponse.saveQuery) {
|
||||
setCharacterQuery(null);
|
||||
return null;
|
||||
}
|
||||
setCharacterQuery({
|
||||
sectionIndex,
|
||||
value: cleanKeyPressed,
|
||||
sectionType: activeSection.type
|
||||
});
|
||||
if (isQueryResponseWithoutValue(queryResponse)) {
|
||||
return null;
|
||||
}
|
||||
return queryResponse;
|
||||
};
|
||||
const applyLetterEditing = params => {
|
||||
const findMatchingOptions = (format, options, queryValue) => {
|
||||
const matchingValues = options.filter(option => option.toLowerCase().startsWith(queryValue));
|
||||
if (matchingValues.length === 0) {
|
||||
return {
|
||||
saveQuery: false
|
||||
};
|
||||
}
|
||||
return {
|
||||
sectionValue: matchingValues[0],
|
||||
shouldGoToNextSection: matchingValues.length === 1
|
||||
};
|
||||
};
|
||||
const testQueryOnFormatAndFallbackFormat = (queryValue, activeSection, fallbackFormat, formatFallbackValue) => {
|
||||
const getOptions = format => (0, _useField.getLetterEditingOptions)(adapter, timezone, activeSection.type, format);
|
||||
if (activeSection.contentType === 'letter') {
|
||||
return findMatchingOptions(activeSection.format, getOptions(activeSection.format), queryValue);
|
||||
}
|
||||
|
||||
// When editing a digit-format month / weekDay and the user presses a letter,
|
||||
// We can support the letter editing by using the letter-format month / weekDay and re-formatting the result.
|
||||
// We just have to make sure that the default month / weekDay format is a letter format,
|
||||
if (fallbackFormat && formatFallbackValue != null && (0, _useField.getDateSectionConfigFromFormatToken)(adapter, fallbackFormat).contentType === 'letter') {
|
||||
const fallbackOptions = getOptions(fallbackFormat);
|
||||
const response = findMatchingOptions(fallbackFormat, fallbackOptions, queryValue);
|
||||
if (isQueryResponseWithoutValue(response)) {
|
||||
return {
|
||||
saveQuery: false
|
||||
};
|
||||
}
|
||||
return (0, _extends2.default)({}, response, {
|
||||
sectionValue: formatFallbackValue(response.sectionValue, fallbackOptions)
|
||||
});
|
||||
}
|
||||
return {
|
||||
saveQuery: false
|
||||
};
|
||||
};
|
||||
const getFirstSectionValueMatchingWithQuery = (queryValue, activeSection) => {
|
||||
switch (activeSection.type) {
|
||||
case 'month':
|
||||
{
|
||||
const formatFallbackValue = fallbackValue => (0, _useField.changeSectionValueFormat)(adapter, fallbackValue, adapter.formats.month, activeSection.format);
|
||||
return testQueryOnFormatAndFallbackFormat(queryValue, activeSection, adapter.formats.month, formatFallbackValue);
|
||||
}
|
||||
case 'weekDay':
|
||||
{
|
||||
const formatFallbackValue = (fallbackValue, fallbackOptions) => fallbackOptions.indexOf(fallbackValue).toString();
|
||||
return testQueryOnFormatAndFallbackFormat(queryValue, activeSection, adapter.formats.weekday, formatFallbackValue);
|
||||
}
|
||||
case 'meridiem':
|
||||
{
|
||||
return testQueryOnFormatAndFallbackFormat(queryValue, activeSection);
|
||||
}
|
||||
default:
|
||||
{
|
||||
return {
|
||||
saveQuery: false
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
||||
return applyQuery(params, getFirstSectionValueMatchingWithQuery);
|
||||
};
|
||||
const applyNumericEditing = params => {
|
||||
const getNewSectionValue = ({
|
||||
queryValue,
|
||||
skipIfBelowMinimum,
|
||||
section
|
||||
}) => {
|
||||
const cleanQueryValue = (0, _useField.removeLocalizedDigits)(queryValue, localizedDigits);
|
||||
const queryValueNumber = Number(cleanQueryValue);
|
||||
const sectionBoundaries = sectionsValueBoundaries[section.type]({
|
||||
currentDate: null,
|
||||
format: section.format,
|
||||
contentType: section.contentType
|
||||
});
|
||||
if (queryValueNumber > sectionBoundaries.maximum) {
|
||||
return {
|
||||
saveQuery: false
|
||||
};
|
||||
}
|
||||
|
||||
// If the user types `0` on a month section,
|
||||
// It is below the minimum, but we want to store the `0` in the query,
|
||||
// So that when he pressed `1`, it will store `01` and move to the next section.
|
||||
if (skipIfBelowMinimum && queryValueNumber < sectionBoundaries.minimum) {
|
||||
return {
|
||||
saveQuery: true
|
||||
};
|
||||
}
|
||||
const shouldGoToNextSection = queryValueNumber * 10 > sectionBoundaries.maximum || cleanQueryValue.length === sectionBoundaries.maximum.toString().length;
|
||||
const newSectionValue = (0, _useField.cleanDigitSectionValue)(adapter, queryValueNumber, sectionBoundaries, localizedDigits, section);
|
||||
return {
|
||||
sectionValue: newSectionValue,
|
||||
shouldGoToNextSection
|
||||
};
|
||||
};
|
||||
const getFirstSectionValueMatchingWithQuery = (queryValue, activeSection) => {
|
||||
if (activeSection.contentType === 'digit' || activeSection.contentType === 'digit-with-letter') {
|
||||
return getNewSectionValue({
|
||||
queryValue,
|
||||
skipIfBelowMinimum: false,
|
||||
section: activeSection
|
||||
});
|
||||
}
|
||||
|
||||
// When editing a letter-format month and the user presses a digit,
|
||||
// We can support the numeric editing by using the digit-format month and re-formatting the result.
|
||||
if (activeSection.type === 'month') {
|
||||
const hasLeadingZerosInFormat = (0, _useField.doesSectionFormatHaveLeadingZeros)(adapter, 'digit', 'month', 'MM');
|
||||
const response = getNewSectionValue({
|
||||
queryValue,
|
||||
skipIfBelowMinimum: true,
|
||||
section: {
|
||||
type: activeSection.type,
|
||||
format: 'MM',
|
||||
hasLeadingZerosInFormat,
|
||||
hasLeadingZerosInInput: true,
|
||||
contentType: 'digit',
|
||||
maxLength: 2
|
||||
}
|
||||
});
|
||||
if (isQueryResponseWithoutValue(response)) {
|
||||
return response;
|
||||
}
|
||||
const formattedValue = (0, _useField.changeSectionValueFormat)(adapter, response.sectionValue, 'MM', activeSection.format);
|
||||
return (0, _extends2.default)({}, response, {
|
||||
sectionValue: formattedValue
|
||||
});
|
||||
}
|
||||
|
||||
// When editing a letter-format weekDay and the user presses a digit,
|
||||
// We can support the numeric editing by returning the nth day in the week day array.
|
||||
if (activeSection.type === 'weekDay') {
|
||||
const response = getNewSectionValue({
|
||||
queryValue,
|
||||
skipIfBelowMinimum: true,
|
||||
section: activeSection
|
||||
});
|
||||
if (isQueryResponseWithoutValue(response)) {
|
||||
return response;
|
||||
}
|
||||
const formattedValue = (0, _useField.getDaysInWeekStr)(adapter, activeSection.format)[Number(response.sectionValue) - 1];
|
||||
return (0, _extends2.default)({}, response, {
|
||||
sectionValue: formattedValue
|
||||
});
|
||||
}
|
||||
return {
|
||||
saveQuery: false
|
||||
};
|
||||
};
|
||||
return applyQuery(params, getFirstSectionValueMatchingWithQuery, queryValue => (0, _useField.isStringNumber)(queryValue, localizedDigits));
|
||||
};
|
||||
return (0, _useEventCallback.default)(params => {
|
||||
const section = state.sections[params.sectionIndex];
|
||||
const isNumericEditing = (0, _useField.isStringNumber)(params.keyPressed, localizedDigits);
|
||||
const response = isNumericEditing ? applyNumericEditing((0, _extends2.default)({}, params, {
|
||||
keyPressed: (0, _useField.applyLocalizedDigits)(params.keyPressed, localizedDigits)
|
||||
})) : applyLetterEditing(params);
|
||||
if (response == null) {
|
||||
setTempAndroidValueStr(null);
|
||||
return;
|
||||
}
|
||||
updateSectionValue({
|
||||
section,
|
||||
newSectionValue: response.sectionValue,
|
||||
shouldGoToNextSection: response.shouldGoToNextSection
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* The letter editing and the numeric editing each define a `CharacterEditingApplier`.
|
||||
* This function decides what the new section value should be and if the focus should switch to the next section.
|
||||
*
|
||||
* If it returns `null`, then the section value is not updated and the focus does not move.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Function called by `applyQuery` which decides:
|
||||
* - what is the new section value ?
|
||||
* - should the query used to get this value be stored for the next key press ?
|
||||
*
|
||||
* If it returns `{ sectionValue: string; shouldGoToNextSection: boolean }`,
|
||||
* Then we store the query and update the section with the new value.
|
||||
*
|
||||
* If it returns `{ saveQuery: true` },
|
||||
* Then we store the query and don't update the section.
|
||||
*
|
||||
* If it returns `{ saveQuery: false },
|
||||
* Then we do nothing.
|
||||
*/
|
||||
exports.useFieldCharacterEditing = useFieldCharacterEditing;
|
||||
20
node_modules/@mui/x-date-pickers/internals/hooks/useField/useFieldHiddenInputProps.d.ts
generated
vendored
Normal file
20
node_modules/@mui/x-date-pickers/internals/hooks/useField/useFieldHiddenInputProps.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
import * as React from 'react';
|
||||
import { PickerManager } from "../../../models/index.js";
|
||||
import { UseFieldStateReturnValue } from "./useFieldState.js";
|
||||
/**
|
||||
* Generate the props to pass to the hidden input element of the field.
|
||||
* It is not used by the non-accessible DOM structure (with an <input /> element for editing).
|
||||
* It should be used in the MUI accessible DOM structure and the Base UI implementation.
|
||||
* @param {UseFieldHiddenInputPropsParameters} parameters The parameters of the hook.
|
||||
* @returns {UseFieldHiddenInputPropsReturnValue} The props to forward to the hidden input element of the field.
|
||||
*/
|
||||
export declare function useFieldHiddenInputProps(parameters: UseFieldHiddenInputPropsParameters): UseFieldHiddenInputPropsReturnValue;
|
||||
interface UseFieldHiddenInputPropsParameters {
|
||||
manager: PickerManager<any, any, any, any, any>;
|
||||
stateResponse: UseFieldStateReturnValue<any>;
|
||||
}
|
||||
interface UseFieldHiddenInputPropsReturnValue {
|
||||
value: string;
|
||||
onChange: React.ChangeEventHandler<HTMLInputElement>;
|
||||
}
|
||||
export {};
|
||||
39
node_modules/@mui/x-date-pickers/internals/hooks/useField/useFieldHiddenInputProps.js
generated
vendored
Normal file
39
node_modules/@mui/x-date-pickers/internals/hooks/useField/useFieldHiddenInputProps.js
generated
vendored
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
||||
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.useFieldHiddenInputProps = useFieldHiddenInputProps;
|
||||
var React = _interopRequireWildcard(require("react"));
|
||||
var _useEventCallback = _interopRequireDefault(require("@mui/utils/useEventCallback"));
|
||||
/**
|
||||
* Generate the props to pass to the hidden input element of the field.
|
||||
* It is not used by the non-accessible DOM structure (with an <input /> element for editing).
|
||||
* It should be used in the MUI accessible DOM structure and the Base UI implementation.
|
||||
* @param {UseFieldHiddenInputPropsParameters} parameters The parameters of the hook.
|
||||
* @returns {UseFieldHiddenInputPropsReturnValue} The props to forward to the hidden input element of the field.
|
||||
*/
|
||||
function useFieldHiddenInputProps(parameters) {
|
||||
const {
|
||||
manager: {
|
||||
internal_fieldValueManager: fieldValueManager
|
||||
},
|
||||
stateResponse: {
|
||||
// States and derived states
|
||||
areAllSectionsEmpty,
|
||||
state,
|
||||
// Methods to update the states
|
||||
updateValueFromValueStr
|
||||
}
|
||||
} = parameters;
|
||||
const handleChange = (0, _useEventCallback.default)(event => {
|
||||
updateValueFromValueStr(event.target.value);
|
||||
});
|
||||
const valueStr = React.useMemo(() => areAllSectionsEmpty ? '' : fieldValueManager.getV7HiddenInputValueFromSections(state.sections), [areAllSectionsEmpty, state.sections, fieldValueManager]);
|
||||
return {
|
||||
value: valueStr,
|
||||
onChange: handleChange
|
||||
};
|
||||
}
|
||||
17
node_modules/@mui/x-date-pickers/internals/hooks/useField/useFieldInternalPropsWithDefaults.d.ts
generated
vendored
Normal file
17
node_modules/@mui/x-date-pickers/internals/hooks/useField/useFieldInternalPropsWithDefaults.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
import { PickerAnyManager, PickerManagerFieldInternalProps, PickerManagerFieldInternalPropsWithDefaults } from "../../models/index.js";
|
||||
/**
|
||||
* Applies the default values to the field internal props.
|
||||
* This is a temporary hook that will be removed during a follow up when `useField` will receive the internal props without the defaults.
|
||||
* It is only here to allow the migration to be done in smaller steps.
|
||||
*/
|
||||
export declare function useFieldInternalPropsWithDefaults<TManager extends PickerAnyManager>(parameters: UseFieldInternalPropsWithDefaultsParameters<TManager>): PickerManagerFieldInternalPropsWithDefaults<TManager>;
|
||||
interface UseFieldInternalPropsWithDefaultsParameters<TManager extends PickerAnyManager> {
|
||||
manager: TManager;
|
||||
internalProps: PickerManagerFieldInternalProps<TManager>;
|
||||
/**
|
||||
* Hack to make sure that on multi input range field, the `useNullableFieldPrivateContext().fieldRef` is only bound to the field matching the range position.
|
||||
* @default false
|
||||
*/
|
||||
skipContextFieldRefAssignment?: boolean;
|
||||
}
|
||||
export {};
|
||||
60
node_modules/@mui/x-date-pickers/internals/hooks/useField/useFieldInternalPropsWithDefaults.js
generated
vendored
Normal file
60
node_modules/@mui/x-date-pickers/internals/hooks/useField/useFieldInternalPropsWithDefaults.js
generated
vendored
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
"use strict";
|
||||
|
||||
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.useFieldInternalPropsWithDefaults = useFieldInternalPropsWithDefaults;
|
||||
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
||||
var React = _interopRequireWildcard(require("react"));
|
||||
var _useForkRef = _interopRequireDefault(require("@mui/utils/useForkRef"));
|
||||
var _useNullablePickerContext = require("../useNullablePickerContext");
|
||||
var _useNullableFieldPrivateContext = require("../useNullableFieldPrivateContext");
|
||||
/**
|
||||
* Applies the default values to the field internal props.
|
||||
* This is a temporary hook that will be removed during a follow up when `useField` will receive the internal props without the defaults.
|
||||
* It is only here to allow the migration to be done in smaller steps.
|
||||
*/
|
||||
function useFieldInternalPropsWithDefaults(parameters) {
|
||||
const {
|
||||
manager: {
|
||||
internal_useApplyDefaultValuesToFieldInternalProps: useApplyDefaultValuesToFieldInternalProps
|
||||
},
|
||||
internalProps,
|
||||
skipContextFieldRefAssignment
|
||||
} = parameters;
|
||||
const pickerContext = (0, _useNullablePickerContext.useNullablePickerContext)();
|
||||
const fieldPrivateContext = (0, _useNullableFieldPrivateContext.useNullableFieldPrivateContext)();
|
||||
const handleFieldRef = (0, _useForkRef.default)(internalProps.unstableFieldRef, skipContextFieldRefAssignment ? null : fieldPrivateContext?.fieldRef);
|
||||
const setValue = pickerContext?.setValue;
|
||||
const handleChangeFromPicker = React.useCallback((newValue, ctx) => {
|
||||
return setValue?.(newValue, {
|
||||
validationError: ctx.validationError,
|
||||
shouldClose: false
|
||||
});
|
||||
}, [setValue]);
|
||||
const internalPropsWithDefaultsFromContext = React.useMemo(() => {
|
||||
// If one of the context is null,
|
||||
// Then the field is used as a standalone component and the other context will be null as well.
|
||||
if (fieldPrivateContext != null && pickerContext != null) {
|
||||
return (0, _extends2.default)({
|
||||
value: pickerContext.value,
|
||||
onChange: handleChangeFromPicker,
|
||||
timezone: pickerContext.timezone,
|
||||
disabled: pickerContext.disabled,
|
||||
readOnly: pickerContext.readOnly,
|
||||
autoFocus: pickerContext.autoFocus && !pickerContext.open,
|
||||
focused: pickerContext.open ? true : undefined,
|
||||
format: pickerContext.fieldFormat,
|
||||
formatDensity: fieldPrivateContext.formatDensity,
|
||||
enableAccessibleFieldDOMStructure: fieldPrivateContext.enableAccessibleFieldDOMStructure,
|
||||
selectedSections: fieldPrivateContext.selectedSections,
|
||||
onSelectedSectionsChange: fieldPrivateContext.onSelectedSectionsChange,
|
||||
unstableFieldRef: handleFieldRef
|
||||
}, internalProps);
|
||||
}
|
||||
return internalProps;
|
||||
}, [pickerContext, fieldPrivateContext, internalProps, handleChangeFromPicker, handleFieldRef]);
|
||||
return useApplyDefaultValuesToFieldInternalProps(internalPropsWithDefaultsFromContext);
|
||||
}
|
||||
16
node_modules/@mui/x-date-pickers/internals/hooks/useField/useFieldRootHandleKeyDown.d.ts
generated
vendored
Normal file
16
node_modules/@mui/x-date-pickers/internals/hooks/useField/useFieldRootHandleKeyDown.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
import { PickerManager } from "../../../models/index.js";
|
||||
import { PickerValidValue } from "../../models/index.js";
|
||||
import { UseFieldStateReturnValue } from "./useFieldState.js";
|
||||
import { UseFieldInternalProps } from "./useField.types.js";
|
||||
/**
|
||||
* Returns the `onKeyDown` handler to pass to the root element of the field.
|
||||
*/
|
||||
export declare function useFieldRootHandleKeyDown<TValue extends PickerValidValue>(parameters: UseFieldRootHandleKeyDownParameters<TValue>): (event: React.KeyboardEvent<HTMLSpanElement>) => void;
|
||||
interface UseFieldRootHandleKeyDownParameters<TValue extends PickerValidValue> {
|
||||
manager: PickerManager<TValue, any, any, any, any>;
|
||||
stateResponse: UseFieldStateReturnValue<TValue>;
|
||||
internalPropsWithDefaults: UseFieldInternalProps<TValue, any, any> & {
|
||||
minutesStep?: number;
|
||||
};
|
||||
}
|
||||
export {};
|
||||
211
node_modules/@mui/x-date-pickers/internals/hooks/useField/useFieldRootHandleKeyDown.js
generated
vendored
Normal file
211
node_modules/@mui/x-date-pickers/internals/hooks/useField/useFieldRootHandleKeyDown.js
generated
vendored
Normal file
|
|
@ -0,0 +1,211 @@
|
|||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.useFieldRootHandleKeyDown = useFieldRootHandleKeyDown;
|
||||
var _useEventCallback = _interopRequireDefault(require("@mui/utils/useEventCallback"));
|
||||
var _useField = require("./useField.utils");
|
||||
var _usePickerAdapter = require("../../../hooks/usePickerAdapter");
|
||||
/**
|
||||
* Returns the `onKeyDown` handler to pass to the root element of the field.
|
||||
*/
|
||||
function useFieldRootHandleKeyDown(parameters) {
|
||||
const adapter = (0, _usePickerAdapter.usePickerAdapter)();
|
||||
const {
|
||||
manager: {
|
||||
internal_fieldValueManager: fieldValueManager
|
||||
},
|
||||
internalPropsWithDefaults: {
|
||||
minutesStep,
|
||||
disabled,
|
||||
readOnly
|
||||
},
|
||||
stateResponse: {
|
||||
// States and derived states
|
||||
state,
|
||||
value,
|
||||
activeSectionIndex,
|
||||
parsedSelectedSections,
|
||||
sectionsValueBoundaries,
|
||||
localizedDigits,
|
||||
timezone,
|
||||
sectionOrder,
|
||||
// Methods to update the states
|
||||
clearValue,
|
||||
clearActiveSection,
|
||||
setSelectedSections,
|
||||
updateSectionValue
|
||||
}
|
||||
} = parameters;
|
||||
return (0, _useEventCallback.default)(event => {
|
||||
if (disabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
// eslint-disable-next-line default-case
|
||||
switch (true) {
|
||||
// Select all
|
||||
case (event.ctrlKey || event.metaKey) && String.fromCharCode(event.keyCode) === 'A' && !event.shiftKey && !event.altKey:
|
||||
{
|
||||
// prevent default to make sure that the next line "select all" while updating
|
||||
// the internal state at the same time.
|
||||
event.preventDefault();
|
||||
setSelectedSections('all');
|
||||
break;
|
||||
}
|
||||
|
||||
// Move selection to next section
|
||||
case event.key === 'ArrowRight':
|
||||
{
|
||||
event.preventDefault();
|
||||
if (parsedSelectedSections == null) {
|
||||
setSelectedSections(sectionOrder.startIndex);
|
||||
} else if (parsedSelectedSections === 'all') {
|
||||
setSelectedSections(sectionOrder.endIndex);
|
||||
} else {
|
||||
const nextSectionIndex = sectionOrder.neighbors[parsedSelectedSections].rightIndex;
|
||||
if (nextSectionIndex !== null) {
|
||||
setSelectedSections(nextSectionIndex);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// Move selection to previous section
|
||||
case event.key === 'ArrowLeft':
|
||||
{
|
||||
event.preventDefault();
|
||||
if (parsedSelectedSections == null) {
|
||||
setSelectedSections(sectionOrder.endIndex);
|
||||
} else if (parsedSelectedSections === 'all') {
|
||||
setSelectedSections(sectionOrder.startIndex);
|
||||
} else {
|
||||
const nextSectionIndex = sectionOrder.neighbors[parsedSelectedSections].leftIndex;
|
||||
if (nextSectionIndex !== null) {
|
||||
setSelectedSections(nextSectionIndex);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// Reset the value of the selected section
|
||||
case event.key === 'Delete':
|
||||
{
|
||||
event.preventDefault();
|
||||
if (readOnly) {
|
||||
break;
|
||||
}
|
||||
if (parsedSelectedSections == null || parsedSelectedSections === 'all') {
|
||||
clearValue();
|
||||
} else {
|
||||
clearActiveSection();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// Increment / decrement the selected section value
|
||||
case ['ArrowUp', 'ArrowDown', 'Home', 'End', 'PageUp', 'PageDown'].includes(event.key):
|
||||
{
|
||||
event.preventDefault();
|
||||
if (readOnly || activeSectionIndex == null) {
|
||||
break;
|
||||
}
|
||||
|
||||
// if all sections are selected, mark the currently editing one as selected
|
||||
if (parsedSelectedSections === 'all') {
|
||||
setSelectedSections(activeSectionIndex);
|
||||
}
|
||||
const activeSection = state.sections[activeSectionIndex];
|
||||
const newSectionValue = adjustSectionValue(adapter, timezone, activeSection, event.key, sectionsValueBoundaries, localizedDigits, fieldValueManager.getDateFromSection(value, activeSection), {
|
||||
minutesStep
|
||||
});
|
||||
updateSectionValue({
|
||||
section: activeSection,
|
||||
newSectionValue,
|
||||
shouldGoToNextSection: false
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
function getDeltaFromKeyCode(keyCode) {
|
||||
switch (keyCode) {
|
||||
case 'ArrowUp':
|
||||
return 1;
|
||||
case 'ArrowDown':
|
||||
return -1;
|
||||
case 'PageUp':
|
||||
return 5;
|
||||
case 'PageDown':
|
||||
return -5;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
function adjustSectionValue(adapter, timezone, section, keyCode, sectionsValueBoundaries, localizedDigits, activeDate, stepsAttributes) {
|
||||
const delta = getDeltaFromKeyCode(keyCode);
|
||||
const isStart = keyCode === 'Home';
|
||||
const isEnd = keyCode === 'End';
|
||||
const shouldSetAbsolute = section.value === '' || isStart || isEnd;
|
||||
const adjustDigitSection = () => {
|
||||
const sectionBoundaries = sectionsValueBoundaries[section.type]({
|
||||
currentDate: activeDate,
|
||||
format: section.format,
|
||||
contentType: section.contentType
|
||||
});
|
||||
const getCleanValue = value => (0, _useField.cleanDigitSectionValue)(adapter, value, sectionBoundaries, localizedDigits, section);
|
||||
const step = section.type === 'minutes' && stepsAttributes?.minutesStep ? stepsAttributes.minutesStep : 1;
|
||||
let newSectionValueNumber;
|
||||
if (shouldSetAbsolute) {
|
||||
if (section.type === 'year' && !isEnd && !isStart) {
|
||||
return adapter.formatByString(adapter.date(undefined, timezone), section.format);
|
||||
}
|
||||
if (delta > 0 || isStart) {
|
||||
newSectionValueNumber = sectionBoundaries.minimum;
|
||||
} else {
|
||||
newSectionValueNumber = sectionBoundaries.maximum;
|
||||
}
|
||||
} else {
|
||||
const currentSectionValue = parseInt((0, _useField.removeLocalizedDigits)(section.value, localizedDigits), 10);
|
||||
newSectionValueNumber = currentSectionValue + delta * step;
|
||||
}
|
||||
if (newSectionValueNumber % step !== 0) {
|
||||
if (delta < 0 || isStart) {
|
||||
newSectionValueNumber += step - (step + newSectionValueNumber) % step; // for JS -3 % 5 = -3 (should be 2)
|
||||
}
|
||||
if (delta > 0 || isEnd) {
|
||||
newSectionValueNumber -= newSectionValueNumber % step;
|
||||
}
|
||||
}
|
||||
if (newSectionValueNumber > sectionBoundaries.maximum) {
|
||||
return getCleanValue(sectionBoundaries.minimum + (newSectionValueNumber - sectionBoundaries.maximum - 1) % (sectionBoundaries.maximum - sectionBoundaries.minimum + 1));
|
||||
}
|
||||
if (newSectionValueNumber < sectionBoundaries.minimum) {
|
||||
return getCleanValue(sectionBoundaries.maximum - (sectionBoundaries.minimum - newSectionValueNumber - 1) % (sectionBoundaries.maximum - sectionBoundaries.minimum + 1));
|
||||
}
|
||||
return getCleanValue(newSectionValueNumber);
|
||||
};
|
||||
const adjustLetterSection = () => {
|
||||
const options = (0, _useField.getLetterEditingOptions)(adapter, timezone, section.type, section.format);
|
||||
if (options.length === 0) {
|
||||
return section.value;
|
||||
}
|
||||
if (shouldSetAbsolute) {
|
||||
if (delta > 0 || isStart) {
|
||||
return options[0];
|
||||
}
|
||||
return options[options.length - 1];
|
||||
}
|
||||
const currentOptionIndex = options.indexOf(section.value);
|
||||
const newOptionIndex = (currentOptionIndex + delta) % options.length;
|
||||
const clampedIndex = (newOptionIndex + options.length) % options.length;
|
||||
return options[clampedIndex];
|
||||
};
|
||||
if (section.contentType === 'digit' || section.contentType === 'digit-with-letter') {
|
||||
return adjustDigitSection();
|
||||
}
|
||||
return adjustLetterSection();
|
||||
}
|
||||
32
node_modules/@mui/x-date-pickers/internals/hooks/useField/useFieldRootProps.d.ts
generated
vendored
Normal file
32
node_modules/@mui/x-date-pickers/internals/hooks/useField/useFieldRootProps.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
import { PickerManager } from "../../../models/index.js";
|
||||
import { UseFieldDOMGetters, UseFieldInternalProps } from "./useField.types.js";
|
||||
import { UseFieldStateReturnValue } from "./useFieldState.js";
|
||||
import { UseFieldCharacterEditingReturnValue } from "./useFieldCharacterEditing.js";
|
||||
/**
|
||||
* Generate the props to pass to the root element of the field.
|
||||
* It is not used by the non-accessible DOM structure (with an <input /> element for editing).
|
||||
* It should be used in the MUI accessible DOM structure and the Base UI implementation.
|
||||
* @param {UseFieldRootPropsParameters} parameters The parameters of the hook.
|
||||
* @returns {UseFieldRootPropsReturnValue} The props to forward to the root element of the field.
|
||||
*/
|
||||
export declare function useFieldRootProps(parameters: UseFieldRootPropsParameters): UseFieldRootPropsReturnValue;
|
||||
interface UseFieldRootPropsParameters {
|
||||
manager: PickerManager<any, any, any, any, any>;
|
||||
stateResponse: UseFieldStateReturnValue<any>;
|
||||
applyCharacterEditing: UseFieldCharacterEditingReturnValue;
|
||||
internalPropsWithDefaults: UseFieldInternalProps<any, any, any>;
|
||||
domGetters: UseFieldDOMGetters;
|
||||
focused: boolean;
|
||||
setFocused: (focused: boolean) => void;
|
||||
}
|
||||
interface UseFieldRootPropsReturnValue {
|
||||
onKeyDown: React.KeyboardEventHandler<HTMLDivElement>;
|
||||
onBlur: React.FocusEventHandler<HTMLDivElement>;
|
||||
onFocus: React.FocusEventHandler<HTMLDivElement>;
|
||||
onClick: React.MouseEventHandler<HTMLDivElement>;
|
||||
onPaste: React.ClipboardEventHandler<HTMLDivElement>;
|
||||
onInput: React.FormEventHandler<HTMLDivElement>;
|
||||
contentEditable: boolean;
|
||||
tabIndex: number;
|
||||
}
|
||||
export {};
|
||||
157
node_modules/@mui/x-date-pickers/internals/hooks/useField/useFieldRootProps.js
generated
vendored
Normal file
157
node_modules/@mui/x-date-pickers/internals/hooks/useField/useFieldRootProps.js
generated
vendored
Normal file
|
|
@ -0,0 +1,157 @@
|
|||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.useFieldRootProps = useFieldRootProps;
|
||||
var _useEventCallback = _interopRequireDefault(require("@mui/utils/useEventCallback"));
|
||||
var _useTimeout = _interopRequireDefault(require("@mui/utils/useTimeout"));
|
||||
var _useFieldRootHandleKeyDown = require("./useFieldRootHandleKeyDown");
|
||||
var _utils = require("../../utils/utils");
|
||||
var _syncSelectionToDOM = require("./syncSelectionToDOM");
|
||||
/**
|
||||
* Generate the props to pass to the root element of the field.
|
||||
* It is not used by the non-accessible DOM structure (with an <input /> element for editing).
|
||||
* It should be used in the MUI accessible DOM structure and the Base UI implementation.
|
||||
* @param {UseFieldRootPropsParameters} parameters The parameters of the hook.
|
||||
* @returns {UseFieldRootPropsReturnValue} The props to forward to the root element of the field.
|
||||
*/
|
||||
function useFieldRootProps(parameters) {
|
||||
const {
|
||||
manager,
|
||||
focused,
|
||||
setFocused,
|
||||
domGetters,
|
||||
stateResponse,
|
||||
applyCharacterEditing,
|
||||
internalPropsWithDefaults,
|
||||
stateResponse: {
|
||||
// States and derived states
|
||||
parsedSelectedSections,
|
||||
sectionOrder,
|
||||
state,
|
||||
// Methods to update the states
|
||||
clearValue,
|
||||
setCharacterQuery,
|
||||
setSelectedSections,
|
||||
updateValueFromValueStr
|
||||
},
|
||||
internalPropsWithDefaults: {
|
||||
disabled = false,
|
||||
readOnly = false
|
||||
}
|
||||
} = parameters;
|
||||
|
||||
// TODO: Inline onContainerKeyDown once the old DOM structure is removed
|
||||
const handleKeyDown = (0, _useFieldRootHandleKeyDown.useFieldRootHandleKeyDown)({
|
||||
manager,
|
||||
internalPropsWithDefaults,
|
||||
stateResponse
|
||||
});
|
||||
const containerClickTimeout = (0, _useTimeout.default)();
|
||||
const handleClick = (0, _useEventCallback.default)(event => {
|
||||
if (disabled || !domGetters.isReady()) {
|
||||
return;
|
||||
}
|
||||
setFocused(true);
|
||||
if (parsedSelectedSections === 'all') {
|
||||
containerClickTimeout.start(0, () => {
|
||||
const cursorPosition = document.getSelection().getRangeAt(0).startOffset;
|
||||
if (cursorPosition === 0) {
|
||||
setSelectedSections(sectionOrder.startIndex);
|
||||
return;
|
||||
}
|
||||
let sectionIndex = 0;
|
||||
let cursorOnStartOfSection = 0;
|
||||
while (cursorOnStartOfSection < cursorPosition && sectionIndex < state.sections.length) {
|
||||
const section = state.sections[sectionIndex];
|
||||
sectionIndex += 1;
|
||||
cursorOnStartOfSection += `${section.startSeparator}${section.value || section.placeholder}${section.endSeparator}`.length;
|
||||
}
|
||||
setSelectedSections(sectionIndex - 1);
|
||||
});
|
||||
} else if (!focused) {
|
||||
setFocused(true);
|
||||
setSelectedSections(sectionOrder.startIndex);
|
||||
} else {
|
||||
const hasClickedOnASection = domGetters.getRoot().contains(event.target);
|
||||
if (!hasClickedOnASection) {
|
||||
setSelectedSections(sectionOrder.startIndex);
|
||||
}
|
||||
}
|
||||
});
|
||||
const handleInput = (0, _useEventCallback.default)(event => {
|
||||
if (!domGetters.isReady() || parsedSelectedSections !== 'all') {
|
||||
return;
|
||||
}
|
||||
const target = event.target;
|
||||
const keyPressed = target.textContent ?? '';
|
||||
domGetters.getRoot().innerHTML = state.sections.map(section => `${section.startSeparator}${section.value || section.placeholder}${section.endSeparator}`).join('');
|
||||
(0, _syncSelectionToDOM.syncSelectionToDOM)({
|
||||
focused,
|
||||
domGetters,
|
||||
stateResponse
|
||||
});
|
||||
if (keyPressed.length === 0 || keyPressed.charCodeAt(0) === 10) {
|
||||
clearValue();
|
||||
setSelectedSections('all');
|
||||
} else if (keyPressed.length > 1) {
|
||||
updateValueFromValueStr(keyPressed);
|
||||
} else {
|
||||
if (parsedSelectedSections === 'all') {
|
||||
setSelectedSections(0);
|
||||
}
|
||||
applyCharacterEditing({
|
||||
keyPressed,
|
||||
sectionIndex: 0
|
||||
});
|
||||
}
|
||||
});
|
||||
const handlePaste = (0, _useEventCallback.default)(event => {
|
||||
if (readOnly || parsedSelectedSections !== 'all') {
|
||||
event.preventDefault();
|
||||
return;
|
||||
}
|
||||
const pastedValue = event.clipboardData.getData('text');
|
||||
event.preventDefault();
|
||||
setCharacterQuery(null);
|
||||
updateValueFromValueStr(pastedValue);
|
||||
});
|
||||
const handleFocus = (0, _useEventCallback.default)(() => {
|
||||
if (focused || disabled || !domGetters.isReady()) {
|
||||
return;
|
||||
}
|
||||
const activeElement = (0, _utils.getActiveElement)(domGetters.getRoot());
|
||||
setFocused(true);
|
||||
const isFocusInsideASection = domGetters.getSectionIndexFromDOMElement(activeElement) != null;
|
||||
if (!isFocusInsideASection) {
|
||||
setSelectedSections(sectionOrder.startIndex);
|
||||
}
|
||||
});
|
||||
const handleBlur = (0, _useEventCallback.default)(() => {
|
||||
setTimeout(() => {
|
||||
if (!domGetters.isReady()) {
|
||||
return;
|
||||
}
|
||||
const activeElement = (0, _utils.getActiveElement)(domGetters.getRoot());
|
||||
const shouldBlur = !domGetters.getRoot().contains(activeElement);
|
||||
if (shouldBlur) {
|
||||
setFocused(false);
|
||||
setSelectedSections(null);
|
||||
}
|
||||
});
|
||||
});
|
||||
return {
|
||||
// Event handlers
|
||||
onKeyDown: handleKeyDown,
|
||||
onBlur: handleBlur,
|
||||
onFocus: handleFocus,
|
||||
onClick: handleClick,
|
||||
onPaste: handlePaste,
|
||||
onInput: handleInput,
|
||||
// Other
|
||||
contentEditable: parsedSelectedSections === 'all',
|
||||
tabIndex: parsedSelectedSections === 0 ? -1 : 0 // TODO: Try to set to undefined when there is a section selected.
|
||||
};
|
||||
}
|
||||
17
node_modules/@mui/x-date-pickers/internals/hooks/useField/useFieldSectionContainerProps.d.ts
generated
vendored
Normal file
17
node_modules/@mui/x-date-pickers/internals/hooks/useField/useFieldSectionContainerProps.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
import * as React from 'react';
|
||||
import { UseFieldStateReturnValue } from "./useFieldState.js";
|
||||
import { UseFieldInternalProps } from "./useField.types.js";
|
||||
/**
|
||||
* Generate the props to pass to the container element of each section of the field.
|
||||
* It is not used by the non-accessible DOM structure (with an <input /> element for editing).
|
||||
* It should be used in the MUI accessible DOM structure and the Base UI implementation.
|
||||
* @param {UseFieldRootPropsParameters} parameters The parameters of the hook.
|
||||
* @returns {UseFieldRootPropsReturnValue} The props to forward to the container element of each section of the field.
|
||||
*/
|
||||
export declare function useFieldSectionContainerProps(parameters: UseFieldSectionContainerPropsParameters): UseFieldSectionContainerPropsReturnValue;
|
||||
interface UseFieldSectionContainerPropsParameters {
|
||||
stateResponse: UseFieldStateReturnValue<any>;
|
||||
internalPropsWithDefaults: UseFieldInternalProps<any, any, any>;
|
||||
}
|
||||
type UseFieldSectionContainerPropsReturnValue = (sectionIndex: number) => React.HTMLAttributes<HTMLSpanElement>;
|
||||
export {};
|
||||
38
node_modules/@mui/x-date-pickers/internals/hooks/useField/useFieldSectionContainerProps.js
generated
vendored
Normal file
38
node_modules/@mui/x-date-pickers/internals/hooks/useField/useFieldSectionContainerProps.js
generated
vendored
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
"use strict";
|
||||
|
||||
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.useFieldSectionContainerProps = useFieldSectionContainerProps;
|
||||
var React = _interopRequireWildcard(require("react"));
|
||||
/**
|
||||
* Generate the props to pass to the container element of each section of the field.
|
||||
* It is not used by the non-accessible DOM structure (with an <input /> element for editing).
|
||||
* It should be used in the MUI accessible DOM structure and the Base UI implementation.
|
||||
* @param {UseFieldRootPropsParameters} parameters The parameters of the hook.
|
||||
* @returns {UseFieldRootPropsReturnValue} The props to forward to the container element of each section of the field.
|
||||
*/
|
||||
function useFieldSectionContainerProps(parameters) {
|
||||
const {
|
||||
stateResponse: {
|
||||
// Methods to update the states
|
||||
setSelectedSections
|
||||
},
|
||||
internalPropsWithDefaults: {
|
||||
disabled = false
|
||||
}
|
||||
} = parameters;
|
||||
const createHandleClick = React.useCallback(sectionIndex => event => {
|
||||
// The click event on the clear button would propagate to the input, trigger this handler and result in a wrong section selection.
|
||||
// We avoid this by checking if the call to this function is actually intended, or a side effect.
|
||||
if (disabled || event.isDefaultPrevented()) {
|
||||
return;
|
||||
}
|
||||
setSelectedSections(sectionIndex);
|
||||
}, [disabled, setSelectedSections]);
|
||||
return React.useCallback(sectionIndex => ({
|
||||
'data-sectionindex': sectionIndex,
|
||||
onClick: createHandleClick(sectionIndex)
|
||||
}), [createHandleClick]);
|
||||
}
|
||||
23
node_modules/@mui/x-date-pickers/internals/hooks/useField/useFieldSectionContentProps.d.ts
generated
vendored
Normal file
23
node_modules/@mui/x-date-pickers/internals/hooks/useField/useFieldSectionContentProps.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
import { UseFieldStateReturnValue } from "./useFieldState.js";
|
||||
import { FieldSection, PickerManager } from "../../../models/index.js";
|
||||
import { UseFieldDOMGetters, UseFieldInternalProps } from "./useField.types.js";
|
||||
import { UseFieldCharacterEditingReturnValue } from "./useFieldCharacterEditing.js";
|
||||
import { PickersSectionElement } from "../../../PickersSectionList/index.js";
|
||||
/**
|
||||
* Generate the props to pass to the content element of each section of the field.
|
||||
* It is not used by the non-accessible DOM structure (with an <input /> element for editing).
|
||||
* It should be used in the MUI accessible DOM structure and the Base UI implementation.
|
||||
* @param {UseFieldRootPropsParameters} parameters The parameters of the hook.
|
||||
* @returns {UseFieldRootPropsReturnValue} The props to forward to the content element of each section of the field.
|
||||
*/
|
||||
export declare function useFieldSectionContentProps(parameters: UseFieldSectionContentPropsParameters): UseFieldSectionContentPropsReturnValue;
|
||||
interface UseFieldSectionContentPropsParameters {
|
||||
manager: PickerManager<any, any, any, any, any>;
|
||||
stateResponse: UseFieldStateReturnValue<any>;
|
||||
applyCharacterEditing: UseFieldCharacterEditingReturnValue;
|
||||
internalPropsWithDefaults: UseFieldInternalProps<any, any, any>;
|
||||
domGetters: UseFieldDOMGetters;
|
||||
focused: boolean;
|
||||
}
|
||||
type UseFieldSectionContentPropsReturnValue = (section: FieldSection, sectionIndex: number) => PickersSectionElement['content'];
|
||||
export {};
|
||||
236
node_modules/@mui/x-date-pickers/internals/hooks/useField/useFieldSectionContentProps.js
generated
vendored
Normal file
236
node_modules/@mui/x-date-pickers/internals/hooks/useField/useFieldSectionContentProps.js
generated
vendored
Normal file
|
|
@ -0,0 +1,236 @@
|
|||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
||||
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.useFieldSectionContentProps = useFieldSectionContentProps;
|
||||
var React = _interopRequireWildcard(require("react"));
|
||||
var _useEventCallback = _interopRequireDefault(require("@mui/utils/useEventCallback"));
|
||||
var _useId = _interopRequireDefault(require("@mui/utils/useId"));
|
||||
var _hooks = require("../../../hooks");
|
||||
var _syncSelectionToDOM = require("./syncSelectionToDOM");
|
||||
/**
|
||||
* Generate the props to pass to the content element of each section of the field.
|
||||
* It is not used by the non-accessible DOM structure (with an <input /> element for editing).
|
||||
* It should be used in the MUI accessible DOM structure and the Base UI implementation.
|
||||
* @param {UseFieldRootPropsParameters} parameters The parameters of the hook.
|
||||
* @returns {UseFieldRootPropsReturnValue} The props to forward to the content element of each section of the field.
|
||||
*/
|
||||
function useFieldSectionContentProps(parameters) {
|
||||
const adapter = (0, _hooks.usePickerAdapter)();
|
||||
const translations = (0, _hooks.usePickerTranslations)();
|
||||
const id = (0, _useId.default)();
|
||||
const {
|
||||
focused,
|
||||
domGetters,
|
||||
stateResponse,
|
||||
applyCharacterEditing,
|
||||
manager: {
|
||||
internal_fieldValueManager: fieldValueManager
|
||||
},
|
||||
stateResponse: {
|
||||
// States and derived states
|
||||
parsedSelectedSections,
|
||||
sectionsValueBoundaries,
|
||||
state,
|
||||
value,
|
||||
// Methods to update the states
|
||||
clearActiveSection,
|
||||
setCharacterQuery,
|
||||
setSelectedSections,
|
||||
updateSectionValue,
|
||||
updateValueFromValueStr
|
||||
},
|
||||
internalPropsWithDefaults: {
|
||||
disabled = false,
|
||||
readOnly = false
|
||||
}
|
||||
} = parameters;
|
||||
const isContainerEditable = parsedSelectedSections === 'all';
|
||||
const isEditable = !isContainerEditable && !disabled && !readOnly;
|
||||
|
||||
/**
|
||||
* If a section content has been updated with a value we don't want to keep,
|
||||
* Then we need to imperatively revert it (we can't let React do it because the value did not change in his internal representation).
|
||||
*/
|
||||
const revertDOMSectionChange = (0, _useEventCallback.default)(sectionIndex => {
|
||||
if (!domGetters.isReady()) {
|
||||
return;
|
||||
}
|
||||
const section = state.sections[sectionIndex];
|
||||
domGetters.getSectionContent(sectionIndex).innerHTML = section.value || section.placeholder;
|
||||
(0, _syncSelectionToDOM.syncSelectionToDOM)({
|
||||
focused,
|
||||
domGetters,
|
||||
stateResponse
|
||||
});
|
||||
});
|
||||
const handleInput = (0, _useEventCallback.default)(event => {
|
||||
if (!domGetters.isReady()) {
|
||||
return;
|
||||
}
|
||||
const target = event.target;
|
||||
const keyPressed = target.textContent ?? '';
|
||||
const sectionIndex = domGetters.getSectionIndexFromDOMElement(target);
|
||||
const section = state.sections[sectionIndex];
|
||||
if (readOnly) {
|
||||
revertDOMSectionChange(sectionIndex);
|
||||
return;
|
||||
}
|
||||
if (keyPressed.length === 0) {
|
||||
if (section.value === '') {
|
||||
revertDOMSectionChange(sectionIndex);
|
||||
return;
|
||||
}
|
||||
const inputType = event.nativeEvent.inputType;
|
||||
if (inputType === 'insertParagraph' || inputType === 'insertLineBreak') {
|
||||
revertDOMSectionChange(sectionIndex);
|
||||
return;
|
||||
}
|
||||
revertDOMSectionChange(sectionIndex);
|
||||
clearActiveSection();
|
||||
return;
|
||||
}
|
||||
applyCharacterEditing({
|
||||
keyPressed,
|
||||
sectionIndex
|
||||
});
|
||||
|
||||
// The DOM value needs to remain the one React is expecting.
|
||||
revertDOMSectionChange(sectionIndex);
|
||||
});
|
||||
const handleMouseUp = (0, _useEventCallback.default)(event => {
|
||||
// Without this, the browser will remove the selected when clicking inside an already-selected section.
|
||||
event.preventDefault();
|
||||
});
|
||||
const handlePaste = (0, _useEventCallback.default)(event => {
|
||||
// prevent default to avoid the input `onInput` handler being called
|
||||
event.preventDefault();
|
||||
if (readOnly || disabled || typeof parsedSelectedSections !== 'number') {
|
||||
return;
|
||||
}
|
||||
const activeSection = state.sections[parsedSelectedSections];
|
||||
const pastedValue = event.clipboardData.getData('text');
|
||||
const lettersOnly = /^[a-zA-Z]+$/.test(pastedValue);
|
||||
const digitsOnly = /^[0-9]+$/.test(pastedValue);
|
||||
const digitsAndLetterOnly = /^(([a-zA-Z]+)|)([0-9]+)(([a-zA-Z]+)|)$/.test(pastedValue);
|
||||
const isValidPastedValue = activeSection.contentType === 'letter' && lettersOnly || activeSection.contentType === 'digit' && digitsOnly || activeSection.contentType === 'digit-with-letter' && digitsAndLetterOnly;
|
||||
if (isValidPastedValue) {
|
||||
setCharacterQuery(null);
|
||||
updateSectionValue({
|
||||
section: activeSection,
|
||||
newSectionValue: pastedValue,
|
||||
shouldGoToNextSection: true
|
||||
});
|
||||
}
|
||||
// If the pasted value corresponds to a single section, but not the expected type, we skip the modification
|
||||
else if (!lettersOnly && !digitsOnly) {
|
||||
setCharacterQuery(null);
|
||||
updateValueFromValueStr(pastedValue);
|
||||
}
|
||||
});
|
||||
const handleDragOver = (0, _useEventCallback.default)(event => {
|
||||
event.preventDefault();
|
||||
event.dataTransfer.dropEffect = 'none';
|
||||
});
|
||||
const createFocusHandler = React.useCallback(sectionIndex => () => {
|
||||
if (disabled) {
|
||||
return;
|
||||
}
|
||||
setSelectedSections(sectionIndex);
|
||||
}, [disabled, setSelectedSections]);
|
||||
return React.useCallback((section, sectionIndex) => {
|
||||
const sectionBoundaries = sectionsValueBoundaries[section.type]({
|
||||
currentDate: fieldValueManager.getDateFromSection(value, section),
|
||||
contentType: section.contentType,
|
||||
format: section.format
|
||||
});
|
||||
return {
|
||||
// Event handlers
|
||||
onInput: handleInput,
|
||||
onPaste: handlePaste,
|
||||
onMouseUp: handleMouseUp,
|
||||
onDragOver: handleDragOver,
|
||||
onFocus: createFocusHandler(sectionIndex),
|
||||
// Aria attributes
|
||||
'aria-labelledby': `${id}-${section.type}`,
|
||||
'aria-readonly': readOnly,
|
||||
'aria-valuenow': getSectionValueNow(section, adapter),
|
||||
'aria-valuemin': sectionBoundaries.minimum,
|
||||
'aria-valuemax': sectionBoundaries.maximum,
|
||||
'aria-valuetext': section.value ? getSectionValueText(section, adapter) : translations.empty,
|
||||
'aria-label': translations[section.type],
|
||||
'aria-disabled': disabled,
|
||||
// Other
|
||||
tabIndex: isContainerEditable || sectionIndex > 0 ? -1 : 0,
|
||||
contentEditable: !isContainerEditable && !disabled && !readOnly,
|
||||
role: 'spinbutton',
|
||||
id: `${id}-${section.type}`,
|
||||
'data-range-position': section.dateName || undefined,
|
||||
spellCheck: isEditable ? false : undefined,
|
||||
autoCapitalize: isEditable ? 'off' : undefined,
|
||||
autoCorrect: isEditable ? 'off' : undefined,
|
||||
children: section.value || section.placeholder,
|
||||
inputMode: section.contentType === 'letter' ? 'text' : 'numeric'
|
||||
};
|
||||
}, [sectionsValueBoundaries, id, isContainerEditable, disabled, readOnly, isEditable, translations, adapter, handleInput, handlePaste, handleMouseUp, handleDragOver, createFocusHandler, fieldValueManager, value]);
|
||||
}
|
||||
function getSectionValueText(section, adapter) {
|
||||
if (!section.value) {
|
||||
return undefined;
|
||||
}
|
||||
switch (section.type) {
|
||||
case 'month':
|
||||
{
|
||||
if (section.contentType === 'digit') {
|
||||
return adapter.format(adapter.setMonth(adapter.date(), Number(section.value) - 1), 'month');
|
||||
}
|
||||
const parsedDate = adapter.parse(section.value, section.format);
|
||||
return parsedDate ? adapter.format(parsedDate, 'month') : undefined;
|
||||
}
|
||||
case 'day':
|
||||
return section.contentType === 'digit' ? adapter.format(adapter.setDate(adapter.startOfYear(adapter.date()), Number(section.value)), 'dayOfMonthFull') : section.value;
|
||||
case 'weekDay':
|
||||
// TODO: improve by providing the label of the week day
|
||||
return undefined;
|
||||
default:
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
function getSectionValueNow(section, adapter) {
|
||||
if (!section.value) {
|
||||
return undefined;
|
||||
}
|
||||
switch (section.type) {
|
||||
case 'weekDay':
|
||||
{
|
||||
if (section.contentType === 'letter') {
|
||||
// TODO: improve by resolving the week day number from a letter week day
|
||||
return undefined;
|
||||
}
|
||||
return Number(section.value);
|
||||
}
|
||||
case 'meridiem':
|
||||
{
|
||||
const parsedDate = adapter.parse(`01:00 ${section.value}`, `${adapter.formats.hours12h}:${adapter.formats.minutes} ${section.format}`);
|
||||
if (parsedDate) {
|
||||
return adapter.getHours(parsedDate) >= 12 ? 1 : 0;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
case 'day':
|
||||
return section.contentType === 'digit-with-letter' ? parseInt(section.value, 10) : Number(section.value);
|
||||
case 'month':
|
||||
{
|
||||
if (section.contentType === 'digit') {
|
||||
return Number(section.value);
|
||||
}
|
||||
const parsedDate = adapter.parse(section.value, section.format);
|
||||
return parsedDate ? adapter.getMonth(parsedDate) + 1 : undefined;
|
||||
}
|
||||
default:
|
||||
return section.contentType !== 'letter' ? Number(section.value) : undefined;
|
||||
}
|
||||
}
|
||||
44
node_modules/@mui/x-date-pickers/internals/hooks/useField/useFieldState.d.ts
generated
vendored
Normal file
44
node_modules/@mui/x-date-pickers/internals/hooks/useField/useFieldState.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
import { UseFieldInternalProps, UseFieldState, FieldParsedSelectedSections, FieldSectionsValueBoundaries, SectionOrdering, UseFieldForwardedProps, CharacterEditingQuery } from "./useField.types.js";
|
||||
import { FieldSelectedSections, PickersTimezone, InferFieldSection, PickerManager } from "../../../models/index.js";
|
||||
import { PickerValidValue } from "../../models/index.js";
|
||||
export declare const useFieldState: <TValue extends PickerValidValue, TEnableAccessibleFieldDOMStructure extends boolean, TError, TValidationProps extends {}, TForwardedProps extends UseFieldForwardedProps<TEnableAccessibleFieldDOMStructure>>(parameters: UseFieldStateParameters<TValue, TEnableAccessibleFieldDOMStructure, TError, TValidationProps, TForwardedProps>) => UseFieldStateReturnValue<TValue>;
|
||||
interface UseFieldStateParameters<TValue extends PickerValidValue, TEnableAccessibleFieldDOMStructure extends boolean, TError, TValidationProps extends {}, TForwardedProps extends UseFieldForwardedProps<TEnableAccessibleFieldDOMStructure>> {
|
||||
manager: PickerManager<TValue, TEnableAccessibleFieldDOMStructure, TError, TValidationProps, any>;
|
||||
internalPropsWithDefaults: UseFieldInternalProps<TValue, TEnableAccessibleFieldDOMStructure, TError> & TValidationProps;
|
||||
forwardedProps: TForwardedProps;
|
||||
}
|
||||
export interface UpdateSectionValueParameters<TValue extends PickerValidValue> {
|
||||
/**
|
||||
* The section on which we want to apply the new value.
|
||||
*/
|
||||
section: InferFieldSection<TValue>;
|
||||
/**
|
||||
* Value to apply to the active section.
|
||||
*/
|
||||
newSectionValue: string;
|
||||
/**
|
||||
* If `true`, the focus will move to the next section.
|
||||
*/
|
||||
shouldGoToNextSection: boolean;
|
||||
}
|
||||
export interface UseFieldStateReturnValue<TValue extends PickerValidValue> {
|
||||
activeSectionIndex: number | null;
|
||||
areAllSectionsEmpty: boolean;
|
||||
error: boolean;
|
||||
localizedDigits: string[];
|
||||
parsedSelectedSections: FieldParsedSelectedSections;
|
||||
sectionOrder: SectionOrdering;
|
||||
sectionsValueBoundaries: FieldSectionsValueBoundaries;
|
||||
state: UseFieldState<TValue>;
|
||||
timezone: PickersTimezone;
|
||||
value: TValue;
|
||||
clearValue: () => void;
|
||||
clearActiveSection: () => void;
|
||||
setCharacterQuery: (characterQuery: CharacterEditingQuery | null) => void;
|
||||
setSelectedSections: (sections: FieldSelectedSections) => void;
|
||||
setTempAndroidValueStr: (tempAndroidValueStr: string | null) => void;
|
||||
updateSectionValue: (parameters: UpdateSectionValueParameters<TValue>) => void;
|
||||
updateValueFromValueStr: (valueStr: string) => void;
|
||||
getSectionsFromValue: (value: TValue, fallbackSections?: InferFieldSection<TValue>[] | null) => InferFieldSection<TValue>[];
|
||||
}
|
||||
export {};
|
||||
400
node_modules/@mui/x-date-pickers/internals/hooks/useField/useFieldState.js
generated
vendored
Normal file
400
node_modules/@mui/x-date-pickers/internals/hooks/useField/useFieldState.js
generated
vendored
Normal file
|
|
@ -0,0 +1,400 @@
|
|||
"use strict";
|
||||
'use client';
|
||||
|
||||
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.useFieldState = void 0;
|
||||
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
||||
var React = _interopRequireWildcard(require("react"));
|
||||
var _useControlled = _interopRequireDefault(require("@mui/utils/useControlled"));
|
||||
var _useTimeout = _interopRequireDefault(require("@mui/utils/useTimeout"));
|
||||
var _useEventCallback = _interopRequireDefault(require("@mui/utils/useEventCallback"));
|
||||
var _RtlProvider = require("@mui/system/RtlProvider");
|
||||
var _hooks = require("../../../hooks");
|
||||
var _useField = require("./useField.utils");
|
||||
var _buildSectionsFromFormat = require("./buildSectionsFromFormat");
|
||||
var _validation = require("../../../validation");
|
||||
var _useControlledValue = require("../useControlledValue");
|
||||
var _getDefaultReferenceDate = require("../../utils/getDefaultReferenceDate");
|
||||
const QUERY_LIFE_DURATION_MS = 5000;
|
||||
const useFieldState = parameters => {
|
||||
const adapter = (0, _hooks.usePickerAdapter)();
|
||||
const translations = (0, _hooks.usePickerTranslations)();
|
||||
const isRtl = (0, _RtlProvider.useRtl)();
|
||||
const {
|
||||
manager: {
|
||||
validator,
|
||||
valueType,
|
||||
internal_valueManager: valueManager,
|
||||
internal_fieldValueManager: fieldValueManager
|
||||
},
|
||||
internalPropsWithDefaults,
|
||||
internalPropsWithDefaults: {
|
||||
value: valueProp,
|
||||
defaultValue,
|
||||
referenceDate: referenceDateProp,
|
||||
onChange,
|
||||
format,
|
||||
formatDensity = 'dense',
|
||||
selectedSections: selectedSectionsProp,
|
||||
onSelectedSectionsChange,
|
||||
shouldRespectLeadingZeros = false,
|
||||
timezone: timezoneProp,
|
||||
enableAccessibleFieldDOMStructure = true
|
||||
},
|
||||
forwardedProps: {
|
||||
error: errorProp
|
||||
}
|
||||
} = parameters;
|
||||
const {
|
||||
value,
|
||||
handleValueChange,
|
||||
timezone
|
||||
} = (0, _useControlledValue.useControlledValue)({
|
||||
name: 'a field component',
|
||||
timezone: timezoneProp,
|
||||
value: valueProp,
|
||||
defaultValue,
|
||||
referenceDate: referenceDateProp,
|
||||
onChange,
|
||||
valueManager
|
||||
});
|
||||
const valueRef = React.useRef(value);
|
||||
React.useEffect(() => {
|
||||
valueRef.current = value;
|
||||
}, [value]);
|
||||
const {
|
||||
hasValidationError
|
||||
} = (0, _validation.useValidation)({
|
||||
props: internalPropsWithDefaults,
|
||||
validator,
|
||||
timezone,
|
||||
value,
|
||||
onError: internalPropsWithDefaults.onError
|
||||
});
|
||||
const error = React.useMemo(() => {
|
||||
// only override when `error` is undefined.
|
||||
// in case of multi input fields, the `error` value is provided externally and will always be defined.
|
||||
if (errorProp !== undefined) {
|
||||
return errorProp;
|
||||
}
|
||||
return hasValidationError;
|
||||
}, [hasValidationError, errorProp]);
|
||||
const localizedDigits = React.useMemo(() => (0, _useField.getLocalizedDigits)(adapter), [adapter]);
|
||||
const sectionsValueBoundaries = React.useMemo(() => (0, _useField.getSectionsBoundaries)(adapter, localizedDigits, timezone), [adapter, localizedDigits, timezone]);
|
||||
const getSectionsFromValue = React.useCallback(valueToAnalyze => fieldValueManager.getSectionsFromValue(valueToAnalyze, date => (0, _buildSectionsFromFormat.buildSectionsFromFormat)({
|
||||
adapter,
|
||||
localeText: translations,
|
||||
localizedDigits,
|
||||
format,
|
||||
date,
|
||||
formatDensity,
|
||||
shouldRespectLeadingZeros,
|
||||
enableAccessibleFieldDOMStructure,
|
||||
isRtl
|
||||
})), [fieldValueManager, format, translations, localizedDigits, isRtl, shouldRespectLeadingZeros, adapter, formatDensity, enableAccessibleFieldDOMStructure]);
|
||||
const [state, setState] = React.useState(() => {
|
||||
const sections = getSectionsFromValue(value);
|
||||
(0, _useField.validateSections)(sections, valueType);
|
||||
const stateWithoutReferenceDate = {
|
||||
sections,
|
||||
lastExternalValue: value,
|
||||
lastSectionsDependencies: {
|
||||
format,
|
||||
isRtl,
|
||||
locale: adapter.locale
|
||||
},
|
||||
tempValueStrAndroid: null,
|
||||
characterQuery: null
|
||||
};
|
||||
const granularity = (0, _getDefaultReferenceDate.getSectionTypeGranularity)(sections);
|
||||
const referenceValue = valueManager.getInitialReferenceValue({
|
||||
referenceDate: referenceDateProp,
|
||||
value,
|
||||
adapter,
|
||||
props: internalPropsWithDefaults,
|
||||
granularity,
|
||||
timezone
|
||||
});
|
||||
return (0, _extends2.default)({}, stateWithoutReferenceDate, {
|
||||
referenceValue
|
||||
});
|
||||
});
|
||||
const [selectedSections, innerSetSelectedSections] = (0, _useControlled.default)({
|
||||
controlled: selectedSectionsProp,
|
||||
default: null,
|
||||
name: 'useField',
|
||||
state: 'selectedSections'
|
||||
});
|
||||
const setSelectedSections = newSelectedSections => {
|
||||
innerSetSelectedSections(newSelectedSections);
|
||||
onSelectedSectionsChange?.(newSelectedSections);
|
||||
};
|
||||
const parsedSelectedSections = React.useMemo(() => (0, _useField.parseSelectedSections)(selectedSections, state.sections), [selectedSections, state.sections]);
|
||||
const activeSectionIndex = parsedSelectedSections === 'all' ? 0 : parsedSelectedSections;
|
||||
const sectionOrder = React.useMemo(() => (0, _useField.getSectionOrder)(state.sections, isRtl && !enableAccessibleFieldDOMStructure), [state.sections, isRtl, enableAccessibleFieldDOMStructure]);
|
||||
const areAllSectionsEmpty = React.useMemo(() => state.sections.every(section => section.value === ''), [state.sections]);
|
||||
const publishValue = newValue => {
|
||||
const context = {
|
||||
validationError: validator({
|
||||
adapter,
|
||||
value: newValue,
|
||||
timezone,
|
||||
props: internalPropsWithDefaults
|
||||
})
|
||||
};
|
||||
handleValueChange(newValue, context);
|
||||
};
|
||||
const setSectionValue = (sectionIndex, newSectionValue) => {
|
||||
const newSections = [...state.sections];
|
||||
newSections[sectionIndex] = (0, _extends2.default)({}, newSections[sectionIndex], {
|
||||
value: newSectionValue,
|
||||
modified: true
|
||||
});
|
||||
return newSections;
|
||||
};
|
||||
const sectionToUpdateOnNextInvalidDateRef = React.useRef(null);
|
||||
const updateSectionValueOnNextInvalidDateTimeout = (0, _useTimeout.default)();
|
||||
const setSectionUpdateToApplyOnNextInvalidDate = newSectionValue => {
|
||||
if (activeSectionIndex == null) {
|
||||
return;
|
||||
}
|
||||
sectionToUpdateOnNextInvalidDateRef.current = {
|
||||
sectionIndex: activeSectionIndex,
|
||||
value: newSectionValue
|
||||
};
|
||||
updateSectionValueOnNextInvalidDateTimeout.start(0, () => {
|
||||
sectionToUpdateOnNextInvalidDateRef.current = null;
|
||||
});
|
||||
};
|
||||
const clearValue = () => {
|
||||
if (valueManager.areValuesEqual(adapter, value, valueManager.emptyValue)) {
|
||||
setState(prevState => (0, _extends2.default)({}, prevState, {
|
||||
sections: prevState.sections.map(section => (0, _extends2.default)({}, section, {
|
||||
value: ''
|
||||
})),
|
||||
tempValueStrAndroid: null,
|
||||
characterQuery: null
|
||||
}));
|
||||
} else {
|
||||
setState(prevState => (0, _extends2.default)({}, prevState, {
|
||||
characterQuery: null
|
||||
}));
|
||||
publishValue(valueManager.emptyValue);
|
||||
}
|
||||
};
|
||||
const clearActiveSection = () => {
|
||||
if (activeSectionIndex == null) {
|
||||
return;
|
||||
}
|
||||
const activeSection = state.sections[activeSectionIndex];
|
||||
if (activeSection.value === '') {
|
||||
return;
|
||||
}
|
||||
setSectionUpdateToApplyOnNextInvalidDate('');
|
||||
if (fieldValueManager.getDateFromSection(value, activeSection) === null) {
|
||||
setState(prevState => (0, _extends2.default)({}, prevState, {
|
||||
sections: setSectionValue(activeSectionIndex, ''),
|
||||
tempValueStrAndroid: null,
|
||||
characterQuery: null
|
||||
}));
|
||||
} else {
|
||||
setState(prevState => (0, _extends2.default)({}, prevState, {
|
||||
characterQuery: null
|
||||
}));
|
||||
publishValue(fieldValueManager.updateDateInValue(value, activeSection, null));
|
||||
}
|
||||
};
|
||||
const updateValueFromValueStr = valueStr => {
|
||||
const parseDateStr = (dateStr, referenceDate) => {
|
||||
const date = adapter.parse(dateStr, format);
|
||||
if (!adapter.isValid(date)) {
|
||||
return null;
|
||||
}
|
||||
const sections = (0, _buildSectionsFromFormat.buildSectionsFromFormat)({
|
||||
adapter,
|
||||
localeText: translations,
|
||||
localizedDigits,
|
||||
format,
|
||||
date,
|
||||
formatDensity,
|
||||
shouldRespectLeadingZeros,
|
||||
enableAccessibleFieldDOMStructure,
|
||||
isRtl
|
||||
});
|
||||
return (0, _useField.mergeDateIntoReferenceDate)(adapter, date, sections, referenceDate, false);
|
||||
};
|
||||
const newValue = fieldValueManager.parseValueStr(valueStr, state.referenceValue, parseDateStr);
|
||||
publishValue(newValue);
|
||||
};
|
||||
const cleanActiveDateSectionsIfValueNullTimeout = (0, _useTimeout.default)();
|
||||
const updateSectionValue = ({
|
||||
section,
|
||||
newSectionValue,
|
||||
shouldGoToNextSection
|
||||
}) => {
|
||||
updateSectionValueOnNextInvalidDateTimeout.clear();
|
||||
cleanActiveDateSectionsIfValueNullTimeout.clear();
|
||||
const activeDate = fieldValueManager.getDateFromSection(value, section);
|
||||
|
||||
/**
|
||||
* Decide which section should be focused
|
||||
*/
|
||||
if (shouldGoToNextSection && activeSectionIndex < state.sections.length - 1) {
|
||||
setSelectedSections(activeSectionIndex + 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Try to build a valid date from the new section value
|
||||
*/
|
||||
const newSections = setSectionValue(activeSectionIndex, newSectionValue);
|
||||
const newActiveDateSections = fieldValueManager.getDateSectionsFromValue(newSections, section);
|
||||
const newActiveDate = (0, _useField.getDateFromDateSections)(adapter, newActiveDateSections, localizedDigits);
|
||||
|
||||
/**
|
||||
* If the new date is valid,
|
||||
* Then we merge the value of the modified sections into the reference date.
|
||||
* This makes sure that we don't lose some information of the initial date (like the time on a date field).
|
||||
*/
|
||||
if (adapter.isValid(newActiveDate)) {
|
||||
const mergedDate = (0, _useField.mergeDateIntoReferenceDate)(adapter, newActiveDate, newActiveDateSections, fieldValueManager.getDateFromSection(state.referenceValue, section), true);
|
||||
if (activeDate == null) {
|
||||
cleanActiveDateSectionsIfValueNullTimeout.start(0, () => {
|
||||
if (valueRef.current === value) {
|
||||
setState(prevState => (0, _extends2.default)({}, prevState, {
|
||||
sections: fieldValueManager.clearDateSections(state.sections, section),
|
||||
tempValueStrAndroid: null
|
||||
}));
|
||||
}
|
||||
});
|
||||
}
|
||||
return publishValue(fieldValueManager.updateDateInValue(value, section, mergedDate));
|
||||
}
|
||||
|
||||
/**
|
||||
* If all the sections are filled but the date is invalid and the previous date is valid or null,
|
||||
* Then we publish an invalid date.
|
||||
*/
|
||||
if (newActiveDateSections.every(sectionBis => sectionBis.value !== '') && (activeDate == null || adapter.isValid(activeDate))) {
|
||||
setSectionUpdateToApplyOnNextInvalidDate(newSectionValue);
|
||||
return publishValue(fieldValueManager.updateDateInValue(value, section, newActiveDate));
|
||||
}
|
||||
|
||||
/**
|
||||
* If the previous date is not null,
|
||||
* Then we publish the date as `null`.
|
||||
*/
|
||||
if (activeDate != null) {
|
||||
setSectionUpdateToApplyOnNextInvalidDate(newSectionValue);
|
||||
return publishValue(fieldValueManager.updateDateInValue(value, section, null));
|
||||
}
|
||||
|
||||
/**
|
||||
* If the previous date is already null,
|
||||
* Then we don't publish the date and we update the sections.
|
||||
*/
|
||||
return setState(prevState => (0, _extends2.default)({}, prevState, {
|
||||
sections: newSections,
|
||||
tempValueStrAndroid: null
|
||||
}));
|
||||
};
|
||||
const setTempAndroidValueStr = tempValueStrAndroid => setState(prevState => (0, _extends2.default)({}, prevState, {
|
||||
tempValueStrAndroid
|
||||
}));
|
||||
const setCharacterQuery = (0, _useEventCallback.default)(newCharacterQuery => {
|
||||
setState(prevState => (0, _extends2.default)({}, prevState, {
|
||||
characterQuery: newCharacterQuery
|
||||
}));
|
||||
});
|
||||
|
||||
// If `prop.value` changes, we update the state to reflect the new value
|
||||
if (value !== state.lastExternalValue) {
|
||||
let sections;
|
||||
if (sectionToUpdateOnNextInvalidDateRef.current != null && !adapter.isValid(fieldValueManager.getDateFromSection(value, state.sections[sectionToUpdateOnNextInvalidDateRef.current.sectionIndex]))) {
|
||||
sections = setSectionValue(sectionToUpdateOnNextInvalidDateRef.current.sectionIndex, sectionToUpdateOnNextInvalidDateRef.current.value);
|
||||
} else {
|
||||
sections = getSectionsFromValue(value);
|
||||
}
|
||||
setState(prevState => (0, _extends2.default)({}, prevState, {
|
||||
lastExternalValue: value,
|
||||
sections,
|
||||
sectionsDependencies: {
|
||||
format,
|
||||
isRtl,
|
||||
locale: adapter.locale
|
||||
},
|
||||
referenceValue: fieldValueManager.updateReferenceValue(adapter, value, prevState.referenceValue),
|
||||
tempValueStrAndroid: null
|
||||
}));
|
||||
}
|
||||
if (isRtl !== state.lastSectionsDependencies.isRtl || format !== state.lastSectionsDependencies.format || adapter.locale !== state.lastSectionsDependencies.locale) {
|
||||
const sections = getSectionsFromValue(value);
|
||||
(0, _useField.validateSections)(sections, valueType);
|
||||
setState(prevState => (0, _extends2.default)({}, prevState, {
|
||||
lastSectionsDependencies: {
|
||||
format,
|
||||
isRtl,
|
||||
locale: adapter.locale
|
||||
},
|
||||
sections,
|
||||
tempValueStrAndroid: null,
|
||||
characterQuery: null
|
||||
}));
|
||||
}
|
||||
if (state.characterQuery != null && !error && activeSectionIndex == null) {
|
||||
setCharacterQuery(null);
|
||||
}
|
||||
if (state.characterQuery != null && state.sections[state.characterQuery.sectionIndex]?.type !== state.characterQuery.sectionType) {
|
||||
setCharacterQuery(null);
|
||||
}
|
||||
React.useEffect(() => {
|
||||
if (sectionToUpdateOnNextInvalidDateRef.current != null) {
|
||||
sectionToUpdateOnNextInvalidDateRef.current = null;
|
||||
}
|
||||
});
|
||||
const cleanCharacterQueryTimeout = (0, _useTimeout.default)();
|
||||
React.useEffect(() => {
|
||||
if (state.characterQuery != null) {
|
||||
cleanCharacterQueryTimeout.start(QUERY_LIFE_DURATION_MS, () => setCharacterQuery(null));
|
||||
}
|
||||
return () => {};
|
||||
}, [state.characterQuery, setCharacterQuery, cleanCharacterQueryTimeout]);
|
||||
|
||||
// If `tempValueStrAndroid` is still defined for some section when running `useEffect`,
|
||||
// Then `onChange` has only been called once, which means the user pressed `Backspace` to reset the section.
|
||||
// This causes a small flickering on Android,
|
||||
// But we can't use `useEnhancedEffect` which is always called before the second `onChange` call and then would cause false positives.
|
||||
React.useEffect(() => {
|
||||
if (state.tempValueStrAndroid != null && activeSectionIndex != null) {
|
||||
clearActiveSection();
|
||||
}
|
||||
}, [state.sections]); // eslint-disable-line react-hooks/exhaustive-deps
|
||||
|
||||
return {
|
||||
// States and derived states
|
||||
activeSectionIndex,
|
||||
areAllSectionsEmpty,
|
||||
error,
|
||||
localizedDigits,
|
||||
parsedSelectedSections,
|
||||
sectionOrder,
|
||||
sectionsValueBoundaries,
|
||||
state,
|
||||
timezone,
|
||||
value,
|
||||
// Methods to update the states
|
||||
clearValue,
|
||||
clearActiveSection,
|
||||
setCharacterQuery,
|
||||
setSelectedSections,
|
||||
setTempAndroidValueStr,
|
||||
updateSectionValue,
|
||||
updateValueFromValueStr,
|
||||
// Utilities methods
|
||||
getSectionsFromValue
|
||||
};
|
||||
};
|
||||
exports.useFieldState = useFieldState;
|
||||
26
node_modules/@mui/x-date-pickers/internals/hooks/useField/useFieldV6TextField.d.ts
generated
vendored
Normal file
26
node_modules/@mui/x-date-pickers/internals/hooks/useField/useFieldV6TextField.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
import { UseFieldParameters, UseFieldProps, UseFieldReturnValue } from "./useField.types.js";
|
||||
import { InferFieldSection } from "../../../models/index.js";
|
||||
import { PickerValidValue } from "../../models/index.js";
|
||||
export declare const addPositionPropertiesToSections: <TValue extends PickerValidValue>(sections: InferFieldSection<TValue>[], localizedDigits: string[], isRtl: boolean) => FieldSectionWithPositions<TValue>[];
|
||||
export declare const useFieldV6TextField: <TValue extends PickerValidValue, TError, TValidationProps extends {}, TProps extends UseFieldProps<false>>(parameters: UseFieldParameters<TValue, false, TError, TValidationProps, TProps>) => UseFieldReturnValue<false, TProps>;
|
||||
type FieldSectionWithPositions<TValue extends PickerValidValue> = InferFieldSection<TValue> & {
|
||||
/**
|
||||
* Start index of the section in the format
|
||||
*/
|
||||
start: number;
|
||||
/**
|
||||
* End index of the section in the format
|
||||
*/
|
||||
end: number;
|
||||
/**
|
||||
* Start index of the section value in the input.
|
||||
* Takes into account invisible unicode characters such as \u2069 but does not include them
|
||||
*/
|
||||
startInInput: number;
|
||||
/**
|
||||
* End index of the section value in the input.
|
||||
* Takes into account invisible unicode characters such as \u2069 but does not include them
|
||||
*/
|
||||
endInInput: number;
|
||||
};
|
||||
export {};
|
||||
420
node_modules/@mui/x-date-pickers/internals/hooks/useField/useFieldV6TextField.js
generated
vendored
Normal file
420
node_modules/@mui/x-date-pickers/internals/hooks/useField/useFieldV6TextField.js
generated
vendored
Normal file
|
|
@ -0,0 +1,420 @@
|
|||
"use strict";
|
||||
'use client';
|
||||
|
||||
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.useFieldV6TextField = exports.addPositionPropertiesToSections = void 0;
|
||||
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
||||
var React = _interopRequireWildcard(require("react"));
|
||||
var _RtlProvider = require("@mui/system/RtlProvider");
|
||||
var _useEnhancedEffect = _interopRequireDefault(require("@mui/utils/useEnhancedEffect"));
|
||||
var _useEventCallback = _interopRequireDefault(require("@mui/utils/useEventCallback"));
|
||||
var _useTimeout = _interopRequireDefault(require("@mui/utils/useTimeout"));
|
||||
var _useForkRef = _interopRequireDefault(require("@mui/utils/useForkRef"));
|
||||
var _hooks = require("../../../hooks");
|
||||
var _utils = require("../../utils/utils");
|
||||
var _useField = require("./useField.utils");
|
||||
var _useFieldCharacterEditing = require("./useFieldCharacterEditing");
|
||||
var _useFieldRootHandleKeyDown = require("./useFieldRootHandleKeyDown");
|
||||
var _useFieldState = require("./useFieldState");
|
||||
var _useFieldInternalPropsWithDefaults = require("./useFieldInternalPropsWithDefaults");
|
||||
const cleanString = dirtyString => dirtyString.replace(/[\u2066\u2067\u2068\u2069]/g, '');
|
||||
const addPositionPropertiesToSections = (sections, localizedDigits, isRtl) => {
|
||||
let position = 0;
|
||||
let positionInInput = isRtl ? 1 : 0;
|
||||
const newSections = [];
|
||||
for (let i = 0; i < sections.length; i += 1) {
|
||||
const section = sections[i];
|
||||
const renderedValue = (0, _useField.getSectionVisibleValue)(section, isRtl ? 'input-rtl' : 'input-ltr', localizedDigits);
|
||||
const sectionStr = `${section.startSeparator}${renderedValue}${section.endSeparator}`;
|
||||
const sectionLength = cleanString(sectionStr).length;
|
||||
const sectionLengthInInput = sectionStr.length;
|
||||
|
||||
// The ...InInput values consider the unicode characters but do include them in their indexes
|
||||
const cleanedValue = cleanString(renderedValue);
|
||||
const startInInput = positionInInput + (cleanedValue === '' ? 0 : renderedValue.indexOf(cleanedValue[0])) + section.startSeparator.length;
|
||||
const endInInput = startInInput + cleanedValue.length;
|
||||
newSections.push((0, _extends2.default)({}, section, {
|
||||
start: position,
|
||||
end: position + sectionLength,
|
||||
startInInput,
|
||||
endInInput
|
||||
}));
|
||||
position += sectionLength;
|
||||
// Move position to the end of string associated to the current section
|
||||
positionInInput += sectionLengthInInput;
|
||||
}
|
||||
return newSections;
|
||||
};
|
||||
exports.addPositionPropertiesToSections = addPositionPropertiesToSections;
|
||||
const useFieldV6TextField = parameters => {
|
||||
const isRtl = (0, _RtlProvider.useRtl)();
|
||||
const focusTimeout = (0, _useTimeout.default)();
|
||||
const selectionSyncTimeout = (0, _useTimeout.default)();
|
||||
const {
|
||||
props,
|
||||
manager,
|
||||
skipContextFieldRefAssignment,
|
||||
manager: {
|
||||
valueType,
|
||||
internal_valueManager: valueManager,
|
||||
internal_fieldValueManager: fieldValueManager,
|
||||
internal_useOpenPickerButtonAriaLabel: useOpenPickerButtonAriaLabel
|
||||
}
|
||||
} = parameters;
|
||||
const {
|
||||
internalProps,
|
||||
forwardedProps
|
||||
} = (0, _hooks.useSplitFieldProps)(props, valueType);
|
||||
const internalPropsWithDefaults = (0, _useFieldInternalPropsWithDefaults.useFieldInternalPropsWithDefaults)({
|
||||
manager,
|
||||
internalProps,
|
||||
skipContextFieldRefAssignment
|
||||
});
|
||||
const {
|
||||
onFocus,
|
||||
onClick,
|
||||
onPaste,
|
||||
onBlur,
|
||||
onKeyDown,
|
||||
onClear,
|
||||
clearable,
|
||||
inputRef: inputRefProp,
|
||||
placeholder: inPlaceholder
|
||||
} = forwardedProps;
|
||||
const {
|
||||
readOnly = false,
|
||||
disabled = false,
|
||||
autoFocus = false,
|
||||
focused,
|
||||
unstableFieldRef
|
||||
} = internalPropsWithDefaults;
|
||||
const inputRef = React.useRef(null);
|
||||
const handleRef = (0, _useForkRef.default)(inputRefProp, inputRef);
|
||||
const stateResponse = (0, _useFieldState.useFieldState)({
|
||||
manager,
|
||||
internalPropsWithDefaults,
|
||||
forwardedProps
|
||||
});
|
||||
const {
|
||||
// States and derived states
|
||||
activeSectionIndex,
|
||||
areAllSectionsEmpty,
|
||||
error,
|
||||
localizedDigits,
|
||||
parsedSelectedSections,
|
||||
sectionOrder,
|
||||
state,
|
||||
value,
|
||||
// Methods to update the states
|
||||
clearValue,
|
||||
clearActiveSection,
|
||||
setCharacterQuery,
|
||||
setSelectedSections,
|
||||
setTempAndroidValueStr,
|
||||
updateSectionValue,
|
||||
updateValueFromValueStr,
|
||||
// Utilities methods
|
||||
getSectionsFromValue
|
||||
} = stateResponse;
|
||||
const applyCharacterEditing = (0, _useFieldCharacterEditing.useFieldCharacterEditing)({
|
||||
stateResponse
|
||||
});
|
||||
const openPickerAriaLabel = useOpenPickerButtonAriaLabel(value);
|
||||
const sections = React.useMemo(() => addPositionPropertiesToSections(state.sections, localizedDigits, isRtl), [state.sections, localizedDigits, isRtl]);
|
||||
function syncSelectionFromDOM() {
|
||||
const browserStartIndex = inputRef.current.selectionStart ?? 0;
|
||||
let nextSectionIndex;
|
||||
if (browserStartIndex <= sections[0].startInInput) {
|
||||
// Special case if browser index is in invisible characters at the beginning
|
||||
nextSectionIndex = 1;
|
||||
} else if (browserStartIndex >= sections[sections.length - 1].endInInput) {
|
||||
// If the click is after the last character of the input, then we want to select the 1st section.
|
||||
nextSectionIndex = 1;
|
||||
} else {
|
||||
nextSectionIndex = sections.findIndex(section => section.startInInput - section.startSeparator.length > browserStartIndex);
|
||||
}
|
||||
const sectionIndex = nextSectionIndex === -1 ? sections.length - 1 : nextSectionIndex - 1;
|
||||
setSelectedSections(sectionIndex);
|
||||
}
|
||||
function focusField(newSelectedSection = 0) {
|
||||
if ((0, _utils.getActiveElement)(inputRef.current) === inputRef.current) {
|
||||
return;
|
||||
}
|
||||
inputRef.current?.focus();
|
||||
setSelectedSections(newSelectedSection);
|
||||
}
|
||||
const handleInputFocus = (0, _useEventCallback.default)(event => {
|
||||
onFocus?.(event);
|
||||
// The ref is guaranteed to be resolved at this point.
|
||||
const input = inputRef.current;
|
||||
focusTimeout.start(0, () => {
|
||||
// The ref changed, the component got remounted, the focus event is no longer relevant.
|
||||
if (!input || input !== inputRef.current) {
|
||||
return;
|
||||
}
|
||||
if (activeSectionIndex != null) {
|
||||
return;
|
||||
}
|
||||
if (
|
||||
// avoid selecting all sections when focusing empty field without value
|
||||
input.value.length && Number(input.selectionEnd) - Number(input.selectionStart) === input.value.length) {
|
||||
setSelectedSections('all');
|
||||
} else {
|
||||
syncSelectionFromDOM();
|
||||
}
|
||||
});
|
||||
});
|
||||
const handleInputClick = (0, _useEventCallback.default)((event, ...args) => {
|
||||
// The click event on the clear button would propagate to the input, trigger this handler and result in a wrong section selection.
|
||||
// We avoid this by checking if the call of `handleInputClick` is actually intended, or a side effect.
|
||||
if (event.isDefaultPrevented()) {
|
||||
return;
|
||||
}
|
||||
onClick?.(event, ...args);
|
||||
syncSelectionFromDOM();
|
||||
});
|
||||
const handleInputPaste = (0, _useEventCallback.default)(event => {
|
||||
onPaste?.(event);
|
||||
|
||||
// prevent default to avoid the input `onChange` handler being called
|
||||
event.preventDefault();
|
||||
if (readOnly || disabled) {
|
||||
return;
|
||||
}
|
||||
const pastedValue = event.clipboardData.getData('text');
|
||||
if (typeof parsedSelectedSections === 'number') {
|
||||
const activeSection = state.sections[parsedSelectedSections];
|
||||
const lettersOnly = /^[a-zA-Z]+$/.test(pastedValue);
|
||||
const digitsOnly = /^[0-9]+$/.test(pastedValue);
|
||||
const digitsAndLetterOnly = /^(([a-zA-Z]+)|)([0-9]+)(([a-zA-Z]+)|)$/.test(pastedValue);
|
||||
const isValidPastedValue = activeSection.contentType === 'letter' && lettersOnly || activeSection.contentType === 'digit' && digitsOnly || activeSection.contentType === 'digit-with-letter' && digitsAndLetterOnly;
|
||||
if (isValidPastedValue) {
|
||||
setCharacterQuery(null);
|
||||
updateSectionValue({
|
||||
section: activeSection,
|
||||
newSectionValue: pastedValue,
|
||||
shouldGoToNextSection: true
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (lettersOnly || digitsOnly) {
|
||||
// The pasted value corresponds to a single section, but not the expected type,
|
||||
// skip the modification
|
||||
return;
|
||||
}
|
||||
}
|
||||
setCharacterQuery(null);
|
||||
updateValueFromValueStr(pastedValue);
|
||||
});
|
||||
const handleContainerBlur = (0, _useEventCallback.default)(event => {
|
||||
onBlur?.(event);
|
||||
setSelectedSections(null);
|
||||
});
|
||||
const handleInputChange = (0, _useEventCallback.default)(event => {
|
||||
if (readOnly) {
|
||||
return;
|
||||
}
|
||||
const targetValue = event.target.value;
|
||||
if (targetValue === '') {
|
||||
clearValue();
|
||||
return;
|
||||
}
|
||||
const eventData = event.nativeEvent.data;
|
||||
// Calling `.fill(04/11/2022)` in playwright will trigger a change event with the requested content to insert in `event.nativeEvent.data`
|
||||
// usual changes have only the currently typed character in the `event.nativeEvent.data`
|
||||
const shouldUseEventData = eventData && eventData.length > 1;
|
||||
const valueStr = shouldUseEventData ? eventData : targetValue;
|
||||
const cleanValueStr = cleanString(valueStr);
|
||||
if (parsedSelectedSections === 'all') {
|
||||
setSelectedSections(activeSectionIndex);
|
||||
}
|
||||
|
||||
// If no section is selected or eventData should be used, we just try to parse the new value
|
||||
// This line is mostly triggered by imperative code / application tests.
|
||||
if (activeSectionIndex == null || shouldUseEventData) {
|
||||
updateValueFromValueStr(shouldUseEventData ? eventData : cleanValueStr);
|
||||
return;
|
||||
}
|
||||
let keyPressed;
|
||||
if (parsedSelectedSections === 'all' && cleanValueStr.length === 1) {
|
||||
keyPressed = cleanValueStr;
|
||||
} else {
|
||||
const prevValueStr = cleanString(fieldValueManager.getV6InputValueFromSections(sections, localizedDigits, isRtl));
|
||||
let startOfDiffIndex = -1;
|
||||
let endOfDiffIndex = -1;
|
||||
for (let i = 0; i < prevValueStr.length; i += 1) {
|
||||
if (startOfDiffIndex === -1 && prevValueStr[i] !== cleanValueStr[i]) {
|
||||
startOfDiffIndex = i;
|
||||
}
|
||||
if (endOfDiffIndex === -1 && prevValueStr[prevValueStr.length - i - 1] !== cleanValueStr[cleanValueStr.length - i - 1]) {
|
||||
endOfDiffIndex = i;
|
||||
}
|
||||
}
|
||||
const activeSection = sections[activeSectionIndex];
|
||||
const hasDiffOutsideOfActiveSection = startOfDiffIndex < activeSection.start || prevValueStr.length - endOfDiffIndex - 1 > activeSection.end;
|
||||
if (hasDiffOutsideOfActiveSection) {
|
||||
// TODO: Support if the new date is valid
|
||||
return;
|
||||
}
|
||||
|
||||
// The active section being selected, the browser has replaced its value with the key pressed by the user.
|
||||
const activeSectionEndRelativeToNewValue = cleanValueStr.length - prevValueStr.length + activeSection.end - cleanString(activeSection.endSeparator || '').length;
|
||||
keyPressed = cleanValueStr.slice(activeSection.start + cleanString(activeSection.startSeparator || '').length, activeSectionEndRelativeToNewValue);
|
||||
}
|
||||
if (keyPressed.length === 0) {
|
||||
if ((0, _useField.isAndroid)()) {
|
||||
setTempAndroidValueStr(valueStr);
|
||||
}
|
||||
clearActiveSection();
|
||||
return;
|
||||
}
|
||||
applyCharacterEditing({
|
||||
keyPressed,
|
||||
sectionIndex: activeSectionIndex
|
||||
});
|
||||
});
|
||||
const handleClear = (0, _useEventCallback.default)((event, ...args) => {
|
||||
event.preventDefault();
|
||||
onClear?.(event, ...args);
|
||||
clearValue();
|
||||
if (!isFieldFocused(inputRef)) {
|
||||
// setSelectedSections is called internally
|
||||
focusField(0);
|
||||
} else {
|
||||
setSelectedSections(sectionOrder.startIndex);
|
||||
}
|
||||
});
|
||||
const handleContainerKeyDown = (0, _useFieldRootHandleKeyDown.useFieldRootHandleKeyDown)({
|
||||
manager,
|
||||
internalPropsWithDefaults,
|
||||
stateResponse
|
||||
});
|
||||
const wrappedHandleContainerKeyDown = (0, _useEventCallback.default)(event => {
|
||||
onKeyDown?.(event);
|
||||
handleContainerKeyDown(event);
|
||||
});
|
||||
const placeholder = React.useMemo(() => {
|
||||
if (inPlaceholder !== undefined) {
|
||||
return inPlaceholder;
|
||||
}
|
||||
return fieldValueManager.getV6InputValueFromSections(getSectionsFromValue(valueManager.emptyValue), localizedDigits, isRtl);
|
||||
}, [inPlaceholder, fieldValueManager, getSectionsFromValue, valueManager.emptyValue, localizedDigits, isRtl]);
|
||||
const valueStr = React.useMemo(() => state.tempValueStrAndroid ?? fieldValueManager.getV6InputValueFromSections(state.sections, localizedDigits, isRtl), [state.sections, fieldValueManager, state.tempValueStrAndroid, localizedDigits, isRtl]);
|
||||
React.useEffect(() => {
|
||||
// Select all the sections when focused on mount (`autoFocus = true` on the input)
|
||||
if (inputRef.current && inputRef.current === (0, _utils.getActiveElement)(inputRef.current)) {
|
||||
setSelectedSections('all');
|
||||
}
|
||||
}, []); // eslint-disable-line react-hooks/exhaustive-deps
|
||||
|
||||
(0, _useEnhancedEffect.default)(() => {
|
||||
function syncSelectionToDOM() {
|
||||
if (!inputRef.current) {
|
||||
return;
|
||||
}
|
||||
if (parsedSelectedSections == null) {
|
||||
if (inputRef.current.scrollLeft) {
|
||||
// Ensure that input content is not marked as selected.
|
||||
// setting selection range to 0 causes issues in Safari.
|
||||
// https://bugs.webkit.org/show_bug.cgi?id=224425
|
||||
inputRef.current.scrollLeft = 0;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// On multi input range pickers we want to update selection range only for the active input
|
||||
// This helps to avoid the focus jumping on Safari https://github.com/mui/mui-x/issues/9003
|
||||
// because WebKit implements the `setSelectionRange` based on the spec: https://bugs.webkit.org/show_bug.cgi?id=224425
|
||||
if (inputRef.current !== (0, _utils.getActiveElement)(inputRef.current)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Fix scroll jumping on iOS browser: https://github.com/mui/mui-x/issues/8321
|
||||
const currentScrollTop = inputRef.current.scrollTop;
|
||||
if (parsedSelectedSections === 'all') {
|
||||
inputRef.current.select();
|
||||
} else {
|
||||
const selectedSection = sections[parsedSelectedSections];
|
||||
const selectionStart = selectedSection.type === 'empty' ? selectedSection.startInInput - selectedSection.startSeparator.length : selectedSection.startInInput;
|
||||
const selectionEnd = selectedSection.type === 'empty' ? selectedSection.endInInput + selectedSection.endSeparator.length : selectedSection.endInInput;
|
||||
if (selectionStart !== inputRef.current.selectionStart || selectionEnd !== inputRef.current.selectionEnd) {
|
||||
if (inputRef.current === (0, _utils.getActiveElement)(inputRef.current)) {
|
||||
inputRef.current.setSelectionRange(selectionStart, selectionEnd);
|
||||
}
|
||||
}
|
||||
selectionSyncTimeout.start(0, () => {
|
||||
// handle case when the selection is not updated correctly
|
||||
// could happen on Android
|
||||
if (inputRef.current && inputRef.current === (0, _utils.getActiveElement)(inputRef.current) &&
|
||||
// The section might loose all selection, where `selectionStart === selectionEnd`
|
||||
// https://github.com/mui/mui-x/pull/13652
|
||||
inputRef.current.selectionStart === inputRef.current.selectionEnd && (inputRef.current.selectionStart !== selectionStart || inputRef.current.selectionEnd !== selectionEnd)) {
|
||||
syncSelectionToDOM();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Even reading this variable seems to do the trick, but also setting it just to make use of it
|
||||
inputRef.current.scrollTop = currentScrollTop;
|
||||
}
|
||||
syncSelectionToDOM();
|
||||
});
|
||||
const inputMode = React.useMemo(() => {
|
||||
if (activeSectionIndex == null) {
|
||||
return 'text';
|
||||
}
|
||||
if (state.sections[activeSectionIndex].contentType === 'letter') {
|
||||
return 'text';
|
||||
}
|
||||
return 'numeric';
|
||||
}, [activeSectionIndex, state.sections]);
|
||||
const inputHasFocus = inputRef.current && inputRef.current === (0, _utils.getActiveElement)(inputRef.current);
|
||||
const shouldShowPlaceholder = !inputHasFocus && areAllSectionsEmpty;
|
||||
React.useImperativeHandle(unstableFieldRef, () => ({
|
||||
getSections: () => state.sections,
|
||||
getActiveSectionIndex: () => {
|
||||
const browserStartIndex = inputRef.current.selectionStart ?? 0;
|
||||
const browserEndIndex = inputRef.current.selectionEnd ?? 0;
|
||||
if (browserStartIndex === 0 && browserEndIndex === 0) {
|
||||
return null;
|
||||
}
|
||||
const nextSectionIndex = browserStartIndex <= sections[0].startInInput ? 1 // Special case if browser index is in invisible characters at the beginning.
|
||||
: sections.findIndex(section => section.startInInput - section.startSeparator.length > browserStartIndex);
|
||||
return nextSectionIndex === -1 ? sections.length - 1 : nextSectionIndex - 1;
|
||||
},
|
||||
setSelectedSections: newSelectedSections => setSelectedSections(newSelectedSections),
|
||||
focusField,
|
||||
isFieldFocused: () => isFieldFocused(inputRef)
|
||||
}));
|
||||
return (0, _extends2.default)({}, forwardedProps, {
|
||||
error,
|
||||
clearable: Boolean(clearable && !areAllSectionsEmpty && !readOnly && !disabled),
|
||||
onBlur: handleContainerBlur,
|
||||
onClick: handleInputClick,
|
||||
onFocus: handleInputFocus,
|
||||
onPaste: handleInputPaste,
|
||||
onKeyDown: wrappedHandleContainerKeyDown,
|
||||
onClear: handleClear,
|
||||
inputRef: handleRef,
|
||||
// Additional
|
||||
enableAccessibleFieldDOMStructure: false,
|
||||
placeholder,
|
||||
inputMode,
|
||||
autoComplete: 'off',
|
||||
value: shouldShowPlaceholder ? '' : valueStr,
|
||||
onChange: handleInputChange,
|
||||
focused,
|
||||
disabled,
|
||||
readOnly,
|
||||
autoFocus,
|
||||
openPickerAriaLabel
|
||||
});
|
||||
};
|
||||
exports.useFieldV6TextField = useFieldV6TextField;
|
||||
function isFieldFocused(inputRef) {
|
||||
return inputRef.current === (0, _utils.getActiveElement)(inputRef.current);
|
||||
}
|
||||
3
node_modules/@mui/x-date-pickers/internals/hooks/useField/useFieldV7TextField.d.ts
generated
vendored
Normal file
3
node_modules/@mui/x-date-pickers/internals/hooks/useField/useFieldV7TextField.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
import { UseFieldParameters, UseFieldProps, UseFieldReturnValue } from "./useField.types.js";
|
||||
import { PickerValidValue } from "../../models/index.js";
|
||||
export declare const useFieldV7TextField: <TValue extends PickerValidValue, TError, TValidationProps extends {}, TProps extends UseFieldProps<true>>(parameters: UseFieldParameters<TValue, true, TError, TValidationProps, TProps>) => UseFieldReturnValue<true, TProps>;
|
||||
263
node_modules/@mui/x-date-pickers/internals/hooks/useField/useFieldV7TextField.js
generated
vendored
Normal file
263
node_modules/@mui/x-date-pickers/internals/hooks/useField/useFieldV7TextField.js
generated
vendored
Normal file
|
|
@ -0,0 +1,263 @@
|
|||
"use strict";
|
||||
'use client';
|
||||
|
||||
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.useFieldV7TextField = void 0;
|
||||
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
||||
var React = _interopRequireWildcard(require("react"));
|
||||
var _useForkRef = _interopRequireDefault(require("@mui/utils/useForkRef"));
|
||||
var _useEventCallback = _interopRequireDefault(require("@mui/utils/useEventCallback"));
|
||||
var _useEnhancedEffect = _interopRequireDefault(require("@mui/utils/useEnhancedEffect"));
|
||||
var _useField = require("./useField.utils");
|
||||
var _utils = require("../../utils/utils");
|
||||
var _hooks = require("../../../hooks");
|
||||
var _useFieldCharacterEditing = require("./useFieldCharacterEditing");
|
||||
var _useFieldState = require("./useFieldState");
|
||||
var _useFieldInternalPropsWithDefaults = require("./useFieldInternalPropsWithDefaults");
|
||||
var _syncSelectionToDOM = require("./syncSelectionToDOM");
|
||||
var _useFieldRootProps = require("./useFieldRootProps");
|
||||
var _useFieldHiddenInputProps = require("./useFieldHiddenInputProps");
|
||||
var _useFieldSectionContainerProps = require("./useFieldSectionContainerProps");
|
||||
var _useFieldSectionContentProps = require("./useFieldSectionContentProps");
|
||||
const useFieldV7TextField = parameters => {
|
||||
const {
|
||||
props,
|
||||
manager,
|
||||
skipContextFieldRefAssignment,
|
||||
manager: {
|
||||
valueType,
|
||||
internal_useOpenPickerButtonAriaLabel: useOpenPickerButtonAriaLabel
|
||||
}
|
||||
} = parameters;
|
||||
const {
|
||||
internalProps,
|
||||
forwardedProps
|
||||
} = (0, _hooks.useSplitFieldProps)(props, valueType);
|
||||
const internalPropsWithDefaults = (0, _useFieldInternalPropsWithDefaults.useFieldInternalPropsWithDefaults)({
|
||||
manager,
|
||||
internalProps,
|
||||
skipContextFieldRefAssignment
|
||||
});
|
||||
const {
|
||||
sectionListRef: sectionListRefProp,
|
||||
onBlur,
|
||||
onClick,
|
||||
onFocus,
|
||||
onInput,
|
||||
onPaste,
|
||||
onKeyDown,
|
||||
onClear,
|
||||
clearable
|
||||
} = forwardedProps;
|
||||
const {
|
||||
disabled = false,
|
||||
readOnly = false,
|
||||
autoFocus = false,
|
||||
focused: focusedProp,
|
||||
unstableFieldRef
|
||||
} = internalPropsWithDefaults;
|
||||
const sectionListRef = React.useRef(null);
|
||||
const handleSectionListRef = (0, _useForkRef.default)(sectionListRefProp, sectionListRef);
|
||||
const domGetters = React.useMemo(() => ({
|
||||
isReady: () => sectionListRef.current != null,
|
||||
getRoot: () => sectionListRef.current.getRoot(),
|
||||
getSectionContainer: sectionIndex => sectionListRef.current.getSectionContainer(sectionIndex),
|
||||
getSectionContent: sectionIndex => sectionListRef.current.getSectionContent(sectionIndex),
|
||||
getSectionIndexFromDOMElement: element => sectionListRef.current.getSectionIndexFromDOMElement(element)
|
||||
}), [sectionListRef]);
|
||||
const stateResponse = (0, _useFieldState.useFieldState)({
|
||||
manager,
|
||||
internalPropsWithDefaults,
|
||||
forwardedProps
|
||||
});
|
||||
const {
|
||||
// States and derived states
|
||||
areAllSectionsEmpty,
|
||||
error,
|
||||
parsedSelectedSections,
|
||||
sectionOrder,
|
||||
state,
|
||||
value,
|
||||
// Methods to update the states
|
||||
clearValue,
|
||||
setSelectedSections
|
||||
} = stateResponse;
|
||||
const applyCharacterEditing = (0, _useFieldCharacterEditing.useFieldCharacterEditing)({
|
||||
stateResponse
|
||||
});
|
||||
const openPickerAriaLabel = useOpenPickerButtonAriaLabel(value);
|
||||
const [focused, setFocused] = React.useState(false);
|
||||
function focusField(newSelectedSections = 0) {
|
||||
if (disabled || !sectionListRef.current ||
|
||||
// if the field is already focused, we don't need to focus it again
|
||||
getActiveSectionIndex(sectionListRef) != null) {
|
||||
return;
|
||||
}
|
||||
const newParsedSelectedSections = (0, _useField.parseSelectedSections)(newSelectedSections, state.sections);
|
||||
setFocused(true);
|
||||
sectionListRef.current.getSectionContent(newParsedSelectedSections).focus();
|
||||
}
|
||||
const rootProps = (0, _useFieldRootProps.useFieldRootProps)({
|
||||
manager,
|
||||
internalPropsWithDefaults,
|
||||
stateResponse,
|
||||
applyCharacterEditing,
|
||||
focused,
|
||||
setFocused,
|
||||
domGetters
|
||||
});
|
||||
const hiddenInputProps = (0, _useFieldHiddenInputProps.useFieldHiddenInputProps)({
|
||||
manager,
|
||||
stateResponse
|
||||
});
|
||||
const createSectionContainerProps = (0, _useFieldSectionContainerProps.useFieldSectionContainerProps)({
|
||||
stateResponse,
|
||||
internalPropsWithDefaults
|
||||
});
|
||||
const createSectionContentProps = (0, _useFieldSectionContentProps.useFieldSectionContentProps)({
|
||||
manager,
|
||||
stateResponse,
|
||||
applyCharacterEditing,
|
||||
internalPropsWithDefaults,
|
||||
domGetters,
|
||||
focused
|
||||
});
|
||||
const handleRootKeyDown = (0, _useEventCallback.default)(event => {
|
||||
onKeyDown?.(event);
|
||||
rootProps.onKeyDown(event);
|
||||
});
|
||||
const handleRootBlur = (0, _useEventCallback.default)(event => {
|
||||
onBlur?.(event);
|
||||
rootProps.onBlur(event);
|
||||
});
|
||||
const handleRootFocus = (0, _useEventCallback.default)(event => {
|
||||
onFocus?.(event);
|
||||
rootProps.onFocus(event);
|
||||
});
|
||||
const handleRootClick = (0, _useEventCallback.default)(event => {
|
||||
// The click event on the clear or open button would propagate to the input, trigger this handler and result in an inadvertent section selection.
|
||||
// We avoid this by checking if the call of `handleInputClick` is actually intended, or a propagated call, which should be skipped.
|
||||
if (event.isDefaultPrevented()) {
|
||||
return;
|
||||
}
|
||||
onClick?.(event);
|
||||
rootProps.onClick(event);
|
||||
});
|
||||
const handleRootPaste = (0, _useEventCallback.default)(event => {
|
||||
onPaste?.(event);
|
||||
rootProps.onPaste(event);
|
||||
});
|
||||
const handleRootInput = (0, _useEventCallback.default)(event => {
|
||||
onInput?.(event);
|
||||
rootProps.onInput(event);
|
||||
});
|
||||
const handleClear = (0, _useEventCallback.default)((event, ...args) => {
|
||||
event.preventDefault();
|
||||
onClear?.(event, ...args);
|
||||
clearValue();
|
||||
if (!isFieldFocused(sectionListRef)) {
|
||||
// setSelectedSections is called internally
|
||||
focusField(0);
|
||||
} else {
|
||||
setSelectedSections(sectionOrder.startIndex);
|
||||
}
|
||||
});
|
||||
const elements = React.useMemo(() => {
|
||||
return state.sections.map((section, sectionIndex) => {
|
||||
const content = createSectionContentProps(section, sectionIndex);
|
||||
return {
|
||||
container: createSectionContainerProps(sectionIndex),
|
||||
content: createSectionContentProps(section, sectionIndex),
|
||||
before: {
|
||||
children: section.startSeparator
|
||||
},
|
||||
after: {
|
||||
children: section.endSeparator,
|
||||
'data-range-position': section.isEndFormatSeparator ? content['data-range-position'] : undefined
|
||||
}
|
||||
};
|
||||
});
|
||||
}, [state.sections, createSectionContainerProps, createSectionContentProps]);
|
||||
React.useEffect(() => {
|
||||
if (sectionListRef.current == null) {
|
||||
throw new Error(['MUI X: The `sectionListRef` prop has not been initialized by `PickersSectionList`', 'You probably tried to pass a component to the `textField` slot that contains an `<input />` element instead of a `PickersSectionList`.', '', 'If you want to keep using an `<input />` HTML element for the editing, please add the `enableAccessibleFieldDOMStructure={false}` prop to your Picker or Field component:', '', '<DatePicker enableAccessibleFieldDOMStructure={false} slots={{ textField: MyCustomTextField }} />', '', 'Learn more about the field accessible DOM structure on the MUI documentation: https://mui.com/x/react-date-pickers/fields/#fields-to-edit-a-single-element'].join('\n'));
|
||||
}
|
||||
if (autoFocus && !disabled && sectionListRef.current) {
|
||||
sectionListRef.current.getSectionContent(sectionOrder.startIndex).focus();
|
||||
}
|
||||
}, []); // eslint-disable-line react-hooks/exhaustive-deps
|
||||
|
||||
(0, _useEnhancedEffect.default)(() => {
|
||||
if (!focused || !sectionListRef.current) {
|
||||
return;
|
||||
}
|
||||
if (parsedSelectedSections === 'all') {
|
||||
sectionListRef.current.getRoot().focus();
|
||||
} else if (typeof parsedSelectedSections === 'number') {
|
||||
const domElement = sectionListRef.current.getSectionContent(parsedSelectedSections);
|
||||
if (domElement) {
|
||||
domElement.focus();
|
||||
}
|
||||
}
|
||||
}, [parsedSelectedSections, focused]);
|
||||
(0, _useEnhancedEffect.default)(() => {
|
||||
(0, _syncSelectionToDOM.syncSelectionToDOM)({
|
||||
focused,
|
||||
domGetters,
|
||||
stateResponse
|
||||
});
|
||||
});
|
||||
React.useImperativeHandle(unstableFieldRef, () => ({
|
||||
getSections: () => state.sections,
|
||||
getActiveSectionIndex: () => getActiveSectionIndex(sectionListRef),
|
||||
setSelectedSections: newSelectedSections => {
|
||||
if (disabled || !sectionListRef.current) {
|
||||
return;
|
||||
}
|
||||
const newParsedSelectedSections = (0, _useField.parseSelectedSections)(newSelectedSections, state.sections);
|
||||
const newActiveSectionIndex = newParsedSelectedSections === 'all' ? 0 : newParsedSelectedSections;
|
||||
setFocused(newActiveSectionIndex !== null);
|
||||
setSelectedSections(newSelectedSections);
|
||||
},
|
||||
focusField,
|
||||
isFieldFocused: () => isFieldFocused(sectionListRef)
|
||||
}));
|
||||
return (0, _extends2.default)({}, forwardedProps, rootProps, {
|
||||
onBlur: handleRootBlur,
|
||||
onClick: handleRootClick,
|
||||
onFocus: handleRootFocus,
|
||||
onInput: handleRootInput,
|
||||
onPaste: handleRootPaste,
|
||||
onKeyDown: handleRootKeyDown,
|
||||
onClear: handleClear
|
||||
}, hiddenInputProps, {
|
||||
error,
|
||||
clearable: Boolean(clearable && !areAllSectionsEmpty && !readOnly && !disabled),
|
||||
focused: focusedProp ?? focused,
|
||||
sectionListRef: handleSectionListRef,
|
||||
// Additional
|
||||
enableAccessibleFieldDOMStructure: true,
|
||||
elements,
|
||||
areAllSectionsEmpty,
|
||||
disabled,
|
||||
readOnly,
|
||||
autoFocus,
|
||||
openPickerAriaLabel
|
||||
});
|
||||
};
|
||||
exports.useFieldV7TextField = useFieldV7TextField;
|
||||
function getActiveSectionIndex(sectionListRef) {
|
||||
const activeElement = (0, _utils.getActiveElement)(sectionListRef.current?.getRoot());
|
||||
if (!activeElement || !sectionListRef.current || !sectionListRef.current.getRoot().contains(activeElement)) {
|
||||
return null;
|
||||
}
|
||||
return sectionListRef.current.getSectionIndexFromDOMElement(activeElement);
|
||||
}
|
||||
function isFieldFocused(sectionListRef) {
|
||||
const activeElement = (0, _utils.getActiveElement)(sectionListRef.current?.getRoot());
|
||||
return !!sectionListRef.current && sectionListRef.current.getRoot().contains(activeElement);
|
||||
}
|
||||
6
node_modules/@mui/x-date-pickers/internals/hooks/useFieldOwnerState.d.ts
generated
vendored
Normal file
6
node_modules/@mui/x-date-pickers/internals/hooks/useFieldOwnerState.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
import { FieldOwnerState } from "../../models/index.js";
|
||||
import { FormProps } from "../models/index.js";
|
||||
export declare function useFieldOwnerState(parameters: UseFieldOwnerStateParameters): FieldOwnerState;
|
||||
export interface UseFieldOwnerStateParameters extends FormProps {
|
||||
required?: boolean;
|
||||
}
|
||||
24
node_modules/@mui/x-date-pickers/internals/hooks/useFieldOwnerState.js
generated
vendored
Normal file
24
node_modules/@mui/x-date-pickers/internals/hooks/useFieldOwnerState.js
generated
vendored
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
"use strict";
|
||||
|
||||
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.useFieldOwnerState = useFieldOwnerState;
|
||||
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
||||
var React = _interopRequireWildcard(require("react"));
|
||||
var _RtlProvider = require("@mui/system/RtlProvider");
|
||||
var _usePickerPrivateContext = require("./usePickerPrivateContext");
|
||||
function useFieldOwnerState(parameters) {
|
||||
const {
|
||||
ownerState: pickerOwnerState
|
||||
} = (0, _usePickerPrivateContext.usePickerPrivateContext)();
|
||||
const isRtl = (0, _RtlProvider.useRtl)();
|
||||
return React.useMemo(() => (0, _extends2.default)({}, pickerOwnerState, {
|
||||
isFieldDisabled: parameters.disabled ?? false,
|
||||
isFieldReadOnly: parameters.readOnly ?? false,
|
||||
isFieldRequired: parameters.required ?? false,
|
||||
fieldDirection: isRtl ? 'rtl' : 'ltr'
|
||||
}), [pickerOwnerState, parameters.disabled, parameters.readOnly, parameters.required, isRtl]);
|
||||
}
|
||||
2
node_modules/@mui/x-date-pickers/internals/hooks/useMobilePicker/index.d.ts
generated
vendored
Normal file
2
node_modules/@mui/x-date-pickers/internals/hooks/useMobilePicker/index.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
export { useMobilePicker } from "./useMobilePicker.js";
|
||||
export type { UseMobilePickerSlots, UseMobilePickerSlotProps, ExportedUseMobilePickerSlotProps, MobileOnlyPickerProps } from "./useMobilePicker.types.js";
|
||||
12
node_modules/@mui/x-date-pickers/internals/hooks/useMobilePicker/index.js
generated
vendored
Normal file
12
node_modules/@mui/x-date-pickers/internals/hooks/useMobilePicker/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "useMobilePicker", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _useMobilePicker.useMobilePicker;
|
||||
}
|
||||
});
|
||||
var _useMobilePicker = require("./useMobilePicker");
|
||||
16
node_modules/@mui/x-date-pickers/internals/hooks/useMobilePicker/useMobilePicker.d.ts
generated
vendored
Normal file
16
node_modules/@mui/x-date-pickers/internals/hooks/useMobilePicker/useMobilePicker.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
import * as React from 'react';
|
||||
import { UseMobilePickerParams, UseMobilePickerProps } from "./useMobilePicker.types.js";
|
||||
import { DateOrTimeViewWithMeridiem } from "../../models/index.js";
|
||||
/**
|
||||
* Hook managing all the single-date mobile pickers:
|
||||
* - MobileDatePicker
|
||||
* - MobileDateTimePicker
|
||||
* - MobileTimePicker
|
||||
*/
|
||||
export declare const useMobilePicker: <TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean, TExternalProps extends UseMobilePickerProps<TView, TEnableAccessibleFieldDOMStructure, any, TExternalProps>>({
|
||||
props,
|
||||
steps,
|
||||
...pickerParams
|
||||
}: UseMobilePickerParams<TView, TEnableAccessibleFieldDOMStructure, TExternalProps>) => {
|
||||
renderPicker: () => React.JSX.Element;
|
||||
};
|
||||
106
node_modules/@mui/x-date-pickers/internals/hooks/useMobilePicker/useMobilePicker.js
generated
vendored
Normal file
106
node_modules/@mui/x-date-pickers/internals/hooks/useMobilePicker/useMobilePicker.js
generated
vendored
Normal file
|
|
@ -0,0 +1,106 @@
|
|||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
||||
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.useMobilePicker = void 0;
|
||||
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
||||
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
||||
var React = _interopRequireWildcard(require("react"));
|
||||
var _useSlotProps2 = _interopRequireDefault(require("@mui/utils/useSlotProps"));
|
||||
var _PickersModalDialog = require("../../components/PickersModalDialog");
|
||||
var _usePicker = require("../usePicker");
|
||||
var _PickersLayout = require("../../../PickersLayout");
|
||||
var _PickerProvider = require("../../components/PickerProvider");
|
||||
var _PickerFieldUI = require("../../components/PickerFieldUI");
|
||||
var _createNonRangePickerStepNavigation = require("../../utils/createNonRangePickerStepNavigation");
|
||||
var _jsxRuntime = require("react/jsx-runtime");
|
||||
const _excluded = ["props", "steps"],
|
||||
_excluded2 = ["ownerState"];
|
||||
/**
|
||||
* Hook managing all the single-date mobile pickers:
|
||||
* - MobileDatePicker
|
||||
* - MobileDateTimePicker
|
||||
* - MobileTimePicker
|
||||
*/
|
||||
const useMobilePicker = _ref => {
|
||||
let {
|
||||
props,
|
||||
steps
|
||||
} = _ref,
|
||||
pickerParams = (0, _objectWithoutPropertiesLoose2.default)(_ref, _excluded);
|
||||
const {
|
||||
slots,
|
||||
slotProps: innerSlotProps,
|
||||
label,
|
||||
inputRef,
|
||||
localeText
|
||||
} = props;
|
||||
const getStepNavigation = (0, _createNonRangePickerStepNavigation.createNonRangePickerStepNavigation)({
|
||||
steps
|
||||
});
|
||||
const {
|
||||
providerProps,
|
||||
renderCurrentView,
|
||||
ownerState
|
||||
} = (0, _usePicker.usePicker)((0, _extends2.default)({}, pickerParams, {
|
||||
props,
|
||||
localeText,
|
||||
autoFocusView: true,
|
||||
viewContainerRole: 'dialog',
|
||||
variant: 'mobile',
|
||||
getStepNavigation
|
||||
}));
|
||||
const labelId = providerProps.privateContextValue.labelId;
|
||||
const isToolbarHidden = innerSlotProps?.toolbar?.hidden ?? false;
|
||||
const Field = slots.field;
|
||||
const _useSlotProps = (0, _useSlotProps2.default)({
|
||||
elementType: Field,
|
||||
externalSlotProps: innerSlotProps?.field,
|
||||
additionalProps: (0, _extends2.default)({}, isToolbarHidden && {
|
||||
id: labelId
|
||||
}),
|
||||
ownerState
|
||||
}),
|
||||
fieldProps = (0, _objectWithoutPropertiesLoose2.default)(_useSlotProps, _excluded2);
|
||||
const Layout = slots.layout ?? _PickersLayout.PickersLayout;
|
||||
let labelledById = labelId;
|
||||
if (isToolbarHidden) {
|
||||
if (label) {
|
||||
labelledById = `${labelId}-label`;
|
||||
} else {
|
||||
labelledById = undefined;
|
||||
}
|
||||
}
|
||||
const slotProps = (0, _extends2.default)({}, innerSlotProps, {
|
||||
toolbar: (0, _extends2.default)({}, innerSlotProps?.toolbar, {
|
||||
titleId: labelId
|
||||
}),
|
||||
mobilePaper: (0, _extends2.default)({
|
||||
'aria-labelledby': labelledById
|
||||
}, innerSlotProps?.mobilePaper)
|
||||
});
|
||||
const renderPicker = () => /*#__PURE__*/(0, _jsxRuntime.jsx)(_PickerProvider.PickerProvider, (0, _extends2.default)({}, providerProps, {
|
||||
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_PickerFieldUI.PickerFieldUIContextProvider, {
|
||||
slots: slots,
|
||||
slotProps: slotProps,
|
||||
inputRef: inputRef,
|
||||
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(Field, (0, _extends2.default)({}, fieldProps)), /*#__PURE__*/(0, _jsxRuntime.jsx)(_PickersModalDialog.PickersModalDialog, {
|
||||
slots: slots,
|
||||
slotProps: slotProps,
|
||||
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(Layout, (0, _extends2.default)({}, slotProps?.layout, {
|
||||
slots: slots,
|
||||
slotProps: slotProps,
|
||||
children: renderCurrentView()
|
||||
}))
|
||||
})]
|
||||
})
|
||||
}));
|
||||
if (process.env.NODE_ENV !== "production") renderPicker.displayName = "renderPicker";
|
||||
return {
|
||||
renderPicker
|
||||
};
|
||||
};
|
||||
exports.useMobilePicker = useMobilePicker;
|
||||
42
node_modules/@mui/x-date-pickers/internals/hooks/useMobilePicker/useMobilePicker.types.d.ts
generated
vendored
Normal file
42
node_modules/@mui/x-date-pickers/internals/hooks/useMobilePicker/useMobilePicker.types.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
import * as React from 'react';
|
||||
import { MakeRequired, SlotComponentPropsFromProps } from '@mui/x-internals/types';
|
||||
import { BasePickerProps } from "../../models/props/basePickerProps.js";
|
||||
import { PickersModalDialogSlots, PickersModalDialogSlotProps } from "../../components/PickersModalDialog.js";
|
||||
import { UsePickerParameters, UsePickerNonStaticProps, UsePickerProps } from "../usePicker/index.js";
|
||||
import { PickerFieldSlotProps, PickerOwnerState } from "../../../models/index.js";
|
||||
import { ExportedPickersLayoutSlots, ExportedPickersLayoutSlotProps, PickersLayoutSlotProps } from "../../../PickersLayout/PickersLayout.types.js";
|
||||
import { DateOrTimeViewWithMeridiem, PickerValue } from "../../models/index.js";
|
||||
import { PickerFieldUISlotsFromContext, PickerFieldUISlotPropsFromContext } from "../../components/PickerFieldUI.js";
|
||||
import { PickerStep } from "../../utils/createNonRangePickerStepNavigation.js";
|
||||
export interface UseMobilePickerSlots extends PickersModalDialogSlots, ExportedPickersLayoutSlots<PickerValue>, PickerFieldUISlotsFromContext {
|
||||
/**
|
||||
* Component used to enter the date with the keyboard.
|
||||
*/
|
||||
field: React.ElementType;
|
||||
}
|
||||
export interface ExportedUseMobilePickerSlotProps<TEnableAccessibleFieldDOMStructure extends boolean> extends PickersModalDialogSlotProps, ExportedPickersLayoutSlotProps<PickerValue>, PickerFieldUISlotPropsFromContext {
|
||||
field?: SlotComponentPropsFromProps<PickerFieldSlotProps<PickerValue, TEnableAccessibleFieldDOMStructure>, {}, PickerOwnerState>;
|
||||
}
|
||||
export interface UseMobilePickerSlotProps<TEnableAccessibleFieldDOMStructure extends boolean> extends ExportedUseMobilePickerSlotProps<TEnableAccessibleFieldDOMStructure>, Pick<PickersLayoutSlotProps<PickerValue>, 'toolbar'> {}
|
||||
export interface MobileOnlyPickerProps extends UsePickerNonStaticProps {}
|
||||
export interface UseMobilePickerProps<TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean, TError, TExternalProps extends UsePickerProps<PickerValue, TView, TError, any>> extends BasePickerProps<PickerValue, TView, TError, TExternalProps>, MakeRequired<MobileOnlyPickerProps, 'format'> {
|
||||
/**
|
||||
* Overridable component slots.
|
||||
* @default {}
|
||||
*/
|
||||
slots: UseMobilePickerSlots;
|
||||
/**
|
||||
* The props used for each component slot.
|
||||
* @default {}
|
||||
*/
|
||||
slotProps?: UseMobilePickerSlotProps<TEnableAccessibleFieldDOMStructure>;
|
||||
}
|
||||
export interface UseMobilePickerParams<TView extends DateOrTimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure extends boolean, TExternalProps extends UseMobilePickerProps<TView, TEnableAccessibleFieldDOMStructure, any, TExternalProps>> extends Pick<UsePickerParameters<PickerValue, TView, TExternalProps>, 'valueManager' | 'valueType' | 'validator' | 'ref'> {
|
||||
props: TExternalProps;
|
||||
/**
|
||||
* Steps available for the picker.
|
||||
* This will be used to define the behavior of navigation actions.
|
||||
* If null, the picker will not have any step navigation.
|
||||
*/
|
||||
steps: PickerStep[] | null;
|
||||
}
|
||||
5
node_modules/@mui/x-date-pickers/internals/hooks/useMobilePicker/useMobilePicker.types.js
generated
vendored
Normal file
5
node_modules/@mui/x-date-pickers/internals/hooks/useMobilePicker/useMobilePicker.types.js
generated
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
9
node_modules/@mui/x-date-pickers/internals/hooks/useNullableFieldPrivateContext.d.ts
generated
vendored
Normal file
9
node_modules/@mui/x-date-pickers/internals/hooks/useNullableFieldPrivateContext.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
import * as React from 'react';
|
||||
import type { UseFieldInternalProps } from "./useField/index.js";
|
||||
import { FieldRef } from "../../models/index.js";
|
||||
import { PickerRangeValue, PickerValue } from "../models/index.js";
|
||||
export declare const PickerFieldPrivateContext: React.Context<PickerFieldPrivateContextValue | null>;
|
||||
export declare function useNullableFieldPrivateContext(): PickerFieldPrivateContextValue | null;
|
||||
export interface PickerFieldPrivateContextValue extends Pick<UseFieldInternalProps<any, any, any>, 'formatDensity' | 'enableAccessibleFieldDOMStructure' | 'selectedSections' | 'onSelectedSectionsChange'> {
|
||||
fieldRef: React.RefObject<FieldRef<PickerValue> | FieldRef<PickerRangeValue> | null>;
|
||||
}
|
||||
15
node_modules/@mui/x-date-pickers/internals/hooks/useNullableFieldPrivateContext.js
generated
vendored
Normal file
15
node_modules/@mui/x-date-pickers/internals/hooks/useNullableFieldPrivateContext.js
generated
vendored
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
"use strict";
|
||||
'use client';
|
||||
|
||||
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.PickerFieldPrivateContext = void 0;
|
||||
exports.useNullableFieldPrivateContext = useNullableFieldPrivateContext;
|
||||
var React = _interopRequireWildcard(require("react"));
|
||||
const PickerFieldPrivateContext = exports.PickerFieldPrivateContext = /*#__PURE__*/React.createContext(null);
|
||||
if (process.env.NODE_ENV !== "production") PickerFieldPrivateContext.displayName = "PickerFieldPrivateContext";
|
||||
function useNullableFieldPrivateContext() {
|
||||
return React.useContext(PickerFieldPrivateContext);
|
||||
}
|
||||
5
node_modules/@mui/x-date-pickers/internals/hooks/useNullablePickerContext.d.ts
generated
vendored
Normal file
5
node_modules/@mui/x-date-pickers/internals/hooks/useNullablePickerContext.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
/**
|
||||
* Returns the context passed by the Picker wrapping the current component.
|
||||
* If the context is not found, returns `null`.
|
||||
*/
|
||||
export declare const useNullablePickerContext: () => import("../index.js").PickerContextValue<any, any, any> | null;
|
||||
16
node_modules/@mui/x-date-pickers/internals/hooks/useNullablePickerContext.js
generated
vendored
Normal file
16
node_modules/@mui/x-date-pickers/internals/hooks/useNullablePickerContext.js
generated
vendored
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
"use strict";
|
||||
'use client';
|
||||
|
||||
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.useNullablePickerContext = void 0;
|
||||
var React = _interopRequireWildcard(require("react"));
|
||||
var _usePickerContext = require("../../hooks/usePickerContext");
|
||||
/**
|
||||
* Returns the context passed by the Picker wrapping the current component.
|
||||
* If the context is not found, returns `null`.
|
||||
*/
|
||||
const useNullablePickerContext = () => React.useContext(_usePickerContext.PickerContext);
|
||||
exports.useNullablePickerContext = useNullablePickerContext;
|
||||
2
node_modules/@mui/x-date-pickers/internals/hooks/usePicker/hooks/useOrientation.d.ts
generated
vendored
Normal file
2
node_modules/@mui/x-date-pickers/internals/hooks/usePicker/hooks/useOrientation.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
import { DateOrTimeViewWithMeridiem, PickerOrientation } from "../../../models/index.js";
|
||||
export declare function useOrientation(views: readonly DateOrTimeViewWithMeridiem[], customOrientation: PickerOrientation | undefined): PickerOrientation;
|
||||
43
node_modules/@mui/x-date-pickers/internals/hooks/usePicker/hooks/useOrientation.js
generated
vendored
Normal file
43
node_modules/@mui/x-date-pickers/internals/hooks/usePicker/hooks/useOrientation.js
generated
vendored
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
"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.useOrientation = useOrientation;
|
||||
var React = _interopRequireWildcard(require("react"));
|
||||
var _useEnhancedEffect = _interopRequireDefault(require("@mui/utils/useEnhancedEffect"));
|
||||
var _utils = require("../../../utils/utils");
|
||||
function getOrientation() {
|
||||
if (typeof window === 'undefined') {
|
||||
return 'portrait';
|
||||
}
|
||||
if (window.screen && window.screen.orientation && window.screen.orientation.angle) {
|
||||
return Math.abs(window.screen.orientation.angle) === 90 ? 'landscape' : 'portrait';
|
||||
}
|
||||
|
||||
// Support IOS safari
|
||||
if (window.orientation) {
|
||||
return Math.abs(Number(window.orientation)) === 90 ? 'landscape' : 'portrait';
|
||||
}
|
||||
return 'portrait';
|
||||
}
|
||||
function useOrientation(views, customOrientation) {
|
||||
const [orientation, setOrientation] = React.useState(getOrientation);
|
||||
(0, _useEnhancedEffect.default)(() => {
|
||||
const eventHandler = () => {
|
||||
setOrientation(getOrientation());
|
||||
};
|
||||
window.addEventListener('orientationchange', eventHandler);
|
||||
return () => {
|
||||
window.removeEventListener('orientationchange', eventHandler);
|
||||
};
|
||||
}, []);
|
||||
if ((0, _utils.arrayIncludes)(views, ['hours', 'minutes', 'seconds'])) {
|
||||
// could not display 13:34:44 in landscape mode
|
||||
return 'portrait';
|
||||
}
|
||||
return customOrientation ?? orientation;
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue