@gympass/yoga 7.72.4 → 7.73.1

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);
@@ -15,7 +15,7 @@ var _Tag = _interopRequireDefault(require("./Tag"));
15
15
 
16
16
  var _Icon = _interopRequireDefault(require("../../Icon"));
17
17
 
18
- var _excluded = ["children", "icon", "theme", "small"];
18
+ var _excluded = ["children", "icon", "theme", "small", "ellipsis"];
19
19
 
20
20
  var _templateObject;
21
21
 
@@ -52,10 +52,12 @@ var TagInformative = function TagInformative(_ref2) {
52
52
  text = _ref2$theme$yoga.colors.text,
53
53
  tag = _ref2$theme$yoga.components.tag,
54
54
  small = _ref2.small,
55
+ ellipsis = _ref2.ellipsis,
55
56
  props = _objectWithoutPropertiesLoose(_ref2, _excluded);
56
57
 
57
58
  return /*#__PURE__*/_react["default"].createElement(Informative, _extends({
58
- small: small
59
+ small: small,
60
+ ellipsis: ellipsis
59
61
  }, props), icon && /*#__PURE__*/_react["default"].createElement(_Icon["default"], {
60
62
  as: icon,
61
63
  size: small ? tag.icon.size.small : tag.icon.size["default"],
@@ -75,12 +77,16 @@ TagInformative.propTypes = {
75
77
  children: _propTypes.node.isRequired,
76
78
 
77
79
  /** The tag's size */
78
- small: _propTypes.bool
80
+ small: _propTypes.bool,
81
+
82
+ /** After set a max-width can put ellipses for large texts */
83
+ ellipsis: _propTypes.bool
79
84
  };
80
85
  TagInformative.defaultProps = {
81
86
  icon: undefined,
82
87
  small: false,
83
- variant: 'neutral'
88
+ variant: 'neutral',
89
+ ellipsis: false
84
90
  };
85
91
  TagInformative.displayName = 'Tag.Informative';
86
92
 
@@ -17,9 +17,10 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "d
17
17
 
18
18
  function _taggedTemplateLiteralLoose(strings, raw) { if (!raw) { raw = strings.slice(0); } strings.raw = raw; return strings; }
19
19
 
20
- var StyledTag = _styledComponents["default"].div(_templateObject || (_templateObject = _taggedTemplateLiteralLoose(["\n display: inline-flex;\n justify-content: center;\n align-items: center;\n\n border-style: solid;\n\n ", "\n\n ", "\n"])), function (_ref) {
20
+ var StyledTag = _styledComponents["default"].div(_templateObject || (_templateObject = _taggedTemplateLiteralLoose(["\n display: inline-flex;\n justify-content: center;\n align-items: center;\n\n border-style: solid;\n\n ", "\n\n ", "\n ", "\n"])), function (_ref) {
21
21
  var variant = _ref.variant,
22
22
  small = _ref.small,
23
+ ellipsis = _ref.ellipsis,
23
24
  _ref$theme$yoga = _ref.theme.yoga,
24
25
  _ref$theme$yoga$color = _ref$theme$yoga.colors,
25
26
  text = _ref$theme$yoga$color.text,
@@ -34,8 +35,8 @@ var StyledTag = _styledComponents["default"].div(_templateObject || (_templateOb
34
35
  dark: elements.selectionAndIcons
35
36
  } : _ref$theme$yoga$color4,
36
37
  tag = _ref$theme$yoga.components.tag;
37
- return "\n " + (small ? "\n padding:\n " + tag.padding.small.top + "\n " + tag.padding.small.right + "px\n " + tag.padding.small.bottom + "\n " + tag.padding.small.left + "px;\n " : "\n padding:\n " + tag.padding["default"].top + "px\n " + tag.padding["default"].right + "px\n " + tag.padding["default"].bottom + "px\n " + tag.padding["default"].left + "px;\n ") + "\n \n color: " + color.dark + ";\n border-radius: " + tag.border.radius + "px;\n border-width: " + tag.border.width + "px;\n border-color: " + borderColor.dark + ";\n\n font-size: " + tag.font.size + "px;\n line-height: " + tag.font.lineHeight + "px;\n font-weight: " + tag.font.weight + ";\n ";
38
- }, _yogaSystem.margins);
38
+ return "\n " + (small ? "\n padding:\n " + tag.padding.small.top + "\n " + tag.padding.small.right + "px\n " + tag.padding.small.bottom + "\n " + tag.padding.small.left + "px;\n " : "\n padding:\n " + tag.padding["default"].top + "px\n " + tag.padding["default"].right + "px\n " + tag.padding["default"].bottom + "px\n " + tag.padding["default"].left + "px;\n ") + "\n\n " + (ellipsis ? "\n display: block;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n " : "") + "\n\n color: " + color.dark + ";\n border-radius: " + tag.border.radius + "px;\n border-width: " + tag.border.width + "px;\n border-color: " + borderColor.dark + ";\n\n font-size: " + tag.font.size + "px;\n line-height: " + tag.font.lineHeight + "px;\n font-weight: " + tag.font.weight + ";\n ";
39
+ }, _yogaSystem.margins, _yogaSystem.maxWidth);
39
40
  /** Tags should be keywords to categorize or organize an item. */
40
41
 
41
42
 
@@ -49,11 +50,15 @@ Tag.propTypes = {
49
50
  children: _propTypes.node.isRequired,
50
51
 
51
52
  /** Can send small to use this variant */
52
- small: _propTypes.bool
53
+ small: _propTypes.bool,
54
+
55
+ /** After set a max-width can put ellipses for large texts */
56
+ ellipsis: _propTypes.bool
53
57
  };
54
58
  Tag.defaultProps = {
55
59
  variant: '',
56
- small: false
60
+ small: false,
61
+ ellipsis: false
57
62
  };
58
63
  var _default = Tag;
59
64
  exports["default"] = _default;
@@ -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 = ["children", "icon", "theme", "small"];
1
+ var _excluded = ["children", "icon", "theme", "small", "ellipsis"];
2
2
 
3
3
  var _templateObject;
4
4
 
@@ -35,10 +35,12 @@ var TagInformative = function TagInformative(_ref2) {
35
35
  text = _ref2$theme$yoga.colors.text,
36
36
  tag = _ref2$theme$yoga.components.tag,
37
37
  small = _ref2.small,
38
+ ellipsis = _ref2.ellipsis,
38
39
  props = _objectWithoutPropertiesLoose(_ref2, _excluded);
39
40
 
40
41
  return /*#__PURE__*/React.createElement(Informative, _extends({
41
- small: small
42
+ small: small,
43
+ ellipsis: ellipsis
42
44
  }, props), icon && /*#__PURE__*/React.createElement(Icon, {
43
45
  as: icon,
44
46
  size: small ? tag.icon.size.small : tag.icon.size["default"],
@@ -58,12 +60,16 @@ TagInformative.propTypes = {
58
60
  children: node.isRequired,
59
61
 
60
62
  /** The tag's size */
61
- small: bool
63
+ small: bool,
64
+
65
+ /** After set a max-width can put ellipses for large texts */
66
+ ellipsis: bool
62
67
  };
63
68
  TagInformative.defaultProps = {
64
69
  icon: undefined,
65
70
  small: false,
66
- variant: 'neutral'
71
+ variant: 'neutral',
72
+ ellipsis: false
67
73
  };
68
74
  TagInformative.displayName = 'Tag.Informative';
69
75
  export default withTheme(TagInformative);
@@ -5,10 +5,11 @@ function _taggedTemplateLiteralLoose(strings, raw) { if (!raw) { raw = strings.s
5
5
  import React from 'react';
6
6
  import styled from 'styled-components';
7
7
  import { oneOf, node, bool } from 'prop-types';
8
- import { margins } from '@gympass/yoga-system';
9
- var StyledTag = styled.div(_templateObject || (_templateObject = _taggedTemplateLiteralLoose(["\n display: inline-flex;\n justify-content: center;\n align-items: center;\n\n border-style: solid;\n\n ", "\n\n ", "\n"])), function (_ref) {
8
+ import { margins, maxWidth } from '@gympass/yoga-system';
9
+ var StyledTag = styled.div(_templateObject || (_templateObject = _taggedTemplateLiteralLoose(["\n display: inline-flex;\n justify-content: center;\n align-items: center;\n\n border-style: solid;\n\n ", "\n\n ", "\n ", "\n"])), function (_ref) {
10
10
  var variant = _ref.variant,
11
11
  small = _ref.small,
12
+ ellipsis = _ref.ellipsis,
12
13
  _ref$theme$yoga = _ref.theme.yoga,
13
14
  _ref$theme$yoga$color = _ref$theme$yoga.colors,
14
15
  text = _ref$theme$yoga$color.text,
@@ -23,8 +24,8 @@ var StyledTag = styled.div(_templateObject || (_templateObject = _taggedTemplate
23
24
  dark: elements.selectionAndIcons
24
25
  } : _ref$theme$yoga$color4,
25
26
  tag = _ref$theme$yoga.components.tag;
26
- return "\n " + (small ? "\n padding:\n " + tag.padding.small.top + "\n " + tag.padding.small.right + "px\n " + tag.padding.small.bottom + "\n " + tag.padding.small.left + "px;\n " : "\n padding:\n " + tag.padding["default"].top + "px\n " + tag.padding["default"].right + "px\n " + tag.padding["default"].bottom + "px\n " + tag.padding["default"].left + "px;\n ") + "\n \n color: " + color.dark + ";\n border-radius: " + tag.border.radius + "px;\n border-width: " + tag.border.width + "px;\n border-color: " + borderColor.dark + ";\n\n font-size: " + tag.font.size + "px;\n line-height: " + tag.font.lineHeight + "px;\n font-weight: " + tag.font.weight + ";\n ";
27
- }, margins);
27
+ return "\n " + (small ? "\n padding:\n " + tag.padding.small.top + "\n " + tag.padding.small.right + "px\n " + tag.padding.small.bottom + "\n " + tag.padding.small.left + "px;\n " : "\n padding:\n " + tag.padding["default"].top + "px\n " + tag.padding["default"].right + "px\n " + tag.padding["default"].bottom + "px\n " + tag.padding["default"].left + "px;\n ") + "\n\n " + (ellipsis ? "\n display: block;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n " : "") + "\n\n color: " + color.dark + ";\n border-radius: " + tag.border.radius + "px;\n border-width: " + tag.border.width + "px;\n border-color: " + borderColor.dark + ";\n\n font-size: " + tag.font.size + "px;\n line-height: " + tag.font.lineHeight + "px;\n font-weight: " + tag.font.weight + ";\n ";
28
+ }, margins, maxWidth);
28
29
  /** Tags should be keywords to categorize or organize an item. */
29
30
 
30
31
  var Tag = function Tag(props) {
@@ -37,10 +38,14 @@ Tag.propTypes = {
37
38
  children: node.isRequired,
38
39
 
39
40
  /** Can send small to use this variant */
40
- small: bool
41
+ small: bool,
42
+
43
+ /** After set a max-width can put ellipses for large texts */
44
+ ellipsis: bool
41
45
  };
42
46
  Tag.defaultProps = {
43
47
  variant: '',
44
- small: false
48
+ small: false,
49
+ ellipsis: false
45
50
  };
46
51
  export default Tag;
@@ -76,4 +76,31 @@ describe('<Tag />', function () {
76
76
 
77
77
  expect(container).toMatchSnapshot();
78
78
  });
79
+ it('should match snapshot with ellipsis prop', function () {
80
+ var _render8 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Tag, {
81
+ maxWidth: "10px",
82
+ ellipsis: true
83
+ }, "Default with ellipsis"))),
84
+ container = _render8.container;
85
+
86
+ expect(container).toMatchSnapshot();
87
+ });
88
+ it('should match snapshot with variant, informative type and ellipsis prop', function () {
89
+ var _render9 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Tag.Informative, {
90
+ variant: "success",
91
+ maxWidth: "10px",
92
+ ellipsis: true
93
+ }, "Success with ellipsis"), /*#__PURE__*/React.createElement(Tag.Informative, {
94
+ variant: "attention",
95
+ maxWidth: "10px",
96
+ ellipsis: true
97
+ }, "Attention with ellipsis"), /*#__PURE__*/React.createElement(Tag.Informative, {
98
+ variant: "informative",
99
+ maxWidth: "10px",
100
+ ellipsis: true
101
+ }, "Informative with ellipsis"))),
102
+ container = _render9.container;
103
+
104
+ expect(container).toMatchSnapshot();
105
+ });
79
106
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gympass/yoga",
3
- "version": "7.72.4",
3
+ "version": "7.73.1",
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": "56a1fbb6108c24a4c9e4610e7ae93c1bcd7b245d",
56
+ "gitHead": "a3dd6190c1e10982f2c9f680eadce5e6544bb632",
57
57
  "module": "./esm",
58
58
  "private": false,
59
59
  "react-native": "./cjs/index.native.js"