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,5 @@
import { DateView, TimeView } from "../../models/views.js";
export type PickerOrientation = 'portrait' | 'landscape';
export type PickerVariant = 'mobile' | 'desktop';
export type TimeViewWithMeridiem = TimeView | 'meridiem';
export type DateOrTimeViewWithMeridiem = DateView | TimeViewWithMeridiem;

View file

@ -0,0 +1,5 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});

View file

@ -0,0 +1,12 @@
import type { FieldSection } from "../../models/index.js";
import { RangePosition } from "./pickers.js";
export interface FieldRangeSection extends FieldSection {
dateName: RangePosition;
}
/**
* Props the single input field can receive when used inside a Picker.
* Only contains what the MUI components are passing to the field, not what users can pass using the `props.slotProps.field`.
*/
export interface BaseSingleInputFieldProps {
id?: string;
}

View file

@ -0,0 +1,5 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});

View file

@ -0,0 +1,14 @@
export interface FormProps {
/**
* If `true`, the component is disabled.
* When disabled, the value cannot be changed and no interaction is possible.
* @default false
*/
disabled?: boolean;
/**
* 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?: boolean;
}

View file

@ -0,0 +1,5 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});

View file

@ -0,0 +1,17 @@
import { ComponentNameToClassKey, ComponentsPropsList } from '@mui/material/styles';
import { CSSObject, CSSInterpolation, Interpolation } from '@mui/system';
/**
* All standard components exposed by `material-ui` are `StyledComponents` with
* certain `classes`, on which one can also set a top-level `className` and inline
* `style`.
*/
export type ExtendMui<C, Removals extends keyof C = never> = Omit<C, 'classes' | 'theme' | Removals>;
type OverridesStyleRules<ClassKey extends string = string, ComponentName = keyof ComponentsPropsList, Theme = unknown, OwnerState = unknown> = Record<ClassKey, Interpolation<(ComponentName extends keyof ComponentsPropsList ? ComponentsPropsList[ComponentName] & Record<string, unknown> & {
ownerState: OwnerState extends object ? OwnerState : ComponentsPropsList[ComponentName] & Record<string, unknown>;
} : {}) & {
theme: Theme;
} & Record<string, unknown>>>;
export type ComponentsOverrides<Theme = unknown, OwnerState = unknown> = { [Name in keyof ComponentNameToClassKey]?: Partial<OverridesStyleRules<ComponentNameToClassKey[Name], Name, Theme, OwnerState>> } & {
MuiCssBaseline?: CSSObject | string | ((theme: Theme) => CSSInterpolation);
};
export {};

View file

@ -0,0 +1,5 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});

View file

@ -0,0 +1,5 @@
export * from "./fields.js";
export * from "./common.js";
export * from "./value.js";
export * from "./formProps.js";
export * from "./manager.js";

View file

@ -0,0 +1,60 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var _fields = require("./fields");
Object.keys(_fields).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (key in exports && exports[key] === _fields[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function () {
return _fields[key];
}
});
});
var _common = require("./common");
Object.keys(_common).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (key in exports && exports[key] === _common[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function () {
return _common[key];
}
});
});
var _value = require("./value");
Object.keys(_value).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (key in exports && exports[key] === _value[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function () {
return _value[key];
}
});
});
var _formProps = require("./formProps");
Object.keys(_formProps).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (key in exports && exports[key] === _formProps[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function () {
return _formProps[key];
}
});
});
var _manager = require("./manager");
Object.keys(_manager).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (key in exports && exports[key] === _manager[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function () {
return _manager[key];
}
});
});

View file

