tg-core-components 5.4.5-bethard → 5.5.1-master

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.
Files changed (105) hide show
  1. package/es/components/AcceptUpdatedTaC/index.js +8 -3
  2. package/es/components/Checkbox/index.js +93 -0
  3. package/es/components/Deposit/CardInput/index.js +1 -3
  4. package/es/components/Input/index.js +222 -22
  5. package/es/components/InputWrapper/index.js +69 -0
  6. package/es/components/Notification.js +4 -4
  7. package/es/components/Select/index.js +202 -64
  8. package/es/components/Select/test.js +111 -0
  9. package/es/index.js +2 -2
  10. package/es/lib/utils/translate.js +1 -8
  11. package/es/misc/countryEmojiFlags.js +0 -1
  12. package/es/widgets/AccountDetail/index.js +53 -77
  13. package/es/widgets/ActivateWidget/index.js +59 -293
  14. package/es/widgets/BonusWidget/BonusCode.js +24 -17
  15. package/es/widgets/BonusWidget/index.js +83 -45
  16. package/es/widgets/Cashier/Payment/index.js +2 -0
  17. package/es/widgets/CashierAccordion/Deposit/BonusCodeInput/index.js +9 -6
  18. package/es/widgets/CashierAccordion/Deposit/DepositWidget/index.js +22 -33
  19. package/es/widgets/CashierAccordion/Deposit/PaymentForm/index.js +2 -6
  20. package/es/widgets/CashierAccordion/Payment/PaymentAccountForms/astroPayBankTransaltions.js +12 -0
  21. package/es/widgets/CashierAccordion/Payment/PaymentAccountForms/index.js +163 -347
  22. package/es/widgets/CashierAccordion/Payment/PaymentAccountParser.js +0 -6
  23. package/es/widgets/CashierAccordion/Payment/PaymentMethodSelector/index.js +2 -2
  24. package/es/widgets/CashierAccordion/Payment/index.js +2 -0
  25. package/es/widgets/CashierAccordion/Withdraw/WithdrawWidget/index.js +9 -23
  26. package/es/widgets/ChangePassword/index.js +53 -40
  27. package/es/widgets/HistoryWidget/index.js +69 -51
  28. package/es/widgets/HistoryWidget/message.js +17 -20
  29. package/es/widgets/RequestResetPassword/index.js +15 -14
  30. package/es/widgets/ResetPassword/index.js +22 -18
  31. package/es/widgets/ResponsibleGamingAccordion/LimitStatus/index.js +5 -2
  32. package/es/widgets/ResponsibleGamingAccordion/PeriodItemContent/index.js +1 -2
  33. package/es/widgets/ResponsibleGamingSingleSignUp/AmountItem/index.js +1 -2
  34. package/es/widgets/ResponsibleGamingWidget/Timespan.js +14 -24
  35. package/es/widgets/ResponsibleGamingWidget/helpers.js +2 -2
  36. package/es/widgets/ResponsibleGamingWidget/validate.js +2 -6
  37. package/es/widgets/Settings/index.js +2 -2
  38. package/es/widgets/SignIn/SignInForm.js +4 -6
  39. package/es/widgets/SignIn/index.js +21 -21
  40. package/es/widgets/SignUp/ContactInfoStep.js +5 -6
  41. package/es/widgets/SportsbookSettings/index.js +10 -24
  42. package/es/widgets/Subscriptions/index.js +3 -5
  43. package/lib/components/AcceptUpdatedTaC/index.js +11 -3
  44. package/lib/components/Checkbox/index.js +106 -0
  45. package/lib/components/Deposit/CardInput/index.js +1 -3
  46. package/lib/components/Input/index.js +223 -26
  47. package/lib/components/InputWrapper/index.js +85 -0
  48. package/lib/components/Notification.js +3 -3
  49. package/lib/components/Select/index.js +209 -63
  50. package/lib/components/Select/test.js +121 -0
  51. package/lib/index.js +7 -7
  52. package/lib/lib/utils/translate.js +1 -8
  53. package/lib/misc/countryEmojiFlags.js +0 -1
  54. package/lib/widgets/AccountDetail/index.js +53 -86
  55. package/lib/widgets/ActivateWidget/index.js +58 -305
  56. package/lib/widgets/BonusWidget/BonusCode.js +24 -20
  57. package/lib/widgets/BonusWidget/index.js +85 -44
  58. package/lib/widgets/Cashier/Payment/index.js +2 -0
  59. package/lib/widgets/CashierAccordion/Deposit/BonusCodeInput/index.js +13 -7
  60. package/lib/widgets/CashierAccordion/Deposit/DepositWidget/index.js +25 -36
  61. package/lib/widgets/CashierAccordion/Deposit/PaymentForm/index.js +2 -9
  62. package/lib/widgets/CashierAccordion/Payment/PaymentAccountForms/astroPayBankTransaltions.js +12 -0
  63. package/lib/widgets/CashierAccordion/Payment/PaymentAccountForms/index.js +195 -378
  64. package/lib/widgets/CashierAccordion/Payment/PaymentAccountParser.js +0 -6
  65. package/lib/widgets/CashierAccordion/Payment/PaymentMethodSelector/index.js +2 -2
  66. package/lib/widgets/CashierAccordion/Payment/index.js +2 -0
  67. package/lib/widgets/CashierAccordion/Withdraw/WithdrawWidget/index.js +11 -25
  68. package/lib/widgets/ChangePassword/index.js +53 -43
  69. package/lib/widgets/HistoryWidget/index.js +69 -51
  70. package/lib/widgets/HistoryWidget/message.js +17 -20
  71. package/lib/widgets/RequestResetPassword/index.js +15 -17
  72. package/lib/widgets/ResetPassword/index.js +25 -21
  73. package/lib/widgets/ResponsibleGamingAccordion/LimitStatus/index.js +5 -2
  74. package/lib/widgets/ResponsibleGamingAccordion/PeriodItemContent/index.js +1 -2
  75. package/lib/widgets/ResponsibleGamingSingleSignUp/AmountItem/index.js +1 -2
  76. package/lib/widgets/ResponsibleGamingWidget/Timespan.js +14 -24
  77. package/lib/widgets/ResponsibleGamingWidget/helpers.js +2 -2
  78. package/lib/widgets/ResponsibleGamingWidget/validate.js +2 -6
  79. package/lib/widgets/Settings/index.js +6 -6
  80. package/lib/widgets/SignIn/SignInForm.js +7 -6
  81. package/lib/widgets/SignIn/index.js +25 -25
  82. package/lib/widgets/SignUp/ContactInfoStep.js +8 -6
  83. package/lib/widgets/SportsbookSettings/index.js +10 -24
  84. package/lib/widgets/Subscriptions/index.js +3 -11
  85. package/package.json +8 -3
  86. package/es/components/AutocompleteInput/index.js +0 -104
  87. package/es/components/Input/BirthdateInput.js +0 -174
  88. package/es/components/Input/Checkbox.js +0 -51
  89. package/es/components/Input/Input.js +0 -73
  90. package/es/components/Input/PasswordInput.js +0 -84
  91. package/es/components/Input/PhoneNumberInput.js +0 -113
  92. package/es/components/Input/input.test.js +0 -80
  93. package/es/components/Input/old-input.test.js +0 -100
  94. package/es/components/common.js +0 -339
  95. package/es/widgets/CashierAccordion/Deposit/PaymentForm/NewTab.js +0 -28
  96. package/lib/components/AutocompleteInput/index.js +0 -118
  97. package/lib/components/Input/BirthdateInput.js +0 -195
  98. package/lib/components/Input/Checkbox.js +0 -65
  99. package/lib/components/Input/Input.js +0 -87
  100. package/lib/components/Input/PasswordInput.js +0 -101
  101. package/lib/components/Input/PhoneNumberInput.js +0 -130
  102. package/lib/components/Input/input.test.js +0 -89
  103. package/lib/components/Input/old-input.test.js +0 -107
  104. package/lib/components/common.js +0 -359
  105. package/lib/widgets/CashierAccordion/Deposit/PaymentForm/NewTab.js +0 -44
