@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 CHANGED
@@ -1,5 +1,6 @@
1
1
  import { createContext, useContext, memo, useMemo, useState, useEffect, useImperativeHandle, forwardRef } from 'react';
2
- import { useFormikContext, FieldArray, ErrorMessage, Formik, Form as Form$2 } from 'formik';
2
+ import classnames from 'classnames';
3
+ import { useFormikContext, FieldArray, Formik, Form as Form$2 } from 'formik';
3
4
  import { findIndexBy, isNotPresent, isPresent, toLabelAndValue, isNotEmpty, findBy, noop } from '@bigbinary/neeto-cist';
4
5
  import { joinHyphenCase } from '@bigbinary/neeto-commons-frontend/utils/general';
5
6
  import Typography from '@bigbinary/neetoui/Typography';
@@ -10,22 +11,20 @@ import { ianaTimezoneToHumanReadable } from '@bigbinary/neeto-time-zones';
10
11
  import i18next from 'i18next';
11
12
  import { dayjs } from '@bigbinary/neeto-commons-frontend/utils';
12
13
  import { timeFormat } from '@bigbinary/neeto-commons-frontend/utils/datetime';
13
- import { fromPairs, map, prop, pick, assoc, identity, uniq, pluck, difference, append, without } from 'ramda';
14
+ import { fromPairs, map, prop, pick, assoc, uniq, pluck, difference, identity, append, without } from 'ramda';
14
15
  import * as yup from 'yup';
15
16
  import _classCallCheck from '@babel/runtime/helpers/classCallCheck';
16
17
  import _createClass from '@babel/runtime/helpers/createClass';
17
18
  import _defineProperty from '@babel/runtime/helpers/defineProperty';
18
19
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
19
- import classnames from 'classnames';
20
20
  import Copy from '@bigbinary/neeto-icons/Copy';
21
21
  import Dropdown from '@bigbinary/neetoui/Dropdown';
22
22
  import Button from '@bigbinary/neetoui/Button';
23
23
  import Label from '@bigbinary/neetoui/Label';
24
24
  import Checkbox from '@bigbinary/neetoui/Checkbox';
25
25
  import Switch from '@bigbinary/neetoui/formik/Switch';
26
- import _typeof from '@babel/runtime/helpers/typeof';
27
26
  import Plus from '@bigbinary/neeto-icons/Plus';
28
- import Delete from '@bigbinary/neeto-icons/Delete';
27
+ import Close from '@bigbinary/neeto-icons/Close';
29
28
  import Select from '@bigbinary/neetoui/formik/Select';
30
29
  import Profile from '@bigbinary/neeto-team-members-frontend/Profile';
31
30
  import Tooltip from '@bigbinary/neetoui/Tooltip';
@@ -48,13 +47,14 @@ var ScheduleContext = /*#__PURE__*/createContext({
48
47
  allowAddPeriod: true,
49
48
  firstDay: 0,
50
49
  slotInterval: DEFAULT_SLOT_INTERVAL,
51
- hourFormat: DEFAULT_HOUR_FORMAT
50
+ hourFormat: DEFAULT_HOUR_FORMAT,
51
+ compact: false
52
52
  });
53
53
 
54
54
  var INTERVALS = ["year", "quarter", "month", "week", "day", "hour", "minute", "second"];
55
55
 
