1
0
Fork 0

Added Statistics calculation

Statistics now show calculated values
This commit is contained in:
Techognito 2025-09-04 17:30:00 +02:00
parent fe87374e47
commit fc0f69dacb
2147 changed files with 141321 additions and 39 deletions

View file

@ -0,0 +1,17 @@
import * as React from 'react';
import { TimePickerProps } from "./TimePicker.types.js";
type TimePickerComponent = (<TEnableAccessibleFieldDOMStructure extends boolean = true>(props: TimePickerProps<TEnableAccessibleFieldDOMStructure> & React.RefAttributes<HTMLDivElement>) => React.JSX.Element) & {
propTypes?: any;
};
/**
* Demos:
*
* - [TimePicker](https://mui.com/x/react-date-pickers/time-picker/)
* - [Validation](https://mui.com/x/react-date-pickers/validation/)
*
* API:
*
* - [TimePicker API](https://mui.com/x/api/date-pickers/time-picker/)
*/
declare const TimePicker: TimePickerComponent;
export { TimePicker };

View file

@ -0,0 +1,327 @@
'use client';
import _extends from "@babel/runtime/helpers/esm/extends";
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
const _excluded = ["desktopModeMediaQuery"];
import * as React from 'react';
import PropTypes from 'prop-types';
import useMediaQuery from '@mui/material/useMediaQuery';
import { useThemeProps } from '@mui/material/styles';
import refType from '@mui/utils/refType';
import { DesktopTimePicker } from "../DesktopTimePicker/index.js";
import { MobileTimePicker } from "../MobileTimePicker/index.js";
import { DEFAULT_DESKTOP_MODE_MEDIA_QUERY } from "../internals/utils/utils.js";
import { jsx as _jsx } from "react/jsx-runtime";
/**
* Demos:
*
* - [TimePicker](https://mui.com/x/react-date-pickers/time-picker/)
* - [Validation](https://mui.com/x/react-date-pickers/validation/)
*
* API:
*
* - [TimePicker API](https://mui.com/x/api/date-pickers/time-picker/)
*/
const TimePicker = /*#__PURE__*/React.forwardRef(function TimePicker(inProps, ref) {
const props = useThemeProps({
props: inProps,
name: 'MuiTimePicker'
});
const {
desktopModeMediaQuery = DEFAULT_DESKTOP_MODE_MEDIA_QUERY
} = props,
other = _objectWithoutPropertiesLoose(props, _excluded);
// defaults to `true` in environments where `window.matchMedia` would not be available (i.e. test/jsdom)
const isDesktop = useMediaQuery(desktopModeMediaQuery, {
defaultMatches: true
});
if (isDesktop) {
return /*#__PURE__*/_jsx(DesktopTimePicker, _extends({
ref: ref
}, other));
}
return /*#__PURE__*/_jsx(MobileTimePicker, _extends({
ref: ref
}, other));
});
if (process.env.NODE_ENV !== "production") TimePicker.displayName = "TimePicker";
process.env.NODE_ENV !== "production" ? TimePicker.propTypes = {
// ----------------------------- Warning --------------------------------
// | These PropTypes are generated from the TypeScript type definitions |
// | To update them edit the TypeScript types and run "pnpm proptypes" |
// ----------------------------------------------------------------------
/**
* 12h/24h view for hour selection clock.
* @default adapter.is12HourCycleInCurrentLocale()
*/
ampm: PropTypes.bool,
/**
* Display ampm controls under the clock (instead of in the toolbar).
* @default true on desktop, false on mobile
*/
ampmInClock: PropTypes.bool,
/**
* If `true`, the main element is focused during the first mount.
* This main element is:
* - the element chosen by the visible view if any (i.e: the selected day on the `day` view).
* - the `input` element if there is a field rendered.
*/
autoFocus: PropTypes.bool,
className: PropTypes.string,
/**
* If `true`, the Picker will close after submitting the full date.
* @default false
*/
closeOnSelect: PropTypes.bool,
/**
* The default value.
* Used when the component is not controlled.
*/
defaultValue: PropTypes.object,
/**
* CSS media query when `Mobile` mode will be changed to `Desktop`.
* @default '@media (pointer: fine)'
* @example '@media (min-width: 720px)' or theme.breakpoints.up("sm")
*/
desktopModeMediaQuery: PropTypes.string,
/**
* If `true`, the component is disabled.
* When disabled, the value cannot be changed and no interaction is possible.
* @default false
*/
disabled: PropTypes.bool,
/**
* If `true`, disable values after the current date for date components, time for time components and both for date time components.
* @default false
*/
disableFuture: PropTypes.bool,
/**
* Do not ignore date part when validating min/max time.
* @default false
*/
disableIgnoringDatePartForTimeValidation: PropTypes.bool,
/**
* If `true`, the button to open the Picker will not be rendered (it will only render the field).
* @deprecated Use the [field component](https://mui.com/x/react-date-pickers/fields/) instead.
* @default false
*/
disableOpenPicker: PropTypes.bool,
/**
* If `true`, disable values before the current date for date components, time for time components and both for date time components.
* @default false
*/
disablePast: PropTypes.bool,
/**
* @default true
*/
enableAccessibleFieldDOMStructure: PropTypes.any,
/**
* Format of the date when rendered in the input(s).
* Defaults to localized format based on the used `views`.
*/
format: PropTypes.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: PropTypes.oneOf(['dense', 'spacious']),
/**
* Pass a ref to the `input` element.
*/
inputRef: refType,
/**
* The label content.
*/
label: PropTypes.node,
/**
* Locale for components texts.
* Allows overriding texts coming from `LocalizationProvider` and `theme`.
*/
localeText: PropTypes.object,
/**
* Maximal selectable time.
* The date part of the object will be ignored unless `props.disableIgnoringDatePartForTimeValidation === true`.
*/
maxTime: PropTypes.object,
/**
* Minimal selectable time.
* The date part of the object will be ignored unless `props.disableIgnoringDatePartForTimeValidation === true`.
*/
minTime: PropTypes.object,
/**
* Step over minutes.
* @default 1
*/
minutesStep: PropTypes.number,
/**
* Name attribute used by the `input` element in the Field.
*/
name: PropTypes.string,
/**
* Callback fired when the value is accepted.
* @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 value that was just accepted.
* @param {FieldChangeHandlerContext<TError>} context The context containing the validation result of the current value.
*/
onAccept: PropTypes.func,
/**
* 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: PropTypes.func,
/**
* Callback fired when the popup requests to be closed.
* Use in controlled mode (see `open`).
*/
onClose: PropTypes.func,
/**
* Callback fired when the error associated with the current value changes.
* When a validation error is detected, the `error` parameter contains a non-null value.
* This can be used to render an appropriate form error.
* @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.
* @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 {TError} error The reason why the current value is not valid.
* @param {TValue} value The value associated with the error.
*/
onError: PropTypes.func,
/**
* Callback fired when the popup requests to be opened.
* Use in controlled mode (see `open`).
*/
onOpen: PropTypes.func,
/**
* Callback fired when the selected sections change.
* @param {FieldSelectedSections} newValue The new selected sections.
*/
onSelectedSectionsChange: PropTypes.func,
/**
* Callback fired on view change.
* @template TView Type of the view. It will vary based on the Picker type and the `views` it uses.
* @param {TView} view The new view.
*/
onViewChange: PropTypes.func,
/**
* Control the popup or dialog open state.
* @default false
*/
open: PropTypes.bool,
/**
* The default visible view.
* Used when the component view is not controlled.
* Must be a valid option from `views` list.
*/
openTo: PropTypes.oneOf(['hours', 'meridiem', 'minutes', 'seconds']),
/**
* Force rendering in particular orientation.
*/
orientation: PropTypes.oneOf(['landscape', 'portrait']),
/**
* If `true`, the component is read-only.
* When read-only, the value cannot be changed but the user can interact with the interface.
* @default false
*/
readOnly: PropTypes.bool,
/**
* If `true`, disable heavy animations.
* @default `@media(prefers-reduced-motion: reduce)` || `navigator.userAgent` matches Android <10 or iOS <13
*/
reduceAnimations: PropTypes.bool,
/**
* The date used to generate the new value when both `value` and `defaultValue` are empty.
* @default The closest valid date-time using the validation props, except callbacks like `shouldDisable<...>`.
*/
referenceDate: PropTypes.object,
/**
* 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: PropTypes.oneOfType([PropTypes.oneOf(['all', 'day', 'empty', 'hours', 'meridiem', 'minutes', 'month', 'seconds', 'weekDay', 'year']), PropTypes.number]),
/**
* Disable specific time.
* @param {PickerValidDate} value The value to check.
* @param {TimeView} view The clock type of the timeValue.
* @returns {boolean} If `true` the time will be disabled.
*/
shouldDisableTime: PropTypes.func,
/**
* If `true`, disabled digital clock items will not be rendered.
* @default false
*/
skipDisabled: PropTypes.bool,
/**
* The props used for each component slot.
* @default {}
*/
slotProps: PropTypes.object,
/**
* Overridable component slots.
* @default {}
*/
slots: PropTypes.object,
/**
* The system prop that allows defining system overrides as well as additional CSS styles.
*/
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
/**
* Amount of time options below or at which the single column time renderer is used.
* @default 24
*/
thresholdToRenderTimeInASingleColumn: PropTypes.number,
/**
* The time steps between two time unit options.
* For example, if `timeSteps.minutes = 8`, then the available minute options will be `[0, 8, 16, 24, 32, 40, 48, 56]`.
* When single column time renderer is used, only `timeSteps.minutes` will be used.
* @default{ hours: 1, minutes: 5, seconds: 5 }
*/
timeSteps: PropTypes.shape({
hours: PropTypes.number,
minutes: PropTypes.number,
seconds: PropTypes.number
}),
/**
* Choose which timezone to use for the value.
* Example: "default", "system", "UTC", "America/New_York".
* If you pass values from other timezones to some props, they will be converted to this timezone before being used.
* @see See the {@link https://mui.com/x/react-date-pickers/timezone/ timezones documentation} for more details.
* @default The timezone of the `value` or `defaultValue` prop is defined, 'default' otherwise.
*/
timezone: PropTypes.string,
/**
* The selected value.
* Used when the component is controlled.
*/
value: PropTypes.object,
/**
* The visible view.
* Used when the component view is controlled.
* Must be a valid option from `views` list.
*/
view: PropTypes.oneOf(['hours', 'meridiem', 'minutes', 'seconds']),
/**
* Define custom view renderers for each section.
* If `null`, the section will only have field editing.
* If `undefined`, internally defined view will be used.
*/
viewRenderers: PropTypes.shape({
hours: PropTypes.func,
meridiem: PropTypes.func,
minutes: PropTypes.func,
seconds: PropTypes.func
}),
/**
* Available views.
*/
views: PropTypes.arrayOf(PropTypes.oneOf(['hours', 'minutes', 'seconds']).isRequired)
} : void 0;
export { TimePicker };