@@ -1,100 +0,0 @@
1
- var _this = this;
2
-
3
- function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
4
-
5
- import React from 'react';
6
- import { render, screen, fireEvent, waitFor } from '@testing-library/react';
7
- import '@testing-library/jest-dom/extend-expect';
8
- import { Input } from 'tg-core-components';
9
-
10
- test('input has title', _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
11
- var _render, container, label;
12
-
13
- return regeneratorRuntime.wrap(function _callee$(_context) {
14
- while (1) {
15
- switch (_context.prev = _context.next) {
16
- case 0:
17
- _render = render(React.createElement(Input, { type: 'text', title: 'input label', value: '1337' })), container = _render.container;
18
- label = container.querySelector('.input_title');
19
-
20
- expect(label).toBeInTheDocument();
21
-
22
- case 3:
23
- case 'end':
24
- return _context.stop();
25
- }
26
- }
27
- }, _callee, _this);
28
- })));
29
-
30
- test('input has correct value', _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
31
- var input;
32
- return regeneratorRuntime.wrap(function _callee2$(_context2) {
33
- while (1) {
34
- switch (_context2.prev = _context2.next) {
35
- case 0:
36
- render(React.createElement(Input, { type: 'text', title: 'input label', value: '1337' }));
37
- input = screen.getByDisplayValue('1337');
38
-
39
- expect(input).toHaveValue('1337');
40
-
41
- case 3:
42
- case 'end':
43
- return _context2.stop();
44
- }
45
- }
46
- }, _callee2, _this);
47
- })));
48
-
49
- test('input shows error message', _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3() {
50
- var _render2, container, errorMessage;
51
-
52
- return regeneratorRuntime.wrap(function _callee3$(_context3) {
53
- while (1) {
54
- switch (_context3.prev = _context3.next) {
55
- case 0:
56
- _render2 = render(React.createElement(Input, {
57
- type: 'text',
58
- title: 'input label',
59
- value: '1337',
60
- error: 'Very bad error.'
61
- })), container = _render2.container;
62
- errorMessage = container.querySelector('.error-message');
63
-
64
- expect(errorMessage).toBeInTheDocument();
65
-
66
- case 3:
67
- case 'end':
68
- return _context3.stop();
69
- }
70
- }
71
- }, _callee3, _this);
72
- })));
73
-
74
- test('input shows toggle icon', _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4() {
75
- var _render3, container, input, toggle;
76
-
77
- return regeneratorRuntime.wrap(function _callee4$(_context4) {
78
- while (1) {
79
- switch (_context4.prev = _context4.next) {
80
- case 0:
81
- _render3 = render(React.createElement(Input, { type: 'text', title: 'input label', value: '1337', showToggleIcon: true })), container = _render3.container;
82
- input = container.querySelector('input[type=text]');
83
- toggle = container.querySelector('.toggle-password.fa.fa-eye');
84
-
85
- expect(input).toBeInTheDocument();
86
- expect(toggle).toBeInTheDocument();
87
-
88
- fireEvent.click(toggle);
89
- waitFor(function () {
90
- var input = container.querySelector('input[type=asdd]');
91
- expect(input).toBeInTheDocument();
92
- });
93
-
94
- case 7:
95
- case 'end':
96
- return _context4.stop();
97
- }
98
- }
99
- }, _callee4, _this);
100
- })));
@@ -1,339 +0,0 @@
1
- var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
2
-
3
- var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
4
-
5
- var _extends = Object.assign || 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; };
6
-
7
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
8
-
9
- function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
10
-
11
- import React, { useMemo, useState, useEffect, useLayoutEffect, useRef } from 'react';
12
- import Icon from './Icon';
13
- import ButtonLoader from './ButtonLoader';
14
- import cn from 'classnames';
15
-
16
- export var statusIcons = {
17
- success: React.createElement(Icon, { icon: 'check-circle', className: 'SuccessIcon' }),
18
- failure: React.createElement(Icon, { icon: 'exclamation-circle', className: 'FailureIcon' }),
19
- loading: React.createElement(ButtonLoader, null)
20
- };
21
-
22
- var Input = function Input(_ref) {
23
- var label = _ref.label,
24
- hasValue = _ref.hasValue,
25
- hasFocus = _ref.hasFocus,
26
- hasTouched = _ref.hasTouched,
27
- hasAutofill = _ref.hasAutofill,
28
- status = _ref.status,
29
- leadingLane = _ref.leadingLane,
30
- trailingLane = _ref.trailingLane,
31
- rest = _objectWithoutProperties(_ref, ['label', 'hasValue', 'hasFocus', 'hasTouched', 'hasAutofill', 'status', 'leadingLane', 'trailingLane']);
32
-
33
- var className = createClassName('Input', {
34
- hasLabel: Boolean(label),
35
- hasValue: hasValue,
36
- hasFocus: hasFocus,
37
- hasTouched: hasTouched,
38
- hasAutofill: hasAutofill,
39
- disabled: rest.disabled,
40
- status: status,
41
- type: rest.type
42
- });
43
- var leadingLaneRef = useRef();
44
- var leadingLaneWidth = useRefWidth(leadingLaneRef);
45
- var trailingLaneRef = useRef();
46
- var trailingLaneWidth = useRefWidth(trailingLaneRef);
47
- return React.createElement(
48
- 'div',
49
- {
50
- className: className,
51
- style: {
52
- '--leading-lane-width': leadingLaneWidth + 'px',
53
- '--trailing-lane-width': trailingLaneWidth + 'px'
54
- } },
55
- React.createElement('input', _extends({}, rest, {
56
- type: rest.type || 'text',
57
- className: 'Input__input',
58
- name: rest.name || rest.id,
59
- ref: rest.setRef
60
- })),
61
- React.createElement(
62
- 'label',
63
- { className: 'Input__label', htmlFor: rest.id },
64
- label
65
- ),
66
- React.createElement(
67
- 'div',
68
- { className: 'Input__leading-lane', ref: leadingLaneRef },
69
- leadingLane
70
- ),
71
- React.createElement(
72
- 'div',
73
- { className: 'Input__trailing-lane', ref: trailingLaneRef },
74
- trailingLane
75
- ),
76
- React.createElement('div', {
77
- className: cn('Input__status-line', {
78
- 'Input__status-line--active': status === 'failure' || status === 'success' || hasFocus
79
- })
80
- })
81
- );
82
- };
83
-
84
- export { Input };
85
- var Select = function Select(_ref2) {
86
- var label = _ref2.label,
87
- hasValue = _ref2.hasValue,
88
- hasFocus = _ref2.hasFocus,
89
- hasTouched = _ref2.hasTouched,
90
- hasAutofill = _ref2.hasAutofill,
91
- status = _ref2.status,
92
- children = _ref2.children,
93
- leadingLane = _ref2.leadingLane,
94
- trailingLane = _ref2.trailingLane,
95
- rest = _objectWithoutProperties(_ref2, ['label', 'hasValue', 'hasFocus', 'hasTouched', 'hasAutofill', 'status', 'children', 'leadingLane', 'trailingLane']);
96
-
97
- var className = createClassName('Select', {
98
- hasLabel: Boolean(label),
99
- hasValue: hasValue,
100
- hasFocus: hasFocus,
101
- hasTouched: hasTouched,
102
- hasAutofill: hasAutofill,
103
- disabled: rest.disabled,
104
- status: status,
105
- type: rest.type
106
- });
107
- var leadingLaneRef = useRef();
108
- var leadingLaneWidth = useRefWidth(leadingLaneRef);
109
- var trailingLaneRef = useRef();
110
- var trailingLaneWidth = useRefWidth(leadingLaneRef);
111
- return React.createElement(
112
- 'div',
113
- {
114
- className: className,
115
- style: {
116
- '--leading-lane-width': leadingLaneWidth + 'px',
117
- '--trailing-lane-width': trailingLaneWidth + 'px'
118
- } },
119
- React.createElement(
120
- 'select',
121
- _extends({}, rest, {
122
- className: 'Select__select',
123
- name: rest.name || rest.id,
124
- ref: rest.setRef }),
125
- children
126
- ),
127
- React.createElement(
128
- 'label',
129
- { className: 'Select__label', htmlFor: rest.id },
130
- label
131
- ),
132
- React.createElement(
133
- 'div',
134
- { className: 'Input__leading-lane', ref: leadingLaneRef },
135
- leadingLane
136
- ),
137
- React.createElement(
138
- 'div',
139
- { className: 'Input__trailing-lane', ref: trailingLaneRef },
140
- trailingLane,
141
- React.createElement(Icon, { icon: 'caret-down' })
142
- ),
143
- React.createElement('div', {
144
- className: cn('Select__status-line', {
145
- 'Select__status-line--active': status === 'failure' || status === 'success' || hasFocus
146
- })
147
- })
148
- );
149
- };
150
- export { Select };
151
- var Option = function Option(_ref3) {
152
- var children = _ref3.children,
153
- rest = _objectWithoutProperties(_ref3, ['children']);
154
-
155
- return React.createElement(
156
- 'option',
157
- rest,
158
- children
159
- );
160
- };
161
- Select.Option = Option;
162
- var OptGroup = function OptGroup(_ref4) {
163
- var children = _ref4.children,
164
- rest = _objectWithoutProperties(_ref4, ['children']);
165
-
166
- return React.createElement(
167
- 'optgroup',
168
- rest,
169
- children
170
- );
171
- };
172
- Select.OptGroup = OptGroup;
173
-
174
- var Checkbox = function Checkbox(_ref5) {
175
- var label = _ref5.label,
176
- hasValue = _ref5.hasValue,
177
- hasFocus = _ref5.hasFocus,
178
- hasTouched = _ref5.hasTouched,
179
- hasAutofill = _ref5.hasAutofill,
180
- status = _ref5.status,
181
- rest = _objectWithoutProperties(_ref5, ['label', 'hasValue', 'hasFocus', 'hasTouched', 'hasAutofill', 'status']);
182
-
183
- var className = createClassName('Checkbox', {
184
- hasLabel: Boolean(label),
185
- hasValue: hasValue,
186
- hasFocus: hasFocus,
187
- hasTouched: hasTouched,
188
- hasAutofill: hasAutofill,
189
- disabled: rest.disabled,
190
- status: status,
191
- type: rest.type
192
- });
193
- return React.createElement(
194
- 'div',
195
- { className: className },
196
- React.createElement(
197
- 'div',
198
- { className: 'Checkbox__input-wrapper' },
199
- React.createElement('input', _extends({}, rest, {
200
- className: 'Checkbox__input',
201
- name: rest.name || rest.id,
202
- checked: hasValue,
203
- ref: rest.setRef
204
- })),
205
- React.createElement('div', { className: 'Checkbox__background' })
206
- ),
207
- React.createElement(
208
- 'label',
209
- { className: 'Checkbox__label', htmlFor: rest.id },
210
- label
211
- )
212
- );
213
- };
214
-
215
- /**
216
- * Returns a unique id. Id will stay the same between renders.
217
- */
218
- export { Checkbox };
219
- export var useId = function useId() {
220
- return useMemo(function () {
221
- return Date.now().toString(36) + Math.random().toString(36).substr(2);
222
- }, []);
223
- };
224
-
225
- /**
226
- * Useful hook for inputs that want to control value
227
- */
228
- export var useValue = function useValue() {
229
- var initialValue = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
230
-
231
- var _useState = useState(initialValue),
232
- _useState2 = _slicedToArray(_useState, 2),
233
- value = _useState2[0],
234
- setValue = _useState2[1];
235
-
236
- useEffect(function () {
237
- setValue(initialValue);
238
- }, [initialValue, setValue]);
239
- var onChange = function onChange(value) {
240
- return setValue(value);
241
- };
242
- return { value: value, hasValue: Boolean(value), onChange: onChange };
243
- };
244
-
245
- /**
246
- * Convenient hook that will keep track of input focus state
247
- */
248
- export var useFocus = function useFocus() {
249
- var _useState3 = useState(false),
250
- _useState4 = _slicedToArray(_useState3, 2),
251
- hasFocus = _useState4[0],
252
- setHasFocus = _useState4[1];
253
-
254
- var onFocus = function onFocus() {
255
- return setHasFocus(true);
256
- };
257
- var onBlur = function onBlur() {
258
- return setHasFocus(false);
259
- };
260
- return { hasFocus: hasFocus, onFocus: onFocus, onBlur: onBlur };
261
- };
262
-
263
- /**
264
- * Keeps track of touched state
265
- */
266
- export var useTouched = function useTouched() {
267
- var _useState5 = useState(false),
268
- _useState6 = _slicedToArray(_useState5, 2),
269
- hasTouched = _useState6[0],
270
- setHasTouched = _useState6[1];
271
-
272
- var onFocus = function onFocus() {
273
- return setHasTouched(true);
274
- };
275
- return { hasTouched: hasTouched, onFocus: onFocus };
276
- };
277
-
278
- /**
279
- * Convenient hook to control input type
280
- */
281
- export var useType = function useType(initialType) {
282
- var _useState7 = useState(initialType),
283
- _useState8 = _slicedToArray(_useState7, 2),
284
- type = _useState8[0],
285
- setType = _useState8[1];
286
-
287
- return { type: type, setType: setType };
288
- };
289
-
290
- /**
291
- * Useful hook to detect when input has been autofilled by browser
292
- * Requires animation to work
293
- */
294
- export var useAutofill = function useAutofill() {
295
- var _useState9 = useState(false),
296
- _useState10 = _slicedToArray(_useState9, 2),
297
- hasAutofill = _useState10[0],
298
- setHasAutofill = _useState10[1];
299
-
300
- var onAnimationStart = function onAnimationStart(e) {
301
- if (e.animationName === 'onAutoFill') {
302
- setHasAutofill(true);
303
- }
304
- };
305
- return { hasAutofill: hasAutofill, onAnimationStart: onAnimationStart };
306
- };
307
-
308
- /**
309
- * Helper function to create BEM modifiers
310
- */
311
- export var createClassName = function createClassName(baseName, props) {
312
- var _cn;
313
-
314
- return cn(baseName, (_cn = {}, _defineProperty(_cn, baseName + '--has-value', props.hasValue), _defineProperty(_cn, baseName + '--has-focus', props.hasFocus), _defineProperty(_cn, baseName + '--has-touched', props.hasTouched), _defineProperty(_cn, baseName + '--has-label', props.hasLabel), _defineProperty(_cn, baseName + '--has-autofill', props.hasAutofill), _defineProperty(_cn, baseName + '--disabled', props.disabled), _defineProperty(_cn, baseName + '--status-' + props.status, props.status), _defineProperty(_cn, baseName + '--type-' + props.type, props.type), _cn));
315
- };
316
-
317
- /**
318
- * Hook keeping track of ref element width
319
- */
320
- var useRefWidth = function useRefWidth(ref) {
321
- var _useState11 = useState(0),
322
- _useState12 = _slicedToArray(_useState11, 2),
323
- width = _useState12[0],
324
- setWidth = _useState12[1];
325
-
326
- useLayoutEffect(function () {
327
- setWidth(ref.current.clientWidth);
328
- });
329
- return width;
330
- };
331
-
332
- /**
333
- * Flat object one layer
334
- */
335
- export var flatObj = function flatObj(obj) {
336
- return Object.keys(obj).reduce(function (acc, key) {
337
- return _extends({}, acc, _typeof(obj[key]) === 'object' ? obj[key] : _defineProperty({}, key, obj[key]));
338
- }, {});
339
- };
@@ -1,28 +0,0 @@
1
- import React from 'react';
2
- import Button from '../../../../components/Button';
3
- import Translate from '../../../../components/Translate';
4
-
5
- var NewTab = function NewTab(_ref) {
6
- var url = _ref.url;
7
-
8
- return React.createElement(
9
- 'div',
10
- { className: 'NewTab' },
11
- React.createElement(Translate, {
12
- tagName: 'p',
13
- id: 'label.new-tab',
14
- defaultMessage: 'A new tab is required in order to proceed, please press the button to continue...'
15
- }),
16
- React.createElement(
17
- Button,
18
- {
19
- className: 'primary',
20
- onClick: function onClick() {
21
- window.open(url, '_blank');
22
- } },
23
- React.createElement(Translate, { id: 'action.open-tab', defaultMessage: 'Open new tab' })
24
- )
25
- );
26
- };
27
-
28
- export default NewTab;
@@ -1,118 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
-
7
- var _extends = Object.assign || 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; };
8
-
9
- var _react = require('react');
10
-
11
- var _react2 = _interopRequireDefault(_react);
12
-
13
- var _common = require('../common');
14
-
15
- var _classnames = require('classnames');
16
-
17
- var _classnames2 = _interopRequireDefault(_classnames);
18
-
19
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20
-
21
- function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
22
-
23
- var AutocompleteSuggestion = function AutocompleteSuggestion(_ref) {
24
- var children = _ref.children,
25
- value = _ref.value,
26
- _onClick = _ref.onClick,
27
- selected = _ref.selected,
28
- classNames = _ref.classNames,
29
- rest = _objectWithoutProperties(_ref, ['children', 'value', 'onClick', 'selected', 'classNames']);
30
-
31
- return _react2.default.createElement(
32
- 'div',
33
- _extends({}, rest, {
34
- className: (0, _classnames2.default)(classNames, 'tg-autocomplete-input__suggestions__suggestion', {
35
- 'tg-autocomplete-input__suggestions__suggestion--selected': selected
36
- }),
37
- onClick: function onClick() {
38
- _onClick(value);
39
- } }),
40
- children
41
- );
42
- };
43
-
44
- var AutocompleteInput = function AutocompleteInput(_ref2) {
45
- var icon = _ref2.icon,
46
- props = _objectWithoutProperties(_ref2, ['icon']);
47
-
48
- var input = {
49
- id: (0, _common.useId)(),
50
- value: (0, _common.useValue)(props.value),
51
- focus: (0, _common.useFocus)(),
52
- touched: (0, _common.useTouched)(),
53
- autofill: (0, _common.useAutofill)()
54
- };
55
-
56
- var _onChange = function _onChange(e) {
57
- return props.onChange && props.onChange(e, e.target.value);
58
- };
59
- var _onBlur = function _onBlur(e) {
60
- return props.onBlur && props.onBlur(e, e.target.value);
61
- };
62
-
63
- var className = (0, _common.createClassName)('tg-autocomplete-input', {
64
- hasValue: input.value.hasValue,
65
- hasLabel: Boolean(props.label),
66
- hasFocus: input.focus.hasFocus,
67
- hasTouched: input.touched.hasTouched,
68
- hasAutofill: input.autofill.hasAutofill,
69
- disabled: props.disabled,
70
- status: props.status
71
- });
72
-
73
- return _react2.default.createElement(
74
- 'div',
75
- { className: (0, _classnames2.default)(props.className, className) },
76
- _react2.default.createElement(_common.Input, _extends({}, props, (0, _common.flatObj)(input), {
77
- children: null,
78
- autoComplete: 'off',
79
- onChange: function onChange(e) {
80
- if (typeof props.transform === 'function') {
81
- e.target.value = props.transform(e.target.value);
82
- }
83
- input.value.onChange(e.target.value);
84
- _onChange(e);
85
- },
86
- onFocus: function onFocus() {
87
- input.focus.onFocus();
88
- input.touched.onFocus();
89
- },
90
- onBlur: function onBlur(e) {
91
- setTimeout(function () {
92
- input.focus.onBlur();
93
- _onBlur(e);
94
- }, 500);
95
- },
96
- leadingLane: [icon].filter(function (i) {
97
- return i;
98
- }),
99
- trailingLane: [_common.statusIcons[props.status]].filter(function (i) {
100
- return i;
101
- })
102
- })),
103
- props.children.length > 0 && input.focus.hasFocus && _react2.default.createElement(
104
- 'div',
105
- { className: 'tg-autocomplete-input__suggestions' },
106
- props.children
107
- ),
108
- _react2.default.createElement(
109
- 'div',
110
- { className: 'tg-autocomplete-input__status-text' },
111
- props.statusText
112
- )
113
- );
114
- };
115
-
116
- AutocompleteInput.Suggestion = AutocompleteSuggestion;
117
-
118
- exports.default = AutocompleteInput;