@bigbinary/neeto-molecules 5.9.12 → 5.9.13

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.
@@ -6,8 +6,9 @@ var React = require('react');
6
6
  var formik = require('formik');
7
7
  var neetoCist = require('@bigbinary/neeto-cist');
8
8
  var neetoAtoms = require('@bigbinary/neeto-atoms');
9
- var general = require('@bigbinary/neeto-commons-frontend/utils/general');
10
9
  var reactI18next = require('react-i18next');
10
+ var jsxRuntime = require('react/jsx-runtime');
11
+ var general = require('@bigbinary/neeto-commons-frontend/utils/general');
11
12
  var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
12
13
  var _toConsumableArray = require('@babel/runtime/helpers/toConsumableArray');
13
14
  var neetoTimeZones = require('@bigbinary/neeto-time-zones');
@@ -19,9 +20,8 @@ var yup = require('yup');
19
20
  var _classCallCheck = require('@babel/runtime/helpers/classCallCheck');
20
21
  var _createClass = require('@babel/runtime/helpers/createClass');
21
22
  require('@babel/runtime/helpers/defineProperty');
22
- var jsxRuntime = require('react/jsx-runtime');
23
- var formik$1 = require('@bigbinary/neeto-atoms/formik');
24
23
  var classnames = require('classnames');
24
+ var formik$1 = require('@bigbinary/neeto-atoms/formik');
25
25
  var _typeof = require('@babel/runtime/helpers/typeof');
26
26
  var trash2 = require('../trash-2-Dic3f2Hq.js');
27
27
  var plus = require('../plus-B3N_9NiI.js');