View file

@ -0,0 +1,28 @@
import { DesktopTimePickerProps, DesktopTimePickerSlots, DesktopTimePickerSlotProps } from "../DesktopTimePicker/index.js";
import { BaseSingleInputFieldProps, TimeViewWithMeridiem } from "../internals/models/index.js";
import { MobileTimePickerProps, MobileTimePickerSlots, MobileTimePickerSlotProps } from "../MobileTimePicker/index.js";
import { ValidateTimeProps } from "../validation/validateTime.js";
export interface TimePickerSlots extends DesktopTimePickerSlots, MobileTimePickerSlots {}
export interface TimePickerSlotProps<TEnableAccessibleFieldDOMStructure extends boolean> extends DesktopTimePickerSlotProps<TEnableAccessibleFieldDOMStructure>, MobileTimePickerSlotProps<TEnableAccessibleFieldDOMStructure> {}
export interface TimePickerProps<TEnableAccessibleFieldDOMStructure extends boolean = true> extends DesktopTimePickerProps<TEnableAccessibleFieldDOMStructure>, Omit<MobileTimePickerProps<TimeViewWithMeridiem, TEnableAccessibleFieldDOMStructure>, 'views'> {
/**
* CSS media query when `Mobile` mode will be changed to `Desktop`.
* @default '@media (pointer: fine)'
* @example '@media (min-width: 720px)' or theme.breakpoints.up("sm")
*/
desktopModeMediaQuery?: string;
/**
* Overridable component slots.
* @default {}
*/
slots?: TimePickerSlots;
/**
* The props used for each component slot.
* @default {}
*/
slotProps?: TimePickerSlotProps<TEnableAccessibleFieldDOMStructure>;
}
/**
* Props the field can receive when used inside a Time Picker (<TimePicker />, <DesktopTimePicker /> or <MobileTimePicker /> component).
*/
export type TimePickerFieldProps = ValidateTimeProps & BaseSingleInputFieldProps;