56
- 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; }
57
- 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; }
56
+ 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; }
57
+ 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; }
58
58
  var REMOVE_SELECT_DOWN_ARROW = {
59
59
  DropdownIndicator: function DropdownIndicator() {
60
60
  return null;
@@ -65,9 +65,14 @@ var REMOVE_SELECT_DOWN_ARROW = {
65
65
  };
66
66
  var BLUR_TEXT_WHEN_SELECT_MENU_IS_OPEN = {
67
67
  singleValue: function singleValue(base, state) {
68
- return _objectSpread(_objectSpread({}, base), {}, {
68
+ return _objectSpread$1(_objectSpread$1({}, base), {}, {
69
69
  color: state.selectProps.menuIsOpen ? "#c2c8cc" : base.color
70
70
  });
71
+ },
72
+ menu: function menu(base) {
73
+ return _objectSpread$1(_objectSpread$1({}, base), {}, {
74
+ minWidth: "8rem"
75
+ });
71
76
  }
72
77
  };
73
78
  var SLOT_TIME_FORMAT = "hh:mm A";
@@ -176,10 +181,6 @@ yup.addMethod(yup.array, "ensureSlotsCantOverlap", function () {
176
181
  return new yup.ValidationError([firstError, secondError]);
177
182
  });
178
183
  });
179
- var isFromAndToSame = function isFromAndToSame(startTime, endTime) {
180
- if (!startTime || !endTime) return true;
181
- return dayjs(startTime, SLOT_TIME_FORMAT_24H).isSame(dayjs(endTime, SLOT_TIME_FORMAT_24H));
182
- };
183
184
  var sortDays = function sortDays(chosenIndex) {
184
185
  if (chosenIndex < 0 || chosenIndex >= 7) return DAYS;
185
186
  return [].concat(_toConsumableArray(DAYS.slice(chosenIndex)), _toConsumableArray(DAYS.slice(0, chosenIndex)));
@@ -187,15 +188,12 @@ var sortDays = function sortDays(chosenIndex) {
187
188
  var wdayValidation = yup.object().shape({
188
189
  periods: yup.array().of(yup.object().shape({
189
190
  startTime: yup.string().required(i18next.t("neetoMolecules.schedule.errors.period.startTime")),
190
- endTime: yup.string().required(i18next.t("neetoMolecules.schedule.errors.period.endTime")).test("ensureToTimeNotBehindFromTime", i18next.t("neetoMolecules.schedule.errors.period.isBehind"), function (value) {
191
- var startTime = this.parent.startTime;
192
- if (isFromAndToSame(value, startTime)) return true;
193
- return isTimeBehind(startTime, value);
194
- })
195
- }).test("ensureTimeNotSame", i18next.t("neetoMolecules.schedule.errors.period.sameTime"), function (value) {
191
+ endTime: yup.string().required(i18next.t("neetoMolecules.schedule.errors.period.endTime"))
192
+ }).test("ensureEndAfterStart", i18next.t("neetoMolecules.schedule.errors.period.isBehind"), function (value) {
196
193
  var startTime = value.startTime,
197
194
  endTime = value.endTime;
198
- return !isFromAndToSame(startTime, endTime);
195
+ if (!startTime || !endTime) return true;
196
+ return isTimeBehind(startTime, endTime);
199
197
  })).ensureSlotsCantOverlap()
200
198
  });
201
199
  var getScheduleValidationSchema = function getScheduleValidationSchema() {
@@ -361,17 +359,93 @@ var DisplayAvailability = function DisplayAvailability(_ref) {
361
359
  t = _useTranslation.t;
362
360
  var _useContext = useContext(ScheduleContext),
363
361
  firstDay = _useContext.firstDay,
364
- hourFormat = _useContext.hourFormat;
362
+ hourFormat = _useContext.hourFormat,
363
+ compact = _useContext.compact;
365
364
  var formatHour = function formatHour(hour) {
366
365
  if (hourFormat === HOUR_FORMATS.H24) {
367
366
  return hour;
368
367
  }
369
368
  return convert24hTo12h(hour);
370
369
  };
370
+ var dayLabel = function dayLabel(day) {
371
+ return t("neetoMolecules.schedule.days.".concat(day));
372
+ };
373
+ var timeRangesForDay = function timeRangesForDay(day) {
374
+ var _sortPeriodsByKey;
375
+ if (!isPresent(periods[day])) return null;
376
+ return (_sortPeriodsByKey = sortPeriodsByKey({
377
+ periods: periods[day],
378
+ key: "startTime",
379
+ order: "asc"
380
+ })) === null || _sortPeriodsByKey === void 0 ? void 0 : _sortPeriodsByKey.map(function (period) {
381
+ return "".concat(formatHour(period.startTime), " - ").concat(formatHour(period.endTime));
382
+ });
383
+ };
384
+ if (compact) {
385
+ var groups = sortDays(firstDay).reduce(function (acc, day) {
386
+ var ranges = timeRangesForDay(day);
387
+ var signature = ranges === null ? null : ranges.join("|");
388
+ var lastGroup = acc[acc.length - 1];
389
+ if (lastGroup && lastGroup.signature === signature) {
390
+ lastGroup.endDay = day;
391
+ } else {
392
+ acc.push({
393
+ startDay: day,
394
+ endDay: day,
395
+ signature: signature,
396
+ ranges: ranges
397
+ });
398
+ }
399
+ return acc;
400
+ }, []);
401
+ var visibleGroups = groups.filter(function (group) {
402
+ return group.ranges !== null;
403
+ });
404
+ if (isNotPresent(visibleGroups)) {
405
+ return /*#__PURE__*/jsx("div", {
406
+ className: "px-4 py-3 md:px-6",
407
+ children: /*#__PURE__*/jsx(Typography, {
408
+ className: "neeto-ui-text-gray-500",
409
+ style: "body2",
410
+ children: t("neetoMolecules.schedule.unavailable")
411
+ })
412
+ });
413
+ }
414
+ return /*#__PURE__*/jsx("div", {
415
+ className: "flex w-full flex-col",
416
+ children: visibleGroups.map(function (group) {
417
+ var dayRange = group.startDay === group.endDay ? dayLabel(group.startDay) : t("neetoMolecules.schedule.dayRange", {
418
+ startDay: dayLabel(group.startDay),
419
+ endDay: dayLabel(group.endDay)
420
+ });
421
+ return /*#__PURE__*/jsxs("div", {
422
+ 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",
423
+ "data-testid": "day-cards-".concat(group.startDay),
424
+ children: [/*#__PURE__*/jsx(Typography, {
425
+ className: "w-44 flex-shrink-0 text-end whitespace-nowrap",
426
+ "data-testid": joinHyphenCase(group.startDay, "day-text"),
427
+ style: "body2",
428
+ weight: "semibold",
429
+ children: dayRange
430
+ }), /*#__PURE__*/jsx("div", {
431
+ className: "flex flex-col gap-0.5",
432
+ children: group.ranges.map(function (range, index) {
433
+ return /*#__PURE__*/jsx(Typography, {
434
+ className: "neeto-ui-text-gray-700",
435
+ style: "body2",
436
+ "data-testid": "".concat(joinHyphenCase(group.startDay, "time-range"), "-").concat(index),
437
+ children: range
438
+ }, index);
439
+ })
440
+ })]
441
+ }, group.startDay);
442
+ })
443
+ });
444
+ }
371
445
  return /*#__PURE__*/jsx("div", {
372
446
  className: "flex w-full flex-col gap-y-3",
373
447
  children: sortDays(firstDay).map(function (day) {
374
- var _sortPeriodsByKey;
448
+ var _sortPeriodsByKey2;
375
449
  return /*#__PURE__*/jsxs("div", {
376
450
  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",
377
451
  "data-testid": "day-cards-".concat(day),
@@ -383,11 +457,11 @@ var DisplayAvailability = function DisplayAvailability(_ref) {
383
457
  children: t("neetoMolecules.schedule.days.".concat(day))
384
458
  }), /*#__PURE__*/jsx("div", {
385
459
  className: "flex flex-grow flex-col items-center gap-y-4 sm:w-1/2",
386
- children: isPresent(periods[day]) ? (_sortPeriodsByKey = sortPeriodsByKey({
460
+ children: isPresent(periods[day]) ? (_sortPeriodsByKey2 = sortPeriodsByKey({
387
461
  periods: periods[day],
388
462
  key: "startTime",
389
463
  order: "asc"
390
- })) === null || _sortPeriodsByKey === void 0 ? void 0 : _sortPeriodsByKey.map(function (period) {
464
+ })) === null || _sortPeriodsByKey2 === void 0 ? void 0 : _sortPeriodsByKey2.map(function (period) {
391
465
  return /*#__PURE__*/jsxs("div", {
392
466
  className: "flex items-center gap-x-4",
393
467
  children: [/*#__PURE__*/jsx(Typography, {
@@ -538,16 +612,21 @@ var addDefaultPeriod = function addDefaultPeriod(wday) {
538
612
  };
539
613
  };
540
614
 
615
+ 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; }
616
+ 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; }
541
617
  var ScheduleRow = function ScheduleRow(_ref) {
542
618
  var day = _ref.day;
543
619
  var _useFormikContext = useFormikContext(),
544
620
  values = _useFormikContext.values,
545
- setFieldValue = _useFormikContext.setFieldValue;
621
+ setFieldValue = _useFormikContext.setFieldValue,
622
+ errors = _useFormikContext.errors,
623
+ touched = _useFormikContext.touched;
546
624
  var bookedSlots = values.wdays[day].periods;
547
625
  var _useContext = useContext(ScheduleContext),
548
626
  allowAddPeriod = _useContext.allowAddPeriod,
549
627
  slotInterval = _useContext.slotInterval,
550
- hourFormat = _useContext.hourFormat;
628
+ hourFormat = _useContext.hourFormat,
629
+ compact = _useContext.compact;
551
630
  var _useTranslation = useTranslation(),
552
631
  t = _useTranslation.t;
553
632
  var sortSlotsInterval = useMemo(function () {
@@ -580,84 +659,129 @@ var ScheduleRow = function ScheduleRow(_ref) {
580
659
  arrayHelpers.remove(index);
581
660
  setFieldValue("wdays.".concat(day, ".available"), !isLastRowDeleted);
582
661
  };
662
+ var renderTimeSelect = function renderTimeSelect(_ref2) {
663
+ var index = _ref2.index,
664
+ period = _ref2.period,
665
+ field = _ref2.field,
666
+ options = _ref2.options,
667
+ hasError = _ref2.hasError;
668
+ return /*#__PURE__*/jsx(Select, _objectSpread(_objectSpread({}, _objectSpread({
669
+ formatCreateLabel: formatCreateLabel
670
+ }, hasError && {
671
+ error: true
672
+ })), {}, {
673
+ isCreateable: true,
674
+ isSearchable: true,
675
+ className: classnames({
676
+ "w-full": !compact
677
+ }),
678
+ components: REMOVE_SELECT_DOWN_ARROW,
679
+ filterOption: filterSlots,
680
+ isClearable: false,
681
+ isValidNewOption: isValidTimeSlotOption,
682
+ name: "wdays.".concat(day, ".periods[").concat(index, "].").concat(field),
683
+ options: options(period),
684
+ placeholder: t("neetoMolecules.schedule.".concat(field)),
685
+ strategy: "fixed",
686
+ styles: BLUR_TEXT_WHEN_SELECT_MENU_IS_OPEN,
687
+ value: findBy({
688
+ value: period === null || period === void 0 ? void 0 : period[field]
689
+ }, options(period)),
690
+ onChange: function onChange(e) {
691
+ return handleChange(index, field, e);
692
+ }
693
+ }));
694
+ };
695
+ var renderField = function renderField(_ref3) {
696
+ var index = _ref3.index,
697
+ period = _ref3.period,
698
+ field = _ref3.field,
699
+ options = _ref3.options,
700
+ hasError = _ref3.hasError;
701
+ return compact ? /*#__PURE__*/jsx("div", {
702
+ className: "w-24 flex-shrink-0",
703
+ children: renderTimeSelect({
704
+ index: index,
705
+ period: period,
706
+ field: field,
707
+ options: options,
708
+ hasError: hasError
709
+ })
710
+ }) : renderTimeSelect({
711
+ index: index,
712
+ period: period,
713
+ field: field,
714
+ options: options,
715
+ hasError: hasError
716
+ });
717
+ };
583
718
  return /*#__PURE__*/jsx(FieldArray, {
584
719
  name: "wdays.".concat(day, ".periods"),
585
720
  render: function render(arrayHelpers) {
586
721
  var _values$wdays$day, _values$wdays$day$per;
587
722
  return /*#__PURE__*/jsxs(Fragment, {
588
723
  children: [isPresent((_values$wdays$day = values.wdays[day]) === null || _values$wdays$day === void 0 ? void 0 : _values$wdays$day.periods) && /*#__PURE__*/jsx("div", {
589
- className: "flex w-full flex-col gap-y-2",
724
+ className: classnames("flex w-full flex-col gap-y-2", {
725
+ "@xl:w-auto": compact
726
+ }),
590
727
  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) {
728
+ var _errors$wdays, _touched$wdays;
729
+ 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];
730
+ 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];
731
+ var hasError = typeof periodError === "string" && ((periodTouched === null || periodTouched === void 0 ? void 0 : periodTouched.startTime) || (periodTouched === null || periodTouched === void 0 ? void 0 : periodTouched.endTime));
591
732
  return /*#__PURE__*/jsxs("div", {
592
- className: "flex w-full flex-col @xl:mx-auto @xl:w-80",
733
+ className: classnames("flex w-full flex-col", {
734
+ "@xl:mx-auto @xl:w-80": !compact,
735
+ "@xl:w-auto": compact
736
+ }),
593
737
  children: [/*#__PURE__*/jsxs("div", {
594
- className: "flex items-start gap-2 @xl:gap-3",
595
738
  "data-testid": "schedule-row",
596
- children: [/*#__PURE__*/jsx(Select, {
597
- formatCreateLabel: formatCreateLabel,
598
- isClearable: true,
599
- isCreateable: true,
600
- isSearchable: true,
601
- className: "w-full",
602
- components: REMOVE_SELECT_DOWN_ARROW,
603
- filterOption: filterSlots,
604
- isValidNewOption: isValidTimeSlotOption,
605
- name: "wdays.".concat(day, ".periods[").concat(index, "].startTime"),
606
- options: startTimeOptions(period),
607
- placeholder: t("neetoMolecules.schedule.startTime"),
608
- strategy: "fixed",
609
- styles: BLUR_TEXT_WHEN_SELECT_MENU_IS_OPEN,
610
- value: findBy({
611
- value: period === null || period === void 0 ? void 0 : period.startTime
612
- }, startTimeOptions(period)),
613
- onChange: function onChange(e) {
614
- return handleChange(index, "startTime", e);
615
- }
616
- }), /*#__PURE__*/jsx(Select, {
617
- formatCreateLabel: formatCreateLabel,
618
- isClearable: true,
619
- isCreateable: true,
620
- isSearchable: true,
621
- className: "w-full",
622
- components: REMOVE_SELECT_DOWN_ARROW,
623
- filterOption: filterSlots,
624
- isValidNewOption: isValidTimeSlotOption,
625
- name: "wdays.".concat(day, ".periods[").concat(index, "].endTime"),
626
- options: endTimeOptions(period),
627
- placeholder: t("neetoMolecules.schedule.endTime"),
628
- strategy: "fixed",
629
- styles: BLUR_TEXT_WHEN_SELECT_MENU_IS_OPEN,
630
- value: findBy({
631
- value: period === null || period === void 0 ? void 0 : period.endTime
632
- }, endTimeOptions(period)),
633
- onChange: function onChange(e) {
634
- return handleChange(index, "endTime", e);
635
- }
739
+ className: classnames("flex gap-2 @xl:gap-3", {
740
+ "items-start": !compact,
741
+ "items-center": compact
742
+ }),
743
+ children: [renderField({
744
+ index: index,
745
+ period: period,
746
+ hasError: hasError,
747
+ field: "startTime",
748
+ options: startTimeOptions
749
+ }), compact && /*#__PURE__*/jsx(Typography, {
750
+ className: "neeto-ui-text-gray-600 flex-shrink-0 select-none",
751
+ component: "span",
752
+ children: "-"
753
+ }), renderField({
754
+ index: index,
755
+ period: period,
756
+ hasError: hasError,
757
+ field: "endTime",
758
+ options: endTimeOptions
636
759
  }), /*#__PURE__*/jsx(Button, {
637
- className: "flex-shrink-0 self-start",
760
+ "aria-label": t("neetoMolecules.schedule.deletePeriod"),
638
761
  "data-testid": "delete-period-button",
639
- icon: Delete,
762
+ icon: Close,
640
763
  style: "text",
764
+ className: classnames("flex-shrink-0", {
765
+ "self-start": !compact
766
+ }),
641
767
  onClick: function onClick() {
642
768
  return handleDeleteRow(arrayHelpers, index);
643
769
  }
644
770
  })]
645
- }), /*#__PURE__*/jsx(ErrorMessage, {
646
- name: "wdays.".concat(day, ".periods[").concat(index, "]"),
647
- children: function children(message) {
648
- return _typeof(message) !== "object" && /*#__PURE__*/jsx("span", {
649
- className: "neeto-ui-text-error-500 mt-1 w-11/12 px-2 text-xs",
650
- children: message
651
- });
652
- }
771
+ }), hasError && /*#__PURE__*/jsx("span", {
772
+ className: "neeto-ui-text-error-500 mt-1 text-xs",
773
+ children: periodError
653
774
  })]
654
775
  }, "wdays.".concat(day, ".periods[").concat(index, "]"));
655
776
  })
656
777
  }), values.wdays[day].available && allowAddPeriod && /*#__PURE__*/jsx(Button, {
657
- className: "absolute end-14 top-3 ms-auto flex-shrink-0 @xl:static",
658
778
  "data-testid": "add-new-period-button",
659
779
  icon: Plus,
660
780
  style: "secondary",
781
+ className: classnames("absolute end-14 top-3 flex-shrink-0 @xl:static", {
782
+ "ms-auto": !compact,
783
+ "@xl:ms-auto": compact
784
+ }),
661
785
  tooltipProps: {
662
786
  content: t("neetoMolecules.schedule.addNewPeriod"),
663
787
  position: "top",
@@ -691,7 +815,8 @@ var Form = function Form(_ref) {
691
815
  var _useTranslation = useTranslation(),
692
816
  t = _useTranslation.t;
693
817
  var _useContext = useContext(ScheduleContext),
694
- firstDay = _useContext.firstDay;
818
+ firstDay = _useContext.firstDay,
819
+ compact = _useContext.compact;
695
820
  var restoreDeletedPeriods = function restoreDeletedPeriods() {
696
821
  setFieldValue("wdays.".concat(day, ".periods"), deletedPeriods);
697
822
  };
@@ -727,13 +852,20 @@ var Form = function Form(_ref) {
727
852
  return setWdaysToCopy(e.target.checked ? append(day) : without([day]));
728
853
  };
729
854
  return /*#__PURE__*/jsx("div", {
730
- className: "neeto-ui-rounded-md neeto-ui-border-gray-300 neeto-ui-bg-white relative mb-3 w-full border px-4 @container last:mb-0 md:px-6",
855
+ className: classnames("neeto-ui-bg-white @container relative w-full px-4 md:px-6", {
856
+ "neeto-ui-rounded-md neeto-ui-border-gray-300 mb-3 border last:mb-0": !compact,
857
+ "neeto-ui-border-gray-200 border-b last:border-b-0": compact
858
+ }),
731
859
  children: /*#__PURE__*/jsxs("div", {
732
- 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
733
- ,
734
860
  "data-testid": "working-day-container",
861
+ className: classnames("@xl:flex-no-wrap flex w-full flex-wrap gap-2 @xl:flex-nowrap @xl:gap-4", {
862
+ "my-4 items-start": !compact,
863
+ "my-3 items-start @xl:min-h-8": compact
864
+ }),
735
865
  children: [/*#__PURE__*/jsxs("div", {
736
- className: classnames("flex w-36 flex-shrink-0 items-center justify-start @xl:mt-1", {
866
+ className: classnames("flex w-36 flex-shrink-0 items-center justify-start", {
867
+ "@xl:mt-1": !compact,
868
+ "@xl:min-h-8": compact,
737
869
  "mb-3 @xl:mb-0": isPresent((_values$wdays$day = values.wdays[day]) === null || _values$wdays$day === void 0 ? void 0 : _values$wdays$day.periods)
738
870
  }),
739
871
  children: [/*#__PURE__*/jsx(Switch, {
@@ -748,14 +880,22 @@ var Form = function Form(_ref) {
748
880
  component: "span",
749
881
  "data-testid": joinHyphenCase(day, "day-text"),
750
882
  style: "body2",
751
- weight: values.wdays[day].available ? "semibold" : "normal",
752
883
  className: classnames("ms-2 capitalize", {
753
884
  "neeto-ui-text-gray-600": !values.wdays[day].available
754
885
  }),
886
+ weight: compact || values.wdays[day].available ? "semibold" : "normal",
755
887
  children: t("neetoMolecules.schedule.days.".concat(day))
756
888
  })]
757
889
  }), /*#__PURE__*/jsx(ScheduleRow$1, {
758
890
  day: day
891
+ }), !values.wdays[day].available && /*#__PURE__*/jsx(Typography, {
892
+ component: "span",
893
+ "data-testid": joinHyphenCase(day, "unavailable-time-text"),
894
+ style: "body2",
895
+ className: classnames("neeto-ui-text-gray-500", {
896
+ "@xl:leading-8": compact
897
+ }),
898
+ children: t("neetoMolecules.schedule.unavailable")
759
899
  }), values.wdays[day].available && /*#__PURE__*/jsxs(Dropdown, {
760
900
  closeOnSelect: true,
761
901
  buttonStyle: "secondary",
@@ -863,6 +1003,8 @@ var Header = function Header(_ref) {
863
1003
  isSubmitting = _useFormikContext.isSubmitting;
864
1004
  var _useTranslation = useTranslation(),
865
1005
  t = _useTranslation.t;
1006
+ var _useContext = useContext(ScheduleContext),
1007
+ compact = _useContext.compact;
866
1008
  var _useState = useState(getTimeZoneAndTime()),
867
1009
  _useState2 = _slicedToArray(_useState, 2),
868
1010
  timeZoneAndTime = _useState2[0],
@@ -883,7 +1025,10 @@ var Header = function Header(_ref) {
883
1025
  };
884
1026
  }, []);
885
1027
  return /*#__PURE__*/jsxs("div", {
886
- className: "mb-6 flex flex-wrap justify-between gap-2",
1028
+ className: classnames("flex flex-wrap justify-between gap-2", {
1029
+ "mb-6": !compact,
1030
+ "neeto-ui-bg-gray-100 neeto-ui-border-gray-200 items-center border-t px-4 py-3 md:px-6": compact
1031
+ }),
887
1032
  children: [showTimeZone && /*#__PURE__*/jsxs("div", {
888
1033
  className: "flex items-center gap-3",
889
1034
  "data-testid": "schedule-timezone-header",
@@ -913,8 +1058,10 @@ var Header = function Header(_ref) {
913
1058
  }]
914
1059
  })]
915
1060
  }), isEditing ? /*#__PURE__*/jsxs("div", {
916
- className: "flex items-center gap-2",
917
- children: [/*#__PURE__*/jsx(Button, {
1061
+ className: classnames("flex items-center gap-2", {
1062
+ "flex-row-reverse": compact
1063
+ }),
1064
+ children: [(!compact || dirty) && /*#__PURE__*/jsx(Button, {
918
1065
  "data-testid": "reset-button",
919
1066
  style: "secondary",
920
1067
  label: !dirty ? t("neetoMolecules.common.actions.cancel") : t("neetoMolecules.common.actions.reset"),
@@ -967,7 +1114,9 @@ var Schedule = /*#__PURE__*/forwardRef(function (_ref, scheduleRef) {
967
1114
  _ref$slotInterval = _ref.slotInterval,
968
1115
  slotInterval = _ref$slotInterval === void 0 ? DEFAULT_SLOT_INTERVAL : _ref$slotInterval,
969
1116
  _ref$hourFormat = _ref.hourFormat,
970
- hourFormat = _ref$hourFormat === void 0 ? DEFAULT_HOUR_FORMAT : _ref$hourFormat;
1117
+ hourFormat = _ref$hourFormat === void 0 ? DEFAULT_HOUR_FORMAT : _ref$hourFormat,
1118
+ _ref$compact = _ref.compact,
1119
+ compact = _ref$compact === void 0 ? false : _ref$compact;
971
1120
  var validationSchema = useMemo(getScheduleValidationSchema, []);
972
1121
  var getInitialFormValues = function getInitialFormValues() {
973
1122
  var isSubmitHandler = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
@@ -986,10 +1135,13 @@ var Schedule = /*#__PURE__*/forwardRef(function (_ref, scheduleRef) {
986
1135
  allowAddPeriod: allowAddPeriod,
987
1136
  firstDay: firstDay,
988
1137
  slotInterval: slotInterval,
989
- hourFormat: hourFormat
1138
+ hourFormat: hourFormat,
1139
+ compact: compact
990
1140
  },
991
1141
  children: /*#__PURE__*/jsx("div", {
992
- className: "neeto-molecules-schedule neeto-ui-border-gray-200 flex-shrink-0",
1142
+ className: classnames("neeto-molecules-schedule neeto-ui-border-gray-200 flex-shrink-0", {
1143
+ "neeto-ui-rounded-md overflow-hidden border": compact
1144
+ }),
993
1145
  children: /*#__PURE__*/jsx(Formik, {
994
1146
  validationSchema: validationSchema,
995
1147
  enableReinitialize: true,
@@ -1000,7 +1152,7 @@ var Schedule = /*#__PURE__*/forwardRef(function (_ref, scheduleRef) {
1000
1152
  handleSubmit(processFormValues(values, firstDay), getInitialFormValues(true));
1001
1153
  },
1002
1154
  children: /*#__PURE__*/jsxs(Fragment, {
1003
- children: [showHeader && /*#__PURE__*/jsx(Header, {
1155
+ children: [showHeader && !compact && /*#__PURE__*/jsx(Header, {
1004
1156
  isCreating: isCreating,
1005
1157
  isEditable: isEditable,
1006
1158
  isEditing: isEditing,
@@ -1013,6 +1165,12 @@ var Schedule = /*#__PURE__*/forwardRef(function (_ref, scheduleRef) {
1013
1165
  })
1014
1166
  }) : /*#__PURE__*/jsx(DisplayAvailability, {
1015
1167
  periods: periods
1168
+ }), showHeader && compact && /*#__PURE__*/jsx(Header, {
1169
+ isCreating: isCreating,
1170
+ isEditable: isEditable,
1171
+ isEditing: isEditing,
1172
+ setIsEditing: setIsEditing,
1173
+ showTimeZone: showTimeZone
1016
1174
  })]
1017
1175
  })
1018
1176
  })