@@ -53,6 +53,50 @@ function _interopNamespaceDefault(e) {
53
53
 
54
54
  var yup__namespace = /*#__PURE__*/_interopNamespaceDefault(yup);
55
55
 
56
+ var Actions = function Actions(_ref) {
57
+ var isCreating = _ref.isCreating,
58
+ isEditable = _ref.isEditable,
59
+ isEditing = _ref.isEditing,
60
+ setIsEditing = _ref.setIsEditing;
61
+ var _useFormikContext = formik.useFormikContext(),
62
+ dirty = _useFormikContext.dirty,
63
+ resetForm = _useFormikContext.resetForm,
64
+ submitForm = _useFormikContext.submitForm,
65
+ isSubmitting = _useFormikContext.isSubmitting;
66
+ var _useTranslation = reactI18next.useTranslation(),
67
+ t = _useTranslation.t;
68
+ var handleReset = function handleReset() {
69
+ if (dirty) resetForm();else setIsEditing(false);
70
+ };
71
+ if (isEditing) {
72
+ return /*#__PURE__*/jsxRuntime.jsxs("div", {
73
+ className: "flex items-center gap-2",
74
+ children: [/*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Button, {
75
+ "data-testid": "reset-button",
76
+ variant: "secondary",
77
+ label: !dirty ? t("neetoMolecules.common.actions.cancel") : t("neetoMolecules.common.actions.reset"),
78
+ onClick: handleReset
79
+ }), /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Button, {
80
+ "data-testid": "weekly-hours-save-changes-button",
81
+ disabled: !dirty && !isCreating || isSubmitting,
82
+ label: t("neetoMolecules.common.actions.saveChanges"),
83
+ loading: isSubmitting,
84
+ onClick: submitForm
85
+ })]
86
+ });
87
+ }
88
+ return isEditable ? /*#__PURE__*/jsxRuntime.jsx("div", {
89
+ children: /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Button, {
90
+ "data-testid": "weekly-schedule-header",
91
+ label: t("neetoMolecules.schedule.changeAvailability"),
92
+ variant: "default",
93
+ onClick: function onClick() {
94
+ return setIsEditing(true);
95
+ }
96
+ })
97
+ }) : null;
98
+ };
99
+
56
100
  var DAYS = ["sunday", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday"];
57
101
  var DEFAULT_SLOT_INTERVAL = 30;
58
102
  var HOUR_FORMATS = {
@@ -727,7 +771,7 @@ var Form$1 = function Form(_ref) {
727
771
  "data-testid": general.joinHyphenCase(day, "weekly-hours-checkbox"),
728
772
  id: "day",
729
773
  name: "wdays.".concat(day, ".available"),
730
- size: "lg",
774
+ size: "default",
731
775
  onCheckedChange: handleCheckbox
732
776
  }), /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Typography, {
733
777
  as: "span",
@@ -831,17 +875,7 @@ var Fields = function Fields(_ref) {
831
875
  };
832
876
 
833
877
  var Header = function Header(_ref) {
834
- var isCreating = _ref.isCreating,
835
- isEditable = _ref.isEditable,
836
- isEditing = _ref.isEditing,
837
- setIsEditing = _ref.setIsEditing,
838
- _ref$showTimeZone = _ref.showTimeZone,
839
- showTimeZone = _ref$showTimeZone === void 0 ? true : _ref$showTimeZone;
840
- var _useFormikContext = formik.useFormikContext(),
841
- dirty = _useFormikContext.dirty,
842
- resetForm = _useFormikContext.resetForm,
843
- submitForm = _useFormikContext.submitForm,
844
- isSubmitting = _useFormikContext.isSubmitting;
878
+ var isEditable = _ref.isEditable;
845
879
  var _useTranslation = reactI18next.useTranslation(),
846
880
  t = _useTranslation.t;
847
881
  var _useState = React.useState(getTimeZoneAndTime()),
@@ -852,9 +886,6 @@ var Header = function Header(_ref) {
852
886
  _Profile$usePaneState2 = _slicedToArray(_Profile$usePaneState, 2);
853
887
  _Profile$usePaneState2[0];
854
888
  var setIsProfilePaneOpen = _Profile$usePaneState2[1];
855
- var handleReset = function handleReset() {
856
- if (dirty) resetForm();else setIsEditing(false);
857
- };
858
889
  React.useEffect(function () {
859
890
  var time = setInterval(function () {
860
891
  setTimeZoneAndTime(getTimeZoneAndTime());
@@ -864,58 +895,32 @@ var Header = function Header(_ref) {
864
895
  };
865
896
  }, []);
866
897
  return /*#__PURE__*/jsxRuntime.jsxs("div", {
867
- className: "mb-6 flex flex-wrap justify-between gap-2",
868
- children: [showTimeZone && /*#__PURE__*/jsxRuntime.jsxs("div", {
869
- className: "flex items-center gap-3",
870
- "data-testid": "schedule-timezone-header",
871
- children: [/*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Tooltip, {
872
- content: t("neetoMolecules.schedule.timezoneTooltip"),
873
- position: "bottom",
874
- touch: ["hold", 500],
875
- children: /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Typography, {
876
- as: "h4",
877
- "data-testid": "timezone-text",
878
- variant: "h6",
879
- weight: "medium",
880
- children: timeZoneAndTime
881
- })
882
- }), isEditable && /*#__PURE__*/jsxRuntime.jsx(v2_MoreDropdown, {
883
- dropdownButtonProps: {
884
- "data-testid": "nui-more-dropdown"
885
- },
886
- menuItems: [{
887
- onClick: function onClick() {
888
- return setIsProfilePaneOpen(true);
889
- },
890
- label: t("neetoMolecules.common.actions.changeTimezone"),
891
- target: "_blank",
892
- key: "change-timezone-option",
893
- "data-testid": "change-timezone-option"
894
- }]
895
- })]
896
- }), isEditing ? /*#__PURE__*/jsxRuntime.jsxs("div", {
897
- className: "flex items-center gap-2",
898
- children: [/*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Button, {
899
- "data-testid": "reset-button",
900
- variant: "secondary",
901
- label: !dirty ? t("neetoMolecules.common.actions.cancel") : t("neetoMolecules.common.actions.reset"),
902
- onClick: handleReset
903
- }), /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Button, {
904
- "data-testid": "weekly-hours-save-changes-button",
905
- disabled: !dirty && !isCreating || isSubmitting,
906
- label: t("neetoMolecules.common.actions.saveChanges"),
907
- loading: isSubmitting,
908
- onClick: submitForm
909
- })]
910
- }) : isEditable && /*#__PURE__*/jsxRuntime.jsx("div", {
911
- children: /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Button, {
912
- "data-testid": "weekly-schedule-header",
913
- label: t("neetoMolecules.schedule.changeAvailability"),
914
- variant: "default",
915
- onClick: function onClick() {
916
- return setIsEditing(true);
917
- }
898
+ className: "mb-6 flex items-center gap-3",
899
+ "data-testid": "schedule-timezone-header",
900
+ children: [/*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Tooltip, {
901
+ content: t("neetoMolecules.schedule.timezoneTooltip"),
902
+ position: "bottom",
903
+ touch: ["hold", 500],
904
+ children: /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Typography, {
905
+ as: "h4",
906
+ "data-testid": "timezone-text",
907
+ variant: "h6",
908
+ weight: "medium",
909
+ children: timeZoneAndTime
918
910
  })
911
+ }), isEditable && /*#__PURE__*/jsxRuntime.jsx(v2_MoreDropdown, {
912
+ dropdownButtonProps: {
913
+ "data-testid": "nui-more-dropdown"
914
+ },
915
+ menuItems: [{
916
+ onClick: function onClick() {
917
+ return setIsProfilePaneOpen(true);
918
+ },
919
+ label: t("neetoMolecules.common.actions.changeTimezone"),
920
+ target: "_blank",
921
+ key: "change-timezone-option",
922
+ "data-testid": "change-timezone-option"
923
+ }]
919
924
  })]
920
925
  });
921
926
  };
@@ -980,12 +985,8 @@ var Schedule = /*#__PURE__*/React.forwardRef(function (_ref, scheduleRef) {
980
985
  handleSubmit(processFormValues(values, firstDay), getInitialFormValues(true));
981
986
  },
982
987
  children: /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
983
- children: [showHeader && /*#__PURE__*/jsxRuntime.jsx(Header, {
984
- isCreating: isCreating,
985
- isEditable: isEditable,
986
- isEditing: isEditing,
987
- setIsEditing: setIsEditing,
988
- showTimeZone: showTimeZone
988
+ children: [showHeader && showTimeZone && /*#__PURE__*/jsxRuntime.jsx(Header, {
989
+ isEditable: isEditable
989
990
  }), isEditing || !showHeader ? /*#__PURE__*/jsxRuntime.jsx(formik.Form, {
990
991
  children: /*#__PURE__*/jsxRuntime.jsx(Fields, {
991
992
  handleValuesChanged: handleValuesChanged,
@@ -993,6 +994,14 @@ var Schedule = /*#__PURE__*/React.forwardRef(function (_ref, scheduleRef) {
993
994
  })
994
995
  }) : /*#__PURE__*/jsxRuntime.jsx(DisplayAvailability, {
995
996
  periods: periods
997
+ }), showHeader && (isEditing || isEditable) && /*#__PURE__*/jsxRuntime.jsx("div", {
998
+ className: "neeto-molecules-schedule__actions border-border bg-card sticky bottom-0 z-10 mt-10 flex justify-end gap-2 border-t py-6",
999
+ children: /*#__PURE__*/jsxRuntime.jsx(Actions, {
1000
+ isCreating: isCreating,
1001
+ isEditable: isEditable,
1002
+ isEditing: isEditing,
1003
+ setIsEditing: setIsEditing
1004
+ })
996
1005
  })]
997
1006
  })
998
1007
  })