@onesy/ui-react 1.0.156 → 1.0.158
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.
|
@@ -287,7 +287,7 @@ const CalendarMenu = /*#__PURE__*/_react.default.forwardRef((props_, ref) => {
|
|
|
287
287
|
if (value !== null && value !== void 0 && (_value$repeat9 = value.repeat) !== null && _value$repeat9 !== void 0 && _value$repeat9.skip_weekends && [0, 6].includes(day.dayWeek)) repeating = false;
|
|
288
288
|
if (repeating) {
|
|
289
289
|
var _value$repeat0, _value$repeat1, _value$repeat$ends;
|
|
290
|
-
const
|
|
290
|
+
const formatted = (0, _date.format)(day, _utils2.formats.date);
|
|
291
291
|
if (value !== null && value !== void 0 && (_value$repeat0 = value.repeat) !== null && _value$repeat0 !== void 0 && (_value$repeat0 = _value$repeat0.ends) !== null && _value$repeat0 !== void 0 && _value$repeat0.active) {
|
|
292
292
|
// date
|
|
293
293
|
if ((value === null || value === void 0 ? void 0 : value.repeat.ends.version) === 'date') {
|
|
@@ -297,11 +297,11 @@ const CalendarMenu = /*#__PURE__*/_react.default.forwardRef((props_, ref) => {
|
|
|
297
297
|
}
|
|
298
298
|
if (repeating) {
|
|
299
299
|
if (!refs.repeatCount.current[value === null || value === void 0 ? void 0 : value.id]) refs.repeatCount.current[value === null || value === void 0 ? void 0 : value.id] = [];
|
|
300
|
-
if (!refs.repeatCount.current[value === null || value === void 0 ? void 0 : value.id].includes(
|
|
300
|
+
if (!refs.repeatCount.current[value === null || value === void 0 ? void 0 : value.id].includes(formatted)) refs.repeatCount.current[value === null || value === void 0 ? void 0 : value.id].push(formatted);
|
|
301
301
|
}
|
|
302
302
|
if (value !== null && value !== void 0 && (_value$repeat1 = value.repeat) !== null && _value$repeat1 !== void 0 && (_value$repeat1 = _value$repeat1.ends) !== null && _value$repeat1 !== void 0 && _value$repeat1.active) {
|
|
303
303
|
var _refs$repeatCount$cur;
|
|
304
|
-
const indexRepeated = (_refs$repeatCount$cur = refs.repeatCount.current[value === null || value === void 0 ? void 0 : value.id]) === null || _refs$repeatCount$cur === void 0 ? void 0 : _refs$repeatCount$cur.indexOf(
|
|
304
|
+
const indexRepeated = (_refs$repeatCount$cur = refs.repeatCount.current[value === null || value === void 0 ? void 0 : value.id]) === null || _refs$repeatCount$cur === void 0 ? void 0 : _refs$repeatCount$cur.indexOf(formatted);
|
|
305
305
|
|
|
306
306
|
// count
|
|
307
307
|
if ((value === null || value === void 0 ? void 0 : value.repeat.ends.version) === 'count') repeating = repeating && (value === null || value === void 0 ? void 0 : value.repeat.ends.value) >= (indexRepeated === -1 ? 0 : indexRepeated) + 1;
|
|
@@ -374,7 +374,6 @@ const CalendarMonth = /*#__PURE__*/_react.default.forwardRef((props__, ref) => {
|
|
|
374
374
|
};
|
|
375
375
|
return values[order_];
|
|
376
376
|
};
|
|
377
|
-
const days = [];
|
|
378
377
|
const monthNow = new _date.OnesyDate();
|
|
379
378
|
|
|
380
379
|
// value or value range selected value
|
|
@@ -441,8 +440,8 @@ const CalendarMonth = /*#__PURE__*/_react.default.forwardRef((props__, ref) => {
|
|
|
441
440
|
selectedSame: value.filter(item => item.year === day.year && item.month === day.month && item.day === day.day).length === 2
|
|
442
441
|
};
|
|
443
442
|
|
|
444
|
-
//
|
|
445
|
-
for (const itemRange of
|
|
443
|
+
// value
|
|
444
|
+
for (const itemRange of rangesValue) {
|
|
446
445
|
const rangeStartDay = (0, _date.format)(new _date.OnesyDate(itemRange.start), 'DD-MM-YYYY');
|
|
447
446
|
const rangeEndDay = (0, _date.format)(new _date.OnesyDate(itemRange.end), 'DD-MM-YYYY');
|
|
448
447
|
|
|
@@ -457,14 +456,11 @@ const CalendarMonth = /*#__PURE__*/_react.default.forwardRef((props__, ref) => {
|
|
|
457
456
|
|
|
458
457
|
// same
|
|
459
458
|
result.same = result.start && result.end;
|
|
460
|
-
if (result.selected)
|
|
461
|
-
result.fromSelected = true;
|
|
462
|
-
return result;
|
|
463
|
-
}
|
|
459
|
+
if (result.selected) return result;
|
|
464
460
|
}
|
|
465
461
|
|
|
466
|
-
//
|
|
467
|
-
for (const itemRange of
|
|
462
|
+
// selected
|
|
463
|
+
for (const itemRange of rangesSelected) {
|
|
468
464
|
const rangeStartDay = (0, _date.format)(new _date.OnesyDate(itemRange.start), 'DD-MM-YYYY');
|
|
469
465
|
const rangeEndDay = (0, _date.format)(new _date.OnesyDate(itemRange.end), 'DD-MM-YYYY');
|
|
470
466
|
|
|
@@ -479,73 +475,77 @@ const CalendarMonth = /*#__PURE__*/_react.default.forwardRef((props__, ref) => {
|
|
|
479
475
|
|
|
480
476
|
// same
|
|
481
477
|
result.same = result.start && result.end;
|
|
482
|
-
if (result.selected)
|
|
478
|
+
if (result.selected) {
|
|
479
|
+
result.fromSelected = true;
|
|
480
|
+
return result;
|
|
481
|
+
}
|
|
483
482
|
}
|
|
484
483
|
result.outside = true;
|
|
485
484
|
return result;
|
|
486
485
|
}, [value, selected, rangesSelected, rangesValue]);
|
|
487
|
-
|
|
488
|
-
|
|
486
|
+
const days = _react.default.useMemo(() => {
|
|
487
|
+
const items = [];
|
|
489
488
|
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
const details = getDetails(day);
|
|
495
|
-
if (details.selectedIndex === 0) isMonthFrom = true;else if (details.selectedIndex === 1) isMonthTo = true;
|
|
496
|
-
days.push({
|
|
497
|
-
value: i + 1,
|
|
498
|
-
in: true,
|
|
499
|
-
dayWeek: day.dayWeek,
|
|
500
|
-
weekend: [0, 6].includes(day.dayWeek),
|
|
501
|
-
today: day.year === monthNow.year && day.dayYear === monthNow.dayYear,
|
|
502
|
-
is: _objectSpread({}, details),
|
|
503
|
-
onesyDate: day
|
|
504
|
-
});
|
|
505
|
-
}
|
|
506
|
-
days[0].start = true;
|
|
507
|
-
days[days.length - 1].end = true;
|
|
508
|
-
|
|
509
|
-
// Add to start
|
|
510
|
-
if (weekStartDay === 'Sunday' && monthStart.dayWeek !== 0 || weekStartDay === 'Monday' && monthStart.dayWeek !== 1) {
|
|
511
|
-
let toAdd = monthStart.dayWeek === 0 ? 6 : monthStart.dayWeek - 1;
|
|
512
|
-
if (weekStartDay === 'Sunday') toAdd++;
|
|
513
|
-
for (let i = 0; i < toAdd; i++) {
|
|
514
|
-
const day = (0, _date.set)(previousMonthEnd.day - i, 'day', previousMonth);
|
|
489
|
+
// Add all month days
|
|
490
|
+
for (let i = 0; i < month.daysInMonth; i++) {
|
|
491
|
+
let day = (0, _date.set)(i + 1, 'day', month);
|
|
492
|
+
day = (0, _date.set)(14, 'hour', day);
|
|
515
493
|
const details = getDetails(day);
|
|
516
|
-
|
|
517
|
-
value:
|
|
518
|
-
in:
|
|
494
|
+
items.push({
|
|
495
|
+
value: i + 1,
|
|
496
|
+
in: true,
|
|
519
497
|
dayWeek: day.dayWeek,
|
|
520
498
|
weekend: [0, 6].includes(day.dayWeek),
|
|
521
499
|
today: day.year === monthNow.year && day.dayYear === monthNow.dayYear,
|
|
522
500
|
is: _objectSpread({}, details),
|
|
523
|
-
start: true,
|
|
524
501
|
onesyDate: day
|
|
525
502
|
});
|
|
526
503
|
}
|
|
527
|
-
|
|
504
|
+
items[0].start = true;
|
|
505
|
+
items[items.length - 1].end = true;
|
|
528
506
|
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
}
|
|
507
|
+
// Add to start
|
|
508
|
+
if (weekStartDay === 'Sunday' && monthStart.dayWeek !== 0 || weekStartDay === 'Monday' && monthStart.dayWeek !== 1) {
|
|
509
|
+
let toAdd = monthStart.dayWeek === 0 ? 6 : monthStart.dayWeek - 1;
|
|
510
|
+
if (weekStartDay === 'Sunday') toAdd++;
|
|
511
|
+
for (let i = 0; i < toAdd; i++) {
|
|
512
|
+
const day = (0, _date.set)(previousMonthEnd.day - i, 'day', previousMonth);
|
|
513
|
+
const details = getDetails(day);
|
|
514
|
+
items.unshift({
|
|
515
|
+
value: day.day,
|
|
516
|
+
in: false,
|
|
517
|
+
dayWeek: day.dayWeek,
|
|
518
|
+
weekend: [0, 6].includes(day.dayWeek),
|
|
519
|
+
today: day.year === monthNow.year && day.dayYear === monthNow.dayYear,
|
|
520
|
+
is: _objectSpread({}, details),
|
|
521
|
+
start: true,
|
|
522
|
+
onesyDate: day
|
|
523
|
+
});
|
|
524
|
+
}
|
|
547
525
|
}
|
|
548
|
-
|
|
526
|
+
|
|
527
|
+
// Add to end
|
|
528
|
+
const dayLast = items[items.length - 1];
|
|
529
|
+
if (dayLast.dayWeek < 7) {
|
|
530
|
+
let toAdd = 7 - dayLast.dayWeek;
|
|
531
|
+
if (items.length + toAdd - 1 < 42) toAdd += 41 - (items.length + toAdd - 1);
|
|
532
|
+
for (let i = 0; i < toAdd; i++) {
|
|
533
|
+
const day = (0, _date.set)(i + 1, 'day', nextMonth);
|
|
534
|
+
const details = getDetails(day);
|
|
535
|
+
items.push({
|
|
536
|
+
value: i + 1,
|
|
537
|
+
in: false,
|
|
538
|
+
dayWeek: day.dayWeek,
|
|
539
|
+
weekend: [0, 6].includes(day.dayWeek),
|
|
540
|
+
today: day.year === monthNow.year && day.dayYear === monthNow.dayYear,
|
|
541
|
+
is: _objectSpread({}, details),
|
|
542
|
+
end: true,
|
|
543
|
+
onesyDate: day
|
|
544
|
+
});
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
return items;
|
|
548
|
+
}, [month, getDetails]);
|
|
549
549
|
const colorSelectedTheme = _react.default.useMemo(() => {
|
|
550
550
|
return theme.palette.color[colorSelected] || theme.methods.color(colorSelected);
|
|
551
551
|
}, [colorSelected, theme]);
|
|
@@ -646,10 +646,6 @@ const CalendarMonth = /*#__PURE__*/_react.default.forwardRef((props__, ref) => {
|
|
|
646
646
|
gap: 0,
|
|
647
647
|
direction: "column",
|
|
648
648
|
className: (0, _styleReact.classNames)([(0, _utils2.staticClassName)('CalendarMonth', theme) && ['onesy-CalendarMonth-root', `onesy-CalendarMonth-size-${size}`], className, noTransition ? classes.root : classes.root_transition, classes[`size_${size}`], classes[`move_${refs.move.current}`], !labels && classes.root_no_labels, disabled && classes.disabled])
|
|
649
|
-
}, isMonthFrom && {
|
|
650
|
-
'data-month-from': true
|
|
651
|
-
}, isMonthTo && {
|
|
652
|
-
'data-month-to': true
|
|
653
649
|
}, other), labels && /*#__PURE__*/_react.default.createElement(Line, {
|
|
654
650
|
gap: 0,
|
|
655
651
|
direction: "row",
|
|
@@ -242,7 +242,7 @@ const CalendarMenu = /*#__PURE__*/React.forwardRef((props_, ref) => {
|
|
|
242
242
|
}
|
|
243
243
|
if (value?.repeat?.skip_weekends && [0, 6].includes(day.dayWeek)) repeating = false;
|
|
244
244
|
if (repeating) {
|
|
245
|
-
const
|
|
245
|
+
const formatted = format(day, formats.date);
|
|
246
246
|
if (value?.repeat?.ends?.active) {
|
|
247
247
|
// date
|
|
248
248
|
if (value?.repeat.ends.version === 'date') {
|
|
@@ -252,10 +252,10 @@ const CalendarMenu = /*#__PURE__*/React.forwardRef((props_, ref) => {
|
|
|
252
252
|
}
|
|
253
253
|
if (repeating) {
|
|
254
254
|
if (!refs.repeatCount.current[value?.id]) refs.repeatCount.current[value?.id] = [];
|
|
255
|
-
if (!refs.repeatCount.current[value?.id].includes(
|
|
255
|
+
if (!refs.repeatCount.current[value?.id].includes(formatted)) refs.repeatCount.current[value?.id].push(formatted);
|
|
256
256
|
}
|
|
257
257
|
if (value?.repeat?.ends?.active) {
|
|
258
|
-
const indexRepeated = refs.repeatCount.current[value?.id]?.indexOf(
|
|
258
|
+
const indexRepeated = refs.repeatCount.current[value?.id]?.indexOf(formatted);
|
|
259
259
|
|
|
260
260
|
// count
|
|
261
261
|
if (value?.repeat.ends.version === 'count') repeating = repeating && value?.repeat.ends.value >= (indexRepeated === -1 ? 0 : indexRepeated) + 1;
|
|
@@ -343,7 +343,6 @@ const CalendarMonth = /*#__PURE__*/React.forwardRef((props__, ref) => {
|
|
|
343
343
|
};
|
|
344
344
|
return values[order_];
|
|
345
345
|
};
|
|
346
|
-
const days = [];
|
|
347
346
|
const monthNow = new OnesyDate();
|
|
348
347
|
|
|
349
348
|
// value or value range selected value
|
|
@@ -410,8 +409,8 @@ const CalendarMonth = /*#__PURE__*/React.forwardRef((props__, ref) => {
|
|
|
410
409
|
selectedSame: value.filter(item => item.year === day.year && item.month === day.month && item.day === day.day).length === 2
|
|
411
410
|
};
|
|
412
411
|
|
|
413
|
-
//
|
|
414
|
-
for (const itemRange of
|
|
412
|
+
// value
|
|
413
|
+
for (const itemRange of rangesValue) {
|
|
415
414
|
const rangeStartDay = format(new OnesyDate(itemRange.start), 'DD-MM-YYYY');
|
|
416
415
|
const rangeEndDay = format(new OnesyDate(itemRange.end), 'DD-MM-YYYY');
|
|
417
416
|
|
|
@@ -426,14 +425,11 @@ const CalendarMonth = /*#__PURE__*/React.forwardRef((props__, ref) => {
|
|
|
426
425
|
|
|
427
426
|
// same
|
|
428
427
|
result.same = result.start && result.end;
|
|
429
|
-
if (result.selected)
|
|
430
|
-
result.fromSelected = true;
|
|
431
|
-
return result;
|
|
432
|
-
}
|
|
428
|
+
if (result.selected) return result;
|
|
433
429
|
}
|
|
434
430
|
|
|
435
|
-
//
|
|
436
|
-
for (const itemRange of
|
|
431
|
+
// selected
|
|
432
|
+
for (const itemRange of rangesSelected) {
|
|
437
433
|
const rangeStartDay = format(new OnesyDate(itemRange.start), 'DD-MM-YYYY');
|
|
438
434
|
const rangeEndDay = format(new OnesyDate(itemRange.end), 'DD-MM-YYYY');
|
|
439
435
|
|
|
@@ -448,73 +444,77 @@ const CalendarMonth = /*#__PURE__*/React.forwardRef((props__, ref) => {
|
|
|
448
444
|
|
|
449
445
|
// same
|
|
450
446
|
result.same = result.start && result.end;
|
|
451
|
-
if (result.selected)
|
|
447
|
+
if (result.selected) {
|
|
448
|
+
result.fromSelected = true;
|
|
449
|
+
return result;
|
|
450
|
+
}
|
|
452
451
|
}
|
|
453
452
|
result.outside = true;
|
|
454
453
|
return result;
|
|
455
454
|
}, [value, selected, rangesSelected, rangesValue]);
|
|
456
|
-
|
|
457
|
-
|
|
455
|
+
const days = React.useMemo(() => {
|
|
456
|
+
const items = [];
|
|
458
457
|
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
const details = getDetails(day);
|
|
464
|
-
if (details.selectedIndex === 0) isMonthFrom = true;else if (details.selectedIndex === 1) isMonthTo = true;
|
|
465
|
-
days.push({
|
|
466
|
-
value: i + 1,
|
|
467
|
-
in: true,
|
|
468
|
-
dayWeek: day.dayWeek,
|
|
469
|
-
weekend: [0, 6].includes(day.dayWeek),
|
|
470
|
-
today: day.year === monthNow.year && day.dayYear === monthNow.dayYear,
|
|
471
|
-
is: _objectSpread({}, details),
|
|
472
|
-
onesyDate: day
|
|
473
|
-
});
|
|
474
|
-
}
|
|
475
|
-
days[0].start = true;
|
|
476
|
-
days[days.length - 1].end = true;
|
|
477
|
-
|
|
478
|
-
// Add to start
|
|
479
|
-
if (weekStartDay === 'Sunday' && monthStart.dayWeek !== 0 || weekStartDay === 'Monday' && monthStart.dayWeek !== 1) {
|
|
480
|
-
let toAdd = monthStart.dayWeek === 0 ? 6 : monthStart.dayWeek - 1;
|
|
481
|
-
if (weekStartDay === 'Sunday') toAdd++;
|
|
482
|
-
for (let i = 0; i < toAdd; i++) {
|
|
483
|
-
const day = set(previousMonthEnd.day - i, 'day', previousMonth);
|
|
458
|
+
// Add all month days
|
|
459
|
+
for (let i = 0; i < month.daysInMonth; i++) {
|
|
460
|
+
let day = set(i + 1, 'day', month);
|
|
461
|
+
day = set(14, 'hour', day);
|
|
484
462
|
const details = getDetails(day);
|
|
485
|
-
|
|
486
|
-
value:
|
|
487
|
-
in:
|
|
463
|
+
items.push({
|
|
464
|
+
value: i + 1,
|
|
465
|
+
in: true,
|
|
488
466
|
dayWeek: day.dayWeek,
|
|
489
467
|
weekend: [0, 6].includes(day.dayWeek),
|
|
490
468
|
today: day.year === monthNow.year && day.dayYear === monthNow.dayYear,
|
|
491
469
|
is: _objectSpread({}, details),
|
|
492
|
-
start: true,
|
|
493
470
|
onesyDate: day
|
|
494
471
|
});
|
|
495
472
|
}
|
|
496
|
-
|
|
473
|
+
items[0].start = true;
|
|
474
|
+
items[items.length - 1].end = true;
|
|
497
475
|
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
}
|
|
476
|
+
// Add to start
|
|
477
|
+
if (weekStartDay === 'Sunday' && monthStart.dayWeek !== 0 || weekStartDay === 'Monday' && monthStart.dayWeek !== 1) {
|
|
478
|
+
let toAdd = monthStart.dayWeek === 0 ? 6 : monthStart.dayWeek - 1;
|
|
479
|
+
if (weekStartDay === 'Sunday') toAdd++;
|
|
480
|
+
for (let i = 0; i < toAdd; i++) {
|
|
481
|
+
const day = set(previousMonthEnd.day - i, 'day', previousMonth);
|
|
482
|
+
const details = getDetails(day);
|
|
483
|
+
items.unshift({
|
|
484
|
+
value: day.day,
|
|
485
|
+
in: false,
|
|
486
|
+
dayWeek: day.dayWeek,
|
|
487
|
+
weekend: [0, 6].includes(day.dayWeek),
|
|
488
|
+
today: day.year === monthNow.year && day.dayYear === monthNow.dayYear,
|
|
489
|
+
is: _objectSpread({}, details),
|
|
490
|
+
start: true,
|
|
491
|
+
onesyDate: day
|
|
492
|
+
});
|
|
493
|
+
}
|
|
516
494
|
}
|
|
517
|
-
|
|
495
|
+
|
|
496
|
+
// Add to end
|
|
497
|
+
const dayLast = items[items.length - 1];
|
|
498
|
+
if (dayLast.dayWeek < 7) {
|
|
499
|
+
let toAdd = 7 - dayLast.dayWeek;
|
|
500
|
+
if (items.length + toAdd - 1 < 42) toAdd += 41 - (items.length + toAdd - 1);
|
|
501
|
+
for (let i = 0; i < toAdd; i++) {
|
|
502
|
+
const day = set(i + 1, 'day', nextMonth);
|
|
503
|
+
const details = getDetails(day);
|
|
504
|
+
items.push({
|
|
505
|
+
value: i + 1,
|
|
506
|
+
in: false,
|
|
507
|
+
dayWeek: day.dayWeek,
|
|
508
|
+
weekend: [0, 6].includes(day.dayWeek),
|
|
509
|
+
today: day.year === monthNow.year && day.dayYear === monthNow.dayYear,
|
|
510
|
+
is: _objectSpread({}, details),
|
|
511
|
+
end: true,
|
|
512
|
+
onesyDate: day
|
|
513
|
+
});
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
return items;
|
|
517
|
+
}, [month, getDetails]);
|
|
518
518
|
const colorSelectedTheme = React.useMemo(() => {
|
|
519
519
|
return theme.palette.color[colorSelected] || theme.methods.color(colorSelected);
|
|
520
520
|
}, [colorSelected, theme]);
|
|
@@ -614,10 +614,6 @@ const CalendarMonth = /*#__PURE__*/React.forwardRef((props__, ref) => {
|
|
|
614
614
|
gap: 0,
|
|
615
615
|
direction: "column",
|
|
616
616
|
className: classNames([staticClassName('CalendarMonth', theme) && ['onesy-CalendarMonth-root', `onesy-CalendarMonth-size-${size}`], className, noTransition ? classes.root : classes.root_transition, classes[`size_${size}`], classes[`move_${refs.move.current}`], !labels && classes.root_no_labels, disabled && classes.disabled])
|
|
617
|
-
}, isMonthFrom && {
|
|
618
|
-
'data-month-from': true
|
|
619
|
-
}, isMonthTo && {
|
|
620
|
-
'data-month-to': true
|
|
621
617
|
}, other), labels && /*#__PURE__*/React.createElement(Line, {
|
|
622
618
|
gap: 0,
|
|
623
619
|
direction: "row",
|
package/esm/index.js
CHANGED
package/index.js
CHANGED