@mui/x-date-pickers 8.0.0-alpha.2 → 8.0.0-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +376 -0
- package/DateField/useDateField.d.ts +1 -1
- package/DatePicker/DatePickerToolbar.js +8 -9
- package/DateTimeField/useDateTimeField.d.ts +1 -1
- package/DateTimePicker/DateTimePickerToolbar.d.ts +6 -2
- package/DateTimePicker/DateTimePickerToolbar.js +53 -39
- package/DesktopDateTimePicker/DesktopDateTimePicker.js +1 -2
- package/DigitalClock/DigitalClock.js +13 -11
- package/DigitalClock/DigitalClock.types.d.ts +8 -2
- package/MultiSectionDigitalClock/MultiSectionDigitalClock.js +8 -7
- package/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +12 -10
- package/PickersActionBar/PickersActionBar.js +8 -1
- package/PickersLayout/PickersLayout.js +2 -2
- package/PickersLayout/PickersLayout.types.d.ts +4 -2
- package/PickersLayout/usePickerLayout.js +3 -3
- package/PickersShortcuts/PickersShortcuts.js +8 -1
- package/README.md +1 -1
- package/TimeClock/Clock.js +18 -21
- package/TimeClock/ClockNumber.js +15 -11
- package/TimeClock/ClockPointer.d.ts +6 -1
- package/TimeClock/ClockPointer.js +14 -10
- package/TimeClock/TimeClock.js +9 -8
- package/TimeField/useTimeField.d.ts +1 -1
- package/TimePicker/TimePickerToolbar.js +14 -17
- package/hooks/useClearableField.d.ts +5 -3
- package/hooks/useClearableField.js +4 -2
- package/index.js +1 -1
- package/internals/components/PickerProvider.d.ts +2 -15
- package/internals/components/PickersPopper.d.ts +11 -7
- package/internals/components/PickersPopper.js +18 -20
- package/internals/components/PickersToolbar.js +15 -12
- package/internals/components/PickersToolbarButton.js +4 -6
- package/internals/components/PickersToolbarText.js +11 -13
- package/internals/hooks/useDesktopPicker/useDesktopPicker.types.d.ts +3 -2
- package/internals/hooks/useMobilePicker/useMobilePicker.types.d.ts +3 -2
- package/internals/hooks/useOpenState.d.ts +3 -2
- package/internals/hooks/useOpenState.js +10 -9
- package/internals/hooks/usePicker/usePicker.js +3 -3
- package/internals/hooks/usePicker/usePicker.types.d.ts +3 -2
- package/internals/hooks/usePicker/usePickerProvider.d.ts +17 -6
- package/internals/hooks/usePicker/usePickerProvider.js +14 -12
- package/internals/hooks/usePicker/usePickerValue.js +22 -11
- package/internals/hooks/usePicker/usePickerValue.types.d.ts +26 -0
- package/internals/hooks/usePicker/usePickerViews.d.ts +5 -15
- package/internals/hooks/usePicker/usePickerViews.js +5 -6
- package/internals/hooks/useToolbarOwnerState.d.ts +10 -0
- package/internals/hooks/useToolbarOwnerState.js +13 -0
- package/internals/index.d.ts +5 -1
- package/internals/index.js +3 -1
- package/internals/models/common.d.ts +1 -1
- package/locales/roRO.js +15 -18
- package/modern/DatePicker/DatePickerToolbar.js +8 -9
- package/modern/DateTimePicker/DateTimePickerToolbar.js +53 -39
- package/modern/DesktopDateTimePicker/DesktopDateTimePicker.js +1 -2
- package/modern/DigitalClock/DigitalClock.js +13 -11
- package/modern/MultiSectionDigitalClock/MultiSectionDigitalClock.js +8 -7
- package/modern/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +12 -10
- package/modern/PickersActionBar/PickersActionBar.js +8 -1
- package/modern/PickersLayout/PickersLayout.js +2 -2
- package/modern/PickersLayout/usePickerLayout.js +3 -3
- package/modern/PickersShortcuts/PickersShortcuts.js +8 -1
- package/modern/TimeClock/Clock.js +18 -21
- package/modern/TimeClock/ClockNumber.js +15 -11
- package/modern/TimeClock/ClockPointer.js +14 -10
- package/modern/TimeClock/TimeClock.js +9 -8
- package/modern/TimePicker/TimePickerToolbar.js +14 -17
- package/modern/hooks/useClearableField.js +4 -2
- package/modern/index.js +1 -1
- package/modern/internals/components/PickersPopper.js +18 -20
- package/modern/internals/components/PickersToolbar.js +15 -12
- package/modern/internals/components/PickersToolbarButton.js +4 -6
- package/modern/internals/components/PickersToolbarText.js +11 -13
- package/modern/internals/hooks/useOpenState.js +10 -9
- package/modern/internals/hooks/usePicker/usePicker.js +3 -3
- package/modern/internals/hooks/usePicker/usePickerProvider.js +14 -12
- package/modern/internals/hooks/usePicker/usePickerValue.js +22 -11
- package/modern/internals/hooks/usePicker/usePickerViews.js +5 -6
- package/modern/internals/hooks/useToolbarOwnerState.js +13 -0
- package/modern/internals/index.js +3 -1
- package/modern/locales/roRO.js +15 -18
- package/node/DatePicker/DatePickerToolbar.js +8 -9
- package/node/DateTimePicker/DateTimePickerToolbar.js +54 -39
- package/node/DesktopDateTimePicker/DesktopDateTimePicker.js +1 -2
- package/node/DigitalClock/DigitalClock.js +13 -11
- package/node/MultiSectionDigitalClock/MultiSectionDigitalClock.js +8 -7
- package/node/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +12 -10
- package/node/PickersActionBar/PickersActionBar.js +8 -1
- package/node/PickersLayout/PickersLayout.js +2 -2
- package/node/PickersLayout/usePickerLayout.js +3 -3
- package/node/PickersShortcuts/PickersShortcuts.js +8 -1
- package/node/TimeClock/Clock.js +18 -21
- package/node/TimeClock/ClockNumber.js +15 -11
- package/node/TimeClock/ClockPointer.js +14 -10
- package/node/TimeClock/TimeClock.js +9 -8
- package/node/TimePicker/TimePickerToolbar.js +14 -17
- package/node/hooks/useClearableField.js +4 -2
- package/node/index.js +1 -1
- package/node/internals/components/PickersPopper.js +18 -20
- package/node/internals/components/PickersToolbar.js +15 -12
- package/node/internals/components/PickersToolbarButton.js +4 -6
- package/node/internals/components/PickersToolbarText.js +10 -12
- package/node/internals/hooks/useOpenState.js +10 -9
- package/node/internals/hooks/usePicker/usePicker.js +3 -3
- package/node/internals/hooks/usePicker/usePickerProvider.js +15 -13
- package/node/internals/hooks/usePicker/usePickerValue.js +22 -11
- package/node/internals/hooks/usePicker/usePickerViews.js +5 -6
- package/node/internals/hooks/useToolbarOwnerState.js +21 -0
- package/node/internals/index.js +15 -1
- package/node/locales/roRO.js +15 -18
- package/package.json +1 -1
|
@@ -158,8 +158,8 @@ const usePickerValue = ({
|
|
|
158
158
|
const utils = (0, _useUtils.useUtils)();
|
|
159
159
|
const adapter = (0, _useUtils.useLocalizationContext)();
|
|
160
160
|
const {
|
|
161
|
-
|
|
162
|
-
|
|
161
|
+
open,
|
|
162
|
+
setOpen
|
|
163
163
|
} = (0, _useOpenState.useOpenState)(props);
|
|
164
164
|
const {
|
|
165
165
|
timezone,
|
|
@@ -245,7 +245,7 @@ const usePickerValue = ({
|
|
|
245
245
|
onAccept(action.value, getContext());
|
|
246
246
|
}
|
|
247
247
|
if (shouldClose) {
|
|
248
|
-
|
|
248
|
+
setOpen(false);
|
|
249
249
|
}
|
|
250
250
|
});
|
|
251
251
|
if (dateState.lastControlledValue !== inValueWithoutRenderTimezone) {
|
|
@@ -296,11 +296,11 @@ const usePickerValue = ({
|
|
|
296
296
|
});
|
|
297
297
|
const handleOpen = (0, _useEventCallback.default)(event => {
|
|
298
298
|
event.preventDefault();
|
|
299
|
-
|
|
299
|
+
setOpen(true);
|
|
300
300
|
});
|
|
301
301
|
const handleClose = (0, _useEventCallback.default)(event => {
|
|
302
302
|
event?.preventDefault();
|
|
303
|
-
|
|
303
|
+
setOpen(false);
|
|
304
304
|
});
|
|
305
305
|
const handleChange = (0, _useEventCallback.default)((newValue, selectionState = 'partial') => updateDate({
|
|
306
306
|
name: 'setValueFromView',
|
|
@@ -331,12 +331,12 @@ const usePickerValue = ({
|
|
|
331
331
|
value: dateState.draft,
|
|
332
332
|
onChange: handleChangeFromField
|
|
333
333
|
};
|
|
334
|
-
const
|
|
334
|
+
const valueWithoutError = React.useMemo(() => valueManager.cleanValue(utils, dateState.draft), [utils, valueManager, dateState.draft]);
|
|
335
335
|
const viewResponse = {
|
|
336
|
-
value:
|
|
336
|
+
value: valueWithoutError,
|
|
337
337
|
onChange: handleChange,
|
|
338
338
|
onClose: handleClose,
|
|
339
|
-
open
|
|
339
|
+
open
|
|
340
340
|
};
|
|
341
341
|
const isValid = testedValue => {
|
|
342
342
|
const error = validator({
|
|
@@ -348,17 +348,28 @@ const usePickerValue = ({
|
|
|
348
348
|
return !valueManager.hasError(error);
|
|
349
349
|
};
|
|
350
350
|
const layoutResponse = (0, _extends2.default)({}, actions, {
|
|
351
|
-
value:
|
|
351
|
+
value: valueWithoutError,
|
|
352
352
|
onChange: handleChange,
|
|
353
353
|
onSelectShortcut: handleSelectShortcut,
|
|
354
354
|
isValid
|
|
355
355
|
});
|
|
356
|
+
const contextValue = React.useMemo(() => {
|
|
357
|
+
return {
|
|
358
|
+
open,
|
|
359
|
+
setOpen
|
|
360
|
+
};
|
|
361
|
+
}, [open, setOpen]);
|
|
362
|
+
const providerParams = {
|
|
363
|
+
value: valueWithoutError,
|
|
364
|
+
contextValue
|
|
365
|
+
};
|
|
356
366
|
return {
|
|
357
|
-
open
|
|
367
|
+
open,
|
|
358
368
|
fieldProps: fieldResponse,
|
|
359
369
|
viewProps: viewResponse,
|
|
360
370
|
layoutProps: layoutResponse,
|
|
361
|
-
actions
|
|
371
|
+
actions,
|
|
372
|
+
provider: providerParams
|
|
362
373
|
};
|
|
363
374
|
};
|
|
364
375
|
exports.usePickerValue = usePickerValue;
|
|
@@ -18,10 +18,6 @@ const _excluded = ["className", "sx"];
|
|
|
18
18
|
* Props used to handle the views that are common to all pickers.
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
|
-
/**
|
|
22
|
-
* Props used to handle the views of the pickers.
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
21
|
/**
|
|
26
22
|
* Props used to handle the value of the pickers.
|
|
27
23
|
*/
|
|
@@ -139,11 +135,14 @@ const usePickerViews = ({
|
|
|
139
135
|
view: popperView,
|
|
140
136
|
onViewChange: setView
|
|
141
137
|
};
|
|
142
|
-
|
|
138
|
+
const providerParams = {
|
|
143
139
|
hasUIView,
|
|
144
|
-
views
|
|
140
|
+
views
|
|
141
|
+
};
|
|
142
|
+
return {
|
|
145
143
|
shouldRestoreFocus,
|
|
146
144
|
layoutProps,
|
|
145
|
+
provider: providerParams,
|
|
147
146
|
renderCurrentView: () => {
|
|
148
147
|
if (popperView == null) {
|
|
149
148
|
return null;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
4
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.useToolbarOwnerState = useToolbarOwnerState;
|
|
9
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
10
|
+
var React = _interopRequireWildcard(require("react"));
|
|
11
|
+
var _RtlProvider = require("@mui/system/RtlProvider");
|
|
12
|
+
var _usePickerPrivateContext = require("./usePickerPrivateContext");
|
|
13
|
+
function useToolbarOwnerState() {
|
|
14
|
+
const {
|
|
15
|
+
ownerState: pickerOwnerState
|
|
16
|
+
} = (0, _usePickerPrivateContext.usePickerPrivateContext)();
|
|
17
|
+
const isRtl = (0, _RtlProvider.useRtl)();
|
|
18
|
+
return React.useMemo(() => (0, _extends2.default)({}, pickerOwnerState, {
|
|
19
|
+
toolbarDirection: isRtl ? 'rtl' : 'ltr'
|
|
20
|
+
}), [pickerOwnerState, isRtl]);
|
|
21
|
+
}
|
package/node/internals/index.js
CHANGED
|
@@ -21,6 +21,12 @@ Object.defineProperty(exports, "DIALOG_WIDTH", {
|
|
|
21
21
|
return _dimensions.DIALOG_WIDTH;
|
|
22
22
|
}
|
|
23
23
|
});
|
|
24
|
+
Object.defineProperty(exports, "DateTimePickerToolbarForceDesktopVariant", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function () {
|
|
27
|
+
return _DateTimePickerToolbar.DateTimePickerToolbarForceDesktopVariant;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
24
30
|
Object.defineProperty(exports, "DayCalendar", {
|
|
25
31
|
enumerable: true,
|
|
26
32
|
get: function () {
|
|
@@ -309,6 +315,12 @@ Object.defineProperty(exports, "useStaticPicker", {
|
|
|
309
315
|
return _useStaticPicker.useStaticPicker;
|
|
310
316
|
}
|
|
311
317
|
});
|
|
318
|
+
Object.defineProperty(exports, "useToolbarOwnerState", {
|
|
319
|
+
enumerable: true,
|
|
320
|
+
get: function () {
|
|
321
|
+
return _useToolbarOwnerState.useToolbarOwnerState;
|
|
322
|
+
}
|
|
323
|
+
});
|
|
312
324
|
Object.defineProperty(exports, "useUtils", {
|
|
313
325
|
enumerable: true,
|
|
314
326
|
get: function () {
|
|
@@ -339,6 +351,7 @@ var _useFieldOwnerState = require("./hooks/useFieldOwnerState");
|
|
|
339
351
|
var _usePicker = require("./hooks/usePicker");
|
|
340
352
|
var _usePickerPrivateContext = require("./hooks/usePickerPrivateContext");
|
|
341
353
|
var _useStaticPicker = require("./hooks/useStaticPicker");
|
|
354
|
+
var _useToolbarOwnerState = require("./hooks/useToolbarOwnerState");
|
|
342
355
|
var _useUtils = require("./hooks/useUtils");
|
|
343
356
|
var _useViews = require("./hooks/useViews");
|
|
344
357
|
var _dateHelpersHooks = require("./hooks/date-helpers-hooks");
|
|
@@ -352,4 +365,5 @@ var _useDefaultReduceAnimations = require("./hooks/useDefaultReduceAnimations");
|
|
|
352
365
|
var _views = require("./utils/views");
|
|
353
366
|
var _DayCalendar = require("../DateCalendar/DayCalendar");
|
|
354
367
|
var _useCalendarState = require("../DateCalendar/useCalendarState");
|
|
355
|
-
var _timeUtils = require("./utils/time-utils");
|
|
368
|
+
var _timeUtils = require("./utils/time-utils");
|
|
369
|
+
var _DateTimePickerToolbar = require("../DateTimePicker/DateTimePickerToolbar");
|
package/node/locales/roRO.js
CHANGED
|
@@ -23,11 +23,10 @@ const roROPickers = {
|
|
|
23
23
|
// DateRange labels
|
|
24
24
|
start: 'Început',
|
|
25
25
|
end: 'Sfârșit',
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
26
|
+
startDate: 'Data de început',
|
|
27
|
+
startTime: 'Ora de început',
|
|
28
|
+
endDate: 'Data de sfârșit',
|
|
29
|
+
endTime: 'Ora de sfârșit',
|
|
31
30
|
// Action bar
|
|
32
31
|
cancelButtonLabel: 'Anulare',
|
|
33
32
|
clearButtonLabel: 'Ștergere',
|
|
@@ -61,23 +60,21 @@ const roROPickers = {
|
|
|
61
60
|
fieldYearPlaceholder: params => 'A'.repeat(params.digitAmount),
|
|
62
61
|
fieldMonthPlaceholder: params => params.contentType === 'letter' ? 'LLLL' : 'LL',
|
|
63
62
|
fieldDayPlaceholder: () => 'ZZ',
|
|
64
|
-
|
|
63
|
+
fieldWeekDayPlaceholder: params => params.contentType === 'letter' ? 'ZZZZ' : 'ZZ',
|
|
65
64
|
fieldHoursPlaceholder: () => 'hh',
|
|
66
65
|
fieldMinutesPlaceholder: () => 'mm',
|
|
67
66
|
fieldSecondsPlaceholder: () => 'ss',
|
|
68
|
-
fieldMeridiemPlaceholder: () => 'aa'
|
|
69
|
-
|
|
67
|
+
fieldMeridiemPlaceholder: () => 'aa',
|
|
70
68
|
// View names
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
69
|
+
year: 'An',
|
|
70
|
+
month: 'Luna',
|
|
71
|
+
day: 'Ziua',
|
|
72
|
+
weekDay: 'Ziua saptămânii',
|
|
73
|
+
hours: 'Ore',
|
|
74
|
+
minutes: 'Minute',
|
|
75
|
+
seconds: 'Secunde',
|
|
76
|
+
meridiem: 'Meridiem',
|
|
80
77
|
// Common
|
|
81
|
-
|
|
78
|
+
empty: 'Gol'
|
|
82
79
|
};
|
|
83
80
|
const roRO = exports.roRO = (0, _getPickersLocalization.getPickersLocalization)(roROPickers);
|