@mui/x-date-pickers 8.0.0-alpha.4 → 8.0.0-alpha.6
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 +182 -0
- package/DatePicker/DatePickerToolbar.d.ts +1 -2
- package/DatePicker/DatePickerToolbar.js +6 -17
- package/DateTimePicker/DateTimePicker.types.d.ts +2 -2
- package/DateTimePicker/DateTimePickerTabs.d.ts +2 -5
- package/DateTimePicker/DateTimePickerTabs.js +6 -13
- package/DateTimePicker/DateTimePickerToolbar.d.ts +8 -4
- package/DateTimePicker/DateTimePickerToolbar.js +13 -24
- package/DateTimePicker/shared.d.ts +2 -2
- package/DesktopDatePicker/DesktopDatePicker.types.d.ts +2 -3
- package/DesktopDateTimePicker/DesktopDateTimePicker.types.d.ts +2 -2
- package/DesktopDateTimePicker/DesktopDateTimePickerLayout.d.ts +1 -2
- package/DesktopDateTimePicker/DesktopDateTimePickerLayout.js +1 -11
- package/DesktopTimePicker/DesktopTimePicker.types.d.ts +2 -2
- package/MobileDatePicker/MobileDatePicker.types.d.ts +2 -3
- package/MobileDateTimePicker/MobileDateTimePicker.types.d.ts +4 -4
- package/MobileTimePicker/MobileTimePicker.types.d.ts +4 -4
- package/MonthCalendar/MonthCalendar.d.ts +1 -1
- package/MonthCalendar/MonthCalendar.js +31 -11
- package/MonthCalendar/MonthCalendar.types.d.ts +2 -2
- package/MonthCalendar/MonthCalendarButton.d.ts +24 -0
- package/MonthCalendar/{PickersMonth.js → MonthCalendarButton.js} +20 -61
- package/MonthCalendar/index.d.ts +0 -3
- package/MonthCalendar/index.js +1 -2
- package/MonthCalendar/monthCalendarClasses.d.ts +7 -1
- package/MonthCalendar/monthCalendarClasses.js +1 -1
- package/MultiSectionDigitalClock/MultiSectionDigitalClock.js +3 -0
- package/PickersActionBar/PickersActionBar.d.ts +0 -4
- package/PickersActionBar/PickersActionBar.js +12 -13
- package/PickersLayout/PickersLayout.d.ts +2 -2
- package/PickersLayout/PickersLayout.js +1 -11
- package/PickersLayout/PickersLayout.types.d.ts +12 -14
- package/PickersLayout/usePickerLayout.d.ts +2 -2
- package/PickersLayout/usePickerLayout.js +3 -18
- package/PickersSectionList/PickersSectionList.js +21 -16
- package/PickersSectionList/PickersSectionList.types.d.ts +13 -6
- package/PickersTextField/PickersFilledInput/PickersFilledInput.d.ts +7 -0
- package/PickersTextField/PickersFilledInput/PickersFilledInput.js +34 -28
- package/PickersTextField/PickersFilledInput/pickersFilledInputClasses.d.ts +1 -1
- package/PickersTextField/PickersInput/PickersInput.js +20 -14
- package/PickersTextField/PickersInput/pickersInputClasses.d.ts +3 -2
- package/PickersTextField/PickersInput/pickersInputClasses.js +1 -1
- package/PickersTextField/PickersInputBase/PickersInputBase.d.ts +3 -6
- package/PickersTextField/PickersInputBase/PickersInputBase.js +36 -37
- package/PickersTextField/PickersInputBase/PickersInputBase.types.d.ts +1 -0
- package/PickersTextField/PickersOutlinedInput/Outline.d.ts +0 -1
- package/PickersTextField/PickersOutlinedInput/Outline.js +13 -10
- package/PickersTextField/PickersOutlinedInput/PickersOutlinedInput.js +8 -14
- package/PickersTextField/PickersTextField.js +75 -62
- package/PickersTextField/PickersTextField.types.d.ts +43 -4
- package/PickersTextField/usePickerTextFieldOwnerState.d.ts +4 -0
- package/PickersTextField/usePickerTextFieldOwnerState.js +11 -0
- package/StaticDatePicker/StaticDatePicker.types.d.ts +2 -3
- package/StaticDateTimePicker/StaticDateTimePicker.types.d.ts +2 -2
- package/StaticTimePicker/StaticTimePicker.types.d.ts +2 -2
- package/TimeClock/Clock.d.ts +4 -0
- package/TimeClock/Clock.js +9 -6
- package/TimeClock/TimeClock.js +21 -4
- package/TimePicker/TimePicker.types.d.ts +2 -2
- package/TimePicker/TimePickerToolbar.d.ts +2 -2
- package/TimePicker/TimePickerToolbar.js +6 -20
- package/YearCalendar/YearCalendar.js +46 -13
- package/YearCalendar/YearCalendar.types.d.ts +2 -2
- package/YearCalendar/YearCalendarButton.d.ts +23 -0
- package/YearCalendar/{PickersYear.js → YearCalendarButton.js} +20 -59
- package/YearCalendar/index.d.ts +0 -3
- package/YearCalendar/index.js +1 -2
- package/YearCalendar/yearCalendarClasses.d.ts +7 -1
- package/YearCalendar/yearCalendarClasses.js +1 -1
- package/hooks/index.d.ts +1 -0
- package/hooks/index.js +2 -1
- package/hooks/usePickerActionsContext.d.ts +5 -0
- package/hooks/usePickerActionsContext.js +16 -0
- package/hooks/usePickerContext.d.ts +3 -1
- package/hooks/usePickerContext.js +0 -1
- package/index.js +1 -1
- package/internals/components/PickerProvider.d.ts +11 -6
- package/internals/components/PickerProvider.js +12 -6
- package/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +3 -3
- package/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.types.d.ts +1 -1
- package/internals/components/PickersModalDialog.d.ts +1 -3
- package/internals/components/PickersModalDialog.js +9 -3
- package/internals/components/PickersPopper.d.ts +1 -3
- package/internals/components/PickersPopper.js +11 -6
- package/internals/components/PickersToolbar.d.ts +3 -3
- package/internals/hooks/useDesktopPicker/useDesktopPicker.js +9 -9
- package/internals/hooks/useDesktopPicker/useDesktopPicker.types.d.ts +5 -5
- package/internals/hooks/useFieldOwnerState.d.ts +1 -0
- package/internals/hooks/useFieldOwnerState.js +6 -2
- package/internals/hooks/useMobilePicker/useMobilePicker.js +8 -7
- package/internals/hooks/useMobilePicker/useMobilePicker.types.d.ts +5 -5
- package/internals/hooks/usePicker/usePicker.js +1 -3
- package/internals/hooks/usePicker/usePicker.types.d.ts +2 -2
- package/internals/hooks/usePicker/usePickerProvider.js +5 -4
- package/internals/hooks/usePicker/usePickerValue.js +46 -64
- package/internals/hooks/usePicker/usePickerValue.types.d.ts +38 -17
- package/internals/hooks/usePicker/usePickerViews.d.ts +15 -4
- package/internals/hooks/usePicker/usePickerViews.js +9 -7
- package/internals/hooks/useStaticPicker/useStaticPicker.types.d.ts +4 -4
- package/internals/index.d.ts +4 -4
- package/internals/index.js +1 -1
- package/internals/models/props/tabs.d.ts +0 -13
- package/internals/models/props/toolbar.d.ts +1 -16
- package/models/fields.d.ts +11 -1
- package/modern/DatePicker/DatePickerToolbar.js +6 -17
- package/modern/DateTimePicker/DateTimePickerTabs.js +6 -13
- package/modern/DateTimePicker/DateTimePickerToolbar.js +13 -24
- package/modern/DesktopDateTimePicker/DesktopDateTimePickerLayout.js +1 -11
- package/modern/MonthCalendar/MonthCalendar.js +31 -11
- package/modern/MonthCalendar/{PickersMonth.js → MonthCalendarButton.js} +20 -61
- package/modern/MonthCalendar/index.js +1 -2
- package/modern/MonthCalendar/monthCalendarClasses.js +1 -1
- package/modern/MultiSectionDigitalClock/MultiSectionDigitalClock.js +3 -0
- package/modern/PickersActionBar/PickersActionBar.js +12 -13
- package/modern/PickersLayout/PickersLayout.js +1 -11
- package/modern/PickersLayout/usePickerLayout.js +3 -18
- package/modern/PickersSectionList/PickersSectionList.js +21 -16
- package/modern/PickersTextField/PickersFilledInput/PickersFilledInput.js +34 -28
- package/modern/PickersTextField/PickersInput/PickersInput.js +20 -14
- package/modern/PickersTextField/PickersInput/pickersInputClasses.js +1 -1
- package/modern/PickersTextField/PickersInputBase/PickersInputBase.js +36 -37
- package/modern/PickersTextField/PickersOutlinedInput/Outline.js +13 -10
- package/modern/PickersTextField/PickersOutlinedInput/PickersOutlinedInput.js +8 -14
- package/modern/PickersTextField/PickersTextField.js +75 -62
- package/modern/PickersTextField/usePickerTextFieldOwnerState.js +11 -0
- package/modern/TimeClock/Clock.js +9 -6
- package/modern/TimeClock/TimeClock.js +21 -4
- package/modern/TimePicker/TimePickerToolbar.js +6 -20
- package/modern/YearCalendar/YearCalendar.js +46 -13
- package/modern/YearCalendar/{PickersYear.js → YearCalendarButton.js} +20 -59
- package/modern/YearCalendar/index.js +1 -2
- package/modern/YearCalendar/yearCalendarClasses.js +1 -1
- package/modern/hooks/index.js +2 -1
- package/modern/hooks/usePickerActionsContext.js +16 -0
- package/modern/hooks/usePickerContext.js +0 -1
- package/modern/index.js +1 -1
- package/modern/internals/components/PickerProvider.js +12 -6
- package/modern/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +3 -3
- package/modern/internals/components/PickersModalDialog.js +9 -3
- package/modern/internals/components/PickersPopper.js +11 -6
- package/modern/internals/hooks/useDesktopPicker/useDesktopPicker.js +9 -9
- package/modern/internals/hooks/useFieldOwnerState.js +6 -2
- package/modern/internals/hooks/useMobilePicker/useMobilePicker.js +8 -7
- package/modern/internals/hooks/usePicker/usePicker.js +1 -3
- package/modern/internals/hooks/usePicker/usePickerProvider.js +5 -4
- package/modern/internals/hooks/usePicker/usePickerValue.js +46 -64
- package/modern/internals/hooks/usePicker/usePickerViews.js +9 -7
- package/modern/internals/index.js +1 -1
- package/node/DatePicker/DatePickerToolbar.js +6 -17
- package/node/DateTimePicker/DateTimePickerTabs.js +6 -13
- package/node/DateTimePicker/DateTimePickerToolbar.js +14 -25
- package/node/DesktopDateTimePicker/DesktopDateTimePickerLayout.js +1 -11
- package/node/MonthCalendar/MonthCalendar.js +31 -11
- package/node/MonthCalendar/{PickersMonth.js → MonthCalendarButton.js} +20 -61
- package/node/MonthCalendar/index.js +1 -8
- package/node/MonthCalendar/monthCalendarClasses.js +1 -1
- package/node/MultiSectionDigitalClock/MultiSectionDigitalClock.js +3 -0
- package/node/PickersActionBar/PickersActionBar.js +12 -13
- package/node/PickersLayout/PickersLayout.js +1 -11
- package/node/PickersLayout/usePickerLayout.js +3 -18
- package/node/PickersSectionList/PickersSectionList.js +21 -16
- package/node/PickersTextField/PickersFilledInput/PickersFilledInput.js +34 -28
- package/node/PickersTextField/PickersInput/PickersInput.js +20 -14
- package/node/PickersTextField/PickersInput/pickersInputClasses.js +1 -1
- package/node/PickersTextField/PickersInputBase/PickersInputBase.js +36 -37
- package/node/PickersTextField/PickersOutlinedInput/Outline.js +13 -10
- package/node/PickersTextField/PickersOutlinedInput/PickersOutlinedInput.js +8 -14
- package/node/PickersTextField/PickersTextField.js +75 -62
- package/node/PickersTextField/usePickerTextFieldOwnerState.js +18 -0
- package/node/TimeClock/Clock.js +9 -6
- package/node/TimeClock/TimeClock.js +21 -4
- package/node/TimePicker/TimePickerToolbar.js +6 -20
- package/node/YearCalendar/YearCalendar.js +45 -12
- package/node/YearCalendar/{PickersYear.js → YearCalendarButton.js} +20 -59
- package/node/YearCalendar/index.js +1 -8
- package/node/YearCalendar/yearCalendarClasses.js +1 -1
- package/node/hooks/index.js +8 -1
- package/node/hooks/usePickerActionsContext.js +22 -0
- package/node/index.js +1 -1
- package/node/internals/components/PickerProvider.js +13 -7
- package/node/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +3 -3
- package/node/internals/components/PickersModalDialog.js +9 -3
- package/node/internals/components/PickersPopper.js +11 -6
- package/node/internals/hooks/useDesktopPicker/useDesktopPicker.js +9 -9
- package/node/internals/hooks/useFieldOwnerState.js +6 -2
- package/node/internals/hooks/useMobilePicker/useMobilePicker.js +8 -7
- package/node/internals/hooks/usePicker/usePicker.js +1 -3
- package/node/internals/hooks/usePicker/usePickerProvider.js +5 -4
- package/node/internals/hooks/usePicker/usePickerValue.js +46 -64
- package/node/internals/hooks/usePicker/usePickerViews.js +9 -7
- package/node/internals/index.js +2 -2
- package/package.json +3 -3
- package/themeAugmentation/components.d.ts +0 -8
- package/themeAugmentation/overrides.d.ts +2 -4
- package/themeAugmentation/props.d.ts +4 -7
- package/MonthCalendar/PickersMonth.d.ts +0 -28
- package/MonthCalendar/pickersMonthClasses.d.ts +0 -13
- package/MonthCalendar/pickersMonthClasses.js +0 -5
- package/YearCalendar/PickersYear.d.ts +0 -27
- package/YearCalendar/pickersYearClasses.d.ts +0 -13
- package/YearCalendar/pickersYearClasses.js +0 -5
- package/modern/MonthCalendar/pickersMonthClasses.js +0 -5
- package/modern/YearCalendar/pickersYearClasses.js +0 -5
- package/node/MonthCalendar/pickersMonthClasses.js +0 -12
- package/node/YearCalendar/pickersYearClasses.js +0 -12
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { DefaultizedProps } from '@mui/x-internals/types';
|
|
3
3
|
import { MonthCalendarProps } from './MonthCalendar.types';
|
|
4
|
-
export declare function useMonthCalendarDefaultizedProps(props: MonthCalendarProps, name: string): DefaultizedProps<MonthCalendarProps, 'minDate' | 'maxDate' | 'disableFuture' | 'disablePast'>;
|
|
4
|
+
export declare function useMonthCalendarDefaultizedProps(props: MonthCalendarProps, name: string): DefaultizedProps<MonthCalendarProps, 'minDate' | 'maxDate' | 'disableFuture' | 'disablePast' | 'monthsPerRow'>;
|
|
5
5
|
type MonthCalendarComponent = ((props: MonthCalendarProps & React.RefAttributes<HTMLDivElement>) => React.JSX.Element) & {
|
|
6
6
|
propTypes?: any;
|
|
7
7
|
};
|
|
@@ -2,14 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
4
4
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
5
|
-
const _excluded = ["className", "classes", "value", "defaultValue", "referenceDate", "disabled", "disableFuture", "disablePast", "maxDate", "minDate", "onChange", "shouldDisableMonth", "readOnly", "disableHighlightToday", "
|
|
5
|
+
const _excluded = ["autoFocus", "className", "classes", "value", "defaultValue", "referenceDate", "disabled", "disableFuture", "disablePast", "maxDate", "minDate", "onChange", "shouldDisableMonth", "readOnly", "disableHighlightToday", "onMonthFocus", "hasFocus", "onFocusedViewChange", "monthsPerRow", "timezone", "gridLabelId", "slots", "slotProps"];
|
|
6
6
|
import * as React from 'react';
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
8
|
import clsx from 'clsx';
|
|
9
9
|
import { useRtl } from '@mui/system/RtlProvider';
|
|
10
|
+
import { shouldForwardProp } from '@mui/system/createStyled';
|
|
10
11
|
import { styled, useThemeProps } from '@mui/material/styles';
|
|
11
12
|
import { unstable_useControlled as useControlled, unstable_composeClasses as composeClasses, unstable_useEventCallback as useEventCallback } from '@mui/utils';
|
|
12
|
-
import {
|
|
13
|
+
import { MonthCalendarButton } from "./MonthCalendarButton.js";
|
|
13
14
|
import { useUtils, useNow, useDefaultDates } from "../internals/hooks/useUtils.js";
|
|
14
15
|
import { getMonthCalendarUtilityClass } from "./monthCalendarClasses.js";
|
|
15
16
|
import { applyDefaultDate, getMonthsInYear } from "../internals/utils/date-utils.js";
|
|
@@ -36,6 +37,7 @@ export function useMonthCalendarDefaultizedProps(props, name) {
|
|
|
36
37
|
disableFuture: false,
|
|
37
38
|
disablePast: false
|
|
38
39
|
}, themeProps, {
|
|
40
|
+
monthsPerRow: themeProps.monthsPerRow ?? 3,
|
|
39
41
|
minDate: applyDefaultDate(utils, themeProps.minDate, defaultDates.minDate),
|
|
40
42
|
maxDate: applyDefaultDate(utils, themeProps.maxDate, defaultDates.maxDate)
|
|
41
43
|
});
|
|
@@ -43,15 +45,32 @@ export function useMonthCalendarDefaultizedProps(props, name) {
|
|
|
43
45
|
const MonthCalendarRoot = styled('div', {
|
|
44
46
|
name: 'MuiMonthCalendar',
|
|
45
47
|
slot: 'Root',
|
|
46
|
-
overridesResolver: (props, styles) => styles.root
|
|
48
|
+
overridesResolver: (props, styles) => styles.root,
|
|
49
|
+
shouldForwardProp: prop => shouldForwardProp(prop) && prop !== 'monthsPerRow'
|
|
47
50
|
})({
|
|
48
51
|
display: 'flex',
|
|
49
52
|
flexWrap: 'wrap',
|
|
50
|
-
|
|
51
|
-
|
|
53
|
+
justifyContent: 'space-evenly',
|
|
54
|
+
rowGap: 16,
|
|
55
|
+
padding: '8px 0',
|
|
52
56
|
width: DIALOG_WIDTH,
|
|
53
57
|
// avoid padding increasing width over defined
|
|
54
|
-
boxSizing: 'border-box'
|
|
58
|
+
boxSizing: 'border-box',
|
|
59
|
+
variants: [{
|
|
60
|
+
props: {
|
|
61
|
+
monthsPerRow: 3
|
|
62
|
+
},
|
|
63
|
+
style: {
|
|
64
|
+
columnGap: 24
|
|
65
|
+
}
|
|
66
|
+
}, {
|
|
67
|
+
props: {
|
|
68
|
+
monthsPerRow: 4
|
|
69
|
+
},
|
|
70
|
+
style: {
|
|
71
|
+
columnGap: 0
|
|
72
|
+
}
|
|
73
|
+
}]
|
|
55
74
|
});
|
|
56
75
|
/**
|
|
57
76
|
* Demos:
|
|
@@ -65,6 +84,7 @@ const MonthCalendarRoot = styled('div', {
|
|
|
65
84
|
export const MonthCalendar = /*#__PURE__*/React.forwardRef(function MonthCalendar(inProps, ref) {
|
|
66
85
|
const props = useMonthCalendarDefaultizedProps(inProps, 'MuiMonthCalendar');
|
|
67
86
|
const {
|
|
87
|
+
autoFocus,
|
|
68
88
|
className,
|
|
69
89
|
classes: classesProp,
|
|
70
90
|
value: valueProp,
|
|
@@ -78,11 +98,10 @@ export const MonthCalendar = /*#__PURE__*/React.forwardRef(function MonthCalenda
|
|
|
78
98
|
onChange,
|
|
79
99
|
shouldDisableMonth,
|
|
80
100
|
readOnly,
|
|
81
|
-
autoFocus = false,
|
|
82
101
|
onMonthFocus,
|
|
83
102
|
hasFocus,
|
|
84
103
|
onFocusedViewChange,
|
|
85
|
-
monthsPerRow
|
|
104
|
+
monthsPerRow,
|
|
86
105
|
timezone: timezoneProp,
|
|
87
106
|
gridLabelId,
|
|
88
107
|
slots,
|
|
@@ -209,7 +228,8 @@ export const MonthCalendar = /*#__PURE__*/React.forwardRef(function MonthCalenda
|
|
|
209
228
|
className: clsx(classes.root, className),
|
|
210
229
|
ownerState: ownerState,
|
|
211
230
|
role: "radiogroup",
|
|
212
|
-
"aria-labelledby": gridLabelId
|
|
231
|
+
"aria-labelledby": gridLabelId,
|
|
232
|
+
monthsPerRow: monthsPerRow
|
|
213
233
|
}, other, {
|
|
214
234
|
children: getMonthsInYear(utils, value ?? referenceDate).map(month => {
|
|
215
235
|
const monthNumber = utils.getMonth(month);
|
|
@@ -217,7 +237,7 @@ export const MonthCalendar = /*#__PURE__*/React.forwardRef(function MonthCalenda
|
|
|
217
237
|
const monthLabel = utils.format(month, 'month');
|
|
218
238
|
const isSelected = monthNumber === selectedMonth;
|
|
219
239
|
const isDisabled = disabled || isMonthDisabled(month);
|
|
220
|
-
return /*#__PURE__*/_jsx(
|
|
240
|
+
return /*#__PURE__*/_jsx(MonthCalendarButton, {
|
|
221
241
|
selected: isSelected,
|
|
222
242
|
value: monthNumber,
|
|
223
243
|
onClick: handleMonthSelection,
|
|
@@ -229,9 +249,9 @@ export const MonthCalendar = /*#__PURE__*/React.forwardRef(function MonthCalenda
|
|
|
229
249
|
onBlur: handleMonthBlur,
|
|
230
250
|
"aria-current": todayMonth === monthNumber ? 'date' : undefined,
|
|
231
251
|
"aria-label": monthLabel,
|
|
232
|
-
monthsPerRow: monthsPerRow,
|
|
233
252
|
slots: slots,
|
|
234
253
|
slotProps: slotProps,
|
|
254
|
+
classes: classesProp,
|
|
235
255
|
children: monthText
|
|
236
256
|
}, monthText);
|
|
237
257
|
})
|
|
@@ -6,7 +6,7 @@ import { MonthCalendarClasses } from './monthCalendarClasses';
|
|
|
6
6
|
import { BaseDateValidationProps, MonthValidationProps } from '../internals/models/validation';
|
|
7
7
|
import { PickerOwnerState, PickerValidDate, TimezoneProps } from '../models';
|
|
8
8
|
import { FormProps } from '../internals/models/formProps';
|
|
9
|
-
export interface
|
|
9
|
+
export interface MonthButtonOwnerState extends PickerOwnerState {
|
|
10
10
|
isMonthSelected: boolean;
|
|
11
11
|
isMonthDisabled: boolean;
|
|
12
12
|
}
|
|
@@ -20,7 +20,7 @@ export interface MonthCalendarSlots {
|
|
|
20
20
|
export interface MonthCalendarSlotProps {
|
|
21
21
|
monthButton?: SlotComponentPropsFromProps<React.HTMLAttributes<HTMLButtonElement> & {
|
|
22
22
|
sx: SxProps;
|
|
23
|
-
}, {},
|
|
23
|
+
}, {}, MonthButtonOwnerState>;
|
|
24
24
|
}
|
|
25
25
|
export interface ExportedMonthCalendarProps {
|
|
26
26
|
/**
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { MonthCalendarSlotProps, MonthCalendarSlots } from './MonthCalendar.types';
|
|
3
|
+
import { MonthCalendarClasses } from './monthCalendarClasses';
|
|
4
|
+
export interface MonthCalendarButtonProps {
|
|
5
|
+
value: number;
|
|
6
|
+
tabIndex: number;
|
|
7
|
+
selected: boolean;
|
|
8
|
+
disabled: boolean;
|
|
9
|
+
autoFocus: boolean;
|
|
10
|
+
classes: Partial<MonthCalendarClasses> | undefined;
|
|
11
|
+
slots: MonthCalendarSlots | undefined;
|
|
12
|
+
slotProps: MonthCalendarSlotProps | undefined;
|
|
13
|
+
'aria-current': React.AriaAttributes['aria-current'];
|
|
14
|
+
'aria-label': React.AriaAttributes['aria-label'];
|
|
15
|
+
children: React.ReactNode;
|
|
16
|
+
onClick: (event: React.MouseEvent, month: number) => void;
|
|
17
|
+
onKeyDown: (event: React.KeyboardEvent, month: number) => void;
|
|
18
|
+
onFocus: (event: React.FocusEvent, month: number) => void;
|
|
19
|
+
onBlur: (event: React.FocusEvent, month: number) => void;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* @ignore - do not document.
|
|
23
|
+
*/
|
|
24
|
+
export declare const MonthCalendarButton: React.NamedExoticComponent<MonthCalendarButtonProps>;
|
|
@@ -1,47 +1,27 @@
|
|
|
1
1
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
2
2
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
|
-
const _excluded = ["autoFocus", "
|
|
3
|
+
const _excluded = ["autoFocus", "classes", "disabled", "selected", "value", "onClick", "onKeyDown", "onFocus", "onBlur", "slots", "slotProps"];
|
|
4
4
|
import * as React from 'react';
|
|
5
|
-
import
|
|
6
|
-
import { styled, alpha, useThemeProps } from '@mui/material/styles';
|
|
5
|
+
import { styled, alpha } from '@mui/material/styles';
|
|
7
6
|
import useSlotProps from '@mui/utils/useSlotProps';
|
|
8
7
|
import composeClasses from '@mui/utils/composeClasses';
|
|
9
8
|
import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
|
|
10
|
-
import { getPickersMonthUtilityClass, pickersMonthClasses } from "./pickersMonthClasses.js";
|
|
11
9
|
import { usePickerPrivateContext } from "../internals/hooks/usePickerPrivateContext.js";
|
|
10
|
+
import { getMonthCalendarUtilityClass, monthCalendarClasses } from "./monthCalendarClasses.js";
|
|
12
11
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
12
|
const useUtilityClasses = (classes, ownerState) => {
|
|
14
13
|
const slots = {
|
|
15
|
-
|
|
16
|
-
monthButton: ['monthButton', ownerState.isMonthDisabled && 'disabled', ownerState.isMonthSelected && 'selected']
|
|
14
|
+
button: ['button', ownerState.isMonthDisabled && 'disabled', ownerState.isMonthSelected && 'selected']
|
|
17
15
|
};
|
|
18
|
-
return composeClasses(slots,
|
|
16
|
+
return composeClasses(slots, getMonthCalendarUtilityClass, classes);
|
|
19
17
|
};
|
|
20
|
-
const
|
|
21
|
-
name: '
|
|
22
|
-
slot: '
|
|
23
|
-
overridesResolver: (_, styles) => [styles.
|
|
24
|
-
}
|
|
25
|
-
display: 'flex',
|
|
26
|
-
alignItems: 'center',
|
|
27
|
-
justifyContent: 'center',
|
|
28
|
-
flexBasis: '33.3%',
|
|
29
|
-
variants: [{
|
|
30
|
-
props: {
|
|
31
|
-
monthsPerRow: 4
|
|
32
|
-
},
|
|
33
|
-
style: {
|
|
34
|
-
flexBasis: '25%'
|
|
35
|
-
}
|
|
36
|
-
}]
|
|
37
|
-
});
|
|
38
|
-
const MonthCalendarButton = styled('button', {
|
|
39
|
-
name: 'MuiPickersMonth',
|
|
40
|
-
slot: 'MonthButton',
|
|
41
|
-
overridesResolver: (_, styles) => [styles.monthButton, {
|
|
42
|
-
[`&.${pickersMonthClasses.disabled}`]: styles.disabled
|
|
18
|
+
const DefaultMonthButton = styled('button', {
|
|
19
|
+
name: 'MuiMonthCalendar',
|
|
20
|
+
slot: 'Button',
|
|
21
|
+
overridesResolver: (_, styles) => [styles.button, {
|
|
22
|
+
[`&.${monthCalendarClasses.disabled}`]: styles.disabled
|
|
43
23
|
}, {
|
|
44
|
-
[`&.${
|
|
24
|
+
[`&.${monthCalendarClasses.selected}`]: styles.selected
|
|
45
25
|
}]
|
|
46
26
|
})(({
|
|
47
27
|
theme
|
|
@@ -51,7 +31,6 @@ const MonthCalendarButton = styled('button', {
|
|
|
51
31
|
border: 0,
|
|
52
32
|
outline: 0
|
|
53
33
|
}, theme.typography.subtitle1, {
|
|
54
|
-
margin: '8px 0',
|
|
55
34
|
height: 36,
|
|
56
35
|
width: 72,
|
|
57
36
|
borderRadius: 18,
|
|
@@ -66,10 +45,10 @@ const MonthCalendarButton = styled('button', {
|
|
|
66
45
|
cursor: 'auto',
|
|
67
46
|
pointerEvents: 'none'
|
|
68
47
|
},
|
|
69
|
-
[`&.${
|
|
48
|
+
[`&.${monthCalendarClasses.disabled}`]: {
|
|
70
49
|
color: (theme.vars || theme).palette.text.secondary
|
|
71
50
|
},
|
|
72
|
-
[`&.${
|
|
51
|
+
[`&.${monthCalendarClasses.selected}`]: {
|
|
73
52
|
color: (theme.vars || theme).palette.primary.contrastText,
|
|
74
53
|
backgroundColor: (theme.vars || theme).palette.primary.main,
|
|
75
54
|
'&:focus, &:hover': {
|
|
@@ -81,29 +60,17 @@ const MonthCalendarButton = styled('button', {
|
|
|
81
60
|
/**
|
|
82
61
|
* @ignore - do not document.
|
|
83
62
|
*/
|
|
84
|
-
export const
|
|
85
|
-
const props = useThemeProps({
|
|
86
|
-
props: inProps,
|
|
87
|
-
name: 'MuiPickersMonth'
|
|
88
|
-
});
|
|
63
|
+
export const MonthCalendarButton = /*#__PURE__*/React.memo(function MonthCalendarButton(props) {
|
|
89
64
|
const {
|
|
90
65
|
autoFocus,
|
|
91
|
-
className,
|
|
92
66
|
classes: classesProp,
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
selected = false,
|
|
67
|
+
disabled,
|
|
68
|
+
selected,
|
|
96
69
|
value,
|
|
97
|
-
tabIndex,
|
|
98
70
|
onClick,
|
|
99
71
|
onKeyDown,
|
|
100
72
|
onFocus,
|
|
101
73
|
onBlur,
|
|
102
|
-
'aria-current': ariaCurrent,
|
|
103
|
-
'aria-label': ariaLabel
|
|
104
|
-
// We don't want to forward this prop to the root element
|
|
105
|
-
,
|
|
106
|
-
|
|
107
74
|
slots,
|
|
108
75
|
slotProps
|
|
109
76
|
} = props,
|
|
@@ -125,32 +92,24 @@ export const PickersMonth = /*#__PURE__*/React.memo(function PickersMonth(inProp
|
|
|
125
92
|
ref.current?.focus();
|
|
126
93
|
}
|
|
127
94
|
}, [autoFocus]);
|
|
128
|
-
const MonthButton = slots?.monthButton ??
|
|
95
|
+
const MonthButton = slots?.monthButton ?? DefaultMonthButton;
|
|
129
96
|
const monthButtonProps = useSlotProps({
|
|
130
97
|
elementType: MonthButton,
|
|
131
98
|
externalSlotProps: slotProps?.monthButton,
|
|
99
|
+
externalForwardedProps: other,
|
|
132
100
|
additionalProps: {
|
|
133
|
-
children,
|
|
134
101
|
disabled,
|
|
135
|
-
tabIndex,
|
|
136
102
|
ref,
|
|
137
103
|
type: 'button',
|
|
138
104
|
role: 'radio',
|
|
139
|
-
'aria-current': ariaCurrent,
|
|
140
105
|
'aria-checked': selected,
|
|
141
|
-
'aria-label': ariaLabel,
|
|
142
106
|
onClick: event => onClick(event, value),
|
|
143
107
|
onKeyDown: event => onKeyDown(event, value),
|
|
144
108
|
onFocus: event => onFocus(event, value),
|
|
145
109
|
onBlur: event => onBlur(event, value)
|
|
146
110
|
},
|
|
147
111
|
ownerState,
|
|
148
|
-
className: classes.
|
|
112
|
+
className: classes.button
|
|
149
113
|
});
|
|
150
|
-
return /*#__PURE__*/_jsx(
|
|
151
|
-
className: clsx(classes.root, className),
|
|
152
|
-
ownerState: ownerState
|
|
153
|
-
}, other, {
|
|
154
|
-
children: /*#__PURE__*/_jsx(MonthButton, _extends({}, monthButtonProps))
|
|
155
|
-
}));
|
|
114
|
+
return /*#__PURE__*/_jsx(MonthButton, _extends({}, monthButtonProps));
|
|
156
115
|
});
|
package/MonthCalendar/index.d.ts
CHANGED
|
@@ -2,6 +2,3 @@ export { MonthCalendar } from './MonthCalendar';
|
|
|
2
2
|
export type { MonthCalendarProps, MonthCalendarSlots, MonthCalendarSlotProps, } from './MonthCalendar.types';
|
|
3
3
|
export { monthCalendarClasses, getMonthCalendarUtilityClass } from './monthCalendarClasses';
|
|
4
4
|
export type { MonthCalendarClasses, MonthCalendarClassKey } from './monthCalendarClasses';
|
|
5
|
-
export { pickersMonthClasses } from './pickersMonthClasses';
|
|
6
|
-
export type { PickersMonthClassKey, PickersMonthClasses } from './pickersMonthClasses';
|
|
7
|
-
export type { ExportedPickersMonthProps } from './PickersMonth';
|
package/MonthCalendar/index.js
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
1
|
export { MonthCalendar } from "./MonthCalendar.js";
|
|
2
|
-
export { monthCalendarClasses, getMonthCalendarUtilityClass } from "./monthCalendarClasses.js";
|
|
3
|
-
export { pickersMonthClasses } from "./pickersMonthClasses.js";
|
|
2
|
+
export { monthCalendarClasses, getMonthCalendarUtilityClass } from "./monthCalendarClasses.js";
|
|
@@ -2,6 +2,12 @@ export declare function getMonthCalendarUtilityClass(slot: string): string;
|
|
|
2
2
|
export interface MonthCalendarClasses {
|
|
3
3
|
/** Styles applied to the root element. */
|
|
4
4
|
root: string;
|
|
5
|
+
/** Styles applied to the button element that represents a single month */
|
|
6
|
+
button: string;
|
|
7
|
+
/** Styles applied to a disabled button element. */
|
|
8
|
+
disabled: string;
|
|
9
|
+
/** Styles applied to a selected button element. */
|
|
10
|
+
selected: string;
|
|
5
11
|
}
|
|
6
12
|
export type MonthCalendarClassKey = keyof MonthCalendarClasses;
|
|
7
|
-
export declare const monthCalendarClasses: Record<
|
|
13
|
+
export declare const monthCalendarClasses: Record<keyof MonthCalendarClasses, string>;
|
|
@@ -2,4 +2,4 @@ import { unstable_generateUtilityClass as generateUtilityClass, unstable_generat
|
|
|
2
2
|
export function getMonthCalendarUtilityClass(slot) {
|
|
3
3
|
return generateUtilityClass('MuiMonthCalendar', slot);
|
|
4
4
|
}
|
|
5
|
-
export const monthCalendarClasses = generateUtilityClasses('MuiMonthCalendar', ['root']);
|
|
5
|
+
export const monthCalendarClasses = generateUtilityClasses('MuiMonthCalendar', ['root', 'button', 'disabled', 'selected']);
|
|
@@ -189,6 +189,9 @@ export const MultiSectionDigitalClock = /*#__PURE__*/React.forwardRef(function M
|
|
|
189
189
|
{
|
|
190
190
|
const valueWithMeridiem = convertValueToMeridiem(rawValue, meridiemMode, ampm);
|
|
191
191
|
const dateWithNewHours = utils.setHours(valueOrReferenceDate, valueWithMeridiem);
|
|
192
|
+
if (utils.getHours(dateWithNewHours) !== valueWithMeridiem) {
|
|
193
|
+
return true;
|
|
194
|
+
}
|
|
192
195
|
const start = utils.setSeconds(utils.setMinutes(dateWithNewHours, 0), 0);
|
|
193
196
|
const end = utils.setSeconds(utils.setMinutes(dateWithNewHours, 59), 59);
|
|
194
197
|
return !containsValidTime({
|
|
@@ -8,10 +8,6 @@ export interface PickersActionBarProps extends DialogActionsProps {
|
|
|
8
8
|
* @default `['cancel', 'accept']` for mobile and `[]` for desktop
|
|
9
9
|
*/
|
|
10
10
|
actions?: PickersActionBarAction[];
|
|
11
|
-
onAccept: () => void;
|
|
12
|
-
onClear: () => void;
|
|
13
|
-
onCancel: () => void;
|
|
14
|
-
onSetToday: () => void;
|
|
15
11
|
}
|
|
16
12
|
/**
|
|
17
13
|
* Demos:
|
|
@@ -2,13 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
4
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
5
|
-
const _excluded = ["
|
|
5
|
+
const _excluded = ["actions"];
|
|
6
6
|
import * as React from 'react';
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
8
|
import { styled } from '@mui/material/styles';
|
|
9
9
|
import Button from '@mui/material/Button';
|
|
10
10
|
import DialogActions from '@mui/material/DialogActions';
|
|
11
11
|
import { usePickerTranslations } from "../hooks/usePickerTranslations.js";
|
|
12
|
+
import { usePickerActionsContext } from "../hooks/index.js";
|
|
12
13
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
14
|
const PickersActionBarRoot = styled(DialogActions, {
|
|
14
15
|
name: 'MuiPickersLayout',
|
|
@@ -28,14 +29,16 @@ const PickersActionBarRoot = styled(DialogActions, {
|
|
|
28
29
|
*/
|
|
29
30
|
function PickersActionBar(props) {
|
|
30
31
|
const {
|
|
31
|
-
onAccept,
|
|
32
|
-
onClear,
|
|
33
|
-
onCancel,
|
|
34
|
-
onSetToday,
|
|
35
32
|
actions
|
|
36
33
|
} = props,
|
|
37
34
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
38
35
|
const translations = usePickerTranslations();
|
|
36
|
+
const {
|
|
37
|
+
clearValue,
|
|
38
|
+
setValueToToday,
|
|
39
|
+
acceptValueChanges,
|
|
40
|
+
cancelValueChanges
|
|
41
|
+
} = usePickerActionsContext();
|
|
39
42
|
if (actions == null || actions.length === 0) {
|
|
40
43
|
return null;
|
|
41
44
|
}
|
|
@@ -43,22 +46,22 @@ function PickersActionBar(props) {
|
|
|
43
46
|
switch (actionType) {
|
|
44
47
|
case 'clear':
|
|
45
48
|
return /*#__PURE__*/_jsx(Button, {
|
|
46
|
-
onClick:
|
|
49
|
+
onClick: clearValue,
|
|
47
50
|
children: translations.clearButtonLabel
|
|
48
51
|
}, actionType);
|
|
49
52
|
case 'cancel':
|
|
50
53
|
return /*#__PURE__*/_jsx(Button, {
|
|
51
|
-
onClick:
|
|
54
|
+
onClick: cancelValueChanges,
|
|
52
55
|
children: translations.cancelButtonLabel
|
|
53
56
|
}, actionType);
|
|
54
57
|
case 'accept':
|
|
55
58
|
return /*#__PURE__*/_jsx(Button, {
|
|
56
|
-
onClick:
|
|
59
|
+
onClick: acceptValueChanges,
|
|
57
60
|
children: translations.okButtonLabel
|
|
58
61
|
}, actionType);
|
|
59
62
|
case 'today':
|
|
60
63
|
return /*#__PURE__*/_jsx(Button, {
|
|
61
|
-
onClick:
|
|
64
|
+
onClick: setValueToToday,
|
|
62
65
|
children: translations.todayButtonLabel
|
|
63
66
|
}, actionType);
|
|
64
67
|
default:
|
|
@@ -85,10 +88,6 @@ process.env.NODE_ENV !== "production" ? PickersActionBar.propTypes = {
|
|
|
85
88
|
* @default false
|
|
86
89
|
*/
|
|
87
90
|
disableSpacing: PropTypes.bool,
|
|
88
|
-
onAccept: PropTypes.func.isRequired,
|
|
89
|
-
onCancel: PropTypes.func.isRequired,
|
|
90
|
-
onClear: PropTypes.func.isRequired,
|
|
91
|
-
onSetToday: PropTypes.func.isRequired,
|
|
92
91
|
/**
|
|
93
92
|
* The system prop that allows defining system overrides as well as additional CSS styles.
|
|
94
93
|
*/
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { PickerLayoutOwnerState, PickersLayoutProps } from './PickersLayout.types';
|
|
3
|
-
import {
|
|
3
|
+
import { PickerValidValue } from '../internals/models';
|
|
4
4
|
export declare const PickersLayoutRoot: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme> & {
|
|
5
5
|
ownerState: PickerLayoutOwnerState;
|
|
6
6
|
}, Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof React.ClassAttributes<HTMLDivElement> | keyof React.HTMLAttributes<HTMLDivElement>>, {}>;
|
|
7
7
|
export declare const PickersLayoutContentWrapper: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme> & {
|
|
8
8
|
ownerState: PickerLayoutOwnerState;
|
|
9
9
|
}, Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof React.ClassAttributes<HTMLDivElement> | keyof React.HTMLAttributes<HTMLDivElement>>, {}>;
|
|
10
|
-
type PickersLayoutComponent = (<TValue extends PickerValidValue
|
|
10
|
+
type PickersLayoutComponent = (<TValue extends PickerValidValue>(props: PickersLayoutProps<TValue> & React.RefAttributes<HTMLDivElement>) => React.JSX.Element) & {
|
|
11
11
|
propTypes?: any;
|
|
12
12
|
};
|
|
13
13
|
/**
|
|
@@ -151,16 +151,8 @@ process.env.NODE_ENV !== "production" ? PickersLayout.propTypes = {
|
|
|
151
151
|
classes: PropTypes.object,
|
|
152
152
|
className: PropTypes.string,
|
|
153
153
|
isValid: PropTypes.func.isRequired,
|
|
154
|
-
onAccept: PropTypes.func.isRequired,
|
|
155
|
-
onCancel: PropTypes.func.isRequired,
|
|
156
154
|
onChange: PropTypes.func.isRequired,
|
|
157
|
-
onClear: PropTypes.func.isRequired,
|
|
158
|
-
onClose: PropTypes.func.isRequired,
|
|
159
|
-
onDismiss: PropTypes.func.isRequired,
|
|
160
|
-
onOpen: PropTypes.func.isRequired,
|
|
161
155
|
onSelectShortcut: PropTypes.func.isRequired,
|
|
162
|
-
onSetToday: PropTypes.func.isRequired,
|
|
163
|
-
onViewChange: PropTypes.func.isRequired,
|
|
164
156
|
/**
|
|
165
157
|
* The props used for each component slot.
|
|
166
158
|
* @default {}
|
|
@@ -175,8 +167,6 @@ process.env.NODE_ENV !== "production" ? PickersLayout.propTypes = {
|
|
|
175
167
|
* The system prop that allows defining system overrides as well as additional CSS styles.
|
|
176
168
|
*/
|
|
177
169
|
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
178
|
-
value: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.object), PropTypes.object])
|
|
179
|
-
view: PropTypes.oneOf(['day', 'hours', 'meridiem', 'minutes', 'month', 'seconds', 'year']),
|
|
180
|
-
views: PropTypes.arrayOf(PropTypes.oneOf(['day', 'hours', 'meridiem', 'minutes', 'month', 'seconds', 'year']).isRequired).isRequired
|
|
170
|
+
value: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.object), PropTypes.object])
|
|
181
171
|
} : void 0;
|
|
182
172
|
export { PickersLayout };
|
|
@@ -3,16 +3,14 @@ import { SxProps, Theme } from '@mui/material/styles';
|
|
|
3
3
|
import { SlotComponentProps } from '@mui/utils';
|
|
4
4
|
import { PickersActionBar, PickersActionBarProps } from '../PickersActionBar';
|
|
5
5
|
import { BaseToolbarProps, ExportedBaseToolbarProps } from '../internals/models/props/toolbar';
|
|
6
|
-
import {
|
|
6
|
+
import { ExportedBaseTabsProps } from '../internals/models/props/tabs';
|
|
7
7
|
import { PickersLayoutClasses } from './pickersLayoutClasses';
|
|
8
|
-
import { DateOrTimeViewWithMeridiem } from '../internals/models/common';
|
|
9
8
|
import { PickersShortcutsProps } from '../PickersShortcuts';
|
|
10
9
|
import { ExportedPickersShortcutProps, PickersShortcuts } from '../PickersShortcuts/PickersShortcuts';
|
|
11
10
|
import { PickerOwnerState } from '../models';
|
|
12
11
|
import { PickerValidValue } from '../internals/models';
|
|
13
|
-
import { UsePickerViewsLayoutResponse } from '../internals/hooks/usePicker/usePickerViews';
|
|
14
12
|
import { UsePickerValueLayoutResponse } from '../internals/hooks/usePicker/usePickerValue.types';
|
|
15
|
-
export interface ExportedPickersLayoutSlots<TValue extends PickerValidValue
|
|
13
|
+
export interface ExportedPickersLayoutSlots<TValue extends PickerValidValue> {
|
|
16
14
|
/**
|
|
17
15
|
* Custom component for the action bar, it is placed below the picker views.
|
|
18
16
|
* @default PickersActionBar
|
|
@@ -27,7 +25,7 @@ export interface ExportedPickersLayoutSlots<TValue extends PickerValidValue, TVi
|
|
|
27
25
|
* Custom component for wrapping the layout.
|
|
28
26
|
* It wraps the toolbar, views, action bar, and shortcuts.
|
|
29
27
|
*/
|
|
30
|
-
layout?: React.JSXElementConstructor<PickersLayoutProps<TValue
|
|
28
|
+
layout?: React.JSXElementConstructor<PickersLayoutProps<TValue> & React.RefAttributes<HTMLDivElement>>;
|
|
31
29
|
}
|
|
32
30
|
export interface PickerLayoutOwnerState extends PickerOwnerState {
|
|
33
31
|
/**
|
|
@@ -37,7 +35,7 @@ export interface PickerLayoutOwnerState extends PickerOwnerState {
|
|
|
37
35
|
*/
|
|
38
36
|
layoutDirection: 'ltr' | 'rtl';
|
|
39
37
|
}
|
|
40
|
-
export interface ExportedPickersLayoutSlotProps<TValue extends PickerValidValue
|
|
38
|
+
export interface ExportedPickersLayoutSlotProps<TValue extends PickerValidValue> {
|
|
41
39
|
/**
|
|
42
40
|
* Props passed down to the action bar component.
|
|
43
41
|
*/
|
|
@@ -49,20 +47,20 @@ export interface ExportedPickersLayoutSlotProps<TValue extends PickerValidValue,
|
|
|
49
47
|
/**
|
|
50
48
|
* Props passed down to the layoutRoot component.
|
|
51
49
|
*/
|
|
52
|
-
layout?: Partial<PickersLayoutProps<TValue
|
|
50
|
+
layout?: Partial<PickersLayoutProps<TValue>>;
|
|
53
51
|
}
|
|
54
|
-
export interface PickersLayoutSlots<TValue extends PickerValidValue
|
|
52
|
+
export interface PickersLayoutSlots<TValue extends PickerValidValue> extends ExportedPickersLayoutSlots<TValue> {
|
|
55
53
|
/**
|
|
56
54
|
* Tabs enabling toggling between views.
|
|
57
55
|
*/
|
|
58
|
-
tabs?: React.ElementType<
|
|
56
|
+
tabs?: React.ElementType<{}>;
|
|
59
57
|
/**
|
|
60
58
|
* Custom component for the toolbar.
|
|
61
59
|
* It is placed above the picker views.
|
|
62
60
|
*/
|
|
63
|
-
toolbar?: React.JSXElementConstructor<BaseToolbarProps<TValue
|
|
61
|
+
toolbar?: React.JSXElementConstructor<BaseToolbarProps<TValue>>;
|
|
64
62
|
}
|
|
65
|
-
export interface PickersLayoutSlotProps<TValue extends PickerValidValue
|
|
63
|
+
export interface PickersLayoutSlotProps<TValue extends PickerValidValue> extends ExportedPickersLayoutSlotProps<TValue> {
|
|
66
64
|
/**
|
|
67
65
|
* Props passed down to the tabs component.
|
|
68
66
|
*/
|
|
@@ -72,7 +70,7 @@ export interface PickersLayoutSlotProps<TValue extends PickerValidValue, TView e
|
|
|
72
70
|
*/
|
|
73
71
|
toolbar?: ExportedBaseToolbarProps;
|
|
74
72
|
}
|
|
75
|
-
export interface PickersLayoutProps<TValue extends PickerValidValue
|
|
73
|
+
export interface PickersLayoutProps<TValue extends PickerValidValue> extends UsePickerValueLayoutResponse<TValue> {
|
|
76
74
|
className?: string;
|
|
77
75
|
children?: React.ReactNode;
|
|
78
76
|
/**
|
|
@@ -87,12 +85,12 @@ export interface PickersLayoutProps<TValue extends PickerValidValue, TView exten
|
|
|
87
85
|
* Overridable component slots.
|
|
88
86
|
* @default {}
|
|
89
87
|
*/
|
|
90
|
-
slots?: PickersLayoutSlots<TValue
|
|
88
|
+
slots?: PickersLayoutSlots<TValue>;
|
|
91
89
|
/**
|
|
92
90
|
* The props used for each component slot.
|
|
93
91
|
* @default {}
|
|
94
92
|
*/
|
|
95
|
-
slotProps?: PickersLayoutSlotProps<TValue
|
|
93
|
+
slotProps?: PickersLayoutSlotProps<TValue>;
|
|
96
94
|
}
|
|
97
95
|
export interface SubComponents<TValue extends PickerValidValue> {
|
|
98
96
|
toolbar: React.ReactElement<ExportedBaseToolbarProps> | null;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { PickerLayoutOwnerState, PickersLayoutProps, SubComponents } from './PickersLayout.types';
|
|
2
|
-
import {
|
|
2
|
+
import { PickerValidValue } from '../internals/models';
|
|
3
3
|
interface UsePickerLayoutResponse<TValue extends PickerValidValue> extends SubComponents<TValue> {
|
|
4
4
|
ownerState: PickerLayoutOwnerState;
|
|
5
5
|
}
|
|
6
|
-
declare const usePickerLayout: <TValue extends PickerValidValue
|
|
6
|
+
declare const usePickerLayout: <TValue extends PickerValidValue>(props: PickersLayoutProps<TValue>) => UsePickerLayoutResponse<TValue>;
|
|
7
7
|
export default usePickerLayout;
|
|
@@ -35,17 +35,11 @@ const usePickerLayout = props => {
|
|
|
35
35
|
} = usePickerPrivateContext();
|
|
36
36
|
const {
|
|
37
37
|
variant,
|
|
38
|
-
orientation
|
|
38
|
+
orientation,
|
|
39
|
+
view
|
|
39
40
|
} = usePickerContext();
|
|
40
41
|
const isRtl = useRtl();
|
|
41
42
|
const {
|
|
42
|
-
onAccept,
|
|
43
|
-
onClear,
|
|
44
|
-
onCancel,
|
|
45
|
-
onSetToday,
|
|
46
|
-
view,
|
|
47
|
-
views,
|
|
48
|
-
onViewChange,
|
|
49
43
|
value,
|
|
50
44
|
onChange,
|
|
51
45
|
onSelectShortcut,
|
|
@@ -70,10 +64,6 @@ const usePickerLayout = props => {
|
|
|
70
64
|
elementType: ActionBar,
|
|
71
65
|
externalSlotProps: slotProps?.actionBar,
|
|
72
66
|
additionalProps: {
|
|
73
|
-
onAccept,
|
|
74
|
-
onClear,
|
|
75
|
-
onCancel,
|
|
76
|
-
onSetToday,
|
|
77
67
|
actions: variant === 'desktop' ? [] : ['cancel', 'accept']
|
|
78
68
|
},
|
|
79
69
|
className: classes.actionBar,
|
|
@@ -90,10 +80,7 @@ const usePickerLayout = props => {
|
|
|
90
80
|
isLandscape: orientation === 'landscape',
|
|
91
81
|
// Will be removed in a follow up PR?
|
|
92
82
|
onChange,
|
|
93
|
-
value
|
|
94
|
-
view,
|
|
95
|
-
onViewChange,
|
|
96
|
-
views
|
|
83
|
+
value
|
|
97
84
|
},
|
|
98
85
|
className: classes.toolbar,
|
|
99
86
|
ownerState
|
|
@@ -106,8 +93,6 @@ const usePickerLayout = props => {
|
|
|
106
93
|
// Tabs
|
|
107
94
|
const Tabs = slots?.tabs;
|
|
108
95
|
const tabs = view && Tabs ? /*#__PURE__*/_jsx(Tabs, _extends({
|
|
109
|
-
view: view,
|
|
110
|
-
onViewChange: onViewChange,
|
|
111
96
|
className: classes.tabs
|
|
112
97
|
}, slotProps?.tabs)) : null;
|
|
113
98
|
|