@gympass/yoga 7.73.0 → 7.74.0

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.
@@ -62,12 +62,12 @@ var getDayFieldColor = function getDayFieldColor(selected, disabled, colors, aux
62
62
  return colors.stamina;
63
63
  };
64
64
 
65
- var toUTCDate = function toUTCDate(date) {
66
- return new Date(Date.UTC(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate())).getTime();
65
+ var toUTCTime = function toUTCTime(date) {
66
+ return Date.UTC(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate());
67
67
  };
68
68
 
69
69
  var isSameDate = function isSameDate(firstDate, secondDate) {
70
- return firstDate.getDate() === secondDate.getDate() && firstDate.getMonth() === secondDate.getMonth() && firstDate.getFullYear() === secondDate.getFullYear();
70
+ return firstDate.getUTCDate() === secondDate.getUTCDate() && firstDate.getUTCMonth() === secondDate.getUTCMonth() && firstDate.getUTCFullYear() === secondDate.getUTCFullYear();
71
71
  };
72
72
 
73
73
  var getDayFieldRadius = function getDayFieldRadius(aux, radii) {
@@ -80,11 +80,11 @@ var getDayFieldRadius = function getDayFieldRadius(aux, radii) {
80
80
  month = aux.month;
81
81
  var currentDate = (_Date = new Date(Date.UTC(year, month, val))) == null ? void 0 : _Date.getTime();
82
82
 
83
- if (currentDate === toUTCDate(startDate) && endDate) {
83
+ if (currentDate === toUTCTime(startDate) && endDate) {
84
84
  return radii.circle + "px " + radii.sharp + "px " + radii.sharp + "px " + radii.circle + "px";
85
85
  }
86
86
 
87
- if (currentDate === toUTCDate(endDate) && startDate) {
87
+ if (currentDate === toUTCTime(endDate) && startDate) {
88
88
  return radii.sharp + "px " + radii.circle + "px " + radii.circle + "px " + radii.sharp + "px";
89
89
  }
90
90
 
@@ -152,31 +152,31 @@ function Calendar(_ref6) {
152
152
  return new Date(Date.UTC(year, month, 0)).getUTCDate();
153
153
  };
154
154
 
155
- var toUTCDateDay = function toUTCDateDay(day) {
156
- return new Date(Date.UTC(year, month, day)).getTime();
155
+ var toUTCTimeByDay = function toUTCTimeByDay(day) {
156
+ return Date.UTC(year, month, day);
157
157
  };
158
158
 
159
159
  var isEqual = function isEqual(day) {
160
- var utcDate = new Date(Date.UTC(year, month, day));
160
+ var utcDate = new Date(toUTCTimeByDay(day));
161
161
  return startDate && isSameDate(startDate, utcDate) || endDate && isSameDate(endDate, utcDate);
162
162
  };
163
163
 
164
164
  var inRange = function inRange(day) {
165
- return startDate && startDate.getTime() <= toUTCDateDay(day) && endDate && endDate.getTime() >= toUTCDateDay(day);
165
+ return startDate && toUTCTime(startDate) <= toUTCTimeByDay(day) && endDate && endDate.getTime() >= toUTCTimeByDay(day);
166
166
  };
167
167
 
168
168
  var isDisabled = function isDisabled(day) {
169
- var local = new Date(Date.UTC(year, month, day));
169
+ var local = Date.UTC(year, month, day);
170
170
  var now = new Date();
171
171
  var nowUTC = Date.UTC(now.getFullYear(), now.getMonth(), now.getDate());
172
- var pastDatesDisabled = disablePastDates && local.getTime() < nowUTC || disablePastFrom && local.getTime() < new Date(disablePastFrom.getFullYear(), disablePastFrom.getMonth(), disablePastFrom.getDate());
173
- var futureDateDisabled = disableFutureDates && local.getTime() > nowUTC || disableFutureFrom && local.getTime() > new Date(disableFutureFrom.getFullYear(), disableFutureFrom.getMonth(), disableFutureFrom.getDate());
172
+ var pastDatesDisabled = disablePastDates && local < nowUTC || disablePastFrom && local < toUTCTime(disablePastFrom);
173
+ var futureDateDisabled = disableFutureDates && local > nowUTC || disableFutureFrom && local > toUTCTime(disableFutureFrom);
174
174
  return pastDatesDisabled || futureDateDisabled;
175
175
  };
176
176
 
177
177
  var _onClick = function onClick(day) {
178
178
  var selectedDate = new Date(Date.UTC(year, month, day));
179
- if (isDisabled(day) || startDate && selectedDate.getTime() === toUTCDate(startDate)) return;
179
+ if (isDisabled(day)) return;
180
180
 
181
181
  if (type === 'single') {
182
182
  onSelectSingle(selectedDate);
@@ -17,7 +17,7 @@ var _hooks = require("../../hooks");
17
17
 
18
18
  var _ = require("../..");
19
19
 
20
- var _excluded = ["isOpen", "hideCloseButton", "children", "onClose", "zIndex"];
20
+ var _excluded = ["isOpen", "hideCloseButton", "children", "dialogId", "onClose", "zIndex"];
21
21
 
22
22
  var _templateObject, _templateObject2;
23
23
 
@@ -46,16 +46,17 @@ var Overlay = _styledComponents["default"].div(_templateObject2 || (_templateObj
46
46
  return "\n display: flex;\n z-index: " + zIndex + ";\n justify-content: center;\n align-items: center;\n\n position: fixed;\n top: " + dialog.position["default"] + ";\n right: " + dialog.position["default"] + ";\n left: " + dialog.position["default"] + ";\n bottom: " + dialog.position["default"] + ";\n\n background-color: rgba(35, 27, 34, 0.48);\n ";
47
47
  });
48
48
 
49
- function Dialog(_ref3) {
49
+ var Dialog = /*#__PURE__*/_react["default"].forwardRef(function (_ref3, forwardedRef) {
50
50
  var isOpen = _ref3.isOpen,
51
51
  hideCloseButton = _ref3.hideCloseButton,
52
52
  children = _ref3.children,
53
+ dialogId = _ref3.dialogId,
53
54
  onClose = _ref3.onClose,
54
55
  zIndex = _ref3.zIndex,
55
56
  props = _objectWithoutPropertiesLoose(_ref3, _excluded);
56
57
 
57
- var dialogRef = (0, _react.useRef)(null);
58
- var dialogElement = (0, _hooks.usePortal)('dialog');
58
+ var dialogRef = (0, _hooks.useCombinedRefs)(forwardedRef);
59
+ var dialogElement = (0, _hooks.usePortal)(dialogId != null ? dialogId : 'dialog');
59
60
  var isCloseButtonVisible = onClose && !hideCloseButton;
60
61
  var closeDialog = (0, _react.useCallback)(function (e) {
61
62
  if (dialogRef.current === e.target && isOpen && onClose) {
@@ -93,9 +94,12 @@ function Dialog(_ref3) {
93
94
  inverted: true,
94
95
  onClick: onClose
95
96
  })), children)), dialogElement) : /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null);
96
- }
97
+ });
97
98
 
98
99
  Dialog.propTypes = {
100
+ /** Custom id to allow creating isolated portal nodes */
101
+ dialogId: _propTypes.string,
102
+
99
103
  /** Control the dialog visibility. */
100
104
  isOpen: _propTypes.bool,
101
105
 
@@ -111,7 +115,8 @@ Dialog.defaultProps = {
111
115
  isOpen: false,
112
116
  hideCloseButton: false,
113
117
  onClose: undefined,
114
- zIndex: 3
118
+ zIndex: 3,
119
+ dialogId: undefined
115
120
  };
116
121
  Dialog.displayName = 'Dialog';
117
122
  var _default = Dialog;
@@ -43,12 +43,12 @@ var getDayFieldColor = function getDayFieldColor(selected, disabled, colors, aux
43
43
  return colors.stamina;
44
44
  };
45
45
 
46
- var toUTCDate = function toUTCDate(date) {
47
- return new Date(Date.UTC(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate())).getTime();
46
+ var toUTCTime = function toUTCTime(date) {
47
+ return Date.UTC(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate());
48
48
  };
49
49
 
50
50
  var isSameDate = function isSameDate(firstDate, secondDate) {
51
- return firstDate.getDate() === secondDate.getDate() && firstDate.getMonth() === secondDate.getMonth() && firstDate.getFullYear() === secondDate.getFullYear();
51
+ return firstDate.getUTCDate() === secondDate.getUTCDate() && firstDate.getUTCMonth() === secondDate.getUTCMonth() && firstDate.getUTCFullYear() === secondDate.getUTCFullYear();
52
52
  };
53
53
 
54
54
  var getDayFieldRadius = function getDayFieldRadius(aux, radii) {
@@ -61,11 +61,11 @@ var getDayFieldRadius = function getDayFieldRadius(aux, radii) {
61
61
  month = aux.month;
62
62
  var currentDate = (_Date = new Date(Date.UTC(year, month, val))) == null ? void 0 : _Date.getTime();
63
63
 
64
- if (currentDate === toUTCDate(startDate) && endDate) {
64
+ if (currentDate === toUTCTime(startDate) && endDate) {
65
65
  return radii.circle + "px " + radii.sharp + "px " + radii.sharp + "px " + radii.circle + "px";
66
66
  }
67
67
 
68
- if (currentDate === toUTCDate(endDate) && startDate) {
68
+ if (currentDate === toUTCTime(endDate) && startDate) {
69
69
  return radii.sharp + "px " + radii.circle + "px " + radii.circle + "px " + radii.sharp + "px";
70
70
  }
71
71
 
@@ -132,31 +132,31 @@ function Calendar(_ref6) {
132
132
  return new Date(Date.UTC(year, month, 0)).getUTCDate();
133
133
  };
134
134
 
135
- var toUTCDateDay = function toUTCDateDay(day) {
136
- return new Date(Date.UTC(year, month, day)).getTime();
135
+ var toUTCTimeByDay = function toUTCTimeByDay(day) {
136
+ return Date.UTC(year, month, day);
137
137
  };
138
138
 
139
139
  var isEqual = function isEqual(day) {
140
- var utcDate = new Date(Date.UTC(year, month, day));
140
+ var utcDate = new Date(toUTCTimeByDay(day));
141
141
  return startDate && isSameDate(startDate, utcDate) || endDate && isSameDate(endDate, utcDate);
142
142
  };
143
143
 
144
144
  var inRange = function inRange(day) {
145
- return startDate && startDate.getTime() <= toUTCDateDay(day) && endDate && endDate.getTime() >= toUTCDateDay(day);
145
+ return startDate && toUTCTime(startDate) <= toUTCTimeByDay(day) && endDate && endDate.getTime() >= toUTCTimeByDay(day);
146
146
  };
147
147
 
148
148
  var isDisabled = function isDisabled(day) {
149
- var local = new Date(Date.UTC(year, month, day));
149
+ var local = Date.UTC(year, month, day);
150
150
  var now = new Date();
151
151
  var nowUTC = Date.UTC(now.getFullYear(), now.getMonth(), now.getDate());
152
- var pastDatesDisabled = disablePastDates && local.getTime() < nowUTC || disablePastFrom && local.getTime() < new Date(disablePastFrom.getFullYear(), disablePastFrom.getMonth(), disablePastFrom.getDate());
153
- var futureDateDisabled = disableFutureDates && local.getTime() > nowUTC || disableFutureFrom && local.getTime() > new Date(disableFutureFrom.getFullYear(), disableFutureFrom.getMonth(), disableFutureFrom.getDate());
152
+ var pastDatesDisabled = disablePastDates && local < nowUTC || disablePastFrom && local < toUTCTime(disablePastFrom);
153
+ var futureDateDisabled = disableFutureDates && local > nowUTC || disableFutureFrom && local > toUTCTime(disableFutureFrom);
154
154
  return pastDatesDisabled || futureDateDisabled;
155
155
  };
156
156
 
157
157
  var _onClick = function onClick(day) {
158
158
  var selectedDate = new Date(Date.UTC(year, month, day));
159
- if (isDisabled(day) || startDate && selectedDate.getTime() === toUTCDate(startDate)) return;
159
+ if (isDisabled(day)) return;
160
160
 
161
161
  if (type === 'single') {
162
162
  onSelectSingle(selectedDate);
@@ -1,4 +1,4 @@
1
- var _excluded = ["isOpen", "hideCloseButton", "children", "onClose", "zIndex"];
1
+ var _excluded = ["isOpen", "hideCloseButton", "children", "dialogId", "onClose", "zIndex"];
2
2
 
3
3
  var _templateObject, _templateObject2;
4
4
 
@@ -8,12 +8,12 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
8
8
 
9
9
  function _taggedTemplateLiteralLoose(strings, raw) { if (!raw) { raw = strings.slice(0); } strings.raw = raw; return strings; }
10
10
 
11
- import React, { useEffect, useRef, useCallback } from 'react';
11
+ import React, { useEffect, useCallback } from 'react';
12
12
  import { createPortal } from 'react-dom';
13
13
  import styled from 'styled-components';
14
- import { func, bool, node, number } from 'prop-types';
14
+ import { func, bool, node, number, string } from 'prop-types';
15
15
  import { Close } from '@gympass/yoga-icons';
16
- import { usePortal } from '../../hooks';
16
+ import { usePortal, useCombinedRefs } from '../../hooks';
17
17
  import { Button, Card, Box } from '../..';
18
18
  export var StyledDialog = styled(Card)(_templateObject || (_templateObject = _taggedTemplateLiteralLoose(["\n ", "\n display: flex;\n align-items: center;\n flex-direction: column;\n"])), function (_ref) {
19
19
  var onClose = _ref.onClose,
@@ -25,17 +25,17 @@ var Overlay = styled.div(_templateObject2 || (_templateObject2 = _taggedTemplate
25
25
  dialog = _ref2.theme.yoga.components.dialog;
26
26
  return "\n display: flex;\n z-index: " + zIndex + ";\n justify-content: center;\n align-items: center;\n\n position: fixed;\n top: " + dialog.position["default"] + ";\n right: " + dialog.position["default"] + ";\n left: " + dialog.position["default"] + ";\n bottom: " + dialog.position["default"] + ";\n\n background-color: rgba(35, 27, 34, 0.48);\n ";
27
27
  });
28
-
29
- function Dialog(_ref3) {
28
+ var Dialog = /*#__PURE__*/React.forwardRef(function (_ref3, forwardedRef) {
30
29
  var isOpen = _ref3.isOpen,
31
30
  hideCloseButton = _ref3.hideCloseButton,
32
31
  children = _ref3.children,
32
+ dialogId = _ref3.dialogId,
33
33
  onClose = _ref3.onClose,
34
34
  zIndex = _ref3.zIndex,
35
35
  props = _objectWithoutPropertiesLoose(_ref3, _excluded);
36
36
 
37
- var dialogRef = useRef(null);
38
- var dialogElement = usePortal('dialog');
37
+ var dialogRef = useCombinedRefs(forwardedRef);
38
+ var dialogElement = usePortal(dialogId != null ? dialogId : 'dialog');
39
39
  var isCloseButtonVisible = onClose && !hideCloseButton;
40
40
  var closeDialog = useCallback(function (e) {
41
41
  if (dialogRef.current === e.target && isOpen && onClose) {
@@ -73,9 +73,11 @@ function Dialog(_ref3) {
73
73
  inverted: true,
74
74
  onClick: onClose
75
75
  })), children)), dialogElement) : /*#__PURE__*/React.createElement(React.Fragment, null);
76
- }
77
-
76
+ });
78
77
  Dialog.propTypes = {
78
+ /** Custom id to allow creating isolated portal nodes */
79
+ dialogId: string,
80
+
79
81
  /** Control the dialog visibility. */
80
82
  isOpen: bool,
81
83
 
@@ -91,7 +93,8 @@ Dialog.defaultProps = {
91
93
  isOpen: false,
92
94
  hideCloseButton: false,
93
95
  onClose: undefined,
94
- zIndex: 3
96
+ zIndex: 3,
97
+ dialogId: undefined
95
98
  };
96
99
  Dialog.displayName = 'Dialog';
97
100
  export default Dialog;
@@ -59,4 +59,14 @@ describe('<Dialog />', function () {
59
59
  }, /*#__PURE__*/React.createElement(Dialog.Header, null, "Title"))));
60
60
  expect(screen.queryByRole('button')).toBeNull();
61
61
  });
62
+ it('should render content isolated by dialog id', function () {
63
+ render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Dialog, {
64
+ isOpen: true
65
+ }, /*#__PURE__*/React.createElement(Dialog.Header, null, "Title")), /*#__PURE__*/React.createElement(Dialog, {
66
+ isOpen: true,
67
+ dialogId: "custom-id"
68
+ }, /*#__PURE__*/React.createElement(Dialog.Header, null, "Second Title"))));
69
+ expect(screen.getByText('Title')).toBeInTheDocument();
70
+ expect(screen.getByText('Second Title')).toBeInTheDocument();
71
+ });
62
72
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gympass/yoga",
3
- "version": "7.73.0",
3
+ "version": "7.74.0",
4
4
  "description": "Gympass component library",
5
5
  "main": "./cjs",
6
6
  "sideEffects": false,
@@ -53,7 +53,7 @@
53
53
  "react": ">=16",
54
54
  "styled-components": "^4.4.0"
55
55
  },
56
- "gitHead": "1e683b25901f777084721ebe795c1ebd5e560ff2",
56
+ "gitHead": "21322a4a3a083f86796151e7687dd2b257fe445e",
57
57
  "module": "./esm",
58
58
  "private": false,
59
59
  "react-native": "./cjs/index.native.js"