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.
- package/es/components/AcceptUpdatedTaC/index.js +8 -3
- package/es/components/Checkbox/index.js +93 -0
- package/es/components/Deposit/CardInput/index.js +1 -3
- package/es/components/Input/index.js +222 -22
- package/es/components/InputWrapper/index.js +69 -0
- package/es/components/Notification.js +4 -4
- package/es/components/Select/index.js +202 -64
- package/es/components/Select/test.js +111 -0
- package/es/index.js +2 -2
- package/es/lib/utils/translate.js +1 -8
- package/es/misc/countryEmojiFlags.js +0 -1
- package/es/widgets/AccountDetail/index.js +53 -77
- package/es/widgets/ActivateWidget/index.js +59 -293
- package/es/widgets/BonusWidget/BonusCode.js +24 -17
- package/es/widgets/BonusWidget/index.js +83 -45
- package/es/widgets/Cashier/Payment/index.js +2 -0
- package/es/widgets/CashierAccordion/Deposit/BonusCodeInput/index.js +9 -6
- package/es/widgets/CashierAccordion/Deposit/DepositWidget/index.js +22 -33
- package/es/widgets/CashierAccordion/Deposit/PaymentForm/index.js +2 -6
- package/es/widgets/CashierAccordion/Payment/PaymentAccountForms/astroPayBankTransaltions.js +12 -0
- package/es/widgets/CashierAccordion/Payment/PaymentAccountForms/index.js +163 -347
- package/es/widgets/CashierAccordion/Payment/PaymentAccountParser.js +0 -6
- package/es/widgets/CashierAccordion/Payment/PaymentMethodSelector/index.js +2 -2
- package/es/widgets/CashierAccordion/Payment/index.js +2 -0
- package/es/widgets/CashierAccordion/Withdraw/WithdrawWidget/index.js +9 -23
- package/es/widgets/ChangePassword/index.js +53 -40
- package/es/widgets/HistoryWidget/index.js +69 -51
- package/es/widgets/HistoryWidget/message.js +17 -20
- package/es/widgets/RequestResetPassword/index.js +15 -14
- package/es/widgets/ResetPassword/index.js +22 -18
- package/es/widgets/ResponsibleGamingAccordion/LimitStatus/index.js +5 -2
- package/es/widgets/ResponsibleGamingAccordion/PeriodItemContent/index.js +1 -2
- package/es/widgets/ResponsibleGamingSingleSignUp/AmountItem/index.js +1 -2
- package/es/widgets/ResponsibleGamingWidget/Timespan.js +14 -24
- package/es/widgets/ResponsibleGamingWidget/helpers.js +2 -2
- package/es/widgets/ResponsibleGamingWidget/validate.js +2 -6
- package/es/widgets/Settings/index.js +2 -2
- package/es/widgets/SignIn/SignInForm.js +4 -6
- package/es/widgets/SignIn/index.js +21 -21
- package/es/widgets/SignUp/ContactInfoStep.js +5 -6
- package/es/widgets/SportsbookSettings/index.js +10 -24
- package/es/widgets/Subscriptions/index.js +3 -5
- package/lib/components/AcceptUpdatedTaC/index.js +11 -3
- package/lib/components/Checkbox/index.js +106 -0
- package/lib/components/Deposit/CardInput/index.js +1 -3
- package/lib/components/Input/index.js +223 -26
- package/lib/components/InputWrapper/index.js +85 -0
- package/lib/components/Notification.js +3 -3
- package/lib/components/Select/index.js +209 -63
- package/lib/components/Select/test.js +121 -0
- package/lib/index.js +7 -7
- package/lib/lib/utils/translate.js +1 -8
- package/lib/misc/countryEmojiFlags.js +0 -1
- package/lib/widgets/AccountDetail/index.js +53 -86
- package/lib/widgets/ActivateWidget/index.js +58 -305
- package/lib/widgets/BonusWidget/BonusCode.js +24 -20
- package/lib/widgets/BonusWidget/index.js +85 -44
- package/lib/widgets/Cashier/Payment/index.js +2 -0
- package/lib/widgets/CashierAccordion/Deposit/BonusCodeInput/index.js +13 -7
- package/lib/widgets/CashierAccordion/Deposit/DepositWidget/index.js +25 -36
- package/lib/widgets/CashierAccordion/Deposit/PaymentForm/index.js +2 -9
- package/lib/widgets/CashierAccordion/Payment/PaymentAccountForms/astroPayBankTransaltions.js +12 -0
- package/lib/widgets/CashierAccordion/Payment/PaymentAccountForms/index.js +195 -378
- package/lib/widgets/CashierAccordion/Payment/PaymentAccountParser.js +0 -6
- package/lib/widgets/CashierAccordion/Payment/PaymentMethodSelector/index.js +2 -2
- package/lib/widgets/CashierAccordion/Payment/index.js +2 -0
- package/lib/widgets/CashierAccordion/Withdraw/WithdrawWidget/index.js +11 -25
- package/lib/widgets/ChangePassword/index.js +53 -43
- package/lib/widgets/HistoryWidget/index.js +69 -51
- package/lib/widgets/HistoryWidget/message.js +17 -20
- package/lib/widgets/RequestResetPassword/index.js +15 -17
- package/lib/widgets/ResetPassword/index.js +25 -21
- package/lib/widgets/ResponsibleGamingAccordion/LimitStatus/index.js +5 -2
- package/lib/widgets/ResponsibleGamingAccordion/PeriodItemContent/index.js +1 -2
- package/lib/widgets/ResponsibleGamingSingleSignUp/AmountItem/index.js +1 -2
- package/lib/widgets/ResponsibleGamingWidget/Timespan.js +14 -24
- package/lib/widgets/ResponsibleGamingWidget/helpers.js +2 -2
- package/lib/widgets/ResponsibleGamingWidget/validate.js +2 -6
- package/lib/widgets/Settings/index.js +6 -6
- package/lib/widgets/SignIn/SignInForm.js +7 -6
- package/lib/widgets/SignIn/index.js +25 -25
- package/lib/widgets/SignUp/ContactInfoStep.js +8 -6
- package/lib/widgets/SportsbookSettings/index.js +10 -24
- package/lib/widgets/Subscriptions/index.js +3 -11
- package/package.json +8 -3
- package/es/components/AutocompleteInput/index.js +0 -104
- package/es/components/Input/BirthdateInput.js +0 -174
- package/es/components/Input/Checkbox.js +0 -51
- package/es/components/Input/Input.js +0 -73
- package/es/components/Input/PasswordInput.js +0 -84
- package/es/components/Input/PhoneNumberInput.js +0 -113
- package/es/components/Input/input.test.js +0 -80
- package/es/components/Input/old-input.test.js +0 -100
- package/es/components/common.js +0 -339
- package/es/widgets/CashierAccordion/Deposit/PaymentForm/NewTab.js +0 -28
- package/lib/components/AutocompleteInput/index.js +0 -118
- package/lib/components/Input/BirthdateInput.js +0 -195
- package/lib/components/Input/Checkbox.js +0 -65
- package/lib/components/Input/Input.js +0 -87
- package/lib/components/Input/PasswordInput.js +0 -101
- package/lib/components/Input/PhoneNumberInput.js +0 -130
- package/lib/components/Input/input.test.js +0 -89
- package/lib/components/Input/old-input.test.js +0 -107
- package/lib/components/common.js +0 -359
- package/lib/widgets/CashierAccordion/Deposit/PaymentForm/NewTab.js +0 -44
|
@@ -1,195 +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 _Translate = require('../Translate');
|
|
16
|
-
|
|
17
|
-
var _Translate2 = _interopRequireDefault(_Translate);
|
|
18
|
-
|
|
19
|
-
var _translate = require('../../lib/utils/translate');
|
|
20
|
-
|
|
21
|
-
var _translate2 = _interopRequireDefault(_translate);
|
|
22
|
-
|
|
23
|
-
var _classnames = require('classnames');
|
|
24
|
-
|
|
25
|
-
var _classnames2 = _interopRequireDefault(_classnames);
|
|
26
|
-
|
|
27
|
-
var _reactIntl = require('react-intl');
|
|
28
|
-
|
|
29
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
30
|
-
|
|
31
|
-
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; }
|
|
32
|
-
|
|
33
|
-
var pad = function pad(num) {
|
|
34
|
-
return ('' + num).length === 1 ? '0' + num : num;
|
|
35
|
-
};
|
|
36
|
-
var yearRange = new Array(100).fill(null, 0, 100).map(function (y, i) {
|
|
37
|
-
return new Date().getFullYear() - 18 - i;
|
|
38
|
-
});
|
|
39
|
-
var monthRange = new Array(12).fill(null, 0, 12).map(function (m, i) {
|
|
40
|
-
return i + 1;
|
|
41
|
-
});
|
|
42
|
-
var dayRange = new Array(31).fill(null, 0, 31).map(function (d, i) {
|
|
43
|
-
return i + 1;
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
var BirthdateInput = function BirthdateInput(props) {
|
|
47
|
-
var intl = (0, _reactIntl.useIntl)();
|
|
48
|
-
|
|
49
|
-
var yearInput = {
|
|
50
|
-
id: (0, _common.useId)(),
|
|
51
|
-
value: (0, _common.useValue)(props.value.split('/')[0]),
|
|
52
|
-
focus: (0, _common.useFocus)()
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
var monthInput = {
|
|
56
|
-
id: (0, _common.useId)(),
|
|
57
|
-
value: (0, _common.useValue)(props.value.split('/')[1]),
|
|
58
|
-
focus: (0, _common.useFocus)()
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
var dayInput = {
|
|
62
|
-
id: (0, _common.useId)(),
|
|
63
|
-
value: (0, _common.useValue)(props.value.split('/')[2]),
|
|
64
|
-
focus: (0, _common.useFocus)()
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
var createValue = function createValue() {
|
|
68
|
-
var _Object$values;
|
|
69
|
-
|
|
70
|
-
var id = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
71
|
-
var value = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
72
|
-
return Object.values((_Object$values = {}, _defineProperty(_Object$values, yearInput.id, yearInput.value.value), _defineProperty(_Object$values, monthInput.id, monthInput.value.value), _defineProperty(_Object$values, dayInput.id, dayInput.value.value), _defineProperty(_Object$values, id, value), _Object$values)).join('/');
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
var _onChange = function _onChange(e) {
|
|
76
|
-
return props.onChange && props.onChange(e, createValue(e.target.id, e.target.value));
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
var _onBlur = function _onBlur(e) {
|
|
80
|
-
return props.onBlur && props.onBlur(e, createValue(e.target.id, e.target.value));
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
var inputs = [yearInput, monthInput, dayInput];
|
|
84
|
-
var className = (0, _common.createClassName)('tg-birthdate-input', {
|
|
85
|
-
hasValue: inputs.some(function (i) {
|
|
86
|
-
return i.value.hasValue;
|
|
87
|
-
}),
|
|
88
|
-
hasFocus: inputs.some(function (i) {
|
|
89
|
-
return i.focus.hasFocus;
|
|
90
|
-
}),
|
|
91
|
-
status: props.status
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
return _react2.default.createElement(
|
|
95
|
-
'div',
|
|
96
|
-
{ className: (0, _classnames2.default)(props.className, className) },
|
|
97
|
-
_react2.default.createElement(
|
|
98
|
-
'label',
|
|
99
|
-
{ className: 'tg-birthdate-input__label' },
|
|
100
|
-
props.label
|
|
101
|
-
),
|
|
102
|
-
_react2.default.createElement(
|
|
103
|
-
_common.Select,
|
|
104
|
-
_extends({}, (0, _common.flatObj)(yearInput), {
|
|
105
|
-
autoFocus: props.autoFocus && !yearInput.value.hasValue,
|
|
106
|
-
name: props.name + '_year',
|
|
107
|
-
label: _react2.default.createElement(_Translate2.default, { id: 'label.year-of-birth', defaultMessage: 'Year' }),
|
|
108
|
-
status: props.status,
|
|
109
|
-
onChange: function onChange(e) {
|
|
110
|
-
yearInput.value.onChange(e.target.value);
|
|
111
|
-
_onChange(e);
|
|
112
|
-
},
|
|
113
|
-
onBlur: function onBlur(e) {
|
|
114
|
-
yearInput.focus.onBlur();
|
|
115
|
-
_onBlur(e);
|
|
116
|
-
} }),
|
|
117
|
-
!yearInput.value.hasValue && _react2.default.createElement(
|
|
118
|
-
_common.Select.Option,
|
|
119
|
-
{ value: '', selected: true, disabled: true },
|
|
120
|
-
(0, _translate2.default)({ id: 'label.year-of-birth', defaultMessage: 'Year' }, intl)
|
|
121
|
-
),
|
|
122
|
-
yearRange.map(function (y) {
|
|
123
|
-
return _react2.default.createElement(
|
|
124
|
-
_common.Select.Option,
|
|
125
|
-
{ key: y, value: y },
|
|
126
|
-
y
|
|
127
|
-
);
|
|
128
|
-
})
|
|
129
|
-
),
|
|
130
|
-
_react2.default.createElement(
|
|
131
|
-
_common.Select,
|
|
132
|
-
_extends({}, (0, _common.flatObj)(monthInput), {
|
|
133
|
-
autoFocus: props.autoFocus && yearInput.value.hasValue && !monthInput.value.hasValue,
|
|
134
|
-
name: props.name + '_month',
|
|
135
|
-
label: _react2.default.createElement(_Translate2.default, { id: 'label.month-of-birth', defaultMessage: 'Month' }),
|
|
136
|
-
status: props.status,
|
|
137
|
-
onChange: function onChange(e) {
|
|
138
|
-
monthInput.value.onChange(e.target.value);
|
|
139
|
-
_onChange(e);
|
|
140
|
-
},
|
|
141
|
-
onBlur: function onBlur(e) {
|
|
142
|
-
monthInput.focus.onBlur();
|
|
143
|
-
_onBlur(e);
|
|
144
|
-
} }),
|
|
145
|
-
!monthInput.value.hasValue && _react2.default.createElement(
|
|
146
|
-
_common.Select.Option,
|
|
147
|
-
{ value: '', selected: true, disabled: true },
|
|
148
|
-
(0, _translate2.default)({ id: 'label.month-of-birth', defaultMessage: 'Month' }, intl)
|
|
149
|
-
),
|
|
150
|
-
monthRange.map(function (m) {
|
|
151
|
-
return _react2.default.createElement(
|
|
152
|
-
_common.Select.Option,
|
|
153
|
-
{ key: m, value: pad(m) },
|
|
154
|
-
m
|
|
155
|
-
);
|
|
156
|
-
})
|
|
157
|
-
),
|
|
158
|
-
_react2.default.createElement(
|
|
159
|
-
_common.Select,
|
|
160
|
-
_extends({}, (0, _common.flatObj)(dayInput), {
|
|
161
|
-
autoFocus: props.autoFocus && yearInput.value.hasValue && monthInput.value.hasValue,
|
|
162
|
-
name: props.name + '_day',
|
|
163
|
-
label: _react2.default.createElement(_Translate2.default, { id: 'label.day-of-birth', defaultMessage: 'Day' }),
|
|
164
|
-
status: props.status,
|
|
165
|
-
onChange: function onChange(e) {
|
|
166
|
-
dayInput.value.onChange(e.target.value);
|
|
167
|
-
_onChange(e);
|
|
168
|
-
},
|
|
169
|
-
onBlur: function onBlur(e) {
|
|
170
|
-
dayInput.focus.onBlur();
|
|
171
|
-
_onBlur(e);
|
|
172
|
-
} }),
|
|
173
|
-
!dayInput.value.hasValue && _react2.default.createElement(
|
|
174
|
-
_common.Select.Option,
|
|
175
|
-
{ value: '', selected: true, disabled: true },
|
|
176
|
-
(0, _translate2.default)({ id: 'label.day-of-birth', defaultMessage: 'Day' }, intl)
|
|
177
|
-
),
|
|
178
|
-
dayRange.map(function (d) {
|
|
179
|
-
return _react2.default.createElement(
|
|
180
|
-
_common.Select.Option,
|
|
181
|
-
{ key: d, value: pad(d) },
|
|
182
|
-
d
|
|
183
|
-
);
|
|
184
|
-
})
|
|
185
|
-
),
|
|
186
|
-
_react2.default.createElement(_common.Input, { type: 'hidden', name: props.name, value: createValue() }),
|
|
187
|
-
_react2.default.createElement(
|
|
188
|
-
'div',
|
|
189
|
-
{ className: 'tg-birthdate-input__status-text' },
|
|
190
|
-
props.statusText
|
|
191
|
-
)
|
|
192
|
-
);
|
|
193
|
-
};
|
|
194
|
-
|
|
195
|
-
exports.default = BirthdateInput;
|
|
@@ -1,65 +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
|
-
var TGCheckbox = function TGCheckbox(props) {
|
|
22
|
-
var checkbox = {
|
|
23
|
-
id: (0, _common.useId)(),
|
|
24
|
-
value: (0, _common.useValue)(props.value),
|
|
25
|
-
focus: (0, _common.useFocus)(),
|
|
26
|
-
touched: (0, _common.useTouched)(),
|
|
27
|
-
autofill: (0, _common.useAutofill)()
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
var _onChange = function _onChange(e) {
|
|
31
|
-
return props.onChange && props.onChange(e, e.target.checked ? 'true' : '');
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
var className = (0, _common.createClassName)('tg-checkbox', {
|
|
35
|
-
hasValue: checkbox.value.hasValue,
|
|
36
|
-
hasLabel: Boolean(props.label),
|
|
37
|
-
hasFocus: checkbox.focus.hasFocus,
|
|
38
|
-
hasTouched: checkbox.touched.hasTouched,
|
|
39
|
-
hasAutofill: checkbox.autofill.hasAutofill,
|
|
40
|
-
disabled: props.disabled,
|
|
41
|
-
status: props.status
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
return _react2.default.createElement(
|
|
45
|
-
'div',
|
|
46
|
-
{ className: (0, _classnames2.default)(props.className, className) },
|
|
47
|
-
_react2.default.createElement(_common.Checkbox, _extends({}, props, (0, _common.flatObj)(checkbox), {
|
|
48
|
-
onChange: function onChange(e) {
|
|
49
|
-
checkbox.value.onChange(e.target.checked ? 'true' : '');
|
|
50
|
-
_onChange(e);
|
|
51
|
-
},
|
|
52
|
-
onFocus: function onFocus() {
|
|
53
|
-
checkbox.focus.onFocus();
|
|
54
|
-
checkbox.touched.onFocus();
|
|
55
|
-
}
|
|
56
|
-
})),
|
|
57
|
-
_react2.default.createElement(
|
|
58
|
-
'div',
|
|
59
|
-
{ className: 'tg-checkbox__status-text' },
|
|
60
|
-
props.statusText
|
|
61
|
-
)
|
|
62
|
-
);
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
exports.default = TGCheckbox;
|
|
@@ -1,87 +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 TGInput = function TGInput(_ref) {
|
|
24
|
-
var icon = _ref.icon,
|
|
25
|
-
props = _objectWithoutProperties(_ref, ['icon']);
|
|
26
|
-
|
|
27
|
-
var input = {
|
|
28
|
-
id: (0, _common.useId)(),
|
|
29
|
-
value: (0, _common.useValue)(props.value),
|
|
30
|
-
focus: (0, _common.useFocus)(),
|
|
31
|
-
touched: (0, _common.useTouched)(),
|
|
32
|
-
autofill: (0, _common.useAutofill)()
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
var _onChange = function _onChange(e) {
|
|
36
|
-
return props.onChange && props.onChange(e, e.target.value);
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
var _onBlur = function _onBlur(e) {
|
|
40
|
-
return props.onBlur && props.onBlur(e, e.target.value);
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
var className = (0, _common.createClassName)('tg-input', {
|
|
44
|
-
hasValue: input.value.hasValue,
|
|
45
|
-
hasLabel: Boolean(props.label),
|
|
46
|
-
hasFocus: input.focus.hasFocus,
|
|
47
|
-
hasTouched: input.touched.hasTouched,
|
|
48
|
-
hasAutofill: input.autofill.hasAutofill,
|
|
49
|
-
disabled: props.disabled,
|
|
50
|
-
status: props.status
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
return _react2.default.createElement(
|
|
54
|
-
'div',
|
|
55
|
-
{ className: (0, _classnames2.default)(props.className, className) },
|
|
56
|
-
_react2.default.createElement(_common.Input, _extends({}, props, (0, _common.flatObj)(input), {
|
|
57
|
-
onChange: function onChange(e) {
|
|
58
|
-
if (typeof props.transform === 'function') {
|
|
59
|
-
e.target.value = props.transform(e.target.value);
|
|
60
|
-
}
|
|
61
|
-
input.value.onChange(e.target.value);
|
|
62
|
-
_onChange(e);
|
|
63
|
-
},
|
|
64
|
-
onFocus: function onFocus() {
|
|
65
|
-
input.focus.onFocus();
|
|
66
|
-
input.touched.onFocus();
|
|
67
|
-
},
|
|
68
|
-
onBlur: function onBlur(e) {
|
|
69
|
-
input.focus.onBlur();
|
|
70
|
-
_onBlur(e);
|
|
71
|
-
},
|
|
72
|
-
leadingLane: [icon].filter(function (i) {
|
|
73
|
-
return i;
|
|
74
|
-
}),
|
|
75
|
-
trailingLane: [_common.statusIcons[props.status]].filter(function (i) {
|
|
76
|
-
return i;
|
|
77
|
-
})
|
|
78
|
-
})),
|
|
79
|
-
_react2.default.createElement(
|
|
80
|
-
'div',
|
|
81
|
-
{ className: 'tg-input__status-text' },
|
|
82
|
-
props.statusText
|
|
83
|
-
)
|
|
84
|
-
);
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
exports.default = TGInput;
|
|
@@ -1,101 +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 _Icon = require('../Icon');
|
|
14
|
-
|
|
15
|
-
var _Icon2 = _interopRequireDefault(_Icon);
|
|
16
|
-
|
|
17
|
-
var _common = require('../common');
|
|
18
|
-
|
|
19
|
-
var _classnames = require('classnames');
|
|
20
|
-
|
|
21
|
-
var _classnames2 = _interopRequireDefault(_classnames);
|
|
22
|
-
|
|
23
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
24
|
-
|
|
25
|
-
var PasswordInput = function PasswordInput(props) {
|
|
26
|
-
var input = {
|
|
27
|
-
id: (0, _common.useId)(),
|
|
28
|
-
value: (0, _common.useValue)(props.value),
|
|
29
|
-
focus: (0, _common.useFocus)(),
|
|
30
|
-
touched: (0, _common.useTouched)(),
|
|
31
|
-
type: (0, _common.useType)(props.type),
|
|
32
|
-
autofill: (0, _common.useAutofill)()
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
var _onChange = function _onChange(e) {
|
|
36
|
-
return props.onChange && props.onChange(e, e.target.value);
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
var _onBlur = function _onBlur(e) {
|
|
40
|
-
return props.onBlur && props.onBlur(e, e.target.value);
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
var togglePasswordVisibility = function togglePasswordVisibility() {
|
|
44
|
-
return input.type.setType(input.type.type === 'password' ? 'text' : 'password');
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
var icons = {
|
|
48
|
-
password: _react2.default.createElement(_Icon2.default, {
|
|
49
|
-
icon: 'eye-slash',
|
|
50
|
-
className: 'tg-password-input__toggle',
|
|
51
|
-
onClick: togglePasswordVisibility
|
|
52
|
-
}),
|
|
53
|
-
text: _react2.default.createElement(_Icon2.default, {
|
|
54
|
-
icon: 'eye',
|
|
55
|
-
className: 'tg-password-input__toggle',
|
|
56
|
-
onClick: togglePasswordVisibility
|
|
57
|
-
})
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
var className = (0, _common.createClassName)('tg-password-input', {
|
|
61
|
-
hasValue: input.value.hasValue,
|
|
62
|
-
hasLabel: Boolean(props.label),
|
|
63
|
-
hasFocus: input.focus.hasFocus,
|
|
64
|
-
hasTouched: input.touched.hasTouched,
|
|
65
|
-
hasAutofill: input.autofill.hasAutofill,
|
|
66
|
-
disabled: props.disabled,
|
|
67
|
-
status: props.status
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
return _react2.default.createElement(
|
|
71
|
-
'div',
|
|
72
|
-
{ className: (0, _classnames2.default)(props.className, className) },
|
|
73
|
-
_react2.default.createElement(_common.Input, _extends({}, props, (0, _common.flatObj)(input), {
|
|
74
|
-
onChange: function onChange(e) {
|
|
75
|
-
input.value.onChange(e.target.value);
|
|
76
|
-
_onChange(e);
|
|
77
|
-
},
|
|
78
|
-
onFocus: function onFocus() {
|
|
79
|
-
input.focus.onFocus();
|
|
80
|
-
input.touched.onFocus();
|
|
81
|
-
},
|
|
82
|
-
onBlur: function onBlur(e) {
|
|
83
|
-
input.focus.onBlur();
|
|
84
|
-
_onBlur(e);
|
|
85
|
-
},
|
|
86
|
-
leadingLane: [props.icon].filter(function (i) {
|
|
87
|
-
return i;
|
|
88
|
-
}),
|
|
89
|
-
trailingLane: [icons[input.type.type], _common.statusIcons[props.status]].filter(function (i) {
|
|
90
|
-
return i;
|
|
91
|
-
})
|
|
92
|
-
})),
|
|
93
|
-
_react2.default.createElement(
|
|
94
|
-
'div',
|
|
95
|
-
{ className: 'tg-password-input__status-text' },
|
|
96
|
-
props.statusText
|
|
97
|
-
)
|
|
98
|
-
);
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
exports.default = PasswordInput;
|
|
@@ -1,130 +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 _Translate = require('../Translate');
|
|
16
|
-
|
|
17
|
-
var _Translate2 = _interopRequireDefault(_Translate);
|
|
18
|
-
|
|
19
|
-
var _classnames = require('classnames');
|
|
20
|
-
|
|
21
|
-
var _classnames2 = _interopRequireDefault(_classnames);
|
|
22
|
-
|
|
23
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
24
|
-
|
|
25
|
-
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; }
|
|
26
|
-
|
|
27
|
-
var PhoneNumberInput = function PhoneNumberInput(props) {
|
|
28
|
-
var val = props.value || '';
|
|
29
|
-
|
|
30
|
-
var callingCodeValue = ((props.callingCodes || []).slice().sort(function (a, b) {
|
|
31
|
-
return b.value - a.value;
|
|
32
|
-
}).find(function (c) {
|
|
33
|
-
return val.startsWith(c.value);
|
|
34
|
-
}) || (props.callingCodes || [])[0] || {}).value || '';
|
|
35
|
-
var phoneNumberValue = callingCodeValue ? val.replace(new RegExp('^' + callingCodeValue), '').replace(/^0*/, '') : val;
|
|
36
|
-
|
|
37
|
-
var callingCodeSelect = {
|
|
38
|
-
id: (0, _common.useId)(),
|
|
39
|
-
value: (0, _common.useValue)(callingCodeValue),
|
|
40
|
-
focus: (0, _common.useFocus)()
|
|
41
|
-
};
|
|
42
|
-
var phoneNumberInput = {
|
|
43
|
-
id: (0, _common.useId)(),
|
|
44
|
-
value: (0, _common.useValue)(phoneNumberValue),
|
|
45
|
-
focus: (0, _common.useFocus)()
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
var createValue = function createValue() {
|
|
49
|
-
var _Object$values;
|
|
50
|
-
|
|
51
|
-
var id = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
52
|
-
var value = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
53
|
-
return Object.values((_Object$values = {}, _defineProperty(_Object$values, callingCodeSelect.id, callingCodeSelect.value.value), _defineProperty(_Object$values, phoneNumberInput.id, phoneNumberInput.value.value), _defineProperty(_Object$values, id, value), _Object$values)).join('');
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
var _onChange = function _onChange(e) {
|
|
57
|
-
return props.onChange && props.onChange(e, createValue(e.target.id, e.target.value));
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
var _onBlur = function _onBlur(e) {
|
|
61
|
-
return props.onBlur && props.onBlur(e, createValue(e.target.id, e.target.value));
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
var inputs = [callingCodeSelect, phoneNumberInput];
|
|
65
|
-
var className = (0, _common.createClassName)('tg-phonenumber-input', {
|
|
66
|
-
hasValue: inputs.some(function (i) {
|
|
67
|
-
return i.value.hasValue;
|
|
68
|
-
}),
|
|
69
|
-
hasFocus: inputs.some(function (i) {
|
|
70
|
-
return i.focus.hasFocus;
|
|
71
|
-
}),
|
|
72
|
-
status: props.status
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
return _react2.default.createElement(
|
|
76
|
-
'div',
|
|
77
|
-
{ className: (0, _classnames2.default)(props.className, className) },
|
|
78
|
-
callingCodeSelect.value.hasValue && _react2.default.createElement(
|
|
79
|
-
_common.Select,
|
|
80
|
-
_extends({}, (0, _common.flatObj)(callingCodeSelect), {
|
|
81
|
-
name: props.name + '_calling-code',
|
|
82
|
-
label: _react2.default.createElement(_Translate2.default, { id: 'label.calling-code', defaultMessage: 'Calling code' }),
|
|
83
|
-
onChange: function onChange(e) {
|
|
84
|
-
callingCodeSelect.value.onChange(e.target.value);
|
|
85
|
-
_onChange(e);
|
|
86
|
-
},
|
|
87
|
-
onBlur: function onBlur(e) {
|
|
88
|
-
callingCodeSelect.focus.onBlur();
|
|
89
|
-
_onBlur(e);
|
|
90
|
-
},
|
|
91
|
-
status: props.status }),
|
|
92
|
-
(props.callingCodes || []).map(function (c, i) {
|
|
93
|
-
return _react2.default.createElement(
|
|
94
|
-
_common.Select.Option,
|
|
95
|
-
{ key: c.value + i, value: c.value },
|
|
96
|
-
c.label
|
|
97
|
-
);
|
|
98
|
-
})
|
|
99
|
-
),
|
|
100
|
-
_react2.default.createElement(_common.Input, _extends({}, (0, _common.flatObj)(phoneNumberInput), {
|
|
101
|
-
autoFocus: props.autoFocus,
|
|
102
|
-
type: 'tel',
|
|
103
|
-
name: props.name + '_number',
|
|
104
|
-
label: _react2.default.createElement(_Translate2.default, {
|
|
105
|
-
id: 'label.mobile_number',
|
|
106
|
-
defaultMessage: 'MobilePhoneNumber'
|
|
107
|
-
}),
|
|
108
|
-
onChange: function onChange(e) {
|
|
109
|
-
phoneNumberInput.value.onChange(e.target.value);
|
|
110
|
-
_onChange(e);
|
|
111
|
-
},
|
|
112
|
-
onBlur: function onBlur(e) {
|
|
113
|
-
phoneNumberInput.focus.onBlur();
|
|
114
|
-
_onBlur(e);
|
|
115
|
-
},
|
|
116
|
-
status: props.status,
|
|
117
|
-
trailingLane: [_common.statusIcons[props.status]].filter(function (i) {
|
|
118
|
-
return i;
|
|
119
|
-
})
|
|
120
|
-
})),
|
|
121
|
-
_react2.default.createElement(_common.Input, { type: 'hidden', name: props.name, value: createValue() }),
|
|
122
|
-
_react2.default.createElement(
|
|
123
|
-
'div',
|
|
124
|
-
{ className: 'tg-phonenumber-input__status-text' },
|
|
125
|
-
props.statusText
|
|
126
|
-
)
|
|
127
|
-
);
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
exports.default = PhoneNumberInput;
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var _react = require('react');
|
|
4
|
-
|
|
5
|
-
var _react2 = _interopRequireDefault(_react);
|
|
6
|
-
|
|
7
|
-
var _react3 = require('@testing-library/react');
|
|
8
|
-
|
|
9
|
-
require('@testing-library/jest-dom/extend-expect');
|
|
10
|
-
|
|
11
|
-
var _index = require('./index.js');
|
|
12
|
-
|
|
13
|
-
var _index2 = _interopRequireDefault(_index);
|
|
14
|
-
|
|
15
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
|
-
|
|
17
|
-
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"); }); }; }
|
|
18
|
-
|
|
19
|
-
test('text has value and associated label', _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
|
|
20
|
-
var input;
|
|
21
|
-
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
22
|
-
while (1) {
|
|
23
|
-
switch (_context.prev = _context.next) {
|
|
24
|
-
case 0:
|
|
25
|
-
(0, _react3.render)(_react2.default.createElement(_index2.default, { type: 'text', label: 'input label', value: '1337' }));
|
|
26
|
-
input = _react3.screen.getByLabelText('input label');
|
|
27
|
-
|
|
28
|
-
_react3.fireEvent.click(input);
|
|
29
|
-
expect(input).toHaveValue('1337');
|
|
30
|
-
|
|
31
|
-
case 4:
|
|
32
|
-
case 'end':
|
|
33
|
-
return _context.stop();
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}, _callee, undefined);
|
|
37
|
-
})));
|
|
38
|
-
|
|
39
|
-
test('text input has placeholder', _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
|
|
40
|
-
var input;
|
|
41
|
-
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
42
|
-
while (1) {
|
|
43
|
-
switch (_context2.prev = _context2.next) {
|
|
44
|
-
case 0:
|
|
45
|
-
(0, _react3.render)(_react2.default.createElement(_index2.default, {
|
|
46
|
-
type: 'text',
|
|
47
|
-
label: 'input label',
|
|
48
|
-
placeholder: 'Placeholder text',
|
|
49
|
-
value: '1337'
|
|
50
|
-
}));
|
|
51
|
-
input = _react3.screen.getByPlaceholderText('Placeholder text');
|
|
52
|
-
|
|
53
|
-
expect(input).toHaveValue('1337');
|
|
54
|
-
|
|
55
|
-
case 3:
|
|
56
|
-
case 'end':
|
|
57
|
-
return _context2.stop();
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}, _callee2, undefined);
|
|
61
|
-
})));
|
|
62
|
-
|
|
63
|
-
test('text input has correct class names', _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3() {
|
|
64
|
-
var input;
|
|
65
|
-
return regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
66
|
-
while (1) {
|
|
67
|
-
switch (_context3.prev = _context3.next) {
|
|
68
|
-
case 0:
|
|
69
|
-
(0, _react3.render)(_react2.default.createElement(_index2.default, {
|
|
70
|
-
type: 'text',
|
|
71
|
-
label: 'input label',
|
|
72
|
-
placeholder: 'Placeholder text',
|
|
73
|
-
value: '1337'
|
|
74
|
-
}));
|
|
75
|
-
input = _react3.screen.getByLabelText('input label');
|
|
76
|
-
|
|
77
|
-
expect(input.parentElement.parentElement).toHaveClass('DefaultInput');
|
|
78
|
-
_react3.fireEvent.click(input);
|
|
79
|
-
(0, _react3.waitFor)(function () {
|
|
80
|
-
return expect(input.parentElement).toHaveClass('Input--has-focus');
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
case 5:
|
|
84
|
-
case 'end':
|
|
85
|
-
return _context3.stop();
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
}, _callee3, undefined);
|
|
89
|
-
})));
|