View file

@ -0,0 +1 @@
export {};

View file

@ -0,0 +1,28 @@
import * as React from 'react';
import { BaseToolbarProps, ExportedBaseToolbarProps } from "../internals/models/props/toolbar.js";
import { TimePickerToolbarClasses } from "./timePickerToolbarClasses.js";
export interface TimePickerToolbarProps extends BaseToolbarProps, ExportedTimePickerToolbarProps {
ampm?: boolean;
ampmInClock?: boolean;
}
export interface ExportedTimePickerToolbarProps extends ExportedBaseToolbarProps {
/**
* Override or extend the styles applied to the component.
*/
classes?: Partial<TimePickerToolbarClasses>;
}
/**
* Demos:
*
* - [TimePicker](https://mui.com/x/react-date-pickers/time-picker/)
* - [Custom components](https://mui.com/x/react-date-pickers/custom-components/)
*
* API:
*
* - [TimePickerToolbar API](https://mui.com/x/api/date-pickers/time-picker-toolbar/)
*/
declare function TimePickerToolbar(inProps: TimePickerToolbarProps): React.JSX.Element;
declare namespace TimePickerToolbar {
var propTypes: any;
}
export { TimePickerToolbar };

View file

@ -0,0 +1,240 @@
'use client';
import _extends from "@babel/runtime/helpers/esm/extends";
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
const _excluded = ["ampm", "ampmInClock", "className", "classes"];
import * as React from 'react';
import clsx from 'clsx';
import PropTypes from 'prop-types';
import { styled, useThemeProps } from '@mui/material/styles';
import composeClasses from '@mui/utils/composeClasses';
import { PickersToolbarText } from "../internals/components/PickersToolbarText.js";
import { PickersToolbarButton } from "../internals/components/PickersToolbarButton.js";
import { PickersToolbar } from "../internals/components/PickersToolbar.js";
import { arrayIncludes } from "../internals/utils/utils.js";
import { usePickerAdapter, usePickerContext, usePickerTranslations } from "../hooks/index.js";
import { useMeridiemMode } from "../internals/hooks/date-helpers-hooks.js";
import { getTimePickerToolbarUtilityClass, timePickerToolbarClasses } from "./timePickerToolbarClasses.js";
import { formatMeridiem } from "../internals/utils/date-utils.js";
import { useToolbarOwnerState } from "../internals/hooks/useToolbarOwnerState.js";
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
const useUtilityClasses = (classes, ownerState) => {
const {
pickerOrientation,
toolbarDirection
} = ownerState;
const slots = {
root: ['root'],
separator: ['separator'],
hourMinuteLabel: ['hourMinuteLabel', pickerOrientation === 'landscape' && 'hourMinuteLabelLandscape', toolbarDirection === 'rtl' && 'hourMinuteLabelReverse'],
ampmSelection: ['ampmSelection', pickerOrientation === 'landscape' && 'ampmLandscape'],
ampmLabel: ['ampmLabel']
};
return composeClasses(slots, getTimePickerToolbarUtilityClass, classes);
};
const TimePickerToolbarRoot = styled(PickersToolbar, {
name: 'MuiTimePickerToolbar',
slot: 'Root'
})({});
const TimePickerToolbarSeparator = styled(PickersToolbarText, {
name: 'MuiTimePickerToolbar',
slot: 'Separator'
})({
outline: 0,
margin: '0 4px 0 2px',
cursor: 'default'
});
const TimePickerToolbarHourMinuteLabel = styled('div', {
name: 'MuiTimePickerToolbar',
slot: 'HourMinuteLabel',
overridesResolver: (props, styles) => [{
[`&.${timePickerToolbarClasses.hourMinuteLabelLandscape}`]: styles.hourMinuteLabelLandscape,
[`&.${timePickerToolbarClasses.hourMinuteLabelReverse}`]: styles.hourMinuteLabelReverse
}, styles.hourMinuteLabel]
})({
display: 'flex',
justifyContent: 'flex-end',
alignItems: 'flex-end',
variants: [{
props: {
toolbarDirection: 'rtl'
},
style: {
flexDirection: 'row-reverse'
}
}, {
props: {
pickerOrientation: 'landscape'
},
style: {
marginTop: 'auto'
}
}]
});
const TimePickerToolbarAmPmSelection = styled('div', {
name: 'MuiTimePickerToolbar',
slot: 'AmPmSelection',
overridesResolver: (props, styles) => [{
[`.${timePickerToolbarClasses.ampmLabel}`]: styles.ampmLabel
}, {
[`&.${timePickerToolbarClasses.ampmLandscape}`]: styles.ampmLandscape
}, styles.ampmSelection]
})({
display: 'flex',
flexDirection: 'column',
marginRight: 'auto',
marginLeft: 12,
[`& .${timePickerToolbarClasses.ampmLabel}`]: {
fontSize: 17
},
variants: [{
props: {
pickerOrientation: 'landscape'
},
style: {
margin: '4px 0 auto',
flexDirection: 'row',
justifyContent: 'space-around',
flexBasis: '100%'
}
}]
});
/**
* Demos:
*
* - [TimePicker](https://mui.com/x/react-date-pickers/time-picker/)
* - [Custom components](https://mui.com/x/react-date-pickers/custom-components/)
*
* API:
*
* - [TimePickerToolbar API](https://mui.com/x/api/date-pickers/time-picker-toolbar/)
*/
function TimePickerToolbar(inProps) {
const props = useThemeProps({
props: inProps,
name: 'MuiTimePickerToolbar'
});
const {
ampm,
ampmInClock,
className,
classes: classesProp
} = props,
other = _objectWithoutPropertiesLoose(props, _excluded);
const adapter = usePickerAdapter();
const translations = usePickerTranslations();
const ownerState = useToolbarOwnerState();
const classes = useUtilityClasses(classesProp, ownerState);
const {
value,
setValue,
disabled,
readOnly,
view,
setView,
views
} = usePickerContext();
const showAmPmControl = Boolean(ampm && !ampmInClock && views.includes('hours'));
const {
meridiemMode,
handleMeridiemChange
} = useMeridiemMode(value, ampm, newValue => setValue(newValue, {
changeImportance: 'set'
}));
const formatSection = format => {
if (!adapter.isValid(value)) {
return '--';
}
return adapter.format(value, format);
};
const separator = /*#__PURE__*/_jsx(TimePickerToolbarSeparator, {
tabIndex: -1,
value: ":",
variant: "h3",
selected: false,
className: classes.separator
});
return /*#__PURE__*/_jsxs(TimePickerToolbarRoot, _extends({
landscapeDirection: "row",
toolbarTitle: translations.timePickerToolbarTitle,
ownerState: ownerState,
className: clsx(classes.root, className)
}, other, {
children: [/*#__PURE__*/_jsxs(TimePickerToolbarHourMinuteLabel, {
className: classes.hourMinuteLabel,
ownerState: ownerState,
children: [arrayIncludes(views, 'hours') && /*#__PURE__*/_jsx(PickersToolbarButton, {
tabIndex: -1,
variant: "h3",
onClick: () => setView('hours'),
selected: view === 'hours',
value: formatSection(ampm ? 'hours12h' : 'hours24h')
}), arrayIncludes(views, ['hours', 'minutes']) && separator, arrayIncludes(views, 'minutes') && /*#__PURE__*/_jsx(PickersToolbarButton, {
tabIndex: -1,
variant: "h3",
onClick: () => setView('minutes'),
selected: view === 'minutes',
value: formatSection('minutes')
}), arrayIncludes(views, ['minutes', 'seconds']) && separator, arrayIncludes(views, 'seconds') && /*#__PURE__*/_jsx(PickersToolbarButton, {
variant: "h3",
onClick: () => setView('seconds'),
selected: view === 'seconds',
value: formatSection('seconds')
})]
}), showAmPmControl && /*#__PURE__*/_jsxs(TimePickerToolbarAmPmSelection, {
className: classes.ampmSelection,
ownerState: ownerState,
children: [/*#__PURE__*/_jsx(PickersToolbarButton, {
disableRipple: true,
variant: "subtitle2",
selected: meridiemMode === 'am',
typographyClassName: classes.ampmLabel,
value: formatMeridiem(adapter, 'am'),
onClick: readOnly ? undefined : () => handleMeridiemChange('am'),
disabled: disabled
}), /*#__PURE__*/_jsx(PickersToolbarButton, {
disableRipple: true,
variant: "subtitle2",
selected: meridiemMode === 'pm',
typographyClassName: classes.ampmLabel,
value: formatMeridiem(adapter, 'pm'),
onClick: readOnly ? undefined : () => handleMeridiemChange('pm'),
disabled: disabled
})]
})]
}));
}
process.env.NODE_ENV !== "production" ? TimePickerToolbar.propTypes = {
// ----------------------------- Warning --------------------------------
// | These PropTypes are generated from the TypeScript type definitions |
// | To update them edit the TypeScript types and run "pnpm proptypes" |
// ----------------------------------------------------------------------
ampm: PropTypes.bool,
ampmInClock: PropTypes.bool,
/**
* Override or extend the styles applied to the component.
*/
classes: PropTypes.object,
className: PropTypes.string,
/**
* If `true`, show the toolbar even in desktop mode.
* @default `true` for Desktop, `false` for Mobile.
*/
hidden: PropTypes.bool,
/**
* The system prop that allows defining system overrides as well as additional CSS styles.
*/
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
titleId: PropTypes.string,
/**
* Toolbar date format.
*/
toolbarFormat: PropTypes.string,
/**
* Toolbar value placeholderit is displayed when the value is empty.
* @default ""
*/
toolbarPlaceholder: PropTypes.node
} : void 0;
export { TimePickerToolbar };