@ -0,0 +1,119 @@
import type { MuiPickersAdapter, PickerManager, PickersTimezone, PickerValidDate, PickerValueType } from "../../models/index.js";
import type { GetDefaultReferenceDateProps } from "../utils/getDefaultReferenceDate.js";
import { InferNonNullablePickerValue, PickerRangeValue, PickerValidValue } from "./value.js";
import type { UseFieldInternalProps } from "../hooks/useField/index.js";
export type PickerAnyManager = PickerManager<any, any, any, any, any>;
type PickerManagerProperties<TManager extends PickerAnyManager> = TManager extends PickerManager<infer TValue, infer TEnableAccessibleFieldDOMStructure, infer TError, infer TValidationProps, infer TFieldInternalProps> ? {
value: TValue;
enableAccessibleFieldDOMStructure: TEnableAccessibleFieldDOMStructure;
error: TError;
validationProps: TValidationProps;
fieldInternalProps: TFieldInternalProps;
} : never;
export type PickerManagerValue<TManager extends PickerAnyManager> = PickerManagerProperties<TManager>['value'];
export type PickerManagerError<TManager extends PickerAnyManager> = PickerManagerProperties<TManager>['error'];
export type PickerManagerFieldInternalProps<TManager extends PickerAnyManager> = PickerManagerProperties<TManager>['fieldInternalProps'];
export type PickerManagerValidationProps<TManager extends PickerAnyManager> = PickerManagerProperties<TManager>['validationProps'];
export type PickerManagerFieldInternalPropsWithDefaults<TManager extends PickerAnyManager> = UseFieldInternalProps<PickerManagerValue<TManager>, PickerManagerEnableAccessibleFieldDOMStructure<TManager>, PickerManagerError<TManager>> & PickerManagerValidationProps<TManager>;
export type PickerManagerEnableAccessibleFieldDOMStructure<TManager extends PickerAnyManager> = PickerManagerProperties<TManager>['enableAccessibleFieldDOMStructure'];
export interface PickerValueManager<TValue extends PickerValidValue, TError> {
/**
* Determines if two values are equal.
* @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 Picker date adapter instance.
* @param {TValue} valueLeft The first value to compare.
* @param {TValue} valueRight The second value to compare.
* @returns {boolean} A boolean indicating if the two values are equal.
*/
areValuesEqual: (adapter: MuiPickersAdapter, valueLeft: TValue, valueRight: TValue) => boolean;
/**
* Value to set when clicking the "Clear" button.
*/
emptyValue: TValue;
/**
* Method returning the value to set when clicking the "Today" button.
* @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 Picker date adapter instance.
* @param {PickersTimezone} timezone The current timezone.
* @param {PickerValueType} valueType The type of the value being edited.
* @returns {TValue} The value to set when clicking the "Today" button.
*/
getTodayValue: (adapter: MuiPickersAdapter, timezone: PickersTimezone, valueType: PickerValueType) => 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.
* Method returning the reference value to use when mounting the component.
* @param {object} params The params of the method.
* @param {PickerValidDate | PickerValidDate[] | undefined} params.referenceDate The referenceDate provided by the user.
* @param {TValue} params.value The value provided by the user.
* @param {GetDefaultReferenceDateProps} params.props The validation props needed to compute the reference value.
* @param {MuiPickersAdapter} params.adapter The Picker date adapter instance.
* @param {number} params.granularity The granularity of the selection possible on this component.
* @param {PickersTimezone} params.timezone The current timezone.
* @param {() => PickerValidDate} params.getTodayDate The reference date to use if no reference date is passed to the component.
* @returns {TValue} The reference value to use for non-provided dates.
*/
getInitialReferenceValue: (params: {
referenceDate?: TValue extends PickerRangeValue ? TValue | PickerValidDate : PickerValidDate;
value: TValue;
props: GetDefaultReferenceDateProps;
adapter: MuiPickersAdapter;
granularity: number;
timezone: PickersTimezone;
getTodayDate?: () => PickerValidDate;
}) => InferNonNullablePickerValue<TValue>;
/**
* Method parsing the input value to replace all invalid dates by `null`.
* @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 Picker date adapter instance.
* @param {TValue} value The value to parse.
* @returns {TValue} The value without invalid date.
*/
cleanValue: (adapter: MuiPickersAdapter, value: TValue) => TValue;
/**
* Generates the new value, given the previous value and the new proposed 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 {MuiPickersAdapter} adapter The Picker date adapter instance.
* @param {TValue} lastValidDateValue The last valid value.
* @param {TValue} value The proposed value.
* @returns {TValue} The new value.
*/
valueReducer?: (adapter: MuiPickersAdapter, lastValidDateValue: TValue, value: TValue) => TValue;
/**
* Compare two errors to know if they are equal.
* @template TError
* @param {TError} error The new error
* @param {TError | null} prevError The previous error
* @returns {boolean} `true` if the new error is different from the previous one.
*/
isSameError: (error: TError, prevError: TError | null) => boolean;
/**
* Checks if the current error is empty or not.
* @template TError
* @param {TError} error The current error.
* @returns {boolean} `true` if the current error is not empty.
*/
hasError: (error: TError) => boolean;
/**
* The value identifying no error, used to initialize the error state.
*/
defaultErrorState: TError;
/**
* Return the timezone of the date inside a value.
* When used on a range Picker, throw an error if both values don't have the same timezone.
* @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 Picker date adapter instance.
@param {TValue} value The current value.
@returns {string | null} The timezone of the current value.
*/
getTimezone: (adapter: MuiPickersAdapter, value: TValue) => string | null;
/**
* Change the timezone of the dates inside a 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 {MuiPickersAdapter} adapter The Picker date adapter instance.
@param {PickersTimezone} timezone The current timezone.
@param {TValue} value The value to convert.
@returns {TValue} The value with the new dates in the new timezone.
*/
setTimezone: (adapter: MuiPickersAdapter, timezone: PickersTimezone, value: TValue) => TValue;
}
export {};

