@gympass/yoga 7.71.0 → 7.72.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.
|
@@ -15,7 +15,7 @@ var _yogaIcons = require("@gympass/yoga-icons");
|
|
|
15
15
|
|
|
16
16
|
var _Input = _interopRequireDefault(require("../../Input/web/Input"));
|
|
17
17
|
|
|
18
|
-
var _excluded = ["className", "style", "full", "options", "onChange", "onClean", "onSelect", "value", "error", "openSuggestionsAriaLabel", "closeSuggestionsAriaLabel"];
|
|
18
|
+
var _excluded = ["className", "style", "full", "options", "onChange", "onClean", "onSelect", "value", "error", "openSuggestionsAriaLabel", "closeSuggestionsAriaLabel", "shouldFilterOptions"];
|
|
19
19
|
|
|
20
20
|
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5;
|
|
21
21
|
|
|
@@ -78,6 +78,7 @@ var AutoComplete = /*#__PURE__*/_react["default"].forwardRef(function (_ref6, re
|
|
|
78
78
|
error = _ref6.error,
|
|
79
79
|
openSuggestionsAriaLabel = _ref6.openSuggestionsAriaLabel,
|
|
80
80
|
closeSuggestionsAriaLabel = _ref6.closeSuggestionsAriaLabel,
|
|
81
|
+
shouldFilterOptions = _ref6.shouldFilterOptions,
|
|
81
82
|
props = _objectWithoutPropertiesLoose(_ref6, _excluded);
|
|
82
83
|
|
|
83
84
|
var _useState = (0, _react.useState)(value),
|
|
@@ -136,11 +137,11 @@ var AutoComplete = /*#__PURE__*/_react["default"].forwardRef(function (_ref6, re
|
|
|
136
137
|
openMenu = _ref8.openMenu,
|
|
137
138
|
inputValue = _ref8.inputValue;
|
|
138
139
|
var reg = new RegExp("(" + escapeRegExp(inputValue || '').trim() + ")", 'gi');
|
|
139
|
-
var suggestionList = options.filter(function (option) {
|
|
140
|
+
var suggestionList = shouldFilterOptions ? options.filter(function (option) {
|
|
140
141
|
return option.match(reg);
|
|
141
142
|
}).sort(function (first, second) {
|
|
142
143
|
return first.toLowerCase().indexOf(inputValue) < second.toLowerCase().indexOf(inputValue) ? -1 : 1;
|
|
143
|
-
});
|
|
144
|
+
}) : options;
|
|
144
145
|
|
|
145
146
|
if (!!inputValue && isOpen) {
|
|
146
147
|
setIsSuggestionsOpen(true);
|
|
@@ -218,7 +219,10 @@ AutoComplete.propTypes = {
|
|
|
218
219
|
openSuggestionsAriaLabel: _propTypes.string,
|
|
219
220
|
|
|
220
221
|
/** an aria label for the close suggestions icon */
|
|
221
|
-
closeSuggestionsAriaLabel: _propTypes.string
|
|
222
|
+
closeSuggestionsAriaLabel: _propTypes.string,
|
|
223
|
+
|
|
224
|
+
/** flag to enable options filtering */
|
|
225
|
+
shouldFilterOptions: _propTypes.bool
|
|
222
226
|
};
|
|
223
227
|
AutoComplete.defaultProps = {
|
|
224
228
|
className: undefined,
|
|
@@ -231,7 +235,8 @@ AutoComplete.defaultProps = {
|
|
|
231
235
|
value: undefined,
|
|
232
236
|
error: undefined,
|
|
233
237
|
openSuggestionsAriaLabel: 'Open suggestions',
|
|
234
|
-
closeSuggestionsAriaLabel: 'Close suggestions'
|
|
238
|
+
closeSuggestionsAriaLabel: 'Close suggestions',
|
|
239
|
+
shouldFilterOptions: true
|
|
235
240
|
};
|
|
236
241
|
var _default = AutoComplete;
|
|
237
242
|
exports["default"] = _default;
|
|
@@ -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
|
-
|
|
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 &&
|
|
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(
|
|
168
|
-
var futureDateDisabled = disableFutureDates && local.getTime() > nowUTC || disableFutureFrom && local.getTime() > new Date(
|
|
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
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var _excluded = ["className", "style", "full", "options", "onChange", "onClean", "onSelect", "value", "error", "openSuggestionsAriaLabel", "closeSuggestionsAriaLabel"];
|
|
1
|
+
var _excluded = ["className", "style", "full", "options", "onChange", "onClean", "onSelect", "value", "error", "openSuggestionsAriaLabel", "closeSuggestionsAriaLabel", "shouldFilterOptions"];
|
|
2
2
|
|
|
3
3
|
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5;
|
|
4
4
|
|
|
@@ -59,6 +59,7 @@ var AutoComplete = /*#__PURE__*/React.forwardRef(function (_ref6, ref) {
|
|
|
59
59
|
error = _ref6.error,
|
|
60
60
|
openSuggestionsAriaLabel = _ref6.openSuggestionsAriaLabel,
|
|
61
61
|
closeSuggestionsAriaLabel = _ref6.closeSuggestionsAriaLabel,
|
|
62
|
+
shouldFilterOptions = _ref6.shouldFilterOptions,
|
|
62
63
|
props = _objectWithoutPropertiesLoose(_ref6, _excluded);
|
|
63
64
|
|
|
64
65
|
var _useState = useState(value),
|
|
@@ -117,11 +118,11 @@ var AutoComplete = /*#__PURE__*/React.forwardRef(function (_ref6, ref) {
|
|
|
117
118
|
openMenu = _ref8.openMenu,
|
|
118
119
|
inputValue = _ref8.inputValue;
|
|
119
120
|
var reg = new RegExp("(" + escapeRegExp(inputValue || '').trim() + ")", 'gi');
|
|
120
|
-
var suggestionList = options.filter(function (option) {
|
|
121
|
+
var suggestionList = shouldFilterOptions ? options.filter(function (option) {
|
|
121
122
|
return option.match(reg);
|
|
122
123
|
}).sort(function (first, second) {
|
|
123
124
|
return first.toLowerCase().indexOf(inputValue) < second.toLowerCase().indexOf(inputValue) ? -1 : 1;
|
|
124
|
-
});
|
|
125
|
+
}) : options;
|
|
125
126
|
|
|
126
127
|
if (!!inputValue && isOpen) {
|
|
127
128
|
setIsSuggestionsOpen(true);
|
|
@@ -198,7 +199,10 @@ AutoComplete.propTypes = {
|
|
|
198
199
|
openSuggestionsAriaLabel: string,
|
|
199
200
|
|
|
200
201
|
/** an aria label for the close suggestions icon */
|
|
201
|
-
closeSuggestionsAriaLabel: string
|
|
202
|
+
closeSuggestionsAriaLabel: string,
|
|
203
|
+
|
|
204
|
+
/** flag to enable options filtering */
|
|
205
|
+
shouldFilterOptions: bool
|
|
202
206
|
};
|
|
203
207
|
AutoComplete.defaultProps = {
|
|
204
208
|
className: undefined,
|
|
@@ -211,6 +215,7 @@ AutoComplete.defaultProps = {
|
|
|
211
215
|
value: undefined,
|
|
212
216
|
error: undefined,
|
|
213
217
|
openSuggestionsAriaLabel: 'Open suggestions',
|
|
214
|
-
closeSuggestionsAriaLabel: 'Close suggestions'
|
|
218
|
+
closeSuggestionsAriaLabel: 'Close suggestions',
|
|
219
|
+
shouldFilterOptions: true
|
|
215
220
|
};
|
|
216
221
|
export default AutoComplete;
|
|
@@ -53,14 +53,27 @@ describe('<AutoComplete />', function () {
|
|
|
53
53
|
fireEvent.focus(getByDisplayValue('secon'));
|
|
54
54
|
expect(container.querySelector('ul').firstChild.textContent).toBe('second');
|
|
55
55
|
});
|
|
56
|
-
it('should
|
|
56
|
+
it('should not filter the options', function () {
|
|
57
57
|
var _render6 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(AutoComplete, {
|
|
58
58
|
value: "secon",
|
|
59
|
-
options: ['first', 'second', 'third']
|
|
59
|
+
options: ['first', 'second', 'third'],
|
|
60
|
+
shouldFilterOptions: false
|
|
60
61
|
}))),
|
|
61
62
|
container = _render6.container,
|
|
62
|
-
getByDisplayValue = _render6.getByDisplayValue
|
|
63
|
-
|
|
63
|
+
getByDisplayValue = _render6.getByDisplayValue;
|
|
64
|
+
|
|
65
|
+
fireEvent.focus(getByDisplayValue('secon'));
|
|
66
|
+
expect(container.querySelector('ul').firstChild.textContent).toBe('first');
|
|
67
|
+
expect(container.querySelector('ul').childNodes.length).toBe(3);
|
|
68
|
+
});
|
|
69
|
+
it('should close options list when clean button is clicked', function () {
|
|
70
|
+
var _render7 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(AutoComplete, {
|
|
71
|
+
value: "secon",
|
|
72
|
+
options: ['first', 'second', 'third']
|
|
73
|
+
}))),
|
|
74
|
+
container = _render7.container,
|
|
75
|
+
getByDisplayValue = _render7.getByDisplayValue,
|
|
76
|
+
getByRole = _render7.getByRole;
|
|
64
77
|
|
|
65
78
|
fireEvent.focus(getByDisplayValue('secon'));
|
|
66
79
|
fireEvent.click(getByRole('button', {
|
|
@@ -75,12 +88,12 @@ describe('<AutoComplete />', function () {
|
|
|
75
88
|
var onCleanMock = jest.fn();
|
|
76
89
|
var onSelectMock = jest.fn();
|
|
77
90
|
|
|
78
|
-
var
|
|
91
|
+
var _render8 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(AutoComplete, {
|
|
79
92
|
value: "New",
|
|
80
93
|
options: ['New York'],
|
|
81
94
|
onChange: onChangeMock
|
|
82
95
|
}))),
|
|
83
|
-
getByDisplayValue =
|
|
96
|
+
getByDisplayValue = _render8.getByDisplayValue;
|
|
84
97
|
|
|
85
98
|
fireEvent.change(getByDisplayValue('New'), {
|
|
86
99
|
target: {
|
|
@@ -96,15 +109,15 @@ describe('<AutoComplete />', function () {
|
|
|
96
109
|
var onSelectMock = jest.fn();
|
|
97
110
|
var onChangeMock = jest.fn();
|
|
98
111
|
|
|
99
|
-
var
|
|
112
|
+
var _render9 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(AutoComplete, {
|
|
100
113
|
value: "New",
|
|
101
114
|
options: ['New York'],
|
|
102
115
|
onClean: onCleanMock,
|
|
103
116
|
onSelect: onSelectMock,
|
|
104
117
|
onChange: onChangeMock
|
|
105
118
|
}))),
|
|
106
|
-
getByDisplayValue =
|
|
107
|
-
getByRole =
|
|
119
|
+
getByDisplayValue = _render9.getByDisplayValue,
|
|
120
|
+
getByRole = _render9.getByRole;
|
|
108
121
|
|
|
109
122
|
fireEvent.focus(getByDisplayValue('New'));
|
|
110
123
|
fireEvent.click(getByRole('button', {
|
|
@@ -119,15 +132,15 @@ describe('<AutoComplete />', function () {
|
|
|
119
132
|
var onCleanMock = jest.fn();
|
|
120
133
|
var onChangeMock = jest.fn();
|
|
121
134
|
|
|
122
|
-
var
|
|
135
|
+
var _render10 = render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(AutoComplete, {
|
|
123
136
|
value: "New",
|
|
124
137
|
options: ['New York'],
|
|
125
138
|
onSelect: onSelectMock,
|
|
126
139
|
onClean: onCleanMock,
|
|
127
140
|
onChange: onChangeMock
|
|
128
141
|
}))),
|
|
129
|
-
getByDisplayValue =
|
|
130
|
-
getByRole =
|
|
142
|
+
getByDisplayValue = _render10.getByDisplayValue,
|
|
143
|
+
getByRole = _render10.getByRole;
|
|
131
144
|
|
|
132
145
|
fireEvent.focus(getByDisplayValue('New'));
|
|
133
146
|
fireEvent.click(getByRole('option'));
|
|
@@ -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
|
-
|
|
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 &&
|
|
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(
|
|
148
|
-
var futureDateDisabled = disableFutureDates && local.getTime() > nowUTC || disableFutureFrom && local.getTime() > new Date(
|
|
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
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gympass/yoga",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.72.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": "
|
|
56
|
+
"gitHead": "6319278bb75d659bcf645458d4845c9ec91462ce",
|
|
57
57
|
"module": "./esm",
|
|
58
58
|
"private": false,
|
|
59
59
|
"react-native": "./cjs/index.native.js"
|