View file

@ -0,0 +1,6 @@
export { TimePicker } from "./TimePicker.js";
export type { TimePickerProps, TimePickerSlots, TimePickerSlotProps, TimePickerFieldProps } from "./TimePicker.types.js";
export { TimePickerToolbar } from "./TimePickerToolbar.js";
export type { TimePickerToolbarProps } from "./TimePickerToolbar.js";
export { timePickerToolbarClasses } from "./timePickerToolbarClasses.js";
export type { TimePickerToolbarClassKey, TimePickerToolbarClasses } from "./timePickerToolbarClasses.js";

View file

@ -0,0 +1,3 @@
export { TimePicker } from "./TimePicker.js";
export { TimePickerToolbar } from "./TimePickerToolbar.js";
export { timePickerToolbarClasses } from "./timePickerToolbarClasses.js";

View file

@ -0,0 +1,49 @@
import * as React from 'react';
import { DefaultizedProps } from '@mui/x-internals/types';
import { TimeClockSlots, TimeClockSlotProps } from "../TimeClock/TimeClock.types.js";
import { BasePickerInputProps } from "../internals/models/props/basePickerProps.js";
import { LocalizedComponent } from "../locales/utils/pickersLocaleTextApi.js";
import { TimePickerToolbarProps, ExportedTimePickerToolbarProps } from "./TimePickerToolbar.js";
import { TimeValidationError } from "../models/index.js";
import { PickerViewRendererLookup } from "../internals/hooks/usePicker/index.js";
import { TimeViewRendererProps } from "../timeViewRenderers/index.js";
import { BaseClockProps, ExportedBaseClockProps } from "../internals/models/props/time.js";
import { PickerValue, TimeViewWithMeridiem } from "../internals/models/index.js";
import { ValidateTimePropsToDefault } from "../validation/validateTime.js";
export interface BaseTimePickerSlots extends TimeClockSlots {
/**
* Custom component for the toolbar rendered above the views.
* @default TimePickerToolbar
*/
toolbar?: React.JSXElementConstructor<TimePickerToolbarProps>;
}
export interface BaseTimePickerSlotProps extends TimeClockSlotProps {
toolbar?: ExportedTimePickerToolbarProps;
}
export type TimePickerViewRenderers<TView extends TimeViewWithMeridiem> = PickerViewRendererLookup<PickerValue, TView, TimeViewRendererProps<TView, BaseClockProps<TView>>>;
export interface BaseTimePickerProps<TView extends TimeViewWithMeridiem> extends BasePickerInputProps<PickerValue, TView, TimeValidationError>, ExportedBaseClockProps {
/**
* Display ampm controls under the clock (instead of in the toolbar).
* @default true on desktop, false on mobile
*/
ampmInClock?: boolean;
/**
* Overridable component slots.
* @default {}
*/
slots?: BaseTimePickerSlots;
/**
* The props used for each component slot.
* @default {}
*/
slotProps?: BaseTimePickerSlotProps;
/**
* Define custom view renderers for each section.
* If `null`, the section will only have field editing.
* If `undefined`, internally defined view will be used.
*/
viewRenderers?: Partial<TimePickerViewRenderers<TView>>;
}
type UseTimePickerDefaultizedProps<TView extends TimeViewWithMeridiem, Props extends BaseTimePickerProps<TView>> = LocalizedComponent<DefaultizedProps<Props, 'views' | 'openTo' | 'ampm' | ValidateTimePropsToDefault>>;
export declare function useTimePickerDefaultizedProps<TView extends TimeViewWithMeridiem, Props extends BaseTimePickerProps<TView>>(props: Props, name: string): UseTimePickerDefaultizedProps<TView, Props>;
export {};

