@gympass/yoga 7.72.0 → 7.72.2

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.
@@ -66,6 +66,10 @@ var toUTCDate = function toUTCDate(date) {
66
66
  return new Date(Date.UTC(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate())).getTime();
67
67
  };
68
68
 
69
+ var isSameDate = function isSameDate(firstDate, secondDate) {
70
+ return firstDate.getDate() === secondDate.getDate() && firstDate.getMonth() === secondDate.getMonth() && firstDate.getFullYear() === secondDate.getFullYear();
71
+ };
72
+
69
73
  var getDayFieldRadius = function getDayFieldRadius(aux, radii) {
70
74
  var _Date;
71
75
 
@@ -153,19 +157,20 @@ function Calendar(_ref6) {
153
157
  };
154
158
 
155
159
  var isEqual = function isEqual(day) {
156
- return startDate && toUTCDate(startDate) === toUTCDateDay(day) || endDate && toUTCDate(endDate) === toUTCDateDay(day);
160
+ var utcDate = new Date(Date.UTC(year, month, day));
161
+ return startDate && isSameDate(startDate, utcDate) || endDate && isSameDate(endDate, utcDate);
157
162
  };
158
163
 
159
164
  var inRange = function inRange(day) {
160
- return startDate && toUTCDate(startDate) <= toUTCDateDay(day) && endDate && toUTCDate(endDate) >= toUTCDateDay(day);
165
+ return startDate && startDate.getTime() <= toUTCDateDay(day) && endDate && endDate.getTime() >= toUTCDateDay(day);
161
166
  };
162
167
 
163
168
  var isDisabled = function isDisabled(day) {
164
169
  var local = new Date(Date.UTC(year, month, day));
165
170
  var now = new Date();
166
171
  var nowUTC = Date.UTC(now.getFullYear(), now.getMonth(), now.getDate());
167
- var pastDatesDisabled = disablePastDates && local.getTime() < nowUTC || disablePastFrom && local.getTime() < new Date(Date.UTC(disablePastFrom.getFullYear(), disablePastFrom.getMonth(), disablePastFrom.getDate()));
168
- var futureDateDisabled = disableFutureDates && local.getTime() > nowUTC || disableFutureFrom && local.getTime() > new Date(Date.UTC(disableFutureFrom.getFullYear(), disableFutureFrom.getMonth(), disableFutureFrom.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());
169
174
  return pastDatesDisabled || futureDateDisabled;
170
175
  };
171
176
 
@@ -3,7 +3,7 @@
3
3
  exports.__esModule = true;
4
4
  exports["default"] = void 0;
5
5
 
6
- var _react = _interopRequireDefault(require("react"));
6
+ var _react = _interopRequireWildcard(require("react"));
7
7
 
8
8
  var _styledComponents = _interopRequireWildcard(require("styled-components"));
9
9
 
@@ -22,12 +22,12 @@ var _excluded = ["isOpen", "selected"],
22
22
 
23
23
  var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12;
24
24
 
25
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
26
+
25
27
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
26
28
 
27
29
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
28
30
 
29
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
30
-
31
31
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
32
32
 
33
33
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
@@ -103,15 +103,8 @@ var ArrowIcon = (0, _styledComponents["default"])(function (_ref8) {
103
103
  dropdown = _ref9.theme.yoga.components.dropdown;
104
104
  return "\n fill: " + dropdown.arrow.fill + ";\n " + (disabled ? "fill: " + dropdown.disabled.arrow.fill + ";" : '') + ";\n " + (selected && !disabled ? "fill: " + dropdown.selected.arrow.fill + ";" : '') + ";\n transform: rotate(" + (isOpen ? '180deg' : '0') + ");\n ";
105
105
  });
106
-
107
- var getSelectedOption = function getSelectedOption(options) {
108
- return options.find(function (item) {
109
- return item.selected === true;
110
- });
111
- };
112
106
  /** Gympass Dropdown is a multiple choice type of menu. */
113
107
 
114
-
115
108
  var Dropdown = /*#__PURE__*/_react["default"].forwardRef(function (_ref10, ref) {
116
109
  var error = _ref10.error,
117
110
  label = _ref10.label,
@@ -123,15 +116,31 @@ var Dropdown = /*#__PURE__*/_react["default"].forwardRef(function (_ref10, ref)
123
116
 
124
117
  var inputRef = ref || _react["default"].useRef(null);
125
118
 
119
+ var selectedOption = options.find(function (item) {
120
+ return item.selected === true;
121
+ });
122
+
123
+ var _useState = (0, _react.useState)(selectedOption),
124
+ localSelectedItem = _useState[0],
125
+ setLocalSelectedItem = _useState[1];
126
+
127
+ (0, _react.useEffect)(function () {
128
+ setLocalSelectedItem(selectedOption);
129
+ }, [options]);
130
+ var onLocalChange = (0, _react.useCallback)(function (opt) {
131
+ setLocalSelectedItem(opt);
132
+ onChange(opt);
133
+ }, [onChange]);
126
134
  return /*#__PURE__*/_react["default"].createElement(_downshift["default"], {
127
- initialSelectedItem: getSelectedOption(options),
135
+ initialSelectedItem: selectedOption,
128
136
  selectedItemChanged: function selectedItemChanged(prevItem, item) {
129
137
  return prevItem !== item;
130
138
  },
131
139
  itemToString: function itemToString(item) {
132
140
  return item ? item.label : '';
133
141
  },
134
- onChange: onChange
142
+ onChange: onLocalChange,
143
+ selectedItem: localSelectedItem
135
144
  }, function (_ref11) {
136
145
  var getInputProps = _ref11.getInputProps,
137
146
  getItemProps = _ref11.getItemProps,
@@ -47,6 +47,10 @@ var toUTCDate = function toUTCDate(date) {
47
47
  return new Date(Date.UTC(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate())).getTime();
48
48
  };
49
49
 
50
+ var isSameDate = function isSameDate(firstDate, secondDate) {
51
+ return firstDate.getDate() === secondDate.getDate() && firstDate.getMonth() === secondDate.getMonth() && firstDate.getFullYear() === secondDate.getFullYear();
52
+ };
53
+
50
54
  var getDayFieldRadius = function getDayFieldRadius(aux, radii) {
51
55
  var _Date;
52
56
 
@@ -133,19 +137,20 @@ function Calendar(_ref6) {
133
137
  };
134
138
 
135
139
  var isEqual = function isEqual(day) {
136
- return startDate && toUTCDate(startDate) === toUTCDateDay(day) || endDate && toUTCDate(endDate) === toUTCDateDay(day);
140
+ var utcDate = new Date(Date.UTC(year, month, day));
141
+ return startDate && isSameDate(startDate, utcDate) || endDate && isSameDate(endDate, utcDate);
137
142
  };
138
143
 
139
144
  var inRange = function inRange(day) {
140
- return startDate && toUTCDate(startDate) <= toUTCDateDay(day) && endDate && toUTCDate(endDate) >= toUTCDateDay(day);
145
+ return startDate && startDate.getTime() <= toUTCDateDay(day) && endDate && endDate.getTime() >= toUTCDateDay(day);
141
146
  };
142
147
 
143
148
  var isDisabled = function isDisabled(day) {
144
149
  var local = new Date(Date.UTC(year, month, day));
145
150
  var now = new Date();
146
151
  var nowUTC = Date.UTC(now.getFullYear(), now.getMonth(), now.getDate());
147
- var pastDatesDisabled = disablePastDates && local.getTime() < nowUTC || disablePastFrom && local.getTime() < new Date(Date.UTC(disablePastFrom.getFullYear(), disablePastFrom.getMonth(), disablePastFrom.getDate()));
148
- var futureDateDisabled = disableFutureDates && local.getTime() > nowUTC || disableFutureFrom && local.getTime() > new Date(Date.UTC(disableFutureFrom.getFullYear(), disableFutureFrom.getMonth(), disableFutureFrom.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());
149
154
  return pastDatesDisabled || futureDateDisabled;
150
155
  };
151
156
 
@@ -9,7 +9,7 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
9
9
 
10
10
  function _taggedTemplateLiteralLoose(strings, raw) { if (!raw) { raw = strings.slice(0); } strings.raw = raw; return strings; }
11
11
 
12
- import React from 'react';
12
+ import React, { useCallback, useEffect, useState } from 'react';
13
13
  import styled, { css } from 'styled-components';
14
14
  import Downshift from 'downshift';
15
15
  import { arrayOf, func, shape, string, number, bool, oneOfType } from 'prop-types';
@@ -78,15 +78,8 @@ var ArrowIcon = styled(function (_ref8) {
78
78
  dropdown = _ref9.theme.yoga.components.dropdown;
79
79
  return "\n fill: " + dropdown.arrow.fill + ";\n " + (disabled ? "fill: " + dropdown.disabled.arrow.fill + ";" : '') + ";\n " + (selected && !disabled ? "fill: " + dropdown.selected.arrow.fill + ";" : '') + ";\n transform: rotate(" + (isOpen ? '180deg' : '0') + ");\n ";
80
80
  });
81
-
82
- var getSelectedOption = function getSelectedOption(options) {
83
- return options.find(function (item) {
84
- return item.selected === true;
85
- });
86
- };
87
81
  /** Gympass Dropdown is a multiple choice type of menu. */
88
82
 
89
-
90
83
  var Dropdown = /*#__PURE__*/React.forwardRef(function (_ref10, ref) {
91
84
  var error = _ref10.error,
92
85
  label = _ref10.label,
@@ -97,15 +90,31 @@ var Dropdown = /*#__PURE__*/React.forwardRef(function (_ref10, ref) {
97
90
  rest = _objectWithoutPropertiesLoose(_ref10, _excluded2);
98
91
 
99
92
  var inputRef = ref || React.useRef(null);
93
+ var selectedOption = options.find(function (item) {
94
+ return item.selected === true;
95
+ });
96
+
97
+ var _useState = useState(selectedOption),
98
+ localSelectedItem = _useState[0],
99
+ setLocalSelectedItem = _useState[1];
100
+
101
+ useEffect(function () {
102
+ setLocalSelectedItem(selectedOption);
103
+ }, [options]);
104
+ var onLocalChange = useCallback(function (opt) {
105
+ setLocalSelectedItem(opt);
106
+ onChange(opt);
107
+ }, [onChange]);
100
108
  return /*#__PURE__*/React.createElement(Downshift, {
101
- initialSelectedItem: getSelectedOption(options),
109
+ initialSelectedItem: selectedOption,
102
110
  selectedItemChanged: function selectedItemChanged(prevItem, item) {
103
111
  return prevItem !== item;
104
112
  },
105
113
  itemToString: function itemToString(item) {
106
114
  return item ? item.label : '';
107
115
  },
108
- onChange: onChange
116
+ onChange: onLocalChange,
117
+ selectedItem: localSelectedItem
109
118
  }, function (_ref11) {
110
119
  var getInputProps = _ref11.getInputProps,
111
120
  getItemProps = _ref11.getItemProps,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gympass/yoga",
3
- "version": "7.72.0",
3
+ "version": "7.72.2",
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": "9231980c252bc0f14c5c37da6cec98d6070ba14f",
56
+ "gitHead": "b7d7d085f0f2c59c3ae24ed8d0ba3d0be8ca48f7",
57
57
  "module": "./esm",
58
58
  "private": false,
59
59
  "react-native": "./cjs/index.native.js"