View file

@ -0,0 +1,5 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});

View file

@ -0,0 +1 @@
export type RangePosition = 'start' | 'end';

View file

@ -0,0 +1,5 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});

View file

@ -0,0 +1,27 @@
import { Theme } from '@mui/material/styles';
import { SxProps } from '@mui/system';
import { MakeOptional } from '@mui/x-internals/types';
import { UsePickerBaseProps } from "../../hooks/usePicker/index.js";
import { PickersInputComponentLocaleText } from "../../../locales/utils/pickersLocaleTextApi.js";
import type { UsePickerProps } from "../../hooks/usePicker/index.js";
import { DateOrTimeViewWithMeridiem } from "../common.js";
import { PickerValidValue } from "../value.js";
/**
* Props common to all pickers after applying the default props on each Picker.
*/
export interface BasePickerProps<TValue extends PickerValidValue, TView extends DateOrTimeViewWithMeridiem, TError, TExternalProps extends UsePickerProps<TValue, TView, TError, any>> extends UsePickerBaseProps<TValue, TView, TError, TExternalProps> {
className?: string;
/**
* The system prop that allows defining system overrides as well as additional CSS styles.
*/
sx?: SxProps<Theme>;
/**
* Locale for components texts.
* Allows overriding texts coming from `LocalizationProvider` and `theme`.
*/
localeText?: PickersInputComponentLocaleText;
}
/**
* Props common to all pickers before applying the default props on each Picker.
*/
export interface BasePickerInputProps<TValue extends PickerValidValue, TView extends DateOrTimeViewWithMeridiem, TError> extends Omit<MakeOptional<BasePickerProps<TValue, TView, TError, any>, 'openTo' | 'views'>, 'viewRenderers'> {}

View file

@ -0,0 +1,5 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});

View file

@ -0,0 +1,9 @@
import { SxProps } from '@mui/system';
import { Theme } from '@mui/material/styles';
export interface ExportedBaseTabsProps {
className?: string;
/**
* The system prop that allows defining system overrides as well as additional CSS styles.
*/
sx?: SxProps<Theme>;
}

View file

@ -0,0 +1,5 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});

View file