View file

@ -0,0 +1,43 @@
import _extends from "@babel/runtime/helpers/esm/extends";
import * as React from 'react';
import { useThemeProps } from '@mui/material/styles';
import { TimePickerToolbar } from "./TimePickerToolbar.js";
import { applyDefaultViewProps } from "../internals/utils/views.js";
import { useApplyDefaultValuesToTimeValidationProps } from "../managers/useTimeManager.js";
import { usePickerAdapter } from "../hooks/usePickerAdapter.js";
export function useTimePickerDefaultizedProps(props, name) {
const adapter = usePickerAdapter();
const themeProps = useThemeProps({
props,
name
});
const validationProps = useApplyDefaultValuesToTimeValidationProps(themeProps);
const ampm = themeProps.ampm ?? adapter.is12HourCycleInCurrentLocale();
const localeText = React.useMemo(() => {
if (themeProps.localeText?.toolbarTitle == null) {
return themeProps.localeText;
}
return _extends({}, themeProps.localeText, {
timePickerToolbarTitle: themeProps.localeText.toolbarTitle
});
}, [themeProps.localeText]);
return _extends({}, themeProps, validationProps, {
ampm,
localeText
}, applyDefaultViewProps({
views: themeProps.views,
openTo: themeProps.openTo,
defaultViews: ['hours', 'minutes'],
defaultOpenTo: 'hours'
}), {
slots: _extends({
toolbar: TimePickerToolbar
}, themeProps.slots),
slotProps: _extends({}, themeProps.slotProps, {
toolbar: _extends({
ampm,
ampmInClock: themeProps.ampmInClock
}, themeProps.slotProps?.toolbar)
})
});
}

