@mui/x-date-pickers 7.0.0-alpha.9 → 7.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +139 -38
- package/DateTimePicker/DateTimePickerTabs.js +7 -4
- package/DateTimePicker/DateTimePickerToolbar.d.ts +6 -1
- package/DateTimePicker/DateTimePickerToolbar.js +33 -17
- package/PickersLayout/PickersLayout.types.d.ts +6 -5
- package/PickersLayout/pickersLayoutClasses.js +3 -2
- package/PickersLayout/usePickerLayout.d.ts +2 -2
- package/PickersLayout/usePickerLayout.js +2 -1
- package/README.md +2 -2
- package/TimeClock/TimeClock.js +3 -3
- package/dateTimeViewRenderers/dateTimeViewRenderers.js +4 -4
- package/index.js +1 -1
- package/internals/hooks/usePicker/usePicker.d.ts +1 -1
- package/internals/hooks/usePicker/usePicker.js +4 -2
- package/internals/hooks/usePicker/usePicker.types.d.ts +1 -1
- package/internals/hooks/usePicker/usePickerViews.d.ts +11 -2
- package/internals/hooks/usePicker/usePickerViews.js +8 -3
- package/internals/index.d.ts +4 -4
- package/internals/index.js +2 -2
- package/internals/models/props/tabs.d.ts +2 -1
- package/legacy/DateTimePicker/DateTimePickerTabs.js +7 -4
- package/legacy/DateTimePicker/DateTimePickerToolbar.js +43 -29
- package/legacy/PickersLayout/pickersLayoutClasses.js +3 -2
- package/legacy/PickersLayout/usePickerLayout.js +2 -1
- package/legacy/TimeClock/TimeClock.js +3 -3
- package/legacy/dateTimeViewRenderers/dateTimeViewRenderers.js +5 -4
- package/legacy/index.js +1 -1
- package/legacy/internals/hooks/usePicker/usePicker.js +4 -2
- package/legacy/internals/hooks/usePicker/usePickerViews.js +8 -3
- package/legacy/internals/index.js +2 -2
- package/legacy/locales/beBY.js +8 -3
- package/legacy/locales/caES.js +7 -2
- package/legacy/locales/csCZ.js +8 -3
- package/legacy/locales/daDK.js +8 -3
- package/legacy/locales/deDE.js +6 -1
- package/legacy/locales/elGR.js +8 -3
- package/legacy/locales/enUS.js +7 -3
- package/legacy/locales/esES.js +8 -3
- package/legacy/locales/eu.js +6 -1
- package/legacy/locales/faIR.js +6 -1
- package/legacy/locales/fiFI.js +8 -3
- package/legacy/locales/frFR.js +6 -1
- package/legacy/locales/heIL.js +6 -1
- package/legacy/locales/huHU.js +6 -1
- package/legacy/locales/isIS.js +8 -3
- package/legacy/locales/itIT.js +8 -3
- package/legacy/locales/jaJP.js +6 -1
- package/legacy/locales/koKR.js +6 -1
- package/legacy/locales/kzKZ.js +6 -1
- package/legacy/locales/mk.js +6 -1
- package/legacy/locales/nbNO.js +8 -3
- package/legacy/locales/nlNL.js +8 -3
- package/legacy/locales/plPL.js +8 -3
- package/legacy/locales/ptBR.js +6 -1
- package/legacy/locales/roRO.js +6 -1
- package/legacy/locales/ruRU.js +8 -3
- package/legacy/locales/skSK.js +8 -3
- package/legacy/locales/svSE.js +8 -3
- package/legacy/locales/trTR.js +8 -3
- package/legacy/locales/ukUA.js +8 -3
- package/legacy/locales/urPK.js +6 -1
- package/legacy/locales/viVN.js +8 -3
- package/legacy/locales/zhCN.js +6 -1
- package/legacy/locales/zhHK.js +6 -1
- package/locales/beBY.d.ts +4 -0
- package/locales/beBY.js +8 -3
- package/locales/caES.d.ts +4 -0
- package/locales/caES.js +7 -2
- package/locales/csCZ.d.ts +4 -0
- package/locales/csCZ.js +8 -3
- package/locales/daDK.d.ts +4 -0
- package/locales/daDK.js +8 -3
- package/locales/deDE.d.ts +4 -0
- package/locales/deDE.js +6 -1
- package/locales/elGR.d.ts +4 -0
- package/locales/elGR.js +8 -3
- package/locales/enUS.d.ts +4 -0
- package/locales/enUS.js +7 -3
- package/locales/esES.d.ts +4 -0
- package/locales/esES.js +8 -3
- package/locales/eu.d.ts +4 -0
- package/locales/eu.js +6 -1
- package/locales/faIR.d.ts +4 -0
- package/locales/faIR.js +6 -1
- package/locales/fiFI.d.ts +4 -0
- package/locales/fiFI.js +8 -3
- package/locales/frFR.d.ts +4 -0
- package/locales/frFR.js +6 -1
- package/locales/heIL.d.ts +4 -0
- package/locales/heIL.js +6 -1
- package/locales/huHU.d.ts +4 -0
- package/locales/huHU.js +6 -1
- package/locales/isIS.d.ts +4 -0
- package/locales/isIS.js +8 -3
- package/locales/itIT.d.ts +4 -0
- package/locales/itIT.js +8 -3
- package/locales/jaJP.d.ts +4 -0
- package/locales/jaJP.js +6 -1
- package/locales/koKR.d.ts +4 -0
- package/locales/koKR.js +6 -1
- package/locales/kzKZ.d.ts +4 -0
- package/locales/kzKZ.js +6 -1
- package/locales/mk.d.ts +4 -0
- package/locales/mk.js +6 -1
- package/locales/nbNO.d.ts +4 -0
- package/locales/nbNO.js +8 -3
- package/locales/nlNL.d.ts +4 -0
- package/locales/nlNL.js +8 -3
- package/locales/plPL.d.ts +4 -0
- package/locales/plPL.js +8 -3
- package/locales/ptBR.d.ts +4 -0
- package/locales/ptBR.js +6 -1
- package/locales/roRO.d.ts +4 -0
- package/locales/roRO.js +6 -1
- package/locales/ruRU.d.ts +4 -0
- package/locales/ruRU.js +8 -3
- package/locales/skSK.d.ts +4 -0
- package/locales/skSK.js +8 -3
- package/locales/svSE.d.ts +4 -0
- package/locales/svSE.js +8 -3
- package/locales/trTR.d.ts +4 -0
- package/locales/trTR.js +8 -3
- package/locales/ukUA.d.ts +4 -0
- package/locales/ukUA.js +8 -3
- package/locales/urPK.d.ts +4 -0
- package/locales/urPK.js +6 -1
- package/locales/utils/getPickersLocalization.d.ts +4 -0
- package/locales/utils/pickersLocaleTextApi.d.ts +4 -0
- package/locales/viVN.d.ts +4 -0
- package/locales/viVN.js +8 -3
- package/locales/zhCN.d.ts +4 -0
- package/locales/zhCN.js +6 -1
- package/locales/zhHK.d.ts +4 -0
- package/locales/zhHK.js +6 -1
- package/modern/DateTimePicker/DateTimePickerTabs.js +7 -4
- package/modern/DateTimePicker/DateTimePickerToolbar.js +33 -17
- package/modern/PickersLayout/pickersLayoutClasses.js +3 -2
- package/modern/PickersLayout/usePickerLayout.js +2 -1
- package/modern/TimeClock/TimeClock.js +3 -3
- package/modern/dateTimeViewRenderers/dateTimeViewRenderers.js +4 -4
- package/modern/index.js +1 -1
- package/modern/internals/hooks/usePicker/usePicker.js +4 -2
- package/modern/internals/hooks/usePicker/usePickerViews.js +8 -3
- package/modern/internals/index.js +2 -2
- package/modern/locales/beBY.js +8 -3
- package/modern/locales/caES.js +7 -2
- package/modern/locales/csCZ.js +8 -3
- package/modern/locales/daDK.js +8 -3
- package/modern/locales/deDE.js +6 -1
- package/modern/locales/elGR.js +8 -3
- package/modern/locales/enUS.js +7 -3
- package/modern/locales/esES.js +8 -3
- package/modern/locales/eu.js +6 -1
- package/modern/locales/faIR.js +6 -1
- package/modern/locales/fiFI.js +8 -3
- package/modern/locales/frFR.js +6 -1
- package/modern/locales/heIL.js +6 -1
- package/modern/locales/huHU.js +6 -1
- package/modern/locales/isIS.js +8 -3
- package/modern/locales/itIT.js +8 -3
- package/modern/locales/jaJP.js +6 -1
- package/modern/locales/koKR.js +6 -1
- package/modern/locales/kzKZ.js +6 -1
- package/modern/locales/mk.js +6 -1
- package/modern/locales/nbNO.js +8 -3
- package/modern/locales/nlNL.js +8 -3
- package/modern/locales/plPL.js +8 -3
- package/modern/locales/ptBR.js +6 -1
- package/modern/locales/roRO.js +6 -1
- package/modern/locales/ruRU.js +8 -3
- package/modern/locales/skSK.js +8 -3
- package/modern/locales/svSE.js +8 -3
- package/modern/locales/trTR.js +8 -3
- package/modern/locales/ukUA.js +8 -3
- package/modern/locales/urPK.js +6 -1
- package/modern/locales/viVN.js +8 -3
- package/modern/locales/zhCN.js +6 -1
- package/modern/locales/zhHK.js +6 -1
- package/node/DateTimePicker/DateTimePickerTabs.js +8 -5
- package/node/DateTimePicker/DateTimePickerToolbar.js +34 -18
- package/node/PickersLayout/pickersLayoutClasses.js +5 -3
- package/node/PickersLayout/usePickerLayout.js +2 -1
- package/node/TimeClock/TimeClock.js +3 -3
- package/node/dateTimeViewRenderers/dateTimeViewRenderers.js +4 -4
- package/node/index.js +1 -1
- package/node/internals/hooks/usePicker/usePicker.js +4 -2
- package/node/internals/hooks/usePicker/usePickerViews.js +8 -3
- package/node/internals/index.js +12 -0
- package/node/locales/beBY.js +8 -3
- package/node/locales/caES.js +7 -2
- package/node/locales/csCZ.js +8 -3
- package/node/locales/daDK.js +8 -3
- package/node/locales/deDE.js +6 -1
- package/node/locales/elGR.js +8 -3
- package/node/locales/enUS.js +7 -3
- package/node/locales/esES.js +8 -3
- package/node/locales/eu.js +6 -1
- package/node/locales/faIR.js +6 -1
- package/node/locales/fiFI.js +8 -3
- package/node/locales/frFR.js +6 -1
- package/node/locales/heIL.js +6 -1
- package/node/locales/huHU.js +6 -1
- package/node/locales/isIS.js +8 -3
- package/node/locales/itIT.js +8 -3
- package/node/locales/jaJP.js +6 -1
- package/node/locales/koKR.js +6 -1
- package/node/locales/kzKZ.js +6 -1
- package/node/locales/mk.js +6 -1
- package/node/locales/nbNO.js +8 -3
- package/node/locales/nlNL.js +8 -3
- package/node/locales/plPL.js +8 -3
- package/node/locales/ptBR.js +6 -1
- package/node/locales/roRO.js +6 -1
- package/node/locales/ruRU.js +8 -3
- package/node/locales/skSK.js +8 -3
- package/node/locales/svSE.js +8 -3
- package/node/locales/trTR.js +8 -3
- package/node/locales/ukUA.js +8 -3
- package/node/locales/urPK.js +6 -1
- package/node/locales/viVN.js +8 -3
- package/node/locales/zhCN.js +6 -1
- package/node/locales/zhHK.js +6 -1
- package/package.json +4 -4
- package/timeViewRenderers/timeViewRenderers.d.ts +1 -1
|
@@ -105,7 +105,8 @@ const usePickerLayout = props => {
|
|
|
105
105
|
const Tabs = slots == null ? void 0 : slots.tabs;
|
|
106
106
|
const tabs = view && Tabs ? /*#__PURE__*/_jsx(Tabs, _extends({
|
|
107
107
|
view: view,
|
|
108
|
-
onViewChange: onViewChange
|
|
108
|
+
onViewChange: onViewChange,
|
|
109
|
+
className: classes.tabs
|
|
109
110
|
}, slotProps == null ? void 0 : slotProps.tabs)) : null;
|
|
110
111
|
|
|
111
112
|
// Shortcuts
|
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
# MUI
|
|
1
|
+
# MUI X Date Pickers
|
|
2
2
|
|
|
3
3
|
This package is the community edition of the date and time picker components.
|
|
4
|
-
It's part of [MUI
|
|
4
|
+
It's part of [MUI X](https://mui.com/x/), an open-core extension of MUI Core, with advanced components.
|
|
5
5
|
|
|
6
6
|
## Installation
|
|
7
7
|
|
package/TimeClock/TimeClock.js
CHANGED
|
@@ -218,7 +218,7 @@ export const TimeClock = /*#__PURE__*/React.forwardRef(function TimeClock(inProp
|
|
|
218
218
|
{
|
|
219
219
|
const handleHoursChange = (hourValue, isFinish) => {
|
|
220
220
|
const valueWithMeridiem = convertValueToMeridiem(hourValue, meridiemMode, ampm);
|
|
221
|
-
setValueAndGoToNextView(utils.setHours(valueOrReferenceDate, valueWithMeridiem), isFinish);
|
|
221
|
+
setValueAndGoToNextView(utils.setHours(valueOrReferenceDate, valueWithMeridiem), isFinish, 'hours');
|
|
222
222
|
};
|
|
223
223
|
return {
|
|
224
224
|
onChange: handleHoursChange,
|
|
@@ -238,7 +238,7 @@ export const TimeClock = /*#__PURE__*/React.forwardRef(function TimeClock(inProp
|
|
|
238
238
|
{
|
|
239
239
|
const minutesValue = utils.getMinutes(valueOrReferenceDate);
|
|
240
240
|
const handleMinutesChange = (minuteValue, isFinish) => {
|
|
241
|
-
setValueAndGoToNextView(utils.setMinutes(valueOrReferenceDate, minuteValue), isFinish);
|
|
241
|
+
setValueAndGoToNextView(utils.setMinutes(valueOrReferenceDate, minuteValue), isFinish, 'minutes');
|
|
242
242
|
};
|
|
243
243
|
return {
|
|
244
244
|
viewValue: minutesValue,
|
|
@@ -257,7 +257,7 @@ export const TimeClock = /*#__PURE__*/React.forwardRef(function TimeClock(inProp
|
|
|
257
257
|
{
|
|
258
258
|
const secondsValue = utils.getSeconds(valueOrReferenceDate);
|
|
259
259
|
const handleSecondsChange = (secondValue, isFinish) => {
|
|
260
|
-
setValueAndGoToNextView(utils.setSeconds(valueOrReferenceDate, secondValue), isFinish);
|
|
260
|
+
setValueAndGoToNextView(utils.setSeconds(valueOrReferenceDate, secondValue), isFinish, 'seconds');
|
|
261
261
|
};
|
|
262
262
|
return {
|
|
263
263
|
viewValue: secondsValue,
|
|
@@ -139,23 +139,23 @@ export const renderDesktopDateTimeView = ({
|
|
|
139
139
|
view: 'hours',
|
|
140
140
|
views: ['hours'],
|
|
141
141
|
focusedView: focusedView && isInternalTimeView(focusedView) ? 'hours' : null,
|
|
142
|
-
sx:
|
|
142
|
+
sx: [{
|
|
143
143
|
width: 'auto',
|
|
144
144
|
[`&.${digitalClockClasses.root}`]: {
|
|
145
145
|
maxHeight: VIEW_HEIGHT
|
|
146
146
|
}
|
|
147
|
-
}, Array.isArray(sx) ? sx : [sx])
|
|
147
|
+
}, ...(Array.isArray(sx) ? sx : [sx])]
|
|
148
148
|
})) : renderMultiSectionDigitalClockTimeView(_extends({}, commonTimeProps, {
|
|
149
149
|
view: isInternalTimeView(view) ? view : 'hours',
|
|
150
150
|
views: views.filter(isInternalTimeView),
|
|
151
151
|
focusedView: focusedView && isInternalTimeView(focusedView) ? focusedView : null,
|
|
152
|
-
sx:
|
|
152
|
+
sx: [{
|
|
153
153
|
borderBottom: 0,
|
|
154
154
|
width: 'auto',
|
|
155
155
|
[`.${multiSectionDigitalClockSectionClasses.root}`]: {
|
|
156
156
|
maxHeight: '100%'
|
|
157
157
|
}
|
|
158
|
-
}, Array.isArray(sx) ? sx : [sx])
|
|
158
|
+
}, ...(Array.isArray(sx) ? sx : [sx])]
|
|
159
159
|
}))]
|
|
160
160
|
})]
|
|
161
161
|
}), isActionBarVisible && /*#__PURE__*/_jsx(Divider, {})]
|
package/index.js
CHANGED
|
@@ -2,4 +2,4 @@ import { UsePickerParams, UsePickerProps, UsePickerResponse } from './usePicker.
|
|
|
2
2
|
import { InferError } from '../useValidation';
|
|
3
3
|
import { FieldSection } from '../../../models';
|
|
4
4
|
import { DateOrTimeViewWithMeridiem } from '../../models';
|
|
5
|
-
export declare const usePicker: <TValue, TDate, TView extends DateOrTimeViewWithMeridiem, TSection extends FieldSection, TExternalProps extends UsePickerProps<TValue, TDate, TView, TSection, any, any, any>, TAdditionalProps extends {}>({ props, valueManager, valueType, wrapperVariant, inputRef, additionalViewProps, validator, autoFocusView, }: UsePickerParams<TValue, TDate, TView, TSection, TExternalProps, TAdditionalProps>) => UsePickerResponse<TValue, TView, TSection, InferError<TExternalProps>>;
|
|
5
|
+
export declare const usePicker: <TValue, TDate, TView extends DateOrTimeViewWithMeridiem, TSection extends FieldSection, TExternalProps extends UsePickerProps<TValue, TDate, TView, TSection, any, any, any>, TAdditionalProps extends {}>({ props, valueManager, valueType, wrapperVariant, inputRef, additionalViewProps, validator, autoFocusView, rendererInterceptor, }: UsePickerParams<TValue, TDate, TView, TSection, TExternalProps, TAdditionalProps>) => UsePickerResponse<TValue, TView, TSection, InferError<TExternalProps>>;
|
|
@@ -11,7 +11,8 @@ export const usePicker = ({
|
|
|
11
11
|
inputRef,
|
|
12
12
|
additionalViewProps,
|
|
13
13
|
validator,
|
|
14
|
-
autoFocusView
|
|
14
|
+
autoFocusView,
|
|
15
|
+
rendererInterceptor
|
|
15
16
|
}) => {
|
|
16
17
|
if (process.env.NODE_ENV !== 'production') {
|
|
17
18
|
if (props.renderInput != null) {
|
|
@@ -30,7 +31,8 @@ export const usePicker = ({
|
|
|
30
31
|
inputRef,
|
|
31
32
|
additionalViewProps,
|
|
32
33
|
autoFocusView,
|
|
33
|
-
propsFromPickerValue: pickerValueResponse.viewProps
|
|
34
|
+
propsFromPickerValue: pickerValueResponse.viewProps,
|
|
35
|
+
rendererInterceptor
|
|
34
36
|
});
|
|
35
37
|
const pickerLayoutResponse = usePickerLayoutProps({
|
|
36
38
|
props,
|
|
@@ -10,7 +10,7 @@ export interface UsePickerBaseProps<TValue, TDate, TView extends DateOrTimeViewW
|
|
|
10
10
|
}
|
|
11
11
|
export interface UsePickerProps<TValue, TDate, TView extends DateOrTimeViewWithMeridiem, TSection extends FieldSection, TError, TExternalProps extends UsePickerViewsProps<TValue, TDate, TView, any, any>, TAdditionalProps extends {}> extends UsePickerValueProps<TValue, TSection, TError>, UsePickerViewsProps<TValue, TDate, TView, TExternalProps, TAdditionalProps>, UsePickerLayoutProps {
|
|
12
12
|
}
|
|
13
|
-
export interface UsePickerParams<TValue, TDate, TView extends DateOrTimeViewWithMeridiem, TSection extends FieldSection, TExternalProps extends UsePickerProps<TValue, TDate, TView, TSection, any, any, any>, TAdditionalProps extends {}> extends Pick<UsePickerValueParams<TValue, TDate, TSection, TExternalProps>, 'valueManager' | 'valueType' | 'wrapperVariant' | 'validator'>, Pick<UsePickerViewParams<TValue, TDate, TView, TExternalProps, TAdditionalProps>, 'additionalViewProps' | 'inputRef' | 'autoFocusView'> {
|
|
13
|
+
export interface UsePickerParams<TValue, TDate, TView extends DateOrTimeViewWithMeridiem, TSection extends FieldSection, TExternalProps extends UsePickerProps<TValue, TDate, TView, TSection, any, any, any>, TAdditionalProps extends {}> extends Pick<UsePickerValueParams<TValue, TDate, TSection, TExternalProps>, 'valueManager' | 'valueType' | 'wrapperVariant' | 'validator'>, Pick<UsePickerViewParams<TValue, TDate, TView, TExternalProps, TAdditionalProps>, 'additionalViewProps' | 'inputRef' | 'autoFocusView' | 'rendererInterceptor'> {
|
|
14
14
|
props: TExternalProps;
|
|
15
15
|
}
|
|
16
16
|
export interface UsePickerResponse<TValue, TView extends DateOrTimeViewWithMeridiem, TSection extends FieldSection, TError> extends Omit<UsePickerValueResponse<TValue, TSection, TError>, 'viewProps' | 'layoutProps'>, Omit<UsePickerViewsResponse<TView>, 'layoutProps'>, UsePickerLayoutPropsResponse<TValue, TView> {
|
|
@@ -13,7 +13,7 @@ export type PickerViewsRendererProps<TValue, TView extends DateOrTimeViewWithMer
|
|
|
13
13
|
focusedView: TView | null;
|
|
14
14
|
onFocusedViewChange: (viewToFocus: TView, hasFocus: boolean) => void;
|
|
15
15
|
};
|
|
16
|
-
type PickerViewRenderer<TValue, TView extends DateOrTimeViewWithMeridiem, TExternalProps extends PickerViewsRendererBaseExternalProps<TView>, TAdditionalProps extends {}> = (props: PickerViewsRendererProps<TValue, TView, TExternalProps, TAdditionalProps>) => React.ReactNode;
|
|
16
|
+
export type PickerViewRenderer<TValue, TView extends DateOrTimeViewWithMeridiem, TExternalProps extends PickerViewsRendererBaseExternalProps<TView>, TAdditionalProps extends {}> = (props: PickerViewsRendererProps<TValue, TView, TExternalProps, TAdditionalProps>) => React.ReactNode;
|
|
17
17
|
export type PickerViewRendererLookup<TValue, TView extends DateOrTimeViewWithMeridiem, TExternalProps extends PickerViewsRendererBaseExternalProps<any>, TAdditionalProps extends {}> = {
|
|
18
18
|
[K in TView]: PickerViewRenderer<TValue, K, TExternalProps, TAdditionalProps> | null;
|
|
19
19
|
};
|
|
@@ -65,6 +65,15 @@ export interface UsePickerViewParams<TValue, TDate, TView extends DateOrTimeView
|
|
|
65
65
|
additionalViewProps: TAdditionalProps;
|
|
66
66
|
inputRef?: React.RefObject<HTMLInputElement>;
|
|
67
67
|
autoFocusView: boolean;
|
|
68
|
+
/**
|
|
69
|
+
* A function that intercepts the regular picker rendering.
|
|
70
|
+
* Can be used to consume the provided `viewRenderers` and render a custom component wrapping them.
|
|
71
|
+
* @param {PickerViewRendererLookup<TValue, TView, TExternalProps, TAdditionalProps>} viewRenderers The `viewRenderers` that were provided to the picker component.
|
|
72
|
+
* @param {TView} popperView The current picker view.
|
|
73
|
+
* @param {any} rendererProps All the props that are being passed down to the renderer.
|
|
74
|
+
* @returns {React.ReactNode} A React node that will be rendered instead of the default renderer.
|
|
75
|
+
*/
|
|
76
|
+
rendererInterceptor?: (viewRenderers: PickerViewRendererLookup<TValue, TView, TExternalProps, TAdditionalProps>, popperView: TView, rendererProps: Omit<TExternalProps, 'className' | 'sx'> & TAdditionalProps & UsePickerValueViewsResponse<TValue>) => React.ReactNode;
|
|
68
77
|
}
|
|
69
78
|
export interface UsePickerViewsResponse<TView extends DateOrTimeViewWithMeridiem> {
|
|
70
79
|
/**
|
|
@@ -87,5 +96,5 @@ export interface UsePickerViewsLayoutResponse<TView extends DateOrTimeViewWithMe
|
|
|
87
96
|
* - Handles the switch between UI views and field views
|
|
88
97
|
* - Handles the focus management when switching views
|
|
89
98
|
*/
|
|
90
|
-
export declare const usePickerViews: <TValue, TDate, TView extends DateOrTimeViewWithMeridiem, TExternalProps extends UsePickerViewsProps<TValue, TDate, TView, any, any>, TAdditionalProps extends {}>({ props, propsFromPickerValue, additionalViewProps, inputRef, autoFocusView, }: UsePickerViewParams<TValue, TDate, TView, TExternalProps, TAdditionalProps>) => UsePickerViewsResponse<TView>;
|
|
99
|
+
export declare const usePickerViews: <TValue, TDate, TView extends DateOrTimeViewWithMeridiem, TExternalProps extends UsePickerViewsProps<TValue, TDate, TView, any, any>, TAdditionalProps extends {}>({ props, propsFromPickerValue, additionalViewProps, inputRef, autoFocusView, rendererInterceptor, }: UsePickerViewParams<TValue, TDate, TView, TExternalProps, TAdditionalProps>) => UsePickerViewsResponse<TView>;
|
|
91
100
|
export {};
|
|
@@ -30,7 +30,8 @@ export const usePickerViews = ({
|
|
|
30
30
|
propsFromPickerValue,
|
|
31
31
|
additionalViewProps,
|
|
32
32
|
inputRef,
|
|
33
|
-
autoFocusView
|
|
33
|
+
autoFocusView,
|
|
34
|
+
rendererInterceptor
|
|
34
35
|
}) => {
|
|
35
36
|
const {
|
|
36
37
|
onChange,
|
|
@@ -146,7 +147,7 @@ export const usePickerViews = ({
|
|
|
146
147
|
if (renderer == null) {
|
|
147
148
|
return null;
|
|
148
149
|
}
|
|
149
|
-
|
|
150
|
+
const rendererProps = _extends({}, propsToForwardToView, additionalViewProps, propsFromPickerValue, {
|
|
150
151
|
views,
|
|
151
152
|
timezone,
|
|
152
153
|
onChange: setValueAndGoToNextView,
|
|
@@ -156,7 +157,11 @@ export const usePickerViews = ({
|
|
|
156
157
|
onFocusedViewChange: setFocusedView,
|
|
157
158
|
showViewSwitcher: timeViewsCount > 1,
|
|
158
159
|
timeViewsCount
|
|
159
|
-
})
|
|
160
|
+
});
|
|
161
|
+
if (rendererInterceptor) {
|
|
162
|
+
return rendererInterceptor(viewRenderers, popperView, rendererProps);
|
|
163
|
+
}
|
|
164
|
+
return renderer(rendererProps);
|
|
160
165
|
}
|
|
161
166
|
};
|
|
162
167
|
};
|
package/internals/index.d.ts
CHANGED
|
@@ -20,16 +20,16 @@ export type { PickerPopperProps } from './components/PickersPopper';
|
|
|
20
20
|
export { pickersPopperClasses } from './components/pickersPopperClasses';
|
|
21
21
|
export type { PickersPopperClassKey, PickersPopperClasses, } from './components/pickersPopperClasses';
|
|
22
22
|
export { PickersToolbarButton } from './components/PickersToolbarButton';
|
|
23
|
-
export { DAY_MARGIN, DIALOG_WIDTH } from './constants/dimensions';
|
|
23
|
+
export { DAY_MARGIN, DIALOG_WIDTH, VIEW_HEIGHT } from './constants/dimensions';
|
|
24
24
|
export { useControlledValueWithTimezone } from './hooks/useValueWithTimezone';
|
|
25
25
|
export type { DesktopOnlyPickerProps } from './hooks/useDesktopPicker';
|
|
26
26
|
export { useField, createDateStrForInputFromSections, addPositionPropertiesToSections, } from './hooks/useField';
|
|
27
27
|
export type { UseFieldInternalProps, UseFieldParams, UseFieldResponse, UseFieldForwardedProps, FieldValueManager, FieldChangeHandler, FieldChangeHandlerContext, } from './hooks/useField';
|
|
28
28
|
export type { MobileOnlyPickerProps } from './hooks/useMobilePicker';
|
|
29
29
|
export { usePicker } from './hooks/usePicker';
|
|
30
|
-
export type { UsePickerResponse, UsePickerParams, UsePickerProps } from './hooks/usePicker';
|
|
30
|
+
export type { UsePickerResponse, UsePickerParams, UsePickerProps, UsePickerValueFieldResponse, } from './hooks/usePicker';
|
|
31
31
|
export type { UsePickerValueNonStaticProps, PickerValueManager, PickerSelectionState, } from './hooks/usePicker/usePickerValue.types';
|
|
32
|
-
export type { UsePickerViewsNonStaticProps, PickerViewRendererLookup, UsePickerViewsProps, } from './hooks/usePicker/usePickerViews';
|
|
32
|
+
export type { UsePickerViewsNonStaticProps, PickerViewRendererLookup, PickerViewRenderer, UsePickerViewsProps, } from './hooks/usePicker/usePickerViews';
|
|
33
33
|
export { useStaticPicker } from './hooks/useStaticPicker';
|
|
34
34
|
export type { StaticOnlyPickerProps, UseStaticPickerSlots, UseStaticPickerSlotProps, } from './hooks/useStaticPicker';
|
|
35
35
|
export { useLocalizationContext, useDefaultDates, useUtils, useLocaleText, useNow, } from './hooks/useUtils';
|
|
@@ -63,4 +63,4 @@ export { DayCalendar } from '../DateCalendar/DayCalendar';
|
|
|
63
63
|
export type { DayCalendarProps, DayCalendarSlots, DayCalendarSlotProps, ExportedDayCalendarProps, } from '../DateCalendar/DayCalendar';
|
|
64
64
|
export type { ExportedDateCalendarProps } from '../DateCalendar/DateCalendar.types';
|
|
65
65
|
export { useCalendarState } from '../DateCalendar/useCalendarState';
|
|
66
|
-
export { isTimeView } from './utils/time-utils';
|
|
66
|
+
export { isInternalTimeView, isTimeView } from './utils/time-utils';
|
package/internals/index.js
CHANGED
|
@@ -8,7 +8,7 @@ export { pickersToolbarTextClasses } from './components/pickersToolbarTextClasse
|
|
|
8
8
|
export { pickersArrowSwitcherClasses } from './components/PickersArrowSwitcher/pickersArrowSwitcherClasses';
|
|
9
9
|
export { pickersPopperClasses } from './components/pickersPopperClasses';
|
|
10
10
|
export { PickersToolbarButton } from './components/PickersToolbarButton';
|
|
11
|
-
export { DAY_MARGIN, DIALOG_WIDTH } from './constants/dimensions';
|
|
11
|
+
export { DAY_MARGIN, DIALOG_WIDTH, VIEW_HEIGHT } from './constants/dimensions';
|
|
12
12
|
export { useControlledValueWithTimezone } from './hooks/useValueWithTimezone';
|
|
13
13
|
export { useField, createDateStrForInputFromSections, addPositionPropertiesToSections } from './hooks/useField';
|
|
14
14
|
export { usePicker } from './hooks/usePicker';
|
|
@@ -32,4 +32,4 @@ export { applyDefaultViewProps } from './utils/views';
|
|
|
32
32
|
export { buildDeprecatedPropsWarning, buildWarning } from './utils/warning';
|
|
33
33
|
export { DayCalendar } from '../DateCalendar/DayCalendar';
|
|
34
34
|
export { useCalendarState } from '../DateCalendar/useCalendarState';
|
|
35
|
-
export { isTimeView } from './utils/time-utils';
|
|
35
|
+
export { isInternalTimeView, isTimeView } from './utils/time-utils';
|
|
@@ -5,11 +5,12 @@ export interface BaseTabsProps<TView extends DateOrTimeViewWithMeridiem> {
|
|
|
5
5
|
*/
|
|
6
6
|
view: TView;
|
|
7
7
|
/**
|
|
8
|
-
* Callback called when a tab is clicked
|
|
8
|
+
* Callback called when a tab is clicked.
|
|
9
9
|
* @template TView
|
|
10
10
|
* @param {TView} view The view to open
|
|
11
11
|
*/
|
|
12
12
|
onViewChange: (view: TView) => void;
|
|
13
13
|
}
|
|
14
14
|
export interface ExportedBaseTabsProps {
|
|
15
|
+
className?: string;
|
|
15
16
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
2
|
import * as React from 'react';
|
|
3
|
+
import clsx from 'clsx';
|
|
3
4
|
import PropTypes from 'prop-types';
|
|
4
5
|
import Tab from '@mui/material/Tab';
|
|
5
6
|
import Tabs, { tabsClasses } from '@mui/material/Tabs';
|
|
6
7
|
import { styled, useThemeProps } from '@mui/material/styles';
|
|
7
|
-
import
|
|
8
|
+
import composeClasses from '@mui/utils/composeClasses';
|
|
8
9
|
import { TimeIcon, DateRangeIcon } from '../icons';
|
|
9
10
|
import { useLocaleText } from '../internals/hooks/useUtils';
|
|
10
11
|
import { getDateTimePickerTabsUtilityClass } from './dateTimePickerTabsClasses';
|
|
@@ -71,7 +72,8 @@ var DateTimePickerTabs = function DateTimePickerTabs(inProps) {
|
|
|
71
72
|
timeIcon = _props$timeIcon === void 0 ? /*#__PURE__*/_jsx(TimeIcon, {}) : _props$timeIcon,
|
|
72
73
|
view = props.view,
|
|
73
74
|
_props$hidden = props.hidden,
|
|
74
|
-
hidden = _props$hidden === void 0 ? typeof window === 'undefined' || window.innerHeight < 667 : _props$hidden
|
|
75
|
+
hidden = _props$hidden === void 0 ? typeof window === 'undefined' || window.innerHeight < 667 : _props$hidden,
|
|
76
|
+
className = props.className;
|
|
75
77
|
var localeText = useLocaleText();
|
|
76
78
|
var classes = useUtilityClasses(props);
|
|
77
79
|
var handleChange = function handleChange(event, value) {
|
|
@@ -85,7 +87,7 @@ var DateTimePickerTabs = function DateTimePickerTabs(inProps) {
|
|
|
85
87
|
variant: "fullWidth",
|
|
86
88
|
value: viewToTab(view),
|
|
87
89
|
onChange: handleChange,
|
|
88
|
-
className: classes.root,
|
|
90
|
+
className: clsx(className, classes.root),
|
|
89
91
|
children: [/*#__PURE__*/_jsx(Tab, {
|
|
90
92
|
value: "date",
|
|
91
93
|
"aria-label": localeText.dateTableLabel,
|
|
@@ -110,6 +112,7 @@ process.env.NODE_ENV !== "production" ? DateTimePickerTabs.propTypes = {
|
|
|
110
112
|
* Override or extend the styles applied to the component.
|
|
111
113
|
*/
|
|
112
114
|
classes: PropTypes.object,
|
|
115
|
+
className: PropTypes.string,
|
|
113
116
|
/**
|
|
114
117
|
* Date tab icon.
|
|
115
118
|
* @default DateRange
|
|
@@ -121,7 +124,7 @@ process.env.NODE_ENV !== "production" ? DateTimePickerTabs.propTypes = {
|
|
|
121
124
|
*/
|
|
122
125
|
hidden: PropTypes.bool,
|
|
123
126
|
/**
|
|
124
|
-
* Callback called when a tab is clicked
|
|
127
|
+
* Callback called when a tab is clicked.
|
|
125
128
|
* @template TView
|
|
126
129
|
* @param {TView} view The view to open
|
|
127
130
|
*/
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
2
2
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
3
3
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
|
-
var _excluded = ["ampm", "ampmInClock", "value", "onChange", "view", "isLandscape", "onViewChange", "toolbarFormat", "toolbarPlaceholder", "views", "disabled", "readOnly", "toolbarVariant"];
|
|
4
|
+
var _excluded = ["ampm", "ampmInClock", "value", "onChange", "view", "isLandscape", "onViewChange", "toolbarFormat", "toolbarPlaceholder", "views", "disabled", "readOnly", "toolbarVariant", "toolbarTitle", "className"];
|
|
5
5
|
import * as React from 'react';
|
|
6
6
|
import PropTypes from 'prop-types';
|
|
7
7
|
import { styled, useThemeProps, useTheme } from '@mui/material/styles';
|
|
8
|
-
import
|
|
8
|
+
import composeClasses from '@mui/utils/composeClasses';
|
|
9
|
+
import clsx from 'clsx';
|
|
9
10
|
import { PickersToolbarText } from '../internals/components/PickersToolbarText';
|
|
10
11
|
import { PickersToolbar } from '../internals/components/PickersToolbar';
|
|
11
12
|
import { PickersToolbarButton } from '../internals/components/PickersToolbarButton';
|
|
@@ -14,6 +15,8 @@ import { dateTimePickerToolbarClasses, getDateTimePickerToolbarUtilityClass } fr
|
|
|
14
15
|
import { useMeridiemMode } from '../internals/hooks/date-helpers-hooks';
|
|
15
16
|
import { MULTI_SECTION_CLOCK_SECTION_WIDTH } from '../internals/constants/dimensions';
|
|
16
17
|
import { formatMeridiem } from '../internals/utils/date-utils';
|
|
18
|
+
import { pickersToolbarTextClasses } from '../internals/components/pickersToolbarTextClasses';
|
|
19
|
+
import { pickersToolbarClasses } from '../internals';
|
|
17
20
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
18
21
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
19
22
|
var useUtilityClasses = function useUtilityClasses(ownerState) {
|
|
@@ -40,14 +43,17 @@ var DateTimePickerToolbarRoot = styled(PickersToolbar, {
|
|
|
40
43
|
})(function (_ref) {
|
|
41
44
|
var theme = _ref.theme,
|
|
42
45
|
ownerState = _ref.ownerState;
|
|
43
|
-
return {
|
|
46
|
+
return _extends({
|
|
44
47
|
paddingLeft: ownerState.toolbarVariant === 'desktop' && !ownerState.isLandscape ? 24 : 16,
|
|
45
48
|
paddingRight: ownerState.toolbarVariant === 'desktop' && !ownerState.isLandscape ? 0 : 16,
|
|
46
49
|
borderBottom: ownerState.toolbarVariant === 'desktop' ? "1px solid ".concat((theme.vars || theme).palette.divider) : undefined,
|
|
47
50
|
borderRight: ownerState.toolbarVariant === 'desktop' && ownerState.isLandscape ? "1px solid ".concat((theme.vars || theme).palette.divider) : undefined,
|
|
48
51
|
justifyContent: 'space-around',
|
|
49
52
|
position: 'relative'
|
|
50
|
-
}
|
|
53
|
+
}, ownerState.toolbarVariant === 'desktop' && _defineProperty({}, "& .".concat(pickersToolbarClasses.content, " .").concat(pickersToolbarTextClasses.selected), {
|
|
54
|
+
color: (theme.vars || theme).palette.primary.main,
|
|
55
|
+
fontWeight: theme.typography.fontWeightBold
|
|
56
|
+
}));
|
|
51
57
|
});
|
|
52
58
|
DateTimePickerToolbarRoot.propTypes = {
|
|
53
59
|
// ----------------------------- Warning --------------------------------
|
|
@@ -83,9 +89,9 @@ var DateTimePickerToolbarTimeContainer = styled('div', {
|
|
|
83
89
|
overridesResolver: function overridesResolver(props, styles) {
|
|
84
90
|
return styles.timeContainer;
|
|
85
91
|
}
|
|
86
|
-
})(function (
|
|
87
|
-
var theme =
|
|
88
|
-
ownerState =
|
|
92
|
+
})(function (_ref3) {
|
|
93
|
+
var theme = _ref3.theme,
|
|
94
|
+
ownerState = _ref3.ownerState;
|
|
89
95
|
var direction = ownerState.isLandscape && ownerState.toolbarVariant !== 'desktop' ? 'column' : 'row';
|
|
90
96
|
return _extends({
|
|
91
97
|
display: 'flex',
|
|
@@ -104,9 +110,9 @@ var DateTimePickerToolbarTimeDigitsContainer = styled('div', {
|
|
|
104
110
|
overridesResolver: function overridesResolver(props, styles) {
|
|
105
111
|
return styles.timeDigitsContainer;
|
|
106
112
|
}
|
|
107
|
-
})(function (
|
|
108
|
-
var theme =
|
|
109
|
-
ownerState =
|
|
113
|
+
})(function (_ref4) {
|
|
114
|
+
var theme = _ref4.theme,
|
|
115
|
+
ownerState = _ref4.ownerState;
|
|
110
116
|
return _extends({
|
|
111
117
|
display: 'flex'
|
|
112
118
|
}, ownerState.toolbarVariant === 'desktop' && {
|
|
@@ -130,8 +136,8 @@ var DateTimePickerToolbarSeparator = styled(PickersToolbarText, {
|
|
|
130
136
|
overridesResolver: function overridesResolver(props, styles) {
|
|
131
137
|
return styles.separator;
|
|
132
138
|
}
|
|
133
|
-
})(function (
|
|
134
|
-
var ownerState =
|
|
139
|
+
})(function (_ref5) {
|
|
140
|
+
var ownerState = _ref5.ownerState;
|
|
135
141
|
return {
|
|
136
142
|
margin: ownerState.toolbarVariant === 'desktop' ? 0 : '0 4px 0 2px',
|
|
137
143
|
cursor: 'default'
|
|
@@ -145,8 +151,8 @@ var DateTimePickerToolbarAmPmSelection = styled('div', {
|
|
|
145
151
|
overridesResolver: function overridesResolver(props, styles) {
|
|
146
152
|
return [_defineProperty({}, ".".concat(dateTimePickerToolbarClasses.ampmLabel), styles.ampmLabel), _defineProperty({}, "&.".concat(dateTimePickerToolbarClasses.ampmLandscape), styles.ampmLandscape), styles.ampmSelection];
|
|
147
153
|
}
|
|
148
|
-
})(function (
|
|
149
|
-
var ownerState =
|
|
154
|
+
})(function (_ref8) {
|
|
155
|
+
var ownerState = _ref8.ownerState;
|
|
150
156
|
return _extends({
|
|
151
157
|
display: 'flex',
|
|
152
158
|
flexDirection: 'column',
|
|
@@ -192,6 +198,8 @@ function DateTimePickerToolbar(inProps) {
|
|
|
192
198
|
readOnly = props.readOnly,
|
|
193
199
|
_props$toolbarVariant = props.toolbarVariant,
|
|
194
200
|
toolbarVariant = _props$toolbarVariant === void 0 ? 'mobile' : _props$toolbarVariant,
|
|
201
|
+
inToolbarTitle = props.toolbarTitle,
|
|
202
|
+
className = props.className,
|
|
195
203
|
other = _objectWithoutProperties(props, _excluded);
|
|
196
204
|
var ownerState = props;
|
|
197
205
|
var utils = useUtils();
|
|
@@ -205,6 +213,7 @@ function DateTimePickerToolbar(inProps) {
|
|
|
205
213
|
var classes = useUtilityClasses(_extends({}, ownerState, {
|
|
206
214
|
theme: theme
|
|
207
215
|
}));
|
|
216
|
+
var toolbarTitle = inToolbarTitle != null ? inToolbarTitle : localeText.dateTimePickerToolbarTitle;
|
|
208
217
|
var formatHours = function formatHours(time) {
|
|
209
218
|
return ampm ? utils.format(time, 'hours12h') : utils.format(time, 'hours24h');
|
|
210
219
|
};
|
|
@@ -218,9 +227,9 @@ function DateTimePickerToolbar(inProps) {
|
|
|
218
227
|
return utils.format(value, 'shortDate');
|
|
219
228
|
}, [value, toolbarFormat, toolbarPlaceholder, utils]);
|
|
220
229
|
return /*#__PURE__*/_jsxs(DateTimePickerToolbarRoot, _extends({
|
|
221
|
-
toolbarTitle: localeText.dateTimePickerToolbarTitle,
|
|
222
230
|
isLandscape: isLandscape,
|
|
223
|
-
className: classes.root
|
|
231
|
+
className: clsx(classes.root, className),
|
|
232
|
+
toolbarTitle: toolbarTitle
|
|
224
233
|
}, other, {
|
|
225
234
|
ownerState: ownerState,
|
|
226
235
|
children: [/*#__PURE__*/_jsxs(DateTimePickerToolbarDateContainer, {
|
|
@@ -249,16 +258,16 @@ function DateTimePickerToolbar(inProps) {
|
|
|
249
258
|
children: [/*#__PURE__*/_jsxs(DateTimePickerToolbarTimeDigitsContainer, {
|
|
250
259
|
className: classes.timeDigitsContainer,
|
|
251
260
|
ownerState: ownerState,
|
|
252
|
-
children: [views.includes('hours') && /*#__PURE__*/
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
261
|
+
children: [views.includes('hours') && /*#__PURE__*/_jsxs(React.Fragment, {
|
|
262
|
+
children: [/*#__PURE__*/_jsx(PickersToolbarButton, {
|
|
263
|
+
variant: isDesktop ? 'h5' : 'h3',
|
|
264
|
+
width: isDesktop && !isLandscape ? MULTI_SECTION_CLOCK_SECTION_WIDTH : undefined,
|
|
265
|
+
onClick: function onClick() {
|
|
266
|
+
return onViewChange('hours');
|
|
267
|
+
},
|
|
268
|
+
selected: view === 'hours',
|
|
269
|
+
value: value ? formatHours(value) : '--'
|
|
270
|
+
}), /*#__PURE__*/_jsx(DateTimePickerToolbarSeparator, {
|
|
262
271
|
variant: isDesktop ? 'h5' : 'h3',
|
|
263
272
|
value: ":",
|
|
264
273
|
className: classes.separator,
|
|
@@ -269,8 +278,9 @@ function DateTimePickerToolbar(inProps) {
|
|
|
269
278
|
onClick: function onClick() {
|
|
270
279
|
return onViewChange('minutes');
|
|
271
280
|
},
|
|
272
|
-
selected: view === 'minutes',
|
|
273
|
-
value: value ? utils.format(value, 'minutes') : '--'
|
|
281
|
+
selected: view === 'minutes' || !views.includes('minutes') && view === 'hours',
|
|
282
|
+
value: value ? utils.format(value, 'minutes') : '--',
|
|
283
|
+
disabled: !views.includes('minutes')
|
|
274
284
|
})]
|
|
275
285
|
}), views.includes('seconds') && /*#__PURE__*/_jsxs(React.Fragment, {
|
|
276
286
|
children: [/*#__PURE__*/_jsx(DateTimePickerToolbarSeparator, {
|
|
@@ -360,12 +370,16 @@ process.env.NODE_ENV !== "production" ? DateTimePickerToolbar.propTypes = {
|
|
|
360
370
|
* @default "––"
|
|
361
371
|
*/
|
|
362
372
|
toolbarPlaceholder: PropTypes.node,
|
|
373
|
+
/**
|
|
374
|
+
* If provided, it will be used instead of `dateTimePickerToolbarTitle` from localization.
|
|
375
|
+
*/
|
|
376
|
+
toolbarTitle: PropTypes.node,
|
|
363
377
|
toolbarVariant: PropTypes.oneOf(['desktop', 'mobile']),
|
|
364
378
|
value: PropTypes.any,
|
|
365
379
|
/**
|
|
366
380
|
* Currently visible picker view.
|
|
367
381
|
*/
|
|
368
|
-
view: PropTypes.oneOf(['day', 'hours', 'meridiem', 'minutes', 'month', 'seconds', 'year'])
|
|
382
|
+
view: PropTypes.oneOf(['day', 'hours', 'meridiem', 'minutes', 'month', 'seconds', 'year']),
|
|
369
383
|
views: PropTypes.arrayOf(PropTypes.oneOf(['day', 'hours', 'meridiem', 'minutes', 'month', 'seconds', 'year']).isRequired).isRequired
|
|
370
384
|
} : void 0;
|
|
371
385
|
export { DateTimePickerToolbar };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import generateUtilityClass from '@mui/utils/generateUtilityClass';
|
|
2
|
+
import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
|
|
2
3
|
export function getPickersLayoutUtilityClass(slot) {
|
|
3
4
|
return generateUtilityClass('MuiPickersLayout', slot);
|
|
4
5
|
}
|
|
5
|
-
export var pickersLayoutClasses = generateUtilityClasses('MuiPickersLayout', ['root', 'landscape', 'contentWrapper', 'toolbar', 'actionBar', 'shortcuts']);
|
|
6
|
+
export var pickersLayoutClasses = generateUtilityClasses('MuiPickersLayout', ['root', 'landscape', 'contentWrapper', 'toolbar', 'actionBar', 'tabs', 'shortcuts']);
|
|
@@ -98,7 +98,8 @@ var usePickerLayout = function usePickerLayout(props) {
|
|
|
98
98
|
var Tabs = slots == null ? void 0 : slots.tabs;
|
|
99
99
|
var tabs = view && Tabs ? /*#__PURE__*/_jsx(Tabs, _extends({
|
|
100
100
|
view: view,
|
|
101
|
-
onViewChange: onViewChange
|
|
101
|
+
onViewChange: onViewChange,
|
|
102
|
+
className: classes.tabs
|
|
102
103
|
}, slotProps == null ? void 0 : slotProps.tabs)) : null;
|
|
103
104
|
|
|
104
105
|
// Shortcuts
|
|
@@ -220,7 +220,7 @@ export var TimeClock = /*#__PURE__*/React.forwardRef(function TimeClock(inProps,
|
|
|
220
220
|
{
|
|
221
221
|
var handleHoursChange = function handleHoursChange(hourValue, isFinish) {
|
|
222
222
|
var valueWithMeridiem = convertValueToMeridiem(hourValue, meridiemMode, ampm);
|
|
223
|
-
setValueAndGoToNextView(utils.setHours(valueOrReferenceDate, valueWithMeridiem), isFinish);
|
|
223
|
+
setValueAndGoToNextView(utils.setHours(valueOrReferenceDate, valueWithMeridiem), isFinish, 'hours');
|
|
224
224
|
};
|
|
225
225
|
return {
|
|
226
226
|
onChange: handleHoursChange,
|
|
@@ -242,7 +242,7 @@ export var TimeClock = /*#__PURE__*/React.forwardRef(function TimeClock(inProps,
|
|
|
242
242
|
{
|
|
243
243
|
var minutesValue = utils.getMinutes(valueOrReferenceDate);
|
|
244
244
|
var handleMinutesChange = function handleMinutesChange(minuteValue, isFinish) {
|
|
245
|
-
setValueAndGoToNextView(utils.setMinutes(valueOrReferenceDate, minuteValue), isFinish);
|
|
245
|
+
setValueAndGoToNextView(utils.setMinutes(valueOrReferenceDate, minuteValue), isFinish, 'minutes');
|
|
246
246
|
};
|
|
247
247
|
return {
|
|
248
248
|
viewValue: minutesValue,
|
|
@@ -263,7 +263,7 @@ export var TimeClock = /*#__PURE__*/React.forwardRef(function TimeClock(inProps,
|
|
|
263
263
|
{
|
|
264
264
|
var secondsValue = utils.getSeconds(valueOrReferenceDate);
|
|
265
265
|
var handleSecondsChange = function handleSecondsChange(secondValue, isFinish) {
|
|
266
|
-
setValueAndGoToNextView(utils.setSeconds(valueOrReferenceDate, secondValue), isFinish);
|
|
266
|
+
setValueAndGoToNextView(utils.setSeconds(valueOrReferenceDate, secondValue), isFinish, 'seconds');
|
|
267
267
|
};
|
|
268
268
|
return {
|
|
269
269
|
viewValue: secondsValue,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
2
3
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
4
|
import * as React from 'react';
|
|
4
5
|
import Divider from '@mui/material/Divider';
|
|
@@ -139,21 +140,21 @@ export var renderDesktopDateTimeView = function renderDesktopDateTimeView(_ref)
|
|
|
139
140
|
view: 'hours',
|
|
140
141
|
views: ['hours'],
|
|
141
142
|
focusedView: focusedView && isInternalTimeView(focusedView) ? 'hours' : null,
|
|
142
|
-
sx:
|
|
143
|
+
sx: [_defineProperty({
|
|
143
144
|
width: 'auto'
|
|
144
145
|
}, "&.".concat(digitalClockClasses.root), {
|
|
145
146
|
maxHeight: VIEW_HEIGHT
|
|
146
|
-
})
|
|
147
|
+
})].concat(_toConsumableArray(Array.isArray(sx) ? sx : [sx]))
|
|
147
148
|
})) : renderMultiSectionDigitalClockTimeView(_extends({}, commonTimeProps, {
|
|
148
149
|
view: isInternalTimeView(view) ? view : 'hours',
|
|
149
150
|
views: views.filter(isInternalTimeView),
|
|
150
151
|
focusedView: focusedView && isInternalTimeView(focusedView) ? focusedView : null,
|
|
151
|
-
sx:
|
|
152
|
+
sx: [_defineProperty({
|
|
152
153
|
borderBottom: 0,
|
|
153
154
|
width: 'auto'
|
|
154
155
|
}, ".".concat(multiSectionDigitalClockSectionClasses.root), {
|
|
155
156
|
maxHeight: '100%'
|
|
156
|
-
})
|
|
157
|
+
})].concat(_toConsumableArray(Array.isArray(sx) ? sx : [sx]))
|
|
157
158
|
}))]
|
|
158
159
|
})]
|
|
159
160
|
}), isActionBarVisible && /*#__PURE__*/_jsx(Divider, {})]
|
package/legacy/index.js
CHANGED
|
@@ -11,7 +11,8 @@ export var usePicker = function usePicker(_ref) {
|
|
|
11
11
|
inputRef = _ref.inputRef,
|
|
12
12
|
additionalViewProps = _ref.additionalViewProps,
|
|
13
13
|
validator = _ref.validator,
|
|
14
|
-
autoFocusView = _ref.autoFocusView
|
|
14
|
+
autoFocusView = _ref.autoFocusView,
|
|
15
|
+
rendererInterceptor = _ref.rendererInterceptor;
|
|
15
16
|
if (process.env.NODE_ENV !== 'production') {
|
|
16
17
|
if (props.renderInput != null) {
|
|
17
18
|
warnRenderInputIsDefined();
|
|
@@ -29,7 +30,8 @@ export var usePicker = function usePicker(_ref) {
|
|
|
29
30
|
inputRef: inputRef,
|
|
30
31
|
additionalViewProps: additionalViewProps,
|
|
31
32
|
autoFocusView: autoFocusView,
|
|
32
|
-
propsFromPickerValue: pickerValueResponse.viewProps
|
|
33
|
+
propsFromPickerValue: pickerValueResponse.viewProps,
|
|
34
|
+
rendererInterceptor: rendererInterceptor
|
|
33
35
|
});
|
|
34
36
|
var pickerLayoutResponse = usePickerLayoutProps({
|
|
35
37
|
props: props,
|
|
@@ -31,7 +31,8 @@ export var usePickerViews = function usePickerViews(_ref) {
|
|
|
31
31
|
propsFromPickerValue = _ref.propsFromPickerValue,
|
|
32
32
|
additionalViewProps = _ref.additionalViewProps,
|
|
33
33
|
inputRef = _ref.inputRef,
|
|
34
|
-
autoFocusView = _ref.autoFocusView
|
|
34
|
+
autoFocusView = _ref.autoFocusView,
|
|
35
|
+
rendererInterceptor = _ref.rendererInterceptor;
|
|
35
36
|
var onChange = propsFromPickerValue.onChange,
|
|
36
37
|
open = propsFromPickerValue.open,
|
|
37
38
|
onSelectedSectionsChange = propsFromPickerValue.onSelectedSectionsChange,
|
|
@@ -151,7 +152,7 @@ export var usePickerViews = function usePickerViews(_ref) {
|
|
|
151
152
|
if (renderer == null) {
|
|
152
153
|
return null;
|
|
153
154
|
}
|
|
154
|
-
|
|
155
|
+
var rendererProps = _extends({}, propsToForwardToView, additionalViewProps, propsFromPickerValue, {
|
|
155
156
|
views: views,
|
|
156
157
|
timezone: timezone,
|
|
157
158
|
onChange: setValueAndGoToNextView,
|
|
@@ -161,7 +162,11 @@ export var usePickerViews = function usePickerViews(_ref) {
|
|
|
161
162
|
onFocusedViewChange: setFocusedView,
|
|
162
163
|
showViewSwitcher: timeViewsCount > 1,
|
|
163
164
|
timeViewsCount: timeViewsCount
|
|
164
|
-
})
|
|
165
|
+
});
|
|
166
|
+
if (rendererInterceptor) {
|
|
167
|
+
return rendererInterceptor(viewRenderers, popperView, rendererProps);
|
|
168
|
+
}
|
|
169
|
+
return renderer(rendererProps);
|
|
165
170
|
}
|
|
166
171
|
};
|
|
167
172
|
};
|
|
@@ -8,7 +8,7 @@ export { pickersToolbarTextClasses } from './components/pickersToolbarTextClasse
|
|
|
8
8
|
export { pickersArrowSwitcherClasses } from './components/PickersArrowSwitcher/pickersArrowSwitcherClasses';
|
|
9
9
|
export { pickersPopperClasses } from './components/pickersPopperClasses';
|
|
10
10
|
export { PickersToolbarButton } from './components/PickersToolbarButton';
|
|
11
|
-
export { DAY_MARGIN, DIALOG_WIDTH } from './constants/dimensions';
|
|
11
|
+
export { DAY_MARGIN, DIALOG_WIDTH, VIEW_HEIGHT } from './constants/dimensions';
|
|
12
12
|
export { useControlledValueWithTimezone } from './hooks/useValueWithTimezone';
|
|
13
13
|
export { useField, createDateStrForInputFromSections, addPositionPropertiesToSections } from './hooks/useField';
|
|
14
14
|
export { usePicker } from './hooks/usePicker';
|
|
@@ -32,4 +32,4 @@ export { applyDefaultViewProps } from './utils/views';
|
|
|
32
32
|
export { buildDeprecatedPropsWarning, buildWarning } from './utils/warning';
|
|
33
33
|
export { DayCalendar } from '../DateCalendar/DayCalendar';
|
|
34
34
|
export { useCalendarState } from '../DateCalendar/useCalendarState';
|
|
35
|
-
export { isTimeView } from './utils/time-utils';
|
|
35
|
+
export { isInternalTimeView, isTimeView } from './utils/time-utils';
|