diginet-core-ui 1.4.34-beta.2 → 1.4.36-beta.1
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.
|
@@ -101,10 +101,10 @@ const DropdownBox = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, referen
|
|
|
101
101
|
}
|
|
102
102
|
};
|
|
103
103
|
|
|
104
|
-
/**
|
|
105
|
-
* Chuyển đổi data thành giá trị cần hiện thị dựa vào displayExpr [string, string object {field} - {field}], renderSelectedItem, displayExpr, valueExpr
|
|
106
|
-
* @param data {object} rowData of dataSource
|
|
107
|
-
* @return {string}
|
|
104
|
+
/**
|
|
105
|
+
* Chuyển đổi data thành giá trị cần hiện thị dựa vào displayExpr [string, string object {field} - {field}], renderSelectedItem, displayExpr, valueExpr
|
|
106
|
+
* @param data {object} rowData of dataSource
|
|
107
|
+
* @return {string}
|
|
108
108
|
*/
|
|
109
109
|
const displayValue = data => {
|
|
110
110
|
let text = '';
|
|
@@ -90,10 +90,10 @@ const TimePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, referenc
|
|
|
90
90
|
const saveText = getGlobal(['save']);
|
|
91
91
|
const nowText = getGlobal(['now']);
|
|
92
92
|
|
|
93
|
-
/**
|
|
94
|
-
* onChange handler with condition base on min max
|
|
95
|
-
* @param {*} e
|
|
96
|
-
* @param {String} key one of ['hour', 'minute', 'second']
|
|
93
|
+
/**
|
|
94
|
+
* onChange handler with condition base on min max
|
|
95
|
+
* @param {*} e
|
|
96
|
+
* @param {String} key one of ['hour', 'minute', 'second']
|
|
97
97
|
*/
|
|
98
98
|
const onChangeHandler = (e, key) => {
|
|
99
99
|
var _e$target;
|
|
@@ -149,10 +149,10 @@ const TimePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, referenc
|
|
|
149
149
|
}
|
|
150
150
|
};
|
|
151
151
|
|
|
152
|
-
/**
|
|
153
|
-
*
|
|
154
|
-
* @param {String} key
|
|
155
|
-
* @param {Number} value
|
|
152
|
+
/**
|
|
153
|
+
*
|
|
154
|
+
* @param {String} key
|
|
155
|
+
* @param {Number} value
|
|
156
156
|
*/
|
|
157
157
|
const setTimeAfterChange = (key, value) => {
|
|
158
158
|
setTimeValue({
|
|
@@ -161,14 +161,14 @@ const TimePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, referenc
|
|
|
161
161
|
});
|
|
162
162
|
};
|
|
163
163
|
|
|
164
|
-
/**
|
|
165
|
-
*
|
|
166
|
-
* Arrow up hour input onClick in the following cases:
|
|
167
|
-
* (1): Increase current hour by 1
|
|
168
|
-
* (2): If current hour is equal to max hour value, set current hour equal to min hour
|
|
169
|
-
* (3): If current hour plus 1 is equal to max hour, set current minute equal to max minute if current minute greater than max minute value
|
|
170
|
-
* (4): If current hour plus 1 is equal to max hour, set current second equal to max second if current second greater than max second value
|
|
171
|
-
* (5): Set current minute, second to min minute, second if current hour is greater than max hour value and current minute, second is greater than min minute, second value
|
|
164
|
+
/**
|
|
165
|
+
*
|
|
166
|
+
* Arrow up hour input onClick in the following cases:
|
|
167
|
+
* (1): Increase current hour by 1
|
|
168
|
+
* (2): If current hour is equal to max hour value, set current hour equal to min hour
|
|
169
|
+
* (3): If current hour plus 1 is equal to max hour, set current minute equal to max minute if current minute greater than max minute value
|
|
170
|
+
* (4): If current hour plus 1 is equal to max hour, set current second equal to max second if current second greater than max second value
|
|
171
|
+
* (5): Set current minute, second to min minute, second if current hour is greater than max hour value and current minute, second is greater than min minute, second value
|
|
172
172
|
*/
|
|
173
173
|
const onIncreaseHour = () => {
|
|
174
174
|
if (maxHour === currentHour + 1 && maxMinute < currentMinute) {
|
|
@@ -209,15 +209,15 @@ const TimePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, referenc
|
|
|
209
209
|
}
|
|
210
210
|
};
|
|
211
211
|
|
|
212
|
-
/**
|
|
213
|
-
*
|
|
214
|
-
* @constant {Number} minuteStep
|
|
215
|
-
* @constant {Number} lastMinute
|
|
216
|
-
* Arrow up minute input onClick in the following cases:
|
|
217
|
-
* (1): Increase current minute by minute step (default 1).
|
|
218
|
-
* (2): If current minute plus minute step is greater than lastMinute, set current minute equal to min minute.
|
|
219
|
-
* (3): If current second greater than max second value, set current second equal to max second.
|
|
220
|
-
* (4): (3) and current second is greater than max second value, set current second equal to max second.
|
|
212
|
+
/**
|
|
213
|
+
*
|
|
214
|
+
* @constant {Number} minuteStep
|
|
215
|
+
* @constant {Number} lastMinute
|
|
216
|
+
* Arrow up minute input onClick in the following cases:
|
|
217
|
+
* (1): Increase current minute by minute step (default 1).
|
|
218
|
+
* (2): If current minute plus minute step is greater than lastMinute, set current minute equal to min minute.
|
|
219
|
+
* (3): If current second greater than max second value, set current second equal to max second.
|
|
220
|
+
* (4): (3) and current second is greater than max second value, set current second equal to max second.
|
|
221
221
|
*/
|
|
222
222
|
const onIncreaseMinute = () => {
|
|
223
223
|
if (lastMinute < currentMinute + minuteStep) {
|
|
@@ -244,11 +244,11 @@ const TimePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, referenc
|
|
|
244
244
|
}
|
|
245
245
|
};
|
|
246
246
|
|
|
247
|
-
/**
|
|
248
|
-
*
|
|
249
|
-
* Arrow up second input onClick in the following cases:
|
|
250
|
-
* (1): Increase current second by 1
|
|
251
|
-
* (2): If current second plus 1 equal to max second value, set current second to min second
|
|
247
|
+
/**
|
|
248
|
+
*
|
|
249
|
+
* Arrow up second input onClick in the following cases:
|
|
250
|
+
* (1): Increase current second by 1
|
|
251
|
+
* (2): If current second plus 1 equal to max second value, set current second to min second
|
|
252
252
|
*/
|
|
253
253
|
const onIncreaseSecond = () => {
|
|
254
254
|
if (lastSecond < currentSecond + 1) {
|
|
@@ -260,15 +260,15 @@ const TimePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, referenc
|
|
|
260
260
|
}
|
|
261
261
|
};
|
|
262
262
|
|
|
263
|
-
/**
|
|
264
|
-
*
|
|
265
|
-
* Arrow down hour input onClick in the following cases:
|
|
266
|
-
* (1): Decrease current hour by 1
|
|
267
|
-
* (2): If current hour is equal to min hour value, set current hour equal to max hour
|
|
268
|
-
* (3): (2) and current minute is greater than max minute value, set minute to max minute value
|
|
269
|
-
* (4): (3) and current second is greater than min second value, set second to max second value
|
|
270
|
-
* (5): If current hour minus 1 is equal to min hour and current minute greater than min minute value, set current minute equal to min minute
|
|
271
|
-
* (6): (5) and current second is greater than min second value, set current second equal to min second
|
|
263
|
+
/**
|
|
264
|
+
*
|
|
265
|
+
* Arrow down hour input onClick in the following cases:
|
|
266
|
+
* (1): Decrease current hour by 1
|
|
267
|
+
* (2): If current hour is equal to min hour value, set current hour equal to max hour
|
|
268
|
+
* (3): (2) and current minute is greater than max minute value, set minute to max minute value
|
|
269
|
+
* (4): (3) and current second is greater than min second value, set second to max second value
|
|
270
|
+
* (5): If current hour minus 1 is equal to min hour and current minute greater than min minute value, set current minute equal to min minute
|
|
271
|
+
* (6): (5) and current second is greater than min second value, set current second equal to min second
|
|
272
272
|
*/
|
|
273
273
|
const onDecreaseHour = () => {
|
|
274
274
|
if (minHour === currentHour - 1 && minMinute > currentMinute) {
|
|
@@ -319,15 +319,15 @@ const TimePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, referenc
|
|
|
319
319
|
}
|
|
320
320
|
};
|
|
321
321
|
|
|
322
|
-
/**
|
|
323
|
-
*
|
|
324
|
-
* @constant {Number} minuteStep
|
|
325
|
-
* @constant {Number} startMinute
|
|
326
|
-
* @constant {Number} lastMinute
|
|
327
|
-
* Arrow down minute input onClick in the following cases:
|
|
328
|
-
* (1): Decrease current minute by @minuteStep
|
|
329
|
-
* (2): If current minute minus @minuteStep is smaller than @startMinute , set current minute to @lastMinute - @lastMinute % @minuteStep
|
|
330
|
-
* (3): (2) and current second is greater than max second, set current second to max second
|
|
322
|
+
/**
|
|
323
|
+
*
|
|
324
|
+
* @constant {Number} minuteStep
|
|
325
|
+
* @constant {Number} startMinute
|
|
326
|
+
* @constant {Number} lastMinute
|
|
327
|
+
* Arrow down minute input onClick in the following cases:
|
|
328
|
+
* (1): Decrease current minute by @minuteStep
|
|
329
|
+
* (2): If current minute minus @minuteStep is smaller than @startMinute , set current minute to @lastMinute - @lastMinute % @minuteStep
|
|
330
|
+
* (3): (2) and current second is greater than max second, set current second to max second
|
|
331
331
|
*/
|
|
332
332
|
const onDecreaseMinute = () => {
|
|
333
333
|
if (startMinute > currentMinute - minuteStep) {
|
|
@@ -348,13 +348,13 @@ const TimePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, referenc
|
|
|
348
348
|
}
|
|
349
349
|
};
|
|
350
350
|
|
|
351
|
-
/**
|
|
352
|
-
*
|
|
353
|
-
* @constant {Number} startSecond
|
|
354
|
-
* @constant {Number} lastSecond
|
|
355
|
-
* Arrow down second input onClick in the following cases:
|
|
356
|
-
* (1): Decrease current second by 1
|
|
357
|
-
* (2): If current second minus 1 is smaller than start second, set current second to last second
|
|
351
|
+
/**
|
|
352
|
+
*
|
|
353
|
+
* @constant {Number} startSecond
|
|
354
|
+
* @constant {Number} lastSecond
|
|
355
|
+
* Arrow down second input onClick in the following cases:
|
|
356
|
+
* (1): Decrease current second by 1
|
|
357
|
+
* (2): If current second minus 1 is smaller than start second, set current second to last second
|
|
358
358
|
*/
|
|
359
359
|
const onDecreaseSecond = () => {
|
|
360
360
|
if (startSecond >= currentSecond - 1) {
|
|
@@ -366,30 +366,30 @@ const TimePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, referenc
|
|
|
366
366
|
}
|
|
367
367
|
};
|
|
368
368
|
|
|
369
|
-
/**
|
|
370
|
-
*
|
|
371
|
-
* onClose Popover Timepicker when click Save button
|
|
369
|
+
/**
|
|
370
|
+
*
|
|
371
|
+
* onClose Popover Timepicker when click Save button
|
|
372
372
|
*/
|
|
373
373
|
const onCloseTimePicker = () => {
|
|
374
374
|
timePickerRef.current.close();
|
|
375
375
|
setCurrentInputFocus(null);
|
|
376
376
|
};
|
|
377
377
|
|
|
378
|
-
/**
|
|
379
|
-
*
|
|
380
|
-
* Format value using date().format() in utils
|
|
381
|
-
* @param {Date} value
|
|
382
|
-
* @param {String} outputFormat
|
|
383
|
-
* @returns
|
|
378
|
+
/**
|
|
379
|
+
*
|
|
380
|
+
* Format value using date().format() in utils
|
|
381
|
+
* @param {Date} value
|
|
382
|
+
* @param {String} outputFormat
|
|
383
|
+
* @returns
|
|
384
384
|
*/
|
|
385
385
|
const formatTime = (value, outputFormat) => {
|
|
386
386
|
return mode12h ? date(value).format(`hh${outputFormat.slice(2)} A`) : date(value).format(outputFormat);
|
|
387
387
|
};
|
|
388
388
|
|
|
389
|
-
/**
|
|
390
|
-
*
|
|
391
|
-
* Button Save onClick
|
|
392
|
-
* @param {Boolean} now
|
|
389
|
+
/**
|
|
390
|
+
*
|
|
391
|
+
* Button Save onClick
|
|
392
|
+
* @param {Boolean} now
|
|
393
393
|
*/
|
|
394
394
|
const onSelectTime = (now = false) => {
|
|
395
395
|
let displayTimeValue = '00:00:00';
|
|
@@ -404,8 +404,8 @@ const TimePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, referenc
|
|
|
404
404
|
text: displayTimeValue.slice(0, 2).includes(':') ? displayTimeValue.slice(9, 11) : displayTimeValue.slice(10, 12)
|
|
405
405
|
});
|
|
406
406
|
} else {
|
|
407
|
-
displayTimeValue = `${date(currentTime).format(displayFormat)}
|
|
408
|
-
returnTimeValue = `${date(currentTime).format(returnFormat)}
|
|
407
|
+
displayTimeValue = `${date(currentTime).format(displayFormat)}${mode12h ? ` ${timeValue === null || timeValue === void 0 ? void 0 : timeValue.text}` : ''}`;
|
|
408
|
+
returnTimeValue = `${date(currentTime).format(returnFormat)}${mode12h ? ` ${timeValue === null || timeValue === void 0 ? void 0 : timeValue.text}` : ''}`;
|
|
409
409
|
}
|
|
410
410
|
if (!now) {
|
|
411
411
|
setDisplayTime(displayTimeValue);
|
|
@@ -420,12 +420,22 @@ const TimePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, referenc
|
|
|
420
420
|
// useEffect for prop value
|
|
421
421
|
useEffect(() => {
|
|
422
422
|
if (!value) {
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
423
|
+
if (!mode12h) {
|
|
424
|
+
const timeValue = {
|
|
425
|
+
hour: min ? min.slice(0, 2) : mode12h ? 1 : 0,
|
|
426
|
+
minute: min ? min.slice(3, 5) : 0,
|
|
427
|
+
second: min ? min.slice(6, 8) : 0
|
|
428
|
+
};
|
|
429
|
+
setTimeValue(timeValue);
|
|
430
|
+
} else {
|
|
431
|
+
const timeValue = {
|
|
432
|
+
hour: min ? min.slice(0, 2) : mode12h ? 1 : 0,
|
|
433
|
+
minute: min ? min.slice(3, 5) : 0,
|
|
434
|
+
second: min ? min.slice(6, 8) : 0,
|
|
435
|
+
text: min ? (returnFormat === 'HH:mm:ss' ? min.slice(10, 12) : min.slice(6, 8)) || 'AM' : 'AM'
|
|
436
|
+
};
|
|
437
|
+
setTimeValue(timeValue);
|
|
438
|
+
}
|
|
429
439
|
setDisplayTime(null);
|
|
430
440
|
} else {
|
|
431
441
|
let displayTimeValue = '00:00:00';
|
|
@@ -433,13 +443,22 @@ const TimePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, referenc
|
|
|
433
443
|
const valueMinute = Number(value.slice(3, 5)) || '00';
|
|
434
444
|
const valueSecond = Number(value.slice(6, 8)) || '00';
|
|
435
445
|
const valueTime = new Date(new Date().getFullYear(), 0, 1, valueHour, valueMinute, valueSecond);
|
|
436
|
-
displayTimeValue = formatTime(valueTime, displayFormat);
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
446
|
+
displayTimeValue = formatTime(valueTime, displayFormat).slice(0, -3).concat(returnFormat === 'HH:mm:ss' ? ` ${value.slice(10, 12)}` : ` ${value.slice(6, 8)}`);
|
|
447
|
+
if (!mode12h) {
|
|
448
|
+
setTimeValue({
|
|
449
|
+
hour: value.slice(0, 2),
|
|
450
|
+
minute: value.slice(3, 5),
|
|
451
|
+
second: value.slice(6, 8)
|
|
452
|
+
});
|
|
453
|
+
} else {
|
|
454
|
+
const timeValue = {
|
|
455
|
+
hour: value.slice(0, 2),
|
|
456
|
+
minute: value.slice(3, 5),
|
|
457
|
+
second: returnFormat === 'HH:mm:ss' ? value.slice(6, 8) : '00',
|
|
458
|
+
text: returnFormat === 'HH:mm:ss' ? value.slice(10, 12) : value.slice(6, 8)
|
|
459
|
+
};
|
|
460
|
+
setTimeValue(timeValue);
|
|
461
|
+
}
|
|
443
462
|
setDisplayTime(displayTimeValue);
|
|
444
463
|
}
|
|
445
464
|
}, [value, displayFormat, returnFormat, mode12h, min, max]);
|
|
@@ -477,7 +496,23 @@ const TimePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, referenc
|
|
|
477
496
|
disabled: disabled,
|
|
478
497
|
required: required,
|
|
479
498
|
...labelProps
|
|
480
|
-
}, label), jsx(
|
|
499
|
+
}, label), readOnly ? jsx(InputBase, {
|
|
500
|
+
inputProps: {
|
|
501
|
+
placeholder: !readOnly && !disabled ? placeholder : '',
|
|
502
|
+
...inputProps
|
|
503
|
+
},
|
|
504
|
+
disabled: disabled,
|
|
505
|
+
viewType: viewType,
|
|
506
|
+
inputStyle: {
|
|
507
|
+
...inputStyle
|
|
508
|
+
},
|
|
509
|
+
value: displayTime,
|
|
510
|
+
endIcon: endIcon,
|
|
511
|
+
startIcon: startIcon,
|
|
512
|
+
onKeyDown: e => e.preventDefault(),
|
|
513
|
+
status: error ? 'danger' : 'default',
|
|
514
|
+
readOnly: true
|
|
515
|
+
}) : jsx(Popover, {
|
|
481
516
|
css: _TimePickerCSS,
|
|
482
517
|
anchor: jsx(InputBase, {
|
|
483
518
|
inputProps: {
|
|
@@ -725,24 +760,6 @@ const TimePickerAMPMCSS = (currentText, {
|
|
|
725
760
|
${parseWidth(32)};
|
|
726
761
|
}
|
|
727
762
|
`;
|
|
728
|
-
|
|
729
|
-
// TimePicker.defaultProps = {
|
|
730
|
-
// actionIconAt: 'end',
|
|
731
|
-
// className: '',
|
|
732
|
-
// disabled: false,
|
|
733
|
-
// displayFormat: 'HH:mm:ss',
|
|
734
|
-
// mode12h: false,
|
|
735
|
-
// readOnly: false,
|
|
736
|
-
// required: false,
|
|
737
|
-
// returnFormat: 'HH:mm:ss',
|
|
738
|
-
// error: '',
|
|
739
|
-
// minuteStep: 1,
|
|
740
|
-
// min: '',
|
|
741
|
-
// max: '',
|
|
742
|
-
// label: '',
|
|
743
|
-
// value: '',
|
|
744
|
-
// };
|
|
745
|
-
|
|
746
763
|
TimePicker.propTypes = {
|
|
747
764
|
/** CSS class for the component. ({container: '', header: '', body: '', footer: ''}) */
|
|
748
765
|
className: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
|