1
0
Fork 0
react-playground/node_modules/@mui/x-date-pickers/esm/internals/hooks/useField/useFieldHiddenInputProps.js
Techognito fc0f69dacb Added Statistics calculation
Statistics now show calculated values
2025-09-04 17:30:00 +02:00

31 lines
No EOL
1.2 KiB
JavaScript

import * as React from 'react';
import useEventCallback from '@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.
*/
export function useFieldHiddenInputProps(parameters) {
const {
manager: {
internal_fieldValueManager: fieldValueManager
},
stateResponse: {
// States and derived states
areAllSectionsEmpty,
state,
// Methods to update the states
updateValueFromValueStr
}
} = parameters;
const handleChange = useEventCallback(event => {
updateValueFromValueStr(event.target.value);
});
const valueStr = React.useMemo(() => areAllSectionsEmpty ? '' : fieldValueManager.getV7HiddenInputValueFromSections(state.sections), [areAllSectionsEmpty, state.sections, fieldValueManager]);
return {
value: valueStr,
onChange: handleChange
};
}