@onesy/ui-react 1.0.196 → 1.0.198
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/Button/Button.js +3 -2
- package/CardButton/CardButton.js +3 -2
- package/Checkbox/Checkbox.js +3 -2
- package/DatePicker/DatePicker.js +40 -40
- package/DateTimePicker/DateTimePicker.js +28 -28
- package/NavigationItem/NavigationItem.js +3 -2
- package/Radio/Radio.js +3 -2
- package/Tab/Tab.js +3 -2
- package/TimePicker/TimePicker.js +44 -44
- package/esm/Button/Button.js +3 -2
- package/esm/CardButton/CardButton.js +3 -2
- package/esm/Checkbox/Checkbox.js +3 -2
- package/esm/DatePicker/DatePicker.js +40 -40
- package/esm/DateTimePicker/DateTimePicker.js +28 -28
- package/esm/NavigationItem/NavigationItem.js +3 -2
- package/esm/Radio/Radio.js +3 -2
- package/esm/Tab/Tab.js +3 -2
- package/esm/TimePicker/TimePicker.js +44 -44
- package/esm/index.js +1 -1
- package/index.js +1 -1
- package/package.json +1 -1
package/TimePicker/TimePicker.js
CHANGED
|
@@ -238,11 +238,11 @@ const TimePicker = props__ => {
|
|
|
238
238
|
ref,
|
|
239
239
|
tonal,
|
|
240
240
|
color = 'primary',
|
|
241
|
-
version:
|
|
242
|
-
value:
|
|
241
|
+
version: versionProps = 'auto',
|
|
242
|
+
value: valueProps,
|
|
243
243
|
valueDefault,
|
|
244
244
|
onChange,
|
|
245
|
-
selecting:
|
|
245
|
+
selecting: selectingProps,
|
|
246
246
|
selectingDefault,
|
|
247
247
|
onChangeSelecting,
|
|
248
248
|
size = 'regular',
|
|
@@ -252,37 +252,37 @@ const TimePicker = props__ => {
|
|
|
252
252
|
min,
|
|
253
253
|
max,
|
|
254
254
|
validate,
|
|
255
|
-
autoNext:
|
|
256
|
-
autoCloseOnLast:
|
|
255
|
+
autoNext: autoNextProps,
|
|
256
|
+
autoCloseOnLast: autoCloseOnLastProps,
|
|
257
257
|
openMobile = 'select',
|
|
258
258
|
openDesktop = 'select',
|
|
259
259
|
selectModalSubHeadingText = l('Select time'),
|
|
260
260
|
selectModalSubHeadingTextRange = `${l('Select from')}${_DatePicker.SEPARATOR}${l('to time')}`,
|
|
261
261
|
inputModalSubHeadingText = l('Enter time'),
|
|
262
262
|
inputModalSubHeadingTextRange = `${l('Enter from')}${_DatePicker.SEPARATOR}${l('to time')}`,
|
|
263
|
-
orientation:
|
|
263
|
+
orientation: orientationProps,
|
|
264
264
|
format = '12',
|
|
265
265
|
hour = true,
|
|
266
266
|
minute = true,
|
|
267
267
|
second = false,
|
|
268
|
-
switch:
|
|
269
|
-
static:
|
|
268
|
+
switch: switchProps,
|
|
269
|
+
static: staticProps,
|
|
270
270
|
today,
|
|
271
271
|
clear = true,
|
|
272
|
-
placeholder:
|
|
273
|
-
heading:
|
|
274
|
-
actions:
|
|
272
|
+
placeholder: placeholderProps,
|
|
273
|
+
heading: headingProps = true,
|
|
274
|
+
actions: actionsProps = true,
|
|
275
275
|
fullWidth,
|
|
276
276
|
readOnly,
|
|
277
277
|
disabled,
|
|
278
|
-
valid:
|
|
279
|
-
onClick:
|
|
280
|
-
onClose:
|
|
281
|
-
onCancel:
|
|
282
|
-
onNow:
|
|
283
|
-
onToday:
|
|
284
|
-
onClear:
|
|
285
|
-
onOk:
|
|
278
|
+
valid: validProps,
|
|
279
|
+
onClick: onClickProps,
|
|
280
|
+
onClose: onCloseProps,
|
|
281
|
+
onCancel: onCancelProps,
|
|
282
|
+
onNow: onNowProps,
|
|
283
|
+
onToday: onTodayProps,
|
|
284
|
+
onClear: onClearProps,
|
|
285
|
+
onOk: onOkProps,
|
|
286
286
|
renderValue,
|
|
287
287
|
Icon: Icon_ = _IconMaterialScheduleW.default,
|
|
288
288
|
IconEnter = _IconMaterialKeyboardAltW.default,
|
|
@@ -316,22 +316,22 @@ const TimePicker = props__ => {
|
|
|
316
316
|
};
|
|
317
317
|
const keys = _react.default.useMemo(() => {
|
|
318
318
|
const result = [];
|
|
319
|
-
const items = [
|
|
319
|
+
const items = [switchProps, orientationProps, autoNextProps, autoCloseOnLastProps];
|
|
320
320
|
items.forEach(item => {
|
|
321
321
|
if ((0, _utils.is)('object', item)) Object.keys(item).filter(key => theme.breakpoints.media[key]).forEach(key_0 => result.push(key_0));
|
|
322
322
|
});
|
|
323
323
|
return (0, _utils.unique)(result);
|
|
324
|
-
}, [
|
|
324
|
+
}, [switchProps, orientationProps, autoNextProps, autoCloseOnLastProps]);
|
|
325
325
|
const breakpoints = {};
|
|
326
326
|
keys.forEach(key_1 => {
|
|
327
327
|
breakpoints[key_1] = (0, _useMediaQuery.default)(theme.breakpoints.media[key_1], {
|
|
328
328
|
element: refs.root.current
|
|
329
329
|
});
|
|
330
330
|
});
|
|
331
|
-
const switch_ = (0, _utils2.valueBreakpoints)(
|
|
332
|
-
const orientation = (0, _utils2.valueBreakpoints)(
|
|
333
|
-
const autoNext = (0, _utils2.valueBreakpoints)(
|
|
334
|
-
const autoCloseOnLast = (0, _utils2.valueBreakpoints)(
|
|
331
|
+
const switch_ = (0, _utils2.valueBreakpoints)(switchProps, true, breakpoints, theme);
|
|
332
|
+
const orientation = (0, _utils2.valueBreakpoints)(orientationProps, 'vertical', breakpoints, theme);
|
|
333
|
+
const autoNext = (0, _utils2.valueBreakpoints)(autoNextProps, undefined, breakpoints, theme);
|
|
334
|
+
const autoCloseOnLast = (0, _utils2.valueBreakpoints)(autoCloseOnLastProps, undefined, breakpoints, theme);
|
|
335
335
|
const touch = (0, _useMediaQuery.default)('(pointer: coarse)', {
|
|
336
336
|
element: refs.root.current
|
|
337
337
|
});
|
|
@@ -341,11 +341,11 @@ const TimePicker = props__ => {
|
|
|
341
341
|
return sorted;
|
|
342
342
|
};
|
|
343
343
|
const [value, setValue] = _react.default.useState(() => {
|
|
344
|
-
const valueResult = (valueDefault !== undefined ? valueDefault :
|
|
344
|
+
const valueResult = (valueDefault !== undefined ? valueDefault : valueProps) || now && (range ? [new _date.OnesyDate(), new _date.OnesyDate()] : [new _date.OnesyDate()]);
|
|
345
345
|
return onResolveValue(valueResult);
|
|
346
346
|
});
|
|
347
347
|
const [selecting, setSelecting] = _react.default.useState(() => {
|
|
348
|
-
const valueResult_0 = (selectingDefault !== undefined ? selectingDefault :
|
|
348
|
+
const valueResult_0 = (selectingDefault !== undefined ? selectingDefault : selectingProps) || ['hour', 'hour'];
|
|
349
349
|
return ((0, _utils.is)('array', valueResult_0) ? valueResult_0 : [valueResult_0]).filter(Boolean);
|
|
350
350
|
});
|
|
351
351
|
const [open, setOpen] = _react.default.useState(false);
|
|
@@ -375,7 +375,7 @@ const TimePicker = props__ => {
|
|
|
375
375
|
return result_0;
|
|
376
376
|
};
|
|
377
377
|
const [input, setInput] = _react.default.useState(valueToInput());
|
|
378
|
-
let version =
|
|
378
|
+
let version = versionProps;
|
|
379
379
|
if (version === 'auto') {
|
|
380
380
|
if (touch) version = 'mobile';else version = 'desktop';
|
|
381
381
|
}
|
|
@@ -404,8 +404,8 @@ const TimePicker = props__ => {
|
|
|
404
404
|
|
|
405
405
|
// Value
|
|
406
406
|
_react.default.useEffect(() => {
|
|
407
|
-
if (
|
|
408
|
-
}, [
|
|
407
|
+
if (valueProps !== undefined && valueProps !== value) onUpdateValue(valueProps);
|
|
408
|
+
}, [valueProps]);
|
|
409
409
|
const onUpdate = (valueNew__0, triggerOnChange = true) => {
|
|
410
410
|
const valueNew_3 = resolve(valueNew__0);
|
|
411
411
|
|
|
@@ -422,7 +422,7 @@ const TimePicker = props__ => {
|
|
|
422
422
|
if ((0, _utils.is)('function', onChangeSelecting)) onChangeSelecting(valueNew_4);
|
|
423
423
|
};
|
|
424
424
|
const valid = (...args) => {
|
|
425
|
-
if ((0, _utils.is)('function',
|
|
425
|
+
if ((0, _utils.is)('function', validProps)) return validProps(...args);
|
|
426
426
|
const onesyDate = args[0];
|
|
427
427
|
if (min || max || validate) {
|
|
428
428
|
let response = true;
|
|
@@ -463,7 +463,7 @@ const TimePicker = props__ => {
|
|
|
463
463
|
if ((0, _utils.is)('string', valueTime_0) && valueTime_0.startsWith('0')) valueTime_0 = valueTime_0.slice(1);
|
|
464
464
|
valueTime_0 = +valueTime_0;
|
|
465
465
|
value[index_1] = (0, _date.set)(valueTime_0, unit || selecting[index_1], value[index_1]);
|
|
466
|
-
(!
|
|
466
|
+
(!actionsProps ? onUpdate : setValue)(resolve(value));
|
|
467
467
|
};
|
|
468
468
|
const resolve = (valueNew_7 = refs.value.current, dayTimeNew = refs.dayTime.current) => {
|
|
469
469
|
const values_0 = onResolveValue(valueNew_7).map((item_4, index_2) => {
|
|
@@ -485,7 +485,7 @@ const TimePicker = props__ => {
|
|
|
485
485
|
dayTimeNew_0[index_3] = valueNew_8;
|
|
486
486
|
refs.dayTime.current = dayTimeNew_0;
|
|
487
487
|
setDayTime(dayTimeNew_0);
|
|
488
|
-
(!
|
|
488
|
+
(!actionsProps ? onUpdate : setValue)(resolve(refs.value.current));
|
|
489
489
|
};
|
|
490
490
|
const inputToValue = (valueNew__3 = input) => {
|
|
491
491
|
let valueNew_9 = valueNew__3;
|
|
@@ -519,7 +519,7 @@ const TimePicker = props__ => {
|
|
|
519
519
|
const valueNew_11 = [...value];
|
|
520
520
|
if (valueNew__5 !== value[index_4]) {
|
|
521
521
|
valueNew_11[index_4] = valueNew__5;
|
|
522
|
-
(!
|
|
522
|
+
(!actionsProps ? onUpdate : setValue)(resolve(valueNew_11));
|
|
523
523
|
|
|
524
524
|
// Error
|
|
525
525
|
errorCheck(valueNew_11);
|
|
@@ -550,7 +550,7 @@ const TimePicker = props__ => {
|
|
|
550
550
|
};
|
|
551
551
|
const onClose = event => {
|
|
552
552
|
setOpen(false);
|
|
553
|
-
if ((0, _utils.is)('function',
|
|
553
|
+
if ((0, _utils.is)('function', onCloseProps)) onCloseProps(event);
|
|
554
554
|
};
|
|
555
555
|
const onReset = () => {
|
|
556
556
|
const valueNew_14 = inputToValue();
|
|
@@ -574,7 +574,7 @@ const TimePicker = props__ => {
|
|
|
574
574
|
// Update dayTime
|
|
575
575
|
setDayTime(valueNew_15.map(item_8 => (0, _date.format)(item_8, 'a')));
|
|
576
576
|
onClose(event_0);
|
|
577
|
-
if ((0, _utils.is)('function',
|
|
577
|
+
if ((0, _utils.is)('function', onTodayProps)) onTodayProps(event_0);
|
|
578
578
|
};
|
|
579
579
|
const onClear = event_1 => {
|
|
580
580
|
const valueNew_16 = [];
|
|
@@ -588,7 +588,7 @@ const TimePicker = props__ => {
|
|
|
588
588
|
// Update dayTime
|
|
589
589
|
setDayTime(valueNew_16.map(item_9 => (0, _date.format)(item_9, 'a')));
|
|
590
590
|
onClose(event_1);
|
|
591
|
-
if ((0, _utils.is)('function',
|
|
591
|
+
if ((0, _utils.is)('function', onClearProps)) onClearProps(event_1);
|
|
592
592
|
};
|
|
593
593
|
const onOk = event_2 => {
|
|
594
594
|
// Error
|
|
@@ -603,12 +603,12 @@ const TimePicker = props__ => {
|
|
|
603
603
|
// Update dayTime
|
|
604
604
|
setDayTime(refs.value.current.map(item_10 => (0, _date.format)(item_10, 'a')));
|
|
605
605
|
onClose(event_2);
|
|
606
|
-
if ((0, _utils.is)('function',
|
|
606
|
+
if ((0, _utils.is)('function', onOkProps)) onOkProps(event_2);
|
|
607
607
|
};
|
|
608
608
|
const onCancel = event_3 => {
|
|
609
609
|
onReset();
|
|
610
610
|
onClose(event_3);
|
|
611
|
-
if ((0, _utils.is)('function',
|
|
611
|
+
if ((0, _utils.is)('function', onCancelProps)) onCancelProps(event_3);
|
|
612
612
|
};
|
|
613
613
|
const mask = [];
|
|
614
614
|
let placeholder = '';
|
|
@@ -661,7 +661,7 @@ const TimePicker = props__ => {
|
|
|
661
661
|
mask.push(' ', _DatePicker.SEPARATOR_SYMBOL, ' ', ...mask);
|
|
662
662
|
placeholder += `${_DatePicker.SEPARATOR}${placeholder}`;
|
|
663
663
|
}
|
|
664
|
-
placeholder =
|
|
664
|
+
placeholder = placeholderProps || placeholder;
|
|
665
665
|
const buttonProps = _objectSpread({
|
|
666
666
|
color: 'inherit',
|
|
667
667
|
version: 'text',
|
|
@@ -915,7 +915,7 @@ const TimePicker = props__ => {
|
|
|
915
915
|
Component: Line
|
|
916
916
|
}, MainProps), {}, {
|
|
917
917
|
className: (0, _styleReact.classNames)([(0, _utils2.staticClassName)('TimePicker', theme) && ['onesy-TimePicker-main'], MainProps === null || MainProps === void 0 ? void 0 : MainProps.className, classes.main, classes[`main_size_${size}`]]),
|
|
918
|
-
children: [
|
|
918
|
+
children: [headingProps && /*#__PURE__*/(0, _jsxRuntime.jsx)(Type, {
|
|
919
919
|
version: size === 'large' ? 'l1' : size === 'regular' ? 'l2' : 'l3',
|
|
920
920
|
className: (0, _styleReact.classNames)([(0, _utils2.staticClassName)('TimePicker', theme) && ['onesy-TimePicker-heading'], classes.heading, classes[`heading_size_${size}`]]),
|
|
921
921
|
children: heading
|
|
@@ -926,7 +926,7 @@ const TimePicker = props__ => {
|
|
|
926
926
|
valueDefault: tab,
|
|
927
927
|
onChange: setTab
|
|
928
928
|
}, TabsProps), {}, {
|
|
929
|
-
className: (0, _styleReact.classNames)([(0, _utils2.staticClassName)('TimePicker', theme) && ['onesy-TimePicker-tabs'], TabsProps === null || TabsProps === void 0 ? void 0 : TabsProps.className, classes.tabs,
|
|
929
|
+
className: (0, _styleReact.classNames)([(0, _utils2.staticClassName)('TimePicker', theme) && ['onesy-TimePicker-tabs'], TabsProps === null || TabsProps === void 0 ? void 0 : TabsProps.className, classes.tabs, headingProps && classes.tabs_padding]),
|
|
930
930
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(Tab, _objectSpread({
|
|
931
931
|
value: 0,
|
|
932
932
|
name: l('From')
|
|
@@ -938,12 +938,12 @@ const TimePicker = props__ => {
|
|
|
938
938
|
gap: 0,
|
|
939
939
|
className: (0, _styleReact.classNames)([(0, _utils2.staticClassName)('TimePicker', theme) && ['onesy-TimePicker-middle'], MiddleProps === null || MiddleProps === void 0 ? void 0 : MiddleProps.className, classes.middle, classes[`middle_size_${size}`]]),
|
|
940
940
|
children: elementValues[tab]
|
|
941
|
-
}),
|
|
941
|
+
}), actionsProps && actions]
|
|
942
942
|
}));
|
|
943
943
|
if (version === 'mobile') {
|
|
944
944
|
if (!(readOnly || disabled)) moreProps.onClick = onOpen;
|
|
945
945
|
}
|
|
946
|
-
if (
|
|
946
|
+
if (staticProps) return element;
|
|
947
947
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(Line, _objectSpread(_objectSpread({
|
|
948
948
|
gap: 0,
|
|
949
949
|
direction: "column",
|
package/esm/Button/Button.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
2
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
-
const _excluded = ["ref", "tonal", "color", "version", "name", "size", "fullWidth", "fontSize", "selected", "iconSelected", "start", "startSelected", "end", "endSelected", "elevation", "backgroundOpacity", "align", "loading", "loadingLabel", "loadingIcon", "loadingIconPosition", "fab", "chip", "icon", "focus", "value", "noIconRootFontSize", "firstLevelChildren", "noFontSize", "disabled", "onFocus", "onBlur", "IconWrapperComponent", "InteractionProps", "IconWrapperProps", "LabelProps", "IconProps", "Component", "className", "style", "children"];
|
|
3
|
+
const _excluded = ["ref", "tonal", "color", "version", "name", "size", "fullWidth", "fontSize", "selected", "iconSelected", "start", "startSelected", "end", "endSelected", "elevation", "backgroundOpacity", "align", "loading", "loadingLabel", "loadingIcon", "loadingIconPosition", "fab", "chip", "icon", "focus", "value", "noIconRootFontSize", "firstLevelChildren", "noFontSize", "readOnly", "disabled", "onFocus", "onBlur", "IconWrapperComponent", "InteractionProps", "IconWrapperProps", "LabelProps", "IconProps", "Component", "className", "style", "children"];
|
|
4
4
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
5
5
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
6
6
|
import React from 'react';
|
|
@@ -271,6 +271,7 @@ const Button = props_ => {
|
|
|
271
271
|
noIconRootFontSize,
|
|
272
272
|
firstLevelChildren,
|
|
273
273
|
noFontSize,
|
|
274
|
+
readOnly,
|
|
274
275
|
disabled: disabled_,
|
|
275
276
|
onFocus: onFocus_,
|
|
276
277
|
onBlur: onBlur_,
|
|
@@ -422,7 +423,7 @@ const Button = props_ => {
|
|
|
422
423
|
}
|
|
423
424
|
refs.root.current = item_2;
|
|
424
425
|
},
|
|
425
|
-
tabIndex: !disabled ? 0 : -1,
|
|
426
|
+
tabIndex: !(readOnly || disabled) ? 0 : -1,
|
|
426
427
|
type: "button",
|
|
427
428
|
role: "button",
|
|
428
429
|
color: color,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
2
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
-
const _excluded = ["focus", "selected", "href", "disabled", "onFocus", "onBlur", "InteractionProps", "Component", "className", "children"];
|
|
3
|
+
const _excluded = ["focus", "selected", "href", "readOnly", "disabled", "onFocus", "onBlur", "InteractionProps", "Component", "className", "children"];
|
|
4
4
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
5
5
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
6
6
|
import React from 'react';
|
|
@@ -25,6 +25,7 @@ const CardButton = props_ => {
|
|
|
25
25
|
focus: focus_,
|
|
26
26
|
selected,
|
|
27
27
|
href,
|
|
28
|
+
readOnly,
|
|
28
29
|
disabled,
|
|
29
30
|
onFocus: onFocus_,
|
|
30
31
|
onBlur: onBlur_,
|
|
@@ -52,7 +53,7 @@ const CardButton = props_ => {
|
|
|
52
53
|
};
|
|
53
54
|
const Component = Component_;
|
|
54
55
|
return /*#__PURE__*/_jsxs(Component, _objectSpread(_objectSpread({
|
|
55
|
-
tabIndex: !disabled ? 0 : -1,
|
|
56
|
+
tabIndex: !(readOnly || disabled) ? 0 : -1,
|
|
56
57
|
Component: Component,
|
|
57
58
|
onFocus: onFocus,
|
|
58
59
|
onBlur: onBlur,
|
package/esm/Checkbox/Checkbox.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
2
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
3
|
const _excluded = ["noFontSizeDownScale", "Component", "className", "style", "children"],
|
|
4
|
-
_excluded2 = ["tonal", "color", "version", "size", "colorIndeterminate", "colorUnchecked", "valueDefault", "checkedDefault", "value", "checked", "onChange", "indeterminate", "disabled", "inputRef", "Component", "className", "children"];
|
|
4
|
+
_excluded2 = ["tonal", "color", "version", "size", "colorIndeterminate", "colorUnchecked", "valueDefault", "checkedDefault", "value", "checked", "onChange", "indeterminate", "readOnly", "disabled", "inputRef", "Component", "className", "children"];
|
|
5
5
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
6
6
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
7
7
|
import { c as _c } from "react/compiler-runtime";
|
|
@@ -302,6 +302,7 @@ const Checkbox = props_ => {
|
|
|
302
302
|
checked: checked_,
|
|
303
303
|
onChange,
|
|
304
304
|
indeterminate: indeterminate_,
|
|
305
|
+
readOnly,
|
|
305
306
|
disabled,
|
|
306
307
|
inputRef,
|
|
307
308
|
Component = 'span',
|
|
@@ -389,7 +390,7 @@ const Checkbox = props_ => {
|
|
|
389
390
|
if (!value && tonal) colorValue = colorUnchecked;
|
|
390
391
|
if (indeterminate) colorValue = colorIndeterminate;
|
|
391
392
|
return /*#__PURE__*/_jsxs(IconButton, _objectSpread(_objectSpread({
|
|
392
|
-
tabIndex: !disabled ? 0 : -1,
|
|
393
|
+
tabIndex: !(readOnly || disabled) ? 0 : -1,
|
|
393
394
|
color: colorValue,
|
|
394
395
|
tonal: tonal,
|
|
395
396
|
version: version,
|
|
@@ -135,19 +135,19 @@ const DatePicker = props__ => {
|
|
|
135
135
|
ref,
|
|
136
136
|
tonal,
|
|
137
137
|
color = 'primary',
|
|
138
|
-
version:
|
|
138
|
+
version: versionProps = 'auto',
|
|
139
139
|
size = 'regular',
|
|
140
140
|
value: valueProps,
|
|
141
141
|
valueDefault,
|
|
142
142
|
onChange,
|
|
143
|
-
calendar:
|
|
143
|
+
calendar: calendarProps,
|
|
144
144
|
calendarDefault,
|
|
145
145
|
onChangeCalendar,
|
|
146
146
|
range,
|
|
147
147
|
now,
|
|
148
|
-
static:
|
|
148
|
+
static: staticProps,
|
|
149
149
|
openMobile = 'select',
|
|
150
|
-
placeholder:
|
|
150
|
+
placeholder: placeholderProps,
|
|
151
151
|
calendars = props.range ? 2 : 1,
|
|
152
152
|
min,
|
|
153
153
|
max,
|
|
@@ -155,31 +155,31 @@ const DatePicker = props__ => {
|
|
|
155
155
|
name,
|
|
156
156
|
nameFrom,
|
|
157
157
|
nameTo,
|
|
158
|
-
label:
|
|
159
|
-
labelFrom:
|
|
160
|
-
labelTo:
|
|
158
|
+
label: labelProps,
|
|
159
|
+
labelFrom: labelFromProps = l('Date from'),
|
|
160
|
+
labelTo: labelToProps = l('Date to'),
|
|
161
161
|
modeModalSubHeadingText = l('Select date'),
|
|
162
162
|
modeModalSubHeadingTextRange = `${l('Date from')}${SEPARATOR}${l('Date to')}`,
|
|
163
163
|
selectModeHeadingText = l('Select date'),
|
|
164
164
|
inputModeHeadingText = l('Enter date'),
|
|
165
|
-
useHelperText:
|
|
165
|
+
useHelperText: useHelperTextProps,
|
|
166
166
|
weekStartDay = 'Monday',
|
|
167
|
-
switch:
|
|
167
|
+
switch: switchProps,
|
|
168
168
|
fullScreen,
|
|
169
169
|
today,
|
|
170
170
|
clear = true,
|
|
171
|
-
heading:
|
|
172
|
-
actions:
|
|
171
|
+
heading: headingProps = true,
|
|
172
|
+
actions: actionsProps = true,
|
|
173
173
|
fullWidth,
|
|
174
174
|
readOnly,
|
|
175
175
|
disabled,
|
|
176
|
-
valid:
|
|
177
|
-
onClick:
|
|
178
|
-
onClose:
|
|
179
|
-
onToday:
|
|
180
|
-
onClear:
|
|
181
|
-
onCancel:
|
|
182
|
-
onOk:
|
|
176
|
+
valid: validProps,
|
|
177
|
+
onClick: onClickProps,
|
|
178
|
+
onClose: onCloseProps,
|
|
179
|
+
onToday: onTodayProps,
|
|
180
|
+
onClear: onClearProps,
|
|
181
|
+
onCancel: onCancelProps,
|
|
182
|
+
onOk: onOkProps,
|
|
183
183
|
Icon: Icon_ = IconMaterialCalendarToday,
|
|
184
184
|
IconEnter = IconMaterialEdit,
|
|
185
185
|
IconClose = IconMaterialClose,
|
|
@@ -205,21 +205,21 @@ const DatePicker = props__ => {
|
|
|
205
205
|
};
|
|
206
206
|
const keys = React.useMemo(() => {
|
|
207
207
|
const result = [];
|
|
208
|
-
const items = [
|
|
208
|
+
const items = [switchProps, useHelperTextProps];
|
|
209
209
|
items.forEach(item => {
|
|
210
210
|
if (is('object', item)) Object.keys(item).filter(key => theme.breakpoints.media[key]).forEach(key_0 => result.push(key_0));
|
|
211
211
|
});
|
|
212
212
|
return unique(result);
|
|
213
|
-
}, [
|
|
213
|
+
}, [switchProps, useHelperTextProps]);
|
|
214
214
|
const breakpoints = {};
|
|
215
215
|
keys.forEach(key_1 => {
|
|
216
216
|
breakpoints[key_1] = useMediaQuery(theme.breakpoints.media[key_1], {
|
|
217
217
|
element: refs.root.current
|
|
218
218
|
});
|
|
219
219
|
});
|
|
220
|
-
const label = name !== undefined ? name :
|
|
221
|
-
const switch_ = valueBreakpoints(
|
|
222
|
-
const useHelperText = valueBreakpoints(
|
|
220
|
+
const label = name !== undefined ? name : labelProps;
|
|
221
|
+
const switch_ = valueBreakpoints(switchProps, true, breakpoints, theme);
|
|
222
|
+
const useHelperText = valueBreakpoints(useHelperTextProps, undefined, breakpoints, theme);
|
|
223
223
|
const touch = useMediaQuery('(pointer: coarse)', {
|
|
224
224
|
element: refs.root.current
|
|
225
225
|
});
|
|
@@ -232,7 +232,7 @@ const DatePicker = props__ => {
|
|
|
232
232
|
const valueResult = (valueDefault !== undefined ? valueDefault : valueProps) || now && (range ? [new OnesyDate(), new OnesyDate()] : [new OnesyDate()]);
|
|
233
233
|
return onResolveValue(valueResult);
|
|
234
234
|
});
|
|
235
|
-
const [calendar, setCalendar] = React.useState((calendarDefault !== undefined ? calendarDefault :
|
|
235
|
+
const [calendar, setCalendar] = React.useState((calendarDefault !== undefined ? calendarDefault : calendarProps) || new OnesyDate());
|
|
236
236
|
const [open, setOpen] = React.useState(false);
|
|
237
237
|
const [mode, setMode] = React.useState((touch ? openMobile : 'select') || 'select');
|
|
238
238
|
const [error, setError] = React.useState(false);
|
|
@@ -253,7 +253,7 @@ const DatePicker = props__ => {
|
|
|
253
253
|
};
|
|
254
254
|
const [input, setInput] = React.useState(valueToInput());
|
|
255
255
|
const [inputModal, setInputModal] = React.useState(valueToInput());
|
|
256
|
-
let version =
|
|
256
|
+
let version = versionProps;
|
|
257
257
|
if (version === 'auto') {
|
|
258
258
|
if (touch) version = 'mobile';else version = 'desktop';
|
|
259
259
|
}
|
|
@@ -291,8 +291,8 @@ const DatePicker = props__ => {
|
|
|
291
291
|
|
|
292
292
|
// Calendar
|
|
293
293
|
React.useEffect(() => {
|
|
294
|
-
if (
|
|
295
|
-
}, [
|
|
294
|
+
if (calendarProps !== undefined && calendarProps !== calendar) setCalendar(calendarProps);
|
|
295
|
+
}, [calendarProps]);
|
|
296
296
|
const onUpdate = (valueNew_3, triggerOnChange = true) => {
|
|
297
297
|
// Inner update
|
|
298
298
|
if (!props.hasOwnProperty('value') || !triggerOnChange) setValue(valueNew_3);
|
|
@@ -311,7 +311,7 @@ const DatePicker = props__ => {
|
|
|
311
311
|
const onCalendarChange = valueNew__0 => {
|
|
312
312
|
const valueNew_5 = onResolveValue(valueNew__0);
|
|
313
313
|
if (valueNew_5 !== value) {
|
|
314
|
-
(!
|
|
314
|
+
(!actionsProps ? onUpdate : setValue)(valueNew_5);
|
|
315
315
|
|
|
316
316
|
// Update input modal
|
|
317
317
|
setInputModal(valueToInput(valueNew_5));
|
|
@@ -334,7 +334,7 @@ const DatePicker = props__ => {
|
|
|
334
334
|
};
|
|
335
335
|
const onClose = event => {
|
|
336
336
|
setOpen(false);
|
|
337
|
-
if (is('function',
|
|
337
|
+
if (is('function', onCloseProps)) onCloseProps(event);
|
|
338
338
|
};
|
|
339
339
|
const onReset = () => {
|
|
340
340
|
let valueNew_8 = inputToValue();
|
|
@@ -381,7 +381,7 @@ const DatePicker = props__ => {
|
|
|
381
381
|
// Update input modal
|
|
382
382
|
setInputModal(valueToInput(valueNew_9));
|
|
383
383
|
onClose(event_0);
|
|
384
|
-
if (is('function',
|
|
384
|
+
if (is('function', onTodayProps)) onTodayProps(event_0);
|
|
385
385
|
};
|
|
386
386
|
const onClear = event_1 => {
|
|
387
387
|
const dateNow_1 = new OnesyDate();
|
|
@@ -399,7 +399,7 @@ const DatePicker = props__ => {
|
|
|
399
399
|
// Update input modal
|
|
400
400
|
setInputModal(valueToInput(valueNew_10));
|
|
401
401
|
onClose(event_1);
|
|
402
|
-
if (is('function',
|
|
402
|
+
if (is('function', onClearProps)) onClearProps(event_1);
|
|
403
403
|
};
|
|
404
404
|
const onOk = event_2 => {
|
|
405
405
|
// Error
|
|
@@ -414,15 +414,15 @@ const DatePicker = props__ => {
|
|
|
414
414
|
// Update input modal
|
|
415
415
|
setInputModal(valueToInput(value));
|
|
416
416
|
onClose(event_2);
|
|
417
|
-
if (is('function',
|
|
417
|
+
if (is('function', onOkProps)) onOkProps(event_2);
|
|
418
418
|
};
|
|
419
419
|
const onCancel = event_3 => {
|
|
420
420
|
onReset();
|
|
421
421
|
onClose(event_3);
|
|
422
|
-
if (is('function',
|
|
422
|
+
if (is('function', onCancelProps)) onCancelProps(event_3);
|
|
423
423
|
};
|
|
424
424
|
const valid = (...args) => {
|
|
425
|
-
if (is('function',
|
|
425
|
+
if (is('function', validProps)) return validProps(...args);
|
|
426
426
|
const onesyDate = args[0];
|
|
427
427
|
if (min || max || validate) {
|
|
428
428
|
let response = true;
|
|
@@ -504,7 +504,7 @@ const DatePicker = props__ => {
|
|
|
504
504
|
mask.push(' ', SEPARATOR_SYMBOL, ' ', ...mask);
|
|
505
505
|
placeholder += `${SEPARATOR}${placeholder}`;
|
|
506
506
|
}
|
|
507
|
-
placeholder =
|
|
507
|
+
placeholder = placeholderProps || placeholder;
|
|
508
508
|
const buttonProps = _objectSpread({
|
|
509
509
|
color: 'inherit',
|
|
510
510
|
version: 'text',
|
|
@@ -593,7 +593,7 @@ const DatePicker = props__ => {
|
|
|
593
593
|
gap: 0,
|
|
594
594
|
direction: "column",
|
|
595
595
|
className: classNames([staticClassName('DatePicker', theme) && ['onesy-DatePicker-header'], classes.header, fullScreen && classes.header_fullScreen]),
|
|
596
|
-
children: [
|
|
596
|
+
children: [actionsProps && fullScreen && /*#__PURE__*/_jsxs(Line, {
|
|
597
597
|
gap: 0,
|
|
598
598
|
direction: "row",
|
|
599
599
|
align: "center",
|
|
@@ -615,7 +615,7 @@ const DatePicker = props__ => {
|
|
|
615
615
|
}, buttonProps), {}, {
|
|
616
616
|
children: l('Save')
|
|
617
617
|
}))]
|
|
618
|
-
}),
|
|
618
|
+
}), headingProps && /*#__PURE__*/_jsx(Type, {
|
|
619
619
|
version: "l2",
|
|
620
620
|
className: classNames([staticClassName('DatePicker', theme) && ['onesy-DatePicker-subheading'], classes.subheading, fullScreen && classes.subheading_fullScreen]),
|
|
621
621
|
children: !range ? modeModalSubHeadingText : modeModalSubHeadingTextRange
|
|
@@ -726,7 +726,7 @@ const DatePicker = props__ => {
|
|
|
726
726
|
}), fullScreen && /*#__PURE__*/_jsx(Divider, {
|
|
727
727
|
tonal: false,
|
|
728
728
|
className: classNames([staticClassName('DatePicker', theme) && ['onesy-DatePicker-divider'], classes.divider])
|
|
729
|
-
}),
|
|
729
|
+
}), actionsProps && /*#__PURE__*/React.cloneElement(actions, {
|
|
730
730
|
style: {
|
|
731
731
|
paddingTop: theme.methods.space.value(1, 'px')
|
|
732
732
|
}
|
|
@@ -747,11 +747,11 @@ const DatePicker = props__ => {
|
|
|
747
747
|
min: min,
|
|
748
748
|
max: max,
|
|
749
749
|
validate: validate,
|
|
750
|
-
belowCalendars:
|
|
750
|
+
belowCalendars: actionsProps ? actions : undefined
|
|
751
751
|
}, CalendarProps), CalendarPropsDesktop), {}, {
|
|
752
752
|
className: classNames([staticClassName('DatePicker', theme) && ['onesy-DatePicker-calendar', 'onesy-DatePicker-version-desktop'], CalendarProps?.className, CalendarPropsDesktop?.className, classes.calendar, classes.calendar_desktop])
|
|
753
753
|
}));
|
|
754
|
-
if (
|
|
754
|
+
if (staticProps) {
|
|
755
755
|
if (version === 'mobile') return mobile;
|
|
756
756
|
if (version === 'desktop') return desktop;
|
|
757
757
|
}
|