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,47 @@
import * as React from 'react';
import { ListProps } from '@mui/material/List';
import { PickerValidValue } from "../internals/models/index.js";
import { PickerChangeImportance } from "../models/pickers.js";
interface PickersShortcutsItemGetValueParams<TValue extends PickerValidValue> {
isValid: (value: TValue) => boolean;
}
export interface PickersShortcutsItem<TValue extends PickerValidValue> {
label: string;
getValue: (params: PickersShortcutsItemGetValueParams<TValue>) => TValue;
/**
* Identifier of the shortcut.
* If provided, it will be used as the key of the shortcut.
*/
id?: string;
}
export type PickersShortcutsItemContext = Omit<PickersShortcutsItem<PickerValidValue>, 'getValue'>;
export interface ExportedPickersShortcutProps<TValue extends PickerValidValue> extends Omit<ListProps, 'onChange'> {
/**
* Ordered array of shortcuts to display.
* If empty, does not display the shortcuts.
* @default []
*/
items?: PickersShortcutsItem<TValue>[];
/**
* Importance of the change when picking a shortcut:
* - "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;
}
export interface PickersShortcutsProps<TValue extends PickerValidValue> extends ExportedPickersShortcutProps<TValue> {}
/**
* Demos:
*
* - [Shortcuts](https://mui.com/x/react-date-pickers/shortcuts/)
*
* API:
*
* - [PickersShortcuts API](https://mui.com/x/api/date-pickers/pickers-shortcuts/)
*/
declare function PickersShortcuts<TValue extends PickerValidValue>(props: PickersShortcutsProps<TValue>): React.JSX.Element | null;
declare namespace PickersShortcuts {
var propTypes: any;
}
export { PickersShortcuts };

View file

@ -0,0 +1,129 @@
"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.PickersShortcuts = PickersShortcuts;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
var React = _interopRequireWildcard(require("react"));
var _styles = require("@mui/material/styles");
var _propTypes = _interopRequireDefault(require("prop-types"));
var _List = _interopRequireDefault(require("@mui/material/List"));
var _ListItem = _interopRequireDefault(require("@mui/material/ListItem"));
var _Chip = _interopRequireDefault(require("@mui/material/Chip"));
var _dimensions = require("../internals/constants/dimensions");
var _hooks = require("../hooks");
var _jsxRuntime = require("react/jsx-runtime");
const _excluded = ["items", "changeImportance"],
_excluded2 = ["getValue"];
const PickersShortcutsRoot = (0, _styles.styled)(_List.default, {
name: 'MuiPickersLayout',
slot: 'Shortcuts'
})({});
/**
* Demos:
*
* - [Shortcuts](https://mui.com/x/react-date-pickers/shortcuts/)
*
* API:
*
* - [PickersShortcuts API](https://mui.com/x/api/date-pickers/pickers-shortcuts/)
*/
function PickersShortcuts(props) {
const {
items,
changeImportance = 'accept'
} = props,
other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
const {
setValue
} = (0, _hooks.usePickerActionsContext)();
const isValidValue = (0, _hooks.useIsValidValue)();
if (items == null || items.length === 0) {
return null;
}
const resolvedItems = items.map(_ref => {
let {
getValue
} = _ref,
item = (0, _objectWithoutPropertiesLoose2.default)(_ref, _excluded2);
const newValue = getValue({
isValid: isValidValue
});
return (0, _extends2.default)({}, item, {
label: item.label,
onClick: () => {
setValue(newValue, {
changeImportance,
shortcut: item
});
},
disabled: !isValidValue(newValue)
});
});
return /*#__PURE__*/(0, _jsxRuntime.jsx)(PickersShortcutsRoot, (0, _extends2.default)({
dense: true,
sx: [{
maxHeight: _dimensions.VIEW_HEIGHT,
maxWidth: 200,
overflow: 'auto'
}, ...(Array.isArray(other.sx) ? other.sx : [other.sx])]
}, other, {
children: resolvedItems.map(item => {
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ListItem.default, {
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Chip.default, (0, _extends2.default)({}, item))
}, item.id ?? item.label);
})
}));
}
process.env.NODE_ENV !== "production" ? PickersShortcuts.propTypes = {
// ----------------------------- Warning --------------------------------
// | These PropTypes are generated from the TypeScript type definitions |
// | To update them edit the TypeScript types and run "pnpm proptypes" |
// ----------------------------------------------------------------------
/**
* Importance of the change when picking a shortcut:
* - "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: _propTypes.default.oneOf(['accept', 'set']),
className: _propTypes.default.string,
component: _propTypes.default.elementType,
/**
* If `true`, compact vertical padding designed for keyboard and mouse input is used for
* the list and list items.
* The prop is available to descendant components as the `dense` context.
* @default false
*/
dense: _propTypes.default.bool,
/**
* If `true`, vertical padding is removed from the list.
* @default false
*/
disablePadding: _propTypes.default.bool,
/**
* Ordered array of shortcuts to display.
* If empty, does not display the shortcuts.
* @default []
*/
items: _propTypes.default.arrayOf(_propTypes.default.shape({
getValue: _propTypes.default.func.isRequired,
id: _propTypes.default.string,
label: _propTypes.default.string.isRequired
})),
style: _propTypes.default.object,
/**
* The content of the subheader, normally `ListSubheader`.
*/
subheader: _propTypes.default.node,
/**
* The system prop that allows defining system overrides as well as additional CSS styles.
*/
sx: _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.object, _propTypes.default.bool])), _propTypes.default.func, _propTypes.default.object])
} : void 0;

View file

@ -0,0 +1,2 @@
export { PickersShortcuts } from "./PickersShortcuts.js";
export type { PickersShortcutsProps, PickersShortcutsItem, PickersShortcutsItemContext } from "./PickersShortcuts.js";

View file

@ -0,0 +1,12 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "PickersShortcuts", {
enumerable: true,
get: function () {
return _PickersShortcuts.PickersShortcuts;
}
});
var _PickersShortcuts = require("./PickersShortcuts");