From 60456b592422903cdd0677c984895aacfcf3092b Mon Sep 17 00:00:00 2001 From: Lukas Tyla Date: Thu, 26 Jan 2023 22:46:39 +0000 Subject: [PATCH 1/9] Add `resetValueOnClose` prop controlling if value is reset on picker close --- .../internals/hooks/usePicker/usePickerValue.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/packages/x-date-pickers/src/internals/hooks/usePicker/usePickerValue.ts b/packages/x-date-pickers/src/internals/hooks/usePicker/usePickerValue.ts index b02eb82445cc..bc63a8a6bd5b 100644 --- a/packages/x-date-pickers/src/internals/hooks/usePicker/usePickerValue.ts +++ b/packages/x-date-pickers/src/internals/hooks/usePicker/usePickerValue.ts @@ -1,5 +1,5 @@ import * as React from 'react'; -import { unstable_useControlled as useControlled } from '@mui/utils'; +import useControlled from '@mui/utils/useControlled'; import useEventCallback from '@mui/utils/useEventCallback'; import { useOpenState } from '../useOpenState'; import { useLocalizationContext, useUtils } from '../useUtils'; @@ -206,6 +206,13 @@ export interface UsePickerValueNonStaticProps * Use in controlled mode (see open). */ onOpen?: () => void; + /** + * If `true`, on close will reset the value to the value when the picker was opened. + * + * Might make most sense when in need of resetting the value on modal dismiss/close. + * @default `true` for mobile, `false` for desktop. + */ + resetValueOnClose?: boolean; } /** @@ -302,6 +309,7 @@ export const usePickerValue = < closeOnSelect = wrapperVariant === 'desktop', selectedSections: selectedSectionsProp, onSelectedSectionsChange, + resetValueOnClose = wrapperVariant !== 'desktop', } = props; const utils = useUtils(); @@ -429,7 +437,10 @@ export const usePickerValue = < const handleDismiss = useEventCallback(() => { // Set all dates in state to equal the last committed date. // e.g. Reset the state to the last committed value. - setDate({ value: dateState.committed, action: 'acceptAndClose' }); + setDate({ + value: resetValueOnClose ? dateState.resetFallback : dateState.committed, + action: 'acceptAndClose', + }); }); const handleCancel = useEventCallback(() => { From a76845430967b1a5b66b13900bec153902e35a57 Mon Sep 17 00:00:00 2001 From: Lukas Tyla Date: Thu, 26 Jan 2023 23:18:50 +0000 Subject: [PATCH 2/9] Adjust tests --- .../tests/describes.MobileDatePicker.test.tsx | 2 +- .../tests/describes.MobileDateTimePicker.test.tsx | 2 +- .../tests/describes.MobileTimePicker.test.tsx | 2 +- .../describeValue/testPickerOpenCloseLifeCycle.tsx | 13 +++++++++---- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/packages/x-date-pickers/src/MobileDatePicker/tests/describes.MobileDatePicker.test.tsx b/packages/x-date-pickers/src/MobileDatePicker/tests/describes.MobileDatePicker.test.tsx index 3d7045525eed..e17826b29c5e 100644 --- a/packages/x-date-pickers/src/MobileDatePicker/tests/describes.MobileDatePicker.test.tsx +++ b/packages/x-date-pickers/src/MobileDatePicker/tests/describes.MobileDatePicker.test.tsx @@ -42,7 +42,7 @@ describe(' - Describes', () => { // Close the picker to return to the initial state if (!isOpened) { - userEvent.keyPress(document.activeElement!, { key: 'Escape' }); + userEvent.mousePress(screen.getByText('OK')); clock.runToLast(); } diff --git a/packages/x-date-pickers/src/MobileDateTimePicker/tests/describes.MobileDateTimePicker.test.tsx b/packages/x-date-pickers/src/MobileDateTimePicker/tests/describes.MobileDateTimePicker.test.tsx index e4346ec87111..4e4544e55fcf 100644 --- a/packages/x-date-pickers/src/MobileDateTimePicker/tests/describes.MobileDateTimePicker.test.tsx +++ b/packages/x-date-pickers/src/MobileDateTimePicker/tests/describes.MobileDateTimePicker.test.tsx @@ -57,7 +57,7 @@ describe(' - Describes', () => { // Close the picker to return to the initial state if (!isOpened) { - userEvent.keyPress(document.activeElement!, { key: 'Escape' }); + userEvent.mousePress(screen.getByText('OK')); clock.runToLast(); } diff --git a/packages/x-date-pickers/src/MobileTimePicker/tests/describes.MobileTimePicker.test.tsx b/packages/x-date-pickers/src/MobileTimePicker/tests/describes.MobileTimePicker.test.tsx index 6f571925eaa8..788e0811dfdc 100644 --- a/packages/x-date-pickers/src/MobileTimePicker/tests/describes.MobileTimePicker.test.tsx +++ b/packages/x-date-pickers/src/MobileTimePicker/tests/describes.MobileTimePicker.test.tsx @@ -85,7 +85,7 @@ describe(' - Describes', () => { // Close the picker to return to the initial state if (!isOpened) { - userEvent.keyPress(document.activeElement!, { key: 'Escape' }); + userEvent.mousePress(screen.getByText('OK')); clock.runToLast(); } diff --git a/packages/x-date-pickers/src/tests/describeValue/testPickerOpenCloseLifeCycle.tsx b/packages/x-date-pickers/src/tests/describeValue/testPickerOpenCloseLifeCycle.tsx index 012a66dddd54..c90dfc2efb35 100644 --- a/packages/x-date-pickers/src/tests/describeValue/testPickerOpenCloseLifeCycle.tsx +++ b/packages/x-date-pickers/src/tests/describeValue/testPickerOpenCloseLifeCycle.tsx @@ -213,14 +213,19 @@ export const testPickerOpenCloseLifeCycle: DescribeValueTestSuite // Dismiss the picker userEvent.keyPress(document.activeElement!, { key: 'Escape' }); - expect(onChange.callCount).to.equal(1); - expect(onAccept.callCount).to.equal(1); + // Closing picker will reset value on mobile (+1 call) + expect(onChange.callCount).to.equal(pickerParams.variant === 'mobile' ? 2 : 1); + // Closing picker will not accept value on mobile + expect(onAccept.callCount).to.equal(pickerParams.variant === 'mobile' ? 0 : 1); + // Closing picker will emit `onChange` with value before change if (pickerParams.type === 'date-range') { - newValue.forEach((value, index) => { + (pickerParams.variant === 'mobile' ? values[0] : newValue).forEach((value, index) => { expect(onChange.lastCall.args[0][index]).toEqualDateTime(value); }); } else { - expect(onChange.lastCall.args[0]).toEqualDateTime(newValue as any); + expect(onChange.lastCall.args[0]).toEqualDateTime( + pickerParams.variant === 'mobile' ? values[0] : (newValue as any), + ); } expect(onClose.callCount).to.equal(1); }); From d190c51dedb167a9825ba5f7e8328569458a62b0 Mon Sep 17 00:00:00 2001 From: Lukas Tyla Date: Thu, 26 Jan 2023 23:20:21 +0000 Subject: [PATCH 3/9] proptypes --- .../src/DateRangePicker/DateRangePicker.tsx | 7 +++++++ .../src/DesktopDateRangePicker/DesktopDateRangePicker.tsx | 7 +++++++ .../src/MobileDateRangePicker/MobileDateRangePicker.tsx | 7 +++++++ packages/x-date-pickers/src/DatePicker/DatePicker.tsx | 7 +++++++ .../x-date-pickers/src/DateTimePicker/DateTimePicker.tsx | 7 +++++++ .../src/DesktopDatePicker/DesktopDatePicker.tsx | 7 +++++++ .../src/DesktopDateTimePicker/DesktopDateTimePicker.tsx | 7 +++++++ .../src/DesktopTimePicker/DesktopTimePicker.tsx | 7 +++++++ .../src/MobileDatePicker/MobileDatePicker.tsx | 7 +++++++ .../src/MobileDateTimePicker/MobileDateTimePicker.tsx | 7 +++++++ .../src/MobileTimePicker/MobileTimePicker.tsx | 7 +++++++ packages/x-date-pickers/src/TimePicker/TimePicker.tsx | 7 +++++++ 12 files changed, 84 insertions(+) diff --git a/packages/x-date-pickers-pro/src/DateRangePicker/DateRangePicker.tsx b/packages/x-date-pickers-pro/src/DateRangePicker/DateRangePicker.tsx index bc59839c0a3a..26b9e23dc260 100644 --- a/packages/x-date-pickers-pro/src/DateRangePicker/DateRangePicker.tsx +++ b/packages/x-date-pickers-pro/src/DateRangePicker/DateRangePicker.tsx @@ -218,6 +218,13 @@ DateRangePicker.propTypes = { * @default () => "..." */ renderLoading: PropTypes.func, + /** + * If `true`, on close will reset the value to the value when the picker was opened. + * + * Might make most sense when in need of resetting the value on modal dismiss/close. + * @default `true` for mobile, `false` for desktop. + */ + resetValueOnClose: PropTypes.bool, /** * The currently selected sections. * This prop accept four formats: diff --git a/packages/x-date-pickers-pro/src/DesktopDateRangePicker/DesktopDateRangePicker.tsx b/packages/x-date-pickers-pro/src/DesktopDateRangePicker/DesktopDateRangePicker.tsx index 235d017f05a2..33a484a2ada9 100644 --- a/packages/x-date-pickers-pro/src/DesktopDateRangePicker/DesktopDateRangePicker.tsx +++ b/packages/x-date-pickers-pro/src/DesktopDateRangePicker/DesktopDateRangePicker.tsx @@ -247,6 +247,13 @@ DesktopDateRangePicker.propTypes = { * @default () => "..." */ renderLoading: PropTypes.func, + /** + * If `true`, on close will reset the value to the value when the picker was opened. + * + * Might make most sense when in need of resetting the value on modal dismiss/close. + * @default `true` for mobile, `false` for desktop. + */ + resetValueOnClose: PropTypes.bool, /** * The currently selected sections. * This prop accept four formats: diff --git a/packages/x-date-pickers-pro/src/MobileDateRangePicker/MobileDateRangePicker.tsx b/packages/x-date-pickers-pro/src/MobileDateRangePicker/MobileDateRangePicker.tsx index e32190dd3e9e..2ddb580cccae 100644 --- a/packages/x-date-pickers-pro/src/MobileDateRangePicker/MobileDateRangePicker.tsx +++ b/packages/x-date-pickers-pro/src/MobileDateRangePicker/MobileDateRangePicker.tsx @@ -247,6 +247,13 @@ MobileDateRangePicker.propTypes = { * @default () => "..." */ renderLoading: PropTypes.func, + /** + * If `true`, on close will reset the value to the value when the picker was opened. + * + * Might make most sense when in need of resetting the value on modal dismiss/close. + * @default `true` for mobile, `false` for desktop. + */ + resetValueOnClose: PropTypes.bool, /** * The currently selected sections. * This prop accept four formats: diff --git a/packages/x-date-pickers/src/DatePicker/DatePicker.tsx b/packages/x-date-pickers/src/DatePicker/DatePicker.tsx index 05f1acf1d47f..b1927cc5ae86 100644 --- a/packages/x-date-pickers/src/DatePicker/DatePicker.tsx +++ b/packages/x-date-pickers/src/DatePicker/DatePicker.tsx @@ -244,6 +244,13 @@ DatePicker.propTypes = { * @default () => ... */ renderLoading: PropTypes.func, + /** + * If `true`, on close will reset the value to the value when the picker was opened. + * + * Might make most sense when in need of resetting the value on modal dismiss/close. + * @default `true` for mobile, `false` for desktop. + */ + resetValueOnClose: PropTypes.bool, /** * The currently selected sections. * This prop accept four formats: diff --git a/packages/x-date-pickers/src/DateTimePicker/DateTimePicker.tsx b/packages/x-date-pickers/src/DateTimePicker/DateTimePicker.tsx index 9043b9d73b3f..5b7ab5831926 100644 --- a/packages/x-date-pickers/src/DateTimePicker/DateTimePicker.tsx +++ b/packages/x-date-pickers/src/DateTimePicker/DateTimePicker.tsx @@ -282,6 +282,13 @@ DateTimePicker.propTypes = { * @default () => ... */ renderLoading: PropTypes.func, + /** + * If `true`, on close will reset the value to the value when the picker was opened. + * + * Might make most sense when in need of resetting the value on modal dismiss/close. + * @default `true` for mobile, `false` for desktop. + */ + resetValueOnClose: PropTypes.bool, /** * The currently selected sections. * This prop accept four formats: diff --git a/packages/x-date-pickers/src/DesktopDatePicker/DesktopDatePicker.tsx b/packages/x-date-pickers/src/DesktopDatePicker/DesktopDatePicker.tsx index 23916f4d9c2f..99eff4899c10 100644 --- a/packages/x-date-pickers/src/DesktopDatePicker/DesktopDatePicker.tsx +++ b/packages/x-date-pickers/src/DesktopDatePicker/DesktopDatePicker.tsx @@ -280,6 +280,13 @@ DesktopDatePicker.propTypes = { * @default () => ... */ renderLoading: PropTypes.func, + /** + * If `true`, on close will reset the value to the value when the picker was opened. + * + * Might make most sense when in need of resetting the value on modal dismiss/close. + * @default `true` for mobile, `false` for desktop. + */ + resetValueOnClose: PropTypes.bool, /** * The currently selected sections. * This prop accept four formats: diff --git a/packages/x-date-pickers/src/DesktopDateTimePicker/DesktopDateTimePicker.tsx b/packages/x-date-pickers/src/DesktopDateTimePicker/DesktopDateTimePicker.tsx index bf8c882bfb5a..abfcdb5cf0ac 100644 --- a/packages/x-date-pickers/src/DesktopDateTimePicker/DesktopDateTimePicker.tsx +++ b/packages/x-date-pickers/src/DesktopDateTimePicker/DesktopDateTimePicker.tsx @@ -324,6 +324,13 @@ DesktopDateTimePicker.propTypes = { * @default () => ... */ renderLoading: PropTypes.func, + /** + * If `true`, on close will reset the value to the value when the picker was opened. + * + * Might make most sense when in need of resetting the value on modal dismiss/close. + * @default `true` for mobile, `false` for desktop. + */ + resetValueOnClose: PropTypes.bool, /** * The currently selected sections. * This prop accept four formats: diff --git a/packages/x-date-pickers/src/DesktopTimePicker/DesktopTimePicker.tsx b/packages/x-date-pickers/src/DesktopTimePicker/DesktopTimePicker.tsx index 5bf97ccc608c..2342bab3cbef 100644 --- a/packages/x-date-pickers/src/DesktopTimePicker/DesktopTimePicker.tsx +++ b/packages/x-date-pickers/src/DesktopTimePicker/DesktopTimePicker.tsx @@ -238,6 +238,13 @@ DesktopTimePicker.propTypes = { */ orientation: PropTypes.oneOf(['landscape', 'portrait']), readOnly: PropTypes.bool, + /** + * If `true`, on close will reset the value to the value when the picker was opened. + * + * Might make most sense when in need of resetting the value on modal dismiss/close. + * @default `true` for mobile, `false` for desktop. + */ + resetValueOnClose: PropTypes.bool, /** * The currently selected sections. * This prop accept four formats: diff --git a/packages/x-date-pickers/src/MobileDatePicker/MobileDatePicker.tsx b/packages/x-date-pickers/src/MobileDatePicker/MobileDatePicker.tsx index 59388614b9b4..8f3a139e8b99 100644 --- a/packages/x-date-pickers/src/MobileDatePicker/MobileDatePicker.tsx +++ b/packages/x-date-pickers/src/MobileDatePicker/MobileDatePicker.tsx @@ -282,6 +282,13 @@ MobileDatePicker.propTypes = { * @default () => ... */ renderLoading: PropTypes.func, + /** + * If `true`, on close will reset the value to the value when the picker was opened. + * + * Might make most sense when in need of resetting the value on modal dismiss/close. + * @default `true` for mobile, `false` for desktop. + */ + resetValueOnClose: PropTypes.bool, /** * The currently selected sections. * This prop accept four formats: diff --git a/packages/x-date-pickers/src/MobileDateTimePicker/MobileDateTimePicker.tsx b/packages/x-date-pickers/src/MobileDateTimePicker/MobileDateTimePicker.tsx index afbe7c00f217..f257a50969bf 100644 --- a/packages/x-date-pickers/src/MobileDateTimePicker/MobileDateTimePicker.tsx +++ b/packages/x-date-pickers/src/MobileDateTimePicker/MobileDateTimePicker.tsx @@ -326,6 +326,13 @@ MobileDateTimePicker.propTypes = { * @default () => ... */ renderLoading: PropTypes.func, + /** + * If `true`, on close will reset the value to the value when the picker was opened. + * + * Might make most sense when in need of resetting the value on modal dismiss/close. + * @default `true` for mobile, `false` for desktop. + */ + resetValueOnClose: PropTypes.bool, /** * The currently selected sections. * This prop accept four formats: diff --git a/packages/x-date-pickers/src/MobileTimePicker/MobileTimePicker.tsx b/packages/x-date-pickers/src/MobileTimePicker/MobileTimePicker.tsx index efef81e12a4e..1ab5c3ae9738 100644 --- a/packages/x-date-pickers/src/MobileTimePicker/MobileTimePicker.tsx +++ b/packages/x-date-pickers/src/MobileTimePicker/MobileTimePicker.tsx @@ -236,6 +236,13 @@ MobileTimePicker.propTypes = { */ orientation: PropTypes.oneOf(['landscape', 'portrait']), readOnly: PropTypes.bool, + /** + * If `true`, on close will reset the value to the value when the picker was opened. + * + * Might make most sense when in need of resetting the value on modal dismiss/close. + * @default `true` for mobile, `false` for desktop. + */ + resetValueOnClose: PropTypes.bool, /** * The currently selected sections. * This prop accept four formats: diff --git a/packages/x-date-pickers/src/TimePicker/TimePicker.tsx b/packages/x-date-pickers/src/TimePicker/TimePicker.tsx index 57d0d26ea0fa..0ead5eb2add4 100644 --- a/packages/x-date-pickers/src/TimePicker/TimePicker.tsx +++ b/packages/x-date-pickers/src/TimePicker/TimePicker.tsx @@ -205,6 +205,13 @@ TimePicker.propTypes = { */ orientation: PropTypes.oneOf(['landscape', 'portrait']), readOnly: PropTypes.bool, + /** + * If `true`, on close will reset the value to the value when the picker was opened. + * + * Might make most sense when in need of resetting the value on modal dismiss/close. + * @default `true` for mobile, `false` for desktop. + */ + resetValueOnClose: PropTypes.bool, /** * The currently selected sections. * This prop accept four formats: From 6a7604236b0baded733e570c4b91257abf4d42ef Mon Sep 17 00:00:00 2001 From: Lukas Tyla Date: Thu, 26 Jan 2023 23:23:41 +0000 Subject: [PATCH 4/9] docs:api --- docs/pages/x/api/date-pickers/date-picker.json | 4 ++++ docs/pages/x/api/date-pickers/date-range-picker.json | 4 ++++ docs/pages/x/api/date-pickers/date-time-picker.json | 4 ++++ docs/pages/x/api/date-pickers/desktop-date-picker.json | 4 ++++ docs/pages/x/api/date-pickers/desktop-date-range-picker.json | 4 ++++ docs/pages/x/api/date-pickers/desktop-date-time-picker.json | 4 ++++ docs/pages/x/api/date-pickers/desktop-time-picker.json | 4 ++++ docs/pages/x/api/date-pickers/mobile-date-picker.json | 4 ++++ docs/pages/x/api/date-pickers/mobile-date-range-picker.json | 4 ++++ docs/pages/x/api/date-pickers/mobile-date-time-picker.json | 4 ++++ docs/pages/x/api/date-pickers/mobile-time-picker.json | 4 ++++ docs/pages/x/api/date-pickers/time-picker.json | 4 ++++ docs/translations/api-docs/date-pickers/date-picker.json | 1 + .../translations/api-docs/date-pickers/date-range-picker.json | 1 + docs/translations/api-docs/date-pickers/date-time-picker.json | 1 + .../api-docs/date-pickers/desktop-date-picker.json | 1 + .../api-docs/date-pickers/desktop-date-range-picker.json | 1 + .../api-docs/date-pickers/desktop-date-time-picker.json | 1 + .../api-docs/date-pickers/desktop-time-picker.json | 1 + .../api-docs/date-pickers/mobile-date-picker.json | 1 + .../api-docs/date-pickers/mobile-date-range-picker.json | 1 + .../api-docs/date-pickers/mobile-date-time-picker.json | 1 + .../api-docs/date-pickers/mobile-time-picker.json | 1 + docs/translations/api-docs/date-pickers/time-picker.json | 1 + 24 files changed, 60 insertions(+) diff --git a/docs/pages/x/api/date-pickers/date-picker.json b/docs/pages/x/api/date-pickers/date-picker.json index b6d2ac49accc..2d4205bbc78b 100644 --- a/docs/pages/x/api/date-pickers/date-picker.json +++ b/docs/pages/x/api/date-pickers/date-picker.json @@ -75,6 +75,10 @@ "type": { "name": "func" }, "default": "() => ..." }, + "resetValueOnClose": { + "type": { "name": "bool" }, + "default": "`true` for mobile, `false` for desktop." + }, "selectedSections": { "type": { "name": "union", diff --git a/docs/pages/x/api/date-pickers/date-range-picker.json b/docs/pages/x/api/date-pickers/date-range-picker.json index 7d778a8bb33e..d9792b7544c9 100644 --- a/docs/pages/x/api/date-pickers/date-range-picker.json +++ b/docs/pages/x/api/date-pickers/date-range-picker.json @@ -59,6 +59,10 @@ "default": "typeof navigator !== 'undefined' && /(android)/i.test(navigator.userAgent)" }, "renderLoading": { "type": { "name": "func" }, "default": "() => \"...\"" }, + "resetValueOnClose": { + "type": { "name": "bool" }, + "default": "`true` for mobile, `false` for desktop." + }, "selectedSections": { "type": { "name": "union", diff --git a/docs/pages/x/api/date-pickers/date-time-picker.json b/docs/pages/x/api/date-pickers/date-time-picker.json index 3f41e232d507..e38f01fb74b6 100644 --- a/docs/pages/x/api/date-pickers/date-time-picker.json +++ b/docs/pages/x/api/date-pickers/date-time-picker.json @@ -83,6 +83,10 @@ "type": { "name": "func" }, "default": "() => ..." }, + "resetValueOnClose": { + "type": { "name": "bool" }, + "default": "`true` for mobile, `false` for desktop." + }, "selectedSections": { "type": { "name": "union", diff --git a/docs/pages/x/api/date-pickers/desktop-date-picker.json b/docs/pages/x/api/date-pickers/desktop-date-picker.json index 383d948dc778..6ef4a1ea121f 100644 --- a/docs/pages/x/api/date-pickers/desktop-date-picker.json +++ b/docs/pages/x/api/date-pickers/desktop-date-picker.json @@ -71,6 +71,10 @@ "type": { "name": "func" }, "default": "() => ..." }, + "resetValueOnClose": { + "type": { "name": "bool" }, + "default": "`true` for mobile, `false` for desktop." + }, "selectedSections": { "type": { "name": "union", diff --git a/docs/pages/x/api/date-pickers/desktop-date-range-picker.json b/docs/pages/x/api/date-pickers/desktop-date-range-picker.json index 5380766ba363..1da1acd29a06 100644 --- a/docs/pages/x/api/date-pickers/desktop-date-range-picker.json +++ b/docs/pages/x/api/date-pickers/desktop-date-range-picker.json @@ -55,6 +55,10 @@ "default": "typeof navigator !== 'undefined' && /(android)/i.test(navigator.userAgent)" }, "renderLoading": { "type": { "name": "func" }, "default": "() => \"...\"" }, + "resetValueOnClose": { + "type": { "name": "bool" }, + "default": "`true` for mobile, `false` for desktop." + }, "selectedSections": { "type": { "name": "union", diff --git a/docs/pages/x/api/date-pickers/desktop-date-time-picker.json b/docs/pages/x/api/date-pickers/desktop-date-time-picker.json index 7b2ae9eb7792..69403ee797e9 100644 --- a/docs/pages/x/api/date-pickers/desktop-date-time-picker.json +++ b/docs/pages/x/api/date-pickers/desktop-date-time-picker.json @@ -79,6 +79,10 @@ "type": { "name": "func" }, "default": "() => ..." }, + "resetValueOnClose": { + "type": { "name": "bool" }, + "default": "`true` for mobile, `false` for desktop." + }, "selectedSections": { "type": { "name": "union", diff --git a/docs/pages/x/api/date-pickers/desktop-time-picker.json b/docs/pages/x/api/date-pickers/desktop-time-picker.json index bc8acba73b4d..101c94316e2d 100644 --- a/docs/pages/x/api/date-pickers/desktop-time-picker.json +++ b/docs/pages/x/api/date-pickers/desktop-time-picker.json @@ -52,6 +52,10 @@ "orientation": { "type": { "name": "enum", "description": "'landscape'
| 'portrait'" } }, + "resetValueOnClose": { + "type": { "name": "bool" }, + "default": "`true` for mobile, `false` for desktop." + }, "selectedSections": { "type": { "name": "union", diff --git a/docs/pages/x/api/date-pickers/mobile-date-picker.json b/docs/pages/x/api/date-pickers/mobile-date-picker.json index dc665267d5e4..ef64cc1da4d4 100644 --- a/docs/pages/x/api/date-pickers/mobile-date-picker.json +++ b/docs/pages/x/api/date-pickers/mobile-date-picker.json @@ -71,6 +71,10 @@ "type": { "name": "func" }, "default": "() => ..." }, + "resetValueOnClose": { + "type": { "name": "bool" }, + "default": "`true` for mobile, `false` for desktop." + }, "selectedSections": { "type": { "name": "union", diff --git a/docs/pages/x/api/date-pickers/mobile-date-range-picker.json b/docs/pages/x/api/date-pickers/mobile-date-range-picker.json index 78a587fe6257..67729fd05169 100644 --- a/docs/pages/x/api/date-pickers/mobile-date-range-picker.json +++ b/docs/pages/x/api/date-pickers/mobile-date-range-picker.json @@ -55,6 +55,10 @@ "default": "typeof navigator !== 'undefined' && /(android)/i.test(navigator.userAgent)" }, "renderLoading": { "type": { "name": "func" }, "default": "() => \"...\"" }, + "resetValueOnClose": { + "type": { "name": "bool" }, + "default": "`true` for mobile, `false` for desktop." + }, "selectedSections": { "type": { "name": "union", diff --git a/docs/pages/x/api/date-pickers/mobile-date-time-picker.json b/docs/pages/x/api/date-pickers/mobile-date-time-picker.json index c84f8876ac18..359fc21bd0b7 100644 --- a/docs/pages/x/api/date-pickers/mobile-date-time-picker.json +++ b/docs/pages/x/api/date-pickers/mobile-date-time-picker.json @@ -79,6 +79,10 @@ "type": { "name": "func" }, "default": "() => ..." }, + "resetValueOnClose": { + "type": { "name": "bool" }, + "default": "`true` for mobile, `false` for desktop." + }, "selectedSections": { "type": { "name": "union", diff --git a/docs/pages/x/api/date-pickers/mobile-time-picker.json b/docs/pages/x/api/date-pickers/mobile-time-picker.json index 1b90c8d99357..0f94a007e65c 100644 --- a/docs/pages/x/api/date-pickers/mobile-time-picker.json +++ b/docs/pages/x/api/date-pickers/mobile-time-picker.json @@ -52,6 +52,10 @@ "orientation": { "type": { "name": "enum", "description": "'landscape'
| 'portrait'" } }, + "resetValueOnClose": { + "type": { "name": "bool" }, + "default": "`true` for mobile, `false` for desktop." + }, "selectedSections": { "type": { "name": "union", diff --git a/docs/pages/x/api/date-pickers/time-picker.json b/docs/pages/x/api/date-pickers/time-picker.json index 2f4867f2ba96..0eff0971a97a 100644 --- a/docs/pages/x/api/date-pickers/time-picker.json +++ b/docs/pages/x/api/date-pickers/time-picker.json @@ -56,6 +56,10 @@ "orientation": { "type": { "name": "enum", "description": "'landscape'
| 'portrait'" } }, + "resetValueOnClose": { + "type": { "name": "bool" }, + "default": "`true` for mobile, `false` for desktop." + }, "selectedSections": { "type": { "name": "union", diff --git a/docs/translations/api-docs/date-pickers/date-picker.json b/docs/translations/api-docs/date-pickers/date-picker.json index 38cd6555f6cb..33508c82d590 100644 --- a/docs/translations/api-docs/date-pickers/date-picker.json +++ b/docs/translations/api-docs/date-pickers/date-picker.json @@ -39,6 +39,7 @@ "orientation": "Force rendering in particular orientation.", "reduceAnimations": "Disable heavy animations.", "renderLoading": "Component displaying when passed loading true.

Signature:
function() => React.ReactNode

returns (React.ReactNode): The node to render when loading.", + "resetValueOnClose": "If true, on close will reset the value to the value when the picker was opened.
Might make most sense when in need of resetting the value on modal dismiss/close.", "selectedSections": "The currently selected sections. This prop accept four formats: 1. If a number is provided, the section at this index will be selected. 2. If an object with a startIndex and endIndex properties are provided, the sections between those two indexes will be selected. 3. If a string of type MuiDateSectionName is provided, the first section with that name will be selected. 4. If null is provided, no section will be selected If not provided, the selected sections will be handled internally.", "shouldDisableDate": "Disable specific date.

Signature:
function(day: TDate) => boolean
day: The date to test.
returns (boolean): If true the date will be disabled.", "shouldDisableMonth": "Disable specific month.

Signature:
function(month: TDate) => boolean
month: The month to test.
returns (boolean): If true, the month will be disabled.", diff --git a/docs/translations/api-docs/date-pickers/date-range-picker.json b/docs/translations/api-docs/date-pickers/date-range-picker.json index 0fc09069a662..38f748563d75 100644 --- a/docs/translations/api-docs/date-pickers/date-range-picker.json +++ b/docs/translations/api-docs/date-pickers/date-range-picker.json @@ -35,6 +35,7 @@ "open": "Control the popup or dialog open state.", "reduceAnimations": "Disable heavy animations.", "renderLoading": "Component displaying when passed loading true.

Signature:
function() => React.ReactNode

returns (React.ReactNode): The node to render when loading.", + "resetValueOnClose": "If true, on close will reset the value to the value when the picker was opened.
Might make most sense when in need of resetting the value on modal dismiss/close.", "selectedSections": "The currently selected sections. This prop accept four formats: 1. If a number is provided, the section at this index will be selected. 2. If an object with a startIndex and endIndex properties are provided, the sections between those two indexes will be selected. 3. If a string of type MuiDateSectionName is provided, the first section with that name will be selected. 4. If null is provided, no section will be selected If not provided, the selected sections will be handled internally.", "shouldDisableDate": "Disable specific date. @DateIOType

Signature:
function(day: TDate, position: string) => boolean
day: The date to test.
position: The date to test, 'start' or 'end'.
returns (boolean): Returns true if the date should be disabled.", "showDaysOutsideCurrentMonth": "If true, days outside the current month are rendered:
- if fixedWeekNumber is defined, renders days to have the weeks requested.
- if fixedWeekNumber is not defined, renders day to fill the first and last week of the current month.
- ignored if calendars equals more than 1 on range pickers.", diff --git a/docs/translations/api-docs/date-pickers/date-time-picker.json b/docs/translations/api-docs/date-pickers/date-time-picker.json index afcae97b6bce..2ff8cc9208be 100644 --- a/docs/translations/api-docs/date-pickers/date-time-picker.json +++ b/docs/translations/api-docs/date-pickers/date-time-picker.json @@ -47,6 +47,7 @@ "orientation": "Force rendering in particular orientation.", "reduceAnimations": "Disable heavy animations.", "renderLoading": "Component displaying when passed loading true.

Signature:
function() => React.ReactNode

returns (React.ReactNode): The node to render when loading.", + "resetValueOnClose": "If true, on close will reset the value to the value when the picker was opened.
Might make most sense when in need of resetting the value on modal dismiss/close.", "selectedSections": "The currently selected sections. This prop accept four formats: 1. If a number is provided, the section at this index will be selected. 2. If an object with a startIndex and endIndex properties are provided, the sections between those two indexes will be selected. 3. If a string of type MuiDateSectionName is provided, the first section with that name will be selected. 4. If null is provided, no section will be selected If not provided, the selected sections will be handled internally.", "shouldDisableClock": "Disable specific clock time.

Signature:
function(clockValue: number, view: TimeView) => boolean
clockValue: The value to check.
view: The clock type of the timeValue.
returns (boolean): If true the time will be disabled.", "shouldDisableDate": "Disable specific date.

Signature:
function(day: TDate) => boolean
day: The date to test.
returns (boolean): If true the date will be disabled.", diff --git a/docs/translations/api-docs/date-pickers/desktop-date-picker.json b/docs/translations/api-docs/date-pickers/desktop-date-picker.json index 5252bd5ac411..b5653462f611 100644 --- a/docs/translations/api-docs/date-pickers/desktop-date-picker.json +++ b/docs/translations/api-docs/date-pickers/desktop-date-picker.json @@ -38,6 +38,7 @@ "orientation": "Force rendering in particular orientation.", "reduceAnimations": "Disable heavy animations.", "renderLoading": "Component displaying when passed loading true.

Signature:
function() => React.ReactNode

returns (React.ReactNode): The node to render when loading.", + "resetValueOnClose": "If true, on close will reset the value to the value when the picker was opened.
Might make most sense when in need of resetting the value on modal dismiss/close.", "selectedSections": "The currently selected sections. This prop accept four formats: 1. If a number is provided, the section at this index will be selected. 2. If an object with a startIndex and endIndex properties are provided, the sections between those two indexes will be selected. 3. If a string of type MuiDateSectionName is provided, the first section with that name will be selected. 4. If null is provided, no section will be selected If not provided, the selected sections will be handled internally.", "shouldDisableDate": "Disable specific date.

Signature:
function(day: TDate) => boolean
day: The date to test.
returns (boolean): If true the date will be disabled.", "shouldDisableMonth": "Disable specific month.

Signature:
function(month: TDate) => boolean
month: The month to test.
returns (boolean): If true, the month will be disabled.", diff --git a/docs/translations/api-docs/date-pickers/desktop-date-range-picker.json b/docs/translations/api-docs/date-pickers/desktop-date-range-picker.json index 72ce374dcc61..3507ba6bf56b 100644 --- a/docs/translations/api-docs/date-pickers/desktop-date-range-picker.json +++ b/docs/translations/api-docs/date-pickers/desktop-date-range-picker.json @@ -34,6 +34,7 @@ "open": "Control the popup or dialog open state.", "reduceAnimations": "Disable heavy animations.", "renderLoading": "Component displaying when passed loading true.

Signature:
function() => React.ReactNode

returns (React.ReactNode): The node to render when loading.", + "resetValueOnClose": "If true, on close will reset the value to the value when the picker was opened.
Might make most sense when in need of resetting the value on modal dismiss/close.", "selectedSections": "The currently selected sections. This prop accept four formats: 1. If a number is provided, the section at this index will be selected. 2. If an object with a startIndex and endIndex properties are provided, the sections between those two indexes will be selected. 3. If a string of type MuiDateSectionName is provided, the first section with that name will be selected. 4. If null is provided, no section will be selected If not provided, the selected sections will be handled internally.", "shouldDisableDate": "Disable specific date. @DateIOType

Signature:
function(day: TDate, position: string) => boolean
day: The date to test.
position: The date to test, 'start' or 'end'.
returns (boolean): Returns true if the date should be disabled.", "showDaysOutsideCurrentMonth": "If true, days outside the current month are rendered:
- if fixedWeekNumber is defined, renders days to have the weeks requested.
- if fixedWeekNumber is not defined, renders day to fill the first and last week of the current month.
- ignored if calendars equals more than 1 on range pickers.", diff --git a/docs/translations/api-docs/date-pickers/desktop-date-time-picker.json b/docs/translations/api-docs/date-pickers/desktop-date-time-picker.json index 37924622ca25..0e981ee9fb2d 100644 --- a/docs/translations/api-docs/date-pickers/desktop-date-time-picker.json +++ b/docs/translations/api-docs/date-pickers/desktop-date-time-picker.json @@ -46,6 +46,7 @@ "orientation": "Force rendering in particular orientation.", "reduceAnimations": "Disable heavy animations.", "renderLoading": "Component displaying when passed loading true.

Signature:
function() => React.ReactNode

returns (React.ReactNode): The node to render when loading.", + "resetValueOnClose": "If true, on close will reset the value to the value when the picker was opened.
Might make most sense when in need of resetting the value on modal dismiss/close.", "selectedSections": "The currently selected sections. This prop accept four formats: 1. If a number is provided, the section at this index will be selected. 2. If an object with a startIndex and endIndex properties are provided, the sections between those two indexes will be selected. 3. If a string of type MuiDateSectionName is provided, the first section with that name will be selected. 4. If null is provided, no section will be selected If not provided, the selected sections will be handled internally.", "shouldDisableClock": "Disable specific clock time.

Signature:
function(clockValue: number, view: TimeView) => boolean
clockValue: The value to check.
view: The clock type of the timeValue.
returns (boolean): If true the time will be disabled.", "shouldDisableDate": "Disable specific date.

Signature:
function(day: TDate) => boolean
day: The date to test.
returns (boolean): If true the date will be disabled.", diff --git a/docs/translations/api-docs/date-pickers/desktop-time-picker.json b/docs/translations/api-docs/date-pickers/desktop-time-picker.json index eaf59d5fd652..e8d33512357a 100644 --- a/docs/translations/api-docs/date-pickers/desktop-time-picker.json +++ b/docs/translations/api-docs/date-pickers/desktop-time-picker.json @@ -31,6 +31,7 @@ "open": "Control the popup or dialog open state.", "openTo": "The default visible view. Used when the component view is not controlled. Must be a valid option from views list.", "orientation": "Force rendering in particular orientation.", + "resetValueOnClose": "If true, on close will reset the value to the value when the picker was opened.
Might make most sense when in need of resetting the value on modal dismiss/close.", "selectedSections": "The currently selected sections. This prop accept four formats: 1. If a number is provided, the section at this index will be selected. 2. If an object with a startIndex and endIndex properties are provided, the sections between those two indexes will be selected. 3. If a string of type MuiDateSectionName is provided, the first section with that name will be selected. 4. If null is provided, no section will be selected If not provided, the selected sections will be handled internally.", "shouldDisableClock": "Disable specific clock time.

Signature:
function(clockValue: number, view: TimeView) => boolean
clockValue: The value to check.
view: The clock type of the timeValue.
returns (boolean): If true the time will be disabled.", "shouldDisableTime": "Disable specific time.

Signature:
function(value: TDate, view: TimeView) => boolean
value: The value to check.
view: The clock type of the timeValue.
returns (boolean): If true the time will be disabled.", diff --git a/docs/translations/api-docs/date-pickers/mobile-date-picker.json b/docs/translations/api-docs/date-pickers/mobile-date-picker.json index d32bbd46dd89..9d8d31fb8b50 100644 --- a/docs/translations/api-docs/date-pickers/mobile-date-picker.json +++ b/docs/translations/api-docs/date-pickers/mobile-date-picker.json @@ -38,6 +38,7 @@ "orientation": "Force rendering in particular orientation.", "reduceAnimations": "Disable heavy animations.", "renderLoading": "Component displaying when passed loading true.

Signature:
function() => React.ReactNode

returns (React.ReactNode): The node to render when loading.", + "resetValueOnClose": "If true, on close will reset the value to the value when the picker was opened.
Might make most sense when in need of resetting the value on modal dismiss/close.", "selectedSections": "The currently selected sections. This prop accept four formats: 1. If a number is provided, the section at this index will be selected. 2. If an object with a startIndex and endIndex properties are provided, the sections between those two indexes will be selected. 3. If a string of type MuiDateSectionName is provided, the first section with that name will be selected. 4. If null is provided, no section will be selected If not provided, the selected sections will be handled internally.", "shouldDisableDate": "Disable specific date.

Signature:
function(day: TDate) => boolean
day: The date to test.
returns (boolean): If true the date will be disabled.", "shouldDisableMonth": "Disable specific month.

Signature:
function(month: TDate) => boolean
month: The month to test.
returns (boolean): If true, the month will be disabled.", diff --git a/docs/translations/api-docs/date-pickers/mobile-date-range-picker.json b/docs/translations/api-docs/date-pickers/mobile-date-range-picker.json index 44ef59e1f062..80c221460933 100644 --- a/docs/translations/api-docs/date-pickers/mobile-date-range-picker.json +++ b/docs/translations/api-docs/date-pickers/mobile-date-range-picker.json @@ -34,6 +34,7 @@ "open": "Control the popup or dialog open state.", "reduceAnimations": "Disable heavy animations.", "renderLoading": "Component displaying when passed loading true.

Signature:
function() => React.ReactNode

returns (React.ReactNode): The node to render when loading.", + "resetValueOnClose": "If true, on close will reset the value to the value when the picker was opened.
Might make most sense when in need of resetting the value on modal dismiss/close.", "selectedSections": "The currently selected sections. This prop accept four formats: 1. If a number is provided, the section at this index will be selected. 2. If an object with a startIndex and endIndex properties are provided, the sections between those two indexes will be selected. 3. If a string of type MuiDateSectionName is provided, the first section with that name will be selected. 4. If null is provided, no section will be selected If not provided, the selected sections will be handled internally.", "shouldDisableDate": "Disable specific date. @DateIOType

Signature:
function(day: TDate, position: string) => boolean
day: The date to test.
position: The date to test, 'start' or 'end'.
returns (boolean): Returns true if the date should be disabled.", "showDaysOutsideCurrentMonth": "If true, days outside the current month are rendered:
- if fixedWeekNumber is defined, renders days to have the weeks requested.
- if fixedWeekNumber is not defined, renders day to fill the first and last week of the current month.
- ignored if calendars equals more than 1 on range pickers.", diff --git a/docs/translations/api-docs/date-pickers/mobile-date-time-picker.json b/docs/translations/api-docs/date-pickers/mobile-date-time-picker.json index d8b80f6a97c3..899f2e5eb268 100644 --- a/docs/translations/api-docs/date-pickers/mobile-date-time-picker.json +++ b/docs/translations/api-docs/date-pickers/mobile-date-time-picker.json @@ -46,6 +46,7 @@ "orientation": "Force rendering in particular orientation.", "reduceAnimations": "Disable heavy animations.", "renderLoading": "Component displaying when passed loading true.

Signature:
function() => React.ReactNode

returns (React.ReactNode): The node to render when loading.", + "resetValueOnClose": "If true, on close will reset the value to the value when the picker was opened.
Might make most sense when in need of resetting the value on modal dismiss/close.", "selectedSections": "The currently selected sections. This prop accept four formats: 1. If a number is provided, the section at this index will be selected. 2. If an object with a startIndex and endIndex properties are provided, the sections between those two indexes will be selected. 3. If a string of type MuiDateSectionName is provided, the first section with that name will be selected. 4. If null is provided, no section will be selected If not provided, the selected sections will be handled internally.", "shouldDisableClock": "Disable specific clock time.

Signature:
function(clockValue: number, view: TimeView) => boolean
clockValue: The value to check.
view: The clock type of the timeValue.
returns (boolean): If true the time will be disabled.", "shouldDisableDate": "Disable specific date.

Signature:
function(day: TDate) => boolean
day: The date to test.
returns (boolean): If true the date will be disabled.", diff --git a/docs/translations/api-docs/date-pickers/mobile-time-picker.json b/docs/translations/api-docs/date-pickers/mobile-time-picker.json index 824ef794f313..59709a5cdc95 100644 --- a/docs/translations/api-docs/date-pickers/mobile-time-picker.json +++ b/docs/translations/api-docs/date-pickers/mobile-time-picker.json @@ -31,6 +31,7 @@ "open": "Control the popup or dialog open state.", "openTo": "The default visible view. Used when the component view is not controlled. Must be a valid option from views list.", "orientation": "Force rendering in particular orientation.", + "resetValueOnClose": "If true, on close will reset the value to the value when the picker was opened.
Might make most sense when in need of resetting the value on modal dismiss/close.", "selectedSections": "The currently selected sections. This prop accept four formats: 1. If a number is provided, the section at this index will be selected. 2. If an object with a startIndex and endIndex properties are provided, the sections between those two indexes will be selected. 3. If a string of type MuiDateSectionName is provided, the first section with that name will be selected. 4. If null is provided, no section will be selected If not provided, the selected sections will be handled internally.", "shouldDisableClock": "Disable specific clock time.

Signature:
function(clockValue: number, view: TimeView) => boolean
clockValue: The value to check.
view: The clock type of the timeValue.
returns (boolean): If true the time will be disabled.", "shouldDisableTime": "Disable specific time.

Signature:
function(value: TDate, view: TimeView) => boolean
value: The value to check.
view: The clock type of the timeValue.
returns (boolean): If true the time will be disabled.", diff --git a/docs/translations/api-docs/date-pickers/time-picker.json b/docs/translations/api-docs/date-pickers/time-picker.json index 6e5ba0059c18..fe11168b4292 100644 --- a/docs/translations/api-docs/date-pickers/time-picker.json +++ b/docs/translations/api-docs/date-pickers/time-picker.json @@ -32,6 +32,7 @@ "open": "Control the popup or dialog open state.", "openTo": "The default visible view. Used when the component view is not controlled. Must be a valid option from views list.", "orientation": "Force rendering in particular orientation.", + "resetValueOnClose": "If true, on close will reset the value to the value when the picker was opened.
Might make most sense when in need of resetting the value on modal dismiss/close.", "selectedSections": "The currently selected sections. This prop accept four formats: 1. If a number is provided, the section at this index will be selected. 2. If an object with a startIndex and endIndex properties are provided, the sections between those two indexes will be selected. 3. If a string of type MuiDateSectionName is provided, the first section with that name will be selected. 4. If null is provided, no section will be selected If not provided, the selected sections will be handled internally.", "shouldDisableClock": "Disable specific clock time.

Signature:
function(clockValue: number, view: TimeView) => boolean
clockValue: The value to check.
view: The clock type of the timeValue.
returns (boolean): If true the time will be disabled.", "shouldDisableTime": "Disable specific time.

Signature:
function(value: TDate, view: TimeView) => boolean
value: The value to check.
view: The clock type of the timeValue.
returns (boolean): If true the time will be disabled.", From e6075da46b352fc125a1f8cad322a75c4dc48814 Mon Sep 17 00:00:00 2001 From: Lukas Tyla Date: Fri, 27 Jan 2023 16:51:45 +0000 Subject: [PATCH 5/9] Code review: Alex - call `handleCancel` when `resetValueOnClose` --- .../src/internals/hooks/usePicker/usePickerValue.ts | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/packages/x-date-pickers/src/internals/hooks/usePicker/usePickerValue.ts b/packages/x-date-pickers/src/internals/hooks/usePicker/usePickerValue.ts index bc63a8a6bd5b..c018ff3e33a7 100644 --- a/packages/x-date-pickers/src/internals/hooks/usePicker/usePickerValue.ts +++ b/packages/x-date-pickers/src/internals/hooks/usePicker/usePickerValue.ts @@ -437,10 +437,7 @@ export const usePickerValue = < const handleDismiss = useEventCallback(() => { // Set all dates in state to equal the last committed date. // e.g. Reset the state to the last committed value. - setDate({ - value: resetValueOnClose ? dateState.resetFallback : dateState.committed, - action: 'acceptAndClose', - }); + setDate({ value: dateState.committed, action: 'acceptAndClose' }); }); const handleCancel = useEventCallback(() => { @@ -503,7 +500,7 @@ export const usePickerValue = < const actions: UsePickerValueActions = { onClear: handleClear, onAccept: handleAccept, - onDismiss: handleDismiss, + onDismiss: resetValueOnClose ? handleCancel : handleDismiss, onCancel: handleCancel, onSetToday: handleSetToday, onOpen: handleOpen, From 27ebc687e18f9e5fc3ba51c3973632f3421dc62a Mon Sep 17 00:00:00 2001 From: Lukas Tyla Date: Fri, 27 Jan 2023 16:54:53 +0000 Subject: [PATCH 6/9] Rename to `resetValueOnDismiss` to align with action name --- .../src/internals/hooks/usePicker/usePickerValue.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/x-date-pickers/src/internals/hooks/usePicker/usePickerValue.ts b/packages/x-date-pickers/src/internals/hooks/usePicker/usePickerValue.ts index c018ff3e33a7..b414803ff19a 100644 --- a/packages/x-date-pickers/src/internals/hooks/usePicker/usePickerValue.ts +++ b/packages/x-date-pickers/src/internals/hooks/usePicker/usePickerValue.ts @@ -207,12 +207,12 @@ export interface UsePickerValueNonStaticProps */ onOpen?: () => void; /** - * If `true`, on close will reset the value to the value when the picker was opened. + * If `true`, on dismiss will reset the value to the value when the picker was opened. * - * Might make most sense when in need of resetting the value on modal dismiss/close. + * Might make most sense when in need of resetting the value on modal dismiss. * @default `true` for mobile, `false` for desktop. */ - resetValueOnClose?: boolean; + resetValueOnDismiss?: boolean; } /** @@ -309,7 +309,7 @@ export const usePickerValue = < closeOnSelect = wrapperVariant === 'desktop', selectedSections: selectedSectionsProp, onSelectedSectionsChange, - resetValueOnClose = wrapperVariant !== 'desktop', + resetValueOnDismiss = wrapperVariant !== 'desktop', } = props; const utils = useUtils(); @@ -500,7 +500,7 @@ export const usePickerValue = < const actions: UsePickerValueActions = { onClear: handleClear, onAccept: handleAccept, - onDismiss: resetValueOnClose ? handleCancel : handleDismiss, + onDismiss: resetValueOnDismiss ? handleCancel : handleDismiss, onCancel: handleCancel, onSetToday: handleSetToday, onOpen: handleOpen, From de8a9230d90fffd2d0dcdebce85cd657010fe4a5 Mon Sep 17 00:00:00 2001 From: Lukas Tyla Date: Fri, 27 Jan 2023 16:54:59 +0000 Subject: [PATCH 7/9] proptypes --- .../src/DateRangePicker/DateRangePicker.tsx | 6 +++--- .../src/DesktopDateRangePicker/DesktopDateRangePicker.tsx | 6 +++--- .../src/MobileDateRangePicker/MobileDateRangePicker.tsx | 6 +++--- packages/x-date-pickers/src/DatePicker/DatePicker.tsx | 6 +++--- .../x-date-pickers/src/DateTimePicker/DateTimePicker.tsx | 6 +++--- .../src/DesktopDatePicker/DesktopDatePicker.tsx | 6 +++--- .../src/DesktopDateTimePicker/DesktopDateTimePicker.tsx | 6 +++--- .../src/DesktopTimePicker/DesktopTimePicker.tsx | 6 +++--- .../src/MobileDatePicker/MobileDatePicker.tsx | 6 +++--- .../src/MobileDateTimePicker/MobileDateTimePicker.tsx | 6 +++--- .../src/MobileTimePicker/MobileTimePicker.tsx | 6 +++--- packages/x-date-pickers/src/TimePicker/TimePicker.tsx | 6 +++--- 12 files changed, 36 insertions(+), 36 deletions(-) diff --git a/packages/x-date-pickers-pro/src/DateRangePicker/DateRangePicker.tsx b/packages/x-date-pickers-pro/src/DateRangePicker/DateRangePicker.tsx index 26b9e23dc260..f82e69bffd71 100644 --- a/packages/x-date-pickers-pro/src/DateRangePicker/DateRangePicker.tsx +++ b/packages/x-date-pickers-pro/src/DateRangePicker/DateRangePicker.tsx @@ -219,12 +219,12 @@ DateRangePicker.propTypes = { */ renderLoading: PropTypes.func, /** - * If `true`, on close will reset the value to the value when the picker was opened. + * If `true`, on dismiss will reset the value to the value when the picker was opened. * - * Might make most sense when in need of resetting the value on modal dismiss/close. + * Might make most sense when in need of resetting the value on modal dismiss. * @default `true` for mobile, `false` for desktop. */ - resetValueOnClose: PropTypes.bool, + resetValueOnDismiss: PropTypes.bool, /** * The currently selected sections. * This prop accept four formats: diff --git a/packages/x-date-pickers-pro/src/DesktopDateRangePicker/DesktopDateRangePicker.tsx b/packages/x-date-pickers-pro/src/DesktopDateRangePicker/DesktopDateRangePicker.tsx index 33a484a2ada9..4fbb3fe037da 100644 --- a/packages/x-date-pickers-pro/src/DesktopDateRangePicker/DesktopDateRangePicker.tsx +++ b/packages/x-date-pickers-pro/src/DesktopDateRangePicker/DesktopDateRangePicker.tsx @@ -248,12 +248,12 @@ DesktopDateRangePicker.propTypes = { */ renderLoading: PropTypes.func, /** - * If `true`, on close will reset the value to the value when the picker was opened. + * If `true`, on dismiss will reset the value to the value when the picker was opened. * - * Might make most sense when in need of resetting the value on modal dismiss/close. + * Might make most sense when in need of resetting the value on modal dismiss. * @default `true` for mobile, `false` for desktop. */ - resetValueOnClose: PropTypes.bool, + resetValueOnDismiss: PropTypes.bool, /** * The currently selected sections. * This prop accept four formats: diff --git a/packages/x-date-pickers-pro/src/MobileDateRangePicker/MobileDateRangePicker.tsx b/packages/x-date-pickers-pro/src/MobileDateRangePicker/MobileDateRangePicker.tsx index 2ddb580cccae..4ba92930624a 100644 --- a/packages/x-date-pickers-pro/src/MobileDateRangePicker/MobileDateRangePicker.tsx +++ b/packages/x-date-pickers-pro/src/MobileDateRangePicker/MobileDateRangePicker.tsx @@ -248,12 +248,12 @@ MobileDateRangePicker.propTypes = { */ renderLoading: PropTypes.func, /** - * If `true`, on close will reset the value to the value when the picker was opened. + * If `true`, on dismiss will reset the value to the value when the picker was opened. * - * Might make most sense when in need of resetting the value on modal dismiss/close. + * Might make most sense when in need of resetting the value on modal dismiss. * @default `true` for mobile, `false` for desktop. */ - resetValueOnClose: PropTypes.bool, + resetValueOnDismiss: PropTypes.bool, /** * The currently selected sections. * This prop accept four formats: diff --git a/packages/x-date-pickers/src/DatePicker/DatePicker.tsx b/packages/x-date-pickers/src/DatePicker/DatePicker.tsx index b1927cc5ae86..2daefe890a21 100644 --- a/packages/x-date-pickers/src/DatePicker/DatePicker.tsx +++ b/packages/x-date-pickers/src/DatePicker/DatePicker.tsx @@ -245,12 +245,12 @@ DatePicker.propTypes = { */ renderLoading: PropTypes.func, /** - * If `true`, on close will reset the value to the value when the picker was opened. + * If `true`, on dismiss will reset the value to the value when the picker was opened. * - * Might make most sense when in need of resetting the value on modal dismiss/close. + * Might make most sense when in need of resetting the value on modal dismiss. * @default `true` for mobile, `false` for desktop. */ - resetValueOnClose: PropTypes.bool, + resetValueOnDismiss: PropTypes.bool, /** * The currently selected sections. * This prop accept four formats: diff --git a/packages/x-date-pickers/src/DateTimePicker/DateTimePicker.tsx b/packages/x-date-pickers/src/DateTimePicker/DateTimePicker.tsx index 5b7ab5831926..ff874c96addf 100644 --- a/packages/x-date-pickers/src/DateTimePicker/DateTimePicker.tsx +++ b/packages/x-date-pickers/src/DateTimePicker/DateTimePicker.tsx @@ -283,12 +283,12 @@ DateTimePicker.propTypes = { */ renderLoading: PropTypes.func, /** - * If `true`, on close will reset the value to the value when the picker was opened. + * If `true`, on dismiss will reset the value to the value when the picker was opened. * - * Might make most sense when in need of resetting the value on modal dismiss/close. + * Might make most sense when in need of resetting the value on modal dismiss. * @default `true` for mobile, `false` for desktop. */ - resetValueOnClose: PropTypes.bool, + resetValueOnDismiss: PropTypes.bool, /** * The currently selected sections. * This prop accept four formats: diff --git a/packages/x-date-pickers/src/DesktopDatePicker/DesktopDatePicker.tsx b/packages/x-date-pickers/src/DesktopDatePicker/DesktopDatePicker.tsx index 99eff4899c10..25bbf17b318c 100644 --- a/packages/x-date-pickers/src/DesktopDatePicker/DesktopDatePicker.tsx +++ b/packages/x-date-pickers/src/DesktopDatePicker/DesktopDatePicker.tsx @@ -281,12 +281,12 @@ DesktopDatePicker.propTypes = { */ renderLoading: PropTypes.func, /** - * If `true`, on close will reset the value to the value when the picker was opened. + * If `true`, on dismiss will reset the value to the value when the picker was opened. * - * Might make most sense when in need of resetting the value on modal dismiss/close. + * Might make most sense when in need of resetting the value on modal dismiss. * @default `true` for mobile, `false` for desktop. */ - resetValueOnClose: PropTypes.bool, + resetValueOnDismiss: PropTypes.bool, /** * The currently selected sections. * This prop accept four formats: diff --git a/packages/x-date-pickers/src/DesktopDateTimePicker/DesktopDateTimePicker.tsx b/packages/x-date-pickers/src/DesktopDateTimePicker/DesktopDateTimePicker.tsx index abfcdb5cf0ac..902fe2b11fce 100644 --- a/packages/x-date-pickers/src/DesktopDateTimePicker/DesktopDateTimePicker.tsx +++ b/packages/x-date-pickers/src/DesktopDateTimePicker/DesktopDateTimePicker.tsx @@ -325,12 +325,12 @@ DesktopDateTimePicker.propTypes = { */ renderLoading: PropTypes.func, /** - * If `true`, on close will reset the value to the value when the picker was opened. + * If `true`, on dismiss will reset the value to the value when the picker was opened. * - * Might make most sense when in need of resetting the value on modal dismiss/close. + * Might make most sense when in need of resetting the value on modal dismiss. * @default `true` for mobile, `false` for desktop. */ - resetValueOnClose: PropTypes.bool, + resetValueOnDismiss: PropTypes.bool, /** * The currently selected sections. * This prop accept four formats: diff --git a/packages/x-date-pickers/src/DesktopTimePicker/DesktopTimePicker.tsx b/packages/x-date-pickers/src/DesktopTimePicker/DesktopTimePicker.tsx index 2342bab3cbef..227261cddc70 100644 --- a/packages/x-date-pickers/src/DesktopTimePicker/DesktopTimePicker.tsx +++ b/packages/x-date-pickers/src/DesktopTimePicker/DesktopTimePicker.tsx @@ -239,12 +239,12 @@ DesktopTimePicker.propTypes = { orientation: PropTypes.oneOf(['landscape', 'portrait']), readOnly: PropTypes.bool, /** - * If `true`, on close will reset the value to the value when the picker was opened. + * If `true`, on dismiss will reset the value to the value when the picker was opened. * - * Might make most sense when in need of resetting the value on modal dismiss/close. + * Might make most sense when in need of resetting the value on modal dismiss. * @default `true` for mobile, `false` for desktop. */ - resetValueOnClose: PropTypes.bool, + resetValueOnDismiss: PropTypes.bool, /** * The currently selected sections. * This prop accept four formats: diff --git a/packages/x-date-pickers/src/MobileDatePicker/MobileDatePicker.tsx b/packages/x-date-pickers/src/MobileDatePicker/MobileDatePicker.tsx index 8f3a139e8b99..a4642dbe238b 100644 --- a/packages/x-date-pickers/src/MobileDatePicker/MobileDatePicker.tsx +++ b/packages/x-date-pickers/src/MobileDatePicker/MobileDatePicker.tsx @@ -283,12 +283,12 @@ MobileDatePicker.propTypes = { */ renderLoading: PropTypes.func, /** - * If `true`, on close will reset the value to the value when the picker was opened. + * If `true`, on dismiss will reset the value to the value when the picker was opened. * - * Might make most sense when in need of resetting the value on modal dismiss/close. + * Might make most sense when in need of resetting the value on modal dismiss. * @default `true` for mobile, `false` for desktop. */ - resetValueOnClose: PropTypes.bool, + resetValueOnDismiss: PropTypes.bool, /** * The currently selected sections. * This prop accept four formats: diff --git a/packages/x-date-pickers/src/MobileDateTimePicker/MobileDateTimePicker.tsx b/packages/x-date-pickers/src/MobileDateTimePicker/MobileDateTimePicker.tsx index f257a50969bf..6d491ee039f9 100644 --- a/packages/x-date-pickers/src/MobileDateTimePicker/MobileDateTimePicker.tsx +++ b/packages/x-date-pickers/src/MobileDateTimePicker/MobileDateTimePicker.tsx @@ -327,12 +327,12 @@ MobileDateTimePicker.propTypes = { */ renderLoading: PropTypes.func, /** - * If `true`, on close will reset the value to the value when the picker was opened. + * If `true`, on dismiss will reset the value to the value when the picker was opened. * - * Might make most sense when in need of resetting the value on modal dismiss/close. + * Might make most sense when in need of resetting the value on modal dismiss. * @default `true` for mobile, `false` for desktop. */ - resetValueOnClose: PropTypes.bool, + resetValueOnDismiss: PropTypes.bool, /** * The currently selected sections. * This prop accept four formats: diff --git a/packages/x-date-pickers/src/MobileTimePicker/MobileTimePicker.tsx b/packages/x-date-pickers/src/MobileTimePicker/MobileTimePicker.tsx index 1ab5c3ae9738..1dbabfdda1fb 100644 --- a/packages/x-date-pickers/src/MobileTimePicker/MobileTimePicker.tsx +++ b/packages/x-date-pickers/src/MobileTimePicker/MobileTimePicker.tsx @@ -237,12 +237,12 @@ MobileTimePicker.propTypes = { orientation: PropTypes.oneOf(['landscape', 'portrait']), readOnly: PropTypes.bool, /** - * If `true`, on close will reset the value to the value when the picker was opened. + * If `true`, on dismiss will reset the value to the value when the picker was opened. * - * Might make most sense when in need of resetting the value on modal dismiss/close. + * Might make most sense when in need of resetting the value on modal dismiss. * @default `true` for mobile, `false` for desktop. */ - resetValueOnClose: PropTypes.bool, + resetValueOnDismiss: PropTypes.bool, /** * The currently selected sections. * This prop accept four formats: diff --git a/packages/x-date-pickers/src/TimePicker/TimePicker.tsx b/packages/x-date-pickers/src/TimePicker/TimePicker.tsx index 0ead5eb2add4..7876fdb1fc43 100644 --- a/packages/x-date-pickers/src/TimePicker/TimePicker.tsx +++ b/packages/x-date-pickers/src/TimePicker/TimePicker.tsx @@ -206,12 +206,12 @@ TimePicker.propTypes = { orientation: PropTypes.oneOf(['landscape', 'portrait']), readOnly: PropTypes.bool, /** - * If `true`, on close will reset the value to the value when the picker was opened. + * If `true`, on dismiss will reset the value to the value when the picker was opened. * - * Might make most sense when in need of resetting the value on modal dismiss/close. + * Might make most sense when in need of resetting the value on modal dismiss. * @default `true` for mobile, `false` for desktop. */ - resetValueOnClose: PropTypes.bool, + resetValueOnDismiss: PropTypes.bool, /** * The currently selected sections. * This prop accept four formats: From db5e5ed617fca478abbb6fa2c28e600a4f348ffb Mon Sep 17 00:00:00 2001 From: Lukas Tyla Date: Fri, 27 Jan 2023 16:55:44 +0000 Subject: [PATCH 8/9] docs:api --- docs/pages/x/api/date-pickers/date-picker.json | 2 +- docs/pages/x/api/date-pickers/date-range-picker.json | 2 +- docs/pages/x/api/date-pickers/date-time-picker.json | 2 +- docs/pages/x/api/date-pickers/desktop-date-picker.json | 2 +- docs/pages/x/api/date-pickers/desktop-date-range-picker.json | 2 +- docs/pages/x/api/date-pickers/desktop-date-time-picker.json | 2 +- docs/pages/x/api/date-pickers/desktop-time-picker.json | 2 +- docs/pages/x/api/date-pickers/mobile-date-picker.json | 2 +- docs/pages/x/api/date-pickers/mobile-date-range-picker.json | 2 +- docs/pages/x/api/date-pickers/mobile-date-time-picker.json | 2 +- docs/pages/x/api/date-pickers/mobile-time-picker.json | 2 +- docs/pages/x/api/date-pickers/time-picker.json | 2 +- docs/translations/api-docs/date-pickers/date-picker.json | 2 +- docs/translations/api-docs/date-pickers/date-range-picker.json | 2 +- docs/translations/api-docs/date-pickers/date-time-picker.json | 2 +- .../translations/api-docs/date-pickers/desktop-date-picker.json | 2 +- .../api-docs/date-pickers/desktop-date-range-picker.json | 2 +- .../api-docs/date-pickers/desktop-date-time-picker.json | 2 +- .../translations/api-docs/date-pickers/desktop-time-picker.json | 2 +- docs/translations/api-docs/date-pickers/mobile-date-picker.json | 2 +- .../api-docs/date-pickers/mobile-date-range-picker.json | 2 +- .../api-docs/date-pickers/mobile-date-time-picker.json | 2 +- docs/translations/api-docs/date-pickers/mobile-time-picker.json | 2 +- docs/translations/api-docs/date-pickers/time-picker.json | 2 +- 24 files changed, 24 insertions(+), 24 deletions(-) diff --git a/docs/pages/x/api/date-pickers/date-picker.json b/docs/pages/x/api/date-pickers/date-picker.json index 2d4205bbc78b..91fdfced439d 100644 --- a/docs/pages/x/api/date-pickers/date-picker.json +++ b/docs/pages/x/api/date-pickers/date-picker.json @@ -75,7 +75,7 @@ "type": { "name": "func" }, "default": "() => ..." }, - "resetValueOnClose": { + "resetValueOnDismiss": { "type": { "name": "bool" }, "default": "`true` for mobile, `false` for desktop." }, diff --git a/docs/pages/x/api/date-pickers/date-range-picker.json b/docs/pages/x/api/date-pickers/date-range-picker.json index d9792b7544c9..d97667bb55ac 100644 --- a/docs/pages/x/api/date-pickers/date-range-picker.json +++ b/docs/pages/x/api/date-pickers/date-range-picker.json @@ -59,7 +59,7 @@ "default": "typeof navigator !== 'undefined' && /(android)/i.test(navigator.userAgent)" }, "renderLoading": { "type": { "name": "func" }, "default": "() => \"...\"" }, - "resetValueOnClose": { + "resetValueOnDismiss": { "type": { "name": "bool" }, "default": "`true` for mobile, `false` for desktop." }, diff --git a/docs/pages/x/api/date-pickers/date-time-picker.json b/docs/pages/x/api/date-pickers/date-time-picker.json index e38f01fb74b6..9bc29617e3bd 100644 --- a/docs/pages/x/api/date-pickers/date-time-picker.json +++ b/docs/pages/x/api/date-pickers/date-time-picker.json @@ -83,7 +83,7 @@ "type": { "name": "func" }, "default": "() => ..." }, - "resetValueOnClose": { + "resetValueOnDismiss": { "type": { "name": "bool" }, "default": "`true` for mobile, `false` for desktop." }, diff --git a/docs/pages/x/api/date-pickers/desktop-date-picker.json b/docs/pages/x/api/date-pickers/desktop-date-picker.json index 6ef4a1ea121f..6789b020db55 100644 --- a/docs/pages/x/api/date-pickers/desktop-date-picker.json +++ b/docs/pages/x/api/date-pickers/desktop-date-picker.json @@ -71,7 +71,7 @@ "type": { "name": "func" }, "default": "() => ..." }, - "resetValueOnClose": { + "resetValueOnDismiss": { "type": { "name": "bool" }, "default": "`true` for mobile, `false` for desktop." }, diff --git a/docs/pages/x/api/date-pickers/desktop-date-range-picker.json b/docs/pages/x/api/date-pickers/desktop-date-range-picker.json index 1da1acd29a06..8e7c33747aac 100644 --- a/docs/pages/x/api/date-pickers/desktop-date-range-picker.json +++ b/docs/pages/x/api/date-pickers/desktop-date-range-picker.json @@ -55,7 +55,7 @@ "default": "typeof navigator !== 'undefined' && /(android)/i.test(navigator.userAgent)" }, "renderLoading": { "type": { "name": "func" }, "default": "() => \"...\"" }, - "resetValueOnClose": { + "resetValueOnDismiss": { "type": { "name": "bool" }, "default": "`true` for mobile, `false` for desktop." }, diff --git a/docs/pages/x/api/date-pickers/desktop-date-time-picker.json b/docs/pages/x/api/date-pickers/desktop-date-time-picker.json index 69403ee797e9..b6a0d90ffd3d 100644 --- a/docs/pages/x/api/date-pickers/desktop-date-time-picker.json +++ b/docs/pages/x/api/date-pickers/desktop-date-time-picker.json @@ -79,7 +79,7 @@ "type": { "name": "func" }, "default": "() => ..." }, - "resetValueOnClose": { + "resetValueOnDismiss": { "type": { "name": "bool" }, "default": "`true` for mobile, `false` for desktop." }, diff --git a/docs/pages/x/api/date-pickers/desktop-time-picker.json b/docs/pages/x/api/date-pickers/desktop-time-picker.json index 101c94316e2d..fc275c4a5929 100644 --- a/docs/pages/x/api/date-pickers/desktop-time-picker.json +++ b/docs/pages/x/api/date-pickers/desktop-time-picker.json @@ -52,7 +52,7 @@ "orientation": { "type": { "name": "enum", "description": "'landscape'
| 'portrait'" } }, - "resetValueOnClose": { + "resetValueOnDismiss": { "type": { "name": "bool" }, "default": "`true` for mobile, `false` for desktop." }, diff --git a/docs/pages/x/api/date-pickers/mobile-date-picker.json b/docs/pages/x/api/date-pickers/mobile-date-picker.json index ef64cc1da4d4..784a095aff3e 100644 --- a/docs/pages/x/api/date-pickers/mobile-date-picker.json +++ b/docs/pages/x/api/date-pickers/mobile-date-picker.json @@ -71,7 +71,7 @@ "type": { "name": "func" }, "default": "() => ..." }, - "resetValueOnClose": { + "resetValueOnDismiss": { "type": { "name": "bool" }, "default": "`true` for mobile, `false` for desktop." }, diff --git a/docs/pages/x/api/date-pickers/mobile-date-range-picker.json b/docs/pages/x/api/date-pickers/mobile-date-range-picker.json index 67729fd05169..0e3e79642bce 100644 --- a/docs/pages/x/api/date-pickers/mobile-date-range-picker.json +++ b/docs/pages/x/api/date-pickers/mobile-date-range-picker.json @@ -55,7 +55,7 @@ "default": "typeof navigator !== 'undefined' && /(android)/i.test(navigator.userAgent)" }, "renderLoading": { "type": { "name": "func" }, "default": "() => \"...\"" }, - "resetValueOnClose": { + "resetValueOnDismiss": { "type": { "name": "bool" }, "default": "`true` for mobile, `false` for desktop." }, diff --git a/docs/pages/x/api/date-pickers/mobile-date-time-picker.json b/docs/pages/x/api/date-pickers/mobile-date-time-picker.json index 359fc21bd0b7..3c7808a53dd1 100644 --- a/docs/pages/x/api/date-pickers/mobile-date-time-picker.json +++ b/docs/pages/x/api/date-pickers/mobile-date-time-picker.json @@ -79,7 +79,7 @@ "type": { "name": "func" }, "default": "() => ..." }, - "resetValueOnClose": { + "resetValueOnDismiss": { "type": { "name": "bool" }, "default": "`true` for mobile, `false` for desktop." }, diff --git a/docs/pages/x/api/date-pickers/mobile-time-picker.json b/docs/pages/x/api/date-pickers/mobile-time-picker.json index 0f94a007e65c..d9eed9cefa2a 100644 --- a/docs/pages/x/api/date-pickers/mobile-time-picker.json +++ b/docs/pages/x/api/date-pickers/mobile-time-picker.json @@ -52,7 +52,7 @@ "orientation": { "type": { "name": "enum", "description": "'landscape'
| 'portrait'" } }, - "resetValueOnClose": { + "resetValueOnDismiss": { "type": { "name": "bool" }, "default": "`true` for mobile, `false` for desktop." }, diff --git a/docs/pages/x/api/date-pickers/time-picker.json b/docs/pages/x/api/date-pickers/time-picker.json index 0eff0971a97a..fd4bfb5ae875 100644 --- a/docs/pages/x/api/date-pickers/time-picker.json +++ b/docs/pages/x/api/date-pickers/time-picker.json @@ -56,7 +56,7 @@ "orientation": { "type": { "name": "enum", "description": "'landscape'
| 'portrait'" } }, - "resetValueOnClose": { + "resetValueOnDismiss": { "type": { "name": "bool" }, "default": "`true` for mobile, `false` for desktop." }, diff --git a/docs/translations/api-docs/date-pickers/date-picker.json b/docs/translations/api-docs/date-pickers/date-picker.json index 33508c82d590..7c034705277d 100644 --- a/docs/translations/api-docs/date-pickers/date-picker.json +++ b/docs/translations/api-docs/date-pickers/date-picker.json @@ -39,7 +39,7 @@ "orientation": "Force rendering in particular orientation.", "reduceAnimations": "Disable heavy animations.", "renderLoading": "Component displaying when passed loading true.

Signature:
function() => React.ReactNode

returns (React.ReactNode): The node to render when loading.", - "resetValueOnClose": "If true, on close will reset the value to the value when the picker was opened.
Might make most sense when in need of resetting the value on modal dismiss/close.", + "resetValueOnDismiss": "If true, on dismiss will reset the value to the value when the picker was opened.
Might make most sense when in need of resetting the value on modal dismiss.", "selectedSections": "The currently selected sections. This prop accept four formats: 1. If a number is provided, the section at this index will be selected. 2. If an object with a startIndex and endIndex properties are provided, the sections between those two indexes will be selected. 3. If a string of type MuiDateSectionName is provided, the first section with that name will be selected. 4. If null is provided, no section will be selected If not provided, the selected sections will be handled internally.", "shouldDisableDate": "Disable specific date.

Signature:
function(day: TDate) => boolean
day: The date to test.
returns (boolean): If true the date will be disabled.", "shouldDisableMonth": "Disable specific month.

Signature:
function(month: TDate) => boolean
month: The month to test.
returns (boolean): If true, the month will be disabled.", diff --git a/docs/translations/api-docs/date-pickers/date-range-picker.json b/docs/translations/api-docs/date-pickers/date-range-picker.json index 38f748563d75..c1402c5138fb 100644 --- a/docs/translations/api-docs/date-pickers/date-range-picker.json +++ b/docs/translations/api-docs/date-pickers/date-range-picker.json @@ -35,7 +35,7 @@ "open": "Control the popup or dialog open state.", "reduceAnimations": "Disable heavy animations.", "renderLoading": "Component displaying when passed loading true.

Signature:
function() => React.ReactNode

returns (React.ReactNode): The node to render when loading.", - "resetValueOnClose": "If true, on close will reset the value to the value when the picker was opened.
Might make most sense when in need of resetting the value on modal dismiss/close.", + "resetValueOnDismiss": "If true, on dismiss will reset the value to the value when the picker was opened.
Might make most sense when in need of resetting the value on modal dismiss.", "selectedSections": "The currently selected sections. This prop accept four formats: 1. If a number is provided, the section at this index will be selected. 2. If an object with a startIndex and endIndex properties are provided, the sections between those two indexes will be selected. 3. If a string of type MuiDateSectionName is provided, the first section with that name will be selected. 4. If null is provided, no section will be selected If not provided, the selected sections will be handled internally.", "shouldDisableDate": "Disable specific date. @DateIOType

Signature:
function(day: TDate, position: string) => boolean
day: The date to test.
position: The date to test, 'start' or 'end'.
returns (boolean): Returns true if the date should be disabled.", "showDaysOutsideCurrentMonth": "If true, days outside the current month are rendered:
- if fixedWeekNumber is defined, renders days to have the weeks requested.
- if fixedWeekNumber is not defined, renders day to fill the first and last week of the current month.
- ignored if calendars equals more than 1 on range pickers.", diff --git a/docs/translations/api-docs/date-pickers/date-time-picker.json b/docs/translations/api-docs/date-pickers/date-time-picker.json index 2ff8cc9208be..99520f6a0bed 100644 --- a/docs/translations/api-docs/date-pickers/date-time-picker.json +++ b/docs/translations/api-docs/date-pickers/date-time-picker.json @@ -47,7 +47,7 @@ "orientation": "Force rendering in particular orientation.", "reduceAnimations": "Disable heavy animations.", "renderLoading": "Component displaying when passed loading true.

Signature:
function() => React.ReactNode

returns (React.ReactNode): The node to render when loading.", - "resetValueOnClose": "If true, on close will reset the value to the value when the picker was opened.
Might make most sense when in need of resetting the value on modal dismiss/close.", + "resetValueOnDismiss": "If true, on dismiss will reset the value to the value when the picker was opened.
Might make most sense when in need of resetting the value on modal dismiss.", "selectedSections": "The currently selected sections. This prop accept four formats: 1. If a number is provided, the section at this index will be selected. 2. If an object with a startIndex and endIndex properties are provided, the sections between those two indexes will be selected. 3. If a string of type MuiDateSectionName is provided, the first section with that name will be selected. 4. If null is provided, no section will be selected If not provided, the selected sections will be handled internally.", "shouldDisableClock": "Disable specific clock time.

Signature:
function(clockValue: number, view: TimeView) => boolean
clockValue: The value to check.
view: The clock type of the timeValue.
returns (boolean): If true the time will be disabled.", "shouldDisableDate": "Disable specific date.

Signature:
function(day: TDate) => boolean
day: The date to test.
returns (boolean): If true the date will be disabled.", diff --git a/docs/translations/api-docs/date-pickers/desktop-date-picker.json b/docs/translations/api-docs/date-pickers/desktop-date-picker.json index b5653462f611..43e05e64a6f9 100644 --- a/docs/translations/api-docs/date-pickers/desktop-date-picker.json +++ b/docs/translations/api-docs/date-pickers/desktop-date-picker.json @@ -38,7 +38,7 @@ "orientation": "Force rendering in particular orientation.", "reduceAnimations": "Disable heavy animations.", "renderLoading": "Component displaying when passed loading true.

Signature:
function() => React.ReactNode

returns (React.ReactNode): The node to render when loading.", - "resetValueOnClose": "If true, on close will reset the value to the value when the picker was opened.
Might make most sense when in need of resetting the value on modal dismiss/close.", + "resetValueOnDismiss": "If true, on dismiss will reset the value to the value when the picker was opened.
Might make most sense when in need of resetting the value on modal dismiss.", "selectedSections": "The currently selected sections. This prop accept four formats: 1. If a number is provided, the section at this index will be selected. 2. If an object with a startIndex and endIndex properties are provided, the sections between those two indexes will be selected. 3. If a string of type MuiDateSectionName is provided, the first section with that name will be selected. 4. If null is provided, no section will be selected If not provided, the selected sections will be handled internally.", "shouldDisableDate": "Disable specific date.

Signature:
function(day: TDate) => boolean
day: The date to test.
returns (boolean): If true the date will be disabled.", "shouldDisableMonth": "Disable specific month.

Signature:
function(month: TDate) => boolean
month: The month to test.
returns (boolean): If true, the month will be disabled.", diff --git a/docs/translations/api-docs/date-pickers/desktop-date-range-picker.json b/docs/translations/api-docs/date-pickers/desktop-date-range-picker.json index 3507ba6bf56b..21787abc784d 100644 --- a/docs/translations/api-docs/date-pickers/desktop-date-range-picker.json +++ b/docs/translations/api-docs/date-pickers/desktop-date-range-picker.json @@ -34,7 +34,7 @@ "open": "Control the popup or dialog open state.", "reduceAnimations": "Disable heavy animations.", "renderLoading": "Component displaying when passed loading true.

Signature:
function() => React.ReactNode

returns (React.ReactNode): The node to render when loading.", - "resetValueOnClose": "If true, on close will reset the value to the value when the picker was opened.
Might make most sense when in need of resetting the value on modal dismiss/close.", + "resetValueOnDismiss": "If true, on dismiss will reset the value to the value when the picker was opened.
Might make most sense when in need of resetting the value on modal dismiss.", "selectedSections": "The currently selected sections. This prop accept four formats: 1. If a number is provided, the section at this index will be selected. 2. If an object with a startIndex and endIndex properties are provided, the sections between those two indexes will be selected. 3. If a string of type MuiDateSectionName is provided, the first section with that name will be selected. 4. If null is provided, no section will be selected If not provided, the selected sections will be handled internally.", "shouldDisableDate": "Disable specific date. @DateIOType

Signature:
function(day: TDate, position: string) => boolean
day: The date to test.
position: The date to test, 'start' or 'end'.
returns (boolean): Returns true if the date should be disabled.", "showDaysOutsideCurrentMonth": "If true, days outside the current month are rendered:
- if fixedWeekNumber is defined, renders days to have the weeks requested.
- if fixedWeekNumber is not defined, renders day to fill the first and last week of the current month.
- ignored if calendars equals more than 1 on range pickers.", diff --git a/docs/translations/api-docs/date-pickers/desktop-date-time-picker.json b/docs/translations/api-docs/date-pickers/desktop-date-time-picker.json index 0e981ee9fb2d..e2e6ce5cf954 100644 --- a/docs/translations/api-docs/date-pickers/desktop-date-time-picker.json +++ b/docs/translations/api-docs/date-pickers/desktop-date-time-picker.json @@ -46,7 +46,7 @@ "orientation": "Force rendering in particular orientation.", "reduceAnimations": "Disable heavy animations.", "renderLoading": "Component displaying when passed loading true.

Signature:
function() => React.ReactNode

returns (React.ReactNode): The node to render when loading.", - "resetValueOnClose": "If true, on close will reset the value to the value when the picker was opened.
Might make most sense when in need of resetting the value on modal dismiss/close.", + "resetValueOnDismiss": "If true, on dismiss will reset the value to the value when the picker was opened.
Might make most sense when in need of resetting the value on modal dismiss.", "selectedSections": "The currently selected sections. This prop accept four formats: 1. If a number is provided, the section at this index will be selected. 2. If an object with a startIndex and endIndex properties are provided, the sections between those two indexes will be selected. 3. If a string of type MuiDateSectionName is provided, the first section with that name will be selected. 4. If null is provided, no section will be selected If not provided, the selected sections will be handled internally.", "shouldDisableClock": "Disable specific clock time.

Signature:
function(clockValue: number, view: TimeView) => boolean
clockValue: The value to check.
view: The clock type of the timeValue.
returns (boolean): If true the time will be disabled.", "shouldDisableDate": "Disable specific date.

Signature:
function(day: TDate) => boolean
day: The date to test.
returns (boolean): If true the date will be disabled.", diff --git a/docs/translations/api-docs/date-pickers/desktop-time-picker.json b/docs/translations/api-docs/date-pickers/desktop-time-picker.json index e8d33512357a..8d12839b83d0 100644 --- a/docs/translations/api-docs/date-pickers/desktop-time-picker.json +++ b/docs/translations/api-docs/date-pickers/desktop-time-picker.json @@ -31,7 +31,7 @@ "open": "Control the popup or dialog open state.", "openTo": "The default visible view. Used when the component view is not controlled. Must be a valid option from views list.", "orientation": "Force rendering in particular orientation.", - "resetValueOnClose": "If true, on close will reset the value to the value when the picker was opened.
Might make most sense when in need of resetting the value on modal dismiss/close.", + "resetValueOnDismiss": "If true, on dismiss will reset the value to the value when the picker was opened.
Might make most sense when in need of resetting the value on modal dismiss.", "selectedSections": "The currently selected sections. This prop accept four formats: 1. If a number is provided, the section at this index will be selected. 2. If an object with a startIndex and endIndex properties are provided, the sections between those two indexes will be selected. 3. If a string of type MuiDateSectionName is provided, the first section with that name will be selected. 4. If null is provided, no section will be selected If not provided, the selected sections will be handled internally.", "shouldDisableClock": "Disable specific clock time.

Signature:
function(clockValue: number, view: TimeView) => boolean
clockValue: The value to check.
view: The clock type of the timeValue.
returns (boolean): If true the time will be disabled.", "shouldDisableTime": "Disable specific time.

Signature:
function(value: TDate, view: TimeView) => boolean
value: The value to check.
view: The clock type of the timeValue.
returns (boolean): If true the time will be disabled.", diff --git a/docs/translations/api-docs/date-pickers/mobile-date-picker.json b/docs/translations/api-docs/date-pickers/mobile-date-picker.json index 9d8d31fb8b50..8e527bfd7dd8 100644 --- a/docs/translations/api-docs/date-pickers/mobile-date-picker.json +++ b/docs/translations/api-docs/date-pickers/mobile-date-picker.json @@ -38,7 +38,7 @@ "orientation": "Force rendering in particular orientation.", "reduceAnimations": "Disable heavy animations.", "renderLoading": "Component displaying when passed loading true.

Signature:
function() => React.ReactNode

returns (React.ReactNode): The node to render when loading.", - "resetValueOnClose": "If true, on close will reset the value to the value when the picker was opened.
Might make most sense when in need of resetting the value on modal dismiss/close.", + "resetValueOnDismiss": "If true, on dismiss will reset the value to the value when the picker was opened.
Might make most sense when in need of resetting the value on modal dismiss.", "selectedSections": "The currently selected sections. This prop accept four formats: 1. If a number is provided, the section at this index will be selected. 2. If an object with a startIndex and endIndex properties are provided, the sections between those two indexes will be selected. 3. If a string of type MuiDateSectionName is provided, the first section with that name will be selected. 4. If null is provided, no section will be selected If not provided, the selected sections will be handled internally.", "shouldDisableDate": "Disable specific date.

Signature:
function(day: TDate) => boolean
day: The date to test.
returns (boolean): If true the date will be disabled.", "shouldDisableMonth": "Disable specific month.

Signature:
function(month: TDate) => boolean
month: The month to test.
returns (boolean): If true, the month will be disabled.", diff --git a/docs/translations/api-docs/date-pickers/mobile-date-range-picker.json b/docs/translations/api-docs/date-pickers/mobile-date-range-picker.json index 80c221460933..be41c60bfccb 100644 --- a/docs/translations/api-docs/date-pickers/mobile-date-range-picker.json +++ b/docs/translations/api-docs/date-pickers/mobile-date-range-picker.json @@ -34,7 +34,7 @@ "open": "Control the popup or dialog open state.", "reduceAnimations": "Disable heavy animations.", "renderLoading": "Component displaying when passed loading true.

Signature:
function() => React.ReactNode

returns (React.ReactNode): The node to render when loading.", - "resetValueOnClose": "If true, on close will reset the value to the value when the picker was opened.
Might make most sense when in need of resetting the value on modal dismiss/close.", + "resetValueOnDismiss": "If true, on dismiss will reset the value to the value when the picker was opened.
Might make most sense when in need of resetting the value on modal dismiss.", "selectedSections": "The currently selected sections. This prop accept four formats: 1. If a number is provided, the section at this index will be selected. 2. If an object with a startIndex and endIndex properties are provided, the sections between those two indexes will be selected. 3. If a string of type MuiDateSectionName is provided, the first section with that name will be selected. 4. If null is provided, no section will be selected If not provided, the selected sections will be handled internally.", "shouldDisableDate": "Disable specific date. @DateIOType

Signature:
function(day: TDate, position: string) => boolean
day: The date to test.
position: The date to test, 'start' or 'end'.
returns (boolean): Returns true if the date should be disabled.", "showDaysOutsideCurrentMonth": "If true, days outside the current month are rendered:
- if fixedWeekNumber is defined, renders days to have the weeks requested.
- if fixedWeekNumber is not defined, renders day to fill the first and last week of the current month.
- ignored if calendars equals more than 1 on range pickers.", diff --git a/docs/translations/api-docs/date-pickers/mobile-date-time-picker.json b/docs/translations/api-docs/date-pickers/mobile-date-time-picker.json index 899f2e5eb268..c03bea10dbd3 100644 --- a/docs/translations/api-docs/date-pickers/mobile-date-time-picker.json +++ b/docs/translations/api-docs/date-pickers/mobile-date-time-picker.json @@ -46,7 +46,7 @@ "orientation": "Force rendering in particular orientation.", "reduceAnimations": "Disable heavy animations.", "renderLoading": "Component displaying when passed loading true.

Signature:
function() => React.ReactNode

returns (React.ReactNode): The node to render when loading.", - "resetValueOnClose": "If true, on close will reset the value to the value when the picker was opened.
Might make most sense when in need of resetting the value on modal dismiss/close.", + "resetValueOnDismiss": "If true, on dismiss will reset the value to the value when the picker was opened.
Might make most sense when in need of resetting the value on modal dismiss.", "selectedSections": "The currently selected sections. This prop accept four formats: 1. If a number is provided, the section at this index will be selected. 2. If an object with a startIndex and endIndex properties are provided, the sections between those two indexes will be selected. 3. If a string of type MuiDateSectionName is provided, the first section with that name will be selected. 4. If null is provided, no section will be selected If not provided, the selected sections will be handled internally.", "shouldDisableClock": "Disable specific clock time.

Signature:
function(clockValue: number, view: TimeView) => boolean
clockValue: The value to check.
view: The clock type of the timeValue.
returns (boolean): If true the time will be disabled.", "shouldDisableDate": "Disable specific date.

Signature:
function(day: TDate) => boolean
day: The date to test.
returns (boolean): If true the date will be disabled.", diff --git a/docs/translations/api-docs/date-pickers/mobile-time-picker.json b/docs/translations/api-docs/date-pickers/mobile-time-picker.json index 59709a5cdc95..ca357899bed9 100644 --- a/docs/translations/api-docs/date-pickers/mobile-time-picker.json +++ b/docs/translations/api-docs/date-pickers/mobile-time-picker.json @@ -31,7 +31,7 @@ "open": "Control the popup or dialog open state.", "openTo": "The default visible view. Used when the component view is not controlled. Must be a valid option from views list.", "orientation": "Force rendering in particular orientation.", - "resetValueOnClose": "If true, on close will reset the value to the value when the picker was opened.
Might make most sense when in need of resetting the value on modal dismiss/close.", + "resetValueOnDismiss": "If true, on dismiss will reset the value to the value when the picker was opened.
Might make most sense when in need of resetting the value on modal dismiss.", "selectedSections": "The currently selected sections. This prop accept four formats: 1. If a number is provided, the section at this index will be selected. 2. If an object with a startIndex and endIndex properties are provided, the sections between those two indexes will be selected. 3. If a string of type MuiDateSectionName is provided, the first section with that name will be selected. 4. If null is provided, no section will be selected If not provided, the selected sections will be handled internally.", "shouldDisableClock": "Disable specific clock time.

Signature:
function(clockValue: number, view: TimeView) => boolean
clockValue: The value to check.
view: The clock type of the timeValue.
returns (boolean): If true the time will be disabled.", "shouldDisableTime": "Disable specific time.

Signature:
function(value: TDate, view: TimeView) => boolean
value: The value to check.
view: The clock type of the timeValue.
returns (boolean): If true the time will be disabled.", diff --git a/docs/translations/api-docs/date-pickers/time-picker.json b/docs/translations/api-docs/date-pickers/time-picker.json index fe11168b4292..76203bf57473 100644 --- a/docs/translations/api-docs/date-pickers/time-picker.json +++ b/docs/translations/api-docs/date-pickers/time-picker.json @@ -32,7 +32,7 @@ "open": "Control the popup or dialog open state.", "openTo": "The default visible view. Used when the component view is not controlled. Must be a valid option from views list.", "orientation": "Force rendering in particular orientation.", - "resetValueOnClose": "If true, on close will reset the value to the value when the picker was opened.
Might make most sense when in need of resetting the value on modal dismiss/close.", + "resetValueOnDismiss": "If true, on dismiss will reset the value to the value when the picker was opened.
Might make most sense when in need of resetting the value on modal dismiss.", "selectedSections": "The currently selected sections. This prop accept four formats: 1. If a number is provided, the section at this index will be selected. 2. If an object with a startIndex and endIndex properties are provided, the sections between those two indexes will be selected. 3. If a string of type MuiDateSectionName is provided, the first section with that name will be selected. 4. If null is provided, no section will be selected If not provided, the selected sections will be handled internally.", "shouldDisableClock": "Disable specific clock time.

Signature:
function(clockValue: number, view: TimeView) => boolean
clockValue: The value to check.
view: The clock type of the timeValue.
returns (boolean): If true the time will be disabled.", "shouldDisableTime": "Disable specific time.

Signature:
function(value: TDate, view: TimeView) => boolean
value: The value to check.
view: The clock type of the timeValue.
returns (boolean): If true the time will be disabled.", From 362d30cb597cfaa848e044c8f5fba78c2cf37f8b Mon Sep 17 00:00:00 2001 From: Lukas Tyla Date: Mon, 30 Jan 2023 11:13:09 +0000 Subject: [PATCH 9/9] Rename the prop to correct boolean form --- docs/pages/x/api/date-pickers/date-picker.json | 8 ++++---- .../x/api/date-pickers/date-range-picker.json | 8 ++++---- .../pages/x/api/date-pickers/date-time-picker.json | 8 ++++---- .../x/api/date-pickers/desktop-date-picker.json | 8 ++++---- .../date-pickers/desktop-date-range-picker.json | 8 ++++---- .../api/date-pickers/desktop-date-time-picker.json | 8 ++++---- .../x/api/date-pickers/desktop-time-picker.json | 8 ++++---- .../x/api/date-pickers/mobile-date-picker.json | 8 ++++---- .../api/date-pickers/mobile-date-range-picker.json | 8 ++++---- .../api/date-pickers/mobile-date-time-picker.json | 8 ++++---- .../x/api/date-pickers/mobile-time-picker.json | 8 ++++---- docs/pages/x/api/date-pickers/time-picker.json | 8 ++++---- .../api-docs/date-pickers/date-picker.json | 2 +- .../api-docs/date-pickers/date-range-picker.json | 2 +- .../api-docs/date-pickers/date-time-picker.json | 2 +- .../api-docs/date-pickers/desktop-date-picker.json | 2 +- .../date-pickers/desktop-date-range-picker.json | 2 +- .../date-pickers/desktop-date-time-picker.json | 2 +- .../api-docs/date-pickers/desktop-time-picker.json | 2 +- .../api-docs/date-pickers/mobile-date-picker.json | 2 +- .../date-pickers/mobile-date-range-picker.json | 2 +- .../date-pickers/mobile-date-time-picker.json | 2 +- .../api-docs/date-pickers/mobile-time-picker.json | 2 +- .../api-docs/date-pickers/time-picker.json | 2 +- .../src/DateRangePicker/DateRangePicker.tsx | 14 +++++++------- .../DesktopDateRangePicker.tsx | 14 +++++++------- .../MobileDateRangePicker.tsx | 14 +++++++------- .../x-date-pickers/src/DatePicker/DatePicker.tsx | 14 +++++++------- .../src/DateTimePicker/DateTimePicker.tsx | 14 +++++++------- .../src/DesktopDatePicker/DesktopDatePicker.tsx | 14 +++++++------- .../DesktopDateTimePicker.tsx | 14 +++++++------- .../src/DesktopTimePicker/DesktopTimePicker.tsx | 14 +++++++------- .../src/MobileDatePicker/MobileDatePicker.tsx | 14 +++++++------- .../MobileDateTimePicker/MobileDateTimePicker.tsx | 14 +++++++------- .../src/MobileTimePicker/MobileTimePicker.tsx | 14 +++++++------- .../x-date-pickers/src/TimePicker/TimePicker.tsx | 14 +++++++------- .../internals/hooks/usePicker/usePickerValue.ts | 10 +++++----- 37 files changed, 149 insertions(+), 149 deletions(-) diff --git a/docs/pages/x/api/date-pickers/date-picker.json b/docs/pages/x/api/date-pickers/date-picker.json index 91fdfced439d..6c52ec16680b 100644 --- a/docs/pages/x/api/date-pickers/date-picker.json +++ b/docs/pages/x/api/date-pickers/date-picker.json @@ -1,5 +1,9 @@ { "props": { + "acceptValueOnDismiss": { + "type": { "name": "bool" }, + "default": "`true` for desktop, `false` for mobile." + }, "autoFocus": { "type": { "name": "bool" } }, "className": { "type": { "name": "string" } }, "closeOnSelect": { @@ -75,10 +79,6 @@ "type": { "name": "func" }, "default": "() => ..." }, - "resetValueOnDismiss": { - "type": { "name": "bool" }, - "default": "`true` for mobile, `false` for desktop." - }, "selectedSections": { "type": { "name": "union", diff --git a/docs/pages/x/api/date-pickers/date-range-picker.json b/docs/pages/x/api/date-pickers/date-range-picker.json index d97667bb55ac..e5f3d4f3a4a4 100644 --- a/docs/pages/x/api/date-pickers/date-range-picker.json +++ b/docs/pages/x/api/date-pickers/date-range-picker.json @@ -1,5 +1,9 @@ { "props": { + "acceptValueOnDismiss": { + "type": { "name": "bool" }, + "default": "`true` for desktop, `false` for mobile." + }, "autoFocus": { "type": { "name": "bool" } }, "calendars": { "type": { "name": "enum", "description": "1
| 2
| 3" }, @@ -59,10 +63,6 @@ "default": "typeof navigator !== 'undefined' && /(android)/i.test(navigator.userAgent)" }, "renderLoading": { "type": { "name": "func" }, "default": "() => \"...\"" }, - "resetValueOnDismiss": { - "type": { "name": "bool" }, - "default": "`true` for mobile, `false` for desktop." - }, "selectedSections": { "type": { "name": "union", diff --git a/docs/pages/x/api/date-pickers/date-time-picker.json b/docs/pages/x/api/date-pickers/date-time-picker.json index 9bc29617e3bd..75adfde52a44 100644 --- a/docs/pages/x/api/date-pickers/date-time-picker.json +++ b/docs/pages/x/api/date-pickers/date-time-picker.json @@ -1,5 +1,9 @@ { "props": { + "acceptValueOnDismiss": { + "type": { "name": "bool" }, + "default": "`true` for desktop, `false` for mobile." + }, "ampm": { "type": { "name": "bool" }, "default": "`utils.is12HourCycleInCurrentLocale()`" }, "ampmInClock": { "type": { "name": "bool" } }, "autoFocus": { "type": { "name": "bool" } }, @@ -83,10 +87,6 @@ "type": { "name": "func" }, "default": "() => ..." }, - "resetValueOnDismiss": { - "type": { "name": "bool" }, - "default": "`true` for mobile, `false` for desktop." - }, "selectedSections": { "type": { "name": "union", diff --git a/docs/pages/x/api/date-pickers/desktop-date-picker.json b/docs/pages/x/api/date-pickers/desktop-date-picker.json index 6789b020db55..5e6aafcca2d3 100644 --- a/docs/pages/x/api/date-pickers/desktop-date-picker.json +++ b/docs/pages/x/api/date-pickers/desktop-date-picker.json @@ -1,5 +1,9 @@ { "props": { + "acceptValueOnDismiss": { + "type": { "name": "bool" }, + "default": "`true` for desktop, `false` for mobile." + }, "autoFocus": { "type": { "name": "bool" } }, "className": { "type": { "name": "string" } }, "closeOnSelect": { @@ -71,10 +75,6 @@ "type": { "name": "func" }, "default": "() => ..." }, - "resetValueOnDismiss": { - "type": { "name": "bool" }, - "default": "`true` for mobile, `false` for desktop." - }, "selectedSections": { "type": { "name": "union", diff --git a/docs/pages/x/api/date-pickers/desktop-date-range-picker.json b/docs/pages/x/api/date-pickers/desktop-date-range-picker.json index 8e7c33747aac..c403e3a0ac51 100644 --- a/docs/pages/x/api/date-pickers/desktop-date-range-picker.json +++ b/docs/pages/x/api/date-pickers/desktop-date-range-picker.json @@ -1,5 +1,9 @@ { "props": { + "acceptValueOnDismiss": { + "type": { "name": "bool" }, + "default": "`true` for desktop, `false` for mobile." + }, "autoFocus": { "type": { "name": "bool" } }, "calendars": { "type": { "name": "enum", "description": "1
| 2
| 3" }, @@ -55,10 +59,6 @@ "default": "typeof navigator !== 'undefined' && /(android)/i.test(navigator.userAgent)" }, "renderLoading": { "type": { "name": "func" }, "default": "() => \"...\"" }, - "resetValueOnDismiss": { - "type": { "name": "bool" }, - "default": "`true` for mobile, `false` for desktop." - }, "selectedSections": { "type": { "name": "union", diff --git a/docs/pages/x/api/date-pickers/desktop-date-time-picker.json b/docs/pages/x/api/date-pickers/desktop-date-time-picker.json index b6a0d90ffd3d..46562e0f1314 100644 --- a/docs/pages/x/api/date-pickers/desktop-date-time-picker.json +++ b/docs/pages/x/api/date-pickers/desktop-date-time-picker.json @@ -1,5 +1,9 @@ { "props": { + "acceptValueOnDismiss": { + "type": { "name": "bool" }, + "default": "`true` for desktop, `false` for mobile." + }, "ampm": { "type": { "name": "bool" }, "default": "`utils.is12HourCycleInCurrentLocale()`" }, "ampmInClock": { "type": { "name": "bool" } }, "autoFocus": { "type": { "name": "bool" } }, @@ -79,10 +83,6 @@ "type": { "name": "func" }, "default": "() => ..." }, - "resetValueOnDismiss": { - "type": { "name": "bool" }, - "default": "`true` for mobile, `false` for desktop." - }, "selectedSections": { "type": { "name": "union", diff --git a/docs/pages/x/api/date-pickers/desktop-time-picker.json b/docs/pages/x/api/date-pickers/desktop-time-picker.json index fc275c4a5929..5d3164d42167 100644 --- a/docs/pages/x/api/date-pickers/desktop-time-picker.json +++ b/docs/pages/x/api/date-pickers/desktop-time-picker.json @@ -1,5 +1,9 @@ { "props": { + "acceptValueOnDismiss": { + "type": { "name": "bool" }, + "default": "`true` for desktop, `false` for mobile." + }, "ampm": { "type": { "name": "bool" }, "default": "`utils.is12HourCycleInCurrentLocale()`" }, "ampmInClock": { "type": { "name": "bool" } }, "autoFocus": { "type": { "name": "bool" } }, @@ -52,10 +56,6 @@ "orientation": { "type": { "name": "enum", "description": "'landscape'
| 'portrait'" } }, - "resetValueOnDismiss": { - "type": { "name": "bool" }, - "default": "`true` for mobile, `false` for desktop." - }, "selectedSections": { "type": { "name": "union", diff --git a/docs/pages/x/api/date-pickers/mobile-date-picker.json b/docs/pages/x/api/date-pickers/mobile-date-picker.json index 784a095aff3e..c01fbc7eee28 100644 --- a/docs/pages/x/api/date-pickers/mobile-date-picker.json +++ b/docs/pages/x/api/date-pickers/mobile-date-picker.json @@ -1,5 +1,9 @@ { "props": { + "acceptValueOnDismiss": { + "type": { "name": "bool" }, + "default": "`true` for desktop, `false` for mobile." + }, "autoFocus": { "type": { "name": "bool" } }, "className": { "type": { "name": "string" } }, "closeOnSelect": { @@ -71,10 +75,6 @@ "type": { "name": "func" }, "default": "() => ..." }, - "resetValueOnDismiss": { - "type": { "name": "bool" }, - "default": "`true` for mobile, `false` for desktop." - }, "selectedSections": { "type": { "name": "union", diff --git a/docs/pages/x/api/date-pickers/mobile-date-range-picker.json b/docs/pages/x/api/date-pickers/mobile-date-range-picker.json index 0e3e79642bce..415794ef3949 100644 --- a/docs/pages/x/api/date-pickers/mobile-date-range-picker.json +++ b/docs/pages/x/api/date-pickers/mobile-date-range-picker.json @@ -1,5 +1,9 @@ { "props": { + "acceptValueOnDismiss": { + "type": { "name": "bool" }, + "default": "`true` for desktop, `false` for mobile." + }, "autoFocus": { "type": { "name": "bool" } }, "calendars": { "type": { "name": "enum", "description": "1
| 2
| 3" }, @@ -55,10 +59,6 @@ "default": "typeof navigator !== 'undefined' && /(android)/i.test(navigator.userAgent)" }, "renderLoading": { "type": { "name": "func" }, "default": "() => \"...\"" }, - "resetValueOnDismiss": { - "type": { "name": "bool" }, - "default": "`true` for mobile, `false` for desktop." - }, "selectedSections": { "type": { "name": "union", diff --git a/docs/pages/x/api/date-pickers/mobile-date-time-picker.json b/docs/pages/x/api/date-pickers/mobile-date-time-picker.json index 3c7808a53dd1..7294e4cacb7a 100644 --- a/docs/pages/x/api/date-pickers/mobile-date-time-picker.json +++ b/docs/pages/x/api/date-pickers/mobile-date-time-picker.json @@ -1,5 +1,9 @@ { "props": { + "acceptValueOnDismiss": { + "type": { "name": "bool" }, + "default": "`true` for desktop, `false` for mobile." + }, "ampm": { "type": { "name": "bool" }, "default": "`utils.is12HourCycleInCurrentLocale()`" }, "ampmInClock": { "type": { "name": "bool" } }, "autoFocus": { "type": { "name": "bool" } }, @@ -79,10 +83,6 @@ "type": { "name": "func" }, "default": "() => ..." }, - "resetValueOnDismiss": { - "type": { "name": "bool" }, - "default": "`true` for mobile, `false` for desktop." - }, "selectedSections": { "type": { "name": "union", diff --git a/docs/pages/x/api/date-pickers/mobile-time-picker.json b/docs/pages/x/api/date-pickers/mobile-time-picker.json index d9eed9cefa2a..04e3713d5551 100644 --- a/docs/pages/x/api/date-pickers/mobile-time-picker.json +++ b/docs/pages/x/api/date-pickers/mobile-time-picker.json @@ -1,5 +1,9 @@ { "props": { + "acceptValueOnDismiss": { + "type": { "name": "bool" }, + "default": "`true` for desktop, `false` for mobile." + }, "ampm": { "type": { "name": "bool" }, "default": "`utils.is12HourCycleInCurrentLocale()`" }, "ampmInClock": { "type": { "name": "bool" } }, "autoFocus": { "type": { "name": "bool" } }, @@ -52,10 +56,6 @@ "orientation": { "type": { "name": "enum", "description": "'landscape'
| 'portrait'" } }, - "resetValueOnDismiss": { - "type": { "name": "bool" }, - "default": "`true` for mobile, `false` for desktop." - }, "selectedSections": { "type": { "name": "union", diff --git a/docs/pages/x/api/date-pickers/time-picker.json b/docs/pages/x/api/date-pickers/time-picker.json index fd4bfb5ae875..8e4aa5212fef 100644 --- a/docs/pages/x/api/date-pickers/time-picker.json +++ b/docs/pages/x/api/date-pickers/time-picker.json @@ -1,5 +1,9 @@ { "props": { + "acceptValueOnDismiss": { + "type": { "name": "bool" }, + "default": "`true` for desktop, `false` for mobile." + }, "ampm": { "type": { "name": "bool" }, "default": "`utils.is12HourCycleInCurrentLocale()`" }, "ampmInClock": { "type": { "name": "bool" } }, "autoFocus": { "type": { "name": "bool" } }, @@ -56,10 +60,6 @@ "orientation": { "type": { "name": "enum", "description": "'landscape'
| 'portrait'" } }, - "resetValueOnDismiss": { - "type": { "name": "bool" }, - "default": "`true` for mobile, `false` for desktop." - }, "selectedSections": { "type": { "name": "union", diff --git a/docs/translations/api-docs/date-pickers/date-picker.json b/docs/translations/api-docs/date-pickers/date-picker.json index 7c034705277d..0658aab711a3 100644 --- a/docs/translations/api-docs/date-pickers/date-picker.json +++ b/docs/translations/api-docs/date-pickers/date-picker.json @@ -1,6 +1,7 @@ { "componentDescription": "", "propDescriptions": { + "acceptValueOnDismiss": "If false, on dismiss will reset the value to the value when the picker was opened.
Might make most sense when in need of resetting the value on modal dismiss.", "autoFocus": "If true, the main element is focused during the first mount. This main element is: - the element chosen by the visible view if any (i.e: the selected day on the day view). - the input element if there is a field rendered.", "className": "Class name applied to the root element.", "closeOnSelect": "If true, the popover or modal will close after submitting the full date.", @@ -39,7 +40,6 @@ "orientation": "Force rendering in particular orientation.", "reduceAnimations": "Disable heavy animations.", "renderLoading": "Component displaying when passed loading true.

Signature:
function() => React.ReactNode

returns (React.ReactNode): The node to render when loading.", - "resetValueOnDismiss": "If true, on dismiss will reset the value to the value when the picker was opened.
Might make most sense when in need of resetting the value on modal dismiss.", "selectedSections": "The currently selected sections. This prop accept four formats: 1. If a number is provided, the section at this index will be selected. 2. If an object with a startIndex and endIndex properties are provided, the sections between those two indexes will be selected. 3. If a string of type MuiDateSectionName is provided, the first section with that name will be selected. 4. If null is provided, no section will be selected If not provided, the selected sections will be handled internally.", "shouldDisableDate": "Disable specific date.

Signature:
function(day: TDate) => boolean
day: The date to test.
returns (boolean): If true the date will be disabled.", "shouldDisableMonth": "Disable specific month.

Signature:
function(month: TDate) => boolean
month: The month to test.
returns (boolean): If true, the month will be disabled.", diff --git a/docs/translations/api-docs/date-pickers/date-range-picker.json b/docs/translations/api-docs/date-pickers/date-range-picker.json index c1402c5138fb..9f75558d3c65 100644 --- a/docs/translations/api-docs/date-pickers/date-range-picker.json +++ b/docs/translations/api-docs/date-pickers/date-range-picker.json @@ -1,6 +1,7 @@ { "componentDescription": "", "propDescriptions": { + "acceptValueOnDismiss": "If false, on dismiss will reset the value to the value when the picker was opened.
Might make most sense when in need of resetting the value on modal dismiss.", "autoFocus": "If true, the main element is focused during the first mount. This main element is: - the element chosen by the visible view if any (i.e: the selected day on the day view). - the input element if there is a field rendered.", "calendars": "The number of calendars to render on desktop.", "className": "Class name applied to the root element.", @@ -35,7 +36,6 @@ "open": "Control the popup or dialog open state.", "reduceAnimations": "Disable heavy animations.", "renderLoading": "Component displaying when passed loading true.

Signature:
function() => React.ReactNode

returns (React.ReactNode): The node to render when loading.", - "resetValueOnDismiss": "If true, on dismiss will reset the value to the value when the picker was opened.
Might make most sense when in need of resetting the value on modal dismiss.", "selectedSections": "The currently selected sections. This prop accept four formats: 1. If a number is provided, the section at this index will be selected. 2. If an object with a startIndex and endIndex properties are provided, the sections between those two indexes will be selected. 3. If a string of type MuiDateSectionName is provided, the first section with that name will be selected. 4. If null is provided, no section will be selected If not provided, the selected sections will be handled internally.", "shouldDisableDate": "Disable specific date. @DateIOType

Signature:
function(day: TDate, position: string) => boolean
day: The date to test.
position: The date to test, 'start' or 'end'.
returns (boolean): Returns true if the date should be disabled.", "showDaysOutsideCurrentMonth": "If true, days outside the current month are rendered:
- if fixedWeekNumber is defined, renders days to have the weeks requested.
- if fixedWeekNumber is not defined, renders day to fill the first and last week of the current month.
- ignored if calendars equals more than 1 on range pickers.", diff --git a/docs/translations/api-docs/date-pickers/date-time-picker.json b/docs/translations/api-docs/date-pickers/date-time-picker.json index 99520f6a0bed..477d65687cec 100644 --- a/docs/translations/api-docs/date-pickers/date-time-picker.json +++ b/docs/translations/api-docs/date-pickers/date-time-picker.json @@ -1,6 +1,7 @@ { "componentDescription": "", "propDescriptions": { + "acceptValueOnDismiss": "If false, on dismiss will reset the value to the value when the picker was opened.
Might make most sense when in need of resetting the value on modal dismiss.", "ampm": "12h/24h view for hour selection clock.", "ampmInClock": "Display ampm controls under the clock (instead of in the toolbar).", "autoFocus": "If true, the main element is focused during the first mount. This main element is: - the element chosen by the visible view if any (i.e: the selected day on the day view). - the input element if there is a field rendered.", @@ -47,7 +48,6 @@ "orientation": "Force rendering in particular orientation.", "reduceAnimations": "Disable heavy animations.", "renderLoading": "Component displaying when passed loading true.

Signature:
function() => React.ReactNode

returns (React.ReactNode): The node to render when loading.", - "resetValueOnDismiss": "If true, on dismiss will reset the value to the value when the picker was opened.
Might make most sense when in need of resetting the value on modal dismiss.", "selectedSections": "The currently selected sections. This prop accept four formats: 1. If a number is provided, the section at this index will be selected. 2. If an object with a startIndex and endIndex properties are provided, the sections between those two indexes will be selected. 3. If a string of type MuiDateSectionName is provided, the first section with that name will be selected. 4. If null is provided, no section will be selected If not provided, the selected sections will be handled internally.", "shouldDisableClock": "Disable specific clock time.

Signature:
function(clockValue: number, view: TimeView) => boolean
clockValue: The value to check.
view: The clock type of the timeValue.
returns (boolean): If true the time will be disabled.", "shouldDisableDate": "Disable specific date.

Signature:
function(day: TDate) => boolean
day: The date to test.
returns (boolean): If true the date will be disabled.", diff --git a/docs/translations/api-docs/date-pickers/desktop-date-picker.json b/docs/translations/api-docs/date-pickers/desktop-date-picker.json index 43e05e64a6f9..7c64e3a8fdaf 100644 --- a/docs/translations/api-docs/date-pickers/desktop-date-picker.json +++ b/docs/translations/api-docs/date-pickers/desktop-date-picker.json @@ -1,6 +1,7 @@ { "componentDescription": "", "propDescriptions": { + "acceptValueOnDismiss": "If false, on dismiss will reset the value to the value when the picker was opened.
Might make most sense when in need of resetting the value on modal dismiss.", "autoFocus": "If true, the main element is focused during the first mount. This main element is: - the element chosen by the visible view if any (i.e: the selected day on the day view). - the input element if there is a field rendered.", "className": "Class name applied to the root element.", "closeOnSelect": "If true, the popover or modal will close after submitting the full date.", @@ -38,7 +39,6 @@ "orientation": "Force rendering in particular orientation.", "reduceAnimations": "Disable heavy animations.", "renderLoading": "Component displaying when passed loading true.

Signature:
function() => React.ReactNode

returns (React.ReactNode): The node to render when loading.", - "resetValueOnDismiss": "If true, on dismiss will reset the value to the value when the picker was opened.
Might make most sense when in need of resetting the value on modal dismiss.", "selectedSections": "The currently selected sections. This prop accept four formats: 1. If a number is provided, the section at this index will be selected. 2. If an object with a startIndex and endIndex properties are provided, the sections between those two indexes will be selected. 3. If a string of type MuiDateSectionName is provided, the first section with that name will be selected. 4. If null is provided, no section will be selected If not provided, the selected sections will be handled internally.", "shouldDisableDate": "Disable specific date.

Signature:
function(day: TDate) => boolean
day: The date to test.
returns (boolean): If true the date will be disabled.", "shouldDisableMonth": "Disable specific month.

Signature:
function(month: TDate) => boolean
month: The month to test.
returns (boolean): If true, the month will be disabled.", diff --git a/docs/translations/api-docs/date-pickers/desktop-date-range-picker.json b/docs/translations/api-docs/date-pickers/desktop-date-range-picker.json index 21787abc784d..89c0b314e64e 100644 --- a/docs/translations/api-docs/date-pickers/desktop-date-range-picker.json +++ b/docs/translations/api-docs/date-pickers/desktop-date-range-picker.json @@ -1,6 +1,7 @@ { "componentDescription": "", "propDescriptions": { + "acceptValueOnDismiss": "If false, on dismiss will reset the value to the value when the picker was opened.
Might make most sense when in need of resetting the value on modal dismiss.", "autoFocus": "If true, the main element is focused during the first mount. This main element is: - the element chosen by the visible view if any (i.e: the selected day on the day view). - the input element if there is a field rendered.", "calendars": "The number of calendars to render on desktop.", "className": "Class name applied to the root element.", @@ -34,7 +35,6 @@ "open": "Control the popup or dialog open state.", "reduceAnimations": "Disable heavy animations.", "renderLoading": "Component displaying when passed loading true.

Signature:
function() => React.ReactNode

returns (React.ReactNode): The node to render when loading.", - "resetValueOnDismiss": "If true, on dismiss will reset the value to the value when the picker was opened.
Might make most sense when in need of resetting the value on modal dismiss.", "selectedSections": "The currently selected sections. This prop accept four formats: 1. If a number is provided, the section at this index will be selected. 2. If an object with a startIndex and endIndex properties are provided, the sections between those two indexes will be selected. 3. If a string of type MuiDateSectionName is provided, the first section with that name will be selected. 4. If null is provided, no section will be selected If not provided, the selected sections will be handled internally.", "shouldDisableDate": "Disable specific date. @DateIOType

Signature:
function(day: TDate, position: string) => boolean
day: The date to test.
position: The date to test, 'start' or 'end'.
returns (boolean): Returns true if the date should be disabled.", "showDaysOutsideCurrentMonth": "If true, days outside the current month are rendered:
- if fixedWeekNumber is defined, renders days to have the weeks requested.
- if fixedWeekNumber is not defined, renders day to fill the first and last week of the current month.
- ignored if calendars equals more than 1 on range pickers.", diff --git a/docs/translations/api-docs/date-pickers/desktop-date-time-picker.json b/docs/translations/api-docs/date-pickers/desktop-date-time-picker.json index e2e6ce5cf954..ce02a167bb0d 100644 --- a/docs/translations/api-docs/date-pickers/desktop-date-time-picker.json +++ b/docs/translations/api-docs/date-pickers/desktop-date-time-picker.json @@ -1,6 +1,7 @@ { "componentDescription": "", "propDescriptions": { + "acceptValueOnDismiss": "If false, on dismiss will reset the value to the value when the picker was opened.
Might make most sense when in need of resetting the value on modal dismiss.", "ampm": "12h/24h view for hour selection clock.", "ampmInClock": "Display ampm controls under the clock (instead of in the toolbar).", "autoFocus": "If true, the main element is focused during the first mount. This main element is: - the element chosen by the visible view if any (i.e: the selected day on the day view). - the input element if there is a field rendered.", @@ -46,7 +47,6 @@ "orientation": "Force rendering in particular orientation.", "reduceAnimations": "Disable heavy animations.", "renderLoading": "Component displaying when passed loading true.

Signature:
function() => React.ReactNode

returns (React.ReactNode): The node to render when loading.", - "resetValueOnDismiss": "If true, on dismiss will reset the value to the value when the picker was opened.
Might make most sense when in need of resetting the value on modal dismiss.", "selectedSections": "The currently selected sections. This prop accept four formats: 1. If a number is provided, the section at this index will be selected. 2. If an object with a startIndex and endIndex properties are provided, the sections between those two indexes will be selected. 3. If a string of type MuiDateSectionName is provided, the first section with that name will be selected. 4. If null is provided, no section will be selected If not provided, the selected sections will be handled internally.", "shouldDisableClock": "Disable specific clock time.

Signature:
function(clockValue: number, view: TimeView) => boolean
clockValue: The value to check.
view: The clock type of the timeValue.
returns (boolean): If true the time will be disabled.", "shouldDisableDate": "Disable specific date.

Signature:
function(day: TDate) => boolean
day: The date to test.
returns (boolean): If true the date will be disabled.", diff --git a/docs/translations/api-docs/date-pickers/desktop-time-picker.json b/docs/translations/api-docs/date-pickers/desktop-time-picker.json index 8d12839b83d0..aab091f07664 100644 --- a/docs/translations/api-docs/date-pickers/desktop-time-picker.json +++ b/docs/translations/api-docs/date-pickers/desktop-time-picker.json @@ -1,6 +1,7 @@ { "componentDescription": "", "propDescriptions": { + "acceptValueOnDismiss": "If false, on dismiss will reset the value to the value when the picker was opened.
Might make most sense when in need of resetting the value on modal dismiss.", "ampm": "12h/24h view for hour selection clock.", "ampmInClock": "Display ampm controls under the clock (instead of in the toolbar).", "autoFocus": "If true, the main element is focused during the first mount. This main element is: - the element chosen by the visible view if any (i.e: the selected day on the day view). - the input element if there is a field rendered.", @@ -31,7 +32,6 @@ "open": "Control the popup or dialog open state.", "openTo": "The default visible view. Used when the component view is not controlled. Must be a valid option from views list.", "orientation": "Force rendering in particular orientation.", - "resetValueOnDismiss": "If true, on dismiss will reset the value to the value when the picker was opened.
Might make most sense when in need of resetting the value on modal dismiss.", "selectedSections": "The currently selected sections. This prop accept four formats: 1. If a number is provided, the section at this index will be selected. 2. If an object with a startIndex and endIndex properties are provided, the sections between those two indexes will be selected. 3. If a string of type MuiDateSectionName is provided, the first section with that name will be selected. 4. If null is provided, no section will be selected If not provided, the selected sections will be handled internally.", "shouldDisableClock": "Disable specific clock time.

Signature:
function(clockValue: number, view: TimeView) => boolean
clockValue: The value to check.
view: The clock type of the timeValue.
returns (boolean): If true the time will be disabled.", "shouldDisableTime": "Disable specific time.

Signature:
function(value: TDate, view: TimeView) => boolean
value: The value to check.
view: The clock type of the timeValue.
returns (boolean): If true the time will be disabled.", diff --git a/docs/translations/api-docs/date-pickers/mobile-date-picker.json b/docs/translations/api-docs/date-pickers/mobile-date-picker.json index 8e527bfd7dd8..ce3065cd883e 100644 --- a/docs/translations/api-docs/date-pickers/mobile-date-picker.json +++ b/docs/translations/api-docs/date-pickers/mobile-date-picker.json @@ -1,6 +1,7 @@ { "componentDescription": "", "propDescriptions": { + "acceptValueOnDismiss": "If false, on dismiss will reset the value to the value when the picker was opened.
Might make most sense when in need of resetting the value on modal dismiss.", "autoFocus": "If true, the main element is focused during the first mount. This main element is: - the element chosen by the visible view if any (i.e: the selected day on the day view). - the input element if there is a field rendered.", "className": "Class name applied to the root element.", "closeOnSelect": "If true, the popover or modal will close after submitting the full date.", @@ -38,7 +39,6 @@ "orientation": "Force rendering in particular orientation.", "reduceAnimations": "Disable heavy animations.", "renderLoading": "Component displaying when passed loading true.

Signature:
function() => React.ReactNode

returns (React.ReactNode): The node to render when loading.", - "resetValueOnDismiss": "If true, on dismiss will reset the value to the value when the picker was opened.
Might make most sense when in need of resetting the value on modal dismiss.", "selectedSections": "The currently selected sections. This prop accept four formats: 1. If a number is provided, the section at this index will be selected. 2. If an object with a startIndex and endIndex properties are provided, the sections between those two indexes will be selected. 3. If a string of type MuiDateSectionName is provided, the first section with that name will be selected. 4. If null is provided, no section will be selected If not provided, the selected sections will be handled internally.", "shouldDisableDate": "Disable specific date.

Signature:
function(day: TDate) => boolean
day: The date to test.
returns (boolean): If true the date will be disabled.", "shouldDisableMonth": "Disable specific month.

Signature:
function(month: TDate) => boolean
month: The month to test.
returns (boolean): If true, the month will be disabled.", diff --git a/docs/translations/api-docs/date-pickers/mobile-date-range-picker.json b/docs/translations/api-docs/date-pickers/mobile-date-range-picker.json index be41c60bfccb..bd627c330c56 100644 --- a/docs/translations/api-docs/date-pickers/mobile-date-range-picker.json +++ b/docs/translations/api-docs/date-pickers/mobile-date-range-picker.json @@ -1,6 +1,7 @@ { "componentDescription": "", "propDescriptions": { + "acceptValueOnDismiss": "If false, on dismiss will reset the value to the value when the picker was opened.
Might make most sense when in need of resetting the value on modal dismiss.", "autoFocus": "If true, the main element is focused during the first mount. This main element is: - the element chosen by the visible view if any (i.e: the selected day on the day view). - the input element if there is a field rendered.", "calendars": "The number of calendars to render on desktop.", "className": "Class name applied to the root element.", @@ -34,7 +35,6 @@ "open": "Control the popup or dialog open state.", "reduceAnimations": "Disable heavy animations.", "renderLoading": "Component displaying when passed loading true.

Signature:
function() => React.ReactNode

returns (React.ReactNode): The node to render when loading.", - "resetValueOnDismiss": "If true, on dismiss will reset the value to the value when the picker was opened.
Might make most sense when in need of resetting the value on modal dismiss.", "selectedSections": "The currently selected sections. This prop accept four formats: 1. If a number is provided, the section at this index will be selected. 2. If an object with a startIndex and endIndex properties are provided, the sections between those two indexes will be selected. 3. If a string of type MuiDateSectionName is provided, the first section with that name will be selected. 4. If null is provided, no section will be selected If not provided, the selected sections will be handled internally.", "shouldDisableDate": "Disable specific date. @DateIOType

Signature:
function(day: TDate, position: string) => boolean
day: The date to test.
position: The date to test, 'start' or 'end'.
returns (boolean): Returns true if the date should be disabled.", "showDaysOutsideCurrentMonth": "If true, days outside the current month are rendered:
- if fixedWeekNumber is defined, renders days to have the weeks requested.
- if fixedWeekNumber is not defined, renders day to fill the first and last week of the current month.
- ignored if calendars equals more than 1 on range pickers.", diff --git a/docs/translations/api-docs/date-pickers/mobile-date-time-picker.json b/docs/translations/api-docs/date-pickers/mobile-date-time-picker.json index c03bea10dbd3..927778cfc18d 100644 --- a/docs/translations/api-docs/date-pickers/mobile-date-time-picker.json +++ b/docs/translations/api-docs/date-pickers/mobile-date-time-picker.json @@ -1,6 +1,7 @@ { "componentDescription": "", "propDescriptions": { + "acceptValueOnDismiss": "If false, on dismiss will reset the value to the value when the picker was opened.
Might make most sense when in need of resetting the value on modal dismiss.", "ampm": "12h/24h view for hour selection clock.", "ampmInClock": "Display ampm controls under the clock (instead of in the toolbar).", "autoFocus": "If true, the main element is focused during the first mount. This main element is: - the element chosen by the visible view if any (i.e: the selected day on the day view). - the input element if there is a field rendered.", @@ -46,7 +47,6 @@ "orientation": "Force rendering in particular orientation.", "reduceAnimations": "Disable heavy animations.", "renderLoading": "Component displaying when passed loading true.

Signature:
function() => React.ReactNode

returns (React.ReactNode): The node to render when loading.", - "resetValueOnDismiss": "If true, on dismiss will reset the value to the value when the picker was opened.
Might make most sense when in need of resetting the value on modal dismiss.", "selectedSections": "The currently selected sections. This prop accept four formats: 1. If a number is provided, the section at this index will be selected. 2. If an object with a startIndex and endIndex properties are provided, the sections between those two indexes will be selected. 3. If a string of type MuiDateSectionName is provided, the first section with that name will be selected. 4. If null is provided, no section will be selected If not provided, the selected sections will be handled internally.", "shouldDisableClock": "Disable specific clock time.

Signature:
function(clockValue: number, view: TimeView) => boolean
clockValue: The value to check.
view: The clock type of the timeValue.
returns (boolean): If true the time will be disabled.", "shouldDisableDate": "Disable specific date.

Signature:
function(day: TDate) => boolean
day: The date to test.
returns (boolean): If true the date will be disabled.", diff --git a/docs/translations/api-docs/date-pickers/mobile-time-picker.json b/docs/translations/api-docs/date-pickers/mobile-time-picker.json index ca357899bed9..31c29bb924c2 100644 --- a/docs/translations/api-docs/date-pickers/mobile-time-picker.json +++ b/docs/translations/api-docs/date-pickers/mobile-time-picker.json @@ -1,6 +1,7 @@ { "componentDescription": "", "propDescriptions": { + "acceptValueOnDismiss": "If false, on dismiss will reset the value to the value when the picker was opened.
Might make most sense when in need of resetting the value on modal dismiss.", "ampm": "12h/24h view for hour selection clock.", "ampmInClock": "Display ampm controls under the clock (instead of in the toolbar).", "autoFocus": "If true, the main element is focused during the first mount. This main element is: - the element chosen by the visible view if any (i.e: the selected day on the day view). - the input element if there is a field rendered.", @@ -31,7 +32,6 @@ "open": "Control the popup or dialog open state.", "openTo": "The default visible view. Used when the component view is not controlled. Must be a valid option from views list.", "orientation": "Force rendering in particular orientation.", - "resetValueOnDismiss": "If true, on dismiss will reset the value to the value when the picker was opened.
Might make most sense when in need of resetting the value on modal dismiss.", "selectedSections": "The currently selected sections. This prop accept four formats: 1. If a number is provided, the section at this index will be selected. 2. If an object with a startIndex and endIndex properties are provided, the sections between those two indexes will be selected. 3. If a string of type MuiDateSectionName is provided, the first section with that name will be selected. 4. If null is provided, no section will be selected If not provided, the selected sections will be handled internally.", "shouldDisableClock": "Disable specific clock time.

Signature:
function(clockValue: number, view: TimeView) => boolean
clockValue: The value to check.
view: The clock type of the timeValue.
returns (boolean): If true the time will be disabled.", "shouldDisableTime": "Disable specific time.

Signature:
function(value: TDate, view: TimeView) => boolean
value: The value to check.
view: The clock type of the timeValue.
returns (boolean): If true the time will be disabled.", diff --git a/docs/translations/api-docs/date-pickers/time-picker.json b/docs/translations/api-docs/date-pickers/time-picker.json index 76203bf57473..e9a590172f51 100644 --- a/docs/translations/api-docs/date-pickers/time-picker.json +++ b/docs/translations/api-docs/date-pickers/time-picker.json @@ -1,6 +1,7 @@ { "componentDescription": "", "propDescriptions": { + "acceptValueOnDismiss": "If false, on dismiss will reset the value to the value when the picker was opened.
Might make most sense when in need of resetting the value on modal dismiss.", "ampm": "12h/24h view for hour selection clock.", "ampmInClock": "Display ampm controls under the clock (instead of in the toolbar).", "autoFocus": "If true, the main element is focused during the first mount. This main element is: - the element chosen by the visible view if any (i.e: the selected day on the day view). - the input element if there is a field rendered.", @@ -32,7 +33,6 @@ "open": "Control the popup or dialog open state.", "openTo": "The default visible view. Used when the component view is not controlled. Must be a valid option from views list.", "orientation": "Force rendering in particular orientation.", - "resetValueOnDismiss": "If true, on dismiss will reset the value to the value when the picker was opened.
Might make most sense when in need of resetting the value on modal dismiss.", "selectedSections": "The currently selected sections. This prop accept four formats: 1. If a number is provided, the section at this index will be selected. 2. If an object with a startIndex and endIndex properties are provided, the sections between those two indexes will be selected. 3. If a string of type MuiDateSectionName is provided, the first section with that name will be selected. 4. If null is provided, no section will be selected If not provided, the selected sections will be handled internally.", "shouldDisableClock": "Disable specific clock time.

Signature:
function(clockValue: number, view: TimeView) => boolean
clockValue: The value to check.
view: The clock type of the timeValue.
returns (boolean): If true the time will be disabled.", "shouldDisableTime": "Disable specific time.

Signature:
function(value: TDate, view: TimeView) => boolean
value: The value to check.
view: The clock type of the timeValue.
returns (boolean): If true the time will be disabled.", diff --git a/packages/x-date-pickers-pro/src/DateRangePicker/DateRangePicker.tsx b/packages/x-date-pickers-pro/src/DateRangePicker/DateRangePicker.tsx index f82e69bffd71..0a94ba22f901 100644 --- a/packages/x-date-pickers-pro/src/DateRangePicker/DateRangePicker.tsx +++ b/packages/x-date-pickers-pro/src/DateRangePicker/DateRangePicker.tsx @@ -33,6 +33,13 @@ DateRangePicker.propTypes = { // | These PropTypes are generated from the TypeScript type definitions | // | To update them edit the TypeScript types and run "yarn proptypes" | // ---------------------------------------------------------------------- + /** + * If `false`, on dismiss will reset the value to the value when the picker was opened. + * + * Might make most sense when in need of resetting the value on modal dismiss. + * @default `true` for desktop, `false` for mobile. + */ + acceptValueOnDismiss: PropTypes.bool, /** * If `true`, the main element is focused during the first mount. * This main element is: @@ -218,13 +225,6 @@ DateRangePicker.propTypes = { * @default () => "..." */ renderLoading: PropTypes.func, - /** - * If `true`, on dismiss will reset the value to the value when the picker was opened. - * - * Might make most sense when in need of resetting the value on modal dismiss. - * @default `true` for mobile, `false` for desktop. - */ - resetValueOnDismiss: PropTypes.bool, /** * The currently selected sections. * This prop accept four formats: diff --git a/packages/x-date-pickers-pro/src/DesktopDateRangePicker/DesktopDateRangePicker.tsx b/packages/x-date-pickers-pro/src/DesktopDateRangePicker/DesktopDateRangePicker.tsx index 4fbb3fe037da..7e86e5571a71 100644 --- a/packages/x-date-pickers-pro/src/DesktopDateRangePicker/DesktopDateRangePicker.tsx +++ b/packages/x-date-pickers-pro/src/DesktopDateRangePicker/DesktopDateRangePicker.tsx @@ -68,6 +68,13 @@ DesktopDateRangePicker.propTypes = { // | These PropTypes are generated from the TypeScript type definitions | // | To update them edit the TypeScript types and run "yarn proptypes" | // ---------------------------------------------------------------------- + /** + * If `false`, on dismiss will reset the value to the value when the picker was opened. + * + * Might make most sense when in need of resetting the value on modal dismiss. + * @default `true` for desktop, `false` for mobile. + */ + acceptValueOnDismiss: PropTypes.bool, /** * If `true`, the main element is focused during the first mount. * This main element is: @@ -247,13 +254,6 @@ DesktopDateRangePicker.propTypes = { * @default () => "..." */ renderLoading: PropTypes.func, - /** - * If `true`, on dismiss will reset the value to the value when the picker was opened. - * - * Might make most sense when in need of resetting the value on modal dismiss. - * @default `true` for mobile, `false` for desktop. - */ - resetValueOnDismiss: PropTypes.bool, /** * The currently selected sections. * This prop accept four formats: diff --git a/packages/x-date-pickers-pro/src/MobileDateRangePicker/MobileDateRangePicker.tsx b/packages/x-date-pickers-pro/src/MobileDateRangePicker/MobileDateRangePicker.tsx index 4ba92930624a..e6d0637209b8 100644 --- a/packages/x-date-pickers-pro/src/MobileDateRangePicker/MobileDateRangePicker.tsx +++ b/packages/x-date-pickers-pro/src/MobileDateRangePicker/MobileDateRangePicker.tsx @@ -68,6 +68,13 @@ MobileDateRangePicker.propTypes = { // | These PropTypes are generated from the TypeScript type definitions | // | To update them edit the TypeScript types and run "yarn proptypes" | // ---------------------------------------------------------------------- + /** + * If `false`, on dismiss will reset the value to the value when the picker was opened. + * + * Might make most sense when in need of resetting the value on modal dismiss. + * @default `true` for desktop, `false` for mobile. + */ + acceptValueOnDismiss: PropTypes.bool, /** * If `true`, the main element is focused during the first mount. * This main element is: @@ -247,13 +254,6 @@ MobileDateRangePicker.propTypes = { * @default () => "..." */ renderLoading: PropTypes.func, - /** - * If `true`, on dismiss will reset the value to the value when the picker was opened. - * - * Might make most sense when in need of resetting the value on modal dismiss. - * @default `true` for mobile, `false` for desktop. - */ - resetValueOnDismiss: PropTypes.bool, /** * The currently selected sections. * This prop accept four formats: diff --git a/packages/x-date-pickers/src/DatePicker/DatePicker.tsx b/packages/x-date-pickers/src/DatePicker/DatePicker.tsx index 2daefe890a21..fe99d85f3f94 100644 --- a/packages/x-date-pickers/src/DatePicker/DatePicker.tsx +++ b/packages/x-date-pickers/src/DatePicker/DatePicker.tsx @@ -34,6 +34,13 @@ DatePicker.propTypes = { // | These PropTypes are generated from the TypeScript type definitions | // | To update them edit the TypeScript types and run "yarn proptypes" | // ---------------------------------------------------------------------- + /** + * If `false`, on dismiss will reset the value to the value when the picker was opened. + * + * Might make most sense when in need of resetting the value on modal dismiss. + * @default `true` for desktop, `false` for mobile. + */ + acceptValueOnDismiss: PropTypes.bool, /** * If `true`, the main element is focused during the first mount. * This main element is: @@ -244,13 +251,6 @@ DatePicker.propTypes = { * @default () => ... */ renderLoading: PropTypes.func, - /** - * If `true`, on dismiss will reset the value to the value when the picker was opened. - * - * Might make most sense when in need of resetting the value on modal dismiss. - * @default `true` for mobile, `false` for desktop. - */ - resetValueOnDismiss: PropTypes.bool, /** * The currently selected sections. * This prop accept four formats: diff --git a/packages/x-date-pickers/src/DateTimePicker/DateTimePicker.tsx b/packages/x-date-pickers/src/DateTimePicker/DateTimePicker.tsx index ff874c96addf..cad040254e88 100644 --- a/packages/x-date-pickers/src/DateTimePicker/DateTimePicker.tsx +++ b/packages/x-date-pickers/src/DateTimePicker/DateTimePicker.tsx @@ -34,6 +34,13 @@ DateTimePicker.propTypes = { // | These PropTypes are generated from the TypeScript type definitions | // | To update them edit the TypeScript types and run "yarn proptypes" | // ---------------------------------------------------------------------- + /** + * If `false`, on dismiss will reset the value to the value when the picker was opened. + * + * Might make most sense when in need of resetting the value on modal dismiss. + * @default `true` for desktop, `false` for mobile. + */ + acceptValueOnDismiss: PropTypes.bool, /** * 12h/24h view for hour selection clock. * @default `utils.is12HourCycleInCurrentLocale()` @@ -282,13 +289,6 @@ DateTimePicker.propTypes = { * @default () => ... */ renderLoading: PropTypes.func, - /** - * If `true`, on dismiss will reset the value to the value when the picker was opened. - * - * Might make most sense when in need of resetting the value on modal dismiss. - * @default `true` for mobile, `false` for desktop. - */ - resetValueOnDismiss: PropTypes.bool, /** * The currently selected sections. * This prop accept four formats: diff --git a/packages/x-date-pickers/src/DesktopDatePicker/DesktopDatePicker.tsx b/packages/x-date-pickers/src/DesktopDatePicker/DesktopDatePicker.tsx index 25bbf17b318c..462c8a7db523 100644 --- a/packages/x-date-pickers/src/DesktopDatePicker/DesktopDatePicker.tsx +++ b/packages/x-date-pickers/src/DesktopDatePicker/DesktopDatePicker.tsx @@ -76,6 +76,13 @@ DesktopDatePicker.propTypes = { // | These PropTypes are generated from the TypeScript type definitions | // | To update them edit the TypeScript types and run "yarn proptypes" | // ---------------------------------------------------------------------- + /** + * If `false`, on dismiss will reset the value to the value when the picker was opened. + * + * Might make most sense when in need of resetting the value on modal dismiss. + * @default `true` for desktop, `false` for mobile. + */ + acceptValueOnDismiss: PropTypes.bool, /** * If `true`, the main element is focused during the first mount. * This main element is: @@ -280,13 +287,6 @@ DesktopDatePicker.propTypes = { * @default () => ... */ renderLoading: PropTypes.func, - /** - * If `true`, on dismiss will reset the value to the value when the picker was opened. - * - * Might make most sense when in need of resetting the value on modal dismiss. - * @default `true` for mobile, `false` for desktop. - */ - resetValueOnDismiss: PropTypes.bool, /** * The currently selected sections. * This prop accept four formats: diff --git a/packages/x-date-pickers/src/DesktopDateTimePicker/DesktopDateTimePicker.tsx b/packages/x-date-pickers/src/DesktopDateTimePicker/DesktopDateTimePicker.tsx index 902fe2b11fce..51dd9621b4a9 100644 --- a/packages/x-date-pickers/src/DesktopDateTimePicker/DesktopDateTimePicker.tsx +++ b/packages/x-date-pickers/src/DesktopDateTimePicker/DesktopDateTimePicker.tsx @@ -82,6 +82,13 @@ DesktopDateTimePicker.propTypes = { // | These PropTypes are generated from the TypeScript type definitions | // | To update them edit the TypeScript types and run "yarn proptypes" | // ---------------------------------------------------------------------- + /** + * If `false`, on dismiss will reset the value to the value when the picker was opened. + * + * Might make most sense when in need of resetting the value on modal dismiss. + * @default `true` for desktop, `false` for mobile. + */ + acceptValueOnDismiss: PropTypes.bool, /** * 12h/24h view for hour selection clock. * @default `utils.is12HourCycleInCurrentLocale()` @@ -324,13 +331,6 @@ DesktopDateTimePicker.propTypes = { * @default () => ... */ renderLoading: PropTypes.func, - /** - * If `true`, on dismiss will reset the value to the value when the picker was opened. - * - * Might make most sense when in need of resetting the value on modal dismiss. - * @default `true` for mobile, `false` for desktop. - */ - resetValueOnDismiss: PropTypes.bool, /** * The currently selected sections. * This prop accept four formats: diff --git a/packages/x-date-pickers/src/DesktopTimePicker/DesktopTimePicker.tsx b/packages/x-date-pickers/src/DesktopTimePicker/DesktopTimePicker.tsx index 227261cddc70..61070ba58f87 100644 --- a/packages/x-date-pickers/src/DesktopTimePicker/DesktopTimePicker.tsx +++ b/packages/x-date-pickers/src/DesktopTimePicker/DesktopTimePicker.tsx @@ -73,6 +73,13 @@ DesktopTimePicker.propTypes = { // | These PropTypes are generated from the TypeScript type definitions | // | To update them edit the TypeScript types and run "yarn proptypes" | // ---------------------------------------------------------------------- + /** + * If `false`, on dismiss will reset the value to the value when the picker was opened. + * + * Might make most sense when in need of resetting the value on modal dismiss. + * @default `true` for desktop, `false` for mobile. + */ + acceptValueOnDismiss: PropTypes.bool, /** * 12h/24h view for hour selection clock. * @default `utils.is12HourCycleInCurrentLocale()` @@ -238,13 +245,6 @@ DesktopTimePicker.propTypes = { */ orientation: PropTypes.oneOf(['landscape', 'portrait']), readOnly: PropTypes.bool, - /** - * If `true`, on dismiss will reset the value to the value when the picker was opened. - * - * Might make most sense when in need of resetting the value on modal dismiss. - * @default `true` for mobile, `false` for desktop. - */ - resetValueOnDismiss: PropTypes.bool, /** * The currently selected sections. * This prop accept four formats: diff --git a/packages/x-date-pickers/src/MobileDatePicker/MobileDatePicker.tsx b/packages/x-date-pickers/src/MobileDatePicker/MobileDatePicker.tsx index a4642dbe238b..256ff640bbed 100644 --- a/packages/x-date-pickers/src/MobileDatePicker/MobileDatePicker.tsx +++ b/packages/x-date-pickers/src/MobileDatePicker/MobileDatePicker.tsx @@ -78,6 +78,13 @@ MobileDatePicker.propTypes = { // | These PropTypes are generated from the TypeScript type definitions | // | To update them edit the TypeScript types and run "yarn proptypes" | // ---------------------------------------------------------------------- + /** + * If `false`, on dismiss will reset the value to the value when the picker was opened. + * + * Might make most sense when in need of resetting the value on modal dismiss. + * @default `true` for desktop, `false` for mobile. + */ + acceptValueOnDismiss: PropTypes.bool, /** * If `true`, the main element is focused during the first mount. * This main element is: @@ -282,13 +289,6 @@ MobileDatePicker.propTypes = { * @default () => ... */ renderLoading: PropTypes.func, - /** - * If `true`, on dismiss will reset the value to the value when the picker was opened. - * - * Might make most sense when in need of resetting the value on modal dismiss. - * @default `true` for mobile, `false` for desktop. - */ - resetValueOnDismiss: PropTypes.bool, /** * The currently selected sections. * This prop accept four formats: diff --git a/packages/x-date-pickers/src/MobileDateTimePicker/MobileDateTimePicker.tsx b/packages/x-date-pickers/src/MobileDateTimePicker/MobileDateTimePicker.tsx index 6d491ee039f9..8247c2ae38cd 100644 --- a/packages/x-date-pickers/src/MobileDateTimePicker/MobileDateTimePicker.tsx +++ b/packages/x-date-pickers/src/MobileDateTimePicker/MobileDateTimePicker.tsx @@ -84,6 +84,13 @@ MobileDateTimePicker.propTypes = { // | These PropTypes are generated from the TypeScript type definitions | // | To update them edit the TypeScript types and run "yarn proptypes" | // ---------------------------------------------------------------------- + /** + * If `false`, on dismiss will reset the value to the value when the picker was opened. + * + * Might make most sense when in need of resetting the value on modal dismiss. + * @default `true` for desktop, `false` for mobile. + */ + acceptValueOnDismiss: PropTypes.bool, /** * 12h/24h view for hour selection clock. * @default `utils.is12HourCycleInCurrentLocale()` @@ -326,13 +333,6 @@ MobileDateTimePicker.propTypes = { * @default () => ... */ renderLoading: PropTypes.func, - /** - * If `true`, on dismiss will reset the value to the value when the picker was opened. - * - * Might make most sense when in need of resetting the value on modal dismiss. - * @default `true` for mobile, `false` for desktop. - */ - resetValueOnDismiss: PropTypes.bool, /** * The currently selected sections. * This prop accept four formats: diff --git a/packages/x-date-pickers/src/MobileTimePicker/MobileTimePicker.tsx b/packages/x-date-pickers/src/MobileTimePicker/MobileTimePicker.tsx index 1dbabfdda1fb..3cb80e022636 100644 --- a/packages/x-date-pickers/src/MobileTimePicker/MobileTimePicker.tsx +++ b/packages/x-date-pickers/src/MobileTimePicker/MobileTimePicker.tsx @@ -71,6 +71,13 @@ MobileTimePicker.propTypes = { // | These PropTypes are generated from the TypeScript type definitions | // | To update them edit the TypeScript types and run "yarn proptypes" | // ---------------------------------------------------------------------- + /** + * If `false`, on dismiss will reset the value to the value when the picker was opened. + * + * Might make most sense when in need of resetting the value on modal dismiss. + * @default `true` for desktop, `false` for mobile. + */ + acceptValueOnDismiss: PropTypes.bool, /** * 12h/24h view for hour selection clock. * @default `utils.is12HourCycleInCurrentLocale()` @@ -236,13 +243,6 @@ MobileTimePicker.propTypes = { */ orientation: PropTypes.oneOf(['landscape', 'portrait']), readOnly: PropTypes.bool, - /** - * If `true`, on dismiss will reset the value to the value when the picker was opened. - * - * Might make most sense when in need of resetting the value on modal dismiss. - * @default `true` for mobile, `false` for desktop. - */ - resetValueOnDismiss: PropTypes.bool, /** * The currently selected sections. * This prop accept four formats: diff --git a/packages/x-date-pickers/src/TimePicker/TimePicker.tsx b/packages/x-date-pickers/src/TimePicker/TimePicker.tsx index 7876fdb1fc43..44905995d69a 100644 --- a/packages/x-date-pickers/src/TimePicker/TimePicker.tsx +++ b/packages/x-date-pickers/src/TimePicker/TimePicker.tsx @@ -34,6 +34,13 @@ TimePicker.propTypes = { // | These PropTypes are generated from the TypeScript type definitions | // | To update them edit the TypeScript types and run "yarn proptypes" | // ---------------------------------------------------------------------- + /** + * If `false`, on dismiss will reset the value to the value when the picker was opened. + * + * Might make most sense when in need of resetting the value on modal dismiss. + * @default `true` for desktop, `false` for mobile. + */ + acceptValueOnDismiss: PropTypes.bool, /** * 12h/24h view for hour selection clock. * @default `utils.is12HourCycleInCurrentLocale()` @@ -205,13 +212,6 @@ TimePicker.propTypes = { */ orientation: PropTypes.oneOf(['landscape', 'portrait']), readOnly: PropTypes.bool, - /** - * If `true`, on dismiss will reset the value to the value when the picker was opened. - * - * Might make most sense when in need of resetting the value on modal dismiss. - * @default `true` for mobile, `false` for desktop. - */ - resetValueOnDismiss: PropTypes.bool, /** * The currently selected sections. * This prop accept four formats: diff --git a/packages/x-date-pickers/src/internals/hooks/usePicker/usePickerValue.ts b/packages/x-date-pickers/src/internals/hooks/usePicker/usePickerValue.ts index b414803ff19a..a83fe6a37d65 100644 --- a/packages/x-date-pickers/src/internals/hooks/usePicker/usePickerValue.ts +++ b/packages/x-date-pickers/src/internals/hooks/usePicker/usePickerValue.ts @@ -207,12 +207,12 @@ export interface UsePickerValueNonStaticProps */ onOpen?: () => void; /** - * If `true`, on dismiss will reset the value to the value when the picker was opened. + * If `false`, on dismiss will reset the value to the value when the picker was opened. * * Might make most sense when in need of resetting the value on modal dismiss. - * @default `true` for mobile, `false` for desktop. + * @default `true` for desktop, `false` for mobile. */ - resetValueOnDismiss?: boolean; + acceptValueOnDismiss?: boolean; } /** @@ -309,7 +309,7 @@ export const usePickerValue = < closeOnSelect = wrapperVariant === 'desktop', selectedSections: selectedSectionsProp, onSelectedSectionsChange, - resetValueOnDismiss = wrapperVariant !== 'desktop', + acceptValueOnDismiss = wrapperVariant === 'desktop', } = props; const utils = useUtils(); @@ -500,7 +500,7 @@ export const usePickerValue = < const actions: UsePickerValueActions = { onClear: handleClear, onAccept: handleAccept, - onDismiss: resetValueOnDismiss ? handleCancel : handleDismiss, + onDismiss: acceptValueOnDismiss ? handleDismiss : handleCancel, onCancel: handleCancel, onSetToday: handleSetToday, onOpen: handleOpen,