@ -0,0 +1,77 @@
import { SxProps, Theme } from '@mui/material/styles';
import { PickerValidDate, TimeStepOptions, TimezoneProps } from "../../../models/index.js";
import type { ExportedDigitalClockProps } from "../../../DigitalClock/DigitalClock.types.js";
import type { ExportedMultiSectionDigitalClockProps } from "../../../MultiSectionDigitalClock/MultiSectionDigitalClock.types.js";
import type { ExportedUseViewsOptions } from "../../hooks/useViews.js";
import { TimeViewWithMeridiem } from "../common.js";
import { ExportedValidateTimeProps } from "../../../validation/validateTime.js";
import { FormProps } from "../formProps.js";
import { PickerValue } from "../value.js";
export interface AmPmProps {
/**
* 12h/24h view for hour selection clock.
* @default adapter.is12HourCycleInCurrentLocale()
*/
ampm?: boolean;
}
export interface ExportedBaseClockProps extends ExportedValidateTimeProps, TimezoneProps, AmPmProps {}
export interface BaseClockProps<TView extends TimeViewWithMeridiem> extends ExportedUseViewsOptions<PickerValue, TView>, ExportedBaseClockProps, FormProps {
className?: string;
/**
* The system prop that allows defining system overrides as well as additional CSS styles.
*/
sx?: SxProps<Theme>;
/**
* The selected value.
* Used when the component is controlled.
*/
value?: PickerValidDate | null;
/**
* The default selected value.
* Used when the component is not controlled.
*/
defaultValue?: PickerValidDate | null;
/**
* The date used to generate the new value when both `value` and `defaultValue` are empty.
* @default The closest valid time using the validation props, except callbacks such as `shouldDisableTime`.
*/
referenceDate?: PickerValidDate;
}
export interface DigitalTimePickerProps extends Omit<ExportedDigitalClockProps, 'timeStep'>, Omit<ExportedMultiSectionDigitalClockProps, 'timeSteps'> {
/**
* Amount of time options below or at which the single column time renderer is used.
* @default 24
*/
thresholdToRenderTimeInASingleColumn?: 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?: TimeStepOptions;
}
interface DigitalClockOnlyBaseProps {
/**
* If `true`, disabled digital clock items will not be rendered.
* @default false
*/
skipDisabled?: boolean;
}
export interface DigitalClockOnlyProps extends DigitalClockOnlyBaseProps {
/**
* The time steps between two time options.
* For example, if `timeStep = 45`, then the available time options will be `[00:00, 00:45, 01:30, 02:15, 03:00, etc.]`.
* @default 30
*/
timeStep?: number;
}
export interface MultiSectionDigitalClockOnlyProps extends DigitalClockOnlyBaseProps {
/**
* 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]`.
* @default{ hours: 1, minutes: 5, seconds: 5 }
*/
timeSteps?: TimeStepOptions;
}
export {};

View file

@ -0,0 +1,5 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});

View file

@ -0,0 +1,27 @@
import * as React from 'react';
import { SxProps } from '@mui/system';
import { Theme } from '@mui/material/styles';
export interface BaseToolbarProps extends ExportedBaseToolbarProps {
titleId?: string;
}
export interface ExportedBaseToolbarProps {
/**
* Toolbar date format.
*/
toolbarFormat?: string;
/**
* Toolbar value placeholderit is displayed when the value is empty.
* @default ""
*/
toolbarPlaceholder?: React.ReactNode;
className?: string;
/**
* If `true`, show the toolbar even in desktop mode.
* @default `true` for Desktop, `false` for Mobile.
*/
hidden?: boolean;
/**
* The system prop that allows defining system overrides as well as additional CSS styles.
*/
sx?: SxProps<Theme>;
}

View file

@ -0,0 +1,5 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});

View file

