@bigbinary/neeto-molecules 5.2.32 → 5.2.34
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/dist/Schedule.js +251 -93
- package/dist/Schedule.js.map +1 -1
- package/dist/cjs/Schedule.js +249 -91
- package/dist/cjs/Schedule.js.map +1 -1
- package/dist/cjs/v2/Builder.js +21 -11
- package/dist/cjs/v2/Builder.js.map +1 -1
- package/dist/cjs/v2/ResponsiveDevicePicker.js +19 -26
- package/dist/cjs/v2/ResponsiveDevicePicker.js.map +1 -1
- package/dist/v2/Builder.js +21 -11
- package/dist/v2/Builder.js.map +1 -1
- package/dist/v2/ResponsiveDevicePicker.js +19 -26
- package/dist/v2/ResponsiveDevicePicker.js.map +1 -1
- package/package.json +7 -7
- package/src/translations/en.json +3 -1
package/dist/cjs/Schedule.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var React = require('react');
|
|
6
|
+
var classnames = require('classnames');
|
|
6
7
|
var formik = require('formik');
|
|
7
8
|
var neetoCist = require('@bigbinary/neeto-cist');
|
|
8
9
|
var general = require('@bigbinary/neeto-commons-frontend/utils/general');
|
|
@@ -20,16 +21,14 @@ var _classCallCheck = require('@babel/runtime/helpers/classCallCheck');
|
|
|
20
21
|
var _createClass = require('@babel/runtime/helpers/createClass');
|
|
21
22
|
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
22
23
|
var jsxRuntime = require('react/jsx-runtime');
|
|
23
|
-
var classnames = require('classnames');
|
|
24
24
|
var Copy = require('@bigbinary/neeto-icons/Copy');
|
|
25
25
|
var Dropdown = require('@bigbinary/neetoui/Dropdown');
|
|
26
26
|
var Button = require('@bigbinary/neetoui/Button');
|
|
27
27
|
var Label = require('@bigbinary/neetoui/Label');
|
|
28
28
|
var Checkbox = require('@bigbinary/neetoui/Checkbox');
|
|
29
29
|
var Switch = require('@bigbinary/neetoui/formik/Switch');
|
|
30
|
-
var _typeof = require('@babel/runtime/helpers/typeof');
|
|
31
30
|
var Plus = require('@bigbinary/neeto-icons/Plus');
|
|
32
|
-
var
|
|
31
|
+
var Close = require('@bigbinary/neeto-icons/Close');
|
|
33
32
|
var Select = require('@bigbinary/neetoui/formik/Select');
|
|
34
33
|
var Profile = require('@bigbinary/neeto-team-members-frontend/Profile');
|
|
35
34
|
var Tooltip = require('@bigbinary/neetoui/Tooltip');
|
|
@@ -71,13 +70,14 @@ var ScheduleContext = /*#__PURE__*/React.createContext({
|
|
|
71
70
|
allowAddPeriod: true,
|
|
72
71
|
firstDay: 0,
|
|
73
72
|
slotInterval: DEFAULT_SLOT_INTERVAL,
|
|
74
|
-
hourFormat: DEFAULT_HOUR_FORMAT
|
|
73
|
+
hourFormat: DEFAULT_HOUR_FORMAT,
|
|
74
|
+
compact: false
|
|
75
75
|
});
|
|
76
76
|
|
|
77
77
|
var INTERVALS = ["year", "quarter", "month", "week", "day", "hour", "minute", "second"];
|
|
78
78
|
|
|
79
|
-
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; }
|
|
80
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), true).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; }
|
|
79
|
+
function ownKeys$1(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; }
|
|
80
|
+
function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$1(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$1(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
81
81
|
var REMOVE_SELECT_DOWN_ARROW = {
|
|
82
82
|
DropdownIndicator: function DropdownIndicator() {
|
|
83
83
|
return null;
|
|
@@ -88,9 +88,14 @@ var REMOVE_SELECT_DOWN_ARROW = {
|
|
|
88
88
|
};
|
|
89
89
|
var BLUR_TEXT_WHEN_SELECT_MENU_IS_OPEN = {
|
|
90
90
|
singleValue: function singleValue(base, state) {
|
|
91
|
-
return _objectSpread(_objectSpread({}, base), {}, {
|
|
91
|
+
return _objectSpread$1(_objectSpread$1({}, base), {}, {
|
|
92
92
|
color: state.selectProps.menuIsOpen ? "#c2c8cc" : base.color
|
|
93
93
|
});
|
|
94
|
+
},
|
|
95
|
+
menu: function menu(base) {
|
|
96
|
+
return _objectSpread$1(_objectSpread$1({}, base), {}, {
|
|
97
|
+
minWidth: "8rem"
|
|
98
|
+
});
|
|
94
99
|
}
|
|
95
100
|
};
|
|
96
101
|
var SLOT_TIME_FORMAT = "hh:mm A";
|
|
@@ -199,10 +204,6 @@ yup__namespace.addMethod(yup__namespace.array, "ensureSlotsCantOverlap", functio
|
|
|
199
204
|
return new yup__namespace.ValidationError([firstError, secondError]);
|
|
200
205
|
});
|
|
201
206
|
});
|
|
202
|
-
var isFromAndToSame = function isFromAndToSame(startTime, endTime) {
|
|
203
|
-
if (!startTime || !endTime) return true;
|
|
204
|
-
return utils.dayjs(startTime, SLOT_TIME_FORMAT_24H).isSame(utils.dayjs(endTime, SLOT_TIME_FORMAT_24H));
|
|
205
|
-
};
|
|
206
207
|
var sortDays = function sortDays(chosenIndex) {
|
|
207
208
|
if (chosenIndex < 0 || chosenIndex >= 7) return DAYS;
|
|
208
209
|
return [].concat(_toConsumableArray(DAYS.slice(chosenIndex)), _toConsumableArray(DAYS.slice(0, chosenIndex)));
|
|
@@ -210,15 +211,12 @@ var sortDays = function sortDays(chosenIndex) {
|
|
|
210
211
|
var wdayValidation = yup__namespace.object().shape({
|
|
211
212
|
periods: yup__namespace.array().of(yup__namespace.object().shape({
|
|
212
213
|
startTime: yup__namespace.string().required(i18next.t("neetoMolecules.schedule.errors.period.startTime")),
|
|
213
|
-
endTime: yup__namespace.string().required(i18next.t("neetoMolecules.schedule.errors.period.endTime"))
|
|
214
|
-
|
|
215
|
-
if (isFromAndToSame(value, startTime)) return true;
|
|
216
|
-
return isTimeBehind(startTime, value);
|
|
217
|
-
})
|
|
218
|
-
}).test("ensureTimeNotSame", i18next.t("neetoMolecules.schedule.errors.period.sameTime"), function (value) {
|
|
214
|
+
endTime: yup__namespace.string().required(i18next.t("neetoMolecules.schedule.errors.period.endTime"))
|
|
215
|
+
}).test("ensureEndAfterStart", i18next.t("neetoMolecules.schedule.errors.period.isBehind"), function (value) {
|
|
219
216
|
var startTime = value.startTime,
|
|
220
217
|
endTime = value.endTime;
|
|
221
|
-
|
|
218
|
+
if (!startTime || !endTime) return true;
|
|
219
|
+
return isTimeBehind(startTime, endTime);
|
|
222
220
|
})).ensureSlotsCantOverlap()
|
|
223
221
|
});
|
|
224
222
|
var getScheduleValidationSchema = function getScheduleValidationSchema() {
|
|
@@ -384,17 +382,93 @@ var DisplayAvailability = function DisplayAvailability(_ref) {
|
|
|
384
382
|
t = _useTranslation.t;
|
|
385
383
|
var _useContext = React.useContext(ScheduleContext),
|
|
386
384
|
firstDay = _useContext.firstDay,
|
|
387
|
-
hourFormat = _useContext.hourFormat
|
|
385
|
+
hourFormat = _useContext.hourFormat,
|
|
386
|
+
compact = _useContext.compact;
|
|
388
387
|
var formatHour = function formatHour(hour) {
|
|
389
388
|
if (hourFormat === HOUR_FORMATS.H24) {
|
|
390
389
|
return hour;
|
|
391
390
|
}
|
|
392
391
|
return convert24hTo12h(hour);
|
|
393
392
|
};
|
|
393
|
+
var dayLabel = function dayLabel(day) {
|
|
394
|
+
return t("neetoMolecules.schedule.days.".concat(day));
|
|
395
|
+
};
|
|
396
|
+
var timeRangesForDay = function timeRangesForDay(day) {
|
|
397
|
+
var _sortPeriodsByKey;
|
|
398
|
+
if (!neetoCist.isPresent(periods[day])) return null;
|
|
399
|
+
return (_sortPeriodsByKey = sortPeriodsByKey({
|
|
400
|
+
periods: periods[day],
|
|
401
|
+
key: "startTime",
|
|
402
|
+
order: "asc"
|
|
403
|
+
})) === null || _sortPeriodsByKey === void 0 ? void 0 : _sortPeriodsByKey.map(function (period) {
|
|
404
|
+
return "".concat(formatHour(period.startTime), " - ").concat(formatHour(period.endTime));
|
|
405
|
+
});
|
|
406
|
+
};
|
|
407
|
+
if (compact) {
|
|
408
|
+
var groups = sortDays(firstDay).reduce(function (acc, day) {
|
|
409
|
+
var ranges = timeRangesForDay(day);
|
|
410
|
+
var signature = ranges === null ? null : ranges.join("|");
|
|
411
|
+
var lastGroup = acc[acc.length - 1];
|
|
412
|
+
if (lastGroup && lastGroup.signature === signature) {
|
|
413
|
+
lastGroup.endDay = day;
|
|
414
|
+
} else {
|
|
415
|
+
acc.push({
|
|
416
|
+
startDay: day,
|
|
417
|
+
endDay: day,
|
|
418
|
+
signature: signature,
|
|
419
|
+
ranges: ranges
|
|
420
|
+
});
|
|
421
|
+
}
|
|
422
|
+
return acc;
|
|
423
|
+
}, []);
|
|
424
|
+
var visibleGroups = groups.filter(function (group) {
|
|
425
|
+
return group.ranges !== null;
|
|
426
|
+
});
|
|
427
|
+
if (neetoCist.isNotPresent(visibleGroups)) {
|
|
428
|
+
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
429
|
+
className: "px-4 py-3 md:px-6",
|
|
430
|
+
children: /*#__PURE__*/jsxRuntime.jsx(Typography, {
|
|
431
|
+
className: "neeto-ui-text-gray-500",
|
|
432
|
+
style: "body2",
|
|
433
|
+
children: t("neetoMolecules.schedule.unavailable")
|
|
434
|
+
})
|
|
435
|
+
});
|
|
436
|
+
}
|
|
437
|
+
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
438
|
+
className: "flex w-full flex-col",
|
|
439
|
+
children: visibleGroups.map(function (group) {
|
|
440
|
+
var dayRange = group.startDay === group.endDay ? dayLabel(group.startDay) : t("neetoMolecules.schedule.dayRange", {
|
|
441
|
+
startDay: dayLabel(group.startDay),
|
|
442
|
+
endDay: dayLabel(group.endDay)
|
|
443
|
+
});
|
|
444
|
+
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
445
|
+
className: "neeto-ui-border-gray-200 flex w-full items-start gap-6 border-b px-4 py-3 last:border-b-0 md:px-6",
|
|
446
|
+
"data-testid": "day-cards-".concat(group.startDay),
|
|
447
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Typography, {
|
|
448
|
+
className: "w-44 flex-shrink-0 text-end whitespace-nowrap",
|
|
449
|
+
"data-testid": general.joinHyphenCase(group.startDay, "day-text"),
|
|
450
|
+
style: "body2",
|
|
451
|
+
weight: "semibold",
|
|
452
|
+
children: dayRange
|
|
453
|
+
}), /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
454
|
+
className: "flex flex-col gap-0.5",
|
|
455
|
+
children: group.ranges.map(function (range, index) {
|
|
456
|
+
return /*#__PURE__*/jsxRuntime.jsx(Typography, {
|
|
457
|
+
className: "neeto-ui-text-gray-700",
|
|
458
|
+
style: "body2",
|
|
459
|
+
"data-testid": "".concat(general.joinHyphenCase(group.startDay, "time-range"), "-").concat(index),
|
|
460
|
+
children: range
|
|
461
|
+
}, index);
|
|
462
|
+
})
|
|
463
|
+
})]
|
|
464
|
+
}, group.startDay);
|
|
465
|
+
})
|
|
466
|
+
});
|
|
467
|
+
}
|
|
394
468
|
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
395
469
|
className: "flex w-full flex-col gap-y-3",
|
|
396
470
|
children: sortDays(firstDay).map(function (day) {
|
|
397
|
-
var
|
|
471
|
+
var _sortPeriodsByKey2;
|
|
398
472
|
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
399
473
|
className: "neeto-ui-rounded-md neeto-ui-border-gray-300 neeto-ui-bg-white flex w-full flex-wrap items-center justify-center gap-2 border px-6 py-4 sm:items-start sm:justify-start",
|
|
400
474
|
"data-testid": "day-cards-".concat(day),
|
|
@@ -406,11 +480,11 @@ var DisplayAvailability = function DisplayAvailability(_ref) {
|
|
|
406
480
|
children: t("neetoMolecules.schedule.days.".concat(day))
|
|
407
481
|
}), /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
408
482
|
className: "flex flex-grow flex-col items-center gap-y-4 sm:w-1/2",
|
|
409
|
-
children: neetoCist.isPresent(periods[day]) ? (
|
|
483
|
+
children: neetoCist.isPresent(periods[day]) ? (_sortPeriodsByKey2 = sortPeriodsByKey({
|
|
410
484
|
periods: periods[day],
|
|
411
485
|
key: "startTime",
|
|
412
486
|
order: "asc"
|
|
413
|
-
})) === null ||
|
|
487
|
+
})) === null || _sortPeriodsByKey2 === void 0 ? void 0 : _sortPeriodsByKey2.map(function (period) {
|
|
414
488
|
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
415
489
|
className: "flex items-center gap-x-4",
|
|
416
490
|
children: [/*#__PURE__*/jsxRuntime.jsx(Typography, {
|
|
@@ -561,16 +635,21 @@ var addDefaultPeriod = function addDefaultPeriod(wday) {
|
|
|
561
635
|
};
|
|
562
636
|
};
|
|
563
637
|
|
|
638
|
+
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; }
|
|
639
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), true).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; }
|
|
564
640
|
var ScheduleRow$1 = function ScheduleRow(_ref) {
|
|
565
641
|
var day = _ref.day;
|
|
566
642
|
var _useFormikContext = formik.useFormikContext(),
|
|
567
643
|
values = _useFormikContext.values,
|
|
568
|
-
setFieldValue = _useFormikContext.setFieldValue
|
|
644
|
+
setFieldValue = _useFormikContext.setFieldValue,
|
|
645
|
+
errors = _useFormikContext.errors,
|
|
646
|
+
touched = _useFormikContext.touched;
|
|
569
647
|
var bookedSlots = values.wdays[day].periods;
|
|
570
648
|
var _useContext = React.useContext(ScheduleContext),
|
|
571
649
|
allowAddPeriod = _useContext.allowAddPeriod,
|
|
572
650
|
slotInterval = _useContext.slotInterval,
|
|
573
|
-
hourFormat = _useContext.hourFormat
|
|
651
|
+
hourFormat = _useContext.hourFormat,
|
|
652
|
+
compact = _useContext.compact;
|
|
574
653
|
var _useTranslation = reactI18next.useTranslation(),
|
|
575
654
|
t = _useTranslation.t;
|
|
576
655
|
var sortSlotsInterval = React.useMemo(function () {
|
|
@@ -603,84 +682,129 @@ var ScheduleRow$1 = function ScheduleRow(_ref) {
|
|
|
603
682
|
arrayHelpers.remove(index);
|
|
604
683
|
setFieldValue("wdays.".concat(day, ".available"), !isLastRowDeleted);
|
|
605
684
|
};
|
|
685
|
+
var renderTimeSelect = function renderTimeSelect(_ref2) {
|
|
686
|
+
var index = _ref2.index,
|
|
687
|
+
period = _ref2.period,
|
|
688
|
+
field = _ref2.field,
|
|
689
|
+
options = _ref2.options,
|
|
690
|
+
hasError = _ref2.hasError;
|
|
691
|
+
return /*#__PURE__*/jsxRuntime.jsx(Select, _objectSpread(_objectSpread({}, _objectSpread({
|
|
692
|
+
formatCreateLabel: formatCreateLabel
|
|
693
|
+
}, hasError && {
|
|
694
|
+
error: true
|
|
695
|
+
})), {}, {
|
|
696
|
+
isCreateable: true,
|
|
697
|
+
isSearchable: true,
|
|
698
|
+
className: classnames({
|
|
699
|
+
"w-full": !compact
|
|
700
|
+
}),
|
|
701
|
+
components: REMOVE_SELECT_DOWN_ARROW,
|
|
702
|
+
filterOption: filterSlots,
|
|
703
|
+
isClearable: false,
|
|
704
|
+
isValidNewOption: isValidTimeSlotOption,
|
|
705
|
+
name: "wdays.".concat(day, ".periods[").concat(index, "].").concat(field),
|
|
706
|
+
options: options(period),
|
|
707
|
+
placeholder: t("neetoMolecules.schedule.".concat(field)),
|
|
708
|
+
strategy: "fixed",
|
|
709
|
+
styles: BLUR_TEXT_WHEN_SELECT_MENU_IS_OPEN,
|
|
710
|
+
value: neetoCist.findBy({
|
|
711
|
+
value: period === null || period === void 0 ? void 0 : period[field]
|
|
712
|
+
}, options(period)),
|
|
713
|
+
onChange: function onChange(e) {
|
|
714
|
+
return handleChange(index, field, e);
|
|
715
|
+
}
|
|
716
|
+
}));
|
|
717
|
+
};
|
|
718
|
+
var renderField = function renderField(_ref3) {
|
|
719
|
+
var index = _ref3.index,
|
|
720
|
+
period = _ref3.period,
|
|
721
|
+
field = _ref3.field,
|
|
722
|
+
options = _ref3.options,
|
|
723
|
+
hasError = _ref3.hasError;
|
|
724
|
+
return compact ? /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
725
|
+
className: "w-24 flex-shrink-0",
|
|
726
|
+
children: renderTimeSelect({
|
|
727
|
+
index: index,
|
|
728
|
+
period: period,
|
|
729
|
+
field: field,
|
|
730
|
+
options: options,
|
|
731
|
+
hasError: hasError
|
|
732
|
+
})
|
|
733
|
+
}) : renderTimeSelect({
|
|
734
|
+
index: index,
|
|
735
|
+
period: period,
|
|
736
|
+
field: field,
|
|
737
|
+
options: options,
|
|
738
|
+
hasError: hasError
|
|
739
|
+
});
|
|
740
|
+
};
|
|
606
741
|
return /*#__PURE__*/jsxRuntime.jsx(formik.FieldArray, {
|
|
607
742
|
name: "wdays.".concat(day, ".periods"),
|
|
608
743
|
render: function render(arrayHelpers) {
|
|
609
744
|
var _values$wdays$day, _values$wdays$day$per;
|
|
610
745
|
return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
611
746
|
children: [neetoCist.isPresent((_values$wdays$day = values.wdays[day]) === null || _values$wdays$day === void 0 ? void 0 : _values$wdays$day.periods) && /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
612
|
-
className: "flex w-full flex-col gap-y-2",
|
|
747
|
+
className: classnames("flex w-full flex-col gap-y-2", {
|
|
748
|
+
"@xl:w-auto": compact
|
|
749
|
+
}),
|
|
613
750
|
children: (_values$wdays$day$per = values.wdays[day].periods) === null || _values$wdays$day$per === void 0 ? void 0 : _values$wdays$day$per.map(function (period, index) {
|
|
751
|
+
var _errors$wdays, _touched$wdays;
|
|
752
|
+
var periodError = errors === null || errors === void 0 || (_errors$wdays = errors.wdays) === null || _errors$wdays === void 0 || (_errors$wdays = _errors$wdays[day]) === null || _errors$wdays === void 0 || (_errors$wdays = _errors$wdays.periods) === null || _errors$wdays === void 0 ? void 0 : _errors$wdays[index];
|
|
753
|
+
var periodTouched = touched === null || touched === void 0 || (_touched$wdays = touched.wdays) === null || _touched$wdays === void 0 || (_touched$wdays = _touched$wdays[day]) === null || _touched$wdays === void 0 || (_touched$wdays = _touched$wdays.periods) === null || _touched$wdays === void 0 ? void 0 : _touched$wdays[index];
|
|
754
|
+
var hasError = typeof periodError === "string" && ((periodTouched === null || periodTouched === void 0 ? void 0 : periodTouched.startTime) || (periodTouched === null || periodTouched === void 0 ? void 0 : periodTouched.endTime));
|
|
614
755
|
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
615
|
-
className: "flex w-full flex-col
|
|
756
|
+
className: classnames("flex w-full flex-col", {
|
|
757
|
+
"@xl:mx-auto @xl:w-80": !compact,
|
|
758
|
+
"@xl:w-auto": compact
|
|
759
|
+
}),
|
|
616
760
|
children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
617
|
-
className: "flex items-start gap-2 @xl:gap-3",
|
|
618
761
|
"data-testid": "schedule-row",
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
}), /*#__PURE__*/jsxRuntime.jsx(Select, {
|
|
640
|
-
formatCreateLabel: formatCreateLabel,
|
|
641
|
-
isClearable: true,
|
|
642
|
-
isCreateable: true,
|
|
643
|
-
isSearchable: true,
|
|
644
|
-
className: "w-full",
|
|
645
|
-
components: REMOVE_SELECT_DOWN_ARROW,
|
|
646
|
-
filterOption: filterSlots,
|
|
647
|
-
isValidNewOption: isValidTimeSlotOption,
|
|
648
|
-
name: "wdays.".concat(day, ".periods[").concat(index, "].endTime"),
|
|
649
|
-
options: endTimeOptions(period),
|
|
650
|
-
placeholder: t("neetoMolecules.schedule.endTime"),
|
|
651
|
-
strategy: "fixed",
|
|
652
|
-
styles: BLUR_TEXT_WHEN_SELECT_MENU_IS_OPEN,
|
|
653
|
-
value: neetoCist.findBy({
|
|
654
|
-
value: period === null || period === void 0 ? void 0 : period.endTime
|
|
655
|
-
}, endTimeOptions(period)),
|
|
656
|
-
onChange: function onChange(e) {
|
|
657
|
-
return handleChange(index, "endTime", e);
|
|
658
|
-
}
|
|
762
|
+
className: classnames("flex gap-2 @xl:gap-3", {
|
|
763
|
+
"items-start": !compact,
|
|
764
|
+
"items-center": compact
|
|
765
|
+
}),
|
|
766
|
+
children: [renderField({
|
|
767
|
+
index: index,
|
|
768
|
+
period: period,
|
|
769
|
+
hasError: hasError,
|
|
770
|
+
field: "startTime",
|
|
771
|
+
options: startTimeOptions
|
|
772
|
+
}), compact && /*#__PURE__*/jsxRuntime.jsx(Typography, {
|
|
773
|
+
className: "neeto-ui-text-gray-600 flex-shrink-0 select-none",
|
|
774
|
+
component: "span",
|
|
775
|
+
children: "-"
|
|
776
|
+
}), renderField({
|
|
777
|
+
index: index,
|
|
778
|
+
period: period,
|
|
779
|
+
hasError: hasError,
|
|
780
|
+
field: "endTime",
|
|
781
|
+
options: endTimeOptions
|
|
659
782
|
}), /*#__PURE__*/jsxRuntime.jsx(Button, {
|
|
660
|
-
|
|
783
|
+
"aria-label": t("neetoMolecules.schedule.deletePeriod"),
|
|
661
784
|
"data-testid": "delete-period-button",
|
|
662
|
-
icon:
|
|
785
|
+
icon: Close,
|
|
663
786
|
style: "text",
|
|
787
|
+
className: classnames("flex-shrink-0", {
|
|
788
|
+
"self-start": !compact
|
|
789
|
+
}),
|
|
664
790
|
onClick: function onClick() {
|
|
665
791
|
return handleDeleteRow(arrayHelpers, index);
|
|
666
792
|
}
|
|
667
793
|
})]
|
|
668
|
-
}), /*#__PURE__*/jsxRuntime.jsx(
|
|
669
|
-
|
|
670
|
-
children:
|
|
671
|
-
return _typeof(message) !== "object" && /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
672
|
-
className: "neeto-ui-text-error-500 mt-1 w-11/12 px-2 text-xs",
|
|
673
|
-
children: message
|
|
674
|
-
});
|
|
675
|
-
}
|
|
794
|
+
}), hasError && /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
795
|
+
className: "neeto-ui-text-error-500 mt-1 text-xs",
|
|
796
|
+
children: periodError
|
|
676
797
|
})]
|
|
677
798
|
}, "wdays.".concat(day, ".periods[").concat(index, "]"));
|
|
678
799
|
})
|
|
679
800
|
}), values.wdays[day].available && allowAddPeriod && /*#__PURE__*/jsxRuntime.jsx(Button, {
|
|
680
|
-
className: "absolute end-14 top-3 ms-auto flex-shrink-0 @xl:static",
|
|
681
801
|
"data-testid": "add-new-period-button",
|
|
682
802
|
icon: Plus,
|
|
683
803
|
style: "secondary",
|
|
804
|
+
className: classnames("absolute end-14 top-3 flex-shrink-0 @xl:static", {
|
|
805
|
+
"ms-auto": !compact,
|
|
806
|
+
"@xl:ms-auto": compact
|
|
807
|
+
}),
|
|
684
808
|
tooltipProps: {
|
|
685
809
|
content: t("neetoMolecules.schedule.addNewPeriod"),
|
|
686
810
|
position: "top",
|
|
@@ -714,7 +838,8 @@ var Form$1 = function Form(_ref) {
|
|
|
714
838
|
var _useTranslation = reactI18next.useTranslation(),
|
|
715
839
|
t = _useTranslation.t;
|
|
716
840
|
var _useContext = React.useContext(ScheduleContext),
|
|
717
|
-
firstDay = _useContext.firstDay
|
|
841
|
+
firstDay = _useContext.firstDay,
|
|
842
|
+
compact = _useContext.compact;
|
|
718
843
|
var restoreDeletedPeriods = function restoreDeletedPeriods() {
|
|
719
844
|
setFieldValue("wdays.".concat(day, ".periods"), deletedPeriods);
|
|
720
845
|
};
|
|
@@ -750,13 +875,20 @@ var Form$1 = function Form(_ref) {
|
|
|
750
875
|
return setWdaysToCopy(e.target.checked ? ramda.append(day) : ramda.without([day]));
|
|
751
876
|
};
|
|
752
877
|
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
753
|
-
className: "neeto-ui-
|
|
878
|
+
className: classnames("neeto-ui-bg-white @container relative w-full px-4 md:px-6", {
|
|
879
|
+
"neeto-ui-rounded-md neeto-ui-border-gray-300 mb-3 border last:mb-0": !compact,
|
|
880
|
+
"neeto-ui-border-gray-200 border-b last:border-b-0": compact
|
|
881
|
+
}),
|
|
754
882
|
children: /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
755
|
-
className: "@xl:flex-no-wrap my-4 flex w-full flex-wrap items-start gap-2 @xl:flex-nowrap @xl:gap-4" // Added `@xl:flex-no-wrap` since neetoCal is using old version of tailwind
|
|
756
|
-
,
|
|
757
883
|
"data-testid": "working-day-container",
|
|
884
|
+
className: classnames("@xl:flex-no-wrap flex w-full flex-wrap gap-2 @xl:flex-nowrap @xl:gap-4", {
|
|
885
|
+
"my-4 items-start": !compact,
|
|
886
|
+
"my-3 items-start @xl:min-h-8": compact
|
|
887
|
+
}),
|
|
758
888
|
children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
759
|
-
className: classnames("flex w-36 flex-shrink-0 items-center justify-start
|
|
889
|
+
className: classnames("flex w-36 flex-shrink-0 items-center justify-start", {
|
|
890
|
+
"@xl:mt-1": !compact,
|
|
891
|
+
"@xl:min-h-8": compact,
|
|
760
892
|
"mb-3 @xl:mb-0": neetoCist.isPresent((_values$wdays$day = values.wdays[day]) === null || _values$wdays$day === void 0 ? void 0 : _values$wdays$day.periods)
|
|
761
893
|
}),
|
|
762
894
|
children: [/*#__PURE__*/jsxRuntime.jsx(Switch, {
|
|
@@ -771,14 +903,22 @@ var Form$1 = function Form(_ref) {
|
|
|
771
903
|
component: "span",
|
|
772
904
|
"data-testid": general.joinHyphenCase(day, "day-text"),
|
|
773
905
|
style: "body2",
|
|
774
|
-
weight: values.wdays[day].available ? "semibold" : "normal",
|
|
775
906
|
className: classnames("ms-2 capitalize", {
|
|
776
907
|
"neeto-ui-text-gray-600": !values.wdays[day].available
|
|
777
908
|
}),
|
|
909
|
+
weight: compact || values.wdays[day].available ? "semibold" : "normal",
|
|
778
910
|
children: t("neetoMolecules.schedule.days.".concat(day))
|
|
779
911
|
})]
|
|
780
912
|
}), /*#__PURE__*/jsxRuntime.jsx(ScheduleRow, {
|
|
781
913
|
day: day
|
|
914
|
+
}), !values.wdays[day].available && /*#__PURE__*/jsxRuntime.jsx(Typography, {
|
|
915
|
+
component: "span",
|
|
916
|
+
"data-testid": general.joinHyphenCase(day, "unavailable-time-text"),
|
|
917
|
+
style: "body2",
|
|
918
|
+
className: classnames("neeto-ui-text-gray-500", {
|
|
919
|
+
"@xl:leading-8": compact
|
|
920
|
+
}),
|
|
921
|
+
children: t("neetoMolecules.schedule.unavailable")
|
|
782
922
|
}), values.wdays[day].available && /*#__PURE__*/jsxRuntime.jsxs(Dropdown, {
|
|
783
923
|
closeOnSelect: true,
|
|
784
924
|
buttonStyle: "secondary",
|
|
@@ -886,6 +1026,8 @@ var Header = function Header(_ref) {
|
|
|
886
1026
|
isSubmitting = _useFormikContext.isSubmitting;
|
|
887
1027
|
var _useTranslation = reactI18next.useTranslation(),
|
|
888
1028
|
t = _useTranslation.t;
|
|
1029
|
+
var _useContext = React.useContext(ScheduleContext),
|
|
1030
|
+
compact = _useContext.compact;
|
|
889
1031
|
var _useState = React.useState(getTimeZoneAndTime()),
|
|
890
1032
|
_useState2 = _slicedToArray(_useState, 2),
|
|
891
1033
|
timeZoneAndTime = _useState2[0],
|
|
@@ -906,7 +1048,10 @@ var Header = function Header(_ref) {
|
|
|
906
1048
|
};
|
|
907
1049
|
}, []);
|
|
908
1050
|
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
909
|
-
className: "
|
|
1051
|
+
className: classnames("flex flex-wrap justify-between gap-2", {
|
|
1052
|
+
"mb-6": !compact,
|
|
1053
|
+
"neeto-ui-bg-gray-100 neeto-ui-border-gray-200 items-center border-t px-4 py-3 md:px-6": compact
|
|
1054
|
+
}),
|
|
910
1055
|
children: [showTimeZone && /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
911
1056
|
className: "flex items-center gap-3",
|
|
912
1057
|
"data-testid": "schedule-timezone-header",
|
|
@@ -936,8 +1081,10 @@ var Header = function Header(_ref) {
|
|
|
936
1081
|
}]
|
|
937
1082
|
})]
|
|
938
1083
|
}), isEditing ? /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
939
|
-
className: "flex items-center gap-2",
|
|
940
|
-
|
|
1084
|
+
className: classnames("flex items-center gap-2", {
|
|
1085
|
+
"flex-row-reverse": compact
|
|
1086
|
+
}),
|
|
1087
|
+
children: [(!compact || dirty) && /*#__PURE__*/jsxRuntime.jsx(Button, {
|
|
941
1088
|
"data-testid": "reset-button",
|
|
942
1089
|
style: "secondary",
|
|
943
1090
|
label: !dirty ? t("neetoMolecules.common.actions.cancel") : t("neetoMolecules.common.actions.reset"),
|
|
@@ -990,7 +1137,9 @@ var Schedule = /*#__PURE__*/React.forwardRef(function (_ref, scheduleRef) {
|
|
|
990
1137
|
_ref$slotInterval = _ref.slotInterval,
|
|
991
1138
|
slotInterval = _ref$slotInterval === void 0 ? DEFAULT_SLOT_INTERVAL : _ref$slotInterval,
|
|
992
1139
|
_ref$hourFormat = _ref.hourFormat,
|
|
993
|
-
hourFormat = _ref$hourFormat === void 0 ? DEFAULT_HOUR_FORMAT : _ref$hourFormat
|
|
1140
|
+
hourFormat = _ref$hourFormat === void 0 ? DEFAULT_HOUR_FORMAT : _ref$hourFormat,
|
|
1141
|
+
_ref$compact = _ref.compact,
|
|
1142
|
+
compact = _ref$compact === void 0 ? false : _ref$compact;
|
|
994
1143
|
var validationSchema = React.useMemo(getScheduleValidationSchema, []);
|
|
995
1144
|
var getInitialFormValues = function getInitialFormValues() {
|
|
996
1145
|
var isSubmitHandler = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
@@ -1009,10 +1158,13 @@ var Schedule = /*#__PURE__*/React.forwardRef(function (_ref, scheduleRef) {
|
|
|
1009
1158
|
allowAddPeriod: allowAddPeriod,
|
|
1010
1159
|
firstDay: firstDay,
|
|
1011
1160
|
slotInterval: slotInterval,
|
|
1012
|
-
hourFormat: hourFormat
|
|
1161
|
+
hourFormat: hourFormat,
|
|
1162
|
+
compact: compact
|
|
1013
1163
|
},
|
|
1014
1164
|
children: /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
1015
|
-
className: "neeto-molecules-schedule neeto-ui-border-gray-200 flex-shrink-0",
|
|
1165
|
+
className: classnames("neeto-molecules-schedule neeto-ui-border-gray-200 flex-shrink-0", {
|
|
1166
|
+
"neeto-ui-rounded-md overflow-hidden border": compact
|
|
1167
|
+
}),
|
|
1016
1168
|
children: /*#__PURE__*/jsxRuntime.jsx(formik.Formik, {
|
|
1017
1169
|
validationSchema: validationSchema,
|
|
1018
1170
|
enableReinitialize: true,
|
|
@@ -1023,7 +1175,7 @@ var Schedule = /*#__PURE__*/React.forwardRef(function (_ref, scheduleRef) {
|
|
|
1023
1175
|
handleSubmit(processFormValues(values, firstDay), getInitialFormValues(true));
|
|
1024
1176
|
},
|
|
1025
1177
|
children: /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
1026
|
-
children: [showHeader && /*#__PURE__*/jsxRuntime.jsx(Header, {
|
|
1178
|
+
children: [showHeader && !compact && /*#__PURE__*/jsxRuntime.jsx(Header, {
|
|
1027
1179
|
isCreating: isCreating,
|
|
1028
1180
|
isEditable: isEditable,
|
|
1029
1181
|
isEditing: isEditing,
|
|
@@ -1036,6 +1188,12 @@ var Schedule = /*#__PURE__*/React.forwardRef(function (_ref, scheduleRef) {
|
|
|
1036
1188
|
})
|
|
1037
1189
|
}) : /*#__PURE__*/jsxRuntime.jsx(DisplayAvailability, {
|
|
1038
1190
|
periods: periods
|
|
1191
|
+
}), showHeader && compact && /*#__PURE__*/jsxRuntime.jsx(Header, {
|
|
1192
|
+
isCreating: isCreating,
|
|
1193
|
+
isEditable: isEditable,
|
|
1194
|
+
isEditing: isEditing,
|
|
1195
|
+
setIsEditing: setIsEditing,
|
|
1196
|
+
showTimeZone: showTimeZone
|
|
1039
1197
|
})]
|
|
1040
1198
|
})
|
|
1041
1199
|
})
|