View file

@ -0,0 +1,21 @@
export interface TimePickerToolbarClasses {
/** Styles applied to the root element. */
root: string;
/** Styles applied to the separator element. */
separator: string;
/** Styles applied to the time sections element. */
hourMinuteLabel: string;
/** Styles applied to the time sections element in landscape mode. */
hourMinuteLabelLandscape: string;
/** Styles applied to the time sections element in "rtl" theme mode. */
hourMinuteLabelReverse: string;
/** Styles applied to the meridiem selection element. */
ampmSelection: string;
/** Styles applied to the meridiem selection element in landscape mode. */
ampmLandscape: string;
/** Styles applied to the meridiem label element. */
ampmLabel: string;
}
export type TimePickerToolbarClassKey = keyof TimePickerToolbarClasses;
export declare function getTimePickerToolbarUtilityClass(slot: string): string;
export declare const timePickerToolbarClasses: TimePickerToolbarClasses;

View file

@ -0,0 +1,6 @@
import generateUtilityClass from '@mui/utils/generateUtilityClass';
import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
export function getTimePickerToolbarUtilityClass(slot) {
return generateUtilityClass('MuiTimePickerToolbar', slot);
}
export const timePickerToolbarClasses = generateUtilityClasses('MuiTimePickerToolbar', ['root', 'separator', 'hourMinuteLabel', 'hourMinuteLabelLandscape', 'hourMinuteLabelReverse', 'ampmSelection', 'ampmLandscape', 'ampmLabel']);