@ -0,0 +1,116 @@
import type { PickerValidDate, TimeView } from "../../models/index.js";
interface FutureAndPastValidationProps {
/**
* If `true`, disable values before the current date for date components, time for time components and both for date time components.
* @default false
*/
disablePast?: boolean;
/**
* If `true`, disable values after the current date for date components, time for time components and both for date time components.
* @default false
*/
disableFuture?: boolean;
}
/**
* Validation props common to all the time views.
* All these props have a default value when used inside a Field / Picker / Clock.
*/
export interface BaseTimeValidationProps extends FutureAndPastValidationProps {}
/**
* Props used to validate a time value.
*/
export interface TimeValidationProps {
/**
* Minimal selectable time.
* The date part of the object will be ignored unless `props.disableIgnoringDatePartForTimeValidation === true`.
*/
minTime?: PickerValidDate;
/**
* Maximal selectable time.
* The date part of the object will be ignored unless `props.disableIgnoringDatePartForTimeValidation === true`.
*/
maxTime?: PickerValidDate;
/**
* Step over minutes.
* @default 1
*/
minutesStep?: 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?: (value: PickerValidDate, view: TimeView) => boolean;
/**
* Do not ignore date part when validating min/max time.
* @default false
*/
disableIgnoringDatePartForTimeValidation?: boolean;
}
/**
* Validation props common to all the date views.
* All these props have a default value when used inside a Field / Picker / Calendar.
*/
export interface BaseDateValidationProps extends FutureAndPastValidationProps {
/**
* Maximal selectable date.
* @default 2099-12-31
*/
maxDate?: PickerValidDate;
/**
* Minimal selectable date.
* @default 1900-01-01
*/
minDate?: PickerValidDate;
}
/**
* Props used to validate a date value (validates day + month + year).
*/
export interface DayValidationProps {
/**
* Disable specific date.
*
* Warning: This function can be called multiple times (for example when rendering date calendar, checking if focus can be moved to a certain date, etc.). Expensive computations can impact performance.
*
* @param {PickerValidDate} day The date to test.
* @returns {boolean} If `true` the date will be disabled.
*/
shouldDisableDate?: (day: PickerValidDate) => boolean;
}
/**
* Props used to validate a month value
*/
export interface MonthValidationProps {
/**
* Disable specific month.
* @param {PickerValidDate} month The month to test.
* @returns {boolean} If `true`, the month will be disabled.
*/
shouldDisableMonth?: (month: PickerValidDate) => boolean;
}
/**
* Props used to validate a year value
*/
export interface YearValidationProps {
/**
* Disable specific year.
* @param {PickerValidDate} year The year to test.
* @returns {boolean} If `true`, the year will be disabled.
*/
shouldDisableYear?: (year: PickerValidDate) => boolean;
}
/**
* Props used to validate a date time value.
*/
export interface DateTimeValidationProps {
/**
* Minimal selectable moment of time with binding to date, to set min time in each day use `minTime`.
*/
minDateTime?: PickerValidDate;
/**
* Maximal selectable moment of time with binding to date, to set max time in each day use `maxTime`.
*/
maxDateTime?: PickerValidDate;
}
export {};

View file

@ -0,0 +1,5 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});

View file

@ -0,0 +1,12 @@
import { PickerValidDate } from "../../models/pickers.js";
/**
* The type that the `value` and `defaultValue` props can receive on non-range components (date, time and date-time).
*/
export type PickerValue = PickerValidDate | null;
/**
* The type that the `value` and `defaultValue` props can receive on range components (date-range, time-range and date-time-range).
*/
export type PickerRangeValue = [PickerValidDate | null, PickerValidDate | null];
export type PickerNonNullableRangeValue = [PickerValidDate, PickerValidDate];
export type PickerValidValue = PickerValue | PickerRangeValue;
export type InferNonNullablePickerValue<TValue extends PickerValidValue> = TValue extends PickerRangeValue ? TValue extends PickerValue ? PickerValidDate | PickerNonNullableRangeValue : PickerNonNullableRangeValue : PickerValidDate;

View file

@ -0,0 +1,5 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});